/* Bookmark Haven ------------------------------------------------------------ */

:root {
  --bg: #f6f4fb;
  --surface: #ffffff;
  --surface-2: #f1ecfa;
  --surface-3: #e9e2f7;
  --border: #e1d9f0;
  --border-strong: #cbbfe3;
  --text: #1d1530;
  --muted: #685d80;
  --accent: #6b3fd4;
  --accent-hover: #5a2fc0;
  --accent-soft: #ece4fc;
  --accent-soft-2: #ddd0fa;
  --accent-text: #ffffff;
  --accent-ink: #5126b8;
  --danger: #c0344c;
  --danger-hover: #a52a40;
  --danger-soft: #fbe8ec;
  --ok: #1f7a55;
  --ok-soft: #e3f4ec;
  --info-soft: #ece4fc;
  --star: #d89c00;
  --focus: #8b5cf6;
  --shadow: 0 1px 2px rgb(40 20 80 / 0.06), 0 4px 16px rgb(40 20 80 / 0.06);
  --shadow-pop: 0 8px 30px rgb(40 20 80 / 0.16);
  --radius: 10px;
  --radius-sm: 7px;
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    --bg: #120e1b;
    --surface: #1a1426;
    --surface-2: #221a33;
    --surface-3: #2b2140;
    --border: #31274a;
    --border-strong: #45386a;
    --text: #ece7f7;
    --muted: #a597c4;
    --accent: #a684ff;
    --accent-hover: #b99dff;
    --accent-soft: #2a1f48;
    --accent-soft-2: #36295e;
    --accent-text: #170f29;
    --accent-ink: #c6b0ff;
    --danger: #ff7a8f;
    --danger-hover: #ff97a8;
    --danger-soft: #3a1823;
    --ok: #5fd3a0;
    --ok-soft: #13302a;
    --info-soft: #2a1f48;
    --star: #ffc53d;
    --focus: #b99dff;
    --shadow: 0 1px 2px rgb(0 0 0 / 0.3), 0 4px 16px rgb(0 0 0 / 0.25);
    --shadow-pop: 0 10px 36px rgb(0 0 0 / 0.5);
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #120e1b;
  --surface: #1a1426;
  --surface-2: #221a33;
  --surface-3: #2b2140;
  --border: #31274a;
  --border-strong: #45386a;
  --text: #ece7f7;
  --muted: #a597c4;
  --accent: #a684ff;
  --accent-hover: #b99dff;
  --accent-soft: #2a1f48;
  --accent-soft-2: #36295e;
  --accent-text: #170f29;
  --accent-ink: #c6b0ff;
  --danger: #ff7a8f;
  --danger-hover: #ff97a8;
  --danger-soft: #3a1823;
  --ok: #5fd3a0;
  --ok-soft: #13302a;
  --info-soft: #2a1f48;
  --star: #ffc53d;
  --focus: #b99dff;
  --shadow: 0 1px 2px rgb(0 0 0 / 0.3), 0 4px 16px rgb(0 0 0 / 0.25);
  --shadow-pop: 0 10px 36px rgb(0 0 0 / 0.5);
  color-scheme: dark;
}

/* Mist: light gray with pale blue, sage and amber accents. */
:root[data-theme="mist"] {
  --bg: #eceff3;
  --surface: #ffffff;
  --surface-2: #f3f5f8;
  --surface-3: #e6eaf0;
  --border: #d9dee6;
  --border-strong: #bfc7d3;
  --text: #1b2430;
  --muted: #5b6676;
  --accent: #3a6ea5;
  --accent-hover: #2f5d8e;
  --accent-soft: #e2edf9;
  --accent-soft-2: #cfe0f4;
  --accent-text: #ffffff;
  --accent-ink: #2c5a8c;
  --danger: #b8475a;
  --danger-hover: #9d3a4c;
  --danger-soft: #f8e6e9;
  --ok: #2f7a62;
  --ok-soft: #e2f1ec;
  --info-soft: #e2edf9;
  --star: #c98a1a;
  --focus: #5b8fd0;
  --shadow: 0 1px 2px rgb(30 45 70 / 0.06), 0 4px 16px rgb(30 45 70 / 0.06);
  --shadow-pop: 0 8px 30px rgb(30 45 70 / 0.16);
  color-scheme: light;
}

/* Mist Dark: the Mist palette carried onto deep slate. */
:root[data-theme="mist-dark"] {
  --bg: #13171d;
  --surface: #1a1f27;
  --surface-2: #212732;
  --surface-3: #29303d;
  --border: #2e3644;
  --border-strong: #414b5c;
  --text: #e4e9f0;
  --muted: #97a3b4;
  --accent: #8cb8e6;
  --accent-hover: #a5c8ee;
  --accent-soft: #1e2d40;
  --accent-soft-2: #283b54;
  --accent-text: #0f1a27;
  --accent-ink: #a9cbef;
  --danger: #f08a9a;
  --danger-hover: #f4a3b0;
  --danger-soft: #3a1d24;
  --ok: #6fcfae;
  --ok-soft: #15302a;
  --info-soft: #1e2d40;
  --star: #f2bd55;
  --focus: #a5c8ee;
  --shadow: 0 1px 2px rgb(0 0 0 / 0.3), 0 4px 16px rgb(0 0 0 / 0.25);
  --shadow-pop: 0 10px 36px rgb(0 0 0 / 0.5);
  color-scheme: dark;
}

/* Base -------------------------------------------------------------------- */

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; scroll-padding-top: 104px; scroll-padding-bottom: 80px; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 var(--font);
  min-height: 100vh;
}

h1, h2, h3 { line-height: 1.25; margin: 0; }
h1 { font-size: 1.55rem; font-weight: 700; letter-spacing: -0.01em; }
h2 { font-size: 1.05rem; font-weight: 650; display: flex; align-items: center; gap: 0.45rem; }
p { margin: 0; }
a { color: var(--accent-ink); text-decoration-thickness: 1px; text-underline-offset: 2px; }
code { font-family: var(--mono); font-size: 0.88em; background: var(--surface-2); padding: 0.05em 0.35em; border-radius: 4px; }
[hidden] { display: none !important; }

:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 4px; }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.skip-link { position: absolute; left: -999px; top: 8px; background: var(--accent); color: var(--accent-text); padding: 6px 12px; border-radius: 6px; z-index: 100; }
.skip-link:focus { left: 8px; }

.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.hint { color: var(--muted); font-size: 0.82rem; }
.ico { flex: none; vertical-align: -3px; }

/* Top bar ----------------------------------------------------------------- */

