* { box-sizing: border-box; }

/* Tamil text face: Anjal InaiMathi when the computer has it (InaiMathi ships with macOS).
   Everyone else gets Noto Sans Tamil, loaded from Google Fonts in index.html, so every PC
   shows a clean Tamil font; Nirmala UI / Latha (built into Windows) only if even that fails. */
@font-face {
  font-family: "CorpusTamil";
  src:
    local("Anjal InaiMathi"),
    local("Anjal Inaimathi"),
    local("AnjalInaiMathi"),
    local("InaiMathi"),
    local("InaiMathi-Regular");
  font-display: swap;
}

:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --text: #1f2937;
  --muted: #667085;
  --border: #e5e7eb;
  --soft: #f0f3f7;
  --dark: #111827;
  --tip: #111827;
}

body {
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
    "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
}

.tamil,
.learner-text,
.snippet,
.kwic-left,
.kwic-key,
.kwic-right,
#analyzeSearch,
#dialogTitle {
  font-family: "CorpusTamil", "Anjal InaiMathi", "Anjal Inaimathi", "InaiMathi",
    "Noto Sans Tamil", "Nirmala UI", "Latha", sans-serif;
}

.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 20px 24px 0;
  position: sticky;
  top: 0;
  z-index: 10;
}

.brandblock {
  max-width: 1180px;
  margin: 0 auto;
  display: flex;
  gap: 16px;
  align-items: center;
}

.brand {
  width: 54px;
  height: 54px;
  border-radius: 14px;
  background: var(--dark);
  color: white;
  display: grid;
  place-items: center;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: .08em;
}

h1 { margin: 0 0 4px; font-size: 24px; }
.topbar p { margin: 0; color: var(--muted); font-size: 14px; }

.mainnav {
  max-width: 1180px;
  margin: 18px auto 0;
  display: flex;
  gap: 4px;
}

.navbtn, .levelbtn, .toolbtn, .insightbtn {
  background: transparent;
  cursor: pointer;
}

.navbtn {
  border: 0;
  padding: 12px 14px;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  color: var(--muted);
}

.navbtn.active {
  color: var(--dark);
  border-bottom-color: var(--dark);
  font-weight: 700;
}

.container { max-width: 1180px; margin: 0 auto; padding: 26px 24px 60px; }
.page { display: none; }
.page.active { display: block; }

.pagehead { margin-bottom: 16px; }
.pagehead h2 { margin: 4px 0; font-size: 27px; }
.subtext { margin: 0; color: var(--muted); }
.eyebrow { font-size: 11px; font-weight: 800; letter-spacing: .12em; color: var(--muted); }

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 16px;
}

.card, .panel, .mini-stats > div {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
}

.card { padding: 18px; }
.card span, .mini-stats span {
  display: block;
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 8px;
}
.card strong { font-size: 30px; }

.centered-card {
  text-align: center;
}
.centered-card span,
.centered-card strong {
  text-align: center;
}

.panel { padding: 20px; margin-bottom: 16px; }
.panel h3 { margin-top: 0; }

.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

.metric-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  padding: 11px 0;
  border-top: 1px solid var(--border);
}
.metric-row:first-child { border-top: 0; }
.metric-row span:last-child { font-weight: 700; }

.workflow {
  display: grid;
  grid-template-columns: 1fr auto 1fr auto 1fr;
  gap: 18px;
  align-items: center;
}
.workflow div:not(.arrow) {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.workflow span { color: var(--muted); font-size: 13px; }
.arrow { color: var(--muted); font-size: 22px; }

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
.form-grid label {
  display: flex;
  flex-direction: column;
  gap: 7px;
  font-size: 13px;
  color: var(--muted);
}
.form-grid .full { grid-column: 1 / -1; }

input, select, button {
  font: inherit;
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 11px 12px;
  background: white;
}
button { cursor: pointer; }
button:hover { background: var(--soft); }

.pipeline {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
  margin: 20px 0;
}
.pipe-step {
  padding: 10px;
  border-radius: 9px;
  background: var(--soft);
  color: var(--muted);
  font-size: 13px;
  text-align: center;
}
.pipe-step.active { background: var(--dark); color: white; }

.upload-preview {
  padding: 18px;
  border: 1px dashed var(--border);
  border-radius: 10px;
}

.level-tabs, .tool-tabs {
  display: flex;
  gap: 7px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.levelbtn, .toolbtn, .insightbtn {
  border: 1px solid var(--border);
  padding: 8px 11px;
}

.levelbtn.active, .toolbtn.active, .insightbtn.active {
  background: var(--dark);
  border-color: var(--dark);
  color: white;
}

.tool-wrap {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  position: relative;
}

.info-btn {
  width: 22px;
  height: 22px;
  min-width: 22px;
  border-radius: 50%;
  border: 1px solid var(--border);
  padding: 0;
  display: inline-grid;
  place-items: center;
  font-size: 12px;
  font-weight: 800;
  color: var(--muted);
  background: white;
  cursor: help;
  position: relative;
}

.info-btn:hover,
.info-btn:focus {
  color: var(--dark);
  border-color: #98a2b3;
  background: white;
  outline: none;
}

.info-btn::after {
  content: attr(data-tip);
  position: absolute;
  z-index: 30;
  left: 50%;
  bottom: calc(100% + 10px);
  transform: translateX(-50%);
  width: 280px;
  max-width: 70vw;
  padding: 10px 12px;
  border-radius: 8px;
  background: var(--tip);
  color: white;
  font-weight: 400;
  font-size: 12px;
  line-height: 1.45;
  text-align: left;
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  transition: opacity .15s ease;
  box-shadow: 0 8px 24px rgba(0,0,0,.18);
}

.info-btn::before {
  content: "";
  position: absolute;
  z-index: 31;
  left: 50%;
  bottom: calc(100% + 4px);
  transform: translateX(-50%);
  border: 6px solid transparent;
  border-top-color: var(--tip);
  opacity: 0;
  visibility: hidden;
  transition: opacity .15s ease;
}

.info-btn:hover::after,
.info-btn:hover::before,
.info-btn:focus::after,
.info-btn:focus::before {
  opacity: 1;
  visibility: visible;
}

.mini-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 14px;
}
.mini-stats > div { padding: 14px; }
.mini-stats strong { font-size: 23px; }

.mode-banner {
  display: flex;
  gap: 8px;
  align-items: baseline;
  padding: 10px 12px;
  margin-bottom: 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fbfcfd;
}
.mode-banner span {
  color: var(--muted);
  font-size: 13px;
}

.searchbar {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  margin-bottom: 14px;
}

.term-summary {
  margin: 0 0 18px;
}
.term-summary:empty { display: none; }

.term-summary-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-bottom: 12px;
}
.term-stat {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
  background: #fbfcfd;
  text-align: center;
}
.term-stat span {
  display: block;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 4px;
}
.term-stat strong { font-size: 20px; }

.breakdown-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.breakdown-box {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
}
.breakdown-box h4 { margin: 0 0 8px; }
.breakdown-row {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 0;
  border-top: 1px solid var(--border);
}
.breakdown-row:first-of-type { border-top: 0; }

.result-item {
  border-top: 1px solid var(--border);
  padding: 15px 0;
}
.result-item:first-child { border-top: 0; }
.result-top { display: flex; justify-content: space-between; gap: 12px; }
.result-id { font-weight: 750; }

.meta-row { display: flex; gap: 7px; flex-wrap: wrap; margin: 8px 0 10px; }
.badge {
  background: var(--soft);
  border-radius: 999px;
  padding: 5px 9px;
  color: #475467;
  font-size: 12px;
}

.metadata-block {
  margin: 10px 0 18px;
  padding: 10px 12px;
  background: #fafafa;
  border: 1px solid var(--border);
  border-radius: 10px;
}
.metadata-block:empty { display: none; }

.snippet, .learner-text { font-size: 19px; line-height: 1.9; }

