:root {
  color-scheme: dark;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", sans-serif;
  font-synthesis: none;
  --ink: rgba(247, 249, 255, 0.9);
  --muted: rgba(231, 238, 255, 0.46);
  --hairline: rgba(213, 226, 255, 0.1);
  --panel: rgba(9, 12, 22, 0.52);
  --safe-top: max(18px, env(safe-area-inset-top));
  --safe-right: max(18px, env(safe-area-inset-right));
  --safe-bottom: max(18px, env(safe-area-inset-bottom));
  --safe-left: max(18px, env(safe-area-inset-left));
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  min-width: 280px;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: #020308;
  overscroll-behavior: none;
}

body {
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

button,
select {
  font: inherit;
}

button,
select,
canvas {
  -webkit-touch-callout: none;
}

.app-shell {
  position: relative;
  width: 100%;
  height: 100%;
  height: 100dvh;
  isolation: isolate;
  overflow: hidden;
  background:
    radial-gradient(circle at 50% 48%, rgba(20, 23, 42, 0.25), transparent 45%),
    radial-gradient(circle at 12% 0%, rgba(85, 42, 140, 0.07), transparent 35%),
    #020308;
}

.app-shell::before,
.app-shell::after {
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  content: "";
}

.app-shell::before {
  background: radial-gradient(circle at 50% 48%, transparent 40%, rgba(0, 0, 0, 0.54) 100%);
}

.app-shell::after {
  opacity: 0.12;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.018) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.014) 1px, transparent 1px);
  background-size: 36px 36px;
  mask-image: radial-gradient(circle at center, black, transparent 78%);
}

#knowledge-canvas {
  position: absolute;
  inset: 0;
  z-index: 0;
  display: block;
  width: 100%;
  height: 100%;
  cursor: grab;
  outline: none;
  touch-action: none;
}

#knowledge-canvas:active {
  cursor: grabbing;
}

#knowledge-canvas:focus-visible {
  box-shadow: inset 0 0 0 1px rgba(128, 190, 255, 0.38);
}

.brand,
.toolbar,
.readout {
  position: absolute;
  z-index: 2;
}

.brand {
  top: calc(var(--safe-top) + 4px);
  left: calc(var(--safe-left) + 4px);
  display: flex;
  align-items: flex-start;
  gap: 11px;
  pointer-events: none;
}

.brand__signal {
  width: 5px;
  height: 5px;
  margin-top: 6px;
  border-radius: 50%;
  background: #9fdcff;
  box-shadow: 0 0 8px rgba(118, 207, 255, 0.9), 0 0 18px rgba(169, 104, 255, 0.5);
  animation: signal-breathe 4.5s ease-in-out infinite;
}

.brand h1,
.brand p,
.readout p {
  margin: 0;
}

.brand h1 {
  color: var(--ink);
  font-size: 12px;
  font-weight: 580;
  line-height: 1.2;
  letter-spacing: 0.2em;
}

.brand p {
  margin-top: 6px;
  color: rgba(222, 231, 255, 0.3);
  font-size: 8px;
  font-weight: 500;
  letter-spacing: 0.17em;
}

.toolbar {
  top: var(--safe-top);
  right: var(--safe-right);
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px;
  border: 1px solid var(--hairline);
  border-radius: 12px;
  background: var(--panel);
  box-shadow: 0 14px 48px rgba(0, 0, 0, 0.28), inset 0 1px rgba(255, 255, 255, 0.025);
  backdrop-filter: blur(18px) saturate(120%);
  -webkit-backdrop-filter: blur(18px) saturate(120%);
}

.control {
  position: relative;
  display: inline-flex;
  min-width: 0;
  height: 30px;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 0 9px;
  border: 0;
  border-radius: 8px;
  color: rgba(245, 248, 255, 0.58);
  background: transparent;
  font-size: 11px;
  font-weight: 520;
  line-height: 1;
  white-space: nowrap;
  transition: color 160ms ease, background-color 160ms ease;
}

button.control {
  cursor: pointer;
}

.control:hover,
.control:focus-within,
.control:focus-visible {
  color: rgba(255, 255, 255, 0.9);
  background: rgba(255, 255, 255, 0.055);
  outline: none;
}

.control[aria-pressed="true"] {
  color: rgba(255, 255, 255, 0.84);
}

.control__dot {
  width: 5px;
  height: 5px;
  border: 1px solid currentColor;
  border-radius: 50%;
}

