/* ============================================================================
 * theCortex — Living Studio Droid Portraits & Strict Accent-Only Color System
 * Obsidian studio canvas (#06090d) matching the 4 square droid portraits:
 *   antigravity: aerospace white (#F2F6FC) + animated liquid-chrome shimmer
 *   nexx (ollama): dual neon blue (#00A8FF) + white (#F2F6FC) + neon orange (#FF7A1A)
 *   claude: neon orange (#FF7A1A)
 *   codex: neon blue (#00A8FF)
 * ========================================================================== */

.room-scene {
  flex: 0 0 auto;
  min-width: 0;
  background: #06090d;
}

.cortex-scene {
  --cx-bg: #06090d;
  --cx-surface: #0b1017;
  --cx-surface-hi: #111824;
  --cx-border: rgba(255, 255, 255, 0.09);
  --cx-text: #eef3f9;
  --cx-muted: #8b9bb0;
  position: relative;
  isolation: isolate;
  color: var(--cx-text);
  background:
    radial-gradient(ellipse 80% 70% at 50% 0%, rgba(0, 168, 255, 0.07), transparent 65%),
    radial-gradient(ellipse 65% 60% at 85% 10%, rgba(242, 246, 252, 0.05), transparent 60%),
    var(--cx-bg);
  font-family: var(--font-sans, inherit);
  border-bottom: 1px solid var(--cx-border);
}

.cortex-scene *,
.cortex-scene *::before,
.cortex-scene *::after {
  box-sizing: border-box;
}

.cortex-scene [hidden] {
  display: none !important;
}

.cortex-scene button:focus-visible {
  outline: 2px solid #F2F6FC;
  outline-offset: 2px;
  z-index: 12;
}

/* ---- Strict per-droid accent variables ---- */
.cortex-scene [data-theme="antigravity"] {
  --droid-accent: #F2F6FC;
  --droid-accent-rgb: 242, 246, 252;
  --droid-glow-soft: rgba(242, 246, 252, 0.22);
  --droid-glow-strong: rgba(242, 246, 252, 0.56);
}

.cortex-scene [data-theme="claude"] {
  --droid-accent: #FF7A1A;
  --droid-accent-rgb: 255, 122, 26;
  --droid-glow-soft: rgba(255, 122, 26, 0.24);
  --droid-glow-strong: rgba(255, 122, 26, 0.62);
}

.cortex-scene [data-theme="codex"] {
  --droid-accent: #00A8FF;
  --droid-accent-rgb: 0, 168, 255;
  --droid-glow-soft: rgba(0, 168, 255, 0.24);
  --droid-glow-strong: rgba(0, 168, 255, 0.62);
}

.cortex-scene [data-theme="nexx"] {
  --droid-accent: #00A8FF;
  --droid-accent-2: #FF7A1A;
  --droid-accent-3: #F2F6FC;
  --droid-accent-rgb: 0, 168, 255;
  --droid-glow-soft: rgba(0, 168, 255, 0.22);
  --droid-glow-strong: rgba(0, 168, 255, 0.54);
}

.cortex-scene [data-theme="venice"] {
  --droid-accent: #E14B4B;
  --droid-accent-rgb: 225, 75, 75;
  --droid-glow-soft: rgba(225, 75, 75, 0.24);
  --droid-glow-strong: rgba(225, 75, 75, 0.62);
}

.cortex-scene [data-theme="grok"] {
  --droid-accent: #E5E9F0;
  --droid-accent-rgb: 229, 233, 240;
  --droid-glow-soft: rgba(229, 233, 240, 0.22);
  --droid-glow-strong: rgba(229, 233, 240, 0.56);
}

.cortex-scene [data-theme="meta"] {
  --droid-accent: #3B82F6;
  --droid-accent-rgb: 59, 130, 246;
  --droid-glow-soft: rgba(59, 130, 246, 0.24);
  --droid-glow-strong: rgba(59, 130, 246, 0.60);
}

