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

:root {
  --bg: #08080d;
  --bg2: #0e0e16;
  --bg3: #141420;
  --border: #1e1e33;
  --border2: #2a2a44;
  --text: #d8d8ee;
  --text2: #8888aa;
  --text3: #555570;
  --accent: #7c6cf0;
  --accent2: #a8a0ff;
  --accent-glow: rgba(124, 108, 240, 0.25);
  --green: #00e676;
  --green-glow: rgba(0, 230, 118, 0.3);
  --yellow: #ffd740;
  --red: #ff5252;
  --orange: #ff9100;
  --mono: 'JetBrains Mono', monospace;
  --sans: 'Space Grotesk', sans-serif;
}

body {
  font-family: var(--sans);
  background: var(--bg);
  color: var(--text);
  height: 100vh;
  overflow: hidden;
}

/* ── Background ────────────────────────────────────────── */
.bg-grid {
  position: fixed; inset: 0;
  background-image:
    linear-gradient(rgba(124,108,240,0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(124,108,240,0.025) 1px, transparent 1px);
  background-size: 50px 50px;
  pointer-events: none; z-index: 0;
}
.noise {
  position: fixed; inset: 0; opacity: 0.02;
  background: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  pointer-events: none; z-index: 0;
}

/* ── Layout ────────────────────────────────────────────── */
.scene-page {
  position: relative; z-index: 1;
  display: flex; flex-direction: column;
  height: 100vh;
}

/* ── Top Bar ───────────────────────────────────────────── */
.top-bar {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 28px;
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.top-left { display: flex; align-items: center; gap: 10px; }
.logo-icon { font-size: 1.4rem; }
.logo-text { font-family: var(--mono); font-weight: 700; font-size: 1.1rem; color: var(--accent2); letter-spacing: -0.5px; }

.status-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--red); margin-left: 8px;
  animation: pulse-dot 1.5s ease-in-out infinite;
}
.status-dot.online { background: var(--green); box-shadow: 0 0 10px var(--green-glow); animation: none; }

@keyframes pulse-dot {
  0%,100% { opacity: 1; } 50% { opacity: 0.3; }
}

.status-text { font-family: var(--mono); font-size: 0.7rem; color: var(--text3); letter-spacing: 1px; }

.top-right { display: flex; align-items: center; gap: 14px; }
.clock { font-family: var(--mono); font-size: 0.85rem; color: var(--text2); }
.model-tag {
  font-family: var(--mono); font-size: 0.65rem; color: var(--accent2);
  background: rgba(124,108,240,0.1); border: 1px solid rgba(124,108,240,0.2);
  padding: 3px 10px; border-radius: 12px;
}

/* ── Character Scene ───────────────────────────────────── */
.character-scene {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 30px;
  padding: 20px;
  min-height: 0;
  overflow: hidden;
}

/* ── Main Character ────────────────────────────────────── */
.main-character {
  display: flex; flex-direction: column; align-items: center;
  position: relative;
}

/* Thought Bubble */
.thought-bubble {
  position: relative;
  background: var(--bg3);
  border: 1px solid var(--border2);
  border-radius: 14px;
  padding: 10px 18px;
  margin-bottom: 14px;
  max-width: 340px;
  text-align: center;
  animation: floatIn 0.4s ease;
}
.thought-text {
  font-family: var(--mono); font-size: 0.8rem; color: var(--text);
  line-height: 1.5;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: block;
  max-width: 300px;
}
.thought-tail {
  position: absolute;
  bottom: -8px; left: 50%;
  transform: translateX(-50%) rotate(45deg);
  width: 14px; height: 14px;
  background: var(--bg3);
  border-right: 1px solid var(--border2);
  border-bottom: 1px solid var(--border2);
}

@keyframes floatIn {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Avatar */
.avatar-wrapper {
  position: relative;
  width: 140px; height: 170px;
  display: flex; align-items: center; justify-content: center;
}

.avatar-shadow {
  position: relative;
  width: 120px; height: 160px;
  animation: ghostFloat 3s ease-in-out infinite;
}

@keyframes ghostFloat {
  0%,100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}

.shadow-svg {
  width: 100%; height: 100%;
  filter: drop-shadow(0 0 20px rgba(200,200,230,0.15));
  transition: filter 0.3s ease;
}

.shadow-svg.active {
  filter: drop-shadow(0 0 30px rgba(124,108,240,0.3));
}

.aura {
  position: absolute;
  inset: -20px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(124,108,240,0.08) 0%, transparent 70%);
  animation: auraGlow 2s ease-in-out infinite alternate;
  pointer-events: none;
}

@keyframes auraGlow {
  from { opacity: 0.5; transform: scale(0.95); }
  to { opacity: 1; transform: scale(1.1); }
}

