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

:root {
  --bg: #0f1117;
  --surface: #1a1d27;
  --border: #2a2d3e;
  --accent: #5c6ef8;
  --accent-hover: #7b8bfa;
  --text: #e2e4f0;
  --muted: #6b7280;
  --danger: #ef4444;
  --success: #22c55e;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, sans-serif;
  font-size: 14px;
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

header {
  padding: 12px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

header h1 { font-size: 18px; font-weight: 600; letter-spacing: 0.02em; }

main {
  display: flex;
  flex: 1;
  overflow: hidden;
}

/* Sidebar */
.sidebar {
  width: 260px;
  min-width: 260px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  overflow-y: auto;
}

.control-group { display: flex; flex-direction: column; gap: 6px; }

.control-group label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

input[type="file"],
input[type="text"],
input[type="password"] {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  padding: 7px 10px;
  font-size: 13px;
  width: 100%;
  outline: none;
  transition: border-color 0.15s;
}

input[type="file"] { padding: 5px; cursor: pointer; }

input:focus { border-color: var(--accent); }

.slider-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

input[type="range"] {
  flex: 1;
  accent-color: var(--accent);
  cursor: pointer;
}

#frame-label { min-width: 32px; text-align: right; color: var(--muted); }

.btn-row { display: flex; gap: 6px; }

.btn-row button {
  flex: 1;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-size: 18px;
  padding: 4px;
  cursor: pointer;
  transition: background 0.15s;
}

.btn-row button:hover { background: var(--border); }

.btn-primary {
  background: var(--accent);
  border: none;
  border-radius: 8px;
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  padding: 10px;
  cursor: pointer;
  transition: background 0.15s;
  width: 100%;
}

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

.btn-primary:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

#status {
  font-size: 12px;
  min-height: 18px;
  color: var(--muted);
}

#status.error { color: var(--danger); }
#status.success { color: var(--success); }

#results-panel h3 {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin-bottom: 8px;
}

#detection-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

#detection-list li {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  background: var(--bg);
  border-radius: 6px;
  border: 1px solid var(--border);
  font-size: 12px;
}

.swatch {
  width: 12px;
  height: 12px;
  border-radius: 3px;
  flex-shrink: 0;
}

/* Canvas area */
.canvas-area {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background: var(--bg);
  position: relative;
}

#placeholder {
  color: var(--muted);
  font-size: 15px;
  pointer-events: none;
}

#canvas-container {
  position: relative;
  display: none;
  line-height: 0;
}

#canvas-base {
  display: block;
  max-width: 100%;
  max-height: calc(100vh - 52px);
  border-radius: 4px;
}

#canvas-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border-radius: 4px;
  pointer-events: none;
}
