/* ==========================================================================
   AMEVA Neural Fabric — Edge-Native AI Dashboard Design System (SSOT)
   Theme: Obsidian x Supabase High-Clarity Neon Dark
   SPDX-License-Identifier: Apache-2.0 OR Commercial-License
   ========================================================================== */

:root {
  /* Surface & Background Tokens */
  --bg-primary: #070b14;
  --bg-secondary: #0d1527;
  --bg-tertiary: #131d36;
  --bg-card: rgba(15, 23, 42, 0.94);
  --bg-glass: rgba(13, 21, 39, 0.88);
  --bg-hud: rgba(11, 18, 33, 0.92);

  /* Border & Divider Tokens */
  --border-subtle: rgba(255, 255, 255, 0.08);
  --border-medium: rgba(255, 255, 255, 0.16);
  --border-glow: rgba(0, 239, 255, 0.35);
  --border-cyan: #00EFFF;
  --border-purple: #7C3AED;

  /* Typography Colors */
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --text-subtle: #475569;

  /* Accent & Status Colors */
  --accent-cyan: #00EFFF;
  --accent-purple: #7C3AED;
  --accent-green: #10B981;
  --accent-amber: #F59E0B;
  --accent-red: #EF4444;
  --danger: #EF4444;

  /* Fonts */
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Apple SD Gothic Neo", "Malgun Gothic", "맑은 고딕", sans-serif;
  --font-mono: "JetBrains Mono", "SFMono-Regular", Consolas, "Liberation Mono", Menlo, Courier, monospace;

  /* Metrics & Radii */
  --header-height: 56px;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-xl: 18px;
  --radius-full: 9999px;
  --shadow-lg: 0 20px 48px rgba(0, 0, 0, 0.75);
  --shadow-glow: 0 0 24px rgba(0, 239, 255, 0.2);
}

/* ── Reset & Baseline ─────────────────────────────────────────────── */
*, *::before, *::after {
  box-sizing: border-box;
}

html, body {
  background-color: var(--bg-primary) !important;
  color: var(--text-primary) !important;
  margin: 0;
  padding: 0;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
  font-family: var(--font-sans);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ── Universal State Utilities ────────────────────────────────────── */
.is-hidden {
  display: none !important;
}

#global-loading.is-hidden {
  display: none !important;
  opacity: 0 !important;
  visibility: hidden !important;
  pointer-events: none !important;
}

.dim {
  opacity: 0.35 !important;
}

.status-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.status-dot.online {
  background: var(--accent-green);
  box-shadow: 0 0 8px var(--accent-green);
}

.status-dot.loading {
  background: var(--accent-amber);
  animation: pulse-dot 1.5s infinite;
}

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

@keyframes ameva-spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* ── Graph Canvas Container ────────────────────────────────────────── */
#graph-container {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
  z-index: 1;
  background: radial-gradient(circle at 50% 50%, #0d172e 0%, #050811 100%);
  user-select: none;
}

#graph-container svg {
  display: block;
  width: 100%;
  height: 100%;
}

.node-item {
  cursor: pointer;
}

.node-hitbox {
  cursor: pointer;
  fill: transparent;
}

.node-visual {
  transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1), stroke 0.2s;
}

.node-label {
  fill: #e2e8f0;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  pointer-events: none;
  user-select: none;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.95), 0 0 8px rgba(0, 0, 0, 0.8);
}

/* ── Global Loading Screen ─────────────────────────────────────────── */
.global-loading {
  position: fixed;
  inset: 0;
  z-index: 99999;
  background: rgba(7, 11, 20, 0.96);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  transition: opacity 0.5s ease, visibility 0.5s ease;
}

.spinner-large {
  width: 60px;
  height: 60px;
  border: 4px solid rgba(0, 239, 255, 0.15);
  border-top-color: var(--accent-cyan);
  border-right-color: var(--accent-cyan);
  border-radius: 50%;
  animation: ameva-spin 0.85s linear infinite;
  box-shadow: 0 0 24px rgba(0, 239, 255, 0.2);
}

