:root {
  color-scheme: light;
  --bg: color-mix(in srgb, var(--accent) 10%, white);
  --paper: color-mix(in srgb, var(--accent) 4%, white);
  --surface: color-mix(in srgb, var(--accent) 2%, white);
  --surface-muted: color-mix(in srgb, var(--accent) 18%, white);
  --surface-warm: color-mix(in srgb, var(--accent) 12%, white);
  --ink: #142638;
  --ink-soft: #38546a;
  --muted: #6d8294;
  --line: color-mix(in srgb, var(--accent) 25%, white);
  --line-strong: color-mix(in srgb, var(--accent) 36%, white);
  --accent: #42afe7;
  --accent-dark: #176f9f;
  --clay: color-mix(in srgb, var(--accent) 58%, white);
  --sage: color-mix(in srgb, var(--accent-dark) 70%, #64748b);
  --gold: color-mix(in srgb, var(--accent) 78%, white);
  --shadow: 0 14px 34px color-mix(in srgb, var(--accent-dark) 10%, transparent);
  --shadow-soft: 0 8px 20px color-mix(in srgb, var(--accent-dark) 8%, transparent);
  --radius: 8px;
  --nav-height: 76px;
  --font: "Times New Roman", Times, Georgia, serif;
}

:root[data-color-mode="dark"] {
  color-scheme: dark;
  --bg: color-mix(in srgb, var(--accent-dark) 24%, #07131e);
  --paper: color-mix(in srgb, var(--accent-dark) 13%, #0b1722);
  --surface: color-mix(in srgb, var(--accent-dark) 12%, #101d29);
  --surface-muted: color-mix(in srgb, var(--accent) 18%, #102638);
  --surface-warm: color-mix(in srgb, var(--accent) 14%, #142b3c);
  --ink: #edf8ff;
  --ink-soft: #c2d7e7;
  --muted: #8fafc5;
  --line: color-mix(in srgb, var(--accent) 28%, #183044);
  --line-strong: color-mix(in srgb, var(--accent) 40%, #1b405a);
  --shadow: 0 18px 48px rgba(0, 0, 0, 0.28);
  --shadow-soft: 0 10px 28px rgba(0, 0, 0, 0.22);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: auto;
}

body {
  margin: 0;
  background:
    linear-gradient(
      180deg,
      color-mix(in srgb, var(--accent) 2%, white) 0,
      color-mix(in srgb, var(--accent) 10%, white) 46%,
      color-mix(in srgb, var(--accent) 18%, white) 100%
    ),
    var(--bg);
  color: var(--ink);
  font-family: var(--font);
  letter-spacing: 0;
}

:root[data-color-mode="dark"] body {
  background:
    linear-gradient(
      180deg,
      color-mix(in srgb, var(--accent-dark) 14%, #07131e) 0,
      color-mix(in srgb, var(--accent-dark) 24%, #07131e) 46%,
      #06111b 100%
    ),
    var(--bg);
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

button:focus-visible,
input:focus-visible {
  outline: 2px solid color-mix(in srgb, var(--accent) 72%, white);
  outline-offset: 2px;
}

button:disabled {
  cursor: default;
}

h1,
h2,
h3,
p,
blockquote {
  margin-top: 0;
}

svg {
  width: 100%;
  height: 100%;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.9;
}

.app-shell {
  display: block;
  min-height: 100svh;
}

.side-nav {
  display: none;
}

.brand,
.study-clock {
  display: none;
}

.nav-list {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 4px;
  height: 100%;
}

.nav-item {
  display: grid;
  place-items: center;
  align-content: center;
  gap: 4px;
  min-width: 0;
  min-height: 58px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: transparent;
  color: var(--muted);
  padding: 4px 2px;
  text-align: center;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.1;
  transition: background 160ms ease, color 160ms ease, border-color 160ms ease, transform 160ms ease;
}

.nav-item:hover {
  border-color: var(--line-strong);
  background: var(--surface-warm);
  color: var(--accent-dark);
}

.nav-item.active {
  border-color: var(--clay);
  background: var(--surface-warm);
  color: var(--accent-dark);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 28%, transparent);
}

.icon,
.button-icon {
  display: inline-grid;
  place-items: center;
  width: 22px;
  height: 22px;
  flex: 0 0 auto;
}

.main-app {
  width: min(1160px, 100%);
  margin: 0 auto;
  padding: 14px 14px 28px;
}

.mobile-masthead {
  position: sticky;
  top: 0;
  z-index: 14;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: -14px -14px 18px;
  padding: 12px 14px;
  border-bottom: 1px solid color-mix(in srgb, var(--accent) 22%, transparent);
  background: color-mix(in srgb, var(--paper) 88%, transparent);
  backdrop-filter: blur(18px);
}

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

.mobile-masthead .brand-mark {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: var(--radius);
  background: var(--accent-dark);
  color: var(--surface);
  font-weight: 700;
}

.mobile-masthead strong {
  font-size: 20px;
  font-weight: 700;
}

.menu-button {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--accent-dark);
  box-shadow: var(--shadow-soft);
}

.topbar {
  display: grid;
  gap: 14px;
  margin-bottom: 12px;
}

body:not([data-route="home"]) .topbar {
  display: none;
}

.time-label,
.section-label {
  margin: 0 0 7px;
  color: var(--accent-dark);
  font-size: 12px;
  font-weight: 700;
}

h1 {
  max-width: 760px;
  margin-bottom: 0;
  font-size: 30px;
  line-height: 1.08;
  font-weight: 700;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 0;
  font-size: 19px;
  line-height: 1.22;
  font-weight: 700;
}

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

.mini-stat,
.theme-card {
  min-height: 62px;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--surface) 82%, transparent);
  box-shadow: var(--shadow-soft);
}

.mini-stat span,
.mini-stat small {
  display: block;
}

.mini-stat span {
  color: var(--accent-dark);
  font-size: 22px;
  font-weight: 700;
  line-height: 1.05;
}

.mini-stat small {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.theme-card {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 10px;
}

.theme-card label {
  color: var(--accent-dark);
  font-size: 14px;
  font-weight: 700;
}

.theme-picker {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.theme-picker input {
  width: 46px;
  height: 46px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 4px;
}

.theme-picker input::-webkit-color-swatch-wrapper {
  padding: 0;
}

.theme-picker input::-webkit-color-swatch {
  border: 0;
  border-radius: 5px;
}

.theme-picker button {
  min-height: 46px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface-warm);
  color: var(--accent-dark);
  padding: 0 14px;
  font-size: 14px;
  font-weight: 700;
}

.settings-theme-card {
  margin-top: 14px;
  box-shadow: none;
}

.settings-drawer {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  pointer-events: none;
  visibility: hidden;
}

.settings-backdrop {
  position: fixed;
  inset: 0;
  border: 0;
  background: rgba(8, 23, 35, 0.24);
  opacity: 0;
  transition: opacity 180ms ease;
}

.settings-sheet {
  position: relative;
  z-index: 1;
  width: min(430px, calc(100vw - 24px));
  height: calc(100svh - 24px);
  margin: 12px auto 12px 12px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--paper);
  box-shadow: 0 24px 72px rgba(8, 23, 35, 0.22);
  padding: 0;
  transform: translateX(calc(-100% - 18px));
  transition: transform 220ms ease;
}

body.settings-open {
  overflow: hidden;
}

body.settings-open .settings-drawer {
  pointer-events: auto;
  visibility: visible;
}

body.settings-open .settings-backdrop {
  opacity: 1;
}

body.settings-open .settings-sheet {
  transform: translateX(0);
}

.settings-sheet-header {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin: 0 0 14px;
  padding: 14px;
  border-bottom: 1px solid var(--line);
  background: var(--paper);
  backdrop-filter: blur(16px);
}

.settings-stack {
  display: grid;
  gap: 12px;
  padding: 0 14px 14px;
}

.settings-panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  padding: 16px;
}

.settings-field {
  display: grid;
  gap: 10px;
  margin-top: 16px;
}

.settings-field label,
.field-label {
  color: var(--accent-dark);
  font-size: 14px;
  font-weight: 700;
}

.choice-ui {
  display: grid;
  gap: 8px;
}

.choice-ui.two-up {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.setting-choice {
  display: grid;
  gap: 3px;
  min-height: 72px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--surface) 78%, transparent);
  color: var(--ink);
  padding: 11px 12px;
  text-align: left;
  transition: background 160ms ease, border-color 160ms ease, transform 160ms ease;
}

.setting-choice strong,
.setting-choice small {
  display: block;
}

.setting-choice strong {
  font-size: 16px;
  line-height: 1.1;
}

.setting-choice small {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.32;
}

.setting-choice[aria-checked="true"] {
  border-color: var(--clay);
  background: var(--surface-warm);
  color: var(--accent-dark);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 26%, transparent);
}

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

.theme-swatch {
  min-height: 48px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background:
    linear-gradient(135deg, color-mix(in srgb, var(--swatch) 80%, white), var(--swatch));
  box-shadow: inset 0 0 0 3px var(--surface);
}

.theme-swatch[aria-pressed="true"] {
  border-color: var(--ink);
  box-shadow:
    inset 0 0 0 3px var(--surface),
    0 0 0 2px color-mix(in srgb, var(--swatch) 44%, transparent);
}

.hex-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: end;
}

.hex-control {
  display: grid;
  gap: 6px;
}

.hex-control span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.hex-control input {
  min-height: 48px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  padding: 0 12px;
  font-size: 17px;
  font-weight: 700;
}

.hex-row > button {
  min-height: 48px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface-warm);
  color: var(--accent-dark);
  padding: 0 14px;
  font-size: 14px;
  font-weight: 700;
}

.quote-strip {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr) 44px;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  box-shadow: var(--shadow-soft);
}

.quote-icon {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: var(--radius);
  background: var(--surface-muted);
  color: var(--accent-dark);
}

.quote-copy span,
.quote-copy cite {
  display: block;
}

.quote-copy span {
  color: var(--accent-dark);
  font-size: 12px;
  font-weight: 700;
}

.quote-copy blockquote {
  margin: 3px 0 5px;
  color: var(--ink);
  font-size: 17px;
  line-height: 1.42;
  font-weight: 700;
}

.quote-copy cite {
  color: var(--muted);
  font-style: normal;
  font-size: 12px;
  line-height: 1.35;
}

.icon-button {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--accent-dark);
  transition: transform 160ms ease, border-color 160ms ease, background 160ms ease;
}

