/* ==========================================================================
   QRilo — Design System
   --------------------------------------------------------------------------
   1. Tokens
   2. Reset & base
   3. Layout
   4. Header & navigation
   5. Buttons & controls
   6. Cards & surfaces
   7. Generator UI
   8. Advert slots (reserved space, never layout-shifting)
   9. Content: hero, trust, prose, FAQ, footer
  10. Responsive
  11. Print
   ========================================================================== */

/* ==========================================================================
   1. Tokens
   ========================================================================== */

:root {
  /* Brand */
  --brand-600: #3B4BE0;
  --brand-700: #2E3CC4;
  --brand-500: #5A68E8;
  --accent-600: #0E9488;
  --accent-500: #12A594;
  --ink-900: #0B1020;

  /* Surfaces */
  --bg: #F6F7FB;
  --surface: #FFFFFF;
  --surface-2: #FAFBFE;
  --surface-sunken: #EFF1F8;
  --border: #E3E6F0;
  --border-strong: #CFD4E4;

  /* Text */
  --text: #101427;
  --text-muted: #5A6178;
  --text-faint: #868DA3;

  /* Accents for states */
  --ok: #0E9488;
  --warn: #B26A00;
  --error: #C0392B;
  --ok-bg: #E8F8F5;
  --warn-bg: #FDF4E3;
  --error-bg: #FDECEA;

  /* Radii */
  --r-xs: 6px;
  --r-sm: 9px;
  --r-md: 13px;
  --r-lg: 18px;
  --r-xl: 26px;
  --r-full: 999px;

  /* Shadows */
  --sh-1: 0 1px 2px rgba(16, 20, 39, .05), 0 1px 3px rgba(16, 20, 39, .04);
  --sh-2: 0 4px 12px rgba(16, 20, 39, .06), 0 1px 3px rgba(16, 20, 39, .04);
  --sh-3: 0 14px 40px rgba(16, 20, 39, .10), 0 2px 8px rgba(16, 20, 39, .05);
  --sh-focus: 0 0 0 3px rgba(59, 75, 224, .28);

  /* Type */
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, 'SF Mono', Menlo, Consolas, monospace;

  /* Motion */
  --ease: cubic-bezier(.22, .61, .36, 1);

  /* Metrics */
  --container: 1180px;
  --header-h: 66px;
}

html[data-theme="dark"] {
  --brand-600: #7C88F5;
  --brand-700: #6A77F0;
  --brand-500: #96A0F8;
  --accent-600: #2CC3AE;
  --accent-500: #35D0BA;

  --bg: #080C18;
  --surface: #101728;
  --surface-2: #141C30;
  --surface-sunken: #0C1220;
  --border: #232C44;
  --border-strong: #313C58;

  --text: #EAEEF9;
  --text-muted: #9AA3BC;
  --text-faint: #7B84A0;

  --ok: #35D0BA;
  --warn: #E0A33D;
  --error: #F2776A;
  --ok-bg: #10261F;
  --warn-bg: #2A2113;
  --error-bg: #2C1717;

  --sh-1: 0 1px 2px rgba(0, 0, 0, .4);
  --sh-2: 0 4px 14px rgba(0, 0, 0, .45);
  --sh-3: 0 18px 46px rgba(0, 0, 0, .55);
  --sh-focus: 0 0 0 3px rgba(124, 136, 245, .35);
}

/* ==========================================================================
   2. Reset & base
   ========================================================================== */

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

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--header-h) + 16px);
}

body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.62;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

body.nav-open { overflow: hidden; }

h1, h2, h3, h4 {
  margin: 0 0 .5em;
  line-height: 1.2;
  letter-spacing: -.021em;
  font-weight: 700;
  color: var(--text);
}
h1 { font-size: clamp(1.85rem, 1.2rem + 2.6vw, 3.05rem); letter-spacing: -.032em; }
h2 { font-size: clamp(1.4rem, 1.1rem + 1.3vw, 2rem); letter-spacing: -.026em; }
h3 { font-size: clamp(1.1rem, 1rem + .45vw, 1.28rem); }
h4 { font-size: 1rem; }

p { margin: 0 0 1em; }
p:last-child { margin-bottom: 0; }

a { color: var(--brand-600); text-decoration: none; }
a:hover { text-decoration: underline; }

img, svg, canvas { max-width: 100%; }
img { height: auto; }

ul, ol { margin: 0 0 1em; padding-left: 1.35em; }
li { margin-bottom: .4em; }

code, kbd, samp {
  font-family: var(--font-mono);
  font-size: .875em;
  background: var(--surface-sunken);
  padding: .12em .42em;
  border-radius: var(--r-xs);
  border: 1px solid var(--border);
}

hr {
  border: 0;
  border-top: 1px solid var(--border);
  margin: 2.5rem 0;
}

:focus-visible {
  outline: 2px solid var(--brand-600);
  outline-offset: 2px;
  border-radius: var(--r-xs);
}

