/* Treat Ghost — companion overlay + nav holo label */

.ni-add--holo .ni-add-ring {
  display: none !important;
}

.ni-add--holo .nil {
  margin-top: -6px;
  font-weight: 800;
  font-size: 10px;
  letter-spacing: 0.02em;
  background: linear-gradient(90deg, #32b5be, #7c6cff, #c4b8ff);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

/* ── Full-screen companion ───────────────────────────────────────── */

.treat-ghost-root {
  position: fixed;
  inset: 0;
  z-index: 960;
  pointer-events: none;
}

.treat-ghost-root[hidden] {
  display: none !important;
}

.treat-ghost-popup {
  position: fixed;
  inset: 0;
  z-index: 961;
  pointer-events: auto;
}

.treat-ghost-popup[hidden] {
  display: none !important;
  visibility: hidden !important;
}

.treat-ghost-veil {
  position: absolute;
  inset: -8%;
  pointer-events: none;
  z-index: 0;
  opacity: 1;
  background:
    radial-gradient(ellipse 130% 95% at 50% 108%, rgba(48, 120, 200, 0.32) 0%, transparent 58%),
    radial-gradient(ellipse 85% 70% at 12% 38%, rgba(60, 100, 200, 0.18) 0%, transparent 52%),
    radial-gradient(ellipse 75% 65% at 88% 52%, rgba(72, 140, 210, 0.14) 0%, transparent 48%);
  animation: treat-ghost-veil-in 0.9s cubic-bezier(0.22, 1, 0.36, 1) both;
}

@keyframes treat-ghost-veil-in {
  from {
    opacity: 0;
    transform: scale(0.94);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

.treat-ghost-scrim {
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: auto;
  cursor: pointer;
  background: linear-gradient(
    180deg,
    rgba(8, 10, 14, 0.25) 0%,
    rgba(8, 10, 14, 0.55) 35%,
    rgba(8, 10, 14, 0.9) 72%,
    rgba(8, 10, 14, 0.94) 100%
  );
}

.treat-ghost-field {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: max(12px, env(safe-area-inset-top))
    max(12px, env(safe-area-inset-right))
    calc(68px + env(safe-area-inset-bottom))
    max(12px, env(safe-area-inset-left));
  pointer-events: none;
  min-height: 0;
}

.treat-ghost-panel {
  position: relative;
  width: 100%;
  max-width: 520px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px 16px 14px;
  border-radius: 20px 20px 16px 16px;
  background: rgba(14, 16, 20, 0.94);
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 -8px 40px rgba(0, 0, 0, 0.45);
  pointer-events: auto;
}

.treat-ghost-thread {
  position: relative;
  flex: 0 1 auto;
  max-height: min(48vh, 380px);
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 2px 0;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.2) transparent;
}

.treat-ghost-line {
  position: relative;
  z-index: 1;
  display: block;
  width: fit-content;
  max-width: 92%;
  padding: 10px 14px;
  margin: 0;
  border: none;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.1);
  align-self: flex-start;
  font-family: Manrope, sans-serif;
  font-size: 15px;
  font-weight: 700;
  line-height: 1.45;
  letter-spacing: -0.01em;
  color: #f4f3f1;
  text-shadow: none;
  animation: treat-ghost-line-in 0.35s cubic-bezier(0.22, 1, 0.36, 1) both;
}

@keyframes treat-ghost-line-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.treat-ghost-line--ai {
  align-self: flex-start;
  margin-right: auto;
}

.treat-ghost-line--user {
  align-self: flex-end;
  margin-left: auto;
  text-align: left;
  color: #fff;
  font-weight: 800;
  background: rgba(48, 120, 200, 0.42);
  border: 1px solid rgba(126, 176, 232, 0.28);
}

.treat-ghost-line--system {
  align-self: center;
  margin-left: auto;
  margin-right: auto;
  text-align: center;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.55);
  background: transparent;
  padding: 4px 8px;
  max-width: 100%;
}

.treat-ghost-line--ai-holo {
  font-size: 15px;
  font-weight: 800;
  color: #dcecff;
  background: rgba(28, 56, 96, 0.55);
  border: 1px solid rgba(126, 176, 232, 0.35);
}

.treat-ghost-line--fade {
  opacity: 0.55;
}

.treat-ghost-actions {
  position: relative;
  flex: 0 0 auto;
  z-index: 2;
  display: flex;
  flex-wrap: wrap;
  gap: 8px 10px;
  justify-content: flex-start;
  align-items: center;
}

.treat-ghost-actions--stack {
  flex-direction: column;
  align-items: stretch;
  gap: 10px;
}

.treat-ghost-actions--stack .treat-ghost-act--primary {
  align-self: stretch;
}

.treat-ghost-act {
  flex: 0 1 auto;
  min-width: 0;
  padding: 10px 16px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  font-family: Manrope, sans-serif;
  font-size: 14px;
  font-weight: 800;
  color: #f2f1ef;
  text-shadow: none;
  cursor: pointer;
  text-decoration: none;
}

.treat-ghost-act--primary {
  color: #0e1014;
  background: linear-gradient(135deg, #9ed4f0, #7eb0e8);
  border-color: transparent;
}

.treat-ghost-act:active,
.treat-ghost-tag:active {
  opacity: 0.82;
  transform: scale(0.98);
}

.treat-ghost-act:disabled {
  opacity: 0.5;
  cursor: wait;
}

.treat-ghost-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  width: 100%;
}

.treat-ghost-tag {
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  background: rgba(255, 255, 255, 0.08);
  font-family: Manrope, sans-serif;
  font-size: 13px;
  font-weight: 800;
  color: #f2f1ef;
  cursor: pointer;
}

.treat-ghost-tag--on {
  border-color: rgba(126, 176, 232, 0.75);
  color: #dcecff;
  background: rgba(48, 120, 200, 0.45);
}

.treat-ghost-tags--glow .treat-ghost-tag {
  border-color: rgba(158, 212, 240, 0.45);
  box-shadow: 0 0 14px rgba(126, 176, 232, 0.28);
  animation: treat-ghost-tag-glow 2.6s ease-in-out infinite;
}

@keyframes treat-ghost-tag-glow {
  0%,
  100% {
    box-shadow: 0 0 10px rgba(126, 176, 232, 0.22);
  }
  50% {
    box-shadow: 0 0 18px rgba(158, 212, 240, 0.42);
  }
}

body.treat-ghost-open .treatly-agent-banner {
  display: none !important;
}

/* ── Terry takeover pulse (companion wakes — AI has the room) ─────────── */

.terry-takeover {
  position: fixed;
  inset: 0;
  z-index: 10032;
  pointer-events: none;
  overflow: hidden;
  opacity: 0;
  visibility: hidden;
}

.terry-takeover--in,
.terry-takeover--out {
  opacity: 1;
  visibility: visible;
}

.terry-takeover-vignette {
  position: absolute;
  inset: -5%;
  background:
    radial-gradient(
      circle 120vmax at var(--terry-ox, 50%) var(--terry-oy, 90%),
      rgba(94, 176, 232, 0.38) 0%,
      rgba(48, 120, 200, 0.14) 28%,
      transparent 58%
    ),
    radial-gradient(ellipse 100% 70% at 50% 50%, rgba(58, 134, 255, 0.08) 0%, transparent 70%);
  animation: terry-takeover-vignette 1.35s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.terry-takeover-flash {
  position: absolute;
  inset: 0;
  background: rgba(94, 176, 232, 0.14);
  opacity: 0;
  animation: terry-takeover-flash 0.55s ease-out both;
}

.terry-takeover-rings {
  position: absolute;
  left: var(--terry-ox, 50%);
  top: var(--terry-oy, 90%);
  width: 0;
  height: 0;
}

.terry-takeover-ring {
  position: absolute;
  left: 0;
  top: 0;
  width: 40vmax;
  height: 40vmax;
  margin: -20vmax 0 0 -20vmax;
  border-radius: 50%;
  border: 2px solid rgba(94, 176, 232, 0.55);
  box-shadow:
    0 0 24px rgba(94, 176, 232, 0.45),
    inset 0 0 40px rgba(58, 134, 255, 0.12);
  opacity: 0;
  transform: scale(0.15);
  animation: terry-takeover-ring 1.25s cubic-bezier(0.22, 1, 0.32, 1) forwards;
}

.terry-takeover-badge {
  position: absolute;
  left: var(--terry-ox, 50%);
  top: var(--terry-oy, 90%);
  transform: translate(-50%, calc(-100% - 18px));
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 14px 7px 10px;
  border-radius: 999px;
  font-family: Manrope, sans-serif;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #e8f4fc;
  background: rgba(14, 18, 28, 0.82);
  border: 1px solid rgba(126, 176, 232, 0.45);
  box-shadow: 0 8px 28px rgba(48, 120, 200, 0.35);
  opacity: 0;
  animation: terry-takeover-badge 1.1s cubic-bezier(0.22, 1, 0.36, 1) 0.08s both;
}

.terry-takeover-badge-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: linear-gradient(135deg, #5eb0e8, #3a86ff);
  box-shadow: 0 0 10px rgba(94, 176, 232, 0.9);
  animation: terry-badge-dot-pulse 1.2s ease-in-out infinite;
}

.terry-takeover-svg {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 10034;
}

.terry-takeover-trace {
  stroke-width: 3.5;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 2400;
  stroke-dashoffset: 2400;
  filter: drop-shadow(0 0 14px rgba(94, 176, 232, 0.75))
    drop-shadow(0 0 6px rgba(58, 134, 255, 0.45));
  animation: terry-takeover-trace-draw 1.15s cubic-bezier(0.33, 1, 0.48, 1) 0.05s forwards;
}

.terry-takeover-svg--out .terry-takeover-trace {
  animation: terry-takeover-trace-fade 0.5s ease-out forwards;
}

.terry-takeover-scan {
  animation: terry-takeover-scan 1.4s ease-out both;
}

@keyframes terry-takeover-vignette {
  0% {
    opacity: 0;
    transform: scale(0.92);
  }
  35% {
    opacity: 1;
  }
  100% {
    opacity: 0.35;
    transform: scale(1.02);
  }
}

@keyframes terry-takeover-flash {
  0% {
    opacity: 0;
  }
  18% {
    opacity: 0.55;
  }
  100% {
    opacity: 0;
  }
}

@keyframes terry-takeover-ring {
  0% {
    opacity: 0.85;
    transform: scale(0.12);
  }
  100% {
    opacity: 0;
    transform: scale(1.35);
  }
}

@keyframes terry-takeover-badge {
  0% {
    opacity: 0;
    transform: translate(-50%, calc(-100% - 8px)) scale(0.9);
  }
  40% {
    opacity: 1;
    transform: translate(-50%, calc(-100% - 18px)) scale(1);
  }
  100% {
    opacity: 0;
    transform: translate(-50%, calc(-100% - 22px)) scale(1);
  }
}

@keyframes terry-badge-dot-pulse {
  0%,
  100% {
    transform: scale(1);
    opacity: 1;
  }
  50% {
    transform: scale(1.25);
    opacity: 0.75;
  }
}

@keyframes terry-takeover-trace-draw {
  to {
    stroke-dashoffset: 0;
  }
}

@keyframes terry-takeover-trace-fade {
  to {
    opacity: 0;
    stroke-width: 1;
  }
}

@keyframes terry-takeover-scan {
  0% {
    box-shadow: 0 0 0 0 rgba(94, 176, 232, 0);
  }
  35% {
    box-shadow:
      0 0 0 2px rgba(94, 176, 232, 0.35),
      0 0 28px rgba(48, 120, 200, 0.22);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(94, 176, 232, 0);
  }
}

/* Sustained “someone’s home” while companion is open */
body.terry-ai-living::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: 10020;
  pointer-events: none;
  background:
    radial-gradient(ellipse 90% 55% at 50% 100%, rgba(48, 120, 200, 0.14) 0%, transparent 62%),
    radial-gradient(ellipse 70% 40% at 12% 20%, rgba(94, 176, 232, 0.06) 0%, transparent 55%),
    radial-gradient(ellipse 60% 35% at 88% 30%, rgba(58, 134, 255, 0.06) 0%, transparent 50%);
  animation: terry-living-breath 4.2s ease-in-out infinite;
}

body.terry-ai-living::after {
  content: '';
  position: fixed;
  inset: 0;
  z-index: 10021;
  pointer-events: none;
  box-shadow:
    inset 0 0 0 1px rgba(94, 176, 232, 0.22),
    inset 0 0 80px rgba(48, 120, 200, 0.06);
  animation: terry-living-edge 3.6s ease-in-out infinite;
}

@keyframes terry-living-breath {
  0%,
  100% {
    opacity: 0.55;
  }
  50% {
    opacity: 1;
  }
}

@keyframes terry-living-edge {
  0%,
  100% {
    box-shadow:
      inset 0 0 0 1px rgba(94, 176, 232, 0.16),
      inset 0 0 50px rgba(48, 120, 200, 0.04);
  }
  50% {
    box-shadow:
      inset 0 0 0 2px rgba(94, 176, 232, 0.32),
      inset 0 0 90px rgba(48, 120, 200, 0.1);
  }
}

body.terry-ai-living #n-add.terry-ai-living-source .holo-logo-canvas {
  animation: terry-holo-glow-pulse 2.6s ease-in-out infinite;
}

