/* ============================================================
   GENERATOR CHROME — stage, moving backdrop, control panel.
   None of this is part of what users copy; it's the workbench.
   ============================================================ */
*, *::before, *::after { box-sizing: border-box; }
:root {
  --panel-w: 372px;
  --ink: #0b0b0f;
  --panel-bg: rgba(16, 16, 22, 0.72);
  --hair: rgba(255, 255, 255, 0.10);
  --txt: #f4f4f6;
  --txt-dim: rgba(244, 244, 246, 0.55);
  --acc: #8ab4ff;
}
html, body { height: 100%; }
body {
  margin: 0;
  font-family: "Inter", system-ui, sans-serif;
  background: #0b0b0f;
  color: var(--txt);
  overflow: hidden;
}
.lg-defs { position: absolute; }

/* ---------- STAGE ---------- */
.stage {
  position: fixed;
  inset: 0 var(--panel-w) 0 0;
  display: grid;
  place-items: center;
  overflow: hidden;
}
.stage-bg { position: absolute; inset: 0; z-index: 0; background-size: cover; background-position: center; }
.lg-wrap { position: relative; z-index: 2; touch-action: none; }
.lg { cursor: grab; user-select: none; }
.lg[hidden] { display: none; }
.lg:active { cursor: grabbing; }
.lg:focus-visible { outline: 2px solid var(--acc); outline-offset: 6px; }

.stage-hint {
  position: absolute; bottom: 22px; left: 50%; transform: translateX(-50%);
  z-index: 3; margin: 0;
  font: 500 12px/1 "JetBrains Mono", monospace; letter-spacing: 0.04em;
  color: rgba(255, 255, 255, 0.55);
  background: rgba(0, 0, 0, 0.28);
  padding: 8px 14px; border-radius: 999px;
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  pointer-events: none; white-space: nowrap;
}

/* ---------- BACKDROP MODE: TILES ---------- */
.lanes { position: absolute; inset: -8% -2%; display: flex; gap: 18px; }
.lane { flex: 1; display: flex; flex-direction: column; gap: 18px; animation: lane-up 26s linear infinite; will-change: transform; }
.lane:nth-child(even) { animation-direction: reverse; animation-duration: 32s; }
.lane:nth-child(3n) { animation-duration: 22s; }
@keyframes lane-up { from { transform: translateY(0); } to { transform: translateY(-50%); } }
.tile {
  flex: 0 0 auto; height: 190px; border-radius: 18px;
  display: flex; flex-direction: column; justify-content: space-between;
  padding: 18px; color: #fff; overflow: hidden;
}
.tile b { font: 800 40px/1 "Inter", sans-serif; letter-spacing: -0.03em; }
.tile span { font: 600 12px/1 "JetBrains Mono", monospace; letter-spacing: 0.14em; opacity: 0.9; }

