/* The app's one stylesheet. System fonts only; nothing is loaded from anywhere else.
   Sizes that change at run time (the visible height, the input's height) arrive as custom
   properties set from script; the page carries no inline styles. */

/* theme: light */
:root {
  color-scheme: light dark;
  --backdrop: #e6e9f0;
  --page: #f4f5f8;
  --surface: #ffffff;
  --surface-2: #eceff5;
  --ink: #161a23;
  --muted: #535d70;
  --line: #d9deea;
  --field-line: #7b869b;
  --accent: #2f55d4;
  --on-accent: #ffffff;
  --accent-ink: #2545b0;
  --accent-soft: #e9eefd;
  --accent-line: #b9c7f5;
  --danger: #a8201a;
  --danger-soft: #fdeceb;
  --ok: #17633a;
  --ok-soft: #e3f4ea;
  --warn: #7a5200;
  --warn-soft: #fff4dc;
  --focus: #2f55d4;
  --shade: #0b0d1273;

  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", "Apple SD Gothic Neo", "Malgun Gothic", "Hiragino Sans", "Yu Gothic UI", "Noto Sans KR", "Noto Sans JP", "Noto Sans CJK KR", sans-serif;
  --font-ko: system-ui, -apple-system, "Apple SD Gothic Neo", "Malgun Gothic", "Noto Sans KR", "Noto Sans CJK KR", "Segoe UI", Roboto, sans-serif;
  --font-ja: system-ui, -apple-system, "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Yu Gothic UI", "Meiryo", "Noto Sans JP", "Noto Sans CJK JP", "Segoe UI", Roboto, sans-serif;
}

@media (prefers-color-scheme: dark) {
  /* theme: dark */
  :root {
    --backdrop: #090b10;
    --page: #0f1218;
    --surface: #1a1e27;
    --surface-2: #242a36;
    --ink: #eef1f6;
    --muted: #a7b0c0;
    --line: #2d3442;
    --field-line: #76819a;
    --accent: #3d62e0;
    --on-accent: #ffffff;
    --accent-ink: #a9bcff;
    --accent-soft: #1e2a52;
    --accent-line: #3a4c8c;
    --danger: #ffb4ab;
    --danger-soft: #3a1512;
    --ok: #7fd6a4;
    --ok-soft: #133324;
    --warn: #f2c46b;
    --warn-soft: #3a2c0c;
    --focus: #a9bcff;
    --shade: #000000a6;
  }
}