.loading-text {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: 0.5px;
}

.loading-subtext {
  font-size: 0.85rem;
  color: var(--accent-cyan);
  font-family: var(--font-mono);
  letter-spacing: 0.3px;
}

/* ── Top Header Bar (Glassmorphism SRE Bar) ────────────────────────── */
#header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--header-height);
  background: var(--bg-glass);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  padding: 0 20px;
  z-index: 500;
}

.header-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  user-select: none;
}

.logo-icon {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--accent-purple), var(--accent-cyan));
  color: #fff;
  font-weight: 900;
  font-size: 1.05rem;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 12px rgba(0, 239, 255, 0.35);
}

.header-logo h1 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: #fff;
}

.header-logo h1 span {
  color: var(--accent-cyan);
  font-weight: 400;
  font-size: 0.9em;
  margin-left: 4px;
}

.sre-metrics {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-left: 28px;
}

.metric-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 0.78rem;
  color: var(--text-secondary);
  font-family: var(--font-mono);
}

.metric-value {
  color: var(--text-primary);
  font-weight: 600;
}

/* ── Spotlight Search (Command Palette) ────────────────────────────── */
.spotlight-container {
  position: fixed;
  top: 15%;
  left: 50%;
  transform: translateX(-50%);
  width: 90vw;
  max-width: 620px;
  background: rgba(15, 23, 42, 0.96);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border-glow);
  border-radius: 12px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.85), 0 0 30px rgba(0, 239, 255, 0.15);
  z-index: 9000;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

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

.spotlight-input-wrapper .search-icon {
  font-size: 1.1rem;
  opacity: 0.75;
}

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

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

.spotlight-results {
  max-height: 52vh;
  overflow-y: auto;
  padding: 8px 0;
}

.spotlight-item {
  padding: 10px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  transition: background 0.15s ease;
  border-left: 3px solid transparent;
}

.spotlight-item:hover, .spotlight-item.is-selected {
  background: rgba(0, 239, 255, 0.08);
  border-left-color: var(--accent-cyan);
}

.spotlight-item-title {
  color: #fff;
  font-size: 0.92rem;
  font-weight: 600;
}

.spotlight-item-desc {
  color: var(--text-secondary);
  font-size: 0.8rem;
  margin-top: 2px;
}

/* ── Museum Docent Tour Overlay ────────────────────────────────────── */
.tour-overlay {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 2000;
  display: flex;
  flex-direction: column;
}

.museum-header-bar {
  pointer-events: auto;
  position: fixed;
  top: 68px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--bg-hud);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--border-glow);
  border-radius: 40px;
  padding: 6px 16px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6), 0 0 20px rgba(0, 239, 255, 0.15);
  z-index: 2010;
}

.museum-badge {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--accent-cyan);
  white-space: nowrap;
}

.docent-track-select {
  background: rgba(15, 23, 42, 0.85);
  border: 1px solid var(--border-subtle);
  border-radius: 20px;
  color: var(--text-primary);
  font-size: 0.8rem;
  padding: 4px 10px;
  outline: none;
  cursor: pointer;
}

.museum-step-counter {
  font-size: 0.78rem;
  font-family: var(--font-mono);
  color: var(--text-secondary);
  white-space: nowrap;
}

.btn-museum-exit {
  background: rgba(255, 255, 255, 0.1);
  border: none;
  border-radius: 50%;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  cursor: pointer;
  font-size: 0.85rem;
  transition: background 0.2s;
}

.btn-museum-exit:hover {
  background: rgba(239, 68, 68, 0.75);
}

