/* Scorely: styled like an exam answer sheet.
   Selected = highlighter. Choices = fillable bubbles. Questions = printed serif. */

:root {
  --paper: #F1F3F9;
  --card: #FFFFFF;
  --ink: #12172B;
  --ink-soft: #4A5170;
  --line: #D3D8E8;
  --hi: #FFE14D;
  --hi-soft: #FFF3A8;
  --ok: #12703F;
  --ok-bg: #DDF3E6;
  --bad: #A8231B;
  --bad-bg: #FBE1DE;
  --display: "Bricolage Grotesque", system-ui, "Segoe UI", sans-serif;
  --serif: "Source Serif 4", Georgia, "Times New Roman", serif;
  --mono: "JetBrains Mono", ui-monospace, Consolas, "Courier New", monospace;
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--display);
  font-size: 1.0625rem;
  line-height: 1.55;
  font-optical-sizing: auto;
}

#app:focus { outline: none; }
:focus-visible { outline: 3px solid var(--ink); outline-offset: 3px; }

.skip {
  position: absolute; left: -999px; top: 0;
  background: var(--ink); color: var(--paper); padding: .6rem 1rem; z-index: 20;
}
.skip:focus { left: 0; }

.wrap { width: min(100% - 2rem, 1080px); margin-inline: auto; }
.narrow { width: min(100% - 2rem, 760px); }

/* ---------- top bar and brand ---------- */
.topbar { display: flex; justify-content: space-between; align-items: center; padding: 1.25rem 0; }
.brand {
  display: inline-flex; align-items: center; gap: .7rem;
  font-weight: 800; font-size: 1.3rem; letter-spacing: -.02em; color: var(--ink);
}
.mark {
  width: 2rem; height: 2rem; border-radius: 22%; flex: none;
  background: url(/icon.svg) center / cover no-repeat;
}

/* ---------- type ---------- */
.display {
  font-weight: 800; letter-spacing: -.035em; line-height: 1.04; margin: 0;
  font-size: clamp(2.4rem, 6.2vw, 4.6rem); text-wrap: balance;
}
.display-sm { font-size: clamp(2rem, 4.5vw, 3rem); }
.lede { font-size: 1.2rem; color: var(--ink-soft); max-width: 34rem; margin: 1.1rem 0 0; }
.note { color: var(--ink-soft); font-size: .95rem; max-width: 34rem; }
.error { color: var(--bad); font-weight: 600; margin: .9rem 0 0; min-height: 1.5em; }

/* ---------- home ---------- */
.hero { display: grid; gap: 3rem; align-items: center; padding: clamp(1.5rem, 5vw, 4rem) 0 2.5rem; }
@media (min-width: 880px) { .hero { grid-template-columns: 1.3fr .7fr; } }

.sheet {
  background: var(--card); border: 2px solid var(--ink); border-radius: 22px;
  padding: 1.3rem 1.5rem; display: grid; gap: .75rem; width: min(100%, 19rem);
  justify-self: start; transform: rotate(1.5deg);
}
@media (min-width: 880px) { .sheet { justify-self: end; } }
.sheet-row { display: grid; grid-template-columns: 1.4rem repeat(4, 1fr); align-items: center; justify-items: center; gap: .5rem; font-weight: 700; color: var(--ink-soft); }
.sheet-row > :first-child { justify-self: start; }
.sheet-head { color: var(--ink); }

.bubble {
  display: inline-grid; place-items: center; flex: none;
  width: 2rem; height: 2rem; border-radius: 50%; border: 2px solid var(--ink);
  font-weight: 700; font-size: .9rem; line-height: 1; color: var(--ink);
  transition: background-color .15s, color .15s;
}
.sheet .bubble { width: 1.75rem; height: 1.75rem; }
.sheet .bubble.on { background: var(--ink); }

@media (prefers-reduced-motion: no-preference) {
  .sheet .bubble.on { animation: fill .45s ease-out both; animation-delay: calc(var(--i) * .22s + .35s); }
  @keyframes fill { from { background-color: transparent; } to { background-color: var(--ink); } }
}

.setup { max-width: 720px; padding-bottom: 4rem; }
.group { border: 0; margin: 0 0 2.4rem; padding: 0; min-inline-size: 0; }
.group-title { font-weight: 700; font-size: 1.35rem; letter-spacing: -.01em; margin: 0 0 .9rem; padding: 0; }

