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

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: "Inter var", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-feature-settings: "cv02", "cv03", "cv04", "cv11";
  background: var(--bg);
  color: var(--fg);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100dvh;
}

/* ----------------------------------------------------------------- tokens */
:root {
  color-scheme: light;

  --bg: #fafafb;
  --surface: #ffffff;
  --surface-2: #f3f4f7;
  --surface-3: #e9ebf0;
  --surface-glass: rgba(255, 255, 255, .72);

  --fg: #0c0e14;
  --fg-muted: #545c6b;
  --fg-subtle: #8992a1;

  --border: #e8eaf0;
  --border-strong: #d5d9e2;

  --accent: #3d5afe;
  --accent-2: #7c3aed;
  --accent-3: #06b6d4;
  --accent-fg: #ffffff;
  --accent-soft: #edf0ff;
  --accent-ring: rgba(61, 90, 254, .18);

  --danger: #d13c30;
  --danger-soft: #fdeceb;
  --success: #12795a;
  --success-soft: #e4f5ef;
  --warn: #91600a;
  --warn-soft: #fdf4e3;

  --radius-2xl: 28px;
  --radius-xl: 22px;
  --radius-lg: 16px;
  --radius: 12px;
  --radius-sm: 9px;

  --shadow-sm: 0 1px 2px rgba(12, 14, 20, .05);
  --shadow-md: 0 1px 2px rgba(12, 14, 20, .05), 0 6px 18px rgba(12, 14, 20, .06);
  --shadow-lg: 0 2px 4px rgba(12, 14, 20, .06), 0 18px 44px rgba(12, 14, 20, .11);
  --shadow-accent: 0 2px 4px rgba(12, 14, 20, .05), 0 16px 36px var(--accent-ring);

  --ease: cubic-bezier(.22, .61, .36, 1);
  /* Overshoots slightly — used for lifts and pop-ins, not for colour fades. */
  --ease-spring: cubic-bezier(.34, 1.4, .64, 1);
  --ease-out: cubic-bezier(.16, 1, .3, 1);

  /* Tint laid over a surface to make hover states read without a colour swap. */
  --tint: color-mix(in srgb, var(--accent) 5%, transparent);
  --tint-strong: color-mix(in srgb, var(--accent) 11%, transparent);
}

/* Dark tokens apply on system preference unless light is explicitly pinned,
   and always when dark is explicitly pinned. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { color-scheme: dark; }
}

:root[data-theme="dark"] { color-scheme: dark; }

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0a0c11;
    --surface: #12151c;
    --surface-2: #191d26;
    --surface-3: #222733;
    --surface-glass: rgba(18, 21, 28, .72);

    --fg: #e9ecf2;
    --fg-muted: #99a2b2;
    --fg-subtle: #6b7484;

    --border: #232833;
    --border-strong: #313848;

    --accent: #6b86ff;
    --accent-2: #a273f7;
    --accent-3: #3ecfe0;
    --accent-fg: #070910;
    --accent-soft: #191f38;
    --accent-ring: rgba(107, 134, 255, .22);

    --danger: #ff8175;
    --danger-soft: #33191a;
    --success: #45d3a0;
    --success-soft: #0e281f;
    --warn: #e9b65f;
    --warn-soft: #2c2415;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .5);
    --shadow-md: 0 1px 2px rgba(0, 0, 0, .5), 0 6px 18px rgba(0, 0, 0, .38);
    --shadow-lg: 0 2px 4px rgba(0, 0, 0, .5), 0 18px 44px rgba(0, 0, 0, .5);
    --shadow-accent: 0 2px 4px rgba(0, 0, 0, .5), 0 16px 36px var(--accent-ring);
  }
}

:root[data-theme="dark"] {
  --bg: #0a0c11;
  --surface: #12151c;
  --surface-2: #191d26;
  --surface-3: #222733;
  --surface-glass: rgba(18, 21, 28, .72);

  --fg: #e9ecf2;
  --fg-muted: #99a2b2;
  --fg-subtle: #6b7484;

  --border: #232833;
  --border-strong: #313848;

  --accent: #6b86ff;
  --accent-2: #a273f7;
  --accent-3: #3ecfe0;
  --accent-fg: #070910;
  --accent-soft: #191f38;
  --accent-ring: rgba(107, 134, 255, .22);

  --danger: #ff8175;
  --danger-soft: #33191a;
  --success: #45d3a0;
  --success-soft: #0e281f;
  --warn: #e9b65f;
  --warn-soft: #2c2415;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .5);
  --shadow-md: 0 1px 2px rgba(0, 0, 0, .5), 0 6px 18px rgba(0, 0, 0, .38);
  --shadow-lg: 0 2px 4px rgba(0, 0, 0, .5), 0 18px 44px rgba(0, 0, 0, .5);
  --shadow-accent: 0 2px 4px rgba(0, 0, 0, .5), 0 16px 36px var(--accent-ring);
}

::selection { background: var(--accent); color: var(--accent-fg); }

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

/* Aurora wash behind the top of the page. Three offset blobs on a very slow
   drift — enough to feel alive on a second look, not enough to notice while
   reading. Fixed + pointer-events:none so it never intercepts a click. */
