/* lumen.css — Depth & presence foundation (placeholder entity) */

/* Route home anchors — invisible, no layout shift outside dashboard grid */
.workspace-view {
  position: relative;
}
.workspace-view > .lumen-home-zone.bf-lumen-dock:not(#lumen-home-zone) {
  position: absolute;
  top: auto;
  bottom: 48px;
  right: 0;
  margin: 0;
  width: 260px;
  height: 260px;
  z-index: 0;
  pointer-events: none;
}

.lumen-root {
  position: fixed;
  inset: 0;
  z-index: 65;
  pointer-events: none;
  perspective: 900px;
  perspective-origin: 50% 40%;
}

/* Gemini WebGL full-viewport canvas — sole visual entity */
.lumen-webgl-layer {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
}
.lumen-webgl-layer canvas {
  display: block;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

/* Hit-target only — CSS orb visuals disabled when WebGL is active */
.lumen-entity--webgl {
  width: var(--lumen-hit-w, 188px) !important;
  height: var(--lumen-hit-h, 210px) !important;
  margin: var(--lumen-hit-mt, -58px) 0 0 var(--lumen-hit-ml, -76px);
  background: transparent !important;
  box-shadow: none !important;
  overflow: visible;
  cursor: pointer;
  transform: translate3d(
    calc(var(--lumen-x) + var(--lumen-float-x)),
    calc(var(--lumen-y) + var(--lumen-float-y)),
    0
  ) !important;
}
.lumen-entity--webgl.lumen-entity--minimized {
  width: max(44px, var(--lumen-hit-w, 48px)) !important;
  height: max(44px, var(--lumen-hit-h, 48px)) !important;
  min-width: 44px;
  min-height: 44px;
  margin: var(--lumen-hit-mt, -6px) 0 0 var(--lumen-hit-ml, -6px);
}
.lumen-entity--webgl.lumen-entity--panel-open {
  filter: brightness(1.08);
}
.lumen-entity--webgl .lumen-morph-shell,
.lumen-entity--webgl .lumen-core,
.lumen-entity--webgl .lumen-projected-shadow,
.lumen-entity--webgl .lumen-aura,
.lumen-entity--webgl .lumen-audit-ring,
.lumen-entity--webgl .lumen-guide-tail,
.lumen-entity--webgl .lumen-guide-tip,
.lumen-entity--webgl .lumen-particles {
  display: none !important;
}

.lumen-trail-canvas {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 1;
}

.lumen-entity {
  --lumen-x: 0px;
  --lumen-y: 0px;
  --lumen-z: 18px;
  --lumen-scale: 1;
  --lumen-rx: 0deg;
  --lumen-ry: 0deg;
  --lumen-glow: 0.45;
  --lumen-illum: 0.55;
  --lumen-refraction: 0.35;
  --lumen-shadow-blur: 28px;
  --lumen-shadow-opacity: 0.28;
  --lumen-parallax-x: 0px;
  --lumen-parallax-y: 0px;
  --lumen-float-x: 0px;
  --lumen-float-y: 0px;
  --lumen-attention: 0;
  --lumen-proximity: 0;
  --lumen-elongate: 0;
  --lumen-point: 0;
  --lumen-rings: 0;
  --lumen-energy-level: 0.4;
  --lumen-state-glow: 0.4;
  --lumen-twist: 0;
  --lumen-asym: 0;
  --lumen-guide-angle: 0deg;

  position: fixed;
  top: 0;
  left: 0;
  width: 36px;
  height: 36px;
  border: none;
  padding: 0;
  background: transparent;
  cursor: pointer;
  pointer-events: auto;
  z-index: 3;
  overflow: visible;
  transform:
    translate3d(
      calc(var(--lumen-x) + var(--lumen-float-x)),
      calc(var(--lumen-y) + var(--lumen-float-y)),
      0
    )
    scale(var(--lumen-scale));
  transform-style: preserve-3d;
  will-change: transform, filter;
  -webkit-tap-highlight-color: transparent;
  transition: filter 0.35s ease;
}

.lumen-entity:focus-visible {
  outline: 2px solid rgba(180, 200, 255, 0.7);
  outline-offset: 6px;
  border-radius: 50%;
}

.lumen-sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.lumen-projected-shadow {
  position: absolute;
  left: 50%;
  top: 72%;
  width: 62%;
  height: 28%;
  transform: translateX(-50%) translateZ(-1px) scale(calc(1 + var(--lumen-attention) * 0.15));
  border-radius: 50%;
  background: radial-gradient(
    ellipse at center,
    rgba(15, 18, 28, calc(var(--lumen-shadow-opacity) + 0.08)) 0%,
    rgba(15, 18, 28, calc(var(--lumen-shadow-opacity) * 0.45)) 45%,
    transparent 72%
  );
  filter: blur(calc(var(--lumen-shadow-blur) * 0.35));
  pointer-events: none;
  opacity: calc(0.75 + var(--lumen-attention) * 0.25);
}

.lumen-depth-layer {
  position: absolute;
  inset: 0;
  transform:
    perspective(720px)
    rotateX(var(--lumen-rx))
    rotateY(var(--lumen-ry))
    translateZ(var(--lumen-z));
  transform-style: preserve-3d;
  pointer-events: none;
}

.lumen-aura {
  position: absolute;
  inset: -10px;
  border-radius: 50%;
  background: radial-gradient(
    circle,
    rgba(170, 200, 255, calc(0.22 + var(--lumen-glow) * 0.35)) 0%,
    rgba(120, 90, 200, calc(0.06 + var(--lumen-glow) * 0.12)) 48%,
    transparent 72%
  );
  filter: blur(calc(3px + var(--lumen-glow) * 4px));
  opacity: calc(0.7 + var(--lumen-proximity) * 0.25);
  pointer-events: none;
  transform: translateZ(-8px);
}

.lumen-core {
  position: absolute;
  inset: 7px;
  border-radius: 50%;
  overflow: hidden;
  transform-style: preserve-3d;
  box-shadow:
    0 calc(6px + var(--lumen-z) * 0.15) calc(18px + var(--lumen-shadow-blur) * 0.25)
      rgba(12, 16, 28, calc(var(--lumen-shadow-opacity))),
    inset 0 1px 1px rgba(255, 255, 255, calc(0.28 + var(--lumen-illum) * 0.35)),
    inset 0 -10px 18px rgba(0, 0, 0, 0.4),
    0 0 calc(12px + var(--lumen-glow) * 20px) rgba(160, 190, 255, calc(var(--lumen-glow) * 0.35));
}

.lumen-glass {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background:
    radial-gradient(
      circle at calc(32% + var(--lumen-parallax-x) * 0.4) calc(26% + var(--lumen-parallax-y) * 0.4),
      rgba(255, 255, 255, calc(0.45 + var(--lumen-illum) * 0.35)) 0%,
      transparent 34%
    ),
    radial-gradient(circle at 70% 72%, rgba(70, 50, 130, 0.55) 0%, transparent 52%),
    linear-gradient(145deg, rgba(26, 30, 46, 0.94), rgba(10, 12, 20, 0.97));
  border: 1px solid rgba(255, 255, 255, calc(0.14 + var(--lumen-refraction) * 0.25));
}

.lumen-specular {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: linear-gradient(
    125deg,
    rgba(255, 255, 255, calc(0.22 + var(--lumen-illum) * 0.2)) 0%,
    transparent 38%,
    transparent 62%,
    rgba(180, 210, 255, calc(0.08 + var(--lumen-refraction) * 0.12)) 100%
  );
  mix-blend-mode: screen;
  transform: translate3d(var(--lumen-parallax-x), var(--lumen-parallax-y), 2px);
  pointer-events: none;
}

.lumen-iridescence {
  position: absolute;
  inset: -22%;
  background: conic-gradient(
    from 120deg,
    rgba(120, 200, 255, 0.0),
    rgba(160, 140, 255, calc(0.28 + var(--lumen-glow) * 0.2)),
    rgba(255, 180, 220, 0.22),
    rgba(140, 220, 200, 0.28),
    rgba(120, 200, 255, 0.0)
  );
  mix-blend-mode: screen;
  opacity: calc(0.45 + var(--lumen-proximity) * 0.25);
  animation: lumen-iridescence-spin 10s linear infinite;
  transform: translate3d(calc(var(--lumen-parallax-x) * -0.5), calc(var(--lumen-parallax-y) * -0.5), 1px);
}

.lumen-energy {
  position: absolute;
  inset: 28%;
  border-radius: 50%;
  background: radial-gradient(
    circle,
    rgba(235, 245, 255, calc(0.85 + var(--lumen-illum) * 0.15)) 0%,
    rgba(160, 190, 255, calc(0.3 + var(--lumen-illum) * 0.25)) 42%,
    transparent 72%
  );
  filter: blur(1px);
  opacity: calc(0.85 + var(--lumen-attention) * 0.15);
  transform: translate3d(var(--lumen-parallax-x), var(--lumen-parallax-y), 4px) scale(calc(0.92 + var(--lumen-illum) * 0.18));
}

.lumen-rim {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, calc(0.1 + var(--lumen-refraction) * 0.35)),
    inset 0 0 12px rgba(180, 210, 255, calc(var(--lumen-refraction) * 0.25));
  pointer-events: none;
}

