.puls-voice-mode {
  position: fixed;
  inset: 0;
  z-index: 1800;
  overflow: hidden;
  background: #00030a;
  touch-action: manipulation;
}

.puls-voice-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.topbar-inner {
  position: relative;
}

.puls-voice-header-label {
  --puls-mode-input: #43bfff;
  --puls-mode-processing: #ff9a32;
  --puls-mode-inactive: rgba(184, 199, 213, .58);
  position: absolute;
  top: 50%;
  left: 50%;
  display: inline-flex;
  color: #f4fbff;
  font-size: 13px;
  font-weight: 400;
  line-height: 1;
  white-space: nowrap;
  pointer-events: none;
  transform: translate(-50%, -50%);
  align-items: center;
  gap: 7px;
}

body:not([data-auth-state="authenticated"]) .puls-voice-header-label {
  display: none;
}

:is(body.voice-workspace-visible, body[data-auth-state="authenticated"]) .topbar-inner {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
}

:is(body.voice-workspace-visible, body[data-auth-state="authenticated"]) .brand-nav-toggle {
  min-width: 0;
  max-width: 100%;
  justify-self: start;
}

:is(body.voice-workspace-visible, body[data-auth-state="authenticated"]) .puls-voice-header-label {
  position: static;
  grid-column: 2;
  justify-self: center;
  transform: none;
}

:is(body.voice-workspace-visible, body[data-auth-state="authenticated"]) .system-pill {
  min-width: 0;
  max-width: 100%;
  justify-self: end;
}

.puls-voice-header-audiogram {
  display: inline-flex;
  width: 23px;
  height: 15px;
  align-items: center;
  justify-content: center;
  gap: 3.22px;
  color: var(--puls-mode-input);
  padding: 0;
  border: 0;
  background: transparent;
  transition: color .28s ease, filter .28s ease;
}

.puls-header-mode-control,
.puls-header-mode-label {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  font: inherit;
  line-height: 1;
  cursor: default;
}

.puls-header-mode-label {
  order: 1;
  width: 74px;
  color: #f4fbff;
  text-align: center;
}

.puls-text-header-icon {
  order: 2;
  width: 25px;
  height: 21px;
  margin-left: -4px;
  color: var(--puls-mode-inactive);
  transition: color .28s ease, filter .28s ease;
}

.puls-text-header-icon svg { width: 100%; height: 100%; fill: none; stroke: currentColor; stroke-width: 1.5; }
.puls-text-header-icon circle { fill: currentColor; stroke: none; }
.puls-voice-header-label[data-mode="text"] .puls-voice-header-audiogram { display: none; }
.puls-voice-header-label[data-mode="voice"] .puls-voice-header-audiogram { order: 2; }
.puls-voice-header-label[data-mode="voice"] .puls-text-header-icon { display: none; }
.puls-voice-header-label[data-mode="text"][data-text-state="idle"] .puls-text-header-icon { color: var(--puls-mode-input); filter: none; }
.puls-voice-header-label[data-mode="text"][data-text-state="typing"] .puls-text-header-icon { color: var(--puls-mode-input); filter: drop-shadow(0 0 5px rgba(67,191,255,.24)); }
.puls-voice-header-label[data-mode="text"][data-text-state="thinking"] .puls-text-header-icon { color: var(--puls-mode-processing); filter: drop-shadow(0 0 5px rgba(255,154,50,.22)); }
.puls-voice-header-label[data-mode="text"][data-text-state="idle"] .puls-text-header-icon circle { animation: none; opacity: .72; }
.puls-voice-header-label[data-mode="text"][data-text-state="typing"] .puls-text-header-icon circle { animation: puls-text-dot-input 1.7s ease-in-out infinite; }
.puls-voice-header-label[data-mode="text"][data-text-state="thinking"] .puls-text-header-icon circle { animation: puls-text-dot-processing 1.2s ease-in-out infinite; }
.puls-voice-header-label[data-mode="text"] .puls-text-header-icon circle:nth-of-type(2) { animation-delay: .18s; }
.puls-voice-header-label[data-mode="text"] .puls-text-header-icon circle:nth-of-type(3) { animation-delay: .36s; }

