:root {
  --bg: #f5f7fb;
  --surface: rgba(255, 255, 255, 0.85);
  --surface-soft: rgba(238, 245, 255, 0.7);
  --surface-strong: rgba(255, 255, 255, 0.96);
  --panel-bg: linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(248, 251, 255, 0.92));
  --card-bg: linear-gradient(180deg, rgba(255, 255, 255, 0.82), rgba(246, 250, 255, 0.72));
  --row-bg: linear-gradient(180deg, #ffffff, #fbfdff);
  --row-hover: linear-gradient(180deg, #f8fbff, #ffffff);
  --control-bg: rgba(255, 255, 255, 0.76);
  --chip-bg: rgba(239, 246, 255, 0.9);
  --panel-gloss:
    linear-gradient(135deg, rgba(255, 255, 255, 0.9), rgba(255, 255, 255, 0) 40%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.42), rgba(255, 255, 255, 0) 26%);
  --inset-highlight: rgba(255, 255, 255, 0.9);
  --ink: #0f172a;
  --muted: #64748b;
  --line: rgba(226, 232, 240, 0.8);
  --blue: #2563eb;
  --blue-soft: rgba(37, 99, 235, 0.1);
  --green: #10b981;
  --green-soft: rgba(16, 185, 129, 0.1);
  --amber: #d97706;
  --amber-soft: rgba(217, 119, 6, 0.1);
  --red: #ef4444;
  --shadow: 0 10px 30px rgba(15, 23, 42, 0.04);
  --shadow-deep: 0 20px 40px rgba(15, 23, 42, 0.08);
  --shadow-lift: 0 4px 14px rgba(37, 99, 235, 0.2);
  --radius: 12px;
  --font-sans: 'Plus Jakarta Sans', "PingFang SC", "Microsoft YaHei", system-ui, -apple-system, sans-serif;
  --font-display: 'Outfit', 'Plus Jakarta Sans', system-ui, sans-serif;
  font-family: var(--font-sans);
}

[data-theme="dark"] {
  --bg: #090d16;
  --surface: rgba(17, 24, 39, 0.82);
  --surface-soft: rgba(30, 41, 59, 0.72);
  --surface-strong: rgba(15, 23, 42, 0.96);
  --panel-bg: linear-gradient(180deg, rgba(17, 24, 39, 0.96), rgba(15, 23, 42, 0.9));
  --card-bg: linear-gradient(180deg, rgba(30, 41, 59, 0.84), rgba(15, 23, 42, 0.72));
  --row-bg: linear-gradient(180deg, rgba(15, 23, 42, 0.96), rgba(17, 24, 39, 0.92));
  --row-hover: linear-gradient(180deg, rgba(30, 41, 59, 0.96), rgba(15, 23, 42, 0.94));
  --control-bg: rgba(15, 23, 42, 0.82);
  --chip-bg: rgba(30, 41, 59, 0.96);
  --panel-gloss:
    linear-gradient(135deg, rgba(148, 163, 184, 0.12), rgba(148, 163, 184, 0) 42%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0) 30%);
  --inset-highlight: rgba(255, 255, 255, 0.08);
  --ink: #f8fafc;
  --muted: #b6c3d4;
  --line: rgba(148, 163, 184, 0.22);
  --blue: #3b82f6;
  --blue-soft: rgba(59, 130, 246, 0.15);
  --green: #10b981;
  --green-soft: rgba(16, 185, 129, 0.15);
  --amber: #f59e0b;
  --amber-soft: rgba(245, 158, 11, 0.15);
  --red: #f43f5e;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
  --shadow-deep: 0 20px 40px rgba(0, 0, 0, 0.45);
  --shadow-lift: 0 4px 14px rgba(59, 130, 246, 0.3);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(180deg, rgba(226, 238, 253, 0.92) 0, rgba(247, 249, 252, 0.82) 330px, rgba(247, 249, 252, 1) 100%),
    linear-gradient(90deg, rgba(255, 255, 255, 0.45), rgba(228, 236, 247, 0.36)),
    var(--bg);
  transition: background 0.3s ease, color 0.3s ease;
}

