:root {
  color-scheme: light;
  --bg: #f4fbff;
  --ink: #152033;
  --muted: #64748b;
  --line: #cfe0ef;
  --panel: #ffffff;
  --cyan: #22c6f3;
  --blue: #2563eb;
  --lime: #a3e635;
  --yellow: #facc15;
  --coral: #fb7185;
  --violet: #8b5cf6;
  --green: #10b981;
  --shadow: 0 18px 45px rgba(37, 99, 235, 0.14);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    linear-gradient(135deg, rgba(34, 198, 243, 0.16), transparent 36%),
    linear-gradient(225deg, rgba(250, 204, 21, 0.22), transparent 32%),
    var(--bg);
}

button,
input {
  font: inherit;
}

button {
  border: 0;
}

a {
  color: inherit;
  text-decoration: none;
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: grid;
  grid-template-columns: minmax(180px, 1fr) auto minmax(180px, 1fr);
  gap: 18px;
  align-items: center;
  padding: 14px clamp(16px, 4vw, 42px);
  background: rgba(244, 251, 255, 0.88);
  border-bottom: 1px solid rgba(207, 224, 239, 0.8);
  backdrop-filter: blur(16px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.brand-mark {
  display: grid;
  width: 40px;
  height: 40px;
  place-items: center;
  color: white;
  font-weight: 900;
  background: linear-gradient(135deg, var(--blue), var(--cyan));
  border-radius: 8px;
  box-shadow: 0 10px 24px rgba(37, 99, 235, 0.28);
}

.brand strong,
.brand small {
  display: block;
  line-height: 1.1;
}

.brand small {
  color: var(--muted);
  margin-top: 3px;
}

.top-nav {
  display: inline-flex;
  align-items: center;
  padding: 4px;
  gap: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  box-shadow: 0 10px 25px rgba(21, 32, 51, 0.08);
}

.top-nav a {
  padding: 9px 14px;
  border-radius: 6px;
  color: #334155;
  font-weight: 700;
  white-space: nowrap;
}

.top-nav a:hover,
.top-nav a.active {
  color: white;
  background: var(--blue);
}

.service-status {
  justify-self: end;
  max-width: 320px;
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.header-actions {
  justify-self: end;
  display: inline-flex;
  gap: 10px;
  align-items: center;
  min-width: 0;
}

.pwa-install-button {
  min-height: 36px;
  padding: 0 12px;
  color: white;
  font-weight: 900;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--blue), var(--violet));
  box-shadow: 0 10px 22px rgba(37, 99, 235, 0.22);
  cursor: pointer;
}

.pwa-install-button:hover {
  filter: brightness(1.05);
}

.is-offline .service-status {
  color: #b45309;
  font-weight: 800;
}

.app-shell {
  width: min(1180px, calc(100% - 28px));
  margin: 24px auto 56px;
}

.hero-band,
.toolbar-band,
.audio-band,
.stats-band,
.empty-state {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.88);
  box-shadow: var(--shadow);
}

.hero-band {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(240px, 0.8fr);
  gap: 18px;
  align-items: center;
  padding: clamp(20px, 4vw, 32px);
  border-radius: 8px;
}

.hero-band h1,
.page-title h1 {
  margin: 0;
  font-size: clamp(28px, 5vw, 52px);
  line-height: 1.05;
  letter-spacing: 0;
}

.hero-band p,
.page-title p {
  color: var(--muted);
  line-height: 1.7;
}

.hero-metrics {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.metric-tile {
  min-height: 94px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(180deg, white, #f8fdff);
}

.metric-tile strong {
  display: block;
  font-size: 28px;
}

.metric-tile span {
  color: var(--muted);
  font-size: 13px;
}

.section-head {
  display: flex;
  gap: 14px;
  align-items: flex-end;
  justify-content: space-between;
  margin: 28px 0 14px;
}

.section-head h2 {
  margin: 0;
  font-size: 24px;
}

.section-head p {
  margin: 5px 0 0;
  color: var(--muted);
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(270px, 1fr));
  gap: 16px;
}

.course-card,
.lesson-card,
.record-card,
.line-row,
.chart-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 12px 28px rgba(21, 32, 51, 0.08);
}

.course-card,
.lesson-card {
  display: grid;
  gap: 14px;
  min-height: 210px;
  padding: 18px;
  position: relative;
  overflow: hidden;
}

