/* ============================================================
   Anjam — workspace layout, ruby accent
   One family (Vazirmatn), fixed px scale, 4px spacing grid,
   radii 4/6/8/12, light + dark themes (system / forced).
   ============================================================ */

@font-face {
  font-family: 'Vazirmatn';
  src: url('fonts/Vazirmatn.woff2') format('woff2-variations'), url('fonts/Vazirmatn.woff2') format('woff2');
  font-weight: 100 900;
  font-display: swap;
}

:root {
  color-scheme: light;
  --font: 'Vazirmatn', 'Inter', -apple-system, 'SF Pro Text', 'Segoe UI', system-ui, sans-serif;
  --font-code: 'JetBrains Mono', monospace;

  /* Stitch Light Palette (Editorial Crimson Workspace) */
  --bg: #FAFAF9;                    /* Warm bone-white canvas foundation */
  --bg-side: #F5F4F2;               /* Tactile warm-sand sidebar */
  --bg-2: #f2eced;                  /* surface-container */
  --bg-card: #ffffff;               /* surface-container-lowest */
  --bg-surface-low: #f8f2f3;        /* surface-container-low */
  --bg-surface-high: #ede7e8;       /* surface-container-high */
  --text: #1d1b1c;                  /* on-surface */
  --text-2: #594141;                /* on-surface-variant */
  --text-3: #7f6566;                /* outline — darkened from #8c7071, which failed WCAG AA (4.1-4.3:1) against bg/bg-side */
  --text-4: #e0bfbf;                /* outline-variant */
  --line: #EBE8E5;                  /* hairline-border */
  --line-strong: #ded9da;           /* surface-dim / strong hairline */
  --hover: rgba(29, 27, 28, .045);
  --active: rgba(29, 27, 28, .08);

  /* Primary Ruby (Stitch Editorial Crimson) */
  --ruby: #9e1b32;                  /* Primary Ruby */
  --ruby-hover: #B8213E;            /* Brightens subtly on hover */
  --ruby-active: #7D1226;
  --ruby-soft: #FDF2F4;             /* Ruby subtle tint */
  --ruby-ring: rgba(158, 27, 50, .28);
  --ruby-text: #9e1b32;
  --on-ruby: #ffffff;

  --danger: #ba1a1a;
  --ok: #1b7a45;

  /* Semantic Priority Tokens (Stitch) */
  --priority-urgent: #D9383A;
  --priority-high: #E07A22;
  --priority-medium: #3A86C8;
  --priority-low: #8C9199;

  --chip-red: #FDF2F4;     --chip-red-t: #D9383A;
  --chip-amber: #FFF4E5;   --chip-amber-t: #E07A22;
  --chip-blue: #EBF4FC;    --chip-blue-t: #3A86C8;
  --chip-green: #EAF7EF;   --chip-green-t: #1B7A45;
  --chip-gray: #F2ECED;    --chip-gray-t: #594141;
  --chip-purple: #F3EEFB;  --chip-purple-t: #6B4E9E;

  --shadow-sm: 0 1px 2px rgba(29, 27, 28, .04), 0 0 0 1px var(--line);
  --shadow-md: 0 4px 16px rgba(29, 27, 28, .06), 0 0 0 1px var(--line);
  --shadow-lg: 0 4px 24px -2px rgba(32, 30, 31, .06), 0 1px 4px 0 rgba(32, 30, 31, .04), 0 0 0 1px var(--line);
  --shadow-toast: 0 8px 24px rgba(29, 27, 28, .22);
  --shadow-fab: 0 8px 20px rgba(158, 27, 50, .24);
  /* Neutral, not ruby-tinted: a colored blurred shadow reads as an AI-generated glow effect */
  --ruby-shadow-sm: rgba(29, 27, 28, .18);
  --ruby-shadow-lg: rgba(29, 27, 28, .28);

  --r-sm: 4px; --r-md: 8px; --r-lg: 12px; --r-xl: 14px; --r-full: 9999px;
  --sidebar-w: 260px;
  --topbar-h: 56px;
  --peek-w: 560px;
  --ease: cubic-bezier(.2, .8, .2, 1);
  --t-fast: 100ms; --t-mid: 160ms; --t-slow: 220ms;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}

:root[data-theme="dark"] { color-scheme: dark; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { color-scheme: dark; } }

:root[data-theme="dark"],
:root:not([data-theme="light"]).sys-dark {
  /* Stitch Dark Palette (Obsidian & Crimson) */
  --bg: #161415;                    /* Obsidian charcoal canvas */
  --bg-side: #1C191A;               /* Dark sidebar tier */
  --bg-2: #201f1f;                  /* surface-container */
  --bg-card: #201f1f;               /* surface card */
  --bg-surface-low: #1c1b1b;
  --bg-surface-high: #2a2a2a;
  --text: #f5eff0;                  /* inverse-on-surface */
  --text-2: #dbc0c0;                /* on-surface-variant */
  --text-3: #8c7071;                /* outline */
  --text-4: #554242;                /* outline-variant */
  --line: #2B2628;                  /* dark-hairline-border */
  --line-strong: #353534;           /* surface-container-highest */
  --hover: rgba(245, 239, 240, .05);
  --active: rgba(245, 239, 240, .09);

  /* Hue nudged toward true red (was #E03E58 — B > G reads as pink/rose, not red) */
  --ruby: #E03E43;                  /* Emissive high-legibility dark ruby */
  --ruby-hover: #E8585F;
  --ruby-active: #B8212A;
  --ruby-soft: #2D1618;             /* dark-ruby-subtle */
  --ruby-ring: rgba(224, 62, 67, .35);
  --ruby-text: #E03E43;
  --on-ruby: #ffffff;
  /* Colored glow shadows read as AI-slop on dark backgrounds; use plain elevation instead */
  --ruby-shadow-sm: rgba(0, 0, 0, .35);
  --ruby-shadow-lg: rgba(0, 0, 0, .45);

  --danger: #ff5a68;
  --ok: #8fd7a9;

  --chip-red: #2D161B;     --chip-red-t: #FF7B88;
  --chip-amber: #2B1D0E;   --chip-amber-t: #F5A855;
  --chip-blue: #142130;    --chip-blue-t: #6BB5F8;
  --chip-green: #11281A;   --chip-green-t: #52C77F;
  --chip-gray: #252223;    --chip-gray-t: #DBC0C0;
  --chip-purple: #231730;  --chip-purple-t: #BA99F2;

  --shadow-sm: 0 1px 3px rgba(0, 0, 0, .35), 0 0 0 1px var(--line);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, .45), 0 0 0 1px var(--line);
  --shadow-lg: 0 8px 32px -4px rgba(0, 0, 0, .55), 0 0 0 1px var(--line);
}

/* ============================================================
   Mobile design system — from the Stitch project "Anjam Mobile Task
   Manager" (projects/12871347997904680480). Scoped to <=760px only:
   desktop keeps the Editorial Crimson palette above untouched. This
   redefines the same custom properties so every component downstream
   picks up the new tokens automatically; --r-* also gets a rounder,
   more tactile scale (16px cards, pill chips) per that design system.
   ============================================================ */
@media (max-width: 760px) {
  :root {
    --bg: #FAF9F6; --bg-side: #FFFFFF; --bg-2: #F4F3EF; --bg-card: #FFFFFF;
    --bg-surface-low: #F4F3EF; --bg-surface-high: #E5E5E0;
    --text: #18191E; --text-2: #3F3F46; --text-3: #71717A; --text-4: #D4D4D8;
    --line: #E5E5E0; --line-strong: #D4D4D8;
    --hover: rgba(24, 25, 30, .045); --active: rgba(24, 25, 30, .08);
    --ruby: #E11D48; --ruby-hover: #BE123C; --ruby-active: #9F1039; --ruby-soft: #FCE7EB;
    --ruby-ring: rgba(225, 29, 72, .28); --ruby-text: #E11D48; --on-ruby: #ffffff;
    --ruby-shadow-sm: rgba(24, 25, 30, .16); --ruby-shadow-lg: rgba(24, 25, 30, .24);
    --r-sm: 6px; --r-md: 10px; --r-lg: 16px; --r-xl: 20px; --r-full: 9999px;
  }
  :root[data-theme="dark"], :root:not([data-theme="light"]).sys-dark {
    --bg: #121316; --bg-side: #1B1D22; --bg-2: #1B1D22; --bg-card: #24272E;
    --bg-surface-low: #1B1D22; --bg-surface-high: #343538;
    --text: #F3F4F6; --text-2: #C7C9CE; --text-3: #9CA3AF; --text-4: #5B5F6B;
    --line: #323640; --line-strong: #3F4450;
    --hover: rgba(243, 244, 246, .05); --active: rgba(243, 244, 246, .09);
    --ruby: #E11D48; --ruby-hover: #F43F5E; --ruby-active: #BE123C; --ruby-soft: #3A1620;
    --ruby-ring: rgba(225, 29, 72, .35); --ruby-text: #FF6B85; --on-ruby: #ffffff;
    --ruby-shadow-sm: rgba(0, 0, 0, .35); --ruby-shadow-lg: rgba(225, 29, 72, .35);
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .3), 0 0 0 1px var(--line);
    --shadow-md: 0 12px 32px -4px rgba(0, 0, 0, .45), 0 0 0 1px var(--line);
    --shadow-lg: 0 12px 32px -4px rgba(0, 0, 0, .45), 0 0 0 1px var(--line);
  }
}

