/* ─── Design tokens ─── */
:root {
  --bg: #0b1120;
  --bg-soft: rgba(15, 23, 42, 0.84);
  --panel: rgba(15, 23, 42, 0.96);
  --panel-strong: rgba(17, 24, 39, 0.98);
  --line: rgba(148, 163, 184, 0.12);
  --line-strong: rgba(148, 163, 184, 0.22);
  --text: #f1ece4;
  --muted: #8b9cb7;
  --muted-strong: #bcc8db;
  --accent: #38bdf8;
  --accent-soft: #34d399;
  --accent-alt: #f5deb3;
  --success: #34d399;
  --danger: #fb7185;
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.38);
  --shadow-sm: 0 4px 24px rgba(0, 0, 0, 0.26);
  --radius-xl: 28px;
  --radius-lg: 22px;
  --radius-md: 16px;
  --radius-sm: 12px;
  --font-body: "Inter", "DM Sans", -apple-system, "Segoe UI", sans-serif;
  --font-display: "Plus Jakarta Sans", "DM Sans", -apple-system, "Segoe UI", sans-serif;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  color-scheme: dark;
}

/* ─── Reset ─── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  position: relative;
}

h1, h2, h3, h4, p { margin: 0; }
h1, h2, h3, h4 { font-family: var(--font-display); font-weight: 700; }
h1 { font-size: 1.15rem; }

button, input, textarea { font: inherit; color: inherit; }
button { border: 0; cursor: pointer; appearance: none; -webkit-appearance: none; }
img { max-width: 100%; display: block; }

/* ─── Ambient background ─── */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.03), transparent 30%),
    radial-gradient(circle at top, rgba(255, 255, 255, 0.05), transparent 50%);
  opacity: 0.7;
  pointer-events: none;
  z-index: 0;
}

.ambient {
  position: fixed;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.35;
  pointer-events: none;
  z-index: 0;
}

.ambient-a { width: 30rem; height: 30rem; top: -8rem; left: -6rem; background: radial-gradient(circle, rgba(56, 189, 248, 0.7), transparent); }
.ambient-b { width: 24rem; height: 24rem; right: -10rem; top: 10rem; background: radial-gradient(circle, rgba(245, 222, 179, 0.6), transparent); }
.ambient-c { width: 26rem; height: 26rem; bottom: -12rem; right: 16rem; background: radial-gradient(circle, rgba(52, 211, 153, 0.5), transparent); }

/* ═══════════════════════════════════════════
   APP SHELL – always single column
   ═══════════════════════════════════════════ */
.app-shell {
  display: flex;
  height: 100vh;
  height: 100dvh;
  position: relative;
}

/* ─── Drawers (sidebar + inspector) always overlay ─── */
.drawer {
  position: fixed;
  top: 0;
  bottom: 0;
  z-index: 30;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 1rem;
  padding-top: calc(1rem + var(--safe-top));
  padding-bottom: calc(1rem + var(--safe-bottom));
  background: var(--panel-strong);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  transition: transform 280ms cubic-bezier(0.4, 0, 0.2, 1);
}

.sidebar.drawer {
  left: 0;
  width: min(88vw, 340px);
  border-radius: 0 var(--radius-xl) var(--radius-xl) 0;
  transform: translateX(-105%);
}

/* ─── Inspector modal (expands from FAB) ─── */
.inspector {
  position: fixed;
  z-index: 30;
  bottom: calc(6.2rem + var(--safe-bottom));
  right: calc(1.2rem + var(--safe-right));
  width: min(92vw, 400px);
  max-height: min(80vh, 640px);
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 1rem;
  background: var(--panel-strong);
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow);
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  transform: scale(0);
  transform-origin: bottom right;
  opacity: 0;
  pointer-events: none;
  transition: transform 280ms cubic-bezier(0.34, 1.56, 0.64, 1), opacity 180ms ease;
}

.inspector.open {
  transform: scale(1);
  opacity: 1;
  pointer-events: auto;
}

.drawer.open {
  transform: translateX(0);
}

/* ─── Sidebar header ─── */
.sidebar-header {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  flex-shrink: 0;
  padding-bottom: 0.65rem;
  border-bottom: 1px solid var(--line);
}

.brand-row {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.brand-text { flex: 1; min-width: 0; }

.brand-mark {
  width: 2.5rem;
  height: 2.5rem;
  flex-shrink: 0;
  display: grid;
  place-items: center;
  border-radius: 12px;
  background:
    radial-gradient(circle at 30% 30%, rgba(255, 255, 255, 0.28), transparent 35%),
    linear-gradient(135deg, var(--accent), var(--accent-soft));
  color: #0b1120;
  font-weight: 800;
  font-size: 0.85rem;
  letter-spacing: 0.08em;
}

.eyebrow {
  margin: 0;
  font-size: 0.68rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 600;
}

/* ─── Collapsible nav sections ─── */
.nav-section {
  flex-shrink: 0;
}

.nav-section-toggle {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  padding: 0.6rem 0.25rem;
  background: transparent;
  color: var(--muted-strong);
  font-size: 0.82rem;
  font-weight: 600;
  text-align: left;
  border-bottom: 1px solid transparent;
}

.nav-section-toggle .nav-chevron {
  flex-shrink: 0;
  transition: transform 200ms ease;
  color: var(--muted);
}

.nav-section-toggle[aria-expanded="false"] .nav-chevron {
  transform: rotate(-90deg);
}

.nav-section-toggle > span:first-of-type {
  flex: 1;
}

.nav-badge {
  min-width: 1.5rem;
  height: 1.2rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 0.35rem;
  border-radius: 999px;
  background: rgba(56, 189, 248, 0.18);
  color: var(--accent);
  font-size: 0.7rem;
  font-weight: 700;
}

.nav-action {
  margin-left: auto;
  font-size: 0.75rem;
}

.nav-section-body {
  display: none;
  padding: 0.4rem 0 0.2rem;
}

.nav-section-body.open {
  display: block;
}

/* History nav section — stretches to fill remaining sidebar space */
#navRecentChats {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

#navRecentChats .nav-section-body {
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

#navRecentChats .nav-section-body.open {
  display: flex;
  flex-direction: column;
}

/* ── History list ── */
.history-list {
  overflow-y: auto;
  overscroll-behavior: contain;
  min-height: 0;
  flex: 1;
  padding-bottom: 4px;
}