@keyframes terry-holo-glow-pulse {
  0%,
  100% {
    filter: drop-shadow(0 0 10px rgba(48, 120, 200, 0.62))
      drop-shadow(0 0 24px rgba(36, 96, 180, 0.4));
  }
  50% {
    filter: drop-shadow(0 0 18px rgba(94, 176, 232, 0.9))
      drop-shadow(0 0 40px rgba(48, 120, 200, 0.55))
      drop-shadow(0 0 58px rgba(58, 134, 255, 0.3));
  }
}

@media (prefers-reduced-motion: reduce) {
  .terry-takeover-ring,
  .terry-takeover-vignette,
  .terry-takeover-flash,
  .terry-takeover-badge,
  .terry-takeover-trace {
    animation-duration: 0.01ms !important;
  }
  body.terry-ai-living::before,
  body.terry-ai-living::after {
    animation: none;
    opacity: 0.7;
  }
  body.terry-ai-living #n-add.terry-ai-living-source .holo-logo-canvas {
    animation: none !important;
  }
}

/* ── Spatial mode — bubbles on app chrome, app stays fully usable ─── */

.treat-ghost-root--spatial {
  pointer-events: none;
}

.treat-ghost-root--spatial .treat-ghost-popup {
  pointer-events: none;
}

.treat-ghost-root--spatial .treat-ghost-scrim,
.treat-ghost-root--spatial .treat-ghost-veil {
  display: none;
}

