:root {
  --bg: #f6f5f1;
  --surface: #ffffff;
  --text: #1c1c1a;
  --muted: #64625c;
  --line: #dedbd3;
  --line-strong: #c9c5bb;
  --accent: #2c5a5e;
  --accent-text: #ffffff;
  --accent-soft: #e4ecec;
  --focus: #1f6feb;
  --radius: 10px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141413;
    --surface: #1d1d1b;
    --text: #ebe9e4;
    --muted: #a19e96;
    --line: #2f2e2b;
    --line-strong: #44423e;
    --accent: #8cc1c4;
    --accent-text: #0f1f20;
    --accent-soft: #1f2e2f;
    --focus: #79b0ff;
    color-scheme: dark;
  }
}

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

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 17px;
  line-height: 1.5;
  overflow-x: hidden;
}

.page {
  max-width: 640px;
  margin: 0 auto;
  padding: max(20px, env(safe-area-inset-top)) 16px max(32px, env(safe-area-inset-bottom));
}

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

a { color: var(--accent); text-underline-offset: 3px; }

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
  border-radius: 6px;
}

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.muted { color: var(--muted); }
.small { font-size: 14px; }

/* Header */
.top {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 4px 16px;
  padding-bottom: 16px;
}
.top h1 { font-size: 20px; font-weight: 650; letter-spacing: -0.01em; }
.today { color: var(--muted); font-size: 15px; }

.notice {
  font-size: 14px;
  color: var(--muted);
  border-left: 3px solid var(--line-strong);
  padding: 4px 0 4px 10px;
  margin-bottom: 16px;
}

.eyebrow {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 8px;
}

/* Next step: the one framed element on the page */
.next {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px 18px 18px;
  margin-bottom: 8px;
}
.next .pos { font-size: 15px; color: var(--muted); font-variant-numeric: tabular-nums; }
.next .title {
  font-size: 26px;
  line-height: 1.2;
  font-weight: 650;
  letter-spacing: -0.015em;
  margin: 4px 0 8px;
  overflow-wrap: anywhere;
}
.next .meta { color: var(--muted); font-size: 15px; }
.next .where {
  margin-top: 14px;
  padding: 12px 14px;
  background: var(--accent-soft);
  border-radius: 8px;
  font-weight: 500;
}
.next .where code { font-family: var(--mono); font-size: 0.95em; }
.next .status-line { margin-top: 12px; font-size: 15px; color: var(--muted); }
.next .doc-link {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  margin-top: 8px;
  font-weight: 500;
}

/* Plain sections, divided by rules */
.block {
  border-top: 1px solid var(--line);
  padding: 20px 0;
}
.block:first-of-type { margin-top: 16px; }

.figure { font-size: 22px; font-weight: 600; font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }
.figure-sub { color: var(--muted); font-size: 15px; margin-top: 2px; }

/* Recall */
.recall-btn {
  display: flex;
  width: 100%;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 64px;
  padding: 12px 16px;
  font: inherit;
  color: var(--accent-text);
  background: var(--accent);
  border: 0;
  border-radius: var(--radius);
  cursor: pointer;
  text-align: left;
}
.recall-btn .figure { font-size: 20px; }
.recall-btn .go { font-size: 15px; font-weight: 600; white-space: nowrap; }
.recall-btn:active { opacity: 0.9; }
.recall-quiet .figure-sub { margin-top: 4px; }

.toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  margin-top: 10px;
  font-size: 15px;
  cursor: pointer;
}
.toggle input { width: 20px; height: 20px; margin: 0; accent-color: var(--accent); }

.backup summary {
  display: flex;
  align-items: center;
  min-height: 44px;
  font-size: 15px;
  color: var(--muted);
  cursor: pointer;
  list-style: none;
}
.backup summary::-webkit-details-marker { display: none; }
.backup summary::before {
  content: "";
  width: 7px; height: 7px;
  margin: 0 12px 0 3px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(-45deg);
  transition: transform 0.15s ease;
}
.backup[open] summary::before { transform: rotate(45deg); }
.backup-body { display: grid; gap: 10px; padding: 4px 0 4px; }
.backup textarea {
  width: 100%;
  min-height: 96px;
  padding: 10px;
  font: 13px/1.4 var(--mono);
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  resize: vertical;
}

.row { display: flex; flex-wrap: wrap; gap: 8px; }

