/* ============================================================
   Semester Planner — "drafting table"
   Notion's quiet surfaces + a calendar's ruled time grid.
   Hairlines, tabular mono for anything numeric, one ink accent.
   ============================================================ */

:root {
  /* palette — overridden by [data-theme] and by user custom colors */
  --paper:      #F6F6F4;
  --surface:    #FFFFFF;
  --surface-2:  #FBFBFA;
  --ink:        #1A1C1E;
  --ink-2:      #5B6068;
  --ink-3:      #8B9099;
  --rule:       #E4E4E0;
  --rule-soft:  #EFEFEC;
  --accent:     #35566B;
  --accent-ink: #FFFFFF;
  --accent-soft:rgba(53, 86, 107, 0.10);
  --warn:       #A9762C;
  --danger:     #A2453C;
  --ok:         #3E7A5E;

  /* type */
  --font-heading: -apple-system, BlinkMacSystemFont, "Segoe UI Variable Display", "Segoe UI", Inter, Roboto, system-ui, sans-serif;
  --font-body:    -apple-system, BlinkMacSystemFont, "Segoe UI Variable Text", "Segoe UI", Inter, Roboto, system-ui, sans-serif;
  --font-mono:    ui-monospace, "SF Mono", "Cascadia Mono", "Segoe UI Mono", Menlo, Consolas, monospace;
  --scale: 1;

  /* metrics */
  --r: 5px;
  --r-lg: 9px;
  --sidebar-w: 216px;
  --peek-w: 400px;
  --hour-h: 52px;
  --gutter-w: 54px;
  --shadow-1: 0 1px 2px rgba(20, 22, 26, .05);
  --shadow-2: 0 8px 28px rgba(20, 22, 26, .12), 0 1px 3px rgba(20, 22, 26, .06);
}