.icon-button:hover {
  border-color: var(--clay);
  background: var(--surface-warm);
  transform: translateY(-1px);
}

button.is-pressing,
button:active {
  transform: translateY(1px) scale(0.985);
}

.dashboard-grid,
.home-grid,
.settings-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  align-items: start;
}

.page-section {
  display: none;
  scroll-margin-top: 76px;
}

.page-section.active {
  display: block;
  animation: page-enter 180ms ease-out both;
}

#learn.active {
  display: grid;
  gap: 12px;
}

@keyframes page-enter {
  from {
    opacity: 0;
    transform: translateY(8px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.feature-page-header {
  margin-bottom: 12px;
}

.back-button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--surface) 84%, transparent);
  color: var(--accent-dark);
  padding: 0 12px 0 9px;
  font-size: 14px;
  font-weight: 700;
}

.back-button svg {
  width: 18px;
  height: 18px;
}

.panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  box-shadow: var(--shadow-soft);
}

.word-panel,
.practice-panel,
.understanding-panel,
.score-panel,
.plan-panel,
.review-panel,
.spelling-panel,
.settings-panel,
.home-action-panel {
  padding: 16px;
}

.panel-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.panel-heading.compact {
  margin-bottom: 14px;
}

.level-pill,
.trend,
.accuracy {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 32px;
  border-radius: var(--radius);
  padding: 0 10px;
  white-space: nowrap;
  font-size: 12px;
  font-weight: 700;
}

