/* Nova frontend — dark chat theme. No build step, no dependencies. */

:root {
  --bg: #0f1115;
  --panel: #161a22;
  --panel-2: #1c2230;
  --text: #e8eaf0;
  --muted: #9aa3b2;
  --accent: #5ac8fa;
  --accent-dim: rgba(90, 200, 250, 0.16);
  --border: #262c3a;
  --radius: 14px;
  --maxw: 820px;
  --glass-panel: rgba(22, 26, 34, 0.62);
  --glass-panel2: rgba(28, 34, 48, 0.55);
  --glass-edge: rgba(255, 255, 255, 0.16);
  --glass-user: rgba(90, 200, 250, 0.28);
  --glass-user-edge: rgba(150, 175, 255, 0.45);
  --glass-gloss: rgba(255, 255, 255, 0.12);
}

* { box-sizing: border-box; }

html { background: var(--bg); }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  background: var(--bg);
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

#app {
  display: flex;
  flex-direction: row;
  height: 100vh; /* fallback for older browsers */
  height: 100dvh;
  overflow: hidden;
  position: relative;
  background: var(--bg);
}

#main-col {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
  min-height: 0;
  max-width: var(--maxw);
  margin: 0 auto;
}

/* ---------- header ---------- */
header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(14px + env(safe-area-inset-top)) 18px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--panel);
}

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

.brand .dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 12px var(--accent);
}

.brand h1 {
  font-size: 18px;
  margin: 0;
  font-weight: 600;
  letter-spacing: 0.2px;
}

#sidebar-toggle {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 15px;
  cursor: pointer;
}

#sidebar-toggle:hover { color: var(--text); border-color: var(--accent); }

#new-chat {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 7px 14px;
  font-size: 14px;
  cursor: pointer;
}

#new-chat:hover { color: var(--text); border-color: var(--accent); }

.head-actions { display: flex; align-items: center; gap: 8px; }

#speak-toggle {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 7px 11px;
  font-size: 15px;
  cursor: pointer;
}
#speak-toggle:hover { color: var(--text); border-color: var(--accent); }

/* ---------- messages (flushed to bottom, tight to composer/tabs) ---------- */
#messages {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 12px 0 8px;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-y: contain;
  display: flex;
  flex-direction: column;
  gap: 14px;
  position: relative;
}

/* living brain background (brain.js canvas takes this slot; robot retired 2026-11-01) */
#messages::before {
  content: "";
  position: fixed;
  inset: 0;
  background: transparent;
  pointer-events: none;
  z-index: 0;
}

#nova-brain {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
}
#messages > #nova-brain { position: fixed; z-index: 0; }

#messages > * {
  position: relative;
  z-index: 1;
}
/* flush: when the chat is short, bubbles sit on the bottom above the
   composer instead of hanging at the top (margin-top:auto is scroll-safe,
   unlike justify-content:flex-end which clips overflow) */
#messages > :first-child {
  margin-top: auto !important;
}
/* flush tight to the composer — no trailing gap inside the scroll area */
#messages > :last-child {
  margin-bottom: 0;
}

.bubble {
  max-width: 100%;
  box-sizing: border-box;
  padding: 12px 18px;
  border-radius: var(--radius);
  overflow-wrap: break-word;
}

.bubble.user {
  align-self: flex-end;
  background: var(--accent-dim);
  border: 1px solid rgba(90, 200, 250, 0.35);
  border-radius: 20px 0 0 20px;
}

.bubble.assistant {
  align-self: flex-start;
  background: var(--panel);
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
  width: 100%;
  max-width: 100%;
}

.bubble p { margin: 0 0 10px; }
.bubble p:last-child { margin-bottom: 0; }

.bubble h1, .bubble h2, .bubble h3, .bubble h4 {
  margin: 14px 0 8px;
  line-height: 1.3;
  font-weight: 700;
}
.bubble h1:first-child, .bubble h2:first-child,
.bubble h3:first-child, .bubble h4:first-child { margin-top: 0; }
.bubble h1 { font-size: 1.35em; }
.bubble h2 { font-size: 1.2em; }
.bubble h3 { font-size: 1.08em; }
.bubble h4 { font-size: 1em; }

.bubble ul, .bubble ol {
  margin: 0 0 10px;
  padding-left: 22px;
}
.bubble li { margin-bottom: 5px; }
.bubble li:last-child { margin-bottom: 0; }
.bubble li::marker { color: var(--accent); }

.bubble blockquote {
  margin: 0 0 10px;
  padding: 8px 14px;
  border-left: 3px solid var(--accent);
  background: var(--accent-dim);
  border-radius: 0 8px 8px 0;
}
.bubble blockquote p { margin-bottom: 6px; }

.bubble a {
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px solid rgba(90, 200, 250, 0.4);
}
.bubble a:hover { border-bottom-color: var(--accent); }

.bubble hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 14px 0;
}

.bubble em { color: #c9d2e8; }

/* reply bar above composer */
#reply-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: 10px;
  padding: 9px 12px;
  margin-bottom: 8px;
  font-size: 13.5px;
}
#reply-bar.hidden { display: none; }
.reply-preview { overflow: hidden; }
.reply-label {
  display: block;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--accent);
  margin-bottom: 2px;
}
.reply-text {
  display: block;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
#reply-cancel {
  flex-shrink: 0;
  background: transparent;
  border: none;
  color: var(--muted);
  font-size: 22px;
  cursor: pointer;
  padding: 2px 8px;
  line-height: 1;
}
#reply-cancel:hover { color: var(--text); }

/* tappable bubbles get a subtle affordance */
.bubble { cursor: default; }
.bubble.user { user-select: text; -webkit-user-select: text; }

.bubble pre {
  background: #0b0d12;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  overflow-x: auto;
  font-size: 13.5px;
}

.bubble code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.bubble p code, .bubble li code {
  background: #0b0d12;
  padding: 2px 6px;
  border-radius: 6px;
  font-size: 0.9em;
}

/* typing indicator */
.typing span {
  display: inline-block;
  width: 7px; height: 7px;
  margin-right: 4px;
  border-radius: 50%;
  background: var(--muted);
  animation: blink 1.2s infinite;
}
.typing span:nth-child(2) { animation-delay: 0.2s; }
.typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes blink { 0%, 80%, 100% { opacity: 0.25; } 40% { opacity: 1; } }

/* ---------- working indicator (the "I can see Nova working" bar) ---------- */
#working {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 0 14px 10px;
  padding: 11px 16px;
  background: var(--accent-dim);
  border: 1px solid rgba(90, 200, 250, 0.45);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 14.5px;
  font-weight: 600;
}
#working.hidden { display: none; }

/* Word-dissolve (2026-10-17): status words dissolve out — fade + blur +
   letterspacing drift + slight lift — and the next words materialize the
   reverse. Replaces every spinning status indicator. */
.word-dissolve {
  transition: opacity 0.22s ease, filter 0.22s ease, letter-spacing 0.22s ease, transform 0.22s ease;
}
.word-dissolve.wd-out {
  opacity: 0;
  filter: blur(6px);
  letter-spacing: 0.04em;
  transform: translateY(-2px);
}

/* Specificity fix (2026-10-17): the #nova-status ID rule below pins
   opacity: 0.95, which outranks .word-dissolve.wd-out (0,2,0) — the
   avatar status line could blur but never fade. Give its wd-out state
   ID-level weight so the dissolve fade actually happens. */
#nova-status.wd-out {
  opacity: 0;
}
@media (prefers-reduced-motion: reduce) {
  .word-dissolve { transition: none; }
}

/* ---------- memory toast ---------- */
#memory-note {
  align-self: center;
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--muted);
  font-size: 13px;
  border-radius: 999px;
  padding: 6px 14px;
  margin-bottom: 8px;
  transition: opacity 0.3s;
}
#memory-note.hidden { display: none; }

/* ---------- composer ---------- */
footer {
  padding: 6px 0 0;
  margin: 0;
  border-top: 1px solid var(--border);
  background: var(--panel);
}

#composer {
  display: flex;
  gap: 10px;
  align-items: flex-end;
}

#input {
  flex: 1;
  resize: none;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  font-size: 16px; /* 16px+ prevents iOS auto-zoom */
  font-family: inherit;
  line-height: 1.45;
  max-height: 160px;
  -webkit-user-select: text;
  user-select: text;
  -webkit-touch-callout: default;
}

#input:focus { outline: none; border-color: var(--accent); }
#input:disabled { opacity: 0.6; }

#send {
  width: 44px;
  height: 44px;
  flex-shrink: 0;
  border-radius: 50%;
  border: none;
  background: var(--accent);
  color: #fff;
  font-size: 20px;
  cursor: pointer;
}

#send:disabled { opacity: 0.4; cursor: default; }

#stop {
  width: 44px;
  height: 44px;
  flex-shrink: 0;
  border-radius: 50%;
  border: none;
  background: #e5484d;
  color: #fff;
  font-size: 16px;
  cursor: pointer;
}
#stop.hidden, #send.hidden { display: none; }

.hint {
  margin: 6px 2px 0;
  font-size: 12px;
  color: var(--muted);
  text-align: center;
}

/* ---------- image attachments ---------- */
#attach {
  width: 44px;
  height: 44px;
  flex-shrink: 0;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  font-size: 20px;
  cursor: pointer;
}
#attach:hover { color: var(--text); border-color: var(--accent); }

/* ---------- voice input ---------- */
#mic {
  width: 44px;
  height: 44px;
  flex-shrink: 0;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  font-size: 20px;
  cursor: pointer;
}
#mic:hover { color: var(--text); border-color: var(--accent); }
#mic:disabled { opacity: 0.35; cursor: default; }
#mic.listening {
  background: #e5484d;
  border-color: #e5484d;
  color: #fff;
  animation: mic-pulse 1.2s ease-in-out infinite;
}
@keyframes mic-pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.12); }
}

#preview-row {
  display: flex;
  gap: 8px;
  padding: 0 2px 10px;
  flex-wrap: wrap;
}
#preview-row.hidden { display: none; }

.preview { position: relative; display: inline-block; }
.preview img {
  width: 64px;
  height: 64px;
  object-fit: cover;
  border-radius: 10px;
  border: 1px solid var(--border);
  display: block;
}
.preview-x {
  position: absolute;
  top: -8px;
  right: -8px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text);
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  padding: 0;
}

.thumbs {
  display: flex;
  gap: 6px;
  margin-bottom: 8px;
  flex-wrap: wrap;
}
.thumbs img {
  max-width: 120px;
  max-height: 120px;
  border-radius: 10px;
  border: 1px solid var(--border);
  object-fit: cover;
}

/* generated images rendered in assistant bubbles — width/height attrs
     reserve space (no layout shift), lazy + async decode for speed */
.bubble.assistant img.generated {
  display: block;
  max-width: 100%;
  height: auto;
  aspect-ratio: 1 / 1;
  border-radius: 12px;
  margin-top: 10px;
  border: 1px solid var(--border);
  content-visibility: auto;
}

/* voice notes rendered in assistant bubbles */
.bubble.assistant .voice-note {
  display: block;
  max-width: 100%;
  border-radius: 12px;
  margin-top: 10px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.04);
}
.bubble.assistant .voice-note-label {
  font-size: 12px;
  opacity: 0.75;
  margin-bottom: 6px;
}
.bubble.assistant audio.generated-audio {
  display: block;
  width: 100%;
  min-height: 36px;
}
.bubble.assistant .voice-note-dl {
  display: inline-block;
  margin-top: 6px;
  font-size: 12px;
}

/* generated videos rendered in assistant bubbles */
.bubble.assistant video.generated {
  display: block;
  max-width: 100%;
  border-radius: 12px;
  margin-top: 10px;
  border: 1px solid var(--border);
  background: #000;
}

/* ---------- chat history list ---------- */
#chat-list {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: 220px;
  overflow-y: auto;
}

.chat-section-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-dim);
  padding: 10px 10px 4px;
  font-weight: 600;
}

.chat-item {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-bottom: 2px;
  border-radius: 10px;
  padding: 2px;
  transition: background 0.15s;
}

.chat-item:hover {
  background: var(--panel-2);
}