/* ---------- reset ---------- */
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 400 14px/1.5 var(--font);
  font-feature-settings: "tnum";
  -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
  overflow: hidden; text-rendering: optimizeLegibility;
  overscroll-behavior: none;
}
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; border-radius: var(--r-sm); -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
input, select, textarea { font: inherit; color: inherit; }
svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }
kbd { font-family: var(--font); font-size: 11px; color: var(--text-3); }
[hidden] { display: none !important; }
[dir="rtl"] .flip-rtl, [dir="ltr"] .flip-ltr { transform: scaleX(-1); }
:focus-visible { outline: 2px solid var(--ruby-ring); outline-offset: 1px; }
::selection { background: var(--ruby-soft); }
::placeholder { color: var(--text-3); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ---------- shell ---------- */
.app { display: grid; grid-template-columns: var(--sidebar-w) 1fr; height: 100vh; height: 100dvh; position: relative; overflow: hidden; transition: grid-template-columns var(--t-slow) var(--ease); }
.app.rail-collapsed { grid-template-columns: 0 1fr; }
.app > .sidebar { grid-column: 1; grid-row: 1; }
.app > main, .app > .main { grid-column: 2; grid-row: 1; min-width: 0; }
/* Collapsed: the sidebar keeps its real width, leaves the grid (absolute) and slides fully off-screen —
   never squeezed into a 0px column. */
.app.rail-collapsed .sidebar { position: absolute; top: 0; bottom: 0; inset-inline-start: 0; transform: translateX(var(--side-hide)); visibility: hidden; pointer-events: none; }
[dir="rtl"] { --side-hide: 100%; }
[dir="ltr"] { --side-hide: -100%; }
.app.rail-collapsed .topbar-expand { display: inline-flex; }

/* ---------- sidebar ---------- */
.sidebar {
  background: var(--bg-side); border-inline-end: 1px solid var(--line);
  display: flex; flex-direction: column; padding: 12px 10px; min-width: 0; width: var(--sidebar-w);
  transition: transform var(--t-slow) var(--ease), visibility 0s linear var(--t-slow); position: relative; z-index: 30;
}
.ws { display: flex; align-items: center; gap: 8px; height: 38px; padding: 0 6px; border-radius: var(--r-md); width: 100%; text-align: start; margin-top: 0; }
.ws:hover { background: var(--hover); }
.ws-mark { width: 28px; height: 28px; border-radius: 8px; background: var(--ruby); color: var(--on-ruby); display: inline-flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 800; flex-shrink: 0; overflow: hidden; }
.ws-mark svg { width: 28px; height: 28px; }
.ws-mark.lg { width: 36px; height: 36px; border-radius: 10px; font-size: 18px; }
.ws-name { font-weight: 600; font-size: 13.5px; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ws-spacer { flex: 1; }
.ws-chev { width: 14px; height: 14px; color: var(--text-3); flex-shrink: 0; }
.sidebar-close { opacity: 0; }
.sidebar:hover .sidebar-close, .sidebar-close:focus-visible { opacity: 1; }
.sidebar-scroll { flex: 1; overflow-y: auto; overflow-x: hidden; margin: 4px -10px 0; padding: 0 10px; scrollbar-width: thin; }
.side-section { margin-top: 14px; }
.side-head { display: flex; align-items: center; justify-content: space-between; height: 26px; padding: 0 8px; font-size: 12px; font-weight: 600; color: var(--text-3); text-transform: uppercase; letter-spacing: 0.03em; }
.side-head .ibtn { opacity: 0; }
.side-section:hover .side-head .ibtn, .side-head .ibtn:focus-visible { opacity: 1; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-item, .rail-item, .rail-group {
  display: flex; align-items: center; gap: 8px; height: 32px; padding: 0 10px; border-radius: var(--r-md);
  width: 100%; text-align: start; color: var(--text-2); font-weight: 500; font-size: 13.5px; position: relative; min-width: 0;
  transition: background var(--t-fast), color var(--t-fast);
}
.nav-item svg, .rail-item svg { color: var(--text-3); width: 17px; height: 17px; }
.nav-item:hover, .rail-item:hover, .rail-group:hover { background: var(--hover); color: var(--text); }
.nav-item.active, .rail-item.active { background: var(--ruby-soft); color: var(--ruby); font-weight: 600; }
.nav-item.active svg, .rail-item.active svg { color: var(--ruby); }
.nav-label { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.count { font-size: 11px; padding: 1px 6px; border-radius: var(--r-full); background: var(--bg-2); color: var(--text-2); font-variant-numeric: tabular-nums; }
.nav-item.active .count { background: rgba(158, 27, 50, .12); color: var(--ruby); font-weight: 600; }
.nav-item kbd { margin-inline-start: auto; font-family: var(--font-code); font-size: 10px; }
.rail-item .dot { width: 8px; height: 8px; border-radius: 3px; flex-shrink: 0; margin: 0 5px; }
.rail-item .dot.tag { background: var(--text-3); border-radius: 50%; width: 7px; height: 7px; }
.rail-item .rail-edit { opacity: 0; margin-inline-end: -4px; }
.rail-item:hover .rail-edit, .rail-item:focus-within .rail-edit { opacity: 1; }
.rail-group { height: 28px; color: var(--text-3); font-size: 12px; font-weight: 600; margin-top: 6px; text-transform: uppercase; letter-spacing: 0.03em; }
.rail-group svg { width: 15px; height: 15px; }
.rail-empty { padding: 4px 10px; font-size: 12px; color: var(--text-4); }
.sidebar-bottom { border-top: 1px solid var(--line); padding-top: 8px; margin-top: 8px; display: flex; flex-direction: column; gap: 2px; }
.new-task { margin: 6px 0 10px; height: 34px; border-radius: var(--r-full); justify-content: space-between; padding: 0 12px; width: 100%; box-shadow: 0 2px 8px var(--ruby-shadow-sm); }
.new-task-label { flex: 1; text-align: start; margin-inline-start: 6px; font-size: 13px; font-weight: 600; }
.new-task-key { padding: 1px 6px; border-radius: var(--r-full); background: var(--ruby-active); color: var(--on-ruby); font-family: var(--font-code); font-size: 10px; font-weight: 600; line-height: 1.2; }
.update-pill { display: flex; align-items: center; gap: 8px; height: 32px; padding: 0 10px; border-radius: var(--r-md); background: var(--ruby-soft); color: var(--ruby-text); font-size: 13px; font-weight: 600; }
.update-pill.quiet { background: transparent; color: var(--text-3); font-weight: 500; }
.sync-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--ok); margin-inline-start: auto; }
.tabbar button { position: relative; }
.tabbar .sync-dot { position: absolute; top: 2px; inset-inline-end: 50%; margin-inline-end: -17px; }
.sync-dot.err { background: var(--danger); }
.sync-dot.busy { background: var(--text-3); animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: .35; } }

/* ---------- main / topbar ---------- */
.main { display: flex; flex-direction: column; min-width: 0; min-height: 0; position: relative; }
.topbar { height: var(--topbar-h); display: flex; align-items: center; padding: 0 18px; gap: 6px; flex-shrink: 0; background: var(--bg-card); border-bottom: 1px solid var(--line); z-index: 25; }
.topbar-menu { display: none; }
/* one sidebar toggle in the top bar: visible only while the sidebar is off-screen (collapsed on desktop, drawer on phones) */
.topbar-expand { display: none; }
.topbar-spacer { flex: 1; }
.crumb { display: flex; align-items: center; gap: 4px; min-width: 0; overflow: hidden; }
.crumb button { height: 30px; padding: 0 8px; border-radius: var(--r-sm); color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 240px; display: inline-flex; align-items: center; gap: 6px; font-weight: 500; font-size: 13px; }
.crumb button:hover { background: var(--hover); color: var(--text); }
.crumb button:last-child { color: var(--text); font-weight: 600; }
.crumb .sep { color: var(--text-3); padding: 0 3px; font-family: var(--font-code); font-size: 11px; }
.crumb .dot { width: 8px; height: 8px; border-radius: 3px; display: inline-block; }
.tbtn { height: 30px; padding: 0 10px; border-radius: var(--r-sm); display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text-2); white-space: nowrap; font-weight: 500; }
.tbtn:hover { background: var(--hover); color: var(--text); }
.tbtn.on { color: var(--ruby-text); background: var(--ruby-soft); }
.tbtn svg { width: 15px; height: 15px; }
.sync-pill { height: 28px; padding: 0 10px; border-radius: var(--r-full); display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-3); background: var(--bg-surface-low); }
.sync-pill:hover { background: var(--hover); color: var(--text); }
.sync-pill svg { width: 14px; height: 14px; }
.sync-pill.busy svg { animation: spin 1s linear infinite; }
.sync-pill.err { color: var(--danger); }
.sync-pill.off { color: var(--chip-amber-t); }
@keyframes spin { to { transform: rotate(360deg); } }

.ibtn { width: 30px; height: 30px; display: inline-flex; align-items: center; justify-content: center; border-radius: var(--r-md); color: var(--text-2); flex-shrink: 0; transition: background var(--t-fast), color var(--t-fast); }
.ibtn:hover { background: var(--hover); color: var(--text); }
.ibtn.xs { width: 22px; height: 22px; border-radius: var(--r-sm); }
.ibtn.xs svg { width: 14px; height: 14px; }
.ibtn.danger:hover { color: var(--danger); background: var(--chip-red); }

/* ---------- page ---------- */
.app.peek-open .scroller { margin-inline-end: var(--peek-w); }
.scroller { flex: 1; overflow-y: auto; overflow-x: hidden; min-height: 0; scrollbar-gutter: stable; }
.page { max-width: 1180px; margin: 0 auto; padding: 32px 40px 96px; }
.page.wide { max-width: none; padding-inline: 40px; }
.page-head { display: flex; flex-direction: column; }
.page-icon { width: 56px; height: 56px; border-radius: var(--r-lg); background: var(--ruby-subtle, var(--ruby-soft)); color: var(--ruby); display: flex; align-items: center; justify-content: center; box-shadow: var(--shadow-sm); flex-shrink: 0; }
.page-icon svg { width: 28px; height: 28px; stroke-width: 1.7; }
.page-icon .dot { width: 22px; height: 22px; border-radius: 7px; }
.page-title { margin: 12px 0 0; font-size: 28px; font-weight: 600; line-height: 1.25; letter-spacing: -0.02em; overflow-wrap: anywhere; }
.page-sub { margin: 6px 0 0; color: var(--text-3); font-size: 13px; font-weight: 500; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* ---------- database bar ---------- */
.db-bar { display: flex; align-items: center; gap: 10px; border-bottom: 1px solid var(--line); margin-top: 24px; padding: 8px 0; position: sticky; top: 0; background: var(--bg); z-index: 10; }
.db-tabs { display: inline-flex; align-items: center; gap: 2px; min-width: 0; padding: 2.5px; border-radius: var(--r-md); background: var(--bg-surface-low); border: 1px solid var(--line); overflow-x: auto; scrollbar-width: none; }
.db-tabs::-webkit-scrollbar { display: none; }
.db-tabs button { height: 28px; padding: 0 12px; display: inline-flex; align-items: center; gap: 6px; font-weight: 500; font-size: 13px; color: var(--text-2); border-radius: var(--r-sm); border: 0; margin: 0; transition: all var(--t-fast); white-space: nowrap; }
.db-tabs button svg { width: 15px; height: 15px; color: var(--text-3); }
.db-tabs button:hover:not([aria-selected="true"]) { background: var(--hover); color: var(--text); }
.db-tabs button[aria-selected="true"] { color: var(--text); background: var(--bg-card); font-weight: 600; box-shadow: 0 1px 3px rgba(0, 0, 0, .06); }
.db-tabs button[aria-selected="true"] svg { color: var(--ruby); }
.db-tools { margin-inline-start: auto; display: flex; align-items: center; gap: 4px; }
/* Always its full size, never an animated-width icon-to-box reveal: that pattern has no
   thrash-free version when it has to actually push sibling toolbar buttons over on expand — the
   box itself was the layout cost, not the easing. A static field sidesteps the problem entirely. */
.search { display: flex; align-items: center; gap: 6px; height: 30px; padding: 0 8px; border-radius: var(--r-md); color: var(--text-3); width: 160px; overflow: hidden; cursor: text; border: 1px solid transparent; transition: background var(--t-fast), border-color var(--t-fast); }
.search svg { width: 16px; height: 16px; flex-shrink: 0; }
.search input { border: 0; background: transparent; outline: 0; width: 100%; min-width: 0; font-size: 13px; color: var(--text); padding: 0; }
.search input::-webkit-search-cancel-button { display: none; }
.search:hover { background: var(--hover); }
.search:focus-within, .search.has-q { background: var(--bg-card); border-color: var(--line); box-shadow: var(--shadow-sm); }
.split { display: inline-flex; margin-inline-start: 6px; border-radius: var(--r-full); overflow: hidden; box-shadow: 0 2px 8px var(--ruby-shadow-sm); }
.split .btn { border-radius: 0; box-shadow: none; }
.split-chev { width: 26px; padding: 0; border-inline-start: 1px solid rgba(255, 255, 255, .22); }
.split-chev svg { width: 14px; height: 14px; }

/* ---------- buttons ---------- */
.btn { height: 32px; padding: 0 14px; border-radius: var(--r-md); display: inline-flex; align-items: center; justify-content: center; gap: 6px; font-weight: 500; font-size: 13.5px; white-space: nowrap; background: var(--bg-card); border: 1px solid var(--line); box-shadow: var(--shadow-sm); color: var(--text); transition: all var(--t-fast); }
.btn:hover { background: var(--bg-surface-low); border-color: var(--line-strong); }
.btn:active { transform: translateY(.5px); }
.btn svg { width: 16px; height: 16px; }
.btn.sm { height: 28px; padding: 0 10px; font-size: 12.5px; }
.btn.primary { border: 0; border-radius: var(--r-full); background: var(--ruby); color: var(--on-ruby); font-weight: 600; box-shadow: 0 2px 8px var(--ruby-shadow-sm); }
.btn.primary:hover { background: var(--ruby-hover); }
.btn.ghost { background: transparent; border-color: transparent; box-shadow: none; color: var(--text-2); }
.btn.ghost:hover { background: var(--hover); color: var(--text); }
.btn.ghost.danger { color: var(--danger); }
.btn.ghost.danger:hover { background: var(--chip-red); }
.btn:disabled { opacity: .5; cursor: default; }

/* ---------- capture (inline new row) ---------- */
.capture { padding: 8px 0 4px; }
.capture-line { display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 6px 14px; border-radius: var(--r-lg); background: var(--bg-card); border: 1px solid var(--line); box-shadow: var(--shadow-sm); transition: border-color var(--t-fast), box-shadow var(--t-fast); }
.capture-line:focus-within { border-color: var(--ruby); box-shadow: 0 0 0 1px var(--ruby), var(--shadow-sm); }
.capture-line .cb { width: 18px; height: 18px; border-radius: 4px; border: 1.5px solid var(--text-3); flex-shrink: 0; }
.capture-line input { flex: 1; min-width: 0; border: 0; background: transparent; outline: 0; font-size: 14px; }
.capture-chips { display: flex; flex-wrap: wrap; gap: 6px; padding: 8px 36px 2px; min-height: 0; }
.capture-chips:empty { display: none; }

/* ---------- chips / pills ---------- */
.chip, .pill { display: inline-flex; align-items: center; gap: 4px; height: 22px; padding: 0 8px; border-radius: var(--r-sm); font-size: 12px; font-weight: 500; white-space: nowrap; background: var(--chip-gray); color: var(--chip-gray-t); line-height: 1; }
.chip svg, .pill svg { width: 12px; height: 12px; }
.pill.p3, .chip.p3, .chip.red { background: var(--chip-red); color: var(--chip-red-t); }
.pill.p2, .chip.p2, .chip.amber { background: var(--chip-amber); color: var(--chip-amber-t); }
.pill.p1, .chip.p1, .chip.blue { background: var(--chip-blue); color: var(--chip-blue-t); }
.chip.green { background: var(--chip-green); color: var(--chip-green-t); }
.chip.purple, .pill.tag { background: var(--chip-purple); color: var(--chip-purple-t); }
button.chip { height: 26px; padding: 0 10px; border-radius: var(--r-full); background: var(--hover); color: var(--text-2); }
button.chip:hover { background: var(--active); color: var(--text); }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 3px; flex-shrink: 0; }