/* tints: light */
.tint-0 { --tint-bg: #dbe4ff; --tint-ink: #26398c; }
.tint-1 { --tint-bg: #d3f1e4; --tint-ink: #0d573a; }
.tint-2 { --tint-bg: #ffe2cc; --tint-ink: #853900; }
.tint-3 { --tint-bg: #f6d9ef; --tint-ink: #761d60; }
.tint-4 { --tint-bg: #d6eef7; --tint-ink: #0a4d64; }
.tint-5 { --tint-bg: #efe6c8; --tint-ink: #594500; }

@media (prefers-color-scheme: dark) {
  /* tints: dark */
  .tint-0 { --tint-bg: #2b3a7a; --tint-ink: #dbe4ff; }
  .tint-1 { --tint-bg: #1d4d3a; --tint-ink: #d3f1e4; }
  .tint-2 { --tint-bg: #6b3410; --tint-ink: #ffe2cc; }
  .tint-3 { --tint-bg: #5c2350; --tint-ink: #f6d9ef; }
  .tint-4 { --tint-bg: #164a5c; --tint-ink: #d6eef7; }
  .tint-5 { --tint-bg: #4f4210; --tint-ink: #efe6c8; }
}

/* ---- base */

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

html {
  height: 100%;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  height: 100%;
  margin: 0;
  overflow: hidden;
  overscroll-behavior: none;
  background: var(--backdrop);
  color: var(--ink);
  font-family: var(--font);
  font-size: 1rem;
  line-height: 1.45;
  -webkit-tap-highlight-color: transparent;
}

/* Korean and Japanese text picks its own fonts wherever it appears, whatever the interface language:
   the same code point is drawn differently in the two languages. */
:lang(ko) { font-family: var(--font-ko); word-break: keep-all; overflow-wrap: anywhere; }
:lang(ja) { font-family: var(--font-ja); line-break: strict; overflow-wrap: anywhere; }
/* keep-all is inherited: without this, Japanese inside a Korean interface would have no place to
   break a line at all and would be cut wherever the box ends, even before a question mark. */
:not(:lang(ko)) { word-break: normal; }

h1, h2, h3, p, ul, ol, blockquote, fieldset, legend { margin: 0; padding: 0; }
ul, ol { list-style: none; }
fieldset { border: 0; min-width: 0; }
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; }
a { color: var(--accent-ink); }
[hidden] { display: none !important; }

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

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.icon { display: block; flex: none; }
.quiet { color: var(--muted); }
.noscript { max-width: 30rem; margin: 3rem auto; padding: 0 1.25rem; }

/* ---- shell: one centred column that always fits the visible height */

#app { height: 100%; }

.app {
  position: relative;
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 480px;
  height: var(--vvh, 100vh);
  margin: 0 auto;
  overflow: hidden;
  background: var(--page);
}

@supports (height: 100dvh) {
  .app { height: var(--vvh, 100dvh); }
}

@media (min-width: 520px) {
  .app { border-inline: 1px solid var(--line); }
}

.screen-slot, .screen {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-height: 0;
}

.screen.centered {
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 24px;
  text-align: center;
}

.scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

.demo-banner {
  padding: 6px 12px;
  background: var(--accent-soft);
  color: var(--accent-ink);
  font-size: 0.8125rem;
  font-weight: 600;
  text-align: center;
}

/* ---- top bar */

.topbar {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 56px;
  padding: 6px 8px 6px 12px;
  padding-top: max(6px, env(safe-area-inset-top));
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.topbar-title {
  overflow: hidden;
  font-size: 1.125rem;
  font-weight: 700;
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.topbar-who { flex: 1; min-width: 0; }

.topbar-sub {
  display: flex;
  align-items: center;
  gap: 6px;
  overflow: hidden;
  color: var(--muted);
  font-size: 0.8125rem;
  white-space: nowrap;
}

.ai-label {
  flex: none;
  margin-inline-start: auto;
  padding: 3px 9px;
  border: 1px solid var(--accent-line);
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-ink);
  font-size: 0.75rem;
  font-weight: 600;
  white-space: nowrap;
}

.tag {
  flex: none;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--ink);
  font-size: 0.75rem;
  font-weight: 600;
  white-space: nowrap;
}

/* ---- buttons and fields */

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 10px 18px;
  border: 1px solid var(--field-line);
  border-radius: 14px;
  background: var(--surface);
  color: var(--ink);
  font-weight: 600;
  text-decoration: none;
}

.button.primary { border-color: var(--accent); background: var(--accent); color: var(--on-accent); }
.button.danger { border-color: var(--danger); color: var(--danger); }
.button.wide { width: 100%; min-height: 50px; font-size: 1.0625rem; }
.button:disabled { opacity: 0.55; }

.icon-button {
  display: inline-grid;
  flex: none;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--ink);
}

.icon-button.quiet-icon { color: var(--muted); }

.chip-button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 44px;
  padding: 0 14px;
  border: 1px solid var(--accent-line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--accent-ink);
  font-size: 0.875rem;
  font-weight: 600;
}

.chip-button.strong { border-color: var(--accent); background: var(--accent); color: var(--on-accent); }

.button-row { display: flex; flex-wrap: wrap; gap: 8px; }
.button-row.end { justify-content: flex-end; }

.field { display: flex; flex-direction: column; gap: 6px; }
.field-label { display: block; margin-bottom: 6px; font-size: 0.9375rem; font-weight: 700; }
.field .field-label { margin-bottom: 0; }
.hint { color: var(--muted); font-size: 0.8125rem; }
.field-error { color: var(--danger); font-size: 0.875rem; font-weight: 600; }

.text-input {
  width: 100%;
  min-height: 48px;
  padding: 10px 14px;
  border: 1px solid var(--field-line);
  border-radius: 14px;
  background: var(--surface);
  font-size: 1.0625rem;
}

.text-input[aria-invalid="true"] { border-color: var(--danger); box-shadow: inset 0 0 0 1px var(--danger); }
.year-input { max-width: 9rem; font-variant-numeric: tabular-nums; letter-spacing: 0.04em; }

.choice-row { display: flex; align-items: center; gap: 12px; }

.choice-value {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-width: 0;
  font-size: 1.0625rem;
  font-weight: 600;
}

.choice-sub { color: var(--muted); font-size: 0.8125rem; font-weight: 400; }

.notice {
  padding: 10px 14px;
  border-radius: 14px;
  background: var(--surface-2);
  font-size: 0.875rem;
}

.state-block {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 32px 20px;
  text-align: center;
}

/* ---- language being learned */

.target-switch:disabled { opacity: 0.6; }
.target-options { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.target-option { position: relative; display: block; }

.target-option input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}

.target-face {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-height: 68px;
  padding: 10px;
  border: 1px solid var(--field-line);
  border-radius: 16px;
  background: var(--surface);
  text-align: center;
}

.target-option input:checked + .target-face {
  border-color: var(--accent);
  background: var(--accent-soft);
  box-shadow: inset 0 0 0 1.5px var(--accent);
}

.target-option input:focus-visible + .target-face { outline: 3px solid var(--focus); outline-offset: 2px; }
.target-native { font-size: 1.25rem; font-weight: 700; line-height: 1.2; }
.target-local { color: var(--muted); font-size: 0.8125rem; }

/* A language that is not open yet: visible, marked "coming soon", not pickable. */
.target-option.closed .target-face { border-style: dashed; background: var(--page); }
.target-option.closed input { cursor: not-allowed; }
.tag.soon { margin-top: 2px; }

/* ---- start */

.start {
  display: flex;
  flex-direction: column;
  gap: 22px;
  padding: 28px 20px 32px;
  padding-top: max(28px, env(safe-area-inset-top));
  padding-bottom: max(32px, env(safe-area-inset-bottom));
}

/* The form under the hero: the same rhythm as the page around it. */
.start-form { display: flex; flex-direction: column; gap: 22px; }

/* ---- the first page's hero: a headline, one line, and a three-line example */

.hero { display: flex; flex-direction: column; align-items: flex-start; gap: 12px; }
.hero .ai-label { margin-inline-start: 0; }
.hero-title { font-size: 1.75rem; font-weight: 800; letter-spacing: -0.02em; line-height: 1.15; }

.hero-demo {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--surface);
}

.hero-line { display: flex; flex-direction: column; gap: 2px; }
.hero-line.sent { align-items: flex-end; }
.hero-who { color: var(--muted); font-size: 0.75rem; font-weight: 600; }

.hero-bubble {
  max-width: 90%;
  padding: 8px 12px;
  border-radius: 16px;
  font-size: 1.0625rem;
  line-height: 1.35;
}

.hero-line.sent .hero-bubble { border-end-end-radius: 6px; background: var(--accent); color: var(--on-accent); }
.hero-line.reply .hero-bubble { border-start-start-radius: 6px; background: var(--page); box-shadow: inset 0 0 0 1px var(--line); color: var(--ink); }
.hero-line.better .hero-bubble { border: 1.5px solid var(--accent); background: var(--accent-soft); color: var(--ink); font-weight: 700; }

.wordmark {
  color: var(--accent-ink);
  font-size: 1.625rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.1;
}

.lead { font-size: 1.125rem; line-height: 1.4; }
.dead-end-title { font-size: 1.25rem; line-height: 1.3; }

/* ---- language picker */

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

.search-field {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 48px;
  padding: 0 14px;
  border: 1px solid var(--field-line);
  border-radius: 14px;
  background: var(--page);
  color: var(--muted);
}

.search-field:focus-within { outline: 3px solid var(--focus); outline-offset: 2px; }

.search-field input {
  flex: 1;
  min-width: 0;
  min-height: 44px;
  border: 0;
  background: transparent;
  color: var(--ink);
  font-size: 1.0625rem;
}

.search-field input:focus-visible { outline: none; }

.picker-list { display: flex; flex-direction: column; gap: 2px; }

.picker-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  min-height: 52px;
  padding: 8px 10px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: var(--ink);
  text-align: start;
}

.picker-row[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent-ink); }
.picker-names { display: flex; flex-direction: column; min-width: 0; }
.picker-native { font-size: 1.0625rem; font-weight: 600; }
.picker-localized { color: var(--muted); font-size: 0.8125rem; }

/* ---- rooms */

/* Under the top bar: the streak and today's allowance. */
.rooms-status { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; padding: 12px 16px 4px; }
.rooms-status .quota-line { padding: 0; }

.streak {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 32px;
  padding: 4px 12px 4px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  font-size: 0.875rem;
  font-weight: 700;
}

.streak.active { border-color: var(--accent-line); background: var(--accent-soft); color: var(--accent-ink); }
/* Today does not count yet: the same chip, with a dashed edge as the quiet reminder. */
.streak.at-risk { border-style: dashed; }

.notice-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 12px 16px 0;
  padding: 10px 10px 10px 14px;
  border: 1.5px solid var(--accent);
  border-radius: 14px;
  background: var(--accent-soft);
  font-size: 0.9375rem;
}

.notice-row p { flex: 1; }

.quota-line { padding: 12px 16px 4px; color: var(--muted); font-size: 0.8125rem; }
.quota-line.empty { color: var(--ink); font-weight: 600; }

/* The story: the chapter the learner is in and its missions, under the episode. Practice between
   episodes, so it is folded to one quiet line that opens on a tap. */
.story-card {
  margin: 12px 16px 4px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--surface);
}

.story-card.open { border-color: var(--accent-line); }

.story-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  min-height: 44px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 0.875rem;
  font-weight: 700;
  text-align: start;
}

.story-toggle-text { min-width: 0; overflow-wrap: anywhere; }
.story-body { padding-bottom: 4px; }

.story-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.story-title { min-width: 0; font-size: 1rem; font-weight: 700; line-height: 1.3; overflow-wrap: anywhere; }
.story-progress { flex: none; color: var(--accent-ink); font-size: 0.875rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.story-intro { margin-top: 4px; color: var(--muted); font-size: 0.875rem; line-height: 1.4; word-break: keep-all; overflow-wrap: anywhere; }
.missions { display: flex; flex-direction: column; margin-top: 6px; }

.mission {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  min-height: 44px;
  padding: 9px 0;
  border-top: 1px solid var(--line);
  color: inherit;
  text-decoration: none;
}

.missions li:first-child .mission { border-top: 0; }
a.mission:focus-visible { outline-offset: 0; }

.mission-mark {
  display: inline-grid;
  flex: none;
  place-items: center;
  width: 20px;
  height: 20px;
  margin-top: 1px;
  border: 2px solid var(--field-line);
  border-radius: 50%;
  color: var(--on-accent);
}

.mission-mark.done { border-color: var(--accent); background: var(--accent); }
.mission-text { display: flex; flex: 1; flex-direction: column; gap: 1px; min-width: 0; }
.mission-title { font-size: 0.9375rem; font-weight: 600; line-height: 1.35; word-break: keep-all; overflow-wrap: anywhere; }
/* Done is quieter, not crossed out: the learner may still want to read what it was. */
.mission.done .mission-title { color: var(--muted); }
/* Korean words inside the hints (-습니다, 드셨어요?) stay whole on a line break. */
.mission-hint { color: var(--muted); font-size: 0.8125rem; line-height: 1.35; word-break: keep-all; overflow-wrap: anywhere; }
.mission-count { flex: none; color: var(--muted); font-size: 0.8125rem; font-weight: 700; font-variant-numeric: tabular-nums; }

.story-complete { display: flex; align-items: center; gap: 6px; padding: 10px 16px 0; color: var(--ok); font-size: 0.875rem; font-weight: 600; }

.rooms { padding: 4px 0 16px; }

.room-row {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 76px;
  padding: 12px 16px;
  color: inherit;
  text-decoration: none;
}

.room-row:focus-visible { outline-offset: -3px; }

.room-main { display: flex; flex: 1; flex-direction: column; gap: 2px; min-width: 0; }
.room-top, .room-bottom { display: flex; align-items: center; gap: 8px; }
.room-name { flex: 1; overflow: hidden; font-size: 1.0625rem; font-weight: 700; text-overflow: ellipsis; white-space: nowrap; }
.room-time { flex: none; color: var(--muted); font-size: 0.75rem; }
.room-meta { display: flex; align-items: center; gap: 6px; min-width: 0; color: var(--muted); font-size: 0.8125rem; }
.room-role { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.room-preview { flex: 1; overflow: hidden; color: var(--muted); font-size: 0.9375rem; text-overflow: ellipsis; white-space: nowrap; }
.room-speaker { color: var(--ink); font-weight: 600; }

.badge {
  display: inline-grid;
  flex: none;
  place-items: center;
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  border-radius: 11px;
  background: var(--accent);
  color: var(--on-accent);
  font-size: 0.75rem;
  font-weight: 700;
}

.avatar {
  display: inline-grid;
  flex: none;
  place-items: center;
  width: 50px;
  height: 50px;
  border-radius: 50%;
  background: var(--tint-bg);
  color: var(--tint-ink);
  font-size: 1.25rem;
  font-weight: 700;
  line-height: 1;
}

.avatar.small { width: 32px; height: 32px; font-size: 1.0625rem; }
.avatar-gap { flex: none; width: 32px; }

/* A drawn face (faces.ts) fills its tint circle; the circle crops the ears a little. */
.avatar.drawn { position: relative; }
.avatar .face { display: block; width: 100%; height: 100%; clip-path: circle(50%); }
/* The reaction: the face is puzzled (raised brow, flat mouth, a drop of sweat), gives a small start,
   and wears a "?" that still reads at 32px, where the face's own details are small. */
.avatar.puzzled { animation: taken-aback 0.5s ease-out 1; }
.avatar.puzzled::after {
  content: "?";
  position: absolute;
  inset-block-start: -5px;
  inset-inline-end: -6px;
  display: grid;
  place-items: center;
  width: 17px;
  height: 17px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--on-accent);
  box-shadow: 0 0 0 2px var(--page);
  font-size: 0.6875rem;
  font-weight: 800;
  line-height: 1;
}
/* Pleased: a small happy bounce. Down: a little greyer. */
.avatar.happy { animation: pleased 0.5s ease-out 1; }
.avatar.down { filter: saturate(0.8); }

@keyframes pleased {
  0% { transform: none; }
  40% { transform: translateY(-3px) scale(1.06); }
  100% { transform: none; }
}

@keyframes taken-aback {
  0% { transform: translateY(0) rotate(0); }
  30% { transform: translateY(-3px) rotate(-6deg); }
  60% { transform: translateY(0) rotate(4deg); }
  100% { transform: translateY(0) rotate(0); }
}

/* A group's people, overlapping: each picture keeps a ring of the page colour so the edges read. */
/* Sized to its pictures (three of 28px, 9px apart) so it never runs under the text beside it. */
.avatar-stack { display: inline-flex; flex: none; align-items: center; min-width: 50px; height: 50px; }
.avatar.stacked { width: 28px; height: 28px; margin-inline-start: -10px; box-shadow: 0 0 0 2px var(--page); font-size: 0.9375rem; }
.avatar.stacked:first-child { margin-inline-start: 0; }
.avatar-stack.small { min-width: 32px; height: 32px; }
.avatar-stack.small .avatar.stacked { width: 22px; height: 22px; margin-inline-start: -9px; box-shadow: 0 0 0 2px var(--surface); font-size: 0.75rem; }
.avatar-stack.small .avatar.stacked:first-child { margin-inline-start: 0; }

/* ---- who is in a room */

/* Positioned, so hidden labels inside the chips scroll with the strip instead of widening the app. */
.member-strip {
  position: relative;
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 8px 12px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  scrollbar-width: none;
}

.member-chip {
  position: relative;
  display: inline-flex;
  flex: none;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 4px 12px 4px 6px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--page);
  color: var(--ink);
  text-align: start;
}

/* Under the people: the mission to do here next. Two lines at most, outside the thread, so on a narrow
   phone it takes a little height and never covers a message. */
.mission-strip {
  padding: 6px 12px;
  background: var(--accent-soft);
  border-bottom: 1px solid var(--accent-line);
}

.mission-strip-text {
  display: -webkit-box;
  overflow: hidden;
  color: var(--ink);
  font-size: 0.8125rem;
  line-height: 1.45;
  word-break: keep-all;
  overflow-wrap: anywhere;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
}

.mission-label {
  margin-inline-end: 6px;
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--accent);
  color: var(--on-accent);
  font-size: 0.6875rem;
  font-weight: 700;
}

.mission-strip-title { font-weight: 700; }
.mission-strip-hint { color: var(--muted); }

.member-chip-text { display: flex; flex-direction: column; line-height: 1.2; }
.member-chip-name { font-size: 0.875rem; font-weight: 700; white-space: nowrap; }
.member-chip-sub { color: var(--muted); font-size: 0.75rem; white-space: nowrap; }

.member-list { display: flex; flex-direction: column; gap: 14px; }
.member-item { display: flex; align-items: flex-start; gap: 12px; }
.member-info { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.member-name { font-size: 1.0625rem; font-weight: 700; }
.member-role { color: var(--ink); font-size: 0.9375rem; }
.member-line { color: var(--muted); font-size: 0.875rem; }

/* What a person remembers about the learner, each with a way to make them forget it. */
.memory { margin-top: 8px; }
.memory-title { margin-bottom: 2px; color: var(--ink); font-size: 0.8125rem; font-weight: 700; }
.memory-list { display: flex; flex-direction: column; }
.memory-item { display: flex; align-items: center; justify-content: space-between; gap: 4px; min-height: 44px; border-bottom: 1px solid var(--line); }
.memory-item:last-child { border-bottom: 0; }
.memory-fact { flex: 1; min-width: 0; font-size: 0.9375rem; overflow-wrap: anywhere; }

/* ---- chat thread */

/* The thread keeps itself at the newest message; the browser's own scroll anchoring would fight that. */
.thread-scroll { overflow-anchor: none; }

.thread-hint {
  padding: 12px 20px 0;
  color: var(--muted);
  font-size: 0.8125rem;
  text-align: center;
}

.thread {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 8px 12px 12px;
}

.day { display: flex; justify-content: center; padding: 10px 0 4px; }

.day span {
  padding: 2px 10px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 600;
}

.row { display: flex; align-items: flex-start; gap: 8px; }
.row.first { margin-top: 8px; }
.row.me { justify-content: flex-end; }

.stack { display: flex; flex-direction: column; align-items: flex-start; min-width: 0; max-width: calc(100% - 40px); }
.row.me .stack { align-items: flex-end; max-width: min(92%, 380px); }

.bubble-line { display: flex; align-items: flex-end; gap: 4px; max-width: 100%; }
.row.me .bubble-line { flex-direction: row-reverse; }

.bubble {
  min-width: 44px;
  min-height: 44px;
  padding: 10px 14px;
  border: 0;
  border-radius: 20px;
  font-size: 1.0625rem;
  line-height: 1.4;
  text-align: start;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.row.them .bubble {
  border-start-start-radius: 6px;
  background: var(--surface);
  box-shadow: inset 0 0 0 1px var(--line);
  color: var(--ink);
}

.row.me .bubble {
  border-end-end-radius: 6px;
  background: var(--accent);
  color: var(--on-accent);
}

/* A bubble that is not a button: a message still on its way, or the typing indicator. */
.bubble.static { cursor: default; }
/* The app's own note, shown where a friend's answer would be: plainly not a chat bubble. */
.row.them .bubble.note {
  border-radius: 12px;
  background: var(--surface-2);
  box-shadow: inset 0 0 0 1px var(--line);
  color: var(--ink);
  font-size: 0.9375rem;
}
.bubble.sending { opacity: 0.7; }

.row.me .bubble.failed {
  background: var(--danger-soft);
  box-shadow: inset 0 0 0 1px var(--danger);
  color: var(--ink);
}

.bubble.typing { display: inline-flex; align-items: center; }

.speaker-name { padding: 0 6px 2px; color: var(--muted); font-size: 0.8125rem; font-weight: 600; }

.stamp { flex: none; padding-bottom: 3px; color: var(--muted); font-size: 0.75rem; white-space: nowrap; }
/* Under a friend's bubble instead of beside it: beside it, the bubble would lose a quarter of its width. */
.stamp.under { padding: 2px 6px 0; }

.system-line {
  margin-top: 6px;
  padding: 6px 12px;
  border-radius: 12px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 0.8125rem;
}

/* After a send: how someone's closeness moved. Quiet, centred, like a day separator. */
.change-line { display: flex; justify-content: center; padding: 6px 0 2px; }

.change-line span {
  padding: 3px 12px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 0.8125rem;
  text-align: center;
}

/* A new way to speak to someone: worth more attention than a closeness step. */
.change-line.level span { border: 1px solid var(--accent-line); background: var(--accent-soft); color: var(--accent-ink); font-weight: 600; }

/* After the fifth message: saving progress, once, above the input. */
.save-prompt {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px 12px;
  background: var(--accent-soft);
  border-top: 1px solid var(--accent-line);
  font-size: 0.9375rem;
}

.natural {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin: 4px 4px 0;
  color: var(--ok);
  font-size: 0.8125rem;
  font-weight: 600;
}

.failed-line { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; margin-top: 6px; }
.failed-text { color: var(--danger); font-size: 0.8125rem; text-align: end; }

/* ---- the correction card: the reason the app exists */

.correction {
  width: 100%;
  margin-top: 6px;
  padding: 14px 16px;
  border: 1.5px solid var(--accent);
  border-radius: 20px;
  border-start-end-radius: 6px;
  background: var(--accent-soft);
}

.correction-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.correction-label { color: var(--accent-ink); font-size: 0.8125rem; font-weight: 700; }
.correction .tag { background: var(--surface); }

.correction-better {
  margin-top: 6px;
  color: var(--ink);
  font-size: 1.25rem;
  font-weight: 700;
  line-height: 1.35;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

/* How the message came across: the funny part, so it comes first and reads largest after the fix. */
.sounds { margin-bottom: 12px; padding-bottom: 12px; border-bottom: 1px solid var(--accent-line); }
.sounds-line { margin-top: 4px; color: var(--ink); font-size: 1.0625rem; font-weight: 600; line-height: 1.4; overflow-wrap: anywhere; }

.correction-why { margin-top: 12px; color: var(--muted); font-size: 0.9375rem; line-height: 1.45; overflow-wrap: anywhere; }
.correction-to { margin-top: 6px; color: var(--muted); font-size: 0.8125rem; }
.correction-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }

/* ---- composer */

.composer {
  padding: 8px 12px;
  padding-bottom: max(8px, env(safe-area-inset-bottom));
  background: var(--surface);
  border-top: 1px solid var(--line);
}

.composer-field { display: flex; align-items: flex-end; gap: 8px; }

.composer textarea {
  flex: 1;
  min-width: 0;
  height: var(--h, auto);
  min-height: 44px;
  max-height: 132px;
  padding: 9px 14px;
  border: 1px solid var(--field-line);
  border-radius: 22px;
  background: var(--page);
  font-size: 1.0625rem;
  line-height: 1.4;
  resize: none;
}

.composer textarea[aria-invalid="true"] { border-color: var(--danger); box-shadow: inset 0 0 0 1px var(--danger); }
.composer textarea::placeholder { color: var(--muted); opacity: 1; }

.send {
  display: inline-grid;
  flex: none;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 50%;
  background: var(--accent);
  color: var(--on-accent);
}

.send:disabled { background: var(--surface-2); color: var(--muted); }

.composer-meta {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  min-height: 1.25rem;
  padding: 4px 6px 0;
  color: var(--muted);
  font-size: 0.75rem;
}

.meta-text.over { color: var(--danger); font-weight: 600; }
.counter { flex: none; margin-inline-start: auto; font-variant-numeric: tabular-nums; }
.counter.near { color: var(--ink); font-weight: 600; }
.counter.over { color: var(--danger); font-weight: 700; }

/* ---- typing dots */

.dots { display: inline-flex; gap: 4px; padding: 6px 2px; }

.dots span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--muted);
  animation: dot 1.2s ease-in-out infinite;
}

.dots span:nth-child(2) { animation-delay: 0.15s; }
.dots span:nth-child(3) { animation-delay: 0.3s; }

@keyframes dot {
  0%, 80%, 100% { opacity: 0.35; transform: translateY(0); }
  40% { opacity: 1; transform: translateY(-3px); }
}

/* ---- bottom sheet */

.sheet-layer {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
}

.sheet-backdrop { position: absolute; inset: 0; background: var(--shade); }

.sheet {
  position: relative;
  display: flex;
  flex-direction: column;
  max-height: 88%;
  border-radius: 22px 22px 0 0;
  background: var(--surface);
  animation: rise 0.18s ease-out;
}

/* The panel takes focus when it opens so that Tab starts inside it; it is not itself a control. */
.sheet:focus { outline: none; }

.sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 8px 4px 20px;
}