.course-card.is-read,
.lesson-card.is-read {
  border-color: #86efac;
  background: linear-gradient(180deg, #f0fdf4, #ffffff);
  box-shadow: 0 16px 34px rgba(16, 185, 129, 0.16);
}

.course-card.is-unread,
.lesson-card.is-unread {
  border-style: dashed;
  border-color: #cbd5e1;
  background: linear-gradient(180deg, #f8fafc, #ffffff);
  box-shadow: none;
}

.course-card.is-read::before,
.lesson-card.is-read::before,
.line-row.is-read::before,
.line-row.is-unread::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 6px;
}

.course-card.is-read::before,
.lesson-card.is-read::before,
.line-row.is-read::before {
  background: linear-gradient(180deg, #22c55e, #22c6f3);
}

.line-row.is-unread::before {
  background: #cbd5e1;
}

.course-card h3,
.lesson-card h3 {
  margin: 0;
  font-size: 20px;
}

.course-card p,
.lesson-card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
}

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

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 4px 9px;
  color: #31506d;
  background: #e9f8ff;
  border: 1px solid #bdeaff;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
}

.is-read .status-pill {
  color: #065f46;
  background: #dcfce7;
  border-color: #86efac;
}

.is-unread .status-pill {
  color: #475569;
  background: #f1f5f9;
  border-color: #cbd5e1;
}

.progress-track {
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: #e2e8f0;
}

.progress-fill {
  width: 0;
  height: 100%;
  background: linear-gradient(90deg, var(--cyan), var(--lime));
}

.primary-button,
.ghost-button,
.danger-button,
.warning-button,
.small-button,
.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 38px;
  padding: 0 14px;
  border-radius: 8px;
  font-weight: 900;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.primary-button {
  color: white;
  background: linear-gradient(135deg, var(--blue), var(--cyan));
  box-shadow: 0 12px 22px rgba(37, 99, 235, 0.22);
}

.ghost-button {
  color: #1d4ed8;
  background: #eaf6ff;
  border: 1px solid #b6e6ff;
}

.danger-button {
  color: white;
  background: linear-gradient(135deg, #f43f5e, #fb923c);
}

.warning-button {
  color: #713f12;
  background: #fef3c7;
  border: 1px solid #facc15;
}

.small-button,
.icon-button,
.time-chip {
  min-height: 34px;
  padding: 0 10px;
  color: #24405f;
  background: #f8fbff;
  border: 1px solid var(--line);
}

.icon-button {
  width: 36px;
  padding: 0;
}

.time-chip {
  min-height: 26px;
  width: 54px;
  padding: 0;
  color: #0f766e;
  background: #ecfeff;
  border-color: #a5f3fc;
  font-size: 12px;
  font-weight: 950;
}

.time-range {
  color: #64748b;
  font-size: 11px;
  font-weight: 800;
  line-height: 1.2;
  text-align: center;
}

.primary-button:hover,
.ghost-button:hover,
.danger-button:hover,
.warning-button:hover,
.small-button:hover,
.icon-button:hover,
.time-chip:hover {
  transform: translateY(-1px);
}

.primary-button:disabled,
.ghost-button:disabled,
.danger-button:disabled,
.warning-button:disabled,
.small-button:disabled,
.icon-button:disabled,
.time-chip:disabled {
  cursor: not-allowed;
  opacity: 0.55;
  transform: none;
}

.busy-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(244, 251, 255, 0.72);
  backdrop-filter: blur(8px);
}

.busy-overlay[aria-hidden="true"] {
  display: none;
}

.busy-overlay div {
  display: grid;
  gap: 8px;
  width: min(360px, 92vw);
  padding: 20px;
  color: #12395a;
  background: white;
  border: 1px solid #bdeaff;
  border-radius: 8px;
  box-shadow: var(--shadow);
  text-align: center;
}

.busy-overlay strong {
  font-size: 18px;
}

.busy-overlay span {
  color: var(--muted);
  line-height: 1.5;
}

.pwa-toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 60;
  display: flex;
  gap: 12px;
  align-items: center;
  max-width: min(420px, calc(100vw - 28px));
  padding: 12px 14px;
  color: #0f172a;
  border: 1px solid #bfdbfe;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 18px 42px rgba(21, 32, 51, 0.18);
  transform: translateY(0);
  transition: opacity 0.18s ease, transform 0.18s ease;
}

.pwa-toast[aria-hidden="true"] {
  pointer-events: none;
  opacity: 0;
  transform: translateY(12px);
}

.pwa-toast button {
  min-height: 34px;
  padding: 0 12px;
  color: white;
  font-weight: 900;
  border-radius: 8px;
  background: var(--blue);
  cursor: pointer;
}

.toolbar-band,
.audio-band,
.stats-band {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  padding: 14px;
  border-radius: 8px;
}

.toolbar-left,
.toolbar-right {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  padding: 0 10px;
  color: #24405f;
  background: white;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-weight: 800;
}

