:root {
  --ink: var(--tools-text);
  --muted: var(--tools-muted);
  --paper: var(--tools-bg);
  --surface: var(--tools-surface);
  --surface-soft: var(--tools-surface-soft);
  --line: var(--tools-line);
  --green: var(--tools-green);
  --green-strong: var(--tools-green-strong);
  --green-soft: var(--tools-green-soft);
  --red: var(--tools-red);
  color: var(--ink);
  background: var(--paper);
  font-family: var(--tools-sans);
  font-synthesis: none;
  text-rendering: optimizeLegibility;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  min-height: 100vh;
  margin: 0;
  background:
    radial-gradient(circle at 13% 12%, color-mix(in srgb, var(--green) 8%, transparent), transparent 27rem),
    var(--paper);
}
button, input, select { font: inherit; }
button, select, input[type="checkbox"] { cursor: pointer; }
button:disabled, select:disabled, input:disabled { cursor: not-allowed; opacity: .62; }
a { color: inherit; }
[v-cloak] { display: none; }

.visually-hidden {
  position: fixed;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  clip-path: inset(50%);
  white-space: nowrap;
}

main {
  width: min(1040px, calc(100% - 40px));
  margin: 0 auto;
}

.hero {
  max-width: 850px;
  margin: 42px auto 52px;
  text-align: center;
}

.eyebrow,
.step-label {
  margin: 0 0 12px;
  color: var(--green-strong);
  font: 700 .72rem/1.3 var(--tools-mono);
  letter-spacing: .11em;
  text-transform: uppercase;
}

.hero h1 {
  max-width: 760px;
  margin: 0 auto;
  font: 500 clamp(2.3rem, 6vw, 4.7rem)/.98 var(--tools-serif);
  letter-spacing: -.045em;
}

.hero-copy {
  max-width: 700px;
  margin: 22px auto 0;
  color: var(--muted);
  font-size: clamp(1rem, 2vw, 1.16rem);
  line-height: 1.65;
}

.hero-proof {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  margin: 24px 0 0;
  padding: 0;
  list-style: none;
}

.hero-proof li {
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  color: var(--muted);
  font-size: .88rem;
  font-weight: 650;
}

.workspace {
  margin-bottom: 72px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--tools-radius);
  background: color-mix(in srgb, var(--surface) 96%, transparent);
  box-shadow: var(--tools-shadow);
}

.workflow-section,
.export-panel,
.privacy-note {
  padding: clamp(20px, 4vw, 34px);
}

.workflow-section + .workflow-section,
.export-panel,
.privacy-note {
  border-top: 1px solid var(--line);
}

.section-heading {
  max-width: 760px;
  margin-bottom: 22px;
}

.section-heading h2,
.export-panel h2 {
  margin: 0;
  font: 600 clamp(1.45rem, 3vw, 2rem)/1.15 var(--tools-serif);
  letter-spacing: -.025em;
}

.section-heading > p:last-child,
.section-heading > div > p:last-child,
.export-panel p,
.privacy-note p {
  margin: 8px 0 0;
  color: var(--muted);
  line-height: 1.55;
}

.split-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  max-width: none;
}

.drop-zone {
  display: grid;
  justify-items: center;
  gap: 10px;
  min-height: 176px;
  padding: 28px 20px;
  border: 1.5px dashed color-mix(in srgb, var(--green) 62%, var(--line));
  border-radius: 16px;
  background: color-mix(in srgb, var(--green-soft) 40%, var(--surface));
  text-align: center;
}

.drop-zone p { margin: 2px 0 0; color: var(--muted); }
.drop-zone small { color: var(--muted); line-height: 1.45; }

.primary-button,
.secondary-button,
.quiet-button {
  min-height: 44px;
  padding: 10px 15px;
  border-radius: 12px;
  font-weight: 700;
  line-height: 1.15;
}

.primary-button {
  border: 1px solid var(--green-strong);
  background: var(--tools-action);
  color: var(--tools-on-action);
  box-shadow: 0 7px 18px color-mix(in srgb, var(--green) 18%, transparent);
}

.secondary-button {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
}

.quiet-button {
  border: 1px solid color-mix(in srgb, var(--line) 82%, transparent);
  background: transparent;
  color: var(--ink);
}

.primary-button:hover:not(:disabled) { background: var(--tools-action-hover); }
.secondary-button:hover:not(:disabled),
.quiet-button:hover:not(:disabled) { background: var(--surface-soft); }

button:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--green) 52%, transparent);
  outline-offset: 2px;
}

.destructive-text { color: var(--red); }

.busy-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 14px;
  padding: 12px 14px;
  border-radius: 12px;
  background: var(--surface-soft);
  color: var(--muted);
}

.image-list {
  display: grid;
  gap: 12px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.image-item {
  display: grid;
  grid-template-columns: 112px minmax(0, 1fr);
  gap: 16px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
}

.image-item.has-error {
  border-color: color-mix(in srgb, var(--red) 42%, var(--line));
}

.image-item.is-removed { display: block; }

.thumb-wrap {
  display: grid;
  place-items: center;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 10px;
  background:
    linear-gradient(45deg, color-mix(in srgb, var(--line) 45%, transparent) 25%, transparent 25% 75%, color-mix(in srgb, var(--line) 45%, transparent) 75%),
    linear-gradient(45deg, color-mix(in srgb, var(--line) 45%, transparent) 25%, transparent 25% 75%, color-mix(in srgb, var(--line) 45%, transparent) 75%);
  background-position: 0 0, 6px 6px;
  background-size: 12px 12px;
}

.thumb-wrap img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.thumb-placeholder {
  width: 36px;
  height: 28px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-soft);
}