[data-theme="dark"] body {
  background:
    linear-gradient(180deg, rgba(13, 17, 30, 0.96) 0, rgba(9, 13, 22, 0.96) 330px, rgba(9, 13, 22, 1) 100%),
    radial-gradient(circle at top right, rgba(59, 130, 246, 0.08), transparent 450px),
    var(--bg);
}

button,
input,
select {
  font: inherit;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 28px;
  padding: 24px 18px;
  background: #10213f;
  color: #eef5ff;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 6px;
}

.brand-mark {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: #dff8ec;
  color: #07563e;
  font-weight: 900;
  font-size: 1.35rem;
}

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

.brand strong {
  font-size: 1rem;
}

.brand span {
  margin-top: 2px;
  color: #a9bed8;
  font-size: 0.78rem;
}

.nav-list {
  display: grid;
  gap: 6px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 12px;
  color: #cbd7e8;
  text-decoration: none;
  border-radius: 8px;
  font-size: 0.92rem;
  font-weight: 700;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.nav-item:hover {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.08);
}

.nav-item.active {
  color: #ffffff;
  background: linear-gradient(135deg, var(--blue) 0%, #4f46e5 100%);
  box-shadow: 0 4px 14px rgba(37, 99, 235, 0.35);
}

.nav-icon {
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.1);
}

.sidebar-note {
  margin-top: auto;
  padding: 16px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.06);
}

.sidebar-note b,
.sidebar-note span {
  display: block;
}

.sidebar-note span {
  margin-top: 8px;
  color: #b9c7d9;
  font-size: 0.82rem;
  line-height: 1.65;
}

.main {
  width: min(1260px, 100%);
  min-width: 0;
  margin: 0 auto;
  padding: 26px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 12px 0 20px;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1,
h2,
h3 {
  font-family: var(--font-display);
}

h1 {
  font-size: clamp(1.7rem, 3vw, 2.7rem);
  line-height: 1.12;
  letter-spacing: 0;
}

.topbar p,
.panel-head p {
  margin-top: 8px;
  color: var(--muted);
  line-height: 1.6;
  font-size: 0.94rem;
}

.top-actions,
.card-actions,
.quiz-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.top-actions {
  justify-content: flex-end;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--control-bg);
  box-shadow: 0 10px 28px rgba(20, 33, 61, 0.06);
}

.day-picker {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  padding: 0 10px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
}

.day-picker + .day-picker {
  border-left: 1px solid var(--line);
  border-radius: 0;
}

select,
input {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  outline: none;
}

select {
  border: 0;
  background: transparent;
  font-weight: 800;
}

input {
  width: 100%;
  min-height: 42px;
  padding: 0 12px;
}

input:focus,
select:focus-visible,
button:focus-visible {
  outline: 3px solid rgba(29, 78, 216, 0.22);
  outline-offset: 2px;
}

.button {
  min-height: 42px;
  padding: 0 14px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 0.88rem;
  font-weight: 800;
  color: var(--ink);
  background: var(--surface);
  box-shadow: 0 1px 0 var(--inset-highlight) inset, 0 7px 16px rgba(20, 33, 61, 0.06);
  transition: transform 160ms ease, box-shadow 160ms ease, border-color 160ms ease;
}

.button:hover {
  transform: translateY(-1px);
  box-shadow: 0 1px 0 var(--inset-highlight) inset, 0 12px 24px rgba(20, 33, 61, 0.09);
}

.button.primary {
  background: var(--blue);
  color: #ffffff;
  box-shadow: var(--shadow-lift);
}

.button.success {
  background: var(--green);
  color: #ffffff;
  box-shadow: 0 14px 28px rgba(15, 159, 110, 0.18), inset 0 1px 0 rgba(255, 255, 255, 0.22);
}

.button.warn {
  background: var(--amber-soft);
  color: var(--amber);
  border-color: rgba(245, 158, 11, 0.34);
}

.button.ghost {
  border-color: var(--line);
  background: var(--control-bg);
}

.app-view {
  display: none;
}

.app-view.active {
  display: block;
}

