:root {
  color-scheme: dark;
  --bg: #06060b;
  --bg-deep: #030308;
  --bg-grid: rgba(66, 232, 255, 0.04);
  --glass: rgba(14, 14, 22, 0.82);
  --glass-border: rgba(66, 232, 255, 0.16);
  --text: #e8edf5;
  --muted: #8b95a8;
  --cyan: #42e8ff;
  --cyan-dim: #1a3a48;
  --coral: #ff6b8a;
  --red: #ff6b6b;
  --green: #45e89a;
  --warn: #f0c050;
  --mag: #c47bff;
  --blue: #5b8cff;
  --orb-size: min(72vw, 280px);
  --radius: 14px;
  --font: "Segoe UI", system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  height: 100%;
  overflow-x: hidden;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
}

body {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background:
    radial-gradient(ellipse 80% 50% at 50% 0%, rgba(66, 232, 255, 0.08), transparent 60%),
    linear-gradient(180deg, var(--bg) 0%, var(--bg-deep) 100%);
}

.grid-bg {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(var(--bg-grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--bg-grid) 1px, transparent 1px);
  background-size: 32px 32px;
  opacity: 0.6;
}

.hud {
  position: relative;
  z-index: 1;
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: max(12px, env(safe-area-inset-top)) 16px max(12px, env(safe-area-inset-bottom));
  max-width: 480px;
  margin: 0 auto;
  width: 100%;
}

.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}

.brand {
  font-size: 0.72rem;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 700;
}

.safety-badge {
  padding: 5px 10px;
  border-radius: 999px;
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--cyan, #7ee8fa);
  border: 1px solid rgba(126, 232, 250, 0.35);
  background: rgba(8, 20, 32, 0.55);
}

.safety-badge.collab {
  color: #ffd966;
  border-color: rgba(255, 217, 102, 0.45);
  background: rgba(32, 24, 8, 0.65);
}

.vision-chip {
  padding: 5px 10px;
  border-radius: 999px;
  font-size: 0.58rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  border: 1px solid rgba(126, 232, 250, 0.25);
  background: rgba(8, 20, 32, 0.55);
  color: rgba(255, 255, 255, 0.45);
  white-space: nowrap;
}
.vision-chip.vision-off { color: rgba(255, 255, 255, 0.45); }
.vision-chip.vision-front,
.vision-chip.vision-rear {
  color: #7ee8fa;
  border-color: rgba(66, 232, 255, 0.55);
  background: rgba(0, 40, 55, 0.75);
  box-shadow: 0 0 12px rgba(66, 232, 255, 0.15);
}
.vision-chip.vision-analyzing {
  color: #45e89a;
  border-color: rgba(80, 250, 123, 0.45);
  background: rgba(0, 32, 20, 0.75);
}
.vision-chip.vision-error {
  color: #ff6b81;
  border-color: rgba(255, 107, 129, 0.5);
  background: rgba(40, 8, 16, 0.75);
}

body.vision-active .orb-wrap {
  box-shadow: 0 0 24px rgba(66, 232, 255, 0.08);
}