/* Group block: Today / Yesterday / Previous 7 Days */
.history-group {
  margin-bottom: 4px;
}

.history-group-label {
  padding: 0.55rem 0.4rem 0.3rem;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--muted);
  user-select: none;
}

.history-group-items {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

/* Individual chat row */
.history-item {
  display: flex;
  align-items: center;
  gap: 0;
  width: 100%;
  border-radius: 8px;
  border: 1px solid transparent;
  background: transparent;
  cursor: pointer;
  transition: background 140ms ease;
  min-height: 2.4rem;
}

.history-item:hover {
  background: rgba(255, 255, 255, 0.05);
}

.history-item.active {
  background: rgba(255, 255, 255, 0.07);
  border-color: rgba(255, 255, 255, 0.06);
}

.history-item.active .history-item-title {
  color: var(--accent);
}

.history-item.active .history-item-icon {
  color: var(--accent);
}

/* The clickable body (icon + title) */
.history-item-body {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.38rem 0.5rem;
  background: transparent;
  border: none;
  color: inherit;
  cursor: pointer;
  text-align: left;
  border-radius: 8px;
  min-height: 2.4rem;
}

.history-item-icon {
  flex-shrink: 0;
  width: 1.1rem;
  height: 1.1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  opacity: 0.7;
  transition: opacity 140ms ease;
}

.history-item:hover  .history-item-icon,
.history-item.active .history-item-icon { opacity: 1; }

.history-item-title {
  font-size: 0.88rem;
  line-height: 1.3;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  min-width: 0;
}

/* Delete button — appears on hover / touch */
.history-delete {
  flex-shrink: 0;
  width: 1.6rem;
  height: 1.6rem;
  border-radius: 6px;
  border: none;
  background: transparent;
  color: var(--muted);
  display: grid;
  place-items: center;
  opacity: 0;
  transition: opacity 130ms ease, color 130ms ease, background 130ms ease;
  cursor: pointer;
  margin-right: 4px;
}

.history-item:hover .history-delete,
.history-item:focus-within .history-delete { opacity: 1; }

.history-delete:hover {
  color: var(--danger);
  background: rgba(251, 113, 133, 0.12);
}

@media (hover: none) { .history-delete { opacity: 1; } }

/* Load-more sentinel */
.history-sentinel {
  height: 1px;
  pointer-events: none;
}

/* "Loading more…" indicator */
.history-loading-more {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 0;
  color: var(--muted);
  font-size: 0.78rem;
}

.history-loading-more::before {
  content: '';
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 1.5px solid var(--muted);
  border-top-color: var(--accent);
  animation: spin 0.7s linear infinite;
  flex-shrink: 0;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* Footer row (Clear all) */
.history-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.4rem;
  padding-top: 0.4rem;
  border-top: 1px solid var(--line);
  flex-shrink: 0;
}

.clear-all-btn {
  padding: 0;
  background: transparent;
  border: none;
  color: var(--muted);
  font-size: 0.72rem;
  cursor: pointer;
}
.clear-all-btn:hover { color: var(--danger); }

/* Hide the old pager — replaced by infinite scroll */
.history-pager { display: none; }
.history-pager-btn { display: none; }
.history-pager-label { display: none; }

/* Nav link (Control panel) */
.nav-section-link {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  padding: 0.6rem 0.25rem;
  color: var(--muted-strong);
  font-size: 0.82rem;
  font-weight: 600;
  text-decoration: none;
  border-radius: 8px;
  transition: background 160ms ease, color 160ms ease;
}
.nav-section-link:hover { color: var(--text); background: rgba(255, 255, 255, 0.05); }
.nav-button-link { text-align: left; }
.nav-link-icon { flex-shrink: 0; color: var(--accent); }
.nav-section-link > span:first-of-type { flex: 1; }
.nav-link-arrow { flex-shrink: 0; color: var(--muted); }
.nav-sub-link {
  display: inline-flex;
  margin-left: 2rem;
  margin-top: 0.15rem;
  color: var(--muted);
  font-size: 0.74rem;
  text-decoration: none;
}
.nav-sub-link:hover { color: var(--text); }

/* Profile nav body */
#navProfile .nav-section-body {
  display: none;
  padding: 0.5rem 0;
}
#navProfile .nav-section-body.open {
  display: grid;
  gap: 0.5rem;
}

.field { display: grid; gap: 0.3rem; color: var(--muted); font-size: 0.82rem; }
.field span { font-weight: 600; }
.field input,
.field select,
.field textarea {
  width: 100%;
  min-height: 2.5rem;
  padding: 0.55rem 0.75rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.3);
  color: var(--text);
  font-size: 0.88rem;
  outline: none;
  transition: border-color 160ms ease;
}
.field textarea {
  min-height: 4.8rem;
  resize: vertical;
}
.field input:focus,
.field select:focus,
.field textarea:focus { border-color: rgba(56, 189, 248, 0.45); }
.field select option,
select option {
  background: #111827;
  color: var(--text);
}
.field select,
.agent-multi-select {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12' fill='none'%3E%3Cpath d='M3 4.5l3 3 3-3' stroke='%238b9cb7' stroke-width='1.4' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.6rem center;
  padding-right: 2rem;
}
.agent-multi-select {
  background-image: none;
  padding-right: 0.75rem;
}
.compact-field span { font-size: 0.74rem; }

/* ─── Prompt grid ─── */
.prompt-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.4rem;
}

.prompt-card {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  padding: 0.65rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.03);
  min-height: 5rem;
  text-align: left;
  cursor: pointer;
}

.prompt-card strong { font-size: 0.82rem; line-height: 1.2; color: var(--text); display: block; }
.prompt-card span { color: var(--muted); font-size: 0.75rem; line-height: 1.35; display: block; }
.prompt-card em { margin-top: auto; color: var(--muted); font-style: normal; font-size: 0.72rem; opacity: 0.6; display: block; }

/* ─── Glass card base ─── */
.glass-card {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.06), rgba(255, 255, 255, 0.02));
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

/* ═══════════════════════════════════════════
   CHAT STAGE – full width always
   ═══════════════════════════════════════════ */