.chat-item.pinned {
  background: rgba(99, 140, 255, 0.08);
  border: 1px solid rgba(99, 140, 255, 0.2);
}

.chat-item-btn {
  flex: 1;
  min-width: 0;
  text-align: left;
  background: transparent;
  border: none;
  color: var(--text);
  font-size: 13.5px;
  line-height: 1.35;
  padding: 9px 10px;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-family: inherit;
  border-radius: 8px;
}

/* Sidebar chat cards — clean layout */
.chat-item {
  margin-bottom: 4px;
  border-radius: 12px;
}
.chat-item-btn {
  display: block !important;
  width: 100%;
  text-align: left;
  padding: 10px 12px !important;
  white-space: normal !important;
}
.chat-item-title {
  display: block;
  font-weight: 600;
  font-size: 14px;
  line-height: 1.35;
  margin-bottom: 3px;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.chat-item-meta {
  display: block;
  font-size: 11px;
  opacity: 0.55;
  font-weight: 400;
}
.chat-pin-btn {
  flex-shrink: 0;
  background: transparent;
  border: none;
  color: var(--text-dim);
  font-size: 15px;
  padding: 6px 8px;
  cursor: pointer;
  border-radius: 6px;
  opacity: 0.5;
  transition: opacity 0.15s;
  font-family: inherit;
}

.chat-item:hover .chat-pin-btn,
.chat-item.pinned .chat-pin-btn {
  opacity: 1;
}

.chat-pin-btn:hover {
  color: #ffc94d;
}

/* ---------- memory section ---------- */
#memory-content {
  font-size: 13.5px;
  line-height: 1.5;
  color: var(--text);
  padding: 4px 10px 10px;
}

.mem-section-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-dim);
  font-weight: 600;
  margin: 10px 0 6px;
}

.mem-section-label:first-child {
  margin-top: 2px;
}

.mem-summary {
  margin: 0 0 8px;
  padding: 8px 10px;
  background: rgba(99, 140, 255, 0.06);
  border-radius: 8px;
  border-left: 3px solid rgba(99, 140, 255, 0.35);
  font-size: 13px;
  line-height: 1.45;
}

#memory-content p {
  margin: 0 0 8px;
  padding: 8px 10px;
  background: var(--panel-2);
  border-radius: 8px;
  border-left: 3px solid rgba(99, 140, 255, 0.4);
}

#memory-content .dim {
  background: transparent;
  border: none;
  padding: 4px 0;
}

/* ---------- sidebar ---------- */
#sidebar {
  width: 320px;
  flex-shrink: 0;
  background: #161a22;
  border-left: 1px solid var(--border);
  display: none;
  flex-direction: column;
  overflow: hidden;
}

.sidebar-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  touch-action: pan-y;
}

#app.sidebar-open #sidebar { display: flex; }

.side-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px 8px;
}

.side-head h2 {
  font-size: 14px;
  margin: 0;
  font-weight: 700;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  color: var(--muted);
}

#sidebar-close {
  background: transparent;
  border: none;
  color: var(--muted);
  font-size: 20px;
  cursor: pointer;
  padding: 2px 8px;
}
#sidebar-close:hover { color: var(--text); }

#reconnect-btn {
  background: transparent;
  border: 1px solid var(--border, rgba(255, 255, 255, 0.18));
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.3px;
  border-radius: 999px;
  cursor: pointer;
  padding: 4px 10px;
  margin-left: auto;
  margin-right: 6px;
}
#reconnect-btn:hover { color: var(--text); border-color: var(--accent); }

.side-body {
  padding: 0 16px 16px;
  font-size: 13.5px;
  color: var(--text);
}

.side-body p { margin: 0 0 8px; }
.side-body .dim { color: var(--muted); }

#memory-content {
  max-height: 45%;
  overflow-y: auto;
  white-space: normal;
  overflow-wrap: break-word;
}
#memory-content pre {
  white-space: pre-wrap;
  font-size: 12.5px;
}

#todo-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.todo {
  display: flex;
  gap: 9px;
  align-items: flex-start;
  padding: 7px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13.5px;
}
.todo:last-child { border-bottom: none; }

.todo .box {
  color: var(--accent);
  font-size: 15px;
  line-height: 1.4;
  flex-shrink: 0;
}

.todo.done span:last-child {
  text-decoration: line-through;
  color: var(--muted);
}
.todo.doing span:last-child {
  font-weight: 600;
}
.todo.doing .box { color: #ffd479; }

/* ---------- sidebar backdrop (tap outside to close on mobile) ---------- */
#sidebar-backdrop {
  display: none;
}

@media (max-width: 900px) {
  #app.sidebar-open #sidebar-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 40;
    background: rgba(0, 0, 0, 0.4);
  }
}
@media (max-width: 900px) {
  #sidebar {
    position: fixed;
    top: 0;
    right: 0;
    /* dvh handles iOS Safari's dynamic toolbar so the sidebar gets a real
       height — without it, top:0/bottom:0 collapses and there's nothing to scroll */
    height: 100dvh;
    max-height: 100dvh;
    z-index: 50;
    box-shadow: -12px 0 32px rgba(0, 0, 0, 0.55);
    width: min(85vw, 320px);
    background: #161a22;
    /* iOS: capture vertical touches so the menu scrolls, not the chat behind */
    touch-action: pan-y;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
  }
  /* lock the background chat while the menu is open */
  #app.sidebar-open {
    overflow: hidden;
  }
  #app.sidebar-open #messages {
    overflow: hidden;
  }
  #app.sidebar-open .sidebar-scroll {
    /* ensure the inner scroller owns the gesture on iOS */
    position: relative;
    z-index: 1;
  }
  /* On phones, let sections flow naturally instead of nested scroll traps */
  #chat-list {
    max-height: none;
  }
  #memory-content {
    max-height: none;
  }
}

/* desktop: keep the robot's face in frame (portrait image under cover crops it) */
@media (min-width: 901px) {
  #messages::before {
    background-position: center 18%;
  }
}

@media (max-width: 520px) {
  #messages { padding: 14px 12px; }
  .bubble { max-width: 94%; }
  .hint { display: none; }
  #working { margin: 0 10px 8px; }
}

/* --- Pull-to-refresh --- */
#ptr-indicator {
  position: absolute;
  top: 0; left: 0; right: 0;
  display: flex; justify-content: center;
  height: 0; overflow: hidden;
  z-index: 50;
  pointer-events: none;
  transition: height 0.2s ease;
}
#ptr-indicator .ptr-spinner {
  width: 28px; height: 28px;
  margin-top: 12px;
  border: 3px solid rgba(255,255,255,0.15);
  border-top-color: #7cc4ff;
  border-radius: 50%;
  animation: ptr-spin 0.8s linear infinite;
}
#ptr-indicator.ready .ptr-spinner { border-top-color: #4ade80; }
@keyframes ptr-spin { to { transform: rotate(360deg); } }
#main-col { position: relative; }
#messages { overscroll-behavior-y: contain; }

/* Refresh button spin animation */
#refresh-chat.spinning {
  animation: refresh-spin 0.8s linear infinite;
}
@keyframes refresh-spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

/* ---------- bottom tab bar ---------- */
#tabbar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 60;
  display: flex;
  background: var(--panel);
  border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom);
  margin-top: 0;
  /* keep centered column on wide screens */
}
#tabbar button {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-height: 56px;
  padding: 8px 4px 6px;
  background: transparent;
  border: none;
  color: var(--muted);
  font-size: 11px;
  font-family: inherit;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
#tabbar button .tab-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}
#tabbar button .tab-icon svg {
  width: 23px;
  height: 23px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}
#tabbar button.active .tab-icon svg {
  stroke-width: 2.1;
  filter: drop-shadow(0 0 4px rgba(90, 200, 250, 0.4));
}
#tabbar button.active { color: var(--accent); }
#tabbar button:active { opacity: 0.7; }

/* tab views share main-col layout */
.tab-view {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
  min-height: 0;
  max-width: var(--maxw);
  margin: 0 auto;
  width: 100%;
  padding-bottom: calc(62px + env(safe-area-inset-bottom));
}
.tab-view[hidden], #main-col[hidden] { display: none; }
#main-col { padding-bottom: calc(62px + env(safe-area-inset-bottom)); }

/* composer + refresh row never shrink — they own their height so the
   message list (flex:1) absorbs all size changes with no bottom jump */
#main-col footer { flex-shrink: 0; }
#refresh-row { flex-shrink: 0; }

/* chat footer (composer) visible only on the chat tab */
#main-col footer { display: none; }
body[data-tab="chat"] #main-col footer { display: block; }

.view-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(14px + env(safe-area-inset-top)) 18px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--panel);
}
.view-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* goal cards */
.goal-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
}
.goal-card h3 { margin: 0 0 6px; font-size: 15px; }
.goal-card p { margin: 0; color: var(--muted); font-size: 13.5px; }
.goal-card .goal-num {
  display: inline-block;
  color: var(--accent);
  font-weight: 700;
  font-size: 12px;
  margin-bottom: 4px;
}

/* ideas */
.idea-capture { display: flex; gap: 8px; align-items: flex-end; }
.idea-capture textarea {
  flex: 1;
  resize: none;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  font-size: 16px;
  font-family: inherit;
  line-height: 1.45;
}
.idea-capture textarea:focus { outline: none; border-color: var(--accent); }
.idea-capture button {
  min-height: 44px;
  padding: 10px 20px;
  background: var(--accent);
  color: #0b0e14;
  border: none;
  border-radius: var(--radius);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}
.idea-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.idea-list li {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
  font-size: 14.5px;
}
.idea-list .idea-del {
  background: transparent;
  border: none;
  color: var(--muted);
  font-size: 18px;
  cursor: pointer;
  padding: 4px 8px;
  min-width: 44px;
  min-height: 44px;
}