.track {
  position: relative; display: flex; align-items: center; gap: 1rem;
  padding: 1rem 1.1rem; margin-bottom: .6rem; cursor: pointer;
  border: 2px solid var(--line); border-radius: 14px; background: var(--card);
  font-weight: 600; font-size: 1.1rem;
}
.track input { position: absolute; opacity: 0; pointer-events: none; }
.track .bubble { width: 1.6rem; height: 1.6rem; }
.track-name { flex: 1; }
.track-state { font-weight: 500; color: var(--ink-soft); font-size: .95rem; }
.track:hover { border-color: var(--ink); }
.track:has(input:checked) { border-color: var(--ink); background: var(--hi-soft); }
.track input:checked + .bubble { background: var(--ink); }
.track:has(input:focus-visible) { outline: 3px solid var(--ink); outline-offset: 3px; }
.track.is-off { color: var(--ink-soft); background: transparent; border-style: dashed; cursor: not-allowed; }
.track.is-off:hover { border-color: var(--line); }

.chips { display: flex; flex-wrap: wrap; gap: .6rem; }
.chip { position: relative; }
.chip input { position: absolute; opacity: 0; pointer-events: none; }
.chip span {
  display: inline-block; padding: .6rem 1.1rem; cursor: pointer;
  border: 2px solid var(--line); border-radius: 999px; background: var(--card); font-weight: 600;
}
.chip span:hover { border-color: var(--ink); }
.chip input:checked + span { background: var(--hi); border-color: var(--ink); }
.chip input:focus-visible + span { outline: 3px solid var(--ink); outline-offset: 3px; }

