@font-face {
  font-family: 'PPMori';
  src: url('fonts/Mori/web/PPMori-Regular.woff2') format('woff2'),
       url('fonts/Mori/web/PPMori-Regular.woff') format('woff');
  font-weight: 400; font-style: normal; font-display: swap;
}
@font-face {
  font-family: 'PPMori';
  src: url('fonts/Mori/web/PPMori-Book.woff2') format('woff2'),
       url('fonts/Mori/web/PPMori-Book.woff') format('woff');
  font-weight: 450; font-style: normal; font-display: swap;
}
@font-face {
  font-family: 'PPMori';
  src: url('fonts/Mori/web/PPMori-Semibold.woff2') format('woff2'),
       url('fonts/Mori/web/PPMori-Semibold.woff') format('woff');
  font-weight: 600; font-style: normal; font-display: swap;
}
@font-face {
  font-family: 'PPMori';
  src: url('fonts/Mori/web/PPMori-Extrabold.woff2') format('woff2'),
       url('fonts/Mori/web/PPMori-Extrabold.woff') format('woff');
  font-weight: 700; font-style: normal; font-display: swap;
}

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

:root {
  --bg: #fff;
  --surface: #f5f5f5;
  --line: #e8e8e8;
  --text: #111;
  --muted: #aaa;
  --card-h: 82px;
  --header-bg: rgba(255,255,255,0.94);
  --nav-muted: rgba(255,255,255,0.55);
  --nav-indicator: rgba(255,255,255,0.16);
}

.dark {
  --bg: #111;
  --surface: #1c1c1c;
  --line: #272727;
  --text: #eee;
  --muted: #555;
  --header-bg: rgba(17,17,17,0.94);
  --nav-muted: rgba(0,0,0,0.45);
  --nav-indicator: rgba(0,0,0,0.10);
}

html, body { height: 100%; overflow: hidden; }

body {
  font-family: 'PPMori', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  display: flex;
  flex-direction: column;
  transition: background 0.15s, color 0.15s;
}

/* ── Header ── */
header {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  border-bottom: 1px solid var(--line);
  background: var(--header-bg);
  backdrop-filter: blur(10px);
  z-index: 10;
}

.header-top {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 24px;
  padding: 26px 30px;
  transition: padding 0.42s cubic-bezier(0.33, 1, 0.68, 1);
}
.header-top > .logo { justify-self: start; }
.header-top > .controls { justify-self: end; }

/* Compact, minimal header on scroll-down */
header.scrolled .header-top { padding-top: 12px; padding-bottom: 12px; }

/* Smoothly collapse the theme toggle away on scroll */
header.scrolled #dark-btn {
  max-width: 0;
  margin-left: -8px;
  padding-left: 0;
  padding-right: 0;
  border-width: 0;
  opacity: 0;
  transform: scale(0.7);
  pointer-events: none;
}

/* Search becomes a refined floating pill — grows when selected */
header.scrolled .search-wrap {
  width: clamp(300px, 36vw, 500px);
  background: var(--bg);
  border-color: var(--line);
  border-radius: 13px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.10), 0 1px 3px rgba(0,0,0,0.05);
}
header.scrolled .search-wrap:focus-within {
  width: clamp(340px, 46vw, 640px);
  border-color: var(--muted);
  box-shadow: 0 12px 32px rgba(0,0,0,0.16);
}

/* Collapse the tabs row entirely for a minimal look */
header.scrolled .header-tabs {
  min-height: 0;
  max-height: 0;
  padding-top: 0;
  padding-bottom: 0;
  opacity: 0;
  border-top-color: transparent;
  pointer-events: none;
}

.header-tabs {
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  padding: 0 20px;
  border-top: 1px solid var(--line);
  min-height: 50px;
  max-height: 64px;
  overflow: hidden;
  transition: min-height 0.42s cubic-bezier(0.33, 1, 0.68, 1),
              max-height 0.42s cubic-bezier(0.33, 1, 0.68, 1),
              opacity 0.3s ease,
              border-color 0.35s ease;
}

.htabs {
  display: flex;
  align-items: stretch;
  position: relative;
  gap: 4px;
}

