:root {
  --ink: #102a32;
  --soft: #5b7276;
  --ocean: #071c24;
  --ocean-2: #0d3b46;
  --paper: #fffdf7;
  --foam: #f3f7f3;
  --line: #d9e0d9;
  --aqua: #55c2b8;
  --coral: #f06d5f;
  --sun: #f4bd4b;
  --content: 1320px;
  font-family: Inter, "Avenir Next", Avenir, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--foam);
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; background: radial-gradient(circle at 90% 0, rgba(85, 194, 184, .11), transparent 34rem), var(--foam); }
button, select { font: inherit; }
button, select { cursor: pointer; }
[hidden] { display: none !important; }

.view-nav { position: sticky; top: 0; z-index: 50; border-bottom: 1px solid rgba(16,42,50,.11); background: rgba(247,250,247,.95); backdrop-filter: blur(18px); }
.view-nav-inner { width: min(1480px, calc(100% - 44px)); min-height: 70px; margin: 0 auto; }
.view-tabs { min-width: 0; min-height: 70px; display: flex; align-items: stretch; }
.view-tab { position: relative; display: flex; align-items: center; border: 0; padding: 0 20px; color: var(--soft); background: transparent; font-weight: 750; text-decoration: none; white-space: nowrap; }
.view-tab::after { content: ""; position: absolute; left: 20px; right: 20px; bottom: 0; height: 4px; border-radius: 4px 4px 0 0; background: var(--coral); transform: scaleX(0); }
.view-tab.active { color: var(--ink); }
.view-tab.active::after { transform: scaleX(1); }
.view-tab:focus-visible { outline: 3px solid rgba(240,109,95,.45); outline-offset: -3px; }
.tab-number { margin-right: 7px; color: #8aa0a3; font-size: .72rem; letter-spacing: .08em; }

.hero { color: white; background: linear-gradient(135deg, #061a22, #0d3b46 72%, #155965); }
.hero-copy, .hero-stats, main { width: min(var(--content), calc(100% - 42px)); margin-inline: auto; }
.hero-copy { padding: 58px 0 38px; }
.eyebrow { margin: 0 0 9px; color: var(--aqua); font-size: .7rem; font-weight: 850; letter-spacing: .17em; text-transform: uppercase; }
.hero h1 { margin: 0; font-size: clamp(3.2rem, 8vw, 7.2rem); line-height: .92; letter-spacing: -.055em; }
.hero-copy > p:last-child { max-width: 710px; margin: 26px 0 0; color: #bcd3d4; font-size: 1rem; line-height: 1.65; }
.hero-stats { display: grid; grid-template-columns: repeat(4, 1fr); border-top: 1px solid rgba(255,255,255,.13); }
.hero-stat { padding: 19px 0 24px; }
.hero-stat strong { display: block; font-size: 1.55rem; }
.hero-stat span { color: #a9c3c5; font-size: .7rem; }

main { padding: 30px 0 90px; }
.toolbar { position: sticky; top: 82px; z-index: 20; display: flex; justify-content: space-between; gap: 18px; margin-bottom: 28px; padding: 12px; border: 1px solid var(--line); border-radius: 15px; background: rgba(255,253,247,.94); box-shadow: 0 12px 34px rgba(7,28,36,.08); backdrop-filter: blur(18px); }
.tabs { display: flex; gap: 4px; }
.tab { border: 0; border-radius: 9px; padding: 10px 14px; color: var(--soft); background: transparent; font-weight: 760; }
.tab.active { color: white; background: var(--ocean-2); }
.selectors { display: flex; gap: 9px; }
.selectors label { display: flex; align-items: center; gap: 7px; }
.selectors span { color: var(--soft); font-size: .66rem; font-weight: 820; letter-spacing: .07em; text-transform: uppercase; }
select { height: 38px; border: 1px solid #cbd6d2; border-radius: 8px; padding: 0 30px 0 10px; color: var(--ink); background: white; }

.panel { animation: reveal .2s ease; }
@keyframes reveal { from { opacity: .25; transform: translateY(5px); } }
.grammar-cards { display: grid; gap: 22px; }
.grammar-card, .transition-panel, .table-shell, .interpretation { overflow: hidden; border: 1px solid var(--line); border-radius: 22px; background: var(--paper); box-shadow: 0 10px 30px rgba(7,28,36,.055); }
.grammar-header { display: grid; grid-template-columns: auto minmax(260px, 1fr) auto; align-items: center; gap: 18px; padding: 21px 24px; border-bottom: 1px solid #e6e7df; background: linear-gradient(90deg, color-mix(in srgb, var(--theme) 13%, white), white 48%); }
.theme-number { width: 62px; height: 62px; display: grid; place-content: center; border-radius: 16px; color: white; background: var(--theme); font-weight: 880; }
.grammar-header h2, .section-heading h2 { margin: 0; font-size: 1.7rem; }
.grammar-header p { margin: 4px 0 0; color: var(--soft); font-size: .76rem; }
.coverage { text-align: right; }
.coverage strong { display: block; font-size: 1.2rem; }
.coverage span { color: var(--soft); font-size: .68rem; }
.grammar-body { padding: 24px; }
.grammar-expression { margin: 0 0 22px; padding: 17px 19px; border-left: 5px solid var(--theme); border-radius: 8px; color: #19343c; background: #f1f5f0; font-family: "SFMono-Regular", Consolas, monospace; font-size: clamp(1rem, 2vw, 1.45rem); line-height: 1.5; }
.grammar-grid { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(300px, .65fr); gap: 26px; }
.subheading { margin: 0 0 12px; font-size: .73rem; letter-spacing: .09em; text-transform: uppercase; }
.phrase-variants { display: grid; gap: 9px; }
.phrase-variant { display: grid; grid-template-columns: 38px 1fr auto; align-items: center; gap: 9px; min-width: 0; }
.variant-count { color: var(--soft); font-size: .67rem; text-align: right; }
.unit-sequence { min-width: 0; display: flex; gap: 3px; overflow-x: auto; padding: 3px 0 5px; }
.unit-token { flex: 0 0 auto; border-radius: 5px; padding: 5px 7px; color: white; background: var(--unit); font-size: .62rem; font-weight: 850; }
.variant-share { color: var(--soft); font-size: .67rem; }
.label-bars { display: grid; gap: 9px; }
.label-bar { display: grid; grid-template-columns: 100px 1fr 44px; align-items: center; gap: 8px; font-size: .7rem; }
.label-bar strong { overflow: hidden; text-overflow: ellipsis; }
.bar-track { height: 7px; overflow: hidden; border-radius: 7px; background: #e9ede7; }
.bar-track i { display: block; height: 100%; border-radius: inherit; background: var(--unit); }
.label-bar span { color: var(--soft); text-align: right; }
.unit-graph { width: 100%; min-height: 290px; margin-top: 24px; border-top: 1px solid #ecece5; }
.unit-graph text { font-family: inherit; font-size: 10px; font-weight: 800; fill: white; text-anchor: middle; dominant-baseline: central; pointer-events: none; }
.unit-graph path { fill: none; stroke: #809396; stroke-opacity: .5; marker-end: url(#arrow); }
.unit-graph circle { stroke: white; stroke-width: 3px; }

.transition-panel { margin-top: 26px; padding-bottom: 22px; }
.section-heading { display: flex; justify-content: space-between; align-items: end; gap: 28px; padding: 22px 24px; border-bottom: 1px solid #e5e7df; }
.section-heading > p { max-width: 610px; margin: 0; color: var(--soft); font-size: .78rem; line-height: 1.5; text-align: right; }
.theme-transitions { display: flex; flex-wrap: wrap; gap: 8px; padding: 20px 24px 0; }
.transition-chip { display: inline-flex; align-items: center; gap: 8px; padding: 8px 10px; border: 1px solid #dce1db; border-radius: 999px; font-size: .7rem; }
.transition-chip i { width: 8px; height: 8px; border-radius: 50%; background: var(--from); box-shadow: 18px 0 var(--to); margin-right: 18px; }
.transition-chip strong { font-size: .76rem; }
.transition-chip span { color: var(--soft); }

.confusion-summary { display: flex; flex-wrap: wrap; gap: 8px; margin: 20px 0; }
.confusion-chip { padding: 8px 11px; border-radius: 999px; color: #49302d; background: #f8dfd8; font-size: .72rem; }
.table-shell { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .74rem; }
th { padding: 11px 13px; color: var(--soft); background: #f0f4ef; font-size: .62rem; letter-spacing: .08em; text-align: left; text-transform: uppercase; }
td { padding: 12px 13px; border-top: 1px solid #e8eae3; vertical-align: top; }
.score-pill { display: inline-block; min-width: 48px; border-radius: 999px; padding: 5px 7px; color: white; background: var(--coral); text-align: center; font-weight: 850; }
.change { font-weight: 850; white-space: nowrap; }
.recording-cell { max-width: 340px; }
.recording-cell strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.recording-cell span, .evidence { color: var(--soft); }

.metric-cards { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin: 22px 0; }
.metric-card { padding: 19px; border: 1px solid var(--line); border-radius: 16px; background: var(--paper); }
.metric-card strong { display: block; margin-bottom: 5px; font-size: 2rem; }
.metric-card span { color: var(--soft); font-size: .72rem; line-height: 1.35; }
.year-results { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.year-card { padding: 18px; border-radius: 16px; color: white; background: var(--ocean-2); }
.year-card h3 { margin: 0 0 15px; font-size: 1.3rem; }
.year-card dl { margin: 0; display: grid; gap: 9px; }
.year-card div { display: flex; justify-content: space-between; gap: 12px; }
.year-card dt { color: #b9d0d1; font-size: .69rem; }
.year-card dd { margin: 0; font-weight: 820; }
.interpretation { margin-top: 20px; padding: 22px 24px; }
.interpretation h3 { margin: 0 0 8px; }
.interpretation p { max-width: 850px; margin: 0; color: var(--soft); line-height: 1.6; }

.loading { position: fixed; inset: 0; z-index: 100; display: grid; place-content: center; color: white; background: var(--ocean); transition: opacity .2s, visibility .2s; }
.loading.done { opacity: 0; visibility: hidden; }
.empty { padding: 50px; color: var(--soft); text-align: center; }

@media (max-width: 900px) {
  .hero-stats, .metric-cards, .year-results { grid-template-columns: repeat(2, 1fr); }
  .grammar-grid { grid-template-columns: 1fr; }
  .toolbar, .section-heading { align-items: stretch; flex-direction: column; }
  .section-heading > p { text-align: left; }
}
@media (max-width: 760px) {
  .view-nav-inner { width: min(100% - 26px, 1480px); min-height: 62px; overflow-x: auto; }
  .view-nav-inner { scrollbar-width: none; }
  .view-nav-inner::-webkit-scrollbar { display: none; }
  .view-tabs { min-height: 62px; }
  .view-tab { padding-inline: 13px; font-size: .78rem; }
  .view-tab::after { left: 13px; right: 13px; }
}
@media (max-width: 600px) {
  .hero-copy, .hero-stats, main { width: min(100% - 24px, var(--content)); }
  .hero-stats { grid-template-columns: repeat(2, 1fr); }
  .toolbar { position: static; }
  .tabs, .selectors { flex-wrap: wrap; }
  .grammar-header { grid-template-columns: auto 1fr; }
  .coverage { grid-column: 1 / 3; text-align: left; }
  .metric-cards, .year-results { grid-template-columns: 1fr; }
}
