:root {
  --bg: #f4f6f9; --panel: #ffffff; --line: #e3e8ef; --text: #1f2937; --muted: #6b7280;
  --brand: #1f6feb; --brand-d: #1553b8; --ok: #16a34a; --warn: #d97706; --danger: #dc2626;
  --sel: #e8f1ff; --shadow: 0 2px 14px rgba(16, 32, 64, .07);
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, "PingFang SC", "Microsoft YaHei", "Segoe UI", Roboto, sans-serif;
  background: var(--bg); color: var(--text); -webkit-font-smoothing: antialiased;
  font-size: 15px; line-height: 1.6;
}
a { color: var(--brand); }
.wrap { max-width: 1080px; margin: 0 auto; padding: 18px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); }
.pad { padding: 18px; }
.row { display: flex; gap: 10px; align-items: center; }
.between { justify-content: space-between; }
.wrap-flex { flex-wrap: wrap; }
.grow { flex: 1; }
h1, h2, h3 { margin: 0 0 10px; font-weight: 700; }
h1 { font-size: 22px; } h2 { font-size: 18px; } h3 { font-size: 15px; }
.muted { color: var(--muted); font-size: 13px; }
.small { font-size: 13px; }
.center { text-align: center; }
.mt { margin-top: 14px; } .mb { margin-bottom: 14px; }