.kwic {
  display: grid;
  grid-template-columns: 1fr minmax(120px, auto) 1fr 125px;
  gap: 12px;
  border-top: 1px solid var(--border);
  padding: 11px 0;
  align-items: baseline;
  font-size: 17px;
}
.kwic-left { text-align: right; color: #475467; }
.kwic-key { text-align: center; font-weight: 800; }
.kwic-right { color: #475467; }
.kwic-meta { font-size: 12px; color: var(--muted); text-align: right; }

.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; min-width: 700px; }
.table th, .table td {
  border-bottom: 1px solid var(--border);
  padding: 10px 8px;
  text-align: left;
  vertical-align: top;
}
.table th { color: var(--muted); font-size: 12px; }

.annotation {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
  margin: 10px 0;
}

.bar-row {
  display: grid;
  grid-template-columns: 160px 1fr 55px;
  gap: 10px;
  align-items: center;
  margin: 10px 0;
}
.bar-track { height: 10px; background: var(--soft); border-radius: 99px; overflow: hidden; }
.bar-fill { height: 100%; background: var(--dark); }

.insight-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}
.insight-card {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 15px;
  text-align: center;
}
.insight-card span {
  display: block;
  color: var(--muted);
  font-size: 13px;
  text-align: center;
}
.insight-card strong {
  display: block;
  margin-top: 7px;
  font-size: 22px;
  text-align: center;
}

mark { background: #fff1a8; padding: 1px 2px; border-radius: 3px; }
.small { color: var(--muted); font-size: 13px; }
.empty { color: var(--muted); padding: 16px 0; }
.linkbtn { border: 0; padding: 0; background: transparent; text-decoration: underline; }

.require-search {
  text-align: center;
  padding: 30px 20px;
  border: 1px dashed var(--border);
  border-radius: 12px;
  background: #fbfcfd;
}
.require-search strong {
  display: block;
  margin-bottom: 6px;
}
.require-search span {
  color: var(--muted);
  font-size: 13px;
}

dialog {
  width: min(850px, 92vw);
  border: 0;
  border-radius: 14px;
  padding: 22px;
  box-shadow: 0 24px 70px rgba(0,0,0,.22);
}
dialog::backdrop { background: rgba(17,24,39,.45); }
.dialog-head { display: flex; justify-content: space-between; gap: 20px; }
.dialog-head h2 { margin: 2px 0 6px; }
.icon-button { border: 0; font-size: 28px; line-height: 1; padding: 2px 8px; }

@media (max-width: 850px) {
  .stats-grid, .two-col, .mini-stats, .insight-grid, .term-summary-grid, .breakdown-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .workflow { grid-template-columns: 1fr; }
  .arrow { transform: rotate(90deg); text-align: center; }
  .pipeline { grid-template-columns: 1fr; }
  .kwic { grid-template-columns: 1fr; gap: 3px; }
  .kwic-left, .kwic-key, .kwic-meta { text-align: left; }
}

@media (max-width: 560px) {
  .stats-grid, .two-col, .mini-stats, .insight-grid, .form-grid,
  .term-summary-grid, .breakdown-grid {
    grid-template-columns: 1fr;
  }
  .mainnav { overflow-x: auto; }
  .mode-banner { flex-direction: column; align-items: flex-start; }
}


/* Upload workflow v0.6 */
.pipeline button.pipe-step {
  border: 0;
}
.pipeline button.pipe-step:hover {
  background: var(--soft);
}
.pipeline button.pipe-step.active:hover {
  background: var(--dark);
}
.upload-step-panel { display: none; }
.upload-step-panel.active { display: block; }
.step-heading {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
}
.step-heading h3 { margin-bottom: 4px; }
.status-pill {
  display: inline-block;
  padding: 6px 9px;
  border-radius: 999px;
  background: var(--soft);
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}
.processing-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-top: 16px;
}
.processing-grid h4 { margin: 0 0 8px; }
.source-preview {
  min-height: 330px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fbfcfd;
  overflow: hidden;
  padding: 12px;
}
.source-preview img,
.source-preview iframe {
  width: 100%;
  height: 420px;
  object-fit: contain;
  border: 0;
  background: white;
}
.source-preview pre {
  margin: 0;
  white-space: pre-wrap;
  font: inherit;
}
.transcription-box {
  width: 100%;
  min-height: 360px;
  resize: vertical;
  font-size: 18px;
  line-height: 1.8;
}
.step-actions {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-top: 18px;
}
.step-actions.right { justify-content: flex-end; }
.wrap-actions { flex-wrap: wrap; }
.primary-btn {
  background: var(--dark);
  color: white;
  border-color: var(--dark);
}
.primary-btn:hover { background: #263041; }
.check-row {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-top: 10px;
  color: var(--text);
  font-size: 13px;
}
.check-row input { width: auto; }
.annotation-draft-list { margin-top: 14px; }
.annotation-draft-item {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  margin-top: 8px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
}
.annotation-draft-item button {
  border: 0;
  padding: 4px 7px;
  align-self: start;
}
.record-review-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-bottom: 16px;
}
.review-box {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 13px;
}
.review-box h4 { margin: 0 0 8px; }
.review-json {
  max-height: 360px;
  overflow: auto;
  padding: 12px;
  border-radius: 10px;
  background: #111827;
  color: #f9fafb;
  white-space: pre-wrap;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
}
@media (max-width: 850px) {
  .processing-grid, .record-review-grid { grid-template-columns: 1fr; }
}


