/* ==============================
   🎨 ОСНОВНЫЕ ПЕРЕМЕННЫЕ ЦВЕТОВ И РАЗМЕРОВ
   ============================== */

:root {
  /* === ОСНОВНЫЕ ЦВЕТА ФОНА === */
  --bg: #0f0f14;
  --panel: linear-gradient(90deg, #1a1a24, #1a1a24);
  --overlay-bg: rgba(15, 15, 20, 0.85);
  
  /* === АКЦЕНТНЫЕ ЦВЕТА === */
  --accent: #3a86ff;
  --accent-light: #5d9cff;
  --accent-dark: #2a75f0;
  --accent-glow: rgba(58, 134, 255, 0.4);
  
  /* === ЦВЕТА ТЕКСТА === */
  --text: #e8eef5;
  --text-weak: rgba(232, 238, 245, 0.7);
  --muted: #8b95a8;
  
  /* === ЦВЕТА УЗЛОВ === */
  --node-bg: var(--panel);
  --sub-bg: linear-gradient(90deg, #1a1a24, #181829);
  --sub-bg-opacity: rgba(96, 165, 250, 0.25);
  --sub-bg-hover: linear-gradient(135deg, #0d5fa3 0%, var(--accent));
  
  /* === ЦВЕТА КНОПОК === */
  --restart-bg: #b43030;
  --restart-bg-gradient: linear-gradient(135deg, #d64e4e, #f78433);
  
  /* === ЭФФЕКТЫ И ТЕНИ === */
  --shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
  --shadow-glow: 0 0 20px rgba(58, 134, 255, 0.3);
  --shadow-light: 0 4px 20px rgba(13, 95, 163, 0.3);
  --shadow-hover: 0 10px 25px rgba(58, 134, 255, 0.4);
  
  /* === РАЗДЕЛИТЕЛИ И ГРАНИЦЫ === */
  --outline: rgba(58, 134, 255, 0.15);
  --outline-strong: rgba(58, 134, 255, 0.3);
  --ring: rgba(58, 134, 255, 0.6);
  --border-light: rgba(255, 255, 255, 0.1);
  --border-medium: rgba(255, 255, 255, 0.15);
  
  /* === ЦВЕТА ЛИНИЙ И СВЯЗЕЙ === */
  --line-color: rgba(58, 134, 255, 0.4);
  --line-selected-color: var(--accent);
  --line-pulse-start: 0.4;
  --line-pulse-end: 0.8;
  
  /* === ЦВЕТА ФОНОВЫХ ГРАДИЕНТОВ === */
  --bg-gradient-1: radial-gradient(circle at center, #1a1a1a 0%, #0f0f0f 20%);
  --bg-glow-1: rgba(58, 134, 255, 0.08);
  --bg-glow-2: rgba(239, 68, 68, 0.05);
  --bg-glow-3: rgba(58, 134, 255, 0.05);
  
  /* === ЦВЕТА КАРТОЧЕК === */
  --card-gradient: linear-gradient(135deg, #0d5fa3 20%, var(--accent));
  --card-active-gradient: linear-gradient(135deg, #0d5fa3 0%, var(--accent));
  --card-shadow: 0 4px 20px rgba(13, 95, 163, 0.3);
  --card-shadow-hover: 0 10px 25px rgba(58, 134, 255, 0.4);
  --card-glow: 0 0 30px rgba(37, 99, 235, 0.5);
  
  /* === ЦВЕТА ИНТЕРФЕЙСА === */
  --topbar-gradient: linear-gradient(90deg, rgba(26, 26, 36, 0.95), rgba(15, 15, 20, 0.95));
  --sidebar-bg: linear-gradient(90deg, rgba(26, 26, 36, 0.95), rgba(15, 15, 20, 0.95));
  --sidebar-bg-hover: linear-gradient(90deg, rgba(26, 26, 36, 0.95), rgba(15, 15, 20, 0.85));
  --input-bg: transparent;
  
  /* === ЦВЕТА СООБЩЕНИЙ === */
  --msg-assistant-bg: var(--panel);
  --msg-user-bg: var(--accent);
  --msg-code-bg: rgba(255, 255, 255, 0.05);
  
  /* === ЦВЕТА УВЕДОМЛЕНИЙ === */
  --toast-bg: linear-gradient(90deg, rgba(26, 26, 36, 0.95), rgba(15, 15, 20, 0.95));
  --error-bg: #ff6b6b;
  
  /* === ЦВЕТА КНОПОК ИНТЕРФЕЙСА === */
  --info-btn-bg: var(--accent);
  --close-btn-bg: var(--sub-bg);
  --agreement-btn-bg: var(--sub-bg);
  --cookie-btn-bg: var(--accent);
  --cookie-decline-border: var(--text);
  
  /* === РАЗМЕРЫ УЗЛОВ И ПЛОСКОСТИ === */
  --node-w: 160px;
  --node-h: 80px;
  --sub-w: 120px;
  --plane-w: 4000px;
  --plane-h: 4000px;
  
  /* === РАЗМЕРЫ ИНТЕРФЕЙСА === */
  --topbar-height: 64px;
  --sidebar-width: 340px;
  --input-max-width: 500px;
  --blob-button-size: 48px;
  
  /* === АНИМАЦИЯ И ПЕРЕХОДЫ === */
  --ease: cubic-bezier(0.2, 0, 0, 1);
  --dur: 200ms;
  --dur-slow: 320ms;
  
  /* === РАДИУСЫ СКРУГЛЕНИЯ === */
  --radius-small: 8px;
  --radius-medium: 12px;
  --radius-large: 16px;
  --radius-xl: 20px;
  --radius-2xl: 24px;
  --radius-full: 50px;
  
  /* === ТИПОГРАФИЯ === */
  --font-size-xs: 10px;
  --font-size-sm: 12px;
  --font-size-base: 14px;
  --font-size-lg: 16px;
  --font-size-xl: 18px;
  --font-size-2xl: 32px;
  
  /* === ОТСТУПЫ === */
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 12px;
  --space-lg: 16px;
  --space-xl: 20px;
  --space-2xl: 24px;
}

/* ==============================
   🌟 СВЕТЛАЯ ТЕМА
   ============================== */

[data-theme="light"] {
  --bg: #f5f7fb;
  --panel: #ffffff;
  --overlay-bg: rgba(255, 255, 255, 0.7);
  
  --accent: #1d4ed8;
  --accent-light: #3b82f6;
  --accent-dark: #1e40af;
  --accent-glow: rgba(29, 78, 216, 0.3);
  
  --text: #111827;
  --text-weak: #475569;
  --muted: #6b7280;
  
  --node-bg: #fbbf24;
  --sub-bg: #93c5fd;
  --sub-bg-opacity: rgba(147, 197, 253, 0.25);
  --sub-bg-hover: rgba(147, 197, 253, 0.4);
  
  --restart-bg: #dc2626;
  --restart-bg-gradient: linear-gradient(135deg, #dc2626, #ea580c);
  
  --shadow: 0 8px 20px rgba(15, 23, 42, 0.06);
  --shadow-glow: 0 0 15px rgba(29, 78, 216, 0.2);
  --shadow-light: 0 4px 20px rgba(13, 95, 163, 0.1);
  --shadow-hover: 0 10px 25px rgba(29, 78, 216, 0.3);
  
  --outline: rgba(17, 24, 39, 0.12);
  --outline-strong: rgba(17, 24, 39, 0.25);
  --ring: rgba(29, 78, 216, 0.5);
  --border-light: rgba(17, 24, 39, 0.1);
  --border-medium: rgba(17, 24, 39, 0.15);
  
  --line-color: rgba(29, 78, 216, 0.4);
  
  --bg-gradient-1: radial-gradient(circle at center, #f5f5f5 0%, #e5e5e5 80%);
  --bg-glow-1: rgba(29, 78, 216, 0.08);
  --bg-glow-2: rgba(220, 38, 38, 0.05);
  --bg-glow-3: rgba(29, 78, 216, 0.05);
  
  --card-gradient: linear-gradient(135deg, #fbbf24 0%, #f59e0b 100%);
  --card-active-gradient: linear-gradient(135deg, #1d4ed8, #1e40af);
  --card-shadow: 0 4px 20px rgba(251, 191, 36, 0.3);
  --card-shadow-hover: 0 10px 25px rgba(29, 78, 216, 0.3);
  --card-glow: 0 0 30px rgba(29, 78, 216, 0.4);
  
  --topbar-gradient: linear-gradient(90deg, rgba(255, 255, 255, 0.95), rgba(245, 247, 251, 0.95));
  --sidebar-bg: rgba(255, 255, 255, 0.7);
  --sidebar-bg-hover: rgba(255, 255, 255, 0.8);
  
  --msg-assistant-bg: var(--panel);
  --msg-user-bg: var(--accent);
  --msg-code-bg: rgba(0, 0, 0, 0.05);
  
  --toast-bg: rgba(255, 255, 255, 0.95);
  --error-bg: #ef4444;
  
  --info-btn-bg: var(--accent);
  --close-btn-bg: var(--sub-bg);
  --agreement-btn-bg: var(--sub-bg);
  --cookie-btn-bg: var(--accent);
  --cookie-decline-border: var(--text);
}

/* ==============================
   🔧 БАЗОВЫЕ СТИЛИ И СБРОС
   ============================== */

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
}

html, body, #app {
  height: 100%;
  font-family: Inter, Arial, Helvetica, sans-serif;
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
  position: relative;
}

/* ==============================
   📱 НАСТРОЙКА VIEWPORT
   ============================== */

@viewport {
  width: device-width;
  zoom: 1.0;
  user-zoom: fixed;
}

/* ==============================
   🚫 СКРЫТИЕ СКРОЛЛБАРОВ
   ============================== */

html::-webkit-scrollbar,
body::-webkit-scrollbar,
#app::-webkit-scrollbar,
.sidebar-content::-webkit-scrollbar,
#chatArea::-webkit-scrollbar,
#viewport::-webkit-scrollbar,
.viewport::-webkit-scrollbar,
.agreement-content::-webkit-scrollbar {
  display: none;
}

html, body, #app, .sidebar-content, #chatArea, #viewport, .viewport, .agreement-content {
  -ms-overflow-style: none;
  scrollbar-width: none;
}

/* ==============================
   🎯 ВЕРХНЯЯ ПАНЕЛЬ (TOPBAR)
   ============================== */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-md) var(--space-lg);
  background: var(--topbar-gradient);
  border-bottom: 1px solid var(--outline);
  box-shadow: var(--shadow);
  position: sticky;
  top: 0;
  z-index: 100;
  flex-shrink: 0;
  height: var(--topbar-height);
}

/* ==============================
   ✨ АНИМИРОВАННЫЙ ЗАГОЛОВОК
   ============================== */

.title {
  font-weight: 600;
  font-size: var(--font-size-xl);
  font-family: Inter, Arial, Helvetica, sans-serif;
  background: linear-gradient(90deg, var(--accent), var(--accent-light));
  background-size: 200% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  animation: textGradientFlow 3.5s linear infinite;
}

@keyframes textGradientFlow {
  0% { background-position: 100% 50%; }
  100% { background-position: -100% 50%; }
}

[data-theme="light"] .title {
  background: linear-gradient(90deg, transparent, var(--accent), var(--accent), transparent);
  background-size: 200% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  animation: textGradientFlow 3s linear infinite;
}

/* ==============================
   🍔 КНОПКА МЕНЮ (МОБИЛЬНАЯ)
   ============================== */

.menu-button {
  display: none;
  background: none;
  border: none;
  color: var(--text);
  cursor: pointer;
  padding: var(--space-sm);
}

/* ==============================
   🏗️ ОСНОВНАЯ СТРУКТУРА
   ============================== */

.main {
  display: flex;
  flex: 1;
  height: calc(100vh - var(--topbar-height));
  min-height: 0;
  position: relative;
}

/* ==============================
   🎮 ОБЛАСТЬ ПРОСМОТРА (VIEWPORT)
   ============================== */

#viewport, .viewport {
  flex: 1;
  position: relative;
  overflow: hidden;
  outline: none;
  width: 100%;
  height: 100%;
  touch-action: pan-x pan-y pinch-zoom;
  -webkit-user-drag: none;
  -webkit-touch-callout: none;
  background: var(--bg-gradient-1);
}

#viewport::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
  background:
    radial-gradient(circle at 40% 40%, var(--bg-glow-1), transparent 70%),
    radial-gradient(circle at 70% 60%, var(--bg-glow-2), transparent 80%);
}

#viewport::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 400px;
  height: 400px;
  transform: translate(-50%, -50%);
  background: radial-gradient(circle, var(--bg-glow-3), transparent 70%);
  pointer-events: none;
  animation: moveGlow 10s ease-in-out infinite;
}

/* ==============================
   🌍 РАБОЧАЯ ОБЛАСТЬ (WORLD/PLANE)
   ============================== */

#world, .world {
  position: absolute;
  left: 0;
  top: 0;
  transform-origin: 0 0;
  will-change: transform;
  width: var(--plane-w);
  height: var(--plane-h);
}

#plane, .plane {
  position: relative;
  width: var(--plane-w);
  height: var(--plane-h);
}

/* ==============================
   🔗 ЛИНИИ СВЯЗЕЙ (EDGES)
   ============================== */

#edges, .edges {
  position: absolute;
  left: 0;
  top: 0;
  width: var(--plane-w);
  height: var(--plane-h);
  pointer-events: none;
}

