/* LeetCode 风格 · 408 题库 */
:root {
  --bg: #f7f8fa;
  --panel: #ffffff;
  --panel-2: #f2f3f5;
  --border: #e6e8eb;
  --border-2: #eff1f6;
  --text: #262626;
  --text-2: #595959;
  --text-3: #8c8c8c;
  --orange: #ffa116;
  --orange-hover: #ffb84d;
  --orange-soft: #fff7e6;
  --green: #00b8a3;
  --green-soft: rgba(0, 184, 163, .1);
  --red: #ff375f;
  --red-soft: rgba(255, 55, 95, .08);
  --yellow: #ffc01e;
  --nav: #262626;
  --nav-text: #eff1f6;
  --nav-muted: #a0a0a0;
  --radius: 8px;
  --shadow: 0 1px 2px rgba(0, 0, 0, .03);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1a1a1a;
    --panel: #262626;
    --panel-2: #303030;
    --border: #3a3a3a;
    --border-2: #3a3a3a;
    --text: #eff1f6;
    --text-2: #c4c4c4;
    --text-3: #8c8c8c;
    --orange-soft: #3a2a12;
    --green-soft: rgba(0, 184, 163, .16);
    --red-soft: rgba(255, 55, 95, .14);
    --nav: #1a1a1a;
    --shadow: none;
  }
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, "SF Pro Text", "Segoe UI", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

button { font: inherit; color: inherit; }
a { color: inherit; text-decoration: none; }
.hidden { display: none !important; }
.muted { color: var(--text-3); }

/* ---------- top navbar ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  height: 50px;
  background: var(--nav);
  border-bottom: 1px solid #3a3a3a;
}

.topbar-inner {
  max-width: 1200px;
  height: 100%;
  margin: 0 auto;
  padding: 0 clamp(12px, 3vw, 20px);
  display: flex;
  align-items: center;
  gap: 24px;
}

.brand { display: flex; align-items: center; gap: 10px; flex: none; }
.logo {
  width: 30px; height: 30px;
  display: grid; place-items: center;
  border-radius: 6px;
  background: var(--orange);
  color: #262626;
  font-size: 11px; font-weight: 800; letter-spacing: -.3px;
}
.brand-name { color: var(--nav-text); font-size: 16px; font-weight: 600; letter-spacing: .2px; }

.nav { display: flex; align-items: center; height: 100%; gap: 4px; flex: 1; }
.nav-item {
  position: relative;
  height: 100%;
  padding: 0 12px;
  border: 0;
  background: transparent;
  color: var(--nav-muted);
  font-size: 14px;
  cursor: pointer;
  transition: color .15s ease;
}
.nav-item:hover { color: var(--nav-text); }
.nav-item.active { color: var(--nav-text); }
.nav-item.active::after {
  content: "";
  position: absolute;
  left: 10px; right: 10px; bottom: 0;
  height: 2px;
  border-radius: 2px 2px 0 0;
  background: var(--orange);
}

.head-stats { display: flex; align-items: center; gap: 14px; flex: none; }
.nav-stat { color: var(--nav-muted); font-size: 13px; white-space: nowrap; }
.nav-stat b { color: var(--nav-text); font-weight: 600; }

/* ---------- page / layout ---------- */
.page { max-width: 1200px; margin: 0 auto; padding: 22px clamp(12px, 3vw, 20px) 0; }

.layout {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  gap: 24px;
  align-items: start;
  min-height: calc(100vh - 170px);
}

.sidebar {
  position: sticky;
  top: 72px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.side-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  box-shadow: var(--shadow);
}

.side-title {
  margin: 0 0 8px;
  padding: 0 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-3);
  letter-spacing: .04em;
}

.side-list { display: flex; flex-direction: column; gap: 1px; }

.side-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  padding: 7px 8px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--text-2);
  font-size: 14px;
  text-align: left;
  cursor: pointer;
  transition: background .12s ease, color .12s ease;
}
.side-item:hover { background: var(--panel-2); color: var(--text); }
.side-item.active { background: var(--panel-2); color: var(--text); font-weight: 600; }
.side-item .count { font-size: 12px; color: var(--text-3); font-weight: 400; }

.progress-card { margin-bottom: 2px; }
.side-head { display: flex; align-items: center; justify-content: space-between; font-size: 13px; color: var(--text-2); }
.side-head b { color: var(--text); font-size: 14px; }
.progress-bar { height: 6px; margin: 10px 0 8px; border-radius: 999px; background: var(--border-2); overflow: hidden; }
.progress-bar span { display: block; width: 0; height: 100%; border-radius: inherit; background: var(--orange); transition: width .4s ease; }
.progress-meta { display: flex; justify-content: space-between; font-size: 12px; color: var(--text-3); }

