:root {
  --blue: #315efb;
  --blue-dark: #2449c7;
  --blue-soft: #eef3ff;
  --green: #14805e;
  --green-soft: #e9f8f1;
  --amber: #9a6500;
  --amber-soft: #fff6dc;
  --red: #cf3f52;
  --red-soft: #fff0f2;
  --ink: #17213a;
  --muted: #66758d;
  --muted-2: #8b98aa;
  --line: #dfe6f1;
  --line-strong: #cbd6e7;
  --card: #ffffff;
  --bg: #f3f6fb;
  --shadow: 0 14px 38px rgba(39, 65, 113, 0.08);
  --shadow-soft: 0 7px 20px rgba(39, 65, 113, 0.06);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background:
    radial-gradient(circle at 96% 2%, rgba(49, 94, 251, 0.1), transparent 22rem),
    linear-gradient(180deg, #f8faff 0, var(--bg) 24rem);
  color: var(--ink);
  font: 15px/1.65 -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

button:focus-visible,
input:focus-visible {
  outline: 3px solid rgba(49, 94, 251, 0.22);
  outline-offset: 2px;
}

[hidden] {
  display: none !important;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  min-height: 64px;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 22px;
  border-bottom: 1px solid rgba(214, 224, 238, 0.9);
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(18px);
}

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

.brand-mark {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  color: #fff;
  font-size: 13px;
  font-weight: 900;
  letter-spacing: -0.03em;
  background: linear-gradient(145deg, #4977ff, #234bd2);
  box-shadow: 0 8px 18px rgba(49, 94, 251, 0.25);
}

.brand-copy {
  display: flex;
  flex-direction: column;
  line-height: 1.25;
}

.brand-copy strong {
  font-size: 16px;
  letter-spacing: -0.02em;
}

.brand-copy small {
  color: var(--muted);
  font-size: 11px;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-left: auto;
}

.save-state {
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.save-state.saved {
  color: var(--green);
}

.page {
  width: min(1440px, 100%);
  margin: 0 auto;
  padding: 28px 22px 42px;
}

.hero {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 28px;
  margin-bottom: 18px;
}

.hero-copy {
  max-width: 760px;
}

.eyebrow {
  margin: 0 0 4px;
  color: #5572a7;
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

.hero h1,
.card h2 {
  margin: 0;
  letter-spacing: -0.03em;
}

.hero h1 {
  font-size: clamp(28px, 4vw, 44px);
  line-height: 1.13;
}

.hero-subtitle {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 15px;
}

.lesson-picker {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 13px;
  padding: 6px 8px 6px 11px;
  border: 1px solid #d4dfef;
  border-radius: 11px;
  color: #536783;
  background: rgba(255, 255, 255, 0.78);
  font-size: 11px;
  font-weight: 800;
}

.lesson-picker select {
  max-width: 320px;
  height: 31px;
  padding: 3px 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: #315b9c;
  background: #fff;
  font-size: 11px;
  font-weight: 800;
}

.hero-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(78px, 1fr));
  gap: 9px;
  flex: 0 0 auto;
}

.stat {
  min-width: 82px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: rgba(255, 255, 255, 0.82);
  box-shadow: var(--shadow-soft);
  text-align: center;
}

.stat strong {
  display: block;
  color: #28477c;
  font-size: 21px;
  line-height: 1.15;
}

.stat span {
  color: var(--muted);
  font-size: 11px;
}

.stat.accent strong {
  color: var(--amber);
}

.stat.due strong {
  color: var(--green);
}

.workspace {
  display: grid;
  grid-template-columns: minmax(310px, 0.82fr) minmax(0, 1.6fr);
  align-items: start;
  gap: 17px;
}

.card {
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--card);
  box-shadow: var(--shadow);
}

.sentence-panel {
  position: sticky;
  top: 80px;
  overflow: hidden;
}

.panel-head,
.card-heading,
.practice-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}

.panel-head {
  padding: 17px 18px 13px;
  border-bottom: 1px solid var(--line);
}

.card-heading,
.practice-head {
  padding: 18px 20px 0;
}

.card h2 {
  font-size: 19px;
  line-height: 1.25;
}

.panel-note {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 11px;
}

.filter-row {
  display: flex;
  gap: 7px;
  padding: 11px 13px;
  border-bottom: 1px solid var(--line);
  overflow-x: auto;
  scrollbar-width: none;
}

.filter-row::-webkit-scrollbar {
  display: none;
}

.filter-btn,
.speed-btn {
  border: 1px solid transparent;
  border-radius: 9px;
  background: #f3f6fb;
  color: #5b6a81;
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.filter-btn:hover,
.speed-btn:hover {
  border-color: #bacbea;
  background: #edf3ff;
}

.filter-btn.active,
.speed-btn.active {
  border-color: var(--blue);
  color: #fff;
  background: var(--blue);
  box-shadow: 0 4px 12px rgba(49, 94, 251, 0.2);
}

.sentence-list {
  max-height: calc(100vh - 245px);
  min-height: 280px;
  overflow-y: auto;
  padding: 8px;
  overscroll-behavior: contain;
}

.sentence-group + .sentence-group {
  margin-top: 7px;
  padding-top: 8px;
  border-top: 1px dashed var(--line);
}

.sentence-group-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 6px 9px 5px;
  color: #3e5c91;
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.04em;
}

.sentence-group-title span:last-child {
  color: var(--muted-2);
  font-weight: 700;
  letter-spacing: 0;
}

.sentence-item {
  width: 100%;
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr) auto;
  align-items: start;
  gap: 9px;
  padding: 10px 9px;
  border: 1px solid transparent;
  border-radius: 12px;
  background: transparent;
  color: inherit;
  text-align: left;
  transition: background 0.16s ease, border-color 0.16s ease, transform 0.16s ease;
}

