/* Colours are tokens, so light and dark share every rule below. The default follows the system;
   the page's theme toggle sets data-theme and overrides it. */
:root {
  color-scheme: light;
  --paper: #f5f4ee;
  --paper-2: #f0efe8;
  --surface: #fffefa;
  --surface-2: #fafaf6;
  --ink: #17241f;
  --ink-2: #29372f;
  --muted: #68716b;
  --muted-2: #879087;
  --body: #5c6860;
  --dim: #84937e;
  --green: #c9ef5b;
  --green-hover: #bce34d;
  --accent: #6b9012;
  --accent-ink: #4f6f12;
  --line: #dedfd6;
  --line-strong: #cbd1c7;
  --dots: #d5d9cd;
  --art-paper: #f2f2eb;
  --code-bg: var(--ink);
  --code-ink: #e9f2d8;
  --ok-ink: #3b5a10;
  --ok-bg: #e1efc0;
  --bad-ink: #9b3527;
  --bad-bg: #f7dfd9;
  --error: #b34132;
  --focus: #6c8c20;
  --mono: 'Cascadia Mono', 'SFMono-Regular', Consolas, monospace;
  --sans: 'Segoe UI', Arial, sans-serif;
  --display: 'Segoe UI', Arial, sans-serif;
}
:root[data-theme='dark'] {
  color-scheme: dark;
  --paper: #0f1714;
  --paper-2: #131d19;
  --surface: #162019;
  --surface-2: #1b2821;
  --ink: #e7efe6;
  --ink-2: #d5e0d1;
  --muted: #9aa89e;
  --muted-2: #7f8d82;
  --body: #b3c0b5;
  --dim: #8c9a8d;
  --green: #c9ef5b;
  --green-hover: #d8f77a;
  --accent: #b7e04d;
  --accent-ink: #cdeb7a;
  --line: #2a3a32;
  --line-strong: #3a4d43;
  --dots: #2e3f36;
  --art-paper: #111a16;
  --code-bg: #0a100d;
  --code-ink: #cdeb7a;
  --ok-ink: #d6f0a0;
  --ok-bg: #2a3d1c;
  --bad-ink: #f3b7aa;
  --bad-bg: #4a2a24;
  --error: #f08f7f;
  --focus: #b7e04d;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    color-scheme: dark;
    --paper: #0f1714;
    --paper-2: #131d19;
    --surface: #162019;
    --surface-2: #1b2821;
    --ink: #e7efe6;
    --ink-2: #d5e0d1;
    --muted: #9aa89e;
    --muted-2: #7f8d82;
    --body: #b3c0b5;
    --dim: #8c9a8d;
    --green-hover: #d8f77a;
    --accent: #b7e04d;
    --accent-ink: #cdeb7a;
    --line: #2a3a32;
    --line-strong: #3a4d43;
    --dots: #2e3f36;
    --art-paper: #111a16;
    --code-bg: #0a100d;
    --code-ink: #cdeb7a;
    --ok-ink: #d6f0a0;
    --ok-bg: #2a3d1c;
    --bad-ink: #f3b7aa;
    --bad-bg: #4a2a24;
    --error: #f08f7f;
    --focus: #b7e04d;
  }
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 85px; }
body { margin: 0; background: var(--paper); color: var(--ink); font-family: var(--sans); }
a { color: inherit; text-decoration: none; }
button, select, textarea { font: inherit; }
button, a, select, label { -webkit-tap-highlight-color: transparent; }
button:focus-visible, a:focus-visible, select:focus-visible, textarea:focus-visible, .upload-button:focus-within { outline: 3px solid var(--focus); outline-offset: 3px; }

.topbar { height: 76px; padding: 0 7.3%; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); }
.wordmark { display: inline-flex; align-items: center; gap: 10px; font: 700 19px var(--display); letter-spacing: -.8px; }
.wordmark-dot { color: var(--accent); }
.mark { width: 25px; height: 25px; display: grid; grid-template-columns: repeat(2, 1fr); gap: 3px; transform: rotate(-7deg); }
.mark i { display: block; background: var(--ink); }
.mark i:nth-child(2) { border-radius: 0 7px 0 0; }
.mark i:nth-child(3) { border-radius: 0 0 0 7px; background: var(--accent); }
.topbar nav { display: flex; align-items: center; gap: 34px; font-size: 13px; font-weight: 600; }
.topbar nav a { transition: color .18s ease; }
.topbar nav a:hover, footer a:hover { color: var(--accent); }
.topbar .source-link { padding: 10px 14px; border: 1px solid var(--line); border-radius: 5px; }

