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

:root {
  --bg: #0a0a10;
  --bg-card: #141420;
  --bg-hover: #1a1a2a;
  --border: #252536;
  --border-hover: #6366f1;
  --text: #e4e4e7;
  --text-secondary: #9898a8;
  --text-hint: #585868;
  --primary: #6366f1;
  --primary-hover: #818cf8;
  --primary-bg: rgba(99, 102, 241, 0.12);
  --danger: #ef4444;
  --danger-bg: rgba(239, 68, 68, 0.12);
  --success: #22c55e;
  --success-bg: rgba(34, 197, 94, 0.1);
  --warning: #f59e0b;
  --radius: 10px;
  --radius-sm: 6px;
}

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

body {
  display: flex;
  justify-content: center;
  min-height: 100vh;
  padding: 0 16px;
}

.app {
  width: 100%;
  max-width: 520px;
  padding: 48px 0 80px;
}

/* ── Header ── */
.header {
  text-align: center;
  margin-bottom: 32px;
}

.header h1 {
  font-size: 26px;
  font-weight: 800;
  background: linear-gradient(135deg, var(--primary), #a78bfa);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 6px;
}

.subtitle {
  font-size: 13px;
  color: var(--text-hint);
  line-height: 1.5;
}

/* ── Section ── */
.section {
  margin-bottom: 20px;
}

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

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  border-radius: 11px;
  background: var(--primary-bg);
  color: var(--primary);
  font-size: 12px;
  font-weight: 600;
}

/* ── Drop zone ── */
.drop-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 36px 20px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
}

.drop-zone:hover,
.drop-zone.drag-over {
  border-color: var(--primary);
  background: var(--primary-bg);
}

.dz-icon {
  width: 40px;
  height: 40px;
  color: var(--text-hint);
  margin-bottom: 10px;
  transition: color 0.2s;
}

.drop-zone:hover .dz-icon,
.drop-zone.drag-over .dz-icon {
  color: var(--primary);
}

.dz-text {
  font-size: 15px;
  font-weight: 500;
  margin-bottom: 4px;
}

.dz-hint {
  font-size: 12px;
  color: var(--text-hint);
}

.drop-actions {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 8px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
  font-family: inherit;
}

.btn:hover:not(:disabled) {
  border-color: var(--border-hover);
  background: var(--primary-bg);
}

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

.btn-sm {
  padding: 5px 12px;
  font-size: 12px;
}

.btn-xl {
  width: 100%;
  padding: 12px 20px;
  font-size: 15px;
  border-radius: var(--radius);
}

.btn-ghost {
  background: transparent;
  border-color: transparent;
}

.btn-ghost:hover:not(:disabled) {
  background: var(--bg-hover);
  border-color: var(--border);
}

.btn-danger:hover:not(:disabled) {
  color: var(--danger);
  border-color: var(--danger);
  background: var(--danger-bg);
}

.btn-primary {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
  font-weight: 600;
}

.btn-primary:hover:not(:disabled) {
  background: var(--primary-hover);
  border-color: var(--primary-hover);
}

.btn-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.btn-wrap {
  margin-top: 24px;
}

/* ── Image list ── */
.image-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.image-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: grab;
  transition: border-color 0.15s, opacity 0.15s;
}

.image-item:hover {
  border-color: var(--primary);
}

.image-item.dragging {
  opacity: 0.4;
  border-color: var(--primary);
}

.image-item.drag-over {
  border-color: var(--primary);
  background: var(--primary-bg);
}

.image-item .idx-badge {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--primary-bg);
  color: var(--primary);
  font-size: 11px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

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

.image-item .info .name {
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.image-item .info .meta {
  font-size: 11px;
  color: var(--text-hint);
  margin-top: 1px;
}

.remove-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--text-hint);
  cursor: pointer;
  flex-shrink: 0;
  transition: all 0.15s;
}

.remove-btn:hover {
  background: var(--danger-bg);
  color: var(--danger);
}

.order-hint {
  font-size: 11px;
  color: var(--text-hint);
  margin-top: 8px;
  text-align: center;
}

/* ── Settings ── */
.settings-details {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.settings-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  user-select: none;
  list-style: none;
}

.settings-summary::-webkit-details-marker {
  display: none;
}

.settings-details[open] .settings-summary {
  border-bottom: 1px solid var(--border);
}

.settings-details[open] .chevron {
  transform: rotate(180deg);
}

.chevron {
  width: 16px;
  height: 16px;
  color: var(--text-hint);
  transition: transform 0.2s;
}

.settings-body {
  padding: 16px;
  background: var(--bg-card);
}

.setting-row {
  margin-bottom: 14px;
}

.setting-row:last-child {
  margin-bottom: 0;
}

.setting-label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

.setting-label .unit {
  font-weight: 400;
  color: var(--text-hint);
}

.input {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text);
  font-size: 13px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s;
  -webkit-appearance: none;
  appearance: none;
}

.input:focus {
  border-color: var(--border-hover);
}

select.input {
  cursor: pointer;
}

.setting-hint {
  font-size: 11px;
  color: var(--text-hint);
  margin-top: 3px;
}

/* ── Result ── */
.result {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px 24px;
  text-align: center;
  margin-top: 24px;
}

.result-icon-wrap {
  margin-bottom: 12px;
}

.result-icon {
  width: 40px;
  height: 40px;
  color: var(--success);
}

.result-title {
  font-size: 17px;
  font-weight: 600;
  margin-bottom: 16px;
}

.result-stats {
  display: flex;
  justify-content: center;
  gap: 24px;
  margin-bottom: 12px;
}

.stat-item {
  text-align: center;
}

.stat-value {
  font-size: 22px;
  font-weight: 700;
  color: var(--primary);
}

.stat-label {
  font-size: 11px;
  color: var(--text-hint);
  margin-top: 2px;
}

.result-matches {
  font-size: 12px;
  color: var(--text-hint);
  line-height: 1.7;
  margin-bottom: 8px;
  text-align: left;
  padding: 10px 14px;
  background: var(--bg);
  border-radius: var(--radius-sm);
  font-family: "SF Mono", "Fira Code", monospace;
}

.result-matches .low-conf {
  color: var(--warning);
}

/* ── Progress ── */
.progress-wrap {
  margin-top: 20px;
  text-align: center;
}

.progress-bar {
  width: 100%;
  height: 4px;
  border-radius: 2px;
  background: var(--border);
  overflow: hidden;
  margin-bottom: 8px;
}

.progress-fill {
  height: 100%;
  border-radius: 2px;
  background: var(--primary);
  width: 0%;
  transition: width 0.3s ease;
}

.progress-text {
  font-size: 12px;
  color: var(--text-hint);
}

/* ── Scrollbar ── */
::-webkit-scrollbar {
  width: 5px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--text-hint);
}

/* ── Responsive ── */
@media (max-width: 540px) {
  .app {
    padding: 32px 0 60px;
  }
  .header h1 {
    font-size: 22px;
  }
  .result-stats {
    gap: 16px;
  }
}
