/* ============ tokens ============ */
:root {
  --font: "Segoe UI Variable Text", "Segoe UI Variable", "Segoe UI", system-ui, -apple-system, "SF Pro Text", Roboto, sans-serif;
  --font-display: "Segoe UI Variable Display", "Segoe UI Variable", "Segoe UI", system-ui, -apple-system, sans-serif;

  --bg: #fdfcfa;
  --surface: #ffffff;
  --sidebar: #f6f4f0;
  --text: #24211d;
  --text-2: #5f5a53;
  --muted: #8f8981;
  --hair: rgba(60, 45, 30, .09);
  --hair-strong: rgba(60, 45, 30, .16);
  --hover: rgba(60, 45, 30, .045);
  --press: rgba(60, 45, 30, .08);

  --accent: #d1493c;
  --accent-hover: #bd3c30;
  --accent-soft: rgba(209, 73, 60, .09);
  --accent-text: #b8392d;

  --p1: #d1453b; --p2: #e08a12; --p3: #2f6fdb; --p4: #9c968e;
  --green: #1f8a4c; --violet: #7a5af0;

  --shadow-sm: 0 1px 2px rgba(50, 35, 20, .06);
  --shadow-lg: 0 24px 60px -12px rgba(50, 35, 20, .28), 0 2px 6px rgba(50, 35, 20, .06);
  --ring: 0 0 0 2px var(--bg), 0 0 0 4px rgba(209, 73, 60, .45);

  --r-sm: 6px; --r-md: 10px; --r-lg: 16px;
  --ease: cubic-bezier(.2, .7, .2, 1);
  --spring: cubic-bezier(.34, 1.4, .5, 1);
  --z-sidebar: 20; --z-overlay: 40; --z-toast: 50;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #1a1918; --surface: #232220; --sidebar: #201f1d; --text: #ece8e2; --text-2: #b9b3aa; --muted: #8a847b;
    --hair: rgba(255, 245, 230, .07); --hair-strong: rgba(255, 245, 230, .13); --hover: rgba(255, 245, 230, .045); --press: rgba(255, 245, 230, .08);
    --accent: #e0594b; --accent-hover: #ea6a5d; --accent-soft: rgba(224, 89, 75, .14); --accent-text: #f08174;
    --p1: #f0675c; --p2: #f0a033; --p3: #5b93f0; --p4: #8a847b; --green: #4fbf7b;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .3); --shadow-lg: 0 28px 70px -10px rgba(0, 0, 0, .65), 0 0 0 1px rgba(255, 245, 230, .06);
    --ring: 0 0 0 2px var(--bg), 0 0 0 4px rgba(240, 120, 105, .55);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #1a1918; --surface: #232220; --sidebar: #201f1d; --text: #ece8e2; --text-2: #b9b3aa; --muted: #8a847b;
  --hair: rgba(255, 245, 230, .07); --hair-strong: rgba(255, 245, 230, .13); --hover: rgba(255, 245, 230, .045); --press: rgba(255, 245, 230, .08);
  --accent: #e0594b; --accent-hover: #ea6a5d; --accent-soft: rgba(224, 89, 75, .14); --accent-text: #f08174;
  --p1: #f0675c; --p2: #f0a033; --p3: #5b93f0; --p4: #8a847b; --green: #4fbf7b;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .3); --shadow-lg: 0 28px 70px -10px rgba(0, 0, 0, .65), 0 0 0 1px rgba(255, 245, 230, .06);
  --ring: 0 0 0 2px var(--bg), 0 0 0 4px rgba(240, 120, 105, .55);
  color-scheme: dark;
}

/* ============ base ============ */
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg); color: var(--text);
  font: 14px/1.5 var(--font); -webkit-font-smoothing: antialiased;
  font-feature-settings: "ss01", "cv11"; overflow: hidden;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { -webkit-tap-highlight-color: transparent; }
::selection { background: var(--accent-soft); color: var(--text); }
:focus { outline: none; }
:focus-visible { box-shadow: var(--ring); border-radius: var(--r-sm); }
input:focus-visible, textarea:focus-visible, select:focus-visible { box-shadow: none; }
.ico { width: 18px; height: 18px; flex-shrink: 0; display: block; }
kbd {
  font: 500 11px/1 var(--font); color: var(--muted); background: var(--surface);
  border: 1px solid var(--hair-strong); border-bottom-width: 2px; border-radius: 5px; padding: 3px 5px; min-width: 18px; text-align: center;
}
.skip-link { position: absolute; left: 12px; top: -40px; z-index: 100; background: var(--surface); padding: 8px 12px; border-radius: var(--r-sm); box-shadow: var(--shadow-lg); transition: top .2s var(--ease); }
.skip-link:focus { top: 12px; }
.spacer { flex: 1; }
[hidden] { display: none !important; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--hair-strong); border-radius: 10px; border: 3px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background-color: var(--muted); }

