/* ============================================================
   菜就多练 · 网页版样式
   移动端优先，>=768px 放大为大屏布局
   ============================================================ */

:root {
  --bg: #f2f2f7;
  --bg-blur: rgba(242, 242, 247, 0.82);
  --card: #ffffff;
  --card-inset: #f7f7fa;
  --text: #101014;
  --text-2: rgba(60, 60, 67, 0.62);
  --text-3: rgba(60, 60, 67, 0.38);
  --line: rgba(60, 60, 67, 0.12);
  --chip: rgba(60, 60, 67, 0.08);

  --blue: #2e78f0;
  --orange: #f28026;
  --teal: #129e85;
  --green: #1aad61;
  --red: #e64742;
  --amber: #fa8f29;

  --radius-card: 18px;
  --radius-tile: 16px;
  --shadow-card: 0 1px 2px rgba(16, 16, 20, 0.04), 0 6px 20px rgba(16, 16, 20, 0.05);
  --shadow-btn: 0 10px 24px rgba(46, 120, 240, 0.28);

  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang SC",
          "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", system-ui, sans-serif;

  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #000000;
    --bg-blur: rgba(0, 0, 0, 0.76);
    --card: #1c1c1e;
    --card-inset: #242426;
    --text: #f5f5f7;
    --text-2: rgba(235, 235, 245, 0.62);
    --text-3: rgba(235, 235, 245, 0.34);
    --line: rgba(235, 235, 245, 0.14);
    --chip: rgba(235, 235, 245, 0.1);
    --blue: #4c8ff7;
    --orange: #f68d3c;
    --teal: #22b39a;
    --green: #2fc172;
    --red: #f2564f;
    --shadow-card: none;
  }
}

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

html, body { height: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overscroll-behavior-y: none;
}

button {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
  border: 0;
  background: none;
  padding: 0;
  cursor: pointer;
}

button:disabled { cursor: default; }

.app { min-height: 100%; }

.noscript {
  padding: 40px 24px;
  text-align: center;
  color: var(--text-2);
}

/* ---------- 通用容器 ---------- */

.wrap {
  width: 100%;
  max-width: 720px;
  margin: 0 auto;
  padding: 0 20px;
}

.card {
  background: var(--card);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
  padding: 20px;
}

.row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.divider {
  height: 1px;
  background: var(--line);
  margin: 14px 0;
}

.muted { color: var(--text-2); }
.small { font-size: 13px; }

.sr-only {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ---------- 首页 ---------- */

.home {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: calc(24px + var(--safe-t)) 20px calc(28px + var(--safe-b));
}

.home-inner {
  width: 100%;
  max-width: 700px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.home-head {
  text-align: center;
  margin-bottom: 8px;
}

.home-title {
  margin: 0;
  font-size: 42px;
  font-weight: 800;
  letter-spacing: 0.02em;
}

.home-sub {
  margin: 8px 0 0;
  font-size: 16px;
  color: var(--text-2);
}

.streak {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-top: 10px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-2);
}

.streak svg { color: var(--amber); }

.module-card {
  display: flex;
  align-items: center;
  gap: 16px;
  width: 100%;
  text-align: left;
  padding: 18px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 20px;
  box-shadow: var(--shadow-card);
  transition: transform 0.16s ease, box-shadow 0.16s ease, border-color 0.16s ease;
}

.module-card:active { transform: scale(0.985); }

@media (hover: hover) {
  .module-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 2px 4px rgba(16, 16, 20, 0.05), 0 14px 30px rgba(16, 16, 20, 0.1);
  }
}

.module-icon {
  flex: none;
  width: 60px;
  height: 60px;
  border-radius: 18px;
  display: grid;
  place-items: center;
  font-size: 30px;
  font-weight: 800;
  line-height: 1;
}

.module-body { flex: 1; min-width: 0; }

.module-title {
  margin: 0;
  font-size: 20px;
  font-weight: 650;
}

