/* VibeKB V1 Software Guide — readability and information hierarchy.
   Warm cream + teal identity retained; surfaces, nav, and reading rhythm refined. */

:root {
    color-scheme: light;

    /* Surfaces — tonal hierarchy (page < shell < content < inset) */
    --page-bg: #ebe6dc;
    --shell-bg: #f4f0e8;
    --surface: #fffcf7;
    --surface-raised: #ffffff;
    --surface-inset: #efeae0;
    --surface-interactive: #f7f3eb;

    --border: rgba(26, 36, 33, 0.14);
    --border-strong: rgba(26, 36, 33, 0.22);

    --text: #1a2421;
    --text-soft: #2f3b36;
    --muted: #4f5c56;

    --accent: #0c7c6c;
    --accent-deep: #085a4e;
    --accent-soft: #d5ebe5;
    --accent-soft-2: #e7f4f0;

    --radius: 10px;
    --radius-sm: 6px;
    --maxw: 1120px;
    --reading: 46rem; /* ~736px */
    --sidebar-w: 15.5rem;
    --header-h: 3.5rem;
    --shadow: 0 1px 0 rgba(26, 36, 33, 0.04), 0 8px 24px rgba(26, 36, 33, 0.05);
    --display: "Outfit", "Avenir Next", "Segoe UI", sans-serif;

    --ok-bg: #d9efe0; --ok-fg: #176636;
    --info-bg: #d5ebe5; --info-fg: #085a4e;
    --warn-bg: #f6ead4; --warn-fg: #7a4210;
    --danger-bg: #f6dede; --danger-fg: #9e2424;
    --muted-bg: #e4e8e3; --muted-fg: #4f5c56;
    --unknown-bg: #e4e8e3; --unknown-fg: #5c6570;

    /* Legacy aliases used by older class names */
    --bg: var(--surface);
    --surface-2: var(--surface-inset);
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    color: var(--text);
    font-family: "Figtree", "Avenir Next", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    line-height: 1.65;
    font-size: 16.5px;
    background-color: var(--page-bg);
    background-image:
        radial-gradient(700px 280px at 0% 0%, rgba(12, 124, 108, 0.07), transparent 60%),
        radial-gradient(520px 240px at 100% 0%, rgba(138, 75, 18, 0.04), transparent 55%);
    background-repeat: no-repeat;
    background-attachment: scroll;
    min-height: 100vh;
}

h1, h2, h3 { font-family: var(--display); font-weight: 700; color: var(--text); }
h1 { font-size: clamp(1.65rem, 3.5vw, 2.2rem); line-height: 1.18; letter-spacing: -0.02em; margin: 0 0 0.45em; }
h2 { font-size: 1.28rem; letter-spacing: -0.015em; margin: 0 0 0.4em; line-height: 1.3; }
h3 { font-size: 1.05rem; margin: 0 0 0.35em; line-height: 1.35; }

a { color: var(--accent-deep); text-underline-offset: 2px; }
a:hover { color: var(--accent); }
a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 3px; }

code {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 0.88em;
    background: var(--surface-inset);
    padding: 0.1em 0.35em;
    border-radius: 4px;
}

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

.wrap {
    width: 100%;
    max-width: var(--maxw);
    margin: 0 auto;
    padding: 0 clamp(16px, 3.5vw, 28px);
}

.muted { color: var(--muted); }
.text-soft { color: var(--text-soft); }
.text-link { font-weight: 600; }

/* ---- layout primitives ---- */
.app-shell {
    display: grid;
    grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
    grid-template-rows: auto 1fr;
    grid-template-areas:
        "header header"
        "sidebar main";
    min-height: 100vh;
}

.site-header {
    grid-area: header;
    position: sticky;
    top: 0;
    z-index: 30;
    background: rgba(255, 252, 247, 0.94);
    border-bottom: 1px solid var(--border);
    backdrop-filter: saturate(1.1) blur(6px);
}

.site-header__inner {
    display: flex;
    align-items: center;
    gap: 16px;
    min-height: var(--header-h);
    padding: 0 clamp(16px, 3.5vw, 28px);
    max-width: none;
}

.brand {
    display: flex;
    align-items: baseline;
    gap: 10px;
    text-decoration: none;
    color: var(--text);
}
.brand:hover { text-decoration: none; color: var(--text); }
.brand__mark {
    font-family: var(--display);
    font-weight: 800;
    letter-spacing: -0.02em;
    font-size: 1.15rem;
    color: var(--accent-deep);
}
.brand__project { color: var(--text-soft); font-size: 0.95rem; font-weight: 500; }

.nav-toggle {
    margin-left: auto;
    background: var(--surface-interactive);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 9px 14px;
    min-height: 40px;
    border-radius: var(--radius-sm);
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
}
.nav-toggle:hover { border-color: var(--accent); }
.nav-toggle[hidden] { display: none !important; }

.nav-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(26, 36, 33, 0.35);
    z-index: 35;
}
.nav-backdrop.is-visible:not([hidden]) { display: block; }
.nav-backdrop[hidden] { display: none !important; }

.sidebar {
    grid-area: sidebar;
    background: var(--shell-bg);
    border-right: 1px solid var(--border);
    padding: 20px 14px 32px;
    position: sticky;
    top: var(--header-h);
    align-self: start;
    height: calc(100vh - var(--header-h));
    overflow-y: auto;
}

.sidebar-nav__label {
    margin: 18px 10px 6px;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--muted);
}
.sidebar-nav__label:first-child { margin-top: 0; }

.sidebar-nav__list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    gap: 2px;
}

.sidebar-nav__list a {
    display: block;
    padding: 9px 12px;
    border-radius: var(--radius-sm);
    text-decoration: none;
    color: var(--text-soft);
    font-size: 0.93rem;
    font-weight: 550;
    line-height: 1.3;
}
.sidebar-nav__list a:hover {
    background: var(--surface);
    color: var(--text);
    text-decoration: none;
}
.sidebar-nav__list a[aria-current="page"] {
    background: var(--accent-soft);
    color: var(--accent-deep);
    font-weight: 650;
}