::selection { background: rgba(59, 75, 224, .18); }

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 200;
  background: var(--brand-600);
  color: #fff;
  padding: .7rem 1.1rem;
  border-radius: 0 0 var(--r-sm) 0;
  font-weight: 600;
}
.skip-link:focus { left: 0; }

.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;
}

/* ==========================================================================
   3. Layout
   ========================================================================== */

.container {
  width: 100%;
  max-width: var(--container);
  margin-inline: auto;
  padding-inline: 20px;
}

.container--narrow { max-width: 760px; }
.container--wide { max-width: 1340px; }

.section { padding: clamp(3rem, 2rem + 4vw, 5.5rem) 0; }
.section--tight { padding: clamp(2rem, 1.4rem + 2.4vw, 3.4rem) 0; }

.stack-sm > * + * { margin-top: .75rem; }
.stack > * + * { margin-top: 1.25rem; }
.stack-lg > * + * { margin-top: 2rem; }

.center { text-align: center; }
.muted { color: var(--text-muted); }
.faint { color: var(--text-faint); font-size: .875rem; }

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: .45rem;
  font-size: .78rem;
  font-weight: 700;
  letter-spacing: .09em;
  text-transform: uppercase;
  color: var(--brand-600);
  margin-bottom: .9rem;
}

.section-head { max-width: 660px; margin-bottom: 2.3rem; }
.section-head--center { margin-inline: auto; text-align: center; }
.section-head p { color: var(--text-muted); margin: 0; font-size: 1.02rem; }

.grid { display: grid; gap: 1.25rem; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(268px, 1fr)); }
.grid-4 { grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); }

/* ==========================================================================
   4. Header & navigation
   ========================================================================== */

.site-header {
  position: sticky;
  top: 0;
  z-index: 90;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: saturate(180%) blur(14px);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid var(--border);
}

@supports not (backdrop-filter: blur(2px)) {
  .site-header { background: var(--surface); }
}

.site-header__inner {
  display: flex;
  align-items: center;
  gap: 1.1rem;
  min-height: var(--header-h);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: .6rem;
  font-weight: 800;
  font-size: 1.16rem;
  letter-spacing: -.03em;
  color: var(--text);
  flex-shrink: 0;
}
.brand:hover { text-decoration: none; }
.brand img { width: 32px; height: 32px; display: block; }
.brand__name { background: linear-gradient(100deg, var(--brand-600), var(--accent-500)); -webkit-background-clip: text; background-clip: text; color: transparent; }

.nav { margin-left: auto; }
.nav__list {
  display: flex;
  align-items: center;
  gap: .25rem;
  list-style: none;
  margin: 0;
  padding: 0;
}
.nav__list li { margin: 0; }
.nav__link {
  display: inline-block;
  padding: .5rem .72rem;
  border-radius: var(--r-sm);
  font-size: .925rem;
  font-weight: 550;
  color: var(--text-muted);
  transition: background .16s var(--ease), color .16s var(--ease);
}
.nav__link:hover { background: var(--surface-sunken); color: var(--text); text-decoration: none; }
.nav__link[aria-current="page"] { color: var(--brand-600); background: var(--surface-sunken); font-weight: 650; }

.nav__actions { display: flex; align-items: center; gap: .5rem; }

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px; height: 40px;
  border-radius: var(--r-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  cursor: pointer;
  transition: background .16s var(--ease), color .16s var(--ease), border-color .16s var(--ease);
}
.icon-btn:hover { background: var(--surface-sunken); color: var(--text); border-color: var(--border-strong); }
.icon-btn svg { width: 19px; height: 19px; }

.theme-toggle .icon-moon { display: none; }
html[data-theme="dark"] .theme-toggle .icon-sun { display: none; }
html[data-theme="dark"] .theme-toggle .icon-moon { display: block; }

.nav-toggle { display: none; }

