/* ==========================================================================
   WAIVY DESIGN SYSTEM — THE BLUE BUBBLE AI
   Mirrors the boop-agent palette: sand-and-sky-glass radial background,
   ink-on-sand user bubble, glass cream Waivy bubble, Georgia serif heads,
   Inter body. "Blue bubble" is the iMessage metaphor — the UI itself is
   refined slate-and-sand, not saturated iMessage blue.
   ========================================================================== */

:root {
  --font-sans: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-serif: Georgia, "Iowan Old Style", "Apple Garamond", serif;
  --font-mono: 'JetBrains Mono', monospace;

  --transition-fast: 0.15s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-normal: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: 0.4s cubic-bezier(0.4, 0, 0.2, 1);

  --radius-s: 6px;
  --radius-m: 10px;
  --radius-l: 16px;
  --radius-xl: 24px;
  --radius-bubble: 18px;
  --radius-bubble-tail: 6px;

  /* Waivy brand tints (boop-agent canon) */
  --waivy-sky-glass: #cfe5ee;
  --waivy-slate-dark: #3d4458;
  --waivy-slate-soft: #989aae;

  /* Legacy glow-token names retained for compatibility with downstream
     widget styles; values shift to subtle ink-toned shadows. */
  --shadow-glow-purple: 0 8px 24px -10px rgba(26, 39, 48, 0.22);
  --shadow-glow-cyan: 0 6px 18px -8px rgba(207, 229, 238, 0.5);
}

/* Light — sand-and-sky-glass radial; ink text; cream-glass Waivy bubble;
 * slate-ink user bubble. This is the canon Waivy look. */
[data-theme="light"] {
  --color-ink: #1a2730;
  --color-ink-soft: #4a5560;
  --color-sand: #f7f3ec;

  --bg-app-gradient: radial-gradient(ellipse at top, #e6f1f6 0%, #f1ece1 60%, #ecd9c5 100%);
  --bg-app: #f1ece1;
  --bg-card: rgba(255, 255, 255, 0.78);
  --bg-card-hover: rgba(255, 255, 255, 0.92);
  --bg-sidebar: rgba(255, 255, 255, 0.85);
  --bg-input: rgba(255, 255, 255, 0.85);
  --bg-input-focus: #ffffff;

  /* Bubbles */
  --bg-bubble-user: #1a2730;
  --bg-bubble-user-text: #f7f3ec;
  --bg-bubble-assistant: rgba(255, 255, 255, 0.7);
  --bg-bubble-assistant-text: #1a2730;

  --border-color: rgba(26, 39, 48, 0.1);
  --border-color-hover: rgba(26, 39, 48, 0.18);
  --border-color-focus: rgba(26, 39, 48, 0.4);

  --text-primary: #1a2730;
  --text-secondary: #4a5560;
  --text-tertiary: #8e9aa8;
  --text-inverse: #f7f3ec;

  /* "Accent" = the slate ink. Used for filled buttons (Send, Get started)
   * and as the user bubble background. Filled-button text-on-ink uses
   * --text-inverse so contrast holds in both themes. */
  --accent-color: #1a2730;
  --accent-color-hover: #2a3a48;
  --accent-color-rgb: 26, 39, 48;
  --accent-soft: rgba(26, 39, 48, 0.08);

  /* Sky-glass is the soft secondary tint — logo backdrop, accent panels. */
  --accent-cyan: #5b8aa3;
  --accent-cyan-soft: rgba(207, 229, 238, 0.55);

  --surface-glass-top: rgba(255, 255, 255, 0.55);
  --surface-glass-bot: rgba(255, 255, 255, 0.35);
  --surface-glass-border: rgba(255, 255, 255, 0.55);
  --surface-modal: rgba(247, 243, 236, 0.97);
  --divider: rgba(26, 39, 48, 0.1);

  --glass-blur: blur(18px) saturate(160%);
  --glass-shadow: 0 8px 32px 0 rgba(26, 39, 48, 0.12);
  --glass-border: 1px solid rgba(255, 255, 255, 0.55);

  --shadow-glass: 0 8px 24px -10px rgba(26, 39, 48, 0.18);
  --shadow-hero: 0 24px 60px -24px rgba(26, 39, 48, 0.25);
  --shadow-modal: 0 24px 80px -16px rgba(26, 39, 48, 0.45);

  color-scheme: light;
}

/* Dark — deep slate night; ink-soft/sand inversions so contrast holds. */
[data-theme="dark"] {
  --color-ink: #e8edf3;
  --color-ink-soft: #8e9aa8;
  --color-sand: #0e1822;

  --bg-app-gradient: radial-gradient(ellipse at top, #1a2738 0%, #0f1a26 55%, #060c14 100%);
  --bg-app: #0f1a26;
  --bg-card: rgba(255, 255, 255, 0.06);
  --bg-card-hover: rgba(255, 255, 255, 0.1);
  --bg-sidebar: rgba(255, 255, 255, 0.04);
  --bg-input: rgba(255, 255, 255, 0.06);
  --bg-input-focus: rgba(255, 255, 255, 0.1);

  /* In dark mode the user bubble inverts: sand (warm cream) on the user's
   * outbound side; the Waivy bubble stays glass with ink-light text. */
  --bg-bubble-user: #e8edf3;
  --bg-bubble-user-text: #0e1822;
  --bg-bubble-assistant: rgba(255, 255, 255, 0.07);
  --bg-bubble-assistant-text: #e8edf3;

  --border-color: rgba(255, 255, 255, 0.08);
  --border-color-hover: rgba(255, 255, 255, 0.16);
  --border-color-focus: rgba(255, 255, 255, 0.4);

  --text-primary: #e8edf3;
  --text-secondary: #8e9aa8;
  --text-tertiary: #5d6776;
  --text-inverse: #0e1822;

  --accent-color: #e8edf3;
  --accent-color-hover: #ffffff;
  --accent-color-rgb: 232, 237, 243;
  --accent-soft: rgba(255, 255, 255, 0.08);

  --accent-cyan: #cfe5ee;
  --accent-cyan-soft: rgba(207, 229, 238, 0.12);

  --surface-glass-top: rgba(255, 255, 255, 0.08);
  --surface-glass-bot: rgba(255, 255, 255, 0.04);
  --surface-glass-border: rgba(255, 255, 255, 0.1);
  --surface-modal: rgba(22, 30, 40, 0.97);
  --divider: rgba(255, 255, 255, 0.1);

  --glass-blur: blur(18px) saturate(160%);
  --glass-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.45);
  --glass-border: 1px solid rgba(255, 255, 255, 0.08);

  --shadow-glass: 0 8px 24px -10px rgba(0, 0, 0, 0.55);
  --shadow-hero: 0 24px 60px -24px rgba(0, 0, 0, 0.65);
  --shadow-modal: 0 24px 80px -16px rgba(0, 0, 0, 0.7);

  color-scheme: dark;
}

/* ==========================================================================
   GLOBAL RESET & INTERACTIVE STYLES
   ========================================================================== */

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-sans);
  background-color: var(--bg-app);
  color: var(--text-primary);
  height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: background-color var(--transition-normal), color var(--transition-normal);
}

/* Custom Scrollbars */
::-webkit-scrollbar {
  width: 5px;
  height: 5px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--border-color-hover);
  border-radius: var(--radius-s);
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-tertiary);
}

code {
  font-family: var(--font-mono);
}

/* ==========================================================================
   HEADER / NAVIGATION BAR
   ========================================================================== */

.navbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 28px;
  background: var(--bg-sidebar);
  border-bottom: 1px solid var(--border-color);
  z-index: 100;
  transition: all var(--transition-normal);
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo-wrapper {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 30px;
  border-radius: var(--radius-m);
  background: var(--accent-soft);
  color: var(--accent-color);
  padding: 4px 6px;
  box-shadow: var(--shadow-glow-purple);
  transition: background var(--transition-normal), box-shadow var(--transition-normal);
}

/* Waivy wave mark — inline SVG, paints itself with `currentColor` from the
 * parent (logo-wrapper or placeholder-icon), so theme + accent changes track
 * automatically. Aspect ratio is 240×110 (≈2.18:1). */
.waivy-mark {
  display: block;
  width: 100%;
  height: 100%;
}

.glowing-icon {
  animation: pulse-glow-purple 3s infinite ease-in-out;
}

.nav-titles {
  display: flex;
  flex-direction: column;
}

.nav-main-title {
  font-family: var(--font-serif);
  font-weight: 600;
  font-size: 1.25rem;
  line-height: 1.05;
  letter-spacing: -0.01em;
}

.nav-sub-title {
  font-family: var(--font-mono);
  font-size: 0.62rem;
  letter-spacing: 0.22em;
  color: var(--text-secondary);
}

.nav-actions {
  display: flex;
  align-items: center;
  gap: 16px;
}

/* Copilot Status Pill (grows and updates color) */
.copilot-status-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  border-radius: var(--radius-xl);
  font-size: 0.78rem;
  font-weight: 700;
  border: 1px solid var(--border-color);
  position: relative;
  transition: all var(--transition-normal);
}

.copilot-status-pill.idle {
  background: var(--accent-soft);
  color: var(--accent-color);
  border-color: rgba(var(--accent-color-rgb), 0.2);
}

.copilot-status-pill.routing {
  background: rgba(245, 158, 11, 0.1);
  color: #f59e0b;
  border-color: rgba(245, 158, 11, 0.2);
}

.copilot-status-pill.searching {
  background: var(--accent-cyan-soft);
  color: var(--accent-cyan);
  border-color: rgba(6, 182, 212, 0.2);
}

.copilot-status-pill.streaming {
  background: rgba(16, 185, 129, 0.1);
  color: #10b981;
  border-color: rgba(16, 185, 129, 0.2);
}

.pulse-ring {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background-color: currentColor;
}

.copilot-status-pill.streaming .pulse-ring, 
.copilot-status-pill.routing .pulse-ring,
.copilot-status-pill.searching .pulse-ring {
  animation: status-pulsate 1.8s infinite ease-in-out;
}

.theme-toggle-btn {
  background: none;
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  width: 36px;
  height: 36px;
  border-radius: var(--radius-m);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
}

.theme-toggle-btn:hover {
  color: var(--text-primary);
  border-color: var(--text-secondary);
  background: var(--bg-card);
}

/* ==========================================================================
   WORKSPACE GRID LAYOUT
   ========================================================================== */

.workspace-grid {
  display: grid;
  grid-template-columns: 310px 1fr;
  flex: 1;
  height: calc(100vh - 65px);
  overflow: hidden;
}

/* ==========================================================================
   LEFT SIDEBAR: CONFIGS, MEMORY & TODOS
   ========================================================================== */

.sidebar-panel {
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  height: 100%;
}

.sidebar-scrollable {
  flex: 1;
  overflow-y: auto;
  padding: 20px 18px 30px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* Sidebar Glass Cards */
.sidebar-card {
  background: var(--bg-card);
  border: var(--glass-border);
  box-shadow: var(--glass-shadow);
  border-radius: var(--radius-l);
  padding: 16px;
  transition: background-color var(--transition-normal);
}

.sidebar-card:hover {
  background: var(--bg-card-hover);
}

.card-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.card-title h3 {
  font-size: 0.84rem;
  font-weight: 750;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 6px;
}

.card-collapse-btn, .btn-clear-memory {
  background: none;
  border: none;
  color: var(--text-tertiary);
  cursor: pointer;
  transition: color var(--transition-fast);
  padding: 2px;
}

.card-collapse-btn:hover, .btn-clear-memory:hover {
  color: var(--accent-color);
}

.card-body {
  transition: all var(--transition-normal);
}

.card-body.hidden {
  display: none !important;
}

/* Forms controls in sidebar */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-label {
  font-size: 0.74rem;
  font-weight: 700;
  color: var(--text-secondary);
}

.form-control {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  padding: 8px 10px;
  font-family: var(--font-sans);
  font-size: 0.8rem;
  border-radius: var(--radius-m);
  outline: none;
  transition: all var(--transition-fast);
}

.form-control:focus {
  border-color: var(--accent-color);
  background: var(--bg-input-focus);
}

.api-key-input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.api-key-input-wrapper .input-icon {
  position: absolute;
  left: 10px;
  color: var(--text-tertiary);
  font-size: 0.78rem;
  pointer-events: none;
}

.api-key-input-wrapper .form-control {
  padding-left: 28px;
  padding-right: 32px;
}

.visibility-btn {
  position: absolute;
  right: 6px;
  background: none;
  border: none;
  color: var(--text-tertiary);
  width: 24px;
  height: 24px;
  border-radius: var(--radius-s);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
}

.visibility-btn:hover {
  color: var(--text-primary);
}

/* Memory Bank Styling */
.memory-placeholder, .reminders-placeholder {
  text-align: center;
  padding: 14px 4px;
  color: var(--text-tertiary);
  font-size: 0.74rem;
  line-height: 1.4;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.memory-placeholder i, .reminders-placeholder i {
  font-size: 1.4rem;
  color: var(--border-color-hover);
}

.memory-bank-facts {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.memory-chip {
  font-size: 0.76rem;
  font-weight: 600;
  padding: 6px 10px;
  border-radius: var(--radius-m);
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 6px;
  animation: slide-in-memory 0.3s ease;
}

.memory-chip i {
  color: var(--accent-color);
  font-size: 0.78rem;
}

/* Task checklist board */
.badge {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  font-weight: 700;
  background: var(--accent-soft);
  color: var(--accent-color);
  padding: 1px 6px;
  border-radius: var(--radius-s);
}

.todo-input-wrapper {
  display: flex;
  gap: 6px;
  margin-bottom: 12px;
}

.todo-add-btn {
  background: var(--accent-color);
  color: var(--text-inverse);
  border: none;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-m);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
}

.todo-add-btn:hover {
  background: var(--accent-color-hover);
}

.todo-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 180px;
  overflow-y: auto;
}

.todo-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 8px;
  border-radius: var(--radius-m);
  background: rgba(0, 0, 0, 0.08);
  border: 1px solid var(--border-color);
  font-size: 0.78rem;
  animation: slide-in-memory 0.25s ease;
}

.todo-item-left {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  flex: 1;
}

.todo-item input[type="checkbox"] {
  cursor: pointer;
}

.todo-item.completed {
  opacity: 0.5;
}

.todo-item.completed span {
  text-decoration: line-through;
}

.todo-del-btn {
  background: none;
  border: none;
  color: var(--text-tertiary);
  cursor: pointer;
  font-size: 0.74rem;
  padding: 2px;
  transition: color var(--transition-fast);
}

.todo-del-btn:hover {
  color: #ef4444;
}

/* Reminders board sidebar */
.reminders-list-grid {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 180px;
  overflow-y: auto;
}

.reminder-card {
  padding: 8px 10px;
  border-radius: var(--radius-m);
  background: rgba(var(--accent-color-rgb), 0.04);
  border: 1px solid rgba(var(--accent-color-rgb), 0.15);
  font-size: 0.76rem;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.reminder-card-title {
  font-weight: 700;
  color: var(--text-primary);
}

.reminder-card-time {
  font-size: 0.68rem;
  color: var(--accent-color);
  font-family: var(--font-mono);
  display: flex;
  align-items: center;
  gap: 4px;
}

/* ==========================================================================
   CENTER PANEL: CHAT FEED CONSOLE
   ========================================================================== */

.main-console {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;        /* allow this grid item to shrink so its flex child can scroll */
  min-width: 0;
  overflow: hidden;
  background: var(--bg-app);
}

.chat-thread-container {
  flex: 1;
  /* min-height:0 lets this flex child shrink so overflow-y can scroll
     instead of pushing the container past its parent's height. */
  min-height: 0;
  overflow-y: auto;
  padding: 28px 32px 14px;
  display: flex;
  flex-direction: column;
}

/* Empty State / Welcome Panel */
.chat-placeholder-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  margin: auto;
  text-align: center;
  max-width: 600px;
  color: var(--text-secondary);
  gap: 16px;
  padding: 20px;
}

.placeholder-icon {
  width: 92px;
  height: 42px;
  color: var(--accent-color);
  filter: drop-shadow(0 0 18px rgba(var(--accent-color-rgb), 0.45));
}

.chat-placeholder-wrapper h2 {
  font-family: var(--font-serif);
  font-weight: 600;
  font-size: 1.65rem;
  letter-spacing: -0.01em;
  color: var(--text-primary);
}

.chat-placeholder-wrapper p {
  font-size: 0.88rem;
  line-height: 1.5;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.chat-suggestions-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  width: 100%;
  margin-top: 10px;
}

.suggestion-card {
  background: var(--bg-card);
  border: var(--glass-border);
  box-shadow: var(--glass-shadow);
  border-radius: var(--radius-l);
  padding: 12px 16px;
  text-align: left;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.suggestion-card:hover {
  background: var(--bg-card-hover);
  border-color: var(--accent-color);
  transform: translateY(-2px);
}

.suggestion-card h4 {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--accent-color);
  margin-bottom: 4px;
}

.suggestion-card p {
  font-size: 0.74rem;
  color: var(--text-secondary);
  margin: 0;
  line-height: 1.3;
}

/* Active Conversation Dialogue */
.conversation-feed {
  display: flex;
  flex-direction: column;
  gap: 24px;
  width: 100%;
  max-width: 800px;
  margin: 0 auto;
  padding-bottom: 40px;
}

/* Dialogue Bubbles */
.chat-message-row {
  display: flex;
  flex-direction: column;
  width: 100%;
  animation: chat-bubble-pop 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.chat-message-row.user {
  align-items: flex-end;
}

.chat-message-row.assistant {
  align-items: flex-start;
}

.chat-message-row .bubble-author {
  font-size: 0.74rem;
  font-weight: 700;
  color: var(--text-tertiary);
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 4px;
}

.message-bubble {
  max-width: 85%;
  padding: 14px 20px;
  border-radius: var(--radius-l);
  font-size: 0.94rem;
  line-height: 1.6;
  position: relative;
  box-shadow: var(--glass-shadow);
}

.chat-message-row.user .message-bubble {
  background: var(--bg-bubble-user);
  color: #ffffff;
  border-bottom-right-radius: 4px;
}

.chat-message-row.assistant .message-bubble {
  background: var(--bg-bubble-assistant);
  color: var(--text-primary);
  border: var(--glass-border);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border-bottom-left-radius: 4px;
}

/* Glowing Left border representing Gemini brain on Assistant */
.chat-message-row.assistant .message-bubble::after {
  content: "";
  position: absolute;
  top: 14px;
  bottom: 14px;
  left: 0;
  width: 3px;
  background-color: var(--accent-color);
  border-radius: var(--radius-s);
}

/* Search Source Groundings summary dropdown inside assistant bubble */
.embedded-grounding-block {
  background: rgba(0, 0, 0, 0.08);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-m);
  margin-top: 12px;
  font-size: 0.8rem;
}

.grounding-toggle-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  cursor: pointer;
  font-weight: 700;
  color: var(--text-secondary);
}

.grounding-links-grid {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 10px 12px;
  border-top: 1px solid var(--border-color);
  max-height: 120px;
  overflow-y: auto;
}

