/* ==========================================================================
   OCS 题库 · 设计系统
   深浅自适应：跟随系统 prefers-color-scheme，也可用 <html data-theme="dark"> 强制
   ========================================================================== */

:root {
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
          "Hiragino Sans GB", "Microsoft YaHei", "Source Han Sans SC", sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;

  --bg: #f4f6fb;
  --bg-soft: #eef1f8;
  --surface: #ffffff;
  --surface-2: #f9fafd;
  --text: #16202f;
  --text-soft: #4a5568;
  --muted: #6f7b90;
  --border: #e3e8f1;
  --border-strong: #cfd7e6;

  --accent: #4659f0;
  --accent-soft: #eef0ff;
  --accent-text: #ffffff;
  --teal: #0ea89b;
  --ok: #12876f;
  --ok-bg: #e8f7f2;
  --info: #2f6fd0;
  --info-bg: #eaf1fd;
  --warn: #9a6205;
  --warn-bg: #fdf3e2;
  --bad: #b42318;
  --bad-bg: #fdecea;

  --shadow-sm: 0 1px 2px rgba(19, 32, 58, .06);
  --shadow: 0 1px 2px rgba(19, 32, 58, .05), 0 10px 30px -12px rgba(19, 32, 58, .18);
  --radius: 14px;
  --radius-sm: 9px;
  --radius-lg: 20px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0d1219;
    --bg-soft: #111823;
    --surface: #151d28;
    --surface-2: #1a2331;
    --text: #e7edf7;
    --text-soft: #b7c3d6;
    --muted: #8b98ad;
    --border: #232e3f;
    --border-strong: #33415a;

    --accent: #7b8dff;
    --accent-soft: #1d2540;
    --accent-text: #0d1219;
    --teal: #2fd0bd;
    --ok: #4ed3ab;
    --ok-bg: #10312a;
    --info: #7fb2f7;
    --info-bg: #132840;
    --warn: #f0c07a;
    --warn-bg: #33260f;
    --bad: #f79088;
    --bad-bg: #3a1a1a;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
    --shadow: 0 1px 2px rgba(0, 0, 0, .35), 0 14px 34px -16px rgba(0, 0, 0, .7);
  }
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.65;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

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

h1, h2, h3, h4 { margin: 0; font-weight: 600; letter-spacing: -.01em; }
p { margin: 0 0 12px; }
small, .small { font-size: 12.5px; }
.muted { color: var(--muted); }
.mono { font-family: var(--mono); font-size: 12.5px; }

/* ------------------------------ 布局 ------------------------------ */

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

.stack > * + * { margin-top: 14px; }
.row { display: flex; gap: 14px; flex-wrap: wrap; }
.row > * { flex: 1 1 220px; min-width: 0; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-top: 6px; }
.grid { display: grid; gap: 14px; }
.grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }

@media (max-width: 820px) {
  .grid.cols-2, .grid.cols-3, .grid.cols-4 { grid-template-columns: minmax(0, 1fr); }
}

/* ------------------------------ 卡片 ------------------------------ */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 20px;
}
.card.pad-lg { padding: 26px; }
.card > h2 {
  font-size: 15px;
  margin-bottom: 4px;
}
.card > h2 + .hint { margin-top: 0; margin-bottom: 16px; }
.card.flat { box-shadow: none; }

.hint { color: var(--muted); font-size: 12.8px; margin: 6px 0 0; }
.divider { height: 1px; background: var(--border); margin: 18px 0; border: 0; }

/* ------------------------------ 按钮 ------------------------------ */

.btn {
  --btn-bg: var(--surface);
  --btn-fg: var(--text);
  --btn-bd: var(--border-strong);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 9px 16px;
  font: inherit;
  font-size: 14px;
  font-weight: 500;
  color: var(--btn-fg);
  background: var(--btn-bg);
  border: 1px solid var(--btn-bd);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: transform .06s ease, box-shadow .15s ease, background .15s ease, border-color .15s ease;
  text-decoration: none;
  white-space: nowrap;
}
.btn:hover { text-decoration: none; border-color: var(--accent); color: var(--accent); }
.btn:active { transform: translateY(1px); }

