:root {
  --bg: #050b10;
  --panel: rgba(9, 16, 22, 0.82);
  --panel-border: rgba(120, 160, 150, 0.18);
  --text: #dce8e2;
  --text-dim: #8fa39b;
  --accent: #c6ddcd;
  --cyan: #7fe8ff;
  --quake: #ffb347;
  --fire: #ff7a2f;
  --volcano: #ff5a3c;
  --danger: #ff6b6b;
  --ok: #7fd6a2;
  --stale: #e8c46a;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: "Inter", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  overflow: hidden;
}

#globe-app {
  position: fixed;
  inset: 0;
}

#globe {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  cursor: grab;
}

#globe:active {
  cursor: grabbing;
}

.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  background: var(--bg);
  z-index: 40;
  transition: opacity 0.4s ease;
}

.overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

.spinner {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 2px solid rgba(198, 221, 205, 0.2);
  border-top-color: var(--accent);
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

#topbar {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 56px;
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 0 20px;
  z-index: 20;
  pointer-events: none;
}

#topbar > * {
  pointer-events: auto;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-size: 13px;
  color: var(--accent);
}

.brand-mark {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, #bfe8ff, #2b6f8f 60%, #0a2531);
  box-shadow: 0 0 12px rgba(127, 232, 255, 0.5);
}

.mode-switch {
  display: flex;
  border: 1px solid var(--panel-border);
  border-radius: 999px;
  overflow: hidden;
  background: var(--panel);
}

.mode-switch button {
  border: 0;
  background: transparent;
  color: var(--text-dim);
  padding: 6px 16px;
  font: inherit;
  font-size: 13px;
  cursor: pointer;
  transition: color 0.2s, background 0.2s;
}

.mode-switch button.active {
  color: #06110f;
  background: var(--accent);
}

.clock {
  font-variant-numeric: tabular-nums;
  color: var(--text-dim);
  font-size: 13px;
}

.fps {
  margin-left: auto;
  font-size: 11px;
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
}

.data-progress {
  margin-left: 12px;
  font-size: 11px;
  color: var(--accent);
  border: 1px solid var(--panel-border);
  border-radius: 999px;
  padding: 4px 10px;
  background: rgba(198, 221, 205, 0.06);
  white-space: nowrap;
}

.data-progress.hidden {
  display: none;
}

.panel {
  position: absolute;
  top: 72px;
  bottom: 74px;
  width: 268px;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 14px;
  backdrop-filter: blur(10px);
  z-index: 20;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.left-panel {
  left: 20px;
}

.right-panel {
  right: 20px;
  width: 312px;
  /* Miejsce na kontrolki kamery, które lądują pod panelem, a nie na nim. */
  bottom: 122px;
}

.panel.hidden {
  display: none;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px 10px;
  border-bottom: 1px solid var(--panel-border);
}

.panel-head h2 {
  margin: 0;
  font-size: 14px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-dim);
  font-weight: 600;
}

.panel-body {
  padding: 12px 16px 16px;
  overflow-y: auto;
  flex: 1;
  scrollbar-width: thin;
}

.icon-button {
  border: 1px solid var(--panel-border);
  background: rgba(255, 255, 255, 0.02);
  color: var(--text);
  width: 28px;
  height: 28px;
  border-radius: 8px;
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
}

.icon-button:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.layer-list {
  list-style: none;
  margin: 0 0 16px;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.layer-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 8px;
  border-radius: 8px;
  cursor: pointer;
  user-select: none;
}

.layer-item:hover {
  background: rgba(198, 221, 205, 0.06);
}

.layer-item input {
  accent-color: var(--accent);
}

.layer-name {
  flex: 1;
}

.layer-note {
  display: block;
  color: var(--text-dim);
  font-size: 11px;
  margin-top: 2px;
}

.layer-count {
  color: var(--text-dim);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.layer-name-link,
.layer-count-link {
  cursor: pointer;
}

.layer-name-link:hover,
.layer-count-link:hover {
  color: var(--accent);
}

.layer-count-link {
  border: none;
  background: transparent;
  padding: 0;
  font-family: inherit;
}

.list-row {
  display: block;
  width: 100%;
  text-align: left;
  background: transparent;
  border: 1px solid var(--panel-border);
  border-radius: 10px;
  padding: 8px 10px;
  margin-bottom: 6px;
  color: var(--text);
  font: inherit;
  cursor: pointer;
}

.list-row:hover {
  border-color: var(--accent);
  background: rgba(198, 221, 205, 0.05);
}

.list-row-title {
  display: block;
  font-size: 13px;
  color: var(--text);
}

.list-row-meta {
  display: block;
  margin-top: 2px;
  font-size: 11px;
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
}

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

.filters h3 {
  margin: 0 0 10px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-dim);
}

.filter-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
  color: var(--text-dim);
  font-size: 13px;
}

.filter-value {
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}

input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
  margin: 0 0 10px;
}

input[type="search"],
select {
  width: 100%;
  background: rgba(4, 10, 14, 0.8);
  border: 1px solid var(--panel-border);
  color: var(--text);
  border-radius: 8px;
  padding: 8px 10px;
  font: inherit;
  font-size: 13px;
}

input[type="search"]:focus,
select:focus {
  outline: none;
  border-color: var(--accent);
}

.list-search {
  padding: 10px 16px 0;
}

.list-search input[type="search"] {
  width: 100%;
}

.text-button {
  background: transparent;
  border: 1px solid var(--panel-border);
  color: var(--accent);
  border-radius: 8px;
  padding: 7px 12px;
  font: inherit;
  font-size: 12px;
  cursor: pointer;
}

