:root {
      color-scheme: only dark;
      --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-search-shell {
      position: absolute;
      top: 10px;
      left: 50%;
      z-index: 25;
      width: min(340px, calc(100% - 126px));
      transform: translateX(-50%);
      font-family: 'Epilogue', sans-serif;
    }
    .node-search-toggle {
      display: flex;
      align-items: center;
      justify-content: center;
      gap: 8px;
      min-height: 42px;
      width: 100%;
      border-radius: 24px;
      color: #f0e3c8;
      font-size: 13px;
      font-weight: 700;
      letter-spacing: normal;
    }
    .node-search-panel {
      margin-top: 6px;
      padding: 12px;
      border-radius: 12px;
      color: #e6ddce;
      box-shadow: 0 12px 25px rgba(0,0,0,.6);
    }
    .node-search-panel[hidden] { display: none; }
    .node-search-panel label { display: block; margin-bottom: 6px; font-size: 12px; }
    .node-search-panel input {
      width: 100%;
      min-height: 42px;
      padding: 8px 10px;
      border: 1px solid #846733;
      border-radius: 7px;
      background: #100e13;
      color: #fff1d4;
      font: 13px/1.3 'Epilogue', sans-serif;
    }
    #node-search-results { display: grid; gap: 4px; max-height: 260px; overflow-y: auto; margin-top: 8px; }
    #node-search-results p { padding: 8px; color: #cfc7bc; font-size: 13px; }
    .node-search-result {
      min-height: 40px;
      padding: 8px 10px;
      border: 1px solid #42394f;
      border-radius: 7px;
      background: #17141f;
      color: #e6ddce;
      font: 600 13px/1.3 'Epilogue', sans-serif;
      text-align: left;
    }
    .node-search-result:hover, .node-search-result:focus-visible { border-color: #cbb074; background: #2b2430; }
    #view-skill-tree button { letter-spacing: normal; }
    #node-action-btn, #node-secondary-btn, #m-node-action-btn, #m-node-secondary-btn,
    #m-drawer-secondary-btn, #floating-view-controls button, #m-sheet-expand-btn {
      font-family: 'Epilogue', sans-serif;
      font-size: 12px;
      line-height: 1.3;
      color: #f0e3c8;
    }
    /* Действия не полагаются на Tailwind CDN: его dynamic-классы менялись
       из JS и оставляли браузерную серую кнопку в VK WebView. */
    #node-action-btn, #node-secondary-btn, #m-node-action-btn,
    #m-node-secondary-btn, #m-drawer-secondary-btn, #reset-skill-points-btn {
      min-height: 44px;
      border-radius: 8px;
      font-family: 'Epilogue', sans-serif;
      font-size: 13px;
      font-weight: 700;
      line-height: 1.3;
      letter-spacing: normal;
      text-align: center;
      text-shadow: 0 1px 1px rgba(0, 0, 0, .6);
    }
    #node-action-btn[class*="bg-[#3d1117]"],
    #m-node-action-btn[class*="bg-[#3d1117]"] {
      background: linear-gradient(180deg, #54252a 0%, #321519 100%) !important;
      border: 1px solid #a85a60 !important;
      color: #ffe2dc !important;
      box-shadow: inset 0 1px rgba(255, 224, 220, .08), 0 2px 6px rgba(0, 0, 0, .45);
    }
    #node-action-btn[class*="bg-[#3d1117]"]:hover:not(:disabled),
    #m-node-action-btn[class*="bg-[#3d1117]"]:hover:not(:disabled) {
      background: linear-gradient(180deg, #71333a 0%, #481d23 100%) !important;
      border-color: #d0797e !important;
    }
    #node-secondary-btn, #m-node-secondary-btn, #m-drawer-secondary-btn {
      background: linear-gradient(180deg, #3b2023 0%, #241315 100%);
      border: 1px solid #9d555b;
      color: #ffe2dc;
    }
    #node-action-btn:disabled, #m-node-action-btn:disabled {
      appearance: none;
      background: #28231c !important;
      border: 1px solid #756243 !important;
      color: #eadcc4 !important;
      -webkit-text-fill-color: #eadcc4;
      opacity: 1;
      cursor: not-allowed;
    }
    #reset-skill-points-btn {
      background: linear-gradient(180deg, #28231c 0%, #171411 100%);
      border: 1px solid #756243;
      color: #f0e2c5;
    }
    #reset-skill-points-btn:hover {
      background: linear-gradient(180deg, #3a3022 0%, #211a12 100%);
      border-color: #b38e50;
      color: #fff1d4;
    }
    #node-action-btn:focus-visible, #node-secondary-btn:focus-visible,
    #m-node-action-btn:focus-visible, #m-node-secondary-btn:focus-visible,
    #m-drawer-secondary-btn:focus-visible, #reset-skill-points-btn:focus-visible {
      outline: 2px solid #e2c27b;
      outline-offset: 2px;
    }
    @media (max-width: 767px) {
      .node-search-shell { left: 12px; width: calc(100% - 76px); transform: none; }
      .node-search-toggle { min-height: 44px; }
    }
    /* На ширине VK Mini App поиск занимает колонку между инспектором и кнопками карты. */
    @media (min-width: 768px) and (max-width: 1050px) {
      .node-search-shell {
        left: 288px;
        right: 100px;
        width: auto;
        min-width: 0;
        transform: none;
      }
    }

    /* Оставлял только лёгкую подсветку нового узла без сдвига карты. */
    .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;
    }

    /* Масштаб меняет плотность линий, но не бледнит и не уменьшает сами медальоны. */
    #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; }

    /* На общем плане круглые PNG-иконки сжимаются в белые точки; сохраняем медальон и статус узла. */
    #nodes-layer[data-semantic-zoom="overview"] .node-tier-minor .node-icon-image {
      display: none;
    }
    #nodes-layer[data-semantic-zoom="overview"] .node-tier-minor:not(.branch-active):not(.branch-dimmed) .node-body > circle:first-of-type {
      fill: #151117;
      stroke: #796748;
      stroke-width: 4;
    }
    #nodes-layer[data-semantic-zoom="overview"] .node-tier-minor.branch-active .node-body > circle:first-of-type {
      fill: #241b13;
      stroke: #e0bd70;
      stroke-width: 4;
    }

    @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;
      }
    }

    @media (max-width: 767px) {
      #view-skill-tree { height: calc(100dvh - 96px); }
    }
    #desktop-inspector-panel {
      display: none;
    }
    #desktop-header-actions {
      display: none;
    }
    #sync-modal.hidden {
      display: none !important;
    }
    #mobile-nav-drawer.hidden {
      display: none !important;
    }
    @media (min-width: 768px) {
      #desktop-inspector-panel {
        display: block !important;
      }
      #desktop-header-actions {
        display: flex !important;
      }
    }
