/* Return Scanner.
   Built for a phone held in a bright yard by someone wearing gloves:
   high contrast, 48px minimum tap targets, no ornament that costs legibility.
   Counts are set in tabular numerals so digits line up down a column - this is
   a tally sheet before it is a web app. */

:root {
  --slate: #f2f3f1;
  --card: #ffffff;
  --ink: #16181a;
  /* Secondary text is still text read in sun: 8.3:1 on the slate, not the
     5.6:1 the old #5a6068 gave. */
  --ink-2: #454b52;
  --rule: #d3d7d3;
  --counted: #0b6e4f;
  /* Background for white text on a solid green fill (the Accept button, the
     count pill): --counted itself is also used as a *text* colour on light
     backgrounds elsewhere, where dark mode's brighter #35b183 reads fine.
     White-on-#35b183 is only 2.7:1, below the WCAG AA floor even for large
     text - --counted-fill is the token those two fills use instead, so the
     brighter --counted can stay everywhere else without dragging this pair
     below AA. Light mode's value matches --counted exactly (6.25:1). */
  --counted-fill: #0b6e4f;
  /* --pending is a text colour (7.3:1 on white); the brighter marking-paint
     orange stays for stripes and borders only, as --pending-stripe. */
  --pending: #9a3412;
  --pending-stripe: #c2410c;
  --focus: #1d4ed8;
  --danger: #a51d1d;
  --shadow: 0 1px 0 rgba(22, 24, 26, 0.05), 0 2px 10px rgba(22, 24, 26, 0.06);
  --tap: 48px;
  --gutter: 16px;
  --font-ui: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-num: ui-monospace, "SF Mono", Menlo, Consolas, "DejaVu Sans Mono", monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --slate: #101211;
    --card: #1b1e1d;
    --ink: #eef0ed;
    --ink-2: #a3aaa5;
    --rule: #343a37;
    --counted: #35b183;
    /* 5.34:1 against white - see the --counted-fill comment above. */
    --counted-fill: #0d7a54;
    --pending: #f08347;
    --pending-stripe: #f08347;
    --focus: #7aa2ff;
    --danger: #ef6a6a;
    --shadow: 0 1px 0 rgba(0, 0, 0, 0.4), 0 2px 10px rgba(0, 0, 0, 0.35);
  }
}

* { box-sizing: border-box; }

/* Class rules below set display on buttons and links, which would otherwise
   out-specify the hidden attribute. */
[hidden] { display: none !important; }

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

body {
  margin: 0;
  background: var(--slate);
  color: var(--ink);
  font: 16px/1.5 var(--font-ui);
  overscroll-behavior-y: contain;
}

.wrap {
  max-width: 640px;
  margin: 0 auto;
  padding: 0 var(--gutter) 96px;
}

/* ------------------------------------------------------------------ header */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 12px;
  min-height: 56px;
  padding: 8px var(--gutter);
  background: var(--card);
  border-bottom: 1px solid var(--rule);
}

.topbar__home {
  font-family: var(--font-num);
  font-weight: 700;
  letter-spacing: -0.03em;
  text-decoration: none;
  color: var(--ink);
  display: inline-flex;
  align-items: center;
  min-height: var(--tap);
}

.topbar__spacer { flex: 1; }

.topbar__who {
  display: inline-flex;
  align-items: center;
  min-height: var(--tap);
  font-size: 15px;
  color: var(--ink);
  text-decoration: underline;
  text-decoration-color: var(--ink-2);
}

.eyebrow {
  display: block;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-2);
}

h1 {
  font-family: var(--font-num);
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 20px 0 4px;
}

h2 {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 0.02em;
  margin: 28px 0 10px;
}

h3 {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--ink-2);
  margin: 20px 0 6px;
}

.sub { color: var(--ink-2); margin: 0 0 16px; }
.sub__who { color: var(--ink); }

/* Back links and footer links are taps, not reading: full height. */
.link-tap {
  display: inline-flex;
  align-items: center;
  min-height: var(--tap);
  font-weight: 600;
}
.backlink { margin: 8px 0 -8px; }
.foot-links { display: flex; flex-wrap: wrap; gap: 0 20px; margin-top: 16px; }

