:root {
  color-scheme: light dark;
  --bg: #f6f7f9;
  --panel: #ffffff;
  --text: #1b1d21;
  --dim: #6b7280;
  --line: #d9dce1;
  --accent: #1f4fa3;
  --ok: #2e9e5b;
  --bad: #c8483f;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14161a;
    --panel: #1d2026;
    --text: #e8eaee;
    --dim: #9aa1ab;
    --line: #333844;
    --accent: #7cc4ff;
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

body {
  display: flex;
  flex-direction: column;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

.bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}

.bar.top { flex-wrap: wrap; }

.brand { font-weight: 700; color: var(--accent); }

.stats {
  margin-left: auto;
  display: flex;
  gap: 12px;
  font-size: 12px;
  color: var(--dim);
}

.main {
  flex: 1;
  overflow: auto;
  padding: 14px;
  -webkit-overflow-scrolling: touch;
}

.card {
  max-width: 760px;
  margin: 0 auto;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px;
}

.stem { font-weight: 600; margin-bottom: 10px; }

.options { display: flex; flex-direction: column; gap: 8px; }

.opt {
  width: 100%;
  text-align: left;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: transparent;
  color: inherit;
  font: inherit;
  line-height: 1.45;
}

.opt.right { border-color: var(--ok); background: rgba(46, 158, 91, .14); }
.opt.wrong { border-color: var(--bad); background: rgba(200, 72, 63, .14); }

.feedback { margin-top: 10px; font-size: 13px; color: var(--dim); display: flex; gap: 12px; align-items: center; }

.exp { margin-top: 12px; border-top: 1px dashed var(--line); padding-top: 10px; }

.exp summary { cursor: pointer; color: var(--dim); font-size: 13px; }

.exp-body { margin-top: 8px; white-space: pre-wrap; font-size: 13px; color: var(--dim); }

.controls {
  border-top: 1px solid var(--line);
  border-bottom: none;
  justify-content: space-between;
}

.btn {
  flex: 1;
  padding: 12px 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: transparent;
  color: inherit;
  font: inherit;
}

.btn.primary { border-color: var(--accent); color: var(--accent); font-weight: 600; }
.btn[disabled] { opacity: .45; }
.btn.on { border-color: var(--ok); background: rgba(46, 158, 91, .14); }
.btn.small { flex: 0 0 auto; padding: 6px 10px; font-size: 12px; }

.empty { color: var(--dim); text-align: center; padding: 24px; }

.stats { flex-wrap: wrap; }

.badge {
  display: inline-block;
  font-size: 11px;
  padding: 0 6px;
  margin-left: 6px;
  border-radius: 6px;
  background: rgba(31, 79, 163, .14);
  color: var(--accent);
  vertical-align: 1px;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 12px;
  background: rgba(0, 0, 0, .45);
}

.modal[hidden] { display: none; }

.modal-card {
  width: 100%;
  max-width: 680px;
  max-height: 86vh;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--panel);
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.modal-card textarea {
  width: 100%;
  min-height: 170px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: transparent;
  color: inherit;
  resize: vertical;
  font: 12px/1.5 ui-monospace, SFMono-Regular, Consolas, monospace;
}

.modal-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.hint {
  margin: 0;
  font-size: 12px;
  color: var(--dim);
  line-height: 1.6;
}

.hint code {
  padding: 0 4px;
  border-radius: 4px;
  background: rgba(127, 127, 127, .14);
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(88px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 20;
  max-width: 90vw;
  padding: 10px 14px;
  border-radius: 10px;
  background: #22252b;
  color: #fff;
  font-size: 13px;
}

.toast[hidden] { display: none; }

.sep {
  border: none;
  border-top: 1px solid var(--line);
  margin: 4px 0;
}

