html, body {
  margin: 0;
  overflow: hidden;
  width: 100%;
  height: 100%;
  background-color: #000000;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
}
canvas {
  touch-action: none;
}

#loader {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #000000;
  transition: opacity 0.6s ease;
}
#loader.fade-out {
  opacity: 0;
  pointer-events: none;
}
#loader svg {
  width: 64px;
  height: 64px;
}

/* Annotation styles */
.annotation {
  background: rgba(18, 20, 28, 0.82);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 14px 14px 14px 4px;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  pointer-events: auto;
  cursor: default;
  max-width: 240px;
  min-width: 180px;
  will-change: transform;
  contain: layout style paint;
  user-select: none;
  -webkit-user-select: none;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.35), 0 2px 4px rgba(0, 0, 0, 0.2);
  text-align: left;
}
.annotation:hover {
  background: rgba(24, 26, 36, 0.88);
  border-color: rgba(255, 255, 255, 0.16);
}
.annotation-text {
  color: rgba(255, 255, 255, 0.9);
  font-family: system-ui, -apple-system, sans-serif;
  font-size: 13px;
  font-weight: 400;
  line-height: 1.5;
  letter-spacing: 0.01em;
  min-height: 20px;
  outline: none;
  border: none;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 8px;
  white-space: pre-wrap;
  word-break: break-word;
  padding: 8px 10px;
  text-align: left;
  transition: background 0.15s;
}
.annotation-text:empty::before {
  content: "Add a comment\2026";
  color: rgba(255, 255, 255, 0.3);
  font-weight: 400;
  pointer-events: none;
}
.annotation-text:focus {
  color: rgba(255, 255, 255, 0.95);
  background: rgba(255, 255, 255, 0.08);
}
.annotation-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 2px;
  padding-top: 2px;
}
.annotation-confirm,
.annotation-delete,
.annotation-flyto {
  color: rgba(255, 255, 255, 0.4);
  cursor: pointer;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.04);
  transition: color 0.15s, background 0.15s;
}
.annotation-confirm svg,
.annotation-delete svg,
.annotation-flyto svg {
  width: 16px;
  height: 16px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.annotation-confirm:hover {
  color: rgba(255, 255, 255, 0.9);
  background: rgba(255, 255, 255, 0.10);
}
.annotation-flyto:hover {
  color: rgba(255, 255, 255, 0.9);
  background: rgba(255, 255, 255, 0.10);
}
.annotation-delete:hover {
  color: rgba(255, 100, 100, 0.9);
  background: rgba(255, 100, 100, 0.10);
}
.annotation-actions [data-tooltip] {
  position: relative;
}
.annotation-actions [data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%) translateY(4px);
  background: rgba(18, 20, 28, 0.92);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 6px;
  padding: 3px 8px;
  color: rgba(255, 255, 255, 0.85);
  font-family: system-ui, sans-serif;
  font-size: 11px;
  font-weight: 500;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s ease, transform 0.15s ease;
}
.annotation-actions [data-tooltip]:hover::after {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* Compact (committed) state */
.annotation.compact {
  padding: 6px 10px;
  min-width: auto;
  max-width: 200px;
  gap: 0;
  border-radius: 10px 10px 10px 3px;
  cursor: pointer;
  flex-direction: row;
  align-items: center;
  transition: background 0.15s, border-color 0.15s, gap 0.2s;
}
.annotation.compact .annotation-text {
  font-size: 12px;
  line-height: 1.4;
  min-height: auto;
  color: rgba(255, 255, 255, 0.75);
  background: none;
  padding: 0;
  border-radius: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  min-width: 0;
}
.annotation.compact .annotation-actions {
  display: none;
}
/* Hover / touch-active: expand text, show actions below */
.annotation.compact:hover,
.annotation.compact.touch-active {
  padding: 8px 10px;
  gap: 6px;
  background: rgba(24, 26, 36, 0.92);
  border-color: rgba(255, 255, 255, 0.18);
  flex-direction: column;
  align-items: stretch;
}
.annotation.compact:hover .annotation-text,
.annotation.compact.touch-active .annotation-text {
  color: rgba(255, 255, 255, 0.95);
  white-space: pre-wrap;
  overflow: visible;
  text-overflow: clip;
}
.annotation.compact:hover .annotation-actions,
.annotation.compact.touch-active .annotation-actions {
  display: flex;
  padding-top: 0;
  flex-shrink: 0;
}
.annotation.compact:hover .annotation-confirm,
.annotation.compact:hover .annotation-delete,
.annotation.compact:hover .annotation-flyto,
.annotation.compact.touch-active .annotation-confirm,
.annotation.compact.touch-active .annotation-delete,
.annotation.compact.touch-active .annotation-flyto {
  width: 28px;
  height: 28px;
  border-radius: 6px;
}
.annotation.compact:hover .annotation-confirm svg,
.annotation.compact:hover .annotation-delete svg,
.annotation.compact:hover .annotation-flyto svg,
.annotation.compact.touch-active .annotation-confirm svg,
.annotation.compact.touch-active .annotation-delete svg,
.annotation.compact.touch-active .annotation-flyto svg {
  width: 14px;
  height: 14px;
}

/* Viewing (read-only expanded) state */
.annotation.viewing {
  cursor: default;
}
.annotation.viewing .annotation-text {
  background: none;
  padding: 2px 0;
  cursor: default;
}

/* Toolbar */
#toolbar {
  position: fixed;
  bottom: calc(40px + env(safe-area-inset-bottom, 0px));
  left: 50%;
  transform: translateX(-50%);
  z-index: 200;
  display: flex;
  gap: 4px;
  background: rgba(18, 20, 28, 0.82);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 12px;
  padding: 6px;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}