.treat-ghost-root--spatial .treat-ghost-field {
  justify-content: flex-start;
  padding: 0;
  pointer-events: none;
}

.treat-ghost-root--spatial .treat-ghost-panel {
  display: none;
}

.treat-ghost-actions--anchored {
  position: fixed;
  z-index: 10055;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  max-width: min(320px, calc(100vw - 24px));
  padding: 0;
  margin: 0;
  background: transparent;
  border: none;
  box-shadow: none;
  pointer-events: auto;
}

.treat-ghost-actions--anchored.treat-ghost-actions--stack {
  flex-direction: row;
  align-items: flex-start;
  max-width: min(360px, calc(100vw - 16px));
}

.treat-ghost-actions--anchored .treat-ghost-act,
.treat-ghost-actions--anchored .treat-ghost-tag {
  pointer-events: auto;
  flex: 0 1 auto;
}

/* Diagnose stress tags — solid pills readable over live feed */
.treat-ghost-actions--anchored.treat-ghost-actions--diagnose {
  padding: 10px 12px;
  border-radius: 16px;
  background: rgba(14, 16, 20, 0.96);
  border: 1px solid rgba(126, 176, 232, 0.35);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
  max-width: min(380px, calc(100vw - 16px));
}

.treat-ghost-actions--anchored.treat-ghost-actions--diagnose .treat-ghost-tags {
  gap: 10px;
}

