/* ============================================================
   AMEVA Edge-Native AI Dashboard — Design System
   Aesthetic: Supabase × Obsidian Dark-Mode Fusion
   ============================================================ */

/* ── Google Fonts ───────────────────────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=JetBrains+Mono:wght@400;500;600&display=swap');

/* ── Design Tokens ─────────────────────────────────────────── */
:root {
  /* Backgrounds */
  --bg-deep: #0f0f0f;
  --bg-canvas: #181818;
  --bg-panel: #1c1c1c;
  --bg-elevated: #222222;
  --bg-input: #1a1a1a;

  /* Borders */
  --border-subtle: #2e2e2e;
  --border-focus: #3ECF8E;

  /* Primary Accent — Supabase Neon Green */
  --accent-green: #3ECF8E;
  --accent-green-dim: rgba(62, 207, 142, 0.15);
  --accent-green-glow: 0 0 12px rgba(62, 207, 142, 0.4);

  /* Secondary Accent — Obsidian Purple / Cyber Blue */
  --accent-purple: #7C3AED;
  --accent-cyan: #00EFFF;
  --accent-purple-dim: rgba(124, 58, 237, 0.15);
  --accent-cyan-dim: rgba(0, 239, 255, 0.10);
  --accent-cyan-glow: 0 0 14px rgba(0, 239, 255, 0.35);

  /* Text */
  --text-primary: #EDEDED;
  --text-secondary: #8B8D98;
  --text-muted: #555555;

  /* Danger / Warning */
  --danger: #EF4444;
  --warning: #F59E0B;

  /* Typography */
  --font-sans: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', monospace;

  /* Spacing */
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 16px;
  --space-lg: 24px;
  --space-xl: 32px;
  --space-2xl: 48px;

  /* Radii */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-xl: 20px;

  /* Shadows */
  --shadow-panel: 0 8px 32px rgba(0, 0, 0, 0.55), 0 0 0 1px var(--border-subtle);
  --shadow-fab: 0 4px 20px rgba(0, 0, 0, 0.5), 0 0 24px rgba(62, 207, 142, 0.15);
  --shadow-heavy: 0 24px 64px rgba(0, 0, 0, 0.7);

  /* Transitions */
  --ease-smooth: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-bounce: cubic-bezier(0.34, 1.56, 0.64, 1);
  --duration-fast: 200ms;
  --duration-med: 350ms;
  --duration-slow: 500ms;

  /* Z-Index Layers */
  --z-graph: 1;
  --z-header: 100;
  --z-fab: 200;
  --z-panel: 300;
  --z-overlay: 400;
  --z-modal: 500;
}


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

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  scroll-behavior: smooth;
}

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

::selection {
  background: var(--accent-green-dim);
  color: var(--accent-green);
}

/* Custom scrollbar */
::-webkit-scrollbar {
  width: 5px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--border-subtle);
  border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}


/* ── Graph Container (Obsidian Canvas) ─────────────────────── */
#graph-container {
  position: fixed;
  inset: 0;
  z-index: var(--z-graph);
  background:
    radial-gradient(ellipse at 20% 50%, rgba(124, 58, 237, 0.04) 0%, transparent 60%),
    radial-gradient(ellipse at 80% 20%, rgba(0, 239, 255, 0.03) 0%, transparent 50%),
    transparent;
}

/* Subtle animated grid overlay */
#graph-container::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.015) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.015) 1px, transparent 1px);
  background-size: 60px 60px;
  pointer-events: none;
}

/* Placeholder label for when D3 hasn't loaded */
#graph-container .graph-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-md);
  pointer-events: none;
  opacity: 0.25;
}

#graph-container .graph-placeholder svg {
  width: 64px;
  height: 64px;
  stroke: var(--accent-cyan);
  animation: pulse-slow 3s ease-in-out infinite;
}

#graph-container .graph-placeholder span {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--text-secondary);
  letter-spacing: 0.05em;
  text-transform: uppercase;
}


/* ── Header / SRE Metrics Bar ──────────────────────────────── */
#header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: var(--z-header);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-md) var(--space-lg);
  height: 56px;
  /* Glassmorphism */
  background: rgba(24, 24, 24, 0.65);
  backdrop-filter: blur(20px) saturate(1.4);
  -webkit-backdrop-filter: blur(20px) saturate(1.4);
  border-bottom: 1px solid var(--border-subtle);
}

.header-logo {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.header-logo .logo-icon {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, var(--accent-green), var(--accent-cyan));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 700;
  color: var(--bg-deep);
  box-shadow: var(--accent-green-glow);
}

.header-logo h1 {
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--text-primary);
}

.header-logo h1 span {
  color: var(--text-secondary);
  font-weight: 400;
}

/* SRE Metrics Cluster */
.sre-metrics {
  display: flex;
  align-items: center;
  gap: var(--space-md);
}

