:root {
  --bg:              #02050E;
  --bg-elevated:     #070C22;
  --bg-plate:        #0A1230;
  --bg-plate-edge:   #121C44;

  --rule:            rgba(74, 111, 255, 0.10);
  --rule-strong:     rgba(74, 111, 255, 0.22);

  --core-deep:       #0F1A4A;
  --core-mid:        #2B1B6E;

  --glow-blue:       #4A6FFF;
  --glow-violet:     #B967DB;
  --glow-cyan:       #6FD3FF;

  --accent-active:   #6FD3FF;
  --accent-think:    #B967DB;
  --accent-warn:     #FF4A6F;
  --accent-ok:       #59E5A0;

  --text-primary:    #D6DEFF;
  --text-secondary:  #6B7BA8;
  --text-muted:      #3F4B73;

  --amplitude:       0;
  --elapsed-ms:      0;

  --ease-monolith:   cubic-bezier(0.65, 0, 0.35, 1);
  --ease-soft:       cubic-bezier(0.4, 0, 0.2, 1);
  --ease-snap:       cubic-bezier(0.2, 0.8, 0.2, 1);

  --font-display:    'Orbitron', 'Inter', system-ui, sans-serif;
  --font-body:       'Inter', system-ui, -apple-system, sans-serif;
  --font-mono:       'JetBrains Mono', ui-monospace, 'SF Mono', Menlo, monospace;

  --safe-top:        max(12px, env(safe-area-inset-top));
  --safe-bottom:     max(12px, env(safe-area-inset-bottom));
  --safe-left:       max(16px, env(safe-area-inset-left));
  --safe-right:      max(16px, env(safe-area-inset-right));
}

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  height: 100%;
  width: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  background: var(--bg);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-weight: 300;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
  touch-action: manipulation;
}

body {
  min-height: -webkit-fill-available;
  background:
    radial-gradient(ellipse 90vw 60vh at 50% 32%, rgba(43, 27, 110, 0.22) 0%, transparent 65%),
    radial-gradient(ellipse 120vw 80vh at 50% 110%, rgba(15, 26, 74, 0.30) 0%, transparent 60%),
    var(--bg);
}

/* The hairline diagonal field gives the deep blue some weave so it doesn't read flat on big iPad screens. */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    repeating-linear-gradient(
      135deg,
      transparent 0,
      transparent 3px,
      rgba(74, 111, 255, 0.012) 3px,
      rgba(74, 111, 255, 0.012) 4px
    );
  z-index: 0;
}

/* ═══════════════════ APP SHELL ═══════════════════ */

#app {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-rows: auto auto 1fr auto;
  grid-template-areas:
    "topbar"
    "presence"
    "crew"
    "activity";
  height: 100vh;
  height: 100dvh;
  width: 100%;
  padding:
    var(--safe-top)
    var(--safe-right)
    0
    var(--safe-left);
  gap: 0;
}

/* ═══════════════════ TOPBAR ═══════════════════ */

#topbar {
  grid-area: topbar;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 48px;
  padding: 0 4px;
  border-bottom: 1px solid var(--rule);
}

.brand {
  display: flex;
  align-items: baseline;
  gap: 0.85rem;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 0.78rem;
  letter-spacing: 0.42em;
  text-transform: uppercase;
  color: var(--text-primary);
}

.brand-mark {
  position: relative;
  display: inline-block;
  width: 8px;
  height: 8px;
  background: var(--glow-cyan);
  border-radius: 50%;
  box-shadow: 0 0 10px var(--glow-cyan), 0 0 22px rgba(111, 211, 255, 0.4);
  animation: brand-mark-breathe 3.6s ease-in-out infinite;
}

@keyframes brand-mark-breathe {
  0%, 100% { opacity: 0.55; transform: scale(0.85); }
  50%      { opacity: 1;    transform: scale(1.1);  }
}

.brand-meta {
  font-family: var(--font-mono);
  font-size: 0.62rem;
  font-weight: 400;
  letter-spacing: 0.18em;
  color: var(--text-muted);
  text-transform: uppercase;
}

.topbar-controls {
  display: flex;
  align-items: center;
  gap: 4px;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-family: var(--font-body);
  font-size: 1rem;
  cursor: pointer;
  border-radius: 4px;
  text-decoration: none;
  transition:
    color 0.25s var(--ease-soft),
    background 0.25s var(--ease-soft);
}

.icon-btn:hover,
.icon-btn:focus-visible {
  color: var(--text-primary);
  background: rgba(74, 111, 255, 0.08);
  outline: none;
}

.icon-btn:active {
  background: rgba(74, 111, 255, 0.18);
}

.icon-btn.active {
  color: #7ec8ff;
  background: rgba(74, 111, 255, 0.12);
}

/* ═══════════════════ PRESENCE — "Horizon" ═══════════════════ */
/*
   Replaces the orb. A horizon-line monolith.
   - .horizon-swell: the central luminous mass (analog to the orb's glow)
   - .horizon-line: the thin bright rule that anchors the visual
   - .horizon-bars: 16 vertical bars driven by --amplitude
   - .horizon-scan: a sweeping pulse that crosses on .thinking
*/

#presence {
  grid-area: presence;
  position: relative;
  height: 30vh;
  min-height: 220px;
  max-height: 320px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.horizon {
  --amp: var(--amplitude, 0);
  position: relative;
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
  overflow: hidden;
}

.horizon-swell {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 70vw;
  max-width: 540px;
  aspect-ratio: 1.6 / 1;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background:
    radial-gradient(
      ellipse at center,
      rgba(43, 27, 110, 0.85) 0%,
      rgba(15, 26, 74, 0.55) 25%,
      rgba(15, 26, 74, 0.18) 50%,
      transparent 75%
    );
  filter: blur(2px);
  opacity: 0.85;
  pointer-events: none;
  transition: opacity 0.6s var(--ease-monolith);
}

.horizon-line {
  position: absolute;
  left: 8%;
  right: 8%;
  top: 50%;
  height: 1px;
  background: linear-gradient(
    to right,
    transparent 0%,
    rgba(74, 111, 255, 0.25) 15%,
    rgba(111, 211, 255, 0.85) 50%,
    rgba(74, 111, 255, 0.25) 85%,
    transparent 100%
  );
  box-shadow:
    0 0 12px rgba(111, 211, 255, 0.4),
    0 0 28px rgba(74, 111, 255, 0.18);
  transform: translateY(-50%) scaleX(0.92);
  transform-origin: center;
  transition:
    opacity 0.4s var(--ease-monolith),
    box-shadow 0.4s var(--ease-monolith),
    transform 0.4s var(--ease-monolith);
}

.horizon-bars {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  align-items: center;
  gap: 4px;
  height: 60%;
  width: min(420px, 70vw);
  pointer-events: none;
  opacity: 0.0;
  transition: opacity 0.4s var(--ease-monolith);
}

.horizon-bar {
  flex: 1;
  height: 6%;
  min-height: 2px;
  background: linear-gradient(
    to top,
    rgba(74, 111, 255, 0.0) 0%,
    var(--glow-blue) 50%,
    var(--glow-cyan) 100%
  );
  border-radius: 1px;
  transform-origin: center;
  box-shadow: 0 0 6px rgba(111, 211, 255, 0.5);
  transition: transform 0.08s linear;
}

.horizon-scan {
  position: absolute;
  left: 0;
  top: 50%;
  width: 18%;
  height: 1px;
  background: linear-gradient(
    to right,
    transparent 0%,
    rgba(185, 103, 219, 0.85) 50%,
    transparent 100%
  );
  box-shadow: 0 0 18px rgba(185, 103, 219, 0.6);
  transform: translateY(-50%) translateX(-100%);
  opacity: 0;
  pointer-events: none;
}

/* state: boot — pre-tap, very dim, faint pulse on the line */
#presence.boot .horizon-line {
  opacity: 0.4;
  box-shadow: 0 0 6px rgba(74, 111, 255, 0.2);
  animation: line-boot 2.4s ease-in-out infinite;
}

#presence.boot .horizon-swell {
  opacity: 0.35;
}

@keyframes line-boot {
  0%, 100% { opacity: 0.35; transform: translateY(-50%) scaleX(0.85); }
  50%      { opacity: 0.7;  transform: translateY(-50%) scaleX(0.95); }
}

/* state: idle — slow breathing of the swell, line steady */
#presence.idle .horizon-swell {
  animation: swell-breathe 5.5s var(--ease-monolith) infinite;
}

@keyframes swell-breathe {
  0%, 100% { opacity: 0.55; transform: translate(-50%, -50%) scale(0.96); }
  50%      { opacity: 0.85; transform: translate(-50%, -50%) scale(1.04); }
}

/* state: listening — the line brightens and widens, cyan dominant */
#presence.listening .horizon-line {
  opacity: 1;
  transform: translateY(-50%) scaleX(1);
  background: linear-gradient(
    to right,
    transparent 0%,
    rgba(111, 211, 255, 0.5) 12%,
    rgba(111, 211, 255, 1) 50%,
    rgba(111, 211, 255, 0.5) 88%,
    transparent 100%
  );
  box-shadow:
    0 0 22px rgba(111, 211, 255, 0.7),
    0 0 60px rgba(111, 211, 255, 0.35),
    0 0 120px rgba(74, 111, 255, 0.18);
  animation: line-listen 1.8s var(--ease-monolith) infinite;
}

