:root {
  --bg: #f6f8fb;
  --panel: #ffffff;
  --panel-strong: #f1f5f9;
  --ink: #172033;
  --muted: #64748b;
  --line: #dce3ec;
  --blue: #2563eb;
  --blue-soft: #dbeafe;
  --green: #16803c;
  --green-soft: #dcfce7;
  --yellow: #b7791f;
  --yellow-soft: #fef3c7;
  --red: #c2410c;
  --red-soft: #ffedd5;
  --teal: #0f766e;
  --shadow: 0 16px 40px rgba(15, 23, 42, 0.09);
  color-scheme: light;
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

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

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

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

.brand-mark {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border-radius: 8px;
  background: #ffffff;
  color: #0f172a;
  font-size: 24px;
  font-weight: 800;
}

.brand h1 {
  margin: 0;
  font-size: 20px;
  line-height: 1.2;
}

.brand p,
.date-line,
.metric p,
.countdown span,
.card-kicker {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.brand p {
  color: #cbd5e1;
}

.nav-tabs {
  display: grid;
  gap: 8px;
}

.nav-tab {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  border: 0;
  border-radius: 8px;
  padding: 0 12px;
  background: transparent;
  color: #cbd5e1;
  text-align: left;
}

.nav-tab:hover,
.nav-tab.is-active {
  background: #1e293b;
  color: #ffffff;
}

.tab-icon {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.08);
  font-size: 13px;
  font-weight: 700;
}

.side-panel {
  margin-top: auto;
  display: grid;
  gap: 14px;
}

.countdown {
  padding: 14px;
  border-radius: 8px;
  background: #ffffff;
  color: var(--ink);
}

.countdown strong {
  display: block;
  margin-top: 4px;
  font-size: 32px;
  line-height: 1;
}

.legend {
  display: flex;
  justify-content: space-between;
  color: #cbd5e1;
  font-size: 13px;
}

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

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

.yellow {
  background: var(--yellow);
}

.red {
  background: var(--red);
}

.main {
  min-width: 0;
  padding: 28px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: center;
  margin-bottom: 22px;
}

.topbar h2 {
  margin: 4px 0 0;
  font-size: 28px;
  line-height: 1.2;
}

.top-actions {
  display: flex;
  gap: 10px;
}

.icon-button {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--ink);
}

.icon-button:hover {
  border-color: var(--blue);
  color: var(--blue);
}

.icon-button svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.file-button input {
  display: none;
}

.view {
  display: none;
}

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

.summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.metric,
.task-panel,
.flashcard,
.quiz-item,
.word-item,
.special-item,
.red-item,
.notebook-side {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 1px 0 rgba(15, 23, 42, 0.03);
}

.metric {
  padding: 18px;
}

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

.metric strong {
  display: block;
  margin: 6px 0 4px;
  font-size: 32px;
  line-height: 1;
}

.metric-primary {
  color: #ffffff;
  background: #1d4ed8;
  border-color: #1d4ed8;
}

.metric-primary span,
.metric-primary p {
  color: #dbeafe;
}

.workbench {
  display: grid;
  grid-template-columns: 0.9fr 1.4fr;
  gap: 18px;
}

.task-panel {
  min-width: 0;
  padding: 18px;
}

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

.section-head h3,
.notebook-side h4 {
  margin: 0;
  font-size: 18px;
}

.small-button,
.reveal-button,
.mark-btn {
  border: 0;
  border-radius: 8px;
  padding: 10px 14px;
  background: var(--blue);
  color: #ffffff;
  font-weight: 700;
}

.small-button:hover,
.reveal-button:hover {
  filter: brightness(0.96);
}

.small-button.danger {
  background: var(--red);
}

