/* TaskHub Web — design system
   Tokens first, then layout, then components. Light is the default, dark overrides the tokens. */

:root {
  color-scheme: light;
  --bg: #f4f5f7;
  --panel: #ffffff;
  --panel-2: #f8f9fb;
  --ink: #171a21;
  --ink-2: #3f4655;
  --muted: #737b8c;
  --line: #e4e6eb;
  --line-2: #d6d9e0;
  --accent: #4f46e5;
  --accent-2: #6366f1;
  --accent-ink: #ffffff;
  --accent-soft: rgba(79, 70, 229, .10);
  --accent-soft-2: rgba(79, 70, 229, .18);
  --danger: #dc2626;
  --danger-soft: rgba(220, 38, 38, .10);
  --warn: #d97706;
  --ok: #16a34a;
  --star: #f59e0b;
  --p5: #ef4444;
  --p4: #f97316;
  --p3: #eab308;
  --p1: #94a3b8;
  --shadow-1: 0 1px 2px rgba(20, 24, 40, .06), 0 0 0 1px rgba(20, 24, 40, .04);
  --shadow-2: 0 8px 24px rgba(20, 24, 40, .10), 0 2px 6px rgba(20, 24, 40, .06);
  --shadow-3: 0 24px 60px rgba(20, 24, 40, .22), 0 8px 20px rgba(20, 24, 40, .10);
  --r-s: 8px;
  --r-m: 12px;
  --r-l: 16px;
  --sidebar-w: 264px;
  --topbar-h: 64px;
  --ease: cubic-bezier(.2, .8, .2, 1);
  --fast: 140ms;
  --normal: 220ms;
  --font: "Inter", "SF Pro Text", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
:root[data-theme="dark"] { color-scheme: dark; }
@media (prefers-color-scheme: dark) { :root[data-theme="system"] { color-scheme: dark; } }
@media (prefers-color-scheme: dark) {
  :root[data-theme="system"] {
    --bg: #101217; --panel: #171a21; --panel-2: #1d2029; --ink: #e8eaf0; --ink-2: #c3c8d4; --muted: #8b93a5; --line: #262b36; --line-2: #333947;
    --accent: #818cf8; --accent-2: #a5b4fc; --accent-ink: #12121a; --accent-soft: rgba(129, 140, 248, .14); --accent-soft-2: rgba(129, 140, 248, .24);
    --danger: #f87171; --danger-soft: rgba(248, 113, 113, .14); --warn: #fbbf24; --ok: #4ade80; --star: #fbbf24; --p5: #f87171; --p4: #fb923c; --p3: #facc15; --p1: #64748b;
    --shadow-1: 0 1px 2px rgba(0, 0, 0, .4), 0 0 0 1px rgba(255, 255, 255, .04); --shadow-2: 0 8px 24px rgba(0, 0, 0, .45), 0 2px 6px rgba(0, 0, 0, .3); --shadow-3: 0 24px 60px rgba(0, 0, 0, .6), 0 8px 20px rgba(0, 0, 0, .4);
  }
}
:root[data-theme="dark"] {
  --bg: #101217; --panel: #171a21; --panel-2: #1d2029; --ink: #e8eaf0; --ink-2: #c3c8d4; --muted: #8b93a5; --line: #262b36; --line-2: #333947;
  --accent: #818cf8; --accent-2: #a5b4fc; --accent-ink: #12121a; --accent-soft: rgba(129, 140, 248, .14); --accent-soft-2: rgba(129, 140, 248, .24);
  --danger: #f87171; --danger-soft: rgba(248, 113, 113, .14); --warn: #fbbf24; --ok: #4ade80; --star: #fbbf24; --p5: #f87171; --p4: #fb923c; --p3: #facc15; --p1: #64748b;
  --shadow-1: 0 1px 2px rgba(0, 0, 0, .4), 0 0 0 1px rgba(255, 255, 255, .04); --shadow-2: 0 8px 24px rgba(0, 0, 0, .45), 0 2px 6px rgba(0, 0, 0, .3); --shadow-3: 0 24px 60px rgba(0, 0, 0, .6), 0 8px 20px rgba(0, 0, 0, .4);
}

/* ---------- base ---------- */
* { box-sizing: border-box; }
html { height: 100%; }
body { margin: 0; min-height: 100%; min-width: 320px; background: var(--bg); color: var(--ink); font: 14px/1.45 var(--font); -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; overscroll-behavior-y: none; }
body.dragging { user-select: none; cursor: grabbing; }
body.dragging * { cursor: grabbing !important; }
h1, h2, h3, p { margin: 0; }
button, input, textarea, select { font: inherit; color: inherit; }
button { border: 0; background: none; padding: 0; cursor: pointer; }
a { color: var(--accent); }
[hidden] { display: none !important; }
kbd.kbd { display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 5px; border-radius: 5px; border: 1px solid var(--line-2); background: var(--panel-2); color: var(--muted); font: 600 11px/1 var(--font); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: var(--r-s); }
.quiet { color: var(--muted); }
.eyebrow { color: var(--muted); font-size: 12px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; }
.spacer { flex: 1; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* icons are inline SVGs injected by app.js into [data-icon] */
.i { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- screens ---------- */
.screen-center { min-height: 100dvh; display: grid; place-content: center; justify-items: center; gap: 12px; padding: 24px; text-align: center; }
.brand-lockup { display: flex; align-items: center; gap: 10px; font-size: 18px; font-weight: 700; letter-spacing: -.01em; }
.brand-mark { position: relative; display: inline-block; width: 30px; height: 30px; border-radius: 9px; background: linear-gradient(140deg, var(--accent), var(--accent-2)); box-shadow: 0 4px 12px rgba(79, 70, 229, .3); }
.brand-mark.small { width: 24px; height: 24px; border-radius: 7px; }
.brand-mark::after { content: ""; position: absolute; left: 30%; top: 26%; width: 34%; height: 22%; border-left: 3px solid #fff; border-bottom: 3px solid #fff; transform: rotate(-45deg); border-radius: 1px; }
.brand-mark.small::after { border-width: 2.5px; }
#boot { gap: 18px; }
#boot .brand-lockup { flex-direction: column; font-size: 20px; }
#boot .brand-mark { width: 44px; height: 44px; border-radius: 13px; animation: breathe 1.6s ease-in-out infinite; }
@keyframes breathe { 0%, 100% { transform: scale(1); opacity: 1; } 50% { transform: scale(.94); opacity: .8; } }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-l); box-shadow: var(--shadow-2); }
.auth-card { width: min(100%, 400px); padding: 28px; text-align: left; display: grid; gap: 12px; }
.auth-card h1 { font-size: 22px; letter-spacing: -.02em; margin-top: 6px; }
.state-card { width: min(100%, 400px); padding: 32px 28px; display: grid; gap: 10px; justify-items: center; }
.state-card h1 { font-size: 20px; }
.state-icon { display: grid; place-items: center; width: 52px; height: 52px; border-radius: 50%; background: var(--danger-soft); color: var(--danger); }
.state-icon .i { width: 26px; height: 26px; }
.state-actions { display: flex; gap: 8px; margin-top: 8px; flex-wrap: wrap; justify-content: center; }

/* ---------- controls ---------- */
.field { display: grid; gap: 6px; font-weight: 500; font-size: 13px; color: var(--ink-2); }
.field > span { font-weight: 600; font-size: 12px; color: var(--muted); }
input[type="text"], input[type="search"], input[type="password"], input[type="number"], textarea, select {
  width: 100%; border: 1px solid var(--line-2); border-radius: var(--r-s); padding: 9px 11px; background: var(--panel); color: var(--ink); font-size: 14px; transition: border-color var(--fast), box-shadow var(--fast);
}
input:focus-visible, textarea:focus-visible, select:focus-visible { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
input::placeholder, textarea::placeholder { color: var(--muted); opacity: .9; }
textarea { resize: vertical; }
.inline-error { padding: 9px 12px; border-radius: var(--r-s); background: var(--danger-soft); color: var(--danger); font-size: 13px; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; min-height: 36px; padding: 0 14px; border-radius: 9px; border: 1px solid transparent; background: var(--panel-2); color: var(--ink); font-weight: 600; font-size: 13.5px; white-space: nowrap; transition: background var(--fast), transform var(--fast), box-shadow var(--fast), border-color var(--fast), opacity var(--fast); }
.btn:hover { background: var(--line); }
.btn:active { transform: translateY(1px) scale(.99); }
.btn:disabled { opacity: .55; cursor: default; }
.btn-primary { background: var(--accent); color: var(--accent-ink); box-shadow: 0 1px 2px rgba(79, 70, 229, .3); }
.btn-primary:hover { background: color-mix(in srgb, var(--accent) 88%, #000); }
.btn-ghost { background: transparent; }
.btn-ghost:hover { background: var(--accent-soft); }
.btn-danger { color: var(--danger); }
.btn-danger:hover { background: var(--danger-soft); }
.btn-small { min-height: 30px; padding: 0 10px; font-size: 12.5px; border-radius: 7px; }
.btn-block { width: 100%; margin-top: 4px; }
.btn .i { width: 16px; height: 16px; }
.icon-btn { display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: 9px; color: var(--ink-2); transition: background var(--fast), color var(--fast), transform var(--fast); }
.icon-btn:hover { background: var(--accent-soft); color: var(--ink); }
.icon-btn:active { transform: scale(.94); }
.icon-btn.subtle { color: var(--muted); }
.icon-btn[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent); }

.segmented { display: inline-flex; padding: 3px; border-radius: 10px; background: var(--panel-2); border: 1px solid var(--line); }
.segmented button { padding: 6px 12px; border-radius: 8px; font-weight: 600; font-size: 13px; color: var(--muted); transition: background var(--fast), color var(--fast); }
.segmented button[aria-checked="true"] { background: var(--panel); color: var(--ink); box-shadow: var(--shadow-1); }

/* theme toggle: sun ↔ moon morph */
.theme-btn { position: relative; overflow: hidden; }
.theme-icon { position: relative; display: block; width: 20px; height: 20px; }
.theme-icon svg { position: absolute; inset: 0; width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; transition: transform 420ms var(--ease), opacity 260ms ease; }
.theme-icon .sun { transform: rotate(0) scale(1); opacity: 1; }
.theme-icon .sun .rays { transform-origin: 12px 12px; transition: transform 420ms var(--ease); }
.theme-icon .moon { fill: currentColor; stroke: none; transform: rotate(-60deg) scale(.4); opacity: 0; }
body.is-dark .theme-icon .sun { transform: rotate(90deg) scale(.3); opacity: 0; }
body.is-dark .theme-icon .moon { transform: rotate(0) scale(1); opacity: 1; }
body.is-dark .theme-icon .sun .rays { transform: scale(.4); }

/* ---------- app shell ---------- */
.app-shell { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); min-height: 100dvh; }
.sidebar { position: sticky; top: 0; height: 100dvh; display: flex; flex-direction: column; gap: 4px; padding: 14px 12px; background: var(--panel); border-right: 1px solid var(--line); overflow: hidden auto; scrollbar-width: thin; }
.sidebar-brand { display: flex; align-items: center; gap: 9px; padding: 4px 8px 12px; font-size: 15px; font-weight: 700; letter-spacing: -.01em; }
.sidebar-brand .mobile-only { margin-left: auto; }
.new-task-btn { width: 100%; justify-content: flex-start; height: 38px; margin-bottom: 8px; }
.new-task-btn .kbd { margin-left: auto; background: rgba(255, 255, 255, .18); border-color: transparent; color: var(--accent-ink); opacity: .85; }
.new-note-btn { width: 100%; justify-content: flex-start; height: 34px; margin: -4px 0 8px; color: var(--ink-2); }
.views { display: grid; gap: 2px; }
.nav-item { display: flex; align-items: center; gap: 9px; width: 100%; min-height: 34px; padding: 0 10px; border-radius: 8px; color: var(--ink-2); font-weight: 500; text-align: left; transition: background var(--fast), color var(--fast); }
.nav-item:hover { background: var(--accent-soft); color: var(--ink); }
.nav-item[aria-current="page"] { background: var(--accent-soft-2); color: var(--accent); font-weight: 600; }
.nav-item .i { width: 17px; height: 17px; color: var(--muted); }
.nav-item[aria-current="page"] .i { color: var(--accent); }
.nav-item .count { margin-left: auto; font-size: 12px; font-weight: 600; color: var(--muted); font-variant-numeric: tabular-nums; }
.nav-item .count.hot { color: var(--danger); }
.side-section { margin-top: 14px; }
.side-section-head { display: flex; align-items: center; justify-content: space-between; padding: 0 4px 4px 10px; color: var(--muted); font-size: 11.5px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; }
.side-section-head .icon-btn { width: 26px; height: 26px; border-radius: 6px; opacity: 0; transition: opacity var(--fast); }
.side-section:hover .side-section-head .icon-btn, .side-section-head .icon-btn:focus-visible { opacity: 1; }
.project-tree { display: grid; gap: 1px; }
.tree-node { position: relative; display: flex; align-items: center; gap: 4px; min-height: 32px; padding: 0 6px 0 calc(6px + var(--depth, 0) * 16px); border-radius: 8px; color: var(--ink-2); transition: background var(--fast), color var(--fast); }
.tree-node:hover { background: var(--accent-soft); }
.tree-node[aria-selected="true"] { background: var(--accent-soft-2); color: var(--accent); font-weight: 600; }
.tree-node.drop-target { background: var(--accent-soft-2); box-shadow: inset 0 0 0 2px var(--accent); }
.tree-node.inbox { color: var(--muted); font-size: 13px; margin-top: 6px; }
.tree-toggle { display: grid; place-items: center; width: 20px; height: 20px; border-radius: 5px; color: var(--muted); flex: none; }
.tree-toggle .i { width: 14px; height: 14px; transition: transform var(--normal) var(--ease); }
.tree-toggle[aria-expanded="true"] .i { transform: rotate(90deg); }
.tree-toggle.leaf { visibility: hidden; }
.tree-title { flex: 1; min-width: 0; padding: 6px 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-align: left; font-weight: inherit; }
.tree-count { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; padding-right: 2px; }
.tree-more { width: 24px; height: 24px; border-radius: 6px; opacity: 0; color: var(--muted); }
.tree-more .i { width: 15px; height: 15px; }
.tree-node:hover .tree-more, .tree-more:focus-visible, .tree-node.menu-open .tree-more { opacity: 1; }
.tree-node:hover .tree-count { display: none; }
.tree-children { display: grid; gap: 1px; overflow: hidden; }
.sidebar-foot { margin-top: auto; padding-top: 10px; border-top: 1px solid var(--line); display: flex; align-items: center; gap: 6px; }
.sync-state { flex: 1; display: flex; align-items: center; gap: 8px; min-height: 32px; padding: 0 8px; border-radius: 8px; font-size: 12px; color: var(--muted); text-align: left; }
.sync-state:hover { background: var(--accent-soft); }
.sync-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); flex: none; transition: background var(--fast); }
.sync-state.busy .sync-dot { background: var(--accent); animation: pulse 1s ease-in-out infinite; }
.sync-state.offline .sync-dot { background: var(--danger); }
.sync-state.stale .sync-dot { background: var(--warn); }
.connection-status { display: flex; align-items: center; gap: 10px; margin: 0 clamp(16px, 4vw, 40px) 12px; padding: 10px 12px; border: 1px solid color-mix(in srgb, var(--warn) 25%, var(--line)); border-radius: 14px; background: color-mix(in srgb, var(--warn) 7%, var(--panel)); color: var(--ink); }
.connection-symbol { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 10px; background: color-mix(in srgb, var(--warn) 12%, transparent); color: var(--warn); flex: none; }
.connection-symbol .i { width: 18px; height: 18px; }
.connection-copy { display: grid; gap: 2px; flex: 1; min-width: 0; font-size: 12px; }
.connection-copy strong { font-weight: 600; font-size: 12.5px; }
.connection-copy > span { color: var(--muted); }
.connection-status .btn { flex: none; }
.sync-issues { padding-top: 8px; }
.sync-issue { display: grid; gap: 8px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.sync-issue .state-actions { justify-content: flex-start; flex-wrap: wrap; }
.sync-issue .quiet { font-size: 13px; }
@keyframes pulse { 0%, 100% { transform: scale(1); opacity: 1; } 50% { transform: scale(.6); opacity: .5; } }

.main { display: flex; flex-direction: column; min-width: 0; }
.topbar { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 12px; min-height: var(--topbar-h); padding: 10px clamp(16px, 4vw, 40px); background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); }
.topbar-title { min-width: 0; flex: 1; }
.topbar-title h1 { font-size: 22px; font-weight: 700; letter-spacing: -.02em; line-height: 1.2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-title .quiet { font-size: 12.5px; margin-top: 1px; }
.topbar-actions { display: flex; align-items: center; gap: 4px; }
.search { position: relative; display: flex; align-items: center; width: 220px; transition: width var(--normal) var(--ease); }
.search:focus-within { width: 300px; }
.search input { padding-left: 34px; padding-right: 34px; height: 36px; border-radius: 9px; background: var(--panel); }
.search-icon { position: absolute; left: 10px; color: var(--muted); display: grid; pointer-events: none; }
.search-icon .i { width: 16px; height: 16px; }
.search .kbd { position: absolute; right: 8px; pointer-events: none; }
.search:focus-within .kbd, .search.has-value .kbd { display: none; }
.search .icon-btn { position: absolute; right: 2px; width: 30px; height: 30px; }
.banner { display: flex; align-items: center; gap: 12px; margin: 0 clamp(16px, 4vw, 40px) 8px; padding: 9px 12px; border-radius: 10px; background: color-mix(in srgb, var(--warn) 14%, var(--panel)); border: 1px solid color-mix(in srgb, var(--warn) 40%, var(--line)); color: var(--ink); font-size: 13px; }
.banner.error { background: var(--danger-soft); border-color: color-mix(in srgb, var(--danger) 40%, var(--line)); }
.banner span { flex: 1; }

.quick-add { display: flex; align-items: center; gap: 8px; margin: 4px clamp(16px, 4vw, 40px) 10px; max-width: 860px; padding: 2px 8px 2px 12px; border-radius: 11px; border: 1px dashed var(--line-2); background: transparent; transition: border-color var(--fast), background var(--fast), box-shadow var(--fast); }
.quick-add:hover { border-color: var(--accent); }
.quick-add:focus-within { border-style: solid; border-color: var(--accent); background: var(--panel); box-shadow: 0 0 0 3px var(--accent-soft); }
.quick-add-icon { color: var(--accent); display: grid; }
.quick-add input { flex: 1; min-width: 0; width: auto; border: 0; background: transparent; box-shadow: none !important; padding: 10px 4px; height: 40px; }
.quick-add:focus-within .quick-add-submit { display: inline-flex !important; }
.quick-add-mic { width: 34px; height: 34px; color: var(--accent); }

.content { padding: 0 clamp(16px, 4vw, 40px) 120px; max-width: 900px; width: 100%; }

/* ---------- groups & task cards ---------- */
.group { margin-bottom: 18px; }
.group-head { display: flex; align-items: baseline; gap: 8px; padding: 6px 4px; }
.group-head h2 { font-size: 13px; font-weight: 700; color: var(--ink); letter-spacing: .01em; }
.group-head h2 button { font: inherit; color: inherit; }
.group-head h2 button:hover { color: var(--accent); }
.group-head .count { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.group-head .sub { font-size: 12px; color: var(--muted); }
.group-head.overdue h2 { color: var(--danger); }
.task-list { display: flex; flex-direction: column; gap: 6px; min-height: 12px; border-radius: var(--r-m); transition: background var(--fast); position: relative; }
.task-list.drop-hover { background: var(--accent-soft); box-shadow: 0 0 0 2px var(--accent-soft-2); }
.task-list.empty-drop { min-height: 44px; }
.task-list.empty-drop::before { content: "Перетащите сюда"; position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); font-size: 12.5px; border: 1px dashed var(--line-2); border-radius: var(--r-m); opacity: 0; transition: opacity var(--fast); }
body.dragging .task-list.empty-drop::before { opacity: 1; }

.task-card { position: relative; display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: start; gap: 10px; padding: 10px 10px 10px 12px; border-radius: var(--r-m); background: var(--panel); border: 1px solid var(--line); box-shadow: var(--shadow-1); transition: box-shadow var(--normal) var(--ease), border-color var(--fast), transform var(--normal) var(--ease), opacity var(--normal); touch-action: pan-y; will-change: transform; }
.task-card:hover { border-color: var(--line-2); box-shadow: var(--shadow-2); }
.task-card:focus-visible, .task-card.selected { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft), var(--shadow-1); }
.task-card.pending { opacity: .72; }
.task-card.pending .task-title::after { content: ""; display: inline-block; width: 10px; height: 10px; margin-left: 8px; border-radius: 50%; border: 2px solid var(--accent-soft-2); border-top-color: var(--accent); vertical-align: middle; animation: spin .9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.task-card.done .task-title { color: var(--muted); text-decoration: line-through; text-decoration-color: var(--line-2); }
.task-card.done { opacity: .78; }
.task-card.drag-source { opacity: 0; }
.task-card.drag-ghost { position: fixed; z-index: 100; margin: 0; pointer-events: none; transform: scale(1.03) rotate(.6deg); box-shadow: var(--shadow-3); border-color: var(--accent-soft-2); transition: none; background: var(--panel); }
.task-card.drag-ghost.landing { transition: transform 200ms var(--ease), top 200ms var(--ease), left 200ms var(--ease), box-shadow 200ms var(--ease); transform: none; box-shadow: var(--shadow-1); }
.task-card.entering { animation: card-in 260ms var(--ease); }
@keyframes card-in { from { opacity: 0; transform: translateY(-6px) scale(.98); } to { opacity: 1; transform: none; } }
.task-body { display: grid; gap: 4px; min-width: 0; }
.task-title { font-size: 14.5px; font-weight: 500; line-height: 1.4; overflow-wrap: anywhere; color: var(--ink); }
.task-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; font-size: 12px; color: var(--muted); }
.task-meta > span { display: inline-flex; align-items: center; gap: 4px; }
.task-meta .i { width: 13px; height: 13px; }
.meta-due.today { color: var(--accent); font-weight: 600; }
.meta-due.overdue { color: var(--danger); font-weight: 600; }
.meta-due.soon { color: var(--warn); font-weight: 600; }
.meta-priority.p5 { color: var(--p5); } .meta-priority.p4 { color: var(--p4); } .meta-priority.p3 { color: var(--p3); } .meta-priority.p1 { color: var(--p1); }
.meta-project { max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.task-actions { display: flex; align-items: center; gap: 2px; margin: -4px -4px -4px 0; }
.task-actions .icon-btn { width: 32px; height: 32px; opacity: 0; transition: opacity var(--fast), background var(--fast), transform var(--fast); }
.task-card:hover .task-actions .icon-btn, .task-card:focus-within .task-actions .icon-btn, .task-actions .icon-btn[aria-pressed="true"] { opacity: 1; }
.task-actions .grip { opacity: 0; cursor: grab; color: var(--muted); }
.task-card:hover .task-actions .grip { opacity: .7; }
.star-btn[aria-pressed="true"] { color: var(--star); background: transparent; }
.star-btn[aria-pressed="true"] .i { fill: currentColor; }
.star-btn.pop .i { animation: star-pop 360ms var(--ease); }
@keyframes star-pop { 0% { transform: scale(1); } 40% { transform: scale(1.35) rotate(-8deg); } 100% { transform: scale(1); } }
@media (hover: none) { .task-actions .icon-btn { opacity: 1; } .task-actions .grip { display: none; } }

/* ---------- notes ---------- */
.notes-list { display: grid; gap: 8px; }
.note-card { display: grid; gap: 8px; padding: 16px 18px; border: 1px solid var(--line); border-radius: var(--r-m); background: var(--panel); box-shadow: var(--shadow-1); text-align: left; transition: border-color var(--fast), box-shadow var(--normal), transform var(--fast); }
.note-card:hover { border-color: var(--accent-soft-2); box-shadow: var(--shadow-2); transform: translateY(-1px); }
.note-card:focus-visible { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft), var(--shadow-1); }
.note-card-head { display: flex; align-items: center; gap: 9px; min-width: 0; }
.note-card-head .i { width: 18px; height: 18px; color: var(--accent); }
.note-card h2 { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 16px; line-height: 1.3; }
.note-card p { display: -webkit-box; overflow: hidden; color: var(--ink-2); font-size: 13.5px; line-height: 1.5; -webkit-box-orient: vertical; -webkit-line-clamp: 3; }
.note-card-meta { display: flex; gap: 12px; color: var(--muted); font-size: 12px; }

/* custom checkbox */
.check { position: relative; display: grid; place-items: center; width: 26px; height: 26px; margin-top: 1px; border-radius: 50%; color: var(--line-2); flex: none; transition: transform var(--fast); }
.check svg { width: 24px; height: 24px; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; overflow: visible; }
.check .ring { stroke: currentColor; fill: transparent; transition: fill var(--normal) var(--ease), stroke var(--normal) var(--ease); }
.check .tick { stroke: var(--accent-ink); stroke-dasharray: 20; stroke-dashoffset: 20; transition: stroke-dashoffset 240ms var(--ease) 60ms; }
.check:hover { transform: scale(1.08); color: var(--accent); }
.check:hover .ring { fill: var(--accent-soft); }
.check:active { transform: scale(.92); }
.check[aria-checked="true"] { color: var(--accent); }
.check[aria-checked="true"] .ring { fill: var(--accent); stroke: var(--accent); }
.check[aria-checked="true"] .tick { stroke-dashoffset: 0; }
.check.p5 { color: var(--p5); } .check.p4 { color: var(--p4); } .check.p3 { color: var(--p3); }
.check.p5:hover .ring { fill: color-mix(in srgb, var(--p5) 14%, transparent); }
.check.p4:hover .ring { fill: color-mix(in srgb, var(--p4) 14%, transparent); }
.check.p3:hover .ring { fill: color-mix(in srgb, var(--p3) 14%, transparent); }
.check.p5:hover, .check.p4:hover, .check.p3:hover { color: inherit; }
.check.p5[aria-checked="true"], .check.p4[aria-checked="true"], .check.p3[aria-checked="true"] { color: var(--accent); }

/* states */
.empty { display: grid; justify-items: center; gap: 8px; padding: 56px 20px; text-align: center; color: var(--muted); }
.empty .empty-icon { display: grid; place-items: center; width: 56px; height: 56px; border-radius: 18px; background: var(--accent-soft); color: var(--accent); margin-bottom: 4px; }
.empty .empty-icon .i { width: 26px; height: 26px; }
.empty h3 { color: var(--ink); font-size: 16px; font-weight: 650; }
.empty p { max-width: 380px; font-size: 13.5px; }
.empty .btn { margin-top: 6px; }
.skeleton-list { display: grid; gap: 6px; }
.skeleton { height: 58px; border-radius: var(--r-m); background: linear-gradient(100deg, var(--panel) 30%, var(--panel-2) 50%, var(--panel) 70%); background-size: 240% 100%; animation: shimmer 1.4s infinite; border: 1px solid var(--line); }
.skeleton.short { width: 40%; height: 18px; border-radius: 6px; margin: 10px 0 4px; border: 0; }
@keyframes shimmer { to { background-position: -240% 0; } }

/* ---------- dialogs ---------- */
.dialog { width: min(100% - 32px, 640px); max-height: min(88dvh, 780px); padding: 0; border: 1px solid var(--line); border-radius: var(--r-l); background: var(--panel); color: var(--ink); box-shadow: var(--shadow-3); overflow: hidden; }
.dialog::backdrop { background: rgba(10, 12, 20, .45); backdrop-filter: blur(2px); }
.dialog[open] { animation: dialog-in 200ms var(--ease); }
@keyframes dialog-in { from { opacity: 0; transform: translateY(10px) scale(.98); } to { opacity: 1; transform: none; } }
.small-dialog { width: min(100% - 32px, 460px); }
.task-form { display: flex; flex-direction: column; max-height: inherit; }
.dialog-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 12px 12px 8px 20px; }
.dialog-head-actions { display: flex; gap: 2px; }
.task-form-body { display: grid; gap: 12px; padding: 0 20px 16px; overflow: auto; }
.dialog-foot { display: flex; align-items: center; gap: 8px; padding: 12px 16px 14px; border-top: 1px solid var(--line); background: var(--panel-2); }
.title-row { display: flex; align-items: flex-start; gap: 10px; }
.title-row .check { margin-top: 5px; }
.title-input { min-height: 38px; border: 0; padding: 4px 0; background: transparent; box-shadow: none !important; font-size: 19px; font-weight: 600; letter-spacing: -.01em; line-height: 1.35; resize: none; overflow: hidden; }
.description-input { min-height: 56px; border: 0; padding: 2px 0 0 36px; background: transparent; box-shadow: none !important; resize: none; overflow: hidden; color: var(--ink-2); }
.chip-row { display: flex; flex-wrap: wrap; gap: 6px; padding-left: 36px; }
.chip { display: inline-flex; align-items: center; gap: 6px; min-height: 30px; padding: 0 10px 0 8px; border-radius: 8px; border: 1px solid var(--line-2); background: var(--panel); color: var(--ink-2); font-size: 12.5px; font-weight: 600; transition: background var(--fast), border-color var(--fast), color var(--fast); max-width: 100%; }
.chip > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip:hover { background: var(--accent-soft); border-color: var(--accent-soft-2); }
.chip.set { color: var(--accent); border-color: var(--accent-soft-2); background: var(--accent-soft); }
.chip.overdue { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 30%, transparent); background: var(--danger-soft); }
.chip.p5 { color: var(--p5); } .chip.p4 { color: var(--p4); } .chip.p3 { color: var(--p3); }
.chip .i { width: 15px; height: 15px; }
.task-form.create .description-input, .task-form.create .chip-row { padding-left: 0; }
.labels-row { display: flex; flex-wrap: wrap; gap: 6px; padding-left: 36px; }
.label-pill { padding: 2px 8px; border-radius: 999px; background: var(--panel-2); border: 1px solid var(--line); font-size: 12px; color: var(--muted); }
.settings-body { gap: 20px; padding-bottom: 20px; }
.settings-group { display: grid; gap: 8px; }
.settings-label { font-size: 12px; font-weight: 700; color: var(--muted); letter-spacing: .05em; text-transform: uppercase; }
.settings-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.token-editor { display: grid; gap: 8px; padding: 10px; border-radius: 10px; background: var(--panel-2); border: 1px solid var(--line); }
.shortcuts { margin: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 6px 14px; }
.shortcuts div { display: flex; align-items: center; gap: 8px; }
.shortcuts dt { display: flex; gap: 3px; min-width: 52px; }
.shortcuts dd { margin: 0; color: var(--ink-2); font-size: 13px; }
.danger-zone { padding-top: 6px; border-top: 1px solid var(--line); }

