/* Every colour is a light-dark() pair, so the theme follows the device unless
   the account dialog forces one (theme.js sets data-theme on <html>). */
:root {
  color-scheme: light dark;
  --bg: light-dark(#f6f5f1, #161614);
  --panel: light-dark(#ffffff, #201f1d);
  --soft: light-dark(#ebe9e2, #2b2a27);
  --line: light-dark(#dcd9d0, #3b3934);
  --line-strong: light-dark(#aaa69b, #625f57);
  --text: light-dark(#23221f, #e9e6df);
  --muted: light-dark(#736f66, #a09c91);
  --accent: light-dark(#1f7a42, #6fd394);
  --primary: light-dark(#23874a, #2f9e5b);
  --red: light-dark(#b42318, #ff8f85);
  --red-bg: light-dark(#fde3e1, #4b201c);
  --danger: light-dark(#b42318, #c0392b);
  --amber: light-dark(#b45309, #f0b45c);
  --ok: light-dark(#1b7a3d, #7fd49b);
  --blocked-fill: light-dark(#e8e7e2, #34332f);
  --done-text: light-dark(#9a968d, #777369);
  --chip-bg: light-dark(#eceff2, #2b3137);
  --chip-line: light-dark(#bcc5cf, #4b5660);
  --chip-text: light-dark(#34475a, #c3cfdb);
  --ready-bg: light-dark(#dff3e4, #1e3d29);
  --ready-text: light-dark(#1b6b36, #8fdba6);
  --held-bg: light-dark(#d3d1ca, #4d4b45);
  --held-text: light-dark(#45423c, #dbd8cf);
  --warn-bg: light-dark(#fff3d6, #3c3115);
  --warn-line: light-dark(#e6c56a, #7c6524);
  --highlight: light-dark(#e2f3e7, #22402c);
  --flash: light-dark(#ffe9a8, #5e4c13);
  --shadow: light-dark(rgb(0 0 0 / 0.16), rgb(0 0 0 / 0.55));
  --detail-width: 340px;
  /* Chart colours, checked for colour-blind separation and contrast on both surfaces. */
  --chart-done: light-dark(#2f9d52, #3aa85e);
  --st-ready: light-dark(#2f9d52, #3aa85e);
  --st-doing: light-dark(#2a6fd6, #5288e0);
  --st-blocked: light-dark(#d97a1a, #d07f2a);
  --st-done: light-dark(#7e55c7, #9a76de);
}
:root[data-theme='light'] { color-scheme: light; }
:root[data-theme='dark'] { color-scheme: dark; }

/* Category colours: fill, text and edge stripe for each. */
.g-blue { --g-bg: light-dark(#dbe7ff, #22345c); --g-text: light-dark(#1d3f94, #b4c9ff); --g-line: light-dark(#4f7be0, #6d93f0); }
.g-green { --g-bg: light-dark(#d9f2df, #1c3d27); --g-text: light-dark(#1b6b36, #93dba8); --g-line: light-dark(#3aa35c, #4fb873); }
.g-amber { --g-bg: light-dark(#fdeecb, #46360f); --g-text: light-dark(#8a5a00, #f1c56b); --g-line: light-dark(#d79a1b, #e0aa37); }
.g-purple { --g-bg: light-dark(#ebe0fb, #37285a); --g-text: light-dark(#5b2fa3, #cdb6ff); --g-line: light-dark(#8a5fd6, #a383e6); }
.g-teal { --g-bg: light-dark(#d3f1f0, #173d3d); --g-text: light-dark(#0f6362, #86d9d6); --g-line: light-dark(#2aa3a0, #43bcb8); }
.g-rose { --g-bg: light-dark(#fbdde2, #4a1f28); --g-text: light-dark(#a1263b, #ffb0bd); --g-line: light-dark(#e0556b, #ee7386); }
.g-orange { --g-bg: light-dark(#fde3d0, #48290f); --g-text: light-dark(#9a4a0c, #f8b98a); --g-line: light-dark(#e8822f, #f09650); }
.g-lime { --g-bg: light-dark(#e6f2c4, #323c12); --g-text: light-dark(#55690d, #c6dc7c); --g-line: light-dark(#8fae24, #a5c540); }
.g-pink { --g-bg: light-dark(#fbdcf1, #47203c); --g-text: light-dark(#9c2a7a, #f7aede); --g-line: light-dark(#d858b2, #e678c4); }
.g-slate { --g-bg: light-dark(#e3e6ea, #2e3238); --g-text: light-dark(#47505c, #c3cad3); --g-line: light-dark(#7b8794, #93a0ad); }
.g-indigo { --g-bg: light-dark(#e0e2ff, #272a5e); --g-text: light-dark(#3138a8, #bcc1ff); --g-line: light-dark(#5a63e0, #7c84f0); }
.g-sky { --g-bg: light-dark(#d6eefb, #163a4d); --g-text: light-dark(#0c5f86, #8fd3f4); --g-line: light-dark(#2f9fd6, #52b5e6); }
.g-brown { --g-bg: light-dark(#efe0d2, #40301f); --g-text: light-dark(#7a4a1e, #e0b88f); --g-line: light-dark(#a8703a, #c08a55); }
.g-yellow { --g-bg: light-dark(#fbf3bf, #3f390f); --g-text: light-dark(#6f6100, #e8d96a); --g-line: light-dark(#cdb81a, #d8c63a); }
.g-magenta { --g-bg: light-dark(#f3dcfb, #3f1f4a); --g-text: light-dark(#8a2aa3, #e6aef5); --g-line: light-dark(#b95bd3, #cc7de2); }
.g-graphite { --g-bg: light-dark(#d9d9d9, #3a3a3a); --g-text: light-dark(#2e2e2e, #e2e2e2); --g-line: light-dark(#555555, #b5b5b5); }
.g-red { --g-bg: light-dark(#fdd9d5, #4d1a16); --g-text: light-dark(#a31b12, #ffa79e); --g-line: light-dark(#dc3b2e, #f0584a); }
.g-mint { --g-bg: light-dark(#d4f6e8, #123d30); --g-text: light-dark(#0b6b4b, #86e2c0); --g-line: light-dark(#34b98a, #4fcf9f); }
.g-olive { --g-bg: light-dark(#e8e9c6, #35360f); --g-text: light-dark(#5b5d10, #d3d57a); --g-line: light-dark(#8a8d22, #a9ac3e); }
.g-navy { --g-bg: light-dark(#d5dbee, #1c2547); --g-text: light-dark(#1c2c66, #aebbee); --g-line: light-dark(#2c3f8f, #5b6fc4); }
.g-plum { --g-bg: light-dark(#ead8ee, #3a2040); --g-text: light-dark(#6b2a78, #dba9e6); --g-line: light-dark(#8b3f9a, #a862b6); }
.g-sand { --g-bg: light-dark(#f1e7d3, #3d3524); --g-text: light-dark(#6e5a2c, #dccb9c); --g-line: light-dark(#b79d5c, #c9b274); }
.g-maroon { --g-bg: light-dark(#f1d5db, #451821); --g-text: light-dark(#7d1630, #f0a3b5); --g-line: light-dark(#9c2543, #c04d6a); }
.g-forest { --g-bg: light-dark(#d3e8d6, #17331c); --g-text: light-dark(#1d5a2a, #9fd4a9); --g-line: light-dark(#2c7a3c, #4a9a5a); }

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.4 system-ui, -apple-system, 'Segoe UI', sans-serif;
  padding-bottom: env(safe-area-inset-bottom);
}
body.with-detail { padding-right: var(--detail-width); }

button, input, select, textarea { font: inherit; color: inherit; }
button {
  padding: 5px 11px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  cursor: pointer;
}
button:hover:not(:disabled) { border-color: var(--line-strong); }
button:disabled { opacity: 0.5; cursor: default; }
button.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
button.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: -1px; }

input, select, textarea {
  padding: 5px 7px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--panel);
}

.muted { color: var(--muted); }
.error-text, .late { color: var(--red); }
.warn-text { color: var(--amber); }
.ok-text { color: var(--ok); }
.error-text:empty, .muted:empty { display: none; }

/* ---------- login ---------- */

.login {
  width: min(340px, calc(100vw - 32px));
  margin: 12vh auto 0;
  padding: 28px 24px 24px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  display: grid;
  gap: 12px;
}
.login .brand { display: block; width: 76px; height: 76px; margin: 0 auto 2px; }
.login h1 { margin: 0 0 8px; font-size: 24px; text-align: center; }
.login .sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.login label { display: grid; }
.login label input { padding: 11px 13px; border: 0; border-radius: 10px; background: var(--soft); color: var(--text); font-size: 16px; }
.login label input:focus { outline: 2px solid var(--primary); outline-offset: -1px; }
.login .error-text:empty { display: none; }
.login button.primary { margin-top: 4px; padding: 12px; border-radius: 12px; font-size: 16px; font-weight: 600; }
.login .note { margin: 0; padding: 10px; background: var(--warn-bg); border-radius: 6px; }
.login .signup { margin: 2px 0 0; font-size: 13px; text-align: center; }

/* Sign in with Apple and Google, styled the way each asks for its button:
   Apple's is black (white in the dark), Google's is white with a border. */
.providers { display: grid; gap: 10px; }
.provider {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 11px 13px;
  border-radius: 10px;
  font-size: 16px;
  font-weight: 500;
}
.provider.apple { background: light-dark(#000, #fff); border-color: light-dark(#000, #fff); color: light-dark(#fff, #000); }
.provider.google { background: light-dark(#fff, #131314); border-color: light-dark(#747775, #8e918f); color: light-dark(#1f1f1f, #e3e3e3); }
.or { display: flex; align-items: center; gap: 10px; margin: 2px 0 0; color: var(--muted); font-size: 13px; }
.or::before, .or::after { content: ''; flex: 1; border-top: 1px solid var(--line); }
.identity { display: inline-block; min-width: 64px; }

/* ---------- header and summary ---------- */

/* The env() insets leave room for a phone's status bar, notch and home
   indicator when the app runs full-screen; everywhere else they are 0. */
.top {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: calc(10px + env(safe-area-inset-top)) calc(16px + env(safe-area-inset-right)) 10px calc(16px + env(safe-area-inset-left));
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}
.top .spacer { flex: 1; }
/* The menu, under the ••• button: the pull-down menu of an iOS app, on a
   computer too. A click anywhere else closes it (and goes no further). */
.top { position: relative; }
#menu-btn { display: flex; align-items: center; justify-content: center; width: 36px; height: 36px; padding: 0; border: 0; background: none; color: var(--primary); }
@keyframes menu-in { from { transform: scale(0.8); opacity: 0; } }
.top.menu-open::before { content: ''; position: fixed; inset: 0; z-index: 29; }
.menu { display: none; position: absolute; top: calc(100% - 2px); right: calc(10px + env(safe-area-inset-right)); z-index: 30; flex-direction: column; width: 250px; padding: 0; border-radius: 13px; background: color-mix(in srgb, var(--panel) 82%, transparent); -webkit-backdrop-filter: blur(24px) saturate(1.8); backdrop-filter: blur(24px) saturate(1.8); box-shadow: 0 0 0 0.5px var(--line), 0 12px 40px rgb(0 0 0 / 0.22); overflow: hidden; transform-origin: top right; }
.top.menu-open .menu { display: flex; animation: menu-in 0.18s ease-out; }
.menu-group { display: flex; flex-direction: column; }
.menu-group:not(:last-child) { border-bottom: 8px solid color-mix(in srgb, var(--text) 9%, transparent); }
.menu button { display: flex; align-items: center; justify-content: space-between; gap: 12px; width: 100%; min-height: 40px; padding: 0 14px; border: 0; border-radius: 0; background: none; color: var(--text); font-size: 15px; text-align: left; }
.menu button span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.menu button svg { display: block; flex: none; width: 20px; height: 20px; }
.menu-group button + button:not([hidden]) { border-top: 0.5px solid var(--line); }
.menu button:disabled { color: var(--muted); opacity: 1; }
.menu button:hover:not(:disabled), .menu button:active { background: color-mix(in srgb, var(--text) 8%, transparent); }
#list-select { font-size: 16px; font-weight: 600; max-width: 45vw; }
#list-menu-btn, #list-menu { display: none; } /* the phone's title menu; a computer has the select */
.save-status { color: var(--muted); font-size: 12px; }
.save-status.failed { color: var(--red); font-weight: 600; }

.no-list { padding: 60px 16px; text-align: center; }

.summary { display: flex; flex-wrap: wrap; gap: 10px; padding: 14px 16px 4px; }
.tile {
  min-width: 132px;
  padding: 9px 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}
.tile b { display: block; font-size: 22px; line-height: 1.2; }
.tile span { color: var(--muted); font-size: 12px; }
.tile.alert b { color: var(--red); }
button.tile { text-align: left; cursor: pointer; font: inherit; }
button.tile:hover { border-color: var(--accent); }
.tile small { display: block; color: var(--muted); font-size: 11px; }

.banner { margin: 10px 16px 0; padding: 8px 12px; border-radius: 8px; }
.banner.warn { background: var(--warn-bg); border: 1px solid var(--warn-line); }
.banner.update { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; background: var(--highlight); border: 1px solid var(--chip-line); }
#name-nudge span { flex: 1 1 260px; }
.banner p { margin: 2px 0; }

/* ---------- toolbar and add bar ---------- */

.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; padding: 12px 16px 0; }
.tabs { display: flex; flex-wrap: wrap; gap: 4px; flex: 1; }
.tabs button { border-radius: 16px; padding: 4px 12px; }
.tabs button[aria-pressed='true'] { background: var(--text); border-color: var(--text); color: var(--bg); }
.tabs button.temp { margin-left: 10px; }
.tabs i { font-style: normal; opacity: 0.65; font-size: 12px; }
.tabs .short { display: none; }
.close .word { display: none; }
#search { width: 260px; }
#sort-select { display: none; }

.now-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 14px; padding: 10px 16px 0; }
.now-bar input { width: 70px; margin: 0 4px; }
.now-bar span { color: var(--muted); }

.add { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 10px 16px; }
.add label { font-weight: 600; }
.add #add-task { flex: 1; min-width: 180px; max-width: 640px; }
#shorthand-btn { width: 30px; padding: 5px 0; border-radius: 50%; color: var(--muted); font-weight: 700; }
.shorthand { position: fixed; inset: auto; margin: 0; width: min(460px, calc(100vw - 16px)); padding: 12px 14px; border: 1px solid var(--line-strong); border-radius: 8px; background: var(--panel); color: var(--text); box-shadow: 0 10px 30px var(--shadow); font-size: 13px; line-height: 1.4; }
.shorthand p { margin: 0 0 10px; }
.shorthand dl { display: grid; grid-template-columns: 14em 1fr; align-items: baseline; gap: 7px 14px; margin: 0 0 12px; }
.shorthand dt, .shorthand code, .shorthand .example { font-family: ui-monospace, Menlo, monospace; font-size: 12px; }
.shorthand dt { padding: 1px 6px; border-radius: 4px; background: var(--soft); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.shorthand code { padding: 0 4px; border-radius: 3px; background: var(--soft); }
.shorthand dd { margin: 0; color: var(--muted); }
.shorthand .example { margin: 0; padding: 8px 10px; border-left: 3px solid var(--primary); border-radius: 0 6px 6px 0; background: var(--soft); color: var(--text); overflow-wrap: anywhere; }
.add-hints { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; flex-basis: 100%; font-size: 12px; }
.add-actions { display: none; }
.add-cat, .add-box, .list-title { display: contents; }
.due-text, .hrs-text { display: none; }
.hint { padding: 1px 8px; border-radius: 10px; background: var(--soft); color: var(--text); }
.hint.priority { background: var(--red-bg); color: var(--red); }
.hint.area { background: var(--chip-bg); color: var(--chip-text); }
.hint.warn { background: var(--warn-bg); color: var(--amber); }
.hint.who { background: var(--ready-bg); color: var(--ready-text); }
/* Who a task is assigned to, as a small tag after its name. */
.who { flex: none; max-width: 120px; margin: 0 4px 0 2px; padding: 1px 8px; border-radius: 10px; background: var(--ready-bg); color: var(--ready-text); font-size: 12px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.who::before { content: '→ '; opacity: 0.7; }
tr.done .who { background: var(--soft); color: var(--done-text); }
.add-more { display: none; } /* the phone's add sheet has the room for proper fields; the bar does not */
#undo-menu-btn, #redo-menu-btn { display: none; } /* a computer's header has Undo and Redo; a phone's menu does */
/* A tip that shows at once (a title would take a second), saying what Undo or Redo would do. */
.hint-btn { position: relative; }
.hint-btn:hover::after, .hint-btn:focus-visible::after { content: attr(data-label); position: absolute; top: calc(100% + 6px); right: 0; z-index: 40; max-width: 320px; padding: 4px 8px; border-radius: 6px; background: var(--text); color: var(--bg); font-size: 12px; font-weight: 400; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; pointer-events: none; }
.hint-btn:disabled:hover::after { opacity: 0.75; }
.choice { display: grid; gap: 4px; justify-items: start; }
.choice p { margin: 0; }
.print-head { display: none; }
.next-id { min-width: 40px; padding: 3px 8px; border-radius: 5px; background: var(--soft); font-weight: 600; text-align: center; }

/* ---------- the grid ---------- */

#grid {
  width: calc(100% - 32px);
  min-width: 960px;
  margin: 0 16px;
  border-collapse: collapse;
  table-layout: fixed;
  background: var(--panel);
}
.w-drag { width: 22px; } .w-id { width: 62px; } .w-area { width: 112px; } .w-prio { width: 96px; }
 .w-due { width: 124px; } .w-hrs { width: 78px; } .w-deps { width: 140px; }
.w-state { width: 104px; } .w-done { width: 30px; }

#grid th {
  position: sticky;
  top: 0;
  z-index: 2;
  padding: 7px 7px;
  background: var(--soft);
  border-bottom: 1px solid var(--line);
  text-align: left;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}
#grid th button { padding: 0; border: 0; border-radius: 3px; background: none; font-weight: inherit; }
#grid th button::after { content: '↕'; margin-left: 4px; opacity: 0; }
#grid th button:hover::after, #grid th button:focus-visible::after { opacity: 0.45; }
#grid th button[data-dir='asc']::after { content: '▲'; opacity: 1; font-size: 9px; }
#grid th button[data-dir='desc']::after { content: '▼'; opacity: 1; font-size: 9px; }
/* Cells line up along the top, so a row expanded for reading keeps its controls on the task's own line. */
#grid td { padding: 0; border-bottom: 1px solid var(--soft); vertical-align: top; height: 32px; }
#grid .c-drag, #grid .c-done, #grid .c-id { line-height: 30px; }

/* Cells are real inputs that only look like inputs when hovered or focused. */
#grid td input, #grid td select {
  width: 100%;
  height: 31px;
  padding: 4px 7px;
  border: 1px solid transparent;
  border-radius: 0;
  background: transparent;
  text-overflow: ellipsis;
}
#grid td select { appearance: none; cursor: pointer; }
#grid td input:hover, #grid td select:hover { border-color: var(--line); }
#grid td input:focus, #grid td select:focus { background: var(--panel); outline: 2px solid var(--accent); outline-offset: -2px; color: var(--text); }
#grid td input[readonly] { cursor: default; }
#grid td .c-hrs input, #grid td input[type='number'] { text-align: right; }
.c-hrs input { text-align: right; }
#grid td input[type='date'].blank:not(:focus):not(:hover) { color: transparent; }
#grid td input[type='date'].blank:not(:focus):not(:hover)::-webkit-calendar-picker-indicator { opacity: 0; }

.c-drag { text-align: center; box-shadow: inset 3px 0 0 var(--g-line, transparent); }
.gpill { max-width: 100%; padding: 1px 9px; overflow: hidden; border-radius: 10px; background: var(--g-bg); color: var(--g-text); font-size: 12px; font-weight: 600; white-space: nowrap; text-overflow: ellipsis; }
.task-line { display: flex; align-items: center; }
.task-line input { flex: 1; min-width: 0; }
.task-text { display: none; }
/* The description sits under the task name, in full unless it is long. */
.note-line { display: flex; align-items: baseline; gap: 6px; padding: 0 8px 7px; font-size: 13px; line-height: 1.4; color: color-mix(in srgb, var(--text) 72%, transparent); }
.note-line .more { flex: none; }
.note-text { min-width: 0; white-space: pre-wrap; overflow-wrap: anywhere; cursor: pointer; }
tr.done .note-line { color: var(--done-text); }
.detail textarea[data-field='notes'] { resize: vertical; }
.note-text.cut { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 3; overflow: hidden; }
.more { padding: 0; border: 0; background: none; color: var(--accent); font-size: 12px; text-decoration: underline; }
.thumbs { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0; }
.thumb { padding: 0; overflow: hidden; border-radius: 6px; line-height: 0; }
.thumb img { width: 84px; height: 84px; object-fit: cover; }
.open-btn { flex: none; display: flex; margin-right: 4px; padding: 4px; border-color: transparent; background: transparent; color: var(--line-strong); }
tr:hover .open-btn, .open-btn:focus-visible, tr.open .open-btn { color: var(--accent); border-color: var(--line); background: var(--panel); }
tr.open td { box-shadow: inset 0 1px 0 var(--accent), inset 0 -1px 0 var(--accent); }
tr.open td.c-drag { box-shadow: inset 3px 0 0 var(--g-line, transparent), inset 0 1px 0 var(--accent), inset 0 -1px 0 var(--accent); }
.swatch { flex: none; display: inline-flex; align-items: center; justify-content: center; width: 22px; height: 22px; padding: 0; border: 2px solid var(--g-line); border-radius: 50%; background: var(--g-bg); color: var(--g-text); font-size: 12px; font-weight: 700; }
.color-pop { position: fixed; inset: auto; margin: 0; width: 460px; max-width: calc(100vw - 16px); max-height: calc(100vh - 16px); overflow-y: auto; padding: 10px 12px 12px; background: var(--panel); border: 1px solid var(--line-strong); border-radius: 8px; color: var(--text); box-shadow: 0 10px 30px var(--shadow); }
.color-pop p { margin: 0 0 8px; }
.palette { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; }
.palette button { display: flex; align-items: center; gap: 8px; padding: 4px 6px; border-color: transparent; text-align: left; }
.palette button:hover, .palette button[aria-pressed='true'] { border-color: var(--line-strong); }
.palette button[aria-pressed='true'] { background: var(--g-bg); }
.palette small { display: block; color: var(--muted); font-size: 11px; line-height: 1.1; }
.palette button.used > .swatch { opacity: 0.35; }
.handle { display: none; cursor: grab; color: var(--line-strong); font-size: 11px; letter-spacing: -2px; user-select: none; }
#grid.can-reorder .handle { display: inline; }
.c-id { white-space: nowrap; padding-left: 4px !important; }
.idlink { padding: 2px 5px; border-color: transparent; background: transparent; font-weight: 600; color: var(--accent); }
.cycle-flag { color: var(--amber); }
mark { padding: 0 1px; border-radius: 2px; background: var(--flash); color: inherit; }
.reading { padding: 2px 8px 8px; font-size: 13px; line-height: 1.45; color: var(--text); }
.reading p { margin: 0 0 4px; white-space: pre-wrap; overflow-wrap: anywhere; }
.reading b { color: var(--muted); font-size: 12px; }
.read-btn { flex: none; margin-right: 4px; padding: 1px 7px; border-radius: 10px; border-color: var(--line); background: var(--panel); color: var(--ok); font-size: 12px; font-weight: 600; white-space: nowrap; }
/* Priority and status cells: a pill or badge showing the computed value, under
   an invisible dropdown that sets the user's own. */
.pick { position: relative; display: flex; align-items: center; height: 31px; padding: 0 7px; border: 1px solid transparent; overflow: hidden; }
.pick:hover { border-color: var(--line); }
.pick:focus-within { outline: 2px solid var(--accent); outline-offset: -2px; }
#grid td .pick select { position: absolute; inset: 0; width: 100%; max-width: none; height: 100%; opacity: 0; }
#grid td input[type='checkbox'] { width: 16px; height: 16px; margin: 0 7px; padding: 0; vertical-align: middle; accent-color: var(--primary); cursor: pointer; }
.pill { padding: 1px 9px; border-radius: 10px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.pill:empty { display: none; }
.pill.high, .high { color: var(--red); background: var(--red-bg); }
.pill.medium, .medium { color: var(--amber); }
.pill.medium { background: var(--warn-bg); }
.pill.low { color: var(--muted); background: var(--soft); }
.c-deps { padding: 5px 4px 2px !important; }
.c-deps .chips { display: inline; }
.dep-edit { padding: 0 6px; border-color: transparent; background: transparent; color: var(--muted); }
.dep-edit:hover, .dep-edit:focus-visible { border-color: var(--line); background: var(--panel); }

.chip {
  margin: 1px 3px 1px 0;
  padding: 0 7px;
  border: 1px solid var(--chip-line);
  border-radius: 10px;
  background: var(--chip-bg);
  color: var(--chip-text);
  font-size: 12px;
  font-weight: 600;
}
.chip.done { border-color: var(--line); background: transparent; color: var(--muted); text-decoration: line-through; font-weight: 400; }

.badge { padding: 1px 8px; border-radius: 10px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.badge.ready { background: var(--ready-bg); color: var(--ready-text); }
.badge.blocked { background: var(--held-bg); color: var(--held-text); }
.badge.doing { background: var(--chip-bg); color: var(--chip-text); }
.badge.done { color: var(--done-text); }

/* Row states, as in the spreadsheet. */
tr.blocked td { background: var(--blocked-fill); }
tr.done td { color: var(--done-text); }
tr.done .idlink { color: var(--done-text); }
tr.first-done td { border-top: 3px solid var(--line); }
/* Overdue: just the date in red. The box is big enough that any fill shouts. */
#grid td.c-due.overdue { color: var(--red); }
tr.drop-before td { box-shadow: inset 0 2px 0 var(--accent); }
tr.drop-after td { box-shadow: inset 0 -2px 0 var(--accent); }
tr.flash td { animation: flash 1.6s ease-out; }
@keyframes flash { from { background-color: var(--flash); } }

.elsewhere { margin: 18px 16px 0; }
.elsewhere h3 { margin: 0 0 6px; font-size: 13px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); }
.hit { padding: 8px 10px; background: var(--panel); border-bottom: 1px solid var(--soft); }
.hit > button { margin-right: 6px; padding: 1px 8px; border-radius: 10px; color: var(--accent); font-size: 12px; font-weight: 600; }
.hit .reading { padding: 4px 0 0; }

.empty { margin: 0 16px; padding: 28px; background: var(--panel); text-align: center; color: var(--muted); }
.keys { margin: 10px 16px 24px; font-size: 12px; color: var(--muted); }

/* ---------- task detail panel ---------- */

.detail {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 5;
  width: var(--detail-width);
  padding: calc(14px + env(safe-area-inset-top)) calc(16px + env(safe-area-inset-right)) calc(24px + env(safe-area-inset-bottom)) 16px;
  overflow-y: auto;
  background: var(--panel);
  border-left: 1px solid var(--line);
  box-shadow: -6px 0 18px var(--shadow);
}
.detail header, .dialog header { display: flex; align-items: center; justify-content: space-between; }
.detail h2, .dialog h2 { margin: 0; font-size: 18px; }
.detail h3, .dialog h3 { margin: 16px 0 6px; font-size: 13px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); }
.detail header button, .dialog header button { border-color: transparent; font-size: 20px; line-height: 1; padding: 2px 8px; }
.detail label, .detail .field { display: grid; gap: 3px; margin-top: 10px; color: var(--muted); font-size: 12px; }
.detail label > *, .detail output { font-size: 14px; color: var(--text); }
.detail .grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
.detail output { padding: 5px 8px; border-radius: 5px; background: var(--bg); font-weight: 600; }
.detail output.high { color: var(--red); background: var(--red-bg); }
.detail output.medium { color: var(--amber); }
.detail textarea { resize: vertical; }
.d-ready { margin: 14px 0 0; line-height: 1.9; }
.d-ready .late { display: block; }
.dep { display: flex; align-items: center; gap: 4px; padding: 2px 0; }
.dep span { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dep button:not(.chip) { padding: 0 7px; border-color: transparent; color: var(--muted); }
.d-related .fix { padding: 5px 0; }
.d-related .fix p { margin: 2px 0 0; font-size: 13px; line-height: 1.45; color: var(--text); white-space: pre-wrap; overflow-wrap: anywhere; }
.d-related .more { margin-top: 2px; }
.detail textarea::placeholder { color: var(--muted); opacity: 0.8; }
.d-photos { margin-bottom: 6px; }
.d-delete { margin-top: 24px; padding-top: 14px; border-top: 1px solid var(--line); }

/* ---------- dependency picker ---------- */

.picker {
  position: fixed;
  z-index: 20;
  width: 400px;
  max-width: calc(100vw - 16px);
  padding: 8px;
  background: var(--panel);
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  box-shadow: 0 10px 30px var(--shadow);
}
.picker input { width: 100%; }
.picker ul { max-height: 280px; margin: 6px 0 0; padding: 0; overflow-y: auto; list-style: none; }
.picker li { display: flex; align-items: center; gap: 6px; padding: 4px 6px; border-radius: 5px; cursor: pointer; }
.picker li.hi { background: var(--highlight); }
.picker li.none { color: var(--muted); cursor: default; }
.picker .tick { width: 14px; color: var(--accent); font-weight: 700; }
.picker .title { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.picker em { font-style: normal; font-size: 11px; color: var(--muted); white-space: nowrap; }
.picker em.loop { color: var(--amber); font-weight: 600; }
.picker-hint { margin: 6px 2px 0; font-size: 11px; color: var(--muted); }
.picker-head { display: none; }
.add-deps-field { display: grid; gap: 6px; color: var(--muted); font-size: 14px; }
#add-deps { display: flex; flex-wrap: wrap; gap: 6px; }
#add-deps-btn { justify-self: start; }
.dep-chip { display: inline-flex; align-items: center; gap: 4px; max-width: 100%; padding: 3px 4px 3px 9px; border: 1px solid var(--chip-line); border-radius: 999px; background: var(--highlight); color: var(--text); font-size: 14px; }
.dep-chip b { font-weight: 600; }
.dep-chip button { padding: 0 6px; border: 0; background: none; color: var(--muted); font-size: 17px; line-height: 1; }

/* ---------- dialogs ---------- */

.dialog {
  width: min(700px, calc(100vw - 24px));
  max-height: calc(100vh - 40px);
  padding: 18px 22px 22px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--text);
}
.dialog.small { width: min(460px, calc(100vw - 24px)); }
.dialog::backdrop { background: rgb(20 19 17 / 0.45); }
.dialog section { padding-bottom: 14px; border-bottom: 1px solid var(--soft); }
.dialog section:last-child { border-bottom: 0; padding-bottom: 0; }
.dialog p { margin: 6px 0; }
.dialog ul { margin: 4px 0 8px; padding-left: 20px; }
.dialog .row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 8px 0; }
.dialog .format { margin: 8px 0 12px; font-size: 13px; line-height: 1.4; }
.dialog .format summary { cursor: pointer; color: var(--primary); }
.dialog .format dl { display: grid; grid-template-columns: max-content 1fr; align-items: baseline; gap: 5px 12px; margin: 8px 0; }
.dialog .format dt, .dialog .format code, .dialog .format .example { font-family: ui-monospace, Menlo, monospace; font-size: 12px; }
.dialog .format dt { padding: 1px 6px; border-radius: 4px; background: var(--soft); white-space: nowrap; }
.dialog .format code { padding: 0 4px; border-radius: 3px; background: var(--soft); }
.dialog .format dd { margin: 0; color: var(--muted); }
.dialog .format .example { margin: 8px 0; padding: 8px 10px; border-left: 3px solid var(--primary); border-radius: 0 6px 6px 0; background: var(--soft); overflow-x: auto; }
.dialog .stack, .dialog.small form { display: grid; gap: 10px; justify-items: start; }
.dialog .stack label, .dialog.small form label { display: grid; gap: 3px; width: 100%; max-width: 420px; color: var(--muted); }
.dialog label > input, .dialog label > select { color: var(--text); }
.dialog .inline { display: flex; align-items: center; gap: 8px; color: var(--muted); }
.dialog .inline input { flex: 1; min-width: 0; max-width: 360px; }
.dialog .check { display: flex; align-items: center; gap: 5px; }
.dialog input.days { width: 64px; }
.dialog input.prefix { width: 72px; text-transform: uppercase; }
.plain { width: 100%; border-collapse: collapse; }
.plain th { padding: 4px 6px; text-align: left; font-size: 12px; color: var(--muted); font-weight: 600; }
.plain td { padding: 3px 6px; border-top: 1px solid var(--soft); }
.plain td.actions { text-align: right; white-space: nowrap; }
.plain td.actions button:not(.primary):not(.danger) { padding: 2px 7px; border-color: transparent; background: none; color: var(--primary); }
.plain td.actions button:not(.primary):not(.danger):hover { border-color: var(--line); }
#users-tools { margin: 0 0 10px; }
#users-search { flex: 1 1 240px; max-width: 360px; }
#users-pager { justify-content: center; margin-top: 12px; }
.plain td.actions .placeholder { visibility: hidden; }
.plain td.person { line-height: 1.3; }
.plain td.person .muted { font-size: 12px; }
.plain td input:not([type='checkbox']) { width: 100%; }
.plain td input.prefix { width: 72px; }
.plain td.actions input { width: 170px; }
#import-file { max-width: 100%; }
.dest { min-width: 0; margin: 12px 0 0; padding: 8px 12px 10px; border: 1px solid var(--line); border-radius: 8px; }
.dest legend { padding: 0 4px; color: var(--muted); font-size: 12px; }
.dest .check { padding: 3px 0; }
.dest #import-new { margin: 2px 0 6px 22px; }
.dest .inline { flex: 1 1 100%; min-width: 0; }
.dest .inline select { flex: 1; min-width: 0; max-width: 360px; }
.no-list button { margin: 4px; }
.plain td.actions input.new-name, .plain td.actions input.new-display { width: 150px; }
.plain td.actions input.reset-url { width: 100%; margin: 4px 0; font-size: 12px; }
.plain td.actions span { display: block; text-align: left; }
.trash { list-style: none; padding: 0 !important; }
.trash li { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 4px 10px; padding: 4px 0; border-top: 1px solid var(--soft); }
.steps { margin: 12px 0; padding-left: 22px; }
.steps li { margin: 8px 0; line-height: 1.5; }
.steps svg { vertical-align: -3px; color: var(--accent); }
.dialog.wide { width: min(860px, calc(100vw - 24px)); }
.kpis { display: flex; flex-wrap: wrap; gap: 10px; }
.kpis .tile { flex: 1 1 120px; }
.chart { margin: 4px 0 8px; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart .bar { fill: var(--chart-done); }
.chart .hit { fill: transparent; }
.chart g:hover .bar { fill-opacity: 0.8; }
.chart .grid { stroke: var(--soft); stroke-width: 1; }
.chart .axis { fill: var(--muted); font-size: 11px; }
.chart .val { fill: var(--text); font-size: 12px; font-weight: 600; }
.st-ready { fill: var(--st-ready); background: var(--st-ready); }
.st-doing { fill: var(--st-doing); background: var(--st-doing); }
.st-blocked { fill: var(--st-blocked); background: var(--st-blocked); }
.st-done { fill: var(--st-done); background: var(--st-done); }
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; margin: 8px 0 0; font-size: 12px; color: var(--muted); }
.legend .key { display: inline-flex; align-items: center; gap: 6px; }
.legend .key b { color: var(--text); }
.legend i { width: 12px; height: 12px; border-radius: 3px; }
.legend .sw-open { background: var(--line-strong); }
.legend .sw-done { background: var(--soft); border: 1px solid var(--line-strong); }
.cats .cat { display: grid; grid-template-columns: 120px 1fr auto; align-items: center; gap: 10px; padding: 3px 0; }
.cats .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.cats .track { display: flex; gap: 2px; height: 14px; }
.cats .track i { display: block; height: 100%; border-radius: 3px; }
.cats .track .open { background: var(--g-line); }
.cats .track .done { background: var(--g-bg); box-shadow: inset 0 0 0 1px var(--g-line); }
.cats .nums { font-size: 12px; color: var(--muted); white-space: nowrap; }
.as-table { margin-top: 6px; font-size: 12px; color: var(--muted); }
.as-table table { margin-top: 6px; max-width: 360px; }
.recent { list-style: none; margin: 0; padding: 0 !important; }
.recent li { display: flex; align-items: center; gap: 8px; padding: 5px 0; border-top: 1px solid var(--soft); }
.recent .gpill { font-size: 11px; }
.recent .title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.recent .when { color: var(--muted); font-size: 12px; white-space: nowrap; }
.tip { position: fixed; z-index: 50; max-width: 260px; padding: 5px 9px; border-radius: 6px; background: var(--text); color: var(--bg); font-size: 12px; pointer-events: none; }
.photo-view { width: min(900px, calc(100vw - 24px)); }
.photo-view h2 { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.photo-view img { display: block; max-width: 100%; max-height: calc(100vh - 190px); margin: 12px auto; border-radius: 6px; }
.members { list-style: none; padding: 0 !important; }
.members li { display: flex; align-items: center; justify-content: space-between; max-width: 360px; padding: 3px 0; }
#import-report { margin-top: 10px; }
#import-report li .error-text { margin-left: 8px; }

/* Pull down to refresh (home-screen app on an iPhone): a spinner in the
   space that opens above the list as it is pulled down. */
.pull {
  position: fixed;
  top: env(safe-area-inset-top);
  left: 0;
  right: 0;
  display: flex;
  justify-content: center;
  pointer-events: none;
}
.pull span { width: 26px; height: 26px; border: 3px solid var(--muted); border-top-color: transparent; border-radius: 50%; }
body.settling #app, body.settling .pull { transition: transform 0.25s ease-out, opacity 0.25s; }
body.refreshing #app { transform: translateY(56px); transition: transform 0.2s ease-out; }
body.refreshing .pull { display: flex !important; opacity: 1 !important; transform: translateY(15px); }
body.refreshing .pull span { animation: spin 0.7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.fab { display: none; }

/* Inside the iOS app: no grey tap flashes or text-selection callouts on controls. */
.in-app { -webkit-tap-highlight-color: transparent; -webkit-touch-callout: none; }
.in-app button, .in-app .pick, .in-app .tabs, .in-app .tile, .in-app .badge, .in-app .pill, .in-app .gpill, .in-app .chip { -webkit-user-select: none; user-select: none; }

.toast {
  inset: auto auto calc(18px + env(safe-area-inset-bottom)) 50%;
  transform: translateX(-50%);
  margin: 0;
  max-width: min(560px, calc(100vw - 32px));
  padding: 10px 16px;
  border: 0;
  border-radius: 8px;
  background: var(--text);
  color: var(--bg);
  box-shadow: 0 8px 24px var(--shadow);
}
.toast button { margin-left: 8px; padding: 2px 10px; border-color: currentColor; background: transparent; color: inherit; font-weight: 600; }

/* ---------- phones ----------
   The same table, restyled: each row becomes a card showing the task, its
   status, area, priority, due date and dependencies. Everything else is one
   tap away in the detail panel, which takes the whole screen. */

@media screen and (max-width: 720px) {
  input, select, textarea { font-size: 16px; } /* smaller text makes iOS zoom in on focus */
  button { padding: 7px 12px; }

  /* One header line: the list, Undo, and a menu holding the rest. */
  .top { position: relative; gap: 6px; padding: calc(8px + env(safe-area-inset-top)) calc(10px + env(safe-area-inset-right)) 8px calc(10px + env(safe-area-inset-left)); }
  #list-select { flex: 1; min-width: 0; max-width: none; }
  .top { flex-wrap: wrap; }
  .top .spacer, .save-status:empty { display: none; }
  .save-status.failed, #retry-btn { order: 9; } /* a save problem gets a line of its own */
  .save-status.failed { flex-basis: 100%; }
  .now-bar { padding: 10px 10px 0; }
  .elsewhere { margin: 14px 10px 0; }

  .summary { flex-wrap: nowrap; gap: 8px; padding: 10px 10px 2px; overflow-x: auto; }
  .tile { flex: none; min-width: 104px; padding: 7px 10px; }
  .tile b { font-size: 19px; }
  .banner { margin: 8px 10px 0; }

  .toolbar { padding: 10px 10px 0; }
  /* Less at the top: no tiles (they are in Progress), and the views are one
     segmented control. */
  .summary { display: none; }
  .tabs { flex: 1 1 100%; flex-wrap: nowrap; gap: 0; padding: 2px; border-radius: 9px; background: var(--soft); overflow-x: auto; scrollbar-width: none; }
  .tabs::-webkit-scrollbar { display: none; }
  .tabs button { flex: 1 0 auto; min-width: 0; padding: 6px 8px; border: 0; border-radius: 7px; background: transparent; color: var(--text); font-size: 13px; white-space: nowrap; }
  .tabs button[aria-pressed='true'] { background: var(--panel); color: var(--text); font-weight: 600; box-shadow: 0 1px 3px var(--shadow); }
  .tabs button.temp { margin-left: 0; }
  .tabs .long, .tabs i { display: none; }
  .tabs .short { display: inline; }

  .close .glyph { display: none; }
  .close .word { display: inline; }
  #search { flex: 1; width: auto; min-width: 0; }
  #sort-select { display: block; }

  /* Adding is a sheet behind the + button, so the top of the screen stays clear. */
  .adder { display: none; position: fixed; inset: 0 0 auto 0; z-index: 35; padding-top: env(safe-area-inset-top); background: var(--panel); border-bottom: 1px solid var(--line-strong); border-radius: 0 0 16px 16px; box-shadow: 0 10px 30px var(--shadow); }
  body.add-open .adder { display: block; }
  .add-backdrop { display: none; position: fixed; inset: 0; z-index: 34; background: rgb(0 0 0 / 0.35); }
  body.add-open .add-backdrop { display: block; }
  .fab { position: fixed; right: calc(18px + env(safe-area-inset-right)); bottom: calc(22px + env(safe-area-inset-bottom)); z-index: 33; display: flex; align-items: center; justify-content: center; width: 56px; height: 56px; padding: 0; border: 0; border-radius: 50%; background: var(--primary); color: #fff; font-size: 32px; font-weight: 300; line-height: 1; box-shadow: 0 6px 20px var(--shadow); }
  body.add-open .fab, body.with-detail .fab, #app[hidden] ~ .fab { display: none; }
  .add #shorthand-btn { flex: none; }
  .add-more { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 10px; flex-basis: 100%; padding: 14px 0 6px; }
  .add .add-more label { display: grid; gap: 4px; color: var(--muted); font-size: 14px; font-weight: 400; }
  .add-more label > input, .add-more label > select, .add-more label > textarea { width: 100%; min-width: 0; color: var(--text); }
  .add-more .wide { grid-column: 1 / -1; }
  .add-more p { grid-column: 1 / -1; margin: 0; font-size: 13px; }

  #grid { display: block; width: auto; min-width: 0; margin: 0 10px; }
  #grid colgroup, #grid thead { display: none; }
  #grid tbody { display: block; }
  #grid tr {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px 8px;
    padding: 6px 8px 8px;
    border-bottom: 1px solid var(--soft);
  }
  #grid tr::after { content: ''; order: 4; flex-basis: 100%; } /* ends the first line */
  #grid td { display: block; height: auto; padding: 0 !important; border: 0 !important; background: transparent; }
  #grid .c-drag, #grid .c-hrs { display: none; }
  #grid .c-id { order: 1; }
  #grid .c-task { order: 2; flex: 1 1 0; min-width: 0; }
  #grid .c-done { order: 0; }
  #grid .c-state { order: 3; }
  #grid td input[type='checkbox'] { width: 22px; height: 22px; margin: 0 2px 0 0; }
  #grid .c-area { order: 6; }
  #grid .c-prio { order: 7; }
  #grid .c-prio:has(.pill:empty) { display: none; } /* no priority: set one in the detail panel */
  .pick { height: 36px; padding: 0 2px; }
  .pill { padding: 3px 11px; font-size: 14px; }
  #grid .c-due { order: 8; border-radius: 6px; }
  #grid .c-deps { order: 9; }

  #grid td input, #grid td select { height: 36px; }
  #grid td select, #grid .c-due input { width: auto; max-width: 42vw; border-color: var(--line); border-radius: 6px; }
  #grid .c-due:has(input.blank) { display: none; } /* a date is added in the detail panel */
  #grid td.c-due.overdue input { color: var(--red); }
  #grid td select { padding: 4px 8px; }
  .idlink { padding: 6px 6px; }
  .dep-edit { padding: 4px 10px; border-color: var(--line); }

  #grid tr { border-left: 4px solid var(--g-line, transparent); }
  .gpill { padding: 3px 11px; font-size: 14px; }
  .open-btn { padding: 8px; color: var(--accent); }
  /* The whole task name, wrapped; tapping it opens the task for editing. */
  .task-line { align-items: flex-start; }
  .task-line input { display: none; }
  .note-line { padding: 0 2px 4px; font-size: 14px; }
  .task-text { display: block; flex: 1; min-width: 0; padding: 7px 2px; overflow-wrap: anywhere; cursor: pointer; }
  #grid tr.open td { box-shadow: none; }
  #grid tr.blocked { background: var(--blocked-fill); }
  #grid tr.first-done { border-top: 3px solid var(--line); }
  .empty { margin: 0 10px; }
  .keys { display: none; }

  body.with-detail, body.add-open { padding-right: 0; overflow: hidden; }
  .adder, .detail, .dialog, .picker ul, .menu, #list-menu { overscroll-behavior: contain; }
  .detail { width: 100%; border-left: 0; padding-left: calc(16px + env(safe-area-inset-left)); }

  .dialog { padding: 14px 14px 18px; }
  .cats .cat { grid-template-columns: 88px 1fr; }
  .cats .nums { grid-column: 2; margin-top: -2px; }
  .palette { grid-template-columns: 1fr 1fr; }
  .plain .next { display: none; }
  .plain td { padding: 3px 3px; }
  .plain td.actions input { width: 100%; }

  /* Accounts: each account is a card - who, then Plan and Admin on one line,
     then the actions wrapping underneath - instead of a table too wide to fit. */
  #admin thead { display: none; }
  #admin tbody { display: block; }
  #admin tbody tr { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; align-items: center; padding: 10px 0; border-top: 1px solid var(--soft); }
  #admin tbody tr:first-child { border-top: 0; }
  #admin tbody td { display: block; padding: 0; border: 0; }
  #admin td.person { grid-column: 1 / -1; }
  #admin td.person .muted { font-size: 13px; }
  #admin td:has([data-user-admin]) { display: flex; align-items: center; gap: 6px; font-size: 15px; }
  #admin td:has([data-user-admin])::before { content: 'Admin'; color: var(--muted); }
  #admin td.actions { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 4px 2px; white-space: normal; text-align: left; }
  #admin td.actions button:not(.primary):not(.danger) { padding: 6px 8px; margin-left: -8px; font-size: 15px; }
  #admin td.actions .placeholder { display: none; }
  #admin td.actions span { flex-basis: 100%; }
  #admin td.actions input { flex: 1 1 100%; margin: 0; }
  #admin td.actions input.new-name, #admin td.actions input.new-display, #admin td.actions input.new-password { flex: 1 1 160px; }
  #users-tools { margin-bottom: 4px; }
  #users-search { max-width: none; }
}

/* ---------- phones: the chrome of an iOS app ----------
   The header is a navigation bar with the list's name as its title. Anything
   modal - the add form, a task's details, every dialog - is a page sheet that
   slides up, with a centred title and Done or Cancel at the ends, and the
   menu is an action sheet from the bottom. */
@media screen and (max-width: 720px) {
  :root { --sheet-top: calc(env(safe-area-inset-top) + 10px); --dim: rgb(0 0 0 / 0.35); }
  @keyframes sheet-in { from { transform: translateY(48px); opacity: 0.4; } }
  @keyframes fade-in { from { opacity: 0; } }

  .top { gap: 6px; padding: calc(4px + env(safe-area-inset-top)) calc(8px + env(safe-area-inset-right)) 4px calc(14px + env(safe-area-inset-left)); border-bottom: 0; background: var(--bg); }
  /* The list's name is the title; tapping it drops down the lists (a title menu). */
  .list-title { position: relative; display: flex; align-items: center; flex: 1; min-width: 0; }
  #list-select { display: none; }
  #list-menu-btn { display: inline-flex; align-items: center; gap: 5px; max-width: 100%; padding: 6px 0; border: 0; background: none; color: var(--text); font-size: 22px; font-weight: 700; }
  #list-menu-btn span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  #list-menu-btn svg { flex: none; margin-top: 3px; color: var(--muted); }
  .top.list-open::before { content: ''; position: fixed; inset: 0; z-index: 29; }
  #list-menu { display: none; right: auto; left: 0; width: 270px; transform-origin: top left; }
  .top.list-open #list-menu { display: flex; animation: menu-in 0.18s ease-out; }
  #list-menu small { color: var(--muted); font-size: 14px; font-weight: 400; }
  #list-menu button svg { color: var(--primary); }
  #undo-btn, #redo-btn { display: none; } /* in the menu instead, where they say what they would do; in the app, a shake */
  #undo-menu-btn, #redo-menu-btn { display: flex; }
  .toolbar { padding-top: 4px; }
  #search { padding: 8px 12px; border: 0; border-radius: 10px; background: var(--soft); }
  #sort-select { border: 0; border-radius: 10px; background: var(--soft); }

  /* The menu, at a thumb's size. */
  .menu button { min-height: 44px; padding: 0 16px; font-size: 17px; }
  .menu button svg { width: 21px; height: 21px; }
  .in-app .menu-undo { display: none; } /* the app has shake to undo instead */
  body.menu-open .fab { display: none; }

  /* Sheets. */
  .dialog, .dialog.small, .dialog.wide, .detail, .adder { position: fixed; top: var(--sheet-top); right: 0; bottom: 0; left: 0; width: auto; max-width: none; height: auto; max-height: none; margin: 0; padding: 0 16px calc(20px + env(safe-area-inset-bottom)); border: 0; border-radius: 14px 14px 0 0; background: var(--panel); box-shadow: 0 -6px 30px var(--shadow); overflow-y: auto; animation: sheet-in 0.25s ease-out; }
  /* With the keyboard up, only part of the screen is visible: a sheet is
     sized and placed to that part (--vvh/--vvt, from the visual viewport),
     so it scrolls inside itself instead of hiding behind the keys. */
  .dialog, .dialog.small, .dialog.wide, .detail, .adder { top: calc(var(--vvt, 0px) + var(--sheet-top)); bottom: auto; height: calc(var(--vvh, 100%) - var(--sheet-top)); }
  /* The keyboard's accessory bar is translucent and sits below the visual
     viewport, so while a sheet is open the sheet's colour continues under it
     rather than the list's: a panel of its own in the top layer (a fixed
     child of the sheet would be clipped with the sheet's scrolling). */
  #keyboard-fill { position: fixed; inset: auto 0 0 0; top: calc(var(--vvt, 0px) + var(--vvh, 100%)); width: auto; height: 100vh; margin: 0; padding: 0; border: 0; background: var(--panel); overflow: hidden; pointer-events: none; }
  #keyboard-fill[hidden]:not(:popover-open) { display: none; }
  .dialog::backdrop { background: var(--dim); }
  .add-backdrop { background: var(--dim); }
  body.with-detail::after { content: ''; position: fixed; inset: 0; z-index: 4; background: var(--dim); animation: fade-in 0.2s; }
  .dialog::before, .detail::before, .adder::before { content: ''; display: block; width: 36px; height: 5px; margin: 6px auto 0; border-radius: 3px; background: var(--line-strong); }

  /* Choosing dependencies: a sheet from the bottom, over the add sheet or the task's details. */
  .picker { top: auto !important; right: 0; bottom: calc(100% - var(--vvt, 0px) - var(--vvh, 100%)); left: 0 !important; z-index: 36; display: flex; flex-direction: column; width: auto; max-width: none; max-height: min(72vh, calc(var(--vvh, 100vh) - 24px)); padding: 0 16px calc(12px + env(safe-area-inset-bottom)); border: 0; border-radius: 14px 14px 0 0; box-shadow: 0 -6px 30px var(--shadow); animation: sheet-in 0.25s ease-out; }
  .picker[hidden] { display: none; }
  .picker-head { position: relative; display: flex; align-items: center; justify-content: center; min-height: 50px; margin: 0 -16px 10px; padding: 0 16px; border-bottom: 1px solid var(--line); font-size: 17px; }
  .picker-head button { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); padding: 8px 6px; border: 0; background: none; color: var(--primary); font-size: 17px; font-weight: 600; }
  .picker input { font-size: 16px; }
  .picker ul { flex: 1; max-height: none; margin-top: 8px; overflow-y: auto; }
  .picker li { padding: 10px 6px; font-size: 16px; }
  .picker-hint { display: none; }

  /* A sheet's navigation bar: the title in the middle, Done or Cancel at the ends. */
  .dialog header, .detail header, .add-actions { position: sticky; top: 0; z-index: 2; display: flex; align-items: center; justify-content: center; min-height: 50px; margin: 0 -16px 8px; padding: 0 16px; background: var(--panel); border-bottom: 1px solid var(--line); }
  .dialog h2, .detail h2, .add-title { margin: 0; font-size: 17px; font-weight: 600; text-align: center; }
  .dialog header .close, .detail header .close, .add-actions button { position: absolute; top: 50%; transform: translateY(-50%); padding: 8px 6px; border: 0; background: none; color: var(--primary); font-size: 17px; line-height: 1.2; }
  .dialog header .close, .detail header .close, .add-actions #add-submit { right: 10px; font-weight: 600; }
  .add-actions #add-cancel { left: 10px; }
  /* showModal() lands focus on Done; no ring for that. */
  .dialog header .close:focus, .detail header .close:focus { outline: none; }

  /* The add form inside its sheet. */
  .add { flex-direction: column; align-items: stretch; gap: 14px; padding: 0; }
  .add-actions { order: -2; display: flex; }
  .add label { display: none; }
  .add-box { order: -1; display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
  .add-box .shorthand { position: static; flex-basis: 100%; width: auto; margin: 6px 0 0; padding: 12px 14px; border: 0; border-radius: 12px; background: var(--soft); box-shadow: none; font-size: 15px; line-height: 1.4; animation: fade-in 0.2s; }
  .add-box .shorthand { min-width: 0; max-width: 100%; overflow-wrap: anywhere; }
  .add-box .shorthand dl { display: block; margin: 0 0 10px; }
  .add-box .shorthand dt { display: inline-block; margin-top: 10px; font-size: 14px; white-space: normal; background: var(--panel); }
  .add-box .shorthand .example { background: var(--panel); }
  .add-box .shorthand dd { margin: 2px 0 0; }
  .add #add-task { flex: 1; min-width: 0; padding: 10px 0; border: 0; border-bottom: 1px solid var(--line); border-radius: 0; background: none; font-size: 20px; }
  .add #add-task:focus { outline: none; border-bottom-color: var(--primary); }
  .add-cat { display: flex; align-items: center; gap: 10px; }
  .add-cat::before { content: 'Category'; color: var(--muted); font-size: 15px; }
  .add #add-area { flex: 1; min-width: 0; }
  .add-hints { flex-basis: auto; padding: 0; }

  /* The list as an inset group, with room under it for the + button. */
  #grid { margin: 6px 10px 96px; }
  #grid tbody { border-radius: 12px; overflow: hidden; }

  .in-app button:active, .in-app .tile:active { opacity: 0.55; }

  .login { width: auto; margin: max(16vh, calc(60px + env(safe-area-inset-top))) 28px 0; padding: 0; background: none; border: 0; gap: 12px; }
  .login .brand { width: 96px; height: 96px; margin-bottom: 6px; }
  .login h1 { font-size: 28px; }
  .login label input { padding: 14px 16px; font-size: 17px; }
  .login button.primary { padding: 14px; font-size: 17px; }

  /* A quiet row: a round check, the name, then one grey line of facts -
     category · priority · date · after D6 · blocked. No boxes or buttons; a
     tap on the name opens the sheet, where everything is edited. */
  #grid tr { gap: 0 8px; padding: 11px 14px 11px 48px; }
  #grid .c-done { margin-left: -38px; }
  #grid td input[type='checkbox'] { width: 24px; height: 24px; margin: 0 6px 0 0; border: 1.5px solid var(--line-strong); border-radius: 50%; background: none; -webkit-appearance: none; appearance: none; }
  #grid td input[type='checkbox']:checked { border-color: var(--primary); background: var(--primary); box-shadow: inset 0 0 0 2.5px var(--panel); }
  .idlink { padding: 4px 0; font-size: 13px; font-weight: 600; color: var(--muted); }
  .task-text { padding: 3px 0; font-size: 17px; line-height: 1.3; }
  .note-line { padding: 0 0 2px; font-size: 14px; color: var(--muted); }
  .open-btn, .read-btn { display: none; }
  #grid tr::after { margin-top: 3px; }
  #grid .c-area, #grid .c-prio, #grid .c-due, #grid .c-deps, #grid .c-state { order: 6; font-size: 13px; line-height: 1.5; color: var(--muted); }
  #grid .c-prio .pick::before, #grid .c-due::before, #grid .c-deps:has(.chip)::before, #grid .c-state .pick::before { content: '·'; margin-right: 8px; }
  #grid .c-deps:has(.chip)::before { content: '· after'; }
  #grid td .pick { display: inline-flex; align-items: baseline; height: auto; padding: 0; border: 0; }
  #grid td .pick select { display: none; }
  #grid .gpill { max-width: none; padding: 0; overflow: visible; background: none; color: var(--g-text); font-size: 13px; font-weight: 600; }
  #grid .pill { padding: 0; background: none; font-size: 13px; font-weight: 600; }
  #grid .c-due input { display: none; }
  .due-text { display: inline; }
  #grid td.c-due.overdue .due-text { color: var(--red); font-weight: 600; }
  .dep-edit { display: none; }
  #grid .c-deps:not(:has(.chip)) { display: none; }
  .chips .chip { padding: 0; margin-right: 4px; border: 0; background: none; color: var(--accent); font-size: 13px; }
  #grid .badge { padding: 0; background: none; font-size: 13px; font-weight: 600; }
  #grid .c-state:has(.badge.ready), #grid .c-state:has(.badge.done) { display: none; }
  #grid tr.blocked { background: var(--panel); }
  tr.done .task-text { text-decoration: line-through; }
}

/* ---------- print: the view on screen as a plain table ---------- */

@media print {
  @page { margin: 12mm; }
  :root { color-scheme: light; }
  body, body.with-detail { padding: 0; background: #fff; color: #000; }
  .top, .toolbar, .summary, .now-bar, .adder, .add-backdrop, .fab, .detail, .keys, .elsewhere, .banner, .pull, .toast, #cycles, #update, .empty { display: none !important; }
  .print-head { display: block; margin: 0 0 10px; }
  .print-head h1 { margin: 0; font-size: 20px; }
  .print-head p { margin: 2px 0 0; color: #555; font-size: 12px; }
  #grid { width: 100%; min-width: 0; margin: 0; table-layout: auto; background: none; font-size: 11px; }
  #grid thead { display: table-header-group; }
  #grid th { position: static; padding: 4px 5px; background: #eee; color: #000; border-bottom: 1px solid #999; font-size: 10px; print-color-adjust: exact; }
  #grid th button { display: none; }
  #grid th[data-label]::before { content: attr(data-label); }
  #grid td { height: auto; padding: 3px 5px; border-bottom: 1px solid #ccc; vertical-align: top; line-height: 1.35; }
  #grid tr { break-inside: avoid; page-break-inside: avoid; border-left: 4px solid var(--g-line, #ccc); print-color-adjust: exact; }
  #grid tr.blocked { background: #f3f3f3; print-color-adjust: exact; }
  #grid tr.done { color: #777; }
  #grid tr.first-done { border-top: 2px solid #999; }
  .w-drag, .c-drag, #grid thead th:first-child { display: none; }
  /* Values, not controls. */
  #grid td input, #grid td select, .dep-edit, .open-btn, .read-btn, .more, .pick::after { display: none !important; }
  #grid .c-done input[type='checkbox'] { display: inline-block !important; width: 11px; height: 11px; margin: 2px 0 0; appearance: auto; }
  .task-line { display: block; } /* a flex box would shrink the column to its longest word */
  .task-line input { display: none; }
  .task-text { display: inline; }
  .due-text, .hrs-text { display: inline; }
  #grid .c-task { width: 40%; }
  #grid .c-done { width: 16px; }
  #grid .c-hrs { text-align: right; }
  tr.done .pill { display: none; }
  .pick { height: auto; padding: 0; border: 0; overflow: visible; }
  .pill, .badge, .gpill, .chip, .who { display: inline-block; padding: 0 6px; border: 1px solid #aaa; border-radius: 9px; background: none !important; color: #000 !important; font-size: 10px; font-weight: 600; }
  .pill:empty, .badge:empty { display: none; }
  .who::before { content: '→ '; }
  .chip { margin-right: 3px; }
  .note-line { padding: 1px 0 0; color: #333; font-size: 10px; }
  .note-text.cut { display: block; -webkit-line-clamp: unset; }
  .reading { font-size: 10px; }
  .thumbs { display: none; }
}