.control[aria-pressed="true"] .control__dot {
  border-color: #9edcff;
  background: #9edcff;
  box-shadow: 0 0 8px rgba(103, 204, 255, 0.75);
}

.control--select {
  padding: 0;
}

.control select {
  width: 100%;
  height: 100%;
  padding: 0 25px 0 9px;
  border: 0;
  border-radius: inherit;
  appearance: none;
  color: inherit;
  background: transparent;
  cursor: pointer;
  outline: none;
}

.control--select::after {
  position: absolute;
  right: 9px;
  width: 5px;
  height: 5px;
  border-right: 1px solid currentColor;
  border-bottom: 1px solid currentColor;
  content: "";
  pointer-events: none;
  transform: translateY(-2px) rotate(45deg);
}

.control--module {
  max-width: 134px;
}

.control--music-select {
  max-width: 92px;
}

.control--icon {
  width: 30px;
  padding: 0;
}

.control--icon svg {
  width: 15px;
  height: 15px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.1;
}

.control--music[aria-pressed="true"] {
  color: #a9ddff;
  background: rgba(104, 183, 255, 0.08);
  box-shadow: inset 0 0 16px rgba(109, 185, 255, 0.04);
}

.control--music[aria-pressed="true"] svg {
  filter: drop-shadow(0 0 4px rgba(120, 203, 255, 0.58));
  animation: music-breathe 4.5s ease-in-out infinite;
}

.readout {
  right: calc(var(--safe-right) + 4px);
  bottom: calc(var(--safe-bottom) + 3px);
  left: calc(var(--safe-left) + 4px);
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.02em;
  pointer-events: none;
}

.readout__hint {
  color: rgba(225, 234, 255, 0.25);
  font-size: 9px;
  letter-spacing: 0.08em;
}

.sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

@keyframes signal-breathe {
  0%,
  100% {
    opacity: 0.42;
    transform: scale(0.82);
  }
  46% {
    opacity: 1;
    transform: scale(1.12);
  }
}

@keyframes music-breathe {
  0%,
  100% {
    opacity: 0.58;
    transform: scale(0.94);
  }
  46% {
    opacity: 1;
    transform: scale(1.04);
  }
}

@media (max-width: 760px) {
  .brand {
    top: var(--safe-top);
    left: var(--safe-left);
  }

  .brand p {
    display: none;
  }

  .toolbar {
    top: auto;
    right: var(--safe-right);
    bottom: var(--safe-bottom);
    left: var(--safe-left);
    justify-content: space-between;
    overflow: hidden;
  }

  .control {
    flex: 0 1 auto;
    padding-right: 7px;
    padding-left: 7px;
  }

  .control--select {
    flex: 1 1 96px;
  }

  .control--module {
    flex-basis: 108px;
  }

  .control select {
    padding-right: 19px;
    padding-left: 7px;
  }

  .control--select::after {
    right: 7px;
  }

  #labels-button span:last-child {
    display: none;
  }

  .readout {
    right: var(--safe-right);
    bottom: calc(var(--safe-bottom) + 53px);
    left: var(--safe-left);
    font-size: 10px;
  }

  .readout__hint {
    display: none;
  }
}

@media (max-width: 390px) {
  .control--icon {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .brand__signal {
    animation: none;
    opacity: 0.75;
  }

  .control--music[aria-pressed="true"] svg {
    animation: none;
  }

  .control {
    transition: none;
  }
}

.nebula-labels { position:absolute; inset:0; pointer-events:none; overflow:hidden; }
.nebula-labels span { position:absolute; top:0; left:0; font:11px/18px -apple-system,BlinkMacSystemFont,sans-serif; letter-spacing:.2px; white-space:nowrap; padding:0 3px; border-radius:3px; background:rgba(3,5,12,.38); text-shadow:0 1px 3px #000; }
.nebula-labels span[hidden] { display:none; }

.nebula-labels[hidden] { display:none; }

.voice-panel { position:absolute; z-index:5; right:20px; top:72px; max-width:320px; color:#c4d4e8; font-size:12px; background:rgba(8,12,23,.94); border:1px solid #ffffff20; border-radius:12px; }
.voice-panel summary { padding:10px 14px; cursor:pointer; }
.voice-panel__body { padding:0 14px 12px; line-height:1.7; }
.voice-note { color:#91a0b6; font-size:11px; }
#voice-status { margin-bottom:0; color:#99dfef; }
#voice-status[data-phase="error"] { color:#ffc29b; }
@media(max-width:600px){.voice-panel{top:52px;right:12px;max-width:calc(100vw - 24px);}}