.puls-voice-header-audiogram i {
  width: 2px;
  height: 5px;
  border-radius: 999px;
  background: currentColor;
  opacity: .55;
  animation: puls-voice-header-idle 1.8s ease-in-out infinite;
}

.puls-voice-header-audiogram i:nth-child(2) { animation-delay: -.22s; }
.puls-voice-header-audiogram i:nth-child(3) { animation-delay: -.44s; }
.puls-voice-header-audiogram i:nth-child(4) { animation-delay: -.66s; }
.puls-voice-header-label[data-mode="voice"][data-voice-state="listening"] .puls-voice-header-audiogram { color: var(--puls-mode-input); filter: drop-shadow(0 0 5px rgba(67,191,255,.24)); }
.puls-voice-header-label[data-mode="voice"][data-voice-state="listening"] .puls-voice-header-audiogram i { animation-name: puls-voice-header-listening; animation-duration: 1.05s; }
.puls-voice-header-label[data-mode="voice"][data-voice-state="thinking"] .puls-voice-header-audiogram { color: var(--puls-mode-processing); filter: drop-shadow(0 0 5px rgba(255,154,50,.22)); }
.puls-voice-header-label[data-mode="voice"][data-voice-state="speaking"] .puls-voice-header-audiogram { color: var(--puls-mode-input); filter: drop-shadow(0 0 5px rgba(67,191,255,.24)); }
.puls-voice-header-label[data-mode="voice"][data-voice-state="thinking"] .puls-voice-header-audiogram i { animation-name: puls-voice-header-thinking; animation-duration: 1.2s; }
.puls-voice-header-label[data-mode="voice"][data-voice-state="speaking"] .puls-voice-header-audiogram i { animation-name: puls-voice-header-speaking; animation-duration: .62s; }

@keyframes puls-voice-header-idle { 0%,100% { height: 4px; opacity: .35; } 50% { height: 7px; opacity: .65; } }
@keyframes puls-voice-header-listening { 0%,100% { height: 5px; } 35% { height: 13px; opacity: .95; } 70% { height: 8px; } }
@keyframes puls-voice-header-thinking { 0%,100% { height: 5px; opacity: .45; } 45% { height: 15px; opacity: .95; } 72% { height: 9px; } }
@keyframes puls-voice-header-speaking { 0%,100% { height: 6px; } 30% { height: 16px; opacity: 1; } 65% { height: 10px; } }
@keyframes puls-text-dot-input { 0%,60%,100% { opacity: .35; } 30% { opacity: 1; } }
@keyframes puls-text-dot-processing { 0%,60%,100% { opacity: .3; } 30% { opacity: 1; } }

@media (max-width: 600px) {
  .puls-voice-header-label {
    gap: 5px;
    font-size: 12px;
  }

  .puls-header-mode-label { width: 68px; }
  .puls-voice-header-audiogram { width: 20px; height: 14px; gap: 2.45px; }
  .puls-text-header-icon { width: 22px; height: 19px; }
}

@media (prefers-reduced-motion: reduce) {
  .puls-voice-header-audiogram i { animation: none !important; height: 6px; }
  .puls-text-header-icon circle { animation: none !important; }
}

.puls-voice-status {
  position: fixed;
  z-index: 4;
  left: 50%;
  top: calc(50% + clamp(92px, 15vh, 150px));
  width: min(86vw, 520px);
  margin: 0;
  padding: 10px 14px;
  color: #e8f8ff;
  border: 1px solid rgba(38, 220, 255, .28);
  border-radius: 12px;
  background: rgba(2, 7, 13, .68);
  box-shadow: 0 0 18px rgba(8, 108, 255, .16);
  font-size: 14px;
  line-height: 1.45;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 6px);
  transition: opacity 180ms ease, transform 180ms ease;
}

.puls-voice-status.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

