@font-face {
  font-family: 'Source Serif 4';
  src: url('../assets/fonts/source-serif-4-latin-ext.woff2') format('woff2');
  font-weight: 400 800;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: 'Source Serif 4';
  src: url('../assets/fonts/source-serif-4-latin.woff2') format('woff2');
  font-weight: 400 800;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Source Sans 3';
  src: url('../assets/fonts/source-sans-3-latin-ext.woff2') format('woff2');
  font-weight: 400 700;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'IBM Plex Mono';
  src: url('../assets/fonts/ibm-plex-mono-600-latin-ext.woff2') format('woff2');
  font-weight: 500 700;
  font-style: normal;
  font-display: swap;
}

:root {
  --bg: #F5F4F8;
  --surface: #FFFFFF;
  --surface-alt: #EAE8F2;
  --ink: #191726;
  --ink-muted: #4A4660;
  --border: #D1CDE0;
  --border-strong: #9E97B8;
  --amethyst: #562886;
  --amethyst-soft: #EFE6FA;
  --star: #8F4F00;
  --star-soft: #FCF0DC;
  --bridge: #0E5E66;
  --bridge-soft: #DFF2F4;
  --map-ocean: #ECEAF3;
  --map-land: #D7D3E3;
  --map-stroke: #F5F4F8;
  --font-serif: 'Source Serif 4', Georgia, serif;
  --font-sans: 'Source Sans 3', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'IBM Plex Mono', ui-monospace, Menlo, monospace;
  --radius: 10px;
}

[data-theme="dark"] {
  --bg: #0D0E18;
  --surface: #141626;
  --surface-alt: #1C1F34;
  --ink: #F0EFF8;
  --ink-muted: #B8B5D0;
  --border: #2C2F4C;
  --border-strong: #4A4F7B;
  --amethyst: #C69EFF;
  --amethyst-soft: #2A1D47;
  --star: #FBC761;
  --star-soft: #3B2C12;
  --bridge: #67DEE9;
  --bridge-soft: #12373C;
  --map-ocean: #101220;
  --map-land: #222640;
  --map-stroke: #0D0E18;
}

[hidden] { display: none !important; }
svg[hidden] { display: none; }

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--amethyst); text-decoration-thickness: 1.5px; text-underline-offset: 2px; }
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible {
  outline: 3px solid var(--amethyst);
  outline-offset: 2px;
}
.skip-link { position: absolute; left: -9999px; top: 0; padding: 10px 14px; background: var(--amethyst); color: var(--bg); font-weight: 700; z-index: 50; }
.skip-link:focus { left: 12px; top: 12px; }
.shell { max-width: 1220px; margin: 0 auto; padding: 0 20px; }

.topbar { border-bottom: 1px solid var(--border); background: var(--surface); }
.topbar-inner { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 54px; flex-wrap: wrap; padding: 8px 0; }
.brand { font-family: var(--font-mono); font-size: 13px; font-weight: 500; text-decoration: none; color: var(--ink); }
.topbar-controls { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.lang-nav { display: flex; gap: 4px; }
.lang-nav a { font-family: var(--font-mono); font-size: 12px; padding: 5px 8px; border-radius: 6px; text-decoration: none; color: var(--ink-muted); border: 1px solid transparent; }
.lang-nav a[aria-current="page"] { background: var(--amethyst); color: var(--bg); font-weight: 700; }
.lang-nav a:hover:not([aria-current="page"]) { border-color: var(--border-strong); color: var(--ink); }
.theme-btn { font-family: var(--font-sans); font-size: 13px; font-weight: 600; padding: 6px 12px; border-radius: 6px; border: 1px solid var(--border-strong); background: var(--surface-alt); color: var(--ink); cursor: pointer; }

.hero { padding: 28px 0 20px; }
.hero-kicker { display: inline-flex; align-items: center; gap: 8px; font-family: var(--font-mono); font-size: 12px; text-transform: uppercase; letter-spacing: 0.07em; color: var(--amethyst); font-weight: 500; margin-bottom: 10px; }
.star-mark { width: 10px; height: 10px; border-radius: 50%; background: var(--star); box-shadow: 0 0 0 3px var(--amethyst-soft); display: inline-block; }
.hero h1 { font-family: var(--font-serif); font-size: clamp(1.85rem, 3.6vw, 2.75rem); line-height: 1.12; font-weight: 800; letter-spacing: -0.02em; margin: 0 0 12px; max-width: 24ch; }
.hero-deck { font-size: 1.07rem; color: var(--ink-muted); max-width: 68ch; margin: 0 0 16px; }

.mode-tabs { display: inline-flex; gap: 6px; background: var(--surface-alt); padding: 4px; border-radius: 9px; border: 1px solid var(--border); }
.mode-tab { font-family: var(--font-sans); font-size: 14px; font-weight: 700; padding: 8px 16px; border-radius: 7px; border: none; background: transparent; color: var(--ink-muted); cursor: pointer; }
.mode-tab[aria-pressed="true"] { background: var(--amethyst); color: var(--bg); }

.stage { display: grid; grid-template-columns: minmax(0, 1.08fr) minmax(0, 0.92fr); gap: 20px; align-items: start; margin-bottom: 32px; }
@media (max-width: 960px) { .stage { grid-template-columns: 1fr; } }
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; }

