/* TGAplus V5.9.2 high-contrast interface themes. Signal-display drawing colours remain controlled by the renderers. */
:root,
:root[data-theme="mandarin"] {
  --bg: linear-gradient(135deg, #ead3ad 0%, #f6e7cf 42%, #e9c4b3 100%);
  --panel: #fffaf0;
  --ink: #241914;
  --muted: #6d5546;
  --line: #bf8f68;
  --soft: #efd9bd;
  --surface: #f8ead5;
  --control: #fffdf7;
  --accent: #aa3d25;
  --accent-2: #7f2b1f;
  --header-start: #1b1110;
  --header-end: #8b3227;
  --topbar-bg: rgba(33, 22, 18, .94);
  --topbar-title: #ffd9b0;
  --topbar-border: rgba(255, 230, 198, .28);
  --footer: #4c3428;
  --warn: #9a5c00;
  --error: #a12222;
  --ok: #176f4a;
  --primary-button-bg: #fff0ec;
  --primary-button-text: #7f2b1f;
  --primary-button-border: #aa3d25;
  --primary-button-hover: #ffe0d7;
  --shadow: 0 14px 34px rgba(76, 38, 22, 0.22);
  --tab-input-accent: #1f5f9a;
  --tab-input-tint: #eaf3ff;
  --tab-text-accent: #9a5a00;
  --tab-text-tint: #fff2d9;
  --tab-acoustic-accent: #087477;
  --tab-acoustic-tint: #e4f8f4;
  --tab-annotation-accent: #aa3d25;
  --tab-annotation-tint: #fff0ec;
  --tab-rfa-accent: #6b3fa0;
  --tab-rfa-tint: #f4edff;
  --tab-fdlp-accent: #5b21b6;
  --tab-fdlp-tint: #f5f0ff;
}

:root[data-theme="red-lacquer"] {
  --bg: linear-gradient(135deg, #4b0710 0%, #8f1d2a 36%, #f2d5c6 100%);
  --panel: #fff7f2;
  --ink: #2a1414;
  --muted: #78534d;
  --line: #c9867d;
  --soft: #f4d7d0;
  --surface: #fee9e2;
  --control: #fffdf9;
  --accent: #b91c2c;
  --accent-2: #7f1221;
  --header-start: #2b050a;
  --header-end: #a01827;
  --topbar-bg: rgba(43, 5, 10, .94);
  --topbar-title: #ffe3d2;
  --topbar-border: rgba(255, 226, 211, .32);
  --footer: #ffe3d2;
  --warn: #9a5c00;
  --error: #991b1b;
  --ok: #176b53;
  --primary-button-bg: #ffe9e4;
  --primary-button-text: #6f101c;
  --primary-button-border: #b91c2c;
  --primary-button-hover: #ffd5ce;
  --shadow: 0 16px 38px rgba(82, 10, 20, 0.28);
  --tab-input-accent: #9f1239;
  --tab-input-tint: #fff0f3;
  --tab-text-accent: #b45309;
  --tab-text-tint: #fff3dc;
  --tab-acoustic-accent: #0f766e;
  --tab-acoustic-tint: #e4f8f4;
  --tab-annotation-accent: #b91c2c;
  --tab-annotation-tint: #fff0f0;
  --tab-rfa-accent: #7c2d12;
  --tab-rfa-tint: #fff3e8;
}

:root[data-theme="scholarly"] {
  --bg: linear-gradient(135deg, #e6d7ba 0%, #f5edda 48%, #d9d2e8 100%);
  --panel: #fffaf0;
  --ink: #20233a;
  --muted: #5f6474;
  --line: #b8aa8c;
  --soft: #eadfc9;
  --surface: #f7efdf;
  --control: #fffdf8;
  --accent: #5a2e62;
  --accent-2: #334374;
  --header-start: #20233a;
  --header-end: #5a2e62;
  --topbar-bg: rgba(32, 35, 58, .94);
  --topbar-title: #fff0d0;
  --topbar-border: rgba(255, 240, 208, .28);
  --footer: #4c3f34;
  --warn: #9a6400;
  --error: #9b2b2b;
  --ok: #216d48;
  --primary-button-bg: #f7edf8;
  --primary-button-text: #3f2248;
  --primary-button-border: #7d3c75;
  --primary-button-hover: #efe0f2;
  --shadow: 0 14px 34px rgba(32, 35, 58, 0.18);
  --tab-input-accent: #314f86;
  --tab-input-tint: #eef4ff;
  --tab-text-accent: #8c5b05;
  --tab-text-tint: #fff4de;
  --tab-acoustic-accent: #216f73;
  --tab-acoustic-tint: #eaf7f6;
  --tab-annotation-accent: #7d3c75;
  --tab-annotation-tint: #f8ecf7;
  --tab-rfa-accent: #4c3b8f;
  --tab-rfa-tint: #f0eeff;
}

:root[data-theme="phonetics-lab"] {
  --bg: linear-gradient(135deg, #06101f 0%, #0b2340 48%, #123b58 100%);
  --panel: #f8fbff;
  --ink: #13263b;
  --muted: #52677c;
  --line: #93b4d4;
  --soft: #ddeeff;
  --surface: #edf6ff;
  --control: #ffffff;
  --accent: #0f86a5;
  --accent-2: #0b5f86;
  --header-start: #020712;
  --header-end: #0a3752;
  --topbar-bg: rgba(3, 11, 24, .94);
  --topbar-title: #facc15;
  --topbar-border: rgba(148, 212, 255, .32);
  --footer: #c7ddf0;
  --warn: #b77900;
  --error: #b42323;
  --ok: #14724c;
  --primary-button-bg: #e6faff;
  --primary-button-text: #06435f;
  --primary-button-border: #0891b2;
  --primary-button-hover: #d3f4fb;
  --shadow: 0 16px 38px rgba(0, 0, 0, 0.32);
  --tab-input-accent: #2563eb;
  --tab-input-tint: #eaf1ff;
  --tab-text-accent: #b77900;
  --tab-text-tint: #fff6d8;
  --tab-acoustic-accent: #0891b2;
  --tab-acoustic-tint: #e6faff;
  --tab-annotation-accent: #7c3aed;
  --tab-annotation-tint: #f3ecff;
  --tab-rfa-accent: #f59e0b;
  --tab-rfa-tint: #fff7e6;
}

:root[data-theme="soft-jade"] {
  --bg: linear-gradient(135deg, #d7eadc 0%, #edf7ee 45%, #cde4d7 100%);
  --panel: #fbfffb;
  --ink: #1e3129;
  --muted: #5e7169;
  --line: #9fc8ae;
  --soft: #dbeee2;
  --surface: #edf8f0;
  --control: #ffffff;
  --accent: #176b53;
  --accent-2: #0f4d3e;
  --header-start: #0e2e25;
  --header-end: #27755d;
  --topbar-bg: rgba(14, 46, 37, .94);
  --topbar-title: #d9ffe9;
  --topbar-border: rgba(215, 255, 233, .30);
  --footer: #244a3e;
  --warn: #946200;
  --error: #9e2f2f;
  --ok: #176b53;
  --primary-button-bg: #e4f8ed;
  --primary-button-text: #0f4d3e;
  --primary-button-border: #177e66;
  --primary-button-hover: #d4f0e1;
  --shadow: 0 14px 34px rgba(31, 73, 55, 0.20);
  --tab-input-accent: #2f6ca3;
  --tab-input-tint: #e9f4ff;
  --tab-text-accent: #8a6200;
  --tab-text-tint: #fff5d9;
  --tab-acoustic-accent: #177e66;
  --tab-acoustic-tint: #e4f8ed;
  --tab-annotation-accent: #7f4ca5;
  --tab-annotation-tint: #f5edfb;
  --tab-rfa-accent: #2f6f8f;
  --tab-rfa-tint: #e8f5ff;
}

:root[data-theme="neutral"] {
  --bg: #f7f4ef;
  --panel: #ffffff;
  --ink: #1f2933;
  --muted: #6b7280;
  --line: #d7dce2;
  --soft: #edf2f7;
  --surface: #f8fafc;
  --control: #ffffff;
  --accent: #315f72;
  --accent-2: #4a8297;
  --header-start: #173747;
  --header-end: #315f72;
  --topbar-bg: rgba(247,244,239,.95);
  --topbar-title: #315f72;
  --topbar-border: #d7dce2;
  --footer: #6b7280;
  --warn: #a86600;
  --error: #a12222;
  --ok: #19724a;
  --primary-button-bg: #edf6fa;
  --primary-button-text: #173747;
  --primary-button-border: #315f72;
  --primary-button-hover: #e0edf3;
  --shadow: 0 10px 25px rgba(31, 41, 51, 0.08);
  --tab-input-accent: #315f72;
  --tab-input-tint: #f8fafc;
  --tab-text-accent: #315f72;
  --tab-text-tint: #f8fafc;
  --tab-acoustic-accent: #315f72;
  --tab-acoustic-tint: #f8fafc;
  --tab-annotation-accent: #315f72;
  --tab-annotation-tint: #f8fafc;
  --tab-rfa-accent: #315f72;
  --tab-rfa-tint: #f8fafc;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--bg);
}
.app-header, .app-footer {
  padding: 1.2rem clamp(1rem, 4vw, 2.5rem);
}
.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  background: linear-gradient(135deg, var(--header-start), var(--header-end));
  color: white;
}
.app-header h1 { margin: 0 0 .3rem 0; font-size: clamp(1.5rem, 3vw, 2.2rem); }
.app-header p { margin: 0; opacity: .88; }
.header-status {
  padding: .45rem .7rem;
  border-radius: 999px;
  background: rgba(255,255,255,.15);
  white-space: nowrap;
}

/* Sticky navigation and revealable startup/status banner */
.startup-banner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 80;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 1.2rem clamp(1rem, 4vw, 2.5rem);
  background: linear-gradient(135deg, var(--header-start), var(--header-end));
  color: white;
  overflow: hidden;
  opacity: 1;
  transform: translateY(0);
  transition: opacity .28s ease, transform .28s ease;
  box-shadow: 0 18px 45px rgba(0,0,0,.20);
}
.startup-banner h1 { margin: 0 0 .3rem 0; font-size: clamp(1.5rem, 3vw, 2.2rem); }
.startup-banner p { margin: 0; opacity: .88; }
body.banner-collapsed .startup-banner {
  opacity: 0;
  transform: translateY(-110%);
  pointer-events: none;
}
.sticky-topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: .6rem;
  align-items: center;
  margin: 0 0 1rem;
  padding: .45rem .55rem;
  border: 1px solid var(--topbar-border, var(--line));
  border-radius: 18px;
  background: var(--topbar-bg);
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
}
.compact-title {
  white-space: nowrap;
  font-weight: 800;
  color: var(--topbar-title, var(--accent));
  padding: .35rem .5rem;
}
.sticky-topbar .tab-nav {
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}
.sticky-topbar .tab-nav label {
  padding: .45rem .68rem;
  font-size: .92rem;
}
.header-status.status-idle { background: #eef2f5; color: var(--muted); border-color: var(--line); }
.header-status.status-running { background: #eaf4f8; color: #244b5c; border-color: #b9d7e4; }
.header-status.status-finished { background: #e8f7ef; color: var(--ok); border-color: #b9e4ce; }
.header-status.status-failed { background: #fde8e8; color: var(--error); border-color: #f1b5b5; }
@media (max-width: 850px) {
  .sticky-topbar { grid-template-columns: 1fr; align-items: stretch; }
  .compact-title { text-align: center; }
  .header-status { justify-self: center; }
}
@media (prefers-reduced-motion: reduce) {
  .startup-banner { transition: none; }
}
.grid {
  padding: 1rem clamp(1rem, 4vw, 2.5rem) 2rem;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
  padding: 1rem;
  min-width: 0;
}
.card.wide { grid-column: 1 / -1; }
.card h2 { margin: 0 0 .7rem 0; font-size: 1.1rem; }
.card-head { display: flex; align-items: start; justify-content: space-between; gap: 1rem; }
.muted { color: var(--muted); margin: .2rem 0 .8rem; }
.button-row { display: flex; gap: .5rem; flex-wrap: wrap; margin: .7rem 0; }
.button-row.wrap { flex-wrap: wrap; }
button, select, input[type="number"] {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--control);
  color: var(--ink);
  padding: .55rem .75rem;
  font: inherit;
}
button {
  cursor: pointer;
  transition: transform .05s ease, background .15s ease, border-color .15s ease;
  background: var(--primary-button-bg, var(--control));
  color: var(--primary-button-text, var(--ink));
  border-color: var(--primary-button-border, var(--accent));
  font-weight: 700;
}
button:hover:enabled {
  background: var(--primary-button-hover, var(--soft));
  border-color: var(--primary-button-border, var(--accent));
}
button:active:enabled { transform: translateY(1px); }
button.primary {
  background: var(--primary-button-bg, var(--control));
  color: var(--primary-button-text, var(--ink));
  border-color: var(--primary-button-border, var(--accent));
  font-weight: 700;
}
button.primary:hover:enabled { background: var(--primary-button-hover, var(--soft)); }
button:disabled { opacity: .45; cursor: not-allowed; }
.inline-label { display: flex; align-items: center; gap: .5rem; white-space: nowrap; }
.status-list { display: grid; gap: .35rem; }
.status-item {
  display: flex;
  justify-content: space-between;
  gap: .7rem;
  border-bottom: 1px dashed var(--line);
  padding: .25rem 0;
}
.status-item span:first-child { color: var(--muted); }
.badge { display: inline-block; padding: .15rem .45rem; border-radius: 999px; background: var(--soft); }
.badge.ok { color: var(--ok); background: #e8f7ef; }
.badge.warn { color: var(--warn); background: #fff2d7; }
.badge.error { color: var(--error); background: #fde8e8; }
.meta-grid, .settings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: .5rem;
}
.meta-cell {
  padding: .55rem;
  background: var(--soft);
  border-radius: 12px;
}
.meta-cell strong { display: block; font-size: .82rem; color: var(--muted); font-weight: 600; }
.settings-grid label { display: grid; gap: .25rem; font-size: .9rem; }
.settings-grid input[type="range"] { width: 100%; }
.preview {
  white-space: pre-wrap;
  word-break: break-word;
  background: #111827;
  color: #e5e7eb;
  padding: .8rem;
  border-radius: 12px;
  min-height: 4rem;
  max-height: 16rem;
  overflow: auto;
}
.table-wrap { overflow: auto; max-height: 420px; border: 1px solid var(--line); border-radius: 12px; }
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th, td { padding: .45rem .55rem; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { position: sticky; top: 0; background: var(--soft); z-index: 1; }
.waveform-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: .75rem;
  flex-wrap: wrap;
  margin: .35rem 0 .65rem;
  padding: .55rem;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
}
.button-row.compact { margin: 0; gap: .4rem; }
.button-row.compact button { padding: .42rem .6rem; }
.playback-controls { border-left: 1px solid var(--line); padding-left: .55rem; }
.waveform-readouts {
  display: flex;
  gap: .75rem;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 1rem;
}
.waveform-readouts span {
  padding: .25rem .45rem;
  border-radius: 999px;
  background: var(--control);
  border: 1px solid var(--line);
}
.small-note { font-size: .88rem; margin-bottom: 0; }
.signal-panels { display: grid; gap: .8rem; }
.signal-panel { display: grid; gap: .35rem; }
.panel-caption { font-weight: 700; color: var(--ink); display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.panel-caption span { font-weight: 500; color: var(--muted); }
.signal-canvas { width: 100%; max-width: 100%; border-radius: 14px; border: 1px solid var(--line); background: #fbfdff; display: block; touch-action: none; cursor: crosshair; }
.waveform-canvas { height: 420px; }
.envelope-canvas { height: 420px; }
.derivative-canvas { height: 420px; }
.panel-purpose { margin: -.15rem 0 .15rem; color: var(--muted); font-size: .94rem; line-height: 1.35; }
.diagnostics { display: grid; gap: .45rem; }
.diag-row { padding: .55rem; border-radius: 12px; background: var(--soft); }
.diag-row.warning { background: #fff7e6; color: #7c4a00; }
.diag-row.error { background: #fee7e7; color: #8d1b1b; }
.diag-row.info { background: #eaf4f8; color: #244b5c; }
.app-footer { color: var(--footer, var(--muted)); }
@media (max-width: 850px) {
  .grid { grid-template-columns: 1fr; }
  .app-header { align-items: start; flex-direction: column; }
  .card-head { flex-direction: column; }
}

/* Finite State Phonology Card */
.fsa-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: .5rem;
  margin: .7rem 0;
}
.fsa-chip {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  padding: .55rem;
}
.fsa-chip strong {
  display: block;
  color: var(--muted);
  font-size: .78rem;
  font-weight: 600;
}
.fsa-chip span { font-weight: 700; }
.fsa-graph-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fbfdff;
  min-height: 280px;
  margin: .7rem 0;
}
.fsa-graph {
  width: 100%;
  min-width: 780px;
  min-height: 280px;
  display: block;
}
.fsa-arc {
  fill: none;
  stroke: #5b6b7a;
  stroke-width: 1.6;
  opacity: .8;
}
.fsa-arrow-head { fill: #5b6b7a; }
.fsa-arc-label {
  font-size: 13px;
  font-weight: 700;
  fill: #1f2933;
  paint-order: stroke;
  stroke: #fbfdff;
  stroke-width: 4px;
  stroke-linejoin: round;
  text-anchor: middle;
}
.fsa-state circle {
  fill: white;
  stroke: var(--accent);
  stroke-width: 2;
}
.fsa-state.final circle:first-child { stroke: var(--ok); }
.fsa-final-ring {
  fill: none !important;
  stroke: var(--ok) !important;
  stroke-width: 1.5 !important;
}
.fsa-state-label {
  text-anchor: middle;
  font-size: 13px;
  font-weight: 700;
  fill: var(--ink);
}
#fsaCard h3 {
  margin: 1rem 0 .5rem;
  font-size: 1rem;
}

/* Version 1.3 Alignment Card */
#alignmentCard h3 {
  margin: 1rem 0 .45rem;
  font-size: 1rem;
}
.alignment-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: .35rem .75rem;
  margin: .6rem 0;
}
.check-label {
  display: flex !important;
  grid-template-columns: none !important;
  align-items: center;
  gap: .5rem !important;
  padding: .45rem .55rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
}
.check-label input { margin: 0; }
#sdrTable td, #boundaryAdjustmentTable td {
  font-variant-numeric: tabular-nums;
}

/* AM envelope smoothing controls */
.am-control-panel {
  display: grid;
  gap: .55rem;
  padding: .75rem;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
}
.slider-row {
  display: grid;
  grid-template-columns: 220px minmax(160px, 1fr) 78px 135px;
  gap: .65rem;
  align-items: center;
}
.slider-row label {
  font-weight: 650;
  color: var(--ink);
}
.slider-row input[type="range"] {
  width: 100%;
}
.value-badge,
.helper-badge {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  min-height: 28px;
  padding: .18rem .45rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--control);
  font-size: .88rem;
  white-space: nowrap;
}
.helper-badge {
  color: var(--muted);
}
.filter-note {
  color: var(--muted);
  font-size: .88rem;
}
.stale-notice {
  padding: .5rem .6rem;
  border-radius: 12px;
  background: #fff7e6;
  color: #7c4a00;
  border: 1px solid #f2d38b;
  font-size: .92rem;
}
@media (max-width: 850px) {
  .slider-row {
    grid-template-columns: 1fr;
    gap: .35rem;
  }
  .value-badge,
  .helper-badge {
    justify-content: flex-start;
    width: fit-content;
  }
}

/* Version 1.4 manual boundary shifting */
.edit-controls {
  border-left: 1px solid var(--line);
  padding-left: .55rem;
}

/* Version 2.0 tabbed workflow */
.tab-shell {
  padding: .75rem clamp(1rem, 4vw, 2.5rem) 2rem;
}
.tab-radio {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}
.tab-nav {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
  margin: 0 0 1rem;
  padding: .55rem;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--panel);
  box-shadow: var(--shadow);
}
.tab-nav label {
  cursor: pointer;
  user-select: none;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: .6rem .85rem;
  background: var(--control);
  color: var(--muted);
  font-weight: 650;
}
#tabInput:checked ~ .sticky-topbar .tab-nav label[for="tabInput"] {
  background: var(--tab-input-accent);
  border-color: var(--tab-input-accent);
  color: white;
}
#tabText:checked ~ .sticky-topbar .tab-nav label[for="tabText"] {
  background: var(--tab-text-accent);
  border-color: var(--tab-text-accent);
  color: white;
}
#tabAcoustic:checked ~ .sticky-topbar .tab-nav label[for="tabAcoustic"] {
  background: var(--tab-acoustic-accent);
  border-color: var(--tab-acoustic-accent);
  color: white;
}
#tabAnnotation:checked ~ .sticky-topbar .tab-nav label[for="tabAnnotation"] {
  background: var(--tab-annotation-accent);
  border-color: var(--tab-annotation-accent);
  color: white;
}
#tabTga:checked ~ .sticky-topbar .tab-nav label[for="tabTga"],
#tabRfa:checked ~ .sticky-topbar .tab-nav label[for="tabRfa"],
#tabFdlp:checked ~ .sticky-topbar .tab-nav label[for="tabFdlp"] {
  background: var(--tab-rfa-accent);
  border-color: var(--tab-rfa-accent);
  color: white;
}
.tab-panel { display: none; }
#tabInput:checked ~ #panelInput,
#tabText:checked ~ #panelText,
#tabAcoustic:checked ~ #panelAcoustic,
#tabAnnotation:checked ~ #panelAnnotation,
#tabTga:checked ~ #panelTga,
#tabRfa:checked ~ #panelRfa,
#tabFdlp:checked ~ #panelFdlp,
#tabInfo:checked ~ #panelInfo {
  display: block;
}
.tab-panel .grid {
  padding: 0;
}

