:root {
  --paper: oklch(97% 0.015 75);
  --surface: oklch(99.5% 0.006 75);
  --ink: oklch(24% 0.03 45);
  --muted: oklch(52% 0.03 55);
  --accent: oklch(64% 0.17 42);        /* tangerine */
  --accent-deep: oklch(52% 0.16 38);
  --accent-soft: oklch(92% 0.05 55);
  --ok: oklch(58% 0.13 150);
  --ok-soft: oklch(93% 0.06 150);
  --bad: oklch(58% 0.17 25);
  --bad-soft: oklch(93% 0.07 30);
  --line: oklch(89% 0.015 65);
  --radius: 20px;
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
  --shadow-sm: 0 1px 2px oklch(30% 0.03 55 / 0.05), 0 6px 18px oklch(30% 0.03 55 / 0.07);
  --shadow-lg: 0 2px 6px oklch(30% 0.03 55 / 0.08), 0 18px 44px oklch(30% 0.03 55 / 0.12);
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

body {
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(130% 80% at 100% -5%, oklch(94% 0.05 60) 0%, transparent 52%),
    radial-gradient(120% 90% at -10% 100%, oklch(93% 0.05 30) 0%, transparent 48%),
    var(--paper);
  min-height: 100dvh;
  line-height: 1.5;
}

.wrap { max-width: 620px; margin: 0 auto; padding: calc(env(safe-area-inset-top) + 1.2rem) 1.1rem 3rem; }
.hidden { display: none !important; }

/* ---------- Masthead ---------- */
.masthead { padding: 1rem 0 1.4rem; }
.brand { display: flex; align-items: center; gap: 0.5rem; font-weight: 700; }
.brand .dot { font-size: 1.5rem; }
.brand-name { font-size: 1.05rem; letter-spacing: 0.02em; color: var(--accent-deep); }

.headline {
  font-family: "Fraunces", Georgia, serif;
  font-weight: 600; font-size: clamp(1.9rem, 1.1rem + 3.4vw, 2.9rem);
  line-height: 1.08; letter-spacing: -0.015em; margin-top: 1.1rem;
}
.headline em { font-style: italic; color: var(--accent); }
.dek { color: var(--muted); font-size: 1.02rem; max-width: 40ch; margin-top: 0.85rem; }

.pick-title {
  font-family: "Fraunces", serif; font-weight: 600; font-size: 1.05rem;
  margin: 1.6rem 0 0.8rem; color: var(--muted);
}

/* ---------- Language cards ---------- */
.lang-grid { display: grid; gap: 0.75rem; }
.lang-card {
  display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 0.9rem;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 1rem 1.05rem; cursor: pointer; text-align: left; width: 100%;
  box-shadow: var(--shadow-sm); transition: transform 0.25s var(--ease), box-shadow 0.25s var(--ease), border-color 0.25s var(--ease);
}
.lang-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); border-color: var(--accent-soft); }
.lang-card:active { transform: translateY(-1px) scale(0.995); }
.lang-flag { font-size: 2rem; line-height: 1; }
.lang-meta { display: flex; flex-direction: column; }
.lang-name { font-weight: 700; font-size: 1.12rem; }
.lang-native { font-family: "Noto Serif SC", "Fraunces", serif; color: var(--muted); font-size: 0.95rem; }
.lang-badge { font-size: 0.72rem; font-weight: 600; padding: 0.32rem 0.6rem; border-radius: 999px; white-space: nowrap; }
.lang-badge.full { background: var(--ok-soft); color: var(--ok); }
.lang-badge.limited { background: var(--accent-soft); color: var(--accent-deep); }

.fineprint { color: var(--muted); font-size: 0.8rem; margin-top: 1.3rem; text-align: center; }

/* ---------- Banners ---------- */
.banner {
  background: var(--bad-soft); color: var(--bad); border-radius: 14px;
  padding: 0.75rem 0.9rem; font-size: 0.9rem; margin: 0.9rem 0;
}
.banner.soft { background: var(--accent-soft); color: var(--accent-deep); }

