/* =============================================================
   Ali's Intel Log — stylesheet
   Typography-first. Dark by default, real light mode.
   ============================================================= */

:root {
    --bg:          #0c0e12;
    --surface:     #14171d;
    --surface-2:   #1a1e26;
    --border:      #252a34;
    --border-soft: #1d222b;
    --text:        #e8ebf0;
    --text-2:      #b3bcc9;
    --muted:       #7f8a9a;
    --accent:      #4ade80;
    --accent-dim:  #1c3a29;
    --accent-text: #4ade80;
    --warn:        #fbbf24;
    --warn-dim:    #3a2f10;
    --danger:      #f87171;
    --danger-dim:  #3a1c1c;
    --link:        #7dd3fc;

    --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;

    --wrap: 1140px;
    --measure: 68ch;
    --radius: 8px;
}

[data-theme="light"] {
    --bg:          #ffffff;
    --surface:     #f8f9fb;
    --surface-2:   #f1f3f7;
    --border:      #e0e4ea;
    --border-soft: #eaedf2;
    --text:        #14171c;
    --text-2:      #414855;
    --muted:       #6b7382;
    --accent:      #059669;
    --accent-dim:  #d9f5e6;
    --accent-text: #047857;
    --warn:        #b45309;
    --warn-dim:    #fdf0d5;
    --danger:      #dc2626;
    --danger-dim:  #fde8e8;
    --link:        #0369a1;
}

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

html { scroll-behavior: smooth; scroll-padding-top: 90px; -webkit-text-size-adjust: 100%; }

body {
    background: var(--bg);
    color: var(--text);
    font-family: var(--font);
    font-size: 17px;
    line-height: 1.7;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }

img { max-width: 100%; height: auto; }

.wrap { max-width: var(--wrap); margin: 0 auto; padding: 0 24px; }
.wrap.narrow { max-width: 780px; }

.skip-link {
    position: absolute; left: -9999px; top: 0; z-index: 999;
    background: var(--accent); color: #04140c; padding: 10px 16px; border-radius: 0 0 var(--radius) 0;
}
.skip-link:focus { left: 0; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 3px; }

/* ---------- Header ---------- */
.site-header {
    position: sticky; top: 0; z-index: 100;
    background: color-mix(in srgb, var(--bg) 88%, transparent);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border-soft);
}
.header-inner { display: flex; align-items: center; gap: 24px; height: 60px; }

.brand { font-family: var(--mono); font-size: 15px; font-weight: 700; color: var(--text); text-decoration: none; white-space: nowrap; }
.brand:hover { text-decoration: none; }
.brand-mark { color: var(--accent); }

.site-nav { display: flex; gap: 22px; margin-left: 8px; flex: 1; }
.site-nav a { color: var(--text-2); font-size: 14.5px; text-decoration: none; }
.site-nav a:hover { color: var(--text); text-decoration: none; }

.header-tools { display: flex; align-items: center; gap: 8px; }

.search-trigger {
    display: inline-flex; align-items: center; gap: 8px;
    background: var(--surface); border: 1px solid var(--border); color: var(--muted);
    border-radius: var(--radius); padding: 6px 10px; font: inherit; font-size: 13.5px; cursor: pointer;
}
.search-trigger:hover { border-color: var(--accent); color: var(--text-2); }
.search-trigger kbd {
    font-family: var(--mono); font-size: 11px; border: 1px solid var(--border);
    border-radius: 4px; padding: 0 5px; color: var(--muted);
}

.theme-toggle, .nav-toggle {
    background: none; border: 1px solid var(--border); color: var(--text-2);
    border-radius: var(--radius); width: 34px; height: 32px; cursor: pointer;
    display: inline-flex; align-items: center; justify-content: center;
}
.theme-toggle:hover, .nav-toggle:hover { color: var(--text); border-color: var(--accent); }
.nav-toggle { display: none; }
[data-theme="dark"] .icon-sun { display: none; }
[data-theme="light"] .icon-moon { display: none; }

