/* KBatch Dictionary — clean single page · light / dark */

:root,
html[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0a0c10;
  --bg-elev: #0d1117;
  --bg-card: #12171f;
  --bg-card-hover: #161c27;
  --bg-header: rgba(10, 12, 16, 0.92);
  --line: #21262d;
  --line-soft: #1a1f27;
  --ink: #e6edf3;
  --muted: #8b949e;
  --faint: #484f58;
  --braille: #e6edf3;
  --accent: #f97316;
  --accent-dim: rgba(249, 115, 22, 0.15);
  --accent-text: #fdba74;
  --blue: #58a6ff;
  --green: #3fb950;
  --purple: #c084fc;
  --pink: #f472b6;
  --cyan: #22d3ee;
  --danger: #f85149;
  --warn: #d29922;
  --canvas-bg: #0d1117;
  --key-fill: #161b22;
  --key-stroke: #30363d;
  --key-label: #8b949e;
  --key-label-hot: #fff7ed;
  --path: rgba(249, 115, 22, 0.9);
  --path-dot: #ea580c;
  --panel-cell: #161b22;
  --radius: 10px;
  --font: "Inter", ui-sans-serif, system-ui, -apple-system, sans-serif;
  --mono: "SF Mono", "JetBrains Mono", ui-monospace, Menlo, monospace;
  /* Compact sticky header (writer moved into main flow) */
  --header-h: 132px;
  --rail-w: 44px;
  --geo-h: 200px;
}

html[data-theme="light"] {
  color-scheme: light;
  --bg: #f6f5f2;
  --bg-elev: #ffffff;
  --bg-card: #fafaf8;
  --bg-card-hover: #f0efeb;
  --bg-header: rgba(246, 245, 242, 0.92);
  --line: #e0ddd6;
  --line-soft: #ebe8e1;
  --ink: #1c1917;
  --muted: #57534e;
  --faint: #a8a29e;
  --braille: #1c1917;
  --accent: #ea580c;
  --accent-dim: rgba(234, 88, 12, 0.12);
  --accent-text: #c2410c;
  --blue: #2563eb;
  --green: #16a34a;
  --purple: #7c3aed;
  --pink: #db2777;
  --cyan: #0891b2;
  --danger: #dc2626;
  --warn: #b45309;
  --canvas-bg: #ffffff;
  --key-fill: #fafafa;
  --key-stroke: #e0e0e0;
  --key-label: #737373;
  --key-label-hot: #1c1917;
  --path: rgba(234, 88, 12, 0.85);
  --path-dot: #c2410c;
  --panel-cell: #f5f5f4;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  transition: background 0.2s ease, color 0.2s ease;
  overflow-x: hidden;
}

/* Long words / run-ons never escape the viewport */
.main-col,
.header-inner,
.word-card,
.writer-panel,
.pres-modal,
.geo-side,
.letter-section {
  min-width: 0;
  max-width: 100%;
}

.breakable,
.word-label,
.focus-word,
.geo-label,
#geo-label,
.layout-chip b,
.layout-mini i,
.meta-v,
.ddr-flow,
.braille,
.flow-arrows,
.ct-strip,
.ct-stats-bar,
.writer-so,
.writer-card p,
.status-line,
.pres-preview {
  overflow-wrap: anywhere;
  word-break: break-word;
  max-width: 100%;
}

/* ── Header ── */
.app-header {
  position: sticky;
  top: 0;
  z-index: 40;
  background: var(--bg-header);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}

.header-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 12px 16px 12px;
  display: grid;
  gap: 10px;
}

.brand-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

/* Theme toggle — left of title */
.theme-toggle {
  appearance: none;
  flex-shrink: 0;
  width: 34px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--bg-elev);
  color: var(--muted);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s, transform 0.15s;
  position: relative;
}

.theme-toggle:hover {
  color: var(--ink);
  border-color: var(--accent);
  background: var(--accent-dim);
}

.theme-toggle:active {
  transform: scale(0.96);
}

.theme-icon {
  font-size: 0.95rem;
  line-height: 1;
  position: absolute;
}

/* Dark theme: show sun (switch to light). Light theme: show moon (switch to dark). */
html[data-theme="dark"] .theme-icon--sun,
html:not([data-theme]) .theme-icon--sun {
  display: inline;
}
html[data-theme="dark"] .theme-icon--moon,
html:not([data-theme]) .theme-icon--moon {
  display: none;
}
html[data-theme="light"] .theme-icon--sun {
  display: none;
}
html[data-theme="light"] .theme-icon--moon {
  display: inline;
}

.brand h1 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.brand h1 span {
  color: var(--accent);
}

.brand-sub {
  font-size: 0.7rem;
  color: var(--muted);
}

/* Site nav: Dictionary · DOJO */
.site-nav {
  display: flex;
  gap: 4px;
  align-items: center;
}

.nav-link {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--muted);
  text-decoration: none;
  padding: 6px 10px;
  border-radius: 7px;
  border: 1px solid transparent;
}

.nav-link:hover {
  color: var(--ink);
  background: var(--bg-card-hover);
}

.nav-link.is-active {
  color: var(--accent-text);
  background: var(--accent-dim);
  border-color: color-mix(in srgb, var(--accent) 40%, transparent);
}

/* List toolbar under keyboard, above A–Z */
.list-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: 0 0 12px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg-elev);
}

.list-toolbar-left {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.list-toolbar-title {
  font-size: 0.8rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.list-toolbar-hint {
  font-size: 0.65rem;
  color: var(--muted);
}

.list-toolbar-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.list-toolbar-actions a.btn {
  text-decoration: none;
  display: inline-flex;
  align-items: center;
}

/* Language section above A–Z */
.lang-section {
  margin: 0 0 12px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg-elev);
  min-width: 0;
  max-width: 100%;
}

.lang-section-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 6px 12px;
  margin-bottom: 8px;
}