.btn {
  min-height: 44px;
  min-width: 44px;
  padding: 0 16px;
  font: inherit;
  font-size: 16px;
  font-weight: 500;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  cursor: pointer;
}
.btn.primary { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
.btn.quiet { background: transparent; }

/* Shipped shelf */
.shelf { list-style: none; margin: 12px 0 0; padding: 0; display: grid; gap: 8px; }
.slot {
  display: grid;
  grid-template-columns: 52px 1fr;
  gap: 2px 10px;
  align-items: baseline;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
}
.slot.empty { border-style: dashed; color: var(--muted); }
.slot .lab-no { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.slot .what { overflow-wrap: anywhere; }
.slot a { display: inline-block; padding: 6px 0; font-weight: 500; }
.slot .when { grid-column: 2; font-size: 14px; color: var(--muted); }

/* Labs list */
.labs { display: grid; }
.lab { border-bottom: 1px solid var(--line); }
.lab:last-child { border-bottom: 0; }
.lab summary {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 4px 12px;
  min-height: 56px;
  padding: 8px 0;
  cursor: pointer;
  list-style: none;
}
.lab summary::-webkit-details-marker { display: none; }
.lab .lab-name { font-weight: 550; overflow-wrap: anywhere; }
.lab .lab-name .num { color: var(--muted); font-variant-numeric: tabular-nums; margin-right: 4px; }
.lab .lab-meta { font-size: 14px; color: var(--muted); font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.lab .lab-meta .chev {
  display: inline-block;
  width: 7px; height: 7px;
  margin-left: 10px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: translateY(-2px) rotate(45deg);
  transition: transform 0.15s ease;
}
.lab[open] .lab-meta .chev { transform: translateY(1px) rotate(-135deg); }
.lab .aim { color: var(--muted); font-size: 15px; margin-bottom: 8px; }
.lab .lab-doc { display: inline-flex; align-items: center; min-height: 44px; font-size: 15px; }
.steps { list-style: none; margin: 0 0 12px; padding: 0; }
.steps li {
  display: grid;
  grid-template-columns: 24px 1fr auto;
  gap: 8px;
  align-items: baseline;
  padding: 6px 0;
  font-size: 15px;
}
.steps .mark { width: 16px; height: 16px; align-self: center; }
.steps .mark svg { display: block; width: 16px; height: 16px; }
.steps .mark .ring { fill: none; stroke: var(--line-strong); stroke-width: 1.5; }
.steps .mark .tick { fill: none; stroke: var(--accent); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.steps .mark .done-ring { fill: var(--accent-soft); stroke: var(--accent); stroke-width: 1.5; }
.steps li.done .s-title { color: var(--muted); }
.steps li.current .s-title { font-weight: 600; }
.steps .s-min { color: var(--muted); font-size: 14px; font-variant-numeric: tabular-nums; white-space: nowrap; }

.status {
  display: inline-block;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
  margin-left: 8px;
}

.foot { padding-top: 8px; }

/* Review */
.review {
  position: fixed;
  inset: 0;
  z-index: 10;
  background: var(--bg);
  overflow-y: auto;
}
.review[hidden] { display: none; }
.review-inner {
  max-width: 640px;
  min-height: 100%;
  margin: 0 auto;
  padding: max(16px, env(safe-area-inset-top)) 16px max(24px, env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
}
.review-top { display: flex; align-items: center; gap: 12px; }
.review-top .eyebrow { margin: 0; }
.review-top #review-count { flex: 1; font-variant-numeric: tabular-nums; }
.review-card {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 16px;
  padding: 32px 4px;
}
.review-card:focus { outline: none; }
.review-card .concept { font-size: 13px; color: var(--muted); letter-spacing: 0.04em; text-transform: uppercase; }
.review-card .front { font-size: 23px; line-height: 1.35; font-weight: 600; overflow-wrap: anywhere; }
.review-card .back {
  font-size: 19px;
  line-height: 1.45;
  padding-top: 16px;
  border-top: 1px solid var(--line);
  overflow-wrap: anywhere;
}
.review-card .end { font-size: 21px; font-weight: 600; }
.review-actions { display: grid; gap: 8px; }
.review-actions .full { width: 100%; min-height: 52px; }
.grades { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.grades .btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 60px;
  padding: 6px 4px;
  line-height: 1.2;
}
.grades .btn small { font-size: 12px; color: var(--muted); font-weight: 400; margin-top: 2px; font-variant-numeric: tabular-nums; }
.keys { text-align: center; font-size: 13px; color: var(--muted); }
@media (hover: none) { .keys { display: none; } }

body.locked { overflow: hidden; }

@media (min-width: 720px) {
  .page { padding-top: 40px; }
  .next { padding: 24px 24px 20px; }
  .next .title { font-size: 30px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
}
