/* ==========================================================
   Theme Designer Pro site, v2
   Every color below comes from one hue (--h) and one chroma (--c),
   set by palette.js. Changing the hue on the home page recolors the
   whole site, the way the designer recolors Open WebUI.
   ========================================================== */

@property --h {
  syntax: '<number>';
  inherits: true;
  initial-value: 265;
}

:root {
  --h: 265;
  --c: 0.024;

  --bg: oklch(0.15 calc(var(--c) * 0.8) var(--h));
  --bg-2: oklch(0.175 var(--c) var(--h));
  --surface: oklch(0.2 var(--c) var(--h));
  --surface-2: oklch(0.24 var(--c) var(--h));
  --surface-3: oklch(0.29 var(--c) var(--h));
  --line: oklch(0.34 var(--c) var(--h) / 0.55);
  --line-2: oklch(0.44 var(--c) var(--h) / 0.6);
  --text: oklch(0.97 calc(var(--c) * 0.25) var(--h));
  --text-2: oklch(0.84 calc(var(--c) * 0.5) var(--h));
  --muted: oklch(0.68 calc(var(--c) * 0.6) var(--h));
  --faint: oklch(0.52 calc(var(--c) * 0.6) var(--h));
  --accent: oklch(0.8 0.14 var(--h));
  --accent-strong: oklch(0.72 0.17 var(--h));
  --accent-2: oklch(0.78 0.15 calc(var(--h) + 50));
  --accent-ink: oklch(0.2 0.05 var(--h));
  --accent-soft: oklch(0.8 0.14 var(--h) / 0.12);
  --accent-line: oklch(0.8 0.14 var(--h) / 0.35);
  --glow: oklch(0.62 0.2 var(--h) / 0.32);
  --ok: oklch(0.78 0.16 150);

  --r-xl: 28px;
  --r-lg: 20px;
  --r-md: 14px;
  --r-sm: 10px;
  --r-pill: 999px;

  --font: 'Geist', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', sans-serif;
  --serif: 'Instrument Serif', 'Iowan Old Style', Georgia, serif;
  --mono: 'Geist Mono', ui-monospace, 'SFMono-Regular', Menlo, monospace;

  --max: 1200px;
  --gutter: clamp(16px, 4vw, 32px);
  --header-h: 64px;
  --ease: cubic-bezier(0.16, 1, 0.3, 1);

  color-scheme: dark;
  transition: --h 0.5s var(--ease);
}

@media (prefers-reduced-motion: reduce) {
  :root { transition: none; }
}

@media (prefers-reduced-motion: no-preference) {
  @view-transition { navigation: auto; }
}

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

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

html {
  -webkit-text-size-adjust: 100%;
  scroll-padding-top: calc(var(--header-h) + 16px);
}

@media (prefers-reduced-motion: no-preference) {
  html { scroll-behavior: smooth; }
}

body {
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100vh;
  overflow-x: clip;
}

img, svg, canvas, iframe { display: block; max-width: 100%; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; text-decoration: none; }
code, kbd { font-family: var(--mono); font-size: 0.88em; }
::selection { background: var(--accent); color: var(--accent-ink); }

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

.container {
  width: 100%;
  max-width: calc(var(--max) + var(--gutter) * 2);
  margin-inline: auto;
  padding-inline: var(--gutter);
}

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.skip-link {
  position: absolute; left: 12px; top: -48px; z-index: 100;
  padding: 8px 14px; border-radius: var(--r-sm);
  background: var(--accent); color: var(--accent-ink); font-weight: 600;
}
.skip-link:focus { top: 12px; }

/* ---------- Type ---------- */

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-family: var(--mono);
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
}
.eyebrow::before {
  content: '';
  width: 18px;
  height: 1px;
  background: currentColor;
}

.display {
  font-weight: 600;
  letter-spacing: -0.035em;
  line-height: 0.98;
  font-size: clamp(2.9rem, 8.4vw, 7rem);
  text-wrap: balance;
}

.h2 {
  font-weight: 600;
  letter-spacing: -0.03em;
  line-height: 1.04;
  font-size: clamp(2rem, 4.6vw, 3.6rem);
  text-wrap: balance;
}

.h3 {
  font-weight: 600;
  letter-spacing: -0.015em;
  line-height: 1.2;
  font-size: 1.15rem;
}

/* The serif italic word in a headline */
.ital {
  font-family: var(--serif);
  font-style: italic;
  font-weight: 400;
  letter-spacing: -0.01em;
  color: var(--accent);
}

.lede {
  font-size: clamp(1.05rem, 1.6vw, 1.25rem);
  line-height: 1.55;
  color: var(--text-2);
  max-width: 60ch;
  text-wrap: pretty;
}

.muted { color: var(--muted); }
p { text-wrap: pretty; }

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 44px;
  padding: 0 20px;
  border-radius: var(--r-pill);
  border: 1px solid transparent;
  font-weight: 600;
  font-size: 0.95rem;
  white-space: nowrap;
  transition: background-color 0.2s, border-color 0.2s, color 0.2s, translate 0.2s var(--ease);
}
.btn svg { width: 18px; height: 18px; flex-shrink: 0; }
.btn:active { translate: 0 1px; }

.btn-primary {
  background: var(--accent);
  color: var(--accent-ink);
  box-shadow: 0 0 0 1px oklch(1 0 0 / 0.08) inset, 0 10px 30px -10px var(--glow);
}
.btn-primary:hover { background: oklch(0.86 0.12 var(--h)); }

.btn-ghost {
  background: oklch(1 0 0 / 0.03);
  border-color: var(--line-2);
  color: var(--text);
}
.btn-ghost:hover { background: oklch(1 0 0 / 0.07); border-color: var(--muted); }

.btn-sm { height: 34px; padding: 0 14px; font-size: 0.85rem; }
.btn-sm svg { width: 15px; height: 15px; }

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: var(--r-pill);
  border: 1px solid var(--line);
  background: oklch(0 0 0 / 0.35);
  color: var(--text);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  transition: background-color 0.15s, border-color 0.15s, color 0.15s;
}
.icon-btn svg { width: 16px; height: 16px; }
.icon-btn:hover { background: var(--surface-3); border-color: var(--line-2); }
.icon-btn.is-done { color: var(--ok); border-color: var(--ok); }

/* ---------- Header ---------- */

.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  height: var(--header-h);
  background: color-mix(in oklch, var(--bg) 72%, transparent);
  backdrop-filter: blur(16px) saturate(1.4);
  -webkit-backdrop-filter: blur(16px) saturate(1.4);
  border-bottom: 1px solid transparent;
  transition: border-color 0.3s;
  view-transition-name: site-header;
}
.site-header.is-scrolled { border-bottom-color: var(--line); }

.header-inner {
  height: 100%;
  display: flex;
  align-items: center;
  gap: 24px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  letter-spacing: -0.01em;
  white-space: nowrap;
}

.brand-mark {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background:
    radial-gradient(circle at 30% 25%, oklch(0.9 0.12 calc(var(--h) + 40)), transparent 60%),
    conic-gradient(from 200deg, var(--accent-strong), var(--accent-2), var(--accent-strong));
  box-shadow: 0 0 0 1px oklch(1 0 0 / 0.15) inset, 0 6px 18px -6px var(--glow);
}
.brand-mark svg { width: 16px; height: 16px; color: var(--accent-ink); }

