/* MTR station style: tiled header, route-map list */

:root {
  --tile: #e2231a;    /* Tsuen Wan line red */
  --word: #e2231a;
  --phrase: #00ab4e;  /* Kwun Tong line green */
  --island: #007dc5;  /* Island line blue */
  --tseung-kwan-o: #7d499d;  /* Tseung Kwan O line purple */
  --ink: #1a1a1a;
  --muted: #6b6b6b;
  --panel: #f4f4f1;
  --border: #d6d6d0;
  --radius: 10px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: #fff;
  color: var(--ink);
  font-family: "Noto Sans TC", system-ui, sans-serif;
  line-height: 1.5;
}

main {
  max-width: 44rem;
  margin: 0 auto;
  padding: 2rem 1rem 4rem;
}

/* Header: mosaic tile wall with the station name */

.station {
  background-color: var(--tile);
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.2) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.2) 1px, transparent 1px);
  background-size: 14px 14px;
  padding: 2.5rem 1rem 2rem;
}

.station-sign {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
  max-width: 44rem;
  margin: 0 auto;
  color: #fff;
}

.station-name {
  color: inherit;
  text-decoration: none;
}

.station nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 0.5rem;
}

.station nav a {
  white-space: nowrap;
  padding: 0.35rem 0.8rem;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.18);
  color: #fff;
  font-weight: 700;
  font-size: 0.9rem;
  text-decoration: none;
}

.station nav a:hover { background: rgba(0, 0, 0, 0.3); }

.station nav a[aria-current="page"] {
  background: #fff;
  color: var(--tile);
}

.station-sign .zh {
  display: block;
  font-size: clamp(2.75rem, 10vw, 4rem);
  font-weight: 900;
  letter-spacing: 0.15em;
  line-height: 1.1;
}

.station-sign .en {
  display: block;
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: 0.05em;
}

/* Add form */

.add-form {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.9rem 1rem;
  background: var(--panel);
  border-radius: var(--radius);
  padding: 1.25rem;
  margin-bottom: 2.5rem;
}

.add-form label {
  display: grid;
  gap: 0.3rem;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.add-form input,
.add-form select,
.add-form textarea {
  font: inherit;
  font-size: 1rem;
  font-weight: 400;
  letter-spacing: normal;
  text-transform: none;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.6rem 0.7rem;
}

.add-form input:focus,
.add-form select:focus,
.add-form textarea:focus {
  outline: 2px solid var(--tile);
  outline-offset: 1px;
}

.add-form button {
  grid-column: 1 / -1;
  justify-self: end;
  font: inherit;
  font-weight: 700;
  color: #fff;
  background: var(--tile);
  border: 0;
  border-radius: 999px;
  padding: 0.7rem 1.5rem;
  cursor: pointer;
}

.add-form button:hover { filter: brightness(0.9); }

.actions {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 1.25rem;
}

.actions a {
  color: var(--muted);
  font-weight: 700;
}

.add-form .wide { grid-column: 1 / -1; }

.add-form textarea {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.95rem;
  line-height: 1.6;
  resize: vertical;
}

@media (max-width: 560px) {
  .add-form { grid-template-columns: 1fr; }
  .add-form button { justify-self: stretch; }
}

/* List heading and legend */

.list-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}

.list-head h2 {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 900;
}

.legend {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.8rem;
  color: var(--muted);
}

.dot {
  width: 0.7rem;
  height: 0.7rem;
  border-radius: 50%;
  margin-left: 0.5rem;
}
.dot.word { background: var(--word); }
.dot.phrase { background: var(--phrase); }

/* Entries as stations on a route line, coloured by kind */

.route {
  list-style: none;
  margin: 0;
  padding: 0;
}

.route li {
  --c: var(--word);
  position: relative;
  margin-left: 0.6rem;
  padding: 0.5rem 4rem 1.25rem 2rem;
  border-left: 6px solid var(--c);
}

.route li.kind-phrase { --c: var(--phrase); }

.route li::before {
  content: "";
  position: absolute;
  left: -14px;
  top: 0.7rem;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #fff;
  border: 5px solid var(--c);
}