.sheet-head h2 { font-size: 1.0625rem; font-weight: 700; }

.sheet-body {
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 6px 20px 20px;
  padding-bottom: max(20px, env(safe-area-inset-bottom));
}

/* Movement only, never opacity: if the animation does not get to run (a background tab, a paused
   compositor), the sheet is a few pixels low instead of invisible. */
@keyframes rise {
  from { transform: translateY(24px); }
}

/* ---- a finished chapter */

.chapter-mark {
  display: inline-grid;
  place-items: center;
  align-self: center;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--on-accent);
  animation: rise 0.3s ease-out;
}

.chapter-next {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 14px 16px;
  border: 1px solid var(--accent-line);
  border-radius: 16px;
  background: var(--accent-soft);
}

.chapter-next .section-label { margin-bottom: 2px; }
.chapter-next-title { color: var(--ink); font-size: 1.0625rem; font-weight: 700; line-height: 1.3; overflow-wrap: anywhere; }
.chapter-intro { margin-top: 4px; color: var(--muted); font-size: 0.9375rem; line-height: 1.45; overflow-wrap: anywhere; }

/* ---- explanation */

.explain-quote {
  padding: 10px 14px;
  border-inline-start: 3px solid var(--accent);
  border-radius: 4px 12px 12px 4px;
  background: var(--surface-2);
  font-size: 1.125rem;
  font-weight: 600;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.explanation { display: flex; flex-direction: column; gap: 16px; }
.section-label { margin-bottom: 6px; color: var(--muted); font-size: 0.8125rem; font-weight: 700; }
.explain-meaning { font-size: 1.0625rem; }

.parts { display: flex; flex-wrap: wrap; gap: 8px; }

.part {
  display: flex;
  flex-direction: column;
  align-items: center;
  max-width: 100%;
  min-width: 56px;
  padding: 6px 12px 8px;
  border-radius: 14px;
  background: var(--surface-2);
  text-align: center;
}

.part-reading { min-height: 1.1rem; color: var(--muted); font-size: 0.75rem; line-height: 1.1rem; }
.part-text { font-size: 1.25rem; font-weight: 700; line-height: 1.3; overflow-wrap: anywhere; }
.part-gloss { margin-top: 2px; color: var(--muted); font-size: 0.8125rem; line-height: 1.3; overflow-wrap: anywhere; }
.footnote { color: var(--muted); font-size: 0.75rem; }

/* ---- share card */

.share-canvas {
  display: block;
  width: min(100%, 264px);
  height: auto;
  aspect-ratio: 4 / 5;
  margin: 0 auto;
  border: 1px solid var(--line);
  border-radius: 14px;
}

.captions { display: flex; flex-direction: column; gap: 2px; }

.caption-option {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  padding: 6px 4px;
  font-size: 0.9375rem;
}

.caption-option input { flex: none; width: 20px; height: 20px; margin: 0; accent-color: var(--accent); }

/* ---- message menu */

.menu { display: flex; flex-direction: column; gap: 8px; }

.menu-item {
  min-height: 48px;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  color: var(--ink);
  font-weight: 600;
  text-align: start;
}

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

/* ---- settings */

.settings {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px;
  padding-bottom: max(24px, env(safe-area-inset-bottom));
}

.card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--surface);
}

