:root {
  --bg: #000;
  --text: #f5f5f5;
  --muted: #a8a8a8;
  --line: #262626;
  --bubble-in: #262626;
  --card: #1c1c1c;
  --chip: #121212;
  --chip-line: #363636;
  --blue: #0095f6;
  --blue-press: #1877f2;
  --sent-a: #a334fa;
  --sent-b: #6a4cf5;
  --sent-c: #0a8cf5;
  --gold: #ffd76a;
  --sheet: #262626;
  color-scheme: dark;
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg: #fff;
    --text: #000;
    --muted: #737373;
    --line: #dbdbdb;
    --bubble-in: #efefef;
    --card: #fff;
    --chip: #fff;
    --chip-line: #dbdbdb;
    --gold: #b7791f;
    --sheet: #fff;
    color-scheme: light;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.34 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
button, input { font: inherit; color: inherit; }
a { color: inherit; }

.app {
  height: 100dvh;
  max-width: 480px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  border-inline: 1px solid var(--line);
  background: var(--bg);
}
@media (max-width: 480px) { .app { border-inline: 0; } }

/* ---- header ---- */
.bar {
  display: flex; align-items: center; gap: 4px;
  height: 60px; padding: 0 8px 0 4px;
  border-bottom: 1px solid var(--line);
  flex: none;
  padding-top: env(safe-area-inset-top);
  box-sizing: content-box;
}
.icon-btn {
  width: 44px; height: 44px; display: grid; place-items: center;
  background: none; border: 0; border-radius: 50%; cursor: pointer; text-decoration: none;
}
.icon-btn:active { opacity: .5; }
.who {
  flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px;
  background: none; border: 0; padding: 0; cursor: pointer; text-align: left;
}
.who-text { display: flex; flex-direction: column; min-width: 0; }
.who-name { font-weight: 600; font-size: 16px; }
.who-sub { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.ring {
  display: inline-grid; place-items: center; border-radius: 50%; flex: none;
  background: conic-gradient(from 200deg, #feda75, #fa7e1e, #d62976, #962fbf, #4f5bd5, #feda75);
}
.ring img { border-radius: 50%; display: block; border: 2px solid var(--bg); object-fit: cover; }
.ring.sm { padding: 2px; } .ring.sm img { width: 32px; height: 32px; }
.ring.lg { padding: 3px; } .ring.lg img { width: 92px; height: 92px; border-width: 3px; }

/* ---- thread ---- */
.thread {
  flex: 1; overflow-y: auto; overscroll-behavior: contain;
  padding: 8px 12px 12px;
}
.intro { text-align: center; padding: 22px 0 10px; }
.intro h1 { font-size: 20px; font-weight: 700; margin: 12px 0 2px; letter-spacing: -.01em; }
.intro-handle { margin: 0; font-size: 14px; color: var(--muted); }
.intro-meta { margin: 2px 0 14px; font-size: 14px; color: var(--muted); }
.pill-btn {
  display: inline-block; border: 0; border-radius: 8px; cursor: pointer;
  background: var(--bubble-in); padding: 7px 16px; font-weight: 600; font-size: 14px; text-decoration: none;
}
.pill-btn:active { opacity: .7; }
.pill-btn.wide { width: 100%; padding: 12px; background: var(--blue); color: #fff; font-size: 15px; margin-top: 8px; }
.notice {
  margin: 14px auto 6px; max-width: 320px; text-align: center;
  font-size: 12px; color: var(--muted); line-height: 1.4;
}
.stamp { text-align: center; font-size: 12px; color: var(--muted); margin: 18px 0 10px; font-weight: 500; }

.row { display: flex; align-items: flex-end; gap: 8px; margin-top: 2px; }
.row.first { margin-top: 10px; }
.row.out { justify-content: flex-end; }
.row .av { width: 28px; height: 28px; border-radius: 50%; flex: none; visibility: hidden; object-fit: cover; }
.row.last .av { visibility: visible; }

.bubble {
  max-width: 76%; padding: 8px 12px; border-radius: 22px;
  white-space: pre-wrap; overflow-wrap: anywhere;
  animation: pop .22s cubic-bezier(.2, .9, .3, 1.2) both;
}
.in .bubble { background: var(--bubble-in); }
.in.join-up .bubble { border-top-left-radius: 4px; }
.in.join-down .bubble { border-bottom-left-radius: 4px; }
.out .bubble {
  color: #fff;
  background-color: var(--sent-b);
  background-image: linear-gradient(180deg, var(--sent-a) 0%, var(--sent-b) 45%, var(--sent-c) 100%);
  background-attachment: fixed;
}
.out.join-up .bubble { border-top-right-radius: 4px; }
.out.join-down .bubble { border-bottom-right-radius: 4px; }
.bubble b { font-weight: 600; }
@keyframes pop { from { opacity: 0; transform: translateY(6px) scale(.97); } }

.seen { text-align: right; font-size: 12px; color: var(--muted); margin: 3px 4px 0 0; }

.typing { display: inline-flex; gap: 4px; padding: 13px 14px; }
.typing i {
  width: 7px; height: 7px; border-radius: 50%; background: var(--muted);
  animation: blink 1.2s infinite ease-in-out;
}
.typing i:nth-child(2) { animation-delay: .15s; }
.typing i:nth-child(3) { animation-delay: .3s; }
@keyframes blink { 0%, 60%, 100% { opacity: .3; transform: translateY(0); } 30% { opacity: 1; transform: translateY(-3px); } }

/* ---- restaurant cards (shared-post style) ---- */
.cards {
  display: flex; flex-direction: column; align-items: flex-start; gap: 6px;
  margin: 6px 0 0; padding-left: 36px;
}
.card {
  width: min(100%, 290px);
  background: var(--card); border: 1px solid var(--line); border-radius: 18px; overflow: hidden;
  display: flex; flex-direction: column;
  animation: pop .3s cubic-bezier(.2, .9, .3, 1.15) both;
}
.card:nth-child(2) { animation-delay: .06s; } .card:nth-child(3) { animation-delay: .12s; }
.card-img { height: 150px; background: #111 center/cover no-repeat; position: relative; }
.card-img.tile {
  display: grid; place-items: center; font-size: 46px;
  background: radial-gradient(120% 90% at 20% 10%, #3a2a55 0%, #1a1530 45%, #0d1a2e 100%);
}
.card-img .badge {
  position: absolute; left: 8px; top: 8px;
  background: rgba(0,0,0,.72); color: #fff; backdrop-filter: blur(6px);
  font-size: 12px; font-weight: 600; padding: 4px 8px; border-radius: 999px;
  display: inline-flex; align-items: center; gap: 4px;
}
.badge .sc { color: #ffd76a; font-weight: 700; }
.card-body { padding: 10px 12px 4px; display: flex; flex-direction: column; gap: 3px; flex: 1; }
.card-name { font-weight: 600; font-size: 15px; line-height: 1.25; }
.card-meta { font-size: 13px; color: var(--muted); }
.card-dist { font-size: 13px; font-weight: 600; margin-top: 4px; }
.card-verdict { font-size: 13px; line-height: 1.35; margin-top: 3px;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.card-verdict::before { content: "“"; } .card-verdict::after { content: "”"; }
.card-note { font-size: 13px; line-height: 1.35; margin-top: 3px; font-weight: 500; }
.photo {
  width: min(62vw, 240px); aspect-ratio: 4 / 5; object-fit: cover; border-radius: 18px; display: block;
  background: var(--bubble-in); animation: pop .3s ease both;
}
.in.join-up .photo { border-top-left-radius: 4px; }
.in.join-down .photo { border-bottom-left-radius: 4px; }
.card-hmc {
  align-self: flex-start; margin-top: 5px; padding: 2px 8px; border-radius: 999px;
  font-size: 11px; font-weight: 600; letter-spacing: .02em;
  color: #34c759; background: rgba(52, 199, 89, .14);
}
.card-verified { font-size: 12px; color: var(--muted); margin-top: 2px; display: flex; gap: 5px; align-items: center; }
.card-verified svg { flex: none; }
.card-actions { display: flex; border-top: 1px solid var(--line); margin-top: 8px; }
.card-actions a, .card-actions button {
  flex: 1; text-align: center; padding: 10px 4px; font-size: 13px; font-weight: 600;
  color: var(--blue); text-decoration: none; background: none; border: 0; font-family: inherit; cursor: pointer;
}
.card-actions > * + * { border-left: 1px solid var(--line) !important; }
.card-actions a:active, .card-actions button:active { opacity: .6; }
/* "Was this helpful?" under the latest reply */
.fb { margin: 2px 0 10px 36px; font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.fb button { background: none; border: 1px solid var(--line); border-radius: 999px; padding: 2px 9px; font-size: 14px; cursor: pointer; }
.fb button:active { transform: scale(.92); }

/* ---- quick replies + composer ---- */
.chips {
  flex: none; display: flex; gap: 8px; overflow-x: auto; padding: 8px 12px 4px; scrollbar-width: none;
}
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; background: var(--chip); border: 1px solid var(--chip-line); border-radius: 999px;
  padding: 7px 14px; font-size: 14px; cursor: pointer; white-space: nowrap;
  animation: pop .25s ease both;
}
.chip:active { background: var(--bubble-in); }

.composer {
  flex: none; display: flex; align-items: center; gap: 8px;
  margin: 6px 12px calc(10px + env(safe-area-inset-bottom));
  padding: 5px 6px 5px 5px; border: 1px solid var(--chip-line); border-radius: 26px; background: var(--bg);
}
.cam { width: 34px; height: 34px; border-radius: 50%; background: var(--blue); display: grid; place-items: center; flex: none; }
.composer input {
  flex: 1; min-width: 0; border: 0; outline: 0; background: none; padding: 8px 2px; font-size: 16px;
}
.composer input::placeholder { color: var(--muted); }
.send {
  border: 0; background: none; color: var(--blue); font-weight: 600; font-size: 15px;
  padding: 6px 10px; cursor: pointer; opacity: 0; pointer-events: none; transition: opacity .15s;
}
.composer.has-text .send { opacity: 1; pointer-events: auto; }
.send:active { color: var(--blue-press); }

/* ---- about sheet ---- */
.sheet-back {
  position: fixed; inset: 0; background: rgba(0,0,0,.55); display: flex; align-items: flex-end; justify-content: center;
  z-index: 10; animation: fade .2s ease both;
}
.sheet-back[hidden] { display: none; }
.sheet {
  width: 100%; max-width: 480px; background: var(--sheet); border-radius: 16px 16px 0 0;
  padding: 10px 20px calc(20px + env(safe-area-inset-bottom)); animation: rise .28s cubic-bezier(.2, .9, .3, 1) both;
}
.grab { width: 40px; height: 4px; border-radius: 2px; background: var(--chip-line); margin: 0 auto 14px; }
.sheet h2 { font-size: 17px; margin: 0 0 8px; text-align: center; }
.sheet p { font-size: 14px; line-height: 1.45; margin: 8px 0; }
.sheet-small { color: var(--muted); }
.score-inline { color: var(--gold); font-weight: 700; }
@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { transform: translateY(100%); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}

/* Small "Copied!" message (Share inside Instagram's browser) */
.toast {
  position: fixed; left: 50%; bottom: calc(90px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: var(--text, #111); color: var(--bg, #fff); padding: 9px 14px; border-radius: 999px;
  font-size: 13px; font-weight: 600; z-index: 50; box-shadow: 0 4px 16px rgba(0,0,0,.25);
  animation: toast 2.6s ease both; white-space: nowrap;
}
@keyframes toast { 0% { opacity: 0; transform: translate(-50%, 8px); } 10%, 85% { opacity: 1; transform: translate(-50%, 0); } 100% { opacity: 0; } }

/* Label on replies written by the AI fallback */
.ai-note { display: block; margin-top: 6px; font-size: 11px; color: var(--muted); }
