/* ============================================================
   LUMEN — generative shader studio
   dark precision-instrument UI
   ============================================================ */

:root {
  --bg: #09090b;
  --bg-stage: #0c0c0f;
  --bg-rail: rgba(17, 17, 21, 0.82);
  --bg-raised: rgba(255, 255, 255, 0.045);
  --bg-hover: rgba(255, 255, 255, 0.09);
  --line: rgba(255, 255, 255, 0.10);
  --line-soft: rgba(255, 255, 255, 0.06);
  --glass-hi: rgba(255, 255, 255, 0.14);
  --text: #ececef;
  --text-mid: #9b9ba4;
  --text-dim: #5e5e68;
  --focus: #d7d7de;
  --radius-s: 9px;
  --radius-m: 13px;
  --radius-l: 18px;
  --font-ui: "Inter", -apple-system, "Segoe UI", sans-serif;
  --font-display: "Space Grotesk", var(--font-ui);
  --font-mono: "IBM Plex Mono", ui-monospace, "Cascadia Mono", monospace;
  --topbar-h: 54px;
  --rail-w: 312px;
}

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

:root { color-scheme: dark; }

html, body { height: 100%; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 13px;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

.mono { font-family: var(--font-mono); }
.dim { color: var(--text-dim); }

button { font: inherit; color: inherit; cursor: pointer; background: none; border: none; }

/* ---------- top bar ---------- */

.topbar {
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 14px 0 18px;
  border-bottom: 1px solid var(--line-soft);
  background: rgba(12, 12, 15, 0.75);
  backdrop-filter: blur(18px) saturate(1.2);
  -webkit-backdrop-filter: blur(18px) saturate(1.2);
  position: relative;
  z-index: 5;
}

.brand { display: flex; align-items: baseline; gap: 10px; min-width: 260px; }
.brand-mark { width: 17px; height: 17px; color: var(--text); align-self: center; }
.brand-name {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 15px;
  letter-spacing: 0.22em;
}
.brand-sub {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--text-dim);
  letter-spacing: 0.04em;
}

.topbar-center { display: flex; justify-content: center; }

.topbar-actions { display: flex; align-items: center; gap: 8px; min-width: 260px; justify-content: flex-end; }
.topbar-divider { width: 1px; height: 22px; background: var(--line); margin: 0 4px; }

/* ---------- buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 33px;
  padding: 0 14px;
  border-radius: var(--radius-s);
  border: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(255,255,255,0.07), rgba(255,255,255,0.025));
  box-shadow: inset 0 1px 0 var(--glass-hi), 0 1px 3px rgba(0,0,0,0.3);
  color: var(--text);
  font-size: 12.5px;
  font-weight: 500;
  text-decoration: none;
  transition: background 160ms ease, border-color 160ms ease, transform 140ms cubic-bezier(.34,1.56,.64,1), box-shadow 160ms ease;
  white-space: nowrap;
}
.btn svg { width: 14px; height: 14px; flex: none; transition: transform 220ms cubic-bezier(.34,1.56,.64,1); }
.btn:hover {
  background: linear-gradient(180deg, rgba(255,255,255,0.12), rgba(255,255,255,0.05));
  border-color: rgba(255,255,255,0.20);
  transform: translateY(-1px);
  box-shadow: inset 0 1px 0 var(--glass-hi), 0 6px 16px -6px rgba(0,0,0,0.55);
}
.btn:hover svg { transform: scale(1.18) rotate(-4deg); }
.btn:active { transform: translateY(0.5px) scale(0.98); }

.btn-primary {
  background: linear-gradient(180deg, #ffffff, #dfdfe6);
  border-color: rgba(255,255,255,0.85);
  color: #0a0a0c;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.9), 0 2px 8px -2px rgba(255,255,255,0.18);
}
.btn-primary:hover {
  background: linear-gradient(180deg, #ffffff, #f2f2f6);
  border-color: #fff;
  box-shadow: inset 0 1px 0 #fff, 0 8px 22px -6px rgba(255,255,255,0.28);
}

.btn-ghost {
  background: transparent;
  border-color: transparent;
  box-shadow: none;
  color: var(--text-mid);
}
.btn-ghost:hover { color: var(--text); background: var(--bg-hover); border-color: var(--line); }

.icon-btn {
  width: 28px; height: 28px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: var(--radius-s);
  color: var(--text-mid);
  transition: background 130ms ease, color 130ms ease;
}
.icon-btn svg { width: 13px; height: 13px; }
.icon-btn:hover { background: var(--bg-hover); color: var(--text); }

/* ---------- segmented control ---------- */

