@font-face {
  font-family: "Instrument Sans";
  src: url("/fonts/InstrumentSans.ttf") format("truetype");
  font-weight: 400 700;
  font-display: swap;
}

:root {
  --washi: #F4F1EA;
  --sumi: #16202A;
  --indigo: #2E4FA3;
  --bg: var(--washi);
  --surface: #FBFAF6;
  --text: var(--sumi);
  --muted: #5C6670;
  --line: #DDD7CB;
  --accent: var(--indigo);
  --accent-text: #FFFFFF;
  --user-bubble: #E7E2D7;
  --error: #A33A2E;
  --radius: 14px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: var(--sumi);
    --surface: #1D2934;
    --text: #ECE8DF;
    --muted: #9AA4AE;
    --line: #2E3B47;
    --accent: #7D99E0;
    --accent-text: #0F1720;
    --user-bubble: #26333F;
    --error: #E58A7E;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: var(--sumi); --surface: #1D2934; --text: #ECE8DF; --muted: #9AA4AE; --line: #2E3B47;
  --accent: #7D99E0; --accent-text: #0F1720; --user-bubble: #26333F; --error: #E58A7E; color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
[hidden] { display: none !important; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 "Instrument Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* Header */
.top {
  position: sticky; top: 0; z-index: 2;
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px; padding-top: max(12px, env(safe-area-inset-top));
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; background: none; border: 0; padding: 0; cursor: pointer; }
.brand img { border-radius: 8px; }
.wordmark { font-weight: 600; font-size: 20px; letter-spacing: -0.01em; }
.chip {
  border: 1px solid var(--line); background: var(--surface); border-radius: 999px;
  padding: 6px 12px; font-size: 14px; cursor: pointer; color: var(--muted);
}
.chip:hover { color: var(--text); }
.head-right { display: flex; align-items: center; gap: 8px; min-width: 0; }

/* Questions from a Buy For You run */
.ask { border: 1px solid var(--accent); border-radius: 12px; padding: 12px 14px; background: var(--surface); }
.ask .answer { font-size: 15px; }
.ask .answer > :first-child { margin-top: 0; }
.ask .answer > :last-child { margin-bottom: 0; }
.ask-actions { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.ask-actions button { border-radius: 999px; padding: 8px 16px; cursor: pointer; font-weight: 600; border: 1px solid var(--line); background: var(--bg); }
.ask-actions .primary { border-color: transparent; }
.ask .hint { font-size: 13px; color: var(--muted); margin-top: 8px; }
.ask.answered { border-color: var(--line); }
.ask.answered .ask-actions, .ask.answered .hint { display: none; }
.buy-btn { align-self: flex-start; border: 1px solid var(--accent); color: var(--accent); background: var(--surface); border-radius: 999px; padding: 8px 16px; cursor: pointer; font-weight: 600; }
.buy-btn:hover { background: var(--accent); color: var(--accent-text); }
.ask .reply { margin-top: 8px; font-size: 14px; color: var(--muted); }

/* Chat */
main { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 18px; }
main > * { width: 100%; max-width: 760px; margin-inline: auto; }

.empty { margin-top: 8vh; }
.empty h1 { font-size: clamp(28px, 6vw, 40px); line-height: 1.1; font-weight: 600; letter-spacing: -0.02em; margin: 0 0 12px; }
.empty p { color: var(--muted); margin: 0 0 20px; max-width: 56ch; }
.examples { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 20px; }
.example {
  border: 1px solid var(--line); background: var(--surface); border-radius: 999px;
  padding: 8px 14px; cursor: pointer; font-size: 15px;
}
.example:hover { border-color: var(--accent); }
.fine { font-size: 13px; color: var(--muted); }

.msg.user { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }
.msg.user .bubble {
  background: var(--user-bubble); border-radius: var(--radius) var(--radius) 4px var(--radius);
  padding: 10px 14px; max-width: 85%; white-space: pre-wrap; overflow-wrap: anywhere;
}
.msg.user img { max-width: 180px; max-height: 180px; border-radius: 10px; object-fit: cover; }

.msg.bot { display: flex; flex-direction: column; gap: 10px; }
.progress {
  border: 1px solid var(--line); background: var(--surface); border-radius: var(--radius); padding: 12px 14px;
}
.progress-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; font-size: 14px; }
.progress-head .status { display: flex; align-items: center; gap: 8px; font-weight: 600; }
.progress-head .timer { color: var(--muted); font-variant-numeric: tabular-nums; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); animation: pulse 1.2s ease-in-out infinite; }
.progress.done .dot { animation: none; background: var(--muted); }
@keyframes pulse { 50% { opacity: 0.3; } }
@media (prefers-reduced-motion: reduce) { .dot { animation: none; } }
.steps { list-style: none; margin: 10px 0 0; padding: 0; font-size: 14px; color: var(--muted); display: flex; flex-direction: column; gap: 4px; }
.steps li { display: flex; gap: 8px; overflow-wrap: anywhere; }
.steps li::before { content: "–"; color: var(--line); }
.steps li.thought { font-style: italic; }
.progress.done .steps { display: none; }
.progress.done.open .steps { display: flex; }
.toggle-steps { background: none; border: 0; padding: 0; color: var(--muted); font-size: 13px; cursor: pointer; text-decoration: underline; }
.live { margin-top: 10px; font-size: 14px; }
.live a { color: var(--accent); }
.live iframe { width: 100%; aspect-ratio: 1366 / 900; border: 1px solid var(--line); border-radius: 10px; margin-top: 8px; background: #000; }

.answer { overflow-wrap: anywhere; }
.answer h3 { font-size: 15px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); margin: 20px 0 8px; font-weight: 600; }
.answer p { margin: 8px 0; }
.answer a { color: var(--accent); }
.answer em { color: var(--muted); font-size: 13px; }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }
.answer table { border-collapse: collapse; width: 100%; font-size: 14px; font-variant-numeric: tabular-nums; }
.answer th, .answer td { padding: 8px 10px; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; }
.answer th { font-weight: 600; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em; }
.answer tr:last-child td { border-bottom: 0; }
.answer tbody tr:first-child td { background: color-mix(in srgb, var(--accent) 8%, transparent); }
.stats { font-size: 12px; color: var(--muted); }
.error-msg { color: var(--error); font-size: 14px; }

