:root {
  --bg: #f6f5f1; --panel: #ffffff; --ink: #1f1f1d; --muted: #8a8780; --line: #e6e3dc;
  --accent: #2f6f5e; --accent-soft: #e3efe9; --star: #d99a1e; --danger: #b4452f;
  --row: 34px; --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #1b1b1a; --panel: #242423; --ink: #ecebe7; --muted: #8f8c85; --line: #353432; --accent: #6cbfa6; --accent-soft: #23352f; --star: #e8b04a; }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.4 var(--font); padding-bottom: calc(env(safe-area-inset-bottom) + 80px); }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
a { color: var(--accent); }

/* header */
.top { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 10px; padding: calc(env(safe-area-inset-top) + 10px) 16px 10px; background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 8px; text-decoration: none; color: var(--ink); font-weight: 650; }
#search { flex: 1; min-width: 0; max-width: 360px; margin-left: auto; padding: 7px 12px; border-radius: 9px; border: 1px solid var(--line); background: var(--panel); color: var(--ink); font: inherit; font-size: 15px; }
.sync { width: 9px; height: 9px; border-radius: 50%; background: var(--muted); flex: none; }
.sync.ok { background: var(--accent); } .sync.pending { background: var(--star); } .sync.error { background: var(--danger); }
.iconbtn { font-size: 22px; line-height: 1; width: 34px; height: 34px; border-radius: 8px; }
.iconbtn:hover { background: var(--line); }
.menu { display: none; position: absolute; right: 12px; top: calc(100% + 4px); background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; width: 290px; box-shadow: 0 8px 30px rgb(0 0 0 / .12); font-size: 14px; }
.menu.open { display: grid; gap: 10px; }
.menu label { display: flex; gap: 8px; align-items: center; }
.menu > button { text-align: left; color: var(--accent); }
.menu .status { color: var(--muted); font-size: 13px; }
.menu dl { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; margin: 8px 0 0; font-size: 13px; }
.menu dt { color: var(--muted); white-space: nowrap; } .menu dd { margin: 0; }
.demo-banner, .signin { display: none; text-align: center; font-size: 13px; padding: 6px 12px; background: var(--accent-soft); }
body.demo .demo-banner, .signin.show { display: block; }

main { max-width: 780px; margin: 0 auto; padding: 14px 16px 40px; }
.crumbs { font-size: 14px; color: var(--muted); min-height: 4px; margin-bottom: 6px; }
.crumbs a { color: var(--muted); text-decoration: none; } .crumbs a:hover { color: var(--accent); }
.crumbs .sep { margin: 0 6px; }

/* quick add + cards */
.quick input { width: 100%; padding: 12px 14px; font: inherit; border-radius: 12px; border: 1px solid var(--line); background: var(--panel); color: var(--ink); }
.quick input:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; margin: 12px 0; }
.card-h { display: flex; justify-content: space-between; align-items: center; font-size: 13px; font-weight: 650; letter-spacing: .02em; color: var(--muted); text-transform: uppercase; margin-bottom: 6px; }
.card .link { font-size: 13px; color: var(--muted); text-transform: none; font-weight: 400; }
.brief h3, .brief h4, .brief h5 { margin: 8px 0 4px; font-size: 15px; } .brief p { margin: 4px 0; } .brief ul { margin: 4px 0; padding-left: 20px; } .brief li { margin: 2px 0; }
.rocks .card-h { color: var(--star); }
.rock { display: flex; align-items: center; gap: 10px; padding: 6px 0; border-top: 1px solid var(--line); }
.rock:first-of-type { border-top: 0; }
.rock-t, .hit { flex: 1; cursor: pointer; min-width: 0; }
.path { font-size: 12.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hit { padding: 8px 0; border-top: 1px solid var(--line); } .hit:first-of-type { border-top: 0; }
.empty { color: var(--muted); font-size: 14px; margin: 4px 0; }

/* outline */
.ztitle-wrap { display: flex; align-items: center; gap: 8px; margin: 4px 0 10px 28px; }
.ztitle { flex: 1; font-size: 26px; font-weight: 700; line-height: 1.25; outline: none; min-height: 1.25em; }
.list { margin-top: 6px; }
.kids { margin-left: 22px; border-left: 1px solid var(--line); padding-left: 4px; }
.row { display: flex; align-items: flex-start; min-height: var(--row); border-radius: 8px; position: relative; }
.row.focused, .row:hover { background: color-mix(in srgb, var(--line) 45%, transparent); }
.row.flash { animation: flash 1.2s ease; }
@keyframes flash { 0%, 40% { background: var(--accent-soft); } 100% { background: transparent; } }
.chev { width: 22px; height: var(--row); flex: none; display: grid; place-items: center; color: var(--muted); }
.chev::before { content: ""; width: 0; height: 0; border-left: 5px solid transparent; border-right: 5px solid transparent; border-top: 6px solid currentColor; transition: transform .12s; }
.chev.closed::before { transform: rotate(-90deg); }
.chev.none { visibility: hidden; }
.tick, .tick-space { width: 30px; height: var(--row); flex: none; display: grid; place-items: center; }
.tick::before { content: ""; width: 17px; height: 17px; border-radius: 50%; border: 1.6px solid var(--muted); transition: all .15s; }
.tick:hover::before { border-color: var(--accent); background: var(--accent-soft); }
.done > .row .tick::before, .ticking .tick::before { background: var(--accent); border-color: var(--accent); box-shadow: inset 0 0 0 3px var(--panel); }
.text { flex: 1; min-width: 0; padding: 6px 4px; outline: none; word-break: break-word; white-space: pre-wrap; min-height: var(--row); }
.text:empty::before { content: "\200b"; }
.section > .row > .text { font-weight: 650; font-size: 17px; }
.section { margin-top: 6px; }
.done > .row > .text, .ticking > .row > .text, .ticking .rock-t { text-decoration: line-through; color: var(--muted); }
.ticking { animation: fadeout .65s ease forwards; }
@keyframes fadeout { 0%, 50% { opacity: 1; } 100% { opacity: 0; } }
.count { align-self: center; font-size: 12px; color: var(--muted); background: var(--line); border-radius: 10px; padding: 1px 7px; margin-right: 4px; }
.star, .zoom { width: 32px; height: var(--row); flex: none; color: var(--muted); font-size: 17px; opacity: 0; }
.star.on { color: var(--star); opacity: 1; }
.star.big { opacity: 1; font-size: 22px; }
.zoom { font-size: 22px; }
.row:hover .star, .row:hover .zoom, .row.focused .star, .row.focused .zoom { opacity: 1; }
.add { margin: 8px 0 0 52px; color: var(--muted); font-size: 15px; padding: 6px 4px; }
.add:hover { color: var(--accent); }

/* phone toolbar */
.toolbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; display: none; flex-direction: column; gap: 2px; padding: 6px 8px calc(env(safe-area-inset-bottom) + 6px); background: var(--panel); border-top: 1px solid var(--line); box-shadow: 0 -4px 16px rgb(0 0 0 / .06); transition: opacity .12s; }
.toolbar .tb-row { display: grid; grid-template-columns: repeat(6, 1fr); gap: 4px; }
.toolbar button { height: 44px; font-size: 19px; border-radius: 10px; }
.toolbar button:active { background: var(--line); }
.toolbar .tb-kb, .toolbar .tb-new { color: var(--accent); font-weight: 600; }
.toolbar.moving { opacity: 0; pointer-events: none; }
body.phone.selecting .toolbar, body.phone.typing .toolbar { display: flex; }
body.phone.typing .toolbar .tb-more, body.phone.typing .toolbar .tb-new { display: none; }
body.phone.typing .toolbar .tb-row { grid-template-columns: repeat(5, 1fr); }
body.phone.typing .toolbar { padding-bottom: 6px; }
body.phone.selecting { padding-bottom: calc(env(safe-area-inset-bottom) + 130px); }
body.phone .row.selected, body.phone .ztitle-wrap.selected { background: var(--accent-soft); box-shadow: inset 3px 0 0 var(--accent); }
body.phone .text[contenteditable="false"] { -webkit-user-select: none; user-select: none; cursor: default; }
body.phone .mic { display: none; }
body.phone .quick input { padding-right: 14px; }
.cardstrip { display: flex; gap: 8px; margin: 10px 0 4px; }
.cardstrip .pill { flex: 1; padding: 10px 6px; border-radius: 12px; background: var(--panel); border: 1px solid var(--line); font-weight: 650; font-size: 15px; }
.cardstrip .duesoon { color: var(--danger); } .cardstrip .bigrocks { color: var(--rock); } .cardstrip .rocks { color: var(--star); }
@media (hover: none), (max-width: 700px) {
  :root { --row: 40px; }
  .row:hover { background: none; }
  .row.focused { background: color-mix(in srgb, var(--line) 45%, transparent); }
  .star { opacity: 0; } .star.on { opacity: 1; }
  .row:hover .star:not(.on), .row:hover .zoom { opacity: 0; }
  .row.focused .star, .row.focused .zoom { opacity: 1; }
  .kids { margin-left: 16px; }
  #search { max-width: none; }
  .brand span { display: none; }
}

