/* Physics Challenge Training — single stylesheet; fonts are served locally (works behind the Great Firewall). */
@font-face { font-family: "Space Grotesk"; font-style: normal; font-weight: 500; font-display: swap; src: url(/static/fonts/space-grotesk-latin-500-normal.woff2) format("woff2"); }
@font-face { font-family: "Space Grotesk"; font-style: normal; font-weight: 700; font-display: swap; src: url(/static/fonts/space-grotesk-latin-700-normal.woff2) format("woff2"); }
:root {
  color-scheme: light;
  --bg: #f4f5fb;
  --surface: #ffffff;
  --surface-2: #f9fafb;
  --ink: #0f172a;
  --ink-2: #4b5563;
  --muted: #6b7280;
  --line: #e5e7eb;
  --line-2: #d1d5db;
  --brand: #4f46e5;
  --brand-hover: #4338ca;
  --brand-soft: #eef2ff;
  --violet: #7c3aed;
  --cyan: #06b6d4;
  --grad: linear-gradient(135deg, #4f46e5 0%, #7c3aed 55%, #db2777 100%);
  --grad-cool: linear-gradient(135deg, #4f46e5 0%, #2563eb 50%, #06b6d4 100%);
  --space: radial-gradient(120% 90% at 75% 30%, #312e81 0%, #1e1b4b 30%, #0b1020 62%, #05070f 100%);
  --brand-ink: #ffffff;
  --series: #2a78d6;
  --good: #0ca30c;
  --good-ink: #006300;
  --good-soft: #e9f7e9;
  --bad: #d03b3b;
  --bad-ink: #a52828;
  --bad-soft: #fdecec;
  --warn: #fab219;
  --warn-ink: #8a5a00;
  --warn-soft: #fff6e0;
  --radius: 14px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .04), 0 6px 20px -10px rgba(15, 23, 42, .12);
  --shadow-lg: 0 10px 40px -12px rgba(49, 46, 129, .35);
  --font: system-ui, -apple-system, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
  --mono: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  --display: "Space Grotesk", system-ui, -apple-system, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; color: var(--ink); font: 15px/1.55 var(--font);
  background-color: var(--bg);
  /* faint graph-paper grid */
  background-image: linear-gradient(rgba(79, 70, 229, .045) 1px, transparent 1px), linear-gradient(90deg, rgba(79, 70, 229, .045) 1px, transparent 1px);
  background-size: 28px 28px;
}
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { line-height: 1.25; margin: 0 0 .5em; }
h1, h2, .display { font-family: var(--display); letter-spacing: -.01em; }
h1 { font-size: 1.65rem; }
h2 { font-size: 1.2rem; }
h3 { font-size: 1.02rem; }
p { margin: 0 0 .8em; }
img { max-width: 100%; }
hr { border: 0; border-top: 1px solid var(--line); margin: 1.2rem 0; }
code, .mono { font-family: var(--mono); font-size: .92em; }
.muted { color: var(--muted); }
.small { font-size: .86rem; }
.nowrap { white-space: nowrap; }
.num { font-variant-numeric: tabular-nums; }
.right { text-align: right; }
.center { text-align: center; }
.hidden, [hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20; background: rgba(255, 255, 255, .86); border-bottom: 1px solid rgba(226, 232, 240, .9);
  -webkit-backdrop-filter: saturate(160%) blur(10px); backdrop-filter: saturate(160%) blur(10px);
  display: flex; align-items: center; gap: 18px; padding: 0 20px; min-height: 56px;
}
.brand { display: flex; align-items: center; gap: 9px; font-weight: 700; color: var(--ink); white-space: nowrap; font-family: var(--display); }
.brand:hover { text-decoration: none; }
.brand svg { width: 28px; height: 28px; flex: none; }
.mainnav { display: flex; gap: 2px; overflow-x: auto; scrollbar-width: none; flex: 1; }
.mainnav::-webkit-scrollbar { display: none; }
.mainnav a { padding: 16px 10px; color: var(--ink-2); white-space: nowrap; border-bottom: 2px solid transparent; font-weight: 500; }
.mainnav a:hover { color: var(--ink); text-decoration: none; }
.mainnav a.active { color: var(--brand); border-image: var(--grad) 1; border-bottom-width: 2px; border-bottom-style: solid; }
.tools { display: flex; align-items: center; gap: 10px; white-space: nowrap; }
.langswitch { display: inline-flex; border: 1px solid var(--line-2); border-radius: 999px; overflow: hidden; font-size: .82rem; }
.langswitch a { padding: 3px 10px; color: var(--ink-2); }
.langswitch a.on { background: var(--ink); color: #fff; }
.langswitch a:hover { text-decoration: none; }
.usermenu { display: flex; align-items: center; gap: 8px; font-size: .9rem; }
.usermenu form { margin: 0; }
.linkbtn { background: none; border: 0; padding: 0; color: var(--brand); font: inherit; cursor: pointer; }
.linkbtn:hover { text-decoration: underline; }

@media (max-width: 860px) {
  .topbar { flex-wrap: wrap; padding: 0 12px; gap: 0 12px; }
  .brand { padding: 12px 0; }
  .brand .brand-text { max-width: 44vw; overflow: hidden; text-overflow: ellipsis; }
  .tools { margin-left: auto; }
  .mainnav { order: 3; flex-basis: 100%; border-top: 1px solid var(--line); }
  .mainnav a { padding: 10px 10px; }
  .usermenu .uname { display: none; }
}

/* ---------- layout ---------- */
.container { max-width: 1180px; margin: 0 auto; padding: 24px 20px 64px; }
.container.narrow { max-width: 760px; }
@media (max-width: 600px) { .container { padding: 16px 16px 48px; } }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.page-head h1 { margin: 0; }
.page-head .sub { color: var(--muted); margin: 4px 0 0; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.grid { display: grid; gap: 16px; }
.grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid.side { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
@media (max-width: 900px) { .grid.cols-3, .grid.cols-4, .grid.side { grid-template-columns: repeat(2, minmax(0, 1fr)); } .grid.side > * { grid-column: 1 / -1; } }
@media (max-width: 600px) { .grid.cols-2, .grid.cols-3 { grid-template-columns: minmax(0, 1fr); } }
.stack > * + * { margin-top: 16px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }

/* ---------- cards ---------- */
.card { background: var(--surface); border: 1px solid rgba(226, 232, 240, .9); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px 22px; min-width: 0; }
.card > h2:first-child, .card > h3:first-child { margin-top: 0; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.card-head h2, .card-head h3 { margin: 0; }
.card.flush { padding: 0; }
.card.flush > .card-head { padding: 16px 20px 0; }
.empty { text-align: center; color: var(--muted); padding: 28px 12px; }
.empty .big { font-size: 1.05rem; color: var(--ink-2); margin-bottom: 6px; }

/* stat tiles */
.stat { position: relative; overflow: hidden; background: var(--surface); border: 1px solid rgba(226, 232, 240, .9); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); }
.stat::before { content: ""; position: absolute; inset: 0 0 auto 0; height: 3px; background: var(--grad-cool); opacity: .85; }
.grid > .stat:nth-child(2)::before { background: var(--grad); }
.grid > .stat:nth-child(3)::before { background: linear-gradient(90deg, #f59e0b, #ef4444); }
.grid > .stat:nth-child(4)::before { background: linear-gradient(90deg, #10b981, #06b6d4); }
.stat .label { color: var(--muted); font-size: .84rem; }
.stat .value { font-size: 1.8rem; font-weight: 700; line-height: 1.2; margin-top: 2px; font-family: var(--display); }
.stat .value small { font-size: .9rem; font-weight: 500; color: var(--muted); }
.stat .foot { font-size: .82rem; color: var(--muted); margin-top: 2px; }

/* countdown */
.countdown { display: flex; align-items: center; gap: 14px; }
.countdown .days { font-size: 2.2rem; font-weight: 700; line-height: 1; min-width: 3ch; text-align: center; font-family: var(--display); background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.countdown .days small { display: block; font-size: .72rem; font-weight: 600; color: var(--muted); letter-spacing: .04em; text-transform: uppercase; margin-top: 4px; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 8px 14px; border-radius: var(--radius-sm);
  border: 1px solid var(--line-2); background: var(--surface); color: var(--ink); font: inherit; font-weight: 600; font-size: .92rem;
  cursor: pointer; line-height: 1.2; white-space: nowrap;
}
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, .choice:focus-within { outline: 2px solid var(--brand); outline-offset: 2px; }
.btn { transition: transform .12s ease, box-shadow .12s ease, background-color .12s ease; }
.btn.primary { background: var(--grad); border-color: transparent; color: var(--brand-ink); box-shadow: 0 6px 16px -8px rgba(79, 70, 229, .7); }
.btn.primary:hover { background: var(--grad); filter: brightness(1.07); transform: translateY(-1px); box-shadow: 0 10px 22px -10px rgba(79, 70, 229, .8); }
.btn.glass { background: rgba(255, 255, 255, .08); border-color: rgba(255, 255, 255, .28); color: #fff; }
.btn.glass:hover { background: rgba(255, 255, 255, .16); }
.btn.danger { color: var(--bad-ink); border-color: #f0c2c2; }
.btn.danger:hover { background: var(--bad-soft); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--surface-2); }
.btn.sm { padding: 5px 10px; font-size: .84rem; }
.btn.lg { padding: 11px 20px; font-size: 1rem; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.inline-form { display: inline; margin: 0; }

/* ---------- forms ---------- */
label { display: block; font-weight: 600; font-size: .9rem; margin-bottom: 4px; }
.field { margin-bottom: 14px; }
.field .hint { font-weight: 400; color: var(--muted); font-size: .82rem; margin-top: 3px; }
input[type=text], input[type=password], input[type=number], input[type=date], input[type=datetime-local], input[type=search], input[type=url], select, textarea {
  width: 100%; padding: 8px 10px; border: 1px solid var(--line-2); border-radius: var(--radius-sm); background: #fff; color: var(--ink); font: inherit;
}
textarea { min-height: 84px; resize: vertical; }
textarea.tall { min-height: 160px; }
input[type=file] { font: inherit; max-width: 100%; }
.check { display: flex; align-items: center; gap: 8px; font-weight: 500; margin: 0; cursor: pointer; }
.check input { width: 16px; height: 16px; margin: 0; flex: none; }
.checks { display: flex; flex-wrap: wrap; gap: 6px 16px; }
.checkgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 6px 14px; }
.form-row { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: flex-end; margin-bottom: 14px; }
.filters .field { margin: 0; min-width: 140px; }
.filters input[type=search] { min-width: 200px; }
fieldset { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 12px 14px; margin: 0 0 14px; }
legend { font-weight: 700; font-size: .9rem; padding: 0 6px; }
.bi-inputs { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
@media (max-width: 700px) { .bi-inputs { grid-template-columns: 1fr; } }
.opt-row { display: grid; grid-template-columns: 52px 1fr 1fr; gap: 8px; align-items: center; margin-bottom: 8px; }
.opt-row .opt-key { display: flex; align-items: center; gap: 6px; font-weight: 700; }
@media (max-width: 700px) { .opt-row { grid-template-columns: 52px 1fr; } .opt-row input:last-child { grid-column: 2; } }

/* ---------- alerts & badges ---------- */
.alert { padding: 10px 14px; border-radius: var(--radius-sm); margin-bottom: 16px; border: 1px solid; font-weight: 500; }
.alert.ok { background: var(--good-soft); border-color: #bfe5bf; color: var(--good-ink); }
.alert.err { background: var(--bad-soft); border-color: #f3c4c4; color: var(--bad-ink); }
.alert.info { background: var(--brand-soft); border-color: #cddafc; color: #1a3a99; }
.alert.warn { background: var(--warn-soft); border-color: #f5dc9f; color: var(--warn-ink); }
.badge { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: .76rem; font-weight: 700; background: var(--surface-2); border: 1px solid var(--line); color: var(--ink-2); white-space: nowrap; vertical-align: middle; }
.badge.comp { background: #eef2ff; border-color: #d9e0ff; color: #2c3fa8; }
.badge.ok { background: var(--good-soft); border-color: #cbe9cb; color: var(--good-ink); }
.badge.bad { background: var(--bad-soft); border-color: #f3cfcf; color: var(--bad-ink); }
.badge.warn { background: var(--warn-soft); border-color: #f3dfaa; color: var(--warn-ink); }
.badge.live { background: var(--brand); border-color: var(--brand); color: #fff; }
.diff { letter-spacing: 1px; color: var(--muted); font-size: .8rem; white-space: nowrap; }
.diff b { color: var(--warn-ink); }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.table th, .table td { padding: 9px 12px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.table th { font-size: .78rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); font-weight: 700; background: var(--surface-2); white-space: nowrap; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr:hover td { background: #fbfcfe; }
.table td.num, .table th.num { text-align: right; font-variant-numeric: tabular-nums; }
.table .stem-preview { max-width: 520px; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.card.flush .table th:first-child, .card.flush .table td:first-child { padding-left: 20px; }
.card.flush .table th:last-child, .card.flush .table td:last-child { padding-right: 20px; }

.pager { display: flex; gap: 6px; justify-content: center; margin-top: 16px; flex-wrap: wrap; }
.pager a, .pager span { padding: 4px 10px; border-radius: var(--radius-sm); border: 1px solid var(--line); background: #fff; }
.pager span.cur { background: var(--ink); color: #fff; border-color: var(--ink); }

/* ---------- bars (single-series, one hue) ---------- */
.bars { display: grid; gap: 10px; }
.bar-row { display: grid; grid-template-columns: minmax(120px, 1.1fr) minmax(0, 2fr) 92px; gap: 12px; align-items: center; font-size: .9rem; }
.bar-row .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-track { height: 12px; background: #eef0f3; border-radius: 4px; position: relative; overflow: hidden; }
.bar-fill { position: absolute; inset: 0 auto 0 0; background: var(--series); border-radius: 0 4px 4px 0; min-width: 2px; }
.bar-track .tick { position: absolute; top: -2px; bottom: -2px; width: 2px; background: var(--ink); opacity: .55; }
.bar-row .val { text-align: right; font-variant-numeric: tabular-nums; color: var(--ink-2); white-space: nowrap; }
.bar-row.nodata .val, .bar-row.nodata .name { color: var(--muted); }
@media (max-width: 560px) { .bar-row { grid-template-columns: 1fr 80px; } .bar-row .bar-track { grid-column: 1 / -1; grid-row: 2; } }

/* histogram */
.histo { display: grid; grid-template-columns: repeat(10, 1fr); gap: 2px; align-items: end; height: 120px; border-bottom: 1px solid var(--line-2); }
.histo .col { background: var(--series); border-radius: 4px 4px 0 0; min-height: 0; position: relative; }
.histo .col[data-n="0"] { background: transparent; }
.histo-labels { display: grid; grid-template-columns: repeat(10, 1fr); gap: 2px; font-size: .72rem; color: var(--muted); text-align: center; margin-top: 4px; }

/* heatmap */
.heat { border-collapse: separate; border-spacing: 2px; font-size: .84rem; }
.heat th { font-weight: 600; color: var(--ink-2); padding: 4px 6px; text-align: left; white-space: nowrap; }
.heat thead th { vertical-align: bottom; font-size: .74rem; width: 82px; min-width: 82px; max-width: 82px; white-space: normal; line-height: 1.2; overflow-wrap: anywhere; hyphens: auto; }
.heat thead th:first-child { width: auto; max-width: none; }
.heat td { width: 64px; min-width: 56px; height: 34px; text-align: center; border-radius: 4px; font-variant-numeric: tabular-nums; font-weight: 600; }
.heat td.nodata { background: repeating-linear-gradient(45deg, #f3f4f6, #f3f4f6 4px, #ebedf0 4px, #ebedf0 8px); color: var(--muted); font-weight: 400; }
.heat td.total { background: var(--surface-2); color: var(--ink); border: 1px solid var(--line); }
.legend-ramp { display: flex; align-items: center; gap: 8px; font-size: .78rem; color: var(--muted); margin-top: 10px; flex-wrap: wrap; }
.legend-ramp .ramp { width: 160px; height: 10px; border-radius: 3px; background: linear-gradient(90deg, #cde2fb, #6da7ec, #2a78d6, #184f95, #0d366b); }
.legend-ramp .nod { width: 18px; height: 10px; border-radius: 3px; background: repeating-linear-gradient(45deg, #f3f4f6, #f3f4f6 3px, #e5e7eb 3px, #e5e7eb 6px); }

/* ---------- question display ---------- */
.q-stem { font-size: 1.04rem; line-height: 1.65; }
.q-stem .bi-alt, .opt-text .bi-alt, .explain .bi-alt, .fact .bi-alt { display: none; color: var(--ink-2); font-size: .94em; margin-top: 4px; }
html.show-both .bi-alt { display: block !important; }
html.show-both .q-stem .bi-alt { border-left: 3px solid var(--line-2); padding-left: 10px; margin-top: 8px; }
.q-img { margin: 12px 0; max-height: 420px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: #fff; }
.choices { display: grid; gap: 8px; margin-top: 14px; }
.choice {
  display: grid; grid-template-columns: 34px 1fr auto; gap: 10px; align-items: center; padding: 10px 12px; border: 1.5px solid var(--line-2);
  border-radius: var(--radius-sm); background: #fff; cursor: pointer; font-weight: 400; margin: 0; text-align: left; width: 100%; font: inherit; color: inherit;
}
.choice:hover { border-color: #9fb3ea; background: #fbfcff; }
.choice .key { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; background: var(--surface-2); border: 1px solid var(--line-2); }
.choice input { position: absolute; opacity: 0; pointer-events: none; }
.choice.selected { border-color: var(--brand); background: var(--brand-soft); }
.choice.selected .key { background: var(--brand); border-color: var(--brand); color: #fff; }
.choice.correct { border-color: var(--good); background: var(--good-soft); }
.choice.correct .key { background: var(--good); border-color: var(--good); color: #fff; }
.choice.wrong { border-color: var(--bad); background: var(--bad-soft); }
.choice.wrong .key { background: var(--bad); border-color: var(--bad); color: #fff; }
.choice .mark { font-weight: 700; font-size: .85rem; white-space: nowrap; }
.choice.correct .mark { color: var(--good-ink); }
.choice.wrong .mark { color: var(--bad-ink); }
.choice[disabled], .choices.locked .choice { cursor: default; }
.explain { margin-top: 14px; padding: 12px 14px; border-radius: var(--radius-sm); background: var(--surface-2); border: 1px solid var(--line); }
.explain h4 { margin: 0 0 4px; font-size: .9rem; }
.verdict { display: flex; align-items: center; gap: 8px; font-weight: 700; margin-top: 12px; }
.verdict.ok { color: var(--good-ink); }
.verdict.bad { color: var(--bad-ink); }
.verdict svg { width: 20px; height: 20px; flex: none; }

/* ---------- attempt runner ---------- */
.runner { display: grid; grid-template-columns: minmax(0, 1fr) 280px; gap: 18px; align-items: start; }
@media (max-width: 900px) { .runner { grid-template-columns: minmax(0, 1fr); } .runner .side { order: -1; } }
.runner .side { position: sticky; top: 72px; }
.side-top { display: flex; flex-direction: column; gap: 14px; padding-bottom: 16px; margin-bottom: 16px; border-bottom: 1px solid var(--line); }
.submit-form { margin: 0; }
.submit-form .btn { width: 100%; }
.side-hint { margin: 14px 0 0; }
@media (max-width: 900px) {
  .runner .side { position: static; }
  .side-card { padding: 12px 14px; }
  .side-top { flex-direction: row; align-items: center; justify-content: space-between; padding-bottom: 10px; margin-bottom: 10px; }
  .submit-form .btn { width: auto; }
  .side-top .timer { font-size: 1.35rem; }
  .palette { grid-auto-flow: column; grid-template-columns: none; grid-auto-columns: 38px; overflow-x: auto; padding: 3px; scrollbar-width: thin; }
  .side-hint, .palette-legend { display: none; }
  .qnav { flex-wrap: nowrap; gap: 6px; }
  .qnav .row { flex-wrap: nowrap; gap: 6px; }
  .qnav .btn { padding-left: 10px; padding-right: 10px; }
}
.runner-bar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.qnum { font-weight: 700; color: var(--muted); font-size: .9rem; }
.timer { font-size: 1.6rem; font-weight: 800; font-variant-numeric: tabular-nums; letter-spacing: .02em; }
.timer.low { color: var(--bad-ink); }
.palette { display: grid; grid-template-columns: repeat(auto-fill, minmax(38px, 1fr)); gap: 6px; }
.palette button {
  height: 36px; border-radius: 6px; border: 1px solid var(--line-2); background: #fff; font: inherit; font-weight: 600; font-size: .85rem; cursor: pointer; position: relative; padding: 0;
}
.palette button.answered { background: #dbe6ff; border-color: #9fb3ea; }
.palette button.correct { background: var(--good-soft); border-color: var(--good); color: var(--good-ink); }
.palette button.wrong { background: var(--bad-soft); border-color: var(--bad); color: var(--bad-ink); }
.palette button.current { outline: 2px solid var(--ink); outline-offset: 1px; }
.palette button.flagged::after { content: ""; position: absolute; top: 3px; right: 3px; width: 7px; height: 7px; border-radius: 50%; background: var(--warn); box-shadow: 0 0 0 1.5px #fff; }
.palette-legend { display: flex; gap: 12px; flex-wrap: wrap; font-size: .76rem; color: var(--muted); margin-top: 10px; }
.palette-legend span::before { content: ""; display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 4px; vertical-align: -1px; border: 1px solid var(--line-2); background: #fff; }
.palette-legend .l-ans::before { background: #dbe6ff; border-color: #9fb3ea; }
.palette-legend .l-flag::before { background: var(--warn); border-color: var(--warn); border-radius: 50%; }
.savestate { font-size: .8rem; color: var(--muted); }
.savestate.err { color: var(--bad-ink); font-weight: 600; }
.qnav { display: flex; gap: 8px; justify-content: space-between; margin-top: 18px; flex-wrap: wrap; }
.flagbtn.on { background: var(--warn-soft); border-color: #f0cf7c; color: var(--warn-ink); }

/* result */
.score-hero { display: flex; align-items: center; gap: 22px; flex-wrap: wrap; }
.score-ring { --p: 0; width: 112px; height: 112px; border-radius: 50%; display: grid; place-items: center; flex: none;
  background: conic-gradient(#4f46e5 0, #7c3aed calc(var(--p) * .5%), #06b6d4 calc(var(--p) * 1%), #e8ebf0 0); }
.score-ring > div { font-family: var(--display); }
.score-ring > div { width: 88px; height: 88px; border-radius: 50%; background: #fff; display: grid; place-items: center; font-size: 1.5rem; font-weight: 800; }
.review-item { border-top: 1px solid var(--line); padding: 18px 0; }
.review-item:first-child { border-top: 0; padding-top: 4px; }
.review-head { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 8px; }

/* item analysis option distribution */
.dist { display: flex; gap: 4px; flex-wrap: wrap; }
.dist span { font-size: .78rem; padding: 1px 7px; border-radius: 4px; background: var(--surface-2); border: 1px solid var(--line); font-variant-numeric: tabular-nums; white-space: nowrap; }
.dist span.key { background: var(--good-soft); border-color: #b6dfb6; color: var(--good-ink); font-weight: 700; }

/* ---------- auth pages ---------- */
.auth-wrap { min-height: calc(100vh - 57px); display: grid; place-items: center; padding: 24px 16px; }
.auth-card { width: 100%; max-width: 400px; }
.auth-card .brand-big { display: flex; flex-direction: column; align-items: center; gap: 8px; margin-bottom: 18px; text-align: center; }
.auth-card .brand-big svg { width: 48px; height: 48px; }
.auth-card .brand-big .name { font-weight: 800; font-size: 1.2rem; }

/* resource list */
.res-item { display: grid; grid-template-columns: 40px 1fr auto; gap: 12px; align-items: center; padding: 12px 0; border-top: 1px solid var(--line); }
.res-item:first-child { border-top: 0; }
.res-icon { width: 40px; height: 40px; border-radius: 8px; display: grid; place-items: center; font-size: .7rem; font-weight: 800; color: #fff; background: #64748b; }
.res-icon.pdf { background: #c2410c; }
.res-icon.img { background: #0e7490; }
.res-icon.doc { background: #1d4ed8; }
.res-icon.ppt { background: #b45309; }
.res-icon.link { background: #4a3aa7; }
.res-icon.vid { background: #be185d; }
.res-title { font-weight: 600; }
.res-meta { font-size: .82rem; color: var(--muted); display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 2px; }

/* credential slips (printable) */
.slips { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.slip { border: 1.5px dashed var(--line-2); border-radius: 8px; padding: 12px 14px; background: #fff; break-inside: avoid; }
.slip .site { font-size: .78rem; color: var(--muted); word-break: break-all; }
.slip .who { font-weight: 700; font-size: 1.05rem; margin: 2px 0 6px; }
.slip dl { display: grid; grid-template-columns: auto 1fr; gap: 2px 10px; margin: 0; }
.slip dt { color: var(--muted); font-size: .84rem; }
.slip dd { margin: 0; font-family: var(--mono); font-weight: 700; }

.invite-code { font-family: var(--mono); font-size: 1.6rem; font-weight: 800; letter-spacing: .12em; background: var(--surface-2); border: 1px dashed var(--line-2); border-radius: 8px; padding: 6px 14px; display: inline-block; }
.kbd { font-family: var(--mono); background: var(--surface-2); border: 1px solid var(--line); border-radius: 4px; padding: 0 5px; font-size: .85em; }

.steps { counter-reset: s; list-style: none; padding: 0; margin: 0; }
.steps li { counter-increment: s; display: grid; grid-template-columns: 28px 1fr; gap: 10px; padding: 8px 0; }
.steps li::before { content: counter(s); width: 24px; height: 24px; border-radius: 50%; background: var(--brand-soft); color: var(--brand); display: grid; place-items: center; font-weight: 800; font-size: .8rem; }
.steps li.done::before { content: "✓"; background: var(--good-soft); color: var(--good-ink); }
.steps li.done { color: var(--muted); }

.site-foot { text-align: center; color: var(--muted); font-size: .8rem; padding: 18px; }

details.more > summary { cursor: pointer; color: var(--brand); font-weight: 600; list-style: none; }
details.more > summary::-webkit-details-marker { display: none; }
details.more > summary::before { content: "▸ "; }
details.more[open] > summary::before { content: "▾ "; }

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

@media print {
  .topbar, .no-print, .site-foot, .alert { display: none !important; }
  body { background: #fff; }
  .container { padding: 0; max-width: none; }
  .card { box-shadow: none; border: 0; padding: 0; }
  .slips { grid-template-columns: repeat(3, 1fr); }
}

/* ======================================================================
   Physics look: animated logo, landing page, login pages, home banners
   ====================================================================== */
.brand svg.logo { filter: drop-shadow(0 4px 10px rgba(79, 70, 229, .35)); }

.space { background: var(--space); color: #e2e8f0; position: relative; overflow: hidden; }
.space canvas.bg { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.space .katex { color: #e0e7ff; }
.eyebrow { display: inline-flex; align-items: center; gap: 8px; font-size: .8rem; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; color: #a5b4fc; }
.eyebrow::before { content: ""; width: 22px; height: 2px; background: linear-gradient(90deg, #22d3ee, #a78bfa); border-radius: 2px; }
.grad-text { background: linear-gradient(100deg, #c7d2fe 0%, #a5f3fc 40%, #f0abfc 100%); -webkit-background-clip: text; background-clip: text; color: transparent; }

/* ---------- landing ---------- */
.landing .topbar { position: absolute; left: 0; right: 0; background: transparent; border-bottom: 0; backdrop-filter: none; -webkit-backdrop-filter: none; }
.landing .topbar .brand { color: #fff; }
.landing .topbar .langswitch { border-color: rgba(255, 255, 255, .35); }
.landing .topbar .langswitch a { color: #e2e8f0; }
.landing .topbar .langswitch a.on { background: #fff; color: #0f172a; }
.landing main { padding: 0; }
.hero { min-height: min(92vh, 860px); display: flex; align-items: center; }
.hero-inner { position: relative; z-index: 2; max-width: 1180px; margin: 0 auto; padding: 120px 24px 80px; width: 100%; pointer-events: none; }
.hero-inner > * { pointer-events: auto; }
.hero h1 { font-size: clamp(2.4rem, 6vw, 4.4rem); line-height: 1.05; margin: 18px 0 18px; color: #fff; font-weight: 700; max-width: 12em; }
.hero p.lead { font-size: clamp(1.02rem, 1.6vw, 1.2rem); color: #cbd5e1; max-width: 34em; margin: 0 0 28px; }
.hero .cta { display: flex; gap: 12px; flex-wrap: wrap; }
.hero .cta .btn { padding: 12px 22px; font-size: 1rem; border-radius: 999px; }
.hero .eqline { margin-top: 38px; display: flex; gap: 26px; flex-wrap: wrap; color: #c7d2fe; font-size: 1.08rem; opacity: .9; }
.hero::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 120px; background: linear-gradient(to bottom, transparent, rgba(5, 7, 15, .9)); z-index: 1; pointer-events: none; }
.scroll-hint { position: absolute; z-index: 2; left: 50%; bottom: 22px; transform: translateX(-50%); color: #94a3b8; font-size: .8rem; letter-spacing: .1em; text-transform: uppercase; text-align: center; }
.scroll-hint::after { content: ""; display: block; width: 1px; height: 28px; margin: 8px auto 0; background: linear-gradient(#94a3b8, transparent); animation: drip 2s ease-in-out infinite; }
@keyframes drip { 0%, 100% { opacity: .2; transform: scaleY(.6); transform-origin: top; } 50% { opacity: 1; transform: scaleY(1); } }

.section { padding: 84px 24px; }
.section .inner { max-width: 1180px; margin: 0 auto; }
.section h2 { font-size: clamp(1.7rem, 3.4vw, 2.4rem); margin-bottom: 10px; }
.section .sub { color: var(--muted); max-width: 44em; margin-bottom: 36px; font-size: 1.05rem; }
.section.dark { background: #05070f; color: #e2e8f0; }
.section.dark h2 { color: #fff; }
.section.dark .sub { color: #94a3b8; }

.gallery { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 20px; }
@media (max-width: 980px) { .gallery { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 640px) { .gallery { grid-template-columns: minmax(0, 1fr); } }
.phys-card { border-radius: 18px; overflow: hidden; background: #0b1020; border: 1px solid rgba(148, 163, 184, .16); box-shadow: 0 24px 60px -30px rgba(79, 70, 229, .55); transition: transform .25s ease, border-color .25s ease; }
.phys-card:hover { transform: translateY(-4px); border-color: rgba(165, 180, 252, .45); }
.phys-card .stage { position: relative; aspect-ratio: 4 / 3; background: radial-gradient(90% 90% at 50% 40%, #151b3a 0%, #0b1020 70%); }
.phys-card .stage canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.phys-card .stage .tag { position: absolute; top: 12px; left: 12px; z-index: 1; font-size: .72rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: #c7d2fe; background: rgba(15, 23, 42, .6); border: 1px solid rgba(165, 180, 252, .25); padding: 3px 9px; border-radius: 999px; }
.phys-card .body { padding: 16px 18px 18px; }
.phys-card h3 { color: #fff; font-family: var(--display); font-size: 1.12rem; margin: 0 0 6px; }
.phys-card p { color: #94a3b8; font-size: .92rem; margin: 0 0 10px; }
.phys-card .eq { color: #e0e7ff; font-size: 1.02rem; }

.features { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 18px; }
@media (max-width: 980px) { .features { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 560px) { .features { grid-template-columns: minmax(0, 1fr); } }
.feature { background: #fff; border: 1px solid rgba(226, 232, 240, .9); border-radius: 18px; padding: 22px; box-shadow: var(--shadow); }
.feature .ico { width: 46px; height: 46px; border-radius: 14px; display: grid; place-items: center; background: var(--grad); color: #fff; margin-bottom: 14px; box-shadow: 0 10px 20px -10px rgba(124, 58, 237, .7); }
.feature:nth-child(2) .ico { background: var(--grad-cool); }
.feature:nth-child(3) .ico { background: linear-gradient(135deg, #f59e0b, #ef4444); }
.feature:nth-child(4) .ico { background: linear-gradient(135deg, #10b981, #06b6d4); }
.feature .ico svg { width: 24px; height: 24px; }
.feature h3 { font-family: var(--display); font-size: 1.05rem; margin-bottom: 6px; }
.feature p { color: var(--muted); font-size: .92rem; margin: 0; }

.cta-band { background: var(--space); color: #fff; border-radius: 24px; padding: 48px 36px; display: flex; align-items: center; justify-content: space-between; gap: 24px; flex-wrap: wrap; position: relative; overflow: hidden; }
.cta-band h2 { color: #fff; margin: 0 0 6px; }
.cta-band p { color: #c7d2fe; margin: 0; }
.cta-band .btn { border-radius: 999px; padding: 12px 22px; }
.cta-band canvas.bg { position: absolute; top: 0; right: 0; width: 46%; height: 100%; display: block; opacity: .5; -webkit-mask-image: linear-gradient(to right, transparent, #000 45%); mask-image: linear-gradient(to right, transparent, #000 45%); }
.cta-band > :not(canvas) { position: relative; z-index: 1; }
@media (max-width: 640px) { .cta-band { padding: 34px 22px; } .cta-band canvas.bg { width: 100%; opacity: .3; } }
.landing-foot { text-align: center; color: #64748b; padding: 30px 16px 40px; font-size: .85rem; }

/* ---------- login / join / setup ---------- */
.auth-split { min-height: calc(100vh - 57px); display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); }
.auth-art { position: relative; overflow: hidden; background: var(--space); color: #e2e8f0; display: flex; align-items: flex-end; }
.auth-art canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.auth-art .caption { position: relative; z-index: 1; padding: 36px 40px; max-width: 560px; }
.auth-art .caption h2 { color: #fff; font-size: 1.7rem; margin: 10px 0 8px; }
.auth-art .caption p { color: #cbd5e1; margin: 0 0 14px; }
.auth-art .maxwell { display: grid; grid-template-columns: repeat(2, auto); gap: 8px 28px; justify-content: start; color: #e0e7ff; font-size: 1rem; opacity: .95; }
.auth-art::after { content: ""; position: absolute; inset: auto 0 0 0; height: 55%; background: linear-gradient(to bottom, transparent, rgba(5, 7, 15, .85)); pointer-events: none; }
.auth-panel { display: grid; place-items: center; padding: 40px 20px; }
.auth-panel .auth-card { width: 100%; max-width: 410px; }
@media (max-width: 900px) {
  .auth-split { grid-template-columns: minmax(0, 1fr); }
  .auth-art { min-height: 250px; }
  .auth-art canvas { opacity: .55; }
  .auth-art::after { height: 100%; background: linear-gradient(to bottom, rgba(5, 7, 15, .15), rgba(5, 7, 15, .8)); }
  .auth-art .caption { padding: 22px 20px; }
  .auth-art .caption h2 { font-size: 1.3rem; }
  .auth-art .maxwell { display: none; }
}

/* ---------- home banners ---------- */
.banner { position: relative; overflow: hidden; border-radius: 22px; background: var(--space); color: #e2e8f0; padding: 28px 30px; margin-bottom: 18px; min-height: 190px; box-shadow: var(--shadow-lg); }
.banner canvas { position: absolute; top: 0; right: 0; height: 100%; width: 58%; display: block; -webkit-mask-image: linear-gradient(to right, transparent, #000 35%); mask-image: linear-gradient(to right, transparent, #000 35%); }
.banner .content { position: relative; z-index: 1; max-width: 62%; }
.banner h1 { color: #fff; font-size: clamp(1.5rem, 3vw, 2.1rem); margin: 6px 0 6px; }
.banner .sub { color: #cbd5e1; margin: 0 0 16px; }
.banner .actions .btn:not(.primary) { background: rgba(255, 255, 255, .08); border-color: rgba(255, 255, 255, .28); color: #fff; }
.banner .pill { display: inline-flex; align-items: baseline; gap: 8px; background: rgba(255, 255, 255, .08); border: 1px solid rgba(255, 255, 255, .18); border-radius: 999px; padding: 5px 14px; font-size: .9rem; color: #e0e7ff; margin: 0 8px 10px 0; }
.banner .pill b { font-family: var(--display); font-size: 1.15rem; color: #fff; }
@media (max-width: 760px) {
  .banner { padding: 22px 20px 20px; }
  .banner canvas { width: 100%; opacity: .45; -webkit-mask-image: none; mask-image: none; }
  .banner .content { max-width: none; }
}

.fact { position: relative; overflow: hidden; }
.fact .label { display: inline-flex; align-items: center; gap: 6px; font-size: .74rem; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.fact .text { margin: 8px 0 10px; font-size: .98rem; }
.fact .eq { font-size: 1.1rem; padding: 10px 12px; background: var(--brand-soft); border-radius: 10px; overflow-x: auto; }
.fact .alt { color: var(--muted); font-size: .88rem; margin-top: 8px; }

/* animations on/off switch */
.site-foot .linkbtn, .landing-foot .linkbtn { font-size: inherit; color: inherit; text-decoration: underline; text-underline-offset: 2px; }
.motion-pill { position: fixed; right: 14px; bottom: 14px; z-index: 30; }
.motion-pill .linkbtn { background: rgba(15, 23, 42, .72); color: #e2e8f0; border: 1px solid rgba(255, 255, 255, .22); border-radius: 999px; padding: 4px 12px; font-size: .78rem; }
.motion-pill .linkbtn:hover { background: rgba(15, 23, 42, .9); }
@media (prefers-reduced-motion: reduce) { [data-motion-toggle] { display: none; } }

@media (prefers-reduced-motion: reduce) {
  .scroll-hint::after { animation: none; }
  .phys-card, .btn { transition: none; }
}
@media print { .banner canvas, .auth-art { display: none !important; } .banner { background: #fff; color: #000; box-shadow: none; } }

/* ---------- past-paper questions shown as the original page image ---------- */
.q-picture { margin: 4px 0 2px; }
.q-full { display: block; max-width: 100%; height: auto; border-radius: var(--radius-sm); border: 1px solid var(--line); background: #fff; }
.q-alt-img { display: none; margin-top: 10px; }
html.show-both .q-alt-img { display: block; }
.choices.letters { grid-template-columns: repeat(auto-fit, minmax(56px, 1fr)); gap: 10px; }
.choices.letters .choice { grid-template-columns: 1fr; justify-items: center; text-align: center; padding: 10px 6px; gap: 4px; }
.choices.letters .choice .key { width: 40px; height: 40px; font-size: 1.15rem; }
.choices.letters .opt-text { display: none; }
.choices.letters .mark { font-size: .72rem; white-space: normal; line-height: 1.2; }
.choices.letters .mark:empty { display: none; }
#review-list.only-wrong .review-item.is-right { display: none; }
.q-thumb { width: 150px; max-height: 90px; object-fit: cover; object-position: top left; border: 1px solid var(--line); border-radius: 6px; float: right; margin: 0 0 6px 10px; background: #fff; }

/* ---------- chapter practice (分章练习) ---------- */
.chapters { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 14px; }
.chapter { background: #fff; border: 1px solid rgba(226, 232, 240, .95); border-radius: 16px; padding: 16px 16px 14px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 10px; position: relative; overflow: hidden; }
.chapter::before { content: ""; position: absolute; inset: 0 0 auto 0; height: 3px; background: var(--grad-cool); opacity: .8; }
.chapter:nth-child(3n+2)::before { background: var(--grad); }
.chapter:nth-child(3n)::before { background: linear-gradient(90deg, #10b981, #06b6d4); }
.chapter.empty { opacity: .6; box-shadow: none; }
.ch-head { display: flex; align-items: baseline; gap: 10px; }
.ch-no { font-family: var(--display); font-weight: 700; font-size: .95rem; color: var(--brand); background: var(--brand-soft); border-radius: 8px; padding: 2px 7px; }
.ch-head h3 { margin: 0; font-family: var(--display); font-size: 1.06rem; line-height: 1.25; }
.ch-meta { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: .85rem; color: var(--muted); }
.ch-meta b { color: var(--ink); font-family: var(--display); font-size: 1rem; }
.ch-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: auto; }
.layout-switch .img-only { display: none; }
#qform.layout-image .layout-switch .img-only { display: block; }
#qform.layout-image .opt-row input[type=text] { display: none; }
#qform.layout-image .opt-row { grid-template-columns: auto; display: inline-flex; margin-right: 14px; }
.pack-card { display: flex; justify-content: space-between; align-items: center; gap: 14px; flex-wrap: wrap; margin-bottom: 14px; border-left: 4px solid var(--brand); }

/* ---------- lessons (课程) ---------- */
.lessons { display: grid; gap: 12px; }
.lesson-card { display: grid; grid-template-columns: 64px minmax(0, 1fr) auto; gap: 16px; align-items: center; background: #fff; color: inherit;
  border: 1px solid rgba(226, 232, 240, .95); border-radius: 16px; padding: 14px 18px; box-shadow: var(--shadow); position: relative; transition: border-color .15s, transform .15s; }
.lesson-card:hover { text-decoration: none; border-color: #c7cdfb; transform: translateY(-1px); }
.lesson-card.current { border-color: var(--brand); box-shadow: var(--shadow-lg); }
.lesson-card.unseen::after { content: ""; position: absolute; top: 14px; right: 14px; width: 8px; height: 8px; border-radius: 50%; background: #db2777; }
.lesson-card h3 { margin: 2px 0 2px; font-family: var(--display); font-size: 1.1rem; line-height: 1.3; }
.lesson-sum { margin: 2px 0 6px; font-size: .88rem; color: var(--ink-2); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.lesson-go { font-size: 1.3rem; color: var(--muted); }
.lesson-when { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; font-size: .82rem; color: var(--muted); font-weight: 600; }
.lesson-no { width: 64px; height: 64px; border-radius: 14px; background: var(--grad); color: #fff; display: grid; place-content: center; text-align: center; line-height: 1; box-shadow: 0 8px 18px -10px rgba(79, 70, 229, .8); }
.lesson-no span { font-size: .62rem; letter-spacing: .06em; text-transform: uppercase; opacity: .85; font-weight: 700; }
.lesson-no b { font-family: var(--display); font-size: 1.7rem; margin-top: 3px; }
.lesson-no.big { width: 78px; height: 78px; border-radius: 18px; }
.lesson-no.big b { font-size: 2.1rem; }
.chip-vid { color: #be185d; font-weight: 600; }
.lesson-now { display: grid; grid-template-columns: 64px minmax(0, 1fr) auto; gap: 16px; align-items: center; color: inherit; border-left: 4px solid var(--brand); }
.lesson-now:hover { text-decoration: none; border-color: var(--brand); }
.crumbs { margin: -4px 0 10px; font-size: .88rem; }
.lesson-head { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 18px; align-items: center; margin-bottom: 18px; }
.lesson-head h1 { margin: 4px 0 2px; font-family: var(--display); line-height: 1.2; }
.lesson-head .sub { color: var(--muted); }
.lesson-summary { margin-bottom: 16px; line-height: 1.65; border-left: 4px solid var(--brand); }
.video-card .card-head h2 { font-size: 1.05rem; }
.player { width: 100%; max-height: 72vh; border-radius: 10px; background: #0b1020; display: block; }
.video-frame { position: relative; width: 100%; aspect-ratio: 16 / 9; border-radius: 10px; overflow: hidden; background: #0b1020; }
.video-frame iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.video-link { display: flex; align-items: center; justify-content: center; gap: 12px; aspect-ratio: 16 / 9; max-height: 240px; width: 100%; border-radius: 10px;
  background: linear-gradient(135deg, #0b1020, #312e81); color: #fff; font-weight: 700; font-size: 1.05rem; }
.video-link span { width: 54px; height: 54px; border-radius: 50%; background: rgba(255, 255, 255, .16); display: grid; place-items: center; font-size: 1.3rem; }
.video-link:hover { text-decoration: none; color: #fff; filter: brightness(1.15); }
.pdf-view { margin-top: 14px; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: #525659; }
.pdf-view iframe { display: block; width: 100%; height: 78vh; min-height: 520px; border: 0; }
@media (max-width: 720px) { .pdf-view { display: none; } }
.after-class h2 { margin-bottom: 8px; }
.homework { background: var(--warn-soft); border: 1px solid #f3dfaa; border-radius: var(--radius-sm); padding: 10px 12px; line-height: 1.6; }
.homework h4 { margin: 0 0 4px; font-size: .88rem; color: var(--warn-ink); }
.paper-link { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); display: grid; gap: 6px; justify-items: start; }
.lesson-nav { display: grid; gap: 10px; }
.lesson-nav a { display: grid; gap: 2px; color: inherit; padding: 8px 10px; border-radius: var(--radius-sm); border: 1px solid var(--line); }
.lesson-nav a:hover { text-decoration: none; border-color: var(--brand); }
.lesson-nav a.right { text-align: right; }
.mat-row { display: grid; grid-template-columns: 40px minmax(0, 1fr) auto; gap: 12px; align-items: start; padding: 12px 0; border-top: 1px solid var(--line); }
.mat-row:first-of-type { border-top: 0; }
.mat-edit { display: grid; gap: 6px; min-width: 0; }
.mat-names { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.mat-names input { padding: 6px 8px; }
.mat-meta { overflow-wrap: anywhere; }
.mat-controls { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.mat-controls select { width: auto; padding: 5px 8px; }
.mat-controls .check { margin: 0; }
.mat-actions { display: flex; gap: 4px; flex-wrap: wrap; justify-content: flex-end; }
.upload-box { margin-top: 16px; padding: 16px; border: 2px dashed #c7cdfb; border-radius: 12px; background: var(--brand-soft); }
.upload-box h3 { margin-top: 0; }
.upload-progress { margin: 4px 0 12px; }
.upload-progress .bar-fill { background: var(--grad); transition: width .2s; }
.upload-status { margin-top: 6px; }
.upload-status.err { color: var(--bad-ink); font-weight: 600; }
@media (max-width: 700px) {
  .lesson-card, .lesson-now { grid-template-columns: 52px minmax(0, 1fr); padding: 12px 14px; }
  .lesson-card .lesson-go, .lesson-now > .btn { display: none; }
  .lesson-no { width: 52px; height: 52px; }
  .lesson-no b { font-size: 1.4rem; }
  .mat-row { grid-template-columns: 40px minmax(0, 1fr); }
  .mat-actions { grid-column: 1 / -1; justify-content: flex-start; }
  .mat-names { grid-template-columns: 1fr; }
}

/* ---------- v1.4: written (self-marked) questions, IPC ---------- */
.badge.wq { background: #f3e8ff; border-color: #e3ccfb; color: #6b21a8; }
.written-note { margin-top: 12px; padding: 10px 12px; border-radius: var(--radius-sm); background: #faf5ff; border: 1px dashed #d8b4fe; color: #581c87; font-size: .92rem; }
.explain.marking { background: #fffdf5; border-color: #f3dfaa; }
.explain.marking h4 { color: var(--warn-ink); }
.selfmark { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 12px; }
.selfmark .lbl { font-weight: 700; margin-right: 4px; }
.selfmark .btn { min-width: 38px; justify-content: center; }
.selfmark .btn.on { background: var(--brand); border-color: var(--brand); color: #fff; }
.verdict.mid { color: var(--warn-ink); }
.palette button.partial { background: var(--warn-soft); border-color: var(--warn); color: var(--warn-ink); }
.palette button.w { border-style: dashed; }
.palette-legend .l-w::before { border-style: dashed; border-color: #a78bfa; }
.review-item[id] { scroll-margin-top: 80px; }
.layout-switch .w-only, #qform .w-only, #qform .w-only-inline { display: none; }
#qform.layout-written .w-only { display: block; }
#qform.layout-written .w-only-inline { display: inline; }
#qform.layout-written .mc-only, #qform.layout-written .mc-only-inline { display: none; }
