:root {
  --background: #f6f8fb;
  --card: #ffffff;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --success: #16a34a;
  --text: #111827;
  --muted: #6b7280;
  --border: #e5e7eb;
  --soft-blue: #dbeafe;
  --shadow: 0 20px 48px rgba(17, 24, 39, 0.08);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

html {
  color-scheme: light;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--background);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select {
  font: inherit;
}

.app-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 36px 0 24px;
}

.app-header h1 {
  margin: 4px 0 8px;
  font-size: clamp(2rem, 4vw, 3.4rem);
  line-height: 1.05;
  letter-spacing: 0;
}

.app-header p {
  margin: 0;
  color: var(--muted);
  font-size: 1rem;
}

.eyebrow {
  color: var(--primary) !important;
  font-size: 0.78rem !important;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.privacy-note {
  max-width: 340px;
  padding: 14px 16px;
  border: 1px solid #bbf7d0;
  border-radius: var(--radius);
  background: #f0fdf4;
  color: #14532d;
  font-size: 0.94rem;
  line-height: 1.45;
}

.app-shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto 48px;
}

.workspace-card,
.panel {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card);
  box-shadow: var(--shadow);
}

.workspace-card {
  padding: 18px;
}

.panel {
  padding: 22px;
  box-shadow: none;
}

.panel-grid,
.split-area {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

.position-panel,
.page-editor-panel,
.advanced-panel,
.actions-panel,
.split-area {
  margin-top: 18px;
}

.section-heading {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  margin-bottom: 18px;
}

.section-heading.compact {
  margin-bottom: 12px;
}

.section-heading h2 {
  margin: 0 0 4px;
  font-size: 1.05rem;
  line-height: 1.25;
}

.section-heading p {
  margin: 0;
  color: var(--muted);
  font-size: 0.94rem;
  line-height: 1.45;
}

.step {
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--soft-blue);
  color: var(--primary);
  font-weight: 800;
}

.drop-zone {
  position: relative;
  display: grid;
  place-items: center;
  gap: 8px;
  min-height: 190px;
  padding: 24px;
  border: 1.5px dashed #bfdbfe;
  border-radius: var(--radius);
  background: #f8fbff;
  color: var(--muted);
  text-align: center;
  cursor: pointer;
  transition: border-color 160ms ease, background-color 160ms ease, transform 160ms ease;
}

.drop-zone input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.drop-zone strong {
  color: var(--text);
  font-size: 1.04rem;
}

.drop-zone.dragging {
  border-color: var(--primary);
  background: #eff6ff;
  transform: translateY(-1px);
}

.drop-icon {
  display: grid;
  place-items: center;
  width: 54px;
  height: 54px;
  border-radius: var(--radius);
  background: var(--primary);
  color: #ffffff;
  font-weight: 900;
  font-size: 0.9rem;
}

.image-icon {
  background: var(--success);
}

.file-summary {
  margin-top: 14px;
  display: grid;
  gap: 8px;
  color: var(--muted);
}

.summary-line {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius);
  background: #f9fafb;
  font-size: 0.94rem;
}

.summary-line strong {
  color: var(--text);
}

.page-editor-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
  color: var(--muted);
  font-size: 0.94rem;
  font-weight: 700;
}

.small-button {
  min-height: 38px;
  padding: 0 12px;
  font-size: 0.9rem;
}

.pdf-page-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 10px;
}

.pdf-page-list.empty {
  display: grid;
  place-items: center;
  min-height: 74px;
  border: 1px dashed #cbd5e1;
  border-radius: var(--radius);
  color: var(--muted);
  background: #f9fafb;
}

.pdf-page-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #ffffff;
}

.page-number-pill {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: #eff6ff;
  color: var(--primary);
  font-weight: 900;
}

.page-row-copy {
  min-width: 0;
}

.page-row-copy strong,
.page-row-copy span {
  display: block;
}

.page-row-copy strong {
  color: var(--text);
  font-size: 0.94rem;
}

.page-row-copy span {
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.82rem;
}

.page-row-actions {
  display: flex;
  gap: 4px;
}