.metric-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border-radius: 999px;
  border: 1px solid var(--border-subtle);
  background: rgba(30, 30, 30, 0.6);
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 500;
  color: var(--text-secondary);
  white-space: nowrap;
  transition: border-color var(--duration-fast) ease;
}

.metric-badge:hover {
  border-color: var(--text-muted);
}

.metric-badge .status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}

.metric-badge .status-dot.online {
  background: var(--accent-green);
  box-shadow: 0 0 6px var(--accent-green);
  animation: pulse-dot 2s ease-in-out infinite;
}

.metric-badge .status-dot.offline {
  background: var(--danger);
  box-shadow: 0 0 6px var(--danger);
}

.metric-badge .status-dot.loading {
  background: var(--warning);
  box-shadow: 0 0 6px var(--warning);
  animation: pulse-dot 1s ease-in-out infinite;
}

.metric-badge .metric-value {
  color: var(--accent-green);
  font-weight: 600;
}







/* ── Floating Action Button (Who Made AMEVA?) ── */
.fab-who-made {
  position: fixed;
  bottom: var(--space-xl);
  left: 50%;
  transform: translateX(-50%);
  z-index: var(--z-fab);
  background: rgba(15, 15, 15, 0.7);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(124, 58, 237, 0.4);
  color: #fff;
  border-radius: 20px;
  padding: 8px 18px;
  font-family: var(--font-primary);
  font-size: 0.8rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  box-shadow: 0 4px 15px rgba(124, 58, 237, 0.2);
  transition: all var(--duration-fast) var(--ease-smooth);
}

.fab-who-made:hover {
  background: rgba(124, 58, 237, 0.2);
  border-color: rgba(124, 58, 237, 0.8);
  box-shadow: 0 0 20px rgba(124, 58, 237, 0.4);
  transform: translateX(-50%) translateY(-2px);
}

.fab-who-made:active {
  transform: translateX(-50%) translateY(2px);
}

.fab-who-made .icon {
  font-size: 1.1rem;
}


/* ── Chat Panel ────────────────────────────────────────────── */
.chat-panel {
  position: fixed;
  bottom: 96px;
  right: var(--space-lg);
  z-index: var(--z-panel);
  width: 420px;
  max-width: calc(100vw - 48px);
  height: 560px;
  max-height: calc(100vh - 140px);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-subtle);
  background: var(--bg-panel);
  box-shadow: var(--shadow-heavy);
  display: flex;
  flex-direction: column;
  overflow: hidden;

  /* Slide-up animation */
  transform: translateY(20px) scale(0.96);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition:
    transform var(--duration-slow) var(--ease-smooth),
    opacity var(--duration-med) ease,
    visibility 0ms var(--duration-slow);
}

.chat-panel.is-visible {
  transform: translateY(0) scale(1);
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transition:
    transform var(--duration-slow) var(--ease-smooth),
    opacity var(--duration-med) ease,
    visibility 0ms 0ms;
}

/* ── Chat Panel Header ──────────────────────────────────── */
.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-md);
  border-bottom: 1px solid var(--border-subtle);
  flex-shrink: 0;
  background: rgba(28, 28, 28, 0.9);
  backdrop-filter: blur(12px);
}

.chat-header-left {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.chat-header-left .ai-avatar {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, var(--accent-purple), var(--accent-cyan));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}

.chat-header-left .chat-title-group {
  display: flex;
  flex-direction: column;
}

.chat-header-left .chat-title {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.2;
}

.chat-header-left .chat-subtitle {
  font-size: 0.68rem;
  color: var(--text-secondary);
  font-family: var(--font-mono);
}

.chat-header-actions {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
}

/* PC Tour Button */
.btn-tour-pc {
  background: rgba(16, 185, 129, 0.15);
  border: 1px solid rgba(16, 185, 129, 0.3);
  color: var(--accent-green);
  border-radius: var(--radius-sm);
  padding: 4px 10px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--duration-fast);
  margin-right: var(--space-sm);
}

.btn-tour-pc:hover {
  background: rgba(16, 185, 129, 0.25);
  border-color: rgba(16, 185, 129, 0.6);
  box-shadow: 0 0 10px rgba(16, 185, 129, 0.3);
}

/* Clear & Close chat buttons */
.chat-header-actions button:not(.btn-tour-pc) {
  width: 30px;
  height: 30px;
  border-radius: var(--radius-sm);
  border: none;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--duration-fast) ease;
}

.chat-header-actions button:hover {
  background: var(--bg-elevated);
  color: var(--text-primary);
}

.chat-header-actions button svg {
  width: 16px;
  height: 16px;
}


/* ── TPS Metrics Strip (inside chat panel) ───────────────── */
.tps-strip {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: 8px var(--space-md);
  border-bottom: 1px solid var(--border-subtle);
  background: var(--bg-deep);
  flex-shrink: 0;
}

