/* 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);
  --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);
  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;
}

.records-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 0.625rem;
  align-items: center;
}

.records-tools input[type="search"] {
  font-family: var(--g-font);
  font-size: 0.9375rem;
  padding: 0.75rem 0.875rem;
  border: var(--rule);
  border-radius: 0;
  background: var(--g-white);
  color: var(--g-black);
  flex: 1 1 14rem;
  min-width: 0;
  -webkit-appearance: none;
  appearance: none;
}

.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;
}

.toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-family: var(--g-font-mono);
  font-size: 0.6875rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 0.75rem 0.875rem;
  border: var(--rule);
  background: var(--g-white);
  cursor: pointer;
  white-space: nowrap;
}

.toggle input {
  width: 0.875rem;
  height: 0.875rem;
  accent-color: var(--g-cta-blue);
  margin: 0;
}

/* 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 ---------- */

.thumb {
  display: block;
  width: 44px;
  height: 44px;
  border: var(--rule);
  background: var(--g-gray-shopgrid);
  overflow: hidden;
}

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

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


/* ---------- 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;
  }

  .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;
  }

  .records-tools input[type="search"] {
    flex: 1 1 100%;
  }

  .toggle {
    flex: 1 1 auto;
    justify-content: center;
  }
}

/* Very narrow: stack the tool row completely. */
@media (max-width: 26rem) {
  .records-tools .button,
  .records-tools .toggle {
    flex: 1 1 100%;
  }
}

/* ---------- 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));
  max-height: min(90vh, 52rem);
  overflow-y: auto;
  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);
}

@media (max-width: 34rem) {
  .modal-body {
    grid-template-columns: minmax(0, 1fr);
  }

  /* Full width, the label photo pushed the recipient controls off the bottom of
   * a phone. Capped so the reason you opened the modal is reachable without
   * scrolling past a picture you can tap to enlarge anyway. */
  .modal-photo img {
    max-height: 9rem;
    object-fit: contain;
    object-position: left top;
    background: var(--g-white);
  }
}

.modal-photo a,
.modal-photo img {
  display: block;
  width: 100%;
}

.modal-photo img {
  border: var(--rule);
  background: var(--g-gray-shopgrid);
}

.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;
}
