/* components.css: every class in the shared spec vocabulary.
   Colours, spacing, radii and type come only from tokens.css.
   Layout-only shell rules (positions, grids, breakpoints) live in base.css. */

/* ---------- Keyframes ---------- */

@keyframes pp-spin {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}

@keyframes pp-fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@keyframes pp-sheet-up {
  from { transform: translateY(100%); }
  to   { transform: none; }
}

@keyframes pp-modal-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: none; }
}

@keyframes pp-toast-in {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: none; }
}

@keyframes pp-shimmer {
  from { background-position: 100% 0; }
  to   { background-position: 0 0; }
}

@keyframes pp-success {
  0%   { box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 35%, transparent); }
  100% { box-shadow: 0 0 0 10px transparent; }
}

@keyframes pp-alert-ring {
  0%   { box-shadow: 0 0 0 0 color-mix(in srgb, var(--alert) 30%, transparent); }
  100% { box-shadow: 0 0 0 8px transparent; }
}

@keyframes pp-shake {
  0%, 100% { transform: none; }
  25%      { transform: translateX(-3px); }
  75%      { transform: translateX(3px); }
}

@keyframes pp-pop {
  from { transform: translateY(8px) scale(0.98); opacity: 0; }
  to   { transform: none; opacity: 1; }
}

/* ---------- Header, brand, role switcher ---------- */

.app-header {
  background: var(--glass);
  border-bottom: 1px solid var(--border);
  color: var(--text);
}

.brand {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  min-height: var(--tap);
  font-size: var(--fs-l);
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--text);
  text-decoration: none;
}

.brand-mark {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  box-shadow: 0 2px 6px -2px var(--accent);
}

.brand-mark img {
  display: block;
  width: 100%;
  height: 100%;
}

/* Account chip (top right) and its menu sheet */
.account {
  display: flex;
  align-items: center;
  min-width: 0;
}

.account-chip {
  --role: var(--accent);
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  min-height: 40px;
  padding: 3px var(--space-2) 3px 3px;
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}

.account-chip.role-donor { --role: var(--donor); }
.account-chip.role-receiver { --role: var(--receiver); }
.account-chip.role-coordinator { --role: var(--coordinator); }

.account-text {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  line-height: 1.15;
  min-width: 0;
}

.account-text strong { font-size: var(--fs-s); font-weight: 700; }
.account-text span { font-size: var(--fs-xs); font-weight: 600; color: var(--role); }

.account-chip svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: var(--text-2);
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.avatar {
  --role: var(--accent);
  --role-soft: var(--accent-soft);
  flex: 0 0 auto;
  display: inline-grid;
  place-items: center;
  border-radius: 50%;
  background: var(--role-soft);
  color: var(--role);
  font-weight: 800;
}

.avatar.role-donor { --role: var(--donor-fg); --role-soft: var(--donor-soft); }
.avatar.role-receiver { --role: var(--receiver-fg); --role-soft: var(--receiver-soft); }
.avatar.role-coordinator { --role: var(--coordinator-fg); --role-soft: var(--coordinator-soft); }
.avatar-s { width: 32px; height: 32px; font-size: var(--fs-s); }
.avatar-m { width: 44px; height: 44px; font-size: var(--fs-l); }
.avatar-l { width: 64px; height: 64px; font-size: var(--fs-xl); }

.menu-row {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  width: 100%;
  min-height: 64px;
  padding: var(--space-2) var(--space-3);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-m);
  background: var(--surface);
  color: var(--text);
  text-align: left;
  cursor: pointer;
}

.menu-row.is-active { border-color: var(--accent); background: var(--accent-soft); }
.menu-text { display: flex; flex-direction: column; flex: 1 1 auto; min-width: 0; line-height: 1.25; }
.menu-text span { font-size: var(--fs-s); color: var(--text-2); }
.menu-state { font-size: var(--fs-xs); font-weight: 700; color: var(--accent-fg); }
.menu-state.is-muted { color: var(--text-2); }

.menu-links { display: flex; flex-direction: column; gap: var(--space-1); padding-top: var(--space-2); }

.menu-link {
  display: flex;
  align-items: center;
  min-height: var(--tap);
  padding: 0 var(--space-3);
  border: 0;
  background: none;
  color: var(--text);
  font-size: var(--fs-m);
  font-weight: 600;
  text-decoration: none;
  text-align: left;
  cursor: pointer;
}

/* ---------- Navigation ---------- */

.app-nav {
  background: var(--glass);
  border-top: 1px solid var(--border);
  box-shadow: 0 -6px 24px -12px rgba(60, 40, 10, 0.18);
}