.item-main { min-width: 0; }
.item-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 7px 10px;
}
.filename {
  min-width: 0;
  max-width: 100%;
  overflow-wrap: anywhere;
}
.item-meta small { color: var(--muted); }

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 3px 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-soft);
  color: var(--muted);
  font-size: .78rem;
  font-weight: 700;
}
.status-ready { color: var(--tools-green-text); background: var(--green-soft); }
.status-corrupt,
.status-unsupported,
.status-cancelled { color: var(--red); }

.item-error,
.blocking-note,
.layout-error {
  color: var(--red);
}

.item-error {
  margin: 8px 0 0;
  font-size: .92rem;
  line-height: 1.4;
}

.caption-field,
.settings-grid label,
.margin-grid label,
.caption-settings > label:not(.check-row) {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: .87rem;
  font-weight: 700;
}

.caption-field { margin-top: 12px; }

input[type="text"],
input[type="number"],
select {
  width: 100%;
  min-width: 0;
  min-height: 44px;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  color: var(--ink);
}

.item-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.removed-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}
.removed-row > div { display: grid; gap: 3px; min-width: 0; }
.removed-row strong { overflow-wrap: anywhere; }
.removed-row span { color: var(--muted); font-size: .9rem; }

.blocking-note {
  margin: 14px 0 0;
  padding: 12px 14px;
  border: 1px solid color-mix(in srgb, var(--red) 38%, var(--line));
  border-radius: 12px;
  background: color-mix(in srgb, var(--red) 7%, var(--surface));
  line-height: 1.45;
}

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

.unit-field {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
}
.unit-field > span:last-child {
  color: var(--muted);
  font: 600 .8rem/1 var(--tools-mono);
}

.margin-fieldset {
  margin: 22px 0 0;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
}
.margin-fieldset legend {
  padding: 0 7px;
  font-weight: 700;
}
.margin-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.caption-settings {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(150px, .6fr);
  align-items: end;
  gap: 14px;
  margin-top: 18px;
}

.check-row {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-soft);
  font-weight: 700;
}
.check-row input {
  width: 20px;
  height: 20px;
  accent-color: var(--green-strong);
}
.muted { opacity: .68; }
.settings-note {
  margin: 13px 0 0;
  color: var(--muted);
  font-size: .9rem;
  line-height: 1.45;
}

.layout-error,
.preview-empty {
  display: grid;
  gap: 5px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface-soft);
}
.layout-error { border-color: color-mix(in srgb, var(--red) 40%, var(--line)); }
.preview-empty p { margin: 0; color: var(--muted); }

.page-stack {
  display: grid;
  gap: 24px;
  justify-items: center;
}
.page-preview {
  width: min(100%, 690px);
  margin: 0;
}
.page-canvas {
  display: block;
  width: 100%;
  height: auto;
  border: 1px solid color-mix(in srgb, var(--line) 82%, var(--ink));
  border-radius: 3px;
  background: #fff;
  box-shadow: 0 12px 30px rgb(0 0 0 / 12%);
}
.page-preview figcaption {
  margin-top: 8px;
  color: var(--muted);
  font-size: .85rem;
  text-align: center;
}

.export-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
  gap: 18px 28px;
  background: color-mix(in srgb, var(--green-soft) 30%, var(--surface));
}
.export-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 9px;
}
.export-note {
  grid-column: 1 / -1;
  margin-top: -7px !important;
  font-size: .88rem;
}
.export-note + .export-note { margin-top: -16px !important; }

.privacy-note {
  background: var(--surface-soft);
}
.privacy-note strong { display: block; }

.toast {
  position: fixed;
  z-index: 30;
  right: 20px;
  bottom: 20px;
  max-width: min(420px, calc(100vw - 40px));
  padding: 12px 15px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--ink);
  color: var(--paper);
  box-shadow: var(--tools-shadow);
  font-weight: 700;
}

.print-root { display: none; }

@media (max-width: 760px) {
  main { width: min(100% - 24px, 1040px); }
  .hero { margin: 32px auto 38px; }
  .workspace { margin-bottom: 48px; }
  .settings-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .margin-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .caption-settings { grid-template-columns: 1fr; }
  .image-item { grid-template-columns: 86px minmax(0, 1fr); }
  .export-panel { grid-template-columns: 1fr; }
  .export-actions { justify-content: flex-start; }
}

@media (max-width: 480px) {
  .workflow-section,
  .export-panel,
  .privacy-note { padding: 18px 14px; }
  .split-heading { display: grid; }
  .settings-grid,
  .margin-grid { grid-template-columns: 1fr; }
  .image-item { grid-template-columns: 1fr; }
  .thumb-wrap { max-width: 190px; }
  .removed-row { align-items: flex-start; }
  .item-actions > button,
  .export-actions > button { flex: 1 1 140px; }
  .busy-row { align-items: flex-start; flex-direction: column; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}

@media print {
  html, body {
    width: auto;
    min-height: 0;
    margin: 0;
    padding: 0;
    background: #fff;
  }
  body > :not(#app),
  #app > :not(.print-root) { display: none !important; }
  .print-root {
    display: block !important;
    margin: 0;
    padding: 0;
  }
  .print-page {
    display: block;
    margin: 0;
    padding: 0;
    overflow: hidden;
    break-after: page;
    page-break-after: always;
    background: #fff;
  }
  .print-page:last-child {
    break-after: auto;
    page-break-after: auto;
  }
  .print-page canvas {
    display: block;
    margin: 0;
    padding: 0;
  }
}