.nav {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-left: 8px;
}
.nav a {
  padding: 6px 12px;
  border-radius: var(--r-pill);
  font-size: 0.9rem;
  color: var(--muted);
  transition: color 0.15s, background-color 0.15s;
}
.nav a:hover { color: var(--text); background: oklch(1 0 0 / 0.05); }
.nav a[aria-current='page'] { color: var(--text); }

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

.gh-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 34px;
  padding: 0 12px;
  border-radius: var(--r-pill);
  font-size: 0.85rem;
  color: var(--text-2);
  border: 1px solid var(--line);
  transition: border-color 0.15s, color 0.15s;
}
.gh-link:hover { color: var(--text); border-color: var(--line-2); }
.gh-link svg { width: 16px; height: 16px; }

.menu-btn { display: none; }

@media (max-width: 820px) {
  .nav { display: none; }
  .gh-link span { display: none; }
  .menu-btn { display: inline-grid; }
  .site-header.menu-open .nav {
    display: flex;
    position: absolute;
    top: var(--header-h);
    left: 0;
    right: 0;
    flex-direction: column;
    align-items: stretch;
    gap: 2px;
    margin: 0;
    padding: 8px var(--gutter) 16px;
    background: var(--bg);
    border-bottom: 1px solid var(--line);
  }
  .site-header.menu-open .nav a { padding: 12px; font-size: 1rem; }
}

@media (max-width: 420px) {
  .header-actions .btn-get { display: none; }
}

/* ---------- Sections ---------- */

.section { padding-block: clamp(72px, 11vw, 140px); position: relative; }
.section-head { display: grid; gap: 18px; max-width: 820px; margin-bottom: clamp(36px, 5vw, 64px); }
.section-head.center { margin-inline: auto; text-align: center; justify-items: center; }

.divider {
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--line-2), transparent);
}

/* ---------- Hero ---------- */

.hero {
  position: relative;
  padding-top: clamp(48px, 8vw, 96px);
  padding-bottom: clamp(40px, 6vw, 80px);
  isolation: isolate;
}

.hero-bg {
  position: absolute;
  inset: calc(var(--header-h) * -1) 0 auto 0;
  height: 900px;
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(60% 50% at 18% 12%, oklch(0.6 0.2 var(--h) / 0.28), transparent 70%),
    radial-gradient(45% 45% at 85% 20%, oklch(0.6 0.2 calc(var(--h) + 60) / 0.2), transparent 70%);
  mask-image: linear-gradient(to bottom, #000 40%, transparent);
  -webkit-mask-image: linear-gradient(to bottom, #000 40%, transparent);
}
.hero-bg::after {
  content: '';
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(to right, oklch(1 0 0 / 0.045) 1px, transparent 1px),
    linear-gradient(to bottom, oklch(1 0 0 / 0.045) 1px, transparent 1px);
  background-size: 64px 64px;
  mask-image: radial-gradient(70% 60% at 50% 20%, #000, transparent);
  -webkit-mask-image: radial-gradient(70% 60% at 50% 20%, #000, transparent);
}

.hero-copy {
  display: grid;
  gap: 28px;
  justify-items: start;
}

.hero-row {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  justify-content: space-between;
  gap: 28px 48px;
  width: 100%;
}
.hero-row .lede { max-width: 54ch; }

.cta-row { display: flex; flex-wrap: wrap; gap: 12px; }

.fine {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 18px;
  font-size: 0.85rem;
  color: var(--muted);
}
.fine span { display: inline-flex; align-items: center; gap: 7px; }
.fine span::before {
  content: '';
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--accent);
}

/* ---------- Live demo ---------- */

.demo {
  margin-top: clamp(40px, 6vw, 72px);
  position: relative;
}

.demo-glow {
  position: absolute;
  inset: 8% 6% -4% 6%;
  z-index: -1;
  background: radial-gradient(closest-side, var(--glow), transparent);
  filter: blur(40px);
  opacity: 0.9;
}

.window {
  border-radius: var(--r-lg);
  border: 1px solid var(--line-2);
  background: var(--bg-2);
  overflow: hidden;
  box-shadow:
    0 0 0 1px oklch(0 0 0 / 0.4),
    0 40px 100px -30px oklch(0 0 0 / 0.8),
    0 1px 0 oklch(1 0 0 / 0.08) inset;
}

.window-bar {
  height: 40px;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 14px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}
.window-dots { display: flex; gap: 7px; }
.window-dots i { width: 11px; height: 11px; border-radius: 50%; background: var(--surface-3); }
.window-url {
  flex: 1;
  max-width: 420px;
  margin-inline: auto;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border-radius: 7px;
  background: var(--bg-2);
  font-size: 0.75rem;
  color: var(--muted);
  font-family: var(--mono);
  overflow: hidden;
  white-space: nowrap;
}
.window-url svg { width: 11px; height: 11px; }
.window-badge {
  font-family: var(--mono);
  font-size: 0.68rem;
  color: var(--accent);
  border: 1px solid var(--accent-line);
  background: var(--accent-soft);
  border-radius: var(--r-pill);
  padding: 2px 8px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.window-badge::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  animation: live-pulse 2s ease-in-out infinite;
}
@keyframes live-pulse { 50% { opacity: 0.3; } }
@media (prefers-reduced-motion: reduce) { .window-badge::before { animation: none; } }

.viewport {
  position: relative;
  aspect-ratio: var(--vw, 1280) / var(--vh, 800);
  overflow: hidden;
  background: #0b0b0e;
  /* The window's overflow doesn't clip the scaled frame at its rounded
     corners in every browser, so the viewport clips its own */
  clip-path: inset(0 round 0 0 calc(var(--r-lg) - 1px) calc(var(--r-lg) - 1px));
}
.viewport iframe {
  position: absolute;
  top: 0;
  left: 0;
  width: calc(var(--vw, 1280) * 1px);
  height: calc(var(--vh, 800) * 1px);
  max-width: none;
  border: 0;
  transform: scale(var(--s, 1));
  transform-origin: 0 0;
  background: transparent;
}
.viewport .viewport-msg[hidden] { display: none; }
.viewport .viewport-msg {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 0.9rem;
}

.dock {
  display: grid;
  grid-template-columns: minmax(220px, 1.4fr) minmax(160px, 1fr) auto;
  gap: 18px 28px;
  align-items: end;
  padding: 18px 20px 20px;
  border-top: 1px solid var(--line);
  background: var(--surface);
}
.dock-row-2 {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 18px;
}

.field { display: grid; gap: 8px; min-width: 0; }
.field-label {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 0.75rem;
  font-family: var(--mono);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}
.field-label output { color: var(--text-2); font-variant-numeric: tabular-nums; }

/* Range inputs: a track that shows what the slider changes */
.range {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 26px;
  background: transparent;
  cursor: pointer;
  --track: var(--surface-3);
}
.range::-webkit-slider-runnable-track {
  height: 10px;
  border-radius: var(--r-pill);
  background: var(--track);
  box-shadow: 0 0 0 1px oklch(1 0 0 / 0.08) inset;
}
.range::-moz-range-track {
  height: 10px;
  border-radius: var(--r-pill);
  background: var(--track);
  box-shadow: 0 0 0 1px oklch(1 0 0 / 0.08) inset;
}
.range::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 22px;
  height: 22px;
  margin-top: -6px;
  border-radius: 50%;
  background: oklch(0.7 0.16 var(--h));
  border: 3px solid #fff;
  box-shadow: 0 2px 10px oklch(0 0 0 / 0.5);
}
.range::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: oklch(0.7 0.16 var(--h));
  border: 3px solid #fff;
  box-shadow: 0 2px 10px oklch(0 0 0 / 0.5);
}
.range-hue {
  --track: linear-gradient(90deg in oklch longer hue, oklch(0.7 0.16 0), oklch(0.7 0.16 359.9));
}
.range-chroma {
  --track: linear-gradient(90deg, oklch(0.6 0 var(--h)), oklch(0.6 0.2 var(--h)));
}

.seg {
  display: inline-flex;
  padding: 3px;
  gap: 2px;
  border-radius: var(--r-pill);
  background: var(--bg-2);
  border: 1px solid var(--line);
}
.seg button {
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 500;
  padding: 6px 13px;
  border-radius: var(--r-pill);
  transition: color 0.15s, background-color 0.15s;
}
.seg button:hover { color: var(--text); }
.seg button[aria-pressed='true'] { background: var(--surface-3); color: var(--text); }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 32px;
  padding: 0 13px;
  border-radius: var(--r-pill);
  border: 1px solid var(--line);
  background: transparent;
  color: var(--text-2);
  font-size: 0.82rem;
  transition: border-color 0.15s, background-color 0.15s, color 0.15s;
}
.chip:hover { border-color: var(--line-2); color: var(--text); }
.chip[aria-pressed='true'] { border-color: var(--accent-line); background: var(--accent-soft); color: var(--text); }
.chip .swatch { width: 12px; height: 12px; border-radius: 4px; }
.chip-count { color: var(--faint); font-variant-numeric: tabular-nums; font-size: 0.78rem; }

