:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --text: #1c2230;
  --muted: #6b7385;
  --border: #dde1e8;
  --accent: #6a3fb5;
  --accent-text: #ffffff;
  --ok: #1f8a4c;
  --warn: #b36b00;
  --err: #c0392b;
  --track: #e8eaf0;
  --radius: 10px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12151c;
    --surface: #1b1f29;
    --text: #e6e8ee;
    --muted: #9aa2b4;
    --border: #2c3342;
    --accent: #a07ee6;
    --accent-text: #12151c;
    --ok: #4cc281;
    --warn: #e0a040;
    --err: #ef6b5e;
    --track: #2a3040;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
}
h1 { font-size: 1.2rem; margin: 0; }
h2 { font-size: 1.05rem; margin: 0 0 12px; }
h3 { font-size: 1rem; margin: 0; }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.error { color: var(--err); }
.warn { color: var(--warn); }

button, input, select {
  font: inherit;
  color: inherit;
}
button {
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 8px;
  padding: 6px 12px;
  cursor: pointer;
}
button:hover:not(:disabled) { border-color: var(--accent); }
button:disabled { opacity: 0.5; cursor: default; }
button.primary { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
button.ghost { background: transparent; }
button.danger { color: var(--err); }
button.small { padding: 3px 8px; font-size: 0.85rem; }
input[type=text], input[type=password], select {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.layout {
  max-width: 1200px;
  margin: 0 auto;
  padding: 16px;
  display: grid;
  gap: 16px;
}
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  min-width: 0;
}
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin: 8px 0; }
.row label { min-width: 90px; }
.row input { flex: 1; min-width: 180px; }
.row.center { justify-content: center; }
.row.end { justify-content: flex-end; }
.row.between { justify-content: space-between; }

.dropzone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 20px;
  text-align: center;
  margin-top: 8px;
}
.dropzone p { margin: 4px 0; }
.dropzone.over { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 8%, transparent); }

.queue, .active-list { list-style: none; padding: 0; margin: 12px 0 0; display: grid; gap: 8px; }
.queue li, .active-list li {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  display: grid;
  gap: 4px;
}
.item-head { display: flex; gap: 8px; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.item-name { font-weight: 600; overflow-wrap: anywhere; }
.bar { height: 6px; background: var(--track); border-radius: 3px; overflow: hidden; }
.bar > span { display: block; height: 100%; width: 0; background: var(--accent); transition: width 0.3s; }
.bar.done > span { background: var(--ok); }
.bar.err > span { background: var(--err); }

.badge {
  font-size: 0.75rem;
  padding: 1px 8px;
  border-radius: 999px;
  border: 1px solid var(--border);
  white-space: nowrap;
}
.badge.ok { color: var(--ok); border-color: currentColor; }
.badge.warn { color: var(--warn); border-color: currentColor; }
.badge.err { color: var(--err); border-color: currentColor; }

.crumbs { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
.crumbs button { border: none; background: none; color: var(--accent); padding: 2px 4px; }
.crumbs .sep { color: var(--muted); }

.folders { display: grid; gap: 6px; margin: 8px 0; }
.folder {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
}
.folder .open { border: none; background: none; text-align: left; flex: 1; font-weight: 600; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; }
.slide {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.thumb {
  aspect-ratio: 4 / 3;
  background: var(--track);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
}
.thumb img { width: 100%; height: 100%; object-fit: contain; background: #fff; }
.slide-body { padding: 8px 10px; display: grid; gap: 4px; }
.actions { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }

dialog {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  width: min(640px, calc(100vw - 32px));
  max-height: 85vh;
  padding: 16px;
}
dialog::backdrop { background: rgb(0 0 0 / 0.45); }
.dialog-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
table.kv { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
table.kv td { border-top: 1px solid var(--border); padding: 4px 6px; vertical-align: top; overflow-wrap: anywhere; }
table.kv td:first-child { color: var(--muted); width: 38%; }

.login-body { display: flex; min-height: 100vh; align-items: center; justify-content: center; padding: 16px; }
.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  width: min(360px, 100%);
}
.login-card form { display: grid; gap: 10px; margin-top: 12px; }

/* collapsible "Processing & quarantine" */
#active-details > summary {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  cursor: pointer;
  list-style: none;
}
#active-details > summary::-webkit-details-marker { display: none; }
#active-details > summary::before { content: "▸"; color: var(--muted); }
#active-details[open] > summary::before { content: "▾"; }
#active-details > summary h2 { margin: 0; }
#active-details[open] > summary { margin-bottom: 8px; }
#active-summary { margin: 0; }