.htab {
  padding: 7px 16px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  color: var(--muted);
  background: none;
  border: none;
  border-radius: 9px;
  cursor: pointer;
  transition: color 0.15s, background 0.15s;
  white-space: nowrap;
  position: relative;
  z-index: 1;
}
.htab:hover:not(:disabled):not(.active) { color: var(--text); background: var(--surface); }
.htab.active { color: var(--text); font-weight: 600; background: var(--surface); }
.htab:disabled { opacity: 0.35; cursor: default; }

.header-vdiv {
  width: 1px;
  height: 20px;
  background: var(--line);
  flex-shrink: 0;
}

.hdr-btn {
  display: flex; align-items: center; gap: 7px;
  padding: 7px 13px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  font-family: inherit; font-size: 13px; font-weight: 500;
  color: var(--text); text-decoration: none;
  white-space: nowrap; cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.hdr-btn:hover { background: var(--surface-2); border-color: #444; }
.figma-cta-btn { padding-left: 10px; }
.figma-cta-icon { width: 13px; height: 20px; flex-shrink: 0; }
.login-chevron { width: 13px; height: 13px; flex-shrink: 0; transition: transform 0.18s; }
.menu-open .login-chevron { transform: rotate(180deg); }

.user-menu-wrap { position: relative; }
.user-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 4px;
  min-width: 120px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.12);
  z-index: 50;
}
.user-menu[hidden] { display: none; }
.user-menu-item {
  display: block;
  width: 100%;
  padding: 8px 12px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  background: none;
  border: none;
  border-radius: 7px;
  text-align: left;
  cursor: pointer;
}
.user-menu-item:hover { background: var(--surface); }

@keyframes logo-in {
  from { opacity: 0; transform: translateY(5px); filter: blur(4px); }
  to   { opacity: 1; transform: translateY(0);   filter: blur(0); }
}

.logo {
  display: flex;
  align-items: center;
  flex-shrink: 0;
  color: var(--text);
  cursor: pointer;
  user-select: none;
  animation: logo-in 0.55s cubic-bezier(0.16, 1, 0.3, 1) both;
}
.logo { position: relative; overflow: hidden; height: 38px; }
.logo svg { width: auto; display: block; }
.logo-full {
  height: 38px;
  transition: transform 0.42s cubic-bezier(0.33, 1, 0.68, 1);
}
/* Slide-mask: full wordmark rolls up & out the top, icon mark rolls up from below into place.
   The mark stays 30px (centered in the 38px box) while the wordmark is larger. */
.logo-mark {
  position: absolute;
  left: 0;
  top: 4px;
  height: 30px;
  transform: translateY(150%);
  pointer-events: none;
  transition: transform 0.42s cubic-bezier(0.33, 1, 0.68, 1);
}
header.scrolled .logo-full { transform: translateY(-130%); }
header.scrolled .logo-mark { transform: translateY(0); }

/* ── Search bar (search + filter inside) ── */
.search-wrap {
  position: relative;
  justify-self: center;
  width: clamp(300px, 46vw, 620px);
  max-width: 100%;
  display: flex;
  align-items: center;
  background: var(--surface);
  border: 1.5px solid transparent;
  border-radius: 12px;
  transition: border-color 0.25s ease, background 0.3s ease, box-shadow 0.42s ease,
              width 0.42s cubic-bezier(0.33, 1, 0.68, 1),
              border-radius 0.42s cubic-bezier(0.33, 1, 0.68, 1);
}
/* Grow + emphasize when the search is selected */
.search-wrap:focus-within {
  width: clamp(340px, 52vw, 720px);
  border-color: var(--muted);
  background: var(--bg);
  box-shadow: 0 6px 24px rgba(0,0,0,0.09);
}

.search-icon {
  position: absolute; left: 16px; top: 50%;
  transform: translateY(-50%);
  width: 18px; height: 18px;
  stroke: var(--muted); fill: none;
  pointer-events: none; flex-shrink: 0;
}

