/* ═══════════════════════════════════════════════════════════════
   Gracie — Abyssal Bioluminescence (2026 High-Fidelity)
   ═══════════════════════════════════════════════════════════════ */

:root {
  /* Mood Engine — defaults to Neutral */
  --mood-color: #bf00ff;
  --mood-glow: rgba(191, 0, 255, 0.35);
  --mood-glow-soft: rgba(191, 0, 255, 0.12);
  --pulse-speed: 4s;

  /* Palette */
  --void: #030303;
  --glass: rgba(10, 10, 10, 0.85);
  --glass-heavy: rgba(6, 6, 6, 0.92);
  --glass-border: rgba(255, 255, 255, 0.1);
  --text: #f0f0f0;
  --text-dim: #888;
  --success: #00ff41;
  --alert: #ff003c;

  /* Torch (set by JS) */
  --torch-x: 50%;
  --torch-y: 50%;
}

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

/* ── The Slide — Smooth Scrolling Everywhere ── */
.chat-messages,
.feed,
.session-list,
.tools-panel { scroll-behavior: smooth; }

/* ── Typography ── */
body, button, input, select, textarea {
  font-family: "Inter", "Space Grotesk", system-ui, sans-serif;
  color: var(--text);
}

.brand, .stack h3, .ws-label, .meta, .typing-indicator em {
  font-family: "Space Grotesk", "Inter", sans-serif;
}

code, pre, .log-msg code, .feed {
  font-family: "JetBrains Mono", "Fira Code", monospace;
}

/* ── Activity Theater ── */
.activity-feed {
  max-height: 320px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 4px 0;
  scroll-behavior: smooth;
}

.activity-event {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.03);
  border-left: 3px solid var(--mood-color);
  font-size: 0.82rem;
  animation: activity-slide-in 0.3s cubic-bezier(0.22, 0.68, 0, 1.2);
  transition: opacity 0.5s ease, border-color 0.3s ease;
}

.activity-event.error {
  border-left-color: var(--alert);
  background: rgba(255, 0, 60, 0.06);
}

.activity-event .activity-icon {
  font-size: 1.1rem;
  flex-shrink: 0;
  width: 24px;
  text-align: center;
}

.activity-event .activity-body {
  flex: 1;
  min-width: 0;
}

.activity-event .activity-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.activity-event .activity-label {
  font-weight: 600;
  color: var(--mood-color);
  font-family: "Space Grotesk", sans-serif;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.activity-event .activity-time {
  font-size: 0.7rem;
  color: var(--text-dim);
  font-family: "JetBrains Mono", monospace;
  flex-shrink: 0;
}

.activity-event .activity-args {
  color: var(--text-dim);
  font-size: 0.78rem;
  margin-top: 3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.activity-event .activity-result {
  color: var(--text);
  font-size: 0.78rem;
  margin-top: 4px;
  font-family: "JetBrains Mono", monospace;
  line-height: 1.4;
  max-height: 60px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.activity-event.fresh {
  border-left-color: var(--success);
  background: rgba(0, 255, 65, 0.06);
}

@keyframes activity-slide-in {
  from { opacity: 0; transform: translateX(20px); }
  to { opacity: 1; transform: translateX(0); }
}

/* ── Activity Theater Toggle ── */
.activity-toggle {
  display: inline-block;
  font-size: 0.65rem;
  font-family: "JetBrains Mono", monospace;
  padding: 2px 10px;
  border-radius: 10px;
  border: 1px solid var(--success);
  background: rgba(0, 255, 65, 0.1);
  color: var(--success);
  cursor: pointer;
  margin-left: 8px;
  vertical-align: middle;
  transition: all 0.25s ease;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}
.activity-toggle.off {
  border-color: var(--text-dim);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-dim);
}
.activity-toggle:hover {
  filter: brightness(1.3);
}

/* ── Expandable Rich Content ── */
.activity-detail {
  margin-top: 6px;
  border-radius: 6px;
  overflow: hidden;
}
.activity-detail-toggle {
  font-size: 0.72rem;
  color: var(--mood-color, #bf00ff);
  cursor: pointer;
  font-family: "JetBrains Mono", monospace;
  padding: 3px 0;
  user-select: none;
  opacity: 0.8;
}
.activity-detail-toggle:hover { opacity: 1; }
.activity-detail[open] .activity-detail-toggle { opacity: 1; }
.activity-detail[open] .activity-detail-toggle::after { content: ""; }

.activity-code {
  background: rgba(0, 0, 0, 0.5);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 6px;
  padding: 8px 10px;
  font-family: "JetBrains Mono", "Fira Code", monospace;
  font-size: 0.72rem;
  line-height: 1.5;
  color: var(--text);
  overflow-x: auto;
  max-height: 300px;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-word;
  margin: 4px 0 0;
}

.activity-text-content,
.activity-search-results {
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(255, 255, 255, 0.04);
  border-radius: 6px;
  padding: 8px 10px;
  font-size: 0.75rem;
  line-height: 1.5;
  color: var(--text);
  max-height: 250px;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-word;
  margin: 4px 0 0;
}

/* ── Memory Visualizer ── */
.memory-viz {
  padding: 4px 0;
}

.memory-viz-status {
  font-family: "JetBrains Mono", monospace;
  font-size: 0.82rem;
  color: var(--text-dim);
  padding: 6px 10px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.02);
  margin-bottom: 8px;
  transition: color 0.3s ease, background 0.3s ease;
}

.memory-viz-status.searching {
  color: var(--mood-color);
  background: rgba(191, 0, 255, 0.08);
  animation: memory-pulse 1.2s ease-in-out infinite;
}

.memory-viz-status.complete {
  color: var(--success);
}

.memory-viz-status.error {
  color: var(--alert);
}

@keyframes memory-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.memory-viz-results {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 280px;
  overflow-y: auto;
}

.memory-viz-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.03);
  animation: memory-item-in 0.4s cubic-bezier(0.22, 0.68, 0, 1.2);
  animation-fill-mode: both;
}

.memory-viz-item:nth-child(1) { animation-delay: 0s; }
.memory-viz-item:nth-child(2) { animation-delay: 0.08s; }
.memory-viz-item:nth-child(3) { animation-delay: 0.16s; }
.memory-viz-item:nth-child(4) { animation-delay: 0.24s; }
.memory-viz-item:nth-child(5) { animation-delay: 0.32s; }

@keyframes memory-item-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.memory-viz-score {
  flex-shrink: 0;
  width: 48px;
  height: 6px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 3px;
  overflow: hidden;
}

