﻿:root {
  --canvas: #f1eee7;
  --paper: #fffdf8;
  --paper-soft: #f8f4ec;
  --ink: #17272b;
  --ink-2: #284348;
  --muted: #758083;
  --line: #d9d6cd;
  --line-strong: #bdc1ba;
  --teal: #0d6c69;
  --teal-soft: #dcebea;
  --coral: #e56b55;
  --coral-soft: #f8e4dd;
  --mustard: #d69c39;
  --mustard-soft: #f9edc9;
  --green: #2e8161;
  --red: #bf594e;
  --shadow: 0 16px 34px rgba(24, 42, 44, 0.07);
  --display: Georgia, "Times New Roman", serif;
  --body: Candara, "Trebuchet MS", sans-serif;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: var(--body);
  background:
    radial-gradient(circle at 82% 2%, rgba(229, 107, 85, 0.13), transparent 25rem),
    radial-gradient(circle at 16% 82%, rgba(13, 108, 105, 0.08), transparent 28rem),
    var(--canvas);
}

body::before {
  position: fixed;
  inset: 0;
  pointer-events: none;
  content: "";
  opacity: 0.24;
  background-image: radial-gradient(rgba(23, 39, 43, 0.2) 0.65px, transparent 0.65px);
  background-size: 5px 5px;
  mix-blend-mode: multiply;
}

button,
select,
textarea,
input { font: inherit; }

button {
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  padding: 10px 16px;
  color: var(--ink);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.02em;
  background: rgba(255, 253, 248, 0.72);
  cursor: pointer;
  transition: transform 160ms ease, box-shadow 160ms ease, border-color 160ms ease, background 160ms ease;
}

button:hover {
  border-color: var(--teal);
  box-shadow: 0 6px 18px rgba(13, 108, 105, 0.11);
  transform: translateY(-1px);
}

button:active { transform: translateY(0); }
button:disabled { cursor: not-allowed; opacity: 0.48; transform: none; box-shadow: none; }

button.primary {
  border-color: var(--teal);
  color: #fffdf8;
  background: var(--teal);
  box-shadow: 0 7px 16px rgba(13, 108, 105, 0.2);
}

button.primary:hover { background: #0a5d5a; }
.button-link {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  padding: 10px 14px;
  color: var(--ink);
  background: var(--paper);
  font-size: 13px;
  font-weight: 700;
  text-decoration: none;
}

.jump-scroll-btn {
  position: fixed;
  right: 20px;
  top: 58%;
  z-index: 30;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 46px;
  height: 46px;
  padding: 0;
  border: 1px solid rgba(13, 108, 105, 0.46);
  color: var(--teal);
  font-size: 22px;
  line-height: 1;
  background: rgba(255, 253, 248, 0.92);
  box-shadow: 0 12px 28px rgba(24, 42, 44, 0.14);
  backdrop-filter: blur(12px);
}

.jump-scroll-btn.hidden { display: none; }

.jump-scroll-btn[data-direction="down"] {
  color: #fffdf8;
  background: var(--teal);
  box-shadow: 0 14px 30px rgba(13, 108, 105, 0.24);
}

h1, h2, h3, h4, h5, p { margin-top: 0; }
h1, h2, h3 { text-wrap: balance; }

.app {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto 1fr;
  min-height: 100vh;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 24px;
  padding: 17px 30px;
  border-bottom: 1px solid rgba(189, 193, 186, 0.76);
  background: rgba(255, 253, 248, 0.86);
  backdrop-filter: blur(18px);
}

.brand { display: flex; align-items: center; gap: 13px; }

.brand-mark {
  position: relative;
  display: grid;
  width: 46px;
  height: 46px;
  place-items: center;
  border-radius: 50%;
  color: var(--paper);
  background: var(--ink);
  font-family: var(--display);
  font-size: 22px;
}

.brand-mark::after {
  position: absolute;
  inset: 4px;
  border: 1px solid rgba(255, 253, 248, 0.42);
  border-radius: inherit;
  content: "";
}

.brand-mark i {
  position: absolute;
  right: -8px;
  bottom: -4px;
  z-index: 1;
  padding: 3px 5px;
  border-radius: 8px;
  color: var(--ink);
  background: var(--mustard);
  font-family: var(--body);
  font-size: 9px;
  font-style: normal;
  font-weight: 800;
}

.eyebrow {
  margin: 0 0 5px;
  color: var(--teal);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.19em;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-family: var(--display);
  font-size: 27px;
  font-weight: 500;
  line-height: 0.92;
}

h1 span { color: var(--coral); }
h2 { font-size: 19px; }
h3 { font-size: 15px; }

.stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(74px, 1fr));
  gap: 22px;
}

.topbar-actions { display: flex; align-items: center; gap: 18px; }