.museum-curator-card {
  pointer-events: auto;
  position: fixed;
  top: 126px;
  left: 24px;
  width: 400px;
  max-width: calc(100vw - 48px);
  background: var(--bg-card);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border-glow);
  border-radius: 14px;
  padding: 16px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.7);
  z-index: 2010;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.curator-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.curator-tag {
  background: rgba(0, 239, 255, 0.12);
  color: var(--accent-cyan);
  border: 1px solid rgba(0, 239, 255, 0.3);
  font-size: 0.72rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 4px;
  text-transform: uppercase;
}

.curator-badge-tier {
  background: rgba(124, 58, 237, 0.15);
  color: #c084fc;
  border: 1px solid rgba(124, 58, 237, 0.3);
  font-size: 0.72rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 4px;
}

.btn-tour-live-doc {
  font-size: 0.78rem;
  color: var(--accent-cyan);
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 4px;
  transition: opacity 0.2s;
}

.btn-tour-live-doc:hover {
  opacity: 0.8;
  text-decoration: underline;
}

#tour-title {
  color: #fff;
  font-size: 1.15rem;
  font-weight: 700;
  margin: 0;
}

.curator-note {
  font-size: 0.85rem;
  color: var(--text-secondary);
  line-height: 1.45;
}

.curator-spec-grid {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.8rem;
  background: rgba(0, 0, 0, 0.3);
  padding: 8px 12px;
  border-radius: 6px;
  border: 1px solid var(--border-subtle);
}

.spec-item {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.spec-label {
  color: var(--text-muted);
  font-weight: 600;
}

.museum-showcase-window {
  background: rgba(6, 9, 17, 0.88);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  margin-top: 4px;
}

.showcase-window-header {
  background: rgba(15, 23, 42, 0.95);
  padding: 6px 10px;
  display: flex;
  align-items: center;
  border-bottom: 1px solid var(--border-subtle);
  gap: 8px;
  font-size: 0.72rem;
}

.showcase-dots {
  display: flex;
  gap: 5px;
}

.showcase-dots .dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
}
.showcase-dots .dot.red { background: #ef4444; }
.showcase-dots .dot.yellow { background: #f59e0b; }
.showcase-dots .dot.green { background: #10b981; }

.showcase-title {
  color: var(--text-secondary);
  font-family: var(--font-mono);
  font-size: 0.72rem;
}

.showcase-scroll-status {
  margin-left: auto;
  color: var(--accent-cyan);
  font-family: var(--font-mono);
  font-size: 0.68rem;
}

.showcase-viewport {
  max-height: 160px;
  overflow-y: auto;
  padding: 10px;
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.docent-subtitle-hud {
  pointer-events: auto;
  position: fixed;
  bottom: 84px;
  left: 50%;
  transform: translateX(-50%);
  width: 90vw;
  max-width: 680px;
  background: var(--bg-hud);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--border-glow);
  border-radius: 12px;
  padding: 10px 18px;
  text-align: center;
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.65), 0 0 20px rgba(0, 239, 255, 0.1);
  z-index: 2010;
}

.docent-speaker-label {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-size: 0.72rem;
  color: var(--accent-cyan);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 4px;
}

.docent-transcript-text {
  margin: 0;
  font-size: 0.92rem;
  color: #fff;
  line-height: 1.5;
}

.museum-controls-bar {
  pointer-events: auto;
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--bg-hud);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--border-glow);
  border-radius: 40px;
  padding: 6px 16px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.65), 0 0 20px rgba(0, 239, 255, 0.15);
  z-index: 2010;
}

.btn-tour-ctrl, .btn-tour-playpause {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--border-subtle);
  color: #fff;
  border-radius: 20px;
  padding: 6px 14px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.btn-tour-playpause {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  padding: 0;
  background: var(--accent-cyan);
  color: #000;
  border: none;
  font-size: 1rem;
}

.btn-tour-ctrl:hover {
  background: rgba(255, 255, 255, 0.15);
  border-color: rgba(0, 239, 255, 0.4);
}

