/* Synapse minimalist UI
   Warm monochrome, editorial, flat.
   Canvas #F7F6F3 · Phone #FBFBFA · Card #FFFFFF
   Ink #2F3437 · Strong #111111 · Muted #787774 · Line #EAEAEA
   Correct #346538 on #EDF3EC
   Wrong   #9F2F2D on #FDEBEC
   Flagged #956400 on #FBF3DB
   Type: Instrument Serif, Geist, JetBrains Mono
*/

:root {
  --canvas: #F7F6F3;
  --paper: #FBFBFA;
  --surface: #FFFFFF;
  --sunken: #F7F6F3;
  --ink: #2F3437;
  --ink-strong: #111111;
  --ink-hover: #333333;
  --muted: #787774;
  --line: #EAEAEA;
  --on-ink: #FFFFFF;

  --correct: #346538;
  --correct-bg: #EDF3EC;
  --wrong: #9F2F2D;
  --wrong-bg: #FDEBEC;
  --flag: #956400;
  --flag-bg: #FBF3DB;
  --info: #1F6C9F;
  --info-bg: #E1F3FE;

  --font-sans: "Geist", "Helvetica Neue", sans-serif;
  --font-serif: "Instrument Serif", "Iowan Old Style", Palatino, serif;
  --font-mono: "JetBrains Mono", "SF Mono", ui-monospace, monospace;

  --text-xs: 11px;
  --text-sm: 13px;
  --text-md: 15px;
  --text-lg: 17px;
  --text-xl: 22px;
  --text-2xl: 36px;
  --text-3xl: 48px;
  --text-display: 56px;

  --leading-tight: 1.1;
  --leading-ui: 1.4;
  --leading-body: 1.6;
  --track-tight: -0.03em;
  --track-label: 0.08em;

  --radius-xs: 4px;
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-tag: 999px;

  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;
  --space-10: 40px;
  --space-12: 48px;
  --space-16: 64px;

  --phone-w: 390px;
  --phone-h: 844px;

  --grid-line: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='28' height='28'%3E%3Cpath d='M28 0H0v28' fill='none' stroke='%232F3437' stroke-opacity='0.05' stroke-width='1'/%3E%3C/svg%3E");
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background-color: var(--canvas);
  background-image: var(--grid-line);
  background-size: 28px 28px;
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 16px;
  font-weight: 400;
  line-height: var(--leading-body);
  -webkit-font-smoothing: antialiased;
}

p,
h1,
h2,
figure {
  margin: 0;
}

::selection {
  background: var(--line);
  color: var(--ink-strong);
}

.preface {
  max-width: 40rem;
  padding: var(--space-16) var(--space-10) var(--space-4);
}

.kicker {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}

.preface h1 {
  max-width: 11em;
  margin: var(--space-3) 0 var(--space-5);
  color: var(--ink-strong);
  font-family: var(--font-serif);
  font-size: 44px;
  font-weight: 400;
  letter-spacing: var(--track-tight);
  line-height: var(--leading-tight);
}

.note {
  max-width: 38em;
  color: var(--ink);
  font-size: var(--text-md);
  line-height: var(--leading-body);
}

.note p + p {
  margin-top: var(--space-3);
}

.board {
  display: flex;
  gap: var(--space-8);
  align-items: flex-start;
  padding: var(--space-8) var(--space-10) var(--space-16);
  overflow-x: auto;
}

.frame {
  flex: 0 0 auto;
}

.frame figcaption {
  margin: 0 0 var(--space-3);
  color: var(--ink);
  font-size: var(--text-sm);
  font-weight: 500;
  letter-spacing: 0.01em;
}

.phone {
  position: relative;
  display: flex;
  flex-direction: column;
  width: var(--phone-w);
  height: var(--phone-h);
  overflow: hidden;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  color: var(--ink);
  font-size: var(--text-md);
  line-height: var(--leading-body);
}

