/* Design System Variables */
:root {
  --bg-gradient: radial-gradient(circle at 50% 0%, #0d1e30 0%, #050b11 70%, #020406 100%);
  --bg-color: #050b11;
  --card-bg: rgba(13, 27, 43, 0.72);
  --card-bg-solid: #0b1522;
  --card-border: rgba(112, 214, 255, 0.16);
  --card-border-glow: rgba(112, 214, 255, 0.45);
  
  /* Text colors */
  --color-ink: #f0f6fc;
  --color-muted: #8b9eb0;
  --color-subtle: #5f748a;
  
  /* Glowing Neon Accents */
  --accent-cyan: #00f0ff;
  --accent-cyan-rgb: 0, 240, 255;
  --accent-purple: #bd93f9;
  --accent-gold: #ffb86c;
  --accent-green: #50fa7b;
  --accent-pink: #ff79c6;
  --accent-red: #ff5555;
  
  /* Theme mapping colors */
  --dot-article: #00f0ff;
  --dot-point: #bd93f9;
  --dot-source: #ff79c6;
  --dot-theme: #ffb86c;
  
  /* Structural variables */
  --radius-lg: 20px;
  --radius-md: 14px;
  --radius-sm: 8px;
  --shadow-neon: 0 0 20px rgba(0, 240, 255, 0.15);
  --shadow-neon-hover: 0 0 35px rgba(0, 240, 255, 0.35);
  --font-display: 'Outfit', sans-serif;
  --font-body: 'Inter', sans-serif;
  --transition-fast: 0.18s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-normal: 0.28s cubic-bezier(0.4, 0, 0.2, 1);
}

/* LIGHT THEME (Sand Yellow / Gold Graph Paper style) */
.light-theme {
  --bg-gradient: radial-gradient(circle at 50% 0%, #fffcf5 0%, #f7f1e1 60%, #eeddb8 100%);
  --bg-color: #faf4e3;
  --card-bg: rgba(253, 250, 242, 0.88);
  --card-bg-solid: #fcfbf8;
  --card-border: rgba(196, 154, 108, 0.28);
  --card-border-glow: rgba(196, 154, 108, 0.65);
  
  /* Text colors */
  --color-ink: #2b2015;
  --color-muted: #73604f;
  --color-subtle: #a69280;
  
  /* Amber/Gold Accents */
  --accent-cyan: #c4943c;
  --accent-cyan-rgb: 196, 148, 60;
  --accent-purple: #7a3ebb;
  --accent-gold: #b37d14;
  --accent-green: #2e7d32;
  --accent-pink: #d81b60;
  --accent-red: #c62828;
  
  /* Theme mapping colors */
  --dot-article: #c4943c;
  --dot-point: #7a3ebb;
  --dot-source: #d81b60;
  --dot-theme: #b37d14;
  
  --shadow-neon: 0 10px 30px rgba(196, 154, 108, 0.14);
  --shadow-neon-hover: 0 15px 40px rgba(196, 154, 108, 0.32);
}

/* READING-FRIENDLY THEME (Warm Sepia Parchment / Eye-Comfort Editorial) */
.reading-theme {
  --bg-gradient: radial-gradient(circle at 50% 0%, #fcf8f2 0%, #f4ede4 60%, #eae0d0 100%);
  --bg-color: #f4ede4;
  --card-bg: rgba(254, 252, 248, 0.94);
  --card-bg-solid: #fcfaf6;
  --card-border: rgba(180, 142, 95, 0.24);
  --card-border-glow: rgba(180, 142, 95, 0.55);
  
  /* High-legibility warm text colors */
  --color-ink: #292524;
  --color-muted: #57534e;
  --color-subtle: #78716c;
  
  /* Warm Earthy & Amber Accents */
  --accent-cyan: #b45309;
  --accent-cyan-rgb: 180, 83, 9;
  --accent-purple: #7c2d12;
  --accent-gold: #d97706;
  --accent-green: #15803d;
  --accent-pink: #be123c;
  --accent-red: #991b1b;
  
  /* Theme mapping colors */
  --dot-article: #b45309;
  --dot-point: #475569;
  --dot-source: #be123c;
  --dot-theme: #c2410c;
  
  --shadow-neon: 0 8px 24px rgba(180, 142, 95, 0.12);
  --shadow-neon-hover: 0 12px 32px rgba(180, 142, 95, 0.25);
}

/* Base resets & layouts */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  height: 100%;
  width: 100%;
  background: var(--bg-color);
  background-image: var(--bg-gradient);
  color: var(--color-ink);
  font-family: var(--font-body);
  overflow: hidden;
  transition: background var(--transition-normal);
}

/* Graph Paper Grid */
body::before {
  content: "";
  position: fixed;
  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: 32px 32px;
  mask-image: radial-gradient(circle at center, black, transparent 80%);
  pointer-events: none;
  z-index: 1;
}

.light-theme body::before {
  background-image: 
    linear-gradient(rgba(196, 154, 108, 0.09) 1px, transparent 1px),
    linear-gradient(90deg, rgba(196, 154, 108, 0.09) 1px, transparent 1px);
  background-size: 36px 36px;
  mask-image: radial-gradient(circle at center, black, transparent 90%);
}

.reading-theme body::before {
  background-image: 
    linear-gradient(rgba(180, 142, 95, 0.07) 1px, transparent 1px),
    linear-gradient(90deg, rgba(180, 142, 95, 0.07) 1px, transparent 1px);
  background-size: 34px 34px;
  mask-image: radial-gradient(circle at center, black, transparent 90%);
}

/* App Grid Structure */
.app-container {
  display: grid;
  grid-template-columns: auto 1fr auto;
  height: 100vh;
  gap: 0;
  padding: 16px;
  position: relative;
  z-index: 2;
  transition: padding var(--transition-normal);
}

/* Central WebGL Viewport Container */
.viewport-container {
  position: relative;
  height: 100%;
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: #02060b;
  box-shadow: inset 0 0 60px rgba(0, 0, 0, 0.8);
  border: 1px solid var(--card-border);
}

.light-theme .viewport-container {
  background: #fdfdf9;
  box-shadow: inset 0 0 40px rgba(196, 154, 108, 0.08);
}

.reading-theme .viewport-container {
  background: #fbf7ee;
  box-shadow: inset 0 0 40px rgba(180, 142, 95, 0.08);
}

.threejs-wrapper {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
}

#threejs-canvas {
  width: 100%;
  height: 100%;
  display: block;
}

/* Sidebars Base Styling */
.sidebar-left, .sidebar-right {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
  position: relative;
  z-index: 10;
}

.sidebar-left {
  width: 340px;
  padding: 20px;
  margin-right: 16px;
  overflow-y: auto;
  overflow-x: hidden;
  transition: width var(--transition-normal), margin var(--transition-normal), padding var(--transition-normal), opacity var(--transition-normal), border var(--transition-normal), transform var(--transition-normal);
}

.sidebar-left.collapsed {
  width: 0 !important;
  margin-right: 0 !important;
  padding: 0 !important;
  opacity: 0 !important;
  border: none !important;
  pointer-events: none;
}

.sidebar-right {
  width: 420px;
  margin-left: 16px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: width var(--transition-normal), margin var(--transition-normal), padding var(--transition-normal), opacity var(--transition-normal), border var(--transition-normal), transform var(--transition-normal), backdrop-filter 0.4s ease;
}

.sidebar-right.collapsed {
  width: 0 !important;
  margin-left: 0 !important;
  padding: 0 !important;
  opacity: 0 !important;
  border: none !important;
  pointer-events: none;
}

/* Top floating status pill bar */
.top-pillbar {
  position: absolute;
  top: 16px;
  left: 16px;
  right: 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  z-index: 20;
  pointer-events: none;
  transition: transform 0.4s ease, opacity 0.4s ease;
}

.top-pillbar > * {
  pointer-events: auto;
}

/* Zen Focus Mode behavior - Ghost Translucent Sidebars */
.app-container.zen-focus-mode .sidebar-left {
  opacity: 0.12;
  filter: blur(0.5px);
  pointer-events: auto;
  transition: opacity 0.4s ease, filter 0.4s ease;
}

.app-container.zen-focus-mode .sidebar-left:hover {
  opacity: 0.96;
  filter: none;
}

.app-container.zen-focus-mode .sidebar-right {
  opacity: 0.12;
  filter: blur(0.5px);
  pointer-events: auto;
  transition: opacity 0.4s ease, filter 0.4s ease;
}

.app-container.zen-focus-mode .sidebar-right:hover {
  opacity: 0.96;
  filter: none;
}

.app-container.zen-focus-mode .top-pillbar {
  transform: translateY(-130%) !important;
  opacity: 0 !important;
  pointer-events: none;
}

/* Glassmorphic Cards */
.glass-card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.4), var(--shadow-neon);
  border-radius: var(--radius-lg);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  transition: border-color var(--transition-normal), box-shadow var(--transition-normal), background var(--transition-normal);
}

