/* ============================================================
   464 · THE SEMESTER LEDGER — style
   An engineer's notebook: graph paper, ink, highlighter, tape,
   stamps, and just enough wobble to feel alive.
   ============================================================ */

/* ---------- tokens ---------- */
:root {
  --font-hand: 'Caveat', 'Segoe Print', 'Bradley Hand', 'Comic Sans MS', cursive;
  --font-hand2: 'Kalam', 'Segoe Print', 'Comic Sans MS', cursive;
  --font-body: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --font-mono: 'Courier New', ui-monospace, monospace;

  --paper: #f4efe4;
  --paper-edge: #ece5d3;
  --card: #fffdf6;
  --ink: #26221c;
  --ink-soft: #6b6355;
  --rule-line: #cfc4a8;
  --rule-line-soft: #e4dcc8;

  --accent-yellow: #ffd75e;
  --accent-red: #d94f3d;
  --accent-green: #3d9a6c;
  --accent-blue: #3b6ea5;
  --accent-purple: #7d5ba6;
  --accent-orange: #d9822b;

  /* semantic inks — pass 4.5:1 on --card AND carry --on-fill as a fill */
  --c-good: #2f7d56;
  --c-warn: #a85f14;
  --c-bad: #c8402f;
  --c-blue: #3b6ea5;
  --c-purple: #7d5ba6;
  --on-fill: #ffffff;
  --on-yellow: #26221c;
  --mark-yellow: var(--accent-yellow);

  /* tints */
  --tint-yellow: rgba(255, 215, 94, 0.14);
  --tint-yellow-strong: rgba(255, 215, 94, 0.55);
  --tint-yellow-ring: rgba(255, 215, 94, 0.5);
  --tint-yellow-gate: rgba(255, 215, 94, 0.35);
  --tint-bad: rgba(200, 64, 47, 0.12);
  --tint-good: rgba(47, 125, 86, 0.07);
  --scrim: rgba(30, 26, 20, 0.45);
  --hm-1: rgba(59, 110, 165, 0.16);
  --hm-2: rgba(59, 110, 165, 0.38);
  --hm-3: rgba(59, 110, 165, 0.62);
  --hm-4: rgba(59, 110, 165, 0.9);

  --tape: rgba(255, 232, 140, 0.72);
  --shadow: 2px 3px 0 rgba(38, 34, 28, 0.14);
  --shadow-lift: 4px 6px 0 rgba(38, 34, 28, 0.16);
  --grain-opacity: 0.05;
  --stain: rgba(120, 80, 30, 0.07);
}

[data-theme="night"] {
  --paper: #191c22;
  --paper-edge: #14161b;
  --card: #22262e;
  --ink: #e9e3d3;
  --ink-soft: #9a9484;
  --rule-line: #3a404c;
  --rule-line-soft: #2a2f38;

  --accent-yellow: #e8c35a;
  --accent-red: #e06553;
  --accent-green: #55b98a;
  --accent-blue: #6fa3d8;
  --accent-purple: #a68ad0;
  --accent-orange: #e09a4f;

  --c-good: #55b98a;
  --c-warn: #e09a4f;
  --c-bad: #e06553;
  --c-blue: #6fa3d8;
  --c-purple: #a68ad0;
  --on-fill: #191c22;
  --on-yellow: #191c22;
  --mark-yellow: #8a6f22;

  --tint-yellow: rgba(232, 195, 90, 0.16);
  --tint-yellow-strong: rgba(232, 195, 90, 0.45);
  --tint-yellow-ring: rgba(232, 195, 90, 0.5);
  --tint-yellow-gate: rgba(232, 195, 90, 0.3);
  --tint-bad: rgba(224, 101, 83, 0.14);
  --tint-good: rgba(85, 185, 138, 0.1);
  --scrim: rgba(0, 0, 0, 0.55);
  --hm-1: rgba(111, 163, 216, 0.18);
  --hm-2: rgba(111, 163, 216, 0.4);
  --hm-3: rgba(111, 163, 216, 0.64);
  --hm-4: rgba(111, 163, 216, 0.92);

  --tape: rgba(200, 180, 100, 0.28);
  --shadow: 2px 3px 0 rgba(0, 0, 0, 0.4);
  --shadow-lift: 4px 6px 0 rgba(0, 0, 0, 0.45);
  --grain-opacity: 0.045;
  --stain: rgba(160, 120, 60, 0.05);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: var(--font-body);
  color: var(--ink);
  background-color: var(--paper);
  background-image:
    linear-gradient(var(--rule-line-soft) 1px, transparent 1px),
    linear-gradient(90deg, var(--rule-line-soft) 1px, transparent 1px),
    linear-gradient(var(--rule-line) 1.2px, transparent 1.2px),
    linear-gradient(90deg, var(--rule-line) 1.2px, transparent 1.2px);
  background-size: 26px 26px, 26px 26px, 130px 130px, 130px 130px;
  background-position: -1px -1px;
  display: flex;
  min-height: 100vh;
  line-height: 1.5;
  transition: background-color .3s;
}

/* paper grain */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 1;
  opacity: var(--grain-opacity);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2'/%3E%3C/filter%3E%3Crect width='160' height='160' filter='url(%23n)' opacity='1'/%3E%3C/svg%3E");
}

/* coffee stains */
.desk-stain {
  position: fixed;
  border-radius: 50%;
  pointer-events: none;
  z-index: 0;
  background:
    radial-gradient(circle, transparent 58%, var(--stain) 60%, var(--stain) 68%, transparent 70%),
    radial-gradient(circle, transparent 0%, var(--stain) 100%);
}
.stain-1 { width: 190px; height: 170px; right: 4vw; bottom: 8vh; transform: rotate(12deg); }
.stain-2 { width: 120px; height: 110px; left: 26vw; top: 62vh; transform: rotate(-20deg); opacity: .7; }

::selection { background: var(--accent-yellow); color: var(--on-yellow); }

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

/* ============================================================
   SIDEBAR — index tabs on the edge of the notebook
   ============================================================ */
.sidebar {
  width: 208px;
  flex-shrink: 0;
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 18px 0 14px 14px;
  z-index: 20;
  background: linear-gradient(90deg, var(--paper-edge) 0%, transparent 100%);
}

.brand {
  display: block;
  text-decoration: none;
  color: var(--ink);
  margin: 2px 0 14px 6px;
  transform: rotate(-2deg);
}
.brand-num {
  font-family: var(--font-hand);
  font-size: 52px;
  font-weight: 700;
  line-height: .9;
  display: block;
  background: linear-gradient(transparent 58%, var(--mark-yellow) 58%, var(--mark-yellow) 92%, transparent 92%);
  width: fit-content;
  padding: 0 4px;
}
.brand-sub {
  font-family: var(--font-hand2);
  font-size: 14px;
  color: var(--ink-soft);
  display: block;
  margin-top: 2px;
  transform: rotate(0.6deg);
}

#nav { display: flex; flex-direction: column; gap: 3px; }

.nav-tab {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px 12px 7px 14px;
  text-decoration: none;
  color: var(--ink);
  font-family: var(--font-hand2);
  font-size: 16.5px;
  border: 1.6px solid transparent;
  border-left: none;
  border-radius: 2px 14px 14px 2px;
  position: relative;
  transition: transform .12s ease, background .15s;
}
.nav-tab:hover { transform: translateX(3px); background: var(--tint-yellow); }
.nav-tab.active {
  background: var(--card);
  border-color: var(--ink);
  box-shadow: var(--shadow);
  font-weight: 700;
  transform: translateX(2px) rotate(-0.4deg);
}
.nav-tab.active::after {
  content: '';
  position: absolute;
  left: 10px; right: 10px; bottom: 3px;
  height: 7px;
  background: var(--accent-yellow);
  opacity: .75;
  transform: rotate(-0.5deg);
  z-index: -1;
}
/* grouped sidebar — one label per family, the digits never move */
.nav-group {
  margin: 14px 0 3px;
  padding: 0 14px;
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--ink-soft);
  opacity: .8;
  user-select: none;
}
.nav-group:first-child { margin-top: 0; }
.nav-icon { font-size: 17px; filter: saturate(.9); }
.nav-label { flex: 1; }
.nav-key {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--ink-soft);
  border: 1px solid var(--rule-line);
  border-radius: 4px;
  padding: 0 4px;
}

