/* app.css - the editor chrome. The receipt itself is styled in receipt.css
 * so that the print window can reuse it untouched. */

/* ============================== tokens ============================== */
:root {
  color-scheme: light;

  /* Warm neutrals: the product is paper, so the chrome is paper-adjacent
   * rather than the usual cold grey. */
  --ink: #14151a;
  --ink-2: #575c66;
  --ink-3: #8a8f9a;
  --line: #e6e3dc;
  --line-2: #d3cfc6;
  --bg: #f4f2ed;
  --card: #ffffff;
  --sunk: #faf9f6;

  /* One accent, warm, so it never reads as a default framework blue. */
  --accent: #a8571c;
  --accent-ink: #8c4715;
  --accent-soft: #fbf1e7;
  --accent-line: #e9d3bd;
  --danger: #ad2b20;

  /* The desk the paper sits on. Light in light mode so the white receipt
   * still reads as the brightest thing on screen. */
  --stage: #e4e0d8;
  --stage-2: #efece6;

  --r-sm: 6px;
  --r: 10px;
  --r-lg: 14px;
  --shadow-sm: 0 1px 2px rgba(20, 18, 14, .06);
  --shadow: 0 1px 2px rgba(20, 18, 14, .05), 0 10px 28px -8px rgba(20, 18, 14, .14);
  --shadow-lg: 0 2px 4px rgba(20, 18, 14, .06), 0 24px 60px -16px rgba(20, 18, 14, .26);

  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI Variable Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SFMono-Regular", "Cascadia Mono", Consolas, "Liberation Mono", monospace;

  --topbar-h: 58px;
}

/* Dark appearance. `auto` follows the system, the toggle stamps data-theme
 * on <html> and that always wins over the media query. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    /* color-scheme also switches the native widgets: scrollbars, the date
     * picker, and the dropdown popup that CSS cannot reach. */
    color-scheme: dark;
    --ink: #eeecea;
    --ink-2: #a9a69f;
    --ink-3: #7c7973;
    --line: #2a2926;
    --line-2: #3a3835;
    --bg: #131311;
    --card: #1b1b19;
    --sunk: #171715;
    --accent: #e0913f;
    --accent-ink: #f0ad63;
    --accent-soft: #2a2118;
    --accent-line: #43331f;
    --danger: #ef6a5c;
    --stage: #0a0a09;
    --stage-2: #171714;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .5);
    --shadow: 0 1px 2px rgba(0, 0, 0, .5), 0 10px 28px -8px rgba(0, 0, 0, .6);
    --shadow-lg: 0 2px 4px rgba(0, 0, 0, .5), 0 24px 60px -16px rgba(0, 0, 0, .7);
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --ink: #eeecea;
  --ink-2: #a9a69f;
  --ink-3: #7c7973;
  --line: #2a2926;
  --line-2: #3a3835;
  --bg: #131311;
  --card: #1b1b19;
  --sunk: #171715;
  --accent: #e0913f;
  --accent-ink: #f0ad63;
  --accent-soft: #2a2118;
  --accent-line: #43331f;
  --danger: #ef6a5c;
  --stage: #0a0a09;
  --stage-2: #171714;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .5);
  --shadow: 0 1px 2px rgba(0, 0, 0, .5), 0 10px 28px -8px rgba(0, 0, 0, .6);
  --shadow-lg: 0 2px 4px rgba(0, 0, 0, .5), 0 24px 60px -16px rgba(0, 0, 0, .7);
}

/* ============================== base ============================== */
* { box-sizing: border-box; }

html, body { margin: 0; height: 100%; }

body {
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -0.015em; }
a { color: var(--accent-ink); }

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

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    transition-duration: .001ms !important;
  }
}

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 100;
  background: var(--ink);
  color: var(--card);
  padding: 10px 16px;
  border-radius: 0 0 6px 0;
  font-size: 13px;
}
.skip-link:focus { left: 0; }

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

/* ============================== buttons ============================== */
.btn {
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  line-height: 1.2;
  padding: 8px 13px;
  border: 1px solid var(--line-2);
  background: var(--card);
  color: var(--ink);
  border-radius: var(--r-sm);
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  box-shadow: var(--shadow-sm);
  transition: background .13s ease, border-color .13s ease, transform .07s ease, box-shadow .13s ease;
}
.btn:hover { background: var(--sunk); border-color: var(--ink-3); }
.btn:active { transform: translateY(1px); box-shadow: none; }
.btn:disabled { opacity: .35; cursor: default; box-shadow: none; }
.btn:disabled:hover { background: var(--card); border-color: var(--line-2); }