.module-sub {
  margin: 4px 0 0;
  font-size: 13.5px;
  color: var(--text-2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.module-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
  font-size: 12.5px;
  color: var(--text-2);
}

.module-meta .weak { color: var(--red); }

.module-chevron { flex: none; color: var(--text-3); display: flex; }

.home-foot {
  margin-top: 14px;
  text-align: center;
  font-size: 12.5px;
  color: var(--text-2);
}

/* ---------- 模块外壳 ---------- */

.shell {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding-top: var(--safe-t);
}

.topbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 20px 10px;
}

.pill-back {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 34px;
  padding: 0 14px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 600;
}

.topbar-title {
  flex: 1;
  text-align: center;
  font-size: 15px;
  font-weight: 600;
  color: var(--text-2);
}

.topbar-spacer { width: 72px; flex: none; }

.tabbar {
  align-self: center;
  display: inline-flex;
  gap: 4px;
  padding: 4px;
  border-radius: 999px;
  background: var(--chip);
  margin-bottom: 8px;
}

.tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: 999px;
  font-size: 14.5px;
  font-weight: 600;
  color: var(--text-2);
  transition: background 0.18s ease, color 0.18s ease;
}

.tab[aria-selected="true"] { color: #fff; }

.tab svg { opacity: 0.9; }

.view {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 8px 20px calc(28px + var(--safe-b));
}

.scroll-inner {
  width: 100%;
  max-width: 720px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* ---------- 待开始 ---------- */

.idle-head { text-align: center; margin: 10px 0 6px; }

.idle-title {
  margin: 0;
  font-size: 34px;
  font-weight: 800;
  letter-spacing: 0.01em;
}

.idle-hint { margin: 8px 0 0; font-size: 16px; color: var(--text-2); }

.field-label { font-size: 16px; color: var(--text-2); }
.field-value { font-size: 16px; font-weight: 650; }

.segmented {
  display: flex;
  gap: 2px;
  padding: 3px;
  border-radius: 11px;
  background: var(--chip);
  margin-top: 10px;
}

.seg {
  flex: 1;
  padding: 9px 6px;
  border-radius: 9px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-2);
  text-align: center;
  transition: background 0.16s ease, color 0.16s ease, box-shadow 0.16s ease;
}

.seg[aria-pressed="true"] {
  background: var(--card);
  color: var(--text);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
}

.link-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 10px;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--tint, var(--blue));
}

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

.chip {
  padding: 7px 13px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 600;
  color: var(--blue);
  background: color-mix(in srgb, var(--blue) 11%, transparent);
  transition: background 0.14s ease, color 0.14s ease, transform 0.14s ease;
}

.chip:active { transform: scale(0.96); }

.chip[aria-pressed="true"] { color: #fff; background: var(--blue); }

.chip .n { opacity: 0.7; font-size: 12px; margin-left: 4px; }

.start-wrap { display: flex; justify-content: center; margin-top: 4px; }

.btn-primary {
  height: 62px;
  min-width: 260px;
  padding: 0 44px;
  border-radius: 999px;
  background: var(--blue);
  color: #fff;
  font-size: 21px;
  font-weight: 700;
  box-shadow: 0 12px 26px color-mix(in srgb, var(--blue) 32%, transparent);
  transition: transform 0.14s ease, opacity 0.14s ease;
}

.btn-primary:active { transform: scale(0.98); }
.btn-primary:disabled { opacity: 0.45; box-shadow: none; }

.empty-note {
  text-align: center;
  font-size: 14px;
  color: var(--text-2);
  line-height: 1.6;
}

/* ---------- 答题中 ---------- */

.running {
  flex: 1;
  min-height: 0;
  width: 100%;
  max-width: 980px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  padding: 0 20px calc(24px + var(--safe-b));
}

.run-head { padding-top: 6px; }

.run-top {
  display: flex;
  align-items: center;
  gap: 12px;
}

.run-progress-text {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-2);
  white-space: nowrap;
}

