:root {
  --bg: #fafaf7;
  --fg: #1d1d1b;
  --muted: #6b6b66;
  --line: #deded8;
  --accent: #b3261e;
  --card: #ffffff;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #171716;
    --fg: #ecece8;
    --muted: #a3a39c;
    --line: #353532;
    --accent: #f2b8b5;
    --card: #20201e;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 16px/1.5 system-ui, sans-serif;
}

header {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--line);
  /* C340: the navigation stays when the page scrolls */
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--bg);
}

header nav { display: flex; gap: 1rem; align-items: center; }
.brand { font-weight: 700; text-decoration: none; color: inherit; }
/* C923: the version, the environment outside prod, and who is logged in */
header .about { margin-right: auto; color: var(--muted); }
header .env { color: var(--bg); background: var(--accent); padding: 0 0.4rem; border-radius: 4px;
  font-size: 0.8rem; letter-spacing: 0.05em; }
header .who { color: var(--muted); overflow-wrap: anywhere; }
a { color: var(--accent); }

main { max-width: 40rem; margin: 0 auto; padding: 1rem; }

form, .choice, label { display: block; margin: 0.75rem 0; }
input, select { display: block; width: 100%; margin-top: 0.25rem; padding: 0.5rem; font: inherit;
  border: 1px solid var(--line); border-radius: 6px; background: var(--card); color: inherit; }
/* C922: a box to tick sits before its text, not as a full-width field above it */
input[type=checkbox], input[type=radio] { display: inline; width: auto; margin: 0 0.25rem 0 0;
  padding: 0; }
.choice input { display: inline; width: auto; }

button {
  padding: 0.5rem 1rem;
  font: inherit;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--card);
  color: inherit;
  cursor: pointer;
}
button[type="submit"], .actions button:first-child { border-color: var(--accent); }
button.danger { color: var(--accent); }
button.link { border: 0; padding: 0; background: none; color: var(--accent); text-decoration: underline; }
button:disabled { opacity: 0.5; cursor: wait; }
/* C328: the tapped card button, until and after the answer */
button[data-tap="sending"]::after { content: " \2026"; } /* CSS escapes, ASCII only (C353) */
button[data-tap="sent"]::after { content: " \2713"; }

.cards { list-style: none; padding: 0; }
.cards li { display: flex; flex-direction: column; gap: 0.25rem; padding: 0.75rem; margin: 0.5rem 0;
  border: 1px solid var(--line); border-radius: 8px; background: var(--card); }
.actions { display: flex; gap: 0.5rem; }
/* C337: the address card's lines, one size; the line's name muted */
.cards li > span { overflow-wrap: anywhere; }
.cards li .name { color: var(--muted); }
.editor { display: flex; flex-direction: column; gap: 0.75rem; border-top: 1px solid var(--line); padding-top: 0.5rem; }
.editor form { display: flex; flex-direction: column; gap: 0.25rem; }
small, .attribution { color: var(--muted); }
.attribution { font-size: 0.85rem; }

.tabs { display: flex; gap: 1rem; }
.tabs .current { font-weight: 700; text-decoration: none; color: inherit; }

#message:empty { display: none; }
#message { padding: 0.5rem 0.75rem; border-radius: 6px; background: var(--card); border: 1px solid var(--line); }
#message.error { border-color: var(--accent); }

dl { display: grid; grid-template-columns: max-content 1fr; gap: 0.25rem 1rem; }
dt { color: var(--muted); }
dd { margin: 0; overflow-wrap: anywhere; }

/* --- chat (M5): phone first, the input stays at the bottom --- */
.log { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 0.75rem; }
.log > li { max-width: 92%; display: flex; flex-direction: column; gap: 0.5rem; }
.log > li > p { margin: 0; padding: 0.5rem 0.75rem; border-radius: 12px; white-space: pre-wrap;
  overflow-wrap: anywhere; background: var(--card); border: 1px solid var(--line); }
.log > li.user { align-self: flex-end; }
.log > li.user > p { border-color: var(--accent); }
.log > li.assistant { align-self: flex-start; }
.error { color: var(--accent); }
.typing { color: var(--muted); margin: 0.5rem 0; }
.say { position: sticky; bottom: 0; display: flex; gap: 0.5rem; align-items: flex-end;
  padding: 0.75rem 0; background: var(--bg); }
.say textarea { flex: 1; padding: 0.5rem; font: inherit; resize: vertical; border: 1px solid var(--line);
  border-radius: 6px; background: var(--card); color: inherit; }
.card { display: flex; flex-direction: column; gap: 0.25rem; padding: 0.75rem;
  border: 1px solid var(--line); border-radius: 8px; background: var(--card); }
.card .card { border: 0; padding: 0; }
.actions { flex-wrap: wrap; }
.entries { list-style: none; padding: 0; margin: 0.25rem 0; }
.entries li { display: flex; flex-wrap: wrap; gap: 0.25rem 0.75rem; align-items: center;
  padding: 0.5rem 0; border-top: 1px solid var(--line); }
.entries li > :first-child { flex: 1 1 10rem; }
.price, .total { font-variant-numeric: tabular-nums; }
.total { font-weight: 700; margin: 0.25rem 0; }
.picker fieldset { border: 1px solid var(--line); border-radius: 6px; margin: 0.5rem 0; }
.picker .opt label { margin: 0.25rem 0; }
.picker .opt input { display: inline; width: auto; margin: 0 0.25rem 0 0; }
.picker .nested { margin-left: 1.25rem; }
button.current { border-color: var(--accent); font-weight: 700; }
/* M6: confirming, the order, its questions and payment */
/* M7: the site's sums, a refused method, Change For */
.sums .fee, .sums .site-total { white-space: nowrap; }
.confirm label.refused { color: var(--muted, #666); }
.confirm .reason { display: block; margin-left: 1.5rem; }
.confirm .change { display: block; }
.confirm .change[hidden] { display: none; }
.payment small, .card small.tracking { display: block; }
.payment a.wallet { display: block; margin: 0.25rem 0; font-weight: 700; }
.confirm fieldset { border: 1px solid var(--line); border-radius: 6px; margin: 0.5rem 0; }
.confirm label, .answer label { margin: 0.25rem 0; }
.confirm input, .answer input[type=checkbox] { display: inline; width: auto; margin: 0 0.25rem 0 0; }
.card .state { font-weight: 700; margin: 0.25rem 0; }
img.confirmation { width: 100%; height: auto; border-radius: 6px; border: 1px solid #ddd; }
/* C339: the site checkout's delivery address above the code, a line per line */
.site-address { display: flex; flex-direction: column; gap: 0.25rem; }
.site-address .name { color: var(--muted); }
.site-address .lines { white-space: pre-line; font-weight: 600; overflow-wrap: anywhere; }
img.qr { width: min(240px, 100%); height: auto; image-rendering: pixelated; background: #fff; padding: 0.5rem; border-radius: 6px; }
#telegram-qr img.qr { width: min(200px, 100%); }