#edges line, .edges line {
  vector-effect: non-scaling-stroke;
  stroke: var(--line-color);
  stroke-width: 2;
  /*animation: pulseLine 3s ease-in-out infinite;*/
}

/* Линии пути подсветки - БЕЗ анимации пульса, статическая толщина */
#edges line.edge-path, .edges line.edge-path {
  stroke-width: 2 !important;
  animation: none !important;
  stroke: var(--line-selected-color);
}

@keyframes pulseLine {
  0%, 100% { stroke-opacity: var(--line-pulse-start); }
  50% { stroke-opacity: var(--line-pulse-end); }
}

@keyframes moveGlow {
  0%, 100% {
    transform: translate(-50%, -50%) scale(1);
    opacity: .4;
  }
  50% {
    transform: translate(-50%, -50%) scale(1.2);
    opacity: .6;
  }
}

/* ==============================
   🎴 УЗЛЫ И КАРТОЧКИ
   ============================== */

.node, .sub {
  position: absolute;
  transform: translate(-50%, -50%);
  -webkit-transform: translate(-50%, -50%);
}

.node {
  width: var(--node-w);
  cursor: pointer;
  touch-action: pan-x pan-y;
}

.card {
  width: 100%;
  min-height: var(--node-h);
  height: auto;
  background: var(--card-gradient);
  color: #fff;
  border-radius: var(--radius-medium);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--card-shadow), inset 0 0 12px rgba(255, 255, 255, 0.05);
  padding: var(--space-md);
  text-align: center;
  user-select: none;
  transition: transform var(--dur) var(--ease), box-shadow var(--dur-slow) var(--ease), background-color var(--dur) var(--ease);
  border: 1px solid var(--border-light);
  font-weight: 600;
  font-size: var(--font-size-base);
  line-height: 1.3;
  word-wrap: break-word;
  overflow: hidden;
  position: relative;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