.lumen-entity[data-lumen-travel-phase="COMPRESS"] .lumen-core {
  filter: saturate(1.15) brightness(1.08);
}
.lumen-entity[data-lumen-travel-phase="TRAVEL"] .lumen-core {
  filter: saturate(1.35) brightness(1.18);
  border-radius: 42%;
}
.lumen-entity[data-lumen-travel-phase="TRAVEL"] .lumen-energy {
  inset: 22%;
}
.lumen-entity[data-lumen-travel-phase="DECELERATE"] .lumen-core,
.lumen-entity[data-lumen-travel-phase="REFORM"] .lumen-core {
  filter: saturate(1.2) brightness(1.1);
}

.lumen-state-IDLE .lumen-energy {
  animation: lumen-breathe 3.6s ease-in-out infinite;
}
.lumen-state-LISTENING .lumen-aura {
  animation: lumen-pulse-soft 1.8s ease-in-out infinite;
}
.lumen-state-THINKING .lumen-iridescence {
  animation-duration: 3.2s;
  opacity: 0.75;
}
.lumen-state-MOVING .lumen-aura {
  opacity: 1;
}
.lumen-state-RESEARCHING .lumen-core {
  animation: lumen-scan 2.4s ease-in-out infinite;
}
.lumen-state-WRITING .lumen-energy {
  animation: lumen-flow 1.6s ease-in-out infinite;
}
.lumen-state-VISUAL .lumen-iridescence {
  animation-duration: 2.4s;
  opacity: 0.85;
}
.lumen-state-AUDITING .lumen-glass {
  box-shadow: inset 0 0 0 1px rgba(200, 220, 255, 0.45);
}
.lumen-state-SUCCESS .lumen-energy {
  background: radial-gradient(circle, rgba(200, 255, 230, 0.95) 0%, rgba(120, 220, 180, 0.35) 45%, transparent 70%);
  animation: lumen-bloom 1.2s ease-out 1;
}
.lumen-state-WARNING .lumen-aura {
  background: radial-gradient(circle, rgba(255, 200, 120, 0.35) 0%, transparent 70%);
  animation: lumen-warn 1.4s ease-in-out infinite;
}
.lumen-state-ERROR .lumen-aura {
  background: radial-gradient(circle, rgba(255, 120, 120, 0.4) 0%, transparent 70%);
  animation: lumen-error 0.9s ease-in-out infinite;
}

