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

/* ── Tokens + light default ── */
:root {
  --accent: #8eb353; --accent-dim: rgba(142,179,83,.18);
  --radius: 12px; --ease: cubic-bezier(.4,0,.2,1); --t: .22s;
  --bg: #f4f2ee; --surface: #fff; --surface-alt: #f0eeea;
  --border: rgba(0,0,0,.09); --border-hi: rgba(0,0,0,.22);
  --text: #111110; --muted: #6a6a6f;
  --shadow: rgba(0,0,0,.12); --color-error: #c0392b;
  --ph-stroke: rgba(0,0,0,.14); --qr-ring: rgba(0,0,0,.08); --logo: #2a2a2a;
}
@media (prefers-color-scheme: dark) { :root {
  --bg: #0e0e0f; --surface: #18181a; --surface-alt: #111113;
  --border: rgba(255,255,255,.08); --border-hi: rgba(255,255,255,.18);
  --text: #f0ede8; --muted: #858589;
  --shadow: rgba(0,0,0,.5); --color-error: #e05252;
  --ph-stroke: rgba(255,255,255,.18); --qr-ring: rgba(255,255,255,.06); --logo: #8eb353;
}}
[data-theme="light"] { color-scheme: light;
  --bg: #f4f2ee; --surface: #fff; --surface-alt: #f0eeea;
  --border: rgba(0,0,0,.09); --border-hi: rgba(0,0,0,.22);
  --text: #111110; --muted: #6a6a6f;
  --shadow: rgba(0,0,0,.12); --color-error: #c0392b;
  --ph-stroke: rgba(0,0,0,.14); --qr-ring: rgba(0,0,0,.08); --logo: #2a2a2a;
}
[data-theme="dark"] { color-scheme: dark;
  --bg: #0e0e0f; --surface: #18181a; --surface-alt: #111113;
  --border: rgba(255,255,255,.08); --border-hi: rgba(255,255,255,.18);
  --text: #f0ede8; --muted: #858589;
  --shadow: rgba(0,0,0,.5); --color-error: #e05252;
  --ph-stroke: rgba(255,255,255,.18); --qr-ring: rgba(255,255,255,.06); --logo: #8eb353;
}

/* ── Base ── */
body {
  background: var(--bg); color: var(--text); font-family: 'DM Sans', sans-serif;
  min-height: 100vh; display: flex; flex-direction: column; align-items: center;
  padding: 1.5rem 1rem 3rem;
  transition: background var(--t) var(--ease), color var(--t) var(--ease);
}
.hidden { display: none !important; }

/* ── Topbar ── */
.topbar {
  width: 100%; max-width: 860px;
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 1.25rem; padding: 0 4px;
}
.logo { font-family: 'DM Mono', monospace; font-size: 11px; letter-spacing: .15em; text-transform: uppercase; color: var(--logo); transition: color var(--t); }
.logo svg { display: inline-block; vertical-align: middle; margin-right: 7px; }
.topbar-controls { display: flex; align-items: center; gap: 8px; }

/* ── Theme pill ── */
.theme-switcher {
  position: relative; display: flex; gap: 2px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 999px; padding: 3px; transition: background var(--t), border-color var(--t);
}
.theme-indicator {
  position: absolute; top: 3px; bottom: 3px; border-radius: 999px;
  background: var(--bg); pointer-events: none;
  transition: transform .28s var(--ease), width .28s var(--ease), background var(--t);
}
.theme-opt {
  position: relative; z-index: 1; display: flex; align-items: center; gap: 5px;
  padding: 5px 11px; border: none; border-radius: 999px; background: none; cursor: pointer;
  font-family: 'DM Mono', monospace; font-size: 11px; letter-spacing: .05em;
  color: var(--muted); white-space: nowrap; touch-action: manipulation;
  transition: color .22s var(--ease);
}
.theme-opt.active, .theme-opt:hover { color: var(--text); }
.theme-opt-icon { font-size: 11px; line-height: 1; }

/* ── Share button ── */
.share-btn {
  display: flex; align-items: center; gap: 5px;
  padding: 8px 11px; border: 1px solid var(--border); border-radius: 999px;
  background: var(--surface); cursor: pointer;
  font-family: 'DM Mono', monospace; font-size: 11px; letter-spacing: .05em;
  color: var(--muted); white-space: nowrap; touch-action: manipulation;
  transition: color .22s var(--ease), border-color .18s, background var(--t);
}
.share-btn:hover { color: var(--text); border-color: var(--border-hi); }
.share-btn-icon { font-size: 11px; line-height: 1; }
@media (max-width: 640px) { .share-btn-label { display: none; } .share-btn { padding: 9px 10px; } }

