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

[hidden] { display: none !important; }

:root {
  --fg: #fff;
  --bg: #000;
  --muted: #a3a3a3;
  --hairline: #fff;
  --hairline-soft: #3a3a3a;
  --ring: #fff;
  --danger: #fff;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --radius: 8px;
  --radius-sm: 6px;
}

html { color-scheme: dark; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--fg);
  font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
  font-size: 16px;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
}

body {
  display: flex;
  flex-direction: column;
}

a { color: inherit; }

button {
  font: inherit;
  color: inherit;
  background: var(--bg);
  border: 1px solid var(--fg);
  padding: 0.6rem 1rem;
  cursor: pointer;
  border-radius: var(--radius-sm);
}
button:disabled { opacity: 0.5; cursor: default; }
button:focus-visible { outline: 2px solid var(--ring); outline-offset: 2px; }

input, textarea, select {
  font: inherit;
  color: inherit;
  background: var(--bg);
  border: 1px solid var(--fg);
  padding: 0.6rem 0.75rem;
  width: 100%;
  border-radius: var(--radius-sm);
}
input:focus-visible, textarea:focus-visible, select:focus-visible { outline: 2px solid var(--ring); outline-offset: 2px; }

label {
  display: block;
  font-size: 0.85rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.field { display: flex; flex-direction: column; gap: 0.3rem; }
.field-help { font-size: 0.8rem; color: var(--muted); margin: 0; line-height: 1.4; }

/* ---------- shared ---------- */

.page-center {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 1.5rem;
}

.card {
  width: 100%;
  max-width: 420px;
  border: 1px solid var(--fg);
  border-radius: var(--radius);
  padding: 1.25rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  align-items: stretch;
}

.brand {
  font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
  font-size: 2rem;
  margin: 0;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  text-align: center;
  font-weight: 700;
}

.lede { margin: 0; color: var(--muted); text-align: center; }
.status { color: var(--muted); text-align: center; }
.err { color: var(--fg); border: 1px solid var(--fg); border-radius: var(--radius-sm); padding: 0.5rem 0.75rem; margin: 0; }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }

.stack { display: flex; flex-direction: column; gap: 0.75rem; }
.row { display: flex; gap: 0.5rem; }
.row > * { flex: 1; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  border: 1px solid var(--fg);
  background: var(--bg);
  color: var(--fg);
  padding: 0.7rem 1rem;
  min-height: 44px;
  cursor: pointer;
  border-radius: var(--radius-sm);
}
.btn-primary { background: var(--fg); color: var(--bg); }
.btn-danger  { background: var(--fg); color: var(--bg); }

.btn-small-outline {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  min-height: 36px;
  padding: 0.35rem 0.75rem;
  font-size: 0.85rem;
  background: var(--bg);
  color: var(--fg);
  border: 1px solid var(--hairline-soft);
  border-radius: var(--radius-sm);
  cursor: pointer;
  align-self: center;
  opacity: 0.85;
}
.btn-small-outline:hover,
.btn-small-outline:focus-visible { opacity: 1; border-color: var(--fg); }

.btn-row { display: flex; gap: 0.5rem; }
.btn-row .btn { flex: 1; }

/* ---------- landing ---------- */

.landing {
  height: auto;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding: clamp(0.75rem, 4vh, 3rem) 1rem max(1.75rem, env(safe-area-inset-bottom));
  gap: 1.25rem;
}
.landing .card { align-self: center; }

.explainer {
  width: 100%;
  max-width: 420px;
  color: var(--fg);
  font-family: "Courier New", Courier, ui-monospace, monospace;
  font-size: 0.85rem;
  line-height: 1.45;
  letter-spacing: 0;
  word-spacing: -0.05em;
}
.explainer p {
  margin: 0 0 0.55rem 0;
  color: var(--fg);
  text-indent: 1.5em;
}
.explainer p:last-child { margin-bottom: 0; }
.explainer em {
  color: var(--fg);
  font-style: italic;
}
.explainer .cp-link {
  color: var(--fg);
  text-decoration: none;
  cursor: pointer;
}