.chat-stage {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  padding: 0.75rem;
  padding-top: calc(0.75rem + var(--safe-top));
  padding-bottom: calc(0.75rem + var(--safe-bottom));
  padding-left: calc(0.75rem + var(--safe-left));
  padding-right: calc(0.75rem + var(--safe-right));
}

/* ─── Topbar ─── */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.65rem;
  padding: 0.65rem 0.85rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.04), rgba(255, 255, 255, 0.02));
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  box-shadow: var(--shadow-sm);
  flex-shrink: 0;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  min-width: 0;
  flex: 1;
}

.topbar-info { min-width: 0; flex: 1; }

.topbar h2 {
  font-size: clamp(0.95rem, 2vw, 1.3rem);
  margin-top: 0.1rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.topbar-action-button {
  min-width: 0;
  padding-inline: 0.8rem;
}

.topbar-action-button.is-disabled,
.topbar-action-button:disabled {
  opacity: 0.5;
  cursor: default;
}

.status-pill {
  min-height: 2rem;
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.04);
  padding: 0 0.75rem;
  color: var(--muted-strong);
  font-size: 0.78rem;
  white-space: nowrap;
}

/* ─── Welcome state ─── */
.welcome-state {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  flex-shrink: 0;
}

.welcome-card {
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(120px, 0.7fr);
  align-items: center;
  gap: 1rem;
  padding: 1rem;
  overflow: hidden;
  background:
    radial-gradient(circle at 70% 30%, rgba(245, 222, 179, 0.18), transparent 36%),
    radial-gradient(circle at 30% 0%, rgba(56, 189, 248, 0.14), transparent 40%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0.02));
}

.welcome-copy h3 { margin-top: 0.25rem; font-size: clamp(1.15rem, 2.5vw, 1.8rem); line-height: 1.1; }
.welcome-copy p:last-child { margin-top: 0.5rem; color: var(--muted-strong); line-height: 1.5; font-size: 0.88rem; }

.orb-cluster { display: grid; place-items: center; min-height: 140px; }

.orb-shell {
  position: relative;
  width: min(12rem, 36vw);
  aspect-ratio: 1;
  border-radius: 42% 58% 61% 39% / 43% 40% 60% 57%;
  background:
    radial-gradient(circle at 20% 20%, rgba(255, 255, 255, 0.34), transparent 25%),
    radial-gradient(circle at 80% 80%, rgba(56, 189, 248, 0.66), transparent 34%),
    linear-gradient(135deg, rgba(52, 211, 153, 0.22), rgba(245, 222, 179, 0.18));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08), 0 0 40px rgba(56, 189, 248, 0.26);
  animation: float-orb 7.5s ease-in-out infinite;
}

.orb-core, .orb-ring { position: absolute; inset: 12%; border-radius: 45% 55% 37% 63% / 56% 39% 61% 44%; }
.orb-core {
  background:
    radial-gradient(circle, rgba(255, 255, 255, 0.22), transparent 35%),
    repeating-radial-gradient(circle at center, rgba(255, 255, 255, 0.16) 0 1px, transparent 2px 5px),
    radial-gradient(circle at 72% 28%, rgba(56, 189, 248, 0.7), transparent 35%),
    rgba(11, 17, 32, 0.75);
  filter: blur(0.2px);
}
.orb-ring { inset: -8%; border: 1px solid rgba(255, 255, 255, 0.12); opacity: 0.8; }

.suggestion-showcase {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.55rem;
}

.showcase-card {
  min-height: 7rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 0.3rem;
  padding: 0.8rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.03);
  text-align: left;
  cursor: pointer;
}

.showcase-card strong { font-size: 0.88rem; line-height: 1.25; color: var(--text); display: block; }
.showcase-card span { color: var(--muted); font-size: 0.8rem; line-height: 1.4; display: block; }
.showcase-card em { margin-top: auto; color: var(--muted); font-style: normal; font-size: 0.75rem; opacity: 0.6; display: block; }

/* ─── Message scroll ─── */
.message-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  padding-right: 0.1rem;
  scroll-padding-bottom: 10rem;
}

.message-list { display: grid; gap: 0.8rem; padding-bottom: 0.5rem; }

.message {
  display: grid;
  grid-template-columns: 2.2rem minmax(0, 1fr);
  gap: 0.6rem;
  align-items: start;
}

.message.user { grid-template-columns: minmax(0, 1fr) 2.2rem; }
.message.user .avatar { order: 2; }
.message.user .bubble-stack { order: 1; justify-items: end; }

.avatar {
  width: 2.2rem;
  height: 2.2rem;
  border-radius: 12px;
  flex-shrink: 0;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.14), rgba(255, 255, 255, 0.02)),
    linear-gradient(135deg, var(--accent), var(--accent-soft));
  box-shadow: 0 6px 16px rgba(56, 189, 248, 0.15);
}

.message.assistant .avatar {
  background:
    radial-gradient(circle at 30% 30%, rgba(255, 255, 255, 0.3), transparent 30%),
    linear-gradient(135deg, var(--accent-alt), var(--accent));
}

.bubble-stack { display: grid; gap: 0.3rem; }
.bubble-meta { display: flex; align-items: center; gap: 0.5rem; padding-inline: 0.15rem; color: var(--muted); font-size: 0.72rem; }

.bubble {
  max-width: min(100%, 44rem);
  padding: 0.75rem 0.9rem;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.04);
  line-height: 1.6;
  font-size: 0.9rem;
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.bubble a {
  color: var(--muted-strong);
  text-decoration: underline;
}

.rich-message {
  display: grid;
  gap: 0.8rem;
}

.message-heading {
  font-size: 0.95rem;
  line-height: 1.35;
  color: var(--text);
}

.message-paragraph {
  margin: 0;
  color: inherit;
}

.message-list-block {
  margin: 0;
  padding-left: 1.1rem;
  display: grid;
  gap: 0.35rem;
}

.message-list-block.ordered {
  padding-left: 1.2rem;
}

.inline-code {
  display: inline-flex;
  align-items: center;
  padding: 0.08rem 0.38rem;
  border-radius: 8px;
  background: rgba(15, 23, 42, 0.88);
  border: 1px solid rgba(148, 163, 184, 0.2);
  color: #c7f0ff;
  font-size: 0.82em;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.code-block {
  border: 1px solid rgba(148, 163, 184, 0.18);
  background: rgba(2, 6, 23, 0.86);
  border-radius: 16px;
  overflow: hidden;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.03);
}

