:root {
  color-scheme: dark;
  --bg: #08111d;
  --panel: rgba(10, 22, 36, 0.86);
  --panel-border: rgba(106, 176, 255, 0.22);
  --panel-soft: rgba(255, 255, 255, 0.06);
  --text: #e9f4ff;
  --muted: #9cb5cf;
  --accent: #5fc9ff;
  --accent-strong: #0aa5ff;
  --warning: #ffc266;
  --good: #75f0b3;
  --danger: #ff7a7a;
  --shadow: 0 20px 50px rgba(0, 0, 0, 0.35);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  width: 100%;
  background:
    radial-gradient(circle at top, rgba(15, 96, 156, 0.35), transparent 28%),
    linear-gradient(180deg, #07101b 0%, #050b13 100%);
  color: var(--text);
  font-family: Inter, Segoe UI, Arial, sans-serif;
}

body {
  height: 100vh;
  overflow: hidden;
  overscroll-behavior: none;
}

button,
input,
select {
  font: inherit;
}

.app-shell {
  display: grid;
  grid-template-columns: 360px minmax(0, 1fr);
  height: 100vh;
  width: 100%;
  overflow: hidden;
}

.sidebar {
  overflow-y: auto;
  padding: 12px;
  display: grid;
  gap: 10px;
  background: rgba(4, 10, 18, 0.72);
  border-right: 1px solid rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(16px);
}

.panel {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 18px;
  padding: 12px;
  box-shadow: var(--shadow);
}

.hero-panel h1,
.panel h2,
.legend-card h3 {
  margin: 0 0 8px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--accent);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.14em;
}

.subtle,
.empty-state,
#feedStatus,
#timelineLabel,
.event-meta,
.stat-label {
  color: var(--muted);
}

.status-banner {
  margin-top: 14px;
  padding: 12px 14px;
  border-radius: 12px;
  background: rgba(255, 194, 102, 0.12);
  border: 1px solid rgba(255, 194, 102, 0.3);
  color: #ffe2b4;
  line-height: 1.4;
}

.status-banner.success {
  background: rgba(117, 240, 179, 0.14);
  border-color: rgba(117, 240, 179, 0.3);
  color: #bff4d7;
}

.status-banner.error {
  background: rgba(255, 122, 122, 0.14);
  border-color: rgba(255, 122, 122, 0.3);
  color: #ffc3c3;
}

.field-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.full-width {
  grid-column: 1 / -1;
}