.sidebar-nav__list--secondary a {
    font-size: 0.88rem;
    font-weight: 500;
    color: var(--muted);
    padding-top: 7px;
    padding-bottom: 7px;
}
.sidebar-nav__list--secondary a:hover { color: var(--text-soft); }
.sidebar-nav__list--secondary a[aria-current="page"] {
    color: var(--accent-deep);
    font-weight: 600;
}

.app-main {
    grid-area: main;
    background: transparent;
    min-width: 0;
}

main.wrap {
    padding-top: clamp(22px, 4vw, 40px);
    padding-bottom: 56px;
}

.reading-column {
    max-width: var(--reading);
}

.wide-section {
    max-width: none;
}

.content-section {
    margin-top: clamp(2rem, 4vw, 2.75rem);
}

.section-intro {
    margin-bottom: 0.85rem;
}
.section-intro h2 { margin-bottom: 0.3em; }
.section-intro__support {
    margin: 0;
    color: var(--text-soft);
    max-width: var(--reading);
    font-size: 0.98rem;
}

.page-head { margin-bottom: 1.5rem; }
.eyebrow {
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--accent);
    margin: 0 0 6px;
}
.lede {
    font-size: 1.08rem;
    color: var(--text-soft);
    max-width: 62ch;
    margin: 0 0 0.55rem;
    line-height: 1.55;
}
.sub { color: var(--text-soft); margin: 0.35rem 0; }
.breadcrumb { margin: 0 0 14px; font-size: 0.92rem; }
.updated-note { margin-top: 40px; color: var(--muted); font-size: 0.9rem; }

/* ---- source / provenance notice ---- */
.source-notice {
    margin-top: 1rem;
    padding: 10px 14px;
    background: var(--surface-inset);
    border: 1px solid var(--border);
    border-left: 3px solid var(--warn-fg);
    border-radius: var(--radius-sm);
    font-size: 0.88rem;
}
.source-notice__title {
    margin: 0;
    font-weight: 700;
    color: var(--text);
    font-size: 0.9rem;
}
.source-notice__hint {
    margin: 2px 0 0;
    color: var(--muted);
    font-size: 0.82rem;
}
.source-notice__details {
    margin-top: 6px;
}
.source-notice__details summary {
    cursor: pointer;
    color: var(--accent-deep);
    font-weight: 600;
    font-size: 0.84rem;
}
.source-notice__details p {
    margin: 8px 0 0;
    color: var(--text-soft);
    font-size: 0.86rem;
    line-height: 1.55;
}

/* ---- snapshot bar ---- */
.snapshot-bar {
    display: grid;
    gap: 12px;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    margin: 0 0 0.5rem;
    padding: 14px 16px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}
.snapshot-bar__label {
    margin: 0 0 4px;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--muted);
}
.snapshot-bar__value {
    margin: 0 0 8px;
    font-family: var(--display);
    font-size: 1.15rem;
    font-weight: 700;
}
.snapshot-bar__value--quiet {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-soft);
}
.snapshot-bar__text {
    margin: 0 0 8px;
    color: var(--text-soft);
    font-size: 0.94rem;
    line-height: 1.45;
}
.snapshot-bar__item .badge-row { margin: 0; }
.snapshot-bar__item .text-link { font-size: 0.9rem; }

/* ---- badges & chips ---- */
.badge {
    display: inline-block;
    padding: 1px 8px;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 600;
    line-height: 1.55;
    white-space: nowrap;
    border: 1px solid transparent;
}
.badge--ok { background: var(--ok-bg); color: var(--ok-fg); border-color: rgba(28, 122, 65, 0.18); }
.badge--info { background: var(--info-bg); color: var(--info-fg); border-color: rgba(8, 90, 78, 0.18); }
.badge--warn { background: var(--warn-bg); color: var(--warn-fg); border-color: rgba(138, 75, 18, 0.2); }
.badge--danger { background: var(--danger-bg); color: var(--danger-fg); border-color: rgba(176, 42, 42, 0.2); }
.badge--muted { background: var(--muted-bg); color: var(--muted-fg); border-color: rgba(79, 92, 86, 0.15); }
.badge--unknown { background: var(--unknown-bg); color: var(--unknown-fg); border-color: rgba(92, 101, 112, 0.15); }

.badge-row {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
    margin: 10px 0;
}
.badge-row--quiet .badge {
    opacity: 0.92;
    font-weight: 550;
}

.chip {
    display: inline-block;
    max-width: 100%;
    padding: 3px 9px;
    margin: 2px 4px 2px 0;
    border-radius: var(--radius-sm);
    background: var(--surface-interactive);
    border: 1px solid var(--border);
    color: var(--text);
    font-size: 0.82rem;
    text-decoration: none;
    word-break: break-word;
    overflow-wrap: anywhere;
    line-height: 1.4;
}
a.chip:hover {
    background: var(--accent-soft);
    border-color: var(--accent);
    color: var(--accent-deep);
    text-decoration: none;
}
a.chip:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}
.chip--file {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    background: var(--surface-inset);
    font-size: 0.78rem;
}
.chip--broken {
    background: var(--danger-bg);
    color: var(--danger-fg);
    border-color: rgba(176, 42, 42, 0.35);
}

/* ---- panels, callouts, areas ---- */
.panel-grid {
    display: grid;
    gap: 14px;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    margin: 24px 0;
}
.panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px 18px;
}
.panel h2 { margin-top: 0; font-size: 1.02rem; }

.split {
    display: grid;
    gap: 14px;
    grid-template-columns: 1fr 1fr;
}
@media (max-width: 720px) {
    .split { grid-template-columns: 1fr; }
}