.embedded-grounding-block.collapsed .grounding-links-grid {
  display: none;
}

.embedded-grounding-block.collapsed .grounding-toggle-header i {
  transform: rotate(-90deg);
}

.grounding-item-link {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--accent-cyan);
  font-weight: 600;
  text-decoration: none;
}

.grounding-item-link:hover {
  text-decoration: underline;
}

.grounding-item-link .index {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  background: var(--accent-cyan-soft);
  padding: 1px 4px;
  border-radius: 2px;
}

/* ==========================================================================
   COIOPILOT ACTIVE ROUTING TRACKER WIDGET
   ========================================================================== */

.routing-visualizer-card {
  background: rgba(0, 0, 0, 0.1);
  border: var(--glass-border);
  border-radius: var(--radius-l);
  padding: 16px 20px;
  width: 100%;
  max-width: 480px;
  margin: 10px 0;
  backdrop-filter: var(--glass-blur);
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-self: center;
  animation: chat-bubble-pop 0.3s ease;
}

.routing-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-secondary);
}

.routing-header span i {
  color: var(--accent-color);
  animation: spin 3s infinite linear;
}

/* The Nodes pipeline visualizer layout */
.routing-pipeline-diagram {
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: relative;
  padding: 10px 0;
}

.routing-node {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  position: relative;
  z-index: 2;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-tertiary);
}

.node-icon-bubble {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.95rem;
  transition: all var(--transition-normal);
}

.routing-node.source-qb .node-icon-bubble {
  background: var(--accent-soft);
  border-color: var(--accent-color);
  color: var(--accent-color);
  box-shadow: var(--shadow-glow-purple);
  animation: pulse-node 1.5s infinite;
}

.routing-node.active .node-icon-bubble {
  background: var(--accent-cyan-soft);
  border-color: var(--accent-cyan);
  color: var(--accent-cyan);
  box-shadow: var(--shadow-glow-cyan);
}

.routing-node.active span {
  color: var(--text-primary);
}

/* Connecting laser lines */
.pipeline-wires-wrapper {
  position: absolute;
  left: 20px;
  right: 20px;
  top: 28px;
  height: 2px;
  background: var(--border-color);
  z-index: 1;
}

.laser-pulse-particle {
  position: absolute;
  top: 0;
  left: 0;
  width: 35px;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--accent-cyan));
  animation: laser-flow 1.2s infinite linear;
}

/* ==========================================================================
   DYNAMIC CUSTOM WIDGETS
   ========================================================================== */

/* 1. Pollinations Image Synthesizer Card */
.image-widget-card {
  width: 100%;
  max-width: 480px;
  background: var(--bg-card);
  border: var(--glass-border);
  border-radius: var(--radius-l);
  overflow: hidden;
  box-shadow: var(--glass-shadow);
  display: flex;
  flex-direction: column;
  margin-top: 10px;
}

.image-widget-card .img-prompt-header {
  padding: 10px 14px;
  background: rgba(0, 0, 0, 0.1);
  font-size: 0.76rem;
  font-weight: 600;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border-color);
}

.image-widget-card .img-container {
  width: 100%;
  aspect-ratio: 1;
  position: relative;
  background: #000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.image-widget-card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform var(--transition-slow);
}

.image-widget-card img:hover {
  transform: scale(1.03);
}

.image-widget-card .loading-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  font-size: 0.8rem;
  gap: 8px;
}

/* 2. Monthly Planner Calendar Widget */
.calendar-widget-card {
  width: 100%;
  max-width: 380px;
  background: var(--bg-card);
  border: var(--glass-border);
  border-radius: var(--radius-l);
  padding: 14px;
  box-shadow: var(--glass-shadow);
  margin-top: 10px;
  font-size: 0.82rem;
}

.calendar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-weight: 700;
  margin-bottom: 10px;
}

.calendar-days-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
  text-align: center;
}

.calendar-day-label {
  font-size: 0.65rem;
  font-weight: 700;
  color: var(--text-tertiary);
  padding: 2px 0;
}

.calendar-cell {
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-s);
  background: rgba(0,0,0,0.1);
  border: 1px solid var(--border-color);
  font-family: var(--font-mono);
  font-size: 0.74rem;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.calendar-cell:hover {
  background: var(--bg-card-hover);
  border-color: var(--text-secondary);
}

.calendar-cell.active-reminder {
  border-color: var(--accent-color);
  background: var(--accent-soft);
  color: var(--accent-color);
  font-weight: 750;
  box-shadow: 0 0 8px rgba(var(--accent-color-rgb), 0.2);
}

.calendar-cell.today {
  background: var(--border-color-hover);
  font-weight: 800;
}

/* 3. Flight Tracker widget */
.flight-widget-card {
  width: 100%;
  max-width: 440px;
  background: var(--bg-card);
  border: var(--glass-border);
  border-radius: var(--radius-l);
  padding: 16px;
  box-shadow: var(--glass-shadow);
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 10px;
}

.flight-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.76rem;
  font-weight: 700;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 6px;
}

.flight-airports {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 0;
}

.airport-node h2 {
  font-size: 1.8rem;
  font-weight: 850;
  color: var(--text-primary);
  line-height: 1;
}

.airport-node p {
  font-size: 0.72rem;
  color: var(--text-secondary);
}

.flight-arrow-path {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  position: relative;
  padding: 0 20px;
}

.timeline-line-track {
  height: 2px;
  background: repeating-linear-gradient(90deg, transparent, transparent 4px, var(--border-color) 4px, var(--border-color) 8px);
  width: 100%;
  position: relative;
  top: 14px;
}

.timeline-active-progress {
  height: 2px;
  background: var(--accent-cyan);
  position: absolute;
  top: 14px;
  left: 20px;
  width: calc(65% - 20px);
}

.flight-arrow-path i {
  position: relative;
  z-index: 2;
  color: var(--accent-cyan);
  font-size: 0.95rem;
  transform: rotate(90deg);
  animation: plane-fly 4s infinite linear;
}

.flight-details-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  text-align: center;
  font-size: 0.72rem;
  background: rgba(0, 0, 0, 0.08);
  padding: 8px;
  border-radius: var(--radius-m);
}

.flight-details-grid .title {
  color: var(--text-tertiary);
  font-weight: 700;
  margin-bottom: 2px;
}

.flight-details-grid .value {
  font-weight: 700;
  color: var(--text-primary);
}

/* 4. Weather widget */
.weather-widget-card {
  width: 100%;
  max-width: 360px;
  background: var(--bg-card);
  border: var(--glass-border);
  border-radius: var(--radius-l);
  padding: 16px;
  box-shadow: var(--glass-shadow);
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 10px;
}

.weather-main-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.weather-temp-block h2 {
  font-size: 2.2rem;
  font-weight: 850;
  line-height: 1;
}

.weather-temp-block p {
  font-size: 0.78rem;
  color: var(--text-secondary);
}

.weather-main-row i {
  font-size: 2.2rem;
  color: #f59e0b;
}

.weather-specs-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  font-size: 0.72rem;
}

.weather-spec-item {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text-secondary);
  background: rgba(0,0,0,0.1);
  padding: 6px 10px;
  border-radius: var(--radius-m);
}

.weather-forecast-row {
  display: flex;
  justify-content: space-between;
  border-top: 1px solid var(--border-color);
  padding-top: 10px;
}

.weather-forecast-day {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  font-size: 0.7rem;
}

.weather-forecast-day .day {
  color: var(--text-tertiary);
  font-weight: 700;
}

.weather-forecast-day i {
  color: var(--text-secondary);
}

/* ==========================================================================
   INPUT BAR & AUTOCOMPLETE WIDGETS
   ========================================================================== */

.console-input-card {
  padding: 16px 32px 28px;
  flex-shrink: 0;
  position: relative;
  max-width: 800px;
  width: 100%;
  margin: 0 auto;
}

.query-box-container {
  display: flex;
  flex-direction: column;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-l);
  overflow: hidden;
  transition: all var(--transition-fast);
}

.query-box-container:focus-within {
  border-color: var(--accent-color);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.query-textarea {
  width: 100%;
  background: none;
  border: none;
  resize: none;
  padding: 14px 18px;
  font-family: var(--font-sans);
  font-size: 0.94rem;
  line-height: 1.5;
  color: var(--text-primary);
  outline: none;
}

.query-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 14px;
  background: rgba(0, 0, 0, 0.08);
  border-top: 1px solid var(--border-color);
}

.textarea-length-indicator {
  font-size: 0.72rem;
  color: var(--text-tertiary);
  font-family: var(--font-mono);
}

/* General Buttons */
/* Per-message latency chip + click-to-expand trace timeline */
.bubble-author {
  display: flex;
  align-items: center;
  gap: 8px;
}
.latency-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-left: 4px;
  padding: 2px 8px;
  font-size: 0.65rem;
  font-weight: 700;
  font-family: var(--font-mono);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
  letter-spacing: 0;
}
.latency-chip:hover {
  background: rgba(255, 255, 255, 0.07);
  border-color: var(--accent-color);
  color: var(--text-primary);
}
.latency-chip.open {
  background: var(--accent-soft);
  border-color: var(--accent-color);
  color: var(--text-primary);
}
.latency-chip .ttfb {
  font-weight: 500;
  opacity: 0.75;
}
.latency-chip.tier-fast { border-color: rgba(34, 197, 94, 0.4); color: #22c55e; }
.latency-chip.tier-fast:hover, .latency-chip.tier-fast.open { background: rgba(34, 197, 94, 0.1); }
.latency-chip.tier-medium { border-color: rgba(245, 158, 11, 0.4); color: #f59e0b; }
.latency-chip.tier-medium:hover, .latency-chip.tier-medium.open { background: rgba(245, 158, 11, 0.1); }
.latency-chip.tier-slow { border-color: rgba(239, 68, 68, 0.4); color: #ef4444; }
.latency-chip.tier-slow:hover, .latency-chip.tier-slow.open { background: rgba(239, 68, 68, 0.1); }

.trace-panel {
  margin-top: 6px;
  padding: 12px 14px;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-m);
  font-family: var(--font-mono);
  font-size: 0.7rem;
  line-height: 1.5;
  max-width: 720px;
}
.trace-panel .trace-header {
  font-weight: 700;
  color: var(--accent-color);
  margin: 8px 0 4px;
  letter-spacing: 0.08em;
  font-size: 0.65rem;
}
.trace-panel .trace-header:first-child { margin-top: 0; }
.trace-panel .trace-meta {
  color: var(--text-tertiary);
  font-size: 0.66rem;
  margin-bottom: 4px;
}
.trace-panel .trace-footer {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px dashed var(--border-color);
  color: var(--text-tertiary);
  font-size: 0.66rem;
}
.trace-panel .trace-row {
  display: grid;
  grid-template-columns: 70px 1fr 70px auto;
  gap: 10px;
  align-items: baseline;
  padding: 2px 0;
}
.trace-panel .trace-at {
  color: var(--text-tertiary);
  text-align: right;
  white-space: pre;
}
.trace-panel .trace-label {
  color: var(--text-primary);
  font-weight: 700;
}
.trace-panel .trace-dur {
  color: var(--accent-cyan);
  text-align: right;
}
.trace-panel .trace-extra {
  color: var(--text-secondary);
  font-family: var(--font-sans);
  font-weight: 400;
  font-size: 0.68rem;
  grid-column: 2 / -1;
  margin-top: -2px;
  margin-bottom: 4px;
}
.trace-panel .trace-empty {
  color: var(--text-tertiary);
  font-style: italic;
}

/* Places widget — map + list (for "italian near me" type queries) */
.places-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px 14px 12px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-l);
  max-width: 460px;
  font-family: var(--font-sans);
}
.places-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.places-head .places-title {
  font-size: 0.92rem;
  font-weight: 800;
  letter-spacing: -0.01em;
  text-transform: capitalize;
}
.places-head .places-loc {
  font-weight: 500;
  color: var(--text-secondary);
  text-transform: none;
}
.places-head .places-count {
  font-size: 0.66rem;
  font-weight: 700;
  color: var(--accent-color);
  background: var(--accent-soft);
  padding: 3px 8px;
  border-radius: 999px;
  font-family: var(--font-mono);
}
.places-map {
  height: 220px;
  border-radius: var(--radius-m);
  overflow: hidden;
  border: 1px solid var(--border-color);
  background: rgba(0, 0, 0, 0.3);
  position: relative;
}
.places-map .leaflet-control-attribution {
  font-size: 0.55rem;
  background: rgba(0, 0, 0, 0.5);
  color: var(--text-tertiary);
  padding: 1px 6px;
}
.places-map .leaflet-control-zoom a {
  background: var(--bg-card);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
}
.places-map .map-fallback {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  font-size: 0.78rem;
  color: var(--text-secondary);
  font-style: italic;
}
.place-marker .place-marker-inner {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--accent-color);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 0.78rem;
  border: 2px solid white;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.5);
  font-family: var(--font-sans);
}
.places-map .leaflet-popup-content-wrapper {
  background: var(--bg-card);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-m);
}
.places-map .leaflet-popup-tip {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
}
.places-map .leaflet-popup-content {
  margin: 8px 12px;
  font-family: var(--font-sans);
  font-size: 0.74rem;
}
.places-map .map-pop strong {
  font-size: 0.82rem;
}
.places-map .map-pop small {
  color: var(--text-tertiary);
}
.places-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.places-empty {
  font-size: 0.78rem;
  color: var(--text-secondary);
  text-align: center;
  font-style: italic;
  padding: 14px 0;
}
.place-item {
  display: grid;
  grid-template-columns: 28px 1fr;
  gap: 10px;
  padding: 10px;
  background: rgba(0, 0, 0, 0.18);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-m);
  cursor: pointer;
  transition: all var(--transition-fast);
}
.place-item:hover, .place-item-active {
  border-color: var(--accent-color);
  background: var(--accent-soft);
  transform: translateY(-1px);
}
.place-item .place-pin {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--accent-color);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 0.76rem;
  margin-top: 2px;
}
.place-item .place-body { min-width: 0; }
.place-item .place-name {
  font-weight: 800;
  font-size: 0.86rem;
  letter-spacing: -0.01em;
}
.place-item .place-sub {
  font-size: 0.72rem;
  color: var(--text-secondary);
  margin-top: 1px;
}
.place-item .place-addr {
  font-size: 0.7rem;
  color: var(--text-tertiary);
  margin-top: 4px;
}
.place-item .place-addr i {
  color: var(--accent-color);
  margin-right: 3px;
}
.place-item .place-open { color: #22c55e; font-weight: 700; }
.place-item .place-closed { color: #ef4444; font-weight: 700; }
.place-item .place-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}
.place-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.68rem;
  font-weight: 700;
  padding: 5px 10px;
  border-radius: 999px;
  background: var(--bg-card);
  border: 1px solid var(--border-color-hover);
  color: var(--text-primary);
  text-decoration: none;
  transition: all var(--transition-fast);
}
.place-btn:hover {
  background: var(--bg-card-hover);
  border-color: var(--accent-color);
}
.place-btn.primary {
  background: var(--accent-color);
  color: white;
  border-color: var(--accent-color);
}
.place-btn.primary:hover {
  filter: brightness(1.1);
}
.place-btn i {
  font-size: 0.72rem;
}

/* Scores widget — sport-aware (NBA, NFL, MLB, NHL, soccer, F1, tennis, etc.) */
.scores-widget-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px 16px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-left: 4px solid var(--sport-accent, var(--accent-cyan));
  border-radius: var(--radius-l);
  max-width: 460px;
  font-family: var(--font-sans);
}
.scores-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  font-size: 0.74rem;
}
.scores-league {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 800;
}
.scores-sport-emoji { font-size: 1rem; }
.scores-leaguesub {
  font-weight: 500;
  color: var(--text-secondary);
}
.scores-status {
  font-size: 0.66rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  display: flex;
  align-items: center;
  gap: 4px;
}
.scores-teams {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
}
.scores-team { text-align: center; }
.scores-team-name {
  font-size: 0.92rem;
  font-weight: 800;
  letter-spacing: -0.01em;
  margin-bottom: 4px;
  line-height: 1.2;
}
.scores-score {
  font-size: 2rem;
  font-weight: 850;
  font-family: var(--font-mono);
  letter-spacing: -0.02em;
}
.scores-home .scores-score { color: var(--sport-accent, var(--accent-cyan)); }
.scores-side {
  font-size: 0.58rem;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-top: 2px;
}
.scores-vs {
  font-size: 0.7rem;
  font-weight: 800;
  color: var(--text-tertiary);
  text-transform: lowercase;
}
.scores-stats {
  display: grid;
  gap: 0 8px;
  padding: 8px 10px;
  background: rgba(0, 0, 0, 0.18);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-m);
  font-size: 0.72rem;
}
.scores-stats .scores-stat-corner {}
.scores-stats .scores-stat-label {
  text-align: center;
  font-size: 0.6rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-tertiary);
  font-weight: 800;
  padding-bottom: 2px;
}
.scores-stats .scores-stat-team {
  font-size: 0.66rem;
  color: var(--text-secondary);
  font-weight: 600;
  padding: 4px 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.scores-stats .scores-stat-val {
  text-align: center;
  font-family: var(--font-mono);
  font-weight: 700;
  padding: 4px 0;
  color: var(--text-primary);
}
.scores-stats .scores-stat-val.home {
  color: var(--sport-accent, var(--accent-cyan));
}
.scores-highlight {
  font-size: 0.72rem;
  color: var(--text-primary);
  padding: 8px 10px;
  background: var(--accent-soft);
  border-radius: var(--radius-m);
  line-height: 1.4;
}
.scores-highlight strong {
  font-size: 0.6rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--accent-color);
  font-weight: 800;
  margin-right: 6px;
}
.scores-meta {
  font-size: 0.66rem;
  color: var(--text-tertiary);
  text-align: center;
}