.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

/* A state word, not a number: "Not counted" in place of a big orange
   "count" that read like a button. */
.pill {
  display: inline-block;
  padding: 4px 10px;
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
  border: 1.5px solid currentColor;
}
.pill--pending { color: var(--pending); }
.pill--warn { color: var(--pending); background: var(--card); margin-top: 8px; white-space: normal; }

.flash {
  margin: 12px 0 0;
  padding: 12px 14px;
  background: var(--card);
  border-left: 4px solid var(--focus);
  box-shadow: var(--shadow);
  font-size: 14px;
}

/* The quick count's copy fallback: the text and link, on the page, to copy
   by hand when the clipboard is not available (quick_share.js). */
.share-text {
  display: block;
  width: 100%;
  margin-top: 8px;
  padding: 8px 10px;
  font: 16px var(--font-ui); /* 16px: iOS zooms the page on focus below this */
  color: var(--ink);
  background: var(--card);
  border: 1.5px solid var(--ink-2);
  border-radius: 0;
  resize: vertical;
}
.share-text[hidden] { display: none; }

/* ---------------------------------------------------------------- placards */

/* Every load in the yard wears a white numbered placard; so does every load
   here. The left stripe is marking paint: orange until counted, green after. */
.placard {
  display: block;
  position: relative;
  background: var(--card);
  border: 1px solid var(--rule);
  border-left: 5px solid var(--pending-stripe);
  box-shadow: var(--shadow);
  padding: 14px 16px;
  margin-bottom: 10px;
  color: inherit;
  text-decoration: none;
}

.placard.is-counted { border-left-color: var(--counted); }
.placard--archived { border-left-color: var(--ink-2); }

.placard__row {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 12px;
}

.placard__no {
  font-family: var(--font-num);
  font-variant-numeric: tabular-nums;
  font-size: 30px;
  font-weight: 700;
  letter-spacing: -0.04em;
  line-height: 1;
  overflow-wrap: anywhere;
}

/* A return or quick count named in words rather than a placard number. */
.placard__title {
  font-size: 20px;
  font-weight: 700;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

/* Who the return is from: the thing that tells two same-number returns
   apart, so it wraps rather than truncating. */
.placard__who { font-size: 16px; font-weight: 600; overflow-wrap: anywhere; }

.placard__meta { flex: 1 1 160px; min-width: 0; }

.placard__sku {
  font-size: 14px;
  color: var(--ink-2);
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow-wrap: anywhere;
}

.placard__count {
  font-family: var(--font-num);
  font-variant-numeric: tabular-nums;
  font-size: 40px;
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.05em;
  color: var(--counted);
}

.placard__count.is-empty { color: var(--pending); font-size: 22px; letter-spacing: 0; }

.placard__foot {
  margin-top: 8px;
  font-size: 14px;
  color: var(--ink-2);
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

/* ------------------------------------------------------------------- total */

.total {
  background: var(--card);
  border: 1px solid var(--rule);
  box-shadow: var(--shadow);
  padding: 18px 16px;
  margin: 16px 0;
  text-align: center;
}

.total__value {
  font-family: var(--font-num);
  font-variant-numeric: tabular-nums;
  font-size: clamp(64px, 22vw, 104px);
  font-weight: 700;
  line-height: 0.9;
  letter-spacing: -0.06em;
  display: block;
  margin: 6px 0 4px;
}

/* These notes carry NAS paths, which have no spaces to break at and are wider
   than a phone. Let them break mid-token rather than run off the card. */
.total__note { font-size: 13px; color: var(--ink-2); overflow-wrap: break-word; }
.total__note.is-warning { color: var(--pending); font-weight: 600; }

/* ------------------------------------------------------------------- forms */

.card {
  background: var(--card);
  border: 1px solid var(--rule);
  box-shadow: var(--shadow);
  padding: 16px;
  margin-bottom: 16px;
}

.field { margin-bottom: 14px; }
/* Scoped to the card, not to any last child: a field that ends a .row still
   needs its gap before whatever follows the row. */
.card > .field:last-child { margin-bottom: 0; }

/* Sits under a control to say what it will do, in sentence case rather than
   the label's uppercase: it is read, not scanned. */
.field__hint { margin: 6px 0 0; font-size: 13px; color: var(--ink-2); }

label.field > span,
.field > label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-2);
  margin-bottom: 6px;
}