.segmented {
  display: inline-flex;
  background: var(--bg-raised);
  border: 1px solid var(--line);
  border-radius: var(--radius-s);
  padding: 2px;
  gap: 2px;
}
.segmented button {
  height: 24px;
  padding: 0 10px;
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-dim);
  transition: background 120ms ease, color 120ms ease;
}
.segmented button:hover { color: var(--text-mid); }
.segmented button.active { background: #26262d; color: var(--text); }

/* ---------- layout ---------- */

.app {
  display: flex;
  height: calc(100vh - var(--topbar-h));
}

.stage {
  flex: 1;
  display: flex;
  flex-direction: column;
  background:
    radial-gradient(ellipse 90% 70% at 50% 42%, #101016 0%, var(--bg-stage) 70%);
  min-width: 0;
  position: relative;
}

.canvas-frame {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 34px 40px 18px;
  min-height: 0;
}

#view {
  max-width: 100%;
  max-height: 100%;
  border-radius: var(--radius-l);
  box-shadow:
    0 0 0 1px rgba(255,255,255,0.07),
    inset 0 1px 0 rgba(255,255,255,0.08),
    0 30px 80px -20px rgba(0,0,0,0.9),
    0 8px 26px -10px rgba(0,0,0,0.65);
  background: #000;
}

.stage-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 22px 14px;
  flex: none;
}
.meta-left, .meta-right { display: flex; align-items: center; gap: 10px; }
.meta-item { font-size: 11px; letter-spacing: 0.03em; }
.meta-sep { width: 3px; height: 3px; border-radius: 50%; background: var(--line); }

/* ---------- control rail ---------- */

.rail {
  width: var(--rail-w);
  flex: none;
  background: var(--bg-rail);
  backdrop-filter: blur(22px) saturate(1.25);
  -webkit-backdrop-filter: blur(22px) saturate(1.25);
  border-left: 1px solid var(--line-soft);
  box-shadow: inset 1px 0 0 rgba(255,255,255,0.03);
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.14) transparent;
}
.rail::-webkit-scrollbar { width: 9px; }
.rail::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.12);
  border-radius: 5px;
  border: 3px solid transparent;
  background-clip: content-box;
}
.rail::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.22); background-clip: content-box; }

.rail-section { border-bottom: 1px solid var(--line-soft); padding: 14px 16px 17px; }
.rail-section:last-child { border-bottom: none; padding-bottom: 28px; }

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.section-title {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.18em;
  color: var(--text-dim);
  text-transform: uppercase;
}
.section-dice {
  width: 24px; height: 24px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 5px;
  color: var(--text-dim);
  transition: background 120ms ease, color 120ms ease, transform 80ms ease;
}
.section-dice svg { width: 12px; height: 12px; }
.section-dice:hover { background: var(--bg-hover); color: var(--text); }
.section-dice:active { transform: rotate(90deg); }

/* ---------- mode grid ---------- */

.mode-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}
.mode-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 9px 2px 8px;
  border-radius: var(--radius-s);
  border: 1px solid var(--line-soft);
  background: linear-gradient(180deg, rgba(255,255,255,0.04), rgba(255,255,255,0.012));
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.05);
  color: var(--text-dim);
  transition: border-color 160ms ease, color 160ms ease, background 160ms ease,
    transform 180ms cubic-bezier(.34,1.56,.64,1);
}
.mode-card svg { width: 26px; height: 18px; transition: transform 220ms cubic-bezier(.34,1.56,.64,1); }
.mode-card span { font-size: 10px; font-weight: 500; letter-spacing: 0.02em; }
.mode-card:hover { color: var(--text-mid); border-color: rgba(255,255,255,0.16); transform: translateY(-1.5px); }
.mode-card:hover svg { transform: scale(1.15); }
.mode-card:active { transform: scale(0.96); }
.mode-card.active {
  border-color: rgba(255,255,255,0.34);
  background: linear-gradient(180deg, rgba(255,255,255,0.13), rgba(255,255,255,0.05));
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.2), 0 4px 14px -6px rgba(0,0,0,0.6);
  color: var(--text);
}

