/* ui-light/style.css — light interface of the recorder.
   Scene: an older person at home, daylight or a warm lamp, phone held at chest height, reading
   aloud carefully and a little nervous about doing it right. So: a bright, warm daylight neutral,
   high contrast, large type and large targets.
   Colour strategy: restrained. Warm tinted neutrals, one accent (Recharge navy) for the main
   action and the progress, semantic colours only for state. System fonts, one family.
   Every value below is a token; a customer theme overrides only :root. */

:root {
  /* neutrals, tinted warm (hue ~80) */
  --bg: oklch(0.985 0.004 80);
  --surface: oklch(0.997 0.002 80);
  --surface-2: oklch(0.962 0.006 80);
  --line: oklch(0.905 0.008 80);
  --ink: oklch(0.255 0.035 265);      /* navy-tinted text */
  --ink-2: oklch(0.43 0.03 265);
  --ink-3: oklch(0.5 0.024 265);      /* about 5:1 on --bg for small text */

  /* the one accent: Recharge navy */
  --accent: oklch(0.32 0.075 265);
  --accent-hover: oklch(0.27 0.07 265);
  --accent-soft: oklch(0.94 0.018 265);
  --on-accent: oklch(0.99 0.003 265);

  /* state */
  --recording: oklch(0.6 0.2 22);
  --success: oklch(0.52 0.12 155);
  --success-soft: oklch(0.95 0.035 155);
  --warning: oklch(0.5 0.1 70);
  --warning-soft: oklch(0.96 0.045 85);
  --danger: oklch(0.52 0.17 25);
  --scrim: oklch(0.22 0.03 265 / 0.4);
  --notice-bg: var(--accent-soft);   /* reminders while recording */
  --notice-ink: var(--accent);
  --focus: oklch(0.55 0.15 255);

  /* type: system family, ratio ~1.2 */
  --font: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Noto Sans SC",
    "Microsoft YaHei", "Segoe UI", system-ui, sans-serif;
  --fs-xs: 0.875rem;    /* 14: smallest text (older readers) */
  --fs-sm: 0.9375rem;   /* 15 */
  --fs-md: 1rem;        /* 16: body */
  --fs-lg: 1.1875rem;   /* 19 */
  --fs-xl: 1.625rem;    /* 26: page titles */
  --fs-num: 3rem;       /* 48: progress */

  /* shape and space */
  --radius: 14px;
  --radius-panel: 18px;
  --radius-sheet: 22px;
  --btn-h: 56px;
  --gutter: 20px;
  --ease: cubic-bezier(0.25, 1, 0.5, 1); /* ease-out-quart */
  --shadow-sheet: 0 -12px 40px oklch(0.25 0.035 265 / 0.14);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: var(--fs-md);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

/* every page is exactly one screen: its height is the part of the screen the browser really
   shows (--app-h, measured in app.js; Chrome on iPhone lays the page under its own toolbars, so
   100vh/100dvh there is taller than what is visible). No bounce; a long step or the topic list
   scrolls inside itself */
html,
body {
  overscroll-behavior: none;
}
.step-screen,
.pane {
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

.hidden {
  display: none !important;
}

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

/* ---------- shell ---------- */
.page {
  max-width: 34rem;
  margin: 0 auto;
  min-height: 100vh;
  min-height: 100dvh;
  padding-inline: var(--gutter);
  padding-block: 0 calc(var(--btn-h) + 48px + env(safe-area-inset-bottom, 0px));
}

/* one screen per page: no page scroll; a long step scrolls inside itself */
.page.screen {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  height: var(--app-h, 100dvh);
  min-height: 0;
  padding-block: 0 calc(var(--btn-h) + 25px + env(safe-area-inset-bottom, 0px));
}

/* ---------- instruction steps ---------- */
.stepper {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-block: 28px 0;
}

/* three parts; the steps reached so far are filled */
.stepper-bar {
  flex: 1 1 auto;
  display: flex;
  gap: 4px;
}

.stepper-bar i {
  flex: 1 1 0;
  height: 4px;
  border-radius: 2px;
  background: var(--line);
  transition: background-color 200ms var(--ease);
}

.stepper-bar i.on {
  background: var(--brand-blue, var(--accent));
}

.stepper-count {
  flex: none;
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--ink-3);
  font-variant-numeric: tabular-nums;
}

.step-screen {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding-block: 28px 20px;
  animation: step-in 220ms var(--ease);
}

/* the small blue title above each step's heading */
.eyebrow {
  margin: 0 0 6px;
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--brand-blue-ink, #126d94);
}

.step-screen h1 {
  margin: 0;
  font-size: var(--fs-xl);
  line-height: 1.3;
  font-weight: 700;
  text-wrap: balance;
}

.step-screen .lead {
  margin: 12px 0 0;
  color: var(--ink-2);
}

.step-screen h1 + .prep,
.step-screen .lead + .flow,
.step-screen .lead + .choices {
  margin-top: 32px;
}

.step-screen.consent ul {
  margin-top: 20px;
}

@keyframes step-in {
  from {
    opacity: 0;
    transform: translateX(12px);
  }
}

/* ---------- instruction page ---------- */
.page-head {
  padding-block: 40px 4px;
}

.page-head h1,
.rec-head h1 {
  margin: 0;
  font-size: var(--fs-xl);
  line-height: 1.3;
  font-weight: 700;
  letter-spacing: -0.005em;
}

.page-head p {
  margin: 10px 0 0;
  max-width: 34em;
  color: var(--ink-2);
}

.group {
  margin-top: 36px;
}

.group-title {
  margin: 0 0 14px;
  font-size: var(--fs-lg);
  font-weight: 650;
  line-height: 1.35;
}

.prep,
.flow-line {
  margin: 20px 0 0;
  color: var(--ink-2);
  font-size: var(--fs-sm);
  line-height: 1.6;
  max-width: 34em;
}

.flow {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 28px;
}

.prep li,
.flow li {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr);
  gap: 14px;
  align-items: start;
}