.callout {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px 18px;
    background: var(--surface);
}
.callout--warn { border-left: 3px solid var(--warn-fg); }
.callout--work { border-left: 3px solid var(--info-fg); }
.callout--ok { border-left: 3px solid var(--ok-fg); background: var(--ok-bg); }
.callout h2 { margin-top: 0; font-size: 1.05rem; }
.callout ul,
.callout-list {
    margin: 8px 0 0;
    padding-left: 18px;
}
.callout-list li {
    margin: 6px 0;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: baseline;
}

.next-step {
    padding: 20px 22px;
    background: var(--accent-soft-2);
    border: 1px solid rgba(12, 124, 108, 0.18);
    border-radius: var(--radius);
}
.next-step h2 { margin-top: 0; }

.area-summary-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    gap: 12px;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
}
.area-summary-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px 16px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.area-summary-card__head {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    align-items: baseline;
    flex-wrap: wrap;
}
.area-summary-card__title {
    margin: 0;
    font-size: 1.05rem;
}
.area-summary-card__title a {
    color: var(--text);
    text-decoration: none;
}
.area-summary-card__title a:hover {
    color: var(--accent-deep);
    text-decoration: underline;
}
.area-summary-card__count {
    margin: 0;
    font-size: 0.8rem;
    color: var(--muted);
    font-weight: 600;
    white-space: nowrap;
}
.area-summary-card__desc {
    margin: 0;
    color: var(--text-soft);
    font-size: 0.92rem;
    line-height: 1.45;
}
.area-summary-card__samples {
    list-style: none;
    margin: 4px 0 0;
    padding: 0;
    font-size: 0.88rem;
}
.area-summary-card__samples li {
    margin: 2px 0;
    padding-left: 0.9em;
    position: relative;
    color: var(--muted);
}
.area-summary-card__samples li::before {
    content: "·";
    position: absolute;
    left: 0;
    color: var(--muted);
}
.area-summary-card__action {
    margin: 6px 0 0;
    font-size: 0.9rem;
}
.wide-section__footer {
    margin-top: 14px;
}

/* ---- buttons ---- */
.btn {
    display: inline-block;
    padding: 9px 15px;
    min-height: 40px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    text-decoration: none;
    font-weight: 600;
    font-size: 0.94rem;
    cursor: pointer;
    line-height: 1.3;
}
.btn:hover {
    border-color: var(--accent);
    text-decoration: none;
    background: var(--surface-interactive);
}
.btn--primary {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}
.btn--primary:hover {
    background: var(--accent-deep);
    border-color: var(--accent-deep);
    color: #fff;
}
.button-row,
.cross-links {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 14px;
}

/* ---- functionality index / record cards ---- */
.group-block { margin: 2rem 0; }
.group-block .section-intro { margin-bottom: 0.75rem; }

.filters {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px;
    margin: 0 0 1.5rem;
}
.filters__row {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: flex-end;
}
.filters label {
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 0.78rem;
    font-weight: 650;
    color: var(--text-soft);
}
.filters select {
    font-size: 0.93rem;
    padding: 8px 10px;
    min-height: 40px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--surface-raised);
    color: var(--text);
    min-width: 150px;
}
.filters__actions { display: flex; gap: 8px; }

.record-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: grid;
    gap: 10px;
}

