/* ============================================================
 * styles.css — 法规业务答题系统 原型共享样式层
 * 设计方向：清爽现代（clean modern）· 亮蓝主色 × 琥珀点缀 × 浅灰底
 * 所有页面必须只引用本文件中的令牌与组件类，不得另造颜色/字号/圆角
 * ============================================================ */

/* ---------- 1. Tokens ---------- */
:root {
  /* color */
  --c-primary:      #0B5FFF;
  --c-primary-hover:#0847C7;
  --c-primary-soft: #EBF1FF;
  --c-accent:       #F5A524;
  --c-accent-soft:  #FFF4E0;
  --c-bg:           #F5F7FA;
  --c-surface:      #FFFFFF;
  --c-surface-2:    #F8FAFC;
  --c-border:       #E8ECF1;
  --c-border-strong:#D6DCE5;
  --c-text:         #111827;
  --c-text-sub:     #5B6472;
  --c-text-muted:   #9AA3B2;
  --c-success:      #12A150;
  --c-success-soft: #E8F7EF;
  --c-warning:      #F5A524;
  --c-warning-soft: #FFF4E0;
  --c-danger:       #E5484D;
  --c-danger-soft:  #FDECEC;
  --c-info:         #0B5FFF;
  --c-info-soft:    #EBF1FF;

  /* font */
  --font-display: "PingFang SC", "HarmonyOS Sans SC", "Microsoft YaHei UI", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  --font-body:    "PingFang SC", "HarmonyOS Sans SC", "Microsoft YaHei UI", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  --font-mono:    "JetBrains Mono", "Cascadia Mono", "Consolas", "Courier New", monospace;

  /* radius / shadow */
  --r-sm: 8px;  --r-md: 12px;  --r-lg: 16px;  --r-pill: 999px;
  --sh-sm: 0 1px 2px rgba(16,24,40,.04);
  --sh-md: 0 6px 20px rgba(16,24,40,.08);
  --sh-lg: 0 20px 48px rgba(16,24,40,.14);

  /* spacing (4px base) */
  --s1:4px; --s2:8px; --s3:12px; --s4:16px; --s5:24px; --s6:32px; --s7:48px; --s8:64px;

  /* layout */
  --sidebar-w: 248px;
  --topbar-h: 64px;
  --content-max: 1240px;

  /* icon */
  --ic-stroke: 1.75;

  /* motion */
  --ease: cubic-bezier(.22,.61,.36,1);
}

/* ---------- 2. Base ---------- */
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1.6;
  color: var(--c-text);
  background-color: var(--c-bg);
  background-image:
    radial-gradient(1100px 620px at 8% -12%, rgba(11,95,255,.055), transparent 62%),
    radial-gradient(920px 520px at 100% 0%, rgba(245,165,36,.045), transparent 58%),
    radial-gradient(760px 560px at 50% 120%, rgba(11,95,255,.03), transparent 60%);
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }
h1,h2,h3,h4 { margin: 0; font-family: var(--font-display); font-weight: 700; letter-spacing: -.2px; }
p { margin: 0; }
ul { margin: 0; padding: 0; list-style: none; }
button, input, select, textarea { font: inherit; color: inherit; }
::selection { background: var(--c-accent-soft); }

/* ---------- 3. Typography ---------- */
.h1 { font-size: 32px; line-height: 1.25; }
.h2 { font-size: 24px; line-height: 1.3; }
.h3 { font-size: 20px; line-height: 1.35; }
.h4 { font-size: 16px; line-height: 1.4; font-family: var(--font-body); font-weight: 700; }
.lede { font-size: 16px; color: var(--c-text-sub); }
.sub  { font-size: 13px; color: var(--c-text-sub); }
.muted{ color: var(--c-text-muted); }
.mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.label {
  font-size: 12px; letter-spacing: 1.2px; text-transform: uppercase;
  color: var(--c-text-muted); font-weight: 700;
}
.serif { font-family: var(--font-display); }