.lang-section-title {
  margin: 0;
  font-size: 0.8rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.lang-section-meta {
  margin: 0;
  font-size: 0.68rem;
  color: var(--muted);
  overflow-wrap: anywhere;
  word-break: break-word;
  max-width: 100%;
}

.lang-section-lead {
  margin: 0 0 10px;
  font-size: 0.68rem;
  color: var(--faint);
  line-height: 1.4;
  overflow-wrap: anywhere;
}

/* Sound origin → phoneme → discourse pipeline */
.step-origin-row {
  display: flex;
  flex-wrap: nowrap;
  gap: 4px;
  overflow-x: auto;
  margin-bottom: 10px;
  padding-bottom: 4px;
  max-width: 100%;
  scrollbar-width: thin;
}

.step-origin-chip {
  appearance: none;
  flex: 0 0 auto;
  border: 1px solid var(--line-soft);
  background: var(--bg);
  color: var(--muted);
  font: inherit;
  font-size: 0.58rem;
  font-weight: 700;
  padding: 5px 8px;
  border-radius: 8px;
  cursor: default;
  max-width: 7.5rem;
  line-height: 1.25;
  text-align: left;
}

.step-origin-chip small {
  display: block;
  font-size: 0.5rem;
  font-weight: 600;
  color: var(--faint);
  margin-top: 2px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.step-origin-chip.is-reached {
  border-color: color-mix(in srgb, var(--accent) 25%, var(--line));
  color: var(--ink);
}

.step-origin-chip.is-active {
  color: var(--accent-text);
  background: var(--accent-dim);
  border-color: color-mix(in srgb, var(--accent) 50%, transparent);
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--accent) 25%, transparent);
}

/* Register spectrum: classical → slang → off */
.step-register-row {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-bottom: 10px;
}

.step-reg-chip {
  appearance: none;
  border: 1px solid var(--line-soft);
  background: var(--bg);
  color: var(--muted);
  font: inherit;
  font-size: 0.6rem;
  font-weight: 700;
  padding: 4px 9px;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
}

.step-reg-chip:hover {
  color: var(--ink);
}

.step-reg-chip.is-hit {
  color: var(--ink);
  border-color: color-mix(in srgb, var(--chip-c, var(--accent)) 40%, var(--line));
}

.step-reg-chip.is-active {
  color: var(--bg);
  background: var(--chip-c, var(--accent));
  border-color: transparent;
}

/* Historical language stepping path */
.step-path-block {
  margin: 0 0 10px;
  padding: 10px;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: var(--bg);
  min-width: 0;
}

.step-path-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.step-path-title {
  font-size: 0.68rem;
  font-weight: 800;
  color: var(--ink);
}

.step-path-select {
  max-width: min(100%, 280px);
  height: 30px;
  padding: 0 8px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: var(--bg-elev);
  color: var(--ink);
  font: inherit;
  font-size: 0.65rem;
  font-weight: 600;
}

.step-path-row {
  display: flex;
  flex-wrap: nowrap;
  gap: 0;
  overflow-x: auto;
  align-items: stretch;
  max-width: 100%;
  scrollbar-width: thin;
  padding-bottom: 2px;
}

.step-path-node {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 0;
  min-width: 0;
}

.step-path-card {
  padding: 6px 8px;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: var(--bg-elev);
  min-width: 5.5rem;
  max-width: 8.5rem;
}

.step-path-card strong {
  display: block;
  font-size: 0.65rem;
  font-weight: 800;
  color: var(--ink);
  overflow-wrap: anywhere;
  line-height: 1.25;
}

.step-path-card span {
  display: block;
  font-size: 0.52rem;
  color: var(--faint);
  margin-top: 2px;
}

.step-path-card em {
  display: block;
  font-style: normal;
  font-size: 0.55rem;
  color: var(--muted);
  margin-top: 3px;
  line-height: 1.3;
  overflow-wrap: anywhere;
}

.step-path-card.is-active {
  border-color: color-mix(in srgb, var(--accent) 50%, transparent);
  background: var(--accent-dim);
}

.step-path-arrow {
  flex: 0 0 auto;
  padding: 0 4px;
  color: var(--faint);
  font-size: 0.75rem;
  font-weight: 700;
  user-select: none;
}

.lang-path-note {
  margin: 8px 0 0;
  font-size: 0.62rem;
  color: var(--muted);
  line-height: 1.4;
  overflow-wrap: anywhere;
}

.lang-chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 8px;
}

.lang-chip {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--muted);
  font: inherit;
  font-size: 0.68rem;
  font-weight: 700;
  padding: 5px 10px;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
}

.lang-chip:hover {
  color: var(--ink);
  border-color: #30363d;
}

.lang-chip.is-active {
  color: var(--accent-text);
  background: var(--accent-dim);
  border-color: color-mix(in srgb, var(--accent) 45%, transparent);
}

.lang-chip small {
  display: block;
  font-size: 0.52rem;
  font-weight: 600;
  color: var(--faint);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  margin-top: 1px;
}

.lang-chip.is-active small {
  color: color-mix(in srgb, var(--accent-text) 80%, var(--faint));
}

.lang-alpha-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  max-width: 100%;
  min-width: 0;
}

.lang-alpha-glyph {
  appearance: none;
  border: 1px solid var(--line-soft);
  background: var(--bg);
  color: var(--ink);
  font: inherit;
  font-family: var(--mono);
  font-size: 0.75rem;
  font-weight: 700;
  min-width: 1.75rem;
  height: 1.75rem;
  padding: 0 5px;
  border-radius: 6px;
  cursor: pointer;
  line-height: 1;
}

.lang-alpha-glyph:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.lang-alpha-glyph.is-active {
  background: var(--accent-dim);
  border-color: color-mix(in srgb, var(--accent) 45%, transparent);
  color: var(--accent-text);
}

.letter-glyph {
  font-weight: 800;
  font-size: 1.05em;
  line-height: 1;
}

.letter-lang-tag {
  font-size: 0.65rem;
  font-weight: 600;
  color: var(--faint);
  margin-left: 4px;
  font-family: var(--mono);
}

.show-more-btn {
  display: block;
  width: calc(100% - 28px);
  margin: 10px 14px 14px;
  text-align: center;
}

.letter-page-meta {
  margin: 0;
  padding: 8px 14px 12px;
  font-size: 0.7rem;
  color: var(--muted);
}

/* ── Writer panel (paragraphs / sections) ──
   Must stay in normal document flow. Never sticky/fixed/absolute —
   expanding it pushes geo / language / A–Z down; it must not paint over them. */
.writer-panel {
  position: static;
  z-index: auto;
  float: none;
  clear: both;
  display: block;
  margin: 0 0 14px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg-elev);
  max-width: 100%;
  min-width: 0;
  /* Contain children so nothing escapes over following sections */
  overflow: hidden;
  contain: layout style;
}

.writer-panel[hidden] {
  display: none !important;
}

.writer-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 8px 12px;
  margin-bottom: 8px;
}