/* Composer */
.composer {
  position: sticky; bottom: 0;
  padding: 10px 16px; padding-bottom: max(10px, env(safe-area-inset-bottom));
  background: var(--bg); border-top: 1px solid var(--line);
}
.composer .row, .attachments { max-width: 760px; margin-inline: auto; }
.composer .row {
  display: flex; align-items: flex-end; gap: 8px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 22px; padding: 6px;
}
.composer .row:focus-within { border-color: var(--accent); }
textarea {
  flex: 1; border: 0; background: transparent; resize: none; outline: none;
  padding: 8px 4px; max-height: 160px; min-width: 0;
}
.icon-btn, .send {
  flex: none; width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; cursor: pointer; border: 0;
}
.icon-btn { color: var(--muted); background: transparent; }
.icon-btn:hover { color: var(--text); }
.send { background: var(--accent); color: var(--accent-text); }
.send:disabled { opacity: 0.4; cursor: default; }
.send.stop { background: var(--text); color: var(--bg); }
.attachments { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.attachments[hidden] { display: none; }
.attachment { position: relative; display: inline-block; }
.attachment img { height: 64px; border-radius: 8px; display: block; }
.attachment button {
  position: absolute; top: -6px; right: -6px; width: 22px; height: 22px; border-radius: 50%;
  border: 0; background: var(--text); color: var(--bg); cursor: pointer; line-height: 1;
}

/* Dialogs */
dialog {
  border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); color: var(--text);
  padding: 0; width: min(420px, calc(100vw - 32px));
}
dialog::backdrop { background: rgb(22 32 42 / 0.45); }
.sheet { padding: 20px; display: flex; flex-direction: column; gap: 12px; }
.sheet h2 { margin: 0; font-size: 20px; font-weight: 600; }
.sheet p { margin: 0; }
.sheet label { display: flex; flex-direction: column; gap: 4px; font-size: 14px; color: var(--muted); }
.sheet select, .sheet input {
  padding: 10px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg); color: var(--text);
}
.actions { display: flex; justify-content: flex-end; }
.primary { background: var(--accent); color: var(--accent-text); border: 0; border-radius: 999px; padding: 10px 20px; cursor: pointer; font-weight: 600; }
.error { color: var(--error); font-size: 14px; }

/* Sign-in, Account and My orders */
.link { background: none; border: 0; padding: 0; color: var(--accent); cursor: pointer; font-size: 14px; text-decoration: underline; }
.actions.spread { justify-content: space-between; align-items: center; margin-top: 8px; }
.actions .fine { margin-right: auto; align-self: center; }
.sheet input:disabled { opacity: 0.6; }
#signinCode { letter-spacing: 0.3em; font-variant-numeric: tabular-nums; font-size: 20px; text-align: center; }
dialog.tall { width: min(560px, calc(100vw - 32px)); max-height: calc(100dvh - 32px); overflow-y: auto; }
.sheet-head { display: flex; justify-content: space-between; align-items: center; }
.sheet h3 { margin: 12px 0 0; font-size: 13px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); font-weight: 600; }
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.grid .wide { grid-column: 1 / -1; }
@media (max-width: 480px) { .grid { grid-template-columns: 1fr; } }
.orders { display: flex; flex-direction: column; gap: 10px; }
.order { border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; background: var(--bg); }
.order-head { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.order ul { margin: 6px 0; padding-left: 18px; font-size: 14px; }
.order ul a { color: var(--accent); overflow-wrap: anywhere; }
.order p { margin: 4px 0 0; }
.status { font-size: 12px; border-radius: 999px; padding: 2px 10px; background: var(--user-bubble); color: var(--text); }
.status.s-invoiced, .status.s-shipping_invoiced { background: var(--accent); color: var(--accent-text); }
.status.s-cancelled { color: var(--muted); }
.invoice { border-radius: 10px; padding: 8px 10px; margin: 6px 0; font-size: 14px; }
.invoice.open { border: 1px solid var(--accent); }
.invoice.paid { color: var(--muted); }
.invoice pre { margin: 6px 0 0; white-space: pre-wrap; font: inherit; font-size: 13px; }
.head-right .chip { white-space: nowrap; }
#whereLabel { display: inline-block; max-width: 42vw; overflow: hidden; text-overflow: ellipsis; vertical-align: bottom; }
#openAccount.needs::after { content: ""; display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--accent); margin-left: 6px; vertical-align: middle; }
.primary, .btn { white-space: nowrap; }

/* Chat scrolling: the newest question is pinned to the top; offsetTop is measured against main. */
main { position: relative; overflow-anchor: none; }
.spacer { flex: none; padding: 0; margin-top: -18px; }
.msg.user .photos { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; max-width: 85%; }
.msg.user .photos img { width: 120px; height: 120px; }
.msg.user .photos img:only-child { width: auto; height: auto; max-width: 220px; max-height: 220px; }

/* Photos: drop target and small notices */
body.dropping .composer .row { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 25%, transparent); }
body.dropping main::after {
  content: "Drop photos to add them"; position: fixed; inset: auto 0 96px 0; margin: auto; width: max-content;
  background: var(--accent); color: var(--accent-text); padding: 8px 16px; border-radius: 999px; font-size: 14px; pointer-events: none;
}
.flash { position: absolute; left: 50%; transform: translateX(-50%); top: -36px; background: var(--text); color: var(--bg); padding: 6px 14px; border-radius: 999px; font-size: 13px; white-space: nowrap; }

