/* KSG Knowledge Hub — hand-written stylesheet (no build step required) */

:root {
    --bg: #f5f4f1;
    --surface: #ffffff;
    --surface-2: #faf9f7;
    --border: #e6e2da;
    --border-strong: #d6d0c4;
    --text: #1c1a17;
    --text-2: #4a453d;
    --muted: #6b655c;
    --brand: #7a5a2b;
    --brand-hover: #634820;
    --brand-soft: #f3ece1;
    --brand-ink: #5b431f;
    --kenya-black: #111111;
    --kenya-red: #bb1e10;
    --kenya-green: #1f6b35;
    --radius: 14px;
    --radius-sm: 8px;
    --shadow: 0 1px 2px rgba(28, 26, 23, .04), 0 1px 1px rgba(28, 26, 23, .03);
    --shadow-lg: 0 18px 50px -12px rgba(28, 26, 23, .28);
    --font: "Plus Jakarta Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
    --container: 1216px;
    --sidebar-w: 248px;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: 120px; }
body {
    margin: 0;
    font-family: var(--font);
    font-size: 15px;
    line-height: 1.55;
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
}
img, svg, video, iframe { max-width: 100%; display: block; }
a { color: var(--brand); text-decoration: none; }
a:hover { color: var(--brand-hover); text-decoration: underline; text-underline-offset: 3px; }
h1, h2, h3 { margin: 0; line-height: 1.2; letter-spacing: -.02em; color: var(--text); }
p { margin: 0; }
button { font: inherit; color: inherit; }
kbd {
    font-family: var(--mono); font-size: .72em; padding: 1px 5px; border-radius: 4px;
    border: 1px solid var(--border-strong); background: var(--surface); color: var(--muted);
}
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; border-radius: 4px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip-link { position: absolute; left: -999px; top: 8px; z-index: 100; background: var(--brand); color: #fff; padding: 8px 14px; border-radius: 6px; }
.skip-link:focus { left: 8px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.block { display: block; }
[hidden] { display: none !important; }

.container { width: 100%; max-width: var(--container); margin: 0 auto; padding: 0 24px; }
.container--narrow { max-width: 960px; }
.site-main { padding: 32px 0 64px; min-height: 60vh; }

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    height: 40px; padding: 0 18px; border-radius: var(--radius-sm);
    font-size: 14px; font-weight: 600; white-space: nowrap; cursor: pointer;
    border: 1px solid transparent; transition: background-color .15s, border-color .15s, color .15s;
    text-decoration: none !important;
}
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-hover); color: #fff; }
.btn-outline { background: var(--surface); border-color: var(--border-strong); color: var(--text); }
.btn-outline:hover { border-color: var(--brand); color: var(--brand); }
.btn-outline[aria-pressed="true"] { background: var(--brand-soft); border-color: var(--brand); color: var(--brand-ink); }
.btn-ghost { background: transparent; color: var(--muted); }
.btn-ghost:hover { color: var(--brand); background: var(--brand-soft); }
.btn-sm { height: 32px; padding: 0 12px; font-size: 13px; }
.btn-block { width: 100%; margin-top: 12px; }
.icon-btn { display: inline-grid; place-items: center; width: 40px; height: 40px; border: 0; background: none; border-radius: var(--radius-sm); cursor: pointer; }
.icon-btn:hover { background: var(--brand-soft); }
.link-sm { font-size: 13px; font-weight: 600; }

/* ---------- Header ---------- */
.site-header { position: sticky; top: 0; z-index: 40; background: var(--surface); }
.header-bar {
    display: grid; grid-template-columns: 1fr auto 1fr; align-items: center;
    height: 58px; padding: 0 22px; border-top: 2px solid var(--kenya-black);
}
.brand { display: inline-flex; align-items: center; gap: 12px; color: var(--text); font-weight: 700; font-size: 17px; letter-spacing: -.02em; }
.brand:hover { color: var(--text); text-decoration: none; }
.brand img { height: 30px; width: auto; }
.main-nav { display: flex; gap: 6px; }
.main-nav a { padding: 6px 12px; border-radius: 6px; color: var(--text-2); font-size: 14px; font-weight: 500; }
.main-nav a:hover { color: var(--brand); background: var(--brand-soft); text-decoration: none; }
.main-nav a.active { color: var(--brand); font-weight: 600; }
.header-actions { display: flex; justify-content: flex-end; align-items: center; gap: 8px; }
.menu-toggle { display: none; }

