/* QR Studio */
:root {
  --bg: #f4f2ec;
  --panel: #ffffff;
  --panel-2: #f8f7f3;
  --ink: #17171b;
  --ink-2: #55555f;
  --ink-3: #8a8a94;
  --line: #e3e0d7;
  --line-2: #d4d0c4;
  --accent: #ff4f1f;
  --accent-ink: #ffffff;
  --accent-soft: #ffe7de;
  --ok: #138a4b;
  --ok-soft: #ddf5e7;
  --warn: #a35d00;
  --warn-soft: #fff1d6;
  --bad: #c0262d;
  --bad-soft: #fde2e2;
  --info-soft: #e8eefc;
  --info: #2c4fa8;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 1px 0 rgba(23, 23, 27, 0.04), 0 8px 24px -12px rgba(23, 23, 27, 0.12);
  --check-a: #ecebe6;
  --check-b: #f7f6f2;
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #121214;
    --panel: #1b1b1f;
    --panel-2: #232328;
    --ink: #f1f0ec;
    --ink-2: #b4b3ad;
    --ink-3: #7e7d78;
    --line: #2c2c32;
    --line-2: #3a3a42;
    --accent: #ff6a3d;
    --accent-ink: #160b07;
    --accent-soft: #3a1f16;
    --ok: #5fd394;
    --ok-soft: #173225;
    --warn: #f3b45a;
    --warn-soft: #382a12;
    --bad: #ff7b80;
    --bad-soft: #3c1a1c;
    --info: #9db6ff;
    --info-soft: #1c2440;
    --shadow: 0 1px 0 rgba(0, 0, 0, 0.3), 0 10px 30px -14px rgba(0, 0, 0, 0.6);
    --check-a: #26262b;
    --check-b: #1f1f23;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #121214;
  --panel: #1b1b1f;
  --panel-2: #232328;
  --ink: #f1f0ec;
  --ink-2: #b4b3ad;
  --ink-3: #7e7d78;
  --line: #2c2c32;
  --line-2: #3a3a42;
  --accent: #ff6a3d;
  --accent-ink: #160b07;
  --accent-soft: #3a1f16;
  --ok: #5fd394;
  --ok-soft: #173225;
  --warn: #f3b45a;
  --warn-soft: #382a12;
  --bad: #ff7b80;
  --bad-soft: #3c1a1c;
  --info: #9db6ff;
  --info-soft: #1c2440;
  --shadow: 0 1px 0 rgba(0, 0, 0, 0.3), 0 10px 30px -14px rgba(0, 0, 0, 0.6);
  --check-a: #26262b;
  --check-b: #1f1f23;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.45 var(--font);
  -webkit-font-smoothing: antialiased;
}
[hidden] { display: none !important; }
svg { display: block; }
button, input, select, textarea { font: inherit; color: inherit; }
code { font-family: var(--mono); font-size: 0.9em; background: var(--panel-2); padding: 1px 5px; border-radius: 5px; }
.muted { color: var(--ink-2); }
.small { font-size: 13px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* top bar */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  max-width: 1320px; margin: 0 auto; padding: 18px 24px 6px;
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); font-weight: 800; font-size: 19px; letter-spacing: -0.02em; }
.brand svg { width: 30px; height: 30px; fill: var(--ink); }
.brand svg rect:nth-child(2) { fill: var(--accent); }
.topbar-actions { display: flex; gap: 6px; }
.icon-btn {
  width: 38px; height: 38px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--panel); display: grid; place-items: center; cursor: pointer;
}
.icon-btn svg, .btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.btn svg .fill { fill: currentColor; stroke: none; }
.icon-btn:hover { border-color: var(--line-2); }
.icon-btn:disabled { opacity: 0.4; cursor: default; }

/* layout */
.layout {
  max-width: 1320px; margin: 0 auto; padding: 12px 24px 48px;
  display: grid; grid-template-columns: minmax(0, 1fr) 420px; gap: 24px; align-items: start;
}
.controls { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.preview-col { position: sticky; top: 16px; display: flex; flex-direction: column; gap: 10px; }

/* cards */
.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px; box-shadow: var(--shadow);
}
.card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; gap: 12px; }
h2 { font-size: 15px; margin: 0; font-weight: 750; letter-spacing: -0.01em; }
h3 { font-size: 12px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--ink-3); margin: 14px 0 8px; font-weight: 700; }
.section { padding: 0; }
.section > summary {
  list-style: none; cursor: pointer; padding: 16px 18px; display: flex; align-items: baseline; gap: 10px;
  user-select: none;
}
.section > summary::-webkit-details-marker { display: none; }
.section > summary::after {
  content: ""; margin-left: auto; width: 9px; height: 9px; border-right: 2px solid var(--ink-3); border-bottom: 2px solid var(--ink-3);
  transform: rotate(45deg); transition: transform 0.15s; align-self: center;
}
.section[open] > summary::after { transform: rotate(-135deg); }
.section > summary .hint { color: var(--ink-3); font-size: 13px; }
.section > :not(summary) { margin-left: 18px; margin-right: 18px; }
.section > :last-child { margin-bottom: 18px; }