/* Podium scores widget — F1 / Olympics / golf / marathon top-3 */
.scores-podium-card .podium-stage {
  display: grid;
  grid-template-columns: 1fr 1.05fr 1fr;
  align-items: end;
  gap: 8px;
  padding: 8px 0 12px;
}
.scores-podium-card .podium-block {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 12px 6px;
  background: rgba(0, 0, 0, 0.18);
  border: 1px solid var(--border-color);
  border-top: 4px solid var(--sport-accent, var(--accent-cyan));
  border-radius: var(--radius-m);
  gap: 2px;
}
.scores-podium-card .podium-rank-1 {
  order: 2;       /* center column */
  padding-top: 16px;
  padding-bottom: 16px;
  background: linear-gradient(180deg, rgba(234, 179, 8, 0.16), rgba(0, 0, 0, 0.18));
  border-top-color: #eab308;
}
.scores-podium-card .podium-rank-2 {
  order: 1;       /* left column */
  background: linear-gradient(180deg, rgba(203, 213, 225, 0.12), rgba(0, 0, 0, 0.18));
  border-top-color: #cbd5e1;
}
.scores-podium-card .podium-rank-3 {
  order: 3;       /* right column */
  background: linear-gradient(180deg, rgba(180, 83, 9, 0.14), rgba(0, 0, 0, 0.18));
  border-top-color: #b45309;
}
.scores-podium-card .podium-medal {
  font-size: 1.6rem;
  line-height: 1;
  margin-bottom: 2px;
}
.scores-podium-card .podium-rank-label {
  font-size: 0.6rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-tertiary);
  font-weight: 800;
}
.scores-podium-card .podium-name {
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: -0.01em;
  line-height: 1.2;
  margin-top: 4px;
}
.scores-podium-card .podium-rank-1 .podium-name {
  font-size: 0.86rem;
}
.scores-podium-card .podium-team {
  font-size: 0.62rem;
  color: var(--text-secondary);
  margin-top: 1px;
}
.scores-podium-card .podium-value {
  font-family: var(--font-mono);
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-top: 6px;
}
.scores-podium-card .podium-rank-1 .podium-value {
  font-size: 0.96rem;
  color: #eab308;
}
.scores-podium-card .podium-delta {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--text-tertiary);
}
.scores-podium-card .podium-value-label {
  text-align: center;
  font-size: 0.6rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-tertiary);
  margin-top: -6px;
  margin-bottom: 4px;
}

/* Standings scores widget — F1 standings / league tables / rankings */
.scores-standings-card .standings-scroll {
  overflow-x: auto;
  margin: 0 -4px;
}
.scores-standings-card .standings-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.76rem;
}
.scores-standings-card .standings-table th {
  text-align: left;
  font-size: 0.6rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-tertiary);
  font-weight: 800;
  padding: 6px 8px;
  border-bottom: 1px solid var(--border-color);
  background: rgba(255, 255, 255, 0.03);
}
.scores-standings-card .standings-table td {
  padding: 7px 8px;
  border-bottom: 1px solid var(--border-color);
  vertical-align: middle;
}
.scores-standings-card .standings-table tbody tr:last-child td { border-bottom: none; }
.scores-standings-card .standings-table .st-rank-col { width: 32px; text-align: center; }
.scores-standings-card .standings-table .st-num-col { width: 56px; text-align: right; font-family: var(--font-mono); font-weight: 700; }
.scores-standings-card .standings-table .st-rank-num { font-weight: 800; font-family: var(--font-mono); color: var(--sport-accent, var(--text-secondary)); font-size: 0.82rem; }
.scores-standings-card .standings-name { font-weight: 700; line-height: 1.2; }
.scores-standings-card .standings-team {
  display: inline-block;
  font-size: 0.62rem;
  color: var(--text-tertiary);
  margin-left: 6px;
}
.scores-standings-card .standings-row.highlighted {
  background: var(--accent-soft);
  position: relative;
}
.scores-standings-card .standings-row.highlighted td:first-child {
  border-left: 3px solid var(--sport-accent, var(--accent-color));
}

/* Structured table widget — comparisons + ranked lists + plain tables */
.structured-table-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 14px 16px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-l);
  max-width: 600px;
  font-family: var(--font-sans);
}
.structured-table-card .st-title {
  font-size: 0.95rem;
  font-weight: 800;
  letter-spacing: -0.01em;
}
.structured-table-card .st-sub {
  font-size: 0.72rem;
  color: var(--text-secondary);
  margin-top: -2px;
}
.structured-table-card .st-scroll {
  overflow-x: auto;
  margin: 0 -4px;
}
.structured-table-card .st-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.78rem;
}
.structured-table-card .st-table th,
.structured-table-card .st-table td {
  padding: 8px 10px;
  text-align: left;
  border-bottom: 1px solid var(--border-color);
  vertical-align: top;
}
.structured-table-card .st-table th {
  font-size: 0.66rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-tertiary);
  background: rgba(255, 255, 255, 0.03);
  font-weight: 700;
  white-space: nowrap;
}
.structured-table-card .st-table tbody tr:last-child td { border-bottom: none; }
.structured-table-card .st-table tbody tr:hover { background: rgba(255, 255, 255, 0.02); }
.structured-table-card .st-row-label {
  font-weight: 800;
  color: var(--text-primary);
  font-size: 0.74rem;
}
.structured-table-card .st-prod-img {
  width: 56px;
  height: 56px;
  object-fit: contain;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-color);
  display: block;
  margin: 0 auto 6px;
}
.structured-table-card .st-prod-img.inline {
  width: 32px;
  height: 32px;
  display: inline-block;
  vertical-align: middle;
  margin: 0 8px 0 0;
}
.structured-table-card .st-rank {
  width: 32px;
  text-align: center;
  font-family: var(--font-mono);
  font-weight: 800;
  color: var(--accent-color);
  font-size: 0.84rem;
}
.structured-table-card.kind-comparison .st-table th:not(:first-child) {
  background: var(--accent-soft);
  color: var(--text-primary);
}
.structured-table-card .st-foot {
  font-size: 0.66rem;
  color: var(--text-tertiary);
  padding-top: 6px;
  border-top: 1px dashed var(--border-color);
  font-style: italic;
}

/* Stock widget */
.stock-widget-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px 16px;
  background: linear-gradient(135deg, rgba(34, 211, 238, 0.04), rgba(139, 92, 246, 0.06));
  border: 1px solid var(--border-color);
  border-radius: var(--radius-l);
  max-width: 440px;
  font-family: var(--font-sans);
}
.stock-widget-card .stock-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
}
.stock-widget-card .stock-symbol {
  font-size: 1.4rem;
  font-weight: 850;
  letter-spacing: -0.02em;
  font-family: var(--font-mono);
}
.stock-widget-card .stock-name {
  font-size: 0.72rem;
  color: var(--text-secondary);
  margin-top: 2px;
}
.stock-widget-card .stock-exch {
  font-family: var(--font-mono);
  font-size: 0.62rem;
  color: var(--text-tertiary);
}
.stock-widget-card .stock-rating {
  font-size: 0.66rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 5px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  white-space: nowrap;
}
.stock-widget-card .rating-strongbuy { color: #16a34a; border-color: rgba(34, 197, 94, 0.4); background: rgba(34, 197, 94, 0.08); }
.stock-widget-card .rating-buy       { color: #22c55e; border-color: rgba(34, 197, 94, 0.3); background: rgba(34, 197, 94, 0.06); }
.stock-widget-card .rating-hold      { color: #f59e0b; border-color: rgba(245, 158, 11, 0.3); background: rgba(245, 158, 11, 0.06); }
.stock-widget-card .rating-sell      { color: #ef4444; border-color: rgba(239, 68, 68, 0.3); background: rgba(239, 68, 68, 0.06); }
.stock-widget-card .stock-price-row {
  display: flex;
  align-items: baseline;
  gap: 12px;
}
.stock-widget-card .stock-price {
  font-size: 1.9rem;
  font-weight: 850;
  font-family: var(--font-mono);
  letter-spacing: -0.02em;
}
.stock-widget-card .stock-curr {
  font-size: 0.72rem;
  color: var(--text-tertiary);
  font-weight: 600;
  margin-left: 4px;
}
.stock-widget-card .stock-change {
  font-size: 0.86rem;
  font-weight: 800;
  font-family: var(--font-mono);
}
.stock-widget-card .stock-spark {
  width: 100%;
  height: 56px;
  display: block;
  margin: 4px 0 -4px;
}
.stock-widget-card .stock-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(80px, 1fr));
  gap: 6px 12px;
  padding: 8px 10px;
  background: rgba(0, 0, 0, 0.15);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-m);
  font-size: 0.7rem;
}
.stock-widget-card .stock-stats > div {
  display: flex;
  flex-direction: column;
}
.stock-widget-card .stock-stats span {
  color: var(--text-tertiary);
  font-size: 0.6rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.stock-widget-card .stock-stats strong {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 0.78rem;
  color: var(--text-primary);
}
.stock-widget-card .stock-summary {
  font-size: 0.74rem;
  color: var(--text-secondary);
  font-style: italic;
  line-height: 1.45;
}
.stock-widget-card .stock-asof {
  font-size: 0.62rem;
  color: var(--text-tertiary);
  text-align: right;
}

/* Itinerary widget — multi-day expandable cards */
.itinerary-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px 16px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-l);
  max-width: 520px;
  font-family: var(--font-sans);
}
.itinerary-card .itin-head { margin-bottom: 2px; }
.itinerary-card .itin-title {
  font-size: 1rem;
  font-weight: 800;
  letter-spacing: -0.01em;
}
.itinerary-card .itin-sub {
  font-size: 0.74rem;
  color: var(--text-secondary);
  margin-top: 2px;
  line-height: 1.45;
}
.itinerary-card .itin-day {
  background: rgba(0, 0, 0, 0.18);
  border: 1px solid var(--border-color);
  border-left: 3px solid var(--accent-color);
  border-radius: var(--radius-m);
}
.itinerary-card .itin-day summary {
  list-style: none;
  cursor: pointer;
  padding: 10px 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  user-select: none;
}
.itinerary-card .itin-day summary::-webkit-details-marker { display: none; }
.itinerary-card .itin-day-num {
  font-family: var(--font-mono);
  font-size: 0.74rem;
  font-weight: 800;
  color: var(--accent-color);
  background: var(--accent-soft);
  padding: 2px 8px;
  border-radius: 999px;
}
.itinerary-card .itin-day-title {
  font-weight: 700;
  font-size: 0.84rem;
  flex: 1;
  min-width: 0;
}
.itinerary-card .itin-chev {
  font-size: 0.7rem;
  color: var(--text-tertiary);
  transition: transform 0.18s;
}
.itinerary-card .itin-day[open] .itin-chev { transform: rotate(180deg); }
.itinerary-card .itin-section {
  padding: 6px 12px 10px 12px;
}
.itinerary-card .itin-time {
  font-size: 0.66rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-tertiary);
  margin: 6px 0 4px;
}
.itinerary-card .itin-items {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.itinerary-card .itin-item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 0.78rem;
}
.itinerary-card .itin-emoji {
  font-size: 1rem;
  line-height: 1.2;
  flex-shrink: 0;
}
.itinerary-card .itin-label { font-weight: 700; }
.itinerary-card .itin-detail {
  color: var(--text-secondary);
  font-size: 0.72rem;
  margin-top: 1px;
  line-height: 1.4;
}
.itinerary-card .itin-tips {
  padding: 10px 12px;
  background: rgba(34, 211, 238, 0.05);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-m);
  font-size: 0.76rem;
}
.itinerary-card .itin-tips-head {
  font-weight: 800;
  margin-bottom: 4px;
  font-size: 0.72rem;
}
.itinerary-card .itin-tips ul {
  margin: 0;
  padding-left: 16px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  color: var(--text-secondary);
}

/* Knowledge card — entity (people, orgs, places, concepts, etc.) */
.knowledge-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px 16px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-l);
  max-width: 480px;
  font-family: var(--font-sans);
}
.knowledge-card .kc-head {
  display: flex;
  gap: 12px;
  align-items: flex-start;
}
.knowledge-card .kc-img,
.knowledge-card .kc-img-placeholder {
  width: 64px;
  height: 64px;
  border-radius: 12px;
  object-fit: cover;
  background: var(--accent-soft);
  border: 1px solid var(--border-color);
  flex-shrink: 0;
}
.knowledge-card .kc-img-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.8rem;
}
.knowledge-card .kc-id { min-width: 0; }
.knowledge-card .kc-title {
  font-size: 1rem;
  font-weight: 800;
  letter-spacing: -0.01em;
}
.knowledge-card .kc-sub {
  font-size: 0.74rem;
  color: var(--text-secondary);
  margin-top: 2px;
}
.knowledge-card .kc-summary {
  font-size: 0.8rem;
  color: var(--text-primary);
  line-height: 1.5;
}
.knowledge-card .kc-facts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 6px 12px;
  padding: 10px 12px;
  background: rgba(0, 0, 0, 0.15);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-m);
}
.knowledge-card .kc-fact {
  display: flex;
  flex-direction: column;
  font-size: 0.72rem;
}
.knowledge-card .kc-fact-label {
  font-size: 0.6rem;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 1px;
}
.knowledge-card .kc-fact-value {
  font-weight: 600;
  color: var(--text-primary);
}
.knowledge-card .kc-highlights {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.76rem;
}
.knowledge-card .kc-highlights li {
  padding-left: 4px;
  line-height: 1.45;
  color: var(--text-secondary);
}

/* Events Board (Copilot OS calendar) */
.events-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.event-card {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-color);
  border-left: 3px solid var(--accent-cyan);
  border-radius: var(--radius-m);
  padding: 8px 10px;
  font-family: var(--font-sans);
}
.event-card .event-card-time {
  font-size: 0.62rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--accent-cyan);
  font-weight: 700;
  font-family: var(--font-mono);
  margin-bottom: 2px;
}
.event-card .event-card-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 6px;
}
.event-card .event-card-title {
  font-weight: 800;
  font-size: 0.8rem;
  color: var(--text-primary);
  flex: 1;
  min-width: 0;
}
.event-card .event-del-btn {
  background: transparent;
  border: none;
  color: var(--text-tertiary);
  cursor: pointer;
  padding: 2px 4px;
  font-size: 0.7rem;
  border-radius: 4px;
  transition: all var(--transition-fast);
}
.event-card .event-del-btn:hover { color: #ef4444; background: rgba(239, 68, 68, 0.1); }
.event-card .event-card-loc {
  font-size: 0.7rem;
  color: var(--text-secondary);
  margin-top: 4px;
}
.event-card .event-card-loc i { color: var(--accent-color); margin-right: 4px; font-size: 0.66rem; }
.event-card .event-card-desc {
  font-size: 0.7rem;
  color: var(--text-secondary);
  margin-top: 4px;
  line-height: 1.4;
}

/* Calendar widget — event dots on day cells + upcoming list */
.calendar-cell.has-event { position: relative; font-weight: 700; }
.calendar-cell .cal-event-dot {
  position: absolute;
  bottom: 3px;
  right: 3px;
  min-width: 14px;
  height: 14px;
  padding: 0 4px;
  background: var(--accent-cyan);
  color: white;
  font-size: 0.55rem;
  font-weight: 800;
  border-radius: 999px;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}
.calendar-widget-card .cal-upcoming {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border-color);
}
.calendar-widget-card .cal-upcoming-head {
  font-size: 0.62rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-tertiary);
  font-weight: 800;
  margin-bottom: 6px;
}
.calendar-widget-card .cal-upcoming-item {
  display: grid;
  grid-template-columns: 110px 1fr;
  gap: 8px;
  padding: 4px 0;
  align-items: start;
  font-size: 0.72rem;
}
.calendar-widget-card .cal-upcoming-when {
  font-family: var(--font-mono);
  font-size: 0.62rem;
  color: var(--accent-cyan);
  font-weight: 700;
}
.calendar-widget-card .cal-upcoming-title { font-weight: 700; line-height: 1.3; }
.calendar-widget-card .cal-upcoming-loc {
  font-size: 0.62rem;
  color: var(--text-tertiary);
  margin-top: 1px;
}

/* Notes Board (sidebar + inline list widget) */
.notes-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.note-card {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-color);
  border-left: 3px solid var(--accent-color);
  border-radius: var(--radius-m);
  padding: 8px 10px;
  font-family: var(--font-sans);
}
.note-card .note-card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 6px;
  margin-bottom: 2px;
}
.note-card .note-card-title {
  font-weight: 800;
  font-size: 0.8rem;
  color: var(--text-primary);
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.note-card .note-del-btn {
  background: transparent;
  border: none;
  color: var(--text-tertiary);
  cursor: pointer;
  padding: 2px 4px;
  font-size: 0.7rem;
  border-radius: 4px;
  transition: all var(--transition-fast);
}
.note-card .note-del-btn:hover {
  color: #ef4444;
  background: rgba(239, 68, 68, 0.1);
}
.note-card .note-card-body {
  font-size: 0.72rem;
  color: var(--text-secondary);
  line-height: 1.45;
  white-space: pre-wrap;
  word-wrap: break-word;
}
.note-card .note-card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 6px;
}
.note-card .note-tag {
  font-size: 0.6rem;
  padding: 1px 6px;
  background: var(--accent-soft);
  color: var(--accent-color);
  border-radius: 999px;
  font-weight: 700;
}

/* Image attachments (paste / drag / click-to-attach) */
.attachment-strip {
  display: flex;
  gap: 8px;
  padding: 8px 12px 0;
  flex-wrap: wrap;
}
.attachment-thumb {
  position: relative;
  width: 64px;
  height: 64px;
  border-radius: var(--radius-m);
  overflow: hidden;
  border: 1px solid var(--border-color);
  background: rgba(0, 0, 0, 0.3);
}
.attachment-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.attachment-thumb .attachment-remove {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 18px;
  height: 18px;
  padding: 0;
  border: none;
  background: rgba(0, 0, 0, 0.75);
  color: white;
  border-radius: 50%;
  font-size: 0.78rem;
  font-weight: 800;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}
.attachment-thumb .attachment-remove:hover {
  background: #ef4444;
}
.attachment-thumb .attachment-meta {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  font-size: 0.56rem;
  font-family: var(--font-mono);
  color: white;
  background: linear-gradient(180deg, transparent, rgba(0,0,0,0.7));
  padding: 4px 4px 2px;
  text-align: center;
}
.bubble-attached-image {
  display: block;
  max-width: 260px;
  max-height: 320px;
  border-radius: var(--radius-m);
  margin-bottom: 6px;
  border: 1px solid var(--border-color);
}
.query-box-container.drop-target-active {
  outline: 2px dashed var(--accent-color);
  outline-offset: -8px;
  background: var(--accent-soft);
}