.nav-item {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  min-height: var(--tap);
  padding: var(--space-1) var(--space-1);
  border-radius: var(--radius-m);
  color: var(--text-2);
  font-size: var(--fs-xs);
  font-weight: 650;
  line-height: 1.2;
  text-decoration: none;
  white-space: nowrap;
  transition:
    color var(--dur) var(--ease),
    background-color var(--dur) var(--ease);
}

.nav-item svg {
  width: 24px;
  height: 24px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.nav-item:hover {
  color: var(--text);
  background: var(--surface-2);
}

.nav-item.is-active {
  color: var(--accent-fg);
  font-weight: 750;
  background: var(--accent-soft);
}

/* Mobile active marker: a short bar at the top of the tab (desktop rail overrides this below). */
.nav-item.is-active::before {
  content: "";
  position: absolute;
  top: -1px;
  left: 50%;
  width: 28px;
  height: 3px;
  margin-left: -14px;
  border-radius: 0 0 3px 3px;
  background: var(--accent);
}

.nav-badge {
  position: absolute;
  top: 4px;
  left: calc(50% + 6px);
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: var(--radius-pill);
  background: var(--exception-fg);
  color: var(--surface);
  font-size: var(--fs-xs);
  font-weight: 800;
  line-height: 20px;
  text-align: center;
  font-variant-numeric: tabular-nums;
  box-shadow: 0 0 0 2px var(--surface);
}

/* ---------- Page scaffolding ---------- */

.page-title {
  margin: 0 0 var(--space-2);
  font-size: 1.85rem;
  font-weight: 800;
  line-height: 1.12;
  letter-spacing: -0.02em;
  color: var(--text);
}

.page-sub {
  margin: 0 0 var(--space-5);
  font-size: var(--fs-m);
  color: var(--text-2);
  max-width: 60ch;
}

.stack {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-3);
}

.section-title:first-child {
  margin-top: 0;
}

.section-title {
  margin: var(--space-5) 0 var(--space-1);
  font-size: var(--fs-xs);
  font-weight: 750;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-2);
}

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-7) var(--space-5);
  text-align: center;
  color: var(--text-2);
}

.empty-icon {
  display: grid;
  place-items: center;
  width: 80px;
  height: 80px;
  margin-bottom: var(--space-1);
  border-radius: 28px;
  background: var(--accent-soft);
  color: var(--accent-fg);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 18%, transparent);
  transform: rotate(-4deg);
}

.empty-icon svg {
  width: 38px;
  height: 38px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.empty-title {
  font-size: var(--fs-l);
  font-weight: 750;
  letter-spacing: -0.01em;
  color: var(--text);
}

.empty-text {
  max-width: 36ch;
  font-size: var(--fs-m);
  line-height: 1.5;
}

/* Two-pane list/detail: sizing and scrolling are in base.css. */
.split-list {
  padding-right: var(--space-1);
}

.split-detail {
  padding-right: var(--space-1);
}

/* ---------- Buttons ---------- */

.btn {
  --btn-ink: var(--text);
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-height: var(--tap);
  padding: var(--space-2) var(--space-5);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-s);
  background: var(--surface);
  color: var(--btn-ink);
  font-size: var(--fs-m);
  font-weight: 650;
  line-height: 1.2;
  text-align: center;
  text-decoration: none;
  box-shadow: var(--shadow-1);
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  transition:
    background-color var(--dur) var(--ease),
    border-color var(--dur) var(--ease),
    box-shadow var(--dur) var(--ease),
    transform var(--dur) var(--ease);
}

.btn:hover {
  background: var(--surface-2);
}

.btn:active {
  transform: scale(0.98);
}

/* Primary: strong accent fill, lifted edge, pressed state deepens. */
.btn-primary {
  --btn-ink: var(--accent-ink);
  background: linear-gradient(180deg, color-mix(in srgb, var(--accent) 92%, #fff 8%), var(--accent));
  border-color: var(--accent);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2), var(--shadow-accent);
}

.btn-primary:hover {
  background: linear-gradient(180deg, color-mix(in srgb, var(--accent) 86%, #fff 14%), var(--accent));
  filter: brightness(1.04);
}

.btn-primary:active {
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.25);
  filter: brightness(0.95);
}

.btn-secondary {
  --btn-ink: var(--text);
  background: var(--surface);
  border-color: var(--border-strong);
}

.btn-secondary:active {
  background: var(--surface-2);
}

.btn-ghost {
  --btn-ink: var(--accent-fg);
  background: transparent;
  border-color: transparent;
  box-shadow: none;
}

.btn-ghost:hover {
  background: var(--accent-soft);
}

.btn-ghost:active {
  background: var(--accent-soft);
  filter: brightness(0.97);
}

/* Danger: serious red fill with an inverted ink so it reads in both themes. */
.btn-danger {
  --btn-ink: var(--surface);
  background: var(--exception-fg);
  border-color: var(--exception-fg);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.18), 0 6px 14px -8px var(--exception-fg);
}

.btn-danger:hover {
  background: var(--exception-fg);
  filter: brightness(1.08);
}

.btn-danger:active {
  filter: brightness(0.9);
}

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

.btn[disabled],
.btn:disabled,
.btn[aria-disabled="true"] {
  opacity: 0.5;
  cursor: not-allowed;
  box-shadow: none;
  transform: none;
}

.btn.is-loading {
  color: transparent;
  pointer-events: none;
}

.btn.is-loading::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 20px;
  height: 20px;
  margin: -10px 0 0 -10px;
  border: 2.5px solid var(--btn-ink);
  border-top-color: transparent;
  border-radius: 50%;
  animation: pp-spin 700ms linear infinite;
}

