:root {
  --bg: #f0ede8;
  --surface: #ffffff;
  --surface-2: #f7f5f2;
  --surface-3: #ede9e3;
  --border: #ddd9d2;
  --border-focus: #432a60;
  --accent: #432a60;
  --accent-deep: #331c4d;
  --accent-mid: #643a94;
  --accent-light: #eee8f3;
  --accent-glow: rgba(70, 42, 96, 0.15);
  --text: #1a1816;
  --text-muted: #7a766f;
  --text-light: #b2aea7;
  --danger: #dc2626;
  --danger-bg: #fef2f2;
  --danger-border: #fca5a5;
  --shadow-xs: 0 1px 3px rgba(0,0,0,0.05);
  --shadow-sm: 0 2px 8px rgba(0,0,0,0.07);
  --shadow-md: 0 4px 20px rgba(0,0,0,0.09);
  --shadow-lg: 0 8px 40px rgba(0,0,0,0.12);
  --shadow-xl: 0 20px 60px rgba(0,0,0,0.14);
  --r-xs: 6px;
  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 16px;
  --r-xl: 20px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'DM Sans', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

body.auth-checking .app,
body.auth-locked .app {
  display: none;
}

body.auth-locked {
  overflow: auto;
}

/* ─── Scrollbar ──────────────────────────────────────────── */
::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-light); }

/* ─── Header ─────────────────────────────────────────────── */
header {
  height: 60px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  flex-shrink: 0;
  box-shadow: var(--shadow-xs);
  z-index: 100;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
}

.brand-icon {
  width: 34px;
  height: 34px;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-mid) 100%);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 15px;
  box-shadow: 0 3px 10px var(--accent-glow);
}

.brand-logo {
  height: 34px;
  width: auto;
  display: block;
}

.brand-name {
  font-family: 'Outfit', sans-serif;
  font-size: 19px;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -0.6px;
}

.brand-name em {
  font-style: normal;
  color: var(--accent);
}

.header-meta {
  display: flex;
  align-items: center;
  gap: 16px;
}

.header-pill {
  font-size: 11px;
  font-weight: 600;
  font-family: 'Outfit', sans-serif;
  letter-spacing: 0.4px;
  color: var(--accent);
  background: var(--accent-light);
  padding: 4px 10px;
  border-radius: 20px;
  border: 1px solid rgba(42,96,73,0.15);
}

.header-hint {
  font-size: 12px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 5px;
}

/* ─── Auth Gate ─────────────────────────────────────────── */
.qr-auth-gate {
  min-height: calc(100vh - 60px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 36px 28px;
  background:
    linear-gradient(rgba(240, 237, 232, 0.877), rgba(240, 237, 232, 0.493)),
    url("../qrstudiobg.png") center / cover no-repeat,
    var(--bg);
}

.qr-auth-gate[hidden] {
  display: none;
}

.qr-auth-gate-layout {
  width: min(100%, 1040px);
  display: grid;
  grid-template-columns: minmax(300px, 0.95fr) minmax(280px, 1.05fr);
  align-items: center;
  gap: clamp(26px, 5vw, 64px);
}

.qr-auth-gate-inner {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
}

.qr-auth-tool-icon {
  width: 118px;
  height: 118px;
  border-radius: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #ffffff;
  font-size: 52px;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-mid) 100%);
  box-shadow: var(--shadow-xl), 0 12px 32px var(--accent-glow);
}

.qr-auth-gate h1 {
  font-family: 'Outfit', sans-serif;
  font-size: clamp(42px, 8vw, 72px);
  line-height: 0.95;
  font-weight: 800;
  color: var(--text);
  letter-spacing: 0;
}

.qr-auth-gate p {
  max-width: 480px;
  color: var(--text-muted);
  font-size: 18px;
  line-height: 1.55;
}

.qr-auth-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 48px;
  padding: 13px 24px;
  margin-top: 6px;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-mid) 100%);
  color: #ffffff;
  border: none;
  border-radius: var(--r-md);
  font-family: 'Outfit', sans-serif;
  font-size: 14px;
  font-weight: 800;
  letter-spacing: 0.4px;
  text-decoration: none;
  box-shadow: 0 4px 18px rgba(42,96,73,0.35);
  transition: all 0.2s ease;
}

.qr-auth-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 24px rgba(42,96,73,0.45);
}

.qr-auth-showcase {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  text-align: center;
}