.topbar {
  position: sticky; top: 0; z-index: 30;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--border);
}
.topbar-inner {
  max-width: 1280px; margin: 0 auto; padding: 0 20px;
  display: flex; align-items: center; gap: 20px; min-height: 56px;
}
.brand {
  display: flex; align-items: center; gap: 9px; color: var(--text);
  font-weight: 700; font-size: 1.02rem; text-decoration: none; white-space: nowrap; letter-spacing: -0.01em;
}
.logo-bg { fill: var(--accent); }
.logo-mark { fill: var(--accent-text); }
.mainnav { display: flex; gap: 2px; flex: 1; min-width: 0; overflow-x: auto; scrollbar-width: none; }
.mainnav::-webkit-scrollbar { display: none; }
.mainnav a {
  color: var(--muted); text-decoration: none; padding: 7px 11px; border-radius: 8px;
  font-weight: 550; white-space: nowrap;
}
.mainnav a:hover { color: var(--text); background: var(--surface-2); }
.mainnav a[aria-current="page"] { color: var(--accent-ink); background: var(--accent-soft); }
.topbar-actions { display: flex; align-items: center; gap: 6px; }

/* Theme toggle icon swap */
.when-dark { display: none; }
:root:is([data-theme="dark"], [data-theme="mist-dark"]) .when-dark { display: inline-flex; }
:root:is([data-theme="dark"], [data-theme="mist-dark"]) .when-light { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) .when-dark { display: inline-flex; }
  :root:not([data-theme]) .when-light { display: none; }
}

/* Menus (details/summary) ------------------------------------------------- */

.menu { position: relative; }
.menu > summary { list-style: none; cursor: pointer; }
.menu > summary::-webkit-details-marker { display: none; }
.menu-trigger {
  display: flex; align-items: center; gap: 8px; padding: 4px 8px 4px 4px;
  border-radius: 999px; border: 1px solid transparent;
}
.menu-trigger:hover, .menu[open] > .menu-trigger { background: var(--surface-2); border-color: var(--border); }
.avatar {
  width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center;
  background: var(--accent); color: var(--accent-text); font-weight: 700; font-size: 0.85rem;
}
.menu-name { font-weight: 550; max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.caret {
  width: 0; height: 0; border-left: 4px solid transparent; border-right: 4px solid transparent;
  border-top: 5px solid currentColor; opacity: 0.7; transition: transform 0.15s; margin-left: 2px;
}
.menu[open] > summary .caret { transform: rotate(180deg); }
.menu-panel {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 40; min-width: 220px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow-pop); padding: 6px; display: grid; gap: 2px;
}
.menu-panel.wide { min-width: 290px; }
.menu-meta { padding: 8px 10px 10px; border-bottom: 1px solid var(--border); margin-bottom: 4px; color: var(--muted); font-size: 0.85rem; }
.menu-meta strong { color: var(--text); }
.menu-item {
  display: block; width: 100%; text-align: left; padding: 8px 10px; border-radius: 7px;
  color: var(--text); text-decoration: none; background: none; border: 0; font: inherit; cursor: pointer;
}
.menu-item:hover:not(:disabled) { background: var(--surface-2); }
.menu-item:disabled { color: var(--muted); cursor: not-allowed; }
.danger-zone { border-top: 1px solid var(--border); margin-top: 4px; padding: 10px 6px 4px; display: grid; gap: 8px; }
.danger-zone .field span { font-size: 0.82rem; color: var(--muted); font-weight: 400; }
.menu-form { border-bottom: 1px solid var(--border); margin-bottom: 4px; padding: 6px 6px 10px; display: grid; gap: 8px; }
.menu-form .field span { font-size: 0.82rem; color: var(--muted); font-weight: 400; }
.menu-email { overflow-wrap: anywhere; }

/* Layout ------------------------------------------------------------------ */

.page { max-width: 1280px; margin: 0 auto; padding: 24px 20px 64px; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head p { margin-top: 4px; max-width: 70ch; }
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 18px;
}
.card + .card { margin-top: 16px; }
.card h2 + p, .card h2 + form { margin-top: 10px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.card.narrow { max-width: 520px; margin: 40px auto; }
.two-col { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 16px; align-items: start; }
.two-col > .card + .card { margin-top: 0; }
.stack { display: grid; gap: 14px; }

/* Buttons and fields ------------------------------------------------------ */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 7px 13px; border-radius: 8px; border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--text); font: inherit; font-weight: 600;
  text-decoration: none; cursor: pointer; white-space: nowrap; line-height: 1.3;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
}
.btn:hover { background: var(--surface-2); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
:root:is([data-theme="dark"], [data-theme="mist-dark"]) .btn-danger { color: #2a0b12; }
@media (prefers-color-scheme: dark) { :root:not([data-theme]) .btn-danger { color: #2a0b12; } }
.btn-danger:hover { background: var(--danger-hover); border-color: var(--danger-hover); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }
.btn-small { padding: 4px 9px; font-size: 0.85rem; border-radius: 7px; }
.btn-block { width: 100%; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }

.icon-btn {
  display: inline-grid; place-items: center; width: 30px; height: 30px; padding: 0;
  border-radius: 7px; border: 0; background: transparent; color: var(--muted); cursor: pointer;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn.danger:hover { background: var(--danger-soft); color: var(--danger); }
.link-btn {
  background: none; border: 0; padding: 2px 4px; color: var(--accent-ink); font: inherit;
  font-size: 0.82rem; cursor: pointer; border-radius: 5px;
}
.link-btn:hover { text-decoration: underline; }

input[type="text"], input[type="email"], input[type="url"], input[type="search"], input[type="password"],
input[type="number"], select {
  font: inherit; color: var(--text); background: var(--surface);
  border: 1px solid var(--border-strong); border-radius: 8px; padding: 7px 10px;
  min-width: 0; width: 100%; line-height: 1.3;
}
select {
  appearance: none; padding-right: 30px; cursor: pointer;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 15px) 52%, calc(100% - 10px) 52%;
  background-size: 5px 5px; background-repeat: no-repeat;
}
input:focus, select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 25%, transparent); }
input::placeholder { color: color-mix(in srgb, var(--muted) 80%, transparent); }
input[type="checkbox"], input[type="radio"] { accent-color: var(--accent); width: 15px; height: 15px; margin: 0; cursor: pointer; }

.field { display: grid; gap: 5px; min-width: 0; }
.field > span { font-weight: 600; font-size: 0.86rem; }
.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; }
.form-error {
  background: var(--danger-soft); color: var(--danger); border-radius: 8px;
  padding: 9px 12px; margin: 12px 0; font-weight: 550;
}
.form-error:first-child { margin-top: 0; }

.badge {
  display: inline-block; font-size: 0.72rem; font-weight: 650; padding: 1px 7px; border-radius: 999px;
  background: var(--surface-3); color: var(--muted); vertical-align: 1px; letter-spacing: 0.01em;
}
.badge-accent { background: var(--accent-soft); color: var(--accent-ink); }
.badge-warn { background: color-mix(in srgb, var(--star) 22%, transparent); color: var(--text); }
.count {
  display: inline-block; min-width: 22px; text-align: center; font-size: 0.75rem; font-weight: 650;
  padding: 0 7px; border-radius: 999px; background: var(--surface-3); color: var(--muted);
}

/* Flash messages ---------------------------------------------------------- */

.flash-region { display: grid; gap: 8px; }
.flash-region:not(:empty) { margin-bottom: 16px; }
.flash {
  display: flex; align-items: flex-start; gap: 10px; padding: 10px 10px 10px 14px; border-radius: var(--radius);
  border: 1px solid var(--border); background: var(--surface); box-shadow: var(--shadow);
  border-left: 4px solid var(--accent);
}
.flash-ok { border-left-color: var(--ok); }
.flash-error { border-left-color: var(--danger); background: var(--danger-soft); }
.flash-body { flex: 1; min-width: 0; display: grid; gap: 8px; padding-top: 4px; }
.flash-close { flex: none; }
.copy-field { display: flex; gap: 6px; max-width: 760px; }
.copy-field input { font-family: var(--mono); font-size: 0.82rem; }

/* Footer and release label ------------------------------------------------ */

.site-footer {
  max-width: 1280px; margin: 0 auto; padding: 0 20px 28px; display: flex; justify-content: space-between;
  gap: 12px; color: var(--muted); font-size: 0.78rem;
}
.release {
  font-family: var(--mono); font-size: 0.72rem; color: var(--muted); text-decoration: none; letter-spacing: 0;
}
a.release:hover { color: var(--accent-ink); text-decoration: underline; }
.auth-release { justify-self: end; margin-top: 4px; opacity: 0.8; }
.site-footer .release { margin-left: 4px; }
.whats-new-link { color: var(--muted); text-decoration: none; display: inline-flex; align-items: center; gap: 6px; }
.whats-new-link:hover { color: var(--accent-ink); text-decoration: underline; }
.new-dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--accent); flex: none; }
.menu-item .new-dot { margin-left: 8px; vertical-align: 1px; }
.avatar { position: relative; }
.new-dot.on-avatar {
  position: absolute; top: -1px; right: -1px; width: 9px; height: 9px; box-shadow: 0 0 0 2px var(--surface);
  background: var(--star);
}

