/* ==========================================================
   错题大师 V0.1 —— 样式
   风格：深蓝学习工具感（和作品集其它页面一个家族，但更"书房"）
   重点：手机优先（高三学生多用手机），打印友好（家长要打印）
   ========================================================== */

:root {
  --ink:   #1F2937;
  --ink2:  #5B6472;
  --ink3:  #8B94A3;
  --paper: #F5F7FB;
  --card:  #FFFFFF;
  --line:  #E4E9F2;
  --brand: #3B5BDB;
  --brand-d: #2F4BC0;
  --brand-l: #EEF2FF;
  --accent: #F08C00;
  --err:  #E03131;
  --ok:   #0CA678;
  --warn: #E8A33D;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(16,24,40,.05), 0 4px 14px rgba(16,24,40,.06);
  --shadow-h: 0 6px 22px rgba(47,75,192,.16);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Helvetica Neue", sans-serif;
  background: var(--paper);
  color: var(--ink);
  padding-top: 56px;              /* 给顶部导航留位 */
  -webkit-font-smoothing: antialiased;
  line-height: 1.6;
}
.wrap { max-width: 880px; margin: 0 auto; padding: 0 16px; }
.hide { display: none !important; }
button { font-family: inherit; cursor: pointer; }

/* ---------- 顶部导航（独立站点自己的品牌条） ---------- */
.top-nav {
  position: fixed; top: 0; left: 0; right: 0; z-index: 9999;
  height: 56px;
  background: rgba(7, 17, 32, .94);
  -webkit-backdrop-filter: saturate(1.5) blur(14px);
  backdrop-filter: saturate(1.5) blur(14px);
  border-bottom: 1px solid rgba(140, 180, 255, .13);
}
.top-nav-in {
  max-width: 880px; margin: 0 auto; height: 100%;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 0 16px;
}
.top-brand {
  display: inline-flex; align-items: baseline; gap: 7px;
  color: #E9EFFA; text-decoration: none; font-size: 16.5px; font-weight: 800;
  letter-spacing: .02em; white-space: nowrap;
}
.top-brand span {
  font-size: 11.5px; font-weight: 700; color: #8FBBFF;
  border: 1px solid rgba(140, 180, 255, .3); border-radius: 100px; padding: 1px 8px;
}
.top-kicker { color: #56688A; font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- 通用组件 ---------- */
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 20px; margin: 14px 0;
}
.card h2 { font-size: 17px; margin: 0 0 8px; }
.hint { font-size: 13.5px; color: var(--ink2); margin: 0 0 12px; }
.tiny { font-size: 12.5px; color: var(--ink3); }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 12px; }
.row.end { justify-content: flex-end; }
.pill {
  display: inline-block; font-size: 12px; font-weight: 600; color: var(--brand);
  background: var(--brand-l); border-radius: 100px; padding: 2px 10px; margin-left: 6px;
  vertical-align: 2px;
}