/* ---------- Cards and lists ---------- */

.card {
  padding: var(--space-4);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-m);
  box-shadow: var(--shadow-1);
  color: var(--text);
}

@media (min-width: 720px) {
  .card {
    padding: var(--space-5);
  }
}

.card-link {
  display: block;
  color: inherit;
  text-decoration: none;
  cursor: pointer;
  transition:
    border-color var(--dur) var(--ease),
    box-shadow var(--dur) var(--ease),
    transform var(--dur) var(--ease);
}

.card-link:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow-2);
  transform: translateY(-2px);
}

.card-link:active {
  transform: translateY(0) scale(0.995);
}

.card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-3);
}

.card-title {
  margin: 0;
  font-size: var(--fs-m);
  font-weight: 700;
  line-height: 1.3;
  letter-spacing: -0.01em;
  color: var(--text);
  overflow-wrap: anywhere;
}

.card-meta {
  margin-top: var(--space-1);
  font-size: var(--fs-s);
  color: var(--text-2);
}

.lot-card-foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  margin-top: var(--space-3);
  padding-top: var(--space-3);
  border-top: 1px dashed var(--border-strong);
  font-size: var(--fs-s);
  color: var(--text-2);
  font-variant-numeric: tabular-nums;
}

/* Back link on the lot page (mobile only; desktop uses the split list). */
.back-link {
  display: inline-flex;
  align-items: center;
  min-height: var(--tap);
  font-size: var(--fs-s);
  font-weight: 650;
  color: var(--accent-fg);
  text-decoration: none;
}

/* ---------- Chips (family from logic.stageFamily) ---------- */

