:root {
  --bg: #fafafa;
  --fg: #1a1a1a;
  --muted: #666;
  --grid: #e5e5e5;
  --accent: #1a1a1a;
  --panel: #fff;
  --border: #e0e0e0;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
}

header {
  padding: 0.75rem 1.25rem;
  border-bottom: 1px solid var(--border);
  background: var(--panel);
}

header h1 {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 600;
}

main {
  display: grid;
  grid-template-columns: 1fr 1fr 220px;
  gap: 1rem;
  padding: 1rem;
  height: calc(100vh - 50px);
}

.video-pane,
.stage-pane,
.formations-pane {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.75rem;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.video-stage {
  flex: 1;
  min-height: 0;
  background: #000;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.video-stage {
  position: relative;
  flex: 1;
  min-height: 0;
}

.video-stage video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #000;
  display: none;
}

.video-stage video.active { display: block; }

.tab-bar {
  display: flex;
  gap: 0.25rem;
  margin-bottom: 0.5rem;
}

.tab-bar button {
  padding: 0.4rem 0.9rem;
  border: 1px solid var(--border);
  background: var(--panel);
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.85rem;
  color: var(--fg);
}

.tab-bar button:hover { background: #f0f0f0; }

.tab-bar button.active {
  background: #1a1a1a;
  color: #fff;
  border-color: #1a1a1a;
}

@media (max-width: 768px) {
  main {
    grid-template-columns: 1fr;
    height: auto;
    min-height: calc(100vh - 50px);
    gap: 0.75rem;
    padding: 0.75rem;
  }

  .video-pane,
  .stage-pane,
  .formations-pane {
    min-height: auto;
  }

  .video-stage {
    aspect-ratio: 16 / 9;
    flex: none;
  }

  #stage {
    aspect-ratio: 1 / 1;
    flex: none;
    height: auto;
  }

  .formations-pane {
    max-height: none;
  }

  #formation-list {
    max-height: 240px;
  }

  header h1 {
    font-size: 1rem;
  }
}

.loading-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  background: #000;
  color: #fff;
  z-index: 10;
  transition: opacity 0.3s ease;
}

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

.loading-text {
  font-size: 0.9rem;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
}

.loading-bar {
  width: 60%;
  max-width: 320px;
  height: 6px;
  background: #333;
  border-radius: 3px;
  overflow: hidden;
}

.loading-bar-fill {
  height: 100%;
  width: 0%;
  background: #fff;
  transition: width 0.15s ease;
}


.stage-controls {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
}

#flip-btn {
  padding: 0.35rem 0.75rem;
  border: 1px solid var(--border);
  background: var(--panel);
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.85rem;
}

#flip-btn:hover { background: #f0f0f0; }

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

#stage {
  flex: 1;
  width: 100%;
  height: 100%;
  min-height: 0;
}

.grid-line { stroke: var(--grid); stroke-width: 1; }
.stage-edge { fill: none; stroke: #bbb; stroke-width: 1.5; }
.stage-marker {
  font-size: 11px;
  fill: var(--muted);
  text-anchor: middle;
  font-weight: 500;
  letter-spacing: 0.05em;
}

.dancer-dot {
  fill: #888;
  stroke: #fff;
  stroke-width: 2;
  transition: fill 0.15s ease;
}

.dancer-label {
  font-size: 12px;
  fill: var(--fg);
  font-weight: 500;
  pointer-events: none;
  user-select: none;
}

.formations-pane h2 {
  margin: 0 0 0.5rem;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  font-weight: 600;
}

#formation-list {
  list-style: none;
  margin: 0;
  padding: 0;
  overflow-y: auto;
}

#formation-list li {
  padding: 0.5rem 0.6rem;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.9rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

#formation-list li:hover { background: #f0f0f0; }

#formation-list li.active {
  background: #1a1a1a;
  color: #fff;
}

#formation-list li .time {
  font-variant-numeric: tabular-nums;
  font-size: 0.8rem;
  opacity: 0.7;
}