/* activity tab */
#activity-now { display: flex; flex-direction: column; gap: 10px; }
.activity-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  font-size: 14.5px;
}
.activity-card .act-label { font-weight: 700; }
.activity-card .act-detail { color: var(--muted); font-size: 13px; margin-top: 2px; word-break: break-word; }
.activity-card .act-where { color: var(--accent); font-size: 12.5px; margin-top: 4px; word-break: break-all; }
.activity-card .act-where a { color: inherit; }
.activity-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.activity-list li {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px;
  font-size: 13.5px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.activity-list .act-row { display: flex; justify-content: space-between; gap: 10px; align-items: baseline; }
.activity-list .act-label { font-weight: 600; }
.activity-list .act-time { color: var(--muted); font-size: 12px; white-space: nowrap; }
.activity-list .act-detail { color: var(--muted); font-size: 12.5px; word-break: break-word; }
.activity-list .act-where { color: var(--accent); font-size: 12px; word-break: break-all; }
.activity-list .act-where a { color: inherit; }
.act-pulse { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: #22c55e; margin-right: 8px; animation: actblink 1.6s ease-in-out infinite; }
@keyframes actblink { 0%,100% { opacity: 1; } 50% { opacity: 0.3; } }


/* connected accounts */
.accounts-section { margin-bottom: 20px; }
.section-title {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--muted);
  margin: 6px 0 12px;
}
.account-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 10px;
}
.account-icon {
  flex: 0 0 auto;
  width: 48px;
  height: 48px;
  border-radius: 12px;
  background: rgba(90, 200, 250, 0.12);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
}
.account-info { flex: 1 1 auto; min-width: 0; }
.account-info h3 { margin: 0 0 4px; font-size: 16px; line-height: 1.3; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account-sub { margin: 0 0 4px; color: var(--muted); font-size: 12.5px; line-height: 1.4; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account-detail { margin: 0 0 8px; color: var(--muted); font-size: 13px; line-height: 1.4; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account-status {
  display: inline-block;
  font-size: 11.5px;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 20px;
  line-height: 1.5;
}
.account-status.on { background: rgba(52, 211, 153, 0.15); color: #34d399; }
.account-status.off { background: rgba(148, 163, 184, 0.15); color: var(--muted); }
.account-btn {
  flex: 0 0 auto;
  align-self: center;
  min-height: 44px;
  padding: 10px 16px;
  border: none;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  white-space: nowrap;
}
.account-btn.connect { background: var(--accent); color: #0b0e14; }
.account-btn.disconnect { background: transparent; color: var(--muted); border: 1px solid var(--border); }
.oauth-banner {
  background: rgba(52, 211, 153, 0.12);
  border: 1px solid rgba(52, 211, 153, 0.35);
  color: #34d399;
  border-radius: var(--radius);
  padding: 12px 16px;
  margin-bottom: 12px;
  font-size: 14px;
}
.oauth-banner.error {
  background: rgba(248, 113, 113, 0.12);
  border-color: rgba(248, 113, 113, 0.35);
  color: #f87171;
}

/* library placeholder */
.library-empty {
  text-align: center;
  padding: 56px 20px;
  color: var(--muted);
  border-top: 1px solid var(--border);
}
.library-empty p { margin: 0; font-size: 14px; }

/* sidebar above tab bar */
#sidebar { z-index: 80; }
#sidebar-backdrop { z-index: 70; }

/* ---------- sidebar safety: never visible on non-chat tabs ---------- */
body[data-tab="goals"] #sidebar,
body[data-tab="ideas"] #sidebar,
body[data-tab="library"] #sidebar,
body[data-tab="goals"] #sidebar-backdrop,
body[data-tab="ideas"] #sidebar-backdrop,
body[data-tab="library"] #sidebar-backdrop {
  display: none !important;
}

/* ---------- tasks (Goals tab checklist) ---------- */
.tasks-section {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
}
.section-label {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.14em;
  color: var(--muted);
  margin: 0 0 12px;
}
.task-add {
  display: flex;
  gap: 10px;
  align-items: center;
}
.task-add input {
  flex: 1;
  min-width: 0;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  font-size: 16px;
  padding: 10px 12px;
  outline: none;
}
.task-add input:focus { border-color: var(--accent); }
.task-add button {
  flex: 0 0 auto;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: none;
  background: var(--accent);
  color: #fff;
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
}
.task-add button:active { transform: scale(0.94); }
.task-list {
  list-style: none;
  margin: 6px 0 0;
  padding: 0;
}
.task-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
  animation: taskIn 0.18s ease-out;
}
.task-item:last-child { border-bottom: none; }
@keyframes taskIn {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: none; }
}
.task-check {
  flex: 0 0 auto;
  width: 24px;
  height: 24px;
  border-radius: 7px;
  border: 2px solid var(--muted);
  background: transparent;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
}
.task-check:active { transform: scale(0.88); }
.task-check svg {
  opacity: 0;
  transform: scale(0.5);
  transition: opacity 0.15s, transform 0.15s;
}
.task-item.done .task-check {
  background: var(--accent);
  border-color: var(--accent);
}
.task-item.done .task-check svg { opacity: 1; transform: scale(1); }
.task-text {
  flex: 1;
  min-width: 0;
  font-size: 16px;
  color: var(--text);
  overflow-wrap: break-word;
  transition: color 0.15s;
}
.task-item.done .task-text {
  text-decoration: line-through;
  color: var(--muted);
}
.task-del {
  flex: 0 0 auto;
  width: 32px;
  height: 32px;
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  border-radius: 8px;
}
.task-del:active { background: var(--panel-2); }
.task-empty {
  padding: 14px 0 4px;
  color: var(--muted);
  font-size: 14px;
  text-align: center;
  list-style: none;
}
.task-clear {
  display: block;
  margin: 8px auto 0;
  background: none;
  border: none;
  color: var(--muted);
  font-size: 13px;
  cursor: pointer;
  padding: 8px 12px;
}
#goal-cards {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

@media (max-width: 400px) {
  .account-card { padding: 14px 12px; gap: 10px; }
  .account-btn { padding: 10px 12px; font-size: 13px; }
  .account-icon { width: 44px; height: 44px; flex-basis: 44px; font-size: 22px; }
}

/* Chrome extension bridge: tab-context chip */
#context-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 2px 10px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--panel-2);
  font-size: 13px;
  color: var(--text);
}
#context-chip.hidden { display: none; }
#context-chip .chip-label {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
#context-chip .chip-x {
  flex: none;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  padding: 0;
}
#tab-btn.busy { opacity: 0.5; }
.ctx-note {
  margin-top: 6px;
  font-size: 12px;
  opacity: 0.65;
}
#tab-btn.hidden { display: none; }

/* ---------- Muse-style composer pill (2026-10-09) ---------- */
.composer-pill {
  display: flex;
  flex: 1 1 auto;
  min-width: 0;
  align-items: center;
  gap: 2px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 28px;
  padding: 6px 8px;
}
.composer-pill:focus-within { border-color: var(--accent); }
.composer-pill #input {
  flex: 1;
  min-width: 0;
  border: none;
  background: transparent;
  border-radius: 0;
  padding: 10px 8px;
}
.composer-pill #input:focus { border: none; outline: none; box-shadow: none; }
.composer-pill #attach,
.composer-pill #mic,
.composer-pill #tab-btn {
  width: 38px;
  height: 38px;
  flex-shrink: 0;
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 22px;
  font-weight: 300;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}
.composer-pill #attach:hover,
.composer-pill #mic:hover,
.composer-pill #tab-btn:hover { color: var(--text); background: var(--accent-dim); }
.composer-pill #mic:disabled { opacity: 0.35; cursor: default; }
.composer-pill #mic.listening {
  background: #e5484d;
  border-color: #e5484d;
  color: #fff;
  animation: mic-pulse 1.2s ease-in-out infinite;
}
.composer-pill #send,
.composer-pill #stop {
  width: 38px;
  height: 38px;
  flex-shrink: 0;
  font-size: 18px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
#tab-btn.hidden { display: none; }

/* ---------- Muse-style floating tab bar (2026-10-09) ---------- */
#tabbar {
  left: 0;
  right: 0;
  bottom: 0;
  border: 1px solid var(--border);
  border-left: none;
  border-right: none;
  border-bottom: none;
  border-radius: 0;
  background: rgba(22, 26, 34, 0.97);
  /* keep the bar's dark background extended through the iPhone home-bar
     safe-area — padding:4px alone was wiping out the safe-area inset and
     leaving a body-colored strip below the tabs */
  padding: 4px 4px calc(4px + env(safe-area-inset-bottom));
  gap: 2px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.45);
}
#tabbar button {
  border-radius: 18px;
  border: none;
  min-height: 46px;
  padding: 4px 4px;
}
#tabbar button .tab-icon { font-size: 20px; }
#tabbar button.tab-label { font-size: 10px; font-weight: 500; }
#tabbar button.active {
  background: var(--accent-dim);
  color: var(--accent);
}
#tabbar button:not(.active):active { background: rgba(255,255,255,0.04); }
/* Nova animated avatar — bigger + clearer states (2026-10-10) */
#nova-avatar {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  cursor: pointer;
  flex-shrink: 0;
  position: relative;
  transition: transform 0.25s ease;
}
#nova-avatar:active { transform: scale(0.92); }
#nova-avatar svg { width: 100%; height: 100%; display: block; }

/* gentle idle bob */
#nova-avatar .avatar-bob {
  animation: avatarBob 3s ease-in-out infinite;
  transform-origin: center;
}
@keyframes avatarBob {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-2px); }
}

/* blinking eyes */
#nova-avatar .eye {
  animation: avatarBlink 4.5s infinite;
  transform-origin: center;
  transform-box: fill-box;
}
@keyframes avatarBlink {
  0%, 94%, 100% { transform: scaleY(1); }
  96%, 98% { transform: scaleY(0.1); }
}

/* THINKING — puffs up big + excited wobble + glowing eyes + spinning ring */
#nova-avatar.thinking { cursor: wait; transform: scale(1.35); }
#nova-avatar.thinking .avatar-bob {
  animation: avatarThink 0.8s ease-in-out infinite;
  transform-origin: center;
}
@keyframes avatarThink {
  0%, 100% { transform: translateY(0) rotate(-8deg) scale(1); }
  25% { transform: translateY(-4px) rotate(0deg) scale(1.1); }
  50% { transform: translateY(0) rotate(8deg) scale(1); }
  75% { transform: translateY(-4px) rotate(0deg) scale(1.1); }
}
#nova-avatar.thinking .eye {
  animation: avatarThinkEyes 0.8s ease-in-out infinite;
}
@keyframes avatarThinkEyes {
  0%, 100% { opacity: 1; transform: scale(1.15); }
  50% { opacity: 0.5; transform: scale(0.95); }
}
#nova-avatar.thinking::after {
  content: '';
  position: absolute;
  inset: -6px;
  border-radius: 50%;
  border: 3px solid rgba(90, 200, 250, 0.5);
  animation: avatarWorkPulse 1.6s ease-in-out infinite;
}
@keyframes avatarWorkPulse {
  0%, 100% { transform: scale(1); opacity: 0.85; }
  50% { transform: scale(1.14); opacity: 0.3; }
}

/* SEARCHING — puffed up + eyeballs dart left/right scanning, pupils jitter */
#nova-avatar.searching { cursor: wait; transform: scale(1.35); }
#nova-avatar.searching .avatar-bob {
  animation: avatarSearchBob 0.7s ease-in-out infinite;
  transform-origin: center;
}
@keyframes avatarSearchBob {
  0%, 100% { transform: translateY(0) scale(1.05); }
  50% { transform: translateY(-5px) scale(1.12); }
}
#nova-avatar.searching .eyeball-left {
  animation: eyeDartLeft 0.9s ease-in-out infinite;
  transform-box: fill-box;
  transform-origin: center;
}
#nova-avatar.searching .eyeball-right {
  animation: eyeDartRight 0.9s ease-in-out infinite;
  transform-box: fill-box;
  transform-origin: center;
}
@keyframes eyeDartLeft {
  0%, 100% { transform: translate(0, 0); }
  20% { transform: translate(-2.4px, -0.8px); }
  40% { transform: translate(2.4px, 0.4px); }
  60% { transform: translate(-1.8px, 0.8px); }
  80% { transform: translate(2px, -0.6px); }
}
@keyframes eyeDartRight {
  0%, 100% { transform: translate(0, 0); }
  20% { transform: translate(-2.4px, 0.6px); }
  40% { transform: translate(2.4px, -0.8px); }
  60% { transform: translate(-2px, -0.4px); }
  80% { transform: translate(1.8px, 0.8px); }
}
#nova-avatar.searching .eye { animation: none; opacity: 1; }
#nova-avatar.searching .pupil {
  animation: pupilJitter 0.45s ease-in-out infinite alternate;
  transform-box: fill-box;
  transform-origin: center;
}
@keyframes pupilJitter {
  from { transform: scale(1.25); opacity: 1; }
  to { transform: scale(0.85); opacity: 0.75; }
}
#nova-avatar.searching::after {
  content: '';
  position: absolute;
  inset: -6px;
  border-radius: 50%;
  border: 3px solid rgba(74, 222, 128, 0.5);
  animation: avatarWorkPulse 1.4s ease-in-out infinite;
}

/* speaking state - puffed up + head bops + bandana (mouth cover) pulses like talking */
#nova-avatar.speaking { transform: scale(1.35); }
#nova-avatar.speaking .avatar-bob {
  animation: avatarSpeakBob 0.5s ease-in-out infinite alternate;
}
@keyframes avatarSpeakBob {
  from { transform: translateY(0) scale(1); }
  to { transform: translateY(-3px) scale(1.1); }
}
#nova-avatar.speaking .mouth {
  animation: avatarTalk 0.28s ease-in-out infinite alternate;
  transform-origin: center;
  transform-box: fill-box;
}
@keyframes avatarTalk {
  from { transform: scaleY(0.85); }
  to { transform: scaleY(1.12); }
}
#nova-avatar.speaking .eye {
  animation: avatarSpeakEyes 0.5s ease-in-out infinite alternate;
}
@keyframes avatarSpeakEyes {
  from { transform: scaleY(1); }
  to { transform: scaleY(1.18); }
}