.prep svg {
  width: 24px;
  height: 24px;
  margin-top: 1px;
  color: var(--accent);
  stroke-width: 1.75;
}

.prep b,
.flow b {
  display: block;
  font-weight: 600;
}

.prep span,
.flow span:not(.flow-n) {
  display: block;
  margin-top: 4px;
  font-size: var(--fs-sm);
  line-height: 1.6;
  color: var(--ink-2);
}

.sub-title {
  margin: 40px 0 12px;
  font-size: var(--fs-md);
  font-weight: 650;
}

.notes {
  margin: 0;
  padding: 0 0 0 1.2em;
  font-size: var(--fs-md);
  line-height: 1.7;
  color: var(--ink-2);
}

.notes li + li {
  margin-top: 10px;
}

.step-screen.consent .notes {
  margin: 28px 0 32px;
}

.flow-n {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: var(--fs-sm);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.more {
  margin-top: 22px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.more summary {
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 52px;
  font-weight: 600;
  color: var(--ink);
  cursor: pointer;
}

.more summary::-webkit-details-marker {
  display: none;
}

.more summary svg {
  width: 20px;
  height: 20px;
  color: var(--ink-3);
  transition: transform 200ms var(--ease);
}

.more[open] summary svg {
  transform: rotate(180deg);
}

.more ul,
.consent ul {
  margin: 0;
  padding: 0 0 14px 1.25em;
  font-size: var(--fs-sm);
  line-height: 1.7;
  color: var(--ink-2);
}

.more li + li,
.consent li + li {
  margin-top: 6px;
}

/* consent: plain list, then the agreements as a single bordered group */
.consent ul {
  padding-bottom: 18px;
}

.consent a {
  color: var(--accent);
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.checks {
  border: 1px solid var(--line);
  border-radius: var(--radius-panel);
  background: var(--surface);
}

.check {
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr);
  gap: 14px;
  align-items: start;
  padding: 16px;
  font-size: var(--fs-md);
  line-height: 1.6;
  cursor: pointer;
}

.check + .check {
  border-top: 1px solid var(--line);
}

.check input {
  appearance: none;
  -webkit-appearance: none;
  width: 24px;
  height: 24px;
  margin: 0;
  border: 2px solid var(--ink-3);
  border-radius: 7px;
  background: var(--surface);
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: background-color 150ms var(--ease), border-color 150ms var(--ease);
}

.check input:checked {
  background: var(--accent);
  border-color: var(--accent);
}

.check input:checked::after {
  content: "";
  width: 6px;
  height: 11px;
  border: solid var(--on-accent);
  border-width: 0 2.5px 2.5px 0;
  transform: translateY(-1px) rotate(45deg);
}

/* ---------- buttons ---------- */
.btn {
  appearance: none;
  position: relative;
  min-height: var(--btn-h);
  padding-inline: 22px;
  border-radius: var(--radius);
  border: 1.5px solid transparent;
  font: 600 var(--fs-md) / 1.2 var(--font);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  -webkit-user-select: none;
  user-select: none;
  transition: background-color 150ms var(--ease), border-color 150ms var(--ease), transform 100ms var(--ease);
}

.btn svg {
  width: 20px;
  height: 20px;
  stroke-width: 2;
  flex-shrink: 0;
}

.btn:active {
  transform: scale(0.985);
}

.btn:disabled {
  background: var(--surface-2);
  border: 1.5px dashed var(--line-strong, #7b8da3); /* clearly "not yet", not a lighter twin of 上一步 */
  color: var(--ink-3);
  cursor: not-allowed;
  transform: none;
}

.btn-primary {
  background: var(--accent);
  color: var(--on-accent);
}

@media (hover: hover) {
  .btn-primary:hover:not(:disabled) {
    background: var(--accent-hover);
  }
  .btn-secondary:hover:not(:disabled),
  .btn-danger:hover:not(:disabled) {
    background: var(--surface-2);
  }
}

.btn-secondary {
  background: var(--surface);
  color: var(--ink);
  border-color: var(--line-strong, #7b8da3); /* a visible edge (about 3:1) */
}

.btn-danger {
  background: var(--surface);
  color: var(--danger);
  border-color: var(--line);
}

.btn-block {
  width: 100%;
}

/* loading: keeps its size, the label gives way to a spinner */
.btn.is-loading {
  color: transparent !important;
  pointer-events: none;
}

.btn.is-loading::after {
  content: "";
  position: absolute;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2.5px solid var(--on-accent);
  border-right-color: transparent;
  animation: spin 800ms linear infinite;
}

.text-btn {
  appearance: none;
  border: 0;
  background: none;
  min-height: 44px;
  padding-inline: 8px;
  margin-inline: -8px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font: 600 var(--fs-sm) / 1 var(--font);
  color: var(--accent);
  border-radius: 10px;
  cursor: pointer;
}

.text-btn svg {
  width: 18px;
  height: 18px;
}

.action-bar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 20;
  padding: 12px var(--gutter) calc(12px + env(safe-area-inset-bottom, 0px));
  background: var(--bg);
  border-top: 1px solid var(--line);
}

.action-bar-inner {
  max-width: 34rem;
  margin: 0 auto;
  display: flex;
  gap: 10px;
}

.action-bar-inner .cancel-btn {
  flex: 0 0 auto;
  min-height: 56px;
  padding: 0 14px;
  color: var(--ink-2, var(--ink));
  font-size: var(--fs-md, 1rem);
}

.action-bar-inner .btn {
  flex: 1 1 0;
  min-width: 0;
}

/* ---------- recording page ---------- */
.rec-head {
  padding-block: 28px 0;
}

.meter {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding-block: 26px 0;
  flex-shrink: 0;
}

.orb {
  position: relative;
  width: 160px;
  height: 160px;
}

.orb svg {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.ring-track {
  fill: none;
  stroke: var(--surface-2);
  stroke-width: 8;
}

.ring-value {
  fill: none;
  stroke: var(--accent);
  stroke-width: 8;
  stroke-linecap: round;
  transition: stroke-dashoffset 500ms var(--ease), stroke 200ms var(--ease);
}

.orb.done .ring-value {
  stroke: var(--success);
}

.ring-center {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.ring-pct {
  font-size: var(--fs-num);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.ring-pct small {
  font-size: var(--fs-lg);
  font-weight: 600;
  margin-left: 2px;
  letter-spacing: 0;
  color: var(--ink-3);
}

.ring-label {
  margin-top: 8px;
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--ink-2); /* readable on the pale circle */
}

.status-slot {
  margin-top: 14px;
  min-height: 52px; /* room for two lines: a longer message does not move the page */
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* a reminder replaces the status text in the same line */
.status-slot:has(.banner:not(.hidden)) .rec-state {
  display: none;
}

.rec-state {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--ink-2);
  text-align: center;
}

.rec-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--line);
  flex-shrink: 0;
}

.rec-dot.on {
  background: var(--recording);
  animation: blink 1.6s ease-in-out infinite; /* state: recording */
}

@keyframes blink {
  50% {
    opacity: 0.4;
  }
}

.banner {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  max-width: 100%;
  padding: 10px 16px;
  border-radius: 999px;
  background: var(--notice-bg);
  color: var(--notice-ink);
  font-size: var(--fs-sm);
  font-weight: 600;
  line-height: 1.4;
  animation: fade-in 200ms var(--ease);
}

.banner svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.banner.good {
  background: var(--success-soft);
  color: var(--success);
}

/* The page without a valid code (ui-light/app.js): an alert mark, the reason, a countdown ring
   back to the home page, one button. The recorder's own colours and type. */
.nosession {
  min-height: 100vh;
  min-height: 100dvh;
  max-width: 26rem;
  margin: 0 auto;
  padding: 48px 24px calc(32px + env(safe-area-inset-bottom, 0px));
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  animation: fade-in 0.35s ease-out both;
}
.ns-mark {
  position: relative;
  width: 84px;
  height: 84px;
  margin-bottom: 26px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: oklch(0.95 0.03 25);
  color: var(--danger);
}
.ns-mark::after {
  /* a slow breath around the mark, as on the recording page */
  content: "";
  position: absolute;
  inset: -10px;
  border-radius: 50%;
  border: 2px solid oklch(0.88 0.06 25);
  animation: ns-breath 2.4s ease-in-out infinite;
}
.ns-mark svg {
  width: 40px;
  height: 40px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.nosession h1 {
  margin: 0;
  font-size: 1.6rem;
  font-weight: 700;
  line-height: 1.3;
  color: var(--ink);
  text-wrap: balance;
}
.ns-body {
  margin: 12px 0 0;
  font-size: 1.05rem;
  line-height: 1.6;
  color: var(--ink);
}
.ns-hint {
  margin: 6px 0 0;
  font-size: 0.95rem;
  line-height: 1.6;
  color: var(--ink-2);
}
.ns-count {
  position: relative;
  width: 72px;
  height: 72px;
  margin: 34px 0 0;
  display: grid;
  place-items: center;
}
.ns-count svg {
  position: absolute;
  inset: 0;
  transform: rotate(-90deg);
}
.ns-count circle {
  fill: none;
  stroke-width: 5;
}
.ns-track {
  stroke: var(--line);
}
.ns-left {
  stroke: var(--accent);
  stroke-linecap: round;
  stroke-dashoffset: 0;
  transition: stroke-dashoffset 1s linear; /* set each second by ui-light/app.js */
}
.ns-count span {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}
.ns-count-label {
  margin: 8px 0 0;
  font-size: 0.9rem;
  color: var(--ink-3);
}
.ns-home {
  display: block;
  width: 100%;
  margin: 30px 0 0;
  padding: 16px;
  border-radius: var(--radius);
  background: var(--accent);
  color: var(--on-accent);
  font-size: 1.05rem;
  font-weight: 600;
  text-decoration: none;
}
.ns-home:hover {
  background: var(--accent-hover);
}
.ns-home:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
}
@keyframes ns-breath {
  0%, 100% { transform: scale(1); opacity: 0.9; }
  50% { transform: scale(1.12); opacity: 0.25; }
}
@media (prefers-reduced-motion: reduce) {
  .nosession, .ns-mark::after { animation: none; }
  .ns-left { transition: none; } /* still steps once a second */
}

@keyframes fade-in {
  from {
    opacity: 0;
  }
}

/* the reading surface: the one panel on the page */
.script {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  margin-top: 18px;
  padding: 10px 18px 4px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-panel);
}

.script-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding-bottom: 4px;
}

.choices {
  display: grid;
  gap: 12px;
}

.choice {
  appearance: none;
  width: 100%;
  display: grid;
  grid-template-columns: 26px minmax(0, 1fr);
  gap: 14px;
  align-items: center;
  min-height: 72px;
  padding: 14px 16px;
  border: 1.5px solid var(--line);
  border-radius: var(--radius-panel);
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: border-color 150ms var(--ease), background-color 150ms var(--ease);
}

.choice svg {
  width: 24px;
  height: 24px;
  color: var(--ink-3);
  stroke-width: 1.75;
}

.choice b {
  display: block;
  font-weight: 650;
}

.choice small {
  display: block;
  margin-top: 2px;
  font-size: var(--fs-sm);
  color: var(--ink-2);
}

.choice[aria-checked="true"] {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.choice[aria-checked="true"] svg {
  color: var(--accent);
}

.mode-now {
  display: flex;
  align-items: baseline;
  gap: 2px;
  min-width: 0;
  white-space: nowrap;
  font-size: var(--fs-sm);
  color: var(--ink-3);
}

.mode-now b {
  color: var(--ink);
  font-weight: 650;
}

.link-btn {
  appearance: none;
  border: 0;
  background: none;
  min-height: 44px;
  padding: 0 8px;
  color: var(--accent);
  font: 600 var(--fs-sm) / 1 var(--font);
  cursor: pointer;
}

.modes {
  display: inline-flex;
  padding: 3px;
  border-radius: 12px;
  background: var(--surface-2);
  min-width: 0;
}

.modes button {
  appearance: none;
  border: 0;
  min-height: 40px;
  padding-inline: 11px;
  border-radius: 9px;
  background: transparent;
  color: var(--ink-2);
  font: 600 var(--fs-sm) / 1 var(--font);
  white-space: nowrap;
  cursor: pointer;
  transition: background-color 150ms var(--ease), color 150ms var(--ease);
}

.modes button[aria-checked="true"] {
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 1px 3px oklch(0.25 0.035 265 / 0.12);
}

.icon-only {
  appearance: none;
  border: 0;
  width: 44px;
  height: 44px;
  margin-right: -10px;
  border-radius: 10px;
  background: none;
  color: var(--ink-2);
  display: grid;
  place-items: center;
  cursor: pointer;
}

.icon-only svg {
  width: 20px;
  height: 20px;
}

.controls {
  flex-shrink: 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  padding-block: 12px 10px;
  border-top: 1px solid var(--line);
}

.toggles {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

/* small, always there; each tap switches to the next choice */
.toggle {
  appearance: none;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 44px;
  padding-inline: 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink-2);
  font: 500 var(--fs-sm) / 1 var(--font);
  white-space: nowrap;
  cursor: pointer;
  transition: background-color 150ms var(--ease), border-color 150ms var(--ease);
}

.toggle b {
  color: var(--ink);
  font-size: var(--fs-sm);
  font-weight: 650;
}

.toggle:active {
  background: var(--surface-2);
}

.seg-ctl {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.ctl-label {
  font-size: var(--fs-xs);
  font-weight: 600;
  color: var(--ink-3);
}

/* three-way choice, like iOS segmented controls */
.seg-ctl .seg {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 2px;
  padding: 3px;
  border-radius: 12px;
  background: var(--surface-2);
}

.seg-ctl .seg button {
  appearance: none;
  border: 0;
  min-width: 0;
  min-height: 42px;
  border-radius: 9px;
  background: transparent;
  color: var(--ink-2);
  font: 600 var(--fs-md) / 1 var(--font);
  cursor: pointer;
  transition: background-color 150ms var(--ease), color 150ms var(--ease), box-shadow 150ms var(--ease);
}

.seg-ctl .seg button[aria-checked="true"] {
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 1px 2px oklch(0.25 0.035 265 / 0.08), 0 2px 6px oklch(0.25 0.035 265 / 0.1);
}

.pane {
  flex: 1 1 auto;
  min-height: 140px;
  overflow-y: auto;
  padding-block: 8px;
}

.pane-hint {
  margin: 0 0 14px;
  font-size: var(--fs-sm);
  color: var(--ink-2);
}

.topics {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

/* the same size for every topic: title and one hint line */
.topics li {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-height: 84px;
  padding: 12px 14px;
  border-radius: 14px;
  background: var(--surface-2);
}

.topics b {
  font-size: var(--fs-md);
  font-weight: 650;
  line-height: 1.35;
}

.topics span {
  font-size: var(--fs-xs);
  line-height: 1.5;
  color: var(--ink-2);
}

.more-topics {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 6px;
  margin-left: -8px;
}

.more-topics svg {
  width: 16px;
  height: 16px;
}

#countPane {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

#countPane .pane-hint {
  align-self: stretch;
  text-align: left;
}

.count-now {
  margin-top: auto;
  font-size: 5.5rem;
  font-weight: 700;
  line-height: 1;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

.count-next {
  margin: 10px 0 auto;
  font-size: var(--fs-lg);
  letter-spacing: 0.3em;
  color: var(--ink-3);
  font-variant-numeric: tabular-nums;
}

.script-head > span {
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--ink-3);
}

#teleprompter {
  position: relative;
  flex: 1 1 auto;
  min-height: 140px;
  overflow: hidden;
  -webkit-mask-image: linear-gradient(to bottom, transparent 0, #000 16%, #000 82%, transparent 100%);
  mask-image: linear-gradient(to bottom, transparent 0, #000 16%, #000 82%, transparent 100%);
}

#teleprompterContent {
  white-space: pre-wrap;
  line-height: 1.75;
  color: var(--ink);
}

#player {
  display: block;
  width: 100%;
  margin-top: 16px;
}

#debugStats {
  margin-top: 12px;
  font-size: var(--fs-xs);
  color: var(--ink-3);
  text-align: center;
  font-variant-numeric: tabular-nums;
  word-break: break-word;
}

/* ---------- bottom sheets: settings, dialogs, waiting ---------- */
.sheet-backdrop,
#overlay {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: var(--scrim);
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

#overlay {
  z-index: 50;
  display: none;
}