.card .field-label { margin-bottom: 0; }
.plain-list { display: flex; flex-direction: column; gap: 8px; font-size: 0.9375rem; }
.confirm { display: flex; flex-direction: column; gap: 10px; }
.card > .button { align-self: flex-start; }

/* ---- sign-in, Plus */

.signin-form { display: flex; flex-direction: column; gap: 8px; }
.signin-form .field-label { margin-bottom: 0; }
.signin-sent { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; }
.signin-sent-title { font-size: 1.0625rem; font-weight: 700; }
.button-col { display: flex; flex-direction: column; gap: 8px; }

.plus { display: flex; flex-direction: column; gap: 14px; }
.plus-lead { font-size: 1.0625rem; font-weight: 600; }
.plus-features { display: flex; flex-direction: column; gap: 6px; }
.plus-features li { display: flex; align-items: center; gap: 8px; color: var(--ink); }
.plus-features .icon { color: var(--ok); }
.plus-done { display: flex; flex-direction: column; gap: 6px; }
.plans { display: flex; flex-direction: column; gap: 8px; }
.plan-option { position: relative; display: block; }

.plan-option input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}

.plan-face {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-height: 64px;
  padding: 10px 14px;
  border: 1px solid var(--field-line);
  border-radius: 16px;
  background: var(--surface);
}

