/* Taski: Todoist's visual language, kept calm. */

:root {
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, Roboto, "Helvetica Neue", Arial, sans-serif;
  --bg: #ffffff;
  --side: #fcfaf8;
  --text: #202020;
  --text-2: #666666;
  --muted: #808080;
  --line: #f0f0f0;
  --line-2: #e6e6e6;
  --hover: #f2efed;
  --hover-2: #f5f5f5;
  --sel-bg: #ffefe5;
  --sel-text: #c3402c;
  --accent: #dc4c3e;
  --accent-hover: #c3392c;
  --accent-text: #ffffff;
  --card: #ffffff;
  --popover: #ffffff;
  --shadow: 0 0 0 1px rgba(0, 0, 0, .06), 0 4px 16px rgba(0, 0, 0, .1);
  --shadow-lg: 0 15px 50px rgba(0, 0, 0, .25);
  --p1: #d1453b; --p2: #eb8909; --p3: #246fe0; --p4: #999999;
  --p1-bg: rgba(209, 69, 59, .1); --p2-bg: rgba(235, 137, 9, .1); --p3-bg: rgba(36, 111, 224, .1);
  --due-overdue: #d1453b; --due-today: #058527; --due-tomorrow: #ad6200; --due-week: #692ec2; --due-later: #808080;
  --icon-inbox: #246fe0; --icon-today: #058527; --icon-upcoming: #692ec2;
  --toast-bg: #282828; --toast-text: #ffffff;
  --radius: 10px;
  --tabbar-h: 52px;
  color-scheme: light;
}

/* Dark: by system preference unless the person picked light, or when they picked dark. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #1e1e1e; --side: #262626; --text: #e8e8e8; --text-2: #a6a6a6; --muted: #8a8a8a;
    --line: #2f2f2f; --line-2: #3d3d3d; --hover: #333333; --hover-2: #2a2a2a;
    --sel-bg: #3b2a26; --sel-text: #ff8a7a; --accent: #e0503f; --accent-hover: #f0614f;
    --card: #262626; --popover: #2b2b2b; --shadow: 0 0 0 1px rgba(255, 255, 255, .08), 0 6px 20px rgba(0, 0, 0, .5); --shadow-lg: 0 15px 50px rgba(0, 0, 0, .6);
    --p1: #ff7066; --p2: #ff9a14; --p3: #5297ff; --p4: #7a7a7a;
    --p1-bg: rgba(255, 112, 102, .14); --p2-bg: rgba(255, 154, 20, .14); --p3-bg: rgba(82, 151, 255, .14);
    --due-overdue: #ff7066; --due-today: #25b84c; --due-tomorrow: #ff9a14; --due-week: #a970ff; --due-later: #8a8a8a;
    --icon-inbox: #5297ff; --icon-today: #25b84c; --icon-upcoming: #a970ff;
    --toast-bg: #f0f0f0; --toast-text: #202020;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #1e1e1e; --side: #262626; --text: #e8e8e8; --text-2: #a6a6a6; --muted: #8a8a8a;
  --line: #2f2f2f; --line-2: #3d3d3d; --hover: #333333; --hover-2: #2a2a2a;
  --sel-bg: #3b2a26; --sel-text: #ff8a7a; --accent: #e0503f; --accent-hover: #f0614f;
  --card: #262626; --popover: #2b2b2b; --shadow: 0 0 0 1px rgba(255, 255, 255, .08), 0 6px 20px rgba(0, 0, 0, .5); --shadow-lg: 0 15px 50px rgba(0, 0, 0, .6);
  --p1: #ff7066; --p2: #ff9a14; --p3: #5297ff; --p4: #7a7a7a;
  --p1-bg: rgba(255, 112, 102, .14); --p2-bg: rgba(255, 154, 20, .14); --p3-bg: rgba(82, 151, 255, .14);
  --due-overdue: #ff7066; --due-today: #25b84c; --due-tomorrow: #ff9a14; --due-week: #a970ff; --due-later: #8a8a8a;
  --icon-inbox: #5297ff; --icon-today: #25b84c; --icon-upcoming: #a970ff;
  --toast-bg: #f0f0f0; --toast-text: #202020;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body { margin: 0; font: 14px/1.45 var(--font); color: var(--text); background: var(--bg); -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2, h3 { margin: 0; }
code { font: 12px ui-monospace, SFMono-Regular, Menlo, monospace; background: var(--hover-2); padding: 1px 5px; border-radius: 4px; word-break: break-all; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.pad { padding: 10px 0; }
.center { text-align: center; }
.spacer { flex: 1; }

.i { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.i.sm { width: 18px; height: 18px; }
.i.xs { width: 13px; height: 13px; stroke-width: 2; }
.caret { width: 14px; height: 14px; stroke-width: 2.2; }

/* --- buttons --- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 32px; padding: 0 12px; border-radius: 6px; border: 0; background: var(--hover-2); color: var(--text); font-weight: 600; font-size: 13px; white-space: nowrap; }
.btn:hover { background: var(--line-2); }
.btn.primary { background: var(--accent); color: var(--accent-text); }
.btn.primary:hover { background: var(--accent-hover); }
.btn.primary:disabled { opacity: .5; cursor: default; }
.btn.ghost { background: none; color: var(--text-2); }
.btn.ghost:hover { background: var(--hover-2); color: var(--text); }
.btn.sm { height: 28px; padding: 0 10px; font-size: 12px; }
.btn.block { display: flex; width: 100%; height: 42px; font-size: 15px; }
.btn .i { width: 18px; height: 18px; }
.icon-btn { display: inline-grid; place-items: center; width: 28px; height: 28px; border: 0; border-radius: 6px; background: none; color: var(--muted); padding: 0; }
.icon-btn:hover { background: var(--hover-2); color: var(--text); }
.icon-btn .i { width: 20px; height: 20px; }
.link-btn { border: 0; background: none; padding: 0; color: var(--accent); font-weight: 600; font-size: 13px; }
.link-btn:hover { text-decoration: underline; }
.danger { color: var(--p1) !important; }

/* --- layout --- */
.shell { display: flex; min-height: 100vh; min-height: 100dvh; }
.sidebar { width: 280px; flex: none; background: var(--side); position: sticky; top: 0; height: 100vh; height: 100dvh; overflow-y: auto; overscroll-behavior: contain; }
.main { flex: 1; min-width: 0; }
.view { max-width: 800px; margin: 0 auto; padding: 36px 55px 96px; }