.tour-progress-wrapper {
  position: relative;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.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-linecap: round;
  stroke-dasharray: 100.53;
  stroke-dashoffset: 100.53;
  transition: stroke-dashoffset 0.15s;
}

.tts-speed-select {
  background: rgba(15, 23, 42, 0.85);
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  color: var(--text-primary);
  font-size: 0.75rem;
  padding: 3px 6px;
  outline: none;
  cursor: pointer;
}

/* ── Chat & Codex Command Panel ────────────────────────────────────── */
.chat-panel {
  position: fixed;
  top: 66px;
  right: 20px;
  width: 420px;
  max-width: calc(100vw - 40px);
  height: calc(100vh - 86px);
  background: var(--bg-card);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border: 1px solid var(--border-glow);
  border-radius: 16px;
  box-shadow: var(--shadow-lg), var(--shadow-glow);
  z-index: 1000;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: translateX(calc(100% + 40px));
  opacity: 0;
  pointer-events: none;
  transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.25s ease;
}

.chat-panel.is-visible {
  transform: translateX(0);
  opacity: 1;
  pointer-events: auto;
}

.chat-header {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(15, 23, 42, 0.75);
}

.chat-header-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.ai-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent-purple), var(--accent-cyan));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  color: #fff;
}

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

.chat-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: #fff;
}

.chat-subtitle {
  font-size: 0.72rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

.chat-header-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.btn-tour-pc {
  background: rgba(0, 239, 255, 0.1);
  border: 1px solid rgba(0, 239, 255, 0.3);
  color: var(--accent-cyan);
  border-radius: 6px;
  padding: 4px 8px;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

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

.icon-btn, .chat-header-actions button {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  transition: all 0.15s;
}

.icon-btn:hover, .chat-header-actions button:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.08);
}

.tps-strip {
  display: flex;
  align-items: center;
  justify-content: space-around;
  padding: 6px 12px;
  background: rgba(0, 0, 0, 0.35);
  border-bottom: 1px solid var(--border-subtle);
  font-size: 0.72rem;
  font-family: var(--font-mono);
}

.tps-item {
  display: flex;
  gap: 6px;
}

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

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

.chat-log {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.chat-msg {
  display: flex;
  flex-direction: column;
  max-width: 86%;
}

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

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

.msg-bubble {
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 0.88rem;
  line-height: 1.5;
}

.chat-msg.ai .msg-bubble {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-primary);
  border: 1px solid var(--border-subtle);
  border-bottom-left-radius: 2px;
}

.chat-msg.user .msg-bubble {
  background: linear-gradient(135deg, #1e3a8a, #2563eb);
  color: #fff;
  border-bottom-right-radius: 2px;
}

.source-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
}

.source-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: rgba(0, 239, 255, 0.08);
  border: 1px solid rgba(0, 239, 255, 0.2);
  color: var(--accent-cyan);
  font-size: 0.72rem;
  font-family: var(--font-mono);
  padding: 2px 8px;
  border-radius: 4px;
  text-decoration: none;
}

.chat-input-area {
  padding: 12px 14px;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(15, 23, 42, 0.7);
}

#chat-input {
  flex: 1;
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  padding: 8px 12px;
  color: #fff;
  font-size: 0.88rem;
  resize: none;
  outline: none;
  font-family: var(--font-sans);
}

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

#btn-send, #btn-stop-gen {
  background: var(--accent-cyan);
  border: none;
  border-radius: 8px;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #000;
  cursor: pointer;
  transition: opacity 0.2s;
}

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

