/* ==========================================================================
   Final Sprint — 期末复习指引共用设计系统
   University of Melbourne · BCom Year 1
   ========================================================================== */

:root {
  --maxw: 1180px;
  --nav-w: 286px;
  --radius: 14px;
  --radius-sm: 9px;

  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  --font-serif: "Iowan Old Style", "Palatino Linotype", "Songti SC", Georgia,
    "Times New Roman", serif;
  --font-mono: "SFMono-Regular", "JetBrains Mono", Menlo, Consolas, monospace;

  --bg: #f6f7fb;
  --bg-soft: #ffffff;
  --bg-sunken: #eef0f7;
  --bg-code: #f2f4f9;
  --text: #16182a;
  --text-soft: #4d526b;
  --text-faint: #838aa5;
  --line: #e2e5ef;
  --line-strong: #cdd2e2;

  --accent: #4f46e5;
  --accent-soft: #eef0ff;
  --accent-ink: #3730a3;
  --accent-2: #0ea5e9;

  --ok: #0f9d58;
  --ok-soft: #e8f7ef;
  --warn: #d97706;
  --warn-soft: #fdf4e3;
  --danger: #dc2626;
  --danger-soft: #fdecec;
  --violet: #7c3aed;
  --violet-soft: #f3ecff;

  --shadow-sm: 0 1px 2px rgba(20, 22, 45, 0.06), 0 1px 3px rgba(20, 22, 45, 0.05);
  --shadow: 0 4px 14px rgba(20, 22, 45, 0.07), 0 1px 3px rgba(20, 22, 45, 0.05);
  --shadow-lg: 0 18px 44px rgba(20, 22, 45, 0.13);
  --ring: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent);
}

html[data-theme="dark"] {
  --bg: #0d1020;
  --bg-soft: #151a2e;
  --bg-sunken: #10142a;
  --bg-code: #1b2140;
  --text: #e9ebf5;
  --text-soft: #b3b9d1;
  --text-faint: #7d84a3;
  --line: #262c48;
  --line-strong: #384066;

  --accent: #8b8cf9;
  --accent-soft: #1d2145;
  --accent-ink: #c7c8ff;
  --accent-2: #38bdf8;

  --ok: #4ade80;
  --ok-soft: #12291f;
  --warn: #fbbf24;
  --warn-soft: #2c2413;
  --danger: #f87171;
  --danger-soft: #2e1a1c;
  --violet: #a78bfa;
  --violet-soft: #241b40;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow: 0 6px 18px rgba(0, 0, 0, 0.45);
  --shadow-lg: 0 20px 50px rgba(0, 0, 0, 0.55);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; scroll-padding-top: 84px; }

body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.75;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

img, svg { max-width: 100%; }

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

/* ---------------------------------------------------------------- topbar -- */
.topbar {
  position: sticky; top: 0; z-index: 60;
  display: flex; align-items: center; gap: 14px;
  height: 58px; padding: 0 18px;
  background: color-mix(in srgb, var(--bg-soft) 88%, transparent);
  backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid var(--line);
}
.topbar .brand {
  display: flex; align-items: center; gap: 9px;
  font-weight: 700; letter-spacing: -0.01em; color: var(--text);
}
.topbar .brand:hover { text-decoration: none; }
.brand-mark {
  width: 26px; height: 26px; border-radius: 8px; flex: none;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  display: grid; place-items: center; color: #fff; font-size: 13px; font-weight: 800;
}
.brand small { display: block; font-weight: 500; font-size: 11px; color: var(--text-faint); line-height: 1.1; }
.topbar-spacer { flex: 1; }
.topbar-btn {
  display: inline-flex; align-items: center; gap: 6px;
  height: 34px; padding: 0 12px; border-radius: 999px; cursor: pointer;
  background: transparent; border: 1px solid var(--line-strong);
  color: var(--text-soft); font: inherit; font-size: 13px;
}
.topbar-btn:hover { background: var(--bg-sunken); color: var(--text); }
.nav-toggle { display: none; }