.note-dialog { width: min(100% - 32px, 880px); }
.note-form { display: flex; flex-direction: column; max-height: inherit; }
.note-form-body { display: grid; gap: 14px; padding: 0 20px 18px; overflow: auto; }
.note-title-input { min-height: 42px; padding: 4px 0; border: 0; border-radius: 0; background: transparent; box-shadow: none !important; resize: none; overflow: hidden; font-size: 22px; font-weight: 700; letter-spacing: -.02em; line-height: 1.3; }
.note-save-status { max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); font-size: 12px; }
.note-save-status[data-kind="error"] { color: var(--danger); }
.markdown-editor { display: grid; grid-template-columns: auto 1fr; gap: 8px; min-width: 0; }
.markdown-tabs { grid-column: 1 / -1; display: flex; gap: 4px; border-bottom: 1px solid var(--line); }
.markdown-tabs button { min-height: 32px; padding: 0 10px; border-bottom: 2px solid transparent; color: var(--muted); font-size: 12.5px; font-weight: 650; }
.markdown-tabs button[aria-selected="true"] { border-bottom-color: var(--accent); color: var(--accent); }
.markdown-toolbar { display: flex; flex-direction: column; align-items: stretch; gap: 3px; padding: 3px; border: 1px solid var(--line); border-radius: 9px; background: var(--panel-2); }
.markdown-toolbar button { min-width: 32px; min-height: 30px; padding: 0 6px; border-radius: 6px; color: var(--ink-2); font-size: 11px; font-weight: 650; }
.markdown-toolbar button:hover { background: var(--accent-soft); color: var(--accent); }
.note-body-input { min-height: 360px; padding: 12px 14px; resize: vertical; line-height: 1.55; font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace; font-size: 13.5px; }
.markdown-preview { min-height: 360px; padding: 12px 14px; overflow: auto; border: 1px solid var(--line); border-radius: var(--r-s); background: var(--panel-2); color: var(--ink-2); line-height: 1.6; }
.markdown-preview > :first-child { margin-top: 0; }
.markdown-preview > :last-child { margin-bottom: 0; }
.markdown-preview h1, .markdown-preview h2, .markdown-preview h3, .markdown-preview h4 { margin: 1.1em 0 .45em; color: var(--ink); line-height: 1.25; }
.markdown-preview h1 { font-size: 1.5em; }.markdown-preview h2 { font-size: 1.3em; }.markdown-preview h3 { font-size: 1.14em; }.markdown-preview h4 { font-size: 1em; }
.markdown-preview p { margin: .65em 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.markdown-preview ul, .markdown-preview ol { margin: .65em 0; padding-left: 1.35em; }
.markdown-preview li { margin: .28em 0; }
.markdown-preview blockquote { margin: .8em 0; padding: .15em 0 .15em 12px; border-left: 3px solid var(--accent-soft-2); color: var(--muted); white-space: pre-wrap; }
.markdown-preview pre { margin: .8em 0; padding: 11px; overflow: auto; border-radius: 8px; background: var(--ink); color: var(--bg); font: 12.5px/1.5 "SFMono-Regular", Consolas, monospace; }
.markdown-preview code { padding: .1em .3em; border-radius: 4px; background: var(--accent-soft); color: var(--ink); font: .9em "SFMono-Regular", Consolas, monospace; }
.markdown-preview pre code { padding: 0; background: transparent; color: inherit; }
.markdown-check { list-style: none; margin-left: -1.35em; }
.markdown-check-box { display: inline-grid; width: 15px; height: 15px; margin-right: 6px; place-items: center; border: 1px solid var(--line-2); border-radius: 4px; color: var(--accent); font-size: 11px; font-weight: 800; vertical-align: -1px; }
.note-conflict { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; padding: 9px 10px; border: 1px solid color-mix(in srgb, var(--warn) 45%, var(--line)); border-radius: 9px; background: color-mix(in srgb, var(--warn) 12%, var(--panel)); color: var(--ink-2); font-size: 13px; }
.note-conflict span { flex: 1; }

/* ---------- popovers, menus, date picker ---------- */
.popover-layer { position: fixed; inset: 0; z-index: 50; pointer-events: none; width: 0; height: 0; }
dialog.popover, dialog.popover:modal { position: fixed; inset: auto; margin: 0; width: auto; height: auto; overflow: visible; pointer-events: auto; min-width: 200px; max-width: min(360px, calc(100vw - 24px)); max-height: none; padding: 6px; border-radius: 12px; background: var(--panel); border: 1px solid var(--line); color: var(--ink); box-shadow: var(--shadow-3); animation: pop-in 160ms var(--ease); transform-origin: var(--origin, top left); }
.popover::backdrop { background: transparent; }
.popover.dim::backdrop { background: rgba(10, 12, 20, .18); }
@keyframes pop-in { from { opacity: 0; transform: scale(.96) translateY(-4px); } to { opacity: 1; transform: none; } }
.menu { display: grid; gap: 1px; }
.menu-item { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 34px; padding: 0 10px; border-radius: 8px; text-align: left; font-weight: 500; color: var(--ink); }
.menu-item:hover, .menu-item:focus-visible { background: var(--accent-soft); outline: none; }
.menu-item[aria-checked="true"] { color: var(--accent); font-weight: 600; }
.menu-item .i { width: 16px; height: 16px; color: var(--muted); }
.menu-item[aria-checked="true"] .i { color: var(--accent); }
.menu-item .hint { margin-left: auto; font-size: 12px; color: var(--muted); }
.menu-item.danger { color: var(--danger); }
.menu-item.danger .i { color: var(--danger); }
.menu-item.p5 .i { color: var(--p5); } .menu-item.p4 .i { color: var(--p4); } .menu-item.p3 .i { color: var(--p3); } .menu-item.p1 .i { color: var(--p1); }
.menu-item[style*="--depth"] { padding-left: calc(10px + var(--depth) * 14px); }
.menu-sep { height: 1px; margin: 5px 4px; background: var(--line); }
.menu-title { padding: 6px 10px 4px; font-size: 11.5px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); }
.menu-search { margin: 2px 2px 6px; }
.menu-scroll { max-height: 320px; overflow: auto; }