/* ---------- 4. App Shell ---------- */
.app-topbar {
  position: fixed;
  top: 0; right: 0; left: var(--sidebar-w);
  inset: 0 0 auto var(--sidebar-w); height: var(--topbar-h); z-index: 40;
  display: flex; align-items: center; gap: var(--s4);
  padding: 0 var(--s5);
  background: rgba(255,255,255,.86);
  backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--c-border);
}
.app-nav {
  position: fixed;
  top: 0; bottom: 0; left: 0;
  inset: 0 auto 0 0; width: var(--sidebar-w); z-index: 50;
  display: flex; flex-direction: column;
  background: var(--c-surface);
  color: var(--c-text-sub);
  border-right: 1px solid var(--c-border);
  padding: var(--s4) var(--s3);
}
.app-content {
  margin-left: var(--sidebar-w);
  padding: calc(var(--topbar-h) + var(--s5)) var(--s5) var(--s7);
  min-height: 100vh;
}
.page { max-width: var(--content-max); margin: 0 auto; }
.nav-scrim {
  position: fixed;
  top: 0; right: 0; bottom: 0; left: 0;
  inset: 0; z-index: 45; background: rgba(17,24,39,.42);
  opacity: 0; pointer-events: none; transition: opacity .22s var(--ease);
}
.brand { display: flex; align-items: center; gap: var(--s3); }
.brand-mark {
  width: 34px; height: 34px; border-radius: var(--r-sm); flex: none;
  display: grid; place-items: center;
  background: linear-gradient(135deg, var(--c-primary), var(--c-accent)); color: #fff;
  font-family: var(--font-display); font-size: 18px; font-weight: 700;
  box-shadow: var(--sh-sm);
}
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-text strong { font-size: 14px; letter-spacing: .4px; }
.brand-text em { font-style: normal; font-size: 11px; color: var(--c-text-muted); letter-spacing: 1px; }
.app-topbar .brand-text strong { color: var(--c-text); }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: var(--s4); }
.topbar-clock { font-family: var(--font-mono); font-size: 13px; color: var(--c-text-sub); }
.user-chip { display: flex; align-items: center; gap: var(--s2); padding-left: var(--s4); border-left: 1px solid var(--c-border); }
.avatar {
  width: 30px; height: 30px; border-radius: 50%; flex: none;
  display: grid; place-items: center; background: var(--c-primary-soft); color: var(--c-primary);
  font-size: 13px; font-weight: 700;
}
.user-meta { display: flex; flex-direction: column; line-height: 1.2; }
.user-meta b { font-size: 13px; }
.user-meta em { font-style: normal; font-size: 11px; color: var(--c-text-muted); font-family: var(--font-mono); }
.switch-role {
  display: inline-flex; align-items: center; gap: 6px; font-size: 12px;
  padding: 6px 10px; border: 1px solid var(--c-border-strong); border-radius: var(--r-pill);
  color: var(--c-text-sub);
}
.switch-role:hover { color: var(--c-primary); border-color: var(--c-primary); background: var(--c-primary-soft); }
.nav-toggle {
  display: none; background: transparent; border: 0; padding: 4px; cursor: pointer;
  color: var(--c-text); border-radius: var(--r-sm);
}
.nav-list { display: flex; flex-direction: column; gap: 2px; margin-top: var(--s3); }
.nav-item {
  display: flex; align-items: center; gap: var(--s3);
  padding: 10px var(--s3); border-radius: var(--r-sm);
  color: var(--c-text-sub); font-size: 14px;
  border-left: 3px solid transparent;
  transition: background .16s var(--ease), color .16s var(--ease), border-color .16s var(--ease);
}
.nav-item:hover { background: var(--c-surface-2); color: var(--c-text); }
.nav-item.active {
  background: var(--c-primary-soft); color: var(--c-primary);
  border-left-color: var(--c-primary); font-weight: 700;
}
.nav-item .ic { opacity: .92; }
.nav-foot {
  margin-top: auto; padding: var(--s4) var(--s3) var(--s2);
  border-top: 1px solid var(--c-border);
}
.nav-foot-title { font-size: 11px; letter-spacing: 1.4px; text-transform: uppercase; color: var(--c-text-muted); margin-bottom: var(--s2); }
.nav-foot-row { display: flex; justify-content: space-between; font-size: 12px; color: var(--c-text-sub); padding: 3px 0; }
.nav-foot-row b { font-family: var(--font-mono); color: var(--c-text); }

/* ---------- 5. Page scaffolding ---------- */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--s4); margin-bottom: var(--s5); flex-wrap: wrap; }
.page-head .eyebrow { font-size: 12px; letter-spacing: 1.4px; text-transform: uppercase; color: var(--c-primary); font-weight: 700; margin-bottom: 6px; }
.page-head h1 { font-size: 28px; }
.page-head .page-desc { color: var(--c-text-sub); margin-top: 6px; max-width: 62ch; }
.sec-title { display: flex; align-items: center; gap: var(--s2); margin: var(--s6) 0 var(--s4); }
.sec-title h2 { font-size: 18px; font-family: var(--font-body); font-weight: 700; }
.sec-title .rule { flex: 1; height: 1px; background: var(--c-border); }
.grid { display: grid; gap: var(--s4); }
.grid-2 { grid-template-columns: repeat(2, minmax(0,1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0,1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0,1fr)); }
.split { display: grid; grid-template-columns: minmax(0,1fr) 320px; gap: var(--s4); align-items: start; }
.stack { display: flex; flex-direction: column; gap: var(--s4); }
.stack-sm { display: flex; flex-direction: column; gap: var(--s2); }
.row { display: flex; align-items: center; gap: var(--s3); }
.row-wrap { display: flex; align-items: center; gap: var(--s3); flex-wrap: wrap; }
.spacer { flex: 1; }

