:root {
  --bg: #f7f8fb;
  --surface: #ffffff;
  --field: #ffffff;
  --line: rgba(17, 24, 39, .14);
  --text: #111827;
  --sub: #6f5148;
  --muted: #667085;
  --topbar: #ffffff;
  --primary: #fa9403;
  --primary-strong: #cf6f00;
  --accent: #2563eb;
  --success: #16a34a;
  --danger: #dc2626;
  --shadow: 0 18px 48px rgba(17, 24, 39, .08);
}

html[data-theme="dark"] {
  --bg: #0c0e12;
  --surface: #15171d;
  --field: #0f1117;
  --line: rgba(255, 255, 255, .16);
  --text: #e5e7eb;
  --sub: #d9b8a0;
  --muted: #9ca3af;
  --topbar: #090a0d;
  --primary: #ffad32;
  --primary-strong: #fa9403;
  --accent: #60a5fa;
  --success: #22c55e;
  --danger: #f87171;
  --shadow: none;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
}

.dt-topbar {
  height: 100px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 16px;
  background: var(--topbar);
  border-bottom: 1px solid var(--line);
}

.dt-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.dt-logo {
  display: block;
  flex: 0 1 auto;
}

.dt-logotop {
  width: min(500px, 58vw);
  height: auto;
  display: block;
}

.dt-title {
  color: var(--sub);
  font-weight: 700;
  white-space: nowrap;
}

.dt-actions,
.actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

button,
.dt-secondary-btn,
.download-link {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  border-radius: 8px;
  min-height: 40px;
  padding: 9px 12px;
  font-weight: 800;
  text-decoration: none;
  cursor: pointer;
}

button:not(.dt-secondary-btn) {
  border-color: transparent;
  background: var(--primary);
  color: #17120a;
}

button:hover,
.dt-secondary-btn:hover,
.download-link:hover {
  border-color: var(--primary);
  color: var(--primary-strong);
}

button:not(.dt-secondary-btn):hover {
  background: var(--primary-strong);
  color: #ffffff;
}

button:disabled {
  opacity: .45;
  cursor: not-allowed;
}

.dt-main {
  width: 100%;
  margin: 18px 0;
  padding: 0 14px 40px;
}

.jfp-shell {
  display: flex;
  align-items: flex-start;
  gap: 16px;
}

.jfp-panel {
  flex: 0 0 430px;
  width: 430px;
  order: 2;
}

.jfp-stage {
  flex: 1 1 auto;
  min-width: 0;
  order: 1;
}

.jfp-panel,
.jfp-stage {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
  padding: 14px;
}

.jfp-panel h1,
.jfp-panel h2,
.jfp-stage h2 {
  margin: 0 0 10px;
  color: var(--sub);
  font-weight: 650;
}

.jfp-panel h2 {
  margin-top: 16px;
}

.jfp-row {
  display: grid;
  gap: 10px;
  margin-bottom: 12px;
}

.jfp-row.two {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

label {
  display: block;
  font-size: 12px;
  font-weight: 700;
}

input[type="number"],
input[type="text"],
select {
  width: 100%;
  margin-top: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 10px;
  background: var(--field);
  color: var(--text);
  font-size: 13px;
}

input[type="range"] {
  width: 100%;
  margin-top: 8px;
}

.jfp-mini {
  display: inline-block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

.drop-zone {
  position: relative;
  display: grid;
  place-items: center;
  gap: 8px;
  min-height: 170px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: color-mix(in srgb, var(--accent) 6%, var(--surface));
  padding: 18px;
  cursor: pointer;
  text-align: center;
  transition: background .18s ease, border-color .18s ease, transform .18s ease;
}

.drop-zone.is-dragover {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 14%, var(--surface));
  transform: translateY(-1px);
}

.drop-zone strong {
  color: var(--text);
  font-size: 16px;
  font-weight: 800;
}

.drop-zone span,
.file-name,
.status,
.stage-count,
.meta {
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}

#pdfInput {
  position: absolute;
  inline-size: 1px;
  block-size: 1px;
  opacity: 0;
  pointer-events: none;
}

.file-name {
  min-height: 18px;
  margin-top: 8px;
  overflow-wrap: anywhere;
}

.status {
  min-height: 22px;
  margin: 10px 0 0;
  color: var(--success);
  font-weight: 800;
}

.status.is-error {
  color: var(--danger);
}

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

.stage-count {
  white-space: nowrap;
}

.progress {
  width: 100%;
  height: 8px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--muted) 18%, transparent);
  overflow: hidden;
  margin-bottom: 14px;
}

#progressBar {
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--primary), var(--accent));
  transition: width .18s ease;
}

.preview-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
  min-height: 560px;
}

.empty {
  grid-column: 1 / -1;
  min-height: 540px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  display: grid;
  place-items: center;
  color: var(--muted);
  font-weight: 750;
}

.image-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--field);
  overflow: hidden;
}

.image-card img {
  display: block;
  width: 100%;
  aspect-ratio: 1 / .8;
  object-fit: contain;
  background: #eef1f5;
  border-bottom: 1px solid var(--line);
}

.image-info {
  display: grid;
  gap: 8px;
  padding: 10px;
}

.title {
  font-weight: 850;
  overflow-wrap: anywhere;
}

.download-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 36px;
  font-size: 13px;
}

@media (max-width: 860px) {
  .jfp-shell {
    display: block;
  }

  .jfp-panel {
    width: auto;
    margin-top: 16px;
  }

  .preview-grid {
    min-height: 360px;
  }

  .empty {
    min-height: 340px;
  }
}

@media (max-width: 560px) {
  .dt-topbar {
    height: auto;
    min-height: 86px;
    align-items: flex-start;
    padding-block: 12px;
  }

  .dt-brand {
    align-items: flex-start;
    flex-direction: column;
    gap: 6px;
  }

  .dt-logotop {
    width: min(380px, 68vw);
  }

  .stage-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .jfp-row.two {
    grid-template-columns: 1fr;
  }
}