@keyframes lumen-breathe {
  0%, 100% { transform: translate3d(var(--lumen-parallax-x), var(--lumen-parallax-y), 4px) scale(0.92); opacity: 0.75; }
  50% { transform: translate3d(var(--lumen-parallax-x), var(--lumen-parallax-y), 4px) scale(1.08); opacity: 1; }
}
@keyframes lumen-pulse-soft {
  0%, 100% { transform: translateZ(-8px) scale(1); opacity: 0.7; }
  50% { transform: translateZ(-8px) scale(1.18); opacity: 1; }
}
@keyframes lumen-iridescence-spin {
  to { transform: translate3d(calc(var(--lumen-parallax-x) * -0.5), calc(var(--lumen-parallax-y) * -0.5), 1px) rotate(360deg); }
}
@keyframes lumen-scan {
  0%, 100% { filter: brightness(1); }
  50% { filter: brightness(1.18); }
}
@keyframes lumen-flow {
  0%, 100% { transform: translate3d(var(--lumen-parallax-x), calc(var(--lumen-parallax-y) + 1px), 4px) scale(0.9); }
  50% { transform: translate3d(var(--lumen-parallax-x), calc(var(--lumen-parallax-y) - 1px), 4px) scale(1.1); }
}
@keyframes lumen-bloom {
  0% { transform: translate3d(var(--lumen-parallax-x), var(--lumen-parallax-y), 4px) scale(0.7); opacity: 0.4; }
  60% { transform: translate3d(var(--lumen-parallax-x), var(--lumen-parallax-y), 4px) scale(1.25); opacity: 1; }
  100% { transform: translate3d(var(--lumen-parallax-x), var(--lumen-parallax-y), 4px) scale(1); opacity: 0.9; }
}
@keyframes lumen-warn {
  0%, 100% { opacity: 0.55; }
  50% { opacity: 1; }
}
@keyframes lumen-error {
  0%, 100% { opacity: 0.45; transform: translateZ(-8px) scale(1); }
  50% { opacity: 1; transform: translateZ(-8px) scale(1.12); }
}

/* Interaction panel */
.lumen-panel {
  position: fixed;
  width: min(340px, calc(100vw - 24px));
  pointer-events: auto;
  z-index: 4;
  border-radius: 18px;
  background:
    linear-gradient(165deg, rgba(255, 255, 255, 0.92), rgba(247, 245, 240, 0.96));
  border: 1px solid rgba(0, 0, 0, 0.08);
  box-shadow:
    0 18px 48px rgba(20, 24, 40, 0.14),
    0 1px 0 rgba(255, 255, 255, 0.8) inset;
  backdrop-filter: blur(14px);
  overflow: hidden;
  opacity: 0;
  transform: translateY(6px) scale(0.98);
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.lumen-panel--open {
  opacity: 1;
  transform: translateY(0) scale(1);
}

.lumen-panel-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 14px 10px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.06);
}

.lumen-panel-title {
  margin: 0;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.18em;
  color: #1a1a1a;
}

.lumen-panel-subtitle {
  margin: 2px 0 0;
  font-size: 12px;
  color: #6b7280;
}

.lumen-panel-close {
  width: 28px;
  height: 28px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: #6b7280;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
}
.lumen-panel-close:hover {
  background: rgba(0, 0, 0, 0.05);
  color: #1a1a1a;
}

.lumen-panel-body {
  padding: 12px 14px 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-height: min(72vh, 560px);
  overflow-y: auto;
}