input[type="text"],
input[type="date"],
input[type="number"],
input[type="password"],
input[type="search"],
select,
textarea {
  width: 100%;
  min-width: 0;
  min-height: var(--tap);
  padding: 10px 12px;
  font: 16px var(--font-ui);
  color: var(--ink);
  background: var(--card);
  border: 1px solid var(--rule);
  border-radius: 0;
}

/* Links are ink with an underline, not browser blue. A tally sheet where a
   placard turns purple once you have opened it reads as a mistake, and blue
   on blue-grey is the first thing to disappear in direct sun. */
a { color: var(--ink); text-underline-offset: 3px; }

input:focus-visible,
select:focus-visible,
textarea:focus-visible,
button:focus-visible,
a:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

textarea { min-height: 72px; resize: vertical; }

/* The native picker is the right control here (it is what opens the SD card
   and the camera roll), but the default one is a small target for gloves. */
input[type="file"] {
  width: 100%;
  max-width: 100%;
  overflow: hidden;
  min-height: var(--tap);
  padding: 12px;
  font: 15px var(--font-ui);
  color: var(--ink);
  background: var(--card);
  border: 1px solid var(--rule);
}

input[type="file"]::file-selector-button {
  min-height: 40px;
  margin-right: 12px;
  padding: 0 14px;
  font: 600 14px var(--font-ui);
  color: var(--ink);
  background: var(--slate);
  border: 1.5px solid var(--ink);
  border-radius: 0;
  cursor: pointer;
}

.row { display: flex; gap: 10px; flex-wrap: wrap; }
/* min-width 0: a flex item will not shrink below its content otherwise, and
   a date input's content is wider than a phone at 200% zoom. */
.row > * { flex: 1 1 160px; min-width: 0; }

/* A textarea can't take a native <datalist>, so notes gets its own small
   suggestion list. It sits in the page flow under the field, not floating:
   floating, it covered "Start the return" and a tap on the button picked a
   suggestion instead of submitting. */
.field--suggest { position: relative; }

.suggest-list {
  position: static;
  margin-top: 4px;
  max-height: 190px;
  overflow-y: auto;
  background: var(--card);
  border: 1px solid var(--rule);
  box-shadow: var(--shadow);
}

.suggest-list button {
  display: block;
  width: 100%;
  min-height: var(--tap);
  padding: 10px 12px;
  font: 15px var(--font-ui);
  color: var(--ink);
  background: var(--card);
  text-align: left;
  border: 0;
  border-bottom: 1px solid var(--rule);
  cursor: pointer;
}

.suggest-list button:last-child { border-bottom: 0; }

.suggest-list button:hover,
.suggest-list button:focus-visible {
  background: var(--slate);
}

/* The slate-photo read progress display: one of four states, always with
   elapsed time, sitting under the file input it belongs to. */
.slate-status {
  margin-top: 8px;
  padding: 10px 12px;
  font-size: 14px;
  color: var(--ink-2);
  background: var(--slate);
  border-left: 3px solid var(--rule);
}

.slate-status[data-state="found"] { color: var(--counted); border-left-color: var(--counted); }
.slate-status[data-state="not-found"] { color: var(--pending); border-left-color: var(--pending); }

/* A return number read off the slate lands in the field itself, marked
   here so it reads as "from the photo" rather than typed, until the
   worker keeps or dismisses it (or edits it, which clears the mark). */
input.input--from-photo {
  border-color: var(--counted);
  border-width: 2px;
}

.slate-suggestion {
  margin-top: 6px;
  padding: 10px 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  background: var(--slate);
  border: 1px solid var(--counted);
}

.slate-suggestion__badge {
  flex-basis: 100%;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--counted);
}

.slate-suggestion button {
  min-height: var(--tap);
  padding: 0 14px;
  font: 600 14px var(--font-ui);
  color: var(--ink);
  background: var(--card);
  border: 1.5px solid var(--ink);
  border-radius: 0;
  cursor: pointer;
}

