:root {
  color-scheme: light dark;
  --bg: #f4f6f8;
  --surface: rgba(255,255,255,.94);
  --surface-solid: #fff;
  --surface-muted: #f7f8fa;
  --text: #101319;
  --muted: #6d7480;
  --line: #e3e6ea;
  --line-strong: #d7dbe1;
  --accent: #111318;
  --accent-contrast: #fff;
  --accent-soft: #eef0f3;
  --success: #247655;
  --success-bg: #edf8f3;
  --warning: #8c5f16;
  --warning-bg: #fff8e8;
  --shadow: 0 18px 45px rgba(17,24,39,.065), 0 2px 8px rgba(17,24,39,.035);
  --shadow-small: 0 8px 24px rgba(17,24,39,.055), 0 1px 4px rgba(17,24,39,.03);
  --radius-xl: 24px;
  --radius-lg: 18px;
  --radius-md: 13px;
}

* { box-sizing: border-box; }
html {
  min-width: 320px;
  background: var(--bg);
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}
body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at 8% -6%, rgba(255,255,255,.98), transparent 32rem),
    radial-gradient(circle at 95% 5%, rgba(224,228,234,.82), transparent 30rem),
    var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
button, input, textarea, select { font: inherit; }
button, select { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }
svg { display: block; }
[hidden] { display: none !important; }

.page-shell {
  width: min(1160px, calc(100% - 40px));
  margin: 0 auto;
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
}
.topbar {
  height: 78px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  text-decoration: none;
  font-weight: 780;
  letter-spacing: -.025em;
  font-size: 17px;
}
.brand-mark {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  background: var(--accent);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.1);
}
.brand-mark svg { width: 22px; height: 22px; fill: var(--accent-contrast); }
.privacy-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 36px;
  padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255,255,255,.62);
  color: #626a76;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}
.privacy-pill svg { width: 15px; height: 15px; fill: currentColor; }
.topbar-actions {
  display:flex;
  align-items:center;
  justify-content:flex-end;
  gap:8px;
  min-width:0;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1.08fr) minmax(350px, .92fr);
  grid-template-areas:
    "create preview"
    "appearance preview"
    "privacy preview";
  gap: 16px 22px;
  align-items: start;
}
.card {
  background: var(--surface);
  border: 1px solid rgba(220,224,229,.94);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}
.create-card { grid-area: create; border-radius: var(--radius-xl); padding: 28px; }
.appearance-card { grid-area: appearance; border-radius: var(--radius-xl); padding: 24px 28px 28px; }
.preview-card { grid-area: preview; border-radius: var(--radius-xl); padding: 26px; position: sticky; top: 16px; }
.privacy-card { grid-area: privacy; border-radius: 18px; padding: 15px 17px; display: flex; gap: 13px; align-items: flex-start; }

.section-heading,
.preview-title-wrap {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  min-width: 0;
}
.section-heading > div,
.preview-title-wrap > div { min-width: 0; }
.step-badge {
  width: 28px;
  height: 28px;
  border-radius: 9px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  background: var(--accent-soft);
  color: #5f6671;
  font-size: 11px;
  font-weight: 850;
  margin-top: 1px;
}
.section-heading h1 {
  margin: 4px 0 7px;
  font-size: clamp(28px, 4vw, 36px);
  line-height: 1.03;
  letter-spacing: -.045em;
}
.section-heading p,
.appearance-heading p { margin: 0; color: var(--muted); line-height: 1.5; font-size: 13px; }
.eyebrow {
  display: block;
  font-size: 10px;
  font-weight: 850;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: #858c96;
}