.glass-card:hover {
  border-color: rgba(var(--accent-cyan-rgb), 0.28);
}

.light-theme .glass-card {
  box-shadow: 0 15px 40px rgba(196, 154, 108, 0.12), var(--shadow-neon);
}

.light-theme .glass-card:hover {
  border-color: rgba(196, 154, 108, 0.45);
}

.reading-theme .glass-card {
  background: rgba(254, 252, 248, 0.94);
  border-color: rgba(180, 142, 95, 0.24);
  box-shadow: 0 12px 35px rgba(180, 142, 95, 0.1), var(--shadow-neon);
}

.reading-theme .glass-card:hover {
  border-color: rgba(180, 142, 95, 0.5);
}

/* LEFT SIDEBAR: Brand & Controls */
.sidebar-left {
  padding: 20px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 18px;
}

.brand-logo {
  width: 46px;
  height: 46px;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--accent-cyan), var(--accent-purple), var(--accent-pink));
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  box-shadow: 0 8px 24px rgba(var(--accent-cyan-rgb), 0.3);
}

.logo-inner {
  width: 22px;
  height: 22px;
  border-radius: 6px;
  background: var(--bg-color);
  animation: logo-rotate 8s linear infinite;
  transition: background var(--transition-normal);
}

@keyframes logo-rotate {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.brand-text h1 {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.5px;
  line-height: 1.1;
}

.brand-text .subtitle {
  font-size: 11px;
  color: var(--color-muted);
  letter-spacing: 0.5px;
}

/* Stats Summary Widget */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-bottom: 16px;
}

.stat-card {
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.035);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: var(--radius-md);
  display: flex;
  flex-direction: column;
}

.light-theme .stat-card {
  background: rgba(196, 154, 108, 0.06);
  border: 1px solid rgba(196, 154, 108, 0.12);
}

.stat-val {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 700;
  color: var(--accent-cyan);
}

.stat-label {
  font-size: 11px;
  color: var(--color-muted);
  margin-top: 2px;
}

/* Tour Banner Widget */
.tour-banner {
  position: relative;
  background: linear-gradient(135deg, rgba(189, 147, 249, 0.2) 0%, rgba(112, 214, 255, 0.1) 100%);
  border: 1px solid rgba(189, 147, 249, 0.3);
  border-radius: var(--radius-md);
  padding: 14px;
  margin-bottom: 18px;
  overflow: hidden;
  transition: transform var(--transition-fast);
}

.light-theme .tour-banner {
  background: linear-gradient(135deg, rgba(196, 154, 108, 0.15) 0%, rgba(196, 154, 108, 0.05) 100%);
  border-color: rgba(196, 154, 108, 0.3);
}

.tour-banner:hover {
  transform: translateY(-2px);
  border-color: rgba(189, 147, 249, 0.5);
  box-shadow: 0 8px 30px rgba(189, 147, 249, 0.2);
}

.light-theme .tour-banner:hover {
  border-color: rgba(196, 154, 108, 0.5);
  box-shadow: 0 8px 30px rgba(196, 154, 108, 0.15);
}

.banner-glow {
  position: absolute;
  top: -50px;
  right: -50px;
  width: 120px;
  height: 120px;
  background: radial-gradient(circle, rgba(189, 147, 249, 0.4) 0%, transparent 70%);
  filter: blur(10px);
  pointer-events: none;
}

.light-theme .banner-glow {
  background: radial-gradient(circle, rgba(196, 154, 108, 0.4) 0%, transparent 70%);
}

.banner-content h3 {
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 700;
  color: var(--color-ink);
  margin-bottom: 4px;
}

.banner-content p {
  font-size: 11.5px;
  color: var(--color-muted);
  line-height: 1.35;
  margin-bottom: 12px;
}

/* Standard Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.05);
  color: var(--color-ink);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  cursor: pointer;
  font-size: 12.5px;
  font-weight: 600;
  outline: none;
  transition: transform var(--transition-fast), background var(--transition-fast), border-color var(--transition-fast);
}

.light-theme .btn {
  border-color: rgba(196, 154, 108, 0.28);
  background: rgba(196, 154, 108, 0.06);
}

.btn:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.2);
  transform: translateY(-1px);
}

.light-theme .btn:hover {
  background: rgba(196, 154, 108, 0.14);
  border-color: rgba(196, 154, 108, 0.4);
}

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

.btn-primary {
  background: linear-gradient(135deg, rgba(189, 147, 249, 0.8), rgba(112, 214, 255, 0.8));
  border-color: rgba(189, 147, 249, 0.5);
  text-shadow: 0 1px 2px rgba(0,0,0,0.3);
}

.light-theme .btn-primary {
  background: linear-gradient(135deg, #c4943c, #b37d14);
  border-color: #b37d14;
  color: #ffffff;
  text-shadow: none;
}

.btn-glow {
  box-shadow: 0 0 15px rgba(189, 147, 249, 0.35);
}

.light-theme .btn-glow {
  box-shadow: 0 0 15px rgba(196, 154, 108, 0.35);
}

.btn-glow:hover {
  box-shadow: 0 0 25px rgba(189, 147, 249, 0.55);
}

.light-theme .btn-glow:hover {
  box-shadow: 0 0 25px rgba(196, 154, 108, 0.55);
}

/* Search Box Container */
.search-box {
  position: relative;
  margin-bottom: 18px;
}

.search-box input {
  width: 100%;
  background: #03080e;
  border: 1px solid var(--card-border);
  border-radius: var(--radius-md);
  padding: 12px 14px 12px 38px;
  color: var(--color-ink);
  font-size: 13px;
  outline: none;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.light-theme .search-box input {
  background: #ffffff;
  border-color: rgba(196, 154, 108, 0.35);
}

.search-box input:focus {
  border-color: var(--accent-cyan);
  box-shadow: 0 0 12px rgba(var(--accent-cyan-rgb), 0.25);
}

.search-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 14px;
  color: var(--color-muted);
}

/* Sections inside control panels */
.section-title {
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--accent-cyan);
  margin: 14px 0 10px;
}

.control-group {
  margin-bottom: 14px;
}

.control-label {
  display: block;
  font-size: 11.5px;
  color: var(--color-muted);
  margin-bottom: 6px;
}

/* Button Toggle Group */
.button-toggle-group {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px;
}

.toggle-btn {
  background: rgba(255, 255, 255, 0.035);
  border: 1px solid rgba(255, 255, 255, 0.06);
  color: var(--color-muted);
  border-radius: var(--radius-sm);
  padding: 8px 6px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition-fast);
}

.light-theme .toggle-btn {
  background: rgba(196, 154, 108, 0.05);
  border-color: rgba(196, 154, 108, 0.12);
}

.toggle-btn:hover {
  background: rgba(255, 255, 255, 0.07);
  color: var(--color-ink);
}

.light-theme .toggle-btn:hover {
  background: rgba(196, 154, 108, 0.12);
}

.toggle-btn.active {
  background: linear-gradient(135deg, rgba(var(--accent-cyan-rgb), 0.16), rgba(189, 147, 249, 0.1));
  border-color: rgba(var(--accent-cyan-rgb), 0.4);
  color: var(--accent-cyan);
  font-weight: 600;
  box-shadow: 0 0 10px rgba(var(--accent-cyan-rgb), 0.1);
}

/* Custom Select Tag */
.custom-select {
  width: 100%;
  background: #03080e;
  border: 1px solid var(--card-border);
  color: var(--color-ink);
  border-radius: var(--radius-sm);
  padding: 10px;
  outline: none;
  font-size: 12.5px;
  cursor: pointer;
  transition: border-color var(--transition-fast);
}

.light-theme .custom-select {
  background: #ffffff;
  border-color: rgba(196, 154, 108, 0.35);
}

.custom-select:focus {
  border-color: var(--accent-cyan);
}

/* Sliders */
.control-sliders {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 18px;
}

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

.slider-header {
  display: flex;
  justify-content: space-between;
  font-size: 11.5px;
  color: var(--color-muted);
}

.custom-slider {
  -webkit-appearance: none;
  width: 100%;
  height: 4px;
  border-radius: 99px;
  background: rgba(255,255,255,0.1);
  outline: none;
}

.light-theme .custom-slider {
  background: rgba(196, 154, 108, 0.18);
}

.custom-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent-cyan);
  cursor: pointer;
  box-shadow: 0 0 10px var(--accent-cyan);
  transition: transform var(--transition-fast);
}

.custom-slider::-webkit-slider-thumb:hover {
  transform: scale(1.2);
}

/* Search results list */
.results-container {
  flex: 1;
  overflow-y: auto;
  padding-right: 4px;
}

.results-container::-webkit-scrollbar {
  width: 4px;
}