/* ---- Top Cortex toolbar (Council Chamber) ---- */
.cortex-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 16px 4px;
  background: transparent;
}

.cortex-brand {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.cortex-glyph {
  font-size: 0.95rem;
  color: #F2F6FC;
  opacity: 0.9;
}

.cortex-toolbar .scene-title {
  color: #F2F6FC;
  font-family: var(--font-display, inherit);
  font-size: 0.88rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.cortex-toolbar .scene-status {
  flex: 1;
  color: var(--cx-muted);
  font-size: 0.74rem;
}

.cortex-toolbar .scene-all,
.cortex-scene .reader-btn {
  border: 1px solid rgba(242, 246, 252, 0.24);
  color: #eef3f9;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 999px;
  min-height: 30px;
  padding: 4px 13px;
  font: 600 0.75rem/1 var(--font-sans, inherit);
  cursor: pointer;
  transition: background 160ms ease, border-color 160ms ease, color 160ms ease;
}

.cortex-toolbar .scene-all:hover:not(:disabled),
.cortex-scene .reader-btn:hover {
  background: rgba(242, 246, 252, 0.14);
  border-color: rgba(242, 246, 252, 0.55);
}

.cortex-toolbar .scene-all.picked {
  background: #F2F6FC;
  border-color: #F2F6FC;
  color: #06090d;
  box-shadow: 0 0 14px rgba(242, 246, 252, 0.32);
}

/* ---- Canvas & neural arc backdrop ---- */
.cortex-canvas {
  position: relative;
  width: 100%;
  padding: 8px 16px 14px;
}

.cortex-backdrop {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 0;
}

.cortex-arc-svg {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  width: 100%;
  height: 110px;
  opacity: 0.85;
}

.cortex-scene.is-direct .cortex-backdrop {
  opacity: 0.35;
}

/* Projector button hook (mounted into .scene-canvas by projector.js):
   Hidden by default so it never covers Nexx/Antigravity portraits; toggled on/off via toolbar Projector button. */
.cortex-scene .hive-projector {
  display: none !important;
}
.cortex-scene.show-projector:not(.is-direct) .hive-projector {
  display: flex !important;
  position: relative !important;
  inset: auto !important;
  left: auto !important;
  top: auto !important;
  right: auto !important;
  width: 100% !important;
  max-width: 520px !important;
  height: auto !important;
  min-height: 44px;
  max-height: 150px !important;
  margin: 8px auto 0 !important;
  z-index: 4;
  padding: 6px 10px;
  border-radius: 12px;
  border: 1px solid rgba(56, 189, 248, 0.35);
  background: rgba(11, 16, 23, 0.94);
  color: #cbd5e1;
  font-size: 0.74rem;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-shadow: none;
  overflow: hidden;
}
.cortex-scene.show-projector .hive-projector strong { font-size: 0.76rem; font-weight: 600; color: #f1f5f9; }
.cortex-scene.show-projector .hive-projector span { display: inline; font-size: 0.72rem; color: #94a3b8; }
.cortex-scene.show-projector .hive-projector img,
.cortex-scene.show-projector .hive-projector video {
  width: auto !important;
  max-width: 100% !important;
  height: auto !important;
  max-height: 128px !important;
  border-radius: 8px;
  object-fit: contain;
}
.cortex-scene.stage-collapsed .cortex-canvas,
.cortex-scene.stage-collapsed .scene-extra-seats,
.cortex-scene.stage-collapsed .scene-working-roster {
  display: none !important;
}

/* ---- Council Chamber: Living Studio Droids ---- */
.cortex-chamber {
  position: relative;
  z-index: 2;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(132px, 1fr));
  gap: 10px;
  max-width: 1220px;
  margin: 0 auto;
  align-items: start;
}

.cortex-droid-card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 7px;
  padding: 12px 10px 10px;
  border-radius: 18px;
  background: linear-gradient(180deg, rgba(16, 23, 34, 0.76), rgba(6, 9, 13, 0.94));
  border: 1px solid rgba(255, 255, 255, 0.08);
  transition: transform 240ms cubic-bezier(0.22, 1, 0.36, 1), border-color 220ms ease, box-shadow 260ms ease;
  min-width: 0;
}

.cortex-droid-card:hover {
  border-color: color-mix(in srgb, var(--droid-accent) 42%, transparent);
  background: linear-gradient(180deg, rgba(20, 29, 43, 0.86), rgba(6, 9, 13, 0.96));
}

.cortex-droid-card.picked {
  border-color: color-mix(in srgb, var(--droid-accent) 72%, transparent);
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--droid-accent) 26%, transparent), 0 8px 26px rgba(0, 0, 0, 0.45);
}