.sidebar-foot {
  margin-top: auto;
  padding: 8px 6px 0 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.foot-doodle {
  font-family: var(--font-hand);
  font-size: 20px;
  color: var(--ink-soft);
  transform: rotate(-3deg);
  width: fit-content;
  border-bottom: 1.5px dashed var(--rule-line);
}
.foot-doodle.small { font-size: 15px; transform: rotate(1.5deg); }

/* ============================================================
   MAIN COLUMN + TOPBAR
   ============================================================ */
.main-col {
  flex: 1;
  min-width: 0;
  padding: 0 clamp(14px, 4vw, 54px) 90px;
  max-width: 1180px;
  z-index: 5;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 15;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 0 10px;
  backdrop-filter: blur(3px);
}
.week-chip {
  font-family: var(--font-hand2);
  font-weight: 700;
  font-size: 15px;
  color: var(--card);
  background: var(--ink);
  border: none;
  border-radius: 255px 15px 225px 15px / 15px 225px 15px 255px;
  padding: 5px 16px;
  cursor: pointer;
  transform: rotate(-1.2deg);
  box-shadow: var(--shadow);
  letter-spacing: .5px;
}
.week-chip.ph-ramp { background: var(--c-good); color: var(--on-fill); }
.week-chip.ph-core { background: var(--c-blue); color: var(--on-fill); }
.week-chip.ph-buffer { background: var(--c-bad); color: var(--on-fill); }
.week-chip.ph-data { background: var(--c-purple); color: var(--on-fill); }
.week-chip.ph-frontend { background: var(--c-warn); color: var(--on-fill); }
.week-chip.ph-freeze { background: var(--ink); color: var(--paper); }
.week-chip.ph-exams { background: var(--c-bad); color: var(--on-fill); }

.topbar-rule {
  flex: 1;
  height: 0;
  border-top: 2px dashed var(--rule-line);
  transform: rotate(-0.15deg);
}
.topbar-motto {
  font-family: var(--font-hand);
  font-size: 18px;
  color: var(--ink-soft);
  transform: rotate(-0.8deg);
  white-space: nowrap;
}

/* ============================================================
   HEADERS & TYPE
   ============================================================ */
.view-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 20px;
  margin: 22px 0 18px;
  flex-wrap: wrap;
}
.kicker {
  font-family: var(--font-mono);
  font-size: 12.5px;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--ink-soft);
  margin: 0 0 4px;
}
.page-title {
  font-family: var(--font-hand);
  font-weight: 700;
  font-size: clamp(38px, 6vw, 60px);
  line-height: 1;
  margin: 0 0 8px;
  transform: rotate(-0.5deg);
}
.sub { margin: 0; max-width: 62ch; color: var(--ink-soft); font-size: 15px; }
.muted { color: var(--ink-soft); }
.small { font-size: 13px; }
.tiny { font-size: 12px; }
.good { color: var(--c-good); font-weight: 600; }
.hot { color: var(--c-bad); }
.blurb { font-style: italic; margin: 4px 0 10px; }

.sec-head { margin: 26px 0 12px; }
.sec-title {
  font-family: var(--font-hand);
  font-size: 34px;
  margin: 0;
  display: inline-block;
}
.mark {
  background: linear-gradient(transparent 55%, var(--mark-yellow) 55%, var(--mark-yellow) 90%, transparent 90%);
  padding: 0 6px;
}
.sec-sub { color: var(--ink-soft); font-size: 14px; }

/* ============================================================
   CARDS — hand-drawn edges, tape, tilt
   ============================================================ */
.card {
  background: var(--card);
  border: 1.8px solid var(--ink);
  border-radius: 255px 15px 225px 15px / 15px 225px 15px 255px;
  padding: 18px 20px 20px;
  box-shadow: var(--shadow);
  position: relative;
  margin: 14px 0;
  transition: transform .15s ease, box-shadow .15s ease;
}
.card:hover { box-shadow: var(--shadow-lift); }
.card-title {
  font-family: var(--font-hand);
  font-size: 27px;
  font-weight: 700;
  margin: 2px 0 10px;
  transform: rotate(-0.3deg);
  border-bottom: 2px dashed var(--rule-line);
  padding-bottom: 4px;
}

.tape::before {
  content: '';
  position: absolute;
  top: -11px;
  left: 22px;
  width: 84px;
  height: 24px;
  background: var(--tape);
  transform: rotate(-3.2deg);
  box-shadow: 0 1px 2px rgba(0, 0, 0, .12);
  border-left: 1px dashed rgba(0, 0, 0, .08);
  border-right: 1px dashed rgba(0, 0, 0, .08);
  z-index: 2;
}

/* stamps */
.stamp {
  display: inline-block;
  font-family: var(--font-hand2);
  font-weight: 700;
  letter-spacing: 2.5px;
  font-size: 13px;
  text-transform: uppercase;
  border: 2.5px double currentColor;
  border-radius: 8px;
  padding: 3px 10px 4px;
  transform: rotate(-5deg);
  opacity: .85;
  white-space: nowrap;
}
.stamp.ink { color: var(--ink); }
.stamp.hot { color: var(--c-bad); }
.stamp.warn { color: var(--c-warn); }
.stamp.good { color: var(--c-good); }
.stamp.ph-ramp { color: var(--c-good); }
.stamp.ph-core { color: var(--c-blue); }
.stamp.ph-buffer { color: var(--c-bad); }
.stamp.ph-data { color: var(--c-purple); }
.stamp.ph-frontend { color: var(--c-warn); }
.stamp.ph-freeze { color: var(--ink); }
.stamp.ph-exams { color: var(--c-bad); }

/* ============================================================
   TASK ROWS & CHECKS
   ============================================================ */
.task-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 7px 6px;
  border-radius: 8px;
  cursor: pointer;
  transition: background .12s;
}
.task-row:hover { background: var(--tint-yellow); }
.task-row.done .task-text {
  color: var(--ink-soft);
  text-decoration: line-through;
  text-decoration-color: var(--accent-green);
  text-decoration-thickness: 2px;
}
.task-text { flex: 1 1 200px; min-width: 140px; font-size: 14.5px; padding-top: 1px; }

.cbx {
  width: 21px; height: 21px;
  flex-shrink: 0;
  border: 2.2px solid var(--ink);
  border-radius: 42% 58% 55% 45% / 50% 45% 55% 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-top: 1px;
  background: transparent;
  transition: background .15s;
}
.cbx.on {
  background: var(--c-good);
  border-color: var(--c-good);
  color: var(--on-fill);
  transform: rotate(-4deg);
}
.check { width: 16px; height: 16px; overflow: visible; }
.check-path {
  stroke-dasharray: 30;
  stroke-dashoffset: 30;
  animation: draw .35s ease forwards;
}
@keyframes draw { to { stroke-dashoffset: 0; } }

.cat-head {
  font-family: var(--font-hand2);
  font-size: 16px;
  margin: 16px 0 4px;
  color: var(--ink-soft);
  letter-spacing: .4px;
}

/* progress */
.prog-line { display: flex; align-items: center; gap: 10px; margin: 8px 0; }
.prog-track {
  flex: 1;
  height: 12px;
  border: 1.6px solid var(--ink);
  border-radius: 225px 15px 255px 15px / 15px 255px 15px 225px;
  overflow: hidden;
  background: var(--paper);
}
.prog-track.slim { height: 8px; }
.prog-fill {
  height: 100%;
  background: repeating-linear-gradient(-45deg, var(--accent-green) 0 6px, #35895f 6px 12px);
  transition: width .4s ease;
}
.prog-num { font-family: var(--font-mono); font-size: 12.5px; color: var(--ink-soft); }

/* ============================================================
   BUTTONS, INPUTS, CHIPS
   ============================================================ */
.btn {
  font-family: var(--font-hand2);
  font-size: 16px;
  font-weight: 700;
  color: var(--ink);
  background: var(--card);
  border: 2px solid var(--ink);
  border-radius: 225px 15px 255px 15px / 15px 255px 15px 225px;
  padding: 7px 18px 8px;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
  box-shadow: var(--shadow);
  transition: transform .1s, box-shadow .1s;
}
.btn:hover { transform: translate(-1px, -1px); box-shadow: var(--shadow-lift); }
.btn:active { transform: translate(1px, 1px); box-shadow: none; }
.btn:disabled { opacity: .4; cursor: default; transform: none; box-shadow: none; }
.btn.primary { background: var(--accent-yellow); color: var(--on-yellow); }
.btn.danger { background: var(--c-bad); color: var(--on-fill); border-color: var(--c-bad); }
.btn.good { background: var(--c-good); color: var(--on-fill); border-color: var(--c-good); }
.btn.small { font-size: 13.5px; padding: 3px 10px 4px; }
.btn.big { font-size: 22px; padding: 12px 30px; }

.icon-btn {
  background: none;
  border: none;
  color: var(--ink-soft);
  font-size: 16px;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 6px;
}
.icon-btn:hover { color: var(--c-bad); background: var(--tint-bad); }

.inp, .sel {
  font-family: var(--font-body);
  font-size: 14px;
  color: var(--ink);
  background: var(--paper);
  border: 1.8px solid var(--ink);
  border-radius: 10px 4px 10px 4px;
  padding: 7px 10px;
  min-width: 0;
  width: auto;
}
.inp:focus, .sel:focus {
  outline: 2px solid var(--ink);
  outline-offset: 1px;
  box-shadow: 0 0 0 4px var(--tint-yellow-strong);
}
textarea.inp { width: 100%; resize: vertical; font-size: 14px; }
.inp.big { font-size: 18px; padding: 10px 14px; }
.sel.small { font-size: 12.5px; padding: 3px 6px; }
.hours-in { width: 74px; }
.date-in { width: 150px; }
.pct-in { width: 74px; }
.search { width: 100%; font-size: 16px; }

.chip {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 11.5px;
  border: 1.4px solid var(--rule-line);
  border-radius: 20px;
  padding: 2px 9px;
  color: var(--ink-soft);
  background: var(--paper);
  white-space: nowrap;
}
.chip.est { border-color: var(--c-blue); color: var(--c-blue); }
.chip.ref { border-color: var(--c-purple); color: var(--c-purple); }
.chip-row { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }
.chip.tog {
  font-family: var(--font-hand2);
  font-size: 14px;
  cursor: pointer;
  border: 1.8px solid var(--ink);
  background: var(--card);
  border-radius: 20px;
  padding: 3px 12px 4px;
}
.chip.tog.on { background: var(--accent-yellow); color: var(--on-yellow); font-weight: 700; }

.field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-family: var(--font-hand2);
  font-size: 14px;
  color: var(--ink-soft);
  font-weight: 700;
}

