/* ============================================================
   Bookmarker — design system
   ============================================================ */

:root {
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;

  --accent: #6366f1;
  --accent-2: #d946ef;
  --accent-grad: linear-gradient(115deg, #6366f1, #a855f7 45%, #ec4899);
  --star: #fbbf24;
  --danger: #f43f5e;
  --ok: #22c55e;

  --radius: 16px;
  --radius-sm: 10px;
  --radius-lg: 22px;
  --sidebar-w: 268px;
  --ease: cubic-bezier(.22, 1, .36, 1);
  --speed: .28s;
}

html[data-theme="dark"] {
  --bg: #080a14;
  --bg-2: #0d1020;
  --surface: rgba(255, 255, 255, .045);
  --surface-2: rgba(255, 255, 255, .07);
  --surface-3: rgba(255, 255, 255, .11);
  --border: rgba(255, 255, 255, .09);
  --border-strong: rgba(255, 255, 255, .16);
  --text: #eef0f8;
  --text-dim: #a3a9c2;
  --text-faint: #6e7590;
  --shadow: 0 24px 60px -20px rgba(0, 0, 0, .75);
  --shadow-sm: 0 6px 20px -8px rgba(0, 0, 0, .6);
  --glass-blur: saturate(160%) blur(18px);
  --media-bg: #11142a;
  color-scheme: dark;
}

html[data-theme="light"] {
  --bg: #f4f5fb;
  --bg-2: #eceefa;
  --surface: rgba(255, 255, 255, .78);
  --surface-2: rgba(255, 255, 255, .95);
  --surface-3: rgba(15, 23, 42, .06);
  --border: rgba(15, 23, 42, .09);
  --border-strong: rgba(15, 23, 42, .16);
  --text: #10142a;
  --text-dim: #545b78;
  --text-faint: #838aa6;
  --shadow: 0 24px 55px -22px rgba(30, 32, 80, .35);
  --shadow-sm: 0 6px 18px -8px rgba(30, 32, 80, .28);
  --glass-blur: saturate(180%) blur(16px);
  --media-bg: #e7e9f6;
  color-scheme: light;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

body.modal-open { overflow: hidden; }

svg { display: block; width: 20px; height: 20px; }

button, input, select, textarea { font: inherit; color: inherit; }

::selection { background: rgba(168, 85, 247, .35); }

/* scrollbars */
* { scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 20px; border: 3px solid transparent; background-clip: content-box; }
*::-webkit-scrollbar-thumb:hover { background: var(--text-faint); background-clip: content-box; }

.hidden { display: none !important; }
.muted { color: var(--text-dim); }
.small { font-size: 13px; }
.spacer { flex: 1; }
.row { display: flex; align-items: center; }
.gap { gap: 10px; }
.mt { margin-top: 14px; }
.self-start { align-self: flex-start; }
.stack { display: flex; flex-direction: column; gap: 20px; }
.stack.tight { gap: 10px; }

/* ───────────────────────────────────────────── background aurora ── */
.aurora { position: fixed; inset: 0; overflow: hidden; z-index: 0; pointer-events: none; }
.aurora::after {
  content: ""; position: absolute; inset: 0;
  background: radial-gradient(120% 80% at 50% 0%, transparent, var(--bg) 72%);
}
.blob { position: absolute; border-radius: 50%; filter: blur(90px); opacity: .5; }
html[data-theme="light"] .blob { opacity: .35; }
.b1 { width: 46vw; height: 46vw; background: #6366f1; top: -14vw; left: -8vw; animation: drift1 26s var(--ease) infinite alternate; }
.b2 { width: 38vw; height: 38vw; background: #d946ef; top: -6vw; right: -6vw; animation: drift2 32s var(--ease) infinite alternate; }
.b3 { width: 34vw; height: 34vw; background: #06b6d4; bottom: -16vw; left: 32vw; animation: drift3 38s var(--ease) infinite alternate; }
@keyframes drift1 { to { transform: translate3d(6vw, 8vh, 0) scale(1.15); } }
@keyframes drift2 { to { transform: translate3d(-8vw, 12vh, 0) scale(1.2); } }
@keyframes drift3 { to { transform: translate3d(10vw, -8vh, 0) scale(1.1); } }
@media (prefers-reduced-motion: reduce) { .blob { animation: none; } }

.glass {
  background: var(--surface);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: 1px solid var(--border);
}

/* ─────────────────────────────────────────────────────── buttons ── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 40px; padding: 0 16px;
  border-radius: 12px; border: 1px solid var(--border);
  background: var(--surface-2); color: var(--text);
  font-size: 14px; font-weight: 550; cursor: pointer; white-space: nowrap;
  transition: transform var(--speed) var(--ease), background var(--speed), border-color var(--speed), box-shadow var(--speed), opacity var(--speed);
  text-decoration: none;
}
.btn:hover { background: var(--surface-3); border-color: var(--border-strong); transform: translateY(-1px); }
.btn:active { transform: translateY(0) scale(.98); }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }
.btn.primary {
  background: var(--accent-grad); border-color: transparent; color: #fff;
  box-shadow: 0 8px 22px -10px rgba(139, 92, 246, .9);
}
.btn.primary:hover { box-shadow: 0 14px 30px -10px rgba(139, 92, 246, 1); filter: brightness(1.06); }
.btn.ghost { background: transparent; }
.btn.ghost:hover { background: var(--surface-2); }
.btn.danger { background: var(--danger); border-color: transparent; color: #fff; }
.btn.danger:hover { filter: brightness(1.08); }
.btn.ghost.danger { background: transparent; color: var(--danger); border-color: color-mix(in srgb, var(--danger) 35%, transparent); }
.btn.ghost.danger:hover { background: color-mix(in srgb, var(--danger) 14%, transparent); }
.btn.block { width: 100%; }
.btn.big { height: 48px; font-size: 15px; }
.btn.small { height: 32px; padding: 0 12px; font-size: 13px; border-radius: 9px; }
.btn svg { width: 16px; height: 16px; }

.icon-btn {
  display: inline-grid; place-items: center;
  width: 38px; height: 38px; flex: none;
  border-radius: 11px; border: 1px solid transparent;
  background: transparent; color: var(--text-dim); cursor: pointer;
  transition: all var(--speed) var(--ease);
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); border-color: var(--border); }
.icon-btn.tiny { width: 26px; height: 26px; border-radius: 8px; }
.icon-btn.tiny svg { width: 14px; height: 14px; }

.link, .link-btn {
  color: var(--accent-2); cursor: pointer; text-decoration: none;
  background: none; border: 0; padding: 0; font-size: inherit;
}
.link:hover, .link-btn:hover { text-decoration: underline; }

kbd {
  font-family: var(--mono); font-size: 11px; padding: 2px 6px;
  border-radius: 6px; border: 1px solid var(--border-strong);
  background: var(--surface-2); color: var(--text-dim);
}

/* ───────────────────────────────────────────────────────── login ── */
.login { position: relative; z-index: 2; display: grid; place-items: center; height: 100vh; padding: 24px; }
.login-card {
  width: min(400px, 100%); padding: 38px 34px; border-radius: var(--radius-lg);
  box-shadow: var(--shadow); text-align: center;
  animation: pop .5s var(--ease) both;
}
@keyframes pop { from { opacity: 0; transform: translateY(18px) scale(.97); } }
.login-mark {
  width: 60px; height: 60px; margin: 0 auto 16px; border-radius: 18px;
  display: grid; place-items: center; color: #fff; background: var(--accent-grad);
  box-shadow: 0 14px 34px -12px rgba(139, 92, 246, .95);
}
.login-card h1 { margin: 0 0 4px; font-size: 25px; letter-spacing: -.02em; }
.login-card p { margin: 0 0 24px; font-size: 14px; }
.login-error { min-height: 18px; margin: 12px 0 0; color: var(--danger); font-size: 13px; }

/* ──────────────────────────────────────────────────── app layout ── */
.app { position: relative; z-index: 1; display: grid; grid-template-columns: var(--sidebar-w) 1fr; height: 100vh; }

.sidebar {
  display: flex; flex-direction: column; gap: 18px;
  padding: 18px 14px; height: 100vh;
  border-right: 1px solid var(--border);
  background: color-mix(in srgb, var(--bg-2) 72%, transparent);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  z-index: 30;
}

.brand { display: flex; align-items: center; gap: 11px; padding: 4px 8px 2px; }
.brand-mark {
  width: 34px; height: 34px; border-radius: 11px; display: grid; place-items: center;
  color: #fff; background: var(--accent-grad); box-shadow: 0 8px 20px -8px rgba(139, 92, 246, .9);
}
.brand-name { font-weight: 700; font-size: 17px; letter-spacing: -.02em; }
.brand .icon-btn { margin-left: auto; }

.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-item {
  display: flex; align-items: center; gap: 11px;
  padding: 9px 11px; border-radius: 11px; border: 0; cursor: pointer;
  background: transparent; color: var(--text-dim); font-size: 14px; font-weight: 500;
  text-align: left; transition: all .2s var(--ease); position: relative;
}
.nav-item svg { width: 17px; height: 17px; flex: none; opacity: .85; }
.nav-item span { flex: 1; }
.nav-item em {
  font-style: normal; font-size: 11.5px; font-weight: 600; color: var(--text-faint);
  background: var(--surface-2); padding: 2px 7px; border-radius: 20px; min-width: 24px; text-align: center;
}
.nav-item:hover { background: var(--surface); color: var(--text); }
.nav-item.active { background: var(--surface-2); color: var(--text); }
.nav-item.active::before {
  content: ""; position: absolute; left: -14px; top: 50%; translate: 0 -50%;
  width: 3px; height: 20px; border-radius: 0 3px 3px 0; background: var(--accent-grad);
}
.nav-item.active em { background: var(--accent); color: #fff; }

.side-section { display: flex; flex-direction: column; min-height: 0; flex: 1; gap: 8px; }
.side-head { display: flex; align-items: center; padding: 0 10px; }
.side-head h2 { margin: 0; font-size: 11px; letter-spacing: .12em; text-transform: uppercase; color: var(--text-faint); flex: 1; }
.side-head-actions { display: flex; align-items: center; gap: 4px; }
.pill-toggle {
  font-size: 10px; font-weight: 700; letter-spacing: .08em; cursor: pointer;
  padding: 3px 7px; border-radius: 6px; background: var(--surface-2); color: var(--text-faint);
  transition: all .2s var(--ease); user-select: none;
}
.pill-toggle:hover { color: var(--text); }
.pill-toggle[data-mode="any"] { background: color-mix(in srgb, var(--accent) 30%, transparent); color: #fff; }

.tag-search {
  margin: 0 6px; padding: 8px 11px; border-radius: 10px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  font-size: 13px; outline: none; transition: border-color .2s;
}
.tag-search:focus { border-color: var(--accent); }

.tag-list { overflow-y: auto; padding: 2px 4px 4px; display: flex; flex-direction: column; gap: 1px; }
.tag-row {
  display: flex; align-items: center; gap: 9px; padding: 7px 9px;
  border-radius: 9px; cursor: pointer; border: 0; background: transparent;
  color: var(--text-dim); font-size: 13.5px; text-align: left; width: 100%;
  transition: all .18s var(--ease);
}
.tag-row:hover { background: var(--surface); color: var(--text); }
.tag-row.on { background: var(--surface-2); color: var(--text); font-weight: 560; }
.tag-dot { width: 9px; height: 9px; border-radius: 3px; flex: none; box-shadow: 0 0 0 3px color-mix(in srgb, currentColor 12%, transparent); }
.tag-row .name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tag-row .count { font-size: 11px; color: var(--text-faint); }
.tag-empty { padding: 14px 10px; font-size: 12.5px; color: var(--text-faint); text-align: center; }

.sidebar-foot { display: flex; flex-direction: column; gap: 8px; padding-top: 12px; border-top: 1px solid var(--border); }
.foot-row { display: flex; gap: 4px; justify-content: center; }

.sidebar-scrim { display: none; }

/* ────────────────────────────────────────────────────────── main ── */
.main { display: flex; flex-direction: column; min-width: 0; height: 100vh; }

.topbar {
  display: flex; align-items: center; gap: 14px;
  padding: 12px 22px; border: 0; border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--bg) 55%, transparent);
  position: sticky; top: 0; z-index: 20;
}

.search { position: relative; flex: 1; max-width: 520px; }
.search-ico { position: absolute; left: 13px; top: 50%; translate: 0 -50%; width: 17px; height: 17px; color: var(--text-faint); pointer-events: none; }
.search input {
  width: 100%; height: 42px; padding: 0 46px 0 40px;
  border-radius: 13px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); outline: none; font-size: 14px;
  transition: all var(--speed) var(--ease);
}
.search input::placeholder { color: var(--text-faint); }
.search input:focus { border-color: color-mix(in srgb, var(--accent) 65%, transparent); background: var(--surface-2); box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 14%, transparent); }
.search input:focus + .search-kbd { opacity: 0; }
.search-kbd { position: absolute; right: 12px; top: 50%; translate: 0 -50%; transition: opacity .2s; }
.search input::-webkit-search-cancel-button { -webkit-appearance: none; }

.topbar-actions { display: flex; align-items: center; gap: 10px; margin-left: auto; }

.segmented { display: flex; padding: 3px; gap: 2px; border-radius: 12px; background: var(--surface); border: 1px solid var(--border); }
.segmented button {
  display: flex; align-items: center; gap: 7px; height: 34px; padding: 0 12px;
  border: 0; border-radius: 9px; background: transparent; color: var(--text-dim);
  font-size: 13px; font-weight: 550; cursor: pointer; transition: all var(--speed) var(--ease);
}
.segmented button svg { width: 15px; height: 15px; }
.segmented button:hover { color: var(--text); }
.segmented button.active { background: var(--surface-3); color: var(--text); box-shadow: var(--shadow-sm); }

.select-wrap { position: relative; display: flex; }
.select-wrap::after {
  content: ""; position: absolute; right: 13px; top: 50%; translate: 0 -60%;
  width: 7px; height: 7px; border-right: 2px solid var(--text-faint); border-bottom: 2px solid var(--text-faint);
  rotate: 45deg; pointer-events: none;
}
select {
  appearance: none; height: 40px; padding: 0 34px 0 14px;
  border-radius: 12px; border: 1px solid var(--border); background: var(--surface);
  color: var(--text); font-size: 13.5px; cursor: pointer; outline: none;
  transition: all var(--speed) var(--ease);
}
select:hover { border-color: var(--border-strong); }
select option { background: var(--bg-2); color: var(--text); }

.crumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 12px 22px 0; }
.crumbs:empty { display: none; }
.crumb {
  display: inline-flex; align-items: center; gap: 7px; height: 28px; padding: 0 6px 0 11px;
  border-radius: 20px; font-size: 12.5px; font-weight: 550;
  background: var(--surface-2); border: 1px solid var(--border); color: var(--text);
  animation: chipIn .3s var(--ease) both;
}
@keyframes chipIn { from { opacity: 0; transform: scale(.85); } }
.crumb .x { display: grid; place-items: center; width: 18px; height: 18px; border-radius: 50%; border: 0; background: transparent; color: var(--text-faint); cursor: pointer; }
.crumb .x:hover { background: var(--surface-3); color: var(--text); }
.crumb .x svg { width: 11px; height: 11px; }
.crumb-count { font-size: 12.5px; color: var(--text-faint); margin-left: 2px; }

.content { flex: 1; overflow-y: auto; padding: 18px 22px 60px; scroll-behavior: smooth; }

/* ───────────────────────────────────────────────────── tile grid ── */
.grid { display: grid; gap: 18px; grid-template-columns: repeat(auto-fill, minmax(272px, 1fr)); }

.card {
  position: relative; display: flex; flex-direction: column; overflow: hidden;
  border-radius: var(--radius); border: 1px solid var(--border);
  background: var(--surface); backdrop-filter: var(--glass-blur); -webkit-backdrop-filter: var(--glass-blur);
  cursor: pointer; isolation: isolate;
  transition: transform var(--speed) var(--ease), box-shadow var(--speed) var(--ease), border-color var(--speed);
  animation: cardIn .45s var(--ease) both;
  animation-delay: calc(var(--i, 0) * 22ms);
}
@keyframes cardIn { from { opacity: 0; transform: translateY(14px); } }
.card:hover { transform: translateY(-4px); border-color: var(--border-strong); box-shadow: var(--shadow); }
.card::after {
  content: ""; position: absolute; inset: 0; border-radius: inherit; pointer-events: none;
  background: linear-gradient(120deg, transparent 40%, color-mix(in srgb, var(--accent) 12%, transparent));
  opacity: 0; transition: opacity var(--speed);
}
.card:hover::after { opacity: 1; }

.card-media { position: relative; aspect-ratio: 16 / 10; overflow: hidden; background: var(--media-bg); }
.card-media img { width: 100%; height: 100%; object-fit: cover; object-position: top center; display: block; transition: transform .6s var(--ease); }
.card:hover .card-media img { transform: scale(1.05); }
.card-media .fallback {
  position: absolute; inset: 0; display: grid; place-items: center;
  font-size: 46px; font-weight: 800; color: rgba(255, 255, 255, .92); letter-spacing: -.04em;
  text-shadow: 0 4px 18px rgba(0, 0, 0, .3);
}
.card-media .fallback::before {
  content: ""; position: absolute; inset: 0;
  background: radial-gradient(circle at 30% 20%, rgba(255,255,255,.22), transparent 55%);
}
.media-veil { position: absolute; inset: 0; background: linear-gradient(to top, rgba(6,8,18,.82) 0%, rgba(6,8,18,.15) 42%, transparent 70%); }

.card-badges { position: absolute; top: 10px; left: 10px; right: 10px; display: flex; align-items: center; gap: 6px; }
.badge {
  display: inline-flex; align-items: center; gap: 5px; height: 24px; padding: 0 9px;
  border-radius: 20px; font-size: 11.5px; font-weight: 650; color: #fff;
  background: rgba(10, 12, 24, .62); backdrop-filter: blur(8px); border: 1px solid rgba(255,255,255,.14);
}
.badge svg { width: 12px; height: 12px; }
.badge.star-badge { color: var(--star); }
.badge.fav { color: #fb7185; margin-left: auto; }

.card-actions {
  position: absolute; right: 10px; bottom: 10px; display: flex; gap: 6px;
  opacity: 0; translate: 0 8px; transition: all var(--speed) var(--ease);
}
.card:hover .card-actions, .card:focus-within .card-actions { opacity: 1; translate: 0; }
.act {
  display: grid; place-items: center; width: 32px; height: 32px; border-radius: 10px;
  border: 1px solid rgba(255,255,255,.16); background: rgba(10, 12, 24, .68);
  backdrop-filter: blur(8px); color: #fff; cursor: pointer; transition: all .18s var(--ease);
}
.act svg { width: 15px; height: 15px; }
.act:hover { background: var(--accent); border-color: transparent; transform: translateY(-2px); }
.act.del:hover { background: var(--danger); }
.act.on { color: #fb7185; }

.card-body { display: flex; flex-direction: column; gap: 8px; padding: 13px 14px 14px; flex: 1; }
.card-title {
  margin: 0; font-size: 14.5px; font-weight: 620; line-height: 1.35; letter-spacing: -.01em;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.card-host { display: flex; align-items: center; gap: 6px; font-size: 11.5px; color: var(--text-faint); }
.card-host img { width: 14px; height: 14px; border-radius: 3px; flex: none; }
.card-host span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-desc {
  margin: 0; font-size: 12.5px; line-height: 1.5; color: var(--text-dim);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.card-foot { display: flex; align-items: center; gap: 8px; margin-top: auto; padding-top: 4px; }
.chips { display: flex; flex-wrap: wrap; gap: 5px; overflow: hidden; max-height: 22px; }
.chip {
  display: inline-flex; align-items: center; gap: 5px; height: 21px; padding: 0 8px;
  border-radius: 7px; font-size: 11px; font-weight: 560; cursor: pointer;
  background: color-mix(in srgb, var(--c, var(--accent)) 16%, transparent);
  color: color-mix(in srgb, var(--c, var(--accent)) 82%, var(--text));
  border: 1px solid color-mix(in srgb, var(--c, var(--accent)) 26%, transparent);
  transition: all .18s var(--ease);
}
.chip:hover { background: color-mix(in srgb, var(--c, var(--accent)) 32%, transparent); transform: translateY(-1px); }
.chip.more { background: var(--surface-2); color: var(--text-faint); border-color: var(--border); }

/* ─────────────────────────────────────────────────────── ratings ── */
.stars { display: inline-flex; gap: 2px; }
.stars svg { width: 14px; height: 14px; color: var(--text-faint); transition: color .15s, transform .15s var(--ease); }
.stars .on svg { color: var(--star); }
.stars.interactive svg { cursor: pointer; }
.stars.interactive button { border: 0; background: none; padding: 1px; cursor: pointer; line-height: 0; }
/* Buttons are rendered 5→1 and flipped, so `button:hover ~ button` lights everything to the left. */
.stars.interactive { flex-direction: row-reverse; justify-content: flex-end; }
.stars.interactive:hover button svg { color: var(--text-faint); }
.stars.interactive button:hover svg,
.stars.interactive button:hover ~ button svg { color: var(--star); transform: scale(1.12); }
.stars.big svg { width: 26px; height: 26px; }
.stars .lit svg { color: var(--star); }
.rating-wrap { display: flex; align-items: center; gap: 10px; }
.rating-clear { font-size: 12px; color: var(--text-faint); background: none; border: 0; cursor: pointer; }
.rating-clear:hover { color: var(--danger); }

/* ─────────────────────────────────────────────────────── list view ── */
.grid.list { display: flex; flex-direction: column; gap: 8px; }
.grid.list .card { flex-direction: row; align-items: stretch; border-radius: 14px; }
.grid.list .card:hover { transform: translateX(3px); }
.grid.list .card-media { width: 150px; flex: none; aspect-ratio: auto; border-radius: 0; }
.grid.list .media-veil, .grid.list .card-badges, .grid.list .card-actions { display: none; }
.grid.list .card-body { flex-direction: row; align-items: center; gap: 16px; padding: 11px 14px; }
.grid.list .list-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.grid.list .card-title { -webkit-line-clamp: 1; font-size: 14.5px; }
.grid.list .card-desc { -webkit-line-clamp: 1; font-size: 12.5px; }
.grid.list .list-side { display: flex; align-items: center; gap: 14px; flex: none; }
.grid.list .chips { max-height: 22px; flex-wrap: nowrap; }
.grid.list .list-actions { display: flex; gap: 4px; opacity: .35; transition: opacity .2s; }
.grid.list .card:hover .list-actions { opacity: 1; }
.grid.list .list-actions .act { background: var(--surface-2); border-color: var(--border); color: var(--text-dim); }
.grid.list .list-actions .act:hover { color: #fff; }
@media (max-width: 860px) {
  .grid.list .list-side { display: none; }
  .grid.list .card-media { width: 96px; }
}

/* ─────────────────────────────────────────────────── empty state ── */
.empty { display: grid; place-items: center; text-align: center; padding: 80px 20px; gap: 6px; animation: pop .4s var(--ease) both; }
.empty .ico { width: 74px; height: 74px; border-radius: 24px; display: grid; place-items: center; background: var(--surface-2); border: 1px solid var(--border); color: var(--text-faint); margin-bottom: 10px; }
.empty .ico svg { width: 32px; height: 32px; }
.empty h3 { margin: 0; font-size: 18px; }
.empty p { margin: 0 0 12px; color: var(--text-dim); max-width: 380px; font-size: 14px; }

.skeleton { border-radius: var(--radius); height: 268px; background: var(--surface); border: 1px solid var(--border); overflow: hidden; position: relative; }
.skeleton::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent, var(--surface-3), transparent);
  animation: shimmer 1.3s infinite;
}
@keyframes shimmer { from { transform: translateX(-100%); } to { transform: translateX(100%); } }

/* ────────────────────────────────────────────────────────  modals ── */
.modal-root { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 24px; }
.modal-scrim { position: absolute; inset: 0; background: rgba(4, 6, 14, .62); backdrop-filter: blur(6px); animation: fadeIn .25s ease both; }
@keyframes fadeIn { from { opacity: 0; } }
.modal {
  position: relative; width: min(560px, 100%); max-height: min(88vh, 900px);
  display: flex; flex-direction: column; border-radius: var(--radius-lg);
  background: color-mix(in srgb, var(--bg-2) 88%, transparent);
  box-shadow: var(--shadow); overflow: hidden;
  animation: modalIn .35s var(--ease) both;
}
@keyframes modalIn { from { opacity: 0; transform: translateY(20px) scale(.97); } }
.modal-lg { width: min(1000px, 100%); }
.modal-sm { width: min(420px, 100%); }
.modal-head { display: flex; align-items: center; gap: 12px; padding: 18px 20px; border-bottom: 1px solid var(--border); }
.modal-head h2 { margin: 0; font-size: 17px; font-weight: 650; letter-spacing: -.01em; flex: 1; }
.modal-body { padding: 20px; overflow-y: auto; }
.modal-body h2 { margin: 0 0 8px; font-size: 17px; }
.modal-foot { display: flex; align-items: center; gap: 10px; padding: 14px 20px; border-top: 1px solid var(--border); background: var(--surface); }
.foot-msg { font-size: 13px; color: var(--text-dim); }
.foot-msg.err { color: var(--danger); }

/* fields */
.field { display: flex; flex-direction: column; gap: 7px; margin-bottom: 16px; }
.field > span, .field-label { font-size: 12.5px; font-weight: 600; color: var(--text-dim); letter-spacing: .01em; }
.field input[type="text"], .field input[type="password"], .field textarea, .token-row input, .stack.tight input {
  width: 100%; padding: 11px 13px; border-radius: 11px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  outline: none; font-size: 14px; transition: all var(--speed) var(--ease); resize: vertical;
}
.field input:focus, .field textarea:focus, .stack.tight input:focus {
  border-color: color-mix(in srgb, var(--accent) 65%, transparent);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 13%, transparent);
}
.field textarea { line-height: 1.55; min-height: 62px; }
.hint { font-size: 12px; color: var(--text-faint); line-height: 1.5; }
.hint.err { color: var(--danger); }
.hint.ok { color: var(--ok); }
.url-row { display: flex; gap: 8px; }
.url-row input { flex: 1; }

.check { display: inline-flex; align-items: center; gap: 9px; font-size: 13.5px; color: var(--text-dim); cursor: pointer; user-select: none; }
.check input { appearance: none; width: 18px; height: 18px; border-radius: 6px; border: 1.5px solid var(--border-strong); background: var(--surface); cursor: pointer; position: relative; transition: all .2s var(--ease); flex: none; }
.check input:checked { background: var(--accent); border-color: var(--accent); }
.check input:checked::after { content: ""; position: absolute; left: 5px; top: 1.5px; width: 5px; height: 10px; border: 2px solid #fff; border-top: 0; border-left: 0; rotate: 45deg; }

/* editor layout */
.editor-grid { display: grid; grid-template-columns: 1.25fr 1fr; gap: 26px; }
.editor-right { display: flex; flex-direction: column; gap: 10px; }
@media (max-width: 820px) { .editor-grid { grid-template-columns: 1fr; gap: 8px; } }

.tag-input {
  display: flex; flex-wrap: wrap; gap: 6px; align-items: center;
  padding: 8px; min-height: 46px; border-radius: 11px;
  border: 1px solid var(--border); background: var(--surface); cursor: text;
  transition: all var(--speed) var(--ease);
}
.tag-input:focus-within { border-color: color-mix(in srgb, var(--accent) 65%, transparent); box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 13%, transparent); }
.tag-input input { flex: 1; min-width: 130px; border: 0; background: transparent; outline: none; font-size: 13.5px; padding: 3px; }
.tag-token {
  display: inline-flex; align-items: center; gap: 6px; height: 26px; padding: 0 6px 0 10px;
  border-radius: 8px; font-size: 12.5px; font-weight: 560;
  background: color-mix(in srgb, var(--c, var(--accent)) 18%, transparent);
  color: color-mix(in srgb, var(--c, var(--accent)) 85%, var(--text));
  border: 1px solid color-mix(in srgb, var(--c, var(--accent)) 30%, transparent);
  animation: chipIn .22s var(--ease) both;
}
.tag-token button { border: 0; background: none; color: inherit; cursor: pointer; opacity: .65; padding: 0; line-height: 0; }
.tag-token button:hover { opacity: 1; }
.tag-token svg { width: 12px; height: 12px; }
.tag-suggest { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.tag-suggest button {
  height: 24px; padding: 0 9px; border-radius: 7px; font-size: 12px; cursor: pointer;
  background: var(--surface-2); border: 1px dashed var(--border-strong); color: var(--text-dim);
  transition: all .18s var(--ease);
}
.tag-suggest button:hover { color: var(--text); border-style: solid; border-color: var(--accent); transform: translateY(-1px); }

.shot-drop {
  position: relative; aspect-ratio: 16 / 10; border-radius: 14px; overflow: hidden;
  border: 1.5px dashed var(--border-strong); background: var(--media-bg);
  display: grid; place-items: center; cursor: pointer; outline: none;
  transition: all var(--speed) var(--ease);
}
.shot-drop:hover, .shot-drop:focus-visible, .shot-drop.drag { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 8%, var(--media-bg)); }
.shot-drop img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: top center; }
.shot-placeholder { text-align: center; padding: 16px; color: var(--text-faint); display: grid; justify-items: center; gap: 6px; }
.shot-placeholder p { margin: 0; font-size: 13px; color: var(--text-dim); }
.shot-placeholder small { font-size: 11.5px; }
.shot-actions { display: flex; gap: 8px; }
.shot-actions .btn { flex: 1; }
.meta-preview { margin-top: auto; font-size: 12px; color: var(--text-faint); line-height: 1.6; }
.meta-preview b { color: var(--text-dim); font-weight: 600; }

/* detail */
.detail-modal { padding: 0; }
.detail-close { position: absolute; top: 12px; right: 12px; z-index: 3; background: rgba(10,12,24,.55); color: #fff; backdrop-filter: blur(8px); }
.detail-close:hover { background: rgba(10,12,24,.8); color: #fff; }
.detail-hero { position: relative; aspect-ratio: 21 / 9; background: var(--media-bg); overflow: hidden; }
.detail-hero img { width: 100%; height: 100%; object-fit: cover; object-position: top center; }
.detail-hero .veil { position: absolute; inset: 0; background: linear-gradient(to top, color-mix(in srgb, var(--bg-2) 96%, transparent), transparent 65%); }
.detail-hero .fallback { position: absolute; inset: 0; display: grid; place-items: center; font-size: 74px; font-weight: 800; color: rgba(255,255,255,.9); }
.detail-content { padding: 0 26px 24px; margin-top: -46px; position: relative; display: flex; flex-direction: column; gap: 16px; }
.detail-head { display: flex; gap: 14px; align-items: flex-start; }
.detail-fav { width: 44px; height: 44px; border-radius: 13px; background: var(--surface-2); border: 1px solid var(--border); display: grid; place-items: center; flex: none; }
.detail-fav img { width: 24px; height: 24px; border-radius: 5px; }
.detail-head h2 { margin: 0 0 4px; font-size: 22px; letter-spacing: -.02em; line-height: 1.25; }
.detail-head a.host { font-size: 13px; color: var(--accent-2); text-decoration: none; word-break: break-all; }
.detail-head a.host:hover { text-decoration: underline; }
.detail-desc { font-size: 14.5px; line-height: 1.65; color: var(--text-dim); margin: 0; }
.detail-section { border-top: 1px solid var(--border); padding-top: 14px; }
.detail-section h4 { margin: 0 0 8px; font-size: 11px; letter-spacing: .12em; text-transform: uppercase; color: var(--text-faint); }
.detail-review { font-size: 14px; line-height: 1.65; white-space: pre-wrap; margin: 0; }
.detail-review.placeholder { color: var(--text-faint); font-style: italic; }
.detail-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; font-size: 13px; }
.detail-grid div span { display: block; font-size: 11px; color: var(--text-faint); text-transform: uppercase; letter-spacing: .08em; margin-bottom: 2px; }
.detail-actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }

/* settings / install */
.card-block { border: 1px solid var(--border); border-radius: 14px; padding: 16px; background: var(--surface); }
.card-block h3 { margin: 0 0 4px; font-size: 14.5px; }
.card-block p { margin: 0 0 12px; }
.token-row { display: flex; gap: 8px; }
.token-row input { font-family: var(--mono); font-size: 12.5px; }
.steps { margin: 18px 0 14px; padding-left: 20px; display: grid; gap: 9px; font-size: 13.5px; color: var(--text-dim); line-height: 1.55; }
.steps strong { color: var(--text); font-weight: 600; }
.steps code { font-family: var(--mono); font-size: 12.5px; background: var(--surface-2); padding: 2px 7px; border-radius: 6px; color: var(--text); }
.steps li::marker { color: var(--accent-2); font-weight: 700; }

/* toasts */
.toasts { position: fixed; bottom: 22px; left: 50%; translate: -50% 0; z-index: 200; display: flex; flex-direction: column; gap: 9px; align-items: center; pointer-events: none; }
.toast {
  display: flex; align-items: center; gap: 10px; padding: 11px 17px; border-radius: 13px;
  background: color-mix(in srgb, var(--bg-2) 92%, transparent); border: 1px solid var(--border-strong);
  box-shadow: var(--shadow); font-size: 13.5px; font-weight: 520; backdrop-filter: blur(14px);
  animation: toastIn .35s var(--ease) both; pointer-events: auto; max-width: 460px;
}
.toast.out { animation: toastOut .25s ease forwards; }
@keyframes toastIn { from { opacity: 0; transform: translateY(16px) scale(.95); } }
@keyframes toastOut { to { opacity: 0; transform: translateY(10px) scale(.96); } }
.toast .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); flex: none; }
.toast.ok .dot { background: var(--ok); }
.toast.err .dot { background: var(--danger); }
.toast .act-link { color: var(--accent-2); cursor: pointer; font-weight: 600; }

/* theme icon swap */
html[data-theme="dark"] .ico-sun, html[data-theme="light"] .ico-moon { display: none; }

/* ──────────────────────────────────────────────────── responsive ── */
.only-mobile { display: none !important; }

@media (max-width: 1000px) {
  .app { grid-template-columns: 1fr; }
  .only-mobile { display: inline-grid !important; }
  .sidebar {
    position: fixed; inset: 0 auto 0 0; width: 288px;
    transform: translateX(-100%); transition: transform .35s var(--ease);
    background: var(--bg-2);
  }
  .app.sidebar-open .sidebar { transform: none; }
  .sidebar-scrim { display: block; position: fixed; inset: 0; z-index: 25; background: rgba(4,6,14,.6); opacity: 0; pointer-events: none; transition: opacity .3s; }
  .app.sidebar-open .sidebar-scrim { opacity: 1; pointer-events: auto; }
  .topbar { padding: 10px 14px; flex-wrap: wrap; }
  .topbar-actions { width: 100%; }
  .search { max-width: none; order: 3; width: 100%; flex-basis: 100%; }
  .content { padding: 14px; }
  .crumbs { padding: 10px 14px 0; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; }
}
@media (max-width: 620px) {
  .topbar-actions { gap: 8px; }
  .segmented button span, #btn-add span { display: none; }
  #btn-add { width: 40px; padding: 0; }
  .select-wrap { flex: 1; }
  select { width: 100%; }
  .grid { grid-template-columns: 1fr 1fr; gap: 12px; }
  .card-desc { display: none; }
  .modal-root { padding: 0; place-items: end stretch; }
  .modal { max-height: 94vh; border-radius: 22px 22px 0 0; width: 100%; }
}
@media (max-width: 420px) { .grid { grid-template-columns: 1fr; } }