.run-score {
  margin-left: auto;
  display: flex;
  align-items: baseline;
  gap: 6px;
  white-space: nowrap;
}

.run-score .label { font-size: 13px; color: var(--text-2); }
.run-score .val {
  font-size: 24px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  transition: color 0.2s ease;
}
.run-score .val.pos { color: var(--green); }
.run-score .val.neg { color: var(--red); }

.btn-quit {
  height: 28px;
  padding: 0 11px;
  border-radius: 999px;
  background: var(--chip);
  color: var(--text-2);
  font-size: 12.5px;
  font-weight: 600;
  white-space: nowrap;
}

.progress-track {
  height: 5px;
  margin-top: 12px;
  border-radius: 999px;
  background: var(--chip);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  border-radius: 999px;
  transition: width 0.28s ease;
}

.question {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 10px 0;
}

.qtext {
  max-width: 100%;
  font-weight: 800;
  line-height: 1.02;
  letter-spacing: 0.01em;
  white-space: nowrap;
  animation: qin 0.26s cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes qin {
  from { transform: scale(0.9); }
  to   { transform: scale(1); }
}

.qsub {
  display: flex;
  align-items: baseline;
  gap: 10px;
  font-size: 20px;
  color: var(--text-2);
  min-height: 26px;
}

.qsub .keyword { font-weight: 600; color: var(--text); font-size: 21px; }

.btn-hint {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 7px 14px;
  border-radius: 999px;
  background: var(--chip);
  color: var(--text-2);
  font-size: 13.5px;
  font-weight: 600;
}

.btn-listen {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 600;
  background: color-mix(in srgb, var(--blue) 12%, transparent);
  color: var(--blue);
  transition: transform 0.12s ease;
}

.btn-listen:active { transform: scale(0.95); }
.btn-listen.playing { animation: pulse 0.9s ease-in-out infinite; }

@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.04); }
}

.judge-row {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 28px;
  padding: 8px 0 4px;
}

.judge {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 132px;
  height: 132px;
  border-radius: 50%;
  color: #fff;
  font-size: 16px;
  font-weight: 700;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
  user-select: none;
}

.judge.ok {
  background: var(--green);
  box-shadow: 0 12px 26px color-mix(in srgb, var(--green) 34%, transparent);
}

.judge.no {
  background: var(--red);
  box-shadow: 0 12px 26px color-mix(in srgb, var(--red) 34%, transparent);
}

.judge:active { transform: scale(0.94); }
.judge svg { pointer-events: none; }

/* ---------- 小结 ---------- */

.summary { padding: 6px 0 10px; }

.summary-title {
  margin: 8px 0 0;
  text-align: center;
  font-size: 30px;
  font-weight: 800;
}

.big-score {
  text-align: center;
  margin: 10px 0 2px;
  font-size: 82px;
  font-weight: 800;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.big-score-label { text-align: center; font-size: 15px; color: var(--text-2); }

.tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-top: 6px; }

.tile {
  background: var(--card);
  border-radius: var(--radius-tile);
  padding: 16px 10px;
  text-align: center;
  box-shadow: var(--shadow-card);
}

.tile-num { font-size: 26px; font-weight: 800; font-variant-numeric: tabular-nums; }
.tile-label { margin-top: 4px; font-size: 12.5px; color: var(--text-2); }

.section-title { font-size: 16px; font-weight: 700; margin: 0 0 10px; }

.summary-actions {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  margin-top: 6px;
}

.btn-wide {
  width: 100%;
  max-width: 320px;
  height: 54px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: 999px;
  color: #fff;
  font-size: 17px;
  font-weight: 700;
  transition: transform 0.14s ease;
}