.memory-viz-score-bar {
  height: 100%;
  border-radius: 3px;
  background: var(--mood-color);
  transition: width 0.6s cubic-bezier(0.22, 0.68, 0, 1.2);
}

.memory-viz-text {
  flex: 1;
  font-size: 0.78rem;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.3;
}

.memory-viz-meta {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-shrink: 0;
}
.memory-viz-mood {
  font-size: 0.7rem;
  color: var(--text-dim);
  flex-shrink: 0;
  font-style: italic;
}
.memory-viz-ts {
  font-size: 0.62rem;
  color: var(--text-dim);
  opacity: 0.6;
  font-family: "JetBrains Mono", monospace;
}

.memory-viz-query {
  font-size: 0.78rem;
  color: var(--text-dim);
  padding: 4px 10px;
  margin-bottom: 6px;
  border-left: 2px solid var(--mood-color);
  font-style: italic;
}

/* ── Token Usage & Cost Indicator ── */
.token-usage-container {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  padding: 0.5rem 0;
}

.token-section {
  border-left: 2px solid var(--mood-color);
  padding-left: 1rem;
}

.token-section h4 {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--mood-color);
  margin-bottom: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.token-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem 0;
  font-size: 0.9rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.token-row:last-child {
  border-bottom: none;
}

.token-label {
  color: var(--text-dim);
  font-weight: 500;
}

.token-value {
  color: var(--text);
  font-weight: 600;
  font-family: "JetBrains Mono", monospace;
  letter-spacing: 0.5px;
}

.token-cost {
  color: var(--success);
  font-weight: 700;
}

.token-model {
  color: var(--mood-color);
  font-size: 0.85rem;
}

/* ── The Void ── */
html, body {
  height: 100%;
  overflow: hidden;
}

body {
  background: var(--void);
}

/* Torch — mouse-following radial glow */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  background: radial-gradient(
    600px circle at var(--torch-x) var(--torch-y),
    var(--mood-glow-soft),
    transparent 70%
  );
  pointer-events: none;
  z-index: 0;
  transition: background 300ms ease;
}

/* Bioluminescence — the void breathes with her mood */
body::after {
  content: "";
  position: fixed;
  inset: 0;
  background: radial-gradient(
    ellipse 80% 60% at 50% 50%,
    color-mix(in srgb, var(--mood-color) 5%, transparent),
    transparent 70%
  );
  pointer-events: none;
  z-index: 0;
  animation: aura-breathe var(--pulse-speed) ease-in-out infinite;
}

@keyframes aura-breathe {
  0%, 100% { opacity: 0.05; }
  50%      { opacity: 0.18; }
}

/* ── Breathe Animation — Mood Engine ── */
@keyframes breathe {
  0%, 100% {
    box-shadow:
      0 20px 50px rgba(0, 0, 0, 0.9),
      0 0 0 1px var(--glass-border),
      inset 0 0 30px rgba(0, 0, 0, 0.4),
      0 0 40px var(--mood-glow-soft);
    border-color: var(--glass-border);
  }
  50% {
    box-shadow:
      0 20px 50px rgba(0, 0, 0, 0.9),
      0 0 0 1px color-mix(in srgb, var(--mood-color) 40%, transparent),
      inset 0 0 30px rgba(0, 0, 0, 0.4),
      0 0 80px var(--mood-glow);
    border-color: color-mix(in srgb, var(--mood-color) 35%, transparent);
  }
}

@keyframes breathe-subtle {
  0%, 100% { box-shadow: 0 8px 24px rgba(0, 0, 0, 0.7), 0 0 15px var(--mood-glow-soft); }
  50%      { box-shadow: 0 8px 24px rgba(0, 0, 0, 0.7), 0 0 50px var(--mood-glow), 0 0 100px var(--mood-glow-soft); }
}

@keyframes fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@keyframes flicker {
  0%, 100% { opacity: 1; }
  10%  { opacity: 0.85; }
  20%  { opacity: 1; }
  30%  { opacity: 0.92; }
  50%  { opacity: 0.78; }
  60%  { opacity: 1; }
  80%  { opacity: 0.88; }
}

/* ── The Glass (shared container style) ── */
.glass {
  background: var(--glass);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--glass-border);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.9);
}

/* ── App Shell ── */
.app-shell {
  position: relative;
  display: flex;
  height: 100vh;
  z-index: 1;
}

/* ── Sidebar ── */
.sidebar {
  width: 280px;
  background: var(--glass-heavy);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border-right: 1px solid var(--glass-border);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: width 0.5s cubic-bezier(0.4, 0, 0.2, 1),
              padding 0.5s cubic-bezier(0.4, 0, 0.2, 1),
              opacity 0.35s ease,
              border-color 0.35s ease,
              min-width 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

.sidebar.collapsed { width: 72px; padding-inline: 8px; }

/* Sidebar fully hidden (drive_ui / theater modes) */
.sidebar.sidebar-hidden {
  width: 0; min-width: 0; padding: 0; overflow: hidden;
  border-right-color: transparent; opacity: 0;
}
.sidebar.collapsed .sidebar-search,
.sidebar.collapsed .project-filter,
.sidebar.collapsed .session-list { display: none; }

.sidebar-top { display: flex; gap: 8px; align-items: center; }
.sidebar.collapsed .sidebar-top { justify-content: center; }
.sidebar.collapsed #new-chat-btn { display: none; }

.sidebar-search,
.project-filter,
textarea,
input,
select {
  width: 100%;
  border: 1px solid var(--glass-border);
  background: rgba(6, 6, 6, 0.85);
  color: var(--text);
  border-radius: 0;
  padding: 10px 12px;
  font: inherit;
  font-size: 14px;
  transition: border-color 0.2s ease;
}

.sidebar-search:focus,
textarea:focus,
input:focus,
select:focus {
  outline: none;
  border-color: color-mix(in srgb, var(--mood-color) 60%, transparent);
}

.session-list { overflow: auto; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.session-group-label { font-size: 10px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.1em; margin-top: 8px; }
.session-item {
  padding: 10px 12px;
  border: 1px solid var(--glass-border);
  background: rgba(8, 8, 8, 0.8);
  display: grid;
  gap: 4px;
  cursor: pointer;
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
}
.session-item:hover {
  border-color: color-mix(in srgb, var(--mood-color) 45%, transparent);
}
.session-item.active {
  border-color: color-mix(in srgb, var(--mood-color) 65%, transparent);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--mood-color) 25%, transparent);
}
.session-title { font-weight: 600; font-size: 13px; }
.session-meta,
.session-project-tag { font-size: 11px; color: var(--text-dim); }
.session-actions { margin-left: auto; display: flex; gap: 4px; }