.sentence-item:hover {
  border-color: #d4e0f1;
  background: #f8faff;
}

.sentence-item.active {
  border-color: #a9bfee;
  background: linear-gradient(135deg, #f2f6ff, #edf3ff);
  box-shadow: 0 5px 16px rgba(49, 94, 251, 0.1);
}

.sentence-number {
  width: 27px;
  height: 27px;
  display: grid;
  place-items: center;
  border-radius: 9px;
  background: #eef2f8;
  color: #63728a;
  font-size: 10px;
  font-weight: 900;
}

.sentence-item.active .sentence-number {
  color: #fff;
  background: var(--blue);
}

.sentence-body {
  min-width: 0;
}

.sentence-preview {
  display: -webkit-box;
  margin: 0;
  overflow: hidden;
  color: #263650;
  font-size: 13px;
  font-weight: 700;
  line-height: 1.45;
  text-indent: 2em;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.sentence-meta {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-top: 5px;
  color: var(--muted-2);
  font-size: 10px;
}

.score-chip {
  color: #49668f;
  font-weight: 800;
}

.score-chip.done {
  color: var(--green);
}

.favorite-mark {
  align-self: center;
  color: #b3bdca;
  font-size: 17px;
  line-height: 1;
}

.favorite-mark.on {
  color: #e3a80d;
}

.study-column {
  min-width: 0;
}

.practice-card,
.recording-card,
.review-card {
  margin-bottom: 15px;
}

.section-label {
  color: #2a4a7f;
}

.favorite-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 38px;
  padding: 7px 12px;
  border: 1px solid #dfd5aa;
  border-radius: 11px;
  color: #7f6411;
  background: #fffdf4;
  font-size: 12px;
  font-weight: 900;
}

.favorite-btn:hover {
  border-color: #e4c45d;
  background: #fff9dc;
}

.favorite-btn.active {
  border-color: #edc64b;
  color: #755500;
  background: #fff4bf;
  box-shadow: 0 5px 14px rgba(214, 162, 13, 0.13);
}

.favorite-icon {
  font-size: 19px;
  line-height: 1;
}

.speaker-line {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 17px 20px 0;
}

.speaker-pill {
  min-width: 29px;
  height: 29px;
  display: grid;
  place-items: center;
  padding: 0 7px;
  border-radius: 9px;
  color: #fff;
  background: #526f9f;
  font-size: 11px;
  font-weight: 900;
}

.sentence-time {
  color: var(--muted);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 8px;
  border-radius: 999px;
  color: #48648c;
  background: var(--blue-soft);
  font-size: 10px;
  font-weight: 800;
  white-space: nowrap;
}

.badge.subtle {
  color: #7a6016;
  background: var(--amber-soft);
}

.current-sentence {
  margin: 13px 20px 20px;
  color: #111d33;
  font-size: clamp(25px, 3.2vw, 39px);
  font-weight: 750;
  line-height: 1.33;
  letter-spacing: -0.025em;
  text-indent: 2em;
}

.current-translation {
  margin: -9px 20px 18px;
  padding-left: 2em;
  color: var(--muted);
  font-size: 13px;
}

.word-context-bar {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  margin: -5px 20px 16px;
  padding: 9px 10px;
  border: 1px solid #dbe4f2;
  border-radius: 12px;
  background: #f8faff;
}

.word-context-label {
  flex: 0 0 auto;
  padding-top: 6px;
  color: #5b6d88;
  font-size: 10px;
  font-weight: 900;
}

.word-context-list {
  min-width: 0;
  display: flex;
  gap: 7px;
  flex-wrap: wrap;
}

.word-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 8px;
  border: 1px solid #d5e0f1;
  border-radius: 9px;
  color: #334c73;
  background: #fff;
  font-size: 10px;
}