.record-card {
    position: relative;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px 16px;
    background: var(--surface);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.record-card:hover,
.record-card:focus-within {
    border-color: rgba(12, 124, 108, 0.35);
    box-shadow: var(--shadow);
}

.record-card__row {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: flex-start;
    flex-wrap: wrap;
}
.record-card__title {
    margin: 0;
    font-size: 1.08rem;
    flex: 1 1 12rem;
    line-height: 1.3;
}
.record-card__link {
    color: var(--text);
    text-decoration: none;
}
.record-card__link:hover {
    color: var(--accent-deep);
    text-decoration: underline;
}
.record-card__link::after {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: inherit;
}
.record-card__status {
    position: relative;
    z-index: 1;
    flex: 0 0 auto;
}
.record-card__summary {
    margin: 6px 0 0;
    color: var(--text-soft);
    font-size: 0.95rem;
    line-height: 1.45;
    max-width: 65ch;
}
.record-card__meta {
    position: relative;
    z-index: 1;
    margin: 10px 0 0;
    padding-top: 8px;
    border-top: 1px solid var(--border);
    display: grid;
    gap: 4px;
}
.record-card__meta div {
    display: grid;
    grid-template-columns: 6.5rem minmax(0, 1fr);
    gap: 8px;
    font-size: 0.82rem;
    align-items: baseline;
}
.record-card__meta dt {
    color: var(--muted);
    margin: 0;
    font-weight: 600;
}
.record-card__meta dd {
    margin: 0;
    color: var(--text-soft);
}
.record-card__meta a,
.record-card__meta .chip,
.record-card__meta .badge {
    position: relative;
    z-index: 1;
}

@media (max-width: 560px) {
    .record-card__meta div {
        grid-template-columns: 1fr;
        gap: 1px;
    }
}

/* Legacy class retained for any residual markup */
.func-cards { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
.func-card { border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; background: var(--surface); }
.func-line-list { list-style: none; padding: 0; margin: 8px 0; }
.func-line-list li { padding: 8px 0; border-bottom: 1px solid var(--border); }

/* ---- detail view ---- */
.detail-grid {
    display: grid;
    gap: 28px;
    grid-template-columns: minmax(0, 1fr) minmax(240px, 280px);
    align-items: start;
}
@media (max-width: 900px) {
    .detail-grid {
        grid-template-columns: 1fr;
    }
    .detail-rail {
        order: 2;
        position: static;
    }
    .detail-main { order: 1; }
}

.detail-rail {
    display: grid;
    gap: 12px;
    position: sticky;
    top: calc(var(--header-h) + 12px);
}
.rail-card,
.metadata-group {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px 14px;
    background: var(--surface);
}
.rail-card h2,
.metadata-group h2 {
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--muted);
    margin: 0 0 8px;
    font-family: "Figtree", sans-serif;
    font-weight: 700;
}
.rail-card h2 + p,
.rail-card p { margin: 0 0 8px; font-size: 0.9rem; }
.rail-card p:last-child { margin-bottom: 0; }

.rail-dl {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 6px 10px;
    margin: 0;
}
.rail-dl dt { color: var(--muted); font-size: 0.8rem; font-weight: 600; }
.rail-dl dd { margin: 0; font-size: 0.88rem; }

.work-meta { grid-template-columns: 1fr; gap: 2px; }
.work-meta dt { margin-top: 8px; font-weight: 700; color: var(--text-soft); }

.rail-list { list-style: none; padding: 0; margin: 0; }
.rail-list li {
    padding: 5px 0;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: flex-start;
}
.rail-list code {
    word-break: break-word;
    overflow-wrap: anywhere;
    background: transparent;
    padding: 0;
}

.rail-disclose {
    margin-top: 6px;
    font-size: 0.88rem;
}
.rail-disclose summary {
    cursor: pointer;
    color: var(--accent-deep);
    font-weight: 600;
    padding: 4px 0;
}
.rail-disclose[open] summary { margin-bottom: 6px; }

/* ---- prose ---- */
.prose {
    font-size: 1rem;
    line-height: 1.7;
}
.prose > *:first-child { margin-top: 0; }
.prose p { margin: 0 0 0.95em; }
.prose h2 {
    font-size: 1.18rem;
    border-top: 1px solid var(--border);
    padding-top: 1.25em;
    margin: 1.85em 0 0.45em;
}
.prose h2:first-child {
    border-top: 0;
    padding-top: 0;
    margin-top: 0;
}
.prose h3 {
    font-size: 1.02rem;
    margin: 1.35em 0 0.35em;
}
.prose ul,
.prose ol {
    padding-left: 1.3em;
    margin: 0 0 1em;
}
.prose li { margin: 0.28em 0; }
.prose li > ul,
.prose li > ol { margin-bottom: 0.2em; }
.prose code {
    background: var(--surface-inset);
    padding: 1px 5px;
    border-radius: 4px;
}
.prose pre {
    background: var(--surface-inset);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 12px 14px;
    overflow-x: auto;
    font-size: 0.88rem;
    line-height: 1.5;
}
.prose pre code {
    background: transparent;
    padding: 0;
}
.prose pre,
.prose p code { word-break: break-word; }
.prose blockquote {
    margin: 0.9em 0;
    padding: 6px 14px;
    border-left: 3px solid var(--accent);
    color: var(--text-soft);
    background: var(--surface);
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}
.prose hr {
    border: 0;
    border-top: 1px solid var(--border);
    margin: 1.6em 0;
}
.prose a { font-weight: 550; }

/* ---- tables ---- */
.table-wrap {
    overflow-x: auto;
    margin: 12px 0;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    -webkit-overflow-scrolling: touch;
}
table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
th, td {
    text-align: left;
    padding: 9px 12px;
    border-bottom: 1px solid var(--border);
    vertical-align: top;
}
th {
    background: var(--surface-inset);
    font-weight: 700;
    white-space: nowrap;
}
tr:last-child td { border-bottom: 0; }
td code {
    word-break: break-word;
    overflow-wrap: anywhere;
}

/* ---- docs / files / why / changes ---- */
.doc-section { margin: 1.75rem 0; }

.file-list { display: grid; gap: 12px; }
.file-card {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px 16px;
    background: var(--surface);
    scroll-margin-top: calc(var(--header-h) + 12px);
}
.file-card__head {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    flex-wrap: wrap;
    align-items: baseline;
}
.file-card__head h2 {
    margin: 0;
    font-size: 0.98rem;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-weight: 600;
    word-break: break-word;
    overflow-wrap: anywhere;
}
.file-card__head h2 code { background: transparent; padding: 0; }
.file-card__badges { display: flex; gap: 6px; flex-wrap: wrap; }
.file-card__purpose { margin: 8px 0; color: var(--text-soft); }
.file-card__meta { display: grid; gap: 6px; margin: 8px 0 0; }
.file-card__meta div {
    display: grid;
    grid-template-columns: 130px minmax(0, 1fr);
    gap: 10px;
    font-size: 0.88rem;
}
.file-card__meta dt { color: var(--muted); margin: 0; font-weight: 600; }
.file-card__meta dd { margin: 0; color: var(--text-soft); }
@media (max-width: 560px) {
    .file-card__meta div { grid-template-columns: 1fr; gap: 2px; }
}

.why-group { margin: 1.75rem 0; }
.why-list,
.change-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: grid;
    gap: 12px;
}
.why-item,
.change-card {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px 16px;
    background: var(--surface);
}
.why-item__head,
.change-card__head {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    flex-wrap: wrap;
    align-items: baseline;
}
.why-item__head h3,
.change-card__head h2 { margin: 0; font-size: 1.05rem; }
.why-item p,
.change-card p { margin: 8px 0; color: var(--text-soft); }
.why-item__links,
.change-card__links { margin-top: 8px; }
.change-card__body { margin-top: 10px; }

/* ---- alerts / empty ---- */
.content-alert {
    background: var(--warn-bg);
    color: var(--warn-fg);
    border-radius: var(--radius-sm);
    padding: 10px 16px;
    margin: 16px 0 0;
    border: 1px solid rgba(138, 75, 18, 0.2);
}
.issue-list { padding-left: 20px; }
.issue-list--error li { color: var(--danger-fg); }
.issue-list--warn li { color: var(--warn-fg); }
.empty-state {
    padding: 22px;
    background: var(--surface);
    border: 1px dashed var(--border-strong);
    border-radius: var(--radius);
    color: var(--text-soft);
}

/* ---- footer ---- */
.site-footer {
    border-top: 1px solid var(--border);
    padding: 24px 0;
    margin-top: 24px;
    background: var(--shell-bg);
}
.site-footer__inner p { margin: 4px 0; }

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

