/* ==========================================================================
   QR Studio
   ========================================================================== */

:root {
  --bg: #0b0d11;
  --bg-soft: #10131a;
  --card: #141822;
  --card-2: #1a1f2b;
  --line: #262c3a;
  --line-soft: #1e2430;
  --text: #e8ecf4;
  --text-dim: #99a3b5;
  --text-faint: #6b7688;
  --accent: #6ee7b7;
  --accent-2: #38bdf8;
  --accent-ink: #04231a;
  --danger: #f87171;
  --warn: #fbbf24;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 18px 40px -22px rgba(0, 0, 0, .8);
  --stage: #0e1117;
  color-scheme: dark;
}

[data-theme="light"] {
  --bg: #f4f6fa;
  --bg-soft: #eef1f7;
  --card: #ffffff;
  --card-2: #f6f8fc;
  --line: #dfe4ee;
  --line-soft: #e9edf4;
  --text: #131720;
  --text-dim: #5a6478;
  --text-faint: #838d9f;
  --accent: #0d9488;
  --accent-2: #2563eb;
  --accent-ink: #ffffff;
  --shadow: 0 18px 40px -26px rgba(20, 30, 60, .35);
  --stage: #eef1f7;
  color-scheme: light;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background:
    radial-gradient(1100px 620px at 84% -12%, color-mix(in srgb, var(--accent-2) 13%, transparent), transparent 62%),
    radial-gradient(900px 520px at 4% 0%, color-mix(in srgb, var(--accent) 11%, transparent), transparent 58%),
    var(--bg);
  color: var(--text);
  font: 15px/1.5 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

h1, h2 { margin: 0; font-weight: 650; letter-spacing: -.01em; }

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

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px clamp(16px, 3vw, 34px);
  flex-wrap: wrap;
}

.brand { display: flex; align-items: center; gap: 13px; }
.brand h1 { font-size: 19px; }
.brand p { margin: 2px 0 0; color: var(--text-dim); font-size: 13px; }

.brand-mark {
  width: 38px; height: 38px;
  fill: var(--accent);
  filter: drop-shadow(0 4px 12px color-mix(in srgb, var(--accent) 40%, transparent));
}

.topbar-actions { display: flex; align-items: center; gap: 8px; }

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

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(340px, 420px);
  gap: 18px;
  align-items: start;
  padding: 0 clamp(16px, 3vw, 34px) 28px;
  max-width: 1500px;
  margin: 0 auto;
}

.controls { display: grid; gap: 16px; min-width: 0; }

.preview-pane { position: sticky; top: 18px; }

@media (max-width: 1040px) {
  .layout { grid-template-columns: 1fr; }
  .preview-pane { position: static; order: -1; }
}

/* -------------------------------------------------- cards */

.card {
  background: color-mix(in srgb, var(--card) 88%, transparent);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(8px);
}

.card > h2 {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--text-faint);
  margin-bottom: 14px;
}

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 520px) { .grid-2 { grid-template-columns: 1fr; } }

/* -------------------------------------------------- fields */

.field { margin-bottom: 14px; min-width: 0; }
.field:last-child { margin-bottom: 0; }
.fields { display: grid; gap: 12px; }

label {
  display: block;
  font-size: 12.5px;
  font-weight: 550;
  color: var(--text-dim);
  margin-bottom: 6px;
}

label output { float: right; color: var(--text-faint); font-variant-numeric: tabular-nums; font-weight: 500; }

input[type="text"], input[type="number"], input[type="tel"], input[type="email"],
input[type="url"], input[type="datetime-local"], input[type="date"], textarea, select {
  width: 100%;
  padding: 9px 11px;
  background: var(--card-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  color: var(--text);
  font: inherit;
  font-size: 14px;
  transition: border-color .15s, box-shadow .15s;
}

textarea { resize: vertical; min-height: 84px; line-height: 1.45; }

input:focus-visible, textarea:focus-visible, select:focus-visible, button:focus-visible, .dropzone:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 26%, transparent);
}

select {
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--text-faint) 50%),
                    linear-gradient(135deg, var(--text-faint) 50%, transparent 50%);
  background-position: calc(100% - 17px) 50%, calc(100% - 12px) 50%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-right: 30px;
}

