/* Gradient QR Codes
   Follows the Gradient Apps web style (Brand book v1.1, page 15):
   paper canvas, restrained blue emphasis, 1px borders, square buttons. */

:root {
  --paper: #F5F4EE;
  --ink: #141719;
  --blue: #087CA8;
  --muted: #626967;
  --line: #D7D8D1;
  --soft: #E6F0EC;
  --white: #FFFFFF;

  --ok: #1F7A4D;
  --warn: #9A6200;
  --bad: #B3261E;

  --font-head: "Manrope", "DM Sans", Arial, Helvetica, sans-serif;
  --font-body: "DM Sans", Arial, Helvetica, sans-serif;

  --pad: 64px;
}

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

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

img { max-width: 100%; }

/* Component display rules (flex, grid, block) must not override the hidden attribute. */
[hidden] { display: none !important; }

a { color: var(--blue); }

h1, h2, h3 {
  font-family: var(--font-head);
  line-height: 1.07;
  margin: 0;
  text-wrap: balance;
}

:focus-visible {
  outline: 3px solid var(--blue);
  outline-offset: 2px;
}

.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.wrap {
  max-width: 1340px;
  margin-inline: auto;
  padding-inline: var(--pad);
}

/* Header: logo + divider + APPS label */
.site-header {
  background: var(--paper);
  border-bottom: 1px solid var(--line);
}

.header-inner {
  height: 94px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.lockup {
  display: flex;
  align-items: center;
  gap: 18px;
  text-decoration: none;
  color: var(--ink);
}

.lockup img { width: 180px; height: auto; display: block; }

.lockup-divider {
  width: 1px;
  height: 34px;
  background: var(--line);
}

.lockup-label {
  font-family: var(--font-head);
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.header-nav { display: flex; gap: 28px; }

.install-btn { margin-left: auto; min-height: 40px; padding: 0 16px; }

.header-nav a {
  color: var(--ink);
  text-decoration: none;
  font-weight: 500;
  font-size: 15px;
}

.header-nav a:hover { color: var(--blue); }

/* Hero */
.hero {
  display: grid;
  grid-template-columns: 1.15fr 0.85fr;
  gap: 70px;
  padding-block: 72px 56px;
  align-items: end;
}

.eyebrow {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 22px;
  font-family: var(--font-head);
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

h1 {
  font-size: clamp(44px, 6.2vw, 92px);
  font-weight: 600;
  letter-spacing: -0.055em;
}

h1 .accent { color: var(--blue); }

.lede {
  max-width: 34em;
  margin: 24px 0 0;
  font-size: 18px;
  color: var(--muted);
}

.hero-points {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0;
  border-top: 1px solid var(--line);
}

.hero-points li {
  display: grid;
  gap: 2px;
  padding-block: 16px;
  border-bottom: 1px solid var(--line);
}

.hero-points strong {
  font-family: var(--font-head);
  font-weight: 600;
}

.hero-points span { color: var(--muted); font-size: 15px; }

/* Builder layout */
.builder {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 440px);
  gap: 40px;
  align-items: start;
  padding-block: 8px 90px;
}

.editor { display: grid; gap: 20px; min-width: 0; }

.panel {
  background: var(--white);
  border: 1px solid var(--line);
  padding: 28px;
  display: grid;
  gap: 22px;
  min-width: 0;
}

.panel-head { display: grid; gap: 4px; }

.panel-head h2 {
  font-size: 24px;
  font-weight: 600;
  letter-spacing: -0.03em;
}

.panel-head p { margin: 0; color: var(--muted); font-size: 15px; }

.field { display: grid; gap: 10px; }

.label {
  font-family: var(--font-head);
  font-weight: 700;
  font-size: 12px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.label-sub { margin-top: 6px; }

.row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 14px 18px;
}

.row > * { min-width: 0; }

.grow { flex: 1 1 200px; }

/* Content type tabs */
.type-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.type-tab {
  font: 500 14px/1 var(--font-body);
  padding: 10px 14px;
  background: var(--white);
  color: var(--ink);
  border: 1px solid var(--line);
  cursor: pointer;
  transition: border-color .15s, color .15s;
}

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

.type-tab[aria-selected="true"] {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--white);
}

/* Form fields */
.fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px 18px;
}