/* ---------- 6. Components ---------- */
.card {
  background: var(--c-surface); border: 1px solid var(--c-border); border-radius: var(--r-md);
  padding: var(--s5); box-shadow: var(--sh-sm);
}
.card-flat { background: var(--c-surface); border: 1px solid var(--c-border); border-radius: var(--r-md); }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); margin-bottom: var(--s4); }
.card-head h3 { font-size: 16px; font-family: var(--font-body); font-weight: 700; }
.card-head .sub { margin-top: 2px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 9px 16px; border-radius: var(--r-sm); border: 1px solid var(--c-border-strong);
  background: var(--c-surface); color: var(--c-text); cursor: pointer;
  font-size: 14px; font-weight: 600; white-space: nowrap;
  transition: background .16s var(--ease), border-color .16s var(--ease), color .16s var(--ease), box-shadow .16s var(--ease), transform .1s var(--ease);
}
.btn:hover { border-color: var(--c-primary); color: var(--c-primary); background: var(--c-primary-soft); }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: 2px solid var(--c-primary); outline-offset: 2px; }
.btn[disabled], .btn.is-disabled { opacity: .45; cursor: not-allowed; transform: none; }
.btn.primary { background: var(--c-primary); border-color: var(--c-primary); color: #fff; box-shadow: 0 2px 8px rgba(11,95,255,.24); }
.btn.primary:hover { background: var(--c-primary-hover); border-color: var(--c-primary-hover); color: #fff; box-shadow: 0 3px 10px rgba(11,95,255,.28); }
.btn.primary:active { background: var(--c-primary-hover); box-shadow: 0 1px 3px rgba(11,95,255,.20); }
.btn.accent { background: var(--c-accent); border-color: var(--c-accent); color: var(--c-text); }
.btn.accent:hover { background: var(--c-accent); border-color: var(--c-accent); color: var(--c-text); filter: brightness(.94); }
.btn.accent:active { filter: brightness(.88); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--c-text-sub); }
.btn.ghost:hover { background: var(--c-primary-soft); color: var(--c-primary); border-color: transparent; }
.btn.danger { color: var(--c-danger); border-color: transparent; background: var(--c-danger-soft); }
.btn.danger:hover { background: var(--c-danger); color: #fff; border-color: var(--c-danger); }
.btn.sm { padding: 6px 11px; font-size: 13px; }
.btn.lg { padding: 13px 24px; font-size: 16px; }
.btn.full { width: 100%; }

.input, .select, .textarea {
  width: 100%; padding: 9px 12px; background: var(--c-surface);
  border: 1px solid var(--c-border-strong); border-radius: var(--r-sm);
  font-size: 14px; transition: border-color .16s var(--ease), box-shadow .16s var(--ease);
}
.input:focus, .select:focus, .textarea:focus {
  outline: none; border-color: var(--c-primary); box-shadow: 0 0 0 3px rgba(11,95,255,.15);
}
.input[disabled], .select[disabled] { background: var(--c-surface-2); color: var(--c-text-muted); }
.textarea { min-height: 84px; resize: vertical; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field > label { font-size: 13px; font-weight: 600; color: var(--c-text-sub); }
.field .hint { font-size: 12px; color: var(--c-text-muted); }
.field .err { font-size: 12px; color: var(--c-danger); }

.tag {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px; border-radius: var(--r-pill); font-size: 12px; font-weight: 600;
  background: var(--c-surface-2); border: 1px solid var(--c-border); color: var(--c-text-sub);
}
.tag.primary { background: var(--c-primary-soft); border-color: transparent; color: var(--c-primary); }
.tag.accent  { background: var(--c-accent-soft); border-color: transparent; color: var(--c-text); }
.tag.success { background: var(--c-success-soft); border-color: transparent; color: var(--c-success); }
.tag.warning { background: var(--c-warning-soft); border-color: transparent; color: var(--c-text); }
.tag.danger  { background: var(--c-danger-soft); border-color: transparent; color: var(--c-danger); }
.tag.info    { background: var(--c-info-soft); border-color: transparent; color: var(--c-primary); }
.dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th {
  text-align: left; font-size: 12px; letter-spacing: .6px; text-transform: uppercase;
  color: var(--c-text-muted); font-weight: 700; padding: 10px 12px;
  background: var(--c-surface-2); border-bottom: 1px solid var(--c-border); white-space: nowrap;
}
.table td { padding: 11px 12px; border-bottom: 1px solid var(--c-border); vertical-align: middle; }
.table tbody tr { transition: background .14s var(--ease); }
.table tbody tr:hover { background: var(--c-surface-2); }
.table .num { font-family: var(--font-mono); text-align: right; }
.table-wrap { overflow-x: auto; border: 1px solid var(--c-border); border-radius: var(--r-md); background: var(--c-surface); }
.table-wrap .table { min-width: 640px; }

.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--c-border); margin-bottom: var(--s5); flex-wrap: wrap; }
.tab {
  padding: 9px 14px; font-size: 14px; color: var(--c-text-sub); cursor: pointer;
  border: 0; background: transparent; border-bottom: 2px solid transparent; font-weight: 600;
}
.tab:hover { color: var(--c-primary); }
.tab.active { color: var(--c-primary); border-bottom-color: var(--c-primary); }
.pane { display: none; }
.pane.active { display: block; animation: riseIn .38s var(--ease) both; }

.progress { height: 8px; border-radius: var(--r-pill); background: var(--c-surface-2); border: 1px solid var(--c-border); overflow: hidden; }
.progress > i { display: block; height: 100%; background: linear-gradient(90deg, var(--c-primary), var(--c-primary-hover)); }
.progress.accent > i { background: linear-gradient(90deg, var(--c-accent), var(--c-primary)); }
.progress.thin { height: 5px; }

.kpi { display: flex; flex-direction: column; gap: 4px; }
.kpi .kpi-val { font-family: var(--font-display); font-size: 30px; line-height: 1.1; }
.kpi .kpi-val small { font-size: 14px; color: var(--c-text-muted); margin-left: 4px; }
.kpi .kpi-key { font-size: 12px; color: var(--c-text-sub); letter-spacing: .4px; }
.kpi-delta { font-size: 12px; font-family: var(--font-mono); }
.kpi-delta.up { color: var(--c-success); }
.kpi-delta.down { color: var(--c-danger); }

.empty {
  text-align: center; padding: var(--s7) var(--s5); color: var(--c-text-muted);
  border: 1px dashed var(--c-border-strong); border-radius: var(--r-md); background: var(--c-surface-2);
}
.empty .ic { color: var(--c-border-strong); margin-bottom: var(--s3); }
.empty h4 { color: var(--c-text-sub); margin-bottom: 4px; }

.skeleton {
  background: linear-gradient(90deg, var(--c-surface-2) 25%, var(--c-border) 37%, var(--c-surface-2) 63%);
  background-size: 400% 100%; animation: shimmer 1.3s infinite; border-radius: var(--r-sm); height: 14px;
}
@keyframes shimmer { 0% { background-position: 100% 0; } 100% { background-position: 0 0; } }

.modal-backdrop {
  position: fixed;
  top: 0; right: 0; bottom: 0; left: 0;
  inset: 0; z-index: 80; background: rgba(17,24,39,.46);
  display: none; place-items: center; padding: var(--s5); backdrop-filter: blur(2px);
}
.modal-backdrop.open { display: grid; }
.modal {
  width: 560px; max-width: 100%;
  width: min(560px, 100%); background: var(--c-surface); border-radius: var(--r-lg);
  box-shadow: var(--sh-lg); border: 1px solid var(--c-border); overflow: hidden;
  animation: riseIn .28s var(--ease) both;
}
.modal-head { padding: var(--s5) var(--s5) var(--s3); display: flex; align-items: flex-start; gap: var(--s3); }
.modal-head h3 { font-size: 18px; font-family: var(--font-body); }
.modal-body { padding: 0 var(--s5) var(--s5); color: var(--c-text-sub); }
.modal-foot { padding: var(--s4) var(--s5); background: var(--c-surface-2); border-top: 1px solid var(--c-border); display: flex; justify-content: flex-end; gap: var(--s2); }
.modal-wide { width: 880px; max-width: 100%; width: min(880px, 100%); }

.toast {
  position: fixed; left: 50%; bottom: 32px; transform: translate(-50%, 16px);
  z-index: 90; background: var(--c-text); color: #fff; padding: 11px 18px; border-radius: var(--r-pill);
  box-shadow: var(--sh-lg); font-size: 13px; display: flex; align-items: center; gap: 8px;
  opacity: 0; pointer-events: none; transition: opacity .22s var(--ease), transform .22s var(--ease);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

.divider { height: 1px; background: var(--c-border); margin: var(--s4) 0; }
.list-row {
  display: flex; align-items: center; gap: var(--s3);
  padding: var(--s3) var(--s4); border-bottom: 1px solid var(--c-border);
  transition: background .14s var(--ease);
}
.list-row:last-child { border-bottom: 0; }
.list-row:hover { background: var(--c-surface-2); }
.list-row .idx { font-family: var(--font-mono); color: var(--c-text-muted); width: 28px; flex: none; }

/* ---------- 7. Domain components ---------- */
.mode-card {
  position: relative; display: flex; flex-direction: column; gap: var(--s3);
  padding: var(--s5); background: var(--c-surface); border: 1px solid var(--c-border);
  border-radius: var(--r-md); box-shadow: var(--sh-sm); overflow: hidden;
  transition: transform .18s var(--ease), box-shadow .18s var(--ease), border-color .18s var(--ease);
}
.mode-card::after {
  content: ""; position: absolute;
  top: 0; right: 0; left: 0;
  inset: 0 0 auto 0; height: 2px;
  border-radius: var(--r-md) var(--r-md) 0 0;
  background: linear-gradient(90deg, var(--c-primary), var(--c-accent));
  opacity: 0; transition: opacity .18s var(--ease); pointer-events: none;
}
.mode-card:hover { transform: translateY(-2px); box-shadow: var(--sh-md); border-color: var(--c-border-strong); }
.mode-card:hover::after { opacity: 1; }
.mode-card .mode-ic {
  width: 40px; height: 40px; border-radius: var(--r-sm); display: grid; place-items: center;
  background: var(--c-primary-soft); color: var(--c-primary);
}
.mode-card h3 { font-size: 17px; font-family: var(--font-body); font-weight: 700; }
.mode-card p { font-size: 13px; color: var(--c-text-sub); }
.mode-meta { display: flex; gap: var(--s3); font-size: 12px; color: var(--c-text-muted); font-family: var(--font-mono); }

.timer {
  display: inline-flex; align-items: center; gap: 7px;
  font-family: var(--font-mono); font-size: 20px; font-weight: 600;
  padding: 6px 12px; border-radius: var(--r-sm); border: 1px solid var(--c-border-strong);
  background: var(--c-surface); color: var(--c-text);
}
.timer.warn { color: var(--c-danger); border-color: transparent; background: var(--c-danger-soft); animation: pulse 1.2s infinite; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .62; } }

.diff-stars { display: inline-flex; gap: 2px; color: var(--c-accent); }
.diff-stars .off { color: var(--c-border-strong); }

.q-wrap { display: grid; grid-template-columns: minmax(0,1fr) 280px; gap: var(--s5); align-items: start; }
.q-card { background: var(--c-surface); border: 1px solid var(--c-border); border-radius: var(--r-md); padding: var(--s5) var(--s5) var(--s4); box-shadow: var(--sh-sm); }
.q-head { display: flex; align-items: center; gap: var(--s3); margin-bottom: var(--s4); flex-wrap: wrap; }
.q-no { font-family: var(--font-display); font-size: 22px; }
.q-stem { font-size: 17px; line-height: 1.75; margin-bottom: var(--s5); }
.opt {
  display: flex; align-items: flex-start; gap: var(--s3);
  padding: 13px var(--s4); border: 1px solid var(--c-border); border-radius: var(--r-sm);
  background: var(--c-surface); cursor: pointer; margin-bottom: var(--s2);
  transition: border-color .15s var(--ease), background .15s var(--ease), box-shadow .15s var(--ease);
}
.opt:hover { border-color: var(--c-primary); background: var(--c-primary-soft); }
.opt .key {
  width: 24px; height: 24px; flex: none; border-radius: var(--r-sm); display: grid; place-items: center;
  background: var(--c-surface-2); border: 1px solid var(--c-border-strong);
  font-family: var(--font-mono); font-size: 13px; font-weight: 700; color: var(--c-text-sub);
}
.opt.sel { border-color: var(--c-primary); background: var(--c-primary-soft); box-shadow: 0 0 0 2px rgba(11,95,255,.15); }
.opt.sel .key { background: var(--c-primary); border-color: var(--c-primary); color: #fff; }
.opt.correct { border-color: var(--c-success); background: var(--c-success-soft); }
.opt.correct .key { background: var(--c-success); border-color: var(--c-success); color: #fff; }
.opt.wrong { border-color: var(--c-danger); background: var(--c-danger-soft); }
.opt.wrong .key { background: var(--c-danger); border-color: var(--c-danger); color: #fff; }
.opt:not(.sel):not(.correct):not(.wrong):hover .key { border-color: var(--c-primary); }

.answer-sheet { background: var(--c-surface); border: 1px solid var(--c-border); border-radius: var(--r-md); padding: var(--s4); box-shadow: var(--sh-sm); }
.sheet-grid { display: grid; grid-template-columns: repeat(8, 1fr); gap: 6px; margin-top: var(--s3); }
.sheet-cell {
  aspect-ratio: 1; display: grid; place-items: center; border-radius: var(--r-sm);
  border: 1px solid var(--c-border-strong); background: var(--c-surface);
  font-family: var(--font-mono); font-size: 12px; cursor: pointer; color: var(--c-text-sub);
}
.sheet-cell:hover { border-color: var(--c-primary); color: var(--c-primary); }
.sheet-cell.done { background: var(--c-primary-soft); border-color: transparent; color: var(--c-primary); }
.sheet-cell.marked { border-color: var(--c-accent); background: var(--c-accent-soft); color: var(--c-text); }
.sheet-cell.current { background: var(--c-primary); border-color: var(--c-primary); color: #fff; }

.rank-table .rank-no { font-family: var(--font-display); font-size: 18px; width: 44px; }
.rank-table tr.me { background: var(--c-accent-soft); }
.rank-table tr.me td { font-weight: 700; }
.medal { color: var(--c-accent); }

.ruin-hp { display: flex; gap: 4px; }
.ruin-hp i { width: 18px; height: 6px; border-radius: 2px; background: var(--c-success); }
.ruin-hp i.lost { background: var(--c-border-strong); }
.ruin-count { font-family: var(--font-display); font-size: 44px; line-height: 1; }

.filter-bar {
  display: flex; gap: var(--s3); flex-wrap: wrap; align-items: flex-end;
  padding: var(--s4); background: var(--c-surface); border: 1px solid var(--c-border);
  border-radius: var(--r-md); box-shadow: var(--sh-sm);
}
.filter-bar .field { min-width: 150px; }

.stage {
  display: flex; align-items: center; gap: var(--s4);
  padding: var(--s4); border: 1px solid var(--c-border); border-radius: var(--r-md);
  background: var(--c-surface); margin-bottom: var(--s2);
}
.stage .stage-no {
  width: 46px; height: 46px; flex: none; border-radius: var(--r-sm); display: grid; place-items: center;
  background: var(--c-surface-2); border: 1px solid var(--c-border-strong);
  font-family: var(--font-display); font-size: 20px;
}
.stage.active { border-color: var(--c-primary); box-shadow: 0 0 0 2px rgba(11,95,255,.15); }
.stage.active .stage-no { background: var(--c-primary); border-color: var(--c-primary); color: #fff; }
.stage.done .stage-no { background: var(--c-success-soft); border-color: transparent; color: var(--c-success); }

.bar-chart { display: flex; align-items: flex-end; gap: var(--s2); height: 132px; padding-top: var(--s3); }
.bar-chart .bar { flex: 1; background: linear-gradient(180deg, var(--c-primary), var(--c-primary-hover)); border-radius: 3px 3px 0 0; position: relative; min-height: 3px; transition: filter .16s var(--ease); }
.bar-chart .bar:hover { filter: brightness(1.12); }
.bar-chart .bar span { position: absolute; top: -18px; left: 50%; transform: translateX(-50%); font-family: var(--font-mono); font-size: 11px; color: var(--c-text-sub); }
.bar-axis { display: flex; gap: var(--s2); margin-top: 6px; }
.bar-axis span { flex: 1; text-align: center; font-size: 11px; color: var(--c-text-muted); }

.notice {
  display: flex; gap: var(--s3); padding: var(--s4);
  border-radius: var(--r-md); border: 1px solid var(--c-border); background: var(--c-surface-2);
  font-size: 13px; color: var(--c-text-sub);
}
.notice.info { background: var(--c-info-soft); border-color: transparent; }
.notice.warn { background: var(--c-warning-soft); border-color: transparent; }
.notice.danger { background: var(--c-danger-soft); border-color: transparent; }
.notice .ic { flex: none; margin-top: 2px; }

.keypoint { display: inline-flex; align-items: center; gap: 6px; color: var(--c-accent); font-size: 13px; font-weight: 700; cursor: pointer; }
.keypoint.on { color: var(--c-accent); }
.keypoint:not(.on) { color: var(--c-text-muted); font-weight: 500; }

/* ---------- 8. Motion ---------- */
@keyframes riseIn { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
.stagger > * { animation: riseIn .5s var(--ease) both; }
.stagger > *:nth-child(1) { animation-delay: .04s; }
.stagger > *:nth-child(2) { animation-delay: .10s; }
.stagger > *:nth-child(3) { animation-delay: .16s; }
.stagger > *:nth-child(4) { animation-delay: .22s; }
.stagger > *:nth-child(5) { animation-delay: .28s; }
.stagger > *:nth-child(6) { animation-delay: .34s; }
.stagger > *:nth-child(7) { animation-delay: .40s; }
.stagger > *:nth-child(8) { animation-delay: .46s; }
@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* ---------- 9. Responsive ---------- */
@media (max-width: 1100px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .split { grid-template-columns: minmax(0,1fr); }
  .q-wrap { grid-template-columns: minmax(0,1fr); }
}
@media (max-width: 900px) {
  .app-nav { transform: translateX(-100%); transition: transform .24s var(--ease); box-shadow: var(--sh-lg); }
  body.nav-open .app-nav { transform: none; }
  body.nav-open .nav-scrim { opacity: 1; pointer-events: auto; }
  .app-topbar { top: 0; right: 0; left: 0; inset: 0 0 auto 0; padding: 0 var(--s4); gap: var(--s2); }
  .app-content { margin-left: 0; padding: calc(var(--topbar-h) + var(--s4)) var(--s4) var(--s7); }
  .nav-toggle { display: inline-flex; }
  .grid-3, .grid-2 { grid-template-columns: minmax(0,1fr); }
  .user-meta, .topbar-clock { display: none; }
}
@media (max-width: 480px) {
  body { font-size: 13.5px; }
  .h1, .page-head h1 { font-size: 22px; }
  .grid-4 { grid-template-columns: minmax(0,1fr); }
  .card { padding: var(--s4); }
  .q-stem { font-size: 15.5px; }
  .sheet-grid { grid-template-columns: repeat(6, 1fr); }
  .app-content { padding-left: var(--s3); padding-right: var(--s3); }
  .brand-text em { display: none; }
}

/* ---------- 9.1 Device differences（html[data-device] 差异微调，不改布局骨架） ---------- */
html[data-device="mobile"] .opt {
  min-height: 48px; padding: 12px var(--s4); align-items: center;
}
html[data-device="mobile"] .q-card { padding: var(--s4) var(--s4) var(--s3); }
html[data-device="mobile"] .q-head { gap: var(--s2); }
html[data-device="mobile"] .table-wrap {
  overflow-x: auto; -webkit-overflow-scrolling: touch; max-width: 100%;
}
html[data-device="mobile"] .switch-role { padding: 6px 8px; }
html[data-device="mobile"] .switch-role span { display: none; }

/* ---------- 10. Icon ---------- */
.ic {
  display: inline-flex; align-items: center; justify-content: center;
  width: 20px; height: 20px; flex: none; color: currentColor;
}
.ic svg { width: 100%; height: 100%; stroke-width: var(--ic-stroke); display: block; }

/* ---------- 11. Utilities ---------- */
.tc { text-align: center; }
.tr { text-align: right; }
.nowrap { white-space: nowrap; }
.mt2 { margin-top: var(--s2); } .mt3 { margin-top: var(--s3); } .mt4 { margin-top: var(--s4); } .mt5 { margin-top: var(--s5); }
.mb2 { margin-bottom: var(--s2); } .mb3 { margin-bottom: var(--s3); } .mb4 { margin-bottom: var(--s4); } .mb5 { margin-bottom: var(--s5); }
.hide { display: none !important; }
.strong { font-weight: 700; }
.fs12 { font-size: 12px; } .fs13 { font-size: 13px; } .fs16 { font-size: 16px; }
.gap2 { gap: var(--s2); } .gap3 { gap: var(--s3); } .gap4 { gap: var(--s4); }

/* ---------- 12. 移动端：顶部概览折叠 / 登录页精简 ---------- */
.mobile-fold-toggle { display: none; }
.mobile-fold-arrow { font-size: 12px; line-height: 1; }

@media (max-width: 900px) {
  /* 首页顶部概览默认折叠，点击展开 */
  .mobile-fold-toggle {
    display: flex; width: 100%; align-items: center; justify-content: space-between;
    gap: var(--s2); padding: 10px 12px; margin-bottom: var(--s3);
    background: var(--c-surface); border: 1px solid var(--c-border);
    border-radius: var(--r-sm); color: var(--c-text-sub);
    font-size: 13px; font-weight: 600; cursor: pointer;
  }
  .mobile-fold:not(.is-open) .mobile-fold-body { display: none; }
  .mobile-fold.is-open .mobile-fold-toggle { margin-bottom: var(--s4); }

  /* 登录页：隐藏品牌区，只保留登录框 */
  .login-shell { grid-template-columns: minmax(0, 1fr) !important; }
  .login-brand { display: none !important; }
  .login-panel {
    min-height: 100vh;
    min-height: 100dvh;
    align-items: center !important;
    padding: var(--s5) var(--s4) !important;
  }
  .login-card {
    width: 100% !important;
    max-width: 420px;
    padding: var(--s5) !important;
  }
  .login-help { display: none !important; }
}

@media (max-width: 480px) {
  .login-panel { padding: var(--s4) var(--s3) !important; }
  .login-card { padding: var(--s4) !important; }
}

/* ---------- 13. 手机端答题页（沉浸式单屏布局） ---------- */
.exam-mobile-bar { display: none; }

@media (max-width: 900px) {
  /* 答题页隐藏全局顶栏与导航，独占整个屏幕 */
  body.exam-page .app-topbar,
  body.exam-page .app-nav,
  body.exam-page .nav-scrim { display: none !important; }

  body.exam-page { background: var(--c-bg); overflow: hidden; height: 100%; }
  body.exam-page .app-content {
    margin: 0 !important;
    padding: 0 !important;
    height: 100%;
    overflow: hidden;
  }
  body.exam-page .page {
    position: fixed;
    top: 0; right: 0; bottom: 0; left: 0;
    inset: 0;
    height: auto;
    min-height: 0;
    max-width: none;
    display: flex;
    flex-direction: column;
    padding: 0;
    overflow: hidden;
  }

  /* 顶部：试卷标题 + 倒计时 + 进度 */
  body.exam-page .page > .card:first-child {
    flex: none;
    margin: 0;
    padding: calc(8px + constant(safe-area-inset-top)) 12px 8px;
    padding: calc(8px + env(safe-area-inset-top)) 12px 8px;
    border-radius: 0;
    border-left: 0;
    border-right: 0;
    border-top: 0;
    box-shadow: none;
  }
  body.exam-page .page > .card:first-child .row-wrap { gap: 8px; align-items: center; }
  body.exam-page .page > .card:first-child .label { display: none; }
  body.exam-page .page > .card:first-child h3 {
    font-size: 15px; margin: 0; line-height: 1.3;
    max-width: 52vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  }
  body.exam-page #paperMode { display: none; }
  body.exam-page .timer { font-size: 18px; padding: 4px 8px; }
  body.exam-page .page > .card:first-child .row.mt4 { margin-top: 6px; gap: 8px; }
  body.exam-page .page > .card:first-child .row.mt4 .sub { font-size: 11px; white-space: nowrap; }
  body.exam-page .page > .card:first-child .row.mt4 label { font-size: 10.5px; white-space: nowrap; }
  body.exam-page .page > .card:first-child .row.mt4 input[type="checkbox"] { width: 14px; height: 14px; }

  /* 判分提示在手机上隐藏，交卷弹窗里仍有完整提示 */
  body.exam-page .page > .notice { display: none; }

  /* 答题区：上下两段，中间题目可滚动 */
  body.exam-page .q-wrap {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-top: 0 !important;
    padding: 0 8px;
    overflow: hidden;
  }

  /* 答题卡：8 列小格，尽量压缩高度 */
  body.exam-page .answer-sheet {
    order: 0;
    flex: none;
    width: auto;
    margin: 0;
    padding: 6px 8px;
    border-radius: 10px;
    box-shadow: var(--sh-sm);
  }
  body.exam-page .answer-sheet .card-head,
  body.exam-page .answer-sheet #btnSubmit,
  body.exam-page .answer-sheet .row-wrap { display: none; }
  body.exam-page .sheet-grid {
    grid-template-columns: repeat(8, minmax(0, 1fr));
    gap: 5px;
    margin-top: 0;
  }
  body.exam-page .sheet-cell {
    aspect-ratio: auto;
    height: 26px;
    font-size: 11px;
    border-radius: 7px;
  }

  /* 题目与选项 */
  body.exam-page .q-card {
    order: 1;
    flex: 1 1 0;
    height: 0;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    margin: 0;
    padding: 10px 12px 16px;
    border-radius: 10px;
  }
  body.exam-page .q-head { gap: 6px; margin-bottom: 8px; }
  body.exam-page .q-no { font-size: 18px; }
  body.exam-page .q-head .tag { font-size: 11px; padding: 2px 6px; }
  body.exam-page .q-head .btn.ghost.sm { font-size: 11px; padding: 2px 6px; }
  body.exam-page .q-stem {
    font-size: 15.5px;
    line-height: 1.6;
    margin-bottom: 10px;
  }
  body.exam-page .opt {
    min-height: 44px;
    padding: 8px 10px;
    margin-bottom: 6px;
    gap: 8px;
    align-items: center;
    font-size: 14px;
  }
  body.exam-page .opt .key { width: 22px; height: 22px; font-size: 12px; }

  /* 题内的上一题/下一题隐藏，统一放到底栏 */
  body.exam-page .q-card .row-wrap.gap3.mt5 { display: none; }

  /* 底部固定操作栏 */
  body.exam-page .exam-mobile-bar {
    display: flex;
    flex: none;
    align-items: center;
    gap: 8px;
    padding: 8px 10px calc(8px + constant(safe-area-inset-bottom));
    padding: 8px 10px calc(8px + env(safe-area-inset-bottom));
    background: var(--c-surface);
    border-top: 1px solid var(--c-border);
    box-shadow: 0 -4px 16px rgba(17,24,39,.07);
  }
  body.exam-page .exam-mobile-bar .btn {
    flex: 1;
    min-height: 44px;
    padding: 8px 6px;
    font-size: 13px;
  }
  body.exam-page .exam-mobile-bar .btn.primary { flex: 1.2; }
  body.exam-page .exam-mobile-bar .btn[disabled] { opacity: .4; }
}

/* ---------- 14. 触屏设备取消粘滞 hover（避免自动跳题后下题选项被高亮） ---------- */
@media (hover: none), (pointer: coarse) {
  .opt:not(.sel):not(.correct):not(.wrong):hover {
    border-color: var(--c-border);
    background: var(--c-surface);
    box-shadow: none;
  }
  .opt:not(.sel):not(.correct):not(.wrong):hover .key {
    border-color: var(--c-border-strong);
    color: var(--c-text-sub);
  }
  .sheet-cell:not(.current):not(.done):not(.marked):hover {
    border-color: var(--c-border-strong);
    color: var(--c-text-sub);
  }
}
body.exam-page .opt {
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
}

/* ---------- 15. 手机端试卷配置弹窗（一屏内完成） ---------- */
@media (max-width: 900px) {
  #cfgModal { padding: 0; place-items: end stretch; }
  #cfgModal .modal {
    width: 100%;
    max-height: 94dvh;
    border-radius: 16px 16px 0 0;
    display: flex;
    flex-direction: column;
  }
  #cfgModal .modal-head { padding: 12px 14px 8px; flex: none; }
  #cfgModal .modal-head h3 { font-size: 16px; }
  #cfgModal .modal-head .sub { font-size: 11px; }

  #cfgModal .modal-body {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 0 14px 8px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    align-content: start;
  }
  #cfgModal .modal-body > .field:first-child,
  #cfgModal .modal-body > .field:nth-child(4) { grid-column: 1 / -1; }
  #cfgModal .modal-body > .field.mt4 { margin-top: 0; }
  #cfgModal .modal-body > .notice { display: none; }
  #cfgModal .modal-body .field > label { font-size: 12px; }
  #cfgModal .modal-body .field .hint { display: none; }
  #cfgModal #cfgDomains {
    max-height: 86px !important;
    padding: 6px 8px !important;
    overflow-y: auto;
  }
  #cfgModal .modal-body .select {
    height: 38px;
    padding: 0 8px;
    font-size: 12px;
  }
  #cfgModal .modal-foot {
    flex: none;
    padding: 8px 14px calc(8px + constant(safe-area-inset-bottom));
    padding: 8px 14px calc(8px + env(safe-area-inset-bottom));
  }
  #cfgModal .modal-foot .btn { flex: 1; min-height: 42px; }
}

/* ---------- 16. 手机端其他弹窗：内容滚动，底部按钮不被遮挡 ---------- */
@media (max-width: 900px) {
  #genModal, #histModal, #reviewModal { padding: 0; place-items: end stretch; }
  #genModal .modal, #histModal .modal, #reviewModal .modal {
    width: 100%;
    max-height: 94dvh;
    border-radius: 16px 16px 0 0;
    display: flex;
    flex-direction: column;
  }
  #genModal .modal-head, #histModal .modal-head, #reviewModal .modal-head {
    flex: none;
    padding: 12px 14px 8px;
  }
  #genModal .modal-body, #histModal .modal-body, #reviewModal .modal-body {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 0 14px 8px;
  }
  #genModal .modal-foot, #histModal .modal-foot, #reviewModal .modal-foot {
    flex: none;
    padding: 8px 14px calc(8px + constant(safe-area-inset-bottom));
    padding: 8px 14px calc(8px + env(safe-area-inset-bottom));
  }
  #genModal .modal-foot .btn, #histModal .modal-foot .btn, #reviewModal .modal-foot .btn {
    flex: 1;
    min-height: 42px;
  }
}