/* ============ buttons ============ */
.icon-btn {
  display: inline-grid; place-items: center; width: 30px; height: 30px; border: 0; border-radius: var(--r-sm);
  background: none; color: var(--muted); cursor: pointer;
  transition: background .15s var(--ease), color .15s var(--ease), transform .15s var(--ease);
}
.icon-btn:hover { background: var(--hover); color: var(--text); }
.icon-btn:active { background: var(--press); transform: scale(.94); }
.icon-btn.sm { width: 24px; height: 24px; }
.icon-btn.sm .ico { width: 15px; height: 15px; }
.icon-btn.danger:hover { color: var(--p1); background: color-mix(in srgb, var(--p1) 10%, transparent); }

.btn {
  height: 34px; padding: 0 14px; border: 0; border-radius: var(--r-sm); cursor: pointer; font-weight: 600; font-size: 13px;
  background: var(--hover); color: var(--text);
  transition: background .15s var(--ease), transform .12s var(--ease), box-shadow .15s var(--ease), opacity .15s;
}
.btn:hover { background: var(--press); }
.btn:active { transform: translateY(1px) scale(.98); }
.btn.primary { background: var(--accent); color: #fff; box-shadow: 0 1px 0 rgba(255,255,255,.18) inset, 0 4px 12px -4px color-mix(in srgb, var(--accent) 60%, transparent); }
.btn.primary:hover { background: var(--accent-hover); }
.btn.primary:disabled { opacity: .45; cursor: default; transform: none; box-shadow: none; }
.btn.danger-fill { background: var(--p1); color: #fff; }
.btn.danger-fill:hover { filter: brightness(1.06); }

.chip-btn {
  display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 10px; border-radius: var(--r-sm);
  border: 1px solid var(--hair-strong); background: var(--surface); color: var(--text-2); font-size: 12.5px; font-weight: 500; cursor: pointer;
  transition: all .15s var(--ease);
}
.chip-btn .ico { width: 15px; height: 15px; }
.chip-btn:hover { color: var(--text); border-color: var(--muted); }
.chip-btn[aria-pressed="true"] { background: var(--accent-soft); border-color: transparent; color: var(--accent-text); }

/* ============ layout ============ */
.layout { display: flex; height: 100dvh; }
.sidebar {
  width: 272px; flex-shrink: 0; background: var(--sidebar); padding: 12px 10px 24px;
  overflow-y: auto; border-right: 1px solid var(--hair);
  display: flex; flex-direction: column; gap: 2px;
  transition: margin-left .28s var(--ease), transform .28s var(--ease);
}
body.sidebar-hidden .sidebar { margin-left: -272px; }
.sidebar-top { display: flex; align-items: center; gap: 2px; padding: 2px 2px 10px 6px; }
.brand { display: flex; align-items: center; gap: 9px; flex: 1; font: 650 15px/1 var(--font-display); letter-spacing: -.01em; }
.brand-mark {
  width: 26px; height: 26px; border-radius: 8px; display: grid; place-items: center; color: #fff;
  background: linear-gradient(160deg, color-mix(in srgb, var(--accent) 85%, #fff), var(--accent));
  box-shadow: 0 1px 0 rgba(255,255,255,.25) inset, 0 3px 8px -2px color-mix(in srgb, var(--accent) 55%, transparent);
}
.brand-mark .ico { width: 15px; height: 15px; stroke-width: 2.6; }

.add-task-btn {
  display: flex; align-items: center; gap: 10px; width: 100%; height: 36px; padding: 0 8px; border: 0; border-radius: var(--r-sm);
  background: none; color: var(--accent-text); font-weight: 600; cursor: pointer; transition: background .15s var(--ease);
}
.add-task-btn:hover { background: var(--accent-soft); }
.add-task-btn:active .add-dot { transform: scale(.9); }
.add-task-btn kbd { margin-left: auto; opacity: 0; transition: opacity .15s; }
.add-task-btn:hover kbd { opacity: 1; }
.add-dot {
  width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; background: var(--accent); color: #fff;
  transition: transform .2s var(--spring);
}
.add-dot .ico { width: 14px; height: 14px; stroke-width: 2.4; }
.add-task-btn:hover .add-dot { transform: rotate(90deg); }

.search {
  display: flex; align-items: center; gap: 8px; height: 34px; padding: 0 8px; margin: 4px 0 10px; border-radius: var(--r-sm);
  color: var(--muted); border: 1px solid transparent; transition: background .15s, border-color .15s;
}
.search:hover { background: var(--hover); }
.search:focus-within { background: var(--surface); border-color: var(--hair-strong); box-shadow: var(--shadow-sm); }
.search .ico { width: 16px; height: 16px; }
.search input { flex: 1; min-width: 0; border: 0; background: none; outline: none; color: var(--text); }
.search input::placeholder { color: var(--muted); }
.search input::-webkit-search-cancel-button { display: none; }
.search:focus-within kbd { opacity: 0; }

.nav-section { margin-top: 18px; }
.nav-section[hidden] { display: none; }
.nav-heading {
  display: flex; justify-content: space-between; align-items: center; height: 28px; padding: 0 4px 0 10px;
  color: var(--muted); font-weight: 600; font-size: 12px; letter-spacing: .01em;
}
.nav-heading .icon-btn { opacity: 0; }
.nav-section:hover .nav-heading .icon-btn, .nav-heading .icon-btn:focus-visible { opacity: 1; }
.nav { display: flex; flex-direction: column; gap: 1px; }
.nav-item {
  position: relative; display: flex; align-items: center; gap: 10px; height: 34px; padding: 0 10px; border-radius: var(--r-sm);
  color: var(--text-2); text-decoration: none; font-weight: 500;
  transition: background .15s var(--ease), color .15s var(--ease);
}
.nav-item:hover { background: var(--hover); color: var(--text); }
.nav-item:active { background: var(--press); }
.nav-item.active { background: var(--accent-soft); color: var(--accent-text); }
.nav-item.active .count { color: var(--accent-text); }
.nav-icon { width: 20px; display: grid; place-items: center; }
.nav-icon .ico { width: 18px; height: 18px; }
.nav-item .i-inbox { color: #2f6fdb; } .nav-item .i-today { color: var(--green); } .nav-item .i-upcoming { color: var(--violet); } .nav-item .i-done { color: #d9822b; }
.nav-item.active .nav-icon .ico { color: currentColor; }
.today-num { position: relative; display: grid; place-items: center; }
.today-num b { position: absolute; top: 7px; font-size: 8.5px; font-weight: 700; line-height: 1; }
.nav-label { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.count { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.proj-hash .ico { width: 16px; height: 16px; stroke-width: 2; }

.new-project { display: flex; align-items: center; gap: 10px; height: 34px; padding: 0 10px; margin-bottom: 2px; border-radius: var(--r-sm); background: var(--surface); box-shadow: 0 0 0 1px var(--hair-strong), var(--shadow-sm); animation: pop .22s var(--spring); }
.new-project[hidden] { display: none; }
.new-project input { flex: 1; min-width: 0; border: 0; background: none; outline: none; }
.dot-preview { width: 10px; height: 10px; border-radius: 50%; margin: 0 5px; }

/* ============ main ============ */
.main { flex: 1; min-width: 0; overflow-y: auto; scroll-behavior: smooth; padding: 0 clamp(16px, 5vw, 56px) 120px; }
.view-header {
  position: sticky; top: 0; z-index: 5; display: flex; align-items: flex-end; gap: 10px;
  max-width: 820px; margin: 0 auto; padding: 36px 0 14px;
  background: linear-gradient(var(--bg) 78%, color-mix(in srgb, var(--bg) 0%, transparent));
}
.view-titles { flex: 1; min-width: 0; }
.view-header h1 { margin: 0; font: 700 26px/1.15 var(--font-display); letter-spacing: -.02em; text-wrap: balance; }
.view-sub { margin: 4px 0 0; color: var(--muted); font-size: 12.5px; }
.view-sub:empty { display: none; }
.view-actions { display: flex; align-items: center; gap: 6px; }
.menu-btn { display: none; }
body.sidebar-hidden .menu-btn { display: inline-grid; }
.task-area { max-width: 820px; margin: 0 auto; }

/* groups */
.group + .group { margin-top: 22px; }
.group-head { display: flex; align-items: baseline; gap: 8px; padding: 0 2px 8px; border-bottom: 1px solid var(--hair); }
.group-head h2 { margin: 0; font-size: 13.5px; font-weight: 650; }
.group-head .sub { color: var(--muted); font-size: 12px; }
.group-head .count { margin-left: auto; }
.group-head.overdue h2 { color: var(--p1); }
.group-head.is-today h2 { color: var(--green); }
.task-list { list-style: none; margin: 0; padding: 0; min-height: 6px; }

/* ============ task row ============ */
.task {
  position: relative; display: flex; align-items: flex-start; gap: 12px; padding: 11px 8px 11px 6px; margin: 0 -8px 0 -6px;
  border-radius: var(--r-md); cursor: pointer;
  transition: background .15s var(--ease), opacity .25s var(--ease), transform .25s var(--ease);
}
.task::after { content: ""; position: absolute; left: 38px; right: 8px; bottom: 0; height: 1px; background: var(--hair); transition: opacity .15s; }
.task:hover { background: var(--hover); }
.task:hover::after, .task.selected::after { opacity: 0; }
.task.selected { background: var(--accent-soft); box-shadow: inset 2px 0 0 var(--accent); }
.task.enter { animation: rowIn .38s var(--ease) both; animation-delay: calc(var(--i, 0) * 22ms); }
.task.added { animation: rowAdded 1.1s var(--ease); }
.task.dragging { opacity: .5; background: var(--surface); box-shadow: var(--shadow-lg); }
.task.leaving { opacity: 0; transform: translateX(14px); }
.task-wrap { display: grid; grid-template-rows: 1fr; transition: grid-template-rows .28s var(--ease); }
.task-wrap.collapse { grid-template-rows: 0fr; }
.task-wrap > .task { min-height: 0; overflow: hidden; }

/* checkbox */
.check {
  --c: var(--p4);
  position: relative; flex-shrink: 0; width: 20px; height: 20px; margin-top: 1px; padding: 0; border: 0; border-radius: 50%;
  background: none; cursor: pointer; color: var(--c);
}
.check svg { width: 20px; height: 20px; display: block; overflow: visible; }
.check .ring { fill: color-mix(in srgb, var(--c) 0%, transparent); stroke: var(--c); stroke-width: 1.6; transition: fill .2s var(--ease), stroke-width .15s; }
.check .tick { fill: none; stroke: var(--c); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; stroke-dasharray: 14; stroke-dashoffset: 14; opacity: 0; transition: stroke-dashoffset .25s var(--ease), opacity .15s; }
.p1 .check { --c: var(--p1); } .p2 .check { --c: var(--p2); } .p3 .check { --c: var(--p3); }
.p1 .check .ring, .p2 .check .ring, .p3 .check .ring { fill: color-mix(in srgb, var(--c) 12%, transparent); stroke-width: 2; }
.check:hover .tick { opacity: .9; stroke-dashoffset: 0; }
.check:active { transform: scale(.88); }
.check.checked .ring, .done .check .ring { fill: var(--c); stroke: var(--c); }
.check.checked .tick, .done .check .tick { stroke: #fff; opacity: 1; stroke-dashoffset: 0; }
.check.checked { animation: checkPop .35s var(--spring); }
.check.checked::before {
  content: ""; position: absolute; inset: -6px; border-radius: 50%; border: 2px solid var(--c); opacity: 0;
  animation: burst .45s var(--ease);
}

.task-body { flex: 1; min-width: 0; }
.task-title { line-height: 1.4; word-break: break-word; transition: color .2s; }
.done .task-title { color: var(--muted); text-decoration: line-through; text-decoration-color: var(--hair-strong); }
.task-desc { margin-top: 2px; color: var(--muted); font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.task-desc:empty { display: none; }
.task-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; margin-top: 5px; font-size: 12px; color: var(--muted); }
.task-meta:empty { display: none; }
.meta { display: inline-flex; align-items: center; gap: 4px; }
.meta .ico { width: 13px; height: 13px; }
.meta.today { color: var(--green); } .meta.overdue { color: var(--p1); } .meta.soon { color: var(--violet); }
.meta.label { color: var(--text-2); }
.meta.label .ico { color: var(--muted); }
.meta.proj { margin-left: auto; }
.meta.proj .ico { color: var(--pc, var(--muted)); stroke-width: 2.2; }

.row-actions { display: flex; gap: 2px; margin: -4px 0 -4px; opacity: 0; transform: translateX(4px); transition: opacity .15s var(--ease), transform .15s var(--ease); }
.task:hover .row-actions, .task.selected .row-actions, .task:focus-within .row-actions { opacity: 1; transform: none; }
.row-actions .icon-btn { width: 28px; height: 28px; }
.row-actions .ico { width: 16px; height: 16px; }

.drop-hint { box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--accent) 45%, transparent); border-radius: var(--r-md); background: var(--accent-soft); }

.mini-add {
  display: flex; align-items: center; gap: 10px; width: 100%; height: 36px; padding: 0 6px; border: 0; background: none;
  color: var(--muted); cursor: pointer; border-radius: var(--r-md); transition: color .15s;
}
.mini-add .add-dot { width: 20px; height: 20px; background: none; color: var(--accent); }
.mini-add:hover { color: var(--accent-text); }
.mini-add:hover .add-dot { background: var(--accent); color: #fff; }

/* inline add */
.inline-add {
  display: flex; align-items: center; gap: 12px; max-width: 820px; margin: 10px auto 0; height: 42px; padding: 0 10px 0 6px;
  border-radius: var(--r-md); border: 1px solid transparent; transition: border-color .2s, background .2s, box-shadow .2s;
}
.inline-add[hidden] { display: none; }
.inline-add:hover { background: var(--hover); }
.inline-add:focus-within { background: var(--surface); border-color: var(--hair-strong); box-shadow: var(--shadow-sm); }
.add-dot.ghost { width: 20px; height: 20px; background: none; color: var(--accent); }
.inline-add:hover .add-dot.ghost, .inline-add:focus-within .add-dot.ghost { background: var(--accent); color: #fff; }
.inline-add input { flex: 1; min-width: 0; border: 0; background: none; outline: none; }
.inline-add input::placeholder { color: var(--muted); }
.inline-hint { color: var(--muted); font-size: 12px; opacity: 0; white-space: nowrap; transition: opacity .2s; }
.inline-add:focus-within .inline-hint { opacity: 1; }

/* empty */
.empty { display: grid; justify-items: center; gap: 6px; padding: 72px 0 40px; text-align: center; animation: fadeUp .5s var(--ease) both; }
.empty-art {
  width: 88px; height: 88px; border-radius: 28px; display: grid; place-items: center; margin-bottom: 10px; color: var(--green);
  background: radial-gradient(circle at 30% 25%, color-mix(in srgb, var(--green) 22%, transparent), color-mix(in srgb, var(--green) 6%, transparent) 70%);
}
.empty-art .ico { width: 40px; height: 40px; stroke-width: 1.4; }
.empty h3 { margin: 0; font-size: 15px; font-weight: 650; }
.empty p { margin: 0; color: var(--muted); max-width: 36ch; }

/* ============ overlays ============ */
.overlay {
  position: fixed; inset: 0; z-index: var(--z-overlay); display: flex; align-items: flex-start; justify-content: center;
  padding: 13vh 16px 16px; background: rgba(25, 18, 10, .32); backdrop-filter: blur(3px);
  animation: fadeIn .18s var(--ease);
}
.overlay[hidden] { display: none; }
.overlay.closing { animation: fadeOut .16s var(--ease) forwards; }
.overlay.closing .sheet { animation: sheetOut .16s var(--ease) forwards; }
.sheet {
  width: min(580px, 100%); background: var(--surface); border-radius: var(--r-lg); box-shadow: var(--shadow-lg);
  border: 1px solid var(--hair); animation: sheetIn .32s var(--spring);
}
.sheet-foot { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-top: 1px solid var(--hair); }

.quick { padding-top: 14px; }
.title-input { display: block; width: 100%; border: 0; background: none; outline: none; padding: 0 18px; font: 600 17px/1.4 var(--font-display); letter-spacing: -.01em; }
.title-input::placeholder { color: var(--muted); font-weight: 500; }
.desc-input { display: block; width: 100%; border: 0; background: none; outline: none; resize: none; padding: 4px 18px 0; color: var(--text-2); font-size: 13.5px; }
.desc-input::placeholder { color: var(--muted); }
.token-row { display: flex; flex-wrap: wrap; gap: 6px; padding: 8px 18px 0; min-height: 8px; }
.token { display: inline-flex; align-items: center; gap: 4px; height: 22px; padding: 0 8px; border-radius: 6px; font-size: 12px; font-weight: 600; background: var(--accent-soft); color: var(--accent-text); animation: pop .25s var(--spring); }
.token .ico { width: 13px; height: 13px; }
.chip-row { display: flex; flex-wrap: wrap; gap: 8px; padding: 12px 18px 14px; }

.chip, .prop-field {
  position: relative; display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 10px;
  border: 1px solid var(--hair-strong); border-radius: var(--r-sm); color: var(--text-2); font-size: 12.5px; font-weight: 500;
  cursor: pointer; transition: border-color .15s, background .15s, color .15s;
}
.chip:hover, .prop-field:hover { background: var(--hover); color: var(--text); }
.chip:focus-within, .prop-field:focus-within { border-color: var(--muted); box-shadow: var(--ring); }
.chip .ico, .prop-field .ico { width: 15px; height: 15px; }
.chip.ghost { border-color: transparent; }
.chip select, .chip input, .prop-field select, .prop-field input {
  border: 0; background: none; outline: none; padding: 0; font-size: 12.5px; font-weight: 500; color: inherit; cursor: pointer; appearance: none; min-width: 0;
}
.chip input[type="date"]::-webkit-calendar-picker-indicator, .prop-field input[type="date"]::-webkit-calendar-picker-indicator { opacity: .5; cursor: pointer; filter: var(--picker-filter, none); }
:root[data-theme="dark"] { --picker-filter: invert(1); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --picker-filter: invert(1); } }
select option { background: var(--surface); color: var(--text); }
[data-prio="1"] .ico { color: var(--p1); } [data-prio="2"] .ico { color: var(--p2); } [data-prio="3"] .ico { color: var(--p3); }

/* detail */
.detail { width: min(820px, 100%); }
.detail-head { display: flex; align-items: center; gap: 4px; padding: 10px 10px 10px 18px; border-bottom: 1px solid var(--hair); }
.crumb { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 12.5px; font-weight: 500; }
.crumb .ico { width: 14px; height: 14px; }
.detail-body { display: grid; grid-template-columns: 1fr 250px; min-height: 340px; }
.detail-main { padding: 18px 0 18px; min-width: 0; }
.detail-main .title-input { font-size: 20px; }
.desc-wrap { display: flex; gap: 8px; align-items: flex-start; padding: 8px 18px 0; color: var(--muted); }
.desc-wrap .ico { width: 16px; height: 16px; margin-top: 3px; }
.desc-wrap .desc-input { padding: 0; }
.sub-heading { display: flex; align-items: center; gap: 8px; margin: 22px 18px 6px; font-size: 12.5px; font-weight: 650; color: var(--text-2); }
.sub-heading .ico { width: 16px; height: 16px; color: var(--muted); }
.sub-heading span { color: var(--muted); font-weight: 500; }
.subtasks { list-style: none; margin: 0; padding: 0 10px; }
.subtasks li { display: flex; align-items: center; gap: 10px; padding: 7px 8px; border-radius: var(--r-sm); animation: fadeUp .25s var(--ease) both; }
.subtasks li:hover { background: var(--hover); }
.subtasks li .check { width: 18px; height: 18px; margin: 0; }
.subtasks li .check svg { width: 18px; height: 18px; }
.subtasks li span { flex: 1; }
.subtasks li.done span { color: var(--muted); text-decoration: line-through; }
.subtasks li .icon-btn { opacity: 0; width: 24px; height: 24px; }
.subtasks li:hover .icon-btn { opacity: 1; }
.sub-add { display: flex; align-items: center; gap: 10px; margin: 2px 10px 0; padding: 0 8px; height: 34px; border-radius: var(--r-sm); color: var(--accent); }
.sub-add:focus-within { background: var(--hover); }
.sub-add input { flex: 1; border: 0; background: none; outline: none; color: var(--text); }
.sub-add input::placeholder { color: var(--muted); }
.detail-props { background: color-mix(in srgb, var(--sidebar) 60%, var(--surface)); border-left: 1px solid var(--hair); padding: 14px; display: flex; flex-direction: column; gap: 12px; }
.prop { display: flex; flex-direction: column; gap: 5px; }
.prop > span:first-child { font-size: 11.5px; font-weight: 600; color: var(--muted); padding-left: 2px; }
.prop-field { width: 100%; background: var(--surface); }
.prop-field select, .prop-field input { flex: 1; }

/* confirm */
.confirm { width: min(400px, 100%); }
.confirm h2 { margin: 0; padding: 20px 20px 6px; font-size: 16px; font-weight: 650; }
.confirm p { margin: 0; padding: 0 20px 18px; color: var(--text-2); }

/* toast */
.toast {
  position: fixed; left: 50%; bottom: 24px; z-index: var(--z-toast);
  display: flex; align-items: center; gap: 10px; padding: 8px 8px 8px 12px; border-radius: 12px;
  background: #2a2724; color: #f3efe9; box-shadow: 0 16px 40px -8px rgba(0, 0, 0, .45);
  transform: translate(-50%, 140%); opacity: 0; pointer-events: none;
  transition: transform .35s var(--spring), opacity .2s var(--ease);
}
.toast.show { transform: translate(-50%, 0); opacity: 1; pointer-events: auto; }
.toast-ico { width: 20px; height: 20px; border-radius: 50%; display: grid; place-items: center; background: #3fa66b; color: #fff; }
.toast-ico .ico { width: 13px; height: 13px; stroke-width: 2.6; }
.toast button#toastUndo { height: 28px; padding: 0 10px; border: 0; border-radius: 6px; background: rgba(255,255,255,.08); color: #ffb1a6; font-weight: 600; cursor: pointer; transition: background .15s; }
.toast button#toastUndo:hover { background: rgba(255,255,255,.14); }
.toast button#toastUndo[hidden] { display: none; }
.toast .icon-btn { color: #a9a29a; }
.toast .icon-btn:hover { background: rgba(255,255,255,.08); color: #fff; }

.scrim { display: none; }

/* ============ motion ============ */
@keyframes rowIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes rowAdded { 0% { background: var(--accent-soft); } 100% { background: transparent; } }
@keyframes fadeIn { from { opacity: 0; } }
@keyframes fadeOut { to { opacity: 0; } }
@keyframes fadeUp { from { opacity: 0; transform: translateY(8px); } }
@keyframes sheetIn { from { opacity: 0; transform: translateY(14px) scale(.97); } }
@keyframes sheetOut { to { opacity: 0; transform: translateY(8px) scale(.98); } }
@keyframes pop { from { opacity: 0; transform: scale(.85); } }
@keyframes checkPop { 0% { transform: scale(1); } 40% { transform: scale(1.22); } 100% { transform: scale(1); } }
@keyframes burst { 0% { opacity: .6; transform: scale(.6); } 100% { opacity: 0; transform: scale(1.35); } }
@keyframes viewIn { from { opacity: 0; transform: translateY(4px); } }
.view-header h1.swap { animation: viewIn .3s var(--ease); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

/* ============ responsive ============ */
@media (max-width: 820px) {
  .sidebar { position: fixed; inset: 0 auto 0 0; z-index: var(--z-sidebar); transform: translateX(-100%); box-shadow: var(--shadow-lg); margin-left: 0 !important; }
  body.nav-open .sidebar { transform: none; }
  .scrim { display: block; position: fixed; inset: 0; z-index: calc(var(--z-sidebar) - 1); background: rgba(25, 18, 10, .3); opacity: 0; pointer-events: none; transition: opacity .25s; }
  body.nav-open .scrim { opacity: 1; pointer-events: auto; }
  .menu-btn { display: inline-grid; }
  #collapseBtn { display: none; }
  .view-header { padding-top: 18px; }
  .chip-btn span { display: none; }
  .detail-body { grid-template-columns: 1fr; }
  .detail-props { border-left: 0; border-top: 1px solid var(--hair); display: grid; grid-template-columns: 1fr 1fr; }
  .overlay { padding-top: 6vh; }
  .inline-hint { display: none; }

  /* phones: notch / home-indicator safe areas */
  .sidebar { padding-top: calc(12px + env(safe-area-inset-top)); padding-bottom: calc(24px + env(safe-area-inset-bottom)); padding-left: calc(10px + env(safe-area-inset-left)); }
  .sidebar { box-shadow: none; }
  body.nav-open .sidebar { box-shadow: var(--shadow-lg); }
  /* column layout so the add bar sits at the bottom even when the list is short */
  .main { display: flex; flex-direction: column; padding-bottom: 0; padding-left: max(16px, env(safe-area-inset-left)); padding-right: max(16px, env(safe-area-inset-right)); }
  .view-header, .task-area { width: 100%; }
  .task-area { flex: 1 0 auto; }
  .view-header { padding-top: calc(14px + env(safe-area-inset-top)); }
  .task-area { padding-bottom: 24px; }
  .inline-add {
    position: sticky; bottom: 0; z-index: 4; height: auto; min-height: 52px; margin-top: 0;
    padding: 6px 10px calc(6px + env(safe-area-inset-bottom)) 8px;
    background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(12px);
    border: 0; border-top: 1px solid var(--hair); border-radius: 0; margin-left: -16px; margin-right: -16px;
  }
  .inline-add:hover, .inline-add:focus-within { background: color-mix(in srgb, var(--surface) 94%, transparent); border-color: var(--hair-strong); box-shadow: none; }
  .add-dot.ghost { background: var(--accent); color: #fff; width: 26px; height: 26px; }
  .toast { bottom: calc(68px + env(safe-area-inset-bottom)); max-width: calc(100% - 24px); }
  .overlay { padding-bottom: calc(16px + env(safe-area-inset-bottom)); }
  .sheet { max-height: calc(100dvh - 6vh - env(safe-area-inset-top) - env(safe-area-inset-bottom) - 16px); overflow-y: auto; }
  /* 16px fields stop iOS Safari from zooming in on focus */
  input, textarea, select, .chip select, .chip input, .prop-field select, .prop-field input { font-size: 16px; }
}

/* touch screens: no hover-only affordances, bigger hit areas */
@media (hover: none) {
  .row-actions, .task .del { display: none; }
  .task { padding-top: 13px; padding-bottom: 13px; }
  .check::after { content: ""; position: absolute; inset: -10px; }
  .add-task-btn kbd, .search kbd { display: none; }
  .nav-heading .icon-btn { opacity: 1; }
  .task:hover { background: none; }
  .task:active { background: var(--hover); }
}

/* ============ phone sync ============ */
.sync-card {
  margin-top: auto; display: flex; align-items: center; gap: 10px; padding: 10px 10px 10px 12px;
  border-radius: var(--r-md); background: var(--surface); box-shadow: 0 0 0 1px var(--hair), var(--shadow-sm);
}
.sync-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; background: var(--muted); transition: background .3s; }
.sync-dot.ok { background: var(--green); box-shadow: 0 0 0 3px color-mix(in srgb, var(--green) 18%, transparent); }
.sync-dot.busy { background: var(--p2); animation: pulse 1s var(--ease) infinite; }
.sync-dot.off { background: var(--p1); }
.sync-text { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.3; }
.sync-text b { font-size: 12.5px; font-weight: 600; }
.sync-text span { font-size: 11.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@keyframes pulse { 50% { opacity: .35; } }

.pair { width: min(640px, 100%); }
.pair-body { display: grid; grid-template-columns: 220px 1fr; gap: 22px; padding: 22px; align-items: center; }
.qr-wrap { background: #fff; border-radius: var(--r-md); padding: 10px; box-shadow: 0 0 0 1px var(--hair-strong); aspect-ratio: 1; display: grid; place-items: center; }
.qr-wrap img { width: 100%; height: 100%; image-rendering: pixelated; display: block; }
.pair-steps h2 { margin: 0 0 10px; font: 650 17px/1.3 var(--font-display); letter-spacing: -.01em; }
.pair-steps ol { margin: 0 0 12px; padding-left: 18px; color: var(--text-2); display: grid; gap: 6px; }
.pair-url { margin: 0 0 8px; color: var(--muted); font-size: 12.5px; }
.pair-url code { color: var(--text); background: var(--hover); padding: 1px 6px; border-radius: 5px; user-select: all; }
.pair-note { margin: 0; color: var(--muted); font-size: 12px; }
@media (max-width: 820px) { .pair-body { grid-template-columns: 1fr; justify-items: center; } .qr-wrap { width: 220px; } }
.pair-app { margin: 0 0 12px; padding: 12px; border-radius: var(--r-md); background: var(--hover); font-size: 13px; color: var(--text-2); }
.pair-app b { color: var(--text); }
.pair-fields { display: flex; gap: 10px; margin: 10px 0 6px; flex-wrap: wrap; }
.pair-fields span { display: flex; flex-direction: column; gap: 3px; }
.pair-fields small, .pair-expire { color: var(--muted); font-size: 11.5px; }
.pair-fields code { font: 600 15px/1 ui-monospace, "Cascadia Mono", Consolas, monospace; background: var(--surface); padding: 7px 10px; border-radius: 6px; box-shadow: 0 0 0 1px var(--hair-strong); user-select: all; }
.pair-fields code.code { letter-spacing: .18em; color: var(--accent-text); }
.connect { width: min(440px, 100%); }
.connect-body { padding: 18px; display: grid; gap: 14px; }
.connect-body > p { margin: 0; color: var(--text-2); font-size: 13.5px; }
.field { display: grid; gap: 6px; }
.field > span { font-size: 12px; font-weight: 600; color: var(--muted); }
.field input {
  height: 42px; padding: 0 12px; border-radius: var(--r-sm); border: 1px solid var(--hair-strong); background: var(--bg);
  font-size: 15px; outline: none; transition: border-color .15s, box-shadow .15s;
}
.field input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.field input.code-input { font: 600 22px/1 ui-monospace, "Cascadia Mono", Consolas, monospace; letter-spacing: .4em; text-align: center; }
.form-error { margin: 0; padding: 10px 12px; border-radius: var(--r-sm); background: color-mix(in srgb, var(--p1) 10%, transparent); color: var(--p1); font-size: 13px; }
.sync-card .chip-btn span { display: inline; }
.scan-btn { height: 46px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; font-size: 14.5px; }
.scan-btn .ico { width: 20px; height: 20px; }
.connect .scan-btn, .connect .or-divider { display: none; }
.native .connect .scan-btn { display: inline-flex; }
.native .connect .or-divider { display: flex; }
.or-divider { align-items: center; gap: 10px; color: var(--muted); font-size: 12px; }
.or-divider::before, .or-divider::after { content: ""; flex: 1; height: 1px; background: var(--hair-strong); }