.results-container::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.1);
  border-radius: 99px;
}

.empty-state {
  font-size: 12px;
  color: var(--color-subtle);
  text-align: center;
  padding: 20px 0;
}

/* Individual Search Hit */
.search-hit-item {
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.04);
  margin-bottom: 8px;
  cursor: pointer;
  transition: var(--transition-fast);
}

.light-theme .search-hit-item {
  background: #ffffff;
  border-color: rgba(196, 154, 108, 0.15);
}

.search-hit-item:hover {
  background: rgba(var(--accent-cyan-rgb), 0.08);
  border-color: rgba(var(--accent-cyan-rgb), 0.25);
  transform: translateX(2px);
}

.search-hit-item b {
  display: block;
  font-size: 13px;
  color: var(--color-ink);
}

.search-hit-item span {
  display: block;
  font-size: 11.5px;
  color: var(--color-muted);
  margin-top: 3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-footer {
  font-size: 10.5px;
  color: var(--color-subtle);
  line-height: 1.4;
  border-top: 1px solid rgba(255,255,255,0.06);
  padding-top: 10px;
  margin-top: 10px;
}

.light-theme .sidebar-footer {
  border-top-color: rgba(196, 154, 108, 0.15);
}

/* CENTRAL GRAPH VIEWPORT */
.viewport-container {
  position: relative;
  height: 100%;
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: #02060b;
}

.light-theme .viewport-container {
  background: #fdfdf9;
}

.threejs-wrapper {
  position: absolute;
  inset: 0;
  z-index: 1;
}

#threejs-canvas {
  width: 100%;
  height: 100%;
  display: block;
}

/* Floating Top Pillbar */
.top-pillbar {
  position: absolute;
  top: 16px;
  left: 16px;
  right: 16px;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  pointer-events: none;
}

.pill-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(3, 8, 14, 0.7);
  border: 1px solid var(--card-border);
  border-radius: 99px;
  padding: 8px 14px;
  pointer-events: auto;
  box-shadow: 0 8px 30px rgba(0,0,0,0.3);
}

.light-theme .pill-badge {
  background: rgba(253, 250, 242, 0.88);
  box-shadow: 0 8px 24px rgba(196, 154, 108, 0.12);
}

.active-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent-green);
  box-shadow: 0 0 8px var(--accent-green);
  animation: pulse-green 2s infinite;
}

@keyframes pulse-green {
  0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(80, 250, 123, 0.7); }
  70% { transform: scale(1); box-shadow: 0 0 0 6px rgba(80, 250, 123, 0); }
  100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(80, 250, 123, 0); }
}

.pill-badge span:last-child {
  font-family: var(--font-display);
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: 0.3px;
}

.pill-actions {
  display: flex;
  gap: 8px;
  pointer-events: auto;
}

.btn-action {
  background: rgba(3, 8, 14, 0.7);
  border: 1px solid var(--card-border);
  border-radius: 99px;
  padding: 8px 16px;
}

.light-theme .btn-action {
  background: rgba(253, 250, 242, 0.88);
  color: var(--color-ink);
}

.btn-action:hover {
  border-color: var(--accent-cyan);
  color: var(--accent-cyan);
  box-shadow: 0 0 15px rgba(var(--accent-cyan-rgb), 0.25);
}

/* ANIME STORY TOUR OVERLAY */
.anime-story-tour-overlay {
  position: absolute;
  inset: 0;
  z-index: 100;
  pointer-events: none;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 24px;
  background: rgba(3, 6, 10, 0.4);
  transition: opacity var(--transition-normal);
}

.anime-story-tour-overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

/* Background Speedlines animation */
.anime-speedlines {
  position: absolute;
  inset: 0;
  background-image: radial-gradient(circle, transparent 20%, rgba(var(--accent-cyan-rgb), 0.05) 50%, rgba(189, 147, 249, 0.15) 100%),
                    repeating-conic-gradient(from 0deg, transparent 0deg 8deg, rgba(255,255,255,0.035) 9deg 12deg, transparent 13deg 20deg);
  pointer-events: none;
  animation: speedlines-spin 25s linear infinite;
  opacity: 0.75;
  z-index: 1;
}

.light-theme .anime-speedlines {
  background-image: radial-gradient(circle, transparent 20%, rgba(196, 154, 108, 0.08) 50%, rgba(196, 154, 108, 0.15) 100%),
                    repeating-conic-gradient(from 0deg, transparent 0deg 8deg, rgba(196,154,108,0.06) 9deg 12deg, transparent 13deg 20deg);
}

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

/* Dialog Container Card */
.story-dialog-box {
  width: min(840px, 100%);
  display: flex;
  align-items: stretch;
  gap: 20px;
  padding: 20px;
  z-index: 10;
  pointer-events: auto;
  border-color: rgba(189, 147, 249, 0.4);
  background: rgba(13, 20, 32, 0.92);
  transform: translateY(0);
  transition: transform var(--transition-normal);
  animation: dialog-intro var(--transition-normal) forwards;
}

.light-theme .story-dialog-box {
  background: rgba(253, 250, 242, 0.96);
  border-color: rgba(196, 154, 108, 0.45);
}