#overlay-content {
  width: 100%;
  max-width: 34rem;
}

.sheet,
.dialog,
.waiting {
  width: 100%;
  background: var(--surface);
  border-radius: var(--radius-sheet) var(--radius-sheet) 0 0;
  box-shadow: var(--shadow-sheet);
  padding: 12px 24px calc(24px + env(safe-area-inset-bottom, 0px));
  animation: rise 240ms var(--ease);
}

.grip {
  width: 40px;
  height: 4px;
  border-radius: 2px;
  background: var(--line);
  margin: 0 auto 20px;
}

.sheet h2,
.sheet h3,
.dialog h2 {
  margin: 0 0 8px;
  font-size: var(--fs-lg);
  font-weight: 700;
  line-height: 1.35;
}

.dialog {
  text-align: center;
}

.dialog-icon {
  width: 48px;
  height: 48px;
  margin: 2px auto 14px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--notice-bg);
  color: var(--notice-ink);
}

.dialog-icon.done {
  background: var(--success-soft);
  color: var(--success);
}

.dialog-icon.problem {
  background: oklch(0.95 0.03 25);
  color: var(--danger);
}

.dialog-icon svg {
  width: 24px;
  height: 24px;
}

.dialog-body {
  margin: 0 auto;
  max-width: 24em;
  color: var(--ink-2);
  line-height: 1.65;
}