.tricolor { display: grid; grid-template-columns: 1fr 1fr 1fr; height: 2px; }
.tricolor span:nth-child(1) { background: var(--kenya-black); }
.tricolor span:nth-child(2) { background: var(--kenya-red); }
.tricolor span:nth-child(3) { background: var(--kenya-green); }
.tricolor--short { width: 240px; margin: 14px 0 18px; }

.sub-bar {
    display: flex; justify-content: space-between; align-items: center;
    height: 30px; padding: 0 18px; background: var(--surface-2); border-bottom: 1px solid var(--border);
}
.quick-search-trigger, .layout-toggle {
    display: inline-flex; align-items: center; gap: 7px; border: 0; background: none; cursor: pointer;
    color: var(--muted); font-size: 13px; padding: 3px 6px; border-radius: 6px;
}
.quick-search-trigger:hover, .layout-toggle:hover { color: var(--brand); background: var(--brand-soft); }

/* ---------- Sidebar layout ---------- */
.side-nav { display: none; }
.sidebar-layout .side-nav {
    display: block; position: fixed; left: 0; top: 92px; bottom: 0; width: var(--sidebar-w);
    background: var(--surface); border-right: 1px solid var(--border); overflow-y: auto; padding: 18px 14px 40px; z-index: 30;
}
.sidebar-layout .main-nav { visibility: hidden; }
.sidebar-layout .site-main, .sidebar-layout .site-footer { margin-left: var(--sidebar-w); }
.side-nav nav { display: flex; flex-direction: column; gap: 2px; }
.side-nav a { padding: 7px 12px; border-radius: 7px; color: var(--text-2); font-size: 14px; font-weight: 500; }
.side-nav a:hover { background: var(--brand-soft); color: var(--brand); text-decoration: none; }
.side-nav a.active { background: var(--brand-soft); color: var(--brand-ink); font-weight: 600; }
.side-heading { margin: 16px 12px 6px; font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.side-heading:first-child { margin-top: 0; }

/* ---------- Cards & common ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.eyebrow { font-size: 13px; font-weight: 500; color: var(--brand-ink); margin-bottom: 10px; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; margin: 8px 0 24px; }
.page-head h1 { font-size: 32px; font-weight: 700; }
.page-head .muted { margin-top: 6px; }
.section-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.section-head h2 { font-size: 22px; font-weight: 700; }
.section-head .muted { font-size: 13px; margin-top: 4px; }
.notice { background: #fff7e6; border: 1px solid #f0d9a8; color: #6b4a0f; padding: 10px 16px; border-radius: var(--radius-sm); margin-bottom: 16px; font-size: 14px; }

.input-icon { position: relative; display: flex; align-items: center; }
.input-icon svg { position: absolute; left: 14px; color: var(--muted); pointer-events: none; }
.input-icon input {
    width: 100%; height: 44px; padding: 0 14px 0 40px; font: inherit; font-size: 15px; color: var(--text);
    background: var(--surface-2); border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
}
.input-icon input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(122, 90, 43, .15); background: #fff; }
.grow { flex: 1; }

/* ---------- Hero ---------- */
.hero { display: grid; grid-template-columns: 1.4fr 1fr; overflow: hidden; min-height: 448px; }
.hero-copy { padding: 52px 48px; display: flex; flex-direction: column; justify-content: center; }
.hero-logo { height: 48px; width: auto; }
.hero h1 { font-size: clamp(32px, 3.6vw, 44px); font-weight: 700; letter-spacing: -.035em; line-height: 1.12; max-width: 560px; }
.hero .lead { margin-top: 18px; font-size: 17px; color: var(--text-2); max-width: 560px; line-height: 1.6; }
.hero-search { display: flex; gap: 12px; margin-top: 28px; flex-wrap: wrap; }
.hero-search .input-icon { flex: 1 1 260px; max-width: 300px; }
.hero-search .btn { height: 44px; }
.hero-media { position: relative; margin: 0; min-height: 320px; background: #2a2116; }
.hero-media img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.hero-media figcaption {
    position: absolute; left: 0; right: 0; bottom: 0; padding: 60px 24px 20px; color: #fff;
    background: linear-gradient(to top, rgba(0, 0, 0, .72), transparent);
    display: flex; flex-direction: column; gap: 2px; font-size: 13px;
}
.hero-media figcaption strong { font-weight: 600; font-size: 14px; }
.hero-media figcaption span { opacity: .85; }
/* Placeholder used until a hero photo is uploaded in Site settings */
.hero-shelves {
    position: absolute; inset: 0;
    background:
        linear-gradient(180deg, rgba(20, 14, 6, .1), rgba(20, 14, 6, .55)),
        repeating-linear-gradient(180deg, transparent 0 86px, #3a2b17 86px 98px),
        repeating-linear-gradient(90deg,
            #7a5a2b 0 14px, #4d3a1c 14px 16px, #9b2a1f 16px 27px, #3b2a14 27px 29px,
            #1f5a33 29px 42px, #2e2212 42px 44px, #a88a5c 44px 52px, #3b2a14 52px 54px,
            #5b431f 54px 70px, #2e2212 70px 72px, #c9b48c 72px 80px, #3b2a14 80px 82px,
            #26354a 82px 96px, #2e2212 96px 98px);
}

/* ---------- Stats ---------- */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); margin-top: 32px; }
.stat { padding: 22px 22px; display: flex; flex-direction: column; gap: 6px; }
.stat + .stat { border-left: 1px solid var(--border); }
.stat-label { font-size: 13px; color: var(--text-2); }
.stat-value { font-size: 26px; font-weight: 600; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.stat-sub { font-size: 12.5px; color: var(--muted); }

/* ---------- Directory filters ---------- */
.directory { margin-top: 48px; }
.segmented { display: inline-flex; gap: 2px; padding: 4px; background: #ebe8e2; border-radius: 10px; }
.segmented a { padding: 6px 14px; border-radius: 7px; font-size: 13.5px; font-weight: 500; color: var(--text-2); }
.segmented a:hover { color: var(--text); text-decoration: none; }
.segmented a.active { background: var(--surface); color: var(--text); box-shadow: 0 1px 2px rgba(0, 0, 0, .08); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 26px; }
.chip {
    padding: 6px 14px; border: 1px solid var(--border-strong); border-radius: 8px; background: var(--surface);
    font-size: 13.5px; font-weight: 500; color: var(--text-2);
}
.chip:hover { border-color: var(--brand); color: var(--brand); text-decoration: none; }
.chip.active { background: var(--brand); border-color: var(--brand); color: #fff; }
[data-directory-results] { transition: opacity .15s; }
[data-directory-results].loading { opacity: .45; }

/* ---------- Resource cards ---------- */
.card-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 24px; }
.resource-card { position: relative; display: flex; flex-direction: column; overflow: hidden; transition: box-shadow .2s, transform .2s; }
.resource-card:hover { box-shadow: 0 10px 30px -12px rgba(28, 26, 23, .25); transform: translateY(-2px); }
.card-link { display: block; }
.cover { position: relative; aspect-ratio: 4 / 3; overflow: hidden; background: #2a2116; }
.cover img { width: 100%; height: 100%; object-fit: cover; transition: transform .4s; }
.resource-card:hover .cover img { transform: scale(1.03); }
.cover-overlay {
    position: absolute; left: 0; right: 0; bottom: 0; display: flex; justify-content: space-between; align-items: flex-end; gap: 12px;
    padding: 48px 16px 14px; background: linear-gradient(to top, rgba(0, 0, 0, .7), transparent); color: #fff;
}
.cover-collection { font-size: 13.5px; font-weight: 600; }
.cover-format { font-family: var(--mono); font-size: 12px; font-weight: 500; opacity: .95; }
/* Placeholder covers, one tone per format */
.cover--placeholder { --c1: #5b431f; --c2: #2c2013; }
.cover--placeholder.cover--pdf { --c1: #7a3324; --c2: #2f160f; }
.cover--placeholder.cover--word { --c1: #2c4a6e; --c2: #121e2c; }
.cover--placeholder.cover--video { --c1: #285a3c; --c2: #0f2418; }
.cover--placeholder.cover--audio { --c1: #5a3560; --c2: #221425; }
.cover-art {
    position: absolute; inset: 0; padding: 22px 22px 60px; display: flex; flex-direction: column; justify-content: space-between; color: #fff;
    background:
        radial-gradient(120% 80% at 100% 0%, rgba(255, 255, 255, .14), transparent 60%),
        repeating-linear-gradient(135deg, rgba(255, 255, 255, .035) 0 2px, transparent 2px 14px),
        linear-gradient(150deg, var(--c1), var(--c2));
}
.cover-icon { width: 44px; height: 44px; padding: 9px; border-radius: 10px; background: rgba(255, 255, 255, .12); }
.cover-icon svg { width: 100%; height: 100%; }
.cover-title { font-size: 18px; font-weight: 700; line-height: 1.3; letter-spacing: -.01em; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; text-shadow: 0 1px 2px rgba(0, 0, 0, .25); }
.save-btn {
    position: absolute; top: 12px; right: 12px; display: grid; place-items: center; width: 36px; height: 36px;
    border: 0; border-radius: 50%; background: rgba(255, 255, 255, .92); color: var(--text); cursor: pointer;
    box-shadow: 0 2px 6px rgba(0, 0, 0, .15); transition: transform .15s, background-color .15s;
}
.save-btn:hover { transform: scale(1.08); color: var(--brand); }
.save-btn[aria-pressed="true"] { background: var(--brand); color: #fff; }
.save-btn[aria-pressed="true"] svg path, [data-save][aria-pressed="true"] svg path { fill: currentColor; }
.save-btn--inline { position: static; box-shadow: none; border: 1px solid var(--border-strong); }
.card-body { padding: 20px 20px 14px; flex: 1; }
.card-title { font-size: 16.5px; font-weight: 600; line-height: 1.35; letter-spacing: -.01em; }
.card-title a { color: var(--text); }
.card-title a:hover { color: var(--brand); text-decoration: none; }
.card-text { margin-top: 8px; font-size: 14px; color: var(--text-2); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card-meta { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 14px 20px; border-top: 1px solid var(--border); font-size: 12.5px; color: var(--muted); }
.card-byline { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-stats { display: inline-flex; gap: 12px; flex-shrink: 0; font-variant-numeric: tabular-nums; }
.card-stats > span { display: inline-flex; align-items: center; gap: 4px; }

.empty-state { display: flex; flex-direction: column; align-items: center; gap: 14px; text-align: center; padding: 56px 24px; color: var(--muted); border: 1px dashed var(--border-strong); border-radius: var(--radius); background: var(--surface-2); }
.empty-state svg { color: var(--border-strong); }
.empty-state p { max-width: 440px; }

/* ---------- Pagination ---------- */
.pagination { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-top: 32px; flex-wrap: wrap; }
.page-numbers { display: flex; gap: 4px; }
.page-link, .page-num { display: inline-grid; place-items: center; min-width: 36px; height: 36px; padding: 0 12px; border-radius: 8px; font-size: 14px; font-weight: 500; color: var(--text-2); border: 1px solid var(--border); background: var(--surface); }
.page-link:hover, .page-num:hover { border-color: var(--brand); color: var(--brand); text-decoration: none; }
.page-num.current { background: var(--brand); border-color: var(--brand); color: #fff; }
.page-link.disabled { opacity: .45; pointer-events: none; }
.page-gap { padding: 0 6px; color: var(--muted); align-self: center; }

/* ---------- Catalog ---------- */
.catalog { display: grid; grid-template-columns: 260px minmax(0, 1fr); gap: 24px; align-items: start; }
.facets { padding: 18px; position: sticky; top: 112px; max-height: calc(100vh - 130px); overflow-y: auto; }
.facet-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.facet-head h2 { font-size: 15px; }
.facet { border: 0; padding: 14px 0 6px; margin: 0; border-top: 1px solid var(--border); }
.facet legend { padding: 0; font-size: 12px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin-bottom: 6px; float: left; width: 100%; }
.check { display: flex; align-items: center; gap: 10px; padding: 5px 4px; border-radius: 6px; font-size: 14px; cursor: pointer; clear: both; }
.check:hover { background: var(--surface-2); }
.check input { accent-color: var(--brand); width: 16px; height: 16px; margin: 0; flex-shrink: 0; }
.check-label { flex: 1; line-height: 1.3; }
.check-count { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.results-bar { display: flex; gap: 10px; }
.results-bar .btn { height: 44px; }
.results-meta { display: flex; justify-content: space-between; align-items: center; margin: 18px 0 14px; color: var(--text-2); font-size: 14px; }
.sort { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; }
.sort select { font: inherit; font-size: 14px; color: var(--text); height: 36px; padding: 0 10px; border: 1px solid var(--border-strong); border-radius: 8px; background: var(--surface); }
.result-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 14px; }
.result { display: grid; grid-template-columns: 132px minmax(0, 1fr) auto; gap: 20px; padding: 16px; }
.result-thumb .cover { border-radius: 10px; }
.result-thumb .cover-art { padding: 12px; }
.result-thumb .cover-title { display: none; }
.result-thumb .cover-icon { width: 34px; height: 34px; padding: 7px; }
.result h3 { font-size: 17px; font-weight: 600; margin-top: 8px; }
.result h3 a { color: var(--text); }
.result h3 a:hover { color: var(--brand); }
.result-byline { margin-top: 4px; font-size: 13.5px; color: var(--muted); }
.result-text { margin-top: 8px; font-size: 14px; color: var(--text-2); }
.result-side { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; font-size: 12.5px; color: var(--muted); white-space: nowrap; }
.badges { display: flex; flex-wrap: wrap; gap: 6px; }
.badge { display: inline-flex; align-items: center; height: 22px; padding: 0 9px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--brand-soft); color: var(--brand-ink); }
.badge--plain { background: #eeece8; color: var(--text-2); }
.badge--pdf { background: #fbe9e6; color: #8a2a1c; }
.badge--word { background: #e6eef8; color: #24466e; }
.badge--video { background: #e4f1e8; color: #1f5a33; }
.badge--audio { background: #f1e7f3; color: #5a3560; }
.subjects { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.subjects a { font-size: 12.5px; padding: 2px 10px; border-radius: 999px; border: 1px solid var(--border-strong); color: var(--text-2); }
.subjects a:hover { border-color: var(--brand); color: var(--brand); text-decoration: none; }

/* ---------- Resource page ---------- */
.breadcrumb { display: flex; flex-wrap: wrap; gap: 8px; font-size: 13.5px; color: var(--muted); margin-bottom: 18px; }
.breadcrumb a { color: var(--text-2); }
.resource-layout { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 24px; align-items: start; }
.resource-main { display: flex; flex-direction: column; gap: 20px; min-width: 0; }
.resource-head { padding: 28px 30px; }
.resource-head h1 { font-size: clamp(26px, 2.8vw, 34px); font-weight: 700; margin-top: 14px; letter-spacing: -.03em; }
.resource-byline { margin-top: 10px; color: var(--text-2); }
.resource-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 22px; }
.viewer { overflow: hidden; }
.viewer--pdf iframe { width: 100%; height: 78vh; min-height: 520px; border: 0; background: #e9e6e0; }
.viewer-fallback { padding: 10px 16px; font-size: 13px; color: var(--muted); border-top: 1px solid var(--border); }
.viewer--video { background: #000; }
.viewer--video iframe, .viewer--video video { width: 100%; aspect-ratio: 16 / 9; border: 0; height: auto; }
.viewer--audio, .viewer--file { display: flex; align-items: center; gap: 18px; padding: 22px 24px; }
.viewer--audio audio { flex: 1; min-width: 0; }
.viewer--file > div { flex: 1; min-width: 0; }
.viewer--file strong { word-break: break-all; }
.viewer-icon { flex-shrink: 0; width: 52px; height: 52px; padding: 12px; border-radius: 12px; background: var(--brand-soft); color: var(--brand); }
.prose { padding: 26px 30px; font-size: 15.5px; line-height: 1.7; color: var(--text-2); overflow-wrap: anywhere; }
.prose h2 { font-size: 18px; margin-bottom: 10px; color: var(--text); }
.prose h1, .prose h3 { margin: 1.2em 0 .5em; color: var(--text); }
.prose p, .prose ul, .prose ol, .prose blockquote, .prose table { margin: 0 0 1em; }
.prose img { height: auto; border-radius: 8px; }
.prose blockquote { border-left: 3px solid var(--brand); padding-left: 16px; color: var(--muted); }
.prose table { border-collapse: collapse; width: 100%; }
.prose td, .prose th { border: 1px solid var(--border); padding: 6px 10px; }
.resource-side { display: flex; flex-direction: column; gap: 16px; position: sticky; top: 112px; }
.side-card { padding: 20px 22px; }
.side-card h2 { font-size: 15px; margin-bottom: 12px; }
.glance { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin: 0; }
.glance dt { font-size: 12px; color: var(--muted); }
.glance dd { margin: 2px 0 0; font-weight: 600; font-variant-numeric: tabular-nums; }
.citation { font-size: 13.5px; color: var(--text-2); background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; margin-bottom: 12px; overflow-wrap: anywhere; }
.dc-details summary { cursor: pointer; list-style: none; display: flex; justify-content: space-between; align-items: center; }
.dc-details summary::-webkit-details-marker { display: none; }
.dc-details summary::after { content: "+"; font-size: 18px; color: var(--muted); }
.dc-details[open] summary::after { content: "−"; }
.dc-details summary h2 { margin: 0; }
.dc-table { margin: 14px 0 0; font-size: 13px; }
.dc-table > div { padding: 8px 0; border-top: 1px solid var(--border); }
.dc-table dt { font-family: var(--mono); font-size: 11.5px; color: var(--brand-ink); }
.dc-table dd { margin: 2px 0 0; color: var(--text-2); overflow-wrap: anywhere; }
.related { margin-top: 48px; }

/* ---------- Metrics ---------- */
.metrics-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; margin-top: 24px; }
.chart-card { padding: 22px 24px; min-width: 0; }
.chart-card h2 { font-size: 16px; }
.chart-card > .muted { margin: 2px 0 14px; }
.chart { width: 100%; height: auto; overflow: visible; }
.chart-grid { stroke: #ebe7e0; stroke-width: 1; }
.chart-tick { font-size: 11px; fill: var(--muted); font-family: var(--font); }
.chart-value { font-size: 11.5px; font-weight: 600; fill: var(--text); font-family: var(--font); }
.chart-bar { fill: var(--brand); transition: opacity .15s; }
.chart-hit { fill: transparent; cursor: default; }
.chart:has(.chart-hit:hover) .chart-bar { opacity: .55; }
.hbar { display: grid; grid-template-columns: 170px minmax(0, 1fr); gap: 12px; align-items: center; padding: 6px 0; }
.hbar-label { font-size: 13.5px; color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hbar-track { display: flex; align-items: center; gap: 8px; min-width: 0; }
.hbar-fill { display: block; height: 16px; min-width: 2px; background: var(--brand); border-radius: 0 4px 4px 0; transition: opacity .15s; }
.hbar:hover .hbar-fill { opacity: .8; }
.hbar-value { font-size: 12.5px; font-weight: 600; font-variant-numeric: tabular-nums; color: var(--text); }
.chart-tooltip {
    position: fixed; z-index: 60; pointer-events: none; padding: 8px 12px; border-radius: 8px;
    background: var(--text); color: #fff; font-size: 12.5px; line-height: 1.4; box-shadow: var(--shadow-lg); transform: translate(-50%, calc(-100% - 12px));
}
.chart-tooltip strong { display: block; font-weight: 600; }
.table-view { margin-top: 16px; padding: 14px 20px; }
.table-view summary { cursor: pointer; font-size: 14px; font-weight: 600; color: var(--brand); }
.table-view .data-table { margin-top: 12px; }
.data-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.data-table th { text-align: left; font-size: 12px; font-weight: 600; color: var(--muted); padding: 8px 8px; border-bottom: 1px solid var(--border); }
.data-table td { padding: 10px 8px; border-bottom: 1px solid var(--border); vertical-align: top; }
.data-table tr:last-child td { border-bottom: 0; }
.data-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.data-table .rank { color: var(--muted); width: 28px; }
.data-table a { color: var(--text); font-weight: 500; }
.data-table a:hover { color: var(--brand); }

/* ---------- Guide ---------- */
.guide-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; }
.guide-step { padding: 22px; }
.guide-step h2 { font-size: 17px; margin: 12px 0 8px; }
.guide-step p { font-size: 14px; color: var(--text-2); }
.step-num { display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; background: var(--brand-soft); color: var(--brand-ink); font-weight: 700; font-size: 14px; }
.staff-help { padding: 26px 28px; margin-top: 24px; }
.staff-help h2 { font-size: 18px; margin-bottom: 12px; }
.staff-help ol { margin: 0; padding-left: 20px; color: var(--text-2); display: grid; gap: 6px; }

/* ---------- Quick search dialog ---------- */
.search-dialog { position: fixed; inset: 0; z-index: 80; display: flex; justify-content: center; align-items: flex-start; padding: 12vh 16px 16px; }
.search-backdrop { position: absolute; inset: 0; background: rgba(28, 26, 23, .45); backdrop-filter: blur(2px); }
.search-panel { position: relative; width: 100%; max-width: 620px; background: var(--surface); border-radius: 14px; box-shadow: var(--shadow-lg); overflow: hidden; }
.search-field { display: flex; align-items: center; gap: 12px; padding: 0 18px; border-bottom: 1px solid var(--border); color: var(--muted); }
.search-field input { flex: 1; height: 56px; border: 0; outline: none; font: inherit; font-size: 17px; color: var(--text); background: none; }
.search-results { list-style: none; margin: 0; padding: 6px; max-height: 52vh; overflow-y: auto; }
.search-results:empty { display: none; }
.search-results a { display: flex; justify-content: space-between; align-items: center; gap: 14px; padding: 10px 12px; border-radius: 8px; color: var(--text); }
.search-results a:hover, .search-results a.selected { background: var(--brand-soft); text-decoration: none; }
.search-results .sr-title { font-weight: 600; font-size: 14.5px; }
.search-results .sr-meta { font-size: 12.5px; color: var(--muted); }
.search-results .sr-format { font-family: var(--mono); font-size: 11.5px; color: var(--muted); flex-shrink: 0; }
.search-hint { padding: 10px 18px; font-size: 12.5px; color: var(--muted); border-top: 1px solid var(--border); background: var(--surface-2); }

.toast { position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%); z-index: 90; background: var(--text); color: #fff; padding: 10px 18px; border-radius: 10px; font-size: 14px; box-shadow: var(--shadow-lg); }

/* ---------- Footer ---------- */
.site-footer { border-top: 1px solid var(--border); background: var(--surface); padding: 32px 0; }
.footer-inner { display: grid; grid-template-columns: 1fr auto; gap: 18px 32px; align-items: start; }
.footer-brand img { height: 34px; width: auto; margin-bottom: 10px; }
.footer-brand p { font-size: 13.5px; color: var(--muted); }
.footer-links { display: flex; flex-wrap: wrap; gap: 6px 20px; font-size: 14px; }
.footer-links a { color: var(--text-2); }
.footer-copy { grid-column: 1 / -1; font-size: 12.5px; color: var(--muted); border-top: 1px solid var(--border); padding-top: 16px; }

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
    .card-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .resource-layout { grid-template-columns: minmax(0, 1fr) 300px; }
    .guide-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 960px) {
    .header-bar { grid-template-columns: 1fr auto; }
    .main-nav { display: none; position: absolute; top: 60px; left: 0; right: 0; flex-direction: column; background: var(--surface); border-bottom: 1px solid var(--border); padding: 10px 16px; box-shadow: var(--shadow-lg); }
    .main-nav.open { display: flex; }
    .sidebar-layout .main-nav { visibility: visible; }
    .menu-toggle { display: inline-grid; }
    .header-actions .btn span { display: none; }
    .header-actions .btn { padding: 0 12px; }
    .layout-toggle { display: none; }
    .sidebar-layout .side-nav { display: none; }
    .sidebar-layout .site-main, .sidebar-layout .site-footer { margin-left: 0; }
    .hero { grid-template-columns: 1fr; }
    .hero-copy { padding: 36px 28px; }
    .hero-media { min-height: 260px; }
    .stats { grid-template-columns: repeat(2, 1fr); }
    .stat:nth-child(3) { border-left: 0; }
    .stat:nth-child(n+3) { border-top: 1px solid var(--border); }
    .catalog { grid-template-columns: 1fr; }
    .facets { position: static; max-height: none; }
    .resource-layout { grid-template-columns: 1fr; }
    .resource-side { position: static; }
    .metrics-grid { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
    .container { padding: 0 16px; }
    .site-main { padding-top: 20px; }
    .brand span { display: none; }
    .card-grid { grid-template-columns: 1fr; }
    .guide-grid { grid-template-columns: 1fr; }
    .hero-search .input-icon { max-width: none; flex-basis: 100%; }
    .segmented { width: 100%; overflow-x: auto; }
    .result { grid-template-columns: 1fr; }
    .result-thumb { display: none; }
    .result-side { flex-direction: row; align-items: center; }
    .resource-head, .prose { padding: 22px 20px; }
    .hbar { grid-template-columns: 110px minmax(0, 1fr); }
    .footer-inner { grid-template-columns: 1fr; }
    .page-head { flex-direction: column; align-items: flex-start; }
}
@media (prefers-reduced-motion: reduce) {
    * { transition: none !important; }
}
@media print {
    .site-header, .side-nav, .site-footer, .resource-actions, .save-btn, .viewer { display: none !important; }
    .sidebar-layout .site-main { margin-left: 0; }
}
