/* DepthSkeleton Video Extractor — dark theme replica */
:root {
  --bg: #0a0e14;
  --panel: #0d1219;
  --card: #111823;
  --border: #1e2735;
  --border-soft: #182130;
  --text: #cdd8e4;
  --text-dim: #5c6b7f;
  --accent: #3b82f6;
  --green: #17a34a;
  --green-hover: #15903f;
  --mono: "SF Mono", ui-monospace, Menlo, Consolas, monospace;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, "Segoe UI", Roboto, "Noto Sans Thai", sans-serif;
  font-size: 14px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ── Top bar ─────────────────────────────── */
.topbar {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 20px 10px;
}
.brand-kicker {
  font-size: 11px;
  letter-spacing: 3px;
  color: var(--text-dim);
  font-weight: 600;
}
.brand h1 { font-size: 24px; font-weight: 800; letter-spacing: 0.3px; }
.pill {
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text-dim);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 1px;
  padding: 8px 16px;
  border-radius: 8px;
  align-self: center;
}
.topbar-spacer { flex: 1; }

/* ── Buttons ─────────────────────────────── */
.btn {
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  padding: 9px 16px;
  border-radius: 8px;
  font-size: 14px;
  cursor: pointer;
  font-family: inherit;
}
.btn:hover:not(:disabled) { border-color: #2c3a4f; background: #16202e; }
.btn:disabled { opacity: 0.45; cursor: default; }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-blue { background: #1d4ed8; border-color: #1d4ed8; color: #fff; }
.btn-blue:hover:not(:disabled) { background: #2559e8; border-color: #2559e8; }
.btn-green {
  background: var(--green);
  border-color: var(--green);
  color: #fff;
  font-weight: 700;
  flex: 1;
  padding: 13px;
  font-size: 16px;
}
.btn-green:hover:not(:disabled) { background: var(--green-hover); }

/* ── Layout ──────────────────────────────── */
.layout {
  display: grid;
  grid-template-columns: 1fr 1fr 380px;
  /* แถวต้อง definite — ไม่งั้นสื่อในกรอบดันแถวสูงทะลุ statusbar */
  grid-template-rows: minmax(0, 1fr);
  gap: 16px;
  padding: 8px 20px 16px;
  flex: 1;
  min-height: 0;
}
@media (max-width: 1200px) {
  .layout { grid-template-columns: 1fr 1fr; }
  .sidebar { grid-column: 1 / -1; }
}

/* ── Panels ──────────────────────────────── */
.panel { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 2px 10px;
}
.panel-head h2 {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 1.5px;
  color: var(--text);
}
.badge {
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text-dim);
  font-size: 12px;
  padding: 5px 14px;
  border-radius: 99px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 45%;
}
.badge.active { color: #7ec8ff; border-color: #274a6d; }
.badge.done { color: #5fd38a; border-color: #245c38; }
.viewport {
  position: relative;
  background: #05070b;
  border: 1px solid var(--border-soft);
  border-radius: 10px;
  flex: 1;
  min-height: 240px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.viewport.dragover { border-color: var(--accent); }
/* absolute = ไม่นับเป็น content height ของกรอบ → กรอบไม่ถูกดันสูงตามวิดีโอ
   แล้ว object-fit ค่อยย่อให้พอดีโดยคงสัดส่วน */
.viewport video, .viewport canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}
.viewport-hint { text-align: center; color: #2e3d51; line-height: 2.1; font-size: 15px; }
.viewport-hint .dim { font-size: 13px; color: #26334a; }
.panel-foot { padding: 12px 2px 0; min-height: 44px; }

/* ── Sidebar cards ───────────────────────── */
.sidebar {
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow-y: auto;
  padding-bottom: 4px;
}
.card {
  background: var(--card);
  border: 1px solid var(--border-soft);
  border-radius: 10px;
  padding: 14px 16px;
}
.card h3 {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 2px;
  color: var(--text-dim);
  margin-bottom: 12px;
}
.row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}
.row:last-child { margin-bottom: 0; }
.row > label { color: var(--text); flex-shrink: 0; }
.row-controls { display: flex; align-items: center; gap: 8px; min-width: 0; }
.chip {
  border: 1px solid var(--border);
  background: var(--panel);
  padding: 6px 10px;
  border-radius: 8px;
  font-size: 12px;
  color: var(--text-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 170px;
}
select {
  background: var(--panel);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 13px;
  font-family: inherit;
  max-width: 220px;
}
.check {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
  cursor: pointer;
  user-select: none;
}
.check input { accent-color: var(--accent); width: 15px; height: 15px; }
.slider-row { gap: 12px; }
.slider-row label { min-width: 110px; }
.slider-row input[type="range"] { flex: 1; accent-color: var(--accent); }
.slider-row .mono { min-width: 34px; text-align: right; color: var(--text); }
.mono { font-family: var(--mono); font-size: 12px; }
.dim { color: var(--text-dim); }

.actions { display: flex; gap: 10px; margin-top: 2px; }
.actions .btn:not(.btn-green) { padding: 13px 22px; }

/* ── Status bar ──────────────────────────── */
.statusbar { padding: 0 20px 16px; }
.progress-track {
  position: relative;
  background: var(--card);
  border: 1px solid var(--border-soft);
  border-radius: 8px;
  height: 26px;
  overflow: hidden;
}
.progress-fill {
  position: absolute;
  inset: 0 auto 0 0;
  width: 0%;
  background: linear-gradient(90deg, #1d4ed8, #3b82f6);
  transition: width 0.15s ease;
}
#progressText {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-family: var(--mono);
  color: var(--text);
}
.status-line { padding: 10px 2px 8px; color: var(--text-dim); font-size: 13px; }
.log-box {
  background: #070b10;
  border: 1px solid var(--border-soft);
  border-radius: 10px;
  padding: 12px 14px;
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.7;
  color: #8fa3b8;
  max-height: 130px;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-word;
}
.log-box .ok { color: #4ade80; }