.cortex-droid-card[data-theme="nexx"].picked {
  border-color: rgba(0, 168, 255, 0.75);
  box-shadow: -6px 4px 20px rgba(0, 168, 255, 0.2), 6px 4px 20px rgba(255, 122, 26, 0.2);
}

.cortex-droid-card.is-speaking {
  transform: translateY(-4px) scale(1.035);
  border-color: var(--droid-accent);
  box-shadow:
    0 0 28px var(--droid-glow-strong),
    0 12px 32px rgba(0, 0, 0, 0.6);
  z-index: 5;
}

.cortex-droid-card[data-theme="nexx"].is-speaking {
  box-shadow:
    -10px 0 28px rgba(0, 168, 255, 0.45),
    10px 0 28px rgba(255, 122, 26, 0.45),
    0 0 22px rgba(242, 246, 252, 0.28),
    0 12px 32px rgba(0, 0, 0, 0.6);
}

/* ---- Living Studio Portrait Frame ---- */
.cortex-portrait-btn {
  position: relative;
  display: block;
  padding: 0;
  margin: 0;
  border: 0;
  background: transparent;
  border-radius: 50%;
  cursor: pointer;
}

.cortex-portrait-wrap {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: clamp(86px, 9.2vw, 114px);
  height: clamp(86px, 9.2vw, 114px);
  border-radius: 50%;
  background: #06090d;
  isolation: isolate;
  transition: transform 240ms cubic-bezier(0.22, 1, 0.36, 1);
}

.cortex-portrait-btn:hover .cortex-portrait-wrap {
  transform: scale(1.04);
}

.cortex-portrait-img {
  position: relative;
  z-index: 2;
  width: calc(100% - 6px);
  height: calc(100% - 6px);
  border-radius: 50%;
  object-fit: cover;
  object-position: center 16%;
  background: #06090d;
  display: block;
  user-select: none;
  pointer-events: none;
}

/* Accent Ring (strict color coding) */
.cortex-ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  z-index: 1;
  background: var(--droid-accent);
  opacity: 0.78;
  transition: opacity 220ms ease, filter 220ms ease;
}

/* Antigravity: clean aerospace white + animated liquid-chrome shimmer border */
[data-theme="antigravity"] .cortex-ring {
  background: conic-gradient(
    from 0deg,
    #F2F6FC 0deg,
    #8894A6 65deg,
    #FFFFFF 135deg,
    #6B778A 205deg,
    #E2E8F0 285deg,
    #F2F6FC 360deg
  );
  animation: cortex-chrome-spin 7s linear infinite;
}

/* Nexx: dual neon blue + aerospace white + neon orange fusion ring */
[data-theme="nexx"] .cortex-ring {
  background: conic-gradient(
    from 210deg,
    #00A8FF 0deg,
    #00A8FF 115deg,
    #F2F6FC 165deg,
    #FF7A1A 215deg,
    #FF7A1A 310deg,
    #F2F6FC 340deg,
    #00A8FF 360deg
  );
  animation: cortex-chrome-spin 11s linear infinite;
}

