:root {
  --red: #e4002b;
  --red-dark: #9b0018;
  --red-mid: #c8102e;
  --ink: #2a1618;
  --muted: #6b4a4e;
  --line: #ead4d6;
  --card: #fff;
  --soft: #fffdfd;
  --wash: #f7ecee;
  --tab-h: 72px;
  --shadow: 0 10px 30px rgba(42, 22, 24, 0.05);
  --radius: 18px;
}

*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  background:
    radial-gradient(900px 420px at 50% -80px, rgba(228, 0, 43, 0.10), transparent 60%),
    linear-gradient(180deg, #f7ecee 0%, #fffdfd 38%, #ffffff 100%);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Noto Sans SC", "Microsoft YaHei", sans-serif;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body {
  min-height: 100dvh;
}

button, input, textarea, select {
  font: inherit;
  color: inherit;
}

button {
  appearance: none;
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
}

button:disabled {
  cursor: default;
  opacity: 0.55;
}

a { color: var(--red); }

:focus { outline: none; }

:focus-visible {
  outline: 2px solid var(--red);
  outline-offset: 3px;
}

.shell {
  width: 100%;
  max-width: 100%;
  min-height: 100dvh;
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}

.top {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 22px 10px;
  padding-top: max(14px, env(safe-area-inset-top));
  background: transparent;
  min-height: 52px;
}

.wordmark {
  font-family: Georgia, "Times New Roman", ui-serif, serif;
  font-size: 20px;
  letter-spacing: 0.12em;
  font-weight: 500;
  color: var(--ink);
  line-height: 1;
}

.wordmark span {
  color: var(--red);
  letter-spacing: 0.12em;
}

.timer {
  font-variant-numeric: tabular-nums;
  font-size: 13px;
  letter-spacing: 0.08em;
  color: var(--muted);
  min-height: 32px;
  display: inline-flex;
  align-items: center;
  padding: 0 2px;
  white-space: nowrap;
}

.timer.is-low { color: var(--red-dark); }

.main {
  flex: 1 1 auto;
  width: 100%;
  padding: 6px 22px 28px;
  padding-bottom: calc(28px + env(safe-area-inset-bottom));
  overflow-x: hidden;
  overflow-y: auto;
}