/* A read that lands while the field already holds a value the worker put
   there themselves (typed, or kept from an earlier photo) never overwrites
   it: the photo's own answer surfaces here instead, a separate choice
   rather than a silent substitution. */
.slate-alt-suggestion {
  margin-top: 6px;
  padding: 10px 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  font-size: 14px;
  color: var(--ink-2);
  background: var(--slate);
  border: 1px solid var(--focus);
}

.slate-alt-suggestion button {
  min-height: var(--tap);
  padding: 0 14px;
  font: 600 14px var(--font-ui);
  color: var(--ink);
  background: var(--card);
  border: 1.5px solid var(--ink);
  border-radius: 0;
  cursor: pointer;
}

/* ----------------------------------------------------------------- buttons */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: var(--tap);
  padding: 0 18px;
  font: 600 15px var(--font-ui);
  color: var(--ink);
  background: var(--card);
  border: 1.5px solid var(--ink);
  border-radius: 0;
  cursor: pointer;
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
}

.btn:disabled { opacity: 0.45; cursor: not-allowed; }

.btn--primary {
  background: var(--ink);
  color: var(--slate);
}

.btn--go {
  background: var(--counted-fill);
  border-color: var(--counted-fill);
  color: #fff;
}

/* Quieter than the primary, but still a button you can see: the old
   --rule border was 1.4:1 and read as plain text in sun. */
.btn--quiet {
  border-color: var(--ink-2);
  color: var(--ink);
  font-weight: 600;
}
.btn--quiet:disabled { border-style: dashed; }

/* A checkbox you can hit with a glove, with its sentence beside it. */
label.check {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: var(--tap);
  font-size: 15px;
}
label.check input { width: 24px; height: 24px; flex: 0 0 auto; margin: 0; }
.photo-hide { display: grid; gap: 8px; padding: 8px 10px 10px; }

.btn--danger { border-color: var(--danger); color: var(--danger); }

.btn--block { display: flex; width: 100%; }

.btn-row { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 12px; }
.btn-row > .btn { flex: 1 1 auto; }

/* The camera button delegates to the native camera app; the file input that
   drives it is visually hidden but still focusable via its label. The type
   selector is part of it so this outweighs the sizing of a visible file input
   above; without it the hidden input keeps its full width and, being
   positioned, sticks out past the right edge of the page. */
input[type="file"].file-input {
  position: absolute;
  width: 1px;
  height: 1px;
  min-height: 0;
  padding: 0;
  border: 0;
  opacity: 0;
  overflow: hidden;
}

/* An always-visible affordance for dropping files onto the picker form. The
   outline draws outside the box model (no border/padding change), so it
   cannot grow the form or push the camera controls below it down. */
.dropzone {
  outline: 2px dashed var(--rule);
  outline-offset: 6px;
  transition: outline-color 120ms ease, background-color 120ms ease;
}

.dropzone.is-dragover {
  outline-color: var(--focus);
  background-color: rgba(29, 78, 216, 0.08);
}

@media (prefers-color-scheme: dark) {
  .dropzone.is-dragover {
    background-color: rgba(122, 162, 255, 0.12);
  }
}

/* ------------------------------------------------------------------ photos */

.photo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}

.photo {
  position: relative;
  display: block;
  background: var(--card);
  border: 1px solid var(--rule);
  text-decoration: none;
  color: inherit;
}

.photo img {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  background: var(--rule);
}

.photo__bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  padding: 8px 10px;
  font-size: 13px;
  color: var(--ink-2);
}

.photo__count {
  font-family: var(--font-num);
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  font-size: 18px;
  color: var(--counted);
}

.badge {
  display: inline-block;
  padding: 3px 8px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  border: 1px solid currentColor;
}

.badge--blind { color: var(--ink); background: var(--card); }
.badge--capture { color: var(--ink-2); }
.badge--pending { color: var(--pending); }

.empty {
  padding: 24px 16px;
  text-align: center;
  color: var(--ink-2);
  border: 1px dashed var(--rule);
  background: var(--card);
}