/* fields */
.field { display: flex; flex-direction: column; gap: 6px; margin: 10px 0; min-width: 0; }
.field > span { font-size: 13px; color: var(--ink-2); font-weight: 550; display: flex; justify-content: space-between; gap: 8px; }
.field output { color: var(--ink); font-variant-numeric: tabular-nums; font-weight: 650; }
input:not([type]), input[type="url"], input[type="email"], input[type="tel"], input[type="number"], input[type="datetime-local"], select, textarea, .hex {
  width: 100%; padding: 10px 12px; border: 1px solid var(--line-2); border-radius: var(--radius-sm);
  background: var(--panel); outline: none; min-width: 0;
}
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.content-card input[type="url"] { font-size: 17px; padding: 13px 14px; }
.check { display: flex; align-items: center; gap: 9px; margin: 10px 0; cursor: pointer; font-size: 14px; }
.check input { width: 18px; height: 18px; accent-color: var(--accent); margin: 0; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0 12px; }
details.sub { margin-top: 4px; }
details.sub > summary { cursor: pointer; color: var(--ink-2); font-size: 13px; font-weight: 600; padding: 4px 0; }

input[type="range"] { width: 100%; accent-color: var(--accent); margin: 2px 0; }
.color-field { display: flex; gap: 8px; align-items: center; }
.color-field input[type="color"] {
  width: 44px; height: 42px; padding: 3px; border: 1px solid var(--line-2); border-radius: var(--radius-sm);
  background: var(--panel); cursor: pointer; flex: none;
}
.color-field input[type="color"]::-webkit-color-swatch-wrapper { padding: 0; }
.color-field input[type="color"]::-webkit-color-swatch { border: none; border-radius: 7px; }
.color-field input[type="color"]::-moz-color-swatch { border: none; border-radius: 7px; }
.hex { font-family: var(--mono); font-size: 13px; text-transform: lowercase; }