/* ---------- 17. 微信内置浏览器 / 触屏兼容 ---------- */
html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  color-scheme: light;
}

/* 触屏设备取消粘滞 hover，避免按钮/卡片点完一直保持高亮 */
@media (hover: none), (pointer: coarse) {
  .btn:hover { border-color: var(--c-border-strong); color: var(--c-text); background: var(--c-surface); }
  .btn.primary:hover { border-color: var(--c-primary); background: var(--c-primary); color: #fff; box-shadow: 0 2px 8px rgba(11,95,255,.24); }
  .btn.accent:hover { border-color: var(--c-accent); background: var(--c-accent); color: var(--c-text); filter: none; }
  .btn.ghost:hover { border-color: transparent; background: transparent; color: var(--c-text-sub); }
  .btn.danger:hover { border-color: transparent; background: var(--c-danger-soft); color: var(--c-danger); }
  .nav-item:not(.active):hover { background: transparent; color: var(--c-text-sub); }
  .tab:not(.active):hover { color: var(--c-text-sub); }
  .mode-card:not(.active):hover { transform: none; box-shadow: var(--sh-sm); border-color: var(--c-border); }
  .table tbody tr:hover { background: transparent; }
}

/* 触屏点击反馈与系统菜单控制 */
.btn, .nav-item, .mode-card, .sheet-cell, .tab, .keypoint, .mobile-fold-toggle {
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  touch-action: manipulation;
}
.btn, .nav-item, .mode-card, .sheet-cell, .tab, .keypoint, .mobile-fold-toggle {
  -webkit-user-select: none;
  user-select: none;
}
.nav-item:active { background: var(--c-surface-2); }
.mode-card:active { transform: scale(.995); }
.sheet-cell:active { background: var(--c-primary-soft); }

/* 手机端：输入框 16px 防止微信/iOS 聚焦自动放大；按钮保证可点面积 */
@media (max-width: 900px) {
  .input, .select, .textarea { font-size: 16px; }
  .input, .select { min-height: 44px; }
  .textarea { min-height: 88px; }
  .btn { min-height: 40px; }
  .btn.sm { min-height: 32px; }
  .btn.lg { min-height: 46px; }
  .login-card label[for="remember"] { min-height: 44px; }
  .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; max-width: 100%; }
  .filter-bar .field, .row-wrap > .field { min-width: 0 !important; }
  .filter-bar .field { flex: 1 1 100%; }
  .toast {
    bottom: calc(24px + constant(safe-area-inset-bottom));
    bottom: calc(24px + env(safe-area-inset-bottom));
  }
}

