*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: var(--font);
  font-size: 15px;
  letter-spacing: 0.01em;
  color: var(--color-text);
  background: var(--color-bg);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  transition: background 0.2s, color 0.2s;
}
h1, h2, h3 { margin: 0; font-family: var(--font); font-weight: 800; letter-spacing: 0.01em; }
p { margin: 0; }
a { color: var(--color-link); }
.num { font-variant-numeric: tabular-nums; }

.boot { min-height: 100vh; display: grid; place-items: center; align-content: center; gap: var(--space-3); color: var(--color-muted); font-weight: 600; }

/* Buttons — every button is at least a 44 px tap target */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: var(--tap);
  padding: 10px 18px;
  border-radius: var(--radius);
  border: 1.5px solid transparent;
  font: inherit; font-size: 0.95rem; font-weight: 700;
  cursor: pointer; text-decoration: none;
  transition: transform 0.1s ease, box-shadow 0.12s ease, background 0.12s ease, border-color 0.12s ease;
  white-space: nowrap;
}
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: 3px solid var(--color-focus); outline-offset: 2px; }
.btn--primary { background: var(--color-primary); color: var(--color-on-dark); }
.btn--primary:hover { background: var(--color-primary-ink); box-shadow: var(--shadow-md); }
.btn--accent { background: var(--color-accent); color: var(--color-accent-ink); }
.btn--accent:hover { box-shadow: var(--shadow-md); filter: brightness(0.95); }
.btn--secondary { background: var(--color-surface); color: var(--color-text); border-color: var(--color-border); }
.btn--secondary:hover { border-color: var(--color-primary); box-shadow: var(--shadow-sm); }
.btn--ghost { background: transparent; color: var(--color-muted); }
.btn--ghost:hover { background: var(--color-tint); color: var(--color-text); }
.btn--danger { background: var(--color-danger); color: var(--color-on-dark); }
.btn--danger:hover { box-shadow: var(--shadow-md); filter: brightness(0.92); }
.btn:disabled { opacity: 0.6; cursor: default; transform: none; box-shadow: none; }
.btn--sm { min-height: var(--tap); padding: 6px 14px; font-size: 0.82rem; border-radius: var(--radius-full); }
.btn--block { width: 100%; }

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

/* Page column used by most screens */
.page { max-width: var(--content-max); margin: 0 auto; padding: var(--space-4) var(--space-3) var(--space-5); display: flex; flex-direction: column; gap: var(--space-3); }
.page__title { font-size: 1.5rem; line-height: 1.15; }
.page__sub { color: var(--color-muted); }

.card { background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-lg); padding: var(--space-4); box-shadow: var(--shadow-md); }
.card__title { font-size: 1.05rem; }
.eyebrow { font-size: 0.72rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--color-muted); }

/* Forms — small uppercase labels, pale 48 px fields */
.field { display: flex; flex-direction: column; gap: 6px; }
.field__label { font-size: 0.72rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--color-muted); }
.field__hint { color: var(--color-muted); font-size: 0.82rem; }
.field__error { color: var(--color-danger-text); font-size: 0.85rem; font-weight: 600; }
.field__error:empty { margin-top: -6px; }
.field__error:not(:empty)::before { content: "⚠ "; }
.input {
  font: inherit; font-size: 1rem; color: var(--color-text); background: var(--color-input);
  border: 1.5px solid var(--color-border); border-radius: var(--radius); padding: 11px 14px; width: 100%;
  min-height: 48px;
}
.input:focus-visible { outline: 3px solid color-mix(in srgb, var(--color-focus) 55%, transparent); outline-offset: 1px; border-color: var(--color-focus); }
.input[aria-invalid="true"] { border-color: var(--color-danger-text); }
.input-prefix { display: flex; align-items: center; border: 1.5px solid var(--color-border); border-radius: var(--radius); background: var(--color-input); }
.input-prefix > span { padding-left: 14px; color: var(--color-muted); font-weight: 700; }
.input-prefix > .input { border: 0; padding-left: 2px; background: transparent; }
.input-prefix:focus-within { border-color: var(--color-focus); outline: 3px solid color-mix(in srgb, var(--color-focus) 55%, transparent); outline-offset: 1px; }
.input-prefix:has(.input[aria-invalid="true"]) { border-color: var(--color-danger-text); }
.input-prefix > .input:focus-visible { outline: none; }

.pill { display: inline-flex; align-items: center; gap: 6px; padding: 3px 12px; border-radius: var(--radius-full); background: var(--color-surface-2); border: 1px solid var(--color-border); font-size: 0.82rem; font-weight: 600; color: var(--color-muted); }

.stalled__actions { display: flex; gap: var(--space-2); flex-wrap: wrap; }

/* Localhost-only data badge (lib/data-mode.js envBadge) */
.env-badge { position: fixed; left: 12px; bottom: calc(12px + env(safe-area-inset-bottom)); z-index: 900; pointer-events: none; padding: 4px 10px; border-radius: var(--radius-full); font-size: 0.72rem; font-weight: 800; letter-spacing: 0.06em; box-shadow: var(--shadow-md); }
.env-badge--live { background: var(--color-danger); color: var(--color-on-dark); }
.env-badge--sandbox { background: var(--color-accent); color: var(--color-accent-ink); }