.route li.empty {
  --c: var(--border);
  color: var(--muted);
}

.romanisation {
  font-size: 1.2rem;
  font-weight: 700;
}

.alt {
  color: var(--muted);
  font-size: 0.95rem;
}

/* Form errors, full width at the top of the form */

.errors {
  grid-column: 1 / -1;
  margin: 0;
  padding: 0.6rem 0.9rem;
  list-style: none;
  border-left: 4px solid var(--tile);
  border-radius: 6px;
  background: #fdeceb;
  color: #a5140f;
  font-weight: 700;
}

/* Tags, notices, hints */

.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  margin-top: 0.35rem;
}

.tag {
  padding: 0.05rem 0.55rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 700;
}

.notice {
  margin: 0 0 1rem;
  padding: 0.6rem 0.9rem;
  border-left: 4px solid var(--phrase);
  border-radius: 6px;
  background: #e8f7ee;
  color: #00703a;
  font-weight: 700;
}

.hints {
  margin: 0;
  padding-left: 1.2rem;
  color: var(--muted);
  font-size: 0.9rem;
}

/* Edit page */

.page-title {
  margin: 0 0 1rem;
  font-size: 1.4rem;
  font-weight: 900;
}

.edit-link {
  position: absolute;
  top: 0.6rem;
  right: 0;
  padding: 0.1rem 0.65rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 700;
  text-decoration: none;
}

.edit-link:hover {
  border-color: var(--tile);
  color: var(--tile);
}

.delete-form {
  margin-top: 1.5rem;
  text-align: right;
}

.delete-form button {
  font: inherit;
  font-weight: 700;
  color: var(--tile);
  background: none;
  border: 1px solid var(--tile);
  border-radius: 999px;
  padding: 0.5rem 1.2rem;
  cursor: pointer;
}

.delete-form button:hover { background: #fdeceb; }

/* Sounds page: one MTR line colour per section */

.intro {
  margin: 0 0 1.5rem;
  color: var(--muted);
}

.intro code,
.sound-part {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

.sound-section { --c: var(--tile); margin-bottom: 2.5rem; }
.sound-section.tones { --c: var(--island); }
.sound-section.finals { --c: var(--phrase); }

.sound-section h2 {
  margin: 0 0 0.75rem;
  padding-left: 0.6rem;
  border-left: 6px solid var(--c);
  font-size: 1.3rem;
  font-weight: 900;
}

.sound-section h3 {
  margin: 1.25rem 0 0.5rem;
  color: var(--muted);
  font-size: 0.8rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.sound-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(9.5rem, 1fr));
  gap: 0.6rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.sound {
  padding: 0.6rem 0.75rem 0.7rem;
  border: 1px solid var(--border);
  border-top: 4px solid var(--c);
  border-radius: 8px;
}

.sound-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.3rem;
}

.sound-part {
  font-size: 1.15rem;
  font-weight: 700;
}

.yale-diff {
  padding: 0.05rem 0.4rem;
  border-radius: 4px;
  background: #fff1c2;
  color: #7a5200;
  font-size: 0.75rem;
  font-weight: 700;
}

.sound-example {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 0.35rem 0 0.15rem;
}

.char {
  font-size: 2rem;
  font-weight: 700;
  line-height: 1.2;
}

.play {
  width: 2.1rem;
  height: 2.1rem;
  border: 0;
  border-radius: 50%;
  background: var(--c, var(--tile));  /* red where no line colour is set */
  color: #fff;
  font-size: 0.8rem;
  cursor: pointer;
}

.play:hover { filter: brightness(0.9); }
.play:disabled { background: var(--border); cursor: not-allowed; }

.sound-reading {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.85rem;
}

.yale-reading {
  margin-left: 0.3rem;
  color: #7a5200;
}

.sound-english,
.sound-note {
  color: var(--muted);
  font-size: 0.85rem;
}

.sound-note { font-style: italic; }

/* Characters: hidden until "Show characters" */

.characters {
  display: none;
  font-size: 1.5rem;
  font-weight: 700;
  line-height: 1.3;
}

.show-characters .characters { display: block; }

.list-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: -0.25rem 0 1rem;
}

