/* ── Custom Properties ── */
:root {
  --bg: #1a1a1a;
  --bg-sidebar: #242424;
  --bg-input: #333;
  --border: #444;
  --text: #e0e0e0;
  --text-muted: #999;
  --accent: #4a9eff;
  --accent-hover: #6bb3ff;
  --sidebar-width: 280px;
  --radius: 6px;
}

/* ── Reset ── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  height: 100%;
  overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 13px;
  color: var(--text);
  background: var(--bg);
}

/* ── App Layout ── */
.app {
  display: grid;
  grid-template-columns: 1fr var(--sidebar-width);
  height: 100vh;
}

/* ── Media Area ── */
.media-area {
  position: relative;
  overflow: hidden;
  background: #111;
  display: flex;
  align-items: center;
  justify-content: center;
}

.media-area.drag-over {
  outline: 3px dashed var(--accent);
  outline-offset: -6px;
}

#videoEl, #imageEl {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: none;
}

#videoEl.active { display: block; }
#imageEl.active { display: block; }

#gridCanvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  touch-action: none;
}

.placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  color: var(--text-muted);
  pointer-events: none;
  user-select: none;
}

.placeholder.hidden { display: none; }

.placeholder svg {
  opacity: 0.5;
}

.placeholder p {
  font-size: 14px;
}

/* ── Sidebar ── */
.sidebar {
  background: var(--bg-sidebar);
  border-left: 1px solid var(--border);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.sidebar-scroll {
  overflow-y: auto;
  padding: 16px;
  flex: 1;
}

.panel-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.panel-section h3 {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
}

.divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 12px 0;
}

/* ── Controls ── */
.row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.row label {
  min-width: 52px;
  font-size: 12px;
  color: var(--text-muted);
}

.row input[type="range"] {
  flex: 1;
}

.value {
  min-width: 44px;
  text-align: right;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  color: var(--text-muted);
}

input[type="number"] {
  width: 72px;
  padding: 4px 8px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 13px;
  text-align: center;
}

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

input[type="color"] {
  width: 36px;
  height: 28px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: none;
  cursor: pointer;
}

input[type="color"]::-webkit-color-swatch-wrapper { padding: 2px; }
input[type="color"]::-webkit-color-swatch { border: none; border-radius: 3px; }

/* ── Range Slider ── */
input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  outline: none;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
}

input[type="range"]::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border: none;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
}

/* ── Buttons ── */
.btn {
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-input);
  color: var(--text);
  font-size: 12px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.btn:hover:not(:disabled) {
  background: #3a3a3a;
  border-color: #555;
}

.btn:disabled {
  opacity: 0.4;
  cursor: default;
}

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 500;
}

.btn-primary:hover:not(:disabled) {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

.btn-small {
  padding: 3px 10px;
  font-size: 11px;
}

.preset-buttons {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.file-name {
  font-size: 11px;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-height: 16px;
}

.hint {
  font-size: 11px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

/* ── Formation Planner ── */
.formation-rows {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.formation-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.formation-row span {
  font-size: 12px;
  color: var(--text-muted);
  min-width: 44px;
}

.formation-row input[type="number"] {
  width: 56px;
}

.formation-row .btn-remove {
  padding: 2px 7px;
  font-size: 14px;
  line-height: 1;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-input);
  color: var(--text-muted);
  cursor: pointer;
}

.formation-row .btn-remove:hover {
  background: #4a2020;
  border-color: #a33;
  color: #f88;
}

/* ── Responsive ── */
@media (max-width: 768px) {
  .app {
    grid-template-columns: 1fr;
    grid-template-rows: 1fr auto;
  }

  .sidebar {
    border-left: none;
    border-top: 1px solid var(--border);
    max-height: 40vh;
  }

  .media-area {
    min-height: 40vh;
  }
}