/* --------------------------------------------------------------- layout -- */
.layout {
  display: grid;
  grid-template-columns: var(--nav-w) minmax(0, 1fr);
  max-width: 1400px; margin: 0 auto; padding: 0 18px;
  gap: 26px;
}
.sidebar {
  position: sticky; top: 58px; align-self: start;
  height: calc(100vh - 58px); overflow-y: auto;
  padding: 22px 8px 60px 0;
  font-size: 14px;
  scrollbar-width: thin;
}
.sidebar::-webkit-scrollbar { width: 8px; }
.sidebar::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 8px; }

.side-group { margin-bottom: 20px; }
.side-group h4 {
  margin: 0 0 7px; padding: 0 10px;
  font-size: 11px; letter-spacing: 0.09em; text-transform: uppercase;
  color: var(--text-faint); font-weight: 700;
}
.side-group a {
  display: block; padding: 6px 10px; border-radius: 8px;
  color: var(--text-soft); font-size: 13.5px; line-height: 1.5;
}
.side-group a:hover { background: var(--bg-sunken); color: var(--text); text-decoration: none; }
.side-group a.active {
  background: var(--accent-soft); color: var(--accent-ink); font-weight: 600;
}
.side-group a .n {
  display: inline-block; min-width: 30px; color: var(--text-faint);
  font-variant-numeric: tabular-nums; font-size: 12px;
}
.side-group a.active .n { color: var(--accent-ink); }

main { padding: 30px 0 90px; min-width: 0; }
.wrap { max-width: var(--maxw); margin: 0 auto; }

/* ------------------------------------------------------------ typography -- */
h1, h2, h3, h4 { line-height: 1.28; letter-spacing: -0.015em; color: var(--text); }
h1 { font-family: var(--font-serif); font-size: clamp(28px, 3.4vw, 40px); margin: 0 0 10px; font-weight: 700; }
h2 {
  font-size: 23px; margin: 46px 0 14px; padding-bottom: 9px;
  border-bottom: 1px solid var(--line);
}
h3 { font-size: 18px; margin: 30px 0 10px; }
h4 { font-size: 15.5px; margin: 22px 0 8px; color: var(--text-soft); }
p { margin: 0 0 14px; }
.lead { font-size: 17.5px; color: var(--text-soft); line-height: 1.8; }
.muted { color: var(--text-soft); }
.faint { color: var(--text-faint); font-size: 13.5px; }
.center { text-align: center; }
strong { font-weight: 650; color: var(--text); }
hr { border: 0; border-top: 1px solid var(--line); margin: 34px 0; }

ul, ol { padding-left: 22px; margin: 0 0 16px; }
li { margin: 5px 0; }
li::marker { color: var(--text-faint); }

code {
  font-family: var(--font-mono); font-size: 0.88em;
  background: var(--bg-code); padding: 2px 6px; border-radius: 6px;
  border: 1px solid var(--line);
}
pre {
  background: var(--bg-code); border: 1px solid var(--line);
  border-radius: var(--radius-sm); padding: 14px 16px; overflow-x: auto;
  font-size: 13.5px; line-height: 1.6;
}
pre code { background: none; border: 0; padding: 0; }
blockquote {
  margin: 18px 0; padding: 4px 18px; border-left: 3px solid var(--accent);
  color: var(--text-soft); background: var(--accent-soft);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

/* ---------------------------------------------------------------- chrome -- */
.eyebrow {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 12px; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--accent-ink); background: var(--accent-soft);
  padding: 5px 12px; border-radius: 999px; margin-bottom: 14px;
}
.crumbs { font-size: 13px; color: var(--text-faint); margin-bottom: 14px; }
.crumbs a { color: var(--text-faint); }
.crumbs span { margin: 0 6px; }

.badges { display: flex; flex-wrap: wrap; gap: 8px; margin: 16px 0 6px; }
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 12.5px; font-weight: 600; padding: 4px 11px; border-radius: 999px;
  background: var(--bg-sunken); color: var(--text-soft); border: 1px solid var(--line);
}
.badge.b-accent { background: var(--accent-soft); color: var(--accent-ink); border-color: transparent; }
.badge.b-ok { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.badge.b-warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.badge.b-danger { background: var(--danger-soft); color: var(--danger); border-color: transparent; }

/* ----------------------------------------------------------------- cards -- */
.card {
  background: var(--bg-soft); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 22px 24px; box-shadow: var(--shadow-sm);
}
.card + .card { margin-top: 16px; }
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }

.tile {
  display: block; background: var(--bg-soft); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow-sm);
  color: inherit; transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}
.tile:hover { text-decoration: none; transform: translateY(-3px); box-shadow: var(--shadow); border-color: var(--line-strong); }
.tile h3 { margin: 0 0 6px; font-size: 17px; }
.tile p { margin: 0; font-size: 14px; color: var(--text-soft); }

/* --------------------------------------------------------------- callout -- */
.callout {
  display: grid; grid-template-columns: 26px minmax(0, 1fr); gap: 12px;
  border-radius: var(--radius); padding: 15px 18px; margin: 18px 0;
  border: 1px solid var(--line); background: var(--bg-soft);
  border-left-width: 4px;
}
.callout .ico { font-size: 17px; line-height: 1.5; }
.callout > div > :first-child { margin-top: 0; }
.callout > div > :last-child { margin-bottom: 0; }
.callout .ctitle { font-weight: 700; font-size: 14px; margin-bottom: 3px; }
.callout.tip { border-left-color: var(--ok); background: var(--ok-soft); }
.callout.tip .ctitle { color: var(--ok); }
.callout.warn { border-left-color: var(--warn); background: var(--warn-soft); }
.callout.warn .ctitle { color: var(--warn); }
.callout.danger { border-left-color: var(--danger); background: var(--danger-soft); }
.callout.danger .ctitle { color: var(--danger); }
.callout.info { border-left-color: var(--accent); background: var(--accent-soft); }
.callout.info .ctitle { color: var(--accent-ink); }
.callout.exam { border-left-color: var(--violet); background: var(--violet-soft); }
.callout.exam .ctitle { color: var(--violet); }

/* -------------------------------------------------------------- formulas -- */
.formula {
  position: relative; margin: 18px 0; padding: 18px 20px;
  background: var(--bg-soft); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow-sm);
  overflow-x: auto;
}
.formula .fname {
  display: block; font-size: 12.5px; font-weight: 700; letter-spacing: 0.05em;
  text-transform: uppercase; color: var(--text-faint); margin-bottom: 8px;
}
.formula .katex-display { margin: 6px 0 2px; }
.formula .fnote { font-size: 13px; color: var(--text-soft); margin-top: 8px; border-top: 1px dashed var(--line); padding-top: 8px; }

.katex { font-size: 1.02em; }
.katex-display { overflow-x: auto; overflow-y: hidden; padding: 2px 0; }

/* ---------------------------------------------------------------- tables -- */
.table-wrap { overflow-x: auto; margin: 18px 0; border-radius: var(--radius); border: 1px solid var(--line); background: var(--bg-soft); }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
thead th {
  text-align: left; background: var(--bg-sunken); color: var(--text-soft);
  font-size: 12.5px; font-weight: 700; letter-spacing: 0.03em; text-transform: uppercase;
  padding: 11px 14px; border-bottom: 1px solid var(--line); white-space: nowrap;
}
tbody td { padding: 10px 14px; border-bottom: 1px solid var(--line); vertical-align: top; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: color-mix(in srgb, var(--accent-soft) 45%, transparent); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.tbl-compact td, .tbl-compact th { padding: 7px 11px; font-size: 13.5px; }

/* ----------------------------------------------------------------- chips -- */
.tag {
  display: inline-block; font-size: 11.5px; font-weight: 700; padding: 2px 8px;
  border-radius: 6px; background: var(--bg-sunken); color: var(--text-soft);
  letter-spacing: 0.02em; white-space: nowrap;
}
.tag.t-mcq { background: var(--accent-soft); color: var(--accent-ink); }
.tag.t-calc { background: var(--ok-soft); color: var(--ok); }
.tag.t-graph { background: var(--violet-soft); color: var(--violet); }
.tag.t-essay { background: var(--warn-soft); color: var(--warn); }
.tag.t-case { background: var(--danger-soft); color: var(--danger); }

.marks {
  display: inline-flex; align-items: baseline; gap: 2px; font-weight: 800;
  font-variant-numeric: tabular-nums; color: var(--accent-ink);
}
.marks::after { content: "分"; font-size: 11px; font-weight: 600; color: var(--text-faint); }

/* ------------------------------------------------------------ accordion -- */
details.acc {
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--bg-soft); margin: 10px 0; overflow: hidden;
}
details.acc > summary {
  cursor: pointer; padding: 12px 16px; font-weight: 600; font-size: 14.5px;
  list-style: none; display: flex; align-items: center; gap: 10px;
}
details.acc > summary::-webkit-details-marker { display: none; }
details.acc > summary::before {
  content: "▸"; color: var(--accent); font-size: 13px; transition: transform 0.2s ease;
}
details.acc[open] > summary::before { transform: rotate(90deg); }
details.acc > summary:hover { background: var(--bg-sunken); }
details.acc .acc-body { padding: 4px 18px 16px; border-top: 1px solid var(--line); }
details.acc .acc-body > :first-child { margin-top: 12px; }