main { overflow: clip; } /* clip, not hidden: hidden would stop the Studio preview sticking */
.hero { position: relative; min-height: 570px; padding: 104px 10% 76px; display: grid; grid-template-columns: 1.05fr .95fr; align-items: center; gap: 6%; }
.eyebrow { margin: 0 0 19px; color: var(--body); font: 500 10px var(--mono); letter-spacing: 1.5px; }
.live-dot { display: inline-block; width: 7px; height: 7px; margin-right: 7px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 3px var(--ok-bg); }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 20px; font: 600 clamp(54px, 6.1vw, 82px)/.99 var(--display); letter-spacing: -5.7px; }
h1 span { color: var(--dim); }
.hero-text { max-width: 470px; margin-bottom: 30px; color: var(--body); font-size: 16px; line-height: 1.75; }
.hero-actions { display: flex; align-items: center; gap: 24px; }
.button { min-height: 46px; padding: 0 18px; border: 0; border-radius: 4px; display: inline-flex; align-items: center; justify-content: center; gap: 22px; cursor: pointer; font-size: 12px; font-weight: 700; transition: transform .18s ease, background .18s ease; }
.button:hover, .upload-button:hover { transform: translateY(-2px); }
.button-dark { color: var(--paper); background: var(--ink); }
.button-dark:hover { background: var(--ink-2); }
.text-link { font-size: 12px; font-weight: 700; }
.text-link span { margin-left: 6px; color: var(--accent); }
.hero-proof { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 48px; }
.hero-proof span { padding: 7px 9px; border: 1px solid var(--line); border-radius: 3px; color: var(--body); font: 9px var(--mono); letter-spacing: .5px; }
.hero-proof span:last-child { color: var(--ok-ink); background: var(--ok-bg); border-color: var(--ok-bg); }

.hero-art { position: relative; height: 375px; max-width: 480px; width: 100%; justify-self: end; }
.art-card { position: absolute; padding: 16px; border: 1px solid var(--line); border-radius: 7px; background: var(--surface); box-shadow: 0 18px 50px #273a2514; }
/* Cards size to their code: a call-to-action band or a caption makes a code taller. */
.art-qr { z-index: 1; top: 5px; left: 9%; width: 225px; padding-bottom: 18px; transform: rotate(-7deg); }
.art-caption { color: var(--muted-2); font: 9px var(--mono); letter-spacing: 1px; }
.art-bar { z-index: 2; top: 200px; right: 0; width: 250px; padding-bottom: 14px; transform: rotate(5deg); }
.bar-label { display: block; color: var(--muted-2); font: 9px var(--mono); }

.feature-strip { padding: 25px 10%; display: grid; grid-template-columns: repeat(3, 1fr); gap: 26px; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); background: var(--paper-2); }
.feature-strip > div { display: grid; grid-template-columns: 32px 1fr; align-items: center; row-gap: 3px; }
.feature-number { grid-row: span 2; color: var(--accent); font: 10px var(--mono); }
.feature-strip strong { font-size: 12px; }
.feature-strip div > span:last-child { color: var(--muted); font-size: 10px; }