.chip {
  --chip-bg: var(--surface-2);
  --chip-fg: var(--text);
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  min-height: 28px;
  padding: 2px var(--space-3);
  border-radius: var(--radius-pill);
  background: var(--chip-bg);
  color: var(--chip-fg);
  font-size: var(--fs-xs);
  font-weight: 700;
  line-height: 1.4;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.chip-dot {
  flex: 0 0 auto;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
}

.chip-dot {
  box-sizing: border-box;
}

/* Neutral chips: the stage reads from the dot's shape, not from a hue that role colours already use. */
.chip-offered .chip-dot {
  background: transparent;
  border: 2px solid currentColor;
}

.chip-progress .chip-dot {
  background: currentColor;
}

.chip-done {
  --chip-bg: var(--done-bg);
  --chip-fg: var(--done-fg);
}

.chip-exception {
  --chip-bg: var(--warn-bg);
  --chip-fg: var(--warn-fg);
}

.chip-dispute {
  --chip-bg: var(--alert);
  --chip-fg: var(--alert-ink);
}

/* ---------- Stage stepper ---------- */

.stage-stepper {
  display: flex;
  align-items: flex-start;
  margin: 0;
  padding: var(--space-3) var(--space-2) var(--space-2);
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}

.stage-stepper::-webkit-scrollbar {
  display: none;
}

.stage-step {
  position: relative;
  flex: 1 0 88px;
  min-width: 88px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  color: var(--text-2);
  font-size: var(--fs-xs);
  font-weight: 600;
  line-height: 1.25;
}

/* Connector from the previous step's dot to this one. */
.stage-step::before {
  content: "";
  position: absolute;
  top: 10px;
  left: -50%;
  right: 50%;
  height: 3px;
  border-radius: 2px;
  background: var(--border);
  z-index: 0;
}

.stage-step:first-child::before {
  display: none;
}

.stage-dot {
  position: relative;
  z-index: 1;
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border: 2px solid var(--border-strong);
  border-radius: 50%;
  background: var(--surface);
  transition:
    background-color var(--dur) var(--ease),
    border-color var(--dur) var(--ease),
    box-shadow var(--dur) var(--ease);
}

.stage-label {
  margin-top: var(--space-2);
  max-width: 12ch;
  overflow-wrap: anywhere;
}

.stage-step.is-done::before {
  background: var(--accent);
}

.stage-step.is-done .stage-dot {
  background: var(--accent);
  border-color: var(--accent);
}

.stage-step.is-done .stage-dot::after {
  content: "";
  width: 5px;
  height: 9px;
  margin-top: -2px;
  border: solid var(--accent-ink);
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

.stage-step.is-done .stage-label {
  color: var(--text);
}

.stage-step.is-current .stage-dot {
  border-color: var(--progress-fg);
  background: var(--progress-bg);
  box-shadow: 0 0 0 4px var(--progress-bg);
}

.stage-step.is-current .stage-label {
  color: var(--text);
  font-weight: 750;
}

.stage-step.is-todo .stage-dot {
  border-color: var(--border-strong);
}

/* Exception branch: the last step is shown in the exception colours. */
.stage-stepper.is-exception .stage-step:last-child::before {
  background: var(--exception-fg);
}

.stage-stepper.is-exception .stage-step:last-child .stage-dot {
  background: var(--exception-bg);
  border-color: var(--exception-fg);
  box-shadow: none;
}

.stage-stepper.is-exception .stage-step:last-child.is-current .stage-dot {
  box-shadow: 0 0 0 4px var(--exception-bg);
}

.stage-stepper.is-exception .stage-step:last-child .stage-dot::after {
  content: "!";
  width: auto;
  height: auto;
  margin: 0;
  border: 0;
  transform: none;
  color: var(--exception-fg);
  font-size: var(--fs-xs);
  font-weight: 800;
  line-height: 1;
}

.stage-stepper.is-exception .stage-step:last-child .stage-label {
  color: var(--exception-fg);
  font-weight: 750;
}

@media (max-width: 479px) {
  .stage-step {
    flex-basis: 76px;
    min-width: 76px;
  }

  .stage-label {
    max-width: 10ch;
  }
}

/* ---------- Quantity bar ---------- */

.qty-bar {
  display: flex;
  width: 100%;
  height: 14px;
  overflow: hidden;
  border-radius: var(--radius-pill);
  background: var(--surface-2);
  box-shadow: inset 0 0 0 1px var(--border);
}

.qty-seg {
  flex: 0 0 auto;
  height: 100%;
  min-width: 0;
  transition: width var(--dur) var(--ease);
}

.qty-seg + .qty-seg {
  box-shadow: -2px 0 0 var(--surface);
}

.qty-seg.qty-distributed,
.qty-swatch.qty-distributed,
.qty-key.qty-distributed > .qty-swatch {
  background: var(--q-distributed);
}

.qty-seg.qty-returned,
.qty-swatch.qty-returned,
.qty-key.qty-returned > .qty-swatch {
  background: var(--q-returned);
}

.qty-seg.qty-disposed,
.qty-swatch.qty-disposed,
.qty-key.qty-disposed > .qty-swatch {
  background: var(--q-disposed);
}

.qty-seg.qty-remaining,
.qty-swatch.qty-remaining,
.qty-key.qty-remaining > .qty-swatch {
  background: var(--q-remaining);
}

.qty-legend {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2) var(--space-4);
  margin-top: var(--space-3);
  font-size: var(--fs-s);
  color: var(--text-2);
  font-variant-numeric: tabular-nums;
}

.qty-key {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
}

.qty-swatch {
  flex: 0 0 auto;
  width: 10px;
  height: 10px;
  border-radius: 4px;
}

.qty-big {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(104px, 1fr));
  gap: var(--space-3);
  margin-top: var(--space-4);
}

.qty-big-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: var(--space-4) var(--space-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-m);
  background: var(--surface-2);
  text-align: center;
}

.qty-num {
  font-family: var(--font-num);
  font-size: var(--fs-num);
  font-weight: 800;
  line-height: 1;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}

.qty-cap {
  margin-top: var(--space-2);
  font-size: var(--fs-xs);
  font-weight: 650;
  color: var(--text-2);
}

.qty-caption {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-top: var(--space-3);
  font-size: var(--fs-s);
  color: var(--text-2);
}

.qty-check {
  display: inline-grid;
  place-items: center;
  min-width: 22px;
  height: 22px;
  padding: 0 4px;
  border-radius: var(--radius-pill);
  background: var(--done-bg);
  color: var(--done-fg);
  font-weight: 800;
}

/* ---------- Compare (donor declared vs receiver received) ---------- */

.compare-pair {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-3);
}

.compare-box {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  padding: var(--space-4);
  border: 1px solid var(--border);
  border-radius: var(--radius-m);
  background: var(--surface-2);
  color: var(--text);
}

.compare-box .qty-num {
  font-size: var(--fs-xl);
}