.btn-wide:active { transform: scale(0.98); }
.btn-wide.red { background: var(--red); box-shadow: 0 10px 22px color-mix(in srgb, var(--red) 30%, transparent); }
.btn-wide.blue { background: var(--blue); box-shadow: 0 10px 22px color-mix(in srgb, var(--blue) 30%, transparent); }

.btn-text {
  padding: 8px 4px;
  font-size: 15px;
  color: var(--text-2);
}

/* ---------- 易错页 ---------- */

.overview { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }

.ov {
  background: var(--card);
  border-radius: var(--radius-tile);
  padding: 14px 6px;
  text-align: center;
  box-shadow: var(--shadow-card);
}

.ov-num { font-size: 21px; font-weight: 800; font-variant-numeric: tabular-nums; }
.ov-label { margin-top: 3px; font-size: 11.5px; color: var(--text-2); }

.rank-list { display: flex; flex-direction: column; }

.rank-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}

.rank-row:last-child { border-bottom: 0; }

.rank-no {
  width: 16px;
  flex: none;
  font-size: 12.5px;
  font-weight: 700;
  color: var(--text-3);
  font-variant-numeric: tabular-nums;
}

.rank-word {
  width: 76px;
  flex: none;
  font-size: 22px;
  font-weight: 800;
  color: var(--red);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rank-word.word { font-size: 17px; }

.rank-info { flex: 1; min-width: 0; }
.rank-count { font-size: 12.5px; white-space: nowrap; }
.rank-group {
  font-size: 11.5px;
  color: var(--text-2);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rank-acc { font-size: 12px; color: var(--text-2); font-variant-numeric: tabular-nums; }

.btn-speak {
  flex: none;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--chip);
  color: var(--blue);
}

.btn-speak:active { transform: scale(0.92); }

.stats-empty {
  text-align: center;
  padding: 48px 20px 40px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.stats-empty svg { color: var(--green); opacity: 0.85; }
.stats-empty h3 { margin: 4px 0 0; font-size: 19px; font-weight: 700; }
.stats-empty p { margin: 0; font-size: 14px; color: var(--text-2); }

/* ---------- 设置 ---------- */

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

.step-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--chip);
  font-size: 20px;
  font-weight: 600;
  color: var(--text);
  display: grid;
  place-items: center;
}

.step-btn:active { transform: scale(0.94); }

.step-track {
  flex: 1;
  height: 6px;
  border-radius: 999px;
  background: var(--chip);
  position: relative;
  overflow: hidden;
}

.step-track .fill {
  position: absolute;
  inset: 0 auto 0 0;
  background: var(--blue);
  border-radius: 999px;
  transition: width 0.2s ease;
}

.quick-row { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }

.quick {
  min-width: 52px;
  height: 32px;
  padding: 0 14px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 600;
  color: var(--blue);
  background: color-mix(in srgb, var(--blue) 11%, transparent);
}

.quick[aria-pressed="true"] { background: var(--blue); color: #fff; }

.setting-title { font-size: 16px; font-weight: 650; margin: 0 0 8px; }

.note-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 12.5px;
  color: var(--text-2);
  line-height: 1.55;
}

.note-row svg { flex: none; margin-top: 1px; }

.btn-danger { font-size: 15px; font-weight: 600; color: var(--red); }

/* ---------- 弹层 ---------- */

.sheet-mask,
.modal-mask {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.36);
  backdrop-filter: blur(2px);
  display: flex;
  z-index: 60;
}

/* 入场动画一律只动位移 / 缩放，不动透明度；
   遮罩保持静态底色——万一动画没跑（省电模式、后台标签页、录屏），
   弹窗也不会变成半透明或隐形 */

.sheet-mask { align-items: flex-end; justify-content: center; }

@media (min-width: 720px) {
  .sheet-mask { align-items: center; }
}

.sheet {
  width: 100%;
  max-width: 720px;
  max-height: 86dvh;
  background: var(--bg);
  border-radius: 20px 20px 0 0;
  display: flex;
  flex-direction: column;
  animation: slideup 0.24s cubic-bezier(0.22, 1, 0.36, 1);
  overflow: hidden;
}