/* ==========================================================================
   5. Buttons & controls
   ========================================================================== */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .5rem;
  padding: .68rem 1.15rem;
  border-radius: var(--r-sm);
  border: 1px solid transparent;
  font-family: inherit;
  font-size: .94rem;
  font-weight: 620;
  line-height: 1.25;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition: background .16s var(--ease), border-color .16s var(--ease),
              color .16s var(--ease), transform .1s var(--ease), box-shadow .16s var(--ease);
}
.btn:hover { text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn svg { width: 17px; height: 17px; flex-shrink: 0; }

.btn--primary {
  background: var(--brand-600);
  color: #fff;
  box-shadow: var(--sh-2);
}
.btn--primary:hover { background: var(--brand-700); color: #fff; }

.btn--accent {
  background: var(--accent-600);
  color: #04211E;
  box-shadow: var(--sh-2);
}
.btn--accent:hover { filter: brightness(1.06); }

.btn--ghost {
  background: var(--surface);
  border-color: var(--border);
  color: var(--text);
}
.btn--ghost:hover { background: var(--surface-sunken); border-color: var(--border-strong); }

.btn--subtle {
  background: transparent;
  border-color: transparent;
  color: var(--text-muted);
  padding-inline: .7rem;
}
.btn--subtle:hover { background: var(--surface-sunken); color: var(--text); }

.btn--block { width: 100%; }
.btn--sm { padding: .45rem .8rem; font-size: .86rem; }
.btn--lg { padding: .85rem 1.5rem; font-size: 1rem; }

.btn[disabled], .btn[aria-disabled="true"] {
  opacity: .5;
  cursor: not-allowed;
  transform: none;
}

.btn-row { display: flex; flex-wrap: wrap; gap: .6rem; }

/* Segmented control */
.segmented {
  display: flex;
  gap: 3px;
  padding: 3px;
  background: var(--surface-sunken);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
}
.segmented button {
  flex: 1;
  padding: .42rem .5rem;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--text-muted);
  font-family: inherit;
  font-size: .855rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background .15s var(--ease), color .15s var(--ease);
}
.segmented button:hover { color: var(--text); }
.segmented button[aria-pressed="true"] {
  background: var(--surface);
  color: var(--brand-600);
  box-shadow: var(--sh-1);
}

/* Fields */
.field { display: block; }
.field + .field { margin-top: 1rem; }

.field__label {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: .75rem;
  font-size: .845rem;
  font-weight: 650;
  color: var(--text);
  margin-bottom: .4rem;
}
.field__hint {
  font-size: .78rem;
  font-weight: 500;
  color: var(--text-faint);
}

.input, .select, .textarea {
  width: 100%;
  padding: .66rem .8rem;
  font-family: inherit;
  font-size: .94rem;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-sm);
  transition: border-color .16s var(--ease), box-shadow .16s var(--ease);
}
.input:focus, .select:focus, .textarea:focus {
  outline: none;
  border-color: var(--brand-600);
  box-shadow: var(--sh-focus);
}
.input::placeholder, .textarea::placeholder { color: var(--text-faint); }
.textarea { min-height: 132px; resize: vertical; line-height: 1.55; }
.select {
  appearance: none;
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%235A6178' stroke-width='2.2' stroke-linecap='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right .65rem center;
  background-size: 15px;
  padding-right: 2.1rem;
  cursor: pointer;
}
html[data-theme="dark"] .select {
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%239AA3BC' stroke-width='2.2' stroke-linecap='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
}

.field--inline { display: flex; align-items: center; gap: .6rem; }
.field--inline label { font-size: .9rem; font-weight: 550; margin: 0; }

.checkbox {
  display: flex;
  align-items: flex-start;
  gap: .6rem;
  font-size: .895rem;
  cursor: pointer;
  line-height: 1.45;
}
.checkbox input[type="checkbox"] {
  width: 18px; height: 18px;
  margin: .12rem 0 0;
  flex-shrink: 0;
  accent-color: var(--brand-600);
  cursor: pointer;
}

/* Range slider */
.range {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 22px;
  background: transparent;
  cursor: pointer;
}
.range::-webkit-slider-runnable-track {
  height: 5px;
  border-radius: var(--r-full);
  background: var(--surface-sunken);
  border: 1px solid var(--border);
}
.range::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px; height: 18px;
  margin-top: -7px;
  border-radius: 50%;
  background: var(--brand-600);
  border: 2px solid var(--surface);
  box-shadow: var(--sh-1);
}
.range::-moz-range-track {
  height: 5px;
  border-radius: var(--r-full);
  background: var(--surface-sunken);
  border: 1px solid var(--border);
}
.range::-moz-range-thumb {
  width: 16px; height: 16px;
  border-radius: 50%;
  background: var(--brand-600);
  border: 2px solid var(--surface);
  box-shadow: var(--sh-1);
}

/* Colour swatch picker */
.swatch {
  position: relative;
  width: 40px; height: 40px;
  flex-shrink: 0;
  border-radius: var(--r-sm);
  border: 1px solid var(--border-strong);
  overflow: hidden;
  cursor: pointer;
  padding: 0;
  background: var(--surface);
}
.swatch input[type="color"] {
  position: absolute;
  inset: -6px;
  width: calc(100% + 12px);
  height: calc(100% + 12px);
  border: 0;
  padding: 0;
  cursor: pointer;
  background: none;
}
.swatch-row { display: flex; align-items: center; gap: .6rem; }
.swatch-row .input { font-family: var(--font-mono); font-size: .82rem; text-transform: uppercase; }

.preset-dots {
  display: flex;
  flex-wrap: wrap;
  gap: .45rem;
}
.preset-dot {
  width: 26px; height: 26px;
  border-radius: var(--r-full);
  border: 2px solid var(--border);
  cursor: pointer;
  padding: 0;
  transition: transform .14s var(--ease), border-color .14s var(--ease);
}
.preset-dot:hover { transform: scale(1.14); border-color: var(--border-strong); }
.preset-dot[aria-pressed="true"] { border-color: var(--brand-600); box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--brand-600); }