/* ── Card ── */
.wrap {
  width: 100%; max-width: 860px; display: grid; grid-template-columns: 1fr 1fr;
  gap: 2px; background: var(--border); border-radius: 20px; overflow: hidden;
  box-shadow: 0 32px 64px var(--shadow); transition: box-shadow var(--t);
  animation: fadeUp .4s var(--ease) both;
}
@keyframes fadeUp { from { opacity:0; transform:translateY(16px); } to { opacity:1; transform:none; } }
.panel { background: var(--surface); padding: 2rem; transition: background var(--t); }
.panel-right {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  min-height: 400px; position: relative; background: var(--surface-alt); transition: background var(--t);
}

/* ── Typography ── */
header { margin-bottom: 1.75rem; }
h1 { font-size: 26px; font-weight: 300; line-height: 1.2; }
h1 strong { font-weight: 500; }
.lbl { display: block; font-size: 11px; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); margin-bottom: 7px; font-family: 'DM Mono', monospace; transition: color var(--t); }
.field { margin-bottom: 1.1rem; }

/* ── Form controls ── */
textarea, select, input[type="text"], input[type="password"] {
  width: 100%; background: var(--bg); border: 1px solid var(--border);
  border-radius: var(--radius); color: var(--text); font-family: 'DM Sans', sans-serif;
  font-size: 15px; padding: 11px 13px; outline: none; resize: none; -webkit-appearance: none;
  transition: border-color .18s, background var(--t), color var(--t);
}
textarea { height: 84px; }
textarea:focus, select:focus, input:focus { border-color: var(--accent); }
select {
  appearance: none; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%236b6b70' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 13px center;
}
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

/* ── Validation ── */
.error-msg { font-size: 11px; color: var(--color-error); font-family: 'DM Mono', monospace; margin-top: 5px; display: none; }
.error-msg.visible { display: block; }
@keyframes shake { 0%,100%{transform:none;} 20%,60%{transform:translateX(-5px);} 40%,80%{transform:translateX(5px);} }
.shake { animation: shake .32s var(--ease); border-color: var(--color-error) !important; }

/* ── Tabs ── */
.tabs {
  position: relative; display: flex; gap: 2px;
  background: var(--bg); border-radius: var(--radius);
  padding: 3px; margin-bottom: 1.1rem; transition: background var(--t);
}
.tab-indicator {
  position: absolute; top: 3px; bottom: 3px; width: calc(25% - 2px);
  background: var(--surface); border-radius: 9px; pointer-events: none;
  transition: transform .28s var(--ease), background var(--t);
}
.tab {
  flex: 1; position: relative; z-index: 1; padding: 8px 2px;
  border: none; border-radius: 9px; background: none;
  color: var(--muted); font-size: 12px; font-family: 'DM Sans', sans-serif;
  cursor: pointer; touch-action: manipulation; transition: color .22s var(--ease);
}
.tab.active { color: var(--text); }
.tab-content { display: none; }
.tab-content.active { display: block; animation: tabFade .2s var(--ease) both; }
@keyframes tabFade { from{opacity:0;transform:translateY(4px);} to{opacity:1;transform:none;} }

/* ── Slider ── */
.slider-wrap { display: flex; align-items: center; gap: 10px; }
input[type="range"] { flex: 1; cursor: pointer; -webkit-appearance: none; appearance: none; height: 4px; border-radius: 999px; outline: none; }
input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; width: 16px; height: 16px; border-radius: 50%; background: var(--accent); cursor: pointer; }
input[type="range"]::-moz-range-track { height: 4px; border-radius: 999px; }
input[type="range"]::-moz-range-thumb { width: 16px; height: 16px; border-radius: 50%; background: var(--accent); border: none; cursor: pointer; }
input[type="range"]::-moz-range-progress { background: var(--accent); height: 4px; border-radius: 999px; }