/* ---------- list head ---------- */
.content { min-width: 0; }

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}
.page-heading h1 { margin: 0; font-size: clamp(22px, 3vw, 24px); font-weight: 600; letter-spacing: -.2px; }
.page-sub { margin: 3px 0 0; font-size: 13px; color: var(--text-3); }

.search-box {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 240px;
  height: 34px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--panel);
  color: var(--text-3);
}
.search-box:focus-within { border-color: var(--orange); }
.search-box input {
  flex: 1;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
  font-size: 13px;
}
.search-box input::placeholder { color: var(--text-3); }

.select {
  height: 34px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--panel);
  color: var(--text);
  font-size: 13px;
  cursor: pointer;
}
.select:focus-visible { outline: 2px solid var(--orange); outline-offset: 1px; }

.page-tools { display: flex; align-items: center; gap: 10px; flex: none; flex-wrap: wrap; }
.page-tools .btn { height: 34px; padding: 0 14px; }
.page-tools .select { max-width: 150px; }

/* 键盘可达性 */
.table-row:focus-visible { outline: 2px solid var(--orange); outline-offset: -2px; }
.btn:focus-visible,
.option:focus-visible,
.side-item:focus-visible,
.nav-item:focus-visible,
.back-link:focus-visible {
  outline: 2px solid var(--orange);
  outline-offset: 2px;
}

.table-note { margin: 0 0 10px; font-size: 12px; color: var(--text-3); }

/* ---------- problem table ---------- */
.table {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}

.table-head,
.table-row {
  display: grid;
  grid-template-columns: 56px minmax(0, 1fr) 110px 80px 96px;
  align-items: center;
  gap: 12px;
  padding: 0 16px;
}

.table-head {
  height: 42px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-3);
  border-bottom: 1px solid var(--border);
}

.table-row {
  width: 100%;
  height: 54px;
  border: 0;
  border-bottom: 1px solid var(--border-2);
  background: transparent;
  text-align: left;
  cursor: pointer;
  transition: background .12s ease;
}
.table-row:last-child { border-bottom: 0; }
.table-row:hover { background: var(--bg); }
.table-row:hover .title-text { color: var(--orange); }

.cell-status { display: flex; justify-content: center; }
.status {
  width: 20px; height: 20px;
  display: inline-grid; place-items: center;
  border-radius: 50%;
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
}
.status.todo { border: 1px dashed var(--border); color: transparent; }
.status.seen { background: var(--panel-2); color: var(--text-3); }
.status.right { background: var(--green-soft); color: var(--green); }
.status.wrong { background: var(--red-soft); color: var(--red); }

.cell-title { min-width: 0; }
.title-text {
  display: block;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
  transition: color .12s ease;
}
.title-sub { display: none; margin-top: 2px; font-size: 12px; color: var(--text-3); }