/* Project progress */
.lumen-progress-root {
  margin: 0;
}
.lumen-progress {
  border: 1px solid rgba(0, 0, 0, 0.06);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.55);
  padding: 10px 11px 8px;
}
.lumen-progress-eyebrow {
  margin: 0;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #6b7280;
}
.lumen-progress-title {
  margin: 4px 0 8px;
  font-size: 12px;
  font-weight: 600;
  color: #1a1a1a;
  line-height: 1.3;
}
.lumen-progress-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.lumen-progress-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  padding: 4px 6px;
  border-radius: 8px;
  font-size: 11px;
}
.lumen-progress-row--current {
  background: rgba(120, 140, 200, 0.1);
}
.lumen-progress-label {
  color: #374151;
  font-weight: 500;
}
.lumen-progress-value {
  color: #6b7280;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.lumen-progress-row--complete .lumen-progress-value {
  color: #1d9e75;
  font-weight: 600;
}
.lumen-progress-row--active .lumen-progress-value {
  color: #3c3489;
  font-weight: 600;
}
.lumen-progress-row--warning .lumen-progress-value,
.lumen-progress-row--blocked .lumen-progress-value {
  color: #ba7517;
  font-weight: 600;
}
.lumen-progress-meta {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid rgba(0, 0, 0, 0.06);
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.lumen-progress-meta p {
  margin: 0;
  font-size: 11px;
  color: #1a1a1a;
  line-height: 1.35;
}
.lumen-progress-meta span {
  display: inline-block;
  min-width: 72px;
  color: #6b7280;
  font-weight: 600;
  margin-right: 6px;
}
.lumen-progress-warnings {
  margin-top: 6px;
  padding: 6px 8px;
  border-radius: 8px;
  background: rgba(186, 117, 23, 0.1);
  color: #633806;
  font-size: 11px;
}
.lumen-progress-warnings p { margin: 0; }
.lumen-progress-mock-note {
  margin: 6px 0 0;
  font-size: 9px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #9ca3af;
}
.lumen-progress-empty-msg {
  margin: 4px 0 0;
  font-size: 12px;
  color: #6b7280;
}

.lumen-msg-text {
  margin: 0;
  font-size: 13px;
  line-height: 1.45;
  color: #1a1a1a;
}

.lumen-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.lumen-suggestion {
  border: 1px solid rgba(0, 0, 0, 0.08);
  background: rgba(255, 255, 255, 0.7);
  color: #1a1a1a;
  font-size: 11px;
  font-weight: 500;
  padding: 5px 9px;
  border-radius: 999px;
  cursor: pointer;
}
.lumen-suggestion:hover {
  border-color: rgba(100, 120, 200, 0.35);
  background: rgba(230, 235, 255, 0.8);
}

.lumen-guide-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.lumen-guide-label {
  font-size: 12px;
  font-weight: 600;
  color: #1a1a1a;
}

.lumen-guide-toggle {
  width: 42px;
  height: 24px;
  border-radius: 999px;
  border: none;
  background: rgba(0, 0, 0, 0.12);
  position: relative;
  cursor: pointer;
  transition: background 0.2s ease;
}
.lumen-guide-toggle--on {
  background: #4a5568;
}
.lumen-guide-knob {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2);
  transition: transform 0.2s ease;
}
.lumen-guide-toggle--on .lumen-guide-knob {
  transform: translateX(18px);
}

.lumen-input-form {
  display: flex;
  gap: 8px;
  align-items: center;
}
.lumen-input-form input {
  flex: 1;
  min-width: 0;
  border: 1px solid rgba(0, 0, 0, 0.08);
  background: rgba(255, 255, 255, 0.85);
  border-radius: 12px;
  padding: 8px 10px;
  font-size: 12px;
  color: #1a1a1a;
}
.lumen-input-form input:focus {
  outline: none;
  border-color: rgba(100, 120, 200, 0.45);
  box-shadow: 0 0 0 3px rgba(140, 160, 220, 0.18);
}
.lumen-input-send {
  width: 34px;
  height: 34px;
  border: none;
  border-radius: 10px;
  background: #1f2430;
  color: #fff;
  cursor: pointer;
  font-size: 14px;
}

/* Demo bar */
.lumen-demo-bar {
  position: fixed;
  left: 12px;
  bottom: 12px;
  z-index: 80;
  max-width: min(560px, calc(100vw - 24px));
  padding: 10px 12px;
  border-radius: 14px;
  background: rgba(20, 24, 36, 0.92);
  color: #e8ecf5;
  font-size: 11px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
  pointer-events: auto;
}
.lumen-demo-title {
  font-weight: 700;
  letter-spacing: 0.04em;
  margin-bottom: 8px;
}
.lumen-demo-title span {
  font-weight: 500;
  opacity: 0.65;
}
.lumen-demo-group {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 6px;
}
.lumen-demo-bar button {
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.06);
  color: #e8ecf5;
  border-radius: 8px;
  padding: 4px 8px;
  font-size: 10px;
  cursor: pointer;
}
.lumen-demo-bar button:hover {
  background: rgba(255, 255, 255, 0.14);
}
.lumen-demo-hide {
  margin-top: 2px;
  opacity: 0.75;
}
.lumen-demo-showcase {
  width: 100%;
  border-color: rgba(180, 210, 255, 0.45) !important;
  background: rgba(100, 140, 255, 0.22) !important;
  font-weight: 600 !important;
  letter-spacing: 0.02em;
  padding: 7px 10px !important;
}
.lumen-demo-showcase:disabled {
  opacity: 0.7;
  cursor: wait;
}

