/* TruckMe Learn — one stylesheet, light + dark */
:root {
  --bg: #ffffff;
  --bg-soft: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #f1f3f6;
  --border: #e4e7ec;
  --border-strong: #cfd4dc;
  --text: #111827;
  --text-2: #4b5563;
  --muted: #6b7280;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --accent-soft: #eaf1ff;
  --accent-text: #1d4ed8;
  --danger: #dc2626;
  --ok: #059669;
  --warn-bg: #fff7e6;
  --warn-text: #92400e;
  --mark: #fff1a8;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 1px 3px rgba(16, 24, 40, .06);
  --shadow-lg: 0 12px 32px rgba(16, 24, 40, .14);
  --radius: 12px;
  --radius-sm: 8px;
  --topbar-h: 60px;
  --side-w: 270px;
  --font: ui-sans-serif, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-read: Charter, "Iowan Old Style", Georgia, Cambria, "Times New Roman", serif;
  --mono: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0d1117; --bg-soft: #0f141b; --surface: #151b23; --surface-2: #1c2330;
    --border: #262f3c; --border-strong: #364152; --text: #e6e9ef; --text-2: #b4bccb; --muted: #8b95a6;
    --accent: #4f8bff; --accent-hover: #6c9dff; --accent-soft: #15233d; --accent-text: #8fb3ff;
    --warn-bg: #2a2111; --warn-text: #f3c56b; --mark: #5a4a00;
    --shadow: 0 1px 2px rgba(0,0,0,.4); --shadow-lg: 0 12px 32px rgba(0,0,0,.5);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0d1117; --bg-soft: #0f141b; --surface: #151b23; --surface-2: #1c2330;
  --border: #262f3c; --border-strong: #364152; --text: #e6e9ef; --text-2: #b4bccb; --muted: #8b95a6;
  --accent: #4f8bff; --accent-hover: #6c9dff; --accent-soft: #15233d; --accent-text: #8fb3ff;
  --warn-bg: #2a2111; --warn-text: #f3c56b; --mark: #5a4a00;
  --shadow: 0 1px 2px rgba(0,0,0,.4); --shadow-lg: 0 12px 32px rgba(0,0,0,.5);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: calc(var(--topbar-h) + 16px); }
