/* PERSONAL OS — design system
 *
 * Built against DESIGN.md. The short version:
 *   one accent, one card, one list row, one way to show progress
 *   8px spacing grid, four type sizes
 *   colour never carries meaning alone — always paired with a word
 *   thumb-reachable: primary actions low, 44px minimum targets
 *   motion only where it explains a change
 */

/* ================================================================ themes */

:root,
:root[data-theme='dark'] {
  --bg:        #0d1117;
  --surface:   #161c24;
  --surface-2: #1e252f;
  --line:      #2b333e;
  --line-soft: #232a34;
  --fg:        #e8eef5;
  --fg-dim:    #9aa7b4;
  --fg-faint:  #6b7785;
  --accent:    #5b9dff;
  --accent-2:  #7c5cff;
  --accent-soft: #16273f;
  --on-accent: #ffffff;
  --green:     #3fb950;
  --green-soft:#122a17;
  --amber:     #d29922;
  --amber-soft:#2a2010;
  --red:       #f85149;
  --red-soft:  #2d1416;
  --shadow:    0 1px 3px rgb(0 0 0 / .35);
  --shadow-lg: 0 8px 28px rgb(0 0 0 / .40);
  color-scheme: dark;
}

:root[data-theme='light'] {
  --bg:        #ffffff;
  --surface:   #f7f9fb;
  --surface-2: #eef2f6;
  --line:      #d8dee6;
  --line-soft: #e8edf2;
  --fg:        #161d26;
  --fg-dim:    #55606d;
  --fg-faint:  #838e9b;
  --accent:    #0b6bcb;
  --accent-2:  #6135d4;
  --accent-soft: #e5f0fd;
  --on-accent: #ffffff;
  --green:     #1a7f37;
  --green-soft:#e6f4ea;
  --amber:     #8a6100;
  --amber-soft:#fdf2dc;
  --red:       #c9252d;
  --red-soft:  #fdeaea;
  --shadow:    0 1px 3px rgb(16 24 40 / .07);
  --shadow-lg: 0 10px 32px rgb(16 24 40 / .10);
  color-scheme: light;
}

/* Warm and low-contrast: the theme for actually working through a long
 * lesson. Paper white is harsh after twenty minutes. */
:root[data-theme='paper'] {
  --bg:        #faf6ef;
  --surface:   #f4eee3;
  --surface-2: #ece4d6;
  --line:      #d9cdb9;
  --line-soft: #e7ded0;
  --fg:        #2e2922;
  --fg-dim:    #695f51;
  --fg-faint:  #948974;
  --accent:    #9a5b2c;
  --accent-2:  #7a5099;
  --accent-soft: #f2e3d1;
  --on-accent: #ffffff;
  --green:     #4a7c2f;
  --green-soft:#e8f0dd;
  --amber:     #a8710f;
  --amber-soft:#f6e9cf;
  --red:       #b3402c;
  --red-soft:  #f7e3de;
  --shadow:    0 1px 3px rgb(90 70 40 / .10);
  --shadow-lg: 0 10px 30px rgb(90 70 40 / .12);
  color-scheme: light;
}

/* True black for an OLED phone in a shared room at night. */
:root[data-theme='midnight'] {
  --bg:        #000000;
  --surface:   #0c0f13;
  --surface-2: #161b21;
  --line:      #242a32;
  --line-soft: #181d23;
  --fg:        #d8dee6;
  --fg-dim:    #858f9b;
  --fg-faint:  #5c6570;
  --accent:    #6aa8ff;
  --accent-2:  #8b6cff;
  --accent-soft: #0f1b2b;
  --on-accent: #ffffff;
  --green:     #35a745;
  --green-soft:#0d1f11;
  --amber:     #c08a1e;
  --amber-soft:#211a0c;
  --red:       #e04a42;
  --red-soft:  #240f10;
  --shadow:    none;
  --shadow-lg: none;
  color-scheme: dark;
}

@media (prefers-color-scheme: light) {
  :root[data-theme='auto'] {
    --bg: #ffffff; --surface: #f7f9fb; --surface-2: #eef2f6;
    --line: #d8dee6; --line-soft: #e8edf2;
    --fg: #161d26; --fg-dim: #55606d; --fg-faint: #838e9b;
    --accent: #0b6bcb; --accent-2: #6135d4; --accent-soft: #e5f0fd;
    --on-accent: #fff; --green: #1a7f37; --green-soft: #e6f4ea;
    --amber: #8a6100; --amber-soft: #fdf2dc;
    --red: #c9252d; --red-soft: #fdeaea;
    color-scheme: light;
  }
}

:root {
  --r-sm: 8px; --r: 12px; --r-lg: 16px;
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 24px; --s6: 32px;
  --pad: 16px;
  --tap: 44px;                     /* minimum touch target */
  --font: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Segoe UI', Roboto,
          'Helvetica Neue', Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, 'SF Mono', Menlo, Consolas, monospace;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0; padding: 0;
  background: var(--bg); color: var(--fg);
  font-family: var(--font); font-size: 16px; line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}
button, input, textarea, select { font: inherit; color: inherit; }
a { color: var(--accent); }
[hidden] { display: none !important; }

/* Four type sizes. Emphasis is weight, not size, wherever possible. */
h1 { font-size: 26px; line-height: 1.2; font-weight: 680; letter-spacing: -.022em; margin: 0 0 var(--s1); }
h2 { font-size: 19px; line-height: 1.3; font-weight: 650; letter-spacing: -.015em; }
.sub { margin: 0 0 var(--s5); color: var(--fg-dim); font-size: 14px; }
.lead { font-size: 16px; line-height: 1.6; color: var(--fg-dim); margin: 0 0 var(--s4); }
.small { font-size: 14px; } .tiny { font-size: 12.5px; }
.muted { color: var(--fg-dim); } .faint { color: var(--fg-faint); }
.strong { font-weight: 620; }
.mono { font-family: var(--mono); font-size: 13px; }
.mt-2 { margin-top: var(--s2); } .mt-3 { margin-top: var(--s3); }
.mb-2 { margin-bottom: var(--s2); }

/* ================================================================ chrome */

.topbar {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--s2);
  padding: max(env(safe-area-inset-top), 10px) var(--pad) 10px;
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid var(--line-soft);
}
.brand {
  display: flex; align-items: center; gap: var(--s2);
  background: none; border: 0; padding: 4px 0; cursor: pointer;
  font-weight: 660; letter-spacing: -.015em; font-size: 15px;
}
.brand-mark { color: var(--accent); font-size: 12px; }
.topbar-actions { display: flex; gap: var(--s1); align-items: center; }

