:root {
  --bg: #f7f5f6;
  --surface: #ffffff;
  --text: #1c1b1f;
  --muted: #6f6a70;
  --line: #e2dee1;
  --accent: #8e2f5f;
  --accent-ink: #ffffff;
  --reward: #7a5000;
  --reward-bg: #fdf3dd;
  --danger: #a4232a;
  --dock: 5.5rem;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141216;
    --surface: #1f1c21;
    --text: #ece5ea;
    --muted: #a9a1a8;
    --line: #332e35;
    --accent: #e392bb;
    --accent-ink: #40142a;
    --reward: #f0c86a;
    --reward-bg: #322611;
  }
}

* { box-sizing: border-box; }

/* Every rule below that sets `display` on a class would otherwise beat the
   browser's own [hidden] rule, leaving hidden elements on screen. */
[hidden] { display: none !important; }

body {
  margin: 0;
  padding-bottom: calc(var(--dock) + env(safe-area-inset-bottom));
  background: var(--bg);
  color: var(--text);
  font: 1rem/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-text-size-adjust: 100%;
}

h1 { font-size: 1.5rem; margin: 0 0 0.25rem; }
h2 { font-size: 0.8125rem; text-transform: uppercase; letter-spacing: 0.06em;
     color: var(--muted); margin: 0 0 0.5rem; }
p { margin: 0 0 0.75rem; }

