/* Bundled locally (SIL OFL, see fonts/OFL-*.txt), like everything else this page needs */
@font-face {
  font-family: "Inter";
  src: url("fonts/inter.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
}
@font-face {
  font-family: "Manrope";
  src: url("fonts/manrope.woff2") format("woff2");
  font-weight: 200 800;
  font-display: swap;
}

:root {
  color-scheme: dark;
  --page: #0e1016;
  --page-glow-1: rgba(57, 135, 229, .10);
  --page-glow-2: rgba(144, 133, 233, .08);
  --surface: #161922;
  --surface-2: #1e222d;
  --ink: #eef0f5;
  --ink-2: #b9bdca;
  --muted: #7d8294;
  --border: rgba(255, 255, 255, .07);
  --line: rgba(255, 255, 255, .10);
  --hover: rgba(255, 255, 255, .05);
  --btn-hover: #262b38;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .25);
  --popup-shadow: 0 16px 44px rgba(0, 0, 0, .5);
  --icon-edge: rgba(255, 255, 255, .6);
  --accent: #3987e5;
}
/* data-theme comes from theme.js and app.js */
:root[data-theme="light"] {
  color-scheme: light;
  --page: #f3f4f8;
  --page-glow-1: rgba(42, 120, 214, .08);
  --page-glow-2: rgba(98, 80, 214, .06);
  --surface: #ffffff;
  --surface-2: #f0f2f7;
  --ink: #12141a;
  --ink-2: #4b5060;
  --muted: #6b7080;
  --border: rgba(18, 20, 26, .09);
  --line: rgba(18, 20, 26, .15);
  --hover: rgba(18, 20, 26, .05);
  --btn-hover: #e6e9f0;
  --shadow: 0 1px 2px rgba(18, 20, 26, .05), 0 6px 20px rgba(18, 20, 26, .07);
  --popup-shadow: 0 16px 44px rgba(18, 20, 26, .22);
  --icon-edge: rgba(18, 20, 26, .35);
  --accent: #2a78d6;
}
:root {
  --critical: #d03b3b;
  --series: var(--accent);
  --radius: 16px;
  --font-ui: "Inter", system-ui, "Segoe UI", sans-serif;
  --font-display: "Manrope", "Inter", system-ui, sans-serif;
  --font-features: "cv11", "ss01"; /* of Inter */
}
/* The fonts of an account's own theme: these are what the computer has, and fonts.css holds the rest */
[data-font="standard"] { --font-ui: "Inter", system-ui, "Segoe UI", sans-serif; }
[data-font="system"] { --font-ui: system-ui, "Segoe UI", sans-serif; }
[data-font="serif"] { --font-ui: Georgia, "Times New Roman", "Liberation Serif", serif; }
[data-font="mono"] { --font-ui: ui-monospace, "Cascadia Mono", Menlo, Consolas, "DejaVu Sans Mono", monospace; }
:root[data-font]:not([data-font="standard"]) {
  --font-display: var(--font-ui);
  --font-features: normal;
}
/* An account's own theme: theme.js sets the --own colours, and the rest follows from them */
:root[data-theme="custom"] {
  --page: var(--own-page);
  --page-glow-1: color-mix(in srgb, var(--own-accent) 10%, transparent);
  --page-glow-2: color-mix(in srgb, var(--own-accent) 6%, transparent);
  --surface: var(--own-surface);
  --ink: var(--own-ink);
  --accent: var(--own-accent);
}
:root[data-theme="custom"] .cat {
  color: var(--ink);
  --surface: var(--own-category);
  --ink: var(--own-category-ink);
}
:root[data-theme="custom"], :root[data-theme="custom"] .cat {
  --surface-2: color-mix(in srgb, var(--ink) 7%, var(--surface));
  --ink-2: color-mix(in srgb, var(--ink) 75%, var(--surface));
  --muted: color-mix(in srgb, var(--ink) 58%, var(--surface));
  --border: color-mix(in srgb, var(--ink) 10%, transparent);
  --line: color-mix(in srgb, var(--ink) 16%, transparent);
  --hover: color-mix(in srgb, var(--ink) 6%, transparent);
  --btn-hover: color-mix(in srgb, var(--ink) 13%, var(--surface));
  --icon-edge: color-mix(in srgb, var(--ink) 45%, transparent);
}

/* The fixed colours of the toolbar's buttons. Tabs and categories get theirs from `tint` in app.js. */
.c-blue { --series: #3987e5; }
.c-green { --series: #199e70; }
.c-pink { --series: #d55181; }

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body { margin: 0; }
body {
  /* Side padding that keeps the content at most 1700px wide, while the top bar's background spans the window */
  --gutter: max(24px, calc((100% - 1700px) / 2));
  min-height: 100vh;
  background:
    radial-gradient(1200px 600px at 10% -10%, var(--page-glow-1), transparent 70%),
    radial-gradient(1000px 500px at 95% 0%, var(--page-glow-2), transparent 70%),
    var(--page);
  background-attachment: fixed;
  color: var(--ink);
  font: 14px/1.45 var(--font-ui);
  font-feature-settings: var(--font-features);
  -webkit-font-smoothing: antialiased;
}

button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
a { color: inherit; text-decoration: none; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.caret { width: 12px; height: 12px; }

/* --- top bar --- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px 24px;
  padding: 12px var(--gutter);
  border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--surface) 75%, transparent);
  backdrop-filter: blur(14px);
}
.brand { display: flex; align-items: center; gap: 12px; flex: none; }
.brand img { display: block; border-radius: 10px; box-shadow: 0 4px 14px rgba(57, 135, 229, .35); }
.brand h1 { margin: 0; font: 700 20px/1.2 var(--font-display); letter-spacing: -.01em; white-space: nowrap; }
.top-right { display: flex; align-items: center; justify-content: flex-end; gap: 10px; flex: 1; min-width: 0; }

.finders { display: flex; gap: 10px; flex: 0 1 560px; min-width: 0; }
.finder { position: relative; flex: 1 1 0; min-width: 0; }
.finder > svg {
  position: absolute;
  top: 10px;
  left: 13px;
  width: 16px;
  height: 16px;
  color: var(--muted);
  pointer-events: none;
}
.finder input {
  width: 100%;
  height: 36px;
  padding: 0 14px 0 37px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-2);
  outline: 0;
  transition: border-color .15s, box-shadow .15s;
}
.finder input::placeholder { color: var(--muted); opacity: 1; }
.finder input:focus {
  border-color: color-mix(in srgb, var(--accent) 60%, transparent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent);
}

.suggestions {
  position: absolute;
  z-index: 30;
  top: 100%;
  right: 0;
  width: max(100%, 420px);
  max-width: calc(100vw - 16px);
  max-height: 60vh;
  overflow-y: auto;
  margin-top: 6px;
  padding: 6px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--popup-shadow);
}
.suggestion {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 6px 10px;
  border-radius: 8px;
  text-align: left;
}
.suggestion:hover, .suggestion.selected { background: color-mix(in srgb, var(--series) 14%, transparent); }
.suggestion-text { min-width: 0; flex: 1; }
.suggestion-title, .suggestion-sub { display: block; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.suggestion-title { color: var(--ink); }
.suggestion-sub { font-size: 12px; color: var(--muted); }
.no-match { padding: 6px 10px; color: var(--muted); }

/* --- pills: an icon in its topic's colour, the text stays in ink --- */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 36px;
  padding: 0 14px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-2);
  font-weight: 600;
  white-space: nowrap;
  transition: border-color .15s, background .15s;
}
.pill > svg:first-child { width: 15px; height: 15px; color: var(--series); }
.pill .caret { color: var(--muted); margin-right: -3px; }
.pill:hover:not(:disabled) {
  border-color: color-mix(in srgb, var(--series) 50%, transparent);
  background: color-mix(in srgb, var(--series) 12%, var(--surface-2));
}
.pill:disabled { opacity: .5; cursor: default; }
.top-menu { flex: none; }

/* --- tabs and actions --- */
.toolbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px 24px;
  padding: 16px var(--gutter);
}
.tabs { display: flex; flex-wrap: wrap; gap: 6px; min-width: 0; }
.tab {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 36px;
  padding: 0 14px 0 12px;
  border: 1px solid transparent;
  border-radius: 999px;
  color: var(--ink-2);
  font-weight: 500;
  white-space: nowrap;
  user-select: none;
  transition: border-color .15s, background .15s, color .15s;
}
.tab::before {
  content: "";
  flex: none;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--series);
}
.tab:hover { background: var(--hover); color: var(--ink); }
.tab.active {
  border-color: color-mix(in srgb, var(--series) 55%, transparent);
  background: color-mix(in srgb, var(--series) 20%, transparent);
  color: var(--ink);
  font-weight: 600;
}
.tab.active::before { box-shadow: 0 0 0 3px color-mix(in srgb, var(--series) 25%, transparent); }
.actions { display: flex; gap: 8px; flex: none; }
.link { color: color-mix(in srgb, var(--accent) 75%, var(--ink)); font-weight: 500; }
.link:hover { text-decoration: underline; }

/* --- the board --- */
#board { padding: 0 var(--gutter) 32px; }
.columns {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 16px;
  align-items: start;
}
.column { min-height: 120px; display: flex; flex-direction: column; gap: 16px; }

/* No transform or overflow here: a dragged bookmark is a fixed element inside its category */
.cat {
  min-width: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  transition: border-color .2s;
}
.cat:hover { border-color: color-mix(in srgb, var(--series) 40%, transparent); }
.cat.flash { animation: flash 1.6s ease-out; }
@keyframes flash {
  0%, 40% { box-shadow: 0 0 0 3px var(--series); }
  100% { box-shadow: 0 0 0 3px transparent; }
}
.cat-head {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 48px;
  padding: 0 8px 0 11px;
  border-bottom: 1px solid var(--border);
}
.cat.collapsed .cat-head { border-bottom: 0; }
.cat-head { cursor: grab; }
.icon {
  flex: none;
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 9px;
  color: var(--series);
  background: color-mix(in srgb, var(--series) 18%, transparent);
}
.icon svg { width: 15px; height: 15px; }
.cat-name {
  flex: 1;
  min-width: 0;
  margin: 0;
  font: 600 14px/1.3 var(--font-display);
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.cat-btns { display: flex; flex: none; }
.cat-btn {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 8px;
  color: var(--muted);
  transition: color .15s, background .15s;
}
.cat-btn:hover { color: var(--ink); background: var(--hover); }
.cat-btn svg { width: 15px; height: 15px; }
.chevron svg { transition: transform .15s; }
.cat.collapsed .chevron svg { transform: rotate(-90deg); }
.cat.collapsed .bm-list { display: none; }

.bm-list { list-style: none; margin: 0; padding: 6px; min-height: 26px; }
.bm { display: flex; align-items: center; height: 28px; padding: 0 8px; border-radius: 8px; }
.bm:hover { background: color-mix(in srgb, var(--series) 14%, transparent); }
.bm-link { flex: 1; min-width: 0; display: flex; align-items: center; gap: 9px; color: var(--ink-2); font-size: 13.5px; }
.bm:hover .bm-link { color: var(--ink); }
.bm-title { min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.favicon { width: 16px; height: 16px; flex: none; object-fit: contain; pointer-events: none; color: var(--series); }
/* A faint edge, or black icons like GitHub's vanish on a dark page, and white ones on a light page */
img.favicon { filter: drop-shadow(0 0 1px var(--icon-edge)); }

.sortable-ghost { opacity: .35; }
.sortable-fallback { opacity: .95 !important; box-shadow: 0 12px 30px rgba(0, 0, 0, .55); }
.bm.sortable-fallback, .tab.sortable-fallback { background: var(--surface-2); }
body.dragging, body.dragging * { cursor: grabbing !important; }

.empty { max-width: 460px; margin: 90px auto; text-align: center; color: var(--muted); }
.empty p { margin: 0 0 12px; }
.empty .link { margin: 0 10px; }

/* --- menus --- */
.menu {
  position: fixed;
  z-index: 40;
  min-width: 190px;
  max-height: calc(100vh - 16px);
  overflow-y: auto;
  padding: 6px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--popup-shadow);
}
.menu-item { display: flex; align-items: center; width: 100%; padding: 6px 10px; border-radius: 8px; text-align: left; white-space: nowrap; color: var(--ink-2); }
.menu-item:hover:not(:disabled), .menu-item:focus-visible { background: var(--hover); color: var(--ink); outline: 0; }
.menu-item:disabled { color: var(--muted); opacity: .7; cursor: default; }
.menu-item.danger { color: color-mix(in srgb, var(--critical) 65%, var(--ink)); }
.menu-item.danger:hover:not(:disabled), .menu-item.danger:focus-visible { background: color-mix(in srgb, var(--critical) 18%, transparent); color: color-mix(in srgb, var(--critical) 50%, var(--ink)); }
.menu-item.checked::before { content: "✓"; width: 18px; margin-left: -2px; color: var(--accent); }
.menu-item.unchecked::before { content: ""; width: 18px; margin-left: -2px; }
.menu-sep { height: 1px; margin: 6px 4px; background: var(--border); }
.menu-label { padding: 4px 10px 2px; font-size: 12px; color: var(--muted); }

/* --- sign in --- */
.auth-page { display: grid; place-items: center; padding: 24px 16px; }
.auth { display: grid; gap: 20px; width: min(420px, 100%); }
.auth .brand { justify-content: center; }
.auth-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.auth-card p { font-size: 13px; }
.auth-foot { justify-content: space-between; flex-wrap: wrap; }

/* --- dialogs --- */
dialog {
  width: min(460px, calc(100vw - 32px));
  padding: 0;
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 24px 64px rgba(0, 0, 0, .45);
}
dialog::backdrop { background: rgba(8, 10, 14, .55); backdrop-filter: blur(3px); }
.dialog-head { padding: 16px 20px; border-bottom: 1px solid var(--border); font: 700 16px/1.3 var(--font-display); }
.dialog-body { display: grid; gap: 12px; padding: 16px 20px 4px; }
.dialog-body p { margin: 0; color: var(--ink-2); overflow-wrap: anywhere; }
.field { display: grid; gap: 5px; }
.field > span { font-size: 12px; font-weight: 500; color: var(--muted); }
.field input, .field select {
  width: 100%;
  height: 38px;
  padding: 0 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  outline: 0;
  transition: border-color .15s, box-shadow .15s;
}
.field input:focus, .field select:focus {
  border-color: color-mix(in srgb, var(--accent) 60%, transparent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent);
}
.icon-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.icon-row .btn { height: 32px; padding: 0 12px; font-size: 13px; }
.icon-preview { display: grid; place-items: center; width: 32px; height: 32px; }
.icon-preview .favicon { width: 24px; height: 24px; }
.icon-note { font-size: 12px; color: var(--ink-2); }
.icon-note:empty { display: none; }
.color-preview {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border: 1px solid color-mix(in srgb, var(--series) 40%, transparent);
  border-radius: 12px;
  background: var(--surface-2);
  font: 600 14px/1.3 var(--font-display);
  overflow-wrap: anywhere;
}
.swatches { display: grid; grid-template-columns: repeat(8, 1fr); gap: 10px; }
.swatch { aspect-ratio: 1; border-radius: 50%; background: var(--series); transition: transform .1s; }
.swatch:hover { transform: scale(1.1); }
.swatch[aria-pressed="true"] { outline: 2px solid var(--ink); outline-offset: 2px; }
.color-options { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.btn[aria-pressed="true"] { border-color: var(--ink); }
.color-custom { display: flex; align-items: center; gap: 8px; color: var(--ink-2); cursor: pointer; }
.color-custom input { width: 44px; height: 30px; padding: 2px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface-2); cursor: pointer; }
/* The page behind stays clear while a theme is being made, as it shows the result */
dialog:has(.theme-colors, .theme-grid)::backdrop { background: none; backdrop-filter: none; }
.theme-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  max-height: min(58vh, 500px);
  overflow-y: auto;
  /* Room for the outline of a chosen card, which the scrolling would otherwise cut off */
  padding: 2px;
}
.theme-heading { grid-column: 1 / -1; padding-top: 6px; font-size: 12px; font-weight: 500; color: var(--muted); }
.theme-card {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 0 10px;
  align-items: center;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface-2);
  text-align: left;
  transition: border-color .15s;
}
.theme-card:hover { border-color: var(--line); }
.theme-card[aria-pressed="true"] { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.theme-sample {
  position: relative;
  grid-row: span 2;
  width: 58px;
  height: 42px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--sample-page);
}
.sample-panel { position: absolute; inset: 0 0 auto; height: 9px; background: var(--sample-surface); }
.sample-card {
  position: absolute;
  left: 6px;
  bottom: 5px;
  display: grid;
  place-items: center;
  width: 28px;
  height: 21px;
  border-radius: 4px;
  background: var(--sample-category);
  color: var(--sample-category-ink);
  font-size: 11px;
  font-weight: 700;
}
.sample-dot { position: absolute; right: 7px; bottom: 9px; width: 12px; height: 12px; border-radius: 50%; background: var(--sample-accent); }
.theme-name, .theme-font { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.theme-name { align-self: end; font-weight: 600; }
.theme-font { align-self: start; color: var(--muted); font-size: 12px; }
.theme-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.theme-colors { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px 16px; }
.field input[type="color"] { padding: 3px 4px; cursor: pointer; }
.theme-note { font-size: 12px; }
/* Each row sets its own --font-ui with data-font, so it shows in the font it stands for */
.font-picker { position: relative; }
.font-button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  height: 38px;
  padding: 0 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  text-align: left;
}
.font-button[aria-expanded="true"] {
  border-color: color-mix(in srgb, var(--accent) 60%, transparent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent);
}
.font-button .caret { flex: none; color: var(--muted); }
.font-current, .font-option { font-family: var(--font-ui); font-feature-settings: normal; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.font-list {
  position: absolute;
  z-index: 5;
  top: 100%;
  left: 0;
  right: 0;
  max-height: 250px;
  margin-top: 4px;
  padding: 6px;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--popup-shadow);
  outline: 0;
}
.font-group { padding: 8px 10px 3px; font-size: 12px; font-weight: 500; color: var(--muted); }
.font-option { padding: 5px 10px; border-radius: 8px; font-size: 15px; line-height: 1.5; color: var(--ink-2); cursor: pointer; }
.font-option:hover { background: var(--hover); color: var(--ink); }
.font-option[aria-selected="true"] { background: color-mix(in srgb, var(--accent) 20%, transparent); color: var(--ink); }
.theme-note:empty { display: none; }
.dialog-error { color: color-mix(in srgb, var(--critical) 65%, var(--ink)); min-height: 1.4em; font-size: 13px; }
.dialog-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 6px 20px 18px; }
.btn {
  height: 36px;
  padding: 0 18px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-2);
  font-weight: 500;
  transition: background .15s, border-color .15s;
}
.btn:hover { border-color: var(--line); background: var(--btn-hover); }
.btn.primary { background: var(--accent); border-color: transparent; color: var(--on-accent, #fff); font-weight: 600; }
.btn.primary:hover { background: color-mix(in srgb, var(--accent) 85%, var(--ink)); border-color: transparent; }
.btn.danger { background: var(--critical); border-color: transparent; color: #fff; font-weight: 600; }
.btn.danger:hover { background: color-mix(in srgb, var(--critical) 85%, var(--ink)); border-color: transparent; }
.btn:disabled { opacity: .6; cursor: default; }

.toast {
  position: fixed;
  z-index: 50;
  left: 50%;
  bottom: 22px;
  transform: translateX(-50%);
  max-width: calc(100vw - 32px);
  padding: 10px 18px;
  background: var(--surface-2);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--popup-shadow);
}
.toast.error { border-color: color-mix(in srgb, var(--critical) 60%, transparent); }
.clipboard-text { position: fixed; top: 0; left: 0; width: 1px; height: 1px; opacity: 0; }
