﻿:root {
  color-scheme: dark;
  --bg: #0d1012;
  --panel: rgba(19, 23, 27, 0.86);
  --line: rgba(170, 184, 196, 0.22);
  --text: #eef3f5;
  --muted: #9aa7af;
  --cyan: #57d7ff;
  --gold: #f2c15f;
  --green: #79d783;
  --pink: #ff7ac8;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, Segoe UI, Arial, sans-serif;
  font-size: 14px;
}

#scene {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

.topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(13, 16, 18, 0.94), rgba(13, 16, 18, 0.62));
  backdrop-filter: blur(10px);
}

.search {
  position: fixed;
  z-index: 2;
  top: 62px;
  right: 14px;
  width: min(360px, calc(100vw - 28px));
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  backdrop-filter: blur(12px);
  padding: 10px;
}

.search:not(.show) {
  display: none;
}

.bookmarks {
  position: fixed;
  z-index: 2;
  top: 62px;
  right: 14px;
  width: min(390px, calc(100vw - 28px));
  max-height: calc(100vh - 86px);
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  backdrop-filter: blur(12px);
  padding: 10px;
}

.bookmarks:not(.show) {
  display: none;
}

.annotations {
  position: fixed;
  z-index: 5;
  top: 62px;
  right: 14px;
  width: min(420px, calc(100vw - 28px));
  max-height: calc(100vh - 86px);
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  backdrop-filter: blur(12px);
  padding: 10px;
}

.annotations:not(.show) {
  display: none;
}

.search-row {
  display: flex;
  gap: 8px;
  align-items: center;
}

.search input[type="search"] {
  flex: 1;
  min-width: 0;
  width: auto;
}

.bookmarks input,
.bookmarks textarea {
  width: 100%;
}

.bookmarks textarea {
  min-height: 68px;
  height: auto;
  resize: vertical;
  padding: 8px 9px;
  line-height: 1.35;
}

.bookmark-form {
  display: grid;
  gap: 8px;
}

.results {
  display: grid;
  gap: 6px;
  margin-top: 8px;
  max-height: 252px;
  overflow: auto;
}

.bookmark-list {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}

.annotation-list {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}

.bookmark-item,
.annotation-item {
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 8px;
  background: rgba(9, 12, 14, 0.48);
}

.bookmark-item strong,
.annotation-item strong {
  display: block;
  font-size: 13px;
  line-height: 1.3;
  overflow-wrap: anywhere;
}

.bookmark-item span,
.annotation-item span {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 11px;
  overflow-wrap: anywhere;
}

.bookmark-note {
  margin-top: 6px;
  color: var(--text);
  font-size: 12px;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.bookmark-tags {
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
  margin-top: 7px;
}

.bookmark-tag {
  border: 1px solid rgba(87, 215, 255, 0.24);
  border-radius: 999px;
  padding: 2px 7px;
  color: var(--cyan);
  background: rgba(87, 215, 255, 0.08);
  font-size: 11px;
}

.bookmark-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 8px;
}

.bookmark-actions button {
  height: 28px;
  padding: 0 8px;
  font-size: 12px;
}

.result {
  width: 100%;
  height: auto;
  min-height: 40px;
  padding: 7px 8px;
  text-align: left;
  white-space: normal;
  line-height: 1.28;
}

.result strong {
  display: block;
  overflow-wrap: anywhere;
}

.result span {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
  overflow-wrap: anywhere;
}

.detail {
  position: fixed;
  z-index: 2;
  right: 14px;
  bottom: 14px;
  width: min(380px, calc(100vw - 28px));
  max-height: calc(100vh - 370px);
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  backdrop-filter: blur(12px);
  padding: 12px;
  display: none;
}

.detail.show { display: block; }

.detail-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
}

.detail h2 {
  margin: 0;
  font-size: 15px;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.detail-sub {
  color: var(--muted);
  margin-top: 4px;
  overflow-wrap: anywhere;
}

.detail-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.detail-actions a {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--text);
  text-decoration: none;
  background: rgba(25, 31, 36, 0.92);
}

.detail-actions a:hover { border-color: var(--cyan); }

.detail-actions button.related-channel {
  color: var(--muted);
  max-width: 100%;
  overflow-wrap: anywhere;
  height: auto;
  min-height: 32px;
  text-align: left;
}

.detail-actions button.related-channel strong {
  display: block;
  color: var(--text);
  font-size: 12px;
  font-weight: 600;
}

.detail-actions button.related-channel span {
  display: block;
  margin-top: 2px;
  font-size: 11px;
}

.annotation-panel {
  margin-top: 12px;
  border-top: 1px solid var(--line);
  padding-top: 10px;
}