.toast { position: fixed; left: 50%; bottom: calc(env(safe-area-inset-bottom) + 24px); transform: translate(-50%, 20px); opacity: 0; pointer-events: none; background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 12px; font-size: 14px; transition: all .2s; z-index: 40; display: flex; gap: 14px; align-items: center; }
.toast.show { opacity: 1; transform: translate(-50%, 0); pointer-events: auto; }
body.phone.selecting .toast, body.phone.typing .toast { bottom: calc(env(safe-area-inset-bottom) + 130px); }
.toast button { color: var(--accent); font-weight: 650; filter: brightness(1.4); }
.section > .row > .tick-space { width: 6px; }
.section > .kids { margin-left: 22px; }
.tidy { flex: none; align-self: center; font-size: 13px; font-weight: 600; color: var(--accent); background: var(--accent-soft); border-radius: 999px; padding: 4px 10px; margin: 0 4px; white-space: nowrap; }
.tidy:hover { filter: brightness(.97); }
.tidy.busy { opacity: .6; pointer-events: none; animation: pulse 1s ease-in-out infinite alternate; }
@keyframes pulse { to { opacity: .35; } }
.ztitle-wrap .tidy { font-size: 14px; padding: 6px 12px; }
.quick { position: relative; }
.quick input { padding-right: 60px; }
.mic { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); min-width: 40px; height: 36px; padding: 0 10px; border-radius: 999px; display: inline-flex; align-items: center; justify-content: center; gap: 6px; color: var(--accent); background: var(--accent-soft); font-size: 14px; font-weight: 600; font-variant-numeric: tabular-nums; }
.mic:hover { filter: brightness(.97); }
.mic.rec { background: var(--danger); color: #fff; }
.mic.rec .dot { width: 9px; height: 9px; border-radius: 2px; background: #fff; animation: pulse 0.8s ease-in-out infinite alternate; }
.mic.busy { pointer-events: none; }
.live { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(env(safe-area-inset-bottom) + 76px); width: min(640px, calc(100vw - 24px)); max-height: 40vh; overflow: auto; background: var(--panel); color: var(--ink); border: 1px solid var(--line); border-left: 4px solid var(--danger); border-radius: 12px; padding: 12px 14px; box-shadow: 0 8px 28px rgba(0,0,0,.14); z-index: 39; font-size: 16px; line-height: 1.45; }
.live[hidden] { display: none; }
.live-text:empty { display: none; }
.live-note { color: var(--muted); font-size: 13px; margin-top: 4px; }
.live-text:empty + .live-note { margin-top: 0; }
.mic .spin { width: 16px; height: 16px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.tidy + .tidy { margin-left: 0; }
@media (max-width: 420px) { .section > .row .tidy { padding: 4px 8px; font-size: 12.5px; margin: 0 2px; } }
/* drag to move (desktop) */
.grip { position: absolute; left: -18px; top: 0; width: 18px; height: var(--row); display: grid; place-items: center; color: var(--muted); font-size: 14px; cursor: grab; opacity: 0; user-select: none; touch-action: none; }
.row:hover .grip { opacity: .7; }
.grip:hover { opacity: 1; color: var(--ink); }
body.is-dragging, body.is-dragging * { cursor: grabbing !important; user-select: none; }
body.is-dragging .row:hover { background: none; }
.drag-src { opacity: .35; }
.drag-ghost { position: fixed; left: 0; top: 0; z-index: 50; pointer-events: none; max-width: 320px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; box-shadow: 0 6px 20px rgb(0 0 0 / .15); font-size: 15px; }
.drop-line { position: fixed; z-index: 45; height: 3px; border-radius: 2px; background: var(--accent); pointer-events: none; display: none; }
.drop-line::before { content: ""; position: absolute; left: -4px; top: -3px; width: 9px; height: 9px; border-radius: 50%; border: 2px solid var(--accent); background: var(--bg); }
.row.drop-into { background: var(--accent-soft) !important; }
@media (hover: none) { .grip { display: none; } }
/* 🤖 Do it */
.bot { flex: none; align-self: center; height: 28px; min-width: 32px; padding: 0 6px; border-radius: 999px; font-size: 15px; opacity: 0; white-space: nowrap; }
.row:hover .bot, .row.focused .bot, .ztitle-wrap .bot { opacity: .8; }
.bot.on, .bot.done { opacity: 1; font-size: 13px; font-weight: 600; padding: 0 10px; margin: 0 2px; }
.bot.on { color: #fff; background: var(--accent); }
.bot.done { color: var(--accent); background: var(--accent-soft); }
.bot.busy { opacity: .7; pointer-events: none; animation: pulse 1s ease-in-out infinite alternate; }
@media (hover: none), (max-width: 700px) { .row:hover .bot:not(.on):not(.done) { opacity: 0; } .row.focused .bot { opacity: .9; } }
.ext { flex: none; align-self: center; text-decoration: none; font-size: 15px; padding: 2px 6px; border-radius: 6px; color: var(--accent); }
.ext:hover { background: var(--accent-soft); }
/* ▲ big rocks */
:root { --rock: #a0662e; }
@media (prefers-color-scheme: dark) { :root { --rock: #d39a5f; } }
.rockbtn { width: 30px; height: var(--row); flex: none; color: var(--muted); font-size: 15px; opacity: 0; }
.rockbtn.on { color: var(--rock); opacity: 1; }
.rockbtn.big { opacity: 1; font-size: 20px; }
.row:hover .rockbtn, .row.focused .rockbtn { opacity: 1; }
@media (hover: none), (max-width: 700px) { .rockbtn { opacity: 0; } .rockbtn.on { opacity: 1; } .row:hover .rockbtn:not(.on) { opacity: 0; } .row.focused .rockbtn { opacity: 1; } }
.bigrocks .card-h { color: var(--rock); }
.card .rockbtn.on { height: auto; align-self: center; }
/* foldable cards */
.card-h.fold { width: 100%; justify-content: flex-start; gap: 6px; cursor: pointer; margin-bottom: 6px; background: none; border: 0; padding: 0; font: inherit; font-size: 13px; font-weight: 650; letter-spacing: .02em; text-transform: uppercase; }
.card.folded .card-h.fold { margin-bottom: 0; }
.fold-chev { width: 0; height: 0; border-left: 4.5px solid transparent; border-right: 4.5px solid transparent; border-top: 5.5px solid currentColor; transition: transform .12s; margin-right: 2px; }
.card.folded .fold-chev { transform: rotate(-90deg); }
.card-count { margin-left: 6px; font-size: 11.5px; font-weight: 600; background: color-mix(in srgb, currentColor 14%, transparent); border-radius: 10px; padding: 1px 7px; letter-spacing: 0; }
/* 📅 dates */
.chips { display: inline-flex; gap: 4px; align-self: center; flex-wrap: wrap; margin: 0 4px; }
.chip { font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 999px; background: var(--line); color: var(--muted); white-space: nowrap; line-height: 1.5; }
.chip.today { background: #fbe7c2; color: #8a5a00; }
.chip.overdue { background: #f8d7d0; color: var(--danger); }
.chip.soon { background: var(--accent-soft); color: var(--accent); }
.chip.rep { font-weight: 500; }
@media (prefers-color-scheme: dark) { .chip.today { background: #4a3a17; color: #f0c56a; } .chip.overdue { background: #4d2520; color: #f09a8a; } }
.done .chip { opacity: .6; }
.datebtn { width: 30px; height: var(--row); flex: none; font-size: 14px; opacity: 0; filter: grayscale(1); }
.datebtn.big { opacity: .8; font-size: 18px; height: auto; }
.row:hover .datebtn, .row.focused .datebtn { opacity: .75; }
@media (hover: none), (max-width: 700px) { .datebtn { display: none; } .datebtn.big { display: inline-block; } }
.duesoon .card-h { color: var(--danger); }
.card .rock .chips { margin-left: auto; }
.datepop { display: none; position: fixed; z-index: 60; width: 300px; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; box-shadow: 0 12px 40px rgb(0 0 0 / .18); padding: 12px; font-size: 14px; }
.datepop.open { display: grid; gap: 10px; }
.datepop.sheet { left: 0 !important; right: 0; bottom: 0; top: auto !important; width: auto; border-radius: 16px 16px 0 0; padding: 16px 16px calc(env(safe-area-inset-bottom) + 16px); }
.dp-title { font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dp-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.dp-tabs button, .dp-quick button { border: 1px solid var(--line); border-radius: 9px; padding: 7px 6px; font-size: 13px; }
.dp-tabs button.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.dp-quick { display: flex; flex-wrap: wrap; gap: 6px; }
.dp-quick button:hover, .dp-tabs button:not(.on):hover { background: var(--accent-soft); }
.dp-row { display: flex; align-items: center; gap: 8px; }
.dp-input, .dp-rep { flex: 1; font: inherit; padding: 7px 8px; border: 1px solid var(--line); border-radius: 9px; background: var(--bg); color: var(--ink); }
.dp-x { color: var(--muted); padding: 4px 8px; }
.dp-foot { display: flex; justify-content: space-between; }
.dp-clear { color: var(--danger); font-size: 13px; }
.dp-done { background: var(--accent); color: #fff; border-radius: 9px; padding: 7px 16px; font-weight: 600; }
/* phone rows: item buttons live in the action bar, so only show markers that are switched on */
body.phone .row .star:not(.on), body.phone .row .rockbtn:not(.on), body.phone .row .zoom, body.phone .row .datebtn,
body.phone .row .bot:not(.on):not(.done), body.phone .row .grip { display: none; }
body.phone .row > .text { flex: 1 1 auto; min-width: 35%; }
body.phone .chips { flex-shrink: 0; }
body.phone .section > .row .tidy { padding: 4px 8px; font-size: 12.5px; margin: 0 2px; }
body.phone .row .star.on, body.phone .row .rockbtn.on { width: 26px; }

#version[data-live="1"]::after { content: ' · live sync'; }

/* Top priorities: drag to reorder */
.rock.sortable { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
.pgrip { flex: none; width: 14px; margin-right: -4px; color: var(--muted); opacity: .45; cursor: grab; font-size: 14px; line-height: 1; text-align: center; }
.rock.sortable:hover .pgrip { opacity: 1; }
body.phone .pgrip { display: none; }
.card.sorting { cursor: grabbing; }
.card.sorting .rock:not(.dragging) { transition: transform .12s; }
.rock.dragging { position: relative; z-index: 2; background: var(--panel); border-radius: 10px; box-shadow: 0 6px 22px rgba(0,0,0,.18); transform: scale(1.02); border-top-color: transparent; }
.rock.dragging + .rock { border-top-color: transparent; }

.callink { word-break: break-all; user-select: all; -webkit-user-select: all; }
.callink:empty { display: none; }

/* Buttons switched off for this person (profiles/index.js) */
body.no-tidy .tidy, body.no-do .bot, body.no-do [data-tool="bot"], body.no-voice #mic { display: none !important; }