input[type="range"] {
  width: 100%;
  height: 22px;
  appearance: none;
  background: transparent;
  margin: 0;
}
input[type="range"]::-webkit-slider-runnable-track {
  height: 5px; border-radius: 99px; background: var(--line);
}
input[type="range"]::-webkit-slider-thumb {
  appearance: none;
  width: 16px; height: 16px; margin-top: -5.5px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid var(--card);
  box-shadow: 0 1px 6px rgba(0, 0, 0, .35);
  cursor: pointer;
}
input[type="range"]::-moz-range-track { height: 5px; border-radius: 99px; background: var(--line); }
input[type="range"]::-moz-range-thumb {
  width: 14px; height: 14px; border-radius: 50%;
  background: var(--accent); border: 2px solid var(--card); cursor: pointer;
}

label.check {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-dim);
  margin: 0;
  cursor: pointer;
  user-select: none;
}
label.check input { accent-color: var(--accent); width: 15px; height: 15px; }

.hint { margin: 7px 0 0; font-size: 12px; color: var(--text-faint); line-height: 1.45; }

.mini-label { font-size: 12px; color: var(--text-faint); margin-right: 6px; }

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

button {
  font: inherit;
  cursor: pointer;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  transition: background .15s, border-color .15s, color .15s, transform .06s;
}
button:active { transform: translateY(1px); }

button.primary {
  background: linear-gradient(180deg, var(--accent), color-mix(in srgb, var(--accent) 78%, #000));
  color: var(--accent-ink);
  font-weight: 650;
  padding: 11px 18px;
  border: none;
}
button.primary:hover { filter: brightness(1.07); }

button.ghost {
  background: var(--card-2);
  border-color: var(--line);
  color: var(--text-dim);
  padding: 9px 14px;
  font-size: 13px;
  font-weight: 550;
}
button.ghost:hover { color: var(--text); border-color: var(--text-faint); }

button.link {
  background: none; border: none; padding: 0;
  color: var(--accent-2); font-size: 12.5px; text-decoration: underline;
}

.icon-btn {
  background: var(--card-2);
  border: 1px solid var(--line);
  width: 36px; height: 36px;
  display: grid; place-items: center;
  color: var(--text-dim);
}
.icon-btn svg { width: 17px; height: 17px; fill: currentColor; }
.icon-btn:hover { color: var(--text); }

/* -------------------------------------------------- chips / segments */

.chips { display: flex; flex-wrap: wrap; gap: 7px; margin-bottom: 14px; }

.chips button {
  background: var(--card-2);
  border: 1px solid var(--line);
  color: var(--text-dim);
  padding: 6px 12px;
  font-size: 13px;
  font-weight: 550;
  border-radius: 99px;
}
.chips button:hover { color: var(--text); }
.chips button.active {
  background: color-mix(in srgb, var(--accent) 17%, transparent);
  border-color: color-mix(in srgb, var(--accent) 55%, transparent);
  color: var(--accent);
}

.seg {
  display: flex;
  background: var(--card-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 3px;
  gap: 3px;
}
.seg button {
  flex: 1;
  background: none;
  color: var(--text-dim);
  padding: 7px 4px;
  font-size: 12.5px;
  font-weight: 550;
  white-space: nowrap;
}
.seg button:hover { color: var(--text); }
.seg button.active { background: color-mix(in srgb, var(--accent) 20%, transparent); color: var(--accent); }

/* -------------------------------------------------- presets */

.presets { display: flex; flex-wrap: wrap; gap: 8px; }

.presets button {
  display: flex;
  align-items: center;
  gap: 7px;
  background: var(--card-2);
  border: 1px solid var(--line);
  color: var(--text-dim);
  padding: 5px 11px 5px 5px;
  font-size: 12.5px;
  font-weight: 550;
  border-radius: 99px;
}
.presets button:hover { color: var(--text); border-color: var(--text-faint); }
.presets .dot { width: 20px; height: 20px; border-radius: 50%; flex: none; }

/* -------------------------------------------------- shape pickers */

.shape-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(58px, 1fr));
  gap: 7px;
}
.shape-grid.small { grid-template-columns: repeat(auto-fill, minmax(50px, 1fr)); }

.shape-grid button {
  aspect-ratio: 1;
  background: var(--card-2);
  border: 1px solid var(--line);
  display: grid;
  place-items: center;
  padding: 6px;
  color: var(--text-dim);
}
.shape-grid button svg { width: 100%; height: 100%; fill: currentColor; }
.shape-grid button:hover { border-color: var(--text-faint); color: var(--text); }
.shape-grid button.active {
  border-color: var(--accent);
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 12%, transparent);
}

/* -------------------------------------------------- colours */