.writer-title {
  font-size: 0.8rem;
  font-weight: 800;
}

.writer-hint {
  flex: 1;
  font-size: 0.65rem;
  color: var(--muted);
}

.writer-input {
  width: 100%;
  min-height: 110px;
  padding: 12px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--ink);
  font: inherit;
  font-size: 0.88rem;
  line-height: 1.5;
  resize: vertical;
}

.writer-input:focus {
  outline: none;
  border-color: color-mix(in srgb, var(--accent) 50%, transparent);
  box-shadow: 0 0 0 3px var(--accent-dim);
}

.writer-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-top: 8px;
}

.writer-level {
  font-family: var(--mono);
  font-size: 0.65rem;
  color: var(--faint);
  margin-left: auto;
}

.writer-results {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--line-soft);
  /* Keep analysis tall content inside the panel so lower sections stay on-page */
  max-height: min(52vh, 560px);
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  position: static;
  z-index: auto;
}

.writer-results[hidden] {
  display: none !important;
}

.writer-strip {
  font-family: var(--mono);
  font-size: 0.68rem;
  color: var(--muted);
  padding: 8px 10px;
  border-radius: 6px;
  background: var(--canvas-bg);
  border: 1px solid var(--line-soft);
  margin-bottom: 10px;
  overflow-x: auto;
  overflow-wrap: anywhere;
  word-break: break-word;
  white-space: pre-wrap;
  max-width: 100%;
}

.writer-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

@media (max-width: 800px) {
  .writer-grid {
    grid-template-columns: 1fr;
  }
}

.writer-card {
  padding: 10px 12px;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: var(--bg);
}

.writer-card h3 {
  margin: 0 0 6px;
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--faint);
}

.writer-card p {
  margin: 0 0 4px;
  font-size: 0.78rem;
  color: var(--ink);
  line-height: 1.35;
}

.writer-so {
  font-family: var(--mono);
  font-size: 0.8rem !important;
  color: var(--cyan) !important;
  word-break: break-all;
  letter-spacing: 0.04em;
}

.writer-muted {
  font-size: 0.7rem !important;
  color: var(--muted) !important;
}

.writer-muted a {
  color: var(--blue);
}

.writer-json {
  margin: 10px 0 0;
  max-height: 240px;
  overflow: auto;
  padding: 10px;
  border-radius: 8px;
  background: var(--canvas-bg);
  border: 1px solid var(--line-soft);
  font-family: var(--mono);
  font-size: 0.62rem;
  color: var(--muted);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.writer-kb-stack {
  margin-bottom: 10px;
  padding: 10px;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: var(--bg);
  max-width: 100%;
  min-width: 0;
}

.writer-meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  max-width: 100%;
}

.writer-metrics-row {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 8px;
}

.writer-encodings {
  margin-top: 8px;
  font-size: 0.68rem;
  color: var(--muted);
  font-family: var(--mono);
  overflow-wrap: anywhere;
  word-break: break-word;
  line-height: 1.4;
}

.writer-layouts-scroll {
  display: flex;
  flex-wrap: nowrap;
  gap: 6px;
  overflow-x: auto;
  margin-top: 8px;
  padding-bottom: 4px;
  max-width: 100%;
  scrollbar-width: thin;
}

.writer-card-wide {
  margin-top: 8px;
  grid-column: 1 / -1;
}

.writer-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: 8px;
}

@media (max-width: 900px) {
  .writer-grid {
    grid-template-columns: 1fr;
  }
}

.writer-pre {
  margin: 4px 0 0;
  padding: 8px;
  border-radius: 6px;
  background: var(--canvas-bg);
  border: 1px solid var(--line-soft);
  font-family: var(--mono);
  font-size: 0.62rem;
  line-height: 1.4;
  color: var(--muted);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
  max-height: 140px;
  overflow: auto;
  max-width: 100%;
}

.writer-details {
  margin-top: 6px;
  font-size: 0.7rem;
}

.writer-details summary {
  cursor: pointer;
  color: var(--blue);
  font-weight: 600;
}

.writer-json-details {
  margin-top: 10px;
}

.writer-tokens {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  max-width: 100%;
}

.writer-token {
  border: 1px solid var(--line-soft);
  background: var(--bg-elev);
  border-radius: 6px;
  padding: 4px 6px;
  font-size: 0.65rem;
  max-width: 100%;
  min-width: 0;
}

.writer-token b {
  display: block;
  font-size: 0.75rem;
  color: var(--ink);
  overflow-wrap: anywhere;
}

.writer-token i {
  font-style: normal;
  color: var(--accent-text);
  font-weight: 700;
  font-size: 0.55rem;
  text-transform: uppercase;
}

.writer-token span {
  display: block;
  font-family: var(--mono);
  font-size: 0.55rem;
  color: var(--faint);
  overflow-wrap: anywhere;
  word-break: break-word;
}

.writer-panel.is-live #btn-writer-live {
  color: var(--accent-text);
  border-color: color-mix(in srgb, var(--accent) 45%, transparent);
  background: var(--accent-dim);
}

/* ── Presentation / X Article modal ── */
.pres-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(0, 0, 0, 0.55);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 24px 12px;
  overflow-y: auto;
}

.pres-overlay[hidden] {
  display: none !important;
}

.pres-modal {
  width: min(920px, 100%);
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
  padding: 16px 18px 20px;
}

.pres-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.pres-head h2 {
  margin: 0;
  font-size: 1rem;
  font-weight: 800;
}

.pres-controls {
  display: grid;
  gap: 10px;
  margin-bottom: 12px;
}

.pres-controls label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--faint);
}

.pres-controls select,
.pres-controls textarea {
  font: inherit;
  font-size: 0.85rem;
  font-weight: 500;
  text-transform: none;
  letter-spacing: 0;
  color: var(--ink);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
}

.pres-blocks {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.pres-block-chip {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--muted);
  font: inherit;
  font-size: 0.68rem;
  font-weight: 700;
  padding: 5px 10px;
  border-radius: 999px;
  cursor: pointer;
}

.pres-block-chip.is-on {
  color: var(--accent-text);
  background: var(--accent-dim);
  border-color: color-mix(in srgb, var(--accent) 45%, transparent);
}

.pres-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.pres-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 8px;
}

.pres-tab {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--muted);
  font: inherit;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 5px 12px;
  border-radius: 6px;
  cursor: pointer;
}