.dock-note { margin-left: auto; font-size: 0.8rem; color: var(--muted); }

@media (max-width: 760px) {
  .dock { grid-template-columns: 1fr; gap: 16px; padding: 16px; }
  .dock-note { margin-left: 0; }
}

/* ---------- Stats ---------- */

.stats {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  border-block: 1px solid var(--line);
}
.stat {
  padding: 28px 20px;
  display: grid;
  gap: 4px;
  border-right: 1px solid var(--line);
  transition: background-color 0.2s;
}
.stat:last-child { border-right: 0; }
a.stat:hover { background: oklch(1 0 0 / 0.025); }
.stat-num {
  font-size: clamp(2rem, 4vw, 3rem);
  font-weight: 600;
  letter-spacing: -0.04em;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.stat-label { color: var(--muted); font-size: 0.9rem; }

@media (max-width: 760px) {
  .stats { grid-template-columns: repeat(2, 1fr); }
  .stat { border-bottom: 1px solid var(--line); }
  .stat:nth-child(2n) { border-right: 0; }
  .stat:last-child { grid-column: 1 / -1; border-bottom: 0; }
}

/* ---------- Feature rows ---------- */

.feature {
  display: grid;
  grid-template-columns: minmax(0, 5fr) minmax(0, 7fr);
  gap: clamp(32px, 6vw, 88px);
  align-items: center;
}
.feature + .feature { margin-top: clamp(80px, 11vw, 140px); }
.feature.flip { grid-template-columns: minmax(0, 7fr) minmax(0, 5fr); }
.feature.flip > .feature-copy { order: 2; }
.feature-copy { display: grid; gap: 20px; align-content: start; }
.feature-copy .h2 { font-size: clamp(1.9rem, 3.6vw, 2.9rem); }

.ticks { list-style: none; padding: 0; display: grid; gap: 10px; color: var(--text-2); }
.ticks li { position: relative; padding-left: 28px; }
.ticks li::before {
  content: '';
  width: 16px;
  height: 16px;
  position: absolute;
  left: 0;
  top: 4px;
  background: var(--accent);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 6 9 17l-5-5'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 6 9 17l-5-5'/%3E%3C/svg%3E") center / contain no-repeat;
}

.text-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--accent);
  font-weight: 500;
}
.text-link svg { width: 16px; height: 16px; transition: translate 0.2s var(--ease); }
.text-link:hover svg { translate: 3px 0; }

.panel {
  position: relative;
  border-radius: var(--r-lg);
  border: 1px solid var(--line);
  background: linear-gradient(180deg, var(--surface), var(--bg-2));
  padding: clamp(18px, 3vw, 28px);
  overflow: hidden;
}

@media (max-width: 900px) {
  .feature { grid-template-columns: 1fr; }
  .feature.flip { grid-template-columns: 1fr; }
  .feature.flip > .feature-copy { order: 0; }
}

/* Palette ramp visual */
.ramp {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 6px;
  height: 260px;
  align-items: end;
}
.ramp-step { display: grid; gap: 8px; height: 100%; grid-template-rows: 1fr auto; align-items: end; }
.ramp-swatch {
  border-radius: 10px;
  box-shadow: 0 0 0 1px oklch(1 0 0 / 0.08) inset;
  transition: background-color 0.3s;
}
.ramp-swatch { transition: background-color 0.3s, height 0.4s var(--ease); }
.ramp-name {
  font-family: var(--mono);
  font-size: 0.68rem;
  color: var(--muted);
  text-align: center;
}
.ramp-foot {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 8px 16px;
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
  font-family: var(--mono);
  font-size: 0.8rem;
  color: var(--muted);
}
.ramp-foot b { color: var(--text); font-weight: 500; }

@media (max-width: 560px) {
  .ramp { gap: 3px; height: 200px; }
  .ramp-name { font-size: 0.55rem; }
}

/* FX tiles on the home page */
.fx-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}
.fx-grid .thumb { border-radius: var(--r-md); }
.fx-grid .fx-tile { position: relative; }
.fx-grid .fx-name {
  position: absolute;
  left: 10px;
  bottom: 8px;
  z-index: 2;
  font-size: 0.78rem;
  font-weight: 500;
  text-shadow: 0 1px 8px oklch(0 0 0 / 0.8);
  pointer-events: none;
}
@media (max-width: 560px) {
  .fx-grid { grid-template-columns: repeat(2, 1fr); }
}

/* Gradient strip */
.grad-strip {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(118px, 1fr));
  gap: 10px;
}
.grad-strip a {
  display: grid;
  gap: 8px;
  font-size: 0.78rem;
  color: var(--text-2);
}
.grad-strip .grad {
  aspect-ratio: 4 / 3;
  border-radius: var(--r-sm);
  box-shadow: 0 0 0 1px oklch(1 0 0 / 0.08) inset;
  transition: translate 0.25s var(--ease);
}
.grad-strip a:hover .grad { translate: 0 -3px; }

@keyframes tdp-preview-gradient-shift {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}
@media (prefers-reduced-motion: reduce) {
  .grad, .thumb-grad { animation: none !important; }
}

/* Instance vs personal */
.layers {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
.layer { display: grid; gap: 10px; }
.layer-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.82rem;
  color: var(--muted);
}
.layer-label b { color: var(--text); font-weight: 500; }
.tag {
  font-family: var(--mono);
  font-size: 0.68rem;
  padding: 2px 8px;
  border-radius: var(--r-pill);
  border: 1px solid var(--line-2);
  color: var(--text-2);
}
@media (max-width: 560px) { .layers { grid-template-columns: 1fr; } }

