* {
  font-family: 'Inter', sans-serif;
}
code, pre, kbd, samp {
  font-family: 'DM Mono', monospace;
}

@media (hover: none) and (pointer: coarse) {
  button, a, input[type="checkbox"], input[type="radio"], select {
    min-height: 44px;
  }
  button, .bookmark-card, .group-item, .tag-pill {
    -webkit-tap-highlight-color: transparent;
    user-select: none;
  }
  input, textarea, p, h1, h2, h3, h4, h5, h6 {
    user-select: text;
  }
}

:root {
  --bg:           #0e0f11;
  --surface:      #16181c;
  --surface2:     #1e2026;
  --surface3:     #242730;
  --border:       #2a2d35;
  --border-light: #343844;
  --accent:       #e8a048;
  --accent-dim:   rgba(232,160,72,0.14);
  --text:         #ecedf0;
  --text-muted:   #6b7280;
  --text-dim:     #9ca3af;
  --green:        #3ecf8e;
  --green-dim:    rgba(62,207,142,0.14);
  --red:          #f04f58;
  --red-dim:      rgba(240,79,88,0.14);
  --blue:         #4f8ef0;
  --blue-dim:     rgba(79,142,240,0.14);
  --purple:       #a78bfa;
  --purple-dim:   rgba(167,139,250,0.14);
  --yellow:       #facc15;
  --yellow-dim:   rgba(250,204,21,0.14);
  --code-bg:      #0b0f16;
  --code-surface: #101620;
  --code-border:  #273244;
  --code-text:    #d7deea;
  --code-muted:   #7f8b9d;
  --code-keyword: #ff8f86;
  --code-title:   #d8b4fe;
  --code-const:   #89c2ff;
  --code-string:  #9de3c0;
  --code-built:   #f6bd60;
  --code-tag:     #7dd3fc;
  --code-section: #93c5fd;
  --code-add-bg:  rgba(62,207,142,0.14);
  --code-add:     #8ff0bf;
  --code-del-bg:  rgba(240,79,88,0.16);
  --code-del:     #ffb4b9;

  /* Alias for Tailwind compat */
  --sage-500: #e8a048;
  --sage-600: #f0b060;
  --cream:    #0e0f11;
  --ink:      #ecedf0;
  --warm-100: #16181c;
  --warm-200: #2a2d35;
  --warm-300: #343844;
  --warm-400: #6b7280;
  --warm-500: #9ca3af;

  --shadow-soft: 0 8px 32px rgba(0,0,0,0.55);
  --shadow-lift: 0 16px 48px rgba(0,0,0,0.65);
  --navbar-bg:   rgba(14,15,17,0.96);
}

/* ── Light Theme ─────────────────────────────────── */
[data-theme="light"] {
  --bg:           #ffffff;
  --surface:      #ffffff;
  --surface2:     #f8f9fa;
  --surface3:     #f1f3f4;
  --border:       #e8eaed;
  --border-light: #dfe1e5;
  --accent:       #c17d2a;
  --accent-dim:   rgba(193,125,42,0.09);
  --text:         #202124;
  --text-muted:   #5f6368;
  --text-dim:     #80868b;
  --green:        #137333;
  --green-dim:    rgba(19,115,51,0.09);
  --red:          #c5221f;
  --red-dim:      rgba(197,34,31,0.09);
  --blue:         #1a73e8;
  --blue-dim:     rgba(26,115,232,0.09);
  --purple:       #6200ee;
  --purple-dim:   rgba(98,0,238,0.09);
  --yellow:       #b06000;
  --yellow-dim:   rgba(176,96,0,0.09);
  --code-bg:      #f6f8fa;
  --code-surface: #ffffff;
  --code-border:  #d8dee7;
  --code-text:    #24292f;
  --code-muted:   #68707c;
  --code-keyword: #cf222e;
  --code-title:   #8250df;
  --code-const:   #0550ae;
  --code-string:  #0a6b3d;
  --code-built:   #9a6700;
  --code-tag:     #116329;
  --code-section: #0969da;
  --code-add-bg:  #dafbe1;
  --code-add:     #116329;
  --code-del-bg:  #ffebe9;
  --code-del:     #cf222e;

  --sage-500: #c17d2a;
  --sage-600: #a86820;
  --cream:    #ffffff;
  --ink:      #202124;
  --warm-100: #ffffff;
  --warm-200: #e8eaed;
  --warm-300: #dfe1e5;
  --warm-400: #80868b;
  --warm-500: #5f6368;

  --shadow-soft: 0 1px 2px rgba(60,64,67,0.06), 0 2px 6px rgba(60,64,67,0.04);
  --shadow-lift: 0 2px 8px rgba(60,64,67,0.10), 0 6px 20px rgba(60,64,67,0.07);
  --navbar-bg:   rgba(255,255,255,0.97);
}

/* Light mode component tweaks */
[data-theme="light"] .bookmark-card {
  border-color: var(--border) !important;
  box-shadow: 0 1px 2px rgba(60,64,67,0.05) !important;
}
[data-theme="light"] .bookmark-card:hover {
  border-color: var(--border-light) !important;
  background: var(--surface2) !important;
  box-shadow: 0 2px 8px rgba(60,64,67,0.09) !important;
}
[data-theme="light"] .top-navbar {
  border-bottom-color: var(--border) !important;
  box-shadow: none;
}
[data-theme="light"] .stash-modal {
  box-shadow: 0 4px 24px rgba(60,64,67,0.14) !important;
}
[data-theme="light"] .dropdown-menu {
  background: var(--surface) !important;
  border-color: var(--border) !important;
  box-shadow: 0 2px 12px rgba(60,64,67,0.12) !important;
}
[data-theme="light"] .context-menu {
  background: var(--surface) !important;
  border-color: var(--border) !important;
  box-shadow: 0 2px 12px rgba(60,64,67,0.12) !important;
}
[data-theme="light"] .sidebar-avatar {
  background: rgba(193,125,42,0.10) !important;
  color: var(--accent) !important;
}
[data-theme="light"] .star-btn.active { color: var(--accent) !important; }
[data-theme="light"] .group-item:hover {
  background: var(--surface2) !important;
}
[data-theme="light"] .group-item.active {
  background: rgba(193,125,42,0.09) !important;
  border-color: rgba(193,125,42,0.16) !important;
  color: var(--accent) !important;
}
[data-theme="light"] #sidebar {
  border-right-color: var(--border) !important;
  box-shadow: none !important;
}
[data-theme="light"] .toggle-switch {
  background: #e0e0e0;
  border-color: #d0d0d0;
}
[data-theme="light"] .toggle-switch::after {
  background: #fff;
  box-shadow: 0 1px 3px rgba(0,0,0,0.18);
}
[data-theme="light"] .toggle-switch.active {
  background: var(--accent);
  border-color: var(--accent);
}
[data-theme="light"] .toggle-switch.active::after {
  background: #fff;
}
[data-theme="light"] .se-scroll-top {
  background: rgba(255,255,255,0.96);
  box-shadow: 0 2px 8px rgba(60,64,67,0.18);
  border-color: var(--border-light);
}
[data-theme="light"] .modal-overlay > div {
  border-color: var(--border) !important;
  box-shadow: 0 4px 24px rgba(60,64,67,0.14) !important;
}

html {
  font-size: 14px;
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  background: var(--bg);
  color: var(--text);
}

/* Momentum scrolling on iOS */
#sidebar, main, .modal-overlay {
  -webkit-overflow-scrolling: touch;
}

/* Display font */
.font-display {
  font-family: 'Inter', sans-serif;
  letter-spacing: 0;
}

