:root {
  --bg: #f4f5f7;
  --card: #ffffff;
  --text: #1a1d23;
  --text-muted: #6b7280;
  --border: #e2e4e9;
  --accent: #6d5efc;
  --accent-hover: #5a4be0;
  --accent-soft: #f0eeff;
  --success: #16a34a;
  --danger: #dc2626;
  --radius: 14px;
  --radius-sm: 10px;
}

* { box-sizing: border-box; }

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

.wrap {
  max-width: 720px;
  margin: 0 auto;
  padding: 28px 20px 60px;
}

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

.header .sub {
  color: var(--text-muted);
  margin: 0 0 24px;
  font-size: 15px;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 20px;
}

.card h2 {
  font-size: 17px;
  margin: 0 0 14px;
}

.drop-zone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 2px dashed var(--border);
  border-radius: var(--radius-sm);
  padding: 36px 20px;
  cursor: pointer;
  text-align: center;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.drop-zone:hover,
.drop-zone.dragover {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.drop-zone__icon { font-size: 36px; }

.drop-zone__text {
  font-weight: 600;
  font-size: 15px;
}

.drop-zone__hint {
  color: var(--text-muted);
  font-size: 13px;
}

.advanced {
  margin-top: 16px;
}

.advanced summary {
  cursor: pointer;
  font-size: 14px;
  color: var(--text-muted);
  user-select: none;
}

.advanced__grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  margin-top: 12px;
}

.advanced__grid label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  color: var(--text-muted);
}

.advanced__grid input {
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  color: var(--text);
}

.btn-primary {
  width: 100%;
  margin-top: 18px;
  padding: 14px 20px;
  border: none;
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: #fff;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.1s ease;
}

.btn-primary:hover:not(:disabled) { background: var(--accent-hover); }
.btn-primary:active:not(:disabled) { transform: scale(0.99); }
.btn-primary:disabled {
  background: #c9cbd3;
  cursor: not-allowed;
}

.btn-secondary {
  display: inline-block;
  margin-top: 14px;
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
  font-size: 14px;
  text-decoration: none;
}

.btn-secondary:hover { background: #e5e1ff; }

.status {
  margin-top: 16px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  font-size: 14px;
}

.status.loading {
  background: var(--accent-soft);
  color: var(--accent);
}

.status.error {
  background: #fee2e2;
  color: var(--danger);
}

.status.success {
  background: #dcfce7;
  color: var(--success);
}

.result {
  margin-top: 20px;
  text-align: center;
}

.result img {
  max-width: 100%;
  max-height: 320px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: repeating-conic-gradient(#f0f0f0 0% 25%, #fff 0% 50%) 50% / 16px 16px;
}

.result__info {
  margin-top: 10px;
  color: var(--text-muted);
  font-size: 13px;
}

.gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  gap: 12px;
}

.gallery__item {
  display: block;
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  text-decoration: none;
  color: var(--text-muted);
  font-size: 11px;
  background: #fafafa;
}

.gallery__item img {
  width: 100%;
  height: 90px;
  object-fit: cover;
  display: block;
  background: repeating-conic-gradient(#f0f0f0 0% 25%, #fff 0% 50%) 50% / 12px 12px;
}

.gallery__item span {
  display: block;
  padding: 6px 8px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.empty-hint {
  color: var(--text-muted);
  font-size: 14px;
  margin: 0;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1115;
    --card: #171a21;
    --text: #e8e9ec;
    --text-muted: #9aa0ac;
    --border: #2a2d36;
    --accent-soft: #232047;
  }
  .result img,
  .gallery__item img {
    background: repeating-conic-gradient(#20222a 0% 25%, #171a21 0% 50%) 50% / 16px 16px;
  }
}
