/* ============================================================
   Ospaces — UI/UX polish layer  (loaded LAST, wins cascade ties)
   ------------------------------------------------------------
   A self-contained refinement pass over the CORE chrome only
   (login · sidebar · topbar · page · library · modals · toast).
   Feature stylesheets use namespaced classes, so nothing here
   reaches into them. Everything reuses existing tokens, so light
   & dark both track automatically. Fully additive / reversible.
   ============================================================ */

/* smoother interaction feel everywhere without touching layout */
:root {
  --ease-out: cubic-bezier(0.22, 0.61, 0.36, 1);
  --lift: 0 1px 2px rgba(20, 22, 43, 0.06), 0 6px 20px rgba(20, 22, 43, 0.1);
}
html[data-theme="dark"] { --lift: 0 1px 2px rgba(0, 0, 0, 0.4), 0 8px 24px rgba(0, 0, 0, 0.5); }

/* crisper thin scrollbars that fade toward the track */
::-webkit-scrollbar { width: 11px; height: 11px; }
::-webkit-scrollbar-thumb { border-radius: 6px; transition: background 0.2s; }
*:hover::-webkit-scrollbar-thumb { background: var(--border-strong); border: 3px solid transparent; background-clip: content-box; }

/* ============================================================
   Login — add quiet depth + a signature floating product card
   ============================================================ */