#search {
  flex: 1;
  min-width: 0;
  padding: 14px 12px 14px 48px;
  border: none;
  outline: none;
  background: transparent;
  color: var(--text);
  font-family: inherit;
  font-size: 15px;
}
#search::-webkit-search-cancel-button { display: none; }

/* ── Search right-side actions ── */
.search-actions {
  display: flex;
  align-items: center;
  padding-right: 6px;
  gap: 2px;
  flex-shrink: 0;
}

.kbd-hint {
  font-size: 11px;
  color: var(--muted);
  font-weight: 500;
  padding: 3px 6px;
  border-radius: 5px;
  border: 1px solid var(--line);
  white-space: nowrap;
  line-height: 1;
  letter-spacing: 0.01em;
  transition: opacity 0.1s;
}

.search-vdiv {
  width: 1px; height: 18px;
  background: var(--line);
  margin: 0 6px;
  flex-shrink: 0;
}

/* ── Filter button (inside search bar) ── */
[hidden] { display: none !important; }
.fd-wrap { position: relative; }
.fd-btn {
  display: flex; align-items: center; gap: 5px;
  height: 32px; padding: 0 10px;
  border-radius: 7px;
  border: 1.5px solid transparent;
  background: none; color: var(--muted);
  cursor: pointer; font-family: inherit;
  font-size: 12px; font-weight: 600;
  white-space: nowrap;
  transition: background 0.12s, color 0.12s, border-color 0.12s;
}
.fd-btn:hover { background: var(--line); color: var(--text); }
.fd-btn svg { width: 13px; height: 13px; flex-shrink: 0; }
.fd-btn.fd-active { border-color: var(--line); background: var(--bg); color: var(--text); }
.fd-sep { width: 1px; height: 12px; background: var(--line); margin: 0 2px; }
.fd-clear-x { display: flex; align-items: center; color: var(--muted); transition: color 0.1s; }
.fd-clear-x:hover { color: var(--text); }
.fd-clear-x svg { width: 12px; height: 12px; }
.fd-panel {
  position: absolute; top: calc(100% + 10px); right: 0;
  width: 240px; background: var(--bg);
  border: 1.5px solid var(--line); border-radius: 20px;
  padding: 6px; box-shadow: 0 12px 40px rgba(0,0,0,0.12);
  z-index: 100; transform-origin: right top;
  opacity: 0; transform: scale(0.95) translateY(-6px);
  pointer-events: none;
  transition: opacity 0.18s ease, transform 0.25s cubic-bezier(0.34,1.4,0.64,1);
}
.fd-panel.open { opacity: 1; transform: scale(1) translateY(0); pointer-events: auto; }
.fd-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 10px; border-radius: 13px; cursor: pointer;
  background: none; border: none; width: 100%; font-family: inherit;
  transition: background 0.12s;
}
.fd-row:hover { background: var(--surface); }
.fd-row-left { display: flex; align-items: center; gap: 14px; }
.fd-row-icon { color: var(--muted); width: 20px; height: 20px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.fd-row-icon svg { width: 18px; height: 18px; }
.fd-row-label { font-size: 14px; font-weight: 600; color: var(--text); }
.fd-check {
  width: 20px; height: 20px; border-radius: 50%;
  border: 2px solid var(--muted); display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; transition: background 0.15s, border-color 0.15s;
}
.fd-check.checked { background: #31C051; border-color: #31C051; }
.fd-check svg { width: 12px; height: 12px; }

/* ── Right-side controls ── */
.controls {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
  transition: opacity 0.28s ease, transform 0.28s ease;
}

.filter-hint {
  margin-left: auto;
  font-size: 10px;
  color: var(--muted);
  opacity: 0.6;
  white-space: nowrap;
  flex-shrink: 0;
  align-self: center;
  padding-left: 10px;
  letter-spacing: 0.01em;
}

.count {
  position: absolute;
  right: 20px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 3px;
}

/* ── Rolling digit counter ── */
.cnt {
  display: inline-flex;
  align-items: flex-end;
  overflow: hidden;
  height: 1.1em;
  line-height: 1.1;
}

.cnt-digit {
  position: relative;
  overflow: hidden;
  height: 1.1em;
}

.cnt-strip {
  display: flex;
  flex-direction: column;
  transition: transform 0.5s cubic-bezier(0.16, 1, 0.3, 1);
  will-change: transform;
}

.cnt-strip span {
  height: 1.1em;
  line-height: 1.1;
  display: block;
  text-align: center;
}

.cnt-sep { display: inline-block; }

#count-loading {
  font-size: 10px;
  color: var(--muted);
  opacity: 0.7;
}

/* ── Adaptive size slider ── */
.aslider-wrap { flex-shrink: 0; }

.aslider-track {
  position: relative;
  width: 120px;
  height: 28px;
  border-radius: 100px;
  background: var(--surface);
  border: 1.5px solid var(--line);
  overflow: hidden;
  cursor: pointer;
}

.aslider-fill {
  position: absolute;
  top: 0; left: 0;
  height: 100%;
  border-radius: 100px;
  pointer-events: none;
  z-index: 2;
  background: var(--text);
  opacity: 0.12;
  transition: width 0.22s cubic-bezier(0.34,1.4,0.64,1);
}

.aslider-thumb {
  position: absolute;
  top: 0;
  width: 28px; height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  z-index: 4;
  transition: left 0.22s cubic-bezier(0.34,1.4,0.64,1);
}
.aslider-thumb-inner {
  position: relative;
  width: 20px; height: 20px;
  border-radius: 50%;
  background: var(--bg);
  border: 1.5px solid var(--line);
  box-shadow: 0 1px 6px rgba(0,0,0,0.18);
}

#size-slider {
  position: absolute;
  inset: 0;
  z-index: 5;
  opacity: 0;
  cursor: pointer;
  width: 100%;
  height: 100%;
  margin: 0;
}