.toolbar-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border: none;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.05);
  color: rgba(255, 255, 255, 0.6);
  font-family: system-ui, sans-serif;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.08s, color 0.08s, transform 0.1s ease;
  white-space: nowrap;
  outline: none;
}
.toolbar-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  color: rgba(255, 255, 255, 0.85);
}
.toolbar-btn:active {
  transform: scale(0.9);
  background: rgba(255, 255, 255, 0.15);
}
.toolbar-btn.active {
  background: rgba(255, 255, 255, 0.12);
  color: rgba(255, 255, 255, 0.95);
}
#btn-perf.perf-low {
  color: rgba(255, 200, 60, 0.85);
}
#btn-perf.perf-low:hover {
  color: rgba(255, 200, 60, 1);
}
#btn-perf.perf-med {
  color: rgba(100, 220, 100, 0.85);
}
#btn-perf.perf-med:hover {
  color: rgba(100, 220, 100, 1);
}
#btn-perf.perf-high {
  color: rgba(180, 100, 255, 0.85);
}
#btn-perf.perf-high:hover {
  color: rgba(180, 100, 255, 1);
}
#btn-vfx.vfx-on {
  color: rgba(229, 144, 42, 0.9);
}
#btn-vfx.vfx-on:hover {
  color: rgba(229, 144, 42, 1);
}
#btn-comments.has-comments {
  color: rgba(100, 149, 237, 0.85);
}
#btn-comments.has-comments:hover {
  color: rgba(100, 149, 237, 1);
}
#btn-waypoints.has-waypoints {
  color: rgba(120, 220, 140, 0.85);
}
#btn-waypoints.has-waypoints:hover {
  color: rgba(120, 220, 140, 1);
}
.toolbar-btn {
  position: relative;
}
.toolbar-btn svg {
  width: 22px;
  height: 22px;
  flex-shrink: 0;
}
.toolbar-btn[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%) translateY(4px);
  z-index: 10;
  background: rgba(18, 20, 28, 0.92);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 6px;
  padding: 4px 10px;
  color: rgba(255, 255, 255, 0.85);
  font-family: system-ui, sans-serif;
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s ease, transform 0.15s ease;
}
.toolbar-btn[data-tooltip]:hover::after {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
.toolbar-btn.active[data-tooltip]::after {
  display: none;
}
.toolbar-panel {
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%) translateY(8px);
  margin-bottom: 12px;
  background: rgba(18, 20, 28, 0.92);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 10px;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  display: flex;
  gap: 2px;
  padding: 4px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s ease;
}
.toolbar-panel.open {
  opacity: 1;
  pointer-events: auto;
  transform: translateX(-50%) translateY(0);
}
.toolbar-panel-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.05);
  color: rgba(255, 255, 255, 0.6);
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.08s, color 0.08s, transform 0.1s ease;
}
.toolbar-panel-btn:hover {
  background: rgba(255, 255, 255, 0.12);
  color: rgba(255, 255, 255, 0.95);
}
.toolbar-panel-btn:active {
  transform: scale(0.9);
  background: rgba(255, 255, 255, 0.15);
}
.toolbar-panel-btn:focus {
  outline: none;
}
.toolbar-panel-btn:disabled {
  opacity: 0.25;
  cursor: default;
  pointer-events: none;
}
.toolbar-panel-btn svg {
  width: 18px;
  height: 18px;
}
.toolbar-panel-btn {
  position: relative;
}
.toolbar-panel-btn[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%) translateY(4px);
  z-index: 10;
  background: rgba(18, 20, 28, 0.92);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 6px;
  padding: 3px 8px;
  color: rgba(255, 255, 255, 0.85);
  font-family: system-ui, sans-serif;
  font-size: 11px;
  font-weight: 500;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s ease, transform 0.15s ease;
}
.toolbar-panel-btn[data-tooltip]:hover::after {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
.toolbar-btn-wrap {
  position: relative;
}

/* Sidebar */
#sidebar {
  position: fixed;
  top: 50%;
  right: 16px;
  transform: translateY(-50%) translateX(8px);
  z-index: 200;
  width: 52px;
  max-height: min(480px, calc(100vh - 160px));
  background: rgba(18, 20, 28, 0.82);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 14px;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 4px 0;
  display: none;
  user-select: none;
  -webkit-user-select: none;
}
#sidebar.open {
  display: flex;
  opacity: 0;
  transform: translateY(-50%) translateX(8px);
  pointer-events: auto;
  animation: sidebar-in 0.18s ease forwards;
}
@keyframes sidebar-in {
  to { opacity: 1; transform: translateY(-50%) translateX(0); }
}
body.scene-loading #sidebar { display: none !important; }