@media (min-width: 720px) {
  .sheet { border-radius: 20px; max-height: 80dvh; }
}

@keyframes slideup { from { transform: translateY(26px); } to { transform: none; } }

.sheet-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
  background: var(--bg);
}

.sheet-title { flex: 1; text-align: center; font-size: 16px; font-weight: 650; }
.sheet-done { font-size: 15px; font-weight: 650; color: var(--blue); }

.sheet-body {
  flex: 1;
  overflow-y: auto;
  padding: 18px 20px calc(24px + var(--safe-b));
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.group-name { font-size: 13.5px; font-weight: 700; color: var(--text-2); margin-bottom: 8px; }

.modal-mask { align-items: center; justify-content: center; padding: 24px; }

.modal {
  width: 100%;
  max-width: 340px;
  background: var(--card);
  border-radius: 18px;
  padding: 22px 20px 16px;
  text-align: center;
  animation: pop 0.2s cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes pop { from { transform: scale(0.94); } to { transform: none; } }

.modal h3 { margin: 0 0 8px; font-size: 17px; }
.modal p { margin: 0 0 18px; font-size: 13.5px; color: var(--text-2); line-height: 1.6; }

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

.modal-actions button {
  flex: 1;
  height: 44px;
  border-radius: 12px;
  font-size: 15px;
  font-weight: 650;
}

.modal-actions .cancel { background: var(--chip); color: var(--text); }
.modal-actions .danger { background: var(--red); color: #fff; }

/* ---------- 奖励浮层 ---------- */

.reward-mask {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  background: rgba(0, 0, 0, 0.2);
}

.reward {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 34px 44px 30px;
  border-radius: 30px;
  background: var(--card);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.22);
  animation: rewardIn 0.34s cubic-bezier(0.22, 1.2, 0.36, 1);
  text-align: center;
}

@keyframes rewardIn {
  from { transform: scale(0.6); }
  to   { transform: scale(1); }
}

.reward-icon { line-height: 1; }
.reward-title { font-size: 28px; font-weight: 800; }
.reward-sub { font-size: 16px; font-weight: 500; color: var(--text-2); }

/* ---------- 大屏适配 ---------- */

@media (min-width: 768px) {
  .wrap, .scroll-inner { max-width: 760px; }
  .home-inner { max-width: 760px; gap: 18px; }
  .home-title { font-size: 54px; }
  .home-sub { font-size: 17px; }
  .module-card { padding: 22px; }
  .module-icon { width: 66px; height: 66px; font-size: 33px; }
  .module-title { font-size: 22px; }
  .module-sub { font-size: 14px; }
  .idle-title { font-size: 38px; }
  .judge { width: 168px; height: 168px; font-size: 19px; gap: 10px; }
  .judge svg { width: 46px; height: 46px; }
  .judge-row { gap: 100px; }
  .qsub { font-size: 21px; }
  .big-score { font-size: 92px; }
  .btn-primary { height: 66px; font-size: 23px; min-width: 300px; }
  .rank-word { width: 130px; font-size: 28px; }
  .rank-word.word { font-size: 20px; }
}

@media (min-width: 1100px) {
  .wrap, .scroll-inner { max-width: 860px; }
  .home-inner { max-width: 820px; }
  .judge-row { gap: 130px; }
  .judge { width: 196px; height: 196px; font-size: 21px; }
  .judge svg { width: 54px; height: 54px; }
}

/* 超窄屏（iPhone SE 等 320px）压缩按钮尺寸，避免挤压变形 */
@media (max-width: 360px) {
  .judge { width: 112px; height: 112px; font-size: 14px; gap: 6px; }
  .judge svg { width: 30px; height: 30px; }
  .judge-row { gap: 20px; }
  .home-title { font-size: 34px; }
  .idle-title { font-size: 28px; }
  .run-score .val { font-size: 20px; }
  .btn-primary { min-width: 220px; font-size: 19px; height: 56px; }
}

/* 横屏矮窗口时压缩竖向留白，避免答题页溢出 */
@media (max-height: 560px) and (min-width: 640px) {
  .question { gap: 6px; padding: 4px 0; }
  .judge { width: 108px; height: 108px; font-size: 14px; gap: 4px; }
  .judge svg { width: 30px; height: 30px; }
  .judge-row { padding: 2px 0; }
  .run-head { padding-top: 0; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

/* ============================================================
   账号 / 登录 / 账号管理
   ============================================================ */

/* ---------- 启动占位 ---------- */

.boot {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-2);
  font-size: 14px;
}

/* ---------- 登录页 ---------- */

.auth {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: calc(28px + var(--safe-t)) 20px calc(28px + var(--safe-b));
}

.auth-card {
  width: 100%;
  max-width: 392px;
  background: var(--card);
  border-radius: 24px;
  box-shadow: var(--shadow-card);
  padding: 32px 26px 24px;
}

.auth-logo {
  display: block;
  width: 64px;
  height: 64px;
  border-radius: 16px;
  margin: 0 auto 16px;
  box-shadow: 0 8px 20px rgba(46, 120, 240, 0.22);
}

.auth-title {
  margin: 0;
  text-align: center;
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -0.5px;
}

.auth-sub {
  margin: 6px 0 22px;
  text-align: center;
  font-size: 13.5px;
  color: var(--text-2);
}

.form { display: flex; flex-direction: column; gap: 12px; }

.input-wrap { position: relative; }

.input {
  width: 100%;
  height: 52px;
  padding: 0 16px;
  border-radius: 14px;
  background: var(--card-inset);
  border: 1.5px solid transparent;
  font-size: 16px;
  color: var(--text);
  font-family: inherit;
  transition: border-color 0.16s ease, background 0.16s ease;
}

.input:focus { outline: none; border-color: var(--blue); background: var(--card); }
.input::placeholder { color: var(--text-3); }

.input-wrap .input { padding-right: 64px; }

.input-eye {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  padding: 6px 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-2);
}

.btn-login {
  width: 100%;
  height: 52px;
  margin-top: 4px;
  border-radius: 14px;
  background: var(--blue);
  color: #fff;
  font-size: 17px;
  font-weight: 700;
  box-shadow: 0 10px 22px rgba(46, 120, 240, 0.28);
  transition: transform 0.14s ease, opacity 0.14s ease;
}

.btn-login:active { transform: scale(0.985); }
.btn-login:disabled { opacity: 0.6; box-shadow: none; }

.form-err {
  min-height: 18px;
  font-size: 13px;
  color: var(--red);
  text-align: center;
  line-height: 1.4;
}

.auth-foot {
  margin: 18px 0 0;
  text-align: center;
  font-size: 12.5px;
  color: var(--text-3);
  line-height: 1.6;
}

.auth-tip {
  margin-top: 16px;
  padding: 12px 14px;
  border-radius: 12px;
  background: var(--card-inset);
  font-size: 12.5px;
  color: var(--text-2);
  line-height: 1.6;
}

/* ---------- 首页右上角账号 ---------- */

.home-user {
  position: fixed;
  top: calc(14px + var(--safe-t));
  right: 16px;
  z-index: 30;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 36px;
  padding: 0 12px 0 4px;
  border-radius: 999px;
  background: var(--card);
  box-shadow: var(--shadow-card);
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text);
}

.avatar {
  width: 28px;
  height: 28px;
  flex: none;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(140deg, #5b9bf8, #2e78f0);
  color: #fff;
  font-size: 13px;
  font-weight: 700;
}

.home-user-name {
  max-width: 96px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.banner {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 12px 16px;
  border-radius: 14px;
  background: color-mix(in srgb, var(--amber) 14%, transparent);
  text-align: left;
}

.banner-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--amber); flex: none; }

.banner-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 12.5px;
  color: var(--text-2);
  line-height: 1.4;
}

