:root {
  --bg: #f5f6f8;
  --card: #ffffff;
  --border: #e2e5ea;
  --text: #1c2330;
  --muted: #6b7280;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --success: #16a34a;
  --danger: #dc2626;
  --radius: 12px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Be Vietnam Pro", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

.container {
  max-width: 860px;
  margin: 0 auto;
  padding: 32px 16px 72px;
}

h1 {
  font-size: 28px;
  margin: 0;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
}

.lang-switch {
  display: flex;
  flex-shrink: 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  background: var(--card);
}

.lang-btn {
  border: none;
  background: transparent;
  padding: 6px 14px;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  color: var(--muted);
  transition: background 0.15s, color 0.15s;
}

.lang-btn:hover { color: var(--text); }

.lang-btn.active {
  background: var(--accent);
  color: #fff;
}

h2 {
  font-size: 16px;
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.subtitle {
  margin: 6px 0 14px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
}

section {
  margin: 28px 0;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.count {
  font-size: 14px;
  color: var(--muted);
}

.dropzone {
  margin-top: 10px;
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 40px 20px;
  text-align: center;
  background: var(--card);
  transition: border-color 0.15s, background 0.15s;
}

.dropzone.dragover {
  border-color: var(--accent);
  background: #eef4ff;
}

.dz-main { margin: 0 0 4px; font-weight: 600; }
.dz-hint { margin: 0 0 16px; color: var(--muted); font-size: 14px; }

button {
  font: inherit;
  cursor: pointer;
  border: none;
  border-radius: 8px;
  padding: 10px 18px;
  font-weight: 600;
}

button.primary {
  background: var(--accent);
  color: #fff;
  width: 100%;
  padding: 14px;
  font-size: 16px;
}

button.primary:hover:not(:disabled) { background: var(--accent-hover); }
button.primary:disabled { opacity: 0.5; cursor: not-allowed; }

button.secondary {
  background: #eef2f7;
  color: var(--text);
}

button.secondary:hover { background: #e2e8f0; }

.grid {
  margin-top: 12px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
}

.thumb {
  position: relative;
  border: 2px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  cursor: pointer;
  background: var(--card);
  transition: border-color 0.15s, opacity 0.15s;
}

.thumb img {
  display: block;
  width: 100%;
  aspect-ratio: 1;
  object-fit: contain;
  background: #eef0f3;
}

.thumb .thumb-name {
  display: block;
  font-size: 11px;
  padding: 6px 8px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.thumb.selected { border-color: var(--accent); }
.thumb.selected::after {
  content: "\2713";
  position: absolute;
  top: 6px;
  right: 6px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.thumb.deselected img { opacity: 0.4; }

.thumb-btn {
  position: absolute;
  top: 6px;
  width: 22px;
  height: 22px;
  border: none;
  border-radius: 50%;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  line-height: 1;
  color: #fff;
  cursor: pointer;
  background: rgba(28, 35, 48, 0.75);
  transition: background 0.15s;
}

.thumb-btn:hover { background: var(--danger); }

.thumb-remove { right: 6px; }

.thumb-rotate { left: 6px; }
.thumb-rotate:hover { background: var(--accent); }

.hint-text {
  margin: 10px 0 0;
  color: var(--muted);
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  font-size: 14px;
}

.progress-track {
  height: 10px;
  border-radius: 999px;
  background: #e5e7eb;
  overflow: hidden;
}

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

.status { color: var(--muted); font-size: 14px; margin: 10px 0 0; }

.result-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  margin-bottom: 12px;
}

.result-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
  font-weight: 600;
}

.result-head .name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.result-compare {
  display: flex;
  gap: 20px;
  flex-wrap: wrap;
}

.result-fig {
  margin: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.result-fig figcaption {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.result-thumb {
  width: 112px;
  height: 112px;
  object-fit: contain;
  background: #f3f4f6;
  border-radius: 8px;
  border: 1px solid var(--border);
  cursor: zoom-in;
}

.result-thumb:hover { border-color: var(--accent); }

.result-fig a {
  font-size: 13px;
  color: var(--accent);
  text-decoration: none;
  font-weight: 600;
}

.result-fig a:hover { text-decoration: underline; }

.result-card .error { color: var(--danger); font-size: 14px; }

#download-all-button { margin-top: 16px; }

.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  max-width: 90vw;
  padding: 12px 20px;
  border-radius: 8px;
  color: #fff;
  font-weight: 600;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.18);
  z-index: 100;
}

.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(0, 0, 0, 0.88);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.lightbox[hidden] { display: none; }

.lightbox img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: 6px;
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.5);
}

.lightbox-close {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: none;
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
  font-size: 26px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.15s;
}

.lightbox-close:hover { background: rgba(255, 255, 255, 0.3); }

@media (max-width: 480px) {
  .container { padding: 20px 12px 56px; }
}