.tag {
  display: inline-block;
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--panel-2);
  color: var(--text-2);
  font-size: 12px;
  white-space: nowrap;
}
.tag.ds { background: rgba(76, 110, 245, .1); color: #4c6ef5; }
.tag.co { background: rgba(0, 184, 163, .12); color: #0b9c8b; }
.tag.os { background: rgba(255, 161, 22, .14); color: #c47a00; }
.tag.net { background: rgba(255, 55, 95, .1); color: #e02b52; }
@media (prefers-color-scheme: dark) {
  .tag.ds { color: #8da2ff; }
  .tag.co { color: #4fd8c6; }
  .tag.os { color: #ffbf5c; }
  .tag.net { color: #ff7d97; }
}

.type { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; color: var(--text-2); white-space: nowrap; }
.type::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--text-3); }
.type.choice::before { background: var(--green); }
.type.short::before { background: var(--orange); }

.cell-no { font-size: 13px; color: var(--text-3); white-space: nowrap; }

.empty { padding: 48px 0; text-align: center; color: var(--text-3); }

/* ---------- pagination ---------- */
.pager {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 14px;
}
.pg-pages { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.pg-btn {
  min-width: 32px;
  height: 32px;
  padding: 0 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--panel);
  color: var(--text-2);
  font-size: 13px;
  cursor: pointer;
}
.pg-btn:hover:not(:disabled) { border-color: var(--orange); color: var(--orange); }
.pg-btn.active { background: var(--orange); border-color: var(--orange); color: #262626; font-weight: 600; }
.pg-btn:disabled { opacity: .45; cursor: not-allowed; }
.pg-gap { padding: 0 2px; color: var(--text-3); }
.pg-meta { display: flex; align-items: center; gap: 10px; font-size: 12px; color: var(--text-3); }
.pg-meta .select { height: 30px; font-size: 12px; }

.trap { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }

/* ---------- practice ---------- */
body.practice-mode .sidebar { display: none; }
body.practice-mode .layout { grid-template-columns: minmax(0, 1fr); max-width: 1080px; }
body.practice-mode .page { max-width: 1120px; }

.practice { display: block; }

.problem-head { margin-bottom: 18px; }
.back-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-bottom: 12px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--text-3);
  font-size: 13px;
  cursor: pointer;
}
.back-link:hover { color: var(--orange); }

.problem-title-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.problem-title-row h1 { margin: 0; font-size: clamp(20px, 3.4vw, 24px); font-weight: 600; letter-spacing: -.2px; line-height: 1.35; }

.problem-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 8px;
  font-size: 13px;
  color: var(--text-3);
}

.problem-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 280px;
  gap: 20px;
  align-items: start;
}

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
}

.stem { font-size: 15px; line-height: 1.85; }
.stem > :first-child { margin-top: 0; }
.stem > :last-child { margin-bottom: 0; }

.options { display: flex; flex-direction: column; gap: 8px; margin-top: 18px; }

.option {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--panel);
  text-align: left;
  cursor: pointer;
  transition: border-color .12s ease, background .12s ease;
}
.option:hover { border-color: var(--orange); }
.option .key {
  flex: none;
  width: 24px; height: 24px;
  display: grid; place-items: center;
  border-radius: 50%;
  background: var(--panel-2);
  color: var(--text-2);
  font-size: 12px;
  font-weight: 700;
}
.option .opt-body { min-width: 0; font-size: 14px; line-height: 1.7; }
.option .opt-body p { display: inline; margin: 0; }
.option .opt-body img { max-width: 100%; max-height: 110px; vertical-align: middle; border-radius: 4px; }
.option.selected { border-color: var(--orange); background: var(--orange-soft); }
.option.selected .key { background: var(--orange); color: #262626; }
.option.correct { border-color: var(--green); background: var(--green-soft); }
.option.correct .key { background: var(--green); color: #fff; }
.option.wrong { border-color: var(--red); background: var(--red-soft); }
.option.wrong .key { background: var(--red); color: #fff; }
.option:disabled { cursor: default; }
.option:disabled:hover { border-color: var(--border); }
.option.correct:disabled:hover { border-color: var(--green); }
.option.wrong:disabled:hover { border-color: var(--red); }

.actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 20px; }
.spacer { flex: 1; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 36px;
  padding: 0 16px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: var(--panel-2);
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background .12s ease, opacity .12s ease;
}
.btn:hover { background: var(--border); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--orange); color: #262626; }
.btn.primary:hover { background: var(--orange-hover); }
.btn.ghost { background: transparent; border-color: var(--border); }
.btn.ghost:hover { background: var(--panel-2); }
.btn.ok { background: var(--green); color: #fff; }
.btn.ok:hover { opacity: .9; background: var(--green); }
.btn.bad { background: var(--red-soft); color: var(--red); border-color: rgba(255, 55, 95, .35); }
.btn.bad:hover { background: var(--red-soft); }

.hint, .kbd-hint { font-size: 12px; color: var(--text-3); }

.side-info h3 { margin: 0 0 10px; font-size: 14px; font-weight: 600; }
.info-list { margin: 0; }
.info-list > div { display: flex; justify-content: space-between; gap: 12px; padding: 7px 0; border-bottom: 1px solid var(--border-2); font-size: 13px; }
.info-list > div:last-child { border-bottom: 0; }
.info-list dt { color: var(--text-3); }
.info-list dd { margin: 0; color: var(--text); text-align: right; }

.side-nav { display: flex; flex-direction: column; gap: 8px; }
.side-nav .btn { width: 100%; justify-content: space-between; }

.status-text { font-weight: 600; }
.status-text.right { color: var(--green); }
.status-text.wrong { color: var(--red); }
.status-text.seen { color: var(--text-2); }
.status-text.todo { color: var(--text-3); }

/* ---------- result ---------- */
#resultBox { margin-top: 20px; scroll-margin-top: 66px; }

.result {
  background: var(--panel);
  border: 1px solid var(--border);
  border-left: 4px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}
.result.pass { border-left-color: var(--green); }
.result.fail { border-left-color: var(--red); }
.result.reveal { border-left-color: var(--orange); }

.result-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  font-size: 15px;
  font-weight: 600;
  border-bottom: 1px solid var(--border-2);
}
.result.pass .result-head { color: var(--green); }
.result.fail .result-head { color: var(--red); }
.result.reveal .result-head { color: var(--orange); }
.result-icon { font-size: 16px; font-weight: 700; }

.result-body { padding: 16px; }
.answer-line { font-size: 14px; color: var(--text-2); margin-bottom: 4px; }
.answer-line b { color: var(--text); font-size: 15px; }
.result-label { margin: 14px 0 6px; font-size: 12px; font-weight: 600; color: var(--text-3); letter-spacing: .04em; }

/* ---------- markdown ---------- */
.markdown { font-size: 14px; line-height: 1.85; color: var(--text); overflow-wrap: anywhere; }
.markdown > :first-child { margin-top: 0; }
.markdown > :last-child { margin-bottom: 0; }
.markdown h1, .markdown h2, .markdown h3, .markdown h4 { line-height: 1.4; margin: 1.1em 0 .45em; }
.markdown h1 { font-size: 1.3em; }
.markdown h2 { font-size: 1.18em; }
.markdown h3 { font-size: 1.06em; }
.markdown p { margin: .55em 0; }
.markdown ul, .markdown ol { padding-left: 1.4em; margin: .55em 0; }
.markdown li { margin: .2em 0; }
.markdown code {
  font-family: "JetBrains Mono", "Cascadia Code", Consolas, monospace;
  font-size: .88em;
  padding: .1em .35em;
  border-radius: 4px;
  background: var(--panel-2);
  color: var(--text);
}
.markdown pre {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  overflow: auto;
  font-size: 13px;
  line-height: 1.6;
}
.markdown pre code { background: transparent; padding: 0; border: 0; font-size: inherit; }
.markdown blockquote {
  margin: .8em 0;
  padding: .15em 0 .15em 1em;
  border-left: 3px solid var(--orange);
  color: var(--text-2);
  background: var(--orange-soft);
  border-radius: 0 6px 6px 0;
}
.markdown table { border-collapse: collapse; margin: .8em 0; width: 100%; font-size: .95em; }
.markdown th, .markdown td { border: 1px solid var(--border); padding: 6px 10px; text-align: left; }
.markdown th { background: var(--bg); font-weight: 600; }
.markdown img { max-width: 100%; height: auto; margin: .6em 0; border: 1px solid var(--border); border-radius: 6px; background: #fff; }
.markdown hr { border: 0; border-top: 1px solid var(--border); margin: 1.1em 0; }

/* KaTeX */
.math-inline { white-space: nowrap; }
.math-display { display: block; overflow-x: auto; overflow-y: hidden; margin: .8em 0; }
.katex { font-size: 1.05em; }
.katex-display { margin: .8em 0; overflow-x: auto; overflow-y: hidden; }

/* ---------- no-JS fallback ---------- */
.seo-fallback { max-width: 900px; margin: 0 auto; padding: 22px 20px 4px; color: var(--text-2); }
.seo-fallback h1 { margin: 0 0 8px; font-size: 22px; color: var(--text); }
.seo-fallback p { margin: 0 0 8px; line-height: 1.75; }

/* ---------- footer / toast ---------- */
.footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 18px;
  margin-top: 48px;
  padding: 18px 20px 28px;
  border-top: 1px solid var(--border);
  color: var(--text-3);
  font-size: 12px;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translate(-50%, 12px);
  z-index: 50;
  max-width: min(92vw, 420px);
  padding: 9px 16px;
  border-radius: var(--radius);
  background: var(--nav);
  color: var(--nav-text);
  font-size: 13px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .18s ease, transform .18s ease;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- auth (topbar) ---------- */
.auth { display: flex; align-items: center; gap: 8px; flex: none; }
.auth-login {
  height: 30px;
  padding: 0 14px;
  border: 1px solid rgba(255, 161, 22, .55);
  border-radius: 999px;
  background: transparent;
  color: var(--orange);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.auth-login:hover { background: rgba(255, 161, 22, .14); }
.avatar {
  width: 28px; height: 28px;
  display: inline-grid; place-items: center;
  border-radius: 50%;
  background: var(--orange);
  color: #262626;
  font-size: 13px;
  font-weight: 700;
}
.auth-name { color: var(--nav-text); font-size: 13px; max-width: 110px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.role-badge {
  padding: 1px 7px;
  border-radius: 999px;
  background: rgba(255, 161, 22, .18);
  color: var(--orange);
  font-size: 11px;
  white-space: nowrap;
}
.auth-link {
  border: 0;
  background: transparent;
  color: var(--nav-muted);
  font-size: 12px;
  cursor: pointer;
}
.auth-link:hover { color: var(--nav-text); }

/* ---------- modal ---------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(0, 0, 0, .55);
  overflow-y: auto;
}
.modal {
  width: min(94vw, 460px);
  max-height: calc(100vh - 40px);
  display: flex;
  flex-direction: column;
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 16px 48px rgba(0, 0, 0, .28);
}
.modal-wide { width: min(96vw, 860px); }
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
}
.modal-head h2 { margin: 0; font-size: 17px; font-weight: 600; }
.modal-head h2 .muted { font-size: 13px; font-weight: 400; }
.modal-x {
  width: 30px; height: 30px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--text-3);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
}
.modal-x:hover { background: var(--panel-2); color: var(--text); }
.modal-body { padding: 18px; overflow-y: auto; }
.modal-foot {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 12px 18px;
  border-top: 1px solid var(--border);
}

/* ---------- login ---------- */
.login-modal .modal-body { text-align: center; }
.login-step { margin: 0 0 10px; font-size: 14px; color: var(--text-2); }
.login-step + .login-qr { margin-top: -2px; }
.login-qr {
  display: block;
  width: 190px; height: 190px;
  margin: 4px auto 14px;
  object-fit: contain;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
}
.login-code {
  margin: 12px auto 14px;
  padding: 10px 0;
  width: min(260px, 100%);
  border: 1px dashed var(--orange);
  border-radius: 10px;
  background: var(--orange-soft);
  color: var(--text);
  font-family: "JetBrains Mono", Consolas, monospace;
  font-size: 40px;
  font-weight: 700;
  letter-spacing: 12px;
  text-indent: 12px;
}
.login-code-input { display: flex; gap: 8px; margin: 10px 0 12px; }
.login-code-input input {
  flex: 1;
  min-width: 0;
  height: 44px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel);
  color: var(--text);
  font-family: "JetBrains Mono", Consolas, monospace;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 8px;
  text-align: center;
}
.login-code-input input:focus { outline: 0; border-color: var(--orange); }
.login-code-input .btn { height: 44px; flex: none; }
.login-error { margin: 6px 0 10px; color: var(--red); font-size: 14px; }
.dev-login { margin-top: 10px; }

/* ---------- editor ---------- */
.edit-body { display: flex; flex-direction: column; gap: 14px; }
.edit-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.options-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--text-2); }
.field-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.edit-input {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--panel);
  color: var(--text);
  font: inherit;
  font-size: 13px;
  line-height: 1.6;
  resize: vertical;
}
.edit-input:focus { outline: 0; border-color: var(--orange); }
textarea.edit-input { font-family: "JetBrains Mono", "Cascadia Code", Consolas, monospace; font-size: 12.5px; }
.mini-btn {
  height: 26px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--panel);
  color: var(--text-2);
  font-size: 12px;
  cursor: pointer;
}
.mini-btn:hover { border-color: var(--orange); color: var(--orange); }
.btn-sm { height: 28px; padding: 0 10px; font-size: 12px; }
.edited-badge {
  padding: 1px 8px;
  border-radius: 999px;
  background: var(--orange-soft);
  color: #c47a00;
  font-size: 12px;
}
.problem-tag {
  padding: 1px 8px;
  border-radius: 999px;
  background: var(--panel-2);
  color: var(--text-3);
  font-size: 12px;
}

/* ---------- admin tabs / raw table browser ---------- */
.admin-tabs {
  display: flex;
  align-items: center;
  gap: 4px;
  margin: -4px 0 18px;
  border-bottom: 1px solid var(--border);
}
.admin-tab {
  position: relative;
  padding: 9px 12px;
  border: 0;
  background: transparent;
  color: var(--text-3);
  font-size: 14px;
  cursor: pointer;
}
.admin-tab:hover { color: var(--text); }
.admin-tab.active { color: var(--text); font-weight: 600; }
.admin-tab.active::after {
  content: "";
  position: absolute;
  left: 8px; right: 8px; bottom: -1px;
  height: 2px;
  border-radius: 2px 2px 0 0;
  background: var(--orange);
}
.db-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}
.db-toolbar .search-box { flex: 1; max-width: 420px; }
.db-table-wrap {
  overflow: auto;
  max-height: min(70vh, 720px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow);
}
.db-table {
  border-collapse: separate;
  border-spacing: 0;
  min-width: 100%;
  font-size: 12.5px;
}
.db-table th,
.db-table td {
  max-width: 340px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border-2);
  text-align: left;
  vertical-align: top;
}
.db-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--panel-2);
  color: var(--text-2);
  font-weight: 600;
  white-space: nowrap;
}
.db-table td {
  color: var(--text-2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.db-table tbody tr:hover td { background: var(--bg); }
.db-table .db-cell-pk { color: var(--text); font-weight: 600; }
.db-pk {
  display: inline-block;
  margin-left: 5px;
  padding: 0 5px;
  border-radius: 4px;
  background: var(--orange-soft);
  color: #b26f00;
  font-size: 10px;
  font-weight: 700;
  vertical-align: 1px;
}
.db-type {
  display: block;
  color: var(--text-3);
  font-size: 10px;
  font-weight: 400;
  letter-spacing: .2px;
}
@media (prefers-color-scheme: dark) {
  .db-pk { color: var(--orange); }
}
.db-null { color: var(--text-3); font-style: italic; }
.db-muted { color: var(--text-3); }
.db-actions { position: sticky; right: 0; background: var(--panel); width: 64px; }
.db-table tbody tr:hover .db-actions { background: var(--bg); }
.db-empty { padding: 28px 16px !important; text-align: center; color: var(--text-3); }
.db-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
}
.db-field-head {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 13px;
  color: var(--text-2);
}
.db-field-name { font-weight: 600; color: var(--text); font-family: "JetBrains Mono", "Cascadia Code", Consolas, monospace; }
.db-field-type { color: var(--text-3); font-size: 11px; }
.db-null-toggle { margin-left: auto; display: inline-flex; align-items: center; gap: 4px; font-size: 12px; color: var(--text-3); cursor: pointer; }
.db-edit-modal .modal-body { max-height: min(72vh, 760px); }
.db-quick-actions { margin-top: 4px; }
.db-value:disabled { opacity: .45; }

/* ---------- admin stats ---------- */
.stat-cards {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}
.stat-card {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 14px 16px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.stat-card span { font-size: 12px; color: var(--text-3); }
.stat-card b { font-size: 24px; font-weight: 700; letter-spacing: -.4px; }
.stat-table { overflow: hidden; }
.stat-table .table-head,
.stat-table .stat-row {
  display: grid;
  grid-template-columns: 140px 70px 70px minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  padding: 0 16px;
}
.stat-table .table-head { height: 38px; border-bottom: 1px solid var(--border); }
.stat-rows .stat-row { height: 34px; border-bottom: 1px solid var(--border-2); font-size: 13px; }
.stat-rows .stat-row:last-child { border-bottom: 0; }
.stat-rows .stat-row > span { min-width: 0; }
.stat-rows .stat-row > span:first-child { color: var(--text-2); }
.stat-rows .stat-row.stat-zero { color: var(--text-3); }
.stat-bar-cell { display: flex; align-items: center; }
.stat-bar {
  display: block;
  height: 12px;
  min-width: 0;
  border-radius: 999px;
  background: var(--orange);
  opacity: .8;
}

/* ---------- tag filter ---------- */
.tag-card { overflow: visible; }
.tag-card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.tag-clear {
  flex: none;
  padding: 0 6px;
  border: 0;
  background: transparent;
  color: var(--text-3);
  font-size: 12px;
  cursor: pointer;
}
.tag-clear:hover { color: var(--orange); }
.tag-selected { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; max-height: 98px; overflow-y: auto; }
.tag-selected:empty { display: none; }
.tag-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  max-width: 100%;
  padding: 3px 8px;
  border: 1px solid rgba(255, 161, 22, .45);
  border-radius: 999px;
  background: var(--orange-soft);
  color: var(--text);
  font-size: 12px;
  cursor: pointer;
}
.tag-chip > span:first-child { max-width: 150px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tag-x { color: var(--text-3); font-size: 14px; line-height: 1; }
.tag-chip:hover .tag-x { color: var(--red); }
.tag-search-wrap { position: relative; }
.tag-search-box {
  display: flex;
  align-items: center;
  gap: 7px;
  height: 32px;
  padding: 0 9px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--panel);
  color: var(--text-3);
}
.tag-search-box:focus-within { border-color: var(--orange); }
.tag-search-box input {
  flex: 1;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
  font-size: 13px;
}
.tag-search-box input::placeholder { color: var(--text-3); }
.tag-suggest {
  position: absolute;
  z-index: 40;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  max-height: 260px;
  overflow-y: auto;
  padding: 4px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: 0 8px 24px rgba(0, 0, 0, .16);
}
.tag-suggest-head { padding: 5px 8px 3px; font-size: 11px; color: var(--text-3); letter-spacing: .04em; }
.tag-suggest-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  padding: 6px 8px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--text-2);
  font-size: 13px;
  text-align: left;
  cursor: pointer;
}
.tag-suggest-item:hover,
.tag-suggest-item.tag-active { background: var(--panel-2); color: var(--text); }
.tag-suggest-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tag-suggest-name mark { padding: 0 1px; border-radius: 2px; background: var(--orange-soft); color: var(--orange); }
.tag-suggest-count { flex: none; font-size: 11px; color: var(--text-3); }
.tag-suggest-empty { padding: 10px 8px; font-size: 12px; color: var(--text-3); text-align: center; }
.tag-suggest-more { padding: 5px 8px; font-size: 11px; color: var(--text-3); }
.tag-mode { display: flex; align-items: center; gap: 4px; margin-top: 8px; font-size: 12px; color: var(--text-3); }
.tag-mode-label { margin-right: 2px; }
.tag-mode button {
  height: 22px;
  padding: 0 8px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--panel);
  color: var(--text-3);
  font-size: 11px;
  cursor: pointer;
}
.tag-mode button.active { border-color: var(--orange); background: var(--orange-soft); color: var(--orange); }

