:root {
  --paper: #f4f1ea;
  --paper-2: #ebe6db;
  --surface: #fbfaf6;
  --ink: #16150f;
  --ink-2: #4a473f;
  --ink-3: #8a857a;
  --rule: #d9d3c5;
  --rule-strong: #b9b2a2;
  --accent: #b8432a;
  --shadow: 0 1px 0 rgba(22, 21, 15, .04), 0 12px 32px -12px rgba(22, 21, 15, .18);

  --serif: "Instrument Serif", "Iowan Old Style", Georgia, serif;
  --sans: "Geist", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "Geist Mono", ui-monospace, "SF Mono", Menlo, monospace;

  --radius: 6px;
  --gutter: clamp(16px, 4vw, 48px);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #12120f;
    --paper-2: #1b1a16;
    --surface: #1d1c18;
    --ink: #edeae2;
    --ink-2: #b7b2a6;
    --ink-3: #7c776c;
    --rule: #2d2c27;
    --rule-strong: #46443d;
    --accent: #e0694d;
    --shadow: 0 1px 0 rgba(0, 0, 0, .3), 0 18px 40px -16px rgba(0, 0, 0, .6);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #12120f;
  --paper-2: #1b1a16;
  --surface: #1d1c18;
  --ink: #edeae2;
  --ink-2: #b7b2a6;
  --ink-3: #7c776c;
  --rule: #2d2c27;
  --rule-strong: #46443d;
  --accent: #e0694d;
  --shadow: 0 1px 0 rgba(0, 0, 0, .3), 0 18px 40px -16px rgba(0, 0, 0, .6);
  color-scheme: dark;
}

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

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 400 15px/1.55 var(--sans);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: "ss01", "cv11";
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

::selection { background: var(--ink); color: var(--paper); }

button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
fieldset { border: 0; margin: 0; padding: 0; min-width: 0; }

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

/* ── Masthead ─────────────────────────────────────────── */

.masthead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 22px var(--gutter);
  border-bottom: 1px solid var(--rule);
}

.wordmark {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  text-decoration: none;
  font-family: var(--serif);
  font-size: 26px;
  line-height: 1;
  letter-spacing: -.01em;
}
.wordmark svg { width: 15px; height: 15px; fill: currentColor; transform: translateY(-1px); }

.masthead-note {
  margin: 0;
  font: 400 12px/1 var(--mono);
  color: var(--ink-3);
  letter-spacing: .02em;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.masthead-note::before {
  content: "";
  width: 6px; height: 6px;
  border-radius: 50%;
  background: #4f8a5b;
  box-shadow: 0 0 0 3px color-mix(in srgb, #4f8a5b 18%, transparent);
}

/* ── Sheet ────────────────────────────────────────────── */

.sheet {
  flex: 1;
  width: 100%;
  max-width: 1240px;
  margin: 0 auto;
  padding: 0 var(--gutter);
}

.intro {
  padding: clamp(48px, 8vw, 96px) 0 clamp(36px, 5vw, 56px);
  border-bottom: 1px solid var(--rule);
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr);
  column-gap: 64px;
  align-items: end;
}

.intro h1 {
  grid-row: span 2;
  margin: 0;
  font: 400 clamp(54px, 9vw, 128px)/.9 var(--serif);
  letter-spacing: -.035em;
}
.intro h1 em { font-style: italic; color: var(--ink-2); padding-right: .04em; }

.lede {
  margin: 0 0 20px;
  max-width: 40ch;
  color: var(--ink-2);
  font-size: 17px;
  line-height: 1.55;
  text-wrap: pretty;
}

.meta {
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  font: 400 12px/1.4 var(--mono);
  color: var(--ink-3);
  letter-spacing: .01em;
}
.meta span:not(:last-child)::after { content: "/"; margin: 0 10px; color: var(--rule-strong); }

/* ── Workspace ────────────────────────────────────────── */

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 440px);
  grid-template-areas:
    "destination preview"
    "options     preview";
  grid-template-rows: auto 1fr;
  column-gap: clamp(40px, 6vw, 96px);
  padding: 48px 0 96px;
}

.destination { grid-area: destination; padding-bottom: 40px; border-bottom: 1px solid var(--rule); }
.options { grid-area: options; }
.preview {
  grid-area: preview;
  align-self: start;
  position: sticky;
  top: 24px;
}

.label {
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin: 0 0 14px;
  padding: 0;
  font: 500 12px/1 var(--mono);
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--ink);
  width: 100%;
}
.num { color: var(--accent); font-weight: 400; }
.label-value { margin-left: auto; color: var(--ink-3); font-weight: 400; }

.hint {
  margin: 12px 0 0;
  font-size: 13px;
  color: var(--ink-3);
  max-width: 52ch;
}
.hint strong { color: var(--ink-2); font-weight: 500; font-family: var(--mono); font-size: 12px; word-break: break-all; }

/* Destination field */

.field {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  border-bottom: 2px solid var(--ink);
  transition: border-color .2s;
}
.field:focus-within { border-color: var(--accent); }