/* ---------- checkbox ---------- */
.cbx { display: inline-flex; align-items: center; cursor: pointer; flex-shrink: 0; }
.cbx input { position: absolute; opacity: 0; width: 0; height: 0; }
.cb { width: 18px; height: 18px; border-radius: 4px; border: 1.5px solid var(--text-3); display: inline-flex; align-items: center; justify-content: center; transition: all 150ms cubic-bezier(.2, .8, .2, 1); flex-shrink: 0; background: var(--bg-card); }
.cb svg { width: 13px; height: 13px; stroke: var(--on-ruby); stroke-width: 2.5; opacity: 0; transform: scale(.6); transition: opacity var(--t-mid), transform var(--t-mid) var(--ease); }
.cbx:hover .cb { border-color: var(--ruby); }
.cbx input:checked + .cb { background: var(--ruby); border-color: var(--ruby); }
.cbx input:checked + .cb svg { opacity: 1; transform: scale(1); }
.cbx input:focus-visible + .cb { outline: 2px solid var(--ruby-ring); outline-offset: 1px; }
.cbx.lg .cb { width: 24px; height: 24px; border-radius: 6px; }
.cbx.lg .cb svg { width: 16px; height: 16px; }
.cbx.md .cb { width: 20px; height: 20px; border-radius: 5px; }
.cbx.md .cb svg { width: 14px; height: 14px; }

/* ---------- list view ---------- */
.rows { display: flex; flex-direction: column; padding-top: 4px; }
.group { display: flex; align-items: center; gap: 8px; height: 36px; margin-top: 10px; font-size: 13px; font-weight: 600; color: var(--text); }
.group svg { width: 14px; height: 14px; color: var(--text-3); }
.group .n { font-size: 11px; padding: 1px 6px; border-radius: var(--r-full); background: var(--ruby-soft); color: var(--ruby); font-weight: 600; font-variant-numeric: tabular-nums; }
.group.overdue { color: var(--danger); }
.group.tomorrow, .group.thisWeek, .group.later, .group.noDate { color: var(--text-2); }
.group .g-add { opacity: 0; width: 22px; height: 22px; }
.group:hover .g-add { opacity: .7; }
.row { display: flex; align-items: center; gap: 10px; min-height: 46px; padding: 0 10px; border-radius: var(--r-md); border-bottom: 1px solid var(--line); position: relative; outline: none; cursor: default; transition: background var(--t-fast), opacity var(--t-slow), transform var(--t-slow) var(--ease); }
/* display:contents on desktop makes .row-content invisible to layout — its children act as
   direct flex items of .row, unchanged from before swipe-to-act was added; mobile turns it into
   a real translatable box instead (see the phone media query). */
.row-content { display: contents; }
.row-swipe-bg { display: none; }
.row:hover, .row:focus-visible { background: var(--hover); }
.row.selected { background: var(--ruby-soft); }
.row:focus-visible { box-shadow: inset 0 0 0 2px var(--ruby-ring); }
.row-grip { position: absolute; inset-inline-start: -18px; top: 14px; color: var(--text-4); opacity: 0; cursor: grab; }
.row:hover .row-grip { opacity: 1; }
.row-main { flex: 1; min-width: 0; display: flex; align-items: center; gap: 8px; cursor: pointer; height: 100%; padding: 8px 0; }
.row-title { font-size: 14px; font-weight: 500; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; unicode-bidi: isolate; text-align: start; }
.row.done .row-title { color: var(--text-3); text-decoration: line-through; opacity: 0.55; }
.row-open { opacity: 0; height: 24px; padding: 0 6px; border-radius: var(--r-sm); background: var(--bg-card); border: 1px solid var(--line); box-shadow: var(--shadow-sm); font-size: 12px; color: var(--text-2); display: inline-flex; align-items: center; gap: 4px; white-space: nowrap; }
.row-open svg { width: 13px; height: 13px; }
.row:hover .row-open { opacity: 1; }
.row-meta { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-3); white-space: nowrap; flex-shrink: 0; }
.row-meta > span { display: inline-flex; align-items: center; gap: 4px; }
.row-meta svg { width: 13px; height: 13px; }
.row-meta .due.overdue { color: var(--danger); font-weight: 600; }
.row-meta .due.today { color: var(--ruby); font-weight: 600; }
.row-meta .list { color: var(--text-2); }
.row-meta .list i { width: 8px; height: 8px; border-radius: 3px; display: inline-block; }
.row-meta .sub.full { color: var(--ok); }
.row-del { opacity: 0; }
.row:hover .row-del, .row:focus-within .row-del { opacity: 1; }
.row.settling .cb { transform: scale(1.12); }
.row.leaving { opacity: 0; transform: translateX(var(--leave-x)); overflow: hidden; height: 0 !important; min-height: 0; padding-top: 0; padding-bottom: 0; }
[dir="rtl"] { --leave-x: -24px; } [dir="ltr"] { --leave-x: 24px; }
.row.dragging { opacity: .4; }
.row.drop-before::before, .row.drop-after::after { content: ''; position: absolute; inset-inline: 6px; height: 2px; background: var(--ruby); border-radius: 1px; }
.row.drop-before::before { top: -1px; } .row.drop-after::after { bottom: -1px; }
.row-new { display: flex; align-items: center; gap: 8px; height: 38px; padding: 0 10px; border-radius: var(--r-md); width: 100%; text-align: start; color: var(--text-3); font-size: 14px; }
.row-new:hover { background: var(--hover); color: var(--text-2); }
.row-new svg { width: 15px; height: 15px; }

