  :root {
    /* palette: yellow, blue and red lead; the rest support */
    --yellow: #F8D000;
    --yellow-soft: #FFD661;
    --blue: #282870;
    --red: #C00028;
    --violet: #796AA1;      /* who's doing it: 4.8:1 on white */
    --brown: #653517;       /* dates, on --yellow-soft: 7.3:1 */
    --olive: #9A9870;
    --ink: #001F1D;
    --ink-soft: #43575A;    /* from the ink hue: 7.6:1 on white, 6.4:1 on paper */
    --line: #CCDADC;
    --control-line: #76744F; /* olive darkened: 3.4:1 on the yellow ground, 4.8:1 on white: outlines people must see */
    --ground: var(--yellow-soft); /* page background */
    --paper: #E6EDEE;       /* tint of the #CCDADC blue-grey: inner surfaces */
    --card: #ffffff;
    --accent: var(--blue);
    --accent-ink: #ffffff;
    --accent-weak: #E8E8F3;
    --ok: var(--blue);      /* done = blue tick */
    --ok-ink: var(--blue);
    --ok-weak: var(--accent-weak);
    --warn-ink: var(--brown);
    --warn-weak: var(--yellow-soft);
    --block: var(--red);
    --block-weak: #FBE6EA;
    --grey-weak: var(--paper);
    --row-hover: #F3F7F7;   /* half-way from white to paper */
    --radius: 10px;
    --tap: 44px;
    --maxw: 760px;    /* sheets and dialogs */
    --pagew: 1120px;  /* the page column: the same in every view so switching views never changes its width */
    --font-head: "Source Serif 4", Georgia, serif;   /* app title, section and stage headings */
    --font-body: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;   /* tasks and everything else */
    /* type scale: one family, five roles */
    --fs-meta: .8125rem;   /* pills, timestamps */
    --fs-small: .875rem;   /* notes, labels, hints */
    --fs-body: 1rem;       /* task titles, controls */
    --fs-stage: 1.125rem;  /* stage headings, sheet titles */
    --fs-lead: 1.375rem;   /* the moving-day line */
    font-synthesis: none;
    accent-color: var(--accent);
    caret-color: var(--accent);
    scrollbar-color: var(--control-line) var(--ground);
  }
  * { box-sizing: border-box; }
  [hidden] { display: none !important; } /* else classes like .login-wrap's display:grid override it */
  ::selection { background: var(--yellow-soft); color: var(--ink); }
  html, body { margin: 0; }
  body {
    font-family: var(--font-body);
    font-size: var(--fs-body);
    color: var(--ink);
    background: var(--ground);
    -webkit-text-size-adjust: 100%;
    line-height: 1.45;
  }
  button, input, select, textarea { font: inherit; color: inherit; }
  button { cursor: pointer; }
  :focus-visible { outline: 2.5px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
  .login-card h1, .countdown h2, .section-head h2, .sheet h2, .stage-name, .fstage .fs-name { font-family: var(--font-head); font-weight: 700; }
  .icon { width: 20px; height: 20px; flex: 0 0 auto; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
  .num { font-variant-numeric: tabular-nums; }
  .sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

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

  main { max-width: var(--pagew); margin: 0 auto; padding: 12px max(12px, env(safe-area-inset-right)) 48px max(12px, env(safe-area-inset-left)); }   /* sideways phones: clear of the notch */

  /* ---------- Moving day + journey ---------- */
  .overview { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 14px 10px; margin-bottom: 16px; }
  .countdown { display: flex; align-items: baseline; justify-content: space-between; gap: 0 12px; flex-wrap: wrap; }
  .countdown h2 { font-size: var(--fs-lead); margin: 0; line-height: 1.2; letter-spacing: -.01em; color: var(--blue); }
  .countdown .hot { color: var(--red); }
  /* milestone tasks (the FLOW milestones) carry a small red diamond in the list and table */
  .mstone { display: inline-block; width: 9px; height: 9px; margin: 0 7px 1px 1px; transform: rotate(45deg); background: var(--red); vertical-align: middle; }
  .countdown p { margin: 0; color: var(--ink-soft); font-size: var(--fs-small); }
  .countdown .linkbtn { min-height: 32px; position: relative; }
  .countdown .linkbtn::before { content: ""; position: absolute; inset: -6px -4px; }   /* 44px tall to the thumb */
  .linkbtn { background: none; border: 0; padding: 0 2px; min-height: var(--tap); color: var(--blue); font-weight: 600; font-size: var(--fs-small);
    text-decoration: underline; text-underline-offset: 3px; }
  /* each stage is a button: no gap between them (the 3px gap is each one's side padding) and taller than it
     looks, so even on a small phone every one is a comfortable tap */
  .journey { display: flex; margin: -2px -1.5px; }
  .stop { flex: 1 1 0; min-width: 0; height: 36px; padding: 0 1.5px; border: 0; background: none; display: flex; align-items: center; }
  .stop .track { display: block; width: 100%; height: 8px; border-radius: 2px; background: var(--line); overflow: hidden; }
  .stop .fill { display: block; height: 100%; background: var(--blue); transition: width .4s cubic-bezier(.16,1,.3,1); }
  .stop.current .track { height: 16px; background: var(--yellow-soft); box-shadow: inset 0 0 0 2px var(--blue); }
  .stage-now { display: flex; justify-content: space-between; gap: 0 12px; flex-wrap: wrap; font-size: var(--fs-small); color: var(--ink-soft); }
  .stage-now b { color: var(--ink); font-weight: 650; }
  .sync { font-size: var(--fs-meta); color: var(--ink-soft); margin: 2px 0 0; }
  .sync:empty { display: none; }
  .sync.bad { color: var(--block); font-weight: 600; }

  /* ---------- Section headings ---------- */
  .section-head { display: flex; align-items: baseline; gap: 4px 10px; flex-wrap: wrap; margin: 0 0 6px; }
  .section-head h2 { font-size: var(--fs-stage); margin: 0; color: var(--blue); }
  .hint { font-size: var(--fs-small); color: var(--ink-soft); margin: 0; }
  .nextup { margin-bottom: 18px; }

  /* ---------- Filters ---------- */
  .filters { display: grid; grid-template-columns: minmax(0,1fr) auto; gap: 6px; margin-bottom: 6px; }
  .filters input, #filterSheet select {
    width: 100%; min-height: var(--tap); border: 1px solid var(--control-line);
    border-radius: 8px; padding: 0 10px; background: var(--card); font-size: var(--fs-body);
  }
  #filterSheet select { padding: 0 8px; }
  .filterbtn { display: inline-flex; align-items: center; gap: 6px; padding: 0 12px; }
  .filterbtn .count { min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px; background: var(--blue); color: #fff; font-size: var(--fs-meta); font-weight: 700; line-height: 20px; text-align: center; }
  .filterbtn.on { border-color: var(--blue); }
  /* One row of views; the pressed tab is underlined in blue like a folder tab */
  .viewtabs { display: flex; gap: 2px; margin: 0 0 8px; border-bottom: 1px solid var(--control-line); overflow-x: auto; scrollbar-width: none; }
  .viewtabs button { flex: 0 1 auto; min-width: 0; min-height: var(--tap); padding: 0 10px; line-height: 1.15; border: 0; background: none; border-bottom: 3px solid transparent; margin-bottom: -1px;
    font-size: var(--fs-body); font-weight: 600; color: var(--ink-soft); text-wrap: balance; }
  .viewtabs button[aria-selected="true"] { color: var(--blue); border-bottom-color: var(--blue); font-weight: 700; }
  @media (hover: hover) { .viewtabs button[aria-selected="false"]:hover { color: var(--ink); } }
  @media (max-width: 359px) { .viewtabs button { padding: 0 7px; } }
  .histlink { width: 100%; display: grid; grid-template-columns: auto 1fr; align-items: center; gap: 0 8px; padding: 6px 12px; text-align: left; font-weight: 650; }
  .histlink .hint { grid-column: 2; font-weight: 400; }
  .login-card > p a { color: var(--blue); font-weight: 600; }
  .filter-note { display: flex; align-items: center; justify-content: space-between; gap: 12px; font-size: var(--fs-small); color: var(--ink-soft); }
  .filters-wrap { margin-bottom: 6px; }

  /* ---------- Stages ---------- */
  .stage + .stage { border-top: 1px solid var(--line); }
  .stage-head {
    display: flex; align-items: center; gap: 10px; width: 100%; min-height: var(--tap);
    background: none; border: 0; text-align: left; padding: 4px 2px;
  }
  .badge { flex: 0 0 auto; width: 26px; height: 26px; border-radius: 6px; display: grid; place-items: center;
    background: var(--card); border: 2px solid var(--control-line); font-size: var(--fs-meta); font-weight: 750; color: var(--ink); }
  /* the same badge states in the list and on the Map */
  .stage.is-current .badge, .fstage.is-current .badge { background: var(--yellow); border-color: var(--blue); color: var(--blue); }
  .stage.is-complete .badge, .fstage.is-complete .badge { background: var(--blue); border-color: var(--blue); color: #fff; }
  .badge .icon { width: 16px; height: 16px; stroke-width: 3; }
  .stage-name { flex: 1; min-width: 0; font-size: var(--fs-body); overflow-wrap: anywhere; }
  .stage.is-current .stage-name { color: var(--blue); }
  .stage-count { font-size: var(--fs-small); color: var(--ink-soft); white-space: nowrap; }
  .stage-head .chev { color: var(--ink-soft); transition: transform .2s ease-out; }
  .stage-head[aria-expanded="false"] .chev { transform: rotate(-90deg); }
  .tasklist { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); margin: 0 0 10px; overflow: hidden; }
  .pop { animation: pop .45s ease-out; }
  @keyframes pop { 40% { transform: scale(1.3); } }

  /* ---------- Task card ---------- */
  .task { display: flex; align-items: flex-start; }
  .task + .task { border-top: 1px solid var(--line); }
  .check { flex: 0 0 auto; width: max(44px, 2.75rem); height: max(44px, 2.75rem); border: 0; background: none; padding: 0; display: grid; place-items: center; border-radius: 10px; }
  .check .box { width: 1.375rem; height: 1.375rem; border-radius: 5px; border: 2px solid var(--control-line); background: var(--card);
    display: grid; place-items: center; color: #fff; transition: background .15s ease-out, border-color .15s ease-out; }
  .check .box .icon { width: .9375rem; height: .9375rem; stroke-width: 3; opacity: 0; }
  .check[aria-pressed="true"] .box { background: var(--ok); border-color: var(--ok); }
  .check[aria-pressed="true"] .box .icon { opacity: 1; }
  @media (hover: hover) { .check:hover .box { border-color: var(--accent); } }
  .task .body { flex: 1 1 auto; min-width: 0; padding: 10px 12px 9px 0; background: none; border: 0; text-align: left; display: block; border-radius: 0; }
  .task .body:focus-visible { outline-offset: -3px; }
  @media (hover: hover) { .task .body:hover .title { text-decoration: underline; text-decoration-color: var(--control-line); text-underline-offset: 3px; } }
  .task .title { display: block; font-weight: 500; font-size: var(--fs-body); line-height: 1.35; overflow-wrap: anywhere; }
  .task.s-done .title { text-decoration: line-through; text-decoration-color: var(--control-line); color: var(--ink-soft); font-weight: 400; }
  .task.s-na .title { color: var(--ink-soft); font-weight: 400; }
  /* one line of details; the note gives way (…) so a task is never more than title + one line */
  .task .meta { margin-top: 2px; display: flex; gap: 8px; align-items: center; font-size: var(--fs-small); color: var(--ink-soft); line-height: 1.35; white-space: nowrap; overflow: hidden; }
  .task .meta > * { flex: 0 0 auto; }
  .pill { font-size: var(--fs-meta); padding: 0 7px; border-radius: 4px; background: var(--grey-weak); color: var(--ink-soft); max-width: 100%; overflow-wrap: anywhere; font-weight: 600; }
  .owner { font-size: var(--fs-meta); font-weight: 700; color: var(--violet); }
  .meta .note-text { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
  .meta .has-comments { display: inline-flex; color: var(--violet); }
  .meta .has-comments .icon { width: 15px; height: 15px; }
  .pill.date { background: var(--warn-weak); color: var(--warn-ink); }
  .pill.date.overdue { background: var(--block-weak); color: var(--block); font-weight: 650; }
  .pill.s-progress { background: var(--accent-weak); color: var(--accent); font-weight: 600; }
  .pill.s-blocked { background: var(--block-weak); color: var(--block); font-weight: 650; }
  .pill.s-done { background: var(--ok-weak); color: var(--ok-ink); }
  .done-toggle { display: flex; align-items: center; gap: 6px; width: 100%; min-height: 40px; padding: 0 12px 0 13px; background: var(--paper); border: 0;
    border-top: 1px solid var(--line); color: var(--ink-soft); font-size: var(--fs-small); font-weight: 650; text-align: left; }
  .done-toggle .icon { width: 16px; height: 16px; transition: transform .2s ease-out; }
  .done-toggle[aria-expanded="false"] .icon { transform: rotate(-90deg); }
  .done-toggle + .task { border-top: 1px solid var(--line); }
  @media (hover: hover) { .done-toggle:hover { color: var(--ink); } }

  .empty { text-align: center; color: var(--ink-soft); padding: 24px 16px; }

  /* ---------- Flow view: the whole process as a map, drawn from the live tasks ---------- */
  #app.is-flow .filters, #app.is-flow #filterNote { display: none !important; }   /* Map and Who does what show the whole process */
  .flow { display: flex; flex-direction: column; align-items: center; padding: 4px 0 8px; }
  .flow-note { font-size: var(--fs-small); color: var(--ink-soft); margin: 0 0 10px; text-align: center; }
  .fstage { width: min(100%, 340px); display: grid; grid-template-columns: auto 1fr; gap: 2px 8px; align-items: center; text-align: left;
    background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 8px 10px; color: var(--ink); }
  .fstage .badge { grid-row: span 2; }
  .fstage .fs-name { font-size: var(--fs-small); line-height: 1.25; overflow-wrap: anywhere; }
  .fstage .fs-prog { display: flex; align-items: center; gap: 6px; font-size: var(--fs-meta); color: var(--ink-soft); }
  .fstage .fs-bar { flex: 1; height: 5px; border-radius: 2px; background: var(--line); overflow: hidden; }
  .fstage .fs-bar > span { display: block; height: 100%; background: var(--blue); }
  .fstage.is-current { border: 2px solid var(--blue); padding: 7px 9px; }
  .fstage .badge .icon { width: 14px; height: 14px; stroke-width: 3; }
  @media (hover: hover) { .fstage:hover { border-color: var(--blue); } .fmile:not(:disabled):hover { box-shadow: inset 0 0 0 1px var(--red); } }
  .fmile { display: inline-flex; align-items: center; gap: 6px; min-height: 32px; padding: 0 12px 0 8px; border-radius: 99px;
    border: 2px solid var(--red); background: var(--card); color: var(--red); font-size: var(--fs-meta); font-weight: 750; max-width: min(100%, 340px); text-align: left; }
  .fmile .dia { width: 10px; height: 10px; transform: rotate(45deg); border: 2px solid currentColor; flex: 0 0 auto; }
  .fmile.done { background: var(--red); color: #fff; }
  .fmile.done .dia { background: var(--yellow); border-color: var(--yellow); }
  .fmile.next { background: var(--yellow); color: var(--ink); }   /* the next big moment: yellow (now) with the red milestone edge */
  .fmile:disabled { cursor: default; opacity: .8; }
  .fdec { width: min(100%, 340px); display: grid; grid-template-columns: auto 1fr; gap: 0 8px; align-items: start; font-size: var(--fs-meta); color: var(--ink); }
  .fdec .dia { width: 14px; height: 14px; margin: 3px 3px 0; transform: rotate(45deg); border: 2px solid var(--olive); background: var(--card); }
  .fdec b { font-weight: 750; }
  .fdec .no { grid-column: 2; color: var(--ink-soft); }
  .fdec .no b { color: var(--red); }
  .fdec .no b.plan { color: var(--blue); }
  .farrow { width: 2px; height: 16px; background: var(--ink-soft); position: relative; flex: 0 0 auto; margin-bottom: 6px; }
  .farrow::after { content: ""; position: absolute; left: -4px; bottom: -6px; border: 5px solid transparent; border-top: 6px solid var(--ink-soft); border-bottom: 0; }
  .farrow.fill { flex: 1 1 auto; min-height: 16px; margin-bottom: 0; }
  .farrow.fill::after { display: none; }
  .fjoin { width: 100%; height: 18px; display: block; color: var(--ink-soft); flex: 0 0 auto; }
  .lanes { width: 100%; display: grid; grid-template-columns: 1fr 1fr; align-items: stretch; }
  .lane { display: flex; flex-direction: column; align-items: center; padding: 0 4px; min-width: 0; }
  .lane h3 { margin: 0 0 6px; font-size: var(--fs-small); font-weight: 750; color: var(--blue); }
  .lane .fstage, .lane .fdec, .lane .fmile { width: 100%; }
  .lane .fmile { justify-content: flex-start; }
  .fend { font-weight: 750; color: var(--blue); font-size: var(--fs-small); }

  /* Who does what: a list grouped by week on phones, swimlanes (one column per party) from 900px */
  .who { display: flex; flex-direction: column; gap: 8px; }
  .wrow { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 8px 10px; display: flex; flex-direction: column; gap: 8px; }
  .wrow.whead { display: none; }
  .wwhen { margin: 0; font-family: var(--font-head); font-size: var(--fs-small); font-weight: 700; color: var(--blue); display: flex; gap: 8px; align-items: baseline; }
  .wwhen span { font-family: var(--font-body); font-size: var(--fs-meta); font-weight: 500; color: var(--ink-soft); }
  .wcell { display: flex; flex-direction: column; min-width: 0; }
  .wcell.is-empty { display: none; }
  .wlane { font-size: var(--fs-meta); font-weight: 700; color: var(--ink-soft); }
  .wcell.you .wlane, .whead .wcell.you { color: var(--red); }
  .wside { font-size: var(--fs-meta); font-weight: 650; padding: 0 5px; border-radius: 4px; margin-right: 2px; white-space: nowrap; }
  .wside.sale { background: var(--paper); color: var(--brown); }
  .wside.buy { background: var(--accent-weak); color: var(--blue); }
  .wside.both { color: var(--ink-soft); padding: 0; }
  .wtasks { font-size: var(--fs-meta); font-weight: 600; color: var(--ink); margin-top: 4px; }
  .wdet .linkbtn { text-align: left; }
  .wdet .linkbtn .icon { width: 14px; height: 14px; margin: 0 4px -2px 0; stroke-width: 3; }
  .wstep { border-top: 1px solid var(--line); }
  .wlane + .wstep { border-top: 0; }
  .wstep summary { list-style: none; display: flex; align-items: flex-start; justify-content: space-between; gap: 6px; min-height: 36px; padding: 6px 0; cursor: pointer;
    font-size: var(--fs-small); font-weight: 500; line-height: 1.35; color: var(--ink); }
  .wstep summary::-webkit-details-marker { display: none; }
  .wtitle { min-width: 0; overflow-wrap: anywhere; }
  .wtitle .icon { width: 14px; height: 14px; margin: 0 4px -2px 0; stroke-width: 3; color: var(--blue); }
  .wstep.done summary { color: var(--ink-soft); }
  .wstep .chev { width: 16px; height: 16px; flex: 0 0 auto; margin-top: 1px; color: var(--ink-soft); transform: rotate(-90deg); transition: transform .2s ease-out; }
  .wstep[open] .chev { transform: none; }
  @media (hover: hover) { .wstep summary:hover .wtitle { text-decoration: underline; text-decoration-color: var(--control-line); text-underline-offset: 3px; } }
  .wdet { padding: 0 0 8px; font-size: var(--fs-small); color: var(--ink-soft); line-height: 1.4; display: flex; flex-direction: column; align-items: flex-start; gap: 2px; }
  .wdet p { margin: 0; }
  .wto { font-size: var(--fs-meta); font-weight: 600; color: var(--ink); }
  .wdet .linkbtn { min-height: 32px; padding: 0; }
  .wmile { display: flex; flex-direction: column; align-items: center; gap: 4px; text-align: center; }
  .wmile p { margin: 0; max-width: 560px; font-size: var(--fs-meta); color: var(--ink-soft); line-height: 1.4; }
  .who-src { margin-top: 10px; }
  @media (min-width: 900px) {
    .who { gap: 0; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
    .wrow, .wrow.whead { display: grid; grid-template-columns: 84px repeat(5, minmax(0, 1fr)); gap: 0; padding: 0; border: 0; border-radius: 0; border-top: 1px solid var(--line); }
    .wrow.whead { border-top: 0; background: var(--paper); }
    .whead .wcell { font-size: var(--fs-meta); font-weight: 750; color: var(--blue); padding: 8px; }
    .whead .wcell.you { box-shadow: inset 0 -3px 0 var(--red); }
    .wrow:not(.whead) .wcell.you { background: var(--block-weak); }
    .wwhen { padding: 8px; flex-direction: column; gap: 0; }
    .wcell, .wcell.is-empty { display: flex; padding: 2px 8px; border-left: 1px solid var(--line); }
    .wrow:not(.whead) .wlane { display: none; }
    .wlane + .wstep { border-top: 0; }
    .wmile { padding: 8px; border-top: 1px solid var(--line); background: var(--yellow-soft); }
  }

  /* ---------- Table view: one flat, sortable table ---------- */
  .tablewrap { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow-x: auto; }
  .tasktable { width: 100%; min-width: 620px; border-collapse: separate; border-spacing: 0; font-size: var(--fs-small); }
  .tasktable th { text-align: left; padding: 0; background: var(--paper); border-bottom: 1px solid var(--line); white-space: nowrap; }
  .tasktable th button { display: flex; align-items: center; gap: 2px; width: 100%; min-height: 36px; padding: 0 10px; background: none; border: 0;
    font-size: var(--fs-meta); font-weight: 750; color: var(--ink-soft); text-align: left; }
  .tasktable th[aria-sort="ascending"] button, .tasktable th[aria-sort="descending"] button { color: var(--blue); }
  .tasktable th .sort { width: 15px; height: 15px; transform: rotate(180deg); }
  .tasktable th[aria-sort="descending"] .sort { transform: none; }
  .tasktable td { padding: 4px 10px; border-top: 1px solid var(--line); vertical-align: middle; background: var(--card); }
  .tasktable tbody tr:first-child td { border-top: 0; }
  .tasktable tbody tr { cursor: pointer; }
  @media (hover: hover) { .tasktable tbody tr:hover td { background: var(--row-hover); } }
  /* the tick and task name stay put while the other columns scroll sideways on phones */
  .tasktable .c-check { position: sticky; left: 0; z-index: 1; width: 44px; padding: 0; }
  .tasktable .c-task { position: sticky; left: 44px; z-index: 1; min-width: 190px; border-right: 1px solid var(--line); }
  .tasktable th.c-check, .tasktable th.c-task { z-index: 2; background: var(--paper); }
  @media (min-width: 900px) { .tasktable .c-task { border-right: 0; min-width: 0; } }
  .tasktable .check { width: 44px; height: 40px; }
  .t-title { background: none; border: 0; padding: 4px 0; text-align: left; font-size: var(--fs-small); font-weight: 500; line-height: 1.3; color: var(--ink); overflow-wrap: anywhere; }
  @media (hover: hover) { .tasktable tr:hover .t-title { text-decoration: underline; text-decoration-color: var(--control-line); text-underline-offset: 3px; } }
  .task-row.s-done .t-title { text-decoration: line-through; text-decoration-color: var(--control-line); color: var(--ink-soft); font-weight: 400; }
  .task-row.s-na .t-title { color: var(--ink-soft); font-weight: 400; }
  .tasktable .t-status, .tasktable .t-who { display: none; }
  /* phones: no sideways scrolling. Stage and Status columns go (status shows under the title),
     leaving tick, task, who and date */
  @media (max-width: 619px) {
    .tasktable { min-width: 0; }
    .tasktable .c-stage, .tasktable .c-status { display: none; }
    .tasktable .c-task { position: static; min-width: 0; border-right: 0; padding: 4px 6px 4px 2px; }
    .tasktable .c-check { position: static; }
    .tasktable td.c-who, .tasktable td.c-date { padding: 4px 6px; }
    .tasktable td.c-who { white-space: normal; }   /* "Mortgage broker" on two lines */
    .tasktable td.c-date .pill { white-space: normal; overflow-wrap: normal; display: inline-block; }   /* "Overdue:" / "18 Oct", never mid-word */
    .tasktable .t-status { display: block; margin: 0 0 5px; }
  }
  /* small phones: Who moves under the title too */
  @media (max-width: 359px) {
    .tasktable .c-who { display: none; }
    .tasktable .t-who { display: block; margin: -2px 0 3px; font-size: var(--fs-meta); font-weight: 700; color: var(--violet); }
  }
  .nowrap { white-space: nowrap; }
  .tasktable .has-comments { display: inline-flex; vertical-align: -2px; margin-left: 4px; color: var(--violet); }
  .tasktable .has-comments .icon { width: 15px; height: 15px; }
  .tasktable .c-stage { white-space: nowrap; max-width: 210px; overflow: hidden; text-overflow: ellipsis; color: var(--ink-soft); }
  .tasktable .c-stage .num { font-weight: 750; color: var(--ink); margin-right: 2px; }
  .tasktable .c-who { white-space: nowrap; font-weight: 700; color: var(--violet); font-size: var(--fs-meta); }
  .tasktable .c-status, .tasktable .c-date { white-space: nowrap; }
  .tasktable .muted { color: var(--ink-soft); font-size: var(--fs-meta); }

  /* ---------- Sheets ---------- */
  .scrim { position: fixed; inset: 0; background: rgba(0,31,29,.5); z-index: 40; opacity: 0; pointer-events: none; transition: opacity .2s; }
  .scrim.open { opacity: 1; pointer-events: auto; }
  .sheet {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
    background: var(--card); border-radius: 18px 18px 0 0; padding: 8px 16px calc(env(safe-area-inset-bottom) + 20px);
    max-height: 92dvh; overflow-y: auto; overscroll-behavior: contain;
    transform: translateY(100%); transition: transform .25s ease-out, visibility 0s .25s;
    max-width: var(--maxw); margin: 0 auto;
    visibility: hidden; /* closed sheets must not catch clicks or keyboard focus */
  }
  .sheet.small { max-width: 480px; }
  .sheet.open { transform: translateY(0); visibility: visible; transition: transform .25s ease-out; }
  .grab { position: relative; width: 40px; height: 4px; background: var(--line); border-radius: 99px; margin: 4px auto 10px; touch-action: none; }
  .grab::before { content: ""; position: absolute; inset: -14px -60px; }   /* bigger target to drag the panel down by */
  .sheet > h2 { touch-action: none; }
  .sheet h2 { font-size: var(--fs-stage); margin: 0 0 12px; color: var(--blue); }
  .sheet h2:focus { outline: none; }
  .sheet h3 { font-size: var(--fs-body); font-weight: 700; margin: 0 0 8px; }
  .sheet section + section { border-top: 1px solid var(--line); margin-top: 14px; padding-top: 14px; }
  .field { margin-bottom: 10px; }
  .field label, .field .label { display: block; font-size: var(--fs-small); font-weight: 650; color: var(--ink); margin-bottom: 4px; }
  .field .hint { margin: -2px 0 6px; font-size: var(--fs-meta); }
  .field input, .field select, .field textarea {
    width: 100%; min-height: var(--tap); border: 1px solid var(--control-line); border-radius: 8px; padding: 9px 10px; background: var(--card);
    font-size: var(--fs-body); /* 16px stops iPhone Safari zooming into the field */
  }
  .field textarea { resize: vertical; min-height: 56px; }
  .field input[aria-invalid="true"], .field textarea[aria-invalid="true"] { border-color: var(--block); }
  .row2 { display: flex; gap: 10px; }
  .row2 > .field { flex: 1; min-width: 0; }
  .inline { display: flex; gap: 8px; }
  .inline input { flex: 1; min-width: 0; }
  /* pinned to the bottom of the panel so Save is always in reach, however long the form */
  .sheet-actions { display: flex; gap: 10px; margin-top: 8px; flex-wrap: wrap; position: sticky; bottom: 0; background: var(--card); padding: 12px 0 4px; }
  .btn { min-height: var(--tap); border-radius: 8px; border: 1px solid var(--control-line);
    background: var(--card); font-weight: 650; padding: 0 16px; flex: 1; }
  .btn.primary { background: var(--blue); color: #fff; border-color: var(--blue); }
  @media (max-height: 500px) { .sheet-actions { position: static; } }
  @media (hover: hover) { .btn:hover { background: var(--paper); } .btn.primary:hover { background: #33338a; } }
  .btn.danger { color: var(--block); border-color: var(--block); flex: 0 0 auto; }
  .btn.slim { flex: 0 0 auto; }
  .btn:disabled { opacity: .6; cursor: progress; }

  @media (min-width: 620px) {
    .sheet { border-radius: 16px; bottom: auto; top: 50%; left: 50%; right: auto; width: min(var(--maxw), calc(100% - 32px));
      max-height: calc(100dvh - 48px); transform: translate(-50%,-50%) scale(.98);
      opacity: 0; transition: opacity .2s, transform .2s ease-out, visibility 0s .2s; padding: 20px 24px 24px; }
    .sheet.small { width: min(480px, calc(100% - 32px)); }
    .sheet.open { transform: translate(-50%,-50%) scale(1); opacity: 1; transition: opacity .2s, transform .2s ease-out; }
    .grab { display: none; }
  }

  /* ---------- History ---------- */
  .hist-item { padding: 8px 2px; border-bottom: 1px solid var(--line); font-size: var(--fs-small); }
  .hist-item:last-child { border-bottom: 0; }
  .hist-item .h-top { display: flex; justify-content: space-between; gap: 10px; color: var(--ink-soft); font-size: var(--fs-meta); margin-bottom: 2px; }
  .hist-item .h-who { font-weight: 650; color: var(--ink); }
  .hist-item .h-act { font-weight: 650; }
  .hist-item .h-act.create, .hist-item .h-act.restore { color: var(--blue); }
  .hist-item .h-act.delete { color: var(--red); }
  .hist-item .h-act.update { color: var(--violet); }
  .hist-change { color: var(--ink-soft); overflow-wrap: anywhere; }
  .hist-change .oldv { text-decoration: line-through; }

  /* ---------- Login ---------- */
  .login-wrap { min-height: 100svh; display: grid; place-items: center; padding: 24px 16px; background: var(--blue); }
  .login-card { background: var(--card); border-radius: 14px; padding: 22px 20px 20px; width: 100%; max-width: 360px; }
  .login-card h1 { font-size: var(--fs-lead); letter-spacing: -.01em; color: var(--blue); margin: 0 0 2px; }
  .login-card h1::before { content: ""; display: block; width: 36px; height: 6px; border-radius: 2px; background: var(--yellow); margin-bottom: 12px; }
  .login-card > p { margin: 0 0 20px; color: var(--ink-soft); font-size: var(--fs-small); }
  .login-card > p.tagline { margin: 2px 0 14px; color: var(--ink); font-size: var(--fs-body); line-height: 1.35; }

  /* ---------- Messages ---------- */
  .toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(env(safe-area-inset-bottom) + 16px);
    background: var(--ink); color: #fff; padding: 6px 6px 6px 16px; border-radius: 12px; font-size: var(--fs-small); z-index: 60;
    opacity: 0; transition: opacity .2s; pointer-events: none; width: max-content; max-width: calc(100% - 32px);
    display: flex; align-items: center; gap: 12px; min-height: 44px; }
  .toast.show { opacity: 1; }
  .toast.show.has-action { pointer-events: auto; }
  .toast button { background: var(--yellow); color: var(--blue); border: 0; border-radius: 8px; min-height: 36px; padding: 0 12px; font-weight: 700; }
  .toast:not(.has-action) { padding-right: 16px; }
  .err { color: var(--block); font-size: var(--fs-small); margin: 8px 0 0; min-height: 1.2em; }
  #menuErr:empty { display: none; }

  @media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
