:root {
  /* Layout: a week of coverage. A shift block is solid navy once confirmed, hatched while it
     awaits a reply, and flagged red when the person can't make it. The 24-hour coverage strip
     over each day is the one loud element; everything around it stays quiet. */
  --paper: #F6F5F3;
  --surface: #FFFFFF;
  --sunken: #ECEAE7;
  --ink: #272424;
  --ink-2: #4F4848;
  --muted: #766C6C;
  --line: #D8D3D3;
  --line-soft: #EBE9E9;
  --navy: #011973;
  --navy-ink: #011973;
  --navy-wash: #E6E9F5;
  --on-navy: #FFFFFF;
  --red: #DD2424;
  --red-ink: #A51919;
  --red-wash: #FCE9E9;
  --sky: #63B1FB;
  --good: #1F7A4D;
  --good-wash: #E3F3EA;
  --warn: #8A5200;
  --warn-wash: #FBF0DC;
  --hatch: rgba(1, 25, 115, 0.16);
  --shade: rgba(39, 36, 36, 0.45);
  --font: "Satoshi", "DM Sans", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --r-chip: 4px;
  --r-ctl: 8px;
  --r-panel: 14px;
  --tabbar: 0px;
  /* Phone safe areas (notch, home indicator) and the height of the on-screen keyboard, set from app.js. */
  --sat: env(safe-area-inset-top, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
  --sal: env(safe-area-inset-left, 0px);
  --sar: env(safe-area-inset-right, 0px);
  --kb: 0px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #141318; --surface: #1E1D24; --sunken: #26252D;
    --ink: #F4F3F1; --ink-2: #D5D1D1; --muted: #A39B9B; --line: #3D3A44; --line-soft: #2A2830;
    --navy: #3D56C9; --navy-ink: #AAB8F6; --navy-wash: #1F2547; --on-navy: #FFFFFF;
    --red: #F05252; --red-ink: #F7A3A3; --red-wash: #3A1414; --sky: #63B1FB;
    --good: #6CC797; --good-wash: #14301F; --warn: #E3B565; --warn-wash: #33260B;
    --hatch: rgba(170, 184, 246, 0.2); --shade: rgba(0, 0, 0, 0.6);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #141318; --surface: #1E1D24; --sunken: #26252D;
  --ink: #F4F3F1; --ink-2: #D5D1D1; --muted: #A39B9B; --line: #3D3A44; --line-soft: #2A2830;
  --navy: #3D56C9; --navy-ink: #AAB8F6; --navy-wash: #1F2547; --on-navy: #FFFFFF;
  --red: #F05252; --red-ink: #F7A3A3; --red-wash: #3A1414; --sky: #63B1FB;
  --good: #6CC797; --good-wash: #14301F; --warn: #E3B565; --warn-wash: #33260B;
  --hatch: rgba(170, 184, 246, 0.2); --shade: rgba(0, 0, 0, 0.6);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { height: 100%; -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100%; background: var(--paper); color: var(--ink);
  font-family: var(--font); font-size: 16px; line-height: 1.5; -webkit-font-smoothing: antialiased;
}
h1, h2, h3, p { margin: 0; }
h1, h2, h3 { line-height: 1.15; letter-spacing: -0.02em; text-wrap: balance; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
/* Touch: no double-tap zoom delay on controls, no grey flash, a visible pressed state instead. */
button, a, input, select, textarea, label { touch-action: manipulation; }
* { -webkit-tap-highlight-color: transparent; }
button:active:not([disabled]), a.btn:active { opacity: 0.72; }
a { color: var(--navy-ink); }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid var(--sky); outline-offset: 2px; border-radius: 4px; }
.vh { position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.small { font-size: 14px; line-height: 1.45; }
svg.ico { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- controls ---------- */
.btn {
  appearance: none; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 10px 16px; border-radius: var(--r-ctl); border: 1px solid var(--line);
  background: var(--surface); color: var(--ink); font-weight: 600; line-height: 1.2; text-decoration: none; text-align: center;
  max-width: 100%; /* long labels wrap inside the button on narrow phones instead of pushing the page wide */
}
.btn.primary { background: var(--navy); border-color: var(--navy); color: var(--on-navy); }
.btn.quiet { background: transparent; border-color: transparent; color: var(--ink-2); }
.btn.danger { color: var(--red-ink); border-color: var(--red); background: transparent; }
.btn.wide { width: 100%; }
.btn[disabled] { opacity: 0.5; cursor: not-allowed; }
.btn.sm { min-height: 36px; padding: 6px 12px; font-size: 14px; }
.iconbtn {
  appearance: none; display: inline-grid; place-items: center; width: 44px; height: 44px; border-radius: var(--r-ctl);
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
}
.iconbtn.quiet { border-color: transparent; background: transparent; }
@media (hover: hover) {
  .btn:not([disabled]):hover, .iconbtn:hover { border-color: var(--ink-2); }
  .btn.primary:not([disabled]):hover { filter: brightness(1.15); border-color: var(--navy); }
  .btn.quiet:not([disabled]):hover, .iconbtn.quiet:hover { background: var(--line-soft); border-color: transparent; }
}
.field { display: grid; gap: 6px; min-width: 0; align-content: start; }
.field > label, .field > .lab { font-weight: 600; font-size: 14px; }
.field .hint { font-size: 13px; line-height: 1.4; color: var(--muted); }
.inp {
  display: block; width: 100%; min-height: 44px; padding: 9px 12px; border: 1px solid var(--line);
  border-radius: var(--r-ctl); background: var(--surface); color: var(--ink);
}
textarea.inp { resize: vertical; min-height: 76px; line-height: 1.4; }
.inp:not(textarea) { height: 44px; }
.inp[type="date"], .inp[type="time"] { min-width: 0; max-width: 100%; }
.inp::-webkit-date-and-time-value { text-align: left; }
.inp:focus-visible { outline-offset: 0; border-color: var(--navy-ink); }
.linkbtn { appearance: none; background: none; border: 0; padding: 0; color: var(--navy-ink); font-weight: 600; text-decoration: underline; }
.row { display: flex; flex-wrap: wrap; gap: 12px; }
.row > .field { flex: 1 1 130px; }
.check { display: grid; grid-template-columns: 22px 1fr; gap: 10px; align-items: start; font-size: 15px; line-height: 1.4; }
.check input { width: 20px; height: 20px; margin: 1px 0 0; accent-color: var(--navy); }
.note { font-size: 14px; line-height: 1.45; padding: 10px 12px; border-radius: var(--r-ctl); background: var(--line-soft); color: var(--ink-2); }
.note.bad { background: var(--red-wash); color: var(--red-ink); }
.note.warn { background: var(--warn-wash); color: var(--warn); }
.note.good { background: var(--good-wash); color: var(--good); }
.days { display: grid; grid-template-columns: repeat(7, 1fr); gap: 5px; }
.daytog {
  appearance: none; min-width: 0; min-height: 42px; padding: 4px 0; border-radius: var(--r-ctl);
  border: 1px solid var(--line); background: var(--surface); font-weight: 600; font-size: 13.5px;
}
.daytog[aria-pressed="true"] { background: var(--navy); border-color: var(--navy); color: var(--on-navy); }
.daytog[disabled] { opacity: 0.45; cursor: default; }

/* ---------- status language: solid = confirmed, hatched = awaiting, red flag = can't make it ---------- */
.st-confirmed { background: var(--navy); border: 1px solid var(--navy); color: var(--on-navy); }
.st-pending {
  background: repeating-linear-gradient(135deg, transparent 0 5px, var(--hatch) 5px 6.5px), var(--surface);
  border: 1px solid var(--navy-ink); color: var(--navy-ink);
}
.st-declined { background: var(--surface); border: 1px solid var(--red); color: var(--red-ink); position: relative; }
.st-declined::after {
  content: ""; position: absolute; top: -1px; right: -1px; width: 12px; height: 12px;
  background: var(--red); clip-path: polygon(0 0, 100% 0, 100% 100%); border-top-right-radius: var(--r-chip);
}
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 3px 9px; border-radius: var(--r-chip); font-size: 13px; font-weight: 600; line-height: 1.3; white-space: nowrap; }
.pill.st-declined { padding-right: 14px; }
.pill svg.ico { width: 14px; height: 14px; stroke-width: 2.4; }

/* ---------- app frame ---------- */
.top { position: sticky; top: 0; z-index: 20; background: var(--paper); border-bottom: 1px solid var(--line); padding-top: var(--sat); }
.top-in { display: flex; align-items: center; gap: 20px; min-height: 60px; padding: 0 max(20px, var(--sar)) 0 max(20px, var(--sal)); max-width: 1360px; margin: 0 auto; }
.logo { height: 24px; width: auto; color: var(--ink); display: block; flex: none; }
.nav { display: none; gap: 4px; align-self: stretch; }
.nav button {
  appearance: none; background: none; border: 0; border-bottom: 3px solid transparent; border-top: 3px solid transparent;
  padding: 0 12px; font-weight: 600; color: var(--ink-2);
}
.nav button[aria-current="page"] { color: var(--ink); border-bottom-color: var(--navy-ink); }
.top-spacer { flex: 1; }
.avatar {
  appearance: none; width: 40px; height: 40px; border-radius: 50%; border: 1px solid var(--line); background: var(--surface);
  font-weight: 700; font-size: 14px; letter-spacing: 0.02em; color: var(--ink);
}
.menu { position: fixed; right: max(20px, var(--sar)); top: calc(56px + var(--sat)); z-index: 30; min-width: 220px; padding: 6px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-panel); box-shadow: 0 14px 30px -18px var(--shade); display: grid; }
.menu .who { padding: 10px 12px 8px; border-bottom: 1px solid var(--line-soft); margin-bottom: 4px; }
.menu button { appearance: none; background: none; border: 0; text-align: left; padding: 10px 12px; border-radius: var(--r-ctl); font-weight: 500; display: flex; gap: 10px; align-items: center; }
@media (hover: hover) { .menu button:hover { background: var(--line-soft); } }
.demo-bar { background: var(--navy); color: var(--on-navy); font-size: 14px; }
.demo-bar-in { max-width: 1360px; margin: 0 auto; padding: 8px max(20px, var(--sar)) 8px max(20px, var(--sal)); display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center; justify-content: space-between; }
.demo-acts { display: flex; flex-wrap: wrap; gap: 8px; }
.demo-bar button { appearance: none; background: transparent; color: inherit; border: 1px solid rgba(255, 255, 255, 0.55); border-radius: var(--r-ctl); padding: 5px 12px; font-size: 13.5px; font-weight: 600; min-height: 36px; white-space: nowrap; }
.demo-bar button.solid { background: #FFFFFF; color: #011973; border-color: #FFFFFF; }
main { max-width: 1360px; margin: 0 auto; padding: 24px max(20px, var(--sar)) calc(40px + var(--tabbar) + var(--sab)) max(20px, var(--sal)); }
.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; display: flex; background: var(--surface);
  border-top: 1px solid var(--line); padding: 0 var(--sar) var(--sab) var(--sal);
}
.tabs button {
  appearance: none; flex: 1; background: none; border: 0; border-top: 3px solid transparent; height: 61px; padding: 6px 4px 8px; align-content: center;
  display: grid; justify-items: center; gap: 2px; font-size: 12px; font-weight: 600; color: var(--muted);
}
.tabs button[aria-current="page"] { color: var(--navy-ink); border-top-color: var(--navy-ink); }

/* ---------- schedule ---------- */
.head { display: flex; flex-wrap: wrap; align-items: end; justify-content: space-between; gap: 12px 20px; margin-bottom: 16px; }
.head h1 { font-size: clamp(1.75rem, 6vw, 2.5rem); font-weight: 900; letter-spacing: -0.035em; }
.head .sub { margin-top: 6px; }
.weeknav { display: flex; gap: 6px; align-items: center; }
.toolbar { display: flex; flex-wrap: wrap; gap: 10px 16px; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.filters { display: flex; gap: 6px; overflow-x: auto; padding: 2px; margin: -2px; scrollbar-width: none; }
.filters::-webkit-scrollbar { display: none; }
.filt {
  appearance: none; display: inline-flex; align-items: baseline; gap: 6px; min-height: 40px; padding: 6px 12px; white-space: nowrap;
  border: 1px solid var(--line); border-radius: var(--r-ctl); background: var(--surface); font-size: 14px; font-weight: 500; color: var(--ink-2);
}
.filt b { font-weight: 800; color: var(--ink); font-variant-numeric: tabular-nums; }
.filt[aria-pressed="true"] { border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); color: var(--ink); }
.filt.alert b { color: var(--red-ink); }
.actions { display: flex; flex-wrap: wrap; gap: 8px; }

.cover { position: relative; height: 12px; border-radius: 2px; background: var(--sunken); overflow: hidden;
  background-image: linear-gradient(90deg, transparent calc(25% - 1px), var(--line) calc(25% - 1px) 25%, transparent 25%, transparent calc(50% - 1px), var(--line) calc(50% - 1px) 50%, transparent 50%, transparent calc(75% - 1px), var(--line) calc(75% - 1px) 75%, transparent 75%); }
.cover i { position: absolute; top: 0; bottom: 0; display: block; }
.cover i.c { background: var(--navy); }
.cover i.p { background: repeating-linear-gradient(135deg, var(--navy-ink) 0 1.5px, transparent 1.5px 4.5px); opacity: 0.75; }
.cover i.d { top: auto; height: 3px; background: var(--red); }
.cover-ticks { display: flex; justify-content: space-between; font-size: 11px; color: var(--muted); margin-top: 4px; font-variant-numeric: tabular-nums; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 13px; color: var(--muted); margin-top: 14px; align-items: center; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { display: inline-block; width: 18px; height: 12px; border-radius: 2px; }

/* week grid (wide screens) */
.gridwrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--r-panel); background: var(--surface); }
.grid { display: grid; grid-template-columns: minmax(150px, 200px) repeat(7, minmax(112px, 1fr)); min-width: 940px; }
.grid > div { border-bottom: 1px solid var(--line-soft); border-right: 1px solid var(--line-soft); min-width: 0; }
.grid > div.last-col { border-right: 0; }
.grid > div.last-row { border-bottom: 0; }
.g-corner, .g-day { padding: 12px 10px 10px; background: var(--surface); }
.g-day { border-top: 3px solid transparent; }
.g-day .wd { font-size: 13px; font-weight: 600; color: var(--muted); }
.g-day .dn { font-size: 20px; font-weight: 800; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.g-day.today { border-top-color: var(--red); }
.g-day.today .wd { color: var(--red-ink); }
.g-day .cover { margin-top: 8px; }
.g-corner { display: flex; flex-direction: column; justify-content: flex-end; font-size: 13px; color: var(--muted); }
.g-person { padding: 10px 12px; display: grid; align-content: start; gap: 2px; position: sticky; left: 0; z-index: 2; background: var(--surface); }
.g-person .nm { font-weight: 700; font-size: 15px; line-height: 1.25; overflow-wrap: anywhere; }
.g-person .meta { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.g-person.me .nm::after { content: " (you)"; font-weight: 500; color: var(--muted); }
.g-cell { padding: 6px; display: grid; align-content: start; gap: 5px; min-height: 62px; position: relative; }
.g-cell.today, .g-day.today { background: color-mix(in srgb, var(--ink) 3.5%, var(--surface)); }
.g-cell .add {
  appearance: none; position: absolute; inset: 6px; border: 1px dashed var(--line); background: transparent; border-radius: var(--r-chip);
  color: var(--muted); display: grid; place-items: center; opacity: 0;
}
.g-cell .add svg.ico { width: 16px; height: 16px; }
.g-cell:hover .add, .g-cell .add:focus-visible { opacity: 1; }
@media (hover: none) { .g-cell .add { opacity: 0.6; } }
.chip { appearance: none; display: grid; grid-template-columns: 1fr auto; gap: 0 6px; text-align: left; width: 100%; padding: 6px 8px; border-radius: var(--r-chip); line-height: 1.25; }
.chip .tm { font-size: 14px; font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.chip .cv { grid-column: 1 / -1; font-size: 12.5px; font-weight: 500; opacity: 0.82; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip svg.ico { width: 15px; height: 15px; stroke-width: 2.4; align-self: center; }
.chip.st-declined .tm { text-decoration: line-through; }
.chip.st-declined svg.ico { margin-right: 6px; }
.chip.past { opacity: 0.5; }
.chip.dim { opacity: 0.18; }
@media (hover: hover) { .chip:hover { filter: brightness(1.12); } }

/* day view (phones) */
.daystrip { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; margin-bottom: 14px; }
.daybtn {
  appearance: none; display: grid; justify-items: center; gap: 1px; padding: 6px 0 8px; border-radius: var(--r-ctl);
  border: 1px solid transparent; background: transparent; color: var(--ink-2); position: relative;
}
.daybtn .wd { font-size: 12px; font-weight: 600; color: var(--muted); }
.daybtn .dn { font-size: 18px; font-weight: 800; font-variant-numeric: tabular-nums; }
.daybtn .dots { display: flex; gap: 3px; height: 6px; }
.daybtn .dots i { width: 6px; height: 6px; border-radius: 50%; display: block; }
.daybtn .dots i.c { background: var(--navy-ink); }
.daybtn .dots i.p { border: 1.5px solid var(--navy-ink); }
.daybtn .dots i.d { background: var(--red); }
.daybtn.today .wd { color: var(--red-ink); }
.daybtn[aria-pressed="true"] { background: var(--surface); border-color: var(--line); box-shadow: inset 0 -3px 0 var(--navy-ink); color: var(--ink); }
.daycard { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-panel); overflow: hidden; }
.daycard-head { padding: 14px 16px 12px; border-bottom: 1px solid var(--line-soft); display: grid; gap: 10px; }
.daycard-head h2 { font-size: 18px; font-weight: 800; }
.daycard-title { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.daycard-title .btn { flex: none; white-space: nowrap; }
.daycard-head .cover { height: 14px; }
.srow {
  appearance: none; display: grid; grid-template-columns: minmax(4.1em, auto) 1fr auto; gap: 4px 12px; align-items: center; width: 100%; text-align: left;
  padding: 12px 16px; background: none; border: 0; border-bottom: 1px solid var(--line-soft); min-height: 64px;
}
.srow:last-child { border-bottom: 0; }
.srow .tm { font-weight: 700; font-size: 15px; line-height: 1.25; font-variant-numeric: tabular-nums; white-space: nowrap; }
.srow .pill { font-size: 12.5px; padding: 3px 8px; }
.srow .pill.st-declined { padding-right: 13px; }
.srow .nm { font-weight: 600; line-height: 1.25; overflow-wrap: anywhere; }
.srow .cv { font-size: 14px; color: var(--muted); }
.srow.past { opacity: 0.62; }
.empty { padding: 28px 16px; text-align: center; color: var(--muted); display: grid; gap: 12px; justify-items: center; }

/* ---------- lists, cards, settings ---------- */
.stack { display: grid; gap: 16px; }
.narrow { max-width: 720px; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-panel); }
.panel-pad { padding: 18px; display: grid; gap: 14px; }
.panel h2 { font-size: 18px; font-weight: 800; }
.mine { display: grid; grid-template-columns: auto 1fr; gap: 4px 16px; padding: 16px 18px; border-bottom: 1px solid var(--line-soft); align-items: start; }
.mine:last-child { border-bottom: 0; }
.mine .date { display: grid; justify-items: center; min-width: 52px; padding: 6px 4px; border-radius: var(--r-ctl); background: var(--sunken); line-height: 1.1; }
.mine .date .wd { font-size: 12px; font-weight: 600; color: var(--muted); }
.mine .date .dn { font-size: 22px; font-weight: 900; font-variant-numeric: tabular-nums; }
.mine .date .mo { font-size: 12px; color: var(--muted); }
.mine .body { display: grid; gap: 8px; min-width: 0; }
.mine .when { font-weight: 800; font-size: 17px; font-variant-numeric: tabular-nums; line-height: 1.25; }
.mine > .stack { grid-column: 1 / -1; margin-top: 6px; }
.prow { appearance: none; display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; width: 100%; text-align: left; padding: 14px 18px; background: none; border: 0; border-bottom: 1px solid var(--line-soft); align-items: center; }
.prow:last-child { border-bottom: 0; }
.prow .nm { font-weight: 700; overflow-wrap: anywhere; }
.prow .sub { font-size: 14px; color: var(--muted); overflow-wrap: anywhere; }
.prow .tags { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; grid-row: span 2; }
.prow.off { opacity: 0.55; }
.tag { font-size: 12.5px; font-weight: 600; padding: 2px 8px; border-radius: var(--r-chip); background: var(--line-soft); color: var(--ink-2); white-space: nowrap; }
.tag.navy { background: var(--navy-wash); color: var(--navy-ink); }
.tag.warn { background: var(--warn-wash); color: var(--warn); }
.tag.bad { background: var(--red-wash); color: var(--red-ink); }
.offs { display: flex; flex-wrap: wrap; gap: 8px; }
.off { display: inline-flex; align-items: center; gap: 4px; padding: 4px 4px 4px 12px; border: 1px solid var(--line); border-radius: var(--r-ctl); font-weight: 600; font-size: 14px; background: var(--surface); }
.off button { appearance: none; border: 0; background: none; width: 32px; height: 32px; display: grid; place-items: center; border-radius: 6px; color: var(--muted); }
.off button svg.ico { width: 16px; height: 16px; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; font-size: 15px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; overflow-wrap: anywhere; }
.log { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; font-size: 14px; }
.log li { display: grid; grid-template-columns: 7.5em 1fr; gap: 10px; color: var(--ink-2); }
.log time { color: var(--muted); font-variant-numeric: tabular-nums; }

/* ---------- sheet (bottom sheet on phones, side panel on wide screens) ---------- */
dialog.sheet {
  border: 0; padding: 0; margin: 0; background: var(--surface); color: var(--ink);
  width: 100%; max-width: 100%; max-height: calc(92vh - var(--kb)); max-height: calc(92dvh - var(--kb)); position: fixed; inset: auto 0 var(--kb) 0;
  border-radius: var(--r-panel) var(--r-panel) 0 0; box-shadow: 0 -18px 40px -24px var(--shade);
}
dialog.sheet::backdrop { background: var(--shade); }
dialog.sheet[open] { display: flex; flex-direction: column; animation: sheet-up 0.18s ease-out; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px max(12px, var(--sar)) 12px max(20px, var(--sal)); border-bottom: 1px solid var(--line-soft); }
.sheet-head h2 { font-size: 20px; font-weight: 800; }
.sheet-body { padding: 18px max(20px, var(--sar)) 18px max(20px, var(--sal)); display: grid; gap: 16px; overflow-y: auto; align-content: start; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
.sheet-foot { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; padding: 12px max(20px, var(--sar)) calc(14px + var(--sab)) max(20px, var(--sal)); border-top: 1px solid var(--line-soft); }
:root.kb-open .sheet-foot { padding-bottom: 12px; }
.sheet-foot .left { margin-right: auto; }
.sec { display: grid; gap: 10px; padding-top: 16px; border-top: 1px solid var(--line-soft); }
.sec h3 { font-size: 15px; font-weight: 800; }
@keyframes sheet-up { from { transform: translateY(24px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes sheet-in { from { transform: translateX(24px); opacity: 0; } to { transform: none; opacity: 1; } }

.toasts { position: fixed; left: 0; right: 0; bottom: calc(var(--tabbar) + 14px + var(--sab) + var(--kb)); z-index: 60; display: grid; justify-items: center; gap: 8px; padding: 0 16px; pointer-events: none; }
.toast { pointer-events: auto; max-width: 520px; padding: 11px 16px; border-radius: var(--r-ctl); background: var(--ink); color: var(--paper); font-size: 15px; font-weight: 500; box-shadow: 0 12px 28px -14px var(--shade); }
.toast.bad { background: var(--red); color: #fff; }

/* ---------- sign-in and confirm link pages ---------- */
.gate { min-height: 100vh; min-height: 100dvh; display: grid; grid-template-rows: auto 1fr auto; position: relative; overflow: hidden; }
.gate::before, .gate::after { content: ""; position: absolute; pointer-events: none; }
.gate::before { right: -60px; top: -40px; width: min(62vw, 520px); aspect-ratio: 310 / 160; background: var(--red); clip-path: polygon(100% 0, 0 100%, 67% 100%, 73% 92%); opacity: 0.9; }
.gate::after { right: 22%; top: 10px; width: min(40vw, 330px); aspect-ratio: 5 / 1; background: var(--red); opacity: 0.4; clip-path: polygon(0 45%, 100% 0, 63% 96%, 58% 100%); }
.gate-top { padding: calc(24px + var(--sat)) max(24px, var(--sar)) 0 max(24px, var(--sal)); position: relative; z-index: 1; }
.gate-main { display: grid; align-content: center; gap: 18px; padding: 40px max(24px, var(--sar)) 40px max(24px, var(--sal)); max-width: 560px; position: relative; z-index: 1; }
.gate-main h1 { font-size: clamp(2.2rem, 9vw, 3.4rem); font-weight: 900; letter-spacing: -0.04em; line-height: 1; }
.gate-main .lead { font-size: 1.125rem; color: var(--ink-2); max-width: 30em; }
.gate-foot { padding: 0 max(24px, var(--sar)) calc(24px + var(--sab)) max(24px, var(--sal)); font-size: 13px; color: var(--muted); position: relative; z-index: 1; }
.cshift { display: grid; gap: 10px; padding: 16px 18px; border-bottom: 1px solid var(--line-soft); }
.cshift:last-child { border-bottom: 0; }
.cshift .when { font-weight: 800; font-size: 17px; line-height: 1.25; font-variant-numeric: tabular-nums; }
.cshift .when2 { font-weight: 600; font-variant-numeric: tabular-nums; }
.spinner { width: 28px; height: 28px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--navy-ink); animation: spin 0.8s linear infinite; margin: 60px auto; }
@keyframes spin { to { transform: rotate(360deg); } }

@media (min-width: 900px) {
  .nav { display: flex; }
  .tabs { display: none; }
  main { padding-top: 32px; }
  dialog.sheet { inset: 0 0 0 auto; width: 460px; height: 100%; max-height: none; border-radius: 0; box-shadow: -18px 0 40px -24px var(--shade); }
  .sheet-foot { padding-bottom: 14px; }
  .sheet-head { padding-top: calc(16px + var(--sat)); }
  dialog.sheet[open] { animation-name: sheet-in; }
  .toasts { bottom: 24px; }
  .gate-top, .gate-main, .gate-foot { padding-left: max(24px, 8vw); }
}
@media (max-width: 899px) {
  :root { --tabbar: 62px; }
  .top-in { min-height: 54px; padding: 0 max(16px, var(--sar)) 0 max(16px, var(--sal)); }
  main { padding: 18px max(16px, var(--sar)) calc(32px + var(--tabbar) + var(--sab)) max(16px, var(--sal)); }
  main > div { max-width: 680px; margin-inline: auto; }
  .logo { height: 21px; }
  .head.sched { flex-wrap: nowrap; align-items: start; }
  .toolbar { gap: 10px; }
  .actions { width: 100%; flex-wrap: nowrap; }
  .actions .btn { flex: 1 1 0; min-width: 0; padding: 8px 10px; font-size: 14.5px; }
  .menu { right: max(12px, var(--sar)); top: calc(52px + var(--sat)); }
  .demo-bar-in { padding: 8px max(16px, var(--sar)) 10px max(16px, var(--sal)); font-size: 13.5px; }
  .demo-acts { width: 100%; }
  .demo-acts button { flex: 1 1 auto; }
  .gate::after { display: none; }
}
@media (pointer: coarse) {
  .btn.sm { min-height: 44px; padding: 8px 14px; }
  .filt, .daytog { min-height: 44px; }
  .avatar { width: 44px; height: 44px; }
  .off { padding-left: 14px; }
  .off button { width: 44px; height: 44px; }
  .demo-bar button { min-height: 44px; }
  .check { padding-block: 12px; }
  .linkbtn { display: inline-flex; align-items: center; min-height: 44px; }
}
@media (max-width: 380px) {
  /* seven days across a small phone: spend the width on the buttons, not the gaps */
  .daystrip { gap: 2px; }
  .days { gap: 3px; }
}
@media (max-width: 359px) {
  .head h1 { font-size: 1.6rem; }
  .actions .btn svg.ico { display: none; }
  .srow { grid-template-columns: minmax(3.9em, auto) 1fr; }
  .srow .pill { grid-column: 2; justify-self: start; }
  .daybtn .dn { font-size: 16px; }
  .mine { column-gap: 12px; padding: 14px; }
}

/* ---------- walkthrough (preview only) ---------- */
.tour {
  position: fixed; left: 0; right: 0; bottom: calc(var(--tabbar) + var(--sab)); z-index: 40; display: flex; flex-direction: column; gap: 10px;
  padding: 12px max(16px, var(--sar)) 14px max(16px, var(--sal)); background: var(--surface); border-top: 3px solid var(--red);
  box-shadow: 0 -18px 40px -24px var(--shade); max-height: 62vh; max-height: 62dvh;
}
.tour-head, .tour-nav { flex: none; }
.tour-scroll { display: grid; gap: 10px; min-height: 0; overflow-y: auto; overscroll-behavior: contain; align-content: start; }
.srow.tour-focus { box-shadow: inset 4px 0 0 var(--red); background: color-mix(in srgb, var(--red) 5%, transparent); }
.g-person.tour-focus { box-shadow: inset 4px 0 0 var(--red); }
.btn.tour-ring { border-color: var(--red); box-shadow: 0 0 0 3px color-mix(in srgb, var(--red) 28%, transparent); }
body.touring .toasts { bottom: auto; top: calc(66px + var(--sat)); }
.tour-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; font-size: 13px; font-weight: 700; color: var(--muted); font-variant-numeric: tabular-nums; }
.tour-head .iconbtn { width: 44px; height: 44px; margin: -8px -10px -8px 0; }
.tour h2 { font-size: 19px; font-weight: 800; }
.tour p { font-size: 15.5px; line-height: 1.45; color: var(--ink-2); }
.tour-nav { display: flex; gap: 8px; justify-content: space-between; margin-top: 2px; }
.tour-nav .btn { min-width: 96px; }
.tour-head > span:first-child { white-space: nowrap; }
.tour-dots { display: flex; gap: 4px; flex: 1 1 auto; min-width: 0; justify-content: center; }
.tour-dots i { display: block; flex: 1 1 0; min-width: 3px; max-width: 14px; height: 4px; border-radius: 2px; background: var(--line); }
.tour-dots i.on { background: var(--red); }
.thread { display: grid; gap: 6px; padding: 12px; border-radius: 12px; background: var(--sunken); }
.thread .who { font-size: 12.5px; font-weight: 700; color: var(--muted); margin-bottom: 2px; }
.bubble { max-width: 88%; padding: 8px 12px; border-radius: 16px; font-size: 14.5px; line-height: 1.38; overflow-wrap: anywhere; }
.bubble.in { justify-self: start; background: var(--surface); border: 1px solid var(--line); border-bottom-left-radius: 4px; }
.bubble.out { justify-self: end; background: var(--navy); color: var(--on-navy); border-bottom-right-radius: 4px; font-weight: 700; }
.mailcard { border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: var(--surface); }
.mailcard .bar { background: #011973; color: #FFFFFF; font-weight: 800; padding: 8px 12px; border-bottom: 3px solid #DD2424; letter-spacing: -0.01em; }
.mailcard .in { padding: 10px 12px 12px; display: grid; gap: 6px; font-size: 14.5px; line-height: 1.38; }
.mailcard .subj { font-weight: 800; }
.mailcard .fakebtn { display: inline-block; justify-self: start; background: var(--navy); color: var(--on-navy); font-weight: 700; padding: 7px 12px; border-radius: 6px; font-size: 14px; }
body.touring main { padding-bottom: 78vh; }
@media (max-height: 520px) and (min-width: 600px) and (max-width: 899px) {
  /* a phone held sideways: the walkthrough moves to the right so the schedule stays visible */
  .tour {
    left: auto; right: 0; top: auto; width: min(46vw, 420px); max-height: calc(100vh - 55px - var(--sat) - var(--tabbar) - var(--sab));
    border-top: 1px solid var(--line); border-left: 3px solid var(--red); border-top-left-radius: var(--r-panel);
    padding-right: max(16px, var(--sar)); box-shadow: -18px 0 40px -24px var(--shade);
  }
  body.touring .tour { top: calc(55px + var(--sat)); max-height: none; border-top: 0; border-top-left-radius: 0; }
  body.touring main { padding-right: calc(min(46vw, 420px) + 16px); padding-bottom: calc(32px + var(--tabbar) + var(--sab)); }
}
@media (min-width: 900px) {
  .tour { left: auto; right: 24px; bottom: 24px; width: 420px; border: 1px solid var(--line); border-top: 3px solid var(--red); border-radius: var(--r-panel); padding: 14px 18px 16px; max-height: 80vh; }
  body.touring main { padding-bottom: 40px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; transition: none !important; }
}