/* Chat-to-theme visual */
.chat {
  display: grid;
  gap: 14px;
  font-size: 0.92rem;
}
.chat-user {
  justify-self: end;
  max-width: 80%;
  padding: 10px 16px;
  border-radius: 20px 20px 6px 20px;
  background: var(--surface-3);
}
.chat-ai { display: grid; grid-template-columns: 28px 1fr; gap: 12px; align-items: start; }
.chat-ai img { width: 28px; height: 28px; border-radius: 50%; }
.chat-ai p { color: var(--text-2); }
.tool-call {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  font-family: var(--mono);
  font-size: 0.76rem;
  color: var(--muted);
}
.tool-call::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: var(--ok); }
.chat-result {
  margin-top: 4px;
  border-radius: var(--r-md);
  border: 1px solid var(--line);
  overflow: hidden;
}
.chat-swatches { display: grid; grid-template-columns: repeat(6, 1fr); height: 54px; }
.chat-result-foot {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px;
  font-family: var(--mono);
  font-size: 0.75rem;
  color: var(--muted);
  background: var(--bg-2);
}

/* Small feature grid */
.bento {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1px;
  background: var(--line);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  overflow: hidden;
}
.bento-item {
  background: var(--bg);
  padding: 28px 26px 30px;
  display: grid;
  gap: 10px;
  align-content: start;
  transition: background-color 0.2s;
}
.bento-item:hover { background: var(--bg-2); }
.bento-icon {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 11px;
  background: var(--accent-soft);
  border: 1px solid var(--accent-line);
  color: var(--accent);
  margin-bottom: 8px;
}
.bento-icon svg { width: 19px; height: 19px; }
.bento-item p { color: var(--muted); font-size: 0.93rem; }
@media (max-width: 900px) { .bento { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 560px) { .bento { grid-template-columns: 1fr; } }

/* Install */
.steps {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  counter-reset: step;
}
.step {
  position: relative;
  padding: 26px;
  border-radius: var(--r-lg);
  border: 1px solid var(--line);
  background: var(--bg-2);
  display: grid;
  gap: 10px;
  align-content: start;
}
.step::before {
  counter-increment: step;
  content: counter(step, decimal-leading-zero);
  font-family: var(--mono);
  font-size: 0.8rem;
  color: var(--accent);
}
.step p { color: var(--muted); font-size: 0.93rem; }
.step code {
  padding: 1px 6px;
  border-radius: 6px;
  background: var(--surface-2);
  color: var(--text-2);
}
@media (max-width: 900px) { .steps { grid-template-columns: 1fr; } }

.callout {
  margin-top: 14px;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 14px;
  padding: 18px 22px;
  border-radius: var(--r-md);
  border: 1px dashed var(--line-2);
  color: var(--text-2);
  font-size: 0.93rem;
}
.callout svg { width: 20px; height: 20px; color: var(--accent); margin-top: 2px; }
.callout code { color: var(--text); }

.companion {
  margin-top: 14px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 18px 32px;
  padding: 26px 28px;
  border-radius: var(--r-lg);
  background:
    radial-gradient(80% 140% at 100% 0%, var(--accent-soft), transparent 60%),
    var(--bg-2);
  border: 1px solid var(--line);
}
.companion > div { display: grid; gap: 6px; max-width: 62ch; }
.companion p { color: var(--muted); font-size: 0.95rem; }

/* Closing band */
.finale {
  position: relative;
  text-align: center;
  display: grid;
  justify-items: center;
  gap: 28px;
  padding: clamp(64px, 9vw, 120px) var(--gutter);
  border-radius: var(--r-xl);
  border: 1px solid var(--line);
  overflow: hidden;
  isolation: isolate;
  background: var(--bg-2);
}
.finale::before {
  content: '';
  position: absolute;
  inset: -40%;
  z-index: -1;
  background: conic-gradient(from 0deg at 50% 50%, oklch(0.55 0.2 var(--h) / 0.35), oklch(0.55 0.2 calc(var(--h) + 60) / 0.25), oklch(0.55 0.2 calc(var(--h) - 60) / 0.3), oklch(0.55 0.2 var(--h) / 0.35));
  filter: blur(60px);
  animation: spin 24s linear infinite;
}
@keyframes spin { to { rotate: 1turn; } }
@media (prefers-reduced-motion: reduce) { .finale::before { animation: none; } }

/* ---------- Footer ---------- */

.site-footer {
  margin-top: clamp(72px, 10vw, 120px);
  border-top: 1px solid var(--line);
  padding-block: 48px 40px;
  color: var(--muted);
  font-size: 0.9rem;
}
.footer-grid {
  display: grid;
  grid-template-columns: 2fr repeat(3, 1fr);
  gap: 32px;
}
.footer-grid h3 {
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--faint);
  margin-bottom: 12px;
  font-weight: 500;
}
.footer-grid ul { list-style: none; padding: 0; display: grid; gap: 8px; }
.footer-grid a:hover { color: var(--text); }
.footer-about { display: grid; gap: 14px; align-content: start; max-width: 36ch; }
.footer-base {
  margin-top: 40px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 12px;
  font-size: 0.82rem;
}
@media (max-width: 760px) {
  .footer-grid { grid-template-columns: 1fr 1fr; }
  .footer-about { grid-column: 1 / -1; }
}

/* ---------- Reveal on scroll ---------- */

@media (prefers-reduced-motion: no-preference) {
  .reveal {
    opacity: 0;
    translate: 0 24px;
    transition: opacity 0.8s var(--ease), translate 0.8s var(--ease);
  }
  .reveal.is-in { opacity: 1; translate: 0 0; }
}

/* ==========================================================
   Shared preset visuals (home page and gallery)
   ========================================================== */

.thumb {
  position: relative;
  aspect-ratio: 16 / 10;
  overflow: hidden;
  background: var(--bg-2);
  isolation: isolate;
}
.thumb iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
  z-index: 1;
}