.conn-badge {
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  border: 1px solid var(--glass-border);
  background: var(--glass);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.line.link a {
  color: var(--cyan, #7ee8fa);
  text-decoration: none;
  word-break: break-all;
}
.line.link a:hover { text-decoration: underline; }

.line.media img,
.line.media video {
  display: block;
  max-width: 100%;
  border-radius: 10px;
  margin-top: 0.35rem;
  border: 1px solid var(--glass-border);
  background: rgba(0, 0, 0, 0.35);
}
.line.media video { width: 100%; }

.media-progress {
  position: relative;
  margin: 0 0.75rem 0.65rem;
  padding: 0.85rem 0.9rem 0.75rem;
  border-radius: 14px;
  border: 1px solid rgba(66, 232, 255, 0.35);
  background:
    linear-gradient(135deg, rgba(66, 232, 255, 0.07), rgba(168, 85, 247, 0.05)),
    rgba(6, 12, 22, 0.88);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  box-shadow:
    0 0 24px rgba(66, 232, 255, 0.08),
    inset 0 1px 0 rgba(255, 255, 255, 0.06);
  overflow: hidden;
}
.media-progress::before {
  content: "";
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 2px,
    rgba(66, 232, 255, 0.03) 2px,
    rgba(66, 232, 255, 0.03) 4px
  );
  pointer-events: none;
  opacity: 0.6;
}
.media-progress.active {
  animation: media-progress-pulse 2.4s ease-in-out infinite;
}
.media-progress.hidden { display: none; }
.media-progress-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.4rem;
  position: relative;
  z-index: 1;
}
.media-progress-badge {
  font-size: 0.62rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: rgba(66, 232, 255, 0.95);
}
.media-progress-pct {
  font-size: 1.05rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: #dffcff;
  text-shadow: 0 0 12px rgba(66, 232, 255, 0.45);
}
.media-progress-label {
  font-size: 0.78rem;
  color: var(--cyan, #7ee8fa);
  margin-bottom: 0.55rem;
  position: relative;
  z-index: 1;
  line-height: 1.35;
}
.media-progress-track {
  position: relative;
  height: 10px;
  border-radius: 999px;
  overflow: hidden;
  z-index: 1;
}
.media-progress-track-bg {
  position: absolute;
  inset: 0;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 999px;
}
.media-progress-bar {
  position: relative;
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: linear-gradient(90deg, #42e8ff, #45e89a 55%, #a855f7);
  box-shadow: 0 0 14px rgba(66, 232, 255, 0.55);
  transition: width 0.55s cubic-bezier(0.22, 1, 0.36, 1);
}
.media-progress-scan {
  position: absolute;
  inset: 0;
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(255, 255, 255, 0.35) 48%,
    transparent 100%
  );
  width: 40%;
  animation: media-progress-scan 1.8s ease-in-out infinite;
  pointer-events: none;
  opacity: 0.5;
}
.media-progress-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-top: 0.45rem;
  position: relative;
  z-index: 1;
}
.media-progress-phase {
  font-size: 0.62rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  padding: 0.2rem 0.45rem;
  border-radius: 6px;
  border: 1px solid rgba(168, 85, 247, 0.35);
  color: #c4b5fd;
  background: rgba(168, 85, 247, 0.1);
}
.media-progress-eta {
  font-size: 0.68rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.media-progress.error .media-progress-bar {
  background: linear-gradient(90deg, #ff4466, #ff8844);
  box-shadow: 0 0 12px rgba(255, 68, 102, 0.45);
}
.media-progress.complete .media-progress-bar {
  background: linear-gradient(90deg, #45e89a, #42e8ff);
}
@keyframes media-progress-scan {
  0% { transform: translateX(-120%); }
  100% { transform: translateX(320%); }
}
@keyframes media-progress-pulse {
  0%, 100% { box-shadow: 0 0 24px rgba(66, 232, 255, 0.08), inset 0 1px 0 rgba(255, 255, 255, 0.06); }
  50% { box-shadow: 0 0 32px rgba(66, 232, 255, 0.16), inset 0 1px 0 rgba(255, 255, 255, 0.08); }
}

.media-viewer {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(2, 5, 12, 0.88);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.75rem;
}
.media-viewer.hidden { display: none; }
.media-viewer-panel {
  position: relative;
  width: min(96vw, 920px);
  max-height: 92vh;
  background:
    linear-gradient(160deg, rgba(10, 18, 32, 0.98), rgba(6, 10, 18, 0.96));
  border: 1px solid rgba(66, 232, 255, 0.32);
  border-radius: 16px;
  padding: 0.85rem;
  box-shadow:
    0 0 40px rgba(66, 232, 255, 0.1),
    0 24px 64px rgba(0, 0, 0, 0.55);
}
.media-viewer-panel.floating-panel {
  z-index: 210;
  max-height: min(72vh, 520px);
}
.media-viewer-drag {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  margin: -0.25rem 0 0.5rem;
  padding: 0.35rem 0.5rem;
  border-radius: 8px;
  cursor: grab;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}
.media-viewer-drag:active { cursor: grabbing; }
.media-viewer-grip {
  color: var(--muted);
  font-size: 0.75rem;
  letter-spacing: -0.12em;
  opacity: 0.85;
}
.media-viewer-panel.floating-dragging {
  box-shadow: 0 28px 72px rgba(66, 232, 255, 0.12), 0 24px 64px rgba(0, 0, 0, 0.6);
}
.media-viewer-close {
  position: absolute;
  top: 0.5rem;
  right: 0.55rem;
  z-index: 3;
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(0, 0, 0, 0.5);
  color: #fff;
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
}
.media-viewer-close:hover { background: rgba(255, 68, 102, 0.4); }
.media-viewer-badge {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--cyan, #7ee8fa);
  margin: 0;
}
.media-viewer-stage {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 42vh;
  max-height: 68vh;
  overflow: hidden;
}
.media-viewer-stage img,
.media-viewer-stage video {
  max-width: 100%;
  max-height: 68vh;
  border-radius: 10px;
}
.media-viewer-toolbar {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  margin-top: 0.75rem;
  flex-wrap: wrap;
}
.media-viewer-save {
  padding: 0.5rem 0.85rem;
  border-radius: 8px;
  background: linear-gradient(90deg, #45e89a, #7ee8fa);
  color: #041018;
  font-weight: 700;
  font-size: 0.8rem;
  text-decoration: none;
}
.media-viewer-expiry { font-size: 0.72rem; color: var(--muted); flex: 1; }
.media-viewer-keep {
  padding: 0.5rem 0.85rem;
  border-radius: 8px;
  border: 1px solid rgba(126, 232, 250, 0.35);
  background: rgba(66, 232, 255, 0.08);
  color: var(--text);
  font-weight: 600;
  font-size: 0.8rem;
  cursor: pointer;
}
.media-viewer-keep:disabled { opacity: 0.45; cursor: default; }
.media-viewer-nav { font-size: 0.72rem; color: var(--muted); }

.quota-badge {
  font-size: 0.62rem;
  padding: 0.28rem 0.45rem;
  border-radius: 999px;
  border: 1px solid rgba(126, 232, 250, 0.25);
  background: rgba(66, 232, 255, 0.06);
  color: var(--cyan);
  white-space: nowrap;
  max-width: 42vw;
  overflow: hidden;
  text-overflow: ellipsis;
}
.quota-badge.exhausted {
  border-color: rgba(255, 68, 102, 0.35);
  color: #ff99aa;
  background: rgba(255, 68, 102, 0.08);
}
.credits-badge {
  font-size: 0.62rem;
  padding: 0.28rem 0.45rem;
  border-radius: 999px;
  border: 1px solid rgba(126, 232, 250, 0.25);
  background: rgba(66, 232, 255, 0.06);
  color: var(--cyan);
  white-space: nowrap;
  max-width: 38vw;
  overflow: hidden;
  text-overflow: ellipsis;
}
.credits-badge.warn {
  border-color: rgba(255, 200, 80, 0.45);
  color: #ffd080;
}
.credits-badge.exhausted {
  border-color: rgba(255, 68, 102, 0.35);
  color: #ff99aa;
  background: rgba(255, 68, 102, 0.08);
}
.quota-banner {
  margin: 0 0 0.5rem;
  padding: 0.55rem 0.7rem;
  border-radius: 10px;
  border: 1px solid rgba(255, 68, 102, 0.35);
  background: rgba(255, 68, 102, 0.1);
  color: #ffc9d2;
  font-size: 0.74rem;
  line-height: 1.35;
}
.quota-banner.hidden { display: none; }

.insecure-mic-banner {
  margin: 0 0 0.5rem;
  padding: 0.65rem 0.75rem;
  border-radius: 10px;
  border: 1px solid rgba(240, 192, 80, 0.4);
  background: rgba(240, 192, 80, 0.12);
  color: #f5e6b8;
  font-size: 0.78rem;
  line-height: 1.4;
}
.insecure-mic-banner.hidden { display: none; }
.insecure-mic-banner a { color: var(--cyan); word-break: break-all; }
.insecure-mic-banner p { margin: 0.35rem 0 0; }

.media-context-card {
  margin: 0 0 0.5rem;
  padding: 0.65rem 0.75rem;
  border-radius: 10px;
  font-size: 0.78rem;
  line-height: 1.4;
}
.media-context-card[data-state="checking"] {
  border: 1px solid rgba(139, 149, 168, 0.35);
  background: rgba(14, 14, 22, 0.55);
  color: var(--muted);
}
.media-context-card[data-state="secure"] {
  border: 1px solid rgba(69, 232, 154, 0.35);
  background: rgba(69, 232, 154, 0.08);
  color: #c8f6dc;
}
.media-context-card[data-state="insecure"] {
  border: 1px solid rgba(240, 192, 80, 0.45);
  background: rgba(240, 192, 80, 0.12);
  color: #f5e6b8;
}
.media-context-card strong { display: block; margin-bottom: 0.25rem; }
.media-context-list { margin: 0; padding-left: 1.1rem; }
.media-context-hint { margin: 0.4rem 0 0; }
.media-context-hint.hidden,
.media-context-cta.hidden { display: none; }
.media-context-cta {
  display: inline-block;
  margin-top: 0.55rem;
  padding: 0.45rem 0.75rem;
  border-radius: 8px;
  background: var(--cyan);
  color: #061016;
  font-weight: 700;
  text-decoration: none;
  touch-action: manipulation;
}
.quota-banner-actions { margin-top: 0.35rem; display: flex; gap: 0.5rem; flex-wrap: wrap; }
.quota-banner-actions button {
  padding: 0.35rem 0.65rem;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  background: rgba(0, 0, 0, 0.35);
  color: #fff;
  font-size: 0.72rem;
  cursor: pointer;
}

.phone-verify-card {
  margin: 0 0.75rem 0.65rem;
  padding: 0.75rem;
  border-radius: 12px;
  border: 1px solid rgba(0, 212, 255, 0.35);
  background: linear-gradient(145deg, rgba(0, 40, 60, 0.85), rgba(0, 20, 35, 0.9));
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}
.phone-verify-card.hidden { display: none; }
.phone-verify-inner h3 {
  margin: 0 0 0.35rem;
  font-size: 0.95rem;
  color: #7ee8ff;
}
.phone-verify-sub {
  margin: 0 0 0.65rem;
  font-size: 0.72rem;
  color: rgba(255, 255, 255, 0.65);
  line-height: 1.35;
}
.phone-verify-card label {
  display: block;
  font-size: 0.68rem;
  color: rgba(255, 255, 255, 0.55);
  margin: 0.45rem 0 0.2rem;
}
.phone-verify-card input {
  width: 100%;
  box-sizing: border-box;
  padding: 0.55rem 0.65rem;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(0, 0, 0, 0.35);
  color: #fff;
  font-size: 0.85rem;
}
.phone-verify-btn {
  margin-top: 0.55rem;
  width: 100%;
  padding: 0.55rem;
  border-radius: 8px;
  border: 1px solid rgba(0, 212, 255, 0.35);
  background: rgba(0, 80, 100, 0.45);
  color: #b8f4ff;
  font-size: 0.78rem;
  cursor: pointer;
}
.phone-verify-btn.primary {
  background: linear-gradient(90deg, rgba(0, 180, 220, 0.55), rgba(0, 120, 200, 0.55));
  color: #fff;
  font-weight: 600;
}
.phone-verify-msg {
  margin: 0.5rem 0 0;
  font-size: 0.72rem;
  color: rgba(255, 255, 255, 0.75);
  min-height: 1em;
}
.phone-verify-dismiss {
  margin-top: 0.35rem;
  background: none;
  border: none;
  color: rgba(255, 255, 255, 0.45);
  font-size: 0.68rem;
  cursor: pointer;
  text-decoration: underline;
}

.fab-camera {
  position: fixed;
  right: max(1rem, env(safe-area-inset-right));
  bottom: calc(5.5rem + env(safe-area-inset-bottom));
  z-index: 120;
  width: 3.25rem;
  height: 3.25rem;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(12, 20, 32, 0.85);
  backdrop-filter: blur(8px);
  color: #fff;
  font-size: 1.35rem;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.45);
  cursor: pointer;
}
.fab-camera:active { transform: scale(0.95); }
.fab-camera.hidden { display: none !important; }
.camera-bubble {
  position: fixed;
  right: max(1rem, env(safe-area-inset-right));
  bottom: calc(9.25rem + env(safe-area-inset-bottom));
  z-index: 130;
  width: 11.5rem;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(8, 12, 20, 0.96);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.5);
  overflow: hidden;
}
.camera-bubble.hidden { display: none; }
.camera-bubble-item {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  width: 100%;
  padding: 0.7rem 0.85rem;
  border: 0;
  background: transparent;
  color: #e8ecf4;
  text-align: left;
  cursor: pointer;
}
.camera-bubble-item:hover { background: rgba(255, 255, 255, 0.05); }
.camera-bubble-item small { display: block; color: var(--muted); font-size: 0.68rem; }
.camera-bubble-icon { font-size: 1.2rem; }

.live-vision {
  position: fixed;
  isolation: isolate;
  right: max(0.75rem, env(safe-area-inset-right));
  bottom: calc(9.5rem + env(safe-area-inset-bottom));
  z-index: 110;
  width: min(46vw, 220px);
  border-radius: 16px;
  overflow: hidden;
  border: 1px solid rgba(66, 232, 255, 0.4);
  box-shadow:
    0 0 0 1px rgba(126, 232, 250, 0.12),
    0 16px 40px rgba(0, 0, 0, 0.55),
    inset 0 1px 0 rgba(255, 255, 255, 0.06);
  background: linear-gradient(165deg, rgba(8, 24, 36, 0.92), rgba(0, 0, 0, 0.95));
  touch-action: none;
  backdrop-filter: blur(8px);
}
.live-vision.hidden { display: none; }
.live-vision.floating-dragging {
  box-shadow: 0 16px 40px rgba(66, 232, 255, 0.18), 0 12px 32px rgba(0, 0, 0, 0.55);
  z-index: 125;
}
.live-vision-drag {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.3rem 0.45rem;
  background: rgba(0, 0, 0, 0.72);
  border-bottom: 1px solid rgba(126, 232, 250, 0.2);
  font-size: 0.62rem;
  color: #dffcff;
  cursor: grab;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}
.live-vision-drag:active { cursor: grabbing; }
.live-vision-grip {
  color: var(--muted);
  font-size: 0.7rem;
  letter-spacing: -0.12em;
}
.live-vision-video {
  display: block;
  width: 100%;
  height: auto;
  max-height: 34vh;
  object-fit: cover;
}
.live-vision-canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}
.live-vision-hud {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.35rem;
  padding: 0.35rem 0.45rem;
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.75));
  font-size: 0.62rem;
  color: #dffcff;
}
.live-vision-mode {
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #7ee8fa;
  font-size: 0.58rem;
}
.live-vision-stop {
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(255, 68, 102, 0.35);
  color: #fff;
  border-radius: 6px;
  padding: 0.2rem 0.45rem;
  font-size: 0.62rem;
  cursor: pointer;
}