/* ---------- Session header ---------- */
.session-head { display: flex; align-items: center; gap: 0.7rem; padding: 0.4rem 0 1rem; }
.ghost {
  appearance: none; border: 1px solid var(--line); background: var(--surface);
  width: 40px; height: 40px; border-radius: 12px; cursor: pointer; font-size: 1.15rem;
  color: var(--ink); box-shadow: var(--shadow-sm); flex: 0 0 auto;
}
.scene-meta { flex: 1 1 auto; min-width: 0; }
.scene-title { font-family: "Fraunces", serif; font-weight: 600; font-size: 1.15rem; }
.scene-sub { color: var(--muted); font-size: 0.85rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.roman-switch { display: flex; align-items: center; gap: 0.4rem; font-size: 0.78rem; color: var(--muted); cursor: pointer; }
.roman-switch input { accent-color: var(--accent); width: 16px; height: 16px; }

/* ---------- Chat feed ---------- */
.feed { display: flex; flex-direction: column; gap: 0.85rem; padding-bottom: 1rem; }
.bubble {
  border-radius: var(--radius); padding: 0.85rem 1rem; box-shadow: var(--shadow-sm);
  animation: rise 0.4s var(--ease); max-width: 88%;
}
@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
.bubble.tutor { background: var(--surface); border: 1px solid var(--line); align-self: flex-start; border-bottom-left-radius: 6px; }
.bubble.learner { background: var(--accent); color: oklch(99% 0.01 75); align-self: flex-end; border-bottom-right-radius: 6px; }
.bubble .who { font-size: 0.72rem; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; opacity: 0.65; margin-bottom: 0.3rem; }
.line-native { font-family: "Noto Serif SC", "Fraunces", serif; font-size: 1.5rem; font-weight: 500; line-height: 1.3; }
.bubble.learner .line-native { font-weight: 600; }
.line-roman { color: var(--accent-deep); font-size: 0.9rem; margin-top: 0.15rem; }
.line-en { color: var(--muted); font-size: 0.88rem; margin-top: 0.2rem; }
.bubble.learner .line-en { color: oklch(97% 0.02 75 / 0.85); }
.replay { margin-top: 0.5rem; }

.bubble.done { align-self: center; text-align: center; background: var(--surface); border: 1px solid var(--line); display: flex; flex-direction: column; gap: 0.6rem; align-items: center; padding: 1.4rem; max-width: 100%; width: 100%; }
.done-emoji { font-size: 2.2rem; }
.done-title { font-family: "Fraunces", serif; font-weight: 600; font-size: 1.15rem; }

/* ---------- Prompt / mic panel ---------- */
.prompt {
  position: sticky; bottom: 0.6rem; margin-top: 0.4rem;
  background: var(--surface); border: 1px solid var(--line); border-radius: 22px;
  padding: 1.05rem 1.1rem 1.15rem; box-shadow: var(--shadow-lg);
}
.prompt-label { font-size: 0.74rem; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; color: var(--accent); margin-bottom: 0.45rem; }
.target-native { font-family: "Noto Serif SC", "Fraunces", serif; font-size: 1.7rem; font-weight: 600; line-height: 1.25; }
.target-roman { color: var(--accent-deep); font-size: 0.98rem; margin-top: 0.2rem; }
.target-en { color: var(--muted); font-size: 0.9rem; margin-top: 0.15rem; }

.mic-row { display: flex; align-items: center; gap: 0.65rem; margin-top: 0.95rem; }
.mini {
  appearance: none; border: 1px solid var(--line); background: var(--paper); color: var(--ink);
  border-radius: 12px; padding: 0.55rem 0.85rem; font-size: 0.85rem; font-weight: 600; cursor: pointer;
  transition: background 0.2s var(--ease), transform 0.15s var(--ease);
}
.mini:hover { background: var(--accent-soft); }
.mini:active { transform: scale(0.97); }
.mic {
  appearance: none; border: 0; cursor: pointer; flex: 1 1 auto;
  background: linear-gradient(135deg, var(--accent), var(--accent-deep)); color: #fff;
  border-radius: 14px; padding: 0.8rem 1rem; font-size: 1rem; font-weight: 700;
  box-shadow: 0 6px 18px oklch(60% 0.17 42 / 0.35); transition: transform 0.15s var(--ease), box-shadow 0.2s var(--ease);
}
.mic:active { transform: scale(0.98); }
.mic.live { animation: pulse 1.2s ease-in-out infinite; background: linear-gradient(135deg, var(--bad), oklch(48% 0.17 25)); box-shadow: 0 6px 22px oklch(58% 0.17 25 / 0.45); }
@keyframes pulse { 0%,100% { box-shadow: 0 6px 22px oklch(58% 0.17 25 / 0.45); } 50% { box-shadow: 0 6px 22px oklch(58% 0.17 25 / 0.75); } }
.listen-hint { color: var(--muted); font-size: 0.82rem; margin-top: 0.55rem; text-align: center; }

/* ---------- Result ---------- */
.result { margin-top: 0.9rem; border-radius: 16px; padding: 0.9rem 1rem; border: 1px solid var(--line); background: var(--paper); animation: rise 0.35s var(--ease); }
.result.great { background: var(--ok-soft); border-color: transparent; }
.result.good { background: var(--accent-soft); border-color: transparent; }
.result.try, .result.again { background: var(--bad-soft); border-color: transparent; }
.score-row { display: flex; align-items: baseline; gap: 0.6rem; }
.score-num { font-family: "Fraunces", serif; font-weight: 700; font-size: 2rem; line-height: 1; }
.score-num small { font-size: 1rem; opacity: 0.7; }
.score-verdict { font-weight: 600; font-size: 0.95rem; }
.heard { font-size: 0.9rem; margin-top: 0.55rem; color: var(--muted); }
.heard b { color: var(--ink); }
.target-diff { font-family: "Noto Serif SC", "Fraunces", serif; font-size: 1.5rem; margin-top: 0.5rem; line-height: 1.35; }
.tok.ok { color: var(--ok); }
.tok.miss { color: var(--bad); text-decoration: underline wavy var(--bad); text-underline-offset: 4px; }
.notes { list-style: none; margin-top: 0.6rem; display: flex; flex-direction: column; gap: 0.25rem; }
.notes li { font-size: 0.86rem; color: var(--ink); padding-left: 1rem; position: relative; }
.notes li::before { content: "•"; position: absolute; left: 0; color: var(--accent); }
.result-actions { display: flex; gap: 0.5rem; margin-top: 0.9rem; flex-wrap: wrap; }
.primary {
  appearance: none; border: 0; cursor: pointer; margin-left: auto;
  background: var(--ink); color: var(--paper); border-radius: 12px;
  padding: 0.55rem 1.1rem; font-size: 0.88rem; font-weight: 700;
  transition: transform 0.15s var(--ease);
}
.primary:active { transform: scale(0.97); }

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