.icon-btn {
  min-width: var(--tap); height: var(--tap);
  display: grid; place-items: center;
  background: none; border: 0; border-radius: var(--r-sm);
  color: var(--fg-dim); cursor: pointer; font-size: 18px;
}
.icon-btn:hover { background: var(--surface-2); color: var(--fg); }

.net {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 4px 9px; border-radius: 999px;
  font-size: 11.5px; font-weight: 620;
  background: var(--surface-2); color: var(--fg-faint);
}
.net:empty { display: none; }
.net.offline { background: var(--amber-soft); color: var(--amber); }
.net.syncing { background: var(--accent-soft); color: var(--accent); }
.net .dotlet { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

.view {
  padding: var(--s5) var(--pad) 120px;
  max-width: 720px; margin: 0 auto; outline: none;
}

/* ================================================================== hero
 * Rule 1: one obvious next action, above the fold, no decision required. */

.hero {
  background: linear-gradient(150deg,
    color-mix(in srgb, var(--accent) 14%, var(--surface)),
    var(--surface) 65%);
  border: 1px solid color-mix(in srgb, var(--accent) 22%, var(--line-soft));
  border-radius: var(--r-lg);
  padding: var(--s5) var(--s4) var(--s4);
  margin-bottom: var(--s5);
  box-shadow: var(--shadow);
}
.hero.compact { padding: var(--s4); }
.hero-kind {
  font-size: 11.5px; font-weight: 680; letter-spacing: .1em;
  text-transform: uppercase; color: var(--accent); margin-bottom: var(--s2);
}
.hero-title {
  font-size: 22px; line-height: 1.25; font-weight: 660;
  letter-spacing: -.02em; margin: 0 0 var(--s2);
}
.hero-why { margin: 0 0 var(--s4); color: var(--fg-dim); font-size: 14.5px; }
.hero-foot {
  display: flex; align-items: center; gap: var(--s2);
  margin-top: var(--s3); flex-wrap: wrap;
}
.hero-bar { flex: 1; min-width: 90px; }

/* ============================================================== sections */

.sec {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: var(--s3);
  margin: var(--s6) 0 var(--s2);
  font-size: 12px; font-weight: 680; letter-spacing: .08em;
  text-transform: uppercase; color: var(--fg-faint);
}
.sec:first-child { margin-top: var(--s4); }
.sec-act {
  text-transform: none; letter-spacing: 0; font-size: 13px; font-weight: 560;
  color: var(--accent); cursor: pointer; background: none; border: 0;
  padding: 4px 0;
}
.sec-note {
  margin: calc(var(--s2) * -1) 0 var(--s3);
  font-size: 13px; color: var(--fg-faint);
}

/* ================================================================= cards */

.card {
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: var(--r);
  padding: var(--s4);
  margin-bottom: var(--s2);
}
.card-warn { border-color: var(--amber); background: var(--amber-soft); }
.card-bad  { border-color: var(--red); background: var(--red-soft); }
.card-accent { border-color: var(--accent); }

.row { display: flex; align-items: center; gap: var(--s3); }
.row.between { justify-content: space-between; }
.row.top { align-items: flex-start; }
.grow { flex: 1; min-width: 0; }
.trunc { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ================================================================= lists
 * One row component. Same markup, same meaning, everywhere. */

.list {
  border: 1px solid var(--line-soft);
  border-radius: var(--r);
  overflow: hidden;
  background: var(--surface);
}
.list > * + * { border-top: 1px solid var(--line-soft); }

.row-item {
  display: flex; align-items: center; gap: var(--s3);
  width: 100%; min-height: var(--tap);
  padding: var(--s3) var(--s4);
  background: none; border: 0; text-align: left; cursor: pointer;
  color: inherit; transition: background .12s;
}
.row-item:hover { background: var(--surface-2); }
.row-item:active { background: var(--surface-2); transform: scale(.995); }
.row-item.static { cursor: default; }
.row-item.static:hover { background: none; }

.row-icon {
  flex: none; width: 30px; height: 30px; border-radius: var(--r-sm);
  display: grid; place-items: center; font-size: 14px;
  background: var(--surface-2); color: var(--fg-dim);
}
.row-icon.amber { background: var(--amber-soft); color: var(--amber); }
.row-icon.green { background: var(--green-soft); color: var(--green); }
.row-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.row-title { font-size: 15px; font-weight: 560; line-height: 1.35; }
.row-why { font-size: 12.5px; color: var(--fg-faint); line-height: 1.35; }
.chev { color: var(--fg-faint); font-size: 16px; flex: none; }

/* Plan rows get a coloured icon by kind, so the shape of the day is legible
 * at a glance without reading every line. */
.row-item.deadline .row-icon { background: var(--red-soft); color: var(--red); }
.row-item.class    .row-icon { background: var(--accent-soft); color: var(--accent); }
.row-item.revision .row-icon { background: var(--amber-soft); color: var(--amber); }
.row-item.review   .row-icon { background: color-mix(in srgb, var(--accent-2) 18%, transparent); color: var(--accent-2); }
.row-item.learn    .row-icon { background: var(--green-soft); color: var(--green); }
.row-item.routine  .row-icon { background: var(--surface-2); color: var(--fg-dim); }

/* Split row: the circle changes status, the name opens the topic. */
.split-row { display: flex; align-items: stretch; background: var(--surface); }
.split-row .row-item { padding-left: var(--s1); }
.dot-btn {
  flex: none; min-width: var(--tap); padding: 0 var(--s2) 0 var(--s4);
  background: none; border: 0; display: grid; place-items: center; cursor: pointer;
}
.dot { width: 10px; height: 10px; border-radius: 50%; flex: none; background: var(--line); }
.dot.learning { background: var(--amber); }
.dot.done { background: var(--green); }
.dot.paused { background: var(--accent-2); }
.dot-btn:hover .dot { outline: 3px solid color-mix(in srgb, var(--accent) 28%, transparent); }

/* ================================================== subject / grid cards */

.grid-cards {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: var(--s2);
}
.subject-card {
  display: flex; flex-direction: column; gap: var(--s1);
  padding: var(--s4); min-height: 92px;
  background: var(--surface); border: 1px solid var(--line-soft);
  border-radius: var(--r); cursor: pointer; text-align: left; color: inherit;
  transition: border-color .12s, transform .12s;
}
.subject-card:hover { border-color: var(--accent); transform: translateY(-1px); }
.subject-name { font-size: 14.5px; font-weight: 600; line-height: 1.3; }
.subject-meta { font-size: 12px; color: var(--fg-faint); }
.subject-bar { margin-top: auto; }

/* =============================================================== buttons */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: var(--tap); padding: 10px var(--s4);
  background: var(--surface-2); border: 1px solid var(--line);
  border-radius: var(--r-sm); color: var(--fg);
  font-size: 14.5px; font-weight: 580; cursor: pointer;
  transition: filter .12s, border-color .12s;
}
.btn:hover { border-color: var(--fg-faint); }
.btn:active { transform: scale(.985); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary {
  background: var(--accent); border-color: var(--accent); color: var(--on-accent);
  box-shadow: var(--shadow);
}
.btn.primary:hover { filter: brightness(1.07); }
.btn.lg { min-height: 50px; font-size: 15.5px; font-weight: 620; }
.btn.sm { min-height: 34px; padding: 6px 12px; font-size: 13px; }
.btn.block { width: 100%; }
.btn.ghost { background: none; }
.btn.danger { color: var(--red); border-color: var(--red); }
.btn-row { display: flex; gap: var(--s2); flex-wrap: wrap; }
.next-step { margin-top: var(--s5); }

.search-trigger {
  display: flex; align-items: center; gap: var(--s3);
  width: 100%; min-height: var(--tap); padding: 12px var(--s4);
  margin-bottom: var(--s4);
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r); color: var(--fg-faint);
  font-size: 15px; cursor: pointer; text-align: left;
}
.search-trigger:hover { border-color: var(--accent); }

/* ================================================================ inputs */

.input, .textarea, .select {
  width: 100%; min-height: var(--tap); padding: 11px var(--s3);
  background: var(--bg); border: 1px solid var(--line);
  border-radius: var(--r-sm); outline: none;
  font-size: 16px;                 /* 16px stops iOS zooming on focus */
  transition: border-color .12s, box-shadow .12s;
}
.input:focus, .textarea:focus, .select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 20%, transparent);
}
.textarea { resize: vertical; min-height: 76px; line-height: 1.55; }
.field { margin-bottom: var(--s3); }
.field > label {
  display: block; margin-bottom: 5px;
  font-size: 13px; font-weight: 580; color: var(--fg-dim);
}
.field-row { display: flex; gap: var(--s2); }
.field-row > * { flex: 1; min-width: 0; }