.compare-box.is-mismatch {
  border: 2px solid var(--alert);
  background: var(--surface);
  color: var(--alert);
}

.compare-box.is-mismatch .qty-num {
  font-size: var(--fs-num);
  line-height: 1.1;
}

/* ---------- Banners ---------- */

.banner {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border: 1px solid transparent;
  border-radius: var(--radius-m);
  font-size: var(--fs-s);
  font-weight: 550;
  line-height: 1.45;
}

.banner > svg {
  flex: 0 0 auto;
  width: 20px;
  height: 20px;
  margin-top: 1px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.banner-info {
  background: var(--progress-bg);
  color: var(--progress-fg);
}

.banner-warn {
  background: var(--offered-bg);
  color: var(--offered-fg);
}

.banner-danger {
  background: var(--exception-bg);
  color: var(--exception-fg);
  border-color: color-mix(in srgb, var(--exception-fg) 30%, transparent);
}

.banner-dispute {
  display: block;
  background: var(--alert);
  color: var(--alert-ink);
}

/* ---------- Deny panel: refused action, serious and red-tinted ---------- */

.deny-panel {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-5);
  border: 1.5px solid var(--exception-fg);
  border-left-width: 6px;
  border-radius: var(--radius-m);
  background: var(--exception-bg);
  color: var(--exception-fg);
  box-shadow: var(--shadow-1);
}

.deny-title {
  margin: 0;
  font-size: var(--fs-l);
  font-weight: 850;
  letter-spacing: -0.01em;
  line-height: 1.25;
  color: var(--exception-fg);
}

.deny-panel > :first-child {
  font-size: var(--fs-l);
  line-height: 1.25;
}

.deny-detail {
  margin: 0;
  padding: var(--space-3);
  border: 1px solid color-mix(in srgb, var(--exception-fg) 22%, transparent);
  border-radius: var(--radius-s);
  background: var(--surface);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  font-weight: 500;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
  overflow-x: auto;
}

/* ---------- Timeline ---------- */

.timeline {
  position: relative;
  margin: 0;
  padding: 0;
  list-style: none;
}

.tl-item {
  position: relative;
  padding: 0 0 var(--space-4) var(--space-6);
}

/* Vertical rail behind the dots. */
.tl-item::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: 6px;
  width: 2px;
  background: var(--border);
}

.tl-item:last-child {
  padding-bottom: 0;
}

.tl-item:last-child::before {
  bottom: auto;
  height: 14px;
}

.tl-dot {
  position: absolute;
  top: 3px;
  left: 0;
  width: 14px;
  height: 14px;
  border: 3px solid var(--accent);
  border-radius: 50%;
  background: var(--surface);
  z-index: 1;
}

.tl-body {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.tl-title {
  font-size: var(--fs-s);
  font-weight: 700;
  color: var(--text);
  overflow-wrap: anywhere;
}

.tl-meta {
  font-size: var(--fs-xs);
  color: var(--text-2);
  overflow-wrap: anywhere;
}

.tl-item.is-deny .tl-dot {
  border-color: var(--exception-fg);
  background: var(--exception-bg);
}

.tl-item.is-deny .tl-title {
  color: var(--exception-fg);
}

.tl-item.is-escalated .tl-dot {
  border-color: var(--dispute-fg);
  background: var(--dispute-bg);
}

.tl-item.is-escalated .tl-title {
  color: var(--dispute-fg);
}

/* ---------- Countdown ---------- */

.countdown {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  min-height: 28px;
  padding: 2px var(--space-3);
  border-radius: var(--radius-pill);
  background: var(--surface-2);
  color: var(--text-2);
  font-size: var(--fs-s);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.countdown.is-late {
  background: var(--exception-bg);
  color: var(--exception-fg);
}

/* ---------- Action bar ---------- */

.action-bar {
  position: sticky;
  bottom: calc(var(--nav-h) + var(--safe-bottom));
  z-index: 20;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
  margin: var(--space-4) calc(var(--space-4) * -1) 0;
  padding: var(--space-3) var(--space-4);
  background: var(--glass);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--border);
  box-shadow: 0 -8px 24px -14px rgba(60, 40, 10, 0.3);
}

.action-bar > .btn {
  flex: 1 1 auto;
}

/* ---------- Sheet (bottom sheet <720px, centred modal >=720px) ---------- */

.sheet-backdrop {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: color-mix(in srgb, var(--text) 40%, transparent);
  -webkit-backdrop-filter: blur(3px);
  backdrop-filter: blur(3px);
  animation: pp-fade-in var(--dur) var(--ease) both;
}

.sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  flex-direction: column;
  max-height: 88vh;
  max-height: 88dvh;
  background: var(--surface);
  color: var(--text);
  border-radius: var(--radius-l) var(--radius-l) 0 0;
  box-shadow: var(--shadow-2);
  padding-bottom: var(--safe-bottom);
  animation: pp-sheet-up calc(var(--dur) * 2) var(--ease) both;
  outline: none;
}