/* ----------------------------------------------------------------- quiz -- */
.quiz { border: 1px solid var(--line); border-radius: var(--radius); background: var(--bg-soft); padding: 18px 20px; margin: 16px 0; box-shadow: var(--shadow-sm); }
.quiz .qhead { display: flex; gap: 10px; align-items: baseline; margin-bottom: 10px; }
.quiz .qnum { font-weight: 800; color: var(--accent-ink); }
.quiz .opts { display: grid; gap: 8px; margin: 12px 0 0; }
.quiz .opt {
  display: flex; gap: 10px; align-items: flex-start; padding: 10px 14px;
  border: 1px solid var(--line); border-radius: var(--radius-sm); cursor: pointer;
  font-size: 14.5px; background: var(--bg-soft); transition: background 0.15s ease, border-color 0.15s ease;
}
.quiz .opt:hover { border-color: var(--accent); background: var(--accent-soft); }
.quiz .opt.correct { border-color: var(--ok); background: var(--ok-soft); }
.quiz .opt.wrong { border-color: var(--danger); background: var(--danger-soft); }
.quiz .opt .key { font-weight: 800; color: var(--text-faint); }
.quiz .fb { margin-top: 12px; font-size: 14px; display: none; padding: 12px 14px; border-radius: var(--radius-sm); background: var(--bg-sunken); }
.quiz .fb.show { display: block; }
.quiz .fb.good { background: var(--ok-soft); }
.quiz .fb.bad { background: var(--danger-soft); }

/* ------------------------------------------------------------ checklist -- */
.plan-list { list-style: none; padding: 0; margin: 16px 0; }
.plan-list li { display: flex; gap: 11px; align-items: flex-start; padding: 9px 12px; border-radius: var(--radius-sm); border: 1px solid transparent; }
.plan-list li:hover { background: var(--bg-sunken); }
.plan-list input[type="checkbox"] { margin-top: 5px; width: 17px; height: 17px; accent-color: var(--accent); flex: none; cursor: pointer; }
.plan-list li.done label { color: var(--text-faint); text-decoration: line-through; }
.plan-list label { cursor: pointer; }

/* ------------------------------------------------------- progress + bar -- */
.pbar { height: 9px; border-radius: 999px; background: var(--bg-sunken); overflow: hidden; }
.pbar > i { display: block; height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--accent), var(--accent-2)); transition: width 0.4s ease; width: 0; }

.day-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(168px, 1fr)); gap: 12px; margin: 18px 0; }
.day {
  border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 13px 14px;
  background: var(--bg-soft); box-shadow: var(--shadow-sm); font-size: 13.5px;
}
.day h5 { margin: 0 0 6px; font-size: 13px; color: var(--accent-ink); font-weight: 800; letter-spacing: 0.02em; }
.day ul { padding-left: 16px; margin: 0; }
.day li { margin: 3px 0; color: var(--text-soft); }
.day.phase1 { border-top: 3px solid var(--accent); }
.day.phase2 { border-top: 3px solid var(--violet); }
.day.phase3 { border-top: 3px solid var(--ok); }

/* ----------------------------------------------------------------- hero -- */
.hero {
  position: relative; overflow: hidden; border-radius: 20px;
  padding: 46px 42px; margin-bottom: 30px;
  background:
    radial-gradient(1200px 420px at 12% -20%, color-mix(in srgb, var(--accent) 26%, transparent), transparent 62%),
    radial-gradient(760px 320px at 92% 8%, color-mix(in srgb, var(--accent-2) 22%, transparent), transparent 60%),
    var(--bg-soft);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}