[data-theme="linen"]   { --paper:#F7F3EC; --surface:#FFFDF9; --surface-2:#FBF7F1; --rule:#E7DFD2; --rule-soft:#F0EAE0; --accent:#8A6A4B; --accent-soft:rgba(138,106,75,.12); }
[data-theme="sage"]    { --paper:#F2F4F0; --surface:#FFFFFF; --surface-2:#F8FAF7; --rule:#DFE5DC; --rule-soft:#EBEFE8; --accent:#4E6E58; --accent-soft:rgba(78,110,88,.12); }
[data-theme="rose"]    { --paper:#F8F2F2; --surface:#FFFDFD; --surface-2:#FCF6F6; --rule:#E9DCDC; --rule-soft:#F2E9E9; --accent:#8E5560; --accent-soft:rgba(142,85,96,.12); }
[data-theme="lavender"]{ --paper:#F4F3F8; --surface:#FFFFFF; --surface-2:#FAF9FC; --rule:#E1DEEA; --rule-soft:#EDEBF3; --accent:#61568A; --accent-soft:rgba(97,86,138,.12); }
[data-theme="bluebell"]{ --paper:#F1F4F7; --surface:#FFFFFF; --surface-2:#F8FAFC; --rule:#DCE3EA; --rule-soft:#E9EEF3; --accent:#3B5F82; --accent-soft:rgba(59,95,130,.12); }
[data-theme="butter"]  { --paper:#F9F6EC; --surface:#FFFEF9; --surface-2:#FCFAF2; --rule:#E8E1CB; --rule-soft:#F1ECDD; --accent:#8A7328; --accent-soft:rgba(138,115,40,.12); }
/* Parchment — built for reading for hours rather than for looking new.
   Dark-on-light, because light-on-dark haloes for anyone with astigmatism;
   an off-white rather than #FFF, which is a glare source at normal monitor
   brightness; ink at about 10:1 rather than black-on-white's 21:1, which is
   past the point where more contrast helps; and the whole thing pushed warm,
   so it emits less blue late at night. */
[data-theme="parchment"] {
  --paper:#EFEAE1; --surface:#F7F3EC; --surface-2:#F2EDE4;
  --ink:#3A3630; --ink-2:#6B655C; --ink-3:#948D82;
  --rule:#DED7CA; --rule-soft:#E8E2D6;
  --accent:#5A7365; --accent-soft:rgba(90,115,101,.14);
  --warn:#96702F; --danger:#98524A; --ok:#4A7A62;
}

[data-theme="ink"] {
  --paper:#16181B; --surface:#1D2024; --surface-2:#212529; --ink:#E8EAED; --ink-2:#A8AEB6; --ink-3:#767D86;
  --rule:#2C3137; --rule-soft:#24282D; --accent:#7FA8C4; --accent-ink:#12161A; --accent-soft:rgba(127,168,196,.16);
  --warn:#D2A45E; --danger:#D0776D; --ok:#6FB292;
  --shadow-2: 0 8px 30px rgba(0,0,0,.5), 0 1px 3px rgba(0,0,0,.4);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: calc(15px * var(--scale));
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior-y: none;
}
h1, h2, h3, h4 { font-family: var(--font-heading); font-weight: 600; letter-spacing: -.015em; margin: 0; }
h1 { font-size: calc(23px * var(--scale)); }
h2 { font-size: calc(17px * var(--scale)); }
h3 { font-size: calc(14px * var(--scale)); }
button, input, select, textarea { font: inherit; color: inherit; }
input, select, textarea { background: var(--surface); }
a { color: var(--accent); }

.mono, .num { font-family: var(--font-mono); font-variant-numeric: tabular-nums; font-feature-settings: "tnum" 1; }

.eyebrow {
  font-family: var(--font-mono);
  font-size: calc(10px * var(--scale));
  letter-spacing: .11em;
  text-transform: uppercase;
  color: var(--ink-3);
}

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--rule); border-radius: 6px; border: 3px solid var(--paper); }
::-webkit-scrollbar-track { background: transparent; }

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

/* ---------------- shell ---------------- */

#app {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  height: 100dvh;
}

.sidebar {
  border-right: 1px solid var(--rule);
  background: var(--surface-2);
  display: flex; flex-direction: column;
  padding: 18px 0 10px;
  min-height: 0;
}
.brand { padding: 0 16px 16px; }
.brand .sem-name {
  font-family: var(--font-heading); font-weight: 600; font-size: calc(15px * var(--scale));
  letter-spacing: -.01em; display: block; width: 100%; border: 0; background: transparent; padding: 0;
}

.rail { flex: 1; overflow-y: auto; padding: 0 8px; }
.nav-item {
  display: flex; align-items: center; gap: 9px; width: 100%;
  padding: 7px 8px; margin-bottom: 1px;
  border: 0; background: transparent; border-radius: var(--r);
  color: var(--ink-2); font-size: calc(13.5px * var(--scale)); text-align: left; cursor: pointer;
}
.nav-item:hover { background: var(--rule-soft); color: var(--ink); }
.nav-item[aria-current="page"] { background: var(--accent-soft); color: var(--ink); font-weight: 550; }
.nav-item .key { margin-left: auto; font-family: var(--font-mono); font-size: 10px; color: var(--ink-3); opacity: 0; }
.nav-item:hover .key { opacity: 1; }
.nav-glyph { width: 16px; text-align: center; opacity: .75; font-size: 13px; }

/* areas sit indented under the category they belong to */
.area-chip {
  display: flex; align-items: center; gap: 8px; width: 100%;
  padding: 4px 8px 4px 33px; border: 0; background: transparent; border-radius: var(--r);
  color: var(--ink-2); font-size: calc(12.5px * var(--scale)); cursor: pointer; text-align: left;
}
.area-chip:hover { background: var(--rule-soft); color: var(--ink); }
.area-chip.is-current { background: var(--accent-soft); color: var(--ink); font-weight: 550; }
.dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.area-chip .count { margin-left: auto; }
.nav-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* the month, small, under the views */
.mini-month { padding: 8px 12px 8px; border-top: 1px solid var(--rule); user-select: none; -webkit-user-select: none; }
.mm-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 4px; }
.mm-title { font-family: var(--font-heading); font-weight: 600; font-size: 12px; color: var(--ink); }
.mm-turn {
  border: 0; background: transparent; color: var(--ink-3); cursor: pointer;
  padding: 1px 7px; border-radius: var(--r); font-size: 14px; line-height: 1.2;
}
.mm-turn:hover { background: var(--rule-soft); color: var(--ink); }
.mm-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 1px; }
.mm-dow { text-align: center; color: var(--ink-3); font-family: var(--font-mono); font-size: 9px; padding-bottom: 2px; }
.mm-day {
  position: relative; height: 22px; padding: 0 0 3px; border: 0; background: transparent; border-radius: 4px;
  color: var(--ink-2); font-family: var(--font-mono); font-size: 10.5px; cursor: pointer; line-height: 1;
}
.mm-day:hover { background: var(--rule-soft); color: var(--ink); }
.mm-day.is-out { color: var(--ink-3); opacity: .5; }
.mm-day.is-shown { background: var(--accent-soft); color: var(--ink); }
.mm-day.is-today { font-weight: 700; color: var(--accent); }
.mm-day.is-busy::after {
  content: ''; position: absolute; left: 50%; bottom: 2px; width: 3px; height: 3px; margin-left: -1.5px;
  border-radius: 50%; background: currentColor; opacity: .7;
}
/* a drag from the week is welcome here */
body.is-moving .mini-month { background: var(--surface); }
.mm-day.is-over { background: var(--accent); color: #fff; }

.sync-stack { display: flex; flex-direction: column; gap: 5px; padding-bottom: 4px; }
.sync-strip {
  margin: 0 8px; padding: 8px 9px; border: 1px solid var(--rule); border-radius: var(--r);
  background: var(--surface); display: flex; gap: 8px; align-items: center; cursor: pointer;
}
.sync-strip:hover { border-color: var(--accent); }
.sync-led { width: 7px; height: 7px; border-radius: 50%; background: var(--ink-3); flex: none; }
.sync-led[data-s="ready"] { background: var(--ok); }
.sync-led[data-s="syncing"] { background: var(--accent); animation: pulse 1.1s ease-in-out infinite; }
.sync-led[data-s="error"] { background: var(--danger); }
.sync-led[data-s="offline"] { background: var(--warn); }
@keyframes pulse { 50% { opacity: .25; } }

/* ---------------- main ---------------- */

.main { min-width: 0; display: flex; flex-direction: column; overflow: hidden; }

.topbar {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 22px; border-bottom: 1px solid var(--rule);
  background: var(--paper);
}
.topbar h1 { flex: none; }
.topbar .spacer { flex: 1; }

.quickadd {
  flex: 1; max-width: 560px; display: flex; align-items: center; gap: 8px;
  border: 1px solid var(--rule); border-radius: var(--r); background: var(--surface);
  padding: 0 10px; height: 34px;
}
.quickadd:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.quickadd input { flex: 1; border: 0; outline: 0; background: transparent; font-size: calc(13.5px * var(--scale)); }
.quickadd .hint { font-family: var(--font-mono); font-size: 10px; color: var(--ink-3); white-space: nowrap; }

/* what is on now, or next — the one thing every screen says about today */
.nextup {
  flex: none; min-width: 0; max-width: 300px;
  display: flex; align-items: baseline; gap: 7px;
  color: var(--ink-3); font-size: calc(12px * var(--scale));
}
.nextup .eyebrow { flex: none; }
.nextup.is-live .eyebrow { color: var(--accent); }
.nextup-t { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink-2); }
.nextup.is-live .nextup-t { color: var(--ink); }

.view { flex: 1; overflow-y: auto; overflow-x: hidden; -webkit-overflow-scrolling: touch; }
/* the week view manages its own scrolling so the tray stays reachable while dragging */
.view.bare { overflow: hidden; display: flex; flex-direction: column; }
.week-scroll { flex: 1; min-height: 0; overflow: auto; -webkit-overflow-scrolling: touch; }
/* Centred, not left-aligned. Without margin-inline the column clings to the
   left and every right-anchored control stops at 1180px — which on a wide
   screen reads as the middle of nowhere — and collapsing the sidebar changes
   nothing, because the width it frees is never used. */
.pad { padding: 22px; max-width: 1180px; margin-inline: auto; }

/* ---------------- primitives ---------------- */

.btn {
  display: inline-flex; align-items: center; gap: 6px;
  border: 1px solid var(--rule); background: var(--surface); color: var(--ink);
  border-radius: var(--r); padding: 6px 11px; cursor: pointer;
  font-size: calc(13px * var(--scale)); line-height: 1.3;
  transition: background .12s ease, border-color .12s ease;
}
.btn:hover { background: var(--surface-2); border-color: var(--ink-3); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.ghost { border-color: transparent; background: transparent; color: var(--ink-2); }
.btn.ghost:hover { background: var(--rule-soft); color: var(--ink); }
.btn.danger { color: var(--danger); }
.btn.sm { padding: 3px 8px; font-size: calc(12px * var(--scale)); }
.btn:disabled { opacity: .45; cursor: not-allowed; }

.field { display: flex; flex-direction: column; gap: 5px; }
.field > label { font-family: var(--font-mono); font-size: 10px; letter-spacing: .1em; text-transform: uppercase; color: var(--ink-3); }
input[type="text"], input[type="date"], input[type="time"], input[type="number"], input[type="url"], select, textarea {
  border: 1px solid var(--rule); border-radius: var(--r); padding: 6px 9px;
  font-size: calc(13.5px * var(--scale)); width: 100%; outline: 0;
  color: var(--ink);
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
textarea { resize: vertical; min-height: 72px; line-height: 1.55; }

.card {
  background: var(--surface); border: 1px solid var(--rule); border-radius: var(--r-lg);
  box-shadow: var(--shadow-1);
}
.card-h { display: flex; align-items: baseline; gap: 10px; padding: 13px 15px 9px; }
.card-h .spacer { flex: 1; }
.card-b { padding: 4px 15px 14px; }

.grid { display: grid; gap: 14px; }

.tag {
  display: inline-flex; align-items: center; gap: 5px; border-radius: 3px;
  padding: 1px 6px; font-size: calc(11.5px * var(--scale)); line-height: 1.55;
  background: var(--rule-soft); color: var(--ink-2); white-space: nowrap;
}
.tag.area { background: var(--tag-bg); color: var(--tag-fg); }
.tag.flag-high { color: var(--danger); background: transparent; border: 1px solid currentColor; }
.tag.flag-low { color: var(--ink-3); }

.empty {
  border: 1px dashed var(--rule); border-radius: var(--r-lg);
  padding: 26px; text-align: center; color: var(--ink-2);
}
.empty h3 { margin-bottom: 4px; }

/* checkbox — soft circle, quick satisfying check */
.check {
  appearance: none; -webkit-appearance: none;
  width: 17px; height: 17px; flex: none; margin: 0;
  border: 1.5px solid var(--ink-3); border-radius: 50%;
  background: transparent; cursor: pointer; position: relative;
  transition: border-color .12s ease, background .12s ease;
}
.check:hover { border-color: var(--accent); }
.check:checked { background: var(--accent); border-color: var(--accent); }
.check::after {
  content: ""; position: absolute; inset: 0;
  background: no-repeat center/9px 9px
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M2 6.4 4.6 9 10 3' fill='none' stroke='white' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  opacity: 0; transform: scale(.6);
  transition: opacity .12s ease, transform .18s cubic-bezier(.2,1.5,.4,1);
}
.check:checked::after { opacity: 1; transform: scale(1); }
.check.sm { width: 14px; height: 14px; }

/* progress meter */
.meter { height: 3px; border-radius: 2px; background: var(--rule-soft); overflow: hidden; }
.meter > span { display: block; height: 100%; background: var(--accent); transition: width .3s ease; }

/* ---------------- item rows (Semester / lists) ---------------- */

.group-h {
  display: flex; align-items: baseline; gap: 10px;
  padding: 20px 2px 7px; border-bottom: 1px solid var(--rule);
  position: sticky; top: 0; background: var(--paper); z-index: 3;
}
.group-h h2 { font-size: calc(15px * var(--scale)); }

.row {
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr) auto;
  align-items: center; gap: 10px;
  padding: 8px 6px; border-bottom: 1px solid var(--rule-soft);
  cursor: pointer;
}
.row .meta { display: flex; align-items: center; gap: 10px; justify-content: flex-end; min-width: 0; }
.row .meta > * { flex: none; }
.row:hover { background: var(--surface-2); }
.row .title { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row.done .title { color: var(--ink-3); text-decoration: line-through; text-decoration-color: var(--ink-3); }
.row .sub { color: var(--ink-3); }
.row .due { font-family: var(--font-mono); font-size: calc(11.5px * var(--scale)); color: var(--ink-2); white-space: nowrap; }
.row .due.late { color: var(--danger); }
.row .due.soon { color: var(--warn); }
.row .bar { width: 3px; height: 15px; border-radius: 2px; }

/* ---------------- week grid (the signature) ---------------- */

.weekbar {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 22px; border-bottom: 1px solid var(--rule);
}
/* a drag held at the grid's edge, or over ‹ ›, is about to turn the week */
.weekbar [data-turn].is-hot { background: var(--accent-soft); border-color: var(--accent); }
.week-wrap { position: relative; min-width: 100%; }

/* heads and the due-date rail together, pinned while the hours scroll */
.week-top { position: sticky; top: 0; z-index: 5; }
.week-head {
  display: grid; grid-template-columns: var(--gutter-w) repeat(7, minmax(0, 1fr));
  background: var(--paper);
  border-bottom: 1px solid var(--rule);
}
.week-head .dhead { padding: 7px 8px 6px; border-left: 1px solid var(--rule-soft); }
.week-head .dhead.weekend .eyebrow, .week-head .dhead.weekend .dnum { color: var(--ink-3); }
.week-head .dhead.today .dnum { color: var(--accent-ink); background: var(--accent); }
.dnum {
  font-family: var(--font-mono); font-size: calc(14px * var(--scale)); font-variant-numeric: tabular-nums;
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 23px; height: 23px; border-radius: 4px; margin-top: 2px;
}
.allday-rail {
  display: grid; grid-template-columns: var(--gutter-w) repeat(7, minmax(0,1fr));
  border-bottom: 1px solid var(--rule); background: var(--surface-2);
  /* one row of flags tall, growing with what is there; three high, it scrolls */
  min-height: 27px; max-height: 148px; overflow-y: auto;
}
.allday-rail .cell { border-left: 1px solid var(--rule-soft); padding: 5px 4px; display: flex; flex-direction: column; gap: 3px; cursor: crosshair; }
.allday-rail .cell:hover { background: var(--surface); }
.allday-rail .gutter {
  display: flex; align-items: flex-start; justify-content: flex-end;
  padding: 6px 7px 0 0; text-align: right; line-height: 1.3; letter-spacing: .03em;
  font-size: 9px;   /* "Due · all day" has to fit the hour gutter */
}
.tz-chip {
  border: 1px solid var(--rule); border-radius: 999px;
  padding: 1px 8px; color: var(--ink-3); cursor: default;
}
.due-flag {
  font-size: calc(11px * var(--scale)); line-height: 1.35; border-radius: 3px;
  padding: 1px 5px; border-left: 2px solid var(--c);
  background: var(--surface); color: var(--ink);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; cursor: pointer;
}
.due-flag.done { opacity: .45; text-decoration: line-through; }
/* a later day of a stretch: the bar runs on, the name said once */
.due-flag.is-cont { border-left-color: transparent; border-radius: 0; color: var(--ink-3); }

.week-body {
  display: grid; grid-template-columns: var(--gutter-w) repeat(7, minmax(0, 1fr));
  position: relative;
}
.hours { position: relative; position: sticky; left: 0; z-index: 4; background: var(--paper); }
.week-head > :first-child, .allday-rail .gutter { position: sticky; left: 0; z-index: 6; background: var(--paper); }
.allday-rail .gutter { background: var(--surface-2); }
.hour-label {
  height: var(--hour-h); position: relative;
  font-family: var(--font-mono); font-size: 10px; color: var(--ink-3);
  text-align: right; padding-right: 7px;
}
.hour-label span { position: relative; top: -6px; }
.hour-label:first-child span { top: 1px; }   /* the first label has no rule above it to straddle */
.daycol {
  position: relative; border-left: 1px solid var(--rule-soft);
  background-image: repeating-linear-gradient(
    to bottom,
    var(--rule) 0, var(--rule) 1px,
    transparent 1px, transparent var(--hour-h)
  );
  background-size: 100% var(--hour-h);
}
.daycol.today { background-color: color-mix(in srgb, var(--accent) 5%, transparent); }

.blk {
  /* One column unless something shares the hour: `--lane-x` and `--lane-w` are
     fractions of the day, set by packBlocks, and default to the whole of it. */
  position: absolute;
  left: calc(3px + var(--lane-x, 0) * (100% - 6px));
  width: calc(var(--lane-w, 1) * (100% - 6px));
  z-index: calc(1 + var(--lane-z, 0));
  border-radius: 4px; padding: 3px 5px; overflow: hidden; cursor: pointer;
  font-size: calc(11.5px * var(--scale)); line-height: 1.3;
  border: 1px solid var(--rule);
  border-left: 2.5px solid var(--c, var(--accent));
  background: var(--bg, var(--surface));
  color: var(--ink);
  transition: box-shadow .12s ease, transform .12s ease;
  /* Panning is the browser's until the press is held out — a finger that came
     down on a block and kept going is scrolling the grid, not moving anything.
     `dragBlock` takes the gesture from there. */
  touch-action: pan-x pan-y;
  -webkit-touch-callout: none;   /* a long press must not raise iOS's own menu */
  user-select: none; -webkit-user-select: none;
}
.blk:hover { box-shadow: var(--shadow-1); z-index: 12; }
.blk .t { font-family: var(--font-mono); font-size: 10px; color: var(--ink-2); }
.blk .n {
  font-weight: 500; overflow: hidden; text-overflow: ellipsis;
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2;
}
/* too short for two lines: fold the time into the title line */
.blk.compact { display: flex; align-items: center; gap: 6px; padding-top: 1px; padding-bottom: 1px; }
.blk.compact .n { -webkit-line-clamp: 1; white-space: nowrap; }
.blk.compact .t { flex: none; }
/* Sharing the column with two others leaves a third of it: a short block can
   carry its time or its name across that, and the name is the one the grid
   cannot already tell you. */
.blk.narrow.compact .t { display: none; }
.blk.class { border-left-style: solid; cursor: pointer; }
.blk.ext { background: transparent; border: 1px solid var(--rule); border-left: 2.5px dashed var(--ink-3); cursor: grab; }
.blk.ext.dragging { cursor: grabbing; }
.blk.plan.done { opacity: .5; }
/* what ran past midnight the day before: squared off at the top, where it came in */
.blk.is-tail { border-top-left-radius: 0; border-top-right-radius: 0; border-top-style: dashed; }
/* a block being named where it will sit */
.blk.is-new { border-style: dashed; border-left-style: solid; background: var(--accent-soft); cursor: text; z-index: 14; }
.blk.is-new input {
  display: block; width: 100%; border: 0; padding: 0; margin-top: 1px; background: transparent;
  font: inherit; font-weight: 500; color: inherit; outline: none;
}
.blk.dragging { opacity: .85; box-shadow: var(--shadow-2); transform: scale(1.015); z-index: 20; }
/* Picked up by a finger, which has no cursor to change: the block has to say
   so itself, or a hold that worked looks like one that did not. */
@media (hover: none) {
  .blk.dragging { opacity: .95; transform: scale(1.05); box-shadow: var(--shadow-2); }
}

/* Only your own planned work can be picked up. The resize zones are the top
   and bottom edges themselves rather than a drawn handle — the same three
   targets every calendar has, and nothing to aim at. They keep a third of the
   block for the middle, matching grabMode(), so a quarter-hour block can still
   be moved. */
.blk.plan { cursor: grab; }
.blk.plan.dragging { cursor: grabbing; }
.blk.plan::before, .blk.plan::after {
  content: ""; position: absolute; left: 0; right: 0;
  height: min(8px, 33%); cursor: ns-resize;
}
.blk.plan::before { top: 0; }
.blk.plan::after { bottom: 0; }
/* a hairline on hover, so the edges are findable without being furniture */
.blk.plan:hover::before, .blk.plan:hover::after {
  background: linear-gradient(var(--c), var(--c)) center / 22px 2px no-repeat;
  opacity: .5; border-radius: 2px;
}
/* the pointer is carrying something; nothing under it should look like text */
body.is-moving, body.is-moving * { cursor: grabbing; user-select: none; }

.nowline { position: absolute; left: 0; right: 0; height: 0; border-top: 1px solid var(--danger); z-index: 6; pointer-events: none; }
.nowline::before { content: ""; position: absolute; left: -3px; top: -3.5px; width: 7px; height: 7px; border-radius: 50%; background: var(--danger); }

.drop-ghost {
  position: absolute; left: 3px; right: 3px; border-radius: 4px;
  border: 1px dashed var(--accent); background: var(--accent-soft); pointer-events: none; z-index: 15;
}
/* a range being swept out says what it is while you draw it */
.drop-ghost.is-new { border-style: solid; overflow: hidden; }
.drop-ghost .ghost-t {
  position: absolute; top: 1px; left: 5px; right: 4px;
  font-family: var(--font-mono); font-size: calc(10px * var(--scale));
  color: var(--accent); white-space: nowrap; overflow: hidden;
}
/* the pointer is drawing, so nothing under it should look like text */
body.is-sweeping, body.is-sweeping * { cursor: ns-resize; user-select: none; }
/* the chart's sweep runs the other way — same gesture, laid on its side */
body.is-sweeping-x, body.is-sweeping-x * { cursor: ew-resize; }

.time-range { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.time-range input { width: auto; min-width: 116px; }
.time-range .num { color: var(--ink-3); }

/* unscheduled tray */
.tray { border-top: 1px solid var(--rule); background: var(--surface-2); padding: 9px 22px 14px; flex: none; max-height: 30vh; overflow-y: auto; }
/* nothing waiting: one quiet line, not a shelf */
.tray.is-empty { padding: 6px 22px; }
.tray-items { display: flex; gap: 7px; flex-wrap: wrap; margin-top: 7px; }
.tray-item {
  border: 1px solid var(--rule); background: var(--surface); border-radius: var(--r);
  padding: 4px 9px; font-size: calc(12.5px * var(--scale)); cursor: grab;
  /* a finger scrolls the tray until it has held the chip (draggable's hold) */
  border-left: 2.5px solid var(--c, var(--ink-3)); touch-action: pan-x pan-y;
}
.tray-item:active { cursor: grabbing; }

/* ---------------- today ---------------- */

.focus-line {
  width: 100%; border: 0; border-bottom: 1px solid var(--rule); background: transparent;
  font-family: var(--font-heading); font-size: calc(20px * var(--scale)); font-weight: 600;
  letter-spacing: -.02em; padding: 4px 0 9px;
}
.focus-line::placeholder { color: var(--ink-3); font-weight: 400; }
.focus-line:focus { border-color: var(--accent); box-shadow: none; }
/* the same field at the end of the day, quieter: tonight it is a note, and
   only in the morning is it the headline */
.focus-line.sm { font-size: calc(15px * var(--scale)); font-weight: 500; letter-spacing: 0; }
.carried { margin-top: 7px; color: var(--ink-3); }
.top3 { display: flex; flex-direction: column; gap: 2px; }
.top3 .row { grid-template-columns: 22px minmax(0,1fr) auto; border: 0; }

/* ---------------- study ---------------- */

.preset { border: 1px solid var(--rule); background: var(--surface); border-radius: 20px; padding: 4px 12px; cursor: pointer; font-size: calc(12.5px * var(--scale)); }
.preset[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }

/* ---------------- peek panel ---------------- */

.scrim {
  position: fixed; inset: 0; background: rgba(20, 22, 26, .28);
  opacity: 0; pointer-events: none; transition: opacity .18s ease; z-index: 40;
}
.scrim.open { opacity: 1; pointer-events: auto; }

.peek {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(var(--peek-w), 100vw);
  background: var(--surface); border-left: 1px solid var(--rule);
  box-shadow: var(--shadow-2); z-index: 50;
  transform: translateX(101%); transition: transform .22s cubic-bezier(.32,.72,0,1);
  display: flex; flex-direction: column;
}
.peek.open { transform: none; }
.peek-h { display: flex; align-items: center; gap: 8px; padding: 12px 14px; border-bottom: 1px solid var(--rule); }
.peek-b { flex: 1; overflow-y: auto; padding: 16px 18px 40px; }
.peek-title {
  width: 100%; border: 0; background: transparent; padding: 0 0 10px;
  font-family: var(--font-heading); font-size: calc(19px * var(--scale)); font-weight: 600; letter-spacing: -.02em;
}
.props { border-top: 1px solid var(--rule-soft); margin-bottom: 14px; }
.prop { display: grid; grid-template-columns: 104px minmax(0, 1fr); gap: 10px; align-items: center; padding: 5px 0; border-bottom: 1px solid var(--rule-soft); }
.prop > label { font-family: var(--font-mono); font-size: 10px; letter-spacing: .1em; text-transform: uppercase; color: var(--ink-3); }
.prop input, .prop select { border-color: transparent; background: transparent; padding: 3px 5px; }
.prop input:hover, .prop select:hover { background: var(--rule-soft); }
/* Two fields and the word between them. It wraps rather than clipping: on a
   phone the From/To pair is a dozen pixels wider than the column it sits in,
   and a time input cut in half cannot be read or set. */
.prop .pair { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.subtask { display: flex; align-items: center; gap: 8px; padding: 3px 0; }
.subtask input[type="text"] { border-color: transparent; background: transparent; padding: 2px 4px; }
.subtask input[type="text"]:hover { background: var(--rule-soft); }
.subtask.done input[type="text"] { color: var(--ink-3); text-decoration: line-through; }

/* ---------------- modal ---------------- */

.modal {
  position: fixed; z-index: 60; inset: auto; left: 50%; top: 8vh; transform: translateX(-50%);
  width: min(680px, calc(100vw - 24px)); max-height: 84vh; overflow-y: auto;
  background: var(--surface); border: 1px solid var(--rule); border-radius: var(--r-lg);
  box-shadow: var(--shadow-2);
}
.modal-h { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--rule); position: sticky; top: 0; background: var(--surface); }
.modal-b { padding: 16px; }
.modal-f { display: flex; gap: 8px; justify-content: flex-end; padding: 12px 16px; border-top: 1px solid var(--rule); position: sticky; bottom: 0; background: var(--surface); }

/* ---------------- toast ---------------- */

#toasts { position: fixed; z-index: 70; left: 50%; bottom: 24px; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast {
  background: var(--ink); color: var(--paper); border-radius: var(--r);
  padding: 8px 14px; font-size: calc(13px * var(--scale)); box-shadow: var(--shadow-2);
  animation: rise .18s ease both; pointer-events: auto; display: flex; gap: 10px; align-items: center;
}
.toast button { background: transparent; border: 0; color: var(--accent); cursor: pointer; padding: 0; font-weight: 600; }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }

/* ---------------- mobile ---------------- */

.tabbar { display: none; }
.mobile-only { display: none; }
.nav-scrim { display: none; }   /* the sidebar is always there on a desktop */

@media (max-width: 860px) {
  :root { --hour-h: 46px; --gutter-w: 42px; }
  #app { grid-template-columns: 1fr; }
  /* Always there, parked just off the left edge, so a swipe has something to
     drag: the menu follows the finger, and on release it slides the rest of
     the way. `dragging` turns the transition off while the finger is down. */
  .sidebar {
    display: flex; position: fixed; inset: 0 auto 0 0; width: 82vw; max-width: 300px; z-index: 55;
    transform: translateX(-100%); transition: transform .22s ease;
  }
  .sidebar.open { transform: none; }
  .sidebar.open, .sidebar.dragging { box-shadow: var(--shadow-2); }
  .sidebar.dragging { transition: none; }
  /* Somewhere to tap that means "not that" — without it the only way back out
     of the menu is to pick something from it. Fades with the slide. */
  .nav-scrim {
    display: block; position: fixed; inset: 0; z-index: 54; background: rgba(0, 0, 0, .38);
    opacity: 0; pointer-events: none; transition: opacity .22s ease;
  }
  body.nav-open .nav-scrim { opacity: 1; pointer-events: auto; }
  body.nav-dragging .nav-scrim { transition: none; pointer-events: auto; }
  .main { padding-bottom: calc(52px + env(safe-area-inset-bottom)); }
  .topbar { padding: 10px 12px; gap: 8px; }
  .topbar h1 { font-size: calc(17px * var(--scale)); }
  /* the bar is already title plus quick add on a phone; the day itself is one
     tap away on Overview, drawn at full size */
  .nextup { display: none; }
  .pad { padding: 14px 12px 28px; }
  .peek { width: 100vw; border-left: 0; top: auto; height: 92dvh; border-radius: var(--r-lg) var(--r-lg) 0 0; transform: translateY(101%); }
  .peek.open { transform: none; }
  .weekbar { padding: 8px 12px; flex-wrap: nowrap; overflow: hidden; }
  .weekbar h2 { font-size: calc(15px * var(--scale)); white-space: nowrap; }
  .weekbar .eyebrow { display: none; }   /* the counts live on Overview */
  .tray { padding: 9px 12px calc(14px + env(safe-area-inset-bottom)); }
  .mobile-only { display: inline-flex; }
  .desktop-only { display: none !important; }

  .tabbar {
    display: grid; grid-template-columns: repeat(5, 1fr);
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 45;
    background: var(--surface); border-top: 1px solid var(--rule);
    padding-bottom: env(safe-area-inset-bottom);
  }
  .tabbar button {
    border: 0; background: transparent; padding: 7px 0 8px; cursor: pointer;
    display: flex; flex-direction: column; align-items: center; gap: 2px;
    color: var(--ink-3); font-size: 10px; font-family: var(--font-mono); letter-spacing: .04em;
  }
  .tabbar button[aria-current="page"] { color: var(--accent); }
  .tabbar .glyph { font-size: 16px; line-height: 1; }

  /* week: 3-day window on phones, swipe/scroll horizontally */
  .week-head, .week-body, .allday-rail { grid-template-columns: var(--gutter-w) repeat(7, 32vw); }
  /* as wide as the seven columns, not the screen: the sticky head and rail
     are hit-tested inside their own box, and with the box a screen wide a tap
     on the rail past the first columns went through to the grid under it */
  .week-wrap { width: max-content; }
  .week-scroll { overflow: auto; }
  .tray-items { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 4px; }
  /* no shrinking: a row that must not wrap squeezed every chip to one letter */
  .tray-item { flex: 0 0 auto; white-space: nowrap; max-width: 70vw; overflow: hidden; text-overflow: ellipsis; }
}

/* a phone on its side: the head, the due-date rail and the tray took the
   whole height between them and the hours had none left */
@media (max-height: 520px) {
  .week-scroll { min-height: 45vh; }
  .allday-rail { min-height: 0; max-height: 54px; }
  .tray { max-height: 22vh; padding-top: 6px; padding-bottom: 6px; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

@media print {
  .sidebar, .tabbar, .topbar, .weekbar, .tray { display: none !important; }
  body { background: #fff; }
}


/* ---------- category pages ---------- */

.page-h { display: flex; align-items: flex-end; gap: 10px; margin-bottom: 18px; flex-wrap: wrap; }
.crumb {
  border: 0; background: transparent; padding: 0 0 3px; cursor: pointer;
  color: var(--ink-3); display: block;
}
.crumb:hover { color: var(--ink); }

.area-group { margin-bottom: 22px; }
.area-group.is-archived { opacity: .55; }
.area-h {
  display: flex; align-items: center; gap: 9px;
  padding-bottom: 7px; border-bottom: 1px solid var(--rule);
}
.area-h .area-name {
  border: 0; background: transparent; padding: 0; cursor: pointer;
  font-size: calc(15px * var(--scale)); font-weight: 550; color: var(--ink);
  font-family: var(--font-heading); letter-spacing: -.01em;
}
.area-h .area-name:hover { text-decoration: underline; text-underline-offset: 3px; }
.area-body { padding-left: 17px; }
.area-when { padding: 7px 0 2px; color: var(--ink-3); }
.area-none { padding: 10px 0; color: var(--ink-3); font-size: calc(13px * var(--scale)); }
.area-more { margin-top: 4px; color: var(--ink-3); }

/* ---------- overview: open work by category ---------- */

.cat-load {
  display: block; width: 100%; text-align: left; cursor: pointer;
  border: 0; background: transparent; padding: 0; margin-bottom: 11px;
}
.cat-load:last-child { margin-bottom: 0; }
.cat-load-h { display: flex; align-items: baseline; gap: 8px; margin-bottom: 4px; }
.cat-load-name { font-size: calc(13px * var(--scale)); color: var(--ink); }
.cat-load-h .num { margin-left: auto; }
.cat-load:hover .cat-load-name { text-decoration: underline; text-underline-offset: 3px; }


/* ---------- capture ---------- */

.capture { margin: 0 0 20px; }
.capture-box {
  width: 100%; min-height: 46px; resize: none; overflow-y: auto;
  padding: 12px 14px; border: 1px solid var(--rule); border-radius: var(--r);
  background: var(--surface); color: var(--ink);
  font: inherit; font-size: calc(14px * var(--scale)); line-height: 1.5;
}
.capture-box::placeholder { color: var(--ink-3); }
.capture-box:focus { outline: none; border-color: var(--accent); background: var(--paper); }
.capture-actions { display: flex; align-items: center; gap: 6px; margin-top: 7px; }
.capture-actions[hidden] { display: none; }   /* display:flex would beat the UA rule */
.capture-hint { color: var(--ink-3); }

/* the area menu, shared by capture and the notes page */
.area-menu {
  position: absolute; top: calc(100% + 5px); right: 0; z-index: 40; width: 240px;
  background: var(--paper); border: 1px solid var(--rule); border-radius: var(--r);
  box-shadow: 0 8px 28px rgba(0,0,0,.14); padding: 6px;
}
.area-menu-filter {
  width: 100%; margin-bottom: 5px; padding: 6px 8px;
  border: 1px solid var(--rule); border-radius: 6px; background: var(--surface); color: var(--ink);
}
.area-menu-list { max-height: 230px; overflow-y: auto; display: flex; flex-direction: column; gap: 1px; }
.area-menu-item {
  display: flex; align-items: center; gap: 8px; width: 100%; text-align: left;
  padding: 7px 8px; border: 0; border-radius: 6px; background: transparent;
  color: var(--ink-2); font-size: calc(13px * var(--scale)); cursor: pointer;
}
.area-menu-item:hover, .area-menu-item:focus-visible {
  background: var(--rule-soft); color: var(--ink); outline: none;
}
.area-menu-none { padding: 8px; color: var(--ink-3); font-size: 13px; }

/* ---------- notes ---------- */

.note-card {
  border: 1px solid var(--rule); border-radius: var(--r);
  background: var(--surface); padding: 12px 14px; margin-bottom: 9px;
}
.note-card .card-text {
  white-space: pre-wrap; word-break: break-word;
  font-size: calc(14px * var(--scale)); line-height: 1.55; color: var(--ink);
}
.note-card .card-text:focus { outline: none; }
.note-foot {
  display: flex; align-items: center; gap: 7px;
  margin-top: 10px; padding-top: 8px; border-top: 1px solid var(--rule-soft);
}

/* ---------- calendar series picker ---------- */

.series-host {
  display: flex; flex-direction: column; gap: 5px;
  max-height: 260px; overflow-y: auto; margin-bottom: 9px;
  padding: 8px; border: 1px solid var(--rule); border-radius: var(--r); background: var(--surface-2);
}
.series-host[hidden] { display: none; }
.series-note { color: var(--ink-3); margin-bottom: 3px; }
.series {
  display: block; width: 100%; text-align: left; cursor: pointer;
  padding: 10px 12px; border: 1px solid var(--rule); border-radius: var(--r);
  background: var(--surface); color: var(--ink);
}
.series:hover, .series:focus-visible { border-color: var(--accent); outline: none; }
.series-title { font-size: calc(14px * var(--scale)); font-weight: 550; margin-bottom: 3px; }
.series-when { color: var(--ink-2); }
.series-where { color: var(--ink-3); margin-top: 2px; }


/* ---------- overview: today on the left, decisions on the right ---------- */

/* Today's clock. The day opens at 8am with the small hours a scroll above,
   so an empty afternoon still reads as empty space rather than as nothing. */
:root { --day-hour-h: 34px; }

.day-scroll {
  height: calc(var(--day-hour-h) * 16);   /* 8am to midnight without scrolling */
  max-height: 60vh; overflow-y: auto; overflow-x: hidden;
  border-top: 1px solid var(--rule-soft);
}
.day-grid { display: grid; grid-template-columns: 52px minmax(0, 1fr); position: relative; }
.day-hours { position: relative; }
.day-hours .hour-label { height: var(--day-hour-h); }
.day-lanes {
  position: relative; border-left: 1px solid var(--rule-soft);
  background-image: repeating-linear-gradient(
    to bottom,
    var(--rule) 0, var(--rule) 1px,
    transparent 1px, transparent var(--day-hour-h)
  );
  background-size: 100% var(--day-hour-h);
}
.day-allday {
  display: flex; flex-wrap: wrap; gap: 5px;
  padding: 8px 14px; border-top: 1px solid var(--rule-soft);
}
.day-chip {
  border: 1px solid var(--rule); border-left: 2.5px solid var(--c, var(--ink-3));
  background: var(--surface); color: var(--ink); border-radius: 4px;
  padding: 2px 8px; font-size: calc(12px * var(--scale)); cursor: pointer;
  max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.day-chip:hover { box-shadow: var(--shadow-1); }
/* tomorrow, at a glance: one line, a button the size of a card */
.tomorrow-peek {
  display: flex; flex-direction: column; gap: 4px; align-items: flex-start; width: 100%;
  padding: 12px 15px; margin-top: 12px; cursor: pointer; text-align: left;
  color: var(--ink); font: inherit;
}
.tomorrow-peek:hover { border-color: var(--accent); }
.tomorrow-peek .peek-first { font-size: calc(13.5px * var(--scale)); font-weight: 550; }

.today-col .card-h { border-bottom: 0; }


.overview-split {
  display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr);
  gap: 14px; align-items: start; margin-bottom: 18px;
}
.overview-side { display: flex; flex-direction: column; gap: 14px; }
.today-col .today-date {
  font-family: var(--font-heading); font-size: calc(17px * var(--scale));
  font-weight: 550; letter-spacing: -.01em; color: var(--ink);
}
.today-col .card-h { align-items: baseline; gap: 9px; }
@media (max-width: 900px) {
  .overview-split { grid-template-columns: minmax(0, 1fr); }
}

/* ---------- drag to reorder ---------- */

.drag-handle {
  border: 0; background: transparent; padding: 0 2px; cursor: grab;
  color: var(--ink-3); font-size: 13px; line-height: 1; flex: none;
  touch-action: none;   /* the pointer drag owns this gesture, not the scroller */
  user-select: none; -webkit-user-select: none;
}
.drag-handle:hover { color: var(--ink); }
.is-dragging { opacity: .6; }
.is-dragging .drag-handle { cursor: grabbing; }
body.is-reordering { cursor: grabbing; user-select: none; }

.area-groups .area-group { transition: none; }

/* sidebar chips become a row with a grip plus the link */
.rail-areas { display: flex; flex-direction: column; }
.area-chip { gap: 4px; padding: 0 8px 0 14px; }
.area-chip .area-chip-open {
  display: flex; align-items: center; gap: 8px; flex: 1; min-width: 0;
  padding: 4px 0; border: 0; background: transparent; cursor: pointer;
  color: inherit; font: inherit; text-align: left;
}
.area-chip .drag-handle { opacity: 0; }
.area-chip:hover .drag-handle, .drag-handle:focus-visible { opacity: 1; }
@media (hover: none) { .area-chip .drag-handle { opacity: .6; } }

/* a pinned view inside a category group: no grip, so it pays the grip's width
   in padding instead and still lines up with the areas above it */
.area-chip.is-pin { padding-left: 32px; }
.pin-glyph { width: 8px; flex: none; color: var(--ink-3); font-size: 11px; line-height: 1; }


/* ---------------- the daily journal ----------------
   A page, not a form: no prompt, no label above the box, and a floor deep
   enough that starting to write does not feel like filling in a field. */

.journal .card-h { align-items: baseline; gap: 10px; }
.journal-date { color: var(--ink-2); font-size: calc(13px * var(--scale)); }
.journal-box {
  width: 100%; display: block; resize: vertical;
  min-height: 190px; padding: 2px 0;
  border: 0; background: transparent; color: var(--ink);
  font-family: var(--font-body); font-size: calc(14.5px * var(--scale));
  line-height: 1.62; overflow: hidden;
}
.journal-box:focus { outline: none; }
.journal-history { padding: 0 15px 12px; }
.journal-past { display: flex; flex-direction: column; }
.journal-day { padding: 11px 0 4px; border-top: 1px solid var(--rule-soft); }
.journal-day:first-child { border-top: 0; }
.journal-day .eyebrow { color: var(--ink-3); margin-bottom: 4px; }
.journal-day .journal-box { min-height: 0; font-size: calc(14px * var(--scale)); }

/* the freewrite: the same box, shorter, at the bottom of every area page */
.freewrite { margin-top: 18px; }
.freewrite-box { min-height: 120px; }

/* ---------------- focuses and sprints ---------------- */

.sprint-form { display: flex; flex-direction: column; gap: 14px; }
.deliv-blurb { margin: 2px 0 0; color: var(--ink-3); font-size: calc(12.5px * var(--scale)); }
.deliv { display: flex; flex-direction: column; gap: 6px; }
.deliv .group-h { margin-bottom: 2px; }
.deliv-row { display: flex; align-items: center; gap: 9px; }
.deliv-row.done .deliv-text { color: var(--ink-3); text-decoration: line-through; }
.deliv-text { flex: 1; min-width: 0; }
.deliv-add { border-style: dashed; }


/* ---------------- links ---------------- */

.link-row { grid-template-columns: minmax(0, 1fr) auto auto auto; cursor: default; }
.link-row .link-title {
  color: var(--ink); text-decoration: none;
  min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.link-row .link-title:hover, .link-row .link-title:focus-visible {
  text-decoration: underline; text-decoration-color: var(--ink-3);
}
.link-row .link-edit {
  padding: 5px 8px; border: 1px solid var(--accent); border-radius: var(--r);
  background: var(--surface); color: var(--ink); font: inherit; min-width: 0;
}
.link-row select {
  padding: 4px 6px; border: 1px solid var(--rule); border-radius: var(--r);
  background: var(--surface); color: var(--ink-2); font: inherit;
  font-size: calc(12px * var(--scale));
}
.link-new {
  padding: 6px 9px; border: 1px solid var(--rule); border-radius: var(--r);
  background: var(--surface); color: var(--ink); font: inherit;
  font-size: calc(13px * var(--scale)); min-width: 210px;
}

@media (max-width: 620px) {
  .link-new { min-width: 0; width: 100%; }
  .group-h .link-new { margin-top: 6px; }
}


/* ---------------- wishlist ---------------- */

.wish-add { display: flex; gap: 8px; margin: 4px 0 10px; max-width: 560px; }
.wish-new {
  flex: 1; min-width: 0; padding: 8px 10px;
  border: 1px solid var(--rule); border-radius: var(--r);
  background: var(--surface); color: var(--ink); font: inherit;
}

.wish-row {
  grid-template-columns: minmax(0, 1fr) 76px 116px 148px auto;
  cursor: default;
}
.wish-name { display: flex; align-items: center; gap: 6px; min-width: 0; }
.wish-name .title { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wish-rename {
  width: 100%; padding: 5px 8px; border: 1px solid var(--accent);
  border-radius: var(--r); background: var(--surface); color: var(--ink); font: inherit;
}

.wish-price, .wish-status, .wish-eta {
  padding: 4px 6px; border: 1px solid var(--rule); border-radius: var(--r);
  background: var(--surface); color: var(--ink-2); font: inherit;
  font-size: calc(12px * var(--scale)); min-width: 0; width: 100%;
}
.wish-price { text-align: right; font-family: var(--font-mono); }
.wish-price:placeholder-shown { color: var(--ink-3); }

/* the ETA is the only thing here with a clock on it, so it is the only thing
   that changes colour */
.wish-eta.is-soon { color: var(--warn); border-color: var(--warn); }
.wish-eta.is-today { color: var(--warn); border-color: var(--warn); font-weight: 550; }
.wish-eta.is-late { color: var(--danger); border-color: var(--danger); font-weight: 550; }
.wish-eta-none { text-align: center; color: var(--ink-3); }
/* the carrier's line under a tracked parcel: where it is, the hour it lands */
.wish-track { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: baseline; padding: 0 0 2px; }
.wish-track .eyebrow { color: var(--ink-3); }
.wish-track .eyebrow.is-err { color: var(--danger); }
.wish-track .eyebrow.is-live { color: var(--accent); }

@media (max-width: 820px) {
  .wish-row { grid-template-columns: minmax(0, 1fr) 64px 100px; row-gap: 6px; }
  .wish-row .wish-eta, .wish-row .wish-eta-none { grid-column: 1 / -1; }
  .wish-add { max-width: none; }
}


/* ---------- scheduled / deadline toggle ---------- */

/* a colour of its own: the area's, or one of the ten */
.swatches { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.swatch {
  width: 20px; height: 20px; border-radius: 50%; padding: 0; cursor: pointer;
  border: 2px solid transparent; background: var(--c); color: #fff;
  font: 600 10px/1 var(--font-mono);
}
.swatch.on { border-color: var(--ink); }
.swatch:hover { transform: scale(1.12); }

.mode-toggle {
  display: inline-flex; border: 1px solid var(--rule); border-radius: var(--r); overflow: hidden;
}
.mode-toggle .mode {
  border: 0; background: transparent; cursor: pointer;
  padding: 5px 12px; color: var(--ink-2);
  font: inherit; font-size: calc(12.5px * var(--scale));
}
.mode-toggle .mode + .mode { border-left: 1px solid var(--rule); }
.mode-toggle .mode:hover { background: var(--rule-soft); color: var(--ink); }
.mode-toggle .mode.on { background: var(--accent-soft); color: var(--ink); font-weight: 550; }


/* ---------- repeating: the weekday picker ----------
   Seven of them, so they have to be small; a row rather than a select because
   "Tuesdays and Thursdays" is one glance and two taps, not a scroll. */

/* Seven across whatever room there is, never wrapping: a week that folds onto
   two lines stops reading as a week. They share the width instead. */
.daypick { display: flex; gap: 4px; }
.daypick .day {
  flex: 1 1 0; min-width: 0; max-width: 34px; aspect-ratio: 1; cursor: pointer;
  border: 1px solid var(--rule); border-radius: 50%;
  background: var(--surface); color: var(--ink-2);
  font: inherit; font-size: calc(12px * var(--scale)); line-height: 1;
  display: flex; align-items: center; justify-content: center;
}
.daypick .day:hover { border-color: var(--accent); color: var(--ink); }
.daypick .day.on {
  background: var(--accent); border-color: var(--accent); color: var(--accent-ink);
  font-weight: 600;
}

/* ---------- sidebar: carets and collapsing ---------- */

.rail-caret {
  border: 0; background: transparent; cursor: pointer; flex: none;
  width: 14px; padding: 0; margin-left: auto;
  color: var(--ink-3); font-size: 12px; line-height: 1;
  transform: rotate(90deg); transition: transform .15s ease;
}
.rail-caret.is-closed { transform: rotate(0deg); }
.rail-caret:hover { color: var(--ink); }

/* One column, not a zero-width one: display:none takes the sidebar out of the
   grid entirely, so main would slide into the first column and get 0px. */
body.rail-hidden #app { grid-template-columns: minmax(0, 1fr); }
body.rail-hidden .sidebar { display: none; }

/* ---------- habits ---------- */

.habits { display: flex; flex-direction: column; }
.habit-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) repeat(7, 38px) 44px 62px;
  align-items: center; gap: 2px;
  border-bottom: 1px solid var(--rule-soft); padding: 3px 0;
}
.habit-head { border-bottom: 1px solid var(--rule); padding-bottom: 6px; }
.habit-tied { font-size: 9.5px; color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 160px; }
.habit-name { display: flex; align-items: center; gap: 6px; min-width: 0; padding-right: 10px; }
.habit-title {
  border: 0; background: transparent; padding: 4px 2px; min-width: 0; flex: 1;
  color: var(--ink); font: inherit; font-size: calc(13.5px * var(--scale));
}
.habit-title:focus { outline: none; background: var(--surface); border-radius: 4px; }
.habit-del { opacity: 0; flex: none; }
.habit-row:hover .habit-del, .habit-del:focus-visible { opacity: 1; }
@media (hover: none) { .habit-del { opacity: .7; } }

.habit-day { display: flex; flex-direction: column; align-items: center; gap: 1px; }
.habit-day.is-today .habit-dnum { color: var(--accent-ink); background: var(--accent); border-radius: 4px; padding: 0 4px; }
.habit-dnum { font-size: 11px; color: var(--ink-2); }
.habit-head .habit-day.is-future { opacity: .45; }

.tick {
  width: 26px; height: 26px; border-radius: 6px; cursor: pointer;
  border: 1px solid var(--rule); background: var(--surface);
  color: var(--accent-ink); font-size: 13px; line-height: 1;
  display: flex; align-items: center; justify-content: center;
  transition: background .12s ease, border-color .12s ease;
}
.tick:hover { border-color: var(--accent); }
.tick.on { background: var(--accent); border-color: var(--accent); }
.tick:disabled { opacity: .3; cursor: default; }
.tick:disabled:hover { border-color: var(--rule); }

.habit-streak { text-align: right; color: var(--ink-2); font-size: 12px; padding-right: 2px; }
.habit-goal { text-align: right; padding-left: 10px; }
.habit-goal .goal-n { font-size: 12px; color: var(--ink-3); display: block; }
.habit-goal .goal-bar { margin-top: 3px; }
.habit-head .habit-goal { padding-left: 10px; }
.habit-add { display: flex; gap: 8px; margin-top: 16px; max-width: 420px; }
.habit-new {
  flex: 1; padding: 8px 10px; border: 1px solid var(--rule); border-radius: var(--r);
  background: var(--surface); color: var(--ink); font: inherit;
}

@media (max-width: 820px) {
  .habit-row { grid-template-columns: minmax(0, 1fr) repeat(7, 30px) 30px 46px; }
  .tick { width: 22px; height: 22px; }
}

/* On a phone the name cannot share a line with the week: seven boxes and two
   numbers take 280px of a 350px page, and the habit is left reading "Sunscr…"
   in the gap. So the name takes a line of its own and the week sits under it,
   full width — which also makes the ticks thumb-sized rather than 22px. */
@media (max-width: 620px) {
  .habit-row {
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 6px 3px; padding: 9px 0;
  }
  .habit-name { grid-row: 1; grid-column: 1 / 5; padding-right: 0; }
  .habit-streak { grid-row: 1; grid-column: 5 / 6; }
  .habit-goal { grid-row: 1; grid-column: 6 / 8; padding-left: 8px; }
  .habit-head .habit-goal { padding-left: 8px; }
  .habit-day { grid-row: 2; width: 100%; }
  .tick { width: 100%; height: 34px; border-radius: 7px; font-size: 15px; }
  .habit-title { font-size: calc(15px * var(--scale)); }
  .habit-goal .goal-bar { margin-top: 2px; }
}


/* ---------------- semester chart ----------------
   One horizontal scroller. The label column is sticky rather than a second
   parallel stack, so rows cannot drift out of line with their own labels. */

.gantt {
  overflow-x: auto; overflow-y: hidden;
  border: 1px solid var(--rule); border-radius: var(--r-lg);
  background: var(--surface);
}
.gantt-inner { width: max-content; min-width: 100%; }

.gantt-row {
  display: grid;
  grid-template-columns: var(--label-w) calc(var(--day-w) * var(--term-days));
  border-bottom: 1px solid var(--rule-soft);
}
.gantt-row:last-child { border-bottom: 0; }

.gantt-label {
  position: sticky; left: 0; z-index: 3;
  display: flex; align-items: center; gap: 8px;
  min-width: 0; padding: 6px 12px;
  background: var(--surface); border-right: 1px solid var(--rule);
  color: var(--ink-2); font: inherit; font-size: calc(13px * var(--scale));
  text-align: left;
}
.gantt-label.is-area { border-top: 0; border-left: 0; border-bottom: 0; cursor: pointer; }
.gantt-label.is-area:hover { background: var(--surface-2); color: var(--ink); }
.gantt-label .bar { width: 3px; height: 15px; border-radius: 2px; flex: none; }
.gantt-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.gantt-head { background: var(--surface-2); position: relative; z-index: 4; }
.gantt-head .gantt-label { background: var(--surface-2); }
.gantt-head .gantt-track { height: 26px; }
.gantt-month {
  position: absolute; top: 0; bottom: 0;
  display: flex; align-items: center; padding-left: 6px;
  border-left: 1px solid var(--rule);
  font-family: var(--font-mono); font-size: calc(10px * var(--scale));
  letter-spacing: .11em; text-transform: uppercase; color: var(--ink-3);
}

.gantt-body { position: relative; }
.gantt-track { position: relative; min-height: 28px; }

/* one overlay for the whole body, so the ruling cannot disagree row to row */
.gantt-rules {
  position: absolute; top: 0; bottom: 0; left: var(--label-w); right: 0;
  pointer-events: none; z-index: 0;
}
.gantt-rule { position: absolute; top: 0; bottom: 0; width: 1px; background: var(--rule-soft); }
.gantt-rule.is-month { background: var(--rule); }
.gantt-now { position: absolute; top: 0; bottom: 0; width: 2px; background: var(--accent); opacity: .5; }

.gantt-cat {
  padding: 11px 12px 3px;
  border-bottom: 1px solid var(--rule-soft);
  background: var(--surface);
}
.gantt-cat .eyebrow { position: sticky; left: 12px; color: var(--ink-2); }

.gantt-item {
  position: absolute; z-index: 1;
  display: flex; align-items: center; gap: 6px;
  height: 16px; padding: 0; border: 0; background: transparent;
  cursor: pointer; white-space: nowrap; color: var(--ink-2);
  font: inherit; font-size: calc(11.5px * var(--scale)); line-height: 1;
}
.gantt-item:hover, .gantt-item:focus-visible { z-index: 2; color: var(--ink); }

/* A focus or a sprint: a stretch of weeks, drawn as ground for the work to sit
   on rather than as another bar competing with it. Same shape as a task bar —
   a rectangle plus a label — so the label can step outside when the rectangle
   is too narrow to hold it. */
.gantt-span {
  position: absolute; z-index: 1;
  display: flex; align-items: center; gap: 6px;
  height: 19px; padding: 0; border: 0; background: transparent;
  color: var(--ink-2); cursor: pointer; text-align: left; white-space: nowrap;
  font: inherit; font-size: calc(11.5px * var(--scale)); line-height: 1;
}
.gantt-band {
  position: relative; flex: none; overflow: hidden;
  display: flex; align-items: center; gap: 6px;
  height: 100%; min-width: 3px; padding: 0 6px; border-radius: 4px;
  border: 1px solid color-mix(in srgb, var(--c) 78%, transparent);
  background: color-mix(in srgb, var(--c) 20%, transparent);
}
.gantt-span:hover, .gantt-span:focus-visible { z-index: 3; color: var(--ink); }
.gantt-span:hover .gantt-band, .gantt-span:focus-visible .gantt-band {
  background: color-mix(in srgb, var(--c) 32%, transparent);
}
/* a focus has no deliverables, so it is an outline and nothing else; a sprint
   is solid, and fills as its list is ticked off */
.gantt-span.is-focus .gantt-band { border-style: dashed; }
.gantt-fill {
  position: absolute; inset: 0 auto 0 0; z-index: 0;
  background: color-mix(in srgb, var(--c) 40%, transparent);
}
.gantt-span-t {
  position: relative; z-index: 1;
  min-width: 0; overflow: hidden; text-overflow: ellipsis;
}
.gantt-span-n { position: relative; z-index: 1; flex: none; color: var(--ink-2); }
/* written beside the band, because the band is too narrow to hold it */
.gantt-span:not(.inside) .gantt-tag { color: var(--ink-2); }
.gantt-span.flip { flex-direction: row-reverse; }
.gantt-span.clip-l .gantt-band { border-top-left-radius: 0; border-bottom-left-radius: 0; border-left: 0; }
.gantt-span.clip-r .gantt-band { border-top-right-radius: 0; border-bottom-right-radius: 0; border-right: 0; }

.gantt-track.is-lane { cursor: crosshair; }
.gantt-ghost {
  position: absolute; top: 4px; height: 19px; z-index: 5;
  display: flex; align-items: center; padding: 0 5px;
  border: 1px dashed var(--c); border-radius: 4px;
  background: color-mix(in srgb, var(--c) 16%, transparent);
  color: var(--ink-2); pointer-events: none;
  font-family: var(--font-mono); font-size: calc(10px * var(--scale));
}
.gantt-shape { flex: none; height: 9px; min-width: 4px; border-radius: 3px; background: var(--c); }
/* a deadline is a moment, so it is a point and not a one-day bar */
.gantt-item.is-mile .gantt-shape {
  width: 9px; height: 9px; border-radius: 1px; margin: 0 2px; transform: rotate(45deg);
}
/* a bar within a label's width of the end writes its title on the other side
   of itself, anchored by its right edge, or the scroller cuts the words off */
.gantt-item.flip { flex-direction: row-reverse; }
/* the title inside a bar wide enough to hold it */
.gantt-item.inside .gantt-shape { display: flex; align-items: center; overflow: hidden; padding: 0 6px; }
.gantt-item.inside .gantt-tag { min-width: 0; overflow: hidden; text-overflow: ellipsis; color: var(--ink); }
.gantt-item.clip-l .gantt-shape { border-top-left-radius: 0; border-bottom-left-radius: 0; }
.gantt-item.clip-r .gantt-shape { border-top-right-radius: 0; border-bottom-right-radius: 0; }
.gantt-item.done { opacity: .42; }
.gantt-item.done .gantt-tag { text-decoration: line-through; }
.gantt-quiet {
  position: absolute; left: 8px; top: 7px;
  font-size: calc(11.5px * var(--scale)); color: var(--ink-3); font-style: italic;
}

.gantt-controls { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; margin: 2px 0 10px; }
.gantt-pick summary { cursor: pointer; color: var(--ink-2); font-size: calc(13px * var(--scale)); }
.gantt-picker { display: flex; flex-direction: column; gap: 6px; margin: 9px 0 4px; }
.gantt-pickrow { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.gantt-pickrow .eyebrow { width: 72px; flex: none; }
.gantt-donetoggle {
  display: flex; align-items: center; gap: 7px; cursor: pointer;
  color: var(--ink-2); font-size: calc(13px * var(--scale));
}

.gantt-foot {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  margin-top: 10px; color: var(--ink-3); font-size: calc(12px * var(--scale));
}
.gantt-key { display: flex; align-items: center; gap: 6px; }
.gantt-key span + span { margin-left: 9px; }
.key-bar { width: 16px; height: 8px; border-radius: 3px; background: var(--ink-3); }
.key-mile { width: 8px; height: 8px; background: var(--ink-3); transform: rotate(45deg); }
.key-now { width: 2px; height: 12px; background: var(--accent); }
.key-focus { width: 18px; height: 9px; border: 1px dashed var(--ink-3); border-radius: 3px; }
.key-sprint { width: 18px; height: 9px; border: 1px solid var(--ink-3); border-radius: 3px; background: var(--rule-soft); }


/* ---------------- version history ---------------- */

.release { border-top: 1px solid var(--rule-soft); padding: 12px 0 4px; }
.release:first-child { border-top: 0; padding-top: 0; }
.release-h { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.release-h h3 { font-size: calc(14px * var(--scale)); }
.release ul { margin: 7px 0 0; padding-left: 17px; }
.release li {
  margin-bottom: 5px; color: var(--ink-2);
  font-size: calc(13.5px * var(--scale)); line-height: 1.45;
}
.release li::marker { color: var(--ink-3); }
.ver-tag {
  font-family: var(--font-mono); font-size: calc(11.5px * var(--scale));
  color: var(--accent); background: var(--accent-soft);
  padding: 1px 7px; border-radius: 4px;
}
details.history > summary {
  cursor: pointer; color: var(--ink-2);
  font-size: calc(13px * var(--scale)); margin-top: 4px;
}
details.history[open] > summary { margin-bottom: 10px; }

/* ---------- the now line ---------- */
/* Drawn only in today's column, moved once a minute. The dot hangs off the
   gutter side so the line reads as "here", not as another gridline. */
.now-line {
  position: absolute; left: 0; right: 0; height: 0; z-index: 4; pointer-events: none;
  border-top: 2px solid var(--accent);
}
.now-line::before {
  content: ''; position: absolute; left: -5px; top: -5px; width: 8px; height: 8px;
  border-radius: 50%; background: var(--accent);
}

/* ---------- links ---------- */
.favicon { width: 16px; height: 16px; border-radius: 3px; flex: none; vertical-align: -3px; margin-right: 7px; }

/* ---------- push to tomorrow ---------- */
.push-btn {
  border: 0; background: transparent; color: var(--ink-3); cursor: pointer;
  font-size: 13px; line-height: 1; padding: 3px 5px; border-radius: 6px;
  opacity: 0; transition: opacity .12s;
}
.row:hover .push-btn, .row:focus-within .push-btn { opacity: 1; }
.push-btn:hover { background: var(--accent-soft); color: var(--accent); }
@media (hover: none) { .push-btn { opacity: .7; } }

/* ---------- find ---------- */
.search { display: flex; flex-direction: column; gap: 10px; min-height: 40vh; }
.search-input {
  width: 100%; font-size: calc(15px * var(--scale)); padding: 10px 12px;
  border: 1px solid var(--rule); border-radius: var(--r); background: var(--surface); color: var(--ink);
}
.search-input:focus { outline: 0; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.search-results { display: flex; flex-direction: column; overflow: auto; max-height: 60vh; }
.search-group { margin: 8px 0 3px; color: var(--ink-3); }
.search-hit {
  display: block; width: 100%; text-align: left; border: 0; background: transparent;
  padding: 7px 8px; border-radius: 6px; cursor: pointer; color: var(--ink); font: inherit;
}
.search-hit:hover, .search-hit:focus-visible { background: var(--accent-soft); outline: 0; }
.search-line { display: flex; align-items: center; gap: 10px; min-width: 0; }
.search-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.search-title.done { text-decoration: line-through; color: var(--ink-3); }
.search-meta { display: flex; gap: 6px; align-items: center; flex: none; }
.search-empty { color: var(--ink-3); padding: 12px 8px; }

/* ---------- keyboard help ---------- */
.keys { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; align-items: center; }
.keys kbd {
  font-family: var(--font-mono); font-size: 11px; padding: 2px 6px; border-radius: 4px;
  border: 1px solid var(--rule); background: var(--surface-2, var(--surface)); color: var(--ink-2);
}

/* ---------- quick add within thumb reach ---------- */
/* On a phone the box leaves the top bar and sits just above the tabs, where a
   thumb already is. It is the same input — nothing in the JS knows it moved. */
@media (max-width: 860px) {
  .quickadd {
    position: fixed; left: 8px; right: 8px; z-index: 46;
    bottom: calc(52px + env(safe-area-inset-bottom) + 8px);
    background: var(--surface); box-shadow: var(--shadow-2);
  }
  .topbar h1 { flex: 1; }
  .main { padding-bottom: calc(52px + 58px + env(safe-area-inset-bottom)); }
  .tray { padding-bottom: calc(60px + env(safe-area-inset-bottom)); }
  .push-btn { opacity: .7; }
}
