/* ============================================================================
   NEVLAR — Chat Area Overhaul (v1)
   APPEND-ONLY override sheet. Loads AFTER style.css so it layers on top of the
   existing rules without removing any. CSS-only — touches no HTML or JS, so it
   cannot cause a runtime error / blank screen. Safe to revert by deleting the
   <link> that includes it.
   Direction: dark + sleek, gold reserved for meaning, tighter rhythm.
   ============================================================================ */

/* ── Wider left sidebar — overriding the single source variable shifts the
   whole layout (sidebar, topbar offset, workspace margin) together cleanly. */
:root { --sidebar-w: 290px !important; }

/* ── Conversation rhythm: a touch more breathing room, calmer max width ────── */
.msg-row { padding: 10px 0; margin-bottom: 2px; }
.msg-row + .msg-row { margin-top: 2px; }

/* ── AI name badge ("Nevlar") — quieter, more refined ──────────────────────── */
.bot-indicator, .msg-role {
  font-size: 12px !important;
  letter-spacing: 0.3px;
  opacity: 0.92;
}

/* ── AI reply rail — slightly crisper, warmer at the top ───────────────────── */
.msg-row.ai .msg-bubble::before {
  width: 2px;
  left: -16px;
  background: linear-gradient(180deg,
    rgba(255,248,238,0.65) 0%,
    rgba(255,208,128,0.40) 38%,
    rgba(200,120,64,0.06) 100%);
  box-shadow: 0 0 10px rgba(255,208,128,0.22);
}

/* ── AI reply text — a hair softer than pure bubble text, easier to scan ───── */
.msg-row.ai .msg-bubble {
  line-height: 1.68;
  color: rgba(237,232,224,0.96);
}

/* ── User bubble — refined ember: smoother gradient, gentler radius ────────── */
.msg-row.user .msg-bubble {
  background:
    linear-gradient(135deg, rgba(255,221,184,0.12) 0%, rgba(255,208,128,0.085) 60%, rgba(200,120,64,0.07) 100%);
  border: 1px solid rgba(255,208,128,0.20);
  border-radius: 18px;
  border-bottom-right-radius: 7px;
  padding: 12px 16px;
  box-shadow:
    inset 0 1px 0 rgba(255,248,238,0.06),
    0 2px 12px rgba(0,0,0,0.30);
}

/* ── "Read aloud" + action chips under messages — smaller, less shouty ─────── */
.read-aloud-btn, .msg-action-btn, .ai-msg-actions button, .user-msg-actions button {
  font-size: 11.5px !important;
  opacity: 0.7;
  transition: opacity 0.15s, color 0.15s;
}
.read-aloud-btn:hover, .msg-action-btn:hover { opacity: 1; }

/* ── Composer — more premium: deeper surface, clearer focus, rounder ───────── */
.input-wrap {
  background: linear-gradient(180deg, rgba(28,21,13,0.96), rgba(20,16,10,0.96));
  border: 1px solid rgba(255,208,128,0.16);
  border-radius: 18px;
  padding: 6px 10px;
  box-shadow: 0 2px 18px rgba(0,0,0,0.35), inset 0 1px 0 rgba(255,248,238,0.03);
}
.input-wrap:focus-within {
  border-color: rgba(255,208,128,0.42);
  box-shadow: 0 4px 30px rgba(255,208,128,0.10), 0 0 0 1px rgba(255,208,128,0.10);
  background: linear-gradient(180deg, rgba(32,24,15,0.98), rgba(22,17,11,0.98));
}
#chatInput { font-size: 15.5px; line-height: 1.6; }
#chatInput::placeholder { color: rgba(154,144,130,0.55); }

/* ── Send button — solid gold when ready, so the primary action is obvious ─── */
#sendBtn {
  width: 38px; height: 38px; border-radius: 11px;
}
#sendBtn:hover {
  background: linear-gradient(135deg, rgba(255,208,128,0.18), rgba(200,120,64,0.14));
  box-shadow: 0 0 18px rgba(255,208,128,0.20);
}