.hero h1 { max-width: 20ch; }
.hero .sub { font-size: 17px; color: var(--text-soft); max-width: 62ch; }
.hero .glow {
  position: absolute; inset: auto -60px -120px auto; width: 320px; height: 320px;
  background: radial-gradient(circle, color-mix(in srgb, var(--accent-2) 30%, transparent), transparent 70%);
  filter: blur(12px); pointer-events: none;
}

/* --------------------------------------------------------------- footer -- */
.site-foot {
  border-top: 1px solid var(--line); margin-top: 60px; padding: 26px 0 40px;
  font-size: 13px; color: var(--text-faint);
}
.site-foot .wrap { display: flex; flex-wrap: wrap; gap: 12px; justify-content: space-between; }

/* ------------------------------------------------------------- reveal ----- */
.reveal { opacity: 0; transform: translateY(14px); }
.reveal.in { opacity: 1; transform: none; transition: opacity 0.55s ease, transform 0.55s cubic-bezier(.2,.7,.3,1); }
@media (prefers-reduced-motion: reduce) {
  .reveal, .reveal.in { opacity: 1; transform: none; transition: none; }
  html { scroll-behavior: auto; }
}

/* --------------------------------------------------------------- to top --- */
.totop {
  position: fixed; right: 20px; bottom: 22px; z-index: 50;
  width: 42px; height: 42px; border-radius: 50%; display: grid; place-items: center;
  background: var(--accent); color: #fff; border: 0; cursor: pointer;
  box-shadow: var(--shadow); opacity: 0; pointer-events: none; transition: opacity 0.25s ease;
}
.totop.show { opacity: 1; pointer-events: auto; }

/* ----------------------------------------------------------------- diag --- */
.diagram {
  margin: 22px 0; padding: 18px; border-radius: var(--radius);
  background: var(--bg-soft); border: 1px solid var(--line); box-shadow: var(--shadow-sm);
  text-align: center;
}
.diagram svg { max-width: 100%; height: auto; }
.diagram figcaption { font-size: 13px; color: var(--text-faint); margin-top: 10px; }
.diagram .axis { stroke: var(--text-soft); stroke-width: 1.6; }
.diagram .curve { stroke: var(--accent); stroke-width: 2.4; fill: none; }
.diagram .curve2 { stroke: var(--accent-2); stroke-width: 2.4; fill: none; }
.diagram .curve3 { stroke: var(--danger); stroke-width: 2.2; fill: none; stroke-dasharray: 6 4; }
.diagram .lbl { font: 600 13px var(--font-sans); fill: var(--text); }
.diagram .lbl-sm { font: 500 11px var(--font-sans); fill: var(--text-faint); }
.diagram .grid-l { stroke: var(--line); stroke-width: 1; stroke-dasharray: 3 4; }

/* --------------------------------------------------------------- search --- */
.side-search {
  width: 100%; padding: 8px 12px; border-radius: 9px; font: inherit; font-size: 13.5px;
  border: 1px solid var(--line-strong); background: var(--bg-soft); color: var(--text);
  margin-bottom: 14px;
}
.side-search:focus { outline: none; box-shadow: var(--ring); border-color: var(--accent); }

/* ------------------------------------------------------------ responsive -- */
@media (max-width: 1080px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 900px) {
  .layout { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .nav-toggle { display: inline-flex; }
  .sidebar {
    position: fixed; top: 58px; left: 0; bottom: 0; width: min(84vw, 320px);
    height: auto; background: var(--bg-soft); border-right: 1px solid var(--line);
    padding: 20px 14px 60px; transform: translateX(-102%); transition: transform 0.26s ease;
    z-index: 59; box-shadow: var(--shadow-lg);
  }
  .sidebar.open { transform: none; }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: minmax(0, 1fr); }
  .hero { padding: 32px 22px; }
  h2 { font-size: 20px; }
}

@media print {
  .topbar, .sidebar, .totop, .site-foot { display: none !important; }
  .layout { display: block; }
  body { background: #fff; }
}