/* Top bar */
.bar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 0.75rem;
  padding: max(0.75rem, env(safe-area-inset-top)) 1rem 0.75rem;
  background: var(--surface); border-bottom: 1px solid var(--line);
}
.bar-title { font-weight: 600; flex: 1; min-width: 0;
             overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-back, .bar .link {
  background: none; border: 0; padding: 0.25rem 0;
  color: var(--accent); font: inherit; text-decoration: none; cursor: pointer;
}
.bar-end { margin: 0; }

.pad { padding: 1rem; }
.center-screen { text-align: center; padding-top: 2.5rem; }
.muted { color: var(--muted); }
.hint { color: var(--muted); font-size: 0.875rem; margin: 0.5rem 0 0; }
.big { font-size: 1.75rem; font-weight: 650; margin: 0.25rem 0; }
.code { font-family: ui-monospace, "SF Mono", Menlo, monospace;
        font-size: 0.8125rem; word-break: break-all; }
.error { color: var(--danger); }
.tick { font-size: 3rem; color: var(--accent); margin: 0; line-height: 1; }

/* Forms */
.field { display: block; margin: 0 0 1rem; border: 0; padding: 0; }
.field > span { display: block; font-size: 0.875rem; color: var(--muted);
                margin-bottom: 0.375rem; }
.field em { font-style: normal; opacity: 0.7; }
input:not([type="checkbox"]):not([type="radio"]), textarea {
  width: 100%; padding: 0.875rem 1rem;
  font: inherit; color: var(--text);
  background: var(--surface);
  border: 1px solid var(--line); border-radius: 0.75rem;
}
input:focus-visible, textarea:focus-visible, button:focus-visible,
a:focus-visible, .pick:focus-within, .chip:focus-within {
  outline: 2px solid var(--accent); outline-offset: 2px;
}

/* Buttons */
.primary, .secondary {
  display: flex; align-items: center; justify-content: center; gap: 0.4rem;
  min-height: 3.25rem; padding: 0 1.25rem;
  font: inherit; font-weight: 600; text-decoration: none;
  border-radius: 0.875rem; border: 1px solid transparent; cursor: pointer;
}
.primary { background: var(--accent); color: var(--accent-ink); }
.secondary { background: var(--surface); color: var(--accent);
             border-color: var(--accent); }
.primary[disabled] { opacity: 0.45; cursor: not-allowed; }
.wide { width: 100%; }

/* Bottom dock */
.dock form { width: 100%; margin: 0; }
.dock {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 6;
  padding: 0.75rem 1rem calc(0.75rem + env(safe-area-inset-bottom));
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
}

/* Lists */
.list { list-style: none; margin: 0; padding: 0;
        background: var(--surface); border-radius: 0.875rem;
        border: 1px solid var(--line); overflow: hidden; }
.list > li + li, .list > li + .row { border-top: 1px solid var(--line); }
.row { display: flex; align-items: baseline; justify-content: space-between;
       gap: 0.75rem; padding: 0.875rem 1rem;
       color: inherit; text-decoration: none; min-height: 3.25rem; }
.row-main { font-weight: 550; }
.row-sub { color: var(--muted); font-size: 0.875rem; text-align: right; }

.facts { margin: 0; }
.facts > div { display: flex; justify-content: space-between; gap: 1rem;
               padding: 0.5rem 0; border-bottom: 1px solid var(--line); }
.facts dt { color: var(--muted); font-size: 0.875rem; }
.facts dd { margin: 0; text-align: right; }

.empty { text-align: center; }
.empty .primary { margin-top: 0.75rem; }

/* Cards */
.card { margin: 0 1rem 1rem; padding: 1rem; background: var(--surface);
        border: 1px solid var(--line); border-radius: 0.875rem; }
.card-reward { background: var(--reward-bg); border-color: var(--reward); }
.card-reward .big, .card-reward h2 { color: var(--reward); }
.note { margin-top: 1.25rem; color: var(--muted); }
.note-reward { color: var(--reward); font-weight: 600; }

/* Selectable services and options */
.picks { list-style: none; margin: 0; padding: 0;
         display: grid; gap: 0.5rem; }
.pick { display: grid; grid-template-columns: auto 1fr;
        gap: 0.25rem 0.875rem; align-items: center;
        padding: 0.875rem 1rem; background: var(--surface);
        border: 1px solid var(--line); border-radius: 0.875rem;
        cursor: pointer; }
.pick input { grid-row: span 2; width: 1.5rem; height: 1.5rem;
              accent-color: var(--accent); }
.pick-main { font-weight: 550; }
.pick-sub { grid-column: 2; color: var(--muted); font-size: 0.875rem; }
.pick:has(input:checked) { border-color: var(--accent);
                           box-shadow: inset 0 0 0 1px var(--accent); }

.choices { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.chip { display: inline-flex; align-items: center; min-height: 2.75rem;
        padding: 0 1rem; background: var(--surface);
        border: 1px solid var(--line); border-radius: 999px; cursor: pointer; }
.chip input { position: absolute; opacity: 0; pointer-events: none; }
.chip:has(input:checked) { background: var(--accent); color: var(--accent-ink);
                           border-color: var(--accent); }

.pair { display: grid; grid-template-columns: 1fr 1.4fr; gap: 0.5rem;
        margin-bottom: 0.5rem; }
#extras:not(:empty) { margin-bottom: 0.75rem; }

.warn { padding: 0.875rem 1rem; border-radius: 0.75rem;
        background: var(--reward-bg); border: 1px solid var(--reward);
        color: var(--reward); font-size: 0.875rem; }
.warn code { font-size: 0.8125rem; word-break: break-all; }

.emblem { width: 8rem; height: auto; border-radius: 50%;
          margin: 0 auto 1rem; display: block; }

/* Identity code */
.qr-row { display: flex; align-items: center; gap: 1rem; margin-top: 1rem; }
.qr-small { flex: none; width: 5.5rem; height: 5.5rem; padding: 0.4rem;
            background: #fff; border-radius: 0.5rem; }
.qr-row .secondary { display: inline-flex; min-height: 2.75rem;
                     margin-top: 0.5rem; }
.qr-small svg, .idcard-qr svg { display: block; width: 100%; height: 100%; }
.qr-small svg path, .idcard-qr svg path { fill: #000; }

#viewfinder video { width: 100%; border-radius: 0.875rem;
                    background: #000; margin-bottom: 0.75rem; }

/* Shareable client card */
.card-sheet { padding: 1rem; }
.idcard {
  display: grid; grid-template-columns: minmax(6.5rem, 25%) 1fr;
  background: #fbf7ee; color: #4a1220;
  border-radius: 0.75rem; overflow: hidden;
  box-shadow: 0 1px 3px rgb(0 0 0 / 0.3);
}
.idcard-brand {
  display: flex; flex-direction: column;
  background: #43091a; color: #f0d68c; text-align: center;
  overflow: hidden;
}
/* min-height lets the emblem give up its intrinsic height and take exactly
   the room the name leaves, at any card width. */
.idcard-crest { flex: 1; min-height: 0; width: 100%; height: auto;
                object-fit: cover; display: block; }
.idcard-name {
  flex: none; margin: 0; padding: 0.75rem 0.4rem 0.9rem;
  font-size: 0.68rem; font-weight: 700; letter-spacing: 0.12em;
  text-transform: uppercase; line-height: 1.45;
}
.idcard-body { padding: 1.25rem 1rem; text-align: center; }
.idcard-offer { margin: 0; font-size: 1.15rem; font-weight: 700;
                color: #7a1a30; }
.idcard-terms { margin: 0.35rem 0 0; font-size: 0.7rem; font-style: italic;
                color: #7d5a3c; }
.idcard-qr { width: 8.5rem; height: 8.5rem; margin: 0.9rem auto 0.5rem;
             padding: 0.5rem; background: #fff; border: 2px solid #c8a34a; }
.idcard-scan { margin: 0; font-size: 0.62rem; letter-spacing: 0.18em;
               text-transform: uppercase; color: #7d5a3c; }
.idcard-holder { margin: 0.75rem 0 0; font-weight: 700; font-size: 0.9rem; }

@media print {
  /* Without this the maroon panel and the emblem are dropped, and the card
     prints as text on white. */
  * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  body { background: #fff; padding: 0; }
  .bar, .dock, .no-print, .hint { display: none !important; }
  .card-sheet { padding: 0; }
  .idcard { box-shadow: none; border: 1px solid #c8a34a;
            break-inside: avoid; max-width: 21rem; }
}

@media (min-width: 40rem) {
  main, .dock > * { max-width: 34rem; margin-inline: auto; }
  .card { max-width: 34rem; margin-inline: auto; }
}