.puls-voice-status.is-error {
  color: #ffd89a;
  border-color: rgba(255, 174, 66, .42);
}

.puls-voice-controls {
  position: fixed;
  z-index: 3;
  left: 50%;
  bottom: max(28px, env(safe-area-inset-bottom));
  display: flex;
  align-items: center;
  gap: clamp(34px, 8vw, 72px);
  opacity: 0;
  pointer-events: none;
  transform: translateX(-50%);
  transition: opacity 220ms ease;
  isolation: isolate;
}

.puls-voice-controls.is-visible {
  opacity: 1;
  pointer-events: auto;
}

.puls-voice-attachment-menu {
  position: fixed;
  z-index: 4;
  left: 50%;
  bottom: calc(max(28px, env(safe-area-inset-bottom)) + 106px);
  width: 220px;
  visibility: hidden;
  pointer-events: none;
  transform: translateX(-50%);
  transition: none;
}

.puls-voice-attachment-menu.is-visible {
  visibility: visible;
  pointer-events: auto;
}

.puls-voice-attachment-menu::before {
  display: none;
}

.puls-voice-attachment-item {
  --voice-attachment-dot: 0;
  --voice-attachment-ray: 0;
  --voice-attachment-full: 0;
  --voice-attachment-label: 0;
  position: relative;
  width: 100%;
  height: 42px;
}

.puls-voice-attachment-item > button {
  position: absolute;
  inset: 0;
  opacity: var(--voice-attachment-full);
  pointer-events: none;
  transform: scaleY(calc(.045 + .955 * var(--voice-attachment-full)));
  transform-origin: center;
  transition: background .18s, border-color .18s, box-shadow .18s, color .18s;
}

.puls-voice-attachment-item.is-ready > button {
  pointer-events: auto;
}

.puls-voice-attachment-item > button > span {
  opacity: var(--voice-attachment-label);
}

.puls-voice-attachment-item.is-selected > button,
.puls-voice-attachment-item > button:not(:disabled):hover,
.puls-voice-attachment-item > button:not(:disabled):focus-visible,
.puls-voice-attachment-item > button:not(:disabled):active {
  color: #fff;
  border-color: #26dcff;
  background: rgba(2, 10, 18, .94);
  box-shadow: inset 0 0 0 1px #26dcff, 0 0 10px rgba(38, 220, 255, .24);
}

.puls-voice-attachment-dot,
.puls-voice-attachment-ray {
  position: absolute;
  z-index: 2;
  top: 50%;
  left: 50%;
  pointer-events: none;
}

.puls-voice-attachment-dot {
  width: 2.5px;
  height: 2.5px;
  border-radius: 50%;
  background: #dcefff;
  box-shadow: 0 0 5px #50cfff, 0 0 12px #2677ff, 0 0 22px rgba(38, 119, 255, .65);
  opacity: var(--voice-attachment-dot);
  transform: translate(-50%, -50%) scale(var(--voice-attachment-dot));
}