@keyframes dialog-intro {
  from { transform: translateY(50px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

/* Mascot Chibi Character Design (CSS / SVG structure) */
.mascot-widget {
  width: 140px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
  flex-shrink: 0;
}

.mascot-avatar {
  width: 100px;
  height: 100px;
  position: relative;
  animation: mascot-float 3s ease-in-out infinite;
}

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

/* Cute Chibi Hair and Face styling */
.mascot-face {
  position: absolute;
  top: 25px;
  left: 20px;
  width: 60px;
  height: 52px;
  background: #ffebd2;
  border-radius: 30px 30px 24px 24px;
  z-index: 2;
  box-shadow: inset 0 -4px 8px rgba(0,0,0,0.1);
  overflow: hidden;
}

.mascot-hair-back {
  position: absolute;
  top: 15px;
  left: 12px;
  width: 76px;
  height: 70px;
  background: var(--accent-purple);
  border-radius: 40px 40px 10px 10px;
  z-index: 1;
}

.mascot-hair-front {
  position: absolute;
  top: 15px;
  left: 15px;
  width: 70px;
  height: 25px;
  background: var(--accent-purple);
  border-radius: 40px 40px 0 0;
  z-index: 3;
  clip-path: polygon(0% 0%, 100% 0%, 90% 100%, 75% 60%, 55% 90%, 45% 60%, 25% 100%, 10% 60%);
}

.mascot-blush {
  position: absolute;
  top: 32px;
  left: 5%;
  width: 90%;
  height: 6px;
  display: flex;
  justify-content: space-between;
  padding: 0 6px;
}

.mascot-blush::before, .mascot-blush::after {
  content: "";
  width: 8px;
  height: 5px;
  background: rgba(255, 105, 180, 0.5);
  border-radius: 50%;
  filter: blur(1px);
}

.mascot-eyes {
  position: absolute;
  top: 22px;
  left: 10px;
  width: 40px;
  height: 12px;
  display: flex;
  justify-content: space-between;
}

.eye {
  width: 11px;
  height: 11px;
  background: #25123d;
  border-radius: 50%;
  position: relative;
  overflow: hidden;
  animation: eye-blink 4s linear infinite;
  transform-origin: center;
}

.pupil {
  width: 4px;
  height: 4px;
  background: #ffffff;
  border-radius: 50%;
  position: absolute;
  top: 2px;
  left: 2px;
}

@keyframes eye-blink {
  0%, 95%, 100% { transform: scaleY(1); }
  97% { transform: scaleY(0.1); }
}

.mascot-mouth {
  position: absolute;
  bottom: 8px;
  left: 27px;
  width: 6px;
  height: 4px;
  border-bottom: 2px solid #25123d;
  border-radius: 0 0 4px 4px;
  transition: all var(--transition-fast);
}

.mascot-body {
  position: absolute;
  bottom: 0;
  left: 32px;
  width: 36px;
  height: 28px;
  background: linear-gradient(180deg, var(--accent-pink) 0%, var(--accent-purple) 100%);
  border-radius: 12px 12px 0 0;
  z-index: 1;
}

/* Expressive Chibi Mouth States */
.mascot-avatar.happy .mascot-mouth {
  width: 8px;
  height: 6px;
  left: 26px;
  border-radius: 0 0 6px 6px;
  border-bottom: 3px solid #25123d;
  background: #ff5555;
}

.mascot-avatar.excited .mascot-mouth {
  width: 10px;
  height: 10px;
  left: 25px;
  bottom: 6px;
  border-radius: 0 0 10px 10px;
  background: #ff5555;
  border: 2px solid #25123d;
}

.mascot-avatar.thinking .mascot-mouth {
  width: 8px;
  height: 2px;
  left: 26px;
  bottom: 10px;
  background: #25123d;
  border: none;
  border-radius: 2px;
  transform: rotate(-10deg);
}

.mascot-nametag {
  background: var(--accent-purple);
  color: #060c13;
  font-family: var(--font-display);
  font-size: 11px;
  font-weight: 800;
  border-radius: 99px;
  padding: 3px 10px;
  margin-top: 10px;
  box-shadow: 0 4px 12px rgba(189, 147, 249, 0.4);
}

.light-theme .mascot-nametag {
  color: #ffffff;
}

/* Speech Balloon controls */
.speech-balloon {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.tour-chapter-badge {
  font-family: var(--font-display);
  font-size: 10.5px;
  font-weight: 800;
  color: var(--accent-purple);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 4px;
}

.tour-step-title {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 700;
  color: var(--color-ink);
  margin-bottom: 8px;
}

.tour-step-text {
  font-size: 13.5px;
  line-height: 1.5;
  color: #d0dbe5;
  margin-bottom: 16px;
  flex: 1;
}

.light-theme .tour-step-text {
  color: var(--color-ink);
}

.tour-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-top: 1px solid rgba(255,255,255,0.06);
  padding-top: 12px;
}

.light-theme .tour-actions {
  border-top-color: rgba(196,154,108,0.15);
}

.btn-tour {
  padding: 8px 16px;
  font-size: 12px;
  border-radius: var(--radius-sm);
}

.btn-tour-primary {
  background: var(--accent-purple);
  color: #060c13;
  border-color: var(--accent-purple);
  box-shadow: 0 0 15px rgba(189,147,249,0.3);
}

.light-theme .btn-tour-primary {
  color: #ffffff;
}

.btn-tour-primary:hover {
  background: #cba2ff;
  border-color: #cba2ff;
  color: #060c13;
}

.light-theme .btn-tour-primary:hover {
  color: #ffffff;
  background: #8e51d2;
}

.btn-tour-skip {
  background: transparent;
  border-color: transparent;
  color: var(--color-muted);
}

.btn-tour-skip:hover {
  background: rgba(255,255,255,0.05);
  color: var(--color-ink);
}

.tour-nav-btns {
  display: flex;
  gap: 8px;
}

/* RIGHT SIDEBAR: Inspector Details Panel */
.sidebar-right {
  padding: 0;
}

.panel-header {
  padding: 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.light-theme .panel-header {
  border-bottom-color: rgba(196, 154, 108, 0.15);
}

.panel-header h2 {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 700;
}

.btn-header {
  font-size: 11.5px;
  padding: 6px 10px;
}

.panel-content {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
}

.panel-content::-webkit-scrollbar {
  width: 4px;
}

.panel-content::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.1);
  border-radius: 99px;
}

/* Default Inspector Intro */
.default-inspector-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  text-align: center;
  color: var(--color-muted);
  padding: 20px 10px;
}

.inspector-icon {
  font-size: 32px;
  margin-bottom: 14px;
  opacity: 0.65;
}

.default-inspector-state h3 {
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 600;
  color: var(--color-ink);
  margin-bottom: 8px;
}

.default-inspector-state p {
  font-size: 12.5px;
  line-height: 1.45;
  margin-bottom: 24px;
}

.quick-tips {
  width: 100%;
  text-align: left;
  background: rgba(255,255,255,0.02);
  border: 1px solid rgba(255,255,255,0.04);
  border-radius: var(--radius-md);
  padding: 14px;
}

.light-theme .quick-tips {
  background: rgba(196, 154, 108, 0.04);
  border-color: rgba(196, 154, 108, 0.12);
}

.quick-tips h4 {
  font-size: 12px;
  font-weight: 700;
  color: var(--accent-cyan);
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.quick-tips ul {
  list-style-type: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.quick-tips li {
  font-size: 11.5px;
  color: var(--color-muted);
  display: flex;
  gap: 6px;
}

.quick-tips strong {
  color: var(--color-ink);
}

/* Detail Inspection Elements */
.kicker {
  font-family: var(--font-display);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--accent-cyan);
}

.detail-title {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 700;
  line-height: 1.15;
  color: var(--color-ink);
  margin: 6px 0 10px;
}

.chips-container {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 12px 0 18px;
}

.badge-chip {
  font-size: 10.5px;
  font-weight: 600;
  padding: 4px 8px;
  border-radius: 99px;
  background: rgba(255,255,255,0.07);
  border: 1px solid rgba(255,255,255,0.09);
  color: #d0dbe5;
}

.light-theme .badge-chip {
  background: rgba(196, 154, 108, 0.08);
  border-color: rgba(196, 154, 108, 0.18);
  color: var(--color-ink);
}

.badge-chip.accent {
  background: rgba(0, 240, 255, 0.1);
  border-color: rgba(0, 240, 255, 0.25);
  color: var(--accent-cyan);
}

.light-theme .badge-chip.accent {
  background: rgba(196, 154, 108, 0.14);
  border-color: rgba(196, 154, 108, 0.35);
  color: var(--accent-cyan);
}

.badge-chip.warn {
  background: rgba(255, 85, 85, 0.1);
  border-color: rgba(255, 85, 85, 0.25);
  color: #ff8888;
}

.light-theme .badge-chip.warn {
  background: rgba(198, 40, 40, 0.08);
  border-color: rgba(198, 40, 40, 0.25);
  color: var(--accent-red);
}

.detail-description {
  font-size: 13.5px;
  line-height: 1.55;
  color: #deebf7;
  margin-bottom: 20px;
}

.light-theme .detail-description {
  color: var(--color-ink);
}

/* Embed Figure Box in Details */
.figure-embed-card {
  background: #03080e;
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: var(--radius-md);
  overflow: hidden;
  margin: 16px 0 20px;
  transition: border-color var(--transition-fast);
}

.light-theme .figure-embed-card {
  background: #ffffff;
  border-color: rgba(196, 154, 108, 0.18);
}

.figure-embed-card:hover {
  border-color: rgba(var(--accent-cyan-rgb), 0.3);
}

.figure-img-container {
  position: relative;
  width: 100%;
  aspect-ratio: 16/10;
  background: #010305;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: zoom-in;
  overflow: hidden;
}

.light-theme .figure-img-container {
  background: #faf4e3;
}

.figure-img-container img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  transition: transform var(--transition-normal);
}

.figure-img-container:hover img {
  transform: scale(1.05);
}

.figure-zoom-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 240, 255, 0.08);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity var(--transition-fast);
}

.figure-img-container:hover .figure-zoom-overlay {
  opacity: 1;
}

.zoom-icon {
  font-size: 24px;
  filter: drop-shadow(0 2px 8px rgba(0,0,0,0.5));
}

.figure-caption {
  padding: 10px 14px;
  font-size: 12px;
  font-weight: 500;
  line-height: 1.4;
  color: var(--color-muted);
  border-top: 1px solid rgba(255,255,255,0.06);
}

.light-theme .figure-caption {
  border-top-color: rgba(196, 154, 108, 0.15);
}

/* Secondary list containers */
.sub-section-header {
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--accent-purple);
  margin: 22px 0 10px;
}

.inspector-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.inspector-list-item {
  padding: 12px;
  border-radius: var(--radius-md);
  background: rgba(255,255,255,0.025);
  border: 1px solid rgba(255,255,255,0.05);
  cursor: pointer;
  transition: var(--transition-fast);
}

.light-theme .inspector-list-item {
  background: rgba(196, 154, 108, 0.04);
  border-color: rgba(196, 154, 108, 0.12);
}

.inspector-list-item:hover {
  background: rgba(189, 147, 249, 0.08);
  border-color: rgba(189, 147, 249, 0.25);
}

.light-theme .inspector-list-item:hover {
  background: rgba(196, 154, 108, 0.08);
  border-color: rgba(196, 154, 108, 0.35);
}

.inspector-list-item.source-item {
  background: rgba(255, 121, 198, 0.02);
  border-color: rgba(255, 121, 198, 0.08);
}

.light-theme .inspector-list-item.source-item {
  background: rgba(216, 27, 96, 0.03);
  border-color: rgba(216, 27, 96, 0.1);
}

.inspector-list-item.source-item:hover {
  background: rgba(255, 121, 198, 0.08);
  border-color: rgba(255, 121, 198, 0.28);
}

.light-theme .inspector-list-item.source-item:hover {
  background: rgba(216, 27, 96, 0.08);
  border-color: rgba(216, 27, 96, 0.3);
}

.inspector-list-item h5 {
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 700;
  color: var(--color-ink);
  margin-bottom: 4px;
}

.inspector-list-item p {
  font-size: 12px;
  line-height: 1.4;
  color: var(--color-muted);
}

.inspector-list-item small {
  display: block;
  font-size: 10px;
  color: var(--color-subtle);
  margin-top: 6px;
}

/* Light Mini Data Table */
.mini-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  margin-top: 8px;
}