.btn-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; align-items: center; }

.note-link {
  font-family: var(--font-hand2);
  font-size: 14.5px;
  color: var(--c-blue);
  text-decoration: none;
  border-bottom: 1.5px dashed var(--c-blue);
  display: inline-block;
  margin-top: 8px;
  cursor: pointer;
}
.note-link:hover { color: var(--c-bad); border-color: var(--c-bad); }

/* ============================================================
   QUICK LOG
   ============================================================ */
.quicklog {
  margin-top: 10px;
  padding: 10px 12px;
  border: 1.6px dashed var(--rule-line);
  border-radius: 12px;
  background: var(--paper);
}
.ql-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 8px; }
.ql-row .inp:not(.hours-in):not(.date-in) { flex: 1; min-width: 140px; }

/* ============================================================
   DASHBOARD
   ============================================================ */
.grid.dash {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(330px, 1fr));
  gap: 4px 18px;
  align-items: start;
}
.grid.courses {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(420px, 1fr));
  gap: 4px 18px;
  align-items: start;
}

.ring-wrap { position: relative; width: 150px; margin: 6px auto 10px; }
.ring { width: 100%; height: auto; display: block; }
.ring-fill { transition: stroke-dashoffset .6s ease; }
.ring-mid {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  pointer-events: none;
}
.ring-mid b { font-family: var(--font-hand); font-size: 32px; line-height: 1; }
.ring-mid span { font-size: 11px; color: var(--ink-soft); max-width: 110px; }

.blocks { display: flex; flex-direction: column; gap: 7px; margin: 4px 0 8px; }
.block-row { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.block-name { width: 108px; flex-shrink: 0; color: var(--ink-soft); }
.block-row .prog-track { flex: 1; }
.block-num { font-family: var(--font-mono); font-size: 11.5px; width: 76px; text-align: right; }

.big-num-row { display: flex; gap: 20px; margin: 6px 0 10px; flex-wrap: wrap; }
.big-num { display: flex; flex-direction: column; }
.big-num b { font-family: var(--font-hand); font-size: 40px; line-height: 1; }
.big-num span { font-size: 11.5px; color: var(--ink-soft); }

/* sticky notes */
.nags {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
  margin: 14px 0 4px;
}
.sticky-note {
  background: #fdf3b7;
  color: #3a3323;
  padding: 14px 16px 12px;
  font-family: var(--font-hand2);
  font-size: 15px;
  box-shadow: 3px 4px 8px rgba(0, 0, 0, .16);
  position: relative;
  border-radius: 2px 2px 12px 2px;
  margin: 8px 0;
}
[data-theme="night"] .sticky-note { background: #4c4526; color: #f0e9cf; }
.sticky-note p { margin: 0 0 6px; }
.sticky-note.warn { background: #fbd9a0; }
[data-theme="night"] .sticky-note.warn { background: #58401f; }
.sticky-note.hot { background: #f7b8ad; }
[data-theme="night"] .sticky-note.hot { background: #5b2f28; }
.sticky-note .note-link { color: inherit; border-color: currentColor; }
.nag { animation: note-in .35s ease both; }
@keyframes note-in {
  from { opacity: 0; transform: translateY(-8px) rotate(0deg); }
}

.alert-strip {
  background: var(--tint-bad);
  border: 1.8px solid var(--c-bad);
  border-radius: 10px 4px 10px 4px;
  color: var(--c-bad);
  font-size: 13.5px;
  padding: 8px 12px;
  margin: 8px 0;
  font-weight: 600;
}
.alert-strip.big { font-size: 15px; }

/* milestones */
.mile-next { display: flex; gap: 14px; align-items: flex-start; margin-bottom: 12px; }
.mile-count {
  font-family: var(--font-hand);
  font-size: 30px;
  background: var(--accent-yellow);
  color: var(--on-yellow);
  border: 1.6px solid var(--ink);
  border-radius: 55% 45% 50% 50% / 50% 55% 45% 50%;
  min-width: 66px;
  text-align: center;
  padding: 8px 6px;
  transform: rotate(-3deg);
  line-height: 1.1;
}
.mile-txt b { font-size: 15px; }
.mile-list { display: flex; flex-direction: column; gap: 5px; margin-top: 8px; }
.mile-dot-row { display: flex; gap: 9px; align-items: center; font-size: 13px; }
.mile-dot-row.past { color: var(--ink-soft); }
.mile-dot {
  width: 11px; height: 11px;
  border: 1.8px solid var(--ink);
  border-radius: 50% 45% 55% 50%;
  flex-shrink: 0;
}
.mile-dot.done { background: var(--c-good); border-color: var(--c-good); }
.mile-dot.now { background: var(--accent-yellow); animation: pulse 1.6s infinite; }
@keyframes pulse { 50% { transform: scale(1.25); } }

/* course pulse */
.pulse-list { display: flex; flex-direction: column; gap: 4px; }
.pulse-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  padding: 3px 4px;
  border-bottom: 1px dashed var(--rule-line);
}
.pulse-code { font-family: var(--font-mono); font-weight: 700; width: 66px; }
.pulse-name { flex: 1; color: var(--ink-soft); }
.pulse-pct { font-family: var(--font-mono); }
.pulse-pct.bad, .pct-flag.bad { color: var(--c-bad); font-weight: 700; }
.pulse-pct.warn, .pct-flag.warn { color: var(--c-warn); }
.pulse-pct.good, .pct-flag.good { color: var(--c-good); }
.pulse-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--rule-line); }
.pulse-dot.bad { background: var(--c-bad); }
.pulse-dot.warn { background: var(--c-warn); }
.pulse-dot.good { background: var(--c-good); }

/* habits */
.habit-row { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0; }
.habit-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border: 1.8px solid var(--ink);
  border-radius: 22px;
  padding: 5px 13px 6px;
  font-size: 13.5px;
  font-family: var(--font-hand2);
  cursor: pointer;
  background: var(--card);
  transition: background .15s;
}
.habit-chip.on { background: var(--c-good); color: var(--on-fill); border-color: var(--c-good); }
.habit-chip input { accent-color: var(--c-good); }
.counter-row { display: flex; gap: 18px; font-size: 14px; margin: 6px 0; color: var(--ink-soft); }
.counter b { font-family: var(--font-hand); font-size: 24px; color: var(--ink); margin-right: 2px; }

blockquote.pred {
  font-family: var(--font-hand);
  font-size: 22px;
  margin: 8px 0;
  padding-left: 14px;
  border-left: 4px solid var(--accent-yellow);
}

/* quote card + mascot */
.quote-card {
  display: flex;
  gap: 18px;
  align-items: center;
  max-width: 760px;
}
.mascot { width: 58px; height: 58px; flex-shrink: 0; animation: bob 3.4s ease-in-out infinite; }
@keyframes bob { 50% { transform: translateY(-5px) rotate(2deg); } }
.quote-card blockquote {
  font-family: var(--font-hand);
  font-size: 26px;
  margin: 0;
  line-height: 1.15;
}
.quote-card cite { font-size: 12.5px; color: var(--ink-soft); font-style: normal; display: block; margin-top: 6px; }

/* ============================================================
   CHARTS
   ============================================================ */
.chart { width: 100%; height: auto; margin: 6px 0; }
.chart-label { font-size: 9.5px; fill: var(--ink-soft); font-family: var(--font-mono); }
.chart-value { font-size: 9px; fill: var(--ink); font-family: var(--font-mono); font-weight: bold; }
.bar { transition: opacity .2s; }
.bar:hover { opacity: 1 !important; }

/* ============================================================
   TIMELINE SPINE
   ============================================================ */
.spine { position: relative; margin: 20px 0 0; padding-left: 54px; }
.spine::before {
  content: '';
  position: absolute;
  left: 21px;
  top: 8px;
  bottom: 8px;
  border-left: 3px solid var(--ink);
  transform: rotate(0.2deg);
  opacity: .75;
}
.spine-week { display: block; position: relative; text-decoration: none; color: inherit; margin-bottom: 6px; }
.spine-node {
  position: absolute;
  left: -54px;
  top: 18px;
  width: 44px;
  height: 44px;
  border-radius: 52% 48% 47% 53% / 48% 52% 48% 52%;
  border: 2.4px solid var(--ink);
  background: var(--card);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-hand);
  font-size: 22px;
  font-weight: 700;
  z-index: 2;
}
.spine-node.ph-ramp { background: var(--c-good); color: var(--on-fill); }
.spine-node.ph-core { background: var(--c-blue); color: var(--on-fill); }
.spine-node.ph-buffer { background: var(--c-bad); color: var(--on-fill); }
.spine-node.ph-data { background: var(--c-purple); color: var(--on-fill); }
.spine-node.ph-frontend { background: var(--c-warn); color: var(--on-fill); }
.spine-node.ph-freeze { background: var(--ink); color: var(--paper); }
.spine-node.ph-exams { background: var(--c-bad); color: var(--on-fill); }

.spine-week .spine-card { margin: 10px 0; }
.spine-week.current .spine-card { border-width: 3px; box-shadow: 0 0 0 4px var(--tint-yellow-ring), var(--shadow-lift); }
.spine-week.past .spine-card { opacity: .82; }
.spine-week:hover .spine-card { transform: rotate(0deg) translateX(4px) !important; }
.spine-top { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.spine-top h3 { font-family: var(--font-hand); font-size: 26px; margin: 0; }
.dates { font-family: var(--font-mono); font-size: 11.5px; color: var(--ink-soft); margin: 2px 0 6px; }
.you-are-here {
  position: absolute;
  right: -6px;
  top: -14px;
  font-family: var(--font-hand);
  font-size: 20px;
  color: var(--c-bad);
  transform: rotate(4deg);
}

/* ============================================================
   WEEK VIEW
   ============================================================ */
.week-nav {
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
  margin: 12px 0;
  flex-wrap: wrap;
}
.week-layout { display: grid; grid-template-columns: 1.6fr 1fr; gap: 20px; align-items: start; }
.week-rail { position: sticky; top: 64px; }

/* ============================================================
   LEDGER & LOG ROWS
   ============================================================ */
.ledger-layout { display: grid; grid-template-columns: 1.4fr 1fr; gap: 20px; align-items: start; }
.log-list { display: flex; flex-direction: column; }
.log-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 4px;
  border-bottom: 1px dashed var(--rule-line);
  font-size: 13.5px;
  flex-wrap: wrap;
}
.log-row.slim { font-size: 13px; }
.log-block {
  font-family: var(--font-mono);
  font-size: 11px;
  text-transform: uppercase;
  border-radius: 4px;
  padding: 2px 7px;
  color: var(--on-fill);
  background: var(--ink-soft);
}
.log-block.courses { background: var(--c-blue); }
.log-block.project { background: var(--c-purple); }
.log-block.standing { background: var(--c-good); }
.log-block.classes { background: var(--ink); }
.log-hours { font-family: var(--font-mono); }
.log-note { flex: 1; color: var(--ink-soft); min-width: 80px; }

.stat-list { padding-left: 18px; margin: 8px 0; font-size: 14px; }
.stat-list li { margin: 4px 0; }
.stat-list b { font-family: var(--font-hand); font-size: 21px; }

/* ============================================================
   SLEEP
   ============================================================ */
.sleep-layout { display: grid; grid-template-columns: 1.3fr 1fr; gap: 20px; align-items: start; }
.ramp-list { display: flex; flex-direction: column; gap: 8px; }
.ramp-row {
  display: grid;
  grid-template-columns: 70px 58px 1fr;
  gap: 10px;
  align-items: center;
  padding: 8px 10px;
  border: 1.6px dashed var(--rule-line);
  border-radius: 10px;
}
.ramp-row.now { border: 2px solid var(--c-good); background: var(--tint-good); }
.ramp-tgt { font-family: var(--font-hand); font-size: 24px; }
.tbl { display: flex; flex-direction: column; }
.tbl-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(90px, 1fr));
  gap: 8px;
  padding: 6px 4px;
  border-bottom: 1px dashed var(--rule-line);
  font-size: 13px;
}
.tbl-row.good { color: var(--c-good); }
.tbl-row.bad { color: var(--c-bad); }

