/* =================================================================
   Message Router — demo shell
   Two visual worlds on purpose: the phone reproduces WhatsApp exactly
   (its own tokens, --wa-*), the page around it is the studio's own
   design (--page-*, --ink-*, --accent-*). They share one theme switch.
   ================================================================= */

/* ---------- font stacks (system, no webfont fetch — kept honest) ---------- */
:root {
  --font-display: Georgia, "Iowan Old Style", "Palatino Linotype", "Book Antiqua", serif;
  --font-ui: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-mono: ui-monospace, "SF Mono", "Cascadia Code", "Consolas", monospace;
  --font-wa: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
}

/* ---------- LIGHT (default — explicit, not system-derived) ---------- */
:root,
:root[data-theme="light"] {
  --page-bg: #fbf6ef;
  --page-bg-2: #f5ede1;
  --ink: #241f2e;
  --ink-soft: #6b6478;
  --ink-faint: #9c93ab;
  --paper: #ffffff;
  --accent-blush: #f3b6c6;
  --accent-lavender: #c9b6f3;
  --accent-mint: #aee6c4;
  --accent-sun: #f6d186;
  --brand-teal: #0a8f74;
  --brand-teal-ink: #ffffff;
  --glass-bg: rgba(255, 255, 255, 0.6);
  --glass-border: rgba(255, 255, 255, 0.9);
  --glass-shadow: rgba(60, 40, 30, 0.16);
  --ring: rgba(36, 31, 46, 0.08);
  --danger: #c14953;
  --warn: #b8790f;
  --good: #1f8a5f;

  --wa-header: #008069;
  --wa-header-ink: #ffffff;
  --wa-list-bg: #ffffff;
  --wa-list-search-bg: #f0f2f5;
  --wa-list-ink: #111b21;
  --wa-list-subtitle: #667781;
  --wa-divider: #e9edef;
  --wa-chat-bg: #efeae2;
  --wa-bubble-in: #ffffff;
  --wa-bubble-in-ink: #111b21;
  --wa-bubble-out: #d9fdd3;
  --wa-bubble-out-ink: #111b21;
  --wa-bubble-shadow: rgba(0, 0, 0, 0.08);
  --wa-timestamp: #667781;
  --wa-tick-grey: #8696a0;
  --wa-tick-blue: #53bdee;
  --wa-fab: #00a884;
  --wa-fab-ink: #ffffff;
  --wa-online: #00a884;
  --wa-panel-ink: #111b21;
  --wa-icon: #54656f;
  --wa-badge: #25d366;
  --wa-badge-ink: #073b2c;
  --wa-doodle: radial-gradient(circle at 1px 1px, rgba(0, 0, 0, 0.05) 1px, transparent 0);
}

/* ---------- DARK, system-preferred (only when no explicit choice) ---------- */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --page-bg: #15121c;
    --page-bg-2: #1c1826;
    --ink: #f1ecf7;
    --ink-soft: #b8afc7;
    --ink-faint: #79708c;
    --paper: #1e1a28;
    --accent-blush: #e38fa6;
    --accent-lavender: #a98ce0;
    --accent-mint: #7fcba0;
    --accent-sun: #e0b563;
    --brand-teal: #24c39a;
    --brand-teal-ink: #0b1f1a;
    --glass-bg: rgba(30, 26, 40, 0.55);
    --glass-border: rgba(255, 255, 255, 0.08);
    --glass-shadow: rgba(0, 0, 0, 0.5);
    --ring: rgba(255, 255, 255, 0.08);
    --danger: #e58089;
    --warn: #e0b563;
    --good: #6bd9a6;

    --wa-header: #202c33;
    --wa-header-ink: #e9edef;
    --wa-list-bg: #111b21;
    --wa-list-search-bg: #202c33;
    --wa-list-ink: #e9edef;
    --wa-list-subtitle: #8696a0;
    --wa-divider: #222e35;
    --wa-chat-bg: #0b141a;
    --wa-bubble-in: #202c33;
    --wa-bubble-in-ink: #e9edef;
    --wa-bubble-out: #005c4b;
    --wa-bubble-out-ink: #e9edef;
    --wa-bubble-shadow: rgba(0, 0, 0, 0.3);
    --wa-timestamp: #8696a0;
    --wa-tick-grey: #8696a0;
    --wa-tick-blue: #53bdee;
    --wa-fab: #00a884;
    --wa-fab-ink: #062f26;
    --wa-online: #00d9a3;
    --wa-panel-ink: #e9edef;
    --wa-icon: #aebac1;
    --wa-badge: #00a884;
    --wa-badge-ink: #04241c;
    --wa-doodle: radial-gradient(circle at 1px 1px, rgba(255, 255, 255, 0.05) 1px, transparent 0);
  }
}

