:root {
  --bg: #0f172a;
  --panel: #1e293b;
  --border: #334155;
  --text: #e2e8f0;
  --muted: #94a3b8;
  --accent: #38bdf8;
  --accent-dark: #0284c7;
  --danger: #f87171;
  --warning: #fbbf24;
  --ok: #4ade80;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 2rem;
  border-bottom: 1px solid var(--border);
}

header h1 { margin: 0; font-size: 1.4rem; }

.status {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.9rem;
  color: var(--muted);
  cursor: default;
}

.status .dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--muted);
}

.status-ok .dot { background: var(--ok); }
.status-warn .dot { background: var(--warning); }
.status-error .dot { background: var(--danger); }

.disclaimer {
  background: rgba(251, 191, 36, 0.12);
  color: var(--warning);
  border-bottom: 1px solid rgba(251, 191, 36, 0.3);
  padding: 0.6rem 2rem;
  font-size: 0.9rem;
}

main {
  max-width: 1300px;
  margin: 0 auto;
  padding: 1.5rem 2rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1.25rem;
}

.panel h2 { margin: 0 0 0.75rem; font-size: 1.1rem; }

.dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.9rem;
  min-height: 140px;
  border: 2px dashed var(--border);
  border-radius: 10px;
  padding: 1rem;
  text-align: center;
  color: var(--muted);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.dropzone:hover, .dropzone.dragover {
  border-color: var(--accent);
  background: rgba(56, 189, 248, 0.06);
}

.dropzone.has-file { color: var(--text); border-style: solid; }

.dropzone-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.5rem;
}

.dropzone-actions button[hidden] { display: none; }

.field-label {
  display: block;
  margin: 1rem 0 0.4rem;
  font-size: 0.9rem;
  color: var(--muted);
}

textarea {
  width: 100%;
  resize: vertical;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.6rem;
  font: inherit;
}

button {
  margin-top: 1rem;
  background: var(--accent-dark);
  color: white;
  border: none;
  border-radius: 8px;
  padding: 0.65rem 1.5rem;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

button:hover:not(:disabled) { background: var(--accent); color: var(--bg); }
button:disabled { opacity: 0.5; cursor: not-allowed; }

button.secondary {
  margin-top: 0;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.35rem 0.9rem;
  font-weight: 500;
}

.error {
  margin-top: 1rem;
  padding: 0.75rem;
  border-radius: 8px;
  background: rgba(248, 113, 113, 0.12);
  border: 1px solid rgba(248, 113, 113, 0.4);
  color: var(--danger);
}

.loading {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-top: 1rem;
  color: var(--muted);
}

.loading[hidden], .error[hidden], .result[hidden], .progress[hidden], .thumbs[hidden] {
  display: none;
}

.loading-text {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  flex: 1;
}

.progress {
  height: 6px;
  max-width: 400px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  width: 0;
  background: var(--accent);
  transition: width 0.2s;
}

.spinner {
  width: 24px;
  height: 24px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.result {
  display: grid;
  grid-template-columns: minmax(280px, 2fr) 3fr;
  gap: 1.5rem;
}

@media (max-width: 900px) {
  .result { grid-template-columns: 1fr; }
}

.image-panel h3 {
  margin: 1.25rem 0 0.25rem;
  font-size: 0.95rem;
  color: var(--muted);
}

#viewer {
  width: 100%;
  border-radius: 6px;
  background: black;
}

.caption {
  margin: 0.4rem 0 0;
  font-size: 0.85rem;
  color: var(--muted);
}

.thumbs {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(64px, 1fr));
  gap: 0.4rem;
  margin-top: 0.75rem;
}

.thumbs img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: 4px;
  border: 2px solid transparent;
  background: black;
  cursor: pointer;
  opacity: 0.7;
}

.thumbs img:hover { opacity: 1; }
.thumbs img.active { border-color: var(--accent); opacity: 1; }

.metadata {
  width: 100%;
  margin-top: 1rem;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.metadata td, .metadata th {
  padding: 0.3rem 0.4rem;
  border-bottom: 1px solid var(--border);
  text-align: left;
}

.metadata th { color: var(--muted); font-weight: 600; }
.metadata:not(.series) td:first-child { color: var(--muted); width: 45%; }
.metadata.series { margin-top: 0.5rem; }
.metadata.series tr.skipped td { color: var(--muted); }
.metadata.series .note { font-size: 0.78rem; color: var(--muted); }

.report-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.actions { display: flex; gap: 0.5rem; }

.report h1, .report h2, .report h3 {
  color: var(--accent);
  font-size: 1.05rem;
  margin: 1.2rem 0 0.4rem;
}

.report p, .report li { margin: 0.3rem 0; }

.report-info {
  margin-top: 1.5rem;
  font-size: 0.8rem;
  color: var(--muted);
}