.pres-tab.is-active {
  color: var(--accent-text);
  background: var(--accent-dim);
  border-color: color-mix(in srgb, var(--accent) 40%, transparent);
}

.pres-preview {
  margin: 0;
  max-height: min(50vh, 420px);
  overflow: auto;
  padding: 14px;
  border-radius: 8px;
  background: var(--canvas-bg);
  border: 1px solid var(--line-soft);
  font-family: var(--mono);
  font-size: 0.72rem;
  line-height: 1.45;
  color: var(--ink);
  white-space: pre-wrap;
  word-break: break-word;
}

.export-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.btn {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--bg-elev);
  color: var(--ink);
  font: inherit;
  font-size: 0.7rem;
  font-weight: 600;
  padding: 6px 10px;
  border-radius: 7px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.btn:hover {
  background: var(--bg-card-hover);
  border-color: #30363d;
}

.btn-primary {
  background: var(--accent-dim);
  border-color: color-mix(in srgb, var(--accent) 45%, transparent);
  color: var(--accent-text);
}

.btn-primary:hover {
  background: color-mix(in srgb, var(--accent) 22%, transparent);
}

.btn-ghost {
  background: transparent;
  color: var(--muted);
}

.search-row {
  display: flex;
  gap: 8px;
  align-items: stretch;
  min-width: 0;
  flex-wrap: wrap;
}

.search-wrap {
  flex: 1;
  position: relative;
  min-width: 0;
}

.search-wrap input {
  width: 100%;
  height: 42px;
  padding: 0 36px 0 36px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--bg-elev);
  color: var(--ink);
  font: inherit;
  font-size: 0.95rem;
  outline: none;
  text-overflow: ellipsis;
  overflow: hidden;
  white-space: nowrap;
}

.search-wrap input:focus {
  border-color: color-mix(in srgb, var(--accent) 55%, transparent);
  box-shadow: 0 0 0 3px var(--accent-dim);
}

.search-wrap .search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--faint);
  font-size: 0.85rem;
  pointer-events: none;
}

.search-clear {
  appearance: none;
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  width: 26px;
  height: 26px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.search-clear:hover {
  color: var(--ink);
  background: var(--bg-card-hover);
}

.search-clear[hidden] {
  display: none !important;
}

.meta-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 16px;
  font-size: 0.7rem;
  color: var(--muted);
}

.meta-row strong {
  color: var(--ink);
  font-weight: 600;
}

.status-line {
  color: var(--faint);
}

/* ── Layout shell ── */
.app-shell {
  display: grid;
  grid-template-columns: var(--rail-w) 1fr;
  max-width: 1140px;
  margin: 0 auto;
  min-height: calc(100vh - var(--header-h));
}

/* Spotify-style A–Z side scrub */
.alpha-rail {
  position: sticky;
  top: var(--header-h);
  align-self: start;
  height: calc(100vh - var(--header-h));
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 0;
  padding: 8px 0;
  border-right: 1px solid var(--line-soft);
  background: var(--bg);
  z-index: 20;
  overflow-y: auto;
  scrollbar-width: none;
}

.alpha-rail::-webkit-scrollbar {
  display: none;
}

.alpha-letter {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--faint);
  font: inherit;
  font-size: 0.62rem;
  font-weight: 700;
  line-height: 1.15;
  padding: 1px 0;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
  transition: color 0.12s, transform 0.12s;
}

.alpha-letter:hover {
  color: var(--ink);
}

.alpha-letter.is-active {
  color: var(--accent);
  transform: scale(1.2);
}

.alpha-letter.is-empty {
  opacity: 0.35;
}

.alpha-count {
  font-size: 0.45rem;
  font-weight: 500;
  color: var(--faint);
  min-height: 0.55rem;
}

.alpha-letter.is-active .alpha-count {
  color: #fdba74;
}

/* Main column — stacked sections in normal flow (no overlap) */
.main-col {
  position: relative;
  z-index: 0;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0;
  padding: 12px 16px 48px;
  min-width: 0;
  isolation: isolate;
}

.main-col > .shadow-live,
.main-col > .geo-panel,
.main-col > .list-toolbar,
.main-col > .lang-section,
.main-col > .word-list {
  position: relative;
  z-index: 0;
  flex-shrink: 0;
}

/* ── Shadow Live (killer app surface) ── */
.shadow-live {
  margin: 0 0 14px;
  padding: 14px;
  border: 1px solid color-mix(in srgb, var(--accent) 35%, var(--line));
  border-radius: var(--radius);
  background:
    linear-gradient(
      135deg,
      color-mix(in srgb, var(--accent) 8%, var(--bg-elev)) 0%,
      var(--bg-elev) 48%,
      var(--bg-elev) 100%
    );
  max-width: 100%;
  min-width: 0;
  overflow: hidden;
  scroll-margin-top: calc(var(--header-h) + 10px);
}

.shadow-live-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px 14px;
  margin-bottom: 10px;
}

.shadow-live-title {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--ink);
}

.shadow-live-tag {
  margin: 3px 0 0;
  font-size: 0.68rem;
  color: var(--muted);
  line-height: 1.35;
  max-width: 42rem;
}

.shadow-live-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.shadow-input-label {
  display: block;
  margin-bottom: 8px;
}

.shadow-input {
  width: 100%;
  min-height: 72px;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--ink);
  font: inherit;
  font-size: 0.92rem;
  line-height: 1.45;
  resize: vertical;
  max-width: 100%;
}

.shadow-input:focus {
  outline: none;
  border-color: color-mix(in srgb, var(--accent) 55%, transparent);
  box-shadow: 0 0 0 3px var(--accent-dim);
}

.shadow-strip {
  font-family: var(--mono);
  font-size: 0.7rem;
  color: var(--muted);
  padding: 8px 10px;
  border-radius: 8px;
  background: var(--canvas-bg);
  border: 1px solid var(--line-soft);
  margin-bottom: 8px;
  overflow-wrap: anywhere;
  word-break: break-word;
  white-space: pre-wrap;
  max-width: 100%;
}

.shadow-metrics {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-bottom: 8px;
}

.shadow-metrics .pill {
  font-size: 0.65rem;
}

.shadow-copilot {
  margin-bottom: 10px;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--line-soft);
  background: var(--bg);
  max-width: 100%;
}

.shadow-copilot-idle {
  margin: 0;
  font-size: 0.68rem;
  color: var(--faint);
}