/* listening state - puffed up + pulsing ring */
#nova-avatar.listening { transform: scale(1.35); }
#nova-avatar.listening::after {
  content: '';
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  border: 2px solid var(--accent);
  animation: avatarPulse 1.5s ease-out infinite;
}
@keyframes avatarPulse {
  0% { transform: scale(0.9); opacity: 1; }
  100% { transform: scale(1.2); opacity: 0; }
}

/* ---------- centered avatar in header (grid = true vertical center) ---------- */
#main-col > header {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
}
#main-col > header .brand { justify-self: start; }
#main-col > header .head-actions { justify-self: end; }
#avatar-wrap {
  justify-self: center;
  align-self: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 0;
  max-width: 38vw;
}
#nova-status {
  margin-top: 2px;
  font-size: 10.5px;
  line-height: 1.3;
  font-weight: 600;
  letter-spacing: 0.1px;
  color: var(--muted);
  text-align: center;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  white-space: normal;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
  min-height: 13px;
  max-height: 28px;
  opacity: 0.95;
}
#nova-status.hidden { visibility: hidden; }
#nova-status.active::after {
  content: "…";
  animation: statusDots 1.2s steps(2) infinite;
}
@keyframes statusDots {
  0% { opacity: 0.2; }
  50% { opacity: 1; }
  100% { opacity: 0.2; }
}
header #nova-avatar {
  position: static;
  left: auto;
  top: auto;
  transform: none;
  width: 52px;
  height: 52px;
  justify-self: center;
  align-self: center;
  margin: 4px 0 0 0;
}
header #nova-avatar:active { transform: scale(0.92); }

/* ---------- refresh button between composer and tabs ---------- */
#refresh-row {
  display: flex;
  justify-content: center;
  padding: 6px 0 2px;
  background: var(--panel);
  border-top: 1px solid var(--border);
}
#refresh-row #refresh-chat {
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--muted);
  border-radius: 50%;
  width: 32px;
  height: 32px;
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
#refresh-row #refresh-chat:active { transform: scale(0.92); }

/* quick-tap chips above composer */
#quick-chips {
  display: flex;
  gap: 8px;
  padding: 8px 12px 4px;
  overflow-x: auto;
  scrollbar-width: none;
}
#quick-chips::-webkit-scrollbar { display: none; }
#quick-chips .chip {
  flex-shrink: 0;
  padding: 6px 14px;
  border-radius: 20px;
  border: 1px solid rgba(120,140,180,0.3);
  background: rgba(60,80,120,0.15);
  color: #aab8d0;
  font-size: 13px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.2s;
}
#quick-chips .chip:active {
  background: rgba(80,120,200,0.3);
}

/* ---------- product cards ---------- */
.product-cards {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin: 12px 0;
}
.product-card {
  display: flex;
  gap: 14px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  text-decoration: none;
  color: var(--text);
  transition: border-color 0.15s, transform 0.15s;
}
.product-card:hover {
  border-color: var(--accent);
  transform: translateY(-1px);
}
.product-card img {
  width: 92px;
  height: 92px;
  object-fit: cover;
  border-radius: 10px;
  flex-shrink: 0;
  background: var(--bg);
}
.product-card-info {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-width: 0;
  flex: 1;
}
.product-card-brand {
  font-size: 0.72em;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin-bottom: 2px;
}
.product-card-name {
  font-weight: 600;
  font-size: 0.95em;
  line-height: 1.35;
  margin-bottom: 6px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.product-card-price {
  display: flex;
  align-items: baseline;
  gap: 8px;
}
.product-card-price .sale {
  color: #4ade80;
  font-weight: 700;
  font-size: 1.05em;
}
.product-card-price .regular {
  color: var(--muted);
  text-decoration: line-through;
  font-size: 0.85em;
}
.product-card-price .current {
  font-weight: 700;
  font-size: 1.05em;
}
.product-card-cta {
  margin-top: 8px;
  font-size: 0.82em;
  color: var(--accent);
  font-weight: 600;
}

/* ---------- code copy button ---------- */
pre { position: relative; }
.code-copy-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--muted);
  border-radius: 8px;
  padding: 4px 10px;
  font-size: 0.75em;
  cursor: pointer;
  opacity: 0.7;
  transition: opacity 0.15s, color 0.15s;
}
.code-copy-btn:hover { opacity: 1; color: var(--text); }

/* ---------- message copy button ---------- */
.bubble { position: relative; }
.msg-copy-btn {
  position: absolute;
  top: 6px;
  right: 6px;
  background: transparent;
  border: none;
  color: var(--muted);
  font-size: 0.85em;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s;
  padding: 4px 6px;
  border-radius: 6px;
}
.bubble:hover .msg-copy-btn { opacity: 0.6; }
.msg-copy-btn:hover { opacity: 1 !important; background: var(--panel-2); }

/* ---------- weather card ---------- */
.weather-card {
  background: linear-gradient(135deg, #1c2230 0%, #161a22 100%);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin: 12px 0;
  display: flex;
  align-items: center;
  gap: 16px;
}
.weather-icon { font-size: 2.8em; line-height: 1; }
.weather-main { flex: 1; }
.weather-temp { font-size: 1.8em; font-weight: 700; }
.weather-desc { color: var(--muted); font-size: 0.9em; }
.weather-details { display: flex; gap: 14px; margin-top: 6px; font-size: 0.82em; color: var(--muted); }

/* ---------- map card ---------- */
.map-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  margin: 12px 0;
  background: var(--panel-2);
}
.map-card img { width: 100%; height: 160px; object-fit: cover; display: block; }
.map-card-info { padding: 12px 14px; }
.map-card-name { font-weight: 600; margin-bottom: 2px; }
.map-card-addr { color: var(--muted); font-size: 0.88em; margin-bottom: 8px; }
.map-card-link { color: var(--accent); font-size: 0.85em; font-weight: 600; text-decoration: none; }

/* ---------- image gallery ---------- */
.gallery {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  margin: 12px 0;
  padding-bottom: 4px;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
}
.gallery img {
  height: 180px;
  border-radius: 10px;
  scroll-snap-align: start;
  flex-shrink: 0;
  cursor: pointer;
  border: 1px solid var(--border);
}
.gallery img:active { transform: scale(0.98); }

/* ---------- video card ---------- */
.video-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  margin: 12px 0;
  background: #000;
}
.video-card video { width: 100%; display: block; max-height: 400px; }
.video-card-caption { padding: 10px 14px; font-size: 0.9em; color: var(--muted); background: var(--panel-2); }

/* ---------- link preview ---------- */
.link-preview {
  display: flex;
  gap: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px;
  margin: 10px 0;
  background: var(--panel-2);
  text-decoration: none;
  color: var(--text);
  align-items: center;
}
.link-preview:hover { border-color: var(--accent); }
.link-preview img {
  width: 72px; height: 72px;
  object-fit: cover;
  border-radius: 8px;
  flex-shrink: 0;
  background: var(--bg);
}
.link-preview-info { min-width: 0; flex: 1; }
.link-preview-title {
  font-weight: 600; font-size: 0.88em;
  display: -webkit-box; -webkit-line-clamp: 2;
  -webkit-box-orient: vertical; overflow: hidden;
}
.link-preview-desc {
  color: var(--muted); font-size: 0.8em; margin-top: 2px;
  display: -webkit-box; -webkit-line-clamp: 2;
  -webkit-box-orient: vertical; overflow: hidden;
}
.link-preview-domain { color: var(--accent); font-size: 0.75em; margin-top: 4px; }

/* ---------- Pulsing robot avatar upgrade ---------- */
#nova-avatar {
  position: relative;
}
/* Pulsing glow ring behind the avatar */
#nova-avatar::before {
  content: "";
  position: absolute;
  inset: -6px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(108,140,255,0.35) 0%, rgba(108,140,255,0.08) 55%, transparent 70%);
  animation: avatarPulse 2.4s ease-in-out infinite;
  pointer-events: none;
  z-index: -1;
}
@keyframes avatarPulse {
  0%, 100% { transform: scale(1); opacity: 0.7; }
  50% { transform: scale(1.12); opacity: 1; }
}
/* Outer energy ring */
#nova-avatar .pulse-ring {
  position: absolute;
  inset: -10px;
  border-radius: 50%;
  border: 2px solid rgba(108,140,255,0.25);
  animation: ringExpand 2.4s ease-out infinite;
  pointer-events: none;
}
@keyframes ringExpand {
  0% { transform: scale(0.85); opacity: 0.8; }
  100% { transform: scale(1.25); opacity: 0; }
}
/* Stronger eye glow pulse */
#nova-avatar .eye {
  filter: drop-shadow(0 0 3px #66f) drop-shadow(0 0 6px #44f);
  animation: avatarBlink 4.5s infinite, eyePulse 2.4s ease-in-out infinite !important;
}
@keyframes eyePulse {
  0%, 100% { opacity: 0.85; }
  50% { opacity: 1; }
}
/* Metallic sheen sweep across the head */
#nova-avatar .avatar-bob { position: relative; overflow: hidden; }
#nova-avatar .avatar-bob::after {
  content: "";
  position: absolute;
  top: 0; left: -60%;
  width: 40%; height: 100%;
  background: linear-gradient(105deg, transparent, rgba(255,255,255,0.18), transparent);
  animation: sheenSweep 5s ease-in-out infinite;
  pointer-events: none;
}
@keyframes sheenSweep {
  0%, 60% { left: -60%; }
  100% { left: 130%; }
}

/* ---------- Theme system ---------- */
:root[data-theme="light"] {
  --bg: #f5f6fa;
  --panel: #ffffff;
  --panel-2: #eef0f6;
  --text: #1a1d26;
  --muted: #6b7280;
  --accent: #3b6fe0;
  --accent-dim: rgba(59, 111, 224, 0.12);
  --border: #e0e3ec;

  --glass-panel: rgba(255, 255, 255, 0.62);
  --glass-panel2: rgba(238, 240, 246, 0.60);
  --glass-edge: rgba(20, 30, 60, 0.14);
  --glass-user: rgba(59, 111, 224, 0.20);
  --glass-user-edge: rgba(59, 111, 224, 0.40);
  --glass-gloss: rgba(255, 255, 255, 0.55);
}
:root[data-theme="midnight-blue"] {
  --bg: #0a0f1e;
  --panel: #101828;
  --panel-2: #16203a;
  --text: #dbe7ff;
  --muted: #7a8db0;
  --accent: #4d9fff;
  --accent-dim: rgba(77, 159, 255, 0.14);
  --border: #1e2c4e;

  --glass-panel: rgba(16, 24, 40, 0.62);
  --glass-panel2: rgba(22, 32, 58, 0.55);
  --glass-edge: rgba(140, 180, 255, 0.18);
  --glass-user: rgba(77, 159, 255, 0.28);
  --glass-user-edge: rgba(120, 185, 255, 0.45);
  --glass-gloss: rgba(255, 255, 255, 0.12);
}
:root[data-theme="sunset"] {
  --bg: #1a1210;
  --panel: #241a16;
  --panel-2: #2e211c;
  --text: #f5e8e0;
  --muted: #a08a7e;
  --accent: #ff7a4d;
  --accent-dim: rgba(255, 122, 77, 0.14);
  --border: #3a2c26;

  --glass-panel: rgba(36, 26, 22, 0.62);
  --glass-panel2: rgba(46, 33, 28, 0.55);
  --glass-edge: rgba(255, 190, 150, 0.18);
  --glass-user: rgba(255, 122, 77, 0.30);
  --glass-user-edge: rgba(255, 150, 110, 0.50);
  --glass-gloss: rgba(255, 255, 255, 0.12);
}
:root[data-theme="forest"] {
  --bg: #0e1512;
  --panel: #16201b;
  --panel-2: #1c2a23;
  --text: #e0f0e8;
  --muted: #7ea892;
  --accent: #4ade80;
  --accent-dim: rgba(74, 222, 128, 0.12);
  --border: #243830;

  --glass-panel: rgba(22, 32, 27, 0.62);
  --glass-panel2: rgba(28, 42, 35, 0.55);
  --glass-edge: rgba(160, 230, 190, 0.16);
  --glass-user: rgba(74, 222, 128, 0.25);
  --glass-user-edge: rgba(120, 235, 160, 0.45);
  --glass-gloss: rgba(255, 255, 255, 0.12);
}
:root[data-theme="purple-haze"] {
  --bg: #130f1e;
  --panel: #1c1628;
  --panel-2: #241d34;
  --text: #ece4f5;
  --muted: #9a8ab5;
  --accent: #a678ff;
  --accent-dim: rgba(166, 120, 255, 0.14);
  --border: #2e2442;

  --glass-panel: rgba(28, 22, 40, 0.62);
  --glass-panel2: rgba(36, 29, 52, 0.55);
  --glass-edge: rgba(200, 170, 255, 0.18);
  --glass-user: rgba(166, 120, 255, 0.30);
  --glass-user-edge: rgba(190, 155, 255, 0.50);
  --glass-gloss: rgba(255, 255, 255, 0.12);
}