/* --- sidebar --- */
.side { padding: 12px 12px 24px; padding-left: max(12px, env(safe-area-inset-left)); }
.side-top { display: flex; align-items: center; margin-bottom: 6px; }
.usermenu > summary { display: flex; align-items: center; gap: 8px; padding: 4px 6px; border-radius: 6px; font-weight: 600; }
.usermenu > summary:hover { background: var(--hover); }
.avatar { display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 50%; background: #7d5ba6; color: #fff; font-size: 11px; font-weight: 700; flex: none; letter-spacing: .02em; }
.avatar.sm { width: 22px; height: 22px; font-size: 9.5px; }
.avatar.xs { width: 16px; height: 16px; font-size: 7.5px; }
.side-add { display: flex; align-items: center; gap: 8px; width: 100%; height: 36px; padding: 0 6px; border: 0; border-radius: 6px; background: none; color: var(--sel-text); font-weight: 600; text-align: left; }
.side-add:hover { background: var(--hover); }
.plus-dot { display: grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; background: var(--accent); color: #fff; }
.plus-dot .i { width: 16px; height: 16px; stroke-width: 2.4; }
.side-link { display: flex; align-items: center; gap: 8px; min-height: 34px; padding: 4px 6px; border-radius: 6px; color: var(--text); }
.side-link:hover { background: var(--hover); }
.side-link[aria-current="page"] { background: var(--sel-bg); color: var(--sel-text); }
.side-link > .i { color: var(--muted); }
.side-link[href="/"] > .i { color: var(--icon-inbox); }
.side-link[href="/today"] > .i { color: var(--icon-today); }
.side-link[href="/upcoming"] > .i { color: var(--icon-upcoming); }
.side-link[aria-current="page"] > .i { color: var(--sel-text); }
.side-link .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-link .count { margin-left: auto; color: var(--muted); font-size: 12px; }
.side-link .count.red { color: var(--due-overdue); }
.side-link .shared { color: var(--muted); display: inline-flex; }
.side-link .shared + .count { margin-left: auto; }
.side-link .shared:last-child { margin-left: auto; }
.hash { width: 24px; text-align: center; font-size: 17px; font-weight: 500; flex: none; color: var(--muted); }
.side-head { display: flex; align-items: center; justify-content: space-between; margin: 18px 0 2px; padding: 4px 6px; color: var(--text-2); font-weight: 700; font-size: 13px; }
.side-head .icon-btn { opacity: 0; }
.side-head:hover .icon-btn, .side-head .icon-btn:focus-visible { opacity: 1; }
@media (hover: none) { .side-head .icon-btn { opacity: 1; } }
.side-projects, .side-labels { list-style: none; margin: 0; padding: 0; }
.side-empty { padding: 4px 6px; color: var(--muted); font-size: 12px; }

/* --- menus (<details>) --- */
details.menu { position: relative; }
details.menu > summary { list-style: none; cursor: pointer; }
details.menu > summary::-webkit-details-marker { display: none; }
.menu-panel { position: absolute; z-index: 50; top: calc(100% + 4px); left: 0; min-width: 220px; background: var(--popover); border-radius: var(--radius); box-shadow: var(--shadow); padding: 6px; display: flex; flex-direction: column; }
.menu-panel.right { left: auto; right: 0; }
.menu-panel > a, .menu-panel > button { display: flex; align-items: center; gap: 10px; height: 34px; padding: 0 10px; border: 0; border-radius: 6px; background: none; text-align: left; font-size: 13px; white-space: nowrap; color: var(--text); }
.menu-panel > a:hover, .menu-panel > button:hover { background: var(--hover-2); }
.menu-panel .i { width: 18px; height: 18px; color: var(--muted); }
.menu-panel .muted { margin-left: auto; font-size: 12px; }
.menu-note { padding: 6px 10px 8px; font-size: 12px; color: var(--muted); border-bottom: 1px solid var(--line); margin-bottom: 4px; word-break: break-all; }
.badge { display: inline-block; padding: 1px 6px; border-radius: 4px; font-size: 11px; font-weight: 700; }
.badge.warn { background: var(--p2-bg); color: var(--p2); }

/* --- view header --- */
.view-head { display: flex; align-items: center; gap: 8px; min-height: 36px; margin-bottom: 16px; }
.view-head h1 { font-size: 20px; font-weight: 700; line-height: 1.25; flex: 1; min-width: 0; overflow-wrap: anywhere; }
.view-head h1 small { font-size: 12px; font-weight: 400; color: var(--muted); margin-left: 4px; }
.view-actions { display: flex; align-items: center; gap: 4px; }
.avatars { display: flex; border: 0; background: none; padding: 2px 4px; border-radius: 6px; }
.avatars:hover { background: var(--hover-2); }
.avatars .avatar { margin-left: -6px; box-shadow: 0 0 0 2px var(--bg); }
.avatars .avatar:first-child { margin-left: 0; }
.avatars .avatar:nth-child(2n) { background: #2a9d8f; }

/* --- groups & sections --- */
.group { margin-bottom: 24px; }
.group-head, .section-head { display: flex; align-items: center; gap: 8px; padding: 6px 0; border-bottom: 1px solid var(--line); }
.group-head h2, .section-head h2 { font-size: 14px; font-weight: 700; flex: 1; min-width: 0; }
.group.overdue .group-head h2 { color: var(--text); }
.section { margin-top: 28px; }
.section-head { gap: 4px; }
.section-head .count { color: var(--muted); font-size: 12px; margin-right: auto; }
.section-head h2 { flex: none; max-width: 70%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.section-head .collapse { width: 24px; height: 24px; display: grid; place-items: center; border: 0; background: none; color: var(--muted); padding: 0; margin-left: -28px; border-radius: 4px; }
.section-head .collapse:hover { background: var(--hover-2); }
.section-head .collapse .i { transition: transform .15s; }
.section.collapsed .collapse .i { transform: rotate(-90deg); }
.section.collapsed .section-body { display: none; }
.section-head details.menu summary { opacity: .0; }
.section-head:hover details.menu summary, .section-head details.menu[open] summary { opacity: 1; }
@media (hover: none) { .section-head details.menu summary { opacity: 1; } }
.add-section { margin-top: 20px; display: flex; flex-direction: column; gap: 8px; }
.add-section input { height: 36px; padding: 0 10px; border: 1px solid var(--line-2); border-radius: 6px; background: var(--bg); font-weight: 700; }
.add-section .row { display: flex; gap: 8px; }
.sections .section.sortable-ghost { opacity: .4; }

/* --- tasks --- */
.task-list { list-style: none; margin: 0; padding: 0; }
.task-list.sub { padding-left: 30px; }
.task { position: relative; }
.task-row { display: flex; align-items: flex-start; gap: 8px; padding: 9px 0 8px; border-bottom: 1px solid var(--line); position: relative; }
.task-list.sub .task:last-child > .task-row { border-bottom-color: var(--line); }
.check { flex: none; width: 18px; height: 18px; margin-top: 1px; border-radius: 50%; border: 1px solid var(--p4); background: none; padding: 0; display: grid; place-items: center; color: transparent; position: relative; }
.check::before { content: ""; position: absolute; inset: -10px; } /* a bigger touch target */
.check .i { width: 12px; height: 12px; stroke-width: 2.6; }
.check:hover .i, .check:focus-visible .i { color: var(--p4); }
.p1 > .task-row .check, .p1 > .check, .detail-title-row.p1 .check { border: 2px solid var(--p1); background: var(--p1-bg); }
.p2 > .task-row .check, .detail-title-row.p2 .check { border: 2px solid var(--p2); background: var(--p2-bg); }
.p3 > .task-row .check, .detail-title-row.p3 .check { border: 2px solid var(--p3); background: var(--p3-bg); }
.p1 > .task-row .check:hover .i, .detail-title-row.p1 .check:hover .i { color: var(--p1); }
.p2 > .task-row .check:hover .i, .detail-title-row.p2 .check:hover .i { color: var(--p2); }
.p3 > .task-row .check:hover .i, .detail-title-row.p3 .check:hover .i { color: var(--p3); }
.task.done > .task-row .check, .detail-title-row.done .check, .task.checking > .task-row .check { background: var(--p4); border-color: var(--p4); }
.task.done > .task-row .check .i, .detail-title-row.done .check .i, .task.checking > .task-row .check .i { color: #fff; }
.task.p1.checking > .task-row .check { background: var(--p1); border-color: var(--p1); }
.task.p2.checking > .task-row .check { background: var(--p2); border-color: var(--p2); }
.task.p3.checking > .task-row .check { background: var(--p3); border-color: var(--p3); }
.task.checking > .task-row .task-title, .task.done > .task-row .task-title { text-decoration: line-through; color: var(--muted); }
.task.checking > .task-row { transition: opacity .3s .1s; opacity: .45; }
.task-body { flex: 1; min-width: 0; cursor: pointer; outline: none; }
.task-title { overflow-wrap: anywhere; line-height: 20px; }
.task-desc { color: var(--text-2); font-size: 12px; line-height: 17px; margin-top: 1px; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical; white-space: pre-line; }
.task-meta { display: flex; flex-wrap: wrap; align-items: center; column-gap: 10px; row-gap: 2px; margin-top: 3px; font-size: 12px; color: var(--muted); }
.task-meta > span { display: inline-flex; align-items: center; gap: 3px; min-width: 0; }
.task-meta .parent { max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: inline-block; }
.task-meta .parent .i { vertical-align: -2px; margin-right: 3px; }
.due.overdue { color: var(--due-overdue); }
.due.today { color: var(--due-today); }
.due.tomorrow { color: var(--due-tomorrow); }
.due.week { color: var(--due-week); }
.due.later { color: var(--due-later); }
.task-project { flex: none; display: inline-flex; align-items: center; gap: 2px; font-size: 12px; color: var(--muted); max-width: 30%; margin-top: 2px; align-self: flex-end; }
.task-project > span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.task-project .hash { width: 14px; font-size: 13px; }
.task-project .i { width: 14px; height: 14px; }
a.task-project:hover { color: var(--text); }
.grip { position: absolute; left: -26px; top: 7px; width: 24px; height: 24px; display: grid; place-items: center; color: var(--muted); cursor: grab; opacity: 0; }
.grip .i { width: 16px; height: 16px; }
.task-row:hover > .grip { opacity: 1; }
.task.sortable-ghost > .task-row { background: var(--hover-2); opacity: .5; }
.task.sortable-chosen > .task-row { background: var(--bg); }
.task.sortable-drag > .task-row { box-shadow: var(--shadow); border-radius: 6px; background: var(--bg); }
@media (hover: hover) { .task-row:hover { background: linear-gradient(var(--bg), var(--bg)); } }

/* --- add task --- */
.adder { margin-top: 2px; }
.add-btn { display: flex; align-items: center; gap: 8px; width: 100%; height: 36px; padding: 0; border: 0; background: none; color: var(--muted); text-align: left; }
.add-btn .plus { width: 18px; height: 18px; display: grid; place-items: center; border-radius: 50%; color: var(--accent); }
.add-btn .plus .i { width: 18px; height: 18px; stroke-width: 1.8; }
.add-btn:hover { color: var(--accent); }
.add-btn:hover .plus { background: var(--accent); color: #fff; }
.add-btn:hover .plus .i { width: 14px; height: 14px; stroke-width: 2.4; }
.add-form { border: 1px solid var(--line-2); border-radius: var(--radius); background: var(--bg); }
.add-form.inline { margin: 8px 0; }
.add-form:focus-within { border-color: var(--muted); }
.add-fields { padding: 10px 10px 6px; }
.add-title { display: block; width: 100%; border: 0; outline: none; background: none; padding: 2px 0; font-size: 15px; font-weight: 600; }
.add-title::placeholder { font-weight: 600; color: var(--muted); }
.add-desc { display: block; width: 100%; border: 0; outline: none; background: none; padding: 2px 0; resize: none; font-size: 13px; color: var(--text); min-height: 22px; max-height: 200px; }
.add-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; padding-top: 8px; }
.add-foot { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-top: 1px solid var(--line-2); }
.add-foot .hint { color: var(--muted); font-size: 12px; }
.chip { display: inline-flex; align-items: center; gap: 5px; height: 28px; padding: 0 8px; border: 1px solid var(--line-2); border-radius: 6px; background: none; color: var(--text-2); font-size: 13px; white-space: nowrap; max-width: 100%; }
.chip.sm { height: 24px; font-size: 12px; padding: 0 7px; }
.chip > span { overflow: hidden; text-overflow: ellipsis; }
.chip .i { width: 15px; height: 15px; }
.chip .i.xs { width: 14px; height: 14px; }
.chip:hover, details[open] > .chip { background: var(--hover-2); }
.chip.set.overdue { color: var(--due-overdue); }
.chip.set.today { color: var(--due-today); }
.chip.set.tomorrow { color: var(--due-tomorrow); }
.chip.set.week { color: var(--due-week); }
.chip.set.later { color: var(--text-2); }
.chip.prio.p1 .i, .menu-panel .prio.p1 .i:first-child { color: var(--p1); }
.chip.prio.p2 .i, .menu-panel .prio.p2 .i:first-child { color: var(--p2); }
.chip.prio.p3 .i, .menu-panel .prio.p3 .i:first-child { color: var(--p3); }
.chip.label { color: var(--text-2); }
.chip-menu > summary { list-style: none; }
.chip-x { display: inline-grid; place-items: center; width: 18px; height: 18px; border: 0; padding: 0; margin-right: -4px; border-radius: 4px; background: none; color: var(--muted); }
.chip-x:hover { background: var(--line-2); color: var(--text); }
.chip-x .i { width: 13px; height: 13px; stroke-width: 2.2; }
.chip-x.solo { width: 22px; height: 22px; margin: 0 2px 0 -4px; }
.project-pick { position: relative; cursor: pointer; }
.project-pick .hash { width: auto; font-size: 15px; }
.project-pick select { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; font-size: 16px; }
.date-panel { min-width: 250px; }
.date-panel > button .muted { margin-left: auto; }
.date-fields { display: grid; gap: 8px; padding: 8px 10px 6px; border-top: 1px solid var(--line); margin-top: 4px; }
.date-fields label { display: grid; grid-template-columns: 56px 1fr; align-items: center; font-size: 12px; color: var(--muted); gap: 6px; }
.date-fields input, .date-fields select { height: 32px; border: 1px solid var(--line-2); border-radius: 6px; background: var(--bg); padding: 0 8px; min-width: 0; width: 100%; }

/* --- forms --- */
.field { margin-bottom: 14px; }
.field label, .field .label { display: block; font-weight: 600; font-size: 13px; margin-bottom: 6px; }
.field input:not([type=radio]), .inline-form input, .copy-row input { width: 100%; height: 38px; padding: 0 10px; border: 1px solid var(--line-2); border-radius: 6px; background: var(--bg); outline: none; }
.field input:focus, .inline-form input:focus { border-color: var(--muted); }
.hint { color: var(--muted); font-size: 12px; margin: 0 0 8px; }
/* iOS gives date inputs an intrinsic width that ignores width: 100%, and once
   unstyled it top-aligns the value, so centre it with the line height. */
input[type=date], input[type=time] { -webkit-appearance: none; appearance: none; display: block; text-align: left; line-height: 30px; }
input[type=date]::-webkit-date-and-time-value, input[type=time]::-webkit-date-and-time-value { text-align: left; margin: 0; line-height: inherit; }
/* iOS zooms into any field whose text is under 16px when it is focused. */
@media (pointer: coarse) { input, select, textarea { font-size: 16px !important; } }
.swatches { display: grid; grid-template-columns: repeat(10, 1fr); gap: 6px; }
.swatch { display: block; cursor: pointer; }
.swatch input { position: absolute; opacity: 0; pointer-events: none; }
.swatch span { display: block; aspect-ratio: 1; border-radius: 50%; box-shadow: inset 0 0 0 2px transparent; transition: transform .1s; }
.swatch input:checked + span { box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px var(--text); }
.swatch input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 3px; }
.inline-form { display: flex; gap: 8px; margin-top: 12px; }
.alert { padding: 10px 12px; border-radius: 8px; margin: 10px 0; font-size: 13px; }
.alert.error { background: var(--p1-bg); color: var(--p1); }
.alert.ok { background: rgba(5, 133, 39, .1); }
.alert p { margin: 0 0 8px; }
.copy-row { display: flex; gap: 8px; }
.copy-row input { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }

/* --- dialog --- */
/* dvh rather than vh: on iOS 100vh is the viewport with the browser bars
   hidden, so a tall dialog would overflow (and be centred off) the visible area. */
dialog#modal {
  border: 0; padding: 0; border-radius: 12px; width: min(560px, calc(100vw - 24px)); background: var(--bg); color: var(--text); box-shadow: var(--shadow-lg);
  max-height: calc(100vh - 48px);
  max-height: calc(100dvh - 24px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
  overscroll-behavior: contain;
  margin-top: 13vh;
}
dialog#modal:has(.detail) { width: min(880px, calc(100vw - 48px)); margin-top: 6vh; height: min(720px, calc(100dvh - 12vh)); }
dialog#modal:has(.add-form.quick) { overflow: visible; }
/* Overhang the viewport so the backdrop also dims the page under Safari's
   floating toolbar and the status bar. */
dialog#modal::backdrop { background: rgba(0, 0, 0, .45); top: -50vh; bottom: -50vh; }
html:has(dialog#modal[open]) { overflow: hidden; }
#modal-body > .add-form { border: 0; }
.dialog-form { padding: 18px 20px 20px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 14px; }
.modal-head h2 { font-size: 17px; overflow-wrap: anywhere; }
.modal-foot { display: flex; gap: 8px; align-items: center; margin-top: 18px; }
.small-head { font-size: 13px; margin: 18px 0 6px; }
.people { list-style: none; margin: 0; padding: 0; }
.people li { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.people .avatar { width: 32px; height: 32px; font-size: 12px; }
.people li > div { min-width: 0; overflow-wrap: anywhere; }

/* --- task detail --- */
.detail { display: flex; flex-direction: column; height: 100%; }
.detail-head { display: flex; align-items: center; gap: 4px; padding: 10px 12px 10px 18px; border-bottom: 1px solid var(--line); flex: none; }
.crumbs { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text-2); min-width: 0; }
.crumbs a { display: inline-flex; align-items: center; gap: 2px; padding: 2px 6px 2px 2px; border-radius: 4px; white-space: nowrap; }
.crumbs a:hover { background: var(--hover-2); }
.crumbs .hash { width: 18px; }
.crumbs .i { width: 16px; height: 16px; margin: 0 4px; color: var(--icon-inbox); }
.crumbs .link-btn { color: var(--text-2); font-weight: 400; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.crumbs .sep { color: var(--muted); }
.detail-grid { display: grid; grid-template-columns: 1fr 270px; flex: 1; min-height: 0; }
.detail-main { padding: 16px 22px 28px; overflow-y: auto; overscroll-behavior: contain; }
.detail-title-row { display: flex; align-items: flex-start; gap: 10px; }
.detail-title-row .check { margin-top: 5px; width: 20px; height: 20px; }
.detail-title { flex: 1; border: 1px solid transparent; border-radius: 6px; padding: 2px 6px; margin-left: -6px; font-size: 20px; font-weight: 700; line-height: 1.35; resize: none; background: none; outline: none; overflow: hidden; }
.detail-title-row.done .detail-title { text-decoration: line-through; color: var(--muted); }
.detail-desc { display: block; width: calc(100% - 24px); margin: 4px 0 0 24px; border: 1px solid transparent; border-radius: 6px; padding: 4px 6px; font-size: 14px; resize: none; background: none; outline: none; min-height: 34px; overflow: hidden; color: var(--text); }
.detail-title:hover, .detail-desc:hover { border-color: var(--line-2); }
.detail-title:focus, .detail-desc:focus { border-color: var(--muted); }
.detail-side { background: var(--side); padding: 14px 16px 20px; overflow-y: auto; border-left: 1px solid var(--line); }
.prop { display: block; padding: 8px 0 10px; border-bottom: 1px solid var(--line); }
.prop-name { display: block; font-size: 12px; font-weight: 600; color: var(--text-2); margin-bottom: 5px; }
.prop select, .prop input[type=date], .prop input[type=time] { width: 100%; height: 32px; border: 1px solid transparent; border-radius: 6px; background: transparent; padding: 0 6px; margin-left: -6px; width: calc(100% + 6px); }
.prop select:hover, .prop input:hover, .prop select:focus, .prop input:focus { border-color: var(--line-2); background: var(--bg); outline: none; }
.date-row { display: flex; align-items: center; gap: 4px; }
.date-row input { flex: 1; }
.due-input.overdue { color: var(--due-overdue); } .due-input.today { color: var(--due-today); } .due-input.tomorrow { color: var(--due-tomorrow); } .due-input.week { color: var(--due-week); }
.quick-dates { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.prio-select.p1 { color: var(--p1); } .prio-select.p2 { color: var(--p2); } .prio-select.p3 { color: var(--p3); }
.labels-edit { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
.label-input { flex: 1; min-width: 90px; height: 28px; border: 1px dashed var(--line-2); border-radius: 6px; background: none; padding: 0 8px; outline: none; font-size: 13px; }
.label-input:focus { border-style: solid; border-color: var(--muted); background: var(--bg); }
.created { margin: 14px 0 0; }
.subtasks, .comments { margin: 22px 0 0 24px; }
.subtasks h3, .comments h3 { font-size: 13px; font-weight: 700; padding-bottom: 6px; border-bottom: 1px solid var(--line); }
.subtasks .task-row .grip { display: none; }
.comment { display: flex; gap: 10px; padding: 10px 0; }
.comment-body { flex: 1; min-width: 0; }
.comment-body header { display: flex; align-items: baseline; gap: 8px; font-size: 13px; }
.comment-body header .link-btn { margin-left: auto; }
.comment-text { white-space: pre-wrap; overflow-wrap: anywhere; margin-top: 2px; }
.comment-text a { color: var(--accent); text-decoration: underline; }
.comment-form { display: flex; gap: 8px; align-items: flex-end; margin-top: 10px; }
.comment-form textarea { flex: 1; min-height: 36px; max-height: 200px; padding: 7px 10px; border: 1px solid var(--line-2); border-radius: 8px; resize: none; background: var(--bg); outline: none; }
.comment-form textarea:focus { border-color: var(--muted); }

/* --- empty states, search, browse, settings --- */
.empty-state { text-align: center; color: var(--muted); padding: 56px 20px; max-width: 360px; margin: 0 auto; }
.empty-state .i { width: 56px; height: 56px; stroke-width: 1.1; color: var(--line-2); }
.empty-state p { margin: 10px 0 0; }
.empty-state.small { padding: 24px 10px; }
.search { position: relative; margin-bottom: 14px; }
.search > .i { position: absolute; left: 10px; top: 50%; translate: 0 -50%; width: 18px; height: 18px; color: var(--muted); }
.search input { width: 100%; height: 40px; padding: 0 12px 0 36px; border: 1px solid var(--line-2); border-radius: 8px; background: var(--bg); outline: none; }
.search input:focus { border-color: var(--muted); }
.browse-list { background: var(--card); border-radius: 12px; overflow: hidden; margin-bottom: 16px; border: 1px solid var(--line); }
.browse-row { display: flex; align-items: center; gap: 12px; min-height: 46px; padding: 0 14px; border-bottom: 1px solid var(--line); }
.browse-row:last-child { border-bottom: 0; }
.browse-row:active { background: var(--hover-2); }
.browse-row > span:nth-child(2) { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.browse-row .count { color: var(--muted); font-size: 13px; }
.browse-row .shared { color: var(--muted); display: inline-flex; }
.browse-row > .i:first-child { color: var(--muted); }
.browse-row[href="/"] > .i:first-child { color: var(--icon-inbox); }
.browse-row[href="/today"] > .i:first-child { color: var(--icon-today); }
.browse-row[href="/upcoming"] > .i:first-child { color: var(--icon-upcoming); }
.browse-row > .i:last-child:not(:first-child) { color: var(--muted); width: 18px; }
.browse-list > p { margin: 0; padding: 12px 14px; }
.browse-head { display: flex; align-items: center; justify-content: space-between; margin: 20px 4px 8px; }
.browse-head h2 { font-size: 15px; }
.card { border: 1px solid var(--line); border-radius: 12px; padding: 16px 18px; margin-bottom: 16px; background: var(--card); }
.card h2 { font-size: 15px; margin-bottom: 10px; }
.card p { margin: 0 0 10px; }
.theme-pick { display: flex; gap: 8px; flex-wrap: wrap; }
.theme-pick label { display: flex; align-items: center; gap: 6px; padding: 8px 12px; border: 1px solid var(--line-2); border-radius: 8px; cursor: pointer; }
.theme-pick label:has(input:checked) { border-color: var(--accent); background: var(--sel-bg); color: var(--sel-text); }
.theme-pick input { accent-color: var(--accent); margin: 0; }
.keys { list-style: none; margin: 0; padding: 0; }
.keys li { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.steps { padding-left: 20px; margin: 0; }
.steps li { margin-bottom: 6px; }

/* --- login --- */
.auth-page { display: grid; place-items: center; min-height: 100vh; min-height: 100dvh; padding: 24px; background: var(--side); }
.auth-card { width: min(380px, 100%); background: var(--bg); border-radius: 16px; padding: 32px 28px; box-shadow: var(--shadow); text-align: center; }
.auth-card p { margin: 12px 0 22px; }
.brand { display: inline-flex; align-items: center; gap: 8px; font-weight: 800; font-size: 20px; letter-spacing: -.02em; color: var(--accent); }
.brand-mark { width: 30px; height: 30px; }
.brand.big { font-size: 30px; }
.brand.big .brand-mark { width: 44px; height: 44px; }

/* --- toast --- */
#toast { position: fixed; bottom: calc(24px + env(safe-area-inset-bottom)); left: 24px; display: flex; align-items: center; gap: 16px; background: var(--toast-bg); color: var(--toast-text); padding: 10px 12px 10px 16px; border-radius: 8px; font-size: 13px; opacity: 0; transform: translateY(8px); transition: opacity .2s, transform .2s; pointer-events: none; z-index: 100; max-width: calc(100vw - 32px); box-shadow: var(--shadow); }
#toast.show { opacity: 1; transform: none; pointer-events: auto; }
.toast-undo { border: 0; background: none; color: #ff9a8f; font-weight: 700; padding: 4px 6px; border-radius: 4px; }
:root[data-theme="dark"] .toast-undo { color: var(--accent); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .toast-undo { color: var(--accent); } }

/* --- phone navigation (hidden on desktop) --- */
.tabbar, .fab { display: none; }

@media (max-width: 767px) {
  .sidebar { display: none; }
  .hide-sm { display: none !important; }
  .view { padding: calc(14px + env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) calc(var(--tabbar-h) + 110px + env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left)); }
  .view-head { margin-bottom: 10px; }
  .view-head h1 { font-size: 28px; letter-spacing: -.01em; }
  .view-head h1 small { display: block; margin: 2px 0 0; font-size: 13px; }
  body { font-size: 15px; }
  .task-row { padding: 11px 0 10px; gap: 10px; }
  .task-title { font-size: 15px; line-height: 21px; }
  .check { width: 20px; height: 20px; }
  .task-meta { font-size: 12.5px; }
  .grip { display: none; }
  .task-project { max-width: 35%; }
  .section-head .collapse { margin-left: -6px; }
  .add-btn { height: 42px; }

  .tabbar { display: flex; position: fixed; z-index: 40; left: 0; right: 0; bottom: 0; height: calc(var(--tabbar-h) + env(safe-area-inset-bottom)); padding: 0 env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left); background: color-mix(in srgb, var(--bg) 92%, transparent); -webkit-backdrop-filter: saturate(180%) blur(16px); backdrop-filter: saturate(180%) blur(16px); border-top: 1px solid var(--line); }
  .tabbar a { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; font-size: 10.5px; font-weight: 500; color: var(--muted); }
  .tabbar a .i { width: 25px; height: 25px; }
  .tabbar a[aria-current="page"] { color: var(--accent); }
  .fab { display: grid; place-items: center; position: fixed; z-index: 41; right: max(18px, env(safe-area-inset-right)); bottom: calc(var(--tabbar-h) + 18px + env(safe-area-inset-bottom)); width: 56px; height: 56px; border-radius: 50%; border: 0; background: var(--accent); color: #fff; box-shadow: 0 4px 14px rgba(220, 76, 62, .45); }
  .fab .i { width: 28px; height: 28px; stroke-width: 2.2; }
  .fab:active { transform: scale(.94); }
  #toast { left: 16px; right: 16px; justify-content: space-between; bottom: calc(var(--tabbar-h) + 14px + env(safe-area-inset-bottom)); }

  /* The add dialog sits at the top, where the keyboard can't cover it. */
  dialog#modal { width: calc(100vw - 16px); margin-top: calc(8px + env(safe-area-inset-top)); border-radius: 14px; }
  dialog#modal:has(.add-form.quick) { overflow: visible; }
  /* The task opens as a full-height sheet. */
  dialog#modal:has(.detail) { width: 100vw; max-width: 100vw; height: 100dvh; max-height: 100dvh; margin: 0; border-radius: 0; }
  .detail-head { padding-top: calc(8px + env(safe-area-inset-top)); padding-left: max(14px, env(safe-area-inset-left)); padding-right: max(10px, env(safe-area-inset-right)); }
  .detail-grid { display: block; overflow-y: auto; overscroll-behavior: contain; padding-bottom: env(safe-area-inset-bottom); }
  .detail-main { overflow: visible; padding: 14px 16px 8px; }
  .detail-side { border-left: 0; border-top: 1px solid var(--line); padding: 6px 16px 24px; overflow: visible; }
  .detail-title { font-size: 19px; }
  .subtasks, .comments { margin-left: 0; }
  .detail-desc { margin-left: 24px; }
  .menu-panel { min-width: 200px; }
  .chip { height: 32px; }
  .swatches { grid-template-columns: repeat(5, 1fr); gap: 10px; }
  .add-foot .btn { height: 36px; }
}

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