/* ---- responsive: drawer nav ---- */
@media (max-width: 900px) {
    .app-shell {
        grid-template-columns: 1fr;
        grid-template-areas:
            "header"
            "main";
    }

    /* Drawer only when JS is ready; without JS the sidebar stays in flow below. */
    body.js-ready .sidebar {
        position: fixed;
        top: var(--header-h);
        left: 0;
        bottom: 0;
        width: min(18.5rem, 86vw);
        z-index: 40;
        transform: translateX(-105%);
        transition: transform 0.2s ease;
        box-shadow: none;
        height: auto;
    }
    body.js-ready .sidebar.is-open {
        transform: translateX(0);
        box-shadow: 8px 0 28px rgba(26, 36, 33, 0.18);
    }

    body.nav-open { overflow: hidden; }

    .detail-rail { position: static; }
}

@media (prefers-reduced-motion: reduce) {
    .sidebar { transition: none; }
    .record-card { transition: none; }
}

/* No-JS mobile: keep the sidebar in document flow so every route remains reachable. */
@media (max-width: 900px) {
    body:not(.js-ready) .app-shell {
        grid-template-areas:
            "header"
            "sidebar"
            "main";
        grid-template-columns: 1fr;
    }
    body:not(.js-ready) .sidebar {
        position: static;
        transform: none;
        width: auto;
        height: auto;
        border-right: 0;
        border-bottom: 1px solid var(--border);
    }
}

/* ---- provenance panel (Mode A + Mode B) ---- */
.provenance {
    margin: 0.5rem 0 1.5rem;
    padding: 16px 18px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-left: 3px solid var(--accent);
    border-radius: var(--radius);
}
.provenance__title {
    margin: 0 0 6px;
    font-size: 1.05rem;
}
.provenance__disclaimer {
    margin: 0 0 4px;
    color: var(--text);
    font-weight: 600;
    font-size: 0.94rem;
}
.provenance__note {
    margin: 0 0 10px;
    font-size: 0.88rem;
}
.provenance__grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 8px 20px;
    margin: 0;
}
.provenance__row {
    display: flex;
    flex-direction: column;
    gap: 1px;
    padding: 4px 0;
    border-top: 1px solid var(--border);
}
.provenance__row dt {
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--muted);
    margin: 0;
}
.provenance__row dd {
    margin: 0;
    font-size: 0.92rem;
    color: var(--text-soft);
    word-break: break-word;
}
.provenance__row dd code { font-size: 0.85rem; }
.site-footer__provenance {
    margin-top: 4px;
    font-size: 0.82rem;
}

/* ---- generated-output notice (static /docs only) ---- */
.generated-notice {
    margin: 0;
    padding: 8px 16px;
    background: var(--warn-bg);
    color: var(--warn-fg);
    border-bottom: 1px solid var(--border);
    font-size: 0.85rem;
    text-align: center;
}
.generated-notice a { color: inherit; }

/* ---- diagrams ---- */
.diagram-toc {
    display: grid;
    gap: 10px;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    margin: 1.25rem 0 1.75rem;
    padding: 0;
    list-style: none;
}
.diagram-toc a {
    display: block;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    text-decoration: none;
    color: inherit;
}
.diagram-toc a:hover { border-color: var(--accent); }
.diagram-toc strong { display: block; }
.diagram-group-title { margin: 2.25rem 0 0.5rem; }
.diagram-section {
    margin: 1.75rem 0;
    padding-top: 1.25rem;
    border-top: 1px solid var(--border);
}
.diagram-section:first-of-type { border-top: 0; padding-top: 0; }
.diagram-figure { margin: 1rem 0 1.25rem; }
.diagram-scroll {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface-raised);
    padding: 8px;
}
.diagram-svg,
.diagram-figure img {
    display: block;
    max-width: 100%;
    height: auto;
    margin: 0 auto;
}
.diagram-caption { margin-top: 10px; font-size: 0.92rem; color: var(--text-soft); }
.diagram-meta {
    margin-top: 12px;
    padding: 12px 14px;
    border-radius: var(--radius-sm);
    background: var(--surface-inset);
    border: 1px solid var(--border);
}
.diagram-meta dt { font-weight: 700; margin-top: 8px; font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); }
.diagram-meta dt:first-child { margin-top: 0; }
.diagram-meta dd { margin: 2px 0 0; color: var(--text-soft); font-size: 0.92rem; }
.related-diagrams {
    margin-top: 1rem;
    padding: 10px 14px;
    border-left: 3px solid var(--accent);
    background: var(--surface-inset);
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

/* ---- explainable diagrams ---- */
.diagram-explain { margin-top: 1.5rem; }

/* Selection focus/dim for the inline SVG (progressive enhancement). Without JS
   these classes are never applied, so nothing changes. */
.diagram-figure svg a { outline: none; cursor: pointer; }
.diagram-figure svg a:focus-visible > rect,
.diagram-figure svg a:focus-visible > path,
.diagram-figure svg a:focus-visible > line {
    outline: 3px solid var(--accent);
    outline-offset: 2px;
}
.diagram-figure svg [data-vibekb-node] > rect,
.diagram-figure svg [data-vibekb-edge] > .arrow,
.diagram-figure svg [data-vibekb-edge] > .arrow-inferred { transition: opacity 120ms ease, filter 120ms ease; }
.diagram-section.dx-has-selection .diagram-figure svg [data-vibekb-node]:not(.is-selected),
.diagram-section.dx-has-selection .diagram-figure svg [data-vibekb-edge]:not(.is-selected) { opacity: 0.32; }
.diagram-figure svg .is-selected > rect { filter: drop-shadow(0 0 0 var(--accent)); stroke: var(--accent-deep); stroke-width: 3; }
.diagram-figure svg .is-selected > .arrow,
.diagram-figure svg .is-selected > .arrow-inferred { stroke: var(--accent-deep); stroke-width: 3; }

.dx-legend {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 18px;
    padding: 10px 14px;
    margin: 0 0 1.25rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface-inset);
    font-size: 0.86rem;
}
.dx-legend__title { font-weight: 700; }
.dx-legend__item { display: inline-flex; align-items: center; gap: 7px; }
.dx-legend__hint { flex-basis: 100%; }
.dx-swatch { display: inline-block; width: 26px; height: 0; border-top-width: 2.5px; border-top-style: solid; border-top-color: var(--muted); }
.dx-swatch--dashed { border-top-style: dashed; }