.tps-item {
  display: flex;
  align-items: center;
  gap: 5px;
  font-family: var(--font-mono);
  font-size: 0.68rem;
  color: var(--text-secondary);
}

.tps-item .tps-label {
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}

.tps-item .tps-value {
  color: var(--accent-green);
  font-weight: 600;
}

.tps-item .tps-value.dim {
  color: var(--text-muted);
}


/* ── Download Overlay ────────────────────────────────────── */
.download-overlay {
  position: absolute;
  inset: 0;
  z-index: var(--z-overlay);
  background: rgba(15, 15, 15, 0.92);
  backdrop-filter: blur(8px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-lg);
  padding: var(--space-xl);
  text-align: center;
  /* Hidden by default via JS; shown initially */
}

.download-overlay.is-hidden {
  display: none;
}

.download-icon {
  width: 64px;
  height: 64px;
  border-radius: var(--radius-lg);
  background: var(--accent-green-dim);
  border: 1px solid rgba(62, 207, 142, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  animation: float 3s ease-in-out infinite;
}

.download-icon svg {
  width: 28px;
  height: 28px;
  stroke: var(--accent-green);
}

.download-overlay h3 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.4;
}

.download-overlay p {
  font-size: 0.8rem;
  color: var(--text-secondary);
  line-height: 1.5;
  max-width: 300px;
}

.download-overlay .model-tag {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--accent-purple-dim);
  border: 1px solid rgba(124, 58, 237, 0.25);
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--accent-purple);
  font-weight: 500;
}

/* Progress bar container */
.download-progress {
  width: 100%;
  max-width: 280px;
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.progress-bar-track {
  width: 100%;
  height: 4px;
  border-radius: 999px;
  background: var(--border-subtle);
  overflow: hidden;
}

.progress-bar-fill {
  width: 0%;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent-green), var(--accent-cyan));
  box-shadow: 0 0 10px var(--accent-green);
  transition: width var(--duration-med) var(--ease-smooth);
}

.progress-text {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  color: var(--text-secondary);
  text-align: center;
  min-height: 1.3em;
}

.progress-percent {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--accent-green);
}

/* Download CTA button */
.btn-download {
  display: inline-flex;
  align-items: center;
  gap: var(--space-sm);
  padding: 10px 24px;
  border-radius: var(--radius-md);
  border: 1px solid var(--accent-green);
  background: var(--accent-green-dim);
  color: var(--accent-green);
  font-family: var(--font-sans);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--duration-fast) ease;
}

.btn-download:hover {
  background: rgba(62, 207, 142, 0.25);
  box-shadow: var(--accent-green-glow);
  transform: translateY(-1px);
}

.btn-download:active {
  transform: translateY(0);
}

.btn-download:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.btn-download svg {
  width: 16px;
  height: 16px;
}


/* ── Chat Log (Message Area) ─────────────────────────────── */
.chat-log {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-md);
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}

/* Individual Message Bubble */
.chat-msg {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
  max-width: 88%;
  animation: msg-appear 0.35s var(--ease-smooth) both;
}

.chat-msg.user {
  align-self: flex-end;
}

.chat-msg.ai {
  align-self: flex-start;
}

.chat-msg .msg-bubble {
  padding: 10px 14px;
  border-radius: var(--radius-md);
  font-size: 0.82rem;
  line-height: 1.55;
  word-break: break-word;
}

.chat-msg.user .msg-bubble {
  background: var(--accent-purple-dim);
  border: 1px solid rgba(124, 58, 237, 0.18);
  color: var(--text-primary);
  border-bottom-right-radius: 4px;
}

.chat-msg.ai .msg-bubble {
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  color: var(--text-primary);
  border-bottom-left-radius: 4px;
}

/* Code blocks inside messages */
.chat-msg .msg-bubble code {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  background: rgba(0, 0, 0, 0.3);
  padding: 2px 6px;
  border-radius: 4px;
  color: var(--accent-cyan);
}

.thinking-indicator {
  display: inline-block;
  font-size: 0.82rem;
  color: var(--text-muted);
  animation: pulse-opacity 1.5s infinite;
}

@keyframes pulse-opacity {
  0% {
    opacity: 0.4;
  }

  50% {
    opacity: 1;
    text-shadow: 0 0 5px rgba(124, 58, 237, 0.5);
  }

  100% {
    opacity: 0.4;
  }
}

/* Source Badges */
.source-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  padding-left: 2px;
}

.source-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 999px;
  border: 1px solid var(--border-subtle);
  background: rgba(30, 30, 30, 0.6);
  font-family: var(--font-mono);
  font-size: 0.65rem;
  color: var(--text-secondary);
  text-decoration: none;
  cursor: pointer;
  transition: all var(--duration-fast) ease;
}

.source-badge:hover {
  border-color: var(--accent-cyan);
  color: var(--accent-cyan);
  box-shadow: 0 0 8px rgba(0, 239, 255, 0.2);
}