.style-lock {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
  color: var(--text-dim);
  font-size: 11.5px;
  user-select: none;
  cursor: pointer;
}
.style-lock input { display: none; }
.lock-box {
  width: 14px; height: 14px;
  border: 1px solid var(--line);
  border-radius: 4px;
  display: inline-flex; align-items: center; justify-content: center;
  transition: background 120ms ease, border-color 120ms ease;
}
.lock-box svg { width: 8px; height: 8px; opacity: 0; transition: opacity 120ms ease; }
.style-lock input:checked + .lock-box { background: var(--text); border-color: var(--text); }
.style-lock input:checked + .lock-box svg { opacity: 1; }

/* ---------- palette ---------- */

.preset-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 14px;
}
.preset-chip {
  height: 22px;
  width: 46px;
  border-radius: 5px;
  border: 1px solid rgba(255,255,255,0.08);
  overflow: hidden;
  display: flex;
  padding: 0;
  transition: transform 100ms ease, border-color 120ms ease;
}
.preset-chip i { flex: 1; display: block; }
.preset-chip:hover { transform: translateY(-1px); border-color: rgba(255,255,255,0.3); }
.preset-chip.active { border-color: #fff; box-shadow: 0 0 0 1px #fff inset; }

.swatch-row {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 14px;
}
.swatch {
  position: relative;
  width: 34px; height: 34px;
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,0.10);
  overflow: hidden;
  flex: none;
  cursor: pointer;
  transition: transform 100ms ease;
}
.swatch:hover { transform: scale(1.06); }
.swatch input {
  position: absolute;
  inset: -8px;
  width: calc(100% + 16px);
  height: calc(100% + 16px);
  border: none;
  padding: 0;
  cursor: pointer;
  opacity: 0;
}
.swatch-label {
  font-family: var(--font-mono);
  font-size: 9px;
  color: var(--text-dim);
  text-align: center;
  margin-top: 4px;
  letter-spacing: 0.05em;
}
.swatch-wrap { display: flex; flex-direction: column; }
.swatch-gap { width: 1px; height: 30px; background: var(--line); margin: 0 3px; align-self: flex-start; margin-top: 2px; }

/* ---------- sliders ---------- */

.ctl { margin-bottom: 11px; }
.ctl:last-child { margin-bottom: 0; }

