:root {
    --bg-dark: #111213;
    --fg-light: #d6d6d6;
    --matrix-green: #39FF14;
    --accent-light: #0b57d0;

    --font-size-xl: 1.8rem;
    --font-size-md: 1.15rem;
    --font-size-base: 0.9rem;
    --font-size-sm: 0.8rem;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: var(--font-size-base);
    line-height: 1.4;
}

body {
    margin: 50px auto;
    max-width: 650px;
    padding: 0 10px;
    background: var(--bg-dark);
    color: var(--fg-light);
    font-family: "SF Mono", "SFMono-Regular", ui-monospace, Menlo, Consolas, "Liberation Mono", monospace;
    -webkit-font-smoothing: antialiased;
}

body.light {
    background: #f6f6f6;
    color: #1f1f1f;
}

body.light a {
    color: var(--accent-light);
}

body.light footer,
body.light .post-meta,
body.light .post-excerpt,
body.light .search-input,
body.light .comment-date,
body.light .comment-body {
    color: #4a4a4a;
}

body.light .search-input {
    border-color: #d0d0d0;
}

body.light .comment-form textarea,
body.light .comment-form button {
    border-color: #d0d0d0;
    color: #1f1f1f;
}

body.light .stat-card {
    border-color: #d0d0d0;
}

a {
    color: var(--matrix-green);
    text-decoration: none;
    word-break: break-word;
}

a:hover,
a:focus {
    text-decoration: underline;
}

.container {
    max-width: 42em;
    margin: 0 auto;
}

header {
    text-align: center;
    margin-bottom: 26px;
}

header h1 {
    margin: 0 0 18px;
    font-size: var(--font-size-xl);
    letter-spacing: -0.01em;
    font-weight: normal;
}

header h1 a {
    color: inherit;
    text-decoration: none;
}

header p {
    margin-bottom: 18px;
}

nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 28px;
}

nav button,
nav a {
    border: 0;
    background: transparent;
    font-size: var(--font-size-md);
    cursor: pointer;
    padding: 6px;
    color: var(--matrix-green);
    text-decoration: none;
    font-family: inherit;
    opacity: 0.85;
}

body.light nav button,
body.light nav a {
    color: var(--accent-light);
}

nav button:hover,
nav a:hover {
    opacity: 1;
}

.post-list {
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

.post-item {
    padding-bottom: 2rem;
    border-bottom: 1px solid #2a2a2a;
}

body.light .post-item {
    border-color: #e0e0e0;
}

.post-item:last-child {
    border-bottom: none;
}

.post-title {
    font-size: var(--font-size-md);
    margin-bottom: 0.35rem;
    font-weight: normal;
    letter-spacing: -0.01em;
}

.post-title a {
    color: var(--matrix-green);
    text-decoration: none;
}

.post-title a:hover {
    text-decoration: underline;
    opacity: 0.85;
}

body.light .post-title a {
    color: var(--accent-light);
}

.post-meta {
    color: var(--fg-light);
    opacity: 0.6;
    margin-bottom: 0.5rem;
    letter-spacing: 0.01em;
    font-size: var(--font-size-sm);
}

.post-excerpt {
    color: var(--fg-light);
    opacity: 0.8;
    line-height: 1.6;
}

.post-content {
    line-height: 1.7;
}

.post-content .post-header {
    margin-bottom: 2rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid #2a2a2a;
}

body.light .post-content .post-header {
    border-color: #e0e0e0;
}

.post-content .post-title-main {
    font-size: var(--font-size-md);
    letter-spacing: -0.01em;
    margin-bottom: 0;
    line-height: 1.3;
}

.post-content .post-meta-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 0.5rem;
}

.post-content .post-title-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
    margin-bottom: 0.5rem;
}

.post-content .post-date {
    opacity: 0.6;
    font-size: var(--font-size-sm);
}