.source-badge .badge-icon {
  font-size: 0.7rem;
}

/* Typing indicator */
.typing-indicator {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 10px 14px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  border-bottom-left-radius: 4px;
  align-self: flex-start;
}

.typing-indicator .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-muted);
  animation: typing-bounce 1.4s ease-in-out infinite;
}

.typing-indicator .dot:nth-child(2) {
  animation-delay: 0.15s;
}

.typing-indicator .dot:nth-child(3) {
  animation-delay: 0.3s;
}


/* ── Chat Input Area ─────────────────────────────────────── */
.chat-input-area {
  display: flex;
  align-items: flex-end;
  gap: var(--space-sm);
  padding: var(--space-md);
  border-top: 1px solid var(--border-subtle);
  background: var(--bg-panel);
  flex-shrink: 0;
}

#chat-input {
  flex: 1;
  min-height: 38px;
  max-height: 120px;
  padding: 8px 14px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  background: var(--bg-input);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 0.82rem;
  line-height: 1.5;
  resize: none;
  outline: none;
  transition: border-color var(--duration-fast) ease;
}

#chat-input::placeholder {
  color: var(--text-muted);
}

#chat-input:focus {
  border-color: var(--accent-green);
}

#chat-input:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

#btn-send {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-md);
  border: none;
  background: var(--accent-green);
  color: var(--bg-deep);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all var(--duration-fast) ease;
}

#btn-send:hover {
  background: #4ae09d;
  box-shadow: var(--accent-green-glow);
}

#btn-send:active {
  transform: scale(0.92);
}

#btn-send:disabled {
  opacity: 0.3;
  cursor: not-allowed;
  box-shadow: none;
}

#btn-send svg {
  width: 18px;
  height: 18px;
}

/* ── Stop Generation Button ────────────────────────────── */
#btn-stop-gen {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-md);
  border: 1px solid rgba(239, 68, 68, 0.4);
  background: rgba(239, 68, 68, 0.12);
  color: var(--danger);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all var(--duration-fast) ease;
  animation: stop-pulse 1.5s ease-in-out infinite;
}

#btn-stop-gen:hover {
  background: rgba(239, 68, 68, 0.25);
  border-color: var(--danger);
  box-shadow: 0 0 14px rgba(239, 68, 68, 0.4);
}

#btn-stop-gen:active {
  transform: scale(0.92);
}

#btn-stop-gen svg {
  width: 16px;
  height: 16px;
}

#btn-stop-gen.is-hidden {
  display: none;
}

@keyframes stop-pulse {

  0%,
  100% {
    opacity: 1;
    border-color: rgba(239, 68, 68, 0.4);
  }

  50% {
    opacity: 0.7;
    border-color: rgba(239, 68, 68, 0.8);
  }
}


/* ── Mobile Block Modal ──────────────────────────────────── */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: var(--z-modal);
  background: rgba(10, 10, 10, 0.85);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  display: none;
  align-items: center;
  justify-content: center;
  padding: var(--space-lg);
}

.modal-backdrop.is-active {
  display: flex;
}

.modal-card {
  width: 90vw;
  max-width: 600px;
  padding: var(--space-xl);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-subtle);
  background: var(--bg-panel);
  box-shadow: var(--shadow-heavy);
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-md);
}

/* ── Tour Overlay (Cinematic Mode) ────────────────────────── */
.tour-overlay {
  position: fixed;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%);
  width: 90vw;
  max-width: 800px;
  background: var(--surface-80);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4), 0 0 0 1px inset rgba(255, 255, 255, 0.05);
  display: flex;
  flex-direction: column;
  gap: 1rem;
  z-index: 500;
  /* Above graph, below modals */
  opacity: 1;
  transition: all 0.4s var(--ease-out-quint);
}

.tour-overlay.is-hidden {
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 20px);
}

.tour-content h3 {
  margin: 0 0 0.5rem 0;
  color: var(--accent-cyan);
  font-family: var(--font-mono);
  font-size: 1.1rem;
  letter-spacing: 0.05em;
}

.tour-content p {
  margin: 0;
  color: #ffffff;
  font-size: 1.05rem;
  line-height: 1.6;
}

.tour-controls {
  display: flex;
  gap: 1rem;
  justify-content: space-between;
}

.modal-card .modal-icon {
  font-size: 2.5rem;
}

.modal-card h2 {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-primary);
}

.modal-card p {
  font-size: 0.82rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

.modal-card .modal-tag {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 999px;
  border: 1px solid rgba(239, 68, 68, 0.3);
  background: rgba(239, 68, 68, 0.1);
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--danger);
  font-weight: 500;
}


/* ── Keyframe Animations ──────────────────────────────────── */
@keyframes pulse-dot {

  0%,
  100% {
    opacity: 1;
  }

  50% {
    opacity: 0.4;
  }
}

