:root {
  --bg: #f5efe5;
  --bg-strong: #fffaf2;
  --panel: rgba(255, 250, 242, 0.9);
  --panel-strong: #fffdf8;
  --line: rgba(64, 48, 27, 0.12);
  --line-strong: rgba(19, 91, 104, 0.22);
  --text: #2c241a;
  --muted: #6c604f;
  --brand: #135b68;
  --brand-strong: #0c4650;
  --brand-soft: #dceff2;
  --accent: #d18937;
  --danger: #a84536;
  --success: #2b7a55;
  --shadow: 0 20px 48px rgba(78, 56, 28, 0.12);
  --radius: 28px;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  font-family: "Microsoft YaHei", "PingFang SC", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(19, 91, 104, 0.14), transparent 30%),
    radial-gradient(circle at bottom right, rgba(209, 137, 55, 0.2), transparent 24%),
    linear-gradient(180deg, #fbf6ee 0%, var(--bg) 100%);
}

button,
select,
input {
  font: inherit;
}

button {
  border: 1px solid transparent;
  border-radius: 16px;
  padding: 11px 16px;
  background: linear-gradient(135deg, var(--brand), var(--brand-strong));
  color: #fff;
  cursor: pointer;
  transition: transform 0.16s ease, box-shadow 0.16s ease, border-color 0.16s ease;
}

button:hover:not(:disabled),
select:hover,
input:hover {
  transform: translateY(-1px);
  box-shadow: 0 12px 22px rgba(44, 32, 17, 0.1);
}

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

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

button.is-active {
  background: linear-gradient(135deg, var(--brand), #1d7382);
  color: #fff;
}

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

button.tiny {
  padding: 8px 12px;
  font-size: 13px;
}

select,
input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 12px 14px;
  background: #fffdf9;
  color: var(--text);
  outline: none;
}

select:focus,
input:focus {
  border-color: var(--line-strong);
  box-shadow: 0 0 0 4px rgba(19, 91, 104, 0.1);
}

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

.app-shell.is-home {
  grid-template-columns: minmax(0, 1fr);
  max-width: 1180px;
  margin: 0 auto;
}

.sidebar,
.topbar,
.progress-panel,
.card {
  backdrop-filter: blur(14px);
}