.btn.primary {
  --btn-bg: var(--accent);
  --btn-fg: var(--accent-text);
  --btn-bd: var(--accent);
  box-shadow: 0 6px 16px -8px var(--accent);
}
.btn.primary:hover { filter: brightness(1.06); color: var(--accent-text); }

.btn.danger { --btn-fg: var(--bad); --btn-bd: color-mix(in srgb, var(--bad) 40%, transparent); }
.btn.danger:hover { background: var(--bad-bg); border-color: var(--bad); color: var(--bad); }

.btn.ghost { --btn-bd: transparent; --btn-bg: transparent; color: var(--muted); }
.btn.ghost:hover { background: var(--bg-soft); color: var(--text); }

.btn.sm, .btn.btn-sm { padding: 6px 11px; font-size: 13px; border-radius: 8px; }
.btn.block { width: 100%; }
.btn.is-disabled { opacity: .45; pointer-events: none; }

.linkbtn {
  background: none;
  border: 0;
  padding: 0;
  font: inherit;
  color: var(--muted);
  cursor: pointer;
}
.linkbtn:hover { color: var(--accent); }

/* ------------------------------ 表单 ------------------------------ */

.field { display: block; margin-bottom: 14px; }
.field > span {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-soft);
  margin-bottom: 6px;
}
.field.inline { display: flex; align-items: center; gap: 10px; }
.field.inline > span { margin-bottom: 0; white-space: nowrap; }

input[type="text"], input[type="password"], input[type="number"], input[type="search"],
input[type="email"], select, textarea {
  width: 100%;
  padding: 10px 12px;
  font: inherit;
  font-size: 14px;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  transition: border-color .15s ease, box-shadow .15s ease, background .15s ease;
}
textarea { resize: vertical; min-height: 62px; line-height: 1.6; }
input:focus, select:focus, textarea:focus {
  outline: none;
  background: var(--surface);
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 16%, transparent);
}
input::placeholder, textarea::placeholder { color: var(--muted); opacity: .75; }

select {
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, currentColor 50%),
                    linear-gradient(135deg, currentColor 50%, transparent 50%);
  background-position: calc(100% - 17px) 50%, calc(100% - 12px) 50%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-right: 34px;
}

.check {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  font-size: 13.5px;
  color: var(--text-soft);
  cursor: pointer;
  margin-bottom: 10px;
}
.check input[type="checkbox"] {
  width: 16px;
  height: 16px;
  margin: 3px 0 0;
  accent-color: var(--accent);
  flex: none;
}
.check b { color: var(--text); font-weight: 500; }

/* ------------------------------ 标签 / 提示 ------------------------------ */

.tag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
  line-height: 1.7;
  white-space: nowrap;
  background: var(--bg-soft);
  color: var(--muted);
  border: 1px solid transparent;
}
.tag.ok { background: var(--ok-bg); color: var(--ok); }
.tag.info { background: var(--info-bg); color: var(--info); }
.tag.warn { background: var(--warn-bg); color: var(--warn); }
.tag.bad { background: var(--bad-bg); color: var(--bad); }
.tag[title] { cursor: help; }

.alert {
  padding: 12px 15px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text-soft);
}
.alert + .alert { margin-top: 10px; }
.alert.ok { background: var(--ok-bg); border-color: color-mix(in srgb, var(--ok) 22%, transparent); color: var(--ok); }
.alert.info { background: var(--info-bg); border-color: color-mix(in srgb, var(--info) 22%, transparent); color: var(--info); }
.alert.warn { background: var(--warn-bg); border-color: color-mix(in srgb, var(--warn) 25%, transparent); color: var(--warn); }
.alert.err, .alert.bad { background: var(--bad-bg); border-color: color-mix(in srgb, var(--bad) 25%, transparent); color: var(--bad); }
.alert strong { font-weight: 600; }
.alert p:last-child { margin-bottom: 0; }

.note {
  font-size: 12.8px;
  color: var(--muted);
  border-left: 2px solid var(--border-strong);
  padding-left: 10px;
  margin-top: 8px;
}

/* ------------------------------ 表格 ------------------------------ */