.sidebar-scroll-arrow {
  width: 36px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: rgba(255, 255, 255, 0.12);
  cursor: default;
  flex-shrink: 0;
  border: none;
  background: none;
  padding: 0;
  transition: color 0.12s;
  pointer-events: none;
}
.sidebar-scroll-arrow.visible {
  color: rgba(255, 255, 255, 0.3);
  cursor: pointer;
  pointer-events: auto;
}
.sidebar-scroll-arrow.visible:hover {
  color: rgba(255, 255, 255, 0.7);
}
.sidebar-scroll-arrow svg {
  width: 14px;
  height: 14px;
}

#sidebar-content {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
  padding: 2px 0;
  scrollbar-width: none;
}
#sidebar-content::-webkit-scrollbar { width: 0; display: none; }

.sidebar-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
  width: 100%;
}
.sidebar-section + .sidebar-section {
  padding-top: 0;
  margin-top: 0;
}

.sidebar-section .sidebar-items {
  display: none;
}
.sidebar-section.active .sidebar-items {
  display: flex;
}

.sidebar-items {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  width: 100%;
  padding: 4px 0;
}

.sidebar-item-btn {
  position: relative;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.04);
  color: rgba(255, 255, 255, 0.6);
  font-family: system-ui, sans-serif;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
  padding: 0;
  overflow: visible;
  outline: none;
}
.sidebar-item-btn:hover {
  background: rgba(255, 255, 255, 0.10);
  border-color: rgba(255, 255, 255, 0.18);
  color: rgba(255, 255, 255, 0.95);
}
.sidebar-section.views .sidebar-item-btn { border-color: rgba(120, 220, 140, 0.15); }
.sidebar-section.views .sidebar-item-btn:hover { border-color: rgba(120, 220, 140, 0.4); color: rgba(120, 220, 140, 0.95); }
.sidebar-section.flames .sidebar-item-btn { border-color: rgba(229, 144, 42, 0.15); }
.sidebar-section.flames .sidebar-item-btn:hover { border-color: rgba(229, 144, 42, 0.4); color: rgba(229, 144, 42, 0.95); }
.sidebar-section.comments .sidebar-item-btn { border-color: rgba(100, 149, 237, 0.15); }
.sidebar-section.comments .sidebar-item-btn:hover { border-color: rgba(100, 149, 237, 0.4); color: rgba(100, 149, 237, 0.95); }

.sidebar-item-btn .item-label {
  pointer-events: none;
}
.sidebar-item-btn .item-delete {
  position: absolute;
  top: -4px;
  left: -1px;
  width: 16px;
  height: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(30, 32, 40, 0.95);
  color: rgba(255, 255, 255, 0.5);
  font-size: 9px;
  font-weight: 700;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.12s, visibility 0s, background 0.15s, color 0.15s;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  line-height: 1;
}
.sidebar-item-btn:hover .item-delete,
.sidebar-item-btn.touch-active .item-delete {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transition-delay: 0.5s;
}
.sidebar-item-btn .item-delete:hover {
  background: rgba(220, 60, 60, 0.9);
  color: rgba(255, 255, 255, 0.95);
  transition-delay: 0s;
}