/* ============================================================
   COURSES
   ============================================================ */
.trig-card { max-width: 900px; }
.trig-list { display: flex; flex-direction: column; gap: 6px; margin: 8px 0; }
.trig-row {
  display: grid;
  grid-template-columns: 86px 1.1fr 1.4fr;
  gap: 10px;
  font-size: 13px;
  padding: 7px 10px;
  border-left: 4px solid var(--rule-line);
  background: var(--paper);
  border-radius: 0 8px 8px 0;
}
.trig-row.armed { border-left-color: var(--c-bad); }
.trig-when { font-family: var(--font-hand2); font-weight: 700; }
.trig-act { color: var(--ink-soft); }

.course-meta { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; margin-bottom: 6px; }
.pct-row, .paper-row, .practice-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin: 8px 0;
}
.pct-flag { font-family: var(--font-hand2); font-size: 14px; font-weight: 700; }
.practice-log { margin: 6px 0; max-height: 150px; overflow-y: auto; }
.muted.hot { color: var(--c-bad); }

/* ============================================================
   PROJECT
   ============================================================ */
.arch {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
  padding: 10px 0;
}
.arch-box {
  border: 2.2px solid var(--ink);
  border-radius: 12px 4px 12px 4px;
  padding: 10px 14px;
  text-align: center;
  background: var(--paper);
  min-width: 130px;
  box-shadow: var(--shadow);
  transform: rotate(-0.6deg);
}
.arch-box b { display: block; font-size: 14px; }
.arch-box span { font-size: 11.5px; color: var(--ink-soft); font-family: var(--font-mono); }
.arch-box.python { border-color: var(--accent-blue); }
.arch-box.pg { border-color: var(--c-good); background: var(--tint-good); }
.arch-box.spring { border-color: var(--accent-green); }
.arch-box.ng { border-color: var(--accent-red); }
.arch-arrow { font-family: var(--font-mono); font-size: 12px; color: var(--ink-soft); }
.arch-col { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.arch-note { font-size: 11.5px; color: var(--ink-soft); max-width: 210px; margin: 4px 0 0; text-align: center; font-style: italic; }

.gates {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 12px;
  margin: 16px 0;
}
.gate {
  border: 1.8px solid var(--rule-line);
  border-radius: 10px;
  padding: 10px 12px;
  display: flex;
  gap: 10px;
  background: var(--card);
  transform: rotate(-0.4deg);
}
.gate.past { opacity: .65; }
.gate.now { border: 2.4px solid var(--accent-yellow); box-shadow: 0 0 0 3px var(--tint-yellow-gate); }
.gate-week {
  font-family: var(--font-hand);
  font-size: 26px;
  font-weight: 700;
  color: var(--c-blue);
}
.gate b { font-size: 14px; }
.gate-line { font-style: italic; }

ul.crossed { list-style: none; padding-left: 4px; }
ul.crossed li {
  position: relative;
  padding: 5px 0 5px 24px;
  font-size: 13.5px;
  color: var(--ink-soft);
}
ul.crossed li::before {
  content: '\2717';
  position: absolute;
  left: 0;
  color: var(--c-bad);
  font-weight: 700;
}
ul.plain, ol.plain { padding-left: 20px; font-size: 14px; }
ul.plain li, ol.plain li { margin: 6px 0; }

/* ============================================================
   NOTES
   ============================================================ */
.notes-layout { display: grid; grid-template-columns: 1.5fr 1fr; gap: 20px; align-items: start; }
.note-form { display: flex; flex-direction: column; gap: 6px; }
.note-form .field { margin-top: 8px; }
.inline-field { display: flex; flex-direction: column; gap: 4px; }
.wc { font-family: var(--font-mono); font-size: 11px; color: var(--ink-soft); align-self: flex-end; }
.md-preview {
  background: var(--paper);
  border: 1.6px dashed var(--rule-line);
  border-radius: 10px;
  padding: 12px;
  font-family: var(--font-mono);
  font-size: 12px;
  white-space: pre-wrap;
  max-height: 400px;
  overflow-y: auto;
  margin-top: 12px;
}
.autofill { display: flex; flex-direction: column; gap: 6px; font-size: 13.5px; }
.af-row b { font-family: var(--font-hand2); }

.pred-list { display: flex; flex-direction: column; gap: 14px; }
.pred-item {
  border: 1.6px dashed var(--rule-line);
  border-radius: 10px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.pred-text { font-family: var(--font-hand); font-size: 20px; margin: 0; }
.cal-row { display: flex; gap: 14px; margin-top: 10px; font-family: var(--font-mono); font-size: 13px; }
.cal.good { color: var(--c-good); }
.cal.bad { color: var(--c-bad); }

/* ============================================================
   DRILLS
   ============================================================ */
.tab-row { display: flex; gap: 8px; flex-wrap: wrap; margin: 14px 0; }
.tab {
  font-family: var(--font-hand2);
  font-size: 16.5px;
  font-weight: 700;
  padding: 7px 16px 8px;
  border: 2px solid var(--ink);
  background: var(--card);
  border-radius: 14px 14px 2px 2px;
  cursor: pointer;
  transform: rotate(-0.5deg);
  box-shadow: var(--shadow);
}
.tab.on {
  background: var(--accent-yellow);
  color: var(--on-yellow);
  transform: rotate(0.4deg) translateY(-2px);
}
.bug-form { display: flex; flex-direction: column; gap: 8px; margin: 10px 0; }
.bug-list { display: flex; flex-direction: column; gap: 12px; }
.bug-item {
  border: 1.6px solid var(--rule-line);
  border-left: 5px solid var(--accent-red);
  border-radius: 4px 10px 10px 4px;
  padding: 10px 12px;
  background: var(--paper);
}
.bug-head { display: flex; gap: 8px; align-items: center; margin-bottom: 4px; }
.bug-item p { margin: 3px 0; font-size: 13.5px; }

.habits-grid {
  display: grid;
  grid-template-columns: minmax(150px, 1.4fr) repeat(7, 1fr);
  gap: 5px;
  align-items: center;
  margin: 6px 0;
}
.hab-cell { font-size: 13px; text-align: center; }
.hab-cell.head { font-family: var(--font-hand2); font-weight: 700; color: var(--ink-soft); }
.hab-cell.label { text-align: left; font-size: 13px; }
.hab-cell.box {
  height: 34px;
  border: 1.8px solid var(--ink);
  border-radius: 42% 58% 55% 45% / 50% 45% 55% 50%;
  background: transparent;
  cursor: pointer;
  font-size: 16px;
  color: var(--ink-soft);
  transition: background .15s;
}
.hab-cell.box.on { background: var(--c-good); border-color: var(--c-good); color: var(--on-fill); transform: rotate(-3deg); }

/* ============================================================
   CAREER
   ============================================================ */
.egypt-list { display: flex; flex-direction: column; gap: 12px; }
.egypt-item { border-bottom: 1px dashed var(--rule-line); padding-bottom: 10px; }
.egypt-item b { font-size: 14.5px; }
.app-form { display: grid; grid-template-columns: 1fr 1fr 1fr auto; gap: 8px; margin: 8px 0 14px; }
.app-list { display: flex; flex-direction: column; gap: 8px; }
.app-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border: 1.6px solid var(--rule-line);
  border-radius: 10px;
  flex-wrap: wrap;
  background: var(--paper);
}
.app-row.st-interview { border-color: var(--accent-blue); }
.app-row.st-offer { border-color: var(--accent-green); border-width: 2.4px; }
.app-row.st-rejected { opacity: .6; }
.app-side { display: flex; gap: 8px; align-items: center; }

/* ============================================================
   LIBRARY
   ============================================================ */
.lib-wrap { margin-top: 10px; }
.search-row { margin: 10px 0; }
.res-row {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 9px 6px;
  border-bottom: 1px dashed var(--rule-line);
}
.res-row.done { opacity: .55; }
.res-main { flex: 1; min-width: 0; }
.res-title {
  font-weight: 600;
  font-size: 14.5px;
  color: var(--c-blue);
  text-decoration: none;
  border-bottom: 1px solid transparent;
}
.res-title:hover { border-color: var(--c-blue); }
.res-row p { margin: 2px 0 0; }
.star {
  background: none;
  border: none;
  font-size: 19px;
  cursor: pointer;
  color: var(--rule-line);
  padding: 0 2px;
}
.star.on { color: var(--c-warn); }
.done-btn {
  font-family: var(--font-hand2);
  font-size: 12.5px;
  border: 1.4px solid var(--rule-line);
  background: transparent;
  color: var(--ink-soft);
  border-radius: 16px;
  padding: 3px 10px 4px;
  cursor: pointer;
  white-space: nowrap;
}
.done-btn.on { background: var(--c-good); color: var(--on-fill); border-color: var(--c-good); }

/* ============================================================
   SETTINGS / FOOTER
   ============================================================ */
.settings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 12px;
  margin: 8px 0;
}
.danger-card { border-color: var(--c-bad); }
.footer {
  margin: 44px 0 10px;
  padding-top: 14px;
  border-top: 2px dashed var(--rule-line);
  text-align: center;
  font-family: var(--font-hand2);
  font-size: 14px;
  color: var(--ink-soft);
}

