/* App layer for live-bangla, on top of lab.css tokens */
:root {
  --bn: "Noto Sans Bengali", "Schibsted Grotesk", system-ui, sans-serif;
  --tok-0: rgba(91, 184, 196, 0.2);
  --tok-1: rgba(242, 169, 59, 0.2);
  --tok-2: rgba(150, 160, 230, 0.22);
  --tok-3: rgba(108, 194, 138, 0.2);
  --tok-line: rgba(228, 236, 245, 0.18);
}
:root[data-theme="light"] {
  --tok-0: rgba(31, 127, 140, 0.14); --tok-1: rgba(168, 100, 0, 0.13);
  --tok-2: rgba(70, 80, 180, 0.12); --tok-3: rgba(47, 138, 81, 0.14); --tok-line: rgba(14, 26, 43, 0.16);
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --tok-0: rgba(31, 127, 140, 0.14); --tok-1: rgba(168, 100, 0, 0.13);
    --tok-2: rgba(70, 80, 180, 0.12); --tok-3: rgba(47, 138, 81, 0.14); --tok-line: rgba(14, 26, 43, 0.16);
  }
}

.skip { position: absolute; left: -999px; top: 8px; background: var(--amber); color: var(--amber-ink); padding: 8px 12px; border-radius: var(--r-s); z-index: 10; }
.skip:focus { left: 16px; }
.bn, [lang="bn"] { font-family: var(--bn); }
.muted { color: var(--muted); }
.hint { color: var(--muted); font-size: 0.85rem; margin: 8px 0 0; }

.intro { padding: 36px 0 22px; }
.intro h1 { max-width: 20ch; }
.views { margin-bottom: 18px; }
.tabpanel { display: grid; gap: 16px; }
.tabpanel[hidden] { display: none; }

.inputs { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); gap: 16px; }
.field-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }
.field-head > label, .en-label { font-weight: 600; }
.en-label { display: block; margin: 14px 0 8px; font-size: 0.9rem; }
.preset select { max-width: 100%; }
textarea { width: 100%; resize: vertical; line-height: 1.6; }
textarea.bn { font-size: 1.12rem; min-height: 6.5em; }
#preset { width: min(340px, 100%); }

.norm-panel { display: flex; flex-direction: column; gap: 12px; }
fieldset { border: 0; padding: 0; margin: 0; }
legend { font-weight: 600; margin-bottom: 6px; padding: 0; }
.radio, .check { display: flex; gap: 8px; align-items: baseline; padding: 3px 0; cursor: pointer; }
.norm-opts summary { cursor: pointer; color: var(--muted); font-size: 0.9rem; }
.opt-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 14px; margin-top: 10px; }
.opt-grid label:not(.check) { display: flex; flex-direction: column; gap: 4px; font-size: 0.84rem; color: var(--muted); }
.opt-grid select { font-size: 0.84rem; }
.norm-diff { margin: 0; font-size: 0.86rem; color: var(--muted); min-height: 1.3em; }
.norm-diff strong { color: var(--amber); font-weight: 600; }
.text-stats { grid-template-columns: repeat(3, 1fr); }
.text-stats .v { font-size: 1.1rem; }

/* Tokenizer picker: toggle buttons */
.picker { display: flex; flex-wrap: wrap; gap: 8px; }
.pick {
  display: inline-flex; align-items: baseline; gap: 8px; border: 1px solid var(--rule); background: transparent;
  color: var(--text); border-radius: 999px; padding: 6px 12px; font: 500 0.88rem var(--sans); cursor: pointer;
}
.pick .size { font: 400 0.72rem var(--mono); color: var(--muted); }
.pick[aria-pressed="true"] { background: var(--amber-soft); border-color: var(--amber); }
.pick[aria-busy="true"] .size::after { content: " loading"; }
.pick.err { border-color: var(--red); }

/* Live tax chart */
.tax-chart { position: relative; height: 260px; margin-bottom: 14px; }
.tax-table td:first-child { white-space: nowrap; }
.tax-table .bar-cost { font-weight: 600; }
td.na { color: var(--muted); }

/* Token strips */
.strips { display: grid; gap: 12px; }
.strip { background: var(--panel); border: 1px solid var(--rule); border-radius: var(--r-m); padding: 14px 16px; min-width: 0; }
.strip-head { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 6px 14px; align-items: baseline; margin-bottom: 10px; }
.strip-head h3 { margin: 0; }
.strip-head .meta { font: 500 0.78rem var(--mono); color: var(--muted); display: flex; gap: 14px; flex-wrap: wrap; }
.strip-head .meta b { color: var(--text); font-weight: 600; }
.tokens { display: flex; flex-wrap: wrap; gap: 3px; font-family: var(--bn); font-size: 1.08rem; line-height: 1.5; }
.tok {
  display: inline-flex; align-items: center; padding: 1px 4px; border-radius: 3px; border: 1px solid var(--tok-line);
  white-space: pre; min-height: 1.9em;
}
.tok.t0 { background: var(--tok-0); }
.tok.t1 { background: var(--tok-1); }
.tok.t2 { background: var(--tok-2); }
.tok.t3 { background: var(--tok-3); }
.tok.cut { border-left: 3px solid var(--red); }
.tok.frag { font: 500 0.72rem var(--mono); border-style: dashed; color: var(--muted); }
.tok .ws { color: var(--muted); font-family: var(--mono); font-size: 0.8em; }
.tok.nl { color: var(--muted); font: 0.8rem var(--mono); }
.tok:focus-visible { outline-offset: 1px; }
.tokens.en { font-family: var(--sans); font-size: 0.95rem; }
.strip details { margin-top: 10px; }
.strip summary { cursor: pointer; color: var(--muted); font-size: 0.86rem; }
.strip-err { color: var(--red); font-size: 0.9rem; margin: 0; }
.empty { color: var(--muted); padding: 18px; border: 1px dashed var(--rule); border-radius: var(--r-m); margin: 0; }

.legend h3 { margin-bottom: 8px; }
.legend ul { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; font-size: 0.9rem; }
.legend li { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.tok.sample { font-family: var(--bn); font-size: 0.95rem; }
.tok.sample.frag { font-family: var(--mono); }

/* Results */
.res-head { display: flex; justify-content: space-between; align-items: center; gap: 12px 24px; flex-wrap: wrap; }
.corpus-switch { display: flex; gap: 16px; flex-wrap: wrap; }
.res-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; }
.chart-box { position: relative; height: 300px; }
.chart-box.tall { height: 420px; }
#t-tok td, #t-tok th { white-space: nowrap; }
#t-tok td:first-child { font-weight: 500; }
.tag { font: 500 0.72rem var(--mono); padding: 1px 6px; border-radius: 3px; border: 1px solid var(--rule); }
.tag.live { color: var(--green); border-color: var(--green); }
.tag.mock { color: var(--muted); }
#t-gen td:last-child { font-family: var(--mono); font-size: 0.8rem; min-width: 280px; }

.about { margin-top: 28px; }
.about p { margin: 4px 0 0; max-width: 78ch; }
.about li { max-width: 78ch; }

@media (max-width: 860px) {
  .inputs, .res-grid { grid-template-columns: 1fr; }
  .chart-box.tall { height: 380px; }
}
@media (max-width: 480px) {
  .intro { padding: 24px 0 16px; }
  .opt-grid { grid-template-columns: 1fr; }
  .text-stats { grid-template-columns: repeat(3, 1fr); }
  .panel { padding: 14px; }
  .tax-chart { height: 300px; }
  .mast-src { display: none; }
}
