/* 默认（深色）：无脚本或 data-theme=dark */
:root {
  --bg: #0f1419;
  --panel: #1a2332;
  --border: #2d3a4d;
  --text: #e7ecf3;
  --muted: #8b9cb3;
  --accent: #3d8bfd;
  --accent-hover: #5ba3ff;
  --danger: #f85149;
  --success: #3fb950;
  --warning: #e3b341;
  --warning-muted: #ffc107;
  --surface-code: #0b0e12;
  --surface-code-elevated: #121820;
  --rich-code-bg: rgba(255, 255, 255, 0.06);
  --msg-success-bg: rgba(63, 185, 80, 0.15);
  --msg-success-border: rgba(63, 185, 80, 0.35);
  --msg-error-bg: rgba(248, 81, 73, 0.12);
  --msg-error-border: rgba(248, 81, 73, 0.35);
  --badge-wait-bg: rgba(255, 193, 7, 0.15);
  --btn-primary-text: #fff;
}

html[data-theme="light"] {
  --bg: #f4f6fa;
  --panel: #ffffff;
  --border: #d1dae6;
  --text: #1a2332;
  --muted: #5c6b7d;
  --accent: #0969da;
  --accent-hover: #0550ae;
  --danger: #cf222e;
  --success: #1a7f37;
  --warning: #9a6700;
  --warning-muted: #bf8700;
  --surface-code: #eef1f6;
  --surface-code-elevated: #e4e9f0;
  --rich-code-bg: rgba(0, 0, 0, 0.06);
  --msg-success-bg: rgba(26, 127, 55, 0.12);
  --msg-success-border: rgba(26, 127, 55, 0.35);
  --msg-error-bg: rgba(207, 34, 46, 0.08);
  --msg-error-border: rgba(207, 34, 46, 0.35);
  --badge-wait-bg: rgba(191, 135, 0, 0.18);
  --btn-primary-text: #fff;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Segoe UI", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  transition: background-color 0.2s ease, color 0.2s ease;
}

a {
  color: var(--accent);
  text-decoration: none;
}
a:hover {
  color: var(--accent-hover);
}

.wrap {
  max-width: 1100px;
  margin: 0 auto;
  padding: 1.25rem 1rem 3rem;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 1.5rem;
}

.topbar-left {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem 0.75rem;
}

.brand {
  font-weight: 700;
  font-size: 1.1rem;
  letter-spacing: 0.02em;
}

.theme-switcher {
  font-size: 0.85rem;
  color: var(--muted);
  margin: 0;
  cursor: pointer;
}

.theme-select {
  max-width: 9rem;
  min-width: 7.5rem;
  padding: 0.35rem 0.5rem;
  font-size: 0.85rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  cursor: pointer;
}

.nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
  align-items: center;
}

.nav a.btn-link {
  color: var(--muted);
}
.nav a.btn-link:hover {
  color: var(--text);
}

.user-pill {
  font-size: 0.85rem;
  color: var(--muted);
}

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1.25rem 1.5rem;
  margin-bottom: 1.25rem;
  transition: background-color 0.2s ease, border-color 0.2s ease;
}

.card h1,
.card h2 {
  margin-top: 0;
  font-size: 1.25rem;
  font-weight: 600;
}

.form-row {
  margin-bottom: 1rem;
}
.form-row label {
  display: block;
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 0.35rem;
}

.input {
  width: 100%;
  max-width: 420px;
  padding: 0.55rem 0.65rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 1rem;
}

select.input {
  max-width: 420px;
}

.errorlist {
  list-style: none;
  padding: 0;
  margin: 0.35rem 0 0;
  color: var(--danger);
  font-size: 0.85rem;
}

.btn {
  display: inline-block;
  padding: 0.5rem 1rem;
  border-radius: 6px;
  border: none;
  font-size: 0.95rem;
  cursor: pointer;
  font-weight: 500;
}

.btn-primary {
  background: var(--accent);
  color: var(--btn-primary-text);
}
.btn-primary:hover {
  background: var(--accent-hover);
}

.btn-ghost {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border);
}
.btn-ghost:hover {
  color: var(--text);
  border-color: var(--muted);
}

.messages {
  list-style: none;
  padding: 0;
  margin: 0 0 1rem;
}
.messages li {
  padding: 0.6rem 0.85rem;
  border-radius: 6px;
  margin-bottom: 0.5rem;
  font-size: 0.9rem;
}
.messages .success {
  background: var(--msg-success-bg);
  border: 1px solid var(--msg-success-border);
  color: var(--success);
}
.messages .error {
  background: var(--msg-error-bg);
  border: 1px solid var(--msg-error-border);
  color: var(--danger);
}