.toggle input {
  width: 18px;
  height: 18px;
  accent-color: var(--blue);
}

.audio-band audio {
  flex: 1 1 380px;
  min-width: 260px;
  height: 40px;
}

.lesson-lines {
  display: grid;
  gap: 12px;
}

.line-row {
  display: grid;
  grid-template-columns: 58px minmax(0, 1fr) minmax(210px, auto);
  gap: 12px;
  align-items: start;
  padding: 14px;
  position: relative;
  overflow: hidden;
}

.line-row.is-read {
  border-color: #86efac;
  background: linear-gradient(90deg, #f0fdf4, #ffffff 38%);
  box-shadow: 0 12px 28px rgba(16, 185, 129, 0.13);
}

.line-row.is-unread {
  border-style: dashed;
  border-color: #cbd5e1;
  background: #f8fafc;
  box-shadow: none;
}

.line-row.playing {
  border-color: #22c6f3;
  background: linear-gradient(90deg, rgba(34, 198, 243, 0.14), white 38%);
  box-shadow: 0 16px 34px rgba(34, 198, 243, 0.18);
}

.line-row.is-recording {
  border-color: #fb7185;
  background:
    linear-gradient(90deg, rgba(255, 241, 242, 0.98), #ffffff 42%),
    white;
  box-shadow: 0 18px 38px rgba(244, 63, 94, 0.2);
}

.line-row.is-recording::after {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 5px;
  background: linear-gradient(180deg, #fb7185, #facc15, #22c55e);
}

.line-marker {
  display: grid;
  justify-items: center;
  gap: 7px;
}

.read-state-chip {
  min-width: 38px;
  padding: 2px 6px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 950;
  text-align: center;
}

.line-row.is-read .read-state-chip {
  color: #065f46;
  background: #dcfce7;
  border: 1px solid #86efac;
}

.line-row.is-unread .read-state-chip {
  color: #64748b;
  background: #f1f5f9;
  border: 1px solid #cbd5e1;
}

.line-number {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  color: white;
  font-weight: 900;
  background: linear-gradient(135deg, var(--violet), var(--blue));
  border-radius: 8px;
}

.line-text {
  display: grid;
  gap: 8px;
  min-width: 0;
}

.english {
  margin: 0;
  font-size: 18px;
  line-height: 1.55;
  font-weight: 800;
}

.word-token {
  display: inline;
  margin: 0;
  padding: 1px 2px;
  color: #0f3f92;
  font: inherit;
  font-weight: inherit;
  line-height: inherit;
  border-radius: 5px;
  background: transparent;
  cursor: pointer;
  text-decoration: underline;
  text-decoration-color: rgba(34, 198, 243, 0.38);
  text-decoration-thickness: 2px;
  text-underline-offset: 3px;
}

.word-token:hover,
.word-token:focus-visible {
  color: #0f172a;
  background: #dff7ff;
  outline: 2px solid rgba(34, 198, 243, 0.55);
  outline-offset: 2px;
}

.translation,
.ipa {
  display: none;
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
}

.show-zh .translation,
.show-ipa .ipa {
  display: block;
}

.ipa {
  color: #6d28d9;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 14px;
}

.line-actions {
  display: grid;
  justify-items: end;
  gap: 8px;
  min-width: 210px;
}

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

.score-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 62px;
  height: 32px;
  padding: 0 10px;
  border-radius: 999px;
  color: #334155;
  background: #eef2f7;
  font-weight: 950;
}

.score-low {
  color: white;
  background: #ef4444;
}

.score-fair {
  color: #3c2a04;
  background: var(--yellow);
}

.score-good {
  color: #052e1b;
  background: #86efac;
}

.score-great {
  color: white;
  background: linear-gradient(135deg, var(--blue), var(--green));
}

.pending {
  color: #475569;
  background: #e2e8f0;
}

.record-meta {
  color: var(--muted);
  font-size: 12px;
  text-align: right;
}

.mini-audio {
  width: 210px;
  height: 34px;
}

.status-line {
  min-height: 24px;
  color: var(--muted);
  font-size: 13px;
}

.recording-banner {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  width: fit-content;
  max-width: 100%;
  padding: 9px 11px;
  color: #881337;
  border: 1px solid #fda4af;
  border-radius: 8px;
  background: #fff1f2;
  box-shadow: 0 8px 18px rgba(244, 63, 94, 0.12);
}

.recording-banner strong {
  font-size: 14px;
  font-weight: 950;
}

.recording-banner span:last-child {
  color: #9f1239;
  font-size: 13px;
  font-weight: 850;
}

.recording-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: #ef4444;
  box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.55);
  animation: recordingPulse 1.1s infinite;
}