.treat-ghost-actions--anchored .treat-ghost-tag {
  background: rgba(22, 26, 34, 0.98);
  border: 1.5px solid rgba(255, 255, 255, 0.32);
  color: #fff;
  font-size: 14px;
  font-weight: 800;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.45);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
}

.treat-ghost-actions--anchored .treat-ghost-tags--glow .treat-ghost-tag {
  animation: none;
  border-color: rgba(158, 212, 240, 0.55);
}

.treat-ghost-actions--anchored .treat-ghost-tag--on {
  background: linear-gradient(135deg, #5a9fd4, #7eb0e8);
  border-color: transparent;
  color: #0e1014;
  text-shadow: none;
  box-shadow: 0 2px 12px rgba(94, 159, 212, 0.45);
}

.treat-ghost-actions--anchored .treat-ghost-act {
  background: rgba(22, 26, 34, 0.98);
  border: 1.5px solid rgba(255, 255, 255, 0.28);
  color: #fff;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
}

.treat-ghost-actions--anchored .treat-ghost-act--primary {
  color: #0e1014;
  text-shadow: none;
}

.treat-ghost-act--ghost {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.14);
  color: rgba(255, 255, 255, 0.72);
  font-weight: 700;
}

@media (max-width: 380px) {
  .treat-ghost-line {
    font-size: 14px;
    max-width: 94%;
  }

  .treat-ghost-panel {
    padding: 14px 12px 12px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .treat-ghost-line,
  .treat-ghost-veil {
    animation: none !important;
  }
}

/* Hold + to toggle Turbo — holo aura leaks on the ring */
.nav--product.nav--turbo-hold #n-add {
  position: relative;
  overflow: visible !important;
}