button, .btn {
  font: inherit; cursor: pointer; border: 1px solid var(--line); background: #fff; color: var(--text);
  padding: 9px 14px; border-radius: 9px; transition: .15s; user-select: none;
}
button:hover, .btn:hover { border-color: #c7d2de; background: #fafbfd; }
button:active { transform: translateY(1px); }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; font-weight: 600; }
.btn-primary:hover { background: var(--brand-d); border-color: var(--brand-d); }
.btn-danger { background: #fff; border-color: #f3c6c6; color: var(--danger); }
.btn-danger:hover { background: #fff5f5; }
.btn-lg { padding: 14px 26px; font-size: 17px; border-radius: 11px; }
.btn-sm { padding: 5px 10px; font-size: 13px; border-radius: 7px; }
button:disabled { opacity: .5; cursor: not-allowed; }

input, select, textarea {
  font: inherit; padding: 10px 12px; border: 1px solid var(--line); border-radius: 9px; width: 100%;
  background: #fff; color: var(--text);
}
input:focus, select:focus, textarea:focus { outline: 2px solid #bcd4ff; border-color: var(--brand); }
label { display: block; font-size: 13px; color: var(--muted); margin: 10px 0 5px; }

.tag { display: inline-block; padding: 2px 9px; border-radius: 20px; font-size: 12px; background: #eef2f7; color: var(--muted); }
.tag-open { background: #e7f7ee; color: var(--ok); } .tag-closed { background: #fdeaea; color: var(--danger); }
.code { font-family: ui-monospace, Menlo, Consolas, monospace; font-weight: 700; letter-spacing: 3px; font-size: 20px; color: var(--brand); }

/* ── 答题界面 ── */
.exam-top { position: sticky; top: 0; z-index: 20; background: #fff; border-bottom: 1px solid var(--line); }
.progress { height: 6px; background: #eef2f7; border-radius: 6px; overflow: hidden; }
.progress > i { display: block; height: 100%; background: linear-gradient(90deg, var(--brand), #38bdf8); width: 0; transition: width .3s; }
.material { border: 1px solid var(--line); border-radius: 10px; background: #fbfcfe; padding: 14px; }
.material img, .material video { max-width: 100%; border-radius: 8px; display: block; margin: 8px 0; background: #000; }
.material .mtext { white-space: pre-wrap; }
.stem { font-size: 17px; font-weight: 600; margin: 16px 0 12px; }
.opt {
  display: flex; gap: 12px; align-items: flex-start; padding: 13px 15px; border: 1.5px solid var(--line);
  border-radius: 10px; margin-bottom: 10px; cursor: pointer; background: #fff; transition: .12s;
}
.opt:hover { border-color: #b9cdf0; background: #fbfdff; }
.opt.sel { border-color: var(--brand); background: var(--sel); }
.opt .k {
  width: 26px; height: 26px; flex: 0 0 26px; border-radius: 50%; background: #eef2f7; color: #475569;
  display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 13px;
}
.opt.sel .k { background: var(--brand); color: #fff; }
.opt .t { flex: 1; }
.kbd { display: inline-block; padding: 1px 8px; border: 1px solid #cbd5e1; border-bottom-width: 2px; border-radius: 6px; background: #f8fafc; font-size: 12px; font-family: ui-monospace, monospace; }
.hint { font-size: 13px; color: var(--muted); }
.toast {
  position: fixed; left: 50%; bottom: 30px; transform: translateX(-50%) translateY(20px); opacity: 0;
  background: #111827; color: #fff; padding: 10px 18px; border-radius: 10px; font-size: 14px; z-index: 60;
  transition: .25s; pointer-events: none; max-width: 90vw;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.opt.ok { border-color: var(--ok); background: #eafaf0; }
.opt.ok .k { background: var(--ok); color: #fff; }
.opt.bad { border-color: var(--danger); background: #fdeeee; }
.opt.bad .k { background: var(--danger); color: #fff; }
.ansbox { border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; margin-top: 12px; background: #fbfcfe; }
.ansbox .res-ok { color: var(--ok); font-weight: 700; }
.ansbox .res-bad { color: var(--danger); font-weight: 700; }
.done-box { text-align: center; padding: 48px 20px; }
.done-box .big { font-size: 46px; }

/* ── 后台 ── */
.grid { display: grid; gap: 14px; }
.g2 { grid-template-columns: 1fr 1fr; } .g3 { grid-template-columns: repeat(3, 1fr); }
@media (max-width: 820px) { .g2, .g3 { grid-template-columns: 1fr; } }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { background: #f7f9fc; font-size: 13px; color: #475569; font-weight: 600; white-space: nowrap; }
tbody tr:hover { background: #fbfdff; }
.bar { height: 18px; background: #eef2f7; border-radius: 5px; overflow: hidden; min-width: 80px; }
.bar > i { display: block; height: 100%; background: var(--brand); }
.mono { font-family: ui-monospace, Menlo, Consolas, monospace; }
.stat { text-align: center; padding: 14px; }
.stat .n { font-size: 26px; font-weight: 700; color: var(--brand); }
.stat .l { font-size: 13px; color: var(--muted); }
.tabs { display: flex; gap: 6px; border-bottom: 1px solid var(--line); margin-bottom: 14px; flex-wrap: wrap; }
.tabs button { border: none; background: none; border-bottom: 2px solid transparent; border-radius: 0 0 0 0; padding: 9px 12px; color: var(--muted); }
.tabs button.on { color: var(--brand); border-bottom-color: var(--brand); font-weight: 600; }
.hide { display: none !important; }
.notice { padding: 10px 12px; border-radius: 9px; font-size: 13px; }
.notice-info { background: #eef4ff; color: #1e40af; }
.notice-warn { background: #fff7e8; color: #92400e; }
pre.schema { background: #0f172a; color: #d6e2f5; padding: 14px; border-radius: 10px; overflow: auto; font-size: 12.5px; line-height: 1.55; }

select.mini { width: auto; padding: 4px 6px; font-size: 12px; margin: 0; display: inline-block; }

/* ── 标签式选项（支持几十个，流式换行） ── */
#ex-options { display: flex; flex-wrap: wrap; gap: 9px; margin-top: 4px; }
.chip {
  display: inline-flex; align-items: center; gap: 8px; padding: 9px 14px; border: 1.5px solid var(--line);
  border-radius: 22px; background: #fff; cursor: pointer; transition: .12s; font: inherit; color: var(--text); max-width: 100%;
}
.chip:hover { border-color: #b9cdf0; background: #fbfdff; }
.chip .chip-key {
  flex: none; min-width: 20px; height: 20px; padding: 0 5px; border-radius: 11px; background: #eef2f7; color: #475569;
  display: inline-flex; align-items: center; justify-content: center; font-weight: 700; font-size: 12px;
}
.chip .chip-t { text-align: left; }
.chip.sel { border-color: var(--brand); background: var(--sel); }
.chip.sel .chip-key { background: var(--brand); color: #fff; }
.chip.ok { border-color: var(--ok); background: #eafaf0; }
.chip.ok .chip-key { background: var(--ok); color: #fff; }
.chip.bad { border-color: var(--danger); background: #fdeeee; }
.chip.bad .chip-key { background: var(--danger); color: #fff; }

/* ── 视频嵌入 / 外部链接 ── */
.mv-embed { position: relative; width: 100%; padding-top: 56.25%; margin: 10px 0; border-radius: 8px; overflow: hidden; background: #000; }
.mv-embed iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.mv-link { border: 1px dashed var(--line); border-radius: 9px; padding: 12px 14px; background: #fbfcfe; margin: 8px 0; }

/* ── 在线出题 ── */
.qlist { max-height: 62vh; overflow: auto; }
.qitem { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; margin-bottom: 8px; cursor: pointer; transition: .12s; }
.qitem:hover { border-color: #b9cdf0; background: #fbfdff; }
.qitem.on { border-color: var(--brand); background: var(--sel); }
.qitem-main { display: flex; gap: 8px; align-items: baseline; }
.qitem-stem { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.qitem-meta { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 6px; }
.matlist { margin-bottom: 6px; }
.matrow { display: flex; gap: 8px; align-items: center; margin-bottom: 6px; }
.matrow input, .matrow textarea { flex: 1; }
.matrow .thumb { width: 46px; height: 46px; object-fit: cover; border-radius: 6px; border: 1px solid var(--line); flex: none; }
.chip-box { display: flex; flex-wrap: wrap; gap: 8px; padding: 10px; border: 1px dashed var(--line); border-radius: 10px; background: #fbfcfe; min-height: 52px; }
.chip-item { display: inline-flex; align-items: center; gap: 4px; padding: 3px 4px 3px 8px; border: 1.5px solid var(--line); border-radius: 20px; background: #fff; }
.chip-item.ans { border-color: var(--ok); background: #eafaf0; }
.chip-item .chip-key { font-weight: 700; font-size: 12px; color: var(--muted); }
.chip-item.ans .chip-key { color: var(--ok); }
.chip-item input { width: 130px; padding: 4px 7px; font-size: 13px; border-radius: 14px; }
.chip-item button { border: none; background: none; padding: 2px 6px; border-radius: 50%; font-size: 14px; line-height: 1; }
.chip-item button:hover { background: #eef2f7; }
.chip-item button.x { color: var(--danger); }

/* ── 分享链接状态徽章 ── */
.tunnel-badge { display: inline-flex; align-items: center; gap: 4px; padding: 4px 11px; border-radius: 20px; font-size: 12.5px; font-weight: 600; white-space: nowrap; }
.tunnel-badge.ok { background: #eafaf0; color: #0b7a3f; border: 1px solid #b6e6c9; }
.tunnel-badge.bad { background: #fdeeee; color: #b3261e; border: 1px solid #f3c2bf; }
.tunnel-badge.warn { background: #fff8e6; color: #8a6100; border: 1px solid #f0dfae; }
.tunnel-badge.checking { background: #eef2f7; color: #475569; border: 1px solid #dbe3ec; }

/* ── 素材图片（加载失败时给提示，而不是黑条） ── */
.img-wrap { display: block; }
.img-wrap > img { cursor: zoom-in; }
.img-wrap .img-fallback { display: none; }
.img-wrap.bad .img-fallback {
  display: block; padding: 10px 12px; margin: 8px 0; background: #fdeeee;
  border: 1px dashed #f3c2bf; border-radius: 8px; color: #b3261e; font-size: 13px; word-break: break-all;
}

/* ── 参考链接弹窗 ── */
.modal { position: fixed; inset: 0; z-index: 1000; display: flex; align-items: center; justify-content: center; padding: 20px; }
.modal-mask { position: absolute; inset: 0; background: rgba(15, 23, 42, .55); }
.modal-box {
  position: relative; display: flex; flex-direction: column; overflow: hidden;
  width: min(1080px, 96vw); height: min(780px, 88vh);
  background: #fff; border-radius: 14px; box-shadow: 0 20px 60px rgba(0, 0, 0, .3);
}
.modal-box.max { width: 100vw !important; height: 100vh !important; border-radius: 0; }
.modal-head { flex: none; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 11px 16px; border-bottom: 1px solid var(--line); }
.modal-title { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.modal-body { flex: 1; position: relative; display: flex; align-items: center; justify-content: center; overflow: hidden; background: #f7f9fc; }
.modal-body iframe { display: block; width: 100%; height: 100%; border: 0; background: #fff; }
.modal-body.dragging { cursor: grabbing; }
.modal-tip {
  position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 8px; padding: 24px; text-align: center; background: #f7f9fc; color: var(--muted); font-size: 14px;
}
.modal-foot { flex: none; padding: 7px 16px; border-top: 1px solid var(--line); word-break: break-all; }
/* 右下角拖拽调整大小 */
.modal-resizer { position: absolute; right: 0; bottom: 0; width: 20px; height: 20px; cursor: nwse-resize; touch-action: none; }
.modal-resizer::after {
  content: ''; position: absolute; right: 4px; bottom: 4px; width: 8px; height: 8px;
  border-right: 2px solid #cbd5e1; border-bottom: 2px solid #cbd5e1;
}
.modal-resizer:hover::after { border-color: #3b82f6; }
/* 图片：可缩放 / 拖拽平移 */
#modal-img {
  max-width: 100%; max-height: 100%; object-fit: contain; user-select: none;
  cursor: grab; touch-action: none; transition: transform .1s ease-out; will-change: transform;
}
.modal-body.dragging #modal-img { cursor: grabbing; transition: none; }
@media (max-width: 640px) {
  .modal { padding: 0; }
  .modal-box { width: 100vw; height: 100vh; border-radius: 0; }
  .modal-resizer { display: none; }
}