.plan-option.highlighted .plan-face { border-width: 2px; }
.plan-option input:checked + .plan-face { border-color: var(--accent); background: var(--accent-soft); box-shadow: inset 0 0 0 1.5px var(--accent); }
.plan-option input:focus-visible + .plan-face { outline: 3px solid var(--focus); outline-offset: 2px; }
.plan-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.plan-name { font-weight: 700; }
.plan-best { background: var(--accent); color: var(--on-accent); }
.plan-price { font-size: 1.125rem; font-weight: 700; }
.plan-detail { color: var(--muted); font-size: 0.8125rem; }

/* ---- the weekly report */

.report { display: flex; flex-direction: column; gap: 12px; padding: 16px; padding-bottom: max(24px, env(safe-area-inset-bottom)); }
.report-range { color: var(--muted); font-size: 0.875rem; font-weight: 600; }
.report-figures { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; }
.report-count { color: var(--ink); font-size: 0.9375rem; font-weight: 600; }
.report-people { display: flex; flex-direction: column; gap: 14px; }
.report-person { display: flex; align-items: flex-start; gap: 12px; }
.report-slips { display: flex; flex-direction: column; gap: 12px; }
.report-slip { display: flex; flex-direction: column; gap: 2px; padding: 12px; border-radius: 14px; background: var(--surface-2); }
.slip-label { margin-top: 6px; color: var(--muted); font-size: 0.75rem; font-weight: 700; }
.slip-example { font-size: 1rem; overflow-wrap: anywhere; }
.slip-better { font-size: 1.0625rem; font-weight: 700; overflow-wrap: anywhere; }
.report-locked { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; }
.report .button.wide { gap: 8px; }

/* ---- links to the pages beside the app */

.page-links ul { display: flex; flex-wrap: wrap; gap: 4px 16px; }

.page-links a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  font-size: 0.9375rem;
  font-weight: 600;
}

.start .page-links { align-self: center; }

/* ---- toast */

.toast-region {
  position: absolute;
  inset-inline: 0;
  bottom: calc(88px + env(safe-area-inset-bottom));
  z-index: 30;
  display: flex;
  justify-content: center;
  padding: 0 16px;
  pointer-events: none;
}

.toast {
  max-width: 100%;
  padding: 10px 16px;
  border-radius: 999px;
  background: var(--ink);
  color: var(--page);
  font-size: 0.875rem;
  font-weight: 600;
  animation: rise 0.18s ease-out;
}

/* ---- the plain pages (safety, privacy, terms): ordinary scrolling documents, not the app shell */

body.doc { height: auto; overflow: auto; overscroll-behavior: auto; background: var(--page); }

