:root {
  --page: #f3f5f4;
  --sheet: #ffffff;
  --in: #eef1f1;
  --ink: #121c25;
  --ink-2: #3e4749;
  --muted: #869093;
  --line: #e4e8e8;
  --teal: #e2703a;
  --teal-deep: #b44c1c;
  --teal-mid: #cc5d27;
  --teal-tint: #fbf0ea;
  --stars: #f2ae00;
  --ui: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --brand: "Archivo", "Helvetica Neue", Arial, sans-serif;
  --spring: cubic-bezier(.2, 1.45, .35, 1);
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; background: var(--page); }
body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font-family: var(--ui);
  font-size: 17px;
  line-height: 1.32;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}
img { display: block; max-width: 100%; height: auto; }
a { color: inherit; }
h1, p, figure, dl, dd { margin: 0; }
button { font: inherit; color: inherit; -webkit-tap-highlight-color: transparent; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 2px solid var(--teal-deep); outline-offset: 2px; }
.mark-accent { stroke: var(--mark-accent, var(--teal)); }

/* ---------------- layout ---------------- */
.panel { display: none; }
.phone { position: relative; min-height: 100vh; min-height: 100svh; background: var(--sheet); display: flex; flex-direction: column; }

/* ---------------- header ---------------- */
.chat-head {
  position: -webkit-sticky; position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 12px;
  padding: 10px 14px 10px 14px;
  padding-top: calc(10px + env(safe-area-inset-top));
  background: rgba(255, 255, 255, 0.97);
  border-bottom: 1px solid var(--line);
}
.chat-avatar { width: 42px; height: 42px; flex: 0 0 42px; --mark-accent: var(--teal); }
.chat-id { flex: 1; min-width: 0; }
.chat-id h1 { font-family: var(--brand); font-size: 17px; font-weight: 700; letter-spacing: -0.01em; line-height: 1.15; }
.chat-id p { font-size: 13px; color: var(--muted); margin-top: 2px; }
.chat-call {
  display: inline-flex; align-items: center; justify-content: center;
  width: 40px; height: 40px; border-radius: 50%;
  background: var(--teal-tint); color: var(--teal-deep);
  transition: transform 0.2s var(--spring);
}
.chat-call:active { transform: scale(0.92); }
.chat-call svg { width: 19px; height: 19px; }

/* ---------------- thread ---------------- */
.thread { flex: 1; display: flex; flex-direction: column; padding: 6px 12px 28px; }
.day { align-self: center; margin: 14px 0 6px; font-size: 12px; font-weight: 600; color: var(--muted); letter-spacing: 0.02em; }
.intro, .flow { display: flex; flex-direction: column; }

.msg { position: relative; max-width: 80%; margin-top: 2px; scroll-margin-top: 84px; scroll-margin-bottom: 84px; }
.msg.first, .msg.solo { margin-top: 14px; }
.msg.in { align-self: flex-start; padding-left: 36px; }
.msg.out { align-self: flex-end; }
.msg.in.last::before, .msg.in.solo::before {
  content: ""; position: absolute; left: 0; bottom: 0;
  width: 28px; height: 28px; border-radius: 50%;
  background: url("../img/avatar.svg") center / cover no-repeat;
}
.media.in.last::before { bottom: 22px; }

.bubble {
  position: relative; z-index: 0;
  display: inline-block;
  padding: 9px 14px 10px;
  border-radius: 20px;
  background: var(--in);
  color: var(--ink);
  overflow-wrap: break-word;
}
.bubble a { color: var(--teal-deep); font-weight: 600; text-decoration: none; }
.msg.in.first .bubble { border-bottom-left-radius: 6px; }
.msg.in.mid .bubble { border-top-left-radius: 6px; border-bottom-left-radius: 6px; }
.msg.in.last .bubble { border-top-left-radius: 6px; }
.msg.in.last .bubble::before, .msg.in.solo .bubble::before {
  content: ""; position: absolute; z-index: -1; bottom: 0; left: -6px;
  width: 20px; height: 18px; background: var(--in);
  border-bottom-right-radius: 15px 14px;
}
.msg.in.last .bubble::after, .msg.in.solo .bubble::after {
  content: ""; position: absolute; z-index: -1; bottom: 0; left: -10px;
  width: 10px; height: 19px; background: var(--sheet);
  border-bottom-right-radius: 10px;
}