/* Canvas FX idle art: two hues from the script's name */
.thumb-fx {
  background:
    radial-gradient(70% 90% at var(--x1) var(--y1), oklch(0.62 0.19 var(--h1) / 0.75), transparent 70%),
    radial-gradient(60% 80% at var(--x2) var(--y2), oklch(0.55 0.2 var(--h2) / 0.65), transparent 70%),
    oklch(0.13 0.02 var(--h1));
}
.thumb-fx::after {
  content: '';
  position: absolute;
  inset: 0;
  background-image: radial-gradient(oklch(1 0 0 / 0.16) 1px, transparent 1.2px);
  background-size: 14px 14px;
  mask-image: linear-gradient(to top, #000, transparent 80%);
  -webkit-mask-image: linear-gradient(to top, #000, transparent 80%);
}
.thumb-play {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 3;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 26px;
  padding: 0 10px;
  border-radius: var(--r-pill);
  border: 1px solid oklch(1 0 0 / 0.18);
  background: oklch(0 0 0 / 0.45);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  font-size: 0.72rem;
  color: #fff;
  transition: opacity 0.2s;
}
.thumb-play svg { width: 11px; height: 11px; }
.thumb.is-live .thumb-play { opacity: 0; }
/* On a mouse the label only shows on hover, so a grid of scripts stays calm */
@media (hover: hover) and (pointer: fine) {
  .thumb-play { padding: 0; width: 26px; justify-content: center; }
  .thumb-play span { display: none; }
  .card:hover .thumb-play, .fx-tile:hover .thumb-play, .thumb-play:focus-visible { width: auto; padding: 0 10px; }
  .card:hover .thumb-play span, .fx-tile:hover .thumb-play span, .thumb-play:focus-visible span { display: inline; }
}
.thumb.is-live:hover .thumb-play,
.thumb.is-live:focus-within .thumb-play { opacity: 1; }

.thumb-grad { background-size: cover; }

/* Mini Open WebUI, painted by a theme's ramp */
.mini {
  --bg-m: var(--color-gray-900);
  --side-m: var(--color-gray-950);
  --bubble-m: var(--color-gray-850);
  --line-m: var(--color-gray-700);
  --line-m2: var(--color-gray-800);
  --input-m: var(--color-gray-850);
  --edge-m: var(--color-gray-800);
  position: absolute;
  inset: 0;
  display: grid;
  grid-template-columns: 26% 1fr;
  background: var(--bg-m);
  transition: background-color 0.3s;
}
.mini[data-mode='light'], .mini[data-mode='her'] {
  --bg-m: #fff;
  --side-m: var(--color-gray-50);
  --bubble-m: var(--color-gray-50);
  --line-m: var(--color-gray-200);
  --line-m2: var(--color-gray-100);
  --input-m: #fff;
  --edge-m: var(--color-gray-100);
}
.mini.has-fx .mini-main {
  background:
    radial-gradient(90% 70% at 70% 100%, oklch(0.62 0.17 var(--mh) / 0.35), transparent 70%),
    radial-gradient(50% 50% at 20% 10%, oklch(0.7 0.15 calc(var(--mh) + 40) / 0.18), transparent 70%);
}
.mini.has-fx[data-mode='light'] .mini-main, .mini.has-fx[data-mode='her'] .mini-main {
  background: radial-gradient(90% 70% at 70% 100%, oklch(0.8 0.12 var(--mh) / 0.35), transparent 70%);
}
.mini-side {
  background: var(--side-m);
  border-right: 1px solid var(--edge-m);
  padding: 12% 10%;
  display: grid;
  align-content: start;
  gap: 9%;
}
.mini-side i { height: 5px; border-radius: 3px; background: var(--line-m2); }
.mini-side i:first-child { width: 70%; background: var(--line-m); height: 7px; margin-bottom: 10%; }
.mini-side i:nth-child(3) { width: 80%; }
.mini-side i:nth-child(4) { width: 60%; }
.mini-main {
  position: relative;
  padding: 9% 12% 0;
  display: grid;
  align-content: start;
  gap: 7%;
}
.mini-bubble {
  justify-self: end;
  width: 46%;
  height: 16px;
  border-radius: 9px;
  background: var(--bubble-m);
}
.mini-lines { display: grid; gap: 6px; }
.mini-lines i { height: 5px; border-radius: 3px; background: var(--line-m); }
.mini-lines i:nth-child(2) { width: 88%; }
.mini-lines i:nth-child(3) { width: 64%; }
.mini-code { height: 22px; border-radius: 6px; background: var(--line-m2); width: 92%; }
.mini-input {
  position: absolute;
  left: 10%;
  right: 10%;
  bottom: 9%;
  height: 20px;
  border-radius: 12px;
  background: var(--input-m);
  border: 1px solid var(--edge-m);
  box-shadow: 0 4px 14px oklch(0 0 0 / 0.18);
}
.mini-flags {
  position: absolute;
  left: 8px;
  bottom: 8px;
  z-index: 2;
  display: flex;
  gap: 4px;
}

/* ==========================================================
   Gallery page
   ========================================================== */

.g-head {
  padding-top: clamp(40px, 6vw, 72px);
  padding-bottom: 28px;
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  justify-content: space-between;
  gap: 20px 40px;
}
.g-head .display { font-size: clamp(2.6rem, 6.5vw, 5rem); }
.g-head p { max-width: 52ch; color: var(--text-2); }
.how {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 0.82rem;
  color: var(--muted);
}
.how span {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px 6px 6px;
  border-radius: var(--r-pill);
  border: 1px solid var(--line);
}
.how b {
  display: grid;
  place-items: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  font-family: var(--mono);
  font-size: 0.7rem;
  font-weight: 500;
}

.g-bar {
  position: sticky;
  top: var(--header-h);
  z-index: 40;
  background: color-mix(in oklch, var(--bg) 86%, transparent);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-block: 1px solid var(--line);
}
.g-bar-inner {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-block: 12px;
}
.cats {
  display: flex;
  gap: 4px;
  overflow-x: auto;
  scrollbar-width: none;
  flex: 1;
  min-width: 0;
}
.cats::-webkit-scrollbar { display: none; }
.cat {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 38px;
  padding: 0 14px;
  border-radius: var(--r-pill);
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 500;
  transition: color 0.15s, background-color 0.15s, border-color 0.15s;
}
.cat:hover { color: var(--text); }
.cat[aria-selected='true'] { color: var(--text); background: var(--surface-2); border-color: var(--line); }
.cat-count {
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--faint);
  font-variant-numeric: tabular-nums;
}
.cat[aria-selected='true'] .cat-count { color: var(--accent); }

.search {
  position: relative;
  width: min(300px, 32vw);
  flex-shrink: 0;
}
.search svg {
  position: absolute;
  left: 13px;
  top: 50%;
  translate: 0 -50%;
  width: 16px;
  height: 16px;
  color: var(--faint);
  pointer-events: none;
}
.search input {
  width: 100%;
  height: 38px;
  padding: 0 40px 0 38px;
  border-radius: var(--r-pill);
  border: 1px solid var(--line);
  background: var(--bg-2);
  font-size: 0.9rem;
  transition: border-color 0.15s;
}
.search input::placeholder { color: var(--faint); }
.search input:focus { outline: none; border-color: var(--accent-line); box-shadow: 0 0 0 3px var(--accent-soft); }
.search input::-webkit-search-cancel-button { display: none; }
.search kbd {
  position: absolute;
  right: 10px;
  top: 50%;
  translate: 0 -50%;
  min-width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
  border-radius: 6px;
  border: 1px solid var(--line-2);
  color: var(--muted);
  font-size: 0.72rem;
  pointer-events: none;
}
.search input:focus + kbd, .search input:not(:placeholder-shown) + kbd { display: none; }

.select {
  height: 38px;
  padding: 0 34px 0 14px;
  border-radius: var(--r-pill);
  border: 1px solid var(--line);
  background:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23999' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") no-repeat right 13px center,
    var(--bg-2);
  -webkit-appearance: none;
  appearance: none;
  font-size: 0.88rem;
  color: var(--text-2);
  flex-shrink: 0;
}
.select option { background: var(--surface); color: var(--text); }

.g-sub {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-block: 22px 18px;
}
.result-count { font-size: 0.88rem; color: var(--muted); }
.result-count b { color: var(--text); font-weight: 500; }

@media (max-width: 760px) {
  .g-bar-inner { flex-wrap: wrap; }
  .cats { order: 2; flex-basis: 100%; }
  .search { flex: 1; width: auto; }
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(270px, 100%), 1fr));
  gap: 18px;
}