/* Claude: crisp neon orange rim */
[data-theme="claude"] .cortex-ring {
  background: linear-gradient(145deg, #FF994D 0%, #FF7A1A 55%, #CC5500 100%);
}

/* Codex: crisp neon blue rim */
[data-theme="codex"] .cortex-ring {
  background: linear-gradient(145deg, #4DC4FF 0%, #00A8FF 55%, #0077CC 100%);
}

/* Ambient Optical Halo — Calm idle breathing */
.cortex-aura {
  position: absolute;
  inset: -6px;
  border-radius: 50%;
  z-index: 0;
  pointer-events: none;
  background: radial-gradient(circle, var(--droid-glow-soft) 0%, transparent 72%);
  opacity: 0.55;
  animation: cortex-idle-breathe 4.6s ease-in-out infinite;
}

[data-theme="nexx"] .cortex-aura {
  background:
    radial-gradient(circle at 28% 50%, rgba(0, 168, 255, 0.34), transparent 62%),
    radial-gradient(circle at 72% 50%, rgba(255, 122, 26, 0.34), transparent 62%),
    radial-gradient(circle at 50% 25%, rgba(242, 246, 252, 0.22), transparent 58%);
}

/* Concentric neural wave ring (active during thinking / listening / speaking) */
.cortex-wave-ring {
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  z-index: 0;
  pointer-events: none;
  border: 1.5px solid var(--droid-accent);
  opacity: 0;
}

[data-theme="nexx"] .cortex-wave-ring {
  border-color: #00A8FF;
  box-shadow: inset 0 0 10px rgba(255, 122, 26, 0.45), 0 0 12px rgba(0, 168, 255, 0.45);
}

/* ---- Live State Classes: .is-thinking, .is-listening, .is-speaking ---- */
.is-thinking .cortex-ring {
  opacity: 1;
  filter: brightness(1.18);
  animation: cortex-thinking-pulse 1.35s ease-in-out infinite;
}

[data-theme="antigravity"].is-thinking .cortex-ring,
[data-theme="nexx"].is-thinking .cortex-ring {
  animation: cortex-chrome-spin 2.4s linear infinite;
}

.is-thinking .cortex-aura {
  opacity: 0.9;
  animation: cortex-thinking-aura 1.35s ease-in-out infinite;
}

.is-thinking .cortex-wave-ring {
  animation: cortex-wave-expand 1.6s ease-out infinite;
}

.is-listening .cortex-ring {
  opacity: 1;
}

.is-listening .cortex-wave-ring {
  animation: cortex-wave-expand 2s ease-out infinite;
}

.is-speaking .cortex-ring {
  opacity: 1;
  filter: brightness(1.3) drop-shadow(0 0 10px var(--droid-accent));
}

[data-theme="antigravity"].is-speaking .cortex-ring,
[data-theme="nexx"].is-speaking .cortex-ring {
  animation: cortex-chrome-spin 1.8s linear infinite;
}

.is-speaking .cortex-aura {
  inset: -12px;
  opacity: 1;
  background: radial-gradient(circle, var(--droid-glow-strong) 0%, transparent 72%);
  animation: cortex-speaking-bloom 0.85s ease-in-out infinite alternate;
}

[data-theme="nexx"].is-speaking .cortex-aura {
  background:
    radial-gradient(circle at 26% 50%, rgba(0, 168, 255, 0.62), transparent 64%),
    radial-gradient(circle at 74% 50%, rgba(255, 122, 26, 0.62), transparent 64%),
    radial-gradient(circle at 50% 22%, rgba(242, 246, 252, 0.42), transparent 58%);
}

.is-speaking .cortex-wave-ring {
  border-width: 2px;
  animation: cortex-wave-expand 1.1s cubic-bezier(0.16, 1, 0.3, 1) infinite;
}

/* ---- Audio-reactive Neural Equalizer Bars ---- */
.cortex-eq {
  display: inline-flex;
  align-items: flex-end;
  justify-content: center;
  gap: 3px;
  pointer-events: none;
}

.cortex-card-eq {
  position: absolute;
  bottom: 6px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 4;
  height: 16px;
  padding: 2px 7px;
  border-radius: 999px;
  background: rgba(6, 9, 13, 0.78);
  border: 1px solid color-mix(in srgb, var(--droid-accent) 45%, transparent);
  opacity: 0;
  transition: opacity 180ms ease;
}

.is-speaking .cortex-card-eq,
.is-listening .cortex-card-eq,
.is-thinking .cortex-card-eq {
  opacity: 1;
}

.cortex-eq-bar {
  display: block;
  width: 3px;
  height: 4px;
  border-radius: 999px;
  background: var(--droid-accent);
  box-shadow: 0 0 6px var(--droid-glow-soft);
  transform-origin: bottom center;
  will-change: transform;
}

[data-theme="nexx"] .cortex-eq-bar:nth-child(odd) {
  background: #00A8FF;
}
[data-theme="nexx"] .cortex-eq-bar:nth-child(even) {
  background: #FF7A1A;
}
[data-theme="nexx"] .cortex-eq-bar:nth-child(3n) {
  background: #F2F6FC;
}

.is-thinking .cortex-eq-bar {
  animation: cortex-eq-think 1.1s ease-in-out infinite;
  animation-delay: calc(var(--bar-i, 0) * 110ms);
}

.is-listening .cortex-eq-bar {
  animation: cortex-eq-listen 0.9s ease-in-out infinite;
  animation-delay: calc(var(--bar-i, 0) * 90ms);
}

.is-speaking .cortex-eq-bar {
  animation: cortex-eq-speak 0.52s ease-in-out infinite;
  animation-delay: calc(var(--bar-i, 0) * 75ms);
}

/* ---- Droid Card Controls & Metadata ---- */
.cortex-seat-pick {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 100%;
  min-height: 30px;
  padding: 4px 8px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.04);
  color: #eef3f9;
  font: inherit;
  cursor: pointer;
  transition: border-color 160ms ease, background 160ms ease;
}

.cortex-seat-pick:hover:not(:disabled) {
  border-color: color-mix(in srgb, var(--droid-accent) 60%, transparent);
  background: rgba(255, 255, 255, 0.08);
}

.cortex-droid-card.picked .cortex-seat-pick {
  border-color: var(--droid-accent);
  background: color-mix(in srgb, var(--droid-accent) 16%, #0b1017);
}

.cortex-seat-pick .scene-led,
.scene-extra-seats .scene-led {
  width: 8px;
  height: 8px;
  flex: 0 0 8px;
  border-radius: 50%;
  background: #ff3b4f;
  box-shadow: 0 0 7px rgba(255, 59, 79, 0.75);
}

.scene-seat[data-led-state="offline"] .scene-led {
  background: #ff3b4f;
  box-shadow: 0 0 7px rgba(255, 59, 79, 0.75);
}

.scene-seat[data-led-state="ready"] .scene-led {
  background: #1a9fff;
  box-shadow: 0 0 7px rgba(26, 159, 255, 0.8);
}

.scene-seat[data-led-state="selected"] .scene-led {
  background: #2bff88;
  box-shadow: 0 0 8px rgba(43, 255, 136, 0.85);
}

.cortex-seat-pick .sc-name {
  font-family: var(--font-display, inherit);
  font-size: 0.84rem;
  font-weight: 700;
  color: #F2F6FC;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cortex-state-pill {
  font-size: 0.66rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  padding: 2px 7px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.07);
  color: #b4c2d4;
  white-space: nowrap;
}

.is-thinking .cortex-state-pill,
.is-speaking .cortex-state-pill,
.is-listening .cortex-state-pill {
  background: color-mix(in srgb, var(--droid-accent) 20%, #0b1017);
  color: #ffffff;
  border: 1px solid color-mix(in srgb, var(--droid-accent) 55%, transparent);
}

.cortex-card-meta {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  flex-wrap: wrap;
  min-height: 14px;
}

.cortex-card-meta .sc-tag {
  font-size: 0.66rem;
  color: var(--cx-muted);
  padding: 0;
}

.cortex-card-meta .scene-subagents {
  font-size: 0.65rem;
  color: var(--droid-accent);
}

.cortex-card-bubble {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 6px 8px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.06);
  background: rgba(255, 255, 255, 0.03);
  color: #c7d4e5;
  text-align: left;
  font: inherit;
  cursor: pointer;
  min-height: 40px;
}

.cortex-card-bubble:hover:not(:disabled) {
  border-color: color-mix(in srgb, var(--droid-accent) 45%, transparent);
  background: rgba(255, 255, 255, 0.06);
}

.cortex-card-bubble:disabled {
  opacity: 0.6;
  cursor: default;
}

.cortex-card-bubble .bubble-text {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
  overflow-wrap: anywhere;
  font-size: 0.72rem;
  line-height: 1.35;
}

.cortex-card-bubble .bubble-time {
  font-size: 0.64rem;
  color: #6e7f96;
}

/* ---- Focused 1-on-1 Direct Tunnel Presence Stage ---- */
.cortex-direct-stage {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  min-height: 0;
  padding: 18px 20px 22px;
  gap: 16px;
}

.cortex-direct-back {
  align-self: flex-start;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.05);
  color: #cbd5e1;
  border-radius: 999px;
  padding: 5px 12px;
  font: 600 0.75rem/1 var(--font-sans, inherit);
  cursor: pointer;
}