/* segmented */
.seg { display: flex; flex-wrap: wrap; gap: 6px; }
.seg button {
  border: 1px solid var(--line-2); background: var(--panel); padding: 8px 13px; border-radius: 999px;
  cursor: pointer; font-weight: 600; font-size: 14px; color: var(--ink-2);
}
.seg button:hover { color: var(--ink); border-color: var(--ink-3); }
.seg button.active { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.seg.small button { padding: 6px 11px; font-size: 13px; }
.seg.small { margin-top: 8px; margin-bottom: 8px; }
#typeTabs { margin-bottom: 6px; }

/* tiles */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(78px, 1fr)); gap: 8px; margin: 4px 0 10px; }
.tiles.wide { grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); }
.tiles button {
  border: 1.5px solid var(--line); background: #fff; border-radius: 12px; padding: 8px 8px 6px; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 5px; color: #333;
  transition: border-color 0.12s, transform 0.12s;
}
.tiles button svg { width: 100%; height: auto; max-height: 64px; aspect-ratio: 1; }
.tiles.wide button svg { max-height: 90px; aspect-ratio: auto; }
.tiles button span { font-size: 11px; font-weight: 600; color: #555; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.tiles button:hover { border-color: var(--ink-3); transform: translateY(-1px); }
.tiles button.active { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

/* presets */
.presets { display: grid; grid-auto-flow: column; grid-auto-columns: 104px; gap: 10px; overflow-x: auto; padding: 2px 2px 8px; scroll-snap-type: x proximity; }
.preset {
  border: 1.5px solid var(--line); background: var(--panel-2); border-radius: 14px; padding: 8px; cursor: pointer;
  display: flex; flex-direction: column; gap: 6px; align-items: center; scroll-snap-align: start;
}
.preset svg { width: 100%; height: 84px; object-fit: contain; }
.preset span { font-size: 12px; font-weight: 650; color: var(--ink-2); }
.preset:hover { border-color: var(--accent); }

/* paint rows */
.paint .grid2 { margin-top: 2px; }
.grad-row { display: flex; align-items: end; gap: 12px; }
.grad-row .field { flex: 1; }
.grad-row .btn { margin-bottom: 12px; }

/* logo picks */
.logo-picks { margin: 6px 0 4px; }
.swatches { display: flex; gap: 6px; margin-bottom: 8px; flex-wrap: wrap; }
.sw { width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--panel); background: var(--c); box-shadow: 0 0 0 1px var(--line-2); cursor: pointer; padding: 0; }
.sw.active { box-shadow: 0 0 0 2px var(--accent); }
.icons { display: grid; grid-template-columns: repeat(auto-fill, minmax(44px, 1fr)); gap: 6px; }
.icons button { border: 1px solid var(--line); background: var(--panel-2); border-radius: 10px; padding: 6px; cursor: pointer; }
.icons button:hover { border-color: var(--accent); }
.icons img { width: 100%; display: block; }
.file-row { display: flex; align-items: center; gap: 10px; margin: 10px 0; flex-wrap: wrap; }

/* buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 1px solid var(--line-2); background: var(--panel); border-radius: 12px; padding: 10px 14px;
  font-weight: 650; font-size: 14px; cursor: pointer; text-decoration: none; color: var(--ink); white-space: nowrap;
}
.btn:hover { border-color: var(--ink-3); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn.small { padding: 6px 11px; font-size: 13px; border-radius: 10px; }
.btn.ghost { background: transparent; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.05); }
.btn.big { width: 100%; padding: 14px; font-size: 16px; border-radius: 14px; }
.btn-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.btn-row .btn { padding: 9px 6px; font-size: 13px; }

/* preview */
.preview-card { padding: 16px; }
.stage {
  border-radius: 12px; padding: 22px; display: grid; place-items: center; min-height: 300px;
  background-color: var(--check-b);
  background-image: linear-gradient(45deg, var(--check-a) 25%, transparent 25%), linear-gradient(-45deg, var(--check-a) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, var(--check-a) 75%), linear-gradient(-45deg, transparent 75%, var(--check-a) 75%);
  background-size: 18px 18px; background-position: 0 0, 0 9px, 9px -9px, -9px 0;
  position: relative;
}
.qr-out { width: 100%; display: grid; place-items: center; transition: opacity 0.2s; }
.qr-out svg { width: 100%; height: auto; max-height: 440px; filter: drop-shadow(0 6px 18px rgba(0, 0, 0, 0.12)); }
.qr-out.empty { opacity: 0.18; }
.stage.is-empty::after {
  content: "Your QR code appears here"; position: absolute; inset: auto 0 50% 0; transform: translateY(50%);
  text-align: center; font-weight: 700; color: var(--ink-2); pointer-events: none;
}
.qr-out .err { color: var(--bad); text-align: center; font-weight: 600; padding: 40px 10px; }
.status-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 12px; flex-wrap: wrap; }
.scan { font-size: 13px; font-weight: 700; padding: 4px 10px; border-radius: 999px; background: var(--panel-2); color: var(--ink-2); }
.scan::before { content: "●"; margin-right: 6px; font-size: 10px; vertical-align: 1px; }
.scan.ok { background: var(--ok-soft); color: var(--ok); }
.scan.fail { background: var(--bad-soft); color: var(--bad); }
.scan.warn { background: var(--warn-soft); color: var(--warn); }
.scan.busy::before { animation: pulse 0.8s infinite alternate; }
@keyframes pulse { from { opacity: 0.2; } to { opacity: 1; } }
.meta { font-size: 12px; color: var(--ink-3); font-family: var(--mono); }
.capacity { height: 4px; background: var(--panel-2); border-radius: 4px; margin-top: 10px; overflow: hidden; }
.capacity div { height: 100%; background: var(--ink-3); border-radius: 4px; transition: width 0.2s; }
.capacity div.over { background: var(--bad); }
.warnings { list-style: none; padding: 0; margin: 10px 0 0; display: flex; flex-direction: column; gap: 6px; }
.warnings li { font-size: 13px; padding: 8px 11px; border-radius: 10px; line-height: 1.35; }
.warnings li.bad { background: var(--bad-soft); color: var(--bad); }
.warnings li.warn { background: var(--warn-soft); color: var(--warn); }
.warnings li.info { background: var(--info-soft); color: var(--info); }
.export { margin-top: 14px; display: flex; flex-direction: column; gap: 8px; border-top: 1px solid var(--line); padding-top: 12px; }
.export .field { margin: 2px 0; }
.privacy { text-align: center; margin: 0 12px; }

/* toast */
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 12px; font-weight: 600; font-size: 14px;
  transition: opacity 0.2s, transform 0.2s; z-index: 50; max-width: calc(100% - 32px); text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.bad { background: var(--bad); color: #fff; }

#printArea { display: none; }

/* responsive */
@media (max-width: 980px) {
  .layout { grid-template-columns: 1fr; gap: 14px; }
  .controls { display: contents; }
  .content-card { order: -2; }
  .preview-col { position: static; order: -1; }
  .qr-out svg { max-height: 320px; }
  .stage { min-height: 220px; }
}
@media (max-width: 560px) {
  .topbar { padding: 14px 16px 4px; }
  .layout { padding: 10px 16px 40px; gap: 14px; }
  .card { padding: 14px; }
  .section > summary { padding: 14px; }
  .section > :not(summary) { margin-left: 14px; margin-right: 14px; }
  .section > summary .hint { display: none; }
  .grid3 { grid-template-columns: 1fr; }
  .tiles { grid-template-columns: repeat(auto-fill, minmax(66px, 1fr)); }
  .btn-row .btn { font-size: 12px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

@media print {
  body > *:not(#printArea) { display: none !important; }
  #printArea { display: flex !important; justify-content: center; align-items: center; height: 100vh; }
  #printArea svg { width: 70%; height: auto; }
  body { background: #fff; }
}