.banner-text b { font-size: 13.5px; font-weight: 650; color: var(--text); }

/* ---------- 账号面板 ---------- */

.account-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 2px 2px 14px;
  border-bottom: 1px solid var(--line);
}

.account-head .avatar { width: 46px; height: 46px; font-size: 18px; }
.account-name { font-size: 17px; font-weight: 700; }
.account-role { font-size: 12.5px; color: var(--text-2); margin-top: 2px; }

.sheet-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 16px 2px;
  border-bottom: 1px solid var(--line);
  text-align: left;
}

.sheet-item:last-child { border-bottom: 0; }
.sheet-item-main { flex: 1; min-width: 0; }
.sheet-item-title { font-size: 15.5px; font-weight: 600; }
.sheet-item-sub { font-size: 12.5px; color: var(--text-2); margin-top: 2px; }
.sheet-item.danger .sheet-item-title { color: var(--red); }

/* ---------- 账号管理 ---------- */

.admin-form { display: flex; flex-direction: column; gap: 12px; margin-top: 14px; }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

@media (max-width: 640px) {
  .form-grid { grid-template-columns: 1fr; }
}

.btn-solid {
  height: 46px;
  padding: 0 20px;
  border-radius: 12px;
  background: var(--blue);
  color: #fff;
  font-size: 15px;
  font-weight: 650;
}