.card {
  position: relative;
  display: grid;
  grid-template-rows: auto 1fr;
  border-radius: var(--r-lg);
  border: 1px solid var(--line);
  background: var(--bg-2);
  overflow: hidden;
  transition: border-color 0.2s, translate 0.3s var(--ease), box-shadow 0.3s var(--ease);
  content-visibility: auto;
  contain-intrinsic-size: auto 290px;
}
.card:hover {
  border-color: var(--line-2);
  translate: 0 -3px;
  box-shadow: 0 24px 50px -24px oklch(0 0 0 / 0.7);
}
.card:has(.card-open:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }
.card-open {
  position: absolute;
  inset: 0;
  z-index: 2;
  border: 0;
  background: transparent;
  border-radius: inherit;
}
.card-open:focus-visible { outline: none; }
.card .thumb { border-bottom: 1px solid var(--line); }
.card-body {
  display: grid;
  gap: 6px;
  align-content: start;
  padding: 14px 16px 16px;
}
.card-title {
  font-size: 0.98rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.card-desc {
  font-size: 0.85rem;
  color: var(--muted);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.card-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-top: 4px;
}
/* The quick actions sit above the card's open button */
.card-actions {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 4;
  display: flex;
  gap: 6px;
  opacity: 0;
  translate: 0 -4px;
  transition: opacity 0.2s, translate 0.2s var(--ease);
}
.card:hover .card-actions,
.card:focus-within .card-actions { opacity: 1; translate: 0 0; }
@media (hover: none) {
  .card-actions { opacity: 1; translate: 0 0; }
}
.card:has(.card-actions) .thumb-play { right: auto; left: 10px; top: 10px; }

.badge {
  display: inline-flex;
  align-items: center;
  height: 21px;
  padding: 0 8px;
  border-radius: var(--r-pill);
  font-size: 0.7rem;
  font-weight: 500;
  border: 1px solid var(--line-2);
  color: var(--text-2);
  background: oklch(1 0 0 / 0.03);
  white-space: nowrap;
}
.badge-accent { color: var(--accent); border-color: var(--accent-line); background: var(--accent-soft); }
.thumb .badge {
  background: oklch(0 0 0 / 0.5);
  border-color: oklch(1 0 0 / 0.18);
  color: #fff;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

.mode-dots { display: inline-flex; gap: 4px; margin-left: auto; position: relative; z-index: 3; }
.mode-dot {
  width: 22px;
  height: 22px;
  padding: 0;
  border-radius: 50%;
  border: 1px solid var(--line-2);
  display: grid;
  place-items: center;
  background: transparent;
}
.mode-dot i { width: 12px; height: 12px; border-radius: 50%; box-shadow: 0 0 0 1px oklch(1 0 0 / 0.12) inset; }
.mode-dot[aria-pressed='true'] { border-color: var(--accent); }

/* CSS preset and bundle art */
.thumb-code {
  display: grid;
  align-content: center;
  padding: 0 10%;
  gap: 7px;
  font-family: var(--mono);
  font-size: 0.72rem;
  line-height: 1.5;
  color: var(--muted);
  background:
    radial-gradient(80% 100% at 100% 0%, oklch(0.6 0.15 var(--h1) / 0.25), transparent 70%),
    var(--bg);
}
.thumb-code .k { color: oklch(0.8 0.12 var(--h1)); }
.thumb-code .v { color: oklch(0.82 0.1 calc(var(--h1) + 120)); }
.thumb-code span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.thumb-bundle {
  display: grid;
  place-items: center;
  background:
    radial-gradient(60% 80% at 50% 120%, var(--accent-soft), transparent 70%),
    var(--bg);
}
.stack { position: relative; width: 46%; aspect-ratio: 4 / 3; }
.stack i {
  position: absolute;
  inset: 0;
  border-radius: 10px;
  border: 1px solid var(--line-2);
  background: var(--surface-2);
}
.stack i:nth-child(1) { rotate: -9deg; translate: -10% 4%; background: oklch(0.5 0.14 calc(var(--h) - 50)); }
.stack i:nth-child(2) { rotate: 6deg; translate: 9% 2%; background: oklch(0.55 0.15 calc(var(--h) + 50)); }
.stack i:nth-child(3) { background: oklch(0.62 0.15 var(--h)); display: grid; place-items: center; color: var(--accent-ink); font-family: var(--mono); font-size: 0.95rem; font-weight: 500; }

.empty, .loading {
  display: grid;
  justify-items: center;
  gap: 14px;
  padding: 80px 20px;
  color: var(--muted);
  text-align: center;
}
.empty svg { width: 40px; height: 40px; opacity: 0.5; }
.spinner {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 2px solid var(--line-2);
  border-top-color: var(--accent);
  animation: spin 0.8s linear infinite;
}
.hidden { display: none !important; }

/* Filter chips row (themes) */
.filters { display: flex; flex-wrap: wrap; gap: 6px; }

/* ---------- Detail drawer ---------- */

.drawer {
  position: fixed;
  inset: 0 0 0 auto;
  width: min(560px, 100vw);
  max-width: 100vw;
  height: 100dvh;
  max-height: 100dvh;
  margin: 0;
  padding: 0;
  border: 0;
  border-left: 1px solid var(--line-2);
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
  box-shadow: -30px 0 80px oklch(0 0 0 / 0.5);
}
.drawer[open] { display: grid; grid-template-rows: auto 1fr; }
.drawer::backdrop {
  background: oklch(0.1 0.02 var(--h) / 0.6);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}
@media (prefers-reduced-motion: no-preference) {
  .drawer[open] { animation: drawer-in 0.4s var(--ease); }
  .drawer[open]::backdrop { animation: fade-in 0.3s ease; }
}
@keyframes drawer-in { from { translate: 40px 0; opacity: 0; } }
@keyframes fade-in { from { opacity: 0; } }

.drawer-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px 14px 24px;
  border-bottom: 1px solid var(--line);
}
.drawer-kind { font-family: var(--mono); font-size: 0.75rem; letter-spacing: 0.06em; text-transform: uppercase; color: var(--accent); }
.drawer-tools { display: flex; gap: 6px; }
.drawer-scroll { overflow-y: auto; overflow-x: hidden; overscroll-behavior: contain; }
.drawer-body > *, .drawer-section > * { min-width: 0; }
.drawer-visual { position: relative; }
.drawer-visual .thumb { aspect-ratio: 16 / 10; }
.drawer-body { padding: 24px; display: grid; gap: 26px; }
.drawer-title { font-size: 1.7rem; font-weight: 600; letter-spacing: -0.025em; line-height: 1.15; }
.drawer-meta { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.drawer-desc { color: var(--text-2); }
.drawer-section { display: grid; gap: 12px; }
.drawer-label { font-family: var(--mono); font-size: 0.72rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--faint); }
.drawer-actions { display: flex; flex-wrap: wrap; gap: 8px; }

.mode-table { display: grid; grid-template-columns: repeat(auto-fill, minmax(112px, 1fr)); gap: 8px; }
.mode-cell {
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  overflow: hidden;
  background: var(--bg-2);
}
.mode-cell-sw { height: 46px; }
.mode-cell-body { padding: 8px 10px 10px; display: grid; gap: 2px; }
.mode-cell-name { font-size: 0.85rem; font-weight: 500; text-transform: capitalize; }
.mode-cell-val { font-family: var(--mono); font-size: 0.68rem; color: var(--muted); }
.mode-cell-flags { display: flex; flex-wrap: wrap; gap: 3px; margin-top: 6px; }
.mode-cell-flags .badge { height: 18px; font-size: 0.62rem; padding: 0 6px; }

.url-field {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 4px 4px 14px;
  border-radius: var(--r-md);
  border: 1px solid var(--line);
  background: var(--bg-2);
}
.url-field code {
  flex: 1;
  min-width: 0;
  font-size: 0.78rem;
  color: var(--text-2);
  overflow-x: auto;
  white-space: nowrap;
  scrollbar-width: none;
}
.url-field code::-webkit-scrollbar { display: none; }

.howto { list-style: none; padding: 0; display: grid; gap: 10px; counter-reset: h; }
.howto li { position: relative; padding-left: 34px; min-height: 22px; color: var(--text-2); font-size: 0.92rem; }
.howto li::before {
  position: absolute;
  left: 0;
  top: 0;
  counter-increment: h;
  content: counter(h);
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--surface-2);
  color: var(--accent);
  font-family: var(--mono);
  font-size: 0.72rem;
}