.icon-btn {
  background: none;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 4px 6px;
  cursor: pointer;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  font-family: inherit;
  white-space: nowrap;
  transition: all 0.1s;
}
.icon-btn:hover { color: var(--text); border-color: var(--muted); }
.icon-btn svg { width: 13px; height: 13px; stroke: currentColor; fill: none; flex-shrink: 0; }

/* Dark toggle — square variant of hdr-btn */
.hdr-icon-btn {
  padding: 7px;
  justify-content: center;
}
.hdr-icon-btn svg { width: 15px; height: 15px; stroke: currentColor; fill: none; flex-shrink: 0; }

/* Dark toggle collapses smoothly on scroll */
#dark-btn {
  max-width: 40px;
  overflow: hidden;
  transition: background 0.15s, border-color 0.15s,
              opacity 0.25s ease,
              transform 0.3s ease,
              max-width 0.4s cubic-bezier(0.4, 0, 0.2, 1),
              margin 0.4s cubic-bezier(0.4, 0, 0.2, 1),
              padding 0.4s cubic-bezier(0.4, 0, 0.2, 1),
              border-width 0.3s ease;
}

/* ── Responsive ── */
@media (max-width: 640px) {
  /* ── Header top row: wrap so search drops below logo+controls ── */
  .header-top {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    padding: 11px 16px 9px;
    gap: 10px 8px;
  }

  /* Smaller logo so it shares the top row with the controls */
  .logo, .logo-full { height: 23px; }
  .logo-mark { height: 19px; top: 2px; }
  .logo { order: 1; flex-shrink: 0; }

  /* dark toggle + auth buttons, right-aligned next to the logo */
  .controls { order: 2; margin-left: auto; gap: 6px; }

  /* search goes full-width below the logo row */
  .search-wrap {
    order: 3;
    flex: 0 0 100%;
    width: auto;
    max-width: 100%;
    border-radius: 11px;
  }
  #search { font-size: 16px; padding: 11px 12px 11px 42px; }
  .search-icon { left: 13px; width: 17px; height: 17px; }
  .kbd-hint { display: none; }

  /* size slider isn't useful on touch */
  .aslider-wrap { display: none; }

  /* compact auth button */
  .hdr-btn { padding: 7px 12px; font-size: 12px; }

  /* tabs row: tighter, and drop the count to keep it clean */
  .header-tabs { min-height: 44px; padding: 0 14px; }
  .htab { padding: 6px 14px; font-size: 13px; }
  .count { display: none; }

  /* ── Auth modal: full-bleed on small screens ── */
  .auth-backdrop { padding: 12px; align-items: flex-end; }
  .auth-outer { border-radius: 24px; }
  .auth-inner { padding: 22px 20px 20px; border-radius: 16px; }
  .auth-header h2 { font-size: 19px; }
  .auth-row { flex-direction: column; gap: 0; }
  .auth-row .auth-field { flex: 1 1 100%; }

  /* ── Filter drawer: edge-to-edge ── */
  .fd { left: 8px; right: 8px; width: auto; }
}