/* Version 2.1.8 stronger tab workspace accenting */
.tab-panel {
  --tab-accent: var(--accent);
  --tab-tint: var(--surface);
}
#panelInput { --tab-accent: var(--tab-input-accent); --tab-tint: var(--tab-input-tint); }
#panelText { --tab-accent: var(--tab-text-accent); --tab-tint: var(--tab-text-tint); }
#panelAcoustic { --tab-accent: var(--tab-acoustic-accent); --tab-tint: var(--tab-acoustic-tint); }
#panelAnnotation { --tab-accent: var(--tab-annotation-accent); --tab-tint: var(--tab-annotation-tint); }
#panelTga { --tab-accent: var(--tab-rfa-accent); --tab-tint: var(--tab-rfa-tint); }
#panelRfa { --tab-accent: var(--tab-rfa-accent); --tab-tint: var(--tab-rfa-tint); }
#panelFdlp { --tab-accent: var(--tab-fdlp-accent); --tab-tint: var(--tab-fdlp-tint); }
#panelInfo { --tab-accent: var(--accent); --tab-tint: var(--surface); }
.tab-panel .card {
  border-left: 5px solid var(--tab-accent);
  background: linear-gradient(180deg, var(--tab-tint) 0, var(--panel) 4.5rem, var(--panel) 100%);
}
.tab-panel .card h2 { color: var(--tab-accent); }
.tab-panel .card .card-head h2 { color: var(--tab-accent); }
.compact-waveform-canvas { height: 420px; }
.compact-envelope-canvas,
.compact-derivative-canvas { height: 420px; }
.plain-signal-panels .signal-canvas {
  cursor: default;
  touch-action: auto;
}
.plain-signal-panels .panel-purpose,
.annotation-signal-panels .panel-purpose {
  max-width: 90rem;
}
@media (max-width: 850px) {
  .tab-shell { padding: 1rem; }
  .tab-nav label { flex: 1 1 100%; text-align: center; }
}