@keyframes recordingPulse {
  70% {
    box-shadow: 0 0 0 9px rgba(239, 68, 68, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(239, 68, 68, 0);
  }
}

.word-popover {
  position: absolute;
  z-index: 30;
  display: none;
  padding: 14px;
  border: 1px solid #bae6fd;
  border-radius: 8px;
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.98), rgba(240, 249, 255, 0.98)),
    white;
  box-shadow: 0 24px 60px rgba(15, 23, 42, 0.2);
}

.word-popover[aria-hidden="false"] {
  display: grid;
  gap: 11px;
}

.word-card-head {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  justify-content: space-between;
}

.word-card-head strong {
  display: block;
  font-size: 24px;
  line-height: 1.05;
}

.word-card-head span {
  display: block;
  margin-top: 5px;
  color: #6d28d9;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 15px;
}

.word-close {
  width: 30px;
  height: 30px;
  min-width: 30px;
}

.word-chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.word-chip-row span,
.word-actions small {
  padding: 4px 8px;
  color: #0f4f74;
  font-size: 12px;
  font-weight: 900;
  border: 1px solid #bae6fd;
  border-radius: 999px;
  background: #effbff;
}

.word-meaning-list,
.word-variant {
  display: grid;
  gap: 6px;
  padding: 10px;
  border: 1px solid #dbeafe;
  border-radius: 8px;
  background: white;
}

.word-meaning-list p,
.word-variant p,
.word-error {
  margin: 0;
  color: #334155;
  line-height: 1.55;
  font-size: 14px;
}

.word-variant strong {
  color: #6d28d9;
  font-size: 13px;
}

.word-actions {
  display: flex;
  gap: 9px;
  align-items: center;
  justify-content: space-between;
}

.feedback-panel {
  border: 1px solid #c7e8ff;
  border-radius: 8px;
  background: #f5fbff;
  overflow: hidden;
}

.feedback-panel summary {
  cursor: pointer;
  padding: 9px 11px;
  color: #0f4f74;
  font-size: 13px;
  font-weight: 950;
}

.feedback-panel p {
  margin: 0;
  padding: 0 11px 10px;
  color: #31506d;
  line-height: 1.55;
}

.feedback-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  padding: 0 11px 8px;
}

.feedback-summary span {
  display: inline-flex;
  min-height: 24px;
  align-items: center;
  padding: 2px 8px;
  color: #36516f;
  background: white;
  border: 1px solid #d7ebfb;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
}

.feedback-list {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0 11px 11px;
  list-style: none;
}

.feedback-list li {
  display: grid;
  gap: 4px;
  padding: 9px;
  border: 1px solid #d7ebfb;
  border-radius: 8px;
  background: white;
}

.feedback-list strong {
  color: #12395a;
  font-size: 13px;
}

.feedback-list span {
  color: #475569;
  font-size: 13px;
  line-height: 1.5;
}

.issue-details {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.issue-details span {
  display: inline-flex;
  min-height: 23px;
  align-items: center;
  gap: 4px;
  padding: 2px 7px;
  color: #214866;
  background: #eef8ff;
  border: 1px solid #ccecff;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
}

.issue-details .phone-detail {
  border-color: #d8b4fe;
  background: #faf5ff;
  color: #5b21b6;
}

.issue-details b {
  font-weight: 950;
}

.all-issues {
  margin: 0 11px 11px;
}

.all-issues summary {
  display: inline-flex;
  min-height: 32px;
  align-items: center;
  padding: 0 11px;
  color: white;
  background: linear-gradient(135deg, var(--violet), var(--blue));
  border-radius: 8px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 950;
}

.all-issues .feedback-list {
  margin-top: 8px;
  padding: 0;
}

.report-details {
  margin: 0 11px 11px;
  border: 1px solid #d7ebfb;
  border-radius: 8px;
  background: white;
  overflow: hidden;
}

.report-details summary,
.raw-report summary {
  padding: 8px 10px;
  color: #144563;
  font-size: 12px;
  font-weight: 950;
}

.report-metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 7px;
  padding: 0 10px 10px;
}

.report-metrics span {
  display: grid;
  gap: 3px;
  min-height: 44px;
  padding: 7px 8px;
  color: #29445f;
  background: #f8fcff;
  border: 1px solid #d7ebfb;
  border-radius: 8px;
  font-size: 12px;
}

.report-metrics b {
  color: #64748b;
  font-size: 11px;
}

.report-block {
  padding: 0 10px 10px;
}

.report-block strong {
  color: #144563;
  font-size: 12px;
}

.raw-report {
  margin: 0 10px 10px;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  background: #f8fafc;
}