/* ---------- Search overlay ---------- */
.search-overlay {
    position: fixed; inset: 0; z-index: 200;
    background: rgba(0,0,0,.6); backdrop-filter: blur(4px);
    display: flex; align-items: flex-start; justify-content: center; padding: 12vh 20px;
}
.search-overlay[hidden] { display: none; }
.search-panel {
    width: 100%; max-width: 620px; background: var(--surface);
    border: 1px solid var(--border); border-radius: 12px; overflow: hidden;
}
.search-form { display: flex; align-items: center; gap: 12px; padding: 14px 16px; color: var(--muted); }
.search-form input {
    flex: 1; background: none; border: none; color: var(--text);
    font: inherit; font-size: 17px; outline: none; padding: 0;
}
.search-close {
    background: none; border: 1px solid var(--border); color: var(--muted);
    font: inherit; font-size: 11px; font-family: var(--mono);
    padding: 3px 7px; border-radius: 4px; cursor: pointer;
}
.search-results { max-height: 55vh; overflow-y: auto; }
.search-results:not(:empty) { border-top: 1px solid var(--border); }
.search-result { display: block; padding: 12px 16px; border-bottom: 1px solid var(--border-soft); text-decoration: none; }
.search-result:hover, .search-result.is-active { background: var(--surface-2); text-decoration: none; }
.search-result strong { display: block; color: var(--text); font-size: 15px; font-weight: 600; }
.search-result span { display: block; color: var(--muted); font-size: 13px; margin-top: 2px; }
.search-empty { padding: 20px 16px; color: var(--muted); font-size: 14px; text-align: center; }

/* ---------- Hero ---------- */
.hero { padding: 64px 24px 40px; max-width: 900px; }
.hero-title { font-size: clamp(28px, 4.5vw, 42px); line-height: 1.2; letter-spacing: -0.02em; font-weight: 700; }
.hero-sub { color: var(--text-2); font-size: 18px; margin-top: 14px; max-width: 60ch; }

/* ---------- Layout ---------- */
.layout { display: grid; grid-template-columns: minmax(0,1fr) 280px; gap: 56px; padding-bottom: 80px; }
.layout-side { display: flex; flex-direction: column; gap: 20px; align-self: start; position: sticky; top: 88px; }

.eyebrow {
    font-family: var(--mono); font-size: 11px; letter-spacing: .12em; text-transform: uppercase;
    color: var(--accent); margin-bottom: 10px;
}

/* ---------- Featured + post list ---------- */
.featured { padding-bottom: 36px; border-bottom: 1px solid var(--border); margin-bottom: 36px; }
.featured-title { font-size: clamp(24px, 3vw, 32px); line-height: 1.25; letter-spacing: -0.015em; }
.featured-title a { color: var(--text); }
.featured-title a:hover { color: var(--accent); text-decoration: none; }
.featured-excerpt { color: var(--text-2); margin-top: 12px; font-size: 17px; max-width: 62ch; }

.section-title { font-size: 14px; text-transform: uppercase; letter-spacing: .1em; color: var(--muted);
    font-weight: 600; margin: 40px 0 20px; font-family: var(--mono); }
.section-title .count { color: var(--accent); }

.post-list { display: flex; flex-direction: column; }
.post-item { padding: 22px 0; border-bottom: 1px solid var(--border-soft); }
.post-item:last-child { border-bottom: none; }
.post-item h3 { font-size: 19px; line-height: 1.4; font-weight: 600; }
.post-item h3 a { color: var(--text); }
.post-item h3 a:hover { color: var(--accent); text-decoration: none; }
.post-excerpt { color: var(--text-2); font-size: 15.5px; margin-top: 6px; max-width: 65ch; }

.meta {
    display: flex; align-items: center; flex-wrap: wrap; gap: 14px;
    font-family: var(--mono); font-size: 12.5px; color: var(--muted); margin-top: 10px;
}

/* ---------- Tags ---------- */
.tag-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.tag {
    display: inline-flex; align-items: center; gap: 6px;
    background: var(--accent-dim); color: var(--accent-text);
    font-size: 12.5px; padding: 3px 10px; border-radius: 20px; text-decoration: none;
}
.tag:hover { text-decoration: none; filter: brightness(1.15); }
.tag-sm { font-size: 11.5px; padding: 2px 8px; }
.tag-warn { background: var(--warn-dim); color: var(--warn); }
.tag-n { opacity: .65; font-family: var(--mono); font-size: 11px; }

/* ---------- Sidebar cards ---------- */
.side-card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 18px; }
.side-heading {
    font-family: var(--mono); font-size: 11px; letter-spacing: .1em; text-transform: uppercase;
    color: var(--muted); margin-bottom: 10px;
}
.side-text { font-size: 14.5px; color: var(--text-2); margin-bottom: 8px; }
.side-link { font-size: 14px; }

