:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --panel: #ffffff;
  --ink: #18202a;
  --muted: #647080;
  --line: #d8dde5;
  --accent: #1d7a6f;
  --accent-strong: #0d5f55;
  --wrong: #b63b3b;
  --right: #227447;
  --soft: #eef5f3;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

.app {
  width: min(1080px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 28px 0 32px;
}

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

h1 {
  margin: 0 0 6px;
  font-size: 28px;
  line-height: 1.2;
  letter-spacing: 0;
}

p {
  margin: 0;
}

#subtitle,
#syncStatus,
#offlineStatus,
small,
.question-meta {
  color: var(--muted);
}

#syncStatus,
#offlineStatus {
  margin-top: 4px;
  font-size: 13px;
}

.toolbar,
.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

button {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--ink);
  padding: 0 14px;
  font-size: 15px;
  cursor: pointer;
}

button:hover {
  border-color: var(--accent);
}

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

.seg.active,
.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.primary {
  min-width: 128px;
}

.ghost {
  background: transparent;
}

.stats {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 10px;
  margin-bottom: 14px;
}

.stats div {
  min-height: 76px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px 14px;
}

.stats span {
  display: block;
  font-size: 26px;
  font-weight: 700;
  line-height: 1.1;
}

.stats small {
  display: block;
  margin-top: 8px;
}

.record-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
  padding: 12px 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.record-panel strong,
.record-panel span {
  display: block;
}

.record-panel span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
}

.record-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.question-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 22px;
  min-height: 460px;
}

.question-meta {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 10px;
  font-size: 14px;
}

.question-tools {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 12px;
}

.favorite-btn {
  min-width: 86px;
  background: #fff9e8;
  border-color: #dcc57b;
  color: #705600;
}

.favorite-btn.active {
  background: #f0c84b;
  border-color: #d4ab28;
  color: #2b2300;
  font-weight: 700;
}

h2 {
  margin: 0 0 18px;
  font-size: 22px;
  line-height: 1.55;
  letter-spacing: 0;
  white-space: pre-wrap;
}

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

.option {
  display: grid;
  grid-template-columns: 36px 1fr;
  align-items: start;
  gap: 10px;
  width: 100%;
  min-height: 54px;
  padding: 12px;
  text-align: left;
  line-height: 1.5;
  border-radius: 8px;
}

.label {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #e8ecef;
  font-weight: 700;
}

.option.correct {
  border-color: var(--right);
  background: #edf8f1;
}

.option.wrong {
  border-color: var(--wrong);
  background: #fff0f0;
}

.answer-panel {
  margin-top: 18px;
  padding: 14px;
  border-left: 4px solid var(--accent);
  background: var(--soft);
  border-radius: 6px;
}

.answer-panel strong {
  display: block;
  margin-bottom: 8px;
}

.explanation-block {
  margin-top: 10px;
}

.explanation-block span {
  display: inline-block;
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.answer-panel p,
.sources {
  line-height: 1.6;
  white-space: pre-wrap;
}

.sources {
  margin: 8px 0 0;
  padding-left: 20px;
  color: var(--muted);
  font-size: 14px;
}

.actions {
  justify-content: flex-end;
  padding-top: 14px;
}

@media (max-width: 720px) {
  .app {
    width: min(100vw - 20px, 1080px);
    padding-top: 16px;
  }

  .topbar {
    align-items: stretch;
    flex-direction: column;
  }

  .toolbar {
    flex-wrap: wrap;
  }

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

  .record-panel {
    align-items: stretch;
    flex-direction: column;
  }

  .record-actions {
    justify-content: stretch;
  }

  .record-actions button {
    flex: 1 1 120px;
  }

  .question-panel {
    padding: 16px;
  }

  h2 {
    font-size: 19px;
  }
}
