/* 答题系统公共样式 —— 支持明亮 / 黑暗两套配色
   主题由 <html data-theme="light|dark"> 决定，theme.js 负责切换与记忆 */
* { margin: 0; padding: 0; box-sizing: border-box; }

/* ---------------- 明亮配色（默认） ---------------- */
:root {
  --pri: #2563eb;
  --pri-dark: #1d4ed8;
  --pri-light: #eff6ff;
  --pri-line: #bfdbfe;
  --ok: #059669;
  --warn: #d97706;
  --danger: #dc2626;

  --bg: #f4f6fa;
  --bg-glow: rgba(37, 99, 235, .09);
  --card: #ffffff;
  --card-soft: #fafcff;
  --topbar: #ffffff;
  --field: #ffffff;
  --chip: #f1f5f9;
  --hover: #f8fafc;

  --line: #e3e8ef;
  --line-strong: #cbd5e1;

  --text: #1e293b;
  --muted: #64748b;
  --faint: #94a3b8;

  --ok-bg: #ecfdf5;
  --warn-bg: #fffbeb;
  --danger-bg: #fef2f2;

  --shadow: 0 1px 2px rgba(16, 24, 40, .04);
  --shadow-lg: 0 8px 30px rgba(16, 24, 40, .09);
  --shadow-xl: 0 20px 60px rgba(0, 0, 0, .25);
  --toast-bg: #334155;
  --mask: rgba(15, 23, 42, .45);
  --scroll: #cbd5e1;
  color-scheme: light;
}

/* ---------------- 黑暗配色 ---------------- */
html[data-theme="dark"] {
  --pri: #4f93ff;
  --pri-dark: #3b82f6;
  --pri-light: rgba(79, 147, 255, .16);
  --pri-line: rgba(79, 147, 255, .38);
  --ok: #34d399;
  --warn: #fbbf24;
  --danger: #f87171;

  --bg: #0e1523;
  --bg-glow: rgba(79, 147, 255, .12);
  --card: #16202f;
  --card-soft: #1a2536;
  --topbar: #131c2a;
  --field: #101a28;
  --chip: #1e2b3d;
  --hover: #1c2738;

  --line: #26344a;
  --line-strong: #35496a;

  --text: #e6edf7;
  --muted: #9aabc2;
  --faint: #8598b2;

  --ok-bg: rgba(16, 185, 129, .15);
  --warn-bg: rgba(245, 158, 11, .15);
  --danger-bg: rgba(239, 68, 68, .15);

  --shadow: 0 1px 2px rgba(0, 0, 0, .4);
  --shadow-lg: 0 8px 30px rgba(0, 0, 0, .45);
  --shadow-xl: 0 20px 60px rgba(0, 0, 0, .6);
  --toast-bg: #2b3a4f;
  --mask: rgba(3, 8, 18, .68);
  --scroll: #35496a;
  color-scheme: dark;
}

html, body {
  height: 100%;
  font-family: "PingFang SC", "Microsoft YaHei", "Source Han Sans SC", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}
