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

:root {
  --bg: #0f1117;
  --surface: #1a1d27;
  --surface2: #242836;
  --border: #2e3348;
  --text: #e4e6f0;
  --muted: #8b8fa8;
  --accent: #f97316;
  --accent2: #ef4444;
  --radius: 12px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

.screen { padding: 1.5rem; max-width: 960px; margin: 0 auto; }

/* ── Center card (login / robot select) ─────────────────────────── */
.center-card {
  max-width: 420px;
  margin: 15vh auto 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem;
  text-align: center;
}
.center-card h1 { font-size: 1.8rem; margin-bottom: 0.25rem; }
.subtitle { color: var(--muted); margin-bottom: 1.25rem; }

/* ── Buttons ────────────────────────────────────────────────────── */
.primary {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 0.65rem 1.5rem;
  font-size: 0.95rem;
  cursor: pointer;
  transition: opacity 0.15s;
}
.primary:disabled { opacity: 0.4; cursor: default; }
.primary:hover:not(:disabled) { opacity: 0.85; }

.secondary {
  background: var(--surface2);
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.55rem 1rem;
  font-size: 0.9rem;
  cursor: pointer;
}
.secondary:hover { border-color: var(--accent); color: var(--text); }

.small { padding: 0.35rem 0.7rem; font-size: 0.8rem; }

.badge {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.25rem 0.6rem;
  font-size: 0.8rem;
}

/* ── Robot list ─────────────────────────────────────────────────── */
.robot-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin: 1rem 0;
}
.robot-btn {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  padding: 0.7rem 1rem;
  cursor: pointer;
  font-size: 0.95rem;
  transition: all 0.15s;
}
.robot-btn:hover { border-color: var(--accent); background: rgba(249,115,22,0.1); }

.muted { color: var(--muted); }
.error { color: var(--accent2); }

/* ── Header ─────────────────────────────────────────────────────── */
header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}
header h1 { font-size: 1.4rem; }
.header-right { display: flex; align-items: center; gap: 0.5rem; }

/* ── Video ──────────────────────────────────────────────────────── */
.video-section { margin-bottom: 1rem; }
.video-container {
  position: relative;
  background: #000;
  border-radius: var(--radius);
  overflow: hidden;
  max-height: 400px;
}
.video-container video {
  width: 100%;
  display: block;
  max-height: 400px;
  object-fit: contain;
}
.capture-btn {
  position: absolute;
  bottom: 1rem;
  left: 50%;
  transform: translateX(-50%);
  font-size: 1.6rem;
  background: rgba(0,0,0,0.6);
  border: 2px solid #fff;
  border-radius: 50%;
  width: 56px;
  height: 56px;
  cursor: pointer;
  transition: all 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
}
.capture-btn:hover { background: rgba(249,115,22,0.6); border-color: var(--accent); }

/* ── Filters ────────────────────────────────────────────────────── */
.filters-panel { margin-bottom: 1rem; }
.filters-panel h2 { margin-bottom: 0.75rem; font-size: 1.1rem; }

.filter-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  gap: 0.5rem;
}
.filter-btn {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  padding: 0.6rem 0.5rem;
  cursor: pointer;
  font-size: 0.85rem;
  transition: all 0.15s;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}
.filter-btn:hover { border-color: var(--accent); }
.filter-btn.active {
  background: rgba(249,115,22,0.15);
  border-color: var(--accent);
  color: var(--accent);
}
.fi { font-size: 1.1rem; }

/* ── Params ─────────────────────────────────────────────────────── */
.params-row {
  margin-top: 1rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1.5rem;
}
.params-row label {
  font-size: 0.82rem;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 0.4rem;
}
.params-row input[type=range] {
  width: 90px;
  accent-color: var(--accent);
}
.params-row span {
  min-width: 2ch;
  text-align: right;
  color: var(--text);
}

/* ── Actions ────────────────────────────────────────────────────── */
.action-row {
  margin-top: 1rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}
.timing { color: var(--muted); font-size: 0.85rem; margin-left: auto; }

/* ── Compare (original vs processed) ────────────────────────────── */
.compare {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-top: 1rem;
}
@media (max-width: 600px) {
  .compare { grid-template-columns: 1fr; }
}
.img-box {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.img-box img {
  width: 100%;
  display: block;
  object-fit: contain;
  max-height: 360px;
  background: #000;
}
.img-box .label {
  position: absolute;
  top: 0.5rem;
  left: 0.5rem;
  background: rgba(0,0,0,0.6);
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
  font-size: 0.75rem;
  color: #fff;
}
.download {
  position: absolute;
  bottom: 0.5rem;
  right: 0.5rem;
  background: var(--accent);
  color: #fff;
  padding: 0.3rem 0.7rem;
  border-radius: 6px;
  font-size: 0.8rem;
  text-decoration: none;
}

/* ── Upload fallback ────────────────────────────────────────────── */
.upload-fallback { margin-top: 1.5rem; }
.upload-fallback summary {
  color: var(--muted);
  cursor: pointer;
  font-size: 0.9rem;
}
.upload-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 2rem 1rem;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.2s;
  margin-top: 0.75rem;
}
.upload-zone:hover, .upload-zone.drag {
  border-color: var(--accent);
}
.drop-content .icon { font-size: 2rem; display: block; margin-bottom: 0.5rem; }
.drop-content button {
  background: none; border: none; color: var(--accent); cursor: pointer;
  font-size: inherit; text-decoration: underline;
}

/* ── Footer ─────────────────────────────────────────────────────── */
footer {
  margin-top: 2rem;
  text-align: center;
  color: var(--muted);
  font-size: 0.82rem;
}
footer a { color: var(--accent); }
