/* Base: design tokens, reset, typography, shared controls. */

:root {
  --bg: #05070d;
  --panel: rgba(12, 18, 30, 0.72);
  --panel-solid: #0c121e;
  --panel-border: rgba(160, 190, 255, 0.16);
  --text: #e8eef9;
  --text-dim: #9aa8c0;
  --text-faint: #6b7890;
  --accent: #6cc4ff;
  --accent-2: #ffcf6c;
  --danger: #ff7a6c;
  --ok: #7ee0a1;
  --warn: #ffd166;
  --spec: #c49bff;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 8px 30px rgba(0, 0, 0, 0.45);
  --blur: blur(14px) saturate(140%);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --gutter: 16px;
  --timeline-h: 118px;
  --ease: cubic-bezier(.2, .7, .2, 1);
  --dur: 220ms;
  color-scheme: dark;
}

:root[data-contrast="high"] {
  --panel: #000;
  --panel-solid: #000;
  --panel-border: #fff;
  --text: #fff;
  --text-dim: #f0f0f0;
  --text-faint: #d0d0d0;
  --accent: #4fd1ff;
  --blur: none;
  --shadow: none;
}

:root[data-motion="reduced"] { --dur: 0ms; }
@media (prefers-reduced-motion: reduce) {
  :root:not([data-motion="full"]) { --dur: 0ms; }
}

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

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 var(--font);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}

#app { position: fixed; inset: 0; overflow: hidden; }

#view {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  outline: none;
  touch-action: none;
  cursor: grab;
}
#view:active { cursor: grabbing; }

[hidden] { display: none !important; }

button, select, input { font: inherit; color: inherit; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 36px;
  min-width: 36px;
  padding: 6px 12px;
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  cursor: pointer;
  transition: background var(--dur) var(--ease), border-color var(--dur) var(--ease);
  user-select: none;
  -webkit-user-select: none;
}
.btn:hover { background: rgba(255, 255, 255, 0.1); }
.btn:focus-visible, select:focus-visible, input:focus-visible, [tabindex]:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.btn[aria-pressed="true"], .btn.active {
  background: rgba(108, 196, 255, 0.18);
  border-color: var(--accent);
}
.btn.icon { padding: 6px; }
.btn svg { width: 18px; height: 18px; flex: none; }

.panel {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 1px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .02em;
  border: 1px solid currentColor;
  white-space: nowrap;
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.well { color: var(--ok); }
.badge.modeled { color: var(--warn); }
.badge.speculative { color: var(--spec); }
.badge.artistic { color: var(--accent-2); }

select, input[type="search"], input[type="text"] {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  min-height: 36px;
}
select option { background: var(--panel-solid); }

a { color: var(--accent); }

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

/* Loading overlay */
.loading {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: radial-gradient(ellipse at center, #0b1426 0%, var(--bg) 70%);
  z-index: 100;
  transition: opacity 600ms var(--ease);
}
.loading.done { opacity: 0; pointer-events: none; }
.loading-inner { width: min(360px, calc(100vw - 2 * var(--gutter))); text-align: center; }
.loading-title { font-size: 22px; font-weight: 600; letter-spacing: .04em; margin-bottom: 18px; }
.loading-bar { height: 4px; border-radius: 4px; background: rgba(255,255,255,.08); overflow: hidden; }
.loading-bar span { display: block; height: 100%; width: 0; background: var(--accent); transition: width 300ms var(--ease); }
.loading-text { margin-top: 10px; color: var(--text-dim); font-size: 12px; min-height: 1.4em; }

.fatal {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: var(--gutter);
  text-align: center;
  color: var(--text);
  z-index: 200;
  background: var(--bg);
}

/* Toasts */
.toasts {
  position: absolute;
  left: 50%;
  top: 14px;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 60;
  pointer-events: none;
  width: min(460px, calc(100vw - 2 * var(--gutter)));
}
.toast {
  pointer-events: auto;
  padding: 10px 14px;
  font-size: 13px;
  animation: toast-in var(--dur) var(--ease);
}
@keyframes toast-in { from { opacity: 0; transform: translateY(-6px); } }