.msg.out .bubble { color: #fff; background: var(--teal-deep); background-image: linear-gradient(180deg, var(--teal-mid), var(--teal-deep)); }
.msg.out.first .bubble { border-bottom-right-radius: 6px; }
.msg.out.mid .bubble { border-top-right-radius: 6px; border-bottom-right-radius: 6px; }
.msg.out.last .bubble { border-top-right-radius: 6px; }
.msg.out.last .bubble::before, .msg.out.solo .bubble::before {
  content: ""; position: absolute; z-index: -1; bottom: 0; right: -6px;
  width: 20px; height: 18px; background: var(--teal-deep);
  border-bottom-left-radius: 15px 14px;
}
.msg.out.last .bubble::after, .msg.out.solo .bubble::after {
  content: ""; position: absolute; z-index: -1; bottom: 0; right: -10px;
  width: 10px; height: 19px; background: var(--sheet);
  border-bottom-left-radius: 10px;
}
.status { align-self: flex-end; margin: 4px 4px 0 0; font-size: 11.5px; font-weight: 600; color: var(--muted); }

/* photos */
.media .photo {
  display: block; padding: 0; border: 0; cursor: zoom-in;
  width: 236px; max-width: 100%;
  border-radius: 20px; overflow: hidden; isolation: isolate;
  background: #e7ebeb;
  transition: transform 0.25s var(--spring);
}
.media .photo:active { transform: scale(0.97); }
.media .photo img { width: 100%; aspect-ratio: 3 / 4; object-fit: cover; }
.media.first .photo { border-bottom-left-radius: 6px; }
.media.mid .photo { border-top-left-radius: 6px; border-bottom-left-radius: 6px; }
.media.last .photo { border-top-left-radius: 6px; }
.media figcaption { margin: 5px 0 0 6px; font-size: 12px; font-weight: 600; color: var(--muted); }

/* shared cards */
.card {
  background: #fff; border: 1px solid var(--line); border-radius: 20px;
  padding: 13px 15px 14px;
  box-shadow: 0 1px 2px rgba(16, 20, 21, 0.04), 0 8px 24px -16px rgba(16, 20, 21, 0.18);
}
.msg.in.card.mid, .msg.in.card.last { border-top-left-radius: 6px; }
.msg.in.card.first, .msg.in.card.mid { border-bottom-left-radius: 6px; }
.msg.in.card { margin-left: 36px; padding-left: 15px; }
.msg.in.card.last::before, .msg.in.card.solo::before { left: -37px; }
.review { width: 300px; max-width: calc(100% - 36px); }
.review header { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 7px; }
.g-stars { color: var(--stars); letter-spacing: 1px; font-size: 14px; }
.review-label { font-size: 11.5px; font-weight: 650; color: var(--muted); letter-spacing: 0.02em; }
.review p { font-size: 15.5px; line-height: 1.42; color: var(--ink); }
.review footer { margin-top: 9px; font-size: 13px; font-weight: 700; color: var(--ink-2); }
.card.link { padding: 0; }
.card.link a { display: flex; align-items: center; gap: 12px; padding: 12px 14px; text-decoration: none; }
.link-score { font-family: var(--brand); font-size: 26px; font-weight: 750; letter-spacing: -0.03em; }
.link-text { display: flex; flex-direction: column; font-size: 14.5px; line-height: 1.3; }
.link-text .g-stars { font-size: 12px; }
.link-go { margin-left: auto; font-size: 28px; line-height: 1; color: var(--muted); }

/* quick replies */
.chips {
  align-self: flex-end;
  display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px;
  max-width: 100%; margin-top: 12px; padding-left: 28px;
}
.chip {
  display: inline-flex; align-items: center; gap: 8px;
  min-height: 44px; padding: 9px 16px;
  border-radius: 999px; border: 1.5px solid rgba(180, 76, 28, 0.42);
  background: #fff; color: var(--teal-deep);
  font-size: 15px; font-weight: 600; cursor: pointer;
  box-shadow: 0 1px 2px rgba(16, 20, 21, 0.05);
  transition: transform 0.22s var(--spring), background-color 0.15s ease, border-color 0.15s ease;
}
.chip:hover { background: var(--teal-tint); border-color: var(--teal-deep); }
.chip:active { transform: scale(0.94); }
.chip .chip-price { font-weight: 700; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.chips.gone { opacity: 0; transform: translateY(6px) scale(0.98); transition: opacity 0.2s ease, transform 0.2s ease; pointer-events: none; }
.chips.nudge .chip { animation: nudge 0.6s var(--spring) 2; }
@keyframes nudge { 50% { transform: translateY(-4px) scale(1.04); } }

/* receipt */
.receipt { width: 300px; max-width: calc(100% - 36px); padding: 16px 16px 14px; }
.receipt-label { font-size: 11.5px; font-weight: 650; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.receipt-title { font-family: var(--brand); font-size: 19px; font-weight: 700; letter-spacing: -0.01em; margin-top: 3px; }
.receipt-price { display: flex; align-items: baseline; justify-content: space-between; margin-top: 10px; padding: 10px 0; border-top: 1px dashed #d3d9d9; border-bottom: 1px dashed #d3d9d9; }
.receipt-price span { font-size: 13px; color: var(--muted); font-weight: 600; }
.receipt-price strong { font-family: var(--brand); font-size: 30px; font-weight: 750; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; }
.receipt ul { list-style: none; margin: 10px 0 0; padding: 0; display: grid; gap: 6px; }
.receipt li { position: relative; padding-left: 20px; font-size: 14.5px; line-height: 1.35; color: var(--ink-2); }
.receipt li::before { content: ""; position: absolute; left: 1px; top: 5px; width: 9px; height: 5px; border-left: 2px solid var(--teal-deep); border-bottom: 2px solid var(--teal-deep); transform: rotate(-45deg); }
.receipt-note { margin-top: 10px; font-size: 13px; color: var(--muted); }
.price-list { list-style: none; margin: 10px 0 0; padding: 0; }
.price-list li { display: flex; justify-content: space-between; gap: 10px; padding: 6px 0; border-bottom: 1px dashed #d3d9d9; font-size: 15px; }
.price-list li::before { content: none; }

/* send card */
.send-card { width: 300px; max-width: calc(100% - 36px); padding: 15px 15px 14px; }
.send-card dl { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; margin: 8px 0 14px; font-size: 14.5px; }
.send-card dt { color: var(--muted); font-weight: 600; }
.send-card dd { text-align: right; font-weight: 600; }
.btn-send {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; border-radius: 14px; text-decoration: none;
  background: var(--teal-deep); background-image: linear-gradient(180deg, var(--teal-mid), var(--teal-deep));
  color: #fff; font-weight: 700; font-size: 16px;
  transition: transform 0.22s var(--spring);
}
.btn-send:active { transform: scale(0.97); }
.btn-send svg { width: 19px; height: 19px; }
.send-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 8px; }
.btn-ghost {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 42px; border-radius: 12px; text-decoration: none;
  background: var(--teal-tint); color: var(--teal-deep); font-weight: 650; font-size: 15px;
}
.btn-ghost svg { width: 17px; height: 17px; }
.send-actions { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.send-actions a { flex: 1 1 auto; padding: 0 12px; }
.restart { align-self: flex-end; margin-top: 10px; }

/* typing */
.typing { display: inline-flex; align-items: center; gap: 4px; height: 38px; padding: 0 14px; border-radius: 20px; background: var(--in); }
.typing i { width: 7px; height: 7px; border-radius: 50%; background: #9aa3a5; animation: dot 1.1s ease-in-out infinite; }
.typing i:nth-child(2) { animation-delay: 0.15s; }
.typing i:nth-child(3) { animation-delay: 0.3s; }
@keyframes dot { 0%, 60%, 100% { transform: translateY(0); opacity: 0.55; } 30% { transform: translateY(-4px); opacity: 1; } }
.msg .typing-slot { position: absolute; left: 36px; top: 0; }
.card .typing-slot { left: 0; }

/* arrival */
.js .msg.pending { opacity: 0; transform: translate3d(0, 10px, 0) scale(0.94); }
.js .msg.pending .typing-slot { opacity: 1; }
.js .msg.arrive { transition: opacity 0.26s ease, transform 0.55s var(--spring); }
.msg.in { transform-origin: 0% 100%; }
.msg.out { transform-origin: 100% 100%; }
.js .msg.holding { opacity: 1; transform: none; }
.js .msg.holding > :not(.typing-slot) { opacity: 0; }
.js .msg.holding.card { background: transparent; border-color: transparent; box-shadow: none; }
.js .msg.holding.media figcaption { opacity: 0; }

.thread-foot { margin-top: 36px; text-align: center; font-size: 12px; line-height: 1.6; color: var(--muted); }
.thread-foot a { color: var(--muted); }

/* ---------------- composer ---------------- */
.composer {
  position: -webkit-sticky; position: sticky; bottom: 0; z-index: 30;
  display: flex; align-items: center; gap: 8px;
  padding: 8px 10px 8px 12px;
  padding-bottom: calc(8px + env(safe-area-inset-bottom));
  background: rgba(255, 255, 255, 0.97);
  border-top: 1px solid var(--line);
}
.composer input {
  flex: 1; min-width: 0; height: 40px; padding: 0 16px;
  font-family: var(--ui); font-size: 16px; color: var(--ink);
  background: #f6f8f8; border: 1px solid #dde2e2; border-radius: 20px;
  -webkit-appearance: none; appearance: none;
}
.composer input:focus { outline: none; border-color: var(--teal-deep); background: #fff; }
.composer input::placeholder { color: #98a1a3; }
.send {
  display: inline-flex; align-items: center; justify-content: center;
  width: 38px; height: 38px; flex: 0 0 38px; border: 0; border-radius: 50%;
  background: var(--teal-deep); color: #fff; cursor: pointer;
  transition: transform 0.22s var(--spring);
}
.send:active { transform: scale(0.9); }
.send svg { width: 19px; height: 19px; }

/* ---------------- lightbox ---------------- */
.lightbox {
  position: fixed; inset: 0; z-index: 100;
  display: flex; align-items: center; justify-content: center;
  padding: 56px 12px 28px;
  background: rgba(9, 11, 12, 0.94);
  opacity: 0; transition: opacity 0.22s ease;
}
.lightbox[hidden] { display: none; }
.lightbox.open { opacity: 1; }
.lightbox figure { display: flex; flex-direction: column; align-items: center; gap: 12px; max-height: 100%; transform: scale(0.94); transition: transform 0.4s var(--spring); }
.lightbox.open figure { transform: none; }
.lightbox img { max-width: 100%; max-height: calc(100vh - 140px); max-height: calc(100svh - 140px); width: auto; border-radius: 10px; }
.lightbox figcaption { color: #e8eded; font-size: 14px; font-weight: 600; }
.lb-close {
  position: absolute; top: calc(10px + env(safe-area-inset-top)); right: 12px;
  width: 44px; height: 44px; border: 0; border-radius: 50%;
  background: rgba(255, 255, 255, 0.12); color: #fff; font-size: 28px; line-height: 1; cursor: pointer;
}

@media (prefers-reduced-motion: reduce) {
  .typing i, .chips.nudge .chip { animation: none; }
  .js .msg.arrive, .chip, .lightbox, .lightbox figure { transition: none; }
}

/* ---------------- desktop ---------------- */
@media (min-width: 1000px) {
  body {
    background:
      radial-gradient(900px 520px at 18% -8%, rgba(226, 112, 58, 0.12), rgba(226, 112, 58, 0) 70%),
      radial-gradient(700px 600px at 100% 100%, rgba(180, 76, 28, 0.06), rgba(180, 76, 28, 0) 70%),
      var(--page);
  }
  .layout {
    display: grid; grid-template-columns: minmax(300px, 380px) 440px;
    justify-content: center; column-gap: clamp(48px, 7vw, 120px);
    padding: 0 40px;
  }
  .panel { display: block; }
  .panel-inner {
    position: -webkit-sticky; position: sticky; top: 0;
    min-height: 100vh; display: flex; flex-direction: column; justify-content: center;
    padding: 56px 0;
  }
  .panel-mark { width: 172px; color: var(--ink); --mark-accent: var(--teal-mid); overflow: visible; }
  .panel-lede { margin-top: 26px; font-family: var(--brand); font-size: 22px; line-height: 1.32; letter-spacing: -0.015em; font-weight: 550; color: var(--ink); max-width: 18em; }
  .panel-facts { margin-top: 28px; display: grid; gap: 14px; }
  .panel-facts dt { font-size: 11.5px; font-weight: 650; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); }
  .panel-facts dd { margin-top: 3px; font-size: 16px; color: var(--ink-2); }
  .panel-facts a { text-decoration: none; color: var(--ink); font-weight: 600; }
  .panel-facts a:hover { color: var(--teal-deep); }
  .qr { display: flex; align-items: center; gap: 16px; margin-top: 30px; padding: 14px; background: #fff; border: 1px solid var(--line); border-radius: 18px; max-width: 340px; }
  .qr-code { width: 104px; height: 104px; flex: 0 0 104px; }
  .qr-code svg { display: block; width: 100%; height: 100%; }
  .qr p { font-size: 14px; line-height: 1.45; color: var(--ink-2); }
  .qr strong { color: var(--ink); }
  .panel-foot { margin-top: 28px; font-size: 12.5px; }
  .panel-foot a { color: var(--muted); }

  .phone {
    border-left: 1px solid var(--line); border-right: 1px solid var(--line);
    box-shadow: 0 40px 90px -50px rgba(16, 20, 21, 0.35);
  }
  .thread { padding-left: 16px; padding-right: 16px; }
  .chat-head { padding-left: 18px; padding-right: 18px; }
}

/* while 2TD is typing, the avatar sits with the dots */
.js .msg.holding::before { opacity: 0; }
.typing-slot::before {
  content: ""; position: absolute; left: -36px; bottom: 5px;
  width: 28px; height: 28px; border-radius: 50%;
  background: url("../img/avatar.svg") center / cover no-repeat;
}
.card .typing-slot::before { left: -36px; }

[hidden] { display: none !important; }

/* Logic hardening, 8 Nov: a choice can't be tapped while it is still invisible,
   and every set of choices offers a quiet way back to the start. */
.js .msg.pending, .js .msg.holding { pointer-events: none; }
.chip.chip-ghost { background: transparent; border-style: dashed; border-color: var(--line); color: var(--muted); }

/* ---------------- Saltline: one live conversation ---------------- */
.notice { align-self: center; margin: 14px 0 0; padding: 6px 12px; border-radius: 999px; background: #f3f5f6; font-size: 12px; font-weight: 600; color: var(--muted); text-align: center; }
.js .msg.queued { display: none; }
.typing-row { margin-top: 14px; }
.typing-row .typing { position: relative; }
.typing-row::before { content: ""; position: absolute; left: 0; bottom: 5px; width: 28px; height: 28px; border-radius: 50%; background: url("../img/avatar.svg") center / cover no-repeat; }
.tray { margin-top: 14px; transition: opacity 0.2s ease; }
.tray.is-busy { opacity: 0.42; }
.tray.is-busy .chip { cursor: default; }
.tray .chip:disabled { pointer-events: none; }
.tray.nudge .chip { animation: nudge 0.6s var(--spring) 2; }
.chip.chip-alt { background: var(--teal-tint); border-color: transparent; }
.chip.chip-ghost { background: transparent; border-style: dashed; border-color: #cfd6d8; color: var(--muted); }
.msg.out .bubble { overflow-wrap: anywhere; }
.status { margin-bottom: 0; }
.composer { position: -webkit-sticky; position: sticky; }
.pill {
  position: absolute; left: 50%; top: -48px; transform: translateX(-50%);
  display: inline-flex; align-items: center; gap: 6px;
  height: 36px; padding: 0 14px 0 11px; border: 0; border-radius: 999px;
  background: var(--ink); color: #fff; font-size: 14px; font-weight: 650; cursor: pointer;
  box-shadow: 0 6px 18px -6px rgba(18, 28, 37, 0.45);
  animation: pill-in 0.35s var(--spring);
}
.pill svg { width: 16px; height: 16px; }
@keyframes pill-in { from { opacity: 0; transform: translate(-50%, 8px) scale(0.92); } to { opacity: 1; transform: translateX(-50%); } }
.panel-mark { color: var(--ink); }
.panel-foot { color: var(--muted); line-height: 1.5; }
.panel-foot a { color: var(--ink-2); font-weight: 600; }
.thread-foot { margin-top: 28px; }
.receipt-label { color: var(--teal-deep); }
@media (prefers-reduced-motion: reduce) { .pill, .tray.nudge .chip { animation: none; } }
.media .photo { width: 248px; }
.media .photo img { aspect-ratio: auto; height: auto; max-height: 360px; object-fit: cover; }
@media (min-width: 1000px) { .panel-mark { width: 270px; } }
.tray.is-busy { transition: none; }
.send-row { grid-template-columns: auto auto; }
.btn-ghost { white-space: nowrap; padding: 0 10px; }