/* Choice rows (radio cards), checkboxes and segmented buttons — shared by forms and dialogs */
.choice { display: flex; align-items: flex-start; gap: var(--space-2); padding: 10px 12px; min-height: var(--tap); border: 1.5px solid var(--color-border); border-radius: var(--radius); cursor: pointer; background: var(--color-input); }
.choice:has(input:checked) { border-color: var(--color-primary); background: var(--color-tint); }
.choice input { margin-top: 4px; accent-color: var(--color-primary); }
.choice > span { display: flex; flex-direction: column; }
.choice__hint { color: var(--color-muted); font-size: 0.85rem; font-weight: 500; }
.check { display: inline-flex; align-items: center; gap: var(--space-2); min-height: var(--tap); font-weight: 600; cursor: pointer; }
.check input { width: 20px; height: 20px; accent-color: var(--color-primary); }
.seg { display: inline-flex; border: 1.5px solid var(--color-border); border-radius: var(--radius-full); overflow: hidden; background: var(--color-input); flex: none; }
.seg__btn { font: inherit; font-size: 0.8rem; font-weight: 700; min-height: var(--tap); padding: 0 12px; border: 0; background: transparent; color: var(--color-muted); cursor: pointer; }
.seg__btn + .seg__btn { border-left: 1px solid var(--color-border); }
.seg__btn[aria-pressed="true"] { background: var(--color-primary); color: var(--color-on-dark); }
.seg__btn:focus-visible { outline: 3px solid var(--color-focus); outline-offset: -3px; }
.seg__btn:disabled { cursor: default; opacity: 0.7; }
.seg--wide { display: flex; margin-bottom: var(--space-3); }
.seg--wide .seg__btn { flex: 1; }
.dialog__body { display: flex; flex-direction: column; gap: var(--space-3); margin-bottom: var(--space-2); }
.dialog__choices { border: 0; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 6px; }
.dialog__error { margin-bottom: var(--space-2); }
.dialog__error + .modal__actions { margin-top: var(--space-3); } /* room between the last field and the buttons */
.page--wide { max-width: 960px; }

/* lib/app.js focuses each screen's h1 for screen readers; it isn't a control, so no ring. */
h1[tabindex="-1"]:focus { outline: none; }

/* Device-mode "Tap to start" (lib/tap-to-start.js) */
.tap-start { position: fixed; inset: 0; z-index: 200; display: grid; place-items: center; padding: var(--space-4); background: var(--color-bg); }
.tap-start__btn { display: flex; flex-direction: column; align-items: center; gap: var(--space-2); width: min(420px, 100%); padding: var(--space-5) var(--space-4); border: 0; border-radius: var(--radius-lg); background: var(--color-primary); color: var(--color-on-dark); font: inherit; font-size: 1.4rem; font-weight: 800; cursor: pointer; }
.tap-start__btn:focus-visible { outline: 3px solid var(--color-focus); outline-offset: 4px; }
.tap-start__title { font-size: 0.8rem; letter-spacing: 0.1em; text-transform: uppercase; opacity: 0.8; }
.tap-start__hint { font-size: 0.9rem; font-weight: 500; opacity: 0.8; }

/* Boards: offline notice (lib/offline-bar.js) */
.offline-bar { position: fixed; left: 50%; transform: translateX(-50%); top: calc(var(--topbar-h) + 8px); z-index: 80; margin: 0; padding: 8px 16px; border-radius: var(--radius-full); background: var(--color-warning); color: var(--color-on-dark); font-weight: 700; box-shadow: var(--shadow-md); }
.offline-bar[hidden] { display: none; }

/* Guest pages (order, status) never show the staff top bar or banners. */
.is-guest-page #topbar, .is-guest-page #banner { display: none; }

/* Read by screen readers, not shown. */
.visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

/* PIN box with a show/hide eye (lib/pin-field.js) */
.pin-field { position: relative; display: block; }
.pin-field .input { padding-right: calc(var(--tap) + var(--space-1)); }
.pin-field__eye { position: absolute; right: 0; top: 0; height: 100%; min-width: var(--tap); display: inline-flex; align-items: center; justify-content: center; border: 0; background: none; color: var(--color-muted); cursor: pointer; }
.pin-field__eye[aria-pressed="true"] { color: var(--color-text); }

/* Dropdowns: our own chevron with room on the right (the native arrow hugs the edge). */
select.input {
  appearance: none;
  padding-right: 2.75rem;
  background-image: linear-gradient(45deg, transparent 50%, var(--color-text-2) 50%), linear-gradient(135deg, var(--color-text-2) 50%, transparent 50%);
  background-position: calc(100% - 1.25rem) 50%, calc(100% - 0.9rem) 50%;
  background-size: 0.36rem 0.36rem, 0.36rem 0.36rem;
  background-repeat: no-repeat;
  cursor: pointer;
}