/* ---------- DARK, explicit toggle (always wins) ---------- */
:root[data-theme="dark"] {
  --page-bg: #15121c;
  --page-bg-2: #1c1826;
  --ink: #f1ecf7;
  --ink-soft: #b8afc7;
  --ink-faint: #79708c;
  --paper: #1e1a28;
  --accent-blush: #e38fa6;
  --accent-lavender: #a98ce0;
  --accent-mint: #7fcba0;
  --accent-sun: #e0b563;
  --brand-teal: #24c39a;
  --brand-teal-ink: #0b1f1a;
  --glass-bg: rgba(30, 26, 40, 0.55);
  --glass-border: rgba(255, 255, 255, 0.08);
  --glass-shadow: rgba(0, 0, 0, 0.5);
  --ring: rgba(255, 255, 255, 0.08);
  --danger: #e58089;
  --warn: #e0b563;
  --good: #6bd9a6;

  --wa-header: #202c33;
  --wa-header-ink: #e9edef;
  --wa-list-bg: #111b21;
  --wa-list-search-bg: #202c33;
  --wa-list-ink: #e9edef;
  --wa-list-subtitle: #8696a0;
  --wa-divider: #222e35;
  --wa-chat-bg: #0b141a;
  --wa-bubble-in: #202c33;
  --wa-bubble-in-ink: #e9edef;
  --wa-bubble-out: #005c4b;
  --wa-bubble-out-ink: #e9edef;
  --wa-bubble-shadow: rgba(0, 0, 0, 0.3);
  --wa-timestamp: #8696a0;
  --wa-tick-grey: #8696a0;
  --wa-tick-blue: #53bdee;
  --wa-fab: #00a884;
  --wa-fab-ink: #062f26;
  --wa-online: #00d9a3;
  --wa-panel-ink: #e9edef;
  --wa-icon: #aebac1;
  --wa-badge: #00a884;
  --wa-badge-ink: #04241c;
}

/* ------------------------------------------------------------- reset ---- */
*, *::before, *::after { box-sizing: border-box; }
html { color-scheme: light; scroll-behavior: smooth; }
html[data-theme="dark"] { color-scheme: dark; }
body {
  margin: 0;
  background: var(--page-bg);
  color: var(--ink);
  font-family: var(--font-ui);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
img { max-width: 100%; display: block; }
button { font: inherit; }
::selection { background: var(--accent-mint); color: #0b1f1a; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; transition-duration: 0.001ms !important; }
}

/* ------------------------------------------------------------ blobs ----- */
.blobs { position: fixed; inset: 0; z-index: 0; overflow: hidden; pointer-events: none; }
.blob {
  position: absolute; border-radius: 50%; filter: blur(60px); opacity: 0.55;
  animation: drift 26s ease-in-out infinite alternate;
}
.blob.b1 { width: 46vw; height: 46vw; top: -14vw; left: -12vw; background: var(--accent-blush); animation-delay: 0s; }
.blob.b2 { width: 38vw; height: 38vw; top: 8vw; right: -14vw; background: var(--accent-lavender); animation-delay: -8s; }
.blob.b3 { width: 34vw; height: 34vw; bottom: -12vw; left: 18vw; background: var(--accent-mint); animation-delay: -16s; }
.blob.b4 { width: 24vw; height: 24vw; bottom: 6vw; right: 10vw; background: var(--accent-sun); animation-delay: -4s; }
@keyframes drift {
  from { transform: translate(0, 0) scale(1); }
  to   { transform: translate(3vw, -2vw) scale(1.08); }
}

/* ------------------------------------------------------------ layout --- */
.wrap { position: relative; z-index: 1; max-width: 1180px; margin: 0 auto; padding: 0 28px; }

.topbar {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 28px;
  backdrop-filter: blur(14px) saturate(1.3);
  background: linear-gradient(to bottom, var(--page-bg) 55%, transparent);
}
.brand { display: flex; align-items: center; gap: 10px; font-family: var(--font-display); font-size: 1.15rem; letter-spacing: 0.01em; }
.brand .mark {
  width: 32px; height: 32px; border-radius: 10px; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--brand-teal), var(--accent-mint)); color: #06231c; font-size: 1rem;
  box-shadow: 0 4px 14px var(--glass-shadow);
}
.theme-toggle {
  border: 1px solid var(--ring); background: var(--glass-bg); backdrop-filter: blur(10px);
  width: 40px; height: 40px; border-radius: 50%; cursor: pointer; display: grid; place-items: center;
  color: var(--ink); transition: transform 0.25s ease, box-shadow 0.25s ease;
  box-shadow: 0 2px 10px var(--glass-shadow);
}
.theme-toggle:hover { transform: translateY(-2px); }
.theme-toggle svg { width: 18px; height: 18px; }

/* ------------------------------------------------------------- hero ---- */
.hero {
  position: relative; z-index: 1;
  display: grid; grid-template-columns: 1.05fr 0.95fr; gap: 40px; align-items: center;
  max-width: 1180px; margin: 0 auto; padding: 28px 28px 60px;
}
.eyebrow {
  display: inline-flex; align-items: center; gap: 8px;
  font-family: var(--font-mono); font-size: 0.72rem; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--brand-teal); background: color-mix(in srgb, var(--brand-teal) 12%, transparent);
  border: 1px solid color-mix(in srgb, var(--brand-teal) 30%, transparent);
  padding: 6px 12px; border-radius: 100px; margin-bottom: 18px;
}
.hero h1 {
  font-family: var(--font-display); font-weight: 600; text-wrap: balance;
  font-size: clamp(2.1rem, 3.6vw, 3.1rem); line-height: 1.08; margin: 0 0 20px; letter-spacing: -0.01em;
}
.hero h1 em { font-style: italic; color: var(--brand-teal); }
.lede { font-size: 1.04rem; line-height: 1.65; color: var(--ink-soft); max-width: 46ch; margin: 0 0 30px; }