table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}
table.data th,
table.data td {
  text-align: left;
  padding: 0.55rem 0.65rem;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
table.data th {
  color: var(--muted);
  font-weight: 500;
  width: 140px;
}

.stem-preview {
  max-width: 480px;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--muted);
  font-size: 0.85rem;
}

.json-block {
  margin: 0;
  padding: 1rem;
  background: var(--surface-code);
  border-radius: 8px;
  border: 1px solid var(--border);
  overflow: auto;
  max-height: 70vh;
  font-size: 0.8rem;
  line-height: 1.4;
  white-space: pre-wrap;
  word-break: break-word;
}

.pagination {
  margin-top: 1rem;
  display: flex;
  gap: 0.75rem;
  align-items: center;
  flex-wrap: wrap;
  font-size: 0.9rem;
  color: var(--muted);
}

.muted {
  color: var(--muted);
  font-size: 0.9rem;
}

.badge {
  display: inline-block;
  padding: 0.15rem 0.45rem;
  border-radius: 4px;
  font-size: 0.75rem;
  background: var(--border);
  color: var(--text);
}

.badge.ok {
  background: rgba(63, 185, 80, 0.2);
  color: var(--success);
}
html[data-theme="light"] .badge.ok {
  background: rgba(26, 127, 55, 0.15);
}

.badge.wait {
  background: var(--badge-wait-bg);
  color: var(--warning-muted);
}
html[data-theme="light"] .badge.wait {
  color: var(--warning);
}

/* —— 试题 content 结构化展示 —— */
.fmt-pill {
  font-size: 0.7rem;
  font-weight: 500;
  color: var(--muted);
  margin-left: 0.35rem;
  vertical-align: middle;
}

.question-content-card .question-body,
.question-body {
  font-size: 1rem;
  line-height: 1.65;
  word-break: break-word;
}

.rich-md,
.rich-md p {
  margin: 0.35rem 0;
}
.rich-md p:first-child {
  margin-top: 0;
}
.rich-md p:last-child {
  margin-bottom: 0;
}
.rich-md ul,
.rich-md ol {
  margin: 0.5rem 0 0.5rem 1.25rem;
  padding: 0;
}
.rich-md code {
  font-size: 0.88em;
  background: var(--rich-code-bg);
  padding: 0.1em 0.35em;
  border-radius: 4px;
}
.rich-md pre {
  background: var(--surface-code);
  padding: 0.75rem 1rem;
  border-radius: 8px;
  overflow: auto;
  border: 1px solid var(--border);
}
.content-plain {
  line-height: 1.65;
}
.content-latex {
  font-family: ui-monospace, "Cascadia Code", monospace;
  font-size: 0.95rem;
}

.option-list {
  margin: 0;
  padding-left: 0;
  list-style: none;
  counter-reset: opt;
}
.option-list li {
  display: flex;
  gap: 0.75rem;
  align-items: flex-start;
  padding: 0.65rem 0;
  border-bottom: 1px solid var(--border);
}
.option-list li:last-child {
  border-bottom: none;
}
.opt-key {
  flex: 0 0 2.25rem;
  font-weight: 600;
  color: var(--accent);
}
.opt-body {
  flex: 1;
  min-width: 0;
}
.opt-body .rich-md p {
  margin: 0.15rem 0;
}

.answer-wrap .answer-pre {
  margin: 0;
  padding: 1rem;
  background: var(--surface-code);
  border-radius: 8px;
  border: 1px solid var(--border);
  font-size: 0.85rem;
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 50vh;
  overflow: auto;
}
.answer-wrap .answer-scalar {
  font-size: 1.05rem;
  padding: 0.5rem 0;
}

.kv-table th {
  width: 200px;
  vertical-align: top;
}
.json-inline {
  margin: 0;
  padding: 0.65rem 0.75rem;
  background: var(--surface-code);
  border-radius: 6px;
  border: 1px solid var(--border);
  font-size: 0.78rem;
  line-height: 1.4;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 16rem;
  overflow: auto;
}
.ext-scalar {
  word-break: break-word;
}

.sub-h {
  font-size: 0.95rem;
  margin: 1rem 0 0.35rem;
  color: var(--muted);
  font-weight: 600;
}
.sub-h:first-of-type {
  margin-top: 0;
}

.media-list {
  margin: 0;
  padding-left: 1.1rem;
}
.media-list li {
  margin: 0.35rem 0;
}

.raw-json-details summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 0.75rem;
}
.raw-json-details[open] summary {
  margin-bottom: 0.75rem;
}