.stat-card,
.panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: var(--shadow);
  transition: border-color 0.3s ease, box-shadow 0.3s ease, background-color 0.3s ease;
}

.panel:hover {
  border-color: var(--blue-soft);
  box-shadow: var(--shadow-deep);
}

.stat-card {
  padding: 16px 18px;
  border: 0;
  border-left: 1px solid rgba(219, 228, 239, 0.72);
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

.stat-card:first-child {
  border-left: 0;
  padding-left: 0;
}

.stat-card span,
.stat-card small {
  display: block;
  color: var(--muted);
}

.stat-card span {
  font-size: 0.78rem;
  font-weight: 800;
}

.stat-card strong {
  display: block;
  margin-top: 6px;
  font-size: 1.55rem;
  letter-spacing: 0;
}

.stat-card small {
  margin-top: 4px;
  font-size: 0.76rem;
}

.section-grid {
  display: grid;
  gap: 18px;
  min-width: 0;
}

.today-grid {
  grid-template-columns: minmax(0, 1.45fr) minmax(320px, 0.75fr);
}

#today {
  max-width: 980px;
  margin: 0 auto;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0;
}

.review-grid {
  grid-template-columns: minmax(0, 1fr) minmax(320px, 0.72fr);
}

.review-grid.quiz-only {
  grid-template-columns: minmax(0, 760px);
  justify-content: center;
}

.quiz-panel {
  width: 100%;
}

.panel,
.dashboard-hero,
.chart-panel,
.dashboard-action {
  position: relative;
  margin-bottom: 18px;
  padding: 18px;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-bg);
  box-shadow: 0 18px 46px rgba(20, 33, 61, 0.08);
}

.dashboard-hero,
.chart-panel,
.dashboard-action {
  overflow: hidden;
  border-color: var(--line);
  box-shadow:
    0 28px 70px rgba(20, 33, 61, 0.11),
    0 10px 24px rgba(20, 33, 61, 0.06),
    0 1px 0 var(--inset-highlight) inset;
}

.dashboard-hero::before,
.chart-panel::before,
.dashboard-action::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: var(--panel-gloss);
}

.dashboard-hero > *,
.chart-panel > *,
.dashboard-action > * {
  position: relative;
}

.dashboard-hero {
  height: 100%;
  transform: none;
  transform-origin: 50% 0;
}

.overview-grid {
  display: grid;
  grid-template-columns: minmax(0, 0.96fr) minmax(360px, 1.04fr);
  gap: 16px;
  margin-top: 18px;
}

.today-overview-card,
.progress-overview-card,
.memory-curve-card {
  min-width: 0;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--card-bg);
  box-shadow:
    inset 0 1px 0 var(--inset-highlight),
    0 16px 34px rgba(20, 33, 61, 0.06);
}

.today-overview-card {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(280px, 0.75fr);
  grid-template-areas:
    "head head"
    "progress reinforce";
  gap: 16px 18px;
  margin-top: 4px;
}

.overview-section-head {
  grid-area: head;
}

.overview-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(260px, 0.52fr);
  gap: 14px;
  align-items: start;
  margin-bottom: 14px;
}

.overview-section-head h3,
.overview-head h3,
.memory-curve-card h3 {
  margin: 0;
  font-size: 0.98rem;
  line-height: 1.3;
}

.overview-section-head p,
.overview-head p,
.memory-curve-card p {
  margin-top: 6px;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.55;
}

.panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 16px;
}

.panel h2 {
  font-size: 1.08rem;
  line-height: 1.25;
}

.card-count {
  flex: 0 0 auto;
  padding: 7px 10px;
  border-radius: 999px;
  background: var(--blue-soft);
  color: var(--blue);
  font-weight: 900;
  font-size: 0.8rem;
}

.word-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 16px;
  min-height: 0;
  min-width: 0;
}

.word-main {
  display: grid;
  align-content: center;
  gap: 14px;
  min-width: 0;
}

