:root {
    --bg: #050714;
    --bg-alt: #050815;
    --panel: #080b1a;
    --accent: #fca311;
    --accent-soft: rgba(252,163,17,0.35);
    --bull: #0aff88;
    --bear: #ff4d6a;
    --neutral: #ffd15c;
    --text-soft: #9ba3c0;
  }

  * { box-sizing: border-box; }

  html, body {
    margin: 0;
    padding: 0;
    background: radial-gradient(ellipse at top, #151b32 0%, #050714 55%, #02040a 100%);
    color: #fff;
    font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
    height: 100%;
    overflow: hidden;
  }

  #main-canvas {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    display: block;
  }

  /* UI-слой поверх сцены */
  #ui-layer {
    position: fixed;
    inset: 0;
    pointer-events: none;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    z-index: 10;
  }

  header {
    pointer-events: auto;
    padding: 10px 20px 8px;
    text-align: center;
    background: linear-gradient(180deg, rgba(0,0,0,0.72) 0%, rgba(0,0,0,0.0) 100%);
    backdrop-filter: blur(8px);
  }

  .title-main {
    letter-spacing: 0.22em;
    font-size: 14px;
    text-transform: uppercase;
    color: #f5f7ff;
  }

  .title-sub {
    margin-top: 6px;
    font-size: 9px;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: rgba(196,208,255,0.8);
    line-height: 1.45;
    max-width: 560px;
    margin-left: auto;
    margin-right: auto;
  }

  .header-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 8px 14px;
    border-radius: 999px;
    border: 1px solid rgba(121,144,255,0.45);
    color: #f5f7ff;
    text-decoration: none;
    font-size: 11px;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    background: rgba(6, 10, 24, 0.7);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
  }

  .header-link:hover {
    transform: translateY(-1px);
    box-shadow: 0 10px 24px rgba(13, 37, 90, 0.4);
  }

  .legend {
    position: fixed;
    left: 24px;
    bottom: 24px;
    padding: 14px 16px;
    border-radius: 16px;
    background: radial-gradient(circle at top left, rgba(34,44,88,0.95), rgba(5,7,20,0.98));
    border: 1px solid rgba(121,144,255,0.45);
    box-shadow: 0 26px 80px rgba(0,0,0,0.9);
    font-size: 11px;
    color: var(--text-soft);
    pointer-events: auto;
    max-width: 260px;
  }

  .legend-row {
    display: flex;
    align-items: center;
    margin-bottom: 4px;
  }

  .legend-dot {
    width: 10px;
    height: 10px;
    border-radius: 99px;
    margin-right: 8px;
  }

  .legend-dot.bull { background: var(--bull); box-shadow: 0 0 14px rgba(10,255,136,0.7); }
  .legend-dot.bear { background: var(--bear); box-shadow: 0 0 14px rgba(255,77,106,0.7); }
  .legend-dot.neutral { background: var(--neutral); box-shadow: 0 0 14px rgba(255,209,92,0.7); }

  .legend small {
    display: block;
    margin-top: 6px;
    font-size: 10px;
    color: rgba(155,164,196,0.85);
  }

  /* Нижние кнопки */
  #bottom-controls {
    pointer-events: auto;
    display: flex;
    justify-content: center;
    gap: 16px;
    margin-bottom: 18px;
  }

  .btn-pill {
    padding: 9px 20px;
    border-radius: 999px;
    border: 1px solid rgba(140,168,255,0.55);
    background: radial-gradient(circle at top left, rgba(15,24,65,0.98), rgba(7,10,30,0.98));
    color: #dde4ff;
    font-size: 11px;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: all 0.22s ease;
  }

  .btn-pill span.icon {
    font-size: 13px;
  }

  .btn-pill:hover {
    border-color: var(--accent);
    box-shadow: 0 0 26px rgba(252,163,17,0.4);
    transform: translateY(-1px);
  }

  .btn-pill.active {
    background: linear-gradient(135deg, #fca311, #ff6b4a);
    color: #05060f;
    border-color: transparent;
  }

  /* Лоадер */
  #loader {
    position: fixed;
    inset: 0;
    background: radial-gradient(circle at 32% 18%, #121a35 0%, #070b18 42%, #03040c 100%);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 100;
    overflow: hidden;
  }

  .loader-ring {
    position: relative;
    width: 96px;
    height: 96px;
    display: grid;
    place-items: center;
    filter: drop-shadow(0 0 30px rgba(252,163,17,0.38));
  }

  .loader-ring::before {
    content: "";
    position: absolute;
    inset: 8px;
    border-radius: 50%;
    background: conic-gradient(#fca311 0deg 120deg, rgba(252,163,17,0.08) 120deg 360deg);
    -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 9px), #000 calc(100% - 7px));
    mask: radial-gradient(farthest-side, transparent calc(100% - 9px), #000 calc(100% - 7px));
    animation: spin 1.4s linear infinite;
  }

  .loader-ring::after {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: 50%;
    background: radial-gradient(circle at 30% 30%, rgba(252,163,17,0.12), rgba(5,7,20,0.92) 55%);
    box-shadow: inset 0 0 0 1px rgba(255,255,255,0.04), 0 0 40px rgba(252,163,17,0.28);
    filter: blur(0.5px);
  }

  .loader-text {
    margin-top: 18px;
    font-size: 11px;
    letter-spacing: 0.32em;
    text-transform: uppercase;
    color: #f8fbff;
    text-align: center;
  }

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

  /* Модальное окно */
  #modal-overlay {
    position: fixed;
    inset: 0;
    padding: 24px;
    background: radial-gradient(circle at top, rgba(12,16,35,0.62), rgba(1,3,12,0.78));
    backdrop-filter: blur(18px);
    display: none;
    z-index: 40;
    align-items: center;
    justify-content: center;
    overflow-y: auto;
  }
  #modal-overlay.visible {
    display: flex;
  }

  #modal-card {
    width: min(1200px, 94vw);
    max-height: 86vh;
    border-radius: 28px;
    background: radial-gradient(circle at 12% 8%, rgba(38,50,120,0.86), rgba(6,8,24,0.88));
    border: 1px solid rgba(140,168,255,0.5);
    box-shadow: 0 38px 140px rgba(0,0,0,0.82), 0 12px 60px rgba(51,74,160,0.35);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    position: relative;
    align-self: center;
    backdrop-filter: blur(16px) saturate(1.15);
  }

  #modal-close {
    position: absolute;
    top: 18px;
    right: 20px;
    width: 28px;
    height: 28px;
    border-radius: 999px;
    border: 1px solid rgba(173,188,255,0.6);
    background: radial-gradient(circle at top, rgba(11,17,45,1), rgba(8,10,28,1));
    color: #e4ebff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 15px;
    z-index: 2;
  }

  #modal-inner {
    display: grid;
    grid-template-columns: minmax(0, 1.02fr) minmax(0, 1.1fr);
    gap: 14px;
    height: 100%;
    padding: 18px;
    align-items: stretch;
    min-height: 0;
    overflow: hidden;
  }

  .modal-left {
    padding: 18px 20px 14px 20px;
    overflow-y: auto;
    border-radius: 18px;
    background: radial-gradient(circle at top left, rgba(13,18,48,0.78), rgba(5,7,22,0.86));
    box-shadow: inset 0 0 0 1px rgba(116,138,217,0.2);
    min-height: 0;
  }

  .modal-right {
    position: relative;
    padding: 18px;
    background: radial-gradient(circle at top left, rgba(18,32,72,0.92), rgba(4,7,20,0.94));
    border-radius: 18px;
    border: 1px solid rgba(88,112,192,0.45);
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 0;
    overflow: hidden;
    box-shadow: inset 0 0 0 1px rgba(255,255,255,0.04);
  }

  .modal-mode-toggle{
    position: absolute;
    top: 16px;
    right: 18px;
    display: inline-flex;
    gap: 6px;
    z-index: 4;
    background: rgba(4,7,20,0.65);
    padding: 4px;
    border-radius: 999px;
    border: 1px solid rgba(120,148,240,0.4);
    backdrop-filter: blur(8px);
  }

  .modal-mode-toggle button{
    padding: 6px 12px;
    font-size: 10px;
    border-radius: 999px;
    border: 1px solid transparent;
    background: transparent;
    color: rgba(214,228,255,0.9);
    text-transform: uppercase;
    letter-spacing: 0.12em;
    cursor: pointer;
    transition: all 0.2s ease;
  }

  .modal-mode-toggle button.active{
    background: linear-gradient(135deg, rgba(15,255,190,0.9), rgba(56,180,255,0.9));
    color: #06101b;
    border-color: rgba(0,0,0,0.15);
    box-shadow: 0 0 16px rgba(56,180,255,0.35);
  }

  .modal-mode-toggle button.mode-3d.active{
    background: linear-gradient(135deg, rgba(252,163,17,0.95), rgba(255,107,74,0.95));
  }

  .badge {
    display: inline-flex;
    padding: 4px 12px 4px 12px;
    border-radius: 999px;
    border: 1px solid rgba(255,255,255,0.28);
    font-size: 10px;
    letter-spacing: 0.22em;
    text-transform: uppercase;
    color: #f5f5ff;
    margin-bottom: 16px;
  }

  .badge.bullish {
    border-color: rgba(10,255,136,0.6);
    box-shadow: 0 0 18px rgba(10,255,136,0.4);
    color: #9cffd0;
  }
  .badge.bearish {
    border-color: rgba(255,77,106,0.8);
    box-shadow: 0 0 18px rgba(255,77,106,0.4);
    color: #ffd0da;
  }
  .badge.neutral {
    border-color: rgba(255,209,92,0.8);
    box-shadow: 0 0 18px rgba(255,209,92,0.4);
    color: #ffecc1;
  }

  .pattern-title {
    font-family: 'Playfair Display', 'Times New Roman', serif;
    font-size: 32px;
    margin: 0 0 6px 0;
    word-break: break-word;
    line-height: 1.1;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }

  .pattern-sub {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.20em;
    color: rgba(186,196,230,0.95);
    margin-bottom: 22px;
  }

  .meta-row {
    display: flex;
    gap: 16px;
    margin-bottom: 22px;
  }

  .meta-pill {
    flex: 1;
    padding: 12px 14px;
    border-radius: 16px;
    background: radial-gradient(circle at top left, rgba(12,19,56,0.96), rgba(4,7,26,0.96));
    border: 1px solid rgba(116,138,217,0.8);
    font-size: 11px;
  }

  .meta-label {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.16em;
    color: rgba(163,178,230,0.9);
    margin-bottom: 4px;
  }

  .meta-value {
    color: #f7f3ff;
    font-weight: 500;
  }

  .section-title {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.16em;
    margin: 20px 0 6px;
    color: rgba(165,178,232,0.96);
  }

  .modal-left p {
    font-size: 13px;
    line-height: 1.6;
    color: var(--text-soft);
    margin: 0 0 6px 0;
  }

  .modal-left ul {
    padding-left: 18px;
    margin: 6px 0 10px 0;
  }

  .modal-left li {
    font-size: 13px;
    line-height: 1.5;
    color: var(--text-soft);
    margin-bottom: 4px;
  }

  .wiki-block {
    margin-top: 14px;
    padding: 10px 12px;
    border-radius: 14px;
    background: radial-gradient(circle at top left, rgba(13,23,55,0.96), rgba(4,7,24,0.96));
    border: 1px dashed rgba(116,138,217,0.7);
    font-size: 12px;
    color: var(--text-soft);
  }

  .wiki-block strong { color: #e6ecff; }
  .wiki-block p { margin: 0; line-height: 1.55; }

  .wiki-title {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.16em;
    color: rgba(149,166,231,0.96);
    margin-bottom: 3px;
  }

  .modal-footer {
    display: flex;
    justify-content: center;
    padding-top: 12px;
  }

  .modal-footer button {
    padding: 10px 26px;
    border-radius: 999px;
    border: 1px solid rgba(139,162,255,0.7);
    background: radial-gradient(circle at top, #101636, #050715);
    color: #e7ecff;
    font-size: 11px;
    letter-spacing: 0.20em;
    text-transform: uppercase;
    cursor: pointer;
  }

  #modal-viewport {
    width: 100%;
    height: 100%;
    border-radius: 20px;
    overflow: hidden;
    position: relative;
    box-shadow: inset 0 0 0 1px rgba(116,138,217,0.7), 0 20px 60px rgba(0,0,0,0.7);
    display: grid;
    place-items: center;
    min-height: 420px;
    background: radial-gradient(circle at 40% 30%, rgba(22,34,70,0.95), rgba(6,9,20,0.98));
  }

  #modal-viewport canvas {
    width: 100%;
    height: 100%;
    display: block;
    position: absolute;
    inset: 0;
    margin: auto;
    filter: drop-shadow(0 0 18px rgba(108,150,255,0.35));
  }

  .modal-caption {
    position: absolute;
    left: 28px;
    bottom: 18px;
    font-size: 11px;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: rgba(172,187,244,0.95);
    pointer-events: none;
    z-index: 3;
  }

  #modal-viewport[data-mode="2d"] .modal-webgl{
    opacity: 0;
    pointer-events: none;
  }

  #modal-viewport[data-mode="3d"] #modal-chart2d{
    opacity: 0;
    pointer-events: none;
    transform: scale(0.98);
  }

  #modal-chart2d{
    position: absolute;
    inset: 0;
    padding: 20px;
    display: grid;
    grid-template-rows: 1fr;
    align-items: stretch;
    justify-items: stretch;
    z-index: 2;
    transition: opacity 0.35s ease, transform 0.35s ease;
  }

  .chart-mask{
    position: relative;
    width: 100%;
    height: 100%;
    border-radius: 16px;
    overflow: hidden;
    box-shadow: inset 0 0 0 1px rgba(116,138,217,0.55);
  }

  .chart-surface{
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
  }

  #chart2d-fallback{
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    display: block;
  }

  #chart2d-overlay{
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    overflow: visible;
    display: block;
    z-index: 3;
  }

  .chart-line{
    stroke: rgba(255,255,255,0.9);
    stroke-width: 2;
    fill: none;
    stroke-linecap: round;
    stroke-linejoin: round;
  }

  .chart-line.dashed{
    stroke-dasharray: 6 6;
  }

  .chart-zone{
    fill: rgba(34,210,170,0.18);
    stroke: rgba(34,210,170,0.45);
    stroke-width: 1;
  }

  .chart-zone.bear{
    fill: rgba(255,77,106,0.16);
    stroke: rgba(255,77,106,0.4);
  }

  #chart2d-labels{
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 4;
  }

  .chart-label{
    position: absolute;
    padding: 6px 10px;
    border-radius: 999px;
    font-size: 11px;
    letter-spacing: 0.02em;
    color: #071018;
    background: rgba(15,255,190,0.9);
    box-shadow: 0 4px 16px rgba(12,240,190,0.35);
    transform: translate(-50%, -50%);
    opacity: 0;
    animation: labelIn 0.5s ease forwards;
  }

  .chart-label.bull{
    background: rgba(15,255,190,0.9);
    box-shadow: 0 4px 16px rgba(12,240,190,0.35);
  }

  .chart-label.bear{
    background: rgba(255,77,106,0.92);
    box-shadow: 0 4px 16px rgba(255,77,106,0.35);
  }

  .chart-label.neutral{
    background: rgba(255,209,92,0.9);
    box-shadow: 0 4px 16px rgba(255,209,92,0.35);
  }

  .chart-label.compact{
    font-size: 10px;
    padding: 4px 8px;
  }

  .chart-animate .chart-mask{
    animation: wipeIn 0.9s ease forwards;
    transform-origin: left center;
  }

  .chart-animate .chart-line{
    stroke-dasharray: 240;
    stroke-dashoffset: 240;
    animation: lineDraw 0.9s ease forwards;
  }

  .chart-animate .chart-line.dashed{
    stroke-dasharray: 140 80;
    stroke-dashoffset: 220;
  }

  @keyframes wipeIn{
    from { clip-path: inset(0 100% 0 0); }
    to { clip-path: inset(0 0 0 0); }
  }

  @keyframes lineDraw{
    to { stroke-dashoffset: 0; }
  }

  @keyframes labelIn{
    from { opacity: 0; transform: translate(-50%, -50%) translateY(6px); }
    to { opacity: 1; transform: translate(-50%, -50%) translateY(0); }
  }

  /* Адаптив */
  @media (max-width: 1000px) {
    #modal-card { max-height: unset; }
    #modal-inner { grid-template-columns: 1fr; height: auto; }
    .modal-right {
      border-left: none;
      border-top: 1px solid rgba(88,112,192,0.45);
      min-height: 42vh;
    }
  }

  @media (max-width: 640px) {
    #modal-overlay { padding: 12px; }
    #modal-card { width: 100%; border-radius: 20px; }
    .modal-left { padding: 18px 16px 16px; }
    .modal-right { min-height: 38vh; }
    .legend { display: none; }
    .modal-mode-toggle{ top: 12px; right: 12px; }
    #modal-chart2d{ padding: 14px; }
    .gesture-panel{ left: 12px; right: 12px; top: 70px; width: auto; }
  }

  /* -------------------- V4: поиск, избранное, иконки-глифы, улучшенная модалка -------------------- */
  header{ display:flex; align-items:center; justify-content:space-between; gap:12px; padding: 10px 20px; }
  .title-left{ display:flex; flex-direction:column; gap:4px; flex: 1; text-align: left; }
  .header-tools{ display:flex; align-items:center; gap:10px; flex-shrink: 0; flex-wrap: wrap; justify-content: flex-end; }
  .btn-pill.small{ padding: 8px 12px; font-size: 11px; border-radius: 999px; }
  .btn-pill.small.gesture-active{
    background: linear-gradient(135deg, #31d3ff, #7b5cff);
    color: #05060f;
    border-color: transparent;
    box-shadow: 0 10px 32px rgba(83,108,255,0.45);
  }

  .gesture-panel{
    position: fixed;
    top: 84px;
    right: 24px;
    width: min(360px, 88vw);
    padding: 16px 18px 18px;
    border-radius: 18px;
    border: 1px solid rgba(121,144,255,0.4);
    background: radial-gradient(circle at top left, rgba(38,54,112,0.95), rgba(5,8,22,0.98));
    box-shadow: 0 24px 70px rgba(0,0,0,0.6);
    color: #e6edff;
    opacity: 0;
    transform: translateY(-10px);
    transition: opacity 0.25s ease, transform 0.25s ease;
    pointer-events: none;
    z-index: 20;
  }
  .gesture-panel.visible{
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
  }
  .gesture-panel-header{
    display:flex;
    align-items:center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 10px;
  }
  .gesture-title{
    font-size: 13px;
    letter-spacing: 0.14em;
    text-transform: uppercase;
  }
  .gesture-status{
    font-size: 10px;
    padding: 4px 10px;
    border-radius: 999px;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    background: rgba(255,255,255,0.12);
    color: rgba(255,255,255,0.9);
  }
  .gesture-status.active{
    background: rgba(48,211,255,0.22);
    color: #dcf6ff;
    border: 1px solid rgba(86,189,255,0.6);
  }
  .gesture-note{
    margin: 0 0 12px;
    font-size: 12px;
    color: rgba(202,214,255,0.88);
    line-height: 1.5;
  }
  .gesture-list{
    margin: 0 0 12px;
    padding-left: 18px;
    font-size: 12px;
    color: rgba(225,234,255,0.92);
    line-height: 1.5;
  }
  .gesture-list li{ margin-bottom: 6px; }
  .gesture-tip{
    font-size: 11px;
    color: rgba(169,183,224,0.88);
  }
  .gesture-cursor{
    position: fixed;
    width: 18px;
    height: 18px;
    border: 2px solid #fca311;
    border-radius: 50%;
    box-shadow: 0 0 16px rgba(252,163,17,0.7);
    transform: translate(-50%, -50%);
    opacity: 0;
    transition: opacity 0.2s ease;
    pointer-events: none;
    z-index: 30;
  }
  .gesture-cursor.active{ opacity: 1; }
  .gesture-video{ position: fixed; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
  .search-wrap{
    position: relative;
    display:flex;
    align-items:center;
    gap:8px;
    padding: 10px 10px;
    border-radius: 999px;
    border: 1px solid rgba(140,170,255,0.28);
    background: radial-gradient(120% 120% at 10% 10%, rgba(90,130,255,0.22), rgba(12,16,38,0.85));
    box-shadow: inset 0 0 0 1px rgba(255,255,255,0.05);
    min-width: 320px;
  }
  .search-ic{ opacity:0.9; font-size: 14px; }
  #pattern-search{
    width: 100%;
    background: transparent;
    border: none;
    outline: none;
    color: rgba(240,248,255,0.92);
    font-family: inherit;
    font-size: 13px;
  }
  .icon-btn{
    border:none;
    outline:none;
    background: rgba(255,255,255,0.07);
    color: rgba(240,248,255,0.92);
    width: 26px;
    height: 26px;
    border-radius: 999px;
    cursor:pointer;
  }
  .icon-btn:hover{ background: rgba(255,255,255,0.12); }
  .search-results{
    position:absolute;
    left:0; right:0;
    top: 46px;
    background: rgba(8,10,24,0.92);
    border: 1px solid rgba(140,170,255,0.25);
    border-radius: 14px;
    overflow:hidden;
    display:none;
    max-height: 340px;
    box-shadow: 0 18px 50px rgba(0,0,0,0.5);
    backdrop-filter: blur(10px);
    z-index: 10;
  }
  .search-results.visible{ display:block; }
  .sr-item{
    display:flex;
    gap:10px;
    padding: 10px 12px;
    cursor:pointer;
    align-items:center;
    border-bottom: 1px solid rgba(255,255,255,0.06);
  }
  .sr-item:last-child{ border-bottom:none; }
  .sr-item:hover{ background: rgba(120,160,255,0.10); }
  .sr-dot{
    width: 10px; height: 10px; border-radius: 999px;
    box-shadow: 0 0 0 2px rgba(255,255,255,0.06);
    flex: 0 0 auto;
  }
  .sr-main{ display:flex; flex-direction:column; gap:2px; min-width:0; }
  .sr-title{ font-weight: 700; font-size: 12px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
  .sr-sub{ font-size: 11px; opacity: 0.75; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }

  /* modal enhancements */
  .modal-left{ position:relative; }
  .modal-actions{
    display:flex;
    gap:8px;
    align-items:center;
    margin: 10px 0 12px;
  }
  .mini-btn{
    border: 1px solid rgba(140,170,255,0.28);
    background: rgba(255,255,255,0.06);
    color: rgba(240,248,255,0.92);
    padding: 8px 10px;
    border-radius: 12px;
    cursor: pointer;
    font-size: 12px;
    text-decoration: none;
    display:inline-flex;
    align-items:center;
    justify-content:center;
    min-width: 38px;
  }
  .mini-btn:hover{ background: rgba(255,255,255,0.10); }
  .mini-btn.active{ background: rgba(0,255,136,0.12); border-color: rgba(0,255,136,0.25); }

  .wiki-title{ display:flex; align-items:center; justify-content:space-between; gap:10px; }
  #wiki-link{
    font-size: 12px;
    color: rgba(150,200,255,0.95);
    text-decoration: none;
    padding: 6px 10px;
    border-radius: 999px;
    border: 1px solid rgba(150,200,255,0.25);
    background: rgba(150,200,255,0.06);
  }
  #wiki-link:hover{ background: rgba(150,200,255,0.10); }
  .wiki-meta{ margin-top: 6px; font-size: 11px; opacity: 0.75; }

  /* small improvement for viewport edge */
  #modal-viewport{
    position:relative;
    overflow:hidden;
  }
  #modal-viewport::after{
    content:"";
    position:absolute; inset: 0;
    pointer-events:none;
    background: radial-gradient(120% 120% at 50% 20%, rgba(120,160,255,0.14), rgba(0,0,0,0) 55%);
    mix-blend-mode: screen;
  }

  #modal-viewport::before{
    content:"";
    position:absolute;
    inset: 0;
    pointer-events:none;
    background: linear-gradient(180deg, rgba(7,10,24,0.0) 40%, rgba(4,6,16,0.65) 100%);
  }

  @media (max-width: 860px){
    header{ align-items:flex-start; flex-direction:column; gap:10px; }
    .search-wrap{ min-width: 100%; }
    .header-tools{ width:100%; }
  }
