:root {
  --bg: #f7f4ee;
  --surface: #ffffff;
  --ink: #1f2328;
  --muted: #5f6670;
  --line: #e2ddd3;
  --accent: #1f6f6b;
  --accent-ink: #ffffff;
  --accent-soft: #dcefed;
  --warn-bg: #fff4dc;
  --warn-ink: #7a4b00;
  --ok: #1d7a3a;
  --rec: #c63a2f;
  --meter: #2a9d8f;
  --meter-zone: rgba(42, 157, 143, .16);
  --radius: 14px;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #15181b; --surface: #1d2125; --ink: #e8e6e1; --muted: #a0a7b0; --line: #2e343a;
    --accent: #5cc2b8; --accent-ink: #0d1514; --accent-soft: #1c3533;
    --warn-bg: #3a2f17; --warn-ink: #f3cf86; --ok: #6fd08f; --rec: #ff6b5e;
    --meter: #5cc2b8; --meter-zone: rgba(92, 194, 184, .18);
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 17px/1.55 var(--sans);
}
.top {
  position: sticky; top: 0; z-index: 5; background: var(--bg);
  padding: 12px 16px 10px; border-bottom: 1px solid var(--line);
}
.brand { font-weight: 650; letter-spacing: .01em; max-width: 680px; margin: 0 auto; }
.tag { font-size: 12px; font-weight: 600; color: var(--accent); background: var(--accent-soft);
  padding: 2px 8px; border-radius: 99px; margin-left: 6px; vertical-align: 2px; }
.progress { max-width: 680px; margin: 8px auto 0; height: 4px; background: var(--line); border-radius: 4px; overflow: hidden; }
#progress-bar { height: 100%; width: 0; background: var(--accent); transition: width .3s; }