.compact-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.inline-section-title {
  margin-top: 14px;
  margin-bottom: 10px;
  color: var(--accent);
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

label {
  display: grid;
  gap: 6px;
}

label span {
  font-size: 0.85rem;
  color: var(--muted);
}

input,
select,
button {
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  min-height: 42px;
  padding: 10px 12px;
}

.stacked-time-input {
  width: 100%;
  min-width: 0;
}

input:focus,
select:focus,
button:focus {
  outline: 2px solid rgba(95, 201, 255, 0.4);
  outline-offset: 1px;
}

button {
  cursor: pointer;
  transition: transform 120ms ease, border-color 120ms ease, background 120ms ease;
}

button:hover {
  transform: translateY(-1px);
  border-color: rgba(95, 201, 255, 0.5);
}

button.primary {
  background: linear-gradient(135deg, rgba(10, 165, 255, 0.95), rgba(95, 201, 255, 0.78));
  color: #02111b;
  font-weight: 700;
  border-color: transparent;
}

button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.compact-row {
  margin-top: 12px;
}

.preset-row button {
  flex: 1 1 80px;
  min-height: 38px;
}

.button-row button {
  flex: 1 1 150px;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.stat-card {
  padding: 12px;
  border-radius: 14px;
  background: var(--panel-soft);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.stat-value {
  font-size: 1.35rem;
  font-weight: 700;
}

.panel-header-row {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
}

.panel-header-row input {
  max-width: 180px;
}

.event-list {
  display: grid;
  gap: 8px;
  max-height: 250px;
  overflow-y: auto;
}

.compact-list {
  max-height: 250px;
}

.event-card,
.comparison-card {
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  padding: 12px;
  background: rgba(255, 255, 255, 0.04);
}

.event-card {
  cursor: pointer;
}

.event-card:hover,
.event-card.active {
  border-color: rgba(95, 201, 255, 0.48);
  background: rgba(95, 201, 255, 0.09);
}

.event-card.selected-result {
  border-color: rgba(255, 212, 102, 0.6);
  background: rgba(255, 212, 102, 0.12);
}

.event-title,
.comparison-title {
  font-weight: 700;
  line-height: 1.35;
}

.event-meta,
.comparison-metrics {
  margin-top: 6px;
  font-size: 0.9rem;
  line-height: 1.45;
}

.map-stage {
  position: relative;
  min-width: 0;
  min-height: 0;
  height: 100vh;
  overflow: hidden;
  overscroll-behavior: none;
}

#globeContainer {
  width: 100%;
  height: 100%;
  overflow: hidden;
  touch-action: none;
  overscroll-behavior: none;
}

#globeContainer canvas {
  display: block;
}

.map-overlay {
  position: absolute;
  z-index: 4;
}

.top-left {
  top: 20px;
  left: 20px;
}

.overlay-stack {
  display: grid;
  gap: 10px;
  max-width: 380px;
}

.bottom-right {
  right: 20px;
  bottom: 20px;
}

.bottom-center {
  left: 50%;
  bottom: 20px;
  transform: translateX(-50%);
  width: min(880px, calc(100% - 380px));
  pointer-events: none;
}

.legend-card,
.timeline-card {
  background: rgba(6, 14, 24, 0.78);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 16px;
  padding: 12px 14px;
  backdrop-filter: blur(10px);
  box-shadow: var(--shadow);
}

.legend-card p,
.timeline-card div {
  margin: 4px 0;
}

.compact-legend p {
  font-size: 0.86rem;
}

.ticker-card {
  max-height: 260px;
  overflow: hidden;
}

.ticker-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.ticker-updated {
  font-size: 0.74rem;
  color: var(--muted);
}

.ticker-list {
  display: grid;
  gap: 6px;
  max-height: 200px;
  overflow-y: auto;
}

.ticker-item {
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr);
  gap: 8px;
  align-items: start;
  padding: 8px 10px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.ticker-item.latest {
  border-color: rgba(255, 96, 96, 0.45);
}

.ticker-item.recent-hour {
  border-color: rgba(255, 214, 102, 0.35);
}

.ticker-item.recent-five-hours {
  border-color: rgba(103, 193, 255, 0.35);
}

.ticker-flag {
  width: 12px;
  height: 12px;
  border-radius: 2px 2px 2px 0;
  margin-top: 4px;
  position: relative;
}

.ticker-flag::after {
  content: '';
  position: absolute;
  left: 0;
  top: 10px;
  width: 2px;
  height: 10px;
  background: rgba(255, 255, 255, 0.75);
}

.ticker-flag.latest {
  background: #ff5a5a;
}

.ticker-flag.latest::before {
  content: 'O';
  position: absolute;
  inset: -2px 0 0 2px;
  color: #fff;
  font-size: 10px;
  font-weight: 700;
}

.ticker-flag.recent-hour {
  background: #ffd55a;
}

.ticker-flag.recent-five-hours {
  background: #5ac2ff;
}

.ticker-flag.stale {
  background: #8aa0b8;
  border-radius: 50%;
}

.ticker-text {
  min-width: 0;
}

.ticker-title {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ticker-meta {
  font-size: 0.78rem;
  color: var(--muted);
}

.overlay-link {
  display: inline-block;
  margin: 6px 0;
  color: var(--accent);
  text-decoration: none;
}

.overlay-link:hover {
  text-decoration: underline;
}

.hidden {
  display: none;
}

.compact-info-card {
  display: grid;
  gap: 4px;
  padding: 10px 14px;
  min-width: 320px;
}

.compact-info-title {
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.compact-info-meta {
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.35;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin-right: 6px;
}

.dot-small {
  background: #83d8ff;
}

.dot-flag-red {
  background: #ff5a5a;
}

.dot-flag-yellow {
  background: #ffd55a;
}

.dot-flag-blue {
  background: #5ac2ff;
}

.dot-depth {
  background: #ff8b5c;
}

.dot-selected {
  background: #56fff3;
}

.dot-comparison {
  background: #ffd466;
}

.selected-grid,
.comparison-grid {
  display: grid;
  gap: 10px;
}

.metric-pill-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.metric-pill {
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 0.82rem;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

@media (max-width: 1180px) {
  body {
    height: auto;
    overflow: auto;
  }

  .app-shell {
    grid-template-columns: 1fr;
    height: auto;
  }

  .sidebar {
    order: 2;
  }

  .map-stage {
    order: 1;
    min-height: 58vh;
    height: 58vh;
  }

  #globeContainer {
    height: 58vh;
  }
}

@media (max-width: 720px) {
  .sidebar {
    padding: 12px;
  }

  .field-grid,
  .compact-grid,
  .stats-grid {
    grid-template-columns: 1fr;
  }

  .panel-header-row {
    display: grid;
  }

  .panel-header-row input {
    max-width: none;
  }

  .map-overlay {
    position: static;
    margin: 12px;
  }

  .overlay-stack {
    max-width: none;
  }

  .bottom-center {
    transform: none;
    width: auto;
    pointer-events: auto;
  }
}