.cortex-direct-back:hover {
  border-color: rgba(242, 246, 252, 0.45);
  color: #ffffff;
}

.cortex-direct-hero {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  width: 100%;
  text-align: center;
}

.cortex-direct-portrait-wrap {
  width: clamp(188px, 21vw, 256px);
  height: clamp(188px, 21vw, 256px);
}

.cortex-direct-stage .cortex-portrait-img {
  width: calc(100% - 8px);
  height: calc(100% - 8px);
}

.cortex-direct-stage.is-speaking .cortex-direct-portrait-wrap {
  transform: scale(1.04);
}

.cortex-direct-meta {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.cortex-direct-name {
  margin: 0;
  font-family: var(--font-display, inherit);
  font-size: 1.55rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: #F2F6FC;
}

.cortex-direct-role {
  margin: 0;
  font-size: 0.8rem;
  color: var(--cx-muted);
}

.cortex-direct-state {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  margin-top: 2px;
  font-size: 0.76rem;
  padding: 4px 12px;
}

.cortex-direct-state::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex: 0 0 8px;
  background: #ff3b4f;
  box-shadow: 0 0 7px rgba(255, 59, 79, 0.75);
}

.cortex-direct-stage.is-online .cortex-direct-state::before {
  background: #2bff88;
  box-shadow: 0 0 8px rgba(43, 255, 136, 0.85);
}