/* ==========================================================================
   6. Cards & surfaces
   ========================================================================== */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-1);
}
.card--pad { padding: 1.4rem; }
.card--flush { overflow: hidden; }
.card--lift { transition: transform .2s var(--ease), box-shadow .2s var(--ease), border-color .2s var(--ease); }
.card--lift:hover { transform: translateY(-3px); box-shadow: var(--sh-3); border-color: var(--border-strong); }

.card__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: .9rem 1.15rem;
  border-bottom: 1px solid var(--border);
}
.card__title {
  margin: 0;
  font-size: .95rem;
  font-weight: 680;
  letter-spacing: -.01em;
  display: flex;
  align-items: center;
  gap: .5rem;
}
.card__title svg { width: 16px; height: 16px; color: var(--brand-600); }
.card__body { padding: 1.15rem; }

.feature-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px; height: 42px;
  border-radius: var(--r-md);
  background: var(--surface-sunken);
  color: var(--brand-600);
  margin-bottom: .85rem;
}
.feature-icon svg { width: 21px; height: 21px; }

.feature h3 { margin-bottom: .35rem; }
.feature p { color: var(--text-muted); font-size: .93rem; margin: 0; }

.pill {
  display: inline-flex;
  align-items: center;
  gap: .38rem;
  padding: .28rem .68rem;
  border-radius: var(--r-full);
  background: var(--surface-sunken);
  border: 1px solid var(--border);
  font-size: .78rem;
  font-weight: 650;
  color: var(--text-muted);
}
.pill svg { width: 13px; height: 13px; }
.pill--ok { background: var(--ok-bg); color: var(--ok); border-color: transparent; }
.pill--warn { background: var(--warn-bg); color: var(--warn); border-color: transparent; }
.pill--error { background: var(--error-bg); color: var(--error); border-color: transparent; }

.notice {
  display: flex;
  gap: .7rem;
  padding: .8rem .95rem;
  border-radius: var(--r-md);
  font-size: .885rem;
  line-height: 1.5;
  border: 1px solid transparent;
}
.notice svg { width: 17px; height: 17px; flex-shrink: 0; margin-top: .14rem; }
.notice--ok { background: var(--ok-bg); color: var(--ok); }
.notice--warn { background: var(--warn-bg); color: var(--warn); }
.notice--error { background: var(--error-bg); color: var(--error); }
.notice--info { background: var(--surface-sunken); color: var(--text-muted); }
.notice strong { font-weight: 680; }

/* Tabs */
.tabs {
  display: flex;
  gap: .3rem;
  overflow-x: auto;
  scrollbar-width: none;
  padding: .35rem;
  background: var(--surface-sunken);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  display: inline-flex;
  align-items: center;
  gap: .42rem;
  padding: .5rem .82rem;
  border: 0;
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--text-muted);
  font-family: inherit;
  font-size: .87rem;
  font-weight: 620;
  white-space: nowrap;
  cursor: pointer;
  transition: background .15s var(--ease), color .15s var(--ease);
}
.tab svg { width: 15px; height: 15px; }
.tab:hover { color: var(--text); }
.tab[aria-selected="true"] {
  background: var(--surface);
  color: var(--brand-600);
  box-shadow: var(--sh-1);
}

.tab-panel[hidden] { display: none; }
.tab-panel { animation: fade-in .22s var(--ease); }

@keyframes fade-in {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: none; }
}

/* ==========================================================================
   7. Generator UI
   ========================================================================== */

.generator {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 420px);
  gap: 1.6rem;
  align-items: start;
}

.generator__panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-2);
  padding: 1.35rem;
}

.panel-title {
  display: flex;
  align-items: center;
  gap: .5rem;
  font-size: .82rem;
  font-weight: 700;
  letter-spacing: .075em;
  text-transform: uppercase;
  color: var(--text-faint);
  margin: 0 0 .8rem;
}
.panel-title:not(:first-child) { margin-top: 1.6rem; }

.preview {
  position: sticky;
  top: calc(var(--header-h) + 20px);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-2);
  overflow: hidden;
}

.preview__stage {
  padding: 1.35rem;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 320px;
  background:
    radial-gradient(circle at 22% 18%, rgba(59, 75, 224, .05), transparent 62%),
    radial-gradient(circle at 78% 82%, rgba(18, 165, 148, .05), transparent 60%),
    var(--surface-2);
  position: relative;
}

.preview__canvas-wrap {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  max-width: 320px;
  width: 100%;
  aspect-ratio: 1;
  background: var(--surface);
  border-radius: var(--r-md);
  box-shadow: var(--sh-2);
  padding: 10px;
}
.preview__canvas-wrap canvas {
  width: 100%;
  height: 100%;
  display: block;
  border-radius: 4px;
  image-rendering: -webkit-optimize-contrast;
  image-rendering: crisp-edges;
}