.mini-table td {
  padding: 8px 4px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  color: var(--color-muted);
}

.light-theme .mini-table td {
  border-bottom-color: rgba(196,154,108,0.12);
}

.mini-table tr:last-child td {
  border-bottom: none;
}

.mini-table td:first-child {
  color: var(--color-ink);
  font-weight: 700;
}

/* EXPANDED IMAGE MODAL */
.image-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(2, 4, 6, 0.85);
  backdrop-filter: blur(10px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
  transition: opacity var(--transition-normal);
}

.light-theme .image-modal-overlay {
  background: rgba(43, 34, 26, 0.65);
}

.image-modal-overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

.image-modal-content {
  position: relative;
  max-width: 1200px;
  width: 100%;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  animation: zoom-in var(--transition-normal) forwards;
}

@keyframes zoom-in {
  from { transform: scale(0.9); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.image-modal-content img {
  max-width: 100%;
  max-height: 75vh;
  object-fit: contain;
  border-radius: var(--radius-md);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.7), 0 0 50px rgba(0, 240, 255, 0.15);
}

.light-theme .image-modal-content img {
  box-shadow: 0 20px 60px rgba(196, 154, 108, 0.22);
}

.btn-close-modal {
  position: absolute;
  top: -40px;
  right: 0;
  background: transparent;
  border: none;
  color: var(--color-ink);
  font-size: 24px;
  cursor: pointer;
  transition: transform var(--transition-fast);
}

.btn-close-modal:hover {
  transform: rotate(90deg);
  color: var(--accent-cyan);
}

.image-modal-caption {
  margin-top: 16px;
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 600;
  color: var(--color-ink);
  text-align: center;
}

/* INTERACTIVE SPOTLIGHT TUTORIAL */
.tutorial-overlay {
  position: fixed;
  inset: 0;
  z-index: 999;
  pointer-events: none;
}

.tutorial-overlay.hidden {
  display: none !important;
}

.tutorial-spotlight {
  position: absolute;
  border-radius: 16px;
  box-shadow: 0 0 0 9999px rgba(3, 6, 12, 0.76);
  border: 2px solid var(--accent-cyan);
  transition: all 0.32s cubic-bezier(0.4, 0, 0.2, 1);
  pointer-events: auto;
  z-index: 1000;
  display: block;
}

.light-theme .tutorial-spotlight {
  box-shadow: 0 0 0 9999px rgba(43, 34, 26, 0.62);
  border-color: var(--accent-cyan);
}

.tutorial-card {
  position: absolute;
  bottom: 40px;
  left: 50%;
  transform: translateX(-50%);
  width: min(720px, 90%);
  display: flex;
  align-items: stretch;
  gap: 20px;
  padding: 20px;
  z-index: 1001;
  pointer-events: auto;
  border-color: var(--accent-cyan);
  background: var(--card-bg-solid);
  animation: tutorial-slide 0.32s ease-out forwards;
  box-shadow: 0 30px 80px rgba(0,0,0,0.6), 0 0 40px rgba(var(--accent-cyan-rgb), 0.3);
}

.light-theme .tutorial-card {
  background: rgba(253, 250, 242, 0.98);
  border-color: var(--accent-cyan);
  box-shadow: 0 20px 60px rgba(196, 154, 108, 0.25);
}

@keyframes tutorial-slide {
  from { transform: translate(-50%, 60px); opacity: 0; }
  to { transform: translate(-50%, 0); opacity: 1; }
}

/* HTML Nodes positioning in 3D projection overlay styling */
.node-label-anchor {
  position: absolute;
  pointer-events: none;
  transform: translate(-50%, -50%);
  transition: opacity 0.1s ease;
}

.label-box {
  background: var(--card-bg-solid);
  border: 1px solid var(--card-border);
  border-radius: 12px;
  padding: 6px 10px;
  display: inline-flex;
  flex-direction: column;
  gap: 3px;
  max-width: 140px;
  min-width: 50px;
  text-align: center;
  box-shadow: 0 8px 16px rgba(0,0,0,0.25);
  transition: transform var(--transition-fast), border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.light-theme .label-box {
  box-shadow: 0 6px 12px rgba(196, 154, 108, 0.12);
  border-color: rgba(196, 154, 108, 0.25);
  background: #ffffff;
}

.node-label-anchor:hover .label-box {
  transform: scale(1.05);
  border-color: var(--accent-cyan);
  box-shadow: 0 10px 24px rgba(var(--accent-cyan-rgb), 0.28);
}

.node-label-anchor.hovered .label-box {
  transform: scale(1.08);
  border-color: var(--accent-cyan);
  box-shadow: 0 10px 24px rgba(var(--accent-cyan-rgb), 0.35);
}

.node-label-anchor.selected .label-box {
  border-color: var(--accent-gold);
  transform: scale(1.1);
  box-shadow: 0 0 15px rgba(255, 184, 108, 0.35);
}

.label-text {
  font-size: 11px;
  font-weight: 700;
  color: var(--color-ink);
  line-height: 1.25;
}

.label-badge {
  font-size: 9px;
  font-weight: 700;
  padding: 1px 4px;
  border-radius: 4px;
  background: rgba(var(--accent-cyan-rgb), 0.12);
  color: var(--accent-cyan);
  align-self: center;
}

.node-article .label-badge {
  background: rgba(0, 240, 255, 0.12);
  color: var(--accent-cyan);
}

.node-theme .label-badge {
  background: rgba(255, 184, 108, 0.15);
  color: var(--accent-gold);
}

.node-source .label-badge {
  background: rgba(255, 121, 198, 0.12);
  color: var(--accent-pink);
}

/* Mini dots styling */
.node-point .label-box {
  border-radius: 99px;
  padding: 4px 6px;
}

.node-point .label-text {
  font-size: 10px;
}

/* CLOSE & REOPEN BUTTONS STYLING */
.btn-close-sidebar {
  background: transparent;
  border: none;
  color: var(--color-muted);
  cursor: pointer;
  font-size: 16px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--transition-fast), color var(--transition-fast), transform var(--transition-fast);
}
.btn-close-sidebar:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--accent-cyan);
  transform: scale(1.1);
}
.light-theme .btn-close-sidebar:hover {
  background: rgba(196, 154, 108, 0.12);
}
.brand .btn-close-sidebar {
  margin-left: auto;
}

.floating-reopen-btn {
  position: fixed;
  top: 50%;
  transform: translateY(-50%);
  z-index: 998;
  background: var(--card-bg);
  border: 1px solid var(--card-border-glow);
  color: var(--color-ink);
  font-family: var(--font-display);
  font-size: 12px;
  font-weight: 700;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  cursor: pointer;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow: var(--shadow-neon);
  transition: transform var(--transition-normal), opacity var(--transition-normal), background var(--transition-fast), border-color var(--transition-fast), box-shadow var(--transition-fast);
}
.floating-reopen-btn:hover {
  background: rgba(var(--accent-cyan-rgb), 0.15);
  border-color: var(--accent-cyan);
  box-shadow: var(--shadow-neon-hover);
}
.floating-reopen-btn.hidden {
  opacity: 0;
  pointer-events: none;
}
#reopen-left-btn {
  left: 20px;
  animation: float-left-button 3s ease-in-out infinite;
}
#reopen-right-btn {
  right: 20px;
  animation: float-right-button 3s ease-in-out infinite;
}
@keyframes float-left-button {
  0% { transform: translateY(-50%) translateX(0); }
  50% { transform: translateY(-50%) translateX(4px); }
  100% { transform: translateY(-50%) translateX(0); }
}
@keyframes float-right-button {
  0% { transform: translateY(-50%) translateX(0); }
  50% { transform: translateY(-50%) translateX(-4px); }
  100% { transform: translateY(-50%) translateX(0); }
}

.btn-voice-toggle {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  font-size: 14px;
  cursor: pointer;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
  color: var(--color-ink);
}
.btn-voice-toggle:hover {
  background: rgba(189, 147, 249, 0.2);
  border-color: var(--accent-purple);
  transform: scale(1.1);
}
.light-theme .btn-voice-toggle:hover {
  background: rgba(196, 154, 108, 0.15);
  border-color: var(--accent-cyan);
}
.btn-voice-toggle.muted {
  filter: grayscale(1) opacity(0.6);
}

.mobile-sidebar-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(2, 4, 6, 0.6);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 990;
  transition: opacity var(--transition-normal);
}
.mobile-sidebar-backdrop.hidden {
  opacity: 0;
  pointer-events: none;
}