.btn-primary {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--bg);
  font-weight: 600;
}
/* Opacity rather than a darker fill: the button is ink-on-paper in light mode
 * and paper-on-ink in dark, so any fixed hover colour is wrong in one of them. */
.btn-primary:hover { opacity: .85; }

.btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--ink-2);
  box-shadow: none;
}
.btn-ghost:hover { background: var(--line); border-color: transparent; color: var(--ink); }

.btn-sm { padding: 6px 10px; font-size: 12px; }
.btn-icon { padding: 8px; min-width: 32px; justify-content: center; }
.btn-group { display: flex; }
.btn-group .btn:first-child { border-radius: var(--r-sm) 0 0 var(--r-sm); }
.btn-group .btn:last-child { border-radius: 0 var(--r-sm) var(--r-sm) 0; margin-left: -1px; }

.btn-coffee {
  background: #ffdd00;
  border-color: #e8c800;
  color: #1a1508;
  font-weight: 600;
}
.btn-coffee:hover { background: #ffe740; border-color: #d9bd00; }

/* Icons drawn in CSS so the page keeps its zero-asset promise. */
.ic { width: 14px; height: 14px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }

/* ============================== topbar ============================== */
.topbar {
  display: flex;
  align-items: center;
  gap: 14px;
  height: var(--topbar-h);
  padding: 0 16px;
  background: var(--card);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 30;
}

.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }

.brand-mark {
  width: 26px;
  height: 32px;
  flex: none;
  border-radius: 2px;
  background:
    repeating-linear-gradient(to bottom, var(--ink) 0 2px, transparent 2px 5px) center/64% 56% no-repeat,
    var(--card);
  border: 1.5px solid var(--ink);
  box-shadow: 2px 2px 0 var(--ink);
}

