:root {
  --bg: #f4f5f7; --surface: #ffffff; --surface-2: #eef0f3; --text: #1c1f24; --muted: #6b7280; --border: #d9dce1;
  --accent: #2563eb; --accent-text: #ffffff; --danger: #dc2626; --ok: #16a34a; --warn: #d97706;
  --critical: #dc2626; --high: #ea580c; --medium: #2563eb; --low: #6b7280;
  --personal: #7c3aed; --mesh: #0e7490; --general: #6b7280;
  --radius: 10px; --shadow: 0 1px 2px rgba(0,0,0,.06), 0 4px 12px rgba(0,0,0,.05);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1115; --surface: #171a21; --surface-2: #1f232c; --text: #e6e8ec; --muted: #9aa1ad; --border: #2b303b;
    --accent: #3b82f6; --shadow: 0 1px 2px rgba(0,0,0,.4), 0 4px 12px rgba(0,0,0,.3);
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.error { color: var(--danger); font-size: 13px; }
a { color: var(--accent); }
button, input, select, textarea { font: inherit; color: inherit; }
button { background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; padding: 6px 12px; cursor: pointer; }
button:hover { border-color: var(--accent); }
button.primary { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
button.ghost { background: transparent; border-color: transparent; }
button.danger { background: transparent; color: var(--danger); border-color: var(--danger); }
button.small { padding: 3px 8px; font-size: 12px; }
input, select, textarea { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 7px 10px; width: 100%; }
textarea { resize: vertical; }
label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); margin-bottom: 10px; }
label > input, label > select, label > textarea { color: var(--text); font-size: 14px; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.inline { display: flex; gap: 6px; }
.inline input { flex: 1; }

/* login */
#login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 28px; width: 100%; max-width: 360px; }
.login-card h1 { margin: 0 0 4px; }
.login-card button { width: 100%; margin-top: 6px; }

/* demo banner (planner.meshhand.com only) */
.demo-banner { background: var(--surface-2); border-bottom: 1px solid var(--border); padding: 8px 16px; font-size: 13px; color: var(--text); }
@media print { .demo-banner { display: none !important; } }

/* top bar */
.topbar { position: sticky; top: 0; z-index: 5; background: var(--surface); border-bottom: 1px solid var(--border); display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; padding: 10px 16px; }
.brand { font-weight: 700; font-size: 18px; color: var(--text); text-decoration: none; cursor: pointer; }
.brand:hover { color: var(--accent); }
.ver { font-weight: 400; font-size: 11px; color: var(--muted); font-family: ui-monospace, Menlo, Consolas, monospace; vertical-align: middle; }
#ver { cursor: pointer; border: 1px solid var(--border); border-radius: 999px; padding: 1px 7px; }
#ver:hover { color: var(--accent); border-color: var(--accent); }
.changelog h2 { font-size: 17px; margin: 18px 0 6px; padding-top: 12px; border-top: 1px solid var(--border); }
.changelog h2:first-child { border-top: 0; padding-top: 0; margin-top: 0; }
.changelog h3 { font-size: 14px; }
.changelog ul { padding-left: 20px; margin: 6px 0 10px; }
.changelog li { margin: 4px 0; }
.changelog p { color: var(--muted); font-size: 13px; }
.brand .muted { font-weight: 400; font-size: 13px; margin-left: 6px; }
#nav { display: flex; gap: 4px; flex-wrap: wrap; }
#nav button { border-color: transparent; background: transparent; padding: 6px 10px; }
#nav button.active { background: var(--surface-2); border-color: var(--border); font-weight: 600; }
.count { background: var(--accent); color: #fff; border-radius: 999px; padding: 0 7px; font-size: 11px; margin-left: 2px; }
.count:empty { display: none; }
.filters { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; margin-left: auto; }
.filters select, .filters input { width: auto; padding: 6px 8px; }
.filters input { min-width: 160px; }

main { padding: 16px; max-width: 1600px; margin: 0 auto; }
h2 { margin: 0 0 10px; font-size: 18px; }
h3 { margin: 18px 0 8px; font-size: 15px; }
.card-box { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; margin-bottom: 16px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 12px; }
.stat b { display: block; font-size: 22px; }
.stat.bad b { color: var(--danger); }
.stat.warn b { color: var(--warn); }

/* board */
.board { display: flex; gap: 12px; overflow-x: auto; padding-bottom: 12px; align-items: flex-start; }
.column { flex: 0 0 280px; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); min-height: 200px; display: flex; flex-direction: column; }
.column.over { outline: 2px dashed var(--accent); }
.column-head { display: flex; justify-content: space-between; align-items: center; padding: 10px 12px; font-weight: 600; font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.column-head.wip-over { color: var(--danger); }
.column-body { padding: 0 8px 8px; display: flex; flex-direction: column; gap: 8px; min-height: 60px; flex: 1; }
.task { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 9px 10px; cursor: grab; box-shadow: var(--shadow); }
.task:active { cursor: grabbing; }
.task.dragging { opacity: .5; }
.task .id { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 11px; color: var(--muted); }
.task .title { font-weight: 600; margin: 2px 0 6px; }
.task .meta { display: flex; flex-wrap: wrap; gap: 4px; font-size: 11px; align-items: center; }
.task .move { width: auto; margin-left: auto; padding: 2px 4px; font-size: 11px; border-radius: 6px; cursor: pointer; }
.chip { border-radius: 999px; padding: 1px 7px; background: var(--surface-2); border: 1px solid var(--border); white-space: nowrap; }
.chip.p-Critical { color: #fff; background: var(--critical); border-color: var(--critical); }
.chip.p-High { color: #fff; background: var(--high); border-color: var(--high); }
.chip.p-Medium { color: #fff; background: var(--medium); border-color: var(--medium); }
.chip.p-Low { color: #fff; background: var(--low); border-color: var(--low); }
.chip.a-personal { color: var(--personal); border-color: var(--personal); }
.chip.a-mesh-connector { color: var(--mesh); border-color: var(--mesh); }
.chip.a-general { color: var(--general); }
.chip.due.overdue { color: #fff; background: var(--danger); border-color: var(--danger); }
.chip.due.today { color: #fff; background: var(--warn); border-color: var(--warn); }
.chip.blocked { color: var(--danger); border-color: var(--danger); }
.chip.epic { color: var(--personal); border-color: var(--personal); }
.subprog { font-size: 11px; color: var(--muted); }

/* lists */
.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; gap: 10px; align-items: flex-start; padding: 8px 0; border-bottom: 1px solid var(--border); }
.list li:last-child { border-bottom: 0; }
.list .grow { flex: 1; min-width: 0; }
.list .actions { display: flex; gap: 4px; flex-wrap: wrap; }
.tasklink { cursor: pointer; }
.tasklink:hover .title { text-decoration: underline; }
.tasklink[draggable="true"] { cursor: grab; }
.tasklink.dragging { opacity: .45; }
.lane-out { margin-left: 8px; padding: 2px 10px; flex: none; }
.today-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
.today-head h2 { margin: 0; }
.lane-hint { margin: -4px 0 12px; }
.lane { transition: outline-color .1s; outline: 2px dashed transparent; outline-offset: -2px; }
.lane.drop-ok { outline-color: var(--border); }
.lane.over { outline-color: var(--accent); background: var(--surface-2); }
.done { text-decoration: line-through; color: var(--muted); }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { color: var(--muted); font-weight: 600; }
code { background: var(--surface-2); padding: 1px 5px; border-radius: 4px; font-size: 12px; }
pre { background: var(--surface-2); padding: 10px; border-radius: 8px; overflow: auto; font-size: 12px; }
.project-card h3 { margin: 0 0 4px; display: flex; gap: 8px; align-items: center; }
.project-card .bars { display: flex; gap: 2px; height: 6px; border-radius: 3px; overflow: hidden; margin: 8px 0; background: var(--surface-2); }
.project-card .bars span { display: block; height: 100%; }
.bar-ParkingLot { background: #d6d3d1; } .column[data-status="Parking Lot"] { opacity: .85; }
.bar-Backlog { background: #9ca3af; } .bar-ToDo { background: #60a5fa; } .bar-InProgress { background: #f59e0b; } .bar-Review { background: #a78bfa; } .bar-Blocked { background: #ef4444; } .bar-Done { background: #22c55e; }
.form-box { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; margin-bottom: 16px; }
.form-box .row { align-items: end; }

/* drawer */
#backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 19; }
#drawer { position: fixed; top: 0; right: 0; bottom: 0; width: 460px; max-width: 100vw; background: var(--surface); border-left: 1px solid var(--border); box-shadow: -8px 0 24px rgba(0,0,0,.15); z-index: 20; overflow-y: auto; padding: 16px 18px 40px; }
.drawer-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.drawer-head h2 { margin: 0; }
.drawer-head button { font-size: 22px; line-height: 1; }
.drawer-actions { display: flex; gap: 8px; align-items: center; margin-top: 6px; }
fieldset.subtasks { border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; margin: 0 0 10px; }
fieldset.subtasks legend { font-size: 13px; color: var(--muted); }
#subtask-list { list-style: none; margin: 0 0 6px; padding: 0; }
#subtask-list li { display: flex; gap: 8px; align-items: center; padding: 3px 0; }
#subtask-list li input[type=checkbox] { width: auto; }
#subtask-list li span { flex: 1; }
#task-activity ul { list-style: none; padding: 0; margin: 6px 0 0; font-size: 12px; color: var(--muted); }
#task-activity li { padding: 2px 0; }

#toast { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); background: var(--text); color: var(--bg); padding: 8px 14px; border-radius: 8px; z-index: 30; font-size: 13px; box-shadow: var(--shadow); }
#toast.err { background: var(--danger); color: #fff; }

/* ---------- mobile first: bottom tab bar, floating + button, full-screen drawer ---------- */
@media (max-width: 720px) {
  button, select, input { min-height: 40px; }
  .topbar { padding: 8px 12px; gap: 8px; }
  .brand { font-size: 16px; }
  .brand .muted { display: none; }
  #nav { position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; background: var(--surface); border-top: 1px solid var(--border); display: flex; flex-wrap: nowrap; gap: 2px; overflow-x: auto; padding: 4px 6px calc(4px + env(safe-area-inset-bottom)); scrollbar-width: none; }
  #nav::-webkit-scrollbar { display: none; }
  #nav button { flex: 0 0 auto; min-width: 60px; min-height: 46px; font-size: 12px; border-radius: 8px; padding: 4px 10px; white-space: nowrap; }
  #nav button.active { background: var(--accent); color: var(--accent-text); }
  #nav .count { background: var(--danger); }
  .filters { margin-left: 0; width: 100%; gap: 6px; }
  .filters select { flex: 1; min-width: 0; }
  .filters input { min-width: 0; width: 100%; order: 3; }
  #btn-logout { position: absolute; right: 10px; top: 8px; font-size: 12px; min-height: 30px; padding: 2px 8px; }
  .brand { padding-right: 70px; }
  #btn-new { position: fixed; right: 14px; bottom: calc(74px + env(safe-area-inset-bottom)); z-index: 11; border-radius: 999px; min-height: 48px; padding: 0 18px; font-size: 15px; box-shadow: 0 6px 16px rgba(0,0,0,.25); }
  main { padding: 12px 12px calc(130px + env(safe-area-inset-bottom)); }
  h2 { font-size: 17px; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .board { scroll-snap-type: x mandatory; -webkit-overflow-scrolling: touch; margin: 0 -12px; padding: 0 12px 12px; }
  .column { flex-basis: 86vw; scroll-snap-align: start; }
  .task { cursor: default; padding: 12px; }
  .task .title { font-size: 15px; }
  .task .move { min-height: 34px; font-size: 13px; }
  .row { grid-template-columns: 1fr; }
  #drawer { width: 100vw; border-left: 0; padding: 12px 14px calc(24px + env(safe-area-inset-bottom)); }
  .drawer-actions { position: sticky; bottom: 0; background: var(--surface); padding: 10px 0; border-top: 1px solid var(--border); }
  .list li { padding: 10px 0; }
  th, td { padding: 8px 6px; }
}

/* ---------- printable to-do ---------- */
.board-tools { display: flex; justify-content: flex-end; align-items: center; gap: 8px; margin-bottom: 8px; flex-wrap: wrap; }
.board-tools .grow { flex: 1; }
.todo-tools { display: flex; gap: 8px; align-items: center; margin-bottom: 12px; flex-wrap: wrap; }
.todo-sheet { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px 24px; max-width: 820px; }
.todo-sheet h2 { margin-bottom: 2px; }
.todo-group { margin: 18px 0 6px; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); border-bottom: 1px solid var(--border); padding-bottom: 3px; }
.todo-item { padding: 8px 0; border-bottom: 1px dashed var(--border); break-inside: avoid; }
.todo-line { display: flex; align-items: flex-start; gap: 8px; }
.todo-line.sub { margin-left: 34px; font-size: 13px; margin-top: 3px; }
.todo-line .box { flex: 0 0 auto; width: 16px; height: 16px; border: 1.5px solid var(--text); border-radius: 3px; margin-top: 3px; }
.todo-line .box.checked { background: var(--text); }
.todo-line .num { color: var(--muted); min-width: 26px; }
.todo-title { font-weight: 600; }
.todo-meta { font-size: 12px; color: var(--muted); margin: 2px 0 0 50px; }
.todo-desc { font-size: 13px; margin: 4px 0 0 50px; white-space: pre-wrap; }
.todo-subs { margin-top: 2px; }
.todo-notes { font-size: 12px; color: var(--muted); margin: 4px 0 0 50px; white-space: pre-wrap; font-style: italic; }
/* ---------- Today paper sheet (.ps): printed by Today's Print button, previewed at #todayprint ---------- */
/* It is paper on screen too: fixed ink on white regardless of theme. Sizes in pt so the preview matches the page. */
.print-only { display: none; }
.ps { --ink: #111; --ink-2: #4a4a4a; --rule: #c4c4c4; background: #fff; color: var(--ink); font: 10.5pt/1.35 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; max-width: 8.5in; padding: .5in .55in; border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.ps-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16pt; border-bottom: 2pt solid var(--ink); padding-bottom: 6pt; }
.ps-head h1 { margin: 0; font-size: 22pt; line-height: 1; letter-spacing: -.015em; }
.ps-date { font-size: 11pt; margin-top: 4pt; }
.ps-counts { font-size: 9pt; color: var(--ink-2); text-align: right; }
.ps-counts b { color: var(--ink); }
.ps-group { margin-top: 16pt; }
.ps-group h2 { display: flex; align-items: baseline; gap: 6pt; margin: 0; padding-bottom: 3pt; border-bottom: .75pt solid var(--ink); font-size: 9pt; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; break-after: avoid; }
.ps-group h2 .sub { font-weight: 400; text-transform: none; letter-spacing: 0; color: var(--ink-2); }
.ps-group h2 .n { margin-left: auto; font-weight: 400; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.ps-none { margin: 5pt 0 0; font-size: 9pt; color: var(--ink-2); }
.ps-item { display: grid; grid-template-columns: 12pt 1fr auto; column-gap: 9pt; padding: 6pt 0; border-bottom: .5pt solid var(--rule); break-inside: avoid; }
.ps-box { display: inline-block; flex: 0 0 auto; width: 11pt; height: 11pt; margin-top: 2pt; border: 1pt solid var(--ink); border-radius: 1.5pt; position: relative; }
.ps-title { font-size: 11pt; font-weight: 600; line-height: 1.3; }
.ps-meta { margin-top: 1.5pt; font-size: 8.5pt; color: var(--ink-2); }
.ps-meta b { color: var(--ink); }
.ps-when { display: flex; flex-direction: column; align-items: flex-end; font-size: 9pt; white-space: nowrap; font-variant-numeric: tabular-nums; }
.ps-when span { font-size: 8.5pt; color: var(--ink-2); }
.ps-desc { margin-top: 3pt; font-size: 9.5pt; white-space: pre-wrap; max-width: 62ch; }
.ps-notes { margin-top: 3pt; font-size: 8.5pt; font-style: italic; color: var(--ink-2); white-space: pre-wrap; max-width: 70ch; }
.ps-subs { display: grid; gap: 2.5pt; margin-top: 4pt; }
.ps-sub { display: flex; align-items: flex-start; gap: 6pt; font-size: 9.5pt; }
.ps-sub .ps-box { width: 9pt; height: 9pt; margin-top: 1.5pt; }
.ps-sub.done > span:last-child { color: var(--ink-2); text-decoration: line-through; }
/* the tick is drawn with borders, not a fill, so it survives "background graphics: off" */
.ps-sub.done .ps-box::after { content: ''; position: absolute; left: 2.6pt; top: .2pt; width: 2.4pt; height: 5pt; border: solid var(--ink); border-width: 0 1.2pt 1.2pt 0; transform: rotate(45deg); }
.ps-stamp { break-before: avoid; display: flex; justify-content: space-between; margin-top: 10pt; font-size: 7.5pt; color: var(--ink-2); }
@media (max-width: 720px) { .ps { padding: 20px 16px; } .ps-head { flex-direction: column; align-items: flex-start; } .ps-counts { text-align: left; } }

@page { margin: .5in .55in; }
@media print {
  :root, :root:not([data-theme="light"]) { --bg: #fff; --surface: #fff; --surface-2: #fff; --text: #000; --muted: #444; --border: #999; --shadow: none; }
  .today-screen { display: none !important; }
  .print-only { display: block !important; }
  .ps { max-width: none; padding: 0; border: 0; border-radius: 0; box-shadow: none; }
  .topbar, #nav, #btn-new, #drawer, #backdrop, #toast, .todo-tools { display: none !important; }
  html, body { background: #fff; color: #000; }
  main { padding: 0; max-width: none; }
  .todo-sheet { border: 0; padding: 0; max-width: none; }
  .todo-item { border-bottom-color: #bbb; }
  .todo-meta, .todo-notes, .todo-group { color: #444; }
  .todo-line .box { border-color: #000; }
  a { color: #000; text-decoration: none; }
}

/* ---------- Get Going ---------- */
.go-text { width: 100%; min-height: 320px; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12.5px; line-height: 1.45; white-space: pre; overflow: auto; background: var(--surface); }
a.btn-link { display: inline-block; background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; padding: 6px 12px; color: var(--text); text-decoration: none; }
a.btn-link:hover { border-color: var(--accent); }
@media (max-width: 720px) { a.btn-link { min-height: 40px; line-height: 26px; } .go-text { white-space: pre-wrap; font-size: 12px; } }

/* Prompt this: To Ginger / On computer switch */
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.seg button { border: 0; border-radius: 0; background: var(--surface-2); }
.seg button + button { border-left: 1px solid var(--border); }
.seg button.on { background: var(--accent); color: var(--accent-text); }
.prompt-first { font-weight: 600; }

/* ---------- calendar lanes (1.10.0) ---------- */
.day-head { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); padding: 8px 0 2px !important; border-bottom: 1px solid var(--border); }
.column-body .day-head { padding: 6px 2px 0 !important; border-bottom: 0; }
.column-sub { padding: 0 12px 8px; margin-top: -6px; }
.lane h3 { display: flex; align-items: baseline; gap: 6px; flex-wrap: wrap; }
.lane-n { margin-left: auto; font-size: 12px; color: var(--muted); font-weight: 600; }
select.when { width: auto; flex: none; padding: 2px 4px; font-size: 11px; border-radius: 6px; cursor: pointer; margin-left: auto; }
.list li select.when { margin-left: 6px; align-self: center; }
.chip.step { color: var(--accent); border-color: var(--accent); max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
.column[data-when="overdue"] .column-head span:first-child { color: var(--danger); }
.column[data-when="today"] { border-color: var(--warn); }
input.sub-date { width: auto; flex: none; padding: 3px 6px; font-size: 12px; }
input.sub-date.overdue { border-color: var(--danger); color: var(--danger); }
.sub-hint { margin: 0 0 6px; }
#due-hint { margin: -4px 0 10px; }
@media (max-width: 720px) { select.when { min-height: 34px; font-size: 13px; } }
.line-side { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; flex: none; }
.line-side .lane-out, .list li .line-side select.when { margin-left: 0; }
