/* ---------- tokens ---------- */

:root {
  color-scheme: light dark;
  --bg: light-dark(#ffffff, #1e1e20);
  --raised: light-dark(#ffffff, #28282b);
  --seg-on: light-dark(#ffffff, #48484d);
  --sidebar: light-dark(rgb(240 240 244 / 0.55), rgb(24 24 27 / 0.4));
  --fg: light-dark(#1d1d1f, #f2f2f4);
  --fg-2: light-dark(#6e6e73, #a1a1a8);
  --fg-3: light-dark(#a3a3a9, #6a6a71);
  --line: light-dark(rgb(0 0 0 / 0.08), rgb(255 255 255 / 0.08));
  --line-strong: light-dark(rgb(0 0 0 / 0.14), rgb(255 255 255 / 0.14));
  --hover: light-dark(rgb(0 0 0 / 0.045), rgb(255 255 255 / 0.06));
  --track: light-dark(rgb(0 0 0 / 0.08), rgb(255 255 255 / 0.12));
  --red: light-dark(#d93d42, #ff6b6f);
  --amber: light-dark(#b8760d, #f2b54f);
  --accent: var(--c, #0a84ff);
  --selected: color-mix(in srgb, var(--accent) 14%, transparent);
  --ring: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent);
  --mono: ui-monospace, "SF Mono", Menlo, monospace;
  font: 13px/1.45 -apple-system, BlinkMacSystemFont, "Helvetica Neue", sans-serif;
  -webkit-font-smoothing: antialiased;
}

[data-color="gray"], [data-accent="gray"] { --c: #8e8e93; }
[data-color="brown"] { --c: #a2845e; }
[data-color="orange"], [data-accent="orange"] { --c: #f2711c; }
[data-color="yellow"] { --c: #d4a106; }
[data-color="green"], [data-accent="green"] { --c: #2fa66a; }
[data-color="blue"], [data-accent="blue"] { --c: #0a84ff; }
[data-color="purple"], [data-accent="purple"] { --c: #8e55d6; }
[data-color="pink"], [data-accent="pink"] { --c: #db4b9c; }
[data-color="red"], [data-accent="red"] { --c: #e5484d; }

/* ---------- base ---------- */

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; overflow: hidden; background: transparent; color: var(--fg); cursor: default; -webkit-user-select: none; user-select: none; }
body { display: grid; grid-template-columns: 224px minmax(0, 1fr) auto; }
button { padding: 0; border: 0; background: none; color: inherit; font: inherit; cursor: default; }
input { color: inherit; font: inherit; -webkit-user-select: text; user-select: text; }
:focus-visible { outline: 2px solid color-mix(in srgb, var(--accent) 60%, transparent); outline-offset: 1px; }
[hidden] { display: none !important; }
.sprite { position: absolute; }
.icon { width: 16px; height: 16px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.empty { margin: 0; padding: 56px 0; color: var(--fg-3); text-align: center; }
.placeholder, .muted { color: var(--fg-3); }
kbd { padding: 1px 6px; border: 1px solid var(--line); border-radius: 5px; color: var(--fg-3); font: 11px -apple-system, sans-serif; }

/* ---------- sidebar ---------- */

.sidebar { display: flex; flex-direction: column; gap: 1px; min-height: 0; padding: 0 10px 12px; overflow-y: auto; background: var(--sidebar); border-right: 1px solid var(--line); }
.titlebar { flex: none; height: 52px; }
.search { display: flex; align-items: center; gap: 6px; height: 28px; margin-bottom: 14px; padding: 0 8px; border-radius: 7px; background: var(--hover); color: var(--fg-3); transition: box-shadow 0.15s; }
.search:focus-within { box-shadow: var(--ring); }
.search .icon { width: 14px; height: 14px; }
.search input { flex: 1; min-width: 0; padding: 0; border: 0; outline: none; background: none; -webkit-appearance: none; appearance: none; }
.search input::placeholder { color: var(--fg-3); }
.nav { display: flex; align-items: center; gap: 9px; width: 100%; height: 30px; padding: 0 8px; border-radius: 7px; text-align: left; }
.nav:hover { background: var(--hover); }
.nav.active { background: light-dark(rgb(0 0 0 / 0.075), rgb(255 255 255 / 0.1)); font-weight: 500; }
.nav .icon { color: var(--accent); }
.nav .label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav .count { margin-left: auto; padding-left: 6px; color: var(--fg-3); font-size: 12px; font-weight: 400; font-variant-numeric: tabular-nums; }
.dot { flex: none; width: 8px; height: 8px; margin: 0 4px; border-radius: 50%; background: var(--c); }
.grow { flex: 1; min-height: 16px; }

/* ---------- main ---------- */

main { display: flex; min-width: 0; min-height: 0; background: var(--bg); }
.view { flex: 1; min-width: 0; overflow-y: auto; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; padding: 44px 0 20px; }
.eyebrow { margin: 0 0 2px; color: var(--fg-2); font-size: 12px; font-weight: 500; }
h1 { margin: 0; font-size: 26px; font-weight: 700; letter-spacing: -0.02em; }


/* ---------- tasks ---------- */

#view-tasks { padding: 0 36px 48px; container-type: inline-size; }

.add { display: flex; align-items: center; gap: 10px; height: 42px; margin-bottom: 22px; padding: 0 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--raised); color: var(--fg-3); box-shadow: 0 1px 2px rgb(0 0 0 / 0.04); transition: border-color 0.15s, box-shadow 0.15s; }
.add:focus-within { border-color: color-mix(in srgb, var(--accent) 55%, transparent); box-shadow: var(--ring); color: var(--accent); }
.add input { flex: 1; min-width: 0; border: 0; outline: none; background: none; font-size: 14px; }
.add input::placeholder { color: var(--fg-3); }
.add kbd { opacity: 0; transition: opacity 0.15s; }
.add:focus-within kbd { opacity: 1; }

.cols, .row { display: grid; grid-template-columns: 20px minmax(0, 1fr) 170px 165px 150px; align-items: center; gap: 14px; padding: 0 10px; }
.cols { padding-bottom: 6px; border-bottom: 1px solid var(--line); color: var(--fg-3); font-size: 11px; font-weight: 500; }

.group { display: grid; gap: 2px; margin-top: 18px; }
.group h3 { display: flex; gap: 6px; margin: 0 0 2px; padding: 0 10px; color: var(--fg-2); font-size: 12px; font-weight: 600; }
.group h3 .n { color: var(--fg-3); font-weight: 400; }
.group.urgent h3 { color: var(--red); }
.group.soon h3 { color: var(--amber); }

.row { min-height: 40px; border-radius: 8px; }
.row.urgent { background-color: color-mix(in srgb, var(--red) 8%, transparent); }
.row.soon { background-color: color-mix(in srgb, var(--amber) 8%, transparent); }
.row:hover { background-image: linear-gradient(var(--hover) 0 0); }
.row.selected { background-color: var(--selected); }

.check { flex: none; width: 18px; height: 18px; margin: 0; border: 1.5px solid var(--fg-3); border-radius: 50%; background: transparent center / 11px no-repeat; -webkit-appearance: none; appearance: none; transition: background-color 0.15s, border-color 0.15s; }
.check:hover { border-color: var(--accent); background-color: color-mix(in srgb, var(--accent) 12%, transparent); }
.check:checked { border-color: var(--accent); background-color: var(--accent); background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M2.5 6.2 5 8.6 9.6 3.6' fill='none' stroke='white' stroke-width='1.9' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E"); }
.row.urgent .check:not(:checked) { border-color: var(--red); }
.row.soon .check:not(:checked) { border-color: var(--amber); }

.title { display: flex; align-items: center; gap: 7px; min-width: 0; }
.name { overflow: hidden; font-size: 13.5px; text-overflow: ellipsis; white-space: nowrap; }
.title .icon { width: 13px; height: 13px; color: var(--fg-3); }
.row.done .name { color: var(--fg-3); text-decoration: line-through; }

.tag { display: inline-block; max-width: 100%; padding: 1px 8px; overflow: hidden; border-radius: 5px; background: color-mix(in srgb, var(--c) 15%, transparent); color: color-mix(in srgb, var(--c) 78%, var(--fg)); font-size: 12px; font-weight: 500; text-overflow: ellipsis; white-space: nowrap; vertical-align: middle; }

.due { display: flex; align-items: center; gap: 6px; color: var(--fg-2); white-space: nowrap; }
.due .icon { width: 14px; height: 14px; opacity: 0.75; }
.row.urgent .due, .due-text.urgent { color: var(--red); font-weight: 500; }
.row.soon .due, .due-text.soon { color: var(--amber); font-weight: 500; }
.row.done .due { color: var(--fg-3); font-weight: 400; }

.progress, .inline { display: flex; align-items: center; gap: 10px; }
.pct, output { min-width: 34px; color: var(--fg-2); font-size: 12px; font-variant-numeric: tabular-nums; text-align: right; }
.bar { flex: 1; min-width: 60px; height: 6px; margin: 0; border-radius: 3px; background: linear-gradient(var(--accent) 0 0) 0 / var(--p, 0%) 100% no-repeat, var(--track); -webkit-appearance: none; appearance: none; }
.bar::-webkit-slider-thumb { width: 14px; height: 14px; border-radius: 50%; background: #fff; box-shadow: 0 0 0 0.5px rgb(0 0 0 / 0.25), 0 1px 3px rgb(0 0 0 / 0.3); opacity: 0; transition: opacity 0.15s; -webkit-appearance: none; }
.row:hover .bar::-webkit-slider-thumb, .bar:focus-visible::-webkit-slider-thumb, #peek .bar::-webkit-slider-thumb { opacity: 1; }

@container (max-width: 760px) {
  .cols, .row { grid-template-columns: 20px minmax(0, 1fr) 150px 155px; }
  .cols > :nth-child(5), .row > :nth-child(5) { display: none; }
}
@container (max-width: 540px) {
  .cols, .row { grid-template-columns: 20px minmax(0, 1fr) max-content; } /* deadline never clips; the name shortens instead */
  .cols > :nth-child(3), .row > :nth-child(3) { display: none; }
}

/* ---------- task side panel ---------- */

#peek { display: flex; flex-direction: column; width: clamp(340px, 34vw, 460px); min-height: 0; background: var(--bg); border-left: 1px solid var(--line); animation: slide-in 0.18s ease-out; }
@keyframes slide-in { from { opacity: 0; transform: translateX(14px); } }
#peek header { display: flex; flex: none; align-items: center; justify-content: flex-end; gap: 4px; height: 52px; padding: 0 14px; }
.peek-body { display: flex; flex: 1; flex-direction: column; min-height: 0; padding: 0 28px 28px; overflow-y: auto; }
.peek-title { width: 100%; margin: 0 0 18px; padding: 0; border: 0; outline: none; background: none; font-size: 22px; font-weight: 700; letter-spacing: -0.01em; }
.peek-title::placeholder { color: var(--fg-3); }
.props { display: grid; grid-template-columns: 108px minmax(0, 1fr); align-items: center; gap: 2px 8px; }
.props > span { display: flex; align-items: center; gap: 8px; height: 32px; color: var(--fg-2); }
.props > span .icon { width: 15px; height: 15px; }
.props .inline { min-height: 32px; }
.props label.inline { gap: 8px; padding-left: 8px; color: var(--fg-2); }
.props .bar { margin-left: 8px; }
.section-label { margin: 22px 0 10px; padding-top: 18px; border-top: 1px solid var(--line); color: var(--fg-3); font-size: 11px; font-weight: 600; letter-spacing: 0.05em; text-transform: uppercase; }

/* A property value that opens a picker (group, deadline). */
.field { display: flex; align-items: center; gap: 6px; min-width: 0; height: 30px; padding: 0 8px; border-radius: 6px; text-align: left; transition: background 0.12s; }
.field:hover, .field:focus-visible { background: var(--hover); }
#p-group { anchor-name: --group-field; }
#p-due { anchor-name: --due-field; }

.icon-btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-width: 28px; height: 28px; padding: 0 6px; border-radius: 7px; color: var(--fg-2); }
.icon-btn:hover { background: var(--hover); color: var(--fg); }
.icon-btn.small { min-width: 24px; height: 24px; padding: 0; }
.icon-btn.small .icon { width: 14px; height: 14px; }
.icon-btn.danger:hover { color: var(--red); }
.armed { background: color-mix(in srgb, var(--red) 12%, transparent) !important; color: var(--red) !important; }
.armed::after { content: "Delete?"; font-size: 12px; font-weight: 600; }

/* ---------- popovers (group menu, date picker) ---------- */

.pop { position: fixed; inset: auto; margin: 6px 0 0; padding: 6px; overflow: visible; border: 1px solid var(--line-strong); border-radius: 12px; background: color-mix(in srgb, var(--raised) 92%, transparent); color: var(--fg); box-shadow: 0 12px 32px rgb(0 0 0 / 0.2), 0 2px 6px rgb(0 0 0 / 0.08); -webkit-backdrop-filter: blur(24px) saturate(1.6); backdrop-filter: blur(24px) saturate(1.6); top: anchor(bottom); right: anchor(right); position-try-fallbacks: flip-block; }
.pop:popover-open { animation: pop-in 0.12s ease-out; }
@keyframes pop-in { from { opacity: 0; transform: translateY(-4px) scale(0.98); } }
#group-pop { position-anchor: --group-field; }
#date-pop { position-anchor: --due-field; }

.menu { width: 250px; }
.menu input { width: 100%; height: 32px; margin-bottom: 4px; padding: 0 10px; border: 0; border-radius: 7px; outline: none; background: var(--hover); }
.menu input::placeholder { color: var(--fg-3); }
#group-opts { display: grid; max-height: 260px; overflow-y: auto; }
.opt { display: flex; align-items: center; gap: 8px; width: 100%; min-width: 0; height: 32px; padding: 0 8px; border-radius: 7px; text-align: left; }
.opt .icon { width: 14px; height: 14px; margin: 0 1px; color: var(--fg-2); }
.opt .label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.opt.active { background: var(--selected); }
.opt.current::after { content: "✓"; color: var(--accent); font-weight: 600; }
.menu-empty { margin: 0; padding: 10px; color: var(--fg-3); }

.datepicker { width: 284px; padding: 10px; }
.quick { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; margin-bottom: 8px; padding-bottom: 8px; border-bottom: 1px solid var(--line); }
.quick button { display: flex; align-items: center; justify-content: space-between; gap: 6px; height: 30px; padding: 0 9px; border-radius: 7px; background: var(--hover); font-weight: 500; white-space: nowrap; }
.quick button:hover { background: var(--selected); }
.quick button.on { background: var(--accent); color: #fff; }
.quick small { color: var(--fg-3); font-size: 11px; font-weight: 400; }
.quick button.on small { color: rgb(255 255 255 / 0.75); }
.cal-head { display: flex; align-items: center; justify-content: space-between; padding: 2px 0 6px; font-weight: 600; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.dow { height: 22px; color: var(--fg-3); font-size: 11px; font-weight: 500; line-height: 22px; text-align: center; }
.day { height: 32px; border-radius: 50%; font-variant-numeric: tabular-nums; transition: background 0.1s; }
.day:hover { background: var(--hover); }
.day.out { color: var(--fg-3); }
.day.today { color: var(--accent); font-weight: 700; }
.day.on { background: var(--accent); color: #fff; font-weight: 600; }
.cal-time { display: flex; align-items: center; gap: 8px; margin-top: 8px; padding-top: 10px; border-top: 1px solid var(--line); color: var(--fg-2); }
.cal-time input { flex: 1; }

/* ---------- inputs ---------- */

.cal-time input { min-width: 0; height: 30px; padding: 0 10px; border: 1px solid var(--line-strong); border-radius: 7px; outline: none; background: var(--bg); color: var(--fg); transition: border-color 0.15s, box-shadow 0.15s; }
.cal-time input::placeholder { color: var(--fg-3); }
.cal-time input:focus { border-color: color-mix(in srgb, var(--accent) 60%, transparent); box-shadow: var(--ring); }
.cal-time input:disabled { opacity: 0.5; }
.cal-time input.invalid { border-color: var(--red); animation: shake 0.3s; }
@keyframes shake { 25% { transform: translateX(-3px); } 75% { transform: translateX(3px); } }

.stepper { display: inline-flex; align-items: center; overflow: hidden; border: 1px solid var(--line-strong); border-radius: 7px; background: var(--bg); }
.stepper button { width: 28px; height: 28px; color: var(--fg-2); font-size: 15px; }
.stepper button:hover { background: var(--hover); color: var(--fg); }
.stepper output { min-width: 26px; color: var(--fg); font-size: 13px; text-align: center; }

.btn { height: 28px; padding: 0 12px; border: 1px solid var(--line-strong); border-radius: 7px; background: var(--bg); font-weight: 500; white-space: nowrap; }
.btn:hover { background: var(--hover); }

/* ---------- markdown editor (CodeMirror) ---------- */

.md { display: flex; flex: 1; flex-direction: column; min-height: 160px; -webkit-user-select: text; user-select: text; cursor: text; }
.md .cm-editor { flex: 1; }
#task-md .cm-content { min-height: 180px; }
#note-md { min-height: 0; }
#note-md .cm-editor { height: 100%; }
#note-md .cm-content { max-width: 760px; margin: 0 auto; padding: 4px 40px 160px; }

/* ---------- notes ---------- */

#view-notes { display: grid; grid-template-columns: 270px minmax(0, 1fr); overflow: hidden; }
.note-list { display: flex; flex-direction: column; min-height: 0; border-right: 1px solid var(--line); }
.note-list header, .note-pane header { display: flex; flex: none; align-items: center; justify-content: space-between; height: 52px; padding: 0 12px 0 20px; }
.note-list h2 { margin: 0; font-size: 15px; font-weight: 700; }
.note-pane { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.note-pane .meta { overflow: hidden; color: var(--fg-3); font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- settings ---------- */

#view-settings { padding: 0 36px 48px; }
#view-settings > * { max-width: 640px; }
#view-settings h3 { margin: 26px 0 8px 4px; color: var(--fg-2); font-size: 12px; font-weight: 600; }
.card { overflow: hidden; border: 1px solid var(--line); border-radius: 12px; background: var(--raised); }
.setting { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 50px; padding: 8px 16px; }
.setting + .setting { border-top: 1px solid var(--line); }
.setting small { display: block; margin-top: 1px; color: var(--fg-3); font-size: 11.5px; }
.setting .inline { gap: 8px; color: var(--fg-2); }
.segmented { display: inline-flex; padding: 2px; border-radius: 8px; background: var(--hover); }
.segmented button { padding: 4px 12px; border-radius: 6px; color: var(--fg-2); }
.segmented button.on { background: var(--seg-on); color: var(--fg); box-shadow: 0 1px 2px rgb(0 0 0 / 0.15); }
.swatches { display: flex; gap: 9px; }
.swatches.small { gap: 6px; }
.swatch { width: 20px; height: 20px; border-radius: 50%; background: var(--c); box-shadow: inset 0 0 0 1px rgb(0 0 0 / 0.12); transition: transform 0.1s; }
.swatches.small .swatch { width: 14px; height: 14px; }
.swatch:hover { transform: scale(1.15); }
.swatch.on { outline: 2px solid var(--c); outline-offset: 2px; }
.name-cell { display: flex; flex: 1; align-items: center; gap: 4px; min-width: 0; }
.name-cell small { margin: 0; white-space: nowrap; }
.rename { flex: 0 1 230px; min-width: 0; padding: 4px 6px; border: 0; border-radius: 6px; outline: none; background: none; font-weight: 500; }
.rename:hover, .rename:focus { background: var(--hover); }
.rename:focus { box-shadow: var(--ring); }

/* ---------- messages ---------- */

.toast { position: fixed; bottom: 18px; left: 50%; padding: 9px 14px; border-radius: 9px; background: var(--red); color: #fff; box-shadow: 0 6px 20px rgb(0 0 0 / 0.25); transform: translateX(-50%); }
.fatal { grid-column: 1 / -1; margin: 0; padding: 48px; background: var(--bg); color: var(--red); }

/* ---------- task toolbar: filter & sort ---------- */

.toolbar { display: flex; align-items: center; gap: 6px; margin: -8px 0 14px; }
.toolbar .grow { flex: 1; }
.tool { display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 10px; border: 1px solid var(--line); border-radius: 7px; color: var(--fg-2); font-weight: 500; transition: background 0.12s, color 0.12s; }
.tool:hover { background: var(--hover); color: var(--fg); }
.tool .icon { width: 14px; height: 14px; }
.tool.on { border-color: color-mix(in srgb, var(--accent) 45%, transparent); background: var(--selected); color: var(--accent); }
.tool.subtle { border-color: transparent; color: var(--fg-3); }
.badge { min-width: 16px; padding: 0 5px; border-radius: 8px; background: var(--accent); color: #fff; font-size: 11px; line-height: 16px; text-align: center; }
.badge:empty { display: none; }
#filter-btn { anchor-name: --filter-btn; }
#sort-btn { anchor-name: --sort-btn; }
#filter-pop { position-anchor: --filter-btn; }
#sort-pop { position-anchor: --sort-btn; }
.group h3 .dot { margin: 0 2px 0 0; align-self: center; }

.pop.left { right: auto; left: anchor(left); }
.pop.panel { width: 300px; padding: 4px 12px 12px; }
.pop.narrow { width: 200px; }
.pop-label { margin: 10px 2px 6px; color: var(--fg-3); font-size: 11px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; }
.pop-label small { margin-left: 4px; font-weight: 400; letter-spacing: 0; text-transform: none; }
.segmented.full { display: flex; }
.segmented.full button { flex: 1; }
#sort-dir { margin-top: 6px; }
.chips { display: flex; flex-wrap: wrap; gap: 4px; }
.chip { height: 26px; padding: 0 10px; border-radius: 13px; background: var(--hover); color: var(--fg-2); }
.chip:hover { color: var(--fg); }
.chip.on { background: var(--accent); color: #fff; }
.check-row { display: flex; align-items: center; gap: 8px; height: 30px; padding: 0 4px; border-radius: 6px; }
.check-row:hover { background: var(--hover); }
.check-row .label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.box { flex: none; width: 15px; height: 15px; margin: 0; border: 1.5px solid var(--fg-3); border-radius: 4px; background: transparent center / 10px no-repeat; -webkit-appearance: none; appearance: none; }
.box:checked { border-color: var(--accent); background-color: var(--accent); background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M2.5 6.2 5 8.6 9.6 3.6' fill='none' stroke='white' stroke-width='1.9' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E"); }

/* ---------- context menu ---------- */

#ctx-menu { width: auto; min-width: 200px; max-width: 320px; max-height: 70vh; margin: 0; overflow-y: auto; top: auto; right: auto; }
.menu hr { margin: 4px 6px; border: 0; border-top: 1px solid var(--line); }
.opt.danger, .opt.danger .icon { color: var(--red); }
.opt:hover { background: var(--selected); }
.opt.armed-opt { background: color-mix(in srgb, var(--red) 14%, transparent); font-weight: 600; }

/* ---------- notes tree ---------- */

.inline.tight { gap: 2px; }
#note-tree { flex: 1; min-height: 0; padding: 0 8px 24px; overflow-y: auto; border-radius: 8px; }
#note-tree.drop-root { box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--accent) 50%, transparent); }
.tree-row { display: flex; align-items: center; gap: 6px; height: 30px; padding: 0 6px 0 calc(6px + var(--depth, 0) * 16px); border-radius: 7px; white-space: nowrap; }
.tree-row:hover { background: var(--hover); }
.tree-row.selected { background: var(--selected); }
.tree-row.drop { background: var(--selected); box-shadow: inset 0 0 0 1.5px var(--accent); }
.tree-row > .icon { width: 15px; height: 15px; color: var(--fg-3); }
.tree-row.folder > .icon { color: var(--accent); }
.tree-row .label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.tree-row.folder .label { font-weight: 500; }
.tree-row small, .tree-row time { flex: none; color: var(--fg-3); font-size: 11px; }
.tree-row small { max-width: 40%; overflow: hidden; text-overflow: ellipsis; }
.chev { display: inline-flex; flex: none; width: 14px; color: var(--fg-3); }
.chev .icon { width: 12px; height: 12px; transition: transform 0.15s; }
.chev.open .icon { transform: rotate(90deg); }
.row-actions { display: none; flex: none; gap: 1px; }
.tree-row.folder:hover .row-actions { display: inline-flex; }
.tree-row.folder:hover time { display: none; }
.icon-btn.tiny { min-width: 22px; height: 22px; padding: 0; }
.icon-btn.tiny .icon { width: 13px; height: 13px; }
.tree-rename { flex: 1; min-width: 0; height: 24px; padding: 0 6px; border: 0; border-radius: 5px; outline: none; background: var(--bg); box-shadow: var(--ring); font-weight: 500; }

/* ---------- settings: groups & shortcuts ---------- */

.add-row { justify-content: flex-start; width: 100%; color: var(--accent); font-weight: 500; text-align: left; }
.add-row:hover { background: var(--hover); }
.add-row .icon { width: 15px; height: 15px; }
.shortcuts { display: grid; grid-template-columns: 1fr 1fr; gap: 0 28px; padding: 4px 16px 14px; }
.shortcut { display: flex; align-items: center; justify-content: space-between; gap: 8px; height: 28px; border-bottom: 1px solid var(--line); }
.shortcut kbd { color: var(--fg-2); font-size: 12px; }

/* ---------- web version (no title bar / traffic lights to leave room for) ---------- */

html.web .titlebar { height: 16px; }

/* ---------- login (server version) ---------- */

#login { position: fixed; inset: 0; z-index: 20; display: grid; place-items: center; padding: 24px; background: var(--bg); }
#login[hidden] { display: none; }
.login-card { display: grid; justify-items: center; gap: 12px; width: min(340px, 100%); text-align: center; }
.login-card img { border-radius: 14px; }
.login-card h1 { margin: 0; }
.login-card p { margin: 0; }
.login-card input[type="password"] { width: 100%; height: 40px; padding: 0 12px; border: 1px solid var(--line-strong); border-radius: 9px; outline: none; background: var(--raised); font-size: 15px; }
.login-card input[type="password"]:focus { border-color: color-mix(in srgb, var(--accent) 60%, transparent); box-shadow: var(--ring); }
.btn.primary { width: 100%; height: 40px; border-color: transparent; background: var(--accent); color: #fff; font-size: 15px; }
.btn.primary:hover { background: color-mix(in srgb, var(--accent) 88%, #000); }
.login-error { min-height: 1.4em; color: var(--red); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }

/* In a browser there's no translucent window behind the page. */
html.web body { background: var(--bg); }

/* ---------- touch screens: no hover, so show what hover would reveal ---------- */

@media (hover: none) {
  .tree-row .row-actions { display: inline-flex; }
  .tree-row time { display: none; }
  .bar::-webkit-slider-thumb { opacity: 1; }
}
@media (hover: hover) {
  .tree-row.note:hover .row-actions { display: inline-flex; }
  .tree-row.note:hover time { display: none; }
}

/* ---------- phones ---------- */

@media (max-width: 720px) {
  body { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr); }
  /* the sidebar becomes a top bar */
  .sidebar { flex-direction: row; align-items: center; gap: 4px; padding: calc(8px + env(safe-area-inset-top)) 10px 8px; overflow-x: auto; border-right: 0; border-bottom: 1px solid var(--line); }
  .titlebar, .grow { display: none; }
  .search { flex: 1; min-width: 90px; margin: 0 4px 0 0; }
  .sidebar nav { display: contents; }
  .nav { width: auto; flex: none; }
  .nav .count { display: none; }
  .nav[data-view="settings"] { font-size: 0; gap: 0; } /* icon only */
  #view-tasks, #view-settings { padding: 0 14px 40px; }
  .page-head { padding-top: 18px; }
  .cols { display: none; }
  /* the task panel covers the screen */
  #peek { position: fixed; inset: 0; z-index: 10; width: auto; padding-top: env(safe-area-inset-top); border-left: 0; }
  .peek-body { padding: 0 18px 28px; }
  /* notes: list above the editor */
  #view-notes { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr); }
  .note-list { max-height: 38vh; border-right: 0; border-bottom: 1px solid var(--line); }
  #note-md .cm-content { padding: 4px 16px 80px; }
  .shortcuts { grid-template-columns: 1fr; }
  .setting { flex-wrap: wrap; }
  /* iPhone zooms into any text field under 16px when you tap it */
  input, .md .cm-editor { font-size: 16px !important; }
}
