:root {
  color-scheme: dark;
  --bg: #06100d;
  --surface: #0d1b18;
  --surface-2: #122622;
  --ink: #e6fff6;
  --muted: #86a79c;
  --line: #21443c;
  --accent: #39ffb6;
  --accent-2: #57a7ff;
  --bad: #ff6b6b;
  --ok: #35d07f;
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.35);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(rgba(57, 255, 182, 0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(57, 255, 182, 0.04) 1px, transparent 1px),
    var(--bg);
  background-size: 28px 28px;
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

button,
input,
select,
textarea {
  font: inherit;
}

button,
.file-btn {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(13, 27, 24, 0.92);
  color: var(--ink);
  padding: 0 14px;
  cursor: pointer;
}

button:hover,
.file-btn:hover {
  border-color: var(--accent);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #03100c;
  font-weight: 750;
}

.danger {
  color: var(--bad);
}

.ghost {
  background: transparent;
}

.hidden {
  display: none !important;
}

.full {
  width: 100%;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 30px;
  line-height: 1.2;
}

h2 {
  font-size: 19px;
}

.eyebrow {
  color: var(--accent);
  font-size: 12px;
  letter-spacing: 0;
  margin-bottom: 6px;
  text-transform: uppercase;
}

.muted-text,
small {
  color: var(--muted);
}

.login-screen {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(280px, 1fr) minmax(300px, 430px);
  gap: 36px;
  align-items: center;
  width: min(1120px, calc(100% - 32px));
  margin: 0 auto;
}

.login-panel,
.panel,
.practice {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(13, 27, 24, 0.86);
  box-shadow: var(--shadow);
}

.login-panel {
  display: grid;
  gap: 16px;
  padding: 24px;
}

.radio-art {
  position: relative;
  min-height: 420px;
  border: 1px solid rgba(57, 255, 182, 0.35);
  border-radius: 8px;
  overflow: hidden;
  background: radial-gradient(circle at 50% 60%, rgba(57, 255, 182, 0.12), transparent 42%);
}

.mast {
  position: absolute;
  left: 50%;
  bottom: 64px;
  width: 2px;
  height: 250px;
  background: var(--accent);
  transform: translateX(-50%);
  box-shadow: 0 0 18px rgba(57, 255, 182, 0.8);
}

.dish {
  position: absolute;
  left: 50%;
  bottom: 52px;
  width: 168px;
  height: 54px;
  border: 2px solid var(--accent);
  border-top: 0;
  border-radius: 0 0 168px 168px;
  transform: translateX(-50%);
}

.wave {
  position: absolute;
  left: 50%;
  bottom: 188px;
  border: 1px solid rgba(57, 255, 182, 0.7);
  border-bottom: 0;
  border-radius: 260px 260px 0 0;
  transform: translateX(-50%);
}

.wave-a {
  width: 140px;
  height: 70px;
}

.wave-b {
  width: 250px;
  height: 125px;
  opacity: 0.65;
}

.wave-c {
  width: 380px;
  height: 190px;
  opacity: 0.4;
}

.scanline {
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(180deg, transparent 0 8px, rgba(57, 255, 182, 0.05) 8px 10px);
}

.error-line {
  min-height: 20px;
  color: var(--bad);
}

.app-shell,
.practice-shell {
  width: min(1220px, calc(100% - 32px));
  margin: 0 auto;
  padding: 24px 0 32px;
}

.topbar,
.toolbar,
.practice-topbar,
.practice-head,
.actions {
  display: flex;
  align-items: center;
}

.topbar,
.practice-topbar {
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.toolbar {
  gap: 8px;
  flex-wrap: wrap;
}

.file-btn {
  display: inline-flex;
  align-items: center;
}

.file-btn input {
  display: none;
}

.metrics {
  display: grid;
  grid-template-columns: 72px repeat(5, minmax(120px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.metrics div {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(13, 27, 24, 0.76);
  padding: 16px;
}

.metrics .metrics-row-label {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent);
  font-weight: 800;
}

.metrics span {
  display: block;
  font-size: 28px;
  font-weight: 800;
}

.overview-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(13, 27, 24, 0.76);
  padding: 18px;
  margin-bottom: 16px;
}

.overview-head,
.panel-title-row,
.progress-legend {
  display: flex;
  align-items: center;
}

.overview-head,
.panel-title-row {
  justify-content: space-between;
  gap: 16px;
}

.overview-head {
  margin-bottom: 14px;
}

.overview-head strong {
  color: var(--accent);
  font-size: 34px;
  line-height: 1;
}

.progress-track {
  position: relative;
  height: 10px;
  background: var(--surface-2);
  border-radius: 999px;
  overflow: hidden;
}

.progress-track.large {
  height: 16px;
}

.progress-track.slim {
  height: 6px;
}

.progress-track span {
  position: absolute;
  inset: 0 auto 0 0;
  display: block;
  border-radius: inherit;
}

.progress-reviewed {
  background: rgba(87, 167, 255, 0.78);
}

.progress-mastered {
  background: var(--accent);
}

.progress-legend {
  gap: 18px;
  flex-wrap: wrap;
  margin-top: 12px;
  color: var(--muted);
  font-size: 13px;
}

.legend-action {
  display: inline-flex;
  align-items: center;
  min-height: 0;
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 0;
}

.legend-action:hover {
  color: var(--ink);
}

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

.legend-dot.reviewed {
  background: var(--accent-2);
}

.legend-dot.mastered {
  background: var(--accent);
}

.home-grid {
  display: grid;
  grid-template-columns: 360px minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.panel {
  padding: 16px;
}

.panel h2 {
  margin-bottom: 14px;
}

.strategy-grid,
.mode-grid {
  display: grid;
  gap: 8px;
  margin-bottom: 14px;
}

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

.mode-grid {
  grid-template-columns: repeat(3, 1fr);
}

.mode.active,
.strategy.active {
  border-color: var(--accent-2);
  background: rgba(87, 167, 255, 0.18);
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 12px;
}

input,
select,
textarea {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #071411;
  color: var(--ink);
  padding: 0 12px;
}

textarea {
  min-height: 132px;
  padding: 12px;
  line-height: 1.5;
  resize: vertical;
}

.compact-list {
  max-height: 520px;
  overflow: auto;
}

.mini-legend {
  color: var(--muted);
  font-size: 12px;
}

.chapter-row {
  display: grid;
  grid-template-columns: 96px minmax(0, 1fr) 96px;
  gap: 12px;
  align-items: center;
  padding: 12px 0;
  border-top: 1px solid var(--line);
  font-size: 13px;
}

.chapter-row small,
.chapter-stats {
  color: var(--muted);
}

.chapter-row small,
.chapter-stats span {
  display: block;
}

.chapter-bars {
  display: grid;
  gap: 6px;
}

.chapter-stats {
  text-align: right;
}

.practice-shell {
  max-width: 980px;
}

.practice {
  min-height: 620px;
  padding: 22px;
}

.practice-head {
  justify-content: space-between;
  gap: 16px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
}

.question-line {
  display: grid;
  gap: 10px;
}

.type-badge {
  width: fit-content;
  border: 1px solid var(--accent);
  border-radius: 999px;
  color: var(--accent);
  padding: 4px 10px;
  font-size: 12px;
}

#questionTitle {
  font-size: 24px;
  line-height: 1.5;
  white-space: pre-wrap;
}

.queue-count {
  min-width: 74px;
  text-align: right;
  color: var(--muted);
}

.answers {
  display: grid;
  gap: 10px;
  margin: 20px 0;
}

.answer {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  gap: 12px;
  align-items: start;
  width: 100%;
  min-height: 58px;
  padding: 14px;
  text-align: left;
  border-radius: 8px;
}

.answer .key {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--surface-2);
  color: var(--accent);
  font-weight: 800;
}

.answer.selected {
  border-color: var(--accent-2);
  background: rgba(87, 167, 255, 0.16);
}

.answer.correct {
  border-color: var(--ok);
  background: rgba(53, 208, 127, 0.14);
}

.answer.incorrect {
  border-color: var(--bad);
  background: rgba(255, 107, 107, 0.12);
}

.result {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  margin-bottom: 16px;
  background: var(--surface-2);
}

.actions {
  gap: 10px;
  flex-wrap: wrap;
}

.actions button {
  min-width: 96px;
}

.modal {
  width: min(560px, calc(100% - 28px));
  border: 0;
  border-radius: 8px;
  padding: 0;
  color: var(--ink);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.modal::backdrop {
  background: rgba(0, 0, 0, 0.58);
}

.modal-card {
  display: grid;
  gap: 16px;
  padding: 18px;
}

.modal-card label {
  margin: 0;
}

.modal-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  flex-wrap: wrap;
}

@media (max-width: 860px) {
  .login-screen,
  .home-grid {
    grid-template-columns: 1fr;
  }

  .login-screen {
    padding: 18px 0;
  }

  .radio-art {
    min-height: 280px;
  }

  .app-shell,
  .practice-shell {
    width: min(100% - 20px, 720px);
    padding-top: 14px;
  }

  .topbar,
  .practice-topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .toolbar {
    width: 100%;
  }

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

  .metrics .metrics-row-label {
    grid-column: 1 / -1;
    min-height: 36px;
    padding: 8px 12px;
    justify-content: flex-start;
  }

  .overview-head,
  .panel-title-row {
    align-items: flex-start;
    flex-direction: column;
    gap: 8px;
  }

  .overview-head strong {
    font-size: 28px;
  }

  .chapter-row {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .chapter-stats {
    display: flex;
    gap: 14px;
    text-align: left;
  }

  .toolbar button,
  .toolbar .file-btn,
  .actions button,
  .modal-actions button {
    flex: 1 1 auto;
    justify-content: center;
  }

  .practice {
    min-height: 520px;
    padding: 16px;
  }

  .practice-head {
    align-items: flex-start;
  }

  #questionTitle {
    font-size: 20px;
  }
}