.sheet-handle {
  flex: 0 0 auto;
  width: 44px;
  height: 5px;
  margin: var(--space-2) auto 0;
  border-radius: var(--radius-pill);
  background: var(--border-strong);
}

.sheet-head {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-3) var(--space-3) var(--space-5);
}

.sheet-title {
  margin: 0;
  flex: 1 1 auto;
  min-width: 0;
  font-size: var(--fs-xl);
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.sheet-close {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  min-width: var(--tap);
  min-height: var(--tap);
  padding: 0;
  border: 0;
  border-radius: var(--radius-pill);
  background: var(--surface-2);
  color: var(--text-2);
  font-size: var(--fs-l);
  transition: background-color var(--dur) var(--ease), color var(--dur) var(--ease);
}

.sheet-close:hover {
  background: var(--border);
  color: var(--text);
}

.sheet-close svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
}

.sheet-body {
  flex: 1 1 auto;
  min-height: 0;
  padding: 0 var(--space-5) var(--space-5);
  overflow-y: auto;
  overscroll-behavior: contain;
}

.sheet-foot {
  flex: 0 0 auto;
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-5);
  border-top: 1px solid var(--border);
  background: var(--surface-2);
}

.sheet-foot > .btn {
  flex: 1 1 auto;
}

@media (min-width: 720px) {
  .sheet-backdrop {
    display: grid;
    place-items: center;
    padding: var(--space-5);
  }

  .sheet {
    position: relative;
    left: auto;
    right: auto;
    bottom: auto;
    width: min(560px, 100%);
    max-height: min(80vh, 720px);
    border: 1px solid var(--border);
    border-radius: var(--radius-l);
    padding-bottom: 0;
    animation: pp-modal-in calc(var(--dur) * 2) var(--ease) both;
  }

  .sheet-handle {
    display: none;
  }
}

/* ---------- Number stepper (large touch targets) ---------- */

.num-stepper {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  width: 100%;
  max-width: 320px;
}

.num-btn {
  flex: 0 0 56px;
  display: grid;
  place-items: center;
  width: 56px;
  height: 56px;
  min-width: 56px;
  padding: 0;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-pill);
  background: var(--surface);
  color: var(--accent-fg);
  font-size: var(--fs-xl);
  font-weight: 600;
  line-height: 1;
  box-shadow: var(--shadow-1);
  user-select: none;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  transition:
    background-color var(--dur) var(--ease),
    transform var(--dur) var(--ease),
    box-shadow var(--dur) var(--ease);
}

.num-btn:hover:not(:disabled) {
  background: var(--accent-soft);
}

.num-btn:active:not(:disabled) {
  transform: scale(0.94);
}

.num-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  box-shadow: none;
}

.num-input {
  flex: 1 1 auto;
  min-width: 0;
  width: 100%;
  height: 56px;
  padding: 0 var(--space-2);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-s);
  background: var(--surface);
  color: var(--text);
  font-family: var(--font-num);
  font-size: var(--fs-num);
  font-weight: 800;
  line-height: 1;
  text-align: center;
  font-variant-numeric: tabular-nums;
  -moz-appearance: textfield;
  appearance: textfield;
}

.num-input::-webkit-outer-spin-button,
.num-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.num-input[aria-invalid="true"] {
  border-color: var(--exception-fg);
  background: var(--exception-bg);
  color: var(--exception-fg);
}

/* ---------- Fields ---------- */

.field {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  min-width: 0;
}

.field-label {
  font-size: var(--fs-s);
  font-weight: 650;
  color: var(--text);
}

.field-hint {
  font-size: var(--fs-s);
  color: var(--text-2);
}

.field-error {
  font-size: var(--fs-s);
  font-weight: 650;
  color: var(--exception-fg);
}

.input,
.select {
  width: 100%;
  min-height: var(--tap);
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-s);
  background: var(--surface);
  color: var(--text);
  font-size: 1rem;
  transition:
    border-color var(--dur) var(--ease),
    box-shadow var(--dur) var(--ease);
}

.input::placeholder {
  color: var(--text-2);
  opacity: 0.8;
}

.input:focus,
.select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
  outline: none;
}

.input[aria-invalid="true"],
.field.is-error .input,
.field.is-error .select {
  border-color: var(--exception-fg);
  background: var(--exception-bg);
  color: var(--exception-fg);
}

/* ---------- Toasts (stack above the bottom nav on mobile) ---------- */

