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

:root {
  --bg: #0c0c0f;
  --surface: #141418;
  --surface2: #1c1c22;
  --border: #2a2a35;
  --accent: #c8f135;
  --accent2: #f1c835;
  --text: #e8e8f0;
  --muted: #6b6b80;
  --danger: #ff4d4d;
  --radius: 12px;
}

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: 'DM Mono', monospace;
  font-size: 13px;
  overflow-x: hidden;
}

/* ── HEADER ── */
header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 32px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  position: sticky;
  top: 0;
  z-index: 100;
}

.logo {
  font-family: 'Syne', sans-serif;
  font-weight: 800;
  font-size: 20px;
  letter-spacing: -0.5px;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 8px;
}

.logo span {
  background: var(--accent);
  color: #000;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 700;
  font-family: 'DM Mono', monospace;
  letter-spacing: 1px;
}

.header-actions {
  display: flex;
  gap: 10px;
}

/* ── BUTTONS ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  font-family: 'DM Mono', monospace;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.btn:hover { border-color: var(--muted); background: var(--surface2); }

.btn.primary {
  background: var(--accent);
  color: #000;
  border-color: var(--accent);
  font-weight: 500;
}

.btn.primary:hover { background: #d4ff44; border-color: #d4ff44; }

.btn.danger { color: var(--danger); border-color: var(--danger); }
.btn.danger:hover { background: rgba(255,77,77,0.1); }

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

/* ── LAYOUT ── */
.main {
  display: grid;
  grid-template-columns: 340px 1fr;
  min-height: calc(100vh - 57px);
}

/* ── SIDEBAR ── */
.sidebar {
  border-right: 1px solid var(--border);
  background: var(--surface);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

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

.section-label {
  font-family: 'Syne', sans-serif;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.section-label::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* ── DROP ZONES ── */
.dropzone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 28px 20px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s ease;
  background: var(--bg);
  position: relative;
}

.dropzone:hover, .dropzone.drag-over {
  border-color: var(--accent);
  background: rgba(200, 241, 53, 0.04);
}

.dropzone input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
  width: 100%;
  height: 100%;
}

.dropzone-icon {
  font-size: 28px;
  margin-bottom: 8px;
  display: block;
}

.dropzone-text {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.5;
}

.dropzone-text strong {
  color: var(--text);
  font-weight: 500;
  display: block;
  margin-bottom: 2px;
}

/* ── OVERLAY PREVIEW ── */
.overlay-preview {
  margin-top: 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  position: relative;
  display: none;
}

.overlay-preview img {
  width: 100%;
  height: 100px;
  object-fit: contain;
  display: block;
  padding: 8px;
}

.overlay-preview .remove-btn {
  position: absolute;
  top: 6px;
  right: 6px;
  background: rgba(0,0,0,0.75);
  border: 1px solid var(--border);
  color: var(--muted);
  border-radius: 6px;
  padding: 3px 7px;
  font-size: 10px;
  cursor: pointer;
  transition: all 0.15s;
}

.overlay-preview .remove-btn:hover { color: var(--danger); border-color: var(--danger); }

/* ── OVERLAY OPTIONS ── */
.options-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 4px;
}

.option-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.option-group.full { grid-column: 1 / -1; }

.option-label {
  font-size: 10px;
  color: var(--muted);
  letter-spacing: 0.5px;
}

.option-group select,
.option-group input[type="range"],
.option-group input[type="number"] {
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 6px;
  padding: 5px 8px;
  font-family: 'DM Mono', monospace;
  font-size: 12px;
  width: 100%;
  outline: none;
  appearance: none;
  -webkit-appearance: none;
  transition: border-color 0.15s;
}

.option-group select:hover,
.option-group input:hover { border-color: var(--muted); }
.option-group select:focus,
.option-group input:focus { border-color: var(--accent); }

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

.range-val {
  font-size: 11px;
  color: var(--accent);
  min-width: 30px;
  text-align: right;
}

input[type="range"] {
  padding: 0 !important;
  accent-color: var(--accent);
  height: 4px;
  cursor: pointer;
}

/* ── QUEUE ── */
.queue-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 300px;
  overflow-y: auto;
  padding-right: 2px;
}

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

.queue-item:hover { border-color: var(--muted); }

.queue-thumb {
  width: 40px;
  height: 40px;
  object-fit: cover;
  border-radius: 5px;
  background: var(--surface2);
  flex-shrink: 0;
}

