/* Keep the neural core legible on both workspace themes without adding height. */
:root[data-theme] .cortex-companion .cortex-control {
  isolation:isolate;
  overflow:visible;
}
:root[data-theme] .cortex-companion .cortex-control::before {
  content:"";
  position:absolute;
  inset:8px;
  z-index:0;
  border:1px solid color-mix(in srgb,var(--cyan) 84%,#fff 16%);
  border-radius:50%;
  background:radial-gradient(circle at 50% 42%,#153650 0%,#0a1c2e 62%,#061321 100%);
  box-shadow:inset 0 0 22px #00d9ef2b,0 0 18px #00d9ef75,0 0 42px #7762ff3d;
  pointer-events:none;
  animation:cortex-core-idle 2.4s ease-in-out infinite;
}
:root[data-theme] .cortex-companion .cortex-control img {
  position:relative;
  z-index:1;
  transform:scale(1.2);
  filter:brightness(1.25) contrast(1.12) saturate(1.25) drop-shadow(0 0 11px #35eaf4c9) drop-shadow(0 0 25px #8571ff85);
}
:root[data-theme] .cortex-companion:is([data-voice=listening],[data-voice=thinking],[data-voice=speaking]) .cortex-control::before {
  border-color:var(--heartbeat-color,#00d8f2);
  animation:cortex-core-active 1.65s ease-in-out infinite;
}
:root[data-theme] .cortex-companion[data-voice=thinking] .cortex-control::before {
  box-shadow:inset 0 0 24px #8b70ff38,0 0 20px #9f66ffb3,0 0 48px #9f66ff59;
}
:root[data-theme] .cortex-companion[data-voice=speaking] .cortex-control::before {
  box-shadow:inset 0 0 24px #35e4ca38,0 0 20px #35e4caa6,0 0 48px #35e4ca50;
}
@keyframes cortex-core-idle {
  0%,44%,100% {opacity:.78;box-shadow:inset 0 0 18px #00d9ef22,0 0 13px #00d9ef61,0 0 32px #7762ff30}
  12% {opacity:1;box-shadow:inset 0 0 24px #00d9ef40,0 0 24px #00d9efaa,0 0 52px #7762ff68}
  24% {opacity:.86}
  34% {opacity:.96;box-shadow:inset 0 0 22px #00d9ef38,0 0 20px #00d9ef91,0 0 44px #7762ff56}
}
@keyframes cortex-core-active {
  0%,44%,100% {opacity:.82;filter:brightness(1)}
  12% {opacity:1;filter:brightness(1.25)}
  24% {opacity:.9}
  34% {opacity:1;filter:brightness(1.15)}
}
@media(prefers-reduced-motion:reduce) {
  :root[data-theme] .cortex-companion .cortex-control::before {animation:none!important;opacity:1}
  :root[data-theme] .cortex-companion .cortex-control img {transform:none}
}
@media(forced-colors:active) {
  :root[data-theme] .cortex-companion .cortex-control::before {background:Canvas;border-color:CanvasText;box-shadow:none;animation:none}
  :root[data-theme] .cortex-companion .cortex-control img {filter:none}
}

/* Cortex-first launch keeps the existing voice, task and text controllers. */
:root[data-theme] .cortex-companion.cortex-first {
  position:relative;width:min(410px,calc(100vw - 28px));min-height:460px;
  padding:34px 22px 22px;text-align:center;overflow-y:auto;
  border:1px solid color-mix(in srgb,var(--cyan) 36%,var(--line));
  border-radius:22px;background:var(--panel);
  box-shadow:0 24px 64px #0008,0 0 28px color-mix(in srgb,var(--cyan) 13%,transparent);
}
:root[data-theme] .cortex-first .dialog-close {top:13px;right:14px;min-height:28px;padding:4px 7px;border:0;background:transparent;color:var(--muted)}
:root[data-theme] .cortex-companion.cortex-first >.cortex-setup-toggle {
  position:absolute;left:16px;top:13px;z-index:3;width:30px;height:30px;min-height:30px;
  padding:0;border:0;border-radius:50%;margin:0;background:transparent;color:var(--muted);font-size:17px;
}
:root[data-theme] .cortex-first .cortex-setup-toggle.attention::after {content:"";position:absolute;top:1px;right:0;width:7px;height:7px;border-radius:50%;background:#f4b24c;box-shadow:0 0 8px #f4b24c}
:root[data-theme] .cortex-first .cortex-control {width:226px;height:226px;margin:44px auto 18px}
:root[data-theme] .cortex-first h2 {font-size:20px;margin:0 0 4px}
:root[data-theme] .cortex-first .companion-voice-state {font-size:12px;margin:0;color:var(--muted)}
:root[data-theme] .cortex-first .cortex-quickbar {display:flex;justify-content:center;align-items:center;gap:14px;margin:26px auto 8px}
:root[data-theme] .cortex-first .cortex-quickbar button {min-height:38px;height:38px;min-width:38px;padding:0 10px;border:0;border-radius:50%;background:var(--raised);color:var(--text);font-size:17px}
:root[data-theme] .cortex-first .cortex-quickbar .primary {min-width:44px;height:44px;border-radius:24px;background:var(--cyan);color:#03212a;font-size:0;font-weight:700}
:root[data-theme] .cortex-first .cortex-quickbar .primary::before {content:"";display:block;width:19px;height:19px;background:currentColor;mask:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cg fill='none' stroke='black' stroke-width='1.7' stroke-linecap='round'%3E%3Crect x='9' y='2' width='6' height='13' rx='3'/%3E%3Cpath d='M5 10v2a7 7 0 0014 0v-2M12 19v3M8 22h8'/%3E%3C/g%3E%3C/svg%3E") center/contain no-repeat}
:root[data-theme] .cortex-first:is([data-voice=listening],[data-voice=speaking],[data-voice=thinking]) .cortex-quickbar .primary::before {mask:none;clip-path:polygon(15% 10%,40% 10%,40% 90%,15% 90%,15% 10%,60% 10%,85% 10%,85% 90%,60% 90%,60% 10%)}
:root[data-theme] .cortex-first .companion-reply {margin:14px 0 0;font-size:12px;text-align:left;max-height:24vh;overflow:auto}
:root[data-theme] .cortex-first .cortex-text {margin:16px 0 0;text-align:left}
:root[data-theme] .cortex-first .cortex-text textarea {min-height:72px;margin:8px 0}
:root[data-theme] .cortex-first .cortex-setup-panel {
  position:relative;margin:14px 0 0;padding:14px;border:1px solid var(--line);border-radius:12px;
  background:var(--raised);text-align:left;box-shadow:0 12px 28px #0003;
}
:root[data-theme] .cortex-first .cortex-setup-panel>strong {display:block;font-size:13px}
:root[data-theme] .cortex-first .cortex-setup-panel .companion-voice-access {margin:8px 0}
:root[data-theme] .cortex-first .cortex-setup-panel .companion-voice-access :is(select,input) {width:100%;min-height:34px;padding:6px 9px;border:1px solid var(--line);border-radius:8px;background:var(--bg);color:var(--text)}
:root[data-theme] .cortex-first .cortex-setup-panel button {min-height:32px;padding:6px 10px;margin:3px 6px 3px 0;font-size:11px}
:root[data-theme] .cortex-first .cortex-setup-panel p {font-size:10px;line-height:1.5;margin:8px 0 0}
:root[data-theme] .cortex-first :is(.cortex-setup-panel,.cortex-text,.companion-reply)[hidden] {display:none!important}
@media(max-width:480px){:root[data-theme] .cortex-companion.cortex-first {min-height:410px;padding:30px 18px 20px}:root[data-theme] .cortex-first .cortex-control {width:186px;height:186px;margin-top:42px}}