.brand h1 { font-size: 15px; letter-spacing: -0.02em; white-space: nowrap; }
.brand-sub {
  margin: 0;
  font-size: 11.5px;
  color: var(--ink-3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar-spacer { flex: 1; }

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* The current template, shown as a quiet status chip that opens the picker. */
.doc-chip {
  font: inherit;
  font-size: 12.5px;
  color: var(--ink-2);
  background: var(--sunk);
  border: 1px solid var(--line);
  border-radius: 100px;
  padding: 5px 12px 5px 10px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  max-width: 260px;
  transition: border-color .13s ease, color .13s ease;
}
.doc-chip:hover { border-color: var(--ink-3); color: var(--ink); }
.doc-chip b { font-weight: 600; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.doc-chip .ic { width: 12px; height: 12px; color: var(--ink-3); }

/* ============================== dropdown menus ============================== */
.menu { position: relative; }
.menu-list {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  min-width: 244px;
  background: var(--card);
  border: 1px solid var(--line-2);
  border-radius: var(--r);
  box-shadow: var(--shadow-lg);
  padding: 6px;
  z-index: 40;
}
.menu-list[hidden] { display: none; }
.menu-list button,
.menu-list a {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  font: inherit;
  font-size: 13px;
  text-align: left;
  text-decoration: none;
  padding: 8px 10px;
  border: none;
  background: transparent;
  color: var(--ink);
  border-radius: var(--r-sm);
  cursor: pointer;
}
.menu-list button:hover,
.menu-list a:hover { background: var(--sunk); }
.menu-list kbd { margin-left: auto; }
.menu-list .menu-sep { height: 1px; background: var(--line); margin: 6px 4px; }
.menu-list .menu-label {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--ink-3);
  font-weight: 600;
  padding: 8px 10px 4px;
}

kbd {
  font: inherit;
  font-size: 10.5px;
  font-family: var(--mono);
  color: var(--ink-3);
  border: 1px solid var(--line-2);
  border-bottom-width: 2px;
  border-radius: 4px;
  padding: 1px 5px;
  background: var(--sunk);
  white-space: nowrap;
}

.mini {
  font: inherit;
  font-size: 13px;
  line-height: 1;
  width: 24px;
  height: 24px;
  padding: 0;
  border: 1px solid transparent;
  background: transparent;
  border-radius: 5px;
  cursor: pointer;
  color: var(--ink-3);
}
.mini:hover { background: var(--line); color: var(--ink); }
.mini-del:hover { background: transparent; border-color: var(--danger); color: var(--danger); }

/* ============================== layout ============================== */
.layout {
  display: grid;
  grid-template-columns: minmax(440px, 600px) 1fr;
  align-items: start;
  min-height: calc(100vh - var(--topbar-h));
}

.panel {
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--line);
  background: var(--bg);
  max-height: calc(100vh - var(--topbar-h));
  overflow-y: auto;
  overscroll-behavior: contain;
  position: sticky;
  top: var(--topbar-h);
}

.panel-search {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  gap: 8px;
  padding: 12px 16px;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}
.panel-search input {
  flex: 1;
  font: inherit;
  font-size: 13px;
  padding: 8px 11px;
  border: 1px solid var(--line-2);
  border-radius: var(--r-sm);
  background: var(--card);
  color: var(--ink);
}
.panel-search input::placeholder { color: var(--ink-3); }

/* ============================== sections ============================== */
.sec { border-bottom: 1px solid var(--line); }

.sec > summary {
  cursor: pointer;
  padding: 13px 16px;
  font-weight: 600;
  font-size: 13px;
  letter-spacing: -0.005em;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 9px;
  user-select: none;
  transition: background .12s ease;
}
.sec > summary::-webkit-details-marker { display: none; }
.sec > summary::before {
  content: "";
  width: 6px; height: 6px;
  flex: none;
  border-right: 1.6px solid var(--ink-3);
  border-bottom: 1.6px solid var(--ink-3);
  transform: rotate(-45deg);
  transition: transform .18s ease;
}
.sec[open] > summary::before { transform: rotate(45deg); }
.sec > summary:hover { background: var(--line); }
.sec[open] > summary { color: var(--ink); }

.sec-note {
  margin-left: auto;
  font-size: 11.5px;
  font-weight: 400;
  color: var(--ink-3);
}

.pill {
  margin-left: auto;
  background: var(--ink);
  color: var(--bg);
  font-size: 11px;
  padding: 1px 8px;
  border-radius: 20px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.sec-body { padding: 2px 16px 20px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 12px; }
.span2 { grid-column: 1 / -1; }

.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field > span {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--ink-3);
  font-weight: 600;
}
.field em { font-style: normal; color: var(--ink-2); }

.field input[type=text], .field input[type=number], .field input[type=date],
.field input[type=time], .field input[type=search], .field select, .field textarea,
.row-inline input, .split-row input, .split-row select {
  font: inherit;
  font-size: 13px;
  padding: 8px 10px;
  border: 1px solid var(--line-2);
  border-radius: var(--r-sm);
  background: var(--card);
  color: var(--ink);
  width: 100%;
  min-width: 0;
  transition: border-color .12s ease, box-shadow .12s ease;
}
.field textarea { resize: vertical; line-height: 1.5; }
.field input::placeholder, .field textarea::placeholder { color: var(--ink-3); }

.field input:focus, .field select:focus, .field textarea:focus,
.panel-search input:focus, .row-inline input:focus,
.items input:focus, .items select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.field input[type=color] {
  width: 100%;
  height: 34px;
  padding: 2px;
  border: 1px solid var(--line-2);
  border-radius: var(--r-sm);
  background: var(--card);
  cursor: pointer;
}
.field input[type=range] {
  width: 100%;
  accent-color: var(--accent);
  height: 20px;
}

.check {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 13px;
  color: var(--ink-2);
  padding: 5px 0;
  cursor: pointer;
}
.check:hover { color: var(--ink); }
.check input { accent-color: var(--accent); width: 15px; height: 15px; flex: none; }

.row-inline { display: flex; gap: 6px; align-items: center; }
.row-inline input[type=file] { font-size: 12px; color: var(--ink-2); }

.hint {
  font-size: 12px;
  color: var(--ink-3);
  margin: 12px 0 0;
  line-height: 1.55;
}

.dim { opacity: .25; }

/* ---------------- wear and photo ---------------- */
.pill-soft {
  background: color-mix(in srgb, var(--ink) 12%, transparent);
  color: var(--ink-2);
  text-transform: uppercase;
  letter-spacing: .06em;
}

.sub-h {
  margin: 20px 0 10px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--ink-3);
  font-weight: 700;
}