#presence.listening .horizon-swell {
  opacity: 0.7;
  background:
    radial-gradient(
      ellipse at center,
      rgba(43, 100, 180, 0.55) 0%,
      rgba(15, 26, 74, 0.35) 35%,
      transparent 70%
    );
}

@keyframes line-listen {
  0%, 100% { transform: translateY(-50%) scaleX(0.95); }
  50%      { transform: translateY(-50%) scaleX(1.02); }
}

/* state: thinking — violet swell pulses, scan-line crosses */
#presence.thinking .horizon-swell {
  opacity: 1;
  background:
    radial-gradient(
      ellipse at center,
      rgba(120, 60, 180, 0.7) 0%,
      rgba(43, 27, 110, 0.4) 35%,
      transparent 70%
    );
  animation: swell-think 3s var(--ease-monolith) infinite;
}

#presence.thinking .horizon-line {
  background: linear-gradient(
    to right,
    transparent 0%,
    rgba(185, 103, 219, 0.4) 15%,
    rgba(185, 103, 219, 0.95) 50%,
    rgba(185, 103, 219, 0.4) 85%,
    transparent 100%
  );
  box-shadow:
    0 0 16px rgba(185, 103, 219, 0.6),
    0 0 40px rgba(185, 103, 219, 0.25);
}

#presence.thinking .horizon-scan {
  opacity: 1;
  animation: scan-sweep 2.4s var(--ease-monolith) infinite;
}

@keyframes swell-think {
  0%, 100% { transform: translate(-50%, -50%) scale(0.98); opacity: 0.85; }
  50%      { transform: translate(-50%, -50%) scale(1.06); opacity: 1;    }
}

@keyframes scan-sweep {
  0%   { transform: translateY(-50%) translateX(-100%); opacity: 0; }
  10%  { opacity: 1; }
  90%  { opacity: 1; }
  100% { transform: translateY(-50%) translateX(560%); opacity: 0; }
}

/* state: speaking — bars activate, swell glows violet, line gains shimmer */
#presence.speaking .horizon-bars {
  opacity: 1;
}

#presence.speaking .horizon-bar {
  transform: scaleY(calc(0.6 + (var(--amp) * 6)));
}

/* nudge each bar with a subtle phase so they don't all snap together when --amplitude changes */
.horizon-bar:nth-child(1)  { transition-duration: 0.06s; }
.horizon-bar:nth-child(2)  { transition-duration: 0.07s; }
.horizon-bar:nth-child(3)  { transition-duration: 0.08s; }
.horizon-bar:nth-child(4)  { transition-duration: 0.09s; }
.horizon-bar:nth-child(5)  { transition-duration: 0.10s; }
.horizon-bar:nth-child(6)  { transition-duration: 0.09s; }
.horizon-bar:nth-child(7)  { transition-duration: 0.08s; }
.horizon-bar:nth-child(8)  { transition-duration: 0.07s; }
.horizon-bar:nth-child(9)  { transition-duration: 0.07s; }
.horizon-bar:nth-child(10) { transition-duration: 0.08s; }
.horizon-bar:nth-child(11) { transition-duration: 0.09s; }
.horizon-bar:nth-child(12) { transition-duration: 0.10s; }
.horizon-bar:nth-child(13) { transition-duration: 0.09s; }
.horizon-bar:nth-child(14) { transition-duration: 0.08s; }
.horizon-bar:nth-child(15) { transition-duration: 0.07s; }
.horizon-bar:nth-child(16) { transition-duration: 0.06s; }

#presence.speaking .horizon-line {
  opacity: 1;
  background: linear-gradient(
    to right,
    transparent 0%,
    rgba(185, 103, 219, 0.5) 15%,
    rgba(255, 200, 255, 1) 50%,
    rgba(185, 103, 219, 0.5) 85%,
    transparent 100%
  );
  box-shadow:
    0 0 calc(20px + (var(--amp) * 30px)) rgba(185, 103, 219, calc(0.5 + (var(--amp) * 0.4))),
    0 0 calc(60px + (var(--amp) * 80px)) rgba(185, 103, 219, calc(0.2 + (var(--amp) * 0.3)));
}

#presence.speaking .horizon-swell {
  opacity: calc(0.8 + (var(--amp) * 0.2));
  background:
    radial-gradient(
      ellipse at center,
      rgba(185, 103, 219, calc(0.6 + (var(--amp) * 0.3))) 0%,
      rgba(120, 60, 180, 0.4) 30%,
      transparent 70%
    );
}

/* state: error — flash red across the line, brief */
#presence.error .horizon-line {
  animation: line-error 0.7s var(--ease-monolith);
}

@keyframes line-error {
  0%   { box-shadow: 0 0 0   rgba(255, 74, 111, 0); }
  20%  {
    background: linear-gradient(to right, transparent, rgba(255, 74, 111, 1) 50%, transparent);
    box-shadow: 0 0 32px rgba(255, 74, 111, 0.85), 0 0 80px rgba(255, 74, 111, 0.4);
  }
  100% { box-shadow: 0 0 0   rgba(255, 74, 111, 0); }
}

/* ═══════════════════ CAPTION STRIP ═══════════════════ */
/*
   Lives between the horizon and the crew.
   Two lines: last user utterance + current Cortana response (streaming).
   Doubles as the "tap to wake" affordance pre-unlock.
*/

/* Caption is a fixed overlay above the transcript handle (Lens v8-hud spec). */
#caption {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(var(--safe-bottom) + 38px);
  z-index: 40;
  width: min(640px, calc(100vw - 32px));
  max-height: 22vh;
  padding: 10px 18px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  background: linear-gradient(180deg,
    rgba(7, 12, 34, 0.0) 0%,
    rgba(7, 12, 34, 0.78) 28%,
    rgba(7, 12, 34, 0.92) 100%);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid var(--rule);
  border-radius: 6px 6px 0 0;
  pointer-events: none;
  overflow: hidden;
}

#caption::before {
  content: '';
  position: absolute;
  inset: 0 0 auto 0;
  height: 18px;
  background: linear-gradient(to bottom, rgba(7,12,34,0.92), transparent);
  pointer-events: none;
}

.caption-line {
  font-family: var(--font-body);
  font-size: 0.92rem;
  font-weight: 300;
  line-height: 1.45;
  letter-spacing: 0.02em;
  text-align: center;
  max-width: 100%;
  opacity: 0;
  transform: translateY(4px);
  transition:
    opacity 0.4s var(--ease-soft),
    transform 0.4s var(--ease-soft);
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.caption-line.caption-user {
  -webkit-line-clamp: 1;
}

.caption-line:not(.caption-user) {
  -webkit-line-clamp: 2;
}

.caption-line.visible {
  opacity: 1;
  transform: translateY(0);
}

.caption-user {
  color: var(--text-secondary);
  font-style: italic;
  letter-spacing: 0.04em;
}

.caption-user::before {
  content: '“';
  margin-right: 0.15em;
  opacity: 0.5;
}

.caption-user::after {
  content: '”';
  margin-left: 0.15em;
  opacity: 0.5;
}

.caption-cortana {
  color: var(--text-primary);
  font-weight: 400;
}

.caption-hint {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 0.72rem;
  letter-spacing: 0.45em;
  text-transform: uppercase;
  color: var(--text-muted);
  animation: hint-pulse 3.2s ease-in-out infinite;
}

@keyframes hint-pulse {
  0%, 100% { opacity: 0.45; }
  50%      { opacity: 0.95; }
}

.caption-hint.hidden {
  display: none;
}

/* ═══════════════════ CREW ═══════════════════ */

#crew {
  grid-area: crew;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 16px 0 12px;
  min-height: 0;
  overflow: hidden;
}

.section-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 0.7rem;
  letter-spacing: 0.4em;
  text-transform: uppercase;
  color: var(--text-secondary);
  padding: 0 4px;
}

.section-header .count {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  letter-spacing: 0.18em;
  color: var(--text-muted);
}

.crew-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  grid-auto-rows: 1fr;
  gap: 8px;
  flex: 1;
  min-height: 0;
}

.agent-tile {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  padding: 12px 8px 10px;
  background:
    linear-gradient(180deg,
      rgba(18, 28, 68, 0.55) 0%,
      rgba(10, 18, 48, 0.85) 100%
    );
  border: 1px solid var(--rule);
  border-radius: 4px;
  cursor: pointer;
  overflow: hidden;
  transition:
    border-color 0.3s var(--ease-soft),
    background 0.3s var(--ease-soft),
    box-shadow 0.3s var(--ease-soft),
    transform 0.45s var(--ease-snap),
    grid-column 0.001s,
    grid-row 0.001s;

  /* clip-path gives the chamfered top-corner monolith silhouette */
  clip-path: polygon(
    8px 0,
    calc(100% - 8px) 0,
    100% 8px,
    100% 100%,
    0 100%,
    0 8px
  );
}

