/* Glossier Package Scanner
 * Type and colour follow the Glossier Brand Book 2025 digital tokens:
 * pink is primary, black and white are the accents, CTA blue is the single
 * digital accent, text is pure black, and corners stay square.
 * Colour never encodes meaning here — state is carried by fill and wording.
 */

@font-face {
  font-family: "Apercu Pro";
  src: url("/fonts/ApercuPro-Regular.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Apercu Pro";
  src: url("/fonts/ApercuPro-Italic.woff2") format("woff2");
  font-weight: 400;
  font-style: italic;
  font-display: swap;
}
@font-face {
  font-family: "Apercu Pro";
  src: url("/fonts/ApercuPro-Medium.woff2") format("woff2");
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Apercu Pro";
  src: url("/fonts/ApercuPro-Bold.woff2") format("woff2");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Apercu Mono Pro";
  src: url("/fonts/ApercuMonoPro-Regular.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Apercu Mono Pro";
  src: url("/fonts/ApercuMonoPro-Medium.woff2") format("woff2");
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}

:root {
  --g-pink-light: #faf2f4;
  --g-pink: #f8e6ea;
  --g-black: #000000;
  --g-white: #ffffff;
  --g-cta-blue: #0600ff;
  --g-gray-shopgrid: #f7f7f7;
  --g-gray: #e3e3e3;

  --g-font: "Apercu Pro", ui-sans-serif, system-ui, -apple-system,
    "Helvetica Neue", Arial, sans-serif;
  --g-font-mono: "Apercu Mono Pro", ui-monospace, "SF Mono", Menlo, monospace;

  --g-leading-body: 1.333;
  --g-leading-display: 1;
  --g-tracking-display: 0.02em;

  --rule: 1px solid var(--g-black);
  /* Every control in a filter row is this tall, so the row reads as one band
   * rather than a set of boxes that nearly line up. */
  --control-h: 2.75rem;
  --gutter: clamp(1rem, 4vw, 2.5rem);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  font-family: var(--g-font);
  font-weight: 400;
  font-size: 1rem;
  line-height: var(--g-leading-body);
  letter-spacing: 0;
  color: var(--g-black);
  background: var(--g-pink-light);
  -webkit-font-smoothing: antialiased;
}

/* ---------- Type ---------- */

.display {
  font-weight: 700;
  text-transform: uppercase;
  line-height: var(--g-leading-display);
  letter-spacing: var(--g-tracking-display);
  margin: 0;
}

h1.display {
  font-size: clamp(1.75rem, 6vw, 2.75rem);
}

h2.display {
  font-size: clamp(1.0625rem, 2.4vw, 1.25rem);
}

.mono {
  font-family: var(--g-font-mono);
}

.eyebrow {
  font-family: var(--g-font-mono);
  font-size: 0.6875rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  line-height: 1.2;
  margin: 0;
}

.lede {
  max-width: 46ch;
  margin: 0;
}

/* ---------- Shell ---------- */

.masthead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
  padding: 1.25rem var(--gutter);
  background: var(--g-white);
  border-bottom: var(--rule);
}

/* The wordmark is the official vector-derived asset, never typeset. */
.masthead img {
  display: block;
  height: 20px;
  width: auto;
}

.masthead-nav {
  display: flex;
  align-items: baseline;
  gap: 1rem;
  text-align: right;
}

.masthead-nav .eyebrow {
  white-space: nowrap;
}

/* ---------- Signed-in account ----------
 * A <details> disclosure dressed as a square button, with the menu hung beneath
 * it. Square corners and black rules, like every other control here.
 */

.account-slot {
  min-width: 0;
}

.account {
  position: relative;
}

.account-summary {
  list-style: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.4375rem;
  max-width: 14rem;
  padding: 0.375rem 0.5rem;
  border: var(--rule);
  background: var(--g-white);
  font-family: var(--g-font);
  font-size: 0.8125rem;
  font-weight: 500;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Safari draws its own marker unless both of these are cleared. */
.account-summary::-webkit-details-marker {
  display: none;
}

.account-summary::after {
  content: "";
  flex: none;
  width: 0.375rem;
  height: 0.375rem;
  border-right: 2px solid var(--g-black);
  border-bottom: 2px solid var(--g-black);
  transform: translateY(-1px) rotate(45deg);
}

.account[open] .account-summary::after {
  transform: translateY(1px) rotate(225deg);
}

.account-summary:hover {
  background: var(--g-pink-light);
}

.account-summary:focus-visible {
  outline: 2px solid var(--g-cta-blue);
  outline-offset: 2px;
}

.account-menu {
  position: absolute;
  top: calc(100% + 0.25rem);
  right: 0;
  z-index: 20;
  min-width: max(100%, 13rem);
  padding: 0.625rem 0.75rem;
  border: var(--rule);
  background: var(--g-white);
  display: grid;
  gap: 0.5rem;
  text-align: left;
}

.account-email {
  margin: 0;
  font-family: var(--g-font-mono);
  font-size: 0.6875rem;
  line-height: 1.4;
  overflow-wrap: anywhere;
}

.account-signout {
  font-family: var(--g-font);
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--g-black);
  text-decoration: none;
  padding: 0.5rem 0.625rem;
  border: var(--rule);
  text-align: center;
}

.account-signout:hover {
  background: var(--g-black);
  color: var(--g-white);
}

.link {
  color: var(--g-cta-blue);
  text-decoration: underline;
  text-underline-offset: 3px;
}

main {
  display: grid;
  gap: 0;
}

@media (min-width: 62rem) {
  main {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  }
  main > .panel:first-child {
    border-right: var(--rule);
  }
}

.panel {
  padding: clamp(1.25rem, 3.5vw, 2rem) var(--gutter);
  border-bottom: var(--rule);
  background: var(--g-white);
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 1.25rem;
  align-content: start;
  min-width: 0;
}

/* The camera half sits on Glossier Pink, carrying black text as the book
 * specifies for a pink field. The values half stays white so the form reads
 * cleanly against it. */
.panel--camera {
  background: var(--g-pink);
}

.panel--camera .stage {
  background: var(--g-white);
}

/* With no footer, the final panel is the end of the page and needs room under
 * it — otherwise the last control sits flush against the bottom edge. */
main > .panel:last-child {
  padding-bottom: clamp(2rem, 5vw, 3rem);
}

.panel-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

/* ---------- Camera ---------- */

.stage {
  position: relative;
  aspect-ratio: 4 / 3;
  background: var(--g-gray-shopgrid);
  border: var(--rule);
  overflow: hidden;
}

.stage video,
.stage img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.stage video,
.stage img,
.stage .stage-empty {
  position: absolute;
  inset: 0;
}

.stage [hidden] {
  display: none !important;
}

.stage-empty {
  display: grid;
  place-content: center;
  gap: 0.5rem;
  text-align: center;
  padding: 1.5rem;
}

/* A guide to line the label up inside. Black on a live frame, no colour.
 * The bottom inset is a fixed measure rather than a percentage so the camera
 * controls in the bottom-left corner always have a band of their own, whatever
 * the height of the viewfinder works out to on a given phone. */
.reticle {
  position: absolute;
  inset: 12% 8% 3.75rem 8%;
  pointer-events: none;
  border: 2px solid var(--g-white);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.45);
}