body::before {
  content: "";
  position: fixed;
  inset: -35% -10% auto -10%;
  height: 75vh;
  pointer-events: none;
  z-index: 0;
  background:
    radial-gradient(45% 45% at 18% 42%, color-mix(in srgb, var(--accent) 26%, transparent), transparent 70%),
    radial-gradient(42% 46% at 78% 18%, color-mix(in srgb, var(--accent-2) 22%, transparent), transparent 70%),
    radial-gradient(38% 40% at 52% 60%, color-mix(in srgb, var(--accent-3) 16%, transparent), transparent 70%);
  filter: blur(18px);
  opacity: .85;
  animation: drift 34s var(--ease) infinite alternate;
}

@keyframes drift {
  from { transform: translate3d(-2.5%, -1.5%, 0) scale(1); }
  to   { transform: translate3d(2.5%, 2%, 0) scale(1.1); }
}

/* Fine grain, so the large flat areas and the gradients above do not band on
   wide displays. Screen-blended at very low alpha. */
body::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  opacity: .022;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* ---------------------------------------------------------------- layout */
.wrap {
  width: min(1240px, 100% - 2.5rem);
  margin-inline: auto;
  position: relative;
  z-index: 1;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 40;
  border-bottom: 1px solid var(--border);
  background: var(--surface-glass);
  backdrop-filter: saturate(180%) blur(16px);
  -webkit-backdrop-filter: saturate(180%) blur(16px);
  transition: background .3s var(--ease), border-color .3s var(--ease), box-shadow .3s var(--ease);
}

.site-header.is-scrolled {
  box-shadow: 0 1px 0 color-mix(in srgb, var(--fg) 4%, transparent), 0 8px 28px -22px rgba(12, 14, 20, .5);
}

/* Opt-in on the portal page only: dissolve into the aurora until the page
   moves. Admin has no portal.js to set `.is-scrolled`, so it keeps the solid
   header above and must not get this modifier. */
.site-header--fade:not(.is-scrolled) {
  background: transparent;
  border-bottom-color: transparent;
}

.site-header__inner {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .85rem 0;
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: .7rem;
  font-weight: 640;
  font-size: 1rem;
  letter-spacing: -.015em;
  color: var(--fg);
  text-decoration: none;
  margin-right: auto;
  min-width: 0;
}

.brand span:not(.brand__mark) {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.brand__mark {
  position: relative;
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 11px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2) 55%, var(--accent-3));
  color: #fff;
  font-size: .95rem;
  flex: none;
  box-shadow: 0 3px 10px var(--accent-ring), inset 0 1px 0 rgba(255, 255, 255, .3);
  transition: transform .35s var(--ease-spring);
}

.brand:hover .brand__mark { transform: rotate(-8deg) scale(1.06); }