.tool-section { padding: 94px 10% 40px; }
.section-heading { margin-bottom: 27px; display: flex; align-items: end; justify-content: space-between; gap: 32px; }
.section-heading .eyebrow { margin-bottom: 11px; }
h2 { margin-bottom: 0; font: 600 clamp(27px, 3.4vw, 40px)/1.1 var(--display); letter-spacing: -1.7px; }
.section-heading > p { max-width: 335px; margin-bottom: 2px; color: var(--muted); font-size: 12px; line-height: 1.7; }
.tool-card { display: grid; grid-template-columns: .8fr 1.2fr; min-height: 330px; overflow: clip; border: 1px solid var(--line); border-radius: 7px; background: var(--surface); }
.tool-controls { padding: 29px; }
.field-label, .preview-top, .preview-bottom, .result-label { color: var(--muted); font: 9px var(--mono); letter-spacing: 1px; }
.tool-controls select, .tool-controls textarea { width: 100%; padding: 12px; border: 1px solid var(--line); border-radius: 4px; color: var(--ink); background: var(--surface-2); font-size: 13px; }
.tool-controls select { margin: 10px 0 23px; }
.tool-controls textarea { min-height: 87px; margin-top: 10px; resize: vertical; line-height: 1.5; }
.field-hint { margin: 9px 0 15px; color: var(--muted-2); font-size: 10px; line-height: 1.5; }
.input-label { display: block; }
/* Green buttons keep dark text in both themes: the green is the same, so the contrast holds. */
.button-green { width: 100%; justify-content: space-between; color: #17241f; background: var(--green); }
.button-green:hover { background: var(--green-hover); }
.button-green:disabled, .download-button:disabled { opacity: .48; cursor: not-allowed; transform: none; }
.error-message { margin: 8px 0 13px; color: var(--error); font-size: 11px; line-height: 1.45; }
.preview-panel { min-width: 0; min-height: 330px; padding: 22px 24px 17px; display: flex; flex-direction: column; justify-content: space-between; background-color: var(--art-paper); background-image: radial-gradient(var(--dots) .7px, transparent .7px); background-size: 15px 15px; }
.preview-top, .preview-bottom { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.preview-top span:last-child { color: var(--muted-2); }
.preview { min-height: 220px; padding: 16px; display: flex; align-items: center; justify-content: center; }
.preview svg { display: block; max-width: 100%; max-height: 230px; width: auto; height: auto; background: white; box-shadow: 0 6px 22px #202d1d14; }
.preview .loading { color: var(--muted-2); font-size: 12px; }
.preview-bottom { color: var(--muted-2); font-size: 9px; letter-spacing: 0; }
.download-button, .copy-button { padding: 8px 10px; border: 1px solid var(--line-strong); border-radius: 4px; color: var(--ink-2); background: var(--surface); cursor: pointer; font-size: 10px; font-weight: 700; }
.download-button:hover, .copy-button:hover { border-color: var(--accent); }
.download-group { display: inline-flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }

.scan-section { padding-top: 70px; }
.scanner { grid-template-columns: .74fr 1.26fr; }
.scan-actions { padding: 30px; }
.upload-button { min-height: 46px; padding: 0 15px; display: flex; align-items: center; justify-content: center; gap: 12px; border: 1px dashed var(--line-strong); border-radius: 4px; color: var(--ink-2); cursor: pointer; font-size: 12px; font-weight: 700; transition: transform .18s ease, border-color .18s ease; }
.upload-button:hover { border-color: var(--accent); }
.upload-button span { font-size: 17px; }
.button-outline { width: 100%; margin-top: 12px; justify-content: space-between; border: 1px solid var(--line-strong); background: transparent; }
.button-outline:hover { background: var(--surface-2); }
.scan-actions .field-hint { margin-top: 20px; }
.scan-preview { position: relative; min-height: 280px; overflow: hidden; display: flex; align-items: center; justify-content: center; background: var(--art-paper); }
.scan-preview video, .scan-preview canvas { max-width: 100%; max-height: 330px; object-fit: contain; }
.scan-preview video:not([hidden]), .scan-preview canvas:not([hidden]) { display: block; }
.scan-empty { position: absolute; display: flex; flex-direction: column; align-items: center; color: var(--muted-2); pointer-events: none; }
.scan-empty[hidden] { display: none; }
.scan-empty p { margin: 13px 0 0; font-size: 11px; }
.scan-frame { position: relative; width: 64px; height: 64px; display: grid; place-items: center; color: var(--accent); font: 28px var(--sans); }
.scan-frame span { position: absolute; width: 18px; height: 18px; border-color: var(--accent); border-style: solid; }
.scan-frame span:nth-child(1) { top: 0; left: 0; border-width: 2px 0 0 2px; }
.scan-frame span:nth-child(2) { top: 0; right: 0; border-width: 2px 2px 0 0; }
.scan-frame span:nth-child(3) { bottom: 0; left: 0; border-width: 0 0 2px 2px; }
.scan-frame span:nth-child(4) { bottom: 0; right: 0; border-width: 0 2px 2px 0; }
.scan-status { position: absolute; right: 12px; bottom: 10px; left: 12px; color: var(--muted); text-align: center; font-size: 10px; pointer-events: none; }
.scan-result { z-index: 1; width: min(85%, 410px); max-height: 75%; padding: 19px; overflow: auto; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); box-shadow: 0 8px 30px var(--ink)16; }
.scan-result[hidden] { display: none; }
.result-label { color: var(--accent); }
.scan-result p { margin: 12px 0; overflow-wrap: anywhere; color: var(--ink); font: 13px/1.6 var(--mono); white-space: pre-wrap; }
.copy-button { background: var(--surface-2); }
.styler .tool-controls input[type="text"] { width: 100%; margin-top: 10px; padding: 12px; border: 1px solid var(--line); border-radius: 4px; color: var(--ink); background: var(--surface-2); font-size: 13px; }
.styler .tool-controls select { margin: 8px 0 0; padding: 10px; font-size: 12px; }
.styler .tool-controls #format { margin: 10px 0 18px; padding: 12px; font-size: 13px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 15px; }
.field-row[hidden] { display: none; }
.field-row > .field-label { display: block; }
.colour-row { grid-template-columns: repeat(3, 1fr); }
.colour-row input[type="color"] { display: block; width: 100%; height: 36px; margin-top: 8px; padding: 2px; border: 1px solid var(--line); border-radius: 4px; background: var(--surface-2); cursor: pointer; }
.field-row input[type="range"] { display: block; width: 100%; margin-top: 14px; accent-color: var(--focus); }
.style-upload { margin-bottom: 12px; }
.text-button { margin: -4px 0 12px; padding: 0; border: 0; color: var(--muted); background: none; cursor: pointer; font-size: 10px; text-decoration: underline; }
.text-button[hidden] { display: none; }
.optional { color: var(--muted-2); letter-spacing: 0; }
.style-group { min-width: 0; margin: 0; padding: 14px 0 0; border: 0; border-top: 1px solid var(--line); }
.style-group[hidden] { display: none; }
.ai-panel { margin: 0 0 16px; padding: 12px 14px; border: 1px dashed var(--line-strong); border-radius: 5px; background: var(--surface-2); }
.ai-panel > summary { cursor: pointer; color: var(--ink); font-size: 12px; font-weight: 700; }
.ai-panel[open] > summary { margin-bottom: 6px; }
.ai-panel textarea { min-height: 58px; }
.ai-actions { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 10px; }
.ai-actions .text-button { margin: 0; }
.ai-design { width: auto; }
.ai-status { margin: 10px 0 6px; }
.ai-status.is-error { color: var(--error); }
.ai-status:empty { display: none; }
.ai-settings { margin-top: 10px; }
.ai-settings > summary { cursor: pointer; color: var(--muted); font-size: 11px; }
.ai-settings[open] > summary { margin-bottom: 10px; }
.styler .tool-controls input[type="password"] { width: 100%; margin-top: 10px; padding: 12px; border: 1px solid var(--line); border-radius: 4px; color: var(--ink); background: var(--surface-2); font-size: 13px; }
.ai-settings .field-row input[type="text"] { margin-top: 8px; padding: 10px; font-size: 12px; }
.check-label { display: flex; align-items: center; gap: 7px; margin: 10px 0 4px; color: var(--muted); font-size: 11px; cursor: pointer; }
.check-label input { accent-color: var(--focus); }
.input-label { display: block; margin-top: 4px; }
.style-badge { padding: 3px 7px; border-radius: 3px; background: var(--line); }
.style-badge.is-ok { color: var(--ok-ink) !important; background: var(--ok-bg); }
.style-badge.is-bad { color: var(--bad-ink) !important; background: var(--bad-bg); }
.styler .preview svg { max-height: 300px; background: transparent; }
/* The Studio's form is long: its preview sits at the top and follows the form as it scrolls. */
.styler .preview-panel { display: block; }
.preview-stick { position: sticky; top: 22px; display: flex; flex-direction: column; gap: 12px; }
.preview-stick .preview { min-height: 300px; }
.style-notes { margin: 0 0 10px; padding: 0 0 0 16px; color: var(--muted); font-size: 10px; line-height: 1.5; }
.style-notes li.is-error { color: var(--error); }
.style-notes:empty { display: none; }
.code-sample { margin-top: 14px; padding: 14px 18px; border: 1px solid var(--line); border-radius: 7px; background: var(--surface); font-size: 12px; }
.code-sample summary { cursor: pointer; font-weight: 700; }
.code-sample pre { margin: 14px 0; padding: 14px; overflow-x: auto; border-radius: 5px; color: var(--code-ink); background: var(--code-bg); font: 11px/1.6 var(--mono); }
.code-sample p { margin: 0; color: var(--muted); line-height: 1.6; }
.code-sample p code { font: 11px var(--mono); color: var(--ink); }
.code-sample a { font-weight: 700; color: var(--accent-ink); }
.generated { margin: 14px auto 0; width: 190px; }
.generated svg { display: block; width: 100%; height: auto; }
.bar-generated { width: 100%; margin: 12px 0 8px; }
.bar-generated svg { width: 100%; height: auto; }
.art-note { position: absolute; right: 12%; bottom: -36px; color: var(--muted-2); font: 9px/1.6 var(--mono); letter-spacing: 1.2px; }
.theme-toggle { width: 34px; height: 34px; display: inline-grid; place-items: center; border: 1px solid var(--line); border-radius: 5px; background: transparent; color: var(--ink); cursor: pointer; font-size: 15px; }
.theme-toggle:hover { border-color: var(--accent); }
/* Scanning a hero card reveals its easter egg in the scanner's result. */
.result-egg { margin: 0 0 12px !important; padding: 10px 12px; border-radius: 5px; color: var(--ok-ink) !important; background: var(--ok-bg); font: 600 12px/1.5 var(--sans) !important; white-space: normal !important; }
.result-egg[hidden] { display: none; }
.result-egg a { color: inherit; text-decoration: underline; }

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

.formats-section { padding: 87px 10% 98px; }
.formats-section > .eyebrow { margin-bottom: 23px; }
.formats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 13px; }
.formats-grid article { min-height: 180px; padding: 18px; border: 1px solid var(--line); border-radius: 5px; background: var(--surface-2); }
.format-icon { width: 35px; height: 35px; margin-bottom: 18px; display: grid; place-items: center; border-radius: 4px; color: var(--accent-ink); background: var(--ok-bg); font: 10px var(--mono); }
.icon-qr { font-size: 20px; }
.formats-grid h3 { margin-bottom: 7px; font: 600 15px var(--display); }
.formats-grid p { margin-bottom: 0; color: var(--muted); font-size: 10px; line-height: 1.6; }

footer { min-height: 82px; padding: 20px 7.3%; display: flex; align-items: center; justify-content: space-between; gap: 20px; border-top: 1px solid var(--line); }
footer .wordmark { font-size: 15px; }
footer .mark { width: 20px; height: 20px; }
footer p { margin: 0; color: var(--muted); font-size: 10px; }
footer p a { color: var(--ink); font-weight: 700; }
.footer-license { color: var(--muted); font: 9px var(--mono); letter-spacing: .8px; }

@media (min-width: 1400px) {
  .hero, .tool-section, .formats-section { padding-right: max(10%, calc((100% - 1120px) / 2)); padding-left: max(10%, calc((100% - 1120px) / 2)); }
}
@media (max-width: 900px) {
  .hero { padding: 80px 7% 60px; grid-template-columns: 1.05fr .95fr; gap: 2%; }
  .hero-art { transform: scale(.88); transform-origin: center right; }
  .feature-strip, .tool-section, .formats-section { padding-right: 7%; padding-left: 7%; }
  .tool-card { grid-template-columns: .9fr 1.1fr; }
  .tool-controls, .scan-actions { padding: 23px; }
}
@media (max-width: 650px) {
  html { scroll-padding-top: 65px; }
  .topbar { height: 64px; padding: 0 5%; }
  .wordmark { font-size: 16px; }
  .topbar nav { gap: 10px; font-size: 11px; }
  .topbar .source-link { padding: 8px; }
  .topbar nav a:not(.source-link) { display: none; }
  .topbar .wordmark > span:last-child { font-size: 15px; }
  .hero { padding: 66px 7% 42px; display: block; }
  h1 { font-size: clamp(54px, 15vw, 76px); letter-spacing: -4px; }
  .hero-text { font-size: 14px; }
  .hero-proof { margin-top: 30px; }
  .hero-art { width: 94%; height: 290px; margin: 34px auto 0; transform: scale(.82); transform-origin: top center; }
  .art-qr { left: 5%; }
  .art-bar { right: 0; }
    .feature-strip { padding: 20px 7%; grid-template-columns: 1fr; gap: 16px; }
  .tool-section { padding: 66px 5% 22px; }
  .section-heading { display: block; }
  .section-heading > p { margin-top: 14px; }
  .tool-card, .scanner { grid-template-columns: 1fr; }
  .tool-controls, .scan-actions { padding: 22px; }
  .preview-panel { min-height: 300px; padding: 17px; }
  .preview { min-height: 215px; }
  .scan-preview { min-height: 260px; }
  .formats-section { padding: 68px 5%; }
  .formats-grid { grid-template-columns: repeat(2, 1fr); }
  .formats-grid article { min-height: 165px; padding: 14px; }
  footer { padding: 20px 5%; flex-wrap: wrap; }
  footer p { order: 3; width: 100%; }
}

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