.explainer-cursor {
  display: inline-block;
  width: 0.5ch;
  height: 1em;
  background: var(--fg);
  vertical-align: -0.15em;
  margin-left: 1px;
  animation: veil-blink 0.85s step-end infinite;
}
@keyframes veil-blink {
  0%, 50% { opacity: 1; }
  50.01%, 100% { opacity: 0; }
}

.open-existing {
  display: flex;
  gap: 0.4rem;
  align-items: stretch;
}
.open-existing input { font-size: 0.9rem; }

.tertiary-link {
  color: var(--muted);
  text-decoration: none;
  text-align: center;
  font-size: 0.85rem;
  letter-spacing: 0.04em;
}
.tertiary-link:hover, .tertiary-link:focus-visible { color: var(--fg); }

/* ---------- shipment view ---------- */

.shipment-body {
  min-height: 100dvh;
  padding: clamp(0.75rem, 4vh, 2rem) 1rem max(1.75rem, env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
}
.shipment {
  width: 100%;
  max-width: 560px;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.shipment-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}
.shipment-header .brand { text-align: left; font-size: 1.5rem; }
.shipment-role {
  font-size: 0.75rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  border: 1px solid var(--hairline-soft);
  padding: 0.25rem 0.5rem;
  border-radius: var(--radius-sm);
}

.section {
  border: 1px solid var(--fg);
  border-radius: var(--radius);
  padding: 1rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.section h2 {
  margin: 0;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}

.address-block {
  font-family: var(--mono);
  font-size: 1rem;
  white-space: pre-wrap;
  word-wrap: break-word;
}

.banner {
  border: 1px solid var(--fg);
  background: var(--fg);
  color: var(--bg);
  padding: 0.6rem 0.75rem;
  border-radius: var(--radius-sm);
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  text-align: center;
  font-size: 0.85rem;
}
.banner-faint {
  background: var(--bg);
  color: var(--muted);
  border: 1px dashed var(--hairline-soft);
  font-weight: 400;
  letter-spacing: 0;
  text-transform: none;
  font-size: 0.9rem;
  text-align: left;
}

.share-link {
  border: 1px solid var(--fg);
  border-radius: var(--radius-sm);
  padding: 0.5rem 0.75rem;
  overflow-wrap: anywhere;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}
.share-link code { font-family: var(--mono); font-size: 0.85rem; }
.share-link button { flex-shrink: 0; }

.id-block {
  border: 1px solid var(--hairline-soft);
  border-radius: var(--radius-sm);
  padding: 0.6rem 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}
.id-block .id-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  justify-content: space-between;
  overflow: hidden;
}
.id-block .id-row code {
  font-family: var(--mono);
  font-size: 0.85rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
}
.id-block .id-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  width: 4rem;
  flex-shrink: 0;
}

/* ---------- timeline ---------- */

.timeline {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
}
.timeline li {
  display: grid;
  grid-template-columns: 1.25rem 1fr;
  gap: 0.6rem;
  padding: 0.4rem 0 0.4rem 0;
  position: relative;
}
.timeline li::before {
  content: "";
  width: 9px;
  height: 9px;
  border: 1px solid var(--fg);
  border-radius: 50%;
  background: var(--bg);
  margin-top: 0.45rem;
  margin-left: 0.2rem;
}
.timeline li::after {
  content: "";
  position: absolute;
  left: calc(0.2rem + 4px);
  top: 1.3rem;
  bottom: -0.4rem;
  width: 1px;
  background: var(--hairline-soft);
}
.timeline li:last-child::after { display: none; }
.timeline li.done::before { background: var(--fg); }
.timeline li.active::before { background: var(--fg); box-shadow: 0 0 0 3px var(--bg), 0 0 0 4px var(--fg); }
.timeline li.bad::before { background: var(--bg); border-color: var(--fg); }
.timeline li.bad { border-left: 0; }
.timeline-label {
  font-size: 0.85rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.timeline li.future .timeline-label { color: var(--muted); }
.timeline-time {
  font-size: 0.75rem;
  color: var(--muted);
  font-family: var(--mono);
}

/* ---------- modal ---------- */

.modal {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 1rem;
}
.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.65);
}
.modal-panel {
  position: relative;
  background: var(--bg);
  border: 1px solid var(--fg);
  border-radius: var(--radius);
  max-width: 420px;
  width: 100%;
  padding: 1rem;
  max-height: calc(100dvh - 2rem);
  overflow: auto;
}
.modal-close {
  position: absolute;
  top: 0.25rem;
  right: 0.25rem;
  border: 1px solid transparent;
  background: transparent;
  font-size: 1.5rem;
  line-height: 1;
  width: 40px;
  height: 40px;
  padding: 0;
  border-radius: var(--radius-sm);
}
.modal-stack { display: flex; flex-direction: column; gap: 0.6rem; }
.modal-stack h2 { margin: 0; font-size: 1.15rem; }