/* ── Main Stage ── */
.main-stage { flex: 1; display: flex; flex-direction: column; min-width: 0; }

.topbar {
  height: 54px;
  border-bottom: 1px solid var(--glass-border);
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding: 0 18px;
  background: var(--glass-heavy);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

.topbar-left { justify-self: start; display: flex; gap: 8px; align-items: center; }
.topbar-right { justify-self: end; }
.brand {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  background: linear-gradient(135deg, var(--mood-color), #fff 80%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  transition: background 0.4s ease;
}

.status-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--text-dim); transition: all 0.3s ease; }
.status-dot.online { background: var(--success); box-shadow: 0 0 10px rgba(0, 255, 65, 0.5); }
.ws-label { color: var(--text-dim); font-size: 11px; letter-spacing: 0.04em; }

/* ── Cockpit — The Working Area ── */
.cockpit {
  flex: 1;
  display: flex;
  min-height: 0;
  padding: 12px;
  gap: 0;
}
.cockpit > * {
  transition: flex 0.6s cubic-bezier(0.25, 0.8, 0.25, 1),
              width 0.6s cubic-bezier(0.25, 0.8, 0.25, 1),
              min-width 0.6s cubic-bezier(0.25, 0.8, 0.25, 1),
              opacity 0.4s ease,
              padding 0.6s cubic-bezier(0.25, 0.8, 0.25, 1),
              border-color 0.4s ease;
}

/* ── Chat Log — The Core ── */
.chat-log {
  flex: 1;
  min-width: 280px;
  border: 1px solid var(--glass-border);
  background: var(--glass);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.9);
  display: grid;
  grid-template-rows: 1fr auto auto auto;
  min-height: 0;
  animation: breathe var(--pulse-speed) ease-in-out infinite;
  transition: flex 0.5s cubic-bezier(0.4, 0, 0.2, 1),
              min-width 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ── Chat Minimized — Collapsed to 0 ── */
.chat-log.minimized {
  flex: 0 0 0px;
  min-width: 0;
  width: 0;
  overflow: hidden;
  border: none;
  padding: 0;
  opacity: 0;
}

/* ── Splitter — Draggable resize handle ── */
.splitter {
  width: 8px;
  flex-shrink: 0;
  cursor: col-resize;
  background: transparent;
  position: relative;
  transition: background 0.2s ease;
  z-index: 2;
}
.splitter::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 2px;
  height: 40px;
  background: var(--glass-border);
  border-radius: 1px;
  transition: background 0.3s ease, height 0.3s ease, box-shadow 0.3s ease;
}
.splitter:hover::after,
.splitter.dragging::after {
  background: var(--mood-color);
  height: 80px;
  box-shadow: 0 0 12px var(--mood-glow);
}

.chat-messages {
  overflow: auto;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* ── Chat Entries — No Bubbles ── */
.entry {
  position: relative;
  display: grid;
  gap: 6px;
  max-width: min(820px, 90%);
  padding: 12px 16px;
  border: 1px solid transparent;
  border-left: 3px solid var(--mood-color);
  background: transparent;
}

.entry.assistant {
  margin-right: auto;
  border-left-color: var(--mood-color);
}

.entry.user {
  margin-left: auto;
  border-left: none;
  border-right: 3px solid var(--success);
  text-align: right;
}

.entry.assistant::before,
.entry.user::before {
  font-family: "Space Grotesk", sans-serif;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
.entry.assistant::before {
  content: "GRACIE";
  color: var(--mood-color);
}
.entry.user::before {
  content: "YOU";
  color: var(--success);
}

.entry.error { border-left-color: var(--alert); }
.entry.error::before { content: "ERROR"; color: var(--alert); }
.entry.thought,
.entry.memory { opacity: 0.85; border-left-color: color-mix(in srgb, var(--mood-color) 50%, transparent); }

.meta {
  font-size: 10px;
  color: var(--text-dim);
  letter-spacing: 0.03em;
}
.entry.assistant .meta,
.entry.user .meta,
.entry.assistant .log-time,
.entry.user .log-time { display: none; }

.log-line { display: grid; gap: 6px; }
.log-time { font-size: 10px; opacity: 0.5; }
.log-msg { line-height: 1.6; font-size: 14px; }
.entry.user .log-msg { color: #eee; }
.log-msg p { margin-bottom: 12px; }
.log-msg p:last-child { margin-bottom: 0; }
.log-msg ol, .log-msg ul { margin-bottom: 12px; padding-left: 24px; }
.log-msg li { margin-bottom: 6px; }
.log-msg li:last-child { margin-bottom: 0; }
.log-msg pre {
  margin: 8px 0 0;
  padding: 12px;
  overflow: auto;
  background: rgba(0, 0, 0, 0.6);
  border: 1px solid var(--glass-border);
  font-size: 13px;
}
.log-msg code {
  background: rgba(255, 255, 255, 0.06);
  padding: 2px 5px;
  font-size: 13px;
}

/* ── Attachments ── */
.entry-attachments { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 6px; }
.entry-thumb {
  width: 96px;
  height: 96px;
  object-fit: cover;
  border: 1px solid var(--glass-border);
  cursor: zoom-in;
}

/* ── Entry TTS button ── */
.entry-tts-btn {
  border: 1px solid var(--glass-border);
  background: rgba(6, 6, 6, 0.85);
  color: var(--text-dim);
  width: 28px;
  height: 28px;
  display: inline-grid;
  place-items: center;
  margin-top: 4px;
  cursor: pointer;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.entry-tts-btn:hover { border-color: var(--mood-color); }
.entry-tts-btn.speaking {
  border-color: var(--mood-color);
  box-shadow: 0 0 10px var(--mood-glow);
}

/* ── Typing Indicator ── */
.typing-indicator {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 18px;
  color: var(--text-dim);
  font-size: 12px;
}
.typing-indicator[hidden] { display: none !important; }
.typing-indicator span {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--mood-color);
  animation: pulse-dot 1.2s infinite ease-in-out;
}
.typing-indicator span:nth-child(2) { animation-delay: .15s; }
.typing-indicator span:nth-child(3) { animation-delay: .3s; }

@keyframes pulse-dot {
  0%, 100% { transform: translateY(0); opacity: 0.4; }
  50% { transform: translateY(-3px); opacity: 1; }
}

/* ── Voice Oscilloscope ── */
.voice-oscilloscope {
  display: block;
  width: calc(100% - 36px);
  height: 48px;
  margin: 0 18px 8px;
  border: 1px solid color-mix(in srgb, var(--mood-color) 25%, var(--glass-border));
  background: rgba(3, 3, 3, 0.7);
}

/* ── Thought Stream — Terminal Log ── */
#thought-messages {
  font-family: "JetBrains Mono", "Fira Code", monospace;
  font-size: 11px;
  line-height: 1.6;
  color: color-mix(in srgb, var(--mood-color) 60%, #00ff41);
  max-height: 320px;
  overflow: auto;
}

#thought-messages .entry {
  border-left-color: color-mix(in srgb, var(--mood-color) 40%, #00ff41 30%);
  opacity: 0.85;
  padding: 6px 10px;
  font-size: 11px;
}

#thought-messages .entry::before {
  font-family: "JetBrains Mono", monospace;
  font-size: 9px;
  letter-spacing: 0.08em;
  color: #00ff41;
  opacity: 0.6;
}

#thought-messages .log-msg {
  font-family: "JetBrains Mono", "Fira Code", monospace;
  font-size: 11px;
  color: color-mix(in srgb, var(--mood-color) 50%, #88ffaa);
}

#thought-messages .log-time {
  display: inline;
  font-size: 9px;
  color: #00ff41;
  opacity: 0.4;
}

/* ── Composer / Input ── */
.chat-form { border-top: 1px solid var(--glass-border); padding: 14px 18px; display: grid; gap: 8px; }
.composer-row { display: grid; grid-template-columns: auto 1fr auto; gap: 8px; align-items: end; }
#chat-input {
  resize: none;
  min-height: 44px;
  max-height: 140px;
  line-height: 1.5;
  background: rgba(6, 6, 6, 0.85);
}
#chat-input:focus {
  border-color: color-mix(in srgb, var(--mood-color) 50%, transparent);
  box-shadow: 0 0 20px var(--mood-glow-soft);
}

