:root {
  color-scheme: light;
  --page: #f5f6f8;
  --panel: #ffffff;
  --ink: #111827;
  --muted: #64748b;
  --line: #dbe1e8;
  --accent: #1d4ed8;
  --accent-hover: #1e40af;
  --danger: #b91c1c;
  --shadow: 0 8px 28px rgba(15, 23, 42, 0.07);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

body {
  min-height: 100vh;
  margin: 0;
  background: var(--page);
  color: var(--ink);
}

button, input, select, textarea { font: inherit; }
button, summary, input[type="color"] { cursor: pointer; }

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: min(1100px, calc(100% - 40px));
  margin: 0 auto;
  padding: 22px 0;
  border-bottom: 1px solid var(--line);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: inherit;
  font-weight: 750;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border-radius: 9px;
  background: var(--ink);
  color: white;
  font-size: 1.25rem;
}

.github-link, footer a {
  color: var(--accent);
  font-weight: 650;
}

.page-shell {
  width: min(1100px, calc(100% - 40px));
  margin: 26px auto 0;
}

.intro {
  margin-bottom: 22px;
}

h1 {
  margin: 0;
  font-size: clamp(1.75rem, 4vw, 2.35rem);
  line-height: 1.15;
  letter-spacing: -0.035em;
}

.intro p {
  max-width: 720px;
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 0.98rem;
  line-height: 1.55;
}

.generator {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(360px, 0.95fr);
  gap: 22px;
  align-items: start;
}

.panel {
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.controls-panel, .preview-panel {
  padding: clamp(20px, 3vw, 30px);
}

.field-group, .content-fields, .appearance-options {
  margin-bottom: 22px;
}

.field-label {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #f8fafc;
}

.tab {
  min-height: 42px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-weight: 700;
}

.tab:hover { color: var(--ink); }

.tab.is-active {
  background: var(--panel);
  color: var(--ink);
  box-shadow: 0 2px 9px rgba(15, 23, 42, 0.08);
}

label {
  display: block;
  margin-bottom: 8px;
  font-size: 0.9rem;
  font-weight: 700;
}

input:not([type="checkbox"]):not([type="color"]), select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  outline: none;
  background: white;
  color: var(--ink);
  transition: border-color 150ms ease, box-shadow 150ms ease;
}

input:not([type="checkbox"]):not([type="color"]), select {
  min-height: 46px;
  padding: 0 13px;
}

textarea {
  min-height: 110px;
  padding: 13px;
  resize: vertical;
  line-height: 1.5;
}

input:focus, select:focus, textarea:focus, button:focus-visible, summary:focus-visible {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(29, 78, 216, 0.14);
}

.field-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-top: 16px;
}

.content-fields > label:not(:first-child) { margin-top: 16px; }
.optional { color: var(--muted); font-weight: 500; }

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-top: 16px;
  font-weight: 600;
}

.checkbox-label input {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
}

.appearance-options {
  border: 1px solid var(--line);
  border-radius: 12px;
}

.appearance-options summary {
  padding: 14px 15px;
  font-weight: 700;
}

.details-body { padding: 0 15px 17px; }

.color-row label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 46px;
  margin: 0;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
}

input[type="color"] {
  width: 38px;
  height: 30px;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: transparent;
}

.form-error {
  margin: -7px 0 14px;
  color: var(--danger);
  font-weight: 650;
}

.primary-button, .secondary-button {
  min-height: 46px;
  border-radius: 10px;
  font-weight: 750;
  transition: transform 120ms ease, background 120ms ease, opacity 120ms ease;
}

.primary-button:active, .secondary-button:active { transform: translateY(1px); }

.primary-button {
  width: 100%;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: white;
}

.primary-button:hover { background: var(--accent-hover); }
.preview-panel { position: sticky; top: 18px; }

.preview-heading {
  display: flex;
  align-items: start;
  justify-content: space-between;
}

.status-message {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.qr-stage {
  display: grid;
  width: 100%;
  min-height: 390px;
  margin: 20px 0;
  padding: 24px;
  place-items: center;
  border: 1px dashed #cbd5e1;
  border-radius: 14px;
  background: #f8fafc;
}

.qr-preview {
  display: grid;
  width: 100%;
  max-width: 390px;
  place-items: center;
}

.qr-preview svg {
  display: block;
  width: 100%;
  max-width: 100%;
  height: auto;
  background: white;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.10);
}

.preview-placeholder {
  margin: 0;
  color: var(--muted);
  text-align: center;
}

#qr-canvas[hidden] { display: none; }

.download-actions {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.secondary-button {
  border: 1px solid var(--line);
  background: white;
  color: var(--ink);
}

.secondary-button:hover:not(:disabled) { background: #f8fafc; }
.secondary-button:disabled { cursor: not-allowed; opacity: 0.45; }

.scan-note {
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.5;
}

footer {
  width: min(1100px, calc(100% - 40px));
  margin: 38px auto 0;
  padding: 20px 0 34px;
  color: var(--muted);
  font-size: 0.83rem;
}

@media (max-width: 860px) {
  .generator { grid-template-columns: 1fr; }
  .preview-panel { position: static; }
  .qr-stage { min-height: 340px; }
}

@media (max-width: 560px) {
  .site-header, .page-shell, footer {
    width: min(100% - 24px, 1100px);
  }

  .site-header { padding: 16px 0; }
  .brand { font-size: 0.92rem; }
  .github-link { font-size: 0.84rem; }
  .panel { border-radius: 13px; }
  .controls-panel, .preview-panel { padding: 18px; }
  .tabs, .field-row, .download-actions { grid-template-columns: 1fr; }
  .tab { min-height: 38px; }
  .qr-stage { min-height: 280px; padding: 16px; }
}

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