.doc main {
  max-width: 40rem;
  margin: 0 auto;
  padding: 24px 20px 48px;
  padding-bottom: max(48px, env(safe-area-inset-bottom));
}

.doc h1 { margin: 12px 0 8px; font-size: 1.625rem; line-height: 1.2; }
.doc h2 { margin: 28px 0 8px; font-size: 1.1875rem; line-height: 1.3; }
.doc p, .doc ul { margin: 0 0 12px; }
.doc ul { padding-inline-start: 1.25rem; list-style: disc; }
.doc li { margin-bottom: 6px; }
.doc-nav { display: flex; flex-wrap: wrap; gap: 4px 16px; font-weight: 600; }
.doc-nav a { display: inline-flex; align-items: center; min-height: 44px; }

/* The guides (/guides/...): a quick answer, one card per person, and what to watch out for. */
.draft-line { display: inline-block; padding: 4px 10px; border: 1px solid var(--danger); border-radius: 8px; background: var(--danger-soft); font-weight: 700; }
.guide-short { margin: 8px 0 16px; padding: 14px 16px; border: 1px solid var(--accent-line); border-radius: 16px; background: var(--accent-soft); }
.guide-short p { margin: 0 0 6px; }
.guide-short p:last-child { margin-bottom: 0; }
.guide-ko { font-family: var(--font-ko); font-weight: 600; }
.guide-ko.big { font-size: 1.375rem; }
.guide-roman { color: var(--muted); font-style: italic; }
.doc ul.guide-lines, .doc ul.guide-watch { padding: 0; list-style: none; }
.guide-lines li, .guide-watch li { margin: 0 0 10px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); }
.guide-lines p, .guide-watch p { margin: 0 0 4px; }
.guide-to { color: var(--muted); font-size: 0.8125rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.02em; }
.guide-wrong { color: var(--danger); font-weight: 700; }
.guide-better { color: var(--ok); font-weight: 700; }
.guide-table { overflow-x: auto; margin: 0 0 12px; }
.guide-table table { border-collapse: collapse; min-width: 100%; font-size: 0.9375rem; }
.guide-table th, .guide-table td { padding: 8px 10px; border: 1px solid var(--line); text-align: start; vertical-align: top; }
.guide-table thead th { background: var(--accent-soft); }

.help-box {
  margin: 12px 0 16px;
  padding: 14px 16px;
  border: 1.5px solid var(--accent);
  border-radius: 16px;
  background: var(--accent-soft);
}

/* ---- the converter page (/banmal): a document page with one form */

.convert { margin: 16px 0; }
.convert-form { display: flex; flex-direction: column; gap: 16px; margin-bottom: 16px; }
.convert-form .field-label { margin-bottom: 0; }

.convert-input {
  width: 100%;
  min-height: 112px;
  padding: 10px 14px;
  border: 1px solid var(--field-line);
  border-radius: 14px;
  background: var(--surface);
  font-size: 1.0625rem;
  line-height: 1.45;
  resize: vertical;
}

.convert-input[aria-invalid="true"] { border-color: var(--danger); box-shadow: inset 0 0 0 1px var(--danger); }

.select-input {
  width: 100%;
  min-height: 48px;
  padding: 10px 14px;
  border: 1px solid var(--field-line);
  border-radius: 14px;
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-size: 1.0625rem;
}

.convert .counter { color: var(--muted); font-size: 0.8125rem; }
.convert .counter.over { color: var(--danger); }
.convert-left { min-height: 1.25rem; }
.convert-result { margin-bottom: 16px; }
.convert-result .correction { border-start-end-radius: 20px; }
.convert-practise { display: flex; flex-direction: column; align-items: flex-start; gap: 10px; margin: 24px 0 12px; padding: 16px; border: 1px solid var(--line); border-radius: 18px; background: var(--surface); }
.convert .demo-banner { margin-bottom: 12px; border-radius: 10px; }

/* ---- episodes (version 5) */

/* The card at the top of the chat list: today's episode, the main way in. */
.episode-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 14px 16px 4px;
  padding: 16px;
  border: 1.5px solid var(--accent);
  border-radius: 20px;
  background: var(--accent-soft);
}

.episode-kicker { color: var(--accent-ink); font-size: 0.75rem; font-weight: 800; letter-spacing: 0.06em; text-transform: uppercase; }
.episode-card-title { display: flex; flex-direction: column; gap: 2px; color: var(--ink); font-size: 1.375rem; font-weight: 800; line-height: 1.2; overflow-wrap: anywhere; }
.episode-card-number { color: var(--muted); font-size: 0.875rem; font-weight: 700; }
.episode-card-wait { color: var(--ink); font-size: 1.0625rem; font-weight: 700; line-height: 1.35; }
.episode-card-next { color: var(--muted); font-size: 0.875rem; }

/* Finished episodes, in a row that scrolls sideways. */
.past-episodes { padding-top: 12px; }
.past-episodes .section-label { padding: 0 16px; }
.past-list { display: flex; gap: 8px; overflow-x: auto; padding: 0 16px 4px; scrollbar-width: none; }
.past-list li { flex: none; }

/* Positioned, so the hidden sentence inside scrolls with the row instead of widening the app. */
.past-episode {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 132px;
  max-width: 200px;
  min-height: 44px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  color: inherit;
  text-decoration: none;
}

.past-episode-number { color: var(--muted); font-size: 0.75rem; font-weight: 700; }
.past-episode-title { overflow: hidden; font-size: 0.9375rem; font-weight: 700; text-overflow: ellipsis; white-space: nowrap; }
.past-episode-result { color: var(--ok); font-size: 0.8125rem; font-weight: 700; font-variant-numeric: tabular-nums; }

/* Above the chats once there are episodes: what the chats are for now. */
.rooms-label { margin: 0; padding: 16px 16px 0; }

/* The player's feed keeps a little air above the dock, so the newest line never touches it. */
.episode-feed { padding-bottom: 8px; }

/* The player's top bar: the room the scene is in, and the episode under its title. */
.episode-sub { overflow: hidden; color: var(--muted); font-size: 0.75rem; font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }

/* A scene's card: when and where, like a title card in a drama. */
.scene-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  align-self: center;
  gap: 2px;
  max-width: 92%;
  margin: 10px 0 4px;
  padding: 9px 16px;
  border-radius: 14px;
  background: var(--ink);
  color: var(--page);
  text-align: center;
}

.scene-time { font-size: 0.75rem; font-weight: 800; letter-spacing: 0.02em; }
.scene-setting { font-size: 0.875rem; line-height: 1.35; overflow-wrap: anywhere; }

/* A line's meaning, under the Korean: smaller and quieter, so the Korean is read first. */
.bubble .gloss { display: block; margin-top: 4px; color: var(--muted); font-size: 0.8125rem; line-height: 1.35; white-space: normal; }

/* In an episode a closeness step says which way it went by its colour too. */
.change-line.warmer span { background: var(--ok-soft); color: var(--ok); font-weight: 600; }
.change-line.cooler span { background: var(--danger-soft); color: var(--danger); font-weight: 600; }

/* Under an answer: how it was judged (the colour), how it came across, what a Korean would send. */
.episode-note {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin: 6px 0 2px;
  padding: 10px 14px;
  border-radius: 16px;
  background: var(--surface-2);
  color: var(--ink);
  font-size: 0.9375rem;
  line-height: 1.4;
  overflow-wrap: anywhere;
}