.word-chip strong {
  color: #315b9c;
  font-size: 11px;
}

.word-chip span {
  color: var(--muted);
}

.word-chip em {
  color: #b18408;
  font-style: normal;
  font-weight: 900;
}

.word-chip.in-wordbook {
  border-color: #e6cc78;
  background: #fffaf0;
}

.audio-shell {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  margin: 0 20px;
  padding: 13px;
  border: 1px solid #d7e1f2;
  border-radius: 15px;
  background: linear-gradient(135deg, #f9fbff, #f0f5ff);
}

.play-main {
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: #fff;
  background: var(--blue);
  font-size: 17px;
  box-shadow: 0 8px 18px rgba(49, 94, 251, 0.26);
}

.play-main:hover {
  background: var(--blue-dark);
}

.play-main.playing {
  background: #284fc9;
}

.audio-main {
  min-width: 0;
}

.range {
  --pct: 0%;
  width: 100%;
  height: 7px;
  margin: 0;
  border-radius: 999px;
  appearance: none;
  -webkit-appearance: none;
  background: linear-gradient(90deg, var(--blue) 0 var(--pct), #dce4f1 var(--pct) 100%);
}

.range::-webkit-slider-thumb {
  width: 17px;
  height: 17px;
  appearance: none;
  -webkit-appearance: none;
  border: 3px solid #fff;
  border-radius: 50%;
  background: var(--blue);
  box-shadow: 0 1px 6px rgba(34, 66, 140, 0.35);
}

.range::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border: 3px solid #fff;
  border-radius: 50%;
  background: var(--blue);
  box-shadow: 0 1px 6px rgba(34, 66, 140, 0.35);
}

.time-row {
  display: flex;
  justify-content: space-between;
  margin-top: 3px;
  color: var(--muted);
  font-size: 10px;
  font-variant-numeric: tabular-nums;
}

.loop-btn {
  min-width: 66px;
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 7px 9px;
  border: 1px solid var(--line-strong);
  border-radius: 11px;
  color: #61708a;
  background: #fff;
  font-size: 11px;
  font-weight: 900;
}

.loop-btn.active {
  border-color: #a9bfee;
  color: #244fc8;
  background: #edf3ff;
}

.audio-tools {
  display: flex;
  align-items: center;
  gap: 11px;
  flex-wrap: wrap;
  padding: 12px 20px 19px;
}

.nudge-group,
.speed-group {
  display: flex;
  align-items: center;
  gap: 6px;
}

.speed-group > span {
  color: var(--muted);
  font-size: 11px;
}

.loop-hint {
  margin-left: auto;
  color: var(--muted-2);
  font-size: 10px;
}

.review-mode-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 0 20px 12px;
  padding: 10px 12px;
  border: 1px solid #e5cf87;
  border-radius: 12px;
  background: linear-gradient(135deg, #fffdf4, #fff7dc);
}

.review-mode-banner strong,
.review-mode-banner span {
  display: block;
}

.review-mode-banner strong {
  color: #795c09;
  font-size: 12px;
}

.review-mode-banner span {
  margin-top: 2px;
  color: #8a743b;
  font-size: 10px;
}

.sentence-nav-row {
  display: grid;
  grid-template-columns: minmax(100px, 0.5fr) auto minmax(100px, 0.5fr);
  align-items: center;
  gap: 10px;
  margin: 0 20px 19px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.sentence-nav-row .btn {
  min-height: 38px;
}

.sentence-nav-row #nextSentence {
  justify-self: end;
}

.practice-position {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  white-space: nowrap;
}

.btn {
  display: inline-flex;
  text-decoration: none;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 34px;
  padding: 6px 11px;
  border: 1px solid var(--line-strong);
  border-radius: 9px;
  color: #42536d;
  background: #fff;
  font-size: 12px;
  font-weight: 800;
  transition: border-color 0.15s ease, background 0.15s ease, transform 0.15s ease;
}

.btn:hover:not(:disabled) {
  border-color: #9fb8e4;
  background: #f7faff;
}

.btn:active:not(:disabled) {
  transform: translateY(1px);
}

.btn:disabled {
  cursor: not-allowed;
  opacity: 0.42;
}

.btn-primary {
  border-color: var(--blue);
  color: #fff;
  background: var(--blue);
  box-shadow: 0 7px 17px rgba(49, 94, 251, 0.19);
}

.btn-primary:hover:not(:disabled) {
  border-color: var(--blue-dark);
  background: var(--blue-dark);
}

.btn-soft {
  border-color: #cddaf1;
  color: #315b9c;
  background: #f3f7ff;
}

.btn-ghost {
  border-color: transparent;
  background: #f4f6fa;
}

.btn-compact {
  min-height: 29px;
  padding: 3px 8px;
  font-size: 11px;
}

.record-stage {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 15px;
  margin: 17px 20px 0;
  padding: 15px;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: #fbfcff;
}

.record-main {
  min-width: 128px;
  min-height: 68px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  padding: 12px 17px;
  border: 0;
  border-radius: 16px;
  color: #fff;
  background: linear-gradient(145deg, #ef5368, #ce344c);
  font-size: 13px;
  font-weight: 900;
  box-shadow: 0 10px 22px rgba(207, 63, 82, 0.22);
}

.record-main:hover:not(:disabled) {
  filter: brightness(1.04);
}

.record-main:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.record-main.recording {
  background: linear-gradient(145deg, #343d54, #1f2637);
  box-shadow: 0 10px 22px rgba(27, 34, 49, 0.2);
}

.record-dot {
  width: 12px;
  height: 12px;
  border: 3px solid currentColor;
  border-radius: 50%;
  background: currentColor;
}

.record-main.recording .record-dot {
  border-radius: 3px;
  animation: recordPulse 1.1s ease-in-out infinite;
}

@keyframes recordPulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.45; transform: scale(0.82); }
}

.record-copy {
  min-width: 0;
}

.record-copy strong {
  display: block;
  color: #273850;
  font-size: 14px;
}

.record-copy p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 11px;
}