.agent-tile::before {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 2px;
  background: linear-gradient(to right,
    transparent 0%,
    var(--tile-accent, var(--glow-blue)) 50%,
    transparent 100%
  );
  opacity: 0.25;
  transition: opacity 0.3s var(--ease-soft);
}

.agent-glyph {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 0.95rem;
  letter-spacing: 0.04em;
  color: var(--tile-accent, var(--text-primary));
  border: 1px solid color-mix(in srgb, var(--tile-accent, var(--glow-blue)) 40%, transparent);
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%,
    color-mix(in srgb, var(--tile-accent, var(--glow-blue)) 18%, transparent) 0%,
    transparent 70%
  );
  text-shadow: 0 0 12px color-mix(in srgb, var(--tile-accent, var(--glow-blue)) 60%, transparent);
  transition:
    box-shadow 0.3s var(--ease-soft),
    border-color 0.3s var(--ease-soft);
}

.agent-name {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 0.62rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--text-primary);
  margin-top: 6px;
}

.agent-status {
  font-family: var(--font-mono);
  font-size: 0.58rem;
  letter-spacing: 0.12em;
  color: var(--text-muted);
  text-transform: uppercase;
  margin-top: 2px;
  min-height: 1em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
  text-align: center;
}

.agent-meter {
  position: absolute;
  left: 0;
  bottom: 0;
  height: 2px;
  background: var(--tile-accent, var(--glow-blue));
  box-shadow: 0 0 8px var(--tile-accent, var(--glow-blue));
  transition: width 0.4s var(--ease-soft);
}

/* v10-meter: three-state predictive bar. Source-of-truth for width/opacity. */
.agent-tile.idle .agent-meter {
  width: 100%;
  opacity: 0.18;
  background: var(--text-muted);
  box-shadow: none;
}

.agent-tile.active .agent-meter {
  width: var(--meter-width, 0%);
  opacity: 1;
  transition: width 0.6s linear;
}

.agent-tile.completed .agent-meter {
  width: 100%;
  opacity: 1;
}