/* Places sources block — actual references gemini used */
.places-sources {
  margin-top: 4px;
  padding-top: 8px;
  border-top: 1px dashed var(--border-color);
}
.places-sources summary {
  cursor: pointer;
  font-size: 0.7rem;
  color: var(--text-secondary);
  list-style: none;
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 600;
  user-select: none;
}
.places-sources summary::-webkit-details-marker { display: none; }
.places-sources summary:hover { color: var(--text-primary); }
.places-sources summary i { color: var(--accent-color); font-size: 0.66rem; }
.places-sources[open] summary { margin-bottom: 6px; }
.places-sources-list {
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.places-source-link {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  font-size: 0.68rem;
  color: var(--text-secondary);
  background: rgba(0, 0, 0, 0.15);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-s);
  text-decoration: none;
  transition: all var(--transition-fast);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.places-source-link:hover {
  color: var(--text-primary);
  border-color: var(--accent-color);
  background: var(--accent-soft);
}
.places-source-link i {
  color: var(--accent-color);
  font-size: 0.6rem;
  flex-shrink: 0;
}
.places-source-link span {
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Flight search widget (multi-option list + deep links) */
.flight-search-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px 16px;
  background: linear-gradient(135deg, rgba(34, 211, 238, 0.06), rgba(139, 92, 246, 0.04));
  border: 1px solid var(--border-color);
  border-radius: var(--radius-l);
  max-width: 460px;
  font-family: var(--font-sans);
}
.flight-search-head .flight-search-route {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 1rem;
  font-weight: 800;
  letter-spacing: -0.01em;
}
.flight-search-head .flight-search-route .iata {
  font-family: var(--font-mono);
  font-size: 0.62rem;
  color: var(--text-tertiary);
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-color);
  padding: 2px 6px;
  border-radius: 5px;
  font-weight: 700;
}
.flight-search-head .flight-search-route i {
  font-size: 0.85rem;
}
.flight-search-head .flight-search-sub {
  font-size: 0.72rem;
  color: var(--text-secondary);
  margin-top: 2px;
}
.flight-opts {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 4px;
}
.flight-opt {
  display: grid;
  grid-template-columns: 1.2fr 1.4fr auto;
  gap: 10px;
  padding: 8px 10px;
  align-items: center;
  background: rgba(0, 0, 0, 0.18);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-m);
  font-size: 0.74rem;
}
.flight-opt .flight-opt-airline {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 700;
}
.flight-opt .flight-opt-airline i {
  color: var(--accent-cyan);
  font-size: 0.78rem;
}
.flight-opt .flight-opt-stops {
  font-weight: 500;
  color: var(--text-tertiary);
  font-size: 0.66rem;
}
.flight-opt .flight-opt-times {
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-mono);
  color: var(--text-primary);
}
.flight-opt .flight-opt-times .flight-opt-dur {
  font-family: var(--font-sans);
  font-size: 0.66rem;
  color: var(--text-tertiary);
  margin-left: 6px;
}
.flight-opt .flight-opt-times i {
  color: var(--text-tertiary);
  font-size: 0.7rem;
}
.flight-opt .flight-opt-price {
  font-weight: 800;
  font-size: 0.86rem;
  color: var(--accent-cyan);
  font-family: var(--font-mono);
  text-align: right;
}
.flight-opt-empty {
  font-size: 0.74rem;
  color: var(--text-secondary);
  font-style: italic;
  padding: 6px 0;
}
.flight-search-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 4px;
  padding-top: 10px;
  border-top: 1px solid var(--border-color);
}
.flight-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.74rem;
  font-weight: 700;
  padding: 7px 14px;
  border-radius: 999px;
  background: var(--bg-card);
  border: 1px solid var(--border-color-hover);
  color: var(--text-primary);
  text-decoration: none;
  transition: all var(--transition-fast);
}
.flight-link:hover {
  background: var(--bg-card-hover);
  border-color: var(--accent-color);
  transform: translateY(-1px);
}
.flight-link.primary {
  background: var(--accent-color);
  color: white;
  border-color: var(--accent-color);
}
.flight-link.primary:hover {
  filter: brightness(1.1);
}

/* iMessage-style tap-back reactions on assistant bubbles (regular + .imsg-card).
   Both bubble flavours need the same hover-to-reveal picker so iMessage display
   mode has parity with widgets mode. Preview cards are excluded — there's
   nothing to react to until the real bubble arrives. */
.chat-message-row.assistant .message-bubble,
.chat-message-row.assistant .imsg-card:not(.imsg-card-preview) {
  position: relative;
}
.chat-message-row.assistant .message-bubble .tapback-picker,
.chat-message-row.assistant .imsg-card:not(.imsg-card-preview) .tapback-picker {
  position: absolute;
  top: -38px;
  right: 8px;
  display: flex;
  gap: 2px;
  padding: 4px 8px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 999px;
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.35);
  opacity: 0;
  pointer-events: none;
  transform: translateY(6px);
  transition: opacity 0.18s ease, transform 0.18s ease;
  z-index: 5;
}
.chat-message-row.assistant .message-bubble:hover .tapback-picker,
.chat-message-row.assistant .message-bubble .tapback-picker:hover,
.chat-message-row.assistant .message-bubble:focus-within .tapback-picker,
.chat-message-row.assistant .imsg-card:hover .tapback-picker,
.chat-message-row.assistant .imsg-card .tapback-picker:hover,
.chat-message-row.assistant .imsg-card:focus-within .tapback-picker {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}
.tapback-react {
  background: transparent;
  border: none;
  font-size: 1rem;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 50%;
  line-height: 1;
  transition: transform 0.1s ease, background 0.15s ease;
}
.tapback-react:hover {
  background: var(--accent-soft);
  transform: scale(1.25);
}
.tapback-badge {
  position: absolute;
  bottom: -10px;
  right: -8px;
  width: 28px;
  height: 28px;
  background: var(--bg-card);
  border: 2px solid var(--bg-app);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.92rem;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
  animation: tapbackPop 0.32s cubic-bezier(0.34, 1.56, 0.64, 1);
  z-index: 4;
}
@keyframes tapbackPop {
  0% { transform: scale(0.2); opacity: 0; }
  60% { transform: scale(1.15); opacity: 1; }
  100% { transform: scale(1); opacity: 1; }
}
.message-bubble[data-tapback-used="1"] {
  opacity: 0.85;
}

/* Clarification chips — tappable suggested replies when QB is uncertain */
.clarify-chips-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px 12px;
  border: 1px solid rgba(34, 211, 238, 0.25);
  background: rgba(34, 211, 238, 0.04);
  border-radius: var(--radius-m);
  max-width: 560px;
}
.clarify-chips-card .clarify-chips-label {
  font-size: 0.7rem;
  color: var(--text-secondary);
}
.clarify-chips-card .clarify-chips-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.chip-btn {
  display: inline-flex;
  align-items: center;
  font-family: var(--font-sans);
  font-size: 0.74rem;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--border-color-hover);
  background: var(--bg-card);
  color: var(--text-primary);
  cursor: pointer;
  transition: all var(--transition-fast);
  outline: none;
}
.chip-btn:hover:not(:disabled) {
  background: var(--accent-soft);
  border-color: var(--accent-color);
  transform: translateY(-1px);
}
.chip-btn:disabled {
  opacity: 0.5;
  cursor: default;
  transform: none;
}
.chip-btn.chip-chosen {
  background: var(--accent-color);
  color: white;
  border-color: var(--accent-color);
  opacity: 1;
}

/* Habit suggestion card (post-reply background detector) */
.habit-suggestion-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px 14px;
  border: 1px solid var(--accent-soft-border, rgba(139, 92, 246, 0.3));
  background: linear-gradient(135deg, rgba(139, 92, 246, 0.06), rgba(34, 211, 238, 0.04));
  border-radius: var(--radius-m);
  max-width: 440px;
}
.habit-suggestion-card .habit-head {
  display: flex;
  gap: 10px;
  align-items: flex-start;
}
.habit-suggestion-card .habit-title {
  font-weight: 800;
  font-size: 0.82rem;
}
.habit-suggestion-card .habit-sub {
  font-size: 0.72rem;
  color: var(--text-secondary);
  margin-top: 2px;
}
.habit-suggestion-card .habit-body {
  font-size: 0.78rem;
  line-height: 1.45;
  color: var(--text-primary);
}
.habit-suggestion-card .habit-actions {
  display: flex;
  gap: 8px;
}
.habit-suggestion-card .habit-actions .btn {
  font-size: 0.72rem;
  padding: 6px 12px;
}

.btn-group {
  display: flex;
  gap: 8px;
}

.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: var(--font-sans);
  font-size: 0.82rem;
  font-weight: 700;
  padding: 8px 16px;
  border-radius: var(--radius-m);
  cursor: pointer;
  transition: all var(--transition-fast);
  outline: none;
  border: none;
}

.btn-accent {
  background: var(--accent-color);
  color: var(--text-inverse);
}

.btn-accent:hover {
  background: var(--accent-color-hover);
  box-shadow: var(--shadow-glow-purple);
}

.btn-outlined {
  background: none;
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
}

.btn-outlined:hover {
  color: var(--text-primary);
  border-color: var(--text-secondary);
  background: var(--bg-card);
}

.btn-danger {
  background: #ef4444;
  color: white;
}

.btn-danger:hover {
  background: #dc2626;
  box-shadow: 0 0 10px rgba(239, 68, 68, 0.3);
}

/* Autocomplete Slash Commands Overlay Menu */
.slash-menu {
  position: absolute;
  bottom: calc(100% - 10px);
  left: 32px;
  width: 300px;
  max-width: calc(100% - 64px);
  background: var(--bg-sidebar);
  border: var(--glass-border);
  box-shadow: var(--glass-shadow);
  backdrop-filter: var(--glass-blur);
  border-radius: var(--radius-l);
  padding: 8px;
  z-index: 10;
  display: flex;
  flex-direction: column;
  gap: 4px;
  transition: width 0.2s ease;
}

.slash-menu-title {
  font-size: 0.65rem;
  font-weight: 800;
  text-transform: uppercase;
  color: var(--text-tertiary);
  padding: 4px 10px;
  border-bottom: 1px solid var(--border-color);
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  cursor: pointer;
  user-select: none;
}
.slash-menu-title:hover { color: var(--text-primary); }

.slash-count {
  font-family: var(--font-mono);
  font-size: 0.6rem;
  font-weight: 700;
  color: var(--accent-color);
  background: var(--accent-soft);
  padding: 1px 6px;
  border-radius: 999px;
  margin-left: 4px;
}

.slash-min-btn {
  background: transparent;
  border: none;
  color: var(--text-tertiary);
  cursor: pointer;
  padding: 2px 6px;
  border-radius: var(--radius-s);
  transition: all 0.15s ease;
  font-size: 0.7rem;
}
.slash-min-btn:hover {
  color: var(--accent-color);
  background: var(--accent-soft);
}

.slash-options-wrap {
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-height: 320px;
  overflow-y: auto;
  transition: max-height 0.2s ease, opacity 0.15s ease;
}

/* Minimized state: collapse to just the title bar */
.slash-menu.minimized {
  width: auto;
  min-width: 180px;
  padding: 6px 8px;
}
.slash-menu.minimized .slash-menu-title {
  border-bottom: none;
  margin-bottom: 0;
  padding: 2px 6px;
}
.slash-menu.minimized .slash-options-wrap {
  max-height: 0;
  opacity: 0;
  overflow: hidden;
  pointer-events: none;
}

.slash-option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 10px;
  border-radius: var(--radius-m);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.slash-option:hover {
  background: var(--accent-soft);
}

.slash-option .cmd-name {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--accent-color);
}

.slash-option .cmd-desc {
  font-size: 0.72rem;
  color: var(--text-secondary);
}

/* ==========================================================================
   MARKDOWN PARSING RENDERINGS OVERRIDES
   ========================================================================== */

.markdown-body {
  font-size: 0.92rem;
  line-height: 1.62;
}

.markdown-body p {
  margin-bottom: 12px;
}

.markdown-body p:last-child {
  margin-bottom: 0;
}

.markdown-body h1, .markdown-body h2, .markdown-body h3 {
  margin-top: 18px;
  margin-bottom: 8px;
  color: var(--text-primary);
}

.markdown-body h2 { font-size: 1.15rem; }
.markdown-body h3 { font-size: 1.02rem; }

.markdown-body ul, .markdown-body ol {
  padding-left: 20px;
  margin-bottom: 12px;
}

.markdown-body li {
  margin-bottom: 4px;
}

.markdown-body code {
  background: rgba(0, 0, 0, 0.15);
  padding: 2px 6px;
  border-radius: var(--radius-s);
  font-size: 0.8rem;
  border: 1px solid var(--border-color);
  color: #ec4899;
}

.markdown-body pre {
  background: rgba(0, 0, 0, 0.25);
  padding: 12px;
  border-radius: var(--radius-m);
  border: 1px solid var(--border-color);
  overflow-x: auto;
  margin: 12px 0;
}

.markdown-body pre code {
  background: none;
  padding: 0;
  border: none;
  color: inherit;
  font-size: 0.8rem;
}

/* Citation superscript links inside markdown text */
.citation-ref {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-size: 0.65rem;
  font-weight: 700;
  vertical-align: super;
  background: var(--accent-cyan-soft);
  color: var(--accent-cyan);
  border: 1px solid rgba(6, 182, 212, 0.2);
  width: 14px;
  height: 14px;
  border-radius: 3px;
  margin: 0 2px;
  cursor: pointer;
  transition: all var(--transition-fast);
  text-decoration: none;
}

.citation-ref:hover {
  background: var(--accent-cyan);
  color: var(--text-inverse);
  transform: scale(1.1);
}

/* ==========================================================================
   DYNAMIC KEYFRAME ANIMATIONS
   ========================================================================== */

/* Waivy's brand-blue pulse. Variable name kept for backwards compatibility
 * with the many call sites — only the color shifted to the iMessage-blue
 * accent. */
@keyframes pulse-glow-purple {
  0%, 100% {
    box-shadow: 0 0 10px rgba(var(--accent-color-rgb, 10, 132, 255), 0.18),
                inset 0 0 4px rgba(var(--accent-color-rgb, 10, 132, 255), 0.1);
  }
  50% {
    box-shadow: 0 0 22px rgba(var(--accent-color-rgb, 10, 132, 255), 0.45),
                inset 0 0 8px rgba(var(--accent-color-rgb, 10, 132, 255), 0.25);
  }
}

@keyframes pulse-node {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.05); }
}

@keyframes status-pulsate {
  0% {
    transform: scale(0.92);
    box-shadow: 0 0 0 0 currentColor;
  }
  70% {
    transform: scale(1);
    box-shadow: 0 0 0 6px rgba(0,0,0,0);
  }
  100% {
    transform: scale(0.92);
    box-shadow: 0 0 0 0 rgba(0,0,0,0);
  }
}

@keyframes laser-flow {
  0% { left: 0%; opacity: 0; }
  25% { opacity: 1; }
  75% { opacity: 1; }
  100% { left: 100%; opacity: 0; }
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

@keyframes chat-bubble-pop {
  0% { transform: scale(0.95) translateY(10px); opacity: 0; }
  100% { transform: scale(1) translateY(0); opacity: 1; }
}

@keyframes slide-in-memory {
  0% { transform: translateX(-15px); opacity: 0; }
  100% { transform: translateX(0); opacity: 1; }
}

@keyframes plane-fly {
  0% { left: 0%; }
  100% { left: 100%; }
}

/* ==========================================================================
   RESPONSIVE DESIGN (Adaptive Grid)
   ========================================================================== */

@media (max-width: 992px) {
  /* Stack sidebar above main console, but KEEP heights bounded so the chat
     scrolls internally and the input stays pinned at the viewport bottom. */
  .workspace-grid {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(120px, 32vh) 1fr;
    height: calc(100vh - 65px);
    overflow: hidden;
  }

  .sidebar-panel {
    border-right: none;
    border-bottom: 1px solid var(--border-color);
    /* height: 100% from base — sidebar-scrollable stays internally scrollable */
  }
}

/* ==========================================================================
   iMESSAGE-STYLE STACK + NEW WIDGETS  (v2)
   ========================================================================== */

/* Bubble stack: tight vertical group with a single author header */
.im-row .bubble-stack {
  display: flex;
  flex-direction: column;
  gap: 4px;
  width: 100%;
  align-items: flex-start;
}
.chat-message-row.user .bubble-stack { align-items: flex-end; }

.im-bubble {
  animation: chat-bubble-pop 0.28s cubic-bezier(.4,0,.2,1);
  padding: 10px 16px;
  max-width: 82%;
}
.chat-message-row.user .im-bubble {
  border-bottom-right-radius: 4px;
}
.chat-message-row.user .im-bubble + .im-bubble {
  border-top-right-radius: 4px;
}
.chat-message-row.assistant .im-bubble {
  border-bottom-left-radius: 4px;
}
.chat-message-row.assistant .im-bubble + .im-bubble {
  border-top-left-radius: 4px;
}

/* Attachment area sits BELOW the bubble stack for the row */
.im-row .attachment-stack {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 8px;
  width: 100%;
  align-items: flex-start;
}
.chat-message-row.user .attachment-stack { align-items: flex-end; }

/* Typing dots + iMessage-style thinking bubble with morphing label */
.typing-bubble,
.thinking-bubble {
  display: inline-flex !important;
  align-self: flex-start;
  gap: 5px;
  padding: 10px 14px !important;
  align-items: center;
  max-width: fit-content !important;
}
.typing-bubble .td,
.thinking-bubble .td {
  width: 7px; height: 7px;
  background: var(--text-tertiary);
  border-radius: 50%;
  opacity: 0.5;
  animation: td-bounce 1.1s infinite ease-in-out;
}
.typing-bubble .td:nth-child(2),
.thinking-bubble .td:nth-child(2) { animation-delay: 0.15s; }
.typing-bubble .td:nth-child(3),
.thinking-bubble .td:nth-child(3) { animation-delay: 0.3s; }

.thinking-bubble .thinking-label {
  font-size: 0.78rem;
  color: var(--text-tertiary);
  font-style: italic;
  margin-left: 6px;
  letter-spacing: 0.01em;
  transition: opacity 0.14s ease;
  white-space: nowrap;
}
.thinking-bubble .thinking-label.empty { display: none; }
.thinking-bubble .thinking-label.fading { opacity: 0; }

@keyframes td-bounce {
  0%, 80%, 100% { transform: scale(0.7); opacity: 0.4; }
  40%           { transform: scale(1);   opacity: 1; }
}

/* System info bubble */
.system-bubble {
  background: var(--bg-sidebar) !important;
  border: var(--glass-border);
  font-size: 0.76rem;
  color: var(--text-secondary);
  padding: 7px 14px !important;
  border-radius: var(--radius-m) !important;
  text-align: center;
  max-width: 60%;
  box-shadow: none !important;
  display: flex !important;
  align-items: center;
  gap: 8px;
}
.system-bubble::after { display: none !important; }

/* Slash help grid */
.slash-help-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 4px;
  margin-top: 8px;
  max-height: 320px;
  overflow-y: auto;
}
.slash-help-row {
  display: flex;
  gap: 10px;
  align-items: baseline;
  padding: 4px 6px;
  border-radius: var(--radius-s);
  font-size: 0.78rem;
}
.slash-help-row code {
  font-family: var(--font-mono);
  font-weight: 700;
  color: var(--accent-color);
  background: var(--accent-soft);
  padding: 1px 6px;
  border-radius: 4px;
  min-width: 100px;
}
.slash-help-row span { color: var(--text-secondary); }

/* "Me" profile grid */
.me-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 4px 12px;
  font-size: 0.78rem;
  margin-top: 4px;
}
.me-grid b { color: var(--text-tertiary); font-weight: 600; }