/* ---------------------------------------------------------------- warnings */

/* A count two photos of the same load disagree about is the one thing on
   these screens that a person has to act on rather than read, so it gets the
   pending colour as a full border rather than the flash's single stripe. */
.warn {
  margin: 12px 0;
  padding: 12px 14px;
  background: var(--card);
  border: 2px solid var(--pending-stripe);
  box-shadow: var(--shadow);
  font-size: 14px;
}

.warn p { margin: 6px 0 0; }
.warn__title { display: block; color: var(--pending); }

/* Under the placard it belongs to, closing the gap so the two read as one. */
.warn--attached { margin-top: -2px; }

/* ------------------------------------------------------------------ tables */

/* A long SKU or an export error is wider than a phone. Let the table scroll
   inside its own box rather than dragging the whole page sideways with it. */
.table-wrap { overflow-x: auto; }

.tally { width: 100%; border-collapse: collapse; background: var(--card); }
.tally th,
.tally td { padding: 10px 12px; border-bottom: 1px solid var(--rule); text-align: left; }
.tally th {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-2);
}
.tally .num {
  font-family: var(--font-num);
  font-variant-numeric: tabular-nums;
  text-align: right;
  font-weight: 700;
}
.tally tfoot td { border-bottom: none; border-top: 2px solid var(--ink); font-weight: 700; }
/* Totals by item: three columns that fit 360 px; "2 of 3" turns orange
   while a load is still uncounted. */
.tally--items th { letter-spacing: 0.04em; }
.tally--items td:first-child { overflow-wrap: anywhere; }
.tally--items .is-short { color: var(--pending); }

/* Marks the first row of a duplicate-return group, so a run of look-alike
   sessions reads as one cluster rather than unrelated rows. */
.tally tr.group-start td { border-top: 2px solid var(--ink); }
.tally tr.group-start:first-child td { border-top: 1px solid var(--rule); }

.meta-list { margin: 0; font-size: 14px; }
.meta-list dt {
  font-size: 13px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-2);
  margin-top: 10px;
}
.meta-list dd { margin: 2px 0 0; }

/* ------------------------------------------------------------- dot editor */

