:root {
  color-scheme: light;
  --bg: #f4f6f2;
  --surface: #ffffff;
  --surface-muted: #eef2ed;
  --text: #17201d;
  --text-muted: #5f6b66;
  --border: #d9dfd8;
  --primary: #0f766e;
  --primary-strong: #0b5f58;
  --primary-soft: #d8f3ef;
  --accent: #b45309;
  --accent-soft: #fff1d6;
  --danger: #b42318;
  --danger-soft: #fde8e5;
  --success: #1d7f44;
  --success-soft: #e2f5e9;
  --shadow: 0 18px 40px rgba(23, 32, 29, 0.1);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  min-width: 320px;
}

body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font-family: "Microsoft YaHei", "PingFang SC", "Noto Sans CJK SC", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 16px;
  line-height: 1.6;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
}

:focus-visible {
  outline: 3px solid rgba(15, 118, 110, 0.35);
  outline-offset: 2px;
}

.skip-link {
  position: fixed;
  left: 16px;
  top: 12px;
  z-index: 20;
  transform: translateY(-160%);
  background: var(--text);
  color: white;
  padding: 8px 12px;
  border-radius: 6px;
}

.skip-link:focus {
  transform: translateY(0);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 18px clamp(16px, 3vw, 32px);
  background: rgba(244, 246, 242, 0.94);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(12px);
}

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

.brand-mark {
  display: grid;
  width: 46px;
  height: 46px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: var(--radius);
  background: var(--primary);
  color: white;
}

.brand-mark svg {
  width: 25px;
  height: 25px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.brand h1 {
  margin: 0;
  font-size: clamp(20px, 2.5vw, 28px);
  line-height: 1.2;
  letter-spacing: 0;
}

.brand p {
  margin: 3px 0 0;
  color: var(--text-muted);
  font-size: 14px;
}

.top-actions,
.bottom-actions,
.answer-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.layout {
  display: grid;
  grid-template-columns: minmax(280px, 340px) minmax(0, 1fr);
  gap: 20px;
  width: min(1460px, 100%);
  margin: 0 auto;
  padding: 20px clamp(16px, 3vw, 32px) 32px;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-width: 0;
}

.panel,
.question-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.controls-panel,
.list-panel {
  padding: 16px;
}

.field-label {
  display: block;
  margin-bottom: 8px;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 700;
}

.field-group {
  margin-top: 14px;
}

.search-input,
.select-input {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: white;
  color: var(--text);
  padding: 9px 12px;
}

.search-input::placeholder {
  color: #7a847f;
}

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

.segment {
  min-height: 44px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface-muted);
  color: var(--text);
  font-weight: 700;
  transition: background 180ms ease, border-color 180ms ease, color 180ms ease, transform 180ms ease;
}

.segment:hover,
.segment.is-active {
  border-color: var(--primary);
  background: var(--primary-soft);
  color: var(--primary-strong);
}

.segment:active {
  transform: scale(0.98);
}

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

.stat {
  min-height: 78px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.stat-label {
  display: block;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 700;
}

.stat strong {
  display: block;
  margin-top: 4px;
  font-size: 25px;
  line-height: 1.2;
}

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

.panel-heading h2 {
  margin: 0;
  font-size: 16px;
}

.panel-heading span {
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 700;
}

.question-list {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
  max-height: 360px;
  overflow: auto;
  padding-right: 2px;
}

.question-pill {
  min-width: 0;
  min-height: 38px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: white;
  color: var(--text);
  font-size: 13px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.question-pill.is-current {
  border-color: var(--primary);
  background: var(--primary);
  color: white;
}

.question-pill.is-done {
  border-color: #9ed5b0;
  background: var(--success-soft);
}

.question-pill.is-wrong {
  border-color: #f0a69f;
  background: var(--danger-soft);
}

.question-pill.is-bookmarked {
  box-shadow: inset 0 -3px 0 var(--accent);
}

.workspace {
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-width: 0;
}

.progress-strip {
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: #dde4dc;
}

.progress-strip div {
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--accent));
  transition: width 220ms ease;
}

.question-card {
  min-height: 520px;
  padding: clamp(18px, 3vw, 28px);
}

.question-toolbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
}

.question-kicker {
  margin-bottom: 8px;
  color: var(--primary-strong);
  font-size: 14px;
  font-weight: 800;
}

#questionTitle {
  max-width: 880px;
  margin: 0;
  font-size: clamp(20px, 2.3vw, 30px);
  line-height: 1.45;
  letter-spacing: 0;
}