/* Maps widget */
.maps-widget-card {
  background: var(--bg-card);
  border: var(--glass-border);
  border-radius: var(--radius-m);
  overflow: hidden;
  width: 100%;
  max-width: 440px;
  box-shadow: var(--glass-shadow);
}
.maps-header {
  display: flex; gap: 10px; align-items: center;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border-color);
}
.maps-header .maps-title { font-weight: 700; font-size: 0.9rem; }
.maps-header .maps-sub   { font-size: 0.72rem; color: var(--text-tertiary); }
.maps-pin-stage {
  position: relative;
  height: 140px;
  background:
    radial-gradient(circle at 60% 50%, rgba(var(--accent-color-rgb),0.18), transparent 50%),
    linear-gradient(135deg, rgba(var(--accent-cyan-rgb),0.08), rgba(var(--accent-color-rgb),0.06));
}
.maps-pin {
  position: absolute;
  left: 50%; top: 50%;
  transform: translate(-50%, -100%);
  font-size: 2.2rem;
  color: var(--accent-color);
  filter: drop-shadow(0 4px 8px rgba(var(--accent-color-rgb), 0.4));
  animation: chat-bubble-pop 0.4s ease;
}
.maps-grid-overlay {
  position: absolute; inset: 0;
  background-image:
    linear-gradient(rgba(255,255,255,0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.04) 1px, transparent 1px);
  background-size: 24px 24px;
}
.maps-actions {
  display: flex; gap: 8px; padding: 10px 12px;
  border-top: 1px solid var(--border-color);
}
.maps-btn {
  flex: 1; text-align: center;
  padding: 8px 10px;
  border-radius: var(--radius-s);
  background: var(--bg-sidebar);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.74rem;
  font-weight: 600;
  display: flex; gap: 6px; justify-content: center; align-items: center;
  transition: all 0.15s ease;
}
.maps-btn:hover {
  border-color: var(--accent-color);
  color: var(--accent-color);
}