/* What's new ---------------------------------------------------------------- */

.releases { display: grid; gap: 16px; max-width: 760px; }
.releases .card + .card { margin-top: 0; }
.release-card.is-current { border-color: var(--accent-soft-2); }
.release-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.release-head time { margin-left: auto; font-size: 0.85rem; font-variant-numeric: tabular-nums; }
.release-summary { margin-top: 8px; }
.release-group {
  margin-top: 14px; font-size: 0.74rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.06em; color: var(--muted);
}
.release-list { margin: 6px 0 0; padding-left: 20px; display: grid; gap: 5px; }
.release-list li::marker { color: var(--accent); }

/* Auth pages -------------------------------------------------------------- */

.auth-page {
  min-height: 100vh; display: grid; place-items: center; padding: 24px 16px;
  background:
    radial-gradient(1200px 600px at 10% -10%, color-mix(in srgb, var(--accent) 16%, transparent), transparent 60%),
    radial-gradient(900px 500px at 110% 110%, color-mix(in srgb, var(--accent) 12%, transparent), transparent 60%);
}
.auth-page .flash-region { width: min(400px, 100%); }
.auth-card {
  position: relative; width: min(400px, 100%); background: var(--surface); border: 1px solid var(--border);
  border-radius: 14px; box-shadow: var(--shadow-pop); padding: 28px; display: grid; gap: 12px;
}
.auth-brand { display: flex; align-items: center; gap: 9px; font-weight: 700; font-size: 1.05rem; margin-bottom: 8px; }
.auth-card h1 { font-size: 1.35rem; }
.auth-card form { margin-top: 6px; }
.auth-foot { font-size: 0.85rem; margin-top: 4px; }
.auth-theme { position: absolute; top: 14px; right: 14px; }
.error-card { text-align: left; display: grid; gap: 10px; justify-items: start; }
.error-code { font-size: 0.85rem; font-weight: 700; color: var(--accent-ink); letter-spacing: 0.06em; }

/* Library ----------------------------------------------------------------- */

.add-panel { position: relative; }
.add-panel > summary { list-style: none; }
.add-panel > summary::-webkit-details-marker { display: none; }
.add-panel[open] > summary { background: var(--accent-hover); }
.add-form {
  position: absolute; right: 0; top: calc(100% + 8px); z-index: 20; width: min(560px, calc(100vw - 32px));
  display: grid; grid-template-columns: 1fr 1fr; gap: 12px; box-shadow: var(--shadow-pop);
}
.field-wide { grid-column: 1 / -1; }
.add-actions { grid-column: 1 / -1; display: flex; align-items: center; gap: 14px; justify-content: flex-end; }
.add-actions .check { margin-right: auto; }

.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 12px; }
.toolbar select { width: auto; max-width: 220px; }
.search { position: relative; flex: 1 1 280px; display: flex; align-items: center; }
.search .ico { position: absolute; left: 10px; color: var(--muted); pointer-events: none; }
.search input { padding-left: 32px; }
.filter-fields { display: contents; }
.filter-toggle { display: none; }
.filter-count {
  display: inline-grid; place-items: center; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px;
  background: var(--accent); color: var(--accent-text); font-size: 0.72rem; font-weight: 700;
}
.toggle-chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 6px 11px; border-radius: 8px; cursor: pointer;
  border: 1px solid var(--border-strong); background: var(--surface); font-weight: 600; user-select: none;
}
.toggle-chip input { position: absolute; opacity: 0; pointer-events: none; }
.toggle-chip .ico { color: var(--muted); }
.toggle-chip:has(input:checked) { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-ink); }
.toggle-chip:has(input:checked) .ico { color: var(--star); }
.toggle-chip:has(input:focus-visible) { outline: 2px solid var(--focus); outline-offset: 2px; }
.sort-menu > summary, .group-menu > summary, .row-menu > summary { list-style: none; }
.sort-menu > summary::-webkit-details-marker, .group-menu > summary::-webkit-details-marker,
.row-menu > summary::-webkit-details-marker { display: none; }
.sort-menu[open] > summary { background: var(--surface-2); }
.sort-menu .menu-panel { min-width: 200px; }
.menu-heading {
  padding: 8px 10px 4px; font-size: 0.72rem; font-weight: 650; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted);
}
.menu-heading + .menu-item { margin-top: 0; }
.menu-item + .menu-heading { border-top: 1px solid var(--border); margin-top: 4px; padding-top: 10px; }
.sort-option { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.sort-option[aria-checked="true"] { background: var(--accent-soft); color: var(--accent-ink); font-weight: 600; }
.menu-item .ico { color: var(--muted); }
.menu-panel .menu-item:has(.ico) { display: flex; align-items: center; gap: 9px; }
.menu-item.danger, .menu-item.danger .ico { color: var(--danger); }
.select-toggle[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent-ink); }
.result-line { margin: 0 0 10px; font-size: 0.88rem; }

