:root {
  --ink: #444444;
  --ink-strong: #333333;
  --muted: #888888;
  --line: #e1e1e1;
  --soft: #f8f8f8;
  --paper: #ffffff;
  --accent: #ed8421;
  --accent-soft: #fff0e2;
  --focus: #003388;
  --danger: #a53d2d;
  --success: #246b48;
  color: var(--ink);
  font-family: "Open Sans", Helvetica, Arial, sans-serif;
  font-synthesis: none;
}

* { box-sizing: border-box; }

html { background: var(--paper); }

body {
  min-width: 280px;
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: inherit;
  line-height: 1.55;
}

button, input, textarea { font: inherit; }

button { cursor: pointer; }

button:focus-visible,
input:focus-visible,
textarea:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--focus) 28%, transparent);
  outline-offset: 3px;
}

.app {
  width: min(1180px, calc(100% - 48px));
  margin: 0 auto;
  padding: 56px 0 62px;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1.07fr) minmax(360px, 0.93fr);
  gap: clamp(42px, 7vw, 90px);
  align-items: start;
}

.intro { max-width: 610px; }

.eyebrow {
  margin: 0 0 9px;
  color: var(--accent);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.13em;
  line-height: 1.3;
  text-transform: uppercase;
}

h1, h2, h3 { color: var(--ink-strong); letter-spacing: -0.035em; }

h1 {
  max-width: 510px;
  margin: 0;
  font-size: clamp(30px, 4.2vw, 46px);
  font-weight: 600;
  line-height: 1.12;
}

.lead {
  max-width: 560px;
  margin: 16px 0 0;
  color: var(--muted);
  font-size: 15px;
}

#qr-form { margin-top: 42px; }

.field-group {
  min-width: 0;
  margin: 30px 0 0;
  padding: 29px 0 0;
  border: 0;
  border-top: 1px solid var(--line);
}

.field-group legend,
.field > label {
  display: block;
  margin: 0 0 8px;
  padding: 0;
  color: var(--ink-strong);
  font-size: 14px;
  font-weight: 700;
}

.group-help,
.field-help {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.destination-field input {
  width: 100%;
  min-height: 52px;
  margin: 0 0 8px;
  padding: 12px 15px;
  border: 2px solid transparent;
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.04);
  color: var(--ink-strong);
  font-size: 15px;
  transition: border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

.destination-field input:hover { background: rgba(0, 0, 0, 0.055); }

.destination-field input:focus {
  border-color: var(--accent);
  background: var(--paper);
  box-shadow: 0 0 10px rgba(0, 0, 0, 0.11);
  outline: 0;
}

.destination-field input.is-invalid { border-color: var(--danger); }

.field-feedback {
  min-height: 20px;
  margin: 5px 0 0;
  color: var(--success);
  font-size: 12px;
}

.field-feedback.is-error { color: var(--danger); }

.shape-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-top: 16px;
}

.shape-option { position: relative; display: block; }

.shape-option input {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
}

.shape-card {
  display: flex;
  min-height: 105px;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 9px;
  border: 1px solid var(--line);
  background: var(--paper);
  color: var(--muted);
  font-size: 12px;
  text-align: center;
  transition: border-color 150ms ease, background 150ms ease, color 150ms ease, box-shadow 150ms ease;
}

.shape-option:hover .shape-card { border-color: #bcbcbc; color: var(--ink); }
.shape-option input:checked + .shape-card {
  border-color: var(--accent);
  background: var(--accent-soft);
  box-shadow: inset 0 0 0 1px var(--accent);
  color: var(--ink-strong);
  font-weight: 700;
}
.shape-option input:focus-visible + .shape-card { outline: 3px solid color-mix(in srgb, var(--focus) 28%, transparent); outline-offset: 2px; }

.shape-glyph { position: relative; display: block; width: 34px; height: 28px; border: 2px solid currentColor; }
.glyph-circle { width: 30px; height: 30px; border-radius: 50%; }
.glyph-oval { width: 38px; height: 26px; border-radius: 50%; }
.glyph-landscape { width: 44px; height: 24px; }
.glyph-portrait { width: 24px; height: 35px; }
.glyph-triangle { width: 34px; height: 30px; border: 0; background: currentColor; clip-path: polygon(50% 0, 100% 100%, 0 100%); }

.range-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 18px; align-items: center; margin: 16px 0 8px; }