/* News widget */
.news-widget-card {
  background: var(--bg-card);
  border: var(--glass-border);
  border-radius: var(--radius-m);
  padding: 12px 14px;
  width: 100%;
  max-width: 440px;
  display: flex; flex-direction: column; gap: 8px;
  box-shadow: var(--glass-shadow);
}
.news-header {
  font-weight: 700; font-size: 0.85rem;
  display: flex; gap: 8px; align-items: center;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.news-list { display: flex; flex-direction: column; gap: 8px; }
.news-item {
  background: rgba(255,255,255,0.03);
  border-radius: var(--radius-s);
  padding: 8px 10px;
  border-left: 3px solid var(--accent-color);
}
.news-source {
  font-size: 0.65rem; color: var(--text-tertiary);
  text-transform: uppercase; letter-spacing: 0.05em;
  font-weight: 700;
}
.news-source span { color: var(--accent-cyan); font-weight: 600; }
.news-title { font-size: 0.84rem; color: var(--text-primary); margin-top: 2px; line-height: 1.35; }

/* Translate widget */
.translate-widget-card {
  background: var(--bg-card);
  border: var(--glass-border);
  border-radius: var(--radius-m);
  padding: 12px 14px;
  width: 100%;
  max-width: 440px;
  display: flex; flex-direction: column; gap: 6px;
  box-shadow: var(--glass-shadow);
}
.translate-row {
  background: rgba(255,255,255,0.03);
  border-radius: var(--radius-s);
  padding: 8px 10px;
}
.translate-row.translate-target {
  background: var(--accent-soft);
  border: 1px solid rgba(var(--accent-color-rgb), 0.2);
}
.translate-lang {
  font-size: 0.6rem; font-weight: 800;
  color: var(--text-tertiary);
  text-transform: uppercase; letter-spacing: 0.1em;
  margin-bottom: 2px;
}
.translate-row.translate-target .translate-lang { color: var(--accent-color); }
.translate-text { font-size: 0.92rem; line-height: 1.4; }
.translate-divider { text-align: center; color: var(--text-tertiary); padding: 2px 0; }

/* Define widget */
.define-widget-card {
  background: var(--bg-card);
  border: var(--glass-border);
  border-radius: var(--radius-m);
  padding: 12px 14px;
  width: 100%;
  max-width: 440px;
  box-shadow: var(--glass-shadow);
}
.define-head { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.define-word { font-size: 1.2rem; font-weight: 800; color: var(--text-primary); }
.define-phon { font-family: var(--font-mono); color: var(--text-tertiary); font-size: 0.78rem; }
.define-pos  { font-size: 0.65rem; text-transform: uppercase; letter-spacing: 0.06em;
               color: var(--accent-color); font-weight: 700;
               background: var(--accent-soft); padding: 2px 8px; border-radius: 999px; }
.define-body { margin-top: 8px; font-size: 0.86rem; line-height: 1.5; color: var(--text-secondary); }
.define-eg   { margin-top: 6px; font-size: 0.78rem; color: var(--text-tertiary); }

/* Currency widget */
.currency-widget-card {
  background: var(--bg-card);
  border: var(--glass-border);
  border-radius: var(--radius-m);
  padding: 14px;
  width: 100%;
  max-width: 360px;
  display: flex; flex-direction: column; gap: 8px;
  box-shadow: var(--glass-shadow);
}
.currency-row {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
}
.currency-amt {
  font-family: var(--font-mono);
  font-size: 1.4rem; font-weight: 800;
  color: var(--text-primary);
}
.currency-amt.strong { color: var(--accent-cyan); }
.currency-code {
  font-size: 0.7rem; font-weight: 700;
  color: var(--text-tertiary);
  text-transform: uppercase; letter-spacing: 0.08em;
}
.currency-foot {
  font-size: 0.7rem; color: var(--text-tertiary);
  text-align: center;
  border-top: 1px solid var(--border-color);
  padding-top: 6px;
}

/* Timer widget */
.timer-widget-card {
  background: var(--bg-card);
  border: var(--glass-border);
  border-radius: var(--radius-m);
  padding: 14px;
  width: 100%;
  max-width: 280px;
  display: flex; flex-direction: column; gap: 10px;
  align-items: center;
  box-shadow: var(--glass-shadow);
}
.timer-label { font-size: 0.78rem; color: var(--text-secondary); font-weight: 600; }
.timer-display {
  font-family: var(--font-mono);
  font-size: 2.4rem; font-weight: 850;
  color: var(--accent-cyan);
  text-shadow: 0 0 14px rgba(var(--accent-cyan-rgb), 0.3);
  transition: color 0.3s;
}
.timer-display.done {
  color: #ef4444;
  text-shadow: 0 0 14px rgba(239, 68, 68, 0.5);
  animation: chat-bubble-pop 0.4s ease;
}
.timer-controls {
  display: flex; gap: 8px;
}
.timer-controls .btn {
  padding: 6px 14px; font-size: 0.78rem;
}

/* Slash autocomplete improvements */
.slash-option .cmd-name {
  display: inline-flex; gap: 6px; align-items: center;
}
.slash-option .cmd-name i { color: var(--accent-color); width: 14px; text-align: center; }

/* ── Live flight status widget (sunny-prism flight-status skill) ── */
.flight-status-live {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 14px 16px;
  background: linear-gradient(135deg, rgba(34, 211, 238, 0.08), rgba(139, 92, 246, 0.04));
  border: 1px solid var(--border-color);
  border-radius: var(--radius-l);
  max-width: 480px;
  font-family: var(--font-sans);
}
.fsl-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 0.85rem;
}
.fsl-title { font-weight: 700; }
.fsl-title i { margin-right: 4px; }
.fsl-status {
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 0.62rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.fsl-status.scheduled { background: rgba(148, 163, 184, 0.18); color: #94a3b8; }
.fsl-status.boarding  { background: rgba(56, 189, 248, 0.18); color: #38bdf8; }
.fsl-status.in-air    { background: rgba(34, 211, 238, 0.2);  color: #22d3ee; }
.fsl-status.landed    { background: rgba(74, 222, 128, 0.18); color: #4ade80; }
.fsl-status.delayed   { background: rgba(251, 191, 36, 0.18); color: #fbbf24; }
.fsl-status.cancelled { background: rgba(248, 113, 113, 0.18); color: #f87171; }

.fsl-status-detail {
  font-size: 0.72rem;
  color: var(--text-secondary);
  margin-top: -4px;
}

.fsl-route {
  display: grid;
  grid-template-columns: 1fr 1.4fr 1fr;
  align-items: start;
  gap: 10px;
}
.fsl-endpoint {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}
.fsl-route > .fsl-endpoint:last-child { text-align: right; align-items: flex-end; }
.fsl-iata {
  font-family: var(--font-mono);
  font-weight: 800;
  font-size: 1.5rem;
  line-height: 1;
  color: var(--text-primary);
}
.fsl-city {
  font-size: 0.72rem;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.fsl-time { margin-top: 4px; display: flex; flex-direction: column; gap: 1px; }
.fsl-time-label {
  font-size: 0.55rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-tertiary);
}
.fsl-time-primary {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--text-primary);
}
.fsl-time-sched {
  font-size: 0.6rem;
  color: var(--text-tertiary);
  text-decoration: line-through;
}
.fsl-side {
  display: flex;
  gap: 8px;
  margin-top: 6px;
  font-size: 0.6rem;
  color: var(--text-secondary);
}
.fsl-side .lbl {
  display: block;
  font-size: 0.5rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-tertiary);
}
.fsl-side strong {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--text-primary);
}
.fsl-route > .fsl-endpoint:last-child .fsl-side { justify-content: flex-end; }

.fsl-path {
  position: relative;
  align-self: center;
  margin: 18px 0 0;
  height: 24px;
}
.fsl-track {
  position: absolute;
  inset: 50% 0 auto;
  height: 2px;
  background: var(--border-color);
  border-radius: 2px;
}
.fsl-progress {
  position: absolute;
  inset: 50% auto auto 0;
  height: 2px;
  background: linear-gradient(90deg, var(--accent-cyan), var(--accent-color));
  border-radius: 2px;
  transition: width 600ms ease-out;
}
.fsl-plane {
  position: absolute;
  top: 50%;
  transform: translate(-50%, -50%);
  color: var(--accent-cyan);
  font-size: 0.85rem;
  filter: drop-shadow(0 0 4px rgba(34, 211, 238, 0.5));
  transition: left 600ms ease-out;
}
.fsl-delays {
  position: absolute;
  top: calc(100% + 4px);
  left: 0; right: 0;
  display: flex;
  justify-content: center;
  gap: 6px;
}
.fsl-delay {
  font-size: 0.58rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 999px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.fsl-delay.late  { background: rgba(251, 191, 36, 0.18); color: #fbbf24; }
.fsl-delay.early { background: rgba(74, 222, 128, 0.18); color: #4ade80; }

.fsl-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  padding-top: 8px;
  border-top: 1px solid var(--border-color);
  font-size: 0.68rem;
  color: var(--text-secondary);
}
.fsl-meta-item { display: inline-flex; align-items: center; gap: 4px; }
.fsl-source {
  margin-left: auto;
  color: var(--accent-color);
  text-decoration: none;
  font-weight: 600;
}
.fsl-source:hover { text-decoration: underline; }

.flight-status-live.error { background: rgba(248, 113, 113, 0.06); }
.fsl-error {
  display: flex;
  gap: 12px;
  align-items: flex-start;
}
.fsl-error i { color: #f87171; font-size: 1.2rem; margin-top: 2px; }
.fsl-error strong { display: block; font-size: 0.85rem; }
.fsl-error p { margin: 2px 0 0; font-size: 0.72rem; color: var(--text-secondary); }

/* ── iMessage display mode ────────────────────────────────────────────── */
/* The toggle sits in the sidebar between Memory Bank and Task Board. */
.display-toggle {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  background: rgba(0, 0, 0, 0.18);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-m);
  padding: 4px;
}
.display-pill {
  padding: 7px 10px;
  border-radius: var(--radius-s);
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-family: var(--font-sans);
  font-weight: 700;
  font-size: 0.78rem;
  cursor: pointer;
  transition: all var(--transition-fast);
}
.display-pill.active {
  background: var(--accent-color);
  color: white;
}
.display-pill:hover:not(.active) { color: var(--text-primary); }
.display-hint {
  font-size: 0.7rem;
  color: var(--text-tertiary);
  margin-top: 8px;
  line-height: 1.4;
}

/* Streamed dynamic bubbles inherit the base .imsg-card pop animation. The
   prior translateY-only fade was duplicating; the spring on .imsg-card now
   carries the entrance. */

/* Preview card during Pass-1: shimmer + a three-dot "typing" badge in the
   bottom-right corner so the in-flight state reads as an actual handoff to
   the assistant rather than a generic loading shimmer. Padding-bottom grows
   to make room for the dots so the title/rule above stays uncrowded. */
.imsg-card-preview {
  position: relative;
  overflow: hidden;
  opacity: 0.95;
  padding-bottom: 22px;
  min-width: 180px;
}
.imsg-card-preview::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(
    100deg,
    transparent 30%,
    rgba(255,255,255,0.06) 50%,
    transparent 70%
  );
  background-size: 300% 100%;
  animation: imsg-card-shimmer 1.6s infinite linear;
  pointer-events: none;
}
.imsg-card-preview::before {
  content: '· · ·';
  position: absolute;
  right: 12px;
  bottom: 5px;
  font-size: 14px;
  letter-spacing: 2px;
  color: rgba(242,242,247,0.55);
  animation: imsg-preview-dots 1.1s infinite ease-in-out;
  pointer-events: none;
  font-family: -apple-system, "system-ui", sans-serif;
  line-height: 1;
}
@keyframes imsg-card-shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
@keyframes imsg-preview-dots {
  0%, 100% { opacity: 0.35; transform: translateY(0); }
  50%      { opacity: 1;    transform: translateY(-1px); }
}
[data-theme="light"] .imsg-card-preview::after {
  background: linear-gradient(
    100deg,
    transparent 30%,
    rgba(0,0,0,0.04) 50%,
    transparent 70%
  );
  background-size: 300% 100%;
}
[data-theme="light"] .imsg-card-preview::before {
  color: rgba(28,28,30,0.5);
}

/* A/B dynamic-iMessage toggle */
.dynamic-imsg-toggle {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin-top: 10px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  user-select: none;
}
.dynamic-imsg-toggle input { margin: 3px 0 0 0; flex-shrink: 0; }
.dynamic-imsg-label { display: flex; flex-direction: column; gap: 2px; font-size: 0.72rem; line-height: 1.35; }
.dynamic-imsg-label strong {
  color: var(--text-primary);
  font-size: 0.78rem;
  display: flex;
  align-items: center;
  gap: 6px;
}
.dynamic-imsg-badge {
  display: inline-flex;
  align-items: center;
  font-family: var(--font-mono);
  font-size: 0.55rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  padding: 1px 6px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-color);
  text-transform: uppercase;
}
.dynamic-imsg-hint { color: var(--text-tertiary); }

/* iMessage rich card — matches the design firm's EXACT iMessage bubble
   sandbox specs (extracted live from docs/imsg-design-system-v2.html):
     width    ~230px (NOT 320 — iPhone column is narrow)
     font     -apple-system / SF Pro
     size     16px
     line-h   20.48px = 1.28
     padding  7px 12px 8px (tight)
     radius   18 18 18 6  (tail bottom-left, the assistant/incoming side)
     bg/fg    oklch(0.92 ...) / oklch(0.16 ...) — system iMessage greys
   The card is pre-wrap text — every glyph (Unicode bold/italic/mono,
   ─ ━ · ▔ dividers, 🟢 status circles) is REAL text, so copy-pasting
   into the actual Messages app preserves the visual EXACTLY. */
.imsg-card {
  font-family: -apple-system, "system-ui", "Helvetica Neue", "Segoe UI", Roboto, sans-serif;
  background: oklch(0.92 0.005 250);
  color: oklch(0.16 0.01 250);
  /* Default fully-rounded; the last-of-run bubble gets the tail via :last-child below. */
  border-radius: 18px;
  padding: 7px 12px 8px;
  width: fit-content;
  /* iMessage's incoming bubble max-width is ~75% of screen width — on
   * our 393px iPhone display that's ~290px. Cards were capped at 230px
   * which forced text to wrap a line earlier than iMessage does. */
  max-width: 290px;
  font-size: 16px;
  line-height: 1.28;
  letter-spacing: -0.16px;
  white-space: pre-wrap;
  font-variant-numeric: tabular-nums;
  /* iMessage's spring on receive — tiny scale-in with a soft overshoot. */
  animation: imsg-card-pop 0.32s cubic-bezier(0.34, 1.45, 0.64, 1);
  transform-origin: bottom left;
  will-change: transform, opacity;
}
@keyframes imsg-card-pop {
  0%   { opacity: 0; transform: scale(0.86) translateY(4px); }
  60%  { opacity: 1; transform: scale(1.02) translateY(0); }
  100% { opacity: 1; transform: scale(1) translateY(0); }
}
/* Tail only on the last bubble of a same-author run. Inside attachment-stack
   the .imsg-card siblings come in a tight group; rounding the intermediates
   matches iMessage's grouped-bubble grammar. */
.imsg-card:last-child {
  border-radius: 18px 18px 18px 6px;
}
/* Tighten the vertical gap between consecutive .imsg-card siblings so a 3-
   bubble dynamic card reads as ONE message group rather than 3 separate sends.
   The parent .attachment-stack uses gap: 8px; pull adjacent .imsg-card up to
   3px effective gap. */
.imsg-card + .imsg-card {
  margin-top: -5px;
}
[data-theme="dark"] .imsg-card {
  background: oklch(0.22 0.005 250);
  color: oklch(0.96 0.005 250);
}
[data-theme="light"] .imsg-card {
  /* Unify on oklch so the light/dark transition stays in the same colour space —
   the previous hex was visually adjacent but mixed scales. */
  background: oklch(0.95 0.003 250);
  color: oklch(0.20 0.01 250);
}
.imsg-card a {
  color: #60a5fa;
  text-decoration: none;
  font-weight: 500;
}
.imsg-card a:hover { text-decoration: underline; }

.imsg-copy-btn {
  position: absolute;
  top: 10px;
  right: 12px;
  background: rgba(242,242,247,0.1);
  border: none;
  color: rgba(242,242,247,0.65);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 5px 9px;
  border-radius: 999px;
  cursor: pointer;
  user-select: none;
  transition: all 0.15s;
}
.imsg-copy-btn:hover { background: rgba(242,242,247,0.18); color: rgba(242,242,247,0.95); }
.imsg-copy-btn.copied { background: rgba(48,209,88,0.25); color: #30d158; }
[data-theme="light"] .imsg-copy-btn { background: rgba(28,28,30,0.08); color: rgba(28,28,30,0.6); }
[data-theme="light"] .imsg-copy-btn:hover { background: rgba(28,28,30,0.14); color: rgba(28,28,30,0.95); }
[data-theme="light"] .imsg-copy-btn.copied { background: rgba(48,209,88,0.18); color: #248a3d; }

.imsg-section {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

/* Header line — emoji + title, INLINE content so paste-as-plain-text
   keeps the whole title on one line. */
.imsg-head {
  font-size: 19px;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.25;
}
.imsg-head .imsg-light { font-weight: 400; }
.imsg-card .imsg-sep { color: rgba(242,242,247,0.5); font-weight: 400; }
[data-theme="light"] .imsg-card .imsg-sep { color: rgba(28,28,30,0.5); }

/* Subtitle — italicized context line under the title */
.imsg-sub {
  font-style: italic;
  font-size: 15px;
  color: rgba(242,242,247,0.65);
  margin-top: -4px;
}
[data-theme="light"] .imsg-sub { color: rgba(28,28,30,0.55); }

/* Full-width thin rule between sections. We hide the actual <hr> visually
   for the dash-text fallback to handle the plain-text paste, but if the
   rule lives in CSS only it has no paste presence — so we use a real
   text element that's invisible in the browser. See .imsg-rule-text below. */
.imsg-rule {
  border: none;
  border-top: 1px solid rgba(242,242,247,0.12);
  margin: 12px 0;
}
[data-theme="light"] .imsg-rule { border-top-color: rgba(28,28,30,0.12); }

/* Plain-text fallback for the rule — invisible in the browser, but
   present in the DOM so it survives copy-to-clipboard as a real
   character. iMessage paste then shows "————" between sections. */
.imsg-rule-text {
  position: absolute;
  left: -9999px;
  width: 1px; height: 1px;
  overflow: hidden;
}

/* Big primary value — used for stock price, flight times, etc. */
.imsg-big {
  font-size: 32px;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.1;
}
.imsg-change {
  font-size: 17px;
  font-weight: 600;
}
.imsg-change.up { color: #34c759; }
.imsg-change.down { color: #ff453a; }

/* Key/value rows — INLINE format so paste shows "Gate: 46 · T8" on one
   line instead of "Gate\n46 · T8\n" as two lines. The label is muted; */
.imsg-kv-row {
  font-size: 17px;
  line-height: 1.42;
}
.imsg-kv-row .k { color: rgba(242,242,247,0.6); font-weight: 400; }
[data-theme="light"] .imsg-kv-row .k { color: rgba(28,28,30,0.55); }

/* Single-line text rows (weather day list) — also inline content. */
.imsg-row {
  font-size: 17px;
  line-height: 1.42;
}

/* Footer line — italic source/timestamp */
.imsg-footer {
  font-style: italic;
  font-size: 14px;
  color: rgba(242,242,247,0.6);
}
[data-theme="light"] .imsg-footer { color: rgba(28,28,30,0.55); }
.imsg-footer .imsg-mono { font-family: "SF Mono", ui-monospace, monospace; font-style: normal; letter-spacing: 0.02em; }

/* Flight route line — single inline block with Unicode em-dashes so
   "JFK ── ✈ ── LHR" is one line of text on paste. */
.imsg-route {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.01em;
}
.imsg-route .imsg-dim { color: rgba(242,242,247,0.5); font-weight: 400; }
[data-theme="light"] .imsg-route .imsg-dim { color: rgba(28,28,30,0.5); }

/* Status pill (delays, statuses) — small inline label */
.imsg-pill {
  display: inline-block;
  font-size: 13px;
  font-weight: 600;
  padding: 2px 10px;
  border-radius: 999px;
  background: rgba(242,242,247,0.1);
  color: rgba(242,242,247,0.85);
}
[data-theme="light"] .imsg-pill { background: rgba(28,28,30,0.08); color: rgba(28,28,30,0.85); }
.imsg-pill.warn { background: rgba(255, 159, 10, 0.18); color: #ff9f0a; }
.imsg-pill.good { background: rgba(48, 209, 88, 0.18); color: #30d158; }
.imsg-pill.bad  { background: rgba(255, 69, 58, 0.18); color: #ff453a; }

/* Itinerary / event / reminder rows — INLINE content, time as a leading
   inline span so paste keeps "morning · Senso-ji Temple" on one line. */
.imsg-day-head { font-weight: 700; font-size: 17px; }
.imsg-day-line { font-size: 16px; color: rgba(242,242,247,0.85); line-height: 1.42; }
[data-theme="light"] .imsg-day-line { color: rgba(28,28,30,0.85); }
.imsg-day-line .imsg-day-time {
  color: rgba(242,242,247,0.55);
  font-weight: 600;
}
[data-theme="light"] .imsg-day-line .imsg-day-time { color: rgba(28,28,30,0.5); }

/* News list */
.imsg-news-item { display: flex; flex-direction: column; gap: 2px; }
.imsg-news-source {
  font-size: 13px;
  color: rgba(242,242,247,0.6);
  text-transform: none;
  font-weight: 500;
}
[data-theme="light"] .imsg-news-source { color: rgba(28,28,30,0.55); }
.imsg-news-title { font-size: 16px; line-height: 1.32; }

/* Generic paragraph inside the card */
.imsg-p { font-size: 16px; line-height: 1.4; color: inherit; }
.imsg-p em, .imsg-em { font-style: italic; color: rgba(242,242,247,0.7); }
[data-theme="light"] .imsg-p em, [data-theme="light"] .imsg-em { color: rgba(28,28,30,0.65); }

/* ==========================================================================
   MODAL — model settings overlay
   ========================================================================== */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(8, 9, 13, 0.65);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  animation: modal-fade-in 0.18s ease-out;
}
.modal-backdrop.hidden { display: none; }
@keyframes modal-fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.modal-card {
  background: var(--bg-sidebar);
  border: var(--glass-border);
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.55);
  border-radius: var(--radius-xl);
  width: 100%;
  max-width: 580px;
  max-height: calc(100vh - 48px);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  animation: modal-pop 0.22s cubic-bezier(0.34, 1.45, 0.64, 1);
}
@keyframes modal-pop {
  from { opacity: 0; transform: scale(0.92) translateY(8px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 22px 12px;
  border-bottom: 1px solid var(--border-color);
}
.modal-head h3 {
  font-size: 1.05rem;
  font-weight: 800;
  letter-spacing: -0.01em;
  display: flex;
  align-items: center;
  gap: 8px;
}

.modal-close-btn {
  background: none;
  border: none;
  color: var(--text-tertiary);
  width: 32px;
  height: 32px;
  border-radius: var(--radius-m);
  cursor: pointer;
  font-size: 0.95rem;
  transition: all var(--transition-fast);
}
.modal-close-btn:hover {
  color: var(--text-primary);
  background: var(--bg-card);
}

.modal-sub {
  padding: 0 22px;
  margin-top: 10px;
  font-size: 0.78rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

.modal-body {
  flex: 1;
  overflow-y: auto;
  padding: 18px 22px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.modal-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 22px 18px;
  border-top: 1px solid var(--border-color);
}
.modal-footer .btn { font-size: 0.78rem; }

/* Tier card inside the settings modal */
.tier-card {
  background: var(--bg-card);
  border: var(--glass-border);
  border-radius: var(--radius-l);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.tier-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.tier-card-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.88rem;
  font-weight: 800;
  letter-spacing: -0.01em;
}
.tier-card-title .tier-badge {
  font-family: var(--font-mono);
  font-size: 0.6rem;
  letter-spacing: 0.06em;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-color);
  text-transform: uppercase;
  font-weight: 700;
}
.tier-card-hint {
  font-size: 0.7rem;
  color: var(--text-tertiary);
  font-style: italic;
  line-height: 1.4;
}

.tier-row {
  display: grid;
  grid-template-columns: 92px 1fr;
  gap: 10px;
  align-items: center;
}
.tier-row label {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.tier-row .form-control { font-size: 0.78rem; }
.tier-row select.form-control {
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--text-secondary) 50%),
                    linear-gradient(135deg, var(--text-secondary) 50%, transparent 50%);
  background-position: calc(100% - 14px) 50%, calc(100% - 9px) 50%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-right: 26px;
}

.tier-temp-row { align-items: center; }
.tier-temp-slider {
  width: 100%;
  -webkit-appearance: none;
  appearance: none;
  height: 4px;
  background: var(--bg-input);
  border-radius: 999px;
  outline: none;
}
.tier-temp-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent-color);
  cursor: pointer;
  border: 2px solid var(--bg-sidebar);
  box-shadow: 0 0 0 1px var(--accent-color);
}
.tier-temp-slider::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent-color);
  cursor: pointer;
  border: 2px solid var(--bg-sidebar);
}
.tier-temp-value {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--accent-color);
  font-weight: 700;
  min-width: 40px;
  text-align: right;
}
.tier-temp-cell {
  display: grid;
  grid-template-columns: 1fr 40px;
  gap: 10px;
  align-items: center;
}

/* ==========================================================================
   ▼▼▼ WAIVY v2 — iMessage chat-only layout (overrides legacy two-pane UI) ▼▼▼
   Phone-shaped shell centered on desktop, full-bleed on mobile. Sand
   radial bg with a sky-glass cream chat sheet floating on top. Ink
   user-bubble, glass Waivy-bubble — boop-agent canon.
   ========================================================================== */

/* Page bg uses the sand-and-sky-glass radial. body keeps its existing
 * flex column from the legacy reset — we just paint over the bg. */
body {
  background: var(--bg-app-gradient, var(--bg-app));
  min-height: 100dvh;
  font-family: var(--font-sans);
  color: var(--text-primary);
}

/* Legacy dashboard chrome is no longer rendered (HTML removed) — these
 * defensive hides guard against any leftover CSS state in old caches. */
.navbar,
.workspace-grid > .sidebar-panel,
.legacy-state {
  display: none !important;
}

/* ---- Phone shell ---------------------------------------------------- */

.waivy-shell {
  /* Centered phone-shaped frame on desktop; full-bleed on phones. */
  display: flex;
  flex-direction: column;
  width: min(100%, 480px);
  height: 100dvh;
  margin: 0 auto;
  padding: 0;
  position: relative;
  overflow: hidden;
}

/* ---- Top header ----------------------------------------------------- */

.phone-header {
  /* Frosted overlay (parity with the landing): the thread scrolls BEHIND a
   * translucent, blurred header. Absolute within .waivy-shell (position:relative)
   * so the chat-sheet fills the box and content passes under it. The scroll's
   * top padding is set to the header's measured height in index.html. */
  position: absolute;
  top: 0; left: 0; right: 0;
  z-index: 5;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding: 14px 18px 8px;
  gap: 12px;
  background: color-mix(in srgb, var(--bg-app) 68%, transparent);
  -webkit-backdrop-filter: blur(18px) saturate(1.6);
  backdrop-filter: blur(18px) saturate(1.6);
  border-bottom: 1px solid color-mix(in srgb, var(--divider) 60%, transparent);
}

.phone-header-side {
  display: flex;
  align-items: center;
  color: var(--waivy-slate-dark);
  min-height: 28px;
}

.phone-header-left .waivy-mark {
  width: 40px;
  height: 18px;
  color: var(--waivy-slate-dark);
}

[data-theme="dark"] .phone-header-left .waivy-mark {
  color: var(--waivy-slate-soft);
}

.phone-header-right {
  justify-content: flex-end;
}

.phone-header-date {
  font-family: var(--font-serif);
  font-size: 1.05rem;
  font-weight: 500;
  color: var(--text-primary);
  letter-spacing: -0.005em;
}

.phone-header-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1px solid var(--border-color);
  background: var(--bg-card);
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background var(--transition-fast), color var(--transition-fast);
  font-size: 0.78rem;
}

.phone-header-btn:hover {
  background: var(--bg-card-hover);
  color: var(--text-primary);
}

/* ---- The chat sheet (the big rounded glass card) -------------------- */

.chat-sheet {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  min-height: 0;
  /* Flat clean thread (matches the landing) — no inset glass card. The rounded
   * chat box (.iphone-device) provides the frame; the thread just fills it. */
  margin: 0;
  padding: 0;
  background: transparent;
  border: none;
  border-radius: 0;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  box-shadow: none;
  position: relative;
  overflow: hidden;
}

.chat-sheet-handle {
  width: 38px;
  height: 4px;
  border-radius: 2px;
  background: var(--text-tertiary);
  opacity: 0.4;
  margin: 4px auto 8px;
  flex: 0 0 auto;
}

.chat-sheet-head {
  flex: 0 0 auto;
  display: grid;
  grid-template-columns: 36px 1fr auto;
  align-items: center;
  gap: 8px;
  padding: 4px 14px 10px;
  border-bottom: 1px solid var(--divider);
}

.chat-sheet-title {
  font-family: var(--font-serif);
  font-weight: 600;
  font-size: 1.2rem;
  letter-spacing: -0.005em;
  color: var(--text-primary);
  text-align: center;
  margin: 0;
}

.chat-sheet-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1px solid var(--border-color);
  background: var(--bg-card);
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.72rem;
  transition: background var(--transition-fast), color var(--transition-fast);
}

.chat-sheet-btn:hover {
  background: var(--bg-card-hover);
  color: var(--text-primary);
}

.chat-sheet-btn.ghost {
  background: transparent;
}

/* Inline status pill — smaller, lives in the sheet head right column. */
.chat-sheet-head .copilot-status-pill {
  padding: 4px 10px;
  font-size: 0.65rem;
  font-family: var(--font-mono);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--text-secondary);
  border: 1px solid var(--border-color);
}

.chat-sheet-head .copilot-status-pill .status-icon { display: none; }

/* ---- Conversation thread (scrollable bubble feed) ------------------- */

.chat-thread-container {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 14px 14px 4px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.conversation-feed {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.conversation-feed.hidden { display: none; }

/* ---- Kill legacy bubble decorations ---------------------------------
 * Old "glowing left border" pseudo and rounded-corner overrides bled
 * through into the new iMessage bubbles. Zero them out. */
.chat-message-row.assistant .message-bubble::after,
.chat-message-row.assistant .message-bubble::before {
  content: none !important;
  display: none !important;
}

/* ---- Empty-state placeholder wrapper ---------------------------------
 * Legacy CSS centered+capped this wrapper. In the chat-only layout it
 * should just stack its children naturally inside the chat thread. */
.chat-placeholder-wrapper {
  display: flex !important;
  flex-direction: column !important;
  align-items: stretch !important;
  justify-content: flex-start !important;
  margin: 0 !important;
  max-width: none !important;
  text-align: left !important;
  gap: 12px !important;
  padding: 0 !important;
}

.chat-placeholder-wrapper.hidden { display: none !important; }

/* ---- Welcome bubbles (empty state) ---------------------------------- */

.welcome-stack {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
}

.welcome-bubble {
  align-self: flex-start;
  max-width: 86%;
  background: var(--bg-bubble-assistant);
  color: var(--bg-bubble-assistant-text);
  border: 1px solid var(--surface-glass-border);
  border-radius: var(--radius-bubble) var(--radius-bubble) var(--radius-bubble) var(--radius-bubble-tail);
  padding: 10px 14px;
  font-size: 0.95rem;
  line-height: 1.42;
  box-shadow: var(--shadow-glass);
  animation: chat-fade-in 0.28s ease-out both;
}

.welcome-wave {
  display: inline-block;
  width: 32px;
  height: 14px;
  vertical-align: -2px;
  margin-right: 6px;
  color: var(--waivy-slate-dark);
}

[data-theme="dark"] .welcome-wave { color: var(--waivy-slate-soft); }

.welcome-wave svg { display: block; width: 100%; height: 100%; }

/* ---- Suggestion chips (tap to send) --------------------------------- */

.chat-suggestions-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 4px;
}

.suggestion-card {
  text-align: left;
  background: var(--bg-card);
  color: var(--text-primary);
  border: 1px solid var(--surface-glass-border);
  border-radius: 16px;
  padding: 10px 12px;
  cursor: pointer;
  font-family: var(--font-sans);
  transition: background var(--transition-fast), transform var(--transition-fast), border-color var(--transition-fast);
  box-shadow: var(--shadow-glass);
}

.suggestion-card:hover {
  background: var(--bg-card-hover);
  transform: translateY(-1px);
  border-color: var(--border-color-hover);
}

.suggestion-card h4 {
  font-family: var(--font-serif);
  font-weight: 600;
  font-size: 0.92rem;
  margin: 0 0 4px;
  color: var(--text-primary);
  letter-spacing: -0.005em;
}

.suggestion-card p {
  margin: 0;
  font-size: 0.74rem;
  line-height: 1.4;
  color: var(--text-secondary);
}

.suggestion-card code {
  font-family: var(--font-mono);
  font-size: 0.74em;
  padding: 0 4px;
  background: var(--accent-soft);
  border-radius: 4px;
}

/* ---- iMessage-style chat bubbles ------------------------------------ */

/* Per-turn row container: user rows flip to flex-end; bubble-stack
 * inherits the side-alignment from the row. */
.chat-message-row {
  display: flex;
  flex-direction: column;
  gap: 2px;
  animation: chat-fade-in 0.24s ease-out both;
}

.chat-message-row.user { align-items: flex-end; }
.chat-message-row.assistant { align-items: flex-start; }

/* Author label — hidden by default in iMessage mode; the bubble side
 * already conveys identity. Keep the DOM element for hover/trace UI. */
.chat-message-row .bubble-author {
  display: none;
}

.bubble-stack {
  display: flex;
  flex-direction: column;
  gap: 3px;
  max-width: 86%;
}

.attachment-stack {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-width: 86%;
  margin-top: 2px;
}

.chat-message-row.user .bubble-stack,
.chat-message-row.user .attachment-stack { align-items: flex-end; }

/* The bubble itself — tight padding, the right corner radius cut on
 * each side to evoke iMessage's tail. */
.message-bubble {
  font-size: 0.95rem;
  line-height: 1.42;
  padding: 9px 14px;
  border-radius: var(--radius-bubble);
  word-wrap: break-word;
  white-space: pre-wrap;
  box-shadow: var(--shadow-glass);
  animation: chat-fade-in 0.22s ease-out both;
}

/* User: ink fill, sand text, tail bottom-right. */
.chat-message-row.user .message-bubble {
  background: var(--bg-bubble-user);
  color: var(--bg-bubble-user-text);
  border-radius: var(--radius-bubble) var(--radius-bubble) var(--radius-bubble-tail) var(--radius-bubble);
  border: 1px solid transparent;
}

/* Waivy: glass cream, ink text, tail bottom-left. */
.chat-message-row.assistant .message-bubble {
  background: var(--bg-bubble-assistant);
  color: var(--bg-bubble-assistant-text);
  border: 1px solid var(--surface-glass-border);
  border-radius: var(--radius-bubble) var(--radius-bubble) var(--radius-bubble) var(--radius-bubble-tail);
}

/* Sequential bubbles in the same stack get a tighter inner corner so
 * they read as one continuous reply (matches iMessage stacking). */
.chat-message-row.user .bubble-stack .message-bubble + .message-bubble {
  border-top-right-radius: var(--radius-bubble-tail);
}
.chat-message-row.user .bubble-stack .message-bubble:not(:last-child) {
  border-bottom-right-radius: var(--radius-bubble-tail);
}
.chat-message-row.assistant .bubble-stack .message-bubble + .message-bubble {
  border-top-left-radius: var(--radius-bubble-tail);
}
.chat-message-row.assistant .bubble-stack .message-bubble:not(:last-child) {
  border-bottom-left-radius: var(--radius-bubble-tail);
}

/* ---- Composer (bottom input bar) ------------------------------------ */

.composer {
  flex: 0 0 auto;
  padding: 8px 10px 12px;
  border-top: 1px solid var(--divider);
  background: linear-gradient(180deg, transparent 0%, var(--surface-glass-top) 60%);
  position: relative;
}

.composer-row {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  padding: 6px 6px 6px 8px;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: 22px;
  transition: border-color var(--transition-fast), background var(--transition-fast);
}

.composer-row:focus-within {
  border-color: var(--border-color-focus);
  background: var(--bg-input-focus);
}

.composer-icon {
  flex: 0 0 auto;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.92rem;
  transition: color var(--transition-fast), background var(--transition-fast);
}

.composer-icon:hover:not(:disabled) {
  color: var(--text-primary);
  background: var(--accent-soft);
}

.composer-icon:disabled,
.composer-icon.disabled {
  color: var(--text-tertiary);
  cursor: not-allowed;
}

.composer-input {
  flex: 1 1 auto;
  min-height: 24px;
  max-height: 140px;
  padding: 6px 4px;
  border: none;
  background: transparent;
  resize: none;
  font-family: var(--font-sans);
  font-size: 0.95rem;
  line-height: 1.35;
  color: var(--text-primary);
  outline: none;
}

.composer-input::placeholder {
  color: var(--text-tertiary);
  font-style: normal;
}

.composer-send {
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: none;
  background: var(--accent-color);
  color: var(--text-inverse);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 0.85rem;
  transition: background var(--transition-fast), transform var(--transition-fast);
  padding: 0;
}

.composer-send:hover { background: var(--accent-color-hover); }
.composer-send:active { transform: scale(0.94); }

/* Beat the legacy `.btn { display: flex }` rule that made the hidden
 * cancel button still render — declare specificity beats `.btn`. */
.composer-send.danger { background: #d33b3b; color: #fff; }
.composer-send.hidden,
button.composer-send.hidden { display: none !important; }

.composer-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 6px;
  padding: 0 8px;
  font-family: var(--font-mono);
  font-size: 0.62rem;
  letter-spacing: 0.06em;
  color: var(--text-tertiary);
  text-transform: uppercase;
}

.composer-meta-hint code {
  font-family: var(--font-mono);
  background: var(--accent-soft);
  padding: 0 4px;
  border-radius: 4px;
  color: var(--text-secondary);
}

/* The attachment strip + slash menu sit above the composer-row inside
 * .composer. They were previously absolutely positioned over the bigger
 * legacy input — re-target for the new container. */
.composer #attachment-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 6px;
}
.composer #attachment-strip.hidden { display: none; }

.composer .slash-menu {
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: calc(100% - 4px);
  max-height: 40vh;
  overflow-y: auto;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 14px;
  box-shadow: var(--shadow-modal);
  z-index: 5;
}

.composer .slash-menu.hidden { display: none; }

/* ---- Settings modal — multi-section layout -------------------------- */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(10, 17, 25, 0.45);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  padding: 16px;
}

.modal-backdrop.hidden { display: none; }

.modal-card.settings-modal {
  width: min(100%, 460px);
  max-height: 88dvh;
  display: flex;
  flex-direction: column;
  background: var(--surface-modal);
  backdrop-filter: blur(40px) saturate(180%);
  -webkit-backdrop-filter: blur(40px) saturate(180%);
  border: 1px solid var(--surface-glass-border);
  border-radius: 22px;
  box-shadow: var(--shadow-modal);
  overflow: hidden;
}

.modal-head {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--divider);
}

.modal-head h3 {
  font-family: var(--font-serif);
  font-weight: 600;
  font-size: 1.15rem;
  letter-spacing: -0.005em;
  color: var(--text-primary);
  margin: 0;
}

.modal-head h3 i { margin-right: 8px; color: var(--text-secondary); }

.modal-close-btn {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 1px solid var(--border-color);
  background: var(--bg-card);
  color: var(--text-secondary);
  cursor: pointer;
}

.modal-close-btn:hover { background: var(--bg-card-hover); color: var(--text-primary); }

.settings-modal-body-wrapper {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 14px 18px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.settings-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--divider);
}

.settings-section:last-child { border-bottom: none; padding-bottom: 0; }

.settings-section-title {
  font-family: var(--font-serif);
  font-weight: 600;
  font-size: 1rem;
  color: var(--text-primary);
  margin: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  letter-spacing: -0.005em;
}

.settings-section-title i { color: var(--text-secondary); font-size: 0.92em; }

.settings-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.settings-row.stacked {
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
}

.settings-row-label {
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.settings-row-hint {
  margin: 0;
  font-size: 0.74rem;
  color: var(--text-tertiary);
  line-height: 1.4;
}

.theme-toggle-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--border-color);
  background: var(--bg-card);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 0.82rem;
  cursor: pointer;
}