.dx-heading { margin: 1.75rem 0 0.25rem; font-size: 1.05rem; }
.dx-heading-note { margin: 0 0 1rem; font-size: 0.9rem; }

.dx-list {
    display: grid;
    gap: 14px;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    margin-bottom: 0.5rem;
}
.dx-card {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    padding: 14px 16px;
    scroll-margin-top: calc(var(--header-h) + 14px);
}
.dx-card:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.dx-card.is-active { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
.dx-edge--inferred { border-left: 3px solid var(--info-fg); }
.dx-edge--verified { border-left: 3px solid var(--ok-fg); }

.dx-card__head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; justify-content: space-between; }
.dx-card__title { margin: 0; font-size: 1rem; }
.dx-card__purpose { margin: 8px 0 10px; }
.dx-edge__title { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-family: var(--display); }
.dx-edge__endpoint { text-decoration: none; font-weight: 700; }
.dx-edge__endpoint:hover { text-decoration: underline; }
.dx-mech {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--accent-deep);
    background: var(--accent-soft-2);
    padding: 1px 8px;
    border-radius: 999px;
}
.dx-verif .badge { margin-left: 4px; }
.dx-verif .badge:first-child { margin-left: 0; }

.dx-rel { margin: 8px 0; font-size: 0.9rem; }
.dx-basis, .dx-uncertain { margin: 8px 0; font-size: 0.88rem; }
.dx-uncertain { color: var(--warn-fg); }
.dx-warn { margin: 8px 0; font-size: 0.88rem; }

.dx-where {
    margin: 10px 0;
    padding: 8px 12px;
    background: var(--surface-inset);
    border-radius: var(--radius-sm);
    font-size: 0.88rem;
}
.dx-where__label, .dx-files__label {
    display: block;
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--muted);
    margin-bottom: 4px;
}
.dx-where__path { font-size: 0.82rem; }
.loc-tree, .loc-tree ul { list-style: none; margin: 4px 0 0; padding: 0 0 0 14px; }
.loc-tree { padding-left: 0; }
.loc-tree li { position: relative; padding: 1px 0 1px 14px; font-size: 0.82rem; line-height: 1.5; }
.loc-tree li::before { content: "└"; position: absolute; left: 0; color: var(--muted); }
.loc-dir { color: var(--text-soft); font-weight: 600; }
.loc-file { background: transparent; padding: 0; }

.dx-files { margin: 10px 0 4px; }
.dx-files__list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.dx-file {
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 8px 10px;
    background: var(--surface-raised);
}
.dx-file__head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px; }
.dx-file__role {
    font-size: 0.68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--accent-deep);
    background: var(--accent-soft);
    padding: 1px 6px;
    border-radius: 999px;
}
.dx-file__path { font-size: 0.8rem; background: transparent; padding: 0; word-break: break-all; }
.dx-file__reason { margin: 5px 0 0; font-size: 0.85rem; }
.dx-file__canon { margin: 3px 0 0; font-size: 0.82rem; }
.dx-file__canon-label { font-weight: 600; }
.dx-file__link { margin: 6px 0 0; font-size: 0.85rem; }
.dx-file__link a { font-weight: 600; }

/* ---- header search + a11y utility ---- */
.visually-hidden {
    position: absolute !important;
    width: 1px; height: 1px;
    padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0 0 0 0);
    white-space: nowrap; border: 0;
}
.site-search {
    margin-left: auto;
    display: flex;
    align-items: center;
}
.site-search input {
    width: min(46vw, 260px);
    padding: 6px 12px;
    font: inherit;
    font-size: 0.9rem;
    color: var(--text);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 999px;
}
.site-search input:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 1px;
    border-color: var(--accent);
}
@media (max-width: 640px) {
    .site-search input { width: 40vw; }
}

/* ============================================================
   Functionality Map — the guide's first screen
   A high-level, interactive map of what the software does. Progressive
   enhancement: the accessible fallback (nested area cards) is styled here too
   and is shown without JS, on small screens, and in list mode.
   ============================================================ */

.fmap { margin: 0 0 2.4rem; }
.fmap__intro { margin-bottom: 1.1rem; }
.fmap__intro .eyebrow { margin-bottom: 0.35rem; }
.fmap__lead-note { margin: 0.5rem 0 0; font-size: 0.98rem; }