@keyframes pulse-slow {

  0%,
  100% {
    opacity: 0.25;
    transform: scale(1);
  }

  50% {
    opacity: 0.4;
    transform: scale(1.05);
  }
}

@keyframes float {

  0%,
  100% {
    transform: translateY(0);
  }

  50% {
    transform: translateY(-6px);
  }
}

@keyframes fab-ping {
  0% {
    transform: scale(1);
    opacity: 0.5;
  }

  75%,
  100% {
    transform: scale(1.6);
    opacity: 0;
  }
}

@keyframes msg-appear {
  from {
    opacity: 0;
    transform: translateY(8px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes typing-bounce {

  0%,
  60%,
  100% {
    transform: translateY(0);
    opacity: 0.4;
  }

  30% {
    transform: translateY(-4px);
    opacity: 1;
  }
}

@keyframes shimmer {
  0% {
    background-position: -200% 0;
  }

  100% {
    background-position: 200% 0;
  }
}

@keyframes spin {
  from {
    transform: rotate(0deg);
  }

  to {
    transform: rotate(360deg);
  }
}

/* Loading spinner utility */
.spinner {
  width: 20px;
  height: 20px;
  border: 2px solid var(--border-subtle);
  border-top-color: var(--accent-green);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.spinner-large {
  width: 40px;
  height: 40px;
  border: 3px solid rgba(255, 255, 255, 0.15);
  border-top-color: var(--accent-cyan);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin-bottom: var(--space-md);
}

/* ── Global Loading Overlay ──────────────────────────────── */
.global-loading {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: #050505;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  transition: opacity var(--duration-med) ease, visibility var(--duration-med);
}

.global-loading.is-hidden {
  opacity: 0;
  visibility: hidden;
}

.loading-text {
  font-family: var(--font-mono);
  font-size: 1.6rem;
  color: var(--accent-cyan);
  letter-spacing: 0.08em;
  animation: pulse-slow 2.0s infinite;
  margin-bottom: 12px;
  font-weight: 900;
  text-transform: uppercase;
  text-shadow: 0 0 15px rgba(0, 239, 255, 0.7), 0 0 30px rgba(0, 239, 255, 0.3);
  text-align: center;
  max-width: 90vw;
  padding: 0 16px;
}

.loading-subtext {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--text-primary);
  opacity: 1;
  font-weight: 500;
  text-shadow: 0 0 8px rgba(255, 255, 255, 0.1);
  text-align: center;
  max-width: 90vw;
  padding: 0 16px;
}

/* ── Small Hover Tooltip ──────────────────────────────────── */
.graph-tooltip-small {
  position: absolute;
  z-index: var(--z-modal);
  background: rgba(20, 20, 20, 0.9);
  border: 1px solid var(--accent-cyan);
  border-radius: var(--radius-sm);
  padding: 6px 12px;
  box-shadow: var(--accent-cyan-glow);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s ease;
  white-space: nowrap;
}

.graph-tooltip-small.is-visible {
  opacity: 1;
}

.graph-tooltip-small span {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: #ffffff;
}

/* ── Modal Enhancements ───────────────────────────────────── */
.modal-medium {
  max-width: 800px !important;
  width: 90vw;
  max-height: 85vh;
  overflow: hidden;
}

#node-modal-desc {
  text-align: left;
  width: 100%;
  max-height: 50vh;
  overflow-y: auto;
  padding-right: 8px;
  color: var(--text-primary);
  line-height: 1.6;
  font-size: 0.9rem;
}

#node-modal-desc h1,
#node-modal-desc h2,
#node-modal-desc h3,
#node-modal-desc h4 {
  color: var(--accent-cyan);
  margin-top: 20px;
  margin-bottom: 10px;
  font-weight: 600;
  border-bottom: 1px solid var(--border-subtle);
  padding-bottom: 4px;
}

#node-modal-desc p {
  margin-bottom: 12px;
  text-align: left;
}

#node-modal-desc ul,
#node-modal-desc ol {
  margin-bottom: 16px;
  padding-left: 20px;
  text-align: left;
}

#node-modal-desc li {
  margin-bottom: 6px;
}

#node-modal-desc code {
  font-family: var(--font-mono);
  background: rgba(255, 255, 255, 0.08);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.85em;
  color: var(--accent-green);
}

#node-modal-desc pre {
  background: #121212;
  border: 1px solid var(--border-subtle);
  padding: 16px;
  border-radius: 8px;
  overflow-x: auto;
  margin-bottom: 16px;
  width: 100%;
}

#node-modal-desc pre code {
  background: transparent;
  padding: 0;
  border-radius: 0;
  color: var(--text-primary);
  display: block;
}

.btn-close-modal {
  position: absolute;
  top: 16px;
  right: 16px;
  background: transparent;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  transition: color var(--duration-fast) ease;
}

.btn-close-modal:hover {
  color: var(--text-primary);
}

