:root {
  color-scheme: light dark;
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #f0f2f5;
  --text: #15181d;
  --muted: #5b6370;
  --border: #e1e4ea;
  --accent: #062f50;
  --accent-text: #ffffff;
  --link: #1a6c80;
  --danger: #b91c1c;
  --shadow: 0 8px 32px rgba(16, 24, 40, .16);
  /* Priority colors are the same in both themes. Priority 5 has no color at all. */
  --p1: #ef8f8a;
  --p2: #f6bd7e;
  --p3: #8fb8ef;
  --p4: #8ccb9b;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1216;
    --surface: #171b21;
    --surface-2: #20252d;
    --text: #eef1f5;
    --muted: #9aa3b0;
    --border: #2a313b;
    --accent: #6aa7dc;
    --accent-text: #0b1a27;
    --link: #8bbde6;
    --danger: #f87171;
    --shadow: 0 8px 32px rgba(0, 0, 0, .5);
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body, #app { height: 100%; }
/* Stops iPhone Safari enlarging text on its own when the phone is turned sideways. */
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; font-size: 16px; }
/* Every text size is in rem, so this one value is the account's text size setting. Wide screens only:
   phones stay at 16px so text boxes never drop under the size that makes iPhone Safari zoom. */
@media (min-width: 801px) {
  html { font-size: calc(16px * var(--text-scale, 1)); }
}
.text-size { display: flex; align-items: center; gap: 4px; padding: 0 8px 6px; font-size: 0.75rem; color: var(--muted); }
.text-size .icon-btn { width: 24px; height: 22px; font-size: 0.875rem; border: 1px solid var(--border); }
.text-size .icon-btn:disabled { opacity: .35; cursor: default; }
.text-size-value { min-width: 36px; text-align: center; }
.text-size-label { margin-right: 2px; }
.profile .text-size { padding: 0; font-size: 0.875rem; }
@media (max-width: 800px) {
  .text-size, .text-size-field { display: none !important; }
}
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 0.875rem/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
h1, h2, h3 { margin: 0; line-height: 1.25; }
a { color: var(--link); }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--link); outline-offset: 1px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 34px; padding: 5px 12px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 6px;
  cursor: pointer; white-space: nowrap;
}
.btn:hover { background: var(--surface-2); }
.btn:disabled { opacity: .6; cursor: default; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); font-weight: 600; }
.btn-primary:hover { background: var(--accent); filter: brightness(1.2); }
.btn-danger { color: var(--danger); }
.btn-small { min-height: 28px; padding: 2px 8px; font-size: 0.8125rem; }
.link-btn { background: none; border: 0; padding: 0; color: var(--muted); cursor: pointer; font-size: 0.75rem; text-decoration: none; }
.link-btn:hover { color: var(--text); text-decoration: underline; }

.field { display: block; margin-bottom: 14px; }
.field > span { display: block; margin-bottom: 4px; font-weight: 600; font-size: 0.8125rem; }
.field small { display: block; margin-top: 4px; color: var(--muted); }
.input {
  width: 100%; min-height: 36px; padding: 6px 10px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 6px;
}
textarea.input { resize: vertical; }
.error { min-height: 20px; margin: 0 0 10px; color: var(--danger); font-size: 0.8125rem; }
.muted { color: var(--muted); }
.noscript { padding: 24px; text-align: center; }

/* Sign-in, setup and forced password screens */
.auth { min-height: 100%; display: flex; align-items: center; justify-content: center; padding: 16px; }
.auth-card {
  width: 100%; max-width: 380px; padding: 28px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
}
.auth-card h1 { font-size: 1.375rem; margin-bottom: 4px; }
.auth-card p.lead { margin: 0 0 20px; color: var(--muted); }
.auth-card .btn { width: 100%; }

/* App frame */
.shell { height: 100%; display: grid; grid-template-columns: 250px minmax(0, 1fr); }
.sidebar {
  display: flex; flex-direction: column; min-height: 0;
  background: var(--surface); border-right: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 9px; padding: 12px 8px 12px 16px; font-weight: 700; font-size: 0.9375rem; }
