/* ══════════════════════════════════════════════════════════════════════
   WMKB Frontend — public site design system: "Cool Atelier"
   Clean, bright, cool-blue. Frosted glass over a soft blue aurora.
   Self-hosted Inter throughout. Distinct from the utilitarian main app.
   ══════════════════════════════════════════════════════════════════════ */

@font-face { font-family:'Inter'; font-style:normal; font-weight:400; font-display:swap; src:url('/static/fonts/inter-400.woff2') format('woff2'); }
@font-face { font-family:'Inter'; font-style:normal; font-weight:500; font-display:swap; src:url('/static/fonts/inter-500.woff2') format('woff2'); }
@font-face { font-family:'Inter'; font-style:normal; font-weight:600; font-display:swap; src:url('/static/fonts/inter-600.woff2') format('woff2'); }
@font-face { font-family:'Inter'; font-style:normal; font-weight:700; font-display:swap; src:url('/static/fonts/inter-700.woff2') format('woff2'); }
@font-face { font-family:'Inter'; font-style:normal; font-weight:800; font-display:swap; src:url('/static/fonts/inter-800.woff2') format('woff2'); }

:root {
    --font-display: 'Inter', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
    --font-body: 'Inter', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
    --sidebar-w: 320px;
    --radius-sm: 12px;
    --radius: 18px;
    --radius-lg: 26px;
    --radius-xl: 34px;
    --pill: 999px;
    --ease: cubic-bezier(0.22, 1, 0.36, 1);
    --speed: 0.5s;
    --speed-fast: 0.28s;
    --blur: 22px;
}

[data-theme="light"] {
    --bg: #eef3fc;
    --bg-2: #e6eefb;
    --ink: #132238;
    --ink-soft: #455772;
    --ink-mute: #8090a8;
    --surface: rgba(255, 255, 255, 0.66);
    --surface-2: rgba(255, 255, 255, 0.82);
    --surface-solid: #ffffff;
    --hairline: rgba(19, 34, 56, 0.09);
    --edge: rgba(255, 255, 255, 0.78);
    --accent: #2f74f0;
    --accent-deep: #1d56cf;
    --accent-soft: rgba(47, 116, 240, 0.12);
    --shadow: 0 12px 34px -16px rgba(30, 64, 128, 0.24), 0 4px 12px -8px rgba(30, 64, 128, 0.14);
    --shadow-lg: 0 36px 70px -24px rgba(30, 64, 128, 0.32), 0 14px 30px -16px rgba(30, 64, 128, 0.18);
    --aurora-1: rgba(138, 184, 255, 0.55);
    --aurora-2: rgba(168, 204, 255, 0.48);
    --aurora-3: rgba(150, 226, 255, 0.42);
    --aurora-4: rgba(186, 206, 252, 0.40);
    --grain-opacity: 0.022;
    --on-accent: #ffffff;
}

[data-theme="dark"] {
    --bg: #0b1220;
    --bg-2: #080e1a;
    --ink: #e9eef9;
    --ink-soft: #a8b5cd;
    --ink-mute: #7382a0;
    --surface: rgba(255, 255, 255, 0.05);
    --surface-2: rgba(255, 255, 255, 0.08);
    --surface-solid: #131d2f;
    --hairline: rgba(255, 255, 255, 0.09);
    --edge: rgba(255, 255, 255, 0.10);
    --accent: #5b9bff;
    --accent-deep: #3b7ef0;
    --accent-soft: rgba(91, 155, 255, 0.15);
    --shadow: 0 14px 34px -18px rgba(0, 0, 0, 0.6), 0 4px 12px -8px rgba(0, 0, 0, 0.5);
    --shadow-lg: 0 40px 80px -28px rgba(0, 0, 0, 0.72), 0 16px 32px -18px rgba(0, 0, 0, 0.55);
    --aurora-1: rgba(46, 96, 168, 0.50);
    --aurora-2: rgba(40, 78, 140, 0.44);
    --aurora-3: rgba(58, 120, 180, 0.36);
    --aurora-4: rgba(80, 110, 190, 0.30);
    --grain-opacity: 0.045;
    --on-accent: #07111f;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
    font-family: var(--font-body); background: var(--bg); color: var(--ink);
    line-height: 1.55; min-height: 100vh; letter-spacing: -0.01em;
    -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
    overflow-x: hidden;
}
a { color: inherit; text-decoration: none; }
svg { display: block; }
::selection { background: var(--accent-soft); color: var(--ink); }