/* ── Scrollbar ─────────────────────────────────── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: var(--surface); }
::-webkit-scrollbar-thumb { background: var(--border-light); border-radius: 2px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ── Rendered Markdown ───────────────────────────── */
.note-body {
  font-family: 'Inter', sans-serif;
}
.note-body ::selection {
  background: rgba(250, 204, 21, 0.38);
  color: inherit;
}
.note-body * {
  font-family: inherit;
}
.note-body code,
.note-body pre,
.note-body pre * {
  font-family: 'DM Mono', monospace !important;
}
.note-body h1,
.note-body h2,
.note-body h3,
.note-body h4,
.note-body h5,
.note-body h6 {
  font-family: 'Inter', sans-serif;
  font-weight: 700;
  color: var(--text);
  letter-spacing: 0;
  margin: 1.75em 0 0.6em;
  line-height: 1.3;
}
.note-body h1 { font-size: 1.8em; }
.note-body h2 {
  font-size: 1.4em;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.3em;
}
.note-body h3 { font-size: 1.2em; }
.note-body h4,
.note-body h5,
.note-body h6 { font-size: 1em; }
.note-body p { margin: 1em 0; }
.note-body a {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-thickness: 1px;
}
.note-body a:hover { color: var(--sage-600); }
.note-body ul,
.note-body ol {
  padding-left: 1.75em;
  margin: 1em 0;
}
.note-body li {
  margin: 0.4em 0;
  line-height: 1.75;
}
.note-body blockquote {
  border-left: 3px solid var(--accent);
  margin: 1.5em 0;
  padding: 0.6em 1.2em;
  color: var(--text-dim);
  background: var(--accent-dim);
  border-radius: 0 4px 4px 0;
  font-style: italic;
}
.note-body :not(pre) > code {
  display: inline-block;
  transform: translateY(-0.02em);
  font-size: 0.82em;
  line-height: 1.35;
  color: var(--code-keyword);
  background: var(--code-bg);
  border: 1px solid var(--code-border);
  border-radius: 4px;
  padding: 0.05em 0.38em 0.12em;
  box-shadow: inset 0 -1px 0 rgba(0,0,0,0.12);
}
.note-body pre {
  position: relative;
  overflow-x: auto;
  margin: 1.45em 0;
  padding: 0;
  background:
    linear-gradient(180deg, rgba(255,255,255,0.035), rgba(255,255,255,0)),
    var(--code-bg);
  border: 1px solid var(--code-border);
  border-radius: 8px;
  box-shadow: 0 12px 34px rgba(0,0,0,0.24), inset 0 1px 0 rgba(255,255,255,0.04);
}
[data-theme="light"] .note-body pre {
  box-shadow: 0 8px 24px rgba(31,35,40,0.08), inset 0 1px 0 rgba(255,255,255,0.75);
}
.note-body pre::before {
  content: "";
  display: block;
  height: 30px;
  background: var(--code-surface);
  border-bottom: 1px solid var(--code-border);
}
.note-body pre::after {
  content: "";
  position: absolute;
  top: 12px;
  left: 14px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--red);
  box-shadow: 13px 0 0 var(--yellow), 26px 0 0 var(--green);
  opacity: 0.88;
}
.note-body pre code.hljs,
.note-body pre code {
  display: block;
  min-width: max-content;
  padding: 16px 20px 18px;
  color: var(--code-text);
  background: transparent;
  border: 0;
  border-radius: 0;
  font-size: 0.86em;
  line-height: 1.72;
  tab-size: 2;
  white-space: pre;
}
.note-body pre::-webkit-scrollbar {
  height: 10px;
}
.note-body pre::-webkit-scrollbar-track {
  background: transparent;
}
.note-body pre::-webkit-scrollbar-thumb {
  background: var(--code-muted);
  background: color-mix(in srgb, var(--code-muted) 45%, transparent);
  border: 3px solid var(--code-bg);
  border-radius: 999px;
}
.note-body table {
  width: 100%;
  border-collapse: collapse;
  margin: 1em 0;
  font-size: 0.9em;
}
.note-body th,
.note-body td {
  border: 1px solid var(--border);
  padding: 0.5em 0.9em;
  text-align: left;
}
.note-body th {
  background: var(--surface2);
  color: var(--text);
  font-weight: 600;
}
.note-body tr:nth-child(even) { background: var(--surface); }
.note-body img {
  max-width: 100%;
  border-radius: 4px;
  margin: 0.75em 0;
  height: auto;
}
.note-body img[data-veilink-image="true"] {
  max-width: 100%;
}
.note-body hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 2em 0;
}
.note-body strong {
  color: var(--text);
  font-weight: 600;
}
.note-body em { color: var(--text-dim); }
.note-body .veilink-columns {
  display: grid;
  gap: 16px;
  align-items: start;
  margin: 1.2em 0;
}
.note-body .veilink-column {
  min-width: 0;
}
.note-body .veilink-column > :first-child {
  margin-top: 0;
}
.note-body .veilink-column > :last-child {
  margin-bottom: 0;
}
@media (max-width: 720px) {
  .note-body .veilink-columns {
    grid-template-columns: 1fr !important;
  }
}
.hljs {
  color: var(--code-text);
  background: transparent;
}

.ob-image-block {
  position: relative;
}
.ob-image-frame {
  position: relative;
  max-width: 100%;
  min-height: 42px;
}
.ob-image-frame img {
  display: block;
  max-width: 100%;
  height: auto;
}
.ob-image-toolbar {
  position: absolute;
  top: 8px;
  right: 8px;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--border);
  background: rgba(14,15,17,0.86);
  backdrop-filter: blur(8px);
  border-radius: 3px;
  opacity: 0;
  transition: opacity 0.15s;
  z-index: 2;
}
.ob-image-frame:hover .ob-image-toolbar,
.ob-image-toolbar:focus-within {
  opacity: 1;
}
.ob-image-toolbar button {
  width: 24px;
  height: 24px;
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--text-dim);
  border-radius: 2px;
  cursor: pointer;
  font-size: 10px;
  font-family: 'Inter', sans-serif;
}
.ob-image-toolbar button:hover {
  border-color: var(--accent);
  color: var(--accent);
}
.ob-image-toolbar span {
  min-width: 34px;
  color: var(--text-muted);
  font-size: 10px;
  font-family: 'Inter', sans-serif;
  text-align: center;
}
.ob-image-resize {
  position: absolute;
  z-index: 2;
  opacity: 0;
  transition: opacity 0.15s, background 0.15s;
}
.ob-image-frame:hover .ob-image-resize {
  opacity: 1;
}
.ob-image-resize-left,
.ob-image-resize-right {
  top: 0;
  bottom: 0;
  width: 10px;
  cursor: ew-resize;
}
.ob-image-resize-left { left: -5px; }
.ob-image-resize-right { right: -5px; }
.ob-image-resize-corner {
  right: -6px;
  bottom: -6px;
  width: 14px;
  height: 14px;
  border: 2px solid var(--accent);
  border-top: 0;
  border-left: 0;
  cursor: nwse-resize;
}
.ob-image-resize-left::after,
.ob-image-resize-right::after {
  content: "";
  position: absolute;
  top: 12px;
  bottom: 12px;
  left: 4px;
  width: 2px;
  border-radius: 999px;
  background: var(--accent);
}
.hljs-doctag,
.hljs-keyword,
.hljs-meta .hljs-keyword,
.hljs-template-tag,
.hljs-template-variable,
.hljs-type,
.hljs-variable.language_ {
  color: var(--code-keyword);
}
.hljs-title,
.hljs-title.class_,
.hljs-title.class_.inherited__,
.hljs-title.function_ {
  color: var(--code-title);
}
.hljs-attr,
.hljs-attribute,
.hljs-literal,
.hljs-meta,
.hljs-number,
.hljs-operator,
.hljs-variable,
.hljs-selector-attr,
.hljs-selector-class,
.hljs-selector-id {
  color: var(--code-const);
}
.hljs-regexp,
.hljs-string,
.hljs-meta .hljs-string {
  color: var(--code-string);
}
.hljs-built_in,
.hljs-symbol {
  color: var(--code-built);
}
.hljs-comment,
.hljs-code,
.hljs-formula {
  color: var(--code-muted);
  font-style: italic;
}
.hljs-name,
.hljs-quote,
.hljs-selector-tag,
.hljs-selector-pseudo {
  color: var(--code-tag);
}
.hljs-subst {
  color: var(--code-text);
}
.hljs-section {
  color: var(--code-section);
  font-weight: 700;
}
.hljs-bullet {
  color: var(--code-built);
}
.hljs-emphasis {
  color: var(--code-text);
  font-style: italic;
}
.hljs-strong {
  color: var(--code-text);
  font-weight: 700;
}
.hljs-addition {
  color: var(--code-add);
  background-color: var(--code-add-bg);
}
.hljs-deletion {
  color: var(--code-del);
  background-color: var(--code-del-bg);
}