.level-pill {
  background: var(--surface-muted);
  color: var(--accent-dark);
}

.trend {
  background: var(--surface-warm);
  color: var(--sage);
}

.accuracy {
  background: var(--surface-warm);
  color: var(--accent-dark);
}

#wordTitle {
  margin-top: 2px;
  font-size: clamp(40px, 15vw, 68px);
  line-height: 0.98;
  font-weight: 700;
  letter-spacing: 0;
}

.word-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 14px 0 12px;
}

.word-meta span {
  min-height: 32px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 7px 9px;
  color: var(--ink-soft);
  background: var(--surface);
  font-size: 13px;
}

.word-definition {
  margin-bottom: 18px;
  color: var(--ink-soft);
  font-size: 17px;
  line-height: 1.55;
}

.segmented {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 4px;
  width: 100%;
  margin-bottom: 16px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-muted);
}

.segment {
  min-height: 44px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

.segment.active {
  background: var(--surface);
  color: var(--accent-dark);
  box-shadow: 0 6px 16px color-mix(in srgb, var(--accent-dark) 12%, transparent);
}

.learning-flow {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
  margin-bottom: 10px;
}

.flow-step {
  display: grid;
  place-items: center;
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--surface) 78%, transparent);
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.flow-step.active {
  border-color: var(--clay);
  background: var(--surface-warm);
  color: var(--accent-dark);
}