input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
}

.dimension-badge,
#size-output {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 4px 9px;
  border: 1px solid var(--line);
  color: var(--ink-strong);
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
  white-space: nowrap;
}

.colour-row { display: flex; flex-wrap: wrap; gap: 9px; margin-top: 15px; }

.swatch {
  position: relative;
  width: 29px;
  height: 29px;
  margin: 0;
  border: 2px solid transparent;
  border-radius: 50%;
  transition: transform 140ms ease, box-shadow 140ms ease;
}

.swatch:hover { transform: scale(1.08); }
.swatch.is-selected { border-color: var(--paper); box-shadow: 0 0 0 2px var(--ink-strong); }
.swatch-dark { background: #444444; }
.swatch-charcoal { background: #333333; }
.swatch-blue { background: #003388; }
.swatch-orange { background: #ed8421; }
.swatch-black { background: #000000; }
.swatch-white { background: #ffffff; box-shadow: inset 0 0 0 1px #cfcfcf; }
.swatch-soft { background: #f8f8f8; box-shadow: inset 0 0 0 1px #d4d4d4; }
.swatch-line { background: #e1e1e1; }
.swatch-orange-light { background: #fff0e2; box-shadow: inset 0 0 0 1px #efd7c2; }

.custom-colour {
  display: inline-flex;
  min-height: 29px;
  align-items: center;
  gap: 6px;
  padding: 0 0 0 8px;
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 11px;
}

.custom-colour input { width: 30px; height: 27px; padding: 0; border: 0; background: none; cursor: pointer; }

.local-note {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  margin-top: 34px;
  padding-top: 22px;
  border-top: 1px solid var(--line);
}

.local-note p { margin: 0; color: var(--muted); font-size: 12px; }
.note-mark { color: var(--accent); font-weight: 700; line-height: 1.55; }

.preview-panel {
  padding: clamp(22px, 3vw, 34px);
  border: 1px solid var(--line);
  border-top: 3px solid var(--accent);
  background: var(--paper);
}

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

.preview-heading h2 { margin: 0; font-size: 22px; font-weight: 600; line-height: 1.2; }

.preview-stage {
  display: flex;
  min-height: 345px;
  align-items: center;
  justify-content: center;
  margin: 26px 0 0;
  padding: 18px;
  background: var(--soft);
}

.canvas-host {
  display: flex;
  width: 100%;
  align-items: center;
  justify-content: center;
}

#qr-canvas {
  display: block;
  max-width: 100%;
  height: auto;
  image-rendering: pixelated;
}

.shape-status {
  margin: 13px 0 0;
  padding: 8px 10px;
  border-left: 3px solid var(--accent);
  background: var(--accent-soft);
  color: var(--ink-strong);
  font-size: 11px;
  line-height: 1.45;
}

.contrast-status {
  min-height: 20px;
  margin: 9px 0 0;
  color: var(--success);
  font-size: 12px;
}
.contrast-status.is-warning { color: #9b5d00; }
.contrast-status::before { display: inline-block; width: 7px; height: 7px; margin: 0 7px 1px 0; border-radius: 50%; background: currentColor; content: ""; }

.download-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; margin-top: 13px; }

.button {
  min-height: 45px;
  border: 1px solid transparent;
  border-radius: 0;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.01em;
  transition: background 150ms ease, border-color 150ms ease, color 150ms ease;
}

.button-primary { background: var(--accent); color: var(--paper); }
.button-primary:hover { background: #d7781e; }
.button-secondary { border-color: var(--ink-strong); background: var(--paper); color: var(--ink-strong); }
.button-secondary:hover { background: var(--ink-strong); color: var(--paper); }
.button:disabled, .copy-button:disabled { cursor: not-allowed; opacity: 0.45; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 850px) {
  .workspace { grid-template-columns: 1fr; gap: 38px; }
  .preview-panel { order: -1; }
}

@media (max-width: 560px) {
  .app { width: min(100% - 28px, 1180px); padding-top: 34px; }
  .shape-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .shape-card { min-height: 93px; }
  .preview-panel { padding: 20px; }
  .preview-stage { min-height: 270px; padding: 12px; }
  .preview-heading { flex-direction: column; }
  .dimension-badge { align-self: flex-start; }
  .download-actions { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; }
}