.shadow-tip {
  margin: 0 0 4px;
  font-size: 0.72rem;
  line-height: 1.4;
  color: var(--ink);
  overflow-wrap: anywhere;
}

.shadow-tip:last-child {
  margin-bottom: 0;
}

.shadow-tip::before {
  content: "→ ";
  color: var(--faint);
  font-weight: 700;
}

.shadow-tip.is-danger {
  color: var(--danger);
}

.shadow-tip.is-warn {
  color: var(--warn);
}

.shadow-tip.is-action {
  color: var(--accent-text);
}

.shadow-tip.is-ok {
  color: var(--green);
}

.shadow-ring-wrap,
.shadow-rank-wrap {
  margin-bottom: 10px;
  min-width: 0;
}

.shadow-ring-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 4px 10px;
  margin-bottom: 6px;
}

.shadow-ring-title {
  font-size: 0.68rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--faint);
}

.shadow-ring-meta {
  font-size: 0.6rem;
  color: var(--muted);
}

.shadow-ring {
  display: flex;
  flex-wrap: nowrap;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 4px;
  max-width: 100%;
  scrollbar-width: thin;
}

.shadow-card {
  flex: 0 0 auto;
  width: min(148px, 42vw);
  padding: 8px 9px;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: var(--bg);
  min-width: 0;
}

.shadow-card.is-base {
  border-color: color-mix(in srgb, var(--accent) 50%, transparent);
  background: var(--accent-dim);
}

.shadow-card em {
  display: block;
  font-style: normal;
  font-size: 0.62rem;
  font-weight: 800;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.shadow-card.is-base em {
  color: var(--accent-text);
}

.shadow-card b {
  display: block;
  margin-top: 4px;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--ink);
  line-height: 1.3;
  overflow-wrap: anywhere;
  word-break: break-word;
  max-height: 3.9em;
  overflow: hidden;
}

.shadow-card small {
  display: block;
  margin-top: 4px;
  font-size: 0.55rem;
  color: var(--faint);
}

.shadow-rank {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.shadow-rank-chip {
  appearance: none;
  border: 1px solid var(--line-soft);
  background: var(--bg);
  color: var(--muted);
  font: inherit;
  font-size: 0.62rem;
  font-weight: 700;
  padding: 5px 9px;
  border-radius: 999px;
  cursor: pointer;
  max-width: 100%;
}

.shadow-rank-chip:hover {
  color: var(--ink);
  border-color: var(--accent);
}

.shadow-rank-chip.is-best {
  color: var(--green);
  border-color: color-mix(in srgb, var(--green) 45%, transparent);
  background: color-mix(in srgb, var(--green) 10%, var(--bg));
}

.shadow-rank-chip.is-base {
  color: var(--accent-text);
  border-color: color-mix(in srgb, var(--accent) 45%, transparent);
}

.shadow-a11y {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px 12px;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--line-soft);
  background: var(--bg);
  font-size: 0.68rem;
  color: var(--muted);
  font-family: var(--mono);
  max-width: 100%;
  min-width: 0;
}

.shadow-a11y-row {
  overflow-wrap: anywhere;
  word-break: break-word;
  min-width: 0;
}

@media (max-width: 640px) {
  .shadow-a11y {
    grid-template-columns: 1fr;
  }
}

.shadow-stack-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
  margin-bottom: 4px;
}

.stack-chip {
  font-size: 0.58rem;
  font-weight: 700;
  padding: 4px 8px;
  border-radius: 999px;
  border: 1px solid var(--line-soft);
  background: var(--bg);
  color: var(--muted);
  font-family: var(--mono);
}

.stack-chip.is-ok {
  color: var(--green);
  border-color: color-mix(in srgb, var(--green) 40%, transparent);
}

.stack-chip.is-warn {
  color: var(--warn);
  border-color: color-mix(in srgb, var(--warn) 40%, transparent);
}

.stack-chip.is-stub {
  color: var(--faint);
}

.stack-chip-live {
  color: var(--accent-text);
  border-color: color-mix(in srgb, var(--accent) 40%, transparent);
}

.shadow-extra-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 10px;
  min-width: 0;
}

@media (max-width: 800px) {
  .shadow-extra-grid {
    grid-template-columns: 1fr;
  }
}

.shadow-extra-card {
  padding: 10px;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: var(--bg);
  min-width: 0;
}

.shadow-search-row {
  display: flex;
  gap: 6px;
  margin-bottom: 8px;
}

.shadow-search-input {
  flex: 1;
  min-width: 0;
  height: 34px;
  padding: 0 10px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--bg-elev);
  color: var(--ink);
  font: inherit;
  font-size: 0.78rem;
}

.shadow-search-hits {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  max-height: 120px;
  overflow-y: auto;
}

.shadow-hit {
  appearance: none;
  border: 1px solid var(--line-soft);
  background: var(--bg-elev);
  color: var(--ink);
  font: inherit;
  font-size: 0.65rem;
  font-weight: 700;
  padding: 4px 8px;
  border-radius: 6px;
  cursor: pointer;
  max-width: 100%;
}

.shadow-hit:hover {
  border-color: var(--accent);
  color: var(--accent-text);
}

.shadow-hit small {
  display: block;
  font-weight: 600;
  color: var(--faint);
  font-size: 0.52rem;
}

.shadow-qasm {
  margin: 0 0 6px;
  max-height: 110px;
  overflow: auto;
  padding: 8px;
  border-radius: 6px;
  background: var(--canvas-bg);
  border: 1px solid var(--line-soft);
  font-family: var(--mono);
  font-size: 0.58rem;
  color: var(--muted);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.shadow-q-verdict {
  margin: 0;
  font-size: 0.68rem;
  color: var(--muted);
  font-weight: 700;
}

.shadow-q-verdict.is-go {
  color: var(--green);
}

.shadow-q-verdict.is-warn {
  color: var(--warn);
}

.shadow-q-verdict.is-abort {
  color: var(--danger);
}

.spatial-canvas-wrap {
  margin: 0 0 10px;
  padding: 8px 8px 4px;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: var(--bg);
  min-width: 0;
}

#spatial-canvas {
  width: 100%;
  height: 180px;
  display: block;
  border-radius: 6px;
  background: var(--canvas-bg);
}

.shadow-kind-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 8px;
}