/* Collapsed restore tab — only when ?lumenDemo=1 panel was hidden */
.lumen-demo-restore {
  position: fixed;
  left: 12px;
  bottom: 12px;
  z-index: 80;
  pointer-events: auto;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(20, 24, 36, 0.88);
  color: #dce3f5;
  border-radius: 999px;
  padding: 7px 12px;
  font-size: 10px;
  font-weight: 650;
  letter-spacing: 0.06em;
  cursor: pointer;
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.22);
}
.lumen-demo-restore:hover {
  background: rgba(40, 48, 70, 0.94);
}



/* ===== Phase 2.1 — VISIBLE morph shell (do not put morph on .lumen-core alone) ===== */
.lumen-depth-layer,
.lumen-morph-shell {
  overflow: visible;
}

.lumen-morph-shell {
  position: absolute;
  inset: 0;
  transform-origin: 50% 50%;
  transform:
    rotate(calc(var(--lumen-guide-angle, 0deg) + var(--lumen-twist) * 1deg))
    scaleX(calc(1 + var(--lumen-elongate) * 0.95 + var(--lumen-asym) * 0.25))
    scaleY(calc(1 - var(--lumen-elongate) * 0.42 - var(--lumen-asym) * 0.1));
  transition:
    transform 0.55s cubic-bezier(0.22, 1, 0.36, 1),
    border-radius 0.55s ease,
    filter 0.4s ease;
  will-change: transform;
}

.lumen-core {
  border-radius: calc(50% - var(--lumen-elongate) * 18% - var(--lumen-asym) * 10%);
  transition: border-radius 0.55s ease, filter 0.4s ease, box-shadow 0.4s ease;
}

/* State CSS fallbacks — visible even if JS morph vars lag */
.lumen-state-IDLE {
  --lumen-elongate: 0;
  --lumen-point: 0;
  --lumen-rings: 0;
  --lumen-twist: 0;
  --lumen-asym: 0;
  --lumen-energy-level: 0.35;
}
.lumen-state-THINKING {
  --lumen-elongate: 0.62;
  --lumen-twist: 8;
  --lumen-asym: 0.18;
  --lumen-energy-level: 0.85;
  --lumen-state-glow: 0.7;
}
.lumen-state-THINKING .lumen-morph-shell {
  animation: lumen-think-morph 2.4s ease-in-out infinite;
}
.lumen-state-THINKING .lumen-iridescence {
  animation-duration: 2.2s;
  opacity: 0.9;
}
.lumen-state-THINKING .lumen-volume {
  animation: lumen-core-spin 3.2s linear infinite;
}

.lumen-state-WORKING {
  --lumen-elongate: 0.4;
  --lumen-point: 0.25;
  --lumen-asym: 0.5;
  --lumen-twist: -14;
  --lumen-energy-level: 1;
  --lumen-state-glow: 0.85;
}
.lumen-state-WORKING .lumen-morph-shell {
  animation: lumen-work-morph 1.6s ease-in-out infinite;
}
.lumen-state-WORKING .lumen-particles {
  opacity: 1;
}
.lumen-state-WORKING .lumen-particles i {
  animation-duration: 2.2s;
}

.lumen-state-AUDITING {
  --lumen-elongate: 0.05;
  --lumen-rings: 1;
  --lumen-energy-level: 0.8;
  --lumen-state-glow: 0.75;
}
.lumen-state-AUDITING .lumen-audit-ring {
  opacity: 1 !important;
}
.lumen-state-AUDITING .lumen-sweep {
  opacity: 0.85;
  animation: lumen-audit-sweep 1.8s linear infinite;
}

.lumen-state-GUIDE {
  --lumen-elongate: 0.9;
  --lumen-point: 1;
  --lumen-asym: 0.3;
  --lumen-energy-level: 0.9;
}
.lumen-state-GUIDE .lumen-guide-tail,
.lumen-state-GUIDE .lumen-guide-tip {
  opacity: 1;
}
.lumen-state-SUCCESS {
  --lumen-elongate: 0;
  --lumen-asym: 0;
  --lumen-energy-level: 1;
  --lumen-state-glow: 1;
}
.lumen-state-SUCCESS .lumen-morph-shell {
  animation: lumen-success-bloom 1.4s ease-out 1;
}
.lumen-state-SUCCESS .lumen-aura {
  animation: lumen-pulse-soft 0.7s ease-out 2;
}

.lumen-state-ATTENTION {
  --lumen-elongate: 0.45;
  --lumen-point: 0.5;
  --lumen-asym: 0.25;
}
.lumen-state-ATTENTION .lumen-morph-shell {
  animation: lumen-attention-pulse 1.3s ease-in-out infinite;
}

.lumen-state-ERROR {
  --lumen-elongate: 0.3;
  --lumen-asym: 0.6;
  --lumen-twist: 20;
}
.lumen-state-ERROR .lumen-morph-shell {
  animation: lumen-error-jitter 0.55s steps(2) infinite;
}

.lumen-volume {
  position: absolute;
  inset: 16%;
  border-radius: 50%;
  background:
    radial-gradient(circle at 38% 32%, rgba(255,255,255,0.7) 0%, transparent 38%),
    radial-gradient(circle at 58% 62%, rgba(130,170,255,0.55) 0%, rgba(40,30,90,0.55) 55%, transparent 72%);
  filter: blur(0.4px);
  opacity: calc(0.6 + var(--lumen-energy-level) * 0.4);
  transform: translate3d(var(--lumen-parallax-x), var(--lumen-parallax-y), 3px);
  pointer-events: none;
}