.status {
  display: flex;
  flex: none;
  align-items: center;
  justify-content: space-between;
  height: 48px;
  padding: 0 var(--space-5);
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.status-battery {
  display: block;
  width: 27px;
  height: 13px;
}

.screen {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-height: 0;
  padding: var(--space-3) var(--space-5) 26px;
  overflow: hidden;
}

.grabber {
  position: absolute;
  bottom: 8px;
  left: 50%;
  width: 120px;
  height: 4px;
  background: var(--line);
  border-radius: 2px;
  transform: translateX(-50%);
}

.label {
  color: var(--muted);
  font-size: var(--text-xs);
  font-weight: 500;
  letter-spacing: var(--track-label);
  line-height: 1.3;
  text-transform: uppercase;
}

.figure {
  color: var(--ink-strong);
  font-family: var(--font-serif);
  font-weight: 400;
  letter-spacing: var(--track-tight);
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.figure .pct {
  margin-left: 1px;
  font-size: 0.52em;
  letter-spacing: 0;
}

.figure-rest {
  color: var(--muted);
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  letter-spacing: 0;
}

.track {
  position: relative;
  height: 4px;
  overflow: hidden;
  background: var(--line);
  border-radius: 2px;
}

.fill {
  display: block;
  width: var(--p);
  max-width: 100%;
  height: 100%;
  background: var(--ink);
  border-radius: 2px;
}

.track-correct {
  background: var(--correct-bg);
}

.fill-correct {
  background: var(--correct);
}

.track-mark {
  overflow: visible;
  margin-top: var(--space-3);
}

.mark {
  position: absolute;
  top: -3px;
  left: var(--p);
  width: 1px;
  height: 10px;
  background: var(--ink-strong);
}

.hello-soft {
  display: block;
  color: var(--muted);
  font-family: var(--font-serif);
  font-size: var(--text-xl);
  font-style: italic;
  font-weight: 400;
  letter-spacing: -0.02em;
  line-height: var(--leading-tight);
}

.hello-name {
  display: block;
  margin-top: var(--space-1);
  color: var(--ink-strong);
  font-family: var(--font-serif);
  font-size: 34px;
  font-weight: 400;
  letter-spacing: var(--track-tight);
  line-height: 1.05;
}

.streak {
  margin-top: var(--space-3);
  color: var(--muted);
  font-size: var(--text-sm);
}

.streak strong {
  color: var(--ink);
  font-weight: 500;
}

.bento {
  display: grid;
  grid-template-columns: 1.25fr 0.9fr;
  grid-template-rows: 1fr 1fr;
  gap: var(--space-2);
  margin-top: var(--space-4);
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: var(--space-3);
}

.card-progress {
  display: flex;
  flex-direction: column;
  grid-row: 1 / span 2;
}

.card-progress .figure {
  margin: var(--space-2) 0 var(--space-3);
  font-size: 40px;
}

.card-progress .track {
  margin-top: auto;
}

.card-side {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 80px;
}

.card-side .figure {
  margin-top: var(--space-2);
  font-size: 28px;
}

.card-flag {
  background: var(--flag-bg);
}

.card-flag .label,
.card-flag .figure {
  color: var(--flag);
}

.group {
  margin-top: var(--space-4);
  padding-top: var(--space-4);
  border-top: 1px solid var(--line);
}

.group > .label {
  margin-bottom: var(--space-2);
}

.stack {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.row {
  display: flex;
  align-items: center;
  min-height: 42px;
  padding: 0 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  color: var(--ink);
  font-size: 14px;
  line-height: var(--leading-ui);
}

.row-primary {
  background: var(--ink-strong);
  border-color: var(--ink-strong);
  border-radius: var(--radius-sm);
  color: var(--on-ink);
}

.row-primary:hover {
  background: var(--ink-hover);
}

.row-primary:active {
  transform: scale(0.98);
}

.focus-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 6px var(--space-3);
  margin-bottom: var(--space-3);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.3;
}

.focus-row:last-child {
  margin-bottom: 0;
}

.focus-pct {
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.focus-row .track {
  grid-column: 1 / -1;
}

.screen-heading {
  color: var(--ink-strong);
  font-family: var(--font-serif);
  font-size: 40px;
  font-weight: 400;
  letter-spacing: var(--track-tight);
  line-height: 1.05;
}

.screen-sub {
  margin-top: 6px;
  color: var(--muted);
  font-size: var(--text-md);
  line-height: var(--leading-body);
}

.fields {
  display: flex;
  flex-direction: column;
  gap: 22px;
  margin-top: var(--space-8);
}

.field .label {
  margin-bottom: var(--space-2);
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.chip {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  padding: 0 var(--space-3);
  background: var(--surface);
  border: 1px solid var(--ink-strong);
  border-radius: var(--radius-sm);
  color: var(--ink);
  font-size: var(--text-sm);
  line-height: 1;
}

.sq {
  width: 8px;
  height: 8px;
  margin-right: var(--space-2);
  background: currentColor;
}

.segment {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
}

.segment span {
  padding: 11px 8px;
  border-right: 1px solid var(--line);
  color: var(--muted);
  font-size: var(--text-sm);
  line-height: 1.2;
  text-align: center;
}

.segment span:last-child {
  border-right: 0;
}

.segment .is-on {
  background: var(--ink-strong);
  color: var(--on-ink);
}

.value,
.stepper {
  min-height: 46px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
}

.value {
  display: flex;
  align-items: center;
  padding: 0 14px;
  color: var(--ink);
  font-size: var(--text-md);
}

.stepper {
  display: grid;
  grid-template-columns: 44px 1fr 44px;
}

.step {
  display: grid;
  place-items: center;
  color: var(--ink);
  font-size: 18px;
  line-height: 1;
}

.step:first-child {
  border-right: 1px solid var(--line);
}

.step:last-child {
  border-left: 1px solid var(--line);
}

.step-value {
  display: grid;
  place-items: center;
  color: var(--ink);
  font-family: var(--font-mono);
  font-size: var(--text-md);
  font-variant-numeric: tabular-nums;
}

.action-foot {
  margin-top: var(--space-8);
}

.quiet-actions {
  display: flex;
  justify-content: center;
  gap: var(--space-5);
  margin-bottom: var(--space-3);
  color: var(--muted);
  font-size: var(--text-sm);
}

.btn-solid,
.btn-quiet {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 46px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  line-height: 1;
}

.btn-solid {
  background: var(--ink-strong);
  color: var(--on-ink);
}

.btn-solid:hover {
  background: var(--ink-hover);
}

.btn-solid:active,
.btn-quiet:active {
  transform: scale(0.98);
}

.btn-quiet {
  background: var(--paper);
  border: 1px solid var(--line);
  color: var(--ink);
  font-weight: 400;
}

.session-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
}

.session-top p {
  color: var(--muted);
  font-size: var(--text-sm);
}

.timer {
  padding: 4px 6px;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 400;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
  background: var(--sunken);
  border: 1px solid var(--line);
  border-radius: var(--radius-xs);
}

.stem {
  margin-top: var(--space-8);
  color: var(--ink);
  font-size: var(--text-lg);
  line-height: var(--leading-body);
}

.choices {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  margin-top: var(--space-6);
}

.choice {
  display: flex;
  gap: var(--space-3);
  align-items: flex-start;
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.5;
}

.choice-key {
  flex: none;
  padding-top: 2px;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 12px;
}

.choice.is-selected {
  background: var(--sunken);
  border-color: var(--ink);
  border-left-color: var(--ink-strong);
  border-left-width: 2px;
}

.choice.is-selected .choice-key {
  color: var(--ink-strong);
}

.session-actions {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: var(--space-2);
  margin-top: var(--space-5);
}

.session-actions .btn-solid,
.session-actions .btn-quiet {
  height: 44px;
}

.mastery .label {
  display: block;
}

.mastery .figure {
  margin: var(--space-2) 0 var(--space-4);
  font-size: var(--text-display);
}

.stat {
  padding: 14px 0;
  border-top: 1px solid var(--line);
}

.stat-head {
  display: flex;
  gap: var(--space-3);
  align-items: baseline;
  justify-content: space-between;
}

.stat-value {
  margin-top: 2px;
  color: var(--ink);
  font-size: 16px;
  line-height: var(--leading-ui);
}

.best,
.aside {
  color: var(--muted);
  font-size: var(--text-sm);
  line-height: var(--leading-body);
}

.stat .track {
  margin-top: var(--space-3);
}

.acc-note {
  margin-top: var(--space-2);
  color: var(--correct);
  font-size: var(--text-sm);
  font-weight: 500;
  line-height: var(--leading-ui);
}

.tag {
  display: inline-flex;
  align-items: center;
  padding: 4px 8px;
  font-size: var(--text-xs);
  font-weight: 500;
  line-height: 1.2;
  letter-spacing: 0.04em;
  border-radius: var(--radius-tag);
}

.tag-wrong {
  background: var(--wrong-bg);
  color: var(--wrong);
}

.aside {
  margin-top: var(--space-2);
}

.disclosure {
  border-top: 1px solid var(--line);
}

.disclosure summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: 14px 0;
  color: var(--ink);
  font-size: var(--text-md);
  font-weight: 500;
  line-height: var(--leading-ui);
  list-style: none;
  cursor: pointer;
}

.disclosure summary::-webkit-details-marker {
  display: none;
}

.disclosure summary::after {
  content: "+";
  color: var(--muted);
  font-size: 18px;
  font-weight: 400;
  line-height: 1;
}

.disclosure[open] summary::after {
  content: "−";
}

.disclosure summary:focus-visible {
  outline: 1px solid var(--ink);
  outline-offset: 3px;
}

.disclosure p {
  padding-bottom: var(--space-2);
  color: var(--muted);
  font-size: var(--text-md);
  line-height: var(--leading-body);
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(12px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (prefers-reduced-motion: no-preference) {
  .preface,
  .frame {
    animation: rise 600ms cubic-bezier(0.16, 1, 0.3, 1) both;
    animation-delay: calc(var(--i, 0) * 80ms);
  }
}