.theme-toggle-btn:hover { background: var(--bg-card-hover); }

.modal-footer {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 12px 18px;
  border-top: 1px solid var(--divider);
  background: var(--bg-card);
}

.modal-footer .btn-group { display: flex; gap: 8px; }

.modal-footer .btn {
  font-family: var(--font-sans);
  font-size: 0.85rem;
  padding: 8px 14px;
  border-radius: 999px;
  cursor: pointer;
  border: 1px solid var(--border-color);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: background var(--transition-fast);
}

.modal-footer .btn.btn-outlined { background: transparent; color: var(--text-primary); }
.modal-footer .btn.btn-outlined:hover { background: var(--bg-card-hover); }

.modal-footer .btn.btn-accent {
  background: var(--accent-color);
  color: var(--text-inverse);
  border-color: var(--accent-color);
}
.modal-footer .btn.btn-accent:hover { background: var(--accent-color-hover); }

.muted { color: var(--text-tertiary); font-weight: 400; }

/* Display mode pills inside the modal */
.display-toggle {
  display: inline-flex;
  border-radius: 999px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  padding: 3px;
  align-self: flex-start;
}

.display-toggle .display-pill {
  padding: 5px 14px;
  border-radius: 999px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-family: var(--font-sans);
  font-size: 0.78rem;
  cursor: pointer;
}

.display-toggle .display-pill.active {
  background: var(--accent-color);
  color: var(--text-inverse);
}

.dynamic-imsg-toggle {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 10px;
  border: 1px solid var(--border-color);
  border-radius: 12px;
  background: var(--bg-card);
  cursor: pointer;
  font-size: 0.82rem;
}

.dynamic-imsg-toggle input { margin-top: 3px; accent-color: var(--accent-color); }

.dynamic-imsg-label { display: flex; flex-direction: column; gap: 3px; }

.dynamic-imsg-label strong { font-weight: 600; color: var(--text-primary); display: flex; align-items: center; gap: 6px; }

.dynamic-imsg-badge {
  font-family: var(--font-mono);
  font-size: 0.6rem;
  background: var(--accent-soft);
  color: var(--text-secondary);
  padding: 1px 6px;
  border-radius: 999px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.dynamic-imsg-hint { color: var(--text-tertiary); font-size: 0.74rem; line-height: 1.4; }

/* Credentials inputs inside settings modal */
.api-key-input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.api-key-input-wrapper .input-icon {
  position: absolute;
  left: 12px;
  color: var(--text-tertiary);
  font-size: 0.85rem;
  pointer-events: none;
}

.api-key-input-wrapper .form-control {
  width: 100%;
  padding: 10px 36px 10px 34px;
  border-radius: 12px;
  border: 1px solid var(--border-color);
  background: var(--bg-input);
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 0.82rem;
}

.api-key-input-wrapper .form-control:focus {
  border-color: var(--border-color-focus);
  background: var(--bg-input-focus);
  outline: none;
}

.api-key-input-wrapper .visibility-btn {
  position: absolute;
  right: 6px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: none;
  background: transparent;
  color: var(--text-tertiary);
  cursor: pointer;
}

.api-key-input-wrapper .visibility-btn:hover { color: var(--text-primary); background: var(--accent-soft); }

.form-label {
  display: block;
  font-size: 0.78rem;
  color: var(--text-secondary);
  margin-bottom: 5px;
  font-family: var(--font-sans);
}

.form-group + .form-group.mt-s { margin-top: 10px; }

/* Memory bank inside settings modal */
.memory-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 14px 12px;
  background: var(--accent-soft);
  border: 1px dashed var(--border-color);
  border-radius: 12px;
  color: var(--text-secondary);
  font-size: 0.82rem;
  text-align: center;
}

.memory-placeholder i { font-size: 1.1rem; color: var(--text-tertiary); }
.memory-placeholder p { margin: 0; line-height: 1.4; }

