/* Betternote — app styles. Tokens first, then layout, then components. */

:root {
  /* Theme: light-dark() picks a value from the color-scheme set by <html data-theme> (system | light | dark). */
  color-scheme: light dark;
  --ink: light-dark(#17132B, #ECE9F8);
  --ink-2: light-dark(#3A3456, #CFCAE6);
  --muted: light-dark(#5C5578, #ABA5C8);
  --muted-2: light-dark(#6E6890, #948DB6);
  --faint: light-dark(#B9B3D6, #5F5982);
  --violet: #6C4BFF;
  --violet-deep: light-dark(#4A2FD6, #B7A6FF);
  --violet-grad: linear-gradient(135deg, #8466FF, #5A3DF0);
  --link: light-dark(#5A3DF0, #A994FF);
  --link-hover: light-dark(#3F25C9, #C8BBFF);
  --coral: #FF6B4A;
  --mint: #1FB58F;
  --hl: #FFE45C;
  /* Highlighted text: half-height marker stroke on paper; full-height soft glow + pale-yellow ink in dark mode. */
  --mark-top: light-dark(rgba(255, 228, 92, 0), rgba(255, 228, 92, 0.26));
  --mark-bottom: light-dark(#FFE45C, rgba(255, 228, 92, 0.26));
  --mark-ink: light-dark(currentColor, #FFF3B8);
  --desk: light-dark(#F5F4F9, #110D22);
  --line: light-dark(rgba(23, 19, 43, 0.08), rgba(255, 255, 255, 0.08));
  --glass: light-dark(rgba(255, 255, 255, 0.62), rgba(44, 37, 82, 0.55));
  --glass-2: light-dark(rgba(255, 255, 255, 0.40), rgba(44, 37, 82, 0.35));
  --glass-hover: light-dark(rgba(255, 255, 255, 0.85), rgba(56, 48, 102, 0.72));
  --glass-border: light-dark(rgba(255, 255, 255, 0.9), rgba(255, 255, 255, 0.07));
  --surface: light-dark(#FFFFFF, #241E44);
  --surface-soft: light-dark(rgba(255, 255, 255, 0.8), rgba(52, 44, 94, 0.6));
  --pop-bg: light-dark(rgba(255, 255, 255, 0.97), rgba(29, 24, 55, 0.97));
  --bar: light-dark(rgba(255, 255, 255, 0.78), rgba(40, 33, 76, 0.82));
  --tint-top: light-dark(#F0ECFF, #2E2560);
  --accent-soft: light-dark(#F4F1FF, rgba(132, 102, 255, 0.16));
  --accent-soft-2: light-dark(#EEEAFF, rgba(132, 102, 255, 0.24));
  --prose: light-dark(#26213D, #DEDAEF);
  --danger: light-dark(#B42318, #FF8F80);
  --danger-soft: light-dark(#FFF1EF, rgba(229, 72, 77, 0.16));
  --note-soft: light-dark(#FFF4C7, rgba(245, 183, 0, 0.14));
  --note-ink: light-dark(#5C4300, #F3D67C);
  --ok: light-dark(#0C6B50, #5CDDB0);
  --thumb-a: light-dark(#D9D2F7, #2E2758);
  --thumb-b: light-dark(#F3E3EE, #3A2540);
  --side-a: light-dark(rgba(246, 244, 253, 0.9), rgba(36, 30, 68, 0.9));
  --side-b: light-dark(rgba(255, 241, 236, 0.6), rgba(60, 32, 44, 0.45));
  --shade: light-dark(#17132B, #000000);
  --shade-v: light-dark(#2B1E6E, #000000);
  --glow-coral: light-dark(rgba(255, 107, 74, 0.08), rgba(255, 107, 74, 0.05));
  --glow-violet: light-dark(rgba(108, 75, 255, 0.10), rgba(108, 75, 255, 0.12));
  --glow-mint: light-dark(rgba(61, 224, 160, 0.04), rgba(61, 224, 160, 0.03));
  --shadow-sm: 0 1px 3px light-dark(rgba(43, 30, 110, 0.05), rgba(0, 0, 0, 0.22));
  --shadow-md: 0 8px 24px light-dark(rgba(43, 30, 110, 0.07), rgba(0, 0, 0, 0.30));
  --shadow-lg: 0 16px 40px light-dark(rgba(43, 30, 110, 0.08), rgba(0, 0, 0, 0.40)), 0 1px 3px light-dark(rgba(23, 19, 43, 0.05), rgba(0, 0, 0, 0.2));
  /* Table cell tints (data-bg) and due-date chip states */
  --cell-gray: light-dark(rgba(23, 19, 43, 0.05), rgba(255, 255, 255, 0.06));
  --cell-violet: light-dark(#EFEBFF, rgba(132, 102, 255, 0.20));
  --cell-coral: light-dark(#FFEDE8, rgba(255, 107, 74, 0.18));
  --cell-mint: light-dark(#E3F7F0, rgba(31, 181, 143, 0.18));
  --cell-sky: light-dark(#E6F1FD, rgba(86, 160, 245, 0.18));
  --cell-yellow: light-dark(#FFF6CC, rgba(255, 228, 92, 0.16));
  --due-today: light-dark(#8A5A00, #F3D67C);
  --due-today-bg: light-dark(#FFF1C2, rgba(245, 183, 0, 0.16));
  --f-ui: 'Geist', system-ui, -apple-system, 'Segoe UI', sans-serif;
  /* One family everywhere (Geist); titles differ by weight and tracking, not by typeface. */
  --f-display: 'Geist', system-ui, -apple-system, sans-serif;
  --f-read: 'Geist', system-ui, -apple-system, sans-serif;
  --f-mono: 'JetBrains Mono', ui-monospace, Menlo, monospace;
  --sidebar-w: 256px;
  --topbar-h: 56px;
  --list-w: 340px;
}
:root[data-theme="light"] { color-scheme: light; }
:root[data-theme="dark"] { color-scheme: dark; }

* { box-sizing: border-box; }
html, body { margin: 0; overscroll-behavior: none; }
body {
  font: 14px/1.45 var(--f-ui);
  color: var(--ink);
  background: var(--desk);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}
/* The desk's glows sit on their own fixed layer: the GPU keeps it while the page scrolls or you type,
   where background-attachment: fixed made the browser repaint the whole window on every frame. */
body::before {
  content: ""; position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background:
    radial-gradient(circle at 92% 4%, var(--glow-coral), transparent 34%),
    radial-gradient(circle at 38% 105%, var(--glow-violet), transparent 46%),
    radial-gradient(circle at 70% 55%, var(--glow-mint), transparent 40%),
    var(--desk);
}
a { color: var(--link); }
a:hover { color: var(--link-hover); }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--violet); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.display { font-family: var(--f-display); font-weight: 600; letter-spacing: -0.02em; }
.eyebrow { font-size: 11px; font-weight: 600; letter-spacing: 1px; text-transform: uppercase; color: var(--muted-2); }
.muted { color: var(--muted-2); }
.spine { display: inline-block; width: 8px; height: 12px; border-radius: 2px; flex: none; background: var(--c, var(--violet)); }
.spines { display: inline-flex; gap: 2px; }
.spines i { width: 4px; height: 16px; border-radius: 2px; background: var(--c); }

/* ---- Buttons, chips, inputs --------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 40px; padding: 0 16px; border-radius: 11px; border: 1px solid var(--glass-border);
  background: var(--glass); color: var(--ink); font-weight: 600; text-decoration: none; white-space: nowrap;
}
.btn:hover { background: var(--surface); color: var(--ink); }
.btn-primary { border: 0; background: var(--violet); color: #fff; box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.18); }
/* Quiet button: no fill until hovered. Used in the top bar and for Attach. */
.btn-ghost { background: transparent; border-color: transparent; color: var(--ink-2); font-weight: 500; }
.btn-ghost:hover { background: color-mix(in srgb, var(--ink) 6%, transparent); color: var(--ink); }
.btn-ghost svg { color: var(--muted-2); }
.btn-primary:hover { color: #fff; background: var(--violet); filter: brightness(1.08); }
.btn-danger { color: var(--danger); }
.btn-sm { height: 32px; padding: 0 12px; border-radius: 9px; font-size: 13px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 5px 12px; border-radius: 999px;
  border: 1px solid var(--glass-border); background: var(--glass); color: var(--ink-2); font-size: 13px; text-decoration: none;
}
.chip.is-on { background: var(--ink); border-color: var(--ink); color: #fff; }
.input, .select {
  height: 40px; width: 100%; padding: 0 12px; border-radius: 10px; border: 1px solid color-mix(in srgb, var(--ink) 12%, transparent);
  background: var(--glass-hover);
}
.input:focus, .select:focus { outline: none; border-color: var(--violet); box-shadow: 0 0 0 3px rgba(108, 75, 255, 0.18); }
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center; width: 34px; height: 34px;
  border: 0; border-radius: 9px; background: transparent; color: var(--ink-2); text-decoration: none;
}
.icon-btn:hover { background: color-mix(in srgb, var(--ink) 6%, transparent); color: var(--ink); }
.icon-btn.is-on { background: rgba(108, 75, 255, 0.10); color: var(--violet-deep); }
.icon-btn svg { width: 17px; height: 17px; }
.glass { background: var(--glass); border: 1px solid var(--glass-border); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); box-shadow: var(--shadow-sm); }
.flash { margin: 0 0 12px; padding: 10px 14px; border-radius: 12px; background: var(--glass-hover); box-shadow: var(--shadow-sm); font-size: 13px; }
.flash.is-error { background: var(--danger-soft); color: var(--danger); }

/* ---- App shell ----------------------------------------------------------------- */
.app { display: flex; min-height: 100vh; }
/* Fixed, full-height sidebar: the list scrolls (no bounce) under a fixed frosted footer. */
.sidebar {
  position: fixed; top: 0; bottom: 0; left: 0; width: var(--sidebar-w); height: 100vh; height: 100dvh; overflow: hidden;
  background: linear-gradient(180deg, #1C1736 0%, #15112A 100%); color: #CFCBE3;
  display: flex; flex-direction: column; box-shadow: inset -1px 0 0 light-dark(transparent, rgba(255, 255, 255, 0.06)); z-index: 20;
}
.sb-scroll {
  flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: none; padding: 18px 12px 96px;
  display: flex; flex-direction: column; gap: 18px; scrollbar-width: thin; scrollbar-color: rgba(255, 255, 255, 0.14) transparent;
}
.sb-brand { display: flex; align-items: center; gap: 10px; padding: 0 6px; color: #fff; text-decoration: none; }
.sb-brand:hover { color: #fff; }
.sb-brand:hover .logo { transform: rotate(-4deg) scale(1.04); }
.logo { flex: none; display: block; transition: transform 0.2s ease; }
.sb-brand span { font-family: var(--f-display); font-weight: 600; font-size: 17px; letter-spacing: -0.4px; }
.sb-new { justify-content: space-between; height: 36px; padding: 0 12px; border-radius: 9px; width: 100%; font-weight: 550; }
.sb-new kbd { font: 12px var(--f-ui); color: #E3DCFF; }
.sb-group { display: flex; flex-direction: column; gap: 2px; }
.sb-label { padding: 0 10px 6px; font-size: 11px; font-weight: 500; letter-spacing: 0.6px; text-transform: uppercase; color: #8F88AE; }
.sb-head { display: flex; align-items: center; gap: 2px; padding: 0 4px 4px 10px; }
.sb-head .sb-label { flex: 1; padding: 0; }
.sb-tool {
  display: inline-flex; align-items: center; justify-content: center; width: 26px; height: 26px; border-radius: 7px;
  color: #9891B5; text-decoration: none; cursor: pointer; list-style: none; flex: none;
}
.sb-tool::-webkit-details-marker { display: none; }
.sb-tool:hover, details[open] > .sb-tool { background: rgba(255, 255, 255, 0.09); color: #fff; }
.sb-tool-text { width: auto; padding: 0 8px; font-size: 12px; }
.sb-link {
  display: flex; align-items: center; gap: 10px; padding: 6px 10px; border-radius: 7px; color: #CFCBE3; text-decoration: none; min-width: 0;
}
.sb-link:hover { background: rgba(255, 255, 255, 0.05); color: #fff; }
.sb-link .name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sb-link .count { margin-left: auto; color: #9891B5; font-size: 13px; transition: opacity 0.12s; }
.sb-link.is-active { color: #fff; background: rgba(255, 255, 255, 0.09); }
.sb-link.is-active .count { color: #E3DCFF; }
.stack-ic { display: inline-flex; color: #9891B5; }
.sb-link.stack:hover .stack-ic, .sb-link.stack.is-active .stack-ic { color: #E3DCFF; }
.sb-link.stack, .sb-link.loose { padding-left: 24px; }
.sb-link.nb { padding-left: 42px; }
.sb-link.stack { color: #fff; font-weight: 500; }
/* A row = link + ⋯ menu that replaces the count on hover. */
.sb-row { position: relative; display: flex; align-items: center; }
.sb-row > .sb-link { flex: 1; }
.sb-row > .sb-more { position: absolute; right: 5px; top: 5px; }
.sb-row > .sb-more > summary { opacity: 0; transition: opacity 0.12s; }
.sb-row:hover > .sb-more > summary, .sb-row:focus-within > .sb-more > summary, .sb-row > .sb-more[open] > summary { opacity: 1; }
.sb-row:hover > .sb-link .count, .sb-row:focus-within > .sb-link .count, .sb-row:has(> .sb-more[open]) > .sb-link .count { opacity: 0; }
@media (hover: none) {
  .sb-row > .sb-more > summary { opacity: 0.7; }
  .sb-row > .sb-link .count { margin-right: 26px; opacity: 1 !important; }
}
.sidebar .menu { position: fixed; top: 80px; left: calc(var(--sidebar-w) + 8px); right: auto; width: 268px; z-index: 40; max-height: calc(100vh - 16px); overflow-y: auto; }
.menu-rule { border: 0; border-top: 1px solid var(--line); margin: 2px 0; width: 100%; }
/* Collapsible stacks */
.sb-caret {
  position: absolute; left: 2px; top: 8px; z-index: 1; width: 20px; height: 20px; padding: 0; border: 0; border-radius: 5px;
  display: inline-flex; align-items: center; justify-content: center; background: none; color: #9891B5;
}
.sb-caret:hover { color: #fff; background: rgba(255, 255, 255, 0.08); }
.sb-caret svg { transform: rotate(90deg); transition: transform 0.18s ease; }
.sb-stack.is-collapsed .sb-caret svg { transform: none; }
.sb-children { display: grid; grid-template-rows: 1fr; transition: grid-template-rows 0.2s ease; }
.sb-children > div { min-height: 0; overflow: hidden; display: flex; flex-direction: column; gap: 2px; padding-top: 2px; }
.sb-stack.is-collapsed .sb-children { grid-template-rows: 0fr; }
.sb-stack.is-collapsed .sb-children > div { visibility: hidden; transition: visibility 0s 0.2s; }
.sb-hint { padding: 4px 10px 8px 42px; font-size: 12px; color: #7B7499; }
.sb-tags { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 10px; }
.sb-tag { padding: 4px 10px; border-radius: 999px; background: rgba(255, 255, 255, 0.06); color: #CFCBE3; text-decoration: none; font-size: 12px; }
.sb-tag:hover, .sb-tag.is-active { background: rgba(255, 255, 255, 0.16); color: #fff; }
.sb-footer {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 2; display: flex; flex-direction: column; gap: 8px; padding: 10px 12px;
  background: rgba(21, 17, 42, 0.86); backdrop-filter: blur(16px) saturate(1.2); -webkit-backdrop-filter: blur(16px) saturate(1.2);
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}
.sb-sync { display: flex; align-items: center; gap: 6px; font-size: 11.5px; font-weight: 400; color: #9891B5; }
.sb-sync i { width: 6px; height: 6px; border-radius: 50%; background: #3DE0A0; }
.sb-sync.is-saving i { background: #FFC94A; }
.sb-sync.is-error i { background: #FF6B4A; }
.sb-account { display: flex; align-items: center; gap: 2px; }
.sb-account form { display: flex; }
.sb-me { flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; padding: 4px 6px 4px 4px; border-radius: 11px; color: #E3DFF4; text-decoration: none; font-weight: 600; font-size: 13px; }
.sb-me:hover { background: rgba(255, 255, 255, 0.06); color: #fff; }
.sb-me-text { min-width: 0; display: flex; flex-direction: column; line-height: 1.25; }
.sb-me-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sb-account .sb-tool { width: 32px; height: 32px; border: 0; background: none; padding: 0; }
.avatar {
  flex: none; width: 32px; height: 32px; border-radius: 50%; object-fit: cover; display: inline-flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #FF8A6B, #6C4BFF); color: #fff; font: 600 12px/1 var(--f-ui); letter-spacing: 0.3px;
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.10);
}
.avatar-lg { width: 72px; height: 72px; font-size: 24px; box-shadow: var(--shadow-sm); }

.main { flex: 1; min-width: 0; margin-left: var(--sidebar-w); display: flex; flex-direction: column; transition: margin-left 0.24s ease; }
.main-body { flex: 1; min-width: 0; display: flex; flex-wrap: wrap; align-items: flex-start; }

/* ---- Top bar: search and Betsy stay put; the middle holds the page's own actions ------------ */
.topbar {
  position: sticky; top: 0; z-index: 18; height: var(--topbar-h); display: flex; align-items: center; gap: 6px; padding: 0 16px 0 24px;
  background: light-dark(rgba(245, 244, 249, 0.82), rgba(17, 13, 34, 0.82)); border-bottom: 1px solid var(--line);
  backdrop-filter: blur(14px) saturate(1.2); -webkit-backdrop-filter: blur(14px) saturate(1.2);
}
.topbar .grow { flex: 1; }
.topbar-search { position: relative; flex: 0 1 420px; min-width: 180px; }
.topbar-search svg { position: absolute; left: 11px; top: 10px; color: var(--muted-2); pointer-events: none; }
.topbar-search input {
  width: 100%; height: 34px; padding: 0 44px 0 34px; border-radius: 9px; border: 1px solid transparent;
  background: color-mix(in srgb, var(--ink) 5%, transparent); color: var(--ink);
}
.topbar-search input::placeholder { color: var(--muted-2); }
.topbar-search input:focus { outline: none; background: var(--surface); border-color: color-mix(in srgb, var(--violet) 50%, transparent); box-shadow: 0 0 0 3px rgba(108, 75, 255, 0.14); }
.topbar-search input::-webkit-search-cancel-button { display: none; }
.topbar-search kbd { position: absolute; right: 9px; top: 8px; font: 11px var(--f-ui); color: var(--muted-2); border: 1px solid var(--line); border-radius: 5px; padding: 1px 5px; }
.topbar-actions { display: flex; align-items: center; gap: 2px; min-width: 0; }
.topbar-actions:empty, .topbar-actions:empty + .topbar-sep { display: none; }
.topbar-actions .btn-sm { height: 32px; padding: 0 10px; border-radius: 8px; }
.topbar-saved { max-width: 180px; }
/* While the search popover is open, the bar sits above its scrim so the field stays usable. */
.topbar:has(.topbar-search.is-open) { z-index: 32; }
.topbar-sep { width: 1px; height: 20px; margin: 0 6px; background: var(--line); }

/* ---- Note list ------------------------------------------------------------------ */
.list-pane { flex: 0 0 var(--list-w); width: var(--list-w); padding: 22px 20px 40px; display: flex; flex-direction: column; gap: 12px; position: sticky; top: var(--topbar-h); max-height: calc(100vh - var(--topbar-h)); max-height: calc(100dvh - var(--topbar-h)); overflow-y: auto; overscroll-behavior: contain; }
.list-head { display: flex; flex-direction: column; gap: 4px; padding: 0 4px; }
.list-head .eyebrow { display: flex; align-items: center; gap: 8px; text-transform: none; letter-spacing: 0; font-size: 12px; font-weight: 400; color: var(--muted); }
.list-head h1 { margin: 0; font-family: var(--f-display); font-weight: 600; font-size: 24px; letter-spacing: -0.7px; line-height: 1.1; }
.list-head .row { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.list-tools { display: flex; gap: 6px; align-items: center; }
/* Sort menu: same family as the notebook picker in the note header. */
.sort-menu { position: relative; }
.sort-btn { list-style: none; border: 0; font-family: inherit; display: inline-flex; align-items: center; gap: 7px; height: 32px; padding: 0 10px; border-radius: 9px; background: var(--surface-soft); box-shadow: 0 1px 3px color-mix(in srgb, var(--ink) 8%, transparent); font-size: 13px; font-weight: 600; color: var(--ink); cursor: pointer; user-select: none; }
.sort-btn::-webkit-details-marker { display: none; }
.sort-btn svg { color: var(--muted-2); }
.sort-btn svg:last-child { transition: transform 0.15s; }
.sort-btn:hover, .sort-menu[open] .sort-btn { background: var(--surface); box-shadow: 0 0 0 1px rgba(108, 75, 255, 0.25), 0 4px 12px color-mix(in srgb, var(--shade-v) 10%, transparent); }
.sort-menu[open] .sort-btn svg:last-child { transform: rotate(180deg); }
.sort-pop {
  position: absolute; top: 38px; left: 0; z-index: 40; width: 240px; padding: 4px 6px 6px;
  border-radius: 16px; background: var(--pop-bg); border: 1px solid var(--surface); backdrop-filter: blur(24px); -webkit-backdrop-filter: blur(24px);
  box-shadow: 0 24px 60px color-mix(in srgb, var(--shade) 22%, transparent), 0 2px 8px color-mix(in srgb, var(--ink) 6%, transparent);
  background-image: linear-gradient(180deg, color-mix(in srgb, var(--tint-top) 80%, transparent), transparent 60px);
}
.sort-pop .nb-opt { text-decoration: none; }
.sort-pop .nb-opt:hover, .sort-pop .nb-opt:focus-visible { background: var(--accent-soft); color: var(--ink); outline: none; }
.sort-pop .nb-opt.is-current { font-weight: 600; }
.sort-pop .nb-opt small { display: block; font-size: 12px; font-weight: 400; color: var(--muted-2); }
.sort-ic { display: inline-flex; align-items: center; justify-content: center; width: 30px; height: 30px; border-radius: 8px; background: var(--surface-soft); color: var(--muted-2); flex: none; }
.nb-opt.is-current .sort-ic { background: var(--accent-soft-2); color: var(--violet-deep); }
.card {
  flex: none; display: flex; flex-direction: column; gap: 6px; padding: 14px 16px; border-radius: 14px; text-decoration: none; color: var(--ink);
  background: light-dark(rgba(255, 255, 255, 0.55), rgba(44, 37, 82, 0.4)); border: 1px solid transparent; overflow: hidden;
}
.card:hover { background: var(--glass-hover); color: var(--ink); }
.card.is-selected { background: var(--surface); border-color: transparent; box-shadow: 0 0 0 1.5px var(--violet), var(--shadow-sm); }
.card-title { font-weight: 600; font-size: 14.5px; letter-spacing: -0.01em; }
.card-excerpt { font-size: 13px; color: var(--muted); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card-meta { display: flex; gap: 10px; align-items: center; font-size: 12px; color: var(--muted-2); }
.card-meta .right { margin-left: auto; display: flex; gap: 8px; }
.card-thumbs { display: flex; gap: 6px; margin: -14px -16px 4px; padding: 10px; height: 76px; background: linear-gradient(135deg, var(--thumb-a), var(--thumb-b)); }
.card-thumbs img { flex: 1; min-width: 0; height: 100%; object-fit: cover; border-radius: 6px; }
.empty { padding: 28px 16px; text-align: center; color: var(--muted); border-radius: 14px; border: 2px dashed rgba(108, 75, 255, 0.2); }

/* ---- Note -------------------------------------------------------------------------- */
.note-pane { flex: 999 1 560px; min-width: 0; padding: 22px 28px 28px 8px; display: flex; flex-direction: column; gap: 16px; }
.sheet {
  /* overflow: clip (not hidden) so the sheet doesn't become a scroll box and the sticky toolbar can follow the page. */
  border-radius: 16px; overflow: clip; display: flex; flex-direction: column;
  background: linear-gradient(180deg, color-mix(in srgb, var(--tint-top) 55%, var(--surface)) 0px, var(--surface) 160px);
  border: 1px solid var(--line); box-shadow: var(--shadow-md);
}
.sheet-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 18px 10px 22px; }
.crumb { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); }
.nb-picker { display: inline-flex; align-items: center; gap: 8px; border: 0; border-radius: 9px; padding: 6px 10px; background: var(--surface-soft); box-shadow: 0 1px 3px color-mix(in srgb, var(--ink) 8%, transparent); font-weight: 600; color: var(--ink); }
.nb-picker:hover:not(:disabled), .nb-picker[aria-expanded="true"] { background: var(--surface); box-shadow: 0 0 0 1px rgba(108, 75, 255, 0.25), 0 4px 12px color-mix(in srgb, var(--shade-v) 10%, transparent); }
.nb-picker:disabled { cursor: default; }
.nb-picker .spine { box-shadow: 0 0 8px color-mix(in srgb, var(--c) 60%, transparent); }
.nb-picker svg { color: var(--muted-2); transition: transform 0.15s; }
.nb-picker[aria-expanded="true"] svg { transform: rotate(180deg); }
.nb-pop {
  position: fixed; z-index: 45; width: 320px; max-width: calc(100vw - 16px); display: flex; flex-direction: column; overflow: hidden;
  border-radius: 16px; background: var(--pop-bg); border: 1px solid var(--surface); backdrop-filter: blur(24px); -webkit-backdrop-filter: blur(24px);
  box-shadow: 0 24px 60px color-mix(in srgb, var(--shade) 22%, transparent), 0 2px 8px color-mix(in srgb, var(--ink) 6%, transparent);
}
.nb-pop[hidden] { display: none; }
.nb-filter-wrap { position: relative; padding: 10px; border-bottom: 1px solid var(--line); background: linear-gradient(180deg, color-mix(in srgb, var(--tint-top) 80%, transparent), transparent); }
.nb-filter-wrap svg { position: absolute; left: 22px; top: 21px; color: var(--muted-2); pointer-events: none; }
.nb-filter { width: 100%; height: 38px; padding: 0 12px 0 34px; border-radius: 10px; border: 1px solid color-mix(in srgb, var(--ink) 12%, transparent); background: var(--surface); }
.nb-filter:focus { outline: none; border-color: var(--violet); box-shadow: 0 0 0 3px rgba(108, 75, 255, 0.18); }
.nb-options { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 4px 6px 6px; }
.nb-group[hidden], .nb-opt[hidden], .nb-empty[hidden] { display: none; }
.nb-group-label { padding: 10px 10px 4px; font-size: 11px; font-weight: 600; letter-spacing: 1px; text-transform: uppercase; color: var(--muted-2); }
.nb-opt { display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px; border: 0; border-radius: 9px; background: none; text-align: left; color: var(--ink); font-size: 14px; }
.nb-opt.is-active { background: var(--accent-soft); }
.nb-opt[aria-selected="true"] { font-weight: 600; }
.nb-opt-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nb-opt .count { font-size: 12px; color: var(--muted-2); }
.nb-opt .tick { color: var(--violet); font-weight: 700; }
.nb-empty { padding: 16px 12px; color: var(--muted); font-size: 13px; }
.head-actions { display: flex; align-items: center; gap: 4px; }
/* Note actions: each has its own colour (on hover, and when on). On = filled icon on a soft tint. */
.head-actions .icon-btn { --act: var(--violet-deep); }
.head-actions [data-action="history"] { --act: light-dark(#2B7FD9, #7DB8FF); }
.head-actions [data-action="shortcut"] { --act: light-dark(#C98A00, #FFCF4A); }
.head-actions .rem-menu > .icon-btn { --act: light-dark(#E0562F, #FF9A7E); }
.head-actions [data-action="pin"] { --act: light-dark(#6C4BFF, #B7A6FF); }
.head-actions [data-action="trash"] { --act: var(--danger); }
.head-actions .note-more:not(.rem-menu) > .icon-btn { --act: var(--ink); }
.head-actions .icon-btn:hover, .head-actions details[open] > .icon-btn { color: var(--act); background: color-mix(in srgb, var(--act) 11%, transparent); }
.head-actions .icon-btn.is-on { color: var(--act); background: color-mix(in srgb, var(--act) 14%, transparent); }
.head-actions .icon-btn.is-on svg path { fill: currentColor; }
.save-state { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted-2); margin-right: 8px; }
.save-state i { width: 6px; height: 6px; border-radius: 50%; background: var(--mint); }
.save-state.is-saving i { background: #F5B700; }
.save-state.is-error i { background: var(--coral); }
.save-state.is-error { color: var(--danger); }

.toolbar-wrap { padding: 0; position: sticky; top: var(--topbar-h); z-index: 5; }
.toolbar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 2px; padding: 6px 14px;
  background: light-dark(rgba(255, 255, 255, 0.86), rgba(36, 30, 68, 0.88)); border-block: 1px solid var(--line); backdrop-filter: blur(16px);
}
.toolbar .sep { width: 1px; height: 20px; background: color-mix(in srgb, var(--ink) 10%, transparent); margin: 0 4px; }
.toolbar .grow { flex: 1; }
.toolbar .hint { font-size: 12px; color: var(--muted-2); margin-right: 8px; }
.toolbar .text-btn { font-weight: 700; font-size: 13px; }
.toolbar .swatch { width: 18px; height: 18px; border-radius: 5px; background: linear-gradient(135deg, #FFE45C, #FFC94A); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--ink) 8%, transparent); }
.toolbar .btn-primary { height: 34px; border-radius: 9px; padding: 0 12px; font-size: 13px; }
.toolbar .attach-btn { height: 32px; padding: 0 10px; }

.note-body { display: flex; justify-content: center; padding: 28px 28px 32px; }
.note-col { width: 100%; max-width: 720px; display: flex; flex-direction: column; gap: 14px; }
.note-title {
  width: 100%; border: 0; background: transparent; padding: 0; resize: none; overflow: hidden;
  font-family: var(--f-display); font-weight: 600; font-size: 34px; line-height: 1.12; letter-spacing: -1.1px; color: var(--ink);
}
.note-title:focus { outline: none; }
.note-title::placeholder { color: var(--faint); }
.note-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; font-size: 13px; color: var(--muted-2); padding-bottom: 14px; border-bottom: 1px solid var(--line); }
.note-meta .dot { width: 3px; height: 3px; border-radius: 50%; background: var(--faint); }
.tag-chip { display: inline-flex; align-items: center; gap: 4px; padding: 3px 6px 3px 10px; border-radius: 999px; background: color-mix(in srgb, var(--ink) 5%, transparent); color: var(--ink-2); }
.tag-chip button { border: 0; background: none; color: var(--muted-2); padding: 0 4px; line-height: 1; }
.tag-input { border: 0; background: transparent; width: 110px; font-size: 13px; color: var(--ink-2); padding: 3px 4px; }
.tag-input:focus { outline: none; width: 160px; }
.trash-banner { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px; border-radius: 12px; background: var(--note-soft); color: var(--note-ink); }

/* Rich text */
.prose { font-family: var(--f-read); font-size: 16px; line-height: 1.7; color: var(--prose); min-height: 200px; }
.prose .ProseMirror { outline: none; }
.prose > div > :first-child, .prose .ProseMirror > :first-child { margin-top: 0; }
.prose p { margin: 0 0 12px; }
.prose h1, .prose h2, .prose h3 { font-family: var(--f-ui); color: var(--ink); line-height: 1.25; margin: 24px 0 8px; }
.prose h1 { font-size: 26px; } .prose h2 { font-size: 21px; } .prose h3 { font-size: 18px; }
.prose a { color: var(--link); }
.prose mark { background: linear-gradient(180deg, var(--mark-top) 45%, var(--mark-bottom) 45%); color: var(--mark-ink); padding: 0 2px; border-radius: 3px; -webkit-box-decoration-break: clone; box-decoration-break: clone; }
.prose code { font-family: var(--f-mono); font-size: 0.82em; background: rgba(108, 75, 255, 0.08); padding: 2px 5px; border-radius: 5px; }
.prose pre { font-family: var(--f-mono); font-size: 13px; line-height: 1.75; background: linear-gradient(160deg, #241D48, #15112B); color: #E9E6F5; border-radius: 12px; padding: 16px 18px; overflow-x: auto; box-shadow: 0 12px 28px rgba(23, 19, 43, 0.22); }
.prose pre code { background: none; padding: 0; color: inherit; font-size: inherit; }
.prose blockquote { margin: 0 0 12px; padding: 4px 0 4px 16px; border-left: 3px solid var(--faint); color: var(--muted); }
.prose hr { border: 0; border-top: 1px solid var(--line); margin: 20px 0; }
.prose ul, .prose ol { padding-left: 24px; margin: 0 0 12px; }
.prose ul[data-type="taskList"] { list-style: none; padding-left: 2px; font-family: var(--f-ui); font-size: 15px; }
.prose ul[data-type="taskList"] li { display: flex; gap: 10px; align-items: flex-start; }
.prose ul[data-type="taskList"] li > label { margin-top: 3px; }
.prose ul[data-type="taskList"] li > div { flex: 1; }
.prose ul[data-type="taskList"] li > div > p { margin: 0 0 4px; }
.prose ul[data-type="taskList"] li[data-checked="true"] > div { color: var(--muted-2); text-decoration: line-through; }
.prose input[type="checkbox"] { accent-color: var(--violet); width: 16px; height: 16px; }
.prose img { max-width: 100%; height: auto; border-radius: 12px; box-shadow: var(--shadow-sm); }
.prose img.ProseMirror-selectednode { outline: 3px solid var(--violet); }
.prose table { border-collapse: collapse; width: 100%; margin: 0 0 12px; font-family: var(--f-ui); font-size: 14px; }
.prose th, .prose td { border: 1px solid color-mix(in srgb, var(--ink) 12%, transparent); padding: 6px 10px; vertical-align: top; }
.prose th { background: rgba(108, 75, 255, 0.06); text-align: left; }
.prose p.is-editor-empty:first-child::before { content: attr(data-placeholder); color: var(--faint); float: left; height: 0; pointer-events: none; }

/* Attachments */
.files { display: flex; flex-wrap: wrap; gap: 10px; }
.file-chip { display: flex; align-items: center; gap: 12px; padding: 8px 10px 8px 8px; border-radius: 12px; background: color-mix(in srgb, var(--ink) 3.5%, transparent); border: 1px solid color-mix(in srgb, var(--ink) 7%, transparent); text-decoration: none; color: var(--ink); max-width: 320px; }
.file-chip:hover { background: color-mix(in srgb, var(--ink) 6%, transparent); color: var(--ink); }
.file-chip .thumb { flex: none; width: 36px; height: 44px; border-radius: 6px; background: var(--surface); box-shadow: 0 1px 3px color-mix(in srgb, var(--shade) 12%, transparent); display: flex; align-items: flex-end; justify-content: center; padding-bottom: 5px; font-size: 9px; font-weight: 700; letter-spacing: 0.5px; color: var(--ink-2); overflow: hidden; }
.file-chip .thumb img { width: 56px; height: 44px; object-fit: cover; }
.file-chip .thumb.is-image { width: 56px; padding: 0; }
.file-chip .name { font-weight: 600; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-chip .sub { font-size: 12px; color: var(--muted-2); }
.file-chip .remove { margin-left: 4px; border: 0; background: none; color: var(--muted-2); padding: 4px; }
.drop-hint { display: none; position: absolute; inset: 0; border-radius: 22px; border: 3px dashed var(--violet); background: rgba(108, 75, 255, 0.08); align-items: center; justify-content: center; font-weight: 700; color: var(--violet-deep); font-size: 18px; z-index: 6; }
.sheet.is-dragging { position: relative; }
.sheet.is-dragging .drop-hint { display: flex; }

/* Context */
.context-box { border-radius: 22px; padding: 18px 22px 22px; background: linear-gradient(135deg, var(--glass), var(--glass-2)); border: 1px solid var(--glass-border); backdrop-filter: blur(20px); box-shadow: var(--shadow-md); display: flex; flex-direction: column; gap: 14px; }
.context-head { display: flex; align-items: center; gap: 10px; }
.context-head .badge { width: 30px; height: 30px; border-radius: 9px; background: var(--violet-grad); box-shadow: 0 4px 12px rgba(108, 75, 255, 0.35); display: flex; align-items: center; justify-content: center; color: #fff; }
.context-head h2 { margin: 0; font-family: var(--f-display); font-weight: 600; font-size: 17px; }
.context-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px; }
.ctx-card { display: flex; flex-direction: column; gap: 8px; padding: 12px 14px; border-radius: 14px; text-decoration: none; color: var(--ink); background: var(--surface-soft); border: 1px solid var(--glass-border); box-shadow: var(--shadow-sm); }
.ctx-card:hover { background: var(--surface); color: var(--ink); }
.ctx-card .nb { display: flex; align-items: center; gap: 6px; font-size: 11px; color: var(--muted-2); }
.ctx-card .nb .spine { width: 7px; height: 10px; }
.ctx-card .title { font-weight: 700; font-size: 13px; line-height: 1.3; }
.ctx-card .why { font-size: 12px; color: var(--muted); }

/* ---- Search popover ---------------------------------------------------------------- */
.search-scrim { position: fixed; inset: 0 0 0 var(--sidebar-w); background: color-mix(in srgb, var(--shade) 28%, transparent); backdrop-filter: blur(3px); z-index: 30; }
.search-pop {
  position: fixed; left: calc(var(--sidebar-w) + 12px); top: 112px; right: 40px; max-width: 1060px; max-height: calc(100vh - 140px);
  border-radius: 20px; background: var(--pop-bg); backdrop-filter: blur(24px); border: 1px solid var(--surface);
  box-shadow: 0 40px 90px color-mix(in srgb, var(--shade) 35%, transparent), 0 4px 14px color-mix(in srgb, var(--ink) 10%, transparent); z-index: 31; display: flex; flex-direction: column; overflow: hidden;
}
/* The pointer is a real triangle (not a rotated square), in the solid color of the popover's top,
   overlapping its 1px border so the two read as one shape in both themes. */
.search-arrow { position: fixed; left: calc(var(--sidebar-w) + 2px); width: 11px; height: 20px; background: var(--tint-top); clip-path: polygon(100% 0, 0 50%, 100% 100%); z-index: 32; pointer-events: none; }
.search-arrow.is-up { width: 22px; height: 11px; clip-path: polygon(0 100%, 50% 0, 100% 100%); }
.search-pop[hidden], .search-scrim[hidden], .search-arrow[hidden] { display: none; }
.sr-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 16px 22px; background: linear-gradient(180deg, color-mix(in srgb, var(--tint-top) 90%, transparent), transparent); }
.sr-head .q { font-family: var(--f-display); font-weight: 600; font-size: 20px; letter-spacing: -0.4px; }
.sr-token { font-family: var(--f-mono); font-size: 13px; background: var(--accent-soft-2); color: var(--link-hover); border-radius: 7px; padding: 3px 8px; }
.sr-head kbd { font: 11px var(--f-ui); color: var(--muted-2); border: 1px solid color-mix(in srgb, var(--ink) 14%, transparent); border-radius: 5px; padding: 1px 6px; }
.sr-filters { display: flex; flex-wrap: wrap; gap: 8px; padding: 0 22px 14px; border-bottom: 1px solid var(--line); align-items: center; }
.sr-filters .chip { border-color: color-mix(in srgb, var(--ink) 10%, transparent); background: var(--surface); }
.sr-filters .chip.is-on { background: var(--ink); color: #fff; }
.sr-body { display: flex; flex-wrap: wrap; overflow-y: auto; }
.sr-results { flex: 999 1 520px; min-width: 0; display: flex; flex-direction: column; }
.sr-item { display: flex; flex-direction: column; gap: 6px; padding: 14px 22px; text-decoration: none; color: var(--ink); border-bottom: 1px solid color-mix(in srgb, var(--ink) 6%, transparent); }
.sr-item:hover, .sr-item.is-active { background: var(--accent-soft); color: var(--ink); }
.sr-item .top { display: flex; align-items: center; gap: 8px; }
.sr-item .title { flex: 1; font-weight: 700; font-size: 15px; }
.sr-item .where { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted-2); }
.sr-item .snip { font-family: var(--f-read); font-size: 15px; line-height: 1.5; color: var(--ink-2); }
.sr-item .also { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); }
.sr-item .also b { padding: 2px 7px; border-radius: 5px; background: var(--surface); box-shadow: 0 1px 2px color-mix(in srgb, var(--shade) 14%, transparent); font-size: 10px; }
.sr-item mark, .sr-head mark { background: linear-gradient(180deg, var(--mark-top) 40%, var(--mark-bottom) 40%); color: var(--mark-ink); padding: 0 1px; border-radius: 2px; }
.sr-foot { padding: 12px 22px; font-size: 13px; color: var(--muted-2); }
.sr-side { flex: 1 1 300px; border-left: 1px solid var(--line); background: linear-gradient(180deg, var(--side-a), var(--side-b)); padding: 18px 20px; display: flex; flex-direction: column; gap: 20px; }
.sr-side section { display: flex; flex-direction: column; gap: 9px; }
.sr-side a { text-decoration: none; color: var(--ink); display: flex; justify-content: space-between; }
.saved-row { display: flex; align-items: center; gap: 4px; margin: 0 -8px; border-radius: 9px; transition: opacity 0.15s; }
.saved-row:hover { background: var(--surface-soft); }
.saved-row a { flex: 1; min-width: 0; flex-direction: column; justify-content: flex-start; gap: 1px; padding: 6px 8px; }
.saved-row a span { font-weight: 600; }
.saved-row code { font-family: var(--f-mono); font-size: 11px; color: var(--muted-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.saved-row form { display: flex; }
.saved-del { width: 28px; height: 28px; margin-right: 4px; display: inline-flex; align-items: center; justify-content: center; border: 0; border-radius: 7px; background: none; color: var(--muted-2); opacity: 0; }
.saved-row:hover .saved-del, .saved-del:focus-visible { opacity: 1; }
.saved-del:hover { background: var(--danger-soft); color: var(--danger); }
.saved-row.is-removing { opacity: 0.4; pointer-events: none; }
@media (hover: none) { .saved-del { opacity: 1; } }
.syntax { display: grid; grid-template-columns: max-content 1fr; gap: 8px 14px; font-size: 12px; color: var(--ink-2); }
.syntax code { font-family: var(--f-mono); color: var(--violet-deep); }
.sr-empty { padding: 40px 22px; color: var(--muted); }
.sr-group { padding: 14px 22px 6px; font-size: 11px; font-weight: 600; letter-spacing: 1px; text-transform: uppercase; color: var(--muted-2); }
.sr-item.sr-nb { flex-direction: row; align-items: center; gap: 12px; padding-top: 11px; padding-bottom: 11px; }
.sr-nb .spine { width: 10px; height: 22px; border-radius: 3px; box-shadow: 0 0 8px color-mix(in srgb, var(--c) 50%, transparent); }
.sr-nb .title { font-family: var(--f-display); font-weight: 600; letter-spacing: -0.2px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sr-nb .where { flex: none; }
.sr-hash { width: 22px; height: 22px; display: inline-flex; align-items: center; justify-content: center; flex: none; border-radius: 6px; background: var(--surface-soft); color: var(--muted-2); font-weight: 700; font-size: 13px; }
.sr-tag .title { font-family: var(--f-ui); font-weight: 600; letter-spacing: 0; }
.sr-group-row { display: flex; align-items: center; justify-content: space-between; }
.sr-clear { border: 0; background: none; padding: 0; font: 600 11px var(--f-ui); letter-spacing: 1px; text-transform: uppercase; color: var(--muted-2); cursor: pointer; }
.sr-clear:hover { color: var(--violet-deep); }
.sr-item.sr-recent { flex-direction: row; align-items: center; gap: 10px; padding-top: 10px; padding-bottom: 10px; }
.sr-recent svg { color: var(--muted-2); flex: none; }
.sr-recent .title { font-weight: 500; font-size: 14px; }

/* ---- Pages: search, organize, settings ------------------------------------------------ */
.page { flex: 1; min-width: 0; padding: 26px 28px 40px; display: flex; flex-direction: column; gap: 22px; }
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 14px; }
.page-head h1 { margin: 2px 0 0; font-family: var(--f-display); font-weight: 600; font-size: 34px; letter-spacing: -1px; }
.page-head .actions { display: flex; gap: 8px; flex-wrap: wrap; }
.panel { border-radius: 14px; padding: 20px 22px; background: light-dark(rgba(255, 255, 255, 0.72), rgba(44, 37, 82, 0.5)); border: 1px solid var(--line); backdrop-filter: blur(16px); display: flex; flex-direction: column; gap: 14px; }
.panel h2 { margin: 0; font-family: var(--f-display); font-weight: 600; font-size: 17px; letter-spacing: -0.3px; }
.cols { display: flex; flex-wrap: wrap; gap: 24px; align-items: flex-start; }
.cols > .wide { flex: 999 1 560px; min-width: 0; display: flex; flex-direction: column; gap: 28px; }
.cols > .side { flex: 1 1 300px; min-width: 0; }

.stack-row { display: flex; align-items: center; gap: 12px; }
.stack-row h2 { margin: 0; font-family: var(--f-display); font-weight: 600; font-size: 20px; }
.stack-row .rule { flex: 1; height: 1px; background: var(--line); }
.covers { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 16px; }
.cover {
  position: relative; display: flex; flex-direction: column; justify-content: center; height: 160px; padding: 14px 14px 14px 28px;
  border-radius: 6px 16px 16px 6px; text-decoration: none; color: var(--fg, #fff); overflow: hidden;
  background: linear-gradient(150deg, color-mix(in srgb, var(--c) 92%, #fff) 0%, color-mix(in srgb, var(--c) 82%, #000) 100%);
  box-shadow: 0 14px 30px color-mix(in srgb, var(--shade-v) 16%, transparent), inset 0 1px 0 rgba(255, 255, 255, 0.3);
}
.cover:hover { color: var(--fg, #fff); transform: translateY(-2px); transition: transform 0.15s; }
.cover::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 14px; background: color-mix(in srgb, var(--c) 45%, #000); box-shadow: 1px 0 0 rgba(255, 255, 255, 0.12); z-index: 1; }
.cover::after { content: ''; position: absolute; inset: 0; background: url(../img/cover-marble.svg) 0 0 / 200px 200px; opacity: 0.7; pointer-events: none; }
/* Composition-book label: white, ruled, holding the name and counts. */
.cover-label {
  position: relative; z-index: 1; display: flex; flex-direction: column; gap: 6px; padding: 8px 11px 7px; border-radius: 7px;
  background: #FFFFFF; color: #17132B; box-shadow: 0 0 0 1.5px rgba(23, 19, 43, 0.18), 0 2px 6px rgba(0, 0, 0, 0.14);
}
.cover-label .name { color: #17132B; font-size: 15px !important; line-height: 1.25; letter-spacing: -0.2px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.cover-label .desc { color: #5C5578; }
.cover-label .sub { color: #6E6890; opacity: 1 !important; gap: 8px; padding-top: 5px; border-top: 1px solid #D9D5E6; }
.cover-label .sub span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cover-label .sub span:first-child { flex: none; }
.cover .name { position: relative; font-family: var(--f-display); font-weight: 600; font-size: 20px; letter-spacing: -0.4px; }
.cover .sub { position: relative; display: flex; justify-content: space-between; font-size: 12px; opacity: 0.8; }
.cover-wrap { position: relative; }
.cover-wrap details { position: absolute; top: 8px; right: 8px; z-index: 2; }
.cover-wrap details[open] { z-index: 15; }
.cover-wrap summary { list-style: none; width: 30px; height: 30px; border-radius: 8px; display: flex; align-items: center; justify-content: center; background: rgba(255, 255, 255, 0.3); color: var(--fg, #fff); cursor: pointer; }
.cover-wrap summary::-webkit-details-marker { display: none; }
.menu { position: absolute; right: 0; top: 36px; width: 250px; padding: 14px; border-radius: 14px; background: var(--surface); box-shadow: var(--shadow-lg); display: flex; flex-direction: column; gap: 10px; color: var(--ink); z-index: 10; }
.menu.menu-flip { right: auto; left: 0; }
.menu label { font-size: 12px; color: var(--muted); display: flex; flex-direction: column; gap: 4px; }
.colors { display: flex; flex-wrap: wrap; gap: 6px; }
.colors label { flex-direction: row; }
.colors input { position: absolute; opacity: 0; }
.colors span { width: 24px; height: 24px; border-radius: 6px; background: var(--c); box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.6); cursor: pointer; }
.colors input:checked + span { box-shadow: 0 0 0 2px #fff, 0 0 0 4px var(--c); }
.new-tile { display: flex; align-items: center; justify-content: center; height: 160px; border-radius: 6px 16px 16px 6px; border: 2px dashed rgba(108, 75, 255, 0.35); background: var(--glass-2); color: var(--violet-deep); font-weight: 600; }
.empty-stack { flex-direction: column; gap: 6px; padding: 20px 24px; text-align: center; line-height: 1.35; }
.empty-stack svg { opacity: 0.7; margin-bottom: 2px; }
.empty-stack small { font-size: 12px; font-weight: 400; color: var(--muted); }

/* Organize: covers or list (bn_nb_view cookie). The list reuses the cover markup. */
.seg { display: inline-flex; align-items: center; gap: 2px; height: 40px; padding: 3px; border-radius: 11px; border: 1px solid var(--glass-border); background: var(--glass); }
.seg a { display: inline-flex; align-items: center; justify-content: center; width: 36px; height: 32px; border-radius: 8px; color: var(--muted-2); }
.seg a:hover { color: var(--ink); background: var(--surface-soft); }
.seg a.is-on { background: var(--surface); color: var(--violet-deep); box-shadow: var(--shadow-sm); }
.nb-view.is-list .covers { display: flex; flex-direction: column; gap: 0; padding: 6px; border-radius: 16px; background: var(--glass); border: 1px solid var(--glass-border); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); box-shadow: var(--shadow-sm); }
.nb-view.is-list .cover-wrap + .cover-wrap { border-top: 1px solid var(--line); }
.nb-view.is-list .cover {
  flex-direction: row; align-items: center; gap: 16px; height: auto; padding: 12px 56px 12px 30px;
  border-radius: 10px; background: none; box-shadow: none; color: var(--ink); overflow: visible;
}
.nb-view.is-list .cover:hover { transform: none; background: var(--surface-soft); color: var(--ink); }
.nb-view.is-list .cover::before { left: 12px; top: 50%; bottom: auto; width: 8px; height: 24px; margin-top: -12px; border-radius: 3px; background: var(--c); box-shadow: 0 0 8px color-mix(in srgb, var(--c) 45%, transparent); }
.nb-view.is-list .cover::after { display: none; }
.nb-view.is-list .cover-label { display: contents; }
.nb-view.is-list .cover-label .name { color: var(--ink); -webkit-line-clamp: 1; }
.nb-view.is-list .cover-label .sub { padding: 0; border: 0; color: var(--muted-2); }
.nb-view.is-list .cover .name { flex: 1; min-width: 0; font-size: 16px; letter-spacing: -0.2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nb-view.is-list .cover .sub { gap: 18px; font-size: 13px; color: var(--muted-2); opacity: 1; white-space: nowrap; }
.nb-view.is-list .cover .sub span:first-child { min-width: 62px; text-align: right; }
.nb-view.is-list .cover-wrap details { top: 50%; right: 10px; transform: translateY(-50%); }
.nb-view.is-list .cover-wrap details[open] { transform: none; top: 6px; }
.nb-view.is-list .cover-wrap summary { background: none; color: var(--muted-2); }
.nb-view.is-list .cover-wrap summary:hover { background: var(--surface-soft); color: var(--ink); }
.nb-view.is-list .new-tile { height: auto; flex-direction: row; gap: 10px; padding: 14px 18px; border-radius: 10px; border-width: 1.5px; background: none; }
.nb-view.is-list .empty-stack svg { margin: 0; }
.nb-view.is-list .covers:has(> .new-tile) { padding: 0; border: 0; background: none; box-shadow: none; backdrop-filter: none; -webkit-backdrop-filter: none; }
.cover-wrap .cover { padding-top: 40px; }
.nb-view.is-list .cover-wrap .cover { padding-top: 12px; }
.nb-view.is-list .cover-wrap .cover .name { padding-right: 0; }
.tag-tree { display: flex; flex-direction: column; gap: 2px; }
.tag-row { display: flex; align-items: center; gap: 8px; padding: 7px 10px; border-radius: 9px; }
.tag-row:hover { background: var(--surface-soft); }
.tag-row a.name { flex: 1; color: var(--ink); text-decoration: none; }
.tag-row .count { font-size: 12px; color: var(--muted-2); }
.tag-row details summary { list-style: none; cursor: pointer; color: var(--muted-2); padding: 0 6px; }
.tag-row details summary::-webkit-details-marker { display: none; }
.tag-row details { position: relative; }
.token-box { font-family: var(--f-mono); font-size: 14px; padding: 12px 14px; border-radius: 10px; background: #17132B; color: #E9E6F5; word-break: break-all; }
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th, .table td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--line); }
.table th { color: var(--muted-2); font-weight: 600; font-size: 12px; }
.checks { display: grid; gap: 8px; }
.checks div { display: flex; justify-content: space-between; gap: 12px; font-size: 13px; }
.ok { color: var(--ok); font-weight: 600; } .no { color: var(--danger); font-weight: 600; }
.form-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; }
.form-row > label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); flex: 1 1 200px; }

/* ---- Bare pages: login, install, error ----------------------------------------------- */
.bare { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; }
.bare-card { width: 100%; max-width: 420px; border-radius: 24px; padding: 32px; background: var(--surface-soft); border: 1px solid var(--surface); backdrop-filter: blur(20px); box-shadow: var(--shadow-lg); display: flex; flex-direction: column; gap: 16px; }
.bare-card h1 { margin: 0; font-family: var(--f-display); font-weight: 600; font-size: 30px; letter-spacing: -0.8px; }
.bare-card label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); }
.bare-card .check { flex-direction: row; align-items: center; gap: 8px; }
.bare-logo { display: flex; align-items: center; gap: 10px; font-family: var(--f-display); font-weight: 600; font-size: 20px; }
.error-text { color: var(--danger); font-size: 13px; }
.bare-lead { margin: -8px 0 0; font-size: 14px; }
.bare-foot { margin: 0; font-size: 12px; line-height: 1.5; }
.bare-back { align-self: center; }
.code-input { font-family: var(--f-mono); font-size: 22px; letter-spacing: 4px; text-align: center; }

/* ---- Resizable columns (drag handles; widths saved in the bn_widths cookie) ---------- */
.sidebar > .resizer { position: absolute; top: 0; right: 0; bottom: 0; width: 7px; z-index: 3; }
.resizer { cursor: col-resize; touch-action: none; outline: none; }
.resizer::after { content: ''; position: absolute; top: 0; bottom: 0; left: 50%; width: 2px; margin-left: -1px; border-radius: 2px; background: transparent; transition: background 0.15s 0.05s; }
.resizer:hover::after, .resizer:focus-visible::after, .resizer.is-dragging::after { background: var(--violet); }
.resizer-list { position: sticky; top: var(--topbar-h); flex: 0 0 9px; align-self: stretch; height: calc(100vh - var(--topbar-h)); height: calc(100dvh - var(--topbar-h)); margin-left: -9px; z-index: 4; }
html.is-resizing, html.is-resizing * { cursor: col-resize !important; user-select: none !important; }
.sb-link > svg { flex: none; color: #9891B5; }
.sb-link.is-active > svg, .sb-link:hover > svg { color: #E3DCFF; }
.menu-pin { width: 100%; justify-content: flex-start; }

/* ---- Home ----------------------------------------------------------------------------- */
.home { max-width: 1180px; gap: 26px; }
.home-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; }
.home-head h1 { margin: 4px 0 0; font-family: var(--f-display); font-weight: 600; font-size: 38px; letter-spacing: -1.2px; line-height: 1.05; }
.home-me { display: none; text-decoration: none; }
.home-me .avatar { width: 40px; height: 40px; font-size: 14px; }
.home-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: -10px; }
.home-chips .chip { gap: 7px; padding: 7px 13px; backdrop-filter: blur(14px); }
.home-chips .chip svg { color: var(--muted-2); }
.home-chips .chip:hover { background: var(--glass-hover); color: var(--ink); }
.home-section { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.home-section-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 12px; padding: 0 2px; }
.home-section-head h2 { margin: 0; font-family: var(--f-display); font-weight: 600; font-size: 17px; letter-spacing: -0.4px; }
.home-section-head .muted { font-size: 13px; }
.home-more { margin-left: auto; font-size: 13px; text-decoration: none; font-weight: 500; }
.home-covers { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 14px; }
.cover-sm { height: 124px; padding: 12px 12px 12px 26px; }
.cover-sm .name { font-size: 17px; }
.home-cols { gap: 28px; }
.home-recent { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; }
.home-recent .card { min-height: 112px; background: light-dark(rgba(255, 255, 255, 0.62), rgba(44, 37, 82, 0.4)); border-color: transparent; box-shadow: none; backdrop-filter: none; }
.home-recent .card:hover { background: var(--surface); }
.card-where { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted-2); min-width: 0; }
.card-when { margin-left: auto; white-space: nowrap; }
.home-list { gap: 2px; padding: 8px; }
.home-list a { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 10px; text-decoration: none; color: var(--ink); min-width: 0; }
.home-list a:hover { background: var(--surface-soft); color: var(--ink); }
.home-list .name { flex: 1; min-width: 0; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.home-list .muted { font-size: 12px; white-space: nowrap; max-width: 40%; overflow: hidden; text-overflow: ellipsis; }
.home-list p { padding: 6px 8px; font-size: 13px; }
/* Search popover under the top-bar field. */
.search-pop.is-below { right: auto; max-width: none; }

/* ---- Notebooks list (phone Notebooks tab) ---------------------------------------------- */
.library-list { max-width: 720px; gap: 14px; }
.ll-sync { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }
.ll-sync i { width: 7px; height: 7px; border-radius: 50%; background: var(--mint); }
.ll-card { border-radius: 18px; background: var(--glass); border: 1px solid var(--glass-border); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); box-shadow: var(--shadow-sm); overflow: hidden; }
.ll-head { display: flex; align-items: center; gap: 10px; width: 100%; padding: 13px 14px; border: 0; background: none; font-weight: 700; text-align: left; color: var(--ink); }
.ll-head .name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ll-head .count { font-weight: 400; font-size: 13px; color: var(--muted-2); }
.ll-head .sb-caret-icon { display: inline-flex; color: var(--muted-2); transform: rotate(90deg); transition: transform 0.18s ease; }
.ll-card.is-collapsed .sb-caret-icon { transform: none; }
.ll-head.is-static { cursor: default; }
.ll-card .sb-children > div { padding-top: 0; gap: 0; }
.ll-row { display: flex; align-items: center; gap: 12px; padding: 13px 14px; text-decoration: none; color: var(--ink); border-top: 1px solid var(--line); }
.ll-card > .ll-row:first-child { border-top: 0; }
.ll-row:hover { background: var(--surface-soft); color: var(--ink); }
.ll-row .name { flex: 1; min-width: 0; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ll-row .count { font-size: 13px; color: var(--muted-2); }
.ll-row > svg { color: var(--faint); }
.ll-pin { display: inline-flex; color: var(--muted-2); }
.ll-hint { padding: 10px 14px 14px; font-size: 13px; color: var(--muted); border-top: 1px solid var(--line); }
.library-list > .btn { align-self: flex-start; }

/* ---- Settings: profile + appearance ------------------------------------------------------ */
.profile-form { display: flex; flex-wrap: wrap; align-items: center; gap: 18px; }
.input-file { padding: 8px 10px; height: auto; font-size: 13px; }
.theme-picker { display: flex; flex-wrap: wrap; gap: 12px; }
.theme-opt { position: relative; display: flex; flex-direction: column; gap: 8px; align-items: center; padding: 10px; border-radius: 14px; cursor: pointer; font-size: 13px; font-weight: 600; color: var(--ink-2); }
.theme-opt input { position: absolute; opacity: 0; }
.theme-opt:has(input:checked) { background: var(--accent-soft); color: var(--violet-deep); }
.theme-opt:has(input:focus-visible) { outline: 2px solid var(--violet); }
.theme-swatch { display: flex; width: 120px; height: 76px; border-radius: 11px; overflow: hidden; box-shadow: var(--shadow-sm), inset 0 0 0 1px var(--line); }
.theme-swatch i { flex: 1; }
.theme-swatch i:first-child { flex: 0 0 34px; background: linear-gradient(180deg, #221B44, #0F0B1F); }
.theme-light .theme-swatch i:last-child { background: radial-gradient(circle at 90% 10%, rgba(255, 107, 74, 0.25), transparent 50%), #EFECF8; }
.theme-dark .theme-swatch i:last-child { background: radial-gradient(circle at 90% 10%, rgba(255, 107, 74, 0.18), transparent 50%), #110D22; }
.theme-system .theme-swatch i:last-child { background: linear-gradient(135deg, #EFECF8 50%, #110D22 50%); }
.theme-opt:has(input:checked) .theme-swatch { box-shadow: 0 0 0 2px var(--violet), var(--shadow-sm); }

/* ---- Tab bar (phones) ----------------------------------------------------------------- */
.tabbar { display: none; }

/* ---- Small screens ---------------------------------------------------------------- */
@media (max-width: 900px) {
  .app { flex-direction: column; }
  .sidebar { display: none; }
  .resizer { display: none; }
  .main { margin-left: 0; padding-bottom: calc(96px + env(safe-area-inset-bottom)); }
  .main-body { flex-direction: column; flex-wrap: nowrap; align-items: stretch; }
  /* Phones: the tab bar has Search and Betsy has her floating button, so the top bar keeps only page actions. */
  .topbar { padding: env(safe-area-inset-top, 0px) 8px 0 12px; height: calc(var(--topbar-h) - 6px + env(safe-area-inset-top, 0px)); }
  .topbar-search, .topbar-sep, .topbar .betsy-dock { display: none; }
  .topbar:has(.topbar-actions:empty) { display: none; }
  .topbar-actions { min-width: 0; overflow-x: auto; scrollbar-width: none; }
  .topbar .save-state { margin-right: 2px; }
  .toolbar-wrap { top: calc(var(--topbar-h) - 6px + env(safe-area-inset-top, 0px)); }
  .list-pane { width: 100%; flex: none; position: static; height: auto; max-height: none; overflow: visible; padding: 18px 14px 24px; }
  .has-note .list-pane { display: none; }
  /* A notebook or list opened without picking a note: show the list, not its first note. */
  .has-note.auto-note .list-pane { display: flex; }
  .auto-note .note-pane { display: none; }
  .note-pane { padding: 0 0 24px; }
  .sheet { border-radius: 0; border-left: 0; border-right: 0; }
  .note-body { padding: 22px 20px 28px; }
  .note-title { font-size: 28px; }
  .context-box { margin: 0 12px; }
  .back-link { display: inline-flex !important; align-self: flex-start; margin: 12px 12px 0; }
  .toolbar .hint { display: none; }
  .search-scrim { inset: 0; }
  .search-pop, .search-pop.is-below { left: 8px; right: 8px; width: auto; top: 64px; max-height: calc(100vh - 170px); }
  .search-arrow { display: none; }
  .toolbar { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
  .toolbar .icon-btn, .toolbar .btn { flex: none; }
  .page { padding: 18px 14px 32px; }
  .cols > .side#tags { order: -1; }
  .home { gap: 20px; }
  .home-head h1 { font-size: 30px; }
  .home-hero { padding-right: 52px; }
  .home-me { display: block; }
  .home-covers { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .home-recent { grid-template-columns: 1fr; }

  .tabbar {
    position: fixed; left: 12px; right: 12px; bottom: calc(14px + env(safe-area-inset-bottom)); z-index: 26; height: 66px; padding: 0 6px;
    display: flex; align-items: center; border-radius: 22px;
    background: var(--bar); border: 1px solid var(--glass-border); backdrop-filter: blur(18px) saturate(1.3); -webkit-backdrop-filter: blur(18px) saturate(1.3);
    box-shadow: 0 14px 34px color-mix(in srgb, var(--shade-v) 18%, transparent);
  }
  .tab { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 6px 0; text-decoration: none; color: var(--muted-2); font-size: 11px; }
  .tab:hover { color: var(--ink-2); }
  .tab.is-on { color: var(--violet-deep); font-weight: 600; }
  .tab-new { flex: none; display: flex; }
  .tab-new button {
    width: 54px; height: 54px; margin-top: -26px; border: 0; border-radius: 18px; display: flex; align-items: center; justify-content: center;
    background: var(--violet-grad); color: #fff; box-shadow: 0 10px 24px rgba(108, 75, 255, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.25);
  }
  .tab-new button svg { stroke-width: 2; }
  /* Writing a note: the bar would cover the keyboard's accessory row, so it steps aside. */
  .has-note.is-typing .tabbar { transform: translateY(140%); }
  .tabbar { transition: transform 0.2s ease; }
}
.back-link { display: none; }

/* ---- Settings → Deploy ---------------------------------------------------------------------- */
.dp-intro { margin: 0; font-size: 14px; max-width: 70ch; }
.dp-intro code, .dp-summary code, .dp-list code, .panel p code, .form-row code { font-family: var(--f-mono); font-size: 0.86em; }
.dp-code { margin: 0; padding: 12px 14px; border-radius: 12px; background: var(--surface); font-family: var(--f-mono); font-size: 12.5px; overflow-x: auto; }
.dp-maint { border-color: color-mix(in srgb, var(--danger) 35%, transparent); }
.dp-summary { margin: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 14px; }
.dp-summary dt { font-size: 11px; font-weight: 600; letter-spacing: 1px; text-transform: uppercase; color: var(--muted-2); }
.dp-summary dd { margin: 4px 0 0; font-size: 14px; }
.dp-pill { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; background: var(--surface); font-size: 12px; font-weight: 600; color: var(--muted); white-space: nowrap; }
.dp-pill i { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.dp-pill.is-ok { color: var(--ok); background: color-mix(in srgb, var(--ok) 12%, transparent); }
.dp-pill.is-warn { color: light-dark(#9A4F00, #FFC37A); background: rgba(255, 170, 60, 0.16); }
.dp-pill.is-no { color: var(--danger); background: var(--danger-soft); }
.dp-pill.is-warn i { animation: dp-blink 1.2s ease-in-out infinite; }
@keyframes dp-blink { 50% { opacity: 0.3; } }
@media (prefers-reduced-motion: reduce) { .dp-pill.is-warn i { animation: none; } }
.dp-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.dp-head h2 { margin: 0; }
.dp-log { margin-left: auto; font-size: 13px; }
.dp-steps { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; font-size: 14px; }
.dp-steps li { display: flex; align-items: center; gap: 10px; }
.dp-steps .dp-mark { width: 20px; height: 20px; flex: none; border-radius: 50%; display: grid; place-items: center; font-size: 11px; font-weight: 700; border: 1.5px solid color-mix(in srgb, var(--muted-2) 45%, transparent); }
.dp-steps .is-done .dp-mark { border: 0; background: var(--violet-grad); color: #fff; }
.dp-steps .is-fail .dp-mark { border: 0; background: var(--danger); color: #fff; }
.dp-steps .is-fail .dp-label { color: var(--danger); }
.dp-steps .is-run .dp-mark { border-color: var(--violet); border-right-color: transparent; animation: dp-spin 0.9s linear infinite; }
.dp-steps .is-wait .dp-label { color: var(--muted-2); }
@keyframes dp-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .dp-steps .is-run .dp-mark { animation: none; } }
.dp-secs { margin-left: auto; font-size: 12px; color: var(--muted-2); font-variant-numeric: tabular-nums; }
.dp-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; font-size: 14px; }
.dp-list li { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.dp-list li .muted { font-size: 12px; }
.dp-form { display: flex; flex-direction: column; align-items: flex-start; gap: 10px; }
.dp-form .check { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.dp-form .check input { accent-color: var(--violet); }
.dp-form .btn { margin-top: 4px; }

/* ---- Settings → Backups ------------------------------------------------------------ */
.backup-list { display: flex; flex-direction: column; gap: 2px; }
.backup-row { display: flex; align-items: center; gap: 12px; padding: 6px 10px; border-radius: 10px; }
.backup-row:hover { background: var(--surface-soft); }
.backup-row .name { flex: 1; font-weight: 600; }
.backup-row form { margin: 0; }

/* ---- Note list: modes (cards · snippets · compact), pins, checklist progress -------------- */
.list-tools { justify-content: space-between; }
.list-desc { margin: 2px 0 0; font-size: 13px; color: var(--muted); line-height: 1.4; }
.seg.seg-sm { height: 32px; padding: 2px; border-radius: 9px; }
.seg.seg-sm a { width: 30px; height: 26px; border-radius: 7px; }
.card-title { display: flex; align-items: baseline; gap: 6px; min-width: 0; }
.card-title .t { min-width: 0; }
.card-pin { display: inline-flex; color: var(--violet); flex: none; transform: translateY(2px); }
.card-progress { display: inline-flex; align-items: center; gap: 6px; font-variant-numeric: tabular-nums; }
.card-progress i { position: relative; width: 34px; height: 4px; border-radius: 2px; background: color-mix(in srgb, var(--ink) 12%, transparent); overflow: hidden; }
.card-progress i::after { content: ''; position: absolute; inset: 0 auto 0 0; width: var(--p); border-radius: 2px; background: var(--violet); }
.card-progress.is-done i::after { background: var(--mint); }

.mode-snippets .card { position: relative; gap: 4px; padding: 12px 14px; }
.mode-snippets .card:has(.card-thumbs) { padding-right: 84px; }
.mode-snippets .card-thumbs { position: absolute; top: 12px; right: 12px; width: 60px; height: 60px; margin: 0; padding: 0; background: none; }
.mode-snippets .card-thumbs img { border-radius: 8px; }
.mode-snippets .card-thumbs img + img { display: none; }
.mode-snippets .card-excerpt { -webkit-line-clamp: 3; }
.mode-snippets .card-meta .right { display: none; }

.mode-compact { gap: 2px; }
.mode-compact .card { flex-direction: row; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 10px; box-shadow: none; }
.mode-compact .card-thumbs, .mode-compact .card-excerpt, .mode-compact .card-meta .right { display: none; }
.mode-compact .card-title { flex: 1; font-size: 14px; font-weight: 600; }
.mode-compact .card-title .t { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mode-compact .card-meta { flex: none; gap: 8px; }
.mode-compact .card-progress i { display: none; }

/* ---- Archived notebooks (Organize) ------------------------------------------------------ */
.archived-section .cover-wrap { opacity: 0.72; filter: saturate(0.6); }
.archived-section .cover-wrap:hover { opacity: 1; filter: none; }
.cover .desc { position: relative; font-size: 12px; opacity: 0.85; line-height: 1.35; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.nb-view.is-list .cover .desc { display: none; }
.menu textarea.input { height: auto; min-height: 56px; padding: 8px 12px; resize: vertical; font: inherit; }

/* ---- Drop files onto a notebook in the sidebar ------------------------------------------ */
.sb-link.is-drop-target { background: color-mix(in srgb, var(--c, var(--violet)) 35%, transparent); box-shadow: inset 0 0 0 1.5px var(--c, var(--violet)); color: #fff; }

/* ---- Toast (undo) ----------------------------------------------------------------------- */
.toast { position: fixed; left: 50%; bottom: 28px; z-index: 80; display: flex; align-items: center; gap: 14px; padding: 11px 12px 11px 18px; border-radius: 14px;
  background: color-mix(in srgb, #17132B 92%, transparent); color: #fff; backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px);
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.3); font-size: 14px; transform: translate(-50%, 0); animation: toast-in 0.22s ease-out; }
.toast[hidden] { display: none; }
.toast.is-leaving { opacity: 0; transform: translate(-50%, 10px); transition: opacity 0.2s, transform 0.2s; }
.toast button { border: 0; border-radius: 9px; padding: 6px 12px; background: rgba(255, 255, 255, 0.14); color: #fff; font-weight: 700; cursor: pointer; }
.toast button:hover { background: rgba(255, 255, 255, 0.24); }
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 12px); } }
@media (max-width: 900px) { .toast { bottom: 96px; } }

/* ---- Quick capture + keyboard sheet (dialogs) ------------------------------------------- */
.sb-new-row { display: flex; gap: 6px; }
.sb-new-row .sb-new { flex: 1; width: auto; }
.sb-capture { width: 36px; height: 36px; padding: 0; border-radius: 9px; flex: none; background: rgba(255, 255, 255, 0.07); border-color: transparent; color: #E3DCFF; }
.sb-capture:hover { background: rgba(255, 255, 255, 0.16); color: #fff; }
dialog.qc { width: min(560px, calc(100vw - 24px)); padding: 0; border: 1px solid var(--surface); border-radius: 20px; color: var(--ink);
  background: var(--pop-bg); backdrop-filter: blur(24px); -webkit-backdrop-filter: blur(24px);
  box-shadow: 0 40px 90px color-mix(in srgb, var(--shade) 35%, transparent); }
dialog.qc[open] { animation: qc-in 0.18s ease-out; }
dialog.qc::backdrop { background: color-mix(in srgb, var(--shade) 30%, transparent); backdrop-filter: blur(3px); }
@keyframes qc-in { from { opacity: 0; transform: translateY(8px) scale(0.98); } }
.qc-form { display: flex; flex-direction: column; }
.qc-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px 10px; background: linear-gradient(180deg, color-mix(in srgb, var(--tint-top) 90%, transparent), transparent); }
.qc-head h2 { margin: 0; display: flex; align-items: center; gap: 8px; font-family: var(--f-display); font-weight: 600; font-size: 19px; letter-spacing: -0.3px; }
.qc-head h2 svg { color: var(--violet); }
.qc kbd, .kbd-grid kbd { font: 11px var(--f-ui); color: var(--muted-2); border: 1px solid color-mix(in srgb, var(--ink) 14%, transparent); border-radius: 5px; padding: 1px 6px; }
.qc-title { border: 0; background: none; padding: 6px 20px; font: 700 18px var(--f-ui); color: var(--ink); }
.qc-text { border: 0; background: none; padding: 6px 20px 12px; font: 16px/1.55 var(--f-read); color: var(--ink); resize: vertical; min-height: 140px; }
.qc-title:focus, .qc-text:focus { outline: none; }
.qc-foot { display: flex; align-items: center; gap: 8px; padding: 12px 16px; border-top: 1px solid var(--line); }
.qc-foot .grow { flex: 1; }
.qc-foot .select { height: 36px; width: auto; max-width: 220px; }
.qc-foot .btn-primary kbd { color: #E3DCFF; border-color: rgba(255, 255, 255, 0.3); margin-left: 4px; }
.kbd-help { width: min(480px, calc(100vw - 24px)); }
.kbd-grid { display: grid; grid-template-columns: auto 1fr; gap: 10px 18px; padding: 6px 20px 22px; font-size: 14px; align-items: center; }
.kbd-grid > span:nth-child(odd) { display: flex; gap: 3px; justify-content: flex-end; white-space: nowrap; }
.kbd-grid kbd { font-size: 12px; min-width: 22px; text-align: center; background: var(--surface-soft); }

/* ---- Templates, ⋯ menu in the note header, Today chip, toast link -------------------------- */
.tpl-row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 4px 0 -4px; font-size: 13px; }
.tpl-row[hidden] { display: none; }
.tpl-row .chip { cursor: pointer; }
.tpl-row .chip:hover { background: var(--accent-soft); color: var(--violet-deep); border-color: transparent; }
.note-more { position: relative; }
.note-more summary { list-style: none; cursor: pointer; }
.note-more summary::-webkit-details-marker { display: none; }
.note-more .menu { width: 210px; gap: 4px; padding: 8px; }
.note-more .menu .btn { border: 0; background: none; }
.note-more .menu .btn:hover { background: var(--surface-soft); }
.chip-today { background: var(--violet-grad); color: #fff; border-color: transparent; font-weight: 600; box-shadow: 0 6px 16px rgba(108, 75, 255, 0.3); }
.home-chips .chip-today svg { color: #fff; }
.home-chips .chip-today:hover { background: var(--violet-grad); color: #fff; filter: brightness(1.06); }
.toast-link { color: #fff; font-weight: 700; text-decoration: none; padding: 6px 12px; border-radius: 9px; background: rgba(255, 255, 255, 0.14); }
.toast-link:hover { color: #fff; background: rgba(255, 255, 255, 0.24); }

/* ---- Motion ----------------------------------------------------------------------------- */
/* No cross-page View Transitions (snapshots of the whole page flickered); the note eases in instead. */
.note-body, .context-box { animation: note-in 0.18s ease-out both; }
@keyframes note-in { from { opacity: 0; transform: translateY(4px); } }
.card { transition: background 0.15s, box-shadow 0.15s, border-color 0.15s; }
.cover { transition: transform 0.18s ease, box-shadow 0.18s ease, background 0.15s; }
.sb-link, .chip, .btn { transition: background 0.15s, color 0.15s, box-shadow 0.15s, filter 0.15s; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
.tpl-row .chip { border-color: color-mix(in srgb, var(--ink) 12%, transparent); background: var(--surface-soft); }
dialog.qc:focus, dialog.qc:focus-visible { outline: none; }

/* ---- Highlighter colours (yellow = plain <mark>; others carry data-color) ----------------- */
:root {
  --hl-yellow: #FFE45C;
  --hl-mint: light-dark(#AEEBD8, rgba(31, 181, 143, 0.34));
  --hl-coral: light-dark(#FFC9BA, rgba(255, 122, 89, 0.34));
  --hl-sky: light-dark(#C6E2FF, rgba(80, 160, 255, 0.34));
  --hl-violet: light-dark(#DDD3FF, rgba(132, 102, 255, 0.4));
}
.prose mark[data-color="mint"] { --mark-bottom: var(--hl-mint); --mark-top: light-dark(rgba(0, 0, 0, 0), var(--hl-mint)); --mark-ink: light-dark(currentColor, #D2FFF0); }
.prose mark[data-color="coral"] { --mark-bottom: var(--hl-coral); --mark-top: light-dark(rgba(0, 0, 0, 0), var(--hl-coral)); --mark-ink: light-dark(currentColor, #FFE1D8); }
.prose mark[data-color="sky"] { --mark-bottom: var(--hl-sky); --mark-top: light-dark(rgba(0, 0, 0, 0), var(--hl-sky)); --mark-ink: light-dark(currentColor, #DDEEFF); }
.prose mark[data-color="violet"] { --mark-bottom: var(--hl-violet); --mark-top: light-dark(rgba(0, 0, 0, 0), var(--hl-violet)); --mark-ink: light-dark(currentColor, #ECE6FF); }
.hl-wrap { position: relative; display: inline-flex; }
.toolbar .swatch[data-color="mint"] { background: var(--hl-mint); }
.toolbar .swatch[data-color="coral"] { background: var(--hl-coral); }
.toolbar .swatch[data-color="sky"] { background: var(--hl-sky); }
.toolbar .swatch[data-color="violet"] { background: var(--hl-violet); }
.hl-pop { position: absolute; top: 40px; left: 50%; transform: translateX(-50%); z-index: 30; display: flex; gap: 4px; padding: 6px; border-radius: 12px; background: var(--pop-bg); border: 1px solid var(--surface); box-shadow: var(--shadow-lg); backdrop-filter: blur(20px); }
.hl-pop[hidden] { display: none; }
.hl-swatch { width: 30px; height: 30px; display: inline-flex; align-items: center; justify-content: center; border: 0; border-radius: 8px; background: none; color: var(--muted-2); cursor: pointer; }
.hl-swatch:hover { background: var(--surface-soft); }
.hl-swatch i { width: 18px; height: 18px; border-radius: 5px; box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--ink) 8%, transparent); }
.hl-swatch .hl-yellow { background: var(--hl-yellow); } .hl-swatch .hl-mint { background: var(--hl-mint); } .hl-swatch .hl-coral { background: var(--hl-coral); }
.hl-swatch .hl-sky { background: var(--hl-sky); } .hl-swatch .hl-violet { background: var(--hl-violet); }

/* ---- Find & replace --------------------------------------------------------------------- */
.find-bar { display: flex; align-items: center; gap: 6px; margin-top: 8px; padding: 6px 8px 6px 12px; border-radius: 12px; background: var(--surface); box-shadow: var(--shadow-sm); flex-wrap: wrap; }
.find-bar[hidden] { display: none; }
.find-bar > svg { color: var(--muted-2); }
.find-input { height: 32px; min-width: 0; flex: 1 1 140px; padding: 0 10px; border-radius: 8px; border: 1px solid color-mix(in srgb, var(--ink) 12%, transparent); background: var(--glass-hover); color: var(--ink); font: 14px var(--f-ui); }
.find-input:focus { outline: none; border-color: var(--violet); box-shadow: 0 0 0 3px rgba(108, 75, 255, 0.16); }
.find-count { font-size: 12px; color: var(--muted-2); min-width: 34px; text-align: center; font-variant-numeric: tabular-nums; }
.find-count.is-none { color: var(--danger); }
.find-bar [data-find-prev] svg { transform: rotate(180deg); }
.find-bar .icon-btn { width: 30px; height: 30px; }
.prose .find-hit { background: color-mix(in srgb, var(--violet) 18%, transparent); border-radius: 3px; box-shadow: 0 0 0 1px color-mix(in srgb, var(--violet) 30%, transparent); }
.prose .find-hit.is-current { background: color-mix(in srgb, var(--violet) 42%, transparent); box-shadow: 0 0 0 2px var(--violet); }

/* ---- Slash menu ------------------------------------------------------------------------- */
.slash-menu { position: fixed; z-index: 60; width: 270px; max-height: 340px; overflow-y: auto; padding: 6px; border-radius: 14px; background: var(--pop-bg); border: 1px solid var(--surface);
  backdrop-filter: blur(24px); -webkit-backdrop-filter: blur(24px); box-shadow: 0 24px 60px color-mix(in srgb, var(--shade) 22%, transparent), 0 2px 8px color-mix(in srgb, var(--ink) 6%, transparent); }
.slash-item { display: flex; flex-direction: column; align-items: flex-start; gap: 1px; width: 100%; padding: 7px 10px; border: 0; border-radius: 9px; background: none; color: var(--ink); text-align: left; cursor: pointer; }
.slash-item.is-active { background: var(--accent-soft); }
.slash-title { font-weight: 600; font-size: 14px; }
.slash-hint { font-size: 12px; color: var(--muted-2); }
.slash-empty { padding: 10px; font-size: 13px; color: var(--muted-2); }

/* ---- Link cards ------------------------------------------------------------------------- */
.prose .link-card, .prose div[data-type="link-card"] { position: relative; margin: 10px 0; }
.link-card-open { display: flex; gap: 14px; align-items: flex-start; padding: 14px 44px 14px 14px; border-radius: 14px; text-decoration: none; color: var(--ink);
  background: var(--surface-soft); border: 1px solid color-mix(in srgb, var(--ink) 9%, transparent); box-shadow: var(--shadow-sm); font-family: var(--f-ui); }
.link-card-open:hover { color: var(--ink); border-color: color-mix(in srgb, var(--violet) 35%, transparent); }
.link-card.ProseMirror-selectednode .link-card-open { box-shadow: 0 0 0 2px var(--violet); }
.link-card-badge { flex: none; width: 38px; height: 38px; border-radius: 10px; display: flex; align-items: center; justify-content: center; font: 600 17px var(--f-display); color: var(--muted); background: color-mix(in srgb, var(--ink) 7%, transparent); }
.link-card-body { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.link-card-site { font-size: 12px; color: var(--muted-2); }
.link-card-title { font-weight: 700; font-size: 15px; line-height: 1.3; }
.link-card-desc { font-size: 13px; color: var(--muted); line-height: 1.4; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.link-card-url { font-size: 12px; color: var(--muted-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.link-card-x { position: absolute; top: 8px; right: 8px; width: 28px; height: 28px; border: 0; border-radius: 8px; background: none; color: var(--muted-2); font-size: 18px; line-height: 1; cursor: pointer; opacity: 0; transition: opacity 0.15s; }
.link-card:hover .link-card-x, .link-card-x:focus-visible { opacity: 1; }
.link-card-x:hover { background: color-mix(in srgb, var(--ink) 8%, transparent); color: var(--ink); }
@media (hover: none) { .link-card-x { opacity: 1; } }
.prose .link-card-open, .prose .link-card-open:hover { color: var(--ink); text-decoration: none; }
.menu-kbd { margin-left: auto; font: 11px var(--f-ui); color: var(--muted-2); border: 1px solid color-mix(in srgb, var(--ink) 14%, transparent); border-radius: 5px; padding: 0 5px; }

/* ---- Note links, Linked from, hiding a related note -------------------------------------- */
.prose a[href^="/notes/"] { text-decoration: none; color: var(--violet-deep); background: var(--accent-soft); border-radius: 5px; padding: 0 4px; box-shadow: inset 0 -1px 0 color-mix(in srgb, var(--violet) 35%, transparent); cursor: pointer; }
.prose a[href^="/notes/"]::before { content: '↗ '; font-size: 0.8em; opacity: 0.6; }
.prose a[href^="/notes/"]:hover { background: var(--accent-soft-2); }
.slash-head { padding: 6px 10px 4px; font-size: 11px; font-weight: 600; letter-spacing: 1px; text-transform: uppercase; color: var(--muted-2); }
.link-item .slash-title { display: flex; align-items: center; gap: 7px; }
.link-item .spine { width: 7px; height: 11px; }
.backlinks { display: flex; flex-direction: column; gap: 8px; }
.backlinks[hidden], .context-grid[hidden] { display: none; }
.bl-list { display: flex; flex-direction: column; gap: 6px; }
.bl-row { display: flex; flex-direction: column; gap: 3px; padding: 10px 14px; border-radius: 12px; text-decoration: none; color: var(--ink); background: var(--surface-soft); border: 1px solid var(--glass-border); }
.bl-row:hover { background: var(--surface); color: var(--ink); }
.bl-title { display: flex; align-items: center; gap: 7px; font-weight: 700; font-size: 13px; }
.bl-title .spine { width: 7px; height: 10px; }
.bl-snip { font-family: var(--f-read); font-size: 14px; line-height: 1.45; color: var(--ink-2); }
.bl-snip mark { background: var(--accent-soft-2); color: var(--violet-deep); border-radius: 3px; padding: 0 2px; }
.ctx-wrap { position: relative; display: flex; transition: opacity 0.2s, transform 0.2s; }
.ctx-wrap .ctx-card { flex: 1; }
.ctx-wrap.is-removing { opacity: 0; transform: scale(0.96); }
.ctx-hide { position: absolute; top: 6px; right: 6px; width: 24px; height: 24px; border: 0; border-radius: 7px; background: none; color: var(--muted-2); font-size: 16px; line-height: 1; cursor: pointer; opacity: 0; transition: opacity 0.15s; }
.ctx-wrap:hover .ctx-hide, .ctx-hide:focus-visible { opacity: 1; }
.ctx-hide:hover { background: color-mix(in srgb, var(--ink) 8%, transparent); color: var(--ink); }
@media (hover: none) { .ctx-hide { opacity: 1; } }

/* ---- Reminders --------------------------------------------------------------------------- */
.rem-menu .menu { width: 250px; gap: 2px; padding: 8px; }
.rem-menu .menu .eyebrow { padding: 4px 8px 2px; }
.rem-menu .menu .btn { border: 0; background: none; justify-content: flex-start; }
.rem-menu .menu .btn .muted { margin-left: auto; font-weight: 400; }
.rem-menu .menu .btn:hover { background: var(--surface-soft); }
.rem-custom .input { width: 100%; height: 36px; margin: 4px 0; font-size: 13px; }
.rem-actions { display: flex; gap: 6px; padding-top: 6px; border-top: 1px solid var(--line); }
.rem-actions[hidden] { display: none; }
.rem-actions .btn { flex: 1; justify-content: center !important; border: 1px solid var(--glass-border) !important; }
.rem-chip { display: inline-flex; align-items: center; gap: 5px; height: 24px; padding: 0 9px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--accent-soft); color: var(--violet-deep); }
.rem-chip[hidden] { display: none; }
.rem-chip.is-overdue { background: color-mix(in srgb, var(--danger) 14%, transparent); color: var(--danger); }
.rem-strip { display: flex; flex-direction: column; gap: 2px; padding: 8px; margin-bottom: 6px; border-radius: 14px; background: var(--glass); border: 1px solid var(--glass-border); }
.rem-strip > .eyebrow { display: flex; align-items: center; gap: 6px; padding: 2px 6px 4px; }
.rem-row { display: flex; align-items: center; gap: 10px; padding: 6px; border-radius: 9px; transition: opacity 0.3s; }
.rem-row:hover { background: var(--surface-soft); }
.rem-row.is-done { opacity: 0.4; }
.rem-row.is-done .rem-title { text-decoration: line-through; }
.rem-check { flex: none; width: 18px; height: 18px; border-radius: 50%; border: 1.5px solid color-mix(in srgb, var(--ink) 30%, transparent); background: none; cursor: pointer; padding: 0; }
.rem-check:hover { border-color: var(--violet); background: var(--accent-soft); }
.rem-row.is-done .rem-check { background: var(--violet); border-color: var(--violet); }
.rem-title { flex: 1; min-width: 0; display: flex; align-items: center; gap: 7px; font-weight: 600; font-size: 14px; color: var(--ink); text-decoration: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rem-title .spine { width: 6px; height: 10px; flex: none; }
.rem-when { flex: none; font-size: 12px; color: var(--muted-2); font-variant-numeric: tabular-nums; }
.rem-row.is-overdue .rem-when { color: var(--danger); font-weight: 600; }
.rem-row.is-today .rem-when { color: var(--violet-deep); font-weight: 600; }
.list-pane .rem-row, .home-rail .rem-row { display: grid; grid-template-columns: 18px minmax(0, 1fr); column-gap: 10px; row-gap: 1px; align-items: center; }
.list-pane .rem-check, .home-rail .rem-check { grid-row: span 2; }
.list-pane .rem-when, .home-rail .rem-when { grid-column: 2; }

/* ---- Home: a right-hand rail (reminders, shortcuts); on wide screens it runs the full height -- */
.home-rail { display: flex; flex-direction: column; gap: 28px; }
.home-rail .rem-strip { margin: 0; }
@media (min-width: 1500px) {
  .home { max-width: 1760px; display: grid; grid-template-columns: minmax(0, 1fr) clamp(320px, 23vw, 420px); column-gap: 36px; row-gap: 26px; align-content: start; }
  .home > * { grid-column: 1; min-width: 0; }
  .home-cols { display: contents; }
  .home-cols > .wide { grid-column: 1; }
  .home-cols > .home-rail { grid-column: 2; grid-row: 2 / span 4; align-self: start; position: sticky; top: calc(var(--topbar-h) + 24px); }
  .home-covers { grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); }
  .home-recent { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
}
@media (min-width: 2100px) {
  .home { max-width: none; }
}
.home-list p.muted { white-space: normal; max-width: none; overflow: visible; }
@media (min-width: 1800px) { .note-col { max-width: 820px; } }

/* ---- Home header: date, greeting, day summary. Plain text on the desk (search lives in the top bar). */
.home-hero { position: relative; display: flex; flex-direction: column; gap: 4px; padding: 6px 2px 0; }
.home-date { font-size: 13px; color: var(--muted-2); }
.home-hero h1 { margin: 0; font-family: var(--f-display); font-weight: 600; font-size: clamp(28px, 2.4vw, 34px); letter-spacing: -1.1px; line-height: 1.1; }
.hero-summary { margin: 2px 0 0; display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; font-size: 14px; color: var(--muted); }
.hero-summary .dot { width: 4px; height: 4px; border-radius: 50%; background: color-mix(in srgb, var(--ink) 25%, transparent); }
.home-hero .home-me { position: absolute; top: 4px; right: 0; }

/* Wide: the header spans both columns; the rail starts level with Notebooks */
@media (min-width: 1500px) {
  .home { grid-auto-flow: row dense; }
  .home > .home-hero, .home > .flash { grid-column: 1 / -1; }
  .home-cols > .home-rail { grid-row: auto / span 2; position: static; }
}

/* ---- Collapsible sections (fold-headings.js) ------------------------------------------------ */
.prose h1, .prose h2, .prose h3 { position: relative; }
.fold-caret { position: absolute; left: -26px; top: 50%; translate: 0 -50%; width: 22px; height: 22px; border: 0; border-radius: 6px; padding: 0; background: none; color: var(--faint); cursor: pointer; opacity: 0; transition: opacity 0.15s, color 0.15s, background 0.15s; }
.fold-caret::before { content: ''; position: absolute; inset: 0; margin: auto; width: 7px; height: 7px; border-right: 2px solid currentColor; border-bottom: 2px solid currentColor; rotate: 45deg; translate: 0 -2px; transition: rotate 0.15s, translate 0.15s; }
.fold-caret.is-closed::before { rotate: -45deg; translate: -1px 0; }
.prose h1:hover .fold-caret, .prose h2:hover .fold-caret, .prose h3:hover .fold-caret, .fold-caret.is-closed, .fold-caret:focus-visible { opacity: 1; }
.fold-caret:hover { color: var(--violet-deep); background: var(--accent-soft); }
.prose .is-folded-away { display: none; }
.prose .is-folded:not(.fold-caret)::after { content: '…'; margin-left: 8px; padding: 0 7px; border-radius: 6px; background: var(--accent-soft); color: var(--violet-deep); font-size: 0.7em; vertical-align: middle; }
@media (hover: none), (max-width: 900px) { .fold-caret { opacity: 0.7; left: -22px; } .note-col .prose { padding-left: 4px; } }

/* ---- Better tables (table-tools.js) ------------------------------------------------------------ */
.prose .tableWrapper { overflow-x: auto; margin: 0 0 12px; }
.prose .tableWrapper table { margin: 0; }
.prose table { table-layout: fixed; }
.prose td[data-bg="gray"], .prose th[data-bg="gray"], .cell-gray { background: var(--cell-gray); }
.prose td[data-bg="violet"], .prose th[data-bg="violet"], .cell-violet { background: var(--cell-violet); }
.prose td[data-bg="coral"], .prose th[data-bg="coral"], .cell-coral { background: var(--cell-coral); }
.prose td[data-bg="mint"], .prose th[data-bg="mint"], .cell-mint { background: var(--cell-mint); }
.prose td[data-bg="sky"], .prose th[data-bg="sky"], .cell-sky { background: var(--cell-sky); }
.prose td[data-bg="yellow"], .prose th[data-bg="yellow"], .cell-yellow { background: var(--cell-yellow); }
.prose td, .prose th { position: relative; }
.prose .selectedCell::after { content: ''; position: absolute; inset: 0; background: color-mix(in srgb, var(--violet) 14%, transparent); pointer-events: none; }
.prose .column-resize-handle { position: absolute; right: -2px; top: 0; bottom: -2px; width: 4px; background: var(--violet); pointer-events: none; z-index: 2; }
.prose.resize-cursor, .prose .resize-cursor { cursor: col-resize; }
.tbl-wrap { display: inline-flex; }
.toolbar [data-cmd="table"].is-on { color: var(--violet-deep); background: var(--accent-soft); }
.tbl-pop { position: fixed; z-index: 60; width: 300px; display: flex; flex-direction: column; gap: 10px; padding: 12px; border-radius: 16px; background: var(--pop-bg); border: 1px solid var(--surface); box-shadow: var(--shadow-lg); backdrop-filter: blur(24px); -webkit-backdrop-filter: blur(24px); }
.tbl-pop[hidden] { display: none; }
.tbl-group { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.tbl-group .eyebrow { flex-basis: 100%; }
.tbl-group .btn { height: 30px; padding: 0 10px; font-size: 12.5px; gap: 6px; background: color-mix(in srgb, var(--ink) 4%, transparent); border-color: transparent; }
.tbl-group .btn:hover { background: var(--accent-soft); color: var(--violet-deep); }
.tbl-group .btn-danger:hover { background: var(--danger-soft); color: var(--danger); }
.tbl-group .btn:disabled { opacity: 0.45; pointer-events: none; }
.tbl-row { padding-top: 8px; border-top: 1px solid var(--line); }
.tbl-swatches { display: flex; gap: 6px; }
.tbl-swatch { width: 30px; height: 30px; padding: 4px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); display: inline-flex; align-items: center; justify-content: center; color: var(--muted-2); }
.tbl-swatch i { display: block; width: 100%; height: 100%; border-radius: 5px; box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--ink) 8%, transparent); }
.tbl-swatch:hover { border-color: var(--violet); }

/* ---- Due dates on checklist items (task-due.js) and the to-dos page ---------------------------- */
.due-chip { display: inline-flex; align-items: center; height: 20px; margin-left: 8px; padding: 0 7px; border: 0; border-radius: 6px; font: 600 11.5px/1 var(--f-ui); vertical-align: 2px; text-decoration: none; white-space: nowrap; background: var(--accent-soft); color: var(--violet-deep); cursor: pointer; }
.due-chip.is-later { background: color-mix(in srgb, var(--ink) 6%, transparent); color: var(--muted); }
.due-chip.is-soon { background: var(--accent-soft); color: var(--violet-deep); }
.due-chip.is-today { background: var(--due-today-bg); color: var(--due-today); }
.due-chip.is-overdue { background: var(--danger-soft); color: var(--danger); }
.due-chip.is-done { background: color-mix(in srgb, var(--ink) 5%, transparent); color: var(--muted-2); }
.prose li[data-checked="true"] .due-chip { text-decoration: none; }
/* Math: the answer offered after "=" (Tab or click writes it in). */
.math-result { color: var(--violet); opacity: 0.75; font-weight: 600; cursor: pointer; border-radius: 4px; white-space: pre; }
.math-result::after { content: "tab"; margin-left: 6px; padding: 1px 5px; border-radius: 4px; font: 500 10px/1.4 var(--f-ui); vertical-align: 2px; color: var(--muted-2); background: color-mix(in srgb, var(--ink) 6%, transparent); }
.math-result:hover { opacity: 1; background: var(--accent-soft); }
@media (hover: none) { .math-result::after { content: "tap"; } }
span.due-chip { cursor: default; }
.due-pop { position: fixed; z-index: 60; width: 220px; display: flex; flex-direction: column; gap: 4px; padding: 10px; border-radius: 14px; background: var(--pop-bg); border: 1px solid var(--surface); box-shadow: var(--shadow-lg); backdrop-filter: blur(24px); -webkit-backdrop-filter: blur(24px); }
.due-pop .eyebrow { padding: 2px 6px 4px; }
.due-pop .btn { justify-content: space-between; }
.due-pop .rem-custom { margin: 4px 0; }
.due-pop .rem-custom .input { width: 100%; }

.todos { max-width: 860px; }
.todos-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.todos-head h1 { font-family: var(--f-display); font-size: 30px; margin: 0 0 4px; }
.todos-head p { margin: 0; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.todos-head .dot { width: 3px; height: 3px; border-radius: 50%; background: var(--faint); }
.todo-stat.is-overdue { color: var(--danger); font-weight: 600; }
.todo-stat.is-today { color: var(--due-today); font-weight: 600; }
.seg .seg-btn { width: auto; padding: 0 12px; gap: 6px; font-size: 13px; font-weight: 600; text-decoration: none; }
.seg .seg-btn.is-on { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-sm); }
.todo-groups { display: flex; flex-direction: column; gap: 12px; }
.todo-group { border-radius: 16px; padding: 6px 6px 8px; }
.todo-note { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-radius: 10px; text-decoration: none; color: var(--ink); }
.todo-note:hover { background: var(--surface-soft); color: var(--ink); }
.todo-note-title { font-weight: 700; font-family: var(--f-ui); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.todo-note-nb { font-size: 12px; white-space: nowrap; }
.todo-note-count { margin-left: auto; font-size: 12px; font-variant-numeric: tabular-nums; }
.todo-list { list-style: none; margin: 0; padding: 0 4px; }
.todo-item { display: flex; align-items: flex-start; gap: 6px; padding: 6px 8px 6px calc(8px + var(--depth, 0) * 22px); border-radius: 9px; }
.todo-item:hover { background: color-mix(in srgb, var(--ink) 3%, transparent); }
.todo-item label { display: flex; align-items: flex-start; gap: 10px; flex: 1; min-width: 0; cursor: pointer; font-size: 15px; line-height: 1.45; }
.todo-item input { accent-color: var(--violet); width: 17px; height: 17px; margin-top: 2px; flex: none; }
.todo-item .due-chip { vertical-align: 1px; }
.todo-item.is-done .todo-text { color: var(--muted-2); text-decoration: line-through; }
@media (max-width: 900px) { .todos-head h1 { font-size: 26px; } .todo-note-nb { display: none; } }

/* ---- PDF preview popover (pdf-view.js) ------------------------------------------------------- */
/* The eye shows while the pointer is over a PDF chip (always on touch screens). */
.file-chip .file-act { margin-left: 2px; border: 0; background: none; color: var(--muted-2); padding: 5px; border-radius: 7px; display: inline-flex; opacity: 0; transition: opacity 0.12s; }
.file-chip:hover .file-act, .file-chip:focus-within .file-act, .file-chip .file-act.is-on { opacity: 1; }
@media (hover: none) { .file-chip .file-act { opacity: 1; } }
.file-chip .file-act:hover, .file-chip .file-act.is-on { color: var(--violet-deep); background: var(--accent-soft); }
dialog.pdf-dialog {
  width: min(900px, calc(100vw - 32px)); height: min(92vh, 1200px); height: min(92dvh, 1200px); max-width: none; max-height: none; margin: auto; padding: 0;
  display: none; flex-direction: column; overflow: hidden; border-radius: 18px; border: 1px solid var(--glass-border); color: var(--ink);
  background: light-dark(rgba(246, 244, 252, 0.94), rgba(30, 25, 56, 0.95)); box-shadow: var(--shadow-lg);
}
dialog.pdf-dialog[open] { display: flex; animation: qc-in 0.18s ease-out; }
dialog.pdf-dialog::backdrop { background: color-mix(in srgb, var(--shade) 34%, transparent); backdrop-filter: blur(3px); }
.pdf-head { flex: none; display: flex; align-items: center; gap: 10px; padding: 10px 10px 10px 16px; border-bottom: 1px solid var(--line); background: var(--surface-soft); font-family: var(--f-ui); }
.pdf-head .grow { flex: 1; }
.pdf-badge { font-size: 9px; font-weight: 700; letter-spacing: 0.6px; padding: 3px 6px; border-radius: 5px; background: var(--surface); color: var(--ink-2); box-shadow: 0 1px 3px color-mix(in srgb, var(--shade) 12%, transparent); }
.pdf-name { font-weight: 600; font-size: 14px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pdf-pages { font-size: 12px; white-space: nowrap; }
.pdf-head .icon-btn { font-size: 20px; line-height: 1; }
/* The pages scroll inside the popover; each keeps its full height (flex: none, or the column would squash them). */
.pdf-scroll { flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 18px; display: flex; flex-direction: column; align-items: center; gap: 16px; outline: none; }
.pdf-page { flex: none; width: 100%; max-width: 820px; background: #fff; border-radius: 4px; box-shadow: var(--shadow-sm); overflow: hidden; }
.pdf-page canvas { display: block; width: 100%; height: auto; }
/* Office preview (office-view.js): same popover, Microsoft's viewer in a frame. Wider, for sheets and slides. */
dialog.office-dialog { width: min(1200px, calc(100vw - 32px)); }
.office-body { flex: 1 1 auto; min-height: 0; display: flex; background: #fff; }
.office-frame { flex: 1; width: 100%; height: 100%; border: 0; display: block; }
@media (max-width: 900px) {
  dialog.pdf-dialog { width: 100vw; height: 100vh; height: 100dvh; border-radius: 0; border: 0; }
  .pdf-head { padding-top: calc(10px + env(safe-area-inset-top, 0px)); }
  .pdf-scroll { padding: 8px 8px calc(8px + env(safe-area-inset-bottom, 0px)); gap: 8px; }
}

/* ---- Multi-select & bulk bar (library.js) -------------------------------------------------- */
/* (.list-pane stays sticky: being positioned, it still anchors the bulk bar's pop-ups.) */
.select-btn.is-on { background: var(--accent-soft-2); color: var(--violet-deep); box-shadow: 0 0 0 1px color-mix(in srgb, var(--violet) 35%, transparent); }
.select-btn.is-on svg { color: var(--violet-deep); }
.card.is-picked { background: var(--accent-soft); border-color: transparent; box-shadow: 0 0 0 2px color-mix(in srgb, var(--violet) 70%, transparent); }
.card { position: relative; }
.list-pane.is-selecting .card::after { content: ''; position: absolute; top: 10px; right: 10px; width: 18px; height: 18px; border-radius: 6px; border: 1.5px solid var(--faint); background: var(--surface); }
.list-pane.is-selecting .card.is-picked::after { border-color: var(--violet); background: var(--violet) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 18 18'%3E%3Cpath d='M4.5 9.5l3 3 6-7' fill='none' stroke='white' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / 14px no-repeat; }
.list-pane.is-selecting .card .card-title { padding-right: 24px; }
.bulk-bar { position: sticky; bottom: 12px; z-index: 20; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-top: 12px; padding: 8px 8px 8px 14px; border-radius: 16px; background: var(--pop-bg); border: 1px solid var(--surface); box-shadow: var(--shadow-lg); backdrop-filter: blur(24px); -webkit-backdrop-filter: blur(24px); animation: bulk-in 0.18s ease-out; }
.bulk-bar[hidden] { display: none; }
@keyframes bulk-in { from { opacity: 0; translate: 0 8px; } }
.bulk-count { font-size: 13px; color: var(--muted); margin-right: 4px; white-space: nowrap; }
.bulk-count b { color: var(--ink); font-variant-numeric: tabular-nums; }
.bulk-bar .btn { height: 32px; padding: 0 10px; gap: 6px; font-size: 13px; }
.bulk-bar .btn.icon-only { width: 32px; padding: 0; justify-content: center; }
.bulk-bar .btn:disabled { opacity: 0.45; pointer-events: none; }
.bulk-bar .grow { flex: 1; }
.bulk-bar { container-type: inline-size; }
.bulk-pop { position: absolute; left: 0; right: 0; bottom: calc(100% + 8px); max-height: 360px; display: flex; flex-direction: column; gap: 8px; padding: 10px; border-radius: 16px; background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow-lg); }
.bulk-group[hidden] { display: none; }
@container (max-width: 380px) {
  .bulk-bar .lbl { display: none; }
  .bulk-bar [data-bulk-open] { width: 32px; padding: 0; justify-content: center; }
  .bulk-count b { display: inline-flex; align-items: center; justify-content: center; min-width: 26px; height: 26px; padding: 0 7px; border-radius: 9px; background: var(--violet); color: var(--surface); font-size: 12.5px; }
}
.bulk-pop[hidden] { display: none; }
.bulk-pop .nb-filter { padding-left: 12px; }
.bulk-options { overflow-y: auto; display: flex; flex-direction: column; }
.bulk-options .nb-opt[hidden] { display: none; }
.bulk-options .nb-opt:hover { background: var(--accent-soft); }
.bulk-pop-row { display: flex; gap: 8px; }

/* ---- Dragging notes to the sidebar, reordering notebooks and stacks ------------------------- */
.drag-ghost { position: fixed; top: -100px; left: -100px; padding: 6px 12px; border-radius: 10px; background: var(--violet); color: var(--surface); font: 600 13px var(--f-ui); box-shadow: var(--shadow-md); }
body.is-dragging-notes .sb-tag, body.is-dragging-notes [data-drop-action], body.is-dragging-notes [data-drop-notebook] { transition: background 0.12s, box-shadow 0.12s; }
.sb-tag.is-drop-target { background: var(--accent-soft-2); color: var(--violet-deep); box-shadow: inset 0 0 0 1.5px var(--violet); }
.sb-link[data-drop-action].is-drop-target { background: color-mix(in srgb, var(--violet) 30%, transparent); box-shadow: inset 0 0 0 1.5px var(--violet); }
.is-dragged { opacity: 0.4; }
.drop-marker { pointer-events: none; border-radius: 2px; background: var(--violet); box-shadow: 0 0 0 3px color-mix(in srgb, var(--violet) 22%, transparent); }
.drop-marker { height: 3px; margin: 1px 8px; }
.cover-wrap { position: relative; }
.cover-wrap.is-drop-before::before, .cover-wrap.is-drop-after::after { content: ''; position: absolute; top: 4px; bottom: 4px; width: 4px; border-radius: 2px; background: var(--violet); box-shadow: 0 0 0 3px color-mix(in srgb, var(--violet) 22%, transparent); z-index: 3; }
.cover-wrap.is-drop-before::before { left: -10px; }
.cover-wrap.is-drop-after::after { right: -10px; }
.covers.is-drop-into { outline: 2px dashed color-mix(in srgb, var(--violet) 50%, transparent); outline-offset: 6px; border-radius: 14px; }
.stack-list { display: flex; flex-direction: column; gap: 28px; }
.stack-row[draggable="true"] { cursor: grab; }
.order-hint { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 13px; margin: 4px 0 0; }
.order-hint .inline-form { display: inline; margin-left: 4px; }
@media (max-width: 900px) {
  .bulk-bar { position: fixed; left: 10px; right: 10px; bottom: calc(86px + env(safe-area-inset-bottom, 0px)); }
  .bulk-count { flex-basis: 100%; }
}

/* ---- Command palette (nav.js, ⌘P) --------------------------------------------------------- */
dialog.palette { width: min(640px, calc(100vw - 24px)); max-height: min(560px, calc(100vh - 120px)); margin: 12vh auto auto; padding: 0; display: none; flex-direction: column; overflow: hidden;
  border: 1px solid var(--surface); border-radius: 20px; color: var(--ink); background: var(--pop-bg); backdrop-filter: blur(24px); -webkit-backdrop-filter: blur(24px);
  box-shadow: 0 40px 90px color-mix(in srgb, var(--shade) 35%, transparent); }
dialog.palette[open] { display: flex; animation: qc-in 0.16s ease-out; }
dialog.palette::backdrop { background: color-mix(in srgb, var(--shade) 26%, transparent); backdrop-filter: blur(2px); }
.palette-field { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--line); color: var(--muted-2);
  background: linear-gradient(180deg, color-mix(in srgb, var(--tint-top) 80%, transparent), transparent); }
.palette-field input { flex: 1; min-width: 0; border: 0; background: none; outline: none; font: 500 17px var(--f-ui); color: var(--ink); }
.palette-field input::placeholder { color: var(--faint); }
.palette kbd { font: 600 11px var(--f-ui); padding: 2px 6px; border-radius: 6px; background: color-mix(in srgb, var(--ink) 7%, transparent); color: var(--muted-2); }
.palette-list { overflow-y: auto; padding: 6px 8px 8px; flex: 1; }
.palette-group { padding: 10px 10px 4px; font-size: 11px; font-weight: 600; letter-spacing: 1px; text-transform: uppercase; color: var(--muted-2); }
.palette-item { display: flex; align-items: center; gap: 10px; min-height: 40px; padding: 0 10px; border-radius: 10px; cursor: pointer; font-size: 14px; }
.palette-item.is-active { background: var(--accent-soft); }
.palette-item.is-active .palette-title { color: var(--violet-deep); }
.palette-ic { width: 10px; text-align: center; color: var(--faint); font-weight: 700; }
.palette-title { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; color: var(--ink); }
.palette-sub { color: var(--muted-2); font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.palette-item kbd { margin-left: auto; }
.palette-empty { padding: 26px; text-align: center; color: var(--muted); }
.palette-foot { display: flex; gap: 16px; flex-wrap: wrap; padding: 9px 16px; border-top: 1px solid var(--line); font-size: 12px; color: var(--muted-2); }
.palette-foot span { display: inline-flex; align-items: center; gap: 4px; }
@media (max-width: 900px) { dialog.palette { margin-top: 10px; } .palette-foot { display: none; } }

/* ---- Tabs for notes ------------------------------------------------------------------------ */
.note-tabs { display: flex; align-items: center; gap: 4px; overflow-x: auto; scrollbar-width: none; margin: 0 0 -6px; padding: 2px 2px 0; }
.note-tab { position: relative; display: inline-flex; align-items: center; gap: 7px; flex: 0 1 200px; min-width: 96px; height: 34px; padding: 0 6px 0 12px; border-radius: 11px;
  background: var(--glass-2); border: 1px solid transparent; color: var(--muted); text-decoration: none; font-size: 13px; font-weight: 600; }
.note-tab:hover { background: var(--glass); color: var(--ink); }
.note-tab.is-active { background: var(--glass-hover); border-color: var(--glass-border); color: var(--ink); box-shadow: var(--shadow-sm); }
.note-tab-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.note-tab-x { flex: none; width: 22px; height: 22px; border: 0; border-radius: 6px; padding: 0; background: none; color: var(--muted-2); font-size: 16px; line-height: 1; opacity: 0; }
.note-tab:hover .note-tab-x, .note-tab.is-active .note-tab-x, .note-tab-x:focus-visible { opacity: 1; }
.note-tab-x:hover { background: color-mix(in srgb, var(--ink) 8%, transparent); color: var(--ink); }
.note-tab-new { flex: none; width: 30px; height: 30px; border: 0; border-radius: 9px; background: none; color: var(--muted-2); font-size: 18px; }
.note-tab-new:hover { background: var(--glass); color: var(--violet-deep); }
@media (max-width: 900px) { .note-tabs { display: none; } }

/* ---- Split view: a second note beside the first ---------------------------------------------- */
.split-pane { flex: 1 1 480px; min-width: 360px; position: sticky; top: var(--topbar-h); height: calc(100vh - var(--topbar-h)); height: calc(100dvh - var(--topbar-h)); display: flex; flex-direction: column; gap: 8px; padding: 22px 20px 20px 0; }
.split-head { display: flex; align-items: center; gap: 8px; height: 34px; padding: 0 6px 0 12px; border-radius: 11px; background: var(--glass); border: 1px solid var(--glass-border); font: 600 13px var(--f-ui); color: var(--ink); }
.split-head .spine { --c: var(--faint); width: 7px; height: 10px; }
.split-title { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.split-head .grow { flex: 1; }
.split-head .icon-btn { width: 28px; height: 28px; font-size: 15px; }
.split-frame { flex: 1; width: 100%; border: 0; border-radius: 22px; background: transparent; }
.has-split .note-pane { flex: 1 1 480px; padding-right: 12px; }
@media (max-width: 1500px) { .has-split .list-pane, .has-split .resizer-list { display: none; } }
@media (max-width: 900px) { .split-pane { display: none; } }

/* Inside the split view's frame: only the note */
.is-framed body { background: transparent; }
.is-framed body::before { display: none; }
.is-framed .sidebar, .is-framed .topbar-search, .is-framed .topbar-sep, .is-framed .topbar .betsy-dock, .is-framed .list-pane, .is-framed .resizer, .is-framed .tabbar, .is-framed .note-tabs, .is-framed .back-link, .is-framed .betsy-panel, .is-framed .betsy-fab { display: none !important; }
.is-framed .main { margin-left: 0; }
.is-framed .note-pane { padding: 0 2px 20px; }
.is-framed .app { min-height: 0; }
@media (max-width: 900px) { .hide-phone { display: none !important; } }
.is-framed .main-body { display: block; }
.is-framed .topbar { padding: 0 8px; background: transparent; border: 0; backdrop-filter: none; }
.is-framed .note-pane { width: 100%; }
.is-framed body { overflow-x: hidden; }
/* The frame is narrow, so the phone layout applies inside it: keep the sheet's rounded card look. */
.is-framed .sheet { border-radius: 22px; border: 1px solid var(--glass-border); }
.is-framed .main { padding-bottom: 0; }

/* ---- Email this note ---------------------------------------------------------------------- */
.email-body { display: flex; flex-direction: column; gap: 12px; padding: 8px 20px 16px; }
.email-body label:not(.check) { display: flex; flex-direction: column; gap: 6px; font-weight: 600; font-size: 13px; }
.email-body label .muted { font-weight: 400; }
.email-body textarea { resize: vertical; min-height: 70px; font: inherit; padding: 10px 12px; height: auto; }
.email-note { margin: 0; font-size: 12px; }
.note-more .menu .eyebrow { padding: 4px 8px 0; }
.note-more .menu a.menu-pin { text-decoration: none; color: var(--ink); }


/* ---- Betsy, the notes agent ------------------------------------------------------------------ */
/* Yellow = Betsy, violet = you. One drawing (betsy_char) holds every pose; data-state picks what shows.
   Soft 3D: light from the top left, a shaded base, a fold that casts its shadow. prefers-reduced-motion = a still pose. */
.ai-tag { display: inline-block; font: 700 10px/1.4 var(--f-ui); letter-spacing: 0.8px; padding: 1px 6px; border-radius: 5px; background: #FFF4C7; color: #5C4300; vertical-align: 1px; }
.betsy { display: inline-flex; flex: none; width: var(--bz, 36px); height: var(--bz, 36px); }
.betsy svg { display: block; width: 100%; height: 100%; overflow: visible; }
.betsy :is(.bz-ring, .bz-dots, .bz-under, .bz-lens, .bz-lines, .bz-flat, .bz-check) { display: none; }
.betsy .bz-dots circle { fill: #FFC800; }
.betsy :is(.bz-body, .bz-eyes, .bz-eye, .bz-ring, .bz-ground, .bz-check, .bz-dots circle) { transform-box: fill-box; transform-origin: center; }
.betsy .bz-body { transform-origin: 50% 100%; transition: filter 0.3s ease; }
.betsy .bz-eyes { transition: transform 0.24s ease; }
.betsy .bz-eye { animation: bz-blink 5s infinite; }
.betsy[data-state="idle"] .bz-body { animation: bz-breathe 3.2s ease-in-out infinite; }
.betsy[data-state="idle"] .bz-ground { animation: bz-ground 3.2s ease-in-out infinite; }
/* Listening: a ring pings out while she waits for you to finish typing. */
.betsy[data-state="listening"] .bz-ring { display: block; animation: bz-ping 1.8s ease-out infinite; }
.betsy[data-state="listening"] .bz-body { animation: bz-breathe 1.8s ease-in-out infinite; }
.betsy:is([data-state="listening"], [data-state="thinking"]) .bz-eyes { transform: translate(2px, -5px); }
/* Searching: one eye behind a magnifier that sweeps. */
.betsy[data-state="searching"] .bz-eyes { display: none; }
.betsy[data-state="searching"] .bz-lens { display: block; animation: bz-look 2.4s ease-in-out infinite; }
/* Reading: eyes down, lines write themselves on her sheet. */
.betsy[data-state="reading"] .bz-eyes { transform: translateY(5px); }
.betsy[data-state="reading"] :is(.bz-mouth, .bz-cheek) { display: none; }
.betsy[data-state="reading"] .bz-lines { display: block; }
.betsy[data-state="reading"] .bz-lines path { stroke-dasharray: 34; animation: bz-draw 1.8s ease-in-out infinite; }
.betsy[data-state="reading"] .bz-lines path:nth-child(2) { animation-delay: 0.3s; }
/* Thinking: three dots hop above, the note squishes. */
.betsy[data-state="thinking"] .bz-dots { display: block; }
.betsy[data-state="thinking"] .bz-dots circle { animation: bz-hop 1.2s ease-in-out infinite; }
.betsy[data-state="thinking"] .bz-dots circle:nth-child(2) { animation-delay: 0.2s; }
.betsy[data-state="thinking"] .bz-dots circle:nth-child(3) { animation-delay: 0.4s; }
.betsy[data-state="thinking"] .bz-body { animation: bz-squish 1.4s ease-in-out infinite; }
/* Writing: a violet underline draws itself, she wiggles. */
.betsy[data-state="writing"] .bz-under { display: block; stroke-dasharray: 90; animation: bz-underline 1.8s ease-in-out infinite; }
.betsy[data-state="writing"] .bz-body { animation: bz-wiggle 1.8s ease-in-out infinite; }
/* Nothing found: color drains, flat eyes. */
.betsy[data-state="nothing"] .bz-body { filter: saturate(0.12) brightness(0.93); }
.betsy[data-state="nothing"] :is(.bz-eyes, .bz-mouth, .bz-cheek) { display: none; }
.betsy[data-state="nothing"] .bz-flat { display: block; }
/* Checking with you: a coral dot and a small sway while cards wait for your OK. */
.betsy[data-state="checking"] .bz-check { display: block; animation: bz-pulse 1.6s ease-in-out infinite; }
.betsy[data-state="checking"] .bz-body { animation: bz-sway 2.2s ease-in-out infinite; }
@media (prefers-reduced-motion: reduce) {
  .betsy * { animation: none !important; }
  .betsy[data-state="writing"] .bz-under, .betsy[data-state="reading"] .bz-lines path { stroke-dasharray: none; }
}
@keyframes bz-breathe { 0%, 100% { transform: scale(1, 1) translateY(0); } 50% { transform: scale(1.03, 0.97) translateY(-1px); } }
@keyframes bz-ground { 0%, 100% { transform: scaleX(1); opacity: 0.2; } 50% { transform: scaleX(1.06); opacity: 0.26; } }
@keyframes bz-blink { 0%, 46%, 50%, 100% { transform: scaleY(1); } 48% { transform: scaleY(0.08); } }
@keyframes bz-ping { 0% { opacity: 0.9; transform: scale(0.72); } 100% { opacity: 0; transform: scale(1.12); } }
@keyframes bz-look { 0%, 100% { transform: translateX(-9px); } 50% { transform: translateX(4px); } }
@keyframes bz-draw { 0% { stroke-dashoffset: 34; } 60%, 100% { stroke-dashoffset: 0; } }
@keyframes bz-hop { 0%, 100% { transform: translateY(0); } 40% { transform: translateY(-6px); } }
@keyframes bz-squish { 0%, 100% { transform: scale(1, 1); } 45% { transform: scale(1.06, 0.93); } 70% { transform: scale(0.97, 1.04); } }
@keyframes bz-underline { 0% { stroke-dashoffset: 90; } 55%, 100% { stroke-dashoffset: 0; } }
@keyframes bz-wiggle { 0%, 100% { transform: rotate(0); } 30% { transform: rotate(-3deg); } 65% { transform: rotate(2.5deg); } }
@keyframes bz-sway { 0%, 100% { transform: rotate(-4deg); } 50% { transform: rotate(4deg); } }
@keyframes bz-pulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.18); } }

/* Dock: Betsy's button at the right end of the top bar. */
.betsy-dock {
  flex: none; display: flex; align-items: center; gap: 8px; height: 34px; padding: 0 8px 0 4px; border-radius: 10px; text-align: left;
  border: 1px solid transparent; background: light-dark(#FFF7D1, rgba(255, 228, 92, 0.10)); color: var(--ink); transition: background 0.15s, border-color 0.15s, box-shadow 0.15s;
}
.betsy-dock:hover { background: light-dark(#FFF0B0, rgba(255, 228, 92, 0.16)); }
.betsy-dock[aria-expanded="true"], .betsy-dock.is-busy { border-color: rgba(242, 190, 0, 0.55); background: light-dark(#FFEB8A, rgba(255, 228, 92, 0.22)); }
.bd-name { font-weight: 500; font-size: 13px; white-space: nowrap; }
.bd-status { display: none; font-size: 12px; color: var(--muted); white-space: nowrap; max-width: 180px; overflow: hidden; text-overflow: ellipsis; }
.betsy-dock.is-busy .bd-name { display: none; }
.betsy-dock.is-busy .bd-status { display: inline; color: var(--ink-2); }
.betsy-dock kbd { flex: none; font: 11px var(--f-ui); color: var(--muted-2); }
/* Stepped aside while you write: just Betsy, no label. */
.topbar.is-betsy-aside .betsy-dock { padding: 0 4px; background: transparent; }
.topbar.is-betsy-aside .betsy-dock :is(.bd-name, .bd-status, kbd) { display: none; }
.betsy-fab { display: none; }

/* Panel: on the right, under Betsy's button in the top bar. */
.betsy-panel {
  position: fixed; right: 12px; top: calc(var(--topbar-h) + 8px); bottom: 12px; width: 420px; max-width: calc(100vw - var(--sidebar-w) - 24px); z-index: 19;
  display: flex; flex-direction: column; overflow: hidden; border-radius: 20px;
  background: light-dark(rgba(255, 255, 255, 0.86), rgba(36, 30, 68, 0.9)); border: 1px solid var(--glass-border);
  backdrop-filter: blur(18px) saturate(1.2); -webkit-backdrop-filter: blur(18px) saturate(1.2); box-shadow: var(--shadow-lg);
  animation: bp-in 0.24s ease-out both;
}
.betsy-panel[hidden] { display: none; }
@keyframes bp-in { from { opacity: 0; transform: translateX(10px); } }
/* Wide enough for sidebar + panel + list + note: the page moves over. Narrower, the panel floats over the list. */
@media (min-width: 1720px) { body.is-betsy-open .main-body { margin-right: 440px; } }
.bp-head { display: flex; align-items: center; gap: 10px; padding: 14px 14px 12px 16px; border-bottom: 1px solid var(--line); }
.bp-head h2 { margin: 0; font: 600 18px var(--f-display); letter-spacing: -0.3px; }
.bp-head .grow, .bp-scopes .grow { flex: 1; }
.bp-hero, .bp-close-m, .bp-scope-pill { display: none; }
.bp-log { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 14px 16px; display: flex; flex-direction: column; gap: 12px; }
.bp-empty { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; color: var(--ink-2); font-size: 14px; }
.bp-empty p { margin: 0; }
.bp-empty .muted { font-size: 13px; }
.bp-empty .betsy { margin-bottom: 4px; }
.bp-q { align-self: flex-end; max-width: 300px; padding: 10px 14px; border-radius: 16px 16px 4px 16px; background: var(--violet-grad); color: #fff; white-space: pre-wrap; overflow-wrap: anywhere; }
.bp-turn { display: flex; flex-direction: column; gap: 10px; }
.bp-trail { border-radius: 12px; background: var(--glass-2); border: 1px solid var(--line); padding: 8px 12px; font-size: 12.5px; color: var(--muted); }
.bp-trail summary { cursor: pointer; font-weight: 600; color: var(--ink-2); }
.bp-trail ol { list-style: none; margin: 0; padding: 6px 0 0; display: flex; flex-direction: column; gap: 4px; font: 11.5px/1.45 var(--f-mono); overflow-wrap: anywhere; }
.bp-answer { display: flex; gap: 10px; align-items: flex-start; }
.bp-answer .betsy { margin-top: 2px; }
.bp-text { flex: 1; min-width: 0; font: 15px/1.55 var(--f-read); color: var(--prose); display: flex; flex-direction: column; gap: 8px; overflow-wrap: anywhere; }
.bp-text p, .bp-text ul { margin: 0; }
.bp-text ul { padding-left: 20px; }
.bp-text.is-error { font-family: var(--f-ui); font-size: 13.5px; color: var(--danger); }
.bp-text.is-calm { font-family: var(--f-ui); font-size: 14px; color: var(--ink-2); }
.bp-cite { font: 600 11px var(--f-ui); vertical-align: super; line-height: 0; text-decoration: none; padding: 0 3px; color: var(--violet-deep); border-radius: 4px; }
.bp-cite:hover, .bp-cite.is-hot { background: var(--accent-soft-2); color: var(--violet-deep); }
.bp-sources { display: flex; flex-direction: column; gap: 6px; padding-left: 32px; }
.bp-src {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 10px; background: var(--surface-soft); color: var(--ink);
  text-decoration: none; box-shadow: var(--shadow-sm); min-width: 0; outline: 2px solid transparent; outline-offset: -2px; transition: outline-color 0.12s, background 0.12s;
}
.bp-src:hover, .bp-src.is-hot { background: var(--surface); outline-color: var(--violet); color: var(--ink); }
.bp-src .n { font: 600 11px var(--f-ui); color: var(--violet-deep); width: 14px; flex: none; }
.bp-src .t { flex: 1; min-width: 0; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bp-src .d { flex: none; font-size: 12px; color: var(--muted-2); }
.bp-actions { display: flex; flex-wrap: wrap; gap: 6px; padding-left: 32px; }
.bp-chip { padding: 6px 12px; border-radius: 999px; border: 1px solid var(--glass-border); background: var(--glass); color: var(--ink-2); font-size: 13px; }
.bp-chip:hover { background: var(--surface); color: var(--ink); }
.bp-live { display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--muted); }
.bp-live strong { color: var(--ink); }
.bp-form { padding: 12px 14px 14px; border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: 8px; }
.bp-scopes { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.bp-scope, .bp-deep {
  display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px; font-size: 12px; max-width: 170px;
  border: 1px solid color-mix(in srgb, var(--ink) 10%, transparent); background: transparent; color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.bp-scope:hover, .bp-deep:hover { background: var(--glass-hover); }
.bp-scope[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: var(--surface); }
.bp-deep[aria-pressed="true"] { background: var(--accent-soft-2); border-color: transparent; color: var(--violet-deep); font-weight: 600; }
.bp-ask {
  position: relative; display: flex; align-items: flex-end; gap: 8px; padding: 6px 6px 6px 14px; border-radius: 14px; background: var(--surface);
  border: 1px solid color-mix(in srgb, var(--ink) 12%, transparent); transition: box-shadow 0.15s, border-color 0.15s;
}
.bp-ask:focus-within { border-color: color-mix(in srgb, var(--violet) 45%, transparent); box-shadow: 0 0 0 3px rgba(108, 75, 255, 0.14); }
.bp-ask textarea { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; resize: none; padding: 8px 0; max-height: 140px; font-size: 14px; line-height: 1.4; color: var(--ink); }
.bp-ask textarea::placeholder { color: var(--muted-2); }
.bp-send { flex: none; width: 36px; height: 36px; border: 0; border-radius: 10px; background: var(--violet-grad); color: #fff; display: flex; align-items: center; justify-content: center; }
.bp-send:disabled, .bp-ask textarea:disabled { opacity: 0.5; cursor: default; }
.bp-foot { font-size: 11.5px; color: var(--muted-2); }

/* The passage a citation points to, in the open note: highlighter yellow + a violet halo. */
.prose.is-cited .find-hit { background: linear-gradient(transparent 52%, var(--mark-bottom) 52%); box-shadow: none; border-radius: 2px; }
.prose.is-cited .find-hit.is-current { box-shadow: 0 0 0 3px rgba(108, 75, 255, 0.18); }

@media (max-width: 900px) {
  /* Phones: full screen, Betsy big at the top, the conversation on a sheet. */
  .betsy-panel {
    left: 0; top: 0; bottom: 0; width: auto; right: 0; max-width: none; border-radius: 0; border: 0; z-index: 45; box-shadow: none;
    padding-top: env(safe-area-inset-top);
    background: radial-gradient(circle at 90% 0%, var(--glow-coral), transparent 40%), radial-gradient(circle at 20% 100%, var(--glow-violet), transparent 50%), var(--desk);
    animation-name: bp-up;
  }
  @keyframes bp-up { from { opacity: 0; transform: translateY(16px); } }
  body.is-betsy-open { overflow: hidden; }
  .bp-head { border: 0; padding: 12px 16px 4px; }
  .bp-head-char, .bp-head h2, .bp-head > .ai-tag, .bp-close-d, .bp-scopes .bp-scope { display: none; }
  .bp-close-m { display: inline-flex; width: 44px; height: 44px; border-radius: 12px; background: var(--glass); }
  .bp-new { width: 44px; height: 44px; border-radius: 12px; }
  .bp-scope-pill { display: inline-flex; align-items: center; min-height: 36px; padding: 6px 14px; border-radius: 999px; border: 0; background: var(--ink); color: var(--surface); font-size: 12px; max-width: 60vw; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .bp-hero { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 0 0 14px; }
  .bp-hero-name { display: flex; align-items: center; gap: 6px; font: 600 18px var(--f-display); }
  .bp-hero-status { font-size: 12px; color: var(--muted); }
  .bp-log { margin: 0 12px; padding: 16px; border-radius: 20px 20px 0 0; background: light-dark(rgba(255, 255, 255, 0.78), rgba(36, 30, 68, 0.8)); box-shadow: 0 -10px 40px color-mix(in srgb, var(--shade-v) 10%, transparent); }
  .bp-text { font-size: 16px; }
  .bp-src { padding: 12px; }
  .bp-sources, .bp-actions { padding-left: 0; }
  .bp-form { margin: 0 12px; padding: 10px 12px calc(14px + env(safe-area-inset-bottom)); background: var(--pop-bg); border-top: 1px solid var(--line); }
  .bp-scopes { display: none; }
  .bp-foot { display: none; }
  .bp-ask textarea { font-size: 16px; }
  .bp-send { width: 44px; height: 44px; border-radius: 12px; }
  .betsy-fab {
    display: flex; align-items: center; justify-content: center; position: fixed; right: 16px; bottom: calc(92px + env(safe-area-inset-bottom)); z-index: 25;
    width: 52px; height: 52px; padding: 0; border: 1px solid rgba(255, 228, 92, 0.35); border-radius: 16px;
    background: linear-gradient(180deg, #221B44, #0F0B1F); box-shadow: 0 12px 28px color-mix(in srgb, var(--shade-v) 28%, transparent); transition: transform 0.2s ease;
  }
  .has-note.is-typing .betsy-fab, body.is-betsy-open .betsy-fab { transform: translateY(160%); }
}

.betsy-title { display: flex; align-items: center; gap: 8px; }
.betsy-meter { height: 6px; border-radius: 999px; background: color-mix(in srgb, var(--ink) 8%, transparent); overflow: hidden; }
.betsy-meter i { display: block; height: 100%; border-radius: inherit; background: #FFD21F; }

/* ---- Betsy phase 2: proposed changes, saved conversations, editor commands ------------------------ */
.bp-cards { display: flex; flex-direction: column; gap: 8px; padding-left: 32px; }
.bp-card {
  display: flex; flex-direction: column; gap: 8px; padding: 10px 12px; border-radius: 12px; background: var(--surface);
  border: 1px solid color-mix(in srgb, #FF6B4A 35%, transparent); box-shadow: var(--shadow-sm);
}
.bp-card:not(.is-pending) { border-color: var(--line); box-shadow: none; background: var(--surface-soft); }
.bp-card-head { display: flex; flex-direction: column; gap: 2px; }
.bp-card-kind { font: 600 10.5px var(--f-ui); letter-spacing: 0.8px; text-transform: uppercase; color: light-dark(#B23A1E, #FF9C85); }
.bp-card:not(.is-pending) .bp-card-kind { color: var(--muted-2); }
.bp-card-sum { font-weight: 600; color: var(--ink); overflow-wrap: anywhere; }
.bp-card-detail { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); }
.bp-card-detail p { margin: 0; white-space: pre-line; overflow-wrap: anywhere; }
.bp-card-todo { color: var(--ink-2); }
.bp-card-tags { display: flex; flex-wrap: wrap; gap: 6px; }
.bp-tag { padding: 2px 8px; border-radius: 999px; background: color-mix(in srgb, var(--ink) 7%, transparent); color: var(--ink-2); font-size: 12px; } /* tags: never coloured */
.bp-card-foot { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 13px; }
.bp-card-status { font-weight: 600; color: var(--ink-2); }
.bp-card.is-approved .bp-card-status { color: var(--ok); }
.bp-card.is-failed .bp-card-status { color: var(--danger); }
.bp-history { flex: 1; min-height: 0; overflow-y: auto; padding: 14px 16px; display: flex; flex-direction: column; gap: 10px; }
.bp-history[hidden], .bp-log[hidden] { display: none; }
.bp-history-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.bp-history-head h3 { margin: 0; font: 700 15px var(--f-ui); }
.bp-history-rows { display: flex; flex-direction: column; gap: 4px; }
.bp-history-rows p { margin: 0; font-size: 13px; }
.bp-hrow { display: flex; align-items: center; gap: 2px; border-radius: 10px; }
.bp-hrow:hover, .bp-hrow.is-current { background: var(--surface-soft); }
.bp-hopen { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; padding: 8px 10px; border: 0; background: none; text-align: left; border-radius: 10px; }
.bp-hopen .t { font-weight: 600; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bp-hopen .d { font-size: 12px; color: var(--muted-2); }
.bp-hrow .icon-btn { opacity: 0; flex: none; }
.bp-hrow:hover .icon-btn, .bp-hrow:focus-within .icon-btn { opacity: 1; }
.bp-hdel:hover { color: var(--danger); background: var(--danger-soft); }
@media (hover: none) { .bp-hrow .icon-btn { opacity: 0.7; } }

/* Editor: "Ask Betsy" over a selection, then her suggestion under the text. */
.be-bubble {
  position: fixed; z-index: 55; display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 10px 0 6px; border-radius: 10px;
  border: 1px solid rgba(255, 228, 92, 0.45); background: linear-gradient(180deg, #221B44, #0F0B1F); color: #fff; font: 600 12.5px var(--f-ui);
  box-shadow: 0 10px 24px color-mix(in srgb, var(--shade-v) 25%, transparent);
}
.be-bubble[hidden], .be-pop[hidden] { display: none; }
.be-pop {
  position: fixed; z-index: 56; width: min(420px, calc(100vw - 16px)); max-height: min(70vh, 560px); overflow: auto; display: flex; flex-direction: column; gap: 10px;
  padding: 12px; border-radius: 16px; background: var(--pop-bg); border: 1px solid var(--glass-border); box-shadow: var(--shadow-lg);
}
.be-head { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.be-menu { display: flex; flex-direction: column; gap: 2px; }
.be-menu button { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; padding: 8px 10px; border: 0; border-radius: 9px; background: none; text-align: left; font-weight: 600; color: var(--ink); }
.be-menu button .muted { font-weight: 400; font-size: 12px; }
.be-menu button:hover, .be-menu button:focus-visible { background: var(--accent-soft); outline: none; }
.be-ask .input { height: 36px; font-size: 13px; }
.be-wait { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 13px; padding: 4px 2px; }
.be-preview { font-size: 15px; padding: 10px 12px; border-radius: 10px; background: light-dark(#FFFBE6, rgba(255, 228, 92, 0.08)); border: 1px dashed color-mix(in srgb, #F2BE00 55%, transparent); min-height: 0; }
.be-preview > :last-child { margin-bottom: 0; }
.be-foot { display: flex; align-items: center; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
.be-error { margin: 0; color: var(--danger); font-size: 13px; margin-right: auto; }
.be-preview ul[data-type="taskList"] { list-style: none; padding-left: 4px; }
.be-preview li[data-type="taskItem"] { display: flex; gap: 8px; }
.be-preview li[data-type="taskItem"]::before { content: '☐'; color: var(--muted-2); }
.be-preview li[data-type="taskItem"] p { margin: 0 0 4px; }

/* ---- Empty states (partials/empty-state.php) ------------------------------------------------ */
.empty-state { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 8px; padding: 36px 24px; max-width: 460px; margin: 0 auto; }
.es-art { position: relative; width: 96px; height: 84px; margin-bottom: 10px; }
.es-book {
  position: absolute; left: 10px; top: 6px; width: 50px; height: 66px; border-radius: 4px 9px 9px 4px; transform: rotate(-9deg);
  background: linear-gradient(150deg, color-mix(in srgb, var(--c) 88%, #fff), color-mix(in srgb, var(--c) 85%, #000));
  box-shadow: inset 7px 0 0 color-mix(in srgb, var(--c) 55%, #000), 0 8px 18px color-mix(in srgb, var(--c) 30%, transparent);
}
.es-sheet {
  position: absolute; left: 38px; top: 14px; width: 46px; height: 60px; border-radius: 7px; transform: rotate(5deg);
  display: flex; flex-direction: column; gap: 6px; padding: 11px 8px; background: var(--surface);
  box-shadow: 0 0 0 1px var(--line), 0 10px 22px color-mix(in srgb, var(--shade-v) 14%, transparent);
}
.es-sheet i { display: block; height: 4px; border-radius: 2px; background: var(--faint); }
.es-sheet i:first-child { width: 60%; background: var(--violet); }
.es-sheet i:nth-child(3) { width: 75%; }
.es-badge {
  position: absolute; right: 0; bottom: 0; width: 32px; height: 32px; border-radius: 10px; display: flex; align-items: center; justify-content: center;
  background: #FFE45C; color: #17132B; box-shadow: 0 0 0 2px var(--surface), 0 6px 14px color-mix(in srgb, var(--shade-v) 18%, transparent); transform: rotate(-6deg);
}
.es-title { margin: 0; font-family: var(--f-display); font-weight: 600; font-size: 20px; letter-spacing: -0.4px; color: var(--ink); }
.es-text { margin: 0; max-width: 360px; font-size: 14px; line-height: 1.5; color: var(--muted); }
.es-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-top: 10px; }
.es-actions form { display: contents; }
.es-actions .btn { gap: 6px; }
.es-hints { margin: 14px 0 0; display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 6px 8px; font-size: 12px; color: var(--muted-2); }
.es-hints kbd, .note-start kbd, .ctx-ghost kbd { font: 11px var(--f-ui); padding: 1px 6px; border-radius: 5px; border: 1px solid color-mix(in srgb, var(--ink) 14%, transparent); background: var(--surface); color: var(--ink-2); }
.es-hints .dot { width: 3px; height: 3px; border-radius: 50%; background: var(--faint); }
/* In the note area when a list is empty: centred on a dashed sheet. */
.note-pane-empty { align-self: stretch; }
.note-pane-empty .empty-state { margin: 0; max-width: none; flex: 1; justify-content: center; min-height: min(70vh, 620px); border-radius: 22px; border: 2px dashed color-mix(in srgb, var(--violet) 16%, transparent); background: color-mix(in srgb, var(--surface) 35%, transparent); }
.list-empty { margin: 8px 4px; font-size: 13px; color: var(--muted-2); }
.es-card { max-width: none; padding: 28px 20px; border-radius: 18px; border: 2px dashed color-mix(in srgb, var(--violet) 16%, transparent); }
@media (max-width: 900px) {
  .list-empty { display: none; }
  .note-pane-empty { padding: 0 14px 24px; }
  .note-pane-empty .empty-state { min-height: 0; padding: 28px 18px; }
  .es-hints { display: none; }
}

/* Empty note: tips under the editor until the first word. */
.note-start { margin: 4px 0 0; display: flex; flex-wrap: wrap; gap: 6px 18px; font-size: 12.5px; color: var(--muted-2); }
.note-start[hidden] { display: none; }
.note-start span { display: inline-flex; align-items: center; gap: 6px; }

/* Empty Context: the three sources as dashed tiles; two of them start a link or a tag. */
.ctx-empty { display: flex; flex-direction: column; gap: 10px; }
.ctx-empty[hidden] { display: none; }
.ctx-empty-lead { margin: 0; font-size: 13.5px; color: var(--muted); }
.ctx-empty-lead strong { color: var(--ink); font-weight: 600; }
.ctx-empty-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 10px; }
.ctx-ghost {
  display: flex; flex-direction: column; align-items: flex-start; gap: 6px; padding: 12px 14px; border-radius: 14px; text-align: left; font: inherit;
  border: 1.5px dashed color-mix(in srgb, var(--ink) 14%, transparent); background: transparent; color: var(--ink); cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.ctx-ghost:hover:not(.is-passive) { border-color: color-mix(in srgb, var(--violet) 50%, transparent); background: var(--accent-soft); }
.ctx-ghost.is-passive { cursor: default; }
.ctx-ghost-ic { width: 28px; height: 28px; border-radius: 8px; display: flex; align-items: center; justify-content: center; background: var(--accent-soft); color: var(--violet-deep); }
.ctx-ghost .t { font-weight: 600; font-size: 14px; }
.ctx-ghost .why { font-size: 12.5px; line-height: 1.45; color: var(--muted); }
.context-box[hidden] { display: none; }
.note-col:has(.note-start:not([hidden])) .prose { min-height: 90px; }
/* ---- Settings: two panes. Left, the sections; right, one section at a time (picked by the URL hash, no JS). ---- */
.settings-page { max-width: 1100px; }
.settings-layout { display: grid; grid-template-columns: 236px minmax(0, 1fr); gap: 28px; align-items: start; }
.settings-nav { position: sticky; top: calc(var(--topbar-h) + 20px); display: flex; flex-direction: column; gap: 16px; }
.sn-group { display: flex; flex-direction: column; gap: 1px; }
.sn-label { padding: 0 10px 4px; font-size: 11px; font-weight: 500; letter-spacing: 0.6px; text-transform: uppercase; color: var(--muted-2); }
.sn-link { display: flex; align-items: center; gap: 10px; min-height: 34px; padding: 6px 10px; border-radius: 9px; color: var(--ink-2); text-decoration: none; font-size: 14px; }
.sn-link:hover { background: color-mix(in srgb, var(--ink) 5%, transparent); color: var(--ink); }
.sn-ic { flex: none; width: 20px; display: inline-flex; justify-content: center; color: var(--muted-2); }
.sn-text { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sn-badge { flex: none; font-size: 11px; font-weight: 500; padding: 1px 7px; border-radius: 999px; }
.sn-badge.is-warn { background: var(--due-today-bg); color: var(--due-today); }
.sn-badge.is-muted { background: color-mix(in srgb, var(--ink) 6%, transparent); color: var(--muted-2); }
.sn-link.is-current,
.settings-layout:not(:has(.settings-pane:target)) [data-sn="profile"]:not(.settings-nav:has(.is-current) *),
.settings-layout:has(#profile:target) [data-sn="profile"],
.settings-layout:has(#appearance:target) [data-sn="appearance"],
.settings-layout:has(#account:target) [data-sn="account"],
.settings-layout:has(#templates:target) [data-sn="templates"],
.settings-layout:has(#calendar:target) [data-sn="calendar"],
.settings-layout:has(#betsy:target) [data-sn="betsy"],
.settings-layout:has(#email:target) [data-sn="email"],
.settings-layout:has(#backups:target) [data-sn="backups"],
.settings-layout:has(#server:target) [data-sn="server"] {
  background: var(--surface); color: var(--ink); font-weight: 500; box-shadow: 0 0 0 1px var(--line), var(--shadow-sm);
}
.sn-link.is-current .sn-ic, .settings-layout:has(.settings-pane:target) .sn-link:hover .sn-ic { color: var(--violet-deep); }
.settings-panes { min-width: 0; display: flex; flex-direction: column; gap: 16px; }
.settings-panes:not(.is-static) > .settings-pane { display: none; scroll-margin-top: 100vh; }
.settings-panes:not(.is-static) > .settings-pane:target,
.settings-panes:not(:has(.settings-pane:target)) > .settings-pane:first-of-type { display: flex; }
.settings-pane > h2 { font-size: 20px; letter-spacing: -0.5px; }
.settings-pane-title { margin: 0; font-family: var(--f-display); font-weight: 600; font-size: 20px; letter-spacing: -0.5px; }
@media (max-width: 900px) {
  .settings-layout { grid-template-columns: 1fr; gap: 14px; }
  .settings-nav { position: static; flex-direction: row; gap: 4px; overflow-x: auto; scrollbar-width: none; margin: 0 -14px; padding: 2px 14px 6px; }
  .sn-group { flex-direction: row; gap: 4px; }
  .sn-label { display: none; }
  .sn-link { flex: none; }
}

/* Settings → API & apps */
.api-new { display: flex; flex-direction: column; gap: 6px; padding: 12px 14px; border-radius: 12px; background: var(--surface-soft); box-shadow: var(--shadow-sm); font-size: 13px; }
.api-secret { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.api-secret code { flex: 1 1 280px; font-family: var(--f-mono); font-size: 12.5px; padding: 8px 10px; border-radius: 8px; background: var(--surface); word-break: break-all; user-select: all; }
.api-tokens .api-hint { font-family: var(--f-mono); font-weight: 400; font-size: 12px; }
.api-tokens .api-used { font-size: 12px; }
.api-tokens .is-off { opacity: 0.55; }

/* ---- Home → Today: the day from Google Calendar (calendar.js) ---------------------------------- */
.day-nav { margin-left: auto; display: inline-flex; align-items: center; gap: 2px; }
.day-nav .icon-btn { width: 28px; height: 28px; }
.day-timeline { gap: 2px; padding: 8px; min-height: 64px; }
.day-skel { display: flex; flex-direction: column; gap: 8px; padding: 6px; }
.day-skel i { display: block; height: 34px; border-radius: 10px; background: color-mix(in srgb, var(--ink) 5%, transparent); animation: day-pulse 1.2s ease-in-out infinite; }
.day-skel i:nth-child(2) { width: 82%; animation-delay: 0.15s; } .day-skel i:nth-child(3) { width: 64%; animation-delay: 0.3s; }
@keyframes day-pulse { 50% { opacity: 0.45; } }
.day-empty { margin: 0; padding: 10px 8px; font-size: 13px; }
.day-error { color: var(--danger); }
.day-allday { display: flex; flex-direction: column; gap: 4px; padding-bottom: 6px; margin-bottom: 4px; border-bottom: 1px solid var(--line); }
.day-chip { --c: var(--violet); display: flex; align-items: center; gap: 8px; padding: 5px 6px 5px 10px; border-radius: 9px; font-size: 13px; font-weight: 600;
  background: color-mix(in srgb, var(--c) 13%, transparent); border-left: 3px solid var(--c); }
.day-chip-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.day-ev { --c: var(--violet); display: grid; grid-template-columns: 58px 3px minmax(0, 1fr) auto; align-items: start; column-gap: 10px; padding: 8px 6px; border-radius: 10px; }
.day-ev:hover { background: var(--surface-soft); }
.day-time { display: flex; flex-direction: column; font-size: 12px; font-weight: 600; line-height: 1.35; text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.day-time .muted { font-weight: 400; color: var(--muted-2); }
.day-bar { align-self: stretch; border-radius: 3px; background: var(--c); min-height: 30px; }
.day-body { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.day-title { font-weight: 600; line-height: 1.3; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.day-title a { color: var(--ink); text-decoration: none; }
.day-title a:hover { text-decoration: underline; }
.day-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; font-size: 12px; color: var(--muted); min-width: 0; }
.day-meta > * { display: inline-flex; align-items: center; gap: 4px; min-width: 0; max-width: 100%; }
.day-meta svg { flex: none; color: var(--muted-2); }
.day-where, .day-who { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.day-join { font-weight: 600; color: var(--violet-deep); text-decoration: none; }
.day-join svg { color: currentColor; }
.day-note { height: 28px !important; padding: 0 9px !important; gap: 5px; border-radius: 8px; font-size: 12px; white-space: nowrap; opacity: 0.8; }
.day-ev:hover .day-note, .day-chip:hover .day-note, .day-note:focus-visible, .day-note.has-note { opacity: 1; }
.day-note.has-note { color: var(--violet-deep); background: var(--accent-soft); border-color: transparent; }
.day-note.is-small { height: 24px !important; }
.day-ev.is-past { opacity: 0.55; }
.day-ev.is-past:hover { opacity: 1; }
.day-ev.is-live { background: color-mix(in srgb, var(--c) 9%, transparent); }
.day-ev.is-declined .day-title { text-decoration: line-through; color: var(--muted); }
.day-now-tag { display: inline-block; margin-right: 6px; padding: 1px 6px; border-radius: 5px; font-size: 10.5px; font-weight: 700; letter-spacing: 0.3px; text-transform: uppercase; color: #fff; background: var(--coral); vertical-align: 1px; }
.day-nowline { position: relative; height: 0; margin: 4px 0 4px 64px; border-top: 2px solid var(--coral); }
.day-nowline::before { content: ""; position: absolute; left: -5px; top: -6px; width: 10px; height: 10px; border-radius: 50%; background: var(--coral); }
.day-nowline span { position: absolute; right: 0; top: -9px; padding: 0 6px; border-radius: 6px; font-size: 10.5px; font-weight: 700; color: var(--coral); background: var(--surface); }
.day-connect { flex-direction: row; align-items: center; gap: 12px; padding: 14px 16px; text-decoration: none; color: var(--ink); }
.day-connect:hover { background: var(--surface-soft); color: var(--ink); }
.day-connect > svg { flex: none; color: var(--violet); }
.day-connect > span { display: flex; flex-direction: column; gap: 2px; font-size: 13px; }

/* ---- Settings → Calendar ---------------------------------------------------------------------- */
.cal-account { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 12px; background: var(--surface-soft); }
.cal-account form { margin: 0; }
.cal-account .grow { flex: 1; }
.cal-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--mint); box-shadow: 0 0 0 3px color-mix(in srgb, var(--mint) 25%, transparent); }
.cal-choose { display: flex; flex-direction: column; gap: 8px; }
.cal-choose .check { display: flex; align-items: center; gap: 8px; }
.cal-swatch { width: 10px; height: 10px; border-radius: 3px; background: var(--c); }
.cal-setup ol { margin: 8px 0 0; padding-left: 20px; display: flex; flex-direction: column; gap: 6px; font-size: 13px; }
.cal-setup code { word-break: break-all; }

/* ---- Settings → Notes & templates ------------------------------------------------------------- */
.tpl-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 6px; }
.tpl-head h3 { margin: 0; font-size: 15px; }
.tpl-list .name { flex: 0 1 auto; color: var(--ink); text-decoration: none; }
.tpl-list .name:hover { text-decoration: underline; }
.tpl-list .grow { flex: 1; }
.tpl-badge { flex: none; font-size: 11px; font-weight: 600; padding: 2px 7px; border-radius: 999px; color: var(--muted); background: color-mix(in srgb, var(--ink) 6%, transparent); white-space: nowrap; }
.tpl-crumbs { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }
.tpl-crumbs a { text-decoration: none; }
.tpl-edit-layout { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 16px; align-items: start; }
.tpl-picker { gap: 2px; padding: 8px; position: sticky; top: calc(var(--topbar-h) + 16px); }
.tpl-pick { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-radius: 9px; color: var(--ink); text-decoration: none; font-size: 13px; }
.tpl-pick .name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.tpl-pick:hover { background: var(--surface-soft); color: var(--ink); }
.tpl-pick.is-current { background: var(--accent-soft); color: var(--violet-deep); }
.tpl-pick-new { color: var(--violet-deep); font-weight: 600; margin-top: 4px; }
.tpl-form { gap: 14px; }
.tpl-fields { display: grid; grid-template-columns: 1fr 1.4fr; gap: 12px; }
.tpl-fields label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); }
.tpl-sheet { border-radius: 14px; border: 1px solid var(--line); background: var(--surface); overflow: clip; box-shadow: var(--shadow-sm); }
.tpl-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 2px; padding: 6px 10px; border-bottom: 1px solid var(--line); background: var(--surface-soft); }
.tpl-bar .sep { width: 1px; height: 18px; background: var(--line); margin: 0 4px; }
.tpl-bar .grow { flex: 1; }
.tpl-bar .text-btn { font-weight: 700; font-size: 13px; }
.tpl-editor { padding: 18px 22px 22px; min-height: 260px; }
.tpl-vars { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-size: 12px; }
.tpl-vars .chip { font: 500 12px var(--f-mono); padding: 4px 8px; }
.tpl-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.tpl-actions .grow { flex: 1; }
@media (max-width: 900px) {
  .tpl-edit-layout { grid-template-columns: 1fr; }
  .tpl-picker { position: static; flex-direction: row; flex-wrap: wrap; }
  .tpl-fields { grid-template-columns: 1fr; }
  .tpl-editor { padding: 14px; }
}
.day-nav [hidden] { display: none; }

/* ---- Settings → Security (two-step sign-in, new-device emails, sessions) ---- */
.sec-block { display: flex; flex-direction: column; gap: 10px; padding-top: 14px; border-top: 1px solid var(--glass-border); }
.sec-block:first-of-type { border-top: 0; padding-top: 0; }
.sec-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.sec-head h3 { margin: 0; flex: 1; }
.sec-head form { margin: 0; }
.sec-text { margin: 0; font-size: 14px; color: var(--ink-2); line-height: 1.5; }
.sec-text .error-text { display: block; margin-top: 4px; }
.chip.is-ok { color: var(--ok); background: color-mix(in srgb, var(--ok) 12%, transparent); border-color: transparent; font-weight: 600; }
.sec-toggle { display: flex; align-items: flex-start; gap: 14px; margin: 0; }
.sec-toggle .sec-text { flex: 1; }
.sec-steps { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 14px; font-size: 14px; color: var(--ink-2); }
.sec-steps li::marker { font-weight: 600; color: var(--violet); }
.sec-steps .form-row { margin-top: 8px; }
.sec-qr-row { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; margin-top: 10px; }
.sec-qr { width: 176px; height: 176px; padding: 10px; border-radius: 14px; background: #fff; box-shadow: var(--shadow-sm); flex: none; }
.sec-qr svg { display: block; width: 100%; height: 100%; }
.sec-secret { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; min-width: 0; flex: 1 1 220px; }
.sec-secret code { font-family: var(--f-mono); font-size: 14px; letter-spacing: 1px; padding: 8px 10px; border-radius: 8px; background: var(--surface); user-select: all; word-break: break-all; }
.sec-codes .sec-code-list { margin: 4px 0; padding: 0; list-style: none; display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 6px; }
.sec-code-list code { font-family: var(--f-mono); font-size: 14px; padding: 4px 8px; border-radius: 6px; background: var(--surface); display: inline-block; }
.sec-session { align-items: center; padding: 10px; }
.sec-session.is-current { background: var(--surface-soft); }
.sec-session .name { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.sec-meta { font-weight: 400; font-size: 12.5px; overflow-wrap: anywhere; }
.sec-ic { color: var(--muted-2); display: inline-flex; }
@media (max-width: 640px) {
  .sec-session { flex-wrap: wrap; }
  .sec-session .name { flex: 1 1 calc(100% - 40px); }
  .sec-toggle { flex-direction: column; }
}