/* Version 2.0.1 layout polish */
.settings-card-wide {
  grid-column: 1 / -1;
}
#settingsCard .settings-grid {
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: .75rem 1rem;
}
#settingsCard .settings-grid label {
  min-width: 0;
  padding: .55rem .6rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
}
#settingsCard .settings-grid label:not(.check-label) {
  grid-template-rows: auto auto;
}
#settingsCard .settings-grid select,
#settingsCard .settings-grid input[type="number"] {
  width: 100%;
}
#settingsCard .settings-grid input[type="range"] {
  width: 100%;
}
.zoom-controls-under-waveform {
  margin: .5rem 0 .2rem;
  padding: .5rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
}
@media (max-width: 850px) {
  #settingsCard .settings-grid {
    grid-template-columns: 1fr;
  }
}
.waveform-toolbar .playback-controls:first-child {
  border-left: 0;
  padding-left: 0;
}

/* Version 2.1 F0 estimation card */
.compact-f0-canvas { height: 520px; }
.f0-canvas { cursor: default; }
.f0-control-panel {
  display: grid;
  gap: .5rem;
  padding: .55rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  margin-top: .45rem;
}
.f0-number-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: .45rem .6rem;
}
.f0-number-grid label {
  display: grid;
  gap: .25rem;
  font-size: .86rem;
  font-weight: 650;
  color: var(--ink);
}
.f0-number-grid input[type="number"] { width: 100%; }
.f0-parameter-readout {
  margin-top: .45rem;
}
.f0-summary {
  margin-top: .45rem;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}