.looks {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 14px;
}

.look {
  font: inherit;
  font-size: 12px;
  padding: 6px 11px;
  border: 1px solid var(--line-2);
  border-radius: 20px;
  background: var(--card);
  color: var(--ink-2);
  cursor: pointer;
  transition: border-color .12s ease, color .12s ease, background .12s ease;
}
.look:hover {
  border-color: color-mix(in srgb, var(--ink) 40%, transparent);
  color: var(--ink);
}
.look.on {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--bg);
}

.surfaces {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin: 12px 0 4px;
}

.surface {
  font: inherit;
  padding: 0;
  border: 1px solid var(--line-2);
  border-radius: var(--r-sm);
  background: var(--card);
  color: var(--ink-2);
  cursor: pointer;
  overflow: hidden;
  text-align: left;
  transition: border-color .12s ease, color .12s ease;
}
.surface:hover { border-color: color-mix(in srgb, var(--ink) 40%, transparent); }
.surface.on { border-color: var(--ink); color: var(--ink); }

.surface-swatch {
  display: block;
  height: 54px;
  background-size: cover;
  background-position: center;
}
.surface-name {
  display: block;
  padding: 6px 8px;
  font-size: 11px;
  letter-spacing: .02em;
}

/* The camera controls stay visible when staging is off, they just stop
   pretending to do anything. */
#photoFields { margin-top: 12px; transition: opacity .15s ease; }
#photoFields.is-off { opacity: .38; pointer-events: none; }

/* ============================== item editor ============================== */
.items-head { display: flex; gap: 8px; margin: 8px 0 12px; flex-wrap: wrap; }
.quick-add {
  font: inherit;
  font-size: 12px;
  padding: 6px 9px;
  border: 1px solid var(--line-2);
  border-radius: var(--r-sm);
  background: var(--card);
  color: var(--ink);
  flex: 1;
  min-width: 150px;
}

.items-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--card);
  box-shadow: var(--shadow-sm);
}

table.items {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  min-width: 500px;
  table-layout: fixed;
}
/* Fixed widths so the Total column stays visible without a scrollbar.
 * Column 2 (the item) is left to absorb whatever is left over. */
table.items th:nth-child(1), table.items td:nth-child(1) { width: 20px; }
table.items th:nth-child(3), table.items td:nth-child(3) { width: 92px; }
table.items th:nth-child(4), table.items td:nth-child(4) { width: 56px; }
table.items th:nth-child(5), table.items td:nth-child(5) { width: 64px; }
table.items th:nth-child(6), table.items td:nth-child(6) { width: 44px; }
table.items th:nth-child(7), table.items td:nth-child(7) { width: 64px; }
table.items th:nth-child(8), table.items td:nth-child(8) { width: 74px; }

.i-sub { display: flex; gap: 4px; margin-top: 2px; }
.i-sub .i-sku { flex: 0 0 72px; }
.i-sub .i-note { flex: 1 1 auto; min-width: 0; }
.i-sub input { font-size: 11px !important; color: var(--ink-3); }

/* The flex lives on an inner div: a display:flex <td> would drop out of the
 * table layout and misalign every column after it. */
.qty-pair { display: flex; gap: 3px; }
.qty-pair .i-num { flex: 1 1 34px; min-width: 0; }
.qty-pair .i-unit { flex: 0 0 42px; padding-left: 3px; padding-right: 0; }