body.editor { overflow: hidden; background: #0d0f0e; color: #fff; }

.editor-shell {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
}

.editor-top {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  padding-top: max(8px, env(safe-area-inset-top));
  background: #16191800;
  background: rgba(10, 12, 11, 0.82);
  font-size: 13px;
  color: #e8eae7;
}

.editor-top a {
  display: inline-flex;
  align-items: center;
  min-height: var(--tap);
  padding: 0 4px;
  color: inherit;
  text-decoration: none;
  font-weight: 600;
  font-size: 15px;
}
.editor-top .badge--blind { color: #ffd166; background: transparent; }

/* Persistent, not part of the transient note cycle below: states an
   existing accepted count before a recount is even reachable. */
.editor-banner {
  padding: 6px 12px;
  background: rgba(10, 12, 11, 0.92);
  color: #ffd166;
  font-size: 13px;
  font-weight: 600;
  border-bottom: 2px solid #ffd166;
}

/* One line of how-to, above the photo rather than over it. */
.editor-hint {
  margin: 0;
  padding: 6px 12px;
  background: rgba(10, 12, 11, 0.92);
  color: #e8eae7;
  font-size: 14px;
  line-height: 1.35;
}

.editor-stage { position: relative; flex: 1; min-height: 0; touch-action: none; }

#stage { display: block; width: 100%; height: 100%; touch-action: none; }

/* Entirely pointer-driven otherwise: a keyboard user tabbing to
   the canvas needs to see that it now has focus, not just be told so. */
#stage:focus-visible { outline: 3px solid var(--focus); outline-offset: -3px; }

/* The live count is the only saturated thing on the screen: it is the answer
   the whole app exists to produce. Fixed white text over a solid fill, so
   this uses --counted-fill (kept at AA contrast in both themes), not
   --counted (which is also used as a *text* colour elsewhere and tuned for
   that job instead - see the --counted-fill token comment). */
/* The two stage controls share one row, so at any width or zoom the
   button sits beside the count and never on top of it. */
.stage-hud {
  position: absolute;
  top: 12px;
  left: 12px;
  right: 12px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  pointer-events: none;
}
.stage-hud > * { pointer-events: auto; }

.count-pill {
  display: flex;
  flex: 0 0 auto;
  align-items: baseline;
  gap: 8px;
  padding: 8px 16px;
  background: var(--counted-fill);
  color: #fff;
  font-family: var(--font-num);
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  font-size: 34px;
  line-height: 1;
  letter-spacing: -0.04em;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.45);
}

.count-pill span {
  font-family: var(--font-ui);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

/* Fixed-position control pinned to the stage, same chrome family as
   .editor-note/.editor-bar below: "Fit to screen" needs to be reachable
   from any zoom level, not just from the bottom bar. Top-left, so
   it never collides with the count pill (top-right), the overview inset
   (bottom-right), or the note bar (spans the full bottom edge). */
.stage-btn {
  flex: 0 1 auto;
  min-width: 0;
  min-height: var(--tap);
  padding: 0 14px;
  font: 600 14px var(--font-ui);
  color: #e8eae7;
  background: rgba(10, 12, 11, 0.86);
  border: 1.5px solid #8a918c;
  border-radius: 0;
  cursor: pointer;
}
.stage-btn__short { display: none; }

/* A phone at 200% text zoom is about 195 CSS px wide: shorter words and a
   smaller pill so both still fit on the one row. */
@media (max-width: 300px) {
  .stage-btn__long { display: none; }
  .stage-btn__short { display: inline; }
  .count-pill { font-size: 26px; padding: 6px 10px; gap: 6px; }
}

/* Below the photo, not over it: a status line in the flow, so it can never
   cover the dots or the count. */
.editor-note {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 6px 12px;
  background: rgba(10, 12, 11, 0.92);
  color: #e8eae7;
  font-size: 14px;
  line-height: 1.35;
  /* Neutral for ordinary news; the alarm stripe is for warnings only. */
  border-left: 4px solid #8a918c;
}
.editor-note--warning { border-left-color: var(--pending-stripe); }
/* The text takes the slack, so Retry and the close button sit together at
   the right end instead of being spread across the strip. */
#note-text { flex: 1 1 auto; min-width: 0; }

/* "Removed dot 12" with its undo, over the bottom of the photo for a few
   seconds; clear of the overview inset in the bottom-right corner. */
.editor-toast {
  position: absolute;
  left: 12px;
  bottom: 12px;
  right: 144px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 4px 4px 4px 12px;
  background: #e8eae7;
  color: #16181a;
  font-size: 14px;
  font-weight: 600;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.45);
}
.editor-toast[hidden] { display: none; }
.editor-toast__undo {
  flex: 0 0 auto;
  min-height: var(--tap);
  padding: 0 14px;
  font: 700 15px var(--font-ui);
  color: #fff;
  background: #16181a;
  border: 0;
  cursor: pointer;
}
@media (max-width: 300px) {
  .editor-toast { right: 12px; }
}

/* At 200% zoom (about 195x422 CSS px) the strips above and below the photo
   used to take nearly all the height. Keep each to two lines, and drop the
   how-to line while a replace banner is up (the accept dialog repeats what
   matters), so the photo keeps most of the screen. */
@media (max-width: 300px) {
  .editor-top { gap: 6px; padding: 2px 8px; font-size: 13px; }
  .editor-top a { font-size: 14px; padding: 0 2px; }
  /* The placard is named in the screen before this one and in the banner;
     its slot stays as the spacer so Back and Problem? keep one row. */
  .editor-top .topbar__spacer { font-size: 0; }
  .editor-note { font-size: 13px; padding: 4px 8px; }
  /* Clamped blocks take their top inset as a border, not padding, so a
     clamped third line cannot show through it. */
  .editor-banner,
  .editor-hint { font-size: 13px; padding: 0 8px; border-top: 4px solid transparent; }
  .editor-banner,
  .editor-hint,
  #note-text {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }
  .editor-banner + .editor-hint { display: none; }
  .editor-note__retry { min-height: 44px; padding: 0 8px; font-size: 13px; }
  .stage-hud { top: 6px; left: 6px; right: 6px; }
  .editor-bar { gap: 4px; padding: 6px 8px; }
  .editor-bar .btn { font-size: 13px; padding: 0 4px; }
}

.editor-note[hidden] { display: none; }
/* The counting screen keeps the strip's height from the first paint, so a
   note that arrives later never resizes the photo (see count.html). Closing
   it with x drops the reservation, so the strip collapses (dots.js). */
.editor-note--reserved { min-height: calc(var(--tap) + 12px); }
.editor-note--reserved.is-empty { visibility: hidden; }

/* Surfaces routes/counting.py's prediction-retry endpoint and a retryable
   full-resolution photo fetch right next to the failure it explains,
   instead of leaving the counter stuck until the next reload. */
.editor-note__retry {
  flex: 0 0 auto;
  min-height: var(--tap);
  padding: 0 14px;
  font: 600 14px var(--font-ui);
  color: #16181a;
  background: #e8eae7;
  border: none;
  cursor: pointer;
}

/* Closes the strip, warnings included (dots.js dismissNote). A full --tap
   square at every width; the closed strip collapses and the photo grows. */
.editor-note__dismiss {
  flex: 0 0 auto;
  width: var(--tap);
  height: var(--tap);
  padding: 0;
  font: 400 26px/1 var(--font-ui);
  color: #e8eae7;
  background: transparent;
  border: 1.5px solid #8a918c;
  cursor: pointer;
}
.editor-note__dismiss[hidden],
.editor-note__retry[hidden] { display: none; }
.editor-note__dismiss:focus-visible,
.editor-note__retry:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

.editor-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 10px 12px;
  padding-bottom: max(10px, env(safe-area-inset-bottom));
  background: rgba(10, 12, 11, 0.92);
}

