:root {
  color-scheme: light;
  --bg: #f5f7fb;
  --surface: #ffffff;
  --surface-subtle: #f8fafc;
  --text: #0f172a;
  --muted: #64748b;
  --border: #dbe3ee;
  --border-strong: #cbd5e1;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --danger: #b91c1c;
  --shadow: 0 24px 70px rgba(15, 23, 42, 0.08);
  --radius-lg: 24px;
  --radius-md: 14px;
}

* { box-sizing: border-box; }
html { min-width: 320px; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

a { color: inherit; }
button, input, textarea, select { font: inherit; }

.site-header {
  min-height: 60px;
  display: flex;
  align-items: center;
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 28px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  text-decoration: none;
  font-size: 1.05rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.brand-mark {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  background: var(--text);
  border-radius: 9px;
}

.brand-mark svg { width: 18px; height: 18px; fill: white; }

.page-shell {
  max-width: 1180px;
  margin: 0 auto;
  padding: 18px 28px 42px;
}

.generator-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(380px, 0.95fr);
  gap: 24px;
  align-items: stretch;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 28px;
}

.panel-heading {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 20px;
  margin-bottom: 26px;
}

.panel-heading h1,
.panel-heading h2 {
  margin: 0;
  font-size: 1.25rem;
  letter-spacing: -0.025em;
}

.step {
  margin: 0 0 8px;
  color: var(--accent);
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.character-count,
.format-badge {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
}

.format-badge {
  color: #166534;
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  border-radius: 999px;
  padding: 5px 9px;
  letter-spacing: 0.04em;
}

.field { margin-top: 20px; }
.field:first-of-type { margin-top: 0; }

.field label {
  display: block;
  margin-bottom: 7px;
  color: #334155;
  font-size: 0.88rem;
  font-weight: 750;
}

textarea, select {
  width: 100%;
  color: var(--text);
  background: var(--surface-subtle);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  outline: none;
  transition: border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

textarea {
  min-height: 138px;
  resize: vertical;
  padding: 14px 15px;
}

select { height: 46px; padding: 0 12px; }

textarea:focus,
select:focus,
input[type="range"]:focus-visible,
input[type="color"]:focus-visible,
button:focus-visible,
a:focus-visible {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.13);
  outline: none;
}

.settings-grid,
.colour-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
}

.range-row {
  min-height: 46px;
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--surface-subtle);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  padding: 0 12px;
}

input[type="range"] { width: 100%; accent-color: var(--accent); }
output { min-width: 48px; color: var(--muted); font-size: 0.78rem; font-variant-numeric: tabular-nums; }

.colour-control {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 46px;
  background: var(--surface-subtle);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  padding: 7px 10px;
}

input[type="color"] {
  width: 34px;
  height: 30px;
  padding: 0;
  background: transparent;
  border: 0;
  cursor: pointer;
}

.colour-control code { color: var(--muted); font-size: 0.82rem; }
.preview-panel { display: flex; flex-direction: column; }

.qr-stage {
  flex: 1;
  min-height: 420px;
  display: grid;
  place-items: center;
  overflow: auto;
  background-color: #f8fafc;
  background-image: linear-gradient(#e2e8f0 1px, transparent 1px), linear-gradient(90deg, #e2e8f0 1px, transparent 1px);
  background-size: 24px 24px;
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 28px;
}

.empty-state {
  max-width: 260px;
  display: grid;
  justify-items: center;
  gap: 6px;
  color: var(--muted);
  text-align: center;
}

.empty-state strong { color: #334155; }
.empty-icon { font-size: 3rem; line-height: 1; color: #94a3b8; }

.qr-preview {
  width: min(var(--preview-size, 360px), 100%);
  max-width: 100%;
  aspect-ratio: 1;
  background: white;
  box-shadow: 0 16px 42px rgba(15, 23, 42, 0.13);
}

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

.qr-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 13px;
}

.qr-meta span {
  color: var(--muted);
  background: var(--surface-subtle);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 4px 9px;
  font-size: 0.72rem;
  font-weight: 650;
}

.actions {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 10px;
  margin-top: 20px;
}

.button {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: 12px;
  padding: 0 16px;
  border: 1px solid transparent;
  font-weight: 750;
  cursor: pointer;
  transition: transform 120ms ease, background 120ms ease, border-color 120ms ease;
}

.button:hover:not(:disabled) { transform: translateY(-1px); }
.button:disabled { opacity: 0.45; cursor: not-allowed; }
.button-primary { color: white; background: var(--accent); }
.button-primary:hover:not(:disabled) { background: var(--accent-hover); }
.button-secondary { color: #334155; background: white; border-color: var(--border-strong); }
.button-secondary:hover { background: var(--surface-subtle); }

.status {
  min-height: 20px;
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 0.78rem;
}
.status.error { color: var(--danger); }

.site-footer {
  max-width: 1180px;
  display: flex;
  justify-content: space-between;
  gap: 20px;
  margin: 0 auto;
  padding: 8px 28px 30px;
  color: var(--muted);
  font-size: 0.75rem;
}
.site-footer p { margin: 0; }
.site-footer a:hover { color: var(--text); }

@media (max-width: 900px) {
  .generator-grid { grid-template-columns: 1fr; }
  .preview-panel { min-height: auto; }
  .qr-stage { min-height: 380px; }
}

@media (max-width: 700px) {
  .actions { grid-template-columns: 1fr 1fr; }
  .button-secondary { grid-column: 1 / -1; }
}

@media (max-width: 620px) {
  .site-header { padding: 0 18px; }
  .page-shell { padding: 12px 18px 34px; }
  .panel { padding: 20px; border-radius: 18px; }
  .settings-grid, .colour-grid { grid-template-columns: 1fr; }
  .actions { grid-template-columns: 1fr; }
  .button-secondary { grid-column: auto; }
  .site-footer { flex-direction: column; gap: 4px; padding: 4px 18px 24px; }
}

/* Structured QR content */
[hidden] { display: none !important; }

.content-type-field {
  margin-top: 0;
  margin-bottom: 22px;
}

.structured-form {
  padding-bottom: 4px;
}

.field-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
}

input[type="text"],
input[type="email"],
input[type="tel"],
input[type="url"],
input[type="password"] {
  width: 100%;
  height: 46px;
  padding: 0 12px;
  color: var(--text);
  background: var(--surface-subtle);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  outline: none;
  transition: border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

input[type="text"]:focus,
input[type="email"]:focus,
input[type="tel"]:focus,
input[type="url"]:focus,
input[type="password"]:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.13);
}

.optional {
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 600;
}

.enterprise-fields {
  margin-top: 4px;
}

.check-row {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  margin-top: 18px;
  color: #334155;
  font-size: 0.88rem;
  font-weight: 700;
  cursor: pointer;
}

.check-row input {
  width: 17px;
  height: 17px;
  accent-color: var(--accent);
}

.field-note {
  margin: 9px 0 0;
  color: var(--muted);
  font-size: 0.75rem;
}

.field-note code {
  color: #475569;
  font-size: 0.72rem;
}

.settings-divider {
  margin-top: 24px;
  padding-top: 4px;
  border-top: 1px solid var(--border);
}

@media (max-width: 620px) {
  .field-grid { grid-template-columns: 1fr; gap: 0; }
}