/* ── Global color overrides (dark theme) ────────── */
/* bg-white → surface */
.bg-white { background-color: var(--surface) !important; }
/* bg-cream → dark bg */
.bg-cream { background-color: var(--bg) !important; }
/* noise-bg — disable light gradients */
.noise-bg::before, .noise-bg::after { display: none !important; }

/* ── Top Navbar ──────────────────────────────────── */
.top-navbar {
  position: sticky;
  top: 0;
  z-index: 100;
  height: 54px;
  background: var(--navbar-bg);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 20px;
  flex-shrink: 0;
  transition: opacity 0.2s ease;
}
@keyframes navbarSlideIn {
  from { opacity: 0; transform: translateY(-8px); }
  to   { opacity: 1; transform: translateY(0); }
}
.top-navbar.navbar-slide-in {
  animation: navbarSlideIn 0.28s ease forwards;
}
.sidebar-toggle {
  width: 28px !important;
  height: 28px !important;
  min-width: 28px !important;
  min-height: 28px !important;
  border: 0;
  border-radius: 2px;
  background: transparent;
  color: var(--text-dim);
  cursor: pointer;
  display: inline-flex !important;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 0;
  flex-shrink: 0;
  opacity: 0.78;
  transition: color 0.15s, background 0.15s, opacity 0.15s;
}
.sidebar-toggle:hover,
.sidebar-toggle[aria-expanded="true"] {
  color: var(--text);
  background: rgba(255,255,255,0.04);
  opacity: 1;
}
.sidebar-toggle-line {
  display: block;
  width: 15px;
  height: 1px;
  background: currentColor;
  border-radius: 999px;
  transition: transform 0.15s, opacity 0.15s;
}
.sidebar-toggle[aria-expanded="true"] .sidebar-toggle-line:nth-child(1) {
  transform: translateY(5px) rotate(45deg);
}
.sidebar-toggle[aria-expanded="true"] .sidebar-toggle-line:nth-child(2) {
  opacity: 0;
}
.sidebar-toggle[aria-expanded="true"] .sidebar-toggle-line:nth-child(3) {
  transform: translateY(-5px) rotate(-45deg);
}
.wordmark {
  display: flex;
  align-items: center;
  gap: 6px;
  text-decoration: none;
  flex-shrink: 0;
}
.wordmark-text {
  font-family: 'Syne', sans-serif;
  font-weight: 800;
  font-size: 17px;
  letter-spacing: -0.3px;
  color: var(--text);
}
.wordmark-glyph {
  color: var(--accent);
  font-size: 14px;
}
.nav-divider {
  width: 1px;
  height: 18px;
  background: var(--border);
  flex-shrink: 0;
}
.nav-count {
  font-size: 10px;
  color: var(--text-muted);
  letter-spacing: 0.06em;
  flex-shrink: 0;
  white-space: nowrap;
}
.nav-count span { color: var(--accent); }
.nav-btn {
  padding: 5px 13px;
  font-family:'Inter',sans-serif;
  font-weight: 700;
  font-size: 11px;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  border-radius: 2px;
  cursor: pointer;
  transition: all 0.15s;
  border: 1px solid;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.nav-btn-ghost {
  background: transparent;
  border-color: var(--border);
  color: var(--text-dim);
}
.nav-btn-ghost:hover { border-color: var(--border-light); color: var(--text); }
.nav-btn-accent {
  background: var(--accent);
  border-color: var(--accent);
  color: #0e0f11;
}
.nav-btn-accent:hover { background: var(--sage-600); }

/* ── Sidebar ─────────────────────────────────────── */
#sidebar {
  width: 220px !important;
  min-width: 220px !important;
  background: var(--surface) !important;
  border-right: 1px solid var(--border) !important;
}
.sidebar-overlay {
  position: fixed;
  inset: 54px 0 0;
  z-index: 35;
  background: rgba(0,0,0,0.46);
  backdrop-filter: blur(2px);
}
.sidebar-overlay[hidden] {
  display: none;
}
/* On mobile, hide the sidebar entirely */
@media (max-width: 1023px) {
  #sidebar,
  #sidebarOverlay,
  #sidebarToggle,
  .sidebar-toggle { display: none !important; }
}

/* Sidebar section label */
.sidebar-label-mono {
  font-size: 9px;
  font-weight: 500;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--text-muted);
  display: block;
  margin-bottom: 6px;
}

.sidebar-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.sidebar-icon-btn {
  width: 22px;
  height: 22px;
  display: inline-grid;
  place-items: center;
  border: 1px solid transparent;
  border-radius: 999px;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  line-height: 1;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease, transform 0.15s ease;
}

.sidebar-icon-btn:hover {
  background: var(--surface2);
  border-color: var(--border);
  color: var(--accent);
  transform: translateY(-1px);
}

.sidebar-add-row {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 10px;
  margin-top: 8px;
  border: 1px dashed color-mix(in srgb, var(--border-light) 78%, var(--accent) 22%);
  border-radius: 10px;
  background: color-mix(in srgb, var(--surface2) 86%, transparent);
  color: var(--text-muted);
  font-family: 'Inter', sans-serif;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  text-align: center;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease, transform 0.15s ease;
}

.sidebar-add-row:hover {
  background: color-mix(in srgb, var(--surface3) 86%, var(--accent) 14%);
  border-color: color-mix(in srgb, var(--accent) 60%, var(--border-light) 40%);
  color: var(--accent);
  transform: translateY(-1px);
}

.sidebar-add-row .sidebar-add-icon {
  width: 18px;
  height: 18px;
  display: inline-grid;
  place-items: center;
  border-radius: 999px;
  background: color-mix(in srgb, var(--accent) 14%, transparent);
  color: var(--accent);
}

/* Sidebar user avatar */
.sidebar-avatar {
  background: var(--accent-dim) !important;
  color: var(--accent) !important;
  font-family:'Inter',sans-serif;
  font-weight: 800;
}

/* ── Group item (sidebar nav links) ──────────────── */
.group-item {
  transition: all 0.15s ease;
  border-radius: 2px !important;
  border: 1px solid transparent;
}
.group-item:hover {
  background: var(--surface2) !important;
  color: var(--text) !important;
}
.group-item.active {
  background: var(--accent-dim) !important;
  border-color: rgba(232,160,72,0.2) !important;
  color: var(--accent) !important;
  font-weight: 600;
  box-shadow: none !important;
}
.group-item:focus, .group-item:focus-visible {
  outline: none !important;
  box-shadow: none !important;
}
/* Override Tailwind active bg-white on sidebar */
.group-item.active { background: var(--accent-dim) !important; }

/* ── Favicon ─────────────────────────────────────── */
.favicon {
  width: 28px;
  height: 28px;
  border-radius: 2px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 800;
  font-family:'Inter',sans-serif;
  color: var(--text-dim);
  flex-shrink: 0;
  background: var(--surface3);
}
.favicon img {
  width: 16px;
  height: 16px;
  object-fit: contain;
  border-radius: 0;
}
.favicon-fallback {
  color: #fff;
}