.card:hover {
  transform: translateY(-6px) scale(1.04);
  box-shadow: var(--card-shadow-hover), inset 0 0 20px rgba(255, 255, 255, 0.08);
}

.card::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: var(--radius-medium);
  background: radial-gradient(circle at 50% 0%, rgba(255, 255, 255, 0.25), transparent 70%);
  opacity: 0;
  transition: opacity var(--dur) var(--ease);
}

.card:hover::after {
  opacity: 0.5;
}

.sub {
  width: var(--sub-w);
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius-xl);
  background: var(--sub-bg);
  backdrop-filter: blur(12px) saturate(1.3);
  text-align: center;
  font-size: var(--font-size-sm);
  font-weight: 500;
  line-height: 1.3;
  cursor: pointer;
  z-index: 10;
  border: 1px solid var(--border-medium);
  box-shadow: var(--shadow);
  transition: transform var(--dur) var(--ease), box-shadow var(--dur) var(--ease), background-color var(--dur) var(--ease);
  word-wrap: break-word;
  touch-action: pan-x pan-y;
}

.sub:hover {
  background: var(--sub-bg-hover);
  box-shadow: var(--shadow-hover);
  transform: translate(-50%, -50%) scale(1.06);
}

.node.active .card {
  background: var(--card-active-gradient);
  box-shadow: var(--card-glow);
}

/* ==============================
   📖 БОКОВАЯ ПАНЕЛЬ (SIDEBAR)
   ============================== */

.sidebar {
  position: absolute;
  top: 0;
  right: 0;
  width: var(--sidebar-width);
  height: 100%;
  background: var(--sidebar-bg);
  backdrop-filter: blur(18px) saturate(1.5);
  box-shadow: var(--shadow);
  border-left: 1px solid var(--border-light);
  padding: var(--space-lg);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  z-index: 90;
  transform: translateX(100%);
  opacity: 0;
  transition: transform 0.3s ease, opacity 0.3s ease;
}

.sidebar:hover {
  background: var(--sidebar-bg-hover);
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-weight: 600;
  margin-bottom: var(--space-md);
  font-size: var(--font-size-lg);
  padding-bottom: var(--space-sm);
  border-bottom: 1px solid var(--outline);
}

.close-button {
  display: none;
  background: none;
  border: none;
  color: var(--text);
  cursor: pointer;
  padding: var(--space-xs);
}

.sidebar-content {
  flex: 1;
  overflow: auto;
  white-space: pre-wrap;
  font-size: var(--font-size-base);
  line-height: 1.5;
  -webkit-overflow-scrolling: touch;
  word-wrap: break-word;
}

.sidebar-content ul {
  margin: var(--space-sm) 0;
  padding-left: var(--space-xl);
}

.sidebar-content li {
  margin: var(--space-xs) 0;
}

.sidebar-content strong {
  position: relative;
  color: #fff;
}

.sidebar-content strong::before {
  content: "";
  position: absolute;
  left: -8px;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 1.2em;
  border-radius: 2px;
  background: linear-gradient(180deg, var(--accent), var(--accent-light));
}

.sidebar.show {
  transform: translateX(0);
  opacity: 1;
}

.sidebar.hide {
  transform: translateX(100%);
  opacity: 0;
}

.sidebar.active {
  right: 0;
  animation: sidebarFade .4s var(--ease) forwards;
}

@keyframes sidebarFade {
  from {
    opacity: 0;
    transform: translateX(50px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

/* ==============================
   ⚫ ОВЕРЛЕЙ
   ============================== */

.overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--overlay-bg);
  z-index: 80;
  backdrop-filter: blur(4px);
}

.overlay-dark {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 300;
  opacity: 0;
  transition: opacity 0.3s ease;
  pointer-events: none;
}

.overlay-dark.show {
  opacity: 1;
  pointer-events: all;
}

/* ==============================
   ⌨️ НИЖНЯЯ ПАНЕЛЬ УПРАВЛЕНИЯ
   ============================== */

.bottom-controls {
  position: fixed;
  bottom: var(--space-2xl);
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-md);
  z-index: 60;
  width: 100%;
  padding: 0 var(--space-lg);
  pointer-events: none;
}

.bottom-controls > * {
  pointer-events: auto;
}