/* ---------- buttons ---------- */
.btn {
  font: inherit; font-weight: 700; cursor: pointer;
  border: 2px solid var(--ink); border-radius: 999px; padding: .85rem 1.7rem;
  transition: background-color .12s;
}
.btn-primary { background: var(--ink); color: var(--paper); }
.btn-primary:hover:not(:disabled) { background: #272f55; }
.btn-ghost { background: transparent; color: var(--ink); }
.btn-ghost:hover:not(:disabled) { background: var(--hi-soft); }
.btn-sm { padding: .45rem 1.1rem; font-size: .95rem; }
.btn:disabled { opacity: .45; cursor: not-allowed; }

/* ---------- test ---------- */
.test-head { position: sticky; top: 0; z-index: 5; background: var(--paper); border-bottom: 2px solid var(--ink); }
.test-head-inner { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .8rem 0; }
.test-tools { display: flex; align-items: center; gap: 1rem; }
.timer { font-variant-numeric: tabular-nums; font-weight: 800; font-size: 1.2rem; }
.timer.is-low { color: var(--bad); }
.timer-wrap { color: var(--ink-soft); font-weight: 500; white-space: nowrap; }
.btn-sm { white-space: nowrap; }
@media (max-width: 520px) {
  .test-head .brand-text { display: none; } /* keep the bubble mark, give the timer room */
  .test-tools { gap: .7rem; }
}

.strip { display: flex; gap: 3px; list-style: none; margin: 0; padding: 0 0 .85rem; }
.strip li { flex: 1; min-width: 0; }
.seg { display: block; width: 100%; height: 10px; border: 0; border-radius: 3px; background: var(--line); cursor: pointer; padding: 0; }
.seg.is-done { background: var(--ink); }
.seg.is-current { background: var(--hi); outline: 2px solid var(--ink); outline-offset: 2px; }
.seg.is-current.is-done { background: var(--ink); }

.q { padding: clamp(1.5rem, 4vw, 3rem) 0 1rem; }
.q-meta { display: flex; flex-wrap: wrap; gap: .4rem 1.1rem; align-items: baseline; color: var(--ink-soft); font-weight: 600; }
.q-section { color: var(--ink); font-weight: 800; font-size: 1.1rem; }
.stem {
  font-family: var(--serif); font-weight: 500; line-height: 1.42; letter-spacing: -.005em;
  font-size: clamp(1.35rem, 3vw, 1.75rem); margin: .7rem 0 1.6rem; max-width: 42rem; overflow-wrap: anywhere;
}
.stem:focus { outline: none; }

.opts { display: grid; gap: .7rem; }
.opt {
  position: relative; display: flex; gap: 1rem; align-items: flex-start; cursor: pointer;
  padding: .95rem 1.1rem; border: 2px solid var(--line); border-radius: 14px; background: var(--card);
}
.opt input { position: absolute; opacity: 0; pointer-events: none; }
.opt:hover { border-color: var(--ink); }
.opt:has(input:checked) { background: var(--hi-soft); border-color: var(--ink); }
.opt input:checked + .bubble { background: var(--ink); color: var(--paper); }
.opt:has(input:focus-visible) { outline: 3px solid var(--ink); outline-offset: 3px; }
.opt-text { padding-top: .22rem; font-size: 1.05rem; overflow-wrap: anywhere; }

.examples { margin: 0 0 1rem; padding: 0; list-style: none; display: grid; gap: .45rem; }
.examples li {
  font-family: var(--mono); font-size: .86rem; background: var(--card);
  border: 2px solid var(--line); border-radius: 10px; padding: .55rem .8rem; overflow-x: auto; white-space: nowrap;
}
.code {
  display: block; width: 100%; min-height: 16rem; resize: vertical;
  font-family: var(--mono); font-size: .92rem; line-height: 1.65; tab-size: 4;
  background: #0F1430; color: #E8ECFF; caret-color: var(--hi);
  border: 2px solid var(--ink); border-radius: 12px; padding: 1rem 1.1rem;
}
.code:focus-visible { outline: 3px solid var(--hi); outline-offset: 2px; }
.hint { color: var(--ink-soft); font-size: .92rem; margin: .65rem 0 0; }

.nav { display: flex; justify-content: space-between; gap: 1rem; padding: 1.5rem 0 3rem; }

.dlg { border: 2px solid var(--ink); border-radius: 20px; padding: 1.6rem; max-width: 26rem; background: var(--card); color: var(--ink); font-family: var(--display); }
.dlg::backdrop { background: rgba(18, 23, 43, .55); }
.dlg h2 { margin: 0 0 .5rem; font-size: 1.4rem; letter-spacing: -.01em; }
.dlg p { margin: 0; color: var(--ink-soft); }
.dlg-actions { display: flex; flex-wrap: wrap; gap: .75rem; justify-content: flex-end; margin-top: 1.4rem; }

/* ---------- locked results ---------- */
.lock { padding: clamp(1.5rem, 5vw, 3.5rem) 0 4rem; }
.veil { position: relative; margin: 2rem 0 1.6rem; max-width: 34rem; overflow: hidden; background: var(--card); border: 2px solid var(--ink); border-radius: 22px; padding: 1.6rem; }
.veil-inner { filter: blur(13px); user-select: none; }
.veil-big { font-weight: 800; font-size: 4.5rem; line-height: 1; letter-spacing: -.05em; }
.veil-line { height: 12px; border-radius: 999px; background: var(--line); margin-top: 1rem; overflow: hidden; }
.veil-line span { display: block; height: 100%; background: var(--ink); }
.veil-lock { position: absolute; inset: 0; display: grid; place-items: center; }
.veil-lock svg {
  width: 4.4rem; height: 4.4rem; padding: .95rem;
  background: var(--paper); border: 2px solid var(--ink); border-radius: 50%;
}
.lock-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 1rem 1.4rem; }
.price { color: var(--ink-soft); }

/* ---------- results ---------- */
.score { display: flex; flex-wrap: wrap; align-items: flex-end; gap: .5rem 2rem; margin: 1.4rem 0 .4rem; }
.big { font-weight: 800; font-size: clamp(4.5rem, 15vw, 8.5rem); line-height: .88; letter-spacing: -.055em; margin: 0; }
.score-copy { margin: 0 0 .4rem; max-width: 28rem; color: var(--ink-soft); font-size: 1.1rem; }