.ctl-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 5px;
}
.ctl-label { font-size: 11.5px; font-weight: 500; color: var(--text-mid); }
.ctl-value {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
}

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 18px;
  background: transparent;
  cursor: pointer;
  display: block;
}
input[type="range"]::-webkit-slider-runnable-track {
  height: 3px;
  border-radius: 2px;
  background: linear-gradient(to right, #62626e var(--fill, 0%), #232329 var(--fill, 0%));
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 12px; height: 12px;
  border-radius: 50%;
  background: #e8e8ec;
  border: none;
  margin-top: -4.5px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.5);
  transition: transform 100ms ease;
}
input[type="range"]:hover::-webkit-slider-thumb { transform: scale(1.15); }
input[type="range"]:active::-webkit-slider-thumb { transform: scale(1.25); background: #fff; }
input[type="range"]::-moz-range-track {
  height: 3px; border-radius: 2px; background: #232329;
}
input[type="range"]::-moz-range-progress { height: 3px; border-radius: 2px; background: #62626e; }
input[type="range"]::-moz-range-thumb {
  width: 12px; height: 12px; border-radius: 50%;
  background: #e8e8ec; border: none;
}

/* ---------- selects / small inputs ---------- */

.field-row { display: flex; gap: 8px; align-items: center; margin-bottom: 11px; }
.field-row:last-child { margin-bottom: 0; }
.field-row .ctl-label { flex: 1; }

select, .num-input {
  background: var(--bg-raised);
  border: 1px solid var(--line);
  border-radius: var(--radius-s);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 11px;
  height: 28px;
  padding: 0 8px;
  outline: none;
}
select:focus, .num-input:focus { border-color: #3c3c46; }
select { cursor: pointer; appearance: none; padding-right: 22px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='8' height='5'%3E%3Cpath d='M0 0l4 5 4-5z' fill='%235e5e68'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
}

.num-input { width: 74px; text-align: right; }

.seed-row { display: flex; gap: 6px; align-items: center; }
.seed-row .num-input { flex: 1; text-align: left; }

.mini-btn {
  height: 28px;
  padding: 0 10px;
  border-radius: var(--radius-s);
  border: 1px solid var(--line);
  background: var(--bg-raised);
  color: var(--text-mid);
  font-size: 11px;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: background 120ms ease, color 120ms ease;
  white-space: nowrap;
}
.mini-btn svg { width: 11px; height: 11px; }
.mini-btn:hover { background: var(--bg-hover); color: var(--text); }

/* ---------- toggle ---------- */

.toggle-row {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 11px;
}
.toggle-row:last-child { margin-bottom: 0; }
.toggle {
  position: relative;
  width: 30px; height: 17px;
  border-radius: 9px;
  background: #26262d;
  transition: background 140ms ease;
  flex: none;
}
.toggle::after {
  content: "";
  position: absolute;
  top: 2.5px; left: 2.5px;
  width: 12px; height: 12px;
  border-radius: 50%;
  background: #9b9ba4;
  transition: transform 140ms ease, background 140ms ease;
}
.toggle.on { background: var(--text); }
.toggle.on::after { transform: translateX(13px); background: #0a0a0c; }

/* ---------- share section ---------- */

.share-row { display: flex; gap: 8px; margin-bottom: 10px; }
.share-row .mini-btn { flex: 1; justify-content: center; }
.share-input {
  width: 100%;
  text-align: left;
  color: var(--text-mid);
}
.share-input::placeholder { color: var(--text-dim); }

/* ---------- share section ---------- */

.share-row { display: flex; gap: 8px; margin-bottom: 10px; }
.share-row .mini-btn { flex: 1; justify-content: center; }
.share-input {
  width: 100%;
  text-align: left;
}
.share-input::placeholder { color: var(--text-dim); }

/* ---------- export section ---------- */

.export-grid { display: flex; flex-direction: column; gap: 8px; margin-top: 4px; }
.export-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  height: 40px;
  padding: 0 14px;
  border-radius: var(--radius-s);
  border: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(255,255,255,0.06), rgba(255,255,255,0.02));
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.08);
  color: var(--text);
  font-size: 12.5px;
  font-weight: 500;
  transition: background 160ms ease, border-color 160ms ease,
    transform 160ms cubic-bezier(.34,1.56,.64,1), box-shadow 160ms ease;
}
.export-btn svg { width: 14px; height: 14px; color: var(--text-mid); transition: transform 220ms cubic-bezier(.34,1.56,.64,1), color 160ms ease; }
.export-btn:hover {
  background: linear-gradient(180deg, rgba(255,255,255,0.11), rgba(255,255,255,0.04));
  border-color: rgba(255,255,255,0.2);
  transform: translateX(2px);
}
.export-btn:hover svg { transform: scale(1.2); color: var(--text); }
.export-btn .ext {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-dim);
  letter-spacing: 0.06em;
}

/* ---------- overlay ---------- */

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(5,5,7,0.78);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
}
.overlay[hidden] { display: none; }
.overlay-card {
  width: 320px;
  background: var(--bg-rail);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 22px 22px 18px;
  box-shadow: 0 30px 80px -20px rgba(0,0,0,0.9);
}
.overlay-title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 14px;
  letter-spacing: 0.02em;
  margin-bottom: 6px;
}
.overlay-detail { font-size: 11px; color: var(--text-dim); margin-bottom: 14px; }
.progress {
  height: 4px;
  border-radius: 2px;
  background: #1d1d23;
  overflow: hidden;
  margin-bottom: 16px;
}
.progress-fill {
  height: 100%;
  width: 0%;
  border-radius: 2px;
  background: var(--text);
  transition: width 160ms ease;
}
.overlay-cancel { width: 100%; justify-content: center; }

