/* 知题 · 青岛好奇心实验 — 移动优先样式 */
:root {
  --ink: #1f2a37;
  --ink-2: #4b5563;
  --muted: #6b7280;
  --line: #e4e7ec;
  --bg: #f7f7f3;
  --card: #ffffff;
  --primary: #1b6b5c;
  --primary-dark: #145246;
  --primary-soft: #e6f1ee;
  --accent: #f08a24;
  --accent-soft: #fff1e3;
  --danger: #c0392b;
  --danger-soft: #fdecea;
  --ok: #2e7d32;
  --ok-soft: #e8f5e9;
  --warn: #9a5b00;
  --warn-soft: #fff4e0;
  --radius: 14px;
  --shadow: 0 2px 10px rgba(31, 42, 55, 0.06);
  --font: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC", "Source Han Sans SC", "WenQuanYi Micro Hei", "Helvetica Neue", Arial, sans-serif;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
  line-height: 1.6;
  font-size: 16px;
  overflow-x: hidden;
  min-height: 100vh;
  min-height: 100dvh;
}
img, svg { max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--primary); }
[hidden] { display: none !important; }
.view { display: none; min-height: 100dvh; }
.view.active { display: block; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ---------- 品牌区 ---------- */
.brand-block { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 10px; }
.brand-logo { width: min(62vw, 260px); height: auto; display: block; }
.brand-name { font-size: 20px; font-weight: 700; letter-spacing: 0.18em; color: var(--primary); margin: 0; }
.brand-name small { display: block; font-size: 12px; letter-spacing: 0.3em; font-weight: 500; color: var(--muted); margin-top: 2px; }

/* ---------- 登录页 ---------- */
.login-wrap {
  min-height: 100dvh;
  display: flex; flex-direction: column; justify-content: center; align-items: center;
  padding: calc(24px + var(--safe-top)) 24px calc(24px + var(--safe-bottom));
  gap: 28px;
}
.login-form { width: 100%; max-width: 360px; display: flex; flex-direction: column; gap: 12px; }
.field input {
  width: 100%; padding: 14px 16px; border: 1px solid var(--line); border-radius: 12px; background: var(--card);
  font-size: 17px; outline: none; transition: border-color .15s, box-shadow .15s;
}
.field input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(27, 107, 92, 0.15); }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 12px 18px; border-radius: 12px; border: 1px solid transparent; font-weight: 600; font-size: 16px;
  background: var(--card); color: var(--ink); border-color: var(--line); min-height: 46px; text-decoration: none;
  transition: transform .05s, background .15s; -webkit-tap-highlight-color: transparent;
}
.btn:active { transform: scale(0.985); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-dark); }
.btn-accent { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--primary); }
.btn-danger { color: var(--danger); border-color: #f1c5c0; }
.btn-sm { padding: 8px 12px; min-height: 36px; font-size: 14px; border-radius: 10px; }
.btn-block { width: 100%; }
.btn-main {
  width: 100%; max-width: 360px; min-height: 58px; font-size: 19px; border-radius: 16px;
  box-shadow: 0 6px 18px rgba(27, 107, 92, 0.25);
}
.form-error { color: var(--danger); font-size: 14px; min-height: 20px; text-align: center; margin: 0; }
.login-note { font-size: 12px; color: var(--muted); text-align: center; }

/* ---------- 顶部栏 ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20; background: rgba(247, 247, 243, .92); backdrop-filter: saturate(180%) blur(10px);
  display: flex; align-items: center; gap: 8px; padding: calc(8px + var(--safe-top)) 12px 8px; border-bottom: 1px solid var(--line);
  min-height: 52px;
}
.topbar .title { flex: 1; font-weight: 600; font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.icon-btn {
  width: 42px; height: 42px; border-radius: 12px; border: 1px solid transparent; background: transparent;
  display: inline-flex; align-items: center; justify-content: center; color: var(--ink);
}
.icon-btn:hover { background: #ecece7; }
.icon-btn svg { width: 24px; height: 24px; }
.topbar-logo { height: 28px; width: auto; }

/* ---------- 极简首页 ---------- */
.home-wrap {
  min-height: calc(100dvh - 52px); display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 24px 24px calc(32px + var(--safe-bottom)); gap: 36px;
}
.home-hint { font-size: 13px; color: var(--muted); margin: -16px 0 0; }

/* ---------- 抽屉菜单 ---------- */
.drawer-backdrop { position: fixed; inset: 0; background: rgba(31, 42, 55, .35); z-index: 40; opacity: 0; pointer-events: none; transition: opacity .2s; }
.drawer-backdrop.open { opacity: 1; pointer-events: auto; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(86vw, 340px); background: var(--card); z-index: 41;
  transform: translateX(100%); transition: transform .22s ease; display: flex; flex-direction: column;
  padding: calc(16px + var(--safe-top)) 16px calc(16px + var(--safe-bottom)); box-shadow: -8px 0 30px rgba(0, 0, 0, .12);
  overflow-y: auto;
}
.drawer.open { transform: translateX(0); }
.drawer-user { display: flex; flex-direction: column; gap: 6px; padding: 8px 8px 14px; border-bottom: 1px solid var(--line); }
.drawer-user .name { font-weight: 700; font-size: 17px; }
.drawer-user .sub { font-size: 13px; color: var(--muted); }
.menu-list { list-style: none; margin: 8px 0; padding: 0; }
.menu-list button {
  width: 100%; text-align: left; background: transparent; border: 0; padding: 13px 10px; border-radius: 10px; font-size: 16px;
  display: flex; align-items: center; gap: 12px;
}
.menu-list button:hover { background: var(--bg); }
.menu-list button svg { width: 22px; height: 22px; color: var(--primary); flex: none; }
.menu-list .danger { color: var(--danger); }
.menu-list .danger svg { color: var(--danger); }

/* Token 余量条 */
.quota-bar { display: block; width: 100%; height: 4px; background: #e2e6ea; border-radius: 999px; overflow: hidden; }
.quota-bar i { display: block; height: 100%; background: var(--primary); border-radius: 999px; transition: width .3s; }
.quota-bar.low i { background: var(--accent); }
.quota-bar.empty i { background: var(--danger); }
.quota-line { display: flex; align-items: center; justify-content: space-between; font-size: 13px; color: var(--muted); }
.quota-line strong { color: var(--ink); font-weight: 600; }

/* ---------- 底部面板（上传） ---------- */
.sheet-backdrop { position: fixed; inset: 0; background: rgba(31, 42, 55, .4); z-index: 50; opacity: 0; pointer-events: none; transition: opacity .2s; }
.sheet-backdrop.open { opacity: 1; pointer-events: auto; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 51; background: var(--card); border-radius: 20px 20px 0 0;
  padding: 10px 16px calc(16px + var(--safe-bottom)); transform: translateY(105%); transition: transform .25s ease;
  max-height: 88dvh; overflow-y: auto; box-shadow: 0 -8px 30px rgba(0, 0, 0, .15);
}
.sheet.open { transform: translateY(0); }
.sheet-handle { width: 40px; height: 4px; border-radius: 999px; background: #d4d7dc; margin: 2px auto 12px; }
.sheet h3 { margin: 0 0 4px; font-size: 17px; }
.sheet p.note { margin: 0 0 12px; font-size: 13px; color: var(--muted); }
.upload-options { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 8px 0 14px; }
.upload-opt {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; padding: 14px 6px;
  border: 1px solid var(--line); border-radius: 14px; background: var(--bg); font-size: 14px; font-weight: 600; min-height: 86px;
}
.upload-opt svg { width: 28px; height: 28px; color: var(--primary); }
.upload-opt input { display: none; }
.dropzone { border: 1.5px dashed #c8cdd4; border-radius: 14px; padding: 18px; text-align: center; color: var(--muted); font-size: 14px; display: none; }
.dropzone.drag { border-color: var(--primary); background: var(--primary-soft); color: var(--primary); }
.scope-box { background: var(--primary-soft); color: var(--primary-dark); border-radius: 12px; padding: 10px 12px; font-size: 13.5px; margin-bottom: 10px; }
.scope-box strong { display: block; margin-bottom: 2px; }
.mock-box { background: var(--accent-soft); color: var(--warn); border-radius: 12px; padding: 10px 12px; font-size: 13.5px; margin-bottom: 10px; }
.demo-list { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--card); font-size: 13.5px; font-weight: 500; color: var(--ink);
}
.chip.active, .chip:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-soft); }
.chip.sm { padding: 3px 9px; font-size: 12.5px; }

/* ---------- 通用容器 ---------- */
.page { padding: 12px 14px calc(28px + var(--safe-bottom)); max-width: 760px; margin: 0 auto; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow); margin-bottom: 12px; }
.card h2 { font-size: 16px; margin: 0 0 8px; }
.muted { color: var(--muted); font-size: 13.5px; }
.small { font-size: 13px; }
.row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.tag { display: inline-block; padding: 2px 8px; border-radius: 8px; font-size: 12px; font-weight: 600; background: var(--primary-soft); color: var(--primary); vertical-align: middle; }
.tag.gray { background: #eef0f3; color: var(--muted); }
.tag.warn { background: var(--warn-soft); color: var(--warn); }
.tag.danger { background: var(--danger-soft); color: var(--danger); }
.tag.ok { background: var(--ok-soft); color: var(--ok); }
.tag.accent { background: var(--accent-soft); color: var(--warn); }
.banner { border-radius: 12px; padding: 10px 12px; font-size: 14px; margin-bottom: 12px; }
.banner.info { background: var(--primary-soft); color: var(--primary-dark); }
.banner.warn { background: var(--warn-soft); color: var(--warn); }
.banner.danger { background: var(--danger-soft); color: var(--danger); }
.banner.ok { background: var(--ok-soft); color: var(--ok); }
.toast {
  position: fixed; left: 50%; bottom: calc(24px + var(--safe-bottom)); transform: translateX(-50%) translateY(20px); z-index: 90;
  background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 12px; font-size: 14px; opacity: 0; transition: all .2s; max-width: 90vw;
  pointer-events: none;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- 进度 ---------- */
.stage { display: flex; align-items: center; gap: 10px; }
.spinner { width: 18px; height: 18px; border: 2.5px solid #cfd6d4; border-top-color: var(--primary); border-radius: 50%; animation: spin .8s linear infinite; flex: none; }
@keyframes spin { to { transform: rotate(360deg); } }
.progress { height: 6px; background: #e2e6ea; border-radius: 999px; overflow: hidden; margin-top: 8px; }
.progress i { display: block; height: 100%; background: var(--primary); transition: width .3s; }

/* ---------- 试卷页 ---------- */
.paper-layout { display: block; }
.pages-strip { display: flex; gap: 8px; overflow-x: auto; padding: 2px 0 6px; -webkit-overflow-scrolling: touch; }
.pages-strip .thumb { flex: none; width: 76px; height: 100px; border-radius: 8px; border: 1px solid var(--line); object-fit: cover; background: #fff; cursor: zoom-in; }
.pages-strip .thumb-pdf { flex: none; width: 76px; height: 100px; border-radius: 8px; border: 1px solid var(--line); display: flex; align-items: center; justify-content: center; font-size: 12px; color: var(--muted); background: #fff; text-decoration: none; text-align: center; padding: 6px; }
.priority { display: flex; flex-wrap: wrap; gap: 8px; }
.priority button { border: 1px solid #c9ddd8; background: var(--primary-soft); color: var(--primary-dark); border-radius: 999px; padding: 6px 12px; font-size: 13.5px; text-align: left; }
.priority button small { color: var(--muted); margin-left: 4px; }

.q-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; margin-bottom: 12px; box-shadow: var(--shadow); scroll-margin-top: 70px; }
.q-card.skipped { background: #fafafa; border-style: dashed; }
.q-card.retake { border-color: #f1d9a8; }
.q-head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.q-head .num { font-weight: 700; font-size: 16px; }
.q-head .spacer { flex: 1; }
.q-stem { background: #fafbfc; border-radius: 10px; padding: 10px 12px; font-size: 15.5px; overflow-x: auto; }
.q-opts { margin: 8px 0 0; padding: 0 0 0 4px; list-style: none; }
.q-opts li { padding: 2px 0; }
.q-student { margin-top: 8px; padding: 8px 10px; border-left: 3px solid #b9c9e8; background: #f4f7fc; border-radius: 0 10px 10px 0; font-size: 14.5px; overflow-x: auto; }
.q-student .label { font-size: 12px; color: #4c63a8; font-weight: 600; display: block; }
.kp-line { margin-top: 10px; font-size: 14px; }
.kp-line .kps { display: inline-flex; flex-wrap: wrap; gap: 6px; vertical-align: middle; }
.stuck { margin-top: 10px; padding: 10px 12px; border-radius: 10px; background: var(--accent-soft); font-size: 14.5px; }
.stuck .label { font-size: 12px; font-weight: 700; color: var(--warn); display: block; margin-bottom: 2px; }
.stuck ul { margin: 6px 0 0; padding-left: 18px; }
.q-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.reveal { margin-top: 10px; padding: 10px 12px; border-radius: 10px; background: var(--primary-soft); font-size: 14.5px; overflow-x: auto; }
.reveal .label { font-size: 12px; font-weight: 700; color: var(--primary-dark); display: block; margin-bottom: 4px; }
.reveal ol { margin: 4px 0 0; padding-left: 20px; }
.reveal ol li { margin: 3px 0; }
.q-more { margin-top: 8px; }
details.q-edit { margin-top: 10px; }
details.q-edit summary { cursor: pointer; font-size: 14px; color: var(--primary); }
textarea.edit-area { width: 100%; min-height: 90px; border: 1px solid var(--line); border-radius: 10px; padding: 10px; font-size: 15px; margin-top: 8px; resize: vertical; }
.usage-line { font-size: 13px; color: var(--muted); margin-top: 6px; }

/* ---------- 练习面板 ---------- */
.practice { margin-top: 12px; border: 1.5px solid #cfe3de; border-radius: 12px; padding: 12px; background: #f6fbf9; }
.practice h4 { margin: 0 0 6px; font-size: 15px; display: flex; align-items: center; gap: 8px; }
.practice .q-stem { background: #fff; }
.answer-area { width: 100%; min-height: 84px; border: 1px solid var(--line); border-radius: 10px; padding: 10px; font-size: 16px; margin-top: 10px; resize: vertical; background: #fff; }
.feedback { margin-top: 10px; border-radius: 10px; padding: 10px 12px; font-size: 14.5px; }
.feedback.ok { background: var(--ok-soft); }
.feedback.partial { background: var(--warn-soft); }
.feedback.bad { background: var(--danger-soft); }
.feedback ul { margin: 4px 0 0; padding-left: 18px; }
.feedback .verdict { font-weight: 700; display: block; margin-bottom: 4px; }
.attempt-history { font-size: 13px; color: var(--muted); margin-top: 8px; }

/* ---------- 列表 ---------- */
.list { list-style: none; margin: 0; padding: 0; }
.list li { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; margin-bottom: 10px; display: flex; gap: 10px; align-items: center; }
.list li .body { flex: 1; min-width: 0; }
.list li .t { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list li .s { font-size: 13px; color: var(--muted); }
.list li.clickable { cursor: pointer; }
.filters { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
select.sel { padding: 8px 10px; border: 1px solid var(--line); border-radius: 10px; background: #fff; font-size: 14px; max-width: 100%; }

/* ---------- 账号 ---------- */
.account-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.stat { background: var(--bg); border-radius: 10px; padding: 10px; }
.stat .v { font-size: 20px; font-weight: 700; }
.stat .l { font-size: 12px; color: var(--muted); }
.ledger { list-style: none; padding: 0; margin: 8px 0 0; font-size: 13px; }
.ledger li { display: flex; justify-content: space-between; gap: 8px; padding: 6px 0; border-bottom: 1px dashed var(--line); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.form-grid label { font-size: 13px; color: var(--muted); display: block; }
.form-grid select, .form-grid input { width: 100%; padding: 10px; border: 1px solid var(--line); border-radius: 10px; font-size: 15px; background: #fff; }
.switch { display: flex; align-items: center; gap: 10px; }
.switch input { width: 20px; height: 20px; }

/* ---------- 灯箱 ---------- */
.lightbox { position: fixed; inset: 0; background: rgba(0, 0, 0, .92); z-index: 95; display: none; overflow: auto; -webkit-overflow-scrolling: touch; touch-action: pan-x pan-y pinch-zoom; }
.lightbox.open { display: block; }
.lightbox img { display: block; margin: 0 auto; max-width: none; width: 100%; }
.lightbox .close { position: fixed; top: calc(12px + var(--safe-top)); right: 12px; background: rgba(255, 255, 255, .9); border-radius: 999px; width: 40px; height: 40px; border: 0; font-size: 20px; }
.lightbox .zoom { position: fixed; bottom: calc(16px + var(--safe-bottom)); left: 50%; transform: translateX(-50%); display: flex; gap: 8px; }
.lightbox .zoom button { background: rgba(255, 255, 255, .9); border: 0; border-radius: 999px; width: 44px; height: 44px; font-size: 20px; }

/* ---------- 公式 ---------- */
.katex-display { overflow-x: auto; overflow-y: hidden; padding: 2px 0; }
.katex { font-size: 1.05em; }
.md-table { display: block; overflow-x: auto; }
.md-table table { border-collapse: collapse; }
.md-table td, .md-table th { border: 1px solid var(--line); padding: 4px 8px; }

/* ---------- 桌面端 ---------- */
@media (min-width: 900px) {
  .page { max-width: 1180px; }
  .paper-layout { display: grid; grid-template-columns: 420px 1fr; gap: 18px; align-items: start; }
  .paper-side { position: sticky; top: 64px; }
  .pages-strip { flex-direction: column; overflow: visible; }
  .pages-strip .thumb, .pages-strip .thumb-pdf { width: 100%; height: auto; max-height: 520px; object-fit: contain; }
  .dropzone { display: block; }
  .upload-options { grid-template-columns: repeat(3, 1fr); }
  .sheet { left: 50%; right: auto; width: 560px; transform: translate(-50%, 105%); border-radius: 20px 20px 0 0; }
  .sheet.open { transform: translate(-50%, 0); }
  .home-wrap { gap: 40px; }
  .brand-logo { width: 300px; }
}
@media (hover: none) { .btn:hover { background: inherit; } .btn-primary:hover { background: var(--primary); } }
@media print { .topbar, .drawer, .sheet, .toast { display: none !important; } }