table.items th {
  text-align: left;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--ink-3);
  font-weight: 600;
  padding: 9px 6px;
  border-bottom: 1px solid var(--line);
  background: var(--sunk);
  position: sticky;
  top: 0;
  z-index: 1;
}
table.items td { padding: 5px 5px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.items tr:last-child td { border-bottom: none; }
table.items tr:hover td { background: var(--sunk); }

table.items input, table.items select {
  font: inherit;
  font-size: 12px;
  padding: 6px 7px;
  border: 1px solid transparent;
  border-radius: 5px;
  background: transparent;
  color: var(--ink);
  width: 100%;
  min-width: 0;
  transition: background .12s ease, border-color .12s ease;
}
table.items input:hover, table.items select:hover { background: var(--bg); }
.i-num { text-align: right; font-variant-numeric: tabular-nums; }
/* The spinners eat 15px of a 44px column, which clips two digit rates. */
table.items input[type=number] { -moz-appearance: textfield; appearance: textfield; }
table.items input[type=number]::-webkit-outer-spin-button,
table.items input[type=number]::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.c-h { width: 22px; }
.c-disc select { margin-bottom: 3px; }
.c-total {
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  white-space: nowrap;
  padding-top: 12px !important;
}
.c-act { white-space: nowrap; text-align: right; }
.drag { cursor: grab; color: var(--ink-3); display: inline-block; padding-top: 7px; }
.item-row.dragging { opacity: .35; }
.item-row.drop-target td { box-shadow: inset 0 2px 0 var(--accent); }
.item-row.voided td input, .item-row.voided td select { text-decoration: line-through; opacity: .5; }

/* ============================== split payments ============================== */
.split-list { display: flex; flex-direction: column; gap: 6px; margin-bottom: 8px; }
.split-row { display: grid; grid-template-columns: 1fr 1fr 92px 24px; gap: 6px; align-items: center; }

/* ============================== library ============================== */
.library { list-style: none; margin: 12px 0 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.library li {
  display: grid;
  grid-template-columns: 1fr auto auto auto;
  gap: 8px;
  align-items: center;
  padding: 8px 10px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  font-size: 13px;
}
.library .lib-date { font-size: 11px; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.library .empty { color: var(--ink-3); font-size: 12px; border-style: dashed; display: block; }

/* ============================== danger zone ============================== */
.danger {
  margin: 24px 16px 0;
  border: 1px solid color-mix(in srgb, var(--danger) 32%, transparent);
  border-radius: var(--r);
  padding: 15px;
  background: color-mix(in srgb, var(--danger) 6%, transparent);
}
.danger h3 { font-size: 11px; text-transform: uppercase; letter-spacing: .07em; color: var(--danger); }
.danger p { font-size: 12px; color: var(--ink-2); line-height: 1.55; margin: 7px 0 13px; }

.btn-hold {
  position: relative;
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  padding: 9px 16px;
  border: 1px solid var(--danger);
  color: var(--danger);
  background: var(--card);
  border-radius: var(--r-sm);
  cursor: pointer;
  overflow: hidden;
  --hold: 0%;
}
.btn-hold .hold-ring {
  position: absolute;
  inset: 0;
  background: var(--danger);
  width: var(--hold);
  transition: width .05s linear;
}
.btn-hold .hold-label { position: relative; z-index: 1; }
.btn-hold.holding .hold-label { color: #fff; mix-blend-mode: difference; }

/* ============================== support nudge ============================== */
/* Shown after a successful export, when the tool has already paid off.
 * A permanent banner in the toolbar just becomes furniture. */
.nudge {
  margin: 24px 16px 0;
  border: 1px solid var(--accent-line);
  background: var(--accent-soft);
  border-radius: var(--r);
  padding: 16px;
}
.nudge[hidden] { display: none; }
.nudge h3 { font-size: 13.5px; margin-bottom: 6px; }
.nudge p { margin: 0 0 13px; font-size: 12.5px; line-height: 1.6; color: var(--ink-2); }
.nudge-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
/* The address in plain text as well as the button: a mailto does nothing on a
 * machine with no mail client, and people copy addresses more than they click. */
.nudge-mail { margin: 12px 0 0; font-size: 11.5px; color: var(--ink-3); }
.nudge-mail a { color: var(--ink-2); }

/* ============================== preview ============================== */
.preview {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: calc(100vh - var(--topbar-h));
  background: var(--stage);
}

.preview-bar {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 0 20px;
  height: 52px;
  border-bottom: 1px solid color-mix(in srgb, var(--ink) 10%, transparent);
  color: var(--ink-2);
  font-size: 12px;
  position: sticky;
  top: var(--topbar-h);
  background: var(--stage-2);
  z-index: 10;
}

.zoom { display: flex; align-items: center; gap: 9px; flex: none; }
.zoom label { color: var(--ink-3); }
.zoom input { width: 110px; accent-color: var(--accent); }
.zoom output { font-variant-numeric: tabular-nums; min-width: 38px; color: var(--ink-2); }

.preview-stats {
  font-variant-numeric: tabular-nums;
  color: var(--ink-3);
  margin-left: auto;
  /* Without min-width:0 a flex item refuses to shrink below its text, and the
   * ellipsis never kicks in: the bar just pushes the page sideways instead. */
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.grand {
  flex: none;
  display: flex;
  align-items: baseline;
  gap: 9px;
  padding-left: 18px;
  border-left: 1px solid color-mix(in srgb, var(--ink) 12%, transparent);
}
.grand span {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--ink-3);
  font-weight: 600;
}
.grand b {
  font-size: 17px;
  font-weight: 650;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
}

.stage {
  --zoom: 1;
  flex: 1;
  padding: 40px 24px 90px;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  overflow: auto;
  background:
    radial-gradient(ellipse 120% 80% at 50% -10%, var(--stage-2) 0%, var(--stage) 62%);
}
.stage > div {
  transform: scale(var(--zoom));
  transform-origin: top center;
  transition: transform .12s ease;
}

/* ============================== start / template picker ============================== */
.start {
  position: fixed;
  inset: 0;
  z-index: 70;
  background: var(--bg);
  overflow-y: auto;
  padding: 0 24px 64px;
}
.start[hidden] { display: none; }
body.start-open { overflow: hidden; }

.start-inner { max-width: 1080px; margin: 0 auto; }

.start-head {
  padding: 72px 0 40px;
  max-width: 640px;
}
.start-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--accent-ink);
  background: var(--accent-soft);
  border: 1px solid var(--accent-line);
  border-radius: 100px;
  padding: 5px 12px;
  margin: 0 0 22px;
}
.start-head h2 {
  font-size: clamp(30px, 4.6vw, 44px);
  line-height: 1.08;
  letter-spacing: -0.035em;
  margin: 0 0 16px;
  font-weight: 640;
}
.start-head p {
  margin: 0;
  font-size: 16px;
  line-height: 1.6;
  color: var(--ink-2);
  max-width: 54ch;
}

.start-trust {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 10px 22px;
  margin: 26px 0 0;
  padding: 0;
}
.start-trust li {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--ink-2);
}
.start-trust .ic { color: var(--accent); width: 15px; height: 15px; }

.start-label {
  display: flex;
  align-items: center;
  gap: 14px;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--ink-3);
  margin: 0 0 18px;
}
.start-label::after { content: ""; flex: 1; height: 1px; background: var(--line); }