/* -------------------------------------------------------------- watermark */
/* The h1, taken out of flow. It is fixed to the viewport and sits behind the
   page content, so the title reads as a background wash rather than a block
   that pushes everything down. z-index is negative because `main.wrap` is a
   stacking context (position + z-index): at 0 it would paint over the cards. */
.watermark {
  position: fixed;
  z-index: -1;
  top: 8vh;
  left: 50%;
  transform: translateX(-50%);
  width: min(1500px, 96vw);
  margin: 0;
  pointer-events: none;
  user-select: none;
  -webkit-user-select: none;
  text-align: center;
  text-wrap: balance;
  font-size: clamp(3.4rem, 14vw, 12rem);
  font-weight: 800;
  line-height: .9;
  letter-spacing: -.055em;
  text-transform: uppercase;
  /* A flat, very faint fill rather than an outline: no dependency on
     -webkit-text-stroke, so there is nothing to feature-detect and no engine
     on which the letters can vanish. Tracks --fg, so it inverts with theme. */
  color: color-mix(in srgb, var(--fg) 6%, transparent);
}

@media (max-width: 640px) {
  .watermark { top: 6vh; }
}

/* ------------------------------------------------------------------- lede */
/* Eyebrow and subtitle on one line, directly under the header. */
.lede {
  display: flex;
  align-items: center;
  gap: .8rem;
  flex-wrap: wrap;
  padding: 1.5rem 0 0;
  margin-bottom: 1rem;
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  padding: .3rem .7rem .3rem .55rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-glass);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  box-shadow: var(--shadow-sm);
  font-size: .74rem;
  font-weight: 600;
  letter-spacing: .07em;
  text-transform: uppercase;
  white-space: nowrap;
  color: var(--fg-muted);
}

.eyebrow__dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent-3));
  box-shadow: 0 0 0 3px var(--accent-ring);
  animation: pulse 2.8s var(--ease) infinite;
}

@keyframes pulse {
  50% { box-shadow: 0 0 0 6px transparent; }
}

.lede p {
  margin: 0;
  color: var(--fg-muted);
  max-width: 56ch;
  font-size: .95rem;
  text-wrap: pretty;
}

main { padding-bottom: 5rem; position: relative; z-index: 1; }

/* --------------------------------------------------------------- controls */
.toolbar {
  display: flex;
  gap: .7rem;
  align-items: center;
  flex-wrap: wrap;
  margin: 0 0 1rem;
}

.search { position: relative; flex: 1 1 300px; min-width: 0; }

.search input {
  width: 100%;
  height: 48px;
  padding: 0 3.2rem 0 2.75rem;
  border-radius: 999px;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  font-size: .95rem;
}

.search input:focus {
  box-shadow: 0 0 0 4px var(--accent-ring), var(--shadow-md);
}

.search:focus-within .search__icon { color: var(--accent); }

.search input::-webkit-search-cancel-button { cursor: pointer; }

.search__icon {
  position: absolute;
  left: 1rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--fg-subtle);
  pointer-events: none;
  font-size: 1.05rem;
  line-height: 1;
}

.search__hint {
  position: absolute;
  right: .75rem;
  top: 50%;
  transform: translateY(-50%);
  pointer-events: none;
  transition: opacity .15s;
}

.search input:focus ~ .search__hint,
.search input:not(:placeholder-shown) ~ .search__hint { opacity: 0; }

kbd {
  display: inline-block;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: .72rem;
  line-height: 1;
  padding: .3rem .45rem;
  color: var(--fg-subtle);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-bottom-width: 2px;
  border-radius: 6px;
}

input, select, textarea {
  font: inherit;
  color: var(--fg);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: .58rem .75rem;
  width: 100%;
  transition: border-color .15s, box-shadow .15s;
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-ring);
}

textarea { resize: vertical; min-height: 84px; }

label {
  display: block;
  font-size: .8rem;
  font-weight: 600;
  color: var(--fg-muted);
  margin-bottom: .35rem;
  letter-spacing: -.005em;
}

.field { margin-bottom: 1.05rem; }
.field__hint { font-size: .78rem; color: var(--fg-subtle); margin-top: .35rem; }