.input-wrapper {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  width: 100%;
  max-width: var(--input-max-width);
  background: var(--panel);
  backdrop-filter: blur(12px);
  border-radius: var(--radius-full);
  padding: var(--space-xs) var(--space-sm);
  border: 1px solid var(--border-light);
}

.input-wrapper input {
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius-full);
  border: none;
  background: var(--input-bg);
  color: var(--text);
  flex: 1;
  font-size: var(--font-size-base);
  outline: none;
  margin: 0;
  border-radius: var(--radius-full);
  font-size: var(--font-size-lg);
  position: relative;
}

.input-wrapper input::placeholder {
  color: var(--muted);
}

.input-wrapper::after {
  content: attr(data-placeholder);
  position: absolute;
  left: 20px;
  top: 50%;
  transform: translateY(-50%);
  pointer-events: none;
  color: transparent;
  background: linear-gradient(90deg, rgba(255, 255, 255, 1.0), rgba(255, 255, 255, 0.5));
  background-size: 200% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  animation: waveReverse 3.5s linear infinite;
  opacity: 0.9;
  white-space: nowrap;
  overflow: hidden;
  max-width: calc(100% - 80px);
  font-size: var(--font-size-lg);
  padding: var(--space-sm) 0;
}

.input-wrapper.has-text::after {
  display: none;
}

.input-wrapper:not(.has-text)::after {
  display: block;
}

[data-theme="light"] .input-wrapper::after {
  background: linear-gradient(90deg, transparent, #374151, #374151, transparent);
  background-size: 200% 100%;
  -webkit-background-clip: text;
  background-clip: text;
}

@keyframes waveReverse {
  0% { background-position: 100% 50%; }
  100% { background-position: -100% 50%; }
}

.input-wrapper:not(.has-text) input::placeholder {
  color: transparent;
}

.input-wrapper input::placeholder {
  color: var(--muted);
  opacity: 1;
}

/* ==============================
   🔘 КНОПКИ
   ============================== */

.blob-button {
  width: var(--blob-button-size);
  height: var(--blob-button-size);
  border-radius: 50% 50% 50% 50% / 60% 60% 40% 40%;
  background: var(--accent);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  box-shadow: var(--shadow);
  transition: all .3s var(--ease);
  position: relative;
  overflow: hidden;
  flex-shrink: 0;
}

.blob-button:hover {
  transform: scale(1.1);
  border-radius: 40% 60% 60% 40% / 50% 50% 50% 50%;
  box-shadow: var(--shadow-hover);
}

.blob-button:active {
  transform: scale(0.95);
}

.restart-button {
  padding: var(--space-md) var(--space-2xl);
  border-radius: var(--radius-full);
  border: none;
  background: var(--restart-bg-gradient);
  color: white;
  cursor: pointer;
  font-size: var(--font-size-base);
  font-weight: 600;
  letter-spacing: .3px;
  box-shadow: 0 0 10px var(--restart-bg), inset 0 0 10px rgba(255, 255, 255, 0.1);
  transition: all .3s var(--ease);
  white-space: nowrap;
}

.restart-button:hover {
  box-shadow: 0 0 20px var(--restart-bg), inset 0 0 20px rgba(255, 255, 255, 0.1);
}

/* ==============================
   © КОПИРАЙТ
   ============================== */

.copyright-desktop {
  position: fixed;
  bottom: var(--space-2xl);
  left: var(--space-2xl);
  color: var(--muted);
  font-size: var(--font-size-sm);
  text-decoration: none;
  padding: var(--space-sm) var(--space-lg);
  background: var(--panel);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow);
  border: 1px solid var(--outline);
  transition: all .3s var(--ease);
  backdrop-filter: blur(10px);
  pointer-events: auto;
  z-index: 99;
}

.copyright-mobile {
  display: none;
  color: var(--muted);
  font-size: var(--font-size-sm);
  text-decoration: none;
  padding: var(--space-sm) var(--space-lg);
  background: var(--panel);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow);
  border: 1px solid var(--outline);
  transition: all .3s var(--ease);
  backdrop-filter: blur(10px);
  pointer-events: auto;
}

.copyright-desktop:hover,
.copyright-mobile:hover {
  color: var(--accent);
  transform: translateY(-2px);
  box-shadow: 0 6px 15px rgba(0, 0, 0, 0.2);
}

/* ==============================
   🎭 СЛУЖЕБНЫЕ КЛАССЫ
   ============================== */

.hidden {
  display: none !important;
}

/* ==============================
   ⏳ ИНЛАЙН-ЛОАДЕР
   ============================== */

.inline-loader {
  display: none;
  align-items: center;
  gap: var(--space-md);
  width: auto;
  max-width: var(--input-max-width);
  background: var(--panel);
  border-radius: var(--radius-full);
  padding: var(--space-sm) var(--space-lg);
  box-shadow: var(--shadow);
  border: 1px solid var(--outline);
  color: var(--text);
}

.inline-loader:not(.hidden) {
  display: flex;
}

.spinner {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, 0.2);
  border-top-color: var(--accent);
  animation: spin .9s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ==============================
   👋 ПРИВЕТСТВЕННЫЙ БЛОК
   ============================== */

.welcome-block {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-2xl);
  z-index: 10;
  pointer-events: none;
}

.welcome-image {
  width: 30vw;
  max-width: 200px;
  min-width: 120px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.welcome-img {
  width: 100%;
  height: auto;
  opacity: .8;
  animation: float 3s ease-in-out infinite;
  display: block;
  border-radius: 50%;
  aspect-ratio: 1/1;
  object-fit: cover;
}

.welcome-text {
  color: var(--text);
  font-size: var(--font-size-xl);
  font-weight: 500;
  text-align: center;
  opacity: .9;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-10px); }
}

.welcome-block.hidden {
  display: none;
}

/* ==============================
   💬 ЧАТ В БОКОВОЙ ПАНЕЛИ
   ============================== */

.msg {
  display: flex;
  width: 100%;
  margin-bottom: var(--space-md);
}

.msg-bubble {
  max-width: 80%;
  padding: var(--space-md) var(--space-lg);
  border-radius: var(--radius-large);
  line-height: 1.4;
  word-wrap: break-word;
  box-shadow: var(--shadow);
  font-size: var(--font-size-base);
  transition: transform var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}

.msg-bubble.assistant {
  background: var(--msg-assistant-bg);
  color: var(--text);
  border-top-left-radius: 0;
  align-self: flex-start;
  border: 1px solid var(--outline);
}