/* ---------- Article ---------- */
.read-progress { position: fixed; top: 0; left: 0; right: 0; height: 2px; z-index: 150; background: transparent; }
.read-progress span { display: block; height: 100%; width: 0; background: var(--accent); transition: width .1s linear; }

.article-layout { display: grid; grid-template-columns: minmax(0,1fr) 260px; gap: 56px; padding-top: 32px; padding-bottom: 80px; }
.article-main { min-width: 0; }
.article-side { display: flex; flex-direction: column; gap: 20px; align-self: start; position: sticky; top: 88px; }

.breadcrumb { font-size: 13px; color: var(--muted); margin-bottom: 20px; display: flex; gap: 8px; flex-wrap: wrap; }
.breadcrumb a { color: var(--muted); }
.breadcrumb a:hover { color: var(--text-2); }

.article-head { padding-bottom: 26px; border-bottom: 1px solid var(--border); margin-bottom: 32px; }
.article-head h1 { font-size: clamp(28px, 4vw, 40px); line-height: 1.2; letter-spacing: -0.02em; }

.cover { margin-bottom: 32px; border-radius: 12px; overflow: hidden; border: 1px solid var(--border); }
.cover img { display: block; width: 100%; }

/* ---------- Prose ---------- */
.prose { max-width: var(--measure); font-size: 17.5px; line-height: 1.78; color: var(--text-2); }
.prose > * + * { margin-top: 1.4em; }
.prose p { color: var(--text-2); }
.prose .lede { font-size: 20px; color: var(--text); }

.prose h2, .prose h3, .prose h4 {
    color: var(--text); line-height: 1.3; letter-spacing: -0.01em;
    margin-top: 2.2em; scroll-margin-top: 90px;
}
.prose h2 { font-size: 25px; font-weight: 700; }
.prose h3 { font-size: 20px; font-weight: 600; }
.prose h4 { font-size: 17.5px; font-weight: 600; }

.heading-anchor { opacity: 0; margin-left: 8px; color: var(--accent); font-weight: 400; text-decoration: none; }
.prose h2:hover .heading-anchor, .prose h3:hover .heading-anchor { opacity: .6; }

.prose ul, .prose ol { padding-left: 1.4em; }
.prose li { margin-top: .5em; }
.prose li::marker { color: var(--accent); }

.prose strong { color: var(--text); font-weight: 600; }
.prose a { color: var(--link); text-decoration: underline; text-underline-offset: 3px; }

.prose blockquote {
    border-left: 3px solid var(--accent); padding: 4px 0 4px 20px;
    color: var(--text-2); font-style: italic;
}
.prose blockquote > * + * { margin-top: 1em; }

.prose hr { border: none; border-top: 1px solid var(--border); margin: 2.6em 0; }

.post-figure { margin: 2em 0; }
.post-figure img, .post-image img { border-radius: 10px; border: 1px solid var(--border); }
.post-figure figcaption { font-size: 13.5px; color: var(--muted); text-align: center; margin-top: 10px; }

/* Callouts */
.callout { border: 1px solid var(--border); border-left: 3px solid var(--accent); border-radius: 0 var(--radius) var(--radius) 0;
    background: var(--surface); padding: 16px 20px; }
.callout > * + * { margin-top: .8em; }
.callout-label {
    font-family: var(--mono); font-size: 11px; letter-spacing: .1em; text-transform: uppercase;
    color: var(--accent); margin-bottom: 6px !important;
}
.callout-warning, .callout-danger { border-left-color: var(--warn); }
.callout-warning .callout-label, .callout-danger .callout-label { color: var(--warn); }
.callout-danger { border-left-color: var(--danger); }
.callout-danger .callout-label { color: var(--danger); }

/* Code */
.inline-code {
    font-family: var(--mono); font-size: .87em; background: var(--surface-2);
    border: 1px solid var(--border-soft); border-radius: 4px; padding: 1px 6px; color: var(--accent-text);
}
.code-block {
    margin: 1.8em 0; background: var(--surface); border: 1px solid var(--border);
    border-radius: 10px; overflow: hidden;
}
.code-bar {
    display: flex; justify-content: space-between; align-items: center;
    padding: 7px 14px; border-bottom: 1px solid var(--border); background: var(--surface-2);
}
.code-lang { font-family: var(--mono); font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; }
.code-copy {
    background: none; border: 1px solid var(--border); color: var(--muted);
    font: inherit; font-size: 11.5px; padding: 2px 9px; border-radius: 4px; cursor: pointer;
}
.code-copy:hover { color: var(--accent); border-color: var(--accent); }
.code-block pre { margin: 0; padding: 16px; overflow-x: auto; }
.code-block code { font-family: var(--mono); font-size: 13.5px; line-height: 1.65; color: var(--text); }

