/* Prime AI — iOS 26 dark. Minimal top bar + top-right nav (no bottom bar).
 * Pure black (no gradient), thin type, translucent glass, iMessage bubbles, x.com feed. */

:root {
  --bg: #000000;
  --blue: #0a84ff;
  --blue-2: #409cff;
  --green: #30d158;
  --amber: #ff9f0a;
  --red: #ff453a;
  --purple: #bf5af2;

  --label: #ffffff;
  --label-2: rgba(235, 235, 245, 0.6);
  --label-3: rgba(235, 235, 245, 0.3);

  --glass: rgba(28, 28, 30, 0.6);
  --glass-strong: rgba(30, 30, 32, 0.82);
  --card: rgba(118, 118, 128, 0.14);
  --hair: rgba(255, 255, 255, 0.09);
  --hair-soft: rgba(255, 255, 255, 0.055);

  --bubble-in: rgba(118, 118, 128, 0.26);
  --bubble-out: #0a84ff;

  --bottom-space: calc(env(safe-area-inset-bottom, 0px) + 12px);
  --top-space: calc(env(safe-area-inset-top, 0px) + 74px);
  --pill-h: 46px;

  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display",
    "Segoe UI", system-ui, Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
body {
  background: var(--bg);
  color: var(--label);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow: hidden;
  display: flex;
  justify-content: center;
  letter-spacing: -0.01em;
  /* no double-tap zoom, no rubber-band page movement */
  touch-action: manipulation;
  overscroll-behavior: none;
}
.hidden { display: none !important; }

/* ============ App shell ============ */
.app {
  position: relative;
  width: 100%; max-width: 620px; height: 100dvh;
  display: flex; flex-direction: column; overflow: hidden;
  background: var(--bg);
}
@media (min-width: 640px) { .app { border-left: 1px solid var(--hair-soft); border-right: 1px solid var(--hair-soft); } }

.stage { position: relative; flex: 1; min-height: 0; }
.view { position: absolute; inset: 0; display: flex; flex-direction: column; min-height: 0; }
.subpane { position: absolute; inset: 0; display: flex; flex-direction: column; min-height: 0; }
.scroll::-webkit-scrollbar, .messages::-webkit-scrollbar { width: 0; }
/* Lock to vertical only — no horizontal drag, no rubber-band leaking to the page */
.messages, .feed, .conv-list, .settings, .scroll {
  overflow-x: hidden; overscroll-behavior: contain; touch-action: pan-y;
}

/* ============ Minimal top bar ============ */
.topbar {
  position: absolute; top: 0; left: 0; right: 0; z-index: 30;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: calc(env(safe-area-inset-top, 0px) + 12px) 14px 10px;
  background: transparent; pointer-events: none;
}
.brand, .topnav { pointer-events: auto; }
/* iOS 26 floating glass pills */
.brand {
  display: flex; align-items: center; gap: 8px; cursor: pointer;
  height: var(--pill-h); padding: 0 16px; border-radius: 999px;
  background: var(--glass-strong);
  -webkit-backdrop-filter: blur(32px) saturate(200%); backdrop-filter: blur(32px) saturate(200%);
  border: 1px solid var(--hair); box-shadow: 0 8px 28px rgba(0,0,0,0.5), inset 0 1px 0 rgba(255,255,255,0.08);
}
.brand-spark { width: 17px; height: 17px; flex: none; fill: var(--blue-2); }
.brand-name { font-size: 17px; font-weight: 300; letter-spacing: 0.01em; color: var(--label); }
.workflows {
  display: inline-flex; align-items: center; gap: 6px; cursor: pointer;
  font-size: 12px; font-weight: 600; color: var(--label-2);
  background: none; border: none; padding: 0;
}
.workflows::before { content: ""; width: 1px; height: 13px; background: var(--hair); margin-right: 3px; }
.wf-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--green); box-shadow: 0 0 8px rgba(48,209,88,0.7); animation: blink 1.8s ease-in-out infinite; }
.workflows.paused .wf-dot { background: var(--amber); box-shadow: 0 0 8px rgba(255,159,10,0.6); animation: none; }
@keyframes blink { 0%,100% { opacity: 0.45; } 50% { opacity: 1; } }