.aura.working {
  background: radial-gradient(circle, rgba(124,108,240,0.15) 0%, transparent 70%);
}

.aura.idle {
  background: radial-gradient(circle, rgba(0,230,118,0.08) 0%, transparent 70%);
}

/* Character Info */
.char-name {
  font-family: var(--mono); font-weight: 700; font-size: 1rem;
  letter-spacing: 3px; color: var(--accent2);
  margin-top: 10px;
}
.char-role {
  font-size: 0.75rem; color: var(--text3); margin-top: 2px;
}
.char-mood {
  font-family: var(--mono); font-size: 0.7rem; color: var(--text2);
  margin-top: 6px;
  background: var(--bg3); padding: 3px 12px;
  border-radius: 10px; border: 1px solid var(--border);
}

/* ── Sub-agents Row ────────────────────────────────────── */
.sub-agents-row {
  display: flex; gap: 24px; flex-wrap: wrap;
  justify-content: center;
  max-width: 900px;
}

.sub-agent-card {
  display: flex; flex-direction: column; align-items: center;
  position: relative;
  animation: popIn 0.3s ease;
}

@keyframes popIn {
  from { opacity: 0; transform: scale(0.8); }
  to { opacity: 1; transform: scale(1); }
}

.sub-avatar {
  width: 60px; height: 80px;
  position: relative;
}

.sub-avatar svg {
  width: 100%; height: 100%;
  animation: ghostFloat 2.5s ease-in-out infinite;
}

.sub-bubble {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 6px 12px;
  margin-bottom: 8px;
  font-family: var(--mono); font-size: 0.65rem;
  color: var(--text2);
  max-width: 160px;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  position: relative;
}
.sub-bubble::after {
  content: '';
  position: absolute;
  bottom: -6px; left: 50%;
  transform: translateX(-50%) rotate(45deg);
  width: 10px; height: 10px;
  background: var(--bg3);
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}

.sub-name {
  font-family: var(--mono); font-size: 0.65rem;
  color: var(--text3); letter-spacing: 1px;
  margin-top: 4px;
}
.sub-status-tag {
  font-family: var(--mono); font-size: 0.55rem;
  margin-top: 3px;
  padding: 2px 8px; border-radius: 8px;
}
.sub-status-tag.running { color: var(--accent2); background: rgba(124,108,240,0.1); border: 1px solid rgba(124,108,240,0.2); }
.sub-status-tag.done { color: var(--green); background: rgba(0,230,118,0.08); border: 1px solid rgba(0,230,118,0.15); }
.sub-status-tag.failed { color: var(--red); background: rgba(255,82,82,0.08); border: 1px solid rgba(255,82,82,0.15); }

/* No sub-agents placeholder */
.no-agents {
  font-family: var(--mono); font-size: 0.75rem;
  color: var(--text3);
  text-align: center;
  padding: 16px;
  border: 1px dashed var(--border);
  border-radius: 12px;
  opacity: 0.6;
}

/* ── Bottom Panels ─────────────────────────────────────── */
.bottom-panels {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1px;
  background: var(--border);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
  height: 220px;
}

.panel {
  background: var(--bg2);
  display: flex; flex-direction: column;
  overflow: hidden;
}

.panel-header {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 14px;
  background: var(--bg3);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.panel-icon { font-size: 0.85rem; }
.panel-title { font-family: var(--mono); font-size: 0.7rem; color: var(--text3); letter-spacing: 1px; font-weight: 500; }

.panel-body { flex: 1; overflow-y: auto; padding: 8px 14px; font-size: 0.78rem; scrollbar-width: thin; scrollbar-color: var(--border) transparent; }

/* Activity Mini */
.act-item {
  padding: 5px 0;
  border-bottom: 1px solid rgba(30,30,51,0.5);
  display: flex; gap: 8px; align-items: baseline;
}
.act-time { font-family: var(--mono); font-size: 0.6rem; color: var(--text3); flex-shrink: 0; width: 50px; }
.act-text { color: var(--text2); font-size: 0.72rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* System Mini */
.sys-row {
  display: flex; justify-content: space-between;
  padding: 4px 0;
  border-bottom: 1px solid rgba(30,30,51,0.3);
}
.sys-key { font-family: var(--mono); font-size: 0.65rem; color: var(--text3); }
.sys-val { font-family: var(--mono); font-size: 0.65rem; color: var(--text2); }

/* ── Responsive ────────────────────────────────────────── */
@media (max-width: 768px) {
  .bottom-panels { grid-template-columns: 1fr; height: auto; }
  .panel { height: 160px; }
  .sub-agents-row { gap: 16px; }
  .avatar-wrapper { width: 100px; height: 130px; }
  .avatar-shadow { width: 90px; height: 120px; }
}
