:root {
  color-scheme: light;
  --bg: #f5f7fb;
  --surface: #ffffff;
  --ink: #1c2433;
  --muted: #647084;
  --line: #dbe2ec;
  --blue: #2563eb;
  --blue-soft: #eaf1ff;
  --green: #0f8f63;
  --green-soft: #e7f7ef;
  --red: #c9343a;
  --red-soft: #fdecee;
  --amber: #9b6400;
  --amber-soft: #fff3d7;
  --nav-h: 70px;
}

* { box-sizing: border-box; }

html { background: var(--bg); }

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

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

.app-shell {
  width: min(960px, 100%);
  min-height: 100vh;
  margin: 0 auto;
  padding: max(18px, env(safe-area-inset-top)) 14px calc(var(--nav-h) + env(safe-area-inset-bottom) + 18px);
}

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

.app-top h1 {
  margin: 0 0 4px;
  font-size: 24px;
  line-height: 1.15;
  font-weight: 800;
}

.app-top p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.icon-btn, .small-btn, .wide-btn, .answer-action, .choice, .bottom-nav button {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  min-height: 42px;
}

.top-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex: 0 0 auto;
}

.icon-btn {
  padding: 0 12px;
  color: var(--blue);
  border-color: #bdd0ff;
  background: var(--blue-soft);
}

.install {
  color: var(--blue);
  border-color: #bdd0ff;
  background: var(--blue-soft);
}

.stats-strip {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-bottom: 12px;
}

.stats-strip div {
  min-width: 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 8px;
}

.stats-strip b {
  display: block;
  font-size: 20px;
  line-height: 1.05;
  overflow-wrap: anywhere;
}

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

.panel { display: none; }
.panel.active { display: block; }

.controls, .question-surface, .settings, .summary-box, .question-list {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.controls {
  padding: 12px;
  margin-bottom: 12px;
}

.control-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

label span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin: 0 0 6px;
}

select, input, textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  outline: none;
  min-height: 44px;
  padding: 9px 10px;
}

textarea {
  resize: vertical;
  line-height: 1.55;
}

select:focus, input:focus, textarea:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px var(--blue-soft);
}

.search-wrap { display: block; margin-top: 10px; }

.segmented {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  margin-top: 10px;
  padding: 4px;
  border-radius: 8px;
  background: #edf1f7;
}

.segmented button {
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  min-height: 38px;
}

.segmented button.active {
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 2px 8px rgba(28, 36, 51, 0.08);
}

.question-surface {
  overflow: hidden;
}

.question-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  padding: 12px;
  border-bottom: 1px solid var(--line);
}

.tag {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0 8px;
  border-radius: 999px;
  background: #f1f4f8;
  color: var(--muted);
  font-size: 12px;
}

.tag.blue { color: var(--blue); background: var(--blue-soft); }
.tag.green { color: var(--green); background: var(--green-soft); }
.tag.red { color: var(--red); background: var(--red-soft); }

.question-body {
  padding: 16px 12px 14px;
}

.stem {
  margin: 0 0 16px;
  font-size: 20px;
  line-height: 1.55;
  font-weight: 650;
  overflow-wrap: anywhere;
}

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

.choice {
  width: 100%;
  display: grid;
  grid-template-columns: 34px 1fr;
  gap: 10px;
  align-items: start;
  text-align: left;
  padding: 12px;
  line-height: 1.45;
}

.choice-key {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: #eef2f7;
  color: #3f4c5f;
  font-weight: 800;
}

.choice.selected {
  border-color: var(--blue);
  background: var(--blue-soft);
}

.choice.correct {
  border-color: #7ad1aa;
  background: var(--green-soft);
}

.choice.wrong {
  border-color: #eea0a5;
  background: var(--red-soft);
}

.feedback {
  display: none;
  margin: 0 0 12px;
  padding: 11px 12px;
  border-radius: 8px;
  line-height: 1.5;
}

.feedback.show { display: block; }
.feedback.ok { color: var(--green); background: var(--green-soft); }
.feedback.no { color: var(--red); background: var(--red-soft); }

.answer-box {
  margin-top: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfe;
  padding: 12px;
  line-height: 1.65;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.action-bar {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding: 12px;
  border-top: 1px solid var(--line);
}

.answer-action {
  padding: 0 10px;
}

.answer-action.primary {
  color: #fff;
  border-color: var(--blue);
  background: var(--blue);
}

.answer-action.good {
  color: #fff;
  border-color: var(--green);
  background: var(--green);
}

.answer-action.warn {
  color: var(--amber);
  border-color: #e3bf6f;
  background: var(--amber-soft);
}

.answer-action.danger {
  color: var(--red);
  border-color: #eba3a8;
  background: var(--red-soft);
}

.list-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: 4px 0 12px;
}

.list-head h2 {
  margin: 0;
  font-size: 20px;
}

.small-btn {
  padding: 0 12px;
  color: var(--blue);
  border-color: #bdd0ff;
  background: var(--blue-soft);
}

.question-list {
  overflow: hidden;
}

.list-item {
  width: 100%;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: transparent;
  text-align: left;
  padding: 13px 12px;
}

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

.list-item b {
  display: block;
  margin-bottom: 4px;
  font-size: 14px;
  line-height: 1.45;
}

.list-item span {
  color: var(--muted);
  font-size: 12px;
}

.settings {
  display: grid;
  gap: 10px;
  padding: 12px;
}

.wide-btn {
  width: 100%;
  min-height: 46px;
  display: grid;
  place-items: center;
  padding: 0 12px;
}

.wide-btn.danger {
  color: var(--red);
  border-color: #eba3a8;
  background: var(--red-soft);
}

.file-btn input {
  position: absolute;
  inline-size: 1px;
  block-size: 1px;
  opacity: 0;
  pointer-events: none;
}

.summary-box {
  margin-top: 12px;
  padding: 12px;
  color: var(--muted);
  line-height: 1.6;
}

.summary-box p { margin: 0; }

.empty-state {
  padding: 44px 12px;
  text-align: center;
  color: var(--muted);
}

.bottom-nav {
  position: fixed;
  left: 50%;
  bottom: 0;
  transform: translateX(-50%);
  width: min(960px, 100%);
  height: calc(var(--nav-h) + env(safe-area-inset-bottom));
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  padding: 8px 10px calc(8px + env(safe-area-inset-bottom));
  background: rgba(255, 255, 255, 0.94);
  border-top: 1px solid var(--line);
  backdrop-filter: blur(14px);
}

.bottom-nav button {
  border: 0;
  background: transparent;
  color: var(--muted);
  min-height: 48px;
}

.bottom-nav button.active {
  color: var(--blue);
  background: var(--blue-soft);
}

@media (min-width: 760px) {
  .app-shell { padding-left: 22px; padding-right: 22px; }
  .app-top h1 { font-size: 30px; }
  .controls {
    display: grid;
    grid-template-columns: 1fr 1fr 220px;
    gap: 12px;
    align-items: end;
  }
  .search-wrap, .segmented { margin-top: 0; }
  .stem { font-size: 22px; }
  .action-bar { grid-template-columns: repeat(4, 1fr); }
}

@media (max-width: 380px) {
  .stats-strip b { font-size: 18px; }
  .stem { font-size: 19px; }
  .control-grid { grid-template-columns: 1fr; }
}