/* BONSAI TEXT FRAMING STYLES */
.bonsai-frame {
  background: rgba(13, 27, 43, 0.4);
  border: 1px solid rgba(112, 214, 255, 0.12);
  border-left: 4px solid var(--accent-cyan);
  border-radius: var(--radius-md);
  padding: 16px;
  margin-bottom: 20px;
  box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.2);
  transition: border-color var(--transition-normal), background var(--transition-normal);
}
.light-theme .bonsai-frame {
  background: rgba(253, 250, 242, 0.5);
  border-color: rgba(196, 154, 108, 0.18);
  border-left-color: var(--accent-cyan);
  box-shadow: inset 0 2px 6px rgba(196, 154, 108, 0.08);
}
.bonsai-frame:hover {
  border-color: rgba(var(--accent-cyan-rgb), 0.3);
  border-left-color: var(--accent-cyan);
}

.bonsai-quote-card {
  font-size: 13.5px;
  line-height: 1.6;
  color: var(--color-ink);
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  background: rgba(0, 240, 255, 0.03);
  border: 1px solid rgba(0, 240, 255, 0.08);
  border-left: 3px solid var(--accent-cyan);
  margin-bottom: 16px;
}
.light-theme .bonsai-quote-card {
  background: rgba(196, 148, 60, 0.04);
  border-color: rgba(196, 148, 60, 0.12);
  border-left-color: var(--accent-cyan);
}

.bonsai-accordion {
  border: 1px solid rgba(255, 255, 255, 0.06);
  background: rgba(255, 255, 255, 0.015);
  border-radius: var(--radius-md);
  margin-bottom: 12px;
  overflow: hidden;
  transition: border-color var(--transition-fast), background var(--transition-fast);
}
.light-theme .bonsai-accordion {
  border-color: rgba(196, 154, 108, 0.15);
  background: rgba(196, 154, 108, 0.02);
}
.bonsai-accordion:hover {
  border-color: rgba(189, 147, 249, 0.25);
  background: rgba(255, 255, 255, 0.03);
}
.light-theme .bonsai-accordion:hover {
  border-color: rgba(196, 154, 108, 0.35);
  background: rgba(196, 154, 108, 0.06);
}
.bonsai-accordion summary {
  padding: 14px 16px;
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 700;
  color: var(--color-ink);
  cursor: pointer;
  outline: none;
  user-select: none;
  list-style: none;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.bonsai-accordion summary::-webkit-details-marker {
  display: none;
}
.bonsai-accordion summary::after {
  content: "▼";
  font-size: 9px;
  color: var(--color-muted);
  transition: transform var(--transition-normal);
}
.bonsai-accordion[open] summary::after {
  transform: rotate(180deg);
}
.bonsai-accordion .accordion-content {
  padding: 0 16px 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.04);
  background: rgba(0, 0, 0, 0.1);
}
.light-theme .bonsai-accordion .accordion-content {
  border-top-color: rgba(196, 154, 108, 0.08);
  background: rgba(255, 255, 255, 0.4);
}

/* RESPONSIVE LAYOUTS */
@media (max-width: 1024px) {
  .app-container {
    grid-template-columns: 1fr;
    padding: 12px;
  }

  .sidebar-left {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    width: 320px;
    z-index: 995;
    border-radius: 0 var(--radius-lg) var(--radius-lg) 0;
    margin-right: 0;
    transform: translateX(0);
    box-shadow: 0 0 50px rgba(0, 0, 0, 0.8);
  }
  .sidebar-left.collapsed {
    transform: translateX(-100%) !important;
    width: 320px !important;
    margin-right: 0 !important;
    padding: 20px !important;
    opacity: 1 !important;
    border: 1px solid var(--card-border) !important;
  }

  .sidebar-right {
    position: fixed;
    top: 0;
    bottom: 0;
    right: 0;
    width: 380px;
    z-index: 995;
    border-radius: var(--radius-lg) 0 0 var(--radius-lg);
    margin-left: 0;
    transform: translateX(0);
    box-shadow: 0 0 50px rgba(0, 0, 0, 0.8);
  }
  .sidebar-right.collapsed {
    transform: translateX(100%) !important;
    width: 380px !important;
    margin-left: 0 !important;
    padding: 0 !important;
    opacity: 1 !important;
    border: 1px solid var(--card-border) !important;
  }

  #reopen-left-btn {
    left: 12px;
  }
  #reopen-right-btn {
    right: 12px;
  }
  .top-pillbar {
    top: 12px;
    left: 12px;
    right: 12px;
  }
}

@media (max-width: 576px) {
  .sidebar-left, .sidebar-right {
    width: 100%;
    max-width: 100%;
    border-radius: 0;
  }
  .sidebar-left.collapsed {
    transform: translateX(-100%) !important;
    width: 100% !important;
  }
  .sidebar-right.collapsed {
    transform: translateX(100%) !important;
    width: 100% !important;
  }
  .pill-badge {
    padding: 6px 10px;
  }
  .pill-badge span:last-child {
    font-size: 11px;
  }
  .btn-action {
    padding: 6px 12px;
    font-size: 11px;
  }
  .top-pillbar {
    flex-direction: column;
    gap: 8px;
    align-items: stretch;
  }
  .pill-badge {
    align-self: center;
  }
  .pill-actions {
    justify-content: center;
  }
  .story-dialog-box, .tutorial-card {
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 12px;
    padding: 16px;
    bottom: 12px;
  }
  .mascot-widget {
    width: auto;
  }
  .mascot-avatar {
    width: 80px;
    height: 80px;
  }
  .speech-balloon {
    align-items: center;
  }
  .tour-actions {
    width: 100%;
    justify-content: space-between;
  }
}

/* ==========================================================================
   ZEN FOCUS EXPLORATION MODE
   ========================================================================== */
.app-container.zen-focus-mode .sidebar-left {
  width: 0 !important;
  margin-right: 0 !important;
  padding: 0 !important;
  opacity: 0 !important;
  border: none !important;
  pointer-events: none;
  transform: translateX(-105%) !important;
  transition: all 0.6s cubic-bezier(0.16, 1, 0.3, 1) !important;
}

.app-container.zen-focus-mode .sidebar-right {
  opacity: 0.16;
  filter: blur(0.4px);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  transition: opacity 0.5s ease, backdrop-filter 0.5s ease, filter 0.5s ease;
  pointer-events: auto;
}

.app-container.zen-focus-mode .sidebar-right:hover {
  opacity: 0.96;
  filter: none;
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}

.zen-focus-pill {
  position: absolute;
  top: 72px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 18px;
  background: rgba(11, 21, 34, 0.88);
  border: 1px solid rgba(0, 240, 255, 0.4);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5), 0 0 20px rgba(0, 240, 255, 0.25);
  border-radius: 999px;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  z-index: 100;
  color: #ffffff;
  font-size: 12.5px;
  font-weight: 500;
  animation: zen-pill-appear 0.45s cubic-bezier(0.16, 1, 0.3, 1);
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.light-theme .zen-focus-pill {
  background: rgba(254, 250, 242, 0.92);
  border-color: rgba(196, 154, 108, 0.5);
  box-shadow: 0 8px 25px rgba(196, 154, 108, 0.25);
  color: #2b2015;
}

.reading-theme .zen-focus-pill {
  background: rgba(254, 252, 248, 0.95);
  border-color: rgba(180, 142, 95, 0.5);
  box-shadow: 0 8px 25px rgba(180, 142, 95, 0.2);
  color: #292524;
}

.zen-focus-pill.hidden {
  opacity: 0;
  pointer-events: none;
  transform: translateX(-50%) translateY(-12px);
}

@keyframes zen-pill-appear {
  from { opacity: 0; transform: translateX(-50%) translateY(-15px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

.zen-sparkle {
  font-size: 14px;
  animation: sparkle-spin 3s ease-in-out infinite;
}

@keyframes sparkle-spin {
  0%, 100% { transform: scale(1) rotate(0deg); }
  50% { transform: scale(1.25) rotate(15deg); }
}

.zen-text {
  font-weight: 600;
  letter-spacing: 0.2px;
}

.zen-hint {
  font-size: 11px;
  color: var(--color-muted);
  opacity: 0.85;
}

.zen-exit-btn {
  background: rgba(255, 255, 255, 0.12);
  border: none;
  color: var(--color-ink);
  width: 20px;
  height: 20px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  transition: all var(--transition-fast);
}

.zen-exit-btn:hover {
  background: rgba(255, 85, 85, 0.75);
  color: #ffffff;
  transform: scale(1.1);
}

/* ==========================================================================
   IN-DOC REPORT VIEWER MODAL
   ========================================================================== */
.indoc-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(2, 6, 11, 0.78);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 1;
  transition: opacity 0.3s ease;
}

.light-theme .indoc-modal-overlay {
  background: rgba(250, 244, 227, 0.82);
}

.reading-theme .indoc-modal-overlay {
  background: rgba(244, 237, 228, 0.85);
}

.indoc-modal-overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

.indoc-modal-container {
  width: 92vw;
  max-width: 1400px;
  height: 88vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
  transition: width 0.3s ease, height 0.3s ease, border-radius 0.3s ease;
}

.indoc-modal-container.fullscreen {
  width: 100vw !important;
  max-width: 100vw !important;
  height: 100vh !important;
  border-radius: 0 !important;
}

.indoc-modal-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--card-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  background: rgba(255, 255, 255, 0.02);
}

.indoc-modal-title-group {
  display: flex;
  align-items: center;
  gap: 12px;
}

.indoc-icon {
  font-size: 24px;
}

.indoc-modal-title-group h3 {
  font-family: var(--font-display);
  font-size: 17px;
  font-weight: 700;
  color: var(--color-ink);
}

.indoc-subtitle {
  font-size: 11.5px;
  color: var(--color-muted);
}

.indoc-modal-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-doc-ext {
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--color-ink);
}