/* ── Colors ── */
.color-section { display: grid; grid-template-columns: 1fr 26px 1fr; gap: 8px; align-items: start; }
.color-col { display: flex; flex-direction: column; gap: 0; }
.swap-col { display: flex; align-items: center; justify-content: center; padding-top: 39px; }
.swap-btn {
  display: flex; align-items: center; justify-content: center;
  width: 26px; height: 26px; border: 1px solid var(--border);
  border-radius: 50%; background: var(--bg); cursor: pointer;
  font-size: 13px; color: var(--muted); flex-shrink: 0;
  transition: border-color .18s, color .18s, transform .3s var(--ease), background var(--t);
}
.swap-btn:hover { border-color: var(--border-hi); color: var(--text); }
.swap-btn:active { transform: rotate(180deg); }
.color-custom {
  display: flex; align-items: center; gap: 8px;
  background: var(--bg); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 8px 12px; cursor: pointer;
  transition: border-color .18s, background var(--t);
}
.color-custom:hover { border-color: var(--border-hi); }
input[type="color"] { width: 20px; height: 20px; border: none; outline: none; background: none; cursor: pointer; padding: 0; border-radius: 50%; }
.color-hex-input {
  font-family: 'DM Mono', monospace; font-size: 12px; color: var(--muted);
  letter-spacing: .04em; background: none; border: none; outline: none;
  padding: 0; width: 6ch; cursor: text; flex: 1;
  transition: color .18s, background var(--t);
}
.color-hex-input:focus { color: var(--text); }
.swatches { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 7px; }
.swatch {
  position: relative; width: 22px; height: 22px; border-radius: 50%;
  border: 2px solid transparent; cursor: pointer; flex-shrink: 0;
.swatch:focus:not(:focus-visible) { outline: none; }
  transition: transform .15s var(--ease), border-color .15s;
}
.swatch:hover { transform: scale(1.18); }
.swatch.active { border-color: var(--accent); }
.swatch::after {
  content: attr(data-name); position: absolute; bottom: calc(100% + 6px); left: 50%;
  transform: translateX(-50%) scale(.9);
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 6px; padding: 3px 8px;
  font-family: 'DM Mono', monospace; font-size: 10px; color: var(--text);
  white-space: nowrap; pointer-events: none; opacity: 0;
  transition: opacity .15s, transform .15s var(--ease);
}
.swatch:hover::after, .swatch:focus-visible::after { opacity: 1; transform: translateX(-50%) scale(1); }

/* ── Password toggle ── */
.pass-wrap { position: relative; }
.pass-wrap input { padding-right: 2.5rem; }
.pass-toggle {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  background: none; border: none; cursor: pointer; font-size: 14px;
  color: var(--muted); padding: 8px; line-height: 1; transition: color .18s;
  min-width: 44px; min-height: 44px; display: flex; align-items: center; justify-content: center;
}
.pass-toggle:hover { color: var(--text); }
.logo-pick {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 13px; border: 1px dashed var(--border);
  border-radius: var(--radius); cursor: pointer; color: var(--muted);
  font-size: 13px; transition: border-color .18s, color .18s;
  user-select: none;
}
.logo-pick:hover { border-color: var(--accent); color: var(--text); }
.logo-pick.drag-over { border-color: var(--accent); color: var(--text); background: var(--accent-dim); }
.logo-pick-icon { font-size: 15px; }
.logo-preview-row {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px; border: 1px solid var(--border);
  border-radius: var(--radius); background: var(--bg); transition: background var(--t), border-color var(--t);
}
.logo-thumb { width: 28px; height: 28px; object-fit: contain; border-radius: 4px; }
.logo-name { font-size: 12px; color: var(--muted); flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-family: 'DM Mono', monospace; }
.logo-remove-btn {
  font-size: 11px; letter-spacing: .06em; text-transform: uppercase;
  color: var(--muted); border: none; background: none; cursor: pointer;
  font-family: 'DM Mono', monospace; flex-shrink: 0; transition: color .18s;
}
.logo-remove-btn:hover { color: var(--color-error); }

/* ── Generate button ── */
.gen-btn {
  width: 100%; padding: 14px; background: var(--accent); color: #0e0e0f;
  border: none; border-radius: var(--radius);
  font-family: 'DM Mono', monospace; font-size: 13px; font-weight: 500;
  letter-spacing: .08em; text-transform: uppercase;
  cursor: pointer; margin-top: .4rem; touch-action: manipulation;
  transition: opacity .18s, transform .12s var(--ease), box-shadow .18s;
}
.gen-btn:hover  { opacity: .88; box-shadow: 0 4px 20px rgba(142,179,83,.3); }
.gen-btn:active { transform: scale(.98); }

/* ── Preview panel ── */
.dot-grid {
  position: absolute; inset: 0; pointer-events: none;
  background-image: radial-gradient(circle, var(--ph-stroke) 1px, transparent 1px);
  background-size: 24px 24px;
}
.qr-placeholder {
  display: flex; flex-direction: column; align-items: center;
  gap: 16px; position: relative; z-index: 1; padding: 2rem; text-align: center;
}
.qr-icon { width: 56px; height: 56px; opacity: .22; animation: phPulse 3s var(--ease) infinite; }
@keyframes phPulse { 0%,100%{opacity:.22;} 50%{opacity:.38;} }
.placeholder-title { font-size: 14px; font-weight: 500; color: var(--text); opacity: .5; }
.placeholder-sub { font-size: 12px; font-family: 'DM Mono', monospace; letter-spacing: .05em; color: var(--muted); }

