:root {
  color-scheme: light;
  --ink: #1d2733;
  --muted: #66758a;
  --line: #d9e1e8;
  --surface: #ffffff;
  --paper: #f6f8fb;
  --accent: #0f8f7f;
  --accent-dark: #087063;
  --gold: #b77812;
  --danger: #c93f36;
  --ok: #17834f;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
  color: var(--ink);
  background: linear-gradient(180deg, #eef5f4 0%, #f7f8fb 34%, #ffffff 100%);
}

button {
  font: inherit;
}

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

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

.topbar,
.question-head,
.section-head,
.stats,
.tabs {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.topbar {
  margin-bottom: 18px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--accent-dark);
  font-size: 14px;
  font-weight: 700;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 34px;
  line-height: 1.15;
}

h2 {
  font-size: 23px;
  line-height: 1.45;
}

.refresh,
.submit {
  border: 0;
  border-radius: 8px;
  color: white;
  background: var(--accent);
  padding: 12px 18px;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 10px 24px rgba(15, 143, 127, 0.18);
}

.refresh:hover,
.submit:hover {
  background: var(--accent-dark);
}

.ghost,
.tab,
.mode-tab,
.pool-tab {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  color: var(--ink);
  padding: 10px 14px;
  cursor: pointer;
}

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

.tabs {
  justify-content: flex-start;
  margin: 20px 0;
}

.sync-panel {
  display: grid;
  grid-template-columns: minmax(160px, 1fr) auto auto auto minmax(120px, auto);
  align-items: center;
  gap: 10px;
  margin: -6px 0 18px;
}

.sync-panel input[type="password"] {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  color: var(--ink);
  padding: 10px 12px;
  font: inherit;
}

.sync-toggle {
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  padding: 8px 12px;
  color: var(--muted);
  font-weight: 700;
}

.sync-status {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  overflow-wrap: anywhere;
}

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

.tab.active,
.mode-tab.active,
.pool-tab.active {
  color: white;
  border-color: var(--accent);
  background: var(--accent);
  font-weight: 800;
}

.mode-tabs {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 20px;
}

.mode-tab,
.pool-tab {
  min-height: 44px;
  font-weight: 700;
}

.stats {
  align-items: stretch;
  margin-bottom: 18px;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
}

.stat {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.88);
  padding: 14px;
}

.stat strong {
  display: block;
  margin-bottom: 4px;
  font-size: 22px;
  overflow-wrap: anywhere;
}

.stat span {
  color: var(--muted);
  font-size: 13px;
}

.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 24px;
  box-shadow: 0 18px 48px rgba(31, 44, 60, 0.08);
}

.question-head,
.section-head {
  margin-bottom: 18px;
}

.question-head {
  justify-content: flex-start;
}

.question-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  order: -1;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  border-radius: 999px;
  padding: 6px 10px;
  margin: 0 6px 6px 0;
  background: #e4f5f2;
  color: var(--accent-dark);
  font-size: 13px;
  font-weight: 800;
  max-width: 100%;
  overflow-wrap: anywhere;
}

.pill.muted {
  background: #eef1f4;
  color: var(--muted);
}

.pill.warn {
  background: #fff3da;
  color: var(--gold);
}

.options {
  display: grid;
  gap: 12px;
  margin: 22px 0 16px;
}

.raw-question {
  margin: 18px 0 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
  padding: 16px;
  color: var(--ink);
  font-family: "SFMono-Regular", Consolas, "Microsoft YaHei", monospace;
  font-size: 15px;
  line-height: 1.65;
  white-space: pre-wrap;
  overflow-x: auto;
}

.option {
  width: 100%;
  min-height: 58px;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  padding: 14px;
  text-align: left;
  cursor: pointer;
  overflow-wrap: anywhere;
}

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

.option .letter {
  flex: 0 0 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: white;
  font-weight: 800;
  color: var(--accent-dark);
}

.option.selected {
  border-color: var(--accent);
  background: #e9f7f4;
}

.option.correct {
  border-color: var(--ok);
  background: #e9f8ef;
}

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

.answer {
  border-left: 4px solid var(--accent);
  background: #f1faf8;
  padding: 14px 16px;
  line-height: 1.7;
}

.answer strong {
  color: var(--accent-dark);
}

.manual-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 12px;
}

.manual-actions input {
  min-height: 46px;
  min-width: 220px;
  flex: 1;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  color: var(--ink);
  padding: 10px 12px;
  font: inherit;
  text-transform: uppercase;
}

.correction-panel {
  margin-top: 16px;
  border-top: 1px solid var(--line);
  padding-top: 16px;
}

.correction-panel textarea {
  width: 100%;
  min-height: 190px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
  color: var(--ink);
  padding: 12px;
  font: inherit;
  line-height: 1.6;
}

.correction-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 10px;
}

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

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

.wrong-item h3 {
  margin: 8px 0;
  font-size: 17px;
  line-height: 1.45;
}

.wrong-item p {
  color: var(--muted);
  line-height: 1.55;
  overflow-wrap: anywhere;
}

.empty {
  color: var(--muted);
  padding: 20px 0;
}

.hidden {
  display: none !important;
}

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

  .topbar,
  .question-head,
  .section-head {
    align-items: stretch;
    flex-direction: column;
  }

  .topbar {
    gap: 12px;
  }

  .refresh,
  .submit,
  .ghost,
  .tab,
  .pool-tab {
    width: 100%;
  }

  .question-actions {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

  .stat {
    padding: 12px;
  }

  .stat strong {
    font-size: 18px;
  }

  .panel {
    padding: 16px;
  }

  .mode-tabs {
    grid-template-columns: 1fr;
  }

  .tabs {
    overflow-x: auto;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .sync-panel {
    grid-template-columns: 1fr 1fr;
  }

  .sync-panel input[type="password"],
  .sync-toggle,
  .sync-status {
    grid-column: 1 / -1;
  }

  h1 {
    font-size: 28px;
  }

  h2 {
    font-size: 20px;
  }

  .raw-question {
    padding: 12px;
    font-size: 14px;
  }

  .option {
    min-height: 54px;
    padding: 12px;
  }

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

  .manual-actions input {
    width: 100%;
    min-width: 0;
  }

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

@media (max-width: 420px) {
  .app {
    width: min(100% - 14px, 1080px);
  }

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

  .sync-panel {
    grid-template-columns: 1fr;
  }

  .question-actions {
    grid-template-columns: 1fr;
  }

  h1 {
    font-size: 24px;
  }

  h2 {
    font-size: 18px;
  }
}