.hud-toast {
  position: fixed;
  left: 50%;
  bottom: calc(6.5rem + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 140;
  padding: 0.45rem 0.85rem;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.82);
  color: #fff;
  font-size: 0.78rem;
  pointer-events: none;
}

.conn-badge.offline { color: var(--muted); border-color: #333; }
.conn-badge.connected { color: var(--green); box-shadow: 0 0 12px rgba(80, 250, 123, 0.2); }
.conn-badge.reconnecting { color: var(--warn); animation: badge-pulse 1.2s infinite; }
.conn-badge.backend-down { color: var(--warn); }
.conn-badge.error { color: var(--red); box-shadow: 0 0 12px rgba(255, 68, 102, 0.25); }

@keyframes badge-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.55; }
}

.orb-stage {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 280px;
  padding: 16px 0;
}

.orb-wrap {
  position: relative;
  width: var(--orb-size);
  height: var(--orb-size);
  display: flex;
  align-items: center;
  justify-content: center;
}

.orb-btn {
  position: relative;
  width: 100%;
  height: 100%;
  border: none;
  background: transparent;
  cursor: pointer;
  padding: 0;
  border-radius: 50%;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  z-index: 2;
  pointer-events: auto;
}
.orb-btn:focus-visible {
  outline: 2px solid rgba(126, 232, 250, 0.55);
  outline-offset: 4px;
}