.indoc-quick-jump-bar {
  padding: 10px 20px;
  background: rgba(0, 0, 0, 0.2);
  border-bottom: 1px solid var(--card-border);
  display: flex;
  align-items: center;
  gap: 8px;
  overflow-x: auto;
  scrollbar-width: none;
}

.light-theme .indoc-quick-jump-bar {
  background: rgba(196, 154, 108, 0.08);
}

.reading-theme .indoc-quick-jump-bar {
  background: rgba(180, 142, 95, 0.08);
}

.jump-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--color-muted);
  white-space: nowrap;
}

.jump-chip {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--color-ink);
  padding: 5px 13px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: all var(--transition-fast);
}

.jump-chip:hover {
  background: var(--accent-cyan);
  color: #000000;
  border-color: var(--accent-cyan);
  transform: translateY(-1px);
}

.light-theme .jump-chip, .reading-theme .jump-chip {
  background: rgba(0, 0, 0, 0.05);
  border-color: rgba(0, 0, 0, 0.1);
}

.light-theme .jump-chip:hover, .reading-theme .jump-chip:hover {
  background: var(--accent-cyan);
  color: #ffffff;
}

.indoc-iframe-wrapper {
  flex: 1;
  position: relative;
  background: #111827;
  overflow: hidden;
}

.indoc-loading-spinner {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  color: var(--color-muted);
  font-size: 13px;
  z-index: 1;
  background: var(--card-bg-solid);
  transition: opacity 0.4s ease;
}

.indoc-loading-spinner.hidden {
  opacity: 0;
  pointer-events: none;
}

.indoc-iframe-wrapper iframe {
  width: 100%;
  height: 100%;
  border: none;
  position: relative;
  z-index: 2;
}

.btn-doc-highlight {
  background: linear-gradient(135deg, rgba(0, 240, 255, 0.2), rgba(189, 147, 249, 0.25));
  border: 1px solid rgba(0, 240, 255, 0.45);
  color: #ffffff;
  font-weight: 600;
  box-shadow: 0 0 15px rgba(0, 240, 255, 0.2);
}

.btn-doc-highlight:hover {
  background: linear-gradient(135deg, rgba(0, 240, 255, 0.35), rgba(189, 147, 249, 0.4));
  border-color: #00f0ff;
  box-shadow: 0 0 25px rgba(0, 240, 255, 0.4);
  transform: translateY(-1px);
}

.light-theme .btn-doc-highlight {
  background: linear-gradient(135deg, rgba(196, 148, 60, 0.15), rgba(122, 62, 187, 0.15));
  border-color: rgba(196, 148, 60, 0.5);
  color: #2b2015;
  box-shadow: 0 4px 15px rgba(196, 148, 60, 0.2);
}

.reading-theme .btn-doc-highlight {
  background: linear-gradient(135deg, rgba(180, 83, 9, 0.15), rgba(217, 119, 6, 0.15));
  border-color: rgba(180, 83, 9, 0.4);
  color: #292524;
  box-shadow: 0 4px 15px rgba(180, 83, 9, 0.15);
}

/* Reading Theme Specific Details */
.reading-theme .bonsai-quote-card {
  font-family: 'Merriweather', 'Charter', 'Georgia', serif;
  font-size: 14.5px;
  line-height: 1.7;
  color: #292524;
  background: rgba(180, 83, 9, 0.04);
  border-color: rgba(180, 83, 9, 0.15);
  border-left-color: var(--accent-cyan);
}

.reading-theme .detail-description {
  font-family: 'Merriweather', 'Charter', 'Georgia', serif;
  font-size: 14px;
  line-height: 1.65;
  color: #44403c;
}

.reading-theme .glass-card {
  background: rgba(254, 252, 248, 0.95);
  border-color: rgba(180, 142, 95, 0.25);
  box-shadow: 0 12px 35px rgba(180, 142, 95, 0.1), var(--shadow-neon);
}