.btn-close-modal svg {
  width: 20px;
  height: 20px;
}

.node-modal-icon {
  font-size: 3rem;
  margin-bottom: var(--space-sm);
}


/* ── Utility Classes ──────────────────────────────────────── */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.mono {
  font-family: var(--font-mono);
}

.text-green {
  color: var(--accent-green);
}

.text-cyan {
  color: var(--accent-cyan);
}

.text-purple {
  color: var(--accent-purple);
}

.text-muted {
  color: var(--text-secondary);
}


/* ── Responsive (tablets — chat panel reflow) ─────────────── */
@media (max-width: 480px) {
  .chat-panel {
    right: var(--space-sm);
    width: calc(100vw - 16px);
    bottom: 80px;
    height: calc(100vh - 120px);
  }

  .sre-metrics {
    display: none;
  }

  /* Mobile tour overlay fix — prevent right overflow */
  .tour-overlay {
    width: calc(100vw - 2rem) !important;
    max-width: none !important;
    left: 1rem !important;
    right: 1rem !important;
    transform: translateX(0) !important;
    padding: 1rem !important;
    box-sizing: border-box;
  }

  .tour-overlay.is-hidden {
    transform: translateY(20px) !important;
    opacity: 0;
  }

  .tour-controls-new {
    gap: 12px;
  }

  .tour-content h3 {
    font-size: 1.05rem;
  }

  .tour-content p {
    font-size: 0.98rem;
    line-height: 1.55;
  }
}

/* ── Toast Container ────────────────────────────────────────── */
.toast-container {
  position: fixed;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}

.toast-msg {
  background: rgba(15, 23, 42, 0.85);
  border: 1px solid var(--accent-cyan);
  color: #fff;
  padding: 12px 24px;
  border-radius: 30px;
  box-shadow: 0 4px 15px rgba(0, 239, 255, 0.2);
  backdrop-filter: blur(8px);
  animation: toastFadeIn 0.3s ease-out forwards, toastFadeOut 0.5s 3s ease-in forwards;
  font-weight: 500;
}

@keyframes toastFadeIn {
  from {
    opacity: 0;
    transform: translateY(20px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes toastFadeOut {
  from {
    opacity: 1;
    transform: translateY(0);
  }

  to {
    opacity: 0;
    transform: translateY(-20px);
  }
}

/* ── Tour Overlay & Timer Ring ────────────────────────────── */
.tour-controls-new {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 20px;
  margin-top: 20px;
}

.btn-tour-nav {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid var(--border-subtle);
  color: #fff;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  font-size: 1.1rem;
}

.btn-tour-nav:hover {
  background: var(--accent-cyan);
  color: #000;
}

.tour-progress-wrapper {
  position: relative;
  width: 60px;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.5);
  transition: transform 0.2s;
}

.tour-progress-wrapper:hover {
  transform: scale(1.05);
}

.tour-progress-ring {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.ring-bg {
  fill: none;
  stroke: rgba(255, 255, 255, 0.1);
  stroke-width: 3;
}

.ring-progress {
  fill: none;
  stroke: var(--accent-cyan);
  stroke-width: 3;
  stroke-dasharray: 100.53;
  /* 2 * PI * 16 = 100.53 */
  stroke-dashoffset: 100.53;
  transition: stroke-dashoffset 0.1s linear, stroke 0.3s ease, stroke-width 0.3s ease, filter 0.3s ease;
}

.ring-progress.ring-intense {
  stroke: #00ffff;
  stroke-width: 4;
  filter: drop-shadow(0 0 8px rgba(0, 255, 255, 0.7));
}

.tts-icon {
  font-size: 1.5rem;
  z-index: 2;
  user-select: none;
}

/* Tour step counter */
.tour-step-counter {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--text-secondary);
  text-align: right;
  opacity: 0.7;
  margin-bottom: -0.5rem;
}

/* Tour GitHub link */
.tour-github-link {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-top: 8px;
  padding: 4px 12px;
  border-radius: 999px;
  border: 1px solid rgba(62, 207, 142, 0.3);
  background: rgba(62, 207, 142, 0.08);
  color: var(--accent-green);
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 500;
  text-decoration: none;
  transition: all var(--duration-fast) ease;
}

.tour-github-link:hover {
  background: rgba(62, 207, 142, 0.2);
  border-color: var(--accent-green);
  box-shadow: 0 0 10px rgba(62, 207, 142, 0.3);
}

/* Tour tech badge */
.tour-tech-badge {
  display: inline-block;
  margin-top: 8px;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--accent-cyan-dim);
  border: 1px solid rgba(0, 239, 255, 0.2);
  font-family: var(--font-mono);
  font-size: 0.68rem;
  color: var(--accent-cyan);
  font-weight: 500;
}

/* ── Profile Modal & Markdown Body ────────────────────────── */
.profile-card {
  position: relative;
  max-width: 450px;
  /* PC에서도 앙증맞은 프로필 카드 사이즈로 고정 */
  width: 90%;
  max-height: 70vh;
  /* 조금 더 짧게 잡아 스크롤이 자연스럽게 생기도록 유도 */
  overflow-y: auto;
  /* 내용이 넘치면 세로 스크롤 생성 */
  background: rgba(15, 23, 42, 0.95);
  text-align: left;
  border-radius: var(--radius-lg);
  padding: var(--space-xl);
}

/* 프로필 모달 커스텀 스크롤바 */
.profile-card::-webkit-scrollbar {
  width: 8px;
}

.profile-card::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.2);
  border-radius: 4px;
}