.puls-voice-attachment-ray {
  width: calc(100% * var(--voice-attachment-ray));
  height: 2px;
  border-radius: 999px;
  background: linear-gradient(90deg, transparent, #2677ff 8%, #50cfff 45%, #dcefff 50%, #50cfff 55%, #2677ff 92%, transparent);
  box-shadow: 0 0 8px rgba(80, 207, 255, .95), 0 0 18px rgba(38, 119, 255, .7);
  opacity: calc(1 - var(--voice-attachment-full));
  transform: translate(-50%, -50%);
}

.puls-voice-control {
  position: relative;
  z-index: 1;
  display: grid;
  width: 46px;
  height: 46px;
  padding: 0;
  place-items: center;
  color: #d8f5ff;
  border: 0;
  border-radius: 50%;
  background: transparent;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.puls-voice-control::before {
  position: absolute;
  inset: 2px;
  content: "";
  border-radius: 50%;
  border: 1px solid rgba(38, 220, 255, .84);
  background: rgba(38, 220, 255, .04);
  box-shadow:
    0 0 7px rgba(38, 220, 255, .78),
    0 0 20px rgba(8, 108, 255, .66),
    0 0 34px rgba(8, 108, 255, .28),
    inset 0 0 8px rgba(38, 220, 255, .12);
  opacity: 0;
  transform: scale(.72);
  transition: opacity 160ms ease, transform 160ms ease;
}

.puls-voice-control:active::before,
.puls-voice-control.is-pending::before,
.puls-voice-control.is-active::before {
  opacity: 1;
  transform: scale(1);
}

.puls-voice-control:focus-visible {
  outline: 2px solid #26dcff;
  outline-offset: 4px;
}

.puls-voice-control svg {
  position: relative;
  z-index: 1;
  width: 25px;
  height: 25px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.puls-voice-toggle {
  width: 64px;
  height: 64px;
}

.puls-voice-toggle svg {
  width: 34px;
  height: 34px;
}

.puls-voice-toggle .voice-stop-icon,
.puls-voice-toggle.is-running .voice-play-icon {
  display: none;
}

.puls-voice-toggle.is-running .voice-stop-icon {
  display: block;
}

body.voice-mode-active {
  overflow: hidden !important;
}

body.voice-mode-active #app {
  pointer-events: none;
}

body.voice-workspace-mode #app {
  position: fixed;
  inset: 0;
  z-index: 1700;
  width: 100%;
  height: 100%;
  overflow: auto;
  pointer-events: auto;
}

body.voice-workspace-mode #app > .hero,
body.voice-workspace-mode #app .side,
body.voice-workspace-mode #app .composer {
  display: none !important;
}

body.voice-workspace-mode #app .workspace {
  display: block !important;
  min-height: 100%;
  grid-template-columns: minmax(0, 1fr) !important;
}

body.voice-workspace-mode #app .content,
body.voice-workspace-mode #app .main-panel {
  width: 100%;
  max-width: none;
  min-height: 100%;
  margin: 0;
}

.puls-voice-mode.is-workspace-visible {
  pointer-events: none;
}

.puls-voice-mode.is-workspace-visible .puls-voice-canvas {
  visibility: hidden;
}

.puls-voice-mode.is-workspace-visible .puls-voice-controls {
  pointer-events: none;
}

.puls-voice-controls::before {
  position: absolute;
  z-index: 0;
  inset: -136px -48px;
  content: "";
  pointer-events: none;
  background:
    radial-gradient(circle 53px at 71px 50%, rgba(0, 0, 0, .96) 0 28%, rgba(0, 0, 0, .72) 50%, rgba(0, 0, 0, .26) 74%, transparent 100%),
    radial-gradient(circle 82px at 50% 50%, rgba(0, 0, 0, .98) 0 36%, rgba(0, 0, 0, .82) 52%, rgba(0, 0, 0, .32) 72%, rgba(0, 0, 0, .08) 88%, transparent 100%),
    radial-gradient(circle 53px at calc(100% - 71px) 50%, rgba(0, 0, 0, .96) 0 28%, rgba(0, 0, 0, .72) 50%, rgba(0, 0, 0, .26) 74%, transparent 100%);
}

.puls-voice-mode.is-workspace-visible .puls-voice-controls.is-visible {
  pointer-events: auto;
}

.puls-voice-mode.is-workspace-visible .puls-voice-control {
  background: rgba(0, 3, 10, .86);
}

@media (max-width: 480px) {
  .puls-voice-canvas {
    transform: scale(1.05);
    transform-origin: 50% 47%;
  }

  .puls-voice-controls {
    bottom: max(20px, env(safe-area-inset-bottom));
    gap: 32px;
  }

  .puls-voice-attachment-menu {
    bottom: calc(max(20px, env(safe-area-inset-bottom)) + 106px);
  }
}

@media (prefers-reduced-motion: reduce) {
  .puls-voice-controls,
  .puls-voice-control::before,
  .puls-voice-attachment-item > button {
    transition-duration: 1ms;
  }
}