.raw-report pre {
  max-height: 260px;
  margin: 0;
  padding: 10px;
  overflow: auto;
  color: #0f172a;
  font-size: 11px;
  line-height: 1.45;
  white-space: pre-wrap;
}

.candidate-panel {
  display: grid;
  gap: 10px;
  margin-top: 10px;
  padding: 11px;
  border: 2px solid #facc15;
  border-radius: 8px;
  background: linear-gradient(180deg, #fffbeb, #ffffff);
}

.candidate-head {
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
}

.candidate-head strong,
.candidate-head span {
  display: block;
}

.candidate-head strong {
  color: #713f12;
  font-size: 14px;
}

.candidate-head span {
  margin-top: 3px;
  color: #854d0e;
  font-size: 12px;
}

.candidate-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  justify-content: flex-end;
}

.reading-stage {
  display: grid;
  gap: 16px;
}

.lesson-topbar {
  border-color: #bee8fb;
  background: rgba(255, 255, 255, 0.92);
}

.lesson-audio-band {
  border: 2px solid #132033;
  background: #ffffff;
  box-shadow: 7px 7px 0 rgba(34, 198, 243, 0.22);
}

.reading-paper {
  position: relative;
  display: grid;
  gap: 8px;
  padding: clamp(16px, 3.4vw, 34px);
  border: 3px solid #111827;
  border-radius: 26px;
  background: #fffef8;
  box-shadow: 10px 10px 0 rgba(37, 99, 235, 0.12), 0 18px 45px rgba(21, 32, 51, 0.08);
}

.paper-title {
  display: grid;
  gap: 4px;
  max-width: 760px;
  margin: 0 auto 4px;
  text-align: center;
}

.paper-title h2 {
  margin: 0;
  color: #111827;
  font-family: "Comic Sans MS", "Chalkboard SE", "Marker Felt", system-ui, sans-serif;
  font-size: clamp(24px, 4vw, 38px);
  line-height: 1.15;
}

.paper-title p {
  margin: 0;
  color: #31506d;
  font-size: 13px;
  font-weight: 850;
  line-height: 1.35;
}

.paper-lines {
  gap: 0;
}

#articleChallenge {
  scroll-margin-top: 154px;
}

.paper-lines .line-row {
  display: block;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  overflow: visible;
  scroll-margin-top: 154px;
}

.paper-lines .line-row::before,
.paper-lines .line-row::after {
  display: none;
}

.line-read-target {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) minmax(120px, auto);
  gap: 8px;
  align-items: start;
  width: 100%;
  min-height: 42px;
  padding: 5px 8px;
  color: inherit;
  border: 2px solid transparent;
  border-radius: 8px;
  background: transparent;
  cursor: pointer;
  text-align: left;
}

.line-read-target:hover,
.line-read-target:focus-visible,
.line-row.is-expanded .line-read-target {
  border-color: #111827;
  background: #ffffff;
  outline: none;
  box-shadow: 4px 4px 0 rgba(250, 204, 21, 0.35);
}

.line-row.is-current .line-read-target {
  border-color: #facc15;
  background: #fff8db;
}

.line-row.is-locked .line-read-target {
  color: #64748b;
  background: rgba(248, 250, 252, 0.72);
}

.line-copy {
  display: grid;
  gap: 1px;
  min-width: 0;
}

.line-copy .english {
  display: block;
  margin: 0;
  color: #111827;
  font-family: "Comic Sans MS", "Chalkboard SE", "Marker Felt", system-ui, sans-serif;
  font-size: clamp(15px, 2vw, 18px);
  font-weight: 800;
  line-height: 1.32;
}

.line-copy .translation {
  margin: 0;
  color: #111827;
  font-size: 14px;
  line-height: 1.28;
}

.line-copy .ipa {
  margin: 4px 0 0;
}

.line-side {
  display: grid;
  justify-items: end;
  gap: 4px;
}

.time-chip-static {
  min-width: 54px;
  padding: 2px 6px;
  color: #0f766e;
  border: 1px solid #a5f3fc;
  border-radius: 999px;
  background: #ecfeff;
  font-size: 11px;
  font-weight: 950;
  text-align: center;
}

.line-bubble {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  max-width: 172px;
  padding: 2px 7px;
  border: 2px solid currentColor;
  border-radius: 999px 999px 999px 6px;
  background: #ffffff;
  font-size: 11px;
  font-weight: 950;
  line-height: 1.25;
  text-align: right;
}

.current-bubble {
  color: #b45309;
  background: #fffbeb;
}

.locked-bubble {
  color: #64748b;
  background: #f8fafc;
}

.pending-bubble,
.neutral-bubble {
  color: #2563eb;
  background: #eff6ff;
}