.qr-auth-showcase img {
  display: block;
  width: min(100%, 970px);
  height: auto;
  object-fit: contain;
}

.qr-auth-showcase figcaption {
  max-width: 420px;
  color: var(--text-muted);
  font-size: 15px;
  line-height: 1.6;
}

.qr-auth-exclusive-note {
  grid-column: 1 / -1;
  justify-self: center;
  text-align: center;
  color: var(--text-muted);
}

/* ─── Layout ─────────────────────────────────────────────── */
.app {
  display: grid;
  grid-template-columns: 400px 1fr 320px;
  height: calc(100vh - 60px);
  overflow: hidden;
}

/* ─── Left Panel ─────────────────────────────────────────── */
.panel {
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.panel-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 22px 22px 0;
}

/* ─── Section Label ──────────────────────────────────────── */
.sec-label {
  font-family: 'Outfit', sans-serif;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.4px;
  color: var(--text-light);
  margin-bottom: 10px;
}

/* ─── Type Tabs ──────────────────────────────────────────── */
.type-tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  background: var(--surface-2);
  border: 1.5px solid var(--border);
  border-radius: var(--r-md);
  padding: 4px;
  gap: 3px;
}

.type-tab {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  padding: 10px 4px;
  border: none;
  background: transparent;
  border-radius: var(--r-sm);
  cursor: pointer;
  color: var(--text-muted);
  font-size: 9.5px;
  font-weight: 700;
  font-family: 'Outfit', sans-serif;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  transition: all 0.16s ease;
  position: relative;
}

.type-tab i { font-size: 15px; transition: transform 0.16s; }
.type-tab:hover { background: var(--surface); color: var(--text); }
.type-tab:hover i { transform: translateY(-1px); }

.type-tab.active {
  background: var(--accent);
  color: white;
  box-shadow: 0 2px 10px rgba(42,96,73,0.35);
}

/* ─── Tab Panes ──────────────────────────────────────────── */
.pane { display: none; margin-top: 16px; }
.pane.active { display: block; animation: fadeSlide 0.2s ease; }