#toast-root {
  position: fixed;
  left: 0;
  right: 0;
  bottom: calc(var(--nav-h) + var(--safe-bottom) + var(--space-3));
  z-index: 110;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-2);
  padding: 0 var(--space-4);
  pointer-events: none;
}

.toast {
  position: relative;
  width: 100%;
  max-width: 480px;
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--border);
  border-radius: var(--radius-m);
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-2);
  font-size: var(--fs-s);
  font-weight: 600;
  line-height: 1.4;
  pointer-events: auto;
  animation: pp-toast-in var(--dur) var(--ease) both;
}

.toast-info {
  border-color: transparent;
  background: var(--progress-bg);
  color: var(--progress-fg);
}

.toast-success {
  border-color: transparent;
  background: var(--done-bg);
  color: var(--done-fg);
}

.toast-error {
  border-color: transparent;
  background: var(--exception-bg);
  color: var(--exception-fg);
}

/* Reward toast: a tinted toast with a star, no decoration. */
.toast-reward {
  border-color: var(--accent);
}

@media (min-width: 720px) {
  #toast-root {
    bottom: var(--space-5);
    padding: 0 var(--space-5);
  }
}

/* ---------- Skeleton shimmer ---------- */

.skeleton,
.skeleton-line,
.skeleton-card {
  background: linear-gradient(
    90deg,
    var(--surface-2) 0%,
    var(--surface) 50%,
    var(--surface-2) 100%
  );
  background-size: 200% 100%;
  animation: pp-shimmer 1.4s linear infinite;
  border-radius: var(--radius-s);
}

.skeleton-line {
  display: block;
  width: 100%;
  height: 14px;
}

.skeleton-line + .skeleton-line {
  width: 70%;
  margin-top: var(--space-2);
}

.skeleton-card {
  display: block;
  height: 112px;
  border-radius: var(--radius-m);
  border: 1px solid var(--border);
}

/* ---------- One-shot success pulse ---------- */

.success-pulse {
  animation: pp-success 800ms var(--ease) 1 both;
}

/* ---------- Sign-in role cards ---------- */

.signin-cards {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--space-3);
}