.episode-note.right { background: var(--ok-soft); }
.episode-note.ok { background: var(--warn-soft); }
.episode-note.wrong { background: var(--danger-soft); }
.episode-note.unknown { background: var(--surface-2); }
/* "You wrote your own reply here" is a sentence, not a verdict: no capitals. */
.episode-note.unknown .episode-note-label { font-size: 0.875rem; font-weight: 600; letter-spacing: 0; text-transform: none; }
.episode-note-label { color: var(--muted); font-size: 0.75rem; font-weight: 800; letter-spacing: 0.05em; text-transform: uppercase; }
.episode-note.right .episode-note-label { color: var(--ok); }
.episode-note.ok .episode-note-label { color: var(--warn); }
.episode-note.wrong .episode-note-label { color: var(--danger); }
.episode-note-text { color: var(--ink); }
.episode-note-sub { margin-top: 4px; color: var(--muted); font-size: 0.75rem; font-weight: 700; }
.episode-note-better { color: var(--ink); font-size: 1.0625rem; font-weight: 700; line-height: 1.35; }
.episode-note-why { color: var(--muted); font-size: 0.875rem; }

/* Under the feed: the three replies, "Next", or the end. */
.episode-dock {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px 12px;
  padding-bottom: max(12px, env(safe-area-inset-bottom));
  background: var(--surface);
  border-top: 1px solid var(--line);
  animation: rise 0.18s ease-out;
}

.episode-prompt { color: var(--muted); font-size: 0.8125rem; font-weight: 700; line-height: 1.35; overflow-wrap: anywhere; }
.episode-options { display: flex; flex-direction: column; gap: 6px; }

.episode-option {
  display: flex;
  flex-direction: column;
  gap: 2px;
  width: 100%;
  min-height: 48px;
  padding: 8px 14px;
  border: 1px solid var(--field-line);
  border-radius: 14px;
  background: var(--page);
  color: var(--ink);
  text-align: start;
}

@media (hover: hover) {
  .episode-option:hover { border-color: var(--accent); background: var(--accent-soft); }
}

.episode-option-ko { font-size: 1.0625rem; font-weight: 600; line-height: 1.35; overflow-wrap: anywhere; }
.episode-option-en { color: var(--muted); font-size: 0.8125rem; line-height: 1.3; }

.episode-write {
  min-height: 44px;
  padding: 8px 14px;
  border: 1.5px dashed var(--accent);
  border-radius: 14px;
  background: transparent;
  color: var(--accent-ink);
  font-size: 0.875rem;
  font-weight: 700;
}

.episode-error { color: var(--danger); font-size: 0.8125rem; }

/* The learner's own reply: the room's input, inside the dock. */
.episode-write-form textarea {
  flex: 1;
  min-width: 0;
  height: var(--h, auto);
  min-height: 44px;
  max-height: 132px;
  padding: 9px 14px;
  border: 1px solid var(--field-line);
  border-radius: 22px;
  background: var(--page);
  font-size: 1.0625rem;
  line-height: 1.4;
  resize: none;
}

.episode-write-form textarea[aria-invalid="true"] { border-color: var(--danger); box-shadow: inset 0 0 0 1px var(--danger); }
.episode-write-form textarea::placeholder { color: var(--muted); opacity: 1; }
.episode-write-form .composer-meta { padding-top: 0; }

/* The end card, and the page that offers a finished episode again. */
.episode-end { display: flex; flex-direction: column; gap: 12px; padding: 18px 16px; padding-bottom: max(24px, env(safe-area-inset-bottom)); }
.episode-end-title { margin-top: -6px; font-size: 1.5rem; font-weight: 800; line-height: 1.2; overflow-wrap: anywhere; }

.episode-score {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 12px 16px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
}

.episode-score-num { font-size: 1.75rem; font-weight: 800; line-height: 1.1; font-variant-numeric: tabular-nums; }
.episode-score-label { color: var(--muted); font-size: 0.9375rem; font-weight: 600; }

.episode-people { display: flex; flex-direction: column; gap: 10px; }
.episode-person { display: flex; align-items: center; gap: 10px; }
.episode-person-text { display: flex; flex: none; flex-direction: column; width: 6.5rem; min-width: 0; line-height: 1.25; }
.episode-person-name { overflow: hidden; font-size: 0.9375rem; font-weight: 700; text-overflow: ellipsis; white-space: nowrap; }
.episode-person-word { color: var(--muted); font-size: 0.75rem; }
.meter { display: flex; flex: 1; gap: 3px; }
.meter-step { position: relative; overflow: hidden; flex: 1; height: 7px; border-radius: 4px; background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--line); }
.meter-step.on { background: var(--accent); box-shadow: none; }
/* How far into the word (5.1): --fill from 0 to 1, set on the element by the screen. */
.meter-fill { position: absolute; inset-block: 0; inset-inline-start: 0; width: calc(var(--fill, 0) * 100%); border-radius: inherit; background: var(--accent); }
.moved { flex: none; width: 1.5rem; color: var(--muted); font-size: 0.8125rem; font-weight: 800; text-align: end; }
.moved.up { color: var(--ok); }
.moved.down { color: var(--danger); }

.learned { display: flex; flex-direction: column; }
.learned-item { padding: 8px 0; border-top: 1px solid var(--line); }
.learned-item:first-child { padding-top: 0; border-top: 0; }
.learned-ko { font-size: 1.0625rem; font-weight: 700; }
.learned-note { color: var(--muted); font-size: 0.875rem; line-height: 1.4; overflow-wrap: anywhere; }

/* The hook: the next episode's question, in the scene card's colours. */
.episode-hook { display: flex; flex-direction: column; gap: 2px; padding: 14px 16px; border-radius: 16px; background: var(--ink); color: var(--page); }
.episode-hook-label { font-size: 0.75rem; font-weight: 800; letter-spacing: 0.04em; text-transform: uppercase; }
.episode-hook-title { font-size: 1.125rem; font-weight: 800; line-height: 1.3; overflow-wrap: anywhere; }
.episode-hook-teaser { font-size: 0.9375rem; line-height: 1.4; overflow-wrap: anywhere; }
.episode-hook-when { margin-top: 6px; font-size: 0.875rem; font-weight: 700; }

/* ---- episodes, version 5.1 */

/* A move inside the same closeness word: quieter than a word change, the same colours. */
.change-line.nudge span { font-weight: 500; }
/* A written reply that was just right: worth a little celebration. */
.change-line.native span { border: 1px solid var(--accent-line); background: var(--accent-soft); color: var(--accent-ink); font-weight: 700; }

/* A just-right answer: a chip, not a lesson; it opens to how it sounded. */
.episode-chip-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 6px 8px; padding: 6px 0 2px; }
.episode-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 36px;
  padding: 4px 14px;
  border: 1px solid var(--ok);
  border-radius: 999px;
  background: var(--ok-soft);
  color: var(--ok);
  font-size: 0.875rem;
  font-weight: 700;
}
.episode-chip-detail { flex-basis: 100%; padding: 8px 14px; border-radius: 14px; background: var(--ok-soft); color: var(--ink); font-size: 0.9375rem; line-height: 1.4; overflow-wrap: anywhere; }