/* per-agent accents so the crew reads as a constellation, not a uniform grid */
.agent-tile[data-agent="atlas"]   { --tile-accent: #6FD3FF; }
.agent-tile[data-agent="forge"]   { --tile-accent: #FF8C5A; }
.agent-tile[data-agent="sage"]    { --tile-accent: #B967DB; }
.agent-tile[data-agent="scribe"]  { --tile-accent: #D6DEFF; }
.agent-tile[data-agent="herald"]  { --tile-accent: #59E5A0; }
.agent-tile[data-agent="lens"]    { --tile-accent: #FFC36F; }
.agent-tile[data-agent="quill"]   { --tile-accent: #4A6FFF; }
.agent-tile[data-agent="warden"]  { --tile-accent: #FF4A6F; }

/* state: idle — gentle ambient breath on the glyph border */
.agent-tile.idle .agent-glyph {
  animation: glyph-breathe 4.2s var(--ease-monolith) infinite;
}

@keyframes glyph-breathe {
  0%, 100% { box-shadow: inset 0 0 8px rgba(74, 111, 255, 0.05); }
  50%      { box-shadow: inset 0 0 14px rgba(74, 111, 255, 0.18),
                          0 0 8px color-mix(in srgb, var(--tile-accent, var(--glow-blue)) 25%, transparent); }
}

/* state: active — tile lifts, edge bar lights up, glyph pulses fast */
.agent-tile.active {
  background:
    linear-gradient(180deg,
      color-mix(in srgb, var(--tile-accent, var(--glow-blue)) 14%, rgba(18, 28, 68, 0.6)) 0%,
      rgba(10, 18, 48, 0.9) 100%
    );
  border-color: color-mix(in srgb, var(--tile-accent, var(--glow-blue)) 60%, transparent);
  box-shadow:
    0 0 0 1px color-mix(in srgb, var(--tile-accent, var(--glow-blue)) 25%, transparent),
    0 8px 28px color-mix(in srgb, var(--tile-accent, var(--glow-blue)) 18%, transparent),
    inset 0 0 30px color-mix(in srgb, var(--tile-accent, var(--glow-blue)) 10%, transparent);
  transform: translateY(-1px);
}

.agent-tile.active::before {
  opacity: 1;
  animation: edge-bar-flow 1.6s linear infinite;
}

.agent-tile.active .agent-glyph {
  animation: glyph-active 1.2s var(--ease-monolith) infinite;
  border-color: var(--tile-accent, var(--glow-blue));
}

.agent-tile.active .agent-status {
  color: var(--tile-accent, var(--glow-blue));
  text-shadow: 0 0 10px color-mix(in srgb, var(--tile-accent, var(--glow-blue)) 50%, transparent);
}

@keyframes edge-bar-flow {
  0%   { background-position: -200% 0; }
  100% { background-position:  200% 0; }
}

@keyframes glyph-active {
  0%, 100% {
    box-shadow:
      inset 0 0 14px color-mix(in srgb, var(--tile-accent, var(--glow-blue)) 25%, transparent),
      0 0 14px color-mix(in srgb, var(--tile-accent, var(--glow-blue)) 40%, transparent);
  }
  50% {
    box-shadow:
      inset 0 0 20px color-mix(in srgb, var(--tile-accent, var(--glow-blue)) 45%, transparent),
      0 0 24px color-mix(in srgb, var(--tile-accent, var(--glow-blue)) 70%, transparent);
  }
}

/* state: just-finished — single brighter pulse, then fades back to idle */
.agent-tile.completed .agent-glyph {
  animation: glyph-complete 1.1s var(--ease-snap);
}

.agent-tile.completed::before {
  opacity: 1;
  animation: edge-complete 1.1s var(--ease-snap);
}

@keyframes glyph-complete {
  0%   { box-shadow: 0 0 0 rgba(89, 229, 160, 0); }
  30%  {
    box-shadow:
      0 0 28px color-mix(in srgb, var(--tile-accent, var(--accent-ok)) 90%, transparent),
      inset 0 0 18px color-mix(in srgb, var(--tile-accent, var(--accent-ok)) 50%, transparent);
  }
  100% { box-shadow: 0 0 0 rgba(89, 229, 160, 0); }
}

@keyframes edge-complete {
  0%   { opacity: 0.25; }
  30%  { opacity: 1; }
  100% { opacity: 0.25; }
}

/* state: error — tile flashes warn red, then settles dim with red rule */
.agent-tile.error {
  border-color: color-mix(in srgb, var(--accent-warn) 65%, transparent);
  background:
    linear-gradient(180deg,
      rgba(60, 12, 24, 0.55) 0%,
      rgba(10, 18, 48, 0.85) 100%
    );
  animation: tile-error 0.7s var(--ease-snap);
}

.agent-tile.error .agent-glyph {
  color: var(--accent-warn);
  border-color: var(--accent-warn);
  text-shadow: 0 0 12px rgba(255, 74, 111, 0.6);
}

.agent-tile.error .agent-status {
  color: var(--accent-warn);
}

@keyframes tile-error {
  0%   { box-shadow: 0 0 0 rgba(255, 74, 111, 0); }
  25%  {
    box-shadow:
      0 0 0 1px var(--accent-warn),
      0 0 32px rgba(255, 74, 111, 0.5);
  }
  100% { box-shadow: 0 0 0 rgba(255, 74, 111, 0); }
}

/* v11-grid — collapsed-state task is hidden (single source of truth: glyph + name + status).
   Expanded reveals it. */
.agent-tile-task {
  display: none;
}

/* Collapsed-state bar wrapper is hidden; only meter + readout show. */
.agent-tile-bar {
  display: none;
}

/* state: expanded — Lens v11 grid. Glyph rail, content column, action rail.
   Same shell across all 8 tiles. */
.agent-tile.expanded {
  grid-column: 1 / -1;
  grid-row: span 3;
  display: grid;
  grid-template-columns: 56px 1fr 56px;
  grid-template-rows: auto auto 1fr auto auto;
  grid-template-areas:
    "glyph  name    close"
    "glyph  task    close"
    ".      bar     ."
    ".      readout ."
    ".      .       stop";
  column-gap: 18px;
  row-gap: 14px;
  padding: 20px 20px 18px;
  cursor: default;
  align-items: center;
  min-height: 0;
}

.agent-tile.expanded .agent-glyph {
  grid-area: glyph;
  align-self: start;
  width: 56px;
  height: 56px;
  font-size: 1.2rem;
  flex-shrink: 0;
}

.agent-tile.expanded .agent-name {
  grid-area: name;
  align-self: end;
  margin: 0;
  text-align: left;
  font-size: 0.78rem;
  letter-spacing: 0.32em;
}

.agent-tile.expanded .agent-status {
  display: none;
}

.agent-tile.expanded .agent-tile-task {
  grid-area: task;
  align-self: start;
  display: -webkit-box;
  font-family: var(--font-body);
  font-weight: 300;
  font-size: 0.92rem;
  line-height: 1.35;
  color: var(--text-primary);
  letter-spacing: 0.01em;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.agent-tile.expanded .agent-tile-bar {
  grid-area: bar;
  display: block;
  position: relative;
  height: 4px;
  width: 100%;
  background: rgba(74, 111, 255, 0.12);
  border-radius: 2px;
  overflow: hidden;
  margin: 8px 0;
}

.agent-tile.expanded .agent-tile-bar-fill {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: var(--meter-width, 0%);
  background: var(--tile-accent, var(--glow-blue));
  box-shadow: 0 0 10px var(--tile-accent, var(--glow-blue));
  transition: width 0.6s linear;
  border-radius: 2px;
}

.agent-tile.expanded .agent-tile-readout {
  grid-area: readout;
  position: static;
  justify-self: center;
  max-width: none;
  font-size: 0.7rem;
  letter-spacing: 0.18em;
  opacity: 1;
  display: flex;
  flex-direction: row;
  gap: 8px;
}

.agent-tile.expanded .tile-close,
.agent-tile.expanded .tile-stop {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  min-height: 44px;
  background: transparent;
  border: 1px solid var(--rule-strong);
  border-radius: 4px;
  font-family: var(--font-display);
  font-size: 0.65rem;
  letter-spacing: 0.22em;
  color: var(--text-secondary);
  cursor: pointer;
}

.agent-tile.expanded .tile-close {
  grid-area: close;
  justify-self: end;
  align-self: start;
  font-size: 1.1rem;
}

.agent-tile.expanded .tile-stop {
  grid-area: stop;
  justify-self: end;
  align-self: end;
  color: rgba(255, 74, 111, 0.85);
  border-color: rgba(255, 74, 111, 0.4);
}

/* STOP visibility — pure CSS. Active + expanded only. */
.agent-tile.expanded.active .tile-stop { display: inline-flex; }
.agent-tile:not(.expanded) .tile-stop,
.agent-tile:not(.active) .tile-stop { display: none !important; }

/* Fix 5 — per-tile scanline + readout for active agents. */
.agent-tile-scan {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0;
  background: linear-gradient(
    to bottom,
    transparent 0%,
    color-mix(in srgb, var(--tile-accent, var(--glow-blue)) 22%, transparent) 48%,
    color-mix(in srgb, var(--tile-accent, var(--glow-blue)) 55%, transparent) 50%,
    color-mix(in srgb, var(--tile-accent, var(--glow-blue)) 22%, transparent) 52%,
    transparent 100%);
  background-size: 100% 220%;
  background-position: 0 -120%;
  mix-blend-mode: screen;
}
.agent-tile.active .agent-tile-scan {
  opacity: 1;
  animation: tile-scan-sweep 2.4s var(--ease-monolith) infinite;
}
@keyframes tile-scan-sweep {
  0%   { background-position: 0 -120%; }
  100% { background-position: 0  120%; }
}
.agent-tile-readout {
  position: absolute;
  top: 6px;
  right: 10px;
  max-width: 60%;
  font-family: var(--font-mono);
  font-size: 0.55rem;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  opacity: 0;
  transition: opacity 0.3s var(--ease-soft);
  pointer-events: none;
  display: flex;
  gap: 4px;
}

.readout-tools {
  font-variant-numeric: tabular-nums;
}
.agent-tile.active .agent-tile-readout {
  opacity: 1;
  color: color-mix(in srgb, var(--tile-accent, var(--glow-blue)) 75%, var(--text-secondary));
  text-shadow: 0 0 6px color-mix(in srgb, var(--tile-accent, var(--glow-blue)) 40%, transparent);
}
.agent-tile.active .readout-elapsed {
  animation: readout-tick 1s steps(2) infinite;
}
@keyframes readout-tick {
  0%, 60%   { opacity: 1; }
  61%, 70%  { opacity: 0.55; }
  71%, 100% { opacity: 1; }
}
@media (prefers-reduced-motion: reduce) {
  .agent-tile.active .agent-tile-scan { animation: none; opacity: 0.35; }
  .agent-tile.active .readout-elapsed { animation: none; }
}

/* ═══════════════════ ACTIVITY STREAM ═══════════════════ */

#activity {
  grid-area: activity;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 12px 0 var(--safe-bottom);
  border-top: 1px solid var(--rule);
  max-height: 22vh;
  min-height: 92px;
}

.activity-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: 6px 4px 0;
}

.activity-filters {
  display: flex;
  gap: 4px;
}

.filter-chip {
  font-family: var(--font-mono);
  font-size: 0.6rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--text-muted);
  background: transparent;
  border: 1px solid var(--rule);
  border-radius: 2px;
  padding: 3px 8px;
  cursor: pointer;
  transition:
    color 0.25s var(--ease-soft),
    border-color 0.25s var(--ease-soft),
    background 0.25s var(--ease-soft);
}

.filter-chip.active {
  color: var(--text-primary);
  border-color: var(--rule-strong);
  background: rgba(74, 111, 255, 0.08);
}

.activity-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 4px 4px 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

/* Hide the scrollbar visually but keep wheel/touch scrolling functional. */
.activity-list::-webkit-scrollbar { width: 0; height: 0; }
.activity-list { scrollbar-width: none; }

.activity-row {
  display: grid;
  grid-template-columns: 64px 16px 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 6px 8px;
  border-radius: 2px;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  letter-spacing: 0.06em;
  color: var(--text-secondary);
  border-left: 2px solid transparent;
  transition: background 0.2s var(--ease-soft);
}

.activity-row:hover {
  background: rgba(74, 111, 255, 0.05);
}

.activity-time {
  color: var(--text-muted);
  font-size: 0.65rem;
}

.activity-marker {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--row-accent, var(--text-muted));
  box-shadow: 0 0 6px var(--row-accent, transparent);
  justify-self: center;
}

.activity-label {
  color: var(--text-primary);
  font-family: var(--font-body);
  font-weight: 400;
  font-size: 0.78rem;
  letter-spacing: 0.02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.activity-label .agent-tag {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 0.65rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--row-accent, var(--text-secondary));
  margin-right: 8px;
}

.activity-elapsed {
  color: var(--text-muted);
  font-size: 0.65rem;
  letter-spacing: 0.08em;
  white-space: nowrap;
}

.activity-row.running {
  border-left-color: var(--row-accent, var(--glow-blue));
  background: linear-gradient(
    to right,
    color-mix(in srgb, var(--row-accent, var(--glow-blue)) 8%, transparent) 0%,
    transparent 70%
  );
}

.activity-row.running .activity-marker {
  animation: marker-pulse 1.4s ease-in-out infinite;
}

@keyframes marker-pulse {
  0%, 100% { opacity: 0.6; transform: scale(0.85); }
  50%      { opacity: 1;   transform: scale(1.15); box-shadow: 0 0 12px var(--row-accent, var(--glow-blue)); }
}

.activity-row.completed .activity-marker {
  background: var(--accent-ok);
  box-shadow: 0 0 6px rgba(89, 229, 160, 0.4);
}

.activity-row.error {
  border-left-color: var(--accent-warn);
}

.activity-row.error .activity-marker {
  background: var(--accent-warn);
  box-shadow: 0 0 8px rgba(255, 74, 111, 0.6);
}

.activity-row.error .activity-label {
  color: var(--accent-warn);
}

/* per-agent row accents mirror the tiles */
.activity-row[data-agent="atlas"]   { --row-accent: #6FD3FF; }
.activity-row[data-agent="forge"]   { --row-accent: #FF8C5A; }
.activity-row[data-agent="sage"]    { --row-accent: #B967DB; }
.activity-row[data-agent="scribe"]  { --row-accent: #D6DEFF; }
.activity-row[data-agent="herald"]  { --row-accent: #59E5A0; }
.activity-row[data-agent="lens"]    { --row-accent: #FFC36F; }
.activity-row[data-agent="quill"]   { --row-accent: #4A6FFF; }
.activity-row[data-agent="warden"]  { --row-accent: #FF4A6F; }

.activity-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 1;
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 0.65rem;
  letter-spacing: 0.4em;
  text-transform: uppercase;
  color: var(--text-muted);
  opacity: 0.6;
}

/* ═══════════════════ TRANSCRIPT SHEET ═══════════════════ */
/*
   Slide-up sheet from bottom edge. The handle sits permanently at the
   bottom of the viewport; tapping or dragging it raises the sheet.
   Forge: toggle .open on #transcript-sheet.
*/

#transcript-handle {
  position: fixed;
  left: 50%;
  bottom: calc(var(--safe-bottom) + 4px);
  transform: translateX(-50%);
  z-index: 50;
  width: 88px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(10, 18, 48, 0.6);
  border: 1px solid var(--rule);
  border-radius: 14px;
  cursor: pointer;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  transition:
    background 0.25s var(--ease-soft),
    border-color 0.25s var(--ease-soft),
    transform 0.4s var(--ease-snap);
}

#transcript-handle::before {
  content: '';
  width: 36px;
  height: 2px;
  background: var(--text-muted);
  border-radius: 1px;
  transition: background 0.25s var(--ease-soft);
}

#transcript-handle:hover,
#transcript-handle:focus-visible {
  background: rgba(74, 111, 255, 0.14);
  border-color: var(--rule-strong);
  outline: none;
}

#transcript-handle:hover::before {
  background: var(--text-primary);
}

#transcript-sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 60;
  height: 85vh;
  height: 85dvh;
  background: var(--bg-elevated);
  border-top: 1px solid var(--rule-strong);
  border-top-left-radius: 16px;
  border-top-right-radius: 16px;
  box-shadow: 0 -24px 64px rgba(0, 0, 0, 0.5);
  transform: translateY(100%);
  transition: transform 0.45s var(--ease-snap);
  display: flex;
  flex-direction: column;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}

#transcript-sheet.open {
  transform: translateY(0);
}

.sheet-grip {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 28px;
  flex-shrink: 0;
  cursor: pointer;
}

.sheet-grip::before {
  content: '';
  width: 44px;
  height: 4px;
  background: var(--text-muted);
  border-radius: 2px;
  opacity: 0.6;
}

.sheet-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 18px 14px;
  border-bottom: 1px solid var(--rule);
  flex-shrink: 0;
}

.sheet-title {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 0.78rem;
  letter-spacing: 0.42em;
  text-transform: uppercase;
  color: var(--text-primary);
}

.sheet-link {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 0.62rem;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: var(--text-secondary);
  text-decoration: none;
  padding: 6px 10px;
  border: 1px solid var(--rule);
  border-radius: 2px;
  transition:
    color 0.25s var(--ease-soft),
    border-color 0.25s var(--ease-soft);
}

.sheet-link:hover,
.sheet-link:focus-visible {
  color: var(--text-primary);
  border-color: var(--rule-strong);
  outline: none;
}

#transcript-feed {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 18px 18px calc(28px + var(--safe-bottom));
  display: flex;
  flex-direction: column;
  gap: 14px;
  -webkit-user-select: text;
  user-select: text;
}

#transcript-feed::-webkit-scrollbar { width: 4px; }
#transcript-feed::-webkit-scrollbar-track { background: transparent; }
#transcript-feed::-webkit-scrollbar-thumb {
  background: rgba(74, 111, 255, 0.18);
  border-radius: 2px;
}

#transcript-backdrop {
  position: fixed;
  inset: 0;
  z-index: 55;
  background: rgba(2, 5, 14, 0.6);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s var(--ease-soft);
}

#transcript-backdrop.visible {
  opacity: 1;
  pointer-events: auto;
}

/* ═══════════════════ MESSAGES (transcript + chatlog page) ═══════════════════ */

.exchange {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.exchange-ts {
  font-family: var(--font-mono);
  font-size: 0.62rem;
  font-weight: 400;
  letter-spacing: 0.18em;
  color: var(--text-muted);
  text-align: center;
  padding: 8px 0 4px;
  text-transform: uppercase;
}

.speak-btn {
  align-self: flex-start;
  margin-left: 12px;
  width: 44px;
  height: 44px;
  min-width: 44px;
  min-height: 44px;
  background: transparent;
  border: 1px solid rgba(74, 111, 255, 0.18);
  border-radius: 4px;
  color: var(--text-secondary);
  font-family: var(--font-body);
  font-size: 0.85rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.25s var(--ease-soft), border-color 0.25s var(--ease-soft);
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

.speak-btn:active {
  color: var(--text-primary);
  border-color: rgba(74, 111, 255, 0.4);
}

.speak-btn {
  align-self: flex-start;
  margin-left: 12px;
  width: 44px;
  height: 44px;
  min-width: 44px;
  min-height: 44px;
  background: transparent;
  border: 1px solid rgba(74, 111, 255, 0.18);
  border-radius: 4px;
  color: var(--text-secondary);
  font-family: var(--font-body);
  font-size: 0.85rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.25s var(--ease-soft), border-color 0.25s var(--ease-soft);
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

.speak-btn:active {
  color: var(--text-primary);
  border-color: rgba(74, 111, 255, 0.4);
}

/* Code blocks with copy buttons */
.code-block {
  position: relative;
  margin: 8px 0;
  border-radius: 4px;
  overflow: hidden;
}

.code-block pre {
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(74, 111, 255, 0.18);
  border-radius: 4px;
  padding: 10px 12px;
  padding-top: 36px;
  overflow-x: auto;
  font-family: var(--font-mono), monospace;
  font-size: 0.8rem;
  line-height: 1.5;
  color: var(--text-primary);
  white-space: pre-wrap;
  word-wrap: break-word;
  margin: 0;
}

.code-block code {
  font-family: inherit;
  font-size: inherit;
  background: transparent;
  padding: 0;
}

.code-block.full-copy pre {
  border-color: rgba(74, 111, 255, 0.32);
}

.copy-btn {
  position: absolute;
  top: 4px;
  right: 6px;
  z-index: 2;
  width: 44px;
  height: 44px;
  min-width: 44px;
  min-height: 44px;
  background: rgba(0, 0, 0, 0.5);
  border: 1px solid rgba(74, 111, 255, 0.22);
  border-radius: 4px;
  color: var(--text-secondary);
  font-size: 0.9rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.2s, border-color 0.2s;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

.copy-btn:active {
  color: var(--text-primary);
  border-color: rgba(74, 111, 255, 0.5);
}

.message {
  max-width: 78%;
  padding: 10px 14px;
  font-family: var(--font-body);
  font-size: 0.94rem;
  font-weight: 300;
  line-height: 1.55;
  letter-spacing: 0.01em;
  color: var(--text-primary);
  border-radius: 4px;
  border: 1px solid transparent;
  word-wrap: break-word;
  overflow-wrap: break-word;
}

.message.user {
  align-self: flex-end;
  background: linear-gradient(135deg,
    rgba(74, 111, 255, 0.16) 0%,
    rgba(74, 111, 255, 0.06) 100%
  );
  border-color: rgba(74, 111, 255, 0.28);
  border-top-right-radius: 1px;
}

.message.cortana {
  align-self: flex-start;
  background: linear-gradient(135deg,
    rgba(185, 103, 219, 0.14) 0%,
    rgba(185, 103, 219, 0.04) 100%
  );
  border-color: rgba(185, 103, 219, 0.28);
  border-top-left-radius: 1px;
}

.message.streaming::after {
  content: '';
  display: inline-block;
  width: 6px;
  height: 0.95em;
  margin-left: 4px;
  vertical-align: text-bottom;
  background: var(--glow-violet);
  box-shadow: 0 0 8px rgba(185, 103, 219, 0.6);
  animation: caret-blink 1s steps(2) infinite;
}

@keyframes caret-blink {
  0%, 49%   { opacity: 1; }
  50%, 100% { opacity: 0; }
}

/* ═══════════════════ MIC OVERLAY ═══════════════════ */

#mic-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2rem;
  padding: 2rem;
  text-align: center;
  background: rgba(2, 5, 14, 0.94);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
}

#mic-overlay[hidden] {
  display: none;
}

#mic-overlay p {
  font-family: var(--font-body);
  font-size: 1rem;
  font-weight: 300;
  line-height: 1.6;
  letter-spacing: 0.04em;
  color: var(--text-primary);
  max-width: 28ch;
}

#mic-retry {
  font-family: var(--font-display);
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: var(--text-primary);
  background: transparent;
  border: 1px solid rgba(74, 111, 255, 0.5);
  border-radius: 2px;
  padding: 0.9rem 2rem;
  cursor: pointer;
  transition:
    background 0.3s var(--ease-monolith),
    border-color 0.3s var(--ease-monolith),
    box-shadow 0.3s var(--ease-monolith);
}

#mic-retry:hover,
#mic-retry:focus-visible {
  background: rgba(74, 111, 255, 0.10);
  border-color: var(--glow-blue);
  box-shadow: 0 0 30px rgba(74, 111, 255, 0.25);
  outline: none;
}

