@font-face { font-family: "Nunito"; font-weight: 800; font-display: swap; src: url(/fonts/nunito-800.woff2) format("woff2"); }
@font-face { font-family: "Barlow Condensed"; font-weight: 700; font-display: swap; src: url(/fonts/barlowc-700.woff2) format("woff2"); }

:root {
  --bg: #0e0f13;
  --panel: #16181e;
  --raise: #1d2028;
  --line: #262932;
  --line-2: #323644;
  --text: #eceef3;
  --muted: #9aa1b0;
  --accent: #7c5cff;
  --accent-hi: #9076ff;
  --accent-ink: #ffffff;
  --danger: #ff5d6c;
  --ok: #46d19a;
  --r: 10px;
  --r-sm: 7px;
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0; min-height: 100vh; background: var(--bg); color: var(--text);
  font: 400 15px/1.5 system-ui, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  -webkit-font-smoothing: antialiased; font-variant-numeric: tabular-nums;
}
::selection { background: var(--accent); color: #fff; }
input, select, button { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent-hi); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.i { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
* { scrollbar-width: thin; scrollbar-color: var(--line-2) transparent; }

/* Top bar */
.top { display: flex; align-items: center; justify-content: space-between; gap: 16px; height: 64px; padding: 0 24px; border-bottom: 1px solid var(--line); }
.logo { display: inline-flex; align-items: center; gap: 10px; color: var(--text); text-decoration: none; font-weight: 800; font-size: 18px; letter-spacing: -0.01em; }
.logo svg { width: 28px; height: 28px; }
.top-actions { display: flex; align-items: center; gap: 8px; }
.select select {
  appearance: none; height: 38px; min-width: 180px; max-width: 260px; padding: 0 34px 0 12px; border-radius: var(--r-sm);
  border: 1px solid var(--line-2); background: var(--panel) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3E%3Cpath d='M6 8l4 4 4-4' fill='none' stroke='%239aa1b0' stroke-width='1.8' stroke-linecap='round'/%3E%3C/svg%3E") right 10px center / 16px no-repeat;
}

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 38px; padding: 0 14px;
  border-radius: var(--r-sm); border: 1px solid transparent; font-weight: 600; white-space: nowrap;
  transition: background-color 150ms var(--ease), border-color 150ms var(--ease), color 150ms var(--ease), transform 100ms var(--ease);
}
.btn:active:not(:disabled) { transform: scale(0.98); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-primary { background: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { background: var(--accent-hi); }
.btn-ghost { border-color: var(--line-2); background: transparent; }
.btn-ghost:hover { background: var(--raise); }
.btn-soft { background: var(--raise); border-color: var(--line-2); }
.btn-soft:hover:not(:disabled) { border-color: #454a5a; background: #242834; }
.icon-only { width: 38px; padding: 0; }

/* Layout */
.app { display: grid; grid-template-columns: 420px minmax(0, 1fr); min-height: calc(100vh - 64px); }
.panel { border-right: 1px solid var(--line); background: var(--panel); padding: 20px 20px 32px; }
.preview { display: grid; grid-template-rows: 1fr auto; gap: 20px; padding: 24px 32px 28px; min-width: 0; }

/* Title */
.title-row { display: flex; align-items: center; gap: 12px; }
.title-input {
  flex: 1; min-width: 0; height: 44px; padding: 0 12px; margin-left: -12px; border: 1px solid transparent; border-radius: var(--r-sm);
  background: transparent; font-size: 22px; font-weight: 800; letter-spacing: -0.01em;
}
.title-input:hover { border-color: var(--line); }
.title-input:focus-visible { outline: none; border-color: var(--accent); background: var(--bg); }
.save { font-size: 13px; color: var(--muted); display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.save::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--ok); }
.save[data-tone="busy"]::before { background: #f6c55b; }
.save[data-tone="error"] { color: var(--danger); }
.save[data-tone="error"]::before { background: var(--danger); }
.save[data-tone="view"]::before { background: var(--muted); }

/* Tabs */
.tabs { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; margin: 16px 0 20px; padding: 4px; border-radius: var(--r); background: var(--bg); }
.tabs button { height: 34px; border: 0; border-radius: var(--r-sm); background: transparent; color: var(--muted); font-weight: 600; transition: background-color 150ms var(--ease), color 150ms var(--ease); }
.tabs button:hover { color: var(--text); }
.tabs button[aria-selected="true"] { background: var(--raise); color: var(--text); box-shadow: inset 0 0 0 1px var(--line-2); }

/* Groups */
.pane { display: grid; gap: 22px; }
.group { display: grid; gap: 10px; }
.group.two { grid-template-columns: 1fr 1fr; }
.field { display: grid; gap: 10px; }
.group-label { font-size: 12px; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; color: var(--muted); }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.hint { margin: 0; font-size: 13px; color: var(--muted); }
.hint.warn { color: #ff9aa4; }

/* Palettes */
.palettes { display: flex; gap: 8px; flex-wrap: wrap; }
.pal { display: inline-flex; align-items: center; gap: 8px; height: 32px; padding: 0 10px 0 6px; border-radius: 999px; border: 1px solid var(--line-2); background: var(--raise); font-size: 13px; font-weight: 600; }
.pal:hover { border-color: #454a5a; }
.pal i { display: flex; width: 36px; height: 18px; border-radius: 999px; overflow: hidden; }
.pal i b { flex: 1; }

/* Slice rows */
.slices { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.slice { display: grid; grid-template-columns: 34px minmax(0, 1fr) 92px 32px; align-items: center; gap: 8px; padding: 6px; border-radius: var(--r); background: var(--raise); border: 1px solid transparent; transition: border-color 150ms var(--ease); }
.slice:hover, .slice:focus-within { border-color: var(--line-2); }
.slice .label {
  height: 34px; min-width: 0; padding: 0 8px; border: 0; border-radius: var(--r-sm); background: transparent; font-weight: 600; text-overflow: ellipsis;
}
.slice .label:focus-visible { outline: none; background: var(--bg); box-shadow: inset 0 0 0 1px var(--accent); }
.stepper { display: grid; grid-template-columns: 26px 1fr 26px; align-items: center; height: 30px; border-radius: var(--r-sm); background: var(--bg); }
.stepper button { height: 30px; border: 0; background: transparent; color: var(--muted); font-size: 16px; line-height: 1; border-radius: var(--r-sm); }
.stepper button:hover:not(:disabled) { color: var(--text); background: var(--line); }
.stepper output { text-align: center; font-weight: 700; font-size: 14px; }
.remove { width: 32px; height: 32px; display: grid; place-items: center; border: 0; border-radius: var(--r-sm); background: transparent; color: var(--muted); }
.remove:hover:not(:disabled) { color: var(--danger); background: rgba(255, 93, 108, 0.12); }
.empty { margin: 0; padding: 14px; border: 1px dashed var(--line-2); border-radius: var(--r); color: var(--muted); text-align: center; }
.add { display: flex; gap: 8px; }
.add input { flex: 1; min-width: 0; height: 38px; padding: 0 12px; border-radius: var(--r-sm); border: 1px solid var(--line-2); background: var(--bg); }
.add input::placeholder { color: #6c7383; }
.add input:focus-visible { outline: none; border-color: var(--accent); }

/* Color chips */
.chip { position: relative; display: inline-grid; place-items: center; width: 34px; height: 34px; flex: none; cursor: pointer; }
.chip input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
.chip span { width: 26px; height: 26px; border-radius: 50%; background: var(--c, #fff); box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.18); transition: transform 150ms var(--ease); }
.chip:hover span { transform: scale(1.08); }
.chip:has(input:focus-visible) span { outline: 2px solid var(--accent-hi); outline-offset: 3px; }
.chip.off { opacity: 0.35; pointer-events: none; }

.swatch { display: inline-flex; align-items: center; gap: 4px; padding-right: 8px; font-size: 13px; color: var(--muted); cursor: pointer; }

/* Segmented control */
.seg { display: inline-grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 4px; padding: 4px; border-radius: var(--r); background: var(--bg); }
.group > .seg { display: grid; }
.seg button { height: 32px; padding: 0 10px; border: 0; border-radius: var(--r-sm); background: transparent; color: var(--muted); font-weight: 600; transition: background-color 150ms var(--ease), color 150ms var(--ease); }
.seg button:hover { color: var(--text); }
.seg button[aria-checked="true"] { background: var(--accent); color: var(--accent-ink); }
.f-rounded { font-family: "Nunito", ui-rounded, sans-serif; font-weight: 800 !important; }
.f-condensed { font-family: "Barlow Condensed", sans-serif; font-size: 16px; }
.f-mono { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 13px; }

/* Range */
.range { display: inline-flex; align-items: center; gap: 10px; flex: 1; min-width: 150px; }
.range.wide { width: 100%; }
.range input { flex: 1; appearance: none; height: 6px; border-radius: 999px; background: linear-gradient(var(--accent), var(--accent)) 0 / var(--fill, 50%) 100% no-repeat, var(--bg); }
.range input::-webkit-slider-thumb { appearance: none; width: 18px; height: 18px; border-radius: 50%; background: #fff; box-shadow: 0 0 0 4px var(--accent); cursor: pointer; }
.range input::-moz-range-thumb { width: 18px; height: 18px; border: 0; border-radius: 50%; background: #fff; box-shadow: 0 0 0 4px var(--accent); cursor: pointer; }
.range output { min-width: 34px; text-align: right; font-weight: 700; font-size: 14px; }

/* Switch */
.switch { display: flex; align-items: center; gap: 12px; cursor: pointer; font-weight: 500; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch span { position: relative; width: 38px; height: 22px; flex: none; border-radius: 999px; background: var(--line-2); transition: background-color 150ms var(--ease); }
.switch span::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: transform 180ms var(--ease); }
.switch input:checked + span { background: var(--accent); }
.switch input:checked + span::after { transform: translateX(16px); }
.switch input:focus-visible + span { outline: 2px solid var(--accent-hi); outline-offset: 2px; }
.switch input:disabled + span { opacity: 0.4; }

/* Copy fields */
.copy { display: flex; gap: 8px; }
.copy input { flex: 1; min-width: 0; height: 38px; padding: 0 12px; border-radius: var(--r-sm); border: 1px solid var(--line-2); background: var(--bg); color: var(--muted); font: 13px ui-monospace, "SF Mono", Menlo, monospace; text-overflow: ellipsis; }

/* Preview */
.stage-wrap { position: relative; display: grid; place-items: center; min-height: 0; border-radius: 14px; border: 1px solid var(--line);
  background: #111318 repeating-conic-gradient(#15171d 0 25%, #111318 0 50%) 0 0 / 24px 24px; }
.stage { width: min(100%, 72vh, 720px); aspect-ratio: 1; }
.stage iframe { display: block; width: 100%; height: 100%; border: 0; background: transparent; color-scheme: normal; }
.stage-tag { position: absolute; top: 12px; left: 14px; font-size: 12px; font-weight: 600; color: var(--muted); }
.controls { display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: center; gap: 24px; }
.btn-spin { height: 56px; min-width: 180px; padding: 0 36px; border-radius: 14px; background: var(--accent); color: #fff; font-size: 20px; font-weight: 800; letter-spacing: 0.01em; }
.btn-spin:hover:not(:disabled) { background: var(--accent-hi); }
.btn-spin:disabled { background: var(--raise); color: var(--muted); opacity: 1; }
.history { display: grid; gap: 8px; min-width: 0; }
.history ol { display: flex; gap: 8px; margin: 0; padding: 0; list-style: none; overflow-x: auto; }
.history li { flex: none; max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding: 6px 12px; border-radius: 999px; background: var(--raise); border: 1px solid var(--line); font-weight: 600; font-size: 14px; }
.history li:first-child:not(.muted) { background: var(--accent); border-color: var(--accent); color: #fff; }
.history li.muted { background: transparent; border-style: dashed; color: var(--muted); font-weight: 500; }

.boot { position: fixed; inset: 64px 0 0; display: grid; place-items: center; color: var(--muted); }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); padding: 10px 16px; border-radius: var(--r); background: #fff; color: #111318; font-weight: 600; opacity: 0; pointer-events: none; transition: opacity 180ms var(--ease), transform 220ms var(--ease); }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 960px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .panel { min-width: 0; }
  .stage-tag { position: static; justify-self: start; padding: 10px 14px 0; }
  .stage-wrap { gap: 4px; }
  .preview { order: -1; padding: 16px; }
  .panel { border-right: 0; border-top: 1px solid var(--line); }
  .stage { width: min(100%, 520px); }
  .controls { grid-template-columns: 1fr; }
  .btn-spin { width: 100%; }
  .top { padding: 0 14px; }
  .top-actions .btn span { display: none; }
  .top-actions .btn { width: 38px; padding: 0; }
  .select select { min-width: 0; max-width: 150px; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition-duration: 1ms !important; } }