/* Theme picker */
.theme-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  padding: 12px;
}
.theme-swatch {
  width: 56px;
  height: 56px;
  border-radius: 14px;
  cursor: pointer;
  border: 2px solid transparent;
  transition: transform 0.15s, border-color 0.15s;
  position: relative;
  overflow: hidden;
}
.theme-swatch:hover { transform: scale(1.08); }
.theme-swatch.active { border-color: var(--accent); }
.theme-swatch-label {
  font-size: 0.7em;
  text-align: center;
  margin-top: 4px;
  color: var(--muted);
}
.theme-option { display: flex; flex-direction: column; align-items: center; }

/* Animated background */
:root[data-bg="stars"] #messages::before {
  content: "";
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background-image:
    radial-gradient(2px 2px at 8% 15%, rgba(255,255,255,0.95) 50%, transparent 51%),
    radial-gradient(1px 1px at 15% 45%, rgba(255,255,255,0.7) 50%, transparent 51%),
    radial-gradient(2px 2px at 25% 75%, rgba(255,255,255,0.9) 50%, transparent 51%),
    radial-gradient(1px 1px at 35% 25%, rgba(255,255,255,0.8) 50%, transparent 51%),
    radial-gradient(3px 3px at 45% 55%, rgba(255,255,255,0.95) 50%, transparent 51%),
    radial-gradient(1px 1px at 55% 10%, rgba(255,255,255,0.7) 50%, transparent 51%),
    radial-gradient(2px 2px at 65% 85%, rgba(255,255,255,0.9) 50%, transparent 51%),
    radial-gradient(1px 1px at 75% 35%, rgba(255,255,255,0.8) 50%, transparent 51%),
    radial-gradient(2px 2px at 85% 65%, rgba(255,255,255,0.95) 50%, transparent 51%),
    radial-gradient(1px 1px at 92% 20%, rgba(255,255,255,0.7) 50%, transparent 51%),
    radial-gradient(2px 2px at 5% 90%, rgba(255,255,255,0.85) 50%, transparent 51%),
    radial-gradient(1px 1px at 50% 90%, rgba(255,255,255,0.75) 50%, transparent 51%),
    radial-gradient(3px 3px at 70% 5%, rgba(180,200,255,0.9) 50%, transparent 51%),
    radial-gradient(2px 2px at 30% 5%, rgba(180,200,255,0.85) 50%, transparent 51%);
  animation: starTwinkle 3s ease-in-out infinite alternate;
  pointer-events: none;
  z-index: 0;
}
@keyframes starTwinkle {
  0% { opacity: 0.5; }
  100% { opacity: 1; }
}
:root[data-bg="stars"] #messages > * {
  position: relative;
  z-index: 1;
}
:root[data-bg="gradient-flow"] body {
  background: linear-gradient(135deg, var(--bg) 0%, var(--panel) 50%, var(--bg) 100%);
  background-size: 200% 200%;
  animation: gradientFlow 12s ease infinite;
}
@keyframes gradientFlow {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}
:root[data-bg="aurora"] body::before {
  content: "";
  position: fixed;
  top: -50%; left: -50%;
  width: 200%; height: 200%;
  background:
    radial-gradient(ellipse 40% 30% at 30% 40%, rgba(108,140,255,0.08) 0%, transparent 70%),
    radial-gradient(ellipse 35% 25% at 70% 60%, rgba(166,120,255,0.06) 0%, transparent 70%),
    radial-gradient(ellipse 30% 20% at 50% 80%, rgba(74,222,128,0.05) 0%, transparent 70%);
  animation: auroraDrift 18s ease-in-out infinite alternate;
  pointer-events: none;
  z-index: 0;
}
@keyframes auroraDrift {
  0% { transform: translate(0, 0) rotate(0deg); }
  100% { transform: translate(3%, 2%) rotate(2deg); }
}

/* ---------- voice waveform ---------- */
.voice-waveform {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  background: var(--accent-dim);
  border-top: 1px solid var(--border);
}
.vw-bars {
  display: flex;
  align-items: center;
  gap: 3px;
  height: 32px;
  flex: 1;
}
.vw-bars span {
  width: 4px;
  border-radius: 2px;
  background: var(--accent);
  animation: vwBounce 0.9s ease-in-out infinite;
  height: 30%;
}
@keyframes vwBounce {
  0%, 100% { height: 20%; opacity: 0.5; }
  50% { height: 100%; opacity: 1; }
}
.vw-label {
  font-size: 0.8em;
  color: var(--muted);
  white-space: nowrap;
}

/* ---------- Upgraded typing indicator ---------- */
.typing {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 0;
}
.typing span {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--accent);
  animation: typingBounce 1.3s ease-in-out infinite;
  box-shadow: 0 0 6px rgba(108,140,255,0.5);
}
.typing span:nth-child(1) { animation-delay: 0s; }
.typing span:nth-child(2) { animation-delay: 0.15s; }
.typing span:nth-child(3) { animation-delay: 0.3s; }
@keyframes typingBounce {
  0%, 60%, 100% { transform: translateY(0) scale(0.85); opacity: 0.5; }
  30% { transform: translateY(-6px) scale(1.1); opacity: 1; }
}
/* Shimmer on the working bar text */
#working {
  position: relative;
  overflow: hidden;
}
#working::after {
  content: "";
  position: absolute;
  top: 0; left: -40%;
  width: 30%; height: 100%;
  background: linear-gradient(105deg, transparent, rgba(255,255,255,0.08), transparent);
  animation: workingShimmer 2s ease-in-out infinite;
}
@keyframes workingShimmer {
  0% { left: -40%; }
  100% { left: 130%; }
}

/* ---------- Upgraded chat list ---------- */
.chat-section-label {
  font-size: 0.72em;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  padding: 14px 12px 6px;
  list-style: none;
}

/* Collapsible System sessions section (health checks, scheduled sweeps) */
.chat-system-wrap { list-style: none; }
.chat-system-toggle {
  background: none;
  border: none;
  cursor: pointer;
  width: 100%;
  text-align: left;
  font: inherit;
  opacity: 0.75;
}
.chat-system-toggle:hover { opacity: 1; }
.chat-system-list {
  display: none;
  margin: 0;
  padding: 0;
  opacity: 0.7;
}
.chat-system-wrap.open .chat-system-list { display: block; }
.chat-item {
  list-style: none;
  margin: 2px 8px;
  border-radius: 10px;
  position: relative;
}
.chat-item-btn {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  width: 100%;
  text-align: left;
  background: transparent;
  border: none;
  color: var(--text);
  padding: 10px 12px;
  border-radius: 10px;
  cursor: pointer;
  gap: 3px;
}
.chat-item-btn:hover { background: var(--panel-2); }
.chat-item.active .chat-item-btn {
  background: var(--accent-dim);
  border: 1px solid rgba(90, 200, 250, 0.35);
}
.chat-item-title {
  font-size: 0.92em;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}
.chat-item-meta {
  font-size: 0.75em;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 6px;
}
.chat-item-date {
  font-size: 0.75em;
  color: var(--accent);
  font-weight: 600;
}
.unread-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 6px var(--accent);
  flex-shrink: 0;
  animation: unreadPulse 2s ease-in-out infinite;
}
@keyframes unreadPulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.6; transform: scale(0.85); }
}
.chat-pin-btn {
  position: absolute;
  right: 6px;
  top: 8px;
  background: transparent;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.9em;
  opacity: 0;
  padding: 2px 4px;
}
.chat-item:hover .chat-pin-btn { opacity: 0.7; }
.chat-item.pinned .chat-pin-btn { opacity: 1; color: var(--accent); }

/* ---------- Message search ---------- */
#search-bar {
  display: flex;
  gap: 8px;
  padding: 10px 14px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  align-items: center;
}
#search-bar.hidden { display: none; }
#search-input {
  flex: 1;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 12px;
  color: var(--text);
  font-size: 0.95em;
  outline: none;
}
#search-input:focus { border-color: var(--accent); }
#search-count {
  font-size: 0.8em;
  color: var(--muted);
  white-space: nowrap;
}
.search-nav-btn {
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  padding: 6px 10px;
  cursor: pointer;
  font-size: 0.9em;
}
.search-highlight {
  background: rgba(255, 200, 50, 0.35);
  border-radius: 3px;
  padding: 0 2px;
}
.search-highlight.current {
  background: rgba(255, 150, 30, 0.6);
  outline: 2px solid rgba(255, 150, 30, 0.8);
}
.bubble.search-match {
  outline: 2px solid rgba(255, 200, 50, 0.5);
  outline-offset: 2px;
}

/* ---------- Swipe to reply ---------- */
.bubble {
  touch-action: pan-y;
  transition: transform 0.15s ease-out;
}
.bubble.swiping {
  transition: none;
}
.swipe-hint {
  position: absolute;
  left: 8px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 1.2em;
  opacity: 0;
  pointer-events: none;
}
.bubble.swiping .swipe-hint { opacity: 0.7; }

/* ---------- Collapsible messages ---------- */
.bubble.collapsed .collapsible-content {
  max-height: 120px;
  overflow: hidden;
  position: relative;
}
.bubble.collapsed .collapsible-content::after {
  content: "";
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 50px;
  background: linear-gradient(transparent, var(--panel));
}
.collapse-toggle {
  background: var(--accent-dim);
  border: 1px solid rgba(90, 200, 250, 0.3);
  color: var(--accent);
  border-radius: 8px;
  padding: 4px 12px;
  font-size: 0.82em;
  cursor: pointer;
  margin-top: 8px;
  font-weight: 600;
}

/* ---------- Message timestamps ---------- */
.msg-time {
  font-size: 0.7em;
  color: var(--muted);
  margin-top: 4px;
  opacity: 0;
  transition: opacity 0.2s;
  text-align: right;
}
.bubble.show-time .msg-time { opacity: 1; }
.bubble.user .msg-time { text-align: right; }
.bubble.assistant .msg-time { text-align: left; }

/* ---------- Settings panel ---------- */
#settings-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
#settings-overlay.hidden { display: none; }
#settings-panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 18px;
  max-width: 440px;
  width: 100%;
  max-height: 82vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.settings-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px 0;
}
.settings-header h2 {
  margin: 0;
  font-size: 1.2em;
}
.settings-close {
  background: transparent;
  border: none;
  color: var(--muted);
  font-size: 1.3em;
  cursor: pointer;
  padding: 4px 8px;
}
.settings-section {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
}
.settings-section:last-child { border-bottom: none; }
.settings-section-title {
  font-size: 0.78em;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin-bottom: 12px;
}
.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 0;
  gap: 12px;
}
.setting-row + .setting-row { border-top: 1px solid var(--border); }
.setting-label { font-size: 0.95em; }
.setting-desc { font-size: 0.8em; color: var(--muted); margin-top: 2px; }
/* Toggle switch */
.toggle-switch {
  position: relative;
  width: 50px;
  height: 28px;
  flex-shrink: 0;
  cursor: pointer;
}
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-track {
  position: absolute;
  inset: 0;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 14px;
  transition: background 0.2s;
}
.toggle-track::before {
  content: "";
  position: absolute;
  width: 22px; height: 22px;
  left: 2px; top: 2px;
  background: var(--muted);
  border-radius: 50%;
  transition: transform 0.2s, background 0.2s;
}
.toggle-switch input:checked + .toggle-track { background: var(--accent-dim); border-color: var(--accent); }
.toggle-switch input:checked + .toggle-track::before {
  transform: translateX(22px);
  background: var(--accent);
}
/* Slider */
.setting-slider {
  width: 130px;
  accent-color: var(--accent);
}
/* Voice select */
.setting-select {
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 0.88em;
  max-width: 160px;
}