#mic-retry:active {
  background: rgba(74, 111, 255, 0.18);
}

/* ═══════════════════ CHATLOG STANDALONE PAGE ═══════════════════ */

body:has(.log-header) {
  overflow-y: auto;
  overscroll-behavior-y: contain;
  -webkit-user-select: text;
  user-select: text;
  background:
    radial-gradient(ellipse at top, rgba(20, 30, 80, 0.22) 0%, transparent 50%),
    var(--bg);
}

.log-header {
  font-family: var(--font-display);
  font-size: clamp(1.1rem, 2.4vw, 1.5rem);
  font-weight: 500;
  letter-spacing: 0.5em;
  text-transform: uppercase;
  color: var(--text-primary);
  text-align: center;
  padding: 3rem 2rem 2rem;
  border-bottom: 1px solid var(--rule);
}

.log-controls {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  padding: 1.25rem 1.5rem;
  background: rgba(2, 5, 14, 0.85);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--rule);
}

.log-controls input {
  flex: 1;
  min-width: 0;
  font-family: var(--font-body);
  font-size: 0.9rem;
  font-weight: 300;
  color: var(--text-primary);
  background: rgba(10, 18, 48, 0.6);
  border: 1px solid var(--rule-strong);
  border-radius: 2px;
  padding: 0.65rem 0.85rem;
  letter-spacing: 0.04em;
  transition:
    border-color 0.25s var(--ease-monolith),
    background 0.25s var(--ease-monolith),
    box-shadow 0.25s var(--ease-monolith);
}

.log-controls input::placeholder {
  color: var(--text-secondary);
  opacity: 0.7;
  letter-spacing: 0.1em;
}