/* ---------- responsive ---------- */

/* 大屏桌面 */
@media (min-width: 1500px) {
  .topbar-inner,
  .page { max-width: 1320px; }
  .layout { grid-template-columns: 240px minmax(0, 1fr); gap: 28px; }
}

/* 小笔记本 / 平板横屏 */
@media (max-width: 1024px) {
  .layout { grid-template-columns: 200px minmax(0, 1fr); gap: 20px; }
  .table-head,
  .table-row { grid-template-columns: 52px minmax(0, 1fr) 100px 76px 88px; }
}

/* 平板：侧栏变成紧凑筛选条，列表更早出现 */
@media (max-width: 900px) {
  .layout { grid-template-columns: minmax(0, 1fr); gap: 16px; }
  .sidebar {
    position: static;
    display: flex;
    flex-direction: column;
    gap: 0;
    padding: 6px 12px 8px;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
  }
  .sidebar .progress-card.side-card { display: none; }
  .sidebar .side-card {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 3px 0;
    border: 0;
    background: transparent;
    box-shadow: none;
  }
  .sidebar .side-title {
    flex: none;
    width: 30px;
    margin: 0;
    padding: 5px 0 0;
    font-size: 12px;
  }
  .sidebar .side-list {
    flex: 1;
    min-width: 0;
    flex-direction: row;
    flex-wrap: wrap;
    gap: 6px;
  }
  .sidebar .side-item {
    width: auto;
    flex: none;
    padding: 4px 10px;
    border: 1px solid transparent;
    border-radius: 999px;
    font-size: 13px;
  }
  .sidebar .side-item:hover,
  .sidebar .side-item.active { background: var(--panel-2); }
  .sidebar .side-item .count { display: none; }
  .sidebar .side-card.tag-card { display: block; padding: 6px 0 8px; }
  .sidebar .tag-card .side-title { width: auto; margin: 0; padding: 0 6px; }
  .sidebar .tag-card-head { align-items: center; }
  .sidebar .tag-selected { margin-top: 6px; }
  .problem-grid { grid-template-columns: minmax(0, 1fr); }
  .problem-side {
    order: 2;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    align-items: start;
  }
}