/* faint engineered dot-grid behind the brand story (uniqueness, not noise) */
.login-brand::before {
  content: ""; position: absolute; inset: 0; z-index: 0; pointer-events: none;
  background-image: radial-gradient(rgba(255, 255, 255, 0.14) 1px, transparent 1.4px);
  background-size: 26px 26px;
  -webkit-mask-image: radial-gradient(120% 80% at 20% 30%, #000 30%, transparent 78%);
          mask-image: radial-gradient(120% 80% at 20% 30%, #000 30%, transparent 78%);
  opacity: 0.6;
}
.login-brand-list li { transition: transform 0.2s var(--ease-out); }
.login-brand-list li:hover { transform: translateX(3px); }

/* the primary CTA gets a confident, tactile press */
.login-btn.primary { transition: background 0.15s, box-shadow 0.2s, transform 0.08s var(--ease-out); }
.login-btn.primary:active { transform: translateY(0) scale(0.99); }
.login-input { transition: border-color 0.15s, box-shadow 0.2s, background 0.15s; }

/* ============================================================
   Sidebar — sharper primary action, calmer rhythm
   ============================================================ */
/* workspace mark: subtle interactive affordance */
.sb-workspace { transition: background 0.14s; cursor: default; }
.sb-logo { box-shadow: 0 2px 8px rgba(61, 63, 184, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.22); }

/* THE create action — a crisp iris chip that clearly reads as primary */
.sb-action-primary {
  background: linear-gradient(180deg, color-mix(in srgb, var(--accent) 88%, #ffffff 12%), var(--accent));
  color: #fff; font-weight: 600;
  box-shadow: 0 1px 2px rgba(8, 9, 22, 0.28), 0 6px 16px rgba(82, 82, 205, 0.34),
              inset 0 1px 0 rgba(255, 255, 255, 0.2);
  transition: filter 0.14s, transform 0.08s var(--ease-out), box-shadow 0.18s;
}
.sb-action-primary .sb-action-icon { color: rgba(255, 255, 255, 0.92); }
.sb-action-primary:hover { background: linear-gradient(180deg, color-mix(in srgb, var(--accent) 82%, #ffffff 18%), var(--accent)); color: #fff; filter: brightness(1.03); box-shadow: 0 1px 2px rgba(8, 9, 22, 0.3), 0 8px 22px rgba(82, 82, 205, 0.44), inset 0 1px 0 rgba(255, 255, 255, 0.24); }
.sb-action-primary:hover .sb-action-icon { color: #fff; }
.sb-action-primary:active { transform: scale(0.985); }

/* nav rows: a touch more travel + a soft active seat */
.sb-action { transition: background 0.14s, color 0.14s; }
.sb-action.active { box-shadow: inset 2px 0 0 var(--accent-soft); }

/* keycap hints read as real keys */
.sb-kbd { background: rgba(255, 255, 255, 0.06); border-color: rgba(255, 255, 255, 0.14); box-shadow: inset 0 -1px 0 rgba(0, 0, 0, 0.25); }

/* footer user chip: gentle hover so it feels clickable-adjacent */
.sb-user { border-radius: 9px; transition: background 0.14s; }
.sb-user-av { box-shadow: 0 1px 4px rgba(61, 63, 184, 0.4); }

/* ============================================================
   Topbar — layered elevation on scroll (via .topbar-scrolled)
   ============================================================ */
#topbar {
  position: relative; z-index: 6;
  transition: box-shadow 0.22s var(--ease-out), background 0.22s;
}
#topbar::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 1px;
  background: var(--border); opacity: 0; transition: opacity 0.22s;
}
#main.topbar-scrolled #topbar::after { opacity: 1; }
#main.topbar-scrolled #topbar {
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  -webkit-backdrop-filter: saturate(1.4) blur(8px);
          backdrop-filter: saturate(1.4) blur(8px);
  box-shadow: 0 4px 16px rgba(20, 22, 43, 0.05);
}
html[data-theme="dark"] #main.topbar-scrolled #topbar { box-shadow: 0 4px 18px rgba(0, 0, 0, 0.4); }

/* topbar controls: uniform tactile hover */
.topbar-btn, .icon-btn { transition: background 0.14s, color 0.14s, transform 0.08s var(--ease-out); }
.topbar-btn:active, .icon-btn:active { transform: scale(0.94); }

/* Share reads as the distinct primary topbar action */
#btn-share {
  border: 1px solid var(--border-strong); border-radius: 8px;
  color: var(--text); font-weight: 600; padding: 5px 13px;
}
#btn-share:hover { background: var(--bg-hover); border-color: var(--accent-soft); color: var(--accent); }
html[data-theme="dark"] #btn-share:hover { color: var(--accent-soft); }

#btn-share { margin-left: 4px; }

/* reading-meta chip injected by ui-polish.js */
#reading-meta {
  display: none; align-items: center; gap: 6px; margin-right: 8px;
  font-size: 11.5px; font-weight: 500; color: var(--text-faint);
  font-family: var(--font-display); letter-spacing: 0.2px; white-space: nowrap;
  animation: rm-in 0.2s var(--ease-out) both;
}
#reading-meta.show { display: inline-flex; }
#reading-meta .rm-dot { width: 3px; height: 3px; border-radius: 50%; background: currentColor; opacity: 0.5; }
@keyframes rm-in { from { opacity: 0; } }
/* reading meta is a desktop-reading nicety — reclaim topbar space on phones */
@media (max-width: 700px) { #reading-meta.show { display: none; } }

/* live save pulse */
#save-indicator.saving::before {
  content: ""; display: inline-block; width: 6px; height: 6px; border-radius: 50%;
  background: var(--star); margin-right: 6px; vertical-align: middle;
  animation: save-pulse 1s ease-in-out infinite;
}
@keyframes save-pulse { 50% { opacity: 0.35; } }

/* ============================================================
   Page — kinder empty title, comfortable head
   ============================================================ */
#page-title { transition: color 0.14s; }
#page-head-actions button { transition: background 0.14s, color 0.14s; border-radius: 7px; }

/* the "no page open" empty state feels intentional, not blank */
#empty-state .empty-inner { animation: view-in 0.24s var(--ease-out) both; }
.empty-logo { box-shadow: 0 10px 30px rgba(61, 63, 184, 0.3); opacity: 0.9; }
.empty-inner p { color: var(--text-light); }
.empty-inner .login-btn.primary { box-shadow: 0 3px 10px rgba(91, 91, 214, 0.32); }

/* ============================================================
   Library — livelier rows, clearer hierarchy
   ============================================================ */
#library-view { animation: view-in 0.2s var(--ease-out) both; }
.lib-title { position: relative; }
/* subtle accent seat under the H1 */
.lib-title::after {
  content: ""; position: absolute; left: 2px; bottom: -8px;
  width: 42px; height: 3px; border-radius: 3px;
  background: linear-gradient(90deg, var(--accent), var(--accent-soft));
  opacity: 0.9;
}
.lib-item { transition: background 0.13s, box-shadow 0.13s; }
.lib-item:hover { box-shadow: inset 2px 0 0 var(--accent-soft); }
.lib-p-icon, .lib-twist { transition: color 0.13s, transform 0.13s; }
.lib-newpage, .lib-templates-btn { transition: background 0.14s, box-shadow 0.16s, border-color 0.14s, transform 0.08s var(--ease-out); }
.lib-newpage:active, .lib-templates-btn:active { transform: scale(0.98); }
.lib-search { transition: border-color 0.14s, width 0.16s var(--ease-out), background 0.14s; }
.lib-tab { transition: color 0.14s; position: relative; }

/* ============================================================
   Home hero — greeting, quick actions, jump-back-in
   ============================================================ */
#home-hero { margin-bottom: 30px; animation: view-in 0.22s var(--ease-out) both; }
.hh-top { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; flex-wrap: wrap; margin-bottom: 26px; }
.hh-greet { min-width: 0; }
.hh-hello {
  font-family: var(--font-display); font-weight: 700; letter-spacing: -0.6px;
  font-size: clamp(24px, 3vw, 32px); color: var(--text); line-height: 1.1;
}
.hh-date { font-size: 14px; color: var(--text-faint); margin-top: 6px; font-family: var(--font-display); }
.hh-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.hh-chip {
  display: inline-flex; align-items: center; gap: 7px; padding: 8px 13px;
  font-size: 13px; font-weight: 600; color: var(--text-light);
  border: 1px solid var(--border); border-radius: 9px; background: var(--bg);
  transition: background 0.14s, color 0.14s, border-color 0.14s, transform 0.08s var(--ease-out), box-shadow 0.16s;
}
.hh-chip .ic { color: var(--text-faint); transition: color 0.14s; }
.hh-chip:hover { background: var(--bg-hover); color: var(--text); border-color: var(--border-strong); }
.hh-chip:hover .ic { color: var(--text-light); }
.hh-chip:active { transform: scale(0.97); }
.hh-chip-primary {
  color: #fff; border-color: transparent;
  background: linear-gradient(180deg, color-mix(in srgb, var(--accent) 88%, #fff 12%), var(--accent));
  box-shadow: 0 2px 6px rgba(91, 91, 214, 0.28), inset 0 1px 0 rgba(255, 255, 255, 0.2);
}
.hh-chip-primary .ic { color: rgba(255, 255, 255, 0.9); }
.hh-chip-primary:hover { color: #fff; filter: brightness(1.04); box-shadow: 0 4px 12px rgba(91, 91, 214, 0.4); }
.hh-chip-primary:hover .ic { color: #fff; }

.hh-recents-label {
  font-family: var(--font-display); font-size: 11px; font-weight: 600; color: var(--text-faint);
  text-transform: uppercase; letter-spacing: 0.7px; margin-bottom: 10px;
}
.hh-recents { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 10px; }
.hh-card {
  display: flex; flex-direction: column; align-items: flex-start; gap: 4px; text-align: left;
  padding: 14px 15px; border: 1px solid var(--border); border-radius: 12px; background: var(--card, var(--bg));
  min-height: 92px; transition: border-color 0.14s, box-shadow 0.16s, transform 0.1s var(--ease-out);
}
.hh-card:hover { border-color: var(--accent-soft); transform: translateY(-2px); box-shadow: 0 8px 20px rgba(20, 22, 43, 0.09); }
.hh-card-ic { font-size: 20px; line-height: 1; margin-bottom: 4px; }
.hh-card-ic .ic { color: var(--text-faint); }
.hh-card-title { font-family: var(--font-display); font-weight: 600; font-size: 14px; color: var(--text); line-height: 1.3;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.hh-card-time { font-size: 11.5px; color: var(--text-faint); margin-top: auto; }
@media (max-width: 720px) {
  .hh-top { margin-bottom: 20px; }
  .hh-recents { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
}

/* ============================================================
   Modals / popovers / cards — consistent tactility
   ============================================================ */
.tpl-card { transition: border-color 0.14s, box-shadow 0.16s, transform 0.1s var(--ease-out); }
.tpl-card:hover { transform: translateY(-2px); }
.menu-item { transition: background 0.1s; }
.settings-nav-item, .settings-seg button { transition: background 0.12s, color 0.12s; }
.result-item { transition: background 0.1s; }

/* command-palette input feels a touch more premium */
.modal-search-input { font-family: var(--font-display); letter-spacing: 0.1px; }

/* ============================================================
   Toast — brand-tinted edge, slight rise on show
   ============================================================ */
#toast { box-shadow: 0 0 0 1px rgba(143, 143, 243, 0.16), 0 12px 34px rgba(4, 5, 16, 0.55); }

/* ============================================================
   Accessibility — skip link, stronger focus, reduced contrast opt
   ============================================================ */
.skip-link {
  position: fixed; top: -60px; left: 12px; z-index: 400;
  background: var(--accent); color: #fff; font-size: 13.5px; font-weight: 600;
  padding: 9px 16px; border-radius: 9px; text-decoration: none;
  box-shadow: 0 6px 18px rgba(91, 91, 214, 0.4);
  transition: top 0.16s var(--ease-out);
}
.skip-link:focus { top: 12px; outline: 2px solid #fff; outline-offset: 2px; }
#page-scroll:focus { outline: none; }
/* a11y (ui-polish.js): the dialog is focused only as a last-resort trap
   target (tabindex=-1) — no ring unless it's genuine keyboard focus. Palette
   options get a clear keyboard ring. All scoped to #modal-layer + focus-visible. */
#modal-layer .modal:focus { outline: none; }
#modal-layer .modal:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
#modal-layer .result-item:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }

/* ---- visible focus ring EVERYWHERE focus can land ----
   :focus-visible only, so pointer users never see a ring; outline draws
   outside the box model, so nothing here can move a pixel of layout.
   contenteditable is deliberately excluded — a ring around every block you
   type into would be noise, and the caret already marks the spot. */
a[href]:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
summary:focus-visible,
[role="button"]:focus-visible,
[role="option"]:focus-visible,
[role="menuitem"]:focus-visible,
[tabindex]:not([tabindex="-1"]):focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
/* grid cells / board cards sit flush against neighbours — inset the ring so it
   never overlaps the next cell. */
.db-td:focus-visible,
.db-th:focus-visible,
.db-card:focus-visible,
.db-list-row:focus-visible {
  /* inset so the ring stays inside the cell — no `position` override here:
     frozen columns are `position: sticky` and must stay that way. */
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}
/* the roving grid cell is the grid's single tab stop */
.db-table [tabindex="0"]:focus { outline-color: var(--accent); }
/* the skip link must be obvious the moment it appears */
.skip-link:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }

@media (prefers-contrast: more) {
  :root { --border: #c3c6d8; --border-strong: #9aa0bd; }
  html[data-theme="dark"] { --border: #3a4066; --border-strong: #565d8a; }
}

/* ============================================================
   Focus / Zen mode — hide the rail & chrome, dim inactive blocks
   ============================================================ */
body.focus-mode #sidebar { margin-left: calc(-1 * var(--sidebar-w)); pointer-events: none; }
body.focus-mode #btn-expand { display: none !important; }
/* topbar recedes; slide a cursor to the top edge to bring it back */
body.focus-mode #topbar { opacity: 0; transition: opacity 0.2s; }
body.focus-mode #main:hover #topbar { opacity: 1; }
body.focus-mode #main.topbar-scrolled #topbar { opacity: 1; }
/* a calmer, slightly wider reading measure */
body.focus-mode #page-body { max-width: 760px; }
/* while actively writing, everything but the current block softens away */
body.focus-mode #editor:focus-within .block { opacity: 0.4; transition: opacity 0.25s var(--ease-out); }
body.focus-mode #editor:focus-within .block:focus-within,
body.focus-mode #editor .block:hover { opacity: 1; }

#focus-exit {
  position: fixed; bottom: 22px; right: 24px; z-index: 120; display: none;
  align-items: center; gap: 8px; padding: 8px 14px; border-radius: 999px;
  font-size: 12.5px; font-weight: 600; color: #eceef8;
  background: rgba(20, 22, 43, 0.72); -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
  box-shadow: 0 2px 10px rgba(4, 5, 16, 0.4), inset 0 0 0 1px rgba(255, 255, 255, 0.12);
  opacity: 0; transition: opacity 0.2s, transform 0.1s var(--ease-out);
}
body.focus-mode #focus-exit { display: inline-flex; opacity: 0.5; }
body.focus-mode #focus-exit:hover { opacity: 1; transform: translateY(1px); }
#focus-exit kbd {
  font-family: var(--font); font-size: 10.5px; padding: 0 5px; border-radius: 4px;
  background: rgba(255, 255, 255, 0.14); box-shadow: inset 0 -1px 0 rgba(0, 0, 0, 0.3);
}

/* ============================================================
   Quick capture modal
   ============================================================ */
.qc-modal { width: 540px; max-width: calc(100vw - 32px); overflow: hidden; }
/* header with a soft brand-tinted band */
.qc-head {
  align-items: flex-start;
  background: linear-gradient(180deg, color-mix(in srgb, var(--accent) 6%, var(--bg-modal)), var(--bg-modal));
  border-bottom: 1px solid var(--border);
}
.qc-head-title { display: flex; align-items: center; gap: 12px; min-width: 0; }
.qc-head-ic {
  display: inline-flex; align-items: center; justify-content: center;
  width: 34px; height: 34px; flex-shrink: 0; border-radius: 10px;
  color: #fff; background: var(--accent);
  box-shadow: 0 2px 8px color-mix(in srgb, var(--accent) 40%, transparent), inset 0 1px 0 rgba(255,255,255,0.25);
}
.qc-head-sub { margin-top: 2px; font-size: 12.5px; color: var(--text-light); }

.qc-body { padding: 18px 20px 8px; display: flex; flex-direction: column; gap: 14px; }
.qc-input-wrap { position: relative; }
.qc-text {
  width: 100%; min-height: 140px; resize: vertical; padding: 13px 14px;
  font-family: var(--font); font-size: 15px; line-height: 1.6;
  border: 1px solid var(--border-strong); border-radius: 12px;
  background: var(--bg-input); color: var(--text); outline: none;
  transition: border-color 0.14s, box-shadow 0.14s;
}
.qc-text:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(91, 91, 214, 0.16); }
.qc-text::placeholder { color: var(--text-placeholder); }
/* dictation mic button, floated in the corner of the textarea */
.qc-mic {
  position: absolute; right: 10px; bottom: 10px;
  display: inline-flex; align-items: center; justify-content: center;
  width: 34px; height: 34px; border-radius: 9px;
  color: var(--text-light); background: var(--bg-modal);
  border: 1px solid var(--border-strong); cursor: pointer;
  transition: background 0.12s, color 0.12s, border-color 0.12s;
}
.qc-mic:hover { background: var(--bg-hover); color: var(--text); }
.qc-mic.is-rec {
  color: #fff; background: #e5484d; border-color: #e5484d;
  animation: qc-mic-pulse 1.3s ease-in-out infinite;
}
@keyframes qc-mic-pulse { 0%,100% { box-shadow: 0 0 0 0 rgba(229,72,77,0.5); } 50% { box-shadow: 0 0 0 6px rgba(229,72,77,0); } }
.qc-mic-status { font-size: 12.5px; color: var(--text-light); padding: 0 2px; }
.qc-mic-status[hidden] { display: none; }

.qc-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.qc-dest-label { font-size: 12px; color: var(--text-faint); font-family: var(--font-display); text-transform: uppercase; letter-spacing: 0.6px; }
.qc-foot {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 20px;
  border-top: 1px solid var(--border); background: var(--bg-sidebar, var(--bg-callout));
}
.qc-hint { font-size: 12px; color: var(--text-faint); }
.qc-hint kbd { font-family: var(--font); background: var(--bg-code); border: 1px solid var(--border-strong); border-radius: 4px; padding: 0 5px; font-size: 11px; }
.qc-save {
  padding: 9px 20px; font-size: 14px; font-weight: 600; font-family: var(--font);
  color: #fff; background: var(--accent); border: none; border-radius: var(--radius-ctl); cursor: pointer;
  box-shadow: 0 3px 10px rgba(91, 91, 214, 0.3); transition: background 0.14s, transform 0.08s, filter 0.14s;
}
.qc-save:hover { background: var(--accent-hover); filter: brightness(1.03); }
.qc-save:active { transform: translateY(1px); }

/* ============================================================
   What's new — changelog modal
   ============================================================ */
.changelog-modal { width: 560px; max-width: calc(100vw - 32px); max-height: 78vh; }
.changelog-body { overflow-y: auto; padding: 18px 22px 22px; }
.cl-release + .cl-release { margin-top: 22px; padding-top: 22px; border-top: 1px solid var(--border); }
.cl-meta { display: flex; align-items: center; gap: 8px; }
.cl-date { font-family: var(--font-mono); font-size: 11.5px; letter-spacing: 0.05em; color: var(--text-faint); text-transform: uppercase; }
.cl-title { font-family: var(--font-display); font-size: 18px; font-weight: 700; color: var(--text); margin: 4px 0 12px; letter-spacing: -0.2px; }
.cl-list { list-style: none; display: grid; gap: 9px; }
.cl-list li { position: relative; padding-left: 24px; font-size: 14px; color: var(--text-light); line-height: 1.5; }
.cl-list li::before {
  content: ""; position: absolute; left: 0; top: 7px; width: 8px; height: 8px; border-radius: 3px;
  background: linear-gradient(135deg, var(--accent), var(--accent-soft));
}

/* ============================================================
   AI ghost text (inline autocomplete overlay)
   ============================================================ */
#ghost-overlay {
  position: fixed; z-index: 90; display: none; pointer-events: none;
  color: var(--text-placeholder); white-space: pre-wrap; overflow: hidden;
  padding: 0; margin: 0; will-change: left, top;
}
#ghost-overlay.show { display: block; }
#ghost-overlay::after {
  content: "Tab"; margin-left: 8px; font-family: var(--font); font-size: 10px; font-weight: 600;
  letter-spacing: 0.3px; color: var(--accent-soft); vertical-align: baseline;
  border: 1px solid color-mix(in srgb, var(--accent-soft) 45%, transparent); border-radius: 4px;
  padding: 0 4px; opacity: 0.8;
}

/* ============================================================
   Rich embeds (bookmark block renders live iframes)
   ============================================================ */
.embed-box { margin: 6px 0 2px; }
.embed-frame {
  position: relative; width: 100%; aspect-ratio: 16 / 9; border-radius: var(--radius-card);
  overflow: hidden; border: 1px solid var(--border); background: var(--bg-code);
}
.embed-frame iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; display: block; }
/* widget/script embeds (tweet, gist) use a fixed height instead of an aspect ratio */
.embed-frame-scroll { aspect-ratio: auto; background: var(--bg); }
.embed-frame-scroll[data-provider="twitter"] { max-width: 550px; }
.embed-open {
  display: inline-block; margin-top: 6px; font-size: 12px; color: var(--text-faint);
  text-decoration: none; border-bottom: 1px solid transparent;
}
.embed-open:hover { color: var(--accent); border-bottom-color: var(--accent-soft); }
html[data-theme="dark"] .embed-open:hover { color: var(--accent-soft); }

/* ============================================================
   Print / Save-as-PDF — isolate the page body on white paper
   ============================================================ */
@media print {
  body.printing #sidebar, body.printing #topbar, body.printing #focus-exit,
  body.printing #sb-scrim, body.printing #toast, body.printing #page-cover,
  body.printing #page-head-actions, body.printing #backlinks, body.printing .block-gutter,
  body.printing #reading-meta { display: none !important; }
  body.printing #app { display: block; padding: 0; height: auto; }
  body.printing #main { box-shadow: none; border-radius: 0; background: #fff; overflow: visible; }
  body.printing #page-scroll { overflow: visible; height: auto; }
  body.printing #page-body { max-width: 100%; padding: 0 8mm; }
  body.printing, body.printing #main, body.printing .block-content { color: #111 !important; }
  body.printing .b-code, body.printing .b-callout { border: 1px solid #ddd; background: #f7f7f9 !important; }
  body.printing #page-title { font-size: 26pt; }
  @page { margin: 14mm; }
}

/* ============================================================
   Buttons everywhere: honor reduced-motion (global rule already
   neutralizes transitions; these transforms sit under it safely)
   ============================================================ */
@media (prefers-reduced-motion: reduce) {
  .login-brand-list li:hover,
  .sb-action-primary:active,
  .topbar-btn:active, .icon-btn:active,
  .tpl-card:hover, .lib-newpage:active, .lib-templates-btn:active { transform: none !important; }
}

/* ---- Saved searches (pinned queries) + palette pin footer ---- */
.palette-foot {
  display: flex;
  justify-content: flex-end;
  padding: 8px 10px 4px;
  margin-top: 4px;
  border-top: 1px solid var(--border);
}
.palette-foot.hidden { display: none; }
.palette-pin {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--border-strong);
  background: var(--bg-input);
  color: var(--text-light);
  font: inherit;
  font-size: 12.5px;
  font-weight: 500;
  padding: 5px 11px;
  border-radius: var(--radius-ctl);
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
}
.palette-pin:hover:not(:disabled) { background: var(--bg-hover); border-color: var(--accent); color: var(--text); }
.palette-pin:disabled { cursor: default; color: var(--accent); }
.palette-pin .ic { color: var(--accent); }

.sb-saved-item { position: relative; }
.sb-saved-item .ti-title { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sb-saved-del {
  opacity: 0;
  margin-left: auto;
  width: 20px;
  height: 20px;
  transition: opacity 0.12s;
}
.sb-saved-item:hover .sb-saved-del { opacity: 0.7; }
.sb-saved-del:hover { opacity: 1 !important; }

/* ---- Palette peek preview (hover a page result to preview it) ---- */
.palette-peek {
  position: fixed;
  z-index: 1200;
  width: 328px;
  overflow-y: auto;
  background: var(--bg-modal);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-popover);
  padding: 14px 16px;
  animation: pk-fade 0.12s var(--ease-out, ease);
  scrollbar-width: thin;
}
.palette-peek.hidden { display: none; }
@keyframes pk-fade { from { opacity: 0; transform: translateX(-4px); } to { opacity: 1; transform: none; } }
.pk-head { display: flex; align-items: center; gap: 8px; padding-bottom: 10px; margin-bottom: 10px; border-bottom: 1px solid var(--border); }
.pk-ic { font-size: 17px; line-height: 1; }
.pk-title { font-family: var(--font-display, "Space Grotesk", sans-serif); font-size: 15px; font-weight: 600; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pk-body { display: flex; flex-direction: column; gap: 5px; }
.pk-body > div { font-size: 12.5px; line-height: 1.45; color: var(--text-light); overflow: hidden; text-overflow: ellipsis; }
.pk-h1 { font-size: 15px !important; font-weight: 700; color: var(--text) !important; margin-top: 3px; }
.pk-h2 { font-size: 14px !important; font-weight: 700; color: var(--text) !important; margin-top: 2px; }
.pk-h3 { font-size: 13px !important; font-weight: 600; color: var(--text) !important; }
.pk-quote { border-left: 2px solid var(--border-strong); padding-left: 8px; font-style: italic; }
.pk-callout { background: var(--bg-callout); border-radius: 6px; padding: 5px 8px; }
.pk-code { font-family: var(--font-mono, monospace); font-size: 11.5px !important; background: var(--bg-code); border-radius: 5px; padding: 4px 7px; white-space: pre-wrap; }
.pk-muted { color: var(--text-faint) !important; }
.pk-divider { border-top: 1px solid var(--border); height: 0; margin: 3px 0; }
.pk-empty { color: var(--text-faint); font-size: 12.5px; font-style: italic; }
@media (prefers-reduced-motion: reduce) { .palette-peek { animation: none; } }
@media (max-width: 720px) { .palette-peek { display: none !important; } }

/* ---- Workspace identity editor (Settings → Workspace) ---- */
.ws-identity { display: flex; flex-direction: column; gap: 12px; margin-bottom: 6px; }
.ws-preview {
  display: flex; align-items: center; gap: 11px;
  padding: 12px 14px; border: 1px solid var(--border); border-radius: var(--radius-card);
  background: var(--bg-hover);
}
.ws-preview-logo {
  width: 32px; height: 32px; border-radius: 9px; flex: none;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 16px; font-weight: 700; color: #fff;
  background: linear-gradient(140deg, #6d6df0, #4a4ac8);
}
.ws-preview-name { font-family: var(--font-display, "Space Grotesk", sans-serif); font-size: 16px; font-weight: 600; color: var(--text); }
.ws-fields { display: flex; gap: 8px; }
.ws-fields #ws-name { flex: 1; }
.ws-icon-input { width: 84px; flex: none; text-align: center; }
.ws-colors { display: flex; gap: 8px; flex-wrap: wrap; }
.ws-swatch {
  width: 26px; height: 26px; border-radius: 999px; cursor: pointer;
  border: 2px solid transparent; box-shadow: inset 0 0 0 1px rgba(0,0,0,0.08);
  transition: transform 0.1s, border-color 0.12s;
}
.ws-swatch:hover { transform: scale(1.1); }
.ws-swatch.active { border-color: var(--text); }
.ws-swatch-default {
  background: var(--bg-input); color: var(--text-faint);
  display: inline-flex; align-items: center; justify-content: center; font-size: 14px; line-height: 1;
}

/* Settings: inline input + button row (backend connection). */
.settings-row-inline { display: flex; gap: 8px; align-items: stretch; }
.settings-row-inline .settings-input { flex: 1; min-width: 0; }
.settings-inline-btn { flex-shrink: 0; white-space: nowrap; }

/* ============================================================
   No-JavaScript fallback
   The app is client-rendered, so without JS the body is empty.
   Say what's wrong instead of showing a blank page.
   ============================================================ */
.noscript-notice {
  max-width: 34rem; margin: 12vh auto; padding: 0 1.5rem;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  line-height: 1.6; color: #2b2b31; text-align: center;
}
.noscript-notice h1 { font-size: 1.5rem; margin: 0 0 .75rem; }
.noscript-notice p { margin: 0 0 .75rem; color: #5a5a66; }
.noscript-notice a { color: #5b5bd6; }
@media (prefers-color-scheme: dark) {
  .noscript-notice { color: #ece9f3; }
  .noscript-notice p { color: #a6a2b4; }
}

/* ============================================================
   In-app back / forward (js/navhistory.js)
   Essential in installed-PWA mode, where there is no browser
   chrome to fall back on.
   ============================================================ */
.navhist { display: flex; align-items: center; gap: 1px; margin-right: 4px; flex-shrink: 0; }
.navhist-btn { width: 26px; height: 26px; display: flex; align-items: center; justify-content: center; }
.navhist-btn[disabled],
.navhist-btn[aria-disabled="true"] { opacity: .32; pointer-events: none; }

/* On narrow screens the hamburger + breadcrumbs already fill the bar. */
@media (max-width: 760px) { .navhist { display: none; } }

/* ============================================================
   Palette footer: pin + escalate to full workspace search.
   The two search surfaces now read as one flow.
   ============================================================ */
.palette-foot { display: flex; align-items: center; gap: 8px; }
.palette-all {
  margin-left: auto; display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; padding: 4px 8px; border-radius: 6px;
  background: none; border: none; cursor: pointer;
  color: var(--text-light, #6b6b76); white-space: nowrap;
}
.palette-all:hover { background: var(--hover, rgba(0,0,0,.05)); color: var(--text, inherit); }
.palette-all kbd {
  font-size: 10px; padding: 1px 4px; border-radius: 3px; opacity: .75;
  background: var(--hover, rgba(0,0,0,.06)); font-family: inherit;
}

/* Settings: per-user credential controls (legacy import + forget). */
.settings-cred-legacy {
  margin: 8px 0 10px; padding: 10px 12px; border-radius: 8px;
  background: color-mix(in srgb, #d9a441 12%, transparent);
  border: 1px solid color-mix(in srgb, #d9a441 34%, transparent);
}
.settings-cred-legacy .settings-help { margin-top: 0; }
.settings-danger { color: var(--danger, #eb5757); }
.settings-danger:hover { background: color-mix(in srgb, var(--danger, #eb5757) 12%, transparent); }
