/* ======================================= тема «BlackHole»: Focus Deck === */

html[data-theme="blackhole"] {
  --display-weight: 620;
  --display-spacing: 0.012em;
  --title-weight: 610;
  --label-spacing: 0.12em;

  --radius-lg: 4px;
  --radius-md: 3px;
  --radius-sm: 2px;
  --radius-chip: 3px;
  --rail-width: 2px;

  --bg: #000;
  --surface-1: rgb(2 6 12 / 72%);
  --surface-2: rgb(7 14 24 / 72%);
  --surface-3: rgb(11 23 38 / 76%);
  --sunken: rgb(0 2 6 / 82%);

  --line: rgb(157 204 255 / 14%);
  --line-strong: rgb(162 213 255 / 32%);
  --card-bg: linear-gradient(180deg, rgb(5 11 19 / 76%), rgb(0 3 8 / 84%));
  --card-bg-open: linear-gradient(180deg, rgb(8 17 29 / 84%), rgb(0 4 10 / 90%));
  --card-texture: none;
  --card-border: rgb(153 204 255 / 16%);
  --card-border-open: rgb(103 190 255 / 48%);
  --card-shadow:
    inset 0 1px 0 rgb(224 243 255 / 5%),
    0 22px 54px -36px rgb(0 0 0 / 100%);
  --plate-bg: linear-gradient(180deg, rgb(210 235 255 / 6%), rgb(0 4 10 / 26%));
  --plate-shadow: inset 0 1px 0 rgb(232 247 255 / 6%);
  --turn-shadow: 0 0 28px -20px rgb(75 174 255 / 82%);

  --text: #f1f6fb;
  --text-soft: #becbd8;
  --text-muted: #78899c;
  --text-faint: #526477;
  --accent: #58bfff;
  --accent-soft: rgb(54 173 255 / 12%);
  --accent-line: rgb(83 187 255 / 46%);
  --accent-glow: 0 0 22px -8px rgb(71 180 255 / 90%);
  --selection: rgb(65 174 255 / 28%);
  --brand-gradient: linear-gradient(145deg, rgb(42 164 255 / 18%), rgb(4 14 27 / 8%));
  --brand-shadow: 0 0 20px -8px rgb(72 183 255 / 95%);

  --provider-none: #718194;
  --provider-codex: #69c7ff;
  --provider-claude: #b8a6e8;
  --provider-tone-lightness: 0.78;
  --provider-tone-chroma: 0.09;
  --provider-tone-alpha: 0.18;
  --ok: #77d0ff;
  --pending: #8a96a5;
  --dot-input: #58bfff;
  --dot-cache: #94dcff;
  --dot-output: #eaf7ff;
  --dot-think: #bdaaf1;

  --space-glow-a: rgb(65 165 255 / 8%);
  --space-glow-b: rgb(98 83 208 / 5%);
  --space-base: #000;
  --space-star: transparent;
  --star-opacity: 0;

  --blackhole-image: url("./blackhole-blue.jpg");
}

/* Три сцены — самостоятельные растры. На них нет интерфейсных деталей, поэтому
   они одинаково кадрируются в браузере, Worker и VS Code webview. */
html[data-theme="blackhole"] body::after {
  background-color: #000;
  background-image: var(--blackhole-image);
  background-position: 50% 51%;
  background-repeat: no-repeat;
  background-size: cover;
  inset: 0;
  mask-image: none;
  opacity: 1;
}

@keyframes blackhole-lensing {
  0%, 100% { opacity: 0.16; transform: scale(1.005); }
  47% { opacity: 0.4; transform: scale(1.028); }
  68% { opacity: 0.23; transform: scale(1.014); }
}

html[data-theme="blackhole"] body::before {
  animation: blackhole-lensing 26s ease-in-out infinite;
  background-image:
    radial-gradient(32% 58% at 52% 51%, transparent 54%, rgb(75 176 255 / 19%) 60%, transparent 69%);
  background-position: center;
  background-size: cover;
  content: "";
  mask-image: none;
  mix-blend-mode: screen;
  opacity: 0.2;
}

html[data-theme="blackhole"] .app-header {
  backdrop-filter: blur(8px) saturate(112%);
  -webkit-backdrop-filter: blur(8px) saturate(112%);
  background: rgb(0 3 8 / 74%);
  border-bottom-color: rgb(126 193 255 / 16%);
}

html[data-theme="blackhole"] .app-header::after {
  background: linear-gradient(90deg, transparent 5%, rgb(82 184 255 / 34%) 50%, transparent 95%);
}

html[data-theme="blackhole"] .view-switch {
  background: transparent;
  border: 0;
  border-radius: 0;
  padding: 0;
}