body { transition: background-color .25s, color .25s; }
a { color: var(--pri); text-decoration: none; }
button { font-family: inherit; cursor: pointer; border: 0; background: none; color: inherit; }
input, select, textarea { font-family: inherit; font-size: 14px; color: var(--text); }
input::placeholder, textarea::placeholder { color: var(--faint); }
.hide { display: none !important; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--scroll); border-radius: 5px; border: 2px solid var(--bg); }
::-webkit-scrollbar-track { background: transparent; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 36px; padding: 0 16px; border-radius: 8px;
  background: var(--pri); color: #fff; font-size: 14px; font-weight: 500;
  white-space: nowrap;
  transition: background .15s, opacity .15s, border-color .15s;
}
html[data-theme="dark"] .btn { color: #08111f; font-weight: 600; }
.btn:hover { background: var(--pri-dark); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.ghost { background: var(--card); color: var(--text); border: 1px solid var(--line); }
.btn.ghost:hover { background: var(--hover); border-color: var(--line-strong); }
html[data-theme="dark"] .btn.ghost { color: var(--text); }
.btn.danger { background: var(--danger); }
.btn.danger:hover { filter: brightness(.92); }
html[data-theme="dark"] .btn.danger { color: #1a0a0a; }
.btn.sm { height: 30px; padding: 0 11px; font-size: 13px; border-radius: 6px; }

.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: 12px; box-shadow: var(--shadow);
  transition: background-color .25s, border-color .25s;
}

/* ---- 站点图标：后台传了图标就用图片盖住默认 svg ---- */
[data-site-ico] { position: relative; overflow: hidden; }
[data-site-ico] img.sico {
  position: absolute; inset: 0; width: 100%; height: 100%;
  object-fit: cover; display: block;
}

/* ---- 配色切换按钮 ---- */.theme-toggle {
  width: 32px; height: 32px; border-radius: 8px; flex: 0 0 auto;
  display: grid; place-items: center; color: var(--muted);
  border: 1px solid var(--line); background: var(--card);
  transition: background .15s, color .15s, border-color .15s;
}
.theme-toggle:hover { background: var(--hover); color: var(--pri); border-color: var(--pri-line); }
.theme-toggle svg { width: 16px; height: 16px; }
/* 图标表示「点了会变成什么」：明亮时显示月亮，黑暗时显示太阳 */
.theme-toggle .i-sun { display: none; }
html[data-theme="dark"] .theme-toggle .i-sun { display: block; }
html[data-theme="dark"] .theme-toggle .i-moon { display: none; }

.toast-wrap {
  position: fixed; top: 20px; left: 50%; transform: translateX(-50%);
  z-index: 999; display: flex; flex-direction: column; gap: 8px; align-items: center;
}
.toast {
  padding: 10px 20px; border-radius: 8px; font-size: 14px; color: #fff;
  background: var(--toast-bg); box-shadow: 0 6px 20px rgba(0, 0, 0, .15);
  opacity: 0; transform: translateY(-8px); transition: all .25s;
}
.toast.in { opacity: 1; transform: none; }
.toast.ok { background: var(--ok); color: #04150f; }
.toast.err { background: var(--danger); color: #1a0606; }

.mask {
  position: fixed; inset: 0; background: var(--mask);
  display: grid; place-items: center; z-index: 900;
}
.dialog {
  width: 420px; max-width: 92vw; background: var(--card); border-radius: 12px;
  padding: 22px 24px; box-shadow: var(--shadow-xl); border: 1px solid var(--line);
  color: var(--text);
}
.dialog h3 { font-size: 16px; margin-bottom: 14px; }
.dialog .row { margin-bottom: 12px; }
.dialog label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.dialog input, .dialog select {
  width: 100%; height: 36px; padding: 0 10px; border: 1px solid var(--line);
  border-radius: 7px; outline: 0; background: var(--field); color: var(--text);
}
.dialog input:focus, .dialog select:focus { border-color: var(--pri); }
.dialog .acts { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }

.field {
  width: 100%; height: 40px; padding: 0 12px; border: 1px solid var(--line);
  border-radius: 8px; outline: 0; background: var(--field); color: var(--text);
}
.field:focus { border-color: var(--pri); box-shadow: 0 0 0 3px rgba(79, 147, 255, .16); }

.empty-state {
  padding: 60px 20px; text-align: center; color: var(--faint); font-size: 14px;
}
.tag {
  display: inline-flex; align-items: center; height: 22px; padding: 0 8px;
  border-radius: 6px; font-size: 12px; background: var(--pri-light); color: var(--pri);
}
.tag.gray { background: var(--chip); color: var(--muted); }
.tag.green { background: var(--ok-bg); color: var(--ok); }
.tag.amber { background: var(--warn-bg); color: var(--warn); }