.learning-copy {
  min-height: 160px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--accent);
  border-radius: var(--radius);
  padding: 14px;
  background: var(--surface);
}

.learning-copy h3 {
  margin: 0 0 8px;
  font-size: 17px;
  font-weight: 700;
}

.learning-copy p {
  margin: 0 0 10px;
  color: var(--ink-soft);
  font-size: 15px;
  line-height: 1.64;
}

.learning-copy p:last-child {
  margin-bottom: 0;
}

.learning-copy strong {
  color: var(--ink);
}

.action-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 9px;
  margin-top: 14px;
}

.home-grid {
  margin-top: 12px;
}

.home-action-panel {
  order: -1;
}

.score-panel {
  order: 2;
}

.flow-list {
  display: grid;
  gap: 10px;
  margin-top: 16px;
}

.flow-item {
  display: grid;
  position: relative;
  grid-template-columns: 38px minmax(0, 1fr) 22px;
  gap: 2px 12px;
  min-height: 78px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  color: var(--ink);
  padding: 13px 12px;
  text-align: left;
  box-shadow: none;
  transition: background 140ms ease, border-color 140ms ease, transform 140ms ease;
}

.flow-item::after {
  content: "";
  grid-column: 3;
  grid-row: 1 / 3;
  align-self: center;
  justify-self: end;
  width: 9px;
  height: 9px;
  border-top: 1.8px solid currentColor;
  border-right: 1.8px solid currentColor;
  color: var(--muted);
  transform: rotate(45deg);
}

.flow-item:hover {
  border-color: var(--line-strong);
  background: var(--surface-warm);
  transform: translateY(-1px);
}

.flow-item span {
  grid-row: span 2;
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: var(--radius);
  background: var(--surface-muted);
  color: var(--accent-dark);
  font-weight: 700;
}

.flow-item strong {
  align-self: end;
  font-size: 17px;
}

.flow-item small {
  color: var(--muted);
  font-size: 13px;
}

.primary-action,
.secondary-action,
.ghost-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  border-radius: var(--radius);
  padding: 0 16px;
  font-size: 15px;
  font-weight: 700;
  transition: background 140ms ease, border-color 140ms ease, color 140ms ease, transform 140ms ease;
}

.primary-action {
  border: 1px solid var(--accent);
  background: var(--accent);
  color: var(--surface);
}