.editor-bar .btn {
  flex: 1 1 0;
  min-width: 0;
  background: transparent;
  color: #e8eae7;
  border-color: #8a918c;
  font-size: 14px;
  padding: 0 8px;
}

.editor-bar .btn--go { flex: 1.6 1 0; background: var(--counted-fill); border-color: var(--counted-fill); color: #fff; }
.editor-bar .btn[aria-pressed="true"] { background: #e8eae7; color: #16181a; border-color: #e8eae7; }

/* Dot size: its own full-width row so the four buttons never squeeze the
   editing buttons. Each is a full --tap target; the current size is the
   inverted button (aria-pressed rule above). */
.size-group {
  display: flex;
  flex: 1 0 100%;
  align-items: center;
  gap: 4px;
}
.size-group__label {
  flex: 0 0 auto;
  margin-right: 4px;
  color: #e8eae7;
  font-size: 13px;
}
.size-group .btn { min-width: var(--tap); }

/* At 200% zoom (about 195 CSS px wide) four --tap buttons plus the label
   do not fit, and the bar clips XL off-screen. Drop the visible label (the
   group's aria-label still names it) and join the four into one segmented
   row: 44 px wide each, still the full --tap height. */
@media (max-width: 300px) {
  .size-group { gap: 0; }
  .size-group__label { display: none; }
  .size-group .btn { flex: 1 1 0; min-width: 44px; padding: 0; }
  .size-group .btn + .btn { margin-left: -1.5px; }
}

.editor-bar--saved { align-items: center; }
.saved-meta { flex: 1 1 auto; color: #e8eae7; font-size: 13px; }
/* Who and when on one row, Recount a full-width --tap target on the next. */
.editor-bar--saved .saved-meta,
.editor-bar--saved .btn { flex: 1 0 100%; }

dialog {
  border: 1px solid var(--rule);
  border-radius: 0;
  padding: 0;
  background: var(--card);
  color: var(--ink);
  max-width: 400px;
  width: calc(100% - 32px);
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.35);
}

dialog::backdrop { background: rgba(10, 12, 11, 0.6); }

.dialog-body { padding: 20px 20px 16px; text-align: center; }
.dialog-body .total__value { font-size: 76px; }
.dialog-actions { display: flex; gap: 10px; padding: 0 20px 20px; }
.dialog-actions .btn { flex: 1; }
.dialog-replace { margin: 12px 0 0; font-size: 16px; font-weight: 600; color: var(--pending); }
#restore .dialog-replace { color: var(--ink); }

/* Confirms the tap landed without making the counter look away from the load. */
@media (prefers-reduced-motion: no-preference) {
  .count-pill { transition: transform 140ms ease-out; }
  .count-pill.bump { transform: scale(1.08); }
}

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

/* ---------------------------------------------------------- help, feedback */

.topbar__link {
  display: inline-flex;
  align-items: center;
  min-height: var(--tap);
  padding: 0 4px;
  font-size: 15px;
  font-weight: 600;
  color: var(--ink);
}

.help-toc { display: flex; gap: 10px; flex-wrap: wrap; margin: 0 0 8px; }
.help-toc > .btn { flex: 1 1 140px; }

.steps { list-style: none; counter-reset: step; margin: 0; padding: 0; }
.steps > li {
  counter-increment: step;
  display: grid;
  grid-template-columns: 36px 1fr;
  gap: 4px 12px;
  align-items: start;
  padding: 14px 0;
  border-bottom: 1px solid var(--rule);
}
.steps > li:last-child { border-bottom: 0; }
.steps > li::before {
  content: counter(step);
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  /* The user guide's step badge: its orange disc, white ring and slate
     outline. The guide prints the number in white; here it is slate, because
     white on this orange is 2.9:1 and slate is 5.1:1. */
  background: #ff6a13;
  color: #1f2a33;
  box-shadow: 0 0 0 2px #ffffff, 0 0 0 4px #1f2a33;
  font-family: var(--font-num);
  font-weight: 800;
}
.steps p { margin: 4px 0 0; }
.steps strong { font-size: 17px; }

/* Each help step shows the real screen, annotated the way the user guide is
   (red outline and arrow on the control, the step number in the red badge),
   inside the guide's phone frame. The images are 480 px wide: sharp at 240 CSS
   px on a 2x screen. */
.step-fig { grid-column: 2; margin: 10px 0 4px; }
.step-fig.phone {
  position: relative;
  width: 100%;
  max-width: 240px;
  padding: 8px;
  background: #e9ecef;
  border: 1px solid #c9d0d6;
  border-radius: 26px;
  box-shadow: 0 7px 19px rgba(31, 42, 51, 0.28), inset 0 0 0 1.5px #ffffff;
}
.step-fig.phone::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 12px;
  width: 48px;
  height: 5px;
  margin-left: -24px;
  border-radius: 3px;
  background: rgba(31, 42, 51, 0.55);
}
.step-fig.phone img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 18px;
  border: 1px solid #b9c1c8;
  background: #ffffff;
}