.f0-control-panel .slider-row {
  grid-template-columns: 180px minmax(160px, 1fr) 92px 92px;
}
@media (max-width: 850px) {
  .f0-control-panel .slider-row { grid-template-columns: 1fr; }
}

/* Version 2.1.3 compact F0 controls */
#f0Card .muted { margin-bottom: .45rem; }
#f0Card .filter-note { margin-top: .2rem; }
#f0Card .status-item { gap: .5rem; }


/* Version 2.1.11 theme selector */
.theme-control {
  display: grid;
  gap: .35rem;
  font-size: .9rem;
  font-weight: 650;
}
.theme-control select {
  width: 100%;
  max-width: 320px;
}
.theme-status {
  margin-top: .45rem;
}
#themeCard {
  border-color: color-mix(in srgb, var(--accent) 30%, var(--line));
}

/* Version 2.1.12 F0 auto-range control */
.f0-auto-range-control {
  align-items: flex-start;
  margin: 0;
}
.f0-auto-range-control small {
  display: block;
  color: var(--muted);
  font-weight: 500;
  margin-top: .12rem;
}

/* Version 2.1.12 F0 profile presets and auto-range readout */
.f0-preset-row {
  display: flex;
  align-items: center;
  gap: .45rem;
  flex-wrap: wrap;
}
.f0-preset-label {
  font-weight: 750;
  color: var(--ink);
  margin-right: .1rem;
}
.f0-preset-row button {
  padding: .42rem .65rem;
}
.f0-auto-range-control {
  flex-wrap: wrap;
}
.f0-auto-range-control > span:first-of-type {
  flex: 1 1 320px;
}
.f0-auto-range-estimate {
  justify-content: flex-start;
  min-width: 220px;
}