.record-timer {
  color: #5c6c84;
  font-size: 20px;
  font-weight: 850;
  font-variant-numeric: tabular-nums;
}

.recording-panel {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 10px;
  margin: 11px 20px 0;
  padding: 11px 12px;
  border: 1px solid #cddcf0;
  border-radius: 13px;
  background: #f4f8ff;
}

.round-btn {
  width: 33px;
  height: 33px;
  border: 0;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: #fff;
  background: #3d6ddb;
  font-size: 12px;
}

.recording-time {
  min-width: 42px;
  color: #52627a;
  font-size: 11px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.evaluation-bar {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 14px 20px 18px;
  flex-wrap: wrap;
}

.evaluation-bar > span {
  color: var(--muted-2);
  font-size: 10px;
}

.evaluation-result {
  margin: 0 20px 20px;
  padding: 14px;
  border: 1px solid #cfe6da;
  border-radius: 15px;
  background: linear-gradient(135deg, #f5fcf8, #edf8f3);
}

.evaluation-head {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 12px;
}

.score-ring {
  --score: 0%;
  width: 72px;
  height: 72px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border-radius: 50%;
  background: conic-gradient(var(--green) 0 var(--score), #dcebe5 var(--score) 100%);
}

.score-ring::before {
  content: "";
  width: 56px;
  height: 56px;
  grid-area: 1 / 1;
  border-radius: 50%;
  background: #fff;
}

.score-ring strong {
  z-index: 1;
  grid-area: 1 / 1;
  color: #17694f;
  font-size: 20px;
  line-height: 1;
}

.score-copy strong {
  display: block;
  color: #205d49;
  font-size: 14px;
}

.score-copy p {
  margin: 3px 0 0;
  color: #527468;
  font-size: 11px;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.metric {
  padding: 9px 10px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.74);
}

.metric-head {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  color: #46665b;
  font-size: 10px;
}

.metric-head strong {
  color: #1d6f53;
}

.metric-bar {
  height: 5px;
  margin-top: 6px;
  overflow: hidden;
  border-radius: 999px;
  background: #dcebe5;
}

.metric-bar span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--green);
}

.evaluation-disclaimer {
  margin: 10px 0 0;
  color: #6b857b;
  font-size: 10px;
}

.evaluation-loading {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #42665a;
  font-size: 12px;
}

.spinner {
  width: 19px;
  height: 19px;
  border: 3px solid #cfe6da;
  border-top-color: var(--green);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.review-summary {
  padding: 14px 20px 19px;
}

.review-empty {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 15px;
  border: 1px dashed var(--line-strong);
  border-radius: 13px;
  color: var(--muted);
  background: #fbfcff;
  font-size: 12px;
}

.review-empty strong {
  color: #41536d;
}

.review-start-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
  padding: 9px 10px;
  border-radius: 11px;
  color: #53647d;
  background: #f3f6fb;
  font-size: 10px;
}

.review-list {
  min-width: 0;
  display: grid;
  gap: 8px;
}

.review-item {
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fbfcff;
}

.review-item > div {
  min-width: 0;
}

.review-item.is-due {
  border-color: #e3cc82;
  background: #fffcf0;
}

.review-item.is-current {
  border-color: #8faeea;
  background: #f3f7ff;
  box-shadow: 0 0 0 2px rgba(49, 94, 251, 0.07);
}

.review-text {
  min-width: 0;
  margin: 0;
  overflow: hidden;
  color: #2c3c54;
  font-size: 12px;
  font-weight: 750;
  text-indent: 2em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.review-meta {
  display: flex;
  align-items: center;
  gap: 7px;
  flex-wrap: wrap;
  margin-top: 4px;
  color: var(--muted);
  font-size: 10px;
}

.review-action {
  min-width: 76px;
}

.privacy-note {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  margin-top: 17px;
  padding: 12px 14px;
  border: 1px solid #d9e2ef;
  border-radius: 13px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.72);
  font-size: 11px;
}

.privacy-note strong {
  color: #47607f;
  white-space: nowrap;
}

.empty-state {
  padding: 55px 18px;
  color: var(--muted);
  text-align: center;
  font-size: 12px;
}

.empty-state strong {
  display: block;
  margin-bottom: 5px;
  color: #3c506d;
  font-size: 14px;
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 100;
  max-width: min(390px, calc(100vw - 40px));
  padding: 10px 14px;
  border-radius: 11px;
  color: #fff;
  background: #1c2940;
  box-shadow: 0 12px 28px rgba(18, 29, 49, 0.28);
  font-size: 12px;
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px);
  transition: opacity 0.18s ease, transform 0.18s ease;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.mode-tabs {
  display: inline-flex;
  gap: 7px;
  margin-bottom: 14px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.84);
  box-shadow: var(--shadow-soft);
}