.chips { display: flex; gap: .4rem; flex-wrap: wrap; }

.chip {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--fg-muted);
  border-radius: 999px;
  padding: .4rem .85rem;
  font-size: .84rem;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  box-shadow: var(--shadow-sm);
  transition: color .15s, border-color .15s, background .15s, transform .15s var(--ease);
}

.chip:hover { border-color: var(--border-strong); color: var(--fg); transform: translateY(-1px); background: var(--tint); }

.chip[aria-pressed="true"] {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  border-color: transparent;
  color: #fff;
  font-weight: 600;
  box-shadow: 0 3px 12px var(--accent-ring), inset 0 1px 0 rgba(255, 255, 255, .22);
  transform: translateY(-1px);
}

.chip__count {
  font-size: .72rem;
  font-variant-numeric: tabular-nums;
  padding: .05rem .4rem;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--fg-subtle);
}

.chip[aria-pressed="true"] .chip__count { background: rgba(255, 255, 255, .22); color: #fff; }

/* Segmented control (grid / list) */
.seg {
  display: inline-flex;
  padding: 3px;
  gap: 2px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  height: 48px;
  align-items: center;
}

.seg button {
  border: none;
  background: none;
  font: inherit;
  cursor: pointer;
  color: var(--fg-subtle);
  width: 38px;
  height: 38px;
  border-radius: 999px;
  line-height: 1;
  display: grid;
  place-items: center;
  transition: background .15s, color .15s, transform .2s var(--ease-spring);
}

.seg button:hover { color: var(--fg); }

.seg button[aria-pressed="true"] {
  background: var(--surface);
  color: var(--accent);
  box-shadow: var(--shadow-sm);
  transform: scale(1.02);
}

.seg svg { width: 16px; height: 16px; display: block; }

/* --------------------------------------------------------------- buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .45rem;
  font: inherit;
  font-weight: 600;
  font-size: .875rem;
  letter-spacing: -.005em;
  padding: .55rem 1rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--fg);
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  box-shadow: var(--shadow-sm);
  transition: transform .12s var(--ease), border-color .15s, background .15s, box-shadow .15s;
}

.btn:hover:not(:disabled) { border-color: var(--border-strong); transform: translateY(-1px); box-shadow: var(--shadow-md); }
.btn:active:not(:disabled) { transform: translateY(0); }
.btn:disabled { opacity: .5; cursor: not-allowed; box-shadow: none; }

.btn--primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  border-color: transparent;
  color: #fff;
  box-shadow: 0 2px 10px var(--accent-ring);
}

.btn--primary:hover:not(:disabled) { filter: brightness(1.07); box-shadow: 0 6px 20px var(--accent-ring); }
.btn--danger { background: var(--danger-soft); border-color: transparent; color: var(--danger); }
.btn--ghost { background: transparent; border-color: transparent; color: var(--fg-muted); box-shadow: none; }
.btn--ghost:hover:not(:disabled) { background: var(--surface-2); box-shadow: none; }
.btn--sm { padding: .38rem .7rem; font-size: .8rem; }
.btn--block { width: 100%; }
.btn--icon { padding: .45rem; width: 36px; height: 36px; }

/* ----------------------------------------------------------------- cards */
.grid {
  display: grid;
  /* min() keeps the track from exceeding the container on very narrow screens,
     where a bare 282px minimum would overflow instead of collapsing to one. */
  grid-template-columns: repeat(auto-fill, minmax(min(282px, 100%), 1fr));
  gap: 1.1rem;
}

.grid--list { grid-template-columns: 1fr; gap: .55rem; }

.card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: .6rem;
  padding: 1.25rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-sm);
  text-decoration: none;
  color: inherit;
  overflow: hidden;
  isolation: isolate;
  transition: transform .28s var(--ease-spring), border-color .2s, box-shadow .28s var(--ease-out);
}

/* Accent hairline that wipes in along the top edge on hover. */
.card::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 2px;
  z-index: 2;
  background: linear-gradient(90deg, var(--accent), var(--accent-2) 60%, var(--accent-3));
  transform: scaleX(0);
  transform-origin: left;
  transition: transform .35s var(--ease);
}