/* Transcription Review v0.7 */
.hidden { display: none !important; }
.recognition-import {
  display: grid;
  gap: 7px;
  font-size: 13px;
  font-weight: 600;
}
.recognition-status {
  margin-top: 10px;
  padding: 11px 12px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: #fbfcfd;
}
.recognition-status.loaded { background: #eef7f0; }
.machine-fallback { margin-top: 12px; }
.machine-fallback summary { cursor: pointer; font-size: 13px; color: var(--muted); }
.transcription-box.compact { min-height: 170px; margin-top: 10px; }
.transcription-review-layout {
  display: grid;
  grid-template-columns: minmax(320px, 0.9fr) minmax(0, 1.25fr);
  gap: 18px;
  margin-top: 16px;
  align-items: start;
}
.review-source-column { min-width: 0; }
.sticky-preview { position: sticky; top: 92px; }
.review-legend {
  margin-top: 10px;
  display: grid;
  gap: 5px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 9px;
  font-size: 12px;
  background: white;
}
.review-legend small { color: var(--muted); margin-top: 3px; }
.review-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
  position: sticky;
  top: 88px;
  z-index: 3;
  background: var(--bg, #fff);
  padding: 8px 0;
}
.line-review-list { display: grid; gap: 11px; }
.line-review-card {
  border: 1px solid var(--border);
  border-radius: 11px;
  padding: 13px;
  background: white;
}
.line-review-card.confirmed { border-color: #94c5a0; background: #fbfffc; }
.line-review-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
  margin-bottom: 9px;
}
.line-review-head > div:first-child { display: flex; gap: 7px; align-items: center; flex-wrap: wrap; }
.review-signals { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; font-size: 11px; color: var(--muted); }
.confidence-chip, .priority-chip {
  display: inline-block;
  border-radius: 999px;
  padding: 3px 7px;
  font-size: 10px;
  border: 1px solid var(--border);
}
.band-super_low { background: #fde8e8; border-color: #e9aaaa; }
.band-low { background: #fff0d3; border-color: #e7c680; }
.band-normal { background: #eef3f8; }
.band-high { background: #eaf5ed; border-color: #a9d0b2; }
.priority-high { background: #fde8e8; border-color: #e9aaaa; }
.priority-medium { background: #fff0d3; border-color: #e7c680; }
.priority-normal { background: #eef3f8; }
.line-flags { display: flex; gap: 5px; flex-wrap: wrap; margin-bottom: 8px; }
.line-flags span { background: #fff7dd; border-radius: 999px; padding: 2px 6px; font-size: 10px; }
.line-review-card label { display: block; font-size: 12px; font-weight: 600; margin: 8px 0 5px; }
.raw-transcription {
  padding: 9px 10px;
  border-radius: 8px;
  background: #f6f7f9;
  font-size: 17px;
  line-height: 1.65;
}
.line-verified {
  width: 100%;
  min-height: 82px;
  resize: vertical;
  font-size: 17px;
  line-height: 1.6;
}
.line-review-options {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 18px;
  margin-top: 8px;
}
.line-review-options label { display: flex; align-items: center; gap: 6px; margin: 0; font-weight: 400; }
.line-review-options input { width: auto; }
@media (max-width: 980px) {
  .transcription-review-layout { grid-template-columns: 1fr; }
  .sticky-preview, .review-toolbar { position: static; }
}

/* v0.8 automatic OCR service */
.ocr-progress {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 12px 0;
  padding: 12px;
  border: 1px solid #d9d9d9;
  border-radius: 8px;
  background: #fafafa;
}
.ocr-progress.hidden { display: none; }
.ocr-spinner {
  width: 20px;
  height: 20px;
  border: 3px solid #ddd;
  border-top-color: #555;
  border-radius: 50%;
  animation: ocr-spin .8s linear infinite;
  flex: 0 0 auto;
}
@keyframes ocr-spin { to { transform: rotate(360deg); } }
.recognition-status.processing { background: #eef5ff; border-color: #bdd2f3; }
.recognition-status.error { background: #fff1f0; border-color: #efb5b1; color: #8b2722; }
button:disabled { opacity: .55; cursor: not-allowed; }


/* v0.9 — Sarvam + Google Vision review */
.google-transcription {
  background: #f7f9fc;
  border: 1px solid #d9e1ee;
  border-radius: 8px;
  padding: 10px 12px;
  margin-top: 6px;
}
.google-transcription.disagree {
  border-color: #d59b25;
  background: #fff8e8;
}
.model-disagree {
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 2px;
}


/* v0.10 — page-by-page OCR with real progress */
.ocr-progress {
  display: block;
}
.ocr-progress-head {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 12px;
}
.ocr-progress-count {
  font-weight: 700;
  white-space: nowrap;
}
.ocr-progress-track {
  width: 100%;
  height: 10px;
  margin: 12px 0 10px;
  border-radius: 999px;
  background: #e5e7eb;
  overflow: hidden;
}
.ocr-progress-fill {
  height: 100%;
  width: 0;
  background: currentColor;
  opacity: .72;
  border-radius: inherit;
  transition: width .25s ease;
}
.ocr-page-status-list {
  display: grid;
  gap: 6px;
  max-height: 260px;
  overflow: auto;
  margin-top: 8px;
}
.ocr-page-row {
  display: grid;
  grid-template-columns: 12px auto 1fr auto;
  align-items: center;
  gap: 8px;
  padding: 7px 8px;
  border: 1px solid #e4e4e4;
  border-radius: 7px;
  background: #fff;
  font-size: 13px;
}
.ocr-page-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #b9b9b9;
}
.ocr-page-row.status-processing .ocr-page-dot { background: #5677a8; }
.ocr-page-row.status-ready .ocr-page-dot { background: #4d8c5c; }
.ocr-page-row.status-failed .ocr-page-dot { background: #b34b43; }
.ocr-page-row.status-ready { border-color: #bcd8c2; }
.ocr-page-row.status-failed { border-color: #efb5b1; background: #fff7f6; }
.ocr-page-retry {
  padding: 4px 8px;
  font-size: 12px;
}
.ocr-progress-note {
  margin-top: 9px;
}
.ocr-spinner.hidden { display: none; }

@media (max-width: 700px) {
  .ocr-progress-head {
    grid-template-columns: auto 1fr;
  }
  .ocr-progress-count {
    grid-column: 2;
  }
  .ocr-page-row {
    grid-template-columns: 12px auto 1fr;
  }
  .ocr-page-retry {
    grid-column: 2 / 4;
    justify-self: start;
  }
}


/* =========================================================
   v0.11 — focused page review
   ========================================================= */
.review-page-nav {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}
.review-nav-spacer { flex: 1; }
.review-page-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(340px, .9fr);
  gap: 18px;
  align-items: start;
}
.review-page-viewport {
  height: min(72vh, 820px);
  overflow: auto;
  border: 1px solid #d9dde5;
  border-radius: 10px;
  background: #eef1f5;
}
.review-page-stage {
  position: relative;
  margin: 0 auto;
  transition: width .15s ease;
}
.review-image-wrap {
  position: relative;
  width: 100%;
}
.review-image-wrap > img {
  display: block;
  width: 100%;
  height: auto;
}
.review-overlay {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}
.review-region {
  fill: rgba(48, 91, 147, .06);
  stroke: rgba(48, 91, 147, .32);
  stroke-width: 2;
  vector-effect: non-scaling-stroke;
  cursor: pointer;
}
.review-region:hover {
  fill: rgba(48, 91, 147, .15);
  stroke: rgba(48, 91, 147, .65);
}
.review-region.active {
  fill: rgba(221, 156, 31, .22);
  stroke: rgba(182, 113, 0, .95);
  stroke-width: 4;
}
.review-region.status-confirmed { fill: rgba(45, 130, 73, .06); }
.review-region.status-ignored { fill: rgba(120, 120, 120, .05); stroke-dasharray: 5 4; }
.review-help { margin-top: 8px; }

.active-review-card {
  border: 1px solid #d9dde5;
  border-radius: 10px;
  padding: 14px;
  background: #fff;
}
.active-review-head,
.candidate-head,
.chart-title-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
}
.ocr-choice-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 14px 0;
}
.ocr-choice-grid.one-choice { grid-template-columns: 1fr; }
.ocr-choice {
  text-align: left;
  padding: 12px;
  min-height: 76px;
  border: 1px solid #cfd6e2;
  border-radius: 9px;
  background: #f8fafc;
}
.ocr-choice:hover { border-color: #8193ad; }
.choice-label {
  display: block;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .05em;
  margin-bottom: 7px;
  opacity: .65;
}
.review-correction-label { display: block; }
.review-correction {
  width: 100%;
  min-height: 88px;
  margin-top: 6px;
  resize: vertical;
}
.review-action-row {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}
.review-item-details {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid #eee;
  font-size: 12px;
  line-height: 1.6;
}
.text-button {
  border: 0;
  background: transparent;
  text-decoration: underline;
  padding: 4px;
}
.page-review-heading {
  display: flex;
  justify-content: space-between;
  margin: 18px 0 8px;
}
.page-review-queue {
  display: grid;
  gap: 6px;
  max-height: 300px;
  overflow: auto;
}
.page-review-item {
  display: grid;
  grid-template-columns: 28px 1fr auto;
  gap: 8px;
  align-items: center;
  text-align: left;
  padding: 8px 10px;
  border: 1px solid #e1e4e8;
  background: #fff;
  border-radius: 7px;
}
.page-review-item.active { border-color: #9a6a1b; box-shadow: 0 0 0 1px #9a6a1b inset; }
.page-review-item.status-confirmed { background: #f3faf5; }
.page-review-item.status-ignored { opacity: .65; text-decoration: line-through; }

/* =========================================================
   v0.11 — annotation candidates
   ========================================================= */
.annotation-source-panel {
  margin-bottom: 14px;
}
.annotation-source-text {
  width: 100%;
  min-height: 170px;
  margin-top: 6px;
}
.annotation-ai-toolbar {
  display: flex;
  gap: 12px;
  align-items: center;
  margin: 14px 0;
  flex-wrap: wrap;
}
.error-candidate-list {
  display: grid;
  gap: 10px;
}
.error-candidate {
  border: 1px solid #d9dde5;
  border-radius: 9px;
  padding: 12px;
  background: #fff;
}
.error-candidate.resolved { opacity: .68; }
.agreement-chip {
  display: inline-block;
  margin-left: 8px;
  padding: 2px 7px;
  border-radius: 999px;
  background: #e8f5eb;
  font-size: 11px;
}
.candidate-meta {
  display: grid;
  grid-template-columns: 190px 1fr;
  gap: 10px;
  margin-top: 10px;
}
.candidate-meta label {
  display: grid;
  gap: 4px;
  font-size: 12px;
}
.candidate-note { margin-top: 8px; }
.candidate-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
  flex-wrap: wrap;
}
.manual-annotation-panel {
  margin-top: 16px;
  padding: 12px;
  border: 1px solid #e1e4e8;
  border-radius: 9px;
}

/* =========================================================
   v0.11 — illustrative Insights charts
   ========================================================= */
.insight-chart-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 18px;
  margin-top: 20px;
}
.insight-chart-card {
  border: 1px solid #e1e4e8;
  border-radius: 10px;
  padding: 12px;
  background: #fff;
}
.insight-chart-card h3 { margin: 0 0 4px; }
.insight-svg-chart {
  display: block;
  width: 100%;
  height: auto;
  margin-top: 8px;
  overflow: visible;
}
.chart-track-svg { fill: rgba(110, 120, 135, .12); }
.chart-bar-svg { fill: currentColor; opacity: .65; }
.chart-line { stroke: currentColor; stroke-width: 3; }
.chart-point { fill: currentColor; }
.chart-axis { stroke: rgba(110, 120, 135, .35); stroke-width: 1; }
.chart-label { font-size: 13px; fill: currentColor; opacity: .78; }
.chart-value { font-size: 12px; fill: currentColor; font-weight: 700; }

@media (max-width: 900px) {
  .review-page-grid { grid-template-columns: 1fr; }
  .review-page-viewport { height: 58vh; }
}
@media (max-width: 620px) {
  .ocr-choice-grid,
  .candidate-meta { grid-template-columns: 1fr; }
}


/* =========================================================
   v0.11.2 — local autosave / resume
   ========================================================= */
.draft-save-tools {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.draft-save-status {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 4px 9px;
  border-radius: 999px;
  border: 1px solid #d9dde5;
  background: #f7f8fa;
  font-size: 12px;
  white-space: nowrap;
}
.draft-save-status.saved {
  background: #f1f8f3;
  border-color: #bed8c5;
}
.draft-save-status.saving {
  background: #fff8e8;
  border-color: #e4cf9b;
}
.draft-save-status.error {
  background: #fff1f0;
  border-color: #e0b5b2;
}
.draft-save-status.muted {
  opacity: .75;
}
.draft-resume-panel {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  padding: 13px 14px;
  margin-bottom: 16px;
  border: 1px solid #bfd0e5;
  border-radius: 10px;
  background: #f6f9fd;
}
.draft-resume-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  flex: 0 0 auto;
}
.draft-local-note {
  opacity: .72;
}
@media (max-width: 720px) {
  .draft-save-tools {
    justify-content: flex-start;
    margin-top: 8px;
  }
  .draft-resume-panel {
    align-items: flex-start;
    flex-direction: column;
  }
}


/* v0.11.3.1 — error engine diagnostics */
.engine-diagnostics {
  margin: -4px 0 12px;
}
.engine-diagnostics details {
  border: 1px solid #e1e4e8;
  border-radius: 8px;
  padding: 8px 10px;
  background: #fafbfc;
}
.engine-diagnostics pre {
  white-space: pre-wrap;
  word-break: break-word;
  margin: 8px 0 0;
  font-size: 11px;
}


/* v0.11.4 — multi-layer annotation evidence */
.candidate-evidence {
  margin-top: 9px;
  padding: 7px 9px;
  border-radius: 7px;
  background: rgba(110, 120, 135, .07);
}
.candidate-evidence summary {
  cursor: pointer;
  font-size: 12px;
}
.evidence-row {
  padding-top: 5px;
}

/* =========================================================
   v0.12 — Wide workspace, Stage 3 three-panel review,
   Stage 4 annotation workspace.
   Colour system: four Tamil error groups + one neutral for
   (dashed = pending, fill = accepted, strike = rejected).
   ========================================================= */
:root {
  --g-ezhuthu: #b7791f;   --g-ezhuthu-bg: #fdf3dc;
  --g-sol: #2f6aa8;       --g-sol-bg: #e5eefa;
  --g-ilakkanam: #b04a5a; --g-ilakkanam-bg: #f9e6e9;
  --g-nadai: #2f7d58;     --g-nadai-bg: #e2f3ea;
  --st-open: #d48a0c;     --st-open-bg: #fff1d6;
  --st-ok: #6b7280;
  --panel-h: max(520px, calc(100vh - 150px));
}

/* ---- 1. genuinely wide workspace (the real container is .container / .brandblock / .mainnav) ---- */
body.wide-workspace .container { max-width: none; width: 100%; padding: 18px clamp(12px, 1.4vw, 28px) 40px; }
body.wide-workspace .brandblock,
body.wide-workspace .mainnav { max-width: none; padding: 0 clamp(0px, 0.4vw, 8px); }
body.wide-workspace .upload-step-panel { padding: 16px clamp(12px, 1vw, 20px); }
body.wide-workspace .pipeline { margin: 12px 0 14px; }
body.wide-workspace .pagehead { margin-bottom: 6px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
body.wide-workspace .pagehead .eyebrow,
body.wide-workspace .pagehead .subtext { display: none; }
body.wide-workspace .pagehead h2 { font-size: 18px; margin: 0; }
body.wide-workspace .topbar { position: static; padding-top: 10px; }
body.wide-workspace .brand { width: 40px; height: 40px; border-radius: 11px; }
body.wide-workspace h1 { font-size: 19px; }
body.wide-workspace .mainnav { margin-top: 6px; }
body.wide-workspace .pipe-step { padding-top: 7px; padding-bottom: 7px; }
body.wide-workspace .step-heading .subtext { font-size: 13px; }

/* small segmented control */
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 9px; overflow: hidden; background: #fff; }
.seg button { border: 0; border-radius: 0; padding: 6px 10px; font-size: 13px; color: var(--muted); background: transparent; }
.seg button + button { border-left: 1px solid var(--border); }
.seg button.active { background: var(--dark); color: #fff; }
.seg button span { opacity: .75; margin-left: 3px; font-size: 12px; }
.small-seg button { font-size: 12px; padding: 5px 8px; }
.check-row.inline { display: inline-flex; margin: 0; align-items: center; gap: 6px; }
.check-row.inline input { padding: 0; }
kbd { font: 11px/1 ui-monospace, monospace; border: 1px solid var(--border); border-bottom-width: 2px; border-radius: 4px; padding: 1px 4px; background: #fff; }

/* ---- 2. Stage 3 layout: 40 / 38 / 22 ---- */
.s3-bar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 10px; }
.s3-bar-nav, .s3-bar-tools { display: flex; align-items: center; gap: 6px; }
.s3-bar button { padding: 7px 11px; }
.s3-summary { flex: 1; text-align: center; color: var(--muted); }
.s3-grid {
  display: grid;
  grid-template-columns: minmax(0, 40fr) minmax(0, 38fr) minmax(280px, 22fr);
  gap: 12px;
  align-items: stretch;
}
.s3-panel {
  display: flex; flex-direction: column; min-width: 0;
  height: var(--panel-h);
  border: 1px solid #dde3ea; border-radius: 12px; background: #fff; overflow: hidden;
}
.s3-panel-head { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-bottom: 1px solid var(--border); background: #fafbfc; }
.s3-panel-head strong { font-size: 13px; letter-spacing: .02em; }
.s3-panel-head .small { margin-left: auto; color: var(--muted); }
.s3-panel-head .text-button { margin-left: auto; }
.s3-panel-foot { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 6px 12px; border-top: 1px solid var(--border); background: #fafbfc; }
.s3-scan .review-page-viewport { height: auto; flex: 1; border: 0; border-radius: 0; }

/* scan overlay states */
.review-region.clear { fill: rgba(107, 114, 128, .03); stroke: rgba(107, 114, 128, .22); }
.review-region.needs-review { fill: rgba(212, 138, 12, .10); stroke: rgba(212, 138, 12, .75); }
.review-region.excluded { fill: rgba(120, 120, 120, .10); stroke: rgba(120, 120, 120, .45); stroke-dasharray: 5 4; }
.review-region.active { fill: rgba(47, 106, 168, .12); stroke: rgba(47, 106, 168, .95); stroke-width: 3; }
.review-word-box { fill: none; stroke: #d48a0c; stroke-width: 3; vector-effect: non-scaling-stroke; pointer-events: none;
  animation: s3pulse 1.4s ease-in-out 2; }
@keyframes s3pulse { 50% { stroke-width: 6; } }

/* ---- 3. live transcript ---- */
.s3-meta { padding: 6px 12px; color: var(--muted); border-bottom: 1px solid #f0f2f5; }
.s3-transcript { flex: 1; overflow: auto; padding: 10px 14px 18px; font-size: 17px; line-height: 1.95; }
.t-page + .t-page { margin-top: 14px; border-top: 1px dashed var(--border); padding-top: 10px; }
.t-page-head { display: flex; justify-content: space-between; align-items: baseline; font-size: 12px; color: var(--muted); font-family: system-ui, sans-serif; margin-bottom: 2px; }
.t-page-head strong { color: var(--text); }
.t-page.status-reviewed .t-page-status { color: var(--g-nadai); }
.t-page.status-in_progress .t-page-status { color: var(--st-open); }
.t-page-body.muted { color: #8a93a3; }
.t-empty { color: var(--muted); font-style: italic; font-size: 14px; }
.t-line { padding: 0 6px; margin: 0 -6px; border-radius: 6px; cursor: pointer; white-space: pre-wrap; }
.t-line:hover { background: #f5f7fa; }
.t-line.active { background: #eef4fb; box-shadow: inset 3px 0 0 var(--g-sol); }
.t-line.excluded { color: #9aa1ad; text-decoration: line-through; font-size: 14px; }
mark.t-issue { background: transparent; color: inherit; border-radius: 3px; padding: 0 1px; cursor: pointer; }
mark.t-issue.open { background: var(--st-open-bg); box-shadow: inset 0 -2px 0 var(--st-open); }
mark.t-issue.resolved { box-shadow: inset 0 -1px 0 rgba(107, 114, 128, .35); }
mark.t-issue.resolved.corrected { box-shadow: inset 0 -2px 0 rgba(107, 114, 128, .7); background: #f3f4f6; }
mark.t-issue.active { outline: 2px solid var(--g-sol); outline-offset: 1px; }
.s3-legend mark { font-size: 12px; padding: 0 4px; }

/* ---- 4. compact review rail ---- */
.s3-rail { flex: 1; overflow: auto; padding: 8px; font-size: 14px; }
.rail-head { display: flex; flex-direction: column; gap: 2px; padding: 4px 4px 8px; }
.rail-head strong { font-size: 12px; letter-spacing: .08em; }
.rail-head .small { color: var(--muted); }
.rail-item { border: 1px solid var(--border); border-radius: 9px; padding: 7px 9px; margin-bottom: 6px; background: #fff; cursor: pointer; }
.rail-item:hover { border-color: #c9d2de; }
.rail-item.active { border-color: var(--g-sol); box-shadow: 0 0 0 2px rgba(47, 106, 168, .12); cursor: default; }
.rail-item.excluded { opacity: .6; }
.rail-item-head { display: flex; align-items: baseline; gap: 7px; }
.rail-num { font-size: 11px; color: var(--muted); min-width: 14px; }
.rail-span { font-weight: 600; overflow-wrap: anywhere; }
.rail-kind { font-size: 12px; color: var(--st-open); margin: 1px 0 5px 21px; }
.rail-context { font-size: 14px; line-height: 1.7; background: #fafbfc; border-radius: 6px; padding: 4px 7px; margin: 4px 0 6px; }
.rail-context mark { background: var(--st-open-bg); box-shadow: inset 0 -2px 0 var(--st-open); }
.rail-options { display: grid; gap: 4px; margin-bottom: 6px; }
.rail-option { display: flex; gap: 6px; align-items: baseline; font-size: 14px; }
.rail-option-key { font: 700 11px system-ui; color: #fff; background: var(--st-ok); border-radius: 4px; padding: 1px 5px; }
.rail-actions { display: flex; flex-wrap: wrap; gap: 5px; }
.rail-btn { padding: 4px 9px; font-size: 13px; border-radius: 7px; }
.rail-btn.subtle { border-color: transparent; color: var(--muted); }
.rail-edit { margin-bottom: 6px; }
.rail-edit input { width: 100%; padding: 6px 8px; margin-bottom: 4px; }
.rail-hint { color: var(--muted); margin-bottom: 5px; line-height: 1.35; }
.rail-item.resolved { padding: 4px 9px; background: #fafbfc; }
.rail-item.resolved .rail-span { font-weight: 400; text-decoration: line-through; color: var(--muted); }
.rail-status { font-size: 12px; margin-left: auto; color: var(--st-ok); }
.rail-status.open { color: var(--st-open); }
.rail-item.resolved .text-button { font-size: 12px; }
.rail-snippet { font-size: 14px; color: var(--text); margin: 2px 0 0 21px; }
.rail-line-edit { width: 100%; font-size: 15px; padding: 6px 8px; margin: 5px 0; border: 1px solid var(--border); border-radius: 7px; }
.rail-done { margin: 6px 2px 10px; padding: 9px 10px; border-radius: 9px; background: var(--g-nadai-bg); color: #1f5c40; font-size: 13px; }
.rail-done .rail-btn { margin-left: 6px; }
.rail-resolved summary { cursor: pointer; font-size: 12px; color: var(--muted); padding: 4px; }
.rail-foot { color: var(--muted); padding: 10px 4px 2px; line-height: 1.8; }

/* ---- Stage 4 ---- */
.s4-toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.s4-grid { display: grid; grid-template-columns: minmax(0, 64fr) minmax(320px, 36fr); gap: 12px; margin-top: 12px; }
.s4-textcol { position: relative; min-width: 0; }
.s4-textpair { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.s4-textbox { border: 1px solid #dde3ea; border-radius: 12px; background: #fff; display: flex; flex-direction: column; height: var(--panel-h); overflow: hidden; }
.s4-textbox header { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 12px; border-bottom: 1px solid var(--border); background: #fafbfc; font-size: 13px; }
.s4-body { flex: 1; overflow: auto; padding: 12px 14px; font-size: 17px; line-height: 2; white-space: pre-wrap; }
#s4Original { user-select: text; cursor: text; }
.s4-legend { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0 10px; align-items: center; }
.s4-legend .lg { padding: 1px 7px; border-radius: 5px; }
.lg-sep { width: 12px; }
.lg.g-ezhuthu { background: var(--g-ezhuthu-bg); color: var(--g-ezhuthu); }
.lg.g-sol { background: var(--g-sol-bg); color: var(--g-sol); }
.lg.g-ilakkanam { background: var(--g-ilakkanam-bg); color: var(--g-ilakkanam); }
.lg.g-nadai { background: var(--g-nadai-bg); color: var(--g-nadai); }
.lg.s-pending { border: 1px dashed var(--st-ok); color: var(--st-ok); }
.lg.s-accepted { background: #e5e7eb; color: var(--text); }

mark.a-mark { background: transparent; color: inherit; border-radius: 3px; padding: 0 1px; cursor: pointer; --c: var(--st-ok); --bg: #eee; }
mark.a-mark.g-ezhuthu { --c: var(--g-ezhuthu); --bg: var(--g-ezhuthu-bg); }
mark.a-mark.g-sol { --c: var(--g-sol); --bg: var(--g-sol-bg); }
mark.a-mark.g-ilakkanam { --c: var(--g-ilakkanam); --bg: var(--g-ilakkanam-bg); }
mark.a-mark.g-nadai { --c: var(--g-nadai); --bg: var(--g-nadai-bg); }
mark.a-mark.s-pending { box-shadow: inset 0 -2px 0 var(--c); background-image: linear-gradient(transparent 60%, color-mix(in srgb, var(--bg) 70%, transparent) 60%); }
mark.a-mark.s-accepted { background: var(--bg); box-shadow: inset 0 -2px 0 var(--c); }
mark.a-mark.active { outline: 2px solid var(--c); outline-offset: 1px; }
mark.a-mark.corrected.s-pending { opacity: .75; }

.s4-seltools { position: absolute; z-index: 5; display: flex; gap: 6px; align-items: center; background: #fff; border: 1px solid #cfd6df; border-radius: 10px; padding: 6px; box-shadow: 0 6px 18px rgba(17, 24, 39, .12); }
.s4-seltools button { padding: 5px 10px; font-size: 13px; }
.s4-sel-text { max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; color: var(--muted); }

.s4-cardcol { display: flex; flex-direction: column; min-width: 0; height: calc(var(--panel-h) + 34px); }
.s4-filters { align-self: flex-start; margin-bottom: 8px; }
.s4-cards { flex: 1; overflow: auto; padding-right: 2px; }
.a-card { --c: var(--st-ok); border: 1px solid var(--border); border-left: 4px solid var(--c); border-radius: 10px; padding: 8px 10px; margin-bottom: 7px; background: #fff; cursor: pointer; }
.a-card.g-ezhuthu { --c: var(--g-ezhuthu); }
.a-card.g-sol { --c: var(--g-sol); }
.a-card.g-ilakkanam { --c: var(--g-ilakkanam); }
.a-card.g-nadai { --c: var(--g-nadai); }
.a-card.active { box-shadow: 0 0 0 2px color-mix(in srgb, var(--c) 25%, transparent); cursor: default; }
.a-card.s-rejected { opacity: .6; }
.a-card.s-rejected .a-orig { text-decoration: line-through; }
.a-card-head { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; }
.a-num { font-size: 11px; color: var(--muted); }
.a-orig { font-weight: 700; font-size: 16px; }
.a-arrow { color: var(--muted); }
.a-sugg { flex: 1; min-width: 110px; padding: 4px 8px; font-size: 15px; }
.a-status { margin-left: auto; font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.a-card.s-accepted .a-status { color: var(--c); font-weight: 700; }
.a-card-meta { display: flex; align-items: center; gap: 6px; margin: 6px 0 4px; }
.a-card-meta select { flex: 1; min-width: 0; padding: 5px 8px; font-size: 13px; }
.a-group-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--c); flex: none; }
.a-prov { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; margin-bottom: 5px; }
.a-chip { font-size: 11px; border: 1px solid var(--border); border-radius: 99px; padding: 0 7px; color: var(--muted); }
.a-chip.agree { border-color: var(--g-nadai); color: var(--g-nadai); }
.a-chip.warn { border-color: var(--st-open); color: var(--st-open); }
.a-occ { margin-left: 4px; }
.a-note { color: var(--muted); margin: 2px 0 5px; }
.a-note-edit input { width: 100%; padding: 5px 8px; margin: 2px 0 6px; }
.a-evidence { margin: 2px 0 6px; }
.a-evidence summary { cursor: pointer; font-size: 12px; color: var(--muted); }
.a-evidence-row { padding: 3px 0 3px 8px; border-left: 2px solid var(--border); margin: 3px 0; }
.a-evidence-note { color: var(--muted); }
.a-actions { display: flex; flex-wrap: wrap; gap: 5px; align-items: center; }
.a-actions button { padding: 4px 10px; font-size: 13px; border-radius: 7px; }
.a-reject-group { display: inline-flex; }
.a-reject-group button:first-child { border-top-right-radius: 0; border-bottom-right-radius: 0; }
.a-reject-group button + button { border-left: 0; border-top-left-radius: 0; border-bottom-left-radius: 0; }

/* ---- responsive ---- */
@media (max-width: 1280px) {
  .s3-grid { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .s3-rail-col { grid-column: 1 / -1; height: auto; max-height: 60vh; }
  .s4-grid { grid-template-columns: 1fr; }
  .s4-cardcol { height: auto; }
}
@media (max-width: 820px) {
  .s3-grid, .s4-textpair { grid-template-columns: 1fr; }
  .s3-panel { height: 70vh; }
  .s4-textbox { height: auto; max-height: 60vh; }
}

/* zoom controls live inside the scan pane */
.s3-zoom { display: inline-flex; gap: 4px; }
.s3-zoom button { padding: 3px 9px; font-size: 13px; border-radius: 7px; }
.s3-scan .s3-panel-head .small { margin-left: auto; }
/* tag reliability chips */
.a-chip.tag-high { border-color: var(--g-nadai); color: var(--g-nadai); }
.a-chip.tag-medium { border-color: #9aa3b2; color: #4b5563; }
.a-chip.tag-low { border-color: var(--st-open); color: var(--st-open); }

/* crossed-out words (learner self-corrections): hidden from the transcript, shown on request */
s.t-struck { color: #9aa1ad; text-decoration: line-through; text-decoration-thickness: 2px; font-size: .92em; cursor: pointer; }
.review-word-box.struck { stroke: #6b7280; stroke-dasharray: 6 4; }


/* =========================================================
   v0.14 — review rail choices, transcript editor, upload page, save screen
   ========================================================= */
.rail-choices { display: grid; grid-template-columns: minmax(0, 1fr); gap: 5px; margin: 2px 0 7px; }
.rail-choice { min-width: 0; box-sizing: border-box; display: flex; align-items: center; gap: 7px; width: 100%; text-align: left; padding: 6px 8px;
  border-radius: 8px; font-size: 14px; background: #fff; }
.rail-choice:hover { border-color: var(--g-sol); background: #f5f9fd; }
.rail-choice-text { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.rail-item { min-width: 0; overflow: hidden; }
.rail-choice-src { font-size: 11px; color: var(--muted); }
.rail-type { cursor: text; border-style: dashed; }
.rail-type:focus-within { border-style: solid; border-color: var(--g-sol); box-shadow: 0 0 0 2px rgba(47,106,168,.12); }
.rail-type input { flex: 1; min-width: 0; width: 100%; border: 0; padding: 2px 0; background: transparent; outline: none; font-size: 14px; }

.t-edit-tools { color: var(--muted); margin: 0 0 8px; line-height: 1.5; }
.t-edit-row { display: grid; grid-template-columns: 22px 1fr auto; gap: 6px; align-items: start; margin-bottom: 4px; }
.t-edit-row.active textarea { border-color: var(--g-sol); box-shadow: 0 0 0 2px rgba(47,106,168,.12); }
.t-edit-row.excluded textarea { color: #9aa1ad; text-decoration: line-through; background: #fafbfc; }
.t-edit-num { font-size: 11px; color: var(--muted); padding-top: 9px; text-align: right; }
.t-edit-line, .t-edit-page { width: 100%; font-size: 16px; line-height: 1.7; border: 1px solid var(--border);
  border-radius: 7px; padding: 4px 8px; resize: none; overflow: hidden; }
.t-edit-page { min-height: 55vh; resize: vertical; overflow: auto; }
.t-edit-actions { display: flex; gap: 8px; margin-top: 8px; }

.req { color: #b04a5a; font-weight: 700; }
.muted { color: var(--muted); }
.u1-grid { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 22px; align-items: start; }
.u1-section { border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px; margin-bottom: 14px; background: #fff; }
.u1-section h4 { margin: 0 0 10px; font-size: 14px; }
.u1-three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.u1-drop { position: relative; display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 26px 16px;
  border: 1.5px dashed #c9d2de; border-radius: 12px; background: #fafbfc; cursor: pointer; text-align: center; }
.u1-drop:hover, .u1-drop.over { border-color: var(--g-sol); background: #f5f9fd; }
.u1-drop.has-file { border-style: solid; border-color: var(--g-nadai); background: var(--g-nadai-bg); }
.u1-drop input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.u1-drop-icon { font-size: 22px; color: var(--muted); }
.u1-drop-main { font-weight: 600; overflow-wrap: anywhere; }
.u1-drop-sub { color: var(--muted); }
.u1-id { display: flex; flex-direction: column; gap: 7px; font-size: 13px; color: var(--muted); margin-top: 14px; }
.u1-id-row { display: flex; gap: 8px; align-items: center; }
.u1-id-row input { flex: 1; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .02em; color: var(--text); }
.u1-optional summary { cursor: pointer; }
.u1-optional[open] summary { margin-bottom: 12px; }
.info-inline { display: inline-grid; place-items: center; width: 15px; height: 15px; border-radius: 50%; background: var(--soft);
  color: var(--muted); font-size: 10px; font-weight: 700; cursor: help; }
.u1-consent { align-items: flex-start; gap: 9px; padding: 12px 14px; border: 1px solid var(--border); border-radius: 12px; background: #fff; line-height: 1.5; }
.u1-consent input { margin-top: 4px; }
.u1-consent .small { display: block; margin-top: 2px; }
.field-error { display: block; color: #b04a5a; font-size: 12px; min-height: 0; }
.field-error:empty { display: none; }
[data-field].invalid select, [data-field].invalid input:not([type=checkbox]) { border-color: #b04a5a; background: #fdf6f7; }
.u1-drop.invalid, .u1-consent.invalid { border-color: #b04a5a; }
#uploadPreview { margin-top: 14px; }
.u1-guide { position: sticky; top: 16px; border-radius: 12px; background: var(--soft); padding: 16px 18px; font-size: 13px; line-height: 1.55; }
.u1-guide h4 { margin: 0 0 8px; font-size: 14px; }
.u1-guide ol { margin: 0; padding-left: 18px; display: grid; gap: 8px; }
.u1-guide code, .record-meta code, .saved-where code { font-size: 12px; background: #fff; border-radius: 4px; padding: 1px 5px; }
.u1-guide-foot { margin-top: 12px; padding-top: 10px; border-top: 1px solid #dfe3ea; color: var(--muted); line-height: 1.7; }
@media (max-width: 980px) { .u1-grid { grid-template-columns: 1fr; } .u1-guide { position: static; } .u1-three { grid-template-columns: 1fr; } }

.lg-title { font-weight: 600; color: var(--muted); margin-right: 2px; }
.s4-stale { display: flex; gap: 12px; align-items: center; justify-content: space-between; padding: 10px 14px; margin: 6px 0 10px;
  border-radius: 10px; background: var(--st-open-bg); color: #6b4a06; font-size: 13px; line-height: 1.5; }
.s4-stale button { flex: none; }
.a-card.stale { opacity: .6; }
.a-stale { color: #6b4a06; background: var(--st-open-bg); border-radius: 6px; padding: 3px 7px; margin-bottom: 6px; }

.record-checks { list-style: none; margin: 0; padding: 0; display: grid; gap: 7px; font-size: 14px; }
.record-checks li { display: flex; gap: 9px; align-items: baseline; }
.record-checks li span { display: inline-grid; place-items: center; flex: none; width: 18px; height: 18px; border-radius: 50%;
  font-size: 11px; font-weight: 700; color: #fff; background: var(--g-nadai); }
.record-checks li.warn span { background: var(--st-open); }
.record-checks li.warn { color: #6b4a06; }
.record-groups { margin-top: 12px; }
.record-meta { display: grid; grid-template-columns: max-content 1fr; gap: 6px 14px; margin: 0; }
.record-meta dt { color: var(--muted); }
.record-meta dd { margin: 0; overflow-wrap: anywhere; }
.record-json { margin-top: 14px; }
.record-json summary { cursor: pointer; color: var(--muted); font-size: 13px; }
#recordSaveView .step-actions { justify-content: space-between; }

.saved-card { max-width: 720px; margin: 10px auto 6px; text-align: center; padding: 28px 24px 20px; }
.saved-tick { width: 64px; height: 64px; margin: 0 auto 10px; border-radius: 50%; display: grid; place-items: center;
  font-size: 32px; color: #fff; background: var(--g-nadai); box-shadow: 0 0 0 8px var(--g-nadai-bg); animation: savedPop .35s ease-out; }
@keyframes savedPop { from { transform: scale(.6); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.saved-card h3 { margin: 6px 0 2px; font-size: 22px; }
.saved-id { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 16px; color: var(--muted); }
.saved-stats { display: flex; justify-content: center; flex-wrap: wrap; gap: 10px; margin: 18px 0 10px; }
.saved-stats div { min-width: 110px; padding: 10px 14px; border-radius: 10px; background: var(--soft); display: flex; flex-direction: column; }
.saved-stats strong { font-size: 18px; }
.saved-stats span { font-size: 12px; color: var(--muted); }
.saved-where { color: var(--muted); line-height: 1.6; max-width: 560px; margin: 8px auto 16px; }
.saved-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; align-items: center; }
.saved-list { margin-top: 22px; text-align: left; border-top: 1px solid var(--border); padding-top: 12px; }
.saved-list summary { cursor: pointer; font-size: 14px; }
.saved-table { width: 100%; border-collapse: collapse; margin: 10px 0; }
.saved-table th, .saved-table td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--border); }
.saved-table th { color: var(--muted); font-weight: 600; }

/* =========================================================
   v0.15 — sign-in, team, upload gate
   ========================================================= */
.account-area { margin-left: auto; position: relative; }
.acct-chip { display: inline-flex; align-items: center; gap: 7px; padding: 6px 12px; border: 1px solid var(--border);
  border-radius: 999px; font-size: 13px; background: #fff; cursor: pointer; list-style: none; white-space: nowrap; }
.acct-chip::-webkit-details-marker { display: none; }
.acct-chip.muted { color: var(--muted); cursor: default; background: var(--soft); }
.acct-chip.warn { border-color: var(--st-open); color: #6b4a06; }
.acct-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--g-nadai); }
.acct-chip.warn .acct-dot { background: var(--st-open); }
.acct-signin { padding: 7px 14px; border-radius: 999px; font-size: 13px; background: var(--dark); color: #fff; border-color: var(--dark); }
.acct-signin:hover { background: #2a3444; }
.acct-menu { position: relative; }
.acct-pop { position: absolute; right: 0; top: calc(100% + 6px); z-index: 30; width: 290px; display: grid; gap: 8px; padding: 12px;
  background: #fff; border: 1px solid var(--border); border-radius: 12px; box-shadow: 0 12px 30px rgba(17, 24, 39, .12); }
.acct-pop button { text-align: left; padding: 8px 10px; font-size: 13px; }

.upload-gate { max-width: 560px; margin: 26px auto; padding: 28px; text-align: center; background: #fff;
  border: 1px solid var(--border); border-radius: 14px; line-height: 1.6; }
.upload-gate h3 { margin: 0 0 6px; }
.upload-gate p { color: var(--muted); margin: 0 0 16px; }
#upload.locked .pipeline, #upload.locked .upload-step-panel, #upload.locked .draft-save-tools { display: none !important; }

.team-dialog { width: min(620px, calc(100vw - 32px)); border: 1px solid var(--border); border-radius: 14px; padding: 20px 22px; }
.team-dialog::backdrop { background: rgba(17, 24, 39, .35); }
.team-dialog h2 { margin: 2px 0 4px; }
.team-add { display: grid; grid-template-columns: 1fr auto auto; gap: 8px; margin: 14px 0 6px; }
.team-add input, .team-add select { padding: 9px 10px; }
.team-dialog select { padding: 4px 8px; }

/* v0.16 detection tiers */
.a-chip.gate { background: var(--g-nadai-bg); color: #1f5c40; }
.a-chip.possible { background: #f1ecfb; color: #5b3f99; }
.a-card.possible { border-style: dashed; }

/* =========================================================
   v0.17 — Dashboard / Analyze / Insights on the Tamil taxonomy
   ========================================================= */
.sample-banner { margin: 0 0 14px; padding: 10px 14px; border-radius: 10px; background: #f1ecfb; color: #4a3485; font-size: 13px; line-height: 1.5; }
.thin-note { margin: -4px 0 12px; }
.seg.g-ezhuthu, .hbar-fill.g-ezhuthu { background: var(--g-ezhuthu); }
.seg.g-sol, .hbar-fill.g-sol { background: var(--g-sol); }
.seg.g-ilakkanam, .hbar-fill.g-ilakkanam { background: var(--g-ilakkanam); }
.seg.g-nadai, .hbar-fill.g-nadai { background: var(--g-nadai); }
.stack { display: flex; height: 12px; border-radius: 4px; overflow: hidden; min-width: 4px; }
.stack .seg { height: 100%; }
.empty-stack { width: 0; }

.lvl-table { display: grid; gap: 2px; }
.lvl-row { display: grid; grid-template-columns: 1.1fr .5fr .7fr 2fr; gap: 10px; align-items: center; padding: 7px 4px; border-bottom: 1px solid var(--border); font-size: 14px; }
.lvl-row.head { font-size: 12px; color: var(--muted); border-bottom-width: 2px; }
.lvl-row.none { color: #a0a7b3; }
.lvl-rate { display: flex; align-items: center; gap: 8px; }
.lvl-rate .stack { flex: none; max-width: calc(100% - 44px); }
.lvl-rate b { margin-left: auto; font-variant-numeric: tabular-nums; }

.grp-block { padding: 9px 0; border-bottom: 1px solid var(--border); }
.grp-head { display: flex; align-items: center; gap: 8px; }
.grp-head strong { margin-left: auto; font-size: 16px; }
.grp-subs { margin-top: 5px; color: var(--muted); line-height: 1.7; }
.grp-subs b { color: var(--text); }

.cov-table th, .cov-table td { text-align: center; padding: 6px 8px; }
.cov-table td:first-child, .cov-table th:first-child { text-align: left; }
.cov-table td.has { background: var(--g-nadai-bg); color: #1f5c40; font-weight: 600; }
.cov-table td.gap { color: #c4c9d2; }

.hbars { display: grid; gap: 7px; margin-top: 6px; }
.hbar-row { display: grid; grid-template-columns: minmax(150px, 1.2fr) 2fr 56px; gap: 10px; align-items: center; font-size: 14px; }
.hbar-label .small { display: block; }
.hbar-track { height: 14px; background: var(--soft); border-radius: 5px; overflow: hidden; }
.hbar-fill { display: block; height: 100%; background: var(--dark); border-radius: 5px; }
.hbar-val { text-align: right; font-variant-numeric: tabular-nums; }

.insight-panels { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 14px; }
.insight-panels .panel, #insightOutput > .panel { margin: 0 0 16px; }
#insightOutput h3 .small, .panel h3 .small { font-weight: 400; margin-left: 6px; }
.prof-row { display: grid; grid-template-columns: 190px 1fr 56px; gap: 12px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--border); }
.prof-row.none { color: #a0a7b3; }
.prof-label { display: flex; flex-direction: column; font-weight: 600; font-size: 14px; }
.prof-label .small { font-weight: 400; }
.prof-row strong { text-align: right; font-variant-numeric: tabular-nums; }
.conf-key { font-size: 18px; white-space: nowrap; }
.det-table td, .det-table th { text-align: right; }
.det-table td:first-child, .det-table th:first-child { text-align: left; }

.conc-filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; margin: 4px 0 10px; }
.conc-filters label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); }
.conc-filters select { padding: 7px 9px; font-size: 13px; max-width: 280px; }
.conc-filters button { padding: 8px 12px; font-size: 13px; }
.conc-table td { vertical-align: middle; }
.conc-left { text-align: right; color: var(--muted); }
.conc-table td.tamil { font-size: 15px; }
.conc-key { white-space: nowrap; }
#dialogText mark.a-mark { border-bottom: 2px solid var(--c); background: var(--bg); }
@media (max-width: 900px) { .insight-panels { grid-template-columns: 1fr; } .prof-row { grid-template-columns: 1fr; } }
.conc-key mark.a-mark, .conc-table mark.a-mark { background: var(--bg); box-shadow: inset 0 -2px 0 var(--c); cursor: default; }
.insight-panels > .panel { min-width: 0; overflow-x: auto; }
.prof-row.thin .stack, .lvl-row.thin .stack { opacity: .35; }
.prof-row.thin strong, .lvl-row.thin b { color: var(--muted); }
.prof-row .few { display: block; font-weight: 400; font-size: 11px; }

/* =========================================================
   v0.18 — Intelligence
   ========================================================= */
.intel-top { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 10px; }
.intel-source button span { margin-left: 4px; opacity: .7; }
.sim-banner { margin: 0 0 12px; padding: 10px 14px; border-radius: 10px; background: #fff4e0; color: #6b4a06; font-size: 13px; line-height: 1.55; border: 1px solid #f3d9a6; }
.intel-nav { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0 16px; padding-bottom: 12px; border-bottom: 1px solid var(--border); }
.intel-nav button { padding: 7px 12px; font-size: 13px; border-radius: 999px; }
.intel-nav button.active { background: var(--dark); color: #fff; border-color: var(--dark); }
.intel-body .panel { margin-bottom: 16px; }
.findings { display: grid; gap: 10px; margin-bottom: 10px; }
.finding { display: flex; gap: 14px; align-items: flex-start; padding: 14px 16px; border: 1px solid var(--border); border-radius: 12px; background: #fff; }
.f-icon { flex: none; width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; font-size: 16px; background: var(--soft); }
.k-development .f-icon { background: var(--g-ezhuthu-bg); color: var(--g-ezhuthu); }
.k-task .f-icon { background: var(--g-sol-bg); color: var(--g-sol); }
.k-school .f-icon { background: var(--g-ilakkanam-bg); color: var(--g-ilakkanam); }
.k-co .f-icon, .k-progress .f-icon { background: var(--g-nadai-bg); color: var(--g-nadai); }
.f-text { font-size: 15px; line-height: 1.6; }
.f-sup { margin-top: 3px; }
.spark polyline { stroke: var(--dark); stroke-width: 1.6; }
.spark circle { fill: var(--dark); }
.dev-table td, .dev-table th { vertical-align: middle; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.cls { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.cls-persistent { background: var(--g-ilakkanam-bg); color: var(--g-ilakkanam); }
.cls-emerging { background: var(--g-sol-bg); color: var(--g-sol); }
.cls-outgrown { background: var(--g-nadai-bg); color: #1f5c40; }
.cls-mixed, .cls-thin { background: var(--soft); color: var(--muted); }
.ci-table td { vertical-align: middle; }
.ci-cell { width: 60%; }
.ci-track { position: relative; display: block; height: 14px; background: var(--soft); border-radius: 7px; }
.ci-range { position: absolute; top: 3px; height: 8px; border-radius: 4px; background: #b8c3d3; }
.ci-dot { position: absolute; top: 1px; width: 12px; height: 12px; margin-left: -6px; border-radius: 50%; background: var(--dark); }
.scatter { width: 100%; height: auto; }
.scatter .ax { stroke: #c9d0da; }
.scatter .axl { font-size: 11px; fill: var(--muted); }
.scatter .axt { font-size: 10px; fill: var(--muted); }
.scatter circle { fill-opacity: .55; }
.lv-0 { fill: #b7791f; background: #b7791f; } .lv-1 { fill: #d49a3a; background: #d49a3a; } .lv-2 { fill: #2f6aa8; background: #2f6aa8; }
.lv-3 { fill: #5b8fc9; background: #5b8fc9; } .lv-4 { fill: #2f7d58; background: #2f7d58; } .lv-5 { fill: #5aa67f; background: #5aa67f; }
.lv-key { display: flex; gap: 12px; flex-wrap: wrap; color: var(--muted); }
.lv-key i { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 4px; }
.intel-search { width: 260px; padding: 7px 10px; margin: 2px 0 10px; }
b.good { color: #1f5c40; } b.bad { color: var(--g-ilakkanam); }
.prio-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); gap: 14px; margin-top: 10px; }
.prio-item { display: flex; gap: 12px; padding: 10px 0; border-top: 1px solid var(--border); }
.prio-n { flex: none; width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; background: var(--dark); color: #fff; font-size: 12px; font-weight: 700; }
.prio-tip { margin: 4px 0; line-height: 1.5; }
.ask-row { display: flex; gap: 8px; margin: 12px 0 8px; }
.ask-row input { flex: 1; padding: 11px 12px; font-size: 15px; }
.ask-examples { display: flex; flex-wrap: wrap; gap: 4px 14px; }
.ask-answer { margin-top: 16px; }
.ask-q { font-weight: 600; margin-bottom: 6px; }
.ask-a { font-size: 15px; line-height: 1.7; padding: 12px 14px; background: var(--soft); border-radius: 10px; margin-bottom: 6px; }
.k-persistent .f-icon { background: var(--g-ilakkanam-bg); color: var(--g-ilakkanam); font-size: 12px; }
.k-emerging .f-icon { background: var(--g-sol-bg); color: var(--g-sol); }
[data-transcript-view] { white-space: nowrap; }
.t-edit-actions { flex-wrap: wrap; align-items: center; }
.t-edit-actions button { padding: 7px 12px; font-size: 13px; }
.t-type-status { color: var(--muted); }

/* v0.20 — missing-word caret, delete, open-lines note */
mark.a-mark.a-ins { display: inline-block; width: 0; position: relative; padding: 0; background: none; box-shadow: none; vertical-align: baseline; }
mark.a-mark.a-ins::before { content: "‸"; position: absolute; left: -6px; bottom: -0.55em; font-size: 1.25em; font-weight: 700; color: var(--c); line-height: 1; }
mark.a-mark.a-ins.s-pending::before { opacity: .85; }
mark.a-mark.a-ins.active::before { outline: 2px solid var(--c); border-radius: 3px; }
mark.a-mark.a-ins-text { text-decoration: underline wavy var(--c); text-underline-offset: 4px; }
.a-ins-label { font-style: normal; color: #6b7280; font-size: 14px; }
.a-actions .a-delete { color: #b91c1c; margin-left: auto; }
.s4-unreviewed { padding: 8px 12px; margin: 0 0 10px; border-radius: 10px; background: #f1f5f9; border: 1px solid #dbe3ec; color: #334155; }
.s4-unreviewed .text-button { padding: 0; font-size: inherit; }
mark.a-mark.a-ins-view { font-size: .8em; vertical-align: super; background: var(--bg); padding: 0 3px; }
.learner-text.keep-lines { white-space: pre-line; }