/* COMPLETE READING THEME CLEAN OVERRIDES (ZERO DARK SPACES) */
.reading-theme .stat-card {
  background: rgba(180, 142, 95, 0.08);
  border: 1px solid rgba(180, 142, 95, 0.16);
}
.reading-theme .stat-val {
  color: #b45309;
}
.reading-theme .tour-banner {
  background: linear-gradient(135deg, rgba(217, 119, 6, 0.14) 0%, rgba(180, 83, 9, 0.06) 100%);
  border-color: rgba(180, 83, 9, 0.28);
}
.reading-theme .tour-banner:hover {
  border-color: rgba(180, 83, 9, 0.5);
  box-shadow: 0 8px 30px rgba(180, 83, 9, 0.15);
}
.reading-theme .banner-glow {
  background: radial-gradient(circle, rgba(217, 119, 6, 0.3) 0%, transparent 70%);
}
.reading-theme .btn {
  background: rgba(180, 142, 95, 0.09);
  border-color: rgba(180, 142, 95, 0.2);
  color: #292524;
}
.reading-theme .btn:hover {
  background: rgba(180, 142, 95, 0.18);
  border-color: rgba(180, 142, 95, 0.35);
}
.reading-theme .btn-primary {
  background: linear-gradient(135deg, #b45309, #d97706);
  color: #ffffff;
}
.reading-theme .btn-glow {
  box-shadow: 0 0 20px rgba(180, 83, 9, 0.25);
}
.reading-theme .search-box input {
  background: rgba(255, 255, 255, 0.9);
  border-color: rgba(180, 142, 95, 0.28);
  color: #292524;
}
.reading-theme .toggle-btn {
  background: rgba(180, 142, 95, 0.08);
  border-color: rgba(180, 142, 95, 0.16);
  color: #57534e;
}
.reading-theme .toggle-btn:hover {
  background: rgba(180, 142, 95, 0.14);
}
.reading-theme .toggle-btn.active {
  background: #b45309;
  color: #ffffff;
  border-color: #b45309;
}
.reading-theme .custom-select {
  background: rgba(255, 255, 255, 0.9);
  border-color: rgba(180, 142, 95, 0.28);
  color: #292524;
}
.reading-theme .custom-slider {
  background: rgba(180, 142, 95, 0.25);
}
.reading-theme .search-hit-item {
  background: rgba(255, 255, 255, 0.7);
  border-color: rgba(180, 142, 95, 0.18);
  color: #292524;
}
.reading-theme .search-hit-item:hover {
  background: rgba(180, 83, 9, 0.08);
  border-color: rgba(180, 83, 9, 0.3);
}
.reading-theme .sidebar-footer {
  color: var(--color-muted);
}
.reading-theme .pill-badge {
  background: rgba(254, 252, 248, 0.94);
  border-color: rgba(180, 142, 95, 0.3);
  color: #292524;
}
.reading-theme .btn-action {
  background: rgba(254, 252, 248, 0.94);
  border-color: rgba(180, 142, 95, 0.25);
  color: #292524;
}
.reading-theme .anime-speedlines {
  display: none;
}
.reading-theme .story-dialog-box {
  background: rgba(254, 252, 248, 0.97);
  border-color: rgba(180, 142, 95, 0.35);
  box-shadow: 0 20px 60px rgba(180, 142, 95, 0.18);
}
.reading-theme .mascot-nametag {
  background: #b45309;
  color: #ffffff;
}
.reading-theme .tour-step-text {
  color: #292524;
}
.reading-theme .tour-actions {
  border-top-color: rgba(180, 142, 95, 0.15);
}
.reading-theme .btn-tour-primary {
  background: #b45309;
  color: #ffffff;
}
.reading-theme .btn-tour-primary:hover {
  background: #9a3412;
}
.reading-theme .panel-header {
  border-bottom-color: rgba(180, 142, 95, 0.18);
}
.reading-theme .quick-tips {
  background: rgba(180, 142, 95, 0.08);
  border-color: rgba(180, 142, 95, 0.18);
}
.reading-theme .badge-chip {
  background: rgba(180, 142, 95, 0.1);
  border-color: rgba(180, 142, 95, 0.22);
  color: #57534e;
}
.reading-theme .badge-chip.accent {
  background: rgba(180, 83, 9, 0.12);
  border-color: rgba(180, 83, 9, 0.3);
  color: #b45309;
}
.reading-theme .figure-embed-card {
  background: rgba(255, 255, 255, 0.65);
  border-color: rgba(180, 142, 95, 0.2);
}
.reading-theme .figure-caption {
  color: var(--color-muted);
}
.reading-theme .inspector-list-item {
  background: rgba(255, 255, 255, 0.6);
  border-color: rgba(180, 142, 95, 0.18);
  color: #292524;
}
.reading-theme .inspector-list-item:hover {
  background: rgba(180, 83, 9, 0.08);
  border-color: rgba(180, 83, 9, 0.3);
}
.reading-theme .bonsai-frame {
  background: rgba(255, 255, 255, 0.6);
  border-color: rgba(180, 142, 95, 0.22);
  border-left-color: #b45309;
  box-shadow: inset 0 2px 6px rgba(180, 142, 95, 0.06);
}
.reading-theme .bonsai-accordion {
  border-color: rgba(180, 142, 95, 0.18);
  background: rgba(180, 142, 95, 0.03);
}
.reading-theme .bonsai-accordion:hover {
  border-color: rgba(180, 83, 9, 0.35);
  background: rgba(180, 142, 95, 0.06);
}
.reading-theme .bonsai-accordion .accordion-content {
  border-top-color: rgba(180, 142, 95, 0.12);
  background: rgba(255, 255, 255, 0.6);
}
.reading-theme .label-box {
  background: rgba(254, 252, 248, 0.95);
  border-color: rgba(180, 142, 95, 0.4);
  color: #292524;
  box-shadow: 0 4px 16px rgba(180, 142, 95, 0.2);
}
.reading-theme .tutorial-spotlight {
  background: radial-gradient(circle at var(--spot-x, 50%) var(--spot-y, 50%), transparent 0px, transparent var(--spot-r, 120px), rgba(244, 237, 228, 0.85) calc(var(--spot-r, 120px) + 80px));
}
.reading-theme .tutorial-card {
  background: rgba(254, 252, 248, 0.97);
  border-color: rgba(180, 142, 95, 0.35);
  box-shadow: 0 20px 60px rgba(180, 142, 95, 0.2);
}
.reading-theme .image-modal-overlay {
  background: rgba(244, 237, 228, 0.85);
}

/* ==========================================================================
   COSMIC ANOMALIES (Black Holes, Solar Flares, Cosmic Earthquakes)
   ========================================================================== */
.cosmic-quake-active {
  animation: cosmic-quake 0.85s cubic-bezier(0.36, 0.07, 0.19, 0.97) both;
}

@keyframes cosmic-quake {
  0%, 100% { transform: translate(0, 0) scale(1); filter: none; }
  15% { transform: translate(-8px, 6px) scale(1.015); filter: hue-rotate(45deg) saturate(1.4); }
  30% { transform: translate(7px, -6px) scale(0.99); filter: hue-rotate(-30deg) saturate(1.3); }
  45% { transform: translate(-5px, 4px) scale(1.01); filter: hue-rotate(20deg); }
  60% { transform: translate(4px, -3px) scale(0.995); }
  75% { transform: translate(-2px, 2px) scale(1.005); }
}

.solar-flare-overlay {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 85;
  background: radial-gradient(circle at 50% 50%, rgba(255, 184, 108, 0.7) 0%, rgba(255, 85, 85, 0.4) 45%, transparent 75%);
  opacity: 0;
  transition: opacity 0.4s ease;
}

.solar-flare-overlay.active {
  animation: solar-flare-burst 2.4s ease-out forwards;
}

@keyframes solar-flare-burst {
  0% { opacity: 0; transform: scale(0.8); }
  25% { opacity: 0.85; transform: scale(1.15); filter: brightness(1.6); }
  100% { opacity: 0; transform: scale(1.4); filter: brightness(1); }
}

.black-hole-overlay {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 85;
  background: radial-gradient(circle at 50% 50%, #000000 0%, rgba(10, 5, 20, 0.85) 25%, rgba(189, 147, 249, 0.3) 50%, transparent 75%);
  opacity: 0;
}

.black-hole-overlay.active {
  animation: black-hole-vortex 4s ease-in-out forwards;
}

@keyframes black-hole-vortex {
  0% { opacity: 0; transform: scale(0.6) rotate(0deg); }
  35% { opacity: 0.9; transform: scale(1.1) rotate(180deg); }
  75% { opacity: 0.85; transform: scale(1.0) rotate(360deg); }
  100% { opacity: 0; transform: scale(0.4) rotate(540deg); }
}

/* ==========================================================================
   AMI 3-LEVEL STORY & AUTOPILOT TOUR MODAL
   ========================================================================== */
.tour-level-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(2, 6, 11, 0.75);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  z-index: 1010;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  transition: opacity 0.3s ease;
}

.light-theme .tour-level-modal-overlay {
  background: rgba(250, 244, 227, 0.8);
}
.reading-theme .tour-level-modal-overlay {
  background: rgba(244, 237, 228, 0.85);
}

.tour-level-modal-overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

.tour-level-card {
  width: 90vw;
  max-width: 580px;
  padding: 28px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

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

.tour-level-header h3 {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 700;
  color: var(--color-ink);
}

.tour-level-options {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.level-option-btn {
  padding: 16px 18px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-md);
  text-align: left;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 16px;
  transition: all var(--transition-fast);
}

.level-option-btn:hover {
  background: rgba(0, 240, 255, 0.08);
  border-color: var(--accent-cyan);
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(0, 240, 255, 0.2);
}

.light-theme .level-option-btn, .reading-theme .level-option-btn {
  background: rgba(0, 0, 0, 0.03);
  border-color: rgba(0, 0, 0, 0.08);
}

.light-theme .level-option-btn:hover, .reading-theme .level-option-btn:hover {
  background: rgba(180, 83, 9, 0.08);
  border-color: var(--accent-cyan);
}

.level-icon {
  font-size: 28px;
}

.level-info h4 {
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 700;
  color: var(--color-ink);
  margin-bottom: 3px;
}

.level-info p {
  font-size: 12px;
  color: var(--color-muted);
  line-height: 1.35;
}

.level-badge-tag {
  margin-left: auto;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  background: rgba(0, 240, 255, 0.15);
  color: var(--accent-cyan);
  border: 1px solid rgba(0, 240, 255, 0.3);
}

/* Autopilot Mode Live Badge in Topbar */
.autopilot-pill {
  animation: pulse-autopilot 2s infinite;
}

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

/* ==========================================================================
   SIMPLE CLEAN IN-DOC GOOGLE DRIVE DOCUMENT VIEWER MODAL
   ========================================================================== */
.indoc-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(2, 6, 11, 0.85);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  z-index: 1020;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  transition: opacity 0.3s ease;
}

.light-theme .indoc-modal-overlay {
  background: rgba(250, 244, 227, 0.85);
}
.reading-theme .indoc-modal-overlay {
  background: rgba(244, 237, 228, 0.9);
}

.indoc-modal-overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

.indoc-modal-container {
  width: 94vw;
  max-width: 1360px;
  height: 88vh;
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--card-border);
  box-shadow: 0 25px 70px rgba(0, 0, 0, 0.6), var(--shadow-neon);
  transition: all 0.3s ease;
}

.indoc-modal-container.fullscreen {
  width: 100vw;
  max-width: 100vw;
  height: 100vh;
  max-height: 100vh;
  border-radius: 0;
}

.indoc-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  border-bottom: 1px solid var(--card-border);
  background: rgba(255, 255, 255, 0.02);
  flex-shrink: 0;
}

.indoc-modal-title-group {
  display: flex;
  align-items: center;
  gap: 12px;
}

.indoc-icon {
  font-size: 24px;
}

.indoc-modal-title-group h3 {
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 700;
  color: var(--color-ink);
  margin: 0;
}

.indoc-subtitle {
  font-size: 11px;
  color: var(--color-muted);
}

.indoc-modal-controls {
  display: flex;
  align-items: center;
  gap: 10px;
}

.btn-doc-ext {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  text-decoration: none;
  font-size: 12px;
}

/* Full-Width Document Viewer Frame */
.indoc-iframe-wrapper {
  position: relative;
  width: 100%;
  height: 100%;
  flex: 1 1 auto;
  min-height: 0;
  background: #111622;
}

.indoc-iframe-wrapper iframe {
  width: 100%;
  height: 100%;
  border: none;
  display: block;
}

.indoc-loading-spinner {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  background: rgba(2, 6, 11, 0.9);
  z-index: 5;
  color: var(--color-muted);
  font-size: 13px;
}

.indoc-loading-spinner.hidden {
  display: none;
}

.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid rgba(0, 240, 255, 0.2);
  border-top-color: var(--accent-cyan);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