/* Spotlight that follows the pointer. --mx/--my are written by portal.js on
   pointermove; the fallback centres it so a keyboard focus still lights up. */
.card::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  opacity: 0;
  background: radial-gradient(230px circle at var(--mx, 50%) var(--my, 0%), var(--tint-strong), transparent 72%);
  transition: opacity .3s var(--ease);
}

a.card:hover,
a.card:focus-visible {
  transform: translateY(-4px);
  border-color: color-mix(in srgb, var(--accent) 32%, var(--border));
  box-shadow: var(--shadow-accent);
}

a.card:hover::before,
a.card:focus-visible::before { transform: scaleX(1); }

a.card:hover::after,
a.card:focus-visible::after { opacity: 1; }

.card__top { display: flex; align-items: flex-start; gap: .75rem; }

.card__icon {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  flex: none;
  border-radius: 14px;
  background: var(--surface-2);
  box-shadow: inset 0 0 0 1px var(--border);
  font-size: 1.3rem;
  line-height: 1;
  overflow: hidden;
  transition: transform .32s var(--ease-spring), box-shadow .2s;
}

a.card:hover .card__icon {
  transform: scale(1.07) rotate(-3deg);
  box-shadow: inset 0 0 0 1px var(--border), 0 6px 16px -8px var(--accent);
}

/* Library SVGs carry baked-in colours (brand hex / slate), so they always sit
   on a white tile to stay legible in both themes. */
.card__icon--img { background: #fff; box-shadow: inset 0 0 0 1px rgba(12, 14, 20, .09); }
.card__icon--img img { width: 25px; height: 25px; display: block; }

/* Uploads are arbitrary raster images rather than a 24px glyph, so they fill
   the tile. contain, not cover — a wide logo should letterbox, not lose its
   ends to a centre crop. */
.card__icon--upload { padding: 4px; }
.card__icon--upload img { width: 100%; height: 100%; object-fit: contain; }
.card__icon--initials { font-size: .95rem; font-weight: 700; color: var(--fg-muted); letter-spacing: .01em; }

.card__head { min-width: 0; flex: 1; }

.card__title {
  margin: 0;
  font-size: 1rem;
  font-weight: 640;
  letter-spacing: -.017em;
  line-height: 1.3;
}

.card__host {
  font-size: .78rem;
  color: var(--fg-subtle);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.card__desc {
  margin: 0;
  font-size: .875rem;
  color: var(--fg-muted);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card__foot { display: flex; gap: .35rem; flex-wrap: wrap; margin-top: auto; padding-top: .4rem; }

.card__go {
  position: absolute;
  top: 1.1rem;
  right: 1.1rem;
  z-index: 2;
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: .85rem;
  opacity: 0;
  transform: translate(-4px, 4px) scale(.85);
  transition: opacity .22s, transform .32s var(--ease-spring), background .2s;
}

a.card:hover .card__go,
a.card:focus-visible .card__go { opacity: 1; transform: none; }

/* list variant */
.grid--list .card { flex-direction: row; align-items: center; gap: .9rem; padding: .8rem 1rem; border-radius: var(--radius); }
.grid--list .card__top { flex: 1; align-items: center; min-width: 0; }
.grid--list .card__icon { width: 36px; height: 36px; border-radius: 10px; font-size: 1.05rem; }
.grid--list .card__icon--img img { width: 20px; height: 20px; }
/* Beats the 20px rule above on specificity, so uploads keep filling the tile. */
.grid--list .card__icon--upload img { width: 100%; height: 100%; }
.grid--list .card__desc { display: none; }
.grid--list .card__foot { margin: 0; padding: 0; flex: none; }
/* The arrow is first in the DOM (it is absolutely positioned in grid view), so
   it needs an explicit order to sit at the end of the list row. */
.grid--list .card__go { position: static; opacity: .45; transform: none; order: 9; margin-left: .25rem; }
.grid--list .card__top { order: 1; }
.grid--list .card__foot { order: 2; }
.grid--list a.card:hover .card__go { opacity: 1; }
.grid--list a.card:hover { transform: translateX(3px); }
@media (max-width: 620px) { .grid--list .card__foot { display: none; } }

.tag {
  font-size: .715rem;
  font-weight: 500;
  padding: .16rem .55rem;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--fg-muted);
  border: 1px solid transparent;
  white-space: nowrap;
}

.tag--cat { background: var(--accent-soft); color: var(--accent); font-weight: 600; }

.section-title {
  display: flex;
  align-items: center;
  gap: .7rem;
  margin: 2rem 0 .9rem;
  font-size: .73rem;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--fg-subtle);
}

.section-title::before {
  content: "";
  width: 3px;
  height: 14px;
  border-radius: 999px;
  background: linear-gradient(180deg, var(--accent), var(--accent-2));
  flex: none;
}

/* The first group sits right under the chips and needs no leading gap. */
#content > .section-title:first-child { margin-top: .35rem; }

.section-title::after {
  content: "";
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, var(--border), transparent);
}