#n-add .ni-add-aura {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 56px;
  height: 56px;
  margin: -28px 0 0 -28px;
  border-radius: 50%;
  pointer-events: none;
  opacity: 0;
  background: radial-gradient(
    circle,
    rgba(50, 181, 190, 0.45) 0%,
    rgba(124, 108, 255, 0.28) 38%,
    transparent 68%
  );
  filter: blur(6px);
  z-index: 0;
}

#n-add .ni-add-ring {
  position: relative;
  z-index: 1;
}

#n-add .ni-add-holo-mini[data-holo-logo] {
  position: absolute;
  inset: -4px;
  opacity: 0;
  transform: scale(0.85);
  transition: opacity 0.35s ease, transform 0.35s ease;
  pointer-events: none;
}

#n-add.ni-add--turbo-on .ni-add-holo-mini[data-holo-logo] {
  opacity: 1;
  transform: scale(1);
}

#n-add.ni-add--turbo-on .nic--plus {
  opacity: 0.35;
}

#n-add.ni-add--aura-leak .ni-add-aura,
#n-add.ni-add--holding .ni-add-aura {
  animation: navAddAuraLeak 1.4s ease-out forwards;
}

#n-add.ni-add--turbo-on .ni-add-aura {
  opacity: 0.55;
  animation: navAddAuraPulse 2.8s ease-in-out infinite;
}

#n-add.ni-add--holding .ni-add-ring {
  transform: scale(0.94);
  transition: transform 0.15s ease;
}

#n-add.ni-add--turbo-on .nil {
  background: linear-gradient(90deg, #32b5be, #7c6cff, #c4b8ff);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  font-weight: 800;
}

@keyframes navAddAuraLeak {
  0% {
    opacity: 0;
    transform: scale(0.7);
  }
  35% {
    opacity: 0.95;
    transform: scale(1.15);
  }
  100% {
    opacity: 0;
    transform: scale(1.35);
  }
}

@keyframes navAddAuraPulse {
  0%,
  100% {
    opacity: 0.35;
    transform: scale(1);
  }
  50% {
    opacity: 0.7;
    transform: scale(1.08);
  }
}

/* Passive free AI on home (no Turbo) */
.home-lite-ai-host {
  margin: 8px 14px 4px;
  max-width: 100%;
}

.home-lite-ai-enc {
  font-size: 13px;
  line-height: 1.45;
  color: var(--text);
  margin: 0 0 8px;
  font-weight: 600;
}

.home-lite-ai-claim {
  display: block;
  width: 100%;
  margin-top: 10px;
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid rgba(50, 181, 190, 0.35);
  background: rgba(50, 181, 190, 0.1);
  color: var(--text);
  font-weight: 700;
  font-size: 13px;
  cursor: pointer;
}

.home-lite-ai-cap {
  font-size: 12px;
  color: var(--t3);
  margin: 8px 0 0;
  line-height: 1.4;
}

.home-lite-ai-hold {
  font-size: 12px;
  color: var(--t2);
  margin: 0 0 8px;
  line-height: 1.4;
  font-weight: 600;
}