.low-bubble {
  color: #b91c1c;
  background: #fff1f2;
}

.fair-bubble {
  color: #92400e;
  background: #fffbeb;
}

.good-bubble {
  color: #047857;
  background: #ecfdf5;
}

.great-bubble {
  color: #1d4ed8;
  background: #eff6ff;
}

.locked-word {
  color: inherit;
  text-decoration: none;
  cursor: default;
}

.locked-word:hover,
.locked-word:focus-visible {
  background: transparent;
  outline: 0;
}

.locked-hint {
  margin: 0 10px 6px 50px;
  color: #64748b;
  font-size: 13px;
  font-weight: 800;
}

.expanded-actions {
  justify-items: stretch;
  width: min(720px, calc(100% - 52px));
  min-width: 0;
  margin: 2px 8px 8px auto;
  padding: 10px;
  border: 2px solid #111827;
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 5px 5px 0 rgba(34, 198, 243, 0.18);
}

.action-head {
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
}

.recording-playback {
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: flex-end;
}

.recording-playback span {
  color: #31506d;
  font-size: 12px;
  font-weight: 950;
}

.current-version-meta {
  display: block;
  color: #31506d;
  font-size: 12px;
  font-weight: 900;
}

.locked-actions {
  color: #64748b;
  border-color: #cbd5e1;
  background: #f8fafc;
  box-shadow: none;
}

.locked-actions strong,
.locked-actions span {
  display: block;
}

.locked-actions span {
  margin-top: 4px;
  line-height: 1.55;
}

.article-challenge {
  display: grid;
  gap: 8px;
  margin: 0 0 8px;
  padding: 10px 12px;
  border: 3px solid #111827;
  border-radius: 14px;
  background: #f0fbff;
  box-shadow: 6px 6px 0 rgba(250, 204, 21, 0.28);
  scroll-margin-top: 154px;
}

.article-challenge.is-locked {
  color: #64748b;
  border-color: #94a3b8;
  background: #f8fafc;
  box-shadow: none;
}

.article-challenge-head {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
}

.article-challenge-head strong,
.article-challenge-head small {
  display: block;
}

.article-challenge-head strong {
  color: #111827;
  font-size: 16px;
}

.article-challenge-head small {
  margin-top: 2px;
  color: #31506d;
  font-weight: 850;
  line-height: 1.35;
}

.article-actions {
  width: 100%;
  margin: 0;
}

.feedback-list em {
  color: #0f766e;
  font-size: 13px;
  font-style: normal;
  font-weight: 800;
  line-height: 1.5;
}

.feedback-more {
  color: var(--muted);
  font-size: 12px;
}

.empty-state {
  display: grid;
  min-height: 220px;
  place-items: center;
  padding: 24px;
  border-radius: 8px;
  color: var(--muted);
  text-align: center;
}

.pulse-line {
  width: min(320px, 80%);
  height: 10px;
  border-radius: 999px;
  background: linear-gradient(90deg, #dbeafe, #67e8f9, #dbeafe);
  background-size: 220% 100%;
  animation: pulse 1.1s linear infinite;
}

@keyframes pulse {
  to {
    background-position: 220% 0;
  }
}

.record-list {
  display: grid;
  gap: 12px;
}

.record-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  padding: 14px;
}

.record-card h3 {
  margin: 0 0 8px;
  font-size: 17px;
}

.record-card p {
  margin: 4px 0;
  color: var(--muted);
  line-height: 1.5;
}

.stats-record-tree {
  display: grid;
  gap: 12px;
}

.tree-group {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  overflow: hidden;
}

.tree-group > summary {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  min-height: 46px;
  padding: 11px 13px;
  cursor: pointer;
  list-style: none;
}

.tree-group > summary::-webkit-details-marker {
  display: none;
}

.tree-group > summary::before {
  content: "▶";
  flex: 0 0 auto;
  color: #2563eb;
  font-size: 12px;
  font-weight: 950;
  transform: rotate(0deg);
  transition: transform 0.15s ease;
}

.tree-group[open] > summary::before {
  transform: rotate(90deg);
}