/* -------------------------------------------------------------- skeletons */
.skeleton {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: .7rem;
}

.skeleton__row { display: flex; gap: .75rem; align-items: center; }

.shimmer {
  border-radius: 7px;
  background: linear-gradient(90deg, var(--surface-2) 25%, var(--surface-3) 37%, var(--surface-2) 63%);
  background-size: 400% 100%;
  animation: shimmer 1.4s ease-in-out infinite;
}

@keyframes shimmer { from { background-position: 100% 0; } to { background-position: -100% 0; } }

/* ----------------------------------------------------------------- panels */
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: 1.5rem;
}

.panel + .panel { margin-top: 1.25rem; }
.panel h2 { margin: 0 0 .35rem; font-size: 1.08rem; letter-spacing: -.02em; }
.panel__sub { margin: 0 0 1.25rem; color: var(--fg-muted); font-size: .875rem; }

.auth-shell { min-height: 100dvh; display: grid; place-items: center; padding: 1.5rem; }
.auth-card { width: min(440px, 100%); }

.empty {
  text-align: center;
  padding: 4.5rem 1.5rem;
  color: var(--fg-muted);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-xl);
  background: color-mix(in srgb, var(--surface) 70%, transparent);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  animation: rise .45s var(--ease-out) backwards;
}

.empty__icon { font-size: 2.4rem; display: block; margin-bottom: .7rem; opacity: .8; }
.empty p { margin: .25rem 0; }

/* ----------------------------------------------------------------- alerts */
.alert {
  padding: .75rem .95rem;
  border-radius: var(--radius-sm);
  font-size: .875rem;
  margin-bottom: 1rem;
  border: 1px solid transparent;
}

.alert--error { background: var(--danger-soft); color: var(--danger); }
.alert--success { background: var(--success-soft); color: var(--success); }
.alert--warn { background: var(--warn-soft); color: var(--warn); }
.alert--info { background: var(--accent-soft); color: var(--accent); }

/* ------------------------------------------------------------------ table */
.table-scroll { overflow-x: auto; margin-inline: -1.5rem; padding-inline: 1.5rem; }

table { width: 100%; border-collapse: collapse; font-size: .875rem; }

th {
  text-align: left;
  font-size: .72rem;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--fg-subtle);
  padding: .55rem .6rem;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