.mode-tab {
  border: 0;
  border-radius: 9px;
  padding: 7px 13px;
  color: #596b84;
  background: transparent;
  font-size: 12px;
  font-weight: 900;
}

.mode-tab.active {
  color: #fff;
  background: var(--blue);
  box-shadow: 0 5px 13px rgba(49, 94, 251, 0.2);
}

.explanation-layout {
  display: grid;
  grid-template-columns: minmax(240px, 0.7fr) minmax(0, 1.6fr);
  align-items: start;
  gap: 17px;
}

.explanation-section-panel {
  position: sticky;
  top: 80px;
  overflow: hidden;
}

.explanation-section-list {
  display: grid;
  gap: 7px;
  max-height: calc(100vh - 235px);
  overflow-y: auto;
  padding: 10px;
}

.explanation-section-button {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 11px;
  padding: 10px 11px;
  color: #405573;
  background: #fbfcff;
  text-align: left;
}

.explanation-section-button strong,
.explanation-section-button span {
  display: block;
}

.explanation-section-button strong {
  font-size: 12px;
}

.explanation-section-button span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 10px;
}

.explanation-section-button.active {
  border-color: #9eb9ee;
  background: #f1f6ff;
  box-shadow: 0 5px 14px rgba(49, 94, 251, 0.08);
}