.preview__loading {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-faint);
  background: var(--surface);
  border-radius: var(--r-md);
  font-size: .85rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity .15s var(--ease);
}
.preview__loading.is-visible { opacity: 1; }

.status {
  border-top: 1px solid var(--border);
  padding: .85rem 1.1rem;
  background: var(--surface-2);
  font-size: .855rem;
  display: flex;
  flex-direction: column;
  gap: .5rem;
}
.status__row { display: flex; align-items: flex-start; gap: .55rem; line-height: 1.45; }
.status__row svg { width: 15px; height: 15px; flex-shrink: 0; margin-top: .17rem; }
.status__row--ok { color: var(--ok); }
.status__row--warn { color: var(--warn); }
.status__row--error { color: var(--error); }
.status__row--info { color: var(--text-muted); }

/* Reassurance note pinned beside the download buttons.
   Advertising is on the site; it is never in the user's code. Stated where
   the user is about to download, which is the moment the question occurs. */
.adfree-note {
  display: flex;
  align-items: flex-start;
  gap: .5rem;
  margin: 0;
  padding: .7rem 1.1rem;
  border-top: 1px solid var(--border);
  background: var(--ok-bg);
  color: var(--ok);
  font-size: .8rem;
  line-height: 1.45;
}
.adfree-note svg { flex-shrink: 0; margin-top: .12rem; }
.adfree-note strong { font-weight: 650; }

.preview__actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: .55rem;
  padding: 1.1rem;
  border-top: 1px solid var(--border);
}
.preview__actions .btn { width: 100%; }
.preview__actions .btn--wide { grid-column: 1 / -1; }

.meta-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: .6rem;
  padding: .85rem 1.1rem;
  border-top: 1px solid var(--border);
  background: var(--surface-2);
}
.meta-item { text-align: center; }
.meta-item dt {
  font-size: .68rem;
  font-weight: 700;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--text-faint);
}
.meta-item dd {
  margin: .18rem 0 0;
  font-size: .95rem;
  font-weight: 680;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}
.meta-item dd.is-warning { color: var(--warn); }
.meta-item dd.is-error { color: var(--error); }

.style-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(96px, 1fr));
  gap: .5rem;
}
.style-option {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .35rem;
  padding: .6rem .4rem;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--surface);
  cursor: pointer;
  font-size: .78rem;
  font-weight: 600;
  color: var(--text-muted);
  font-family: inherit;
  transition: border-color .15s var(--ease), background .15s var(--ease), color .15s var(--ease);
}
.style-option:hover { border-color: var(--border-strong); color: var(--text); }
.style-option[aria-pressed="true"] {
  border-color: var(--brand-600);
  background: color-mix(in srgb, var(--brand-600) 7%, var(--surface));
  color: var(--brand-600);
}
.style-option svg { width: 26px; height: 26px; }

.advanced {
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface-2);
}
.advanced > summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  padding: .78rem .95rem;
  cursor: pointer;
  font-size: .895rem;
  font-weight: 650;
  list-style: none;
  border-radius: var(--r-md);
}
.advanced > summary::-webkit-details-marker { display: none; }
.advanced > summary::after {
  content: '';
  width: 15px; height: 15px;
  flex-shrink: 0;
  background: currentColor;
  color: var(--text-faint);
  -webkit-mask: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2.4' stroke-linecap='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E") center/contain no-repeat;
  mask: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2.4' stroke-linecap='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E") center/contain no-repeat;
  transition: transform .2s var(--ease);
}
.advanced[open] > summary::after { transform: rotate(180deg); }
.advanced__body { padding: 0 .95rem 1rem; }

.logo-drop {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .7rem;
  border: 1.5px dashed var(--border-strong);
  border-radius: var(--r-md);
  background: var(--surface-2);
  cursor: pointer;
  transition: border-color .16s var(--ease), background .16s var(--ease);
}
.logo-drop:hover, .logo-drop.is-drag {
  border-color: var(--brand-600);
  background: color-mix(in srgb, var(--brand-600) 6%, var(--surface));
}
.logo-drop__thumb {
  width: 42px; height: 42px;
  flex-shrink: 0;
  border-radius: var(--r-sm);
  background: var(--surface-sunken);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  color: var(--text-faint);
}
.logo-drop__thumb img { width: 100%; height: 100%; object-fit: contain; }
.logo-drop__thumb svg { width: 19px; height: 19px; }
.logo-drop__text { font-size: .855rem; line-height: 1.4; min-width: 0; }
.logo-drop__text strong { display: block; font-weight: 650; }
.logo-drop__text span { color: var(--text-faint); font-size: .79rem; }