/* drifting aurora + grain atmosphere */
body::before {
    content: ''; position: fixed; inset: -25%; z-index: -2; pointer-events: none;
    background:
        radial-gradient(38% 38% at 12% 18%, var(--aurora-1), transparent 62%),
        radial-gradient(34% 34% at 88% 12%, var(--aurora-2), transparent 60%),
        radial-gradient(46% 46% at 82% 88%, var(--aurora-3), transparent 62%),
        radial-gradient(42% 42% at 8% 92%, var(--aurora-4), transparent 62%);
    filter: blur(34px) saturate(1.15);
    animation: drift 32s var(--ease) infinite alternate;
}
body::after {
    content: ''; position: fixed; inset: 0; z-index: -1; pointer-events: none;
    opacity: var(--grain-opacity);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}
@keyframes drift {
    0%   { transform: translate3d(0, 0, 0) scale(1); }
    100% { transform: translate3d(-2%, -3%, 0) scale(1.06); }
}
@media (prefers-reduced-motion: reduce) { body::before { animation: none; } }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--hairline); border-radius: var(--pill); border: 3px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background: var(--ink-mute); background-clip: padding-box; }

/* glass primitive */
.glass {
    background: var(--surface);
    backdrop-filter: blur(var(--blur)) saturate(1.4);
    -webkit-backdrop-filter: blur(var(--blur)) saturate(1.4);
    border: 1px solid var(--edge);
    box-shadow: var(--shadow);
}

/* ── App shell: fixed sidebar flush to the left edge ── */
.app { display: flex; min-height: 100vh; }

.sidebar {
    width: var(--sidebar-w); flex-shrink: 0; position: fixed; top: 0; left: 0;
    height: 100vh; z-index: 100;
    background: var(--surface);
    backdrop-filter: blur(var(--blur)) saturate(1.4); -webkit-backdrop-filter: blur(var(--blur)) saturate(1.4);
    border-right: 1px solid var(--hairline);
    box-shadow: 10px 0 40px -28px rgba(30, 64, 128, 0.28);
    display: flex; flex-direction: column; overflow: hidden;
    transition: transform var(--speed) var(--ease);
}
.main-wrapper { flex: 1; min-width: 0; margin-left: var(--sidebar-w); }

/* sidebar logo: logo in col 1 row 1 only, so the title centers against it
   and the tagline hangs below without pushing the title up */
.sidebar-logo {
    display: grid; grid-template-columns: auto 1fr; align-items: center;
    column-gap: 0.8rem; padding: 1.6rem 1.5rem 1.2rem;
}
.sidebar-logo-img { grid-row: 1; grid-column: 1; max-height: 42px; max-width: 120px; width: auto; height: auto; }
.sidebar-logo-mark {
    grid-row: 1; grid-column: 1;
    width: 46px; height: 46px; border-radius: 15px; flex-shrink: 0;
    background: linear-gradient(145deg, var(--accent), var(--accent-deep));
    box-shadow: 0 10px 22px -8px var(--accent), inset 0 1px 0 rgba(255,255,255,0.3);
    display: flex; align-items: center; justify-content: center;
    color: #fff; font-family: var(--font-display); font-weight: 600; font-size: 1.35rem;
}
.sidebar-logo-name { grid-row: 1; grid-column: 2; min-width: 0; font-family: var(--font-display); font-weight: 700; font-size: 1.16rem; line-height: 1.1; letter-spacing: -0.02em; }
/* negative margin eats the slack under the title, whose row is as tall as the logo */
.sidebar-logo-sub { grid-row: 2; grid-column: 2; margin-top: -4px; font-size: 0.72rem; color: var(--ink-mute); line-height: 1.3; }
/* the content-area copy of the brand block exists only on mobile */
.mobile-brand { display: none; }
/* mobile-only tagline shown above the sidebar search once the brand moves out */
.sidebar-tagline { display: none; }

/* sidebar search launcher */
.sidebar-head { padding: 0.4rem 1.1rem 0.6rem; }
.sidebar-search {
    display: flex; align-items: center; gap: 0.6rem; width: 100%;
    padding: 0.7rem 0.85rem; border-radius: var(--pill);
    background: var(--surface-2); border: 1px solid var(--hairline);
    color: var(--ink-mute); cursor: pointer; font-family: var(--font-body);
    font-size: 0.86rem; transition: all var(--speed-fast) var(--ease);
}
.sidebar-search:hover { border-color: var(--accent); color: var(--ink-soft); box-shadow: 0 4px 16px -8px var(--accent); }
.kbd-chip { margin-left: auto; display: inline-flex; align-items: center; gap: 3px; font-size: 0.66rem; font-weight: 600; padding: 2px 7px; border: 1px solid var(--hairline); border-radius: 7px; color: var(--ink-mute); }
.kbd-chip .kbd-cmd { width: 10px; height: 10px; }