.thumbnail-list {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.thumb-card {
  display: grid;
  grid-template-columns: 76px minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #ffffff;
  cursor: grab;
}

.thumb-card.active {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.thumb-card.dragging {
  opacity: 0.55;
}

.thumb-card img {
  width: 76px;
  height: 52px;
  border-radius: 6px;
  object-fit: cover;
  background: #f3f4f6;
}

.thumb-meta {
  min-width: 0;
}

.thumb-meta strong {
  display: block;
  overflow: hidden;
  color: var(--text);
  font-size: 0.95rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.thumb-meta span {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.84rem;
}

.thumb-actions {
  display: flex;
  gap: 4px;
}

.icon-button {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #ffffff;
  color: var(--muted);
  cursor: pointer;
}

.icon-button:hover {
  color: var(--primary);
  border-color: #bfdbfe;
  background: #eff6ff;
}

.icon-button:disabled,
.icon-button:disabled:hover {
  color: #cbd5e1;
  border-color: var(--border);
  background: #f9fafb;
  cursor: not-allowed;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

label span {
  display: block;
  margin-bottom: 7px;
  color: var(--muted);
  font-size: 0.87rem;
  font-weight: 700;
}

input,
select {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #ffffff;
  color: var(--text);
  padding: 0 12px;
}

input:focus,
select:focus,
button:focus-visible,
a:focus-visible,
summary:focus-visible {
  outline: 3px solid rgba(37, 99, 235, 0.22);
  outline-offset: 2px;
}

.preview-stage {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 330px;
  border-radius: var(--radius);
  background: linear-gradient(135deg, #f8fafc 25%, transparent 25%) -12px 0 / 24px 24px,
    linear-gradient(225deg, #f8fafc 25%, transparent 25%) -12px 0 / 24px 24px,
    linear-gradient(315deg, #f8fafc 25%, transparent 25%) 0 0 / 24px 24px,
    linear-gradient(45deg, #f8fafc 25%, #ffffff 25%) 0 0 / 24px 24px;
  border: 1px solid var(--border);
}

.page-preview {
  display: grid;
  place-items: center;
  width: min(84%, 560px);
  max-height: 280px;
  overflow: hidden;
  border-radius: 6px;
  background: #ffffff;
  box-shadow: 0 14px 30px rgba(15, 23, 42, 0.15);
}

.page-preview.empty {
  min-height: 160px;
  border: 1px dashed #cbd5e1;
  color: var(--muted);
  box-shadow: none;
}

.page-preview img {
  width: 100%;
  height: 100%;
  object-fit: fill;
  display: block;
}

.page-preview img.rotated-preview {
  width: 100%;
  height: 100%;
  object-fit: contain;
  transform: rotate(90deg);
}

.badge {
  position: absolute;
  right: 18px;
  top: 18px;
  padding: 7px 10px;
  border-radius: 999px;
  background: var(--success);
  color: #ffffff;
  font-size: 0.75rem;
  font-weight: 900;
}

.image-facts {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin: 14px 0 0;
}

.image-facts div {
  padding: 12px;
  border-radius: var(--radius);
  background: #f9fafb;
}

.image-facts dt {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

.image-facts dd {
  margin: 5px 0 0;
  color: var(--text);
  font-weight: 800;
}

.visual-panel {
  display: flex;
  flex-direction: column;
}

.comparison {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  align-items: end;
  flex: 1;
}

.comparison > div {
  display: grid;
  gap: 10px;
  justify-items: center;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 700;
  text-align: center;
}

.paper {
  display: grid;
  place-items: center;
  width: min(100%, 180px);
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #ffffff;
  box-shadow: 0 14px 30px rgba(15, 23, 42, 0.1);
}

.before-demo {
  aspect-ratio: 1 / 1.42;
  padding: 18px;
}

.after-demo {
  aspect-ratio: 16 / 9;
  padding: 0;
}

.demo-image {
  width: 100%;
  aspect-ratio: 16 / 9;
  border-radius: 3px;
  background: linear-gradient(135deg, #2563eb, #16a34a);
}

.advanced-panel summary {
  cursor: pointer;
  color: var(--text);
  font-weight: 800;
}

.advanced-grid {
  margin-top: 18px;
  align-items: end;
}

.checkbox-line {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
}

.checkbox-line input {
  width: 18px;
  min-height: 18px;
}

.checkbox-line span {
  margin: 0;
}

.actions-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 18px 0 0;
}

.button-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.primary-button,
.secondary-button,
.download-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 46px;
  border-radius: var(--radius);
  padding: 0 18px;
  border: 1px solid transparent;
  font-weight: 800;
  text-decoration: none;
  cursor: pointer;
}

.primary-button,
.download-button {
  background: var(--primary);
  color: #ffffff;
}

.primary-button:hover,
.download-button:hover {
  background: var(--primary-dark);
}

.primary-button:disabled {
  background: #93c5fd;
  cursor: not-allowed;
}

.secondary-button {
  border-color: var(--border);
  background: #ffffff;
  color: var(--text);
}

.status-track {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  color: var(--muted);
  font-size: 0.9rem;
}

.status-pill {
  padding: 7px 10px;
  border-radius: 999px;
  background: #f3f4f6;
}

.status-pill.active {
  background: #dbeafe;
  color: #1e40af;
  font-weight: 800;
}

.status-pill.done {
  background: #dcfce7;
  color: #166534;
  font-weight: 800;
}

.message {
  margin-top: 14px;
  min-height: 24px;
  color: var(--muted);
  font-weight: 700;
}

.message.error {
  color: #b91c1c;
}

.message.success {
  color: #15803d;
}

@media (max-width: 900px) {
  .app-header,
  .panel-grid,
  .split-area,
  .actions-panel {
    grid-template-columns: 1fr;
    flex-direction: column;
    align-items: stretch;
  }

  .form-grid {
    grid-template-columns: 1fr;
  }

  .privacy-note {
    max-width: none;
  }

  .actions-panel {
    display: grid;
  }

  .page-editor-toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .button-row {
    justify-content: stretch;
  }

  .primary-button,
  .secondary-button,
  .download-button {
    flex: 1 1 160px;
  }
}

@media (max-width: 560px) {
  .workspace-card,
  .panel {
    padding: 14px;
  }

  .app-shell,
  .app-header {
    width: min(100% - 20px, 1180px);
  }

  .thumb-card {
    grid-template-columns: 62px minmax(0, 1fr);
  }

  .thumb-card img {
    width: 62px;
    height: 48px;
  }

  .thumb-actions {
    grid-column: 1 / -1;
    justify-content: flex-end;
  }

  .pdf-page-row {
    grid-template-columns: auto minmax(0, 1fr);
  }

  .page-row-actions {
    grid-column: 1 / -1;
    justify-content: flex-end;
  }

  .image-facts,
  .comparison {
    grid-template-columns: 1fr;
  }

  .preview-stage {
    min-height: 250px;
  }
}