.shadow-kind {
  appearance: none;
  border: 1px solid var(--line-soft);
  background: var(--bg-elev);
  color: var(--faint);
  font: inherit;
  font-size: 0.58rem;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 999px;
  cursor: pointer;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.shadow-kind.is-on {
  color: var(--accent-text);
  border-color: color-mix(in srgb, var(--accent) 45%, transparent);
  background: var(--accent-dim);
}

.shadow-hit[data-kind]::after {
  content: attr(data-kind);
  display: inline-block;
  margin-left: 4px;
  font-size: 0.5rem;
  color: var(--faint);
  text-transform: uppercase;
}

.ugrad-live-panel {
  margin-top: 10px;
  padding: 10px;
  border: 1px solid color-mix(in srgb, var(--green) 30%, var(--line));
  border-radius: 8px;
  background: var(--bg);
}

.ugrad-live-status {
  margin: 0 0 8px;
  font-size: 0.7rem;
  color: var(--muted);
  line-height: 1.4;
  overflow-wrap: anywhere;
}

/* Layout select */
.layout-select-wrap {
  display: flex;
  align-items: center;
}

.layout-select {
  height: 42px;
  max-width: 200px;
  padding: 0 10px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--bg-elev);
  color: var(--ink);
  font: inherit;
  font-size: 0.72rem;
  font-weight: 600;
}

/* Geometric / Contrails panel */
.geo-panel {
  display: grid;
  grid-template-columns: 1fr minmax(200px, 260px);
  gap: 12px;
  align-items: stretch;
  margin-bottom: 16px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg-elev);
}

.geo-main {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.mode-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.mode-btn {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--muted);
  font: inherit;
  font-size: 0.62rem;
  font-weight: 700;
  padding: 5px 8px;
  border-radius: 6px;
  cursor: pointer;
  letter-spacing: 0.01em;
}

.mode-btn:hover {
  color: var(--ink);
  border-color: #30363d;
}

.mode-btn.is-active {
  color: var(--accent-text);
  background: var(--accent-dim);
  border-color: color-mix(in srgb, var(--accent) 45%, transparent);
}

.geo-canvas-wrap {
  min-width: 0;
}

#geo-canvas {
  width: 100%;
  height: var(--geo-h);
  display: block;
  border-radius: 8px;
  background: var(--canvas-bg);
  border: 1px solid var(--line-soft);
}

.ct-stats-bar {
  font-family: var(--mono);
  font-size: 0.68rem;
  color: var(--muted);
  padding: 6px 10px;
  border-radius: 6px;
  background: var(--canvas-bg);
  border: 1px solid var(--line-soft);
  letter-spacing: 0.02em;
  overflow-x: auto;
  overflow-wrap: anywhere;
  word-break: break-word;
  white-space: pre-wrap;
  max-width: 100%;
}

.geo-side {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
  max-height: calc(var(--geo-h) + 120px);
  overflow-y: auto;
}

.geo-side h2 {
  margin: 0 0 4px;
  font-size: 0.62rem;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.geo-side p,
.geo-hint {
  margin: 0;
  font-size: 0.65rem;
  color: var(--faint);
  line-height: 1.4;
}

.geo-label,
#geo-label {
  font-family: var(--mono);
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 600;
  margin-bottom: 4px;
}

.focus-word {
  font-size: 1.1rem !important;
  font-weight: 800;
  color: var(--ink) !important;
  letter-spacing: -0.02em;
  margin-top: 4px !important;
  overflow-wrap: anywhere;
  word-break: break-word;
  max-width: 100%;
  line-height: 1.25;
}

.geo-label,
#geo-label {
  overflow-wrap: anywhere;
  word-break: break-word;
  max-width: 100%;
}

/* Meaning + etymology under each word */
.sense-block {
  margin: 0 0 8px;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--line-soft);
  background: var(--bg);
  max-width: 100%;
  min-width: 0;
}

.sense-block.is-loading {
  opacity: 0.75;
}

.sense-block.sense-heuristic {
  border-style: dashed;
}

.sense-meaning {
  font-size: 0.8rem;
  line-height: 1.4;
  color: var(--ink);
  overflow-wrap: anywhere;
  word-break: break-word;
  margin-bottom: 4px;
}

.sense-pos {
  display: inline-block;
  font-size: 0.62rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--accent-text);
  background: var(--accent-dim);
  border-radius: 4px;
  padding: 1px 6px;
  margin-right: 6px;
  vertical-align: middle;
}

.sense-phonetic {
  font-family: var(--mono);
  font-size: 0.7rem;
  color: var(--cyan);
  margin-right: 6px;
}

.sense-etym,
.sense-family {
  font-size: 0.72rem;
  color: var(--muted);
  line-height: 1.35;
  overflow-wrap: anywhere;
  word-break: break-word;
  margin-top: 3px;
}

.sense-k {
  font-size: 0.55rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--faint);
  margin-right: 4px;
}

.sense-more {
  margin-top: 4px;
  font-size: 0.7rem;
  color: var(--muted);
}

.sense-more summary {
  cursor: pointer;
  color: var(--blue);
  font-weight: 600;
}

.sense-more ul {
  margin: 4px 0 0;
  padding-left: 1.1rem;
}

.sense-more li {
  margin: 2px 0;
  overflow-wrap: anywhere;
}

.sense-more em {
  color: var(--accent-text);
  font-style: normal;
  font-weight: 700;
  font-size: 0.65rem;
  text-transform: uppercase;
  margin-right: 4px;
}

.sense-refs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 6px;
  font-size: 0.65rem;
}

.sense-refs a {
  color: var(--blue);
  text-decoration: none;
}

.sense-refs a:hover {
  text-decoration: underline;
}

.focus-sense {
  margin-top: 8px;
  padding: 8px;
  border-radius: 8px;
  border: 1px solid var(--line-soft);
  background: var(--bg);
  max-width: 100%;
}

.focus-meaning {
  font-size: 0.75rem;
  line-height: 1.4;
  color: var(--ink);
  overflow-wrap: anywhere;
  word-break: break-word;
}

.focus-etym,
.focus-phonetic {
  font-size: 0.68rem;
  color: var(--muted);
  margin-top: 4px;
  overflow-wrap: anywhere;
  word-break: break-word;
}

/* Phonation · mouth · tone · registers · placements */
.phono-block {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px dashed var(--line-soft);
  max-width: 100%;
  min-width: 0;
}

.phono-row {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 6px 8px;
  margin-top: 4px;
  font-size: 0.72rem;
  color: var(--ink);
  max-width: 100%;
}