.lumen-particles {
  position: absolute;
  inset: 10%;
  pointer-events: none;
  opacity: calc(0.2 + var(--lumen-energy-level) * 0.7);
}
.lumen-particles i {
  position: absolute;
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: rgba(230, 240, 255, 0.95);
  box-shadow: 0 0 8px rgba(180, 210, 255, 0.95);
  animation: lumen-particle-drift 3.6s ease-in-out infinite;
}
.lumen-particles i:nth-child(1) { left: 18%; top: 28%; }
.lumen-particles i:nth-child(2) { left: 72%; top: 22%; animation-delay: 0.4s; }
.lumen-particles i:nth-child(3) { left: 58%; top: 68%; animation-delay: 0.8s; }
.lumen-particles i:nth-child(4) { left: 28%; top: 72%; animation-delay: 1.2s; }
.lumen-particles i:nth-child(5) { left: 48%; top: 38%; animation-delay: 1.6s; }
.lumen-particles i:nth-child(6) { left: 64%; top: 50%; animation-delay: 2s; }
.lumen-particles i:nth-child(7) { left: 40%; top: 55%; animation-delay: 2.3s; }
.lumen-particles i:nth-child(8) { left: 22%; top: 48%; animation-delay: 2.7s; }

@keyframes lumen-particle-drift {
  0%, 100% { transform: translate3d(0, 0, 5px) scale(0.6); opacity: 0.25; }
  50% { transform: translate3d(6px, -10px, 5px) scale(1.35); opacity: 1; }
}

.lumen-audit-ring {
  position: absolute;
  inset: -18px;
  border-radius: 50%;
  border: 2px solid rgba(200, 225, 255, 0.75);
  opacity: 0;
  pointer-events: none;
  box-shadow:
    0 0 16px rgba(140, 180, 255, 0.4),
    inset 0 0 12px rgba(180, 210, 255, 0.15);
  transform: scale(0.92) rotateX(58deg);
  transition: opacity 0.35s ease;
}
.lumen-audit-ring--b {
  inset: -28px;
  border-color: rgba(150, 170, 255, 0.55);
  animation: lumen-ring-scan 2.8s linear infinite reverse;
}
.lumen-audit-ring--a {
  animation: lumen-ring-scan 2.2s linear infinite;
}
.lumen-audit-ring--c {
  inset: -8px;
  border-style: dashed;
  border-width: 1.5px;
  border-color: rgba(230, 240, 255, 0.65);
  animation: lumen-ring-scan 3.4s linear infinite;
}
@keyframes lumen-ring-scan {
  to { transform: scale(1.08) rotateX(62deg) rotateZ(360deg); }
}

.lumen-sweep {
  position: absolute;
  inset: -5%;
  border-radius: 50%;
  background: conic-gradient(from 0deg, transparent 0%, rgba(200,230,255,0.55) 8%, transparent 18%);
  opacity: 0;
  mix-blend-mode: screen;
  pointer-events: none;
}
@keyframes lumen-audit-sweep {
  to { transform: rotate(360deg); }
}

.lumen-guide-tail {
  position: absolute;
  left: 55%;
  top: 42%;
  width: calc(18px + var(--lumen-point) * 28px);
  height: calc(8px + var(--lumen-point) * 6px);
  border-radius: 999px;
  background: linear-gradient(90deg, rgba(180,210,255,0.55), rgba(220,240,255,0.05));
  opacity: calc(var(--lumen-point) * 0.95);
  filter: blur(0.4px);
  transform: translateY(-50%);
  pointer-events: none;
  transition: width 0.45s ease, opacity 0.35s ease;
}
.lumen-guide-tip {
  position: absolute;
  right: -10px;
  top: 50%;
  width: 12px;
  height: 12px;
  margin-top: -6px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(245,250,255,0.95), rgba(140,180,255,0.15));
  opacity: calc(var(--lumen-point) * 0.95);
  transform: translateX(calc(var(--lumen-point) * 14px));
  box-shadow: 0 0 14px rgba(180, 210, 255, 0.65);
  pointer-events: none;
  transition: opacity 0.35s ease, transform 0.45s ease;
}

@keyframes lumen-think-morph {
  0%, 100% { transform: rotate(4deg) scaleX(1.55) scaleY(0.72); }
  50% { transform: rotate(-6deg) scaleX(1.75) scaleY(0.62); }
}
@keyframes lumen-work-morph {
  0%, 100% { transform: rotate(-10deg) scaleX(1.35) scaleY(0.85) skewX(-4deg); }
  50% { transform: rotate(8deg) scaleX(1.55) scaleY(0.7) skewX(6deg); }
}
@keyframes lumen-attention-pulse {
  0%, 100% { transform: scaleX(1.35) scaleY(0.85); }
  50% { transform: scaleX(1.55) scaleY(0.75) translateX(4px); }
}
@keyframes lumen-error-jitter {
  0% { transform: rotate(-8deg) scaleX(1.2) scaleY(0.9) translate(0,0); }
  50% { transform: rotate(10deg) scaleX(1.35) scaleY(0.75) translate(2px, -2px); }
  100% { transform: rotate(-6deg) scaleX(1.15) scaleY(0.95) translate(-1px, 1px); }
}
@keyframes lumen-success-bloom {
  0% { transform: scale(0.85); filter: brightness(1); }
  40% { transform: scale(1.55); filter: brightness(1.35); }
  70% { transform: scale(0.92); filter: brightness(1.1); }
  100% { transform: scale(1); filter: brightness(1); }
}
@keyframes lumen-core-spin {
  to { transform: translate3d(var(--lumen-parallax-x), var(--lumen-parallax-y), 3px) rotate(360deg); }
}