/* 竖屏平板 / 窄窗口：隐藏顶部导航，筛选仍在侧栏 */
@media (max-width: 760px) {
  .nav { display: none; }
  .topbar-inner { gap: 12px; }
  .db-toolbar { flex-wrap: wrap; }
  .db-toolbar .search-box { flex: 1 1 100%; max-width: none; }
}

/* 手机 */
@media (max-width: 640px) {
  .page { padding: 14px max(12px, env(safe-area-inset-left)) 0 max(12px, env(safe-area-inset-right)); }
  .topbar-inner { padding: 0 max(12px, env(safe-area-inset-right)) 0 max(12px, env(safe-area-inset-left)); gap: 12px; }
  .brand-name { font-size: 15px; }
  .head-stats { gap: 10px; }
  .nav-stat:nth-child(2) { display: none; }
  .page-head { flex-direction: column; align-items: stretch; gap: 10px; }
  .page-tools { width: 100%; }
  .search-box { width: 100%; }
  .page-tools .search-box { flex: 1; width: auto; min-width: 0; }
  .page-tools .select { max-width: none; flex: 1; min-width: 104px; }
  .pager { flex-direction: column; align-items: stretch; }
  .pg-meta { justify-content: space-between; }
  .admin-tabs { margin-top: 0; }
  .db-table-wrap { max-height: 62vh; }
  .db-table th,
  .db-table td { max-width: 220px; padding: 7px 8px; }
  .tag-search-box input { font-size: 16px; }
  .sidebar .side-card.tag-card { padding: 8px 0; }
  .tag-suggest { max-height: 200px; }

  /* 手机上标签隐藏，筛选改为三条横向滚动 chip 行，高度固定 */
  .sidebar .side-title { display: none; }
  .sidebar .side-card { padding: 2px 0; }
  .sidebar .side-list {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding-right: 16px;
    -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 16px), transparent);
    mask-image: linear-gradient(to right, #000 calc(100% - 16px), transparent);
  }
  .sidebar .side-list::-webkit-scrollbar { display: none; }
  .sidebar .side-item {
    flex: none;
    white-space: nowrap;
    border-color: var(--border);
    background: var(--panel);
  }

  /* 手机表格只保留“状态 + 题目”，元信息移到标题下方 */
  .table-head,
  .table-row { grid-template-columns: 44px minmax(0, 1fr); gap: 10px; padding: 0 12px; }
  .cell-subject,
  .cell-type,
  .cell-no { display: none; }
  .title-sub { display: block; }
  .table-row { height: auto; min-height: 62px; padding: 10px 12px; }

  .problem-side { grid-template-columns: minmax(0, 1fr); }
  .actions .btn { flex: 1; }
  .footer { flex-direction: column; align-items: center; gap: 6px; }
}