.calendar-toggle {
  display: flex;
  align-items: center;
  gap: 7px;
  border-color: var(--teal);
  color: var(--teal);
  background: var(--teal-soft);
}

.calendar-toggle[aria-expanded="true"] {
  color: #fffdf8;
  background: var(--teal);
}

.calendar-toggle-icon { font-size: 17px; line-height: 1; }

.calendar-tray {
  flex: 0 0 calc(100% + 60px);
  width: calc(100% + 60px);
  margin: 0 -30px -17px;
  padding: 20px 30px 23px;
  border-top: 1px solid var(--line);
  background: rgba(241, 238, 231, 0.94);
  animation: tray-open 220ms ease both;
}

.calendar-tray.hidden { display: none; }

.calendar-tray-inner {
  display: grid;
  max-width: 1180px;
  margin: 0 auto;
  grid-template-columns: minmax(220px, 0.75fr) minmax(520px, 1.55fr);
  gap: 34px;
  align-items: center;
}

.calendar-copy h2 {
  margin: 6px 0;
  font-family: var(--display);
  font-size: 28px;
  font-weight: 500;
}

.calendar-copy p:last-child { margin: 0; color: var(--muted); line-height: 1.55; }

.calendar-card {
  padding: 15px 17px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255, 253, 248, 0.8);
}

.calendar-card .calendar { grid-template-columns: repeat(7, minmax(33px, 1fr)); }

.calendar-history {
  display: grid;
  grid-template-columns: 1fr;
  gap: 18px;
  margin-bottom: 13px;
}