/* ── Bookmark Card ───────────────────────────────── */
.bookmark-card {
  transition: border-color 0.2s, background 0.2s;
  min-height: 110px;
  border-radius: 2px !important;
  background: var(--surface) !important;
  border: 1px solid var(--border) !important;
}
@media (hover: hover) and (pointer: fine) {
  .bookmark-card:hover {
    transform: none !important;
    border-color: var(--border-light) !important;
    background: var(--surface2) !important;
    box-shadow: none !important;
  }
}
@media (hover: none) and (pointer: coarse) {
  .bookmark-card:active { transform: scale(0.99); opacity: 0.9; }
}

/* ── Favorite star ───────────────────────────────── */
.star-btn { transition: transform 0.15s ease; }
.star-btn:hover { transform: scale(1.15); }
.star-btn.active { color: var(--accent) !important; }

/* ── Add button ──────────────────────────────────── */
@keyframes gentle-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(232,160,72,0.4); }
  50%       { box-shadow: 0 0 0 8px rgba(232,160,72,0); }
}
.add-btn { animation: gentle-pulse 3s ease-in-out infinite; }

/* ── Search input ────────────────────────────────── */
.search-input:focus {
  outline: none;
  border-color: var(--accent) !important;
  box-shadow: 0 0 0 2px rgba(232,160,72,0.2) !important;
}

/* ── Form controls (global dark overrides) ───────── */
input, textarea, select {
  background: var(--surface2) !important;
  border-color: var(--border) !important;
  color: var(--text) !important;
  border-radius: 2px !important;
}
input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]),
textarea,
select {
  font-size: 16px !important;
}
input::placeholder, textarea::placeholder { color: var(--text-muted) !important; }
input:focus, textarea:focus, select:focus {
  outline: none !important;
  border-color: var(--accent) !important;
  box-shadow: 0 0 0 2px rgba(232,160,72,0.18) !important;
}
select option { background: var(--surface2); color: var(--text); }
input[type="radio"]    { accent-color: var(--accent); }
input[type="checkbox"] { accent-color: var(--accent); }

/* ── Tag pill ────────────────────────────────────── */
.tag-pill { transition: all 0.15s ease; }
.tag-pill:hover { background: var(--surface2); }

/* ── Modal overlay ───────────────────────────────── */
.modal-overlay { backdrop-filter: blur(6px); }
/* Modal panels */
.modal-overlay > div {
  border-radius: 2px !important;
  background: var(--surface) !important;
  border: 1px solid var(--border-light) !important;
}
/* Modal header/footer separators */
.modal-overlay .border-b,
.modal-overlay .border-t { border-color: var(--border) !important; }

/* ── Stagger animation ───────────────────────────── */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
.animate-in { animation: fadeInUp 0.28s ease forwards; }

/* ── Toast ───────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 40px;
  right: 20px;
  left: auto;
  max-width: 400px;
  padding: 10px 16px;
  background: var(--surface2);
  border: 1px solid var(--border-light);
  color: var(--text);
  border-radius: 2px;
  box-shadow: var(--shadow-soft);
  display: flex;
  align-items: center;
  gap: 10px;
  z-index: 300;
  font-size: 11px;
  transform: translateY(20px);
  opacity: 0;
  transition: all 0.2s ease;
}
.toast.show { transform: translateY(0); opacity: 1; }
@media (max-width: 640px) {
  .toast { left: 20px; right: 20px; max-width: none; bottom: 20px; }
}
.toast-undo {
  color: var(--accent);
  font-weight: 600;
  cursor: pointer;
  text-decoration: underline;
}

/* ── Dropdown menu ───────────────────────────────── */
.dropdown-menu {
  position: absolute;
  background: var(--surface2);
  border-radius: 2px;
  box-shadow: var(--shadow-soft);
  border: 1px solid var(--border-light);
  padding: 4px 0;
  min-width: 160px;
  z-index: 50;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-6px);
  transition: all 0.15s ease;
}
@media (max-width: 640px) { .dropdown-menu { max-width: calc(100vw - 2rem); } }
.dropdown-menu.search-results {
  left: 0; right: 0; width: 100%; min-width: 0;
  box-sizing: border-box; padding-left: 0; padding-right: 0;
}
.dropdown-menu.search-results a,
.dropdown-menu.search-results button.se-search-option { width: 100%; display: flex; box-sizing: border-box; max-width: 100%; }
.dropdown-menu.show { opacity: 1; visibility: visible; transform: translateY(0); }

/* Dropdown items */
.dropdown-menu button:not(.se-search-option), .dropdown-menu a:not(.se-search-option) {
  color: var(--text-dim) !important;
  background: transparent !important;
  font-size: 11px !important;
  letter-spacing: 0.02em;
}
.dropdown-menu button:not(.se-search-option):hover, .dropdown-menu a:not(.se-search-option):hover,
.dropdown-menu a.focused:not(.se-search-option) {
  background: var(--surface3) !important;
  color: var(--text) !important;
}
.se-search-option:hover, .se-search-option.focused {
  background: var(--surface3) !important;
}
.dropdown-menu .border-t { border-color: var(--border) !important; }
.dropdown-menu button.text-red-600 { color: var(--red) !important; }
.dropdown-menu button.text-red-600:hover {
  background: rgba(240,79,88,0.1) !important;
  color: var(--red) !important;
}

/* ── Right-click context menu ────────────────────── */
.context-menu {
  position: fixed;
  left: 0;
  top: 0;
  min-width: 150px;
  padding: 4px 0;
  border: 1px solid var(--border-light);
  border-radius: 2px;
  background: var(--surface2);
  box-shadow: var(--shadow-soft);
  z-index: 260;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-4px) scale(0.98);
  transition: opacity 0.12s ease, transform 0.12s ease, visibility 0.12s;
}
.context-menu.show {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
}
.context-menu button {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  border: 0;
  background: transparent;
  color: var(--text-dim);
  font-size: 11px;
  letter-spacing: 0.02em;
  text-align: left;
  cursor: pointer;
}
.context-menu button:hover,
.context-menu button:focus-visible {
  outline: none;
  background: var(--surface3);
  color: var(--text);
}
.context-menu-divider {
  height: 1px;
  background: var(--border);
  margin: 4px 0;
  border: 0;
}
.context-menu button.context-menu-danger { color: var(--red); }
.context-menu button.context-menu-danger:hover,
.context-menu button.context-menu-danger:focus-visible {
  background: rgba(240,79,88,0.1);
  color: var(--red);
}

/* ── Text color overrides ────────────────────────── */
.text-ink   { color: var(--text) !important; }
.text-warm-400 { color: var(--text-muted) !important; }
.text-warm-500 { color: var(--text-muted) !important; }
.text-warm-600 { color: var(--text-dim) !important; }
.text-warm-700 { color: var(--text-dim) !important; }

/* ── Border color overrides ──────────────────────── */
.border-warm-100, .border-warm-200 { border-color: var(--border) !important; }