.topnav {
  display: flex; align-items: center; gap: 2px; height: var(--pill-h); padding: 0 6px; border-radius: 999px;
  background: var(--glass-strong);
  -webkit-backdrop-filter: blur(32px) saturate(200%); backdrop-filter: blur(32px) saturate(200%);
  border: 1px solid var(--hair); box-shadow: 0 8px 28px rgba(0,0,0,0.5), inset 0 1px 0 rgba(255,255,255,0.08);
}
.nav-ic {
  position: relative;
  display: grid; place-items: center; width: 34px; height: 34px; border-radius: 50%;
  background: transparent; border: none; cursor: pointer; color: var(--label-2);
  transition: color 0.18s ease, background 0.18s ease, transform 0.1s ease;
}
/* unseen-activity dot + blink on new activity in a section */
.nav-ic.has-activity::after {
  content: ''; position: absolute; top: 3px; right: 3px; width: 7px; height: 7px; border-radius: 50%;
  background: var(--blue); box-shadow: 0 0 6px rgba(10,132,255,0.9);
}
.nav-ic.pulse { animation: navpulse 0.9s ease; }
@keyframes navpulse {
  0%   { transform: scale(1); color: var(--label-2); }
  35%  { transform: scale(1.22); color: var(--blue); filter: drop-shadow(0 0 6px rgba(10,132,255,0.8)); }
  100% { transform: scale(1); }
}
.nav-ic svg { width: 21px; height: 21px; fill: currentColor; }
.nav-ic:active { transform: scale(0.92); }
.nav-ic.active { color: var(--blue); background: rgba(10, 132, 255, 0.14); }