@keyframes fadeSlide {
  from { opacity: 0; transform: translateY(5px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ─── Form ───────────────────────────────────────────────── */
.form-group { margin-bottom: 12px; }

label.field-label {
  display: block;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 6px;
  font-family: 'Outfit', sans-serif;
}

label.field-label .req { color: var(--danger); margin-left: 2px; }

input[type="text"], input[type="tel"], input[type="url"], input[type="number"],
input[type="email"], textarea, select {
  width: 100%;
  padding: 9px 13px;
  border: 1.5px solid var(--border);
  border-radius: var(--r-sm);
  font-size: 13.5px;
  font-family: 'DM Sans', sans-serif;
  color: var(--text);
  background: var(--surface);
  transition: border-color 0.15s, box-shadow 0.15s;
  outline: none;
  appearance: none;
}

input:focus, textarea:focus, select:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

input::placeholder, textarea::placeholder { color: var(--text-light); }
textarea { resize: vertical; min-height: 82px; line-height: 1.55; }

.helper { font-size: 11px; color: var(--text-muted); margin-top: 5px; line-height: 1.5; }

.phone-wrap { display: flex; gap: 8px; }
.phone-prefix {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 9px 11px;
  border: 1.5px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--surface-2);
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  white-space: nowrap;
  flex-shrink: 0;
}

.phone-prefix i { color: #25D366; }

/* Info Box */
.info-box {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 12px;
  display: flex;
  gap: 10px;
  align-items: center;
  margin-top: 10px;
}

.info-box i { color: var(--accent); margin-top: 2px; font-size: 13px; flex-shrink: 0; }
.info-box-title { font-size: 12px; font-weight: 700; color: var(--text); margin-bottom: 4px; font-family: 'Outfit', sans-serif; }
.info-box-body { font-size: 11px; color: var(--text-muted); line-height: 1.7; }

/* ─── Divider ────────────────────────────────────────────── */
.divider { height: 1px; background: var(--border); margin: 18px 0; }

/* ─── Accordion ──────────────────────────────────────────── */
.accordion { margin-bottom: 6px; }

.accordion-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  padding: 10px 12px;
  border-radius: var(--r-sm);
  background: var(--surface-2);
  border: 1.5px solid var(--border);
  transition: all 0.14s;
  user-select: none;
}

.accordion-head:hover { border-color: var(--border-focus); background: var(--accent-light); }

.accordion-head.open {
  border-color: var(--accent);
  background: var(--accent-light);
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
  border-bottom-color: transparent;
}

.accordion-title {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 13px;
  font-weight: 600;
  font-family: 'Outfit', sans-serif;
  color: var(--text);
}

.accordion-head.open .accordion-title { color: var(--accent); }
.accordion-title i { font-size: 13px; color: var(--accent); }

.accordion-chevron {
  font-size: 11px;
  color: var(--text-muted);
  transition: transform 0.22s;
}

.accordion-head.open .accordion-chevron { transform: rotate(180deg); }

.accordion-body {
  display: none;
  padding: 16px;
  border: 1.5px solid var(--accent);
  border-top: none;
  border-bottom-left-radius: var(--r-sm);
  border-bottom-right-radius: var(--r-sm);
  background: var(--surface);
  animation: bodyFade 0.18s ease;
}

@keyframes bodyFade {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

.accordion-body.open { display: block; }

/* ─── Color Pickers ──────────────────────────────────────── */
.color-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.color-field {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border: 1.5px solid var(--border);
  border-radius: var(--r-sm);
  cursor: pointer;
  transition: border-color 0.14s;
  position: relative;
}

.color-field:hover { border-color: var(--text-light); }

.color-swatch {
  width: 30px;
  height: 30px;
  border-radius: var(--r-xs);
  border: 2px solid rgba(0,0,0,0.08);
  flex-shrink: 0;
  cursor: pointer;
  position: relative;
  overflow: hidden;
}

.color-swatch-inner {
  width: 100%;
  height: 100%;
}

input[type="color"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  width: 100%;
  height: 100%;
  cursor: pointer;
  border: none;
  padding: 0;
}

.color-info { flex: 1; min-width: 0; }
.color-info-label { font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; color: var(--text-muted); }
.color-info-val { font-size: 13px; font-weight: 700; color: var(--text); font-family: 'Outfit', monospace; }

.qr-color-mode-row {
  margin-top: 12px;
}

.qr-color-mode-row .field-label {
  margin-bottom: 8px;
}

.qr-color-mode-toggle {
  display: block;
  cursor: pointer;
  user-select: none;
}

.qr-color-mode-toggle input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.qr-color-mode-ui {
  position: relative;
  display: grid;
  grid-template-columns: 1fr 1fr;
  min-height: 40px;
  padding: 4px;
  border: 1.5px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface-2);
  overflow: hidden;
}

.qr-color-mode-ui span:not(.qr-color-mode-thumb) {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Outfit', sans-serif;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--text-muted);
  transition: color 0.2s ease;
}

.qr-color-mode-thumb {
  position: absolute;
  z-index: 1;
  top: 4px;
  left: 4px;
  width: calc(50% - 4px);
  height: calc(100% - 8px);
  border-radius: var(--r-sm);
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-mid) 100%);
  box-shadow: 0 2px 10px rgba(42,96,73,0.28);
  transition: transform 0.24s ease;
}

.qr-color-mode-toggle input:checked + .qr-color-mode-ui .qr-color-mode-thumb {
  transform: translateX(0);
}

.qr-color-mode-toggle input:not(:checked) + .qr-color-mode-ui .qr-color-mode-thumb {
  transform: translateX(100%);
}

.qr-color-mode-toggle input:checked + .qr-color-mode-ui span:first-child,
.qr-color-mode-toggle input:not(:checked) + .qr-color-mode-ui span:nth-child(2) {
  color: #ffffff;
}

/* ─── Logo Upload ────────────────────────────────────────── */
.logo-drop {
  border: 2px dashed var(--border);
  border-radius: var(--r-sm);
  padding: 18px;
  text-align: center;
  cursor: pointer;
  transition: all 0.18s;
  position: relative;
}

.logo-drop:hover { border-color: var(--accent); background: var(--accent-light); }
.logo-drop.filled { border-style: solid; border-color: var(--accent); padding: 12px; }

.logo-drop-icon { font-size: 22px; color: var(--text-light); margin-bottom: 7px; }
.logo-drop-text { font-size: 13px; color: var(--text-muted); font-weight: 500; margin-bottom: 3px; }
.logo-drop-hint { font-size: 11px; color: var(--text-light); }

.logo-drop.filled .logo-drop-icon,
.logo-drop.filled .logo-drop-text,
.logo-drop.filled .logo-drop-hint { display: none; }