.sec-title { font-weight: 700; font-size: 1.5rem; letter-spacing: -.01em; margin: 2.6rem 0 1rem; }
.bars { display: grid; gap: 1rem; }
.bar-row { display: grid; grid-template-columns: 9rem 1fr 5rem; align-items: center; gap: 1rem; font-weight: 600; }
.bar-row .count { text-align: right; color: var(--ink-soft); font-variant-numeric: tabular-nums; }
@media (max-width: 560px) {
  .bar-row { grid-template-columns: 1fr auto; }
  .bar-row progress { grid-column: 1 / -1; grid-row: 2; }
}
progress { appearance: none; -webkit-appearance: none; height: 12px; width: 100%; border: 0; border-radius: 999px; background: var(--line); overflow: hidden; }
progress::-webkit-progress-bar { background: var(--line); border-radius: 999px; }
progress::-webkit-progress-value { background: var(--ink); border-radius: 999px; }
progress::-moz-progress-bar { background: var(--ink); border-radius: 999px; }

.review-tools { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; }
.toggle { display: inline-flex; align-items: center; gap: .6rem; font-weight: 600; cursor: pointer; }
.toggle input { width: 1.2rem; height: 1.2rem; accent-color: var(--ink); }

.rev { background: var(--card); border: 2px solid var(--line); border-radius: 16px; padding: 1.2rem 1.3rem; margin-bottom: .9rem; }
.rev-top { display: flex; flex-wrap: wrap; gap: .5rem 1rem; align-items: center; color: var(--ink-soft); font-weight: 600; }
.rev .stem { font-size: 1.2rem; margin: .6rem 0 .8rem; }
.rev p { margin: .3rem 0; overflow-wrap: anywhere; }
.pill { display: inline-block; font-weight: 700; font-size: .9rem; padding: .15rem .75rem; border-radius: 999px; }
.pill-ok { background: var(--ok-bg); color: var(--ok); }
.pill-bad { background: var(--bad-bg); color: var(--bad); }
.pill-skip { background: var(--line); color: var(--ink); }
.why { border-left: 4px solid var(--hi); padding-left: .9rem; margin: .9rem 0 0 !important; }
.err { font-family: var(--mono); font-size: .85rem; background: var(--bad-bg); color: var(--bad); border-radius: 8px; padding: .5rem .7rem; overflow-x: auto; }
.results-actions { display: flex; flex-wrap: wrap; gap: 1rem; padding: 1.6rem 0 4rem; }

/* accounts */
.acct { display: flex; align-items: center; gap: .4rem; min-width: 0; }
.nav-link { font: inherit; font-weight: 600; background: none; border: 0; padding: .45rem .8rem; border-radius: 999px; color: var(--ink); cursor: pointer; }
.nav-link:hover { background: var(--hi-soft); }
.nav-name { max-width: 11rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.panel { background: var(--card); border: 2px solid var(--ink); border-radius: 20px; padding: 1.4rem 1.5rem; max-width: 34rem; margin: 0 0 1.4rem; }
.panel-title { margin: 0 0 .5rem; font-size: 1.3rem; letter-spacing: -.01em; }
.auth-form { display: grid; gap: 1rem; margin-top: 1.1rem; }
.field { display: grid; gap: .3rem; }
.field label { font-weight: 700; }
.field input { font: inherit; padding: .7rem .85rem; border: 2px solid var(--ink); border-radius: 12px; background: var(--paper); color: var(--ink); width: 100%; }
.field .hint { margin: 0; }
.auth-form .btn { justify-self: start; }
.auth-form .error { margin: 0; }
.auth-switch { margin: .9rem 0 0; }
.link { font: inherit; background: none; border: 0; padding: 0; color: var(--ink); text-decoration: underline; text-underline-offset: 3px; cursor: pointer; font-weight: 600; }
.level-card .level-num { font-size: 3.2rem; font-weight: 800; letter-spacing: -.04em; line-height: 1; margin: 0 0 .4rem; }
.rows { list-style: none; margin: 0 0 1.6rem; padding: 0; max-width: 40rem; }
.row { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: .5rem 1rem; padding: .85rem 0; border-bottom: 2px solid var(--line); }
.row-main { display: grid; font-weight: 700; min-width: 0; }
.row-sub { font-weight: 400; color: var(--ink-soft); font-size: .92rem; }
.row-side { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; }
.row-side.is-locked { color: var(--ink-soft); font-weight: 600; }
@media (max-width: 520px) { .nav-name { max-width: 6.5rem; } .panel { padding: 1.1rem; } }
.panel { margin-top: 1.6rem; } .panel + .panel, .level-card + .sec-title { margin-top: 0; }