/* ---------- Premium icon buttons ---------- */
.head-actions button,
.brand button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: 12px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--text);
  cursor: pointer;
  transition: all 0.18s ease;
  padding: 0;
}
.head-actions button:hover,
.brand button:hover {
  background: var(--accent-dim);
  border-color: var(--accent);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(90, 200, 250, 0.15);
}
.head-actions button:active,
.brand button:active {
  transform: translateY(0) scale(0.95);
  box-shadow: none;
}
.head-actions button svg,
.brand button svg {
  width: 19px;
  height: 19px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
/* New chat keeps text but gets premium styling */
#new-chat {
  width: auto;
  padding: 0 16px;
  font-size: 0.88em;
  font-weight: 600;
  gap: 6px;
}
#new-chat svg {
  width: 15px;
  height: 15px;
}

/* ---------- Composer icon buttons ---------- */
#composer button,
.composer-actions button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: 12px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--text);
  cursor: pointer;
  transition: all 0.18s ease;
  padding: 0;
  flex-shrink: 0;
}
#composer button:hover,
.composer-actions button:hover {
  background: var(--accent-dim);
  border-color: var(--accent);
  transform: translateY(-1px);
}
#composer button:active,
.composer-actions button:active {
  transform: scale(0.95);
}
#composer button svg,
.composer-actions button svg {
  width: 18px;
  height: 18px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
#send {
  background: var(--accent) !important;
  border-color: var(--accent) !important;
  color: #fff !important;
}
#send:hover {
  filter: brightness(1.1);
  box-shadow: 0 4px 14px rgba(90, 200, 250, 0.35);
}

/* ---------- Sidebar tools ---------- */
.sidebar-tools {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 0 12px 12px;
}
.sidebar-tools-head { margin-top: 8px; }
#search-toggle, #settings-toggle {
  display: flex !important;
  align-items: center;
  gap: 10px;
  width: 100% !important;
  height: auto !important;
  padding: 10px 14px !important;
  border-radius: 10px !important;
  background: var(--panel-2) !important;
  border: 1px solid var(--border) !important;
  color: var(--text) !important;
  cursor: pointer;
  font-size: 0.92em;
  transition: all 0.15s ease;
}
#search-toggle:hover, #settings-toggle:hover {
  background: var(--accent-dim) !important;
  border-color: var(--accent) !important;
  transform: none !important;
  box-shadow: none !important;
}
#search-toggle svg, #settings-toggle svg {
  width: 18px !important;
  height: 18px !important;
  flex-shrink: 0;
}
.sidebar-tool-label { font-weight: 500; }
/* Header: only + button remains, make it clean */
.head-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ---------- Starfield foreground overlay ---------- */
:root[data-bg="stars"] body::after {
  content: "";
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background-image:
    radial-gradient(2px 2px at 8% 15%, rgba(255,255,255,0.9) 50%, transparent 51%),
    radial-gradient(1px 1px at 15% 45%, rgba(255,255,255,0.65) 50%, transparent 51%),
    radial-gradient(2px 2px at 25% 75%, rgba(255,255,255,0.85) 50%, transparent 51%),
    radial-gradient(1px 1px at 35% 25%, rgba(255,255,255,0.75) 50%, transparent 51%),
    radial-gradient(3px 3px at 45% 55%, rgba(255,255,255,0.9) 50%, transparent 51%),
    radial-gradient(1px 1px at 55% 10%, rgba(255,255,255,0.65) 50%, transparent 51%),
    radial-gradient(2px 2px at 65% 85%, rgba(255,255,255,0.85) 50%, transparent 51%),
    radial-gradient(1px 1px at 75% 35%, rgba(255,255,255,0.75) 50%, transparent 51%),
    radial-gradient(2px 2px at 85% 65%, rgba(255,255,255,0.9) 50%, transparent 51%),
    radial-gradient(1px 1px at 92% 20%, rgba(255,255,255,0.65) 50%, transparent 51%),
    radial-gradient(2px 2px at 5% 90%, rgba(255,255,255,0.8) 50%, transparent 51%),
    radial-gradient(1px 1px at 50% 90%, rgba(255,255,255,0.7) 50%, transparent 51%),
    radial-gradient(3px 3px at 70% 5%, rgba(180,200,255,0.85) 50%, transparent 51%),
    radial-gradient(2px 2px at 30% 5%, rgba(180,200,255,0.8) 50%, transparent 51%),
    radial-gradient(1px 1px at 12% 60%, rgba(255,255,255,0.6) 50%, transparent 51%),
    radial-gradient(2px 2px at 88% 45%, rgba(255,255,255,0.75) 50%, transparent 51%);
  animation: starTwinkle 3s ease-in-out infinite alternate;
  pointer-events: none;
  z-index: 9999;
  opacity: 0.55;
}
@keyframes starTwinkle {
  0% { opacity: 0.35; }
  100% { opacity: 0.7; }
}

/* ---------- Premium pin button ---------- */
.chat-pin-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: transparent;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  transition: all 0.15s ease;
  padding: 0;
  flex-shrink: 0;
}
.chat-pin-btn:hover {
  background: var(--accent-dim);
  color: var(--accent);
  transform: scale(1.1);
}
.chat-pin-btn svg {
  width: 16px;
  height: 16px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.6;
  stroke-linejoin: round;
}
.chat-item.pinned .chat-pin-btn {
  color: #f5b942;
  filter: drop-shadow(0 0 3px rgba(245, 185, 66, 0.5));
}

/* ---------- Header: just the + sign, more breathing room ---------- */
.head-actions {
  margin-left: auto;
  padding-right: 4px;
}
#new-chat {
  width: 40px !important;
  height: 40px !important;
  padding: 0 !important;
  border-radius: 50% !important;
  background: var(--accent) !important;
  border: none !important;
  color: #fff !important;
  box-shadow: 0 2px 10px rgba(90, 200, 250, 0.3);
}
#new-chat:hover {
  filter: brightness(1.12);
  box-shadow: 0 4px 16px rgba(90, 200, 250, 0.45);
  transform: translateY(-1px) !important;
}
#new-chat svg {
  width: 18px !important;
  height: 18px !important;
  stroke-width: 2.2;
}

/* ---------- Liquid Glass theme (stable) ---------- */
:root[data-theme="glass"] {
  --bg: #05070f;
  --panel: rgba(255, 255, 255, 0.06);
  --panel-2: rgba(255, 255, 255, 0.09);
  --text: #ffffff;
  --text-dim: rgba(255, 255, 255, 0.6);
  --border: rgba(255, 255, 255, 0.18);
  --accent: #8aa2ff;
  --accent-dim: rgba(138, 162, 255, 0.22);
  --radius: 24px;
}
:root[data-theme="glass"] body {
  background:
    radial-gradient(ellipse 80% 50% at 20% -10%, rgba(80, 120, 255, 0.22), transparent),
    radial-gradient(ellipse 60% 40% at 90% 110%, rgba(150, 80, 255, 0.15), transparent),
    linear-gradient(160deg, #070b18 0%, #0c1230 50%, #070a16 100%);
  
}
/* Only header/footer/tabbar get backdrop blur (3 elements, iOS-safe) */
:root[data-theme="glass"] header,
:root[data-theme="glass"] #tabbar {
  background: linear-gradient(180deg, rgba(40, 52, 95, 0.85), rgba(22, 30, 60, 0.9)) !important;
  border: 1px solid rgba(255, 255, 255, 0.14) !important;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.25), inset 0 -6px 12px rgba(0, 0, 20, 0.12);
}
:root[data-theme="glass"] footer {
  background: transparent !important;
  border: none !important;
}
:root[data-theme="glass"] #sidebar {
  background: linear-gradient(180deg, rgba(20, 30, 60, 0.96), rgba(14, 20, 42, 0.96)) !important;
}
/* Bubbles: translucent gradients, NO backdrop-filter (iOS can't handle dozens) */
:root[data-theme="glass"] .bubble {
  background: linear-gradient(180deg, rgba(70, 88, 150, 0.6) 0%, rgba(42, 54, 100, 0.55) 100%) !important;
  border: 1px solid rgba(255, 255, 255, 0.22) !important;
  border-radius: 22px !important;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.28), inset 0 -8px 16px rgba(0, 0, 20, 0.15);
}
:root[data-theme="glass"] .bubble.user {
  background: linear-gradient(180deg, rgba(130, 160, 255, 0.65) 0%, rgba(85, 115, 235, 0.55) 100%) !important;
  border: 1px solid rgba(170, 195, 255, 0.35) !important;
  border-radius: 22px 6px 6px 22px !important;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.35), inset 0 -8px 16px rgba(20, 40, 120, 0.2);
}
:root[data-theme="glass"] .bubble.assistant {
  border-radius: 6px 22px 22px 22px !important;
}
:root[data-theme="glass"] .composer-pill {
  background: linear-gradient(180deg, rgba(45, 58, 105, 0.75), rgba(28, 38, 72, 0.7)) !important;
  border: 1px solid rgba(255, 255, 255, 0.24) !important;
  border-radius: 20px !important;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.28), inset 0 -6px 12px rgba(0, 0, 20, 0.12);
  margin: 0 8px 0;
}
:root[data-theme="glass"] #tabbar {
  border-radius: 0 !important;
  margin: 0 !important;
  padding: 4px 4px calc(4px + env(safe-area-inset-bottom)) !important;
  border-left: none !important;
  border-right: none !important;
  border-bottom: none !important;
}
:root[data-theme="glass"] #tabbar button.active {
  background: rgba(138, 162, 255, 0.25) !important;
  border-radius: 18px !important;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.25);
}
:root[data-theme="glass"] .chat-item {
  background: rgba(255, 255, 255, 0.05) !important;
  border: 1px solid rgba(255, 255, 255, 0.1) !important;
  border-radius: 14px !important;
}
:root[data-theme="glass"] #new-chat {
  background: linear-gradient(135deg, #8aa2ff, #5a78e8) !important;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.35),
    0 4px 16px rgba(124, 155, 255, 0.4) !important;
}
:root[data-theme="glass"] #send {
  background: linear-gradient(135deg, #8aa2ff, #5a78e8) !important;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.35),
    0 4px 12px rgba(124, 155, 255, 0.35) !important;
}

/* ---------- Right-edge pull tab ---------- */
#sidebar-pulltab {
  position: fixed;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 28px;
  height: 72px;
  border-radius: 14px 0 0 14px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-right: none;
  color: var(--text-dim);
  cursor: pointer;
  z-index: 55;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: all 0.2s ease;
  box-shadow: -2px 0 12px rgba(0, 0, 0, 0.25);
}
#sidebar-pulltab:hover {
  width: 34px;
  color: var(--accent);
  background: var(--accent-dim);
}
#sidebar-pulltab:active {
  transform: translateY(-50%) scale(0.95);
}
#sidebar-pulltab svg {
  stroke: currentColor;
  fill: none;
}
/* Hide pull tab when sidebar is open */
#app.sidebar-open #sidebar-pulltab {
  opacity: 0;
  pointer-events: none;
}
/* Glass theme pull tab */
:root[data-theme="glass"] #sidebar-pulltab {
  background: linear-gradient(180deg, rgba(45, 58, 105, 0.8), rgba(28, 38, 72, 0.75)) !important;
  border: 1px solid rgba(255, 255, 255, 0.2) !important;
  border-right: none !important;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2), -2px 0 12px rgba(0, 0, 0, 0.3);
}