.logo-filled-view {
  display: none;
  align-items: center;
  gap: 12px;
}

.logo-drop.filled .logo-filled-view { display: flex; }

.logo-thumb {
  width: 50px;
  height: 50px;
  border-radius: var(--r-xs);
  object-fit: cover;
  border: 1px solid var(--border);
  flex-shrink: 0;
}

.logo-filled-info { flex: 1; text-align: left; min-width: 0; }
.logo-filled-name { font-size: 13px; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.logo-filled-sub { font-size: 11px; color: var(--text-muted); margin-top: 2px; }

.logo-remove {
  background: none;
  border: none;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text-muted);
  flex-shrink: 0;
  transition: all 0.14s;
}

.logo-remove:hover { color: var(--danger); background: var(--danger-bg); }

/* ─── Logo Background ────────────────────────────────────── */
.logo-bg-options {
  margin-top: 12px;
}

.logo-bg-options .field-label {
  margin-bottom: 8px;
}

.logo-bg-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.logo-bg-option {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 36px;
  border: 1.5px solid var(--border);
  border-radius: var(--r-sm);
  color: var(--text-muted);
  cursor: pointer;
  font-family: 'Outfit', sans-serif;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  transition: all 0.14s;
  user-select: none;
}

.logo-bg-option:hover {
  border-color: var(--text-light);
  color: var(--text);
}

.logo-bg-option input {
  width: 13px;
  height: 13px;
  accent-color: var(--accent);
  cursor: pointer;
}

.logo-bg-option:has(input:checked) {
  border-color: var(--accent);
  background: var(--accent-light);
  color: var(--accent);
}

/* ─── Options Checkboxes ─────────────────────────────────── */
.options-stack { display: flex; flex-direction: column; gap: 9px; }

.opt-row {
  display: flex;
  align-items: center;
  gap: 9px;
  cursor: pointer;
}

.opt-row input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
  cursor: pointer;
  flex-shrink: 0;
}

.opt-label { font-size: 13px; color: var(--text); user-select: none; }
.opt-label small { color: var(--text-muted); font-size: 11px; display: block; margin-top: 1px; }

/* ─── Frame Grid ─────────────────────────────────────────── */
.frame-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.frame-opt { position: relative; }
.frame-opt input[type="radio"] { display: none; }

.frame-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 10px 4px;
  border: 2px solid var(--border);
  border-radius: var(--r-sm);
  cursor: pointer;
  text-align: center;
  font-size: 9.5px;
  font-weight: 700;
  font-family: 'Outfit', sans-serif;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  transition: all 0.16s;
  user-select: none;
}

.frame-card:hover { border-color: var(--text-light); color: var(--text); }

.frame-opt input:checked + .frame-card {
  border-color: var(--accent);
  background: var(--accent-light);
  color: var(--accent);
}

.frame-icon { width: 38px; height: 38px; }
.frame-icon svg { width: 100%; height: 100%; }

.frame-text-wrap { margin-top: 12px; }

/* ─── Error ──────────────────────────────────────────────── */
.error-bar {
  background: var(--danger-bg);
  border: 1.5px solid var(--danger-border);
  border-radius: var(--r-sm);
  padding: 10px 13px;
  font-size: 12.5px;
  color: var(--danger);
  display: none;
  align-items: center;
  gap: 8px;
  margin-top: 14px;
}

.error-bar.show { display: flex; animation: fadeSlide 0.18s ease; }

/* ─── Generate Button ────────────────────────────────────── */
.gen-section {
  padding: 14px 22px 18px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
  background: var(--surface);
}

.gen-btn {
  width: 100%;
  padding: 13px 24px;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-mid) 100%);
  color: white;
  border: none;
  border-radius: var(--r-md);
  font-family: 'Outfit', sans-serif;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  letter-spacing: 0.2px;
  transition: all 0.2s ease;
  box-shadow: 0 4px 18px rgba(42,96,73,0.35);
  position: relative;
  overflow: hidden;
}

.gen-btn::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(255,255,255,0.1) 0%, transparent 100%);
  opacity: 0;
  transition: opacity 0.2s;
}

.gen-btn:hover { transform: translateY(-1px); box-shadow: 0 6px 24px rgba(42,96,73,0.45); }
.gen-btn:hover::before { opacity: 1; }
.gen-btn:active { transform: translateY(0); box-shadow: 0 2px 10px rgba(42,96,73,0.3); }
.gen-btn.loading { pointer-events: none; opacity: 0.8; }
.gen-btn .spin { animation: rotate 0.7s linear infinite; }
@keyframes rotate { to { transform: rotate(360deg); } }