.code-block-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.55rem 0.75rem;
  border-bottom: 1px solid rgba(148, 163, 184, 0.14);
  background: rgba(255, 255, 255, 0.03);
}

.code-language {
  color: var(--muted);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 700;
}

.copy-code-button {
  min-height: 1.8rem;
  padding: 0 0.65rem;
  border-radius: 999px;
  border: 1px solid rgba(148, 163, 184, 0.18);
  background: rgba(255, 255, 255, 0.04);
  color: var(--muted-strong);
  font-size: 0.74rem;
  font-weight: 700;
}

.code-block pre {
  margin: 0;
  padding: 0.85rem 0.95rem 1rem;
  overflow-x: auto;
}

.code-block code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.82rem;
  line-height: 1.65;
  white-space: pre;
  color: #e5edf8;
}

.route-card {
  display: grid;
  gap: 0.8rem;
}

.route-card-head {
  display: grid;
  gap: 0.15rem;
}

.route-card-head h4 {
  font-size: 0.98rem;
  line-height: 1.3;
  color: var(--text);
}

.route-card-head p {
  color: var(--muted);
  font-size: 0.78rem;
}

.route-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.route-pill {
  display: inline-flex;
  align-items: center;
  min-height: 1.7rem;
  padding: 0 0.7rem;
  border-radius: 999px;
  background: rgba(56, 189, 248, 0.14);
  border: 1px solid rgba(56, 189, 248, 0.2);
  color: #a8ebff;
  font-size: 0.76rem;
  font-weight: 700;
}

.route-trail {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 0.7rem;
}

.route-step {
  display: grid;
  grid-template-columns: 1.9rem minmax(0, 1fr);
  gap: 0.65rem;
  align-items: start;
}

.route-step-index {
  width: 1.9rem;
  height: 1.9rem;
  border-radius: 999px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, rgba(56, 189, 248, 0.9), rgba(52, 211, 153, 0.9));
  color: #06111b;
  font-size: 0.8rem;
  font-weight: 800;
  box-shadow: 0 0 0 4px rgba(56, 189, 248, 0.1);
}

.route-step-copy {
  display: grid;
  gap: 0.35rem;
  padding: 0.65rem 0.75rem;
  border-radius: 14px;
  border: 1px solid rgba(148, 163, 184, 0.14);
  background: rgba(255, 255, 255, 0.03);
}

.route-step-copy .message-paragraph {
  margin: 0;
}

.route-notes {
  display: grid;
  gap: 0.35rem;
  padding-top: 0.2rem;
  border-top: 1px solid rgba(148, 163, 184, 0.14);
}

.route-notes strong {
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.route-notes p {
  margin: 0;
  color: var(--muted-strong);
  font-size: 0.78rem;
  line-height: 1.55;
}

.message.user .bubble {
  background: linear-gradient(135deg, rgba(56, 189, 248, 0.82), rgba(52, 211, 153, 0.92));
  color: #0b1424;
  border-color: rgba(255, 255, 255, 0.08);
  font-weight: 600;
  max-width: min(85%, 36rem);
}

.message.user .bubble a {
  color: #0b1424;
}

.message.user .inline-code {
  background: rgba(255, 255, 255, 0.22);
  border-color: rgba(11, 20, 36, 0.08);
  color: #0b1424;
}

.message.user .code-block {
  background: rgba(11, 20, 36, 0.14);
  border-color: rgba(11, 20, 36, 0.12);
}

.message.user .copy-code-button {
  color: #0b1424;
  border-color: rgba(11, 20, 36, 0.12);
  background: rgba(255, 255, 255, 0.22);
}

/* ─── Attachments ─── */
.attachment-stack { display: grid; gap: 0.5rem; }
.attachment-card { border: 1px solid var(--line); border-radius: var(--radius-md); padding: 0.6rem; background: rgba(255, 255, 255, 0.03); overflow: hidden; }
.attachment-card img { width: 100%; display: block; border-radius: var(--radius-sm); }
.attachment-card a { display: inline-flex; align-items: center; gap: 0.4rem; color: var(--muted-strong); text-decoration: none; font-size: 0.85rem; }
.attachment-card .attachment-label { color: var(--muted-strong); font-size: 0.85rem; line-height: 1.45; }

/* ─── Thinking animation ─── */
.thinking-bubble { display: inline-flex; align-items: center; gap: 0.3rem; padding: 0.2rem 0; }
.thinking-bubble span { width: 0.5rem; height: 0.5rem; border-radius: 999px; background: linear-gradient(135deg, var(--accent), var(--accent-soft)); animation: pulse-dots 1s infinite ease-in-out; }
.thinking-bubble span:nth-child(2) { animation-delay: 0.12s; }
.thinking-bubble span:nth-child(3) { animation-delay: 0.24s; }

/* ─── Composer ─── */
.composer-wrap {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  flex-shrink: 0;
  position: sticky;
  bottom: 0;
  z-index: 4;
  padding-top: 0.35rem;
  background: linear-gradient(180deg, rgba(11, 17, 32, 0), rgba(11, 17, 32, 0.92) 36%, rgba(11, 17, 32, 0.98));
}

.upload-tray { display: flex; gap: 0.5rem; overflow-x: auto; overflow-y: hidden; padding-bottom: 0.1rem; scrollbar-width: none; -ms-overflow-style: none; }
.upload-tray:empty { display: none; }
.upload-tray::-webkit-scrollbar { display: none; }

.upload-pill {
  min-width: 0;
  max-width: min(18rem, 80vw);
  display: grid;
  grid-template-columns: 2.8rem minmax(0, 1fr) auto;
  gap: 0.55rem;
  align-items: center;
  padding: 0.5rem 0.6rem;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.05);
  box-shadow: var(--shadow-sm);
  flex-shrink: 0;
}
.upload-pill.uploading { border-color: rgba(52, 211, 153, 0.4); }
.upload-pill.error { border-color: rgba(251, 113, 133, 0.45); }

.upload-thumb {
  width: 2.8rem; height: 2.8rem;
  border-radius: 12px;
  overflow: hidden;
  display: grid; place-items: center;
  background: radial-gradient(circle at 25% 25%, rgba(255, 255, 255, 0.18), transparent 35%), linear-gradient(135deg, rgba(56, 189, 248, 0.22), rgba(52, 211, 153, 0.18));
  border: 1px solid rgba(255, 255, 255, 0.07);
}
.upload-thumb img { width: 100%; height: 100%; object-fit: cover; }
.upload-thumb span { font-size: 0.7rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted-strong); }