.search-input {
  width: 100%; padding: 14px var(--s4); font-size: 16px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r); outline: none;
}
.search-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 20%, transparent);
}

/* Saved-state feedback: silence reads as failure (rule 4). */
.saved-tick {
  display: inline-block; margin-left: 6px; color: var(--green);
  font-size: 12px; opacity: 0; transition: opacity .2s;
}
.saved-tick.on { opacity: 1; }

/* ================================================= pills, stats, progress */

.pill {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 4px 10px; border-radius: 999px;
  font-size: 12px; font-weight: 600; white-space: nowrap;
  background: var(--surface-2); color: var(--fg-dim);
}
.pill.green { background: var(--green-soft); color: var(--green); }
.pill.amber { background: var(--amber-soft); color: var(--amber); }
.pill.red   { background: var(--red-soft); color: var(--red); }
.pill.accent{ background: var(--accent-soft); color: var(--accent); }
.pills { display: flex; flex-wrap: wrap; gap: 6px; }

.pill-btn { cursor: pointer; border: 1px solid transparent; }
.pill-btn:hover { border-color: var(--fg-faint); }
.pill-btn.on { background: var(--accent); color: var(--on-accent); }

.bar { height: 6px; background: var(--surface-2); border-radius: 999px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--accent); border-radius: 999px; transition: width .3s cubic-bezier(.4,0,.2,1); }
.bar.green > i { background: var(--green); }
.bar.amber > i { background: var(--amber); }

.stat-row {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(78px, 1fr));
  gap: var(--s2);
}
.stat {
  background: var(--surface); border: 1px solid var(--line-soft);
  border-radius: var(--r); padding: var(--s3);
}
.stat b { display: block; font-size: 21px; font-weight: 680; letter-spacing: -.02em; }
.stat span { font-size: 11px; color: var(--fg-faint); text-transform: uppercase; letter-spacing: .05em; }

.seg {
  display: inline-flex; padding: 3px; gap: 2px;
  background: var(--surface-2); border-radius: var(--r-sm); flex-wrap: wrap;
}
.seg > button {
  min-height: 34px; padding: 6px 13px;
  background: none; border: 0; border-radius: 6px;
  color: var(--fg-dim); font-size: 13.5px; font-weight: 580; cursor: pointer;
}
.seg > button.on { background: var(--bg); color: var(--fg); box-shadow: var(--shadow); }
.seg.sm > button { min-height: 30px; padding: 4px 10px; font-size: 12.5px; }

/* The tutor-depth choice. Sits with the button it changes, never in settings,
 * so the trade-off is visible at the moment it matters. */
.tier-picker { margin: var(--s3) 0; }
.tier-note { margin: var(--s2) 0 0; line-height: 1.5; }
.row.wrap { flex-wrap: wrap; gap: var(--s2); }

/* ========================================================= empty & skeleton
 * Rule 5: an empty state teaches and offers a way out. */

.empty-state {
  text-align: center; padding: var(--s6) var(--s4);
  background: var(--surface); border: 1px dashed var(--line);
  border-radius: var(--r);
}
.empty-icon {
  font-size: 30px; color: var(--fg-faint); margin-bottom: var(--s2);
  opacity: .8;
}
.empty-title { font-size: 16px; font-weight: 620; margin-bottom: var(--s1); }
.empty-body {
  margin: 0 auto; max-width: 42ch;
  font-size: 14px; color: var(--fg-dim); line-height: 1.55;
}
.empty-inline {
  padding: var(--s4); text-align: center;
  color: var(--fg-faint); font-size: 13.5px;
}

.skeleton { display: flex; flex-direction: column; gap: var(--s2); }
.sk-row {
  height: 52px; border-radius: var(--r);
  background: linear-gradient(90deg, var(--surface) 25%,
              var(--surface-2) 50%, var(--surface) 75%);
  background-size: 200% 100%;
  animation: sk 1.3s ease-in-out infinite;
}
@keyframes sk { to { background-position: -200% 0; } }
@media (prefers-reduced-motion: reduce) {
  .sk-row { animation: none; }
  * { transition: none !important; }
}

/* ============================================================ onboarding */