.annotation-panel strong {
  display: block;
  margin-bottom: 7px;
  font-size: 12px;
}

.annotation-panel textarea,
.annotation-panel input {
  width: 100%;
  height: auto;
  margin-bottom: 7px;
}

.annotation-panel textarea {
  min-height: 68px;
  resize: vertical;
  padding: 8px 9px;
  line-height: 1.35;
}

.annotation-actions {
  display: flex;
  gap: 7px;
  flex-wrap: wrap;
}

.annotation-tags {
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
  margin: 7px 0;
}

.annotation-tag {
  border: 1px solid rgba(87, 215, 255, 0.24);
  border-radius: 999px;
  padding: 2px 7px;
  color: var(--cyan);
  background: rgba(87, 215, 255, 0.08);
  font-size: 11px;
}

.annotation-item .annotation-note {
  margin-top: 6px;
  color: var(--text);
  font-size: 12px;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.annotation-browser-edit {
  display: grid;
  gap: 7px;
  margin-top: 8px;
}

.annotation-browser-edit[hidden] {
  display: none;
}

.annotation-browser-edit textarea,
.annotation-browser-edit input,
.annotations input {
  width: 100%;
}

.annotation-browser-edit textarea {
  min-height: 64px;
  height: auto;
  resize: vertical;
  padding: 8px 9px;
  line-height: 1.35;
}

.kv {
  display: grid;
  grid-template-columns: 96px minmax(0, 1fr);
  gap: 7px 10px;
  margin-top: 12px;
}

.kv span { color: var(--muted); }

.kv strong {
  font-weight: 500;
  overflow-wrap: anywhere;
}

.brand {
  display: flex;
  align-items: baseline;
  gap: 10px;
  min-width: 0;
}

.brand h1 {
  margin: 0;
  font-size: 17px;
  line-height: 1.2;
  letter-spacing: 0;
}

.brand span {
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

button, input {
  font: inherit;
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(25, 31, 36, 0.92);
  height: 34px;
}

button {
  padding: 0 11px;
  cursor: pointer;
}

button:hover {
  border-color: var(--cyan);
}

.actions button.active {
  color: var(--text);
  border-color: var(--cyan);
}

input {
  width: 96px;
  padding: 0 9px;
}

input[type="range"] {
  width: 112px;
  padding: 0;
  accent-color: var(--cyan);
}

.control {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 34px;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(25, 31, 36, 0.72);
  color: var(--muted);
  white-space: nowrap;
  font-size: 12px;
}

.control output {
  min-width: 30px;
  color: var(--text);
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.panel {
  position: fixed;
  z-index: 2;
  left: 14px;
  bottom: 14px;
  width: min(360px, calc(100vw - 28px));
  max-height: min(58vh, 620px);
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  backdrop-filter: blur(12px);
  padding: 12px;
  transition: opacity 180ms ease, transform 180ms ease;
}

.panel.hidden {
  opacity: 0;
  pointer-events: none;
  transform: translateY(14px);
}

.stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 10px;
}

.stat {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px;
  background: rgba(9, 12, 14, 0.5);
}

.stat strong {
  display: block;
  color: var(--cyan);
  font-size: 16px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stat span, .status {
  color: var(--muted);
  font-size: 12px;
}

.legend {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 12px;
}

.legend-toolbar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

.legend-toolbar button.active {
  color: var(--text);
  border-color: var(--cyan);
}

.legend.collapsed button.legend-chip:not(.active) {
  display: none;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-width: 0;
}

button.chip {
  height: auto;
  min-height: 24px;
  padding: 3px 7px;
  color: var(--muted);
  background: rgba(25, 31, 36, 0.58);
  white-space: normal;
  text-align: left;
}

button.chip.active {
  color: var(--text);
  border-color: var(--cyan);
}

.dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--cyan);
  flex: 0 0 auto;
}

.tooltip {
  position: fixed;
  z-index: 3;
  max-width: min(360px, calc(100vw - 28px));
  pointer-events: none;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(11, 14, 17, 0.94);
  backdrop-filter: blur(10px);
  padding: 10px;
  opacity: 0;
  transform: translate(12px, 12px);
  transition: opacity 120ms ease;
}

.tooltip.show { opacity: 1; }

.focus-label {
  position: fixed;
  z-index: 3;
  width: min(420px, calc(100vw - 28px));
  transform: translate(-50%, calc(-100% - 18px));
  pointer-events: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(11, 14, 17, 0.82);
  backdrop-filter: blur(10px);
  padding: 10px 12px;
  opacity: 0;
  transition: opacity 180ms ease;
  text-align: center;
}

.focus-label.show { opacity: 1; }

.focus-label strong {
  display: block;
  overflow-wrap: anywhere;
}

.focus-label span {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  overflow-wrap: anywhere;
}

.focus-actions {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-top: 9px;
}

.focus-actions a {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--text);
  text-decoration: none;
  background: rgba(25, 31, 36, 0.92);
  pointer-events: auto;
}