/* Saved codes */
.saved-list { display: flex; flex-direction: column; gap: .5rem; }
.saved-item {
  display: flex;
  align-items: center;
  gap: .7rem;
  padding: .6rem .7rem;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--surface);
}
.saved-item__thumb {
  width: 38px; height: 38px;
  flex-shrink: 0;
  border-radius: var(--r-xs);
  border: 1px solid var(--border);
  object-fit: contain;
  background: #fff;
}
.saved-item__meta { min-width: 0; flex: 1; }
.saved-item__name {
  font-size: .875rem;
  font-weight: 620;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.saved-item__sub { font-size: .75rem; color: var(--text-faint); }
.saved-item__actions { display: flex; gap: .25rem; flex-shrink: 0; }
.saved-item__actions .icon-btn { width: 30px; height: 30px; }
.saved-item__actions .icon-btn svg { width: 15px; height: 15px; }

.empty-state {
  text-align: center;
  padding: 1.7rem 1rem;
  color: var(--text-faint);
  font-size: .875rem;
}
.empty-state svg { width: 28px; height: 28px; margin-bottom: .5rem; opacity: .55; }

/* ==========================================================================
   8. Advert slots
   --------------------------------------------------------------------------
   Every slot reserves its height up front, so filling it never shifts the
   page (protects users and Core Web Vitals alike).
   ========================================================================== */

.ad {
  position: relative;
  width: 100%;
  margin-inline: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
}

.ad__label {
  position: absolute;
  top: 5px;
  left: 8px;
  font-size: .58rem;
  font-weight: 700;
  letter-spacing: .13em;
  text-transform: uppercase;
  color: var(--text-faint);
  opacity: .68;
  pointer-events: none;
  z-index: 2;
}

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

/* Placeholder shown only before a slot is filled */
.ad--placeholder::after {
  content: attr(data-placeholder);
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 1.2rem;
  font-size: .78rem;
  color: var(--text-faint);
  opacity: .6;
  letter-spacing: .04em;
}
.ad:not(.ad--placeholder)::after { content: none; }

/* Once a real unit is in place, never clip it: AdSense requires the whole
   creative to be visible, and a responsive unit may be taller than the
   reserved floor. The reserved min-height above stays as the minimum. */
.ad-wrapper[data-ad-loaded="done"] .ad { overflow: visible; }

/* Sized slots — heights are fixed so nothing reflows */
.ad--leaderboard { min-height: 96px; max-width: 740px; }
.ad--billboard { min-height: 130px; max-width: 990px; }
.ad--rectangle { min-height: 254px; max-width: 340px; }
.ad--skyscraper { min-height: 604px; width: 302px; max-width: 100%; }
.ad--mobile-banner { min-height: 56px; max-width: 340px; }

.ad-wrap { margin: 2.4rem auto; }
.ad-wrap--tight { margin: 1.5rem auto; }
.ad-wrap--loose { margin: 3.4rem auto; }

/* A "sponsored" rail next to the article body */
.with-rail {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 302px;
  gap: 2.6rem;
  align-items: start;
}
.with-rail__rail {
  position: sticky;
  top: calc(var(--header-h) + 20px);
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

/* ==========================================================================
   9. Content
   ========================================================================== */

.skip-target:focus { outline: none; }

/* Hero */
.hero {
  position: relative;
  padding: clamp(2.4rem, 1.6rem + 3.4vw, 4.2rem) 0 clamp(1.6rem, 1rem + 2vw, 2.6rem);
  overflow: hidden;
}
.hero::before {
  content: '';
  position: absolute;
  inset: -40% -20% auto -20%;
  height: 130%;
  background:
    radial-gradient(46% 52% at 18% 22%, rgba(59, 75, 224, .13), transparent 68%),
    radial-gradient(42% 46% at 84% 12%, rgba(18, 165, 148, .13), transparent 66%);
  pointer-events: none;
  z-index: 0;
}
html[data-theme="dark"] .hero::before {
  background:
    radial-gradient(46% 52% at 18% 22%, rgba(59, 75, 224, .26), transparent 68%),
    radial-gradient(42% 46% at 84% 12%, rgba(18, 165, 148, .2), transparent 66%);
}
.hero > * { position: relative; z-index: 1; }

.hero__grid {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, .85fr);
  gap: clamp(1.8rem, 1rem + 3vw, 3.6rem);
  align-items: center;
}
.hero h1 { margin-bottom: .7rem; }
.hero__lead {
  font-size: clamp(1.02rem, .96rem + .32vw, 1.19rem);
  color: var(--text-muted);
  max-width: 56ch;
  margin-bottom: 1.5rem;
}
.hero__badges {
  display: flex;
  flex-wrap: wrap;
  gap: .45rem;
  margin-bottom: 1.5rem;
}

.hero__art {
  display: grid;
  gap: 1rem;
  justify-items: center;
}
.hero__code-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  box-shadow: var(--sh-3);
  padding: 1.5rem;
  width: min(100%, 320px);
  text-align: center;
}
.hero__code-card canvas { width: 100%; height: auto; border-radius: var(--r-sm); display: block; }
.hero__code-caption {
  margin: .8rem 0 0;
  font-size: .8rem;
  color: var(--text-faint);
}

