:root {
  --bg: #f6f4ef;
  --surface: #ffffff;
  --text: #1d2323;
  --muted: #5d6868;
  --accent: #1d5c63;
  --accent-ink: #ffffff;
  --line: #e2ded5;
  --bar: #cfe3e4;
  --danger: #b3261e;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #121616;
    --surface: #1b2121;
    --text: #e8eeee;
    --muted: #9aa8a8;
    --accent: #5fb3ba;
    --accent-ink: #0d1a1b;
    --line: #2a3333;
    --bar: #24484b;
    --danger: #f2b8b5;
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #121616;
  --surface: #1b2121;
  --text: #e8eeee;
  --muted: #9aa8a8;
  --accent: #5fb3ba;
  --accent-ink: #0d1a1b;
  --line: #2a3333;
  --bar: #24484b;
  --danger: #f2b8b5;
  color-scheme: dark;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

main {
  max-width: 640px;
  margin: 0 auto;
  padding: 20px 16px 140px;
}

h1 { font-size: 1.4rem; margin: 0 0 4px; text-wrap: balance; }
h2 { font-size: 1.05rem; margin: 20px 0 10px; }
h2.none { color: var(--muted); }
.hint, .note, .status, .meta { color: var(--muted); }
.hint { margin: 0 0 18px; font-size: .95rem; }
.note { font-size: .85rem; margin-top: 28px; }
.status { font-size: .85rem; min-height: 1.45em; margin: 14px 0 0; }
.status.error { color: var(--danger); }
.meta { font-size: .85rem; }

.ask { display: grid; gap: 10px; }
textarea {
  width: 100%;
  font: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
}
textarea { resize: vertical; }
.row { display: flex; gap: 10px; justify-content: flex-end; }

button {
  font: inherit;
  font-size: .95rem;
  border-radius: 999px;
  padding: 9px 18px;
  cursor: pointer;
  border: 1px solid var(--accent);
  background: transparent;
  color: var(--accent);
}
button.primary { background: var(--accent); color: var(--accent-ink); }
button:disabled { opacity: .5; cursor: progress; }

#mic.recording { background: var(--danger); border-color: var(--danger); color: var(--surface); }

.heard { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 10px 16px; margin-top: 12px; display: grid; gap: 4px; }
.heard[hidden] { display: none; }
.heard .label { display: inline-block; min-width: 6.5em; color: var(--muted); font-size: .85rem; }
.langs { color: var(--muted); font-size: .85rem; }
.langs .chip { margin: 2px 4px 2px 0; }

.chip { font-size: .85rem; padding: 5px 12px; border-color: var(--line); color: var(--muted); }

.verse {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px 16px;
  margin-bottom: 10px;
}
.ref { font-weight: 600; }
.text { margin: 6px 0 10px; font-size: 1.05rem; }
.bar { height: 3px; border-radius: 2px; background: var(--bar); margin-bottom: 4px; }
.bar div { height: 100%; border-radius: 2px; background: var(--accent); }
.actions { margin-top: 10px; }

.answer-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 20px 0 10px; }
.answer-head h2 { margin: 0; }
button.info { flex: none; width: 30px; height: 30px; padding: 0; font: italic 700 1rem Georgia, serif; }

dialog {
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
  color: var(--text);
  width: calc(100% - 32px);
  max-width: 560px;
  max-height: calc(100% - 32px);
}
dialog::backdrop { background: rgb(0 0 0 / .45); }
.sheet { padding: 16px 18px 18px; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.sheet-head h2 { margin: 0; }
.summary { margin: 8px 0 16px; }
.steps { list-style: none; padding: 0; margin: 0 0 18px; display: grid; gap: 10px; }
.steps .step { display: flex; justify-content: space-between; gap: 12px; }
.steps .t { font-variant-numeric: tabular-nums; white-space: nowrap; }
.steps .meta { overflow-wrap: anywhere; }
.steps li:not(.longest) .bar div { opacity: .4; }
.steps li.longest .step { font-weight: 600; }
.facts { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 6px 14px; margin: 0; font-size: .9rem; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; overflow-wrap: anywhere; }

.others { margin-top: 18px; font-size: .9rem; }
.others summary { cursor: pointer; color: var(--accent); }
.others ol { padding-left: 0; list-style: none; display: grid; gap: 8px; margin: 10px 0 0; }
.others .p { display: inline-block; min-width: 3.2em; color: var(--muted); font-variant-numeric: tabular-nums; }

#player {
  position: fixed;
  left: 0;
  right: 0;
  bottom: max(16px, env(safe-area-inset-bottom));
  width: calc(100% - 32px);
  max-width: 608px;
  margin: 0 auto;
}

.models { margin-top: 14px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 10px 16px; }
.models summary { cursor: pointer; color: var(--accent); }
.models summary .meta { margin-left: 6px; }
.model-grid { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 10px 14px; align-items: start; margin: 12px 0 4px; }
.model-grid label { padding-top: 8px; font-size: .9rem; color: var(--muted); }
.model-grid select {
  width: 100%;
  font: inherit;
  font-size: .95rem;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 7px 10px;
}
.model-grid [hidden] { display: none; }
.pick-note { margin: 4px 0 0; overflow-wrap: anywhere; }
.pick-note:empty { display: none; }

@media (max-width: 480px) {
  .model-grid { grid-template-columns: minmax(0, 1fr); gap: 4px; }
  .model-grid label { padding-top: 8px; }
}