.lumen-projected-shadow {
  width: 78%;
  height: 34%;
  filter: blur(calc(var(--lumen-shadow-blur) * 0.45));
  opacity: calc(0.85 + var(--lumen-attention) * 0.2);
}

/* Context chip — emerges from Lumen, not a comic bubble */
.lumen-context-chip {
  position: fixed;
  z-index: 5;
  width: min(240px, calc(100vw - 24px));
  padding: 10px 28px 10px 12px;
  border-radius: 14px;
  pointer-events: auto;
  background: linear-gradient(155deg, rgba(255,255,255,0.88), rgba(247,245,240,0.92));
  border: 1px solid rgba(0,0,0,0.07);
  box-shadow:
    0 12px 32px rgba(20, 24, 40, 0.12),
    0 0 0 1px rgba(255,255,255,0.5) inset;
  backdrop-filter: blur(12px);
  opacity: 0;
  transform: translateY(6px) scale(0.96);
  transition: opacity 0.22s ease, transform 0.22s ease;
}
.lumen-context-chip--visible {
  opacity: 1;
  transform: translateY(0) scale(1);
}
.lumen-context-chip-text {
  margin: 0;
  font-size: 12px;
  line-height: 1.4;
  color: #1a1a1a;
}
.lumen-context-chip-dismiss {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 22px;
  height: 22px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: #6b7280;
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
}
.lumen-context-chip-dismiss:hover {
  background: rgba(0,0,0,0.05);
  color: #1a1a1a;
}

@media (prefers-reduced-motion: reduce) {
  .lumen-particles i,
  .lumen-audit-ring--a,
  .lumen-audit-ring--b,
  .lumen-audit-ring--c,
  .lumen-state-THINKING .lumen-morph-shell,
  .lumen-state-WORKING .lumen-morph-shell,
  .lumen-state-ATTENTION .lumen-morph-shell,
  .lumen-state-ERROR .lumen-morph-shell,
  .lumen-state-SUCCESS .lumen-morph-shell,
  .lumen-state-AUDITING .lumen-sweep {
    animation: none !important;
  }
  .lumen-context-chip {
    transition: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .lumen-iridescence,
  .lumen-state-IDLE .lumen-energy,
  .lumen-state-LISTENING .lumen-aura,
  .lumen-state-RESEARCHING .lumen-core,
  .lumen-state-WRITING .lumen-energy,
  .lumen-state-SUCCESS .lumen-energy,
  .lumen-state-WARNING .lumen-aura,
  .lumen-state-ERROR .lumen-aura {
    animation: none !important;
  }
  .lumen-panel {
    transition: none;
  }
  .lumen-entity {
    transition: none !important;
  }
  .lumen-depth-layer,
  .lumen-projected-shadow,
  .lumen-specular {
    transition: none !important;
  }
}

/* ── LUMEN Chat — right-side assistant panel ─────────────────────────── */
.lumen-chat {
  position: fixed;
  z-index: 80;
  top: 72px;
  right: 16px;
  bottom: 16px;
  width: min(384px, calc(100vw - 24px));
  max-height: none;
  height: auto;
  display: flex;
  flex-direction: column;
  pointer-events: auto;
  background:
    linear-gradient(165deg, rgba(255,252,247,0.98), rgba(246,243,235,0.96));
  border: 1px solid rgba(116, 103, 198, 0.18);
  border-radius: 16px;
  box-shadow:
    0 12px 36px rgba(40, 32, 24, 0.10),
    0 1px 0 rgba(255,255,255,0.7) inset;
  backdrop-filter: blur(10px);
  overflow: hidden;
  font-family: Inter, system-ui, sans-serif;
  color: #2c281f;
  transform: translateX(12px);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.22s ease, transform 0.22s ease, visibility 0.22s;
}
.lumen-chat[hidden] { display: none !important; }
.lumen-chat.lumen-chat--open:not([hidden]) {
  opacity: 1;
  visibility: visible;
  transform: translateX(0);
}
.lumen-chat-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 14px 6px;
  flex-shrink: 0;
}
.lumen-chat-title {
  margin: 0;
  font-family: "Instrument Serif", Georgia, serif;
  font-size: 1.35rem;
  letter-spacing: 0.02em;
  color: #2a2438;
  line-height: 1.1;
}
.lumen-chat-subtitle {
  margin: 2px 0 0;
  font-size: 0.68rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #7467C6;
  font-weight: 600;
}
.lumen-chat-header-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}
.lumen-chat-close,
.lumen-chat-cancel {
  border: none;
  background: transparent;
  cursor: pointer;
  color: #6b6458;
  font-size: 1.1rem;
  line-height: 1;
  padding: 4px 8px;
  border-radius: 8px;
}
.lumen-chat-cancel {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: #8a4b3a;
}
.lumen-chat-close:hover,
.lumen-chat-cancel:hover { background: rgba(0,0,0,0.05); }
.lumen-chat-status {
  padding: 0 14px 8px;
  font-size: 0.76rem;
  color: #7467C6;
  font-weight: 500;
  flex-shrink: 0;
}
.lumen-chat-messages {
  flex: 1 1 auto;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 4px 14px 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 0;
}
.lumen-chat-msg { display: flex; }
.lumen-chat-msg--user { justify-content: flex-end; }
.lumen-chat-msg--lumen { justify-content: flex-start; }
.lumen-chat-bubble {
  max-width: 92%;
  padding: 9px 12px;
  border-radius: 12px;
  font-size: 0.86rem;
  line-height: 1.4;
  white-space: pre-wrap;
  word-break: break-word;
}
.lumen-chat-msg--user .lumen-chat-bubble {
  background: #7467C6;
  color: #fff;
  border-bottom-right-radius: 5px;
}
.lumen-chat-msg--lumen .lumen-chat-bubble {
  background: rgba(255,255,255,0.78);
  border: 1px solid rgba(44,40,31,0.08);
  border-bottom-left-radius: 5px;
  color: #2c281f;
}
.lumen-chat-starters {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 0 14px 10px;
  flex-shrink: 0;
}
.lumen-chat-starters button {
  border: 1px solid rgba(116,103,198,0.28);
  background: rgba(255,255,255,0.55);
  color: #4a4460;
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 0.72rem;
  cursor: pointer;
  text-align: left;
}
.lumen-chat-starters button:hover {
  border-color: #7467C6;
  color: #7467C6;
}
.lumen-chat-form {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 10px 12px 12px;
  border-top: 1px solid rgba(44,40,31,0.06);
  background: rgba(255,255,255,0.45);
  flex-shrink: 0;
}
.lumen-chat-form textarea {
  flex: 1;
  resize: none;
  border: 1px solid rgba(44,40,31,0.1);
  border-radius: 12px;
  padding: 10px 12px;
  font: inherit;
  font-size: 0.88rem;
  background: #fff;
  color: #2c281f;
  min-height: 42px;
  max-height: 110px;
}
.lumen-chat-form textarea:focus {
  outline: none;
  border-color: rgba(116,103,198,0.55);
  box-shadow: 0 0 0 3px rgba(116,103,198,0.12);
}
.lumen-chat-send {
  width: 38px;
  height: 38px;
  border: none;
  border-radius: 12px;
  background: #7467C6;
  color: #fff;
  font-size: 1rem;
  cursor: pointer;
  flex-shrink: 0;
}
.lumen-chat-send:hover { filter: brightness(1.05); }