.log-controls input:focus {
  outline: none;
  border-color: rgba(74, 111, 255, 0.5);
  background: rgba(10, 18, 48, 0.85);
  box-shadow: 0 0 0 3px rgba(74, 111, 255, 0.10);
}

.log-controls input[type="date"]::-webkit-calendar-picker-indicator,
.log-controls input[type="search"]::-webkit-search-cancel-button {
  filter: invert(0.7) brightness(1.4);
  opacity: 0.6;
  cursor: pointer;
}

#exchanges {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  padding: 2rem 1.25rem 4rem;
  max-width: 56rem;
  margin: 0 auto;
  width: 100%;
}

/* ═══════════════════ ACCESSIBILITY ═══════════════════ */

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.15s !important;
  }
  /* keep some directional cue alive even with motion reduced */
  #presence.thinking .horizon-swell { opacity: 0.95; }
  #presence.listening .horizon-line { opacity: 1; }
}

@media (prefers-contrast: more) {
  :root {
    --text-primary: #FFFFFF;
    --text-secondary: #B5C4F0;
    --rule: rgba(74, 111, 255, 0.32);
    --rule-strong: rgba(74, 111, 255, 0.55);
  }
}

/* ═══════════════════ LARGER SCREENS (iPad landscape, desktop) ═══════════════════ */

@media (min-width: 900px) and (orientation: landscape) {
  #app {
    grid-template-rows: auto 1fr auto;
    grid-template-columns: 1fr 380px;
    grid-template-areas:
      "topbar    topbar"
      "presence  crew"
      "activity  activity";
  }
  #presence  { min-height: 320px; max-height: none; }
  .crew-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .agent-tile.expanded {
    grid-column: 1 / -1;
    grid-row: span 2;
  }
}

@media (min-width: 1280px) {
  #app {
    max-width: 1440px;
    margin: 0 auto;
  }
}

/* ═══════════════════ VIEW TOGGLE (TOPBAR) ═══════════════════ */

.view-toggle {
  display: inline-flex;
  align-items: stretch;
  gap: 2px;
  margin-right: 6px;
  border: 1px solid var(--rule-strong);
  border-radius: 4px;
  overflow: hidden;
  background: rgba(7, 12, 34, 0.45);
}

.view-toggle-btn {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 0.62rem;
  letter-spacing: 0.22em;
  color: var(--text-secondary);
  background: transparent;
  border: none;
  padding: 0 12px;
  min-width: 56px;
  min-height: 32px;
  /* iPad: 44pt tap target */
  height: 36px;
  cursor: pointer;
  text-transform: uppercase;
  transition: color 0.18s var(--ease-soft), background 0.18s var(--ease-soft), text-shadow 0.25s var(--ease-soft);
}

.view-toggle-btn[aria-selected="true"] {
  color: var(--accent-active);
  background: rgba(111, 211, 255, 0.10);
  text-shadow: 0 0 8px rgba(111, 211, 255, 0.55);
}

.view-toggle-btn:focus-visible {
  outline: 1px solid var(--accent-active);
  outline-offset: 1px;
}

/* ═══════════════════ VIEW SWAP RULES ═══════════════════ */
/* Default: grid view. Shows #presence + #crew + #activity, hides #floor. */
body.view-grid #floor { display: none; }

/* Floor view: hide grid view chrome, show #floor stretched full-bleed
   into the area #crew used to occupy. #presence, #crew and #activity all
   give up their space. */
body.view-floor #presence,
body.view-floor #crew,
body.view-floor #activity { display: none; }

body.view-floor #app {
  grid-template-rows: auto 1fr;
  grid-template-areas:
    "topbar"
    "floor";
}

#floor {
  grid-area: floor;
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  /* leave a little room for the caption that lives at the bottom */
  padding: 8px 8px calc(var(--safe-bottom) + 64px);
}

@media (min-width: 900px) and (orientation: landscape) {
  body.view-floor #app {
    grid-template-rows: auto 1fr;
    grid-template-columns: 1fr;
    grid-template-areas:
      "topbar"
      "floor";
  }
}

/* In floor view: the caption sits below the central node, not above the
   transcript handle. Pin it lower-bottom but keep the same look. */
body.view-floor #caption {
  bottom: calc(var(--safe-bottom) + 8px);
}

/* ═══════════════════ FLOOR STAGE ═══════════════════ */

.floor-stage {
  position: relative;
  width: 100%;
  height: 100%;
  max-width: min(96vh, 100%);
  max-height: 100%;
  aspect-ratio: 1 / 1;
  margin: 0 auto;
}

#floor-svg {
  width: 100%;
  height: 100%;
  display: block;
  /* The SVG already has its own dark background; render with the page bg
     visible at the corners. */
}