.btn-solid:disabled { opacity: 0.55; }

.btn-ghost {
  height: 46px;
  padding: 0 20px;
  border-radius: 12px;
  background: var(--chip);
  color: var(--text);
  font-size: 15px;
  font-weight: 650;
}

.user-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
}

.user-row:last-child { border-bottom: 0; }

.user-main { flex: 1; min-width: 0; }

.user-name {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  font-size: 15.5px;
  font-weight: 650;
}

.user-meta {
  margin-top: 4px;
  font-size: 12.5px;
  color: var(--text-2);
  line-height: 1.5;
}

.user-actions {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
  flex: none;
}

.mini-btn {
  padding: 4px 2px;
  font-size: 13px;
  font-weight: 600;
  color: var(--blue);
}

.mini-btn.danger { color: var(--red); }
.mini-btn:disabled { color: var(--text-3); }

.badge {
  padding: 2px 7px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  background: color-mix(in srgb, var(--blue) 13%, transparent);
  color: var(--blue);
}

.badge.admin { background: color-mix(in srgb, var(--orange) 15%, transparent); color: var(--orange); }
.badge.me { background: var(--chip); color: var(--text-2); }

/* ---------- 弹窗里的表单 ---------- */

.modal .input { height: 46px; margin-bottom: 10px; text-align: left; font-size: 15px; }
.modal .form-err { margin: -2px 0 8px; }

.pw-view {
  margin: 4px 0 16px;
  padding: 14px;
  border-radius: 12px;
  background: var(--card-inset);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 23px;
  font-weight: 700;
  letter-spacing: 2px;
  word-break: break-all;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(30px + var(--safe-b));
  transform: translateX(-50%);
  z-index: 90;
  padding: 10px 18px;
  border-radius: 999px;
  background: rgba(20, 20, 22, 0.9);
  color: #fff;
  font-size: 13.5px;
  transition: opacity 0.3s ease;
}

.toast.out { opacity: 0; }

/* 窄屏下账号行：操作按钮换到第二行，避免挤压账号名 */
@media (max-width: 480px) {
  .user-row { flex-wrap: wrap; }
  .user-actions {
    flex-direction: row;
    gap: 18px;
    width: 100%;
    justify-content: flex-end;
  }
}

.modal-actions .primary { background: var(--blue); color: #fff; }