html[data-theme="blackhole"] .view-tab {
  border-bottom: 1px solid transparent;
  border-radius: 0;
}

html[data-theme="blackhole"] .view-tab[aria-pressed="true"] {
  background: linear-gradient(180deg, transparent 62%, rgb(69 175 255 / 9%));
  border: 0;
  border-bottom: 1px solid #58bfff;
}

html[data-theme="blackhole"] .toolbar .view-settings,
html[data-theme="blackhole"] .chip-button,
html[data-theme="blackhole"] .icon-button,
html[data-theme="blackhole"] .composer-send,
html[data-theme="blackhole"] .composer-input {
  border-radius: 2px;
}

html[data-theme="blackhole"] .journal details[data-work-log-day-section],
html[data-theme="blackhole"] .journal details[data-work-log-turn-details] {
  backdrop-filter: blur(5px) saturate(108%);
  -webkit-backdrop-filter: blur(5px) saturate(108%);
  background-color: rgb(1 6 12 / 68%);
  background-image: none;
}

html[data-theme="blackhole"] .journal details[data-work-log-day-section][open],
html[data-theme="blackhole"] .journal details[data-work-log-turn-details][open] {
  background-color: rgb(2 9 17 / 80%);
}

@media (min-width: 1120px) {
  html[data-theme="blackhole"]:not([data-surface="mobile"]) {
    --task-rail-width: clamp(244px, 17vw, 304px);
  }

  html[data-theme="blackhole"]:not([data-surface="mobile"]) .app-header-inner {
    max-width: none;
    padding-inline: clamp(1rem, 1.35vw, 1.5rem);
  }

  html[data-theme="blackhole"]:not([data-surface="mobile"]) .workspace {
    gap: clamp(0.55rem, 0.7vw, 0.82rem);
    margin: 0;
    max-width: none;
    padding: clamp(0.72rem, 0.9vw, 1rem);
    padding-bottom: 0.7rem;
  }

  html[data-theme="blackhole"]:not([data-surface="mobile"]) .task-rail {
    backdrop-filter: blur(6px) saturate(108%);
    -webkit-backdrop-filter: blur(6px) saturate(108%);
    background: linear-gradient(180deg, rgb(1 7 14 / 76%), rgb(0 3 8 / 82%));
    border: 1px solid rgb(130 195 255 / 18%);
    border-radius: 2px;
    box-shadow: inset 0 1px 0 rgb(223 242 255 / 4%), 0 24px 54px -40px #000;
    overflow: hidden;
  }

  html[data-theme="blackhole"]:not([data-surface="mobile"]) .task-search {
    background: rgb(0 4 9 / 72%);
    border-color: rgb(124 192 255 / 16%);
    border-radius: 2px;
  }

  html[data-theme="blackhole"]:not([data-surface="mobile"]) .task-item {
    border: 0;
    border-bottom: 1px solid rgb(125 187 244 / 7%);
    border-radius: 0;
    margin: 0;
  }

  html[data-theme="blackhole"]:not([data-surface="mobile"]) .task-item:hover {
    background: linear-gradient(90deg, rgb(70 176 255 / 10%), transparent 84%);
  }

  html[data-theme="blackhole"]:not([data-surface="mobile"]) .task-item[data-selected] {
    background: linear-gradient(90deg, rgb(59 166 246 / 18%), rgb(23 71 111 / 5%));
  }

  html[data-theme="blackhole"]:not([data-surface="mobile"]) .task-item[data-selected]::before {
    border-radius: 0;
    bottom: 0;
    box-shadow: 0 0 12px rgb(73 183 255 / 82%);
    left: 0;
    top: 0;
  }

  html[data-theme="blackhole"]:not([data-surface="mobile"]) .chat {
    background: transparent;
    border: 0;
    border-radius: 0;
    gap: 0.5rem;
  }

  /* Streams становятся орбитальными узлами над палубой. Подписи остаются
     настоящими кнопками: переключение, Ctrl+click и drag работают как раньше. */
  html[data-theme="blackhole"]:not([data-surface="mobile"]) .stream-tabs {
    align-items: stretch;
    background: rgb(0 3 8 / 48%);
    border: 0;
    gap: clamp(0.7rem, 1.5vw, 1.6rem);
    min-height: 4.3rem;
    overflow-x: auto;
    padding: 0.25rem clamp(0.8rem, 1.4vw, 1.5rem);
    position: relative;
  }

  html[data-theme="blackhole"]:not([data-surface="mobile"]) .stream-tabs::before {
    background: linear-gradient(90deg, transparent, rgb(126 190 245 / 28%) 8%, rgb(126 190 245 / 28%) 92%, transparent);
    content: "";
    height: 1px;
    left: 1.1rem;
    pointer-events: none;
    position: absolute;
    right: 1.1rem;
    top: 1.45rem;
  }

  html[data-theme="blackhole"]:not([data-surface="mobile"]) .stream-tab {
    border: 0;
    border-radius: 0;
    flex: 1 0 10.5rem;
    max-width: 20rem;
    min-height: 3.7rem;
    padding: 0;
    width: auto;
  }

  html[data-theme="blackhole"]:not([data-surface="mobile"]) .stream-tab:hover,
  html[data-theme="blackhole"]:not([data-surface="mobile"]) .stream-tab:focus-visible,
  html[data-theme="blackhole"]:not([data-surface="mobile"]) .stream-tab[aria-pressed="true"] {
    background: transparent;
    border: 0;
  }

  html[data-theme="blackhole"]:not([data-surface="mobile"]) .stream-tab-card {
    background: transparent;
    border: 0;
    border-radius: 0;
    gap: 0.48rem;
    padding: 0.5rem 0.35rem 0.15rem;
  }

  html[data-theme="blackhole"]:not([data-surface="mobile"]) .stream-tab .provider-dot {
    background: #050b12;
    border: 2px solid #d8e4ee;
    box-shadow: 0 0 0 4px rgb(0 4 10 / 88%);
    height: 0.62rem;
    margin-top: 0.42rem;
    position: relative;
    width: 0.62rem;
    z-index: 1;
  }

  html[data-theme="blackhole"]:not([data-surface="mobile"]) .stream-tab[data-current] .provider-dot {
    background: #72caff;
    border-color: #b9e6ff;
    box-shadow: 0 0 0 4px rgb(4 23 38 / 94%), 0 0 18px 4px rgb(58 173 255 / 78%);
  }

  html[data-theme="blackhole"]:not([data-surface="mobile"]) .stream-tab:not([aria-pressed="true"]) .stream-tab-body {
    opacity: 0.48;
  }

  html[data-theme="blackhole"]:not([data-surface="mobile"]) .stream-tab-body {
    gap: 0.15rem;
  }

  html[data-theme="blackhole"]:not([data-surface="mobile"]) .stream-tab-title {
    font-size: 0.72rem;
  }

  html[data-theme="blackhole"]:not([data-surface="mobile"]) .stream-tab-meta {
    color: var(--text-faint);
    font-size: 0.61rem;
  }

  /* Focus Deck: один боковой Stream уходит влево, остальные — вправо, а
     выбранный всегда остаётся гравитационным центром композиции. */
  html[data-theme="blackhole"]:not([data-surface="mobile"]) .stream-chat-columns[data-multi-stream] {
    display: flex;
    gap: clamp(0.38rem, 0.55vw, 0.64rem);
    overflow-x: auto;
    padding: 0.1rem 0.18rem 0.2rem;
  }

  html[data-theme="blackhole"]:not([data-surface="mobile"]) .stream-chat-columns[data-multi-stream] > .chat-pane {
    backdrop-filter: blur(5px) saturate(108%);
    -webkit-backdrop-filter: blur(5px) saturate(108%);
    background: linear-gradient(180deg, rgb(1 7 14 / 84%), rgb(0 3 8 / 90%));
    border: 1px solid rgb(92 185 255 / 46%);
    border-radius: 0;
    box-shadow:
      inset 0 0 34px rgb(38 135 209 / 8%),
      0 0 24px -13px rgb(50 167 255 / 75%);
    flex: 2 1 0;
    min-width: min(30rem, 40vw);
    order: 0 !important;
    z-index: 2;
  }

  /* Общая подсветка активного Stream имеет более специфичный селектор в
     базовой оболочке. Перекрываем её явно, чтобы яркий аккреционный диск не
     проходил прямо под белым текстом ни в одиночном, ни в многопоточном чате. */
  html[data-theme="blackhole"]:not([data-surface="mobile"]) .stream-chat-columns > .chat-pane[data-active-stream] {
    background: linear-gradient(180deg, rgb(0 4 10 / 90%), rgb(0 2 7 / 94%));
  }

  html[data-theme="blackhole"]:not([data-surface="mobile"]) .stream-chat-preview {
    backdrop-filter: blur(4px) saturate(104%);
    -webkit-backdrop-filter: blur(4px) saturate(104%);
    background: linear-gradient(180deg, rgb(1 6 12 / 70%), rgb(0 3 7 / 80%));
    border: 1px solid rgb(128 190 245 / 17%);
    border-radius: 1px;
    cursor: pointer;
    flex: 1 1 0;
    min-width: 11.5rem;
  }

  html[data-theme="blackhole"]:not([data-surface="mobile"]) .stream-chat-preview:hover {
    background: linear-gradient(180deg, rgb(4 13 23 / 78%), rgb(0 5 11 / 86%));
    border-color: rgb(104 187 250 / 30%);
  }

  html[data-theme="blackhole"]:not([data-surface="mobile"]) .stream-chat-preview:first-of-type {
    order: -1 !important;
  }

  html[data-theme="blackhole"]:not([data-surface="mobile"]) .stream-chat-preview:not(:first-of-type) {
    order: 1 !important;
  }

  html[data-theme="blackhole"]:not([data-surface="mobile"]) .stream-chat-columns[data-multi-stream] .chat-scroll {
    padding-inline: clamp(1rem, 1.5vw, 1.45rem);
  }

  html[data-theme="blackhole"]:not([data-surface="mobile"]) .stream-chat-preview .chat-scroll {
    padding-inline: clamp(0.8rem, 1vw, 1rem);
  }

  html[data-theme="blackhole"]:not([data-surface="mobile"]) .msg-agent,
  html[data-theme="blackhole"]:not([data-surface="mobile"]) .msg-live {
    background: transparent;
    border-color: transparent;
    box-shadow: none;
    padding-inline: 0;
  }

  html[data-theme="blackhole"]:not([data-surface="mobile"]) .msg-user {
    background: rgb(4 14 25 / 94%);
    border: 1px solid rgb(134 195 248 / 52%);
    border-radius: 2px;
    box-shadow: inset 0 1px 0 rgb(222 242 255 / 6%);
  }

  html[data-theme="blackhole"]:not([data-surface="mobile"]) .composer {
    align-self: center;
    backdrop-filter: blur(5px) saturate(108%);
    -webkit-backdrop-filter: blur(5px) saturate(108%);
    background: rgb(0 5 11 / 84%);
    border: 1px solid rgb(101 188 255 / 32%);
    border-radius: 2px;
    margin-bottom: 0.12rem;
    padding: 0.55rem;
    width: min(54rem, calc(100% - var(--gutter-left) - var(--gutter-right)));
  }

  html[data-theme="blackhole"]:not([data-surface="mobile"]) .chat:has(.stream-chat-preview:only-of-type) .composer {
    margin-left: auto;
    margin-right: 0.18rem;
    width: calc(66.66% - 0.45rem);
  }

  html[data-theme="blackhole"]:not([data-surface="mobile"]) .chat:has(.stream-chat-preview:nth-of-type(2)):not(:has(.stream-chat-preview:nth-of-type(3))) .composer {
    margin-inline: auto;
    width: 50%;
  }

  html[data-theme="blackhole"]:not([data-surface="mobile"]) .chat:has(.stream-chat-preview:nth-of-type(3)) .composer {
    margin-inline: auto;
    width: 40%;
  }
}