td { padding: .7rem .6rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
tbody tr { transition: background .12s; }
tbody tr:hover { background: var(--surface-2); }

.row-actions { display: flex; gap: .3rem; justify-content: flex-end; }

.pill {
  display: inline-block;
  font-size: .715rem;
  font-weight: 600;
  padding: .14rem .58rem;
  border-radius: 999px;
}

.pill--on { background: var(--success-soft); color: var(--success); }
.pill--off { background: var(--surface-2); color: var(--fg-subtle); }
.pill--alert { background: var(--danger-soft); color: var(--danger); }

/* ------------------------------------------------------------------ modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(8, 10, 15, .5);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: grid;
  place-items: center;
  padding: 1.5rem;
  z-index: 50;
  animation: fade .18s var(--ease);
}

.modal {
  width: min(580px, 100%);
  max-height: 88dvh;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  padding: 1.6rem;
  animation: pop .22s var(--ease);
}

.modal--wide { width: min(780px, 100%); }

@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: translateY(10px) scale(.985); } }

.modal__head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1.15rem; }
.modal__head h2 { margin: 0; font-size: 1.12rem; letter-spacing: -.02em; }
.modal__foot { display: flex; gap: .6rem; justify-content: flex-end; margin-top: 1.5rem; }

.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
@media (max-width: 560px) { .row-2 { grid-template-columns: 1fr; } }

.switch { display: flex; align-items: center; gap: .6rem; font-size: .875rem; color: var(--fg); cursor: pointer; }
.switch input { width: auto; margin: 0; accent-color: var(--accent); width: 16px; height: 16px; }

/* -------------------------------------------------------- icon selection */
.icon-inline {
  display: inline-grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 6px;
  background: #fff;
  box-shadow: inset 0 0 0 1px rgba(12, 14, 20, .1);
  vertical-align: -5px;
}

.icon-inline img { width: 15px; height: 15px; display: block; }
.icon-inline img.icon-img--upload { width: 100%; height: 100%; object-fit: contain; padding: 1px; }

.icon-field { display: flex; align-items: center; gap: .75rem; }
.icon-field__actions { display: flex; gap: .4rem; flex-wrap: wrap; }

.icon-preview {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  flex: none;
  border-radius: 13px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  font-size: 1.35rem;
  overflow: hidden;
}

.icon-preview--img { background: #fff; }
.icon-preview img { width: 26px; height: 26px; display: block; }
.icon-preview img.icon-img--upload { width: 100%; height: 100%; object-fit: contain; padding: 3px; }
.icon-preview--empty { color: var(--fg-subtle); font-size: .78rem; font-weight: 600; }

.icon-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(76px, 1fr));
  gap: .5rem;
  max-height: 46dvh;
  overflow-y: auto;
  padding: .25rem;
  margin-bottom: .5rem;
}

.icon-cell {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .4rem;
  padding: .6rem .3rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  font: inherit;
  transition: border-color .12s, transform .12s var(--ease), box-shadow .12s;
}

.icon-cell:hover { border-color: var(--accent); transform: translateY(-2px); box-shadow: var(--shadow-md); }
.icon-cell[aria-pressed="true"] { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-ring); }

.icon-cell__art {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: #fff;
  box-shadow: inset 0 0 0 1px rgba(12, 14, 20, .09);
}

.icon-cell__art img { width: 22px; height: 22px; display: block; }

.icon-cell__name {
  font-size: .66rem;
  line-height: 1.22;
  color: var(--fg-muted);
  text-align: center;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  word-break: break-word;
}

/* ------------------------------------------------------- upload dropzone */
.dropzone {
  display: flex;
  align-items: center;
  gap: 1rem;
  width: 100%;
  text-align: left;
  font: inherit;
  color: inherit;
  padding: 1.25rem;
  border: 1.5px dashed var(--border-strong);
  border-radius: var(--radius-lg);
  background: var(--surface-2);
  cursor: pointer;
  transition: border-color .15s, background .15s, transform .15s var(--ease);
}

.dropzone:hover { border-color: var(--accent); background: var(--tint); }
.dropzone.is-over { border-color: var(--accent); background: var(--tint-strong); transform: scale(1.01); }
.dropzone.is-busy { opacity: .6; pointer-events: none; }

.dropzone__art {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  flex: none;
  border-radius: 13px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--accent);
}

.dropzone__text { display: flex; flex-direction: column; gap: .15rem; min-width: 0; }
.dropzone__text .muted { font-size: .78rem; }

.upload-heading {
  margin: 1.4rem 0 .6rem;
  font-size: .73rem;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--fg-subtle);
}

/* An uploaded image fills its tile with object-fit: contain, so a wide logo
   letterboxes rather than being cropped through the middle. */