/* nav */
.sidebar-nav { flex: 1; overflow-y: auto; padding: 0.6rem 0.85rem 1rem; display: flex; flex-direction: column; }
.nav-section-label { font-size: 0.64rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.14em; color: var(--ink-mute); padding: 0.9rem 0.85rem 0.5rem; }
.nav-item {
    display: flex; align-items: center; gap: 0.7rem; padding: 0.6rem 0.85rem;
    border-radius: var(--radius-sm); color: var(--ink-soft); font-size: 0.88rem; font-weight: 500;
    cursor: pointer; border: none; background: none; width: 100%; text-align: left;
    font-family: var(--font-body); transition: all var(--speed-fast) var(--ease); position: relative;
}
.nav-item:hover { background: var(--surface-2); color: var(--ink); }
.nav-item.active { background: var(--accent-soft); color: var(--accent-deep); font-weight: 600; }
.nav-item.active::before { content: ''; position: absolute; left: -0.85rem; top: 50%; transform: translateY(-50%); width: 4px; height: 18px; border-radius: var(--pill); background: linear-gradient(var(--accent), var(--accent-deep)); }
.nav-ico { width: 18px; height: 18px; flex-shrink: 0; opacity: 0.85; }
.nav-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-count { font-size: 0.72rem; color: var(--ink-mute); font-variant-numeric: tabular-nums; }
.nav-item.active .nav-count { color: var(--accent); }
.sidebar-links { display: flex; flex-direction: column; gap: 5px; }
.nav-item.is-link .nav-ico { opacity: 0.55; }

/* sidebar footer */
.sidebar-footer { border-top: 1px solid var(--hairline); padding: 0.9rem 1.1rem; display: flex; flex-direction: column; gap: 0.7rem; }
.footer-links { display: flex; flex-wrap: wrap; gap: 8px; }
.footer-link-text { font-size: 0.8rem; color: var(--ink-soft); transition: color var(--speed-fast); }
.footer-link-text:hover { color: var(--accent); }
.footer-row { display: flex; align-items: center; gap: 0.6rem; }
.footer-row .grow { flex: 1; min-width: 0; }
.sidebar-meta { font-size: 0.68rem; color: var(--ink-mute); }

/* round icon buttons */
.icon-btn {
    width: 38px; height: 38px; border-radius: var(--pill); flex-shrink: 0;
    border: 1px solid var(--hairline); background: var(--surface-2); color: var(--ink-soft);
    cursor: pointer; display: inline-flex; align-items: center; justify-content: center;
    transition: all var(--speed-fast) var(--ease);
}
.icon-btn:hover { color: var(--ink); border-color: var(--accent); box-shadow: 0 4px 14px -8px var(--accent); transform: translateY(-1px); }

/* ── Content ── */
.content { padding: 0.4rem 2rem 4rem; max-width: 1500px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 1.5rem; flex-wrap: wrap; padding: 2.2rem 0 1.8rem; }
.eyebrow { font-size: 0.68rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.16em; color: var(--accent); margin-bottom: 0.5rem; }
.page-title { font-family: var(--font-display); font-weight: 700; font-size: clamp(1.9rem, 3.6vw, 2.7rem); line-height: 1.05; letter-spacing: -0.03em; }
.page-sub { color: var(--ink-soft); font-size: 0.95rem; margin-top: 0.55rem; }
.head-tools { display: flex; align-items: center; gap: 0.7rem; flex-wrap: wrap; }

/* view toggle — sliding gradient pill */
.view-toggle { position: relative; display: inline-flex; padding: 4px; border-radius: var(--pill); background: var(--surface-2); border: 1px solid var(--hairline); backdrop-filter: blur(12px); }
.view-pill { position: absolute; top: 4px; bottom: 4px; border-radius: var(--pill); background: linear-gradient(135deg, var(--accent), var(--accent-deep)); box-shadow: 0 8px 18px -8px var(--accent); transition: left var(--speed) var(--ease), width var(--speed) var(--ease); z-index: 0; }
.seg { position: relative; z-index: 1; display: inline-flex; align-items: center; gap: 6px; padding: 0.5rem 1rem; border: none; background: none; border-radius: var(--pill); font-family: var(--font-body); font-size: 0.82rem; font-weight: 600; color: var(--ink-mute); cursor: pointer; transition: color var(--speed) var(--ease); white-space: nowrap; }
.seg.active { color: var(--on-accent); }