.dialog-note {
  margin: 8px auto 0;
  max-width: 24em;
  font-size: var(--fs-sm);
  line-height: 1.6;
  color: var(--ink-3);
}

.dialog-actions {
  margin-top: 22px;
  display: grid;
  gap: 10px;
}

.setting {
  padding-block: 16px;
  border-top: 1px solid var(--line);
}

.setting:last-of-type {
  margin-bottom: 20px;
}

.setting-row {
  display: flex;
  justify-content: space-between;
  margin-bottom: 14px;
}

.setting-row output {
  color: var(--ink-2);
  font-variant-numeric: tabular-nums;
}

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  border-radius: 3px;
  background: linear-gradient(to right, var(--accent) var(--fill, 0%), var(--surface-2) var(--fill, 0%));
  outline-offset: 6px;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--surface);
  border: 2px solid var(--accent);
  cursor: pointer;
}

input[type="range"]::-moz-range-thumb {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--surface);
  border: 2px solid var(--accent);
  cursor: pointer;
}

.waiting {
  padding-top: 28px;
}

.waiting-row {
  display: flex;
  align-items: center;
  gap: 14px;
}

.spinner {
  width: 24px;
  height: 24px;
  flex-shrink: 0;
  border-radius: 50%;
  border: 3px solid var(--accent-soft);
  border-top-color: var(--accent);
  animation: spin 800ms linear infinite;
}