.sidebar-item-btn[data-tooltip] {
  position: relative;
}
.sidebar-item-btn[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  right: calc(100% + 8px);
  top: 50%;
  transform: translateY(-50%) translateX(4px);
  background: rgba(18, 20, 28, 0.92);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 6px;
  padding: 3px 8px;
  color: rgba(255, 255, 255, 0.85);
  font-family: system-ui, sans-serif;
  font-size: 11px;
  font-weight: 500;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s ease, transform 0.15s ease;
}
.sidebar-item-btn[data-tooltip]:hover::after {
  opacity: 1;
  transform: translateY(-50%) translateX(0);
}

@media (max-width: 480px) {
  #sidebar {
    right: 8px;
    width: 48px;
    max-height: min(400px, calc(100vh - 140px));
  }
  .sidebar-item-btn {
    width: 32px;
    height: 32px;
    font-size: 10px;
  }
}

/* Hide UI until scene is ready (except reload btn) */
body.scene-loading #toolbar,
body.scene-loading #bl-controls,
body.scene-loading #keyboard-hints,
body.scene-loading #data-hud,
body.scene-loading #debug-hud,
body.scene-loading #sidebar {
  display: none !important;
}

#reload-btn {
  position: fixed;
  top: 12px;
  right: 12px;
  z-index: 200;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.15);
  background: rgba(18, 20, 28, 0.82);
  color: rgba(255, 255, 255, 0.7);
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  padding: 0;
  display: none;
}
#reload-btn.visible {
  display: flex;
}
#reload-btn:hover {
  background: rgba(28, 30, 40, 0.88);
  color: rgba(255, 255, 255, 0.95);
}

/* Bottom-left controls */
#bl-controls {
  position: fixed;
  bottom: calc(24px + env(safe-area-inset-bottom, 0px));
  left: 16px;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-items: center;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  user-select: none;
  -webkit-user-select: none;
}
#zoom-group {
  display: flex;
  flex-direction: column;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 24px;
  background: rgba(18, 20, 28, 0.82);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  overflow: hidden;
}
.zoom-btn {
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  color: rgba(255, 255, 255, 0.6);
  font-size: 20px;
  cursor: pointer;
  transition: background 0.08s, color 0.08s;
  -webkit-user-select: none;
  user-select: none;
}
.zoom-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  color: rgba(255, 255, 255, 0.95);
}
.zoom-btn:active {
  background: rgba(255, 255, 255, 0.18);
  color: rgba(255, 255, 255, 1);
}
.zoom-divider {
  height: 1px;
  background: rgba(255, 255, 255, 0.12);
}
#info-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.15);
  background: rgba(18, 20, 28, 0.82);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  color: rgba(255, 255, 255, 0.5);
  font-family: Georgia, serif;
  font-size: 16px;
  font-style: italic;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.08s, color 0.08s, transform 0.1s ease;
}
#info-btn:hover {
  background: rgba(28, 30, 40, 0.88);
  color: rgba(255, 255, 255, 0.85);
}
#info-btn:active {
  transform: scale(0.88);
  background: rgba(255, 255, 255, 0.15);
}

/* Top-left data HUD */
#data-hud {
  position: fixed;
  top: 16px;
  left: 16px;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-family: ui-monospace, 'SF Mono', 'Cascadia Code', 'Segoe UI Mono', monospace;
  font-size: 10px;
  font-weight: 500;
  line-height: 1.6;
  letter-spacing: 0.02em;
  pointer-events: none;
  user-select: none;
  -webkit-user-select: none;
  color: rgba(255, 255, 255, 0.85);
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.6);
}
#data-hud span {
  white-space: nowrap;
}
#debug-hud {
  position: fixed;
  top: 16px;
  left: 16px;
  z-index: 199;
  font: 10px/1.5 ui-monospace, 'SF Mono', 'Cascadia Code', 'Segoe UI Mono', monospace;
  color: rgba(255, 255, 255, 0.7);
  background: rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  padding: 8px 10px;
  border-radius: 6px;
  pointer-events: none;
  white-space: pre;
  min-width: 200px;
  display: none;
  user-select: none;
  -webkit-user-select: none;
}