/* Status colour tokens shared by dots and node accents. */
.fmap-dot {
    --dot: var(--unknown-fg);
    display: inline-block;
    width: 0.62rem; height: 0.62rem;
    border-radius: 50%;
    background: var(--dot);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--dot) 18%, transparent);
    flex: 0 0 auto;
}
[data-status="implemented"] { --dot: #1f9d57; }
[data-status="planned"] { --dot: #0c7c6c; }
[data-status="partial"], [data-status="experimental"], [data-status="needs-verification"] { --dot: #c07c1e; }
[data-status="disabled"], [data-status="deprecated"] { --dot: #7c8a83; }
[data-status="broken"] { --dot: #c0392b; }
[data-status="unknown"] { --dot: #8a938c; }

/* ---- Current-context banner ---- */
.fmap-context {
    display: flex; align-items: center; gap: 0.7rem;
    margin: 0 0 1.1rem;
    padding: 0.7rem 1rem;
    background: linear-gradient(90deg, var(--accent-soft), var(--accent-soft-2));
    border: 1px solid color-mix(in srgb, var(--accent) 30%, transparent);
    border-radius: var(--radius);
}
.fmap-context__pulse {
    width: 0.7rem; height: 0.7rem; border-radius: 50%;
    background: var(--accent);
    box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 55%, transparent);
    animation: fmap-pulse 2.2s ease-out infinite;
    flex: 0 0 auto;
}
@keyframes fmap-pulse {
    0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 55%, transparent); }
    70% { box-shadow: 0 0 0 12px transparent; }
    100% { box-shadow: 0 0 0 0 transparent; }
}
.fmap-context__body { margin: 0; }
.fmap-context__label {
    font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.08em;
    font-weight: 700; color: var(--accent-deep); margin-right: 0.35rem;
}

/* ---- Live statistics ---- */
.fmap-stats {
    list-style: none; margin: 0 0 1.1rem; padding: 0;
    display: grid; gap: 0.6rem;
    grid-template-columns: repeat(6, minmax(0, 1fr));
}
.fmap-stat { margin: 0; }
.fmap-stat__link {
    display: flex; flex-direction: column; gap: 0.15rem;
    padding: 0.85rem 0.9rem;
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); text-decoration: none; color: var(--text);
    box-shadow: var(--shadow);
    transition: transform 140ms ease, border-color 140ms ease, box-shadow 140ms ease;
}
.fmap-stat__link:hover {
    transform: translateY(-2px); color: var(--text);
    border-color: var(--border-strong);
    box-shadow: 0 6px 18px rgba(26, 36, 33, 0.09);
}
.fmap-stat__value { font-family: var(--display); font-weight: 800; font-size: 1.55rem; line-height: 1.05; color: var(--accent-deep); }
.fmap-stat__label { font-size: 0.78rem; color: var(--muted); letter-spacing: 0.01em; }

/* ---- Interactive stage ---- */
.fmap__frame { position: relative; }
.fmap__hint {
    display: flex; flex-wrap: wrap; gap: 0.4rem 1.2rem;
    margin: 0 0 0.6rem; font-size: 0.82rem; color: var(--muted);
}
.fmap__hint span { display: inline-flex; align-items: center; }

.fmap-stage {
    position: relative;
    height: clamp(420px, 62vh, 640px);
    border: 1px solid var(--border);
    border-radius: 14px;
    overflow: hidden;
    background-color: var(--shell-bg);
    background-image:
        radial-gradient(circle at center, rgba(12, 124, 108, 0.05), transparent 70%),
        radial-gradient(rgba(26, 36, 33, 0.06) 1px, transparent 1px);
    background-size: auto, 26px 26px;
    cursor: grab;
    touch-action: none;
    user-select: none;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.6);
}
.fmap-stage.is-grabbing { cursor: grabbing; }

.fmap-stage__canvas {
    position: absolute; top: 0; left: 0;
    width: 2800px; height: 1800px;
    transform-origin: 0 0;
    will-change: transform;
}
.fmap-edges { position: absolute; top: 0; left: 0; overflow: visible; pointer-events: none; }
.fmap-edge {
    fill: none;
    stroke: var(--border-strong);
    stroke-width: 1.5;
    opacity: 0.55;
}
.fmap-edge.is-current { stroke: var(--accent); stroke-width: 2.2; opacity: 0.9; }

.fmap-nodes { position: absolute; top: 0; left: 0; }

/* Nodes */
.fmap-cnode {
    position: absolute;
    transform: translate(-50%, -50%);
    display: flex; flex-direction: column; gap: 0.2rem;
    text-align: left;
    font: inherit; color: var(--text);
    background: var(--surface-raised);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 0.6rem 0.75rem;
    box-shadow: var(--shadow);
    cursor: pointer;
    transition: box-shadow 150ms ease, border-color 150ms ease, transform 120ms ease;
}
.fmap-cnode:hover { z-index: 5; border-color: var(--accent); box-shadow: 0 8px 24px rgba(26, 36, 33, 0.14); }
.fmap-cnode:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; z-index: 6; }
.fmap-cnode.is-selected { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft), 0 8px 24px rgba(26, 36, 33, 0.14); z-index: 5; }
.fmap-cnode__row { display: flex; align-items: center; gap: 0.45rem; }
.fmap-cnode__eyebrow { font-size: 0.64rem; text-transform: uppercase; letter-spacing: 0.1em; font-weight: 700; opacity: 0.75; }
.fmap-cnode__title { font-family: var(--display); font-weight: 700; line-height: 1.2; }
.fmap-cnode__sub { font-size: 0.78rem; color: var(--muted); line-height: 1.35; }
.fmap-cnode__badge {
    align-self: flex-start; margin-top: 0.1rem;
    font-size: 0.7rem; font-weight: 700; color: var(--accent-deep);
    background: var(--accent-soft-2); border-radius: 999px; padding: 0.05rem 0.5rem;
}
.fmap-cnode__badge--soft { color: var(--muted); background: var(--surface-inset); font-weight: 600; }

.fmap-cnode--app {
    width: 190px; align-items: center; text-align: center;
    background: linear-gradient(150deg, var(--accent), var(--accent-deep));
    border: none; color: #fff;
    box-shadow: 0 10px 30px rgba(8, 90, 78, 0.32);
    z-index: 4;
}
.fmap-cnode--app .fmap-cnode__title { color: #fff; font-size: 1.15rem; }
.fmap-cnode--app .fmap-cnode__eyebrow { color: rgba(255,255,255,0.82); }
.fmap-cnode--app .fmap-cnode__sub { color: rgba(255,255,255,0.9); }

.fmap-cnode--area {
    width: 200px;
    border-left: 4px solid var(--dot, var(--accent));
    --dot: var(--accent);
}
.fmap-cnode--area[data-status] { border-left-color: var(--dot); }

.fmap-cnode--leaf { width: 172px; padding: 0.5rem 0.65rem; background: var(--surface); }
.fmap-cnode--leaf .fmap-cnode__title { font-size: 0.9rem; font-weight: 600; }

.fmap-cnode.is-current {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 28%, transparent), 0 10px 26px rgba(8, 90, 78, 0.22);
}
.fmap-cnode.is-current::after {
    content: "In context";
    position: absolute; top: -0.7rem; right: -0.4rem;
    font-size: 0.6rem; font-weight: 700; letter-spacing: 0.04em;
    color: #fff; background: var(--accent); border-radius: 999px; padding: 0.1rem 0.45rem;
    box-shadow: var(--shadow);
}