.download-overlay {
  padding: 24px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

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

.model-tag {
  background: rgba(0, 239, 255, 0.1);
  color: var(--accent-cyan);
  border: 1px solid rgba(0, 239, 255, 0.25);
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 0.75rem;
  font-family: var(--font-mono);
}

.download-progress {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.progress-bar-track {
  width: 100%;
  height: 6px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 3px;
  overflow: hidden;
}

.progress-bar-fill {
  width: 0%;
  height: 100%;
  background: var(--accent-cyan);
  transition: width 0.2s;
}

/* ── Floating Action Buttons (FABs) ────────────────────────────────── */
.fab-group {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column-reverse;
  align-items: center;
  gap: 12px;
  z-index: 1200;
}

#fab-trigger {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent-purple), #2563eb);
  border: 2px solid rgba(255, 255, 255, 0.2);
  color: #fff;
  font-size: 1.3rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5), 0 0 15px rgba(124, 58, 237, 0.4);
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.25s;
}

#fab-trigger:hover {
  transform: scale(1.08);
}

.fab-sub {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: rgba(15, 23, 42, 0.92);
  backdrop-filter: blur(8px);
  border: 1px solid var(--border-glow);
  color: var(--accent-cyan);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.45);
  transition: transform 0.25s ease, opacity 0.2s ease;
  transform: scale(0.6) translateY(20px);
  opacity: 0;
  pointer-events: none;
}

.fab-sub svg {
  width: 20px;
  height: 20px;
}

.fab-group.is-open .fab-sub {
  transform: scale(1) translateY(0);
  opacity: 1;
  pointer-events: auto;
}

.fab-who-made {
  position: fixed;
  bottom: 24px;
  left: 24px;
  background: var(--bg-hud);
  backdrop-filter: blur(10px);
  border: 1px solid var(--border-glow);
  color: var(--accent-cyan);
  padding: 8px 16px;
  border-radius: 30px;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  z-index: 1100;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.45);
  transition: all 0.2s;
}

.fab-who-made:hover {
  background: var(--accent-cyan);
  color: #000;
  box-shadow: 0 0 15px rgba(0, 239, 255, 0.5);
}

/* ── Modals & Backdrop Blur ────────────────────────────────────────── */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.82);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  z-index: 10000;
  display: none !important;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.modal-backdrop.is-active {
  display: flex !important;
  opacity: 1 !important;
  pointer-events: auto !important;
}

.modal-card {
  background: rgba(15, 23, 42, 0.96);
  border: 1px solid var(--border-glow);
  border-radius: 16px;
  padding: 24px;
  max-width: 540px;
  width: 90vw;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.85), 0 0 30px rgba(0, 239, 255, 0.15);
  position: relative;
  color: var(--text-primary);
}

.modal-header {
  margin-bottom: 12px;
}

.modal-title {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 700;
}

.modal-body {
  font-size: 0.9rem;
  color: var(--text-secondary);
  line-height: 1.55;
  margin-bottom: 16px;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.btn {
  padding: 8px 16px;
  border-radius: 6px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: opacity 0.2s;
}

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

.btn-primary:hover {
  opacity: 0.9;
}

.btn-close-modal {
  position: absolute;
  top: 16px;
  right: 16px;
  background: rgba(255, 255, 255, 0.08);
  border: none;
  border-radius: 50%;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  cursor: pointer;
  font-size: 0.9rem;
  transition: background 0.15s;
}

.btn-close-modal:hover {
  background: rgba(255, 255, 255, 0.2);
}

.btn-download {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: linear-gradient(135deg, #0284c7, #2563eb);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 10px 18px;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: opacity 0.2s;
}

.btn-download:hover {
  opacity: 0.9;
}

/* ── Tooltips & Toasts ─────────────────────────────────────────────── */
.toast-container {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 11000;
  pointer-events: none;
}

.toast-message {
  background: var(--bg-hud);
  border: 1px solid var(--border-glow);
  color: #fff;
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 0.85rem;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.6);
  animation: fadeInOut 3s forwards;
}

@keyframes fadeInOut {
  0% { opacity: 0; transform: translateY(10px); }
  10% { opacity: 1; transform: translateY(0); }
  85% { opacity: 1; transform: translateY(0); }
  100% { opacity: 0; transform: translateY(-10px); }
}

.graph-tooltip-small {
  position: fixed;
  pointer-events: none;
  background: rgba(15, 23, 42, 0.92);
  backdrop-filter: blur(8px);
  border: 1px solid var(--border-glow);
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 0.78rem;
  color: var(--accent-cyan);
  font-family: var(--font-mono);
  z-index: 5000;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.5);
  display: none;
}