/* Keyboard hints widget */
#keyboard-hints {
  position: fixed;
  bottom: calc(24px + env(safe-area-inset-bottom, 0px));
  right: 16px;
  z-index: 200;
  display: flex;
  align-items: center;
  pointer-events: auto;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
  animation: hints-slide-in 0.25s ease forwards;
}
@keyframes hints-slide-in {
  from { opacity: 0; transform: translateX(10px); }
  to { opacity: 1; transform: translateX(0); }
}
.hints-icon {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(18, 20, 28, 0.82);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  color: rgba(255, 255, 255, 0.5);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.08s, color 0.08s;
  flex-shrink: 0;
}
.hints-icon:hover {
  background: rgba(28, 30, 40, 0.88);
  color: rgba(255, 255, 255, 0.85);
}
.hints-content {
  display: flex;
  align-items: center;
  gap: 10px;
  white-space: nowrap;
  font-size: 12px;
  font-family: system-ui, -apple-system, sans-serif;
  background: rgba(18, 20, 28, 0.82);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 12px;
  padding: 8px 12px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
  margin-right: 10px;
  opacity: 0;
  transform: translateX(8px);
  pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s ease;
}
#keyboard-hints.expanded .hints-content {
  opacity: 1;
  transform: translateX(0);
  pointer-events: auto;
}
/* Mobile: center above toolbar, no icon button */
@media (hover: none) and (pointer: coarse) {
  #toolbar {
    bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  }
  #filter-panel {
    bottom: calc(16px + env(safe-area-inset-bottom, 0px) + 56px);
  }
  #bl-controls {
    bottom: calc(100px + env(safe-area-inset-bottom, 0px));
    flex-direction: column-reverse;
  }
  #keyboard-hints {
    bottom: auto;
    top: 16px;
    right: 16px;
    left: auto;
    transform: none;
    animation: none;
  }
  .hints-icon { display: none; }
  .hints-content {
    margin-right: 0;
    opacity: 0;
    transform: translateY(4px);
    pointer-events: none;
    transition: opacity 0.18s ease, transform 0.18s ease;
  }
  #keyboard-hints.expanded .hints-content {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
  }
}
.hints-item {
  display: flex;
  align-items: center;
  gap: 4px;
}
.hints-key {
  background: rgba(255, 255, 255, 0.12);
  border-radius: 4px;
  padding: 2px 6px;
  font-size: 11px;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.72);
  line-height: 1.4;
}
.hints-label {
  color: rgba(255, 255, 255, 0.5);
  font-size: 11px;
}

/* Filter panel */
#filter-panel {
  position: fixed;
  bottom: calc(40px + env(safe-area-inset-bottom, 0px) + 56px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 199;
  background: rgba(18, 20, 28, 0.92);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 12px;
  padding: 8px;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  display: none;
  flex-direction: column;
  gap: 4px;
  min-width: 180px;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
}
#filter-panel.open {
  display: flex;
}
#btn-filter.has-filter {
  color: rgba(180, 140, 255, 0.9);
}
#btn-filter.has-filter:hover {
  color: rgba(180, 140, 255, 1);
}
.filter-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.04);
  color: rgba(255, 255, 255, 0.6);
  font-family: system-ui, sans-serif;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  width: 100%;
  text-align: left;
  transition: background 0.08s, color 0.08s;
}
.filter-row:hover {
  background: rgba(255, 255, 255, 0.08);
  color: rgba(255, 255, 255, 0.85);
}
.filter-row.active-filter {
  color: rgba(180, 140, 255, 0.95);
  background: rgba(180, 140, 255, 0.1);
}
#filter-depth-controls {
  display: none;
  flex-direction: column;
  gap: 6px;
  padding: 6px 10px 8px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}
#filter-depth-controls.visible {
  display: flex;
}
#filter-depth-controls label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  color: rgba(255, 255, 255, 0.5);
  font-family: system-ui, sans-serif;
  font-size: 11px;
  font-weight: 500;
}
#filter-depth-controls input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100px;
  height: 4px;
  background: rgba(255, 255, 255, 0.12);
  border-radius: 2px;
  outline: none;
}
#filter-depth-controls input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: rgba(180, 140, 255, 0.9);
  cursor: pointer;
}
#filter-depth-controls input[type="range"]::-moz-range-thumb {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: rgba(180, 140, 255, 0.9);
  cursor: pointer;
  border: none;
}
#filter-depth-controls input[type="checkbox"] {
  accent-color: rgba(180, 140, 255, 0.9);
}

/* Respect reduced-motion preference */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    transition-duration: 0s !important;
    animation-duration: 0s !important;
  }
}