.composer-meta { display: flex; gap: 8px; justify-content: space-between; }

/* ── File Preview ── */
.file-preview { display: flex; flex-wrap: wrap; gap: 8px; min-height: 0; }
.file-thumb-wrap,
.file-chip {
  border: 1px solid var(--glass-border);
  background: rgba(6, 6, 6, 0.85);
  position: relative;
}
.file-thumb-wrap img,
.file-thumb { width: 64px; height: 64px; object-fit: cover; display: block; }
.file-thumb-remove,
.file-chip-remove {
  position: absolute;
  top: -6px; right: -6px;
  width: 18px; height: 18px;
  border: 0;
  background: var(--alert);
  color: #fff;
  cursor: pointer;
  font-size: 11px;
}
.file-chip { padding: 6px 10px 6px 8px; font-size: 12px; }
.file-chip-remove { position: static; margin-left: 8px; }

.file-thumb-wrap.launching,
.file-chip.launching {
  animation: launchToChat 220ms ease forwards;
}

/* ── Buttons ── */
.btn {
  border: 1px solid var(--glass-border);
  color: var(--text);
  background: rgba(10, 10, 10, 0.85);
  padding: 8px 14px;
  font: inherit;
  font-size: 13px;
  cursor: pointer;
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
}
.btn:hover {
  border-color: color-mix(in srgb, var(--mood-color) 50%, transparent);
  box-shadow: 0 0 12px var(--mood-glow-soft);
}
.btn-primary {
  border: 1px solid color-mix(in srgb, var(--mood-color) 50%, transparent);
  background: color-mix(in srgb, var(--mood-color) 15%, rgba(16, 16, 16, 0.8));
  font-weight: 600;
}
.btn-primary:hover {
  background: color-mix(in srgb, var(--mood-color) 25%, rgba(16, 16, 16, 0.85));
  box-shadow: 0 0 20px var(--mood-glow);
}
.btn-icon { min-width: 36px; padding-inline: 10px; }

/* ── Tools Panel (in-flow flex child) ── */
.tools-panel {
  width: 0;
  min-width: 0;
  overflow: hidden;
  background: var(--glass-heavy);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border-left: 1px solid transparent;
  padding: 0;
  display: grid;
  gap: 10px;
  align-content: start;
  opacity: 0;
  pointer-events: none;
  transition: width 0.5s cubic-bezier(0.4, 0, 0.2, 1),
              min-width 0.5s cubic-bezier(0.4, 0, 0.2, 1),
              opacity 0.35s ease,
              padding 0.5s cubic-bezier(0.4, 0, 0.2, 1),
              border-color 0.35s ease;
}
.tools-panel.open {
  width: 420px;
  min-width: 300px;
  opacity: 1;
  pointer-events: auto;
  padding: 12px;
  border-left-color: var(--glass-border);
  overflow-y: auto;
  overflow-x: hidden;
}
/* When chat is minimized, tools fills all remaining space */
.chat-log.minimized ~ .splitter ~ .tools-panel.open,
.chat-log.minimized + .splitter + .tools-panel.open {
  width: auto;
  min-width: 0;
  flex: 1;
}

/* ═══════════════════════════════════════════════════════════════
   THE ACCORDION + CENTER STAGE — Master-Detail Navigation
   ═══════════════════════════════════════════════════════════════ */

.panel-glow {
  border: 1px solid var(--glass-border);
  background: rgba(8, 8, 8, 0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  display: flex;
  flex-direction: column;
  min-height: 0;
  max-height: none;
  transition: border-color 0.3s ease, opacity 0.3s ease;
}

/* ── Accordion Header ── */
.shard-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--glass-border);
  background: rgba(16, 16, 16, 0.6);
  cursor: pointer;
  flex-shrink: 0;
  user-select: none;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.shard-header:hover {
  background: rgba(255,255,255,0.04);
  border-bottom-color: color-mix(in srgb, var(--mood-color) 30%, transparent);
}
.shard-chevron {
  font-size: 10px;
  color: var(--text-dim);
  transition: transform 0.2s ease;
  flex-shrink: 0;
}
.shard-title {
  flex: 1;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-dim);
}

/* Expanded state — chevron rotates */
.panel-glow:not(.shard-collapsed) > .shard-header .shard-chevron {
  transform: rotate(90deg);
}
.panel-glow:not(.shard-collapsed) > .shard-header .shard-title {
  color: var(--text);
}
.panel-glow:not(.shard-collapsed) > .shard-header {
  border-bottom-color: color-mix(in srgb, var(--mood-color) 40%, transparent);
}

