:root {
  --bg: #f4f3f0;
  --panel: #ffffff;
  --text: #17171c;
  --muted: #6b6b75;
  --line: #e2e0db;
  --accent: #6d3ee8;
  --accent-text: #ffffff;
  --warn: #b4441a;
  --radius: 14px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #121216;
    --panel: #1c1c22;
    --text: #ececf1;
    --muted: #9a9aa6;
    --line: #2d2d36;
    --accent: #9b7bff;
    --accent-text: #121216;
    --warn: #ff9b6b;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  padding-bottom: calc(88px + env(safe-area-inset-bottom));
}
button, input, textarea { font: inherit; color: inherit; }
code { font-family: "JetBrains Mono", ui-monospace, monospace; font-size: .9em; }

.top {
  display: flex; align-items: baseline; gap: 12px;
  padding: calc(16px + env(safe-area-inset-top)) 16px 8px;
  max-width: 1200px; margin: 0 auto;
}
.top h1 { font-family: "Syne", sans-serif; font-weight: 800; font-size: 26px; margin: 0; letter-spacing: -.02em; }
.tag { color: var(--muted); font-size: 13px; }

.layout {
  display: grid; gap: 16px;
  padding: 8px 16px 16px;
  max-width: 1200px; margin: 0 auto;
}
@media (min-width: 900px) {
  .layout { grid-template-columns: 400px 1fr; align-items: start; }
  .controls { position: sticky; top: 16px; max-height: calc(100vh - 120px); overflow: auto; }
}

.controls {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; display: grid; gap: 20px;
}
.field { display: grid; gap: 8px; }
.label, .field > label { font-weight: 600; font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.hint { display: block; text-transform: none; letter-spacing: 0; font-weight: 400; margin-top: 2px; }

textarea {
  width: 100%; resize: vertical; min-height: 180px;
  background: var(--bg); border: 1px solid var(--line); border-radius: 10px;
  padding: 12px; font-size: 16px; line-height: 1.5;
}
textarea:focus, button:focus-visible, input:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.swatches { display: grid; grid-template-columns: repeat(auto-fill, minmax(44px, 1fr)); gap: 8px; }
.swatch {
  position: relative; aspect-ratio: 1; border-radius: 10px; border: 2px solid transparent;
  cursor: pointer; padding: 0;
}
.swatch[aria-selected="true"] { border-color: var(--text); box-shadow: inset 0 0 0 2px var(--panel); }
.swatch .del {
  position: absolute; top: -6px; right: -6px; width: 20px; height: 20px; border-radius: 50%;
  border: none; background: var(--text); color: var(--panel); font-size: 13px; line-height: 20px; cursor: pointer; padding: 0;
}

.gradient-editor { display: grid; gap: 10px; padding: 12px; border: 1px dashed var(--line); border-radius: 10px; }
.stops { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.stop { position: relative; }
.stop .del { position: absolute; top: -6px; right: -6px; }
input[type="color"] {
  width: 44px; height: 44px; border: 1px solid var(--line); border-radius: 10px; padding: 2px; background: var(--bg); cursor: pointer;
}
input[type="color"]::-webkit-color-swatch-wrapper { padding: 0; }
input[type="color"]::-webkit-color-swatch { border: none; border-radius: 7px; }
input[type="color"]::-moz-color-swatch { border: none; border-radius: 7px; }
.round {
  width: 44px; height: 44px; border-radius: 10px; border: 1px dashed var(--muted);
  background: transparent; cursor: pointer; font-size: 20px; color: var(--muted);
}
.del {
  width: 20px; height: 20px; border-radius: 50%; border: none; padding: 0;
  background: var(--text); color: var(--panel); font-size: 13px; line-height: 20px; cursor: pointer;
}
.angle, .size { display: grid; grid-template-columns: auto 1fr 48px; gap: 10px; align-items: center; font-size: 14px; }
.size { grid-template-columns: 1fr 48px; }
output { text-align: right; font-variant-numeric: tabular-nums; color: var(--muted); }
input[type="range"] { width: 100%; accent-color: var(--accent); }

.color-row { display: flex; gap: 10px; align-items: center; }
.quick { display: flex; gap: 8px; }
.quick button { width: 32px; height: 32px; border-radius: 50%; border: 1px solid var(--line); cursor: pointer; padding: 0; }

.fonts { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.font {
  border: 1px solid var(--line); background: var(--bg); border-radius: 10px;
  padding: 10px 12px; text-align: left; cursor: pointer; font-size: 18px; line-height: 1.2;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.font[aria-selected="true"] { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }

.segmented { display: grid; grid-template-columns: repeat(3, 1fr); background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 3px; }
.segmented button { border: none; background: transparent; padding: 8px 4px; border-radius: 7px; cursor: pointer; font-size: 14px; }
.segmented button[aria-checked="true"] { background: var(--panel); box-shadow: 0 1px 3px rgba(0,0,0,.15); font-weight: 600; }
.size[hidden] { display: none; }
.warn { margin: 0; color: var(--warn); font-size: 13px; }

.toggle { display: flex; gap: 10px; align-items: center; cursor: pointer; }
.toggle input { width: 20px; height: 20px; accent-color: var(--accent); }

.slides { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
.slide { margin: 0; display: grid; gap: 8px; }
.slide canvas { width: 100%; height: auto; aspect-ratio: 1; border-radius: 6px; display: block; box-shadow: 0 4px 18px rgba(0,0,0,.18); }
.slide figcaption { display: flex; justify-content: space-between; align-items: center; font-size: 13px; color: var(--muted); }
.ghost {
  border: 1px solid var(--line); background: transparent; border-radius: 8px; padding: 6px 12px; cursor: pointer; font-size: 13px;
  justify-self: start;
}
.empty { color: var(--muted); padding: 40px 0; text-align: center; grid-column: 1 / -1; }

.bar {
  position: fixed; inset: auto 0 0 0;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border-top: 1px solid var(--line);
  display: flex; justify-content: center;
}
.primary {
  width: 100%; max-width: 480px; border: none; border-radius: 12px; padding: 15px 20px;
  background: var(--accent); color: var(--accent-text); font-weight: 700; font-size: 16px; cursor: pointer;
}
.primary:disabled { opacity: .5; cursor: default; }