.explanation-player-card,
.explanation-question-card {
  margin-bottom: 13px;
}

.explanation-audio-shell {
  margin-top: 16px;
  margin-bottom: 18px;
}

.explanation-question-card {
  padding: 16px;
}

.explanation-question-head {
  display: flex;
  align-items: center;
  gap: 9px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

.explanation-question-head strong {
  color: #315488;
  font-size: 16px;
}

.explanation-question-head span {
  color: var(--muted);
  font-size: 10px;
}

.explanation-prompt {
  margin: 0 0 13px;
  color: #1f2d42;
  font-size: 17px;
  font-weight: 750;
  line-height: 1.55;
}

.explanation-choices {
  display: grid;
  gap: 8px;
}

.explanation-choice {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fbfdff;
}

.explanation-choice.selected {
  border-color: #81a5eb;
  background: #f1f6ff;
}

.explanation-choice.correct {
  border-color: #8ed2b6;
  background: var(--green-soft);
}

.explanation-choice .choice-letter {
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border-radius: 50%;
  color: #45617f;
  background: #edf3fb;
  font-size: 10px;
  font-weight: 900;
}

.explanation-choice.correct .choice-letter {
  color: var(--green);
  background: #cceee0;
}

.explanation-transcript-panel,
.explanation-expression-panel {
  padding: 15px 16px;
}

.explanation-transcript-list {
  display: grid;
  gap: 7px;
}

.explanation-transcript-row {
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr) auto;
  align-items: start;
  gap: 9px;
  padding: 8px 9px;
  border-radius: 10px;
  cursor: pointer;
}

.explanation-transcript-row:hover {
  background: #f5f8fe;
}

.explanation-transcript-row.active {
  background: #eef4ff;
}

.explanation-transcript-row .speaker {
  color: #526f9f;
  font-size: 11px;
  font-weight: 900;
}

.explanation-transcript-row p {
  margin: 0;
  color: #273850;
  font-size: 12px;
  line-height: 1.55;
  text-indent: 2em;
}

.explanation-transcript-time {
  color: var(--muted);
  font-size: 10px;
  font-variant-numeric: tabular-nums;
}

.explanation-expression-list {
  display: grid;
  gap: 7px;
}

.explanation-expression-row {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 8px 9px;
  border-radius: 9px;
  background: #f8faff;
}

.explanation-expression-row strong {
  color: #704f00;
  font-size: 12px;
}

.explanation-expression-row span {
  color: #6f6040;
  font-size: 11px;
}