/* ---------- how-it-works ---------- */

.prose {
  width: 100%;
  max-width: 640px;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  padding: clamp(1rem, 4vh, 3rem) 1rem;
  margin: 0 auto;
}
.prose h1 {
  font-size: 2rem;
  margin: 0;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
.prose-step {
  display: grid;
  grid-template-columns: 3rem 1fr;
  gap: 1rem;
  align-items: start;
}
.prose-step-num {
  font-family: var(--mono);
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--muted);
  line-height: 1.1;
}
.prose-step-body p {
  margin: 0;
  line-height: 1.55;
}
.prose-step-body h3 {
  margin: 0 0 0.4rem 0;
  font-size: 1rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.divider {
  border: none;
  border-top: 1px solid var(--hairline-soft);
  margin: 0.5rem 0;
}

.disclaimer {
  font-size: 0.85rem;
  color: var(--muted);
  border: 1px dashed var(--hairline-soft);
  border-radius: var(--radius-sm);
  padding: 0.75rem;
}
.disclaimer p { margin: 0 0 0.5rem 0; }
.disclaimer p:last-child { margin: 0; }

/* ---------- printable label ---------- */

.label-body {
  background: #fff;
  color: #000;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 1.5rem;
  font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
}

.label-bar {
  position: fixed;
  top: 0.75rem;
  right: 0.75rem;
  display: flex;
  gap: 0.5rem;
  z-index: 5;
}
.label-bar .btn {
  background: #000;
  color: #fff;
  border-color: #000;
  min-height: 38px;
  padding: 0.4rem 0.9rem;
}
.label-bar .btn-small-outline {
  background: #fff;
  color: #000;
  border-color: #000;
  opacity: 1;
}

.label {
  width: 100%;
  max-width: 480px;
  text-align: center;
  border: 2px solid #000;
  padding: 1.5rem 1.25rem;
  background: #fff;
  color: #000;
}
.label-brand {
  text-transform: uppercase;
  letter-spacing: 0.2em;
  font-weight: 700;
  font-size: 1.05rem;
  margin: 0 0 0.5rem 0;
}
.label-tag {
  font-size: 0.75rem;
  color: #444;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin: 0.25rem 0;
}
.label-qr {
  display: grid;
  place-items: center;
  margin: 0.75rem auto;
}
.label-qr svg {
  width: 100%;
  max-width: 320px;
  height: auto;
  display: block;
}
.label-code {
  font-family: var(--mono);
  font-size: 1.05rem;
  letter-spacing: 0.04em;
  word-break: break-all;
  margin: 0.5rem 0;
  padding: 0.5rem 0.5rem;
  border-top: 1px solid #000;
  border-bottom: 1px solid #000;
}

@media print {
  .label-body { padding: 0; }
  .label-bar { display: none !important; }
  .label { border: 2px solid #000; }
}

/* ---------- desktop tweaks ---------- */

@media (min-width: 720px) {
  .shipment { max-width: 600px; }
}