/* Syntax colours */
.tok-comment  { color: var(--muted); font-style: italic; }
.tok-string   { color: #86efac; }
.tok-keyword  { color: #c4b5fd; }
.tok-number   { color: #fdba74; }
.tok-function { color: #7dd3fc; }
.tok-operator { color: var(--muted); }
.tok-variable { color: #fca5a5; }
[data-theme="light"] .tok-string   { color: #15803d; }
[data-theme="light"] .tok-keyword  { color: #6d28d9; }
[data-theme="light"] .tok-number   { color: #c2410c; }
[data-theme="light"] .tok-function { color: #0369a1; }
[data-theme="light"] .tok-variable { color: #b91c1c; }

/* Tables */
.table-wrap { overflow-x: auto; margin: 1.8em 0; }
.prose table { width: 100%; border-collapse: collapse; font-size: 15px; }
.prose th, .prose td { padding: 10px 14px; border: 1px solid var(--border); text-align: left; }
.prose th { background: var(--surface-2); color: var(--text); font-weight: 600; }

/* ---------- TOC ---------- */
.toc { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 18px; }
.toc-link { display: block; font-size: 13.5px; color: var(--muted); padding: 4px 0; line-height: 1.45; border-left: 2px solid transparent; padding-left: 10px; }
.toc-link:hover { color: var(--text-2); text-decoration: none; }
.toc-link.is-active { color: var(--accent); border-left-color: var(--accent); }
.toc-l3 { padding-left: 22px; font-size: 13px; }

/* ---------- Reactions / share ---------- */
.article-actions {
    display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 16px;
    margin-top: 48px; padding-top: 24px; border-top: 1px solid var(--border);
}
.reactions { display: flex; gap: 10px; }
.react-btn, .share-btn {
    display: inline-flex; align-items: center; gap: 8px;
    background: var(--surface); border: 1px solid var(--border); color: var(--text-2);
    font: inherit; font-size: 14px; padding: 7px 14px; border-radius: 20px; cursor: pointer;
}
.react-btn:hover, .share-btn:hover { border-color: var(--accent); color: var(--text); }
.react-btn.is-active { background: var(--accent-dim); border-color: var(--accent); color: var(--accent-text); }
.react-n { font-family: var(--mono); font-size: 12px; opacity: .75; }

/* ---------- Post nav ---------- */
.post-nav { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 40px; }
.post-nav-item {
    background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
    padding: 16px; display: flex; flex-direction: column; gap: 5px;
    color: var(--text); text-decoration: none; font-size: 15px;
}
.post-nav-item:hover { border-color: var(--accent); text-decoration: none; }
.post-nav-next { text-align: right; }
.post-nav-label { font-family: var(--mono); font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; }

/* ---------- Comments ---------- */
.comments { margin-top: 56px; padding-top: 8px; }
.comments-empty { color: var(--muted); font-size: 15px; }
.comment-thread { display: flex; flex-direction: column; gap: 24px; margin-bottom: 40px; }
.comment { padding-bottom: 4px; }
.comment-reply { margin-top: 18px; margin-left: 34px; padding-left: 16px; border-left: 2px solid var(--border); }
.comment-head { display: flex; align-items: center; flex-wrap: wrap; gap: 9px; margin-bottom: 8px; }
.comment-head time { font-family: var(--mono); font-size: 12px; color: var(--muted); margin-left: auto; }
.comment-author { font-weight: 600; font-size: 14.5px; color: var(--text); }
.comment-body { color: var(--text-2); font-size: 15.5px; }

.avatar {
    width: 28px; height: 28px; border-radius: 50%; background: var(--surface-2);
    color: var(--text-2); display: inline-flex; align-items: center; justify-content: center;
    font-size: 12px; font-weight: 600; flex-shrink: 0;
}
.avatar-author { background: var(--accent); color: #04140c; }

.badge {
    font-size: 11px; padding: 1px 8px; border-radius: 20px;
    background: var(--surface-2); color: var(--muted); text-transform: capitalize;
}
.badge-author, .badge-approved, .badge-published { background: var(--accent-dim); color: var(--accent-text); }
.badge-question, .badge-pending, .badge-scheduled, .badge-featured { background: var(--warn-dim); color: var(--warn); }
.badge-spam, .badge-trash { background: var(--danger-dim); color: var(--danger); }
.badge-draft { background: var(--surface-2); color: var(--muted); }

.reply-btn {
    background: none; border: none; color: var(--muted); font: inherit; font-size: 13px;
    cursor: pointer; padding: 4px 0; margin-top: 6px;
}
.reply-btn:hover { color: var(--accent); }

/* ---------- Forms ---------- */
label { display: block; font-size: 14px; color: var(--text-2); margin-bottom: 14px; }
input[type="text"], input[type="email"], input[type="url"], input[type="password"],
input[type="search"], input[type="number"], input[type="datetime-local"], textarea, select {
    display: block; width: 100%; margin-top: 6px;
    background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius);
    color: var(--text); font: inherit; font-size: 15px; padding: 9px 12px;
}
textarea { resize: vertical; line-height: 1.6; }
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--accent); }
::placeholder { color: var(--muted); }

.hint { display: block; font-size: 12.5px; color: var(--muted); margin-top: 5px; }

.check { display: flex; align-items: center; gap: 9px; font-size: 14px; }
.check input { width: auto; margin: 0; }

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-narrow { max-width: 420px; }
.form-title { font-size: 17px; font-weight: 600; color: var(--text); margin-bottom: 16px; }
.form-note { font-size: 13px; color: var(--muted); margin-top: 10px; }

.comment-form {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: 12px; padding: 24px; max-width: var(--measure);
}
.hp-field { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
.reply-notice {
    background: var(--accent-dim); color: var(--accent-text); border-radius: var(--radius);
    padding: 8px 12px; font-size: 13.5px; margin-bottom: 14px;
    display: flex; align-items: center; justify-content: space-between; gap: 10px;
}
.reply-notice button { background: none; border: none; color: inherit; cursor: pointer; font: inherit; text-decoration: underline; }

/* ---------- Buttons ---------- */
.btn-primary, .btn-ghost, .btn-danger {
    display: inline-flex; align-items: center; justify-content: center; gap: 7px;
    font: inherit; font-size: 14.5px; font-weight: 500; padding: 9px 18px;
    border-radius: var(--radius); cursor: pointer; border: 1px solid transparent; text-decoration: none;
}
.btn-primary { background: var(--accent); color: #04140c; border-color: var(--accent); }
.btn-primary:hover { filter: brightness(1.08); text-decoration: none; }
.btn-primary:disabled { opacity: .5; cursor: not-allowed; }
.btn-ghost { background: transparent; border-color: var(--border); color: var(--text-2); }
.btn-ghost:hover { border-color: var(--accent); color: var(--text); text-decoration: none; }
.btn-danger { background: transparent; border-color: var(--danger-dim); color: var(--danger); }
.btn-danger:hover { background: var(--danger-dim); text-decoration: none; }
.btn-sm { font-size: 13.5px; padding: 6px 13px; }
.btn-xs { font-size: 12.5px; padding: 4px 10px; }
.inline-form { display: inline; }

/* ---------- Flash ---------- */
.flash {
    border-radius: var(--radius); padding: 11px 16px; font-size: 14.5px; margin: 18px 0;
    border: 1px solid var(--border);
}
.flash-ok { background: var(--accent-dim); color: var(--accent-text); border-color: transparent; }
.flash-warn { background: var(--warn-dim); color: var(--warn); border-color: transparent; }

/* ---------- Page heads / misc ---------- */
.page-head { padding: 56px 24px 28px; }
.page-head h1 { font-size: clamp(26px, 3.5vw, 36px); letter-spacing: -0.02em; }
.page-sub { color: var(--text-2); margin-top: 10px; font-size: 17px; max-width: 60ch; }
.muted { color: var(--muted); font-size: 14.5px; }

.page-search { display: flex; gap: 10px; margin-top: 20px; max-width: 560px; }
.page-search input { margin-top: 0; }

.empty { text-align: center; padding: 60px 20px; }
.empty h2 { font-size: 21px; margin-bottom: 8px; }
.empty p { color: var(--muted); }

.pagination { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-top: 48px; padding-top: 24px; border-top: 1px solid var(--border); }
.page-count { font-family: var(--mono); font-size: 13px; color: var(--muted); }

.year-group { margin-bottom: 44px; }
.year-heading { font-family: var(--mono); font-size: 13px; color: var(--accent); letter-spacing: .1em; margin-bottom: 4px; }

.topic-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px; padding-bottom: 60px; }
.topic-card {
    background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
    padding: 18px; display: flex; flex-direction: column; gap: 5px; text-decoration: none;
}
.topic-card:hover { border-color: var(--accent); text-decoration: none; }
.topic-name { font-size: 16.5px; font-weight: 600; color: var(--text); }
.topic-count { font-family: var(--mono); font-size: 12px; color: var(--accent); }
.topic-desc { font-size: 14px; color: var(--muted); margin-top: 4px; }

.stat-row { display: flex; gap: 40px; flex-wrap: wrap; margin: 48px 0 80px; padding-top: 28px; border-top: 1px solid var(--border); }
.stat { display: flex; flex-direction: column; }
.stat-n { font-size: 26px; font-weight: 700; color: var(--text); }
.stat-l { font-size: 13px; color: var(--muted); font-family: var(--mono); }

.error-page { padding: 80px 24px; text-align: center; }
.error-actions { display: flex; gap: 12px; justify-content: center; margin-top: 24px; flex-wrap: wrap; }
.error-page .post-list { max-width: 600px; margin: 0 auto; text-align: left; }

.auth-wrap { display: flex; align-items: center; justify-content: center; min-height: 72vh; padding: 40px 20px; }
.auth-card { width: 100%; max-width: 400px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 32px; }
.auth-card h1 { font-size: 24px; margin-bottom: 6px; }
.auth-card form { margin-top: 20px; }
.auth-card .btn-primary { width: 100%; margin-top: 8px; }
.auth-back { margin-top: 20px; font-size: 14px; text-align: center; }

/* ---------- Footer ---------- */
.site-footer { border-top: 1px solid var(--border); margin-top: 40px; padding: 48px 0 32px; background: var(--surface); }
.footer-inner { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 40px; }
.footer-col { display: flex; flex-direction: column; gap: 7px; }
.footer-col a { color: var(--text-2); font-size: 14.5px; }
.footer-col a:hover { color: var(--accent); text-decoration: none; }
.footer-brand { font-family: var(--mono); font-weight: 700; color: var(--text); }
.footer-tag { color: var(--muted); font-size: 14.5px; max-width: 40ch; }
.footer-heading { font-family: var(--mono); font-size: 11px; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); margin-bottom: 4px; }
.footer-bottom {
    display: flex; justify-content: space-between; flex-wrap: wrap; gap: 12px;
    margin-top: 36px; padding-top: 20px; border-top: 1px solid var(--border);
    font-size: 13.5px; color: var(--muted);
}
.quiet-link { color: var(--muted); }

/* =============================================================
   Admin
   ============================================================= */
.admin-body { background: var(--bg); }
.admin-header { border-bottom: 1px solid var(--border); background: var(--surface); position: sticky; top: 0; z-index: 100; }
.admin-header-inner { display: flex; align-items: center; gap: 24px; height: 56px; max-width: 1400px; margin: 0 auto; padding: 0 24px; }
.admin-nav { display: flex; gap: 20px; flex: 1; }
.admin-nav a { color: var(--text-2); font-size: 14.5px; display: inline-flex; align-items: center; gap: 7px; }
.admin-nav a:hover { color: var(--text); text-decoration: none; }
.admin-nav a.is-active { color: var(--accent); }
.admin-tools { display: flex; align-items: center; gap: 8px; }
.pill { background: var(--warn); color: #241a02; font-size: 11px; font-weight: 600; border-radius: 20px; padding: 0 6px; min-width: 18px; text-align: center; }

.admin-main { max-width: 1400px; margin: 0 auto; padding: 0 24px 80px; }
.admin-wrap { padding-top: 28px; }
.admin-wrap h1 { font-size: 26px; margin-bottom: 4px; }
.admin-page-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 8px; }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; margin: 24px 0 32px; }
.stat-card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 16px; display: flex; flex-direction: column; gap: 3px; }
.stat-card-alert { border-color: var(--warn); }
.stat-card-n { font-size: 26px; font-weight: 700; color: var(--text); }
.stat-card-l { font-size: 12.5px; color: var(--muted); font-family: var(--mono); }

.admin-cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 20px; margin-bottom: 20px; }
.admin-panel { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 20px; }
.admin-panel h2 { font-size: 16px; margin-bottom: 14px; }
.admin-panel h3 { font-size: 14px; margin: 18px 0 10px; color: var(--text-2); }
.panel-sub { font-size: 13px; color: var(--muted); margin-top: 16px; }

.admin-table { width: 100%; border-collapse: collapse; font-size: 14.5px; }
.admin-table td, .admin-table th { padding: 9px 8px; border-bottom: 1px solid var(--border-soft); text-align: left; vertical-align: top; }
.admin-table th { font-size: 12px; color: var(--muted); font-family: var(--mono); text-transform: uppercase; letter-spacing: .07em; }
.admin-table .num { text-align: right; font-family: var(--mono); font-size: 13px; color: var(--muted); white-space: nowrap; }
.admin-table-full { margin-top: 16px; }
.row-title { font-weight: 600; color: var(--text); }
.row-tags { display: flex; gap: 6px; margin-top: 6px; flex-wrap: wrap; }
.row-actions { white-space: nowrap; display: flex; gap: 6px; align-items: center; }
.nowrap { white-space: nowrap; }

.filter-bar { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin: 20px 0 4px; }
.filter-tabs { display: flex; gap: 4px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 3px; }
.filter-tabs a { padding: 5px 13px; border-radius: 6px; font-size: 13.5px; color: var(--text-2); display: inline-flex; align-items: center; gap: 6px; }
.filter-tabs a:hover { color: var(--text); text-decoration: none; }
.filter-tabs a.is-active { background: var(--surface-2); color: var(--accent); }
.filter-search input { margin-top: 0; width: 220px; }

.mini-list { display: flex; flex-direction: column; gap: 14px; margin-bottom: 14px; }
.mini-item { padding-bottom: 12px; border-bottom: 1px solid var(--border-soft); }
.mini-item:last-child { border-bottom: none; }
.mini-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 14px; }
.mini-text { font-size: 14px; color: var(--text-2); margin-top: 5px; }
.mini-meta { font-size: 12.5px; color: var(--muted); margin-top: 4px; }

.comment-admin-list { display: flex; flex-direction: column; gap: 16px; margin-top: 20px; }
.comment-admin { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 18px; }
.comment-admin-head { display: flex; align-items: center; gap: 11px; flex-wrap: wrap; margin-bottom: 12px; }
.comment-admin-who { display: flex; flex-direction: column; }
.comment-admin-badges { margin-left: auto; display: flex; gap: 6px; }
.comment-admin-body { font-size: 15px; color: var(--text-2); }
.comment-admin-actions { display: flex; gap: 7px; flex-wrap: wrap; margin-top: 14px; }
.admin-reply { margin-top: 14px; }
.admin-reply textarea { margin-bottom: 10px; }

.tag-add { display: flex; gap: 8px; align-items: flex-start; margin-bottom: 18px; }
.tag-add input { margin-top: 0; }
.tag-admin-list { display: flex; flex-direction: column; gap: 10px; }
.tag-admin-row { display: flex; gap: 12px; align-items: center; padding-bottom: 10px; border-bottom: 1px solid var(--border-soft); flex-wrap: wrap; }
.tag-admin-main { flex: 1; display: grid; grid-template-columns: 180px 1fr; gap: 8px; min-width: 260px; }
.tag-admin-main input { margin-top: 0; }
.tag-admin-actions { display: flex; align-items: center; gap: 8px; }

/* ---------- Editor ---------- */
.editor { padding-top: 16px; }
.editor-bar {
    display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap;
    padding-bottom: 14px; border-bottom: 1px solid var(--border); margin-bottom: 20px;
}
.editor-bar-left, .editor-bar-right { display: flex; align-items: center; gap: 8px; }
.save-state { font-size: 12.5px; color: var(--muted); font-family: var(--mono); }

.editor-grid { display: grid; grid-template-columns: minmax(0,1fr) 320px; gap: 28px; }
.editor-main { min-width: 0; }

.title-input {
    font-size: 27px; font-weight: 700; letter-spacing: -0.02em; border: none;
    background: none; padding: 0; margin-top: 0; color: var(--text);
}
.title-input:focus { border: none; }

.slug-row { display: flex; align-items: center; gap: 0; margin: 10px 0 18px; font-family: var(--mono); font-size: 12.5px; }
.slug-prefix { color: var(--muted); white-space: nowrap; }
.slug-input { border: none; background: none; padding: 0; margin-top: 0; font-family: var(--mono); font-size: 12.5px; color: var(--accent); }
.slug-input:focus { border: none; }

.md-toolbar { display: flex; gap: 4px; flex-wrap: wrap; align-items: center; padding: 7px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius) var(--radius) 0 0; border-bottom: none; }
.md-toolbar button {
    background: none; border: 1px solid transparent; color: var(--text-2);
    font: inherit; font-size: 13px; padding: 4px 10px; border-radius: 5px; cursor: pointer;
}
.md-toolbar button:hover { background: var(--surface-2); color: var(--text); }
.md-toolbar button.is-active { color: var(--accent); border-color: var(--border); }
.toolbar-spacer { flex: 1; }

.editor-panes { display: grid; grid-template-columns: 1fr 1fr; gap: 0; border: 1px solid var(--border); border-radius: 0 0 var(--radius) var(--radius); overflow: hidden; }
.editor-panes.no-preview { grid-template-columns: 1fr; }
.editor-panes.no-preview .preview-pane { display: none; }
.content-input {
    border: none; border-radius: 0; margin-top: 0; min-height: 62vh;
    font-family: var(--mono); font-size: 14px; line-height: 1.7; background: var(--bg); resize: none;
}
.content-input:focus { border: none; }
.preview-pane { padding: 18px; border-left: 1px solid var(--border); background: var(--surface); overflow-y: auto; max-height: 62vh; max-width: none; font-size: 15.5px; }
.editor-stats { display: flex; gap: 18px; font-family: var(--mono); font-size: 12px; color: var(--muted); margin-top: 10px; }

.editor-side { display: flex; flex-direction: column; gap: 16px; }
.side-panel { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 16px; }
.side-panel h3 { font-size: 13px; font-family: var(--mono); text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin-bottom: 12px; }

.tag-picker { display: flex; flex-wrap: wrap; gap: 7px; margin-bottom: 14px; }
.tag-check { margin: 0; cursor: pointer; }
.tag-check input { position: absolute; opacity: 0; width: 0; }
.tag-check span { display: inline-block; font-size: 12.5px; padding: 3px 10px; border-radius: 20px; background: var(--surface-2); color: var(--muted); border: 1px solid transparent; }
.tag-check input:checked + span { background: var(--accent-dim); color: var(--accent-text); border-color: var(--accent); }
.tag-check input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }

.serp-preview { background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px; margin-bottom: 16px; display: flex; flex-direction: column; gap: 3px; }
.serp-url { font-size: 12px; color: var(--muted); word-break: break-all; }
.serp-title { font-size: 15px; color: var(--link); line-height: 1.3; }
.serp-desc { font-size: 12.5px; color: var(--text-2); line-height: 1.45; }

/* =============================================================
   Responsive
   ============================================================= */
@media (max-width: 1000px) {
    .layout, .article-layout { grid-template-columns: 1fr; gap: 40px; }
    .layout-side, .article-side { position: static; }
    .editor-grid { grid-template-columns: 1fr; }
    .editor-panes { grid-template-columns: 1fr; }
    .preview-pane { display: none; }
}

@media (max-width: 720px) {
    body { font-size: 16px; }
    .wrap { padding: 0 18px; }
    .site-nav { display: none; }
    .site-nav.is-open {
        display: flex; flex-direction: column; position: absolute; top: 60px; left: 0; right: 0;
        background: var(--bg); border-bottom: 1px solid var(--border); padding: 16px 18px; gap: 14px;
    }
    .nav-toggle { display: inline-flex; }
    .search-trigger span, .search-trigger kbd { display: none; }
    .search-trigger { padding: 6px 9px; }
    .hero { padding: 40px 18px 28px; }
    .prose { font-size: 16.5px; }
    .form-row { grid-template-columns: 1fr; }
    .post-nav { grid-template-columns: 1fr; }
    .post-nav-next { text-align: left; }
    .footer-inner { grid-template-columns: 1fr; gap: 28px; }
    .comment-reply { margin-left: 12px; }
    .admin-header-inner { flex-wrap: wrap; height: auto; padding: 10px 18px; gap: 12px; }
    .admin-nav { order: 3; width: 100%; overflow-x: auto; }
    .tag-admin-main { grid-template-columns: 1fr; }
    .filter-search input { width: 100%; }
}

@media print {
    .site-header, .site-footer, .article-side, .comments, .article-actions, .post-nav, .read-progress { display: none; }
    body { background: #fff; color: #000; }
    .prose { max-width: none; }
}

@media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }
    * { animation: none !important; transition: none !important; }
}