/* RFA tab styles */
.rfa-time-canvas { height: 420px; }
.fdlp-time-canvas { height: 420px; }
.rfa-spectrum-canvas { height: 520px; }
.fdlp-response-canvas { height: 520px; }
.rfa-spectrogram-canvas { height: 600px; }
.fdlp-map-canvas { height: 600px; }

.fdlp-sweep-canvas { height: 760px; }

.fdlp-band-grid { margin-top: .85rem; }
.rfa-settings-grid {
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: .75rem 1rem;
  margin-bottom: .8rem;
}
.rfa-settings-grid label,
.rfa-settings-grid .check-label {
  min-width: 0;
  padding: .55rem .6rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255,255,255,.58);
}
.rfa-settings-grid button { align-self: stretch; }
.rfa-readouts { margin: .55rem 0 .75rem; }
.rfa-summary { margin-top: .7rem; }
#panelRfa .signal-panel, #panelFdlp .signal-panel { margin-top: .75rem; }

/* RFA visibility and ranked ridge controls */
.rfa-ridge-control {
  min-width: 0;
  padding: .55rem .6rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255,255,255,.58);
  display: flex;
  flex-direction: column;
  gap: .45rem;
}
.rfa-ridge-control > span:first-child {
  font-weight: 700;
  color: var(--ink);
}
.rfa-ridge-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: .35rem;
}
.rfa-ridge-buttons button {
  padding: .35rem .52rem;
  min-width: 2.7rem;
}
.rfa-ridge-buttons button.active,
.rfa-ridge-buttons button[aria-pressed="true"],
.fdlp-ridge-buttons button.active,
.fdlp-ridge-buttons button[aria-pressed="true"] {
  background: var(--primary-button-border, var(--accent));
  color: #fff;
  border-color: var(--primary-button-border, var(--accent));
}

/* F0 interpolation and regression controls */
.f0-model-panel {
  display: grid;
  gap: .55rem;
  margin-top: .65rem;
  padding: .65rem;
  border: 1px dashed var(--line);
  border-radius: 12px;
  background: var(--surface);
}
.f0-model-panel h3 {
  margin: 0;
  color: var(--tab-accent, var(--accent));
}
.f0-model-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: .5rem .65rem;
}
.f0-model-grid label {
  display: grid;
  gap: .25rem;
  font-size: .86rem;
  font-weight: 650;
  color: var(--ink);
}
.f0-model-grid input,
.f0-model-grid select {
  width: 100%;
}
.f0-model-status {
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}


#tabFdlp:checked ~ .sticky-topbar .tab-nav label[for="tabFdlp"] {
  background: var(--tab-fdlp-accent);
  border-color: var(--tab-fdlp-accent);
  color: white;
}
#tabInfo:checked ~ .sticky-topbar .tab-nav label[for="tabInfo"] {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}
.fdlp-summary { margin-top: .7rem; }
.fdlp-readouts { margin: .55rem 0 .75rem; }

/* Version 5.9.2 Input / Output compact two-column layout */
.input-output-grid {
  grid-template-columns: minmax(0, 1.16fr) minmax(300px, .84fr);
  align-items: start;
}
.input-output-grid #projectCard { grid-column: 1; grid-row: 1 / span 2; }
.input-output-grid #audioCard { grid-column: 2; grid-row: 1; }
.input-output-grid #processingCard { grid-column: 2; grid-row: 2; }
.input-output-grid #outputCard { grid-column: 1; grid-row: 3; }
.input-output-grid #themeCard { grid-column: 2; grid-row: 3; }
.input-output-grid #audioCard,
.input-output-grid #processingCard {
  padding-block: .72rem;
}
.input-output-grid #audioCard h2,
.input-output-grid #processingCard h2 {
  margin-bottom: .45rem;
}
.input-output-grid #audioCard {
  align-self: start;
}
.input-output-grid #audioCard .meta-grid {
  gap: .28rem;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}
.input-output-grid #audioCard .meta-cell {
  padding: .32rem .4rem;
  min-width: 0;
  overflow-wrap: anywhere;
}
.input-output-grid #audioCard .meta-cell strong {
  font-size: .76rem;
}
.input-output-grid #processingCard {
  align-self: stretch;
}
.input-output-grid #processingCard .button-row,
.input-output-grid #processingCard .status-list {
  margin-block: .35rem;
}
.input-output-grid #processingCard .diagnostics-details {
  margin-top: .45rem;
  padding-top: .45rem;
}
.diagnostics-details {
  margin-top: .85rem;
  border-top: 1px solid var(--line);
  padding-top: .65rem;
}
.diagnostics-details summary {
  cursor: pointer;
  color: var(--muted);
  font-weight: 700;
}
.diagnostics-details[open] summary { margin-bottom: .55rem; }
@media (max-width: 760px) {
  .input-output-grid #projectCard,
  .input-output-grid #audioCard,
  .input-output-grid #processingCard,
  .input-output-grid #outputCard,
  .input-output-grid #themeCard {
    grid-column: 1 / -1;
    grid-row: auto;
  }
  .input-output-grid #audioCard .meta-grid {
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  }
}


.method-note { margin: .45rem 0 0; padding: .55rem .7rem; border-left: 4px solid var(--tab-accent, var(--accent)); background: color-mix(in srgb, var(--tab-tint, var(--surface)) 78%, white 22%); border-radius: 10px; font-size: .98rem; }

.file-choice-overlay {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  background: rgba(0, 0, 0, 0.35);
}

.file-choice-dialog {
  width: min(720px, 96vw);
  max-height: min(80vh, 760px);
  overflow: auto;
  padding: 1.25rem;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
}

.file-choice-dialog h3 {
  margin: 0 0 0.5rem;
}

.file-choice-list {
  display: grid;
  gap: 0.45rem;
  margin: 1rem 0;
}

.file-choice-option {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.65rem 0.75rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  cursor: pointer;
  word-break: break-word;
}

.file-choice-option:hover,
.file-choice-option:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(75, 127, 255, 0.16);
}

.file-choice-option input {
  flex: 0 0 auto;
}

.file-choice-buttons {
  justify-content: flex-end;
}