html[data-background-override="true"][data-background="blackhole-photon"] {
  --hub-background-color: #000;
  --hub-background-image: var(--blackhole-photon-image, url("./blackhole-photon.jpg"));
  --hub-background-position: 50% 55%;
}

html[data-background-override="true"][data-background="blackhole-disk"] {
  --hub-background-color: #000;
  --hub-background-image: var(--blackhole-disk-image, url("./blackhole-disk.jpg"));
  --hub-background-position: 50% 50%;
}

html[data-theme="blackhole"][data-background-override="true"] body::before {
  animation-duration: 30s !important;
  background-position: center !important;
  background-repeat: no-repeat !important;
  background-size: cover !important;
  content: "" !important;
  mask-image: none !important;
  mix-blend-mode: screen !important;
}

html[data-theme="blackhole"][data-background="blackhole-photon"] body::before {
  background-image: radial-gradient(42% 22% at 49% 56%, rgb(92 184 255 / 13%), transparent 72%) !important;
}

html[data-theme="blackhole"][data-background="blackhole-disk"] body::before {
  background-image: radial-gradient(38% 34% at 86% 13%, rgb(255 181 121 / 13%), transparent 74%) !important;
}

@media (max-width: 1119px) {
  html[data-theme="blackhole"] body::after {
    background-position: 50% 50%;
  }

  html[data-theme="blackhole"] .task-rail,
  html[data-theme="blackhole"] .chat,
  html[data-theme="blackhole"] .stream-chat-preview {
    background-color: rgb(0 5 11 / 78%);
  }
}

@media (prefers-reduced-motion: reduce) {
  html[data-theme="blackhole"] body::before {
    animation: none !important;
  }
}