.profile-card::-webkit-scrollbar-thumb {
  background: var(--accent-purple);
  border-radius: 4px;
}

.btn-close-modal {
  position: absolute;
  top: 15px;
  right: 15px;
  background: none;
  border: none;
  color: #fff;
  font-size: 1.5rem;
  cursor: pointer;
  opacity: 0.7;
  transition: opacity 0.2s;
}

.btn-close-modal:hover {
  opacity: 1;
}

.markdown-body {
  color: var(--text-base);
  line-height: 1.6;
}

.markdown-body h1 {
  font-size: 1.8rem;
  color: #fff;
  margin-bottom: 10px;
  border-bottom: 1px solid var(--border-subtle);
  padding-bottom: 5px;
}

.markdown-body h2,
.markdown-body h3 {
  color: var(--accent-purple);
  margin-top: 15px;
}

.markdown-body img {
  display: block;
  margin: 15px auto;
  width: 120px;
  height: 120px;
  border-radius: 50%;
  object-fit: cover;
  border: 3px solid var(--accent-cyan);
  box-shadow: 0 0 20px rgba(0, 239, 255, 0.3);
}

.markdown-body ul {
  padding-left: 20px;
  margin-bottom: 15px;
}

.markdown-body code {
  background: rgba(255, 255, 255, 0.1);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.9em;
  color: var(--accent-cyan);
}

/* ── Child Node Item Hover ───────────────────────────────── */
.child-node-item:hover {
  border-color: var(--accent-cyan) !important;
  background: rgba(0, 239, 255, 0.1) !important;
  transform: translateX(4px);
}

/* ═══════════════════════════════════════════════════════════
   SPOTLIGHT SEARCH (FUSE.JS)
   ═══════════════════════════════════════════════════════════ */
.spotlight-container {
  position: fixed;
  top: 80px;
  left: 50%;
  transform: translateX(-50%);
  width: 90vw;
  max-width: 600px;
  background: rgba(20, 20, 20, 0.85);
  backdrop-filter: blur(16px);
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.5);
  z-index: 1000;
  display: flex;
  flex-direction: column;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.spotlight-container.is-hidden {
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, -20px);
}

.spotlight-input-wrapper {
  display: flex;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-subtle);
}

.spotlight-input-wrapper .search-icon {
  font-size: 1.2rem;
  margin-right: 12px;
  opacity: 0.7;
}

#spotlight-input {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text-primary);
  font-size: 1.2rem;
  outline: none;
  font-family: var(--font-sans);
}

.spotlight-results {
  max-height: 400px;
  overflow-y: auto;
  padding: 10px;
}

.search-searching {
  color: var(--accent-purple);
  font-family: var(--font-mono);
  font-size: 0.9rem;
  padding: 15px;
  text-align: center;
  animation: pulse-slow 1.5s ease-in-out infinite;
}

.search-result-item {
  padding: 12px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.2s ease, transform 0.2s ease;
  margin-bottom: 5px;
  animation: slide-up-fade 0.35s var(--ease-smooth) both;
}

/* Cascade animation delays */
.search-result-item:nth-child(1) {
  animation-delay: 0.04s;
}

.search-result-item:nth-child(2) {
  animation-delay: 0.08s;
}

.search-result-item:nth-child(3) {
  animation-delay: 0.12s;
}

.search-result-item:nth-child(4) {
  animation-delay: 0.16s;
}

.search-result-item:nth-child(5) {
  animation-delay: 0.20s;
}