/* Version 4.0.21 Info/TextGrid/TGA tab and embedded HTML guide */
.info-tab-label {
  margin-left: auto;
}
.info-card {
  max-width: 1100px;
  margin-inline: auto;
}
.info-guide {
  font-size: 1rem;
  line-height: 1.6;
  color: var(--ink);
}
.info-guide h1 {
  margin-top: 0;
  color: var(--tab-accent);
  font-size: clamp(1.8rem, 3vw, 2.6rem);
}
.info-guide h2 {
  color: var(--tab-accent);
  font-size: clamp(1.3rem, 2vw, 1.8rem);
  margin-top: 1.8rem;
}
.info-guide h3 {
  color: var(--ink);
  font-size: 1.15rem;
  margin-top: 1.2rem;
}
.info-guide section {
  scroll-margin-top: 7rem;
}
.info-guide .info-toc {
  background: var(--tab-tint);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 1rem 1.25rem;
  margin: 1.25rem 0;
}
.info-guide .info-toc ol {
  columns: 2 18rem;
  gap: 2rem;
}
.info-guide a {
  color: var(--accent);
  font-weight: 650;
}
.info-guide code {
  background: var(--control);
  border: 1px solid var(--line);
  border-radius: .35rem;
  padding: .08rem .28rem;
}
.info-guide pre {
  background: var(--control);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 1rem;
  overflow: auto;
}
.info-guide dt {
  font-weight: 750;
  color: var(--ink);
  margin-top: .8rem;
}
.info-guide dd {
  margin-left: 1rem;
  color: var(--muted);
}


.textgrid-tier-controls {
  margin: 0.8rem 0;
  padding: 0.8rem 1rem;
  border: 1px solid var(--border, #d8e1e8);
  border-radius: 12px;
  background: rgba(255,255,255,0.55);
}
.textgrid-tier-controls .inline-label {
  display: inline-flex;
  gap: 0.6rem;
  align-items: center;
  font-weight: 700;
}
.textgrid-tier-controls select { min-width: 12rem; }

.duration-statistics-panel .panel-purpose { margin-bottom: .55rem; }
.duration-stats-wrap { max-height: none; overflow-x: auto; overflow-y: visible; }
.duration-stats-table { min-width: 1700px; font-size: .92rem; }
.duration-stats-table th,
.duration-stats-table td { white-space: nowrap; text-align: right; }
.duration-stats-table th:first-child,
.duration-stats-table td:first-child { text-align: left; position: sticky; left: 0; background: var(--soft); z-index: 2; }
.duration-stats-table thead th:first-child { z-index: 3; }

.annotation-top-statistics { margin: 1rem 0 1rem; }


/* V5 TGA tab */
.tga-control-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: .75rem;
  align-items: end;
  margin-top: .75rem;
}
.tga-control-grid label {
  display: grid;
  gap: .3rem;
  font-weight: 650;
  color: var(--ink);
}
.tga-control-grid input,
.tga-control-grid select { width: 100%; }
.tga-stats-wrap {
  max-height: none;
  overflow: visible;
}
.tga-table-wrap { max-height: 520px; }
.tga-comparison-stats.duration-stats-table {
  min-width: 0;
  width: 100%;
  table-layout: fixed;
  font-size: .82rem;
}
.tga-comparison-stats th,
.tga-comparison-stats td {
  padding: .28rem .32rem;
  white-space: normal;
  overflow-wrap: anywhere;
}
.tga-comparison-stats th.measure-col { min-width: 0; width: 32%; }
.tga-comparison-stats td.value-col { min-width: 0; width: 18%; text-align: right; }
.tga-comparison-stats td.unit-col { min-width: 0; width: 10%; color: var(--muted); }
.tga-comparison-stats thead th { white-space: normal; }
.text-output {
  white-space: pre-wrap;
  word-break: break-word;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: .75rem;
  padding: .9rem;
  min-height: 5rem;
}

/* Version 5.0.2 pasted TextGrid input dialog */
.textgrid-paste-dialog {
  width: min(900px, 96vw);
}
.textgrid-paste-textarea {
  display: block;
  width: 100%;
  min-height: min(48vh, 520px);
  margin: 1rem 0;
  padding: .8rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--control);
  color: var(--ink);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size: .92rem;
  line-height: 1.35;
  resize: vertical;
}
.textgrid-paste-textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent 78%);
}