/* ── Virtual scroll ── */
#scroller {
  position: absolute;
  inset: 0;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-mask-image: linear-gradient(to bottom, transparent 0px, black 48px, black calc(100% - 48px), transparent 100%);
  mask-image: linear-gradient(to bottom, transparent 0px, black 48px, black calc(100% - 48px), transparent 100%);
}
#scroller.at-top {
  -webkit-mask-image: linear-gradient(to bottom, black 0%, black calc(100% - 48px), transparent 100%);
  mask-image: linear-gradient(to bottom, black 0%, black calc(100% - 48px), transparent 100%);
}

#sizer { position: relative; width: 100%; }

#stage {
  position: absolute;
  top: 0; left: 0;
  width: 100%;
  display: grid;
}

/* ── Cards ── */
.card {
  height: var(--card-h);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 0 6px;
  cursor: pointer;
  border: none;
  background: var(--bg);
  outline: none;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  position: relative;
  transition: background 0.08s;
  font-family: inherit;
  overflow: hidden;
}
.card:hover { background: var(--surface); }

/* Full-color brand/team logos: card follows the theme, logo colors stay fixed */
.card-color svg { color: #111; }

.card svg {
  width: var(--card-icon-size, 20px);
  height: var(--card-icon-size, 20px);
  flex-shrink: 0;
  display: block;
  color: var(--text);
}

/* Crests/badges carry more internal padding than line icons, so they read
   small and lose detail at the same size — scale them up within the card */
.card-color svg {
  width: calc(var(--card-icon-size, 20px) * 1.4);
  height: calc(var(--card-icon-size, 20px) * 1.4);
}

.card-name {
  position: absolute;
  bottom: 6px;
  left: 6px;
  right: 6px;
  font-size: var(--card-name-size, 9px);
  color: var(--muted);
  text-align: center;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  line-height: 1;
}

.flash {
  position: absolute;
  inset: 0;
  background: var(--text);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10.5px;
  font-weight: 500;
  color: var(--bg);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.08s;
}
.card.copied .flash { opacity: 1; }

/* ── Save (heart) button ── */
.save-btn {
  position: absolute;
  top: 5px;
  left: 5px;
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: none;
  padding: 0;
  cursor: pointer;
  border-radius: 5px;
  opacity: 0;
  transition: opacity 0.15s, color 0.15s;
  color: var(--muted);
  z-index: 1;
}
.card:hover .save-btn,
.save-btn.saved { opacity: 1; }
.save-btn svg { width: 13px; height: 13px; pointer-events: none; }
.save-btn.saved { color: #e53935; }
.save-btn.saved svg { fill: #e53935; }
.save-btn:hover:not(.saved) { color: var(--text); }

/* ── Attribution badge (Solar icons) ── */
.attr-badge {
  position: absolute;
  top: 5px;
  right: 5px;
  width: 13px;
  height: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  opacity: 0.45;
  cursor: help;
  z-index: 2;
  transition: opacity 0.12s, color 0.12s;
}
.attr-badge:hover { opacity: 1; color: var(--text); }
.attr-badge svg { width: 100%; height: 100%; }

#attr-tip {
  position: fixed;
  top: 0; left: 0;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 6px 10px;
  font-size: 11px;
  font-weight: 500;
  white-space: nowrap;
  box-shadow: 0 8px 24px rgba(0,0,0,0.14);
  pointer-events: none;
  opacity: 0;
  transform: translate(-50%, -100%) scale(0.92);
  transform-origin: bottom center;
  transition: opacity 0.12s ease, transform 0.12s ease;
  z-index: 210;
}
#attr-tip.visible {
  opacity: 1;
  transform: translate(-50%, -100%) scale(1);
}
#attr-tip-arrow {
  position: absolute;
  bottom: -6px;
  left: 50%;
  transform: translateX(-50%);
}