.pick-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(238px, 1fr));
  gap: 16px;
}

.pick-card {
  display: flex;
  flex-direction: column;
  text-align: left;
  font: inherit;
  padding: 0;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  cursor: pointer;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  transition: transform .16s ease, box-shadow .16s ease, border-color .16s ease;
}
.pick-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow);
  border-color: var(--line-2);
}
.pick-card:active { transform: translateY(-1px); }

/* A live thumbnail: the real renderer, shrunk. Nothing to keep in sync. */
.pick-thumb {
  position: relative;
  height: 178px;
  overflow: hidden;
  background:
    radial-gradient(ellipse 120% 90% at 50% 0%, var(--stage-2) 0%, var(--stage) 70%);
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: center;
}
.pick-paper {
  display: block;
  flex: none;
  margin-top: 14px;
  transform-origin: top center;
  pointer-events: none;
}
.pick-paper .receipt { margin-bottom: 0; }
/* Fades the cut-off bottom of the paper instead of chopping it. */
.pick-thumb::after {
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 56px;
  background: linear-gradient(to bottom, transparent, var(--stage));
}

.pick-meta { padding: 13px 15px 15px; }
.pick-meta strong { display: block; font-size: 13.5px; font-weight: 600; letter-spacing: -0.01em; }
.pick-meta span { display: block; font-size: 12px; color: var(--ink-3); margin-top: 3px; line-height: 1.45; }

.start-foot {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  margin-top: 30px;
  padding-top: 24px;
  border-top: 1px solid var(--line);
}
.start-foot p { margin: 0; font-size: 12.5px; color: var(--ink-3); }

/* ============================== modal + toast ============================== */
.modal[hidden], .toast[hidden] { display: none; }