.onboard { max-width: 460px; margin: 6vh auto; padding: 0 var(--pad); }
.onboard h1 { font-size: 28px; margin-bottom: var(--s3); }
.onboard-progress { display: flex; gap: 6px; margin-bottom: var(--s5); }
.onboard-dot {
  width: 26px; height: 4px; border-radius: 999px; background: var(--line);
  transition: background .25s;
}
.onboard-dot.on { background: var(--accent); }
.onboard-points { display: flex; flex-direction: column; gap: var(--s3); margin: var(--s5) 0; }
.onboard-point { display: flex; gap: var(--s3); align-items: flex-start; }
.onboard-icon {
  flex: none; width: 34px; height: 34px; border-radius: var(--r-sm);
  display: grid; place-items: center;
  background: var(--accent-soft); color: var(--accent); font-size: 15px;
}

/* =============================================================== prose */

.prose { font-size: 16px; line-height: 1.7; }
.prose h2 { font-size: 19px; margin: var(--s5) 0 var(--s2); font-weight: 650; }
.prose h3 { font-size: 16.5px; margin: var(--s4) 0 var(--s2); font-weight: 640; }
.prose h4 { font-size: 14.5px; margin: var(--s4) 0 var(--s1); font-weight: 640; color: var(--fg-dim); }
.prose p { margin: 0 0 var(--s3); }
.prose ul, .prose ol { margin: 0 0 var(--s3); padding-left: 24px; }
.prose li { margin-bottom: 6px; }
.prose ul.tasks { list-style: none; padding-left: 0; }
.prose li.task { display: flex; gap: var(--s2); align-items: flex-start; padding: 5px 0; }
.prose li.task .tick {
  width: 18px; height: 18px; flex: none; margin-top: 2px;
  border: 1.5px solid var(--line); border-radius: 5px;
  display: grid; place-items: center; font-size: 11px; color: var(--green);
}
.prose li.task.done .tick { background: var(--green); border-color: var(--green); color: #fff; }
.prose code {
  font-family: var(--mono); font-size: .875em;
  background: var(--surface-2); padding: 2px 6px; border-radius: 5px;
}
.prose pre.code {
  background: var(--surface-2); border: 1px solid var(--line-soft);
  border-radius: var(--r-sm); padding: var(--s3) var(--s4);
  overflow-x: auto; margin: 0 0 var(--s4);
}
.prose pre.code code { background: none; padding: 0; font-size: 13px; line-height: 1.6; }
.prose blockquote {
  margin: 0 0 var(--s4); padding: var(--s1) 0 var(--s1) var(--s4);
  border-left: 3px solid var(--accent); color: var(--fg-dim);
}
.prose hr { border: 0; border-top: 1px solid var(--line-soft); margin: var(--s5) 0; }
.prose .table-wrap { overflow-x: auto; margin: 0 0 var(--s4); -webkit-overflow-scrolling: touch; }
.prose table { border-collapse: collapse; width: 100%; font-size: 14px; }
.prose th, .prose td { border: 1px solid var(--line-soft); padding: 9px 12px; text-align: left; }
.prose th { background: var(--surface-2); font-weight: 620; }
.prose a { text-decoration: underline; text-underline-offset: 2px; }

.reading-progress {
  position: sticky; top: 0; height: 3px; background: var(--surface-2);
  z-index: 5; border-radius: 999px; margin-bottom: var(--s4);
}
.reading-progress > i { display: block; height: 100%; background: var(--accent); border-radius: 999px; }

.lesson-nav { display: flex; gap: var(--s2); margin-top: var(--s5); }
.lesson-nav .btn { flex: 1; }

/* ============================================================== practice */

.q-option {
  display: block; width: 100%; min-height: var(--tap); text-align: left;
  padding: var(--s3) var(--s4); margin-bottom: var(--s2);
  background: var(--surface); border: 1.5px solid var(--line-soft);
  border-radius: var(--r-sm); cursor: pointer; color: inherit;
  transition: border-color .12s, background .12s;
}
.q-option:hover { border-color: var(--accent); }
.q-option.right { border-color: var(--green); background: var(--green-soft); }
.q-option.wrong { border-color: var(--red); background: var(--red-soft); }
.explain {
  margin-top: var(--s3); padding: var(--s4);
  border-radius: var(--r-sm); background: var(--surface-2);
  border-left: 3px solid var(--accent);
}
.flashcard {
  min-height: 210px; display: grid; place-items: center; text-align: center;
  padding: var(--s6) var(--s4);
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r); cursor: pointer; font-size: 17px; line-height: 1.6;
}

/* ============================================================= timetable */

.tt { display: grid; gap: var(--s2); }
.tt-day { background: var(--surface); border: 1px solid var(--line-soft); border-radius: var(--r); overflow: hidden; }
.tt-day > h3 {
  margin: 0; padding: 10px var(--s4);
  font-size: 12px; font-weight: 680; text-transform: uppercase;
  letter-spacing: .07em; color: var(--fg-faint); background: var(--surface-2);
}
.tt-slot { display: flex; gap: var(--s3); padding: 11px var(--s4); align-items: center; }
.tt-slot + .tt-slot { border-top: 1px solid var(--line-soft); }
.tt-time { font-family: var(--mono); font-size: 12.5px; color: var(--fg-dim); flex: none; width: 92px; }
.tt-day.today { border-color: var(--accent); }

/* =============================================================== chain */

.chain { position: relative; padding-left: 26px; }
.chain::before { content: ''; position: absolute; left: 6px; top: 10px; bottom: 10px; width: 2px; background: var(--line); }
.chain-node { position: relative; padding: var(--s2) 0; }
.chain-node::before {
  content: ''; position: absolute; left: -25px; top: 15px;
  width: 13px; height: 13px; border-radius: 50%;
  background: var(--bg); border: 2px solid var(--line);
}
.chain-node.done::before { background: var(--green); border-color: var(--green); }
.chain-node.active::before { background: var(--amber); border-color: var(--amber); }

/* =============================================================== tabbar */

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  /* Five tabs. Fixed-count columns wrapped to a second row on a 375px
     phone the moment Goals was added; deriving it from the children keeps
     any future tab honest. */
  display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 2px;
  padding: 6px var(--s1) max(env(safe-area-inset-bottom), 8px);
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: saturate(180%) blur(14px);
  border-top: 1px solid var(--line-soft);
}
.tab {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  min-height: var(--tap); padding: 6px 1px; min-width: 0;
  background: none; border: 0; border-radius: var(--r-sm);
  color: var(--fg-faint); font-size: 10.5px; font-weight: 580; cursor: pointer;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  transition: color .12s;
}
.tab .ti { font-size: 19px; line-height: 1; }
.tab.on { color: var(--accent); }
.tab:hover:not(.on) { color: var(--fg-dim); }

/* ================================================================ misc */