/* Trust bar */
.trust-bar {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
  padding: 1.3rem 1.4rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-1);
}
.trust-item { display: flex; align-items: flex-start; gap: .7rem; }
.trust-item__icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px; height: 34px;
  flex-shrink: 0;
  border-radius: var(--r-sm);
  background: color-mix(in srgb, var(--brand-600) 10%, transparent);
  color: var(--brand-600);
}
.trust-item__icon svg { width: 17px; height: 17px; }
.trust-item strong { display: block; font-size: .9rem; font-weight: 660; line-height: 1.35; }
.trust-item span { font-size: .8rem; color: var(--text-muted); line-height: 1.4; }

/* Steps */
.step {
  position: relative;
  counter-increment: step;
  padding-top: 2.4rem;
}
.step::before {
  content: counter(step);
  position: absolute;
  top: 0; left: 0;
  width: 32px; height: 32px;
  display: grid;
  place-items: center;
  border-radius: var(--r-full);
  background: var(--brand-600);
  color: #fff;
  font-size: .85rem;
  font-weight: 700;
}
.steps { counter-reset: step; }

/* Prose (articles) */
.prose { font-size: 1.045rem; line-height: 1.75; color: var(--text); }
.prose > * + * { margin-top: 1.15rem; }
.prose h2 { margin-top: 2.6rem; margin-bottom: -.15rem; }
.prose h3 { margin-top: 2rem; margin-bottom: -.2rem; }
.prose h2:first-child, .prose h3:first-child { margin-top: 0; }
.prose ul, .prose ol { padding-left: 1.3em; }
.prose li { margin-bottom: .55em; }
.prose li::marker { color: var(--brand-600); }
.prose blockquote {
  margin: 1.6rem 0;
  padding: .95rem 1.2rem;
  border-left: 3px solid var(--brand-600);
  background: var(--surface-2);
  border-radius: 0 var(--r-sm) var(--r-sm) 0;
  color: var(--text-muted);
}
.prose blockquote p:last-child { margin-bottom: 0; }
.prose img { border-radius: var(--r-md); border: 1px solid var(--border); }
.prose table { width: 100%; border-collapse: collapse; font-size: .93rem; }
.prose th, .prose td { padding: .6rem .7rem; border-bottom: 1px solid var(--border); text-align: left; }
.prose th { font-weight: 660; background: var(--surface-2); }

.article-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .8rem;
  font-size: .82rem;
  color: var(--text-faint);
  margin-bottom: 1.6rem;
  padding-bottom: 1.2rem;
  border-bottom: 1px solid var(--border);
}

.toc {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 1.05rem 1.2rem;
}
.toc h2 { font-size: .8rem; letter-spacing: .08em; text-transform: uppercase; color: var(--text-faint); margin-bottom: .55rem; }
.toc ol { margin: 0; padding-left: 1.15em; font-size: .9rem; }
.toc li { margin-bottom: .3em; }
.toc a { color: var(--text-muted); }
.toc a:hover { color: var(--brand-600); }

/* Accordion / FAQ */
.accordion {
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface);
  overflow: hidden;
}
.accordion + .accordion { margin-top: .6rem; }
.accordion > summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.15rem;
  cursor: pointer;
  font-weight: 640;
  font-size: .97rem;
  list-style: none;
  transition: background .15s var(--ease);
}
.accordion > summary::-webkit-details-marker { display: none; }
.accordion > summary:hover { background: var(--surface-2); }
.accordion > summary::after {
  content: '';
  width: 17px; height: 17px;
  flex-shrink: 0;
  color: var(--text-faint);
  background: currentColor;
  -webkit-mask: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2.4' stroke-linecap='round'%3E%3Cpath d='M12 5v14M5 12h14'/%3E%3C/svg%3E") center/contain no-repeat;
  mask: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2.4' stroke-linecap='round'%3E%3Cpath d='M12 5v14M5 12h14'/%3E%3C/svg%3E") center/contain no-repeat;
  transition: transform .2s var(--ease);
}
.accordion[open] > summary::after { transform: rotate(135deg); }
.accordion__body {
  padding: 0 1.15rem 1.15rem;
  color: var(--text-muted);
  font-size: .945rem;
  line-height: 1.7;
}
.accordion__body p:last-child { margin-bottom: 0; }

/* Footer */
.site-footer {
  margin-top: 4rem;
  padding: 3rem 0 2rem;
  border-top: 1px solid var(--border);
  background: var(--surface);
  font-size: .9rem;
}
.footer-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) repeat(3, minmax(0, 1fr));
  gap: 2rem;
}
.footer-brand p { color: var(--text-muted); font-size: .875rem; max-width: 34ch; margin-top: .75rem; }
.footer-col h2 {
  font-size: .78rem;
  letter-spacing: .09em;
  text-transform: uppercase;
  color: var(--text-faint);
  margin-bottom: .75rem;
}
.footer-col ul { list-style: none; padding: 0; margin: 0; }
.footer-col li { margin-bottom: .5rem; }
.footer-col a { color: var(--text-muted); font-size: .875rem; }
.footer-col a:hover { color: var(--brand-600); }