.table-wrap { overflow-x: auto; border-radius: var(--radius-sm); }
table.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.6px;
}
table.table th, table.table td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
table.table th {
  font-size: 12px;
  font-weight: 500;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--muted);
  background: var(--surface-2);
  white-space: nowrap;
}
table.table tbody tr:hover { background: var(--surface-2); }
table.table td.num { font-variant-numeric: tabular-nums; }
table.table .actions { white-space: nowrap; }
table.table .actions form { display: inline; }

.empty {
  padding: 34px 18px;
  text-align: center;
  color: var(--muted);
  font-size: 13.5px;
}
.empty b { display: block; color: var(--text-soft); font-weight: 500; margin-bottom: 4px; }

/* ------------------------------ 分页 ------------------------------ */

.pager {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 16px;
  flex-wrap: wrap;
}
.pager-info { font-size: 12.8px; color: var(--muted); }

/* ------------------------------ 代码 / 复制 ------------------------------ */

code {
  font-family: var(--mono);
  font-size: 12.5px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 1px 6px;
  word-break: break-all;
}
pre.code {
  font-family: var(--mono);
  font-size: 12.4px;
  line-height: 1.6;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  overflow: auto;
  max-height: 340px;
  margin: 0;
  white-space: pre-wrap;
  word-break: break-all;
}

.copyline {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px 9px 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.copyline code { background: none; border: 0; padding: 0; flex: 1; }
.copyline.col { flex-direction: column; align-items: stretch; }

/* ------------------------------ 统计块 ------------------------------ */

.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 15px 16px;
}
.stat b {
  display: block;
  font-size: 25px;
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: -.02em;
  font-variant-numeric: tabular-nums;
}
.stat span { font-size: 12.5px; color: var(--muted); }
.stat.is-accent b { color: var(--accent); }
.stat.is-teal b { color: var(--teal); }
.stat.is-warn b { color: var(--warn); }
.stat.is-bad b { color: var(--bad); }

/* ------------------------------ 顶部条 ------------------------------ */

.site-head {
  position: sticky;
  top: 0;
  z-index: 30;
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.site-head .wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 60px;
  gap: 16px;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  font-weight: 600;
  font-size: 15px;
  color: var(--text);
  letter-spacing: -.01em;
}
.brand:hover { text-decoration: none; }
.brand .dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--teal));
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 14%, transparent);
  flex: none;
}
.top-nav {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13.6px;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.top-nav > a, .top-nav .nav-quota {
  padding: 6px 11px;
  border-radius: 8px;
  color: var(--text-soft);
}
.top-nav > a:hover { background: var(--bg-soft); color: var(--text); text-decoration: none; }
.top-nav > a.on { background: var(--surface); color: var(--accent); box-shadow: var(--shadow-sm); }
.nav-quota {
  font-variant-numeric: tabular-nums;
  color: var(--muted);
  background: var(--bg-soft);
}
.nav-quota.zero { color: var(--bad); background: var(--bad-bg); }
.nav-logout { display: inline; }

/* ------------------------------ 页脚 ------------------------------ */

.site-foot {
  border-top: 1px solid var(--border);
  margin-top: 48px;
  padding: 20px 0 30px;
  font-size: 12.8px;
  color: var(--muted);
}
.site-foot .wrap { display: flex; justify-content: space-between; gap: 14px; flex-wrap: wrap; }

/* ------------------------------ 杂项 ------------------------------ */

.kbd {
  font-family: var(--mono);
  font-size: 11.5px;
  border: 1px solid var(--border-strong);
  border-bottom-width: 2px;
  border-radius: 5px;
  padding: 0 5px;
  color: var(--text-soft);
}

.badge-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--muted);
  margin-right: 6px;
}
.badge-dot.on { background: var(--ok); }
.badge-dot.off { background: var(--border-strong); }

.scroll-x { overflow-x: auto; }

.tabs {
  display: flex;
  gap: 4px;
  background: var(--bg-soft);
  padding: 4px;
  border-radius: 10px;
  width: fit-content;
  margin-bottom: 16px;
}
.tabs a {
  padding: 6px 14px;
  border-radius: 7px;
  font-size: 13.4px;
  color: var(--muted);
}
.tabs a.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }
.tabs a:hover { text-decoration: none; color: var(--text); }
