/* OpSync Grader demo. Phone first; min-width queries add the tablet and desktop layouts.
   --accent is the TEACHER's colour (Customise), never OpSync's. */

:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --ink: #0f1720;
  --ink-2: #47515e;
  --ink-3: #7b8592;
  --line: #e4e8ee;
  --accent: #1f6feb;
  --accent-soft: color-mix(in srgb, var(--accent) 12%, white);
  --good: #12805c;
  --good-soft: #e6f4ee;
  --warn: #b25e00;
  --warn-soft: #fdf1e2;
  --bad: #c2362b;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 1px 2px rgba(15, 23, 32, .05), 0 6px 20px -10px rgba(15, 23, 32, .14);
  --ease: cubic-bezier(.2, .7, .2, 1);
  --display: 'Space Grotesk', system-ui, sans-serif;
  --text: 'Inter', system-ui, sans-serif;
  --nav-h: 64px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 400 15px/1.5 var(--text); }
[hidden] { display: none !important; }
h1, h2, h3 { font-family: var(--display); letter-spacing: -.01em; margin: 0; }
button, input, select { font: inherit; color: inherit; }
a { color: inherit; }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--accent) 55%, white); outline-offset: 2px; border-radius: 6px; }
.num { font-family: var(--display); font-variant-numeric: tabular-nums; }

/* Buttons and fields */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 0 18px;
  border-radius: 11px; border: 1px solid var(--line); background: var(--surface); font-weight: 600; text-decoration: none; cursor: pointer;
  transition: transform .15s var(--ease), background .2s var(--ease), border-color .2s var(--ease); }
.btn:active { transform: scale(.98); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: color-mix(in srgb, var(--accent) 88%, black); }
.btn-sm { min-height: 38px; padding: 0 14px; font-size: 14px; }
.btn-ghost { background: transparent; }
.btn-block { width: 100%; }
.field { display: grid; gap: 6px; font-size: 14px; color: var(--ink-2); }
.field input, .field select, .input { min-height: 44px; border: 1px solid var(--line); border-radius: 11px; padding: 0 12px; background: var(--surface); font-size: 16px; color: var(--ink); }