.sidebar,
.topbar,
.progress-panel,
.card,
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.sidebar {
  border-radius: 32px;
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

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

.brand-mark {
  width: 52px;
  height: 52px;
  border-radius: 18px;
  background: linear-gradient(135deg, var(--brand), #207888);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
  font-weight: 700;
  box-shadow: 0 14px 26px rgba(19, 91, 104, 0.22);
}

.brand-copy h1,
.topbar h2,
.question-body h3,
.hero-panel h2 {
  margin: 0;
  font-family: "Georgia", "STKaiti", serif;
  letter-spacing: 0.02em;
}

.eyebrow {
  margin: 0 0 8px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--brand);
}

.brand-copy h1 {
  font-size: 30px;
}

.main {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.panel,
.topbar,
.progress-panel,
.card {
  border-radius: var(--radius);
}

.panel {
  padding: 16px;
}

.panel h2 {
  margin: 0 0 10px;
  font-size: 15px;
}

.filter-list,
.answer-actions,
.topbar-actions,
.pill-row,
.nav-footer {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

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

.stats .stat-grid div {
  background: var(--panel-strong);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 12px;
}

.stats span {
  display: block;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 8px;
}

.stats strong {
  font-size: 24px;
}

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

.topbar-copy {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.topbar-copy p {
  margin: 0;
}

#feedbackText,
.knowledge-point,
.source-panel,
.topic-source,
.topic-picker-header p {
  color: var(--muted);
}

.progress-panel {
  padding: 18px 22px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.progress-copy {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 14px;
}

.progress-bar {
  width: 100%;
  height: 12px;
  background: #e8decf;
  border-radius: 999px;
  overflow: hidden;
}

#progressBarFill {
  width: 0;
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--brand));
  transition: width 0.2s ease;
}

.card {
  min-height: 620px;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.app-shell.is-home .card {
  min-height: calc(100vh - 48px);
  justify-content: center;
  padding: 36px;
}

.card-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.pill {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 8px 12px;
  background: var(--brand-soft);
  color: var(--brand);
  font-size: 12px;
  font-weight: 700;
}

.pill.soft {
  background: #fff2dc;
  color: #8d5c18;
}

.question-body {
  display: flex;
  flex-direction: column;
  gap: 14px;
  flex: 1;
}

.question-body h3 {
  font-size: 30px;
  line-height: 1.5;
}

.knowledge-point {
  margin: 0;
  font-size: 14px;
}

.options {
  display: grid;
  gap: 12px;
}

.option {
  width: 100%;
  text-align: left;
  background: var(--panel-strong);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 14px 16px;
  display: flex;
  gap: 12px;
  align-items: flex-start;
}

.option-key {
  width: 32px;
  height: 32px;
  border-radius: 999px;
  background: #efe3d0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  flex-shrink: 0;
}

.option.selected {
  border-color: var(--brand);
  box-shadow: 0 0 0 4px rgba(19, 91, 104, 0.1);
}

.option.correct {
  background: #e9f7ee;
  border-color: rgba(43, 122, 85, 0.36);
}

.option.wrong {
  background: #ffe9e3;
  border-color: rgba(168, 69, 54, 0.35);
}

.answer-panel {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.answer-result {
  margin: 0;
  font-size: 15px;
}

.answer-result.success {
  color: var(--success);
}

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

.source-panel {
  border-top: 1px dashed var(--line);
  padding-top: 14px;
  font-size: 13px;
  line-height: 1.7;
}

.reference-panel {
  white-space: pre-wrap;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: #fff8ee;
  padding: 18px;
  line-height: 1.75;
  color: var(--muted);
}

.reference-panel strong {
  color: var(--text);
}

.nav-footer {
  justify-content: flex-end;
}

.home-chooser,
.topic-picker {
  width: 100%;
}

.hero-panel {
  max-width: 980px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.hero-panel h2 {
  font-size: clamp(38px, 5vw, 62px);
  line-height: 1.08;
}

.hero-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.hero-badges span {
  display: inline-flex;
  align-items: center;
  padding: 9px 14px;
  border-radius: 999px;
  background: rgba(255, 248, 236, 0.88);
  border: 1px solid var(--line);
  color: var(--muted);
}

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

.mode-card,
.topic-card {
  background: var(--panel-strong);
  border: 1px solid var(--line);
  border-radius: 24px;
  padding: 20px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.6);
}

.mode-card {
  display: flex;
  flex-direction: column;
  gap: 20px;
  min-height: 220px;
  justify-content: space-between;
}

.mode-card-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

.mode-card h3,
.topic-picker-header h3,
.topic-card h4 {
  margin: 0;
}

.mode-card h3 {
  font-size: 28px;
  font-family: "Georgia", "STKaiti", serif;
}

.mode-card strong {
  font-size: 42px;
  line-height: 1;
  color: var(--brand);
}

.mode-card button {
  align-self: flex-start;
  min-width: 144px;
}

.topic-picker-shell {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.topic-picker-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}

.topic-picker-header p {
  margin: 6px 0 0;
}

.topic-search {
  max-width: 320px;
}

.topic-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 14px;
}

.topic-card {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.topic-card-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

.topic-card-head h4 {
  font-size: 18px;
  line-height: 1.55;
}

.topic-card-head span {
  display: inline-flex;
  flex-shrink: 0;
  padding: 6px 10px;
  border-radius: 999px;
  background: var(--brand-soft);
  color: var(--brand);
  font-size: 12px;
  font-weight: 700;
}

.topic-source {
  margin: 0;
  font-size: 13px;
}

.topic-tag-row {
  margin: 0;
  font-size: 13px;
  color: var(--brand);
  font-weight: 700;
}

.topic-card button {
  align-self: flex-start;
}

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

  .sidebar {
    order: 2;
  }

  .main {
    order: 1;
  }

  .card,
  .app-shell.is-home .card {
    min-height: auto;
    padding: 18px;
  }

  .topbar,
  .answer-panel,
  .progress-copy,
  .topic-picker-header,
  .card-head {
    flex-direction: column;
    align-items: stretch;
  }

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

  .question-body h3 {
    font-size: 24px;
  }
}