#qr-output {
  display: none; flex-direction: column; align-items: center;
  gap: 1.25rem; width: 100%; padding: 2rem; position: relative; z-index: 1;
}
#qr-output.visible { display: flex; animation: qrReveal .3s var(--ease) both; }
@keyframes qrReveal { from{opacity:0;transform:scale(.94);} to{opacity:1;transform:none;} }
#qr-canvas-wrap { border-radius: 14px; overflow: hidden; box-shadow: 0 0 0 1px var(--qr-ring); max-width: 100%; }
#qr-canvas-wrap canvas, #qr-canvas-wrap img { display: block; max-width: 100%; height: auto; }
.qr-meta { font-family: 'DM Mono', monospace; font-size: 11px; color: var(--muted); letter-spacing: .04em; text-align: center; }
.action-btns { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; width: 100%; }
.action-btn {
  padding: 10px 8px; background: var(--accent); border: 1px solid var(--accent);
  border-radius: var(--radius); color: #0e0e0f; font-family: 'DM Mono', monospace;
  font-size: 11px; letter-spacing: .07em; text-transform: uppercase;
  cursor: pointer; touch-action: manipulation; transition: opacity .18s, transform .1s;
}
.action-btn:hover  { opacity: .88; }
.action-btn:active { transform: scale(.97); }

/* ── Toast ── */
.toast {
  position: fixed; bottom: 2rem; left: 50%; transform: translateX(-50%) translateY(8px);
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 10px 20px;
  font-family: 'DM Mono', monospace; font-size: 12px; color: var(--text);
  box-shadow: 0 8px 32px var(--shadow); opacity: 0; pointer-events: none; z-index: 100;
  transition: opacity .2s, transform .2s var(--ease);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ── History ── */
.history-wrap { width: 100%; max-width: 860px; margin-top: 1.5rem; padding: 0 4px; display: none; }
.history-wrap.visible { display: block; }
.history-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: .75rem; }
.history-header .lbl { margin-bottom: 0; }
.history-clear-btn {
  font-family: 'DM Mono', monospace; font-size: 10px; letter-spacing: .08em;
  text-transform: uppercase; color: var(--muted); border: none; background: none;
  cursor: pointer; transition: color .18s;
}
.history-clear-btn:hover { color: var(--color-error); }
.history-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; padding-bottom: 4px; }
.history-list { display: flex; gap: 8px; }
.history-item {
  position: relative; flex-shrink: 0; width: 72px; cursor: pointer;
  border: 2px solid var(--border); border-radius: 10px; overflow: hidden;
  transition: border-color .15s; background: var(--surface);
}
.history-item:hover { border-color: var(--accent); }
.history-item img { display: block; width: 68px; height: 68px; object-fit: contain; }
.history-item-label {
  display: block; font-family: 'DM Mono', monospace; font-size: 9px; text-align: center;
  padding: 3px 2px; color: var(--muted); background: var(--surface);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  transition: background var(--t), color var(--t);
}
.history-del {
  position: absolute; top: 3px; right: 3px; width: 16px; height: 16px;
  border-radius: 50%; border: none; background: rgba(0,0,0,.55); color: #fff;
  font-size: 10px; cursor: pointer; display: flex; align-items: center; justify-content: center;
  opacity: 0; transition: opacity .15s; padding: 0; line-height: 1;
}
.history-item:hover .history-del { opacity: 1; }

/* ── Footer ── */
.footer { width: 100%; max-width: 860px; display: flex; justify-content: space-between; align-items: center; margin-top: 2rem; padding: 0 4px; }
.footer a { font-family: 'DM Mono', monospace; font-size: 10px; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); text-decoration: none; transition: color .18s; }
.footer a:hover { color: var(--text); }

/* ── Mobile ── */
@media (max-width: 640px) {
  body { padding: 1rem .75rem 2.5rem; }
  .topbar { margin-bottom: 1rem; flex-wrap: wrap; gap: 10px; }
  .topbar-controls { margin-left: auto; }
  .wrap { grid-template-columns: 1fr; border-radius: 16px; }
  .panel { padding: 1.5rem 1.25rem; }
  .panel-right { min-height: auto; order: -1; }
  h1 { font-size: 22px; }
  header { margin-bottom: 1.25rem; }
  .row { grid-template-columns: 1fr; gap: 0; }
  #qr-output { padding: 1.5rem 1.25rem; }
  #qr-canvas-wrap canvas, #qr-canvas-wrap img { width: 100% !important; height: auto !important; }
  /* gen-btn dark text */ .gen-btn { font-size: 14px; padding: 15px; }
  .theme-opt-label { display: none; }
  .theme-opt.active .theme-opt-label { display: inline; }
  .theme-opt { padding: 6px 10px; }
  .tab { font-size: 11px; }
}