@keyframes slide-up-fade {
  from {
    opacity: 0;
    transform: translateY(12px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.search-result-item:hover {
  background: rgba(124, 58, 237, 0.12);
  border-left: 3px solid var(--accent-purple);
  padding-left: 9px;
  transform: translateX(4px);
}

.search-result-repo {
  font-size: 0.85rem;
  color: var(--accent-cyan);
  margin-bottom: 4px;
  font-weight: bold;
}

.search-result-text {
  font-size: 0.95rem;
  color: var(--text-secondary);
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}


/* Highlight matching search terms */
.search-highlight {
  background: rgba(124, 58, 237, 0.25);
  color: var(--accent-cyan);
  border-bottom: 2px dashed var(--accent-cyan);
  font-weight: bold;
  padding: 0 4px;
  border-radius: 4px;
  margin: 0 1px;
}

/* ── Panel Wobble Animation (Dog in Box Effect) ── */
@keyframes box-wobble {

  0%,
  100% {
    transform: rotate(0deg);
  }

  15% {
    transform: rotate(-3deg) scale(1.02);
  }

  30% {
    transform: rotate(3deg) scale(1.02);
  }

  45% {
    transform: rotate(-2deg) scale(1.01);
  }

  60% {
    transform: rotate(2deg) scale(1.01);
  }

  75% {
    transform: rotate(0deg);
  }
}

.wobble-active {
  animation: box-wobble 0.6s ease-in-out;
}

@keyframes tagFadeIn {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ── FAB (Floating Action Button) : CURRENT INDEX.HTML VERSION ── */

.fab-group {
  position: fixed;
  right: 24px;
  bottom: 24px;
  width: 56px;
  height: 56px;
  z-index: 220;
  pointer-events: none;
  overflow: visible;
}

.fab-group * {
  pointer-events: auto;
}

/* 번개 버튼: 항상 맨 아래 */
#fab-trigger {
  position: absolute;
  right: 0;
  bottom: 0;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: 1px solid var(--accent-green);
  background: var(--bg-panel);
  color: var(--accent-green);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: var(--shadow-fab);
  z-index: 30;
  outline: none;
  transition:
    transform var(--duration-fast) var(--ease-bounce),
    box-shadow var(--duration-fast) ease,
    border-color var(--duration-fast) ease,
    color var(--duration-fast) ease,
    background var(--duration-fast) ease;
}

#fab-trigger:hover {
  transform: scale(1.08);
  box-shadow: var(--shadow-fab), var(--accent-green-glow);
}

#fab-trigger .trigger-icon {
  font-size: 1.5rem;
  display: inline-block;
  transition: transform var(--duration-med) var(--ease-smooth);
}

.fab-group.is-open #fab-trigger {
  border-color: var(--danger);
  color: var(--danger);
}

.fab-group.is-open #fab-trigger .trigger-icon {
  transform: rotate(135deg);
}

/* 서브 버튼: 기본은 번개 위에 겹쳐놓음 */
.fab-sub {
  position: absolute;
  right: 4px;
  bottom: 4px;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 1px solid var(--border-subtle);
  background: rgba(15, 15, 15, 0.85);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);

  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: scale(0.7);

  z-index: 10;
  transition:
    bottom var(--duration-med) var(--ease-smooth),
    opacity var(--duration-med) ease,
    transform var(--duration-med) var(--ease-smooth),
    visibility 0s linear var(--duration-med);
}

/* 열렸을 때 보이기 */
.fab-group.is-open .fab-sub {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: scale(1);
  transition:
    bottom var(--duration-med) var(--ease-smooth),
    opacity var(--duration-med) ease,
    transform var(--duration-med) var(--ease-smooth),
    visibility 0s linear 0s;
}

/* 위로 착착 올라가는 위치 */
/* 위로 착착 올라가는 위치 */
.fab-group.is-open #fab-voice {
  bottom: 68px;
  transition-delay: 0s;
}

.fab-group.is-open #fab-chat {
  bottom: 128px;
  transition-delay: 0.04s;
}

.fab-group.is-open #fab-search {
  bottom: 188px;
  transition-delay: 0.08s;
}

.fab-group.is-open #fab-blog {
  bottom: 248px;
  transition-delay: 0.12s;
}

/* 아이콘 크기 */
.fab-sub svg {
  width: 20px;
  height: 20px;
}

/* 버튼별 색상 */
#fab-chat {
  color: var(--accent-green);
  border-color: rgba(62, 207, 142, 0.4);
}

#fab-chat:hover {
  border-color: var(--accent-green);
  background: rgba(62, 207, 142, 0.1);
  box-shadow: 0 0 12px rgba(62, 207, 142, 0.3);
}

#fab-search {
  color: var(--accent-cyan);
  border-color: rgba(0, 239, 255, 0.4);
}

#fab-search:hover {
  border-color: var(--accent-cyan);
  background: rgba(0, 239, 255, 0.1);
  box-shadow: 0 0 12px rgba(0, 239, 255, 0.3);
}

#fab-blog {
  color: var(--accent-cyan);
  border-color: rgba(0, 239, 255, 0.4);
}

#fab-blog:hover {
  border-color: var(--accent-cyan);
  background: rgba(0, 239, 255, 0.1);
  box-shadow: 0 0 12px rgba(0, 239, 255, 0.3);
}

#fab-voice {
  color: var(--accent-purple);
  border-color: rgba(124, 58, 237, 0.4);
}

#fab-voice:hover {
  border-color: var(--accent-purple);
  background: rgba(124, 58, 237, 0.1);
  box-shadow: 0 0 12px rgba(124, 58, 237, 0.3);
}