/* ---------- Delivering state: gold glow when message lands ---------- */
#nova-avatar.delivering { transform: scale(1.4); }
#nova-avatar.delivering .eye {
  filter: drop-shadow(0 0 4px #f5b942) drop-shadow(0 0 10px #f5b942) drop-shadow(0 0 18px #ff8c00) !important;
  animation: deliveringBlink 0.45s ease-in-out infinite !important;
}
@keyframes deliveringBlink {
  0%, 100% { opacity: 1; transform: scale(1.2); }
  50% { opacity: 0.7; transform: scale(1); }
}
#nova-avatar.delivering::after {
  content: '';
  position: absolute;
  inset: -8px;
  border-radius: 50%;
  border: 2px solid rgba(245, 185, 66, 0.6);
  animation: deliveringRing 0.9s ease-out infinite;
  pointer-events: none;
}
@keyframes deliveringRing {
  0% { transform: scale(0.9); opacity: 1; }
  100% { transform: scale(1.3); opacity: 0; }
}
#nova-avatar.delivering .pulse-ring {
  border-color: rgba(245, 185, 66, 0.5) !important;
}

/* ---------- Safari bottom-gap fix (2026-10-11, tightened): paint home-bar area ---------- */
html, body {
  background: var(--bg);
  min-height: -webkit-fill-available;
}
#app {
  min-height: -webkit-fill-available;
  background: var(--bg);
}
/* filler below the fixed tabbar so the iPhone home-bar strip inherits the
   bar's background instead of showing page/white behind it.
   Use a solid theme color (not inherit/translucent) so Safari white can't
   bleed through, and extend tall enough to cover the swipe-bar zone. */
#tabbar {
  padding-bottom: calc(4px + env(safe-area-inset-bottom, 0px));
  padding-bottom: calc(4px + constant(safe-area-inset-bottom, 0px));
}
#tabbar::after {
  content: "";
  position: absolute;
  left: 0; right: 0; top: 100%;
  height: 50px;
  background: var(--panel);
}
:root[data-theme="glass"] #tabbar::after {
  background: rgba(22, 30, 60, 0.97) !important;
}
/* tighten the clearance above the fixed tabbar: 62px left an ~8px dead
   strip of page background between composer/refresh and tabs */
#main-col, .tab-view {
  padding-bottom: calc(54px + env(safe-area-inset-bottom, 0px));
}

/* ---------- Universal Glass — every theme (2026-10-11, v3 vars) ----------
   Frosted glass everywhere, tinted per-theme via --glass-* vars (no color-mix,
   so it works on iPhone Safari). Blur only on chrome + bubbles + sidebar +
   settings (iOS-safe); cards are translucent without blur. */
header,
.view-header,
#tabbar,
.composer-pill,
.bubble,
#sidebar,
#settings-panel {
  -webkit-backdrop-filter: blur(20px) saturate(1.6);
  backdrop-filter: blur(20px) saturate(1.6);
}
/* top chrome tints with the theme */
header,
.view-header {
  background:
    linear-gradient(180deg, var(--glass-gloss) 0%, rgba(255,255,255,0.02) 45%, transparent 60%),
    var(--glass-panel) !important;
  border-bottom: 1px solid var(--glass-edge) !important;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.22), 0 4px 24px rgba(0,0,0,0.25);
}
/* bottom tab bar tints with the theme */
#tabbar {
  background:
    linear-gradient(180deg, var(--glass-gloss) 0%, rgba(255,255,255,0.02) 40%, transparent 60%),
    var(--glass-panel) !important;
  border-top: 1px solid var(--glass-edge) !important;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.20), 0 8px 32px rgba(0,0,0,0.35);
}
#tabbar::after {
  background: var(--glass-panel) !important;
}
/* footer goes transparent so the glass composer pill floats */
footer {
  background: transparent !important;
  border-top: none !important;
}
#refresh-row {
  background: transparent !important;
  border-top: none !important;
}
/* THE response box (composer pill) — frosted glass tinted by theme */
.composer-pill {
  background:
    linear-gradient(180deg, var(--glass-gloss) 0%, rgba(255,255,255,0.03) 45%, transparent 60%),
    var(--glass-panel2) !important;
  border: 1px solid var(--glass-edge) !important;
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.28),
    inset 0 -6px 12px rgba(0,0,20,0.12),
    0 8px 28px rgba(0,0,0,0.35) !important;
}
/* chat bubbles — frosted glass tinted by the theme */
.bubble {
  border: 1px solid var(--glass-edge) !important;
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.24),
    inset 0 -8px 16px rgba(0,0,20,0.10),
    0 6px 22px rgba(0,0,0,0.25) !important;
}
.bubble.assistant {
  background:
    linear-gradient(180deg, var(--glass-gloss) 0%, rgba(255,255,255,0.03) 45%, transparent 60%),
    var(--glass-panel2) !important;
  border-radius: 6px 22px 22px 22px !important;
}
.bubble.user {
  background:
    linear-gradient(180deg, rgba(255,255,255,0.14) 0%, rgba(255,255,255,0.03) 45%, transparent 60%),
    var(--glass-user) !important;
  border-color: var(--glass-user-edge) !important;
  border-radius: 22px 6px 6px 22px !important;
}
/* sidebar + settings panel — frosted */
#sidebar {
  background: var(--glass-panel) !important;
  border-left: 1px solid var(--glass-edge) !important;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.14) !important;
}
#settings-panel {
  background: var(--glass-panel) !important;
  border: 1px solid var(--glass-edge) !important;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.2), 0 20px 60px rgba(0,0,0,0.5) !important;
}
/* cards — translucent tint, NO blur (iOS-safe) */
.goal-card, .account-card, .tasks-section, .idea-list li,
.product-card, .weather-card, .map-card, .link-preview,
.chat-item {
  background: var(--glass-panel2) !important;
  border: 1px solid var(--glass-edge) !important;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.14) !important;
}
/* light theme needs a softer shadow so glass edges stay visible */
:root[data-theme="light"] header,
:root[data-theme="light"] .view-header,
:root[data-theme="light"] #tabbar,
:root[data-theme="light"] .composer-pill,
:root[data-theme="light"] .bubble,
:root[data-theme="light"] #settings-panel {
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.7),
    0 6px 22px rgba(30,40,70,0.12) !important;
}
/* keep bespoke Liquid Glass theme intact — restore its custom gradients
   (universal glass above would otherwise override them since it comes later) */
:root[data-theme="glass"] header,
:root[data-theme="glass"] #tabbar {
  background: linear-gradient(180deg, rgba(40, 52, 95, 0.85), rgba(22, 30, 60, 0.9)) !important;
}
:root[data-theme="glass"] footer,
:root[data-theme="glass"] #refresh-row {
  background: transparent !important;
  border: none !important;
}
:root[data-theme="glass"] .bubble {
  background: linear-gradient(180deg, rgba(70, 88, 150, 0.6) 0%, rgba(42, 54, 100, 0.55) 100%) !important;
}
:root[data-theme="glass"] .bubble.user {
  background: linear-gradient(180deg, rgba(130, 160, 255, 0.65) 0%, rgba(85, 115, 235, 0.55) 100%) !important;
}
:root[data-theme="glass"] .composer-pill {
  background: linear-gradient(180deg, rgba(45, 58, 105, 0.75), rgba(28, 38, 72, 0.7)) !important;
}

/* ---------- Sidebar top safe-area (iPhone notch fix) ---------- */
#sidebar {
  padding-top: env(safe-area-inset-top);
}
.sidebar-scroll {
  padding-top: 6px;
}
.side-head:first-child {
  padding-top: calc(14px + 4px);
  position: sticky;
  top: 0;
  background: inherit;
  z-index: 2;
}

/* ---------- Collapsible sidebar sections ---------- */
#sidebar .side-head.collapsible {
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}
#sidebar .side-head.collapsible:active { opacity: 0.7; }
#sidebar .side-head .collapse-chevron {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-left: auto;
  width: 28px;
  height: 28px;
  flex-shrink: 0;
  border-radius: 8px;
  color: var(--muted);
  font-size: 13px;
  transition: transform 0.22s ease;
}
#sidebar .side-head.collapsed .collapse-chevron {
  transform: rotate(-90deg);
}
#sidebar .side-body.collapsed { display: none; }
/* keep the close button tappable without toggling */
#sidebar-close { position: relative; z-index: 2; }