.waiting-text {
  font-size: var(--fs-lg);
  line-height: 1.5;
}

.bar {
  margin-top: 22px;
  height: 8px;
  border-radius: 4px;
  background: var(--surface-2);
  overflow: hidden;
}

.bar > i {
  display: block;
  height: 100%;
  width: 0;
  border-radius: 4px;
  background: var(--accent);
  transition: width 300ms var(--ease);
}

.bar-meta {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 8px;
  font-size: var(--fs-sm);
  color: var(--ink-2);
  font-variant-numeric: tabular-nums;
}
.bar-pct {
  margin-left: auto;
  color: var(--ink-3);
  text-align: right;
}
.waiting-hint {
  margin-top: 14px;
  font-size: var(--fs-sm);
  color: var(--ink-3);
  text-align: center;
}

.countdown {
  position: fixed;
  inset: 0;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: var(--gutter);
  text-align: center;
}

.countdown-num {
  font-size: 6rem;
  font-weight: 700;
  line-height: 1;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}

.countdown-text {
  font-size: var(--fs-lg);
  color: var(--ink-2);
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes rise {
  from {
    transform: translateY(24px);
    opacity: 0.5;
  }
}

@media (min-width: 600px) {
  .sheet-backdrop,
  #overlay {
    align-items: center;
  }
  .sheet,
  .dialog,
  .waiting {
    border-radius: var(--radius-sheet);
    max-width: 28rem;
    margin-inline: auto;
  }
}