/* ─── Preview Panel ──────────────────────────────────────── */
.preview {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px;
  background:
    linear-gradient(rgba(240, 237, 232, 0.877), rgba(240, 237, 232, 0.493)),
    url("../qrstudiobg.png") center / cover no-repeat,
    var(--bg);
  position: relative;
  overflow: hidden;
}

/* Decorative background */
.preview::before {
  content: '';
  position: absolute;
  width: 600px;
  height: 600px;
  top: -200px;
  right: -200px;
  background: radial-gradient(circle, rgba(42,96,73,0.05) 0%, transparent 70%);
  pointer-events: none;
}

.preview::after {
  content: '';
  position: absolute;
  width: 400px;
  height: 400px;
  bottom: -100px;
  left: -100px;
  background: radial-gradient(circle, rgba(82,168,130,0.04) 0%, transparent 70%);
  pointer-events: none;
}

.preview-card {
  background: var(--surface);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-xl);
  padding: 28px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  width: 100%;
  max-width: 440px;
  position: relative;
  z-index: 1;
}

.preview-footer-meta {
  margin-top: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  flex-wrap: wrap;
  position: relative;
  z-index: 1;
}

.preview-card-top {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.preview-card-title {
  font-family: 'Outfit', sans-serif;
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
}

.status-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11.5px;
  font-weight: 600;
  font-family: 'Outfit', sans-serif;
  color: var(--text-muted);
  padding: 4px 9px;
  border-radius: 20px;
  background: var(--surface-2);
  border: 1px solid var(--border);
}

.status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-light);
  flex-shrink: 0;
}

.status-badge.ready { color: var(--accent); background: var(--accent-light); border-color: rgba(42,96,73,0.2); }
.status-badge.ready .status-dot { background: var(--accent); box-shadow: 0 0 0 3px rgba(42,96,73,0.2); }

/* QR Display */
.qr-display {
  width: 300px;
  height: 300px;
  background: var(--surface-2);
  border-radius: var(--r-lg);
  border: 1.5px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
  transition: all 0.3s ease;
}

.qr-display.has-qr { border-color: transparent; box-shadow: var(--shadow-md); }

.qr-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 20px;
}

.qr-empty-icon {
  width: 72px;
  height: 72px;
  background: var(--surface-3);
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 30px;
  color: var(--text-light);
}

.qr-empty p {
  font-size: 13px;
  color: var(--text-muted);
  text-align: center;
  max-width: 180px;
  line-height: 1.55;
}

#qr-canvas-wrap {
  display: none;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
}

#qr-canvas-wrap canvas {
  max-width: 100%;
  max-height: 100%;
  image-rendering: -webkit-optimize-contrast;
  image-rendering: pixelated;
  border-radius: 6px;
}

/* QR Meta */
.qr-meta {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  overflow: hidden;
  display: none;
}

.meta-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 14px;
  font-size: 12px;
}

.meta-row + .meta-row { border-top: 1px solid var(--border); }
.meta-key { color: var(--text-muted); font-weight: 500; }
.meta-val { font-weight: 700; color: var(--text); font-family: 'Outfit', sans-serif; font-size: 12px; }
.meta-val .badge {
  display: inline-block;
  padding: 2px 7px;
  border-radius: 10px;
  font-size: 10px;
  font-weight: 700;
}

