:root {
  color-scheme: light;
  --bg: #f5f7fb;
  --panel: #ffffff;
  --text: #172033;
  --muted: #687386;
  --line: #dfe7f3;
  --primary: #2563eb;
  --primary-strong: #1d4ed8;
  --primary-soft: #eaf1ff;
  --accent: #7c9cff;
  --danger: #c2413a;
  --ok: #1d7a46;
  --shadow: 0 18px 48px rgba(32, 72, 140, 0.1);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Microsoft YaHei", "Segoe UI", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}

button,
input,
select {
  font: inherit;
}

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

.sidebar {
  background: linear-gradient(180deg, #f8fbff 0%, #eef5ff 100%);
  border-right: 1px solid var(--line);
  color: var(--text);
  padding: 28px 22px;
}

.brand {
  display: flex;
  gap: 14px;
  align-items: center;
  margin-bottom: 34px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border-radius: 8px;
  background: #dbe8ff;
  color: var(--primary);
  font-size: 24px;
  font-weight: 800;
}

.brand h1,
.brand p {
  margin: 0;
}

.brand h1 {
  font-size: 20px;
  white-space: nowrap;
}

.brand p {
  margin-top: 5px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.2;
  white-space: nowrap;
}

nav {
  display: grid;
  gap: 10px;
}

.nav-btn {
  border: 1px solid transparent;
  background: transparent;
  color: #42526b;
  padding: 12px 14px;
  border-radius: 8px;
  text-align: left;
  cursor: pointer;
}

.nav-btn.active,
.nav-btn:hover:not(:disabled) {
  background: #ffffff;
  border-color: #d7e4f8;
  box-shadow: 0 8px 24px rgba(37, 99, 235, 0.1);
  color: var(--primary);
}

.nav-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.main {
  padding: 36px;
  max-width: none;
  width: 100%;
}

.workspace-panel {
  background: linear-gradient(135deg, #ffffff 0%, #f3f7ff 100%);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  width: 100%;
  min-height: 430px;
  padding: 56px;
  display: grid;
  align-content: center;
}

.workspace-panel h2 {
  margin: 0 0 10px;
  font-size: 48px;
  line-height: 1.12;
  letter-spacing: 0;
}

.workspace-panel p {
  margin: 0;
  max-width: 680px;
  color: var(--muted);
  font-size: 17px;
  line-height: 1.7;
}

.workspace-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 28px;
  color: var(--muted);
}

.workspace-meta span {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0 16px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid var(--line);
}

.workspace-meta strong {
  color: var(--primary);
  font-size: 22px;
}

.workspace-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 32px;
}

.import-note {
  display: grid;
  gap: 6px;
  margin-bottom: 16px;
  padding: 14px 16px;
  border: 1px solid #cfe0ff;
  border-radius: 8px;
  color: var(--muted);
  background: #f8fbff;
}

.import-note strong {
  color: var(--text);
}

.view {
  display: none;
}

.view.active {
  display: block;
}

#home.view.active {
  min-height: auto;
  display: grid;
  align-items: start;
}

.page-head {
  margin-bottom: 22px;
}

.page-head h2,
.quiz-top h2 {
  margin: 0;
  font-size: 28px;
}

.page-head p,
.muted,
.meta-text {
  color: var(--muted);
}

.panel,
.stat-card,
.question-panel,
.template-box {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 20px;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(150px, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}

.stat-card span {
  color: var(--muted);
  display: block;
  margin-bottom: 8px;
}

.stat-card strong {
  font-size: 30px;
}

.template-box h3,
.panel h3 {
  margin-top: 0;
}

.file-picker {
  display: grid;
  gap: 8px;
  padding: 18px;
  border: 1px dashed #9db2ae;
  border-radius: 8px;
  cursor: pointer;
}

.file-picker input {
  display: none;
}

.file-picker span {
  color: var(--muted);
}

.primary-btn,
.ghost-btn {
  min-height: 42px;
  border-radius: 8px;
  padding: 0 16px;
  border: 1px solid transparent;
  cursor: pointer;
}

.primary-btn {
  background: var(--primary);
  color: #fff;
  margin-top: 14px;
}

.primary-btn:hover {
  background: var(--primary-strong);
}

.ghost-btn {
  background: #fff;
  color: var(--text);
  border-color: var(--line);
}

.message {
  margin-top: 12px;
  color: var(--muted);
  min-height: 24px;
}

.message.error {
  color: var(--danger);
}

.message.ok {
  color: var(--ok);
}

.error-list {
  margin: 10px 0 0;
  padding-left: 20px;
  color: var(--danger);
  line-height: 1.7;
}

.section-title,
.quiz-top,
.result-actions,
.quiz-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

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

.bank-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}

.bank-item:last-child {
  border-bottom: 0;
}

.setup-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(160px, 1fr));
  gap: 18px;
}

label {
  display: grid;
  gap: 8px;
}

label span,
.check-group > span {
  color: var(--muted);
  font-size: 14px;
}

input,
select {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  background: #fff;
  color: var(--text);
}

.check-group,
.wide {
  grid-column: 1 / -1;
}

.count-box {
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fbff;
  color: var(--muted);
}

.count-box strong {
  color: var(--primary);
  font-size: 20px;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  min-height: 42px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.question-panel {
  margin-top: 18px;
}

.type-tag {
  display: inline-block;
  padding: 5px 10px;
  border-radius: 8px;
  background: #eaf1ff;
  color: var(--primary);
  font-weight: 700;
}

#questionStem {
  font-size: 22px;
  line-height: 1.55;
}

.options {
  display: grid;
  gap: 10px;
  margin: 18px 0;
}

.option {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.option input {
  min-height: auto;
  margin-top: 4px;
}

.feedback {
  margin-top: 16px;
  padding: 14px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #f8fbfa;
}

.feedback.correct {
  border-color: #a8d4b9;
  color: var(--ok);
}

.feedback.wrong {
  border-color: #e3aaa6;
  color: var(--danger);
}

.hidden {
  display: none;
}

.wrong-list,
.history-list {
  display: grid;
  gap: 14px;
}

.wrong-item,
.history-item {
  border-bottom: 1px solid var(--line);
  padding-bottom: 14px;
}

.wrong-item:last-child,
.history-item:last-child {
  border-bottom: 0;
}

.wrong-item h4,
.history-item h4 {
  margin: 0 0 8px;
  line-height: 1.45;
}

.plan-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #fff;
}

.plan-item summary {
  cursor: pointer;
  font-weight: 700;
  line-height: 1.5;
}

.small-batches {
  margin-top: 14px;
  display: grid;
  gap: 12px;
}

.retry-title {
  margin-top: 24px;
}

.history-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  color: var(--muted);
  margin-bottom: 10px;
}

.segmented {
  display: flex;
  gap: 8px;
}

.active-filter {
  border-color: var(--primary);
  color: var(--primary);
}

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

  .sidebar {
    padding: 18px;
  }

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

  .nav-btn {
    text-align: center;
    padding: 10px 8px;
  }

  .main {
    padding: 20px;
  }

  .stats-grid,
  .setup-grid {
    grid-template-columns: 1fr;
  }

  .workspace-panel {
    padding: 24px;
    min-height: 360px;
    width: 100%;
  }

  .workspace-panel h2 {
    font-size: 30px;
  }

  .quiz-top,
  .quiz-actions,
  .result-actions {
    align-items: stretch;
    flex-direction: column;
  }
}