.upload-meta { min-width: 0; display: grid; gap: 0.15rem; }
.upload-meta strong, .upload-meta span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.upload-meta strong { font-size: 0.82rem; color: var(--text); }
.upload-meta span { font-size: 0.72rem; color: var(--muted); }

.upload-remove {
  width: 1.8rem; height: 1.8rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.04);
  color: var(--muted-strong);
  display: grid; place-items: center;
  flex-shrink: 0;
  font-size: 0.8rem;
}
.upload-remove:disabled { opacity: 0.45; cursor: progress; }

.chip-row { display: flex; gap: 0.45rem; overflow-x: auto; overflow-y: hidden; padding-bottom: 0.1rem; scrollbar-width: none; -ms-overflow-style: none; }
.chip-row::-webkit-scrollbar { display: none; }

.chip {
  white-space: nowrap;
  min-height: 2rem;
  border-radius: 999px;
  padding: 0 0.8rem;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--line);
  color: var(--muted-strong);
  font-size: 0.8rem;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
}

.composer {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  padding: 0.75rem;
  position: relative;
}

.composer textarea {
  width: 100%;
  min-height: 2.6rem;
  max-height: 10rem;
  resize: none;
  padding: 0.2rem 0;
  border: 0;
  background: transparent;
  color: var(--text);
  outline: none;
  line-height: 1.5;
  font-size: 16px;
}
.composer textarea::placeholder { color: var(--muted); }

.composer-actions {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  justify-content: flex-end;
}

.composer-icon-btn {
  width: 2.3rem;
  height: 2.3rem;
  color: var(--muted-strong);
}

.composer-icon-btn svg { width: 16px; height: 16px; }

.send-button {
  min-width: 5rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
}

.send-button svg { flex-shrink: 0; }

/* ─── Inspector panel ─── */
.inspector-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.65rem;
  flex-shrink: 0;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--line);
}

.inspector-card { padding: 0.8rem; display: grid; gap: 0.6rem; flex-shrink: 0; }

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--muted);
  font-size: 0.82rem;
}
.section-heading h4 { font-size: 0.85rem; font-weight: 600; color: var(--muted-strong); }

.agent-list, .model-list, .action-stack { display: grid; gap: 0.45rem; }

.agent-card {
  display: grid;
  gap: 0.55rem;
  padding: 0.75rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.03);
}
.agent-card strong { font-size: 0.88rem; color: var(--text); display: block; }
.agent-card span { color: var(--muted); font-size: 0.78rem; display: block; margin-top: 0.15rem; }
.agent-head { display: grid; gap: 0.15rem; }
.agent-capability-line { color: var(--muted); font-size: 0.78rem; line-height: 1.45; }
.agent-model-summary { color: var(--muted-strong); font-size: 0.76rem; line-height: 1.45; }
.agent-model-editor {
  display: grid;
  gap: 0.55rem;
  padding-top: 0.35rem;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}
.agent-model-row {
  display: grid;
  gap: 0.55rem;
}
.agent-model-actions {
  display: flex;
  justify-content: flex-end;
}
.agent-multi-select {
  min-height: 7rem;
}

.agent-card .status-line {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  color: var(--muted-strong);
  font-size: 0.82rem;
}
.agent-card .status-line::before {
  content: "";
  width: 0.45rem; height: 0.45rem;
  border-radius: 999px;
  background: var(--success);
  box-shadow: 0 0 0 4px rgba(52, 211, 153, 0.14);
  flex-shrink: 0;
}
.agent-card.offline .status-line::before { background: var(--danger); box-shadow: 0 0 0 4px rgba(251, 113, 133, 0.12); }

.model-summary { color: var(--muted-strong); font-size: 0.8rem; line-height: 1.5; }
.model-picker {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.55rem;
  align-items: end;
}
.compact-action { min-width: 5.8rem; }
.model-details-card {
  display: grid;
  gap: 0.45rem;
  padding: 0.75rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.03);
}
.model-details-card:empty { display: none; }
.model-details-card strong { font-size: 0.86rem; color: var(--text); }
.model-details-card p { color: var(--muted-strong); font-size: 0.78rem; line-height: 1.5; }
.model-details-meta { display: flex; flex-wrap: wrap; gap: 0.35rem; }
.model-group { display: grid; gap: 0.4rem; }
.model-group + .model-group { margin-top: 0.3rem; }
.model-group-title { color: var(--muted); font-size: 0.72rem; letter-spacing: 0.08em; text-transform: uppercase; }

.model-item {
  padding: 0.65rem 0.75rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.03);
  display: grid;
  gap: 0.35rem;
  text-align: left;
}
.model-item.active { border-color: rgba(52, 211, 153, 0.5); background: rgba(56, 189, 248, 0.08); }
.model-item:disabled { opacity: 0.72; cursor: progress; }
.model-item-main { display: grid; gap: 0.15rem; }
.model-item-main strong { color: var(--text); font-size: 0.85rem; line-height: 1.3; }
.model-item-main span { color: var(--muted); font-size: 0.75rem; }
.model-badges { display: flex; flex-wrap: wrap; gap: 0.3rem; }
.model-badge {
  min-height: 1.35rem;
  display: inline-flex; align-items: center;
  padding: 0 0.5rem; border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.04);
  color: var(--muted-strong);
  font-size: 0.68rem;
}

.action-item {
  text-align: left;
  width: 100%;
  padding: 0.7rem 0.75rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.03);
  cursor: pointer;
}
.action-item strong { display: block; font-size: 0.85rem; color: var(--text); }
.action-item small { display: block; margin-top: 0.2rem; color: var(--muted); font-size: 0.78rem; line-height: 1.4; }

.note-list { margin: 0; padding-left: 1rem; color: var(--muted-strong); line-height: 1.6; font-size: 0.82rem; }
.note-list li + li { margin-top: 0.3rem; }

/* ═══════════════════════════════════════════
   FLOATING ACTION BUTTON (inspector toggle)
   ═══════════════════════════════════════════ */