.tree-group > summary span {
  flex: 1 1 auto;
  min-width: 0;
  color: #12395a;
  font-weight: 950;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tree-group > summary small {
  flex: 0 1 auto;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-align: right;
}

.course-group > summary {
  background: linear-gradient(90deg, #e0f7ff, #ffffff);
}

.lesson-group {
  border-color: #dbeafe;
}

.lesson-group > summary {
  background: #f8fbff;
}

.sentence-group {
  border-color: #d7ebfb;
  background: #fbfdff;
}

.sentence-group > summary {
  background: #ffffff;
}

.tree-children {
  display: grid;
  gap: 10px;
  padding: 0 11px 11px;
}

.sentence-body {
  display: grid;
  gap: 10px;
  padding: 0 11px 11px;
}

.sentence-zh {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

.compact-record-list .record-card {
  box-shadow: none;
  background: #ffffff;
}

.compact-record-list .feedback-panel {
  margin-top: 8px;
}

.wrongbook-list {
  display: grid;
  gap: 12px;
}

.wrong-word-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  overflow: hidden;
}

.wrong-word-card > summary {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  min-height: 56px;
  padding: 12px 14px;
  cursor: pointer;
  list-style: none;
  background: linear-gradient(90deg, #fff7ed, #ffffff);
}

.wrong-word-card > summary::-webkit-details-marker {
  display: none;
}

.wrong-word-card > summary::before {
  content: "▶";
  color: #f97316;
  font-size: 12px;
  font-weight: 950;
  transition: transform 0.15s ease;
}

.wrong-word-card[open] > summary::before {
  transform: rotate(90deg);
}

.wrong-word-title {
  flex: 1 1 auto;
  color: #9a3412;
  font-size: 22px;
  font-weight: 950;
}

.wrong-word-meta,
.wrong-word-source {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.wrong-word-body {
  display: grid;
  gap: 10px;
  padding: 0 14px 14px;
}

.wrong-word-source {
  margin: 0;
}

.wrong-example-list {
  display: grid;
  gap: 10px;
}

.wrong-example {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  padding: 12px;
  border: 1px solid #fed7aa;
  border-radius: 8px;
  background: #fffaf5;
}

.wrong-example.lookup-example {
  border-color: #bfdbfe;
  background: #eff6ff;
}

.wrong-example.lookup-example h3 {
  color: #1d4ed8;
}

.wrong-example h3,
.wrong-example p {
  margin: 0 0 7px;
}

.wrong-example h3 {
  color: #7c2d12;
  font-size: 15px;
}

.wrong-example p {
  color: #475569;
  line-height: 1.5;
}

.wrong-example em {
  display: block;
  color: #0f766e;
  font-size: 13px;
  font-style: normal;
  font-weight: 800;
  line-height: 1.5;
}

.record-card audio {
  width: 240px;
}

.date-input {
  min-height: 38px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  margin: 16px 0;
}

.stats-grid .metric-tile {
  min-height: 104px;
}

.verdict {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  font-weight: 900;
}

.verdict.great {
  border-color: #34d399;
  background: #ecfdf5;
}

.verdict.good {
  border-color: #93c5fd;
  background: #eff6ff;
}

.verdict.fair {
  border-color: #fde047;
  background: #fffbeb;
}

.verdict.low {
  border-color: #fda4af;
  background: #fff1f2;
}

.chart-grid {
  display: grid;
  grid-template-columns: minmax(0, 0.8fr) minmax(0, 1.2fr);
  gap: 16px;
  margin: 16px 0;
}

.chart-panel {
  padding: 14px;
}

.wide-chart {
  grid-column: 1 / -1;
}

.chart-panel h3 {
  margin: 0 0 10px;
}

.chart-note {
  display: block;
  min-height: 18px;
  margin: -4px 0 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  line-height: 1.45;
}

canvas {
  display: block;
  width: 100%;
  height: 260px;
}

.phonetic-hero,
.phonetic-group,
.phonetic-source {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: var(--shadow);
}

.phonetic-hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 180px;
  gap: 18px;
  align-items: center;
  padding: clamp(20px, 4vw, 32px);
}

.phonetic-hero h1 {
  margin: 0;
  font-size: clamp(34px, 7vw, 68px);
  line-height: 1;
}

.phonetic-hero p {
  max-width: 760px;
  color: var(--muted);
  line-height: 1.7;
}

.phonetic-meter {
  display: grid;
  min-height: 170px;
  place-items: center;
  padding: 18px;
  border: 1px solid #bfdbfe;
  border-radius: 8px;
  background: linear-gradient(160deg, #eff6ff, #ecfeff);
  text-align: center;
}

.phonetic-meter strong {
  color: var(--blue);
  font-size: 58px;
  line-height: 1;
}

.phonetic-meter span,
.phonetic-meter small {
  color: var(--muted);
  font-weight: 800;
}

#phoneticAudioPlayer {
  display: none;
}

.phonetic-sections {
  display: grid;
  gap: 16px;
}

.phonetic-group {
  overflow: hidden;
}

.phonetic-group-head {
  display: flex;
  gap: 12px;
  align-items: flex-end;
  justify-content: space-between;
  padding: 16px;
  border-bottom: 1px solid var(--line);
}

.phonetic-group-head h2,
.phonetic-group-head p {
  margin: 0;
}

.phonetic-group-head h2 {
  font-size: 22px;
}

.phonetic-group-head p {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.phonetic-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 12px;
  padding: 14px;
}

.phonetic-card {
  display: grid;
  gap: 10px;
  min-height: 198px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 0 10px 22px rgba(21, 32, 51, 0.07);
}

.phonetic-card.is-playing {
  border-color: var(--blue);
  box-shadow: 0 16px 34px rgba(37, 99, 235, 0.18);
}

.phonetic-symbol-button {
  display: grid;
  gap: 4px;
  width: 100%;
  min-height: 74px;
  place-items: center;
  color: #0f172a;
  border: 1px solid #dbeafe;
  border-radius: 8px;
  background: linear-gradient(180deg, #ffffff, #eff6ff);
  cursor: pointer;
}

.phonetic-symbol-button span {
  font-family: "Charis SIL", "Noto Sans", "Segoe UI Symbol", system-ui, sans-serif;
  font-size: 34px;
  font-weight: 950;
}

.phonetic-symbol-button small {
  color: var(--muted);
  font-weight: 900;
}

.phonetic-symbol-button:hover {
  transform: translateY(-1px);
}

.phonetic-card p {
  min-height: 42px;
  margin: 0;
  color: #475569;
  font-size: 13px;
  font-weight: 750;
  line-height: 1.55;
}

.phonetic-word-row {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  align-items: center;
}

.phonetic-word-row span {
  min-height: 32px;
  padding: 0 10px;
  color: #164e63;
  border: 1px solid #bae6fd;
  border-radius: 8px;
  background: #ecfeff;
  font-size: 13px;
  font-weight: 900;
  line-height: 30px;
}

.tone-cyan .phonetic-group-head {
  background: linear-gradient(90deg, #ecfeff, #ffffff);
}

.tone-lime .phonetic-group-head {
  background: linear-gradient(90deg, #f0fdf4, #ffffff);
}

.tone-yellow .phonetic-group-head {
  background: linear-gradient(90deg, #fffbeb, #ffffff);
}

.tone-blue .phonetic-group-head {
  background: linear-gradient(90deg, #eff6ff, #ffffff);
}

.tone-violet .phonetic-group-head {
  background: linear-gradient(90deg, #f5f3ff, #ffffff);
}

.phonetic-source {
  margin-top: 16px;
  padding: 14px;
  color: #475569;
  line-height: 1.6;
}

.phonetic-source p {
  margin: 6px 0 0;
}

.phonetic-source code {
  color: #1d4ed8;
  font-weight: 900;
}

@media (max-width: 860px) {
  .app-header {
    grid-template-columns: 1fr;
  }

  .service-status {
    justify-self: start;
  }

  .header-actions {
    justify-self: start;
    width: 100%;
    justify-content: space-between;
  }

  .top-nav {
    overflow-x: auto;
    width: 100%;
  }

  .hero-band,
  .phonetic-hero,
  .chart-grid,
  .stats-grid {
    grid-template-columns: 1fr;
  }

  .phonetic-group-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .phonetic-grid {
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  }

  .reading-paper {
    padding: 18px 12px;
    border-radius: 18px;
    box-shadow: 5px 5px 0 rgba(37, 99, 235, 0.12);
  }

  .line-read-target {
    grid-template-columns: 34px minmax(0, 1fr);
    gap: 8px;
    padding: 8px 6px;
  }

  .line-side {
    grid-column: 2;
    justify-items: start;
    grid-template-columns: auto auto;
    align-items: center;
  }

  .line-bubble {
    max-width: 100%;
    text-align: left;
  }

  .locked-hint {
    margin-left: 48px;
  }

  .expanded-actions {
    width: calc(100% - 8px);
    margin: 4px 4px 12px;
  }

  .recording-playback,
  .action-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .article-challenge-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .line-row {
    grid-template-columns: 58px minmax(0, 1fr);
  }

  .line-actions {
    grid-column: 1 / -1;
    justify-items: stretch;
    min-width: 0;
  }

  .button-row {
    justify-content: flex-start;
  }

  .mini-audio,
  .record-card audio {
    width: 100%;
  }

  .record-card {
    grid-template-columns: 1fr;
  }

  .wrong-word-card > summary,
  .tree-group > summary,
  .wrong-example {
    grid-template-columns: 1fr;
  }

  .wrong-word-card > summary,
  .tree-group > summary {
    align-items: flex-start;
    flex-wrap: wrap;
  }

  .wrong-word-meta,
  .tree-group > summary small {
    width: 100%;
    text-align: left;
  }

  .wrong-example {
    grid-template-columns: 1fr;
  }
}