.icon-cell__art--upload { width: 44px; height: 44px; padding: 3px; }
.icon-cell__art--upload img { width: 100%; height: 100%; object-fit: contain; }

.icon-cell-wrap { position: relative; }

.icon-cell__del {
  position: absolute;
  top: -6px;
  right: -6px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--fg-muted);
  font-size: .7rem;
  line-height: 1;
  cursor: pointer;
  display: grid;
  place-items: center;
  box-shadow: var(--shadow-sm);
  opacity: 0;
  transition: opacity .15s, color .15s, border-color .15s;
}

.icon-cell-wrap:hover .icon-cell__del,
.icon-cell__del:focus-visible { opacity: 1; }
.icon-cell__del:hover:not(:disabled) { color: var(--danger); border-color: var(--danger); }
.icon-cell__del:disabled { cursor: not-allowed; opacity: 0; }

.emoji-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(48px, 1fr));
  gap: .4rem;
  max-height: 34dvh;
  overflow-y: auto;
  margin-bottom: 1rem;
}

.emoji-cell {
  font-size: 1.4rem;
  line-height: 1;
  padding: .5rem 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: border-color .12s, transform .12s var(--ease);
}

.emoji-cell:hover { border-color: var(--accent); transform: translateY(-2px); }

/* ------------------------------------------------------------------- tabs */
.tabs { display: flex; gap: .2rem; border-bottom: 1px solid var(--border); margin-bottom: 1.5rem; flex-wrap: wrap; }

.tab {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  padding: .7rem .9rem;
  font: inherit;
  font-size: .88rem;
  font-weight: 600;
  color: var(--fg-muted);
  cursor: pointer;
  margin-bottom: -1px;
  transition: color .15s, border-color .15s;
}

.tab:hover { color: var(--fg); }
.tab[aria-selected="true"] { color: var(--accent); border-bottom-color: var(--accent); }

/* ------------------------------------------------------------------- misc */
.code-block {
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: .85rem;
  font-size: .92rem;
  letter-spacing: .08em;
  word-break: break-all;
  text-align: center;
}

.recovery-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(132px, 1fr));
  gap: .4rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: .85rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.recovery-list li {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: .38rem .5rem;
  text-align: center;
}

.qr { display: block; margin: 0 auto 1rem; border-radius: var(--radius); background: #fff; padding: 10px; }

.otp-input {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 1.5rem;
  letter-spacing: .5em;
  text-align: center;
  padding-left: .5em;
}

.muted { color: var(--fg-muted); font-size: .85rem; }
.center { text-align: center; }
.stack > * + * { margin-top: 1rem; }
.spread { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.hidden { display: none !important; }
.grab { cursor: grab; color: var(--fg-subtle); user-select: none; }
tr.dragging { opacity: .4; }

.site-footer {
  border-top: 1px solid var(--border);
  padding: 1.75rem 0;
  color: var(--fg-subtle);
  font-size: .82rem;
  position: relative;
  z-index: 1;
  background: color-mix(in srgb, var(--surface) 55%, transparent);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

#countLabel { font-variant-numeric: tabular-nums; }

.spinner {
  width: 15px;
  height: 15px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  display: inline-block;
  animation: spin .6s linear infinite;
}

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

/* Staggered entrance for the card grid. */
.reveal { animation: rise .52s var(--ease-out) backwards; }

@keyframes rise {
  from { opacity: 0; transform: translateY(14px) scale(.98); filter: blur(3px); }
}

@media (max-width: 640px) {
  .wrap { width: min(1240px, 100% - 1.75rem); }
  .lede { padding: 1.1rem 0 0; margin-bottom: .85rem; }
  .modal { padding: 1.2rem; }
  .table-scroll { margin-inline: -1.2rem; padding-inline: 1.2rem; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
  a.card:hover, .btn:hover, .chip:hover, .icon-cell:hover,
  a.card:hover .card__icon, .brand:hover .brand__mark,
  .seg button[aria-pressed="true"] { transform: none; }
  /* The drift keyframe ends off-centre; without motion it should just sit still. */
  body::before { animation: none; }
}
