:root {
  --bg: #0b0c10;
  --panel: #14161c;
  --panel-2: #1a1d25;
  --border: #262933;
  --text: #e7e9ee;
  --muted: #9aa1af;
  --accent: #8b5cf6;
  --grad: linear-gradient(120deg, #6366f1, #a855f7, #ec4899);
  --radius: 10px;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.hidden { display: none !important; }
.muted { color: var(--muted); }

/* ---------- Top bar ---------- */
.topbar {
  height: 56px;
  flex: 0 0 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  border-bottom: 1px solid var(--border);
  background: var(--panel);
}
.brand {
  display: flex; align-items: center; gap: 10px;
  text-decoration: none; color: inherit;
  transition: opacity .2s;
}
.brand:hover { opacity: .82; }
.brand-name { font-weight: 700; font-size: 16px; letter-spacing: .2px; }
.top-actions { display: flex; align-items: center; gap: 8px; }

.btn {
  appearance: none;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text);
  border-radius: var(--radius);
  padding: 8px 14px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: filter .2s, transform .25s cubic-bezier(.16,1,.3,1), box-shadow .25s, opacity .15s;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.btn:hover:not(:disabled) { filter: brightness(1.12); transform: translateY(-1px); }
.btn.primary:hover:not(:disabled) { box-shadow: 0 6px 20px rgba(147,51,234,.4); }
.btn:active:not(:disabled) { transform: translateY(0) scale(.98); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.primary {
  background: var(--grad);
  border: none;
  color: #fff;
}
.btn.ghost { background: transparent; }
.btn.block { width: 100%; }
.btn.pro-active { border-color: #7c3aed; color: #c4b5fd; }

/* ---------- Layout ---------- */
main { flex: 1; display: flex; min-height: 0; }

.stage {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 28px;
  min-width: 0;
  background:
    radial-gradient(1200px 600px at 70% -10%, rgba(99,102,241,.07), transparent 60%),
    radial-gradient(900px 500px at 10% 110%, rgba(236,72,153,.05), transparent 60%);
  position: relative;
}
.stage.dragging::after {
  content: "Drop to load image";
  position: absolute; inset: 12px;
  border: 2px dashed var(--accent);
  border-radius: 16px;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; font-weight: 700;
  background: rgba(11,12,16,.75);
  pointer-events: none;
  z-index: 5;
}

.dropzone {
  text-align: center;
  color: var(--muted);
  border: 1.5px dashed var(--border);
  border-radius: 20px;
  padding: 56px 72px;
  max-width: 460px;
}
.dropzone h2 { color: var(--text); margin: 14px 0 4px; font-size: 20px; }
.dropzone p { margin: 6px 0 18px; }
.dropzone kbd {
  background: var(--panel-2); border: 1px solid var(--border);
  border-radius: 5px; padding: 1px 6px; font-size: 12px; font-family: inherit;
}
.dz-actions { display: flex; gap: 10px; justify-content: center; }
.dz-privacy { font-size: 12px; opacity: .75; margin-top: 22px !important; }

.canvas-wrap {
  max-width: 100%; max-height: 100%;
  display: flex; align-items: center; justify-content: center;
}
.canvas-wrap canvas {
  max-width: 100%;
  max-height: calc(100vh - 56px - 56px);
  width: auto; height: auto;
  border-radius: 8px;
  box-shadow: 0 20px 60px rgba(0,0,0,.5);
}
.canvas-wrap.alpha canvas {
  background: repeating-conic-gradient(#23252d 0 25%, #191b21 0 50%) 0 0 / 22px 22px;
}

/* ---------- Panel ---------- */
.panel {
  width: 296px;
  flex: 0 0 296px;
  border-left: 1px solid var(--border);
  background: var(--panel);
  overflow-y: auto;
  padding: 6px 16px 24px;
}
.section { padding: 16px 0 6px; border-bottom: 1px solid var(--border); }
.section:last-child { border-bottom: none; }
.section-title {
  font-size: 11px; font-weight: 700; letter-spacing: .12em;
  text-transform: uppercase; color: var(--muted); margin-bottom: 12px;
}

.swatch-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; }
.swatch {
  aspect-ratio: 1; border-radius: 8px; cursor: pointer;
  border: 2px solid transparent;
  outline: 1px solid rgba(255,255,255,.08);
  transition: transform .1s;
}
.swatch:hover { transform: scale(1.08); }
.swatch.active { border-color: #fff; }
.swatch.none {
  background: repeating-conic-gradient(#3a3d46 0 25%, #23252d 0 50%) 0 0 / 10px 10px;
}

.custom-bg { margin-top: 14px; }
.row-title { font-size: 12.5px; color: var(--muted); margin-bottom: 8px; display: flex; align-items: center; gap: 8px; }
.pro-tag {
  font-size: 9px; font-weight: 800; letter-spacing: .08em;
  background: var(--grad); color: #fff;
  padding: 2px 6px; border-radius: 99px;
}
.custom-row { display: flex; align-items: center; gap: 10px; }
.custom-row input[type="color"] {
  width: 34px; height: 30px; padding: 2px; border: 1px solid var(--border);
  border-radius: 7px; background: var(--panel-2); cursor: pointer;
}
.custom-row input[type="range"] { flex: 1; }
.custom-bg.locked .custom-row { opacity: .45; pointer-events: none; }

.slider-row {
  display: grid; grid-template-columns: 76px 1fr;
  align-items: center; gap: 10px; margin-bottom: 12px;
  font-size: 13px; color: var(--muted);
}
input[type="range"] {
  appearance: none; -webkit-appearance: none;
  height: 4px; border-radius: 4px; background: var(--border); cursor: pointer;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 15px; height: 15px; border-radius: 50%;
  background: #fff; border: none;
  box-shadow: 0 1px 4px rgba(0,0,0,.4);
  transition: transform .18s cubic-bezier(.16,1,.3,1), box-shadow .18s;
}
input[type="range"]::-webkit-slider-thumb:hover { transform: scale(1.22); box-shadow: 0 2px 8px rgba(0,0,0,.5); }
input[type="range"]:active::-webkit-slider-thumb { transform: scale(1.3); box-shadow: 0 0 0 5px rgba(139,92,246,.22); }
input[type="range"]::-moz-range-thumb {
  width: 15px; height: 15px; border-radius: 50%;
  background: #fff; border: none;
  transition: transform .18s cubic-bezier(.16,1,.3,1);
}
input[type="range"]::-moz-range-thumb:hover { transform: scale(1.22); }

.segmented { display: flex; gap: 4px; background: var(--panel-2); padding: 4px; border-radius: 10px; }
.segmented.wrap { flex-wrap: wrap; }
.segmented button {
  flex: 1; appearance: none; border: none; background: transparent;
  color: var(--muted); font: inherit; font-size: 12.5px; font-weight: 600;
  padding: 6px 8px; border-radius: 7px; cursor: pointer; white-space: nowrap;
  display: inline-flex; align-items: center; justify-content: center; gap: 5px;
  transition: background .25s, color .25s, transform .15s;
}
.segmented button:hover:not(.active) { color: var(--text); background: rgba(255,255,255,.05); }
.segmented button:active { transform: scale(.96); }
.segmented button.active { background: #2c303c; color: var(--text); }
.segmented button .lock { opacity: .65; }
.segmented.small button { padding: 5px 6px; font-size: 12px; }
.frame-extra { margin-top: 10px; display: flex; flex-direction: column; gap: 8px; }

.text-input {
  width: 100%; background: var(--panel-2); border: 1px solid var(--border);
  color: var(--text); border-radius: 8px; padding: 7px 10px; font: inherit; font-size: 13px;
}
.text-input:focus { outline: 1px solid var(--accent); }

.check-row { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text); cursor: pointer; margin-bottom: 10px; }
.check-row input { accent-color: var(--accent); width: 15px; height: 15px; }

.watermark-note {
  font-size: 12px; color: var(--muted);
  background: var(--panel-2); border: 1px solid var(--border);
  padding: 10px 12px; border-radius: 8px; margin-bottom: 8px;
}
.linklike {
  appearance: none; border: none; background: none; padding: 0;
  color: #c4b5fd; font: inherit; font-size: 12px; font-weight: 600; cursor: pointer;
}
.linklike:hover { text-decoration: underline; }

.export-dim { font-size: 12px; color: var(--muted); margin-top: 8px; min-height: 16px; }

/* ---------- Modal ---------- */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(5,6,10,.7); backdrop-filter: blur(6px);
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.modal-backdrop:not(.hidden) { animation: backdropIn .25s ease; }
.modal {
  position: relative;
  width: 100%; max-width: 400px;
  background: var(--panel); border: 1px solid var(--border);
  border-radius: 16px; padding: 26px;
  box-shadow: 0 30px 80px rgba(0,0,0,.6);
}
.modal-backdrop:not(.hidden) .modal { animation: modalIn .35s cubic-bezier(.16,1,.3,1); }
@keyframes backdropIn { from { opacity: 0; } }
@keyframes modalIn { from { opacity: 0; transform: translateY(14px) scale(.97); } }
.modal-close {
  position: absolute; top: 10px; right: 12px;
  appearance: none; border: none; background: none;
  color: var(--muted); font-size: 22px; cursor: pointer; line-height: 1;
}
.modal-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.modal-brand h3 { margin: 0; font-size: 20px; }
.grad-text {
  background: var(--grad);
  -webkit-background-clip: text; background-clip: text;
  color: transparent;
}
.pro-perks { list-style: none; padding: 0; margin: 0 0 18px; }
.pro-perks li { padding: 5px 0 5px 26px; position: relative; color: var(--text); font-size: 13.5px; }
.pro-perks li::before {
  content: "✓"; position: absolute; left: 2px; font-weight: 800;
  background: var(--grad);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.divider {
  display: flex; align-items: center; gap: 10px;
  color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .1em;
  margin: 16px 0 10px;
}
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--border); }
#licenseInput {
  width: 100%; resize: none;
  background: var(--panel-2); border: 1px solid var(--border);
  color: var(--text); border-radius: 8px; padding: 9px 11px;
  font: 12px/1.5 ui-monospace, "Cascadia Mono", Consolas, monospace;
  margin-bottom: 10px;
}
#licenseInput:focus { outline: 1px solid var(--accent); }
.license-error {
  color: #fca5a5; background: rgba(220,38,38,.12);
  border: 1px solid rgba(220,38,38,.3);
  font-size: 12.5px; padding: 8px 11px; border-radius: 8px; margin-bottom: 10px;
}
.licensed-line { font-size: 14.5px; margin: 4px 0 6px; }
.licensed-line strong { color: #c4b5fd; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; bottom: 26px; left: 50%;
  transform: translate(-50%, 20px);
  background: #22252e; border: 1px solid var(--border);
  color: var(--text); font-weight: 600; font-size: 13.5px;
  padding: 10px 18px; border-radius: 99px;
  box-shadow: 0 10px 30px rgba(0,0,0,.5);
  opacity: 0; pointer-events: none;
  transition: opacity .2s, transform .2s;
  z-index: 100;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- Responsive ---------- */
@media (max-width: 860px) {
  body { overflow: auto; }
  main { flex-direction: column; }
  .stage { min-height: 46vh; padding: 16px; }
  .panel { width: 100%; flex: none; border-left: none; border-top: 1px solid var(--border); }
  .canvas-wrap canvas { max-height: 42vh; }
  .dropzone { padding: 36px 22px; }
}