.focus-actions a:hover {
  border-color: var(--cyan);
}

.path-inspector {
  position: fixed;
  z-index: 7;
  min-width: 260px;
  max-width: min(380px, calc(100vw - 24px));
  max-height: calc(100vh - 96px);
  overflow: auto;
  padding: 12px;
  border: 1px solid rgba(118, 225, 255, 0.34);
  border-radius: 8px;
  background: rgba(13, 17, 20, 0.88);
  box-shadow: 0 18px 42px rgba(0, 0, 0, 0.28);
  color: #edf6fa;
  backdrop-filter: blur(12px);
  pointer-events: auto;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 120ms ease, transform 120ms ease;
}

.path-inspector.show {
  opacity: 1;
  transform: translateY(0);
}

.path-inspector h3 {
  margin: 0 0 6px;
  font-size: 13px;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.path-inspector p {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.path-inspector .mini-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.path-inspector button,
.path-inspector a {
  border: 1px solid var(--border);
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
  padding: 6px 8px;
  font: inherit;
  font-size: 12px;
  text-decoration: none;
  cursor: pointer;
}

.tooltip strong {
  display: block;
  margin-bottom: 4px;
  overflow-wrap: anywhere;
}

.tooltip div {
  color: var(--muted);
  line-height: 1.38;
  overflow-wrap: anywhere;
}

@media (max-width: 760px) {
  .topbar {
    align-items: stretch;
    flex-direction: column;
    gap: 8px;
    padding: max(8px, env(safe-area-inset-top)) 10px 9px;
  }

  .brand {
    display: block;
    width: 100%;
  }

  .brand h1 {
    font-size: 15px;
  }

  .brand span {
    display: block;
    margin-top: 3px;
    font-size: 12px;
  }

  .actions {
    width: 100%;
    flex-wrap: nowrap;
    justify-content: flex-start;
    gap: 6px;
    overflow-x: auto;
    overflow-y: hidden;
    padding-bottom: 1px;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }

  .actions::-webkit-scrollbar {
    display: none;
  }

  button,
  input,
  .control {
    height: 38px;
  }

  .actions button {
    flex: 0 0 auto;
    padding: 0 10px;
    min-width: 48px;
  }

  .control {
    flex: 0 0 auto;
    padding: 0 9px;
  }

  input[type="range"] {
    width: 82px;
  }

  .search {
    top: 96px;
    right: 10px;
    width: calc(100vw - 20px);
    max-height: calc(100vh - 112px);
    overflow: auto;
  }

  .bookmarks {
    top: 96px;
    right: 10px;
    width: calc(100vw - 20px);
    max-height: calc(100vh - 112px);
  }

  .annotations {
    top: 96px;
    right: 10px;
    width: calc(100vw - 20px);
    max-height: calc(100vh - 112px);
  }

  .detail {
    right: 10px;
    bottom: max(10px, env(safe-area-inset-bottom));
    max-height: 42vh;
    width: calc(100vw - 20px);
  }

  .panel {
    bottom: max(10px, env(safe-area-inset-bottom));
    left: 10px;
    width: calc(100vw - 20px);
    max-height: min(50vh, 430px);
    padding: 10px;
  }

  .panel.hidden {
    transform: translateY(calc(100% + 18px));
  }

  .stats {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
  }

  .stat {
    padding: 7px;
  }

  .stat strong {
    font-size: 14px;
  }

  .legend {
    gap: 6px;
  }

  button.chip {
    min-height: 30px;
    padding: 5px 8px;
  }

  .results {
    max-height: min(42vh, 360px);
  }

  .tooltip {
    display: none;
  }

  .focus-label {
    width: calc(100vw - 20px);
    transform: translate(-50%, calc(-100% - 10px));
  }

  .path-inspector {
    left: 10px !important;
    right: 10px;
    max-width: none;
    min-width: 0;
    width: calc(100vw - 20px);
    max-height: 44vh;
  }
}

@media (max-width: 760px) and (max-height: 620px) {
  .brand h1 {
    display: none;
  }

  .search,
  .bookmarks,
  .annotations {
    top: 54px;
    max-height: calc(100vh - 70px);
  }

  .panel {
    max-height: 44vh;
  }
}

@media (pointer: coarse) {
  button,
  input,
  .control {
    min-height: 38px;
  }
}

