*,
*::before,
*::after {
  box-sizing: border-box;
}

:root {
  /* Cleared above the bottom toolbar via JS (_syncToolbarClearance). */
  --toolbar-offset: 88px;
}

html,
body {
  margin: 0;
  width: 100%;
  height: 100%;
  min-height: 100vh;
  overflow: hidden;
  background: #000;
  color: #c8c8c8;
  font-family:
    ui-monospace,
    "SF Mono",
    "Cascadia Code",
    "Segoe UI Mono",
    Menlo,
    Consolas,
    monospace;
  font-size: 12px;
  line-height: 1.45;
}

#app,
#viewer-wrap {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
}

#viewer-canvas {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  background: #000;
}

.hud {
  position: absolute;
  pointer-events: none;
  z-index: 2;
}

.hud-tl {
  top: 14px;
  left: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.brand-lockup {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 2px;
}

.brand-row {
  display: flex;
  align-items: center;
  gap: 9px;
}

.brand-mark {
  flex: 0 0 auto;
  width: 30px;
  height: 30px;
  border-radius: 7px;
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.06),
    0 6px 18px rgba(0, 0, 0, 0.45);
}

.brand-logo {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  letter-spacing: 0.04em;
  line-height: 1;
}

.brand-q {
  color: #f2f2f2;
}

.brand-name {
  color: #7a7a7a;
  font-weight: 500;
}

.brand-tag {
  margin: 0;
  padding-left: 39px;
  font-size: 8px;
  font-weight: 500;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: #444;
}

.reference-inset {
  display: inline-flex;
  flex-direction: column;
  gap: 5px;
}

.reference-caption {
  font-size: 9px;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #555;
}

#hud-minimap {
  display: block;
  border: 1px solid #252525;
  border-radius: 2px;
  background: #060606;
  box-shadow:
    inset 0 0 24px rgba(0, 0, 0, 0.65),
    0 0 0 1px rgba(255, 255, 255, 0.03);
}

.hud-tr {
  top: 14px;
  right: 16px;
  max-width: 280px;
  text-align: right;
}

.hud-bl {
  left: 16px;
  bottom: var(--toolbar-offset);
  max-width: min(400px, 42vw);
}

.hud-br {
  right: 16px;
  bottom: var(--toolbar-offset);
  max-width: min(460px, 36vw);
  text-align: right;
  color: #888;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.attribution {
  margin: 0;
  color: #6f7c8c;
  font-size: 10px;
  letter-spacing: 0.02em;
}

.hud-phase {
  margin: 0;
  color: #e8e8e8;
  letter-spacing: 0.02em;
}

.backend-badge {
  margin: 0;
  padding: 2px 7px;
  align-self: flex-start;
  border: 1px solid #2c2c2c;
  border-radius: 3px;
  background: rgba(18, 18, 18, 0.7);
  color: #b9c6d6;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.05em;
}

.legend {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 2px;
  padding: 6px 8px;
  border: 1px solid #222;
  border-radius: 4px;
  background: rgba(8, 8, 8, 0.55);
}

.legend-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.legend-label {
  width: 26px;
  color: #8a8a8a;
  font-size: 9px;
  font-style: italic;
}

.legend-bar {
  display: block;
  border-radius: 1px;
}

.legend-max {
  color: #cfcfcf;
  font-size: 9px;
  min-width: 44px;
}

.legend-scale {
  margin: 1px 0 0;
  color: #555;
  font-size: 8px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.meta-list {
  margin: 0;
}

.meta-list div {
  display: flex;
  justify-content: flex-end;
  gap: 0.65rem;
}

.meta-list dt {
  color: #666;
  font-weight: 400;
}

.meta-list dt::after {
  content: ":";
}

.meta-list dd {
  margin: 0;
  color: #ddd;
  min-width: 9rem;
}

#hud-context {
  margin: 0;
  color: #888;
}

#hud-shortcuts {
  margin: 0;
  font-size: 10px;
  color: #666;
  line-height: 1.35;
}

@media (max-width: 1180px) {
  #hud-shortcuts {
    display: none;
  }
}

#overlay {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.82);
  color: #ccc;
  font-size: 13px;
  pointer-events: none;
}

#overlay.hidden {
  display: none;
}

#overlay.error {
  color: #ff8a80;
}

.toolbar {
  left: 50%;
  bottom: 12px;
  transform: translateX(-50%);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 6px;
  max-width: min(960px, 94vw);
  padding: 6px 8px;
  border: 1px solid #222;
  border-radius: 6px;
  background: rgba(10, 10, 10, 0.88);
  backdrop-filter: blur(6px);
  pointer-events: auto;
  z-index: 4;
}

.toolbar-group {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.toolbar-sep {
  width: 1px;
  align-self: stretch;
  background: #2a2a2a;
}

.tbtn {
  padding: 4px 9px;
  border: 1px solid #2e2e2e;
  border-radius: 4px;
  background: #141414;
  color: #b6b6b6;
  font: inherit;
  font-size: 11px;
  letter-spacing: 0.02em;
  cursor: pointer;
  transition:
    background 0.12s ease,
    color 0.12s ease,
    border-color 0.12s ease;
}

.tbtn:hover {
  background: #1d1d1d;
  color: #e6e6e6;
}

.tbtn[data-active="true"] {
  background: #2a3340;
  border-color: #3f5468;
  color: #d8e6f4;
}

.tbtn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.controls-panel {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 4;
  width: min(300px, 85vw);
  height: 100%;
  padding: 1rem 1.1rem;
  background: rgba(0, 0, 0, 0.88);
  border-right: 1px solid #222;
  pointer-events: auto;
  overflow-y: auto;
}

.controls-panel[hidden] {
  display: none;
}

.controls-panel h2 {
  margin: 0 0 1rem;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #666;
}

.panel {
  margin-bottom: 1.25rem;
}

.panel h3 {
  margin: 0 0 0.45rem;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #555;
}

.panel p {
  margin: 0.2rem 0;
  color: #aaa;
}

.panel label {
  display: block;
  margin-bottom: 0.35rem;
  color: #777;
}

.panel input[type="range"] {
  width: 100%;
  accent-color: #888;
}

.panel select {
  width: 100%;
  margin-bottom: 0.5rem;
  padding: 0.35rem 0.45rem;
  background: #111;
  border: 1px solid #333;
  color: #ddd;
  font: inherit;
}

.panel .molecule-label {
  margin: 0.15rem 0 0.65rem;
  color: #ccc;
  font-size: 13px;
}

#pes-chart {
  display: block;
  width: 100%;
  margin: 0.5rem 0 0.35rem;
  border: 1px solid #222;
  border-radius: 2px;
}

.panel .readout {
  color: #e0e0e0;
}

.panel .hint {
  color: #555;
  font-size: 11px;
}

.layer-toggle {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  margin: 0.35rem 0;
  color: #aaa;
  cursor: pointer;
}

.layer-toggle input {
  accent-color: #888;
}

.layer-toggle.disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