@media (max-width: 640px) {
  .drawer {
    inset: auto 0 0 0;
    width: 100vw;
    height: 92dvh;
    border-left: 0;
    border-top: 1px solid var(--line-2);
    border-radius: var(--r-lg) var(--r-lg) 0 0;
  }
  @keyframes drawer-in { from { translate: 0 40px; opacity: 0; } }
}

/* ---------- Toast ---------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 4000;
  translate: -50% 20px;
  opacity: 0;
  pointer-events: none;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  max-width: calc(100vw - 32px);
  padding: 11px 18px;
  border-radius: var(--r-pill);
  background: var(--text);
  color: var(--bg);
  font-size: 0.9rem;
  font-weight: 500;
  box-shadow: 0 20px 50px -10px oklch(0 0 0 / 0.6);
  transition: opacity 0.25s, translate 0.35s var(--ease);
}
.toast.show { opacity: 1; translate: -50% 0; }
.toast svg { width: 16px; height: 16px; color: var(--accent-strong); }

/* ==========================================================
   Full-screen live preview (preview.js)
   ========================================================== */

.preview-overlay {
  position: fixed;
  inset: 0;
  z-index: 3000;
  background: #0b0b0e;
  display: none;
}
.preview-overlay.open { display: block; animation: fade-in 0.25s ease; }
.preview-stage { position: absolute; inset: 0; overflow: hidden; }
.preview-stage .preview-canvas { position: absolute; inset: 0; width: 100%; height: 100%; z-index: 0; }
.preview-stage .preview-gradient-bg { position: absolute; inset: 0; z-index: 0; }
.preview-stage .preview-frame {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: none;
  z-index: 1;
  background: transparent;
}

.preview-topbar {
  position: absolute;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 14px;
  max-width: calc(100vw - 32px);
  padding: 7px 8px 7px 8px;
  background: color-mix(in oklch, var(--surface) 84%, transparent);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--line-2);
  border-radius: var(--r-pill);
  box-shadow: 0 12px 40px oklch(0 0 0 / 0.5);
}
.preview-titlebox { display: flex; align-items: center; gap: 10px; white-space: nowrap; }
.preview-label {
  font-family: var(--mono);
  font-size: 0.65rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--accent-ink);
  background: var(--accent);
  padding: 4px 10px;
  border-radius: var(--r-pill);
}
.preview-title {
  font-size: 0.88rem;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 30vw;
}
.preview-controls-box { display: flex; align-items: center; gap: 12px; }
.preview-pills {
  display: flex;
  gap: 2px;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--r-pill);
  padding: 3px;
}
.preview-pill {
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 500;
  padding: 4px 12px;
  border-radius: var(--r-pill);
  transition: background-color 0.15s, color 0.15s;
}
.preview-pill:hover { color: var(--text); }
.preview-pill.active { background: var(--surface-3); color: var(--text); }
.preview-hint { font-size: 0.72rem; color: var(--muted); white-space: nowrap; }
.preview-context, .preview-scale {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.72rem;
  color: var(--muted);
  white-space: nowrap;
}
.preview-context input[type='range'] { width: 110px; accent-color: var(--accent); }
.preview-scale input[type='range'] { width: 90px; accent-color: var(--accent); }
.preview-scale output { min-width: 30px; font-variant-numeric: tabular-nums; }
.preview-close {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1px solid var(--line-2);
  background: var(--surface-2);
  color: var(--text);
  display: grid;
  place-items: center;
  flex-shrink: 0;
  transition: background-color 0.15s;
}
.preview-close:hover { background: var(--surface-3); }
.preview-close svg { width: 18px; height: 18px; }
.preview-status {
  position: absolute;
  bottom: 22px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 10;
  display: none;
  max-width: min(560px, calc(100vw - 40px));
  padding: 10px 18px;
  background: color-mix(in oklch, var(--surface) 90%, transparent);
  backdrop-filter: blur(12px);
  border: 1px solid var(--line-2);
  border-radius: var(--r-md);
  font-size: 0.82rem;
  color: var(--text-2);
  text-align: center;
}
.preview-status.visible { display: block; }

@media (max-width: 767px) {
  .preview-topbar { top: 8px; max-width: calc(100vw - 16px); gap: 8px; padding: 5px 6px; }
  .preview-titlebox, .preview-hint, .preview-context, .preview-scale { display: none; }
  .preview-close { width: 30px; height: 30px; }
}

/* Cards open on a click anywhere, so a playing script doesn't swallow it */
.card .thumb { z-index: 3; }
.card .thumb iframe { pointer-events: none; }

/* The mock pages declare no color-scheme. A frame whose scheme differs from
   this dark page gets an opaque white backdrop, hiding the effect behind it. */
iframe { color-scheme: normal; }
@media (hover: none) { .search kbd { display: none; } }

.thumb-play.thumb-note,
.card:hover .thumb-play.thumb-note { width: auto; padding: 0 10px; color: oklch(1 0 0 / 0.75); cursor: default; }

/* ==========================================================
   Studio
   ========================================================== */

.studio {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 420px;
  gap: 28px;
  width: 100%;
  max-width: 2400px;
  margin-inline: auto;
  padding: 24px var(--gutter) 48px;
  align-items: start;
}
.studio-stage {
  position: sticky;
  top: calc(var(--header-h) + 20px);
  display: grid;
  gap: 12px;
}
.studio-note { font-size: 0.82rem; color: var(--faint); }
.studio-panel {
  display: grid;
  gap: 4px;
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--bg-2);
  overflow: hidden;
}
.studio-head { display: grid; gap: 10px; padding: 24px 22px 18px; }
.studio-head .h2 { font-size: 1.9rem; }
.studio-head p { font-size: 0.92rem; }
.studio-sec {
  display: grid;
  gap: 14px;
  padding: 18px 22px 20px;
  border-top: 1px solid var(--line);
}
.studio-sec-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.studio-label {
  font-family: var(--mono);
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--faint);
}
.studio-hint { font-size: 0.84rem; color: var(--muted); }
.studio-select { width: 100%; border-radius: var(--r-md); }
.studio-export { background: var(--bg); }
.studio-export .howto { margin-top: 4px; }

.seg-wide { display: flex; }
.seg-wide button { flex: 1; }

.range-light {
  --track: linear-gradient(90deg, oklch(0.16 0.03 var(--studio-h, 265)), oklch(0.98 0.03 var(--studio-h, 265)));
}