/* Dim everything else when a context is active so highlighted nodes lead. */
.fmap--canvas .fmap-nodes.has-context .fmap-cnode:not(.is-current):not(.fmap-cnode--app) { opacity: 0.72; }

.fmap-cnode.is-entering { animation: fmap-pop 260ms cubic-bezier(.22,.61,.36,1) both; }
@keyframes fmap-pop {
    from { opacity: 0; transform: translate(-50%, -50%) scale(0.8); }
    to { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}

/* Controls */
.fmap-stage__controls {
    position: absolute; right: 12px; bottom: 12px;
    display: flex; gap: 6px; align-items: center; z-index: 10;
}
.fmap-ctrl {
    min-width: 34px; height: 34px; padding: 0 0.5rem;
    display: inline-flex; align-items: center; justify-content: center;
    font: inherit; font-weight: 700; font-size: 0.95rem;
    color: var(--text); background: rgba(255, 252, 247, 0.95);
    border: 1px solid var(--border); border-radius: 9px;
    cursor: pointer; box-shadow: var(--shadow);
    backdrop-filter: blur(4px);
}
.fmap-ctrl:hover { border-color: var(--accent); color: var(--accent-deep); }
.fmap-ctrl:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.fmap-ctrl--wide { font-size: 0.82rem; font-weight: 600; }

/* Tooltip */
.fmap-tooltip {
    position: absolute; z-index: 20; transform: translate(-50%, -100%);
    max-width: 260px; pointer-events: none;
    display: flex; flex-direction: column; gap: 0.2rem;
    padding: 0.55rem 0.7rem;
    background: #1a2421; color: #f4f0e8;
    border-radius: 9px; box-shadow: 0 10px 30px rgba(0,0,0,0.28);
    font-size: 0.8rem; line-height: 1.4;
}
.fmap-tooltip strong { font-family: var(--display); font-size: 0.9rem; }
.fmap-tooltip__meta { color: #b9c6bf; font-size: 0.74rem; }
.fmap-tooltip__hint { color: #8fb8ac; font-size: 0.7rem; margin-top: 0.15rem; }

/* ---- Fallback / list view (no-JS, mobile, and desktop list mode) ---- */
.fmap--canvas:not(.fmap--list) .fmap-fallback { display: none; }
.fmap--canvas:not(.fmap--list) .fmap-stage { display: block; }

.fmap-fallback__intro { margin: 0 0 0.9rem; }
.fmap-fallback__toggle { margin: 0 0 1rem; }

.fmap-area-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.7rem; }
.fmap-area-card {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); box-shadow: var(--shadow);
    overflow: hidden;
}
.fmap-area-card.is-current { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft), var(--shadow); }
.fmap-area-card__details { padding: 0; }
.fmap-area-card__summary {
    list-style: none; cursor: pointer; padding: 0.9rem 1.1rem;
    display: flex; flex-direction: column; gap: 0.3rem;
}
.fmap-area-card__summary::-webkit-details-marker { display: none; }
.fmap-area-card__summary:hover { background: var(--surface-interactive); }
.fmap-area-card__summary:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.fmap-area-card__head { display: flex; align-items: center; gap: 0.5rem; }
.fmap-area-card__title { font-family: var(--display); font-weight: 700; font-size: 1.05rem; }
.fmap-area-card__count {
    margin-left: auto; font-size: 0.78rem; font-weight: 700; color: var(--accent-deep);
    background: var(--accent-soft-2); border-radius: 999px; padding: 0.05rem 0.55rem;
}
.fmap-area-card__desc { color: var(--muted); font-size: 0.9rem; padding-left: 1.12rem; }
.fmap-area-card__more { margin: 0.2rem 1.1rem 1rem; }

.fmap-tag {
    font-size: 0.66rem; font-weight: 700; letter-spacing: 0.03em;
    border-radius: 999px; padding: 0.1rem 0.5rem;
}
.fmap-tag--current { color: #fff; background: var(--accent); }

.fmap-node-list { list-style: none; margin: 0 1.1rem 0.6rem; padding: 0; display: grid; gap: 0.4rem; }
.fmap-node { margin: 0; }
.fmap-node__link {
    display: flex; flex-direction: column; gap: 0.15rem;
    padding: 0.6rem 0.75rem; text-decoration: none; color: var(--text);
    background: var(--surface-raised); border: 1px solid var(--border); border-radius: var(--radius-sm);
    transition: border-color 130ms ease, transform 130ms ease;
}
.fmap-node__link:hover { border-color: var(--accent); transform: translateX(2px); color: var(--text); }
.fmap-node.is-current .fmap-node__link { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
.fmap-node__title { display: flex; align-items: center; gap: 0.45rem; font-weight: 600; }
.fmap-node__summary { color: var(--muted); font-size: 0.85rem; padding-left: 1.07rem; }
.fmap-node__meta { display: flex; flex-wrap: wrap; gap: 0.35rem 0.8rem; padding-left: 1.07rem; font-size: 0.76rem; color: var(--muted); }
.fmap-node__open { color: var(--accent-deep); font-weight: 600; }

/* Responsive statistics + hide the stage on small screens (fallback takes over) */
@media (max-width: 900px) {
    .fmap-stats { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 760px) {
    .fmap-stage, .fmap__hint { display: none !important; }
    .fmap-fallback { display: block !important; }
}
@media (max-width: 460px) {
    .fmap-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .fmap-stat__value { font-size: 1.3rem; }
}

@media (prefers-reduced-motion: reduce) {
    .fmap-cnode, .fmap-stat__link, .fmap-node__link { transition: none; }
    .fmap-cnode.is-entering { animation: none; }
    .fmap-context__pulse { animation: none; }
}