.phono-main,
.phono-tone,
.phono-ipa,
.phono-coach {
  overflow-wrap: anywhere;
  word-break: break-word;
  min-width: 0;
}

.phono-tone {
  font-family: var(--mono);
  color: var(--cyan);
  letter-spacing: 0.06em;
}

.phono-ipa {
  font-family: var(--mono);
  font-size: 0.65rem;
  color: var(--faint);
}

.phono-mouth-seq {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin: 4px 0 2px;
  max-width: 100%;
}

.phono-mouth-unit {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  min-width: 1.6rem;
  padding: 3px 5px;
  border-radius: 5px;
  border: 1px solid var(--line-soft);
  background: var(--bg-elev);
  font-family: var(--mono);
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--ink);
}

.phono-mouth-unit i {
  font-style: normal;
  font-size: 0.48rem;
  font-weight: 600;
  color: var(--faint);
  text-transform: uppercase;
  letter-spacing: 0.02em;
  max-width: 4.5rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.phono-regs,
.phono-places {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  min-width: 0;
  flex: 1;
}

.phono-reg {
  font-size: 0.6rem;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 999px;
  border: 1px solid color-mix(in srgb, var(--reg, var(--purple)) 45%, transparent);
  color: var(--reg, var(--purple));
  background: color-mix(in srgb, var(--reg, var(--purple)) 12%, transparent);
}

.phono-reg b {
  font-family: var(--mono);
  font-weight: 600;
  margin-left: 2px;
}

.phono-place {
  font-size: 0.58rem;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--muted);
  background: var(--bg-elev);
}

.phono-place:first-child {
  color: var(--accent-text);
  border-color: color-mix(in srgb, var(--accent) 40%, transparent);
  background: var(--accent-dim);
}

.phono-coach {
  margin-top: 6px;
  font-size: 0.68rem;
  color: var(--muted);
  line-height: 1.35;
}

.focus-phono {
  margin-top: 8px;
  padding-top: 6px;
  border-top: 1px solid var(--line-soft);
  font-size: 0.68rem;
  color: var(--muted);
  line-height: 1.4;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.focus-regs {
  font-family: var(--mono);
  font-size: 0.62rem;
  color: var(--purple);
  margin-top: 3px;
  overflow-wrap: anywhere;
}

/* Scholar linguistics (doctoral toolkit) */
.scholar-block {
  margin-top: 8px;
  border-top: 1px solid var(--line-soft);
  padding-top: 6px;
  max-width: 100%;
}

.scholar-summary {
  cursor: pointer;
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--blue);
  list-style: none;
}

.scholar-summary::-webkit-details-marker {
  display: none;
}

.scholar-body {
  margin-top: 8px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}

.scholar-sec {
  min-width: 0;
  max-width: 100%;
}

.scholar-p {
  margin: 2px 0;
  font-size: 0.72rem;
  color: var(--ink);
  line-height: 1.35;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.scholar-p.mono,
.scholar-p .mono {
  font-family: var(--mono);
  font-size: 0.65rem;
  color: var(--muted);
}

.scholar-p.muted {
  color: var(--muted);
  font-size: 0.65rem;
}

.scholar-pre {
  margin: 4px 0 0;
  padding: 8px;
  border-radius: 6px;
  background: var(--canvas-bg);
  border: 1px solid var(--line-soft);
  font-family: var(--mono);
  font-size: 0.62rem;
  line-height: 1.4;
  color: var(--muted);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
  max-height: 160px;
  overflow: auto;
  max-width: 100%;
}

.scholar-cite {
  margin-top: 4px;
  font-size: 0.68rem;
}

.scholar-cite summary {
  cursor: pointer;
  color: var(--accent-text);
  font-weight: 600;
}

.scholar-fw {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 4px;
}

.scholar-fw-chip {
  font-size: 0.55rem;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--muted);
  background: var(--bg-elev);
}

.scholar-check {
  margin: 4px 0 0;
  padding-left: 1.1rem;
  font-size: 0.65rem;
  color: var(--muted);
  line-height: 1.4;
}

.scholar-check li {
  margin: 2px 0;
  overflow-wrap: anywhere;
}

.focus-scholar {
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px solid var(--line-soft);
  font-size: 0.65rem;
  color: var(--muted);
  line-height: 1.35;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.focus-scholar .mono {
  font-family: var(--mono);
  font-size: 0.6rem;
}

.ergo-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
}

.ergo-cell {
  padding: 5px 6px;
  background: var(--panel-cell);
  border: 1px solid var(--line-soft);
  border-radius: 5px;
}

.ergo-l {
  font-size: 0.5rem;
  color: var(--faint);
  text-transform: uppercase;
}

.ergo-v {
  font-family: var(--mono);
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--ink);
}

.finger-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 3px;
}

.finger-cell {
  text-align: center;
  padding: 3px;
  background: var(--panel-cell);
  border: 1px solid var(--line-soft);
  border-radius: 4px;
}

.finger-name {
  font-size: 0.48rem;
  color: var(--muted);
}

.finger-n {
  font-family: var(--mono);
  font-size: 0.68rem;
  font-weight: 700;
}

.finger-bar {
  height: 3px;
  background: var(--line);
  border-radius: 2px;
  margin-top: 2px;
  overflow: hidden;
}

.finger-bar i {
  display: block;
  height: 100%;
  border-radius: 2px;
}

.health-risks {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.risk-chip {
  font-size: 0.58rem;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 999px;
  background: rgba(248, 81, 73, 0.12);
  color: #f85149;
  border: 1px solid rgba(248, 81, 73, 0.3);
}

.risk-chip.risk-ok {
  background: rgba(63, 185, 80, 0.12);
  color: var(--green);
  border-color: rgba(63, 185, 80, 0.3);
}

/* Per-card Contrails strip */
.ct-strip {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 6px;
  font-family: var(--mono);
  font-size: 0.62rem;
  color: var(--muted);
  padding: 4px 0 8px;
  max-width: 100%;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.ct-strip em {
  font-style: normal;
  color: var(--faint);
  font-size: 0.55rem;
  text-transform: uppercase;
  margin-right: 2px;
}

.ct-strip b {
  font-weight: 700;
  color: var(--ink);
}

.ct-strip b.good { color: var(--green); }
.ct-strip b.mid { color: var(--warn); }
.ct-strip b.low { color: var(--danger); }
.ct-strip b.cal { color: var(--pink); }
.ct-strip .sep { color: var(--faint); opacity: 0.5; }

.word-row--layouts-all {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 4px;
}

.layout-mini {
  font-size: 0.55rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--faint);
  background: var(--bg);
  border: 1px solid var(--line-soft);
  border-radius: 4px;
  padding: 2px 5px;
  font-family: var(--mono);
  display: inline-flex;
  gap: 4px;
  align-items: baseline;
}

.layout-mini i {
  font-style: normal;
  font-weight: 600;
  color: var(--blue);
  text-transform: none;
  font-size: 0.6rem;
}

.word-card.is-focused {
  outline: 1px solid rgba(249, 115, 22, 0.45);
  background: rgba(249, 115, 22, 0.04);
}

/* Letter sections (collapsed / expandable like large article chat) */
.letter-section {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg-elev);
  margin-bottom: 10px;
  overflow: hidden;
  scroll-margin-top: calc(var(--header-h) + 12px);
}