/* ── Accordion Body ── */
.stack { padding: 10px; display: grid; gap: 8px; min-height: 0; overflow: visible; }
.stack h3 { display: none; }
.feed { max-height: none; overflow: visible; display: grid; gap: 8px; font-size: 12px; }

/* ── Accordion States ── */

/* Collapsed: hide everything except the header */
.panel-glow.shard-collapsed > *:not(.shard-header) { display: none; }
.panel-glow.shard-collapsed { min-height: auto; overflow: hidden; }
.panel-glow.shard-collapsed .shard-header { border-bottom: none; }

/* Hidden shard */
.panel-glow.shard-hidden { display: none; }

/* Active shard — neon border */
.panel-glow.shard-active {
  border-color: var(--mood-color);
  box-shadow: 0 0 20px var(--mood-glow), 0 0 40px var(--mood-glow-soft);
  z-index: 2;
}

/* ═══════════════════════════════════════════════════════════════
   CENTER STAGE — Detail View in Main Chat Area
   ═══════════════════════════════════════════════════════════════ */

.center-stage-detail {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
  background: var(--void);
}
.center-stage-detail[hidden] { display: none !important; }

.detail-topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  border-bottom: 1px solid color-mix(in srgb, var(--mood-color) 40%, var(--glass-border));
  background: var(--glass-heavy);
  flex-shrink: 0;
}
.detail-back {
  border: 1px solid var(--glass-border);
  background: rgba(10,10,10,0.85);
  color: var(--text);
  padding: 6px 14px;
  font-size: 12px;
  font-family: "Space Grotesk", sans-serif;
  font-weight: 600;
  letter-spacing: 0.04em;
  cursor: pointer;
  transition: border-color 0.2s ease, background 0.2s ease;
}
.detail-back:hover {
  border-color: var(--mood-color);
  background: rgba(255,255,255,0.05);
}
.detail-title {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--mood-color);
  font-family: "Space Grotesk", sans-serif;
}
.detail-content {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 16px 20px;
  font-size: 13px;
  line-height: 1.6;
  word-wrap: break-word;
  overflow-wrap: break-word;
}
.detail-content .ghost-card,
.detail-content .entry,
.detail-content article {
  max-width: 100%;
  word-wrap: break-word;
  overflow-wrap: break-word;
}
.detail-content pre {
  white-space: pre-wrap;
  word-break: break-word;
  max-width: 100%;
  overflow-x: hidden;
}

/* ── Row / Pill helpers ── */
.row { display: grid; gap: 8px; }
.pill-row { display: flex; gap: 6px; flex-wrap: wrap; }
.planner-filter {
  border: 1px solid var(--glass-border);
  background: transparent;
  color: var(--text-dim);
  padding: 5px 10px;
  font-size: 12px;
  cursor: pointer;
  transition: border-color 0.2s ease;
}
.planner-filter.active {
  color: var(--text);
  border-color: color-mix(in srgb, var(--mood-color) 60%, transparent);
}

/* ── Planner Compact Styling (tools panel context) ── */
#planner-form {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
#planner-form input,
#planner-form textarea,
#planner-form select {
  padding: 6px 8px;
  font-size: 12px;
}
#planner-form textarea { min-height: 32px; resize: vertical; }
#planner-form .row { grid-template-columns: 1fr auto; align-items: center; }
#planner-form .btn { padding: 6px 14px; font-size: 12px; }

.planner-item {
  padding: 8px 10px !important;
  gap: 4px !important;
  border-left-width: 2px !important;
}
.planner-item::before { display: none !important; }
.planner-title { font-size: 13px; font-weight: 600; color: var(--text); line-height: 1.3; }
.planner-details { font-size: 11px; color: var(--text-dim); line-height: 1.4; max-height: 40px; overflow: hidden; }
.planner-meta { font-size: 10px; color: var(--text-dim); opacity: 0.7; }
.planner-priority {
  display: inline-block;
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 1px 6px;
  border: 1px solid var(--glass-border);
  font-family: 'Fira Code', monospace;
}
.priority-critical { color: var(--alert); border-color: var(--alert); }
.priority-high { color: #ff8800; border-color: #ff8800; }
.priority-medium { color: var(--text-dim); }
.priority-low { color: var(--text-dim); opacity: 0.6; }
.planner-controls {
  display: flex;
  gap: 6px;
  align-items: center;
  margin-top: 2px;
}
.planner-controls select {
  width: auto;
  padding: 3px 6px;
  font-size: 11px;
  background: rgba(6, 6, 6, 0.85);
}
.planner-controls button {
  padding: 3px 8px;
  font-size: 10px;
  cursor: pointer;
  border: 1px solid var(--glass-border);
  background: transparent;
  color: var(--text-dim);
  transition: border-color 0.2s ease;
}
.planner-controls button:hover { border-color: var(--mood-color); color: var(--text); }
.planner-delete { color: var(--alert) !important; }
.planner-delete:hover { border-color: var(--alert) !important; }
.planner-maximize svg { vertical-align: middle; }

/* ── Plan Expanded Editor (hidden by default, shown when maximized) ── */
.plan-expanded { display: none; }

.planner-item.plan-editing {
  padding: 18px 20px;
  border: 1px solid var(--glass-border);
  overflow: auto;
}

.planner-item.plan-editing .plan-compact { display: none; }
.planner-item.plan-editing .plan-expanded {
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-width: 760px;
  margin: 0 auto;
  padding-top: 6px;
  height: auto;
}

.plan-editor-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  opacity: 0.5;
  font-size: 12px;
  font-family: 'Fira Code', monospace;
  letter-spacing: 0.05em;
}

.plan-editor-label {
  display: block;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--mood-color, #bf00ff) !important;
  margin-bottom: 6px;
  font-family: 'Fira Code', monospace;
}