.selection-bar {
  position: sticky; bottom: 14px; z-index: 15; display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  background: var(--surface); border: 1px solid var(--accent); border-radius: 12px;
  padding: 8px 10px 8px 14px; margin-top: 12px; box-shadow: var(--shadow-pop);
}
.selection-bar > strong { color: var(--accent-ink); white-space: nowrap; }
.selection-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; flex: 1; }
.selection-done { margin-left: auto; }
.inline-group { display: inline-flex; gap: 4px; align-items: center; }
.inline-group select, .inline-group input { width: auto; max-width: 180px; padding-top: 4px; padding-bottom: 4px; font-size: 0.85rem; }
.inline-group select { padding-right: 28px; }
.btn-danger-outline { background: var(--surface); border-color: var(--danger); color: var(--danger); }
.btn-danger-outline:hover { background: var(--danger-soft); }

/* Bookmark table. Rows show a star, the title with its site, tags and when it
   was added; edit and delete appear on hover or keyboard focus (a menu on touch
   screens), and checkboxes only in select mode. */
.bm-table {
  width: 100%; border-collapse: separate; border-spacing: 0; table-layout: fixed;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow);
}
.c-check { width: 36px; }
.c-star { width: 40px; }
.c-tags { width: 24%; }
.c-date { width: 116px; }
.c-actions { width: 84px; }
.bm-table th, .bm-table td { padding: 0 8px; text-align: left; vertical-align: middle; }
.bm-table .col-check { padding: 0 0 0 12px; text-align: center; }
.bm-table .col-star { padding: 0 0 0 8px; text-align: center; }
.select-head th { height: 40px; background: var(--surface-2); font-weight: 600; font-size: 0.86rem; border-bottom: 1px solid var(--border); }
.select-head th:first-child { border-top-left-radius: var(--radius); }
.select-head th:last-child { border-top-right-radius: var(--radius); }
.select-all-label { cursor: pointer; }
html.js #bulk:not(.is-selecting) .c-check { width: 0; }
html.js #bulk:not(.is-selecting) .col-check { padding: 0; }
html.js #bulk:not(.is-selecting) .col-check > * { display: none; }
html.js #bulk:not(.is-selecting) .select-head { display: none; }

.group-head td { background: var(--surface); border-top: 1px solid var(--border); height: 44px; }
tbody.group:first-of-type .group-head td { border-top: 0; }
#bulk:not(.is-selecting) tbody.group:first-of-type .group-head td:first-child,
#bulk:not(.is-selecting) tbody.group:first-of-type .group-head td:nth-child(2) { border-top-left-radius: var(--radius); }
tbody.group:first-of-type .group-head td:last-child { border-top-right-radius: var(--radius); }
.group-bar { display: flex; align-items: center; gap: 8px; min-width: 0; flex-wrap: wrap; padding: 3px 0; }
.collapse-btn {
  display: inline-flex; align-items: center; gap: 7px; background: none; border: 0; padding: 3px 6px 3px 4px;
  font: inherit; font-weight: 650; color: var(--text); cursor: pointer; min-width: 0; border-radius: 6px;
}
.collapse-btn .ico { color: var(--muted); }
.group-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.group-count { color: var(--muted); font-weight: 500; font-size: 0.86rem; }
.chev {
  width: 7px; height: 7px; border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted);
  transform: rotate(45deg) translate(-2px, -1px); transition: transform 0.15s; flex: none; margin: 0 3px 0 2px;
}
.is-collapsed .chev { transform: rotate(-45deg); }
tbody.is-collapsed .bm-row, tbody.is-collapsed .empty-row { display: none; }
.group-menu { margin-left: auto; }
.group-menu > summary { width: 30px; height: 30px; }
.rename-box { display: inline-flex; gap: 6px; align-items: center; flex: 1 1 260px; max-width: 480px; }
.rename-box input { padding: 4px 8px; }
.rename-box:not([hidden]) ~ .group-menu { display: none; }