.msg-bubble.user {
  background: var(--msg-user-bg);
  color: #fff;
  border-top-right-radius: 0;
  align-self: flex-end;
  border: 1px solid var(--border-medium);
}

.msg-bubble.assistant pre {
  background: var(--msg-code-bg);
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius-small);
  font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
  overflow-x: auto;
  font-size: var(--font-size-sm);
  margin: var(--space-sm) 0;
}

.msg-bubble.assistant code {
  font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
  background: var(--msg-code-bg);
  padding: 2px 6px;
  border-radius: var(--radius-xs);
  font-size: var(--font-size-sm);
}

.msg-bubble.assistant ul,
.msg-bubble.assistant ol {
  margin: var(--space-sm) 0;
  padding-left: var(--space-xl);
}

.msg-bubble.assistant li {
  margin: var(--space-xs) 0;
}

.msg-bubble.user:hover,
.msg-bubble.assistant:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 15px rgba(0, 0, 0, 0.2);
}

/* ==============================
   💡 TOAST УВЕДОМЛЕНИЯ
   ============================== */

#infoToast {
  position: fixed;
  bottom: 100px;
  left: 50%;
  transform: translateX(-50%) translateY(0);
  padding: var(--space-md) var(--space-xl);
  border-radius: var(--radius-medium);
  font-size: var(--font-size-base);
  font-weight: 500;
  z-index: 9999;
  pointer-events: none;
  opacity: 0;
  transition: opacity .3s var(--ease), transform .3s var(--ease);
  text-align: center;
  max-width: 90%;
  word-wrap: break-word;
  background: var(--toast-bg);
  color: #fff;
  box-shadow: 0 0 10px rgba(58, 134, 255, 0.2);
  backdrop-filter: blur(10px);
}

[data-theme="light"] #infoToast {
  background: var(--toast-bg);
  color: #000;
}

#infoToast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(-10px);
  pointer-events: auto;
}

#infoToast.hide {
  opacity: 0;
  transform: translateX(-50%) translateY(0);
  pointer-events: none;
}

/* ==============================
   ❌ ПАНЕЛЬ ОШИБОК
   ============================== */

#errorPanelContainer {
  position: fixed;
  bottom: 100px;
  left: 50%;
  transform: translateX(-50%) translateY(0);
  z-index: 9999;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: 90%;
}

#errorPanelContainer > * {
  pointer-events: auto;
}

.error-panel {
  border-radius: var(--radius-medium);
  font-size: var(--font-size-base);
  font-weight: 500;
  opacity: 0;
  transition: opacity 250ms cubic-bezier(0.16, 1, 0.3, 1), transform 250ms cubic-bezier(0.16, 1, 0.3, 1);
  text-align: center;
  max-width: 100%;
  word-wrap: break-word;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
  padding: var(--space-md) var(--space-xl);
  transform: translateY(0);
  background: var(--error-bg);
  color: #fff;
}

.error-panel.show {
  opacity: 1;
  transform: translateY(-10px);
  pointer-events: auto;
}

.error-content {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  justify-content: center;
}

.error-icon {
  font-size: 20px;
  flex-shrink: 0;
  line-height: 1.5;
  min-width: 24px;
  text-align: center;
}

.error-message {
  flex: 1;
  font-size: var(--font-size-base);
  font-weight: 500;
  line-height: 1.5;
  word-wrap: break-word;
}

.error-message p {
  margin: 0;
  padding: 0;
}

.error-close {
  background: none;
  border: none;
  font-size: 20px;
  color: #fff;
  cursor: pointer;
  padding: 0;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all 150ms cubic-bezier(0.16, 1, 0.3, 1);
  font-weight: 400;
  line-height: 1;
  opacity: .8;
}

.error-close:hover {
  opacity: 1;
  transform: scale(1.15);
}

.error-close:active {
  transform: scale(0.95);
}

/* ==============================
   ℹ️ КНОПКА ИНФОРМАЦИИ
   ============================== */

.info-button {
  background-color: var(--info-btn-bg);
  border: none;
  color: white;
  width: 25px;
  height: 25px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.25s ease, opacity 0.25s ease;
  position: relative;
  z-index: 60;
  margin-left: auto;
}

.info-button:hover {
  background-color: var(--accent-glow);
}

/* ==============================
   🪟 ИНФО ОКНО
   ============================== */

.info-popup {
  position: absolute;
  background: var(--panel);
  border-radius: var(--radius-large);
  box-shadow: 0 8px 24px var(--shadow);
  width: 300px;
  padding: var(--space-xl);
  display: flex;
  flex-direction: column;
  z-index: 310;
  opacity: 0;
  transform: scale(0);
  transform-origin: top right;
  transition: transform 0.35s ease, opacity 0.35s ease;
}

.info-popup.show {
  opacity: 1;
  transform: scale(1);
}

.close-btn {
  background: var(--accent);
  border: none;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  align-self: flex-end;
  cursor: pointer;
  margin-bottom: var(--space-xs);
  position: relative;
}

.close-btn::before,
.close-btn::after {
  content: '';
  position: absolute;
  width: 12px;
  height: 2px;
  background-color: var(--text);
  border-radius: 1px;
}

.close-btn::before {
  transform: rotate(45deg);
}

.close-btn::after {
  transform: rotate(-45deg);
}

.close-btn:hover {
  background: var(--accent-glow);
}

.info-content {
  font-size: var(--font-size-sm);
  color: var(--text);
  margin-bottom: 30px;
}

.agreement-btn {
  background: var(--accent);
  color: var(--text);
  border: none;
  padding: 10px 14px;
  border-radius: var(--radius-xl);
  cursor: pointer;
  align-self: center;
  transition: background-color 0.2s;
}

.agreement-btn:hover {
  background: var(--accent-glow);
}

/* ==============================
   📄 ОКНО СОГЛАШЕНИЯ
   ============================== */

.agreement-popup {
  position: fixed;
  inset: 5%;
  background: var(--panel);
  border-radius: var(--radius-large);
  box-shadow: 0 12px 40px var(--shadow);
  display: flex;
  flex-direction: column;
  z-index: 330;
  padding: var(--space-xl);
  opacity: 0;
  transform: scale(0.95);
  transition: all 0.3s ease;
  overflow: hidden;
}

.agreement-popup.show {
  opacity: 1;
  transform: scale(1);
}

.agreement-content {
  font-size: var(--font-size-sm);
  color: var(--text);
  line-height: 1.6;
  margin-top: 10px;
  overflow-y: auto;
  flex: 1;
  padding-right: var(--space-sm);
}

.agreement-content::-webkit-scrollbar {
  width: 3px;
}