.icon-button {
  display: inline-grid;
  width: 46px;
  min-width: 46px;
  height: 46px;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: white;
  color: var(--text-muted);
  transition: color 180ms ease, border-color 180ms ease, background 180ms ease, transform 180ms ease;
}

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

.icon-button:hover,
.icon-button.is-active {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
}

.icon-button:active {
  transform: scale(0.96);
}

.option-list {
  display: grid;
  gap: 12px;
}

.option-button {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr);
  align-items: start;
  gap: 12px;
  width: 100%;
  min-height: 58px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: white;
  color: var(--text);
  padding: 12px;
  text-align: left;
  transition: background 180ms ease, border-color 180ms ease, transform 180ms ease, box-shadow 180ms ease;
}

.option-button:hover {
  border-color: var(--primary);
  box-shadow: 0 8px 20px rgba(15, 118, 110, 0.08);
}

.option-button:active {
  transform: scale(0.995);
}

.option-button.is-selected {
  border-color: var(--primary);
  background: var(--primary-soft);
}

.option-button.is-correct {
  border-color: var(--success);
  background: var(--success-soft);
}

.option-button.is-wrong {
  border-color: var(--danger);
  background: var(--danger-soft);
}

.option-label {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border-radius: 6px;
  background: var(--surface-muted);
  color: var(--text);
  font-weight: 900;
}

.option-button.is-selected .option-label,
.option-button.is-correct .option-label {
  background: var(--primary);
  color: white;
}

.option-button.is-wrong .option-label {
  background: var(--danger);
  color: white;
}

.option-text {
  min-width: 0;
  overflow-wrap: anywhere;
}

.answer-panel {
  margin-top: 18px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #fbfcfa;
}

.answer-status {
  margin-bottom: 10px;
  font-weight: 900;
}

.answer-status.is-correct {
  color: var(--success);
}

.answer-status.is-wrong {
  color: var(--danger);
}

.answer-status.is-revealed {
  color: var(--accent);
}

.answer-line {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}

.answer-line span {
  color: var(--text-muted);
  font-weight: 800;
}

.answer-line strong {
  font-size: 18px;
}

#analysisText {
  margin: 0;
  color: var(--text-muted);
}

.source-details {
  margin-top: 12px;
  color: var(--text-muted);
}

.source-details summary {
  width: max-content;
  cursor: pointer;
  font-weight: 800;
}

.source-details ul {
  margin: 8px 0 0;
  padding-left: 18px;
}

.source-details li {
  overflow-wrap: anywhere;
}

.empty-state {
  padding: 56px 16px;
  text-align: center;
}

.empty-state h2 {
  margin: 0 0 8px;
}

.empty-state p {
  margin: 0;
  color: var(--text-muted);
}

.bottom-actions {
  justify-content: space-between;
  padding-bottom: env(safe-area-inset-bottom);
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 9px 14px;
  font-weight: 850;
  transition: background 180ms ease, border-color 180ms ease, color 180ms ease, transform 180ms ease;
}

.button:active:not(:disabled) {
  transform: scale(0.98);
}

.button-primary {
  background: var(--primary);
  color: white;
}

.button-primary:hover:not(:disabled) {
  background: var(--primary-strong);
}

.button-primary:disabled {
  background: #91aaa5;
  color: rgba(255, 255, 255, 0.9);
}

.button-secondary {
  border-color: var(--border);
  background: white;
  color: var(--text);
}

.button-secondary:hover:not(:disabled) {
  border-color: var(--primary);
  background: var(--primary-soft);
  color: var(--primary-strong);
}

.button-secondary:disabled {
  color: #8b948f;
  background: #eef2ed;
}

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

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

  .question-list {
    grid-template-columns: repeat(8, minmax(0, 1fr));
    max-height: 220px;
  }

  .question-card {
    min-height: auto;
  }
}

@media (max-width: 680px) {
  .topbar {
    position: static;
    align-items: stretch;
    flex-direction: column;
    gap: 14px;
  }

  .top-actions,
  .bottom-actions,
  .answer-actions {
    width: 100%;
  }

  .top-actions .button,
  .answer-actions .button,
  .bottom-actions > .button {
    flex: 1 1 0;
  }

  .bottom-actions {
    flex-direction: column;
  }

  .answer-actions {
    order: -1;
  }

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

  .question-toolbar {
    align-items: flex-start;
  }

  .option-button {
    grid-template-columns: 40px minmax(0, 1fr);
    gap: 10px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}