.reticle::before,
.reticle::after {
  content: "";
  position: absolute;
  background: var(--g-white);
}

.reticle::before {
  inset: -0.5rem 45% auto -0.5rem;
  height: 2px;
}

.reticle::after {
  inset: auto -0.5rem -0.5rem 45%;
  height: 2px;
}

.stage-note {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  margin: 0;
  padding: 0.5rem 0.75rem;
  background: var(--g-white);
  border-top: var(--rule);
  font-family: var(--g-font-mono);
  font-size: 0.6875rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

/* ---------- Camera controls ----------
 * Square-cornered throughout, per the book: buttons stay square and
 * utilitarian. Icons are stroked geometry rather than pictograms, and state is
 * carried by fill — a lit torch is a filled button, never a coloured one.
 */

.stage-tools[hidden] {
  display: none;
}

/* Bottom left, below the framing guide rather than across it. */
.stage-tools {
  position: absolute;
  bottom: 0.5rem;
  left: 0.5rem;
  z-index: 2;
  display: flex;
  flex-direction: row;
  gap: 0.5rem;
}

.icon-button {
  position: relative;
  display: grid;
  place-items: center;
  width: 2.25rem;
  height: 2.25rem;
  padding: 0;
  border: var(--rule);
  border-radius: 0;
  background: var(--g-white);
  color: var(--g-black);
  cursor: pointer;
}

/* Drawn small so they stay clear of the framing guide, but the area that
 * answers a thumb is larger than the box on screen. The extra reach is half the
 * gap on each side, so the two never claim the same pixel. */
.icon-button::after {
  content: "";
  position: absolute;
  inset: -0.25rem;
}

.icon-button[hidden] {
  display: none;
}

.icon-button svg {
  width: 1.125rem;
  height: 1.125rem;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: square;
  stroke-linejoin: miter;
}

.icon-button:hover {
  background: var(--g-pink-light);
}

/* On, shown by fill rather than by colour. */
.icon-button[aria-pressed="true"] {
  background: var(--g-black);
  color: var(--g-white);
}

/* The one action that matters, sized for a thumb. */
.shutter-row {
  display: flex;
  gap: 0.5rem;
}

.shutter {
  flex: 1 1 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.625rem;
  min-height: 3.75rem;
  padding: 0.875rem 1.5rem;
  font-family: var(--g-font);
  font-size: 1.0625rem;
  font-weight: 500;
  line-height: 1;
  border: 1px solid var(--g-cta-blue);
  border-radius: 0;
  background: var(--g-cta-blue);
  color: var(--g-white);
  cursor: pointer;
  transition: background 120ms linear, border-color 120ms linear;
}

.shutter:hover:not(:disabled) {
  background: var(--g-black);
  border-color: var(--g-black);
}

.shutter:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.shutter[hidden] {
  display: none;
}

.shutter--secondary {
  background: var(--g-white);
  border-color: var(--g-black);
  color: var(--g-black);
}

.shutter--secondary:hover {
  background: var(--g-gray);
  border-color: var(--g-black);
  color: var(--g-black);
}

.shutter-icon {
  display: grid;
  place-items: center;
  flex: none;
}

.shutter-icon svg {
  width: 1.5rem;
  height: 1.5rem;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: square;
  stroke-linejoin: miter;
}

.shutter-icon svg .solid {
  fill: currentColor;
  stroke: none;
}

/* Only the icon for the current state is shown. */
.shutter[data-state="idle"] [data-icon="capture"],
.shutter[data-state="capture"] [data-icon="start"] {
  display: none;
}

.shutter:focus-visible,
.icon-button:focus-visible {
  outline: 2px solid var(--g-cta-blue);
  outline-offset: 2px;
}

.shutter--secondary:focus-visible {
  outline-color: var(--g-black);
}

/* ---------- Controls ---------- */

.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.625rem;
}