.modal {
  position: fixed;
  inset: 0;
  background: rgba(14, 13, 11, .5);
  backdrop-filter: blur(3px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 80;
  padding: 24px;
}
.modal-card {
  background: var(--card);
  border: 1px solid var(--line-2);
  border-radius: var(--r-lg);
  width: min(680px, 100%);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}
.modal-card header, .modal-card footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 13px 16px;
  border-bottom: 1px solid var(--line);
}
.modal-card footer { border-bottom: none; border-top: 1px solid var(--line); justify-content: flex-start; }
.modal-card h2 { font-size: 14px; }
#textOut {
  display: block;
  width: 100%;
  border: none;
  padding: 16px;
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.45;
  resize: vertical;
  background: var(--sunk);
  color: var(--ink);
}
#textOut:focus { outline: none; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translate(-50%, 12px);
  background: var(--ink);
  color: var(--bg);
  font-size: 13px;
  font-weight: 500;
  padding: 10px 18px;
  border-radius: 100px;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  transition: opacity .2s ease, transform .2s ease;
  z-index: 90;
  pointer-events: none;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ============================== help dialog ============================== */
.help-body { padding: 16px 18px 20px; max-height: 70vh; overflow-y: auto; font-size: 13px; line-height: 1.65; color: var(--ink-2); }
.help-body h3 { font-size: 11px; text-transform: uppercase; letter-spacing: .07em; color: var(--ink-3); margin: 20px 0 7px; }
.help-body h3:first-child { margin-top: 0; }
.help-body ul { margin: 0; padding-left: 18px; }
.help-body li { margin-bottom: 6px; }
.help-body strong { color: var(--ink); }
.help-table { border-collapse: collapse; }
.help-table td { padding: 4px 14px 4px 0; }
.help-support { margin-top: 20px; padding-top: 15px; border-top: 1px solid var(--line); }

/* ============================== mobile bottom bar ============================== */
.pane-switch { display: none; }

/* ============================== about / SEO content ============================== */
.about {
  background: var(--card);
  border-top: 1px solid var(--line);
  padding: 72px 24px 48px;
}
.about-inner {
  max-width: 1180px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(238px, 1fr));
  gap: 40px 34px;
}
.about h2 { font-size: 14px; margin-bottom: 12px; letter-spacing: -0.01em; }
.about p { color: var(--ink-2); line-height: 1.7; margin: 0 0 12px; font-size: 13px; }
.about-list { margin: 0; padding-left: 17px; color: var(--ink-2); font-size: 13px; line-height: 1.75; }
.about-list strong { color: var(--ink); font-weight: 600; }
.about code {
  font-family: var(--mono);
  font-size: 12px;
  background: var(--sunk);
  border: 1px solid var(--line);
  padding: 1px 5px;
  border-radius: 4px;
}

.faq { border-bottom: 1px solid var(--line); padding: 10px 0; }
.faq summary { cursor: pointer; font-size: 13px; font-weight: 600; list-style: none; display: flex; gap: 8px; }
.faq summary::-webkit-details-marker { display: none; }
.faq summary::before { content: "+"; color: var(--ink-3); width: 10px; flex: none; }
.faq[open] summary::before { content: "\2013"; }
.faq p { margin: 9px 0 4px; padding-left: 18px; }

.about-foot {
  max-width: 1180px;
  margin: 44px auto 0;
  padding-top: 22px;
  border-top: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}
.about-foot p { margin: 0; font-size: 12px; color: var(--ink-3); }

.about-links { list-style: none; margin: 0; padding: 0; }
.about-links li { border-bottom: 1px solid var(--line); padding: 10px 0; }
.about-links li:last-child { border-bottom: none; }
.about-links a { font-size: 13px; font-weight: 600; display: block; text-decoration: none; color: var(--ink); }
.about-links a:hover { color: var(--accent-ink); }
.about-links span { display: block; font-size: 12px; color: var(--ink-3); margin-top: 3px; line-height: 1.5; font-weight: 400; }