/* ---------- icons: drawn inline, one stroke weight, always beside a word ---------- */
.ic {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ---------- preparation: a vertical timeline, an icon in each circle, a line joining them ---------- */
.prep {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0;
}
.prep li {
  position: relative;
  grid-template-columns: 44px minmax(0, 1fr);
  gap: 14px;
  padding-bottom: 22px;
}
.prep li:last-child { padding-bottom: 0; }
/* the line from this circle down to the next */
.prep li:not(:last-child)::before {
  content: "";
  position: absolute;
  left: 21px;
  top: 46px;
  bottom: 0;
  width: 2px;
  background: color-mix(in oklab, var(--brand-blue, var(--accent)) 35%, transparent);
}
.prep .node {
  margin-top: 0;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--surface);
  border: 2px solid var(--brand-blue, var(--accent));
  color: var(--brand-blue, var(--accent));
}
.node .ic { width: 22px; height: 22px; }
.prep b { line-height: 1.45; padding-top: 2px; }
.prep div span { margin-top: 2px; }

/* ---------- how it goes: four numbered circles on one line ---------- */
.steps {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
}
.flow-caption {
  margin: 14px 0 0;
  font-size: var(--fs-sm);
  line-height: 1.6;
  color: var(--ink-2);
}
.consent-hint {
  margin: 12px 2px 0;
  font-size: var(--fs-sm);
  color: var(--ink-3);
}
.steps li {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 2px;
  min-width: 0;
}
/* the line joining this circle to the next */
.steps li:not(:last-child)::after {
  content: "";
  position: absolute;
  top: 15px;
  left: calc(50% + 20px);
  right: calc(-50% + 20px);
  height: 2px;
  background: color-mix(in oklab, var(--brand-blue, var(--accent)) 35%, transparent);
}
.step-n {
  width: 32px;
  height: 32px;
  margin-bottom: 6px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  border: 2px solid var(--brand-blue, var(--accent));
  color: #126d94; /* the number is text: darkened brand blue (5.5:1) */
  font-size: var(--fs-sm);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.steps b { font-size: var(--fs-sm); font-weight: 650; }
.steps small { font-size: var(--fs-xs); color: var(--ink-2); line-height: 1.45; }
.step-screen .sub-title { margin: 30px 0 14px; }

/* ---------- page 1, sized for older readers: name -> explanation hierarchy, larger type ---------- */
.step-screen h1 { font-size: 1.75rem; }                       /* 28 */
.prep li { gap: 14px; padding-bottom: 20px; }
.prep b { font-size: 1.0625rem; color: var(--ink); }          /* 17, dark: the item's name */
.prep div span { font-size: var(--fs-md); color: var(--ink-2); line-height: 1.55; } /* 16 */
.prep li:not(:last-child)::before {
  background: color-mix(in oklab, var(--brand-blue, var(--accent)) 18%, transparent); /* lighter than the steps */
}
.step-n { width: 36px; height: 36px; font-size: var(--fs-md); }
.steps { column-gap: 6px; }
.steps li:not(:last-child)::after { top: 17px; left: calc(50% + 22px); right: calc(-50% + 22px); }
.steps b { font-size: var(--fs-md); }
/* the one practical rule: as large as the body, dark, with a small mark */
.flow-caption {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin-top: 18px;
  font-size: var(--fs-md);
  color: var(--ink);
}
.flow-caption .ic { width: 18px; height: 18px; margin-top: 3px; color: var(--brand-blue, var(--accent)); }

/* the toggles: an icon for what it changes, then the value */
.toggle .ic { width: 18px; height: 18px; color: var(--ink-2); }

/* the three ways to speak: one group, rows split by a rule, a radio mark at the end */
.choices {
  gap: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius-panel);
  background: var(--surface);
  overflow: hidden;
}
.choice {
  grid-template-columns: 36px minmax(0, 1fr) 22px;
  min-height: 68px;
  border: 0;
  border-radius: 0;
  background: none;
}
.choice + .choice { border-top: 1px solid var(--line); }
.choice[aria-checked="true"] { border-color: var(--line); background: none; }
.radio {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 1.5px solid var(--ink-3);
  display: grid;
  place-items: center;
}
.choice[aria-checked="true"] .radio { border-color: var(--brand-blue, var(--accent)); }
.choice[aria-checked="true"] .radio::after {
  content: "";
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--brand-blue, var(--accent));
}
.choice:active { background: var(--surface-2); }
.choice-ic {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--surface-2);
  color: var(--ink-2);
}
.choice[aria-checked="true"] .choice-ic {
  background: var(--accent-soft);
  color: #126d94; /* darkened brand blue: 3:1 or more on the soft fill */
}