.word-meta {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.word-meta span,
.context-box > span,
.box-title-row > span {
  display: inline-block;
  padding: 4px 8px;
  border-radius: 6px;
  background: var(--surface-soft);
  color: var(--blue);
  font-size: 0.74rem;
  font-weight: 900;
}

.audio-chip {
  min-height: 0;
  border: 1px solid var(--line);
  background: var(--control-bg);
  color: var(--muted);
  cursor: pointer;
  font-weight: 900;
  box-shadow: none;
}

.icon-audio {
  width: 32px;
  height: 32px;
  display: inline-grid;
  place-items: center;
  padding: 0;
  border-radius: 999px;
  font-size: 0.94rem;
  line-height: 1;
}

.audio-chip:hover {
  color: var(--blue);
  border-color: rgba(29, 78, 216, 0.28);
  background: var(--blue-soft);
  transform: translateY(-1px);
}

.box-title-row {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 10px;
}

.box-title-row .icon-audio {
  margin-left: auto;
}

.word-main h3 {
  font-size: clamp(2.4rem, 6vw, 4.6rem);
  line-height: 1;
  letter-spacing: 0;
  overflow-wrap: anywhere;
  word-break: break-word;
}

#wordChinese {
  color: var(--ink);
  font-size: 1.08rem;
  line-height: 1.65;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.context-box {
  min-width: 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-soft);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

.context-box p {
  margin-top: 8px;
  color: var(--ink);
  opacity: 0.9;
  line-height: 1.65;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.context-box .example-translation {
  margin-top: 6px;
  padding-top: 8px;
  border-top: 1px solid rgba(190, 205, 226, 0.58);
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.65;
}

.context-box.is-empty {
  background: var(--surface-soft);
}

.context-box.is-empty #wordExample {
  color: var(--muted);
  font-weight: 800;
}

.context-box.is-empty .example-translation {
  border-top-style: dashed;
  font-size: 0.86rem;
}

.audio-chip:disabled {
  cursor: not-allowed;
  opacity: 0.45;
  box-shadow: none;
}

.card-actions {
  margin-top: 16px;
  justify-content: flex-end;
}

.card-actions .button[hidden] {
  display: none;
}

.study-complete {
  display: grid;
  gap: 10px;
  margin-top: 16px;
  padding: 16px;
  border: 1px solid rgba(16, 185, 129, 0.34);
  border-radius: var(--radius);
  background: var(--green-soft);
}

.study-complete[hidden] {
  display: none;
}

.study-complete strong {
  color: var(--green);
  font-size: 1rem;
}

.study-complete p {
  color: var(--muted);
  line-height: 1.55;
}

.task-ring {
  display: grid;
  align-items: center;
  margin-bottom: 0;
  min-width: 0;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-soft);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.1), 0 12px 26px rgba(0, 0, 0, 0.05);
}

.dashboard-focus {
  grid-area: progress;
  display: grid;
  grid-template-columns: minmax(300px, 0.42fr) minmax(0, 1fr);
  gap: 22px;
  align-items: center;
  min-height: 154px;
  padding: 2px 0 4px;
}

.reinforce-panel {
  grid-area: reinforce;
  min-width: 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-soft);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.08),
    0 12px 24px rgba(0, 0, 0, 0.05);
}

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

.reinforce-head h4 {
  margin: 0;
  color: var(--ink);
  font-size: 0.98rem;
  line-height: 1.3;
}

.reinforce-head p {
  margin-top: 5px;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.5;
}

.reinforce-head > span {
  min-width: 34px;
  min-height: 30px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: var(--amber-soft);
  color: var(--amber);
  font-size: 0.86rem;
  font-weight: 900;
}

.reinforce-progress {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
}

.reinforce-progress small {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
}

.dual-progress {
  display: grid;
  gap: 14px;
}

.dual-progress span {
  display: block;
  margin-bottom: 7px;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 900;
}

.progress-bar {
  height: 14px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--surface-soft);
  box-shadow: inset 0 1px 3px rgba(20, 33, 61, 0.12);
}