.field input {
  flex: 1;
  min-width: 0;
  padding: 10px 0 14px;
  border: 0;
  background: transparent;
  font: 400 clamp(20px, 2.4vw, 28px)/1.2 var(--sans);
  letter-spacing: -.015em;
  outline: none;
}
.field input::placeholder { color: var(--ink-3); opacity: .55; }

.field-clear {
  flex: none;
  display: grid;
  place-items: center;
  width: 28px; height: 28px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--ink-3);
}
.field-clear:hover { background: var(--paper-2); color: var(--ink); }
.field-clear svg { width: 14px; height: 14px; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; fill: none; }

/* Options */

.options fieldset { padding: 32px 0; border-bottom: 1px solid var(--rule); }
/* Floating the legend takes it out of the fieldset border so it lays out like a normal label. */
.options legend { float: left; }
.options legend + * { clear: both; }
.options fieldset:last-child { border-bottom: 0; }

/* Segmented control */

.seg {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  gap: 2px;
  padding: 3px;
  background: var(--paper-2);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
}
.seg label { position: relative; display: block; }
.seg input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; }
.seg span {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 40px;
  padding: 0 10px;
  border-radius: 4px;
  font-size: 14px;
  font-weight: 500;
  color: var(--ink-2);
  white-space: nowrap;
  transition: background .15s, color .15s, box-shadow .15s;
  pointer-events: none;
}
.seg span small { font: 400 11px/1 var(--mono); color: var(--ink-3); }
.seg label:hover span { color: var(--ink); }
.seg input:checked + span {
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 0 0 1px var(--rule), 0 1px 2px rgba(0, 0, 0, .06);
}
.seg input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 1px; }
.glyph { width: 14px; height: 14px; fill: currentColor; }

.seg-sm span { height: 34px; font: 500 12px/1 var(--mono); }

/* Colour */

.swatches { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 20px; }
.swatch {
  position: relative;
  width: 40px; height: 40px;
  padding: 0;
  border: 1px solid var(--rule);
  border-radius: 50%;
  overflow: hidden;
  background: var(--bg);
  transition: transform .15s;
}
.swatch::before {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--fg);
  clip-path: polygon(0 0, 100% 0, 0 100%);
}
.swatch:hover { transform: translateY(-1px); }
.swatch[aria-checked="true"] { box-shadow: 0 0 0 2px var(--paper), 0 0 0 3.5px var(--ink); }

.colors { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.color {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 46px;
  padding: 0 12px 0 14px;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  background: var(--surface);
}
.color:focus-within { border-color: var(--rule-strong); }
.color-name { font: 500 11px/1 var(--mono); text-transform: uppercase; letter-spacing: .08em; color: var(--ink-3); width: 44px; }
.color-chip {
  position: relative;
  flex: none;
  width: 22px; height: 22px;
  border-radius: 4px;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .12);
  overflow: hidden;
}
.color-chip input { position: absolute; inset: -8px; width: calc(100% + 16px); height: calc(100% + 16px); border: 0; padding: 0; cursor: pointer; opacity: 0; }
.color-hex {
  flex: 1;
  min-width: 0;
  border: 0;
  background: transparent;
  font: 400 14px/1 var(--mono);
  text-transform: uppercase;
  outline: none;
}

.check {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin-top: 18px;
  font-size: 14px;
  color: var(--ink-2);
  cursor: pointer;
  user-select: none;
}
.check input { position: absolute; opacity: 0; pointer-events: none; }
.check-box {
  width: 18px; height: 18px;
  border: 1px solid var(--rule-strong);
  border-radius: 4px;
  background: var(--surface);
  display: grid;
  place-items: center;
  transition: background .15s, border-color .15s;
}
.check-box::after {
  content: "";
  width: 9px; height: 5px;
  border: 1.75px solid var(--paper);
  border-top: 0; border-right: 0;
  transform: translateY(-1px) rotate(-45deg) scale(0);
  transition: transform .15s;
}
.check input:checked + .check-box { background: var(--ink); border-color: var(--ink); }
.check input:checked + .check-box::after { transform: translateY(-1px) rotate(-45deg) scale(1); }
.check input:focus-visible + .check-box { outline: 2px solid var(--accent); outline-offset: 2px; }

.warn {
  margin: 16px 0 0;
  padding: 10px 12px 10px 14px;
  border-left: 2px solid var(--accent);
  background: color-mix(in srgb, var(--accent) 8%, transparent);
  font-size: 13px;
  color: var(--ink-2);
}

/* Range */

.range {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 24px;
  margin: 4px 0 0;
  background: transparent;
  cursor: pointer;
  --fill: 50%;
}
.range::-webkit-slider-runnable-track {
  height: 2px;
  background: linear-gradient(to right, var(--ink) var(--fill), var(--rule) var(--fill));
}
.range::-moz-range-track { height: 2px; background: var(--rule); }
.range::-moz-range-progress { height: 2px; background: var(--ink); }
.range::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px; height: 18px;
  margin-top: -8px;
  border-radius: 50%;
  background: var(--surface);
  border: 1.5px solid var(--ink);
  transition: transform .15s;
}
.range::-moz-range-thumb {
  width: 16px; height: 16px;
  border-radius: 50%;
  background: var(--surface);
  border: 1.5px solid var(--ink);
}
.range:active::-webkit-slider-thumb { transform: scale(1.12); }