/* free-talk topics: a short list, not a grid of tiles */
.topics {
  display: block;
  border-top: 1px solid var(--line);
}
.topics li {
  min-height: 0;
  padding: 11px 0;
  gap: 2px;
  border-radius: 0;
  background: none;
  border-bottom: 1px solid var(--line);
}
.topics span { font-size: var(--fs-sm); }

/* dialogs: read top to bottom like a letter, the title carries the tone */
.dialog { text-align: left; }
.dialog-body,
.dialog-note { margin-left: 0; margin-right: 0; }
.dialog h2.problem { color: var(--danger); }
.dialog h2.done { color: var(--success); }

.banner { justify-content: center; }

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }
  /* except what tells the person something is happening: the loading spinners keep turning
     (slower) and the recording dot keeps blinking */
  .spinner,
  .btn.is-loading::after {
    animation: spin 1.6s linear infinite !important;
  }
  .rec-dot.on {
    animation: blink 2.4s ease-in-out infinite !important;
  }
}

/* ---------- accessibility and touch ---------- */
.sr-only {
  position: absolute !important;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}
.btn, .choice, .toggle, .link-btn, .check {
  touch-action: manipulation; /* no double-tap zoom on repeated taps */
}
.link-btn:active,
.toggle:active {
  opacity: 0.6; /* a tap shows (the browser's tap highlight is off) */
}
.choice:focus-visible {
  outline-offset: -3px; /* inside the row: the group clips anything outside */
}
.step-screen h1:focus {
  outline: none; /* focused for screen readers when the step changes, not a control */
}
.sheet-done {
  margin-top: 16px;
}
/* a step taller than the screen: fade the bottom edge so it is clear there is more */
.step-screen.can-scroll {
  -webkit-mask-image: linear-gradient(to bottom, #000 calc(100% - 40px), transparent);
  mask-image: linear-gradient(to bottom, #000 calc(100% - 40px), transparent);
}
/* ---------- each instruction step fits its screen, no scrolling ----------
   app.js lowers --fit (1 -> 0.6) until the step fits the space above the button bar; spacing and
   type scale with it, never below readable sizes (body 14 px, item names 15 px). */
#instruction { --fit: 1; }
#instruction .stepper { padding-block: calc(28px * var(--fit)) 0; }
#instruction .step-screen { padding-block: calc(28px * var(--fit)) calc(16px * var(--fit)); }
#instruction .eyebrow { margin-bottom: calc(6px * var(--fit)); }
#instruction .step-screen h1 { font-size: max(1.25rem, calc(1.75rem * var(--fit))); }
#instruction .lead { margin-top: calc(8px * var(--fit)); }
#instruction .prep { margin-top: calc(22px * var(--fit)); }
#instruction .prep li {
  grid-template-columns: calc(44px * var(--fit)) minmax(0, 1fr);
  gap: calc(14px * var(--fit));
  padding-bottom: calc(20px * var(--fit));
}
#instruction .prep li:last-child { padding-bottom: 0; }
#instruction .prep .node { width: calc(44px * var(--fit)); height: calc(44px * var(--fit)); }
#instruction .prep .node .ic { width: calc(22px * var(--fit)); height: calc(22px * var(--fit)); }
#instruction .prep li:not(:last-child)::before { left: calc(22px * var(--fit) - 1px); top: calc(44px * var(--fit) + 2px); }
#instruction .prep b { font-size: max(15px, calc(17px * var(--fit))); }
#instruction .prep div span { font-size: max(14px, calc(16px * var(--fit))); }
#instruction .sub-title { margin: calc(30px * var(--fit)) 0 calc(14px * var(--fit)); }
#instruction .step-n { width: calc(36px * var(--fit)); height: calc(36px * var(--fit)); margin-bottom: calc(6px * var(--fit)); }
#instruction .steps li:not(:last-child)::after { top: calc(18px * var(--fit) - 1px); left: calc(50% + 20px * var(--fit) + 2px); right: calc(-50% + 20px * var(--fit) + 2px); }
#instruction .steps b { font-size: max(14px, calc(16px * var(--fit))); }
#instruction .flow-caption { margin-top: calc(18px * var(--fit)); font-size: max(14px, calc(16px * var(--fit))); }
#instruction .step-screen.consent .notes { margin: calc(28px * var(--fit)) 0 calc(28px * var(--fit)); font-size: max(14px, calc(16px * var(--fit))); }
#instruction .notes li + li { margin-top: calc(10px * var(--fit)); }
#instruction .check { padding: calc(16px * var(--fit)) 16px; font-size: max(14px, calc(16px * var(--fit))); }
#instruction .choice { min-height: calc(68px * var(--fit)); padding-block: calc(14px * var(--fit)); }
/* no scrollbar on the steps (they are sized to fit; a fade still shows if a tiny screen overflows) */
.step-screen { scrollbar-width: none; }
.step-screen::-webkit-scrollbar { display: none; }

/* ---------- plain preparation icons: no circles, no connecting line (only the 录音流程 steps
   are a sequence, so only they get numbered circles joined by a line) ---------- */
#instruction .prep .node {
  border: 0;
  background: none;
  border-radius: 0;
  align-self: start;
  justify-items: start;
  padding-top: 1px;
  color: #126d94;
}
#instruction .prep li:not(:last-child)::before { display: none; }