/* 超小屏：进一步压缩边距 */
@media (max-width: 360px) {
  .page { padding-top: 10px; }
  .brand-name { font-size: 14px; }
  .page-heading h1 { font-size: 21px; }
  .side-item { padding: 5px 10px; }
  .search-box { height: 32px; }
  .page-tools .btn { height: 32px; padding: 0 10px; font-size: 13px; }
  .sidebar .side-item { padding: 5px 10px; }
}

/* 触屏设备：加大点击目标 */
@media (pointer: coarse) {
  .btn { min-height: 40px; }
  .sidebar .side-item { padding: 8px 12px; }
  .option { padding: 14px; }
  .table-row { min-height: 58px; }
}

/* 手机横屏：筛选压成单行横向滚动，压缩纵向占用 */
@media (max-height: 480px) and (orientation: landscape) {
  .topbar { height: 44px; }
  .sidebar {
    flex-direction: row;
    align-items: center;
    gap: 14px;
    overflow-x: auto;
    padding: 6px 10px;
    scrollbar-width: none;
  }
  .sidebar::-webkit-scrollbar { display: none; }
  .sidebar .side-card { flex: none; padding: 0; }
  .sidebar .side-card + .side-card { border-left: 1px solid var(--border); padding-left: 14px; }
  .sidebar .side-title { display: none; }
  .sidebar .side-list { flex-wrap: nowrap; gap: 6px; }
  .sidebar .side-item { flex: none; white-space: nowrap; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

/* 新增功能：登录、统计、订正弹窗 */
@media (max-width: 760px) {
  .auth-name { display: none; }
  .head-stats { display: none; }
}

@media (max-width: 640px) {
  .auth { gap: 6px; }
  .role-badge { display: none; }
  .stat-cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat-card b { font-size: 20px; }
  .stat-table .table-head,
  .stat-table .stat-row { grid-template-columns: 92px 42px 42px minmax(0, 1fr); gap: 8px; padding: 0 10px; }
  .edit-grid,
  .options-grid { grid-template-columns: minmax(0, 1fr); }
  .modal-overlay { padding: 8px; align-items: flex-start; }
  .modal { max-height: calc(100vh - 16px); }
  .modal-body { padding: 14px; }
  .login-qr { width: 150px; height: 150px; }
  .login-code { font-size: 32px; letter-spacing: 8px; text-indent: 8px; }
}