.button {
  font-family: var(--g-font);
  text-decoration: none;
  font-size: 0.9375rem;
  font-weight: 500;
  line-height: 1;
  padding: 0.875rem 1.5rem;
  border: var(--rule);
  border-radius: 0;
  background: var(--g-white);
  color: var(--g-black);
  cursor: pointer;
  text-align: center;
  transition: background 120ms linear, color 120ms linear;
}

.button:hover:not(:disabled) {
  background: var(--g-gray);
}

.button--primary {
  background: var(--g-cta-blue);
  border-color: var(--g-cta-blue);
  color: var(--g-white);
}

.button--primary:hover:not(:disabled) {
  background: var(--g-black);
  border-color: var(--g-black);
  color: var(--g-white);
}

.button--quiet {
  border-color: transparent;
  background: transparent;
  text-decoration: underline;
  text-underline-offset: 3px;
  padding: 0.875rem 0.25rem;
}

.button:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.button:focus-visible,
input:focus-visible,
textarea:focus-visible,
a:focus-visible {
  outline: 2px solid var(--g-cta-blue);
  outline-offset: 2px;
}

.grow {
  flex: 1 1 8rem;
}

/* ---------- Form ---------- */

.fields {
  display: grid;
  gap: 0.875rem;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 13rem), 1fr));
}

.field {
  display: grid;
  gap: 0.3125rem;
}

.field--wide {
  grid-column: 1 / -1;
}