/* V5.1.0 TGA Phase B display */
.tga-phase-panel {
  border: 1px solid var(--border, #d6d9df);
  border-radius: 12px;
  padding: 0.9rem 1rem;
  margin: 0.8rem 0 1rem;
  background: color-mix(in srgb, var(--card-bg, #fff) 92%, var(--accent, #2f6fed) 8%);
}
.tga-phase-panel h3 {
  margin: 0 0 0.55rem;
}
.tga-phase-panel dl {
  margin: 0;
  display: grid;
  gap: 0.4rem;
}
.tga-phase-panel dt {
  font-weight: 700;
}
.tga-phase-panel dd {
  margin: -0.25rem 0 0.3rem 1rem;
  color: var(--muted, #5f6673);
}
.tga-duration-display-wrap {
  overflow-x: auto;
}
.tga-duration-display {
  display: grid;
  gap: 0.45rem;
  min-width: 640px;
}
.tga-duration-row {
  display: grid;
  grid-template-columns: 4.5rem 1fr;
  align-items: center;
  gap: 0.75rem;
}
.tga-duration-group {
  font-weight: 700;
  text-align: right;
  color: var(--muted, #5f6673);
}
.tga-duration-group-button {
  border: 1px solid var(--line, #d6d9de);
  border-radius: 999px;
  background: var(--panel, #ffffff);
  color: var(--text, #1f2937);
  font-weight: 800;
  padding: 0.22rem 0.55rem;
  min-width: 3.1rem;
  cursor: pointer;
}
.tga-duration-group-button:hover:not(:disabled),
.tga-duration-group-button:focus-visible {
  border-color: var(--accent, #2f6fed);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent, #2f6fed) 18%, transparent);
}
.tga-duration-group-button.active {
  background: var(--accent, #2f6fed);
  border-color: var(--accent, #2f6fed);
  color: #fff;
}
.tga-duration-group-button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}
.tga-duration-bars {
  display: flex;
  align-items: flex-end;
  gap: 0.55rem;
  min-height: 8.5rem;
  padding: 0.55rem 0 0.35rem;
  border-bottom: 1px solid var(--line, #d6d9de);
}
.tga-duration-cell {
  display: inline-grid;
  grid-template-rows: 6.5rem 1.15rem 1.2rem;
  grid-template-columns: minmax(1.8rem, 2.6rem) auto;
  column-gap: 0.18rem;
  align-items: end;
  justify-items: center;
}
.tga-duration-bar-frame {
  grid-column: 1;
  grid-row: 1;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  width: 100%;
  height: 6.5rem;
}
.tga-duration-bar {
  display: block;
  width: 1.35rem;
  min-height: 0.25rem;
  border-radius: 0.35rem 0.35rem 0 0;
  background: var(--accent, #2f6fed);
  opacity: 0.76;
  box-shadow: inset 0 -1px 0 rgba(0, 0, 0, .12);
}
.tga-duration-label {
  grid-column: 1;
  align-self: start;
  max-width: 3.4rem;
  line-height: 1.05;
  text-align: center;
  overflow-wrap: anywhere;
  color: var(--muted, #5f6673);
}
.tga-duration-text-label {
  grid-row: 2;
  font-size: 0.74rem;
  font-weight: 700;
}
.tga-duration-ms-label {
  grid-row: 3;
  font-size: 0.82rem;
}
.tga-ddt-token {
  grid-row: 1 / span 3;
  grid-column: 2;
  align-self: center;
  min-width: 0.9rem;
  font-weight: 800;
  font-size: 1.05rem;
}

/* V5.2.0 TGA Phase C duration-pattern tables */
.tga-phase-c-wrap {
  max-height: 420px;
}
.tga-phase-c-table {
  width: 100%;
  min-width: 0;
  table-layout: fixed;
  font-size: 0.84rem;
}
.tga-phase-c-table th,
.tga-phase-c-table td {
  padding: 0.34rem 0.4rem;
  white-space: normal;
  overflow-wrap: anywhere;
  vertical-align: top;
}
.tga-phase-c-table .pattern-cell {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  letter-spacing: 0.02em;
}

/* V5.2.2 TGA Phase C D-Wiggliness / D-Spaciousness extension */
.tga-check-control {
  min-height: 3.2rem;
}
.tga-duration-shape-table {
  font-size: 0.82rem;
}
.tga-duration-shape-table th,
.tga-duration-shape-table td {
  padding: 0.3rem 0.35rem;
}

/* Version 5.2.3 Output exports grouping */
.export-results-group {
  border-top: 1px solid var(--line);
  padding-top: .75rem;
  margin-top: .35rem;
}
.export-results-group h3 {
  margin: 0 0 .35rem 0;
  font-size: .95rem;
  color: var(--muted);
}
.export-results-group .button-row {
  margin: .45rem 0;
}
.export-tga-buttons {
  padding-top: .35rem;
  border-top: 1px dashed var(--line);
}

/* Version 5.3.0 TGA Phase D structural visualisation */
.phase-d-display {
  overflow-x: auto;
  display: grid;
  gap: 0.8rem;
}
.phase-d-tree-group {
  border: 1px solid var(--line);
  border-radius: 0.8rem;
  padding: 0.7rem;
  background: color-mix(in srgb, var(--surface) 92%, var(--accent) 8%);
}
.phase-d-tree-group summary {
  cursor: pointer;
  font-weight: 750;
}
.phase-d-tree-pair {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 0.9rem;
  align-items: start;
}
.phase-d-tree-pair h4 {
  margin: 0.4rem 0 0.2rem;
  color: var(--muted);
}
.phase-d-tree-single {
  display: block;
  max-width: 860px;
  margin: 0 auto;
}
.phase-d-tree-single h4 {
  margin: 0.4rem 0 0.35rem;
  color: var(--muted);
  text-align: center;
}
.phase-d-tree-type-switch {
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  padding: 0.55rem 0.75rem;
  margin: 0.45rem 0 0.25rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: color-mix(in srgb, var(--surface) 94%, var(--accent) 6%);
}
.phase-d-control-label {
  font-weight: 800;
  color: var(--ink);
}
.time-tree-svg {
  width: 100%;
  max-width: 820px;
  aspect-ratio: 1 / 1;
  height: auto;
  display: block;
  margin: 0.2rem auto 0.6rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 0.9rem;
}
.wagner-svg,
.tone-duration-svg {
  width: 100%;
  max-width: 760px;
  height: auto;
  display: block;
  margin: 0.2rem auto 0.6rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 0.9rem;
}
.time-tree-edge {
  stroke: var(--muted);
  stroke-width: 1.7;
  opacity: 0.74;
}
.time-tree-node circle {
  fill: var(--card-bg, #fff);
  stroke: var(--accent);
  stroke-width: 2;
}
.time-tree-node.direction-highlight circle {
  fill: color-mix(in srgb, var(--muted) 28%, var(--card-bg, #fff) 72%);
}
.time-tree-label {
  font-size: 12px;
  font-weight: 700;
  fill: var(--ink);
}
.time-tree-sub,
.phase-d-small-label {
  font-size: 11px;
  fill: var(--muted);
}
.phase-d-svg-title,
.phase-d-axis-label {
  font-size: 13px;
  font-weight: 700;
  fill: var(--ink);
}
.wagner-plot-bg {
  fill: color-mix(in srgb, var(--surface) 95%, var(--accent) 5%);
  stroke: var(--line);
}
.wagner-zero-line,
.tone-axis {
  stroke: var(--ink);
  stroke-width: 1.2;
  opacity: 0.7;
}
.wagner-point {
  fill: var(--accent);
  fill-opacity: 0.72;
  stroke: var(--ink);
  stroke-width: 0.7;
}
.wagner-quadrant-label {
  font-size: 13px;
  font-weight: 800;
  fill: var(--muted);
}
.tone-grid {
  stroke: var(--line);
  stroke-width: 1;
  opacity: 0.7;
}
.tone-violin {
  fill: color-mix(in srgb, var(--accent) 30%, transparent 70%);
  stroke: var(--accent);
  stroke-width: 1.2;
  opacity: 0.86;
}
.tone-box {
  fill: color-mix(in srgb, var(--card-bg, #fff) 78%, var(--accent) 22%);
  stroke: var(--ink);
  stroke-width: 1.2;
  opacity: 0.94;
}
.tone-whisker,
.tone-median {
  stroke: var(--ink);
  stroke-width: 1.3;
}
.tone-median { stroke-width: 2; }
.tone-mean {
  fill: #d71920;
  stroke: #ffffff;
  stroke-width: 1.4;
}
.tone-point {
  fill: var(--ink);
  opacity: 0.34;
}

/* Version 5.3.3 TGA Time Tree span selection */
.phase-d-span-controls {
  border: 1px solid var(--line);
  border-radius: 0.9rem;
  padding: 0.75rem;
  margin: 0.75rem 0 0.9rem;
  background: color-mix(in srgb, var(--surface) 94%, var(--accent) 6%);
}
.phase-d-span-head h4 {
  margin: 0 0 0.25rem;
  color: var(--ink);
}
.phase-d-span-head p {
  margin-top: 0;
}
.phase-d-tg-button-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin: 0.55rem 0;
}
.phase-d-tg-button {
  min-width: 3.2rem;
  padding: 0.35rem 0.55rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--card-bg, #fff);
  color: var(--ink);
  cursor: pointer;
  font-weight: 700;
}
.phase-d-tg-button:hover,
.phase-d-tg-button:focus-visible {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 20%, transparent);
}
.phase-d-tg-button.selected-endpoint {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-contrast, #fff);
}
.phase-d-tg-button.selected-intermediate {
  background: color-mix(in srgb, var(--accent) 24%, var(--card-bg, #fff) 76%);
  border-color: var(--accent);
}
.phase-d-span-actions {
  align-items: center;
  margin-top: 0.55rem;
}
.inline-check {
  display: inline-flex;
  gap: 0.35rem;
  align-items: center;
  color: var(--ink);
  font-weight: 650;
}
.selected-span-tree,
.active-time-group-tree {
  margin-top: 0.25rem;
}

/* Version 5.3.3 TGA Time Tree direction highlighting */

/* Version 5.3.5 figure export controls */
.figure-export-toolbar {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 0.45rem;
  margin: 0.35rem 0 0.45rem;
}
.figure-export-button {
  font-size: 0.78rem;
  line-height: 1.2;
  padding: 0.32rem 0.55rem;
  border-radius: 999px;
}
.signal-panel > .figure-export-toolbar,
.fsa-graph-wrap > .figure-export-toolbar,
.phase-d-display + .figure-export-toolbar {
  margin-top: 0.2rem;
}


.input-or-separator {
  align-self: center;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 0.25rem;
  color: var(--text);
  font-weight: 800;
  letter-spacing: 0.04em;
}

.tga-mini-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 0.5rem;
  margin: 0.75rem 0;
}

.tga-mini-grid > div {
  border: 1px solid var(--border, #d0d7de);
  border-radius: 0.5rem;
  padding: 0.55rem 0.65rem;
  background: var(--surface-muted, #f8fafc);
}

.tree-similarity-table th,
.tree-similarity-table td {
  white-space: normal;
  vertical-align: top;
}

.tree-similarity-metrics strong {
  display: inline-block;
  margin-bottom: 0.2rem;
}

.input-secondary-row {
  margin-top: -0.2rem;
}

/* V5.4.5/V5.9.2 TextGrid/WAV compatibility popup */
.compatibility-info-row { margin-top: .65rem; justify-content: flex-end; }
.textgrid-wav-info-dialog { width: min(860px, 96vw); max-height: 92vh; overflow: auto; }
.compatibility-summary-compact {
  display: grid;
  gap: .6rem;
  margin: .65rem 0 .8rem;
}
.compatibility-summary-status {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: .45rem .8rem;
}
.compatibility-summary-columns {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: .7rem;
}
.compatibility-summary-panel {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: .55rem .65rem;
  min-width: 0;
  background: var(--panel, transparent);
}
.compatibility-summary-panel h4 {
  margin: 0 0 .35rem;
  font-size: .92rem;
  color: var(--tab-accent, var(--accent));
}
.compatibility-summary-list { margin: 0; gap: .18rem; }
.compatibility-summary-status .status-item,
.compatibility-summary-list .status-item {
  padding: .16rem 0;
  gap: .45rem;
}
.compatibility-tier-table-wrap { max-height: 34vh; overflow: auto; margin-top: .4rem; }
.compatibility-warning-list { margin: .4rem 0 .8rem 1.25rem; color: var(--warn-ink, var(--ink)); }
.compatibility-warning-list li { margin: .2rem 0; }
@media (max-width: 760px) {
  .compatibility-summary-status,
  .compatibility-summary-columns { grid-template-columns: 1fr; }
}

/* Version 5.5.0 security hardening controls */
.fsa-display-controls {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  align-items: center;
  gap: 0.65rem;
}
.checkbox-label {
  flex-direction: row !important;
  gap: 0.35rem;
  align-items: center;
}
.fsa-arc-tone-label {
  font-weight: 700;
}

/* Version 5.6.4 Pinyin phonemic-unit FSA graphs */
.fsa-gap-report { margin: .5rem 0 1rem; }
.fsa-gap-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: .5rem;
  margin: .45rem 0 .75rem;
}

/* V5.6.5/V5.6.7: constrained FSA uses lighter, smaller graph labels with wrapped finals blocks. */
.fsa-graph[data-fsa-mode="initial_final_constrained"] .fsa-arc-label,
.fsa-graph[data-fsa-mode="initial_final_constrained"] .fsa-state-label {
  font-size: 10px;
  font-weight: 400;
}

/* V5.6.7: constrained finals label blocks are anchored near the start of their transitions. */
.fsa-finals-label-block {
  text-anchor: start;
}

/* V5.6.11/V5.9.2 Text tab compact top-card layout */
.text-overview-card {
  grid-column: 1 / -1;
}
.text-card-layout {
  display: grid;
  grid-template-columns: minmax(260px, .95fr) minmax(320px, 1.05fr);
  gap: 1rem;
  align-items: start;
}
.text-card-description,
.text-card-extracted {
  min-width: 0;
}
.text-card-description .meta-grid {
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
}
.text-card-extracted {
  display: grid;
  gap: .55rem;
}
.text-card-extracted h3 {
  margin: 0;
  font-size: 1rem;
  color: var(--tab-accent, var(--accent));
}
.text-card-extracted .textgrid-tier-controls {
  margin: 0;
}
.text-extracted-preview {
  margin: 0;
  min-height: 9rem;
  max-height: 15rem;
}
@media (max-width: 850px) {
  .text-card-layout {
    grid-template-columns: 1fr;
  }
}

/* V5.9.2 lightweight accessibility alignment */
.sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

button:focus-visible,
select:focus-visible,
input:focus-visible,
textarea:focus-visible,
summary:focus-visible,
a:focus-visible,
.tab-nav label:focus-visible,
.file-choice-option:focus-within {
  outline: 3px solid color-mix(in srgb, var(--accent) 68%, white 32%);
  outline-offset: 3px;
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 18%, transparent);
}

.tab-nav label[role="tab"] {
  transition: background-color 120ms ease, border-color 120ms ease, color 120ms ease, box-shadow 120ms ease;
}

.tab-nav label[role="tab"][aria-selected="true"] {
  text-decoration: underline;
  text-underline-offset: 0.18em;
}

.signal-canvas[role="img"],
.fsa-graph[role="img"],
.phase-d-display[role="img"] {
  scroll-margin-top: 7rem;
}

.file-choice-dialog[role="dialog"] {
  outline: none;
}

.compatibility-warning-list li::marker {
  content: "Warning: ";
  font-weight: 700;
  color: var(--warn);
}

/* V5.9.2 automated Process card */
.process-status-list {
  margin-block: .35rem .55rem;
}
.process-status-item span:last-child {
  text-align: right;
}
.process-action-row {
  align-items: stretch;
}
.process-action-row button {
  flex: 1 1 190px;
  min-width: min(100%, 190px);
  white-space: normal;
  line-height: 1.2;
}
.process-action-row button:last-child {
  flex-basis: 260px;
}
@media (max-width: 720px) {
  .process-status-item { display: grid; gap: .2rem; }
  .process-status-item span:last-child { text-align: left; }
}

/* V5.9.2 Sound / Annotation separation */
.annotation-support-hidden {
  display: none !important;
}
.annotation-edit-mode-notice {
  margin: 0.75rem 0;
}