.brand img { width: 22px; height: 22px; flex: none; }
.side-search { margin: 0 8px 6px; color: var(--muted); }
.side-icon { width: 18px; height: 18px; flex: none; }
.side-initial {
  display: none; width: 28px; height: 28px; flex: none; align-items: center; justify-content: center;
  border-radius: 6px; background: var(--surface-2); font-size: 0.8125rem; font-weight: 700;
}
.side-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 6px 8px 6px 16px; color: var(--muted); font-size: 0.75rem; font-weight: 600;
}
.icon-btn {
  width: 28px; height: 28px; padding: 0;
  display: inline-flex; align-items: center; justify-content: center;
  background: none; border: 0; border-radius: 6px; color: var(--muted); cursor: pointer; font-size: 1.125rem; line-height: 1;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.side-lists { flex: 1; min-height: 0; overflow-y: auto; margin: 0; padding: 0 8px; list-style: none; }
.side-link {
  display: flex; align-items: center; gap: 8px; padding: 6px 8px;
  border-radius: 6px; color: inherit; text-decoration: none;
}
.side-link:hover { background: var(--surface-2); }
.side-link.active { background: var(--surface-2); font-weight: 600; }
.side-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-count { color: var(--muted); font-size: 0.75rem; font-weight: 400; }
.side-foot { padding: 8px; border-top: 1px solid var(--border); }
.side-user { font-size: 0.8125rem; }
.side-user strong { display: block; overflow: hidden; text-overflow: ellipsis; }
.side-user small { display: block; overflow: hidden; text-overflow: ellipsis; color: var(--muted); font-size: 0.75rem; }
.side-foot .link-row { display: flex; flex-wrap: wrap; gap: 12px; padding: 2px 8px 6px; }
.shell.collapsed .text-size { display: none; }
.side-empty { padding: 4px 8px; color: var(--muted); font-size: 0.8125rem; }

.main { min-width: 0; height: 100%; overflow-y: auto; padding: 20px 24px 60px; }
.page-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.page-head h1 { font-size: 1.25rem; min-width: 0; overflow-wrap: anywhere; }
.open-count { color: var(--muted); font-size: 0.875rem; white-space: nowrap; }
.refresh-btn { display: none; }
.refresh-btn.spinning { animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .refresh-btn.spinning { animation: none; opacity: .5; } }
.page-actions { display: flex; align-items: center; gap: 8px; margin-left: auto; flex-wrap: wrap; }
.menu-toggle { display: none; }
.scrim { display: none; }
.empty { padding: 56px 16px; text-align: center; color: var(--muted); }
.empty h2 { color: var(--text); font-size: 1.0625rem; margin-bottom: 6px; }
.empty .btn { margin-top: 14px; }

/* Task table */
.add-task { display: flex; gap: 8px; margin-bottom: 12px; }
.add-task .input { flex: 1; min-width: 0; }
.table-wrap { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; }
.tasks { width: 100%; border-collapse: collapse; table-layout: fixed; }
.tasks th {
  padding: 8px 10px; text-align: left; border-bottom: 1px solid var(--border);
  color: var(--muted); font-size: 0.75rem; font-weight: 600;
}
.tasks td { padding: 7px 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.tasks tbody tr:last-child td { border-bottom: 0; }
.tasks tbody tr { cursor: pointer; }
.tasks tbody tr:hover { background: var(--surface-2); }
.tasks tbody tr.open { background: var(--surface-2); }
.col-sel { width: 30px; padding-right: 0 !important; }
.col-check { width: 34px; padding-right: 2px !important; }
/* Square checkbox selects a row. Round one marks it done, so the two never look alike. */
.sel { width: 15px; height: 15px; margin: 0; display: block; cursor: pointer; accent-color: var(--link); }
.tasks tbody tr.selected { background: var(--surface-2); box-shadow: inset 3px 0 0 var(--link); }
.check {
  appearance: none; -webkit-appearance: none;
  border: 2px solid var(--muted); border-radius: 50%; background: var(--surface);
}
.check:checked { background: var(--accent); border-color: var(--accent); box-shadow: inset 0 0 0 2px var(--surface); }
.group-row th { padding: 0 !important; background: var(--surface-2); }
.group-head { display: flex; align-items: center; gap: 2px; padding-right: 6px; }
.group-btn {
  flex: 1; min-width: 0; padding: 7px 10px; background: none; border: 0;
  text-align: left; font-size: 0.8125rem; font-weight: 700; color: var(--text); cursor: pointer;
}
.group-move { width: 26px; height: 26px; font-size: 0.875rem; }
.group-move:disabled { opacity: .3; cursor: default; background: none; }
.group-count { color: var(--muted); font-weight: 400; }
.title-wrap { display: flex; align-items: flex-start; gap: 4px; min-width: 0; }
.title-text { min-width: 0; flex: 1; }
.expander { flex: none; width: 20px; height: 22px; padding: 0; background: none; border: 0; color: var(--muted); cursor: pointer; }
.expander:hover { color: var(--text); }
.sub-row .title-wrap { padding-left: 24px; }
.sub-row .task-title { font-weight: 400; }
.task-meta { display: flex; flex-wrap: wrap; gap: 4px; }
.task-meta:not(:empty) { margin-top: 2px; }
tr.archived { opacity: .65; }
.batch-bar {
  position: sticky; top: 0; z-index: 5; display: flex; flex-wrap: wrap; align-items: center; gap: 6px;
  margin-bottom: 10px; padding: 8px 10px;
  background: var(--surface); border: 1px solid var(--link); border-radius: 8px;
}
.batch-count { margin-right: 6px; font-size: 0.8125rem; }
.add-type { flex: none; width: auto; }
.recur-row { display: flex; align-items: center; gap: 6px; margin: 6px 0 12px; font-size: 0.8125rem; }
.recur-row .recur-n { width: 68px; flex: none; }
.recur-row .recur-unit { width: auto; flex: none; }
.drawer .recur-row { margin-bottom: 0; }
.last-done { display: block; margin-top: 4px; }
.parent-link { display: inline-block; margin-bottom: 6px; font-size: 0.8125rem; text-decoration: none; }
.parent-link:hover { text-decoration: underline; }
.subtask { display: flex; align-items: center; gap: 8px; padding: 5px 0; border-bottom: 1px solid var(--border); }
.subtask .check { flex: none; }
.subtask-title { flex: 1; min-width: 0; color: inherit; text-decoration: none; overflow-wrap: anywhere; }
.subtask-title:hover { text-decoration: underline; }
.subtask.done .subtask-title { color: var(--muted); text-decoration: line-through; }
.due-text { flex: none; font-size: 0.75rem; color: var(--muted); }
.due-text.overdue { color: var(--danger); font-weight: 600; }
.due-text.today { font-weight: 700; }
.subtask-form { margin-top: 8px; }
.table-foot { display: flex; flex-wrap: wrap; gap: 16px; }
.col-pri { width: 64px; }
.col-due { width: 120px; }
.col-comment { width: 38%; }
.tasks-wrap { overflow-x: auto; }
.tasks th[data-col] { position: relative; white-space: nowrap; }
.col-resize {
  position: absolute; top: 0; right: -5px; bottom: 0; z-index: 2; width: 10px;
  cursor: col-resize; touch-action: none;
}
.col-resize::after {
  content: ''; position: absolute; top: 25%; bottom: 25%; left: 4px; width: 2px; border-radius: 1px; background: var(--border);
}
.col-resize:hover::after, .col-resize:focus-visible::after { top: 0; bottom: 0; background: var(--link); }
body.resizing-column, body.resizing-column * { cursor: col-resize !important; user-select: none; }
.sort-btn { background: none; border: 0; padding: 0; color: inherit; font-weight: inherit; cursor: pointer; }
.sort-btn:hover { color: var(--text); }
.sort-btn[aria-sort-active="true"] { color: var(--text); }
.check { width: 17px; height: 17px; margin: 0; display: block; cursor: pointer; accent-color: var(--accent); }
.task-title { width: 100%; padding: 0; background: none; border: 0; font-weight: 500; text-align: left; cursor: pointer; overflow-wrap: anywhere; }
.task-title:hover { text-decoration: underline; }
tr.done .task-title { color: var(--muted); text-decoration: line-through; font-weight: 400; }

.pri { display: block; width: 34px; height: 18px; padding: 0; border: 0; border-radius: 9px; cursor: pointer; }
.pri:hover { filter: brightness(1.15); }
.p1 { background: var(--p1); }
.p2 { background: var(--p2); }
.p3 { background: var(--p3); }
.p4 { background: var(--p4); }
.p5 { background: transparent; box-shadow: inset 0 0 0 1.5px var(--border); }
.pri-pop {
  position: fixed; z-index: 45; display: flex; gap: 6px; padding: 8px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px; box-shadow: var(--shadow);
}
.pri-swatch { width: 28px; height: 22px; padding: 0; border: 0; border-radius: 6px; cursor: pointer; }
.pri-swatch.current { outline: 2px solid var(--text); outline-offset: 1px; }
.pri-swatch:hover { filter: brightness(1.15); }

/* Date label with an invisible native date input stretched over it, so the whole cell opens the picker. */
.due { position: relative; display: inline-flex; align-items: center; min-height: 26px; padding: 2px 6px; margin-left: -6px; border-radius: 6px; }
.due:hover { background: var(--surface); box-shadow: inset 0 0 0 1px var(--border); }
.due:focus-within { outline: 2px solid var(--link); outline-offset: 1px; }
.due input { position: absolute; inset: 0; width: 100%; height: 100%; padding: 0; border: 0; opacity: 0; cursor: pointer; }
.due input::-webkit-calendar-picker-indicator { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; padding: 0; cursor: pointer; }
.due.none { color: var(--muted); }
.due.today { font-weight: 700; }
.due.overdue { color: var(--danger); font-weight: 600; }
tr.done .due { color: var(--muted); font-weight: 400; }

.latest { display: block; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; color: var(--muted); font-size: 0.8125rem; }
.comment-pop {
  position: fixed; z-index: 40; width: min(420px, calc(100vw - 16px)); max-height: 60vh; overflow: hidden;
  padding: 10px 12px; background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
  box-shadow: var(--shadow); font-size: 0.8125rem; pointer-events: none;
}
.comment-pop-head { margin-bottom: 4px; color: var(--muted); font-size: 0.75rem; }
.comment-pop-head strong { color: var(--text); }
.comment-pop-body { white-space: pre-wrap; overflow-wrap: anywhere; }
.comment-pop-more { margin-top: 6px; color: var(--muted); font-size: 0.75rem; }
.comment-trigger {
  display: block; width: 100%; min-height: 26px; padding: 3px 6px; margin: -3px -6px;
  background: none; border: 0; border-radius: 6px; text-align: left; cursor: text;
}
.comment-trigger:hover { background: var(--surface); box-shadow: inset 0 0 0 1px var(--border); }
.comment-placeholder { color: var(--muted); font-size: 0.8125rem; }
@media (hover: hover) {
  .comment-placeholder { opacity: 0; }
  tr:hover .comment-placeholder, .comment-trigger:focus-visible .comment-placeholder { opacity: 1; }
}
.tasks td.cell-comment { cursor: text; }
.inline-comment { display: block; min-height: 54px; margin-top: 4px; font-size: 0.8125rem; }
.inline-comment:first-child { margin-top: 0; }
.comment-count { font-size: 0.75rem; color: var(--muted); }
.table-foot { padding: 10px 2px; }

/* Floating task window */
.task-overlay {
  position: fixed; inset: 0; z-index: 20; display: flex; align-items: center; justify-content: center;
  padding: 24px 16px; background: rgba(10, 14, 20, .5);
}
.drawer {
  width: min(720px, 100%); max-height: 100%; display: flex; flex-direction: column; overflow: hidden;
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow);
  outline: none;
}
.drawer-head { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-bottom: 1px solid var(--border); }
.drawer-head .save-state { margin-right: auto; color: var(--muted); font-size: 0.75rem; }
.drawer-body { flex: 1; min-height: 0; overflow-y: auto; padding: 16px 20px 24px; }
.title-input {
  width: 100%; padding: 4px 6px; margin: 0 0 12px -6px;
  background: none; border: 1px solid transparent; border-radius: 6px;
  font-size: 1.1875rem; font-weight: 600;
}
.title-input:hover, .title-input:focus { border-color: var(--border); }
.meta-row { display: flex; flex-wrap: wrap; gap: 20px; margin-bottom: 18px; }
.meta-label { display: block; margin-bottom: 4px; font-size: 0.75rem; font-weight: 600; color: var(--muted); }
.pri-group { display: flex; gap: 4px; border: 0; margin: 0; padding: 0; }
.pri-choice { position: relative; }
.pri-choice input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.pri-choice span {
  display: flex; align-items: center; justify-content: center;
  width: 34px; height: 30px; border-radius: 6px; font-weight: 700; font-size: 0.8125rem; opacity: .4;
}
.pri-choice input:checked + span { opacity: 1; box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--text); }
.pri-choice:hover span { opacity: 1; }
.pri-choice input:focus-visible + span { outline: 2px solid var(--link); outline-offset: 3px; }
.due-input { width: auto; min-width: 150px; }
.section-title { margin: 22px 0 8px; font-size: 0.8125rem; font-weight: 700; }