.toast {
  position: fixed; left: 50%; bottom: calc(84px + env(safe-area-inset-bottom));
  transform: translate(-50%, 12px); z-index: 60;
  padding: 11px 18px; background: var(--fg); color: var(--bg);
  border-radius: 999px; font-size: 14px; font-weight: 580;
  opacity: 0; pointer-events: none;
  transition: opacity .2s, transform .2s;
  max-width: calc(100vw - 32px); box-shadow: var(--shadow-lg);
}
.toast.on { opacity: 1; transform: translate(-50%, 0); }

.timer-bar {
  position: fixed; left: 0; right: 0; z-index: 45;
  bottom: calc(70px + env(safe-area-inset-bottom));
  display: flex; align-items: center; gap: var(--s3);
  padding: 11px var(--pad);
  background: var(--accent); color: var(--on-accent);
  font-size: 14px; font-weight: 600;
  box-shadow: var(--shadow-lg);
}
.timer-bar .btn { background: rgb(255 255 255 / .2); border-color: transparent; color: inherit; min-height: 34px; }

.back {
  display: inline-flex; align-items: center; gap: 5px;
  min-height: 36px; margin-bottom: var(--s2);
  padding: 0; background: none; border: 0; color: var(--fg-dim);
  font-size: 14px; cursor: pointer;
}
.back:hover { color: var(--fg); }

.spin { display: inline-block; font-size: 22px; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.kv { display: grid; grid-template-columns: 1fr auto; gap: 7px var(--s4); font-size: 14px; }
.kv dt { color: var(--fg-dim); }
.kv dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; }

mark { background: color-mix(in srgb, var(--accent) 30%, transparent); color: inherit; border-radius: 3px; padding: 0 2px; }

.origin-tag {
  font-size: 10.5px; text-transform: uppercase; letter-spacing: .06em;
  color: var(--fg-faint); border: 1px solid var(--line-soft);
  padding: 2px 6px; border-radius: 4px;
}
.unwritten {
  display: flex; gap: var(--s2); padding: var(--s3) var(--s4);
  background: var(--amber-soft);
  border: 1px dashed color-mix(in srgb, var(--amber) 45%, transparent);
  border-radius: var(--r-sm); color: var(--fg-dim);
  font-size: 13.5px; line-height: 1.55;
}
.callout { border-left: 3px solid var(--line); padding: 2px 0 2px var(--s3); color: var(--fg-dim); font-size: 14px; }
.callout.warn { border-color: var(--amber); }
.callout.info { border-color: var(--accent); }

.check { display: flex; align-items: flex-start; gap: var(--s3); padding: 11px 0; cursor: pointer; min-height: var(--tap); }
.check + .check { border-top: 1px solid var(--line-soft); }
.check input { display: none; }
.check .box {
  width: 20px; height: 20px; flex: none; margin-top: 1px;
  border: 1.5px solid var(--line); border-radius: 6px;
  display: grid; place-items: center; font-size: 12px; color: transparent;
  transition: background .12s, border-color .12s;
}
.check input:checked + .box { background: var(--green); border-color: var(--green); color: #fff; }
.check input:checked ~ .lbl { color: var(--fg-faint); text-decoration: line-through; }
.check .lbl { font-size: 14.5px; line-height: 1.45; }

.auth-wrap { max-width: 360px; margin: 10vh auto; padding: 0 var(--pad); }

/* ============================================================= responsive */

@media (min-width: 760px) {
  .view { padding-bottom: var(--s6); }
  .tabbar {
    position: sticky; top: 0; max-width: 720px; margin: 0 auto;
    grid-template-columns: repeat(4, minmax(0, 160px));
    justify-content: center; border-top: 0;
    border-bottom: 1px solid var(--line-soft);
  }
  .tab { flex-direction: row; gap: var(--s2); font-size: 13.5px; }
  .tab .ti { font-size: 15px; }
  .timer-bar { bottom: 0; }
  .toast { bottom: 32px; }
  .tt { grid-template-columns: repeat(2, 1fr); }
  .grid-cards { grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); }
}