.agreement-content::-webkit-scrollbar-track {
  background: var(--sub-bg);
  border-radius: 3px;
}

.agreement-content::-webkit-scrollbar-thumb {
  background: var(--node-bg);
  border-radius: 3px;
}

.agreement-content::-webkit-scrollbar-thumb:hover {
  background: var(--text);
}

/* ==============================
   🍪 БАННЕР COOKIE
   ============================== */

.cookie-consent {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--panel);
  backdrop-filter: blur(10px);
  border-top: 1px solid rgba(0, 0, 0, 0.1);
  padding: var(--space-xl);
  z-index: 90;
  transform: translateY(100%);
  transition: transform 0.3s ease-in-out;
  box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.1);
}

.cookie-consent.show {
  transform: translateY(0);
}

.cookie-content {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-xl);
}

.cookie-text {
  flex: 1;
}

.cookie-text h3 {
  margin: 0 0 var(--space-sm) 0;
  font-size: var(--font-size-lg);
  font-weight: 600;
  color: var(--text);
}

.cookie-text p {
  margin: 0;
  font-size: var(--font-size-base);
  line-height: 1.4;
  color: var(--text);
}

.cookie-text a {
  color: var(--accent);
  text-decoration: none;
}

.cookie-text a:hover {
  text-decoration: underline;
}

.cookie-buttons {
  display: flex;
  gap: var(--space-md);
  flex-shrink: 0;
}

.cookie-accept-btn {
  background: var(--accent);
  color: var(--text);
  border: none;
  padding: 10px 20px;
  border-radius: var(--radius-small);
  font-size: var(--font-size-base);
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
}

.cookie-accept-btn:hover {
  background: var(--accent-glow);
  transform: translateY(-1px);
}

.cookie-decline-btn {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--cookie-decline-border);
  padding: 10px 20px;
  border-radius: var(--radius-small);
  font-size: var(--font-size-base);
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
}

.cookie-decline-btn:hover {
  background: var(--muted);
  border-color: var(--muted);
}

/* ==============================
   🎬 ИНТРО ЭКРАН
   ============================== */

.intro-screen {
  position: relative;
  width: 100vw;
  height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

#particleCanvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  image-rendering: -webkit-optimize-contrast;
  image-rendering: crisp-edges;
  image-rendering: pixelated;
}

#intro-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  pointer-events: none;
}

#intro-overlay > * {
  pointer-events: auto;
}

#intro-block {
  position: relative;
  z-index: 10;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-xl);
  text-align: center;
  justify-content: flex-start;
  padding-top: 40vh;
  width: 100%;
  box-sizing: border-box;
}

.intro-text {
  font-size: var(--font-size-2xl);
  font-weight: 300;
  color: var(--text);
  opacity: 0;
  transform: translateY(-20px);
  transition: opacity 0.8s ease, transform 0.8s ease;
}

.intro-text.visible {
  opacity: 1;
  transform: translateY(0);
}

.intro-text.hidden {
  opacity: 0;
  visibility: hidden;
}

.intro-button {
  padding: var(--space-md) 40px;
  font-size: var(--font-size-lg);
  font-weight: 500;
  color: var(--text);
  background: var(--accent);
  border: none;
  border-radius: var(--radius-2xl);
  cursor: pointer;
  opacity: 0;
  transform: translateY(-20px);
  transition: opacity 0.8s ease, transform 0.8s ease;
}

.intro-button.visible {
  opacity: 1;
  transform: translateY(0);
}

.intro-button.hidden {
  opacity: 0;
  visibility: hidden;
}

.intro-button:hover {
  background: var(--accent-glow);
}

.mainContent {
  position: relative;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
  display: none;
}

.mainContent.show {
  display: block;
  opacity: 1;
  transition: opacity 0.8s ease;
}

/* ==============================
   📐 АДАПТИВ ДЛЯ ПЛАНШЕТОВ
   ============================== */

@media (max-width: 1024px) {
  .copyright-desktop {
    bottom: var(--space-xl);
    left: var(--space-xl);
  }
  
  .sidebar {
    width: 300px;
  }
  
  .input-wrapper {
    max-width: 400px;
  }
}

/* ==============================
   📱 АДАПТИВ ДЛЯ МОБИЛЬНЫХ
   ============================== */

@media (max-width: 768px) {
  :root {
    --topbar-height: 56px;
    --sidebar-width: 85vw;
    --input-max-width: 350px;
    --blob-button-size: 44px;
    --node-w: 140px;
    --node-h: 70px;
    --sub-w: 100px;
  }
  
  .topbar {
    padding: var(--space-sm) var(--space-md);
    height: var(--topbar-height);
  }
  
  .title {
    font-size: var(--font-size-lg);
  }
  
  .menu-button {
    display: block;
  }
  
  .main {
    height: calc(100vh - var(--topbar-height));
  }

  .sidebar {
    position: fixed;
    top: 0;
    right: -100%;
    bottom: 0;
    width: var(--sidebar-width);
    max-width: 320px;
    transition: right .3s var(--ease);
    z-index: 1200;
  }
  
  .sidebar.active {
    right: 0;
  }

  .close-button {
    display: block;
  }
  
  .input-wrapper {
    max-width: var(--input-max-width);
    gap: var(--space-sm);
    transform: translateZ(0);
  }
  
  .blob-button {
    width: var(--blob-button-size);
    height: var(--blob-button-size);
  }
  
  .blob-button svg,
  .menu-button svg,
  .close-button svg {
    width: 18px;
    height: 18px;
  }

  .node {
    --node-w: var(--node-w);
    --node-h: var(--node-h);
  }
  
  .sub {
    --sub-w: var(--sub-w);
    font-size: var(--font-size-xs);
    padding: 6px 10px;
  }
  
  .card {
    font-size: var(--font-size-sm);
    padding: 10px;
  }

  .copyright-desktop {
    display: none;
  }
  
  .copyright-mobile {
    display: block;
    font-size: var(--font-size-xs);
    padding: 6px 12px;
  }

  .restart-button {
    position: fixed;
    right: var(--space-lg);
    bottom: var(--space-lg);
    z-index: 1300;
    width: 52px;
    height: 52px;
    padding: 0;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--restart-bg-gradient);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.35);
    font-size: 0;
    white-space: nowrap;
    overflow: hidden;
  }
  
  .restart-button::before {
    content: "";
    display: block;
    width: 22px;
    height: 22px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='white'%3E%3Cpath d='M12 5V2L8 6l4 4V7c3.31 0 6 2.69 6 6 0 2.97-2.17 5.43-5 5.91v2.02c3.95-.49 7-3.85 7-7.93 0-4.42-3.58-8-8-8z'/%3E%3Cpath d='M6 13c0-1.65.67-3.15 1.76-4.24L6.34 7.34C4.9 8.79 4 10.79 4 13c0 4.08 3.05 7.44 7 7.93v-2.02c-2.83-.48-5-2.94-5-5.91z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: center;
    background-size: contain;
    transition: transform 0.3s ease;
    margin: 0 auto;
  }

  #inlineLoader {
    position: fixed;
    right: var(--space-lg);
    bottom: var(--space-lg);
    z-index: 1300;
    background: transparent;
    border: none;
    box-shadow: none;
    padding: 0;
    gap: 0;
    min-width: auto;
    max-width: none;
    width: auto;
    height: auto;
    display: flex;
    align-items: center;
    justify-content: center;
  }
  
  #inlineLoader .spinner {
    width: 28px;
    height: 28px;
    border-width: 3px;
    margin: 0;
  }
  
  #inlineLoader .spinner + span {
    display: none;
  }
  
  .welcome-block {
    gap: var(--space-xl);
  }
  
  .welcome-image {
    width: 40vw;
    max-width: 150px;
  }
  
  .welcome-text {
    font-size: var(--font-size-lg);
  }
  
  .msg-bubble {
    max-width: 85%;
    padding: 10px 14px;
    font-size: var(--font-size-sm);
  }
}