/* ============================== built by ============================== */
.maker {
  background: var(--bg);
  border-top: 1px solid var(--line);
  padding: 64px 24px 72px;
}
.maker-inner {
  max-width: 1180px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(0, 1.7fr) minmax(250px, 1fr);
  gap: 48px;
  align-items: start;
}
.maker-kicker {
  margin: 0 0 8px;
  font-size: 11px;
  letter-spacing: .09em;
  text-transform: uppercase;
  color: var(--ink-3);
  font-weight: 600;
}
.maker h2 { font-size: clamp(20px, 2.4vw, 26px); line-height: 1.28; margin: 0 0 16px; max-width: 26ch; letter-spacing: -0.025em; }
.maker p { color: var(--ink-2); font-size: 14px; line-height: 1.72; margin: 0 0 13px; max-width: 62ch; }
.maker-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 22px; }
.maker-mail { margin: 12px 0 0; font-size: 13px; }
.maker-mail a { color: var(--ink-2); }
.maker-facts {
  list-style: none;
  margin: 0;
  padding: 8px 18px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
}
.maker-facts li {
  display: flex;
  align-items: baseline;
  gap: 12px;
  font-size: 12.5px;
  color: var(--ink-2);
  padding: 13px 0;
  border-bottom: 1px solid var(--line);
  line-height: 1.45;
}
.maker-facts li:last-child { border-bottom: none; }
.maker-facts strong {
  flex: none;
  min-width: 40px;
  font-size: 17px;
  font-weight: 650;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}

/* ============================== responsive ============================== */
@media (max-width: 1180px) {
  .layout { grid-template-columns: minmax(400px, 500px) 1fr; }
}

@media (max-width: 1000px) {
  :root { --topbar-h: 54px; }

  .layout { grid-template-columns: 1fr; }
  .panel { position: static; max-height: none; border-right: none; padding-bottom: 90px; }
  .preview { min-height: 78vh; }
  .preview-bar { top: 0; }
  .brand-sub { display: none; }
  .doc-chip { max-width: 150px; }

  /* One pane at a time on a phone, switched from the bar at the bottom. */
  .pane-switch {
    display: flex;
    align-items: center;
    gap: 6px;
    position: fixed;
    left: 50%;
    transform: translateX(-50%);
    bottom: max(14px, env(safe-area-inset-bottom));
    z-index: 45;
    background: var(--card);
    border: 1px solid var(--line-2);
    border-radius: 100px;
    padding: 5px;
    box-shadow: var(--shadow-lg);
  }
  .pane-switch button {
    font: inherit;
    font-size: 13px;
    font-weight: 500;
    padding: 8px 18px;
    border: none;
    background: transparent;
    color: var(--ink-2);
    border-radius: 100px;
    cursor: pointer;
    white-space: nowrap;
  }
  .pane-switch button.active { background: var(--sunk); color: var(--ink); font-weight: 600; }
  .pane-switch .pane-print {
    background: var(--ink);
    color: var(--bg);
    font-weight: 600;
  }

  /* Clear the floating pane bar instead of landing on top of it. */
  .toast { bottom: calc(78px + env(safe-area-inset-bottom)); }

  body:not(.show-preview) .preview { display: none; }
  body.show-preview .panel { display: none; }
  body.show-preview .about, body.show-preview .maker { display: none; }
  .about { padding-bottom: 96px; }
}

@media (max-width: 720px) {
  /* The wordmark is the first thing to go: the actions have to fit on one
   * line or the whole page picks up a horizontal scrollbar. */
  .topbar { padding: 0 12px; gap: 8px; }
  .brand > div { display: none; }
  .topbar-actions { gap: 6px; }
  .start-eyebrow { font-size: 10px; letter-spacing: .05em; }

  .grid-2 { grid-template-columns: 1fr; }
  .stage { padding: 24px 12px 80px; }
  .sec-body { padding: 2px 14px 20px; }
  .panel-search { padding: 10px 14px; }
  .start { padding: 0 18px 56px; }
  .start-head { padding: 44px 0 32px; }
  .about { padding: 48px 18px 96px; }
  .maker { padding: 48px 18px 56px; }
  .maker-inner { grid-template-columns: 1fr; gap: 30px; }
  .about-foot { margin-top: 32px; }
  .preview-bar { padding: 0 14px; gap: 12px; }
  .zoom { display: none; }
  .grand { border-left: none; padding-left: 0; }
}

@media (max-width: 560px) {
  .doc-chip { display: none; }
  .topbar .btn-group { display: none; }
}

@media (max-width: 460px) {
  .pick-grid { grid-template-columns: 1fr; }
}

/* Wide desktops get a roomier stage rather than an endlessly wider form. */
@media (min-width: 1700px) {
  .layout { grid-template-columns: 620px 1fr; }
}