.stat-row { display: flex; flex-wrap: wrap; gap: 14px; }
.stat-chip {
  --rot: 0deg;
  background: var(--glass-bg); border: 1px solid var(--glass-border);
  backdrop-filter: blur(10px); border-radius: 18px; padding: 12px 16px;
  box-shadow: 0 8px 20px var(--glass-shadow);
  transform: rotate(var(--rot));
  transition: transform 0.25s ease, box-shadow 0.25s ease;
  min-width: 108px;
}
.stat-chip:hover { transform: rotate(0deg) translateY(-3px); box-shadow: 0 14px 28px var(--glass-shadow); }
.stat-chip b { display: block; font-family: var(--font-display); font-size: 1.5rem; line-height: 1.1; }
.stat-chip span { display: block; font-size: 0.72rem; color: var(--ink-soft); margin-top: 2px; }

.hero-phone-wrap { position: relative; display: flex; justify-content: center; }
.callout {
  position: absolute; z-index: 5; max-width: 168px; padding: 10px 13px; border-radius: 14px;
  background: var(--glass-bg); border: 1px solid var(--glass-border); backdrop-filter: blur(10px);
  font-family: var(--font-display); font-style: italic; font-size: 0.86rem; line-height: 1.3;
  box-shadow: 0 10px 24px var(--glass-shadow); color: var(--ink);
  animation: floaty 6s ease-in-out infinite;
}
.callout.c1 { top: 4%; left: -8%; animation-delay: -1s; }
.callout.c2 { bottom: 10%; right: -12%; animation-delay: -3s; }
.callout .arrow { display: block; font-family: var(--font-mono); font-size: 0.7rem; color: var(--brand-teal); margin-top: 4px; font-style: normal; }
@keyframes floaty { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-8px); } }

/* --------------------------------------------------------- phone stage - */
.phone-stage { position: relative; z-index: 1; max-width: 1180px; margin: 0 auto; padding: 10px 28px 90px; display: flex; flex-direction: column; align-items: center; }
.stage-controls {
  display: flex; align-items: center; gap: 12px; margin-bottom: 26px; flex-wrap: wrap; justify-content: center;
}
.stage-controls label { font-size: 0.78rem; color: var(--ink-soft); font-family: var(--font-mono); text-transform: uppercase; letter-spacing: 0.06em; }
#userSwitch {
  border: 1px solid var(--ring); background: var(--glass-bg); backdrop-filter: blur(8px);
  color: var(--ink); padding: 9px 14px; border-radius: 100px; font-family: var(--font-ui); font-size: 0.92rem;
  cursor: pointer; box-shadow: 0 4px 14px var(--glass-shadow);
}
.hint-pill {
  font-size: 0.76rem; color: var(--ink-soft); background: var(--glass-bg); border: 1px solid var(--glass-border);
  padding: 7px 13px; border-radius: 100px; display: inline-flex; align-items: center; gap: 6px;
}