/* Gate */
.gate { min-height: 100dvh; display: grid; place-items: center; padding: 16px; }
.gate-card { width: min(380px, 100%); background: var(--surface); border-radius: 20px; padding: 28px 22px; box-shadow: var(--shadow); display: grid; gap: 14px; }
.gate-card h1 { font-size: 26px; }
.gate-card p { margin: 0; color: var(--ink-2); }
.brand-mark { width: 44px; height: 44px; border-radius: 12px; background: var(--accent); color: #fff; display: grid; place-items: center; font: 700 22px var(--display); }

/* Shell */
.app { min-height: 100dvh; padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom)); }
.topbar { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 16px; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: saturate(1.4) blur(10px); border-bottom: 1px solid var(--line); }
.who { display: flex; align-items: center; gap: 10px; text-decoration: none; min-width: 0; }
.logo { width: 38px; height: 38px; flex: none; border-radius: 11px; background: var(--accent) center/cover no-repeat; color: #fff; display: grid; place-items: center; font: 700 17px var(--display); }
.who-text { display: grid; line-height: 1.2; min-width: 0; }
.who-text strong { font-family: var(--display); font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.who-text small { color: var(--ink-3); font-size: 12.5px; }
.top-cta { display: none; }

.nav { position: fixed; z-index: 6; inset: auto 0 0 0; height: calc(var(--nav-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
  display: grid; grid-template-columns: repeat(6, 1fr); background: var(--surface); border-top: 1px solid var(--line); }
.nav a { position: relative; display: grid; place-items: center; align-content: center; gap: 3px; text-decoration: none; color: var(--ink-3); font-size: 10.5px; font-weight: 500; }
.nav svg { width: 22px; height: 22px; fill: currentColor; }
.nav a[aria-current="page"] { color: var(--accent); }
.nav .badge { position: absolute; top: 7px; left: calc(50% + 6px); min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--warn); color: #fff; font: 600 11px/18px var(--text); }
.nav .badge:empty { display: none; }

.view { padding: 18px 16px 28px; max-width: 1180px; margin: 0 auto; outline: none; }
.demo-note { text-align: center; color: var(--ink-3); font-size: 12px; padding: 0 16px 20px; }

.page-head { display: flex; flex-wrap: wrap; align-items: end; justify-content: space-between; gap: 10px; margin-bottom: 16px; }
.page-head h1 { font-size: clamp(24px, 6vw, 34px); }
.page-head p { margin: 4px 0 0; color: var(--ink-2); }
.eyebrow { font-size: 12px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-3); }

/* Cards and grids */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; min-width: 0; }
.card h2 { font-size: 17px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.card-head small { color: var(--ink-3); }
.stack { display: grid; gap: 14px; }
.kpis { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.kpi { padding: 14px; }
.kpi .label { color: var(--ink-2); font-size: 13px; }
.kpi .value { font: 700 clamp(26px, 7vw, 34px)/1.1 var(--display); margin-top: 6px; font-variant-numeric: tabular-nums; }
.kpi .sub { font-size: 12.5px; color: var(--ink-3); margin-top: 4px; }
.kpi.accent { background: var(--accent); border-color: var(--accent); color: #fff; }
.kpi.accent .label, .kpi.accent .sub { color: rgba(255, 255, 255, .82); }
.kpi.warn .value { color: var(--warn); }

.chips { display: flex; gap: 8px; overflow-x: auto; scroll-snap-type: x mandatory; padding-bottom: 2px; }
.chip { flex: none; scroll-snap-align: start; min-height: 38px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); font-weight: 500; font-size: 14px; cursor: pointer; }
.chip[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: #fff; }
.tag { display: inline-flex; align-items: center; gap: 5px; height: 24px; padding: 0 9px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.tag.good { background: var(--good-soft); color: var(--good); }
.tag.warn { background: var(--warn-soft); color: var(--warn); }
.tag.muted { background: #eef1f5; color: var(--ink-2); }

/* Charts */
.chart { width: 100%; height: auto; display: block; overflow: visible; }
.chart .grid line { stroke: var(--line); }
.chart text { fill: var(--ink-3); font: 500 11px var(--text); }
.chart .line { fill: none; stroke: var(--accent); stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round; }
.chart .area { fill: url(#fade); }
.chart .dot { fill: var(--surface); stroke: var(--accent); stroke-width: 2; }
.spark { width: 84px; height: 26px; flex: none; }
.spark path { fill: none; stroke: var(--accent); stroke-width: 2; stroke-linecap: round; }
.spark.down path { stroke: var(--warn); }
.bars { display: grid; gap: 10px; }
.bar-row { display: grid; grid-template-columns: 74px 1fr 46px; align-items: center; gap: 10px; font-size: 14px; }
.bar-track { height: 10px; border-radius: 6px; background: #eef1f5; overflow: hidden; }
.bar-fill { height: 100%; border-radius: 6px; background: var(--accent); transform-origin: left; animation: grow .8s var(--ease) both; }
@keyframes grow { from { transform: scaleX(0); } }

.heat { display: grid; grid-template-columns: repeat(auto-fit, minmax(58px, 1fr)); gap: 8px; }
.heat-cell { border-radius: 12px; padding: 12px 8px; text-align: center; color: #fff; }
.heat-cell b { display: block; font: 700 20px var(--display); }
.heat-cell span { font-size: 12px; opacity: .9; }
.callout { display: flex; gap: 12px; align-items: flex-start; border-radius: var(--radius); padding: 14px; background: var(--warn-soft); color: #6b3a00; }
.callout strong { font-family: var(--display); }

/* Lists */
.list { display: grid; }
.row { display: flex; align-items: center; gap: 12px; padding: 12px 2px; border-bottom: 1px solid var(--line); text-decoration: none; min-height: 56px; }
.row:last-child { border-bottom: 0; }
.row .grow { flex: 1; min-width: 0; }
.row .grow strong { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .grow small { color: var(--ink-3); }
.row button.row-btn { all: unset; display: contents; cursor: pointer; }
.avatar { width: 38px; height: 38px; flex: none; border-radius: 50%; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; font: 600 14px var(--display); }
.score { font: 700 17px var(--display); font-variant-numeric: tabular-nums; text-align: end; min-width: 52px; }
.tbl-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: start; padding: 10px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { color: var(--ink-3); font-weight: 600; font-size: 12.5px; }
td.r, th.r { text-align: end; font-variant-numeric: tabular-nums; }

/* Review */
.review-card { display: grid; gap: 12px; }
.scribble { height: 92px; border-radius: 10px; background:
  repeating-linear-gradient(0deg, transparent 0 22px, #dfe7f3 22px 23px), #fbfcfe; display: grid; place-items: center;
  font: italic 500 26px/1 'Segoe Print', 'Bradley Hand', cursive; color: #2f3e57; filter: blur(.6px); letter-spacing: .02em; }
.review-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.review-actions .input { flex: 1; min-width: 140px; }
.resolved { opacity: .55; }

/* Customise */
.swatches { display: flex; gap: 10px; flex-wrap: wrap; }
.swatch { width: 44px; height: 44px; border-radius: 50%; border: 3px solid transparent; cursor: pointer; }
.swatch[aria-pressed="true"] { border-color: var(--ink); }
.panel-row { display: flex; align-items: center; gap: 8px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.panel-row span { flex: 1; }
.icon-btn { width: 44px; height: 44px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); cursor: pointer; display: grid; place-items: center; }
.switch { position: relative; width: 50px; height: 30px; flex: none; }
.switch input { position: absolute; inset: 0; opacity: 0; cursor: pointer; margin: 0; }
.switch i { position: absolute; inset: 0; border-radius: 99px; background: #d5dbe3; transition: background .2s var(--ease); pointer-events: none; }
.switch i::after { content: ''; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.2); transition: transform .2s var(--ease); }
.switch input:checked + i { background: var(--accent); }
.switch input:checked + i::after { transform: translateX(20px); }

/* Live grade */
.drop { display: grid; gap: 12px; padding: 22px 16px; border: 2px dashed color-mix(in srgb, var(--accent) 40%, var(--line)); border-radius: 18px; background: var(--accent-soft); text-align: center; }
.drop p { margin: 0; color: var(--ink-2); }
.pickers { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.pickers .field:first-child { grid-column: 1 / -1; }
.scan { position: relative; border-radius: 16px; overflow: hidden; background: #111; max-height: 62vh; display: grid; place-items: center; }
.scan img { width: 100%; max-height: 62vh; object-fit: contain; display: block; opacity: .9; }
.scan .beam { position: absolute; inset-inline: 0; top: 0; height: 26%; background: linear-gradient(180deg, transparent, color-mix(in srgb, var(--accent) 55%, transparent) 85%, rgba(255,255,255,.9) 100%);
  mix-blend-mode: screen; animation: beam 2.2s var(--ease) infinite; }
@keyframes beam { from { transform: translateY(-100%); } to { transform: translateY(400%); } }
.scan .status { position: absolute; inset: auto 12px 12px 12px; background: rgba(15, 23, 32, .78); color: #fff; border-radius: 12px; padding: 10px 12px; font-size: 14px; display: flex; align-items: center; gap: 10px; }
.spinner { width: 16px; height: 16px; border-radius: 50%; border: 2px solid rgba(255,255,255,.35); border-top-color: #fff; animation: spin .8s linear infinite; flex: none; }
@keyframes spin { to { transform: rotate(360deg); } }

.result-hero { display: grid; gap: 14px; }
.total { display: flex; align-items: baseline; gap: 10px; }
.total .big { font: 700 clamp(46px, 14vw, 72px)/1 var(--display); font-variant-numeric: tabular-nums; }
.total .of { font: 600 22px var(--display); color: var(--ink-3); }
.ring { --p: 0; width: 76px; height: 76px; border-radius: 50%; flex: none; background: conic-gradient(var(--accent) calc(var(--p) * 1%), #eef1f5 0); display: grid; place-items: center; }
.ring span { width: 58px; height: 58px; border-radius: 50%; background: var(--surface); display: grid; place-items: center; font: 700 17px var(--display); }
.match { display: flex; gap: 10px; align-items: center; padding: 12px 14px; border-radius: 12px; font-weight: 500; }
.match.ok { background: var(--good-soft); color: var(--good); }
.match.warn { background: var(--warn-soft); color: var(--warn); }
.banner-warn { padding: 12px 14px; border-radius: 12px; background: var(--warn-soft); color: var(--warn); font-weight: 600; }
.q-card { border-inline-start: 4px solid var(--line); }
.q-card.full { border-inline-start-color: var(--good); }
.q-card.part { border-inline-start-color: var(--accent); }
.q-card.check { border-inline-start-color: var(--warn); }
.q-card .q-title { font-weight: 600; }
.q-card .q-prompt { color: var(--ink-2); font-size: 14px; margin: 2px 0 10px; }
.step { display: grid; gap: 4px; padding: 10px 0; border-top: 1px solid var(--line); }
.step-top { display: flex; justify-content: space-between; gap: 10px; align-items: start; }
.wrote { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13.5px; background: #f3f5f8; border-radius: 8px; padding: 6px 8px; overflow-wrap: anywhere; }
.model-step { font-size: 13px; color: var(--ink-3); }
.reason { font-size: 13.5px; color: var(--ink-2); }
.marks { flex: none; min-width: 46px; height: 28px; padding: 0 8px; border-radius: 8px; display: grid; place-items: center; font: 700 14px var(--display); }
.marks.full { background: var(--good-soft); color: var(--good); }
.marks.part { background: var(--accent-soft); color: var(--accent); }
.marks.zero { background: #fdeceb; color: var(--bad); }
.message { background: #e7f8ee; border-radius: 16px 16px 16px 4px; padding: 14px; font-size: 14.5px; white-space: pre-line; max-width: 420px; }
.message-meta { font-size: 12px; color: var(--ink-3); }
.sample-label { display: inline-block; font-size: 12px; font-weight: 600; color: var(--ink-3); background: #eef1f5; border-radius: 6px; padding: 3px 8px; }
.reveal { animation: rise .5s var(--ease) both; }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } }

/* Tablet and up */
@media (min-width: 720px) {
  .kpis { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .two { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 14px; align-items: start; }
  .pickers { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .pickers .field:first-child { grid-column: auto; }
  .top-cta { display: inline-flex; }
}

/* Desktop: side rail */
@media (min-width: 1000px) {
  .app { padding-bottom: 0; padding-inline-start: 232px; }
  .nav { inset: 0 auto 0 0; width: 232px; height: 100dvh; grid-template-columns: none; grid-auto-rows: 48px; align-content: start;
    padding: 84px 12px 12px; border-top: 0; border-inline-end: 1px solid var(--line); gap: 2px; }
  .nav a { grid-auto-flow: column; justify-content: start; gap: 12px; padding: 0 12px; border-radius: 10px; font-size: 14.5px; }
  .nav a:hover { background: #f1f4f8; }
  .nav a[aria-current="page"] { background: var(--accent-soft); }
  .nav .badge { position: static; margin-inline-start: auto; }
  .topbar { padding-inline: 24px; }
  .view { padding: 26px 28px 36px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
  .scan .beam { display: none; }
}

/* Phone fit fixes (measured at 375 px): rows drop the sparkline, fields shrink to their column. */
.field { min-width: 0; }
.field select, .field input { width: 100%; min-width: 0; }
.row .spark { display: none; }
@media (min-width: 480px) { .row .spark { display: block; } }