.datepicker { width: 316px; padding: 8px; display: grid; gap: 8px; }
.dp-quick { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; }
.dp-quick button { display: flex; align-items: center; gap: 7px; min-height: 32px; padding: 0 8px; border-radius: 8px; font-weight: 500; color: var(--ink); font-size: 13px; white-space: nowrap; }
.dp-quick button:hover { background: var(--accent-soft); }
.dp-quick .i { width: 15px; height: 15px; color: var(--muted); }
.dp-quick .hint { margin-left: auto; color: var(--muted); font-size: 11.5px; }
.dp-head { display: flex; align-items: center; justify-content: space-between; padding: 2px 2px 0; }
.dp-head strong { font-size: 13.5px; text-transform: capitalize; }
.dp-head .icon-btn { width: 30px; height: 30px; }
.dp-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.dp-wd { text-align: center; font-size: 11px; font-weight: 600; color: var(--muted); padding: 4px 0; text-transform: uppercase; }
.dp-day { height: 34px; border-radius: 8px; font-size: 13px; font-weight: 500; color: var(--ink); font-variant-numeric: tabular-nums; transition: background var(--fast), color var(--fast), transform var(--fast); }
.dp-day:hover { background: var(--accent-soft); }
.dp-day:active { transform: scale(.94); }
.dp-day.other { color: var(--muted); opacity: .55; }
.dp-day.today { box-shadow: inset 0 0 0 1.5px var(--accent-soft-2); color: var(--accent); font-weight: 700; }
.dp-day.selected { background: var(--accent); color: var(--accent-ink); font-weight: 700; }
.dp-day.weekend { color: var(--ink-2); }
.dp-time { display: grid; gap: 6px; padding-top: 6px; border-top: 1px solid var(--line); }
.dp-time-row { display: flex; align-items: center; gap: 6px; }
.dp-time-row .i { width: 15px; height: 15px; color: var(--muted); flex: none; }
input.dp-time-input { width: 74px; flex: none; text-align: center; font-variant-numeric: tabular-nums; padding: 6px 8px; }
.dp-time-chips { display: flex; flex-wrap: wrap; gap: 4px; }
.dp-time-chips button { min-height: 26px; padding: 0 9px; border-radius: 999px; background: var(--panel-2); border: 1px solid var(--line); font-size: 12px; font-weight: 600; color: var(--ink-2); }
.dp-time-chips button:hover, .dp-time-chips button.on { background: var(--accent-soft); color: var(--accent); border-color: var(--accent-soft-2); }
.dp-foot { display: flex; justify-content: flex-end; gap: 6px; }