.hub-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
.chip-btn { font-family: var(--font-sans); font-size: 13px; font-weight: 600; padding: 5px 11px; border-radius: 999px; border: 1px solid var(--border-strong); background: var(--bg); color: var(--ink); cursor: pointer; }
.chip-btn:hover, .chip-btn[aria-pressed="true"] { background: var(--amethyst); color: var(--bg); border-color: var(--amethyst); }

.constellation-wrap { background: var(--bg); border: 1px solid var(--border); border-radius: 9px; overflow: hidden; }
.constellation-svg { width: 100%; height: auto; display: block; }
.star-node { cursor: pointer; }

.edge-detail { margin-top: 12px; padding: 12px 14px; border-radius: 8px; background: var(--amethyst-soft); border-left: 4px solid var(--amethyst); }
.edge-detail-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; flex-wrap: wrap; font-weight: 800; font-size: 1.05rem; color: var(--ink); }
.edge-detail-meta { font-family: var(--font-mono); font-size: 12px; color: var(--amethyst); }
.edge-detail-ex { font-size: 13.5px; color: var(--ink-muted); margin: 6px 0 0; }

.nb-list { display: flex; flex-direction: column; gap: 6px; margin-top: 12px; }
.nb-btn { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 8px 11px; border-radius: 7px; border: 1px solid var(--border); background: var(--bg); color: var(--ink); cursor: pointer; text-align: left; font-size: 14px; }
.nb-btn:hover { border-color: var(--amethyst); }
.nb-btn[aria-pressed="true"] { border-color: var(--amethyst); background: var(--amethyst-soft); font-weight: 700; }
.nb-stat { font-family: var(--font-mono); font-size: 12px; color: var(--bridge); white-space: nowrap; }

.map-header { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; margin-bottom: 10px; flex-wrap: wrap; }
.map-title { font-family: var(--font-serif); font-size: 1.15rem; font-weight: 700; margin: 0; }
.map-sub { font-family: var(--font-mono); font-size: 11.5px; color: var(--ink-muted); }
.world-map-wrap { background: var(--map-ocean); border: 1px solid var(--border); border-radius: 8px; overflow: hidden; margin-bottom: 12px; }
.world-map-svg { width: 100%; height: auto; display: block; }
.land-path { fill: var(--map-land); stroke: var(--map-stroke); stroke-width: 0.6; }

/* Mode 2: 10-Pair Mental-Map Test */
.test-stage { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 0.9fr); gap: 20px; align-items: start; margin-bottom: 34px; }
@media (max-width: 960px) { .test-stage { grid-template-columns: 1fr; } }
.pair-list { display: flex; flex-direction: column; gap: 8px; margin: 12px 0; }
.pair-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 10px 12px; border-radius: 8px; border: 1px solid var(--border); background: var(--bg); }
.pair-row.is-merged { border-color: var(--amethyst); background: var(--amethyst-soft); }
.pair-title { font-weight: 700; font-size: 15px; display: block; color: var(--ink); }
.pair-global { font-family: var(--font-mono); font-size: 11.5px; color: var(--ink-muted); display: block; }
.toggle-group { display: inline-flex; gap: 4px; }
.tog-btn { font-family: var(--font-sans); font-size: 12.5px; font-weight: 700; padding: 6px 11px; border-radius: 6px; border: 1px solid var(--border-strong); background: var(--surface); color: var(--ink); cursor: pointer; }
.tog-btn[aria-pressed="true"] { background: var(--amethyst); color: var(--bg); border-color: var(--amethyst); }