/* ====== Chat, Shop-style: question headings, assistant steps, result cards, floating follow-up bar ====== */
:root { --card: #FFFFFF; --tile: #EFECE4; --shadow: 0 1px 2px rgb(22 32 42 / 0.06), 0 8px 24px rgb(22 32 42 / 0.06); --r-card: 20px; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --card: #1D2934; --tile: #26333F; --shadow: 0 1px 2px rgb(0 0 0 / 0.3), 0 8px 24px rgb(0 0 0 / 0.25); } }
:root[data-theme="dark"] { --card: #1D2934; --tile: #26333F; --shadow: 0 1px 2px rgb(0 0 0 / 0.3), 0 8px 24px rgb(0 0 0 / 0.25); }

main { gap: 14px; padding-bottom: 8px; }

/* The question is the heading of its turn */
.msg.user { align-items: flex-start; gap: 10px; margin-top: 18px; }
.msg.user:first-of-type { margin-top: 0; }
.msg.user .q { margin: 0; font-size: clamp(22px, 5vw, 28px); line-height: 1.2; font-weight: 700; letter-spacing: -0.02em; overflow-wrap: anywhere; }
.msg.user .photos { justify-content: flex-start; max-width: 100%; }
.msg.user .photos img { width: 64px; height: 64px; border-radius: 12px; }
.msg.user .photos img:only-child { width: 88px; height: 88px; max-width: none; max-height: none; }

/* Assistant steps */
.progress { border: 0; background: transparent; padding: 0; }
.progress-head {
  display: inline-flex; align-items: center; gap: 8px; border: 0; background: none; padding: 4px 0; cursor: pointer;
  font: inherit; font-size: 14px; color: var(--muted); width: auto;
}
.progress-head:disabled { cursor: default; }
.progress-head .status { font-weight: 600; color: var(--text); }
.progress.done .progress-head .status { color: var(--muted); font-weight: 500; }
.progress-head .chev { display: inline-flex; transition: transform 0.15s; }
.progress.open .progress-head .chev { transform: rotate(180deg); }
.progress.done .progress-head .timer { display: none; }
.progress .steps { list-style: none; margin: 6px 0 0 2px; padding: 0 0 0 14px; border-left: 2px solid var(--line); display: none; flex-direction: column; gap: 10px; }
.progress.open .steps { display: flex; }
.progress.done.open .steps { display: flex; }
.steps li { display: grid; grid-template-columns: 18px 1fr; column-gap: 8px; align-items: start; font-size: 14px; color: var(--muted); }
.steps li::before { content: none; }
.steps .s-icon { color: var(--muted); display: inline-flex; margin-top: 2px; }
.steps .s-text { color: var(--text); }
.steps .pills { grid-column: 2; display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.pill { display: inline-flex; align-items: center; gap: 5px; background: var(--tile); color: var(--text); border-radius: 999px; padding: 4px 10px; font-size: 13px; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.steps li.thought .s-text { color: var(--muted); font-style: italic; }

/* The answer */
.result { display: flex; flex-direction: column; gap: 14px; }
.answer-text p { margin: 0 0 6px; line-height: 1.5; }
.eyebrow { font-size: 12px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; color: var(--muted); }

.best {
  background: var(--card); border-radius: var(--r-card); box-shadow: var(--shadow); padding: 14px;
  display: grid; grid-template-columns: 112px 1fr; gap: 14px; align-items: center;
}
.best-media { width: 112px; height: 112px; border-radius: 16px; background: var(--tile); display: grid; place-items: center; overflow: hidden; }
.best-media img { width: 100%; height: 100%; object-fit: contain; mix-blend-mode: multiply; }
.best-media .shop-badge { width: 56px; height: 56px; font-size: 24px; }
.best-body { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.best-price { font-size: 30px; font-weight: 700; letter-spacing: -0.02em; line-height: 1.1; font-variant-numeric: tabular-nums; }
.best-local { color: var(--muted); font-size: 14px; font-variant-numeric: tabular-nums; }
.best-shop { color: var(--text); font-weight: 600; text-decoration: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.best-shop:hover { text-decoration: underline; }
.save-pill { align-self: flex-start; margin-top: 4px; background: var(--accent); color: var(--accent-text); border-radius: 999px; padding: 3px 10px; font-size: 13px; font-weight: 600; }
.save-pill.quiet { background: var(--tile); color: var(--text); font-weight: 500; }
.best-actions { grid-column: 1 / -1; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.btn-primary, .btn-dark {
  display: inline-flex; justify-content: center; align-items: center; height: 44px; border-radius: 999px; font: inherit; font-weight: 600;
  font-size: 15px; cursor: pointer; text-decoration: none; border: 0; white-space: nowrap;
}
.btn-primary { background: var(--accent); color: var(--accent-text); }
.btn-dark { background: var(--text); color: var(--bg); }
.btn-primary:hover, .btn-dark:hover { filter: brightness(1.08); }

.seg { display: flex; gap: 6px; flex-wrap: wrap; }
.seg button { border: 1px solid var(--line); background: var(--card); color: var(--text); border-radius: 999px; padding: 6px 14px; font: inherit; font-size: 14px; cursor: pointer; }
.seg button[aria-selected="true"] { background: var(--text); color: var(--bg); border-color: var(--text); }

.sellers { background: var(--card); border-radius: var(--r-card); box-shadow: var(--shadow); overflow: hidden; }
.sellers.muted { opacity: 0.85; }
.seller { display: flex; align-items: center; gap: 8px; padding: 0 12px 0 0; border-bottom: 1px solid var(--line); }
.seller:last-child { border-bottom: 0; }
.seller-main { flex: 1; min-width: 0; display: grid; grid-template-columns: 40px 1fr auto; gap: 12px; align-items: center; padding: 12px 0 12px 14px; color: inherit; text-decoration: none; }
.seller-main:hover .seller-name { text-decoration: underline; }
.shop-badge {
  width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: 16px;
  background: hsl(var(--h, 220) 45% 92%); color: hsl(var(--h, 220) 45% 30%);
}
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .shop-badge { background: hsl(var(--h, 220) 30% 25%); color: hsl(var(--h, 220) 60% 85%); } }
.seller-info { min-width: 0; }
.seller-name { font-weight: 600; display: flex; align-items: center; gap: 6px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.seller-name .tag { background: var(--accent); color: var(--accent-text); font-size: 11px; font-weight: 600; border-radius: 999px; padding: 1px 8px; }
.seller-meta { color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.seller-price { text-align: right; font-variant-numeric: tabular-nums; }
.seller-price .p { font-weight: 700; }
.seller-price .l { color: var(--muted); font-size: 12px; }
.seller-buy { flex: none; border: 1px solid var(--line); background: var(--bg); color: var(--text); border-radius: 999px; padding: 6px 12px; font: inherit; font-size: 13px; font-weight: 600; cursor: pointer; }
.seller-buy:hover { border-color: var(--accent); color: var(--accent); }

.fine-print { font-size: 12px; color: var(--muted); }
.fine-print summary { cursor: pointer; list-style: none; }
.fine-print summary::-webkit-details-marker { display: none; }
.fine-print:not(.plain) summary::after { content: " · details"; text-decoration: underline; }
.fine-print.plain summary { cursor: default; pointer-events: none; }
.fine-print p { margin: 6px 0 0; overflow-wrap: anywhere; }

.suggest { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; border-top: 1px solid var(--line); padding-top: 8px; }
.chip-suggest { border: 0; background: none; color: var(--text); font: inherit; font-size: 15px; padding: 7px 2px; cursor: pointer; text-align: left; }
.chip-suggest span { color: var(--muted); margin-right: 4px; }
.chip-suggest:hover { color: var(--accent); }
.stats { margin-top: -4px; }

/* Floating "Ask a follow-up" bar */
.composer { background: linear-gradient(to top, var(--bg) 70%, transparent); border-top: 0; padding-top: 16px; }
.composer .row { background: var(--card); border: 1px solid var(--line); border-radius: 999px; box-shadow: var(--shadow); padding: 6px 6px 6px 8px; align-items: center; }
.composer .row:focus-within { border-color: var(--accent); }
.composer textarea { padding: 9px 4px; }

/* Seller rows, compact: Buy is a small link under the price */
.seller { padding: 0; }
.seller-main { padding: 12px 14px; grid-template-columns: 40px minmax(0, 1fr) auto; }
.seller-price { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; }
.seller-buy { border: 0; background: none; padding: 2px 0; color: var(--accent); font-size: 13px; font-weight: 600; }
.seller-buy:hover { text-decoration: underline; color: var(--accent); }
.seller-name { display: block; }
.seller-name .tag { margin-left: 6px; vertical-align: 1px; }
.seller-main { cursor: pointer; }
.seller-name a { color: inherit; text-decoration: none; }
.seller-main:hover .seller-name a { text-decoration: underline; }
/* Product photos are shot on white: in dark mode give them a light tile instead of blending them into a dark one. */
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .best-media:has(img) { background: #F1EFE9; } :root:not([data-theme="light"]) .best-media img { mix-blend-mode: normal; } }
:root[data-theme="dark"] .best-media:has(img) { background: #F1EFE9; }
:root[data-theme="dark"] .best-media img { mix-blend-mode: normal; }

/* ====== Welcome screen: greeting, starter cards, three steps ====== */
.empty { margin-top: auto; margin-bottom: auto; padding: 4vh 0 2vh; display: flex; flex-direction: column; gap: 20px; }
.empty[hidden] { display: none; }
.hello h1 { font-size: clamp(30px, 7vw, 44px); line-height: 1.08; font-weight: 700; letter-spacing: -0.03em; margin: 0 0 10px; }
.hello p { margin: 0; color: var(--muted); font-size: 17px; line-height: 1.45; max-width: 42ch; }

.starters { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.starter {
  display: grid; grid-template-columns: auto 1fr; grid-template-rows: auto auto; column-gap: 12px; row-gap: 2px; align-items: center;
  text-align: left; background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 14px; cursor: pointer;
  font: inherit; color: var(--text); box-shadow: var(--shadow); transition: transform 0.12s, border-color 0.12s;
}
.starter:hover { border-color: var(--accent); transform: translateY(-1px); }
.starter:active { transform: translateY(0); }
.starter-icon { grid-row: 1 / 3; width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; background: var(--tile); color: var(--accent); }
.starter-title { font-weight: 600; font-size: 15px; }
.starter-sub { color: var(--muted); font-size: 13px; line-height: 1.3; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 420px) {
  .starter { grid-template-columns: 1fr; grid-template-rows: auto auto auto; row-gap: 4px; padding: 12px; }
  .starter-icon { grid-row: auto; width: 36px; height: 36px; margin-bottom: 6px; }
  .starter-sub { white-space: normal; }
}

.how { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.how li { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 14px; }
.how li span { flex: none; width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; background: var(--text); color: var(--bg); font-size: 12px; font-weight: 700; }
.empty .fine { margin: 0; }
.starter { align-content: start; } @media (max-width: 420px) { .starter { align-items: start; } }

/* Composer: a fixed corner radius (a 999px pill turns into an oval once the text wraps), buttons pinned to the
   bottom line, and the text area scrolling inside after ~6 lines. */
.composer .row { border-radius: 24px; align-items: flex-end; padding: 6px; }
.composer textarea { line-height: 1.45; padding: 7px 4px; min-height: 36px; max-height: 160px; overflow-y: auto; align-self: center; }
.composer .row.multi textarea { align-self: stretch; }
.composer .icon-btn, .composer .send { margin: 0; }
/* Clarifying question chips, good-to-know, shortfall */
.options { display: flex; flex-wrap: wrap; gap: 8px; }
.chip-option { border: 1px solid var(--line); background: var(--card); color: var(--text); border-radius: 999px; padding: 9px 16px; font: inherit; font-size: 15px; cursor: pointer; box-shadow: var(--shadow); }
.chip-option:hover { border-color: var(--accent); color: var(--accent); }
.good-to-know { background: var(--tile); border-radius: 14px; padding: 10px 14px; display: flex; flex-direction: column; gap: 2px; }
.good-to-know p { margin: 0; font-size: 14px; line-height: 1.45; }
.fine-line { margin: -4px 0 0; font-size: 13px; color: var(--muted); }

/* Bottom tab bar: Chat / Wishlist. The composer floats just above it. */
.composer { padding-bottom: 8px; }
.tabbar {
  position: sticky; bottom: 0; z-index: 2; display: flex; justify-content: center; gap: 4px;
  background: var(--bg); border-top: 1px solid var(--line);
  padding: 6px 16px; padding-bottom: max(6px, env(safe-area-inset-bottom));
}
.tab {
  flex: 0 1 160px; display: flex; flex-direction: column; align-items: center; gap: 2px;
  background: none; border: 0; border-radius: 12px; padding: 6px 8px; cursor: pointer;
  color: var(--muted); font-size: 12px; font-weight: 600; letter-spacing: 0.01em;
}
.tab:hover { color: var(--text); }
.tab[aria-current="page"] { color: var(--accent); }
.tab[aria-current="page"] svg path { fill: color-mix(in srgb, var(--accent) 16%, transparent); }
.tab:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Wishlist: a catalogue grid of every product checked */
.wishlist { flex: 1; overflow-y: auto; padding: 20px 16px 24px; }
.wl-inner { max-width: 960px; margin-inline: auto; display: flex; flex-direction: column; gap: 16px; }
.wl-head h1 { margin: 0; font-size: 28px; line-height: 1.15; letter-spacing: -0.01em; }
.wl-head .fine { margin: 4px 0 0; }
.wl-search {
  display: flex; align-items: center; gap: 8px; color: var(--muted);
  background: var(--card); border: 1px solid var(--line); border-radius: 999px; padding: 0 14px; box-shadow: var(--shadow);
}
.wl-search:focus-within { border-color: var(--accent); }
.wl-search input { flex: 1; min-width: 0; border: 0; background: none; padding: 11px 0; outline: none; font-size: 16px; color: var(--text); }
.wl-search[hidden] { display: none; }
.wl-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 14px; }
@media (max-width: 520px) { .wl-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; } }
.wl-card {
  display: flex; flex-direction: column; min-width: 0; overflow: hidden;
  background: var(--card); border-radius: var(--r-card); box-shadow: var(--shadow);
}
.wl-card.skeleton { aspect-ratio: 3 / 4; background: var(--tile); box-shadow: none; animation: pulse 1.4s ease-in-out infinite; }
.wl-img {
  position: relative; aspect-ratio: 1; background: #FFFFFF; display: grid; place-items: center;
  border-bottom: 1px solid var(--line);
}
.wl-img img { width: 100%; height: 100%; object-fit: contain; padding: 10px; box-sizing: border-box; }
.wl-img.none {
  --h: 220; background: hsl(var(--h) 40% 92%); color: hsl(var(--h) 35% 35%);
  font-size: 44px; font-weight: 700;
}
.wl-del {
  position: absolute; top: 8px; right: 8px; width: 28px; height: 28px; border-radius: 50%;
  display: grid; place-items: center; border: 0; cursor: pointer;
  background: rgb(255 255 255 / 0.92); color: var(--sumi); box-shadow: 0 1px 3px rgb(0 0 0 / 0.15);
  opacity: 0; transition: opacity 0.15s;
}
.wl-card:hover .wl-del, .wl-del:focus-visible { opacity: 1; }
@media (hover: none) { .wl-del { opacity: 1; } }
.wl-body { display: flex; flex-direction: column; gap: 2px; padding: 12px; flex: 1; }
.wl-body > .wl-again { margin-top: auto; }
.wl-name {
  margin: 0 0 4px; font-size: 14px; line-height: 1.35; font-weight: 600;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.wl-price { margin: 0; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-size: 17px; }
.wl-price.muted { color: var(--muted); font-size: 14px; }
.wl-store { margin: 0; font-size: 13px; color: var(--muted); text-decoration: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
a.wl-store:hover { color: var(--accent); text-decoration: underline; }
.wl-when { margin: 0 0 10px; font-size: 12px; color: var(--muted); }
.wl-again {
  margin-top: 10px; align-self: stretch;
  border: 1px solid var(--line); background: var(--bg); color: var(--text);
  border-radius: 999px; padding: 7px 10px; font-size: 13px; font-weight: 600; cursor: pointer;
}
.wl-again:hover { border-color: var(--accent); color: var(--accent); }
.wl-price .tag { background: var(--tile); color: var(--muted); font-size: 11px; font-weight: 600; border-radius: 999px; padding: 1px 8px; }
.wl-empty { text-align: center; padding: 40px 16px; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.wl-empty p { margin: 0; max-width: 40ch; }
.wl-empty .buy-btn { margin-top: 12px; align-self: center; }

/* Shop logos: the favicon on white in the same circle; the coloured initial stays when there's no logo. */
.shop-badge { overflow: hidden; flex: none; }
.shop-badge.has-logo { background: #FFFFFF; box-shadow: inset 0 0 0 1px var(--line); }
.shop-badge.has-logo img { width: 62%; height: 62%; object-fit: contain; border-radius: 4px; }
.best-shop { display: inline-flex; align-items: center; gap: 6px; }
.mini-logo { width: 16px; height: 16px; border-radius: 4px; flex: none; background: #FFFFFF; }

/* The saving: the headline of the best-price card. */
:root { --save: #1C7A4A; --save-bg: #E6F3EA; --save-track: #D3E8DA; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --save: #6FD39B; --save-bg: #183327; --save-track: #24493A; } }
:root[data-theme="dark"] { --save: #6FD39B; --save-bg: #183327; --save-track: #24493A; }
.save { grid-column: 1 / -1; background: var(--save-bg); border-radius: 16px; padding: 14px; display: flex; flex-direction: column; gap: 2px; }
.save-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.save-amt { color: var(--save); font-size: 24px; font-weight: 700; letter-spacing: -0.015em; line-height: 1.15; font-variant-numeric: tabular-nums; }
.save-pct { color: var(--save); background: var(--card); border-radius: 999px; padding: 2px 10px; font-size: 13px; font-weight: 700; font-variant-numeric: tabular-nums; }
.save-sub { margin: 0 0 10px; font-size: 14px; color: var(--text); }
.save-bars { display: flex; flex-direction: column; gap: 8px; }
.save-row { display: grid; grid-template-columns: minmax(0, 7.5em) 1fr auto; gap: 10px; align-items: center; font-size: 13px; }
.save-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); }
.save-track { height: 10px; border-radius: 999px; background: var(--save-track); overflow: hidden; }
.save-fill { height: 100%; border-radius: 999px; }
.is-best .save-fill { background: var(--save); }
.is-other .save-fill { background: color-mix(in srgb, var(--muted) 55%, transparent); }
.is-best .save-label, .is-best .save-val { color: var(--text); font-weight: 600; }
.save-val { font-variant-numeric: tabular-nums; color: var(--muted); min-width: 5.5em; text-align: right; }
.save-note { grid-column: 1 / -1; color: var(--save); font-size: 14px; font-weight: 600; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .shop-badge.has-logo { background: #FFFFFF; } }
:root[data-theme="dark"] .shop-badge.has-logo { background: #FFFFFF; }

/* Account panel (Shop-style): a full-height sheet on phones, a tall card on desktop. */
dialog.panel {
  width: min(480px, 100vw); height: min(820px, calc(100dvh - 48px)); max-height: none; max-width: none;
  border: 0; border-radius: 24px; background: var(--bg); overflow: hidden; box-shadow: 0 24px 60px rgb(0 0 0 / 0.25);
}
dialog.panel[open] { display: flex; flex-direction: column; }
@media (max-width: 560px) {
  dialog.panel { width: 100vw; height: 100dvh; margin: 0; border-radius: 0; inset: 0; }
}
.panel-head {
  display: grid; grid-template-columns: 40px 1fr 40px; align-items: center; gap: 8px;
  padding: 12px 12px; padding-top: max(12px, env(safe-area-inset-top));
}
.panel-head h2 { margin: 0; text-align: center; font-size: 17px; font-weight: 700; }
.panel-head #closeAccount { grid-column: 3; }
.round-btn {
  width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; cursor: pointer;
  border: 0; background: var(--tile); color: var(--text);
}
.round-btn:hover { filter: brightness(0.96); }
.round-btn[hidden] { display: grid !important; visibility: hidden; }
.panel-body { flex: 1; overflow-y: auto; padding: 4px 16px 28px; padding-bottom: max(28px, env(safe-area-inset-bottom)); }
.acc-page { display: flex; flex-direction: column; gap: 16px; }
.page-lead { margin: 0; color: var(--muted); font-size: 14px; }

.acc-hero {
  display: flex; align-items: center; gap: 14px; width: 100%; text-align: left; cursor: pointer;
  background: var(--card); border: 0; border-radius: 20px; padding: 16px; box-shadow: var(--shadow); color: var(--text);
}
.avatar {
  --h: 220; width: 56px; height: 56px; border-radius: 50%; flex: none; display: grid; place-items: center;
  background: hsl(var(--h) 45% 88%); color: hsl(var(--h) 45% 28%); font-size: 24px; font-weight: 700;
}
.acc-who { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.acc-name { font-size: 19px; font-weight: 700; line-height: 1.25; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.acc-name.placeholder { color: var(--accent); font-size: 17px; }
.acc-email { color: var(--muted); font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chev { color: var(--muted); flex: none; }

.acc-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.stat {
  display: flex; flex-direction: column; align-items: flex-start; gap: 2px; text-align: left;
  background: var(--card); border: 0; border-radius: 16px; padding: 12px 14px; box-shadow: var(--shadow); color: var(--text); font: inherit;
}
button.stat { cursor: pointer; }
button.stat:hover { box-shadow: var(--shadow), inset 0 0 0 1px var(--line); }
.stat-n { font-size: 22px; font-weight: 700; line-height: 1.2; font-variant-numeric: tabular-nums; }
.stat-l { font-size: 12px; color: var(--muted); line-height: 1.25; }

.pay-due-btn {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; cursor: pointer; font: inherit;
  background: var(--accent); color: var(--accent-text); border: 0; border-radius: 18px; padding: 14px 16px;
}
.pay-due-btn .row-sub { color: inherit; opacity: 0.85; }
.pay-due-cta { background: var(--accent-text); color: var(--accent); border-radius: 999px; padding: 6px 16px; font-weight: 700; font-size: 14px; }

.group { background: var(--card); border-radius: 20px; box-shadow: var(--shadow); overflow: hidden; }
.group-head { display: flex; justify-content: space-between; align-items: center; padding: 14px 16px 4px; font-size: 15px; font-weight: 700; }
.see-all { border: 0; background: none; color: var(--accent); font: inherit; font-size: 14px; font-weight: 600; cursor: pointer; padding: 0; }
#account .row {
  display: flex; align-items: center; gap: 12px; width: 100%; min-height: 60px; padding: 10px 16px; text-align: left;
  background: none; border: 0; color: var(--text); font: inherit; cursor: pointer; text-decoration: none; position: relative;
}
#account .row + .row::before { content: ""; position: absolute; top: 0; left: 64px; right: 0; border-top: 1px solid var(--line); }
#account .row:hover { background: color-mix(in srgb, var(--tile) 60%, transparent); }
#account .row.empty-row { cursor: default; }
#account .row.empty-row:hover { background: none; }
.row-icon { width: 36px; height: 36px; border-radius: 10px; flex: none; display: grid; place-items: center; background: var(--tile); color: var(--text); }
#account .row .shop-badge { width: 36px; height: 36px; font-size: 14px; }
.row-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.row-title { font-size: 15px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-sub { font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-sub.warn { color: var(--accent); font-weight: 600; }
.row-end { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; flex: none; }
.row-amt { font-size: 14px; font-weight: 700; font-variant-numeric: tabular-nums; }
#account .row.danger, #account .row.danger .row-icon { color: var(--error); }

/* Sub-page forms: inputs grouped in cards, label above value, like the Shop app's address form */
.fields { display: flex; flex-direction: column; gap: 14px; }
.field-card { background: var(--card); border-radius: 18px; box-shadow: var(--shadow); overflow: hidden; }
.field { display: flex; flex-direction: column; gap: 2px; padding: 10px 16px; position: relative; cursor: text; }
.field + .field::before { content: ""; position: absolute; top: 0; left: 16px; right: 0; border-top: 1px solid var(--line); }
.field span { font-size: 12px; font-weight: 600; color: var(--muted); }
.field input { border: 0; background: none; padding: 2px 0 4px; font-size: 16px; color: var(--text); outline: none; min-width: 0; }
.field:focus-within span { color: var(--accent); }
.field input::placeholder { color: color-mix(in srgb, var(--muted) 70%, transparent); }
.form-msg { margin: 0; min-height: 1.2em; font-size: 14px; color: var(--muted); text-align: center; }
.btn-primary.block { width: 100%; height: 50px; font-size: 16px; }

/* Orders page inside the panel */
#account .orders { gap: 12px; }
#account .order { background: var(--card); border: 0; border-radius: 18px; box-shadow: var(--shadow); padding: 14px 16px; }
.panel-head h2:focus { outline: none; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .avatar { background: hsl(var(--h) 30% 28%); color: hsl(var(--h) 60% 86%); } }
:root[data-theme="dark"] .avatar { background: hsl(var(--h) 30% 28%); color: hsl(var(--h) 60% 86%); }

/* Composer: one line of text is exactly button height (22px line + 7px padding x2 = 36px), so the placeholder, the
   camera button and Send share one centre line; longer text grows upward with the buttons on the last line. */
.composer .row { align-items: flex-end; }
.composer textarea { line-height: 22px; padding: 7px 4px; min-height: 36px; align-self: flex-end; }
.composer .row.multi textarea { align-self: stretch; }

/* Camera button menu */
.photo-pick { position: relative; flex: none; }
.photo-menu {
  position: absolute; left: -2px; bottom: calc(100% + 12px); z-index: 5; min-width: 196px;
  background: var(--card); border-radius: 16px; box-shadow: 0 2px 6px rgb(0 0 0 / 0.08), 0 12px 32px rgb(22 32 42 / 0.18);
  padding: 6px; display: flex; flex-direction: column; transform-origin: bottom left; animation: menu-in 0.14s ease-out;
}
.photo-menu[hidden] { display: none; }
@keyframes menu-in { from { opacity: 0; transform: translateY(6px) scale(0.97); } }
.photo-menu button {
  display: flex; align-items: center; gap: 12px; width: 100%; padding: 11px 12px; border: 0; border-radius: 10px;
  background: none; color: var(--text); font: inherit; font-size: 15px; font-weight: 600; text-align: left; cursor: pointer;
}
.photo-menu button:hover, .photo-menu button:focus-visible { background: var(--tile); outline: none; }
.photo-menu svg { color: var(--muted); flex: none; }

/* Desktop camera sheet */
dialog.camera { width: min(640px, calc(100vw - 32px)); border: 0; border-radius: 20px; background: var(--card); padding: 12px; }
dialog.camera[open] { display: flex; flex-direction: column; gap: 12px; }
dialog.camera video { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: 12px; background: #000; }
.cam-msg { margin: 8px 4px; color: var(--muted); }
.cam-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.cam-actions button:disabled { opacity: 0.5; cursor: default; }

/* Header: the account is its avatar (the same initial circle as the Account sheet) */
.avatar-btn { position: relative; border: 0; background: none; padding: 0; cursor: pointer; border-radius: 50%; display: grid; }
.avatar-btn .avatar { width: 35px; height: 35px; font-size: 15px; }
.avatar-btn:hover .avatar { filter: brightness(0.96); }
.avatar-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
#openAccount.needs::after { position: absolute; top: -1px; right: -1px; width: 10px; height: 10px; margin: 0; border: 2px solid var(--bg); }

/* Seller rows open in place */
.seller { display: block; }
.seller-main {
  width: 100%; border: 0; background: none; font: inherit; color: inherit; text-align: left; cursor: pointer;
  display: grid; grid-template-columns: 40px minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 12px 14px;
}
.seller-main:hover { background: color-mix(in srgb, var(--tile) 50%, transparent); }
.seller-main:hover .seller-name { text-decoration: none; }
.seller-info { display: flex; flex-direction: column; min-width: 0; }
.seller-name { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.seller-price { display: flex; flex-direction: row; align-items: center; gap: 6px; }
.seller-chev { color: var(--muted); display: grid; transition: transform 0.18s ease; }
.seller.open .seller-chev { transform: rotate(180deg); }
.seller.open { background: color-mix(in srgb, var(--tile) 35%, transparent); }
.seller-more { padding: 2px 14px 14px; display: flex; flex-direction: column; gap: 12px; animation: menu-in 0.16s ease-out; }
.seller-more[hidden] { display: none; }
.more-top { display: flex; gap: 12px; align-items: flex-start; }
.more-img { width: 84px; height: 84px; flex: none; border-radius: 12px; background: #FFFFFF; overflow: hidden; display: grid; place-items: center; }
.more-img img { width: 100%; height: 100%; object-fit: contain; }
.more-facts { margin: 0; display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 3px 12px; font-size: 13px; flex: 1; min-width: 0; }
.more-facts dt { color: var(--muted); }
.more-facts dd { margin: 0; overflow-wrap: anywhere; }
.more-save { margin: 0; border-radius: 12px; padding: 8px 12px; font-size: 14px; font-weight: 600; }
.more-save.up { background: var(--save-bg); color: var(--save); }
.more-save.down { background: var(--tile); color: var(--muted); }
.more-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.more-actions.single { grid-template-columns: 1fr; }
.seller-name { display: flex; align-items: center; gap: 6px; min-width: 0; }
.seller-store { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.seller-name .tag { flex: none; margin: 0; }