/* Per-room palette tokens (mirror agent-tile accents). */
.room[data-agent="atlas"]   { --room-accent: #6FD3FF; --room-fill: rgba(111,211,255,0.20); }
.room[data-agent="forge"]   { --room-accent: #FF8C5A; --room-fill: rgba(255,140,90,0.28); }
.room[data-agent="sage"]    { --room-accent: #B967DB; --room-fill: rgba(185,103,219,0.20); }
.room[data-agent="scribe"]  { --room-accent: #D6DEFF; --room-fill: rgba(214,222,255,0.16); }
.room[data-agent="herald"]  { --room-accent: #59E5A0; --room-fill: rgba(89,229,160,0.20); }
.room[data-agent="lens"]    { --room-accent: #FFC36F; --room-fill: rgba(255,195,111,0.20); }
.room[data-agent="quill"]   { --room-accent: #4A6FFF; --room-fill: rgba(74,111,255,0.22); }
.room[data-agent="warden"]  { --room-accent: #FF4A6F; --room-fill: rgba(255,74,111,0.20); }

.conduit[data-agent="atlas"]   { --room-accent: #6FD3FF; }
.conduit[data-agent="forge"]   { --room-accent: #FF8C5A; }
.conduit[data-agent="sage"]    { --room-accent: #B967DB; }
.conduit[data-agent="scribe"]  { --room-accent: #D6DEFF; }
.conduit[data-agent="herald"]  { --room-accent: #59E5A0; }
.conduit[data-agent="lens"]    { --room-accent: #FFC36F; }
.conduit[data-agent="quill"]   { --room-accent: #4A6FFF; }
.conduit[data-agent="warden"]  { --room-accent: #FF4A6F; }

/* ─── ROOM ───────────────────────────────────────── */

.room {
  cursor: pointer;
  outline: none;
  /* NOTE: each .room has its own SVG transform="translate(cx,cy)" — we don't
     touch CSS transform on the room itself or it would clobber its position.
     Active "scale" is conveyed via room-bg / room-highlight instead. */
}

.room:focus-visible .room-bg {
  stroke: var(--room-accent, #6FD3FF);
  stroke-width: 2;
}

.room .room-bg {
  fill: var(--room-fill, rgba(111,211,255,0.10));
  transition: fill 0.45s var(--ease-soft);
}

.room .room-highlight {
  stroke: var(--room-accent, #6FD3FF);
  stroke-opacity: 0;
  transition: stroke-opacity 0.4s var(--ease-soft);
}

.room.active .room-highlight {
  stroke-opacity: 0.95;
  filter: url(#fl-soft-glow);
}

.room.completed .room-highlight {
  stroke-opacity: 0.95;
  stroke: #FFC36F;
  filter: url(#fl-hot-glow);
}

/* Warden-only completion exception: green-shield, not red. */
.room.completed.warden .room-highlight {
  stroke: var(--accent-ok, #59E5A0);
}

.room .room-label {
  fill: var(--room-accent, #D6DEFF);
  fill-opacity: 0.55;
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 3px;
  text-anchor: middle;
  pointer-events: none;
  transition: fill-opacity 0.3s var(--ease-soft);
}

.room .room-status {
  fill: var(--room-accent, #D6DEFF);
  fill-opacity: 0.40;
  font-family: var(--font-display);
  font-size: 9px;
  letter-spacing: 2.5px;
  text-anchor: middle;
  pointer-events: none;
  transition: fill-opacity 0.3s var(--ease-soft);
}

.room.active .room-label,
.room.completed .room-label { fill-opacity: 0.95; }
.room.active .room-status,
.room.completed .room-status { fill-opacity: 0.85; }

/* Idle ambient: gentle breathing on the bg fill. */
@keyframes room-breathe {
  0%, 100% { opacity: 0.85; }
  50%      { opacity: 1.00; }
}

.room.idle .room-bg {
  animation: room-breathe 5.6s ease-in-out infinite;
}

/* Active state: themed work animations + intensified bg fill. */
.room.active .room-bg {
  fill: color-mix(in srgb, var(--room-accent, #6FD3FF) 32%, rgba(10,18,48,0.85));
  animation: room-breathe 1.6s ease-in-out infinite;
}

/* Completed state: brief celebratory flash, then settle. */
@keyframes room-complete-flash {
  0%   { fill: rgba(255, 255, 255, 0.55); }
  35%  { fill: color-mix(in srgb, var(--room-accent, #FFC36F) 80%, white); }
  100% { fill: var(--room-fill, rgba(111,211,255,0.10)); }
}

.room.completed .room-bg {
  animation: room-complete-flash 1100ms ease-out;
}

/* Warden completion = green clearance flash, not the agent's red accent. */
.room.completed.warden .room-bg {
  animation: room-complete-flash-warden 1100ms ease-out;
}

@keyframes room-complete-flash-warden {
  0%   { fill: rgba(255, 255, 255, 0.55); }
  35%  { fill: color-mix(in srgb, var(--accent-ok, #59E5A0) 80%, white); }
  100% { fill: var(--room-fill, rgba(255,74,111,0.20)); }
}

/* ─── PER-AGENT ACTIVE GLYPH MOTIONS ─────────────── */

/* Atlas: rotate the search beams */
@keyframes atlas-sweep {
  0%   { transform: rotate(0deg);   opacity: 0.85; }
  100% { transform: rotate(360deg); opacity: 0.85; }
}
.room.active [class*="atlas-beams"] {
  opacity: 1 !important;
  transform-origin: 0 0;
  animation: atlas-sweep 4.5s linear infinite;
}

/* Forge: jiggle the arms */
@keyframes forge-arm-l {
  0%, 100% { transform: rotate(0deg);  }
  50%      { transform: rotate(-8deg); }
}
@keyframes forge-arm-r {
  0%, 100% { transform: rotate(0deg); }
  50%      { transform: rotate(8deg); }
}
.room.active .forge-arm-l { transform-origin: -78px -40px; transform-box: fill-box; animation: forge-arm-l 1.6s ease-in-out infinite; }
.room.active .forge-arm-r { transform-origin: 78px -40px;  transform-box: fill-box; animation: forge-arm-r 1.6s ease-in-out infinite; }

/* Sage: glow the tome */
@keyframes sage-tome-pulse {
  0%, 100% { fill-opacity: 0.55; }
  50%      { fill-opacity: 0.95; }
}
.room.active .sage-tome-glow { animation: sage-tome-pulse 2.2s ease-in-out infinite; }

@keyframes sage-mote-rise {
  0%   { transform: translateY(0);    opacity: 0; }
  20%  { opacity: 1; }
  100% { transform: translateY(-40px); opacity: 0; }
}
.room.active .sage-motes circle {
  transform-box: fill-box;
  animation: sage-mote-rise 3.2s ease-out infinite;
}
.room.active .sage-motes circle:nth-child(2) { animation-delay: 0.8s; }
.room.active .sage-motes circle:nth-child(3) { animation-delay: 1.6s; }
.room.active .sage-motes circle:nth-child(4) { animation-delay: 2.4s; }

/* Scribe: drift papers + fill ink */
@keyframes scribe-drift-l { 0%,100% { transform: translateY(0) rotate(-8deg); } 50% { transform: translateY(-4px) rotate(-6deg); } }
@keyframes scribe-drift-r { 0%,100% { transform: translateY(0) rotate(6deg);  } 50% { transform: translateY(4px)  rotate(8deg);  } }
.room.active .scribe-paper-l { transform-box: fill-box; transform-origin: -56px -36px; animation: scribe-drift-l 4s ease-in-out infinite; }
.room.active .scribe-paper-r { transform-box: fill-box; transform-origin: 54px -44px;  animation: scribe-drift-r 4s ease-in-out infinite; }

@keyframes scribe-ink-fill {
  0%   { y: 60; height: 0;  fill-opacity: 0.30; }
  100% { y: 46; height: 14; fill-opacity: 0.65; }
}
.room.active .scribe-ink { animation: scribe-ink-fill 3s ease-in-out infinite alternate; }

/* Herald: expand antenna arcs */
@keyframes herald-arc-pulse {
  0%   { stroke-opacity: 0.85; transform: scale(0.85); }
  80%  { stroke-opacity: 0;     transform: scale(1.10); }
  100% { stroke-opacity: 0;     transform: scale(1.10); }
}
.room.active .herald-arc-1 { transform-box: fill-box; transform-origin: 0px -58px; animation: herald-arc-pulse 1.8s ease-out infinite; }
.room.active .herald-arc-2 { transform-box: fill-box; transform-origin: 0px -58px; animation: herald-arc-pulse 1.8s ease-out infinite 0.5s; }
.room.active .herald-arc-3 { transform-box: fill-box; transform-origin: 0px -58px; animation: herald-arc-pulse 1.8s ease-out infinite 1.0s; }

/* Lens: drift swatches */
@keyframes lens-swatch-drift { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-3px); } }
.room.active .lens-swatches rect { transform-box: fill-box; transform-origin: center; animation: lens-swatch-drift 3.2s ease-in-out infinite; }
.room.active .lens-swatches rect:nth-child(2) { animation-delay: 0.4s; }
.room.active .lens-swatches rect:nth-child(3) { animation-delay: 0.8s; }
.room.active .lens-swatches rect:nth-child(4) { animation-delay: 1.2s; }
.room.active .lens-swatches rect:nth-child(5) { animation-delay: 1.6s; }
.room.active .lens-swatches rect:nth-child(6) { animation-delay: 2.0s; }

/* Quill: animate bar heights */
@keyframes quill-bar { 0%,100% { transform: scaleY(0.85); } 50% { transform: scaleY(1.15); } }
.room.active .quill-bars rect { transform-box: fill-box; transform-origin: center bottom; animation: quill-bar 1.6s ease-in-out infinite; }
.room.active .quill-bars rect:nth-child(2) { animation-delay: 0.2s; }
.room.active .quill-bars rect:nth-child(3) { animation-delay: 0.4s; }
.room.active .quill-bars rect:nth-child(4) { animation-delay: 0.6s; }
.room.active .quill-bars rect:nth-child(5) { animation-delay: 0.8s; }
.room.active .quill-bars rect:nth-child(6) { animation-delay: 1.0s; }

/* Warden: rotating perimeter scan */
@keyframes warden-scan-spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }
.room.active .warden-scan { transform-box: fill-box; transform-origin: 0px 28px; animation: warden-scan-spin 6s linear infinite; }

/* ─── CONDUITS ───────────────────────────────────── */

.conduit-line {
  stroke: rgba(74, 111, 255, 0.22);
  stroke-width: 2;
  stroke-linecap: round;
  transition: stroke 0.4s var(--ease-soft), stroke-opacity 0.4s var(--ease-soft), stroke-width 0.4s var(--ease-soft);
}

.conduit.active .conduit-line {
  stroke: var(--room-accent, #6FD3FF);
  stroke-opacity: 0.95;
  stroke-width: 3;
  filter: url(#fl-soft-glow);
}

.conduit-pulse {
  fill: var(--room-accent, #FFC36F);
  filter: url(#fl-hot-glow);
  opacity: 0;
  pointer-events: none;
}

/* The pulse circle's cx/cy are driven by JS (requestAnimationFrame) when
   .pulsing is added; CSS just controls its visibility envelope. */
.conduit.pulsing .conduit-pulse {
  opacity: 1;
  transition: opacity 0.15s linear;
}

/* Warden completion pulse rides the conduit in green, not red. */
.conduit.pulsing[data-agent="warden"] .conduit-pulse {
  fill: var(--accent-ok, #59E5A0);
}

/* ─── CORTANA CENTRAL NODE ───────────────────────── */

#cortana-node {
  cursor: pointer;
  outline: none;
}

#cortana-node:focus-visible .cn-ring-1 { stroke: #FFFFFF; }

#cortana-node .cn-ring {
  stroke: var(--glow-cyan, #6FD3FF);
  transition: stroke 0.35s var(--ease-soft), stroke-opacity 0.35s var(--ease-soft);
}

#cortana-node .cn-ring-1 { stroke-opacity: 0.55; stroke-width: 1.4; }
#cortana-node .cn-ring-2 { stroke-opacity: 0.30; stroke-width: 1.0; filter: url(#fl-soft-glow); }
#cortana-node .cn-ring-3 { stroke-opacity: 0.18; stroke-width: 0.8; }
#cortana-node .cn-ring-4 { stroke-opacity: 0.10; stroke-width: 0.8; }

#cortana-node .cn-armed {
  stroke: #FFC36F;
  stroke-opacity: 0;
  stroke-width: 2.4;
  filter: url(#fl-hot-glow);
  transition: stroke-opacity 0.2s var(--ease-soft);
}

@keyframes cn-listen-breathe {
  0%, 100% { stroke-opacity: var(--cn-low,  0.25); transform: scale(0.98); }
  50%      { stroke-opacity: var(--cn-high, 0.55); transform: scale(1.02); }
}

#cortana-node.cn-listening .cn-ring-1 {
  --cn-low: 0.40; --cn-high: 0.70;
  transform-box: fill-box; transform-origin: center;
  animation: cn-listen-breathe 3.2s ease-in-out infinite;
}
#cortana-node.cn-listening .cn-ring-2 {
  --cn-low: 0.20; --cn-high: 0.40;
  transform-box: fill-box; transform-origin: center;
  animation: cn-listen-breathe 3.2s ease-in-out infinite 0.4s;
}

/* Recognizing: same as listening but more intense + faster. */
#cortana-node.cn-recognizing .cn-ring-1 {
  --cn-low: 0.65; --cn-high: 0.95;
  transform-box: fill-box; transform-origin: center;
  animation: cn-listen-breathe 1.4s ease-in-out infinite;
}
#cortana-node.cn-recognizing .cn-ring-2 {
  --cn-low: 0.40; --cn-high: 0.70;
  transform-box: fill-box; transform-origin: center;
  animation: cn-listen-breathe 1.4s ease-in-out infinite 0.2s;
}

/* Speaking: violet outward radiation. */
@keyframes cn-speak-radiate {
  0%   { stroke-opacity: 0.85; transform: scale(0.92); }
  100% { stroke-opacity: 0;    transform: scale(1.18); }
}
#cortana-node.cn-speaking .cn-ring {
  stroke: var(--glow-violet, #B967DB);
}
#cortana-node.cn-speaking .cn-ring-1 {
  transform-box: fill-box; transform-origin: center;
  animation: cn-speak-radiate 1.6s ease-out infinite;
}
#cortana-node.cn-speaking .cn-ring-2 {
  transform-box: fill-box; transform-origin: center;
  animation: cn-speak-radiate 1.6s ease-out infinite 0.4s;
}
#cortana-node.cn-speaking .cn-ring-3 {
  transform-box: fill-box; transform-origin: center;
  animation: cn-speak-radiate 1.6s ease-out infinite 0.8s;
}

/* Swap the core gradient depending on state. */
#cortana-node.cn-listening   .cn-core { fill: url(#cn-core-soft); }
#cortana-node.cn-recognizing .cn-core { fill: url(#cn-core-hot); }
#cortana-node.cn-speaking    .cn-core { fill: url(#cn-core-speak); }
#cortana-node.cn-thinking    .cn-core { fill: url(#cn-core-hot); }
#cortana-node.cn-bargein     .cn-core { fill: url(#cn-core-bargein); }

#cortana-node.cn-bargein .cn-armed {
  stroke-opacity: 0.95;
  animation: cn-armed-pulse 0.6s ease-in-out infinite;
}

@keyframes cn-armed-pulse {
  0%, 100% { transform: scale(0.95); stroke-opacity: 0.95; }
  50%      { transform: scale(1.08); stroke-opacity: 1.00; }
}

#cortana-node.cn-bargein .cn-armed {
  transform-box: fill-box;
  transform-origin: center;
}

/* ─── ROOM DETAIL PANEL ──────────────────────────── */

.floor-detail {
  position: absolute;
  z-index: 12;
  min-width: 220px;
  max-width: 320px;
  padding: 14px 16px;
  background: rgba(7, 12, 34, 0.92);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid color-mix(in srgb, var(--detail-accent, #6FD3FF) 50%, transparent);
  border-radius: 6px;
  box-shadow:
    0 0 0 1px rgba(74, 111, 255, 0.10),
    0 12px 36px rgba(0, 0, 0, 0.55),
    0 0 24px color-mix(in srgb, var(--detail-accent, #6FD3FF) 24%, transparent);
  color: var(--text-primary);
  font-family: var(--font-body);
  pointer-events: auto;
}

.floor-detail-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-family: var(--font-display);
  font-size: 0.78rem;
  letter-spacing: 0.32em;
  color: var(--detail-accent, #6FD3FF);
  text-shadow: 0 0 8px color-mix(in srgb, var(--detail-accent, #6FD3FF) 50%, transparent);
}

.floor-detail-close {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-size: 1.1rem;
  width: 32px;
  height: 32px;
  cursor: pointer;
  border-radius: 4px;
}
.floor-detail-close:active { background: rgba(74, 111, 255, 0.18); }

.floor-detail-status {
  margin-top: 6px;
  font-family: var(--font-display);
  font-size: 0.62rem;
  letter-spacing: 0.32em;
  color: var(--text-secondary);
}

.floor-detail-task {
  margin-top: 10px;
  font-size: 0.92rem;
  line-height: 1.45;
  color: var(--text-primary);
  min-height: 1.2em;
}

.floor-detail-readout {
  margin-top: 12px;
  display: flex;
  gap: 6px;
  align-items: baseline;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--text-secondary);
}

.floor-detail-sep { opacity: 0.4; }

.floor-detail-stop {
  margin-top: 14px;
  width: 100%;
  height: 36px;
  background: transparent;
  color: var(--accent-warn, #FF4A6F);
  border: 1px solid var(--accent-warn, #FF4A6F);
  border-radius: 4px;
  font-family: var(--font-display);
  font-size: 0.72rem;
  letter-spacing: 0.32em;
  cursor: pointer;
}
.floor-detail-stop:active { background: rgba(255, 74, 111, 0.16); }

/* ─── TEXT INPUT FALLBACK (long-press central node) ─── */

#text-input-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(2, 5, 14, 0.78);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.text-input-card {
  width: min(420px, 100%);
  background: var(--bg-elevated, #070C22);
  border: 1px solid var(--rule-strong);
  border-radius: 8px;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.55);
}

.text-input-title {
  font-family: var(--font-display);
  font-size: 0.72rem;
  letter-spacing: 0.42em;
  color: var(--accent-active);
}

#text-input-field {
  background: rgba(10, 18, 48, 0.6);
  border: 1px solid var(--rule-strong);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 1rem;
  padding: 10px 12px;
  border-radius: 4px;
  outline: none;
}

#text-input-field:focus {
  border-color: var(--accent-active);
  box-shadow: 0 0 0 2px rgba(111, 211, 255, 0.18);
}

.text-input-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.text-input-actions button {
  font-family: var(--font-display);
  font-size: 0.70rem;
  letter-spacing: 0.32em;
  padding: 8px 16px;
  background: transparent;
  border: 1px solid var(--rule-strong);
  color: var(--text-secondary);
  border-radius: 4px;
  cursor: pointer;
  min-height: 36px;
}

#text-input-send {
  color: var(--accent-active);
  border-color: var(--accent-active);
}

/* ─── REDUCED MOTION OVERRIDES (FLOOR) ───────────── */

@media (prefers-reduced-motion: reduce) {
  .room.idle .room-bg,
  .room.active .room-bg,
  .room.completed .room-bg,
  .room.completed.warden .room-bg,
  [class*="atlas-beams"],
  .forge-arm-l, .forge-arm-r,
  .sage-tome-glow, .sage-motes circle,
  .scribe-paper-l, .scribe-paper-r, .scribe-ink,
  .herald-arc-1, .herald-arc-2, .herald-arc-3,
  .lens-swatches rect,
  .quill-bars rect,
  .warden-scan,
  #cortana-node .cn-ring,
  #cortana-node .cn-armed {
    animation: none !important;
    transform: none !important;
  }
  /* Keep static state cues legible. */
  .room.active .room-bg { fill: color-mix(in srgb, var(--room-accent, #6FD3FF) 32%, rgba(10,18,48,0.85)); }
  #cortana-node.cn-listening   .cn-ring-1 { stroke-opacity: 0.65; }
  #cortana-node.cn-recognizing .cn-ring-1 { stroke-opacity: 0.95; }
  #cortana-node.cn-speaking    .cn-ring-1 { stroke: var(--glow-violet); stroke-opacity: 0.85; }
  #cortana-node.cn-bargein     .cn-armed  { stroke-opacity: 0.95; }
}

/* ─── v14 (conduit tooltip / hit-target) + v15 (speak particles) ─────────
   DISABLED in v16-hudfix: iPad Safari rendered the page blank after these
   shipped. The @keyframes animating SVG cx/cy with a unitless var() is the
   prime suspect; the v14 hit-target + tooltip are stripped together since
   the SHODAN aesthetic is being replaced by the isometric pivot anyway and
   neither block is worth diagnosing further. Kept commented for reference.

#conduit-tooltip {
  position: fixed;
  z-index: 9999;
  padding: 6px 10px;
  font: 11px/1 var(--font-mono, 'JetBrains Mono', ui-monospace, monospace);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #e8eaed;
  background: rgba(7, 12, 34, 0.92);
  border: 1px solid var(--rule-strong, rgba(255, 255, 255, 0.14));
  border-radius: 4px;
  pointer-events: none;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5);
}
#conduit-tooltip[hidden] { display: none; }

.conduit-hit {
  stroke: transparent;
  stroke-width: 24;
  pointer-events: stroke;
  cursor: pointer;
  fill: none;
}
@media (prefers-reduced-motion: reduce) {
  .conduit-hit { stroke-width: 32; }
}

.speak-particle {
  fill: var(--glow-violet, #B967DB);
  opacity: 0;
  pointer-events: none;
  filter: url(#fl-soft-glow);
}

@keyframes speak-particle-flow {
  0%   { cx: 800; cy: 800; opacity: 0; }
  12%  { opacity: 0.78; }
  88%  { opacity: 0.78; }
  100% { cx: var(--end-x); cy: var(--end-y); opacity: 0; }
}

#floor-svg.svg-speaking .speak-particle {
  animation: speak-particle-flow 1.8s linear infinite;
  animation-delay: var(--delay, 0s);
}

@media (prefers-reduced-motion: reduce) {
  #floor-svg.svg-speaking .speak-particle {
    animation: none;
    opacity: 0.45;
  }
}
*/