/* Print: any screen saves as a clean PDF from the browser. */
@media print {
  .topbar, .tabbar, .timer-bar, .toast, .back, .btn, .icon-btn,
  .search-trigger, .next-step { display: none !important; }
  body { background: #fff; color: #000; font-size: 11pt; }
  .view { max-width: none; padding: 0; }
  .card, .list, .row-item, .hero { background: #fff !important; border-color: #ccc !important; }
  .prose pre.code { background: #f5f5f5 !important; }
  a { color: #000; text-decoration: underline; }
  a[href^='http']::after { content: ' (' attr(href) ')'; font-size: 9pt; color: #555; }
}

/* ==================================================== legacy class aliases
 *
 * The rebuild renamed the core components (.item → .row-item, .stats →
 * .stat-row, .chip → .pill, .empty → .empty-state). Screens written before
 * the rebuild still use the old names, and an unstyled <button> falls back
 * to the browser's grey default — which is exactly how it looked.
 *
 * Rather than a risky sweep across a dozen files, the old names are mapped
 * onto the new system here. Same visual result, one place, no behaviour
 * change. New code should use the names in the sections above.
 */

.item {
  display: flex; align-items: center; gap: var(--s3);
  width: 100%; min-height: var(--tap);
  padding: var(--s3) var(--s4);
  background: none; border: 0; text-align: left; cursor: pointer;
  color: inherit; transition: background .12s;
}
.item:hover { background: var(--surface-2); }
.item.static { cursor: default; }
.item.static:hover { background: none; }

.chip {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 4px 10px; border-radius: 999px;
  font-size: 12px; font-weight: 600; white-space: nowrap;
  background: var(--surface-2); color: var(--fg-dim);
}
.chip.accent { background: var(--accent-soft); color: var(--accent); }
.chip.green  { background: var(--green-soft); color: var(--green); }
.chip.amber  { background: var(--amber-soft); color: var(--amber); }
.chip.red    { background: var(--red-soft); color: var(--red); }
.chip.purple { background: color-mix(in srgb, var(--accent-2) 18%, transparent); color: var(--accent-2); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip-btn { cursor: pointer; border: 1px solid transparent; min-height: 32px; }
.chip-btn:hover { border-color: var(--fg-faint); }
.chip-btn.on { background: var(--accent); color: var(--on-accent); }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(78px, 1fr)); gap: var(--s2); }

.empty { padding: var(--s6) var(--s4); text-align: center; color: var(--fg-faint); font-size: 14px; }

.card.tight { padding: var(--s3); }

/* Plan rows predate .row-item; keep them looking identical. */
.plan-item {
  display: flex; gap: var(--s3); align-items: flex-start;
  padding: var(--s3) var(--s4); width: 100%;
  background: none; border: 0; text-align: left; cursor: pointer; color: inherit;
}
.plan-item:hover { background: var(--surface-2); }
.plan-icon {
  flex: none; width: 30px; height: 30px; border-radius: var(--r-sm);
  display: grid; place-items: center; font-size: 14px;
  background: var(--surface-2); color: var(--fg-dim);
}
.plan-why { font-size: 12.5px; color: var(--fg-faint); margin-top: 2px; }

.act {
  text-transform: none; letter-spacing: 0; font-size: 13px;
  color: var(--accent); cursor: pointer; background: none; border: 0;
}


/* ============================================================ goal steps
 * A step is a checkbox, a title, why it is there, when it is due, and one
 * way in. Everything else about it is noise on a phone. */

.step-item {
  display: flex; gap: var(--s3); align-items: flex-start;
  padding: var(--s3) 0; border-bottom: 1px solid var(--line-soft);
}
.step-item:last-child { border-bottom: 0; }
.step-tick {
  flex: none; width: 26px; height: 26px; margin-top: 2px;
  border-radius: 50%; border: 2px solid var(--line);
  background: none; color: var(--on-accent); cursor: pointer;
  font-size: 14px; line-height: 1; display: grid; place-items: center;
}
.step-item.done .step-tick { background: var(--green); border-color: var(--green); }
.step-item.done .step-title { color: var(--fg-faint); text-decoration: line-through; }
.step-body { flex: 1; min-width: 0; }
.step-title { font-size: 14.5px; font-weight: 580; line-height: 1.45; }
.step-detail {
  margin-top: 4px; font-size: 13px; color: var(--fg-dim); line-height: 1.55;
}
.step-detail p:first-child { margin-top: 0; }
.step-meta {
  display: flex; gap: var(--s3); flex-wrap: wrap;
  margin-top: 6px; font-size: 11.5px;
}
.step-meta .late { color: var(--amber); font-weight: 600; }
.step-acts { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }

.btn.xs { min-height: 30px; padding: 4px 10px; font-size: 12.5px; }
.btn.ghost { background: none; border-color: transparent; color: var(--fg-faint); }
.btn.ghost:hover { border-color: var(--line); color: var(--fg-dim); }
.btn.danger { border-color: var(--red); color: var(--red); }

/* Section tabs inside a screen. Same control as .seg, full width. */
.seg.tabs { display: flex; width: 100%; }
.seg.tabs > button { flex: 1; }


/* ========================================================= depth bar
 * The end of a lesson. Two failure modes get an answer here: it did not
 * land, and it did and she wants more. */

.depth-bar {
  margin: var(--s6) 0 var(--s4); padding: var(--s4);
  background: var(--surface); border: 1px solid var(--line-soft);
  border-radius: var(--r);
}
.depth-q { font-size: 14px; font-weight: 620; margin-bottom: var(--s3); }
.depth-opts { display: grid; gap: var(--s2); grid-template-columns: 1fr 1fr; }
@media (max-width: 420px) { .depth-opts { grid-template-columns: 1fr; } }
.depth-opt {
  display: flex; flex-direction: column; gap: 2px; text-align: left;
  min-height: 52px; padding: var(--s3);
  background: var(--bg); border: 1px solid var(--line);
  border-radius: var(--r-sm); cursor: pointer;
}
.depth-opt:hover { border-color: var(--accent); }
.depth-opt:disabled { opacity: .6; cursor: default; }
.depth-label { font-size: 13.5px; font-weight: 600; color: var(--fg); }
.depth-why { font-size: 11.5px; color: var(--fg-faint); }

.step-more > summary {
  margin-top: 5px; font-size: 11.5px; color: var(--fg-faint);
  cursor: pointer; list-style: none;
}
.step-more > summary::-webkit-details-marker { display: none; }
.step-more > summary::before { content: '▸ '; }
.step-more[open] > summary::before { content: '▾ '; }


/* ------------------------------------------------- phone-sized touch targets
 * She uses this on a phone, standing in a corridor. Anything she is meant to
 * tap gets a real target even when the visible chip is small — the padding
 * is invisible, the miss is not. */

@media (pointer: coarse) {
  .step-tick { width: 34px; height: 34px; }
  .pill-btn, .chip-btn, .sec-act {
    min-height: 38px; padding-top: 8px; padding-bottom: 8px;
  }
  .sec-act { padding-left: 10px; padding-right: 10px; }
}


/* ================================================================== ask
 * A conversation, not a search result list. Her turns sit right, the
 * tutor's left and full width, because the tutor's are the long ones. */

.chat-log {
  display: flex; flex-direction: column; gap: var(--s3);
  min-height: 30vh; margin-bottom: var(--s4);
}
.chat-intro { padding: var(--s4) 0; }
.msg { max-width: 100%; }
.msg-body {
  padding: var(--s3) var(--s4); border-radius: var(--r);
  line-height: 1.6; overflow-wrap: anywhere;
}
.msg.mine { align-self: flex-end; max-width: 85%; }
.msg.mine .msg-body {
  background: var(--accent); color: var(--on-accent);
  border-bottom-right-radius: 4px; font-size: 14.5px;
}
.msg.tutor .msg-body {
  background: var(--surface); border: 1px solid var(--line-soft);
  border-bottom-left-radius: 4px;
}
.msg.tutor .msg-body > :first-child { margin-top: 0; }
.msg.tutor .msg-body > :last-child { margin-bottom: 0; }
.msg.pending .msg-body { color: var(--fg-faint); }
.msg-acts { margin-top: 4px; padding-left: 4px; }

/* The composer sticks above the tab bar so the send button is always reachable
   with a thumb, however long the conversation gets. */
.chat-box {
  position: sticky; bottom: calc(70px + env(safe-area-inset-bottom));
  z-index: 20; padding: var(--s3);
  background: var(--bg); border: 1px solid var(--line);
  border-radius: var(--r); box-shadow: var(--shadow-lg);
}
.chat-box .tier-picker { margin: var(--s2) 0; }
.btn.grow { flex: 1; }

/* ============================================================== visuals */

.visual {
  margin-bottom: var(--s4); padding: var(--s4);
  background: var(--surface); border: 1px solid var(--line-soft);
  border-radius: var(--r);
}
.visual-head { display: flex; justify-content: space-between; gap: var(--s3); }
.visual-title { font-size: 14.5px; font-weight: 620; }
.visual-caption {
  margin: 4px 0 var(--s3); font-size: 12.5px; color: var(--fg-dim);
  line-height: 1.5;
}
/* The SVG inherits the page colour, which is how one diagram works in five
   themes without being regenerated. */
.visual-figure { overflow-x: auto; color: var(--fg); }
.visual-figure svg { max-width: 100%; height: auto; display: block; }
.visual-figure img { max-width: 100%; height: auto; border-radius: var(--r-sm); }

/* Handwritten notes: ruled paper, a margin line, and a hand that is not the
   body font. Nothing is downloaded — these are all system faces, so it still
   looks like notes with no network. */
.sketch {
  --rule: 26px;
  padding: var(--s4) var(--s4) var(--s4) 42px;
  font-family: 'Bradley Hand', 'Segoe Print', 'Chalkboard SE', 'Comic Sans MS',
               ui-rounded, cursive;
  font-size: 15.5px; line-height: var(--rule);
  background-image:
    linear-gradient(to bottom, transparent calc(var(--rule) - 1px),
                    color-mix(in srgb, var(--accent) 22%, transparent) 0);
  background-size: 100% var(--rule);
  border-left: 2px solid color-mix(in srgb, var(--red) 45%, transparent);
  border-radius: 0 var(--r) var(--r) 0;
}
.sketch h2 {
  font-size: 17px; font-weight: 700; margin: var(--rule) 0 0;
  line-height: var(--rule); text-decoration: underline;
  text-underline-offset: 3px;
}
.sketch h2:first-child { margin-top: 0; }
.sketch p, .sketch li { line-height: var(--rule); margin: 0; }
.sketch ul, .sketch ol { margin: 0; padding-left: 22px; }
.sketch strong { background: color-mix(in srgb, var(--amber) 30%, transparent); }
.sketch code {
  font-family: ui-monospace, monospace; font-size: 13.5px;
  background: color-mix(in srgb, var(--accent) 12%, transparent);
}
.sketch blockquote {
  margin: 0; padding-left: var(--s3);
  border-left: 3px solid var(--amber); font-weight: 600;
}
.sketch pre.code { line-height: 1.4; font-size: 12.5px; }


/* ====================================================== a doubt, in place
 * The most common moment to get stuck is halfway down a lesson, and the most
 * common response is to keep reading anyway. */

.selection-ask {
  position: absolute; z-index: 60;
  padding: 7px 13px; min-height: 34px;
  background: var(--accent); color: var(--on-accent);
  border: 0; border-radius: 999px;
  font-size: 13px; font-weight: 620; cursor: pointer;
  box-shadow: var(--shadow-lg);
}

.chat-from {
  display: inline-flex; align-items: center; gap: 6px;
  margin-bottom: var(--s2); padding: 4px 6px 4px 10px;
  background: var(--accent-soft); color: var(--accent);
  border-radius: 999px; font-size: 11.5px; font-weight: 600;
}
.chat-from-x {
  width: 20px; height: 20px; padding: 0; line-height: 1;
  background: none; border: 0; color: inherit; cursor: pointer; opacity: .7;
}
.chat-from-x:hover { opacity: 1; }

/* ============================================== writing answers for marks */

.exam-question {
  border-left: 3px solid var(--accent);
}
.answer-sheet {
  min-height: 40vh; line-height: 1.7; font-size: 15px;
  /* Faint rules, so the box reads as an answer sheet rather than a comment
     field, and the length of what she has written is visible at a glance. */
  background-image: linear-gradient(to bottom, transparent 27px,
                    color-mix(in srgb, var(--fg) 7%, transparent) 28px);
  background-size: 100% 28px;
}
.score { font-size: 34px; font-weight: 700; letter-spacing: -.03em; }
.score-of { font-size: 18px; font-weight: 500; color: var(--fg-faint); }
.missing { margin: 0; padding-left: 20px; }
.missing li {
  margin-bottom: 7px; font-size: 13.5px; line-height: 1.55;
  color: var(--fg-dim);
}
.missing li::marker { color: var(--amber); }
.answer-back {
  padding-left: var(--s3); border-left: 2px solid var(--line);
  color: var(--fg-dim);
}


/* ================================================= marking up what you read
 * Four colours, four meanings. "Did not follow this" is the one that earns
 * its place: it turns a vague unease into a list to come back to. */

.selection-bar {
  position: absolute; z-index: 60; display: flex; align-items: center; gap: 6px;
  padding: 5px 6px;
  background: var(--fg); border-radius: 999px; box-shadow: var(--shadow-lg);
}
.sel-btn {
  min-height: 30px; padding: 5px 12px;
  background: none; border: 0; border-radius: 999px;
  color: var(--bg); font-size: 13px; font-weight: 620; cursor: pointer;
}
.sel-hl {
  width: 26px; height: 26px; padding: 0;
  border: 2px solid transparent; border-radius: 50%; cursor: pointer;
}
.sel-hl:hover { border-color: var(--bg); }
.sel-hl.yellow { background: #e8c33c; }
.sel-hl.red    { background: #e06c5a; }
.sel-hl.green  { background: #5fb37a; }
.sel-hl.blue   { background: #5b8ede; }

mark.hl {
  padding: 1px 0; border-radius: 2px; cursor: pointer;
  background: transparent; color: inherit;
  box-shadow: inset 0 -0.6em 0 color-mix(in srgb, var(--hl) 45%, transparent);
}
mark.hl.yellow { --hl: #e8c33c; }
mark.hl.red    { --hl: #e06c5a; }
mark.hl.green  { --hl: #5fb37a; }
mark.hl.blue   { --hl: #5b8ede; }

/* ==================================================== files and secrets */

.drop {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: var(--s6) var(--s4); text-align: center; cursor: pointer;
  border: 1px dashed var(--line); border-radius: var(--r);
}
.drop:hover { border-color: var(--accent); }
.drop-icon { font-size: 26px; color: var(--fg-faint); }
.drop-main { font-size: 14.5px; font-weight: 620; }
.drop-sub { font-size: 12px; color: var(--fg-faint); max-width: 34ch; line-height: 1.5; }

.secret-out:not(:empty) { margin-top: 8px; }
.secret-value {
  margin: 0 0 6px; padding: var(--s2) var(--s3);
  background: var(--surface-2); border-radius: var(--r-sm);
  font-family: ui-monospace, monospace; font-size: 13px;
  white-space: pre-wrap; overflow-wrap: anywhere;
}
.row-why.amber { color: var(--amber); }

.lesson-visual { margin: var(--s6) 0 0; border-left: 3px solid var(--accent); }


/* ================================================= a sheet from the bottom
 * For a choice that should not take her off the screen she is on. */

.sheet {
  position: fixed; inset: 0; z-index: 70;
  display: flex; align-items: flex-end; justify-content: center;
  background: color-mix(in srgb, #000 45%, transparent);
  backdrop-filter: blur(2px);
}
.sheet[hidden] { display: none; }
.sheet-panel {
  width: 100%; max-width: 520px;
  padding: var(--s4) var(--s4) calc(var(--s4) + env(safe-area-inset-bottom));
  background: var(--bg);
  border: 1px solid var(--line); border-bottom: 0;
  border-radius: var(--r-lg) var(--r-lg) 0 0;
  box-shadow: var(--shadow-lg);
  max-height: 85vh; overflow-y: auto;
}
.sheet-title {
  font-size: 16px; font-weight: 640; margin-bottom: var(--s3);
}
.sheet .list { margin-bottom: var(--s3); }

/* A swatch that actually shows the theme, rather than naming it. */
.swatch {
  width: 26px; height: 26px; border-radius: 50%;
  border: 1px solid var(--line);
}
.swatch.dark     { background: linear-gradient(135deg, #0d1117 50%, #7c9cf5 50%); }
.swatch.light    { background: linear-gradient(135deg, #ffffff 50%, #4a6cf7 50%); }
.swatch.paper    { background: linear-gradient(135deg, #faf6ef 50%, #b07d4a 50%); }
.swatch.midnight { background: linear-gradient(135deg, #000000 50%, #6ea8fe 50%); }
.swatch.auto     { background: linear-gradient(135deg, #0d1117 50%, #ffffff 50%); }

/* A due routine should look different from one that is merely listed. */
.item.routine.due { border-left: 2px solid var(--amber); padding-left: var(--s3); }


/* ============================================== saying why it did not work
 * A toast is for a glance. A failure needs somewhere to sit until it is read,
 * because the alternative — which is what used to happen — is a button that
 * appears to do nothing at all. */

.failure {
  display: flex; align-items: flex-start; gap: var(--s3);
  margin: 0 var(--s4) var(--s3);
  padding: var(--s3) var(--s4);
  background: var(--red-soft); border: 1px solid var(--red);
  border-radius: var(--r); font-size: 13.5px; line-height: 1.55;
}
.failure-body { flex: 1; display: flex; flex-direction: column; gap: 2px; }
.failure-what { font-weight: 620; }
.failure-how { color: var(--fg-dim); font-size: 12.5px; }
.failure-x {
  flex: none; width: 30px; height: 30px; padding: 0;
  background: none; border: 0; color: inherit;
  font-size: 20px; line-height: 1; cursor: pointer; opacity: .7;
}
.failure-x:hover { opacity: 1; }


/* =========================================== what kind of day is this
 * The first question of the morning, because the answer changes the whole
 * plan. Given the full screen so it reads as a question rather than a
 * setting she can ignore. */

.day-ask { padding: var(--s4) 0; }
.day-ask-q {
  font-size: 20px; font-weight: 660; letter-spacing: -.02em;
  margin-bottom: var(--s1);
}
.day-ask-why {
  margin: 0 0 var(--s4); font-size: 13.5px; color: var(--fg-dim);
  line-height: 1.55; max-width: 40ch;
}

/* Once answered it shrinks to a chip she can tap to change. */
.day-chip {
  display: inline-flex; align-items: center; gap: 7px;
  margin-bottom: var(--s3); padding: 5px 12px;
  background: var(--surface); border: 1px solid var(--line-soft);
  border-radius: 999px;
  font-size: 12.5px; font-weight: 580; color: var(--fg-dim); cursor: pointer;
}
.day-chip:hover { border-color: var(--accent); color: var(--fg); }
.day-chip-change {
  color: var(--accent); text-decoration: underline; text-underline-offset: 2px;
}

/* A link that is a button, because it does something rather than going
   somewhere new in the browser's sense. */
.linkish {
  padding: 0; background: none; border: 0;
  color: var(--accent); font: inherit; cursor: pointer;
  text-decoration: underline; text-underline-offset: 2px;
}

/* A packing row: the tick fills the row, the remove sits out of the way. */
.pack-row { display: flex; align-items: center; gap: var(--s2); }
.pack-row .check { flex: 1; margin: 0; }
.field-row .field.grow { flex: 1; }


/* ================================================== marking up a page
 * A pen, four colours, a note and an eraser. On a phone this is what
 * marking up actually feels like — tapping lines, not fighting with the
 * text-selection handles. */

.annotate-bar {
  position: fixed; left: 0; right: 0; z-index: 55;
  bottom: calc(66px + env(safe-area-inset-bottom));
  padding: var(--s3) var(--s4) var(--s2);
  background: var(--bg); border-top: 1px solid var(--line);
  box-shadow: 0 -8px 24px color-mix(in srgb, #000 14%, transparent);
}
.ann-tools {
  display: flex; align-items: center; gap: var(--s2);
  max-width: 520px; margin: 0 auto;
}
.ann-swatch {
  width: 30px; height: 30px; padding: 0; flex: none;
  border: 2px solid transparent; border-radius: 50%; cursor: pointer;
}
.ann-swatch.on { border-color: var(--fg); transform: scale(1.12); }
.ann-swatch.yellow { background: #e8c33c; }
.ann-swatch.red    { background: #e06c5a; }
.ann-swatch.green  { background: #5fb37a; }
.ann-swatch.blue   { background: #5b8ede; }
.ann-sep { width: 1px; height: 22px; background: var(--line); margin: 0 2px; }
.ann-tool {
  width: 32px; height: 32px; flex: none; padding: 0;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-sm); color: var(--fg-dim);
  font-size: 15px; cursor: pointer;
}
.ann-tool.on { background: var(--fg); color: var(--bg); border-color: var(--fg); }
.ann-done {
  margin-left: auto; min-height: 32px; padding: 6px 14px;
  background: var(--accent); color: var(--on-accent);
  border: 0; border-radius: var(--r-sm);
  font-size: 13px; font-weight: 620; cursor: pointer;
}
.ann-hint {
  max-width: 520px; margin: 6px auto 0;
  font-size: 11.5px; color: var(--fg-faint); text-align: center;
}

/* While the pen is on, sentences look tappable and links stop competing. */
.annotating .prose { padding-bottom: 90px; }
.annotating .ann-s { cursor: pointer; border-radius: 3px; }
.annotating .ann-s:hover {
  background: color-mix(in srgb, var(--accent) 14%, transparent);
}
.annotating .prose a { pointer-events: none; text-decoration-style: dotted; }
.annotating mark.hl { cursor: pointer; }

/* A mark carrying a note earns a visible tail, or the note is invisible. */
mark.hl.has-note { border-bottom: 2px dotted currentColor; }
#annotate-open.on { background: var(--accent); color: var(--on-accent); }
