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

:root {
  --bg: #1a1a2e;
  --bg-light: #16213e;
  --bg-card: #1e2a45;
  --accent: #0f3460;
  --highlight: #e94560;
  --text: #eee;
  --text-dim: #8892a4;
  --border: #2a3a5c;
  --radius: 6px;
}

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

.app {
  display: grid;
  grid-template-columns: 1fr 320px;
  height: 100vh;
}

/* Canvas Area */
.canvas-area {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.toolbar {
  display: flex;
  gap: 8px;
  padding: 8px 12px;
  background: var(--bg-light);
  border-bottom: 1px solid var(--border);
}

.toolbar button {
  padding: 6px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-card);
  color: var(--text);
  font-size: 13px;
  cursor: pointer;
  transition: background 0.15s;
}

.toolbar button:hover:not(:disabled) {
  background: var(--accent);
}

.toolbar button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.toolbar-spacer {
  flex: 1;
}

.toggle-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-dim);
  cursor: pointer;
  user-select: none;
}

.toggle-label input {
  display: none;
}

.toggle-switch {
  width: 36px;
  height: 20px;
  background: var(--border);
  border-radius: 10px;
  position: relative;
  transition: background 0.2s;
}

.toggle-switch::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.2s;
}

.toggle-label input:checked + .toggle-switch {
  background: var(--highlight);
}

.toggle-label input:checked + .toggle-switch::after {
  transform: translateX(16px);
}

.canvas-wrapper {
  flex: 1;
  position: relative;
  overflow: hidden;
  background: #111827;
}

#canvas {
  display: block;
  cursor: crosshair;
}

.dropzone {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.2s;
}

.dropzone.hidden {
  display: none;
}

.dropzone:hover,
.dropzone.drag-over {
  background: rgba(15, 52, 96, 0.3);
}

.dropzone-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  color: var(--text-dim);
  border: 2px dashed var(--border);
  border-radius: 12px;
  padding: 40px 60px;
  pointer-events: none;
}

.dropzone-content svg {
  opacity: 0.5;
}

.dropzone-content p {
  font-size: 14px;
}

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

.sidebar-section {
  padding: 16px;
  border-bottom: 1px solid var(--border);
}

.sidebar-section h3 {
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-dim);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.badge {
  background: var(--accent);
  color: var(--text);
  font-size: 11px;
  padding: 1px 7px;
  border-radius: 10px;
  font-weight: 500;
}

/* Annotation Form */
.annotation-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.annotation-form.hidden {
  display: none;
}

.no-selection {
  color: var(--text-dim);
  font-size: 13px;
  padding: 8px 0;
}

.no-selection.hidden {
  display: none;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.form-group label {
  font-size: 12px;
  color: var(--text-dim);
}

.form-group input[type="text"] {
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--text);
  font-size: 13px;
  outline: none;
}

.form-group input[type="text"]:focus {
  border-color: var(--highlight);
}

.form-group input[type="range"] {
  width: 100%;
  accent-color: var(--highlight);
}

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

.color-row input[type="color"] {
  width: 32px;
  height: 32px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: none;
  cursor: pointer;
  padding: 2px;
}

.color-presets {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

.color-preset {
  width: 22px;
  height: 22px;
  border-radius: 4px;
  border: 2px solid transparent;
  cursor: pointer;
  transition: border-color 0.15s;
}

.color-preset:hover {
  border-color: #fff;
}

.form-actions {
  margin-top: 4px;
}

.btn-danger {
  width: 100%;
  padding: 6px 12px;
  border: 1px solid #d0021b;
  border-radius: var(--radius);
  background: transparent;
  color: #d0021b;
  font-size: 13px;
  cursor: pointer;
  transition: background 0.15s;
}

.btn-danger:hover {
  background: rgba(208, 2, 27, 0.15);
}

/* Box List */
.box-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 50vh;
  overflow-y: auto;
}

.empty-list {
  color: var(--text-dim);
  font-size: 13px;
}

.box-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: var(--radius);
  background: var(--bg);
  cursor: pointer;
  transition: background 0.15s;
  border: 1px solid transparent;
}

.box-item:hover {
  background: var(--bg-card);
}

.box-item.selected {
  border-color: var(--highlight);
  background: var(--bg-card);
}

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

.box-info {
  flex: 1;
  min-width: 0;
}

.box-label {
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.box-meta {
  font-size: 11px;
  color: var(--text-dim);
}

.box-delete {
  width: 20px;
  height: 20px;
  border: none;
  background: none;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  border-radius: 3px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.box-delete:hover {
  background: rgba(208, 2, 27, 0.2);
  color: #d0021b;
}

/* 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;
  }

  .box-list {
    max-height: 20vh;
  }
}