.routine-list {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.routine-list li {
  display: grid;
  grid-template-columns: 54px 1fr;
  gap: 10px;
  align-items: center;
  padding: 10px;
  border-radius: 8px;
  background: var(--panel-strong);
}

.routine-list span {
  display: grid;
  place-items: center;
  height: 34px;
  border-radius: 7px;
  background: #e2e8f0;
  color: #334155;
  font-size: 13px;
  font-weight: 800;
}

.routine-list p,
.notebook-side p {
  margin: 0;
  color: #334155;
  line-height: 1.55;
}

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

.word-chip {
  min-width: 46px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  background: #ffffff;
  color: var(--ink);
  text-align: center;
}

.word-chip[data-status="green"] {
  background: var(--green-soft);
  border-color: #86efac;
}

.word-chip[data-status="yellow"] {
  background: var(--yellow-soft);
  border-color: #fcd34d;
}

.word-chip[data-status="red"] {
  background: var(--red-soft);
  border-color: #fdba74;
}

.status-mini {
  display: flex;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
}

.toolbar {
  display: flex;
  align-items: end;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}

.toolbar label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
}

.toolbar select,
.toolbar input {
  height: 42px;
  min-width: 150px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  background: #ffffff;
  color: var(--ink);
}

.toolbar-wide input {
  min-width: min(420px, 62vw);
}

.flashcard {
  min-height: 420px;
  padding: 28px;
  display: grid;
  justify-items: center;
  align-content: center;
  text-align: center;
}

.card-word {
  margin: 18px 0 24px;
  font-size: clamp(72px, 12vw, 132px);
  font-weight: 800;
  line-height: 1;
}

.card-answer {
  width: min(760px, 100%);
  margin: 4px auto 24px;
  text-align: left;
  color: #263244;
  line-height: 1.7;
}

.sense-row {
  padding: 10px 0;
  border-top: 1px solid var(--line);
}

.sense-row:first-child {
  border-top: 0;
}

.sense-meaning {
  font-weight: 800;
}

.sense-example {
  color: var(--muted);
  font-size: 14px;
}

.mark-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
}

.mark-btn {
  min-width: 86px;
}

.mark-btn.green {
  background: var(--green);
}

.mark-btn.yellow {
  background: var(--yellow);
}

.mark-btn.red {
  background: var(--red);
}

.quiz-list,
.word-list,
.special-list,
.red-list {
  display: grid;
  gap: 10px;
}

.quiz-item,
.word-item,
.special-item,
.red-item {
  padding: 14px;
}

.quiz-question,
.word-main,
.special-main {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
}

.word-title,
.special-title {
  display: flex;
  align-items: baseline;
  gap: 10px;
}

.word-title strong,
.special-title strong {
  font-size: 26px;
}

.tag {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  padding: 0 9px;
  background: var(--panel-strong);
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.quiz-answer,
.word-details {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.answer-actions,
.item-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.mini-mark,
.ghost-button {
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 10px;
  background: #ffffff;
  color: var(--ink);
  font-weight: 700;
}

.mini-mark:hover,
.ghost-button:hover {
  border-color: var(--blue);
}

.mini-mark[data-mark="green"] {
  color: var(--green);
}

.mini-mark[data-mark="yellow"] {
  color: var(--yellow);
}

.mini-mark[data-mark="red"] {
  color: var(--red);
}

.notebook-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 280px;
  gap: 18px;
}

.notebook-side {
  padding: 16px;
  align-self: start;
}

.notebook-side h4 + p {
  margin-top: 8px;
}

.notebook-side p + h4 {
  margin-top: 18px;
}

.empty {
  padding: 26px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  text-align: center;
}

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  max-width: 320px;
  padding: 12px 14px;
  border-radius: 8px;
  background: #0f172a;
  color: #ffffff;
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(10px);
  pointer-events: none;
  transition: opacity 160ms ease, transform 160ms ease;
}

.toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

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

  .sidebar {
    position: static;
    height: auto;
    padding: 18px;
  }

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

  .side-panel {
    margin-top: 0;
  }

  .summary-grid,
  .workbench,
  .notebook-layout {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .main {
    padding: 18px;
  }

  .topbar,
  .quiz-question,
  .word-main,
  .special-main {
    align-items: stretch;
    flex-direction: column;
  }

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

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

  .toolbar,
  .mark-row,
  .answer-actions,
  .item-actions {
    align-items: stretch;
  }

  .toolbar label,
  .toolbar select,
  .toolbar input,
  .small-button,
  .mark-btn,
  .ghost-button,
  .mini-mark {
    width: 100%;
  }

  .flashcard {
    min-height: 360px;
    padding: 22px 16px;
  }
}