/* ---------- BACKDROP MODE: TYPE ---------- */
.typewall { position: absolute; inset: 0; display: flex; flex-direction: column; justify-content: center; gap: clamp(4px, 1.2vh, 14px); background: #0b0b0f; }
.typerow { display: flex; white-space: nowrap; animation: marquee 24s linear infinite; will-change: transform; }
.typerow:nth-child(even) { animation-direction: reverse; animation-duration: 30s; }
.typerow span {
  font: 800 clamp(48px, 9vh, 110px)/0.95 "Inter", sans-serif;
  letter-spacing: -0.04em; padding-right: 0.35em; flex: 0 0 auto;
  background: linear-gradient(90deg, #ff7a59, #ffb43d, #6ee7ff, #b388ff);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.typerow:nth-child(3n) span { background: linear-gradient(90deg, #34d399, #60a5fa, #f472b6); -webkit-background-clip: text; background-clip: text; }
@keyframes marquee { from { transform: translateX(0); } to { transform: translateX(-50%); } }

/* ---------- BACKDROP MODE: MESH ---------- */
.mesh { position: absolute; inset: -20%; filter: blur(40px) saturate(1.3); }
.mesh i { position: absolute; width: 50%; height: 50%; border-radius: 50%; mix-blend-mode: screen; animation: drift 22s ease-in-out infinite alternate; }
.mesh i:nth-child(1) { background: #6d28d9; top: 4%; left: 6%; }
.mesh i:nth-child(2) { background: #db2777; top: 30%; left: 52%; animation-duration: 28s; }
.mesh i:nth-child(3) { background: #0ea5e9; top: 50%; left: 12%; animation-duration: 25s; }
.mesh i:nth-child(4) { background: #f59e0b; top: 8%; left: 58%; animation-duration: 30s; }
@keyframes drift { from { transform: translate(-6%, -4%) scale(1); } to { transform: translate(10%, 8%) scale(1.25); } }

/* ---------- BACKDROP MODE: MONO ---------- */
.mono { position: absolute; inset: 0; background: #111; overflow: hidden; }
.mono .typewall { background: transparent; }
.mono .typerow span { background: none; -webkit-text-fill-color: #fff; color: #fff; }
.mono .typerow:nth-child(even) span { -webkit-text-fill-color: #111; color: #111; -webkit-text-stroke: 2px #fff; }

/* ---------- PANEL ---------- */
.panel {
  position: fixed; inset: 0 0 0 auto; width: var(--panel-w); z-index: 10;
  display: flex; flex-direction: column;
  background: var(--panel-bg);
  -webkit-backdrop-filter: blur(28px) saturate(1.4); backdrop-filter: blur(28px) saturate(1.4);
  border-left: 1px solid var(--hair);
  overflow-y: auto;
}
.panel-head { padding: 22px 22px 16px; border-bottom: 1px solid var(--hair); position: sticky; top: 0; background: var(--panel-bg); backdrop-filter: blur(28px); -webkit-backdrop-filter: blur(28px); z-index: 5; }
.panel-brand { display: flex; align-items: center; gap: 10px; }
.panel-dot { width: 14px; height: 14px; border-radius: 50%; background: linear-gradient(135deg, #8ab4ff, #c084fc); box-shadow: 0 0 16px rgba(138, 180, 255, 0.7); }
.panel-head h1 { margin: 0; font: 700 17px/1 "Inter", sans-serif; letter-spacing: -0.01em; }
.panel-tag { margin: 6px 0 0; font: 500 12px/1.3 "JetBrains Mono", monospace; color: var(--txt-dim); }

.panel-block { padding: 16px 22px 6px; }
.panel-label { font: 600 10.5px/1 "JetBrains Mono", monospace; letter-spacing: 0.16em; text-transform: uppercase; color: var(--txt-dim); margin-bottom: 10px; }

/* segmented controls + presets */
.seg { display: flex; gap: 6px; background: rgba(255, 255, 255, 0.05); padding: 4px; border-radius: 10px; }
.seg button {
  flex: 1; padding: 8px 0; font: 600 12px/1 "Inter", sans-serif; color: var(--txt-dim);
  background: none; border: 0; border-radius: 7px; cursor: pointer; transition: background 160ms, color 160ms;
}
.seg button:hover { color: var(--txt); }
.seg button.is-on { background: rgba(255, 255, 255, 0.12); color: #fff; }

.presets { display: flex; flex-wrap: wrap; gap: 6px; }
.presets button {
  padding: 7px 12px; font: 500 12px/1 "Inter", sans-serif; color: var(--txt);
  background: rgba(255, 255, 255, 0.06); border: 1px solid var(--hair); border-radius: 999px; cursor: pointer;
  transition: background 160ms, border-color 160ms;
}
.presets button:hover { background: rgba(255, 255, 255, 0.14); border-color: rgba(255, 255, 255, 0.25); }
.presets .preset-random {
  background: linear-gradient(135deg, rgba(138, 180, 255, 0.18), rgba(192, 132, 252, 0.18));
  border-color: rgba(138, 180, 255, 0.4); color: #fff;
}
.presets .preset-random:hover { background: linear-gradient(135deg, rgba(138, 180, 255, 0.32), rgba(192, 132, 252, 0.32)); }

/* sliders */
.panel-controls { padding: 8px 22px 4px; }
.ctl { margin: 14px 0; }
.ctl-row { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 8px; }
.ctl-row label { font: 500 13px/1 "Inter", sans-serif; color: var(--txt); }
.ctl-row output { font: 500 12px/1 "JetBrains Mono", monospace; color: var(--acc); }
input[type="range"] {
  -webkit-appearance: none; appearance: none; width: 100%; height: 5px; border-radius: 99px; cursor: pointer;
  background: linear-gradient(90deg, var(--acc) var(--fill, 50%), rgba(255, 255, 255, 0.14) var(--fill, 50%));
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 16px; height: 16px; border-radius: 50%; background: #fff;
  border: 0; box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4); cursor: grab;
}
input[type="range"]::-moz-range-thumb { width: 16px; height: 16px; border-radius: 50%; background: #fff; border: 0; box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4); }

/* colour control */
.ctl-color { display: flex; align-items: center; justify-content: space-between; margin: 16px 0; }
.ctl-color label { font: 500 13px/1 "Inter", sans-serif; }
.swatch { position: relative; width: 44px; height: 28px; border-radius: 8px; overflow: hidden; border: 1px solid var(--hair); }
.swatch input { position: absolute; inset: -8px; width: 200%; height: 200%; border: 0; padding: 0; cursor: pointer; }

/* actions */
.panel-actions { display: flex; gap: 10px; padding: 16px 22px; position: sticky; bottom: 0; background: var(--panel-bg); backdrop-filter: blur(28px); -webkit-backdrop-filter: blur(28px); border-top: 1px solid var(--hair); }
.btn-primary {
  flex: 1; padding: 13px 0; font: 600 14px/1 "Inter", sans-serif; color: var(--ink);
  background: #fff; border: 0; border-radius: 10px; cursor: pointer; transition: transform 140ms, box-shadow 140ms;
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 8px 24px rgba(255, 255, 255, 0.18); }
.btn-primary:active { transform: translateY(0); }
.btn-ghost {
  padding: 13px 18px; font: 600 14px/1 "Inter", sans-serif; color: var(--txt);
  background: rgba(255, 255, 255, 0.06); border: 1px solid var(--hair); border-radius: 10px; cursor: pointer; transition: background 140ms;
}
.btn-ghost:hover { background: rgba(255, 255, 255, 0.14); }

/* code drawer */
.panel-code { padding: 0 22px 12px; }
.panel-code summary { font: 500 12px/1 "JetBrains Mono", monospace; color: var(--txt-dim); cursor: pointer; padding: 6px 0; }
.panel-code pre {
  margin: 8px 0 0; padding: 14px; max-height: 240px; overflow: auto;
  font: 400 11.5px/1.6 "JetBrains Mono", monospace; color: #c8d3e0;
  background: rgba(0, 0, 0, 0.4); border: 1px solid var(--hair); border-radius: 10px; white-space: pre;
}
.panel-foot {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 4px 22px 22px; font: 500 11px/1.4 "JetBrains Mono", monospace; color: var(--txt-dim);
}
.by-offsite {
  display: inline-flex; align-items: center; gap: 6px; flex: 0 0 auto;
  color: rgba(244, 244, 246, 0.4); text-decoration: none; letter-spacing: 0.02em;
  transition: color 160ms, opacity 160ms;
}
.by-offsite img { opacity: 0.55; transition: opacity 160ms; }
.by-offsite:hover { color: rgba(244, 244, 246, 0.85); }
.by-offsite:hover img { opacity: 1; }

/* toast */
.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translate(-50%, 12px); z-index: 100;
  padding: 12px 20px; font: 600 13px/1 "Inter", sans-serif; color: var(--ink);
  background: #fff; border-radius: 10px; box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
  opacity: 0; pointer-events: none; transition: opacity 220ms, transform 220ms;
}
.toast.is-on { opacity: 1; transform: translate(-50%, 0); }

/* ---------- RESPONSIVE: panel becomes a bottom sheet ---------- */
@media (max-width: 880px) {
  :root { --panel-w: 0px; }
  .stage { inset: 0 0 46vh 0; }
  .panel { inset: auto 0 0 0; width: 100%; height: 46vh; border-left: 0; border-top: 1px solid var(--hair); }
  .stage-hint { bottom: 12px; }
}
@media (prefers-reduced-motion: reduce) {
  .lane, .typerow, .mesh i { animation: none; }
}