.list-tools form { margin: 0; }

.toggle {
  font: inherit;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.3rem 0.85rem;
  cursor: pointer;
}

.toggle:hover { border-color: var(--ink); }

.to-check {
  margin-left: 0.4rem;
  padding: 0.05rem 0.45rem;
  border-radius: 4px;
  background: #fff1c2;
  color: #7a5200;
  font-size: 0.7rem;
  font-weight: 700;
  vertical-align: middle;
  cursor: help;
}

.add-form .checkbox {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  letter-spacing: normal;
  text-transform: none;
  color: var(--ink);
}

.add-form .checkbox input { width: 1.1rem; height: 1.1rem; }

.hint {
  margin: 0;
  color: var(--muted);
  font-size: 0.85rem;
}

.warnings {
  grid-column: 1 / -1;
  margin: 0;
  padding: 0.6rem 0.9rem 0.6rem 1.8rem;
  border-left: 4px solid #e0a800;
  border-radius: 6px;
  background: #fff8e1;
  color: #7a5200;
  font-size: 0.9rem;
}

/* Play buttons in the entries list (route colour), and while loading */

.route .play { background: var(--c); }

.play.small {
  width: 1.6rem;
  height: 1.6rem;
  margin-left: 0.3rem;
  font-size: 0.65rem;
  vertical-align: middle;
}

.play.loading {
  cursor: progress;
  animation: loading 0.6s ease-in-out infinite alternate;
}

@keyframes loading {
  from { opacity: 1; }
  to { opacity: 0.35; }
}

@media (prefers-reduced-motion: reduce) {
  .play.loading { animation: none; opacity: 0.5; }
}

/* Search and tag filters */

.search {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.search input {
  flex: 1;
  min-width: 0;
  font: inherit;
  padding: 0.55rem 0.8rem;
  border: 1px solid var(--border);
  border-radius: 999px;
}

.search input:focus {
  outline: 2px solid var(--tile);
  outline-offset: 1px;
}

.search a { color: var(--muted); font-weight: 700; }

.tag-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-bottom: 1.5rem;
}

a.tag { text-decoration: none; }
a.tag:hover { border-color: var(--ink); color: var(--ink); }

.tag.active {
  border-color: var(--ink);
  background: var(--ink);
  color: #fff;
}

.tag .count { font-weight: 400; opacity: 0.7; }

/* Settings: radio choices */

.choice {
  display: grid;
  gap: 0.5rem;
  margin: 0;
  padding: 0;
  border: 0;
}

.choice legend {
  margin-bottom: 0.4rem;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.choice code { color: var(--muted); }

/* Example sentences */

.examples { margin-top: 0.4rem; }

.examples summary {
  cursor: pointer;
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 700;
}

.examples ul {
  margin: 0.4rem 0 0;
  padding-left: 0.9rem;
  border-left: 2px solid var(--border);
  list-style: none;
}

.examples li { padding: 0.25rem 0; }
.examples .characters { font-size: 1.1rem; }
.example-english { color: var(--muted); font-size: 0.9rem; }

.examples-section { margin-top: 2rem; }

.section-title {
  margin: 0 0 0.75rem;
  font-size: 1.1rem;
  font-weight: 900;
}

.example-list {
  display: grid;
  gap: 0.75rem;
  margin: 0 0 1rem;
  padding: 0;
  list-style: none;
}

.example {
  padding: 0.8rem 1rem;
  border: 1px solid var(--border);
  border-left: 4px solid var(--phrase);
  border-radius: 8px;
}

.example-head { display: flex; align-items: center; gap: 0.3rem; }
.example-characters { font-size: 1.4rem; font-weight: 700; }
.example-romanisation { font-weight: 700; }
.example .warnings { margin-top: 0.5rem; }

.example-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.6rem;
}

.example-actions form { margin: 0; }
.example .play { background: var(--phrase); }

/* Review: "To check" filter, warnings and confirm button */

a.toggle { text-decoration: none; }

.toggle.active {
  border-color: var(--ink);
  background: var(--ink);
  color: #fff;
}