.fields .full { grid-column: 1 / -1; }

.text { display: grid; gap: 6px; min-width: 0; }

.text > span {
  font-size: 14px;
  font-weight: 500;
}

.text input,
.text select,
.text textarea {
  width: 100%;
  font: 400 16px/1.4 var(--font-body);
  color: var(--ink);
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 0;
  padding: 11px 12px;
  min-height: 46px;
}

.text textarea { resize: vertical; min-height: 96px; }

.text input:hover,
.text select:hover,
.text textarea:hover { border-color: var(--muted); }

.text input:focus,
.text select:focus,
.text textarea:focus { border-color: var(--blue); outline: none; box-shadow: 0 0 0 3px var(--soft); }

.text .note { font-size: 13px; color: var(--muted); }

/* Segmented choices */
.seg {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(104px, 1fr));
  gap: 8px;
}

.seg-sm { grid-template-columns: repeat(auto-fill, minmax(88px, 1fr)); }

.seg button {
  display: grid;
  justify-items: center;
  gap: 6px;
  padding: 12px 8px 10px;
  background: var(--white);
  border: 1px solid var(--line);
  color: var(--ink);
  font: 500 13px/1.2 var(--font-body);
  cursor: pointer;
  transition: border-color .15s, background .15s;
}

.seg button:hover { border-color: var(--ink); }

.seg button[aria-checked="true"] {
  border-color: var(--blue);
  background: var(--soft);
  box-shadow: inset 0 0 0 1px var(--blue);
}

.seg svg { width: 34px; height: 34px; display: block; }

.seg-sm button { padding: 10px 8px; }

/* Presets */
.presets {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(92px, 1fr));
  gap: 10px;
}

.preset {
  display: grid;
  gap: 6px;
  padding: 8px;
  background: var(--white);
  border: 1px solid var(--line);
  cursor: pointer;
  font: 500 12px/1.2 var(--font-body);
  color: var(--ink);
  text-align: left;
  transition: border-color .15s, transform .15s;
}

.preset:hover { border-color: var(--ink); transform: translateY(-2px); }

.preset .swatch {
  aspect-ratio: 1;
  width: 100%;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
}

.preset .swatch span {
  width: 56%;
  aspect-ratio: 1;
  border-radius: 6px;
}

/* Color, range, checkbox */
.color {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  cursor: pointer;
}

.color input {
  width: 46px;
  height: 46px;
  padding: 3px;
  border: 1px solid var(--line);
  background: var(--white);
  cursor: pointer;
}

.range {
  display: grid;
  gap: 6px;
  font-size: 14px;
  flex: 1 1 180px;
  min-width: 0;
}

.range span { display: flex; justify-content: space-between; gap: 8px; }

.range output { color: var(--muted); font-variant-numeric: tabular-nums; }

.range input { width: 100%; accent-color: var(--blue); height: 46px; margin: 0; }

.check {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  min-height: 46px;
  cursor: pointer;
}

.check input { width: 18px; height: 18px; accent-color: var(--blue); margin: 0; }

.hint { font-size: 14px; color: var(--muted); align-self: center; }

/* Buttons: square, hover turns blue and lifts 2px */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 46px;
  padding: 0 20px;
  border: 1px solid var(--ink);
  border-radius: 0;
  font: 700 13px/1 var(--font-body);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
  text-decoration: none;
  transition: background .15s, border-color .15s, color .15s, transform .15s;
}

.btn:hover:not(:disabled) {
  background: var(--blue);
  border-color: var(--blue);
  color: var(--white);
  transform: translateY(-2px);
}

.btn:disabled { opacity: .45; cursor: not-allowed; }

.btn-primary { background: var(--blue); border-color: var(--blue); color: var(--white); }
.btn-primary:hover:not(:disabled) { background: var(--ink); border-color: var(--ink); }
.btn-dark { background: var(--ink); color: var(--white); }
.btn-ghost { background: var(--white); color: var(--ink); border-color: var(--line); }

.file-btn { cursor: pointer; }