/* ============================================================
   ONBOARDING
   ============================================================ */
.onboard { display: flex; justify-content: center; padding: 30px 0; }
.onboard-inner { max-width: 680px; width: 100%; }
.onboard-hero { text-align: center; margin-bottom: 10px; }
.logo-xl {
  font-family: var(--font-hand);
  font-size: clamp(90px, 18vw, 150px);
  line-height: .9;
  margin: 0;
  transform: rotate(-2deg);
  display: inline-block;
  background: linear-gradient(transparent 60%, var(--mark-yellow) 60%, var(--mark-yellow) 92%, transparent 92%);
  padding: 0 12px;
}
.tag { font-family: var(--font-hand2); font-size: 18px; color: var(--ink-soft); margin: 6px 0 0; transform: rotate(-0.8deg); }
.onboard-lead { font-size: 15px; max-width: 58ch; }
.rules-box {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 16px 0;
  padding: 14px 16px;
  border: 2px dashed var(--rule-line);
  border-radius: 12px;
  background: var(--paper);
}
.rule-row {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  cursor: pointer;
}
.rule-row input { margin-top: 4px; width: 17px; height: 17px; accent-color: var(--c-good); flex-shrink: 0; }
.rule-row b { font-size: 14.5px; }
.rule-row p { margin: 2px 0 0; }

/* ============================================================
   MODAL
   ============================================================ */
.modal-root {
  position: fixed;
  inset: 0;
  background: var(--scrim);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 20px;
  animation: fade-in .18s ease;
}
@keyframes fade-in { from { opacity: 0; } }
.modal { max-width: 460px; width: 100%; max-height: 85vh; overflow-y: auto; }
.modal.wide { max-width: 700px; }
.modal-x {
  position: absolute;
  top: 8px;
  right: 12px;
  background: none;
  border: none;
  font-size: 26px;
  cursor: pointer;
  color: var(--ink-soft);
  line-height: 1;
}
.modal-x:hover { color: var(--c-bad); }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 16px; }
.section-title { font-family: var(--font-hand); font-size: 30px; margin: 0 0 8px; }

/* ============================================================
   TOASTS
   ============================================================ */
#toasts {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: 340px;
}
.note-toast {
  background: #fdf3b7;
  color: #3a3323;
  font-family: var(--font-hand2);
  font-size: 14.5px;
  padding: 10px 16px;
  box-shadow: 3px 4px 10px rgba(0, 0, 0, .22);
  transform: rotate(-1.2deg) translateX(30px);
  opacity: 0;
  transition: all .3s ease;
  border-radius: 2px 2px 10px 2px;
}
[data-theme="night"] .note-toast { background: #4c4526; color: #f0e9cf; }
.note-toast.in { opacity: 1; transform: rotate(-1.2deg) translateX(0); }
.note-toast.warn { background: #fbd9a0; }
[data-theme="night"] .note-toast.warn { background: #58401f; }

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 1080px) {
  .week-layout, .ledger-layout, .sleep-layout, .notes-layout { grid-template-columns: 1fr; }
  .week-rail { position: static; }
}

@media (max-width: 900px) {
  body { flex-direction: column; }
  .sidebar {
    width: 100%;
    height: auto;
    position: sticky;
    top: 0;
    flex-direction: column;
    padding: 8px 10px 0;
    background: var(--paper-edge);
    border-bottom: 2px solid var(--ink);
    box-shadow: 0 2px 8px rgba(0, 0, 0, .08);
  }
  .brand { display: flex; align-items: baseline; gap: 10px; margin: 0 4px 6px; }
  .brand-num { font-size: 34px; }
  .brand-sub { font-size: 12px; }
  #nav {
    flex-direction: row;
    overflow-x: auto;
    gap: 6px;
    padding-bottom: 8px;
    scrollbar-width: thin;
  }
  .nav-tab {
    border: 1.6px solid var(--rule-line);
    border-radius: 18px;
    padding: 5px 12px 6px;
    white-space: nowrap;
    flex-shrink: 0;
  }
  .nav-tab.active { border-color: var(--ink); transform: none; }
  .nav-tab.active::after { display: none; }
  .nav-key { display: none; }
  .sidebar-foot { display: none; }
  .main-col { padding: 0 14px 80px; }
  .topbar { padding-top: 10px; }
  .topbar-motto { display: none; }
  .spine { padding-left: 44px; }
  .spine-node { left: -44px; width: 36px; height: 36px; font-size: 18px; }
  .spine::before { left: 17px; }
  .desk-stain { display: none; }
}

@media (max-width: 640px) {
  .grid.dash, .grid.courses { grid-template-columns: 1fr; }
  .app-form { grid-template-columns: 1fr; }
  .trig-row { grid-template-columns: 1fr; gap: 2px; }
  .habits-grid { grid-template-columns: minmax(90px, 1.2fr) repeat(7, 1fr); gap: 3px; }
  .hab-cell.label { font-size: 11px; }
  .page-title { font-size: 38px; }
  .quote-card blockquote { font-size: 21px; }
  #toasts { right: 10px; left: 10px; max-width: none; }
  .view-head { gap: 10px; }
  .arch { flex-direction: column; }
  .arch-arrow { transform: rotate(90deg); }
}

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

/* focus visibility */
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible,
textarea:focus-visible, [tabindex]:focus-visible, summary:focus-visible {
  outline: 3px solid var(--c-blue);
  outline-offset: 2px;
}
a:focus-visible, button:focus-visible { outline-offset: 1px; }
.nav-tab:focus-visible, .tab:focus-visible, .chip.tog:focus-visible {
  outline-offset: -3px;
  box-shadow: var(--shadow-lift);
}

/* ============================================================
   FOCUS ON CUSTOM CONTROLS — the real control may be .sr (clipped)
   ============================================================ */
.task-row:focus-within, .rule-row:focus-within, .habit-chip:focus-within,
.ql-row:focus-within {
  outline: 3px solid var(--c-blue);
  outline-offset: 2px;
}

/* ============================================================
   PRINT — this is a ledger, so it should print like one
   ============================================================ */
/* ---------------- ledger filters ---------------- */
.filter-bar {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin: 6px 0 16px;
}
.filter-bar .tab-row { margin: 0; }
.filter-bar .chip-row { margin: 0; }

/* ---------------- hours heatmap ---------------- */
.heatmap {
  display: grid;
  grid-template-columns: 16px repeat(15, minmax(0, 1fr));
  gap: 3px;
  align-items: center;
}
.hm-day {
  font-size: 9px;
  line-height: 1;
  color: var(--ink-soft);
  text-align: right;
  padding-right: 2px;
}
.hm-cell {
  display: block;
  aspect-ratio: 1 / 1;
  min-height: 12px;
  border-radius: 3px;
  border: 1px solid var(--rule-line-soft);
  background: var(--card);
}
.hm-cell.l1 { background: var(--hm-1); }
.hm-cell.l2 { background: var(--hm-2); }
.hm-cell.l3 { background: var(--hm-3); }
.hm-cell.l4 { background: var(--hm-4); border-color: transparent; }
.hm-wk {
  font-size: 9px;
  line-height: 1;
  color: var(--ink-soft);
  text-align: center;
}
.hm-legend {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 10px;
  justify-content: flex-end;
}
.hm-legend .hm-cell { width: 12px; min-height: 12px; }
.hm-legend-l { font-size: 10px; color: var(--ink-soft); }

/* ---------------- toast action (undo) ---------------- */
.note-toast { display: flex; align-items: center; gap: 10px; }
.toast-act {
  font-family: var(--font-body);
  font-size: 12px;
  font-weight: 700;
  color: var(--ink);
  background: transparent;
  border: 1px solid currentColor;
  border-radius: 999px;
  padding: 2px 10px;
  cursor: pointer;
  white-space: nowrap;
}
.toast-act:hover { background: var(--mark-yellow); }
.toast-act:focus-visible { outline: 2px solid var(--c-blue); outline-offset: 2px; }

@media print {
  :root {
    --shadow: none;
    --shadow-lift: none;
  }
  body {
    background: #fff;
    background-image: none;
    display: block;
    color: #000;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
  body::before, .desk-stain, .sidebar, .topbar, .footer, .nags,
  .quicklog, .week-nav, .tab-row, .search-row, .icon-btn, .btn,
  .modal-root, #toasts, .mascot { display: none !important; }
  .main-col { padding: 0; max-width: none; }
  .card {
    box-shadow: none !important;
    transform: none !important;
    margin: 10px 0;
    break-inside: avoid;
    page-break-inside: avoid;
  }
  .tape::before { display: none; }
  .grid.dash, .grid.courses, .week-layout, .ledger-layout,
  .sleep-layout, .notes-layout { display: block; }
  .week-rail { position: static; }
  .spine-week.current .spine-card { box-shadow: none !important; }
  .stamp { opacity: 1; }
  a { color: inherit; text-decoration: none; }
  h2, h3, .card-title, .sec-title { break-after: avoid; page-break-after: avoid; }
}

/* ============================================================
   TAP TARGETS — thumbs, not styluses
   ============================================================ */
@media (max-width: 640px) {
  .nav-tab { min-height: 44px; align-items: center; }
  .btn { min-height: 44px; }
  .icon-btn, .star, .modal-x { min-width: 44px; min-height: 44px; }
  .done-btn, .chip.tog, .habit-chip { min-height: 40px; }
  .cbx { width: 25px; height: 25px; }
  .task-row { padding: 10px 6px; }
  .hab-cell.box { height: 44px; }
  .task-text { font-size: 15.5px; }
  .inp, .sel { font-size: 16px; }
}

/* ============================================================
   STATUS CHROME — week, hours, saved, session clock
   ============================================================ */
.status-line {
  font-family: var(--font-hand2);
  font-size: 14.5px;
  color: var(--ink-soft);
  white-space: nowrap;
  letter-spacing: .01em;
}
.session-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 6px 2px 10px;
  border: 2px solid var(--rule-line);
  border-radius: 999px;
  background: var(--card);
  box-shadow: 1px 2px 0 var(--rule-line-soft);
}
.session-pill[hidden] { display: none; }
.session-pill .icon-btn {
  color: var(--ink-soft);
  font-size: 12px;
  line-height: 1;
  padding: 4px 5px;
}
.session-pill .icon-btn:hover { color: var(--ink); background: var(--tint-yellow); }
.sess-time {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 13.5px;
  font-weight: 700;
  letter-spacing: .02em;
  min-width: 44px;
  text-align: right;
  color: var(--ink);
}
.session-pill.running { border-color: var(--c-good); }
.session-pill.running .sess-time { color: var(--c-good); }
.session-pill.running::before {
  content: '';
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--accent-red);
  flex: none;
}
@media (prefers-reduced-motion: no-preference) {
  .session-pill.running::before { animation: sess-blink 1.6s ease-in-out infinite; }
}
@keyframes sess-blink { 0%, 100% { opacity: 1; transform: scale(1); } 50% { opacity: .3; transform: scale(.7); } }