.phone-frame-outer { position: relative; }
.phone {
  width: 380px; max-width: 92vw; height: 780px; max-height: 82vh;
  border-radius: 46px; padding: 12px; background: linear-gradient(160deg, #2c2c34, #131316);
  box-shadow: 0 30px 60px -20px var(--glass-shadow), 0 0 0 1px rgba(0,0,0,0.4), inset 0 0 0 2px rgba(255,255,255,0.06);
  transform: perspective(1400px) rotateY(-4deg) rotateX(1.5deg);
  transition: transform 0.6s cubic-bezier(.2,.8,.2,1);
}
.phone:hover, .phone.settled { transform: perspective(1400px) rotateY(0deg) rotateX(0deg); }
.screen {
  position: relative; width: 100%; height: 100%; border-radius: 34px; overflow: hidden;
  background: var(--wa-chat-bg); display: flex; flex-direction: column;
  box-shadow: inset 0 0 0 1px rgba(0,0,0,0.35);
}
.notch {
  position: absolute; top: 10px; left: 50%; transform: translateX(-50%); width: 110px; height: 22px;
  background: #131316; border-radius: 14px; z-index: 50;
}
.statusbar {
  height: 30px; display: flex; align-items: center; justify-content: space-between; padding: 0 24px;
  background: var(--wa-header); color: var(--wa-header-ink); font-size: 0.72rem; font-family: var(--font-wa);
  font-variant-numeric: tabular-nums; flex-shrink: 0; position: relative; z-index: 2;
}
.statusbar .icons { display: flex; gap: 4px; align-items: center; }

/* --------------------------------------------------------- WA screens -- */
.view { position: absolute; inset: 0; top: 30px; display: flex; flex-direction: column; background: var(--wa-list-bg); transition: transform 0.32s cubic-bezier(.2,.8,.2,1), opacity 0.32s ease; }
.view.hidden { transform: translateX(100%); opacity: 0; pointer-events: none; }
.view.chat-list-view.hidden { transform: translateX(-30%); }

.wa-header { background: var(--wa-header); color: var(--wa-header-ink); flex-shrink: 0; }
.list-header { padding: 14px 16px 8px; display: flex; align-items: center; justify-content: space-between; }
.list-header .wa-title { font-size: 1.3rem; font-weight: 700; font-family: var(--font-wa); }
.header-icons { display: flex; gap: 20px; align-items: center; }
.header-icons svg { width: 20px; height: 20px; fill: currentColor; }
.filter-row { display: flex; gap: 8px; padding: 10px 16px 12px; }
.filter-pill { padding: 6px 14px; border-radius: 100px; font-size: 0.82rem; background: rgba(255,255,255,0.16); }
.filter-pill.active { background: #ffffff; color: var(--wa-header); font-weight: 600; }

.search-bar { margin: 10px 12px; background: var(--wa-list-search-bg); border-radius: 10px; padding: 9px 12px; display: flex; align-items: center; gap: 10px; color: var(--wa-list-subtitle); font-size: 0.9rem; flex-shrink: 0; }
.search-bar svg { width: 16px; height: 16px; }

.chat-list { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.chat-list.hidden { display: none; }
.nav-stub.hidden { display: none; }
.chat-row { position: relative; display: flex; gap: 12px; padding: 10px 16px; align-items: center; cursor: pointer; border-bottom: 1px solid transparent; }
.chat-row:active { background: var(--wa-list-search-bg); }
.avatar {
  width: 49px; height: 49px; border-radius: 50%; flex-shrink: 0; display: grid; place-items: center;
  font-family: var(--font-wa); font-weight: 600; color: #ffffff; font-size: 1rem; position: relative;
}
.avatar.group::after { content: "👥"; position: absolute; bottom: -2px; right: -2px; font-size: 0.7rem; background: var(--wa-list-bg); border-radius: 50%; padding: 1px; }
.avatar.bot { background: linear-gradient(135deg, var(--brand-teal), var(--accent-lavender)) !important; }
.chat-row-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.chat-row-top { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.chat-row-name { font-size: 0.98rem; color: var(--wa-list-ink); font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: flex; align-items: center; gap: 4px; }
.verified-badge { color: var(--brand-teal); flex-shrink: 0; }
.chat-row-time { font-size: 0.74rem; color: var(--wa-list-subtitle); flex-shrink: 0; }
.chat-row-time.unread { color: var(--wa-badge); font-weight: 600; }
.chat-row-bottom { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.chat-row-preview { font-size: 0.86rem; color: var(--wa-list-subtitle); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: flex; align-items: center; gap: 4px; }
.action-dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }
.chat-row-badge { min-width: 19px; height: 19px; border-radius: 10px; background: var(--wa-badge); color: var(--wa-badge-ink); font-size: 0.7rem; font-weight: 700; display: grid; place-items: center; padding: 0 5px; flex-shrink: 0; }

.bottom-nav { display: flex; border-top: 1px solid var(--wa-divider); background: var(--wa-list-bg); flex-shrink: 0; }
.bottom-nav .nav-item { flex: 1; text-align: center; padding: 8px 0 10px; font-size: 0.68rem; color: var(--wa-list-subtitle); }
.bottom-nav .nav-item .nav-ico { font-size: 1.05rem; display: block; margin-bottom: 2px; }
.bottom-nav .nav-item.active { color: var(--brand-teal); }

/* --------------------------------------------------------- thread ------ */
.thread-header { position: relative; display: flex; align-items: center; gap: 4px; padding: 8px 10px; }
.back-btn { background: none; border: none; color: var(--wa-header-ink); font-size: 1.5rem; cursor: pointer; padding: 4px 6px; line-height: 1; }
.thread-title { flex: 1; min-width: 0; display: flex; flex-direction: column; margin-left: 4px; }
.thread-title .t-name { font-size: 1rem; font-weight: 600; font-family: var(--font-wa); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: flex; align-items: center; gap: 5px; }
.thread-title .t-sub { font-size: 0.72rem; opacity: 0.85; }

.thread-messages { flex: 1; overflow-y: auto; padding: 14px 10px; background-color: var(--wa-chat-bg); background-image: var(--wa-doodle); background-size: 16px 16px; display: flex; flex-direction: column; gap: 2px; }
.date-chip { align-self: center; background: rgba(255,255,255,0.75); color: #54656f; font-size: 0.72rem; padding: 5px 11px; border-radius: 8px; margin: 10px 0; box-shadow: 0 1px 1px rgba(0,0,0,0.08); }
:root[data-theme="dark"] .date-chip { background: #182229; color: #8696a0; }

.bubble-row { display: flex; margin: 2px 0; max-width: 100%; }
.bubble-row.in { justify-content: flex-start; }
.bubble-row.out { justify-content: flex-end; }
.bubble {
  position: relative; max-width: 78%; padding: 6px 8px 7px 9px; border-radius: 8px;
  box-shadow: 0 1px 1px var(--wa-bubble-shadow); font-size: 0.89rem; line-height: 1.35; cursor: default;
  animation: pop-in 0.28s cubic-bezier(.2,.8,.2,1) both;
}
@keyframes pop-in { from { opacity: 0; transform: translateY(6px) scale(0.98); } to { opacity: 1; transform: none; } }
.bubble.in { background: var(--wa-bubble-in); color: var(--wa-bubble-in-ink); border-top-left-radius: 2px; }
.bubble.out { background: var(--wa-bubble-out); color: var(--wa-bubble-out-ink); border-top-right-radius: 2px; }
.bubble .sender-name { display: block; font-size: 0.8rem; font-weight: 700; margin-bottom: 2px; }
.bubble .btext { white-space: pre-wrap; word-wrap: break-word; }
.bubble .btext:empty { display: none; }
.bubble .bmeta { display: flex; justify-content: flex-end; align-items: center; gap: 3px; float: right; margin: 3px -2px -2px 8px; }
.bubble .btime { font-size: 0.68rem; color: var(--wa-timestamp); }
.bubble.out .btime { color: rgba(17,27,33,0.5); }
.tick { width: 15px; height: 10px; }
.tick .stroke { fill: none; stroke: var(--wa-tick-grey); stroke-width: 1.6; }
.tick.read .stroke { stroke: var(--wa-tick-blue); }

.bubble.decisioned { cursor: pointer; }
.bubble.decisioned::after { content: ""; position: absolute; inset: -3px; border-radius: 11px; border: 1.5px dashed color-mix(in srgb, var(--action-color, var(--brand-teal)) 55%, transparent); transition: border-color 0.2s, transform 0.15s; pointer-events: none; }
.bubble.decisioned:hover::after, .bubble.decisioned:active::after { border-color: var(--action-color, var(--brand-teal)); }
.bubble.decisioned:active { transform: scale(0.985); }
.decision-tag {
  clear: both; display: inline-flex; align-items: center; gap: 4px; margin-top: 6px; padding: 3px 8px 3px 6px; border-radius: 100px;
  font-size: 0.68rem; font-weight: 700; letter-spacing: 0.02em; text-transform: uppercase;
  background: color-mix(in srgb, var(--action-color) 16%, transparent); color: var(--action-color);
  border: 1px solid color-mix(in srgb, var(--action-color) 40%, transparent);
}
.decision-tag .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--action-color); }

.media-card { border-radius: 6px; overflow: hidden; margin-bottom: 5px; background: rgba(0,0,0,0.04); }
.media-card .media-visual { display: flex; align-items: center; gap: 10px; padding: 22px 12px; background: linear-gradient(135deg, var(--accent-lavender), var(--accent-blush)); color: #2b2233; }
.media-card.voice .media-visual { background: linear-gradient(135deg, var(--accent-mint), var(--accent-sun)); }
.media-card .media-icon { font-size: 1.5rem; }
.media-card .media-cap { font-size: 0.78rem; padding: 6px 9px 2px; color: var(--wa-list-subtitle); font-style: italic; }
.waveform { flex: 1; display: flex; align-items: center; gap: 2px; height: 22px; }
.waveform span { width: 3px; border-radius: 2px; background: rgba(43,34,51,0.55); }

.typing-row { display: flex; margin: 4px 0; }
.typing-bubble { background: var(--wa-bubble-in); border-radius: 8px; border-top-left-radius: 2px; padding: 10px 14px; display: flex; gap: 4px; box-shadow: 0 1px 1px var(--wa-bubble-shadow); }
.typing-bubble span { width: 6px; height: 6px; border-radius: 50%; background: var(--wa-tick-grey); animation: bounce 1.1s infinite ease-in-out; }
.typing-bubble span:nth-child(2) { animation-delay: 0.15s; }
.typing-bubble span:nth-child(3) { animation-delay: 0.3s; }
@keyframes bounce { 0%, 60%, 100% { transform: translateY(0); opacity: 0.5; } 30% { transform: translateY(-4px); opacity: 1; } }

.quick-replies { display: flex; flex-wrap: wrap; gap: 8px; padding: 10px 6px 4px; }
.qr-chip {
  border: 1px solid var(--brand-teal); color: var(--brand-teal); background: color-mix(in srgb, var(--brand-teal) 8%, var(--wa-chat-bg));
  padding: 8px 13px; border-radius: 100px; font-size: 0.82rem; cursor: pointer; font-family: var(--font-wa);
  transition: transform 0.15s ease, background 0.15s ease;
}
.qr-chip:hover { background: color-mix(in srgb, var(--brand-teal) 16%, var(--wa-chat-bg)); transform: translateY(-1px); }
.qr-chip:disabled { opacity: 0.4; cursor: default; transform: none; }

.deep-link-btn {
  display: inline-flex; align-items: center; gap: 6px; margin-top: 8px; background: var(--brand-teal); color: var(--brand-teal-ink);
  border: none; padding: 8px 12px; border-radius: 8px; font-size: 0.8rem; font-weight: 600; cursor: pointer; font-family: var(--font-wa);
}

.composer { display: flex; align-items: flex-end; gap: 8px; padding: 8px 8px; background: transparent; flex-shrink: 0; }
.composer .cbox { flex: 1; background: var(--wa-bubble-in); border-radius: 24px; padding: 9px 14px; display: flex; align-items: center; gap: 8px; box-shadow: 0 1px 2px var(--wa-bubble-shadow); }
.composer input { flex: 1; border: none; outline: none; background: none; color: var(--wa-list-ink); font-size: 0.92rem; font-family: var(--font-wa); }
.composer input::placeholder { color: var(--wa-list-subtitle); }
.send-btn { width: 42px; height: 42px; border-radius: 50%; background: var(--wa-fab); color: var(--wa-fab-ink); border: none; display: grid; place-items: center; cursor: pointer; flex-shrink: 0; box-shadow: 0 3px 8px var(--wa-bubble-shadow); }
.send-btn svg { width: 19px; height: 19px; margin-left: 2px; }
.send-btn:disabled { opacity: 0.5; cursor: default; }

.locked-note { text-align: center; font-size: 0.72rem; color: var(--wa-list-subtitle); padding: 6px 20px 10px; }

/* --------------------------------------------------------- sheet ------- */
.sheet-overlay { position: fixed; inset: 0; background: rgba(10, 8, 14, 0.55); backdrop-filter: blur(3px); z-index: 90; opacity: 0; transition: opacity 0.25s ease; }
.sheet-overlay.hidden { opacity: 0; pointer-events: none; }
.sheet-overlay.show { opacity: 1; }

.pipeline-sheet {
  position: fixed; left: 50%; bottom: 0; transform: translate(-50%, 100%); width: min(420px, 94vw); max-height: 86vh;
  background: var(--paper); border-radius: 24px 24px 0 0; z-index: 91; box-shadow: 0 -20px 60px rgba(0,0,0,0.35);
  transition: transform 0.38s cubic-bezier(.2,.85,.25,1); display: flex; flex-direction: column; overflow: hidden;
}
.pipeline-sheet.show { transform: translate(-50%, 0); }
.sheet-grab { width: 40px; height: 4px; background: var(--ring); border-radius: 4px; margin: 10px auto 4px; flex-shrink: 0; }
.sheet-head { padding: 6px 22px 14px; flex-shrink: 0; border-bottom: 1px solid var(--ring); }
.sheet-head .sh-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.sheet-head h3 { font-family: var(--font-display); font-size: 1.2rem; margin: 0 0 4px; }
.sheet-head .sh-msg { font-size: 0.86rem; color: var(--ink-soft); font-style: italic; max-width: 30ch; }
.sheet-close { border: none; background: var(--ring); width: 30px; height: 30px; border-radius: 50%; cursor: pointer; color: var(--ink); flex-shrink: 0; font-size: 1rem; }
.action-badge { display: inline-flex; align-items: center; gap: 6px; padding: 5px 12px; border-radius: 100px; font-weight: 700; font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.03em; background: color-mix(in srgb, var(--action-color) 18%, transparent); color: var(--action-color); border: 1px solid color-mix(in srgb, var(--action-color) 45%, transparent); margin-top: 8px; }

.conf-gauge { margin-top: 12px; }
.conf-gauge .cg-label { display: flex; justify-content: space-between; font-family: var(--font-mono); font-size: 0.68rem; color: var(--ink-faint); margin-bottom: 4px; }
.conf-gauge .cg-track { position: relative; height: 6px; border-radius: 4px; background: var(--ring); overflow: visible; }
.conf-gauge .cg-band { position: absolute; top: 0; bottom: 0; border-radius: 4px; background: color-mix(in srgb, var(--action-color) 30%, transparent); }
.conf-gauge .cg-dot { position: absolute; top: 50%; width: 12px; height: 12px; border-radius: 50%; background: var(--action-color); border: 2px solid var(--paper); transform: translate(-50%, -50%); box-shadow: 0 0 0 3px color-mix(in srgb, var(--action-color) 30%, transparent); }

.sheet-body { flex: 1; overflow-y: auto; padding: 18px 22px 28px; }

.flow { display: flex; gap: 14px; }
.flow-rail { display: flex; flex-direction: column; align-items: center; flex-shrink: 0; width: 26px; }
.flow-node { width: 26px; height: 26px; border-radius: 50%; background: var(--ring); border: 2px solid var(--ring); display: grid; place-items: center; font-size: 0.82rem; flex-shrink: 0; opacity: 0.35; transform: scale(0.8); transition: all 0.4s cubic-bezier(.3,1.4,.4,1); }
.flow-node.active { opacity: 1; transform: scale(1); border-color: var(--brand-teal); background: color-mix(in srgb, var(--brand-teal) 16%, var(--paper)); }
.flow-node.override { border-color: var(--danger); background: color-mix(in srgb, var(--danger) 16%, var(--paper)); }
.flow-node.final.active { border-color: var(--action-color); background: color-mix(in srgb, var(--action-color) 20%, var(--paper)); animation: node-pop 0.5s cubic-bezier(.3,1.6,.4,1); }
@keyframes node-pop { 0% { transform: scale(0.6); } 60% { transform: scale(1.18); } 100% { transform: scale(1); } }
.flow-line { width: 2px; flex: 1; min-height: 22px; background: var(--ring); position: relative; overflow: hidden; }
.flow-line .fill { position: absolute; inset: auto 0 0 0; height: 0%; background: var(--brand-teal); transition: height 0.5s ease; }
.flow-line.dashed .fill { background: repeating-linear-gradient(to bottom, var(--danger) 0 4px, transparent 4px 8px); }
.flow-steps { flex: 1; display: flex; flex-direction: column; gap: 22px; min-width: 0; }
.flow-step { opacity: 0.25; transform: translateY(6px); transition: all 0.4s ease; min-height: 26px; }
.flow-step.active { opacity: 1; transform: none; }
.flow-step h4 { margin: 0 0 4px; font-size: 0.86rem; font-family: var(--font-ui); font-weight: 700; }
.flow-step .fs-body { font-size: 0.83rem; color: var(--ink-soft); line-height: 1.5; }
.flow-step .fs-body strong { color: var(--ink); }

.chip-row { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.sig-chip { font-family: var(--font-mono); font-size: 0.68rem; background: var(--ring); color: var(--ink-soft); padding: 3px 8px; border-radius: 6px; }
.sig-chip.hot { background: color-mix(in srgb, var(--danger) 18%, transparent); color: var(--danger); }
.evid-chip { font-family: var(--font-ui); font-size: 0.76rem; background: color-mix(in srgb, var(--brand-teal) 10%, transparent); color: var(--brand-teal); padding: 5px 10px; border-radius: 8px; cursor: pointer; border: 1px solid color-mix(in srgb, var(--brand-teal) 30%, transparent); margin-top: 6px; display: inline-block; }
.evid-preview { margin-top: 8px; background: var(--ring); border-radius: 10px; padding: 10px 12px; font-size: 0.8rem; display: none; }
.evid-preview.show { display: block; }
.evid-preview .ep-meta { font-family: var(--font-mono); font-size: 0.68rem; color: var(--ink-faint); margin-top: 4px; }

.override-banner { margin-top: 10px; background: color-mix(in srgb, var(--danger) 12%, transparent); border: 1px solid color-mix(in srgb, var(--danger) 35%, transparent); color: var(--danger); border-radius: 10px; padding: 9px 11px; font-size: 0.8rem; font-weight: 600; }
.reason-final { margin-top: 10px; padding: 12px 14px; background: var(--ring); border-radius: 12px; font-size: 0.87rem; line-height: 1.5; }
.reason-final .rf-check { color: var(--good); font-size: 0.76rem; font-weight: 700; margin-top: 6px; display: block; }

/* --------------------------------------------------------- pipeline ---- */
.pipeline-overview { position: relative; z-index: 1; max-width: 900px; margin: 40px auto 0; padding: 0 28px 90px; }
.pipeline-overview h2 { font-family: var(--font-display); font-size: 1.9rem; text-align: center; margin-bottom: 8px; text-wrap: balance; }
.pipeline-overview .sub { text-align: center; color: var(--ink-soft); margin-bottom: 34px; }
.diagram-card { background: var(--glass-bg); border: 1px solid var(--glass-border); backdrop-filter: blur(10px); border-radius: 24px; padding: 26px 20px; box-shadow: 0 14px 40px var(--glass-shadow); overflow-x: auto; }
.diagram-card svg { width: 100%; height: auto; display: block; min-width: 640px; }
.diagram-card figcaption { text-align: center; font-size: 0.84rem; color: var(--ink-soft); margin-top: 14px; }

/* ------------------------------------------------------------ footer --- */
.site-footer { position: relative; z-index: 1; text-align: center; padding: 30px 28px 60px; color: var(--ink-faint); font-size: 0.84rem; }
.site-footer a { color: var(--brand-teal); text-decoration: none; border-bottom: 1px dotted; }

/* ------------------------------------------------------------ misc ----- */
.reveal { animation: rise 0.7s cubic-bezier(.2,.8,.2,1) both; }
@keyframes rise { from { opacity: 0; transform: translateY(18px); } to { opacity: 1; transform: none; } }

/* --------------------------------------------------- operational chrome */
.search-bar { position: relative; }
.search-bar input {
  flex: 1; border: none; outline: none; background: none; color: var(--wa-list-ink);
  font-family: var(--font-wa); font-size: 0.9rem;
}
.search-bar input::placeholder { color: var(--wa-list-subtitle); }
.search-clear { border: none; background: none; color: var(--wa-list-subtitle); cursor: pointer; font-size: 0.9rem; padding: 2px; display: none; }
.search-bar.has-value .search-clear { display: block; }

.filter-pill { cursor: pointer; user-select: none; transition: background 0.15s, color 0.15s, transform 0.1s; border: none; font: inherit; }
.filter-pill:active { transform: scale(0.96); }

.empty-row { padding: 46px 24px; text-align: center; color: var(--wa-list-subtitle); font-size: 0.86rem; line-height: 1.5; }
.empty-row .ee { font-size: 1.8rem; display: block; margin-bottom: 10px; }

.header-icons button { background: none; border: none; color: currentColor; padding: 4px; cursor: pointer; display: flex; min-width: 32px; min-height: 32px; align-items: center; justify-content: center; border-radius: 50%; transition: background 0.15s; }
.header-icons button:active { background: rgba(255, 255, 255, 0.18); }
.header-icons { position: relative; }

.dropdown-menu {
  position: absolute; top: 44px; right: 0; z-index: 30; min-width: 208px;
  background: var(--paper); color: var(--ink); border-radius: 14px; overflow: hidden;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.28); border: 1px solid var(--ring);
  opacity: 0; transform: translateY(-6px) scale(0.97); pointer-events: none; transition: all 0.16s ease;
}
.dropdown-menu.show { opacity: 1; transform: none; pointer-events: auto; }
.dropdown-menu button {
  display: flex; align-items: center; gap: 10px; width: 100%; border: none; background: none; color: var(--ink);
  font: inherit; font-size: 0.86rem; text-align: left; padding: 12px 15px; cursor: pointer; transition: background 0.12s;
}
.dropdown-menu button:hover, .dropdown-menu button:active { background: var(--ring); }
.dropdown-menu .dm-divider { height: 1px; background: var(--ring); margin: 2px 0; }

/* pinned Router HQ — impossible to miss on first look */
.chat-row.pinned-hq { position: relative; background: color-mix(in srgb, var(--brand-teal) 7%, transparent); }
.chat-row.pinned-hq .avatar { box-shadow: 0 0 0 0 color-mix(in srgb, var(--brand-teal) 55%, transparent); animation: hq-pulse 2.1s ease-out 3; }
@keyframes hq-pulse {
  0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--brand-teal) 55%, transparent); }
  70% { box-shadow: 0 0 0 12px color-mix(in srgb, var(--brand-teal) 0%, transparent); }
  100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--brand-teal) 0%, transparent); }
}
.start-badge {
  font-size: 0.62rem; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase;
  background: var(--brand-teal); color: var(--brand-teal-ink); padding: 2px 7px; border-radius: 100px; margin-left: 6px;
}
.spotlight-arrow {
  position: absolute; left: 66px; top: -6px; z-index: 25; display: flex; align-items: center; gap: 6px;
  background: var(--ink); color: var(--page-bg); font-family: var(--font-ui); font-size: 0.76rem; font-weight: 600;
  padding: 7px 12px; border-radius: 100px; box-shadow: 0 8px 20px rgba(0, 0, 0, 0.3);
  animation: spotlight-in 0.4s cubic-bezier(.2, .8, .2, 1) both, spotlight-bob 1.6s ease-in-out 0.4s infinite;
  pointer-events: none; white-space: nowrap;
}
@keyframes spotlight-in { from { opacity: 0; transform: translateY(6px) scale(0.9); } to { opacity: 1; transform: none; } }
@keyframes spotlight-bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-4px); } }
.spotlight-arrow.out { animation: spotlight-out 0.3s ease forwards; }
@keyframes spotlight-out { to { opacity: 0; transform: translateY(-6px) scale(0.92); } }