.type-tabs {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 6px;
  padding: 4px;
  margin: 24px 0 21px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface-muted);
}
.type-tab {
  min-width: 0;
  min-height: 40px;
  border: 1px solid transparent;
  background: transparent;
  color: #6c737e;
  border-radius: 10px;
  padding: 0 8px;
  font-size: 12px;
  font-weight: 720;
  white-space: nowrap;
  transition: background .16s ease, color .16s ease, box-shadow .16s ease, transform .16s ease;
}
.type-tab:hover { color: #343942; background: rgba(255,255,255,.65); }
.type-tab:active { transform: scale(.97); }
.type-tab.active {
  background: var(--surface-solid);
  color: var(--text);
  border-color: var(--line);
  box-shadow: 0 3px 10px rgba(17,24,39,.06);
}

.dynamic-fields { min-height: 108px; }
.field-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.field-grid .span-2 { grid-column: 1 / -1; }
.field { display: grid; gap: 7px; min-width: 0; }
.field > span:first-child { color: #484f59; font-size: 12px; font-weight: 740; }
.field input:not([type="color"]),
.field textarea,
.field select {
  width: 100%;
  min-height: 47px;
  border: 1px solid var(--line-strong);
  background: var(--surface-solid);
  color: var(--text);
  border-radius: var(--radius-md);
  outline: none;
  padding: 11px 12px;
  transition: border-color .15s ease, box-shadow .15s ease, background .15s ease;
}
.field textarea { min-height: 104px; resize: vertical; line-height: 1.5; }
.field input:focus, .field textarea:focus, .field select:focus {
  border-color: #9ea4ad;
  box-shadow: 0 0 0 4px rgba(17,19,24,.055);
}
.field input::placeholder, .field textarea::placeholder { color: #a1a6ae; }
.helper { margin: 6px 0 0; font-size: 11px; color: #9096a0; line-height: 1.45; }
.checkbox-row {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 46px;
  padding: 0 2px;
  color: #444b55;
  font-size: 13px;
  font-weight: 650;
}
.checkbox-row input { width: 18px; height: 18px; accent-color: var(--accent); }

.appearance-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 19px;
}
.appearance-heading h2 {
  margin: 3px 0 4px;
  font-size: 19px;
  letter-spacing: -.025em;
}
.text-button {
  border: 1px solid var(--line);
  background: var(--surface-muted);
  color: #646b76;
  border-radius: 10px;
  min-height: 36px;
  padding: 0 11px;
  font-size: 11px;
  font-weight: 760;
}
.text-button:hover { color: var(--text); background: var(--surface-solid); }
.settings-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.color-control {
  display: grid;
  grid-template-columns: 44px 1fr;
  border: 1px solid var(--line-strong);
  background: var(--surface-solid);
  border-radius: var(--radius-md);
  overflow: hidden;
  min-height: 47px;
}
.color-control input[type="color"] {
  appearance: none;
  -webkit-appearance: none;
  width: 44px;
  height: 45px;
  padding: 8px 4px 8px 8px;
  border: 0;
  background: transparent;
  cursor: pointer;
}
.color-control input[type="color"]::-webkit-color-swatch-wrapper { padding: 0; }
.color-control input[type="color"]::-webkit-color-swatch,
.color-control input[type="color"]::-moz-color-swatch { border: 0; border-radius: 7px; }
.color-control input[type="text"] {
  min-height: 45px !important;
  border: 0 !important;
  border-radius: 0 !important;
  padding-left: 9px !important;
  box-shadow: none !important;
  text-transform: uppercase;
}
.notice {
  margin-top: 17px;
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 12px 13px;
  border-radius: 12px;
  font-size: 12px;
  line-height: 1.45;
}
.notice svg { width: 17px; height: 17px; flex: 0 0 auto; margin-top: 1px; fill: currentColor; }
.notice.warning { background: var(--warning-bg); color: var(--warning); border: 1px solid #f2dfb7; }

.preview-topline { display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.preview-topline h2 { margin: 3px 0 0; font-size: 20px; letter-spacing: -.03em; }
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 9px;
  border-radius: 999px;
  background: var(--success-bg);
  color: var(--success);
  font-size: 11px;
  font-weight: 780;
  white-space: nowrap;
}
.status-badge span { width: 7px; height: 7px; border-radius: 50%; background: #35a576; box-shadow: 0 0 0 3px rgba(53,165,118,.12); }
.status-badge.invalid { background: var(--accent-soft); color: #7b818b; }
.status-badge.invalid span { background: #9da3ab; box-shadow: none; }
.qr-stage {
  width: min(100%, 390px);
  aspect-ratio: 1;
  margin: 24px auto 16px;
  border-radius: 22px;
  background:
    radial-gradient(circle at 50% 30%, rgba(255,255,255,.82), transparent 58%),
    #eff1f4;
  display: grid;
  place-items: center;
  padding: clamp(16px, 4vw, 25px);
  position: relative;
  overflow: hidden;
  border: 1px solid #e6e8ec;
}
#qr-canvas {
  display: block;
  width: 100%;
  height: 100%;
  max-width: 342px;
  max-height: 342px;
  border-radius: 12px;
  box-shadow: 0 12px 30px rgba(18,23,31,.1);
  image-rendering: crisp-edges;
  position: relative;
  z-index: 1;
}
.empty-preview {
  position: absolute;
  z-index: 2;
  inset: 0;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 10px;
  text-align: center;
  padding: 30px;
  color: #858c96;
}
.empty-preview svg { width: 46px; height: 46px; fill: #a8adb5; }
.empty-preview p { margin: 0; font-size: 13px; }
.preview-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: #858c96;
  font-size: 11px;
  margin-bottom: 14px;
}
.preview-meta span:first-child { color: #555c67; font-weight: 760; }
.download-actions { display: grid; grid-template-columns: minmax(0,1fr) auto auto; gap: 8px; }
.button {
  min-height: 47px;
  border-radius: 13px;
  border: 1px solid var(--line-strong);
  font-weight: 740;
  font-size: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 14px;
  transition: transform .14s ease, background .14s ease, border-color .14s ease, box-shadow .14s ease;
}
.button:active { transform: scale(.98); }
.button.primary {
  background: var(--accent);
  color: var(--accent-contrast);
  border-color: var(--accent);
  box-shadow: 0 7px 18px rgba(17,19,24,.14);
}
.button.primary:hover { filter: brightness(1.12); }
.button.secondary { background: var(--surface-solid); color: #363c45; }
.button.secondary:hover { background: var(--surface-muted); border-color: #cdd1d6; }
.button svg { width: 16px; height: 16px; fill: currentColor; }
.button:disabled { opacity: .45; cursor: not-allowed; box-shadow: none; }
.scan-tip {
  margin-top: 11px;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  gap: 6px;
  color: #8c929c;
  font-size: 10.5px;
  line-height: 1.4;
  text-align: center;
}
.scan-tip svg { width: 14px; height: 14px; flex: 0 0 auto; margin-top: 1px; fill: currentColor; }

.mini-icon { width: 34px; height: 34px; border-radius: 10px; background: var(--accent-soft); display: grid; place-items: center; flex: 0 0 auto; }
.mini-icon svg { width: 18px; height: 18px; fill: #626a75; }
.privacy-card strong { display: block; font-size: 12px; margin-bottom: 3px; }
.privacy-card p { margin: 0; color: var(--muted); font-size: 11px; line-height: 1.45; }
footer { min-height: 70px; display: flex; align-items: center; justify-content: space-between; gap: 16px; color: #9298a1; font-size: 11px; padding: 0 4px; }

.toast {
  position: fixed;
  left: 50%;
  bottom: max(24px, env(safe-area-inset-bottom));
  z-index: 20;
  transform: translate(-50%, 18px);
  background: #111318;
  color: #fff;
  border-radius: 12px;
  padding: 11px 14px;
  box-shadow: 0 12px 30px rgba(17,19,24,.25);
  font-size: 12px;
  font-weight: 650;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s ease, transform .2s ease;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

button:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible, a:focus-visible {
  outline: 2px solid #737983;
  outline-offset: 2px;
}

@media (max-width: 900px) {
  .page-shell { width: min(700px, calc(100% - 28px)); }
  .workspace {
    grid-template-columns: 1fr;
    grid-template-areas:
      "create"
      "preview"
      "appearance"
      "privacy";
    gap: 12px;
  }
  .preview-card { position: static; }
  .qr-stage { width: min(100%, 360px); }
}

@media (max-width: 560px) {
  body { padding-bottom: env(safe-area-inset-bottom); }
  .topbar-actions { display: none; }
  .page-shell { width: 100%; padding-inline: 12px; }
  .topbar {
    min-height: 60px;
    height: calc(60px + env(safe-area-inset-top));
    padding-top: env(safe-area-inset-top);
    padding-inline: 2px;
    gap: 10px;
  }
  .brand { font-size: 16px; gap: 9px; }
  .brand-mark { width: 31px; height: 31px; border-radius: 9px; }
  .brand-mark svg { width: 20px; height: 20px; }
  .topbar-actions { gap:6px; }
  .privacy-pill { min-height: 44px; padding: 0 10px; font-size: 10.5px; background: rgba(255,255,255,.74); }
  .privacy-pill svg { width: 14px; height: 14px; }

  .workspace { gap: 10px; }
  .create-card, .preview-card, .appearance-card { padding: 17px; border-radius: 19px; }
  .privacy-card { padding: 14px 15px; border-radius: 16px; }
  .card {
    box-shadow: var(--shadow-small);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
  }

  .section-heading, .preview-title-wrap { gap: 10px; }
  .step-badge { width: 25px; height: 25px; border-radius: 8px; font-size: 10px; }
  .section-heading h1 { margin: 3px 0 5px; font-size: 27px; line-height: 1.04; }
  .section-heading p, .appearance-heading p { font-size: 12.5px; line-height: 1.42; }
  .eyebrow { font-size: 9px; }

  .type-tabs {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 6px;
    margin: 18px 0 17px;
    padding: 5px;
    border-radius: 14px;
  }
  .type-tab { min-height: 42px; padding: 0 5px; border-radius: 10px; font-size: 12px; }

  .dynamic-fields { min-height: 0; }
  .field-grid { grid-template-columns: 1fr; gap: 13px; }
  .field-grid .span-2 { grid-column: auto; }
  .field { gap: 7px; }
  .field > span:first-child { font-size: 12.5px; }
  .field input:not([type="color"]), .field textarea, .field select {
    min-height: 50px;
    border-radius: 13px;
    padding: 12px 13px;
    font-size: 16px;
  }
  .field textarea { min-height: 112px; }
  .helper { margin-top: 4px; font-size: 10.5px; }
  .checkbox-row { min-height: 48px; padding: 2px 0; font-size: 14px; }
  .checkbox-row input { width: 19px; height: 19px; }

  .preview-topline { align-items: center; }
  .preview-topline h2 { font-size: 18px; }
  .status-badge { padding: 7px 9px; }
  .qr-stage {
    width: min(100%, 310px);
    margin: 17px auto 13px;
    padding: 15px;
    border-radius: 18px;
  }
  #qr-canvas { border-radius: 10px; }
  .preview-meta { margin-bottom: 12px; font-size: 10.5px; }
  .download-actions { grid-template-columns: 1fr 1fr; gap: 8px; }
  .download-actions .button.primary { grid-column: 1 / -1; }
  .button { min-height: 50px; border-radius: 13px; font-size: 13px; }
  .copy-button { width: auto; }
  .scan-tip { margin-top: 10px; font-size: 10.5px; }

  .appearance-heading { margin-bottom: 16px; align-items: center; }
  .appearance-heading h2 { font-size: 18px; }
  .appearance-heading p { max-width: 220px; }
  .text-button { min-height: 36px; flex: 0 0 auto; }
  .settings-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 9px; }
  .settings-grid .color-field { grid-column: 1 / -1; }
  .color-control { grid-template-columns: 50px 1fr; min-height: 50px; border-radius: 13px; }
  .color-control input[type="color"] { width: 50px; height: 48px; padding: 8px 5px 8px 8px; }
  .color-control input[type="text"] { min-height: 48px !important; font-size: 16px !important; }
  .notice { margin-top: 15px; }

  footer { min-height: 55px; padding: 0 4px max(3px, env(safe-area-inset-bottom)); font-size: 10px; }
  footer span:last-child { text-align: right; }
  .toast { width: calc(100% - 28px); max-width: 360px; bottom: max(18px, env(safe-area-inset-bottom)); text-align: center; }
}

@media (max-width: 370px) {
  .page-shell { padding-inline: 9px; }
  .topbar { height: 57px; }
  .privacy-pill { width: 44px; padding: 0; justify-content: center; font-size: 0; }
  .privacy-pill span { display:none; }
  .privacy-pill svg { width: 16px; height: 16px; }
  .create-card, .preview-card, .appearance-card { padding: 15px; border-radius: 17px; }
  .section-heading h1 { font-size: 25px; }
  .type-tabs { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .settings-grid { grid-template-columns: 1fr; }
  .settings-grid .color-field { grid-column: auto; }
  .appearance-heading { align-items: flex-start; }
  .qr-stage { width: min(100%, 286px); padding: 13px; }
  .preview-meta { align-items: flex-start; }
  .preview-meta span:last-child { text-align: right; }
  footer span:last-child { display: none; }
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d0f13;
    --surface: rgba(22,25,31,.94);
    --surface-solid: #1b1f26;
    --surface-muted: #171a20;
    --text: #f5f7fa;
    --muted: #9ba3af;
    --line: #2a2f38;
    --line-strong: #343a45;
    --accent: #f5f7fa;
    --accent-contrast: #101319;
    --accent-soft: #242932;
    --success: #78d3aa;
    --success-bg: #173326;
    --warning: #e1b968;
    --warning-bg: #312a19;
    --shadow: 0 18px 50px rgba(0,0,0,.2), 0 2px 8px rgba(0,0,0,.14);
    --shadow-small: 0 9px 28px rgba(0,0,0,.18);
  }
  body {
    background:
      radial-gradient(circle at 12% -5%, rgba(50,57,68,.45), transparent 30rem),
      radial-gradient(circle at 96% 0%, rgba(34,40,49,.5), transparent 28rem),
      var(--bg);
  }
  .card { border-color: rgba(53,59,69,.92); }
  .privacy-pill { background: rgba(29,33,40,.72); color: #a9b0ba; }
  .field > span:first-child, .checkbox-row { color: #c5cad1; }
  .field input::placeholder, .field textarea::placeholder { color: #6f7782; }
  .type-tab { color: #9ba2ad; }
  .type-tab:hover { color: #e7e9ed; background: rgba(255,255,255,.04); }
  .type-tab.active { background: #242932; color: #f6f7f9; border-color: #353b46; box-shadow: none; }
  .text-button { color: #b1b7c0; }
  .qr-stage {
    background: radial-gradient(circle at 50% 30%, rgba(255,255,255,.07), transparent 58%), #15191f;
    border-color: #2b3039;
  }
  .preview-meta span:first-child { color: #c0c5cc; }
  .button.secondary { color: #e2e5e9; }
  .mini-icon svg { fill: #a8afb9; }
  .notice.warning { border-color: #4e4122; }
}

@media (hover: none) and (pointer: coarse) {
  button, select, input[type="checkbox"], input[type="color"] { touch-action: manipulation; }
  .type-tab { min-height: 44px; }
  .text-button { min-height: 44px; padding-inline: 13px; }
  .type-tab:hover { background: transparent; color: inherit; }
  .type-tab.active:hover { background: var(--surface-solid); color: var(--text); }
  .button.primary:hover { filter: none; }
  .button.secondary:hover { background: var(--surface-solid); border-color: var(--line-strong); }
  .text-button:hover { color: #646b76; background: var(--surface-muted); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; animation: none !important; }
}