.pal-btn {
  font-family: var(--font-mono);
  font-size: 11.5px;
  font-weight: 700;
  color: var(--ink-soft);
  background: var(--card);
  border: 2px dashed var(--rule-line);
  border-radius: 8px;
  padding: 3px 9px;
  cursor: pointer;
  flex: none;
}
.pal-btn:hover { color: var(--ink); border-color: var(--ink-soft); border-style: solid; }

/* ============================================================
   COMMAND PALETTE
   ============================================================ */
.palette-scrim {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: var(--scrim);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 11vh 16px 16px;
}
.palette {
  width: min(560px, 100%);
  background: var(--card);
  border: 2px solid var(--ink);
  border-radius: 14px;
  box-shadow: 0 26px 60px rgba(0, 0, 0, .38);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
@media (prefers-reduced-motion: no-preference) {
  .palette { animation: pal-in .14s ease-out; }
}
@keyframes pal-in { from { opacity: 0; transform: translateY(-10px); } to { opacity: 1; transform: none; } }
.palette-input {
  width: 100%;
  border: none;
  border-bottom: 2px solid var(--rule-line);
  border-radius: 0;
  padding: 15px 16px;
  font-size: 16px;
  background: transparent;
  color: var(--ink);
}
.palette-input:focus { outline: none; border-bottom-color: var(--accent-yellow); }
.palette-list {
  list-style: none;
  margin: 0;
  padding: 6px;
  max-height: 46vh;
  overflow-y: auto;
}
.palette-item {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 11px;
  border-radius: 8px;
  font-size: 14.5px;
  cursor: pointer;
  color: var(--ink);
}
.palette-item.on { background: var(--tint-yellow); box-shadow: inset 0 0 0 1px var(--tint-yellow-strong); }
.palette-hint {
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--ink-soft);
  white-space: nowrap;
}
.palette-item.result { border-left: 2px dashed var(--rule-line); margin-left: 3px; border-radius: 0 8px 8px 0; }
.palette-item.result .palette-hint { color: var(--ink-soft); font-size: 11px; }
.palette-empty { padding: 16px 12px; color: var(--ink-soft); font-size: 14px; }

/* storage meter (Settings → Data) */
.meter {
  height: 9px;
  border: 1.4px solid var(--ink);
  border-radius: 6px;
  background: var(--paper-2, rgba(0,0,0,.05));
  overflow: hidden;
  margin: 8px 0 6px;
}
.meter-fill {
  height: 100%;
  background: var(--accent-yellow, #ffd23f);
  border-right: 1.4px solid var(--ink);
  transition: width .3s ease;
}
.palette-foot {
  padding: 8px 14px;
  font-size: 12px;
  color: var(--ink-soft);
  border-top: 1px dashed var(--rule-line);
}

/* ============================================================
   INLINE EDIT — click a number or a note, type, Enter
   ============================================================ */
.log-hours, .log-note { cursor: pointer; }
.log-hours:hover { color: var(--accent-blue); }
.log-note:hover { box-shadow: inset 0 -1px 0 var(--rule-line); }
.hours-edit, .note-edit {
  font-size: 14px;
  padding: 2px 6px;
  width: 84px;
  border-radius: 6px;
}
.note-edit { width: min(320px, 100%); }
.log-note .note-edit { font-family: var(--font-body); }

/* ============================================================
   MOTION — quiet, one beat per change
   ============================================================ */
@media (prefers-reduced-motion: no-preference) {
  .view-head { animation: rise .26s ease-out both; }
  .card { animation: fade .3s ease-out both; }
  .cbx.on { animation: cbx-pop .22s ease-out; }
  .check-path { stroke-dasharray: 30; animation: draw .28s ease-out; }
  .task-row { transition: background-color .15s ease; }
  .hm-cell { transition: opacity .2s ease; }
  .nav-tab { transition: transform .12s ease, background-color .15s ease; }
}
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes cbx-pop { 0% { transform: scale(.75); } 55% { transform: scale(1.15); } 100% { transform: scale(1); } }
@keyframes draw { from { stroke-dashoffset: 30; } to { stroke-dashoffset: 0; } }

@media (max-width: 900px) {
  .status-line { display: none; }
}

/* ============================================================
   BURN-DOWN, LEGENDS, DAY LINKS
   ============================================================ */
.legend { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 6px; font-size: 13px; color: var(--ink-soft); }
.legend-key { display: inline-flex; align-items: center; gap: 6px; }
.legend-line { width: 20px; height: 0; border-top-width: 3px; border-top-style: solid; display: inline-block; }
.legend-line.dashed { border-top-style: dashed; border-top-color: var(--accent-red); }
.legend-line.solid { border-top-color: var(--accent-green); }
.burndown { width: 100%; height: auto; }

.cat-head .day-link {
  color: inherit;
  text-decoration: none;
  border-bottom: 2px dotted transparent;
}
.cat-head .day-link:hover { border-bottom-color: var(--rule-line); color: var(--accent-blue); }

/* ============================================================
   MOBILE CHROME + SKIP LINK
   ============================================================ */
.skip {
  position: fixed;
  top: -60px;
  left: 12px;
  z-index: 90;
  background: var(--card);
  color: var(--ink);
  border: 2px solid var(--ink);
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 14px;
  font-weight: 700;
  transition: top .15s ease;
}
.skip:focus { top: 12px; }

@media (max-width: 640px) {
  .topbar { gap: 8px; }
  .session-pill { padding: 2px 4px 2px 8px; }
  .sess-time { min-width: 40px; font-size: 12.5px; }
  .pal-btn { padding: 3px 7px; }
  .status-line { font-size: 13px; }
  .palette-scrim { padding-top: 6vh; }
  .palette-list { max-height: 55vh; }
}

/* ============================================================
   VAULT — linked notes, backlinks, markdown typography
   ============================================================ */
.head-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

.vault-wrap {
  display: grid;
  grid-template-columns: minmax(210px, 270px) 1fr;
  gap: 18px;
  align-items: start;
}
.vault-side {
  border: 1.6px solid var(--ink);
  border-radius: 4px 16px 16px 4px;
  background: var(--card);
  box-shadow: var(--shadow);
  padding: 12px 12px 14px;
  transform: rotate(-0.3deg);
  position: sticky;
  top: 12px;
}
.vault-side .search-row { margin: 0 0 8px; }
.vault-list { display: flex; flex-direction: column; gap: 4px; max-height: 62vh; overflow-y: auto; }
.vault-item {
  display: block;
  padding: 7px 9px;
  border: 1.4px solid transparent;
  border-radius: 8px;
  color: var(--ink);
  text-decoration: none;
}
.vault-item:hover { background: var(--tint-yellow); transform: translateX(2px); }
.vault-item-title { display: block; font-family: var(--font-hand2); font-size: 15.5px; }
.vault-item-sub {
  display: block;
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--ink-soft);
  margin-top: 1px;
}
.vault-orphans { margin-top: 10px; line-height: 1.5; }