/* ── Toggle switch ───────────────────────────────── */
.toggle-switch {
  position: relative;
  width: 44px;
  height: 24px;
  min-width: 44px !important;
  min-height: 24px !important;
  background: var(--surface3);
  border: 1px solid var(--border-light);
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.2s ease;
}
.toggle-switch.active { background: var(--accent); border-color: var(--accent); }
.toggle-switch::after {
  content: '';
  position: absolute;
  left: 3px; top: 3px;
  width: 16px; height: 16px;
  background: var(--text-dim);
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0,0,0,0.4);
  transition: transform 0.2s ease;
}
.toggle-switch.active::after { background: #0e0f11; transform: translateX(20px); }

/* ── Search highlight ────────────────────────────── */
.search-highlight { background: rgba(232,160,72,0.22); border-radius: 1px; padding: 0 2px; }

/* ── Spinner ─────────────────────────────────────── */
.spinner {
  width: 16px; height: 16px;
  border: 2px solid var(--border-light);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Line clamp ──────────────────────────────────── */
.line-clamp-1 {
  display: -webkit-box; line-clamp: 1; -webkit-line-clamp: 1;
  -webkit-box-orient: vertical; overflow: hidden;
}
.line-clamp-2 {
  display: -webkit-box; line-clamp: 2; -webkit-line-clamp: 2;
  -webkit-box-orient: vertical; overflow: hidden;
}

/* ── Favicon gradient fallbacks ──────────────────── */
.bg-gradient-blue    { background: linear-gradient(135deg, #4f8ef0, #2d5daf); }
.bg-gradient-green   { background: linear-gradient(135deg, #3ecf8e, #2a9060); }
.bg-gradient-purple  { background: linear-gradient(135deg, #a78bfa, #6d4ec8); }
.bg-gradient-red     { background: linear-gradient(135deg, #f04f58, #a82830); }
.bg-gradient-amber   { background: linear-gradient(135deg, #e8a048, #b86820); }
.bg-gradient-cyan    { background: linear-gradient(135deg, #22d3ee, #0891b2); }
.bg-gradient-pink    { background: linear-gradient(135deg, #f472b6, #be185d); }
.bg-gradient-slate   { background: linear-gradient(135deg, #64748b, #334155); }
.bg-gradient-emerald { background: linear-gradient(135deg, #34d399, #059669); }
.bg-gradient-rose    { background: linear-gradient(135deg, #fb7185, #be123c); }

/* ── Tag color classes (used by bookmark cards) ──── */
.tag-dark-gray    { background: var(--surface3);   color: var(--text-dim);  border: 1px solid var(--border); }
.tag-dark-red     { background: var(--red-dim);    color: var(--red);       border: 1px solid rgba(240,79,88,0.28); }
.tag-dark-amber   { background: var(--accent-dim); color: var(--accent);    border: 1px solid rgba(232,160,72,0.28); }
.tag-dark-green   { background: var(--green-dim);  color: var(--green);     border: 1px solid rgba(62,207,142,0.28); }
.tag-dark-blue    { background: var(--blue-dim);   color: var(--blue);      border: 1px solid rgba(79,142,240,0.28); }
.tag-dark-purple  { background: var(--purple-dim); color: var(--purple);    border: 1px solid rgba(167,139,250,0.28); }
.tag-dark-yellow  { background: var(--yellow-dim); color: var(--yellow);    border: 1px solid rgba(250,204,21,0.28); }

/* ── Icon picker (collection modal) ─────────────── */
.icon-btn {
  background: var(--surface2) !important;
  border-color: var(--border) !important;
  border-radius: 2px !important;
}
.icon-btn:hover { border-color: var(--accent) !important; }
.icon-btn svg { color: var(--text-dim) !important; }
.icon-btn.selected { border-color: var(--accent) !important; background: var(--accent-dim) !important; }

/* ── Color picker swatches ───────────────────────── */
.color-btn { border-radius: 2px !important; }
.color-btn.ring-offset-2 { --tw-ring-offset-color: var(--surface); }

/* ── Mobile responsiveness ───────────────────────── */
@media (max-width: 1023px) {
  #sidebar { box-shadow: 0 20px 60px rgba(0,0,0,0.6); }
  .bookmark-card { padding: 12px; }
  body { overflow-x: hidden; }
  .modal-overlay { overflow-y: auto; }
  #searchOverlay { padding-top: env(safe-area-inset-top); }
}
@media (max-width: 374px) {
  .bookmark-card { padding: 10px; }
  .favicon { width: 24px; height: 24px; font-size: 10px; }
}
@media (min-width: 475px) {
  .xs\:inline { display: inline; }
  .xs\:hidden  { display: none; }
}

/* ── iOS Safe Area ───────────────────────────────── */
@supports (padding: max(0px)) {
  #mobileMenuToggle {
    top: max(1rem, env(safe-area-inset-top));
    left: max(1rem, env(safe-area-inset-left));
  }
  #sidebar { padding-left: max(0px, env(safe-area-inset-left)); }
  /* Keep sidebar user section clear of the iOS home indicator */
  #sidebar > div:last-child {
    padding-bottom: max(12px, env(safe-area-inset-bottom));
  }
  .toast {
    bottom: max(2.5rem, env(safe-area-inset-bottom));
    right: max(1.25rem, env(safe-area-inset-right));
  }
}

/* ══════════════════════════════════════════════════════════
   SEARCH ENGINE LAYOUT
══════════════════════════════════════════════════════════ */

/* ── Nav search bar (search mode) ───────────────────────── */
.nav-search-wrap {
  display: flex;
  align-items: center;
  position: relative;
  flex: 1;
  max-width: 600px;
  margin: 0 12px;
}

@media (min-width: 769px) {
  #navSearchWrap {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    flex: none;
    width: 560px;
    max-width: calc(100% - 280px);
    margin: 0;
    z-index: 1;
  }
}
.nav-search-icon {
  position: absolute;
  left: 11px;
  top: 50%;
  transform: translateY(-50%);
  width: 15px; height: 15px;
  color: var(--text-muted);
  pointer-events: none;
}
.nav-search-input {
  width: 100%;
  padding: 6px 36px 6px 36px !important;
  font-size: 16px !important;
}
.nav-search-clear {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  background: transparent;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  padding: 3px;
  border-radius: 2px;
  display: flex;
  align-items: center;
  line-height: 0;
  transition: color 0.15s;
}
.nav-search-clear:hover { color: var(--text); }

/* ── Search dropdown (typeahead) ───────────────────────── */
.se-search-dropdown {
  top: calc(100% + 6px);
  max-height: 320px;
  overflow: auto;
  padding: 6px 0;
  z-index: 120;
  overscroll-behavior: contain;
}
.se-search-option {
  display: flex !important;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  min-height: 42px;
  max-height: 42px;
  text-decoration: none;
  overflow: hidden;
  line-height: 1.2;
  width: 100% !important;
  max-width: 100% !important;
  box-sizing: border-box !important;
  background: transparent;
  border: 0;
  color: inherit;
  text-align: left;
  cursor: pointer;
}
.se-search-option-body {
  min-width: 0;
  max-width: 100%;
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow: hidden;
}
.se-search-option-title {
  font-family:'Inter',sans-serif;
  font-size: 12px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.se-search-option-domain {
  font-size: 10px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.se-search-option-meta {
  font-size: 9px;
  color: var(--text-dim);
}
.se-search-option-favicon,
.se-search-option-favicon-fb {
  width: 20px;
  min-width: 20px;
  max-width: 20px;
  height: 20px;
  min-height: 20px;
  max-height: 20px;
  border-radius: 3px;
  flex: 0 0 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  contain: strict;
}
.se-search-option-favicon {
  background: var(--surface3);
}
.se-search-option-favicon img {
  display: block;
  width: 14px !important;
  min-width: 14px !important;
  max-width: 14px !important;
  height: 14px !important;
  min-height: 14px !important;
  max-height: 14px !important;
  object-fit: contain;
  flex: 0 0 14px;
}
.se-search-option-favicon-fb {
  font-family:'Inter',sans-serif;
  font-weight: 800;
  font-size: 9px;
  color: #fff;
}
.se-search-option-pdf-logo {
  width: 22px !important;
  min-width: 22px !important;
  max-width: 22px !important;
  height: 22px !important;
  min-height: 22px !important;
  max-height: 22px !important;
  flex: 0 0 22px !important;
  display: grid;
  place-items: center;
  overflow: hidden;
  contain: strict;
}
.se-search-status {
  padding: 10px 12px;
  font-size: 11px;
  color: var(--text-muted);
}

/* ── User avatar button ─────────────────────────────────── */
.se-user-btn {
  width: 30px; height: 30px;
  border-radius: 2px;
  background: var(--accent-dim);
  color: var(--accent);
  font-family:'Inter',sans-serif;
  font-weight: 800;
  font-size: 13px;
  border: 1px solid rgba(232,160,72,0.25);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}
.se-user-btn:hover { background: var(--accent); color: #0e0f11; }
[data-theme="light"] .se-user-btn:hover { color: #fff; }

/* ── Hero section ───────────────────────────────────────── */
.se-home-shell {
  min-height: calc(100vh - 54px);
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 32px 20px 44px;
}
.se-home-shell-list {
  min-height: 0;
  justify-content: flex-start;
  padding: 54px 0 0;
}
.se-home-shell-list .se-hero {
  padding: 0 20px 28px;
}

.se-hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0;
  gap: 18px;
}

.se-logo {
  font-size: 52px;
  font-weight: 800;
  letter-spacing: -2.5px;
  color: var(--text);
  line-height: 1;
  user-select: none;
  margin-bottom: 6px;
}

/* ── Hero search bar ────────────────────────────────────── */
.se-search-wrap {
  position: relative;
  width: 100%;
  max-width: 580px;
}
.se-search-icon {
  position: absolute;
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
  width: 20px; height: 20px;
  color: var(--text-muted);
  pointer-events: none;
}
.se-search-input {
  width: 100%;
  padding: 15px 20px 15px 52px !important;
  font-size: 16px !important;
  border-radius: 2px !important;
  box-shadow: var(--shadow-soft);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.se-search-input:focus {
  box-shadow: 0 0 0 3px rgba(232,160,72,0.18), var(--shadow-soft) !important;
}

/* ── Quick access ───────────────────────────────────────── */
.se-quick-access {
  width: 100%;
  max-width: 720px;
  margin: 46px auto 0;
}
.se-mobile-only {
  display: none;
}
.se-quick-label {
  margin-bottom: 10px;
  font-size: 10px;
  color: var(--text-muted);
  letter-spacing: 0.08em;
  text-align: center;
  text-transform: uppercase;
}
.se-quick-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}
.se-quick-link {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr);
  grid-template-areas:
    "icon title"
    "icon domain";
  align-items: center;
  column-gap: 9px;
  min-width: 0;
  padding: 9px 10px;
  color: var(--text);
  text-decoration: none;
  border: 1px solid transparent;
  border-radius: 4px;
  background: rgba(255,255,255,0.02);
  transition: background 0.15s, border-color 0.15s;
}
.se-quick-link:hover {
  background: var(--surface2);
  border-color: var(--border);
}
.se-quick-favicon {
  grid-area: icon;
  width: 28px;
  height: 28px;
  border-radius: 4px;
  background: var(--surface3);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  color: var(--text-dim);
  font-family:'Inter',sans-serif;
  font-size: 12px;
  font-weight: 800;
}
.se-quick-favicon img {
  width: 18px;
  height: 18px;
  object-fit: contain;
}
.se-quick-favicon-fb {
  background: var(--accent-dim);
  color: var(--accent);
}
.se-quick-title {
  grid-area: title;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family:'Inter',sans-serif;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.25;
}
.se-quick-domain {
  grid-area: domain;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 10px;
  color: var(--text-muted);
}

/* ── Filter pills ───────────────────────────────────────── */
.se-filters {
  display: flex;
  flex-wrap: nowrap;
  gap: 6px;
  justify-content: flex-start;
  width: min(680px, calc(100vw - 32px));
  max-width: 680px;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 2px 4px 8px;
  /* Touch/mobile adds scroll snap below; desktop timing is handled in JS. */
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
  mask-image: linear-gradient(90deg, transparent 0, #000 18px, #000 calc(100% - 18px), transparent 100%);
}
.se-filters.is-dragging {
  cursor: grabbing;
  user-select: none;
}
.se-filters.is-dragging .se-pill {
  pointer-events: none;
}
.se-filters::-webkit-scrollbar {
  display: none;
}
.se-pill {
  display: inline-flex;
  align-items: center;
  flex: 0 0 auto;
  gap: 5px;
  padding: 4px 13px;
  font-size: 11px;
  letter-spacing: 0.02em;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 2px;
  color: var(--text-dim);
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}
.se-pill:hover {
  border-color: var(--border-light);
  color: var(--text);
  background: var(--surface2);
}
.se-pill.active {
  background: var(--accent-dim);
  border-color: rgba(232,160,72,0.35);
  color: var(--accent);
}

/* Compact pills (search results header) */
.se-filters-compact .se-pill {
  padding: 3px 10px;
  font-size: 10px;
}

/* On touch devices allow pills to snap into place for easier tapping; on desktop pointer devices
   we prefer continuous, JS-animated horizontal scrolling without CSS snap which can feel janky. */
@media (hover: none) and (pointer: coarse) {
  .se-filters {
    scroll-snap-type: x proximity;
  }
  .se-pill {
    scroll-snap-align: start;
  }
}

/* ── Home content area ──────────────────────────────────── */
.se-home-content {
  padding: 0 24px 60px;
  max-width: 1400px;
  margin: 0 auto;
}
.se-home-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}
.se-home-label {
  font-family:'Inter',sans-serif;
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.2px;
}
.se-home-count {
  font-size: 10px;
  color: var(--text-muted);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.se-home-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 10px;
}

.se-pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 22px 0 6px;
}

.se-page-btn {
  min-width: 34px;
  height: 32px;
  padding: 0 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  border-radius: 2px;
  background: transparent;
  color: var(--text-dim);
  font-size: 11px;
  text-decoration: none;
  cursor: pointer;
  transition: all 0.15s;
}

.se-page-btn:hover:not(.disabled):not(:disabled) {
  border-color: var(--border-light);
  background: var(--surface2);
  color: var(--text);
}

.se-page-btn.active {
  border-color: rgba(232,160,72,0.35);
  background: var(--accent-dim);
  color: var(--accent);
}

.se-page-btn.disabled,
.se-page-btn:disabled {
  opacity: 0.38;
  cursor: default;
  pointer-events: none;
}

/* ── Empty state ────────────────────────────────────────── */
.se-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 60px 20px;
  text-align: center;
}

/* ── Search results header ──────────────────────────────── */
.se-results-header {
  display: flex;
  align-items: center;
  gap: 16px;
  box-sizing: border-box;
  padding: 10px max(24px, calc((100vw - 720px) / 2));
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  position: sticky;
  top: 54px;
  z-index: 10;
  flex-wrap: wrap;
  max-height: 200px;
  overflow: hidden;
  transition: max-height 0.3s ease, padding 0.3s ease, border-color 0.3s ease;
}
body.filters-collapsed .se-results-header {
  max-height: 0;
  padding-top: 0;
  padding-bottom: 0;
  border-bottom-color: transparent;
}
.se-result-count {
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
  order: 1;
  margin-left: 0;
  flex: 1 1 auto;
  min-width: 0;
  text-align: left;
}
.se-result-count em {
  color: var(--accent);
  font-style: normal;
  font-weight: 600;
}
#searchFilterPills {
  display: flex;
  width: 100%;
  order: 3;
  mask-image: none;
  max-height: 60px;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  transition: max-height 0.3s ease, opacity 0.25s ease, margin 0.25s ease;
}
/* Keep category pills horizontally scrollable in results mode */
#searchFilterPills::-webkit-scrollbar {
  display: none;
}
/* Trailing spacer so the last pill is fully reachable — flex overflow-x:auto
   ignores padding-right, so a pseudo-element is the reliable fix. */
#searchFilterPills::after {
  content: '';
  flex: 0 0 12px;
}
body.filters-collapsed .se-results-header #searchFilterPills {
  max-height: 0;
  opacity: 0;
  margin: 0;
}
.se-scroll-top {
  display: none;
  position: fixed;
  right: 16px;
  bottom: calc(18px + env(safe-area-inset-bottom));
  width: 38px;
  height: 38px;
  min-height: 38px !important;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(232,160,72,0.38);
  border-radius: 50%;
  background: rgba(24, 26, 32, 0.94);
  color: var(--accent);
  box-shadow: 0 12px 32px rgba(0,0,0,0.34);
  z-index: 140;
  opacity: 0;
  transform: translateY(8px);
  pointer-events: none;
  transition: opacity 0.16s ease, transform 0.16s ease;
}

body.show-scroll-top .se-scroll-top {
  display: inline-flex;
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

/* ── Bottom Sheet ───────────────────────────────────────── */
.bs-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.52);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: 210;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.26s ease;
}
.bs-backdrop.open { opacity: 1; pointer-events: auto; }

.bottom-sheet {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 211;
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-bottom: none;
  border-radius: 16px 16px 0 0;
  transform: translateY(110%);
  transition: transform 0.34s cubic-bezier(0.32, 0.72, 0, 1);
  max-height: 85vh;
  max-height: 85dvh;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  will-change: transform;
}
@media (min-width: 500px) {
  .bottom-sheet {
    left: calc(50% - 240px);
    right: auto;
    width: 480px;
    border-radius: 16px 16px 0 0;
  }
}
.bottom-sheet.open { transform: translateY(0); }
.bottom-sheet.bs-dragging { transition: none; }

.bs-drag-zone {
  padding: 10px 0 6px;
  display: flex;
  justify-content: center;
  cursor: grab;
  touch-action: pan-x;
  user-select: none;
}
.bs-handle {
  width: 36px;
  height: 4px;
  background: var(--border-light);
  border-radius: 2px;
}
.bs-section-header {
  padding: 2px 20px 12px;
  border-bottom: 1px solid var(--border);
}
.bs-section-label {
  font-size: 9px;
  font-weight: 500;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.bs-body { padding: 6px 0 calc(20px + env(safe-area-inset-bottom, 0px)); }
.bs-item {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  min-height: 56px;
  padding: 12px 20px;
  background: transparent;
  border: none;
  text-align: left;
  cursor: pointer;
  text-decoration: none;
  color: var(--text);
  transition: background 0.1s;
  box-sizing: border-box;
}
a.bs-item { display: flex; }
.bs-item:hover, .bs-item:active { background: var(--surface2); }
.bs-item-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: var(--surface3);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-dim);
  flex-shrink: 0;
}
.bs-item-copy { flex: 1; min-width: 0; }
.bs-item-label {
  display: block;
  font-size: 17px;
  font-family: 'Inter', sans-serif;
  font-weight: 500;
  color: var(--text);
  line-height: 1.3;
}
.bs-item-meta {
  display: block;
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}
.bs-divider { height: 1px; background: var(--border); margin: 4px 0; }
.bs-item-danger .bs-item-label { color: var(--red); }
.bs-item-danger .bs-item-icon { color: var(--red); background: var(--red-dim); border-color: rgba(240,79,88,0.2); }
.bs-item-danger:hover, .bs-item-danger:active { background: var(--red-dim); }

/* User header in account bottom sheet */
.bs-user-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.bs-user-avatar {
  width: 42px;
  height: 42px;
  border-radius: 10px;
  background: var(--accent-dim);
  border: 1px solid rgba(232,160,72,0.25);
  color: var(--accent);
  font-family:'Inter',sans-serif;
  font-weight: 800;
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.bs-user-info { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.bs-user-name {
  font-family:'Inter',sans-serif;
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.bs-user-email {
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Light theme tweaks */
[data-theme="light"] .bs-backdrop { background: rgba(60,64,67,0.38); }
[data-theme="light"] .bottom-sheet { border-color: var(--border); }

/* ── Results list ───────────────────────────────────────── */
.se-results {
  max-width: 720px;
  width: 100%;
  box-sizing: border-box;
  margin-left: max(24px, calc((100vw - 720px) / 2));
  margin-right: max(24px, calc((100vw - 720px) / 2));
  padding: 4px 24px 80px;
}

.se-result {
  padding: 14px 0 13px;
  border-bottom: 1px solid var(--border);
  transition: opacity 0.2s ease;
}
.se-result:last-child { border-bottom: none; }

.se-result-menu {
  margin-left: auto;
  flex-shrink: 0;
  position: relative;
}
.se-result-menu-btn {
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 2px;
  color: var(--text-muted);
  transition: color 0.15s, opacity 0.15s;
  opacity: 0;
  line-height: 1;
  display: flex;
  align-items: center;
}
.se-result:hover .se-result-menu-btn { opacity: 1; }
.se-result-menu-btn:hover { color: var(--text); }

.se-result-source {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-bottom: 3px;
}
.se-result-favicon {
  width: 16px; height: 16px;
  border-radius: 2px;
  object-fit: contain;
  flex-shrink: 0;
}
.se-result-favicon-fb {
  width: 16px; height: 16px;
  border-radius: 2px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 9px;
  font-weight: 800;
  font-family:'Inter',sans-serif;
  color: #fff;
  flex-shrink: 0;
}
.se-reading-collection-icon {
  width: 22px;
  height: 22px;
  border-radius: 4px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 22px;
  color: var(--collection-color, var(--accent));
  background: color-mix(in srgb, var(--collection-color, var(--accent)) 14%, transparent);
  border: 1px solid color-mix(in srgb, var(--collection-color, var(--accent)) 40%, transparent);
}
.se-reading-collection-icon svg {
  width: 14px;
  height: 14px;
}
.se-search-option-reading-collection-icon {
  width: 22px;
  height: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 22px;
}
.pdf-logo {
  width: 28px !important;
  min-width: 28px !important;
  max-width: 28px !important;
  height: 28px !important;
  min-height: 28px !important;
  max-height: 28px !important;
  display: inline-grid;
  place-items: center;
  flex: 0 0 28px !important;
  overflow: hidden;
  contain: strict;
}
.pdf-logo img {
  width: 100% !important;
  min-width: 100% !important;
  max-width: 100% !important;
  height: 100% !important;
  min-height: 100% !important;
  max-height: 100% !important;
  display: block;
  object-fit: contain;
  flex: 0 0 auto;
}
.se-result-pdf-logo {
  width: 22px !important;
  min-width: 22px !important;
  max-width: 22px !important;
  height: 22px !important;
  min-height: 22px !important;
  max-height: 22px !important;
  flex-basis: 22px !important;
}
.se-result-domain {
  font-size: 12px;
  color: var(--green);
  letter-spacing: 0.01em;
}
[data-theme="light"] .se-result-domain { color: #0d7f4f; }
.se-result-collection {
  font-size: 11px;
  color: var(--text-muted);
}
.se-result-favorite-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
  padding: 2px 6px;
  border: 1px solid rgba(232,160,72,0.28);
  border-radius: 999px;
  background: rgba(232,160,72,0.1);
  color: var(--accent);
  font-size: 9px;
  font-weight: 700;
  line-height: 1.2;
  text-transform: uppercase;
  white-space: nowrap;
}
.se-result-favorite-badge svg {
  flex: 0 0 auto;
}

.se-result-title {
  display: block;
  font-family:'Inter',sans-serif;
  font-size: 16px;
  font-weight: 700;
  color: var(--accent);
  text-decoration: none;
  line-height: 1.24;
  margin: 0 0 4px;
  letter-spacing: -0.28px;
  transition: color 0.12s;
}
.note-result-title {
  width: 100%;
  padding: 0;
  background: transparent;
  border: 0;
  text-align: left;
  cursor: pointer;
}
.se-result-title:hover {
  text-decoration: underline;
  text-decoration-color: rgba(232,160,72,0.5);
}
[data-theme="light"] .se-result-title { color: var(--accent); }

.se-result-desc {
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.52;
  margin: 0 0 7px;
  font-style: normal;
}

.se-result-pdf-excerpt {
  display: flex;
  align-items: baseline;
  gap: 7px;
}

.se-result-pdf-excerpt mark {
  background: rgba(232,160,72,0.22);
  color: var(--text);
  padding: 0 2px;
  border-radius: 2px;
}

.se-result-excerpt-page {
  flex: 0 0 auto;
  color: var(--accent);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.se-result-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}
.se-result-tag {
  font-size: 9px;
  padding: 1px 7px;
  background: var(--surface3);
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: 1px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

/* ── No-results state ───────────────────────────────────── */
.se-no-results {
  text-align: center;
  padding: 80px 20px;
  color: var(--text-muted);
}
.se-no-results .glyph {
  font-size: 36px;
  opacity: 0.18;
  margin-bottom: 14px;
}
.se-add-url-card {
  margin: 20px auto 0;
  width: min(100%, 480px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 14px;
  text-align: left;
  background: var(--surface2);
  border: 1px solid var(--border-light);
  border-radius: 8px;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.04);
}
.se-add-url-copy {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.se-add-url-copy strong {
  color: var(--text);
  font-family:'Inter',sans-serif;
  font-size: 14px;
  line-height: 1.2;
}
.se-add-url-copy span:last-child {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text-muted);
  font-size: 10px;
}
.se-add-url-kicker {
  color: var(--accent) !important;
  font-size: 9px !important;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
.se-add-url-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  gap: 7px;
  padding: 9px 14px;
  border: 1px solid var(--accent);
  border-radius: 2px;
  background: var(--accent);
  color: #0e0f11;
  font-size: 11px;
  font-family:'Inter',sans-serif;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  cursor: pointer;
  transition: all 0.15s;
}
.se-add-url-btn:hover {
  border-color: var(--accent);
  background: #f0b060;
  transform: translateY(-1px);
}

@media (max-width: 560px) {
  .se-add-url-card {
    align-items: stretch;
    flex-direction: column;
  }
  .se-add-url-btn {
    width: 100%;
  }
}

/* ── Responsive ─────────────────────────────────────────── */
@media (max-width: 768px), (hover: none) and (pointer: coarse) {
  .top-navbar {
    height: 50px;
    gap: 10px;
    padding: 0 14px;
  }
  .wordmark-text { font-size: 15px; }
  .wordmark-glyph { font-size: 12px; }
  .nav-btn {
    min-height: 38px !important;
    padding: 0 11px;
    font-size: 10px;
    gap: 5px;
  }
  .se-user-btn {
    width: 38px;
    height: 38px;
    min-height: 38px !important;
  }
  /* Fix the navbar to the top of the visual viewport during search so the iOS
     keyboard can't push it out of view when a search input is focused. */
  body.mobile-search-active .top-navbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    width: 100%;
  }
  body.mobile-search-active #seMain {
    padding-top: 50px;
  }
  body.mobile-search-active .wordmark,
  body.mobile-search-active .sidebar-toggle {
    display: none;
  }
  body.mobile-search-active .top-navbar {
    gap: 0;
  }
  body.mobile-search-active #navSearchWrap {
    display: flex !important;
    flex: 1 1 auto;
    min-width: 0;
    max-width: none;
    margin: 0;
  }
  /* Keep the account avatar visible on mobile search so the bottom sheet
     remains reachable in filtered/search states. */
  body.mobile-search-active .top-navbar > .flex {
    display: flex !important;
    flex: 0 0 auto;
    margin-left: 8px;
  }
  body.mobile-search-active #navSpacer {
    display: none !important;
  }
  body.mobile-search-active .nav-search-input {
    padding-top: 8px !important;
    padding-bottom: 8px !important;
  }
  .se-home-shell {
    min-height: calc(100svh - 50px);
    min-height: calc(100vh - 50px);
    justify-content: center;
    padding: 24px 16px 44px;
  }
  .se-home-shell-list {
    min-height: calc(100svh - 50px);
    min-height: calc(100vh - 50px);
    justify-content: flex-start;
    padding: 36px 16px 44px;
  }
  .se-home-shell-list .se-hero {
    padding: 0;
  }
  .se-hero {
    gap: 16px;
  }
  .se-logo {
    font-size: 44px;
    letter-spacing: -1.8px;
    margin-bottom: 10px;
    text-align: center;
  }
  .se-search-wrap {
    max-width: min(580px, calc(100vw - 48px));
    margin: 0 auto;
  }
  .se-search-input {
    padding-top: 13px !important;
    padding-bottom: 13px !important;
  }
  #homeFilterPills {
    width: calc(100vw - 24px);
    max-width: calc(100vw - 24px);
    padding-left: 12px;
    padding-right: 12px;
    margin-left: -12px;
    margin-right: -12px;
  }
  .se-quick-access {
    max-width: calc(100vw - 32px);
    margin-top: 42px;
  }
  .se-home-content {
    display: none;
  }
  .se-mobile-only {
    display: block;
  }
  .se-results {
    width: auto;
    margin-left: 0;
    margin-right: 0;
    padding-left: 16px;
    padding-right: 16px;
  }
  .se-results-header {
    top: 50px;
    padding: 6px 16px;
    gap: 8px;
    transition: max-height 0.3s ease, padding 0.3s ease, border-color 0.3s ease;
  }
  body.filters-collapsed .se-results-header {
    max-height: 0;
    padding-top: 0;
    padding-bottom: 0;
    border-bottom-color: transparent;
  }
  .se-results-header #searchFilterPills {
    width: 100%;
    max-width: 100%;
    padding-left: 2px;
    padding-right: 2px;
    max-height: 52px;
    mask-image: linear-gradient(to right, #000 80%, transparent 100%);
    transition: max-height 0.3s ease, opacity 0.25s ease, padding 0.25s ease, margin 0.25s ease;
  }
  body.filters-collapsed .se-results-header #searchFilterPills {
    max-height: 0;
    opacity: 0;
    padding-top: 0;
    padding-bottom: 0;
    margin: 0;
  }
  #searchFilterPills.se-filters-compact .se-pill {
    padding: 2px 8px;
    font-size: 9px;
  }
  .se-result-count {
    font-size: 10px;
  }
  .se-result-pdf-logo {
    width: 20px !important;
    min-width: 20px !important;
    max-width: 20px !important;
    height: 20px !important;
    min-height: 20px !important;
    max-height: 20px !important;
    flex-basis: 20px !important;
  }
  .se-pagination {
    justify-content: flex-start;
    overflow-x: auto;
  }
}
.pdfjs-viewer {
  width: 100%;
  height: 100%;
  max-height: 100%;
  flex: 1 1 auto;
  min-height: 0;
  box-sizing: border-box;
  overflow-x: auto;
  overflow-y: scroll;
  background: #1a1a1a;
  padding: 16px;
  -webkit-overflow-scrolling: touch;
  scrollbar-gutter: stable both-edges;
}

.pdfjs-page {
  width: fit-content;
  background: #fff;
  box-shadow: 0 14px 42px rgba(0, 0, 0, 0.42);
  max-width: 100%;
  margin: 0 auto 14px;
  overflow: hidden;
}

.pdfjs-page canvas,
.pdfjs-page img {
  display: block;
  width: 100%;
  height: 100%;
}

.pdfjs-status {
  min-height: 100%;
  display: grid;
  gap: 14px;
  place-items: center;
  color: var(--text-muted);
  font-family: 'Inter', sans-serif;
  font-size: 12px;
}

.pdfjs-loader-ring {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.12);
  border-top-color: var(--accent);
  animation: pdfjs-spin 0.8s linear infinite;
}

.pdfjs-loader-pages {
  display: grid;
  grid-auto-flow: column;
  gap: 7px;
  align-items: end;
}

.pdfjs-loader-pages span {
  width: 28px;
  height: 38px;
  border-radius: 2px;
  background: linear-gradient(180deg, #f4f5f7 0%, #c9ced6 100%);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  animation: pdfjs-page-pulse 1s ease-in-out infinite;
}

.pdfjs-loader-pages span:nth-child(2) {
  animation-delay: 0.12s;
}

.pdfjs-loader-pages span:nth-child(3) {
  animation-delay: 0.24s;
}

@keyframes pdfjs-spin {
  to { transform: rotate(360deg); }
}

@keyframes pdfjs-page-pulse {
  0%, 100% { opacity: 0.42; transform: translateY(0); }
  50% { opacity: 1; transform: translateY(-5px); }
}