/* ---------- toast ---------- */

.toast {
  position: fixed;
  bottom: 22px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-raised);
  border: 1px solid var(--line);
  color: var(--text);
  font-size: 11.5px;
  padding: 9px 16px;
  border-radius: 8px;
  z-index: 60;
  box-shadow: 0 10px 30px -8px rgba(0,0,0,0.7);
  animation: toast-in 200ms ease;
}
@keyframes toast-in {
  from { opacity: 0; transform: translateX(-50%) translateY(8px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* ---------- responsive ---------- */

@media (max-width: 980px) {
  .brand-sub { display: none; }
  .topbar-center { display: none; }
  .brand { min-width: 0; }
  .topbar-actions { min-width: 0; }
  .btn { padding: 0 10px; }
  .btn span { display: none; }
}
@media (max-width: 820px) {
  body { overflow: auto; }
  .app { flex-direction: column; height: auto; }
  .stage { height: 58vh; }
  .rail { width: 100%; border-left: none; border-top: 1px solid var(--line-soft); }
  .canvas-frame { padding: 18px; }
}

/* ---------- synth + saved styles ---------- */

.synth-row { margin-top: 10px; }
.synth-ctl { margin-top: 8px; }
.mini-btn svg { width: 12px; height: 12px; margin-right: 2px; transition: transform 220ms cubic-bezier(.34,1.56,.64,1); }
.mini-btn:hover svg { transform: rotate(8deg) scale(1.15); }

.saved-styles { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.saved-styles:empty { display: none; }
.saved-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 25px;
  padding: 0 5px 0 10px;
  border-radius: 13px;
  border: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(255,255,255,0.06), rgba(255,255,255,0.02));
  color: var(--text-mid);
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.03em;
  transition: color 150ms ease, border-color 150ms ease, transform 150ms cubic-bezier(.34,1.56,.64,1);
}
.saved-chip:hover { color: var(--text); border-color: rgba(255,255,255,0.22); transform: translateY(-1px); }
.saved-del {
  width: 15px; height: 15px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 50%;
  font-size: 11px;
  color: var(--text-dim);
  transition: background 130ms ease, color 130ms ease;
}
.saved-del:hover { background: rgba(255,80,80,0.18); color: #ff8d8d; }

/* ---------- modals ---------- */

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgba(5,5,8,0.6);
  backdrop-filter: blur(10px) saturate(1.1);
  -webkit-backdrop-filter: blur(10px) saturate(1.1);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  animation: backdrop-in 220ms ease;
}
@keyframes backdrop-in { from { opacity: 0; } to { opacity: 1; } }

.modal-card {
  width: min(560px, 100%);
  max-height: 88vh;
  overflow-y: auto;
  background: rgba(20, 20, 25, 0.92);
  backdrop-filter: blur(26px) saturate(1.3);
  -webkit-backdrop-filter: blur(26px) saturate(1.3);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: var(--radius-l);
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.12),
    0 40px 110px -24px rgba(0,0,0,0.95);
  padding: 20px 22px 22px;
  animation: card-in 320ms cubic-bezier(.22,1.3,.36,1);
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.14) transparent;
}
@keyframes card-in {
  from { opacity: 0; transform: scale(1.06) translateY(10px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}
.modal-card::-webkit-scrollbar { width: 9px; }
.modal-card::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.12);
  border-radius: 5px;
  border: 3px solid transparent;
  background-clip: content-box;
}

.modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 16px;
}
.modal-title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 16px;
  letter-spacing: 0.01em;
}
.modal-sub { font-size: 10.5px; color: var(--text-dim); margin-top: 3px; }
.modal-close {
  width: 28px; height: 28px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 8px;
  color: var(--text-dim);
  transition: background 130ms ease, color 130ms ease, transform 160ms ease;
}
.modal-close svg { width: 11px; height: 11px; }
.modal-close:hover { background: var(--bg-hover); color: var(--text); transform: rotate(90deg); }