/* Tooltip below variant (for elements at top of screen) */
#attr-tip.tip-below {
  transform: translate(-50%, 8px) scale(0.92);
  transform-origin: top center;
}
#attr-tip.tip-below.visible {
  transform: translate(-50%, 8px) scale(1);
}
#attr-tip.tip-below #attr-tip-arrow {
  bottom: auto;
  top: -6px;
  transform: translateX(-50%) rotate(180deg);
}

#empty {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  text-align: center;
  padding: 40px;
}
#empty-title {
  font-size: 13px;
  color: var(--text);
  font-weight: 500;
}
#empty-sub {
  font-size: 12px;
  color: var(--muted);
}
#empty-action {
  margin-top: 10px;
  padding: 6px 14px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: none;
  font-size: 12px;
  font-family: inherit;
  color: var(--text);
  cursor: pointer;
  transition: background 0.1s, border-color 0.1s;
}
#empty-action:hover { background: var(--surface); border-color: var(--muted); }

/* ── Hover preview tooltip ── */
#preview {
  position: fixed;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 16px 14px 12px;
  pointer-events: none;
  z-index: 1000;
  text-align: center;
  display: none;
  box-shadow: 0 4px 24px rgba(0,0,0,0.12);
  min-width: 110px;
}
#preview svg { width: 44px; height: 44px; display: block; margin: 0 auto; color: var(--text); }
#preview-name {
  font-size: 10.5px;
  color: var(--text);
  margin-top: 9px;
  max-width: 100px;
  word-break: break-word;
  line-height: 1.3;
}
#preview-lib {
  font-size: 9.5px;
  color: var(--muted);
  margin-top: 3px;
}

/* ── Dot-matrix loader ── */
#loader {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  background: var(--bg);
  z-index: 5;
  transition: opacity 0.35s ease, visibility 0.35s ease;
}
#loader.hidden { opacity: 0; visibility: hidden; pointer-events: none; }
#loader-label { font-size: 11px; color: var(--muted); letter-spacing: 0.04em; }

/* dmx core */
.dmx-root {
  display: inline-flex; align-items: center; justify-content: center;
  --dmx-cycle: 1500ms;
  --dmx-opacity-base: 0.16; --dmx-opacity-mid: 0.32; --dmx-opacity-peak: 1;
  --dmx-halo-level: 0;
  color: var(--text);
}
.dmx-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  grid-template-rows: repeat(5, minmax(0, 1fr));
}
.dmx-dot {
  border-radius: 999px; display: block;
  background: var(--dmx-dot-fill, currentColor);
  opacity: calc(0.5 * (var(--dmx-opacity-base) + var(--dmx-opacity-mid)));
  --dmx-bloom-level: 0;
  transform-origin: center;
  will-change: opacity;
}
.dmx-bloom .dmx-dot {
  filter:
    drop-shadow(0 0 calc(var(--dmx-dot-size,3px) * 0.75 * max(var(--dmx-bloom-level,0), var(--dmx-halo-level,0))) currentColor)
    drop-shadow(0 0 calc(var(--dmx-dot-size,3px) * 1.35 * max(var(--dmx-bloom-level,0), var(--dmx-halo-level,0))) currentColor);
  will-change: opacity, filter;
}
.dmx-diagonal-alt-sweep {
  animation: dmx-diagonal-alt-sweep calc(var(--dmx-cycle) * var(--dmx-speed, 1)) linear infinite;
  animation-delay: calc(
    (var(--dmx-path, 0) * 0.2 + var(--dmx-diagonal-parity, 0) * 0.5) *
    var(--dmx-cycle) * var(--dmx-speed, 1)
  );
  will-change: opacity;
}
@keyframes dmx-diagonal-alt-sweep {
  0%,100% { opacity: calc(0.5 * var(--dmx-opacity-base)); --dmx-bloom-level: 0; }
  14%      { opacity: var(--dmx-opacity-peak);             --dmx-bloom-level: 1; }
  30%      { opacity: calc(0.75 * var(--dmx-opacity-base));--dmx-bloom-level: 0; }
}
@media (max-width: 1079px) {
  .figma-cta-btn { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .dmx-dot, .dmx-diagonal-alt-sweep { animation: none !important; }
}

/* ── Bookmark toast ── */
#bm-toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(8px);
  background: var(--text);
  color: var(--bg);
  font-size: 12px;
  padding: 8px 16px;
  border-radius: 8px;
  opacity: 0;
  transition: opacity 0.15s, transform 0.15s;
  pointer-events: none;
  white-space: nowrap;
  z-index: 2000;
}
#bm-toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }


#attribution {
  position: fixed;
  bottom: 14px;
  left: 16px;
  right: 16px;
  display: flex;
  justify-content: flex-end;
  align-items: center;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  z-index: 10;
  pointer-events: none;
}
#attribution a, #attribution span {
  pointer-events: auto;
  text-decoration: none;
  color: var(--muted);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 100px;
  padding: 5px 12px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
  transition: color 0.12s, border-color 0.12s, background 0.12s;
}
#attribution a:hover, #attribution span:hover {
  color: var(--text);
  border-color: var(--muted);
  background: var(--surface);
}

/* ── Bottom nav (app page — shares visual with pages.css) ── */
#bottom-nav {
  position: fixed;
  bottom: 18px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  background: var(--text);
  border: 1px solid transparent;
  border-radius: 100px;
  padding: 5px;
  z-index: 50;
  box-shadow: 0 8px 30px rgba(0,0,0,0.22), 0 2px 6px rgba(0,0,0,0.14);
}
.bn-indicator {
  position: absolute;
  top: 5px;
  height: calc(100% - 10px);
  border-radius: 100px;
  background: var(--nav-indicator);
  pointer-events: none;
  z-index: 0;
  opacity: 0;
  transition: left 0.35s cubic-bezier(0.34,1.4,0.64,1),
              width 0.35s cubic-bezier(0.34,1.4,0.64,1),
              opacity 0.15s;
}
.bn-item {
  position: relative; z-index: 1;
  display: flex; align-items: center; gap: 5px;
  padding: 8px 16px; border-radius: 100px;
  text-decoration: none; color: var(--nav-muted);
  font-family: inherit; font-size: 11px; font-weight: 600;
  letter-spacing: 0.05em; text-transform: uppercase;
  white-space: nowrap; transition: color 0.18s; cursor: pointer;
}
.bn-item:hover, .bn-item.active { color: var(--bg); }
.bn-item svg { width: 13px; height: 13px; flex-shrink: 0; opacity: 0.7; transition: opacity 0.18s; }
.bn-item:hover svg, .bn-item.active svg { opacity: 1; }
.bn-item[target="_blank"]::before { content: '↗'; font-size: 9px; opacity: 0.5; margin-left: -2px; }

/* ── Auth Modal ── */
.auth-backdrop {
  position: fixed; inset: 0; z-index: 200;
  display: flex; align-items: center; justify-content: center;
  background: rgba(0,0,0,0.45);
  backdrop-filter: blur(6px);
  padding: 20px;
  opacity: 0; transition: opacity 0.2s;
  pointer-events: none;
}
.auth-backdrop.open { opacity: 1; pointer-events: auto; }
.auth-backdrop[hidden] { display: none; }

.auth-outer {
  background: var(--surface);
  border-radius: 28px;
  padding: 10px;
  width: 100%; max-width: 460px;
  box-shadow: inset 0 0 0 1px var(--line), 0 24px 80px rgba(0,0,0,0.18);
  transform: translateY(10px) scale(0.98);
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}
.auth-backdrop.open .auth-outer { transform: translateY(0) scale(1); }

.auth-inner {
  background: var(--bg);
  border-radius: 20px;
  padding: 28px 28px 24px;
  position: relative;
}