/* "Why?" opens the rest of a note. */
.episode-why {
  align-self: flex-start;
  min-height: 32px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--accent-ink);
  font-size: 0.875rem;
  font-weight: 700;
  text-decoration: underline;
}
.episode-note-meant { color: var(--muted); font-size: 0.875rem; }
.episode-note .whatif-button { align-self: flex-start; margin-top: 4px; }

/* "What if I'd said…?": the option not sent, muted and dashed, so it is never taken for a message. */
.whatif-button { border-style: dashed; }
.whatif-label { padding: 0 6px 2px; color: var(--muted); font-size: 0.75rem; font-style: italic; font-weight: 700; }
.row.whatif .bubble { border: 1.5px dashed var(--muted); background: var(--surface-2); color: var(--muted); box-shadow: none; }
.row.whatif .avatar { opacity: 0.75; }
/*
 * The thread it opens in place, under the chip or inside the note: a quieter copy of the feed, without the
 * feed's own padding (the row or the note around it has that), a little faded as a whole, its bubbles a
 * size down, and a grey rule at the start so it reads as an aside, not as the next messages.
 */
.whatif-thread {
  gap: 2px;
  margin: 4px 0 2px;
  padding: 2px 0 2px 10px;
  border-inline-start: 2px solid var(--line);
  opacity: 0.85;
}
.whatif-thread .bubble { min-height: 36px; padding: 7px 12px; font-size: 0.9375rem; }
.whatif-thread .row.first { margin-top: 4px; }
.whatif-thread .row.first:first-child { margin-top: 0; }
.whatif-thread .whatif-label { padding-inline: 4px; }

/* The prompt and, beside it, the switch for the options' meanings. */
.episode-prompt-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.episode-meanings {
  flex: none;
  min-height: 32px;
  padding: 2px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--page);
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 700;
}
.episode-meanings[aria-pressed="true"] { border-color: var(--accent-line); color: var(--accent-ink); }

/* The streak on the end card. */
.episode-streak { display: flex; justify-content: center; }

/* The home card: where the episode before left off. */
.episode-card-hook { display: flex; flex-direction: column; gap: 6px; }
.episode-card-hook .row.first { margin-top: 0; }
.episode-card-line { min-height: 0; padding: 8px 12px; font-size: 0.9375rem; }
.episode-card-teaser { color: var(--ink); font-size: 0.9375rem; font-weight: 600; line-height: 1.4; overflow-wrap: anywhere; }

/* Until the first episode is finished: the chats wait behind one line. */
.rooms-locked { margin: 16px; padding: 14px 16px; border: 1px dashed var(--line); border-radius: 16px; color: var(--muted); font-weight: 600; text-align: center; }

/* ---- episodes, version 5.2: Season 1 complete */

/* The home card's top line: the kicker, and the way to the season. */
.episode-card-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.episode-card-season {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 44px;
  margin: -12px -8px -12px 0;
  padding: 0 8px;
  color: var(--accent-ink);
  font-size: 0.8125rem;
  font-weight: 700;
  text-decoration: none;
}

/* Beside the streak: the way to the notebook. */
.status-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 32px;
  padding: 4px 12px 4px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink);
  font-size: 0.875rem;
  font-weight: 700;
  text-decoration: none;
}

/* Under a list of expressions: the way to all of them. */
.section-link {
  display: inline-flex;
  align-items: center;
  align-self: flex-start;
  gap: 6px;
  min-height: 44px;
  margin-bottom: -10px;
  color: var(--accent-ink);
  font-size: 0.875rem;
  font-weight: 700;
  text-decoration: none;
}

/* "Get a message when the next episode opens": the words, and a switch or the way to save progress. */
.mail-row { display: flex; flex-direction: column; gap: 6px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 16px; background: var(--surface); }
.card .mail-row { padding: 0; border: 0; }
.mail-row .chip-button { align-self: flex-start; }
.mail-label { font-size: 0.9375rem; font-weight: 700; line-height: 1.35; }
.mail-switch { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 44px; }

/* A checkbox drawn as a switch: a track and a knob, the accent when on. */
.switch {
  position: relative;
  flex: none;
  width: 48px;
  height: 28px;
  margin: 0;
  border: 1px solid var(--field-line);
  border-radius: 999px;
  background: var(--surface-2);
  appearance: none;
  -webkit-appearance: none;
  transition: background-color 0.15s ease;
}
.switch::after {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--surface);
  box-shadow: 0 1px 2px var(--shade);
  content: "";
  transition: transform 0.15s ease;
}
.switch:checked { border-color: var(--accent); background: var(--accent); }
.switch:checked::after { transform: translateX(20px); }
.switch:disabled { opacity: 0.55; }

/* The season: every episode in order, each with its state. */
.season { display: flex; flex-direction: column; gap: 12px; padding: 18px 16px; padding-bottom: max(24px, env(safe-area-inset-bottom)); }
.season-head { display: flex; flex-direction: column; gap: 2px; }
.season-title { font-size: 1.5rem; font-weight: 800; line-height: 1.2; overflow-wrap: anywhere; }
.season-list { display: flex; flex-direction: column; gap: 8px; }

/* A state that does not fit beside the title (a time in a long language, at 375px) goes under it whole:
   the row wraps, the head keeps room for its title, and the state is never squeezed into a narrow column. */
.season-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 10px;
  width: 100%;
  min-height: 56px;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  color: inherit;
  font: inherit;
  text-align: start;
  text-decoration: none;
}
.season-row.open { border: 1.5px solid var(--accent); background: var(--accent-soft); }
.season-row.done .season-row-result { color: var(--ok); }
.season-row.locked, .season-row.soon { border-style: dashed; background: transparent; }
.season-row.soon .season-row-number { color: var(--muted); }
.season-row-head { display: flex; flex: 1 1 10rem; flex-direction: column; min-width: 0; }
.season-row-number { color: var(--muted); font-size: 0.75rem; font-weight: 700; }
.season-row-title { overflow: hidden; font-size: 0.9375rem; font-weight: 700; text-overflow: ellipsis; white-space: nowrap; }
.season-row-state { flex: 0 1 auto; max-width: 100%; color: var(--muted); font-size: 0.8125rem; font-weight: 600; line-height: 1.35; text-align: start; overflow-wrap: break-word; }
.season-row-result { flex: none; font-size: 0.875rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.season-now { background: var(--accent); color: var(--on-accent); }
.plus-tag { border: 1px solid var(--accent-line); background: var(--accent-soft); color: var(--accent-ink); }

/* After the season's last episode: the next season, announced. */
.season-next { display: flex; flex-direction: column; gap: 4px; padding: 14px 16px; border: 1.5px dashed var(--accent-line); border-radius: 14px; background: var(--accent-soft); }
.season-next-label { color: var(--accent-ink); font-size: 0.8125rem; font-weight: 700; }
.season-next-title { font-size: 1.0625rem; font-weight: 800; line-height: 1.3; overflow-wrap: anywhere; }
.season-next-teaser { color: var(--ink); font-size: 0.9375rem; line-height: 1.45; overflow-wrap: anywhere; }

/* The notebook: one card per episode, in the order they were finished. */
.notebook { display: flex; flex-direction: column; gap: 12px; padding: 16px; padding-bottom: max(24px, env(safe-area-inset-bottom)); }
.notebook-episode { margin-bottom: 0; }

/* ---- motion */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }

  .dots span { opacity: 0.7; }
}