.post-content h1,
.post-content h2,
.post-content h3 {
    margin: 18px 0 6px;
    font-size: var(--font-size-base);
    text-align: left;
    font-weight: normal;
}

.post-content h2 {
    font-size: var(--font-size-md);
    letter-spacing: 0.36em;
    text-transform: uppercase;
    margin: 32px 0 14px;
}

.post-content p {
    margin: 0 0 18px;
}

.post-content blockquote {
    border-left: 2px solid var(--matrix-green);
    padding-left: 1rem;
    margin: 1.5rem 0;
    font-style: italic;
    opacity: 0.8;
}

body.light .post-content blockquote {
    border-color: var(--accent-light);
}

.post-content code {
    font-family: inherit;
    font-size: 0.85em;
    background: rgba(255, 255, 255, 0.1);
    padding: 0.15rem 0.35rem;
    border-radius: 2px;
}

body.light .post-content code {
    background: rgba(0, 0, 0, 0.1);
}

.post-content pre {
    background: rgba(255, 255, 255, 0.05);
    padding: 1rem;
    overflow-x: auto;
    line-height: 1.5;
    margin-bottom: 1.25rem;
    border-radius: 3px;
}

body.light .post-content pre {
    background: rgba(0, 0, 0, 0.05);
}

.post-content img {
    max-width: 100%;
    height: auto;
    margin: 1.5rem 0;
}

.post-content ul,
.post-content ol {
    margin: 0 0 18px;
    padding-left: 20px;
}

.post-content li {
    margin-bottom: 0.5rem;
}

.post-content hr {
    border: none;
    border-top: 1px solid #2a2a2a;
    margin: 2rem 0;
}

body.light .post-content hr {
    border-color: #e0e0e0;
}

.post-back {
    margin-bottom: 2rem;
}

.post-back a {
    color: var(--matrix-green);
    opacity: 0.85;
    text-decoration: none;
}

body.light .post-back a {
    color: var(--accent-light);
}

.post-back a:hover {
    opacity: 1;
}

.share-btn {
    padding: 0.2rem 0.5rem;
    font-family: inherit;
    font-size: var(--font-size-sm);
    background: transparent;
    border: 1px solid var(--matrix-green);
    cursor: pointer;
    color: var(--matrix-green);
    opacity: 0.85;
    transition: opacity 0.15s ease;
    flex-shrink: 0;
}

body.light .share-btn {
    border-color: var(--accent-light);
    color: var(--accent-light);
}

.share-btn:hover {
    opacity: 1;
}

.share-btn.shared {
    opacity: 1;
}

.footer {
    margin-top: 42px;
    text-align: left;
    opacity: 0.6;
    font-size: var(--font-size-sm);
}

.archive-filter {
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    opacity: 0.85;
}

.clear-filter-btn {
    background: transparent;
    border: 1px solid var(--matrix-green);
    color: var(--matrix-green);
    font-family: inherit;
    font-size: var(--font-size-sm);
    padding: 0.2rem 0.5rem;
    cursor: pointer;
    opacity: 0.85;
}

body.light .clear-filter-btn {
    border-color: var(--accent-light);
    color: var(--accent-light);
}

.clear-filter-btn:hover {
    opacity: 1;
}