.metric-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin: 0 0 16px; }
.metric-grid .total { margin: 0; }
.day-bar { display: inline-block; height: 10px; background: var(--counted); border-radius: 2px; vertical-align: middle; }

/* ------------------------------------------------- search, filters, matches */

/* "No number yet" is words, not a placard number: smaller, quieter, and not
   monospaced so it cannot be mistaken for a number. */
.placard__no--none {
  font-family: var(--font-ui);
  font-size: 20px;
  letter-spacing: 0;
  color: var(--ink-2);
}

.search { margin: 16px 0 8px; }
.search .field { margin-bottom: 8px; }
.search__dates { margin-bottom: 8px; }
.search__dates summary { cursor: pointer; }

/* One row of filters that wraps rather than scrolls sideways on a phone. */
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 8px; }
.chip {
  display: inline-flex;
  align-items: center;
  min-height: var(--tap);
  padding: 0 16px;
  font: 600 15px var(--font-ui);
  color: var(--ink);
  background: var(--card);
  border: 1.5px solid var(--ink-2);
  text-decoration: none;
}
.chip[aria-current="true"] {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--slate);
}

/* A duplicate-number match: its card, an optional contractor warning, and the
   one button that matters, kept together. */
.match { margin-bottom: 16px; }
.match .placard { margin-bottom: 8px; }
.match .warn { margin-bottom: 8px; }
