:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --text: #111827;
  --muted: #6b7280;
  --border: #e5e7eb;
  --accent: #111827;
  --ok: #15803d;
  --warn: #b45309;
  --bad: #b91c1c;
  font-family: system-ui, -apple-system, "Segoe UI", Tahoma, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #18181b;
    --surface: #232326;
    --text: #f4f4f5;
    --muted: #a1a1aa;
    --border: #3f3f46;
    --accent: #f4f4f5;
    --ok: #4ade80;
    --warn: #fbbf24;
    --bad: #f87171;
  }
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); }
.page { max-width: 760px; margin: 0 auto; padding: 24px 16px 48px; display: grid; gap: 16px; }
.head h1 { margin: 0 0 6px; font-size: 1.5rem; }
.en { color: var(--muted); font-weight: 400; font-size: 0.8em; margin-inline-start: 6px; }
.muted { color: var(--muted); margin: 0; }
.small { font-size: 0.8rem; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 18px; display: grid; gap: 12px; }
/* Grid items default to min-width: auto — a long line (the JSON) would widen the page. */
.page > *, .card > * { min-width: 0; }
h2 { margin: 6px 0 0; font-size: 1rem; }
h3 { margin: 0 0 6px; font-size: 0.9rem; }

.row { display: flex; align-items: center; gap: 12px; }
button { font: inherit; border-radius: 12px; border: 1px solid var(--border); background: var(--surface); color: var(--text); padding: 10px 14px; cursor: pointer; }
button.primary { flex: 1; min-height: 54px; font-size: 1.05rem; font-weight: 700; background: var(--accent); color: var(--bg); border: 0; display: inline-flex; align-items: center; justify-content: center; gap: 10px; }
button.primary.recording { background: var(--bad); color: #fff; }
button:disabled { opacity: 0.6; cursor: progress; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: currentColor; }
.recording .dot { animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: 0.3; } }
.timer { font-variant-numeric: tabular-nums; color: var(--muted); min-width: 52px; }

.wave { height: 40px; display: flex; align-items: center; gap: 3px; direction: ltr; }
.wave span { flex: 1; height: 100%; background: var(--bad); border-radius: 3px; transform-origin: center; transition: transform 80ms linear; }

.status { padding: 10px 12px; border-radius: 10px; background: var(--bg); font-size: 0.92rem; }
.status[data-state="error"], .status[data-state="denied"] { color: var(--bad); }
.status[data-state="success"] { color: var(--ok); font-weight: 700; }
.status[data-state="missing"] { color: var(--warn); font-weight: 700; }

.options { display: grid; gap: 10px; }
.options summary { cursor: pointer; color: var(--muted); }
.options label { display: grid; gap: 4px; font-size: 0.85rem; color: var(--muted); margin-top: 8px; }
select, textarea, input { font: inherit; padding: 8px 10px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface); color: var(--text); }

.transcript { margin: 0; line-height: 1.8; font-size: 1rem; }
.fields { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.fields th, .fields td { text-align: start; padding: 8px 6px; border-bottom: 1px solid var(--border); vertical-align: top; }
.fields th { color: var(--muted); font-weight: 600; }
.fields .name { color: var(--muted); white-space: nowrap; }
.fields .value { font-weight: 600; overflow-wrap: anywhere; }
.fields .heard { display: block; font-weight: 400; color: var(--warn); font-size: 0.8rem; }
.pill { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 0.75rem; border: 1px solid currentColor; white-space: nowrap; }
.pill.extracted, .pill.confirmed { color: var(--ok); }
.pill.uncertain, .pill.invalid { color: var(--warn); }
.pill.rejected { color: var(--bad); }
.pill.missing, .pill.defaulted { color: var(--muted); }
.confirm-mark { color: var(--warn); margin-inline-start: 4px; }

.lists { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.chips { margin: 0; display: flex; flex-wrap: wrap; gap: 6px; min-height: 1.5em; }
.chips span { padding: 3px 9px; border-radius: 999px; background: var(--bg); font-size: 0.8rem; }
pre { overflow: auto; font-size: 0.75rem; background: var(--bg); padding: 10px; border-radius: 10px; max-height: 360px; }

@media (max-width: 560px) {
  .lists { grid-template-columns: 1fr; }
  .fields th:nth-child(4), .fields td:nth-child(4) { display: none; }
}