body { margin: 0; background: var(--bg-soft); color: var(--text); font: 15px/1.55 var(--font); }
a { color: var(--accent-text); text-decoration: none; }
a:hover { text-decoration: underline; }
img, video { max-width: 100%; }
h1, h2, h3 { line-height: 1.25; letter-spacing: -.01em; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.center { text-align: center; }
.spacer { flex: 1; }
.row-gap { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.clamp-2 { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
code, kbd, pre { font-family: var(--mono); }
[hidden] { display: none !important; }

/* buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 38px; padding: 0 16px;
  border-radius: var(--radius-sm); border: 1px solid transparent; font: 600 14px var(--font); cursor: pointer;
  text-decoration: none !important; white-space: nowrap; transition: background .15s, border-color .15s; }
.btn-sm { height: 32px; padding: 0 12px; font-size: 13px; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-ghost { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn-ghost:hover { border-color: var(--border-strong); background: var(--surface-2); }
.btn-danger-ghost { background: transparent; color: var(--danger); border-color: var(--border); }
.btn-danger-ghost:hover { background: rgba(220,38,38,.08); }
.btn.wide { width: 100%; }
.icon-btn { display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: var(--radius-sm);
  border: 0; background: transparent; color: var(--text-2); cursor: pointer; font-size: 20px; }
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.link-danger, .linkish { background: none; border: 0; padding: 0; color: var(--danger); cursor: pointer; font: inherit; }
.linkish { color: var(--accent-text); }

/* topbar */
.topbar { position: sticky; top: 0; z-index: 40; height: var(--topbar-h); background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(180%) blur(10px); border-bottom: 1px solid var(--border); }
.topbar-inner { height: 100%; display: flex; align-items: center; gap: 12px; padding: 0 16px; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); font-weight: 700; font-size: 16px; text-decoration: none !important; flex-shrink: 0; }
.brand-mark { color: var(--accent); display: grid; }
.nav-toggle { display: none; }
.global-search { position: relative; flex: 1; max-width: 560px; margin: 0 auto; }
.global-search input { width: 100%; height: 40px; padding: 0 40px 0 40px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--surface-2); color: var(--text); font: 14px var(--font); outline: none; }
.global-search input:focus { background: var(--surface); border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.gs-icon { position: absolute; left: 12px; top: 11px; color: var(--muted); pointer-events: none; }
.gs-kbd { position: absolute; right: 10px; top: 9px; font-size: 12px; color: var(--muted); border: 1px solid var(--border);
  border-radius: 5px; padding: 1px 6px; background: var(--surface); }
.global-search input:focus ~ .gs-kbd { display: none; }
.gs-results { position: absolute; top: 46px; left: 0; right: 0; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-lg); max-height: 70vh; overflow: auto; padding: 6px; }
.gs-group { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding: 8px 10px 4px; }
.gs-item { display: block; padding: 8px 10px; border-radius: var(--radius-sm); color: var(--text); text-decoration: none !important; }
.gs-item:hover, .gs-item.sel { background: var(--accent-soft); }
.gs-item .t { font-weight: 600; }
.gs-item .s { font-size: 13px; color: var(--text-2); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.gs-item .k { font-size: 12px; color: var(--muted); }
.gs-empty { padding: 14px; color: var(--muted); font-size: 14px; }
.gs-all { display: block; text-align: center; padding: 8px; font-size: 13px; border-top: 1px solid var(--border); margin-top: 4px; }
mark { background: var(--mark); color: inherit; border-radius: 3px; padding: 0 2px; }
.top-actions { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }

.menu { position: relative; }
.menu summary { list-style: none; cursor: pointer; }
.menu summary::-webkit-details-marker { display: none; }
.avatar { width: 34px; height: 34px; border-radius: 50%; display: inline-grid; place-items: center; background: var(--accent);
  color: #fff; font-weight: 700; font-size: 14px; flex-shrink: 0; }
.avatar.sm { width: 38px; height: 38px; }
.menu-panel { position: absolute; right: 0; top: 44px; min-width: 230px; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-lg); padding: 6px; display: flex; flex-direction: column; }
.menu-head { padding: 8px 10px 10px; border-bottom: 1px solid var(--border); margin-bottom: 4px; display: flex; flex-direction: column; }
.menu-head span { font-size: 12px; color: var(--muted); }
.menu-panel a, .menu-panel button { display: block; width: 100%; text-align: left; padding: 8px 10px; border-radius: 6px; color: var(--text);
  background: none; border: 0; font: 14px var(--font); cursor: pointer; text-decoration: none; }
.menu-panel a:hover, .menu-panel button:hover { background: var(--surface-2); }

/* shell */
.shell { display: grid; grid-template-columns: var(--side-w) minmax(0, 1fr); min-height: calc(100vh - var(--topbar-h)); }
.shell:not(:has(.sidenav)) { grid-template-columns: minmax(0, 1fr); }
.sidenav { border-right: 1px solid var(--border); background: var(--bg); }
.sidenav-inner { position: sticky; top: var(--topbar-h); max-height: calc(100vh - var(--topbar-h)); overflow-y: auto; padding: 16px 10px 40px; }
.sidenav-home { display: flex; align-items: center; gap: 8px; padding: 7px 10px; border-radius: var(--radius-sm); color: var(--text-2); font-weight: 600; text-decoration: none !important; }
.sidenav-home:hover, .sidenav-home.active { background: var(--surface-2); color: var(--text); }
.sidenav-label { display: flex; justify-content: space-between; align-items: center; margin: 18px 10px 6px; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); }
.sidenav-edit { font-size: 11px; text-transform: none; letter-spacing: 0; font-weight: 600; }
.sidenav-empty { padding: 0 10px; }
.tree { list-style: none; margin: 0; padding: 0; }
.tree .tree { padding-left: 14px; display: none; }
.tree li.open > .tree { display: block; }
.tree-row { display: flex; align-items: center; border-radius: var(--radius-sm); }
.tree-row:hover { background: var(--surface-2); }
.tree-row.active { background: var(--accent-soft); }
.tree-row.active a { color: var(--accent-text); font-weight: 600; }
.tree-row a { flex: 1; display: flex; align-items: center; gap: 8px; padding: 6px 8px 6px 2px; color: var(--text-2); text-decoration: none !important; min-width: 0; font-size: 14px; }
.t-icon { width: 20px; text-align: center; flex-shrink: 0; }
.t-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.t-count { font-size: 11px; color: var(--muted); background: var(--surface-2); border-radius: 10px; padding: 0 7px; }
.tree-caret, .tree-caret-space { width: 22px; height: 26px; flex-shrink: 0; }
.tree-caret { border: 0; background: none; color: var(--muted); cursor: pointer; display: grid; place-items: center; border-radius: 4px; }
.tree-caret svg { transition: transform .15s; }
li.open > .tree-row .tree-caret svg { transform: rotate(90deg); }
.nav-scrim { display: none; }

.main { padding: 28px 32px 80px; min-width: 0; max-width: 1240px; width: 100%; }
.flashes { margin-bottom: 16px; display: grid; gap: 8px; }
.flash { padding: 10px 14px; border-radius: var(--radius-sm); border: 1px solid var(--border); background: var(--surface); font-size: 14px; }
.flash-ok { border-color: color-mix(in srgb, var(--ok) 40%, var(--border)); color: var(--ok); }
.flash-error { border-color: color-mix(in srgb, var(--danger) 40%, var(--border)); color: var(--danger); }

/* cards & sections */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.section { margin-top: 32px; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.section-head h2 { margin: 0; font-size: 18px; }
.empty-state { padding: 40px; text-align: center; }
.empty-state.small-pad { padding: 24px; }
.empty-state h2 { margin-top: 0; }
.empty-state .row-gap { justify-content: center; }
.err-code { font-size: 64px; font-weight: 800; color: var(--accent); line-height: 1; margin-bottom: 8px; }

.hero { text-align: center; padding: 36px 16px 20px; }
.hero h1 { font-size: clamp(28px, 4vw, 40px); margin: 0 0 8px; }
.hero-sub { color: var(--text-2); font-size: 17px; margin: 0 auto 24px; max-width: 620px; }
.hero-search { display: flex; align-items: center; gap: 8px; max-width: 640px; margin: 0 auto; background: var(--surface);
  border: 1px solid var(--border); border-radius: 14px; padding: 6px 6px 6px 16px; box-shadow: var(--shadow-lg); color: var(--muted); }
.hero-search input { flex: 1; border: 0; outline: none; background: transparent; color: var(--text); font: 16px var(--font); height: 40px; min-width: 0; }

.topic-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 14px; }
.topic-grid.compact { grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); }
.topic-card { display: flex; gap: 14px; padding: 16px; color: var(--text); text-decoration: none !important; transition: border-color .15s, transform .15s; }
.topic-card:hover { border-color: var(--accent); transform: translateY(-1px); }
.topic-icon { width: 44px; height: 44px; flex-shrink: 0; border-radius: 10px; background: var(--accent-soft); color: var(--accent-text);
  display: grid; place-items: center; font-size: 22px; font-weight: 700; }