/* ============ Avatars (image + initials fallback) ============ */
.avatar {
  flex: none; position: relative; overflow: hidden; display: grid; place-items: center; border-radius: 50%;
  font-weight: 700; color: #fff; letter-spacing: -0.02em;
  background: linear-gradient(145deg, #3a3a3c, #1c1c1e); border: 1px solid var(--hair);
}
.avatar.sm { width: 32px; height: 32px; font-size: 12px; }
.avatar.md { width: 40px; height: 40px; font-size: 14px; }
.avatar.lg { width: 48px; height: 48px; font-size: 16px; }
.avatar.is-hub { background: linear-gradient(145deg, #0a84ff, #0060df); border-color: rgba(64,156,255,0.6); }
.avatar-img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.avatar-ini { position: relative; z-index: 0; }

/* ============ Messages / iMessage bubbles ============ */
.messages {
  flex: 1; min-height: 0; overflow-y: auto; padding: 12px 14px 6px;
  display: flex; flex-direction: column; gap: 3px; scroll-behavior: smooth;
}
#prime-messages { padding-top: var(--top-space); } /* clear the floating top pills */
/* Anchor the conversation to the bottom: the last bubble sits just above the composer (WhatsApp/Telegram style) */
.messages::before { content: ''; flex: 1 1 0; min-height: 0; }
.msg-sep { text-align: center; margin: 14px 0 8px; }
.msg-sep span { font-size: 11px; font-weight: 600; color: var(--label-3); background: var(--card); padding: 4px 10px; border-radius: 999px; }
.row { display: flex; align-items: flex-end; gap: 7px; margin-top: 2px; animation: pop 0.26s cubic-bezier(0.22,1,0.36,1); }
.row.right { justify-content: flex-end; }
.row.left { justify-content: flex-start; }
@keyframes pop { from { opacity: 0; transform: translateY(6px) scale(0.98); } to { opacity: 1; transform: none; } }
.bubble { max-width: 78%; padding: 8px 13px; border-radius: 20px; font-size: 15.5px; line-height: 1.35; word-wrap: break-word; white-space: pre-wrap; }
.row.left .bubble { background: var(--bubble-in); color: var(--label); border-bottom-left-radius: 7px; }
.row.right .bubble { background: var(--bubble-out); color: #fff; border-bottom-right-radius: 7px; box-shadow: 0 1px 10px rgba(10,132,255,0.28); }
.bubble.has-img { padding: 5px; max-width: 80%; }
.bubble-img { display: block; width: 100%; max-width: 320px; border-radius: 15px; }
.bubble-cap { padding: 6px 8px 2px; font-size: 14px; line-height: 1.3; }
.bubble-sender { font-size: 11.5px; font-weight: 700; color: var(--blue-2); margin-bottom: 2px; }
.row.right .bubble-sender { color: rgba(255,255,255,0.85); }
.bubble-meta { display: block; font-size: 10px; margin-top: 3px; opacity: 0.55; text-align: right; }
/* Prime chat: full-width bubbles (assistant style) */
#prime-messages .row { width: 100%; }
#prime-messages .bubble { max-width: 100%; width: 100%; }
.empty { margin: auto; text-align: center; color: var(--label-3); padding: 40px 24px; font-size: 14px; }
.empty-ico { font-size: 30px; margin-bottom: 10px; opacity: 0.7; }

/* ============ Question bubble (PRIME) ============ */
.q-bubble {
  align-self: flex-start; max-width: 88%; margin: 8px 0 4px;
  background: var(--glass-strong); -webkit-backdrop-filter: blur(24px) saturate(180%); backdrop-filter: blur(24px) saturate(180%);
  border: 1px solid rgba(64,156,255,0.4); border-radius: 20px; padding: 13px 14px; box-shadow: 0 6px 28px rgba(0,0,0,0.4);
}
.q-tag { font-size: 11px; font-weight: 700; color: var(--blue-2); letter-spacing: 0.04em; margin-bottom: 6px; }
.q-prompt { font-size: 15px; line-height: 1.4; margin-bottom: 10px; white-space: pre-wrap; }
.q-chips { display: flex; flex-wrap: wrap; gap: 7px; margin-bottom: 8px; }
.q-chip { font: inherit; font-size: 13.5px; font-weight: 600; cursor: pointer; padding: 7px 13px; border-radius: 999px; color: var(--blue); background: rgba(10,132,255,0.14); border: 1px solid rgba(10,132,255,0.32); transition: transform 0.1s ease, background 0.2s ease; }
.q-chip:hover { background: rgba(10,132,255,0.24); }
.q-chip:active { transform: scale(0.95); }
.q-free { display: flex; gap: 7px; }
.q-free input { flex: 1; font: inherit; font-size: 14px; color: var(--label); background: rgba(118,118,128,0.18); border: 1px solid var(--hair); border-radius: 999px; padding: 9px 14px; outline: none; }
.q-free input::placeholder { color: var(--label-3); }
.q-free button { font: inherit; font-weight: 600; font-size: 14px; color: #fff; cursor: pointer; background: var(--blue); border: none; border-radius: 999px; padding: 9px 16px; }
.q-answered { font-size: 12.5px; color: var(--green); margin-top: 4px; }

/* ============ Composer ============ */
.composer { flex: none; display: flex; align-items: center; gap: 8px; padding: 8px 14px var(--bottom-space); }
.composer-form { flex: 1; display: flex; align-items: center; background: var(--glass-strong); -webkit-backdrop-filter: blur(24px) saturate(180%); backdrop-filter: blur(24px) saturate(180%); border: 1px solid var(--hair); border-radius: 999px; padding: 4px 6px; }
.composer-input { flex: 1; font: inherit; font-size: 15.5px; color: var(--label); background: transparent; border: none; outline: none; padding: 9px 12px; }
.composer-input::placeholder { color: var(--label-3); }
.send-pill { flex: none; display: grid; place-items: center; width: 46px; height: 46px; border-radius: 50%; background: var(--blue); border: none; color: #fff; cursor: pointer; transition: transform 0.12s ease; box-shadow: 0 6px 22px rgba(10,132,255,0.4); }
.send-pill:active { transform: scale(0.9); }
.send-pill .ic { width: 20px; height: 20px; fill: currentColor; }
.ic { width: 19px; height: 19px; fill: currentColor; }
.glass-btn { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; background: var(--glass-strong); border: 1px solid var(--hair); color: var(--label); cursor: pointer; }
.glass-btn:active { transform: scale(0.92); }

/* ============ Agents — list ============ */
.conv-list { flex: 1; min-height: 0; overflow-y: auto; padding: var(--top-space) 10px var(--bottom-space); }
.conv { display: flex; align-items: center; gap: 12px; padding: 11px 12px; border-radius: 18px; cursor: pointer; transition: background 0.18s ease, transform 0.1s ease; }
.conv:hover { background: rgba(255,255,255,0.04); }
.conv:active { transform: scale(0.99); }
.conv.pinned { background: rgba(10,132,255,0.08); border: 1px solid rgba(10,132,255,0.22); margin-bottom: 4px; }
.conv-main { flex: 1; min-width: 0; }
.conv-toprow { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.conv-name { font-size: 15.5px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conv-time { font-size: 11.5px; color: var(--label-3); flex: none; }
.conv-botrow { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 2px; }
.conv-preview { font-size: 13.5px; color: var(--label-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }
.conv-right { display: flex; align-items: center; gap: 6px; flex: none; }
.unread-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--blue); box-shadow: 0 0 8px rgba(10,132,255,0.8); }
.live-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--green); box-shadow: 0 0 8px rgba(48,209,88,0.85); animation: blink 1.1s ease-in-out infinite; }
@keyframes convflash { 0% { background: rgba(10,132,255,0.26); } 100% { background: transparent; } }
.conv.flash { animation: convflash 1.4s ease-out; }

/* ============ Agents — observation chat ============ */
.chat-header { display: flex; align-items: center; gap: 10px; padding: var(--top-space) 16px 10px; background: var(--glass); -webkit-backdrop-filter: blur(24px) saturate(180%); backdrop-filter: blur(24px) saturate(180%); border-bottom: 1px solid var(--hair-soft); flex: none; }
.chat-id { flex: 1; min-width: 0; }
.chat-name { font-size: 15.5px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-purpose { font-size: 11.5px; color: var(--label-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.observation { flex: none; text-align: center; font-size: 12px; color: var(--label-3); padding: 12px; padding-bottom: var(--bottom-space); display: flex; align-items: center; justify-content: center; gap: 8px; }
.obs-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--amber); animation: blink 2s ease-in-out infinite; }

/* tier badges */
.tier { font-size: 10.5px; font-weight: 700; letter-spacing: 0.02em; padding: 3px 8px; border-radius: 999px; text-transform: lowercase; }
.tier-team { color: var(--green); background: rgba(48,209,88,0.14); }
.tier-biz { color: var(--amber); background: rgba(255,159,10,0.14); }
.tier-ext { color: var(--red); background: rgba(255,69,58,0.14); }

/* ============ Updates — Instagram-style feed ============ */
.feed { flex: 1; min-height: 0; overflow-y: auto; padding-top: var(--top-space); padding-bottom: var(--bottom-space); }
.ig-post { border-bottom: 1px solid var(--hair-soft); padding-bottom: 8px; animation: pop 0.3s cubic-bezier(0.22,1,0.36,1); }
.ig-head { display: flex; align-items: center; gap: 10px; padding: 11px 14px; }
.ig-hmid { flex: 1; min-width: 0; }
.ig-name { font-size: 14px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ig-loc { font-size: 12px; color: var(--label-2); text-transform: lowercase; }
.ig-time { font-size: 12px; color: var(--label-3); flex: none; }
.ig-media { position: relative; aspect-ratio: 1 / 1; display: flex; align-items: center; justify-content: center; padding: 30px 24px; text-align: center; overflow: hidden; }
.ig-media::after { content: ''; position: absolute; inset: 0; background: radial-gradient(120% 80% at 50% 0%, rgba(255,255,255,0.18), transparent 60%); pointer-events: none; }
.ig-media.ft-update { background: linear-gradient(140deg, #0a84ff, #5e5ce6); }
.ig-media.ft-deal { background: linear-gradient(140deg, #30d158, #0a9e6a); }
.ig-media.ft-milestone { background: linear-gradient(140deg, #5e5ce6, #bf5af2); }
.ig-media.ft-delivery { background: linear-gradient(140deg, #ff375f, #ff9f0a); }
.ig-essence { position: relative; z-index: 1; color: #fff; font-size: 20px; font-weight: 700; line-height: 1.32; letter-spacing: -0.01em; text-shadow: 0 1px 16px rgba(0,0,0,0.25); display: -webkit-box; -webkit-line-clamp: 6; -webkit-box-orient: vertical; overflow: hidden; }
.ig-type { position: absolute; z-index: 2; top: 12px; left: 12px; font-size: 10.5px; font-weight: 800; letter-spacing: 0.05em; text-transform: uppercase; color: #fff; background: rgba(0,0,0,0.26); padding: 4px 10px; border-radius: 999px; -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px); }
.ig-actions { display: flex; align-items: center; gap: 16px; padding: 12px 14px 2px; color: var(--label); }
.ig-ic { width: 25px; height: 25px; fill: none; transition: transform 0.1s ease; }
.ig-actions .ig-ic:active { transform: scale(0.85); }
.ig-spacer { flex: 1; }

/* ============ Settings (metrics + controls) ============ */
.settings { flex: 1; min-height: 0; overflow-y: auto; padding: var(--top-space) 16px var(--bottom-space); }
.set-section-title { font-size: 12px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--label-3); margin: 6px 4px 10px; }
.set-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; background: var(--glass); border: 1px solid var(--hair); border-radius: 16px; padding: 14px 16px; margin-bottom: 12px; -webkit-backdrop-filter: blur(20px) saturate(180%); backdrop-filter: blur(20px) saturate(180%); }
.set-row .set-label, .conn-mid .set-label { font-size: 15px; font-weight: 600; }
.set-row .set-sub, .conn-mid .set-sub { font-size: 12px; color: var(--label-2); margin-top: 2px; }
.set-intro { font-size: 13px; color: var(--label-2); line-height: 1.4; margin: 0 4px 14px; }
.conn-row { display: flex; align-items: center; gap: 12px; background: var(--glass); border: 1px solid var(--hair); border-radius: 16px; padding: 12px 14px; margin-bottom: 10px; -webkit-backdrop-filter: blur(20px) saturate(180%); backdrop-filter: blur(20px) saturate(180%); }
.conn-ico { flex: none; width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center; font-size: 21px; background: rgba(118,118,128,0.18); border: 1px solid var(--hair); }
.conn-mid { flex: 1; min-width: 0; }
.conn-btn { flex: none; font: inherit; font-size: 13.5px; font-weight: 600; cursor: pointer; padding: 8px 16px; border-radius: 999px; color: var(--blue); background: rgba(10,132,255,0.14); border: 1px solid rgba(10,132,255,0.4); transition: transform 0.1s ease; }
.conn-btn:active { transform: scale(0.95); }
.conn-btn.on { color: var(--green); background: rgba(48,209,88,0.14); border-color: rgba(48,209,88,0.4); }
.switch { position: relative; width: 52px; height: 31px; border-radius: 999px; background: rgba(118,118,128,0.32); border: none; cursor: pointer; transition: background 0.2s ease; flex: none; }
.switch::after { content: ""; position: absolute; top: 2px; left: 2px; width: 27px; height: 27px; border-radius: 50%; background: #fff; transition: transform 0.2s cubic-bezier(0.22,1,0.36,1); box-shadow: 0 1px 4px rgba(0,0,0,0.4); }
.switch.on { background: var(--green); }
.switch.on::after { transform: translateX(21px); }
.metric-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 12px; }
.metric { background: var(--glass); -webkit-backdrop-filter: blur(20px) saturate(180%); backdrop-filter: blur(20px) saturate(180%); border: 1px solid var(--hair); border-radius: 16px; padding: 13px; }
.metric-num { font-size: 24px; font-weight: 800; letter-spacing: -0.03em; }
.metric-num.accent { color: var(--blue-2); }
.metric-lbl { font-size: 11px; color: var(--label-2); margin-top: 3px; line-height: 1.25; }
.chart-card { background: var(--glass); border: 1px solid var(--hair); border-radius: 18px; padding: 16px; -webkit-backdrop-filter: blur(20px) saturate(180%); backdrop-filter: blur(20px) saturate(180%); }
.chart-title { font-size: 15px; font-weight: 700; }
.chart-sub { font-size: 12px; color: var(--label-2); margin: 3px 0 14px; line-height: 1.35; }
.chart { display: flex; align-items: flex-end; gap: 6px; height: 120px; overflow: hidden; }
.chart-col { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; }
.chart-x { overflow: hidden; }
.chart-bars { flex: 1; width: 100%; display: flex; align-items: flex-end; justify-content: center; gap: 3px; }
.bar { width: 7px; border-radius: 4px 4px 2px 2px; min-height: 2px; transition: height 0.5s cubic-bezier(0.22,1,0.36,1); }
.bar.msg { background: rgba(118,118,128,0.5); }
.bar.q { background: var(--green); box-shadow: 0 0 8px rgba(48,209,88,0.5); }
.chart-x { font-size: 9px; color: var(--label-3); }
.chart-legend { display: flex; gap: 16px; margin-top: 12px; }
.legend-key { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--label-2); }
.legend-swatch { width: 11px; height: 11px; border-radius: 3px; }
.legend-swatch.msg { background: rgba(118,118,128,0.5); }
.legend-swatch.q { background: var(--green); }

/* ============ Toasts ============ */
.toasts { position: fixed; z-index: 40; left: 50%; transform: translateX(-50%); bottom: calc(env(safe-area-inset-bottom, 0px) + 18px); display: flex; flex-direction: column; gap: 8px; width: min(540px, calc(100% - 28px)); pointer-events: none; }
.toast { align-self: center; max-width: 100%; background: var(--glass-strong); -webkit-backdrop-filter: blur(28px) saturate(200%); backdrop-filter: blur(28px) saturate(200%); border: 1px solid var(--hair); border-radius: 16px; padding: 11px 15px; font-size: 13.5px; color: var(--label); display: flex; align-items: center; gap: 9px; box-shadow: 0 8px 30px rgba(0,0,0,0.5); animation: toastin 0.3s cubic-bezier(0.22,1,0.36,1); }
.toast.out { animation: toastout 0.3s ease forwards; }
.toast-ico { font-size: 16px; }
@keyframes toastin { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
@keyframes toastout { to { opacity: 0; transform: translateY(12px); } }