/* ── Welcome chips — tighter pill, gold icon, cleaner hover ────────────────── */
.welcome-chip {
  border-radius: 12px;
  padding: 8px 14px;
  font-size: 13px;
  border: 1px solid rgba(255,208,128,0.14);
  background: rgba(20,16,10,0.6);
}
.welcome-chip:hover {
  transform: translateY(-2px);
  border-color: rgba(255,208,128,0.34);
  box-shadow: 0 6px 18px rgba(255,208,128,0.12);
}
.welcome-chip svg { color: var(--gold2, #e8a050); opacity: 0.85; }
.welcome-chip:hover svg { opacity: 1; }

/* ── Welcome heading — a little more presence ──────────────────────────────── */
.welcome-nb-title { letter-spacing: -0.2px; }
.welcome-nb-title em { color: var(--gold, #ffd080); font-style: normal; }

/* ── Citation chips — slightly calmer so they support, not compete ─────────── */
.cite-chip { font-size: 10.5px; padding: 3px 9px; }

/* ── Cross-reference / insight cards rendered in chat (from intelligence.js) ── */
/* If the AI surfaces a cross-reference card, give it the signature gold edge. */
.nv-insight, .insight-card, [data-insight] {
  background: rgba(14,10,6,0.85);
  border: 1px solid rgba(255,208,128,0.16);
  border-left: 2px solid var(--gold2, #e8a050);
  border-radius: 10px;
  padding: 12px 14px;
  margin-top: 10px;
}

/* ── Scrollbar — thin, gold-tinted, unobtrusive ────────────────────────────── */
#chatArea::-webkit-scrollbar, .chat-scroll::-webkit-scrollbar { width: 8px; }
#chatArea::-webkit-scrollbar-thumb, .chat-scroll::-webkit-scrollbar-thumb {
  background: rgba(255,208,128,0.14); border-radius: 8px;
}
#chatArea::-webkit-scrollbar-thumb:hover, .chat-scroll::-webkit-scrollbar-thumb:hover {
  background: rgba(255,208,128,0.26);
}

/* ── FIX: notification panel — render as a proper card and ALWAYS be visible
   when open. (An earlier fix killed the fade-in animation, but that animation
   was what set opacity:0→1, so the panel became invisible. Set opacity
   explicitly instead, and position it cleanly under the bell.) */
#notifPanel {
  width: 360px !important;
  min-width: 320px !important;
  max-width: 92vw !important;
  min-height: 130px !important;
  max-height: 70vh !important;
  border-radius: 14px !important;
  background: #15100a !important;
  border: 1px solid rgba(255,208,128,0.20) !important;
  box-shadow: 0 14px 50px rgba(0,0,0,0.7) !important;
  right: 16px !important;
  left: auto !important;
  top: 60px !important;
  z-index: 9999 !important;
}
#notifPanel.open {
  display: flex !important;
  flex-direction: column !important;
  opacity: 1 !important;
  transform: none !important;
  visibility: visible !important;
}
#notifPanel .notif-list { min-height: 60px; }
#notifPanel .notif-hdr h3 { display: flex; align-items: center; gap: 7px; }
#notifPanel .notif-hdr h3 svg { color: var(--gold, #ffd080); }

/* ── Scrollable lists in panels (memory, files, history) ──────────────
   The panes use flex:1 inside overflow:hidden parents, which can collapse
   and prevent inner scrolling. Explicit max-height guarantees the list
   scrolls on its own once it grows past the visible area. */
#memoryWidgetList.memory-scroll,
#filesWidgetList,
.memory-scroll,
.files-scroll,
.ltab-pane .widget-list {
  max-height: calc(80dvh - 140px) !important;
  overflow-y: auto !important;
}
#memoryWidgetList.memory-scroll::-webkit-scrollbar,
.memory-scroll::-webkit-scrollbar,
.files-scroll::-webkit-scrollbar { width: 7px; }
#memoryWidgetList.memory-scroll::-webkit-scrollbar-thumb,
.memory-scroll::-webkit-scrollbar-thumb,
.files-scroll::-webkit-scrollbar-thumb {
  background: rgba(255,208,128,0.14); border-radius: 99px;
}

/* ── Welcome weekly digest (clean, professional, gold) ─────────────── */
.welcome-nb { max-width: 600px; margin: 0 auto; padding: 8px 4px; }
.welcome-nb-title { font-family:'Syne',sans-serif; font-size:26px; font-weight:700; letter-spacing:-0.01em;
  background:linear-gradient(92deg,var(--gold,#ffd080),#fff6e8 60%,var(--gold,#ffd080));
  -webkit-background-clip:text; background-clip:text; color:transparent; margin-bottom:4px; }
.welcome-nb-sub { font-size:14px; color:var(--mid,#9a9088); margin-bottom:18px; }
.welcome-digest {
  background:linear-gradient(160deg, rgba(255,208,128,0.05), rgba(13,9,4,0.5));
  border:1px solid rgba(255,200,100,0.14); border-radius:16px;
  padding:18px 20px; margin-bottom:18px;
}
.welcome-digest-loading { font-size:13px; color:var(--gold2,#e8a050); display:flex; align-items:center; gap:8px; opacity:0.85; }
.wd-head { display:flex; align-items:center; justify-content:space-between; margin-bottom:10px; }
.wd-week { font-family:'DM Mono',monospace; font-size:11px; letter-spacing:0.08em; text-transform:uppercase; color:var(--gold2,#e8a050); }
.wd-busy { font-family:'DM Mono',monospace; font-size:11px; letter-spacing:0.05em; text-transform:capitalize; }
.wd-headline { font-family:'Syne',sans-serif; font-size:18px; font-weight:600; color:var(--text,#ede8e0); line-height:1.35; margin-bottom:12px; }
.wd-pris { display:flex; flex-direction:column; gap:7px; margin-bottom:12px; }
.wd-pri { display:flex; align-items:flex-start; gap:8px; font-size:14px; color:rgba(237,232,224,0.82); line-height:1.45; }
.wd-pri svg { margin-top:3px; flex-shrink:0; opacity:0.7; color:var(--gold,#ffd080); }
.wd-tip { display:flex; align-items:center; gap:7px; font-size:13px; color:var(--gold,#ffd080);
  background:rgba(255,200,100,0.06); border:1px solid rgba(255,200,100,0.12);
  border-radius:10px; padding:8px 12px; line-height:1.4; }
.wd-tip svg { flex-shrink:0; opacity:0.8; }
.wd-flags { display:flex; flex-wrap:wrap; gap:6px; margin-top:10px; }
.wd-flag { font-size:11px; color:#d98a5a; background:rgba(217,138,90,0.08);
  border:1px solid rgba(217,138,90,0.2); border-radius:99px; padding:3px 10px; }


/* ── FLASH FIX: backdrop-filter blur causes GPU compositor flicker when panels
   open/close (the purple/green/blue flash on movement). Stabilize the layers:
   promote them to their own composited layer that persists, and cap the blur
   so the recomposite is cheap. Keeps the frosted look, kills the flash. ── */
.sing-breakdown-overlay, #commandDropdown, #checkoutModal, #referralModal,
#nudgeBanner, #profileModal, #onboardingModal, #nvScorePanel, #premiumWelcomeModal,
.modal-fs-card, .modal-box, .attach-popup, .export-menu {
  -webkit-backdrop-filter: blur(8px) !important;
  backdrop-filter: blur(8px) !important;
  transform: translateZ(0);            /* own GPU layer — stops create/destroy flash */
  -webkit-transform: translateZ(0);
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}
/* Hard kill-switch: localStorage.nvNoBlur='1' removes all blur if it STILL flashes */
body.nv-no-blur *, body.nv-no-blur *::before, body.nv-no-blur *::after {
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
}

/* ── FLASH FIX (final): the GPU compositor flashes colored bars during the
   entrance animations on your hardware. Disabling the heavy transform/opacity
   animations removes the recomposite that triggers it. App works identically —
   things just appear instantly instead of animating in.
   Auto-on for users who set OS "reduce motion"; manual via localStorage.nvCalm='1'. */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001s !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001s !important;
  }
}
body.nv-calm *:not(#landAurora):not(#bhStatic), body.nv-calm *::before, body.nv-calm *::after {
  animation: none !important;
  transition: none !important;
}
/* The black hole does NOT cause the flashing (confirmed) — keep it visible and
   animating even in calm mode so the landing always has it. */
body.nv-calm #landAurora { display: block !important; }

/* ── GOLD BOOST: make the chat chrome read more gold (match the preview) ─────
   Additive only — strengthens existing gold accents, touches no structure. */
/* Composer: warmer, more present gold frame */
.input-row {
  border-color: rgba(255,208,128,0.30) !important;
  background:
    linear-gradient(180deg, rgba(255,208,128,0.07) 0%, rgba(22,16,7,0.92) 55%, rgba(13,9,4,0.95) 100%) !important;
  box-shadow: inset 0 1px 0 rgba(255,248,238,0.06), 0 2px 16px rgba(0,0,0,0.5), 0 0 28px rgba(232,160,80,0.08) !important;
}
.input-row:focus-within { border-color: rgba(255,208,128,0.5) !important; box-shadow: 0 0 0 3px rgba(255,208,128,0.07), 0 0 30px rgba(232,160,80,0.12) !important; }
/* Topbar: subtle gold underline + warmer chips */
.topbar { border-bottom: 1px solid rgba(255,208,128,0.14) !important; }
.topbar-tab.active { color: var(--gold,#ffd080) !important; }
.topbar-chip { border-color: rgba(255,208,128,0.22) !important; color: var(--gold2,#e8a050) !important; }
/* Input chips: more gold */
.input-chip { border-color: rgba(255,208,128,0.20) !important; }
.input-chip:hover { border-color: rgba(255,208,128,0.4) !important; }
/* Send button: solid gold gradient like the preview */
.input-send, .send-btn, #sendBtn {
  background: linear-gradient(135deg, var(--gold3,#c87840), var(--gold,#ffd080)) !important;
  color: #1a0f02 !important; border: none !important;
  box-shadow: 0 3px 14px rgba(232,160,80,0.35) !important;
}
/* History/list rows and panels: warmer gold edges */
.hist-item.active, .nav-item.active, .ltab-tab.active { color: var(--gold,#ffd080) !important; }
.acct-panel, #notifPanel, #commandDropdown { border-color: rgba(255,208,128,0.16) !important; }
/* User chat bubble: a touch more gold (matches preview's amber bubble) */
.msg-row.user .msg-bubble, .msg-bubble.user {
  border-color: rgba(255,208,128,0.22) !important;
  background: linear-gradient(135deg, rgba(255,221,184,0.13), rgba(255,208,128,0.09) 55%, rgba(200,120,64,0.08)) !important;
}

/* ════════════════════════════════════════════════════════════════════
   UNIFIED GOLDEN-BROWN THEME — the landing-title look, applied app-wide.
   Animated shimmer on TEXT only (cheap, no GPU flash); static gold-brown
   accents on surfaces. Animation duration uses --anim-dur so the existing
   "Reduce motion" accessibility button freezes shimmer → static gold-brown.
   ════════════════════════════════════════════════════════════════════ */
:root { --anim-dur: 6s; }

/* The signature animated golden-brown text sweep */
.nv-shimmer,
.sing-card-title,
.welcome-nb-title,
.acct-name, #notifPanel .notif-hdr h3,
.modal-title, .modal-fs-title, .ob-title,
.topbar-logo, .pulse-title, #singHeader h1, #singHeader h2 {
  background: linear-gradient(90deg, var(--gold3,#c87840), var(--gold,#ffd080) 35%, #fff8ee 50%, var(--gold,#ffd080) 65%, var(--gold3,#c87840)) !important;
  background-size: 200% 100% !important;
  -webkit-background-clip: text !important; background-clip: text !important;
  -webkit-text-fill-color: transparent !important; color: transparent !important;
  background-position: 50% 0 !important;
}
/* Animation is OPT-IN (body.nv-anim) — static gold by default so it never
   flashes on integrated GPUs. The landing title keeps its own animation. */
body.nv-anim .nv-shimmer,
body.nv-anim .sing-card-title,
body.nv-anim .topbar-logo {
  animation: nv-gold-sweep var(--anim-dur, 6s) linear infinite !important;
}
@keyframes nv-gold-sweep { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* When reduce-motion is on, freeze to a steady golden-brown (no movement) */
body.nv-reduce-motion .nv-shimmer,
body.nv-reduce-motion .sing-card-title,
body.nv-reduce-motion .welcome-nb-title,
body.nv-reduce-motion .modal-title,
body.nv-reduce-motion .topbar-logo,
body.nv-calm .nv-shimmer,
body.nv-calm .sing-card-title,
body.nv-calm .topbar-logo {
  animation: none !important;
  background-position: 50% 0 !important;
}

/* Static gold-brown accents on surfaces (no animation = no flash) */
.modal-box, .modal-fs-card, #commandDropdown, .acct-panel, #notifPanel,
.attach-popup, .export-menu, .onboarding-card, #checkoutModal, #referralModal {
  border: 1px solid rgba(255,200,100,0.16) !important;
}
.modal-box::before, .acct-panel::before {
  content:''; position:absolute; top:0; left:0; right:0; height:2px;
  background: linear-gradient(90deg, transparent, var(--gold2,#e8a050), transparent);
  opacity:0.6; pointer-events:none;
}

/* PULSE CARD FIX: show the title + description in the collapsed view
   (the data is there — proven by the breakdown — it just wasn't visible) */
.sing-card-title { display:block !important; min-height:1em; }
.sing-card-desc { display:block !important; }
.sing-card { min-height:auto !important; }
