.space-mode-switch {
  position: absolute;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 11;
  display: flex;
  gap: 3px;
  padding: 4px;
  border: 1px solid #414b58;
  border-radius: 8px;
  background: #151b24;
}
.space-mode-switch button {
  width: 56px;
  height: 38px;
  border-radius: 5px;
  color: #b9c4d1;
  background: transparent;
  font-weight: 700;
  letter-spacing: 0;
}
.space-mode-switch button[aria-pressed="true"] { background: #c4e8e7; color: #132c31; }
.space-mode-switch button:focus-visible, .space-label:focus-visible { outline: 2px solid #fff; outline-offset: 3px; }
.constellation-space {
  position: absolute;
  inset: 94px 18px 78px 205px;
  z-index: 1;
  background: #0b0f14;
  touch-action: none;
}
.constellation-space canvas { display: block; width: 100%; height: 100%; cursor: grab; touch-action: none; }
.constellation-space canvas:focus-visible { outline: 1px solid #597478; outline-offset: -2px; }
.constellation-space canvas:active { cursor: grabbing; }
.space-labels { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.space-label {
  position: absolute;
  top: 0;
  left: 0;
  max-width: 166px;
  padding: 4px 6px;
  border: 0;
  border-left: 2px solid var(--star-color);
  border-radius: 2px;
  background: #0b0f14e8;
  color: #dee5eb;
  font-size: 12px;
  line-height: 1.4;
  text-align: left;
  pointer-events: auto;
  letter-spacing: 0;
}
.space-label span { display: block; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.space-label small { display: block; color: #c6d1dd; font-size: 10px; }
.space-label:hover, .space-label.is-selected { background: #253138; color: #fff; }
.space-status {
  position: absolute;
  z-index: 13;
  bottom: 84px;
  left: 50%;
  transform: translateX(-50%);
  width: max-content;
  max-width: min(460px, calc(100% - 32px));
  padding: 12px 16px;
  background: #18232c;
  color: #f1f5fa;
  border: 1px solid #637581;
  border-radius: 6px;
  font-size: 14px;
  line-height: 1.5;
}
.space-mode { background: #0b0f14 !important; }
.space-mode .sky::before { display: none; }
.space-mode #viewport, .space-mode .mini-map, .space-mode .mobile-graph-controls { visibility: hidden !important; pointer-events: none !important; }
.space-mode .constellation-space[hidden], .space-mode-switch[hidden], .space-status[hidden], .space-label[hidden] { display: none; }
@media (min-width: 761px) {
  .space-visible.has-active-entry .constellation-space { right: min(444px, 43vw); }
  .space-visible #detailPanel { width: min(414px, 40vw); max-height: calc(100dvh - 126px); }
}
@media (min-width: 761px) and (max-width: 1200px) {
  .constellation-space { top: 146px; }
  .space-visible #detailPanel { max-height: calc(100dvh - 170px); }
}
@media (max-width: 760px) {
  .space-mode-switch { bottom: calc(76px + env(safe-area-inset-bottom)); }
  .space-mode-switch button { width: 58px; height: 40px; }
  .constellation-space { inset: 144px 0 calc(130px + env(safe-area-inset-bottom)); }
  .space-status { bottom: calc(132px + env(safe-area-inset-bottom)); }
  .space-label { min-height: 44px; display: flex; flex-direction: column; justify-content: center; }
  .space-visible .view-controls {
    display: flex;
    visibility: visible;
    pointer-events: auto;
    top: calc(80px + env(safe-area-inset-top));
    right: 12px;
    left: auto;
    bottom: auto;
    width: auto;
    transform: none;
  }
  .space-visible .view-controls #fullscreenBtn, .space-visible .view-controls #quietModeBtn { display: none; }
}

.space-visible :is(.tag-bar, .type-bar, .density-control, .link-legend) { display: none !important; }
.space-visible .constellation-space { inset: 94px 0 84px; }
.space-discovering .constellation-space { right: 380px; }
.space-visible.has-active-entry .constellation-space { right: min(444px, 43vw); }
.space-mode .space-mode-switch { left: auto; right: 22px; transform: none; }
.space-journey {
  position: absolute;
  left: 22px;
  bottom: 24px;
  z-index: 11;
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: calc(100% - 190px);
  pointer-events: none;
}
.space-journey :is(button, label) { pointer-events: auto; }
.space-journey button {
  min-height: 44px;
  padding: 0 14px;
  border: 1px solid #35434c;
  border-radius: 5px;
  background: #10171d;
  color: #e0e8ee;
  font-size: 13px;
}
.space-journey button:disabled { opacity: 0.4; cursor: default; }
.space-journey-nav, .space-display-options { display: flex; align-items: center; gap: 12px; }
.space-motion { display: flex; align-items: center; gap: 7px; color: #a9b8bf; font-size: 12px; white-space: nowrap; cursor: pointer; text-transform: none; letter-spacing: 0; }
.space-display-options .space-motion { min-height: 44px; margin: 0; font-weight: 500; }
.space-display-options .space-motion:has(input:checked) { color: #e0efee; }
.space-motion input { width: 16px; height: 16px; margin: 0; accent-color: #bbe3e3; }
.space-visible .page-actions { bottom: 86px; }
@media (min-width: 761px) {
  .space-visible #openComposeBtn { left: 282px; right: auto; bottom: 86px; }
  .space-visible #openBookComposeBtn { left: 356px; right: auto; bottom: 90px; }
}
.space-discovery {
  position: absolute;
  z-index: 10;
  top: 156px;
  right: 28px;
  bottom: 108px;
  width: 316px;
  min-width: 0;
  overflow: auto;
  overscroll-behavior: contain;
  background: #0b0f14;
  scrollbar-width: thin;
  scrollbar-color: #34454f transparent;
}
.space-discovery-kind {
  padding-top: 15px;
  border-top: 2px solid var(--discovery-color);
  color: var(--discovery-color);
  font-size: 12px;
  font-weight: 650;
}
.space-discovery h2 {
  margin: 16px 0;
  color: #f0f1ee;
  font: 400 29px/1.22 Georgia, serif;
  letter-spacing: 0;
  overflow-wrap: anywhere;
}
.space-excerpt { color: #c0c9cf; font: 16px/1.7 Georgia, serif; overflow-wrap: anywhere; }
.space-discovery-actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 20px 0 30px; }
.space-discovery-actions button {
  min-height: 44px;
  padding: 10px 20px;
  border: 1px solid #40505b;
  border-radius: 5px;
  background: transparent;
  color: #d9e5eb;
  font-size: 14px;
  font-weight: 600;
}
.space-discovery-actions #spaceReadBtn { background: #c4e8e7; border-color: #c4e8e7; color: #112c30; }
.space-discovery h3 { margin: 0 0 10px; color: #8b9fa9; font-size: 12px; font-weight: 600; letter-spacing: 0; }
.space-neighbors { display: grid; gap: 0; max-height: 250px; overflow: auto; scrollbar-width: thin; }
.space-neighbors button {
  min-height: 58px;
  padding: 10px 20px 10px 0;
  border-bottom: 1px solid #263139;
  border-radius: 0;
  background: transparent;
  color: #d9e2e7;
  text-align: left;
}
.space-neighbors button:hover { background: #142027; }
.space-neighbors span { display: block; font-size: 14px; line-height: 1.4; overflow-wrap: anywhere; }
.space-neighbors small { display: block; margin-top: 4px; font-size: 11px; color: #98acb7; overflow-wrap: anywhere; }
.space-no-neighbors { font-size: 13px; color: #98acb7; }
.space-journey button:focus-visible, .space-discovery :is(button, h2):focus-visible { outline: 2px solid #c4e8e7; outline-offset: 2px; }
.space-journey[hidden], .space-discovery[hidden] { display: none; }
@media (min-width: 761px) and (max-width: 1200px) {
  .space-visible .topbar { grid-template-columns: minmax(0, 1fr) auto; gap: 8px; }
  .space-visible .identity { grid-column: 1; grid-row: 1; width: max-content; max-width: 100%; }
  .space-visible .tools { grid-column: 2; grid-row: 1; }
  .space-visible .tools .search { width: 170px; }
  .space-visible .workspace-switcher { grid-column: 1; grid-row: 2; grid-template-columns: repeat(4, minmax(48px, 1fr)) auto; }
  .space-visible .workspace-switcher :is(button, a) { padding: 0 8px; }
  .space-visible .constellation-space { top: 146px; }
  .space-discovering .constellation-space { right: 330px; }
  .space-discovery { width: 286px; right: 20px; top: 154px; }
}
@media (max-width: 760px) {
  .space-visible { --space-preview-height: clamp(120px, calc(46dvh - 134px), 240px); }
  .space-visible.is-admin :is(#openComposeBtn, #openBookComposeBtn) { display: none; }
  .space-mode .space-mode-switch { right: 12px; }
  .space-visible .constellation-space { inset: 82px 0 calc(194px + env(safe-area-inset-bottom)); }
  .space-discovering .constellation-space { bottom: calc(210px + var(--space-preview-height) + env(safe-area-inset-bottom)); }
  .space-journey {
    left: 12px;
    right: 12px;
    bottom: calc(76px + env(safe-area-inset-bottom));
    max-width: none;
    display: grid;
    grid-template-rows: 44px 44px;
    gap: 8px;
  }
  .space-journey-nav { padding-right: 110px; gap: 6px; }
  .space-journey button { padding: 0 8px; font-size: 11px; min-width: 0; white-space: nowrap; }
  .space-display-options { justify-content: space-between; gap: 6px; }
  .space-mode .space-mode-switch { bottom: calc(124px + env(safe-area-inset-bottom)); height: 52px; padding: 3px; }
  .space-mode .space-mode-switch button { width: 44px; height: 44px; padding: 0; }
  .space-motion { gap: 4px; font-size: 11px; }
  .space-discovery {
    top: auto;
    right: 18px;
    left: 18px;
    bottom: calc(194px + env(safe-area-inset-bottom));
    width: auto;
    height: var(--space-preview-height);
  }
  .space-discovery-kind { padding-top: 8px; font-size: 11px; }
  .space-discovery h2 { margin: 8px 0; font-size: 22px; line-height: 1.2; }
  .space-excerpt { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; font-size: 14px; line-height: 1.5; }
  .space-discovery-actions { margin: 12px 0; }
  .space-discovery-actions button { min-height: 44px; padding: 8px 16px; }
  .space-neighbors { max-height: none; overflow: visible; }
  .space-neighbors button { min-height: 54px; }
  .space-visible .view-controls { top: 82px; }
}
@media (max-width: 760px) and (min-height: 521px) and (max-height: 640px) {
  .space-visible { --space-preview-height: 150px; }
  .space-discovery .space-excerpt { display: none; }
  .space-discovery h2 { font-size: 20px; margin: 6px 0; }
  .space-discovery-actions { margin: 8px 0; }
}
@media (min-width: 761px) and (max-height: 520px) {
  .space-discovery .space-excerpt { display: none; }
  .space-discovery-kind { padding-top: 8px; }
  .space-discovery h2 { font-size: 22px; margin: 8px 0; }
  .space-discovery-actions { margin: 10px 0; }
}
@media (max-width: 760px) and (max-height: 520px) {
  .space-visible .constellation-space { bottom: calc(132px + env(safe-area-inset-bottom)); }
  .space-discovering .constellation-space { right: 46%; }
  .space-discovery { top: 82px; bottom: calc(132px + env(safe-area-inset-bottom)); left: auto; right: 16px; width: 40%; height: auto; max-height: none; }
  .space-discovery h2 { font-size: 19px; }
  .space-discovery .space-excerpt { display: none; }
  .space-journey { right: 124px; bottom: calc(76px + env(safe-area-inset-bottom)); display: flex; gap: 12px; }
  .space-journey-nav { padding-right: 0; }
  .space-mode .space-mode-switch { bottom: calc(76px + env(safe-area-inset-bottom)); }
  .space-display-options { gap: 12px; }
  .space-visible .view-controls { left: 12px; right: auto; }
}