.field label {
  font-family: var(--g-font-mono);
  font-size: 0.6875rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.field input,
.field textarea {
  font-family: var(--g-font);
  font-size: 1rem;
  line-height: 1.333;
  color: var(--g-black);
  background: var(--g-white);
  border: var(--rule);
  border-radius: 0;
  padding: 0.625rem 0.75rem;
  width: 100%;
  min-width: 0;
}

.field input.mono {
  font-family: var(--g-font-mono);
}

.field textarea {
  resize: vertical;
  min-height: 4.5rem;
}

/* Read from the label rather than typed by hand — marked by fill, not hue. */
.field input[data-scanned="true"],
.field textarea[data-scanned="true"] {
  background: var(--g-pink);
}

/* ---------- Status line ---------- */

.status {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-height: 1.25rem;
  margin: 0;
  font-family: var(--g-font-mono);
  font-size: 0.75rem;
}

.status:empty {
  display: none;
}

.spinner {
  width: 0.75rem;
  height: 0.75rem;
  flex: none;
  border: 2px solid var(--g-black);
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin 700ms linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@media (prefers-reduced-motion: reduce) {
  .spinner {
    animation-duration: 2.4s;
  }
}

/* ---------- Table ---------- */

.records {
  padding: clamp(1.25rem, 3.5vw, 2rem) var(--gutter) clamp(2.5rem, 6vw, 4rem);
  background: var(--g-pink-light);
  display: grid;
  /* minmax(0, 1fr) rather than 1fr: the wide table must not stretch the page. */
  grid-template-columns: minmax(0, 1fr);
  gap: 1.25rem;
}

/* Six controls in one row where there is room for it. Below that, two columns
 * with the odd one out spanning both, so a row is never left half empty. */
.records-tools {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 0.5rem;
  align-items: stretch;
}

@media (max-width: 68rem) {
  .records-tools {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

}

/* A control that would sit alone on the final row takes the whole width instead
 * of leaving a gap beside it. Bounded at the bottom as well as the top: in the
 * single-column layout a span of 2 invents an implicit second track, which is
 * sized auto rather than 1fr and makes the columns unequal. */
@media (min-width: 26.0625rem) and (max-width: 68rem) {
  .records-tools > .tool:last-child:nth-child(odd) {
    grid-column: span 2;
  }
}

/* Every control in the row shares one height, one box, and one type treatment:
 * the caption in Apercu Mono uppercase, the value in Apercu at one size. Before
 * this the toggles were mono 11px, the dates mono 13px and the search sans 15px,
 * which is what made the row look assembled from spare parts. */
.tool {
  min-height: var(--control-h);
  box-sizing: border-box;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0 0.75rem;
  border: var(--rule);
  border-radius: 0;
  background: var(--g-white);
  color: var(--g-black);
  font-family: var(--g-font);
  font-size: 0.9375rem;
  font-weight: 400;
  line-height: 1.2;
  min-width: 0;
}

/* The caption inside a control: "From", "To", "Show". */
.tool-label {
  flex: none;
  font-family: var(--g-font-mono);
  font-size: 0.6875rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  white-space: nowrap;
}

/* A control that holds a caption and a value. Named apart from the scanner's
 * .field wrapper: they share one stylesheet, and `.field > input { border: 0 }`
 * was quietly stripping the boxes off the scanner's form. */
.tool-field {
  cursor: pointer;
}

.tool-field:focus-within {
  outline: 2px solid var(--g-cta-blue);
  outline-offset: 2px;
}

.tool-field > input,
.tool-field > select {
  flex: 1 1 auto;
  min-width: 0;
  border: 0;
  padding: 0;
  background: transparent;
  color: var(--g-black);
  font-family: var(--g-font);
  font-size: 0.9375rem;
  line-height: 1.2;
  cursor: pointer;
}

.tool-field > input:focus,
.tool-field > select:focus {
  outline: none;
}

/* The chevron, drawn rather than left to the platform, so it matches the one on
 * the recipient picker. */
.tool-field > select {
  -webkit-appearance: none;
  appearance: none;
  padding-right: 1.125rem;
  background-image: linear-gradient(45deg, transparent 50%, var(--g-black) 50%),
    linear-gradient(135deg, var(--g-black) 50%, transparent 50%);
  background-position:
    calc(100% - 6px) calc(50% + 1px),
    calc(100% - 2px) calc(50% + 1px);
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
}

input.tool,
.tool input:not([type="checkbox"]) {
  -webkit-appearance: none;
  appearance: none;
}

input.tool::placeholder {
  color: var(--g-black);
  opacity: 0.55;
}

.table-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  min-width: 0;
  border: var(--rule);
  background: var(--g-white);
}

table {
  border-collapse: collapse;
  width: 100%;
  min-width: 62rem;
  font-size: 0.875rem;
}

th,
td {
  text-align: left;
  vertical-align: top;
  padding: 0.625rem 0.75rem;
  border-bottom: 1px solid var(--g-gray);
  white-space: nowrap;
}

th {
  position: sticky;
  top: 0;
  background: var(--g-black);
  color: var(--g-white);
  font-family: var(--g-font-mono);
  font-size: 0.6875rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  white-space: nowrap;
}

tbody tr:hover {
  background: var(--g-pink-light);
}

tbody tr:last-child td {
  border-bottom: none;
}

td.mono {
  font-family: var(--g-font-mono);
}

td.wrap {
  white-space: normal;
  min-width: 12rem;
  max-width: 20rem;
}

td.empty-cell::after {
  content: "—";
  font-family: var(--g-font-mono);
}

/* A chip and its action, stacked in one cell. */
.cell-stack {
  display: grid;
  gap: 0.3125rem;
  justify-items: start;
}

.cell-note {
  font-family: var(--g-font-mono);
  font-size: 0.625rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.row-action {
  font-family: var(--g-font-mono);
  font-size: 0.6875rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  background: none;
  border: none;
  border-bottom: 1px solid var(--g-black);
  padding: 0;
  color: var(--g-black);
  cursor: pointer;
}

.table-empty {
  padding: clamp(2rem, 6vw, 3.5rem) 1rem;
  gap: 0.75rem;
  text-align: center;
  background: var(--g-white);
  border: var(--rule);
  display: grid;
  gap: 0.5rem;
  place-items: center;
}

.count {
  font-family: var(--g-font-mono);
  font-size: 0.75rem;
}

a {
  color: var(--g-cta-blue);
  text-underline-offset: 3px;
}

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

/* ---------- Recipient matching ----------
 * Whether a package has a person attached is shown by fill and by wording,
 * never by hue: colour does not encode meaning in this brand.
 */

.hint {
  margin: 0;
  font-family: var(--g-font-mono);
  font-size: 0.6875rem;
  line-height: 1.4;
}

.match {
  margin-top: 1.5rem;
  padding-top: 1.25rem;
  border-top: var(--rule);
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 0.875rem;
}

.match .display {
  font-size: 1rem;
}

#match-body {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 0.875rem;
}

.candidates[hidden] {
  display: none;
}

.candidates {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 0.5rem;
}

/* Confirmation that a recipient is settled and the package can be logged.
 * A pink field with a filled black tick: Glossier Pink is the brand's own way
 * of highlighting, and colour is never asked to carry the meaning on its own —
 * the tick and the wording do that. */
.confirmed {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 0.875rem;
  border: var(--rule);
  background: var(--g-pink);
}

.confirmed[hidden] {
  display: none;
}

.confirmed-tick {
  flex: none;
  display: grid;
  place-items: center;
  width: 1.75rem;
  height: 1.75rem;
  background: var(--g-black);
}

.confirmed-tick svg {
  width: 1.125rem;
  height: 1.125rem;
  fill: none;
  stroke: var(--g-white);
  stroke-width: 2.5;
  stroke-linecap: square;
  stroke-linejoin: miter;
}

.confirmed-text {
  display: grid;
  gap: 0.125rem;
  min-width: 0;
}

.confirmed-name {
  font-weight: 500;
  font-size: 1rem;
  line-height: 1.2;
  overflow-wrap: anywhere;
}

.confirmed-how {
  font-family: var(--g-font-mono);
  font-size: 0.6875rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  line-height: 1.3;
}

/* A candidate is a toggle: pressed means this package is theirs. The box on the
 * left is an actual checkbox affordance, so which one is chosen is legible
 * without relying on the fill alone. */
.candidate {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 0.625rem;
  text-align: left;
  font-family: var(--g-font);
  background: var(--g-white);
  color: var(--g-black);
  border: var(--rule);
  border-radius: 0;
  padding: 0.75rem 0.875rem;
  cursor: pointer;
  min-width: 0;
}

.candidate:hover {
  background: var(--g-pink-light);
}

.candidate--on {
  background: var(--g-black);
  color: var(--g-white);
}

.candidate--on:hover {
  background: var(--g-black);
}

.candidate-check {
  flex: none;
  display: grid;
  place-items: center;
  width: 1.25rem;
  height: 1.25rem;
  border: 2px solid var(--g-black);
  background: var(--g-white);
}

.candidate-check svg {
  width: 0.875rem;
  height: 0.875rem;
  fill: none;
  stroke: var(--g-white);
  stroke-width: 3;
  stroke-linecap: square;
  stroke-linejoin: miter;
  visibility: hidden;
}

.candidate--on .candidate-check {
  background: var(--g-black);
  border-color: var(--g-white);
}

.candidate--on .candidate-check svg {
  visibility: visible;
}

.candidate-name {
  font-weight: 500;
  font-size: 1rem;
  line-height: 1.2;
}

.finder input[type="search"] {
  font-family: var(--g-font);
  font-size: 0.9375rem;
  padding: 0.6875rem 0.75rem;
  border: var(--rule);
  border-radius: 0;
  background: var(--g-white);
  color: var(--g-black);
  width: 100%;
  min-width: 0;
  -webkit-appearance: none;
  appearance: none;
}

/* Matched or not, in the table. Fill carries it, not colour. */
.chip {
  display: inline-block;
  font-family: var(--g-font-mono);
  font-size: 0.6875rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 0.25rem 0.5rem;
  border: var(--rule);
  background: var(--g-white);
  color: var(--g-black);
  white-space: nowrap;
}

.chip--on {
  background: var(--g-black);
  color: var(--g-white);
  text-transform: none;
  letter-spacing: 0;
  font-family: var(--g-font);
  font-weight: 500;
}

/* The form's own buttons need air now that the match panel sits above them. */
#form .controls {
  margin-top: 1.25rem;
}

/* ---------- Directory picker ---------- */

.picker {
  display: grid;
  gap: 0.3125rem;
  min-width: 0;
}

/* Native select, dressed to match the rest: square, Apercu, black rule, with a
 * drawn chevron in place of the platform arrow. On a phone this opens the system
 * picker, which is the fastest way through 271 names one-handed. */
.select {
  font-family: var(--g-font);
  font-size: 1rem;
  line-height: 1.333;
  color: var(--g-black);
  background-color: var(--g-white);
  border: var(--rule);
  border-radius: 0;
  padding: 0.625rem 2.25rem 0.625rem 0.75rem;
  width: 100%;
  min-width: 0;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--g-black) 50%),
    linear-gradient(135deg, var(--g-black) 50%, transparent 50%);
  background-position:
    calc(100% - 1.125rem) calc(50% + 2px),
    calc(100% - 0.75rem) calc(50% + 2px);
  background-size: 0.375rem 0.375rem, 0.375rem 0.375rem;
  background-repeat: no-repeat;
}