.progress-bar i {
  width: 0%;
  height: 100%;
  display: block;
  border-radius: inherit;
  background: linear-gradient(90deg, #1d4ed8, #48a1ff);
  box-shadow: 0 6px 14px rgba(29, 78, 216, 0.24);
  transition: width 420ms ease;
}

.progress-bar.amber i {
  background: linear-gradient(90deg, #c77700, #ffc857);
}

.task-ring strong {
  font-size: clamp(1.7rem, 3vw, 2.2rem);
  line-height: 1;
}

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

.task-label {
  display: block;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 900;
}

.task-count {
  display: flex;
  align-items: baseline;
  gap: 6px;
  margin-top: 8px;
  white-space: nowrap;
}

.task-count span {
  color: var(--muted);
  font-size: 1.1rem;
  font-weight: 900;
}

.task-ring p {
  margin-top: 8px;
  color: var(--muted);
  line-height: 1.5;
  overflow-wrap: anywhere;
  font-size: 0.86rem;
}

.mini-list,
.review-list {
  display: grid;
  gap: 9px;
  max-height: 370px;
  overflow: auto;
  padding-right: 4px;
}

.word-row,
.review-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: start;
  padding: 11px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--row-bg);
  box-shadow: 0 7px 18px rgba(20, 33, 61, 0.04);
}

.word-row button,
.review-row button {
  min-height: 34px;
  padding: 0 10px;
  align-self: start;
}

.word-row b,
.review-row b {
  display: block;
  margin-bottom: 3px;
}

.word-row small,
.review-row small {
  color: var(--muted);
  line-height: 1.45;
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.plan-legend {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 14px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

.dot {
  width: 9px;
  height: 9px;
  display: inline-block;
  margin-right: 6px;
  border-radius: 50%;
}

.dot.new {
  background: var(--blue);
}

.dot.review {
  background: var(--amber);
}

.dot.done {
  background: var(--green);
}

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

.plan-grid.compact {
  grid-template-columns: repeat(15, minmax(34px, 1fr));
  gap: 8px;
}

.day-tile {
  min-height: 108px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--row-bg);
  cursor: pointer;
  text-align: left;
}

.plan-grid.compact .day-tile {
  min-height: 58px;
  padding: 8px;
}

.plan-grid.compact .day-tile span {
  display: none;
}

.plan-grid.compact .day-tile strong {
  font-size: 0.78rem;
}

.plan-grid.compact .day-tile::after {
  content: attr(data-progress);
  display: block;
  margin-top: 5px;
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 900;
}

.day-tile.learning {
  background: var(--blue-soft);
}

.day-tile.assessed {
  background: var(--amber-soft);
  border-color: rgba(245, 158, 11, 0.34);
}

.day-tile:hover,
.day-tile.active {
  border-color: var(--blue);
  box-shadow: 0 12px 28px rgba(29, 78, 216, 0.12);
}

.day-tile.done {
  background: var(--green-soft);
  border-color: rgba(16, 185, 129, 0.34);
}

.day-tile strong {
  display: block;
  font-size: 0.95rem;
}

.day-tile span {
  display: block;
  margin-top: 8px;
  color: var(--muted);
  font-size: 0.76rem;
  line-height: 1.45;
}

.day-tile .review-mark {
  margin-top: 8px;
  color: var(--amber);
  font-weight: 900;
}

.quiz-box {
  display: grid;
  gap: 12px;
}

.quiz-stage-badge {
  flex: 0 0 auto;
  min-width: 54px;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--row-bg);
  color: var(--blue);
  font-size: 0.78rem;
  font-weight: 900;
  text-align: center;
  box-shadow: 0 8px 18px rgba(29, 78, 216, 0.08);
}

.quiz-progress {
  display: flex;
  align-items: center;
  min-height: 34px;
  margin: -4px 0 12px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 850;
}

.quiz-prompt {
  min-height: 96px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--card-bg);
  color: var(--ink);
  line-height: 1.62;
  font-size: 1rem;
  font-weight: 900;
  box-shadow:
    inset 0 1px 0 var(--inset-highlight),
    0 12px 28px rgba(20, 33, 61, 0.06);
}

.choice-options {
  display: grid;
  gap: 9px;
}

.choice-options[hidden] {
  display: none;
}

