:root {
  --bg: #EBEFF2;
  --card: #FFFFFF;
  --line: #D5DBE0;
  --rule: #E8ECEF;
  --ink: #16202A;
  --ink-2: #3E4954;
  --muted: #5B6672;
  --accent: #0E6B66;
  --accent-soft: #E2F0EE;
  --warn: #A3520F;
  --warn-ink: #6E3A0B;
  --warn-soft: #FDF3E8;
  --warn-line: #E3B88F;
  --bad: #B42318;
  --chip: #F1F3F5;
  --track: #E3E7EA;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #11171D; --card: #1A222A; --line: #2B3640; --rule: #24303A;
    --ink: #E8EDF1; --ink-2: #C1CBD3; --muted: #93A0AB;
    --accent: #4FB7AE; --accent-soft: #173431;
    --warn: #E39A5B; --warn-ink: #F0C29A; --warn-soft: #2A2016; --warn-line: #6B4A2A;
    --bad: #F2867A; --chip: #222C35; --track: #2B3640;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); }
body { font: 15px/1.45 "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif; }
.wrap { max-width: 1320px; margin: 0 auto; padding: 40px 16px 64px; display: flex; flex-direction: column; gap: 24px; }
.mono { font-family: "IBM Plex Mono", ui-monospace, Consolas, monospace; letter-spacing: .06em; font-size: 12px; color: var(--muted); text-transform: uppercase; }
h1, h2 { font-family: "Space Grotesk", "Segoe UI", sans-serif; margin: 0; }
h1 { font-size: clamp(32px, 5vw, 44px); line-height: 1.05; font-weight: 700; letter-spacing: -.02em; }
h2 { font-size: 20px; font-weight: 600; }
header { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-end; gap: 16px; }
header .sub { font-size: 17px; color: var(--ink-2); margin-top: 6px; }
.pill { display: inline-flex; align-items: center; gap: 8px; padding: 9px 14px; border: 1px solid var(--line); background: var(--card); border-radius: 999px; font-size: 14px; color: var(--ink-2); }
.pill a { color: var(--accent); }
.banner { background: var(--warn-soft); border: 1px solid var(--warn-line); color: var(--ink); border-radius: 12px; padding: 12px 16px; }
.grid { display: flex; flex-wrap: wrap; gap: 20px; align-items: stretch; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 22px 24px; display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.w-full { flex: 1 1 100%; }
.w-wide { flex: 1 1 560px; }
.w-normal { flex: 1 1 380px; }
.w-narrow { flex: 1 1 300px; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.card-head .t { display: flex; align-items: center; gap: 10px; }
.card-head svg { flex: none; }
.empty { color: var(--muted); font-size: 14px; }
.row { display: flex; gap: 12px; align-items: flex-start; padding-top: 12px; border-top: 1px solid var(--rule); }
.row:first-of-type { border-top: 0; padding-top: 0; }
.row .main { flex: 1; min-width: 0; }
.meta { font-size: 13px; color: var(--muted); }
.num { width: 28px; height: 28px; flex: none; border-radius: 50%; background: var(--accent); color: #fff; display: flex; align-items: center; justify-content: center; font: 600 14px "Space Grotesk", sans-serif; }
@media (prefers-color-scheme: dark) { .num { color: #0B1A19; } }
.ptitle { font-size: 17px; font-weight: 600; }
.why { font-size: 14px; color: var(--ink-2); }
.card.check { background: var(--warn-soft); border-color: var(--warn-line); }
.badge { min-width: 24px; height: 24px; padding: 0 7px; border-radius: 999px; background: var(--warn); color: #fff; font: 600 13px "IBM Plex Mono", monospace; display: inline-flex; align-items: center; justify-content: center; }
.notes { display: flex; flex-wrap: wrap; gap: 12px; }
.note { flex: 1 1 380px; min-width: 0; background: var(--card); border: 1px solid var(--warn-line); border-radius: 12px; padding: 14px 16px; display: flex; flex-direction: column; gap: 6px; }
.kind { font: 11px "IBM Plex Mono", monospace; letter-spacing: .06em; color: var(--warn-ink); background: var(--warn-soft); border-radius: 999px; padding: 3px 8px; align-self: flex-start; text-transform: uppercase; }
.ref { font: 700 14px "IBM Plex Mono", monospace; color: #fff; background: var(--warn); border-radius: 6px; padding: 2px 8px; }
@media (prefers-color-scheme: dark) { .ref { color: #1A1208; } }
.hint { font-size: 13px; color: var(--warn-ink); }
.hint code, .card code { font: 12.5px "IBM Plex Mono", monospace; background: var(--chip); padding: 1px 5px; border-radius: 4px; color: var(--ink); }
.ev { display: flex; gap: 14px; }
.ev .time { width: 56px; flex: none; font: 14px "IBM Plex Mono", monospace; color: var(--ink-2); padding-top: 9px; }
.ev .box { flex: 1; min-width: 0; background: var(--chip); border-radius: 10px; padding: 9px 14px; display: flex; justify-content: space-between; gap: 8px; align-items: center; }
.ev.next .box { background: var(--accent-soft); }
.ev.past { opacity: .55; }
.tag { font: 11px "IBM Plex Mono", monospace; letter-spacing: .06em; color: #fff; background: var(--accent); border-radius: 999px; padding: 3px 8px; }
.sec { font: 12px "IBM Plex Mono", monospace; letter-spacing: .06em; color: var(--muted); text-transform: uppercase; padding-top: 8px; }
.sec.bad { color: var(--bad); }
.task { display: flex; justify-content: space-between; gap: 10px; align-items: baseline; }
.task .age { font: 12px "IBM Plex Mono", monospace; color: var(--muted); white-space: nowrap; }
.task .age.old { color: var(--warn); }
.done-t { color: var(--muted); text-decoration: line-through; }
.bar { height: 10px; border-radius: 5px; background: var(--track); overflow: hidden; }
.bar > div { height: 100%; background: var(--accent); border-radius: 5px; }
.big { font: 700 32px/1 "Space Grotesk", sans-serif; }
.spark { height: 64px; display: flex; align-items: flex-end; gap: 4px; }
.spark div { flex: 1; background: var(--accent); border-radius: 2px; opacity: .6; min-height: 2px; }
.spark div.zero { background: var(--line); opacity: 1; }
.spark div.today { opacity: 1; }
.stats { display: flex; justify-content: space-between; gap: 12px; padding-top: 12px; border-top: 1px solid var(--rule); flex-wrap: wrap; }
.stats div { display: flex; flex-direction: column; }
.stats b { font-weight: 600; }
.ico { width: 28px; height: 28px; flex: none; border-radius: 50%; display: flex; align-items: center; justify-content: center; background: var(--accent-soft); color: var(--accent); }
.ico.warn { background: var(--warn-soft); color: var(--warn); }
.ico.blue { background: #E6EBF5; color: #2F4F8F; }
@media (prefers-color-scheme: dark) { .ico.blue { background: #1D2639; color: #9DB4E6; } }
button.link { background: none; border: 0; color: var(--accent); font: inherit; cursor: pointer; padding: 10px 0; min-height: 44px; }
a { color: var(--accent); }
ul.plain { list-style: none; margin: 0; padding: 0; }
ul.plain li { padding: 9px 0; border-top: 1px solid var(--rule); display: flex; gap: 10px; align-items: center; }
ul.plain li:first-child { border-top: 0; }
.box-ico { width: 18px; height: 18px; border: 2px solid var(--muted); border-radius: 5px; flex: none; }
footer { color: var(--muted); font-size: 13px; text-align: center; }

/* tick boxes */
.chk { width: 44px; height: 44px; flex: none; display: flex; align-items: center; justify-content: center; margin: -10px -6px -10px -12px; cursor: pointer; }
.chk input { appearance: none; -webkit-appearance: none; width: 22px; height: 22px; margin: 0; border: 2px solid var(--muted); border-radius: 6px; background: var(--card); cursor: pointer; display: grid; place-content: center; transition: background .12s, border-color .12s; }
.chk input::after { content: ""; width: 11px; height: 6px; border: solid #fff; border-width: 0 0 2.5px 2.5px; transform: rotate(-45deg) translate(1px, -1px); opacity: 0; }
.chk input:checked { background: var(--accent); border-color: var(--accent); }
.chk input:checked::after { opacity: 1; }
.chk input:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.chk input:disabled { opacity: .6; cursor: progress; }
@media (prefers-color-scheme: dark) { .chk input::after { border-color: #0B1A19; } }
.row .chk { margin: -8px -10px -8px 0; align-self: center; }
.task { align-items: center; }
.task .grow, .grow { flex: 1; min-width: 0; }
.is-done .ptitle, .is-done .done-t { color: var(--muted); text-decoration: line-through; }
.row.is-done .num { background: var(--line); color: var(--muted); }
ul.plain li { padding: 0; min-height: 44px; }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 10px; font-size: 14px; opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; max-width: calc(100vw - 32px); z-index: 10; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.bad { background: var(--bad); color: #fff; }
.meta.overdue { color: var(--bad); }

/* star = in / out of Top priorities */
button.star { width: 40px; height: 44px; flex: none; display: flex; align-items: center; justify-content: center; margin: -10px -10px -10px 0; padding: 0; border: 0; background: none; color: var(--muted); cursor: pointer; border-radius: 8px; opacity: .55; transition: opacity .12s, color .12s; }
.task:hover button.star, button.star:focus-visible { opacity: 1; }
button.star:hover { color: var(--warn); opacity: 1; }
button.star.on { color: var(--warn); opacity: 1; }
button.star:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
button.star:disabled { cursor: progress; opacity: .4; }
@media (hover: none) { button.star { opacity: .8; } }
.row .acts { display: flex; align-items: center; gap: 2px; align-self: center; }
.row .acts button.star { margin: 0; }
.row .acts .chk { margin: -8px -10px -8px 0; }
ul.plain li:hover button.star { opacity: 1; }
ul.plain li button.star { margin: 0 -10px 0 0; }

/* ---- phone-first additions ---- */
body { padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left); }
.card-head .hr { display: flex; align-items: center; gap: 6px; margin-left: auto; }
button.fold { width: 36px; height: 36px; margin: -8px -10px -8px 0; display: flex; align-items: center; justify-content: center; border: 0; background: none; color: var(--muted); border-radius: 8px; cursor: pointer; transition: transform .15s; }
button.fold:hover { color: var(--ink); background: var(--chip); }
button.fold:focus-visible { outline: 2px solid var(--accent); outline-offset: 0; }
.card.folded > :not(.card-head) { display: none; }
.card.folded button.fold { transform: rotate(-90deg); }
.card.folded { padding-bottom: 18px; }
.card.slim { flex-direction: row; align-items: center; gap: 10px; padding: 12px 18px; color: var(--ink-2); font-size: 14px; }
button.more { align-self: flex-start; min-height: 40px; padding: 0 2px; border: 0; background: none; color: var(--accent); font: 500 14px "IBM Plex Sans", sans-serif; cursor: pointer; }
#jump { display: none; }
@media (max-width: 760px) {
  .wrap { padding: 16px 12px 40px; gap: 14px; }
  header { gap: 10px; }
  header .sub { font-size: 15px; }
  h1 { font-size: 30px; }
  .pill { padding: 6px 12px; font-size: 13px; }
  .grid { gap: 12px; }
  .card { padding: 16px 16px; border-radius: 12px; gap: 10px; }
  .card-head { flex-wrap: nowrap; }
  .card-head .t { min-width: 0; }
  .card-head .mono { font-size: 11px; white-space: nowrap; }
  .card-head .mono.label { display: none; }
  h2 { font-size: 18px; }
  #jump { display: flex; gap: 8px; overflow-x: auto; position: sticky; top: 0; z-index: 5; margin: 0 -12px; padding: 8px 12px; background: var(--bg); scrollbar-width: none; -webkit-overflow-scrolling: touch; }
  #jump::-webkit-scrollbar { display: none; }
  #jump .chip { flex: none; display: inline-flex; align-items: center; min-height: 36px; padding: 0 14px; border-radius: 999px; background: var(--card); border: 1px solid var(--line); color: var(--ink); text-decoration: none; font-size: 14px; font-weight: 500; }
  #jump .chip:active { background: var(--accent-soft); }
  .card { scroll-margin-top: 60px; }
  .row .why { font-size: 13.5px; }
  .toast { bottom: calc(16px + env(safe-area-inset-bottom)); }
}

/* refresh button (header on desktop, first chip in the sticky bar on phones) */
.hdr-right { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.refresh-btn { display: inline-flex; align-items: center; gap: 8px; min-height: 40px; padding: 0 16px; border-radius: 999px; border: 1px solid var(--accent); background: var(--accent); color: #fff; font: 500 14px "IBM Plex Sans", sans-serif; cursor: pointer; }
.refresh-btn:hover { filter: brightness(1.08); }
.refresh-btn:focus-visible, .chip-refresh:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.refresh-btn:disabled, .chip-refresh:disabled { cursor: progress; opacity: .85; }
@media (prefers-color-scheme: dark) { .refresh-btn { color: #0B1A19; } }
[data-refresh].spinning svg { animation: md-spin .8s linear infinite; }
@keyframes md-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { [data-refresh].spinning svg { animation-duration: 2.5s; } }
#jump .chip-refresh { padding: 0 12px; background: var(--accent); border-color: var(--accent); color: #fff; cursor: pointer; }
@media (max-width: 760px) {
  .refresh-btn { display: none; } /* phones use the chip in the sticky bar */
}

/* sign in */
.signed-out .hdr-right, .signed-out #jump { display: none; }
.signin { max-width: 420px; margin: 0 auto; width: 100%; }
.signin form { display: flex; flex-direction: column; gap: 14px; }
.signin label { display: flex; flex-direction: column; gap: 6px; font-weight: 500; }
.signin input { min-height: 46px; font: inherit; font-size: 16px; padding: 0 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--card); color: var(--ink); }
.signin input:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: var(--accent); }
.signin .err { color: var(--bad); min-height: 1.2em; }
.signin .err:empty { display: none; }
.btn-primary { min-height: 46px; border-radius: 10px; border: 0; background: var(--accent); color: #fff; font: 600 16px "IBM Plex Sans", sans-serif; cursor: pointer; }
.btn-primary:disabled { opacity: .6; cursor: default; }

/* reconnect Google */
.btn-sm { min-height: 40px; padding: 0 14px; border-radius: 10px; border: 0; background: var(--accent); color: #fff; font: 600 14px "IBM Plex Sans", sans-serif; cursor: pointer; white-space: nowrap; flex: none; }
.btn-sm:disabled { opacity: .6; cursor: default; }
.banner.has-action { display: flex; align-items: center; gap: 12px 16px; flex-wrap: wrap; }
.banner.has-action .grow { flex: 1 1 260px; min-width: 0; }
.reconnect { margin-bottom: 12px; border-color: var(--accent); }
.reconnect .card-head { border-bottom: 0; }
.reconnect .steps { margin: 0; padding-left: 22px; display: flex; flex-direction: column; gap: 14px; line-height: 1.5; }
.reconnect .steps li > .meta { margin-top: 6px; }
.reconnect .paste { display: flex; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.reconnect .paste input { flex: 1 1 220px; min-width: 0; min-height: 44px; font: 14px "IBM Plex Mono", monospace; padding: 0 10px; border-radius: 10px; border: 1px solid var(--line); background: var(--card); color: var(--ink); }
.reconnect .paste .btn-sm { min-height: 44px; }
.reconnect .err { color: var(--bad); margin-top: 6px; }
.reconnect .err:empty { display: none; }

/* add a task + changes waiting to sync */
.addrow { display: flex; gap: 8px; margin: 2px 0 6px; }
.addrow input { flex: 1; min-width: 0; min-height: 44px; font: inherit; font-size: 16px; padding: 0 12px; border-radius: 10px; border: 1px dashed var(--line); background: transparent; color: var(--ink); }
.addrow input:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-style: solid; border-color: var(--accent); background: var(--card); }
.addrow .btn-sm { min-height: 44px; }
.chk.pending { display: inline-flex; align-items: center; justify-content: center; width: 44px; height: 44px; flex: none; color: var(--muted); }
.is-pending .grow { color: var(--ink-2); }

/* tap a task to edit it */
[data-okind] { cursor: pointer; border-radius: 8px; }
[data-okind]:hover .ptitle, [data-okind]:hover > div:first-child { text-decoration: underline; text-decoration-color: var(--line); text-underline-offset: 3px; }
[data-okind]:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.has-notes { margin-left: 6px; color: var(--muted); font-weight: 400; font-size: .9em; }
body.sheet-open { overflow: hidden; }
.sheet-back { position: fixed; inset: 0; z-index: 50; background: rgba(14, 20, 26, .45); display: flex; align-items: flex-end; justify-content: center; }
.sheet { background: var(--card); color: var(--ink); width: 100%; max-width: 560px; max-height: 92vh; overflow-y: auto; border-radius: 18px 18px 0 0; padding: 14px 18px calc(18px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 10px; box-shadow: 0 -8px 30px rgba(0,0,0,.18); }
@media (min-width: 761px) { .sheet-back { align-items: center; } .sheet { border-radius: 18px; } }
.sheet-head { display: flex; justify-content: space-between; align-items: center; min-height: 44px; }
.sheet-head .mono { text-transform: uppercase; letter-spacing: .06em; font-size: 12px; color: var(--muted); }
.ed-title { font: 600 20px "Space Grotesk", sans-serif; border: 0; border-bottom: 1px solid var(--rule); background: transparent; color: var(--ink); resize: none; padding: 6px 0 10px; line-height: 1.3; }
.ed-title:focus, .ed-notes:focus, .ed-due input:focus { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
.ed-label { font-size: 13px; font-weight: 600; color: var(--ink-2); margin-top: 4px; }
.ed-notes { font: inherit; font-size: 16px; line-height: 1.5; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); color: var(--ink); padding: 10px 12px; resize: vertical; min-height: 96px; }
.ed-due { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.ed-due input { min-height: 44px; font: inherit; font-size: 16px; padding: 0 10px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg); color: var(--ink); color-scheme: light dark; }
.ed-due .chip { min-height: 40px; }
.ed-switch { display: flex; gap: 12px; align-items: center; min-height: 48px; cursor: pointer; }
.ed-switch input { width: 22px; height: 22px; accent-color: var(--accent); flex: none; }
.ed-switch .meta { display: block; }
.ed-warn { color: var(--warn, var(--ink-2)); margin-top: -6px; }
.ed-actions { display: flex; gap: 10px; justify-content: flex-end; padding-top: 8px; position: sticky; bottom: 0; background: var(--card); }
.ed-actions .btn-sm { min-height: 46px; padding: 0 22px; font-size: 16px; }
.btn-ghost { min-height: 46px; padding: 0 18px; border-radius: 10px; border: 1px solid var(--line); background: transparent; color: var(--ink); font: 500 16px "IBM Plex Sans", sans-serif; cursor: pointer; }
.ed-due .chip { display: inline-flex; align-items: center; padding: 0 14px; border-radius: 999px; background: var(--card); border: 1px solid var(--line); color: var(--ink); font: 500 14px "IBM Plex Sans", sans-serif; cursor: pointer; }
.ed-due .chip:active { background: var(--accent-soft); }

/* Tailscale switch in the app header */
.ts-btn { display: inline-flex; align-items: center; gap: 8px; min-height: 40px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--line); background: var(--card); color: var(--ink-2); font: 500 14px "IBM Plex Sans", sans-serif; cursor: pointer; }
.ts-btn .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--muted); }
.ts-btn.on { color: var(--ink); border-color: var(--accent); }
.ts-btn.on .dot { background: var(--accent); }
.ts-btn:disabled { opacity: .7; }

/* a task's details under its title: two lines, then "…" */
.details { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; overflow: hidden; text-overflow: ellipsis; white-space: pre-line; overflow-wrap: anywhere; color: var(--ink-2); font-size: 13.5px; line-height: 1.4; margin-top: 2px; }
.via-home { color: var(--accent); font-weight: 500; }