/* ── Preview ──────────────────────────────────────────── */

.plate {
  position: relative;
  padding: 36px;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 4px;
  box-shadow: var(--shadow);
}

.crop { position: absolute; width: 14px; height: 14px; border-color: var(--rule-strong); border-style: solid; border-width: 0; }
.crop.tl { top: 12px; left: 12px; border-top-width: 1px; border-left-width: 1px; }
.crop.tr { top: 12px; right: 12px; border-top-width: 1px; border-right-width: 1px; }
.crop.bl { bottom: 12px; left: 12px; border-bottom-width: 1px; border-left-width: 1px; }
.crop.br { bottom: 12px; right: 12px; border-bottom-width: 1px; border-right-width: 1px; }

.qr {
  aspect-ratio: 1;
  border-radius: 2px;
  overflow: hidden;
  transition: opacity .35s ease, filter .35s ease;
}
.qr svg { display: block; width: 100%; height: 100%; }
.qr.is-transparent {
  background:
    repeating-conic-gradient(var(--paper-2) 0 25%, transparent 0 50%) 0 0 / 16px 16px;
}

.plate-empty {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  margin: 0;
  font: italic 400 24px/1.2 var(--serif);
  color: var(--ink-2);
  pointer-events: none;
  opacity: 0;
  transition: opacity .35s ease;
}
.plate[data-empty="true"] .qr { opacity: .07; filter: blur(.4px); }
.plate[data-empty="true"] .plate-empty { opacity: 1; }

.caption {
  margin: 16px 2px 0;
  font: 400 12px/1.4 var(--mono);
  color: var(--ink-3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.specs {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  margin: 20px 0 0;
  border-top: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
}
.specs div { padding: 12px 0 12px 12px; border-left: 1px solid var(--rule); }
.specs div:first-child { border-left: 0; padding-left: 2px; }
.specs dt { font: 500 10px/1 var(--mono); text-transform: uppercase; letter-spacing: .08em; color: var(--ink-3); }
.specs dd { margin: 8px 0 0; font: 400 15px/1 var(--mono); color: var(--ink); font-variant-numeric: tabular-nums; }

.export { display: grid; gap: 10px; margin-top: 24px; }
.export-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr); gap: 10px; }

/* Buttons */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 42px;
  padding: 0 18px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 500;
  letter-spacing: -.005em;
  white-space: nowrap;
  transition: background .15s, color .15s, border-color .15s, transform .1s;
}
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { cursor: not-allowed; opacity: .4; }
.btn svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }

.btn-primary { background: var(--ink); color: var(--paper); }
.btn-primary:hover:not(:disabled) { background: color-mix(in srgb, var(--ink) 86%, var(--paper)); }

.btn-secondary { background: var(--surface); border-color: var(--rule-strong); color: var(--ink); }
.btn-secondary:hover:not(:disabled) { border-color: var(--ink); }

.btn-quiet { background: transparent; color: var(--ink-2); border-color: var(--rule); }
.btn-quiet:hover:not(:disabled) { color: var(--ink); border-color: var(--rule-strong); background: var(--paper-2); }

.field .btn-quiet { height: 34px; padding: 0 14px; font-size: 13px; margin-bottom: 4px; }

/* ── Colophon & toast ─────────────────────────────────── */

.colophon {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px 24px;
  padding: 24px var(--gutter);
  border-top: 1px solid var(--rule);
  font: 400 12px/1.4 var(--mono);
  color: var(--ink-3);
}
.colophon p { margin: 0; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translate(-50%, 12px);
  padding: 11px 18px;
  border-radius: var(--radius);
  background: var(--ink);
  color: var(--paper);
  font-size: 13px;
  font-weight: 500;
  box-shadow: 0 10px 30px -10px rgba(0, 0, 0, .4);
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s, transform .2s;
}
.toast.is-on { opacity: 1; transform: translate(-50%, 0); }

/* ── Responsive ───────────────────────────────────────── */

@media (max-width: 960px) {
  .intro { grid-template-columns: 1fr; row-gap: 24px; }
  .intro h1 { grid-row: auto; }
  .workspace {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas: "destination" "preview" "options";
    grid-template-rows: none;
    padding-top: 36px;
  }
  .preview { position: static; max-width: 480px; width: 100%; margin: 40px auto 0; padding-bottom: 40px; border-bottom: 1px solid var(--rule); }
}

@media (max-width: 560px) {
  .masthead-note { font-size: 11px; }
  .plate { padding: 26px; }
  .colors { grid-template-columns: 1fr; }
  .seg span { padding: 0 6px; font-size: 13px; }
  .seg span small { display: none; }
  .export-row { grid-template-columns: 1fr; }
  .specs { grid-template-columns: repeat(2, 1fr); }
  .specs div:nth-child(3) { border-left: 0; padding-left: 2px; }
  .specs div:nth-child(n + 3) { border-top: 1px solid var(--rule); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 0s !important; }
}