@media (max-width: 1050px) {
  .hero {
    align-items: flex-start;
  }

  .hero-stats {
    grid-template-columns: repeat(2, minmax(82px, 1fr));
  }

  .workspace,
  .explanation-layout {
    grid-template-columns: 1fr;
  }

  .explanation-section-panel {
    position: static;
  }

  .explanation-section-list {
    max-height: 320px;
  }

  .sentence-panel {
    position: static;
  }

  .sentence-list {
    max-height: 390px;
  }
}

@media (max-width: 720px) {
  .topbar {
    padding: 9px 12px;
  }

  .brand-copy small,
  .save-state {
    display: none;
  }

  .top-actions {
    gap: 6px;
  }

  .page {
    padding: 20px 12px 32px;
  }

  .hero {
    display: block;
  }

  .lesson-picker {
    width: 100%;
  }

  .lesson-picker select {
    min-width: 0;
    flex: 1;
    max-width: none;
  }

  .hero-stats {
    margin-top: 16px;
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .stat {
    min-width: 0;
    padding: 9px 5px;
  }

  .stat strong {
    font-size: 18px;
  }

  .card-heading,
  .practice-head {
    padding-left: 15px;
    padding-right: 15px;
  }

  .mode-tabs {
    width: 100%;
  }

  .mode-tab {
    flex: 1 1 0;
  }

  .explanation-audio-shell {
    grid-template-columns: auto minmax(0, 1fr);
    margin-right: 15px;
    margin-left: 15px;
  }

  .explanation-audio-shell .speed-group {
    grid-column: 1 / -1;
    justify-content: center;
  }

  .speaker-line,
  .audio-tools {
    padding-left: 15px;
    padding-right: 15px;
  }

  .current-sentence {
    margin-right: 15px;
    margin-left: 15px;
    font-size: 25px;
  }

  .current-translation {
    margin-right: 15px;
    margin-left: 15px;
  }

  .word-context-bar {
    margin-right: 15px;
    margin-left: 15px;
  }

  .audio-shell {
    grid-template-columns: auto minmax(0, 1fr);
    margin: 0 15px;
  }

  .loop-btn {
    grid-column: 1 / -1;
    width: 100%;
  }

  .loop-hint {
    width: 100%;
    margin-left: 0;
  }

  .record-stage {
    grid-template-columns: 1fr auto;
    margin-right: 15px;
    margin-left: 15px;
  }

  .record-main {
    grid-column: 1 / -1;
    width: 100%;
  }

  .recording-panel {
    grid-template-columns: auto minmax(0, 1fr) auto;
    margin-right: 15px;
    margin-left: 15px;
  }

  .recording-panel .btn {
    grid-column: 1 / -1;
  }

  .review-mode-banner,
  .sentence-nav-row,
  .evaluation-bar,
  .evaluation-result,
  .review-summary {
    margin-right: 15px;
    margin-left: 15px;
  }

  .sentence-nav-row {
    grid-template-columns: 1fr 1fr;
  }

  .practice-position {
    grid-column: 1 / -1;
    grid-row: 1;
    justify-self: center;
  }

  .sentence-nav-row .btn {
    grid-row: 2;
    width: 100%;
  }

  .review-mode-banner {
    align-items: flex-start;
  }

  .evaluation-bar {
    padding-right: 0;
    padding-left: 0;
  }

  .metric-grid {
    grid-template-columns: 1fr;
  }

  .review-item {
    grid-template-columns: 1fr;
  }

  .review-start-bar {
    align-items: stretch;
    flex-direction: column;
  }

  .review-action {
    width: 100%;
  }
}

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

html.echo-embedded .topbar {
  display: none;
}

html.echo-embedded .page {
  width: 100%;
  max-width: none;
  padding-top: 12px;
}

html.echo-embedded .hero {
  margin-bottom: 10px;
}

html.echo-embedded .lesson-picker {
  display: none;
}

.echo-student-only a[href="teacher.html"] { display:none !important; }
.echo-student-only a[href="teacher.html"], .echo-student-only a[href="lesson-card.html"] { display:none !important; }