.color-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.swatch { position: relative; display: block; margin: 0; width: 36px; height: 36px; flex: none; }
.swatch input {
  position: absolute; inset: 0; opacity: 0; width: 100%; height: 100%; cursor: pointer;
}
.swatch span {
  display: block;
  width: 100%; height: 100%;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--_c, #000);
  pointer-events: none;
}

.hex {
  width: 96px !important;
  flex: none;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12.5px !important;
  text-transform: lowercase;
}

.grad-only, .linear-only { display: none; }
.mode-gradient .grad-only { display: block; }
.mode-linear .linear-only { display: block; }

/* -------------------------------------------------- dropzone */

.dropzone {
  border: 1.5px dashed var(--line);
  border-radius: var(--radius);
  padding: 18px;
  text-align: center;
  cursor: pointer;
  transition: border-color .15s, background .15s;
  background: color-mix(in srgb, var(--card-2) 60%, transparent);
}
.dropzone:hover, .dropzone.over { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 8%, transparent); }

.dropzone-empty { display: grid; justify-items: center; gap: 4px; }
.dropzone-empty svg { width: 26px; height: 26px; fill: none; stroke: var(--text-faint); stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.dropzone-empty strong { font-size: 13.5px; font-weight: 600; }
.dropzone-empty span { font-size: 12px; color: var(--text-faint); }

.dropzone-filled { display: flex; align-items: center; gap: 13px; text-align: left; }
.dropzone-filled img {
  width: 52px; height: 52px; object-fit: contain; flex: none;
  background: repeating-conic-gradient(var(--line-soft) 0% 25%, transparent 0% 50%) 50% / 12px 12px;
  border-radius: 8px; padding: 3px;
}
.dropzone-filled strong { display: block; font-size: 13px; word-break: break-all; }

#logo-options { margin-top: 14px; }

/* -------------------------------------------------- preview */

.preview-card { display: grid; gap: 14px; }

.preview-head { display: flex; align-items: center; justify-content: space-between; }
.preview-head h2 { margin: 0; }
.checker-toggle { font-size: 12px; }

.preview-stage {
  background: var(--stage);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  padding: 18px;
  display: grid;
  place-items: center;
  min-height: 260px;
}
.preview-stage.checker {
  background:
    repeating-conic-gradient(color-mix(in srgb, var(--text-faint) 22%, transparent) 0% 25%, transparent 0% 50%)
    50% / 18px 18px, var(--stage);
}

.preview-frame { width: 100%; max-width: 320px; line-height: 0; }
.preview-frame svg { width: 100%; height: auto; display: block; border-radius: 4px; }

.messages { display: grid; gap: 7px; }
.messages:empty { display: none; }

.msg {
  display: flex;
  gap: 9px;
  font-size: 12.5px;
  line-height: 1.45;
  padding: 9px 11px;
  border-radius: var(--radius-sm);
  border: 1px solid;
}
.msg::before { font-weight: 700; }
.msg.warn {
  color: var(--warn);
  border-color: color-mix(in srgb, var(--warn) 35%, transparent);
  background: color-mix(in srgb, var(--warn) 10%, transparent);
}
.msg.warn::before { content: "!"; }
.msg.info {
  color: var(--text-dim);
  border-color: var(--line);
  background: var(--card-2);
}
.msg.info::before { content: "i"; font-style: italic; }
.msg.error {
  color: var(--danger);
  border-color: color-mix(in srgb, var(--danger) 38%, transparent);
  background: color-mix(in srgb, var(--danger) 10%, transparent);
}
.msg.error::before { content: "×"; }

.meta {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 9px 14px;
  margin: 0;
  padding: 13px;
  background: var(--card-2);
  border-radius: var(--radius-sm);
  border: 1px solid var(--line-soft);
}
.meta dt { font-size: 11px; text-transform: uppercase; letter-spacing: .07em; color: var(--text-faint); }
.meta dd { margin: 2px 0 0; font-size: 13px; font-weight: 550; font-variant-numeric: tabular-nums; }

.export { display: grid; gap: 11px; }
.export-actions { display: grid; grid-template-columns: 1.4fr 1fr; gap: 9px; }

/* -------------------------------------------------- footer + toast */

.foot {
  text-align: center;
  padding: 6px 20px 30px;
  color: var(--text-faint);
  font-size: 12px;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 26px;
  transform: translate(-50%, 20px);
  background: var(--card);
  border: 1px solid var(--line);
  color: var(--text);
  padding: 10px 18px;
  border-radius: 99px;
  font-size: 13px;
  font-weight: 550;
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transition: opacity .18s, transform .18s;
  z-index: 40;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

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