.warning-line {
  display: none;
  color: #7a5200;
  font-size: 0.85rem;
}

.reviewing .warning-line { display: block; }

.confirm-form { margin: 0.4rem 0 0; }

.confirm-form .toggle {
  border-color: var(--phrase);
  color: #00703a;
}

.confirm-form .toggle:hover { background: #e8f7ee; }

/* Settings: backup, Claude spend */

.backup-section,
.spend-section,
.access-section { margin-top: 2.5rem; }
.backup-section .hint { margin-bottom: 0.75rem; }
.spend-lines { margin: 0 0 0.75rem; padding-left: 1.25rem; font-variant-numeric: tabular-nums; }

/* MTR lines: each line key sets --c, used by the map and the places */

.line-island { --c: var(--island); }
.line-tsuen_wan { --c: var(--tile); }
.line-kwun_tong { --c: var(--phrase); }
.line-tseung_kwan_o { --c: var(--tseung-kwan-o); }

/* Map */

.world-map {
  display: block;
  width: 100%;
  height: auto;
  margin: 0 0 1.5rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #fbfbf8;
}

.harbour { fill: #dcecf7; }

.harbour-label {
  fill: #7aa6c4;
  font-size: 2.2px;
  font-style: italic;
  text-anchor: middle;
}

.segment {
  stroke: var(--c);
  stroke-width: 1.6;
  stroke-linecap: round;
}

.station-link circle {
  fill: #fff;
  stroke: var(--c);
  stroke-width: 1.2;
}

.station-link:hover circle,
.station-link:focus circle { fill: var(--c); }

.station-zh { font-size: 3.6px; font-weight: 900; fill: var(--ink); }
.station-en { font-size: 2.6px; font-weight: 700; fill: var(--ink); }
.station-scene { font-size: 2.2px; fill: var(--muted); }

.station-list {
  margin: 0;
  padding: 0;
  list-style: none;
  counter-reset: stop;
}

.station-list li {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.25rem 1rem;
  padding: 0.6rem 0 0.6rem 0.9rem;
  border-left: 6px solid var(--c);
  margin-bottom: 0.4rem;
}

.station-list a {
  color: var(--ink);
  font-weight: 700;
  text-decoration: none;
}

.station-list-zh { margin-right: 0.4rem; font-size: 1.15rem; }
.station-list-scene { color: var(--muted); font-size: 0.85rem; }

/* A place */

.back { margin: 0 0 1rem; }
.back a { color: var(--muted); font-weight: 700; text-decoration: none; }

.station-wall {
  display: grid;
  justify-items: center;
  gap: 0.1rem;
  margin-bottom: 1.5rem;
  padding: 2rem 1rem 1.6rem;
  border-radius: var(--radius);
  background-color: var(--c);
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.18) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.18) 1px, transparent 1px);
  background-size: 14px 14px;
  color: #fff;
  text-align: center;
}

.wall-zh {
  font-size: clamp(2.5rem, 12vw, 4.5rem);
  font-weight: 900;
  letter-spacing: 0.2em;
  line-height: 1.1;
}

.wall-en { font-size: 1.3rem; font-weight: 700; }
.wall-reading { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; opacity: 0.85; }

.phrase-bank {
  margin: 0;
  padding: 0;
  list-style: none;
}

.phrase-bank li {
  padding: 0.55rem 0 0.55rem 0.9rem;
  border-left: 4px solid var(--border);
}