.calendar-month { padding-top: 2px; }
.calendar-month + .calendar-month { border-top: 1px solid rgba(189, 193, 186, 0.52); padding-top: 16px; }
.calendar-month-header { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.calendar-month-header h3 { margin: 0; font-family: var(--display); font-size: 18px; font-weight: 600; }
.calendar-month-header span { min-width: 34px; color: var(--teal); font-size: 11px; font-weight: 800; text-align: right; }
.calendar-month-weekdays { margin-top: 12px; }
.calendar-month-grid { margin-bottom: 0; }
.calendar-card .calendar-history { grid-template-columns: 1fr; }
.calendar-card .calendar-month-grid { grid-template-columns: repeat(7, minmax(33px, 1fr)); }

.calendar-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.calendar-footer .legend { margin-bottom: 0; }
.calendar-footer .button-row { flex-wrap: nowrap; }

.stats div { position: relative; min-width: 68px; }

.stats div + div::before {
  position: absolute;
  top: 5px;
  bottom: 3px;
  left: -11px;
  width: 1px;
  background: var(--line);
  content: "";
}

.stats span {
  display: block;
  font-family: var(--display);
  font-size: 24px;
  line-height: 1;
}

.stats small {
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

main {
  min-width: 0;
  width: min(100%, 1500px);
  margin: 0 auto;
  padding: 25px 30px 42px;
  overflow: auto;
}

.tabs { display: flex; gap: 4px; margin-bottom: 19px; }

.tab {
  border-color: transparent;
  color: var(--muted);
  background: transparent;
  box-shadow: none;
}

.tab span { margin-right: 7px; color: var(--coral); font-size: 9px; letter-spacing: 0.09em; }
.tab.active { border-color: var(--line-strong); color: var(--ink); background: rgba(255, 253, 248, 0.72); }
.tab-page { display: none; }
.tab-page.active { display: block; animation: rise 360ms ease both; }

.panel,
.hero {
  border: 1px solid rgba(189, 193, 186, 0.72);
  border-radius: 18px;
  background: rgba(255, 253, 248, 0.86);
  box-shadow: var(--shadow);
}

.panel { padding: 17px; }

.hero {
  position: relative;
  display: flex;
  min-height: 132px;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 15px;
  padding: 23px 26px;
  overflow: hidden;
}

.hero::after {
  position: absolute;
  right: -30px;
  bottom: -57px;
  width: 184px;
  height: 184px;
  border: 27px solid rgba(229, 107, 85, 0.1);
  border-radius: 50%;
  content: "";
}

.hero h2 {
  max-width: 840px;
  margin: 0 0 8px;
  font-family: var(--display);
  font-size: clamp(29px, 3vw, 42px);
  font-weight: 500;
  line-height: 1.05;
}

.source-line { position: relative; z-index: 1; margin: 9px 0 0; color: var(--muted); font-size: 13px; }
.source-line a { color: var(--teal); text-decoration-thickness: 1px; text-underline-offset: 3px; }

.section-kicker { display: flex; align-items: baseline; gap: 10px; margin-bottom: 12px; }
.section-kicker span { color: var(--coral); font-size: 10px; font-weight: 800; letter-spacing: 0.14em; text-transform: uppercase; }
.section-kicker h3 { margin: 0; font-family: var(--display); font-size: 19px; font-weight: 500; }
.section-kicker i { margin-left: auto; color: var(--muted); font-size: 12px; font-style: normal; }

.section-title { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.section-title h2, .section-title h3 { margin-bottom: 0; }

.pill {
  border-radius: 99px;
  padding: 4px 8px;
  color: var(--teal);
  background: var(--teal-soft);
  font-size: 11px;
  font-weight: 800;
}

.weekdays,
.calendar { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }

.weekdays { margin: 14px 0 7px; color: var(--muted); font-size: 9px; text-align: center; text-transform: uppercase; }
.calendar { margin-bottom: 13px; }

.day {
  display: grid;
  min-height: 31px;
  place-items: center;
  border: 1px solid transparent;
  border-radius: 50%;
  color: var(--muted);
  font-size: 12px;
}

.day.blank { background: transparent; }
.day.completed { border-color: rgba(46, 129, 97, 0.3); color: var(--green); background: rgba(46, 129, 97, 0.12); font-weight: 800; }
.day.missed { border-color: rgba(191, 89, 78, 0.28); color: var(--red); background: rgba(191, 89, 78, 0.1); font-weight: 800; }
.day.today { outline: 2px solid var(--mustard); outline-offset: 2px; color: var(--ink); font-weight: 800; }

.legend { display: flex; gap: 9px; flex-wrap: wrap; margin-bottom: 14px; color: var(--muted); font-size: 11px; }
.dot { display: inline-block; width: 8px; height: 8px; margin-right: 4px; border: 1px solid var(--line); border-radius: 50%; }
.dot.complete { background: var(--green); }
.dot.miss { background: var(--red); }
.dot.empty { background: var(--paper-soft); }

.button-row, .clip-actions, .hero-actions, .explain-actions, .question-row, .recorder {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.button-row button { flex: 1; padding-inline: 10px; }
.clip-actions { justify-content: flex-end; margin-top: 14px; }

.lesson-grid,
.practice-layout { display: grid; grid-template-columns: 1.15fr 0.85fr; gap: 15px; }
.wide { grid-column: 1 / -1; }
.hidden { display: none; }
.study-area { display: grid; grid-template-columns: 1fr; gap: 15px; }
.study-area.hidden { display: none; }

.clip-player {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 8.2;
  overflow: hidden;
  border-radius: 12px;
  background: #102326;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.1);
}

.clip-player iframe,
.clip-player video { display: block; width: 100%; height: 100%; border: 0; background: #102326; }
.clip-player .no-clip { display: grid; height: 100%; place-items: center; padding: 20px; color: #fff; text-align: center; }

.clip-player.subtitle-mask::after {
  position: absolute;
  right: 0;
  bottom: clamp(46px, 6%, 64px);
  left: 0;
  z-index: 2;
  height: clamp(52px, 11%, 92px);
  pointer-events: none;
  background: linear-gradient(180deg, rgba(14, 41, 44, 0.04), rgba(14, 41, 44, 0.88) 24%, rgba(14, 41, 44, 0.97) 100%);
  content: "";
}

@media (max-width: 700px) {
  .clip-player.subtitle-mask::after {
    bottom: clamp(34px, 10%, 46px);
    height: clamp(42px, 18%, 62px);
  }
}

.clip-player video { position: relative; z-index: 1; }
#subtitleMaskBtn[aria-pressed="true"] {
  border-color: rgba(11, 112, 109, 0.5);
  color: var(--teal);
  background: rgba(220, 236, 235, 0.88);
}


.transcript-block {
  padding: 18px 19px;
  border: 1px solid rgba(189, 193, 186, 0.68);
  border-radius: 12px;
  color: var(--ink-2);
  background: var(--paper-soft);
  font-family: var(--display);
  font-size: 18px;
  line-height: 1.76;
}

.transcript-block p { margin-bottom: 0; }
.selectable-transcript { user-select: text; }
.token { border-radius: 4px; cursor: pointer; transition: background 130ms ease; }
.token:hover { background: var(--mustard-soft); }
.selected-token { background: #f3d883; }

.selected-items { display: flex; gap: 7px; flex-wrap: wrap; margin: 12px 0; }
.chip { border-color: #b7d0ce; color: var(--teal); background: var(--teal-soft); }

.explanations { display: grid; gap: 10px; }
.explanation-warning {
  padding: 10px 13px;
  border: 1px solid #e2c779;
  border-radius: 10px;
  color: #705312;
  background: var(--mustard-soft);
  font-size: 13px;
}
.explanation-card, .dictation-card, .task {
  border: 1px solid var(--line);
  border-radius: 13px;
  padding: 15px;
  background: var(--paper-soft);
}

.explanation-card h4 { margin: 0 0 6px; font-family: var(--display); font-size: 20px; font-weight: 500; }
.explanation-card p { line-height: 1.55; }
.explanation-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.explanation-status-card {
  border-style: dashed;
  background: rgba(220, 235, 234, 0.42);
}
.explanation-error-card {
  border-color: #e4afa6;
  background: #f8e3de;
}
.explanation-error-card p {
  margin: 8px 0 0;
  color: #6f2f27;
}
.explanation-error-card .retry-explanation {
  border-color: var(--coral);
  color: #6f2f27;
  background: #fff8f6;
}
.pronunciation { display: inline-block; margin-bottom: 7px; color: var(--teal); font-size: 13px; font-weight: 700; }
.speak-selection { flex: 0 0 auto; padding: 7px 11px; font-size: 12px; }
.explanation-section { margin-top: 15px; }
.explanation-section p { margin: 6px 0 0; }
.explanation-label {
  display: block;
  color: var(--coral);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}
.meaning-section { margin-top: 7px; }
.memory-hook {
  margin-top: 15px;
  padding: 11px 13px;
  border-left: 3px solid var(--teal);
  border-radius: 0 9px 9px 0;
  background: var(--teal-soft);
}
.memory-hook span, .usage-note strong {
  color: var(--teal);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}
.memory-hook p, .usage-note p { margin: 4px 0 0; }
.collocation-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 7px;
  margin-top: 7px;
}
.collocation-grid div {
  padding: 8px 10px;
  border: 1px solid #c9d9d6;
  border-radius: 9px;
  background: rgba(220, 235, 234, 0.56);
}
.collocation-grid strong, .collocation-grid small { display: block; }
.collocation-grid small { margin-top: 3px; color: var(--muted); }
.pattern-list { margin-top: 7px; }
.pattern-list p { margin: 0 0 7px; }
.example-list { padding-left: 12px; border-left: 3px solid var(--mustard); }
.example-list p { margin-bottom: 9px; }
.usage-note {
  margin-top: 13px;
  padding: 10px 12px;
  border-radius: 9px;
  color: var(--ink-2);
  background: var(--coral-soft);
}
.usage-note strong { color: var(--coral); }
.question-row { margin-top: 9px; }
.question-row input { flex: 1; min-width: 220px; border: 1px solid var(--line); border-radius: 99px; padding: 10px 13px; background: var(--paper); }
.extra-answer { margin-top: 10px; }
.followup-answer { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line); }
.followup-answer h5 { margin: 0 0 8px; font-size: 14px; }

.next-step-row { display: flex; justify-content: flex-end; margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line); }
.muted { color: var(--muted); }

.flashcard-page { max-width: 860px; margin: 0 auto; }
.flashcard-deck { margin-top: 14px; }
.flashcard {
  display: grid;
  min-height: 300px;
  place-items: center;
  border: 1px solid rgba(11, 112, 109, 0.28);
  border-radius: 18px;
  padding: 26px;
  color: var(--ink);
  background: linear-gradient(145deg, #fffdf8, #edf6f4);
  box-shadow: 0 16px 36px rgba(16, 41, 44, 0.12);
  cursor: pointer;
}
.flashcard-face { width: 100%; text-align: center; }
.flashcard-front strong {
  display: block;
  font-family: var(--display);
  font-size: 38px;
  font-weight: 600;
  line-height: 1.08;
}
.flashcard-front span {
  display: block;
  margin-top: 14px;
  color: var(--teal);
  font-size: 18px;
  font-weight: 800;
}
.flashcard-back { text-align: left; }
.flashcard-back h4 {
  margin: 0 0 8px;
  font-family: var(--display);
  font-size: 27px;
  font-weight: 500;
}
.flashcard-back p { margin: 8px 0; line-height: 1.58; }
.flashcard-back .example-list { margin-top: 14px; }
.flashcard-empty {
  padding: 24px;
  border: 1px dashed var(--line);
  border-radius: 16px;
  color: var(--muted);
  text-align: center;
  background: var(--paper-soft);
}
.flashcard-actions {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 10px;
  margin-top: 14px;
}

.dictation-prompts { display: grid; gap: 8px; margin-bottom: 12px; }
.dictation-prompt {
  display: grid;
  grid-template-columns: 28px 1fr;
  gap: 10px;
  align-items: start;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--paper-soft);
  line-height: 1.5;
}

.dictation-prompt strong {
  display: grid;
  width: 24px;
  height: 24px;
  place-items: center;
  border-radius: 50%;
  color: var(--teal);
  background: var(--teal-soft);
  font-size: 11px;
}

select,
textarea {
  width: 100%;
  margin-bottom: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--ink);
  background: rgba(255, 253, 248, 0.86);
}

textarea:focus, input:focus { outline: 2px solid rgba(13, 108, 105, 0.3); outline-offset: 2px; }
textarea { resize: vertical; }
.feedback { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line); }
.feedback ul { padding-left: 18px; }
.corrected-version {
  margin-top: 12px;
  padding: 11px 13px;
  border-left: 3px solid var(--teal);
  border-radius: 0 9px 9px 0;
  background: var(--teal-soft);
}
.corrected-version p { margin: 6px 0 0; line-height: 1.6; }
.sentence-reviews { display: grid; gap: 12px; margin-top: 14px; }
.sentence-review {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--paper-soft);
}
.sentence-review-title { display: flex; align-items: center; gap: 8px; color: var(--teal); }
.sentence-review-title span {
  display: grid;
  width: 23px;
  height: 23px;
  place-items: center;
  border-radius: 50%;
  color: #fff;
  background: var(--teal);
  font-size: 11px;
}
.sentence-original { margin: 10px 0; font-family: var(--display); font-size: 17px; line-height: 1.5; }
.review-row { display: grid; grid-template-columns: 56px 1fr; gap: 5px; margin-top: 8px; }
.review-row b { color: var(--coral); font-size: 13px; }
.review-row ul { margin: 0; padding-left: 17px; line-height: 1.55; }
.sentence-ok { margin: 8px 0; color: var(--green); }
.sentence-corrected { margin-top: 11px; padding: 9px 11px; border-radius: 8px; background: var(--teal-soft); }
.sentence-corrected b { color: var(--teal); font-size: 12px; }
.sentence-corrected p { margin: 5px 0 0; line-height: 1.55; }
.finish-panel { display: flex; align-items: center; justify-content: space-between; gap: 22px; }
.finish-panel h2 { margin-bottom: 5px; font-family: var(--display); font-size: 24px; font-weight: 500; }
.finish-panel p:last-child { margin-bottom: 0; }
.finish-panel button { flex: 0 0 auto; }
.finish-panel.completed { border-color: rgba(46, 129, 97, 0.45); background: rgba(220, 235, 234, 0.72); }
.finish-status { margin: 8px 0 0; color: var(--teal); font-weight: 700; }

.manual-page { max-width: 1120px; }
.manual-page h2 { margin-bottom: 8px; font-family: var(--display); font-size: 31px; font-weight: 500; }
.manual-lead { max-width: 860px; margin-bottom: 18px; color: var(--muted); line-height: 1.65; }
.manual-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.manual-grid article { padding: 15px; border: 1px solid var(--line); border-radius: 13px; background: var(--paper-soft); }
.manual-grid h3 { margin-bottom: 9px; font-family: var(--display); font-size: 18px; font-weight: 500; }
.manual-grid ul, .manual-grid ol { margin: 0; padding-left: 20px; color: var(--ink-2); line-height: 1.6; }
.manual-grid li + li { margin-top: 5px; }
.manual-grid code { border-radius: 4px; padding: 1px 4px; background: #fff; font-size: 13px; }

.study-timer {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 20;
  padding: 7px 11px;
  border: 1px solid var(--line);
  border-radius: 99px;
  color: var(--teal);
  background: rgba(255, 253, 248, 0.88);
  box-shadow: var(--shadow);
  font-family: var(--display);
  font-size: 13px;
}

@keyframes rise {
  from { opacity: 0; transform: translateY(7px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes tray-open {
  from { opacity: 0; transform: translateY(-7px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (max-width: 980px) {
  .app, .lesson-grid, .practice-layout, .manual-grid { grid-template-columns: 1fr; }
  .topbar { position: static; align-items: stretch; flex-direction: column; }
  .topbar-actions { justify-content: space-between; }
  .stats { gap: 15px; grid-template-columns: repeat(4, 1fr); }
  .stats div + div::before { left: -8px; }
  .calendar-tray-inner { grid-template-columns: 1fr; gap: 12px; }
  main { padding: 20px 18px 28px; }
  .wide { grid-column: auto; }
}

@media (max-width: 620px) {
  .jump-scroll-btn {
    right: 12px;
    top: auto;
    bottom: 66px;
    width: 42px;
    height: 42px;
    font-size: 20px;
  }
  .topbar { padding: 15px 18px; }
  .topbar-actions { align-items: stretch; flex-direction: column; gap: 11px; }
  .calendar-toggle { justify-content: center; }
  .calendar-tray { flex-basis: calc(100% + 36px); width: calc(100% + 36px); margin: 0 -18px -15px; padding: 17px 18px; }
  .calendar-copy { display: none; }
  .calendar-footer { align-items: stretch; flex-direction: column; }
  .calendar-footer .button-row button { flex: 1; }
  .stats { gap: 9px; }
  .stats span { font-size: 20px; }
  .stats small { font-size: 8px; letter-spacing: 0.03em; }
  .panel { padding: 13px; }
  .hero { padding: 19px; }
  .hero h2 { font-size: 29px; }
  .section-kicker { flex-wrap: wrap; }
  .section-kicker i { width: 100%; margin-left: 0; }
  .clip-player { aspect-ratio: 16 / 9; }
  .tabs { overflow-x: auto; }
  .finish-panel { align-items: stretch; flex-direction: column; }
}

/* Visual refinement layer: keep the daily workflow quiet, warm, and focused. */
:root {
  --canvas: #ede9df;
  --paper: #fffdf8;
  --paper-soft: #f7f3ea;
  --ink: #10292c;
  --ink-2: #315055;
  --muted: #768487;
  --line: #d9d4c9;
  --line-strong: #c3c4bb;
  --teal: #0b706d;
  --teal-soft: #dceceb;
  --coral: #df735b;
  --mustard: #daa33f;
  --shadow: 0 18px 45px rgba(31, 53, 54, 0.075);
}

body {
  background:
    radial-gradient(circle at 88% 4%, rgba(223, 115, 91, 0.14), transparent 24rem),
    radial-gradient(circle at 12% 86%, rgba(11, 112, 109, 0.11), transparent 29rem),
    linear-gradient(135deg, rgba(255, 253, 248, 0.25), transparent 48%),
    var(--canvas);
}

.topbar {
  padding: 18px 36px;
  border-bottom-color: rgba(195, 196, 187, 0.68);
  box-shadow: 0 6px 25px rgba(31, 53, 54, 0.04);
}

.brand-mark {
  width: 52px;
  height: 52px;
  box-shadow: 0 8px 18px rgba(16, 41, 44, 0.16);
}

h1 { font-size: 31px; }
.topbar-actions { gap: 25px; }
.stats { gap: 28px; }
.stats div { min-width: 76px; }
.stats div + div::before { left: -14px; }
.stats span { margin-bottom: 4px; font-size: 25px; }

.calendar-toggle {
  padding: 11px 18px;
  background: rgba(220, 236, 235, 0.8);
}

main {
  width: min(100%, 1600px);
  padding: 30px 36px 54px;
}

.tabs {
  position: relative;
  gap: 7px;
  margin-bottom: 22px;
  padding-bottom: 12px;
}

.tabs::after {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  height: 1px;
  background: linear-gradient(90deg, rgba(11, 112, 109, 0.35), rgba(195, 196, 187, 0.62) 38%, transparent);
  content: "";
}

.tab {
  padding: 10px 15px;
  border-radius: 12px 12px 4px 4px;
}

.tab.active {
  border-color: rgba(11, 112, 109, 0.28);
  color: var(--teal);
  background: rgba(255, 253, 248, 0.86);
  box-shadow: 0 7px 18px rgba(31, 53, 54, 0.05);
}

.panel,
.hero {
  border-color: rgba(195, 196, 187, 0.72);
  border-radius: 21px;
  background: rgba(255, 253, 248, 0.9);
}

.panel { padding: 20px; }

.hero {
  min-height: 146px;
  margin-bottom: 18px;
  padding: 27px 30px;
  background:
    linear-gradient(102deg, rgba(255, 253, 248, 0.96), rgba(255, 253, 248, 0.77)),
    radial-gradient(circle at 83% 30%, rgba(11, 112, 109, 0.11), transparent 19rem);
}

.hero::after {
  right: -34px;
  bottom: -72px;
  width: 208px;
  height: 208px;
  border-width: 32px;
}

.section-kicker { margin-bottom: 15px; }
.section-kicker h3 { font-size: 21px; }
.clip-actions { margin-top: 17px; }

.clip-player {
  position: relative;
  border-radius: 16px;
  background:
    radial-gradient(circle at 50% 40%, rgba(35, 91, 91, 0.34), transparent 26rem),
    #0e292c;
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.11),
    0 16px 30px rgba(16, 41, 44, 0.11);
}

.clip-player:has(.no-clip) {
  min-height: clamp(300px, 42vh, 470px);
  aspect-ratio: auto;
}

.clip-player:has(.no-clip)::before,
.clip-player:has(.no-clip)::after {
  position: absolute;
  border: 1px solid rgba(255, 253, 248, 0.08);
  border-radius: 50%;
  content: "";
}

.clip-player:has(.no-clip)::before {
  width: 280px;
  height: 280px;
  transform: translate(-36%, -36%);
}

.clip-player:has(.no-clip)::after {
  right: 0;
  bottom: 0;
  width: 410px;
  height: 410px;
  transform: translate(28%, 38%);
}

.clip-player .no-clip {
  position: relative;
  z-index: 1;
  display: flex;
  width: min(92%, 520px);
  height: auto;
  min-height: 160px;
  margin: auto;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(255, 253, 248, 0.14);
  border-radius: 22px;
  color: rgba(255, 253, 248, 0.92);
  background: rgba(255, 253, 248, 0.055);
  box-shadow: 0 22px 48px rgba(0, 0, 0, 0.13);
  font-family: var(--display);
  font-size: 20px;
  letter-spacing: 0.01em;
  line-height: 1.5;
  backdrop-filter: blur(8px);
}

.clip-player .no-clip::before {
  display: grid;
  width: 52px;
  height: 52px;
  margin-bottom: 17px;
  place-items: center;
  border: 1px solid rgba(255, 253, 248, 0.27);
  border-radius: 50%;
  color: #f1c76d;
  background: rgba(255, 253, 248, 0.07);
  content: "✓";
  font-family: var(--body);
  font-size: 23px;
  font-weight: 800;
}

.clip-actions button { min-width: 112px; }
.clip-actions button.primary { min-width: 146px; }

.transcript-block,
.explanation-card,
.dictation-card,
.task,
.sentence-review {
  border-color: rgba(217, 212, 201, 0.88);
  background: rgba(247, 243, 234, 0.78);
}

textarea {
  border-radius: 14px;
  background: rgba(255, 253, 248, 0.93);
}

@media (max-width: 980px) {
  .topbar { padding-inline: 22px; }
  main { padding: 23px 22px 36px; }
}

@media (max-width: 620px) {
  .topbar { padding: 15px 18px; }
  main { padding: 19px 15px 28px; }
  .panel { padding: 14px; border-radius: 17px; }
  .hero { min-height: 128px; padding: 20px; border-radius: 17px; }
  .tabs { gap: 2px; }
  .tab { padding-inline: 11px; }
  .clip-player { border-radius: 12px; }
  .clip-player:has(.no-clip) { min-height: 260px; }
  .clip-player .no-clip { min-height: 138px; padding: 18px; font-size: 17px; }
  .clip-player .no-clip::before { width: 44px; height: 44px; margin-bottom: 13px; }
}

/* Android app shell: tuned for phone WebView, especially Huawei P30 width. */
@media (max-width: 700px) {
  html,
  body {
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
    background: #f4f1ea;
  }

  body::before { display: none; }

  button,
  .button-link {
    min-height: 44px;
    border-radius: 12px;
    padding: 11px 13px;
    letter-spacing: 0;
  }

  .app {
    display: block;
    min-height: 100vh;
    padding-bottom: calc(76px + env(safe-area-inset-bottom, 0px));
  }

  .topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
    padding: calc(10px + env(safe-area-inset-top, 0px)) 14px 12px;
    border-bottom: 1px solid rgba(195, 196, 187, 0.56);
    background: rgba(255, 253, 248, 0.96);
    box-shadow: 0 8px 22px rgba(31, 53, 54, 0.06);
    backdrop-filter: blur(14px);
  }

  .brand {
    min-width: 0;
    justify-content: space-between;
  }

  .brand-mark {
    width: 38px;
    height: 38px;
    font-size: 18px;
  }

  .brand-mark i {
    right: -6px;
    bottom: -3px;
    padding: 2px 4px;
    font-size: 8px;
  }

  .brand .eyebrow {
    display: none;
  }

  h1 {
    font-size: 25px;
    line-height: 1;
  }

  .topbar-actions {
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: center;
    gap: 10px;
  }

  .stats {
    display: grid;
    min-width: 0;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 6px;
  }

  .stats div {
    min-width: 0;
    padding: 8px 4px;
    border: 1px solid rgba(217, 212, 201, 0.8);
    border-radius: 12px;
    background: rgba(247, 243, 234, 0.72);
    text-align: center;
  }

  .stats div + div::before { display: none; }
  .stats span { margin: 0; font-size: 19px; }
  .stats small {
    display: block;
    max-width: 100%;
    margin-top: 2px;
    overflow: hidden;
    font-size: 7px;
    letter-spacing: 0;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .calendar-toggle {
    width: 46px;
    min-width: 46px;
    padding: 0;
    justify-content: center;
    border-radius: 14px;
  }

  .calendar-toggle span:last-child { display: none; }
  .calendar-toggle-icon { font-size: 19px; }

  .calendar-tray {
    width: auto;
    max-height: calc(100vh - 120px);
    margin: 0 -14px -12px;
    padding: 12px 14px 16px;
    overflow-y: auto;
  }

  .calendar-card {
    padding: 13px;
    border-radius: 16px;
    box-shadow: none;
  }

  .calendar-footer .button-row {
    display: grid;
    grid-template-columns: 1fr;
  }

  main {
    width: 100%;
    padding: 12px 12px 16px;
    overflow: visible;
  }

  .tabs {
    position: fixed;
    right: 10px;
    bottom: calc(8px + env(safe-area-inset-bottom, 0px));
    left: 10px;
    z-index: 25;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
    margin: 0;
    padding: 8px;
    border: 1px solid rgba(195, 196, 187, 0.72);
    border-radius: 18px;
    background: rgba(255, 253, 248, 0.96);
    box-shadow: 0 14px 36px rgba(16, 41, 44, 0.16);
    backdrop-filter: blur(16px);
  }

  .tabs::after { display: none; }

  .tab {
    display: grid;
    min-width: 0;
    min-height: 46px;
    place-items: center;
    border-radius: 13px;
    padding: 6px 4px;
    font-size: 12px;
    line-height: 1.05;
    text-align: center;
  }

  .tab span {
    display: block;
    margin: 0 0 3px;
    font-size: 8px;
  }

  .tab.active {
    border-color: transparent;
    color: #fffdf8;
    background: var(--teal);
    box-shadow: 0 8px 18px rgba(11, 112, 109, 0.18);
  }

  .tab.active span { color: #f1c76d; }

  .flashcard-page {
    margin: 0;
  }

  .flashcard {
    min-height: 270px;
    border-radius: 18px;
    padding: 20px 17px;
  }

  .flashcard-front strong {
    font-size: 31px;
    overflow-wrap: anywhere;
  }

  .flashcard-front span {
    font-size: 16px;
  }

  .flashcard-back h4 {
    font-size: 23px;
    overflow-wrap: anywhere;
  }

  .flashcard-actions {
    grid-template-columns: 1fr;
  }

  .hero {
    min-height: auto;
    margin-bottom: 10px;
    padding: 14px;
    border-radius: 18px;
    box-shadow: none;
    background: rgba(255, 253, 248, 0.82);
  }

  .hero::after { display: none; }
  .hero .eyebrow { margin-bottom: 8px; font-size: 9px; letter-spacing: 0.08em; }

  .hero h2 {
    max-width: 100%;
    font-size: 24px;
    line-height: 1.12;
    overflow-wrap: anywhere;
  }

  .source-line {
    max-width: 100%;
    font-size: 12px;
    line-height: 1.45;
    overflow-wrap: anywhere;
  }

  .lesson-grid,
  .practice-layout,
  .study-area {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 10px;
  }

  .panel {
    min-width: 0;
    padding: 13px;
    border-radius: 18px;
    box-shadow: none;
  }

  .section-title,
  .section-kicker,
  .explanation-head,
  .finish-panel {
    align-items: stretch;
    flex-direction: column;
  }

  .section-title { gap: 10px; }
  .section-kicker { gap: 5px; margin-bottom: 10px; }
  .section-kicker span { font-size: 9px; letter-spacing: 0.08em; }
  .section-kicker h3 { font-size: 18px; line-height: 1.18; }
  .section-kicker i { width: auto; margin: 0; font-size: 11px; }

  .clip-player {
    aspect-ratio: 16 / 9;
    border-radius: 14px;
    box-shadow: none;
  }

  .clip-player:has(.no-clip) {
    min-height: 220px;
  }

  .clip-actions,
  .next-step-row,
  .explain-actions,
  .question-row {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .clip-actions button,
  .clip-actions button.primary,
  .next-step-row button,
  .explain-actions button,
  .question-row button,
  #addSelectionBtn,
  #explainBtn,
  #checkRecitationBtn,
  #sentenceFeedbackBtn,
  #finishDayBtn {
    width: 100%;
    min-width: 0;
  }

  .transcript-block {
    padding: 14px;
    border-radius: 14px;
    font-size: 18px;
    line-height: 1.85;
  }

  .token {
    padding: 2px 1px;
  }

  .selected-items {
    gap: 6px;
    margin: 10px 0;
  }

  .chip,
  .selected-chip,
  .practice-chip {
    max-width: 100%;
    white-space: normal;
    overflow-wrap: anywhere;
  }

  .explanation-card,
  .sentence-review,
  .dictation-prompt,
  .manual-grid article {
    padding: 12px;
    border-radius: 15px;
  }

  .explanation-card h4 {
    font-size: 20px;
    overflow-wrap: anywhere;
  }

  .collocation-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .question-row input {
    width: 100%;
    min-width: 0;
    border-radius: 12px;
  }

  textarea {
    min-height: 150px;
    border-radius: 14px;
    font-size: 16px;
    line-height: 1.5;
  }

  .review-row {
    grid-template-columns: 1fr;
  }

  .sentence-original,
  .sentence-corrected p,
  .feedback,
  .manual-grid li {
    overflow-wrap: anywhere;
  }

  .manual-page h2 { font-size: 24px; }
  .manual-grid { grid-template-columns: 1fr; }
  .manual-grid ul,
  .manual-grid ol { padding-left: 18px; }

  .study-timer {
    right: 12px;
    bottom: calc(84px + env(safe-area-inset-bottom, 0px));
    z-index: 26;
  }

  .jump-scroll-btn {
    right: 12px;
    bottom: calc(136px + env(safe-area-inset-bottom, 0px));
    z-index: 26;
  }
}