.fab {
  position: fixed;
  bottom: calc(2.5rem + var(--safe-bottom));
  right: calc(1.2rem + var(--safe-right));
  z-index: 25;
  width: 3.2rem;
  height: 3.2rem;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  background: var(--panel-strong);
  color: var(--accent);
  display: grid;
  place-items: center;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.35), 0 1px 4px rgba(0, 0, 0, 0.2);
  cursor: pointer;
  transition: transform 200ms ease, box-shadow 200ms ease;
}

.fab:active { transform: scale(0.92); }

.fab .fab-icon-close { display: none; }
.fab.active .fab-icon-open { display: none; }
.fab.active .fab-icon-close { display: block; }

/* ─── Buttons ─── */
.primary-button, .ghost-button {
  min-height: 2.5rem;
  padding: 0.55rem 1rem;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 700;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
}

.primary-button {
  background: linear-gradient(135deg, var(--accent), var(--accent-soft));
  color: #0b1424;
  border: none;
  box-shadow: 0 4px 16px rgba(56, 189, 248, 0.25);
}
.primary-button:active { transform: scale(0.97); }

.ghost-button {
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  border: 1px solid var(--line-strong);
}
.ghost-button:active { background: rgba(255, 255, 255, 0.08); }

.small-button { min-height: 2.1rem; padding-inline: 0.75rem; font-size: 0.8rem; }
.text-button { padding: 0; background: transparent; color: var(--muted); font-size: 0.8rem; border: none; cursor: pointer; }
.full-width { width: 100%; }

.icon-button {
  width: 2.4rem; height: 2.4rem;
  padding: 0; display: grid; place-items: center;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--line);
  flex-shrink: 0;
  color: var(--text);
}

.icon-button svg { flex-shrink: 0; }

/* ─── Backdrop ─── */
.backdrop {
  position: fixed;
  inset: 0;
  background: rgba(8, 12, 24, 0.75);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: 20;
}

.loading-modal {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: 1.25rem;
  background: rgba(8, 12, 24, 0.76);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.loading-modal[hidden] {
  display: none !important;
}

.memorycore-modal {
  position: fixed;
  inset: 0;
  z-index: 42;
  display: grid;
  place-items: center;
  padding: 1rem;
  background: rgba(8, 12, 24, 0.82);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.memorycore-modal[hidden] {
  display: none !important;
}

.memorycore-panel {
  width: min(1120px, 100%);
  max-height: min(90vh, 840px);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 1rem;
  padding: 1rem;
  overflow: hidden;
  box-shadow: var(--shadow);
}

.memorycore-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  padding-bottom: 0.8rem;
  border-bottom: 1px solid var(--line);
}

.memorycore-head-actions,
.memorycore-viewer-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.danger-button {
  color: var(--danger);
  border-color: rgba(251, 113, 133, 0.24);
}

.danger-button:hover {
  background: rgba(251, 113, 133, 0.1);
  border-color: rgba(251, 113, 133, 0.35);
}

.memorycore-layout {
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(280px, 320px) minmax(0, 1fr);
  gap: 1rem;
}

.memorycore-sidebar,
.memorycore-viewer {
  min-height: 0;
  display: grid;
  gap: 0.85rem;
}

.memorycore-profile-card,
.memorycore-projects-card,
.memorycore-launcher-card,
.memorycore-viewer {
  border-radius: var(--radius-md);
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.03);
}

.memorycore-profile-card,
.memorycore-projects-card,
.memorycore-launcher-card {
  padding: 0.9rem;
}

.memorycore-launcher-card {
  align-content: start;
  display: grid;
  gap: 0.75rem;
}

.memorycore-profile-card {
  align-content: start;
}

.memorycore-profile-card strong,
.memorycore-section-head strong,
.memorycore-viewer-head strong {
  color: var(--text);
  font-size: 0.92rem;
}

.memorycore-profile-copy {
  display: grid;
  gap: 0.4rem;
}

.memorycore-profile-copy p,
.memorycore-launcher-copy,
.memorycore-project-summary,
.memorycore-viewer-head p,
.memorycore-empty {
  color: var(--muted-strong);
  font-size: 0.82rem;
  line-height: 1.55;
}

.memorycore-launcher-actions {
  display: grid;
  gap: 0.55rem;
}

.memorycore-filter-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-top: 0.75rem;
}

.memorycore-filter-button.is-active {
  background: rgba(56, 189, 248, 0.12);
  border-color: rgba(56, 189, 248, 0.26);
  color: var(--accent);
}

.memorycore-tag-cluster {
  display: grid;
  gap: 0.32rem;
}

.memorycore-tag-cluster small {
  color: var(--muted);
  font-size: 0.72rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.memorycore-tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.memorycore-tag {
  display: inline-flex;
  align-items: center;
  min-height: 1.45rem;
  padding: 0 0.55rem;
  border-radius: 999px;
  background: rgba(56, 189, 248, 0.14);
  color: var(--accent);
  font-size: 0.7rem;
  border: 1px solid rgba(56, 189, 248, 0.18);
}

.memorycore-section-head,
.memorycore-viewer-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
}

.memorycore-projects-card {
  min-height: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
}

.memorycore-project-list {
  min-height: 0;
  overflow-y: auto;
  display: grid;
  gap: 0.5rem;
  margin-top: 0.75rem;
  padding-right: 0.15rem;
}

.memorycore-project-item {
  width: 100%;
  text-align: left;
  display: grid;
  gap: 0.35rem;
  padding: 0.8rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.03);
}

.memorycore-project-item.active {
  border-color: rgba(56, 189, 248, 0.35);
  background: rgba(56, 189, 248, 0.08);
}

.memorycore-project-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.memorycore-project-heading {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  min-width: 0;
}

.memorycore-project-heading strong {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.memorycore-project-status {
  display: inline-flex;
  align-items: center;
  min-height: 1.3rem;
  padding: 0 0.45rem;
  border-radius: 999px;
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border: 1px solid transparent;
}

.memorycore-project-status.is-active {
  color: var(--success);
  background: rgba(52, 211, 153, 0.12);
  border-color: rgba(52, 211, 153, 0.18);
}

.memorycore-project-status.is-archived {
  color: var(--muted-strong);
  background: rgba(148, 163, 184, 0.12);
  border-color: rgba(148, 163, 184, 0.16);
}

.memorycore-project-item time,
.memorycore-project-item small {
  color: var(--muted);
  font-size: 0.74rem;
}

.memorycore-viewer {
  padding: 0.95rem;
  grid-template-rows: auto minmax(0, 1fr);
}

.memorycore-viewer-body {
  min-height: 0;
  overflow-y: auto;
  padding-right: 0.2rem;
  display: grid;
  gap: 0.8rem;
}

.memorycore-detail-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.65rem;
}