.choice-option {
  width: 100%;
  min-height: 48px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--row-bg);
  color: var(--ink);
  font: inherit;
  font-weight: 850;
  line-height: 1.45;
  text-align: left;
  cursor: pointer;
  box-shadow: 0 8px 18px rgba(20, 33, 61, 0.05);
}

.choice-option:hover {
  border-color: rgba(29, 78, 216, 0.34);
  transform: translateY(-1px);
}

.choice-option.selected {
  border-color: rgba(37, 99, 235, 0.78);
  background: var(--blue-soft);
  color: var(--blue);
  box-shadow: 0 12px 24px rgba(37, 99, 235, 0.14);
}

.quiz-summary {
  display: grid;
  gap: 14px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--card-bg);
  box-shadow: 0 14px 28px rgba(20, 33, 61, 0.06);
}

.quiz-summary[hidden] {
  display: none;
}

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

.summary-stats div {
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-soft);
}

.summary-stats b {
  display: block;
  color: var(--ink);
  font-size: 1.7rem;
  line-height: 1;
}

.summary-stats span {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 850;
}

.quiz-summary h3 {
  margin-bottom: 8px;
  color: var(--ink);
  font-size: 0.86rem;
}

.summary-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.summary-chips span,
.summary-empty {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 5px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--chip-bg);
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 850;
}

.summary-empty {
  margin: 0;
}

.status-overview {
  display: grid;
  gap: 4px;
  padding: 12px;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--card-bg);
  box-shadow:
    inset 0 1px 0 var(--inset-highlight),
    0 14px 30px rgba(20, 33, 61, 0.06);
}

.status-overview span,
.status-overview small {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

.status-overview small {
  white-space: nowrap;
}

.status-overview strong {
  color: var(--ink);
  font-size: 1.75rem;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.distribution-list {
  padding: 0;
}

.dashboard-action {
  align-self: start;
  background: var(--card-bg);
  transform: translateZ(8px);
}

.dashboard-action .panel-head {
  margin-bottom: 12px;
}

.dashboard-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 16px;
}

.action-buttons {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.action-buttons .button {
  flex: 0 0 auto;
  min-width: 112px;
}

.chart-legend {
  display: grid;
  gap: 18px;
  min-width: 0;
}

.legend-row {
  display: grid;
  gap: 7px;
}

.legend-meta {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.legend-meta span {
  color: var(--ink);
  opacity: 0.85;
  font-size: 0.86rem;
  font-weight: 850;
}

.legend-meta b {
  color: var(--ink);
  font-size: 0.9rem;
  font-variant-numeric: tabular-nums;
}

.legend-meta small {
  margin-left: 6px;
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 800;
}

.legend-bar {
  height: 7px;
  overflow: hidden;
  border-radius: 999px;
  background: #e8eef6;
  box-shadow: inset 0 1px 2px rgba(20, 33, 61, 0.1);
}

.legend-bar i {
  width: var(--row-width);
  height: 100%;
  display: block;
  border-radius: inherit;
  background: var(--row-color);
}

.memory-curve-card {
  display: grid;
  grid-template-columns: 150px minmax(0, 1fr);
  gap: 18px;
  align-items: center;
}

.curve-visual {
  width: 100%;
  height: auto;
  min-height: 150px;
  display: block;
}

.curve-grid {
  fill: none;
  stroke: #e3ebf5;
  stroke-width: 1;
}

.curve-area {
  fill: rgba(29, 78, 216, 0.1);
}

.curve-line {
  fill: none;
  stroke: #1d4ed8;
  stroke-width: 4;
  stroke-linecap: round;
}

.curve-points circle {
  fill: #ffffff;
  stroke: #1d4ed8;
  stroke-width: 4;
}

.curve-labels text {
  fill: var(--muted);
  font-size: 13px;
  font-weight: 800;
  text-anchor: middle;
}

.quiz-feedback {
  min-height: 26px;
  color: var(--muted);
  line-height: 1.5;
}

.quiz-feedback.ok {
  color: var(--green);
  font-weight: 900;
}

.quiz-feedback.bad {
  color: var(--red);
  font-weight: 900;
}

.search-box {
  width: min(360px, 100%);
}

.letter-index {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(64px, 1fr));
  gap: 8px;
  margin-bottom: 14px;
}

.letter-button {
  min-height: 48px;
  padding: 7px 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--row-bg);
  color: var(--ink);
  font: inherit;
  cursor: pointer;
  box-shadow: 0 8px 18px rgba(20, 33, 61, 0.04);
}

.letter-button span,
.letter-button small {
  display: block;
}

.letter-button span {
  font-size: 0.86rem;
  font-weight: 950;
}

.letter-button small {
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 800;
}

.letter-button.active {
  border-color: rgba(37, 99, 235, 0.68);
  background: linear-gradient(180deg, #2563eb, #1d4ed8);
  color: #ffffff;
  box-shadow: 0 14px 26px rgba(37, 99, 235, 0.22);
}

.letter-button.active small {
  color: rgba(255, 255, 255, 0.76);
}

.letter-button:disabled {
  cursor: not-allowed;
  opacity: 0.34;
  box-shadow: none;
}

.library-summary {
  margin-bottom: 12px;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 850;
}

.library-results {
  display: grid;
  gap: 18px;
}

.letter-section {
  display: grid;
  gap: 10px;
}

.letter-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line);
}