.archive-list {
    list-style: none;
    margin-top: 1rem;
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.archive-list a {
    color: var(--matrix-green);
    opacity: 0.85;
    font-size: var(--font-size-sm);
}

body.light .archive-list a {
    color: var(--accent-light);
}

.archive-list a:hover {
    opacity: 1;
}

.search-form {
    margin-bottom: 2rem;
}

.search-input {
    width: 100%;
    padding: 0.6rem 0;
    font-family: inherit;
    background: transparent;
    border: none;
    border-bottom: 1px solid #2a2a2a;
    color: var(--fg-light);
}

.search-input:focus {
    outline: none;
    border-color: var(--matrix-green);
}

body.light .search-input:focus {
    border-color: var(--accent-light);
}

.search-input::placeholder {
    color: var(--fg-light);
    opacity: 0.5;
}

body.light .search-input::placeholder {
    color: #4a4a4a;
}

.comments-section {
    margin-top: 3rem;
    padding-top: 2rem;
    border-top: 1px solid #2a2a2a;
}

body.light .comments-section {
    border-color: #e0e0e0;
}

.comments-section h3 {
    font-size: var(--font-size-md);
    margin-bottom: 1.5rem;
    font-weight: normal;
}

.comment {
    margin-bottom: 1.5rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid #2a2a2a;
}

body.light .comment {
    border-color: #e0e0e0;
}

.comment:last-child {
    border-bottom: none;
}

.comment-avatar {
    display: inline-block;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--matrix-green);
    color: var(--bg-dark);
    text-align: center;
    line-height: 32px;
    font-weight: bold;
    margin-right: 0.5rem;
}

body.light .comment-avatar {
    background: var(--accent-light);
    color: #fff;
}

.comment-avatar img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
}

.comment-header {
    display: flex;
    gap: 0.75rem;
    margin-bottom: 0.4rem;
    align-items: center;
}

.comment-author {
    font-weight: normal;
}

.comment-date {
    color: var(--fg-light);
    opacity: 0.6;
    font-size: var(--font-size-sm);
}

.comment-actions {
    margin-left: auto;
    display: flex;
    gap: 0.5rem;
}

.comment-action-btn {
    background: transparent;
    border: none;
    color: var(--matrix-green);
    cursor: pointer;
    font-family: inherit;
    font-size: var(--font-size-sm);
    opacity: 0.7;
    padding: 0;
}

body.light .comment-action-btn {
    color: var(--accent-light);
}

.comment-action-btn:hover {
    opacity: 1;
}

.comment-edit-textarea {
    width: 100%;
    padding: 0.5rem;
    font-family: inherit;
    background: transparent;
    border: 1px solid #2a2a2a;
    color: var(--fg-light);
    resize: vertical;
    min-height: 60px;
    margin-bottom: 0.5rem;
}

body.light .comment-edit-textarea {
    border-color: #e0e0e0;
    color: #1f1f1f;
}

.comment-edit-actions {
    display: flex;
    gap: 0.5rem;
}

.comment-body {
    color: var(--fg-light);
    opacity: 0.85;
    line-height: 1.6;
}

.comment-form {
    margin-top: 2rem;
}

.comment-form textarea {
    width: 100%;
    padding: 0.75rem;
    font-family: inherit;
    background: transparent;
    border: 1px solid #2a2a2a;
    color: var(--fg-light);
    resize: vertical;
    min-height: 100px;
}

.comment-form textarea:focus {
    outline: none;
    border-color: var(--matrix-green);
}

body.light .comment-form textarea:focus {
    border-color: var(--accent-light);
}

.comment-form button {
    margin-top: 0.75rem;
    padding: 0.5rem 1rem;
    font-family: inherit;
    background: transparent;
    border: 1px solid #2a2a2a;
    cursor: pointer;
    color: var(--fg-light);
}

.comment-form button:hover {
    border-color: var(--matrix-green);
    color: var(--matrix-green);
}

body.light .comment-form button:hover {
    border-color: var(--accent-light);
    color: var(--accent-light);
}

.login-prompt {
    margin-top: 1.5rem;
    opacity: 0.85;
    font-size: var(--font-size-sm);
}

.login-prompt a {
    color: var(--matrix-green);
}

body.light .login-prompt a {
    color: var(--accent-light);
}

.hidden {
    display: none !important;
}

.toast-container {
    position: fixed;
    top: 1.5rem;
    right: 1.5rem;
    z-index: 1000;
}

.toast {
    background: var(--bg-dark);
    border: 1px solid var(--matrix-green);
    padding: 0.75rem 1rem;
    margin-top: 0.5rem;
    animation: toast-in 0.2s ease;
}