.topic-icon.lg { width: 60px; height: 60px; font-size: 30px; border-radius: 14px; }
.topic-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.topic-foot { color: var(--accent-text); margin-top: 4px; font-weight: 600; }

/* blog cards */
.home-cols { display: grid; grid-template-columns: minmax(0, 1fr) 280px; gap: 32px; align-items: start; }
.home-cols:not(:has(.side-col)) { grid-template-columns: minmax(0, 1fr); }
.post-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 18px; }
.post { position: relative; overflow: hidden; display: flex; flex-direction: column; transition: border-color .15s, box-shadow .15s, transform .15s; }
.post:hover { border-color: var(--border-strong); box-shadow: var(--shadow-lg); transform: translateY(-2px); }
.post-link { position: absolute; inset: 0; z-index: 1; }
.post .chip { position: relative; z-index: 2; }
.post-cover { aspect-ratio: 16 / 9; background: var(--surface-2); overflow: hidden; }
.post-cover img { width: 100%; height: 100%; object-fit: cover; display: block; }
.post-cover-empty { display: grid; place-items: center; font-size: 40px; font-weight: 800; color: #fff;
  background: linear-gradient(135deg, var(--c1, #2563eb), var(--c2, #7c3aed)); }
.post-body { padding: 14px 16px 16px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.post-title { margin: 0; font-size: 17px; }
.post-summary { margin: 0; color: var(--text-2); font-size: 14px; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.post-meta { margin-top: auto; padding-top: 6px; font-size: 12.5px; color: var(--muted); display: flex; gap: 6px; flex-wrap: wrap; }
.post-meta-top { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; min-height: 0; }
.post-meta-top:empty { display: none; }
@media (min-width: 900px) {
  .post-feature { grid-column: 1 / -1; flex-direction: row; }
  .post-feature .post-cover { flex: 0 0 55%; aspect-ratio: auto; min-height: 260px; }
  .post-feature .post-body { padding: 24px 28px; justify-content: center; }
  .post-feature .post-title { font-size: 26px; }
  .post-feature .post-summary { font-size: 16px; -webkit-line-clamp: 4; }
}
.chip { display: inline-flex; align-items: center; gap: 4px; padding: 2px 10px; border-radius: 20px; background: var(--accent-soft);
  color: var(--accent-text); font-size: 12px; font-weight: 600; text-decoration: none !important; }
.chip.lg { font-size: 14px; padding: 6px 14px; }
.chip-row { display: flex; gap: 8px; flex-wrap: wrap; }
.badge { display: inline-block; padding: 2px 8px; border-radius: 6px; font-size: 11.5px; font-weight: 700; background: var(--surface-2); color: var(--text-2); }
.badge-draft { background: var(--warn-bg); color: var(--warn-text); }
.badge-pin { background: var(--accent-soft); color: var(--accent-text); }
.pager { display: flex; justify-content: space-between; align-items: center; margin-top: 24px; }

.popular { list-style: none; counter-reset: p; margin: 0; padding: 0; display: grid; gap: 14px; }
.popular li { counter-increment: p; display: grid; grid-template-columns: 30px 1fr; gap: 0 8px; }
.popular li::before { content: counter(p, decimal-leading-zero); grid-row: span 2; font-weight: 800; font-size: 18px; color: var(--border-strong); }
.popular a { color: var(--text); font-weight: 600; }
.draft-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.draft-list li { display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap; padding: 10px 14px; background: var(--surface); border: 1px dashed var(--border-strong); border-radius: var(--radius-sm); }
.draft-list li > a:first-child { font-weight: 600; color: var(--text); }
.draft-list li > a:last-child { margin-left: auto; }

/* page heads */
.crumbs { display: flex; flex-wrap: wrap; gap: 6px; font-size: 13px; color: var(--muted); margin-bottom: 14px; }
.crumbs a { color: var(--muted); }
.crumbs .sep { opacity: .5; }
.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap; margin-bottom: 8px; }
.page-head h1 { margin: 0 0 4px; font-size: 28px; }
.page-head p { margin: 0; }
.page-head-main { display: flex; gap: 16px; align-items: center; }
.inline-search input { height: 32px; border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 0 10px; background: var(--surface); color: var(--text); font: 13px var(--font); width: 200px; }

/* article */
.article-layout { display: grid; grid-template-columns: minmax(0, 760px) 240px; gap: 48px; justify-content: center; }
.article-layout.no-toc { grid-template-columns: minmax(0, 760px) 240px; }
.article { min-width: 0; }
.article-head h1 { font-size: clamp(28px, 4vw, 40px); margin: 8px 0 10px; }
.lede { font-size: 19px; color: var(--text-2); margin: 0 0 18px; }
.byline { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 14px 0; border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.article-cover { margin: 24px 0 0; }
.article-cover img { width: 100%; border-radius: var(--radius); display: block; max-height: 460px; object-fit: cover; }
.article-side { position: sticky; top: calc(var(--topbar-h) + 24px); align-self: start; display: grid; gap: 24px; max-height: calc(100vh - var(--topbar-h) - 48px); overflow: auto; }
.side-label { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); margin-bottom: 8px; }
.toc ul, .related { list-style: none; margin: 0; padding: 0; }
.toc ul ul { padding-left: 12px; }
.toc a, .related a { display: block; padding: 4px 0 4px 12px; border-left: 2px solid var(--border); color: var(--text-2); font-size: 13.5px; text-decoration: none; }
.toc a:hover, .related a:hover { color: var(--text); }
.toc a.active { border-left-color: var(--accent); color: var(--accent-text); font-weight: 600; }

.prose { font: 18px/1.75 var(--font-read); color: var(--text); margin-top: 24px; overflow-wrap: break-word; }
.prose > :first-child { margin-top: 0; }
.prose h2, .prose h3, .prose h4 { font-family: var(--font); margin: 1.8em 0 .5em; }
.prose h2 { font-size: 26px; padding-bottom: 6px; border-bottom: 1px solid var(--border); }
.prose h3 { font-size: 21px; }
.prose p, .prose ul, .prose ol, .prose blockquote, .prose pre, .prose table, .prose figure { margin: 0 0 1.2em; }
.prose li { margin: .3em 0; }
.prose li > p { margin: 0; }
.prose a { text-decoration: underline; text-underline-offset: 2px; }
.prose blockquote { border-left: 4px solid var(--accent); padding: 4px 0 4px 18px; color: var(--text-2); font-style: italic; }
.prose code { font-size: .85em; background: var(--surface-2); border: 1px solid var(--border); padding: 1px 5px; border-radius: 5px; }
.prose pre { background: #0f172a; color: #e2e8f0; padding: 16px 18px; border-radius: var(--radius-sm); overflow: auto; font-size: 14px; line-height: 1.6; }
.prose pre code { background: none; border: 0; padding: 0; color: inherit; font-size: inherit; }
.prose table { border-collapse: collapse; width: 100%; font: 15px/1.5 var(--font); display: block; overflow-x: auto; }
.prose th, .prose td { border: 1px solid var(--border); padding: 8px 12px; text-align: left; }
.prose th { background: var(--surface-2); }
.prose img { border-radius: var(--radius-sm); display: block; margin: 0 auto; }
.prose figure { text-align: center; }
.prose figcaption { font: 13.5px var(--font); color: var(--muted); margin-top: 8px; }
.prose video, .prose audio { width: 100%; border-radius: var(--radius-sm); background: #000; display: block; }
.prose audio { background: none; }
.prose .embed iframe { width: 100%; aspect-ratio: 16 / 9; border: 0; border-radius: var(--radius-sm); }
.prose hr { border: 0; border-top: 1px solid var(--border); margin: 2em 0; }
.prose a[href^="/media/"]:not(:has(img))::before { content: "📎 "; }
.prose .admonition { font: 15.5px/1.6 var(--font); border-radius: var(--radius-sm); padding: 12px 16px; border: 1px solid var(--border); border-left: 4px solid var(--accent); background: var(--accent-soft); }
.prose .admonition p { margin: 0 0 .5em; }
.prose .admonition p:last-child { margin: 0; }
.prose .admonition-title { font-weight: 700; }
.prose .admonition.warning, .prose .admonition.caution, .prose .admonition.danger { border-left-color: #f59e0b; background: var(--warn-bg); }
.prose .admonition.danger { border-left-color: var(--danger); }
.prose .admonition.tip, .prose .admonition.success { border-left-color: var(--ok); background: color-mix(in srgb, var(--ok) 10%, var(--surface)); }

.attachments { margin-top: 32px; padding: 18px 20px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.attachments h3 { margin: 0 0 10px; font-size: 15px; }
.attachments ul { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.attachments li { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.attachments li > a:first-of-type { font-weight: 600; flex: 1; min-width: 0; overflow-wrap: anywhere; }
.file-ico { display: inline-grid; place-items: center; min-width: 38px; height: 26px; padding: 0 4px; border-radius: 5px; font: 700 10px var(--font); color: #fff; background: #64748b; flex-shrink: 0; }
.file-ico.big { min-width: 64px; height: 44px; font-size: 14px; border-radius: 8px; }
.file-ico.kind-video { background: #7c3aed; } .file-ico.kind-audio { background: #db2777; } .file-ico.kind-image { background: #059669; }
.tags { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 28px; }
.prevnext { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 36px; }
.prevnext a { padding: 14px 16px; display: flex; flex-direction: column; gap: 2px; color: var(--text); text-decoration: none !important; }
.prevnext a:hover { border-color: var(--accent); }
.prevnext .right { text-align: right; grid-column: 2; }

/* search */
.search-page-form { display: flex; gap: 8px; padding: 10px; margin: 12px 0 8px; flex-wrap: wrap; }
.search-page-form input { flex: 1; min-width: 200px; height: 40px; border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 0 12px; font: 15px var(--font); background: var(--surface); color: var(--text); }
.search-page-form select { height: 40px; max-width: 220px; }
.results { list-style: none; padding: 0; margin: 0; display: grid; gap: 12px; }
.result { padding: 16px 18px; display: flex; gap: 16px; align-items: flex-start; }
.result h3 { margin: 6px 0 4px; font-size: 17px; }
.result h3 a { color: var(--text); }
.result-thumb { width: 120px; aspect-ratio: 16/10; object-fit: cover; border-radius: var(--radius-sm); flex-shrink: 0; }
.snippet { margin: 0; color: var(--text-2); font-size: 14px; }

/* forms */
input, select, textarea { font: 14px var(--font); color: var(--text); }
select, .field input, .field textarea { width: 100%; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); padding: 8px 10px; outline: none; }
select { height: 38px; padding: 0 8px; }
.field input:focus, .field textarea:focus, select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 14px; }
.field > span { font-size: 13px; font-weight: 600; color: var(--text-2); }
.field-row { display: flex; gap: 10px; }
.field.grow { flex: 1; }
.icon-field { width: 76px; }
.icon-field input { text-align: center; font-size: 20px; padding: 4px; }
.check { display: flex; gap: 10px; align-items: flex-start; margin: 6px 0 16px; cursor: pointer; }
.check input { margin-top: 3px; }
.form-card { padding: 22px; max-width: 560px; }
.form-card h2 { margin: 0 0 16px; font-size: 18px; }
.emoji-pick { display: flex; flex-wrap: wrap; gap: 2px; margin: -6px 0 14px; }
.emoji-pick button { border: 0; background: none; font-size: 18px; padding: 4px; border-radius: 6px; cursor: pointer; }
.emoji-pick button:hover { background: var(--surface-2); }

.admin-cols { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 20px; align-items: start; margin-top: 18px; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 700; padding: 12px 14px; border-bottom: 1px solid var(--border); }
.table td { padding: 10px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tr.selected td { background: var(--accent-soft); }
.table .num { text-align: right; width: 80px; }
.table .actions { text-align: right; white-space: nowrap; }
.table .actions > * { margin-left: 10px; display: inline-block; }
.indent { display: inline-block; width: calc(var(--d) * 22px); }
form.inline { display: inline-flex; gap: 6px; align-items: center; }
form.inline select { width: auto; height: 32px; }
form.inline input { height: 32px; border: 1px solid var(--border); border-radius: 6px; padding: 0 8px; background: var(--surface); }
.inline-details summary { cursor: pointer; color: var(--accent-text); list-style: none; }
.inline-details[open] summary { margin-bottom: 6px; }
.stat-row { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; margin: 16px 0 20px; max-width: 760px; }
.stat { padding: 16px; display: flex; flex-direction: column; }
.stat-n { font-size: 28px; font-weight: 800; }

/* auth */
.auth-wrap { min-height: 70vh; display: grid; place-items: center; }
.auth-card { width: 100%; max-width: 400px; padding: 32px; }
.auth-card h1 { margin: 12px 0 4px; font-size: 24px; }
.auth-card > p { margin: 0 0 20px; }
.auth-brand { display: grid; }

/* library */
.dropzone { border: 2px dashed var(--border-strong); box-shadow: none; padding: 24px; text-align: center; cursor: pointer; margin: 16px 0; background: var(--surface); }
.dropzone.over { border-color: var(--accent); background: var(--accent-soft); }
.dropzone p { margin: 0; }
.filter-bar { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin-bottom: 16px; }
.filter-bar input[type=search] { height: 34px; border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 0 10px; background: var(--surface); min-width: 220px; }
.seg { display: inline-flex; background: var(--surface-2); border-radius: var(--radius-sm); padding: 3px; }
.seg a { padding: 5px 12px; border-radius: 6px; color: var(--text-2); font-size: 13px; font-weight: 600; text-decoration: none; }
.seg a.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.lib-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 14px; }
.lib-item { margin: 0; overflow: hidden; display: flex; flex-direction: column; }
.lib-thumb { position: relative; aspect-ratio: 4 / 3; background: var(--surface-2); display: grid; place-items: center; overflow: hidden; }
.lib-thumb img, .lib-thumb video { width: 100%; height: 100%; object-fit: cover; }
.lib-thumb .play { position: absolute; width: 40px; height: 40px; border-radius: 50%; background: rgba(0,0,0,.55); color: #fff; display: grid; place-items: center; font-size: 15px; }
.lib-item figcaption { padding: 10px 12px; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.lib-name { font-weight: 600; font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lib-actions { display: flex; justify-content: space-between; margin-top: 6px; }
.upload-progress { margin-top: 12px; display: flex; align-items: center; gap: 10px; }
.upload-progress .bar { flex: 1; height: 6px; background: var(--surface-2); border-radius: 3px; overflow: hidden; }
.upload-progress .bar span { display: block; height: 100%; width: 0; background: var(--accent); transition: width .2s; }
.upload-progress .label { font-size: 12.5px; color: var(--muted); white-space: nowrap; }

/* editor */
.editor-bar { position: sticky; top: var(--topbar-h); z-index: 20; display: flex; gap: 10px; align-items: center; padding: 10px 0; margin: -16px 0 12px; background: var(--bg-soft); border-bottom: 1px solid var(--border); }
.editor-grid { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 24px; align-items: start; }
.cover-drop { border: 1px dashed var(--border-strong); border-radius: var(--radius); padding: 10px; display: flex; flex-direction: column; gap: 10px; }
.cover-drop.has-cover { border-style: solid; }
.cover-drop img { width: 100%; max-height: 300px; object-fit: cover; border-radius: var(--radius-sm); }
.cover-actions { display: flex; gap: 8px; }
.title-input { width: 100%; border: 0; background: none; outline: none; font: 800 34px/1.2 var(--font); color: var(--text); margin: 18px 0 6px; padding: 0; }
.summary-input { width: 100%; border: 0; background: none; outline: none; resize: vertical; font: 18px/1.5 var(--font); color: var(--text-2); padding: 0; margin-bottom: 14px; }
.md-editor { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); position: relative; }
.md-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 2px; padding: 6px; border-bottom: 1px solid var(--border); position: sticky; top: calc(var(--topbar-h) + 53px); background: var(--surface); z-index: 5; border-radius: var(--radius) var(--radius) 0 0; }
.md-toolbar > button { border: 0; background: none; color: var(--text-2); font: 600 13px var(--font); padding: 6px 8px; border-radius: 6px; cursor: pointer; display: inline-flex; align-items: center; gap: 4px; }
.md-toolbar > button:hover { background: var(--surface-2); color: var(--text); }
.md-toolbar .tb-media { color: var(--accent-text); }
.tb-sep { width: 1px; height: 20px; background: var(--border); margin: 0 4px; }
.tabs { display: inline-flex; background: var(--surface-2); border-radius: 7px; padding: 2px; }
.tab { border: 0; background: none; padding: 5px 12px; border-radius: 5px; font: 600 13px var(--font); color: var(--text-2); cursor: pointer; }
.tab.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.md-pane { position: relative; }
.md-text { width: 100%; min-height: 520px; border: 0; outline: none; resize: vertical; padding: 18px 20px; font: 15px/1.7 var(--mono); background: transparent; color: var(--text); display: block; }
.md-pane.preview { padding: 18px 24px; min-height: 520px; margin: 0; }
.drop-hint { display: none; position: absolute; inset: 8px; border: 2px dashed var(--accent); border-radius: var(--radius-sm); background: color-mix(in srgb, var(--accent-soft) 85%, transparent); place-items: center; font-weight: 700; color: var(--accent-text); pointer-events: none; }
.md-pane.dragging .drop-hint { display: grid; }
.md-editor .upload-progress { padding: 0 14px 12px; margin: 0; }
.editor-side { position: sticky; top: calc(var(--topbar-h) + 70px); display: grid; gap: 14px; }
.side-card { padding: 16px; }
.side-card .field:last-child { margin-bottom: 0; }
.slug-field { display: flex; align-items: center; gap: 4px; }
.attach-list { list-style: none; padding: 0; margin: 0 0 10px; display: grid; gap: 6px; }
.attach-list li { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.attach-list .name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.attach-list .x { border: 0; background: none; color: var(--muted); cursor: pointer; font-size: 18px; line-height: 1; }
.help ul { margin: 0; padding-left: 18px; display: grid; gap: 4px; }
.modal { border: 1px solid var(--border); border-radius: var(--radius); padding: 0; width: min(920px, calc(100vw - 32px)); max-height: 80vh; background: var(--surface); color: var(--text); box-shadow: var(--shadow-lg); }
.modal::backdrop { background: rgba(0,0,0,.45); }
.modal-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--border); position: sticky; top: 0; background: var(--surface); flex-wrap: wrap; }
.modal-head select { width: auto; height: 32px; }
.modal-head input { height: 32px; border: 1px solid var(--border); border-radius: 6px; padding: 0 8px; background: var(--surface); }
.modal .lib-grid { padding: 16px; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.modal .lib-item { cursor: pointer; }
.modal .lib-item:hover { border-color: var(--accent); }

/* responsive */
@media (max-width: 1100px) {
  .article-layout { grid-template-columns: minmax(0, 1fr); }
  .article-side { position: static; max-height: none; order: -1; display: none; }
  .home-cols, .admin-cols { grid-template-columns: minmax(0, 1fr); }
  .editor-grid { grid-template-columns: minmax(0, 1fr); }
  .editor-side { position: static; }
}
@media (max-width: 860px) {
  .nav-toggle { display: inline-grid; }
  .shell { grid-template-columns: minmax(0, 1fr); }
  .sidenav { position: fixed; z-index: 60; top: 0; left: 0; bottom: 0; width: min(300px, 85vw); transform: translateX(-100%); transition: transform .2s; box-shadow: var(--shadow-lg); }
  .sidenav-inner { top: 0; max-height: 100vh; padding-top: 20px; }
  body.nav-open .sidenav { transform: none; }
  body.nav-open .nav-scrim { display: block; position: fixed; inset: 0; z-index: 55; background: rgba(0,0,0,.4); }
  .main { padding: 20px 16px 60px; }
  .brand-name { display: none; }
  .gs-kbd { display: none; }
  .top-actions .btn span { display: none; }
  .top-actions .btn { padding: 0 9px; }
  .prose { font-size: 17px; }
  .title-input { font-size: 26px; }
  .result-thumb { display: none; }
  .prevnext { grid-template-columns: 1fr; }
  .prevnext .right { grid-column: 1; }
  .table .num:nth-child(3) { display: none; }
}