/* ==============================
   📱 АДАПТИВ ДЛЯ МАЛЕНЬКИХ МОБИЛЬНЫХ
   ============================== */

@media (max-width: 480px) {
  :root {
    --topbar-height: 52px;
    --node-w: 120px;
    --node-h: 60px;
    --sub-w: 90px;
  }
  
  .topbar {
    padding: 6px 10px;
    height: var(--topbar-height);
  }
  
  .title {
    font-size: var(--font-size-base);
  }

  .bottom-controls {
    bottom: var(--space-lg);
    padding: 0 var(--space-md);
    transform: translateX(-50%) translateZ(0);
    -webkit-transform: translateX(-50%) translateZ(0);
  }
  
  .input-wrapper {
    max-width: 100%;
    gap: 6px;
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
  }
  
  .input-wrapper input {
    padding: 10px 14px;
    font-size: var(--font-size-lg);
    margin: 0 6px;
    -webkit-appearance: none;
    appearance: none;
    border-radius: var(--radius-full);
  }
  
  .blob-button {
    width: 40px;
    height: 40px;
  }

  .sidebar {
    width: 90vw;
    padding: var(--space-md);
    z-index: 1200;
  }
  
  .sidebar-header {
    font-size: var(--font-size-base);
    margin-bottom: var(--space-sm);
  }
  
  .sidebar-content {
    font-size: var(--font-size-sm);
  }

  .node {
    --node-w: var(--node-w);
    --node-h: var(--node-h);
  }
  
  .sub {
    --sub-w: var(--sub-w);
    font-size: var(--font-size-xs);
    padding: 5px 8px;
  }
  
  .card {
    font-size: var(--font-size-sm);
    padding: var(--space-sm);
    border-radius: var(--radius-xl);
  }

  .copyright-link {
    font-size: var(--font-size-xs);
    padding: 5px 10px;
  }

  .restart-button {
    width: 48px;
    height: 48px;
    right: 14px;
    bottom: 14px;
  }
  
  .restart-button::before {
    width: 20px;
    height: 20px;
  }
  
  #inlineLoader {
    right: 14px;
    bottom: 14px;
  }
  
  #inlineLoader .spinner {
    width: 24px;
    height: 24px;
    border-width: 3px;
  }
  
  #inlineLoader .spinner + span {
    display: none;
  }
  
  .welcome-block {
    gap: var(--space-lg);
  }
  
  .welcome-image {
    width: 50vw;
    max-width: 120px;
  }
  
  .welcome-text {
    font-size: var(--font-size-base);
  }
  
  .msg-bubble {
    max-width: 90%;
    padding: var(--space-sm) var(--space-md);
    font-size: var(--font-size-sm);
  }
  
  #infoToast {
    font-size: var(--font-size-sm);
    padding: 10px 16px;
    bottom: 80px;
  }
  
  #errorPanelContainer {
    bottom: 80px;
  }
  
  .error-panel {
    font-size: var(--font-size-sm);
    padding: 10px 16px;
  }
  
  .error-message {
    font-size: var(--font-size-sm);
  }
  
  .error-icon {
    font-size: 18px;
    min-width: 20px;
  }
  
  .error-close {
    width: 20px;
    height: 20px;
    font-size: 18px;
  }
}

/* ==============================
   📱 АДАПТИВ ДЛЯ ОЧЕНЬ МАЛЕНЬКИХ ЭКРАНОВ
   ============================== */

@media (max-width: 360px) {
  :root {
    --topbar-height: 48px;
    --node-w: 110px;
    --node-h: 55px;
    --sub-w: 80px;
  }
  
  .topbar {
    height: var(--topbar-height);
  }
  
  .title {
    font-size: var(--font-size-sm);
  }
  
  .main {
    height: calc(100vh - var(--topbar-height));
  }

  .node {
    --node-w: var(--node-w);
    --node-h: var(--node-h);
  }
  
  .sub {
    --sub-w: var(--sub-w);
  }
  
  .sub--disabled {
    opacity: .55;
    pointer-events: none;
    filter: grayscale(.1);
  }

  .input-wrapper input {
    padding: var(--space-sm) var(--space-md);
    font-size: var(--font-size-lg);
    margin: 0 var(--space-xs);
  }
  
  .input-wrapper input::placeholder {
    font-size: var(--font-size-sm);
  }

  .restart-button {
    width: 44px;
    height: 44px;
    right: var(--space-md);
    bottom: var(--space-md);
  }
  
  .restart-button::before {
    width: 18px;
    height: 18px;
  }
  
  #inlineLoader {
    right: var(--space-md);
    bottom: var(--space-md);
  }
  
  #inlineLoader .spinner {
    width: 22px;
    height: 22px;
    border-width: 2.5px;
  }
  
  #inlineLoader .spinner + span {
    display: none;
  }
}

/* ==============================
   📱 ЛАНДШАФТНЫЙ РЕЖИМ НА МОБИЛЬНЫХ
   ============================== */