/* ---------- table view ---------- */
.table-wrap { overflow-x: auto; margin: 4px -8px 0; padding: 0 8px; scrollbar-width: thin; }
.table { border-collapse: collapse; width: 100%; min-width: 720px; font-size: 14px; }
.table th { text-align: start; font-weight: 500; font-size: 12px; color: var(--text-3); height: 34px; padding: 0 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table th svg { width: 13px; height: 13px; vertical-align: -2px; margin-inline-end: 5px; }
.table td { height: 36px; padding: 0 8px; border-bottom: 1px solid var(--line); vertical-align: middle; white-space: nowrap; }
.table td.title-cell { white-space: normal; min-width: 260px; }
.table tr.done td { color: var(--text-3); }
.table tr.done .t-title { text-decoration: line-through; }
.table tr:hover td { background: var(--hover); }
.table tr.selected td { background: var(--ruby-soft); }
.table td:first-child { border-start-start-radius: var(--r-sm); border-end-start-radius: var(--r-sm); }
.table td:last-child { border-start-end-radius: var(--r-sm); border-end-end-radius: var(--r-sm); }
.t-title-wrap { display: flex; align-items: center; gap: 10px; }
.t-title { flex: 1; min-width: 0; cursor: pointer; overflow: hidden; text-overflow: ellipsis; unicode-bidi: isolate; text-align: start; }
.cell-btn { height: 28px; padding: 0 6px; margin: 0 -6px; border-radius: var(--r-sm); display: inline-flex; align-items: center; gap: 6px; max-width: 100%; color: inherit; text-align: start; }
.cell-btn:hover { background: var(--active); }
.cell-btn.empty { color: var(--text-4); }
.cell-btn .dot { width: 8px; height: 8px; }
.table .tags { display: inline-flex; gap: 4px; }
.table .t-new td { color: var(--text-3); cursor: pointer; }
.table .t-new:hover td { color: var(--text-2); }
.table .t-new svg { width: 15px; height: 15px; vertical-align: -3px; margin-inline-end: 6px; }
.t-group th { height: 40px; padding-top: 10px; border-bottom: 0; font-size: 13px; font-weight: 600; color: var(--text); }
.t-group.overdue th { color: var(--danger); }

/* ---------- board ---------- */
.board { display: flex; gap: 16px; padding: 16px 0 8px; overflow-x: auto; align-items: flex-start; scrollbar-width: thin; }
.col { width: 272px; flex-shrink: 0; display: flex; flex-direction: column; gap: 8px; }
.col-head { display: flex; align-items: center; gap: 8px; height: 32px; }
.col-head .n { font-size: 12px; color: var(--text-3); }
.col-head .ibtn { opacity: 0; margin-inline-start: auto; }
.col:hover .col-head .ibtn { opacity: 1; }
.col.drop { background: var(--hover); border-radius: var(--r-lg); }
.card { display: flex; flex-direction: column; gap: 8px; padding: 10px 12px; border-radius: var(--r-lg); background: var(--bg); box-shadow: var(--shadow-sm); cursor: pointer; transition: box-shadow var(--t-fast), transform var(--t-fast); }
.card:hover { box-shadow: var(--shadow-md); }
.card.selected { box-shadow: 0 0 0 2px var(--ruby-ring), var(--shadow-sm); }
.card.dragging { opacity: .4; }
.card-title { display: flex; align-items: flex-start; gap: 8px; font-weight: 500; line-height: 1.4; unicode-bidi: isolate; text-align: start; }
.card.done .card-title span { color: var(--text-3); text-decoration: line-through; }
.card-meta { display: flex; flex-wrap: wrap; gap: 6px; font-size: 12px; color: var(--text-3); align-items: center; }
.card-meta > span { display: inline-flex; align-items: center; gap: 4px; }
.card-meta svg { width: 13px; height: 13px; }
.card-meta .overdue { color: var(--danger); }
.card-meta .list i { width: 8px; height: 8px; border-radius: 3px; display: inline-block; }
.col-new { display: flex; align-items: center; gap: 6px; height: 32px; padding: 0 8px; border-radius: var(--r-md); color: var(--text-3); text-align: start; }
.col-new:hover { background: var(--hover); color: var(--text-2); }
.col-new svg { width: 15px; height: 15px; }

/* ---------- calendar ---------- */
.calendar { padding-top: 12px; }
.cal-head { display: flex; align-items: center; gap: 6px; height: 36px; margin-bottom: 8px; }
.cal-title { font-weight: 600; font-size: 15px; margin: 0 6px; }
.cal-head .today-btn { margin-inline-start: 4px; }
.cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); border-top: 1px solid var(--line); border-inline-start: 1px solid var(--line); }
.cal-wd { font-size: 12px; color: var(--text-3); height: 28px; display: flex; align-items: center; padding: 0 8px; border-inline-end: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.cal-day { min-height: 108px; padding: 6px; border-inline-end: 1px solid var(--line); border-bottom: 1px solid var(--line); display: flex; flex-direction: column; gap: 3px; cursor: pointer; }
.cal-day:hover { background: var(--hover); }
.cal-day.other { color: var(--text-4); background: var(--bg-2); }
.cal-day.drop { background: var(--ruby-soft); }
.cal-d { font-size: 12px; font-weight: 500; color: var(--text-2); height: 22px; width: 22px; display: inline-flex; align-items: center; justify-content: center; border-radius: 50%; align-self: flex-start; }
.cal-day.today .cal-d { background: var(--ruby); color: var(--on-ruby); font-weight: 700; }
.cal-day.holiday .cal-d { color: var(--danger); }
.cal-ev { font-size: 12px; padding: 2px 6px; border-radius: var(--r-sm); background: var(--chip-gray); color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: flex; align-items: center; gap: 5px; cursor: pointer; }
.cal-ev i { width: 6px; height: 6px; border-radius: 2px; background: var(--text-3); flex-shrink: 0; }
.cal-ev.done { color: var(--text-3); text-decoration: line-through; }
.cal-ev.p3 { background: var(--chip-red); color: var(--chip-red-t); }
.cal-ev:hover { filter: brightness(.96); }
.cal-more { font-size: 11px; color: var(--text-3); padding: 0 6px; }

/* ---------- empty / skeleton ---------- */
.empty-state { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; padding: 36px 12px; text-align: center; }
.empty-glyph { width: 40px; height: 40px; color: var(--text-4); stroke-width: 1.4; }
.empty-text { margin: 4px 0 0; font-size: 16px; font-weight: 600; }
.empty-hint { margin: 0; color: var(--text-3); font-size: 13px; max-width: 360px; }
.empty-state .btn { margin-top: 8px; }
.skeleton { display: none; flex-direction: column; gap: 14px; padding: 16px 6px; }
.booting .skeleton { display: flex; }
.booting .rows, .booting .empty-state, .booting .page-head, .booting .db-bar { visibility: hidden; }
.sk-row { display: flex; align-items: center; gap: 10px; }
.sk-box { width: 16px; height: 16px; border-radius: 4px; background: var(--hover); flex-shrink: 0; }
.sk-line { height: 12px; border-radius: 4px; background: linear-gradient(90deg, var(--hover) 25%, var(--active) 50%, var(--hover) 75%); background-size: 200% 100%; animation: shimmer 1.4s linear infinite; }
.sk-line.w55 { width: 55%; } .sk-line.w40 { width: 40%; } .sk-line.w62 { width: 62%; } .sk-line.w48 { width: 48%; }
.sk-line.w12 { width: 60px; margin-inline-start: auto; } .sk-line.w16 { width: 80px; margin-inline-start: auto; } .sk-line.w10 { width: 48px; margin-inline-start: auto; } .sk-line.w14 { width: 70px; margin-inline-start: auto; }
@keyframes shimmer { to { background-position: -200% 0; } }
.sheet-actions { display: flex; justify-content: flex-end; padding: 16px 0; }

/* ---------- report ---------- */
.report { display: flex; flex-direction: column; gap: 20px; margin-top: 24px; }
.ledger { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); border-top: 1px solid var(--line-strong); border-bottom: 1px solid var(--line); }
.ledger-row { display: flex; flex-direction: column; gap: 2px; padding: 14px 12px; border-inline-end: 1px solid var(--line); }
.ledger-row:last-child { border-inline-end: 0; }
.ledger-k { font-size: 12px; color: var(--text-3); font-weight: 500; }
.ledger-v { font-size: 26px; font-weight: 700; font-variant-numeric: tabular-nums; }
.ledger-v.accent { color: var(--ruby-text); } .ledger-v.red { color: var(--danger); }
.panel h2 { margin: 0 0 12px; font-size: 14px; font-weight: 600; color: var(--text-2); }
.panel-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 24px; }
.bars { display: flex; gap: 8px; align-items: flex-end; height: 140px; padding: 0 4px; }
.bar { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; gap: 6px; }
.bar-v { font-size: 12px; color: var(--text-3); font-variant-numeric: tabular-nums; }
.bar-f { width: 100%; max-width: 40px; border-radius: 4px 4px 0 0; background: var(--active); min-height: 2px; }
.bar.today .bar-f { background: var(--ruby); }
.bar-l { font-size: 12px; color: var(--text-3); }
.rows-meter { display: flex; flex-direction: column; gap: 8px; }
.meter { display: grid; grid-template-columns: minmax(0, 1fr) 100px 32px; align-items: center; gap: 10px; font-size: 13px; }
.meter-k { display: flex; align-items: center; gap: 6px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.meter-k i { width: 8px; height: 8px; border-radius: 3px; display: inline-block; flex-shrink: 0; }
.meter-t { height: 6px; border-radius: 3px; background: var(--hover); overflow: hidden; }
.meter-f { display: block; height: 100%; background: var(--ruby); border-radius: 3px; }
.meter-v { text-align: end; color: var(--text-2); font-variant-numeric: tabular-nums; }
.export-row { display: flex; flex-wrap: wrap; gap: 8px; }

/* ---------- peek (task page) ---------- */
.scrim { position: fixed; inset: 0; background: rgba(0, 0, 0, .28); z-index: 40; animation: fade var(--t-mid) both; backdrop-filter: blur(2px); -webkit-backdrop-filter: blur(2px); }
@keyframes fade { from { opacity: 0; } }
.peek { position: fixed; top: 0; bottom: 0; inset-inline-end: 0; width: var(--peek-w); max-width: 100vw; background: var(--bg-card); border-inline-start: 1px solid var(--line); box-shadow: -8px 0 32px rgba(0, 0, 0, .10); z-index: 45; display: flex; flex-direction: column; animation: peek-in var(--t-slow) var(--ease) both; }
:root[data-theme="dark"] .peek, :root:not([data-theme="light"]).sys-dark .peek { box-shadow: -8px 0 32px rgba(0, 0, 0, .40); }
[dir="rtl"] { --peek-x: -24px; } [dir="ltr"] { --peek-x: 24px; }
@keyframes peek-in { from { opacity: 0; transform: translateX(var(--peek-x)); } }
.peek.full { width: 100vw; border: 0; }
.peek-bar { height: var(--topbar-h); display: flex; align-items: center; justify-content: space-between; gap: 4px; padding: 0 16px; flex-shrink: 0; border-bottom: 1px solid var(--line); background: var(--bg-card); }
.peek-crumb { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text-2); margin-inline-start: 4px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-weight: 500; }
.peek-crumb i { width: 8px; height: 8px; border-radius: 3px; display: inline-block; }
.peek-crumb svg { width: 14px; height: 14px; }
.peek-saved { font-size: 12px; color: var(--text-3); margin: 0 6px; font-family: var(--f-mono); }
.peek-scroll { flex: 1; overflow-y: auto; padding: 24px 28px 80px; }
.peek-title-row { display: flex; align-items: flex-start; gap: 14px; }
.peek-title-row .cbx { margin-top: 6px; }
.d-title { flex: 1; min-width: 0; border: 0; background: transparent; outline: 0; resize: none; font-size: 24px; font-weight: 700; letter-spacing: -0.015em; line-height: 1.35; padding: 0; margin: 0; overflow: hidden; unicode-bidi: plaintext; color: var(--text); }
.props { display: flex; flex-direction: column; margin-top: 20px; padding: 12px 14px; background: var(--bg-side); border: 1px solid var(--line); border-radius: 12px; gap: 6px; }
.prop { display: flex; align-items: center; min-height: 32px; gap: 8px; padding: 4px 0; }
.prop-k { width: 130px; flex-shrink: 0; display: inline-flex; align-items: center; gap: 8px; color: var(--text-2); font-size: 13px; font-weight: 500; }
.prop-k svg { width: 15px; height: 15px; color: var(--text-3); }
.prop-v { flex: 1; min-width: 0; display: flex; align-items: center; font-size: 13px; }
.prop.meta .prop-v { font-size: 12.5px; color: var(--text-3); font-family: var(--f-mono); }
.pv { height: 28px; padding: 0 8px; border-radius: var(--r-sm); display: inline-flex; align-items: center; gap: 6px; max-width: 100%; text-align: start; font-size: 13px; }
.pv:hover { background: var(--hover); }
.pv .placeholder { color: var(--text-4); }
.pv-alt { font-size: 12px; color: var(--text-3); }
.pv-input { height: 28px; padding: 0 8px; border: 0; border-radius: var(--r-sm); background: transparent; outline: 0; min-width: 0; max-width: 100%; font-size: 13px; }
.pv-input:hover { background: var(--hover); }
.pv-input:focus { background: var(--hover); box-shadow: inset 0 0 0 2px var(--ruby-ring); }
select.pv-input { appearance: none; -webkit-appearance: none; padding-inline-end: 22px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23888' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-size: 14px; background-position: left 6px center; }
[dir="ltr"] select.pv-input { background-position: right 6px center; }
.time-row { gap: 14px; }
input[type="time"].pv-input { width: 108px; direction: ltr; font-family: var(--f-mono); }
.seg { display: inline-flex; padding: 2px; border-radius: var(--r-md); background: var(--hover); gap: 2px; }
.seg button { height: 26px; padding: 0 10px; border-radius: var(--r-sm); font-size: 12.5px; font-weight: 500; color: var(--text-2); }
.seg button:hover { color: var(--text); }
.seg button.active { background: var(--bg-card); color: var(--text); box-shadow: var(--shadow-sm); }
#d-prio button[data-p="3"].active { color: var(--priority-urgent); font-weight: 600; }
#d-prio button[data-p="2"].active { color: var(--priority-high); font-weight: 600; }
#d-prio button[data-p="1"].active { color: var(--priority-medium); font-weight: 600; }
.switch { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-size: 13px; color: var(--text-2); }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch-track { width: 34px; height: 20px; border-radius: 999px; background: var(--text-4); position: relative; transition: background var(--t-mid); flex-shrink: 0; }
.switch-track::after { content: ''; position: absolute; top: 2px; inset-inline-start: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: transform var(--t-mid) var(--ease); box-shadow: 0 1px 2px rgba(0, 0, 0, .25); }
.switch input:checked + .switch-track { background: var(--ruby); }
[dir="rtl"] .switch input:checked + .switch-track::after { transform: translateX(-14px); }
[dir="ltr"] .switch input:checked + .switch-track::after { transform: translateX(14px); }
.switch input:focus-visible + .switch-track { outline: 2px solid var(--ruby-ring); outline-offset: 2px; }

.d-section { margin-top: 20px; }
.d-label { display: flex; align-items: center; gap: 8px; height: 30px; font-weight: 600; font-size: 14px; }
.d-label svg { width: 16px; height: 16px; color: var(--text-3); }
.d-progress { font-size: 12px; color: var(--text-3); font-weight: 500; font-family: var(--f-mono); }
.progress { width: 120px; height: 4px; border-radius: 999px; background: var(--line); overflow: hidden; margin-inline-start: auto; }
.progress i { display: block; height: 100%; width: 100%; background: var(--ruby); transform: scaleX(0); transform-origin: inline-start; transition: transform var(--t-slow) var(--ease); border-radius: 999px; }
.subtasks { display: flex; flex-direction: column; gap: 2px; }
.subtask { display: flex; align-items: center; gap: 10px; min-height: 32px; padding: 2px 6px; border-radius: var(--r-sm); transition: background var(--t-fast); }
.subtask:hover { background: var(--hover); }
.subtask input[type="text"] { flex: 1; min-width: 0; border: 0; background: transparent; outline: 0; font-size: 13.5px; padding: 4px 0; unicode-bidi: plaintext; }
.subtask.done input[type="text"] { color: var(--text-3); text-decoration: line-through; opacity: 0.65; }
.subtask .ibtn { opacity: 0; }
.subtask:hover .ibtn, .subtask:focus-within .ibtn { opacity: 1; }
.subtask-add { display: flex; align-items: center; gap: 10px; min-height: 32px; padding: 2px 6px; color: var(--text-3); font-size: 13px; border-radius: var(--r-sm); }
.subtask-add:hover { color: var(--ruby); background: var(--ruby-soft); }
.subtask-add svg { width: 15px; height: 15px; }
.subtask-add input { flex: 1; border: 0; background: transparent; outline: 0; font-size: 14px; padding: 4px 0; }
.d-notes { width: 100%; margin-top: 16px; border: 0; background: transparent; outline: 0; resize: none; font-size: 14px; line-height: 1.7; padding: 0; overflow: hidden; min-height: 60px; unicode-bidi: plaintext; }
.d-meta { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- menus / popovers ---------- */
.menu { position: fixed; z-index: 70; min-width: 200px; max-width: 320px; padding: 4px 0; border-radius: var(--r-lg); background: var(--bg); box-shadow: var(--shadow-md); animation: pop var(--t-mid) var(--ease) both; max-height: min(60vh, 420px); overflow-y: auto; }
@keyframes pop { from { opacity: 0; transform: scale(.98) translateY(-2px); } }
.menu-title { padding: 6px 12px 4px; font-size: 11px; font-weight: 600; color: var(--text-3); }
.menu-item { display: flex; align-items: center; gap: 8px; height: 30px; padding: 0 8px; margin: 0 4px; border-radius: var(--r-sm); width: calc(100% - 8px); text-align: start; font-size: 14px; color: var(--text); }
.menu-item:hover, .menu-item.active { background: var(--hover); }
.menu-item svg { width: 16px; height: 16px; color: var(--text-2); }
.menu-item .dot { width: 8px; height: 8px; margin: 0 4px; }
.menu-item .mi-hint { margin-inline-start: auto; font-size: 11px; color: var(--text-3); }
.menu-item.on { font-weight: 600; }
.menu-item.on::after { content: ''; width: 6px; height: 6px; border-radius: 50%; background: var(--ruby); margin-inline-start: auto; }
.menu-item.danger { color: var(--danger); }
.menu-sep { height: 1px; background: var(--line); margin: 4px 0; }

.datepicker { position: fixed; z-index: 70; width: 300px; padding: 10px; border-radius: var(--r-lg); background: var(--bg); box-shadow: var(--shadow-md); animation: pop var(--t-mid) var(--ease) both; }
.dp-quick { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 8px; }
.dp-head { display: flex; align-items: center; justify-content: space-between; height: 30px; }
.dp-title { font-size: 13px; font-weight: 600; }
.dp-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 2px; text-align: center; }
.dp-wd { height: 24px; line-height: 24px; font-size: 11px; color: var(--text-3); }
.dp-day { height: 32px; border-radius: var(--r-md); font-size: 13px; font-variant-numeric: tabular-nums; }
.dp-day:hover { background: var(--hover); }
.dp-day.holiday { color: var(--danger); }
.dp-day.today { box-shadow: inset 0 0 0 1.5px var(--ruby); font-weight: 700; }
.dp-day.selected { background: var(--ruby); color: var(--on-ruby); box-shadow: none; }

/* ---------- overlays / dialogs ---------- */
.overlay { position: fixed; inset: 0; z-index: 60; background: rgba(0, 0, 0, .32); display: flex; align-items: center; justify-content: center; padding: 16px; animation: fade var(--t-mid) both; }
.overlay.top { align-items: flex-start; padding-top: 12vh; }
.dialog { width: 460px; max-width: 100%; max-height: calc(100vh - 32px); overflow-y: auto; background: var(--bg); border-radius: var(--r-xl); box-shadow: var(--shadow-lg); padding: 16px 20px 20px; animation: dialog-in var(--t-slow) var(--ease) both; }
.dialog.sm { width: 400px; }
@keyframes dialog-in { from { opacity: 0; transform: translateY(8px) scale(.985); } }
.dialog-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.dialog-head h2 { margin: 0; font-size: 16px; font-weight: 700; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
.dialog-actions .ghost.danger { margin-inline-end: auto; }
.d-field { padding: 12px 0; border-top: 1px solid var(--line); }
.d-field:first-of-type { border-top: 0; }
.d-field .d-label { height: 26px; font-size: 13px; margin-bottom: 6px; }
.d-alt { font-size: 12px; color: var(--text-3); margin-top: 6px; }
.d-alt.hint { line-height: 1.6; }
.field-input { width: 100%; height: 34px; padding: 0 10px; border-radius: var(--r-md); border: 0; background: var(--bg); box-shadow: inset 0 0 0 1px var(--line-strong); outline: 0; transition: box-shadow var(--t-fast); }
.field-input:focus { box-shadow: inset 0 0 0 2px var(--ruby); }
select.field-input { appearance: auto; }
.acc-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.acc-row { display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: center; }
.acc-row.three { grid-template-columns: 1fr auto auto; }
.acc-who { display: flex; align-items: center; gap: 8px; font-weight: 500; }
.avatar { width: 28px; height: 28px; border-radius: 50%; background: var(--ruby); color: var(--on-ruby); display: inline-flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 700; }
.shortcuts { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 16px; font-size: 13px; }
.shortcuts div { display: flex; align-items: center; gap: 4px; color: var(--text-2); }
.shortcuts kbd { display: inline-flex; align-items: center; height: 20px; padding: 0 6px; border-radius: var(--r-sm); background: var(--hover); color: var(--text-2); font-size: 11px; }
.shortcuts span { margin-inline-start: 4px; }
.swatches { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.swatch { width: 26px; height: 26px; border-radius: 8px; transition: transform var(--t-fast); }
.swatch:hover { transform: scale(1.1); }
.swatch.active { box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px var(--text); }
.members { display: flex; flex-direction: column; gap: 4px; margin-top: 12px; }
.member { display: flex; align-items: center; gap: 10px; min-height: 40px; padding: 4px 8px; border-radius: var(--r-md); }
.member:hover { background: var(--hover); }
.member-who { display: flex; flex-direction: column; flex: 1; min-width: 0; font-size: 13px; }
.member-who b { font-weight: 600; }
.member-who span { color: var(--text-3); font-size: 12px; }
.member-role { font-size: 12px; color: var(--text-2); }
.auth-err { color: var(--danger); font-size: 13px; min-height: 0; margin-top: 8px; }
.auth-err:empty { display: none; }

/* palette */
.palette { width: 600px; max-width: 100%; background: var(--bg); border-radius: var(--r-xl); box-shadow: var(--shadow-lg); overflow: hidden; animation: dialog-in var(--t-slow) var(--ease) both; }
.palette-input { display: flex; align-items: center; gap: 10px; height: 48px; padding: 0 16px; border-bottom: 1px solid var(--line); color: var(--text-3); }
.palette-input input { flex: 1; border: 0; background: transparent; outline: 0; font-size: 16px; color: var(--text); min-width: 0; }
.palette-list { max-height: min(60vh, 440px); overflow-y: auto; padding: 6px 0; }
.palette-group { padding: 8px 16px 4px; font-size: 11px; font-weight: 600; color: var(--text-3); }
.palette-item { display: flex; align-items: center; gap: 10px; height: 34px; padding: 0 12px; margin: 0 4px; border-radius: var(--r-sm); width: calc(100% - 8px); text-align: start; color: var(--text); }
.palette-item.active { background: var(--hover); }
.palette-item svg { width: 16px; height: 16px; color: var(--text-2); }
.pi-text { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; unicode-bidi: isolate; }
.pi-hint { font-size: 11px; color: var(--text-3); }
.palette-empty { padding: 20px; text-align: center; color: var(--text-3); }

/* auth */
.auth { position: fixed; inset: 0; z-index: 65; background: var(--bg-side); display: flex; align-items: center; justify-content: center; padding: 16px; overflow-y: auto; }
.auth-card { width: 420px; max-width: 100%; background: var(--bg); border-radius: 16px; box-shadow: var(--shadow-md); padding: 24px 28px 20px; position: relative; }
.auth-brand { display: flex; align-items: center; gap: 10px; margin-bottom: 18px; }
.brand-name { font-size: 20px; font-weight: 800; }
.auth-close { margin-inline-start: auto; }
.auth-tabs { width: 100%; }
.auth-tabs button { flex: 1; }
.auth-title { margin: 20px 0 2px; font-size: 22px; font-weight: 800; }
.auth-sub { margin: 0 0 16px; color: var(--text-2); font-size: 13px; line-height: 1.6; }
.auth-form { display: flex; flex-direction: column; gap: 12px; }
.f { display: flex; flex-direction: column; gap: 5px; font-size: 13px; color: var(--text-2); }
.f em { font-style: normal; color: var(--danger); font-size: 12px; min-height: 0; }
.f em:empty { display: none; }
.f.invalid .field-input { box-shadow: inset 0 0 0 2px var(--danger); }
.pw { position: relative; display: flex; }
.pw .field-input { padding-inline-end: 34px; }
.pw-eye { position: absolute; inset-inline-end: 6px; top: 6px; }
.strength { display: flex; gap: 4px; margin-top: 4px; }
.strength i { flex: 1; height: 3px; border-radius: 2px; background: var(--hover); }
.strength[data-n="1"] i:nth-child(-n+1) { background: var(--danger); }
.strength[data-n="2"] i:nth-child(-n+2) { background: var(--chip-amber-t); }
.strength[data-n="3"] i:nth-child(-n+3) { background: var(--ok); }
.strength[data-n="4"] i { background: var(--ok); }
.auth-submit { height: 38px; margin-top: 4px; font-size: 15px; }
.auth-links { display: flex; justify-content: space-between; font-size: 13px; }
.auth-links a { color: var(--ruby-text); text-decoration: none; }
.auth-links a:hover { text-decoration: underline; }
.auth-terms { margin: 4px 0 0; font-size: 12px; color: var(--text-3); line-height: 1.6; text-align: center; }
.auth-done { display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 12px 0 4px; text-align: center; }
.auth-done svg { width: 44px; height: 44px; color: var(--ok); }
.auth-done p { margin: 0; line-height: 1.7; }

/* toast */
.toast { position: fixed; bottom: calc(24px + var(--safe-b)); left: 50%; transform: translateX(-50%); z-index: 80; display: flex; align-items: center; gap: 12px; height: 40px; padding: 0 6px 0 14px; border-radius: var(--r-lg); background: #1e1a1b; color: #fff; font-size: 13px; box-shadow: var(--shadow-toast); animation: toast-in var(--t-slow) var(--ease) both; white-space: nowrap; max-width: calc(100vw - 32px); }
[dir="rtl"] .toast { padding: 0 14px 0 6px; }
:root[data-theme="dark"] .toast, :root:not([data-theme="light"]).sys-dark .toast { background: #2e2628; }
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 8px); } }
.toast-btn { height: 28px; padding: 0 10px; border-radius: 5px; background: rgba(255, 255, 255, .12); font-size: 13px; font-weight: 600; display: inline-flex; align-items: center; gap: 5px; color: #fff; }
.toast-btn:hover { background: rgba(255, 255, 255, .2); }
.toast-btn svg { width: 14px; height: 14px; }

/* ---------- phone chrome ---------- */
.tabbar { display: none; }
.fab { display: none; }

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 1280px) { .page { padding-inline: 64px; } }
@media (max-width: 1100px) {
  :root { --peek-w: 480px; }
  .app.peek-open .scroller { margin-inline-end: 0; }
  .page { padding-inline: 40px; }
}
@media (max-width: 900px) {
  .page { padding: 32px 24px 120px; }
  .page-title { font-size: 34px; }
  .ledger { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .ledger-row:nth-child(2) { border-inline-end: 0; }
  .ledger-row:nth-child(-n+2) { border-bottom: 1px solid var(--line); }
  .panel-grid { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: fixed; top: 0; bottom: 0; inset-inline-start: 0; width: min(300px, 86vw); transform: translateX(var(--side-hide)); box-shadow: none; z-index: 50; padding-top: calc(8px + var(--safe-t)); }
  .app.sidebar-open .sidebar { transform: none; box-shadow: var(--shadow-lg); pointer-events: auto; }
  .app.rail-collapsed .sidebar { transform: translateX(var(--side-hide)); }
  /* Stitch's phone header: hamburger (opens the drawer) + wordmark at the start, a small muted
     page label centered, sync status + account avatar at the end. Command palette, copy-link,
     share and the desktop "…" catch-all still drop out — those live in the drawer/Settings. */
  .topbar { padding: 0 4px; padding-top: var(--safe-t); height: calc(56px + var(--safe-t)); justify-content: space-between; background: color-mix(in srgb, var(--bg) 85%, transparent); backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px); }
  .topbar-menu, #palette-btn, #link-btn { display: none !important; }
  .topbar-expand { display: inline-flex; order: -1; }
  .topbar .ibtn { width: 40px; height: 40px; }
  .crumb { font-size: 12px; font-weight: 500; color: var(--text-2); max-width: 130px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  #share-btn { display: none !important; }
  /* Every item in the desktop "…" menu already lives somewhere purpose-built on phones: favorite
     and copy-link have their own topbar icons, list management is on the sidebar row's own "…",
     language/calendar are in Settings → Preferences, exports/backup are in Settings → Data,
     Report is its own view. Keeping the catch-all button here just duplicates all of that. */
  #more-btn { display: none !important; }
  #sync-pill { width: 40px; height: 40px; padding: 0; border-radius: 50%; justify-content: center; background: var(--bg-surface-high); box-shadow: none; position: relative; }
  #sync-pill svg { width: 20px; height: 20px; }
  #sync-pill-text { display: none; }
  #sync-pill::after { content: ''; position: absolute; top: 9px; inset-inline-end: 9px; width: 7px; height: 7px; border-radius: 50%; background: var(--ruby); border: 2px solid var(--bg); opacity: 0; }
  #sync-pill.err::after { opacity: 1; }
  #topbar-avatar { display: inline-flex; width: 32px; height: 32px; flex-shrink: 0; }
  .page { padding: 12px 20px calc(120px + var(--safe-b)); }
  .page-icon { width: 44px; height: 44px; border-radius: 10px; }
  .page-icon svg { width: 26px; height: 26px; }
  .page-title { font-size: 30px; margin-top: 10px; }
  .page-sub { font-size: 13px; }
  /* Two rows instead of one cramped strip: the view tabs (when a list has them) on top, then a
     search field that's the dominant element — a real full-height card, not a squashed icon —
     with filter/sort as plain square icon buttons after it. Search is first in the markup, which
     in RTL puts it at the visual right/start edge, exactly where it reads as "the" control. */
  .db-bar { margin-top: 16px; top: 0; flex-wrap: wrap; row-gap: 10px; }
  .db-tabs { flex-basis: 100%; }
  .db-tabs button { height: 40px; font-size: 14px; }
  .db-tabs button span { display: none; }
  .db-tabs button[aria-selected="true"] span { display: inline; }
  .db-tools { flex-basis: 100%; margin-inline-start: 0; gap: 8px; }
  .split { display: none; }
  .search { flex: 1; width: auto; min-width: 0; height: 44px; padding: 0 14px; border-radius: var(--r-lg); }
  .search svg { width: 18px; height: 18px; }
  .search input { font-size: 14.5px; }
  .db-tools .tbtn { width: 44px; height: 44px; border-radius: var(--r-lg); justify-content: center; background: var(--bg-card); border: 1px solid var(--line); flex-shrink: 0; }
  .db-tools .tbtn span { display: none; }
  .db-tools .tbtn svg { width: 18px; height: 18px; }
  .db-tools .tbtn.on { background: var(--ruby-soft); border-color: transparent; }
  /* Stitch mobile row: a rounded card (not a flat hairline row), with swipe-to-act underneath. */
  #task-list { display: flex; flex-direction: column; gap: 8px; }
  .row { min-height: 60px; padding: 0; gap: 0; border-radius: var(--r-lg); border-bottom: 0; background: var(--bg-card); box-shadow: var(--shadow-sm); overflow: hidden; }
  .row:hover, .row:focus-visible { background: var(--bg-card); }
  .row-content { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 60px; padding: 0 12px; background: var(--bg-card); position: relative; z-index: 1; }
  .row .cbx .cb { width: 22px; height: 22px; border-radius: 7px; }
  .row .cbx .cb svg { width: 15px; height: 15px; }
  .row-main { flex-direction: column; align-items: flex-start; gap: 3px; padding: 10px 0; }
  .row-title { font-size: 15px; white-space: normal; }
  .row-swipe-bg { display: flex; position: absolute; inset: 0; z-index: 0; align-items: center; justify-content: center; gap: 8px; font-size: 13px; font-weight: 700; color: #fff; opacity: 0; transition: opacity var(--t-fast); }
  .row-swipe-bg svg { width: 22px; height: 22px; }
  .row-swipe-bg.complete { background: #059669; }
  .row-swipe-bg.del { background: var(--danger); }
  .row.swipe-complete .row-swipe-bg.complete, .row.swipe-del .row-swipe-bg.del { opacity: 1; }
  .row { flex-wrap: wrap; row-gap: 0; }
  .row-meta { flex-wrap: wrap; white-space: normal; flex-basis: 100%; padding: 0 32px 10px 0; margin-top: -4px; }
  [dir="ltr"] .row-meta { padding: 0 0 10px 32px; }
  .row-meta:empty { display: none; }
  .row:focus-visible { box-shadow: none; }
  .row-open, .row-grip, .row-del { display: none; }
  .row-new { height: 44px; font-size: 15px; }
  .group { height: 38px; }
  .capture-line { height: 44px; }
  .capture-line input { font-size: 15px; }
  .capture-line .btn { display: none; }
  .capture-chips { padding-inline-start: 34px; }
  .col { width: 260px; }
  .cal-head { padding: 0 2px; }
  .cal-title { font-size: 16px; font-weight: 700; }
  .cal-head .today-btn { height: 30px; padding: 0 12px; border-radius: var(--r-md); background: var(--bg-card); font-size: 12.5px; font-weight: 600; }
  .cal-grid.mobile { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); border: none; gap: 2px 0; background: var(--bg-card); border-radius: var(--r-lg); padding: 10px 4px 6px; box-shadow: var(--shadow-sm); }
  .cal-grid.mobile .cal-wd { height: 26px; border: none; padding: 0; justify-content: center; font-weight: 600; color: var(--text-3); font-size: 11.5px; }
  .cal-daybtn { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: flex-start; gap: 3px; height: 44px; padding-top: 3px; border-radius: var(--r-md); }
  .cal-daybtn:active { background: var(--hover); }
  .cal-daybtn.other .cal-dnum { color: var(--text-4); }
  .cal-daybtn.holiday .cal-dnum { color: var(--danger); }
  .cal-dnum { display: inline-flex; align-items: center; justify-content: center; width: 30px; height: 30px; border-radius: 50%; font-size: 13.5px; font-weight: 500; color: var(--text); }
  .cal-daybtn.today .cal-dnum { background: var(--ruby-soft); color: var(--ruby); font-weight: 700; }
  .cal-daybtn.selected .cal-dnum { background: var(--ruby); color: var(--on-ruby); font-weight: 700; }
  .cal-dots { display: flex; gap: 2px; height: 4px; }
  .cal-dots i { width: 4px; height: 4px; border-radius: 50%; background: var(--ruby); }
  .cal-agenda { margin-top: 18px; }
  .cal-agenda-head { display: flex; align-items: center; justify-content: space-between; padding: 0 2px 10px; font-size: 14px; font-weight: 700; }
  .cal-agenda-head .count { font-size: 11.5px; font-weight: 600; color: var(--text-3); background: var(--bg-card); border-radius: 999px; padding: 2px 8px; }
  .cal-agenda-list { display: flex; flex-direction: column; gap: 8px; }
  .cal-agenda-empty { padding: 28px 0; text-align: center; color: var(--text-3); font-size: 13px; }
  .tabbar { display: flex; position: fixed; left: 0; right: 0; bottom: 0; height: calc(60px + var(--safe-b)); padding: 4px 8px var(--safe-b); border-top: 1px solid var(--line); background: color-mix(in srgb, var(--bg-side) 90%, transparent); backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px); box-shadow: 0 -2px 12px rgba(0, 0, 0, 0.04); z-index: 35; }
  .tabbar button { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; font-size: 11px; font-weight: 500; color: var(--text-2); height: 100%; position: relative; }
  .tabbar button svg { width: 24px; height: 24px; }
  .tabbar button.active { color: var(--ruby); font-weight: 600; }
  .tabbar button.active::after { content: ''; position: absolute; bottom: 2px; width: 4px; height: 4px; border-radius: 50%; background: var(--ruby); }
  .fab { display: inline-flex; position: fixed; bottom: calc(78px + var(--safe-b)); inset-inline-end: 20px; width: 56px; height: 56px; border-radius: 9999px; background: var(--ruby); color: var(--on-ruby); align-items: center; justify-content: center; z-index: 36; box-shadow: 0 8px 24px var(--ruby-shadow-lg); transition: transform var(--t-fast), background var(--t-fast); }
  .fab svg { width: 26px; height: 26px; stroke-width: 2; }
  .fab:hover { background: var(--ruby-hover); }
  .fab:active { transform: scale(.95); background: var(--ruby-active); }
  .fab.spin { transform: rotate(45deg); }
  .peek { width: 100vw; border: 0; animation: sheet-in var(--t-slow) var(--ease) both; padding-top: var(--safe-t); }
  @keyframes sheet-in { from { opacity: 0; transform: translateY(24px); } }
  .peek-bar .ibtn { width: 40px; height: 40px; }
  #detail-expand { display: none; }
  .peek-scroll { padding: 8px 20px calc(60px + var(--safe-b)); }
  .d-title { font-size: 22px; }
  /* Stitch groups all properties into one rounded card with each value as a pill button,
     instead of a flat hairline-separated list. */
  .props { border-bottom: 0; background: var(--bg-surface-low); border-radius: var(--r-lg); padding: 4px 14px; }
  .prop { min-height: 48px; border-bottom: 1px solid var(--line); }
  .prop:last-child { border-bottom: 0; }
  .prop-k { width: 110px; }
  .pv-alt { display: none; }
  .prop-v, .pv, .pv-input, .subtask input[type="text"], .subtask-add input, .d-notes { font-size: 15px; }
  .pv, .pv-input { height: 34px; padding: 0 14px; border-radius: var(--r-full); background: var(--bg-surface-high); }
  .pv:hover, .pv-input:hover { background: var(--bg-surface-high); }
  .pv-input:focus { background: var(--bg-surface-high); }
  .subtask, .subtask-add { min-height: 44px; }
  .subtask .cbx .cb { width: 20px; height: 20px; }
  .dialog { padding: 16px; border-radius: 14px; }
  .overlay { padding: 12px; }
  .overlay.top { padding-top: 6vh; }
  .palette-list { max-height: 55vh; }
  .shortcuts { grid-template-columns: 1fr; }
  .acc-row.three { grid-template-columns: 1fr; }
  .toast { bottom: calc(72px + var(--safe-b)); }
  .datepicker { width: calc(100vw - 24px); left: 12px !important; }
  .field-input, .btn { height: 40px; font-size: 15px; }
  .btn.sm { height: 36px; }
  .seg button { height: 32px; }
  .auth-card { padding: 20px; border-radius: var(--r-xl); }
  /* Stitch: a filled ruby pill for the active login/signup tab, not a subtle card highlight. */
  .auth-tabs { background: var(--bg-surface-low); padding: 4px; border-radius: var(--r-lg); }
  .auth-tabs button { height: 44px; font-size: 15px; font-weight: 600; border-radius: var(--r-md); }
  .auth-tabs button.active { background: var(--ruby); color: var(--on-ruby); box-shadow: none; }
  .field-input { height: 44px; border-radius: var(--r-lg); font-size: 15px; padding: 0 14px; }
  /* Command palette: a small floating dropdown near the top left an inconsistent amount of raw
     page visible below it — on the phone it becomes what Stitch's own Command Palette screen
     actually shows: a full-screen takeover, not a partial-height overlay. */
  #palette.overlay { padding: 0; align-items: stretch; }
  .palette { width: 100%; max-width: none; height: 100dvh; border-radius: 0; padding-top: var(--safe-t); display: flex; flex-direction: column; }
  .palette-list { flex: 1; max-height: none; }
  /* Board: 272px desktop columns left an uninformative sliver of the next column peeking in at
     phone widths. Snap-scrolling between near-full-width columns reads as an intentional swipe
     gesture instead of a layout accident. */
  .board { scroll-snap-type: x mandatory; gap: 12px; }
  .col { width: 82vw; scroll-snap-align: start; }
  /* Generic dialogs (new/rename list, share, edit profile) become bottom sheets too, same
     reasoning as the .pop conversion: a centered floating card has no good answer for "where does
     this sit on a phone" the way a sheet sliding up from the thumb zone does. */
  .overlay:has(.dialog) { padding: 0; align-items: stretch; }
  .dialog { width: 100%; max-width: none; margin-top: auto; max-height: 85vh; border-radius: var(--r-xl) var(--r-xl) 0 0; padding: 20px 20px calc(20px + var(--safe-b)); animation: sheet-in var(--t-slow) var(--ease) both; position: relative; }
  .dialog::before { content: ''; position: absolute; top: 8px; left: 50%; transform: translateX(-50%); width: 36px; height: 4px; border-radius: 999px; background: var(--line-strong); }
  .dialog-head { padding-top: 8px; }
}
@media (max-height: 560px) {
  .page { padding-top: 16px; }
  .page-icon { display: none; }
}
@media (hover: none) {
  .row-open, .row-del, .row-grip, .side-head .ibtn, .rail-item .rail-edit, .col-head .ibtn, .subtask .ibtn, .sidebar-close, .group .g-add { opacity: 1; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 1ms !important; transition-duration: 1ms !important; }
  .peek, .dialog, .menu, .datepicker, .toast { animation: fade var(--t-fast) both; }
}
@media print { .sidebar, .topbar, .tabbar, .fab, .db-bar, .peek, .scrim { display: none !important; } .page { max-width: none; padding: 0; } }

/* ============================================================
   Sidebar: icon row · search · tab strip · sections · account footer
   ============================================================ */
.side-top { display: flex; align-items: center; justify-content: space-between; gap: 4px; height: 44px; margin: -4px -2px 6px -2px; padding: 0 2px 6px; border-bottom: 1px solid var(--line); flex-shrink: 0; }
.side-top .ws { flex: 1; min-width: 0; margin-top: 0; }
.side-top .sidebar-close { width: 30px; height: 30px; opacity: 0.7; }
.side-top .sidebar-close:hover { opacity: 1; }
.side-search { display: flex; align-items: center; gap: 8px; height: 32px; padding: 0 10px; border-radius: var(--r-sm); background: var(--bg-card); border: 1px solid var(--line); color: var(--text-3); font-size: 13px; width: 100%; text-align: start; box-shadow: var(--shadow-sm); transition: border-color var(--t-fast); }
.side-search:hover { border-color: var(--line-strong); color: var(--text-2); }
.side-search svg { width: 15px; height: 15px; }
.side-search .nav-label { flex: 1; }
.side-search kbd { font-size: 10px; font-family: var(--f-mono); color: var(--text-3); background: var(--bg-side); padding: 1px 4px; border-radius: 4px; }
.side-tabs { display: flex; align-items: center; gap: 2px; margin: 8px 0 4px; }
.side-tab { display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 8px; border-radius: var(--r-sm); color: var(--text-2); font-size: 13px; font-weight: 500; transition: background var(--t-fast), color var(--t-fast); }
.side-tab svg { width: 16px; height: 16px; color: var(--text-3); }
.side-tab .nav-label { display: none; }
.side-tab:hover { background: var(--hover); color: var(--text); }
.side-tab.active { background: var(--ruby-soft); color: var(--ruby); font-weight: 600; }
.side-tab.active .nav-label { display: inline; }
.side-tab.active svg { color: var(--ruby); }
.side-section { margin-top: 10px; }
.side-section:first-child { margin-top: 2px; }
.side-up { display: flex; align-items: flex-start; gap: 10px; width: 100%; padding: 5px 8px; border-radius: var(--r-md); text-align: start; }
.side-up:hover { background: var(--hover); }
.side-up-day { width: 26px; height: 26px; border-radius: 6px; background: var(--ruby-soft); color: var(--ruby-text, var(--ruby)); font-size: 12px; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; margin-top: 1px; font-variant-numeric: tabular-nums; }
.side-up-body { display: flex; flex-direction: column; min-width: 0; }
.side-up-title { font-size: 13.5px; font-weight: 500; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-up-sub { font-size: 12px; color: var(--text-3); }
.rail-add { color: var(--text-3); font-weight: 400; }
.rail-add svg { width: 15px; height: 15px; }
.sidebar-bottom { border-top: 0; margin-top: 6px; padding-top: 6px; }

/* Home: link columns above the week list */
.home-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 32px 48px; margin: 28px 0 8px; }
.home-h { margin: 0 0 6px; padding-bottom: 8px; border-bottom: 1px solid var(--line); font-size: 18px; font-weight: 700; }
.home-link { display: flex; align-items: center; gap: 10px; width: 100%; height: 32px; padding: 0 6px; margin-inline: -6px; border-radius: var(--r-md); font-size: 14px; font-weight: 600; text-align: start; }
.home-link:hover { background: var(--hover); }
.home-link .dot { width: 10px; height: 10px; border-radius: 3px; flex-shrink: 0; }
.home-link-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; border-bottom: 1px solid var(--line); padding-bottom: 1px; }
.home-link .count { font-size: 12px; color: var(--text-3); font-weight: 400; }

/* Type and spacing scale with the page width */
.page-title { font-size: 28px; font-weight: 700; letter-spacing: -0.025em; }
@media (max-width: 1280px) { .page { padding-inline: 48px; } }
@media (max-width: 1100px) { .page { padding-inline: 40px; } .page-title { font-size: 28px; } .page-icon { width: 48px; height: 48px; } .page-icon svg { width: 28px; height: 28px; } }
@media (max-width: 900px) { .page { padding-inline: 28px; } .page-title { font-size: 26px; } .home-cards { gap: 24px 32px; } }
@media (max-width: 760px) {
  .page { padding-inline: 16px; }
  .page-title { font-size: 24px; }
  .page-icon { width: 40px; height: 40px; border-radius: 10px; }
  .page-icon svg { width: 24px; height: 24px; }
  .home-cards { grid-template-columns: 1fr; gap: 12px; margin-top: 20px; }
  .side-tab .nav-label { display: inline; }
  .side-tab { height: 36px; }
  .side-search { height: 36px; font-size: 14px; }
  .side-up-title { font-size: 15px; }
  /* Stitch drawer rows: taller, spaced-out rounded pills instead of a dense flat menu list. */
  .rail-item, .rail-group { height: 44px; padding: 0 12px; font-size: 14.5px; gap: 10px; }
  .rail-item svg, .rail-group svg { width: 19px; height: 19px; }
  .sidebar-scroll .rail-item + .rail-item, .sidebar-scroll .rail-group + .rail-item { margin-top: 2px; }
  .rail-item.active { box-shadow: var(--shadow-sm); }
  .ws { height: 52px; padding: 0 10px; }
  .ws-mark { width: 40px; height: 40px; border-radius: 50%; font-size: 16px; }
  .new-task { height: 46px; }
  /* Report stat "ledger": rounded gapped cards instead of a bordered spreadsheet-style grid. */
  .ledger { border-top: 0; border-bottom: 0; gap: 10px; }
  .ledger-row { border-inline-end: 0 !important; border-bottom: 0 !important; background: var(--bg-card); border-radius: var(--r-lg); box-shadow: var(--shadow-sm); padding: 14px; }
  .ledger-v { font-size: 22px; }

  /* Home: today's-focus card + a 2-col bento grid (Inbox/Today/pinned lists) — from Stitch. */
  .home-focus { display: flex; align-items: center; gap: 12px; padding: 12px; border-radius: var(--r-lg); background: var(--bg-card); box-shadow: var(--shadow-sm); }
  .home-focus-ico { width: 36px; height: 36px; border-radius: var(--r-md); background: var(--bg-surface-high); color: var(--ruby); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
  .home-focus-ico svg { width: 20px; height: 20px; }
  .home-focus-body { display: flex; flex-direction: column; min-width: 0; flex: 1; gap: 2px; }
  .home-focus-body b { font-size: 15px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .home-focus-body span { font-size: 12.5px; color: var(--text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .home-focus-badge { flex-shrink: 0; font-size: 11px; font-weight: 600; padding: 4px 10px; border-radius: var(--r-full); background: var(--ruby-soft); color: var(--ruby-text); }
  .home-bento { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
  .bento-card { display: flex; flex-direction: column; justify-content: space-between; padding: 14px; min-height: 108px; border-radius: var(--r-lg); background: var(--bg-card); box-shadow: var(--shadow-sm); text-align: start; transition: transform var(--t-fast); }
  .bento-card:active { transform: scale(.98); }
  .bento-top { display: flex; align-items: flex-start; justify-content: space-between; }
  .bento-ico { width: 40px; height: 40px; border-radius: var(--r-md); background: var(--bg-surface-high); color: var(--text-3); display: flex; align-items: center; justify-content: center; }
  .bento-ico svg { width: 20px; height: 20px; }
  .bento-card.accent .bento-ico { background: var(--ruby-soft); color: var(--ruby-text); }
  .bento-count { font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: var(--r-full); background: var(--bg-surface-high); color: var(--text); }
  .bento-card.accent .bento-count { background: var(--ruby); color: var(--on-ruby); }
  .bento-body { display: flex; flex-direction: column; margin-top: 12px; gap: 2px; min-width: 0; }
  .bento-body b { font-size: 14.5px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .bento-body span { font-size: 12px; color: var(--text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .bento-card.accent .bento-body span { color: var(--ruby-text); }
}
.sidebar { overflow: hidden; }
.sidebar-scroll { min-height: 0; }
.sidebar-bottom, .sidebar > .ws { flex-shrink: 0; }
.home-link-name { flex: 0 1 auto; }
.home-link .count { margin-inline-start: auto; }

/* ============================================================
   Settings window: search + grouped nav on the start side, one pane of titled rows
   ============================================================ */
.stw { width: min(1150px, calc(100vw - 32px)); height: min(720px, calc(100vh - 32px)); background: var(--bg); border-radius: var(--r-xl); box-shadow: var(--shadow-lg); display: grid; grid-template-columns: 240px 1fr; overflow: hidden; animation: dialog-in var(--t-slow) var(--ease) both; }
.stw-nav { background: var(--bg-side); border-inline-end: 1px solid var(--line); padding: 10px 8px; overflow-y: auto; display: flex; flex-direction: column; gap: 1px; }
.stw-search { display: flex; align-items: center; gap: 8px; height: 30px; padding: 0 8px; margin-bottom: 8px; border-radius: var(--r-md); background: var(--bg); border: 1px solid var(--line); color: var(--text-3); }
.stw-search svg { width: 14px; height: 14px; flex-shrink: 0; }
.stw-search input { flex: 1; min-width: 0; border: 0; background: transparent; font: inherit; font-size: 13px; color: var(--text); outline: none; }
.stw-group { font-size: 12px; font-weight: 600; color: var(--text-3); padding: 12px 8px 4px; }
.stw-item { display: flex; align-items: center; gap: 8px; height: 30px; padding: 0 8px; border-radius: var(--r-md); color: var(--text-2); font-size: 13.5px; font-weight: 500; text-align: start; width: 100%; }
.stw-item svg { width: 16px; height: 16px; color: var(--text-3); }
.stw-item:hover { background: var(--hover); color: var(--text); }
.stw-item.active { background: var(--active); color: var(--text); font-weight: 600; }
.stw-item .nav-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.avatar.xs { width: 20px; height: 20px; border-radius: 6px; font-size: 11px; }
.avatar.lg { width: 64px; height: 64px; border-radius: 50%; font-size: 26px; }
.stw-body { position: relative; overflow-y: auto; padding: 44px 64px 64px; }
.stw-close { position: absolute; top: 12px; inset-inline-end: 12px; }
.stw-mhead, .stw-back, #topbar-avatar { display: none; }
.stw-pane { max-width: 680px; margin: 0 auto; }
.stw-pane h1 { margin: 0; font-size: 24px; font-weight: 700; }
.stw-sub { margin: 4px 0 0; color: var(--text-2); font-size: 14px; }
.stw-h { margin: 32px 0 6px; padding-bottom: 8px; border-bottom: 1px solid var(--line); font-size: 15px; font-weight: 600; }
.stw-row { display: flex; align-items: center; justify-content: space-between; gap: 24px; padding: 14px 0; border-bottom: 1px solid var(--line); }
.stw-k { min-width: 0; }
.stw-k b { display: block; font-size: 14px; font-weight: 600; }
.stw-k p { margin: 2px 0 0; color: var(--text-2); font-size: 12.5px; line-height: 1.5; }
.stw-v { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.stw-v .field-input { width: 300px; }
.stw-profile { display: flex; align-items: center; gap: 16px; padding: 16px 0; }
.stw-profile-body { flex: 1; min-width: 0; }
.avatar.has-img { background-size: cover; background-position: center; color: transparent; }
.avatar-wrap { position: relative; flex-shrink: 0; }
.avatar-edit { position: absolute; bottom: -2px; inset-inline-end: -2px; width: 26px; height: 26px; border-radius: 50%; background: var(--bg-card); border: 2px solid var(--bg); color: var(--text-2); display: flex; align-items: center; justify-content: center; box-shadow: var(--shadow-sm); }
.avatar-edit svg { width: 13px; height: 13px; }
.avatar-edit:hover { background: var(--hover); color: var(--text); }
.link-btn { margin-top: 6px; font-size: 12.5px; color: var(--ruby-text); font-weight: 500; }
.link-btn:hover { text-decoration: underline; }
.stw-lbl { font-size: 12px; color: var(--text-3); }
.stw-who { font-size: 15px; font-weight: 600; }
.stw-member { display: flex; align-items: center; gap: 10px; }
.stw-empty { color: var(--text-2); font-size: 14px; padding: 24px 0; }
.exp-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 12px 0 20px; }
.exp-card { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; padding: 14px; border-radius: var(--r-lg); background: var(--bg-surface-low); text-align: start; transition: background var(--t-fast); }
.exp-card:hover { background: var(--hover); }
.exp-ico { width: 32px; height: 32px; border-radius: var(--r-md); background: var(--bg-surface-high); color: var(--ruby); display: flex; align-items: center; justify-content: center; }
.exp-ico svg { width: 17px; height: 17px; }
.exp-card b { font-size: 13.5px; font-weight: 600; }
.exp-card span { font-size: 11px; color: var(--text-3); }
.stw .shortcuts { margin-top: 16px; }
@media (max-width: 900px) {
  .stw { grid-template-columns: 1fr; height: calc(100vh - 16px); width: calc(100vw - 16px); }
  .stw-row { flex-direction: column; align-items: stretch; gap: 10px; }
  .stw-v .field-input { width: 100%; }
}
@media (max-width: 760px) {
  /* Telegram-style drill-down: a root list of settings groups, then a full-screen pane with a
     back button — not a floating card with a cramped horizontal tab strip squeezed on top. */
  #settings.overlay { padding: 0; align-items: stretch; }
  #settings .stw { width: 100vw; height: 100dvh; grid-template-columns: 1fr; grid-template-rows: auto 1fr; border-radius: 0; animation: sheet-in var(--t-slow) var(--ease) both; }

  .stw-mhead { display: flex; align-items: center; height: calc(52px + var(--safe-t)); padding: var(--safe-t) 4px 4px; flex-shrink: 0; border-bottom: 1px solid var(--line); font-size: 17px; font-weight: 700; }
  .stw-mhead span:not(.stw-mhead-spacer) { flex: 1; text-align: center; }
  .stw-mhead .ibtn, .stw-mhead-spacer { width: 44px; height: 44px; flex-shrink: 0; }
  .stw.pane-open .stw-mhead { display: none; }

  .stw-nav { flex-direction: column; overflow-y: auto; overflow-x: hidden; gap: 0; padding: 8px 12px calc(24px + var(--safe-b)); border-inline-end: 0; }
  .stw.pane-open .stw-nav { display: none; }
  .stw-search { height: 40px; margin-bottom: 12px; border-radius: var(--r-lg); }
  .stw-search input { font-size: 15px; }
  .stw-group { padding: 18px 6px 6px; font-size: 12.5px; }
  .stw-group:first-of-type { padding-top: 6px; }
  .stw-item { height: 50px; padding: 0 12px; border-radius: 0; font-size: 16px; gap: 12px; background: var(--bg-card); }
  .stw-item svg { width: 19px; height: 19px; }
  .stw-item.active { background: var(--bg-card); font-weight: 500; }
  .stw-item::after { content: ''; width: 8px; height: 8px; margin-inline-start: auto; border-inline-start: 2px solid var(--text-3); border-bottom: 2px solid var(--text-3); transform: rotate(45deg); flex-shrink: 0; }
  [dir="ltr"] .stw-item::after { transform: rotate(225deg); }
  .stw-group + .stw-item, .stw-item + .stw-item { position: relative; }
  .stw-group + .stw-item::before, .stw-item + .stw-item::before { content: ''; position: absolute; top: 0; inset-inline-start: 12px; inset-inline-end: 0; border-top: 1px solid var(--line); }
  .stw-item:first-of-type::before { display: none; }
  .stw-nav > .stw-item:first-child { border-start-start-radius: var(--r-lg); border-start-end-radius: var(--r-lg); }
  .avatar.xs { width: 28px; height: 28px; border-radius: 8px; font-size: 13px; }

  .stw-body { display: none; padding: 20px 16px calc(40px + var(--safe-b)); }
  .stw.pane-open .stw-body { display: block; padding-top: calc(52px + var(--safe-t)); }
  .stw-close { display: none; }
  /* Icon-only and flush against the status bar read as barely-there; a clearly labeled row with
     breathing room under the notch/status bar is what a "back" control should look like. */
  .stw-back { position: absolute; top: calc(16px + var(--safe-t)); inset-inline-start: 12px; display: flex; align-items: center; gap: 4px; height: 32px; padding: 0 10px; border-radius: var(--r-md); color: var(--text); font-size: 14.5px; font-weight: 600; }
  .stw-back:active { background: var(--hover); }
  .stw-back svg { width: 20px; height: 20px; }
  .stw-pane h1 { font-size: 22px; }
  .stw-h { font-size: 13px; text-transform: none; color: var(--text-3); border-bottom: 0; margin: 28px 4px 4px; }
  .stw-row { padding: 14px 4px; }
  .stw-k b { font-size: 15px; }
  .stw-profile { padding: 12px 4px 20px; }
}

/* ============================================================
   Page chrome: cover · hover actions · icon/cover pickers · description
   ============================================================ */
.page-cover { position: relative; height: 200px; margin: -32px -56px 0; border-radius: 0; background: var(--bg-side); }
.page.wide .page-cover { margin-inline: -40px; }
.page.has-cover .page-head { margin-top: -28px; }
.page.has-cover .page-icon { border: 3px solid var(--bg); box-shadow: none; }
.cover-btn { position: absolute; bottom: 12px; height: 26px; padding: 0 8px; border-radius: var(--r-sm); background: var(--bg); border: 1px solid var(--line); color: var(--text-2); font-size: 12px; font-weight: 500; opacity: 0; transition: opacity var(--t-fast); box-shadow: var(--shadow-sm); }
.cover-btn:hover { background: var(--hover); color: var(--text); }
#cover-change { inset-inline-end: 56px; } #cover-remove { inset-inline-end: 12px; }
.page-cover:hover .cover-btn { opacity: 1; }
@media (max-width: 1280px) { .page-cover { margin-inline: -48px; } }
@media (max-width: 1100px) { .page-cover { margin-inline: -40px; height: 160px; } }
@media (max-width: 900px) { .page-cover { margin-inline: -28px; } }
@media (max-width: 760px) { .page-cover { margin-inline: -16px; height: 120px; } .cover-btn { opacity: 1; } }
.cover-ruby { background: linear-gradient(135deg, #5a0716, #a9142c 60%, #d84a5a); }
.cover-gold { background: linear-gradient(135deg, #7a4d0c, #d9962b 60%, #f0c46b); }
.cover-forest { background: linear-gradient(135deg, #0f3d2a, #1f6b46 60%, #63b58a); }
.cover-ocean { background: linear-gradient(135deg, #0d2a4d, #1d5a9e 60%, #6aa9e6); }
.cover-violet { background: linear-gradient(135deg, #2c1a5c, #5b3fb0 60%, #a48ee6); }
.cover-rose { background: linear-gradient(135deg, #6b1846, #b6357e 60%, #ec8ec2); }
.cover-slate { background: linear-gradient(135deg, #1e232b, #3d4653 60%, #7b8794); }
.cover-sunset { background: linear-gradient(120deg, #7a1f2b, #d0642d 55%, #f3b34a); }
.cover-dawn { background: linear-gradient(120deg, #3a2b66, #a04c7e 55%, #f2a97e); }
.cover-night { background: linear-gradient(120deg, #0b1020, #1c2b52 55%, #3b5ba5); }
.cover-mint { background: linear-gradient(120deg, #0f5148, #2aa398 55%, #9ee7d6); }
.cover-sand { background: linear-gradient(120deg, #6b5334, #b89468 55%, #eadcc0); }
.page-icon.clickable { cursor: pointer; transition: background var(--t-fast); }
.page-icon.clickable:hover { background: var(--hover); }
.page-icon .emoji-icon { font-size: 40px; line-height: 1; }
.page-icon:has(.emoji-icon) { background: transparent; }
.emoji-mark { width: 18px; text-align: center; font-size: 15px; line-height: 1; flex-shrink: 0; }
.page-actions { display: flex; gap: 2px; margin: 10px 0 -6px; opacity: 0; transition: opacity var(--t-fast); }
.page-head:hover .page-actions, .page-actions:focus-within { opacity: 1; }
.pa-btn { display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 8px; border-radius: var(--r-sm); color: var(--text-3); font-size: 13px; }
.pa-btn:hover { background: var(--hover); color: var(--text-2); }
.pa-btn svg { width: 15px; height: 15px; }
.page-desc { margin: 8px 0 0; font-size: 15px; color: var(--text-2); line-height: 1.6; outline: none; min-height: 24px; border-radius: 4px; }
.page-desc:empty::before { content: attr(placeholder); color: var(--text-4); }
.page-desc:focus { background: var(--hover); box-shadow: 0 0 0 4px var(--hover); }
#fav-btn.on { color: #e0a72f; }
#fav-btn.on svg { fill: currentColor; animation: star-pop var(--t-slow) var(--ease); }
@keyframes star-pop { 0% { transform: scale(.6); } 60% { transform: scale(1.25); } 100% { transform: scale(1); } }

/* Popovers (160ms scale-in) */
.pop { position: fixed; z-index: 60; width: 320px; background: var(--bg); border-radius: var(--r-lg); box-shadow: var(--shadow-md); padding: 8px; animation: pop var(--t-mid) var(--ease) both; }
.pop-tabs { display: flex; align-items: center; gap: 12px; padding: 2px 6px 8px; font-size: 13px; }
.pop-tabs .spacer { flex: 1; }
.pop-tab { color: var(--text-3); padding-bottom: 4px; border-bottom: 2px solid transparent; }
.pop-tab.active { color: var(--text); border-color: var(--text); font-weight: 600; }
.pop-link { color: var(--text-3); font-size: 13px; }
.pop-link:hover { color: var(--text); }
.pop-search { display: flex; align-items: center; gap: 6px; height: 30px; padding: 0 8px; border-radius: var(--r-md); background: var(--hover); color: var(--text-3); margin-bottom: 8px; }
.pop-search svg { width: 14px; height: 14px; }
.pop-search input { flex: 1; min-width: 0; border: 0; background: transparent; font: inherit; font-size: 13px; color: var(--text); outline: none; }
.pop-title { font-size: 13px; font-weight: 600; padding: 4px 6px 8px; }
.pop-foot { padding: 10px 6px 2px; color: var(--text-3); font-size: 12px; line-height: 1.5; border-top: 1px solid var(--line); margin-top: 6px; }
.emoji-grid { display: grid; grid-template-columns: repeat(9, 1fr); gap: 2px; max-height: 240px; overflow-y: auto; }
.emoji-btn { height: 32px; border-radius: var(--r-sm); font-size: 20px; line-height: 1; }
.emoji-btn:hover { background: var(--hover); }
.cover-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.cover-swatch { height: 44px; border-radius: var(--r-md); transition: transform var(--t-fast); }
.cover-swatch:hover { transform: scale(1.04); box-shadow: var(--shadow-sm); }
.trash-pop { width: 380px; }
.trash-list { max-height: 320px; overflow-y: auto; min-height: 120px; }
.trash-row { display: flex; align-items: center; gap: 8px; height: 34px; padding: 0 6px; border-radius: var(--r-md); }
.trash-row:hover { background: var(--hover); }
.trash-row .dot { width: 8px; height: 8px; border-radius: 3px; margin: 0 5px; }
.trash-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13.5px; }
.trash-row .ibtn { opacity: 0; }
.trash-row:hover .ibtn { opacity: 1; }
.trash-empty { padding: 40px 0; text-align: center; color: var(--text-3); font-size: 13px; }
.customize-pop { width: 260px; }
.cz-row { display: flex; align-items: center; justify-content: space-between; height: 34px; padding: 0 6px; font-size: 13.5px; }
.cz-done { width: 100%; margin-top: 6px; }
.cz-hidden { display: none; }
/* sidebar drag-and-drop */
.rail-item.dragging { opacity: .4; }
.rail-item.drop-before { box-shadow: 0 -2px 0 0 var(--ruby); }
.rail-item.drop-after { box-shadow: 0 2px 0 0 var(--ruby); }
@media (max-width: 760px) {
  .page-actions { opacity: 1; }
  /* A box positioned next to whatever button opened it (openPop's desktop dropdown math) can land
     anywhere on a phone — mid-drawer, half off-screen — and reads as broken, not as a menu. Below
     this width every .pop becomes a proper bottom sheet instead, ignoring the JS-computed
     top/left/width (the !important beats those inline styles) and sliding up over a scrim like
     the rest of the phone's sheets (Settings, task peek). */
  .pop { position: fixed !important; left: 0 !important; right: 0 !important; top: auto !important; bottom: 0 !important; width: 100% !important; max-width: none; max-height: min(70vh, 520px); border-radius: var(--r-xl) var(--r-xl) 0 0; padding: 20px 16px calc(16px + var(--safe-b)); overflow-y: auto; animation: sheet-in var(--t-slow) var(--ease) both; }
  .pop::before { content: ''; position: absolute; top: 8px; left: 50%; transform: translateX(-50%); width: 36px; height: 4px; border-radius: 999px; background: var(--line-strong); }
  .trash-pop, .customize-pop { width: 100% !important; }
  .pop-title { font-size: 16px; padding: 10px 0 12px; }
  .trash-row, .cz-row { height: 48px; padding: 0; font-size: 15px; }
  .trash-row .ibtn { opacity: 1; }
  .cz-done { height: 44px; margin-top: 12px; }
}
.page-icon { overflow: visible; }
.page-icon .emoji-icon { font-size: 48px; line-height: 56px; display: block; }
.page.has-cover .page-icon:has(.emoji-icon) { border: 0; }
