/* Sayback UI - restrained, readable at a distance, keyboard friendly. No external assets. */
:root {
  --ink: #14213d;
  --ink-soft: #3b4766;
  --muted: #6b7280;
  --paper: #f6f5f0;
  --card: #ffffff;
  --line: #d9dbe3;
  --accent: #0f766e;
  --accent-ink: #ffffff;
  --accent-soft: #d8f0ec;
  --danger: #b42318;
  --danger-soft: #fde8e6;
  --warn: #9a5b00;
  --warn-soft: #fff1d6;
  --focus: #2563eb;
  --day: #1d4ed8; --day-soft: #dbe7ff;
  --time: #0e7490; --time-soft: #d7f2f7;
  --quantity: #6d28d9; --quantity-soft: #e9ddff;
  --correction: #92400e; --correction-soft: #ffe8c2;
  --negation: #b91c1c; --negation-soft: #ffd9d9;
  --name: #047857; --name-soft: #d4f5e6;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(20, 33, 61, .06), 0 8px 24px rgba(20, 33, 61, .06);
  font-size: 18px;
}
html[data-scale="large"] { font-size: 23px; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ink: #eef1f8; --ink-soft: #c5cbdc; --muted: #9aa3b8;
    --paper: #0f1626; --card: #182238; --line: #2b3652;
    --accent: #2dd4bf; --accent-ink: #062a27; --accent-soft: #123b39;
    --danger: #fca5a5; --danger-soft: #3b1d1d; --warn: #fcd34d; --warn-soft: #3a2e10; --focus: #93c5fd;
    --day: #93b4ff; --day-soft: #1e2d5a; --time: #67e8f9; --time-soft: #0f3a44; --quantity: #c4b5fd; --quantity-soft: #2e2256;
    --correction: #fdba74; --correction-soft: #4a2e10; --negation: #fca5a5; --negation-soft: #4a1d1d; --name: #6ee7b7; --name-soft: #0f3b2e;
    --shadow: 0 1px 2px rgba(0,0,0,.4), 0 8px 24px rgba(0,0,0,.35);
  }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body {
  font-family: "Inter", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  color: var(--ink);
  background: var(--paper);
  line-height: 1.5;
  overflow-wrap: anywhere;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); }
