/* NV QR Studio — a letterpress postal ticket: cream card, ink black, vermilion stamp, perforated edges. Fonts: IBM Plex (SIL OFL). */
@font-face { font-family: 'Plex Mono'; src: url('./fonts/ibm-plex-mono-latin-400-normal.woff2') format('woff2'); font-weight: 400; font-display: swap; }
@font-face { font-family: 'Plex Condensed'; src: url('./fonts/ibm-plex-sans-condensed-latin-500-normal.woff2') format('woff2'); font-weight: 500; font-display: swap; }
@font-face { font-family: 'Plex Condensed'; src: url('./fonts/ibm-plex-sans-condensed-latin-600-normal.woff2') format('woff2'); font-weight: 600; font-display: swap; }
:root {
  --desk: #2c2a26; --card: #efe9dd; --card-2: #f8f4ec; --ink: #1b1a17; --muted: #6c665b; --red: #c8402a; --line: rgba(27, 26, 23, 0.16);
  --serif: 'Iowan Old Style', 'Palatino Linotype', Palatino, Georgia, serif;
  --sans: 'Plex Condensed', 'Arial Narrow', system-ui, sans-serif; --mono: 'Plex Mono', ui-monospace, Consolas, monospace;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-height: 100vh; color: var(--ink); font: 500 16px/1.45 var(--sans); background: radial-gradient(120% 80% at 50% 0%, #3d3a34, var(--desk)) fixed; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--red); outline-offset: 2px; }
a { color: var(--red); }
.ticket {
  width: min(1000px, calc(100% - 32px)); margin: clamp(16px, 4vw, 40px) auto; padding: clamp(18px, 3vw, 30px); position: relative;
  background: radial-gradient(circle at 0 50%, transparent 0 9px, var(--card) 9.5px) left / 51% 22px repeat-y, radial-gradient(circle at 100% 50%, transparent 0 9px, var(--card) 9.5px) right / 51% 22px repeat-y;
  box-shadow: 0 30px 60px -25px rgba(0, 0, 0, 0.7); display: grid; gap: 18px; grid-template-columns: minmax(0, 1fr); border-radius: 6px;
}
.head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: end; gap: 12px; border-bottom: 2px dashed var(--line); padding-bottom: 14px; }
.brand { margin: 0; font-size: 12px; letter-spacing: 0.26em; text-transform: uppercase; color: var(--red); }
.brand span { color: var(--ink); font-weight: 600; }
h1 { margin: 2px 0 0; font: 600 clamp(24px, 4.4vw, 36px)/1.1 var(--serif); }
.modes, .types { display: inline-flex; flex-wrap: wrap; gap: 4px; }
.modes { padding: 3px; border-radius: 10px; border: 1px solid var(--line); background: var(--card-2); }
.modes button { border: 0; background: transparent; padding: 6px 16px; border-radius: 8px; cursor: pointer; font-weight: 600; color: var(--muted); }
.modes button[aria-selected='true'] { background: var(--ink); color: var(--card); }
.make { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); gap: 22px; align-items: start; }
.form { display: grid; gap: 12px; min-width: 0; }
.types button { border: 1px solid var(--line); background: var(--card-2); border-radius: 999px; padding: 5px 13px; cursor: pointer; font-weight: 600; color: var(--muted); }
.types button[aria-pressed='true'] { background: var(--red); border-color: var(--red); color: #fff; }
.fields { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.f { display: grid; gap: 3px; min-width: 0; font-size: 11px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); }
.f--wide { grid-column: 1 / -1; }
.f input, .f select, .f textarea { width: 100%; min-height: 42px; border-radius: 9px; border: 1px solid var(--line); background: #fff; padding: 7px 10px; font-size: 15px; letter-spacing: 0; text-transform: none; color: var(--ink); }
.f textarea { min-height: 96px; resize: vertical; font-family: var(--mono); font-size: 14px; }
.f input[type='color'] { padding: 3px; cursor: pointer; }
.chk { display: flex; gap: 8px; align-items: center; font-size: 14px; color: var(--ink); letter-spacing: 0; text-transform: none; }
.chk input { width: 18px; height: 18px; min-height: 0; accent-color: var(--red); }
.error { margin: 0; color: var(--red); font-weight: 600; }
.opts { border: 1px solid var(--line); border-radius: 12px; background: var(--card-2); padding: 8px 12px; }
.opts summary { cursor: pointer; font-weight: 600; }
.opts__grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px; margin-top: 10px; }
.preview { display: grid; gap: 10px; justify-items: center; position: sticky; top: 16px; }
.stamp { padding: 14px; background: #fff; border: 2px solid var(--ink); outline: 6px solid #fff; box-shadow: 0 0 0 7px var(--ink), 8px 8px 0 7px var(--red); transform: rotate(-1deg); max-width: 100%; }
.stamp canvas { display: block; width: min(320px, 72vw); height: auto; image-rendering: pixelated; }
.meta { margin: 6px 0 0; font: 400 13px var(--mono); color: var(--muted); text-align: center; }
.warn { margin: 0; color: var(--red); font-size: 14px; text-align: center; max-width: 340px; }
.acts { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.btn { min-height: 40px; padding: 0 14px; border-radius: 9px; border: 1px solid var(--line); background: var(--card-2); cursor: pointer; font-weight: 600; display: inline-flex; align-items: center; text-decoration: none; color: var(--ink); }
.btn:hover:not(:disabled) { border-color: var(--ink); }
.btn:disabled { opacity: 0.45; cursor: default; }
.btn--ink { background: var(--ink); color: var(--card); border-color: var(--ink); }
.file { position: relative; overflow: hidden; }
.file input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.scan { display: grid; gap: 14px; justify-items: center; }
.scan__view { width: min(520px, 100%); aspect-ratio: 4 / 3; background: #111; border-radius: 12px; overflow: hidden; display: grid; place-items: center; position: relative; }
.scan__view video { width: 100%; height: 100%; object-fit: cover; }
.scan__idle { color: #cfc8bb; padding: 20px; text-align: center; }
.result { width: min(520px, 100%); background: #fff; border-radius: 12px; border: 1px solid var(--line); padding: 14px; display: grid; gap: 8px; }
.result__kind { margin: 0; font-size: 12px; letter-spacing: 0.16em; text-transform: uppercase; color: var(--red); font-weight: 600; }
.result__text { margin: 0; font: 400 14px/1.5 var(--mono); white-space: pre-wrap; overflow-wrap: anywhere; max-height: 240px; overflow: auto; }
.fine { margin: 0; font-size: 12px; color: var(--muted); text-align: center; }
.foot { font-size: 12px; color: var(--muted); border-top: 2px dashed var(--line); padding-top: 12px; }
.toast { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); background: var(--ink); color: var(--card); padding: 8px 16px; border-radius: 10px; font-weight: 600; }
@media (max-width: 820px) {
  .make { grid-template-columns: minmax(0, 1fr); }
  .preview { position: static; }
  .opts__grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 480px) { .fields { grid-template-columns: minmax(0, 1fr); } .opts__grid { grid-template-columns: 1fr 1fr; } }