.graph-tooltip-small.is-visible {
  display: block;
}

/* ── Markdown Content Styling ──────────────────────────────────────── */
.markdown-body {
  color: var(--text-primary);
  font-size: 0.88rem;
  line-height: 1.6;
}

.markdown-body h1, .markdown-body h2, .markdown-body h3, .markdown-body h4 {
  color: #fff;
  margin-top: 1em;
  margin-bottom: 0.5em;
  font-weight: 700;
}

.markdown-body pre {
  background: rgba(0, 0, 0, 0.45);
  padding: 12px;
  border-radius: 6px;
  overflow-x: auto;
  border: 1px solid var(--border-subtle);
  font-family: var(--font-mono);
  font-size: 0.82rem;
}

.markdown-body code {
  background: rgba(0, 0, 0, 0.3);
  padding: 2px 6px;
  border-radius: 4px;
  font-family: var(--font-mono);
  color: var(--accent-cyan);
  font-size: 0.85em;
}

.markdown-body a {
  color: var(--accent-cyan);
  text-decoration: none;
}

.markdown-body a:hover {
  text-decoration: underline;
}

.markdown-body ul, .markdown-body ol {
  padding-left: 20px;
}

/* ── Split Header Dual Button (Preserved Compatibility) ────────────── */
.header-btn-dual {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.05);
  padding: 2px 3px;
  font-size: 0.82em;
  font-weight: 600;
  line-height: 1.4;
  vertical-align: middle;
  transition: all 0.15s ease-in-out;
}

.header-btn-dual:hover {
  border-color: var(--border-glow);
}

.header-btn-dual .dual-link {
  display: inline-flex;
  align-items: center;
  padding: 3px 8px;
  text-decoration: none;
  color: var(--text-secondary);
  border-radius: 4px;
  font-size: 0.9em;
  font-weight: 600;
  transition: all 0.15s ease;
  cursor: pointer;
}

.header-btn-dual .dual-link:hover {
  background-color: rgba(255, 255, 255, 0.1);
  color: #fff;
}

/* ── Scoped Element Loading Overlay ────────────────────────────────── */
.ameva-loading-container {
  position: relative !important;
  min-height: 80px;
}

.ameva-loading-overlay {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.88);
  backdrop-filter: blur(4px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  z-index: 50;
  border-radius: inherit;
  transition: opacity 0.2s ease;
  pointer-events: all;
}

.ameva-spinner {
  width: 28px;
  height: 28px;
  border: 3px solid rgba(0, 239, 255, 0.15);
  border-top-color: var(--accent-cyan);
  border-right-color: var(--accent-cyan);
  border-radius: 50%;
  animation: ameva-spin 0.75s linear infinite;
}

.ameva-loading-text {
  font-size: 0.82em;
  font-weight: 600;
  color: var(--text-secondary);
  letter-spacing: 0.3px;
  font-family: var(--font-mono);
}

/* ── Neural Fabric High-Contrast Links ────────────────────────────── */
.graph-link {
  opacity: 1 !important;
  stroke: rgba(0, 239, 255, 0.65) !important;
  stroke-width: 2px !important;
  stroke-linecap: round;
  pointer-events: none;
  transition: stroke 0.2s ease, stroke-width 0.2s ease, stroke-opacity 0.2s ease;
}
.graph-link.is-active {
  stroke: #00EFFF !important;
  stroke-width: 3.5px !important;
  stroke-opacity: 1 !important;
  filter: drop-shadow(0 0 10px #00EFFF);
}
.graph-link.is-dimmed {
  stroke-opacity: 0.15 !important;
}