.queue-info {
  flex: 1;
  overflow: hidden;
}

.queue-name {
  font-size: 11px;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.queue-size {
  font-size: 10px;
  color: var(--muted);
  margin-top: 2px;
}

.queue-remove {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 14px;
  padding: 2px;
  line-height: 1;
  transition: color 0.15s;
  flex-shrink: 0;
}

.queue-remove:hover { color: var(--danger); }

.queue-empty {
  text-align: center;
  color: var(--muted);
  font-size: 11px;
  padding: 20px 0;
}

/* ── PROCESS BTN ── */
.sidebar-footer {
  padding: 16px 20px;
  margin-top: auto;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.process-btn {
  width: 100%;
  padding: 12px;
  justify-content: center;
  font-size: 13px;
  font-family: 'Syne', sans-serif;
  font-weight: 700;
  letter-spacing: 1px;
  border-radius: 10px;
}

/* ── CANVAS AREA ── */
.canvas-area {
  background: var(--bg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.canvas-toolbar {
  padding: 12px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: var(--surface);
  flex-wrap: wrap;
}

.toolbar-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

.toolbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.result-count {
  font-size: 11px;
  color: var(--muted);
  padding: 4px 10px;
  background: var(--surface2);
  border-radius: 20px;
  border: 1px solid var(--border);
}

.result-count strong { color: var(--accent); }

/* ── RESULT GRID ── */
.result-grid {
  flex: 1;
  padding: 24px;
  overflow-y: auto;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
  align-content: start;
}

.result-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: all 0.2s ease;
  position: relative;
}

.result-card:hover {
  border-color: var(--muted);
  transform: translateY(-2px);
  box-shadow: 0 8px 32px rgba(0,0,0,0.4);
}

.result-card.selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent);
}

.result-card .card-check {
  position: absolute;
  top: 8px;
  left: 8px;
  width: 20px;
  height: 20px;
  background: rgba(0,0,0,0.7);
  border: 1px solid var(--border);
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 2;
  transition: all 0.15s;
}

.result-card.selected .card-check {
  background: var(--accent);
  border-color: var(--accent);
  color: #000;
}

.result-card .card-img-wrap {
  width: 100%;
  aspect-ratio: 4/3;
  overflow: hidden;
  background: repeating-conic-gradient(#1a1a20 0% 25%, #222228 0% 50%) 0 0 / 16px 16px;
  cursor: pointer;
}

.result-card .card-img-wrap canvas {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.result-card .card-info {
  padding: 10px 12px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 8px;
}

.card-name {
  flex: 1;
  font-size: 11px;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.card-dl {
  background: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--muted);
  font-size: 14px;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s;
  flex-shrink: 0;
}

.card-dl:hover { color: var(--accent); border-color: var(--accent); }

/* ── EMPTY STATE ── */
.empty-state {
  grid-column: 1 / -1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 80px 20px;
  text-align: center;
  color: var(--muted);
}

.empty-icon {
  font-size: 48px;
  margin-bottom: 16px;
  opacity: 0.5;
}

.empty-title {
  font-family: 'Syne', sans-serif;
  font-weight: 700;
  font-size: 18px;
  color: var(--text);
  margin-bottom: 8px;
  opacity: 0.6;
}

.empty-sub { font-size: 12px; line-height: 1.6; }

/* ── PROGRESS ── */
.progress-bar-wrap {
  display: none;
  height: 3px;
  background: var(--surface2);
  position: relative;
  overflow: hidden;
}

.progress-bar-inner {
  height: 100%;
  background: var(--accent);
  transition: width 0.2s ease;
  width: 0%;
}

/* ── SCROLLBAR ── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 999px; }
::-webkit-scrollbar-thumb:hover { background: var(--muted); }

/* ── TOAST ── */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 18px;
  font-size: 12px;
  color: var(--text);
  z-index: 999;
  transform: translateY(80px);
  opacity: 0;
  transition: all 0.3s ease;
  max-width: 280px;
}

.toast.show { transform: translateY(0); opacity: 1; }
.toast.success { border-color: var(--accent); }
.toast.error { border-color: var(--danger); }

/* ── RESPONSIVE ── */
@media (max-width: 768px) {
  .main { grid-template-columns: 1fr; }
  .sidebar { border-right: none; border-bottom: 1px solid var(--border); }
  header { padding: 14px 16px; }
  .result-grid { padding: 16px; }
}