/* ── Card grid ── */
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 1.4rem; }
.kb-card {
    position: relative; border-radius: var(--radius-lg); overflow: hidden; cursor: pointer;
    background: var(--surface);
    backdrop-filter: blur(var(--blur)) saturate(1.3); -webkit-backdrop-filter: blur(var(--blur)) saturate(1.3);
    border: 1px solid var(--edge); box-shadow: var(--shadow);
    display: flex; flex-direction: column;
    transition: transform var(--speed) var(--ease), box-shadow var(--speed) var(--ease), border-color var(--speed) var(--ease);
    animation: rise 0.6s var(--ease) both; animation-delay: calc(var(--i, 0) * 45ms);
}
.kb-card:hover { transform: translateY(-6px); box-shadow: var(--shadow-lg); border-color: color-mix(in srgb, var(--accent) 50%, transparent); }
.kb-thumb { height: 168px; position: relative; overflow: hidden; display: flex; align-items: center; justify-content: center; background: linear-gradient(150deg, var(--accent-soft), transparent); }
.kb-thumb img { width: 100%; height: 100%; object-fit: cover; transition: transform var(--speed) var(--ease); }
.kb-card:hover .kb-thumb img { transform: scale(1.05); }
.kb-thumb::after { content: ''; position: absolute; inset: 0; background: linear-gradient(180deg, transparent 55%, rgba(0,0,0,0.18)); opacity: 0; transition: opacity var(--speed); }
.kb-card:hover .kb-thumb::after { opacity: 1; }
.kb-thumb-icon { width: 52px; height: 52px; color: var(--accent); opacity: 0.55; }
.kb-ext-badge {
    position: absolute; top: 12px; right: 12px; padding: 4px 11px; border-radius: var(--pill);
    background: rgba(255,255,255,0.78); color: var(--accent-deep); font-size: 0.62rem; font-weight: 700;
    text-transform: uppercase; letter-spacing: 0.08em; backdrop-filter: blur(8px); border: 1px solid rgba(255,255,255,0.5);
}
[data-theme="dark"] .kb-ext-badge { background: rgba(0,0,0,0.45); color: var(--accent); border-color: rgba(255,255,255,0.12); }
.kb-card-body { padding: 1.1rem 1.2rem 1.25rem; display: flex; flex-direction: column; gap: 0.55rem; flex: 1; }
.kb-card-cat { font-size: 0.66rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.12em; color: var(--accent); }
.kb-card-title { font-family: var(--font-display); font-weight: 600; font-size: 1.05rem; line-height: 1.3; letter-spacing: -0.018em; }
.kb-card-desc { font-size: 0.84rem; color: var(--ink-soft); line-height: 1.5; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.chip-row { display: flex; flex-wrap: wrap; gap: 6px; margin-top: auto; padding-top: 0.45rem; }

@keyframes rise { from { opacity: 0; transform: translateY(18px); } to { opacity: 1; transform: translateY(0); } }

/* chips */
.chip { font-size: 0.7rem; font-weight: 500; padding: 3px 11px; border-radius: var(--pill); background: var(--surface-2); color: var(--ink-soft); border: 1px solid var(--hairline); white-space: nowrap; }
.chip.part { background: var(--accent-soft); color: var(--accent-deep); border-color: transparent; font-weight: 600; }
a.chip.part { transition: all var(--speed-fast) var(--ease); }
a.chip.part:hover { background: var(--accent); color: var(--on-accent); transform: translateY(-1px); }

/* ── Table view — editorial index ── */
/* overflow-x is auto (not hidden) so narrow desktop widths scroll the table
   instead of clipping the right-hand columns; overflow-y stays hidden to keep
   the rounded corners clipping the header row. */
.index-wrap {
    border-radius: var(--radius-lg); overflow-x: auto; overflow-y: hidden;
    background: var(--surface); backdrop-filter: blur(var(--blur)) saturate(1.3); -webkit-backdrop-filter: blur(var(--blur)) saturate(1.3);
    border: 1px solid var(--edge); box-shadow: var(--shadow);
    animation: rise 0.5s var(--ease) both;
}
/* Fixed layout: auto layout let the nowrap chip columns bully the Document
   column down to ~200px, stacking titles over three lines. Columns now hold a
   deliberate share of the row and the low-value chip columns drop out at narrow
   widths rather than everything scrolling sideways. */
.index-table { width: 100%; min-width: 560px; table-layout: fixed; border-collapse: separate; border-spacing: 0; }
.index-table th:nth-child(1), .index-table td:nth-child(1) { width: 30%; }
.index-table th:nth-child(2), .index-table td:nth-child(2) { width: 13%; }
.index-table th:nth-child(3), .index-table td:nth-child(3) { width: 21%; }
.index-table th:nth-child(4), .index-table td:nth-child(4) { width: 15%; }
.index-table th:nth-child(5), .index-table td:nth-child(5) { width: 9%; }
.index-table th:nth-child(6), .index-table td:nth-child(6) { width: 12%; }
.index-table th { text-align: left; padding: 1rem 1.4rem; font-size: 0.64rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.12em; color: var(--ink-mute); border-bottom: 1px solid var(--hairline); white-space: nowrap; }
/* Sortable headers: the button carries the cell's padding so the whole header
   is the hit target, and the chevron only goes solid on the active column. */
.index-table th.sortable { padding: 0; }
.index-table th.sortable .th-sort { display: flex; align-items: center; gap: 0.4rem; width: 100%; padding: 1rem 1.4rem; background: none; border: 0; font: inherit; color: inherit; text-transform: inherit; letter-spacing: inherit; text-align: left; cursor: pointer; transition: color var(--speed-fast) var(--ease); }
.index-table th.sortable .th-sort:hover { color: var(--ink); }
.index-table th.sortable .th-sort:focus-visible { outline: 2px solid var(--accent); outline-offset: -3px; }
.index-table th.sortable .th-sort.active { color: var(--accent); }
.sort-ind { width: 12px; height: 12px; flex-shrink: 0; opacity: 0; transition: opacity var(--speed-fast) var(--ease); }
.th-sort:hover .sort-ind { opacity: 0.5; }
.th-sort.active .sort-ind { opacity: 1; }
.index-table td { padding: 1.15rem 1.4rem; border-bottom: 1px solid var(--hairline); vertical-align: middle; color: var(--ink-soft); }
.index-table tbody tr { cursor: pointer; transition: background var(--speed-fast) var(--ease); }
.index-table tbody tr:hover td { background: var(--surface-2); }
.index-table tbody tr:last-child td { border-bottom: none; }
/* Action column hugs its button rather than taking an even share of the row. */
.index-table th:last-child, .index-table td:last-child { white-space: nowrap; }
.idx-title { display: flex; align-items: center; gap: 0.85rem; }
.idx-thumb { width: 46px; height: 46px; border-radius: 12px; flex-shrink: 0; overflow: hidden; background: linear-gradient(150deg, var(--accent-soft), transparent); display: flex; align-items: center; justify-content: center; color: var(--accent); }
.idx-thumb img { width: 100%; height: 100%; object-fit: cover; }
.idx-thumb svg { width: 20px; height: 20px; }
.idx-title-text { font-family: var(--font-display); font-weight: 600; font-size: 0.98rem; color: var(--ink); letter-spacing: -0.012em; overflow-wrap: break-word; }
.mini-chip { font-size: 0.68rem; font-weight: 500; padding: 2px 9px; border-radius: var(--pill); background: var(--surface-2); border: 1px solid var(--hairline); margin: 2px 3px 2px 0; display: inline-block; white-space: nowrap; color: var(--ink-soft); }
.mini-chip.part { background: var(--accent-soft); color: var(--accent-deep); border-color: transparent; font-weight: 600; }
a.mini-chip.part:hover { background: var(--accent); color: var(--on-accent); }
.cell-muted { color: var(--ink-mute); }
.cell-link:hover { color: var(--accent); }
/* Titles are real links now (crawlable, middle-clickable); they keep the cell's
   look and only pick up the accent on hover. */
.idx-title-text:hover, .kb-card-title:hover { color: var(--accent); }
/* Narrow desktops: shed the chip columns (both are still shown in the detail
   modal) so Document keeps a readable width instead of scrolling out of reach. */
@media (max-width: 1200px) {
    .index-table th:nth-child(4), .index-table td:nth-child(4) { display: none; }
    .index-table th:nth-child(1), .index-table td:nth-child(1) { width: 34%; }
    .index-table th:nth-child(2), .index-table td:nth-child(2) { width: 15%; }
    .index-table th:nth-child(3), .index-table td:nth-child(3) { width: 26%; }
    .index-table th:nth-child(5), .index-table td:nth-child(5) { width: 10%; }
    .index-table th:nth-child(6), .index-table td:nth-child(6) { width: 15%; }
}
@media (max-width: 1000px) {
    .index-table th:nth-child(3), .index-table td:nth-child(3) { display: none; }
    .index-table th:nth-child(1), .index-table td:nth-child(1) { width: 45%; }
    .index-table th:nth-child(2), .index-table td:nth-child(2) { width: 22%; }
    .index-table th:nth-child(5), .index-table td:nth-child(5) { width: 13%; }
    .index-table th:nth-child(6), .index-table td:nth-child(6) { width: 20%; }
}
/* Phones: title + type + action only, tighter cells, no sideways scroll. */
@media (max-width: 640px) {
    .index-table { min-width: 0; }
    .index-table th:nth-child(2), .index-table td:nth-child(2) { display: none; }
    .index-table th:nth-child(1), .index-table td:nth-child(1) { width: 58%; }
    .index-table th:nth-child(5), .index-table td:nth-child(5) { width: 16%; }
    .index-table th:nth-child(6), .index-table td:nth-child(6) { width: 26%; }
    .index-table th { padding: 0.85rem 0.7rem; }
    .index-table td { padding: 0.95rem 0.7rem; }
    .idx-thumb { width: 38px; height: 38px; border-radius: 10px; }
    .idx-title { gap: 0.6rem; }
}

/* ── Buttons ── */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; padding: 0.65rem 1.3rem; border: none; border-radius: var(--pill); font-family: var(--font-body); font-size: 0.85rem; font-weight: 600; cursor: pointer; transition: all var(--speed-fast) var(--ease); white-space: nowrap; }
.btn-primary { background: linear-gradient(135deg, var(--accent), var(--accent-deep)); color: var(--on-accent); box-shadow: 0 10px 24px -10px var(--accent); }
.btn-primary:hover { transform: translateY(-2px); box-shadow: 0 16px 30px -10px var(--accent); }
.btn-ghost { background: var(--surface-2); color: var(--ink-soft); border: 1px solid var(--hairline); }
.btn-ghost:hover { color: var(--ink); border-color: var(--accent); }
.btn-sm { padding: 0.45rem 0.95rem; font-size: 0.78rem; }