.mono { font-family: ui-monospace, "Cascadia Mono", "Consolas", "SF Mono", Menlo, monospace; font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.skip-link { position: absolute; left: -999px; top: 8px; background: var(--card); padding: .5rem 1rem; border-radius: 8px; z-index: 100; }
.skip-link:focus { left: 8px; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; border-radius: 6px; }

/* Top bar */
.topbar { display: flex; flex-wrap: wrap; gap: 1rem; align-items: center; justify-content: space-between; padding: 1rem clamp(1rem, 4vw, 3rem); border-bottom: 1px solid var(--line); background: var(--card); }
.topbar__brand { display: flex; align-items: center; gap: .8rem; }
.topbar__name { font-weight: 800; font-size: 1.35rem; letter-spacing: -.01em; }
.topbar__tagline { color: var(--ink-soft); font-size: .95rem; }
.topbar__right { display: flex; flex-wrap: wrap; gap: .6rem; align-items: center; }
.status { display: inline-flex; align-items: center; gap: .5rem; padding: .35rem .8rem; border-radius: 999px; border: 1px solid var(--line); font-size: .9rem; background: var(--paper); max-width: 34rem; }
.status__dot { width: .65rem; height: .65rem; border-radius: 50%; background: var(--muted); flex: none; }
.status--ready .status__dot { background: var(--accent); }
.status--pending .status__dot { background: var(--warn); animation: pulse 1.2s infinite; }
.status--error .status__dot { background: var(--danger); }
@keyframes pulse { 0%,100% { opacity: 1 } 50% { opacity: .35 } }

/* Layout and cards */
.layout { max-width: 72rem; margin: 0 auto; padding: 1.25rem clamp(1rem, 4vw, 3rem) 3rem; display: grid; gap: 1.25rem; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: clamp(1rem, 3vw, 1.75rem); }
.card__head h2 { margin: 0 0 .25rem; font-size: 1.45rem; letter-spacing: -.01em; display: flex; align-items: center; gap: .6rem; }
.card__hint { margin: 0 0 1rem; color: var(--ink-soft); }
.step { display: inline-grid; place-items: center; width: 1.9rem; height: 1.9rem; border-radius: 50%; background: var(--ink); color: var(--paper); font-size: .95rem; font-weight: 700; flex: none; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .step { background: var(--accent); color: var(--accent-ink); } }

/* Buttons */
.btn { display: inline-flex; align-items: center; gap: .5rem; padding: .6rem 1.05rem; border-radius: 10px; border: 1px solid var(--line); background: var(--card); color: var(--ink); font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; line-height: 1.2; }
.btn:hover { border-color: var(--ink-soft); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .5; cursor: not-allowed; }
.btn--primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn--primary:hover { filter: brightness(.95); }
.btn--secondary { background: var(--paper); }
.btn--ghost { background: transparent; border-color: transparent; color: var(--ink-soft); }
.btn--ghost:hover { border-color: var(--line); }
.btn--danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn--big { font-size: 1.1rem; padding: .8rem 1.4rem; }
.btn--small { padding: .3rem .65rem; font-size: .85rem; font-weight: 600; }
.btn__icon { font-size: .9em; }
.file-label { position: relative; }

/* Audio section */
.audio-actions { display: flex; flex-wrap: wrap; gap: .7rem; margin-bottom: .5rem; }
.meter { height: .6rem; background: var(--line); border-radius: 999px; overflow: hidden; margin: .5rem 0; max-width: 28rem; }
.meter__bar { height: 100%; width: 0; background: var(--accent); transition: width .08s linear; }
.clip { margin-top: 1rem; padding: 1rem; border: 1px dashed var(--line); border-radius: 12px; display: grid; gap: .75rem; background: var(--paper); }
.clip audio { width: 100%; max-width: 100%; }
.clip__actions { display: flex; flex-wrap: wrap; align-items: center; gap: .75rem; }
.error { margin-top: .75rem; padding: .75rem 1rem; border-radius: 10px; background: var(--danger-soft); color: var(--danger); border: 1px solid color-mix(in srgb, var(--danger) 35%, transparent); }
.notice { padding: .75rem 1rem; border-radius: 10px; background: var(--warn-soft); color: var(--warn); border: 1px solid color-mix(in srgb, var(--warn) 35%, transparent); }
.banner { padding: .75rem 1rem; border-radius: 10px; margin-bottom: 1rem; }
.banner--warn { background: var(--warn-soft); color: var(--warn); border: 1px solid color-mix(in srgb, var(--warn) 40%, transparent); }
.banner strong { display: block; }

/* Transcript */
.transcript { font-size: 1.35rem; line-height: 2.1; padding: .5rem 0 .75rem; }
.word { font: inherit; background: transparent; border: 0; border-bottom: 3px solid transparent; border-radius: 6px; padding: .05em .22em; margin: 0 .05em; color: var(--ink); cursor: pointer; }
.word:hover { background: var(--paper); }
.word.is-playing { background: var(--accent-soft); }
.word--day { background: var(--day-soft); border-bottom-color: var(--day); }
.word--time { background: var(--time-soft); border-bottom-color: var(--time); }
.word--quantity { background: var(--quantity-soft); border-bottom-color: var(--quantity); }
.word--correction, .word--alternative { background: var(--correction-soft); border-bottom-color: var(--correction); font-style: italic; }
.word--negation { border-bottom-color: var(--negation); }
.word--negation_word { background: var(--negation-soft); font-weight: 700; }
.word--name { background: var(--name-soft); border-bottom-color: var(--name); }
.legend { display: flex; flex-wrap: wrap; gap: .5rem; margin: .25rem 0 1rem; }
.chip { display: inline-block; padding: .15rem .6rem; border-radius: 999px; font-size: .8rem; font-weight: 600; border: 1px solid transparent; }
.chip--day { background: var(--day-soft); color: var(--day); }
.chip--time { background: var(--time-soft); color: var(--time); }
.chip--quantity { background: var(--quantity-soft); color: var(--quantity); }
.chip--correction { background: var(--correction-soft); color: var(--correction); }
.chip--negation { background: var(--negation-soft); color: var(--negation); }
.chip--name { background: var(--name-soft); color: var(--name); }
.transcript__meta { display: grid; gap: .25rem; }
.details { margin-top: .75rem; }
.details summary { cursor: pointer; color: var(--ink-soft); }
.pre { white-space: pre-wrap; word-break: break-word; background: var(--paper); padding: .75rem; border-radius: 10px; font-size: .9rem; }
.pre--small { font-size: .75rem; }

/* Review fields */
.field { border: 1px solid var(--line); border-radius: 12px; padding: 1rem 1.1rem; margin: 0 0 1rem; background: var(--card); }
.field--confirmed { border-color: var(--accent); background: color-mix(in srgb, var(--accent-soft) 45%, var(--card)); }
.field--optional { opacity: .92; }
.field legend { padding: 0 .4rem; display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.field__label { font-weight: 700; font-size: 1.1rem; }
.field__state { font-size: .8rem; padding: .1rem .6rem; border-radius: 999px; background: var(--warn-soft); color: var(--warn); font-weight: 700; }
.field--confirmed .field__state { background: var(--accent-soft); color: var(--accent); }
.field--optional .field__state { background: var(--paper); color: var(--muted); }
.field__question { margin: .25rem 0; font-weight: 600; }
.field__note { margin: 0 0 .75rem; color: var(--ink-soft); font-size: .92rem; }
.options { display: grid; gap: .5rem; }
.option { display: grid; grid-template-columns: auto 1fr auto; gap: .6rem; align-items: center; padding: .55rem .7rem; border: 1px solid var(--line); border-radius: 10px; background: var(--paper); }
.option input[type="radio"] { width: 1.15rem; height: 1.15rem; margin: 0; accent-color: var(--accent); }
.option__body { display: flex; flex-wrap: wrap; gap: .25rem .7rem; align-items: baseline; }
.option__value { font-weight: 700; font-size: 1.05rem; }
.option__context { color: var(--ink-soft); font-style: italic; }
.option__time { color: var(--muted); font-size: .8rem; }
.option__tag { font-size: .78rem; padding: .05rem .5rem; border-radius: 999px; background: var(--correction-soft); color: var(--correction); font-weight: 600; }
.option__tag--alt { background: var(--time-soft); color: var(--time); }
.option__note { flex-basis: 100%; color: var(--muted); font-size: .82rem; }
.option input[type="text"] { font: inherit; padding: .35rem .5rem; border: 1px solid var(--line); border-radius: 8px; min-width: 12rem; width: 100%; background: var(--card); color: var(--ink); }
.field__actions { display: flex; flex-wrap: wrap; gap: .6rem; align-items: center; margin-top: .75rem; }
.field__confirmed-value { font-weight: 700; }
.field__confirmed-value small { color: var(--muted); font-weight: 400; }
.field__replay-all { color: var(--muted); font-size: .85rem; }

/* Keep the evidence and human choices readable during a projected demonstration. */
.review-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 1rem; align-items: start; }
.review-grid > .field { margin: 0; min-width: 0; }
.field__reason { margin: .35rem 0 .7rem; color: var(--ink-soft); font-size: .85rem; }
.field__reason summary, .optional-review > summary { cursor: pointer; }
.field__reason p { margin: .5rem 0 0; }
.optional-review { margin-top: 1rem; }
.optional-review > summary { padding: .6rem 0; color: var(--ink-soft); }
.field--confirmed .options,
.field--confirmed .field__question,
.field--confirmed .field__reason,
.field__confirmed-value small { display: none; }
@media (min-width: 1000px) {
  .review-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* Final */
.final { display: grid; gap: .75rem; }
.final__toolbar { display: flex; flex-wrap: wrap; gap: .6rem; align-items: center; }
.label { font-weight: 600; }
textarea { font: inherit; width: 100%; padding: .7rem .8rem; border: 1px solid var(--line); border-radius: 10px; background: var(--paper); color: var(--ink); resize: vertical; min-height: 7rem; }
.check { display: flex; gap: .6rem; align-items: flex-start; padding: .6rem .7rem; border: 1px solid var(--line); border-radius: 10px; }
.check input { width: 1.2rem; height: 1.2rem; margin-top: .2rem; accent-color: var(--accent); flex: none; }
.final__export { display: flex; flex-wrap: wrap; gap: .6rem; align-items: center; }
#export-status.is-blocked { color: var(--warn); }
#export-status.is-ready { color: var(--accent); }

/* Footer */
.footer { border-top: 1px solid var(--line); background: var(--card); padding: 1.5rem clamp(1rem, 4vw, 3rem) 2.5rem; font-size: .9rem; color: var(--ink-soft); }
.footer__grid { max-width: 72rem; margin: 0 auto; display: grid; gap: 1.5rem; grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr)); }
.footer p { margin: .35rem 0; }

@media (max-width: 640px) {
  .topbar { padding: .75rem 1rem; }
  .transcript { font-size: 1.15rem; line-height: 1.9; }
  .option { grid-template-columns: auto 1fr; }
  .option > .btn { grid-column: 1 / -1; justify-self: start; }
  .btn--big { width: 100%; justify-content: center; }
}
@media (prefers-reduced-motion: reduce) { .status--pending .status__dot { animation: none; } .meter__bar { transition: none; } }