body.light .toast {
    background: #f6f6f6;
    border-color: var(--accent-light);
}

@keyframes toast-in {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.admin-tabs {
    display: flex;
    gap: 1rem;
    margin-bottom: 2rem;
    border-bottom: 1px solid #2a2a2a;
    padding-bottom: 0.5rem;
}

body.light .admin-tabs {
    border-color: #e0e0e0;
}

.admin-tab {
    padding: 0.5rem 1rem;
    background: transparent;
    border: none;
    cursor: pointer;
    color: var(--fg-light);
    opacity: 0.7;
    font-family: inherit;
    transition: opacity 0.15s ease;
}

body.light .admin-tab {
    color: #1f1f1f;
}

.admin-tab:hover {
    opacity: 1;
}

.admin-tab.active {
    opacity: 1;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
    margin-bottom: 2rem;
}

.stat-card {
    padding: 1rem;
    border: 1px solid #2a2a2a;
}

body.light .stat-card {
    border-color: #e0e0e0;
}

.stat-value {
    font-size: var(--font-size-md);
    font-weight: normal;
}

.stat-label {
    opacity: 0.6;
    font-size: var(--font-size-sm);
}

@media (max-width: 640px) {
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

.form-group {
    margin-bottom: 1.5rem;
}

.form-input {
    width: 100%;
    padding: 0.75rem;
    font-family: inherit;
    background: transparent;
    border: 1px solid #2a2a2a;
    color: var(--fg-light);
}

body.light .form-input {
    border-color: #e0e0e0;
    color: #1f1f1f;
}

.form-input:focus {
    outline: none;
    border-color: var(--matrix-green);
}

body.light .form-input:focus {
    border-color: var(--accent-light);
}

.btn {
    padding: 0.5rem 1rem;
    font-family: inherit;
    background: transparent;
    border: 1px solid #2a2a2a;
    cursor: pointer;
    color: var(--fg-light);
}

body.light .btn {
    border-color: #e0e0e0;
    color: #1f1f1f;
}

.btn:hover {
    border-color: var(--matrix-green);
    color: var(--matrix-green);
}

body.light .btn:hover {
    border-color: var(--accent-light);
    color: var(--accent-light);
}

.user-item,
.post-item-admin {
    padding: 1rem 0;
    border-bottom: 1px solid #2a2a2a;
}

body.light .user-item,
body.light .post-item-admin {
    border-color: #e0e0e0;
}

.ql-youtube {
    padding: 0 8px;
    font-size: 16px;
}

.ql-container {
    font-family: inherit !important;
}

@media (max-width: 600px) {
    body {
        margin: 30px auto;
        padding: 0 15px;
    }

    header h1 {
        font-size: 1.5rem;
    }
}

/* Reading Enhancements */
.reading-progress-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 3px;
    background: transparent;
    z-index: 9999;
}

.reading-progress-bar {
    height: 100%;
    width: 0%;
    background: var(--matrix-green);
    transition: width 0.1s;
}

body.light .reading-progress-bar {
    background: var(--accent-light);
}

.scroll-to-top {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--bg-dark);
    border: 1px solid var(--matrix-green);
    color: var(--matrix-green);
    font-size: 1.2rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s, visibility 0.3s, background 0.3s;
}

body.light .scroll-to-top {
    background: #f6f6f6;
    border-color: var(--accent-light);
    color: var(--accent-light);
}

.scroll-to-top.visible {
    visibility: visible;
    opacity: 0.8;
}

.scroll-to-top.visible:hover {
    opacity: 1;
    background: var(--matrix-green);
    color: var(--bg-dark);
}

body.light .scroll-to-top.visible:hover {
    background: var(--accent-light);
    color: #fff;
}

@media (max-width: 600px) {
    .scroll-to-top {
        bottom: 1rem;
        right: 1rem;
    }
}