.memory-bank-facts {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.memory-bank-facts.hidden { display: none; }

.btn-clear-memory {
  background: transparent;
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  border-radius: 50%;
  width: 28px;
  height: 28px;
  cursor: pointer;
  font-size: 0.72rem;
}

.btn-clear-memory:hover { color: #d33b3b; border-color: #d33b3b; background: rgba(211, 59, 59, 0.06); }

/* ---- Live game watches (settings tile) ----------------------------- */
.game-watches-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.game-watches-empty {
  margin: 0;
  padding: 12px;
  border: 1px dashed var(--border-color);
  border-radius: 12px;
  background: var(--accent-soft);
  color: var(--text-secondary);
  font-size: 0.82rem;
  text-align: center;
}
.game-watches-list .game-watch-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--border-color);
  border-radius: 12px;
  background: var(--bg-card);
}
.game-watch-row .gw-anchor   { font-size: 1.2rem; }
.game-watch-row .gw-body     { flex: 1; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.game-watch-row .gw-title    { font-weight: 600; color: var(--text-primary); font-size: 0.9rem; }
.game-watch-row .gw-sub      { color: var(--text-secondary); font-size: 0.74rem; }
.game-watch-row .gw-remove {
  background: transparent;
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  border-radius: 50%;
  width: 28px;
  height: 28px;
  cursor: pointer;
  font-size: 0.72rem;
  flex-shrink: 0;
}
.game-watch-row .gw-remove:hover {
  color: #d33b3b;
  border-color: #d33b3b;
  background: rgba(211, 59, 59, 0.08);
}

/* ---- Responsive ----------------------------------------------------- */

@media (min-width: 720px) {
  /* On desktop float the shell with a subtle frame so it reads like a
   * phone app — the boop-agent aesthetic. */
  .waivy-shell {
    margin-top: 0;
    margin-bottom: 0;
    height: 100dvh;
  }
}

@media (max-width: 480px) {
  .chat-sheet { margin: 0; border-radius: 20px 20px 0 0; }
  .phone-header { padding: 10px 14px 6px; }
  .composer { padding: 6px 8px 10px; }
}

/* ==========================================================================
   ▲▲▲ END WAIVY v2 LAYOUT ▲▲▲
   ========================================================================== */


/* ==========================================================================
   ▼▼▼ iMESSAGE AUTHENTIC v3 — DEFINITIVE LAYER ▼▼▼
   Overrides the v2 chat-sheet layout to mirror iMessage on iOS 18:
   centered contact header with avatar+name (tappable → info sheet),
   bubbles with curved SVG tails, "Today HH:MM" date separators,
   Delivered/Read receipts, pill composer with + and mic↔send swap.
   Cream + ink palette preserved (the user bubble is ink-on-cream, not
   iMessage blue — Waivy IS the blue bubble, so we own the contrast).
   ========================================================================== */

/* Global hidden helpers — the v3 layer uses [hidden] heavily (status pill,
 * admin-only sections) and the .hidden class on composer buttons. Earlier
 * CSS sets explicit display:flex on .copilot-status-pill and .composer-plus
 * which overrides the user-agent [hidden] = none, so we re-assert here. */
[hidden] { display: none !important; }
.composer-plus.hidden,
button.composer-plus.hidden { display: none !important; }

/* ---- iPhone device frame (desktop) -------------------------------
 * The chat sits inside an iPhone-shaped device (titanium bezel, Dynamic
 * Island, side buttons, home indicator). On mobile viewports the chrome
 * collapses to full-bleed so the user's own phone provides the frame. */

body {
  /* Center the device vertically + horizontally; gradient becomes the
   * "outside the phone" backdrop. */
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

/* Outer device: titanium bezel with rounded corners.
 *
 * Aspect ratio is HARD-LOCKED to iPhone 15 Pro (414/880 ≈ 0.47). To keep
 * the device proportions identical on any viewport, we set width as the
 * smaller of three constraints and let aspect-ratio derive the height:
 *   - 100% of the available column (mobile)
 *   - 414px max (don't grow past actual iPhone width on huge monitors)
 *   - the width that keeps the device inside 92dvh of the viewport, so
 *     short windows shrink the phone rather than crop it
 */
/* The chat box — a clean rounded surface (no phone bezel / notch / buttons /
 * status bar). A comfortable chat column centered on the page, not an iPhone. */
.iphone-device {
  width: min(100%, 440px);
  height: min(calc(100dvh - 32px), 880px);
  background: var(--bg-app);
  border-radius: 24px;
  padding: 0;
  position: relative;
  overflow: hidden;
  box-shadow:
    0 30px 70px -28px rgba(0, 0, 0, 0.35),
    0 0 0 1px var(--border-color);
}

[data-theme="dark"] .iphone-device {
  box-shadow:
    0 30px 70px -28px rgba(0, 0, 0, 0.6),
    0 0 0 1px var(--border-color);
}

/* Inner surface — fills the rounded box. */
.iphone-display {
  width: 100%;
  height: 100%;
  background: var(--bg-app);
  border-radius: 24px;
  overflow: hidden;
  position: relative;
  display: flex;
  flex-direction: column;
}

/* (Phone chrome removed — no notch / status bar / side buttons / home
 * indicator. The chat box is a plain rounded surface now.) */

/* Inner waivy-shell — fills the rounded chat box. No frame of its own. */
.waivy-shell {
  flex: 1 1 auto;
  width: 100%;
  height: auto;
  min-height: 0;
  background: var(--bg-app);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-radius: 0;
  box-shadow: none;
  margin: 0;
}

/* Bottom safe area so the composer sits well above the home indicator —
 * matches the iMessage layout where the input bar floats well above the
 * device's bottom edge so the home indicator never crowds it. */
.composer {
  padding: 8px 12px 56px 12px;
}

/* Below 480px (real phones) drop the device chrome — the user's actual
 * device already provides one. */
@media (max-width: 480px) {
  /* On real phones the chat box goes full-bleed (no rounded card / shadow). */
  body { display: block; padding: 0; }
  .iphone-device {
    width: 100%;
    height: 100dvh;
    border-radius: 0;
    box-shadow: none;
    background: var(--bg-app);
  }
  .iphone-display { border-radius: 0; }
  .composer {
    padding: 6px 8px max(10px, env(safe-area-inset-bottom)) 8px;
  }
}

/* Apple system font stack — closer to SF Pro than Inter for the chat surface
 * (Inter is still loaded for fallback / legacy widgets). */
:root {
  --font-system: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "Helvetica Neue", Inter, system-ui, sans-serif;

  /* Authentic iMessage bubble dimensions */
  --imsg-bubble-radius: 18px;
  --imsg-bubble-tight: 5px;     /* corner radius when bubbles stack */
  --imsg-bubble-pad-x: 12px;
  --imsg-bubble-pad-y: 8px;
  --imsg-stack-gap: 2px;         /* between bubbles in same group */

  /* Assistant "grey" bubble color — true iMessage neutral grey, not
   * cream-tinted. The page background stays cream; only the bubble
   * itself sits on the iMessage grey so the contrast feels native. */
  --imsg-bubble-grey: #e9e9eb;
  --imsg-bubble-grey-text: #1a2730;
}

[data-theme="dark"] {
  --imsg-bubble-grey: #26262a;
  --imsg-bubble-grey-text: #e8edf3;
}

/* The chat surface uses the system font; the modal/sheet headers stay
 * serif for the brand voice but everything in-thread is iMessage. */
.waivy-shell,
.chat-sheet,
.chat-thread-container,
.message-bubble,
.composer,
.thread-date-separator,
.delivery-receipt {
  font-family: var(--font-system);
}

/* ---- Phone header — centered contact card -------------------------- */

.phone-header {
  grid-template-columns: 56px 1fr 56px;
  padding: 10px 14px 4px;
  gap: 0;
}

.phone-header-side {
  color: var(--text-secondary);
  min-height: 36px;
}

.phone-header-btn {
  width: 36px;
  height: 36px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: 1.05rem;
}
.phone-header-btn:hover { background: var(--accent-soft); color: var(--text-primary); }
.phone-header-btn.ghost { background: transparent; }
.phone-header-btn.ghost:hover { background: var(--accent-soft); }

/* The tappable contact card — avatar above name pill, like iMessage's
 * contact header. Avatar is bigger and the name sits below on its own
 * line with the disclosure chevron after it, matching iOS 18 style. */
.contact-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 4px 6px 0;
  background: transparent;
  border: none;
  cursor: pointer;
  border-radius: 12px;
  transition: background var(--transition-fast);
  min-width: 0;
}

.contact-header:hover,
.contact-header:focus-visible {
  background: var(--accent-soft);
  outline: none;
}

.contact-avatar {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  background: linear-gradient(160deg, #9aa3bd 0%, #5e6884 60%, #3d4458 100%);
  color: #f7f3ec;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 1px 4px rgba(26, 39, 48, 0.22);
}

.contact-avatar .waivy-mark {
  width: 28px;
  height: 13px;
  color: currentColor;
}

/* Name pill below the avatar — sized/weighted to read at glance like
 * the +1 (888) 555-1212 line in iMessage's contact header. */
.contact-name {
  font-family: var(--font-system);
  font-weight: 700;
  font-size: 1.0rem;
  letter-spacing: -0.01em;
  color: var(--text-primary);
  display: inline-flex;
  align-items: center;
  gap: 3px;
  line-height: 1.1;
}

.contact-chevron {
  font-size: 0.65rem;
  color: var(--text-tertiary);
  margin-left: 2px;
  transform: translateY(0.5px);
  font-weight: 700;
}

/* Old date pill, sheet handle, and sheet head are gone in v3 */
.phone-header-date { display: none; }
.chat-sheet-handle { display: none !important; }
.chat-sheet-head { display: none !important; }

/* ---- Chat sheet — flatten (no rounded card lip) --------------------
 * The sheet is now an opaque solid cream surface so the bubble-tail
 * cut-outs (which paint over the sheet with the same color) composite
 * cleanly. We give the shell the same flat color so desktop margins
 * blend rather than reveal the body gradient. */
.waivy-shell {
  background: var(--bg-app);
}

.chat-sheet {
  margin: 0;
  border: none;
  border-radius: 0;
  background: var(--bg-app);
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  box-shadow: none;
  padding: 0;
}

.chat-thread-container {
  /* 24px side padding + 8px per row gives 32px breathing room each
   * side. The bubble's tail extends 22px past the bubble's edge, so
   * 32px leaves 10px clearance plus accounts for the iPhone display's
   * rounded corners not clipping the tail diagonally.
   * Top 98px clears the now-absolute frosted .phone-header (~91px) so the
   * thread scrolls UP behind it (blurred), matching the landing. */
  padding: 98px 24px 4px;
  gap: 0;
  overflow-x: hidden;
}

.conversation-feed { gap: 0; }

/* ---- Thread date / time separator ---------------------------------- */
/* Centered grey label between groups: line 1 "iMessage" small uppercase,
 * line 2 "Today 7:10 PM" larger semibold. */
.thread-date-separator {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  margin: 14px auto 8px;
  color: var(--text-tertiary);
  font-size: 0.7rem;
  line-height: 1.25;
  gap: 1px;
  user-select: none;
}

.thread-date-separator .sep-channel {
  font-weight: 600;
  color: var(--text-tertiary);
}

.thread-date-separator .sep-when {
  font-weight: 700;
  color: var(--text-secondary);
  font-size: 0.72rem;
}

/* ---- Chat rows + bubbles — authentic iMessage geometry ------------- */

.chat-message-row {
  gap: var(--imsg-stack-gap);
  margin: 1px 0;
  /* 8px per side leaves room for the reply tail (it extends 22px past
   * the bubble's edge — combined with container's 18px padding gives
   * 26px clearance, enough for the curl to render fully inside the
   * overflow-x: hidden container). */
  padding: 0 8px;
}

/* Groups of consecutive same-sender rows get tighter spacing */
.chat-message-row + .chat-message-row.user,
.chat-message-row + .chat-message-row.assistant {
  margin-top: 2px;
}
/* Sender flip gets a beat of breathing room — matches real iMessage's
 * inter-turn gap (~14px from the bottom of one bubble to the top of
 * the next sender's bubble, including the receipt). */
.chat-message-row.user + .chat-message-row.assistant,
.chat-message-row.assistant + .chat-message-row.user {
  margin-top: 12px;
}

.bubble-stack {
  gap: var(--imsg-stack-gap);
  /* iMessage caps bubbles at ~85-88% of the chat surface width on
   * iPhone. The bubble-stack is the sole width cap; .message-bubble
   * inside it uses max-width: 100% so percentages don't compound. */
  max-width: 88%;
}

.message-bubble {
  position: relative;
  font-size: 1.0rem;
  line-height: 1.28;
  padding: var(--imsg-bubble-pad-y) var(--imsg-bubble-pad-x);
  border-radius: var(--imsg-bubble-radius);
  box-shadow: none;
  border: none;
  letter-spacing: -0.002em;
  /* Earlier .message-bubble layer set max-width: 85%, which compounded
   * on top of .bubble-stack's 82% and made bubbles wrap text a line
   * earlier than iMessage. Let the bubble fill its stack — width cap
   * is owned by .bubble-stack alone. */
  max-width: 100%;
}

.message-bubble .markdown-body {
  font-size: inherit;
  line-height: inherit;
  /* display:flex strips whitespace-only anonymous text nodes from the
   * flex flow — kills the trailing newline that marked.parse injects
   * between </p> and </div>, which was rendering as an empty line under
   * every bubble. Children still stack normally; the children's own
   * margins between paragraphs survive. */
  display: flex;
  flex-direction: column;
  align-items: stretch;
}
.message-bubble .markdown-body p { margin: 0; }
.message-bubble .markdown-body p + p { margin-top: 0.4em; }

/* ---- iMessage send/receive motion ---------------------------------
 * Outgoing bubbles spring up from the bottom-right (where the send
 * button lives) with a slight overshoot — matches iMessage's tactile
 * "the text just became a bubble" feel.
 * Incoming bubbles ease in from below-left with a softer curve.
 * Both animations target the bubble itself; the tail pseudo-elements
 * inherit the transform since they share the bubble's stacking
 * context. */
@keyframes imsg-send-pop {
  0%   { opacity: 0; transform: translateY(22px) scale(0.55); }
  55%  { opacity: 1; transform: translateY(-2px) scale(1.04); }
  100% { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes imsg-receive-pop {
  0%   { opacity: 0; transform: translateY(10px) scale(0.92); }
  100% { opacity: 1; transform: translateY(0) scale(1); }
}

/* USER bubble — ink slate on the right, sends with the spring pop. */
.chat-message-row.user .message-bubble {
  background: var(--bg-bubble-user);
  color: var(--bg-bubble-user-text);
  border-radius: var(--imsg-bubble-radius);
  transform-origin: bottom right;
  animation: imsg-send-pop 0.42s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

/* ASSISTANT bubble — soft grey-cream on the left, receives with the
 * softer ease. */
.chat-message-row.assistant .message-bubble {
  background: var(--imsg-bubble-grey);
  color: var(--imsg-bubble-grey-text);
  border-radius: var(--imsg-bubble-radius);
  transform-origin: bottom left;
  animation: imsg-receive-pop 0.32s cubic-bezier(0.16, 1, 0.3, 1) both;
  border: none;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}

/* Stack adjustments — tighten corners between bubbles in the same group */
.chat-message-row.user .bubble-stack .message-bubble:not(:last-child) {
  border-bottom-right-radius: var(--imsg-bubble-tight);
}
.chat-message-row.user .bubble-stack .message-bubble + .message-bubble {
  border-top-right-radius: var(--imsg-bubble-tight);
}
.chat-message-row.assistant .bubble-stack .message-bubble:not(:last-child) {
  border-bottom-left-radius: var(--imsg-bubble-tight);
}
.chat-message-row.assistant .bubble-stack .message-bubble + .message-bubble {
  border-top-left-radius: var(--imsg-bubble-tight);
}

/* ---- iMessage reply schema — tail on the FIRST bubble of a group ---
 * iOS 18 iMessage draws the tail at the TOP of the first incoming
 * bubble (curving back toward the message it's replying to) rather
 * than at the bottom of the last bubble. This matches the "reply
 * schema" where each fresh response visually connects to whatever
 * came before it.
 *
 * Two pseudo-elements form the curl:
 *   ::before — a colored quarter-disc bulging out of the top side,
 *              same color as the bubble (continues its body).
 *   ::after  — a same-shaped quarter-disc filled with the page color,
 *              positioned outward to "carve" the curl into a tail. */

/* Hard-reset any inherited pseudo decorations */
.chat-message-row.assistant .message-bubble::before,
.chat-message-row.assistant .message-bubble::after,
.chat-message-row.user .message-bubble::before,
.chat-message-row.user .message-bubble::after {
  content: none;
  display: none;
}

.chat-message-row.user .bubble-stack .message-bubble:first-child::before,
.chat-message-row.assistant .bubble-stack .message-bubble:first-child::before {
  content: "";
  display: block;
  position: absolute;
  z-index: 0;
  top: 0;
  width: 18px;
  height: 18px;
}

.chat-message-row.user .bubble-stack .message-bubble:first-child::after,
.chat-message-row.assistant .bubble-stack .message-bubble:first-child::after {
  content: "";
  display: block;
  position: absolute;
  z-index: 1;
  top: 0;
  width: 22px;
  height: 18px;
  background: var(--bg-app);
}

/* User tail — top RIGHT, ink color */
.chat-message-row.user .bubble-stack .message-bubble:first-child::before {
  right: -7px;
  background: var(--bg-bubble-user);
  border-top-left-radius: 18px 16px;
}
.chat-message-row.user .bubble-stack .message-bubble:first-child::after {
  right: -22px;
  border-top-left-radius: 12px;
}

/* Assistant tail — top LEFT, grey-cream color */
.chat-message-row.assistant .bubble-stack .message-bubble:first-child::before {
  left: -7px;
  background: var(--imsg-bubble-grey);
  border-top-right-radius: 18px 16px;
}
.chat-message-row.assistant .bubble-stack .message-bubble:first-child::after {
  left: -22px;
  border-top-right-radius: 12px;
}

/* Square the corner the tail is anchored to so the curl flows out
 * cleanly from a flat edge rather than a rounded one. */
.chat-message-row.assistant .bubble-stack .message-bubble:first-child {
  border-top-left-radius: var(--imsg-bubble-tight);
}
.chat-message-row.user .bubble-stack .message-bubble:first-child {
  border-top-right-radius: var(--imsg-bubble-tight);
}

/* The typing-bubble carries the same top-left curl so the dots feel
 * like a brand-new incoming reply. */
.chat-message-row.assistant .bubble-stack .thinking-bubble:first-child::before {
  content: "";
  display: block;
  position: absolute;
  z-index: 0;
  top: 0;
  left: -7px;
  width: 18px;
  height: 18px;
  background: var(--imsg-bubble-grey);
  border-top-right-radius: 18px 16px;
}
.chat-message-row.assistant .bubble-stack .thinking-bubble:first-child::after {
  content: "";
  display: block;
  position: absolute;
  z-index: 1;
  top: 0;
  left: -22px;
  width: 22px;
  height: 18px;
  background: var(--bg-app);
  border-top-right-radius: 12px;
}

/* Typing indicator authentic dots */
.thinking-bubble {
  background: var(--imsg-bubble-grey) !important;
  color: var(--text-tertiary);
  padding: 12px 14px !important;
  border-radius: var(--imsg-bubble-radius);
  border: none;
}
.thinking-bubble .td {
  width: 7px; height: 7px;
  background: #98998c;
  opacity: 0.6;
}
[data-theme="dark"] .thinking-bubble .td { background: #8e9aa8; }

/* Suppress thinking-label by default — iMessage typing has no caption.
 * App.js can opt-in with [data-show-label] on the bubble to display it. */
.thinking-bubble .thinking-label { display: none; }
.thinking-bubble[data-show-label] .thinking-label {
  display: inline;
  font-style: normal;
  font-weight: 500;
  font-size: 0.78rem;
}

/* ---- Delivery receipt — "Delivered" / "Read 7:10 PM" --------------- */

.delivery-receipt {
  display: block;
  text-align: right;
  font-size: 0.65rem;
  font-weight: 500;
  color: var(--text-tertiary);
  letter-spacing: -0.002em;
  padding: 2px 4px 0 0;
  user-select: none;
}

.delivery-receipt strong {
  font-weight: 600;
  color: var(--text-secondary);
}

/* Only the latest user row's receipt is shown; older ones fade out. */
.chat-message-row.user.has-receipt-stale .delivery-receipt {
  display: none;
}

/* ---- Composer — iMessage pill -------------------------------------
 * No top border — iMessage has no divider between the thread and the
 * input bar; they share the same background. 56px bottom padding
 * matches real iMessage on iPhone 15 — the pill sits ~40px above the
 * home-indicator area, not crammed at the bezel but not floating in
 * the middle of the screen either. */
.composer {
  padding: 8px 12px 56px 12px;
  border-top: none;
  background: var(--bg-app);
}

.composer-row {
  border: none;
  background: transparent;
  padding: 0;
  gap: 8px;
  align-items: flex-end;
}

.composer-row:focus-within {
  border: none;
  background: transparent;
}

.composer-plus {
  flex: 0 0 auto;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1px solid var(--border-color);
  background: var(--bg-card);
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 0.95rem;
  transition: background var(--transition-fast), color var(--transition-fast), transform var(--transition-fast);
  padding: 0;
  margin-bottom: 2px;
}
.composer-plus:hover { background: var(--bg-card-hover); color: var(--text-primary); }
.composer-plus:active { transform: scale(0.92); }
.composer-plus.danger {
  background: #d33b3b;
  color: #fff;
  border-color: transparent;
}

.composer-pill {
  flex: 1 1 auto;
  display: flex;
  align-items: flex-end;
  gap: 4px;
  background: transparent;
  border: 1.5px solid var(--border-color);
  border-radius: 18px;
  padding: 3px 4px 3px 12px;
  min-height: 32px;
  transition: border-color var(--transition-fast);
}
.composer-pill:focus-within {
  border-color: var(--text-tertiary);
}

.composer-pill .composer-input {
  flex: 1 1 auto;
  min-height: 22px;
  max-height: 140px;
  padding: 3px 0;
  border: none;
  background: transparent;
  resize: none;
  font-family: var(--font-system);
  font-size: 1.0rem;
  line-height: 1.28;
  color: var(--text-primary);
  outline: none;
  letter-spacing: -0.002em;
  /* iMessage-style blue blinking cursor — visible even on placeholder.
   * Caret-color is the bar color; the system handles the blink rate. */
  caret-color: #007AFF;
}

.composer-pill .composer-input::placeholder {
  color: var(--text-tertiary);
  font-weight: 400;
}

/* Trailing icon — mic when empty, blue send arrow when there's text.
 * Sized to match the iMessage arrow button at the right edge of the pill. */
.composer-trailing {
  flex: 0 0 auto;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: background var(--transition-fast), color var(--transition-fast), transform var(--transition-fast);
  align-self: flex-end;
  margin-bottom: 1px;
}
.composer-trailing:hover { background: var(--accent-soft); color: var(--text-primary); }
.composer-trailing:active { transform: scale(0.9); }

.composer-trailing .composer-trailing-mic { font-size: 0.86rem; }
.composer-trailing .composer-trailing-send { font-size: 0.95rem; font-weight: 900; }
.composer-trailing[data-state="mic"] .composer-trailing-send { display: none; }
.composer-trailing[data-state="send"] .composer-trailing-mic { display: none; }
.composer-trailing[data-state="send"] {
  background: #007AFF;
  color: #ffffff;
}
.composer-trailing[data-state="send"]:hover {
  background: #006fe6;
  color: #ffffff;
}

/* Hide legacy composer-meta — char counter still in DOM, just invisible */
.composer-meta { display: none !important; }

/* Old send button (legacy ID may still bind) — collapse to zero */
button.composer-send { display: none !important; }

/* ---- Suggestion cards — tweak typography to match iMessage --------- */

.welcome-stack { gap: 2px; margin-bottom: 12px; }

.welcome-bubble {
  background: var(--imsg-bubble-grey);
  color: var(--imsg-bubble-grey-text);
  border: none;
  font-size: 1.0rem;
  padding: 8px 12px;
  border-radius: var(--imsg-bubble-radius);
  box-shadow: none;
  max-width: 78%;
  letter-spacing: -0.002em;
}

.welcome-bubble:last-child { position: relative; }
.welcome-bubble:last-child::before {
  content: "";
  position: absolute;
  z-index: 0;
  bottom: 0;
  left: -7px;
  width: 18px;
  height: 18px;
  background: var(--imsg-bubble-grey);
  border-bottom-right-radius: 18px 16px;
}
.welcome-bubble:last-child::after {
  content: "";
  position: absolute;
  z-index: 1;
  bottom: 0;
  left: -22px;
  width: 22px;
  height: 18px;
  background: var(--bg-app);
  border-bottom-right-radius: 12px;
}

.welcome-wave { color: var(--waivy-slate-dark); }

.chat-suggestions-grid {
  margin-top: 12px;
  gap: 6px;
}

.suggestion-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 14px;
  padding: 10px 12px;
  box-shadow: none;
}
.suggestion-card:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-color-hover);
}
.suggestion-card h4 {
  font-family: var(--font-system);
  font-size: 0.86rem;
  font-weight: 600;
  letter-spacing: -0.003em;
}
.suggestion-card p {
  font-size: 0.78rem;
}

/* ---- Settings → "Info" sheet (iMessage info screen) --------------- */

.modal-card.settings-modal {
  background: var(--surface-modal);
  border-radius: 22px;
}

.modal-head {
  border-bottom: none;
  padding: 14px 18px 8px;
  background: transparent;
}

.modal-head h3 {
  font-family: var(--font-system);
  font-weight: 600;
  font-size: 1.0rem;
}

.modal-close-btn {
  border: none;
  background: transparent;
  width: auto;
  height: auto;
  padding: 6px 10px;
  color: var(--accent-cyan);
  font-family: var(--font-system);
  font-size: 0.95rem;
  font-weight: 500;
  border-radius: 8px;
}
.modal-close-btn:hover { background: var(--accent-soft); color: var(--text-primary); }

/* Big centered identity card (avatar + name) */
.settings-identity {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 4px 20px 18px;
  gap: 6px;
}

.settings-identity-avatar {
  width: 76px;
  height: 76px;
  border-radius: 50%;
  background: linear-gradient(160deg, var(--waivy-slate-soft) 0%, var(--waivy-slate-dark) 100%);
  color: #f7f3ec;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(26, 39, 48, 0.18);
  margin-bottom: 4px;
}
.settings-identity-avatar .waivy-mark { width: 44px; height: 22px; color: currentColor; }

.settings-identity-name {
  font-family: var(--font-system);
  font-weight: 600;
  font-size: 1.4rem;
  letter-spacing: -0.01em;
  color: var(--text-primary);
}
.settings-identity-sub {
  font-family: var(--font-system);
  font-size: 0.78rem;
  color: var(--text-tertiary);
}

/* Section titles + rows: iMessage Settings look */
.settings-section {
  padding: 10px 14px 14px;
  border-bottom: none;
}
.settings-section-title {
  font-family: var(--font-system);
  font-weight: 600;
  font-size: 0.7rem;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-left: 4px;
  margin-bottom: 6px;
}

/* Grouped list look for the profile fields */
.profile-grid {
  display: flex;
  flex-direction: column;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  overflow: hidden;
}

.profile-row {
  display: grid;
  grid-template-columns: 110px 1fr;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--divider);
  font-size: 0.92rem;
}
.profile-row:last-child { border-bottom: none; }

.profile-row-label {
  color: var(--text-primary);
  font-weight: 500;
}

.profile-row-input {
  background: transparent;
  border: none;
  outline: none;
  font-family: var(--font-system);
  font-size: 0.92rem;
  color: var(--text-secondary);
  width: 100%;
  text-align: right;
  padding: 0;
}
.profile-row-input::placeholder { color: var(--text-tertiary); }
.profile-row-input:focus { color: var(--text-primary); }

/* Memory pills — softer chip style inside the info sheet */
.memory-bank-facts {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 4px;
}
.memory-chip {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 0.82rem;
  color: var(--text-primary);
}
.memory-chip i { color: var(--accent-cyan); font-size: 0.78rem; }

.memory-placeholder {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 14px 12px;
  color: var(--text-tertiary);
  font-size: 0.84rem;
  text-align: center;
}

/* Theme toggle — pill */
.theme-toggle-btn {
  border-radius: 999px;
  border: 1px solid var(--border-color);
  background: var(--bg-card);
  padding: 6px 12px;
  font-family: var(--font-system);
  font-size: 0.85rem;
}
.theme-toggle-btn:hover { background: var(--bg-card-hover); }

/* Modal footer — iMessage uses cancel/done; we still expose save */
.modal-footer {
  background: transparent;
  border-top: 1px solid var(--divider);
  padding: 10px 14px;
}
.modal-footer .btn {
  font-family: var(--font-system);
  border-radius: 999px;
  font-size: 0.92rem;
  padding: 8px 16px;
}
.modal-footer .btn.btn-accent {
  background: var(--accent-color);
  color: var(--text-inverse);
}

/* ---- Bubble attached image — keep nicely cornered ------------------ */
.message-bubble .bubble-attached-image {
  border-radius: 14px;
  max-width: 100%;
  margin-bottom: 4px;
  display: block;
}

/* ---- Responsive tweaks at small width ------------------------------ */
@media (max-width: 480px) {
  .chat-sheet { border-radius: 0; }
  .phone-header { padding: 10px 12px 4px; }
  .composer { padding: 6px 8px max(10px, env(safe-area-inset-bottom)) 8px; }
  .bubble-stack { max-width: 82%; }
}

/* ==========================================================================
   ▲▲▲ END iMESSAGE AUTHENTIC v3 ▲▲▲
   ========================================================================== */