.letter-heading h3 {
  color: var(--ink);
  font-size: 1.35rem;
  line-height: 1;
}

.letter-heading span {
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 850;
}

.library-list {
  display: grid;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-strong);
  box-shadow: 0 10px 24px rgba(20, 33, 61, 0.05);
}

.library-row {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) minmax(126px, auto);
  gap: 16px;
  align-items: center;
  min-width: 0;
  padding: 13px 16px;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: var(--row-bg);
  color: var(--ink);
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.library-row:last-child {
  border-bottom: 0;
}

.library-row:hover {
  background: var(--row-hover);
}

.library-word,
.library-state {
  min-width: 0;
}

.library-word strong {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 8px;
  color: var(--blue);
  font-size: 1.1rem;
  line-height: 1.15;
  overflow-wrap: anywhere;
}

.library-word strong small {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--chip-bg);
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 850;
}

.library-word p {
  margin-top: 5px;
  color: var(--ink);
  opacity: 0.9;
  font-size: 0.86rem;
  line-height: 1.48;
  overflow-wrap: anywhere;
}

.library-state > span:first-child {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--chip-bg);
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 850;
}

.library-state {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}

.library-empty {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-strong);
  color: var(--muted);
  font-weight: 850;
}

.table-wrap {
  width: 100%;
  max-width: 100%;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 860px;
  background: transparent;
}

th,
td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--surface-soft);
  color: var(--ink);
  font-size: 0.78rem;
}

td {
  color: var(--ink);
  opacity: 0.9;
  line-height: 1.5;
  font-size: 0.9rem;
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: break-word;
}

tr {
  transition: background-color 0.25s ease;
}

tr:hover {
  background: var(--surface-soft);
}

td.word-cell {
  color: var(--blue);
  font-weight: 900;
  font-size: 1rem;
}

.status-pill {
  display: inline-block;
  padding: 4px 8px;
  border-radius: 999px;
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 900;
}

.status-pill.mastered {
  background: var(--green-soft);
  color: var(--green);
}

.status-pill.review {
  background: var(--amber-soft);
  color: var(--amber);
}

.status-pill.learning {
  background: var(--blue-soft);
  color: var(--blue);
}

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

  .sidebar {
    position: static;
    height: auto;
  }

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

  .sidebar-note {
    display: none;
  }

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

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

  .today-overview-card,
  .overview-grid {
    grid-template-columns: 1fr;
  }

  .today-overview-card {
    grid-template-areas:
      "head"
      "progress"
      "reinforce";
  }

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

  .plan-grid.compact {
    grid-template-columns: repeat(9, minmax(34px, 1fr));
  }
}

