:root {
  color-scheme: light;
  --bg-a: #0f1b2c;
  --bg-b: #17384e;
  --bg-c: #f3e9d2;
  --panel: rgba(255, 255, 255, 0.92);
  --border: rgba(19, 36, 48, 0.18);
  --text: #182430;
  --muted: #4f5f6c;
  --accent: #c53f3f;
  --accent-2: #267474;
  --danger: #91152a;
  --shadow: 0 10px 30px rgba(7, 24, 36, 0.22);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: 'Space Grotesk', 'IBM Plex Sans', 'Segoe UI', sans-serif;
  color: var(--text);
  background: #0f1b2c;
  min-height: 100vh;
  overflow: hidden;
}

.bg-layer {
  position: fixed;
  inset: 0;
  background:
    radial-gradient(1200px 700px at 12% 12%, rgba(233, 123, 79, 0.36), transparent 55%),
    radial-gradient(900px 560px at 88% 80%, rgba(109, 173, 174, 0.34), transparent 50%),
    linear-gradient(145deg, var(--bg-a), var(--bg-b) 42%, #102438 75%, #0e1a2a);
  z-index: 0;
}

.layout {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: 360px minmax(500px, 1fr) 390px;
  gap: 12px;
  min-height: 100vh;
  padding: 12px;
}

.panel {
  background: var(--panel);
  backdrop-filter: blur(4px);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 14px;
  overflow: hidden;
}

.kicker {
  margin: 0;
  font-size: 0.77rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: #8a2e2e;
  font-weight: 700;
}

h1 {
  margin: 6px 0 8px;
  font-size: 2rem;
  line-height: 1;
  letter-spacing: -0.02em;
}

h2 {
  margin: 0;
  font-size: 1.1rem;
}

.muted {
  margin: 0;
  color: var(--muted);
}

.left-panel {
  overflow-y: auto;
}

.stack {
  margin-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.controls-block {
  border-top: 1px solid rgba(0, 0, 0, 0.08);
  padding-top: 10px;
}

.row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.row.gap-sm {
  grid-template-columns: 1fr auto;
}

label {
  font-weight: 700;
  font-size: 0.95rem;
}

input,
textarea,
button {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px;
  font: inherit;
  color: inherit;
}

input,
textarea {
  background: rgba(255, 255, 255, 0.85);
}

textarea {
  resize: vertical;
}

button {
  cursor: pointer;
  transition: transform 120ms ease, filter 120ms ease;
}

button:hover {
  filter: brightness(0.98);
}

button:active {
  transform: translateY(1px);
}

button.primary {
  border: 0;
  color: #fff;
  background: linear-gradient(115deg, #8f2626, var(--accent));
}

button.secondary {
  background: rgba(255, 255, 255, 0.72);
}

button.danger {
  color: #fff;
  border: 0;
  background: linear-gradient(120deg, #6a0c1b, var(--danger));
}

button.short {
  width: 98px;
}

.speed-btn.active {
  border-color: rgba(143, 38, 38, 0.55);
  background: rgba(197, 63, 63, 0.15);
}

.list-box {
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.75);
  min-height: 72px;
  max-height: 190px;
  overflow: auto;
}

.list-item {
  padding: 8px 10px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.06);
  cursor: pointer;
}

.list-item:last-child {
  border-bottom: 0;
}

.list-item:hover {
  background: rgba(197, 63, 63, 0.08);
}

.list-item.active {
  background: rgba(197, 63, 63, 0.16);
}

.list-item p {
  margin: 3px 0;
}

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

.map-panel {
  padding: 0;
  position: relative;
}

#map {
  width: 100%;
  height: calc(100vh - 24px);
}

.map-overlay {
  position: absolute;
  top: 10px;
  left: 10px;
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(5, minmax(70px, 1fr));
  z-index: 800;
  pointer-events: none;
}

.metric {
  background: rgba(255, 255, 255, 0.85);
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: 9px;
  padding: 6px 8px;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.metric span {
  font-size: 0.74rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.metric strong {
  font-size: 1rem;
}

.right-panel {
  display: flex;
  flex-direction: column;
}

.timeline {
  margin-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow-y: auto;
  max-height: calc(100vh - 110px);
}

.scene-card {
  border: 1px solid rgba(0, 0, 0, 0.1);
  border-radius: 12px;
  padding: 10px;
  background: linear-gradient(160deg, rgba(255, 255, 255, 0.94), rgba(241, 247, 249, 0.94));
  animation: cardIn 280ms ease;
}

.scene-card h3 {
  margin: 0 0 6px;
  font-size: 1rem;
}

.scene-card p {
  margin: 6px 0;
  line-height: 1.3;
}

.scene-impact {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
}

.pill {
  border-radius: 999px;
  padding: 3px 8px;
  font-size: 0.75rem;
  background: rgba(38, 116, 116, 0.14);
  border: 1px solid rgba(38, 116, 116, 0.25);
}

.flash-pulse {
  animation: flashPulse 700ms ease;
}

.error {
  color: var(--danger);
}

@keyframes cardIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes flashPulse {
  0% {
    filter: saturate(1);
  }
  50% {
    filter: saturate(1.9);
  }
  100% {
    filter: saturate(1);
  }
}

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

  .layout {
    grid-template-columns: 1fr;
    grid-template-rows: auto 60vh auto;
  }

  #map {
    height: 60vh;
  }

  .map-overlay {
    grid-template-columns: repeat(3, minmax(70px, 1fr));
  }

  .timeline {
    max-height: none;
  }
}
