:root {
      --bg-crypt: #070709;
      --bg-slate: #0e0d11;
      --iron-dark: #1a1820;
      --iron-rim: #383342;
      --gold-antique: #846733;
      --gold-bright: #cbb074;
    }
    /* Mobile & Safe Area Adaptations */
    :root {
      --safe-top: env(safe-area-inset-top, 0px);
      --safe-bottom: env(safe-area-inset-bottom, 0px);
      --safe-left: env(safe-area-inset-left, 0px);
      --safe-right: env(safe-area-inset-right, 0px);
    }
    @view-transition {
      /* Общая анимация профиля и дерева давала скачок размеров в VK WebView. */
      navigation: none;
    }
    #skill-auth-gate {
      position: fixed;
      inset: 0;
      z-index: 1000;
      display: flex;
      align-items: center;
      justify-content: center;
      padding: 24px;
      background: #070709;
    }
    #skill-auth-gate.is-hidden { display: none; }
    html.warm-character-navigation #skill-auth-gate { display: none; }
    .skill-auth-gate-card {
      width: min(100%, 420px);
      padding: 26px 24px;
      border: 1px solid #5d472b;
      border-radius: 12px;
      background: radial-gradient(circle at 50% 0%, #211a14 0%, #0f0d11 75%);
      box-shadow: 0 18px 60px rgba(0, 0, 0, .55), inset 0 0 0 1px rgba(220, 176, 93, .08);
      color: #e6ddce;
      text-align: center;
    }
    .skill-auth-gate-card strong {
      display: block;
      margin-top: 12px;
      color: #e6ddce;
      font-family: 'Cinzel', serif;
      font-size: 15px;
    }
    .skill-auth-gate-card p {
      margin: 9px 0 0;
      color: #978b7d;
      font: 12px/1.5 'Epilogue', sans-serif;
    }

    /* VK Mini Apps Mobile Capsule Clearance */
    .vk-mobile-header {
      padding-right: calc(var(--safe-right, 0px) + 94px) !important;
      padding-left: calc(var(--safe-left, 0px) + 8px) !important;
    }
    html, body {
      height: 100%;
      height: 100dvh;
      overscroll-behavior: none;
      -webkit-user-select: none;
      user-select: none;
      -webkit-touch-callout: none;
    }
    body {
      display: flex;
      flex-direction: column;
      font-family: 'Source Serif 4', Georgia, serif;
      background-color: var(--bg-crypt);
      color: #cfc7bc;
      overflow-x: hidden;
      min-width: 320px;
      min-height: 100%;
      min-height: 100dvh;
      -webkit-tap-highlight-color: transparent;
      user-select: none;
    }
    body > header {
      position: sticky;
      top: 0;
      z-index: 30;
      display: flex;
      min-height: 48px;
      align-items: center;
      justify-content: space-between;
    }
    body > header svg:not(#tree-canvas),
    #floating-view-controls svg {
      display: block;
      flex: 0 0 auto;
    }
    body > main {
      position: relative;
      display: flex;
      min-width: 0;
      min-height: 0;
      flex: 1 1 auto;
      overflow: hidden;
    }
    #view-skill-tree {
      position: relative;
      display: flex;
      width: 100%;
      min-width: 0;
      min-height: 0;
      flex: 1 1 auto;
      overflow: hidden;
    }
    #tree-viewport {
      position: relative;
      width: 100%;
      height: 100%;
      overflow: hidden;
      touch-action: none;
      overscroll-behavior: none;
    }
    #tree-canvas {
      position: absolute;
      inset: 0;
      display: block;
      width: 100%;
      height: 100%;
    }
    /* Touch Target Hitbox */
    .touch-hitbox {
      cursor: pointer;
      -webkit-tap-highlight-color: transparent;
    }
    /* Hide scrollbars for pill bars */
    .no-scrollbar::-webkit-scrollbar { display: none; }
    .no-scrollbar { -ms-overflow-style: none; scrollbar-width: none; }
    .font-cinzel { font-family: 'Cinzel', serif; }
    .font-mono { font-family: 'JetBrains Mono', monospace; }
    .font-sans { font-family: 'Epilogue', sans-serif; }

    /* Custom Stone Scrollbars */
    ::-webkit-scrollbar { width: 5px; height: 5px; }
    ::-webkit-scrollbar-track { background: #09080c; }
    ::-webkit-scrollbar-thumb { background: #26222b; border-radius: 2px; }
    ::-webkit-scrollbar-thumb:hover { background: #3c3545; }

    /* Grim Gothic Stone Panels */
    .stone-panel {
      background: radial-gradient(circle at 50% 0%, #15131a 0%, #09080d 100%);
      border: 1px solid #2b2733;
      box-shadow: 0 10px 25px rgba(0,0,0,0.85), inset 0 0 15px rgba(0,0,0,0.7);
    }
    .stone-gold-panel {
      background: radial-gradient(circle at 50% 0%, #1c1813 0%, #0c0a08 100%);
      border: 1px solid #544227;
      box-shadow: 0 10px 25px rgba(0,0,0,0.85), inset 0 0 12px rgba(84,66,39,0.25);
    }
    .stone-button {
      background: linear-gradient(180deg, #25212b 0%, #131117 100%);
      border: 1px solid #383242;
      box-shadow: 0 3px 6px rgba(0,0,0,0.5);
    }
    .stone-button:hover {
      background: linear-gradient(180deg, #302b38 0%, #1a1721 100%);
      border-color: #524961;
    }
    .stone-gold-btn {
      background: linear-gradient(180deg, #594426 0%, #2b2010 100%);
      border: 1px solid #8c6f3e;
      color: #e6ce9e;
      box-shadow: 0 3px 6px rgba(0,0,0,0.6);
    }
    .stone-gold-btn:hover {
      background: linear-gradient(180deg, #735730 0%, #3d2d17 100%);
      border-color: #b38e50;
      color: #fff1d4;
    }

    /* Оставлял только лёгкую подсветку нового узла без сдвига карты. */
    .node-body {
      transform-box: fill-box;
      transform-origin: center;
      transition: filter 0.3s ease-out;
    }
    /* Золотое кольцо перемещалось скриптом; зум и координаты карты не анимировались. */
    .node-pulse-once {
      animation: naviaNodePulse 0.8s cubic-bezier(0.16, 1, 0.3, 1) 1 forwards;
    }
    @keyframes naviaNodePulse {
      0% {
        filter: drop-shadow(0 0 0px rgba(255, 215, 0, 0));
      }
      35% {
        filter: drop-shadow(0 0 10px rgba(255, 215, 0, 0.85));
      }
      100% {
        filter: drop-shadow(0 0 2px rgba(203, 176, 116, 0.3));
      }
    }
    @keyframes branchFlowDraw {
      0% {
        stroke-dashoffset: var(--line-length, 200);
        opacity: 0.35;
      }
      15% {
        opacity: 1;
      }
      100% {
        stroke-dashoffset: 0;
        opacity: 1;
      }
    }
    .anim-line-draw {
      animation: branchFlowDraw 1.2s cubic-bezier(0.16, 1, 0.3, 1) 1 forwards;
      filter: drop-shadow(0 0 6px rgba(255, 215, 0, 0.85)) drop-shadow(0 0 14px rgba(203, 176, 116, 0.6));
      stroke-linecap: round;
    }
    .branch-dimmed {
      opacity: 0.18 !important;
      filter: grayscale(0.7);
    }
    .branch-active {
      opacity: 1 !important;
    }

    /* На отдалении карта подчёркивает крупные узлы, но мелкие остаются доступными для выбора. */
    #nodes-layer[data-semantic-zoom="overview"] .node-tier-minor .node-body {
      opacity: 0.42;
      transform: scale(0.78);
    }
    #nodes-layer[data-semantic-zoom="overview"] .node-tier-notable .node-body,
    #nodes-layer[data-semantic-zoom="overview"] .node-tier-keystone .node-body {
      transform: scale(1.03);
    }

    /* Средний масштаб сохраняет все уровни читаемыми и не перегружает карту. */
    #nodes-layer[data-semantic-zoom="branches"] .node-tier-minor .node-body {
      opacity: 0.84;
      transform: scale(0.94);
    }

    /* При приближении сначала проявляются детали ветки, а не меняются координаты узлов. */
    #nodes-layer[data-semantic-zoom="details"] .node-tier-minor .node-body {
      opacity: 1;
      transform: scale(1.05);
    }
    #nodes-layer[data-semantic-zoom="details"] .node-tier-notable .node-body,
    #nodes-layer[data-semantic-zoom="details"] .node-tier-keystone .node-body {
      transform: scale(1.03);
    }

    #links-layer .skill-link,
    #orbit-rings {
      transition: none;
    }
    #links-layer[data-semantic-zoom="overview"] .skill-link-minor:not(.branch-active):not(.branch-dimmed) {
      opacity: 0.22;
    }
    #links-layer[data-semantic-zoom="overview"] .skill-link-deep:not(.branch-active):not(.branch-dimmed) {
      opacity: 0.1;
    }
    #links-layer[data-semantic-zoom="branches"] .skill-link-minor:not(.branch-active):not(.branch-dimmed) {
      opacity: 0.58;
    }
    #links-layer[data-semantic-zoom="branches"] .skill-link-deep:not(.branch-active):not(.branch-dimmed) {
      opacity: 0.38;
    }
    #links-layer[data-semantic-zoom="details"] .skill-link-minor:not(.branch-active):not(.branch-dimmed) {
      opacity: 0.9;
    }
    #links-layer[data-semantic-zoom="details"] .skill-link-deep:not(.branch-active):not(.branch-dimmed) {
      opacity: 0.78;
    }

    #orbit-rings[data-semantic-zoom="overview"] { opacity: 0.1; }
    #orbit-rings[data-semantic-zoom="branches"] { opacity: 0.18; }
    #orbit-rings[data-semantic-zoom="details"] { opacity: 0.24; }

    @media (prefers-reduced-motion: reduce) {
      #selection-ring,
      #nodes-layer .node-body,
      #links-layer .skill-link,
      #orbit-rings,
      #links-layer .anim-line-draw {
        transition: none !important;
        animation: none !important;
        filter: none !important;
      }
    }

    /* Навигация связывает самостоятельные страницы профиля и дерева. */
    .navia-nav-strip {
      display: flex;
      align-items: center;
      gap: 4px;
      padding: 4px;
      border: 1px solid #574328;
      border-radius: 8px;
      background: linear-gradient(180deg, #1b1510, #0d0c0b);
      box-shadow: inset 0 0 12px rgba(0, 0, 0, 0.65), 0 5px 14px rgba(0, 0, 0, 0.35);
    }
    .navia-nav-tab {
      min-height: 42px;
      padding: 7px 13px;
      border: 1px solid transparent;
      border-radius: 5px;
      color: #9b8e7c;
      font: 700 11px/1 'Epilogue', sans-serif;
      text-decoration: none;
      transition: background-color 180ms ease, border-color 180ms ease, color 180ms ease, transform 180ms ease;
    }
    .navia-nav-tab:hover { color: #f1dfbb; background: rgba(132, 103, 51, 0.16); }
    .navia-nav-tab[aria-current='page'] {
      color: #f1d49a;
      border-color: #98733d;
      background: linear-gradient(180deg, rgba(125, 88, 39, 0.58), rgba(50, 33, 17, 0.92));
      box-shadow: inset 0 0 9px rgba(237, 185, 89, 0.10), 0 2px 7px rgba(0, 0, 0, 0.55);
    }
    .navia-nav-tab:active { transform: translateY(1px); }
    .navia-nav-tab:focus-visible {
      outline: 2px solid #e2b968;
      outline-offset: 2px;
    }
    @media (max-width: 767px) {
      #view-skill-tree { height: calc(100dvh - 96px); }
      .navia-nav-strip { width: 100%; justify-content: stretch; }
      .navia-nav-tab { min-width: 0; flex: 1 1 0; padding: 8px 5px; font-size: 9px; }
      .navia-nav-tab .navia-tab-label { display: block; margin-top: 5px; }
    }
    @media (prefers-reduced-motion: reduce) {
      .navia-nav-tab { transition: none; }
    }