.footer-bottom {
  margin-top: 2.4rem;
  padding-top: 1.4rem;
  border-top: 1px solid var(--border);
  display: flex;
  flex-wrap: wrap;
  gap: .8rem 1.4rem;
  align-items: center;
  justify-content: space-between;
  color: var(--text-faint);
  font-size: .82rem;
}

.breadcrumbs {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .4rem;
  font-size: .82rem;
  color: var(--text-faint);
  margin-bottom: 1rem;
}
.breadcrumbs a { color: var(--text-muted); }
.breadcrumbs span[aria-hidden] { opacity: .55; }

/* Page header for sub pages */
.page-head {
  padding: clamp(2rem, 1.4rem + 2.6vw, 3.4rem) 0 clamp(1.4rem, 1rem + 1.6vw, 2.2rem);
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}
.page-head h1 { margin-bottom: .4rem; }
.page-head p { color: var(--text-muted); font-size: 1.05rem; max-width: 62ch; margin: 0; }


/* Toast */
.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translate(-50%, 130%);
  z-index: 130;
  background: var(--ink-900);
  color: #fff;
  padding: .7rem 1.1rem;
  border-radius: var(--r-full);
  font-size: .875rem;
  font-weight: 550;
  box-shadow: var(--sh-3);
  transition: transform .28s var(--ease);
  max-width: calc(100% - 32px);
  text-align: center;
}
html[data-theme="dark"] .toast { background: #EEF1FA; color: var(--ink-900); }
.toast.is-visible { transform: translate(-50%, 0); }

/* ==========================================================================
   10. Responsive
   ========================================================================== */

@media (max-width: 1080px) {
  .generator { grid-template-columns: minmax(0, 1fr) minmax(0, 360px); gap: 1.2rem; }
  .with-rail { grid-template-columns: minmax(0, 1fr); }
  .with-rail__rail { position: static; }
  .ad--skyscraper { min-height: 120px; width: 100%; max-width: 740px; }
}

@media (max-width: 900px) {
  .hero__grid { grid-template-columns: 1fr; }
  .hero__art { order: -1; }
  .hero__code-card { width: min(100%, 260px); padding: 1.1rem; }
  .footer-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .footer-brand { grid-column: 1 / -1; }
}

@media (max-width: 820px) {
  .generator { grid-template-columns: minmax(0, 1fr); }
  .preview { position: static; }
  .preview__stage { min-height: 280px; }

  /* Mobile navigation */
  .nav-toggle { display: inline-flex; }
  .nav {
    position: fixed;
    inset: var(--header-h) 0 auto 0;
    margin: 0;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    box-shadow: var(--sh-3);
    padding: .8rem 20px 1.4rem;
    transform: translateY(-8px);
    opacity: 0;
    visibility: hidden;
    transition: opacity .2s var(--ease), transform .2s var(--ease), visibility .2s;
    max-height: calc(100vh - var(--header-h));
    overflow-y: auto;
  }
  .nav.is-open { opacity: 1; visibility: visible; transform: none; }
  .nav__list { flex-direction: column; align-items: stretch; gap: .1rem; }
  .nav__link { padding: .8rem .7rem; font-size: 1rem; border-radius: var(--r-sm); }
  .nav__actions { display: none; }

  .with-rail { gap: 1.6rem; }
}

@media (max-width: 620px) {
  body { font-size: 15.5px; }
  .container { padding-inline: 16px; }
  .section { padding: 2.6rem 0; }
  .card__body, .generator__panel { padding: 1.05rem; }
  .preview__actions { padding: .9rem; }
  .meta-list { padding: .75rem .9rem; grid-template-columns: repeat(2, 1fr); }
  .trust-bar { padding: 1rem; gap: .85rem; }
  .footer-grid { grid-template-columns: 1fr; gap: 1.5rem; }
  .ad--rectangle { max-width: 100%; }
  .ad--leaderboard, .ad--billboard { min-height: 90px; }
  .ad-wrap { margin: 1.8rem auto; }
  .style-grid { grid-template-columns: repeat(3, 1fr); }

  .preview__canvas-wrap { max-width: 260px; }
}

@media (max-width: 420px) {
  .preview__actions { grid-template-columns: 1fr; }
  .brand__name { font-size: 1.05rem; }
}

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

/* ==========================================================================
   11. Print
   ========================================================================== */

@media print {
  .site-header, .site-footer, .ad, .ad-wrap, .toast,
  .preview__actions, .generator__panel, .nav { display: none !important; }
  body { background: #fff; }
  .preview { position: static; border: 0; box-shadow: none; }
  .preview__canvas-wrap { box-shadow: none; max-width: 100%; }
}