.writer-panel,
.geo-panel,
.list-toolbar,
.lang-section {
  scroll-margin-top: calc(var(--header-h) + 10px);
}

.letter-head {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  cursor: pointer;
  text-align: left;
}

.letter-head:hover {
  background: rgba(255, 255, 255, 0.02);
}

.letter-chevron {
  width: 0;
  height: 0;
  border-left: 5px solid var(--muted);
  border-top: 4px solid transparent;
  border-bottom: 4px solid transparent;
  transition: transform 0.15s;
}

.letter-section.is-open .letter-chevron {
  transform: rotate(90deg);
}

.letter-mark {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  flex-wrap: wrap;
  font-size: 1.15rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--accent);
  min-width: 1.4rem;
}

.letter-mark .letter-lang-tag {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--muted);
  opacity: 0.9;
}

.alpha-letter.is-swapped {
  font-size: 0.7rem;
  color: var(--ink);
}

.lang-alpha-glyph.is-offkb {
  opacity: 0.45;
}

.lang-alpha-bar[data-script]:not([data-script="Latin"]) .lang-alpha-glyph {
  font-size: 0.78rem;
  min-width: 1.6rem;
}

.letter-count {
  font-size: 0.72rem;
  color: var(--muted);
}

.letter-body {
  border-top: 1px solid var(--line-soft);
  padding: 4px 0;
}

.letter-empty,
.empty-state {
  margin: 0;
  padding: 16px;
  color: var(--muted);
  font-size: 0.85rem;
}

/* Word cards — dual row */
.word-card {
  padding: 10px 14px;
  border-bottom: 1px solid var(--line-soft);
  transition: background 0.15s;
}

.word-card:last-child {
  border-bottom: 0;
}

.word-card:hover {
  background: var(--bg-card-hover);
}

.word-card.is-flash {
  animation: flash 1.1s ease;
}

@keyframes flash {
  0%,
  100% {
    background: transparent;
  }
  20% {
    background: var(--accent-dim);
  }
}

.word-row {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.word-row--primary {
  margin-bottom: 8px;
  max-width: 100%;
  min-width: 0;
}

.word-label {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  min-width: 0;
  max-width: min(100%, 14rem);
  flex: 0 1 auto;
  overflow-wrap: anywhere;
  word-break: break-word;
  line-height: 1.25;
}

.layout-scroll {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 2px;
  scrollbar-width: thin;
  scrollbar-color: var(--line) transparent;
  min-width: 0;
  flex: 1 1 auto;
}

.layout-chip {
  flex: 0 0 auto;
  display: inline-flex;
  flex-direction: column;
  gap: 1px;
  padding: 4px 8px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: var(--bg);
  min-width: 4.2rem;
  max-width: 14rem;
}

.layout-chip em {
  font-style: normal;
  font-size: 0.55rem;
  font-weight: 700;
  color: var(--faint);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.layout-chip b {
  font-weight: 600;
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--blue);
  max-width: 12rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  display: block;
}

.word-row--secondary {
  flex-wrap: wrap;
  gap: 6px 10px;
  align-items: flex-start;
  max-width: 100%;
}

.meta-cell {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  max-width: 100%;
}

.meta-k {
  font-size: 0.55rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--faint);
}

.meta-v {
  font-size: 0.72rem;
  color: var(--muted);
  line-height: 1.3;
  overflow-wrap: anywhere;
  word-break: break-word;
  max-width: min(100%, 280px);
}

.meta-ddr .meta-v {
  color: var(--pink);
  font-size: 0.85rem;
  letter-spacing: 0.08em;
  font-weight: 600;
}

.meta-braille .meta-v,
.braille {
  color: var(--braille, var(--ink));
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  opacity: 1;
}
}

.meta-dance .meta-v {
  color: var(--pink);
  max-width: 200px;
}

.meta-music .meta-v,
.mono {
  font-family: var(--mono);
  color: #fbbf24;
  font-size: 0.68rem;
}

.flow-arrows {
  color: var(--cyan);
  letter-spacing: 0.06em;
  font-size: 0.85rem;
}

.flow-arrows small {
  color: var(--faint);
  font-size: 0.6rem;
  margin-left: 4px;
  letter-spacing: 0;
}

.metrics-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.pill {
  display: inline-block;
  font-family: var(--mono);
  font-size: 0.6rem;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--bg);
}

.pill.good {
  color: var(--green);
  border-color: rgba(63, 185, 80, 0.35);
}

.pill.mid {
  color: var(--warn);
  border-color: rgba(210, 153, 34, 0.35);
}

.pill.low {
  color: var(--danger);
  border-color: rgba(248, 81, 73, 0.35);
}

/* Footer */
.app-footer {
  max-width: 1100px;
  margin: 0 auto;
  padding: 8px 16px 28px;
  font-size: 0.68rem;
  color: var(--faint);
  border-top: 1px solid var(--line-soft);
}

.app-footer a {
  color: var(--muted);
}

@media (max-width: 900px) {
  .geo-panel {
    grid-template-columns: 1fr;
  }
  .geo-side {
    max-height: none;
  }
  .layout-select {
    max-width: 140px;
  }
}

@media (max-width: 720px) {
  .word-label {
    min-width: 100%;
  }
  .word-row--primary {
    flex-direction: column;
    align-items: flex-start;
  }
  .layout-scroll {
    width: 100%;
  }
  .search-row {
    flex-wrap: wrap;
  }
  .layout-select {
    max-width: none;
    flex: 1;
  }
}