/* 手机端所有弹窗统一为底部弹层：内容可滚动，底部按钮始终可见 */
@media (max-width: 900px) {
  .modal-backdrop { padding: 0; place-items: end stretch; }
  .modal {
    width: 100%;
    max-height: 94vh;
    max-height: 94dvh;
    border-radius: 16px 16px 0 0;
    display: flex;
    flex-direction: column;
  }
  .modal-head { flex: none; padding: 12px 14px 8px; }
  .modal-body {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    padding: 0 14px 8px;
  }
  .modal-foot {
    flex: none;
    padding: 8px 14px calc(8px + constant(safe-area-inset-bottom));
    padding: 8px 14px calc(8px + env(safe-area-inset-bottom));
  }
  .modal-foot .btn { flex: 1; min-height: 44px; }
}

/* 弹窗打开时锁定背景滚动，避免微信里背景跟着滑动 */
body.modal-open { overflow: hidden; }

/* 微信/移动端关闭毛玻璃，避免 X5 渲染异常与性能问题 */
@media (max-width: 900px) {
  .app-topbar {
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
    background: var(--c-surface);
  }
  .modal-backdrop {
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
  }
}




/* ---------- 纠错上报处置弹窗：手机端按钮换行 ---------- */
@media (max-width: 900px) {
  #repModal .modal-foot { flex-wrap: wrap; }
  #repModal .modal-foot #repErr { flex: 1 0 100%; }
  #repModal .modal-foot .btn { flex: 1 1 30%; min-height: 42px; }
}