main { max-width: 680px; margin: 0 auto; padding: 20px 16px 64px; }
.screen > * + * { margin-top: 16px; }
h1 { font: 650 28px/1.2 var(--sans); margin: 8px 0 0; letter-spacing: -.01em; }
h2 { font: 650 20px/1.3 var(--sans); margin: 28px 0 0; }
h3 { font-size: 16px; margin: 14px 0 4px; }
.h-sub { font-size: 18px; font-weight: 500; }
.lead { font-size: 18px; color: var(--ink); }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.hint { font-size: 14px; color: var(--muted); margin: 6px 0 0; }
.eyebrow { font-size: 13px; text-transform: uppercase; letter-spacing: .08em; color: var(--accent); font-weight: 650; }
.facts { padding-left: 20px; }
.facts li { margin: 8px 0; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.prose p { margin: 0 0 8px; }
.prose h3:first-child { margin-top: 0; }
details.card summary { cursor: pointer; font-weight: 600; }

button { font: inherit; cursor: pointer; border-radius: 12px; padding: 12px 20px; border: 1px solid transparent; min-height: 48px; }
button:disabled { opacity: .45; cursor: not-allowed; }
.primary { background: var(--accent); color: var(--accent-ink); font-weight: 600; }
.ghost { background: transparent; border-color: var(--line); color: var(--ink); }
.link { background: none; border: none; color: var(--muted); text-decoration: underline; padding: 8px 0; min-height: 0; }
.row { display: flex; gap: 12px; justify-content: space-between; align-items: center; flex-wrap: wrap; }
.row.end { justify-content: space-between; margin-top: 28px; }
.row .primary { flex: 1 1 auto; }

[hidden] { display: none !important; }
.check { display: block; position: relative; padding: 6px 0 6px 32px; }
.check input { position: absolute; left: 0; top: 9px; width: 20px; height: 20px; margin: 0; accent-color: var(--accent); }

fieldset { border: none; padding: 0; margin: 0 0 20px; }
legend { font-weight: 600; margin-bottom: 8px; padding: 0; }
input:not([type=checkbox]):not([type=radio]), select, textarea {
  width: 100%; font: inherit; color: var(--ink); background: var(--surface);
  border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; min-height: 46px;
}
input + input, select + input, input + select, .pair + .pair, .pair + input, select + select { margin-top: 8px; }
.pair { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.chips { display: grid; gap: 4px; margin-bottom: 8px; }
.chips label { display: flex; gap: 10px; align-items: center; }
.chips input { width: 18px; height: 18px; accent-color: var(--accent); }
.com { border-top: 1px solid var(--line); padding: 10px 0; }
.com-sub { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 6px; }
.place + .place, .place + .sublbl, .place + button { margin-top: 8px; }
#other-places .place { margin-top: 8px; }
.sublbl { font-size: 14px; color: var(--muted); margin: 10px 0 4px; }
select:disabled { opacity: .45; }
.com-pick { grid-column: 1 / -1; }
.com-pick .chips { margin: 4px 0 0; }
.com-btns { margin-top: 8px; }
.com-btns button { flex: 1 1 0; }
.talk { border: 2px solid var(--rec); }
.rec-btn.nudge { animation: nudge .6s ease-in-out 3; box-shadow: 0 0 0 4px rgba(198,58,47,.3); }
@keyframes nudge { 50% { transform: scale(1.08); } }
.lbl { display: block; font-weight: 600; margin: 16px 0 6px; }

.warn { background: var(--warn-bg); color: var(--warn-ink); padding: 10px 14px; border-radius: 10px; }
.ok { color: var(--ok); font-weight: 600; }
.callout { background: var(--accent-soft); border-radius: var(--radius); padding: 14px 16px; }

/* meter */
.meter { position: relative; height: 14px; background: var(--line); border-radius: 8px; overflow: hidden; }
.meter.thin { height: 6px; }
.meter-zone { position: absolute; left: 35%; width: 50%; top: 0; bottom: 0; background: var(--meter-zone); }
#meter-bar, #meter-bar2 { position: absolute; left: 0; top: 0; bottom: 0; width: 0; background: var(--meter); transition: width 60ms linear; }
.meter.hot #meter-bar, .meter.hot #meter-bar2 { background: var(--rec); }

/* reading */
.passage {
  margin: 8px 0 0; font: 22px/1.65 var(--serif); background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius); padding: 20px;
}
.rec { display: flex; align-items: center; gap: 16px; }
.rec-btn { display: inline-flex; align-items: center; gap: 10px; background: var(--rec); color: #fff; font-weight: 650; padding: 14px 26px; border-radius: 99px; }
.rec-btn .dot { width: 12px; height: 12px; border-radius: 50%; background: #fff; }
.rec-btn.on .dot { border-radius: 2px; animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: .4; } }
.timer { font-variant-numeric: tabular-nums; color: var(--muted); font-size: 18px; }
audio { width: 100%; }

/* wait */
.spinner { width: 44px; height: 44px; border-radius: 50%; border: 4px solid var(--line); border-top-color: var(--accent); animation: spin 1s linear infinite; margin-top: 40px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* results */
.matches { list-style: none; padding: 0; margin: 12px 0 0; }
.matches li { padding: 10px 0; border-bottom: 1px solid var(--line); }
.matches .m-top { display: flex; justify-content: space-between; gap: 12px; align-items: baseline; }
.matches .m-label { font-weight: 600; }
.matches li:first-child .m-label { font-size: 19px; }
.matches .m-pct { font-variant-numeric: tabular-nums; color: var(--muted); }
.bar { height: 8px; border-radius: 6px; background: var(--line); margin-top: 6px; overflow: hidden; }
.bar > div { height: 100%; background: var(--accent); border-radius: 6px; }
.matches li:not(:first-child) .bar > div { opacity: .55; }
.highlights { padding-left: 0; list-style: none; }
.highlights li { padding: 10px 0; border-bottom: 1px solid var(--line); }
.highlights .f-name { font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.round { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-top: 10px; }
.round b { display: block; }
.round .why { font-size: 14px; color: var(--muted); }
.round button { flex: none; }
@media (max-width: 480px) { .round { flex-direction: column; align-items: stretch; } }

.ftable { width: 100%; border-collapse: collapse; font-size: 14px; margin-top: 8px; }
.ftable th { text-align: left; font-weight: 600; padding: 12px 4px 4px; color: var(--accent); }
.ftable td { padding: 6px 4px; border-top: 1px solid var(--line); vertical-align: top; }
.ftable td.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.ftable .mini { width: 60px; height: 6px; background: var(--line); border-radius: 4px; overflow: hidden; display: inline-block; vertical-align: middle; margin-right: 6px; }
.ftable .mini > div { height: 100%; background: var(--accent); }
.ftable .det { color: var(--muted); font-size: 12px; }

.scale { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; margin-top: 8px; }
.scale label { display: block; }
.scale input { position: absolute; opacity: 0; }
.scale span { display: block; text-align: center; padding: 10px 0; border: 1px solid var(--line); border-radius: 10px; font-weight: 600; cursor: pointer; }
.scale input:checked + span { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.scale input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.scale-labels { display: flex; justify-content: space-between; font-size: 13px; color: var(--muted); margin-top: 4px; }
#fb textarea { resize: vertical; }
#fb .primary { margin-top: 12px; width: 100%; }

@media (max-width: 420px) {
  h1 { font-size: 24px; }
  .passage { font-size: 20px; padding: 16px; }
  .pair, .com-sub { grid-template-columns: 1fr; }
}
.com-text { grid-column: 1 / -1; }
#com-list { margin: 12px 0 0 12px; padding-left: 16px; border-left: 3px solid var(--accent-soft); }
#com-list .com:first-of-type { border-top: none; }
.com-lead { margin: 0 0 4px; font-weight: 600; color: var(--ink); }