.mini-ramp {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  height: 34px;
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 0 0 1px oklch(1 0 0 / 0.08) inset;
}

.input {
  width: 100%;
  height: 40px;
  padding: 0 14px;
  border-radius: var(--r-md);
  border: 1px solid var(--line);
  background: var(--bg);
  font-size: 0.92rem;
}
.input::placeholder { color: var(--faint); }
.input:focus { outline: none; border-color: var(--accent-line); box-shadow: 0 0 0 3px var(--accent-soft); }

.switch {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: 0.84rem;
  color: var(--text-2);
  cursor: pointer;
}
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch-ui {
  position: relative;
  width: 36px;
  height: 20px;
  border-radius: 999px;
  background: var(--surface-3);
  transition: background-color 0.2s;
  flex-shrink: 0;
}
.switch-ui::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  transition: translate 0.2s var(--ease);
}
.switch input:checked + .switch-ui { background: var(--accent-strong); }
.switch input:checked + .switch-ui::after { translate: 16px 0; }
.switch input:focus-visible + .switch-ui { outline: 2px solid var(--accent); outline-offset: 2px; }

.grad-pick {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-top: 12px;
}
.grad-pick button {
  display: grid;
  gap: 5px;
  padding: 0;
  border: 0;
  background: transparent;
  text-align: left;
}
.grad-pick .grad {
  aspect-ratio: 4 / 3;
  border-radius: 9px;
  box-shadow: 0 0 0 1px oklch(1 0 0 / 0.1) inset;
  outline: 2px solid transparent;
  outline-offset: 2px;
  transition: outline-color 0.15s;
}
.grad-pick button[aria-pressed='true'] .grad { outline-color: var(--accent); }
.grad-pick .grad-name {
  font-size: 0.7rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.fx-pick {
  margin-top: 10px;
  max-height: 280px;
  overflow-y: auto;
  overscroll-behavior: contain;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--bg);
}
.fx-pick button {
  width: 100%;
  display: grid;
  grid-template-columns: 14px 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: transparent;
  text-align: left;
  font-size: 0.86rem;
  color: var(--text-2);
}
.fx-pick button:last-child { border-bottom: 0; }
.fx-pick button:hover { background: oklch(1 0 0 / 0.04); color: var(--text); }
.fx-pick button[aria-selected='true'] { background: var(--accent-soft); color: var(--text); }
.fx-pick button:disabled { opacity: 0.45; cursor: not-allowed; }
.fx-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, oklch(0.85 0.15 var(--h1)), oklch(0.5 0.18 calc(var(--h1) + 60)));
}
.fx-row-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fx-row-tag { font-size: 0.72rem; color: var(--faint); white-space: nowrap; }

/* Animation settings: the picked script's CONFIG as controls */
.fx-settings {
  margin-top: 12px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--bg);
}
.fx-settings > summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  cursor: pointer;
  font-size: 0.86rem;
  color: var(--text-2);
  list-style: none;
}
.fx-settings > summary::-webkit-details-marker { display: none; }
.fx-settings > summary::after {
  content: '';
  width: 7px;
  height: 7px;
  margin-left: auto;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: rotate(45deg);
  transition: transform 0.15s;
}
.fx-settings[open] > summary::after { transform: rotate(225deg); }
.fx-settings > summary:hover { color: var(--text); }
.fx-settings-count { font-size: 0.72rem; color: var(--faint); font-family: var(--mono); }
.fx-settings[open] { padding-bottom: 12px; }
.fx-settings > .studio-hint { padding: 0 12px; margin: 0 0 4px; }
.fx-settings-body { display: grid; gap: 14px; padding: 8px 12px 14px; }
.fx-settings > .chip { margin: 0 12px; }
.fx-settings > .chip:disabled { opacity: 0.45; cursor: default; }
.fx-set-section {
  margin: 6px 0 -4px;
  font-size: 0.68rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--faint);
}
.fx-set-hint { display: block; font-size: 0.76rem; color: var(--faint); font-weight: 400; line-height: 1.35; }
.fx-set.field { gap: 6px; }
.fx-set-text { display: grid; gap: 2px; min-width: 0; }
.fx-set-color { display: flex; align-items: center; gap: 10px; }
.fx-set-color input[type='color'] {
  flex: none;
  width: 34px;
  height: 26px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: transparent;
}

/* Wide screens: the preview fills the window's height, and the mock lays
   itself out to that shape (mockStage's fill option) */
@media (min-width: 1081px) {
  .studio .viewport {
    aspect-ratio: auto;
    height: max(460px, calc(100dvh - var(--header-h) - 150px));
  }
}

@media (max-width: 1080px) {
  /* Block flow, so the sticky preview can stick across the whole panel */
  .studio { display: block; padding-top: 0; }
  .studio-panel { margin-top: 16px; }
  /* The preview stays in view above the controls while you change them */
  .studio-stage {
    top: var(--header-h);
    z-index: 30;
    margin-inline: calc(var(--gutter) * -1);
    padding: 12px var(--gutter);
    background: color-mix(in oklch, var(--bg) 92%, transparent);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--line);
  }
  .studio-stage .window-bar { display: none; }
  .studio-stage .viewport { clip-path: inset(0 round calc(var(--r-lg) - 1px)); }
  .studio-note { display: none; }
}
@media (max-width: 1080px) and (max-height: 600px) {
  .studio-stage { position: static; }
}
@media (max-width: 560px) {
  .grad-pick { grid-template-columns: repeat(3, 1fr); }
}

/* ==========================================================
   One-click install
   ========================================================== */

.install-dialog {
  width: min(460px, calc(100vw - 32px));
  margin: auto;
  padding: 0;
  border: 1px solid var(--line-2);
  border-radius: var(--r-lg);
  background: var(--bg-2);
  color: var(--text);
  box-shadow: 0 40px 100px -20px oklch(0 0 0 / 0.7);
}
.install-dialog::backdrop {
  background: oklch(0.1 0.02 var(--h) / 0.6);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}
@media (prefers-reduced-motion: no-preference) {
  .install-dialog[open] { animation: fade-in 0.25s ease; }
}
.install-form { display: grid; gap: 16px; padding: 24px; }
.install-form .muted { font-size: 0.92rem; }
.install-scope { border: 0; padding: 0; margin: 0; display: grid; gap: 8px; }
.install-scope legend { margin-bottom: 8px; }
.radio {
  display: grid;
  grid-template-columns: 18px 1fr;
  gap: 10px;
  align-items: start;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  cursor: pointer;
  transition: border-color 0.15s, background-color 0.15s;
}
.radio:has(input:checked) { border-color: var(--accent-line); background: var(--accent-soft); }
.radio input { margin-top: 3px; accent-color: var(--accent-strong); }
.radio span { display: grid; gap: 2px; font-size: 0.92rem; }
.radio small { color: var(--muted); font-size: 0.8rem; }
.install-error { color: oklch(0.75 0.15 25); font-size: 0.85rem; }

.install-note {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  font-size: 0.82rem;
  color: var(--muted);
}
.install-note b { color: var(--text-2); font-weight: 500; }
.linklike {
  border: 0;
  padding: 0;
  background: none;
  color: var(--accent);
  font-size: inherit;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.btn-wide { width: 100%; height: 48px; }