.auth-close {
  position: absolute; top: 14px; right: 14px;
  width: 30px; height: 30px; border-radius: 50%;
  background: none; border: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  color: var(--muted); transition: background 0.15s, color 0.15s;
}
.auth-close:hover { background: var(--surface); color: var(--text); }
.auth-close svg { width: 16px; height: 16px; }

.auth-header { margin-bottom: 20px; }
.auth-header h2 {
  font-size: 22px; font-weight: 700; letter-spacing: -0.3px;
  color: var(--text); margin-bottom: 5px;
}
.auth-header p { font-size: 13px; color: var(--muted); line-height: 1.5; }

.auth-social-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.auth-social-tray {
  background: var(--surface);
  border-radius: 12px; padding: 5px;
  box-shadow: inset 0 0 0 1px var(--line);
}
.auth-social-btn {
  display: flex; align-items: center; justify-content: center;
  gap: 8px; width: 100%; height: 40px;
  background: var(--bg); border: none; border-radius: 8px;
  font-family: inherit; font-size: 13px; font-weight: 500;
  color: var(--text); cursor: pointer;
  box-shadow: 0 1px 3px rgba(0,0,0,0.07);
  transition: background 0.15s;
}
.auth-social-btn:not([aria-disabled="true"]):hover { background: var(--surface); }
.auth-social-btn[aria-disabled="true"] { opacity: 0.45; cursor: not-allowed; }
.auth-social-icon { width: 16px; height: 16px; flex-shrink: 0; }

.auth-divider {
  display: flex; align-items: center; gap: 10px;
  margin: 18px 0;
}
.auth-divider-line { flex: 1; height: 1px; background: var(--line); }
.auth-divider-label { font-size: 11px; color: var(--muted); white-space: nowrap; }

.auth-form { display: flex; flex-direction: column; gap: 14px; }
.auth-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.auth-field { display: flex; flex-direction: column; gap: 5px; }
.auth-field label { font-size: 12px; font-weight: 500; color: var(--text); }

.auth-input-wrap { position: relative; }
.auth-input-icon {
  position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
  width: 15px; height: 15px; stroke: var(--muted); fill: none;
  pointer-events: none;
}
.auth-input-wrap input {
  width: 100%; height: 42px;
  padding: 0 12px 0 36px;
  background: var(--surface); border: 1.5px solid transparent;
  border-radius: 10px; outline: none;
  font-family: inherit; font-size: 13px; color: var(--text);
  transition: border-color 0.15s, background 0.15s;
}
.auth-input-wrap input:focus { border-color: var(--muted); background: var(--bg); }
.auth-input-wrap input::placeholder { color: var(--muted); }

.auth-field-hint { font-size: 11px; color: var(--muted); line-height: 1.4; }

.auth-error {
  font-size: 12px; color: #d32f2f;
  background: rgba(211,47,47,0.08); border-radius: 8px;
  padding: 9px 12px; line-height: 1.4;
}

.auth-submit {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; height: 44px;
  background: var(--text); color: var(--bg);
  border: none; border-radius: 10px;
  font-family: inherit; font-size: 14px; font-weight: 600;
  cursor: pointer; transition: opacity 0.15s;
  margin-top: 2px;
}
.auth-submit:hover { opacity: 0.85; }
.auth-submit svg { width: 16px; height: 16px; flex-shrink: 0; }

.auth-signin-link {
  text-align: center; font-size: 12px; color: var(--muted);
  margin-top: 14px;
}
.auth-signin-link a { color: var(--text); font-weight: 500; text-decoration: none; }
.auth-signin-link a:hover { text-decoration: underline; }

/* ── Right-click context menu ──────────────────────────────── */
#icon-ctx-menu {
  position: fixed;
  z-index: 400;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 4px;
  box-shadow: 0 8px 28px rgba(0,0,0,0.12), 0 2px 8px rgba(0,0,0,0.06);
  min-width: 160px;
  user-select: none;
}
.ctx-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 10px;
  border-radius: 7px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  cursor: pointer;
  white-space: nowrap;
}
.ctx-item:hover { background: var(--surface); }
.ctx-item svg {
  width: 15px;
  height: 15px;
  flex-shrink: 0;
  stroke: var(--muted);
}