.bm-row td { border-top: 1px solid color-mix(in srgb, var(--border) 60%, transparent); height: 52px; padding-top: 6px; padding-bottom: 6px; }
.bm-row:hover td, .bm-row:focus-within td { background: color-mix(in srgb, var(--surface-2) 70%, transparent); }
.bm-row.is-selected td { background: var(--accent-soft); }
tbody.group:last-of-type tr:last-child td:first-child { border-bottom-left-radius: var(--radius); }
tbody.group:last-of-type tr:last-child td:last-child { border-bottom-right-radius: var(--radius); }
.empty-row td { height: 38px; font-size: 0.85rem; border-top: 1px solid color-mix(in srgb, var(--border) 60%, transparent); }
.col-title { overflow: hidden; }
.bm-title {
  display: block; color: var(--text); text-decoration: none; font-weight: 500;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.bm-title:hover { color: var(--accent-ink); text-decoration: underline; }
.bm-title:visited { color: var(--text); }
.bm-host { display: block; color: var(--muted); font-size: 0.8rem; line-height: 1.3; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.col-date { color: var(--muted); font-size: 0.84rem; white-space: nowrap; }
.col-tags { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.chip {
  display: inline-block; font-size: 0.74rem; font-weight: 600; line-height: 1.6; padding: 0 7px; margin-right: 4px;
  border-radius: 999px; background: var(--accent-soft); color: var(--accent-ink); text-decoration: none; white-space: nowrap;
}
a.chip:hover { background: var(--accent-soft-2); }
.bm-table .chip { background: none; border: 1px solid var(--border-strong); color: var(--muted); font-weight: 500; font-size: 0.78rem; line-height: 1.5; }
.bm-table a.chip:hover { border-color: var(--accent); color: var(--accent-ink); background: none; }
.col-actions { white-space: nowrap; text-align: right; }
.row-icons { display: inline-flex; gap: 2px; }
.row-icons .icon-btn { width: 28px; height: 28px; }
.row-menu { display: none; }
.row-menu > summary { width: 32px; height: 32px; }

.star-btn {
  display: inline-grid; place-items: center; width: 28px; height: 28px; padding: 0; border: 0; border-radius: 6px;
  background: none; color: color-mix(in srgb, var(--muted) 55%, transparent); cursor: pointer;
}
.star-btn:hover { color: var(--star); background: var(--surface-2); }
.star-btn.is-on { color: var(--star); }

/* With a mouse, a row's empty star and its edit and delete buttons appear on
   hover; keyboard focus inside the row shows them too. */
@media (hover: hover) {
  .bm-row .star-btn:not(.is-on), .bm-row .row-icons { opacity: 0; }
  .bm-row:hover .star-btn, .bm-row:focus-within .star-btn,
  .bm-row:hover .row-icons, .bm-row:focus-within .row-icons { opacity: 1; }
  .group-menu > summary { opacity: 0; }
  .group-head:hover .group-menu > summary, .group-menu[open] > summary, .group-menu > summary:focus-visible { opacity: 1; }
}
/* Touch screens get a menu per row instead; its panel opens as a sheet at the
   bottom of the screen so the table never clips it. */
@media (hover: none), (max-width: 720px) {
  .row-icons { display: none; }
  .row-menu { display: inline-block; }
  .c-actions { width: 48px; }
  .row-menu .menu-panel, .group-menu .menu-panel {
    position: fixed; left: 12px; right: 12px; top: auto; bottom: 12px; z-index: 60; min-width: 0;
  }
  .row-menu .menu-item, .group-menu .menu-item { padding: 12px 12px; }
}

.empty { text-align: center; padding: 40px 20px; display: grid; gap: 10px; justify-items: center; }

/* Edit page --------------------------------------------------------------- */

.edit-list { display: grid; gap: 10px; }
.edit-row {
  margin: 0; display: grid; gap: 10px; padding: 14px;
  grid-template-columns: minmax(0, 1.2fr) minmax(0, 1.4fr) minmax(0, 0.8fr) minmax(0, 1fr);
}
.card + .edit-row, .edit-row + .edit-row { margin-top: 0; }
.edit-row.has-error { border-color: var(--danger); }
.row-error { grid-column: 1 / -1; color: var(--danger); font-weight: 600; font-size: 0.86rem; }
.sticky-actions {
  position: sticky; bottom: 0; display: flex; justify-content: flex-end; gap: 8px; padding: 12px 0;
  background: linear-gradient(to top, var(--bg) 70%, transparent);
}

/* Manage page ------------------------------------------------------------- */

.inline-create { display: flex; gap: 8px; margin-bottom: 12px; }
.manage-list { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--border); }
.manage-list li { display: flex; align-items: center; gap: 6px; padding: 7px 0; border-bottom: 1px solid var(--border); }
.manage-list li > form:first-child { flex: 1; min-width: 0; }
.rename-row { display: flex; align-items: center; gap: 8px; }
.rename-row input { padding: 5px 9px; border-color: transparent; background: transparent; }
.rename-row input:hover { border-color: var(--border-strong); }
.rename-row input:focus { background: var(--surface); }
.rename-row .btn { opacity: 0; transition: opacity 0.12s; }
.rename-row:focus-within .btn, .manage-list li:hover .rename-row .btn { opacity: 1; }
.count-link {
  flex: none; font-size: 0.78rem; font-weight: 650; min-width: 30px; text-align: center; padding: 1px 8px;
  border-radius: 999px; background: var(--surface-3); color: var(--muted); text-decoration: none;
}
.count-link:hover { background: var(--accent-soft); color: var(--accent-ink); }
.unsorted-li { justify-content: space-between; padding-left: 10px !important; }
.empty-li { padding: 12px 0 !important; }

/* Duplicates -------------------------------------------------------------- */

.dupe-summary { display: grid; gap: 12px; justify-items: start; margin-bottom: 16px; }
.dupe-group { margin: 0 0 12px; padding: 12px; display: grid; gap: 6px; }
.dupe-group legend { float: left; width: 100%; padding: 0 0 6px; margin-bottom: 2px; }
.dupe-key { font-family: var(--mono); font-size: 0.8rem; color: var(--muted); display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dupe-item {
  display: flex; align-items: flex-start; gap: 12px; padding: 10px 12px; border-radius: 8px;
  border: 1px solid var(--border); cursor: pointer; clear: both;
}
.dupe-item:hover { background: var(--surface-2); }
.dupe-item:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.dupe-item input { margin-top: 3px; }
.dupe-main { flex: 1; min-width: 0; display: grid; gap: 2px; }
.dupe-title { font-weight: 600; display: flex; align-items: center; gap: 5px; }
.fav-mark { color: var(--star); display: inline-flex; }
.dupe-url { font-family: var(--mono); font-size: 0.8rem; color: var(--muted); overflow-wrap: anywhere; }
.dupe-meta { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 0.8rem; color: var(--muted); align-items: center; }
.keep-label { font-size: 0.75rem; font-weight: 700; color: var(--accent-ink); opacity: 0; text-transform: uppercase; letter-spacing: 0.05em; }
.dupe-item:has(input:checked) .keep-label { opacity: 1; }
.dupe-actions { display: flex; justify-content: flex-end; padding-top: 4px; }

/* Import ------------------------------------------------------------------ */

.dropzone {
  position: relative; display: grid; gap: 4px; place-items: center; text-align: center; padding: 26px 16px;
  border: 2px dashed var(--border-strong); border-radius: var(--radius); background: var(--surface-2); cursor: pointer;
}
.dropzone:hover, .dropzone:focus-within { border-color: var(--accent); background: var(--accent-soft); }
.dropzone input { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; }
.dz-text { font-weight: 550; overflow-wrap: anywhere; }
.dz-text strong { color: var(--accent-ink); }
.howto { margin-top: 16px; border-top: 1px solid var(--border); padding-top: 12px; }
.howto summary { cursor: pointer; font-weight: 600; color: var(--accent-ink); }
.howto dl { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; margin: 12px 0 0; font-size: 0.88rem; }
.howto dt { font-weight: 650; }
.howto dd { margin: 0; color: var(--muted); }

/* Admin ------------------------------------------------------------------- */

.invite-form { display: flex; flex-wrap: wrap; gap: 12px; align-items: end; }
.invite-form .field { width: 170px; }
.invite-form .field-grow { flex: 1 1 220px; }
.invite-form + .hint { margin-top: 10px; }
.table-wrap { overflow-x: auto; margin: 0 -18px -18px; }
/* An open row menu would be clipped by the scroll box; let it spill out instead. */
.table-wrap:has(details[open]) { overflow: visible; }
.data-table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.data-table th, .data-table td { padding: 9px 18px; text-align: left; border-top: 1px solid var(--border); white-space: nowrap; }
.data-table thead th { font-size: 0.74rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); background: var(--surface-2); }
.data-table td.actions { text-align: right; width: 1%; }
.status { font-size: 0.75rem; font-weight: 650; padding: 1px 8px; border-radius: 999px; }
.status-pending { background: var(--accent-soft); color: var(--accent-ink); }
.status-used { background: var(--ok-soft); color: var(--ok); }
.status-expired { background: var(--surface-3); color: var(--muted); }
.menu-right .menu-panel { text-align: left; white-space: normal; }

/* Account ----------------------------------------------------------------- */

.theme-picker { display: grid; grid-template-columns: repeat(5, minmax(0, 76px)); gap: 8px; }
.theme-option {
  white-space: nowrap; display: grid; gap: 6px; justify-items: center; align-content: start; padding: 8px 4px; border: 1px solid var(--border);
  border-radius: var(--radius); cursor: pointer; font-weight: 600; font-size: 0.78rem; line-height: 1.25; text-align: center; position: relative;
}
.theme-option input { position: absolute; opacity: 0; }
.theme-option:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-ink); }
.theme-option:has(input:focus-visible) { outline: 2px solid var(--focus); outline-offset: 2px; }
.swatch { width: 100%; max-width: 56px; height: 30px; border-radius: 6px; border: 1px solid var(--border-strong); }
.swatch-light { background: linear-gradient(135deg, #ffffff 50%, #ece4fc 50%); }
.swatch-dark { background: linear-gradient(135deg, #1a1426 50%, #36295e 50%); }
.swatch-mist { background: linear-gradient(135deg, #eceff3 50%, #cfe0f4 50%); }
.swatch-mist-dark { background: linear-gradient(135deg, #1a1f27 50%, #283b54 50%); }
.swatch-system { background: linear-gradient(135deg, #ffffff 50%, #1a1426 50%); }

/* Settings layout: a jump menu beside one column of grouped rows. Each row is a
   label, its current value and an action; "Change" opens a form under the row. */
.settings { display: grid; grid-template-columns: 180px minmax(0, 720px); gap: 32px; align-items: start; }
.settings-nav { position: sticky; top: 76px; display: grid; gap: 2px; }
.settings-nav a { color: var(--muted); text-decoration: none; padding: 7px 10px; border-radius: 8px; font-weight: 550; }
.settings-nav a:hover { color: var(--text); background: var(--surface-2); }
.settings-nav a[aria-current="true"] { color: var(--accent-ink); background: var(--accent-soft); }
.settings-group {
  padding: 14px 10px 4px; font-size: 0.72rem; font-weight: 650; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted);
}
.settings-group:first-child { padding-top: 0; }
.settings-main { min-width: 0; }
.settings-section { scroll-margin-top: 76px; }
.settings-section + .settings-section { margin-top: 30px; }
.settings-section > h2 { font-size: 1.02rem; }
.settings-note { color: var(--muted); font-size: 0.88rem; margin: 3px 0 10px; }
.setting-list {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow);
}
.setting-list > * + * { border-top: 1px solid var(--border); }
.setting-row { display: grid; grid-template-columns: 150px minmax(0, 1fr) auto; gap: 6px 16px; align-items: center; padding: 13px 18px; min-height: 58px; }
.setting-label { font-weight: 600; }
.setting-label-wide { grid-column: 1 / 3; cursor: pointer; }
.setting-value { min-width: 0; overflow-wrap: anywhere; }
.setting-action { grid-column: 3; display: flex; align-items: center; justify-content: flex-end; }
details.setting > summary { list-style: none; cursor: pointer; }
details.setting > summary::-webkit-details-marker { display: none; }
details.setting > summary:hover .btn { background: var(--surface-2); }
details.setting > summary:focus-visible { outline-offset: -2px; border-radius: var(--radius); }
details.setting .when-open, details.setting[open] .when-closed { display: none; }
details.setting[open] .when-open { display: inline; }
.setting-panel { display: grid; gap: 12px; padding: 2px 18px 18px 184px; }
.setting-panel .field input { width: 100%; }
.panel-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.panel-actions form { margin: 0; }
.inline-form { display: flex; gap: 8px; }
.inline-form input { flex: 1; min-width: 0; }

/* Segmented control and switch */
.seg { display: inline-flex; justify-self: start; border: 1px solid var(--border-strong); border-radius: 8px; overflow: hidden; }
.seg label { position: relative; cursor: pointer; }
.seg input { position: absolute; opacity: 0; }
.seg span { display: block; padding: 5px 14px; font-weight: 600; font-size: 0.88rem; color: var(--muted); }
.seg label + label span { border-left: 1px solid var(--border-strong); }
.seg input:checked + span { background: var(--accent); color: var(--accent-text); }
.seg input:focus-visible + span { outline: 2px solid var(--focus); outline-offset: -2px; }
input[type="checkbox"].switch {
  appearance: none; position: relative; width: 40px; height: 24px; border-radius: 999px; margin: 0;
  background: var(--border-strong); cursor: pointer; transition: background 0.15s;
}
input[type="checkbox"].switch::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 2px rgb(0 0 0 / 0.25); transition: transform 0.15s;
}
input[type="checkbox"].switch:checked { background: var(--accent); }
input[type="checkbox"].switch:checked::after { transform: translateX(16px); }
@media (prefers-reduced-motion: reduce) { input[type="checkbox"].switch, input[type="checkbox"].switch::after { transition: none; } }
.saved-note { color: var(--ok); font-size: 0.8rem; font-weight: 600; white-space: nowrap; }
.saved-note.is-error { color: var(--danger); }

/* Browser extension keys */
.key-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 1px 12px; align-items: center; padding: 12px 18px; }
.key-row .key-name { overflow-wrap: anywhere; }
.key-row small { grid-column: 1; }
.key-row form { grid-column: 2; grid-row: 1 / span 2; margin: 0; }
.key-form { padding: 14px 18px; }
.setting-list > .howto { padding: 12px 18px; margin: 0; }
.setting-list > .howto > summary { width: fit-content; }
.setting-list > .howto .steps { margin: 10px 0 2px; padding-left: 1.3em; display: grid; gap: 6px; }

@media (max-width: 760px) {
  .settings { grid-template-columns: minmax(0, 1fr); gap: 16px; }
  .settings-nav {
    position: static; display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none;
    margin: 0 -20px; padding: 0 20px;
  }
  .settings-nav::-webkit-scrollbar { display: none; }
  .settings-group { display: none; }
  .settings-nav a { white-space: nowrap; border: 1px solid var(--border); background: var(--surface); }
  .setting-row { grid-template-columns: minmax(0, 1fr) auto; }
  .setting-row > .setting-value { grid-column: 1 / -1; grid-row: 2; }
  .setting-row > .setting-action { grid-column: 2; grid-row: 1; }
  .setting-label-wide { grid-column: 1; }
  .setting-panel { padding: 2px 18px 18px; }
  .theme-picker { grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 5px; }
  .theme-option { font-size: 0.72rem; padding: 6px 2px; }
}

/* Responsive -------------------------------------------------------------- */


/* Favorites --------------------------------------------------------------- */

.fav-grid {
  position: relative; list-style: none; margin: 0; padding: 0; display: grid; gap: 22px 18px;
  grid-template-columns: repeat(auto-fill, minmax(116px, 1fr));
  max-width: calc(9 * 116px + 8 * 18px); /* at most 9 per row, so big screens keep the laptop layout */
}
.fav-tile { position: relative; min-width: 0; -webkit-touch-callout: none; user-select: none; -webkit-user-select: none; }
.fav-tile.is-placeholder { opacity: 0.25; }
.fav-tile.is-placeholder .fav-link { background: var(--surface-2); outline: 2px dashed var(--border-strong); outline-offset: -2px; }
.fav-ghost {
  position: fixed; left: 0; top: 0; z-index: 100; margin: 0; pointer-events: none; list-style: none;
  will-change: transform;
}
.fav-ghost .fav-link { background: var(--surface-2); box-shadow: var(--shadow-pop); transform: scale(1.06); }
.fav-ghost .fav-x { visibility: hidden; }
body.is-dragging-tile, body.is-dragging-tile * { cursor: grabbing !important; }
.fav-link {
  display: grid; justify-items: center; gap: 4px; padding: 14px 6px 8px; border-radius: 16px;
  text-decoration: none; color: var(--text); text-align: center;
}
.fav-link:hover { background: var(--surface-2); }
.fav-icon {
  display: grid; place-items: center; width: 72px; height: 72px; margin-bottom: 6px;
  border-radius: 18px; font-size: 2rem; font-weight: 600; color: #fff;
  box-shadow: var(--shadow); transition: transform 0.12s ease;
}
.fav-link:hover .fav-icon { transform: translateY(-2px); }
.fav-icon > img { width: 48px; height: 48px; border-radius: 10px; object-fit: contain; }
.fav-icon.has-img { background: var(--surface-3); border: 1px solid var(--border); }
/* Only one child is ever laid out, so the grid centers it exactly. */
.fav-icon.has-img > .fav-letter { display: none; }
.fav-name {
  max-width: 100%; font-size: 0.92rem; line-height: 1.3; min-height: 2.6em; overflow: hidden; overflow-wrap: anywhere;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
}
/* Remove button: on hover or keyboard focus with a mouse, and on every tile in
   Edit mode (the only way on touch screens). */
.fav-remove { position: absolute; top: 6px; right: calc(50% - 48px); margin: 0; }
.fav-x {
  display: grid; place-items: center; width: 24px; height: 24px; padding: 0; border: 0; border-radius: 50%;
  background: var(--text); color: var(--bg); box-shadow: var(--shadow); cursor: pointer; opacity: 0;
  transition: opacity 0.12s, transform 0.12s;
}
.fav-x:hover { background: var(--danger); color: #fff; transform: scale(1.08); }
@media (hover: hover) {
  .fav-tile:hover .fav-x, .fav-tile:focus-within .fav-x { opacity: 1; }
}
.fav-x:focus-visible, .is-editing .fav-x { opacity: 1; }
.fav-grid.is-editing .fav-link { cursor: grab; }
.fav-grid.is-editing .fav-icon { animation: fav-wiggle 0.3s ease-in-out infinite alternate; }
.fav-grid.is-editing .fav-tile:nth-child(2n) .fav-icon { animation-delay: -0.15s; }
@keyframes fav-wiggle { from { transform: rotate(-1.5deg); } to { transform: rotate(1.5deg); } }
@media (prefers-reduced-motion: reduce) { .fav-grid.is-editing .fav-icon { animation: none; } }
/* "Add favorite": the last tile, opening a search of bookmarks to star. */
.fav-add-tile { position: relative; min-width: 0; }
.fav-add > summary { list-style: none; cursor: pointer; }
.fav-add > summary::-webkit-details-marker { display: none; }
.fav-add-icon {
  background: none; color: var(--muted); border: 2px dashed var(--border-strong); box-shadow: none;
}
.fav-add-btn:hover .fav-add-icon, .fav-add[open] .fav-add-icon { color: var(--accent-ink); border-color: var(--accent); }
.fav-add-btn .fav-name { color: var(--muted); }
.fav-add-icon .ico { width: 26px; height: 26px; }
.fav-grid.is-editing .fav-add-tile { display: none; }
.fav-add-panel { left: 0; right: auto; width: 340px; max-width: calc(100vw - 32px); padding: 8px; gap: 6px; }
.fav-add-results ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 1px; max-height: 320px; overflow: auto; }
.fav-add-results form { margin: 0; }
.fav-add-option { display: grid; gap: 0; }
.fav-add-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.fav-add-host { color: var(--muted); font-size: 0.8rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fav-add-empty { padding: 8px 10px; font-size: 0.88rem; }
.fav-grid-empty { margin-top: 20px; }
@media (max-width: 720px) {
  .fav-add-icon .ico { width: 22px; height: 22px; }
  .fav-add-panel { position: fixed; left: 12px; right: 12px; top: auto; bottom: 12px; width: auto; z-index: 60; max-height: 70vh; grid-template-rows: auto minmax(0, 1fr); }
  .fav-add-results { min-height: 0; overflow: auto; }
  .fav-add-results ul { max-height: none; }
}
.fav-edit[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent-ink); border-color: var(--accent); }
.edit-hint { margin: -6px 0 14px; padding: 8px 12px; background: var(--accent-soft); color: var(--accent-ink); border-radius: 8px; font-size: 0.88rem; }

.tile-c0 { background: #c2410c; }
.tile-c1 { background: #b91c1c; }
.tile-c2 { background: #be185d; }
.tile-c3 { background: #7e22ce; }
.tile-c4 { background: #4338ca; }
.tile-c5 { background: #0369a1; }
.tile-c6 { background: #0f766e; }
.tile-c7 { background: #15803d; }

/* Weather (Favorites page) ------------------------------------------------ */

.weather {
  display: grid; grid-template-columns: auto 1fr; gap: 4px 14px; align-items: center;
  width: 340px; max-width: 100%; padding: 12px 16px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow);
}
.wx-now { display: flex; align-items: center; gap: 10px; }
.wx-icon { display: grid; place-items: center; color: var(--muted); }
.wx-icon .ico, .wx-days .ico { vertical-align: 0; }
.wx-sun { color: var(--star); stroke: var(--star); }
.wx-moon { stroke: var(--accent-ink); }
.wx-drop { stroke: var(--accent); }
.wx-bolt { stroke: var(--star); }
.wx-temp { font-size: 2rem; font-weight: 700; letter-spacing: -0.02em; line-height: 1; }
.wx-meta { display: grid; gap: 1px; min-width: 0; }
.wx-place {
  display: flex; align-items: center; gap: 4px; min-width: 0;
  font-size: 0.95rem; font-weight: 650;
}
.wx-place > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wx-place .ico { color: var(--muted); flex: none; }
.wx-desc { color: var(--muted); font-size: 0.85rem; }
.wx-nowrap { white-space: nowrap; }
.wx-days {
  grid-column: 1 / -1; display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px;
  list-style: none; margin: 8px 0 0; padding: 10px 0 0; border-top: 1px solid var(--border);
}
.wx-days li { display: grid; justify-items: center; gap: 2px; font-size: 0.8rem; color: var(--muted); }
.wx-day { font-weight: 600; }
.wx-hi { color: var(--text); font-weight: 650; }
.wx-foot { grid-column: 1 / -1; display: flex; justify-content: space-between; gap: 8px; margin-top: 2px; font-size: 0.75rem; color: var(--muted); }
.wx-foot a { text-decoration: none; }
.wx-foot a:hover { text-decoration: underline; }
.wx-setup { grid-template-columns: 1fr; gap: 6px; }
.wx-setup-title { font-size: 0.95rem; }
.wx-setup-title .ico { vertical-align: -5px; }
.wx-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.wx-status:empty { display: none; }
.wx-status { color: var(--muted); }
/* The weather pill in the Favorites heading. It is the summary of a <details>
   menu, so clicking it opens the full forecast below it. */
.fav-head { align-items: center; flex-wrap: nowrap; }
.fav-head > :first-child { flex: 0 0 auto; }
.fav-head-actions { display: flex; align-items: center; gap: 8px; flex: 0 0 auto; }
/* The big search box between the heading and the weather. */
.fav-search { position: relative; flex: 1 1 auto; max-width: 640px; margin: 0 auto; }
.fav-search .search .ico { left: 16px; width: 20px; height: 20px; }
.fav-search input[type="search"] {
  padding: 12px 18px 12px 46px; font-size: 1.1rem; border-radius: 999px; box-shadow: var(--shadow);
}
.fav-search-results:empty { display: none; }
.fav-search-results {
  position: absolute; left: 0; right: 0; top: calc(100% + 8px); z-index: 50; padding: 6px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-pop);
}
.fav-search:not(.is-open) .fav-search-results { display: none; }
.fav-search-results ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 1px; max-height: min(420px, 60vh); overflow: auto; }
.fav-search-item {
  display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: 7px;
  color: var(--text); text-decoration: none;
}
.fav-search-item:hover, .fav-search-item.is-active { background: var(--surface-2); }
.fav-search-icon {
  flex: 0 0 auto; display: grid; place-items: center; width: 28px; height: 28px; border-radius: 7px;
  color: #fff; font-weight: 600; font-size: 0.9rem;
}
.fav-search-text { display: grid; min-width: 0; }
.fav-search-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.fav-search-host { color: var(--muted); font-size: 0.8rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fav-search-empty { padding: 8px 10px; font-size: 0.9rem; }
.fav-search-all {
  display: block; margin-top: 4px; padding: 8px 10px; border-top: 1px solid var(--border);
  color: var(--accent-ink); font-size: 0.88rem; font-weight: 600; text-decoration: none; border-radius: 0 0 7px 7px;
}
.fav-search-all:hover, .fav-search-all.is-active { background: var(--surface-2); }
.wx-menu { position: relative; }
.wx-menu > summary { list-style: none; }
.wx-menu > summary::-webkit-details-marker { display: none; }
.wx-pill {
  display: inline-flex; align-items: center; gap: 8px; padding: 5px 12px 5px 10px; max-width: 240px; min-height: 38px;
  background: var(--surface); color: var(--text); border: 1px solid var(--border-strong); border-radius: 999px;
  font: inherit; cursor: pointer;
}
.wx-pill:hover, .wx-menu[open] > .wx-pill { background: var(--surface-2); }
.wx-pill .ico { vertical-align: 0; color: var(--muted); }
.wx-pill-temp { font-weight: 700; font-size: 1.05rem; }
.wx-pill-place { color: var(--muted); font-size: 0.85rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wx-pill-setup { color: var(--text); font-weight: 600; }
.wx-pill-chev { display: inline-flex; transition: transform 0.15s; }
.wx-menu[open] .wx-pill-chev { transform: rotate(180deg); }
.wx-panel { position: absolute; right: 0; top: calc(100% + 8px); z-index: 40; width: 340px; max-width: calc(100vw - 32px); box-shadow: var(--shadow-pop); }
.wx-loading { width: 120px; cursor: default; }
.wx-loading:hover { background: var(--surface); }
.wx-skel { display: block; width: 100%; height: 12px; border-radius: 6px; background: var(--surface-3); animation: wx-pulse 1.4s ease-in-out infinite; }
@keyframes wx-pulse { 50% { opacity: 0.5; } }
@media (prefers-reduced-motion: reduce) { .wx-skel { animation: none; } }
@media (max-width: 720px) {
  .fav-head { flex-wrap: wrap; }
  .fav-head > :first-child { flex: 1 1 auto; }
  .fav-search { order: 3; flex: 1 0 100%; max-width: none; }
  .fav-search input[type="search"] { font-size: 1rem; padding-top: 10px; padding-bottom: 10px; }
  .wx-pill-place { display: none; }
  .wx-pill-setup { display: inline; }
  .wx-panel { position: fixed; left: 16px; right: 16px; top: auto; margin-top: 8px; width: auto; }
}

/* Weather search results (Account page) */
.wx-results { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.wx-results form { margin: 0; }
.wx-result {
  display: flex; align-items: center; gap: 8px; width: 100%; padding: 8px 10px; border: 0; border-radius: 7px;
  background: none; color: var(--text); font: inherit; text-align: left; cursor: pointer;
}
.wx-result:hover { background: var(--surface-2); }
.wx-result .ico { color: var(--muted); }

@media (max-width: 1100px) {
  .menu-name { display: none; }
}

/* Narrow screens collapse columns to zero width rather than removing cells,
   so every remaining cell stays in its own column. */
@media (max-width: 960px) {
  .c-tags { width: 0; }
  .bm-table .col-tags { padding: 0; }
  .bm-table .col-tags > * { display: none; }
}

@media (max-width: 720px) {
  .topbar-inner { flex-wrap: wrap; gap: 4px 12px; padding: 8px 16px 0; }
  .brand { flex: 1; }
  .mainnav { order: 3; flex-basis: 100%; margin: 0 -16px; padding: 0 12px 6px; }
  .menu-name { display: none; }
  .page { padding: 16px 16px 56px; }
  .selection-bar { bottom: 8px; gap: 8px; }
  .selection-bar > strong { flex-basis: 100%; }
  html { scroll-padding-top: 16px; }
  .c-date { width: 0; }
  .bm-table .col-date { padding: 0; }
  .bm-table .col-date > * { display: none; }
  .c-star { width: 36px; }
  .bm-title { white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
  .rename-row .btn { opacity: 1; }
  .add-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .toolbar .search { flex: 1 0 100%; }
  .toolbar > .filter-toggle, .toolbar > .sort-menu, .toolbar > .select-toggle { flex: 1 1 0; }
  .toolbar > .filter-toggle { display: inline-flex; }
  .toolbar > .sort-menu > summary { width: 100%; }
  .sort-menu .menu-panel { right: auto; left: 50%; transform: translateX(-50%); }
  html.js .filter-fields { display: none; }
  html.js .toolbar.filters-open .filter-fields { display: flex; flex-wrap: wrap; gap: 8px; flex: 1 0 100%; order: 10; }
  .filter-fields select { flex: 1 1 140px; }
  .edit-row { grid-template-columns: 1fr; }
  .add-form { grid-template-columns: 1fr; position: fixed; left: 16px; right: 16px; top: 110px; width: auto; max-height: calc(100vh - 130px); overflow: auto; }
  .add-actions { flex-wrap: wrap; }
  .toolbar select { max-width: none; }
  .menu-panel.wide { min-width: 260px; }
  .inline-group select, .inline-group input { max-width: 140px; }
  .fav-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px 6px; }
  .fav-link { padding: 8px 2px 6px; }
  .fav-icon { width: 58px; height: 58px; border-radius: 15px; font-size: 1.5rem; margin-bottom: 4px; }
  .fav-icon > img { width: 38px; height: 38px; border-radius: 8px; }
  .fav-name { font-size: 0.76rem; line-height: 1.25; min-height: 2.5em; }
  .fav-remove { right: calc(50% - 40px); top: 0; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}

/* Browser extension card (Account page) ----------------------------------- */

.setting-list > .howto code { font-family: var(--mono); font-size: 0.88em; background: var(--surface-2); padding: 1px 5px; border-radius: 5px; overflow-wrap: anywhere; }