.orb-core {
  position: absolute;
  inset: 18%;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #1a3040 0%, #0a1218 70%);
  border: 1px solid rgba(66, 232, 255, 0.15);
  box-shadow: inset 0 0 40px rgba(0, 0, 0, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.wave-bars {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 4px;
  height: 48px;
  opacity: 0;
  transition: opacity 0.3s;
}

.wave-bars span {
  width: 4px;
  height: 8px;
  border-radius: 2px;
  background: var(--cyan);
  animation: wave-idle 0.8s ease-in-out infinite;
}

.wave-bars span:nth-child(2) { animation-delay: 0.1s; }
.wave-bars span:nth-child(3) { animation-delay: 0.2s; }
.wave-bars span:nth-child(4) { animation-delay: 0.15s; }
.wave-bars span:nth-child(5) { animation-delay: 0.05s; }

@keyframes wave-idle {
  0%, 100% { height: 8px; opacity: 0.4; }
  50% { height: 28px; opacity: 1; }
}

.ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 2px solid transparent;
  pointer-events: none;
}

.ring-1 { inset: 0; }
.ring-2 { inset: 6%; }
.ring-3 { inset: 12%; }

.scan-line {
  position: absolute;
  inset: 8%;
  border-radius: 50%;
  background: conic-gradient(from 0deg, transparent 0deg, rgba(66, 232, 255, 0.35) 40deg, transparent 80deg);
  opacity: 0;
  pointer-events: none;
}

.state-label {
  margin-top: 20px;
  text-align: center;
}

.state-title {
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  margin: 0;
}

.state-sub {
  margin: 6px 0 0;
  font-size: 0.88rem;
  color: var(--muted);
}

.transcript-panel {
  margin-top: auto;
  padding: 14px 16px;
  border-radius: var(--radius);
  background: var(--glass);
  border: 1px solid var(--glass-border);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  max-height: 140px;
  overflow-y: auto;
  font-size: 0.85rem;
  line-height: 1.45;
  min-height: 52px;
}

.transcript-panel .line { margin: 0 0 8px; }
.transcript-panel .line.user { color: var(--cyan); }
.transcript-panel .line.hydra { color: var(--text); }
.transcript-panel .line.sys { color: var(--muted); font-size: 0.78rem; text-align: center; }

.command-drawer {
  display: flex;
  gap: 8px;
  margin-top: 10px;
  align-items: flex-end;
}

.command-drawer input {
  flex: 1;
  min-height: 44px;
  padding: 10px 14px;
  border-radius: 14px;
  border: 1px solid var(--glass-border);
  background: rgba(0, 0, 0, 0.35);
  color: var(--text);
  font: inherit;
  font-size: 0.9rem;
}

.command-drawer input::placeholder { color: var(--muted); }

.command-drawer button {
  min-height: 44px;
  padding: 0 16px;
  border: 0;
  border-radius: 14px;
  background: linear-gradient(135deg, #1a5a66, #0d3a44);
  color: var(--cyan);
  font-weight: 700;
  cursor: pointer;
}

.call-action {
  width: 100%;
  margin-top: 12px;
  padding: 15px 18px;
  border: 1px solid rgba(92, 255, 178, 0.35);
  border-radius: 999px;
  background:
    linear-gradient(135deg, rgba(92, 255, 178, 0.18), rgba(56, 233, 255, 0.12)),
    rgba(255, 255, 255, 0.06);
  color: #dfffee;
  font-weight: 900;
  letter-spacing: 0.04em;
  box-shadow: 0 0 28px rgba(92, 255, 178, 0.18);
  cursor: pointer;
  font: inherit;
  font-size: 0.82rem;
  text-transform: uppercase;
}

.call-action:disabled {
  opacity: 0.42;
  cursor: not-allowed;
  filter: grayscale(0.7);
  box-shadow: none;
}

.emergency {
  margin-top: 8px;
  width: 100%;
  padding: 10px;
  border: 1px solid rgba(255, 68, 102, 0.25);
  border-radius: 12px;
  background: transparent;
  color: rgba(255, 136, 136, 0.7);
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
}

.emergency.active {
  border-color: rgba(255, 68, 102, 0.65);
  background: rgba(255, 40, 60, 0.12);
  color: #ff8899;
  box-shadow: 0 0 16px rgba(255, 68, 102, 0.25);
}

.emergency-clear {
  margin-top: 6px;
  width: 100%;
  padding: 8px;
  border: 1px solid rgba(66, 232, 255, 0.25);
  border-radius: 10px;
  background: transparent;
  color: rgba(126, 232, 255, 0.85);
  font-size: 0.7rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  cursor: pointer;
}

.emergency-status {
  margin-top: 6px;
  font-size: 0.72rem;
  color: rgba(255, 136, 136, 0.85);
  text-align: center;
  line-height: 1.35;
}

body.emergency-stop-active .call-action:not(:disabled) {
  opacity: 0.45;
  pointer-events: none;
}

body.emergency-stop-active.state-listening .orb-core,
body.emergency-stop-active.state-speaking .orb-core {
  box-shadow: inset 0 0 40px rgba(255, 40, 60, 0.35);
}

/* ── State: Muted ── */
body.state-muted .ring-1 {
  border-color: rgba(90, 122, 138, 0.35);
  box-shadow: 0 0 20px rgba(90, 122, 138, 0.1);
}
body.state-muted .orb-core {
  box-shadow: inset 0 0 30px rgba(0, 0, 0, 0.9);
}

/* ── State: Listening ── */
body.state-listening .ring-1 {
  border-color: var(--cyan);
  animation: ring-pulse 1.4s ease-in-out infinite;
  box-shadow: 0 0 24px rgba(66, 232, 255, 0.35);
}
body.state-listening .ring-2 {
  border-color: rgba(66, 232, 255, 0.25);
  animation: ring-pulse 1.4s ease-in-out infinite 0.2s;
}
body.state-listening .wave-bars { opacity: 1; }
body.state-listening .state-title { color: var(--cyan); }

@keyframes ring-pulse {
  0%, 100% { transform: scale(1); opacity: 0.85; }
  50% { transform: scale(1.03); opacity: 1; }
}

/* ── State: Thinking ── */
body.state-connecting .ring-1 {
  border-color: var(--cyan-dim);
  animation: ring-pulse 1.6s ease-in-out infinite;
}
body.state-connecting .state-title { color: var(--cyan); }
body.state-connecting .state-sub { color: var(--muted); }

body.state-thinking .ring-1 { border-color: var(--warn); }
body.state-thinking .scan-line {
  opacity: 1;
  animation: scan-spin 1.2s linear infinite;
}
body.state-thinking .state-title { color: var(--warn); }

@keyframes scan-spin {
  to { transform: rotate(360deg); }
}

/* ── State: Speaking ── */
body.state-speaking .ring-1 {
  border-color: var(--coral);
  box-shadow: 0 0 32px rgba(224, 108, 117, 0.45);
  animation: speak-glow 0.6s ease-in-out infinite alternate;
}
body.state-speaking .ring-2 {
  border-color: rgba(224, 108, 117, 0.3);
}
body.state-speaking .orb-core {
  box-shadow: inset 0 0 50px rgba(224, 108, 117, 0.25);
}
body.state-speaking .wave-bars { opacity: 1; }
body.state-speaking .wave-bars span {
  background: var(--coral);
  animation: wave-speak 0.35s ease-in-out infinite;
}
body.state-speaking .state-title { color: var(--coral); }

@keyframes speak-glow {
  from { transform: scale(1); }
  to { transform: scale(1.02); }
}

@keyframes wave-speak {
  0%, 100% { height: 10px; }
  50% { height: 36px; }
}

/* ── State: Error ── */
body.state-error .ring-1 {
  border-color: var(--red);
  animation: error-pulse 0.8s ease-in-out infinite;
  box-shadow: 0 0 28px rgba(255, 68, 102, 0.4);
}
body.state-error .state-title { color: var(--red); }

@keyframes error-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.login-gate {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(5, 8, 15, 0.92);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  padding: 24px;
}

.login-gate.hidden { display: none; }

.hidden { display: none !important; }

.login-panel {
  width: 100%;
  max-width: 320px;
  padding: 24px 20px;
  border-radius: var(--radius);
  background: var(--glass);
  border: 1px solid var(--glass-border);
  text-align: center;
}

.login-panel h2 {
  margin: 0 0 6px;
  color: var(--cyan);
  font-size: 1.2rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.login-sub {
  margin: 0 0 16px;
  font-size: 0.82rem;
  color: var(--muted);
}

.login-panel input {
  width: 100%;
  margin-bottom: 10px;
  min-height: 44px;
  padding: 10px 14px;
  border-radius: 14px;
  border: 1px solid var(--glass-border);
  background: rgba(0, 0, 0, 0.35);
  color: var(--text);
  font: inherit;
}

.login-panel button {
  width: 100%;
  min-height: 44px;
  border: 0;
  border-radius: 14px;
  background: linear-gradient(135deg, #1a5a66, #0d3a44);
  color: var(--cyan);
  font-weight: 700;
  cursor: pointer;
}

.login-err {
  margin: 10px 0 0;
  min-height: 1.2em;
  font-size: 0.8rem;
  color: var(--red);
}

.hud.locked {
  pointer-events: none;
  opacity: 0.35;
  filter: blur(2px);
}

body.surface-phone-desktop .hud {
  max-width: min(960px, 94vw);
  margin-left: auto;
  margin-right: auto;
}

body.surface-phone-desktop {
  --orb-size: min(36vw, 300px);
}

body.surface-phone-desktop .gate-panel {
  max-width: 520px;
}

/* Fixed orb + Agent Console */
.orb-wrap {
  position: relative !important;
  left: auto !important;
  top: auto !important;
  right: auto !important;
  bottom: auto !important;
  margin: 0 auto !important;
  cursor: pointer;
}

.agent-console {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: max(12px, env(safe-area-inset-top)) 12px max(12px, env(safe-area-inset-bottom));
  background: rgba(4, 6, 12, 0.55);
  backdrop-filter: blur(8px);
}
.agent-console.hidden { display: none !important; }
.agent-console-panel {
  width: min(920px, 96vw);
  height: min(720px, 88vh);
  display: flex;
  flex-direction: column;
  border-radius: 16px;
  border: 1px solid rgba(126, 232, 250, 0.22);
  background:
    linear-gradient(165deg, rgba(14, 22, 34, 0.96), rgba(8, 10, 18, 0.98));
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.55);
  overflow: hidden;
}
.agent-console-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  cursor: grab;
  touch-action: none;
}
.agent-console-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.agent-console-mark {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: #7ee8fa;
  border: 1px solid rgba(126, 232, 250, 0.35);
  background: radial-gradient(circle at 35% 30%, #1a3040, #0a1218);
  flex-shrink: 0;
}
.agent-console-brand strong {
  display: block;
  font-size: 12px;
  letter-spacing: 0.14em;
  color: #e8f7ff;
}
.agent-console-sub {
  display: block;
  font-size: 11px;
  color: rgba(180, 200, 220, 0.7);
}
.agent-console-close {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: transparent;
  color: #cfe8f4;
  font-size: 22px;
  cursor: pointer;
}
.agent-console-rails {
  flex: 1;
  display: grid;
  grid-template-columns: 148px 1fr;
  min-height: 0;
}
@media (max-width: 640px) {
  .agent-console-rails { grid-template-columns: 1fr; }
  .agent-console-providers {
    display: flex !important;
    flex-direction: row !important;
    overflow-x: auto;
    border-right: none !important;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    padding: 8px !important;
    gap: 8px;
  }
  .agent-chip { min-width: 92px; }
}
.agent-console-providers {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px;
  border-right: 1px solid rgba(255, 255, 255, 0.06);
  overflow: auto;
}
.agent-chip {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 10px;
  border-radius: 12px;
  border: 1px solid rgba(126, 232, 250, 0.12);
  background: rgba(255, 255, 255, 0.03);
  color: #d7ecf7;
  font-size: 12px;
  font-weight: 600;
}
.agent-chip span {
  font-size: 10px;
  font-weight: 500;
  color: rgba(160, 180, 200, 0.75);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.agent-chip.is-hydra {
  border-color: rgba(126, 232, 250, 0.45);
  box-shadow: inset 0 0 18px rgba(66, 232, 255, 0.08);
}
.agent-chip.is-dim { opacity: 0.45; }
.agent-chip.is-live span { color: #50fa7b; }
.agent-console-main {
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.agent-transcript {
  flex: 1;
  overflow: auto;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.agent-line {
  max-width: 92%;
  padding: 10px 12px;
  border-radius: 12px;
  font-size: 13px;
  line-height: 1.45;
  white-space: pre-wrap;
}
.agent-line.sys {
  align-self: center;
  color: rgba(180, 200, 220, 0.75);
  background: transparent;
  border: 1px dashed rgba(255, 255, 255, 0.08);
}
.agent-line.user {
  align-self: flex-end;
  background: rgba(66, 232, 255, 0.12);
  border: 1px solid rgba(66, 232, 255, 0.2);
  color: #eafcff;
}
.agent-line.hydra {
  align-self: flex-start;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: #dfeaf3;
}
.agent-composer {
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.agent-composer textarea {
  width: 100%;
  resize: none;
  border-radius: 12px;
  border: 1px solid rgba(126, 232, 250, 0.18);
  background: rgba(0, 0, 0, 0.35);
  color: #e8f7ff;
  padding: 12px;
  font: inherit;
  font-size: 14px;
}
.agent-composer-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}
.agent-voice-btn,
.agent-send-btn {
  border-radius: 10px;
  border: 1px solid rgba(126, 232, 250, 0.25);
  padding: 10px 14px;
  cursor: pointer;
  font-weight: 600;
}
.agent-voice-btn {
  background: transparent;
  color: #9fd7e8;
}
.agent-send-btn {
  background: linear-gradient(135deg, #1b6f84, #0e3a4a);
  color: #e8fbff;
}

/* Photosensitive Calm Mode — kill HUD flash/pulse animations */
.calm-mode-btn {
  appearance: none;
  border: 1px solid rgba(255, 196, 86, 0.7);
  background: rgba(28, 18, 4, 0.9);
  color: #ffe7a8;
  font: inherit;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 6px 10px;
  border-radius: 8px;
  cursor: pointer;
  touch-action: manipulation;
}
.calm-mode-btn.is-active {
  border-color: rgba(110, 220, 160, 0.75);
  background: rgba(6, 28, 18, 0.94);
  color: #b8f5d0;
}

html.hydra-calm-mode .ring-1,
html.hydra-calm-mode .ring-2,
html.hydra-calm-mode .ring-3,
html.hydra-calm-mode .wave-bar,
html.hydra-calm-mode .conn-badge.reconnecting,
html.hydra-calm-mode .media-progress,
html.hydra-calm-mode .speak-glow,
html.hydra-calm-mode [class*="pulse"],
html.hydra-photosensitive-safe .ring-1,
html.hydra-photosensitive-safe .ring-2,
html.hydra-photosensitive-safe .ring-3,
html.hydra-photosensitive-safe .wave-bar,
html.hydra-photosensitive-safe .conn-badge.reconnecting,
html.hydra-photosensitive-safe .media-progress,
html.hydra-photosensitive-safe .speak-glow,
html.hydra-photosensitive-safe [class*="pulse"],
body.hydra-calm-mode .ring-1,
body.hydra-calm-mode .ring-2,
body.hydra-calm-mode .ring-3,
body.hydra-calm-mode .wave-bar,
body.hydra-calm-mode .conn-badge.reconnecting,
body.hydra-calm-mode [class*="pulse"] {
  animation: none !important;
}