/* ---- Live Browser view (2026-10-16, watch-only) ---- */
.browser-body { display: flex; flex-direction: column; gap: 10px; }
.browser-chrome {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 10px;
}
.browser-dot { width: 9px; height: 9px; border-radius: 50%; background: #8a8f98; flex: 0 0 auto; }
.browser-dot.live { background: #37d67a; box-shadow: 0 0 8px rgba(55, 214, 122, 0.7); }
.browser-dot.stale { background: #8a8f98; box-shadow: none; }
.browser-url {
  flex: 1 1 auto; min-width: 0;
  font-size: 13px; color: #cfd6e4;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.browser-mode-badge {
  flex: 0 0 auto;
  font-size: 11px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase;
  color: #0b0e13; background: #5ac8fa;
  padding: 3px 8px; border-radius: 999px;
}
.browser-mode-badge[data-mode="stealth"] { background: #b48ffa; }
.browser-mode-badge[data-mode="camo"] { background: #7ae0a3; }
.browser-stage {
  position: relative;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px; overflow: hidden;
  background: #000; min-height: 200px;
}
.browser-stage img { display: block; width: 100%; height: auto; }
.browser-stage img[hidden] { display: none; }
.browser-idle { padding: 48px 20px; text-align: center; }
.browser-idle[hidden] { display: none; }
.browser-idle-icon { font-size: 40px; margin: 0 0 10px; }
#browser-idle-text { font-size: 16px; margin: 0 0 6px; }
.browser-note { text-align: center; margin: 2px 0 0; }
.browser-tab-chip { flex: 0 0 auto; font-size: 11px; font-weight: 600; color: #cfd6e4; background: rgba(255,255,255,0.10); padding: 3px 8px; border-radius: 999px; white-space: nowrap; }
.browser-tab-chip[hidden] { display: none; }
.browser-caption { position: absolute; left: 8px; right: 8px; bottom: 8px; z-index: 3; background: rgba(5,10,16,0.80); color: #eaf4fb; font-size: 12.5px; line-height: 1.35; padding: 7px 10px 7px 24px; border-radius: 8px; pointer-events: none; }
.browser-caption[hidden] { display: none; }
.browser-caption::before { content: ""; position: absolute; left: 10px; top: 50%; width: 7px; height: 7px; margin-top: -3.5px; border-radius: 50%; background: #37d67a; animation: browserCapPulse 1.1s ease-in-out infinite; }
@keyframes browserCapPulse { 0%,100% { opacity: 1; } 50% { opacity: 0.25; } }
.browser-cursor { position: absolute; z-index: 4; width: 22px; height: 22px; transform: translate(-50%,-50%); transition: left 0.45s ease, top 0.45s ease; pointer-events: none; }
.browser-cursor[hidden] { display: none; }
.browser-cursor-dot { position: absolute; left: 50%; top: 50%; width: 11px; height: 11px; transform: translate(-50%,-50%); border-radius: 50%; background: rgba(90,200,250,0.92); border: 2px solid #fff; box-shadow: 0 1px 6px rgba(0,0,0,0.55); }
.browser-cursor-ring { position: absolute; left: 50%; top: 50%; width: 22px; height: 22px; transform: translate(-50%,-50%); border-radius: 50%; border: 2px solid rgba(90,200,250,0.85); opacity: 0; }
.browser-cursor.pulse .browser-cursor-ring { animation: browserClickPulse 0.55s ease-out; }
@keyframes browserClickPulse { 0% { opacity: 0.95; transform: translate(-50%,-50%) scale(0.35); } 100% { opacity: 0; transform: translate(-50%,-50%) scale(1.5); } }
@media (prefers-reduced-motion: reduce) { .browser-cursor { transition: none; } .browser-caption::before { animation: none; } }

/* ---------- Live action status (replaces three-dots typing, 2026-10-16) ---------- */
.action-status { display: inline-flex; align-items: center; gap: 8px; }
.action-label { font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 62vw; display: inline-block; vertical-align: middle; }

/* browser drive controls (phase 2) */
.browser-drive { margin-top: 10px; display: flex; flex-direction: column; gap: 8px; }
.browser-drive-urlrow { display: flex; gap: 8px; }
.browser-drive-urlrow input {
  flex: 1 1 auto; min-width: 0;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.10);
  border-radius: 10px; padding: 9px 12px;
  color: #e8edf5; font-size: 14px;
}
.browser-drive-urlrow button, .browser-drive-form > button {
  flex: 0 0 auto;
  background: #5ac8fa; color: #0b0e13;
  border: none; border-radius: 10px;
  padding: 9px 16px; font-size: 14px; font-weight: 700;
}
.browser-drive-keys { display: flex; gap: 6px; flex-wrap: wrap; }
.browser-drive-keys button {
  flex: 1 1 auto;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.10);
  border-radius: 8px; padding: 7px 6px;
  color: #cfd6e4; font-size: 12.5px; font-weight: 600;
}
.browser-drive-form { display: flex; gap: 8px; align-items: stretch; }
.browser-drive-toggle { display: flex; flex: 0 0 auto; border: 1px solid rgba(255, 255, 255, 0.10); border-radius: 10px; overflow: hidden; }
.browser-drive-toggle button {
  background: rgba(255, 255, 255, 0.04); color: #8a8f98;
  border: none; padding: 9px 12px; font-size: 13px; font-weight: 700;
}
.browser-drive-toggle button.active { background: #5ac8fa; color: #0b0e13; }
.browser-drive-form input {
  flex: 1 1 auto; min-width: 0;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.10);
  border-radius: 10px; padding: 9px 12px;
  color: #e8edf5; font-size: 14px;
}
.browser-drive-status { margin: 0; font-size: 12.5px; color: #cfd6e4; text-align: center; }
.browser-drive-status[hidden] { display: none; }

/* ---------- parity views + scrollable tab bar (2026-10-17) ---------- */
#tabbar { overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
#tabbar::-webkit-scrollbar { display: none; }
#tabbar button { flex: 1 0 auto; min-width: 60px; }
#dash-content, #clients-content, #clips-content, #fantasy-content,
#chats-content, #calendar-content, #mail-content {
  display: flex; flex-direction: column; gap: 12px;
}
#memory-content { display: flex; flex-direction: column; gap: 12px; }
.stat-row {
  display: flex; justify-content: space-between; align-items: baseline;
  gap: 12px; padding: 7px 0;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}
.stat-row:last-child { border-bottom: none; }
.stat-row .stat-val { font-weight: 600; text-align: right; }
.ok-dot { color: #22c55e; }
.bad-dot { color: #f87171; }
.status-dot {
  display: inline-block; width: 8px; height: 8px; border-radius: 50%;
  background: #22c55e; margin-right: 8px; vertical-align: middle;
}
.status-waiting_client, .status-waiting { background: #f59e0b; }
.status-inactive, .status-paused { background: #9ca3af; }
.meta-line { color: var(--muted); font-size: 12.5px; margin: 0; }
.goal-card .meta-line { margin: 2px 0; }
.pending-list { margin: 4px 0 0; padding-left: 18px; color: var(--muted); font-size: 13.5px; }
.view-ask {
  min-height: 44px; padding: 10px 20px;
  background: var(--accent); color: #0b0e14;
  border: none; border-radius: var(--radius);
  font-size: 15px; font-weight: 600; cursor: pointer; font-family: inherit;
  width: 100%;
}
.chat-row {
  text-align: left; width: 100%; cursor: pointer;
  font: inherit; color: inherit;
}
.chat-row h3 { word-break: break-word; }
.view-search { display: flex; gap: 8px; }
.view-search input {
  flex: 1; min-width: 0;
  background: var(--bg); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 12px 14px; font-size: 16px; font-family: inherit;
}
.view-search input:focus { outline: none; border-color: var(--accent); }
.view-search button {
  min-height: 44px; padding: 10px 20px;
  background: var(--accent); color: #0b0e14;
  border: none; border-radius: var(--radius);
  font-size: 15px; font-weight: 600; cursor: pointer; font-family: inherit;
}
.mem-body { font-size: 14px; line-height: 1.5; word-break: break-word; }
.mem-body h1, .mem-body h2, .mem-body h3 { font-size: 15px; margin: 10px 0 6px; }
.mem-body p { margin: 0 0 8px; color: var(--text); }


/* ==== Speaker identity + chat polish (2026-10-23, Stephen) ====
   Nova speaks blue, Cuzvis speaks red. Labels are ::before generated
   content so they survive the renderer's innerHTML swaps. The robot
   background image is untouched. */
.bubble.assistant {
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.25);
}
.bubble.assistant::before {
  content: "Nova";
  display: block;
  font-size: 10px; font-weight: 700;
  letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 6px; opacity: 0.9;
}
.bubble.cuzvis {
  background: linear-gradient(180deg, rgba(74, 27, 27, 0.94), rgba(48, 19, 21, 0.95));
  border: 1px solid rgba(255, 96, 88, 0.45);
  border-left: 3px solid #ff6058;
  box-shadow: 0 6px 24px rgba(120, 20, 16, 0.30);
}
.bubble.cuzvis::before { content: "Cuzvis"; color: #ff7a72; }
.bubble.cuzvis a { color: #ffb3ae; border-bottom-color: rgba(255, 122, 114, 0.5); }
.bubble.cuzvis li::marker { color: #ff7a72; }
.bubble.user { box-shadow: 0 6px 20px rgba(30, 110, 160, 0.20); }
.bubble { line-height: 1.55; animation: bubbleIn 0.28s ease both; }
@keyframes bubbleIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}
@media (prefers-reduced-motion: reduce) { .bubble { animation: none; } }
#nova-avatar { filter: drop-shadow(0 0 14px rgba(90, 200, 250, 0.35)); }
#composer { box-shadow: 0 -8px 30px rgba(0, 0, 0, 0.35); backdrop-filter: blur(10px); }
/* Bottom bar: same row, faster to hit (Stephen, 2026-10-23). */
#tabbar { scroll-snap-type: x proximity; }
#tabbar button { min-height: 54px; padding: 6px 6px; scroll-snap-align: start; }
#tabbar button .tab-icon svg { width: 24px; height: 24px; }
#tabbar button .tab-label { font-size: 10.5px; font-weight: 600; letter-spacing: 0.01em; }
#tabbar button.active {
  box-shadow: inset 0 0 0 1px rgba(90, 200, 250, 0.35), 0 2px 10px rgba(90, 200, 250, 0.15);
}


/* ==== Sidebar organization (2026-10-23, Stephen) ====
   Clean section labels, sticky group headers, card rows, one system. */
#sidebar { background: rgba(15, 17, 21, 0.94); backdrop-filter: blur(14px); }
.side-head { padding: 16px 16px 6px; }
.side-head h2 {
  font-size: 11px; font-weight: 700;
  letter-spacing: 0.16em; text-transform: uppercase;
  color: var(--muted); margin: 0;
}
.side-body { padding: 4px 10px 14px; }
#chat-filter {
  width: 100%; box-sizing: border-box;
  background: var(--bg); border: 1px solid var(--border);
  border-radius: 10px; color: var(--text);
  font-size: 14px; padding: 9px 12px; margin: 2px 0 10px;
  outline: none; -webkit-user-select: text; user-select: text;
}
#chat-filter:focus { border-color: var(--accent); }
#chat-list { display: flex; flex-direction: column; gap: 4px; padding: 0; margin: 0; list-style: none; }
.chat-section-label {
  position: sticky; top: 0; z-index: 2;
  list-style: none;
  font-size: 10.5px; font-weight: 700;
  letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--muted);
  padding: 10px 6px 4px;
  background: rgba(15, 17, 21, 0.95); backdrop-filter: blur(8px);
}
button.chat-section-label.chat-system-toggle {
  width: 100%; text-align: left; border: none; cursor: pointer;
  font-family: inherit;
}
.chat-item {
  list-style: none;
  background: var(--panel); border: 1px solid var(--border);
  border-radius: 12px; margin: 0; overflow: hidden;
}
.chat-item:hover { border-color: rgba(90, 200, 250, 0.4); }
.chat-item.active { background: var(--accent-dim); border-color: rgba(90, 200, 250, 0.55); }
.chat-item-btn { padding: 9px 10px; }
.chat-item-title {
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden; font-size: 14px; line-height: 1.35; color: var(--text);
  text-align: left;
}
.chat-item-date { font-size: 11.5px; color: var(--muted); }

/* === Mobile bottom stack — fleet round 2 (2026-11-14) ===
   Spark's diagnosis, confirmed in this file: the black band under the
   tab bar is the height:100dvh / min-height:-webkit-fill-available
   clash (worst in home-screen standalone mode), and the composer
   "floats" because footer + #refresh-row are transparent over the
   fixed full-screen face canvas, with the #tabbar::after filler ghost
   and the fixed-bar clearance padding still in the stack. Cure:
   anchor #app to the visual edges (fixed, inset 0), kill the filler
   and the clearance, give the bottom stack a solid background. All
   selectors carry #app so they outrank theme rules. Desktop untouched. */
@media (max-width: 900px) {
  html, body { height: 100%; overflow: hidden; }
  #app {
    position: fixed; inset: 0; height: auto; min-height: 0;
    flex-direction: column; overflow: hidden;
  }
  #app #view-town { flex: 1 1 auto; min-height: 0; }
  #app #main-col { flex: 1 1 auto; min-height: 0; padding-bottom: 0 !important; }
  #app #tabbar { position: static; flex: none; width: 100%; }
  #app #tabbar::after { display: none !important; }
  #app #main-col footer, #app #refresh-row { background: var(--panel) !important; }
}

/* === Mobile bottom stack — fleet round 3 (2026-11-14) ===
   From Stephen's 11:01 PM screenshot, read by the whole fleet in the
   room: round 2's solid backgrounds worked (the face no longer bleeds
   through the composer), but (1) the refresh row still sits between
   the composer and the tabs as a gap row, (2) the tab bar is painted
   with the translucent --glass-panel (face tint shows through its
   lower half), and (3) the app still ends short of the screen bottom
   in home-screen standalone mode, exposing black. Round 3: hide the
   refresh row on mobile (pull-to-refresh still works), paint the tab
   bar with the solid --panel color and no backdrop blur, and paint
   the root the same solid color so any standalone sliver under the
   app matches the bar instead of reading as a black band. */
@media (max-width: 900px) {
  html, body { background: var(--panel) !important; }
  #app #refresh-row { display: none !important; }
  #app #tabbar {
    background: var(--panel) !important;
    -webkit-backdrop-filter: none !important;
    backdrop-filter: none !important;
  }
}

/* === Mobile bottom stack — fleet polish, round 4 (2026-11-14) ===
   Stephen's go ("try to fix it now"). Two cosmetic items only, from
   Spark's 11:12 PM note, fleet-agreed: (1) the text input inside the
   "Message Nova..." pill shows a darker inner box — make it
   transparent so the pill reads as one piece; (2) shave 6px off the
   tab bar's bottom (safe-area) padding, which reads tall under the
   labels. No layout or positioning changes — the round-3 stack is
   settled and stays untouched. */
@media (max-width: 900px) {
  #app #composer input, #app #composer textarea {
    background: transparent !important;
    box-shadow: none !important;
  }
  #app #tabbar {
    padding-bottom: max(0px, calc(env(safe-area-inset-bottom) - 6px)) !important;
  }
}

/* === Mobile bottom stack — round 5 (2026-11-14) ===
   The actual culprit, found by reading index.html's inline blocks:
   the 2026-11-09 "Bottom bars" block re-declares
   #app { height: 100dvh } AFTER the stylesheet link, at equal
   specificity to round 2's height:auto — so round 2's pin never
   took effect and the app stayed exactly 100dvh tall, which lands
   ~85px short of the physical screen bottom in Stephen's
   home-screen standalone app (his 11:39 PM screenshot: the whole
   stack, dashboard and message bar alike, floats that far above
   the bottom edge). Round 5 forces the fixed app to size from its
   top/bottom anchors instead of dvh. If the dead zone survives
   this, it lives in the iOS standalone shell itself and the cure
   is delete + re-add the home-screen icon. */
@media (max-width: 900px) {
  #app {
    height: auto !important;
    top: 0 !important;
    bottom: 0 !important;
  }
}