.plan-editor-title {
  width: 100%;
  font-size: 18px !important;
  font-weight: 600;
  padding: 10px 12px !important;
  background: rgba(255,255,255,0.04) !important;
  border: 1px solid rgba(255,255,255,0.1) !important;
  color: #ffffff !important;
  border-radius: 4px;
  font-family: 'Inter', sans-serif;
  transition: border-color 0.2s ease;
}
.plan-editor-title:focus {
  outline: none;
  border-color: var(--mood-color, #bf00ff) !important;
}

.plan-editor-row {
  display: flex;
  gap: 12px;
}
.plan-editor-row > div { flex: 1; }

.plan-editor-status,
.plan-editor-priority {
  width: 100%;
  padding: 10px 14px !important;
  font-size: 14px !important;
  background: rgba(255,255,255,0.04) !important;
  border: 1px solid rgba(255,255,255,0.1) !important;
  color: #ffffff !important;
  border-radius: 4px;
  cursor: pointer;
  transition: border-color 0.2s ease;
}
.plan-editor-status:focus,
.plan-editor-priority:focus {
  outline: none;
  border-color: var(--mood-color, #bf00ff) !important;
}

.plan-editor-details {
  flex: 0 0 auto;
  min-height: 120px;
  max-height: 38vh;
  width: 100%;
  padding: 12px !important;
  font-size: 14px !important;
  line-height: 1.5;
  background: rgba(255,255,255,0.03) !important;
  border: 1px solid rgba(255,255,255,0.1) !important;
  color: #dddddd !important;
  border-radius: 4px;
  resize: vertical;
  font-family: 'Inter', sans-serif;
  transition: border-color 0.2s ease;
}
.plan-editor-details:focus {
  outline: none;
  border-color: var(--mood-color, #bf00ff) !important;
  color: #ffffff !important;
}

.plan-editor-actions {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 16px;
  padding-top: 8px;
}

.plan-editor-save {
  padding: 10px 28px !important;
  font-size: 14px !important;
  cursor: pointer;
}

.plan-editor-saved {
  color: var(--mood-color, #bf00ff) !important;
  font-size: 13px;
  font-family: 'Fira Code', monospace;
  letter-spacing: 0.05em;
  animation: fade-in 0.3s ease forwards;
}

/* ── Mic Button & Voice Recording ── */
.mic-btn {
  position: relative;
  transition: color 0.2s ease, border-color 0.2s ease;
}
.mic-btn.recording {
  color: #ff003c !important;
  border-color: #ff003c !important;
  animation: mic-pulse 1s ease-in-out infinite;
}
.mic-btn.recording svg { stroke: #ff003c; }
@keyframes mic-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255, 0, 60, 0.4); }
  50%      { box-shadow: 0 0 12px 4px rgba(255, 0, 60, 0.3); }
}
.mic-btn.processing {
  color: var(--mood-color, #bf00ff) !important;
  border-color: var(--mood-color, #bf00ff) !important;
  opacity: 0.6;
  pointer-events: none;
}

/* Recording timer indicator */
.mic-timer {
  position: absolute;
  top: -20px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 10px;
  font-family: 'Fira Code', monospace;
  color: #ff003c;
  white-space: nowrap;
  pointer-events: none;
}

/* Silence countdown bar */
.silence-bar {
  position: absolute;
  bottom: -4px;
  left: 0;
  height: 2px;
  background: #ff003c;
  border-radius: 1px;
  transition: width 0.3s linear;
}

/* Voice message in chat */
.voice-message {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 6px;
  margin-top: 6px;
}
.voice-message audio {
  flex: 1;
  height: 32px;
  min-width: 0;
}
.voice-message .voice-label {
  font-size: 11px;
  color: var(--mood-color, #bf00ff);
  font-family: 'Fira Code', monospace;
  letter-spacing: 0.05em;
  white-space: nowrap;
}

.toast-container { position: fixed; bottom: 14px; right: 14px; display: grid; gap: 8px; z-index: 60; }
.toast {
  padding: 10px 14px;
  border: 1px solid var(--glass-border);
  background: var(--glass-heavy);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  opacity: 0;
  transform: translateY(8px);
  transition: .2s ease;
  font-size: 13px;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast-notification {
  border-color: var(--mood-color);
  background: rgba(6, 6, 6, 0.95);
  box-shadow: 0 0 20px color-mix(in srgb, var(--mood-color) 30%, transparent);
  font-size: 14px;
  max-width: 400px;
  line-height: 1.5;
}

/* ── Image Overlay ── */
.img-overlay {
  position: fixed; inset: 0;
  background: rgba(3, 3, 3, 0.92);
  display: grid; place-items: center;
  z-index: 80;
  cursor: pointer;
}
.img-overlay[hidden] { display: none !important; }
.img-overlay img[src=""] { display: none; }
.img-overlay img { max-width: min(92vw, 1200px); max-height: 88vh; cursor: default; }
.img-overlay-close {
  position: fixed;
  top: 16px;
  right: 16px;
  width: 40px;
  height: 40px;
  border: 1px solid var(--glass-border);
  background: rgba(10, 10, 10, 0.85);
  color: #fff;
  font-size: 22px;
  cursor: pointer;
  z-index: 81;
  display: grid;
  place-items: center;
}

/* ── Ghost Process Cards ── */
.ghost-card {
  padding: 8px 10px;
  border-left: 2px solid color-mix(in srgb, var(--mood-color) 40%, var(--glass-border));
  margin-bottom: 6px;
  font-size: 12px;
  line-height: 1.5;
}
.ghost-card.ghost-dim {
  opacity: 0.45;
  border-left-color: var(--glass-border);
}
.ghost-label {
  display: block;
  font-family: "Space Grotesk", sans-serif;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--mood-color);
  margin-bottom: 4px;
}
.ghost-meta {
  font-size: 10px;
  color: var(--text-dim);
  margin-left: 6px;
}
.ghost-row {
  display: flex;
  gap: 6px;
  align-items: center;
  font-size: 11px;
  font-family: "JetBrains Mono", monospace;
  padding: 2px 0;
}
.ghost-key {
  color: var(--text-dim);
  min-width: 140px;
}
.ghost-pre {
  font-family: "JetBrains Mono", monospace;
  font-size: 10px;
  line-height: 1.5;
  color: var(--text-dim);
  background: rgba(0,0,0,0.4);
  border: 1px solid var(--glass-border);
  padding: 8px;
  max-height: 200px;
  overflow: auto;
  white-space: pre-wrap;
  margin-top: 6px;
}
.ghost-diary p,
.ghost-action {
  font-family: "JetBrains Mono", monospace;
  font-size: 11px;
}
.ghost-diary p { margin: 4px 0 0; color: #ccc; }
.ghost-action { display: flex; gap: 6px; align-items: center; }
.briefing-card {
  border-left-color: var(--success);
  background: rgba(0, 255, 65, 0.03);
}
.briefing-card p { margin: 0 0 8px; }
.ghost-thought {
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  border-top: 1px solid rgba(255,255,255,0.04);
  padding: 4px 0;
}
.ghost-thought p {
  margin: 0;
  font-family: "JetBrains Mono", monospace;
  font-size: 10px;
  color: #ccc;
  line-height: 1.5;
}

/* ═══════════════════════════════════════════════════════════════
   THE PRISM — Gracie's Nervous System (v8.3)
   ═══════════════════════════════════════════════════════════════ */

/* ── THE FOCUS: Searchlight ──
   When Gracie's attention shifts, the target panel flares
   and everything else dims. She turns her head. You see it. */

.panel-dimmed {
  opacity: 0.3 !important;
  filter: brightness(0.4) saturate(0.3);
  transition: opacity 0.4s cubic-bezier(0.22, 0.68, 0, 1.2),
              filter 0.4s cubic-bezier(0.22, 0.68, 0, 1.2);
}

.panel-focused {
  border-color: var(--mood-color) !important;
  box-shadow:
    0 0 40px var(--mood-glow),
    0 0 80px color-mix(in srgb, var(--mood-color) 25%, transparent),
    inset 0 0 20px color-mix(in srgb, var(--mood-color) 8%, transparent) !important;
  animation: focus-flare 0.6s cubic-bezier(0.22, 0.68, 0, 1.2) forwards !important;
  transition: box-shadow 0.3s cubic-bezier(0.22, 0.68, 0, 1.2),
              border-color 0.3s cubic-bezier(0.22, 0.68, 0, 1.2);
}

@keyframes focus-flare {
  0% {
    box-shadow: 0 0 0 var(--mood-glow), 0 0 0 transparent;
  }
  40% {
    box-shadow:
      0 0 60px var(--mood-glow),
      0 0 120px color-mix(in srgb, var(--mood-color) 35%, transparent),
      inset 0 0 30px color-mix(in srgb, var(--mood-color) 12%, transparent);
  }
  100% {
    box-shadow:
      0 0 40px var(--mood-glow),
      0 0 80px color-mix(in srgb, var(--mood-color) 25%, transparent),
      inset 0 0 20px color-mix(in srgb, var(--mood-color) 8%, transparent);
  }
}

/* Section-level focus within tools panel */
.tools-panel .panel-glow {
  transition: opacity 0.4s cubic-bezier(0.22, 0.68, 0, 1.2),
              filter 0.4s cubic-bezier(0.22, 0.68, 0, 1.2),
              border-color 0.3s cubic-bezier(0.22, 0.68, 0, 1.2),
              box-shadow 0.3s cubic-bezier(0.22, 0.68, 0, 1.2),
              max-height 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}

/* ── THE APERTURE: Breathing Panels ──
   Snap and shift like a camera lens. Mechanical. Not soft.
   When Gracie enters deep thought, the room rearranges. */

/* Aperture modes — tools panel widens and sections shift */
.tools-panel.aperture-wide {
  width: 560px;
  min-width: 400px;
}

/* Expanded section within tools panel */
.tools-panel .section-expanded {
  max-height: 600px !important;
}
.tools-panel .section-expanded .feed {
  max-height: 500px !important;
}

/* Contracted section */
.tools-panel .section-contracted {
  max-height: 0 !important;
  overflow: hidden !important;
  padding: 0 12px !important;
  opacity: 0;
}

/* ── THE REFRACTION: Prismatic Shockwave ──
   White light enters → hits the Prism → shatters into color. */

/* User send pulse — white light entering */
@keyframes send-pulse {
  0% {
    opacity: 0.7;
    transform: scaleY(0) translateY(0);
  }
  30% {
    opacity: 0.5;
    transform: scaleY(0.5) translateY(-30%);
  }
  100% {
    opacity: 0;
    transform: scaleY(1) translateY(-100%);
  }
}

.chat-log::after {
  content: "";
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 100%;
  pointer-events: none;
  z-index: 2;
  opacity: 0;
}

.chat-log.send-flash::after {
  background: linear-gradient(
    to top,
    rgba(255, 255, 255, 0.08) 0%,
    rgba(255, 255, 255, 0.03) 20%,
    transparent 50%
  );
  animation: send-pulse 0.6s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

/* Gracie response — prismatic shockwave */
@keyframes prism-shockwave {
  0% {
    opacity: 0;
    clip-path: inset(100% 0 0 0);
  }
  15% {
    opacity: 0.6;
    clip-path: inset(85% 0 0 0);
  }
  50% {
    opacity: 0.3;
    clip-path: inset(40% 0 0 0);
  }
  100% {
    opacity: 0;
    clip-path: inset(0 0 0 0);
  }
}

.chat-log.prism-burst::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 1;
  background: linear-gradient(
    180deg,
    transparent 0%,
    color-mix(in srgb, var(--mood-color) 6%, transparent) 20%,
    color-mix(in srgb, var(--mood-color) 12%, transparent) 40%,
    color-mix(in srgb, var(--mood-color) 8%, transparent) 60%,
    color-mix(in srgb, var(--mood-color) 3%, transparent) 80%,
    transparent 100%
  );
  animation: prism-shockwave 0.8s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

/* Entry-level refraction for individual responses */
.entry.assistant.prism-entry {
  position: relative;
}
.entry.assistant.prism-entry::after {
  content: "";
  position: absolute;
  inset: -2px;
  pointer-events: none;
  background: linear-gradient(
    90deg,
    color-mix(in srgb, var(--mood-color) 15%, transparent),
    transparent 60%
  );
  animation: entry-refract 1.2s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes entry-refract {
  0% { opacity: 0.8; transform: translateX(-100%); }
  40% { opacity: 0.4; transform: translateX(0); }
  100% { opacity: 0; transform: translateX(30%); }
}

/* Position relative needed for pseudo-element overlays */
.chat-log { position: relative; overflow: hidden; }

/* ── Keyframes ── */
@keyframes launchToChat {
  0% { transform: translateY(0) scale(1); opacity: 1; }
  100% { transform: translateY(-20px) scale(0.72); opacity: 0; }
}

/* ═══════════════════════════════════════════════════════════════
   REFRAC-MODES — Theater Modes + Maximization Engine
   ═══════════════════════════════════════════════════════════════ */

/* Shared vanish pattern for panels */
.panel-vanish-sidebar {
  width: 0 !important; min-width: 0 !important; padding: 0 !important;
  overflow: hidden !important; border-right-color: transparent !important; opacity: 0 !important;
}
.panel-vanish-chat {
  flex: 0 0 0px !important; min-width: 0 !important; width: 0 !important;
  overflow: hidden !important; border: none !important; padding: 0 !important; opacity: 0 !important;
}
.panel-vanish-tools {
  width: 0 !important; min-width: 0 !important; padding: 0 !important;
  overflow: hidden !important; border-left-color: transparent !important;
  opacity: 0 !important; pointer-events: none !important;
}
.panel-fill-tools {
  width: auto !important; min-width: 0 !important; flex: 1 !important;
  opacity: 1 !important; pointer-events: auto !important; padding: 12px !important;
  border-left-color: var(--glass-border) !important; overflow: auto !important;
}

/* Hide splitters during theater/maximize modes */
.app-shell.theater-war-room .splitter,
.app-shell.theater-war-room .splitter-sidebar,
.app-shell.theater-research .splitter-sidebar,
.app-shell.theater-intimate .splitter,
.app-shell.maximize-tools .splitter,
.app-shell.maximize-tools .splitter-sidebar,
.app-shell.maximize-chat .splitter,
.app-shell.maximize-chat .splitter-sidebar,
.app-shell.maximize-sidebar .splitter,
.app-shell.maximize-sidebar .splitter-sidebar {
  width: 0; opacity: 0; pointer-events: none;
}

/* ── WAR_ROOM: Sidebar=0, Chat=0, Tools=100% ── */
.app-shell.theater-war-room > .sidebar { width: 0; min-width: 0; padding: 0; overflow: hidden; border-right-color: transparent; opacity: 0; }
.app-shell.theater-war-room .chat-log { flex: 0 0 0px; min-width: 0; width: 0; overflow: hidden; border: none; padding: 0; opacity: 0; }
.app-shell.theater-war-room .tools-panel { width: auto; min-width: 0; flex: 1; opacity: 1; pointer-events: auto; padding: 12px; border-left-color: var(--glass-border); overflow: auto; }

/* War Room / Maximize-Tools: sections reflow to 2 columns when wide */
.app-shell.theater-war-room .tools-panel,
.app-shell.maximize-tools .tools-panel {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
  align-content: start;
}
.app-shell.theater-war-room .tools-panel .feed,
.app-shell.maximize-tools .tools-panel .feed {
  max-height: 400px;
}

/* ── RESEARCH: Sidebar=0, Chat=30%, Tools=70% ── */
.app-shell.theater-research > .sidebar { width: 0; min-width: 0; padding: 0; overflow: hidden; border-right-color: transparent; opacity: 0; }
.app-shell.theater-research .chat-log { flex: 0 0 30%; min-width: 200px; }
.app-shell.theater-research .tools-panel { width: auto; min-width: 0; flex: 0 0 calc(70% - 8px); opacity: 1; pointer-events: auto; padding: 12px; border-left-color: var(--glass-border); overflow: auto; }

/* ── INTIMATE: Sidebar=30%, Chat=70%, Tools=0 ── */
.app-shell.theater-intimate > .sidebar { width: 30%; min-width: 200px; }
.app-shell.theater-intimate .tools-panel { width: 0; min-width: 0; padding: 0; overflow: hidden; border-left-color: transparent; opacity: 0; pointer-events: none; }

/* ── MAXIMIZE: Single panel takes everything ── */

/* Maximize Tools */
.app-shell.maximize-tools > .sidebar { width: 0; min-width: 0; padding: 0; overflow: hidden; border-right-color: transparent; opacity: 0; }
.app-shell.maximize-tools .chat-log { flex: 0 0 0px; min-width: 0; width: 0; overflow: hidden; border: none; padding: 0; opacity: 0; }
.app-shell.maximize-tools .tools-panel { width: auto; min-width: 0; flex: 1; opacity: 1; pointer-events: auto; padding: 12px; border-left-color: var(--glass-border); overflow: auto; }

/* Maximize Chat */
.app-shell.maximize-chat > .sidebar { width: 0; min-width: 0; padding: 0; overflow: hidden; border-right-color: transparent; opacity: 0; }
.app-shell.maximize-chat .tools-panel { width: 0; min-width: 0; padding: 0; overflow: hidden; border-left-color: transparent; opacity: 0; pointer-events: none; }

/* Maximize Sidebar */
.app-shell.maximize-sidebar > .main-stage { flex: 0 0 0px; min-width: 0; overflow: hidden; opacity: 0; }
.app-shell.maximize-sidebar > .sidebar { flex: 1; width: auto; }

/* ── Splitter between sidebar and main stage ── */
.splitter-sidebar {
  width: 6px;
  flex-shrink: 0;
  cursor: col-resize;
  background: transparent;
  position: relative;
  z-index: 2;
}
.splitter-sidebar::after {
  content: "";
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: 2px; height: 30px;
  background: var(--glass-border);
  border-radius: 1px;
  transition: background 0.3s ease, height 0.3s ease, box-shadow 0.3s ease;
}
.splitter-sidebar:hover::after,
.splitter-sidebar.dragging::after {
  background: var(--mood-color);
  height: 60px;
  box-shadow: 0 0 12px var(--mood-glow);
}

/* Main stage needs transition for maximize-sidebar */
.main-stage {
  transition: flex 0.5s cubic-bezier(0.4, 0, 0.2, 1),
              opacity 0.35s ease,
              min-width 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ── Sovereign Focus — The Spotlight ── */
@keyframes sovereign-pulse {
  0%, 100% {
    box-shadow: 0 0 8px var(--mood-glow), 0 0 20px var(--mood-glow-soft);
    border-color: var(--mood-color);
  }
  50% {
    box-shadow: 0 0 20px var(--mood-glow), 0 0 50px var(--mood-glow), 0 0 80px var(--mood-glow-soft);
    border-color: var(--mood-color);
  }
}
.sovereign-focus {
  border: 2px solid var(--mood-color) !important;
  animation: sovereign-pulse 1.2s ease-in-out infinite !important;
  position: relative;
  z-index: 10;
}

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.08); }
::-webkit-scrollbar-thumb:hover { background: rgba(255, 255, 255, 0.15); }

/* ── Responsive ── */
@media (max-width: 980px) {
  .sidebar {
    position: fixed; z-index: 70;
    height: 100vh; left: 0; top: 0;
    transform: translateX(-100%);
    transition: transform 0.24s ease;
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar.collapsed { width: 0; padding: 0; overflow: hidden; }
}

@media (max-width: 640px) {
  .topbar { grid-template-columns: 1fr 1fr; }
  .brand { display: none; }
  .composer-row { grid-template-columns: 1fr auto; }
  .composer-row .btn-icon:first-child { display: none; }
  .cockpit { flex-direction: column; }
  .splitter { display: none; }
  .tools-panel.open { width: 100%; min-width: 0; max-height: 50vh; }
  .chat-log.minimized { flex: 0 0 0px; min-width: 0; width: 0; }
}