.select:hover {
  background-color: var(--g-pink-light);
}

.select optgroup {
  font-family: var(--g-font-mono);
  font-size: 0.75rem;
  font-style: normal;
  font-weight: 500;
}

.select option {
  font-family: var(--g-font);
  font-size: 1rem;
  color: var(--g-black);
}

/* ---------- Stored label photograph ---------- */

/* Both sizes of the photograph are buttons that expand it: the 44px one in the
 * table, and the full-width one in the row modal. */
.thumb,
.photo-expand {
  position: relative;
  display: block;
  padding: 0;
  border: var(--rule);
  border-radius: 0;
  background: var(--g-gray-shopgrid);
  overflow: hidden;
  cursor: zoom-in;
  color: var(--g-white);
}

.thumb {
  width: 44px;
  height: 44px;
}

.thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.thumb:hover,
.photo-expand:hover,
.thumb:focus-visible,
.photo-expand:focus-visible {
  outline: 2px solid var(--g-cta-blue);
  outline-offset: 1px;
}

/* The magnifying glass. Held back until the photograph is pointed at or
 * focused, so a column of thumbnails still reads as photographs. */
.zoom-badge {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(0, 0, 0, 0.45);
  opacity: 0;
  transition: opacity 120ms ease;
}

.zoom-badge svg {
  width: 1.125rem;
  height: 1.125rem;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: square;
}

