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

:root {
  --bg: #0f1117;
  --surface: #1a1d27;
  --surface2: #22263a;
  --border: #2e3350;
  --accent: #6c8eff;
  --accent-hover: #899fff;
  --success: #4caf7d;
  --warn: #f0a500;
  --error: #e05c5c;
  --text: #e2e4f0;
  --text-muted: #7880a0;
  --radius: 10px;
  --transition: 0.18s ease;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  font-size: 14px;
  min-height: 100vh;
}

a { color: var(--accent); text-decoration: none; }

/* ── Layout ───────────────────────────────────────────── */
header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 2rem;
  height: 56px;
  display: flex;
  align-items: center;
  gap: 10px;
}
header .logo { font-size: 1.1rem; font-weight: 700; letter-spacing: -.3px; }
header .logo span { color: var(--accent); }
header .badge {
  font-size: 11px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 2px 8px;
  color: var(--text-muted);
}

main { max-width: 900px; margin: 0 auto; padding: 2rem 1rem; }

/* ── Upload Zone ──────────────────────────────────────── */
.upload-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 3rem 2rem;
  text-align: center;
  cursor: pointer;
  transition: border-color var(--transition), background var(--transition);
  background: var(--surface);
  position: relative;
}
.upload-zone:hover,
.upload-zone.dragover {
  border-color: var(--accent);
  background: rgba(108, 142, 255, 0.05);
}
.upload-zone input[type=file] {
  position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; height: 100%;
}
.upload-icon { font-size: 2.5rem; margin-bottom: .75rem; }
.upload-zone h2 { font-size: 1.1rem; margin-bottom: .3rem; }
.upload-zone p { color: var(--text-muted); font-size: 13px; }
.upload-zone .supported {
  margin-top: 1rem;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px;
}
.tag {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 20px;
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text-muted);
}

/* ── Queue ────────────────────────────────────────────── */
.queue { margin-top: 1.5rem; display: flex; flex-direction: column; gap: .75rem; }

