:root {
  --bg-dark: #0b1220;
  --panel-dark: #111a2b;
  --viewport: #070b12;
  --border-dark: #243044;
  --text-light: #e5e7eb;
  --muted: #94a3b8;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --danger: #dc2626;
  --paper: #ffffff;
  --paper-bg: #eef1f5;
  --ink: #111827;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg-dark);
  color: var(--text-light);
  display: flex;
  flex-direction: column;
}

/* ---------- Top bar ---------- */
.topbar {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.75rem 1.25rem;
  background: #0f172a;
  border-bottom: 1px solid var(--border-dark);
  flex-shrink: 0;
}
.brand { display: flex; flex-direction: column; line-height: 1.2; }
.brand .title { font-size: 1.15rem; font-weight: 700; }
.brand .subtitle { font-size: 0.78rem; color: var(--muted); }
.demo-pill {
  margin-left: auto;
  font-size: 0.72rem;
  font-weight: 700;
  color: #fecaca;
  background: rgba(220,38,38,0.15);
  border: 1px solid rgba(220,38,38,0.5);
  padding: 0.25rem 0.6rem;
  border-radius: 999px;
  white-space: nowrap;
}
.icon-btn {
  background: transparent;
  color: var(--text-light);
  border: 1px solid var(--border-dark);
  border-radius: 8px;
  padding: 0.45rem 0.8rem;
  font-size: 0.85rem;
  cursor: pointer;
  white-space: nowrap;
}
.icon-btn:hover { background: rgba(255,255,255,0.06); }

/* ---------- Disclaimer strip ---------- */
.disclaimer {
  background: #fef2f2;
  color: #7f1d1d;
  font-size: 0.78rem;
  text-align: center;
  padding: 0.4rem 1rem;
  border-bottom: 1px solid #fecaca;
  flex-shrink: 0;
}
.disclaimer strong { color: var(--danger); }

/* ---------- Settings ---------- */
.settings {
  background: var(--panel-dark);
  border-bottom: 1px solid var(--border-dark);
  padding: 0.9rem 1.25rem;
  flex-shrink: 0;
}
.settings[hidden] { display: none; }
.settings label { display: block; font-size: 0.8rem; color: var(--muted); margin-bottom: 0.35rem; }
.settings input {
  width: 100%;
  padding: 0.6rem 0.7rem;
  border-radius: 8px;
  border: 1px solid var(--border-dark);
  background: #0b1220;
  color: var(--text-light);
  font-size: 0.95rem;
}
.settings .hint { font-size: 0.72rem; color: var(--muted); margin-top: 0.4rem; }