.phrase-bank li + li { border-top: 1px solid #efefea; }
.phrase-english { color: var(--muted); }

/* Map progress: locked, stamped, marker */

.progress-line {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.25rem;
  margin: -0.5rem 0 1rem;
  color: var(--muted);
}

.streak { color: var(--tile); }

.station-link.locked { --c: #b9b9b2; }
.station-link.locked text { fill: #9a9a93; }
.station-link.stamped circle { fill: var(--c); }

.stamp-tick {
  fill: none;
  stroke: #fff;
  stroke-width: 0.7;
  stroke-linecap: round;
  stroke-linejoin: round;
  pointer-events: none;
}

.marker path { fill: var(--ink); }
.marker-dot { fill: #fff; }
.marker-bob { animation: bob 1.6s ease-in-out infinite; }

@keyframes bob {
  50% { transform: translateY(-0.8px); }
}

@media (prefers-reduced-motion: reduce) {
  .marker-bob { animation: none; }
}

.station-list li.locked { --c: #cfcfc8; }
.station-list li.locked a { color: var(--muted); }
.done-mark { color: var(--phrase); font-weight: 900; }
.lock { font-size: 0.85em; }

/* Missions on a place */

.missions { margin: 0 0 2rem; }

.locked-note {
  margin: 0 0 0.75rem;
  padding: 0.6rem 0.9rem;
  border-radius: 6px;
  background: var(--panel);
  color: var(--muted);
}

.mission-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.6rem;
  padding: 0.8rem 1rem;
  border: 1px solid var(--border);
  border-left: 6px solid var(--c, var(--tile));
  border-radius: 8px;
}

.mission-card form { margin: 0; flex: none; }
.mission-title { font-weight: 900; }
.mission-prompt { color: var(--muted); font-size: 0.9rem; }
.mission-meta { color: var(--muted); font-size: 0.8rem; }
.toggle.start { border-color: var(--tile); color: var(--tile); }

.stamp-badge {
  padding: 0.05rem 0.5rem;
  border-radius: 999px;
  background: #e8f7ee;
  color: #00703a;
  font-size: 0.8rem;
  vertical-align: middle;
}

/* The mission screen */

.mission-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 1.25rem;
  padding: 1rem 1.2rem;
  border-radius: var(--radius);
  background: var(--c, var(--tile));
  color: #fff;
}

.mission-place { font-size: 1.1rem; font-weight: 900; letter-spacing: 0.15em; }
.mission-name { margin: 0; font-size: 1.4rem; }

.progress { display: flex; gap: 0.35rem; }

.pip {
  width: 0.8rem;
  height: 0.8rem;
  border: 2px solid #fff;
  border-radius: 50%;
}

.pip.passed { background: #fff; }
.pip.now { box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.4); }

.feedback {
  margin-bottom: 1.25rem;
  padding: 0.9rem 1.1rem;
  border-left: 6px solid var(--border);
  border-radius: 8px;
  background: var(--panel);
}

.feedback.correct { border-color: var(--phrase); background: #e8f7ee; }
.feedback.wrong_tone { border-color: #e0a800; background: #fff8e1; }
.feedback.wrong { border-color: var(--tile); background: #fdeceb; }

.feedback-title { font-weight: 900; }
.feedback-you { color: var(--muted); font-size: 0.9rem; }
.feedback-answer { margin-top: 0.4rem; font-size: 1.25rem; font-weight: 700; }
.feedback-characters { font-size: 1.5rem; }
.feedback-english { color: var(--muted); }

.tone-off {
  color: #a5140f;
  text-decoration: underline wavy #e0a800;
  text-underline-offset: 3px;
}

.answer-form {
  display: grid;
  gap: 0.6rem;
  padding: 1.1rem;
  border-radius: var(--radius);
  background: var(--panel);
}

.step-number {
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.cue { font-size: 1.3rem; font-weight: 900; }

.type-instead input {
  font: inherit;
  font-size: 1.15rem;
  padding: 0.7rem 0.8rem;
  border: 1px solid var(--border);
  border-radius: 6px;
}

.type-instead input:focus { outline: 2px solid var(--tile); outline-offset: 1px; }

.type-instead button {
  justify-self: end;
  font: inherit;
  font-weight: 700;
  color: #fff;
  background: var(--tile);
  border: 0;
  border-radius: 999px;
  padding: 0.7rem 1.5rem;
  cursor: pointer;
}

.hint-box { margin-top: 1rem; color: var(--muted); }
.hint-box summary { cursor: pointer; font-size: 0.9rem; }

.mission-done {
  padding: 1.5rem 1rem;
  text-align: center;
  border-radius: var(--radius);
  background: var(--panel);
}

.mission-done h2 { margin: 0.5rem 0 0.25rem; }

.done-stamp {
  display: inline-grid;
  place-items: center;
  width: 6rem;
  height: 6rem;
  border: 4px solid var(--tile);
  border-radius: 50%;
  color: var(--tile);
  font-size: 1.6rem;
  font-weight: 900;
  transform: rotate(-12deg);
}


/* Speaking: the mic */

.mic-row {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.mic {
  flex: none;
  width: 4.5rem;
  height: 4.5rem;
  border: 0;
  border-radius: 50%;
  background: var(--tile);
  color: #fff;
  font-size: 2rem;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}

.mic:hover { filter: brightness(0.92); }
.mic:disabled { background: var(--border); cursor: progress; }

.mic.recording { animation: listening 1.2s ease-in-out infinite; }

@keyframes listening {
  0%, 100% { box-shadow: 0 0 0 0 rgba(226, 35, 26, 0.45); }
  50% { box-shadow: 0 0 0 14px rgba(226, 35, 26, 0); }
}

@media (prefers-reduced-motion: reduce) {
  .mic.recording { animation: none; outline: 4px solid rgba(226, 35, 26, 0.4); }
}

.mic-status { margin: 0; color: var(--muted); }
.mic-status.error { color: #a5140f; font-weight: 700; }

.type-instead summary {
  cursor: pointer;
  color: var(--muted);
  font-size: 0.9rem;
}

.type-instead form {
  display: grid;
  gap: 0.6rem;
  margin-top: 0.6rem;
}

/* Tone melody score and chart */

.tone-score {
  margin-top: 0.8rem;
  padding-top: 0.7rem;
  border-top: 1px solid rgba(0, 0, 0, 0.08);
}

.tone-number { font-size: 0.95rem; }
.tone-number b { font-size: 1.3rem; }
.tone-number.great b { color: #00703a; }
.tone-number.close b { color: #7a5200; }
.tone-number.practise b { color: #a5140f; }

.tone-chart {
  display: block;
  width: 100%;
  height: 7rem;
  margin-top: 0.4rem;
  border-radius: 6px;
  background: #fff;
}

.tone-mid { stroke: var(--border); stroke-width: 0.5; vector-effect: non-scaling-stroke; }

.tone-native,
.tone-you {
  fill: none;
  stroke-width: 3;
  stroke-linecap: round;
  stroke-linejoin: round;
  vector-effect: non-scaling-stroke;
}

.tone-native { stroke: #9ab8cf; }
.tone-you { stroke: var(--tile); }

.tone-legend {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  margin-top: 0.3rem;
  color: var(--muted);
  font-size: 0.8rem;
}

.tone-legend .key {
  display: inline-block;
  width: 1rem;
  height: 3px;
  margin-left: 0.4rem;
  border-radius: 2px;
}

.tone-legend .key.native { background: #9ab8cf; }
.tone-legend .key.you { background: var(--tile); }

/* What speech recognition heard, read in romanisation */
.heard-reading { margin-left: 0.5rem; white-space: nowrap; }

/* Painted scenes and portraits (data/art.json, python -m app.art) */

.scene-picture {
  position: relative;
  margin-bottom: 1.5rem;
  overflow: hidden;
  border-radius: var(--radius);
  background: var(--panel);
}

.scene-picture img {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
}

.scene-sign {  /* the MTR sign over a scene: the line colour, white names */
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.2rem 0.9rem;
  padding: 0.55rem 1rem;
  background: var(--c);
  color: #fff;
}

.sign-zh { font-size: 1.6rem; font-weight: 900; letter-spacing: 0.15em; }
.sign-en { font-size: 1.05rem; font-weight: 700; }

.cue-row {
  display: flex;
  align-items: center;
  gap: 0.9rem;
}

.portrait {
  flex: none;
  width: 4.5rem;
  height: 4.5rem;
  border: 3px solid var(--c, var(--tile));
  border-radius: 50%;
  object-fit: cover;
}

.portrait.small { width: 2.75rem; height: 2.75rem; border-width: 2px; }

/* "You'll talk to 何小姐 Ms Ho, ..." under a place's description */
.persona-line {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  margin: 0.5rem 0 1rem;
}

/* ▶ on a sign in the line colour: white button, coloured triangle */
.scene-sign .play,
.station-wall .play,
.mission-head .play { background: #fff; color: var(--c, var(--tile)); }
.scene-sign .play { margin-left: auto; align-self: center; }

/* The robot (step 8): chat buttons on a place, and the conversation */

.talk-form {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: -0.4rem 0 1.2rem;
  font-weight: 700;
}

.chat {
  display: grid;
  gap: 0.8rem;
  margin: 1rem 0;
  padding: 0;
  list-style: none;
}

.chat-turn { display: flex; align-items: flex-end; gap: 0.6rem; }
.chat-turn.me { justify-content: flex-end; }

.bubble {
  max-width: 85%;
  padding: 0.7rem 0.9rem;
  border-radius: 14px;
  background: var(--panel);
}

.persona .bubble { border-left: 4px solid var(--c, var(--tile)); border-bottom-left-radius: 4px; }
.me .bubble { background: #eef3f8; border-bottom-right-radius: 4px; }

.chat-line { font-size: 1.25rem; font-weight: 700; }
.me .chat-line { font-size: 1.05rem; font-weight: 600; }

.chat-reading {
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.85rem;
}

.chat-english { margin-top: 0.3rem; color: var(--muted); font-size: 0.9rem; }
.chat-english summary { cursor: pointer; }

.correction {
  margin-bottom: 0.6rem;
  padding: 0.5rem 0.7rem;
  border-radius: 8px;
  background: #fff8e1;
}

.correction-label { font-weight: 700; color: #7a5200; }
.correction-note { font-size: 0.9rem; }

.new-word {
  margin-top: 0.4rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--phrase);
}

.chat-warnings { margin-top: 0.4rem; font-size: 0.8rem; color: #7a5200; }

.chat-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.5rem;
  margin-top: 1rem;
}

.chat-form .errors { grid-column: 1 / -1; }

.chat-form input {
  font: inherit;
  font-size: 1.1rem;
  padding: 0.7rem 0.8rem;
  border: 1px solid var(--border);
  border-radius: 6px;
}

.chat-form input:focus { outline: 2px solid var(--tile); outline-offset: 1px; }

.chat-form button {
  font: inherit;
  font-weight: 700;
  color: #fff;
  background: var(--tile);
  border: 0;
  border-radius: 6px;
  padding: 0 1.1rem;
  cursor: pointer;
}

.chat-form button:disabled { background: var(--muted); cursor: progress; }

.chat ~ .mic-row { margin-top: 1rem; }

/* Chat missions (step 8d): the goals, next to where I answer */

.goals {
  margin-top: 1rem;
  padding: 0.8rem 1rem;
  border-left: 6px solid var(--c, var(--tile));
  border-radius: var(--radius);
  background: var(--panel);
}

.goals-title { margin: 0 0 0.4rem; font-size: 1rem; }
.goals ul { display: grid; gap: 0.25rem; margin: 0; padding: 0; list-style: none; }
.goal-mark { display: inline-block; width: 1.2rem; color: var(--muted); font-weight: 900; }
.goal.reached { color: var(--muted); }
.goal.reached .goal-mark { color: var(--c, var(--tile)); }

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* Practice (step 8c): counts, boxes */

.practice-line { margin-left: auto; color: var(--muted); font-size: 0.9rem; font-weight: 600; }
.practice-counts { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.practice-counts .count {
  padding: 0.3rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  font-weight: 700;
}
.practice-counts .count.due { border-color: var(--tile); color: var(--tile); }
.practice-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 0.8rem;
  margin-top: 0.2rem;
  color: var(--muted);
  font-size: 0.8rem;
}
.boxes { display: inline-flex; gap: 3px; align-items: center; }
.box { width: 0.6rem; height: 0.6rem; border: 1px solid var(--border); border-radius: 2px; }
.box.full { background: var(--phrase); border-color: var(--phrase); }
.practice-group { margin-top: 1.2rem; }
.practice-group summary { cursor: pointer; font-weight: 700; font-size: 1.1rem; }