.secondary-action {
  border: 1px solid var(--line-strong);
  background: var(--surface-warm);
  color: var(--accent-dark);
}

.ghost-action {
  border: 1px solid var(--line-strong);
  background: transparent;
  color: var(--ink-soft);
}

.quiz-prompt {
  min-height: 54px;
  margin-bottom: 12px;
  color: var(--ink-soft);
  font-size: 16px;
  line-height: 1.52;
}

.choice-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

.choice-button {
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  font-size: 15px;
  font-weight: 700;
  transition: background 140ms ease, border-color 140ms ease, transform 140ms ease;
}

.choice-button:hover {
  border-color: var(--clay);
  background: var(--surface-warm);
}

.choice-button.correct {
  border-color: #80bfa8;
  background: #e7f7f1;
  color: #15382e;
  animation: answer-pop 180ms ease-out both;
}

.choice-button.wrong {
  border-color: #cf8d73;
  background: #fae9e3;
  color: #552719;
  animation: answer-shake 180ms ease-out both;
}

.choice-button:disabled {
  opacity: 1;
}

@keyframes answer-pop {
  50% {
    transform: scale(1.018);
  }
}

@keyframes answer-shake {
  25% {
    transform: translateX(-3px);
  }

  75% {
    transform: translateX(3px);
  }
}

.spelling-input-wrap {
  display: grid;
  gap: 8px;
  margin: 14px 0;
  color: var(--accent-dark);
  font-size: 14px;
  font-weight: 700;
}

.spelling-input-wrap input {
  min-height: 54px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  padding: 0 14px;
  font-size: 28px;
  font-weight: 700;
}

.quiz-feedback {
  min-height: 40px;
  margin: 11px 0 16px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.46;
}

.progress-block {
  display: grid;
  gap: 8px;
}

.progress-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 14px;
}

.progress-row strong {
  color: var(--ink);
}

.progress-track {
  height: 9px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--surface-muted);
}

.progress-track span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), var(--gold));
  transition: width 240ms ease;
}

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

.analysis-item {
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr);
  gap: 10px;
  align-items: start;
}

.analysis-item span {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: var(--radius);
  background: var(--surface-muted);
  color: var(--accent-dark);
  font-size: 13px;
  font-weight: 700;
}

.analysis-item h3 {
  margin: 2px 0 4px;
  font-size: 15px;
  font-weight: 700;
}

.analysis-item p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
}

.score-ring {
  position: relative;
  display: grid;
  place-items: center;
  width: 152px;
  height: 152px;
  margin: 4px auto 16px;
  border-radius: 50%;
  background:
    radial-gradient(circle at center, var(--surface) 55%, transparent 56%),
    conic-gradient(var(--accent) var(--score-deg, 234deg), var(--surface-muted) 0);
}

.score-ring span,
.score-ring small {
  grid-column: 1;
  grid-row: 1;
}

.score-ring span {
  font-size: 42px;
  font-weight: 700;
}

.score-ring small {
  align-self: end;
  margin-bottom: 34px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.score-controls {
  display: grid;
  gap: 14px;
}

.score-controls label {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px 12px;
  color: var(--ink-soft);
  font-size: 14px;
  font-weight: 700;
}

.score-controls label span {
  color: var(--accent-dark);
}

.score-controls input {
  grid-column: 1 / -1;
  width: 100%;
  accent-color: var(--accent);
}

.self-band-control input {
  min-height: 48px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  padding: 0 12px;
  font-size: 24px;
  font-weight: 700;
}

.adaptive-summary {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

.adaptive-summary div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--surface) 72%, var(--surface-warm));
  padding: 0 12px;
}

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

.adaptive-summary strong {
  color: var(--accent-dark);
  font-size: 15px;
}