.btn {
  border: 1.5px solid var(--line); background: #fff; color: var(--ink);
  font-size: 14.5px; font-weight: 600; padding: 10px 16px; border-radius: 10px;
  transition: transform .12s, box-shadow .2s, background .2s, border-color .2s;
}
.btn:hover { border-color: var(--brand); }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-d); border-color: var(--brand-d); box-shadow: var(--shadow-h); }
.btn-lg { font-size: 16px; padding: 12px 26px; }
.btn-ghost { background: transparent; }
.btn-ghost-danger { background: transparent; color: var(--err); border-color: #F5D2D2; }
.btn-ghost-danger:hover { border-color: var(--err); }
.btn-tiny { font-size: 12.5px; padding: 6px 11px; border-radius: 8px; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.mini-select {
  font-size: 12.5px; padding: 6px 8px; border-radius: 8px; border: 1.5px solid var(--line);
  background: #fff; color: var(--ink2); max-width: 150px;
}

/* ---------- 首屏 ---------- */
.gate { padding: 46px 0 60px; text-align: center; }
.gate-badge {
  display: inline-block; font-size: 12.5px; font-weight: 700; color: var(--brand);
  background: var(--brand-l); border-radius: 100px; padding: 4px 14px; margin-bottom: 16px;
  letter-spacing: .04em;
}
.gate h1 { font-size: 40px; margin: 0 0 12px; letter-spacing: .02em; }
.gate-sub { font-size: 16.5px; color: var(--ink2); margin: 0 auto 18px; max-width: 560px; }
.gate-sub strong { color: var(--brand-d); }
.gate-ai {
  display: inline-block; font-size: 13px; color: #007A55; background: #D9F7EC;
  border: 1.5px solid #9CE8CE; padding: 6px 16px; border-radius: 20px; margin: 0 0 20px;
}
.gate-ai.off { color: #8A5A00; background: #FFF4D6; border-color: #F0D48A; }
.gate-cta { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }
.gate-continue { margin: 14px 0 0; font-size: 14px; }
.gate-continue a { color: var(--brand); font-weight: 600; text-decoration: none; }
.gate-points {
  list-style: none; padding: 0; margin: 36px auto 0; max-width: 520px; text-align: left;
}
.gate-points li {
  background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  padding: 10px 16px; margin-bottom: 8px; font-size: 14.5px; color: var(--ink2);
}
.gate-points b { color: var(--ink); }
.gate-privacy { font-size: 12.5px; color: var(--ink3); margin-top: 24px; }

/* ---------- 应用栏 + 标签 ---------- */
.appbar { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 18px 0 0; flex-wrap: wrap; }
.appbar-title { font-size: 19px; font-weight: 800; }
.appbar-title span { font-size: 12px; color: var(--brand); background: var(--brand-l); padding: 2px 8px; border-radius: 100px; vertical-align: 2px; }
.appbar-actions { display: flex; align-items: center; gap: 8px; }
.syncdot { font-size: 12px; color: var(--ink3); white-space: nowrap; }
.syncdot.ok { color: #087F5B; }
.syncdot.busy { color: #9A6A00; }
.syncdot.off { color: #C92A2A; }

.tabs {
  position: sticky; top: 56px; z-index: 50;
  display: flex; gap: 6px; margin: 14px 0 4px; padding: 8px 0;
  background: linear-gradient(var(--paper) 82%, rgba(245,247,251,0));
}
.tab {
  flex: 1; border: 1.5px solid var(--line); background: #fff; color: var(--ink2);
  font-size: 14px; font-weight: 650; padding: 10px 8px; border-radius: 10px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.tab.on { background: var(--brand); border-color: var(--brand); color: #fff; }
.cnt { font-size: 11.5px; font-weight: 700; opacity: .85; margin-left: 2px; }

/* ---------- 录入 ---------- */
.paste {
  width: 100%; border: 1.5px solid var(--line); border-radius: 10px; padding: 12px;
  font-size: 14.5px; line-height: 1.7; font-family: inherit; resize: vertical; min-height: 120px;
  background: #FBFCFE;
}
.paste:focus, .inp:focus { outline: none; border-color: var(--brand); background: #fff; }

.qlist { margin: 12px 0 4px; }
.qitem {
  display: flex; gap: 10px; align-items: flex-start;
  border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; margin-bottom: 8px;
  background: #FBFCFE;
}
.qitem .qno {
  flex: 0 0 auto; min-width: 30px; height: 30px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700; color: var(--brand); background: var(--brand-l);
  margin-top: 2px;
}
.qitem .qbody { flex: 1; min-width: 0; }
.qitem .qtext { font-size: 14px; word-break: break-word; white-space: pre-wrap; }
.qitem .qtext.clamp { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.qitem .qthumb { height: 64px; border-radius: 8px; border: 1px solid var(--line); }
.qitem .qmeta { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.qitem .qops { display: flex; flex-direction: column; gap: 4px; }
.qop {
  border: none; background: transparent; color: var(--ink3); font-size: 13px;
  padding: 3px 6px; border-radius: 6px;
}
.qop:hover { background: var(--line); color: var(--ink); }
.qitem textarea.qedit {
  width: 100%; border: 1.5px solid var(--line); border-radius: 8px; padding: 8px;
  font-size: 14px; font-family: inherit; min-height: 76px; resize: vertical;
}
.empty { text-align: center; color: var(--ink3); font-size: 14px; padding: 22px 10px; border: 1.5px dashed var(--line); border-radius: 12px; margin: 10px 0; }

.chip {
  display: inline-block; font-size: 12px; font-weight: 600;
  border-radius: 100px; padding: 2px 10px; line-height: 1.7;
}
.chip-status { background: #EEF1F6; color: var(--ink2); }
.chip-status.ok { background: #DCF5EC; color: #087F5B; }
.chip-status.working { background: #FFF4D6; color: #9A6A00; }
.chip-status.failed { background: #FDE3E3; color: #C92A2A; }
.chip-subject { color: #fff; }
.chip-reason { color: #fff; }
.chip-point { background: #EFF3FF; color: var(--brand-d); border: 1px solid #D6E0FF; }
.chip-diff { background: #F4F0FF; color: #6741D9; }

.progress { margin-top: 14px; }
.progress .bar { height: 8px; background: var(--line); border-radius: 100px; overflow: hidden; }
.progress .bar i { display: block; height: 100%; width: 0; background: var(--brand); border-radius: 100px; transition: width .3s; }
.progress .tiny { margin-top: 6px; }
.note {
  margin-top: 12px; font-size: 13.5px; border-radius: 10px; padding: 10px 12px;
  background: #FFF4D6; color: #7A5600; border: 1px solid #F0D48A;
}
.note.err { background: #FDE3E3; color: #A61B1B; border-color: #F5C2C2; }

/* ---------- 报告 ---------- */
.stat-row { display: flex; gap: 10px; flex-wrap: wrap; margin: 14px 0; }
.stat-box {
  flex: 1 1 140px; background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  padding: 12px 14px; box-shadow: var(--shadow);
}
.stat-box b { display: block; font-size: 22px; line-height: 1.3; }
.stat-box span { font-size: 12.5px; color: var(--ink3); }

.ai-card { border-left: 4px solid var(--brand); }
.ai-card .who { font-size: 12.5px; color: var(--brand); font-weight: 700; margin-bottom: 6px; }
.ai-card p { margin: 0 0 8px; font-size: 15px; }
.encourage {
  margin-top: 10px; font-size: 14.5px; color: var(--brand-d); font-weight: 600;
  background: var(--brand-l); border-radius: 10px; padding: 10px 14px;
}

.h3 { font-size: 16px; margin: 22px 0 10px; }

.barline { display: flex; align-items: center; gap: 10px; margin-bottom: 7px; }
.barline .lb { flex: 0 0 auto; min-width: 92px; font-size: 13.5px; color: var(--ink2); text-align: right; }
.barline .tr { flex: 1; background: #EEF1F6; border-radius: 8px; height: 20px; overflow: hidden; }
.barline .tr i { display: block; height: 100%; border-radius: 8px; min-width: 6px; }
.barline .vl { flex: 0 0 auto; font-size: 13px; font-weight: 700; color: var(--ink); min-width: 46px; }

.prio {
  display: flex; gap: 12px; align-items: flex-start;
  border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; margin-bottom: 8px; background: #fff;
}
.prio .no {
  flex: 0 0 auto; width: 26px; height: 26px; border-radius: 50%;
  background: var(--brand); color: #fff; font-weight: 800; font-size: 14px;
  display: flex; align-items: center; justify-content: center; margin-top: 2px;
}
.prio b { font-size: 15px; }
.prio .why { font-size: 13.5px; color: var(--ink2); }
.prio .how { font-size: 13.5px; color: var(--brand-d); margin-top: 2px; }

.plan { list-style: none; padding: 0; margin: 0; }
.plan li {
  position: relative; padding: 8px 12px 8px 34px; font-size: 14px;
  border-bottom: 1px dashed var(--line);
}
.plan li:last-child { border-bottom: none; }
.plan li::before {
  content: "□"; position: absolute; left: 12px; color: var(--brand); font-size: 14px;
}

.qcard {
  border: 1px solid var(--line); border-radius: 12px; background: #fff;
  margin-bottom: 10px; overflow: hidden;
}
.qcard-head {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 10px 14px; cursor: pointer; user-select: none;
}
.qcard-head .qn { font-weight: 800; color: var(--ink3); font-size: 13px; }
.qcard-head .t { flex: 1; font-size: 14.5px; min-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.qcard-mastered { opacity: .55; }
.qcard-mastered .t { text-decoration: line-through; }
.qcard-body { padding: 2px 14px 14px; border-top: 1px solid var(--line); display: none; }
.qcard.open .qcard-body { display: block; }
.qcard-body .qsrc { font-size: 13px; color: var(--ink3); background: #F8FAFD; border-radius: 8px; padding: 8px 10px; margin: 10px 0; white-space: pre-wrap; }
.qcard-body .qsrc img { max-width: 100%; border-radius: 8px; }
.kvline { font-size: 14px; margin: 8px 0; }
.kvline b { color: var(--ink2); font-weight: 650; margin-right: 6px; }
.qcard-ops { margin-top: 10px; display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.link-btn { background: none; border: none; color: var(--brand); font-size: 13px; font-weight: 600; padding: 4px 6px; border-radius: 6px; }
.link-btn:hover { background: var(--brand-l); }

details.acc { margin-top: 8px; }
details.acc summary { font-size: 13.5px; color: var(--brand); cursor: pointer; font-weight: 600; }
details.acc .inner { font-size: 14px; padding: 8px 2px; white-space: pre-wrap; }

/* ---------- 错题本 ---------- */
.bookbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.bookbar .inp { flex: 1 1 200px; width: auto; min-width: 150px; }
.bookbar .mini-select { max-width: 132px; }
.cbx { display: inline-flex; align-items: center; gap: 5px; font-size: 13px; color: var(--ink2); white-space: nowrap; cursor: pointer; }
.cbx input { margin: 0; }
.qcard-head .booksrc { flex: 0 0 auto; font-size: 12px; color: var(--ink3); white-space: nowrap; }

/* ---------- 复练 ---------- */
.pcard { border: 1px solid var(--line); border-radius: 12px; background: #fff; padding: 14px 16px; margin-bottom: 10px; }
.pcard .q { font-size: 14.5px; white-space: pre-wrap; }
.pcard .ans { display: none; font-size: 14px; color: #087F5B; background: #EFFAF5; border-radius: 8px; padding: 10px 12px; margin-top: 10px; white-space: pre-wrap; }
.pcard.show .ans { display: block; }
.pcard .ops { margin-top: 10px; display: flex; gap: 8px; }

/* ---------- 弹窗 ---------- */
.modal { position: fixed; inset: 0; z-index: 10000; }
.modal-mask { position: absolute; inset: 0; background: rgba(15, 22, 40, .5); }
.modal-box {
  position: relative; max-width: 460px; margin: 8vh auto 0; background: #fff;
  border-radius: 16px; box-shadow: 0 20px 60px rgba(0,0,0,.25); overflow: hidden;
  width: calc(100% - 32px);
}
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.modal-head h3 { margin: 0; font-size: 16px; }
.modal-x { border: none; background: none; font-size: 22px; color: var(--ink3); line-height: 1; padding: 0 4px; }
.modal-body { padding: 16px 18px 20px; }
.lbl { display: block; font-size: 13px; font-weight: 650; margin: 10px 0 4px; }
.inp { width: 100%; border: 1.5px solid var(--line); border-radius: 9px; padding: 9px 11px; font-size: 14px; font-family: inherit; background: #FBFCFE; }
.srv-state { font-size: 14px; border-radius: 10px; padding: 10px 12px; background: #DCF5EC; color: #087F5B; border: 1px solid #9CE8CE; }
.srv-state.off { background: #FFF4D6; color: #8A5A00; border-color: #F0D48A; }

/* ---------- toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 34px; transform: translateX(-50%);
  background: rgba(23, 30, 48, .95); color: #fff; font-size: 14px;
  padding: 10px 20px; border-radius: 100px; z-index: 10001; max-width: 86vw;
  box-shadow: 0 8px 30px rgba(0,0,0,.3); text-align: center;
}

/* ---------- 页脚 ---------- */
.foot { margin-top: 40px; padding: 20px 0 34px; text-align: center; font-size: 12.5px; color: var(--ink3); border-top: 1px solid var(--line); }

/* ---------- 手机 ---------- */
@media (max-width: 600px) {
  .gate h1 { font-size: 33px; }
  .gate-sub { font-size: 15px; }
  .card { padding: 16px 14px; }
  .barline .lb { min-width: 74px; font-size: 12.5px; }
  .top-nav-in { padding: 0 12px; gap: 8px; }
  .top-kicker { display: none; }
  .tab { font-size: 12.5px; padding: 9px 4px; }
}

/* ---------- 打印：只印报告 ---------- */
@media print {
  .top-nav, .appbar, .tabs, .foot, #tab-input, #tab-practice, #tab-book, .no-print,
  #toast, .modal, .gate { display: none !important; }
  body { padding-top: 0 !important; background: #fff; }
  #tab-report { display: block !important; }
  .wrap { max-width: 100%; padding: 0; }
  .card, .stat-box, .qcard, .prio { box-shadow: none !important; break-inside: avoid; }
  .qcard-body { display: block !important; }
  .qcard-head .t { white-space: normal; }
  details.acc .inner { display: block !important; }
  .print-title { display: block !important; }
}
.print-title { display: none; font-size: 20px; font-weight: 800; margin: 0 0 4px; }
