/* AI 北京中考备考训练系统 — modern, premium study UI.
   Editorial type · airy spacing · hairline depth · one confident indigo accent.
   Class names kept stable so app.js logic is untouched. */

:root {
  --bg: #f4f5f8;
  --bg-tint: #eef1f7;
  --surface: #ffffff;
  --surface-2: #f1f3f8;
  --surface-3: #e9edf5;
  --border: #e4e7ef;
  --border-2: #d4d9e4;
  --hair: rgba(20, 28, 56, .07);

  --ink: #14161d;
  --ink-soft: #4b5566;
  --muted: #8a92a4;

  --brand: #1b2a6b;          /* deep ink-indigo (primary dark blue) */
  --brand-2: #2a3f9e;
  --accent: #3d57ec;         /* vivid interactive indigo */
  --accent-ink: #2742c8;
  --tint: #eaeefe;           /* accent wash */
  --tint-2: #f3f5ff;

  --good: #0e9f6e;
  --good-soft: #e4f7ef;
  --good-ink: #0a7a54;
  --bad: #e24a52;
  --bad-soft: #fdecec;
  --bad-ink: #b8323a;
  --warn: #c5860f;
  --warn-soft: #fbf2dd;

  --radius: 18px;
  --radius-md: 14px;
  --radius-sm: 10px;
  --shadow-xs: 0 1px 2px var(--hair);
  --shadow-sm: 0 2px 8px -2px rgba(20,28,56,.10), 0 1px 2px rgba(20,28,56,.05);
  --shadow: 0 14px 38px -16px rgba(22,30,70,.30), 0 4px 12px -6px rgba(22,30,70,.12);
  --maxw: 780px;

  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
          "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  background:
    radial-gradient(1200px 620px at 78% -8%, #e9ecfb 0%, rgba(233,236,251,0) 60%),
    radial-gradient(900px 520px at -5% 4%, #eef0f9 0%, rgba(238,240,249,0) 55%),
    var(--bg);
  background-attachment: fixed;
  color: var(--ink);
  line-height: 1.62;
  font-size: 16px;
  letter-spacing: -0.003em;
  -webkit-text-size-adjust: 100%;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
a { color: var(--accent-ink); text-decoration: none; }
a:hover { color: var(--accent); }
img { max-width: 100%; height: auto; }
::selection { background: var(--tint); }

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 50;
  background: rgba(247,248,251,.78);
  backdrop-filter: saturate(1.4) blur(14px);
  -webkit-backdrop-filter: saturate(1.4) blur(14px);
  border-bottom: 1px solid var(--hair);
}
.topbar .inner { max-width: 1120px; margin: 0 auto; padding: 12px 20px; display: flex; align-items: center; gap: 14px; }
.brand { display: flex; align-items: center; gap: 11px; cursor: pointer; }
.brand .logo {
  width: 34px; height: 34px; border-radius: 11px; flex: none;
  background: linear-gradient(150deg, var(--brand) 8%, var(--accent) 120%);
  color: #fff; display: grid; place-items: center; font-size: 16px; font-weight: 800;
  box-shadow: 0 4px 12px -4px rgba(61,87,236,.55), inset 0 1px 0 rgba(255,255,255,.25);
}
.brand .name { font-size: 15.5px; font-weight: 700; color: var(--ink); letter-spacing: -.01em; }
.brand .sub { font-size: 11px; color: var(--muted); font-weight: 500; letter-spacing: .01em; }
.topbar .spacer { flex: 1; }
.navlink { color: var(--ink-soft); font-size: 14px; padding: 7px 13px; border-radius: 9px; cursor: pointer; font-weight: 500; transition: .15s; }
.navlink:hover { background: var(--surface-2); color: var(--ink); }
.navlink.active { color: var(--accent-ink); background: var(--tint); font-weight: 600; }
.who { font-size: 12.5px; color: var(--muted); }

/* ---------- layout ---------- */
.wrap { max-width: var(--maxw); margin: 0 auto; padding: 26px 20px 96px; }
.wrap.wide { max-width: 1120px; }
.row { display: flex; gap: 12px; flex-wrap: wrap; }
.grid { display: grid; gap: 14px; }
.grid.cols { grid-template-columns: repeat(auto-fill, minmax(168px, 1fr)); }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.center { text-align: center; }
.spacer { flex: 1; }

/* ---------- cards / tiles ---------- */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-xs);
}
.card.pad { padding: 20px; }
.tile {
  position: relative; overflow: hidden;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 20px; cursor: pointer; transition: transform .16s cubic-bezier(.2,.7,.3,1), box-shadow .16s, border-color .16s;
  box-shadow: var(--shadow-xs);
}
.tile::after {
  content: ""; position: absolute; inset: 0; border-radius: inherit; pointer-events: none;
  background: linear-gradient(160deg, rgba(61,87,236,.05), rgba(61,87,236,0) 42%); opacity: 0; transition: .16s;
}
.tile:hover { transform: translateY(-3px); box-shadow: var(--shadow); border-color: var(--border-2); }
.tile:hover::after { opacity: 1; }
.tile h3 { margin: 0 0 5px; font-size: 16.5px; font-weight: 700; color: var(--ink); letter-spacing: -.01em; }
.tile p { margin: 0; font-size: 13px; color: var(--muted); line-height: 1.55; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 1px solid var(--border-2); background: var(--surface); color: var(--ink);
  border-radius: 11px; padding: 11px 18px; font-size: 14.5px; font-weight: 600;
  cursor: pointer; transition: .14s; font-family: inherit; line-height: 1.2;
  box-shadow: var(--shadow-xs);
}
.btn:hover { border-color: var(--accent); color: var(--accent-ink); transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn.primary { background: linear-gradient(170deg, var(--brand-2), var(--brand)); border-color: transparent; color: #fff; box-shadow: 0 8px 20px -8px rgba(27,42,107,.6); }
.btn.primary:hover { color: #fff; filter: brightness(1.08); }
.btn.accent { background: linear-gradient(170deg, var(--accent), var(--accent-ink)); border-color: transparent; color: #fff; box-shadow: 0 8px 20px -8px rgba(61,87,236,.6); }
.btn.accent:hover { color: #fff; filter: brightness(1.07); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--accent-ink); box-shadow: none; }
.btn.ghost:hover { background: var(--tint); transform: none; }
.btn.sm { padding: 7px 13px; font-size: 13px; border-radius: 9px; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }

/* ---------- chips / pills ---------- */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  display: inline-flex; align-items: center; gap: 5px; padding: 6px 13px; border-radius: 999px;
  background: var(--surface); border: 1px solid var(--border-2); color: var(--ink-soft);
  font-size: 13px; cursor: pointer; transition: .14s; user-select: none; font-weight: 500;
}
.chip:hover { border-color: var(--accent); color: var(--accent-ink); }
.chip.on { background: var(--tint); border-color: transparent; color: var(--accent-ink); font-weight: 650; box-shadow: inset 0 0 0 1px rgba(61,87,236,.25); }
.pill {
  display: inline-flex; align-items: center; gap: 4px; padding: 3px 10px; border-radius: 999px;
  font-size: 11.5px; font-weight: 650; line-height: 1.7; letter-spacing: .01em;
}
.pill.navy { background: var(--tint); color: var(--accent-ink); }
.pill.good { background: var(--good-soft); color: var(--good-ink); }
.pill.bad { background: var(--bad-soft); color: var(--bad-ink); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.gray { background: var(--surface-2); color: var(--muted); }

/* ---------- headings ---------- */
.page-head { margin-bottom: 20px; }
.page-head h1 { font-size: 25px; margin: 0 0 5px; color: var(--ink); font-weight: 750; letter-spacing: -.02em; }
.page-head .crumbs { font-size: 13px; color: var(--muted); }
.crumbs a { color: var(--muted); }
.crumbs a:hover { color: var(--accent); }
.section-title {
  font-size: 12.5px; font-weight: 700; color: var(--muted); margin: 28px 0 12px;
  letter-spacing: .08em; text-transform: uppercase;
}

/* ---------- hero ---------- */
.hero {
  position: relative; overflow: hidden;
  background:
    radial-gradient(120% 140% at 88% -20%, #3957f0 0%, rgba(57,87,240,0) 46%),
    radial-gradient(130% 120% at -10% 120%, #4d63ff 0%, rgba(77,99,255,0) 50%),
    linear-gradient(155deg, #1a2566 0%, #1b2a6b 45%, #243b9c 100%);
  color: #fff; border-radius: 24px; padding: 38px 32px;
  box-shadow: 0 28px 60px -28px rgba(22,30,80,.6);
  border: 1px solid rgba(255,255,255,.07);
}
.hero::before {
  content: ""; position: absolute; inset: 0;
  background-image: radial-gradient(rgba(255,255,255,.10) 1px, transparent 1.4px);
  background-size: 22px 22px; opacity: .35; mask-image: linear-gradient(135deg, #000, transparent 65%);
  -webkit-mask-image: linear-gradient(135deg, #000, transparent 65%);
}
.hero > * { position: relative; }
.hero h1 { margin: 0 0 10px; font-size: 30px; font-weight: 780; letter-spacing: -.025em; line-height: 1.18; }
.hero p { margin: 0; opacity: .9; font-size: 15.5px; max-width: 600px; line-height: 1.6; }
.hero .stats { display: flex; gap: 14px; margin-top: 24px; flex-wrap: wrap; }
.hero .stat {
  background: rgba(255,255,255,.10); border: 1px solid rgba(255,255,255,.14);
  border-radius: 14px; padding: 12px 16px; backdrop-filter: blur(4px); min-width: 84px;
}
.hero .stat b { font-size: 24px; display: block; font-weight: 760; letter-spacing: -.02em; }
.hero .stat span { font-size: 11.5px; opacity: .8; }

/* ---------- question ---------- */
.q-stem { font-size: 16.5px; line-height: 1.82; color: var(--ink); }
.material {
  background: linear-gradient(0deg, var(--surface-2), var(--surface-2));
  border: 1px solid var(--border); border-left: 3px solid var(--accent);
  border-radius: 12px; padding: 14px 16px; margin: 14px 0; font-size: 15px; color: var(--ink-soft);
  white-space: pre-wrap; line-height: 1.78;
}
.q-meta { display: flex; flex-wrap: wrap; gap: 7px; align-items: center; margin: 2px 0 14px; }
.opt {
  display: flex; gap: 12px; align-items: flex-start; padding: 13px 15px; margin: 9px 0;
  border: 1.5px solid var(--border); border-radius: 13px; cursor: pointer; background: var(--surface);
  transition: .13s;
}
.opt:hover { border-color: var(--accent); background: var(--tint-2); }
.opt.sel { border-color: var(--accent); background: var(--tint); box-shadow: inset 0 0 0 1px var(--accent); }
.opt.correct { border-color: var(--good); background: var(--good-soft); box-shadow: inset 0 0 0 1px var(--good); }
.opt.wrong { border-color: var(--bad); background: var(--bad-soft); box-shadow: inset 0 0 0 1px var(--bad); }
.opt .key {
  flex: none; width: 27px; height: 27px; border-radius: 8px; background: var(--surface-2);
  display: grid; place-items: center; font-weight: 700; font-size: 13.5px; color: var(--ink-soft);
  transition: .13s;
}
.opt.sel .key { background: var(--accent); color: #fff; }
.opt.correct .key { background: var(--good); color: #fff; }
.opt.wrong .key { background: var(--bad); color: #fff; }
.q-images figure { background: var(--surface); }

textarea, input[type=text], input[type=number], input[type=password], select {
  width: 100%; font-family: inherit; font-size: 15px; color: var(--ink);
  border: 1.5px solid var(--border-2); border-radius: 12px; padding: 12px 14px; background: var(--surface);
  resize: vertical; transition: .14s;
}
textarea:focus, input:focus, select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3.5px var(--tint); }
textarea { min-height: 116px; line-height: 1.75; }
label.fld { display: block; font-size: 13px; color: var(--ink-soft); margin: 14px 0 6px; font-weight: 650; }

/* uploaded images */
.thumbs { display: flex; gap: 9px; flex-wrap: wrap; margin-top: 12px; }
.thumb { position: relative; width: 82px; height: 82px; border-radius: 11px; overflow: hidden; border: 1px solid var(--border); box-shadow: var(--shadow-xs); }
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.thumb .x { position: absolute; top: 3px; right: 3px; background: rgba(10,14,30,.66); color: #fff;
  width: 19px; height: 19px; border-radius: 50%; display: grid; place-items: center; font-size: 12px; cursor: pointer; }

/* ---------- grade result ---------- */
.grade { border-radius: 16px; padding: 18px; margin-top: 18px; border: 1px solid var(--border); background: var(--surface); }
.grade.ok { background: linear-gradient(180deg, var(--good-soft), #fff 80%); border-color: #c2ead6; }
.grade.no { background: linear-gradient(180deg, var(--bad-soft), #fff 80%); border-color: #f3c9c9; }
.grade.partial { background: linear-gradient(180deg, var(--warn-soft), #fff 80%); border-color: #ecdcb1; }
.grade h3 { margin: 0 0 12px; display: flex; align-items: center; gap: 9px; font-size: 17px; font-weight: 720; }
.grade .score { font-size: 22px; font-weight: 820; letter-spacing: -.02em; }
.kv { margin: 12px 0; }
.kv .k { font-size: 12px; font-weight: 750; color: var(--accent-ink); margin-bottom: 3px; text-transform: uppercase; letter-spacing: .05em; }
.kv .v { font-size: 14.5px; color: var(--ink); line-height: 1.72; }
.kv ul { margin: 5px 0; padding-left: 20px; }
.kv li { margin: 3px 0; }
.collapse-head { cursor: pointer; display: flex; align-items: center; gap: 7px; font-weight: 700; color: var(--accent-ink); font-size: 14px; }
.collapse-head .caret { transition: .15s; font-size: 11px; }
.collapse.closed .collapse-body { display: none; }
.collapse.closed .caret { transform: rotate(-90deg); }

/* ---------- chat ---------- */
.chat { margin-top: 16px; }
.msg { padding: 11px 15px; border-radius: 15px; margin: 9px 0; max-width: 92%; font-size: 14.5px; line-height: 1.72; }
.msg.user { background: linear-gradient(170deg, var(--accent), var(--accent-ink)); color: #fff; margin-left: auto; border-bottom-right-radius: 5px; }
.msg.assistant { background: var(--surface-2); border: 1px solid var(--border); border-bottom-left-radius: 5px; }
.chat-input { display: flex; gap: 9px; margin-top: 10px; }
.chat-input textarea { min-height: 46px; }
.ai-disclaimer { font-size: 12px; color: var(--muted); margin-top: 8px; }

/* ---------- exam bar / timer ---------- */
.exam-bar {
  position: sticky; top: 62px; z-index: 30; background: rgba(255,255,255,.86); backdrop-filter: blur(12px);
  border: 1px solid var(--border); border-radius: 14px; padding: 11px 16px; margin-bottom: 16px;
  display: flex; align-items: center; gap: 12px; box-shadow: var(--shadow-sm);
}
.timer { font-variant-numeric: tabular-nums; font-weight: 820; font-size: 19px; color: var(--brand); letter-spacing: -.01em; }
.timer.warn { color: var(--bad); }
.qnav { display: flex; flex-wrap: wrap; gap: 7px; margin: 4px 0 16px; }
.qnav .b {
  width: 34px; height: 34px; border-radius: 9px; border: 1px solid var(--border-2); background: var(--surface);
  display: grid; place-items: center; font-size: 13px; cursor: pointer; color: var(--ink-soft); transition: .12s; font-weight: 600;
}
.qnav .b:hover { border-color: var(--accent); }
.qnav .b.answered { background: var(--tint); border-color: transparent; color: var(--accent-ink); font-weight: 700; }
.qnav .b.current { outline: 2px solid var(--accent); outline-offset: 1px; }

/* ---------- tables / report ---------- */
table.rep { width: 100%; border-collapse: collapse; font-size: 14px; }
table.rep th, table.rep td { text-align: left; padding: 10px 11px; border-bottom: 1px solid var(--border); }
table.rep th { color: var(--muted); font-weight: 600; font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em; }
table.rep tr:last-child td { border-bottom: 0; }
.bar { height: 8px; border-radius: 5px; background: var(--surface-3); overflow: hidden; }
.bar > span { display: block; height: 100%; background: linear-gradient(90deg, var(--accent), var(--brand-2)); border-radius: 5px; }

/* ---------- credibility banner ---------- */
.cred-note { font-size: 12.5px; padding: 9px 12px; border-radius: 11px; margin: 10px 0; background: var(--warn-soft); color: #7a5210; border: 1px solid #ecdcb1; line-height: 1.55; }
.cred-note.low { background: var(--bad-soft); color: var(--bad-ink); border-color: #f3c9c9; }
.cred-note.ai { background: var(--tint); color: var(--accent-ink); border-color: #cdd7fb; }

/* ---------- misc ---------- */
.spinner { width: 18px; height: 18px; border: 2.5px solid var(--surface-3); border-top-color: var(--accent); border-radius: 50%; animation: spin .7s linear infinite; display: inline-block; vertical-align: middle; }
@keyframes spin { to { transform: rotate(360deg); } }
.loading { display: flex; align-items: center; gap: 10px; color: var(--muted); padding: 28px 0; justify-content: center; font-size: 14px; }
.empty { text-align: center; color: var(--muted); padding: 48px 18px; }
.empty h2 { color: var(--ink-soft); font-weight: 700; }
.divider { height: 1px; background: var(--border); margin: 18px 0; border: 0; }
.toast {
  position: fixed; bottom: 26px; left: 50%; transform: translateX(-50%) translateY(8px); z-index: 200;
  background: rgba(20,22,29,.95); color: #fff; padding: 11px 20px; border-radius: 12px; font-size: 14px;
  box-shadow: var(--shadow); opacity: 0; transition: .26s; pointer-events: none; backdrop-filter: blur(8px);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.katex { font-size: 1.03em; }
.katex-display { overflow-x: auto; overflow-y: hidden; padding: 6px 0; }

.actionbar {
  position: sticky; bottom: 0; background: rgba(255,255,255,.92); backdrop-filter: blur(8px);
  border-top: 1px solid var(--border); padding: 11px 20px; margin: 18px -20px -96px; display: flex; gap: 10px;
}

/* ---------- mobile ---------- */
@media (max-width: 760px) {
  body { font-size: 15.5px; }
  .topbar .inner { padding: 10px 14px; gap: 8px; }
  .brand .sub { display: none; }
  .navlinks-desktop { display: none; }
  .wrap { padding: 16px 15px 96px; }
  .hero { padding: 26px 20px; border-radius: 20px; }
  .hero h1 { font-size: 24px; }
  .hero p { font-size: 14.5px; }
  .hero .stats { gap: 9px; }
  .hero .stat { padding: 10px 13px; min-width: 0; flex: 1; }
  .hero .stat b { font-size: 20px; }
  .page-head h1 { font-size: 22px; }
  .grid.cols { grid-template-columns: 1fr 1fr; gap: 11px; }
  .card.pad, .tile { padding: 16px; }
  .exam-bar { top: 56px; }
}
@media (min-width: 761px) { .mobile-only { display: none; } }

/* bottom tab bar (mobile) */
.tabbar {
  display: none; position: fixed; bottom: 0; left: 0; right: 0; z-index: 60;
  background: rgba(255,255,255,.92); backdrop-filter: saturate(1.4) blur(16px);
  border-top: 1px solid var(--hair); padding: 7px 4px calc(7px + env(safe-area-inset-bottom));
}
.tabbar a { flex: 1; text-align: center; color: var(--muted); font-size: 10.5px; padding: 4px 0; transition: .14s; font-weight: 500; }
.tabbar a .ic { font-size: 20px; display: block; line-height: 1.25; margin-bottom: 1px; }
.tabbar a.active { color: var(--accent-ink); font-weight: 700; }
@media (max-width: 760px) { .tabbar { display: flex; } }