.photo-expand .zoom-badge svg {
  width: 1.5rem;
  height: 1.5rem;
}

.thumb:hover .zoom-badge,
.thumb:focus-visible .zoom-badge,
.photo-expand:hover .zoom-badge,
.photo-expand:focus-visible .zoom-badge {
  opacity: 1;
}

/* Nothing hovers on a touch screen, so there it is always shown. */
@media (hover: none) {
  .zoom-badge {
    opacity: 1;
  }
}

@media (prefers-reduced-motion: reduce) {
  .zoom-badge {
    transition: none;
  }
}

/* ---------- The photograph, expanded ----------
 * A full-viewport dialog: the picture sits in the middle and everything around
 * it is backdrop to click away on.
 */

/* Flex, not grid: the picture's max-height is a percentage, and it needs a
 * definite height to resolve against. A centred auto grid track sizes itself to
 * its content, so the percentage resolved against a track the picture had just
 * sized — circular, and a tall photograph ran off the bottom of the window. A
 * flex item resolves against the container's own content box, which is the
 * height of the window less the padding. */
.lightbox[open] {
  display: flex;
  align-items: center;
  justify-content: center;
}

.lightbox {
  width: 100%;
  max-width: none;
  height: 100%;
  max-height: none;
  margin: 0;
  padding: clamp(1rem, 4vw, 2.5rem);
  border: 0;
  border-radius: 0;
  background: transparent;
  overflow: hidden;
}

.lightbox::backdrop {
  background: rgba(0, 0, 0, 0.8);
}

.lightbox img {
  display: block;
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 100%;
  /* The rule is white here, not black: on this backdrop a black hairline
   * disappears, and a dark photograph would bleed into the surround. */
  border: 1px solid var(--g-white);
  background: var(--g-white);
  cursor: zoom-out;
}

.lightbox-close-form {
  position: absolute;
  top: clamp(1rem, 4vw, 2.5rem);
  right: clamp(1rem, 4vw, 2.5rem);
  margin: 0;
}


/* ---------- Mobile ----------
 * This is a tool used one-handed, standing at a shelf, so on a narrow screen the
 * controls get bigger and the chrome gets out of the way.
 */

@media (max-width: 48rem) {
  :root {
    --gutter: 1rem;
    /* Matches the 3rem minimum the buttons take for touch, so the filter row
     * stays one height rather than a mix of 44 and 48. */
    --control-h: 3rem;
  }

  .masthead {
    padding: 0.875rem var(--gutter);
  }

  .masthead-nav {
    flex-direction: column;
    align-items: flex-end;
    gap: 0.1875rem;
  }

  .panel {
    padding: 1.125rem var(--gutter) 1.25rem;
    gap: 1rem;
  }

  /* A label is taller than it is wide, and so is a phone held up to one. */
  .stage {
    aspect-ratio: 3 / 4;
  }

  /* Thumb-sized, and one action per row rather than two cramped ones. */
  .controls--main {
    gap: 0.5rem;
  }

  .controls--main .button {
    flex: 1 1 100%;
    padding: 1.0625rem 1.5rem;
    font-size: 1rem;
  }

  .shutter {
    min-height: 4.25rem;
    font-size: 1.125rem;
  }

  .icon-button {
    width: 2.5rem;
    height: 2.5rem;
  }

  .icon-button svg {
    width: 1.25rem;
    height: 1.25rem;
  }

  .stage-tools {
    bottom: 0.625rem;
    left: 0.625rem;
  }

  .button {
    min-height: 3rem;
  }

  .field input,
  .field textarea,
  .select {
    /* 1rem or larger, so iOS does not zoom the page on focus. */
    font-size: 1rem;
    padding: 0.75rem;
  }

  .candidate {
    padding: 0.875rem;
    min-height: 3rem;
  }

  h1.display,
  h2.display {
    font-size: 1.125rem;
  }

  .records {
    padding: 1.125rem var(--gutter) 2rem;
  }

  .records-tools {
    gap: 0.5rem;
  }

}