@media (min-width: 720px) {
  .signin-cards {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (min-width: 960px) {
  .signin-cards {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

.role-card {
  --card-role: var(--accent);
  --card-role-soft: var(--accent-soft);
  --card-role-fg: var(--accent-fg);
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--space-2);
  width: 100%;
  min-height: 132px;
  padding: var(--space-4) var(--space-5);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-l);
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-1);
  font-family: inherit;
  text-align: left;
  cursor: pointer;
  transition:
    border-color var(--dur) var(--ease),
    box-shadow var(--dur) var(--ease),
    transform var(--dur) var(--ease);
}

/* Order in sign-in is donor, receiver, coordinator. */
.role-card:nth-child(1) { --card-role: var(--donor); --card-role-soft: var(--donor-soft); --card-role-fg: var(--donor-fg); }
.role-card:nth-child(2) { --card-role: var(--receiver); --card-role-soft: var(--receiver-soft); --card-role-fg: var(--receiver-fg); }
.role-card:nth-child(3) { --card-role: var(--coordinator); --card-role-soft: var(--coordinator-soft); --card-role-fg: var(--coordinator-fg); }

.role-card:hover {
  border-color: var(--card-role);
  box-shadow: var(--shadow-2);
  transform: translateY(-2px);
}

.role-card:active {
  transform: scale(0.99);
}

.role-card[aria-pressed="true"],
.role-card[aria-checked="true"],
.role-card.is-selected,
.role-card.is-active {
  border-color: var(--card-role);
  box-shadow: 0 0 0 1px var(--card-role) inset, var(--shadow-1);
}

.role-icon {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border-radius: 16px;
  background: var(--card-role-soft, var(--accent-soft));
  color: var(--card-role-fg, var(--accent-fg));
}

.role-icon svg {
  width: 24px;
  height: 24px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.role-name {
  font-size: var(--fs-l);
  font-weight: 800;
  letter-spacing: -0.01em;
  line-height: 1.2;
  color: var(--text);
}

.role-desc {
  font-size: var(--fs-s);
  line-height: 1.45;
  color: var(--text-2);
}

/* ---------- Trust record: badges, verification, pickup code, impact ---------- */

.badge {
  display: inline-flex;
  align-items: center;
  align-self: flex-start;
  min-height: 28px;
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-pill);
  font-size: var(--fs-s);
  font-weight: 700;
  line-height: 1.2;
}

.badge-ok {
  background: var(--done-bg);
  color: var(--done-fg);
}

.badge-bad {
  background: var(--exception-bg);
  color: var(--exception-fg);
}

.badge-muted {
  background: var(--surface-2);
  color: var(--text-2);
}

.verify-row {
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
}

/* Pickup code: a torn ticket with a dashed border and notches, the code in large mono digits. */
.pickup-card {
  position: relative;
  overflow: hidden;
  padding: var(--space-5);
  border: 2px dashed var(--accent);
  background:
    linear-gradient(180deg, var(--accent-soft), var(--surface) 75%);
  text-align: center;
  align-items: center;
}

.pickup-card::before,
.pickup-card::after {
  content: "";
  position: absolute;
  top: 50%;
  width: 26px;
  height: 26px;
  margin-top: -13px;
  border-radius: 50%;
  background: var(--bg);
  border: 2px dashed var(--accent);
}

.pickup-card::before {
  left: -15px;
  clip-path: inset(0 0 0 50%);
}

.pickup-card::after {
  right: -15px;
  clip-path: inset(0 50% 0 0);
}

.pickup-card .section-title,
.pickup-card .card-meta {
  color: var(--accent-fg);
  text-align: center;
}

.pickup-code {
  width: fit-content;
  max-width: 100%;
  margin: var(--space-2) auto;
  padding: var(--space-3) var(--space-5) var(--space-3) calc(var(--space-5) + 0.2em);
  border: 1px solid var(--border);
  border-radius: var(--radius-s);
  background: var(--surface);
  box-shadow: var(--shadow-1);
  font-family: var(--font-mono);
  font-size: clamp(2.2rem, 9vw, 3.4rem);
  font-weight: 800;
  line-height: 1.1;
  letter-spacing: 0.2em;
  font-variant-numeric: tabular-nums;
  color: var(--accent-fg);
  overflow-wrap: anywhere;
}

.pickup-input {
  font-family: var(--font-mono);
  font-size: var(--fs-l);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.15em;
}

.impact-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

@media (min-width: 720px) {
  .impact-grid {
    grid-template-columns: repeat(auto-fit, minmax(136px, 1fr));
  }
}

.hero-card,
.impact-card {
  position: relative;
}

/* ---------- Desktop (>=960px) adjustments ---------- */

@media (min-width: 960px) {
  .nav-item {
    flex-direction: row;
    justify-content: flex-start;
    gap: var(--space-2);
    min-height: 40px;
    padding: var(--space-2) var(--space-4);
    font-size: var(--fs-s);
  }

  .nav-item svg {
    width: 20px;
    height: 20px;
  }

  .nav-item.is-active::before {
    display: none;
  }

  .nav-badge {
    position: static;
    margin-left: var(--space-1);
    box-shadow: none;
  }

  .page-title {
    font-size: 2.3rem;
  }

  .action-bar {
    position: static;
    margin: var(--space-4) 0 0;
    padding: 0;
    background: transparent;
    border-top: 0;
    box-shadow: none;
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
  }

  .action-bar > .btn {
    flex: 0 0 auto;
  }

  #toast-root {
    bottom: var(--space-5);
  }
}

/* ---------- Reduced motion: keep state changes, drop the motion ---------- */

@media (prefers-reduced-motion: reduce) {
  .skeleton,
  .skeleton-line,
  .skeleton-card {
    animation: none;
    background: var(--surface-2);
  }

  .success-pulse {
    animation: none;
  }

  .btn.is-loading::after {
    animation-duration: 2s;
  }

  .sheet-backdrop,
  .sheet,
  .toast {
    animation-duration: 0ms;
  }

  .is-animate,
  .is-animate * {
    animation: none !important;
  }

  .card-link,
  .role-card,
  .btn {
    transition: none;
  }

  .card-link:hover,
  .role-card:hover,
  .btn:active,
  .card-link:active,
  .role-card:active {
    transform: none;
  }
}

/* ---------- One-shot motion for the product's own moments (JS adds .is-animate once per event) ---------- */

.compare-box.is-animate { animation: pp-alert-ring 900ms var(--ease) 1 both; }
.deny-panel.is-animate { animation: pp-shake 380ms ease-in-out 1 both; }
.equation.is-ok.is-animate .qty-check { display: inline-block; animation: pp-pop 420ms var(--ease) 1 both; }

/* ---------- Desktop rail items ---------- */

@media (min-width: 960px) {
  .nav-item {
    flex-direction: row;
    justify-content: flex-start;
    gap: var(--space-3);
    min-height: 46px;
    padding: 0 var(--space-4);
    border-radius: var(--radius-btn);
    font-size: var(--fs-m);
    font-weight: 650;
  }

  .nav-item.is-active { background: var(--surface-2); color: var(--ink); }
  .nav-item.is-active::before { display: none; }
  .nav-item.is-active svg { color: var(--accent); }
  .nav-badge { position: static; margin-left: auto; }
}