.queue-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  display: flex;
  align-items: center;
  gap: 1rem;
}
.queue-item .file-icon { font-size: 1.6rem; flex-shrink: 0; }
.queue-item .file-info { flex: 1; min-width: 0; }
.queue-item .file-name {
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.queue-item .file-size { color: var(--text-muted); font-size: 12px; margin-top: 2px; }
.queue-item .actions { display: flex; gap: .5rem; align-items: center; flex-shrink: 0; }

/* ── Buttons ──────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: 7px;
  border: none;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  transition: background var(--transition), opacity var(--transition);
}
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-primary   { background: var(--accent); color: #fff; }
.btn-primary:not(:disabled):hover { background: var(--accent-hover); }
.btn-ghost {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
}
.btn-ghost:not(:disabled):hover { border-color: var(--accent); color: var(--accent); }
.btn-danger { background: var(--error); color: #fff; }
.btn-success { background: var(--success); color: #fff; }
.btn-sm { padding: 5px 10px; font-size: 12px; }

/* ── Status pill ─────────────────────────────────────── */
.status-pill {
  font-size: 11px;
  padding: 3px 9px;
  border-radius: 20px;
  font-weight: 600;
  flex-shrink: 0;
}
.status-pending  { background: var(--surface2); color: var(--text-muted); }
.status-loading  { background: rgba(108,142,255,.15); color: var(--accent); }
.status-ready    { background: rgba(76,175,125,.15); color: var(--success); }
.status-error    { background: rgba(224,92,92,.15);  color: var(--error); }
.status-waiting  { background: rgba(240,165,0,.15);  color: var(--warn); }

/* ── Spinner ─────────────────────────────────────────── */
@keyframes spin { to { transform: rotate(360deg); } }
.spinner {
  display: inline-block;
  width: 14px; height: 14px;
  border: 2px solid var(--accent);
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin .7s linear infinite;
}

/* ── Metadata Panel ──────────────────────────────────── */
.meta-panel {
  margin-top: 1.5rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.meta-panel-header {
  padding: .85rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
  background: var(--surface2);
}
.meta-panel-header h3 {
  font-size: .95rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
}
.meta-panel-header .actions { display: flex; gap: .5rem; }

.meta-section { border-bottom: 1px solid var(--border); }
.meta-section:last-child { border-bottom: none; }
.meta-section-title {
  padding: .6rem 1.25rem;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .6px;
  color: var(--text-muted);
  background: var(--surface2);
  cursor: pointer;
  user-select: none;
  display: flex;
  align-items: center;
  gap: 6px;
}
.meta-section-title:hover { color: var(--text); }
.section-chevron { transition: transform var(--transition); }
.section-chevron.open { transform: rotate(90deg); }

.meta-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1px;
  background: var(--border);
}
.meta-field {
  background: var(--surface);
  padding: .75rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.meta-label {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .4px;
}
.meta-input {
  background: transparent;
  border: none;
  border-bottom: 1px solid transparent;
  color: var(--text);
  font-size: 13px;
  padding: 2px 0;
  width: 100%;
  outline: none;
  transition: border-color var(--transition);
}
.meta-input:not([readonly]):focus {
  border-bottom-color: var(--accent);
}
.meta-input[readonly] {
  color: var(--text-muted);
  cursor: default;
}
.meta-input.readonly-pill {
  font-size: 12px;
  background: var(--surface2);
  border-radius: 4px;
  padding: 2px 6px;
  border: none;
}

/* GPS sub-grid */
.gps-grid { display: flex; gap: .75rem; flex-wrap: wrap; }
.gps-grid .gps-field { flex: 1; min-width: 120px; display: flex; flex-direction: column; gap: 4px; }

/* ── Streams table ────────────────────────────────────── */
.streams-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.streams-table th, .streams-table td {
  padding: .5rem 1.25rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
}
.streams-table th { color: var(--text-muted); font-weight: 600; text-transform: uppercase; font-size: 10px; letter-spacing: .4px; }
.streams-table tr:last-child td { border-bottom: none; }

/* ── Error / Slot banner ─────────────────────────────── */
.banner {
  border-radius: var(--radius);
  padding: .85rem 1.25rem;
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: .75rem;
  margin-top: 1rem;
}
.banner-error { background: rgba(224,92,92,.1); border: 1px solid rgba(224,92,92,.3); color: var(--error); }
.banner-warn  { background: rgba(240,165,0,.1);  border: 1px solid rgba(240,165,0,.3); color: var(--warn); }

/* ── Toast ────────────────────────────────────────────── */
#toast-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: .5rem;
  z-index: 9999;
}
.toast {
  padding: .75rem 1.25rem;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 500;
  max-width: 360px;
  animation: slideIn .2s ease;
  box-shadow: 0 4px 20px rgba(0,0,0,.4);
}
.toast-success { background: #1e3d2f; border: 1px solid var(--success); color: var(--success); }
.toast-error   { background: #3d1e1e; border: 1px solid var(--error);   color: var(--error); }
@keyframes slideIn { from { opacity:0; transform: translateX(20px); } to { opacity:1; transform: translateX(0); } }

/* ── Controls Panel ──────────────────────────────────── */
.controls-panel {
  margin-top: 1.5rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.controls-header {
  padding: .85rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
  background: var(--surface2);
}
.controls-header h3 {
  font-size: .95rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
}
.controls-body {
  padding: 1.25rem;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  align-items: start;
}
.controls-sliders { display: flex; flex-direction: column; gap: 1.1rem; }
.controls-preview { display: flex; flex-direction: column; gap: .6rem; }
.preview-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--text-muted);
}
.preview-canvas-wrap {
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: #000;
  line-height: 0;
}
.preview-canvas-wrap canvas {
  display: block;
  max-width: 100%;
}
.preview-speed-badge {
  font-size: 12px;
  font-weight: 700;
  color: var(--accent);
  display: flex;
  align-items: center;
  gap: 6px;
}

/* Slider row */
.ctrl-row { display: flex; align-items: center; gap: 1rem; }
.ctrl-label {
  width: 90px;
  flex-shrink: 0;
  font-size: 13px;
  color: var(--text-muted);
  font-weight: 500;
}
.ctrl-slider {
  flex: 1;
  -webkit-appearance: none;
  appearance: none;
  height: 4px;
  border-radius: 2px;
  background: var(--border);
  outline: none;
  cursor: pointer;
  position: relative;
}
.ctrl-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  transition: background var(--transition), transform var(--transition);
  box-shadow: 0 0 0 3px rgba(108,142,255,.2);
}
.ctrl-slider::-webkit-slider-thumb:hover { background: var(--accent-hover); transform: scale(1.15); }
.ctrl-slider::-moz-range-thumb {
  width: 16px; height: 16px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  border: none;
}
.ctrl-value {
  width: 42px;
  text-align: right;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  color: var(--accent);
  font-weight: 600;
}
.ctrl-reset {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 11px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color var(--transition), color var(--transition);
  flex-shrink: 0;
}
.ctrl-reset:hover { border-color: var(--accent); color: var(--accent); }

/* Control group label */
.ctrl-group-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .6px;
  color: var(--text-muted);
  padding-bottom: .3rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 8px;
}
.ctrl-group-hint {
  font-size: 10px;
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
  color: var(--success);
  opacity: .8;
}

/* Mosaic toggle */
.mosaic-row { display: flex; align-items: center; gap: 1rem; }
.mosaic-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  user-select: none;
}
.toggle-track {
  width: 36px; height: 20px;
  border-radius: 10px;
  background: var(--border);
  position: relative;
  transition: background var(--transition);
  flex-shrink: 0;
}
.toggle-track.on { background: var(--accent); }
.toggle-thumb {
  width: 14px; height: 14px;
  border-radius: 50%;
  background: #fff;
  position: absolute;
  top: 3px; left: 3px;
  transition: transform var(--transition);
}
.toggle-track.on .toggle-thumb { transform: translateX(16px); }

/* Auto-meta badge */
.auto-meta-note {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: .65rem 1.25rem;
  font-size: 12px;
  color: var(--text-muted);
  border-top: 1px solid var(--border);
  background: var(--surface2);
}
.auto-meta-note .dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--success);
  flex-shrink: 0;
  animation: pulse 2s infinite;
}
@keyframes pulse { 0%,100% { opacity:1; } 50% { opacity:.4; } }

/* ── Responsive ──────────────────────────────────────── */
@media (max-width: 700px) {
  header { padding: 0 1rem; }
  main { padding: 1rem .75rem; }
  .ctrl-label { width: 70px; }
  .controls-body { grid-template-columns: 1fr; }
  .controls-preview { order: -1; } /* preview above sliders on mobile */
}