.link-btn {
  background: none;
  border: 0;
  padding: 4px 0;
  font: 500 14px/1.4 var(--font-body);
  color: var(--blue);
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
}

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

/* Preview */
.preview {
  position: sticky;
  top: 24px;
  min-width: 0;
}

.preview-card {
  background: var(--white);
  border: 1px solid var(--line);
  display: grid;
  grid-template-columns: minmax(0, 1fr);
}

.stage {
  aspect-ratio: 1;
  max-width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  padding: 32px;
  border-bottom: 1px solid var(--line);
  background-color: var(--white);
  background-image:
    linear-gradient(45deg, #EEEEE8 25%, transparent 25%),
    linear-gradient(-45deg, #EEEEE8 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #EEEEE8 75%),
    linear-gradient(-45deg, transparent 75%, #EEEEE8 75%);
  background-size: 20px 20px;
  background-position: 0 0, 0 10px, 10px -10px, -10px 0;
}

.stage img {
  max-width: 100%;
  max-height: 100%;
  min-height: 0;
  object-fit: contain;
  display: block;
}

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

.check-list {
  display: grid;
  gap: 8px;
  padding: 18px 24px;
  border-bottom: 1px solid var(--line);
  font-size: 14px;
}

.check-item {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 10px;
  align-items: start;
}

.check-item .pill {
  font: 700 11px/1 var(--font-body);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 5px 7px;
  border: 1px solid currentColor;
  white-space: nowrap;
}

.check-item.ok .pill { color: var(--ok); }
.check-item.warn .pill { color: var(--warn); }
.check-item.bad .pill { color: var(--bad); }

.check-meta { color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }

.export { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; padding: 22px 24px 24px; }

.download-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.download-row .btn-primary { grid-column: 1 / -1; }

.small-actions { gap: 6px 20px; }

.raw {
  margin: 0;
  padding: 12px;
  background: var(--paper);
  border: 1px solid var(--line);
  font: 13px/1.5 ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  white-space: pre-wrap;
  word-break: break-all;
  max-height: 220px;
  overflow: auto;
}

.toast {
  margin: 0;
  min-height: 1.4em;
  font-size: 14px;
  color: var(--ok);
}

.toast.error { color: var(--bad); }

/* Save box in the preview card */
.save-box {
  display: grid;
  gap: 8px;
  padding: 18px 24px;
  border-bottom: 1px solid var(--line);
  background: var(--paper);
}

.save-box .btn { white-space: nowrap; }

.save-meta { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 4px 16px; }

.save-status { margin: 0; font-size: 13px; color: var(--muted); min-width: 0; overflow-wrap: anywhere; }

.save-status.dirty { color: var(--warn); }

/* My codes library */
.library {
  padding-block: 70px 30px;
  border-top: 1px solid var(--line);
  display: grid;
  gap: 24px;
}

.lib-head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: flex-end;
  gap: 18px 30px;
}

.lib-head h2 {
  font-size: clamp(36px, 4vw, 58px);
  font-weight: 500;
  letter-spacing: -0.055em;
  margin-bottom: 10px;
}

.lib-count {
  font-size: 0.45em;
  letter-spacing: 0;
  color: var(--muted);
  vertical-align: middle;
  font-variant-numeric: tabular-nums;
}

.lib-head p { margin: 0; color: var(--muted); max-width: 60ch; }

.lib-tools { display: flex; flex-wrap: wrap; gap: 8px; }

.lib-search { max-width: 420px; }

.lib-empty {
  border: 1px dashed var(--line);
  background: var(--white);
  padding: 28px;
}

.lib-empty p { margin: 0; max-width: 62ch; color: var(--muted); }
.lib-empty strong { color: var(--ink); }

.lib-note { margin: 0; color: var(--muted); }

.lib-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 20px;
}

.code-card {
  background: var(--white);
  border: 1px solid var(--line);
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto 1fr auto;
  min-width: 0;
  transition: transform .2s, border-color .2s;
}

.code-card:hover { transform: translateY(-5px); }

.code-card.is-open { border-color: var(--blue); box-shadow: inset 0 0 0 1px var(--blue); }

.code-thumb {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-width: 0;
  overflow: hidden;
  aspect-ratio: 1;
  max-width: 100%;
  padding: 22px;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: var(--paper);
  cursor: pointer;
}

.code-thumb img { width: 100%; height: 100%; object-fit: contain; display: block; }

.code-body { padding: 16px 18px 6px; display: grid; gap: 4px; align-content: start; min-width: 0; }

.code-name {
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -0.02em;
  overflow-wrap: anywhere;
}

.code-meta { margin: 0; display: flex; flex-wrap: wrap; gap: 4px 8px; font-size: 14px; color: var(--muted); min-width: 0; }

.code-type {
  font: 700 11px/1 var(--font-body);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--blue);
  border: 1px solid currentColor;
  padding: 4px 6px;
  align-self: center;
}