.score-note {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.timeline {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

.timeline-item {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 10px;
  min-height: 52px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px;
  background: var(--surface);
}

.timeline-item span {
  display: block;
  width: 5px;
  height: 28px;
  border-radius: 999px;
  background: var(--line-strong);
}

.timeline-item.done span {
  background: var(--sage);
}

.timeline-item.active {
  border-color: var(--clay);
  background: var(--surface-warm);
}

.timeline-item.active span {
  background: var(--accent);
}

.timeline-item p,
.timeline-item strong {
  display: block;
  margin: 0;
}

.timeline-item p {
  color: var(--ink-soft);
  font-size: 14px;
  line-height: 1.25;
}

.timeline-item strong {
  color: var(--ink);
  font-size: 14px;
}

@media (min-width: 560px) {
  .main-app {
    padding-right: 20px;
    padding-left: 20px;
  }

  .topbar {
    grid-template-columns: minmax(0, 1fr) minmax(240px, 300px);
    align-items: end;
  }

  .action-row {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .choice-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .timeline {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (min-width: 760px) {
  .app-shell {
    display: block;
  }

  .side-nav {
    display: none;
  }

  .brand {
    display: grid;
    justify-items: center;
    gap: 7px;
    color: inherit;
    text-align: center;
    text-decoration: none;
  }

  .brand-mark {
    display: grid;
    place-items: center;
    width: 42px;
    height: 42px;
    border-radius: var(--radius);
    background: var(--accent-dark);
    color: var(--surface);
    font-weight: 700;
  }

  .brand strong,
  .brand small {
    display: none;
  }

  .nav-list {
    display: grid;
    grid-template-columns: 1fr;
    gap: 7px;
    height: auto;
  }

  .nav-item {
    min-height: 62px;
    padding: 7px 4px;
  }

  .main-app {
    padding: 18px 24px 34px;
  }

  .mobile-masthead {
    margin: -18px -24px 22px;
    padding: 14px 24px;
  }

  .dashboard-grid {
    grid-template-columns: minmax(0, 1.1fr) minmax(260px, 0.9fr);
    gap: 14px;
  }

  .home-grid,
  .settings-grid {
    grid-template-columns: minmax(0, 1fr) minmax(280px, 0.86fr);
    gap: 14px;
  }

  .word-panel {
    grid-row: auto;
    min-height: 552px;
  }

  .dashboard-grid .score-panel {
    grid-column: 2;
    grid-row: span 2;
  }

  .plan-panel {
    grid-column: 1 / -1;
  }

  .quote-strip,
  .panel,
  .mini-stat {
    box-shadow: var(--shadow);
  }
}

@media (min-width: 1100px) {
  .app-shell {
    display: block;
  }

  .side-nav {
    display: none;
  }

  .brand {
    display: flex;
    justify-items: stretch;
    align-items: center;
    gap: 12px;
    text-align: left;
  }

  .brand strong,
  .brand small {
    display: block;
  }

  .brand strong {
    color: var(--ink);
    font-size: 18px;
  }

  .brand small {
    margin-top: 2px;
    color: var(--muted);
    font-size: 12px;
  }

  .nav-item {
    grid-template-columns: 24px minmax(0, 1fr);
    place-items: center start;
    min-height: 48px;
    gap: 10px;
    padding: 0 12px;
    text-align: left;
    font-size: 14px;
  }

  .study-clock {
    display: block;
    margin-top: auto;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: color-mix(in srgb, var(--surface) 78%, transparent);
  }

  .study-clock span,
  .study-clock small {
    display: block;
  }

  .study-clock span {
    font-size: 26px;
    font-weight: 700;
  }

  .study-clock small {
    margin-top: 4px;
    color: var(--muted);
    font-size: 12px;
  }

  .main-app {
    padding: 20px 28px 42px;
  }

  .mobile-masthead {
    display: flex;
    margin: -20px -28px 24px;
    padding: 16px 28px;
  }

  h1 {
    font-size: 40px;
  }

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

  .home-grid,
  .settings-grid {
    grid-template-columns: minmax(0, 0.9fr) minmax(360px, 1.1fr);
    gap: 16px;
  }

  .word-panel,
  .practice-panel,
  .understanding-panel,
  .score-panel,
  .plan-panel,
  .review-panel,
  .spelling-panel,
  .settings-panel,
  .home-action-panel {
    padding: 22px;
  }

  .score-ring {
    width: 176px;
    height: 176px;
  }

  .score-ring span {
    font-size: 48px;
  }

  .score-ring small {
    margin-bottom: 40px;
  }

  .timeline {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .timeline-item {
    grid-template-columns: 1fr;
    min-height: 92px;
    align-items: start;
  }

  .timeline-item span {
    width: 24px;
    height: 4px;
  }
}

@media (min-width: 900px) {
  html,
  body {
    min-height: 100%;
    overflow-x: hidden;
    overflow-y: auto;
  }

  .app-shell {
    min-height: 100svh;
  }

  .main-app {
    display: grid;
    grid-template-rows: 52px auto minmax(0, 1fr);
    gap: 10px;
    min-height: 100svh;
    max-width: 1180px;
    padding: 10px 22px 12px;
  }

  body:not([data-route="home"]) .main-app {
    grid-template-rows: 52px minmax(0, 1fr);
  }

  .mobile-masthead {
    position: relative;
    min-height: 52px;
    margin: -10px -22px 0;
    padding: 7px 22px;
  }

  .menu-button {
    width: 38px;
    height: 38px;
  }

  .mobile-masthead .brand-mark {
    width: 36px;
    height: 36px;
  }

  .topbar {
    grid-template-columns: minmax(0, 1fr) 260px;
    align-items: end;
    gap: 12px;
    margin-bottom: 0;
  }

  .time-label,
  .section-label {
    margin-bottom: 4px;
    font-size: 11px;
  }

  h1 {
    max-width: 900px;
    font-size: 30px;
    line-height: 1.02;
  }

  h2 {
    font-size: 18px;
  }

  .top-actions {
    gap: 8px;
  }

  .mini-stat {
    min-height: 50px;
    padding: 8px 10px;
  }

  .mini-stat span {
    font-size: 20px;
  }

  .mini-stat small {
    margin-top: 2px;
    font-size: 11px;
  }

  .page-section.active {
    min-height: 0;
    overflow: visible;
  }

  #home.active {
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
    gap: 10px;
  }

  .quote-strip {
    min-height: 74px;
    margin-bottom: 0;
    padding: 10px 12px;
    gap: 10px;
  }

  .quote-icon {
    width: 34px;
    height: 34px;
  }

  .quote-copy blockquote {
    display: -webkit-box;
    overflow: hidden;
    margin-bottom: 3px;
    font-size: 15px;
    line-height: 1.24;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
  }

  .icon-button {
    width: 38px;
    height: 38px;
  }

  .home-grid {
    grid-template-columns: minmax(420px, 1.08fr) minmax(300px, 0.92fr);
    gap: 10px;
    min-height: 0;
    margin-top: 0;
  }

  .home-action-panel,
  .score-panel {
    order: initial;
    min-height: 0;
    padding: 14px;
  }

  .flow-list {
    gap: 8px;
    margin-top: 12px;
  }

  .flow-item {
    min-height: 66px;
    padding: 10px 12px;
  }

  .score-ring {
    width: 128px;
    height: 128px;
    margin: 0 auto 10px;
  }

  .score-ring span {
    font-size: 36px;
  }

  .score-ring small {
    margin-bottom: 26px;
    font-size: 11px;
  }

  .adaptive-summary {
    gap: 6px;
  }

  .adaptive-summary div {
    min-height: 40px;
    padding: 0 10px;
  }

  .score-note {
    font-size: 12px;
    line-height: 1.35;
  }

  #learn.active {
    grid-template-columns: minmax(0, 1.14fr) minmax(300px, 0.86fr);
    grid-template-rows: auto minmax(0, 1fr);
    gap: 10px;
    min-height: 0;
  }

  #learn .feature-page-header {
    grid-column: 1 / -1;
  }

  .feature-page-header {
    margin-bottom: 0;
  }

  .back-button {
    min-height: 34px;
    padding-right: 10px;
    font-size: 13px;
  }

  .word-panel,
  .practice-panel,
  .review-panel,
  .spelling-panel {
    min-height: 0;
    height: auto;
    padding: 14px;
    overflow: visible;
  }

  .panel-heading,
  .panel-heading.compact {
    margin-bottom: 8px;
  }

  .level-pill,
  .trend,
  .accuracy {
    min-height: 28px;
    padding: 0 8px;
    font-size: 11px;
  }

  #wordTitle {
    font-size: clamp(40px, 5vw, 54px);
  }

  .word-meta {
    gap: 6px;
    margin: 8px 0;
  }

  .word-meta span {
    min-height: 28px;
    padding: 5px 8px;
    font-size: 12px;
  }

  .word-definition {
    margin-bottom: 10px;
    font-size: 15px;
    line-height: 1.34;
  }

  .learning-flow {
    gap: 4px;
    margin-bottom: 8px;
  }

  .flow-step {
    min-height: 28px;
    font-size: 11px;
  }

  .segmented {
    margin-bottom: 10px;
  }

  .segment {
    min-height: 36px;
    font-size: 13px;
  }

  .learning-copy {
    min-height: 112px;
    padding: 10px 12px;
    overflow: visible;
  }

  .learning-copy h3 {
    margin-bottom: 6px;
    font-size: 16px;
  }

  .learning-copy p {
    margin-bottom: 7px;
    font-size: 14px;
    line-height: 1.42;
  }

  .action-row {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
    margin-top: 10px;
  }

  .primary-action,
  .secondary-action,
  .ghost-action {
    min-height: 40px;
    padding: 0 12px;
    font-size: 14px;
  }

  .quiz-prompt {
    min-height: 42px;
    margin-bottom: 8px;
    font-size: 14px;
    line-height: 1.36;
  }

  .choice-grid {
    gap: 7px;
  }

  .choice-button {
    min-height: 40px;
    font-size: 14px;
  }

  .quiz-feedback {
    min-height: 32px;
    margin: 8px 0 10px;
    font-size: 13px;
  }

  #review.active,
  #spelling.active {
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
    gap: 10px;
    min-height: 0;
  }

  #review .review-panel,
  #spelling .spelling-panel {
    width: min(760px, 100%);
    justify-self: center;
  }

  .spelling-input-wrap {
    gap: 6px;
    margin: 10px 0;
  }

  .spelling-input-wrap input {
    min-height: 44px;
    font-size: 22px;
  }
}

@media (min-width: 900px) and (max-height: 760px) {
  .main-app {
    grid-template-rows: 46px auto minmax(0, 1fr);
    gap: 8px;
    padding-top: 8px;
    padding-bottom: 10px;
  }

  body:not([data-route="home"]) .main-app {
    grid-template-rows: 46px minmax(0, 1fr);
  }

  .mobile-masthead {
    min-height: 46px;
    margin-top: -8px;
    padding-top: 5px;
    padding-bottom: 5px;
  }

  h1 {
    font-size: 26px;
  }

  .quote-strip {
    min-height: 64px;
    padding-top: 8px;
    padding-bottom: 8px;
  }

  .home-grid {
    grid-template-columns: minmax(420px, 1.15fr) minmax(280px, 0.85fr);
  }

  .flow-item {
    min-height: 58px;
  }

  .score-ring {
    width: 112px;
    height: 112px;
  }

  .score-ring span {
    font-size: 32px;
  }

  .score-ring small {
    margin-bottom: 22px;
  }

  #wordTitle {
    font-size: clamp(36px, 4.4vw, 48px);
  }

  .learning-copy {
    min-height: 96px;
  }

  .learning-copy p {
    line-height: 1.34;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition: none !important;
  }
}