/* nav stub screen */
.nav-item { cursor: pointer; background: none; border: none; font: inherit; color: var(--wa-list-subtitle); transition: color 0.15s; }
.nav-stub { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; padding: 30px; text-align: center; background: var(--wa-list-bg); }
.nav-stub .ns-icon { font-size: 2.4rem; }
.nav-stub p { color: var(--wa-list-subtitle); font-size: 0.86rem; line-height: 1.5; max-width: 26ch; margin: 0; }
.nav-stub button { background: var(--brand-teal); color: var(--brand-teal-ink); border: none; padding: 10px 18px; border-radius: 100px; font-size: 0.84rem; font-weight: 600; cursor: pointer; }

/* fake-but-tappable composer row for read-only threads */
.composer-fake { display: flex; align-items: center; gap: 6px; padding: 8px 8px; flex-shrink: 0; }
.composer-fake .cbox { flex: 1; background: var(--wa-bubble-in); border-radius: 24px; padding: 9px 8px 9px 14px; display: flex; align-items: center; gap: 8px; box-shadow: 0 1px 2px var(--wa-bubble-shadow); opacity: 0.85; }
.composer-fake .cbox span.ph { flex: 1; color: var(--wa-list-subtitle); font-size: 0.88rem; }
.icon-btn { background: none; border: none; font-size: 1.05rem; color: var(--wa-icon); cursor: pointer; padding: 4px; line-height: 1; border-radius: 50%; min-width: 30px; min-height: 30px; }
.icon-btn:active { background: rgba(127, 127, 127, 0.18); }
.send-btn.fake { opacity: 0.9; }