.code-summary { overflow-wrap: anywhere; min-width: 0; }

.code-date { margin: 0; font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }

.code-actions { display: flex; flex-wrap: wrap; gap: 4px 14px; padding: 10px 18px 16px; align-items: baseline; }

.link-btn.danger { color: var(--bad); }

.confirm-text { font-size: 14px; font-weight: 500; }

/* How it works */
.how {
  padding-block: 70px 90px;
  border-top: 1px solid var(--line);
}

.how > h2 {
  font-size: clamp(36px, 4vw, 58px);
  font-weight: 500;
  letter-spacing: -0.055em;
  margin-bottom: 36px;
}

.how-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 26px;
}

.how-grid article {
  background: var(--white);
  border: 1px solid var(--line);
  padding: 28px;
  transition: transform .2s;
}

.how-grid article:hover { transform: translateY(-5px); }

.how-grid h3 { font-size: 21px; font-weight: 600; letter-spacing: -0.02em; margin-bottom: 10px; }

.how-grid p { margin: 0; color: var(--muted); max-width: 60ch; }

/* Footer */
.site-footer { border-top: 1px solid var(--line); }

.footer-inner {
  padding-block: 32px;
  display: grid;
  gap: 6px;
  font-size: 14px;
}

.footer-inner p { margin: 0; }

.muted { color: var(--muted); }

/* Keep the code in view while editing on laptop-height screens: the preview card
   never exceeds the viewport, the stage shrinks first, and the export area scrolls. */
@media (min-width: 1001px) {
  .preview-card { max-height: calc(100vh - 48px); overflow-y: auto; }
  .stage { aspect-ratio: auto; height: min(440px, 50vh); padding: 24px; }
}

/* Responsive: Apps breakpoints 1000px and 720px */
@media (max-width: 1000px) {
  :root { --pad: 30px; }
  .hero { grid-template-columns: 1fr; gap: 36px; padding-block: 56px 40px; }
  .builder { grid-template-columns: 1fr; padding-block: 0 60px; }
  .preview { position: static; order: -1; }
  .how-grid { grid-template-columns: 1fr; }
}

@media (max-width: 720px) {
  :root { --pad: 22px; }
  .header-inner { height: 79px; }
  .header-nav { display: none; }
  .header-inner { gap: 12px; }
  .install-btn { padding: 0 12px; min-height: 36px; }
}

/* On narrow phones, make room for the install button by dropping the APPS label. */
@media (max-width: 440px) {
  .header-inner:has(#install:not([hidden])) .lockup-divider,
  .header-inner:has(#install:not([hidden])) .lockup-label { display: none; }
  .panel { padding: 20px; }
  .fields { grid-template-columns: 1fr; }
  .how { padding-block: 60px; }
  .library { padding-block: 56px 20px; }
  .save-box { padding: 16px 20px; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { transition: none !important; }
  .btn:hover:not(:disabled), .preset:hover, .how-grid article:hover, .code-card:hover { transform: none; }
}

/* Product lockup uses the supplied mark beside the unchanged master logo. */
.lockup-label{display:flex;align-items:center;gap:8px;white-space:nowrap}.lockup .product-mark{width:24px;height:24px}.lockup{flex-shrink:0}@media(max-width:440px){.lockup-label{font-size:12px}.lockup{gap:12px}.lockup-divider{margin:0}}