.badge-url { background: #dbeafe; color: #1d4ed8; }
.badge-wa { background: #dcfce7; color: #166534; }
.badge-text { background: #fef3c7; color: #92400e; }
.badge-pdf { background: #fee2e2; color: #991b1b; }
.badge-pix { background: #ccfbf1; color: #0f766e; }
.badge-wifi { background: #e0e7ff; color: #3730a3; }

/* ─── Download ───────────────────────────────────────────── */
.dl-wrap { width: 100%; display: none; }

.dl-dropdown { position: relative; width: 100%; }

.dl-btn {
  width: 100%;
  padding: 11px 18px;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: var(--r-md);
  font-family: 'Outfit', sans-serif;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all 0.16s;
}

.dl-btn:hover { background: var(--accent-deep); }
.dl-btn .chevron { margin-left: auto; transition: transform 0.2s; }
.dl-btn.open .chevron { transform: rotate(180deg); }

.dl-menu {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 0;
  right: 0;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  display: none;
  z-index: 300;
}

.dl-menu.open { display: block; animation: menuUp 0.16s ease; }

@keyframes menuUp {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.dl-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 16px;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  cursor: pointer;
  font-family: 'DM Sans', sans-serif;
  font-size: 13.5px;
  color: var(--text);
  transition: background 0.12s;
}

.dl-item:hover { background: var(--surface-2); }

.dl-item-icon {
  width: 34px;
  height: 34px;
  border-radius: var(--r-xs);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  flex-shrink: 0;
}

.dl-item-icon.png { background: #dbeafe; color: #1d4ed8; }
.dl-item-icon.svg { background: #f3e8ff; color: #7c3aed; }
.dl-item-icon.plate { background: #ecfdf5; color: #047857; }

.dl-item-info { flex: 1; }
.dl-item-name { font-weight: 700; }
.dl-item-desc { font-size: 11px; color: var(--text-muted); margin-top: 1px; }

/* ─── Char Counter ───────────────────────────────────────── */
.char-counter { display: flex; justify-content: space-between; align-items: center; }
.char-bar-track { height: 3px; background: var(--border); border-radius: 10px; margin-top: 4px; overflow: hidden; }
.char-bar-fill { height: 100%; background: var(--accent); border-radius: 10px; transition: width 0.2s, background 0.2s; }
.char-bar-fill.warn { background: #f59e0b; }
.char-bar-fill.over { background: var(--danger); }

/* ─── History ───────────────────────────────────────────── */
.history-panel {
  background: var(--surface);
  border-left: 1px solid var(--border);
  padding: 22px;
  overflow-y: auto;
}

.history-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.history-head h2 {
  font-family: 'Outfit', sans-serif;
  font-size: 19px;
  font-weight: 800;
  color: var(--text);
}

.history-close,
.history-mobile-toggle {
  display: none;
}

.history-helper {
  margin: 12px 0 16px;
  color: var(--text-muted);
  font-size: 12px;
  line-height: 1.55;
}

.history-clear {
  width: 100%;
  min-height: 36px;
  margin-bottom: 14px;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--surface-2);
  color: var(--text-muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: 'Outfit', sans-serif;
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  cursor: pointer;
  transition: all 0.16s;
}

.history-clear:hover {
  border-color: var(--danger);
  color: var(--danger);
  background: var(--danger-bg);
}

.history-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.history-empty {
  padding: 16px;
  border: 1px dashed var(--border);
  border-radius: var(--r-md);
  color: var(--text-muted);
  font-size: 12px;
  line-height: 1.55;
  text-align: center;
  background: var(--surface-2);
}

.history-card {
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface-2);
  padding: 12px;
}

.history-card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.history-card-title {
  font-family: 'Outfit', sans-serif;
  font-size: 13px;
  font-weight: 800;
  color: var(--text);
  line-height: 1.25;
}

.history-kind {
  flex-shrink: 0;
  padding: 2px 7px;
  border-radius: 999px;
  background: var(--accent-light);
  color: var(--accent);
  font-family: 'Outfit', sans-serif;
  font-size: 9px;
  font-weight: 800;
  text-transform: uppercase;
}

.history-card-content {
  color: var(--text-muted);
  font-size: 11px;
  line-height: 1.45;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.history-card-meta {
  margin-top: 7px;
  color: var(--text-light);
  font-size: 10.5px;
}

.history-card-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 7px;
  margin-top: 10px;
}

.history-action {
  min-height: 32px;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--surface);
  color: var(--text);
  font-family: 'Outfit', sans-serif;
  font-size: 11px;
  font-weight: 800;
  cursor: pointer;
}

.history-action.primary {
  color: #ffffff;
  background: var(--accent);
  border-color: var(--accent);
}

/* ─── Plate Studio ──────────────────────────────────────── */
body.plate-mode {
  overflow: auto;
}

body.plate-mode .app {
  display: none;
}

.plate-studio[hidden] {
  display: none;
}

.plate-studio {
  display: grid;
  grid-template-columns: 360px 1fr;
  min-height: calc(100vh - 60px);
  background: var(--bg);
}

.plate-panel {
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 22px;
  overflow-y: auto;
}

.plate-panel-head {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-bottom: 22px;
}

.plate-panel-head h2 {
  font-family: 'Outfit', sans-serif;
  font-size: 24px;
  font-weight: 800;
  letter-spacing: 0;
  color: var(--text);
}

.plate-back-btn {
  width: max-content;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1.5px solid var(--border);
  background: var(--surface-2);
  color: var(--text-muted);
  border-radius: var(--r-sm);
  padding: 9px 12px;
  font-family: 'Outfit', sans-serif;
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  cursor: pointer;
  transition: all 0.16s;
}

.plate-back-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-light);
}

.plate-format-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

.plate-format-option,
.plate-bg-option {
  cursor: pointer;
}

.plate-format-option input,
.plate-bg-option input {
  display: none;
}

.plate-format-option span {
  min-height: 42px;
  border: 1.5px solid var(--border);
  border-radius: var(--r-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Outfit', sans-serif;
  font-size: 12px;
  font-weight: 800;
  color: var(--text-muted);
  background: var(--surface-2);
}

.plate-format-option input:checked + span {
  border-color: var(--accent);
  color: #ffffff;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-mid) 100%);
}

.plate-bg-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 7px;
}

.plate-bg-option span {
  display: block;
  aspect-ratio: 0.707;
  border: 2px solid var(--border);
  border-radius: var(--r-xs);
  background-color: var(--surface-2);
  background-size: cover;
  background-position: center;
  box-shadow: var(--shadow-xs);
  transition: all 0.16s;
}

.plate-bg-custom {
  display: flex !important;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 18px;
  background-image:
    linear-gradient(45deg, rgba(67,42,96,0.08) 25%, transparent 25%),
    linear-gradient(-45deg, rgba(67,42,96,0.08) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, rgba(67,42,96,0.08) 75%),
    linear-gradient(-45deg, transparent 75%, rgba(67,42,96,0.08) 75%);
  background-size: 12px 12px;
  background-position: 0 0, 0 6px, 6px -6px, -6px 0;
}

.plate-bg-option input:checked + span {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.plate-custom-bg-field {
  display: none;
}

.plate-custom-bg-field.show {
  display: block;
}

.plate-actions {
  display: grid;
  gap: 10px;
  margin-top: 20px;
}

.plate-logo-control {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 58px;
  padding: 9px 10px;
  border: 1.5px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--surface-2);
  cursor: pointer;
  transition: all 0.16s;
}

.plate-logo-control:hover {
  border-color: var(--accent);
  background: var(--accent-light);
}

.plate-logo-thumb {
  width: 40px;
  height: 40px;
  border-radius: var(--r-xs);
  background: var(--surface);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-light);
  overflow: hidden;
  flex-shrink: 0;
}

.plate-logo-thumb img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.plate-logo-text {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.plate-logo-text strong {
  font-size: 13px;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.plate-logo-text span {
  font-size: 11px;
  color: var(--text-muted);
}

.plate-logo-remove {
  width: 28px;
  height: 28px;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--text-muted);
  display: none;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
}

.plate-logo-control.filled .plate-logo-remove {
  display: flex;
}

.plate-logo-remove:hover {
  color: var(--danger);
  background: var(--danger-bg);
}

.plate-pdf-btn {
  background: var(--accent-deep);
}

.plate-preview-wrap {
  min-height: calc(100vh - 60px);
  overflow: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  padding: 34px 24px;
  background:
    linear-gradient(rgba(240, 237, 232, 0.9), rgba(240, 237, 232, 0.74)),
    url("../qrstudiobg.png") center / cover no-repeat,
    var(--bg);
}

.plate-sheet {
  width: min(100%, 560px);
  aspect-ratio: 210 / 297;
  background-color: #ffffff;
  background-size: cover;
  background-position: center;
  box-shadow: var(--shadow-xl);
  position: relative;
  overflow: hidden;
  -webkit-print-color-adjust: exact;
  print-color-adjust: exact;
}

.plate-logos-overlay {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: none;
  z-index: 1;
  pointer-events: none;
}

.plate-sheet.custom-bg .plate-logos-overlay {
  display: block;
}

.plate-sheet.a3 {
  width: min(100%, 660px);
}

.plate-content {
  position: absolute;
  inset: 0;
  padding: 12% 10% 10%;
  display: grid;
  grid-template-rows: 0.9fr auto auto auto 1fr;
  align-items: center;
  justify-items: center;
  text-align: center;
  gap: 16px;
  z-index: 2;
}

.plate-brand {
  align-self: end;
  min-height: 54px;
  display: none;
  align-items: center;
  justify-content: center;
  gap: 14px;
  max-width: 82%;
}

.plate-brand.show {
  display: flex;
}

.plate-brand.logo-only img {
  width: 60%;
}

.plate-brand img {
  width: 60%;
  object-fit: contain;
  display: none;
}

.plate-brand.has-logo img {
  display: block;
}

.plate-brand span {
  font-family: 'Outfit', sans-serif;
  font-size: clamp(20px, 3vw, 34px);
  line-height: 1.05;
  font-weight: 800;
  color: var(--text);
  letter-spacing: 0;
  text-align: left;
  overflow-wrap: anywhere;
}

.plate-brand.logo-only span {
  display: none;
}

.plate-content h1 {
  max-width: 88%;
  font-family: 'Outfit', sans-serif;
  font-size: clamp(30px, 5vw, 54px);
  line-height: 1.05;
  font-weight: 800;
  letter-spacing: 0;
  color: var(--text);
  text-wrap: balance;
}

.plate-qr {
  width: min(52%, 320px);
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #ffffff;
  border-radius: 18px;
  padding: 14px;
  box-shadow: 0 16px 36px rgba(0,0,0,0.12);
}

.plate-qr svg {
  width: 100%;
  height: 100%;
  display: block;
}

.plate-info {
  min-height: 42px;
  max-width: 82%;
  display: flex;
  flex-direction: column;
  gap: 18px;
  gap: 4px;
  color: #000000;
  font-family: 'Outfit', sans-serif;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.35;
}

.plate-footer-meta {
  margin-top: 0;
}

.plate-info strong {
  color: #000000;
}

/* ─── Responsiveness ─────────────────────────────────────── */
@media (max-width: 860px) {
  body { overflow: auto; }
  .app { grid-template-columns: 1fr; height: auto; overflow: visible; }
  .panel { height: auto; overflow: visible; }
  .panel-scroll { overflow: visible; }
  .preview { min-height: 500px; padding: 30px 20px; }
  .header-meta { display: none; }
  header { padding: 0 18px; }
  .brand-name { font-size: 17px; }
  .qr-auth-gate { padding: 30px 20px; }
  .qr-auth-gate-layout { grid-template-columns: 1fr; }
  .qr-auth-tool-icon { width: 96px; height: 96px; border-radius: 24px; font-size: 42px; }
  .qr-auth-gate p { font-size: 16px; }
  .qr-auth-showcase img { max-width: 320px; }
  .qr-auth-showcase figcaption { font-size: 14px; }
  .plate-studio { grid-template-columns: 1fr; }
  .plate-panel { border-right: none; border-bottom: 1px solid var(--border); }
  .plate-preview-wrap { min-height: 70vh; padding: 24px 14px; }
  .history-mobile-toggle {
    position: fixed;
    right: 16px;
    bottom: 16px;
    z-index: 700;
    width: 48px;
    height: 48px;
    border: none;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--accent);
    color: #ffffff;
    box-shadow: var(--shadow-lg);
    cursor: pointer;
  }
  .history-panel {
    position: fixed;
    inset: 0 0 0 auto;
    width: min(88vw, 340px);
    z-index: 800;
    transform: translateX(100%);
    transition: transform 0.24s ease;
    box-shadow: var(--shadow-xl);
  }
  .history-panel.open { transform: translateX(0); }
  .history-close {
    width: 34px;
    height: 34px;
    border: none;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--surface-2);
    color: var(--text-muted);
    cursor: pointer;
  }
}

@media print {
  header,
  .app,
  .qr-auth-gate,
  .plate-panel,
  .plate-footer-meta {
    display: none !important;
  }

  body {
    background: #ffffff !important;
    overflow: visible !important;
  }

  .plate-studio {
    display: block !important;
    min-height: 0 !important;
    background: #ffffff !important;
  }

  .plate-preview-wrap {
    display: block !important;
    min-height: 0 !important;
    padding: 0 !important;
    overflow: visible !important;
    background: #ffffff !important;
  }

  .plate-sheet {
    width: 210mm !important;
    height: 297mm !important;
    aspect-ratio: auto !important;
    box-shadow: none !important;
    margin: 0 !important;
    page-break-after: avoid;
  }

  .plate-sheet.a3 {
    width: 297mm !important;
    height: 420mm !important;
  }
}