.memorycore-metric-card,
.memorycore-detail-section {
  padding: 0.8rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.03);
}

.memorycore-metric-card {
  display: grid;
  gap: 0.35rem;
}

.memorycore-metric-label {
  color: var(--muted);
  font-size: 0.72rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.memorycore-metric-value {
  color: var(--text);
  font-size: 0.84rem;
  line-height: 1.55;
}

.memorycore-detail-section {
  display: grid;
  gap: 0.6rem;
}

.memorycore-detail-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.memorycore-detail-heading span {
  color: var(--muted);
  font-size: 0.74rem;
}

.memorycore-detail-list {
  display: grid;
  gap: 0.45rem;
  padding-left: 1rem;
  color: var(--muted-strong);
  font-size: 0.82rem;
  line-height: 1.55;
}

.memorycore-markdown {
  display: grid;
  gap: 0.8rem;
}

.loading-modal-card {
  width: min(100%, 26rem);
  display: grid;
  justify-items: center;
  gap: 0.75rem;
  padding: 1.35rem 1.25rem;
  text-align: center;
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow);
}

.loading-modal-card h3 {
  font-size: 1.1rem;
  line-height: 1.2;
}

.loading-modal-card p:last-child {
  color: var(--muted-strong);
  font-size: 0.85rem;
  line-height: 1.55;
}

.install-help-card {
  text-align: left;
  align-items: stretch;
}

.install-help-steps {
  display: grid;
  gap: 0.55rem;
  padding-left: 1.2rem;
  color: var(--muted-strong);
  font-size: 0.88rem;
  line-height: 1.65;
}

.install-help-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.65rem;
  flex-wrap: wrap;
}

.loading-orb {
  position: relative;
  width: 4.5rem;
  height: 4.5rem;
  display: grid;
  place-items: center;
}

.loading-orb span {
  position: absolute;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--accent), var(--accent-soft));
  opacity: 0.88;
  animation: loading-orb-pulse 1.45s ease-in-out infinite;
}

.loading-orb span:nth-child(1) {
  width: 4.5rem;
  height: 4.5rem;
  opacity: 0.18;
}

.loading-orb span:nth-child(2) {
  width: 3.1rem;
  height: 3.1rem;
  opacity: 0.35;
  animation-delay: 0.14s;
}

.loading-orb span:nth-child(3) {
  width: 1.4rem;
  height: 1.4rem;
  box-shadow: 0 0 24px rgba(56, 189, 248, 0.4);
  animation-delay: 0.28s;
}

/* ─── Utility ─── */
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); border: 0; }
.is-hidden { display: none !important; }
.empty-copy { color: var(--muted); font-size: 0.82rem; line-height: 1.5; padding: 0.2rem 0; }

/* ─── Transitions ─── */
.primary-button, .ghost-button, .text-button, .icon-button,
.chip, .history-item, .action-item, .prompt-card, .showcase-card, .agent-card, .model-item, .fab {
  transition: transform 160ms ease, border-color 160ms ease, background 160ms ease, opacity 160ms ease, box-shadow 160ms ease;
}

/* ─── Hover (pointer devices) ─── */
@media (hover: hover) and (pointer: fine) {
  .primary-button:hover { box-shadow: 0 6px 24px rgba(56, 189, 248, 0.4); transform: translateY(-1px); }
  .ghost-button:hover { background: rgba(255, 255, 255, 0.08); border-color: rgba(255, 255, 255, 0.2); transform: translateY(-1px); }
  .text-button:hover { color: var(--text); }
  .icon-button:hover { background: rgba(255, 255, 255, 0.1); transform: translateY(-1px); }
  .upload-remove:hover:not(:disabled) { background: rgba(255, 255, 255, 0.09); }
  .fab:hover { transform: translateY(-2px); box-shadow: 0 6px 24px rgba(56, 189, 248, 0.2), 0 2px 8px rgba(0, 0, 0, 0.3); }
  .history-item:hover {
    background: rgba(255, 255, 255, 0.04);
    border-color: rgba(255, 255, 255, 0.05);
  }
  .chip:hover, .action-item:hover, .prompt-card:hover, .showcase-card:hover, .model-item:hover {
    transform: translateY(-1px);
    border-color: rgba(255, 255, 255, 0.16);
    background: rgba(255, 255, 255, 0.06);
  }
  .agent-card:hover { border-color: rgba(255, 255, 255, 0.14); }
  .nav-section-toggle:hover { color: var(--text); }
}

/* ─── Scrollbar ─── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.08); border-radius: 999px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255, 255, 255, 0.16); }
* { scrollbar-width: thin; scrollbar-color: rgba(255, 255, 255, 0.08) transparent; }

/* ─── Keyframes ─── */
@keyframes pulse-dots {
  0%, 80%, 100% { transform: translateY(0) scale(0.9); opacity: 0.45; }
  40% { transform: translateY(-2px) scale(1); opacity: 1; }
}

@keyframes float-orb {
  0%, 100% { transform: translateY(0) rotate(0deg) scale(1); }
  50% { transform: translateY(-6px) rotate(6deg) scale(1.02); }
}

@keyframes loading-orb-pulse {
  0%, 100% { transform: scale(0.92); }
  50% { transform: scale(1.06); }
}

/* ═══════════════════════════════════════════
   RESPONSIVE
   ═══════════════════════════════════════════ */

/* Wider desktop: bigger chat padding */
@media (min-width: 900px) {
  .chat-stage {
    padding: 1rem 2rem;
    padding-top: calc(1rem + var(--safe-top));
    padding-bottom: calc(1rem + var(--safe-bottom));
  }

  .welcome-card { padding: 1.2rem; }
}

@media (min-width: 1200px) {
  .chat-stage {
    padding: 1rem 4rem;
    padding-top: calc(1rem + var(--safe-top));
    padding-bottom: calc(1rem + var(--safe-bottom));
  }
}

