:root {
  --bg: #0f1115;
  --surface: #181b22;
  --surface-2: #22262f;
  --border: #2a2f3a;
  --text: #e6e8ec;
  --muted: #9aa1ad;
  --accent: #4f8cff;
  --accent-hover: #6fa0ff;
  --success: #23c483;
  --danger: #ff5c5c;
  --radius: 12px;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }

.container { max-width: 960px; margin: 0 auto; padding: 24px 20px; }

header.site {
  border-bottom: 1px solid var(--border);
  padding: 16px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
header.site .logo { font-weight: 700; font-size: 18px; color: var(--text); }
header.site nav a { margin-left: 16px; font-size: 14px; color: var(--muted); }

h1 { font-size: 28px; margin-bottom: 8px; }
h2 { font-size: 20px; margin: 24px 0 12px; }
p.lead { color: var(--muted); margin-bottom: 24px; }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
  margin-top: 24px;
}
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  transition: border-color .15s, transform .15s;
}
.card:hover { border-color: var(--accent); transform: translateY(-2px); }
.card h3 { font-size: 16px; margin-bottom: 6px; }
.card p { font-size: 13px; color: var(--muted); }

.tool {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin-top: 20px;
}

.dropzone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 40px 20px;
  text-align: center;
  cursor: pointer;
  transition: border-color .15s, background .15s;
}
.dropzone:hover, .dropzone.dragover {
  border-color: var(--accent);
  background: var(--surface-2);
}
.dropzone:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }
.dropzone p { color: var(--muted); font-size: 14px; }
.file-selection { margin-top: 12px; color: var(--success); font-size: 14px; font-weight: 600; overflow-wrap: anywhere; }

.btn {
  display: inline-block;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 10px 18px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s;
}
.btn:hover { background: var(--accent-hover); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.secondary { background: var(--surface-2); color: var(--text); }
.btn.danger { background: var(--danger); }

.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; margin-top: 16px; }
.row.between { justify-content: space-between; }

input[type="number"], input[type="text"], select {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 12px;
  color: var(--text);
  font-size: 14px;
  width: 120px;
}

.filelist { margin-top: 16px; }
.filelist .item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 12px;
  background: var(--surface-2);
  border-radius: 8px;
  margin-bottom: 8px;
  font-size: 13px;
}
.filelist .item button {
  background: transparent;
  border: none;
  color: var(--danger);
  cursor: pointer;
  font-size: 16px;
}

.thumbs {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 12px;
  margin-top: 16px;
}
.thumb {
  border: 2px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  cursor: pointer;
  position: relative;
  background: var(--surface-2);
}
.thumb.selected { border-color: var(--accent); }
.thumb img { width: 100%; display: block; }
.thumb .label {
  position: absolute; bottom: 4px; right: 4px;
  background: rgba(0,0,0,.7); padding: 2px 6px;
  border-radius: 4px; font-size: 11px;
}
.thumb .del {
  position: absolute; top: 4px; right: 4px;
  background: rgba(0,0,0,.7); border: none; color: #fff;
  width: 22px; height: 22px; border-radius: 50%;
  cursor: pointer; font-size: 12px;
}

.result {
  background: var(--surface-2);
  border-radius: 8px;
  padding: 16px;
  margin-top: 16px;
  font-size: 14px;
}
.result .ok { color: var(--success); font-weight: 600; }
.result .warn { color: var(--danger); }
.download-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }

.filelist .item[draggable="true"] { cursor: grab; }
.filelist .item[draggable="true"]:active { cursor: grabbing; }

.spinner {
  display: inline-block;
  width: 16px; height: 16px;
  border: 2px solid rgba(255,255,255,.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .8s linear infinite;
  vertical-align: middle;
  margin-right: 8px;
}
@keyframes spin { to { transform: rotate(360deg); } }

.toast {
  position: fixed;
  bottom: 24px; left: 50%;
  transform: translateX(-50%) translateY(80px);
  background: var(--surface-2);
  border: 1px solid var(--border);
  padding: 12px 20px;
  border-radius: 8px;
  font-size: 14px;
  transition: transform .25s;
  z-index: 999;
}
.toast.show { transform: translateX(-50%) translateY(0); }
.toast.error { border-color: var(--danger); }
.toast.success { border-color: var(--success); }

footer.site {
  text-align: center;
  padding: 32px 20px;
  color: var(--muted);
  font-size: 13px;
  border-top: 1px solid var(--border);
  margin-top: 48px;
}

.hidden { display: none !important; }

@media (max-width: 600px) {
  h1 { font-size: 22px; }
  .container { padding: 16px; }
  .tool { padding: 16px; }
}