.modal-preview {
  position: relative;
  border-radius: var(--radius-m);
  overflow: hidden;
  margin-bottom: 16px;
  box-shadow: 0 0 0 1px rgba(255,255,255,0.08), 0 12px 30px -12px rgba(0,0,0,0.7);
}
.modal-preview canvas { display: block; width: 100%; height: auto; }
.modal-preview-meta {
  position: absolute;
  left: 10px; bottom: 8px;
  font-size: 10px;
  color: rgba(255,255,255,0.92);
  background: rgba(8,8,12,0.55);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  padding: 4px 9px;
  border-radius: 7px;
  letter-spacing: 0.04em;
}

.modal-form { display: flex; flex-direction: column; gap: 2px; margin-bottom: 14px; }
.modal-note {
  font-size: 11.5px;
  color: var(--text-mid);
  line-height: 1.55;
  margin-bottom: 14px;
}
.modal-actions { display: flex; justify-content: flex-end; }
.modal-dl { height: 38px; padding: 0 18px; font-size: 13px; }
.modal-dl svg { width: 14px; height: 14px; }
.modal-dl:disabled { opacity: 0.55; pointer-events: none; }

/* ---------- set generator grid ---------- */

.set-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 16px;
}
.set-tile {
  position: relative;
  border-radius: var(--radius-s);
  overflow: hidden;
  border: 1px solid rgba(255,255,255,0.1);
  padding: 0;
  transition: transform 180ms cubic-bezier(.34,1.56,.64,1), border-color 160ms ease, box-shadow 160ms ease;
}
.set-tile canvas { display: block; width: 100%; height: auto; }
.set-tile:hover {
  transform: scale(1.045);
  border-color: rgba(255,255,255,0.45);
  box-shadow: 0 10px 24px -10px rgba(0,0,0,0.8);
  z-index: 1;
}
.set-tile-label {
  position: absolute;
  left: 6px; bottom: 5px;
  font-size: 9px;
  color: rgba(255,255,255,0.9);
  background: rgba(8,8,12,0.55);
  padding: 2px 6px;
  border-radius: 5px;
}

/* ---------- intro stagger animation ---------- */

@keyframes intro-pop {
  0% { opacity: 0; transform: scale(1.45) translateY(-4px); }
  62% { opacity: 1; }
  100% { opacity: 1; transform: scale(1) translateY(0); }
}
.intro .stagger-item {
  animation: intro-pop 560ms cubic-bezier(.22,1.3,.36,1) both;
  animation-delay: var(--intro-d, 0ms);
  will-change: transform, opacity;
}
.intro .canvas-frame.stagger-item { animation-duration: 780ms; }

/* ---------- download success effect ---------- */

.fx-layer {
  position: fixed;
  inset: 0;
  z-index: 80;
  pointer-events: none;
}
@keyframes fx-ring {
  0% { transform: translate(-50%,-50%) scale(0.3); opacity: 0.9; }
  100% { transform: translate(-50%,-50%) scale(2.4); opacity: 0; }
}
.fx-ring {
  position: fixed;
  width: 180px; height: 180px;
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.8);
  z-index: 80;
  pointer-events: none;
  animation: fx-ring 700ms cubic-bezier(.2,.8,.3,1) forwards;
}
@keyframes toast-success-pop {
  0% { opacity: 0; transform: translateX(-50%) scale(1.4); }
  55% { opacity: 1; transform: translateX(-50%) scale(0.97); }
  100% { opacity: 1; transform: translateX(-50%) scale(1); }
}
.toast.success {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  border-color: rgba(140, 240, 170, 0.35);
  box-shadow: 0 10px 38px -8px rgba(40, 200, 110, 0.25);
  animation: toast-success-pop 420ms cubic-bezier(.22,1.4,.36,1);
}
.toast.success svg { width: 14px; height: 14px; flex: none; }
.toast.success svg path {
  stroke-dasharray: 20;
  stroke-dashoffset: 20;
  animation: check-draw 360ms 150ms ease-out forwards;
}
@keyframes check-draw { to { stroke-dashoffset: 0; } }

@media (prefers-reduced-motion: reduce) {
  * { transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; }
}