@media (max-width: 720px) {
  body {
    background:
      linear-gradient(180deg, rgba(226, 238, 253, 0.98) 0, rgba(247, 249, 252, 0.96) 260px, #f7f9fc 100%),
      var(--bg);
  }

  [data-theme="dark"] body {
    background:
      linear-gradient(180deg, rgba(13, 17, 30, 0.98) 0, rgba(9, 13, 22, 0.96) 260px, rgba(9, 13, 22, 1) 100%),
      var(--bg);
  }

  .main {
    padding: 18px 14px;
  }

  .topbar,
  .panel-head {
    display: grid;
  }

  .top-actions,
  .day-picker,
  .button {
    width: 100%;
  }

  .top-actions {
    padding: 8px;
  }

  .day-picker + .day-picker {
    border-left: 0;
    border-top: 1px solid var(--line);
    padding-top: 8px;
  }

  .nav-list,
  .today-grid,
  .review-grid,
  .dashboard-grid,
  .word-card,
  .plan-grid {
    grid-template-columns: 1fr;
  }

  .panel,
  .dashboard-hero,
  .chart-panel,
  .dashboard-action {
    padding: 16px;
    box-shadow: 0 18px 36px rgba(20, 33, 61, 0.09);
  }

  .dashboard-hero,
  .dashboard-action {
    transform: none;
  }

  .dashboard-hero,
  .chart-panel {
    height: auto;
  }

  .distribution-list {
    align-content: start;
  }

  .overview-grid,
  .today-overview-card,
  .overview-head {
    grid-template-columns: 1fr;
  }

  .today-overview-card {
    grid-template-areas:
      "head"
      "progress"
      "reinforce";
  }

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

  .dashboard-actions {
    display: block;
  }

  .dashboard-actions .action-buttons {
    display: grid;
    grid-template-columns: 1fr;
  }

  .stat-card {
    padding: 12px 0 0;
    border-left: 0;
    border-top: 1px solid rgba(219, 228, 239, 0.82);
  }

  .stat-card:first-child {
    padding-top: 0;
    border-top: 0;
  }

  .dashboard-focus {
    grid-template-columns: 1fr;
  }

  .dashboard-focus {
    gap: 18px;
  }

  .task-ring {
    display: grid;
    grid-template-columns: 1fr;
    padding: 12px;
  }

  .task-count {
    margin-top: 6px;
  }

  .plan-grid.compact {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }

  .nav-item {
    justify-content: center;
  }

  .word-main {
    align-content: start;
  }

  .word-main h3 {
    font-size: clamp(2.2rem, 15vw, 3.8rem);
  }

  .card-actions .button {
    flex: 1 1 140px;
  }

  .word-row,
  .review-row {
    grid-template-columns: 1fr;
  }

  .library-row {
    grid-template-columns: 1fr;
    gap: 10px;
    align-items: start;
  }

  .library-state {
    justify-content: flex-start;
  }

  .word-row button,
  .review-row button {
    width: 100%;
  }

  .table-wrap {
    overflow: visible;
    border: 0;
    background: transparent;
  }

  table,
  tbody,
  tr,
  td {
    display: block;
    width: 100%;
    min-width: 0;
  }

  thead {
    display: none;
  }

  tbody {
    display: grid;
    gap: 12px;
  }

  tr {
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.04);
  }

  td {
    display: grid;
    grid-template-columns: 58px minmax(0, 1fr);
    gap: 10px;
    padding: 7px 0;
    border-bottom: 0;
  }

  td::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: 0.76rem;
    font-weight: 900;
  }

  td.word-cell {
    font-size: 1.08rem;
  }

}

/* --- THEME TOGGLE BUTTON STYLING --- */
.sidebar-theme-toggle {
  margin: 10px 0;
  padding: 0 4px;
}

.btn-theme-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  color: #cbd7e8;
  cursor: pointer;
  font-size: 0.88rem;
  font-weight: 700;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.btn-theme-toggle:hover {
  background: rgba(255, 255, 255, 0.14);
  color: #ffffff;
  border-color: rgba(255, 255, 255, 0.25);
  transform: translateY(-1px);
}

.btn-theme-toggle:active {
  transform: translateY(0);
}

[data-theme="dark"] .btn-theme-toggle {
  background: rgba(0, 0, 0, 0.2);
  border-color: rgba(255, 255, 255, 0.08);
}