/* ---------- page 2: what happens to the voice ---------- */
#instruction .prep.privacy { margin-top: calc(18px * var(--fit)); }
#instruction .consent .checks { margin-top: calc(24px * var(--fit)); }

/* ---------- page 3: choosing what to say ---------- */
/* 7: plain icons, as on pages 1 and 2; blue when chosen */
.choice-ic { background: none; border-radius: 0; width: 26px; color: var(--ink-2); }
.choice[aria-checked="true"] .choice-ic { background: none; color: #126d94; }
.choice { grid-template-columns: 26px minmax(0, 1fr) 22px; }
/* 8: the chosen row is tinted, not only its radio dot */
.choice[aria-checked="true"] { background: #eef8fd; }
/* 3: the 推荐 tag */
.choice .tag {
  display: inline-block;
  margin-left: 8px;
  padding: 1px 8px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: #126d94;
  font-size: 13px;
  font-weight: 600;
  vertical-align: 1px;
}

/* ---------- page 3: the three rows fill the screen; text follows --fit (up to 1.15 on tall screens) ---------- */
#instruction .choice b { font-size: max(16px, calc(16px * var(--fit))); }
#instruction .choice small { font-size: max(14px, calc(15px * var(--fit))); }
#instruction .step-screen[data-step="3"] { display: flex; flex-direction: column; }
#instruction .step-screen[data-step="3"] .choices {
  flex: 1 1 auto;
  max-height: 560px;   /* up to about 185 px a row: taller looks empty */
  margin-bottom: 8px;
  grid-template-rows: repeat(3, minmax(0, 1fr));
}
#instruction .step-screen[data-step="3"].measuring .choices { flex: none; }

/* free talk: "换一组" sits in the panel header, on the right */
.script-head .more-topics { margin: 0 -8px 0 0; }

/* toggles: plain text, no button outline: an icon, then the value underlined (still a 44 px tap area) */
.toggle { gap: 5px; min-height: 44px; padding-inline: 6px; border: 0; background: none; border-radius: 10px; }
.toggles { gap: 10px; }
.toggle .ic { width: 17px; height: 17px; color: var(--ink-2); }
.toggle .t-v {
  font-size: 15px;
  font-weight: 650;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  text-decoration: underline;
  text-decoration-color: #7b8da3;
  text-decoration-thickness: 1.5px;
  text-underline-offset: 5px;
}

/* ring before the first tap: a microphone in place of "0% 录音进度"; the whole circle is a start button */
.ring-idle {
  appearance: none; position: absolute; inset: 0; z-index: 1; display: none;
  align-items: center; justify-content: center;
  border: 0; border-radius: 50%; background: none; padding: 0; cursor: pointer;
  color: #126d94; -webkit-tap-highlight-color: transparent;
  transition: transform 150ms var(--ease);
}
.ring-idle:active { transform: scale(0.96); }
.ring-idle:focus-visible { outline: 2px solid #126d94; outline-offset: 4px; }
.ring-idle .ic { width: 40px; height: 40px; transform: none; stroke-width: 1.75; } /* not the ring's -90deg turn (.orb svg) */
.orb.is-idle .ring-idle { display: flex; }
.orb.is-idle .ring-center { visibility: hidden; }

/* dialogs: a clearer body line, the note set apart, more room above the buttons */
.dialog { padding-top: 24px; }
.dialog h2 { margin-bottom: 10px; }
.dialog-body { color: var(--ink); font-size: 17px; line-height: 1.65; }
.dialog-note { margin-top: 12px; color: var(--ink-2); font-size: var(--fs-sm); }
.dialog-actions { margin-top: 26px; }

/* dialog and sheet titles take focus only so a screen reader starts there: no outline */
#overlay h2:focus, .sheet h2:focus { outline: none; }

/* a failed recording (e.g. "这台手机的麦克风声音偏小"): the full ring stays neutral, not the green of success */
:root[data-style] .orb.failed .ring-value { stroke: var(--ink-3); } /* above the theme's blue and green */
:root[data-style="recharge-breath"] .orb.done.failed .pulse-core { background: var(--surface-2); border-color: var(--line); }
:root[data-style="recharge-breath"] .orb.done.failed .pulse-halo { background: none; }
