:root {
  --bg: #f3f2ee; --panel: #ffffff; --line: #e4e4ea; --text: #17171c; --muted: #6b6b78;
  --accent: #141317; --accent-2: #141317; --accent-ink: #ffffff; --field: #f6f6f9; --ok: #15803d; --err: #c2410c;
  --stage: #e9e9ef;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #0b0a0d; --panel: #121115; --line: #25242a; --text: #f3f2ee; --muted: #9c9aa3; --accent: #f3f2ee; --accent-2: #f3f2ee; --accent-ink: #0b0a0d;
          --field: #1b1a1f; --stage: #0f0e12; --ok: #4ade80; --err: #fb923c; color-scheme: dark; }
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font: 14px/1.45 "Geist", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; letter-spacing: -.005em; background: var(--bg); color: var(--text); display: flex; flex-direction: column; }
.hidden { display: none !important; }

.topbar { height: 56px; flex: none; display: flex; align-items: center; justify-content: space-between; padding: 0 18px; background: var(--panel); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 9px; font-weight: 700; font-size: 16px; color: var(--text); text-decoration: none; letter-spacing: -.01em; }
.topbar-right { display: flex; align-items: center; gap: 10px; }
.pill { font-size: 12px; font-weight: 600; padding: 4px 10px; border-radius: 999px; background: var(--field); color: var(--muted); border: 1px solid var(--line); }
.pill-pro { background: var(--accent); color: var(--accent-ink); border-color: transparent; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 38px; padding: 0 14px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel); color: var(--text); font: 600 13.5px/1 inherit; font-family: inherit; cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn:hover { border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); }
.btn:focus-visible, select:focus-visible, input:focus-visible, .swatch:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { background: color-mix(in srgb, var(--accent) 88%, #000); }
.btn-pro { background: var(--accent); border: 0; color: var(--accent-ink); }
.btn-ghost { background: var(--field); }
.btn-block { width: 100%; height: 44px; font-size: 15px; }
.btn:disabled { opacity: .6; cursor: progress; }

.editor { flex: 1; min-height: 0; display: grid; grid-template-columns: 1fr 330px; }
.stage { position: relative; background: var(--stage); min-height: 0; overflow: hidden; }
.stage-inner { position: absolute; inset: 28px 28px 64px; display: grid; place-items: center; }
#preview { display: block; max-width: 100%; max-height: 100%; border-radius: 4px; }
.checker { background-color: #fff; background-image: linear-gradient(45deg, #ddd 25%, transparent 25%), linear-gradient(-45deg, #ddd 25%, transparent 25%), linear-gradient(45deg, transparent 75%, #ddd 75%), linear-gradient(-45deg, transparent 75%, #ddd 75%); background-size: 16px 16px; background-position: 0 0, 0 8px, 8px -8px, -8px 0; }
.stage-tip { position: absolute; left: 0; right: 0; bottom: 18px; margin: 0; text-align: center; color: var(--muted); font-size: 13px; padding: 0 16px; }
kbd { font: 600 11px/1 inherit; font-family: inherit; padding: 2px 5px; border-radius: 5px; border: 1px solid var(--line); background: var(--panel); }
.link { color: var(--accent); cursor: pointer; text-decoration: underline; background: none; border: 0; padding: 0; font: inherit; }
.drop-hint { position: absolute; inset: 14px; border: 2px dashed var(--accent); border-radius: 16px; display: none; place-items: center; font-size: 18px; font-weight: 700; color: var(--accent); background: color-mix(in srgb, var(--accent) 10%, transparent); pointer-events: none; }
.stage.dragging .drop-hint { display: grid; }

.panel { background: var(--panel); border-left: 1px solid var(--line); overflow-y: auto; overflow-x: hidden; padding: 6px 18px 18px; }
.group { padding: 14px 0; border-bottom: 1px solid var(--line); display: grid; gap: 10px; }
.group:last-child { border-bottom: 0; }
.group-head { font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); }
.row { display: flex; gap: 8px; align-items: center; }
.grow { flex: 1; min-width: 0; }
.field { display: grid; gap: 6px; font-size: 13px; font-weight: 500; }
.field > span { display: flex; justify-content: space-between; }
.field output { color: var(--muted); font-variant-numeric: tabular-nums; }
.check { display: flex; gap: 8px; align-items: center; font-size: 13px; cursor: pointer; }
select, input[type="text"] { width: 100%; height: 36px; padding: 0 10px; border-radius: 9px; border: 1px solid var(--line); background: var(--field); color: var(--text); font: inherit; }
input[type="range"] { width: 100%; accent-color: var(--accent); }
input[type="color"] { width: 40px; height: 34px; padding: 2px; border-radius: 8px; border: 1px solid var(--line); background: var(--field); cursor: pointer; }

.swatches { display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); gap: 7px; }
.swatch { position: relative; aspect-ratio: 1; border-radius: 9px; border: 2px solid transparent; cursor: pointer; padding: 0; box-shadow: inset 0 0 0 1px rgba(0,0,0,.08); }
.swatch.on { border-color: var(--text); }
.swatch-custom { background: var(--field); color: var(--muted); font-size: 18px; font-weight: 600; }
.pro-tag { position: absolute; top: -5px; right: -5px; width: 15px; height: 15px; border-radius: 50%; background: var(--accent); color: var(--accent-ink); font-size: 8px; line-height: 15px; text-align: center; }
.custom { display: grid; gap: 8px; padding: 10px; border-radius: 10px; background: var(--field); }

.export { position: sticky; bottom: 0; background: var(--panel); border-top: 1px solid var(--line); box-shadow: 0 -12px 16px -12px rgba(0,0,0,.12); margin: 0 -18px; padding: 14px 18px; }
.status { margin: 0; min-height: 18px; font-size: 12.5px; color: var(--muted); }
.status.ok { color: var(--ok); } .status.err { color: var(--err); }

.modal-backdrop { position: fixed; inset: 0; background: rgba(10,10,15,.55); display: grid; place-items: center; padding: 16px; z-index: 10; }
.modal { position: relative; width: 100%; max-width: 420px; background: var(--panel); border-radius: 18px; padding: 26px; box-shadow: 0 30px 80px rgba(0,0,0,.35); }
.modal h2 { margin: 0 0 6px; font-size: 21px; letter-spacing: -.01em; }
.modal-sub { margin: 0 0 14px; color: var(--muted); }
.modal-list { margin: 0 0 18px; padding: 0; list-style: none; display: grid; gap: 7px; }
.modal-list li::before { content: "✓"; color: var(--accent); font-weight: 700; margin-right: 8px; }
.modal-close { position: absolute; top: 12px; right: 14px; border: 0; background: none; font-size: 24px; color: var(--muted); cursor: pointer; }
.license { margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--line); display: grid; gap: 8px; font-size: 13px; }
.license-msg { margin: 0; min-height: 18px; font-size: 12.5px; }
.license-msg.ok { color: var(--ok); } .license-msg.err { color: var(--err); }

@media (max-width: 820px) {
  body { height: auto; min-height: 100%; }
  .editor { grid-template-columns: 1fr; }
  .stage { height: 58vh; min-height: 320px; }
  .stage-inner { inset: 16px 16px 72px; }
  .export { margin: 0 -16px; padding: 12px 16px; }
  .panel { border-left: 0; border-top: 1px solid var(--line); overflow: visible; padding: 4px 16px 16px; }
  .swatches { grid-template-columns: repeat(8, minmax(0, 1fr)); }
}