/* ---------- About (educational, collapsible) ---------- */
.about {
  background: var(--panel-dark);
  border-bottom: 1px solid var(--border-dark);
  padding: 1rem 1.25rem 1.1rem;
  flex-shrink: 0;
  color: var(--text-light);
}
.about[hidden] { display: none; }
.about h3 { margin: 0 0 0.35rem; font-size: 1rem; }
.about > p { margin: 0 0 0.85rem; color: var(--muted); font-size: 0.85rem; max-width: 75ch; line-height: 1.5; }
.about-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 0.9rem 1.6rem;
}
.about-grid h4 { margin: 0 0 0.3rem; font-size: 0.85rem; color: #cbd5e1; }
.about-grid p, .about-grid ol { margin: 0; color: var(--muted); font-size: 0.82rem; line-height: 1.5; }
.about-grid ol { padding-left: 1.1rem; }
.about-grid li { margin-bottom: 0.25rem; }
.about-credit { margin: 0.95rem 0 0; font-size: 0.78rem; color: var(--muted); }
.about-credit a { color: #93c5fd; text-decoration: none; }
.about-credit a:hover { text-decoration: underline; }

/* ---------- Workbench ---------- */
.workbench { display: flex; flex: 1; min-height: 0; }

/* Left: image viewport */
.viewer {
  flex: 0 0 auto;
  width: 46%;
  min-width: 280px;
  background: var(--viewport);
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.dropzone {
  flex: 1;
  margin: 1rem;
  border: 2px dashed var(--border-dark);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  color: var(--muted);
  cursor: pointer;
  overflow: hidden;
  position: relative;
  transition: border-color .15s, background .15s;
  min-height: 0;
}
.dropzone:hover { border-color: #3b4a63; }
.dropzone.dragover { border-color: var(--accent); background: rgba(37,99,235,0.08); }
.dropzone .placeholder { padding: 1.5rem; }
.dropzone .placeholder .big { font-size: 2.5rem; margin-bottom: 0.5rem; }
.dropzone img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  display: block;
}
.dropzone .filename {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  background: rgba(0,0,0,0.55);
  color: var(--text-light);
  font-size: 0.75rem;
  padding: 0.3rem 0.6rem;
  text-align: center;
}

.controls { padding: 0 1rem 1rem; }
.controls label { display: block; font-size: 0.8rem; color: var(--muted); margin-bottom: 0.35rem; }
.controls textarea {
  width: 100%;
  padding: 0.6rem 0.7rem;
  border-radius: 8px;
  border: 1px solid var(--border-dark);
  background: #0b1220;
  color: var(--text-light);
  font-family: inherit;
  font-size: 0.95rem;
  resize: vertical;
}
.ack { display: flex; align-items: flex-start; gap: 0.5rem; margin: 0.75rem 0; }
.ack input { margin-top: 0.15rem; }
.ack label { font-size: 0.78rem; color: var(--muted); margin: 0; }
.btn-primary {
  width: 100%;
  padding: 0.85rem;
  background: var(--accent);
  color: #fff;
  font-size: 1rem;
  font-weight: 600;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: background .2s;
}
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); }
.btn-primary:disabled { background: #475569; cursor: not-allowed; }

/* Divider */
.divider {
  flex: 0 0 6px;
  background: var(--border-dark);
  cursor: col-resize;
  transition: background .15s;
}
.divider:hover, .divider.active { background: var(--accent); }

/* Right: report */
.report {
  flex: 1;
  min-width: 320px;
  background: var(--paper-bg);
  color: var(--ink);
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.report-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1.25rem;
  border-bottom: 1px solid #d8dee9;
  background: #f8fafc;
  flex-shrink: 0;
}
.report-header .label { font-weight: 700; font-size: 0.95rem; letter-spacing: 0.04em; }
.report-header .status { margin-left: 0.75rem; font-size: 0.82rem; color: #64748b; }
.report-header .actions { margin-left: auto; display: flex; gap: 0.5rem; }
.report-header .actions button {
  border: 1px solid #cbd5e1;
  background: #fff;
  color: var(--ink);
  border-radius: 7px;
  padding: 0.4rem 0.8rem;
  font-size: 0.82rem;
  cursor: pointer;
}
.report-header .actions button:hover:not(:disabled) { background: #f1f5f9; }
.report-header .actions button:disabled { opacity: 0.45; cursor: not-allowed; }

.report-body { flex: 1; overflow: auto; padding: 1.5rem; min-height: 0; }
.paper {
  background: var(--paper);
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  box-shadow: 0 4px 14px rgba(15,23,42,0.06);
  padding: 1.75rem;
  max-width: 760px;
  margin: 0 auto;
  min-height: 100%;
}
.report pre {
  white-space: pre-wrap;
  word-wrap: break-word;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 0.92rem;
  line-height: 1.5;
  margin: 0;
  color: #1e293b;
}
.empty-state { color: #64748b; text-align: center; padding: 2.5rem 1rem; max-width: 640px; margin: 0 auto; }
.empty-state .big { font-size: 2.5rem; margin-bottom: 0.5rem; }

/* Educational pipeline shown before a report exists */
.pipeline {
  display: flex;
  align-items: stretch;
  justify-content: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}
.pipeline .step {
  flex: 1 1 140px;
  max-width: 180px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 0.9rem 0.7rem;
}
.pipeline .ico { font-size: 1.6rem; margin-bottom: 0.35rem; }
.pipeline .st { font-weight: 600; color: #334155; font-size: 0.85rem; margin-bottom: 0.2rem; }
.pipeline .sd { font-size: 0.76rem; color: #64748b; line-height: 1.35; }
.pipeline .arrow { display: flex; align-items: center; color: #94a3b8; font-size: 1.2rem; }
.empty-hint { font-size: 0.85rem; color: #64748b; margin-top: 1.25rem; line-height: 1.55; }

/* Loading skeleton */
.skeleton { display: none; }
.skeleton .line {
  height: 0.85rem;
  border-radius: 4px;
  background: linear-gradient(90deg,#e2e8f0 25%,#f1f5f9 37%,#e2e8f0 63%);
  background-size: 400% 100%;
  animation: shimmer 1.3s ease-in-out infinite;
  margin-bottom: 0.7rem;
}
@keyframes shimmer { 0%{background-position:100% 0;} 100%{background-position:0 0;} }

/* ---------- Responsive ---------- */
@media (max-width: 820px) {
  .workbench { flex-direction: column; }
  .viewer { width: auto !important; height: 48vh; min-height: 280px; }
  .report { min-height: 320px; }
  .divider { display: none; }
  .demo-pill { display: none; }
  #aboutToggle { margin-left: auto; }
}