/* ---------- toasts ---------- */
.toasts { position: fixed; left: 50%; bottom: 20px; z-index: 80; display: grid; gap: 8px; transform: translateX(-50%); width: min(440px, calc(100% - 24px)); pointer-events: none; }
.toast { display: flex; align-items: center; gap: 10px; padding: 10px 12px 10px 14px; border-radius: 12px; background: var(--ink); color: var(--bg); box-shadow: var(--shadow-3); font-size: 13.5px; font-weight: 500; pointer-events: auto; animation: toast-in 240ms var(--ease); }
.toast.leaving { animation: toast-out 200ms var(--ease) forwards; }
.toast.error { background: var(--danger); color: #fff; }
.toast span { flex: 1; }
.toast button { padding: 4px 10px; border-radius: 7px; font-weight: 700; color: inherit; background: rgba(255, 255, 255, .14); }
.toast button:hover { background: rgba(255, 255, 255, .24); }
@keyframes toast-in { from { opacity: 0; transform: translateY(12px) scale(.97); } to { opacity: 1; transform: none; } }
@keyframes toast-out { to { opacity: 0; transform: translateY(8px) scale(.97); } }

/* ---------- mobile ---------- */
@media (min-width: 861px) { .mobile-only { display: none !important; } }
.bottom-nav { display: none; }
.scrim { position: fixed; inset: 0; z-index: 19; background: rgba(10, 12, 20, .4); backdrop-filter: blur(2px); animation: fade-in 160ms ease; }
@keyframes fade-in { from { opacity: 0; } }
@media (max-width: 860px) {
  .mobile-only { display: inline-grid; }
  .app-shell { display: block; }
  .sidebar { position: fixed; z-index: 20; top: 0; left: 0; width: min(86vw, 320px); height: 100dvh; transform: translateX(-104%); transition: transform var(--normal) var(--ease); box-shadow: none; padding-bottom: calc(14px + env(safe-area-inset-bottom)); }
  body.sidebar-open .sidebar { transform: none; box-shadow: var(--shadow-3); }
  .side-section-head .icon-btn { opacity: 1; }
  .tree-more { opacity: 1; }
  .tree-node:hover .tree-count { display: inline; }
  .topbar { min-height: 56px; padding: 8px 12px; gap: 6px; flex-wrap: wrap; }
  .topbar-title h1 { font-size: 20px; }
  .topbar-actions { margin-left: auto; }
  .search { width: 36px; }
  .search input { padding-left: 34px; padding-right: 30px; }
  .search:not(:focus-within):not(.has-value) input { opacity: 0; cursor: pointer; }
  .search:not(:focus-within):not(.has-value) .search-icon { pointer-events: none; }
  .search:focus-within, .search.has-value { width: 100%; order: 10; flex-basis: 100%; }
  .search .kbd { display: none; }
  .banner, .quick-add { margin-left: 12px; margin-right: 12px; }
  .content { padding: 0 12px calc(110px + env(safe-area-inset-bottom)); }
  .task-card { padding: 11px 8px 11px 10px; }
  .task-actions { margin-right: -2px; }
  .bottom-nav { position: fixed; z-index: 18; left: 0; right: 0; bottom: 0; display: grid; grid-template-columns: 1fr 1fr 64px 1fr 1fr; align-items: end; padding: 6px 6px calc(6px + env(safe-area-inset-bottom)); background: color-mix(in srgb, var(--panel) 92%, transparent); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); border-top: 1px solid var(--line); }
  .bottom-nav button { display: grid; justify-items: center; gap: 2px; min-height: 48px; padding: 4px 0; border-radius: 10px; font-size: 11px; font-weight: 600; color: var(--muted); }
  .bottom-nav button .i { width: 22px; height: 22px; }
  .bottom-nav button[aria-current="page"] { color: var(--accent); }
  .bottom-nav .bottom-add { place-self: center; width: 52px; height: 52px; min-height: 0; margin-top: -22px; border-radius: 50%; background: var(--accent); color: var(--accent-ink); box-shadow: 0 8px 20px rgba(79, 70, 229, .35); }
  .bottom-nav .bottom-add .i { width: 26px; height: 26px; stroke-width: 2.2; }
  .bottom-nav .bottom-add:active { transform: scale(.94); }
  .dialog { width: 100%; max-width: none; max-height: 92dvh; margin: auto 0 0; border-radius: 18px 18px 0 0; border-bottom: 0; }
  .dialog[open] { animation: sheet-in 260ms var(--ease); }
  @keyframes sheet-in { from { transform: translateY(40px); opacity: 0; } to { transform: none; opacity: 1; } }
  .dialog-foot { padding-bottom: calc(14px + env(safe-area-inset-bottom)); }
  .connection-status { margin-inline: 12px; flex-wrap: wrap; }
  .dialog-foot { flex-wrap: wrap; }
  .note-form-body { padding-inline: 14px; }
  .note-title-input { font-size: 20px; }
  .markdown-editor { display: grid; grid-template-columns: 1fr; }
  .markdown-toolbar { flex-direction: row; flex-wrap: wrap; }
  .markdown-toolbar button { min-width: 38px; }
  .note-body-input, .markdown-preview { min-height: 46dvh; }
  .shortcuts { display: none; }
  .settings-group:has(.shortcuts) { display: none; }
  dialog.popover.sheet, dialog.popover.sheet:modal { inset: auto 0 0 0 !important; max-width: none; width: 100%; max-height: 86dvh; overflow: auto; border-radius: 18px 18px 0 0; padding: 10px 12px calc(12px + env(safe-area-inset-bottom)); animation: sheet-in 240ms var(--ease); transform-origin: bottom center; }
  .popover.sheet::backdrop { background: rgba(10, 12, 20, .4); }
  .popover.sheet .datepicker { width: auto; }
  .popover.sheet .dp-day { height: 40px; }
  .popover.sheet .menu-item { min-height: 42px; }
  .toasts { bottom: calc(76px + env(safe-area-inset-bottom)); }
  .quick-add input { font-size: 16px; }
  input[type="text"], input[type="search"], input[type="password"], textarea, select { font-size: 16px; }
}
@media (max-width: 480px) { .topbar-title .quiet { display: none; } .meta-project { max-width: 140px; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; } }
