: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; justify-content: space-around; align-items: center; gap: 2px; padding: 6px 6px calc(env(safe-area-inset-bottom) + 6px); background: var(--panel); border-top: 1px solid var(--line); }
.toolbar button { min-width: 40px; height: 40px; font-size: 19px; border-radius: 8px; }
.toolbar button:active { background: var(--line); }
.toolbar .ok { font-size: 15px; font-weight: 600; color: var(--accent); padding: 0 8px; }
@media (hover: none), (max-width: 700px) {
  :root { --row: 40px; }
  body.editing .toolbar { display: flex; }
  .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.editing .toast { bottom: calc(env(safe-area-inset-bottom) + 70px); }
.toast button { color: var(--accent); font-weight: 650; filter: brightness(1.4); }
.section > .row > .tick-space { width: 6px; }
.section > .kids { margin-left: 22px; }