.note-panel {
  background: var(--card);
  border: 1.6px solid var(--ink);
  border-radius: 4px 18px 18px 4px;
  box-shadow: var(--shadow);
  padding: 18px 20px 20px;
  transform: rotate(0.15deg);
}
.note-head { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.note-title { font-family: var(--font-hand2); font-size: 27px; margin: 0; line-height: 1.15; }
.note-meta { font-family: var(--font-mono); font-size: 11.5px; color: var(--ink-soft); }
.vault-empty .btn-row { margin-top: 14px; }

.vault-edit { display: flex; flex-direction: column; gap: 8px; }
.vault-title-in { font-family: var(--font-hand2); font-size: 19px; }
textarea.vault-editor {
  font-family: var(--font-mono);
  font-size: 13.5px;
  line-height: 1.55;
  min-height: 260px;
  resize: vertical;
}
.vault-edit-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.vault-count { font-family: var(--font-mono); font-size: 11.5px; color: var(--ink-soft); }

.vault-links { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 18px; }
.vault-backlink {
  display: block;
  padding: 7px 9px;
  border: 1.4px dashed var(--rule-line);
  border-radius: 8px;
  color: var(--ink);
  text-decoration: none;
  margin-bottom: 6px;
}
.vault-backlink:hover { background: var(--tint-yellow); border-style: solid; }
.vault-backlink.broken .vault-backlink-title { text-decoration: underline dotted; color: var(--c-warn); }
.vault-backlink-title { display: block; font-family: var(--font-hand2); font-size: 15px; }
.vault-backlink-snip { display: block; font-size: 12.5px; color: var(--ink-soft); margin-top: 2px; }
.warn-line { color: var(--c-warn); }

/* markdown typography */
.md { font-size: 15.5px; line-height: 1.62; }
.md-p { margin: 0 0 12px; }
.md-p.md-empty { color: var(--ink-soft); font-style: italic; }
.md-h { font-family: var(--font-hand2); margin: 20px 0 8px; line-height: 1.2; }
.md-h1 { font-size: 25px; border-bottom: 2px solid var(--rule-line); padding-bottom: 4px; }
.md-h2 { font-size: 21px; }
.md-h3 { font-size: 18px; }
.md-h4, .md-h5, .md-h6 { font-size: 16px; }
.md-hr { border: none; border-top: 2px dashed var(--rule-line); margin: 18px 0; }
.md-quote {
  border-left: 3px solid var(--accent-blue);
  background: var(--tint-blue, rgba(0,0,0,.03));
  margin: 0 0 12px;
  padding: 6px 12px;
  border-radius: 0 8px 8px 0;
}
.md-quote .md-p:last-child { margin-bottom: 0; }
.md-list { margin: 0 0 12px; padding-left: 22px; }
.md-li { margin: 3px 0; }
.md-cb { font-family: var(--font-mono); margin-right: 4px; }
.md-cb.on { color: var(--c-good); }
.code-block {
  background: var(--paper);
  border: 1.4px solid var(--rule-line);
  border-radius: 8px;
  padding: 10px 12px;
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 12.5px;
  margin: 0 0 12px;
}
.code-block code { white-space: pre; }
.md a.md-a, .md a.md-a:visited { color: var(--accent-blue); text-decoration: underline; }
.wikilink { color: var(--accent-blue); text-decoration: none; border-bottom: 1.4px dotted currentColor; }
.wikilink:hover { background: var(--tint-yellow); }
.wikilink.broken { color: var(--c-warn); border-bottom-style: dashed; }
.wikilink.plain { border-bottom: none; color: var(--ink); }
.md-img { max-width: 100%; border: 1.4px solid var(--ink); border-radius: 6px; }

@media (max-width: 820px) {
  .vault-wrap { grid-template-columns: 1fr; }
  .vault-side { position: static; transform: none; }
  .vault-list { max-height: 34vh; }
  .vault-links { grid-template-columns: 1fr; }
  .note-panel { transform: none; }
}

/* ============================================================
   TASKS — quick add, buckets, inbox
   ============================================================ */
.stat-chip { font-family: var(--font-hand2); font-size: 13.5px; border-color: var(--rule-line); }
.stat-chip.late { border-color: var(--c-bad); color: var(--c-bad); }

.quick-row { display: flex; gap: 8px; flex-wrap: wrap; }
.quick-add { flex: 1; min-width: 220px; font-family: var(--font-hand2); font-size: 17px; }
.capture-add { width: 100%; margin-top: 8px; font-family: var(--font-hand2); font-size: 15.5px; }
.quick-hint {
  min-height: 16px;
  margin: 6px 0 0;
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--ink-soft);
}

.task-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; }
.task-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.task-row.overdue .task-text { color: var(--c-bad); }
.cbx-btn {
  flex-shrink: 0;
  border: none;
  background: none;
  padding: 0;
  cursor: pointer;
  line-height: 0;
  margin-top: 1px;
}
.cbx-btn:focus-visible { outline: 2px solid var(--accent-blue); outline-offset: 2px; border-radius: 6px; }
.row-actions { display: flex; gap: 6px; align-items: center; opacity: 0; transition: opacity .12s; }
.task-row:hover .row-actions, .task-row:focus-within .row-actions { opacity: 1; }
.task-row.overdue .row-actions { opacity: 1; }
.task-edit { flex: 1; font-family: var(--font-hand2); font-size: 15px; padding: 2px 8px; }

.due-chip.now { border-color: var(--accent-blue); color: var(--accent-blue); }
.due-chip.late { border-color: var(--c-bad); color: var(--c-bad); }
.prio-high { border-color: var(--c-bad); color: var(--c-bad); font-weight: 700; }
.prio-med { border-color: var(--c-warn); color: var(--c-warn); }
.prio-low { border-color: var(--c-good); color: var(--c-good); }
.label-chip { border-color: var(--c-blue); color: var(--c-blue); }
.repeat-chip { border-color: var(--c-purple); color: var(--c-purple); }

.day-bucket { margin-bottom: 10px; }
.day-bucket-h {
  font-family: var(--font-mono);
  font-size: 11.5px;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--ink-soft);
  margin: 0 0 4px;
}
.inbox-row .task-text { font-family: var(--font-hand2); font-size: 16px; }
.card.grp-overdue { border-color: var(--c-bad); }
.tasks-foot { margin: 16px 0 4px; }

@media (max-width: 820px) {
  .task-grid { grid-template-columns: 1fr; }
  .row-actions { opacity: 1; }
}

/* ============================================================
   CALENDAR — month grid, agenda, .ics
   ============================================================ */
.cal-card { padding-bottom: 14px; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal-row { display: contents; }
.cal-cell {
  position: relative;
  min-height: 96px;
  border: 1.5px solid var(--rule-line);
  border-radius: 10px 8px 11px 7px;
  background: var(--paper);
  padding: 5px 6px 6px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  overflow: hidden;
  transition: background .12s;
}
.cal-cell:not(.out):hover { background: var(--tint-yellow); cursor: pointer; }
.cal-cell.out { opacity: .45; background: transparent; }
.cal-cell.is-today { border-color: var(--accent-blue); box-shadow: 0 0 0 1.5px var(--accent-blue) inset; }
.cal-head { display: contents; }
.cal-dow {
  min-height: 0;
  border: none;
  background: none;
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--ink-soft);
  text-align: center;
  padding: 4px 0 2px;
  cursor: default;
}
.cal-day-top { display: flex; align-items: center; justify-content: space-between; }
.cal-num {
  font-family: var(--font-mono);
  font-size: 12.5px;
  color: var(--ink-soft);
  min-width: 18px;
}
.cal-num.today {
  background: var(--accent-blue);
  color: var(--on-fill);
  border-radius: 40%;
  padding: 1px 5px;
  font-weight: 700;
}
.cal-add {
  opacity: 0;
  font-family: var(--font-mono);
  font-size: 14px;
  line-height: 1;
  color: var(--ink-soft);
  cursor: pointer;
  padding: 0 3px;
}
.cal-cell:hover .cal-add, .cal-add:focus { opacity: 1; }
.cal-ev, .cal-task {
  display: block;
  width: 100%;
  text-align: left;
  border: none;
  border-radius: 5px;
  padding: 1.5px 5px;
  font-family: var(--font-hand2);
  font-size: 12.5px;
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
  background: var(--tint-yellow);
  color: var(--ink);
}
.cal-ev.blue { background: rgba(63, 114, 191, .16); }
.cal-ev.green { background: rgba(46, 139, 87, .16); }
.cal-ev.purple { background: rgba(134, 96, 167, .18); }
.cal-ev.red { background: rgba(196, 74, 60, .16); }
.cal-ev:hover, .cal-task:hover { filter: brightness(.96); }
.cal-task {
  background: transparent;
  color: var(--ink-soft);
  font-family: var(--font-mono);
  font-size: 11px;
  border-top: 1px dashed var(--rule-line);
  border-radius: 0;
}