.score-box { padding: 14px 16px; border-radius: 9px; border: 1.5px solid var(--amethyst); background: var(--amethyst-soft); margin-bottom: 14px; }
.score-big { font-family: var(--font-serif); font-size: 1.75rem; font-weight: 800; color: var(--amethyst); display: block; line-height: 1.15; }
.score-sub { font-size: 14px; color: var(--ink-muted); display: block; margin-top: 4px; }
.match-bars { display: flex; flex-direction: column; gap: 6px; margin: 12px 0; }
.match-row { display: grid; grid-template-columns: 96px 1fr 48px; gap: 8px; align-items: center; font-size: 13.5px; }
.match-bg { height: 10px; border-radius: 999px; background: var(--surface-alt); overflow: hidden; }
.match-fill { height: 100%; background: var(--bridge); border-radius: 999px; }

.share-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--border); }
.btn { font-family: var(--font-sans); font-size: 14px; font-weight: 600; padding: 9px 14px; border-radius: 7px; border: 1px solid var(--border-strong); background: var(--surface-alt); color: var(--ink); cursor: pointer; }
.btn-primary { background: var(--amethyst); color: var(--bg); border-color: var(--amethyst); }
.copy-feedback { font-family: var(--font-mono); font-size: 12px; color: var(--bridge); margin-top: 8px; min-height: 18px; }

/* Sections & Catalog Table */
.section { padding: 34px 0; border-top: 1px solid var(--border); }
.section-eyebrow { font-family: var(--font-mono); font-size: 12px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--amethyst); margin: 0 0 6px; }
.section h2 { font-family: var(--font-serif); font-size: clamp(1.45rem, 2.5vw, 2rem); line-height: 1.18; margin: 0 0 10px; }
.section-lead { color: var(--ink-muted); max-width: 68ch; margin: 0 0 18px; }

.table-controls { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 14px; align-items: center; }
.search-input { flex: 1 1 260px; font-family: var(--font-sans); font-size: 15px; padding: 9px 12px; border-radius: 7px; border: 1.5px solid var(--border-strong); background: var(--surface); color: var(--ink); }
.table-scroll { overflow-x: auto; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); }
table.ref-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.ref-table th, .ref-table td { text-align: left; padding: 9px 11px; border-bottom: 1px solid var(--border); }
.ref-table th { font-family: var(--font-mono); font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.04em; background: var(--surface-alt); color: var(--ink-muted); white-space: nowrap; }
.ref-table tbody tr:hover { background: var(--surface-alt); }
.num-col { font-family: var(--font-mono); text-align: right; }

.findings-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
@media (max-width: 740px) { .findings-grid { grid-template-columns: 1fr; } }
.finding-card h3 { font-family: var(--font-serif); font-size: 1.12rem; margin: 0 0 8px; line-height: 1.25; }
.finding-card p { margin: 0; color: var(--ink-muted); font-size: 15px; }

.method-grid { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 0.85fr); gap: 18px; }
@media (max-width: 820px) { .method-grid { grid-template-columns: 1fr; } }
.faq-item { border-bottom: 1px solid var(--border); padding: 11px 0; }
.faq-item summary { font-weight: 700; cursor: pointer; list-style: none; display: flex; justify-content: space-between; gap: 10px; }
.faq-item summary::after { content: '+'; font-family: var(--font-mono); color: var(--amethyst); }
.faq-item[open] summary::after { content: '−'; }
.faq-item p { margin: 8px 0 0; color: var(--ink-muted); font-size: 14.5px; }

.footer { border-top: 1px solid var(--border); padding: 24px 0 36px; font-size: 13.5px; color: var(--ink-muted); }
.footer-inner { display: flex; justify-content: space-between; align-items: baseline; flex-wrap: wrap; gap: 12px; }
