/* ===================================================================
   Marker - dark study theme. Mobile first; breakpoints at 720 / 1100px.
   =================================================================== */
:root {
  color-scheme: dark;
  --bg: #0e1014;
  --surface: #161920;
  --surface-2: #1d212a;
  --surface-3: #252a35;
  --border: #2a2f3a;
  --border-strong: #3a4150;
  --text: #e9ebf0;
  --text-2: #b9bfcb;
  --muted: #8a92a2;
  --accent: #5b8def;
  --accent-strong: #3f74e0;
  --accent-soft: rgba(91, 141, 239, 0.14);
  --good: #2fb36a;
  --good-soft: rgba(47, 179, 106, 0.14);
  --warn: #f2b134;
  --warn-soft: rgba(242, 177, 52, 0.14);
  --bad: #e66767;
  --bad-soft: rgba(230, 103, 103, 0.14);
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 8px 30px rgba(0, 0, 0, 0.35);
  --header-h: 58px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; display: block; }
h1, h2, h3 { line-height: 1.25; margin: 0 0 .5rem; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.2rem; }
h3 { font-size: 1rem; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.hidden { display: none !important; }
.num { font-variant-numeric: tabular-nums; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ------------------------------------------------------------ header */
.app-header {
  position: sticky; top: 0; z-index: 50;
  height: var(--header-h);
  display: flex; align-items: center; gap: 12px;
  padding: 0 16px;
  background: rgba(14, 16, 20, 0.88);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 9px; font-weight: 700; color: var(--text); font-size: 1.05rem; }
.brand:hover { text-decoration: none; }
.brand-mark {
  width: 30px; height: 30px; border-radius: 9px;
  display: grid; place-items: center;
  background: linear-gradient(135deg, var(--accent), #8a6cf0);
  color: #fff; font-size: 1rem;
}
.nav { display: flex; gap: 4px; margin-left: 12px; }
.nav a {
  color: var(--text-2); padding: 7px 12px; border-radius: 8px; font-size: .92rem; white-space: nowrap;
}
.nav a:hover { background: var(--surface-2); text-decoration: none; color: var(--text); }
.nav a.active { background: var(--accent-soft); color: var(--text); }
.header-right { margin-left: auto; display: flex; align-items: center; gap: 6px; }
.icon-btn {
  position: relative;
  width: 38px; height: 38px; border-radius: 10px;
  display: grid; place-items: center;
  background: transparent; border: 1px solid transparent; color: var(--text-2); cursor: pointer;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.badge {
  position: absolute; top: 3px; right: 3px;
  min-width: 17px; height: 17px; padding: 0 4px; border-radius: 9px;
  background: var(--bad); color: #fff; font-size: .7rem; font-weight: 700; display: grid; place-items: center;
}
.queue-pill {
  display: flex; align-items: center; gap: 8px;
  padding: 5px 10px; border-radius: 999px; font-size: .8rem;
  background: var(--accent-soft); color: var(--text); cursor: pointer; border: 0;
}
.spinner {
  width: 12px; height: 12px; border-radius: 50%;
  border: 2px solid rgba(255,255,255,.25); border-top-color: var(--accent);
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* bottom tab bar on phones */
.tabbar { display: none; }
@media (max-width: 719px) {
  .nav { display: none; }
  .tabbar {
    display: grid; grid-template-columns: repeat(4, 1fr);
    position: fixed; bottom: 0; left: 0; right: 0; z-index: 50;
    background: rgba(22, 25, 32, 0.96); backdrop-filter: blur(10px);
    border-top: 1px solid var(--border);
    padding-bottom: env(safe-area-inset-bottom);
  }
  .tabbar a {
    display: flex; flex-direction: column; align-items: center; gap: 2px;
    padding: 8px 0 7px; font-size: .7rem; color: var(--muted);
  }
  .tabbar a.active { color: var(--accent); }
  .tabbar a:hover { text-decoration: none; }
  .tabbar svg { width: 21px; height: 21px; }
  main { padding-bottom: 80px !important; }
}

/* ------------------------------------------------------------ layout */
main { max-width: 1240px; margin: 0 auto; padding: 22px 16px 60px; }
main.wide { max-width: 1500px; }
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px; margin-bottom: 18px; }
.page-head .grow { flex: 1 1 260px; min-width: 0; }
.page-head p { margin: 0; }
.grid { display: grid; gap: 16px; }
.grid-3 { grid-template-columns: 1fr; }
@media (min-width: 720px) { .grid-3 { grid-template-columns: repeat(3, 1fr); } }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
}
.card-title { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.card-title h2, .card-title h3 { margin: 0; }
.section { margin-top: 28px; }

/* ------------------------------------------------------------ buttons & forms */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 9px 16px; border-radius: 10px; border: 1px solid var(--border-strong);
  background: var(--surface-2); color: var(--text); font: inherit; font-weight: 550; font-size: .92rem;
  cursor: pointer; white-space: nowrap; transition: background .15s, border-color .15s;
}
.btn:hover { background: var(--surface-3); text-decoration: none; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-strong); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }
.btn-danger { color: var(--bad); }
.btn-sm { padding: 6px 11px; font-size: .84rem; border-radius: 8px; }
.btn-block { width: 100%; }

label.field { display: block; margin-bottom: 14px; }
label.field > span { display: block; font-size: .85rem; color: var(--text-2); margin-bottom: 6px; font-weight: 550; }
.input, select.input, textarea.input {
  width: 100%; padding: 10px 12px; border-radius: 10px;
  background: var(--bg); color: var(--text);
  border: 1px solid var(--border-strong); font: inherit;
}
.input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
textarea.input { min-height: 90px; resize: vertical; }
.row { display: flex; gap: 12px; flex-wrap: wrap; }
.row > * { flex: 1 1 200px; min-width: 0; }
.form-error { color: var(--bad); font-size: .88rem; min-height: 1.3em; margin: 4px 0 10px; }
.check { display: flex; align-items: center; gap: 8px; font-size: .9rem; color: var(--text-2); margin-bottom: 14px; }

/* ------------------------------------------------------------ auth */
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.auth-card { width: 100%; max-width: 400px; }
.auth-card .brand { justify-content: center; margin-bottom: 20px; font-size: 1.3rem; }
.auth-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; background: var(--bg); padding: 4px; border-radius: 11px; margin-bottom: 18px; }
.auth-tabs button { padding: 8px; border: 0; border-radius: 8px; background: transparent; color: var(--text-2); font: inherit; font-weight: 600; cursor: pointer; }
.auth-tabs button.active { background: var(--surface-3); color: var(--text); }

/* ------------------------------------------------------------ dashboard */
.hero h1 { font-size: 1.7rem; }
.action-card {
  display: flex; flex-direction: column; gap: 10px;
  color: var(--text); min-height: 170px; position: relative; overflow: hidden;
  transition: transform .15s, border-color .15s;
}
.action-card:hover { transform: translateY(-2px); border-color: var(--border-strong); text-decoration: none; }
.action-icon { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; }
.action-icon svg { width: 22px; height: 22px; }
.action-card h2 { margin: 4px 0 0; }
.action-card p { margin: 0; color: var(--text-2); font-size: .9rem; }
.action-card .foot { margin-top: auto; font-size: .82rem; color: var(--muted); }
.tone-blue { background: var(--accent-soft); color: var(--accent); }
.tone-green { background: var(--good-soft); color: var(--good); }
.tone-amber { background: var(--warn-soft); color: var(--warn); }

/* queue */
.queue-list { display: flex; flex-direction: column; gap: 10px; }
.queue-item {
  display: grid; grid-template-columns: auto 1fr auto; gap: 12px; align-items: center;
  padding: 12px 14px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px;
}
.queue-pos {
  width: 34px; height: 34px; border-radius: 10px; background: var(--surface-3);
  display: grid; place-items: center; font-weight: 700; font-size: .9rem; color: var(--text-2);
}
.queue-item.processing .queue-pos { background: var(--accent-soft); color: var(--accent); }
.queue-item.failed .queue-pos { background: var(--bad-soft); color: var(--bad); }
.queue-main { min-width: 0; }
.queue-name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.queue-stage { font-size: .8rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.progress { height: 7px; border-radius: 99px; background: var(--surface-3); overflow: hidden; margin-top: 7px; }
.progress > div { height: 100%; border-radius: 99px; background: var(--accent); transition: width .6s ease; }
.queue-item.queued .progress > div { background: var(--border-strong); }
.queue-pct { font-variant-numeric: tabular-nums; font-weight: 650; font-size: .9rem; color: var(--text-2); }
.empty { text-align: center; padding: 26px 12px; color: var(--muted); }
.empty svg { width: 34px; height: 34px; margin: 0 auto 8px; opacity: .6; }

/* ------------------------------------------------------------ upload */
.upload-grid { display: grid; gap: 16px; grid-template-columns: 1fr; }
@media (min-width: 900px) { .upload-grid { grid-template-columns: 1.3fr 1fr; } }
.dropzone {
  display: flex; align-items: center; gap: 14px;
  border: 1.5px dashed var(--border-strong); border-radius: 12px; padding: 16px;
  background: var(--bg); cursor: pointer; transition: border-color .15s, background .15s;
  margin-bottom: 12px;
}
.dropzone:hover, .dropzone.drag { border-color: var(--accent); background: var(--accent-soft); }
.dropzone.filled { border-style: solid; border-color: var(--good); background: var(--good-soft); }
.dropzone .dz-icon { width: 42px; height: 42px; flex: none; border-radius: 10px; background: var(--surface-2); display: grid; place-items: center; color: var(--text-2); }
.dropzone.filled .dz-icon { color: var(--good); }
.dz-text { min-width: 0; flex: 1; }
.dz-title { font-weight: 600; }
.dz-sub { font-size: .82rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dropzone input { display: none; }
.opt { font-size: .75rem; font-weight: 500; color: var(--muted); background: var(--surface-2); padding: 1px 7px; border-radius: 6px; margin-left: 6px; }

.tag-input { display: flex; flex-wrap: wrap; gap: 6px; padding: 7px; border-radius: 10px; border: 1px solid var(--border-strong); background: var(--bg); }
.tag-input:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.tag-input input { flex: 1; min-width: 120px; border: 0; background: transparent; color: var(--text); font: inherit; padding: 4px; outline: none; }
.tag {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 9px; border-radius: 999px; font-size: .78rem; font-weight: 550;
  background: var(--surface-3); color: var(--text-2); border: 1px solid transparent; white-space: nowrap;
}
.tag button { border: 0; background: none; color: inherit; cursor: pointer; padding: 0; font-size: .95rem; line-height: 1; }
button.tag { cursor: pointer; font: inherit; font-size: .78rem; }
button.tag:hover { border-color: var(--border-strong); }
button.tag.on { background: var(--accent-soft); color: var(--text); border-color: var(--accent); }
.tag-suggest { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.upload-progress { margin-top: 12px; }

/* ------------------------------------------------------------ tests list */
.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 14px; }
.filters .search { flex: 1 1 240px; position: relative; }
.filters .search svg { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); width: 17px; color: var(--muted); }
.filters .search .input { padding-left: 36px; }
.filters select.input, .filters input[type=date].input { width: auto; flex: 0 1 auto; }
.tag-filter { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 16px; }
.results-meta { font-size: .85rem; color: var(--muted); margin-bottom: 10px; }

.test-list { display: flex; flex-direction: column; gap: 12px; }
.test-card { padding: 0; overflow: hidden; }
.test-row { display: grid; grid-template-columns: auto minmax(0, 1fr); grid-auto-flow: column; grid-auto-columns: auto; gap: 16px; align-items: center; padding: 16px 18px; cursor: pointer; }
.test-row:hover { background: rgba(255,255,255,.015); }
.test-info { min-width: 0; }
.test-name { font-weight: 650; font-size: 1.02rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.test-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; font-size: .82rem; color: var(--muted); margin-top: 3px; }
.test-score { text-align: right; }
.score-big { font-size: 1.45rem; font-weight: 750; font-variant-numeric: tabular-nums; line-height: 1.1; }
.score-sub { font-size: .8rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.outcome-strip { display: flex; gap: 2px; height: 6px; margin-top: 9px; border-radius: 4px; overflow: hidden; max-width: 420px; }
.outcome-strip span { flex: 1; }
.o-full { background: var(--good); }
.o-partial { background: var(--warn); }
.o-zero { background: var(--bad); }
.o-error, .o-pending { background: var(--border-strong); }
.test-expand { border-top: 1px solid var(--border); padding: 12px 18px 16px; background: var(--surface-2); }
.test-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.expand-btn { transition: transform .2s; }
.expand-btn.open { transform: rotate(180deg); }

.q-breakdown { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.q-chip {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 8px 11px; border-radius: 9px; background: var(--surface); border: 1px solid var(--border);
  color: var(--text); font-size: .88rem;
}
.q-chip:hover { border-color: var(--border-strong); text-decoration: none; }
.q-chip .lbl { font-weight: 650; }
.q-chip .mk { font-variant-numeric: tabular-nums; font-weight: 650; display: flex; align-items: center; gap: 5px; }

/* score ring */
.ring { position: relative; width: 58px; height: 58px; flex: none; }
.ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring .ring-bg { stroke: var(--surface-3); }
.ring .ring-fg { transition: stroke-dashoffset .8s ease; stroke-linecap: round; }
.ring .ring-label { position: absolute; inset: 0; display: grid; place-items: center; font-weight: 750; font-size: .86rem; font-variant-numeric: tabular-nums; }
.ring.lg { width: 84px; height: 84px; }
.ring.lg .ring-label { font-size: 1.15rem; }

.status-icon { width: 15px; height: 15px; flex: none; }
.c-good { color: var(--good); }
.c-warn { color: var(--warn); }
.c-bad { color: var(--bad); }

@media (max-width: 560px) {
  .test-row { grid-template-columns: auto minmax(0, 1fr) auto auto; grid-auto-flow: row; gap: 4px 12px; padding: 14px; }
  .test-row .ring { grid-column: 1; grid-row: 1 / span 2; }
  .test-row .test-info { grid-column: 2; grid-row: 1; }
  .test-row .grade-badge { grid-column: 3; grid-row: 1 / span 2; }
  .test-row .expand-btn { grid-column: 4; grid-row: 1 / span 2; }
  .test-row .test-score { grid-column: 2; grid-row: 2; text-align: left; display: flex; align-items: baseline; gap: 8px; }
  .ring { width: 50px; height: 50px; }
}

/* ------------------------------------------------------------ paper view */
.paper-toolbar {
  position: sticky; top: var(--header-h); z-index: 30;
  background: rgba(14, 16, 20, 0.94); backdrop-filter: blur(8px);
  margin: -22px -16px 0; padding: 12px 16px 0; border-bottom: 1px solid var(--border);
}
.paper-top { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.paper-title { flex: 1 1 200px; min-width: 0; }
.paper-title h1 { font-size: 1.15rem; margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.paper-score { display: flex; align-items: center; gap: 12px; }
.seg { display: inline-flex; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 3px; gap: 2px; }
.seg button { border: 0; background: transparent; color: var(--text-2); padding: 5px 10px; border-radius: 7px; font: inherit; font-size: .82rem; font-weight: 600; cursor: pointer; white-space: nowrap; }
.seg button.on { background: var(--surface-3); color: var(--text); }
.qnav { display: flex; gap: 8px; overflow-x: auto; padding: 10px 0 12px; scrollbar-width: thin; align-items: stretch; }
/* one box per question: "Q1" on top, its parts (1, 2, 3...) underneath */
.qnav-group { display: flex; flex-direction: column; align-items: flex-start; gap: 5px; flex: none;
  padding: 5px 7px 7px; border-radius: 11px; background: var(--surface); border: 1px solid var(--border); }
.qnav-group.solo { justify-content: flex-end; }
.qnav-parts { display: flex; gap: 4px; }
.qnav-num { font-size: .86rem; color: var(--text); font-weight: 800; letter-spacing: -.01em; padding-left: 2px; line-height: 1; }
.qnav a {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 34px; height: 30px; padding: 0 8px; border-radius: 8px;
  font-size: .8rem; font-weight: 650; color: var(--text); border: 1px solid var(--border);
  background: var(--surface); white-space: nowrap;
}
.qnav a:hover { text-decoration: none; border-color: var(--border-strong); }
.qnav a.full { border-color: rgba(47,179,106,.55); background: var(--good-soft); }
.qnav a.partial { border-color: rgba(242,177,52,.55); background: var(--warn-soft); }
.qnav a.zero { border-color: rgba(230,103,103,.55); background: var(--bad-soft); }
.qnav a.current { outline: 2px solid var(--accent); outline-offset: 1px; }
.qnav a.dim { opacity: .35; }

.paper-body { display: flex; flex-direction: column; gap: 22px; margin-top: 20px; }
.q-row { display: grid; grid-template-columns: 1fr; gap: 12px; scroll-margin-top: calc(var(--header-h) + 120px); }
@media (min-width: 1100px) {
  .q-row { grid-template-columns: minmax(0, 1.45fr) minmax(340px, 1fr); gap: 18px; align-items: start; }
  .q-row .q-feedback { position: sticky; top: calc(var(--header-h) + 118px); max-height: calc(100vh - var(--header-h) - 134px); overflow-y: auto; }
}
.q-answer { padding: 0; overflow: hidden; }
.q-head { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.q-head .q-label { font-weight: 750; font-size: 1.05rem; }
.q-head .grow { flex: 1; }
.mark-pill { display: inline-flex; align-items: center; gap: 6px; padding: 4px 11px; border-radius: 999px; font-weight: 750; font-variant-numeric: tabular-nums; font-size: .92rem; }
.mark-pill.full { background: var(--good-soft); color: var(--good); }
.mark-pill.partial { background: var(--warn-soft); color: var(--warn); }
.mark-pill.zero { background: var(--bad-soft); color: var(--bad); }
.mark-pill.error { background: var(--surface-3); color: var(--text-2); }
.q-imgs { background: #fff; }
.q-imgs img { width: 100%; cursor: zoom-in; border-bottom: 1px solid #e5e5e5; }
.q-context { border-bottom: 1px solid var(--border); }
.q-context summary { cursor: pointer; padding: 8px 16px; font-size: .82rem; color: var(--text-2); background: var(--surface-2); }

.q-feedback { padding: 0; }
.fb-score { display: flex; align-items: center; gap: 14px; padding: 16px; border-bottom: 1px solid var(--border); }
.fb-marks { font-size: 2rem; font-weight: 800; font-variant-numeric: tabular-nums; line-height: 1; }
.fb-marks small { font-size: 1rem; color: var(--muted); font-weight: 600; }
.fb-tabs { display: flex; gap: 2px; padding: 8px 10px 0; border-bottom: 1px solid var(--border); overflow-x: auto; }
.fb-tabs button { border: 0; background: none; color: var(--muted); font: inherit; font-size: .85rem; font-weight: 600; padding: 7px 10px 9px; cursor: pointer; border-bottom: 2px solid transparent; white-space: nowrap; }
.fb-tabs button.on { color: var(--text); border-bottom-color: var(--accent); }
.fb-pane { padding: 14px 16px 16px; }
.fb-summary { margin: 0 0 12px; color: var(--text); }
.fb-list { list-style: none; margin: 0 0 14px; padding: 0; display: flex; flex-direction: column; gap: 7px; }
.fb-list li { display: flex; gap: 9px; align-items: flex-start; font-size: .92rem; color: var(--text-2); }
.fb-list li svg { margin-top: 3px; }
.fb-h { font-size: .74rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 700; margin: 0 0 7px; }
.fb-answer { font-size: .85rem; background: var(--bg); border: 1px solid var(--border); border-radius: 9px; padding: 9px 11px; color: var(--text-2); white-space: pre-wrap; }
.fb-pane .q-imgs { border-radius: 9px; overflow: hidden; }
.confidence { font-size: .78rem; color: var(--muted); }
.q-row.filtered-out { display: none; }

@media (max-width: 719px) {
  .hide-sm { display: none; }
  .paper-toolbar { padding-top: 10px; }
  .paper-top { gap: 8px; }
  .paper-top > .btn-ghost { padding: 6px; }
  .paper-title { flex: 1 1 calc(100% - 200px); }
  .paper-title h1 { font-size: 1rem; }
  .paper-title .test-meta { display: none; }
  .paper-score { gap: 8px; }
  .paper-score .score-big { font-size: 1.1rem; }
  .paper-top .seg { flex: 1 1 auto; }
  .paper-top .seg button { flex: 1; padding: 5px 6px; }
  .qnav { padding: 8px 0 10px; }
  .q-row { scroll-margin-top: calc(var(--header-h) + 140px); }
}

/* lightbox */
.lightbox { position: fixed; inset: 0; z-index: 200; background: rgba(0,0,0,.85); display: grid; place-items: center; padding: 20px; cursor: zoom-out; }
.lightbox img { max-height: 92vh; max-width: 96vw; width: auto; background: #fff; border-radius: 8px; }

/* ------------------------------------------------------------ stats */
.kpis { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
@media (min-width: 720px) { .kpis { grid-template-columns: repeat(4, 1fr); } }
.kpi { padding: 14px 16px; }
.kpi .kpi-label { font-size: .78rem; color: var(--muted); font-weight: 600; }
.kpi .kpi-value { font-size: 1.55rem; font-weight: 750; margin-top: 2px; }
.kpi .kpi-sub { font-size: .78rem; color: var(--text-2); margin-top: 2px; }
.charts { display: grid; gap: 16px; grid-template-columns: 1fr; margin-top: 16px; }
@media (min-width: 1000px) {
  .charts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .charts .span-2 { grid-column: span 2; }
}
.chart-box { position: relative; height: 260px; }
.chart-box.tall { height: 320px; }
.legend { display: flex; flex-wrap: wrap; gap: 14px; font-size: .82rem; color: var(--text-2); margin-bottom: 8px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.legend i.line { height: 3px; border-radius: 2px; vertical-align: 3px; width: 14px; }

.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: .9rem; }
table.data th, table.data td { padding: 9px 10px; text-align: left; border-bottom: 1px solid var(--border); white-space: nowrap; }
table.data th { font-size: .78rem; color: var(--muted); font-weight: 700; text-transform: uppercase; letter-spacing: .04em; cursor: pointer; user-select: none; }
table.data th.sorted::after { content: " ▾"; }
table.data th.sorted.asc::after { content: " ▴"; }
table.data td.num, table.data th.num { text-align: right; font-variant-numeric: tabular-nums; }
table.data tbody tr:hover { background: var(--surface-2); }
table.data tbody tr { cursor: pointer; }

/* ------------------------------------------------------------ toasts & menus */
.toasts { position: fixed; right: 16px; bottom: 16px; z-index: 300; display: flex; flex-direction: column; gap: 10px; max-width: min(380px, calc(100vw - 32px)); }
@media (max-width: 719px) { .toasts { bottom: 84px; } }
.toast {
  display: flex; gap: 10px; align-items: flex-start;
  background: var(--surface-2); border: 1px solid var(--border-strong); border-left: 4px solid var(--accent);
  border-radius: 12px; padding: 12px 14px; box-shadow: var(--shadow); font-size: .9rem;
  animation: toast-in .25s ease;
}
.toast.success { border-left-color: var(--good); }
.toast.warning { border-left-color: var(--warn); }
.toast.error { border-left-color: var(--bad); }
.toast .grow { flex: 1; }
.toast button { border: 0; background: none; color: var(--muted); cursor: pointer; font-size: 1.1rem; line-height: 1; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

.popover {
  position: absolute; right: 0; top: calc(100% + 8px); width: min(360px, calc(100vw - 24px));
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: 12px; box-shadow: var(--shadow);
  z-index: 60; overflow: hidden;
}
.popover-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 14px; border-bottom: 1px solid var(--border); font-weight: 650; }
.popover-list { max-height: 380px; overflow-y: auto; }
.notif { display: block; padding: 11px 14px; border-bottom: 1px solid var(--border); color: var(--text-2); font-size: .88rem; }
.notif:hover { background: var(--surface-2); text-decoration: none; }
.notif.unread { color: var(--text); background: rgba(91,141,239,.06); }
.notif time { display: block; font-size: .75rem; color: var(--muted); margin-top: 2px; }
.menu-item { display: block; width: 100%; text-align: left; padding: 10px 14px; border: 0; background: none; color: var(--text); font: inherit; cursor: pointer; }
.menu-item:hover { background: var(--surface-2); }
.rel { position: relative; }

.banner { padding: 10px 14px; border-radius: 10px; background: var(--warn-soft); color: var(--warn); font-size: .86rem; margin-bottom: 16px; border: 1px solid rgba(242,177,52,.3); }
.banner.info { background: var(--accent-soft); color: var(--text-2); border-color: rgba(91,141,239,.3); }
.banner.info b { color: var(--text); }
.skeleton { background: linear-gradient(90deg, var(--surface-2), var(--surface-3), var(--surface-2)); background-size: 200% 100%; animation: shimmer 1.4s infinite; border-radius: 10px; }
@keyframes shimmer { to { background-position: -200% 0; } }

/* ===================================================================
   GCSE papers, grades, specification points
   =================================================================== */
.picker { display: grid; gap: 4px; }
.picker select.input:disabled { opacity: .55; }
.spec-facts { margin-top: 8px; padding-top: 12px; border-top: 1px solid var(--border); }
.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px 16px; margin: 0 0 8px; }
.facts dt { font-size: .74rem; color: var(--muted); font-weight: 600; }
.facts dd { margin: 2px 0 0; font-weight: 650; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.bounds-row { display: flex; flex-wrap: wrap; gap: 6px; }
.bound { display: flex; flex-direction: column; align-items: center; min-width: 40px; padding: 5px 6px; border-radius: 8px;
  background: var(--surface-2); border: 1px solid var(--border); font-variant-numeric: tabular-nums; }
.bound b { font-size: .9rem; }
.bound span { font-size: .74rem; color: var(--muted); }
.bound.hit { border-color: var(--accent); background: var(--accent-soft); }
.bound.hit span { color: var(--text-2); }

.paper-line { color: var(--text-2); }
.paper-line b { color: var(--text); font-weight: 650; }
.grade-card { margin-top: 16px; }
.grade-main { display: flex; gap: 16px; align-items: center; margin-bottom: 12px; flex-wrap: wrap; }
.grade-main > div { flex: 1 1 240px; }
.spec-chip { display: inline-flex; align-items: center; gap: 5px; margin-left: 8px; padding: 2px 9px; border-radius: 999px; font-size: .76rem;
  font-weight: 600; background: var(--surface-3); color: var(--text-2); max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.spec-chip svg { width: 13px; height: 13px; flex: none; }


/* ===================================================================
   Admin
   =================================================================== */
.admin-tabs { flex-wrap: wrap; }
.meter { height: 8px; border-radius: 4px; background: var(--surface-3); overflow: hidden; margin-top: 8px; }
.meter > div { height: 100%; border-radius: 4px; background: var(--good); transition: width .4s; }
.meter.warn > div { background: var(--warn); }
.meter.bad > div { background: var(--bad); }
.spark { display: block; width: 100%; height: 40px; margin-top: 4px; }
.spark.empty { height: 40px; display: flex; align-items: center; }
.c-accent { color: var(--accent); }
.cores { display: flex; gap: 6px; align-items: flex-end; height: 120px; overflow-x: auto; }
.core { flex: 1 0 18px; display: flex; flex-direction: column; align-items: center; gap: 4px; height: 100%; }
.core-bar { flex: 1; width: 100%; background: var(--surface-3); border-radius: 4px; display: flex; align-items: flex-end; overflow: hidden; }
.core-bar > div { width: 100%; background: var(--accent); border-radius: 4px 4px 0 0; transition: height .4s; }
.core span { font-size: .68rem; color: var(--muted); }
.state-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 7px; background: var(--muted); vertical-align: 1px; }
.state-dot.marking, .state-dot.splitting { background: var(--good); box-shadow: 0 0 0 3px var(--good-soft); }
.state-dot.error { background: var(--bad); }
.state-dot.starting, .state-dot.stopping { background: var(--warn); }
table.data td.actions { white-space: nowrap; text-align: right; }
table.data td.actions .btn + .btn { margin-left: 4px; }
tr.dim-row td { opacity: .55; }
.inst-form { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.inst-form > * { flex: 0 0 auto !important; margin: 0; }
.inst-form .input { width: 80px; padding-top: 5px; padding-bottom: 5px; }
@media (max-width: 719px) {
  table.data td.actions { white-space: normal; }
  table.data td.actions .btn { margin: 2px 0; }
}

/* ===================================================================
   Brand
   =================================================================== */
.brand-logo { display: block; width: 30px; height: 30px; border-radius: 9px; transition: transform .3s cubic-bezier(.3,1.6,.5,1); }
.brand:hover .brand-logo { transform: rotate(-8deg) scale(1.08); }

/* ===================================================================
   Grade badges - red below a pass, then greener, brighter and more
   excited all the way up to a rainbow 9. Calm by default; the
   `.celebrate` class plays the full show once (when a paper opens).
   =================================================================== */
:root {
  /* one full rainbow, repeated twice so sliding it by one period loops with no seam */
  --rainbow: linear-gradient(90deg, #ffb703, #ff7eb6, #a78bfa, #5eead4, #ffb703, #ff7eb6, #a78bfa, #5eead4, #ffb703);
}
.grade-badge {
  position: relative; display: inline-flex; flex-direction: column; align-items: center; justify-content: center;
  min-width: 50px; height: 50px; padding: 0 8px; border-radius: 14px; flex: none; line-height: 1;
  color: #fff; border: 1px solid transparent; isolation: isolate;
}
.grade-badge small { font-size: .52rem; font-weight: 800; letter-spacing: .09em; text-transform: uppercase; opacity: .85; margin-bottom: 3px; }
.grade-badge b { font-size: 1.35rem; font-weight: 850; letter-spacing: -.02em; }
.grade-badge.lg { min-width: 92px; height: 92px; border-radius: 24px; }
.grade-badge.lg small { font-size: .66rem; margin-bottom: 4px; }
.grade-badge.lg b { font-size: 2.6rem; }
.kpi .grade-badge { margin-top: 6px; }

.grade-badge.g-fail { background: var(--bad-soft); color: var(--bad); border-color: rgba(230,103,103,.5); }
.grade-badge.g-4 { background: #1f8f55; border-color: #2fb36a; box-shadow: 0 4px 14px -8px rgba(47,179,106,.6); }
.grade-badge.g-5 { background: linear-gradient(140deg, #23a463, #3fcf7f); box-shadow: 0 5px 16px -8px rgba(63,207,127,.6); }
.grade-badge.g-6 { background: linear-gradient(140deg, #19b07a, #19b4c4); box-shadow: 0 5px 18px -8px rgba(25,180,196,.6); }
.grade-badge.g-7 { background: linear-gradient(140deg, #14b3c6, #4f7cf7); box-shadow: 0 6px 20px -8px rgba(79,124,247,.65); }
.grade-badge.g-8 { background: linear-gradient(140deg, #5b6cf7, #9b5cf6 55%, #f472b6); box-shadow: 0 6px 22px -8px rgba(155,92,246,.7); }
.grade-badge.g-9 { background: var(--rainbow); background-size: 200% 100%; color: #2a1647; text-shadow: 0 1px 0 rgba(255,255,255,.5);
  border-color: rgba(255,255,255,.55); box-shadow: 0 6px 22px -8px rgba(255,126,182,.7); animation: rainbow-flow 14s linear infinite; }
.grade-badge.g-9 small { color: #3b1d63; opacity: .8; }

/* sparkles only exist while celebrating */
.grade-badge .spark { display: none; position: absolute; width: 9px; height: 9px; pointer-events: none; background: #fff;
  clip-path: polygon(50% 0, 60% 40%, 100% 50%, 60% 60%, 50% 100%, 40% 60%, 0 50%, 40% 40%); opacity: 0; }
.grade-badge .s1 { top: -4px; right: -3px; }
.grade-badge .s2 { bottom: 2px; left: -5px; width: 7px; height: 7px; }
.grade-badge .s3 { top: 40%; right: -7px; width: 6px; height: 6px; }
.grade-badge .s4 { top: -6px; left: 6px; width: 7px; height: 7px; }

/* --- the one-off celebration (about 3 s), then everything settles to the calm look above */
.grade-badge.celebrate { animation: pop-in .65s cubic-bezier(.3,1.7,.5,1) both; }
.grade-badge.celebrate.g-9 { animation: pop-in .7s cubic-bezier(.3,1.8,.5,1) both, rainbow-flow 14s linear infinite; }
.grade-badge.celebrate.g-8 { box-shadow: 0 8px 32px -4px rgba(244,114,182,.85); transition: box-shadow 1.2s ease; }
.grade-badge.celebrate.g-9 { box-shadow: 0 0 0 6px rgba(255,209,102,.16), 0 10px 40px 0 rgba(255,126,182,.85); transition: box-shadow 1.2s ease; }
.grade-badge.g-8, .grade-badge.g-9 { transition: box-shadow 1.2s ease; }
.grade-badge.celebrate.g-7::after, .grade-badge.celebrate.g-8::after, .grade-badge.celebrate.g-9::after {
  content: ""; position: absolute; inset: 0; border-radius: inherit; z-index: -1; pointer-events: none;
  background: linear-gradient(105deg, transparent 35%, rgba(255,255,255,.55) 50%, transparent 65%);
  background-size: 250% 100%; mix-blend-mode: overlay; animation: shine 1.4s ease-in-out .5s 2 both;
}
.grade-badge.celebrate .spark { display: block; animation: twinkle 1.2s ease-in-out 2; }
.grade-badge.celebrate .s2 { animation-delay: .4s; } .grade-badge.celebrate .s3 { animation-delay: .8s; } .grade-badge.celebrate .s4 { animation-delay: .2s; }
.grade-badge.lg .spark { transform: scale(1.6); }

@keyframes rainbow-flow { from { background-position: 0% 50%; } to { background-position: 100% 50%; } }
@keyframes shine { 0%, 30% { background-position: 160% 0; } 100% { background-position: -60% 0; } }
@keyframes twinkle { 0%, 100% { opacity: 0; transform: scale(.4) rotate(0); } 50% { opacity: 1; transform: scale(1.15) rotate(45deg); } }
@keyframes pop-in { 0% { transform: scale(.3) rotate(-12deg); opacity: 0; } 70% { transform: scale(1.12) rotate(3deg); opacity: 1; } 100% { transform: none; } }

/* the card around the big grade: red for a fail, green for a pass (deeper as it climbs), rainbow for a 9 */
.grade-card { position: relative; overflow: visible; }
.grade-word { font-size: 1.35rem; font-weight: 800; letter-spacing: -.01em; }
.grade-cheer { color: var(--text-2); margin: 2px 0 6px; }
.grade-maxed { font-weight: 700; color: #4ade80; }
.g-fail-card { border-color: rgba(230,103,103,.5); background: linear-gradient(160deg, rgba(230,103,103,.1), var(--surface) 55%); }
.g-fail-card .grade-word { color: var(--bad); }
.g-4-card, .g-5-card, .g-6-card, .g-7-card, .g-8-card { border-color: rgba(47,179,106,.45); }
.g-4-card { background: linear-gradient(160deg, rgba(47,179,106,.07), var(--surface) 50%); }
.g-5-card { background: linear-gradient(160deg, rgba(47,179,106,.1), var(--surface) 55%); }
.g-6-card { background: linear-gradient(160deg, rgba(47,179,106,.13), var(--surface) 58%); border-color: rgba(47,179,106,.55); }
.g-7-card { background: linear-gradient(160deg, rgba(47,179,106,.16), var(--surface) 62%); border-color: rgba(74,222,128,.6); }
.g-8-card { background: linear-gradient(160deg, rgba(74,222,128,.2), var(--surface) 66%); border-color: rgba(74,222,128,.75); }
.g-4-card .grade-word, .g-5-card .grade-word, .g-6-card .grade-word, .g-7-card .grade-word, .g-8-card .grade-word { color: #4ade80; }
/* a rainbow edge for the top grade */
.g-9-card { border: 2px solid transparent;
  background: linear-gradient(160deg, rgba(167,139,250,.12), rgba(94,234,212,.05) 50%, var(--surface) 75%) padding-box,
              linear-gradient(var(--surface), var(--surface)) padding-box,
              var(--rainbow) border-box;
  background-size: 100% 100%, 100% 100%, 200% 100%; animation: rainbow-border 14s linear infinite; }
@keyframes rainbow-border { from { background-position: 0 0, 0 0, 0% 50%; } to { background-position: 0 0, 0 0, 100% 50%; } }
.g-9-card .grade-word, .g-9-card .grade-maxed { background: var(--rainbow); background-size: 200% 100%; -webkit-background-clip: text; background-clip: text;
  color: transparent; animation: rainbow-flow 14s linear infinite; }
.g-9-card .grade-word { font-size: 1.6rem; }
.g-9-card .grade-word .emo { -webkit-text-fill-color: initial; }

/* confetti burst */
.confetti { position: absolute; left: 50%; top: 50%; width: 0; height: 0; pointer-events: none; z-index: 5; }
.confetti i { position: absolute; width: 8px; height: 12px; border-radius: 2px; left: -4px; top: -6px; opacity: 0;
  animation: confetti 1.3s cubic-bezier(.15,.7,.4,1) forwards; }
.confetti i.star { width: auto; height: auto; font-size: 18px; font-style: normal; left: -8px; top: -10px; }
@keyframes confetti {
  0% { opacity: 1; transform: translate(0, 0) rotate(0) scale(.6); }
  70% { opacity: 1; }
  100% { opacity: 0; transform: translate(var(--x), calc(var(--y) + 60px)) rotate(var(--r)) scale(1); }
}

/* ===================================================================
   Pencil progress: the pencil draws the line as it goes
   =================================================================== */
.pencil-progress { position: relative; height: 24px; margin-top: 6px; --p: 0%; }
.pp-track { position: absolute; left: 0; right: 0; top: 14px; height: 6px; border-radius: 3px;
  background: repeating-linear-gradient(90deg, var(--surface-3) 0 6px, transparent 6px 10px); opacity: .9; }
.pp-line { position: absolute; left: 0; top: 11px; height: 12px; width: var(--p); transition: width .8s cubic-bezier(.4,0,.2,1);
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='12' viewBox='0 0 24 12'%3E%3Cpath d='M0 6 Q6 1 12 6 T24 6' fill='none' stroke='%235b8def' stroke-width='3' stroke-linecap='round'/%3E%3C/svg%3E") repeat-x left center / 24px 12px; }
.pp-pencil { position: absolute; top: -6px; left: var(--p); width: 30px; height: 30px; margin-left: -4px;
  transition: left .8s cubic-bezier(.4,0,.2,1); transform-origin: 4px 26px; animation: scribble .45s ease-in-out infinite alternate; }
.pp-pencil svg { width: 100%; height: 100%; display: block; filter: drop-shadow(0 2px 2px rgba(0,0,0,.35)); }
.pencil-progress.waiting .pp-pencil { animation: tap 1.1s ease-in-out infinite; }
.pencil-progress.waiting .pp-line { width: 0; }
@keyframes scribble { from { transform: rotate(-7deg) translateY(0); } to { transform: rotate(5deg) translateY(1px); } }
@keyframes tap { 0%, 60%, 100% { transform: rotate(0) translateY(0); } 30% { transform: rotate(-14deg) translateY(-6px); } }
.upload-progress .pencil-progress { margin-top: 12px; }

/* ===================================================================
   Statistics: what to revise
   =================================================================== */
.revise-panel { margin-top: 18px; }
.revise-panel.card .card-title { margin-bottom: 6px; }
.revise-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 12px; margin-bottom: 12px; }
.revise-head h2 { margin: 0; font-size: 1.25rem; }
.q-links { display: inline-flex; flex-wrap: wrap; gap: 4px; vertical-align: middle; }
.q-links a { padding: 1px 7px; border-radius: 999px; background: var(--accent-soft); font-weight: 650; font-size: .76rem; }
.q-links a:hover { text-decoration: none; background: rgba(91,141,239,.28); }
@keyframes rise { from { opacity: 0; transform: translateY(10px) scale(.98); } }

/* specification tree */
.spec-tree { margin-top: 16px; }
.spec-subject + .spec-subject { margin-top: 18px; }
.spec-subject-head { display: flex; align-items: center; gap: 8px; padding-bottom: 8px; border-bottom: 1px solid var(--border); margin-bottom: 4px; }
.spec-subject-head .grow { flex: 1; }
.st-row { margin-left: calc(var(--d) * 18px); border-left: 2px solid transparent; }
.st-row .st-row { border-left-color: var(--border); }
.st-line { display: grid; grid-template-columns: minmax(0, 1fr) auto 90px 44px; gap: 10px; align-items: center;
  padding: 8px 8px; border-radius: 8px; cursor: default; list-style: none; }
summary.st-line { cursor: pointer; }
summary.st-line::-webkit-details-marker { display: none; }
summary.st-line .st-name::before { content: "▸"; display: inline-block; width: 16px; color: var(--muted); transition: transform .2s; }
details[open] > summary.st-line .st-name::before { transform: rotate(90deg); }
.st-leaf .st-name::before { content: "•"; display: inline-block; width: 16px; color: var(--muted); }
.st-line:hover { background: var(--surface-2); }
.st-name { font-weight: 650; overflow-wrap: anywhere; }
.st-row[style*="--d:0"] > .st-line .st-name, details.st-row[style*="--d:0"] > summary .st-name { font-size: 1.02rem; }
.st-ref { font-size: .74rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.st-meter { height: 7px; border-radius: 4px; background: var(--surface-3); overflow: hidden; }
.st-meter > span { display: block; height: 100%; border-radius: 4px; background: var(--good); }
.st-meter.warn > span { background: var(--warn); }
.st-meter.bad > span { background: var(--bad); }
.st-pct { font-weight: 750; text-align: right; font-variant-numeric: tabular-nums; }
.st-pct.good { color: var(--good); } .st-pct.warn { color: var(--warn); } .st-pct.bad { color: var(--bad); }
.st-sub { padding: 0 8px 8px 34px; margin-top: -4px; }
.st-children { padding-bottom: 2px; }
details.st-row[open] > .st-children { animation: rise .3s ease both; }
@media (max-width: 560px) {
  .st-line { grid-template-columns: minmax(0, 1fr) 54px 40px; }
  .st-ref { display: none; }
  .st-row { margin-left: calc(var(--d) * 10px); }
}

/* ===================================================================
   Landing page
   =================================================================== */
main.landing-main { max-width: none; padding: 0; min-height: 100vh;
  background: radial-gradient(700px 360px at 80% 8%, rgba(139,92,246,.16), transparent 70%), radial-gradient(600px 320px at 12% 85%, rgba(91,141,239,.13), transparent 70%); }
.landing { min-height: 100vh; display: flex; flex-direction: column; max-width: 1120px; margin: 0 auto; padding: 18px 16px 28px; }
.landing-top { display: flex; align-items: center; justify-content: space-between; padding: 4px 0 18px; }
.landing-top .brand { font-size: 1.25rem; }
.landing-top .brand-logo { width: 34px; height: 34px; animation: logo-wiggle 4s ease-in-out infinite; }
@keyframes logo-wiggle { 0%, 88%, 100% { transform: none; } 92% { transform: rotate(-10deg); } 96% { transform: rotate(8deg); } }
.landing-hero { flex: 1; display: grid; gap: 28px; align-items: center; grid-template-columns: 1fr; }
@media (min-width: 900px) { .landing-hero { grid-template-columns: 1.1fr .9fr; gap: 48px; } }
.landing-copy h1 { font-size: clamp(1.9rem, 5.5vw, 3.1rem); line-height: 1.08; letter-spacing: -.025em; margin: 0 0 14px; }
.scribble { position: relative; white-space: nowrap; color: #ffd166; }
.scribble::after { content: ""; position: absolute; left: -2%; right: -2%; bottom: -.12em; height: .32em;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 200 14' preserveAspectRatio='none'%3E%3Cpath d='M2 9 C40 2 70 13 105 7 S170 3 198 8' fill='none' stroke='%23ff8fa3' stroke-width='4' stroke-linecap='round'/%3E%3C/svg%3E") no-repeat center / 100% 100%;
  clip-path: inset(0 100% 0 0); animation: underline 1s .5s cubic-bezier(.6,.1,.3,1) forwards; }
@keyframes underline { to { clip-path: inset(0 0 0 0); } }
@media (max-width: 480px) { .scribble { white-space: normal; } }
.landing-copy .lead { font-size: 1.08rem; color: var(--text-2); max-width: 36em; margin: 0 0 16px; }
.install-help { margin-top: 12px; padding: 12px 14px; border-radius: 12px; background: var(--surface); border: 1px solid var(--border); font-size: .9rem; max-width: 30em; animation: rise .3s both; }
.install-help ol { margin: 8px 0 0; padding-left: 20px; display: grid; gap: 4px; }
.kbd { display: inline-block; padding: 0 6px; border-radius: 5px; background: var(--surface-3); border: 1px solid var(--border-strong); font-size: .85em; }
.landing-side { display: grid; justify-items: center; gap: 0; }
.hero-art { width: min(310px, 82%); height: auto; margin-bottom: 22px; position: relative; z-index: 0; overflow: visible; }
.landing-side .auth-card { position: relative; z-index: 1; max-width: 400px; }
.paper-float { animation: float 5s ease-in-out infinite; transform-origin: 150px 150px; }
@keyframes float { 50% { transform: translateY(-8px) rotate(-1.5deg); } }
.hero-art .tick, .hero-art .cross { fill: none; stroke-width: 6; stroke-linecap: round; stroke-linejoin: round;
  stroke-dasharray: 60; stroke-dashoffset: 60; animation: draw 6s ease-in-out infinite; }
.hero-art .tick { stroke: #2fb36a; } .hero-art .cross { stroke: #e66767; }
.hero-art .t1 { animation-delay: .2s; } .hero-art .t2 { animation-delay: .9s; } .hero-art .t3 { animation-delay: 1.6s; } .hero-art .t4 { animation-delay: 2.3s; }
@keyframes draw { 0% { stroke-dashoffset: 60; } 8%, 80% { stroke-dashoffset: 0; } 92%, 100% { stroke-dashoffset: 60; } }
.hero-art .grade-stamp { transform-origin: 232px 236px; animation: stamp 6s ease-in-out infinite; }
@keyframes stamp { 0%, 45% { transform: scale(0); opacity: 0; } 52% { transform: scale(1.25); opacity: 1; } 58%, 82% { transform: scale(1); opacity: 1; } 92%, 100% { transform: scale(0); opacity: 0; } }
.hero-pencil { animation: pencil-path 6s ease-in-out infinite; }
@keyframes pencil-path {
  0% { transform: translate(236px, 86px); } 7% { transform: translate(224px, 104px); }
  14% { transform: translate(236px, 122px); } 21% { transform: translate(224px, 140px); }
  28% { transform: translate(236px, 156px); } 35% { transform: translate(224px, 176px); }
  42% { transform: translate(236px, 196px); } 50% { transform: translate(246px, 212px); }
  80% { transform: translate(250px, 196px) rotate(5deg); } 100% { transform: translate(236px, 86px); }
}
.google-btn { display: flex; justify-content: center; min-height: 44px; }
.or { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: .8rem; margin: 12px 0; }
.or::before, .or::after { content: ""; flex: 1; height: 1px; background: var(--border); }
.landing-foot { text-align: center; padding-top: 24px; }

/* gentle hover life */
.btn-primary { transition: transform .15s, background .15s, box-shadow .2s; }
.btn-primary:hover:not(:disabled) { transform: translateY(-1px); box-shadow: 0 6px 18px -8px rgba(91,141,239,.9); }
.btn-primary:active:not(:disabled) { transform: translateY(1px) scale(.99); }
.action-card .action-icon { transition: transform .3s cubic-bezier(.3,1.6,.5,1); }
.action-card:hover .action-icon { transform: rotate(-8deg) scale(1.08); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001s !important; animation-iteration-count: 1 !important; transition-duration: .001s !important; }
  .hero-art .tick, .hero-art .cross { stroke-dashoffset: 0; }
  .hero-art .grade-stamp { transform: none; opacity: 1; }
}

/* ===================================================================
   SimpleMarker's own vector emojis
   =================================================================== */
.emo { display: inline-block; width: var(--emo, 1.25em); height: var(--emo, 1.25em); vertical-align: -.22em; line-height: 0; flex: none; }
.emo svg { width: 100%; height: 100%; display: block; overflow: visible; }
.emo-wave svg { transform-origin: 70% 85%; animation: wave-hello 2.4s ease-in-out .3s 2; }
@keyframes wave-hello { 0%, 60%, 100% { transform: rotate(0); } 10%, 30% { transform: rotate(16deg); } 20%, 40% { transform: rotate(-10deg); } }
.emo-pop svg { animation: emo-pop .6s cubic-bezier(.3,1.8,.5,1) .4s both; }
@keyframes emo-pop { from { transform: scale(0) rotate(-20deg); } }
.emo-bounce svg { animation: emo-bounce 2.8s ease-in-out infinite; transform-origin: 50% 100%; }
@keyframes emo-bounce { 0%, 70%, 100% { transform: none; } 80% { transform: translateY(-4px) scaleY(1.05); } 90% { transform: scaleY(.94); } }
.counts { display: inline-flex; align-items: center; gap: 3px; }
.counts .emo { margin-right: 4px; }
.confetti i.star { width: 16px; height: 16px; left: -8px; top: -8px; }
.confetti i.star svg { width: 100%; height: 100%; display: block; }

/* ===================================================================
   Landing: animated perks
   =================================================================== */
.perks { list-style: none; padding: 0; margin: 4px 0 12px; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; max-width: 520px; }
.perk { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 6px; font-weight: 650; font-size: .92rem;
  animation: rise .6s cubic-bezier(.3,1.4,.5,1) both; }
.perk:nth-child(2) { animation-delay: .12s; } .perk:nth-child(3) { animation-delay: .24s; }
.perk svg { width: 100%; max-width: 112px; height: auto; overflow: visible; }

/* pencil writes a squiggle, lifts, starts again */
.perk-write .squiggle { stroke-dasharray: 80; stroke-dashoffset: 80; animation: perk-draw 3.2s ease-in-out infinite; }
.perk-write .perk-pencil { animation: perk-pencil 3.2s ease-in-out infinite; }
@keyframes perk-draw { 0% { stroke-dashoffset: 80; } 55%, 85% { stroke-dashoffset: 0; } 100% { stroke-dashoffset: 0; opacity: 0; } }
@keyframes perk-pencil {
  0% { transform: translate(16px, 50px); } 11% { transform: translate(22px, 43px); } 22% { transform: translate(34px, 50px); }
  33% { transform: translate(46px, 43px); } 44% { transform: translate(58px, 50px); } 55% { transform: translate(76px, 50px); }
  70% { transform: translate(80px, 38px) rotate(10deg); } 100% { transform: translate(16px, 50px); }
}

/* dart flies in, target wobbles, little burst */
.perk-grade .dart { animation: perk-dart 3s cubic-bezier(.5,0,.2,1) infinite; }
.perk-grade .target { transform-origin: 40px 38px; animation: perk-target 3s ease-in-out infinite; }
.perk-grade .burst { transform-origin: 40px 38px; animation: perk-burst 3s ease-out infinite; }
@keyframes perk-dart { 0% { transform: translate(34px, -30px); opacity: 0; } 10% { opacity: 1; } 30%, 85% { transform: none; opacity: 1; } 100% { transform: none; opacity: 0; } }
@keyframes perk-target { 0%, 29% { transform: none; } 34% { transform: scale(.9) rotate(-4deg); } 42% { transform: scale(1.04) rotate(3deg); } 50%, 100% { transform: none; } }
@keyframes perk-burst { 0%, 30% { opacity: 0; transform: scale(.6); } 38% { opacity: 1; transform: scale(1); } 60%, 100% { opacity: 0; transform: scale(1.25); } }

/* books drop onto the pile one by one; the top one blinks and a sparkle twinkles */
.perk-revise .bk { animation: perk-book 3.6s cubic-bezier(.3,1.5,.5,1) infinite both; }
.perk-revise .bk1 { animation-delay: 0s; } .perk-revise .bk2 { animation-delay: .25s; } .perk-revise .bk3 { animation-delay: .5s; }
.perk-revise .bk-face { transform-origin: 48px 30px; animation: perk-blink 3.6s infinite; }
.perk-revise .bk-spark { transform-origin: 84px 21px; animation: twinkle 1.8s ease-in-out infinite; }
@keyframes perk-book { 0% { transform: translateY(-40px); opacity: 0; } 12% { opacity: 1; } 22%, 86% { transform: none; opacity: 1; } 100% { transform: translateY(6px); opacity: 0; } }
@keyframes perk-blink { 0%, 60%, 66%, 100% { transform: none; } 63% { transform: scaleY(.15); } }
@media (max-width: 420px) { .perk { font-size: .8rem; } }

/* ===================================================================
   Landing: "Open as app" call to action
   =================================================================== */
.btn-install {
  position: relative; overflow: hidden; display: inline-flex; align-items: center; gap: 12px; margin-top: 12px;
  padding: 10px 18px 10px 12px; border: 0; border-radius: 18px; cursor: pointer; font: inherit; color: #fff; text-align: left;
  background: linear-gradient(120deg, #ff7eb6, #a78bfa 50%, #5b8def); background-size: 180% 100%;
  box-shadow: 0 6px 16px -10px rgba(167,139,250,.55), inset 0 1px 0 rgba(255,255,255,.35);
  transition: transform .2s cubic-bezier(.3,1.6,.5,1), box-shadow .2s, background-position .5s;
  animation: install-nudge 5s ease-in-out 1.5s infinite;
}
.btn-install::after { content: ""; position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(105deg, transparent 35%, rgba(255,255,255,.45) 50%, transparent 65%); background-size: 250% 100%;
  animation: shine 3.5s ease-in-out infinite; }
.btn-install:hover { transform: translateY(-2px) scale(1.02); background-position: 100% 0; box-shadow: 0 8px 20px -10px rgba(255,126,182,.6); }
.btn-install:active { transform: translateY(1px) scale(.98); }
.btn-install:focus-visible { outline: 3px solid #fff; outline-offset: 3px; }
.bi-icon { display: grid; place-items: center; width: 46px; height: 46px; border-radius: 14px; background: rgba(255,255,255,.22); }
.bi-text { display: flex; flex-direction: column; line-height: 1.2; }
.bi-text b { font-size: 1.05rem; }
.bi-text small { font-size: .76rem; opacity: .92; }
.bi-arrow { width: 20px; height: 20px; margin-left: 4px; transition: transform .2s; }
.btn-install:hover .bi-arrow { transform: translateX(4px); }
.emo-ring svg { transform-origin: 50% 90%; animation: phone-ring 3s ease-in-out infinite; }
@keyframes phone-ring { 0%, 70%, 100% { transform: none; } 74%, 82%, 90% { transform: rotate(-12deg); } 78%, 86%, 94% { transform: rotate(12deg); } }
@keyframes install-nudge { 0%, 88%, 100% { transform: none; } 92% { transform: translateY(-3px); } 96% { transform: translateY(1px); } }

/* ===================================================================
   Paper: focus mode
   =================================================================== */
.focus-toggle { display: inline-flex; align-items: center; gap: 6px; font-size: .78rem; font-weight: 650; color: var(--text-2);
  cursor: pointer; user-select: none; padding: 4px 2px; }
.focus-toggle input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.ft-track { position: relative; width: 28px; height: 16px; border-radius: 99px; background: var(--surface-3); border: 1px solid var(--border-strong);
  transition: background .2s, border-color .2s; flex: none; }
.ft-track::after { content: ""; position: absolute; top: 2px; left: 2px; width: 10px; height: 10px; border-radius: 50%; background: var(--muted);
  transition: transform .2s cubic-bezier(.3,1.5,.5,1), background .2s; }
.focus-toggle input:checked + .ft-track { background: var(--accent-soft); border-color: var(--accent); }
.focus-toggle input:checked + .ft-track::after { transform: translateX(12px); background: var(--accent); }
.focus-toggle input:focus-visible + .ft-track { outline: 2px solid var(--accent); outline-offset: 2px; }
.q-row > .card { transition: filter .3s ease, opacity .3s ease, box-shadow .3s ease; }
.paper-body.focus-mode .q-row:not(.in-focus) > .card { filter: blur(.7px); opacity: .82; }
.paper-body.focus-mode .q-row:not(.in-focus):hover > .card { filter: none; opacity: 1; }
.paper-body.focus-mode .q-row.in-focus > .card { box-shadow: 0 0 0 1.5px rgba(255,255,255,.5); }

/* ===================================================================
   Statistics: subject picker
   =================================================================== */
.subject-picker { position: relative; display: inline-flex; align-items: center; gap: 10px; padding: 7px 38px 7px 10px; cursor: pointer;
  border-radius: 14px; background: linear-gradient(135deg, rgba(91,141,239,.2), rgba(167,139,250,.14)); border: 1.5px solid rgba(91,141,239,.75);
  box-shadow: 0 6px 20px -10px rgba(91,141,239,.9); transition: border-color .2s, box-shadow .2s, transform .2s;
  animation: picker-hello 1.6s ease-out .4s 1 both; }
.subject-picker:hover { border-color: #93b4ff; box-shadow: 0 8px 24px -10px rgba(147,180,255,1); transform: translateY(-1px); }
.subject-picker:focus-within { outline: 2px solid var(--accent); outline-offset: 2px; }
.sp-text { display: flex; flex-direction: column; line-height: 1.15; }
.sp-label { font-size: .68rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: #93b4ff; }
.subject-picker select { appearance: none; -webkit-appearance: none; border: 0; background: transparent; color: var(--text);
  font: inherit; font-weight: 700; font-size: 1rem; padding: 0 4px 0 0; cursor: pointer; max-width: 15em; }
.subject-picker select:focus { outline: none; }
.subject-picker select option { background: var(--surface-2); color: var(--text); }
.sp-chev { position: absolute; right: 12px; top: 50%; width: 18px; height: 18px; margin-top: -9px; color: #93b4ff; pointer-events: none; }
@keyframes picker-hello { 0% { box-shadow: 0 0 0 0 rgba(91,141,239,.7); } 100% { box-shadow: 0 0 0 14px rgba(91,141,239,0), 0 6px 20px -10px rgba(91,141,239,.9); } }

/* ===================================================================
   Statistics: revise flashcards
   =================================================================== */
.revise-groups { display: grid; gap: 18px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 290px), 1fr)); align-items: start; }
.revise-group { border-radius: var(--radius); padding: 12px 12px 14px; background: var(--surface); border: 1px solid var(--border); }
.rg-head { display: flex; align-items: center; gap: 8px; font-size: 1rem; }
.rg-dot { width: 11px; height: 11px; border-radius: 50%; background: var(--bad); box-shadow: 0 0 0 4px var(--bad-soft); }
.rg-work .rg-dot { background: var(--warn); box-shadow: 0 0 0 4px var(--warn-soft); }
.rg-technique .rg-dot { background: #9aa3b5; box-shadow: 0 0 0 4px rgba(154,163,181,.18); }
.rg-count { margin-left: auto; font-size: .78rem; font-weight: 750; color: var(--text-2); background: var(--surface-3); border-radius: 99px; padding: 1px 9px; }
.rg-blurb { margin: 4px 0 12px; font-size: .8rem; color: var(--muted); }
.rg-cards { display: grid; gap: 16px; padding-top: 6px; }
.rg-toggle { margin-top: 10px; width: 100%; }

.flashcard { --line: rgba(91,141,239,.16); --band: #e66767;
  position: relative; padding: 16px 16px 12px; border-radius: 6px; color: #2b2f3a; transform: rotate(var(--tilt, 0deg));
  background:
    linear-gradient(var(--band), var(--band)) top / 100% 5px no-repeat,
    repeating-linear-gradient(#fffdf7 0 23px, var(--line) 23px 24px) 0 32px / 100% calc(100% - 32px) no-repeat,
    #fffdf7;
  box-shadow: 0 1px 0 rgba(0,0,0,.05), 0 10px 22px -14px rgba(0,0,0,.65);
  transition: transform .25s cubic-bezier(.3,1.5,.5,1), box-shadow .25s; animation: rise .45s cubic-bezier(.3,1.3,.5,1) both; }
.flashcard:hover { transform: rotate(0deg) translateY(-3px); box-shadow: 0 1px 0 rgba(0,0,0,.05), 0 16px 28px -14px rgba(0,0,0,.75); }
.fc-work { --band: #f2b134; }
.fc-technique { --band: #9aa3b5; }
.fc-tape { position: absolute; top: -9px; left: 50%; width: 64px; height: 18px; transform: translateX(-50%) rotate(-3deg);
  background: rgba(255,255,255,.55); border: 1px solid rgba(255,255,255,.6); box-shadow: 0 1px 2px rgba(0,0,0,.12); backdrop-filter: blur(1px); }
.fc-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: .72rem; font-weight: 750;
  color: #7a8194; text-transform: uppercase; letter-spacing: .05em; }
.fc-score { font-size: .82rem; letter-spacing: 0; color: #c24848; background: rgba(230,103,103,.12); border-radius: 99px; padding: 0 8px; }
.fc-work .fc-score { color: #a26a06; background: rgba(242,177,52,.18); }
.fc-technique .fc-score { color: #5b6273; background: rgba(154,163,181,.2); }
.fc-name { margin: 7px 0 2px; font-size: 1.04rem; line-height: 24px; color: #1d2130; overflow-wrap: anywhere; }
.fc-path { font-size: .76rem; line-height: 24px; color: #7a8194; overflow-wrap: anywhere; }
.fc-tip { font-size: .8rem; line-height: 24px; color: #4b5263; font-style: italic; }
.fc-foot { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px; margin-top: 4px;
  font-size: .78rem; line-height: 24px; color: #4b5263; }
.fc-ref { color: #9aa1b2; font-variant-numeric: tabular-nums; }
.flashcard .q-links a { background: rgba(91,141,239,.14); color: #3157b8; }
.flashcard .q-links a:hover { background: rgba(91,141,239,.26); }

/* ===================================================================
   Landing on phones: a clear hero panel, then the login card
   (desktop and tablet layouts are untouched)
   =================================================================== */
@media (max-width: 599px) {
  .landing { padding: 14px 14px 26px; }
  .landing-top { justify-content: center; padding-bottom: 12px; }
  .landing-hero { flex: none; gap: 18px; align-content: start; }
  .landing-side { display: contents; }
  .landing-copy { order: 1; position: relative; text-align: center; padding: 58px 18px 20px; border-radius: 26px;
    background: radial-gradient(120% 70% at 50% 0%, rgba(139,92,246,.28), transparent 70%), linear-gradient(180deg, rgba(91,141,239,.14), rgba(22,25,32,.6));
    border: 1px solid rgba(139,92,246,.3); box-shadow: 0 20px 40px -24px rgba(91,141,239,.6); }
  .hero-art { order: 0; position: relative; z-index: 2; width: 172px; margin: 0 auto -62px; filter: drop-shadow(0 12px 18px rgba(0,0,0,.35)); }
  .landing-copy h1 { font-size: 1.85rem; margin-top: 0; }
  .landing-copy .lead { font-size: .98rem; margin: 0 auto 16px; }
  .perks { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin: 0 0 10px; max-width: none; }
  .perk { padding: 10px 4px 9px; border-radius: 16px; background: rgba(14,16,20,.45); border: 1px solid var(--border); font-size: .76rem; line-height: 1.2; }
  .perk svg { max-width: 74px; }
  .landing-copy > .small.muted { margin: 4px 0 0; }
  .btn-install { width: 100%; justify-content: flex-start; margin-top: 14px; }
  .bi-arrow { margin-left: auto; }
  .install-help { text-align: left; }
  .landing-side .auth-card { order: 2; max-width: none; padding-top: 18px; }
  .landing-side .auth-card::before { content: "Get started"; display: block; font-weight: 800; font-size: 1.15rem; margin: 0 0 12px; }
  .landing-foot { order: 3; padding-top: 18px; }
}


/* ===================================================================
   Revise these next: one section per group, each on its own rows
   =================================================================== */
.rv-section + .rv-section { margin-top: 22px; }
.rv-title { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; font-size: 1.02rem; margin-bottom: 12px; }
.rv-blurb { flex-basis: 100%; font-size: .8rem; color: var(--text-2); margin-left: 21px; }
@media (min-width: 720px) { .rv-blurb { flex-basis: auto; margin-left: 4px; } .rv-blurb::before { content: "- "; color: var(--muted); } }
.rv-cards { display: grid; gap: 18px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 270px), 1fr)); align-items: start; padding-top: 6px; }
.rv-work .rg-dot { background: var(--warn); box-shadow: 0 0 0 4px var(--warn-soft); }
.rv-technique .rg-dot { background: #9aa3b5; box-shadow: 0 0 0 4px rgba(154,163,181,.18); }
.rv-title .rg-count { margin-left: 0; }

/* Revise these next: a card like the rest of the page, groups as divided sub-sections */
.revise-panel.card { padding-bottom: 20px; }
.revise-panel.card > .card-title { margin-bottom: 4px; }
.revise-panel .rv-section { margin-top: 0; padding-top: 16px; }
.revise-panel .rv-section + .rv-section { margin-top: 20px; border-top: 1px solid var(--border); }
.revise-panel .rv-title { font-size: .95rem; margin-bottom: 10px; }
.revise-panel .rv-title b { font-weight: 750; }
.revise-panel .rv-cards { padding: 8px 4px 2px; }
