:root {
  color-scheme: light;
  --bg: #F6F4F1;
  --surface: #FFFFFF;
  --text: #1D1B19;
  --muted: #6B6661;
  --accent: #E5484D;
  --link: #A72B31;
  --line: #E7E2DC;
  --control-line: #918880;
  --success: #2F9E62;
  --warning: #D9822B;
  --height: 40px;
  --focus: 2px solid var(--link);
  --width: 1040px;
  font: 16px/1.5 -apple-system, "Segoe UI", Roboto, sans-serif;
}
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--bg); color: var(--text); }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: inherit; }
a, button, input, select, textarea, summary { -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: var(--focus); outline-offset: 3px; }
#content:focus { outline: none; }
p, h1, h2, h3, dl, dd, ol, ul, fieldset { margin: 0; }
p, dd, h1, h2, h3, summary, label { overflow-wrap: anywhere; }
h1, h2, h3 { line-height: 1.14; text-wrap: balance; }
h1 { font-size: clamp(2rem, 6vw, 3rem); letter-spacing: -.035em; font-weight: 700; }
h2 { font-size: 1.375rem; letter-spacing: -.02em; font-weight: 700; }
h3 { font-size: 1.125rem; font-weight: 700; }
svg { width: 20px; height: 20px; flex: 0 0 20px; }
img { display: block; max-width: 100%; }
.top { background: var(--surface); border-bottom: 1px solid var(--line); }
.top-inner { max-width: var(--width); margin: auto; padding: 12px 16px; display: flex; align-items: center; justify-content: space-between; gap: 24px; }
.brand { display: inline-flex; align-items: center; gap: 8px; min-height: var(--height); font-weight: 700; font-size: 1.25rem; letter-spacing: -.025em; text-decoration: none; }
.brand img { border-radius: 8px; }
#nav { display: flex; gap: 8px; }
#nav a { display: flex; align-items: center; justify-content: center; gap: 8px; min-height: var(--height); padding: 4px 12px; border-radius: 12px; text-decoration: none; font-weight: 600; color: var(--muted); }
#nav a[aria-current], .tabs a[aria-current] { background: #FCE9E7; color: var(--link); }
#content { max-width: var(--width); margin: 0 auto; padding: 32px 16px 48px; display: grid; gap: 24px; }
#content > *, .columns > *, .pair > *, .stack > * { min-width: 0; }
.stack { display: grid; align-content: start; gap: 16px; }
.compact { gap: 8px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 16px; }
.card-heading, .heading, .actions { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 12px; }
.card-heading, .heading { justify-content: space-between; }
.route { display: inline; }
.route-arrow { display: inline-flex; align-items: center; vertical-align: middle; padding: 0 .2em; color: var(--muted); }
.route-arrow svg { width: .75em; height: .75em; }
.price { font-size: 1.375rem; font-variant-numeric: tabular-nums; }
.listing { gap: 8px; }
.listing h3 a { text-decoration: none; }
.muted { color: var(--muted); }
small, .pill, time { font-size: .875rem; }
.pill { padding: 4px 8px; border-radius: 100px; background: var(--bg); color: var(--muted); font-weight: 600; white-space: nowrap; }
.pill.delivered, .pill.inspected { background: #E5F4EB; color: #246B48; }
.pill.in_transit, .pill.open { background: #FCE9E7; color: var(--link); }
.pill.inspected_wait, .pill.taken { background: #FCEDDC; color: #774611; }
.button {
  display: inline-flex; align-items: center; justify-content: center; justify-self: start; gap: 8px;
  min-height: var(--height); max-width: 100%; padding: 8px 16px; border: 1px solid var(--control-line); border-radius: 12px;
  background: var(--surface); text-align: center; line-height: 1.25; text-decoration: none; font-weight: 600;
  cursor: pointer; transition: background-color 140ms, border-color 140ms;
}
.button.primary { min-height: 48px; color: var(--text); background: var(--accent); border-color: var(--accent); font-weight: 700; }
.button.danger, .text-link { color: var(--link); }
.button:active { background: var(--line); }
.button.primary:active { background: #F07779; }
.button:disabled { color: var(--muted); border-color: var(--line); background: var(--bg); cursor: default; }
.text-link { display: inline-flex; align-items: center; min-height: var(--height); justify-self: start; font-weight: 600; text-underline-offset: 3px; }
.hero {
  padding: clamp(24px, 5vw, 48px); border: 1px solid var(--line); border-radius: 16px; background: var(--surface); gap: 16px;
}
.hero h1 { max-width: 19ch; text-wrap: wrap; }
.hero p { max-width: 72ch; color: var(--muted); }
.hero-actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 8px; }
.hero-actions .button { min-height: 48px; }
.how { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); border: 1px solid var(--line); border-radius: 16px; background: var(--surface); }
.how > div { display: flex; align-items: center; justify-content: center; gap: 8px; padding: 16px 8px; font-size: .875rem; font-weight: 600; }
.how > div + div { border-left: 1px solid var(--line); }
.how svg { color: var(--link); }
.notice { padding: 12px 16px; border-radius: 12px; background: #EFEAE4; }
.warning { background: #FCEDDC; border: 1px solid var(--warning); }
.payment { gap: 4px; }
.columns, .pair { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.columns { gap: 24px; }
.form { padding: 24px; max-width: 720px; }
.form .primary { width: 100%; }
.field { display: grid; gap: 4px; align-content: start; }
.field > label, legend { padding: 0; font-weight: 600; }
fieldset { border: 0; padding: 0; min-inline-size: 0; }
legend { margin-bottom: 4px; }
.field small:empty { display: none; }
.field-error, .form-error { color: var(--link); }
input:not([type="radio"], [type="checkbox"]), select, textarea {
  display: block; width: 100%; min-width: 0; min-height: var(--height); padding: 8px 12px;
  border: 1px solid var(--control-line); border-radius: 12px; background: var(--surface);
  font-size: 16px; line-height: 1.25;
}
textarea { resize: vertical; }
input[aria-invalid="true"], textarea[aria-invalid="true"] { border-color: var(--link); }
input[type="file"] {
  padding: 0;
  border: 0;
  line-height: var(--height);
}
input[type="file"]::file-selector-button {
  height: var(--height); margin-right: 8px; padding: 0 12px; border: 1px solid var(--control-line);
  border-radius: 12px; background: var(--bg); color: var(--text); font: inherit; cursor: pointer;
}
.choices { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.choices label, .stars label { position: relative; display: grid; cursor: pointer; }
.choices input, .stars input { position: absolute; opacity: 0; }
.choices span, .stars span {
  display: grid; align-items: center; min-height: var(--height); padding: 8px 12px;
  border: 1px solid var(--control-line); border-radius: 12px; line-height: 1.25; font-weight: 600;
}
.choices input:checked + span, .stars label:has(~ label input:checked) span, .stars input:checked + span {
  border-color: var(--accent); background: #FCE9E7; color: var(--link);
}
.choices input:focus-visible + span, .stars input:focus-visible + span { outline: var(--focus); outline-offset: 3px; }
.stars { display: flex; gap: 4px; }
.stars span { justify-content: center; width: var(--height); padding: 4px; font-size: 1.25rem; }
.check { display: flex; align-items: center; gap: 12px; min-height: var(--height); cursor: pointer; }
.check input { flex: 0 0 20px; width: 20px; height: 20px; margin: 0; accent-color: var(--link); }
summary { cursor: pointer; min-height: var(--height); align-content: center; color: var(--link); }
.tabs { display: flex; flex-wrap: wrap; gap: 4px; padding: 4px; border: 1px solid var(--line); border-radius: 16px; background: var(--surface); justify-self: start; }
.tabs a { display: inline-flex; align-items: center; justify-content: center; min-height: var(--height); padding: 4px 12px; border-radius: 12px; text-decoration: none; font-weight: 600; color: var(--muted); }
.timeline { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px; padding: 0; list-style: none; }
.timeline li { display: grid; justify-items: start; gap: 8px; color: var(--muted); font-size: .875rem; line-height: 1.25; }
.timeline time { display: block; margin-top: 4px; font-size: .75rem; }
.timeline li.current { color: var(--link); }
.timeline li.done:not(.current) { color: var(--text); }
.step-mark { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 100px; background: var(--bg); font-weight: 700; }
.done .step-mark { background: #E5F4EB; color: #246B48; }
.current .step-mark { background: #FCE9E7; color: var(--link); box-shadow: 0 0 0 1px var(--accent); }
.next { border-top: 1px solid var(--line); padding-top: 16px; }
.photos { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; max-width: 560px; }
.photos img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 12px; background: var(--bg); }
.contacts .compact + .compact { border-top: 1px solid var(--line); padding-top: 16px; }
dt { color: var(--muted); }
dd + dt { margin-top: 8px; }
.code { font-size: clamp(2.5rem, 10vw, 4rem); font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: .12em; line-height: 1.1; }
input.code-input { font-size: 1.5rem; font-variant-numeric: tabular-nums; letter-spacing: .12em; }
.rules { padding-left: 24px; }
.rules li + li { margin-top: 8px; }
details > .rules, details > p { margin-top: 8px; }
.checked { padding: 0; list-style: none; display: grid; gap: 8px; }
.checked li { display: flex; align-items: start; gap: 8px; }
.checked svg { color: #246B48; }
.profile-links { display: flex; flex-wrap: wrap; gap: 8px 16px; }
.metrics { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.metrics > div { padding: 12px; border: 1px solid var(--line); border-radius: 16px; background: var(--surface); display: grid; align-content: space-between; }
.metrics dt { font-size: .875rem; overflow-wrap: anywhere; }
.metrics dd { font-size: 1.5rem; font-weight: 700; }
.refresh-error { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
#toast {
  position: fixed; bottom: 16px; left: 50%; transform: translate(-50%, 8px); opacity: 0;
  max-width: min(calc(100% - 32px), 440px); width: max-content; z-index: 2; padding: 12px 16px;
  background: var(--text); color: var(--surface); border-radius: 12px; pointer-events: none; transition: opacity 140ms, transform 140ms;
}
#toast.shown { transform: translate(-50%, 0); opacity: 1; }
@media (hover: hover) {
  .button:not(:disabled):hover, #nav a:not([aria-current]):hover, .tabs a:not([aria-current]):hover { background: var(--bg); }
  .button.primary:not(:disabled):hover { background: #F07779; }
  .listing h3 a:hover { text-decoration: underline; text-underline-offset: 4px; }
  .choices label:hover span, .stars label:hover span { border-color: var(--accent); }
}
@media (pointer: coarse) { :root { --height: 44px; } }
@media (max-width: 640px) {
  .top-inner { padding-top: max(8px, env(safe-area-inset-top)); padding-bottom: 8px; }
  #nav {
    position: fixed; z-index: 1; bottom: 0; left: 0; right: 0; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr));
    background: var(--surface); border-top: 1px solid var(--line); padding: 4px 8px max(4px, env(safe-area-inset-bottom)); gap: 4px;
  }
  #nav a { flex-direction: column; gap: 4px; padding: 4px; min-height: 52px; font-size: .75rem; line-height: 1.1; }
  #content { padding-top: 16px; padding-bottom: calc(80px + env(safe-area-inset-bottom)); gap: 16px; }
  #toast { bottom: calc(68px + env(safe-area-inset-bottom)); }
  .hero { padding: 16px; }
  .hero-actions { display: grid; margin-top: 0; gap: 8px; }
  .hero-actions .button { justify-self: stretch; }
  .how > div { flex-direction: column; text-align: center; padding: 12px 4px; line-height: 1.25; }
  .columns, .pair { grid-template-columns: minmax(0, 1fr); gap: 16px; }
  .form { padding: 16px; }
  .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .timeline { grid-template-columns: minmax(0, 1fr); gap: 4px; }
  .timeline li { display: flex; align-items: center; min-height: 36px; gap: 8px; }
  .timeline li > span:last-child { display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px 8px; }
  .timeline time { margin: 0; }
  .step-mark { flex: 0 0 32px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; }
}

.listing { position: relative; }
.listing h3 a::after { content: ""; position: absolute; inset: 0; border-radius: 16px; }
.listing .button { position: relative; z-index: 1; }
.parcel-card { display: flex; align-items: start; gap: 12px; }
.parcel-card > div { min-width: 0; flex: 1; }
.thumb { width: 48px; height: 48px; border-radius: 12px; object-fit: cover; flex: 0 0 48px; }