.tabs {
  flex: 0 0 auto;
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 0;
  min-height: var(--tab-h);
  padding: 6px 10px calc(8px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  background: rgba(255, 253, 253, 0.96);
}

.tab {
  min-height: 48px;
  padding: 8px 6px;
  color: var(--muted);
  font-size: 13px;
  letter-spacing: 0.06em;
  border-radius: 12px;
}

.tab.is-on {
  color: var(--red-dark);
  font-weight: 600;
  position: relative;
}

.tab.is-on::after {
  content: "";
  display: block;
  width: 18px;
  height: 2px;
  margin: 6px auto 0;
  background: var(--red);
  border-radius: 2px;
}

.kicker {
  margin: 0 0 8px;
  font-size: 12px;
  letter-spacing: 0.14em;
  color: var(--muted);
}

h1, h2, p { margin: 0; }

.display {
  font-size: 26px;
  font-weight: 600;
  letter-spacing: 0.02em;
  line-height: 1.3;
}

.lead {
  margin-top: 10px;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.7;
}

.scene {
  margin: 22px 0 28px;
  padding: 22px 22px 20px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.scene .en-title {
  margin-top: 6px;
  font-family: Georgia, "Times New Roman", ui-serif, serif;
  font-size: 18px;
  color: var(--muted);
}

.choices {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 0 0 18px;
}

.choice {
  text-align: left;
  width: 100%;
  min-height: 72px;
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--card);
}

.choice:hover { border-color: #e0bec2; }

.choice.is-on {
  border-color: var(--red);
  background: var(--soft);
  box-shadow: 0 0 0 1px var(--red);
}

.choice-min {
  font-size: 16px;
  font-weight: 600;
}

.choice-note {
  margin-top: 4px;
  font-size: 13px;
  line-height: 1.55;
  color: var(--muted);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 48px;
  padding: 12px 18px;
  border-radius: 14px;
  background: var(--red);
  color: #fff;
  font-size: 16px;
  font-weight: 600;
  letter-spacing: 0.04em;
}

.btn:hover { background: var(--red-mid); }

.btn:disabled { background: #d8b4b8; color: #fff; }

.btn-soft {
  background: var(--wash);
  color: var(--red-dark);
}

.btn-soft:hover { background: #f3e0e3; }

.btn-line {
  background: transparent;
  color: var(--red-dark);
  border: 1px solid var(--line);
}

.btn-line:hover { background: var(--soft); }

.btn-text {
  width: auto;
  min-height: 44px;
  padding: 8px 4px;
  background: transparent;
  color: var(--red-dark);
  font-size: 14px;
  font-weight: 500;
  letter-spacing: 0.04em;
}

.row-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 22px;
}

.row-actions.inline {
  flex-direction: row;
  gap: 10px;
}

.row-actions.inline .btn { width: auto; flex: 1; }

.step-rail {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin: 4px 0 18px;
}

.step-index {
  font-size: 13px;
  letter-spacing: 0.12em;
  color: var(--muted);
}

.dots {
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #ebd4d6;
}

.dot.is-done { background: var(--red-mid); }
.dot.is-now { background: var(--red); box-shadow: 0 0 0 3px rgba(228, 0, 43, 0.15); }

.panel {
  padding: 4px 0 0;
}

.en {
  font-family: Georgia, "Times New Roman", ui-serif, serif;
  font-size: 22px;
  line-height: 1.5;
  font-weight: 400;
  overflow-wrap: anywhere;
}

.en.sm { font-size: 19px; }

.zh {
  margin-top: 8px;
  font-size: 14px;
  line-height: 1.7;
  color: var(--muted);
}

.note {
  margin-top: 14px;
  font-size: 14px;
  line-height: 1.7;
  color: var(--muted);
}

.lines {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.line {
  padding: 14px 16px 12px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: var(--card);
  text-align: left;
  width: 100%;
}

.line.is-you {
  background: var(--soft);
}

.line.is-on {
  border-color: var(--red);
  box-shadow: 0 0 0 1px var(--red);
}

.role {
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 6px;
}

.line-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  flex-wrap: wrap;
}

.play {
  min-height: 44px;
  min-width: 44px;
  padding: 0 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--red-dark);
  font-size: 13px;
  letter-spacing: 0.04em;
  background: #fff;
}

.play:disabled {
  color: var(--muted);
}

.hint-voice {
  margin: 0 0 14px;
  padding: 12px 14px;
  background: var(--wash);
  border-radius: 12px;
  font-size: 13px;
  line-height: 1.6;
  color: var(--muted);
}

mark.hl {
  background: var(--wash);
  color: inherit;
  border-bottom: 1.5px solid var(--red);
  padding: 0 0.06em;
  border-radius: 2px;
}

.context {
  margin-bottom: 16px;
}

.context .label {
  font-size: 12px;
  letter-spacing: 0.1em;
  color: var(--muted);
  margin-bottom: 8px;
}

.chunk-card {
  padding: 8px 0 4px;
}

.counter {
  font-size: 12px;
  letter-spacing: 0.12em;
  color: var(--muted);
  margin-bottom: 10px;
}

.prompt-card,
.ref-card {
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--card);
  margin-bottom: 14px;
}

.field {
  width: 100%;
  min-height: 88px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
  resize: vertical;
  line-height: 1.6;
}

.field:focus-visible {
  outline: 2px solid var(--red);
  outline-offset: 2px;
  border-color: transparent;
}

.field-label {
  display: block;
  margin: 4px 0 8px;
  font-size: 13px;
  color: var(--muted);
}

.wrap {
  padding-top: 18px;
}

.wrap .display { margin-bottom: 10px; }

.stat-list {
  list-style: none;
  margin: 22px 0 0;
  padding: 0;
  border-top: 1px solid var(--line);
}

.stat-list li {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
  font-size: 15px;
}

.stat-list .k { color: var(--muted); }
.stat-list .v { text-align: right; overflow-wrap: anywhere; }

.pile {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 18px;
}

.pill {
  padding: 12px 14px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
}

.empty {
  margin-top: 32px;
  color: var(--muted);
  line-height: 1.7;
  font-size: 15px;
}

.set-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 0;
  border-bottom: 1px solid var(--line);
  min-height: 56px;
}

.set-row label { flex: 1; }

.set-help {
  margin-top: 18px;
  font-size: 13px;
  line-height: 1.7;
  color: var(--muted);
}

input[type="range"] {
  width: 140px;
  accent-color: var(--red);
}

input[type="checkbox"] {
  width: 20px;
  height: 20px;
  accent-color: var(--red);
  flex: 0 0 auto;
}

.dialog {
  margin-top: 16px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--soft);
}

.dialog p { margin-bottom: 12px; line-height: 1.6; }

@media (min-width: 900px) {
  body {
    background:
      radial-gradient(1200px 520px at 50% -120px, rgba(228, 0, 43, 0.11), transparent 58%),
      linear-gradient(180deg, #f4e6e8 0%, #fbf6f6 40%, #ffffff 100%);
  }

  .shell {
    width: min(480px, calc(100% - 48px));
    margin: 0 auto;
    min-height: 100dvh;
    background:
      linear-gradient(180deg, rgba(247, 236, 238, 0.65) 0%, #fffdfd 28%, #ffffff 100%);
    box-shadow:
      0 0 0 1px rgba(42, 22, 24, 0.04),
      0 30px 80px rgba(42, 22, 24, 0.07);
  }

  .main { padding-left: 28px; padding-right: 28px; }
  .top { padding-left: 28px; padding-right: 28px; }
}

@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; transition: none !important; }
}