/* ─── Mobile ─── */
@media (max-width: 640px) {
  html { font-size: 14.5px; }

  .chat-stage {
    padding: 0.5rem;
    padding-top: calc(0.5rem + var(--safe-top));
    padding-bottom: calc(0.5rem + var(--safe-bottom));
    gap: 0.45rem;
  }

  .topbar { padding: 0.55rem 0.7rem; border-radius: var(--radius-lg); }
  .topbar h2 { font-size: 0.95rem; }
  .topbar .eyebrow { font-size: 0.62rem; }
  .topbar-actions { gap: 0.3rem; }
  .topbar-action-button { padding-inline: 0.65rem; }
  .topbar-action-button span { display: none; }

  .welcome-card { grid-template-columns: 1fr; padding: 0.85rem; }
  .welcome-copy h3 { font-size: 1.1rem; }
  .welcome-copy p:last-child { font-size: 0.8rem; }
  .orb-cluster { min-height: 90px; }
  .orb-shell { width: min(8rem, 30vw); }

  .suggestion-showcase { grid-template-columns: 1fr; gap: 0.4rem; }
  .showcase-card { min-height: 5.5rem; padding: 0.7rem; }

  .message { grid-template-columns: 1.9rem minmax(0, 1fr); gap: 0.45rem; }
  .message.user { grid-template-columns: minmax(0, 1fr) 1.9rem; }
  .avatar { width: 1.9rem; height: 1.9rem; border-radius: 9px; }
  .bubble { padding: 0.65rem 0.8rem; border-radius: 14px; font-size: 0.86rem; }
  .bubble-meta { font-size: 0.68rem; }

  .composer { padding: 0.6rem; border-radius: var(--radius-lg); }
  .composer textarea,
  .field input {
    font-size: 16px;
  }

  .composer textarea { min-height: 2.2rem; }

  .chip { font-size: 0.76rem; min-height: 1.85rem; padding: 0 0.65rem; }
  .chip-row { gap: 0.35rem; }

  .sidebar.drawer { width: min(92vw, 320px); }
  .inspector { bottom: calc(10rem + var(--safe-bottom)); right: calc(0.85rem + var(--safe-right)); width: min(92vw, 340px); max-height: min(70vh, 480px); }

  .prompt-grid { grid-template-columns: 1fr; gap: 0.35rem; }
  .prompt-card { min-height: 4rem; padding: 0.55rem; }

  .primary-button, .ghost-button { min-height: 2.3rem; padding: 0.5rem 0.85rem; font-size: 0.82rem; }
  .send-button { min-width: 4rem; }

  .fab { width: 2.8rem; height: 2.8rem; bottom: calc(6.5rem + var(--safe-bottom)); right: calc(0.85rem + var(--safe-right)); }
  .fab svg { width: 16px; height: 16px; }

  .status-pill { font-size: 0.72rem; padding: 0 0.6rem; min-height: 1.8rem; }

  .install-help-actions {
    flex-direction: column;
  }

  .install-help-actions .primary-button,
  .install-help-actions .ghost-button {
    width: 100%;
  }

  /* ── Full-screen modal on mobile ── */
  .memorycore-modal {
    padding: 0;
    align-items: stretch;
  }
  .memorycore-panel {
    width: 100%;
    max-height: 100vh;
    max-height: 100dvh;
    height: 100svh;
    border-radius: 0;
    padding: 0;
    overflow: hidden; /* panel clips */
    grid-template-rows: auto minmax(0, 1fr);
  }
  .memorycore-head {
    padding: 0.9rem 1rem;
    border-radius: 0;
    flex-wrap: wrap;
    gap: 0.5rem;
  }
  .memorycore-head-actions {
    width: 100%;
    gap: 0.4rem;
  }
  .memorycore-head-actions .small-button {
    flex: 1 1 0;
    justify-content: center;
  }

  /* ── Scrollable layout inside the panel ── */
  .memorycore-layout {
    grid-template-columns: 1fr;
    overflow-y: auto;          /* KEY: layout area scrolls */
    -webkit-overflow-scrolling: touch;
    padding: 0 1rem 2rem;
    gap: 0.85rem;
  }

  /* ── Sidebar cards: natural height, no scroll clipping ── */
  .memorycore-sidebar {
    overflow: visible;
    gap: 0.85rem;
  }
  .memorycore-projects-card {
    grid-template-rows: auto auto;
  }
  .memorycore-project-list {
    max-height: 48vh;
  }

  /* ── Viewer: natural height ── */
  .memorycore-viewer {
    grid-template-rows: auto auto;
    min-height: 0;
  }
  .memorycore-viewer-body {
    max-height: 55vh;
  }

  /* ── Viewer actions: wrap to 2 columns ── */
  .memorycore-viewer-head {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.75rem;
  }
  .memorycore-viewer-actions {
    width: 100%;
    gap: 0.4rem;
  }
  .memorycore-viewer-actions .small-button {
    flex: 1 1 calc(50% - 0.25rem);
    justify-content: center;
  }

  .memorycore-detail-grid {
    grid-template-columns: 1fr;
  }
  .memorycore-section-head {
    flex-wrap: wrap;
  }
}

/* Very small */
@media (max-width: 380px) {
  html { font-size: 13.5px; }
  .chat-stage { padding: 0.4rem; padding-top: calc(0.4rem + var(--safe-top)); padding-bottom: calc(0.4rem + var(--safe-bottom)); gap: 0.35rem; }
  .topbar { padding: 0.5rem 0.6rem; }
  .composer { padding: 0.5rem; }
  .message { grid-template-columns: 1.7rem minmax(0, 1fr); gap: 0.4rem; }
  .message.user { grid-template-columns: minmax(0, 1fr) 1.7rem; }
  .avatar { width: 1.7rem; height: 1.7rem; border-radius: 8px; }
  .bubble { padding: 0.55rem 0.7rem; border-radius: 12px; font-size: 0.84rem; }
}

/* ─── Visual viewport (keyboard) ─── */
.chat-stage {
  height: var(--vvh, 100dvh);
}

body.keyboard-open .welcome-state {
  display: none;
}

/* ─── PWA standalone ─── */
@media (display-mode: standalone) {
  body { -webkit-user-select: none; user-select: none; }
  .composer textarea, .field input { -webkit-user-select: text; user-select: text; }
}