.lumen-chat-bubble--approval {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 100%;
}
.lumen-approval-title {
  margin: 0;
  font-weight: 600;
  font-size: 0.95em;
}
.lumen-approval-reason {
  margin: 0;
  opacity: 0.85;
  font-size: 0.9em;
  line-height: 1.35;
}
.lumen-approval-actions {
  display: flex;
  gap: 8px;
  margin-top: 4px;
}
.lumen-approval-btn {
  flex: 1;
  border: 1px solid rgba(0,0,0,0.12);
  background: rgba(255,255,255,0.7);
  color: inherit;
  font: inherit;
  font-size: 0.85em;
  padding: 8px 10px;
  border-radius: 8px;
  cursor: pointer;
}
.lumen-approval-btn:hover:not(:disabled) {
  background: rgba(0,0,0,0.04);
}
.lumen-approval-btn--yes {
  border-color: rgba(34, 120, 80, 0.35);
  background: rgba(34, 120, 80, 0.1);
}
.lumen-approval-btn--no {
  border-color: rgba(140, 50, 50, 0.25);
}
.lumen-approval-btn:disabled {
  opacity: 0.5;
  cursor: default;
}

@media (max-width: 900px) {
  .lumen-chat {
    width: min(340px, calc(100vw - 20px));
    top: 64px;
    right: 10px;
    bottom: 12px;
  }
}

@media (max-width: 640px) {
  .lumen-chat {
    top: 56px;
    left: 8px;
    right: 8px;
    bottom: 8px;
    width: auto;
    border-radius: 14px;
  }
}

/* Language switcher (header) — kept here so it applies even before a CSS rebuild */
.bf-lang-switch {
  display: flex;
  align-items: center;
  gap: 2px;
  flex-shrink: 0;
  font-family: inherit;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  color: var(--text-muted, #8a8478);
  user-select: none;
}
.bf-lang-sep { opacity: 0.45; padding: 0 1px; }
.bf-lang-btn {
  background: none;
  border: none;
  padding: 2px 5px;
  cursor: pointer;
  color: inherit;
  font: inherit;
  letter-spacing: inherit;
  border-radius: 4px;
  line-height: 1.2;
}
.bf-lang-btn:hover { color: var(--text-primary, #2c281f); }
.bf-lang-btn[aria-pressed="true"] {
  color: var(--text-primary, #2c281f);
}