/* Rich text editor */
.rte { border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.rte:focus-within { border-color: var(--link); }
.rte-bar { display: flex; flex-wrap: wrap; gap: 2px; padding: 4px; background: var(--surface-2); border-bottom: 1px solid var(--border); }
.rte-btn {
  min-width: 30px; height: 28px; padding: 0 6px;
  background: none; border: 0; border-radius: 5px; cursor: pointer; font-size: 0.8125rem; color: var(--text);
}
.rte-btn:hover { background: var(--border); }
.rte-btn[aria-pressed="true"] { background: var(--accent); color: var(--accent-text); }
.rte-sep { width: 1px; margin: 4px 3px; background: var(--border); }
.rte-link { display: flex; gap: 6px; width: 100%; padding: 4px 2px 2px; }
.rte-link .input { flex: 1; min-width: 0; min-height: 28px; padding: 2px 8px; }
.rte-edit, .rich { overflow-wrap: anywhere; }
.rte-edit { min-height: 150px; max-height: 45vh; overflow-y: auto; padding: 10px 12px; outline: none; }
.rte-edit:empty::before { content: attr(data-placeholder); color: var(--muted); pointer-events: none; }
.rte-edit > :first-child { margin-top: 0; }
.rte-edit > :last-child { margin-bottom: 0; }
.rte-edit p { margin: 0 0 8px; }
.rte-edit h2 { margin: 14px 0 6px; font-size: 1.125rem; }
.rte-edit h3 { margin: 12px 0 4px; font-size: 0.9375rem; }
.rte-edit ul, .rte-edit ol { margin: 0 0 8px; padding-left: 24px; }
.rte-edit blockquote { margin: 0 0 8px; padding: 2px 12px; border-left: 3px solid var(--border); color: var(--muted); }
.rte-edit pre { margin: 0 0 8px; padding: 8px 10px; background: var(--surface-2); border-radius: 6px; white-space: pre-wrap; font: 0.8125rem/1.45 Consolas, Menlo, monospace; }
.rte-edit code { font: 0.8125rem Consolas, Menlo, monospace; }

/* Comments */
.comment { padding: 10px 0; border-bottom: 1px solid var(--border); }
.comment-head { display: flex; align-items: baseline; gap: 8px; margin-bottom: 2px; }
.comment-head strong { font-size: 0.8125rem; }
.comment-head time { color: var(--muted); font-size: 0.75rem; }
.comment-head .link-btn { margin-left: auto; }
.comment-body { white-space: pre-wrap; overflow-wrap: anywhere; }
.comment-form { margin-top: 12px; }
.comment-form .row { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 6px; }
.comment-form small { color: var(--muted); }

/* Dialogs */
dialog.modal {
  width: min(440px, calc(100% - 32px)); padding: 22px;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow);
}
dialog.modal::backdrop { background: rgba(10, 14, 20, .5); }
.modal h2 { font-size: 1.0625rem; margin-bottom: 12px; }
.modal p { margin: 0 0 14px; overflow-wrap: anywhere; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 6px; }
.member { display: flex; align-items: center; gap: 10px; padding: 7px 0; border-bottom: 1px solid var(--border); }
.member div { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.member small { display: block; color: var(--muted); }
.members { margin-bottom: 14px; }
.inline-form { display: flex; gap: 8px; }
.inline-form .input { flex: 1; min-width: 0; }
.input-row { display: flex; gap: 8px; }
.input-row .input { flex: 1; min-width: 0; }

/* Admin */
.users td, .users th { padding: 9px 10px; }
.users tbody tr { cursor: default; }
.users tbody tr:hover { background: none; }
.user-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.tag { display: inline-block; padding: 0 7px; border-radius: 10px; background: var(--surface-2); font-size: 0.75rem; color: var(--muted); }
.tag.warn { color: var(--danger); }

/* Search */
.search-input { display: block; max-width: 640px; margin-bottom: 14px; }
.result-count { margin: 0 0 8px; font-size: 0.8125rem; }
.result {
  display: flex; align-items: flex-start; gap: 12px; padding: 10px 12px;
  border-bottom: 1px solid var(--border); color: inherit; text-decoration: none;
}
.result:last-child { border-bottom: 0; }
.result:hover { background: var(--surface-2); }
.pri-chip { flex: none; display: inline-block; width: 26px; height: 14px; margin-top: 3px; border-radius: 7px; }
.result-body { flex: 1; min-width: 0; }
.result-title { display: block; font-weight: 500; overflow-wrap: anywhere; }
.result.done .result-title { color: var(--muted); text-decoration: line-through; }
.result-meta { display: block; color: var(--muted); font-size: 0.75rem; overflow-wrap: anywhere; }
.result-snippet { display: block; margin-top: 2px; color: var(--muted); font-size: 0.8125rem; overflow-wrap: anywhere; }
mark { background: #facc15; color: #1c1707; border-radius: 2px; }

/* Profile */
.profile { max-width: 480px; padding: 20px; }
.profile select.input { display: block; }
.profile-actions { display: flex; flex-wrap: wrap; gap: 8px; }

/* Minimized left menu (wide screens only: phones use the slide-in menu) */
@media (min-width: 801px) {
  .shell.collapsed { grid-template-columns: 56px minmax(0, 1fr); }
  .shell.collapsed .side-name,
  .shell.collapsed .side-count,
  .shell.collapsed .link-row,
  .shell.collapsed .brand img { display: none; }
  .shell.collapsed .side-initial { display: inline-flex; }
  .shell.collapsed .brand { justify-content: center; padding: 12px 0; }
  .shell.collapsed .side-head { justify-content: center; padding: 6px 0; }
  .shell.collapsed .side-link { justify-content: center; padding: 4px; }
  .shell.collapsed .side-search { margin: 0 8px 6px; padding: 9px 4px; }
  .shell.collapsed .side-link.active .side-initial { background: var(--accent); color: var(--accent-text); }
}
.collapse-toggle { margin-left: auto; }

.toast {
  position: fixed; left: 50%; bottom: 22px; z-index: 50; transform: translateX(-50%);
  max-width: calc(100% - 32px); padding: 9px 16px; border-radius: 8px;
  background: var(--text); color: var(--bg); box-shadow: var(--shadow);
}

@media (max-width: 800px) {
  .shell { display: block; }
  .sidebar {
    position: fixed; top: 0; bottom: 0; left: 0; z-index: 30; width: 270px;
    transform: translateX(-100%); transition: transform .15s;
  }
  .shell.nav-open .sidebar { transform: none; box-shadow: var(--shadow); }
  .shell.nav-open .scrim { display: block; position: fixed; inset: 0; z-index: 25; background: rgba(10, 14, 20, .5); }
  /* Slightly smaller text on phones. */
  body { font-size: 0.8125rem; }
  .page-head h1 { font-size: 1.125rem; }
  .open-count { font-size: 0.8125rem; }
  .btn-small { font-size: 0.75rem; }
  .latest, .comment-placeholder { font-size: 0.75rem; }
  .tag, .comment-count, .result-meta { font-size: 0.6875rem; }
  .group-btn { font-size: 0.75rem; }
  .title-input { font-size: 1.0625rem; }
  /* iPhone Safari zooms in on any text box under 16px when tapped, and stays zoomed. */
  input, select, textarea, .input, .rte-edit, .inline-comment { font-size: 1rem; }
  .menu-toggle { display: inline-flex; }
  .refresh-btn { display: inline-flex; width: 34px; height: 34px; margin-left: auto; font-size: 1.25rem; }
  .page-actions { flex-basis: 100%; margin-left: 0; }
  .collapse-toggle { display: none; }
  .main { padding: 12px 16px 60px; }
  .task-overlay { padding: 0; }
  .drawer { height: 100%; border: 0; border-radius: 0; }

  /* Rows become two-line cards: check, priority, date on one side of the title; comment underneath. */
  .tasks, .tasks tbody { display: block; }
  .tasks thead { display: none; }
  .tasks tbody tr {
    display: grid; grid-template-columns: 20px 24px 38px minmax(0, 1fr) auto; gap: 4px 6px; align-items: center;
    padding: 10px; border-bottom: 1px solid var(--border);
  }
  .tasks tbody tr:last-child { border-bottom: 0; }
  .tasks td { display: block; padding: 0; border: 0; min-width: 0; }
  .tasks td.cell-comment { grid-column: 1 / -1; }
  .tasks tbody tr.group-row { display: block; padding: 0; }
  .group-row th { display: block; }
  .col-sel, .col-check { width: auto; }
  .sub-row .title-wrap { padding-left: 10px; }
  .add-type { max-width: 112px; }
  .users, .users tbody { display: block; }
  .users tbody tr { display: block; padding: 10px; }
  .users td { display: block; padding: 2px 0; border: 0; }
}