/* Very narrow: one control per row. */
@media (max-width: 26rem) {
  .records-tools {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* ---------- Row modal ----------
 * A native <dialog>, dressed to match: square corners, black rules, Apercu.
 * The browser handles focus trapping, Escape, and the backdrop.
 */

.row-open {
  cursor: pointer;
}

.row-open:focus-visible {
  outline: 2px solid var(--g-cta-blue);
  outline-offset: -2px;
}

.modal {
  width: min(38rem, calc(100vw - 2rem));
  /* vh is the viewport with browser chrome hidden, so on a phone a 90vh modal
   * can run past the bottom of what is actually on screen. dvh follows the
   * chrome; the vh line above it is the fallback for anything that lacks it. */
  max-height: min(90vh, 52rem);
  max-height: min(90dvh, 52rem);
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: clamp(1.25rem, 4vw, 2rem);
  border: var(--rule);
  border-radius: 0;
  background: var(--g-white);
  color: var(--g-black);
  font-family: var(--g-font);
}

.modal::backdrop {
  background: rgba(0, 0, 0, 0.45);
}

.modal-close-form {
  float: right;
  margin: -0.25rem -0.25rem 0 0.75rem;
}

.modal-close {
  display: grid;
  place-items: center;
  width: 2.25rem;
  height: 2.25rem;
  padding: 0;
  border: var(--rule);
  border-radius: 0;
  background: var(--g-white);
  color: var(--g-black);
  cursor: pointer;
}

.modal-close svg {
  width: 1.125rem;
  height: 1.125rem;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: square;
}

.modal-close:hover {
  background: var(--g-black);
  color: var(--g-white);
}

#modal-title {
  font-size: clamp(1.0625rem, 3vw, 1.25rem);
  overflow-wrap: anywhere;
}

.modal-sub {
  margin: 0.375rem 0 0;
  font-size: 0.6875rem;
}

.modal-body {
  display: grid;
  grid-template-columns: 7.5rem minmax(0, 1fr);
  gap: 1rem;
  margin-top: 1.25rem;
  padding-top: 1.25rem;
  border-top: var(--rule);
}


/* The button carries the frame, so the image inside it does not draw a second
 * one. */
.modal-photo .photo-expand,
.modal-photo img {
  display: block;
  width: 100%;
}

.modal-facts {
  margin: 0;
  display: grid;
  grid-template-columns: minmax(0, auto) minmax(0, 1fr);
  gap: 0.375rem 0.875rem;
  align-content: start;
}

.modal-facts dt {
  font-family: var(--g-font-mono);
  font-size: 0.625rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  line-height: 1.5;
}

.modal-facts dd {
  margin: 0;
  font-size: 0.875rem;
  line-height: 1.4;
  overflow-wrap: anywhere;
}

.modal-section {
  margin-top: 1.25rem;
  padding-top: 1.25rem;
  border-top: var(--rule);
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 0.5rem;
  justify-items: start;
}

.modal-section .select,
.modal-section .button {
  width: 100%;
}

.modal-current {
  margin: 0;
  font-size: 1rem;
  font-weight: 500;
}

.modal-section .controls {
  width: 100%;
  align-items: center;
}

.modal-footer {
  margin-top: 1.25rem;
  padding-top: 1rem;
  border-top: 1px solid var(--g-gray);
}

#modal-status:not(:empty) {
  margin-top: 0.875rem;
}

/* ---------- Date filter and pager ---------- */


.pager {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.pager[hidden] {
  display: none;
}

.pager .count {
  margin: 0;
  text-align: center;
}

@media (max-width: 48rem) {
  .pager .button {
    flex: 1 1 auto;
  }
}

/* ---------- Modal on small screens ----------
 * Placed last on purpose: these override the base .modal rules above, and a
 * media query adds no specificity, so source order is what decides.
 */

@media (max-width: 34rem) {
  /* Every millimetre counts at this width, so the frame gets thinner and the
   * content gets the space. */
  .modal {
    width: calc(100vw - 1.5rem);
    padding: 1rem;
  }

  .modal-body {
    grid-template-columns: minmax(0, 1fr);
    gap: 0.875rem;
    margin-top: 1rem;
    padding-top: 1rem;
  }

  /* The label photo is capped in height so it does not push the recipient
   * controls off the bottom of a phone. Width is auto rather than 100%: with a
   * full-width box and object-fit, the border was drawn around the box and the
   * letterboxing inside it, sitting well away from the picture. Sizing the
   * element to the image instead means the border hugs the photo. */
  .modal-photo img {
    width: auto;
    max-width: 100%;
    max-height: 10rem;
    object-fit: contain;
  }

  .modal-photo .photo-expand {
    width: max-content;
    max-width: 100%;
  }

  /* Label above value rather than beside it. Side by side, a long label like
   * "Recipient, as printed" left the value a third of the width, which broke
   * email addresses across three lines. */
  .modal-facts {
    grid-template-columns: minmax(0, 1fr);
    gap: 0;
  }

  .modal-facts dt {
    margin-top: 0.625rem;
  }

  .modal-facts dt:first-child {
    margin-top: 0;
  }

  .modal-facts dd {
    margin-top: 0.0625rem;
  }

  .modal-section {
    margin-top: 1rem;
    padding-top: 1rem;
  }

  #modal-title {
    font-size: 1rem;
    /* Clear of the close button, which floats into this line. */
    padding-right: 0.5rem;
  }
}

/* A landscape phone is short rather than narrow: keep the frame off the edges
 * and let the content scroll rather than the dialog being clipped. */
@media (max-height: 30rem) {
  .modal {
    max-height: calc(100dvh - 1.5rem);
    padding: 0.875rem 1rem;
  }
}