/* toast */
.toast-stack { position: absolute; left: 50%; bottom: 78px; transform: translateX(-50%); z-index: 60; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; width: 92%; }
.toast {
  background: var(--ink); color: var(--page-bg); font-family: var(--font-ui); font-size: 0.8rem; line-height: 1.4;
  padding: 10px 15px; border-radius: 12px; box-shadow: 0 10px 26px rgba(0, 0, 0, 0.3); max-width: 100%;
  animation: toast-in 0.28s cubic-bezier(.2, .8, .2, 1) both;
}
.toast.out { animation: toast-out 0.22s ease forwards; }
@keyframes toast-in { from { opacity: 0; transform: translateY(10px) scale(0.96); } to { opacity: 1; transform: none; } }
@keyframes toast-out { to { opacity: 0; transform: translateY(6px) scale(0.97); } }

/* contact-info popover */
.info-pop {
  position: absolute; top: 46px; left: 8px; right: 8px; z-index: 30; background: var(--paper); color: var(--ink);
  border-radius: 16px; box-shadow: 0 16px 40px rgba(0, 0, 0, 0.3); border: 1px solid var(--ring);
  padding: 18px 18px 16px; opacity: 0; transform: translateY(-8px) scale(0.97); pointer-events: none; transition: all 0.18s ease;
}
.info-pop.show { opacity: 1; transform: none; pointer-events: auto; }
.info-pop .ip-avatar { width: 56px; height: 56px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; color: #fff; font-family: var(--font-wa); font-size: 1.2rem; margin-bottom: 10px; }
.info-pop h4 { margin: 0 0 3px; font-family: var(--font-display); font-size: 1.05rem; }
.info-pop .ip-sub { font-size: 0.8rem; color: var(--ink-soft); margin-bottom: 10px; }
.info-pop .ip-row { display: flex; justify-content: space-between; font-size: 0.8rem; padding: 6px 0; border-top: 1px solid var(--ring); }
.info-pop .ip-row b { font-family: var(--font-mono); font-weight: 600; }

/* ---------------------------------------------------- diagram animation */
.diagram-card .arch-node { opacity: 0.18; transform: translateY(6px); transition: opacity 0.4s ease, transform 0.4s ease; transform-box: fill-box; transform-origin: center; }
.diagram-card.play .arch-node.on { opacity: 1; transform: translateY(0); }
.diagram-card .arch-edge { transition: stroke-dashoffset 0.5s ease, opacity 0.3s ease; opacity: 0.3; }
.diagram-card.play .arch-edge.on { opacity: 0.9; }
.diagram-card .arch-node rect { transition: stroke 0.3s ease, fill 0.3s ease; }
.diagram-card.play .arch-node.on.hot rect { stroke: var(--danger); stroke-width: 2.2; }
.diagram-replay {
  display: flex; align-items: center; gap: 6px; margin: 16px auto 0; background: var(--glass-bg); border: 1px solid var(--glass-border);
  color: var(--ink); font-family: var(--font-ui); font-size: 0.8rem; font-weight: 600; padding: 8px 16px; border-radius: 100px;
  cursor: pointer; backdrop-filter: blur(8px);
}

/* ------------------------------------------------------------ responsive */
@media (max-width: 880px) {
  .hero { grid-template-columns: 1fr; padding-top: 8px; }
  .hero-phone-wrap { order: -1; margin-bottom: 10px; transform: scale(0.86); }
  .callout { display: none; }
  .lede { max-width: 60ch; }
}
@media (max-width: 460px) {
  .wrap, .topbar, .phone-stage, .pipeline-overview { padding-left: 16px; padding-right: 16px; }
  .phone { width: 100%; height: 640px; border-radius: 32px; }
  .screen { border-radius: 22px; }
}