.cortex-direct-eq {
  height: 28px;
  gap: 4px;
  margin-top: 6px;
}

.cortex-direct-eq .cortex-eq-bar {
  width: 4px;
  height: 6px;
  opacity: 0.45;
  transition: opacity 200ms ease;
}

.cortex-direct-stage.is-speaking .cortex-direct-eq .cortex-eq-bar,
.cortex-direct-stage.is-listening .cortex-direct-eq .cortex-eq-bar,
.cortex-direct-stage.is-thinking .cortex-direct-eq .cortex-eq-bar {
  opacity: 1;
}

.cortex-voice-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  min-width: 132px;
  min-height: 44px;
  padding: 9px 18px;
  border-radius: 999px;
  border: 1.5px solid color-mix(in srgb, var(--droid-accent) 65%, transparent);
  background: color-mix(in srgb, var(--droid-accent) 12%, #0c121b);
  color: #F2F6FC;
  font: 600 0.86rem/1 var(--font-sans, inherit);
  cursor: pointer;
  box-shadow: 0 0 18px var(--droid-glow-soft);
  transition: transform 160ms ease, background 160ms ease, box-shadow 180ms ease;
}

.cortex-voice-btn:hover {
  transform: translateY(-1px);
  background: color-mix(in srgb, var(--droid-accent) 22%, #0c121b);
  box-shadow: 0 0 24px var(--droid-glow-strong);
}

.cortex-voice-btn.is-live {
  border-color: #ff4f6d;
  background: rgba(185, 28, 60, 0.28);
  box-shadow: 0 0 22px rgba(255, 79, 109, 0.45);
}

.cortex-voice-icon {
  display: inline-flex;
  width: 18px;
  height: 18px;
}

.cortex-voice-icon svg {
  width: 18px;
  height: 18px;
  fill: currentColor;
}

/* ---- Extra Seats & Working Subagents ---- */
.scene-extra-seats {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 6px 14px 10px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.scene-extra-seats .cortex-extra-seat {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.12);
}

.scene-extra-seats .scene-pick {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 0;
  background: transparent;
  color: #d6e0ec;
  padding: 2px 4px;
  font: 600 0.74rem/1 var(--font-sans, inherit);
  cursor: pointer;
}

.scene-extra-seats .scene-bubble {
  border: 0;
  border-left: 1px solid rgba(255, 255, 255, 0.14);
  background: transparent;
  color: #9fb0c6;
  padding: 2px 6px;
  font-size: 0.7rem;
  cursor: pointer;
}
.scene-extra-seats .scene-bubble::after { content: 'Read'; }
.scene-extra-seats .scene-bubble:disabled,
.scene-extra-seats .bubble-text,
.scene-extra-seats .bubble-time,
.scene-extra-seats .sc-tag { display: none; }

.scene-working-roster:not([hidden]) {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 6px 14px 10px;
}

.scene-working-child {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: #101722;
  color: #eef3f9;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 10px;
  padding: 4px 10px 4px 4px;
}
.scene-child-portrait { width: 34px; height: 34px; border-radius: 6px; object-fit: cover; }
.scene-child-label { display: grid; text-align: left; font-size: 0.75rem; }
.scene-child-label small { color: #8ec5ff; font-size: 0.68rem; }

/* ---- Full Message Reader Dialog ---- */
.scene-reader {
  position: fixed;
  z-index: 200;
  top: max(48px, 8vh);
  left: 50%;
  transform: translateX(-50%);
  width: min(650px, calc(100vw - 24px));
  max-height: 82dvh;
  display: flex;
  flex-direction: column;
  background: #0d131c;
  color: #eef3f9;
  border: 1px solid rgba(242, 246, 252, 0.22);
  border-radius: 16px;
  box-shadow: 0 20px 80px rgba(0, 0, 0, 0.78);
  padding: 18px;
}
.reader-head { display: flex; align-items: baseline; gap: 12px; border-bottom: 1px solid rgba(255, 255, 255, 0.12); padding-bottom: 10px; }
.reader-time { margin-left: auto; font-size: 0.75rem; color: #8b9bb0; }
.reader-body { white-space: pre-wrap; overflow-wrap: anywhere; overflow: auto; line-height: 1.6; font-size: 0.96rem; padding: 14px 0; }
.reader-actions { display: flex; justify-content: flex-end; gap: 8px; }
.scene-reader .reader-btn { min-height: 40px; }

/* ---- Mobile / Narrow Compact Adaptation (< 960px) ---- */
@media (max-width: 959px) {
  .cortex-toolbar { padding: 5px 10px 4px; gap: 6px; }
  .cortex-toolbar .scene-title { font-size: 0.82rem; }
  .cortex-toolbar .scene-status { font-size: 0.7rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .cortex-toolbar .scene-all { min-height: 26px; padding: 3px 9px; font-size: 0.7rem; }
  .cortex-canvas { padding: 4px 8px 6px; }
  .cortex-chamber {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 6px;
  }
  .cortex-droid-card {
    padding: 5px 3px 5px;
    border-radius: 12px;
    gap: 4px;
  }
  .cortex-portrait-wrap {
    width: 46px;
    height: 46px;
  }
  .cortex-seat-pick {
    padding: 2px 4px;
    gap: 3px;
    min-height: 22px;
  }
  .cortex-seat-pick .sc-name { font-size: 0.68rem; }
  .cortex-seat-pick .cortex-state-pill { display: none; }
  .cortex-card-meta,
  .cortex-card-bubble,
  .scene-extra-seats { display: none !important; }

  /* Mobile 1-on-1 compact hero banner at top + thumb-friendly Voice ring */
  .cortex-direct-stage {
    padding: 10px 12px;
    gap: 0;
  }
  .cortex-direct-back { display: none; }
  .cortex-direct-hero {
    flex-direction: row;
    align-items: center;
    justify-content: flex-start;
    text-align: left;
    gap: 12px;
  }
  .cortex-direct-portrait-wrap {
    width: 68px;
    height: 68px;
    flex: 0 0 68px;
  }
  .cortex-direct-meta {
    align-items: flex-start;
    flex: 1 1 auto;
    min-width: 0;
    gap: 3px;
  }
  .cortex-direct-name { font-size: 1.05rem; }
  .cortex-direct-role { display: none; }
  .cortex-direct-state { font-size: 0.7rem; padding: 2px 9px; margin-top: 0; }
  .cortex-direct-eq { height: 14px; margin-top: 2px; gap: 3px; }
  .cortex-direct-eq .cortex-eq-bar { width: 3px; height: 4px; }
  .cortex-voice-btn {
    min-width: 48px;
    width: 48px;
    height: 48px;
    padding: 0;
    border-radius: 50%;
    flex: 0 0 48px;
  }
  .cortex-voice-label { display: none; }
}

/* Keyboard open on phone: ultra-compact */
.cb-keyboard .cortex-scene .cortex-card-bubble,
.cb-keyboard .cortex-scene .cortex-card-meta,
.cb-keyboard .cortex-scene .cortex-direct-eq { display: none; }
.cb-keyboard .cortex-portrait-wrap { width: 48px; height: 48px; }
.cb-keyboard .cortex-direct-portrait-wrap { width: 48px; height: 48px; flex-basis: 48px; }

/* ---- 60fps Keyframes ---- */
@keyframes cortex-chrome-spin {
  to { transform: rotate(360deg); }
}

@keyframes cortex-idle-breathe {
  0%, 100% { opacity: 0.42; transform: scale(0.98); }
  50% { opacity: 0.72; transform: scale(1.04); }
}

@keyframes cortex-thinking-pulse {
  0%, 100% { opacity: 0.72; filter: brightness(1); }
  50% { opacity: 1; filter: brightness(1.35); }
}

@keyframes cortex-thinking-aura {
  0%, 100% { opacity: 0.55; transform: scale(0.99); }
  50% { opacity: 0.95; transform: scale(1.09); }
}

@keyframes cortex-speaking-bloom {
  0% { opacity: 0.78; transform: scale(1); }
  100% { opacity: 1; transform: scale(1.1); }
}

@keyframes cortex-wave-expand {
  0% { transform: scale(0.98); opacity: 0.72; }
  100% { transform: scale(1.22); opacity: 0; }
}

@keyframes cortex-eq-speak {
  0%, 100% { transform: scaleY(0.7); }
  35% { transform: scaleY(3.4); }
  65% { transform: scaleY(1.8); }
}

@keyframes cortex-eq-listen {
  0%, 100% { transform: scaleY(0.6); }
  50% { transform: scaleY(2.2); }
}

@keyframes cortex-eq-think {
  0%, 100% { transform: scaleY(0.5); opacity: 0.55; }
  50% { transform: scaleY(1.7); opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
  .cortex-scene *,
  .cortex-scene *::before,
  .cortex-scene *::after {
    animation: none !important;
    transition: none !important;
  }
}