/* A button used as a row control takes the row's height and centring, not its
 * own generous padding. */
.records-tools .button {
  justify-content: center;
  padding: 0 0.875rem;
  font-family: var(--g-font);
  font-size: 0.9375rem;
  font-weight: 500;
  text-align: center;
}

/* ---------- Logged result ----------
 * The outcome of logging, auto or by hand. Black field rather than the pink of
 * "ready to log": one is a state to act on, the other is a thing that has
 * happened, and they should not be mistaken for each other at a glance.
 */

.logged {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-top: 1.25rem;
  padding: 0.875rem;
  border: var(--rule);
  background: var(--g-black);
  color: var(--g-white);
}

.logged[hidden] {
  display: none;
}

.logged .confirmed-tick {
  background: var(--g-white);
}

.logged .confirmed-tick svg {
  stroke: var(--g-black);
}

.logged .confirmed-name {
  font-size: 1.0625rem;
}


/* ---------- Success screen ----------
 * Shown when a scan matched and logged itself. Deliberately an interruption:
 * the next package is scanned into the same screen, so one has to be closed off
 * before the next begins. Glossier Pink field, black mark, square corners.
 */

.success {
  width: min(26rem, calc(100vw - 2rem));
  max-height: min(90vh, 40rem);
  max-height: min(90dvh, 40rem);
  padding: clamp(1.5rem, 6vw, 2.25rem);
  border: var(--rule);
  border-radius: 0;
  background: var(--g-pink);
  color: var(--g-black);
  text-align: center;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.success::backdrop {
  background: rgba(0, 0, 0, 0.55);
}

.success-tick {
  display: grid;
  place-items: center;
  width: 3.5rem;
  height: 3.5rem;
  margin: 0 auto 1rem;
  background: var(--g-black);
}

.success-tick svg {
  width: 2.25rem;
  height: 2.25rem;
  fill: none;
  stroke: var(--g-white);
  stroke-width: 2.5;
  stroke-linecap: square;
  stroke-linejoin: miter;
}

#success-name {
  margin: 0;
  font-size: clamp(1.125rem, 4.5vw, 1.5rem);
  overflow-wrap: anywhere;
}

.success-detail {
  margin: 0.625rem 0 1.5rem;
  font-family: var(--g-font-mono);
  font-size: 0.75rem;
  line-height: 1.5;
}

.success .shutter {
  width: 100%;
}

/* ---------- Choose the recipient ----------
 * The counterpart to the success screen. A scan that settles the recipient
 * announces itself; one that cannot settle it asks here, in the same place and
 * with the same weight, so the answer is given while the package is in hand
 * rather than left on a form to be found later.
 *
 * White field rather than the pink of the success screen: pink says done, and
 * this is the state that still needs something from you. Left-aligned too — a
 * list is read down its left edge, not from the middle.
 */

.choose {
  width: min(26rem, calc(100vw - 2rem));
  max-height: min(90vh, 44rem);
  max-height: min(90dvh, 44rem);
  padding: clamp(1.25rem, 5vw, 2rem);
  border: var(--rule);
  border-radius: 0;
  background: var(--g-white);
  color: var(--g-black);
  overflow-y: auto;
  overscroll-behavior: contain;
}

.choose::backdrop {
  background: rgba(0, 0, 0, 0.55);
}

#choose-heading {
  margin: 0.25rem 0 0;
  font-size: clamp(1.125rem, 4.5vw, 1.5rem);
}

/* What the label said, quoted rather than restated: it is evidence, so it keeps
 * the mono face the scanned values use and is bounded so a whole address block
 * cannot push the picker off the screen. */
.choose-printed {
  margin: 0.75rem 0 0;
  padding: 0.625rem 0.75rem;
  max-height: 5.5rem;
  overflow-y: auto;
  border: var(--rule);
  background: var(--g-gray-shopgrid);
  font-size: 0.75rem;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.choose-note {
  margin: 0.75rem 0 0;
  font-size: 0.875rem;
  line-height: 1.45;
}

.choose .candidates {
  margin-top: 1rem;
}

.choose .candidates[hidden] {
  display: none;
}

.choose-picker {
  display: grid;
  gap: 0.3125rem;
  min-width: 0;
  margin-top: 1rem;
}

.choose .shutter {
  width: 100%;
  margin-top: 1.25rem;
}

/* Disabled deliberately reads as unavailable rather than as a lit action: the
 * package cannot be logged until somebody is chosen, and the button says so. */
.choose .shutter:disabled {
  background: var(--g-gray);
  color: var(--g-black);
  border-color: var(--g-gray);
  cursor: not-allowed;
}

.choose .shutter:disabled .shutter-icon {
  display: none;
}

/* The two ways out, quieter than the action above them and separated from it by
 * a rule so neither is pressed by mistake on the way to the button. */
.choose-outs {
  display: grid;
  gap: 0.5rem;
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: var(--rule);
}

.choose-outs .button {
  width: 100%;
  justify-content: center;
  text-align: center;
}