@media (max-height: 500px) and (orientation: landscape) {
  :root {
    --topbar-height: 48px;
    --node-w: 100px;
    --node-h: 50px;
    --sub-w: 70px;
  }
  
  .topbar {
    height: var(--topbar-height);
    padding: var(--space-xs) var(--space-md);
  }
  
  .main {
    height: calc(100vh - var(--topbar-height));
  }
  
  .bottom-controls {
    bottom: var(--space-md);
    transform: translateX(-50%) translateZ(0);
  }
  
  .input-wrapper {
    max-width: 300px;
  }

  .node {
    --node-w: var(--node-w);
    --node-h: var(--node-h);
  }
  
  .sub {
    --sub-w: var(--sub-w);
    font-size: var(--font-size-xs);
    padding: var(--space-xs) 6px;
  }
  
  .card {
    font-size: var(--font-size-xs);
    padding: 6px;
  }

  .copyright-link {
    display: none;
  }

  .restart-button {
    right: var(--space-md);
    bottom: var(--space-md);
  }
  
  #inlineLoader {
    right: var(--space-md);
    bottom: var(--space-md);
  }
}

/* ==============================
   👆 СТИЛИ ДЛЯ ТАЧ-УСТРОЙСТВ
   ============================== */

@media (hover: none) and (pointer: coarse) {
  .card:hover,
  .sub:hover,
  .blob-button:hover,
  .restart-button:hover {
    transform: none;
  }
  
  .card:active,
  .sub:active {
    transform: scale(0.95);
  }
  
  .blob-button:active {
    transform: scale(0.9);
  }
  
  .restart-button:active {
    transform: translateY(0);
  }

  :where(a, button, [role="button"], .card, .sub, .blob-button, .restart-button, .menu-button, .close-button):focus,
  :where(a, button, [role="button"], .card, .sub, .blob-button, .restart-button, .menu-button, .close-button):focus-visible {
    outline: 0 !important;
    box-shadow: none !important;
  }
}

/* ==============================
   🍎 ИСПРАВЛЕНИЯ ДЛЯ iOS SAFARI
   ============================== */

@supports (-webkit-touch-callout: none) {
  .bottom-controls {
    transform: translateX(-50%) translateZ(0);
    -webkit-transform: translateX(-50%) translateZ(0);
  }
  
  .input-wrapper input {
    font-size: var(--font-size-lg);
    transform: translateZ(0);
  }
  
  #viewport, .viewport {
    -webkit-overflow-scrolling: touch;
  }
}

/* ==============================
   ♿ ДОСТУПНОСТЬ: ФОКУС И РАЗМЕРЫ
   ============================== */

:where(a, button, [role="button"], input, textarea, .card, .sub, .blob-button, .restart-button, .menu-button, .close-button):focus-visible {
  outline: 0;
  box-shadow: 0 0 0 3px var(--ring), 0 0 0 5px var(--outline);
  border-radius: inherit;
}

:where(.blob-button, .restart-button, .menu-button, .close-button) {
  min-width: 44px;
  min-height: 44px;
}

/* ==============================
   🚫 ПРЕДПОЧТЕНИЕ МЕНЬШЕ ДВИЖЕНИЯ
   ============================== */

@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
  
  #viewport::after {
    animation: none !important;
  }
  
  .card:hover,
  .sub:hover {
    transform: none !important;
  }
}

/* ==============================
   🎯 ИСПРАВЛЕНИЯ ЦЕНТРИРОВАНИЯ
   ============================== */

.welcome-block {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-2xl);
  z-index: 10;
  pointer-events: none;
}

.welcome-image {
  width: 30vw;
  max-width: 200px;
  min-width: 120px;
  display: flex;
  align-items: center;
  justify-content: center;
}

#inlineLoader {
  display: flex;
  align-items: center;
  justify-content: center;
}

#inlineLoader .spinner {
  margin: 0;
}

@media (max-width: 768px) {
  #inlineLoader {
    position: fixed;
    right: var(--space-lg);
    bottom: var(--space-lg);
    z-index: 1300;
    background: transparent;
    border: none;
    box-shadow: none;
    padding: 0;
    gap: 0;
    min-width: auto;
    max-width: none;
    width: auto;
    height: auto;
    display: flex;
    align-items: center;
    justify-content: center;
  }
  
  #inlineLoader .spinner {
    width: 28px;
    height: 28px;
    border-width: 3px;
    margin: 0;
  }
}

/* ==============================
   🔧 ИСПРАВЛЕНИЯ ЛИНИЙ СВЯЗЕЙ
   ============================== */

.node, .sub {
  position: absolute;
  transform: translate(-50%, -50%) !important;
  -webkit-transform: translate(-50%, -50%) !important;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  user-select: none;
  left: attr(data-x);
  top: attr(data-y);
}

.card {
  width: 100%;
  min-height: var(--node-h);
  height: auto;
  background: var(--card-gradient);
  color: #fff;
  border-radius: var(--radius-medium);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--card-shadow), inset 0 0 12px rgba(255, 255, 255, 0.05);
  padding: var(--space-md);
  text-align: center;
  user-select: none;
  transition: none !important;
  border: 1px solid var(--border-light);
  font-weight: 600;
  font-size: var(--font-size-base);
  line-height: 1.3;
  word-wrap: break-word;
  overflow: hidden;
  position: relative;
  -webkit-tap-highlight-color: transparent;
  transform: none !important;
  -webkit-transform: none !important;
  left: 0 !important;
  top: 0 !important;
}

.card:hover,
.sub:hover,
.card:active, 
.sub:active,
.card:focus,
.sub:focus {
  transform: none !important;
  -webkit-transform: none !important;
}

.sub:hover,
.sub:active {
  transform: translate(-50%, -50%) !important;
  -webkit-transform: translate(-50%, -50%) !important;
}

.node.active .card {
  background: var(--card-active-gradient);
  box-shadow: var(--card-glow);
  transform: none !important;
  -webkit-transform: none !important;
}

.card,
.sub {
  animation: none !important;
  transition: none !important;
  -webkit-transition: none !important;
  -webkit-animation: none !important;
}

.card[style*="transform"],
.sub[style*="transform"],
.node[style*="transform"] {
  transform: translate(-50%, -50%) !important;
  -webkit-transform: translate(-50%, -50%) !important;
}

.node .card[style*="transform"] {
  transform: none !important;
  -webkit-transform: none !important;
}

/* Стили для кнопки старта в интро */
.startBtn {
  border-radius: 50px; /* Или любое большое значение для эффекта "половины высоты" */
  background: var(--accent);
  color: var(--text);
  border: none;
  padding: 12px 40px;
  font-size: 16px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.3s ease;
  /* Это обеспечит закругление в половину высоты */
  border-radius: 50%;
}

.startBtn:hover {
  background: var(--accent-glow);
}