/* sidebar link button */
.sidebar-link-button { width: 100%; }

/* Plain-HTML fallback (crawlers / no JS) — never seen by a normal visitor. */
.noscript-index { padding: 1rem 0 2rem; color: var(--ink-soft); }
.noscript-index ul { padding-left: 1.2rem; }
.noscript-index li { margin: 0.35rem 0; }
.noscript-index a { color: var(--accent-deep); text-decoration: underline; }

/* ── Empty / loading ── */
.empty-state { text-align: center; padding: 5rem 1rem; color: var(--ink-mute); }
.empty-state svg { width: 56px; height: 56px; margin: 0 auto 1.2rem; opacity: 0.4; color: var(--accent); }
.empty-state h3 { font-family: var(--font-display); font-weight: 600; color: var(--ink-soft); font-size: 1.2rem; margin-bottom: 0.4rem; letter-spacing: -0.01em; }
.spinner { width: 34px; height: 34px; border: 2.5px solid var(--hairline); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.8s linear infinite; margin: 4rem auto; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Command palette ── */
.cmdk-overlay { position: fixed; inset: 0; z-index: 300; display: flex; align-items: flex-start; justify-content: center; padding: 12vh 1.2rem 1.2rem; background: rgba(16, 28, 24, 0.55); opacity: 0; pointer-events: none; transition: opacity var(--speed-fast) var(--ease); }
.cmdk-overlay.active { opacity: 1; pointer-events: all; }
.cmdk { width: 100%; max-width: 660px; border-radius: var(--radius-lg); overflow: hidden; background: var(--surface-solid); border: 1px solid var(--edge); box-shadow: var(--shadow-lg); transform: translateY(-14px) scale(0.98); transition: transform var(--speed) var(--ease); }
.cmdk-overlay.active .cmdk { transform: none; }
.cmdk-input-wrap { display: flex; align-items: center; gap: 0.8rem; padding: 1.15rem 1.3rem; border-bottom: 1px solid var(--hairline); color: var(--accent); }
.cmdk-input { flex: 1; border: none; background: none; outline: none; color: var(--ink); font-family: var(--font-body); font-size: 1.08rem; letter-spacing: -0.01em; }
.cmdk-input::placeholder { color: var(--ink-mute); }
.cmdk-results { max-height: 56vh; overflow-y: auto; padding: 0.5rem; }
.cmdk-item { display: flex; align-items: center; gap: 0.85rem; padding: 0.7rem 0.8rem; border-radius: var(--radius-sm); cursor: pointer; transition: background var(--speed-fast); }
.cmdk-item.sel, .cmdk-item:hover { background: var(--accent-soft); }
.cmdk-item-thumb { width: 42px; height: 42px; border-radius: 11px; flex-shrink: 0; overflow: hidden; background: linear-gradient(150deg, var(--accent-soft), transparent); display: flex; align-items: center; justify-content: center; color: var(--accent); }
.cmdk-item-thumb img { width: 100%; height: 100%; object-fit: cover; }
.cmdk-item-thumb svg { width: 20px; height: 20px; }
.cmdk-item-main { flex: 1; min-width: 0; }
.cmdk-item-title { font-family: var(--font-display); font-weight: 600; font-size: 0.92rem; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cmdk-item-sub { font-size: 0.75rem; color: var(--ink-mute); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 1px; }
.cmdk-empty { padding: 3rem 1rem; text-align: center; color: var(--ink-mute); font-size: 0.9rem; }
.cmdk-foot { padding: 0.65rem 1.3rem; border-top: 1px solid var(--hairline); font-size: 0.7rem; color: var(--ink-mute); display: flex; gap: 1.4rem; }
.cmdk-kbd { font-weight: 600; border: 1px solid var(--hairline); border-radius: 6px; padding: 1px 6px; }

/* ── Detail modal ── */
.modal-overlay { position: fixed; inset: 0; z-index: 200; display: flex; align-items: center; justify-content: center; padding: 1.5rem; background: rgba(16, 28, 24, 0.55); opacity: 0; pointer-events: none; transition: opacity var(--speed-fast) var(--ease); }
.modal-overlay.active { opacity: 1; pointer-events: all; }
/* Solid (not translucent) panel; the header is a fixed row and only .modal-body scrolls. */
.modal { width: 100%; max-width: 900px; max-height: 90vh; display: flex; flex-direction: column; overflow: hidden; border-radius: var(--radius-lg); background: var(--surface-solid); border: 1px solid var(--hairline); box-shadow: var(--shadow-lg); transform: translateY(16px) scale(0.98); transition: transform var(--speed) var(--ease); }
.modal-overlay.active .modal { transform: none; }
.modal-header { flex-shrink: 0; display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; padding: 1.4rem 1.6rem; border-bottom: 1px solid var(--hairline); background: var(--surface-solid); }
.modal-header h2 { font-family: var(--font-display); font-weight: 700; font-size: 1.4rem; line-height: 1.25; letter-spacing: -0.025em; }
/* Download / share / copy / close sit together; the share menu hangs off this row. */
.modal-tools { position: relative; z-index: 3; flex-shrink: 0; display: flex; align-items: center; gap: 0.45rem; }
.modal-download { margin-right: 0.15rem; }
/* .btn is inline-flex, which would otherwise beat the UA's [hidden] rule. */
.modal-download[hidden] { display: none; }
.modal-close, .modal-action { width: 36px; height: 36px; flex-shrink: 0; display: inline-flex; align-items: center; justify-content: center; border: 1px solid var(--hairline); background: var(--surface-2); color: var(--ink-soft); border-radius: var(--pill); cursor: pointer; font-size: 1.2rem; line-height: 1; transition: all var(--speed-fast); }
.modal-close:hover, .modal-action:hover { background: var(--accent); color: var(--on-accent); border-color: transparent; }
.modal-body { flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 1.6rem; }
.detail-images { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; margin: 0 0 1.3rem; }
.detail-thumb { aspect-ratio: 4 / 3; padding: 0; border: 1px solid var(--hairline); border-radius: var(--radius-sm); overflow: hidden; background: var(--surface-2); cursor: zoom-in; transition: transform var(--speed-fast) var(--ease), box-shadow var(--speed-fast) var(--ease); }
.detail-thumb:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.detail-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }

/* glossary */
.glossary-search { width: 100%; padding: 0.7rem 0.9rem; border-radius: var(--radius-sm); border: 1px solid var(--hairline); background: var(--surface-2); color: var(--ink); font-family: var(--font-body); font-size: 0.9rem; margin-bottom: 0.6rem; outline: none; transition: border-color var(--speed-fast); }
.glossary-search:focus { border-color: var(--accent); }
.glossary-letter { font-size: 0.72rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.12em; color: var(--accent); padding: 0.9rem 0 0.35rem; border-bottom: 1px solid var(--hairline); margin-bottom: 0.4rem; }
.glossary-row { display: flex; gap: 1rem; padding: 0.45rem 0; }
.glossary-term { flex: 0 0 32%; min-width: 0; font-weight: 600; font-size: 0.9rem; }
.glossary-def { flex: 1; min-width: 0; font-size: 0.88rem; color: var(--ink-soft); line-height: 1.5; }
.glossary-empty { color: var(--ink-mute); padding: 1rem 0; }
@media (max-width: 640px){ .glossary-row { flex-direction: column; gap: 2px; } .glossary-term { flex: none; } }

/* fullscreen image lightbox */
.lightbox { position: fixed; inset: 0; z-index: 400; display: none; align-items: center; justify-content: center; background: rgba(10, 16, 24, 0.9); overflow: hidden; }
.lightbox.open { display: flex; }
.lightbox img { max-width: 94vw; max-height: 92vh; object-fit: contain; border-radius: 8px; box-shadow: var(--shadow-lg); cursor: zoom-in; touch-action: none; user-select: none; }
.lightbox img.zoomed { cursor: grab; }
.lightbox img.zoomed:active { cursor: grabbing; }
.lightbox-btn { position: fixed; z-index: 2; width: 44px; height: 44px; display: flex; align-items: center; justify-content: center; border: 1px solid rgba(255,255,255,0.25); border-radius: var(--pill); background: rgba(12, 18, 28, 0.6); color: #fff; font-size: 1.5rem; line-height: 1; cursor: pointer; transition: background var(--speed-fast); }
.lightbox-btn:hover { background: rgba(12, 18, 28, 0.85); }
.lightbox-close { top: 18px; right: 18px; }
.lightbox-zoom-in { top: 18px; right: 70px; font-size: 1.25rem; }
.lightbox-zoom-out { top: 18px; right: 122px; font-size: 1.25rem; }
.lightbox-prev { left: 18px; top: 50%; transform: translateY(-50%); }
.lightbox-next { right: 18px; top: 50%; transform: translateY(-50%); }
.lightbox-btn[hidden] { display: none; }
.detail-meta { display: flex; flex-wrap: wrap; gap: 1rem 2rem; margin: 1.1rem 0; padding: 1.2rem 1.4rem; border-radius: var(--radius); background: var(--surface-2); border: 1px solid var(--hairline); }
.detail-meta .mk { font-size: 0.62rem; text-transform: uppercase; letter-spacing: 0.1em; color: var(--ink-mute); margin-bottom: 3px; }
.detail-meta .mv { font-size: 0.92rem; color: var(--ink); }
/* Fitment is a list, so it gets a ceiling and wraps inside its own cell rather
   than stretching the meta row and pushing File/Size onto another line. */
.detail-meta .meta-fit { max-width: 26rem; }
.detail-meta .meta-chips { display: flex; flex-wrap: wrap; gap: 6px; padding-top: 2px; }
.detail-label { font-size: 0.64rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.12em; color: var(--accent); margin-bottom: 0.6rem; }
.preview-frame { width: 100%; height: 74vh; border: 1px solid var(--hairline); border-radius: var(--radius); background: var(--surface-2); }
/* Narrow screens: the label would push the title into a three-line stack, so
   the download button drops to its icon and matches the round tool buttons. */
@media (max-width: 700px) {
    .modal-download span { display: none; }
    .modal-download { width: 36px; height: 36px; padding: 0; margin-right: 0; }
}

/* ── Toasts ── */
.toast-wrap { position: fixed; bottom: 24px; right: 24px; z-index: 400; display: flex; flex-direction: column; gap: 10px; }
.toast { padding: 0.85rem 1.2rem; border-radius: var(--radius); font-size: 0.85rem; font-weight: 500; box-shadow: var(--shadow-lg); color: #fff; animation: toastin var(--speed-fast) var(--ease); }
.toast.success { background: linear-gradient(135deg, var(--accent), var(--accent-deep)); }
.toast.error { background: linear-gradient(135deg, #e06b6b, #c44d4d); }
@keyframes toastin { from { opacity: 0; transform: translateX(20px); } }

/* ── Mobile ── */
.scrim { position: fixed; inset: 0; background: rgba(16,28,24,0.4); backdrop-filter: blur(3px); z-index: 99; opacity: 0; pointer-events: none; transition: opacity var(--speed-fast); }
.scrim.show { opacity: 1; pointer-events: all; }
.mobile-menu { display: none; }
@media (max-width: 900px) {
    .sidebar { transform: translateX(-100%); box-shadow: var(--shadow-lg); max-width: 86vw; }
    .sidebar.open { transform: translateX(0); }
    .main-wrapper { margin-left: 0; }
    .content { padding: 0.8rem 1.2rem 4rem; }
    .mobile-menu { display: inline-flex; position: fixed; top: 14px; left: 14px; z-index: 90; }
    .page-head { padding-top: 1rem; }
    /* branding moves from the sidebar into the content on mobile;
       indented past the fixed burger button so logo + title share its line */
    .sidebar .sidebar-logo { display: none; }
    .mobile-brand { display: grid; grid-template-columns: auto auto; justify-content: center; padding: 0 2.6rem; }
    .eyebrow { display: none; }
    .sidebar-tagline { display: block; padding: 2rem 1.5rem 0; font-size: 0.72rem; color: var(--ink-mute); line-height: 1.3; }
    .sidebar-head { padding-top: 0.8rem; }
}