.cal-side { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; margin-top: 16px; }
.agenda { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.agenda-row { display: flex; gap: 8px; align-items: baseline; }
.agenda-when {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--ink-soft);
  min-width: 96px;
  flex-shrink: 0;
}
.agenda-what {
  border: none;
  background: none;
  padding: 0;
  font-family: var(--font-hand2);
  font-size: 15.5px;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
}
.agenda-what:hover { text-decoration: underline; }

.time-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.ics-box {
  width: 100%;
  font-family: var(--font-mono);
  font-size: 12px;
  margin-top: 8px;
}

@media (max-width: 820px) {
  .cal-cell { min-height: 64px; padding: 4px; }
  .cal-side { grid-template-columns: 1fr; }
  .cal-ev, .cal-task { font-size: 11.5px; }
  .agenda-when { min-width: 78px; }
}

/* ============================================================
   DECKS — flashcards, study session, SM-2
   ============================================================ */
.deck-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; margin-bottom: 16px; }
.deck-card .chip-row { margin-top: 6px; }
.deck-card .quick-row { margin-top: 8px; }

.deck-card-row { cursor: default; }
.deck-face { flex: 1 1 220px; min-width: 160px; display: flex; flex-direction: column; gap: 2px; }
.deck-face b { font-family: var(--font-hand2); font-size: 16px; font-weight: 700; }
.deck-back { font-size: 13.5px; color: var(--ink-soft); }

.study-prog { margin: 6px 0 14px; }
.study-card {
  border: 2px dashed var(--rule-line);
  border-radius: 14px 12px 15px 11px;
  background: var(--paper);
  padding: 22px 24px;
  text-align: center;
  min-height: 170px;
}
.study-card.open { border-style: solid; }
.study-front {
  font-family: var(--font-hand2);
  font-size: 26px;
  line-height: 1.3;
  margin: 0;
}
.study-back { margin-top: 4px; }
.study-back-text { font-size: 17px; margin: 6px 0 4px; }
.rate-row { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 16px; }
.btn.rate { min-width: 130px; }
.btn.rate.bad { border-color: var(--c-bad); color: var(--c-bad); }
.btn.rate.ok { border-color: var(--c-good); color: var(--c-good); }
.btn.rate.primary { background: var(--accent-green); color: var(--on-fill); border-color: var(--accent-green); }

@media (max-width: 820px) {
  .study-front { font-size: 21px; }
  .study-card { padding: 16px 14px; }
  .btn.rate { min-width: 0; flex: 1 1 46%; }
}

/* ============================================================
   FOCUS — session clock, lock, session log, bookmarklet
   ============================================================ */
.focus-clock {
  font-family: var(--font-hand2);
  font-size: clamp(46px, 9vw, 72px);
  line-height: 1;
  font-weight: 700;
  text-align: center;
  letter-spacing: 3px;
  margin: 10px 0 8px;
  font-variant-numeric: tabular-nums;
}
.focus-clock.paused { color: var(--ink-soft); }
.focus-bar {
  height: 13px;
  border: 2px solid var(--ink);
  border-radius: 9px 8px 10px 7px;
  background: var(--paper);
  overflow: hidden;
}
.focus-bar-fill { height: 100%; background: var(--accent-green); transition: width .4s linear; }
.focus-under { text-align: center; font-family: var(--font-mono); font-size: 12.5px; margin: 8px 0 0; }
.focus-actions { justify-content: center; }
.focus-lock-note {
  border: 1.6px dashed var(--c-warn);
  background: var(--tint-yellow);
  border-radius: 10px;
  padding: 8px 10px;
  font-size: 13.5px;
  color: var(--ink-soft);
  margin: 12px 0 0;
}
.field-lock {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13.5px;
  color: var(--ink-soft);
  margin-top: 6px;
}
.field-lock input { width: 17px; height: 17px; flex-shrink: 0; }
.focus-log-row { cursor: default; }
.focus-log-row:hover { background: none; }
.focus-log-time { font-family: var(--font-mono); font-size: 12.5px; color: var(--ink-soft); min-width: 42px; }
.focus-log-chips { display: flex; gap: 5px; flex-wrap: wrap; justify-content: flex-end; }
#focus-bm { flex: 1 1 240px; font-family: var(--font-mono); font-size: 11.5px; }
.limit-list { margin: 4px 0 0; padding-left: 18px; }
.limit-list li { font-size: 13.5px; color: var(--ink-soft); margin-bottom: 6px; }
.focus-pill {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 70;
  font-family: var(--font-hand2);
  font-size: 15px;
  font-weight: 700;
  padding: 7px 14px 8px;
  border: 2px solid var(--ink);
  border-radius: 22px 20px 23px 19px;
  background: var(--accent-yellow);
  color: var(--on-yellow);
  box-shadow: 2px 3px 0 rgba(0, 0, 0, .14);
  cursor: pointer;
}
.focus-pill.locked { background: var(--c-bad); color: var(--on-fill); }
.focus-pill:hover { transform: translateY(-1px); }

@media (max-width: 820px) {
  .focus-clock { font-size: 44px; letter-spacing: 1px; }
  .focus-pill { right: 10px; bottom: 10px; font-size: 13.5px; }
}

/* ============================================================
   SKETCH — vector ink pages, thumbnails, tools
   ============================================================ */
.ink-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 16px; }
.ink-card .ink-thumb { margin-bottom: 6px; }
.ink-canvas {
  display: block;
  width: 100%;
  height: auto;
  background: var(--paper);
  border: 2px solid var(--ink);
  border-radius: 12px 10px 13px 9px;
  touch-action: none;
  cursor: crosshair;
  user-select: none;
}
.ink-thumb {
  border: 1.6px solid var(--rule-line);
  border-radius: 8px;
  cursor: default;
  pointer-events: none;
}
.ink-canvas-card { padding-bottom: 14px; }
.ink-swatch {
  width: 26px;
  height: 26px;
  padding: 0;
  border: 2px solid var(--ink);
  border-radius: 50%;
  cursor: pointer;
}
.ink-swatch.on { outline: 3px solid var(--c-blue); outline-offset: 2px; }
.ink-swatch:focus-visible { outline: 3px solid var(--c-blue); outline-offset: 2px; }

@media (max-width: 820px) {
  .ink-grid { grid-template-columns: 1fr; }
}

/* ============================================================
   MOBILE CAPTURE + SYNC PILL (Phase 1b)
   Bottom bar + FAB + sheet, safe-area aware. Desktop hidden.
   ============================================================ */
.mobilebar { display: none; }
.fab { display: none; }
.sync-pill {
  font-family: var(--font-mono, monospace);
  font-size: 12px;
  padding: 3px 10px 4px;
  border: 1.6px solid var(--rule-line);
  border-radius: 14px;
  white-space: nowrap;
}
.sync-pill.offline { border-color: var(--c-bad); color: var(--c-bad); }
.sync-pill.syncing { border-color: var(--c-blue); color: var(--c-blue); }
.sheet-scrim {
  position: fixed; inset: 0; z-index: 90;
  background: rgba(0,0,0,.35);
  display: flex; align-items: flex-end; justify-content: center;
}
.sheet {
  width: 100%; max-width: 560px;
  background: var(--card, #fffdf6);
  border-top: 2px solid var(--ink);
  border-radius: 16px 16px 0 0;
  padding: 14px 16px calc(16px + env(safe-area-inset-bottom, 0px));
}
.sheet h2 { font-size: 22px; margin: 0 0 10px; }
.sheet .btn-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
@media (max-width: 900px) {
  .mobilebar {
    display: flex; gap: 4px;
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 80;
    padding: 8px 10px calc(8px + env(safe-area-inset-bottom, 0px));
    background: var(--paper-edge);
    border-top: 2px solid var(--ink);
    overflow-x: auto;
  }
  .mobilebar a {
    flex: 1 0 auto; text-align: center;
    padding: 10px 8px; min-height: 44px;
    border: 1.6px solid var(--rule-line); border-radius: 14px;
    text-decoration: none; color: inherit; font-weight: 700; font-size: 14px;
    white-space: nowrap;
  }
  .mobilebar a.active { border-color: var(--ink); background: var(--card, #fff); }
  .fab {
    display: block;
    position: fixed; right: 16px; bottom: calc(70px + env(safe-area-inset-bottom, 0px)); z-index: 81;
    width: 56px; height: 56px; border-radius: 50%;
    font-size: 28px; line-height: 1;
    border: 2px solid var(--ink); background: var(--accent-yellow); color: var(--on-yellow);
    box-shadow: 2px 3px 0 rgba(0,0,0,.18); cursor: pointer;
  }
  .main-col { padding-bottom: 140px; }
  #toasts { bottom: calc(140px + env(safe-area-inset-bottom, 0px)); }
  .focus-pill { bottom: calc(140px + env(safe-area-inset-bottom, 0px)); }
}