.text-button:hover {
  border-color: var(--accent);
  background: rgba(198, 221, 205, 0.08);
}

#reset {
  width: 100%;
  margin-top: 14px;
}

.details-body {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.detail-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.35;
}

.detail-badge {
  align-self: flex-start;
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  border: 1px solid var(--panel-border);
  border-radius: 999px;
  padding: 3px 9px;
  color: var(--accent);
}

.detail-grid {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 6px 12px;
  font-size: 13px;
}

.detail-grid dt {
  color: var(--text-dim);
  margin: 0;
}

.detail-grid dd {
  margin: 0;
  text-align: right;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.detail-link {
  color: var(--cyan);
  font-size: 12px;
  word-break: break-all;
}

.panel-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid var(--panel-border);
}

.panel-actions:empty {
  display: none;
}

.panel-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 10px 16px 0;
}

.cosmos-tab {
  border: 1px solid var(--panel-border);
  background: transparent;
  color: var(--text-dim);
  border-radius: 999px;
  padding: 5px 10px;
  font: inherit;
  font-size: 11px;
  cursor: pointer;
}

.cosmos-tab.active {
  color: var(--accent);
  border-color: var(--accent);
  background: rgba(198, 221, 205, 0.08);
}

.cosmos-card {
  border: 1px solid var(--panel-border);
  border-radius: 10px;
  padding: 10px 12px;
  margin-bottom: 8px;
  background: rgba(255, 255, 255, 0.015);
}

.cosmos-card h3 {
  margin: 0 0 4px;
  font-size: 13px;
  color: var(--text);
}

.cosmos-meta {
  margin: 0;
  font-size: 11px;
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
}

.cosmos-note {
  margin: 6px 0 0;
  font-size: 11px;
  color: var(--text-dim);
}

.cosmos-flag {
  display: inline-block;
  margin-bottom: 4px;
  font-size: 10px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: #ff9a6b;
  border: 1px solid rgba(255, 154, 107, 0.4);
  border-radius: 999px;
  padding: 2px 7px;
}

.cosmos-empty {
  color: var(--text-dim);
  font-size: 12px;
}

#bottombar {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 54px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 18px;
  padding: 0 20px;
  z-index: 20;
  background: linear-gradient(to top, rgba(5, 11, 16, 0.9), transparent);
  pointer-events: none;
}

#bottombar > * {
  pointer-events: auto;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex: none;
  background: var(--text-dim);
}

.status-dot.available {
  background: var(--ok);
}

.status-dot.stale {
  background: var(--stale);
}

.status-dot.missing,
.status-dot.error {
  background: var(--danger);
}

.status-summary {
  margin-left: 12px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font: inherit;
  font-size: 11px;
  color: var(--text-dim);
  border: 1px solid var(--panel-border);
  border-radius: 999px;
  padding: 4px 10px;
  background: rgba(255, 255, 255, 0.02);
  cursor: pointer;
  white-space: nowrap;
}

.status-summary:hover {
  border-color: var(--accent);
}

.status-summary-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-dim);
}

.status-summary-dot.ok {
  background: var(--ok);
}

.status-summary-dot.mixed {
  background: var(--stale);
}

.status-summary-dot.bad {
  background: var(--danger);
}

.status-summary-dot.pending {
  background: var(--text-dim);
}

.status-limit {
  font-size: 12px;
  color: var(--text);
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  padding: 8px 10px;
  margin-bottom: 10px;
  font-variant-numeric: tabular-nums;
}

.status-row {
  border-top: 1px solid var(--panel-border);
  padding: 10px 0;
}

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

.status-row-label {
  font-size: 13px;
  color: var(--text);
}

.status-row-detail {
  font-size: 11px;
  color: var(--text-dim);
  margin-top: 3px;
}

.status-row-code {
  display: inline-block;
  margin-top: 4px;
  font-size: 10px;
  color: var(--stale);
  background: rgba(232, 196, 106, 0.08);
  border-radius: 6px;
  padding: 2px 6px;
}

.status-row-note {
  margin: 4px 0 0;
  font-size: 11px;
  color: var(--text-dim);
}

.camera-controls {
  position: absolute;
  right: 20px;
  bottom: 74px;
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
  align-items: center;
  max-width: 312px;
  z-index: 20;
}

.camera-controls .icon-button {
  width: 34px;
  height: 34px;
  font-size: 18px;
  background: var(--panel);
}

.modal {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(2, 6, 9, 0.7);
  z-index: 30;
}

.modal.hidden {
  display: none;
}

.modal-card {
  width: min(520px, 90vw);
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 14px;
  padding: 18px 20px 22px;
}

.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.modal-head h2 {
  margin: 0;
  font-size: 15px;
  color: var(--text);
}

.sources-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
  font-size: 13px;
  color: var(--text-dim);
}

.sources-list a {
  color: var(--cyan);
  text-decoration: none;
}

.sources-list a:hover {
  text-decoration: underline;
}

.toast {
  position: absolute;
  top: 66px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(60, 16, 16, 0.92);
  border: 1px solid rgba(255, 107, 107, 0.4);
  color: #ffd9d9;
  padding: 10px 16px;
  border-radius: 10px;
  font-size: 13px;
  z-index: 35;
  max-width: 480px;
  text-align: center;
}

.toast.hidden {
  display: none;
}

@media (max-width: 820px) {
  .panel {
    width: 220px;
  }

  .right-panel {
    width: 250px;
  }
}
