:root {
  --bg: #f3f1ec;
  --panel: #ffffff;
  --ink: #171717;
  --muted: #696969;
  --line: #d7d2c8;
  --accent: #111111;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--ink);
}

.app-header {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  padding: 24px 32px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
  position: sticky;
  top: 0;
  z-index: 10;
}

h1, h2, p { margin-top: 0; }
h1 { font-size: 28px; margin-bottom: 6px; }
h2 { font-size: 16px; margin-bottom: 12px; }
p { color: var(--muted); line-height: 1.45; }

button, select, input {
  font: inherit;
  border: 1px solid var(--line);
  background: white;
  color: var(--ink);
  border-radius: 10px;
  padding: 10px 12px;
}
button { cursor: pointer; }
input { width: 100%; }
button.primary { background: var(--accent); color: white; border-color: var(--accent); }
.header-actions { display: flex; align-items: center; gap: 10px; }

.app-shell {
  display: grid;
  grid-template-columns: 310px minmax(520px, 1fr) minmax(420px, 0.75fr);
  gap: 18px;
  padding: 18px;
}

.panel, .workspace, .print-cover {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 18px;
}

.panel section + section { margin-top: 24px; padding-top: 22px; border-top: 1px solid var(--line); }
label { display: grid; gap: 6px; margin-bottom: 12px; color: var(--muted); font-size: 14px; }
.hint { font-size: 13px; }
.small-list { padding-left: 20px; color: var(--muted); line-height: 1.45; font-size: 14px; }
.control-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.drop-zone {
  border: 2px dashed var(--line);
  border-radius: 14px;
  min-height: 120px;
  display: grid;
  place-items: center;
  text-align: center;
  padding: 18px;
  cursor: pointer;
  background: #faf9f6;
}
.drop-zone span { display: block; color: var(--muted); margin-top: 4px; }
.drop-zone.dragover { border-color: var(--accent); background: #fff; }

.workspace-header { display: flex; justify-content: space-between; gap: 18px; }
.pages-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
}
.page-card {
  background: #faf9f6;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px;
}
.page-card-top {
  display: grid;
  gap: 8px;
  margin-bottom: 10px;
}
.page-label { font-size: 14px; }
.page-label.cover { font-weight: 800; }
.layout-select { width: 100%; font-size: 13px; padding: 8px; }

.swap-button {
  width: 100%;
  margin-top: 10px;
  padding: 8px 10px;
  font-size: 13px;
  background: #ffffff;
}
.swap-button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.mini-page {
  position: relative;
  aspect-ratio: 148 / 210;
  background: white;
  border: 1px solid #c8c3ba;
  display: grid;
  overflow: hidden;
}
.slot {
  position: relative;
  display: grid;
  place-items: center;
  overflow: hidden;
  border: 1px dashed #d0d0d0;
  background: #f8f8f8;
  color: #9a9a9a;
  font-size: 12px;
  text-align: center;
}
.slot img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.slot.contain img { object-fit: contain; background: white; }
.slot.has-image { border: none; background: white; }
.slot input { display: none; }
.slot .remove {
  position: absolute;
  top: 6px;
  right: 6px;
  border-radius: 999px;
  padding: 3px 6px;
  font-size: 11px;
  background: rgba(255,255,255,0.85);
}

.cover-text {
  position: absolute;
  inset: 8%;
  z-index: 4;
  display: flex;
  flex-direction: column;
  gap: 0.35em;
  color: #111;
  text-shadow: 0 1px 2px rgba(255,255,255,0.55);
  pointer-events: none;
  line-height: 1.1;
}

.cover-color-black { color: #111; text-shadow: 0 1px 2px rgba(255,255,255,0.55); }
.cover-color-white { color: #fff; text-shadow: 0 1px 3px rgba(0,0,0,0.7); }
.cover-font-clean { font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; }
.cover-font-serif { font-family: Georgia, "Times New Roman", serif; }
.cover-font-mono { font-family: "Courier New", Courier, monospace; }
.cover-font-condensed { font-family: Impact, "Arial Narrow", "Helvetica Neue Condensed", sans-serif; letter-spacing: 0.015em; }
.cover-font-rugged { font-family: Rockwell, "Arial Black", Georgia, serif; letter-spacing: 0.01em; text-transform: uppercase; }

.cover-h-left { text-align: left; align-items: flex-start; }
.cover-h-center { text-align: center; align-items: center; }
.cover-h-right { text-align: right; align-items: flex-end; }
.cover-v-top { justify-content: flex-start; }
.cover-v-center { justify-content: center; }
.cover-v-bottom { justify-content: flex-end; }
.cover-line { max-width: 100%; }
.cover-title.small { font-size: clamp(13px, 1.6vw, 24px); }
.cover-title.medium { font-size: clamp(18px, 2.4vw, 38px); }
.cover-title.large { font-size: clamp(24px, 3.3vw, 58px); }
.cover-subtitle.small, .cover-author.small { font-size: clamp(9px, 0.9vw, 16px); }
.cover-subtitle.medium, .cover-author.medium { font-size: clamp(12px, 1.2vw, 22px); }
.cover-subtitle.large, .cover-author.large { font-size: clamp(16px, 1.7vw, 30px); }
.cover-title { font-weight: 750; letter-spacing: -0.03em; }
.cover-subtitle { font-weight: 400; }
.cover-author { font-weight: 600; margin-top: 0.5em; }
.mini-page .cover-text { inset: 9%; }
.mini-page .cover-title.small { font-size: 13px; }
.mini-page .cover-title.medium { font-size: 19px; }
.mini-page .cover-title.large { font-size: 27px; }
.mini-page .cover-subtitle.small, .mini-page .cover-author.small { font-size: 9px; }
.mini-page .cover-subtitle.medium, .mini-page .cover-author.medium { font-size: 12px; }
.mini-page .cover-subtitle.large, .mini-page .cover-author.large { font-size: 16px; }

.layout-single-bleed { padding: 0; grid-template-columns: 1fr; grid-template-rows: 1fr; }
.layout-single-bleed .slot { border: 0; background: transparent; }
.layout-single-bleed .slot.has-image { border: 0; }
.layout-single-bleed .slot img { width: 100%; height: 100%; object-fit: cover; }
.layout-single-border { padding: 7%; grid-template-columns: 1fr; }
.layout-two-stack { padding: 5%; gap: 5%; grid-template-rows: 1fr 1fr; }
.layout-two-side { padding: 5%; gap: 5%; grid-template-columns: 1fr 1fr; }

.print-area { min-width: 0; }
.sheet {
  background: white;
  border: 1px solid var(--line);
  margin: 0 0 18px;
  padding: 10px;
  border-radius: 14px;
}
.sheet-title {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 8px;
}
.sheet-paper {
  aspect-ratio: 297 / 210;
  display: grid;
  grid-template-columns: 1fr 1fr;
  border: 1px solid #aaa;
  background: white;
}
.print-page {
  position: relative;
  overflow: hidden;
  border-right: 1px solid #aaa;
  display: grid;
  background: white;
}
.print-page:last-child { border-right: 0; }
.print-page-number {
  position: absolute;
  top: 6px;
  left: 8px;
  z-index: 5;
  background: rgba(255,255,255,0.88);
  border: 1px solid #ddd;
  border-radius: 999px;
  padding: 3px 7px;
  font-size: 11px;
}
.proof-placeholder {
  display: grid;
  place-items: center;
  height: 100%;
  font-size: 34px;
  font-weight: 700;
  color: #444;
  background: repeating-linear-gradient(45deg, #fafafa 0, #fafafa 12px, #f0f0f0 12px, #f0f0f0 24px);
}
.fold-line {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 0;
  border-left: 1px dashed #777;
  z-index: 10;
}

@media print {
  @page { size: A4 landscape; margin: 0; }
  body { background: white; }
  .no-print { display: none !important; }
  .app-shell { display: block; padding: 0; }
  .print-area { display: block; }
  .sheet {
    break-after: page;
    page-break-after: always;
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: 0;
  }
  .sheet-title { display: none; }
  .sheet-paper {
    width: 297mm;
    height: 210mm;
    aspect-ratio: auto;
    border: none;
  }
  .print-page { border-right: 0; }
  .print-page-number { display: none; }
  .fold-line { border-left: 0.25pt dashed #999; }
  .print-page .cover-title.small { font-size: 18pt; }
  .print-page .cover-title.medium { font-size: 28pt; }
  .print-page .cover-title.large { font-size: 42pt; }
  .print-page .cover-subtitle.small, .print-page .cover-author.small { font-size: 10pt; }
  .print-page .cover-subtitle.medium, .print-page .cover-author.medium { font-size: 14pt; }
  .print-page .cover-subtitle.large, .print-page .cover-author.large { font-size: 20pt; }
}


/* v5 fix: make full-bleed pages truly edge-to-edge in preview and print */
.mini-page.layout-single-bleed,
.print-page.layout-single-bleed {
  display: block;
  padding: 0;
}

.mini-page.layout-single-bleed > .slot,
.print-page.layout-single-bleed > .slot {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  border: 0;
  display: block;
  background: transparent;
}

.mini-page.layout-single-bleed > .slot img,
.print-page.layout-single-bleed > .slot img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  max-width: none;
  max-height: none;
  object-fit: cover;
  display: block;
}

.mini-page.layout-single-bleed > .slot:not(.has-image),
.print-page.layout-single-bleed > .slot:not(.has-image) {
  display: grid;
  place-items: center;
}

/* v11 refinement: reading-order spreads and cleaner output */
.reading-layout {
  display: grid;
  gap: 18px;
}

.cover-row {
  display: flex;
  justify-content: center;
}
.cover-row .page-card {
  width: min(260px, 100%);
}
.back-cover-row {
  margin-top: 4px;
}

.reading-spread {
  background: #faf9f6;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 12px;
}
.spread-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
  font-size: 14px;
}
.spread-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.small-action {
  padding: 7px 9px;
  border-radius: 999px;
  font-size: 12px;
}
.spread-body {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
  align-items: start;
  background: #111;
  padding: 0;
  border-radius: 12px;
  overflow: hidden;
}
.spread-body .page-card {
  border-radius: 0;
  border: 0;
  background: #faf9f6;
}
.spread-body .page-card:first-child {
  border-right: 1px solid #111;
}
.spread-image-preview {
  grid-column: 1 / -1;
  position: relative;
  aspect-ratio: 296 / 210;
  background: #f8f8f8;
  color: #8a8a8a;
  display: grid;
  place-items: center;
  text-align: center;
  font-size: 14px;
  cursor: pointer;
  overflow: hidden;
}
.spread-image-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.spread-image-preview.dragover {
  outline: 3px solid #111;
  outline-offset: -3px;
}

.sheet-paper {
  border: 0;
  background: #111;
}
.print-page {
  border-right: 0;
}
.fold-line {
  display: none !important;
}

.cover-font-film { font-family: "Bodoni 72", Didot, Georgia, serif; letter-spacing: -0.04em; }
.cover-font-deco { font-family: Copperplate, "Avenir Next Condensed", Impact, sans-serif; letter-spacing: 0.08em; text-transform: uppercase; }
.cover-font-hand { font-family: "Marker Felt", "Chalkboard SE", "Bradley Hand", cursive; letter-spacing: 0.01em; }
.cover-font-rugged { font-family: Rockwell, "American Typewriter", Georgia, serif; letter-spacing: 0.02em; text-transform: uppercase; }

@media (max-width: 1200px) {
  .app-shell {
    grid-template-columns: 300px minmax(420px, 1fr);
  }
  .print-area {
    grid-column: 2;
  }
}


/* v13 refinement: spread image can be full bleed or bordered */
.spread-image-preview.spread-border {
  background: #ffffff;
  padding: 7%;
}
.spread-image-preview.spread-border img {
  object-fit: contain;
  background: #ffffff;
}
.spread-image-preview.spread-bleed {
  background: #111111;
  padding: 0;
}


/* v14: back cover text and QR options */
.back-cover-controls {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}
.back-cover-controls h3 {
  margin: 0 0 12px;
  font-size: 14px;
}
.checkbox-label {
  display: flex;
  align-items: center;
  grid-template-columns: none;
  gap: 9px;
  color: var(--ink);
}
.checkbox-label input {
  width: auto;
}
.back-cover-line.small { font-size: clamp(10px, 1vw, 18px); }
.back-cover-line.medium { font-size: clamp(14px, 1.4vw, 26px); }
.back-cover-line.large { font-size: clamp(18px, 2vw, 38px); }
.mini-page .back-cover-line.small { font-size: 10px; }
.mini-page .back-cover-line.medium { font-size: 14px; }
.mini-page .back-cover-line.large { font-size: 19px; }
.back-cover-qr {
  width: min(74px, 22%);
  height: auto;
  margin-top: 0.7em;
  background: #fff;
  padding: 3px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.18);
}
.cover-h-left .back-cover-qr { align-self: flex-start; }
.cover-h-center .back-cover-qr { align-self: center; }
.cover-h-right .back-cover-qr { align-self: flex-end; }
.print-page .back-cover-line.small { font-size: 10pt; }
.print-page .back-cover-line.medium { font-size: 15pt; }
.print-page .back-cover-line.large { font-size: 22pt; }
.print-page .back-cover-qr { width: 15%; }


/* v15: Step 1 interface polish */
:root {
  --bg: #ede8de;
  --paper: #f7f2e8;
  --panel: #fffdf8;
  --ink: #171512;
  --muted: #6f675b;
  --line: #d7cdbd;
  --line-strong: #b9ad9c;
  --accent: #16130f;
  --soft: #fbf7ef;
  --shadow: 0 18px 40px rgba(31, 25, 18, 0.08);
}

body {
  background:
    radial-gradient(circle at top left, rgba(255,255,255,0.75), transparent 34rem),
    linear-gradient(180deg, #f5efe4 0%, var(--bg) 100%);
  color: var(--ink);
}

.app-header {
  align-items: center;
  padding: 26px 36px;
  background: rgba(255, 253, 248, 0.92);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(185,173,156,0.65);
  box-shadow: 0 8px 24px rgba(31,25,18,0.045);
}

.brand-block {
  max-width: 760px;
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 8px;
  color: #82786b;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

h1 {
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(30px, 4vw, 48px);
  line-height: 0.98;
  letter-spacing: -0.055em;
  margin: 0 0 10px;
}

h2 {
  font-size: 15px;
  font-weight: 800;
  letter-spacing: -0.01em;
  margin-bottom: 12px;
}

h3 {
  letter-spacing: -0.01em;
}

p {
  color: var(--muted);
}

.app-header p {
  max-width: 680px;
  margin-bottom: 0;
  font-size: 15px;
}

button, select, input {
  border-color: rgba(185,173,156,0.9);
  background: #fffefa;
  border-radius: 12px;
  transition: transform 120ms ease, background 120ms ease, border-color 120ms ease, box-shadow 120ms ease;
}

button:hover,
select:hover,
input:hover {
  border-color: #9b8f7e;
}

button:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 18px rgba(31,25,18,0.08);
}

button.primary {
  background: #171512;
  color: #fff8ea;
  border-color: #171512;
  box-shadow: 0 10px 24px rgba(31,25,18,0.16);
}

.header-actions {
  align-items: stretch;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.header-actions button {
  min-height: 42px;
  white-space: nowrap;
}

.app-shell {
  grid-template-columns: 330px minmax(540px, 1.25fr) minmax(380px, 0.72fr);
  gap: 22px;
  padding: 22px;
  align-items: start;
}

.panel,
.workspace,
.print-cover,
.sheet {
  background: rgba(255,253,248,0.94);
  border: 1px solid rgba(185,173,156,0.65);
  border-radius: 22px;
  box-shadow: var(--shadow);
}

.panel {
  padding: 14px;
  position: sticky;
  top: 116px;
  max-height: calc(100vh - 136px);
  overflow: auto;
}

.panel section {
  background: var(--soft);
  border: 1px solid rgba(215,205,189,0.72);
  border-radius: 18px;
  padding: 16px;
}

.panel section + section {
  margin-top: 12px;
  padding-top: 16px;
  border-top: 1px solid rgba(215,205,189,0.72);
}

.ethos-card {
  background: #171512 !important;
  color: #fff8ea;
  border-color: #171512 !important;
}

.ethos-card p,
.ethos-card .eyebrow {
  color: #efe5d4;
}

.ethos-card p {
  margin-bottom: 0;
  font-size: 14px;
}

label {
  color: #625a50;
  font-size: 13px;
  font-weight: 650;
}

.hint,
.small-list {
  color: #766d60;
}

.drop-zone {
  min-height: 132px;
  border: 1.5px dashed #a89b89;
  background:
    linear-gradient(135deg, rgba(255,255,255,0.7), rgba(255,255,255,0.25)),
    #f4ecdf;
}

.drop-zone strong {
  font-size: 16px;
}

.drop-zone.dragover {
  border-color: #171512;
  background: #fffdf8;
}

.workspace {
  padding: 22px;
}

.workspace-header {
  align-items: flex-end;
  border-bottom: 1px solid rgba(215,205,189,0.8);
  padding-bottom: 16px;
  margin-bottom: 20px;
}

.workspace-header h2 {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 28px;
  line-height: 1;
  letter-spacing: -0.04em;
  margin: 0;
}

.workspace-header p {
  max-width: 360px;
  margin: 0;
  font-size: 13px;
}

.reading-layout {
  gap: 24px;
}

.cover-row .page-card {
  width: min(300px, 100%);
}

.page-card {
  background: #fffdf8;
  border-color: rgba(185,173,156,0.76);
  border-radius: 18px;
  padding: 14px;
  box-shadow: 0 8px 18px rgba(31,25,18,0.05);
}

.page-card-top {
  gap: 10px;
}

.page-label {
  color: #2d2923;
  font-size: 13px;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.page-label.cover {
  color: #171512;
}

.layout-select {
  background: #f8f2e8;
  border-color: rgba(185,173,156,0.72);
}

.mini-page {
  border: 1px solid #bfb3a2;
  box-shadow: 0 12px 26px rgba(31,25,18,0.12);
}

.slot {
  background: #f2ede4;
  border-color: #c7bcaa;
  color: #8b8173;
}

.slot .remove {
  background: rgba(255,253,248,0.92);
  border-color: rgba(185,173,156,0.8);
}

.swap-button,
.small-action {
  background: #fffdf8;
  border-color: rgba(185,173,156,0.8);
}

.reading-spread {
  background: #fffdf8;
  border-color: rgba(185,173,156,0.76);
  border-radius: 20px;
  padding: 16px;
  box-shadow: 0 12px 28px rgba(31,25,18,0.06);
}

.spread-top {
  margin-bottom: 14px;
}

.spread-top strong {
  font-size: 13px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.spread-body {
  background: #171512;
  border-radius: 14px;
  box-shadow: inset 0 0 0 1px #171512;
}

.spread-body .page-card {
  background: #fffdf8;
  box-shadow: none;
}

.spread-body .page-card:first-child {
  border-right: 1px solid #171512;
}

.spread-image-preview {
  background: #f1ebe0;
  color: #766d60;
}

.print-cover {
  padding: 18px;
  margin-bottom: 14px;
}

.print-cover h2 {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 24px;
  line-height: 1;
  letter-spacing: -0.04em;
  margin-bottom: 8px;
}

.print-cover p {
  margin-bottom: 0;
  font-size: 13px;
}

.sheet {
  padding: 12px;
}

.sheet-title {
  color: #766d60;
  font-weight: 700;
}

.back-cover-controls {
  border-top-color: rgba(215,205,189,0.9);
}

.checkbox-label {
  background: #fffdf8;
  border: 1px solid rgba(185,173,156,0.72);
  border-radius: 12px;
  padding: 10px 12px;
}

@media (max-width: 1320px) {
  .app-shell {
    grid-template-columns: 330px minmax(520px, 1fr);
  }
  .print-area {
    grid-column: 2;
  }
}

@media (max-width: 900px) {
  .app-header {
    align-items: flex-start;
    flex-direction: column;
  }
  .header-actions {
    justify-content: flex-start;
  }
  .app-shell {
    grid-template-columns: 1fr;
  }
  .panel {
    position: static;
    max-height: none;
  }
  .print-area {
    grid-column: auto;
  }
  .workspace-header {
    align-items: flex-start;
    flex-direction: column;
  }
}


/* v16: rugged DIY zine / photocopy culture skin */
:root {
  --bg: #dcd7cf;
  --paper: #ece8e0;
  --panel: #f4f0e9;
  --soft: #efeae2;
  --ink: #111111;
  --muted: #5c5851;
  --line: #aca396;
  --line-strong: #8f877b;
  --accent: #0f0f0f;
  --shadow: 0 10px 0 rgba(17,17,17,0.07), 0 18px 30px rgba(17,17,17,0.08);
}

body {
  background:
    radial-gradient(circle at 10% 15%, rgba(255,255,255,0.28) 0 0.14rem, transparent 0.16rem),
    radial-gradient(circle at 85% 30%, rgba(0,0,0,0.035) 0 0.08rem, transparent 0.1rem),
    radial-gradient(circle at 30% 70%, rgba(0,0,0,0.03) 0 0.06rem, transparent 0.08rem),
    linear-gradient(180deg, #e4ded4 0%, #d8d1c6 100%);
  background-size: 180px 180px, 160px 160px, 220px 220px, auto;
  color: var(--ink);
}

.app-header {
  background: linear-gradient(180deg, rgba(247,243,236,0.97), rgba(239,233,223,0.97));
  border-bottom: 2px solid #111;
  box-shadow: 0 3px 0 rgba(17,17,17,0.3), 0 10px 24px rgba(17,17,17,0.08);
}

.brand-block {
  position: relative;
}

.eyebrow {
  display: inline-block;
  background: #111;
  color: #f4efe6;
  padding: 5px 8px;
  border-radius: 2px;
  transform: rotate(-1deg);
  box-shadow: 2px 2px 0 rgba(17,17,17,0.18);
}

h1 {
  font-family: Impact, Haettenschweiler, 'Arial Narrow Bold', sans-serif;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  line-height: 0.95;
  margin-top: 10px;
  text-shadow: 1px 1px 0 rgba(255,255,255,0.55);
}

h2 {
  font-family: 'Courier New', Courier, monospace;
  font-size: 14px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

h3 {
  font-family: 'Courier New', Courier, monospace;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

p, label, .hint, .small-list, .sheet-title, .workspace-header p {
  color: var(--muted);
}

button, select, input {
  border-radius: 4px;
  border: 1.5px solid #111;
  background: #f8f4ee;
  box-shadow: 2px 2px 0 rgba(17,17,17,0.12);
}

button:hover,
select:hover,
input:hover {
  border-color: #111;
}

button:hover {
  transform: translate(-1px, -1px);
  box-shadow: 4px 4px 0 rgba(17,17,17,0.14);
}

button.primary {
  background: #111;
  color: #f7f2e9;
  border-color: #111;
  box-shadow: 3px 3px 0 rgba(17,17,17,0.22);
}

.panel,
.workspace,
.print-cover,
.sheet {
  background: var(--panel);
  border: 2px solid #111;
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.panel {
  background:
    linear-gradient(180deg, rgba(255,255,255,0.35), rgba(255,255,255,0.12)),
    var(--panel);
}

.panel section {
  background: rgba(255,255,255,0.22);
  border: 1.5px solid #111;
  border-radius: 8px;
}

.ethos-card {
  background:
    repeating-linear-gradient(-45deg, rgba(255,255,255,0.04) 0 8px, rgba(255,255,255,0.0) 8px 16px),
    #111 !important;
  transform: rotate(-0.45deg);
}

.drop-zone {
  border: 2px dashed #111;
  border-radius: 6px;
  background:
    linear-gradient(180deg, rgba(255,255,255,0.5), rgba(255,255,255,0.1)),
    #e9e2d6;
}

.workspace-header {
  border-bottom: 2px solid #111;
}

.workspace-header h2,
.print-cover h2 {
  font-family: Impact, Haettenschweiler, 'Arial Narrow Bold', sans-serif;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.page-card,
.reading-spread {
  border: 1.5px solid #111;
  border-radius: 8px;
  background: #f7f3ec;
  box-shadow: 5px 5px 0 rgba(17,17,17,0.08);
}

.page-label,
.spread-top strong {
  font-family: 'Courier New', Courier, monospace;
  color: #111;
}

.layout-select {
  background: #efe9df;
}

.mini-page {
  border: 1.5px solid #111;
  box-shadow: 4px 4px 0 rgba(17,17,17,0.14);
}

.slot {
  background: #e6dfd4;
  border: 1px dashed #111;
  color: #6a655d;
}

.slot.has-image,
.layout-single-bleed .slot,
.layout-single-bleed .slot.has-image {
  border: 0;
}

.slot .remove,
.swap-button,
.small-action,
.checkbox-label {
  border-radius: 4px;
  border: 1.5px solid #111;
  background: #faf6ef;
}

.cover-text {
  text-shadow: 0 1px 0 rgba(255,255,255,0.5);
}

.cover-color-white {
  text-shadow: 0 2px 0 rgba(0,0,0,0.72);
}

.spread-body {
  background: #111;
  border-radius: 0;
  box-shadow: inset 0 0 0 2px #111;
}

.spread-body .page-card:first-child {
  border-right: 2px solid #111;
}

.spread-image-preview {
  background: #ded7cc;
}

.spread-image-preview.dragover,
.drop-zone.dragover {
  outline: 3px solid #111;
  outline-offset: -3px;
}

.print-cover {
  background:
    linear-gradient(180deg, rgba(255,255,255,0.34), rgba(255,255,255,0.12)),
    var(--panel);
}

.sheet-paper {
  background: #111;
  box-shadow: inset 0 0 0 2px #111;
}

.print-page-number {
  border-radius: 3px;
  border: 1px solid #111;
  box-shadow: 2px 2px 0 rgba(17,17,17,0.1);
}


/* v17: softer DIY photocopy look with cooler grey paper and border fixes */
:root {
  --bg: #d8d8d6;
  --paper: #ececeb;
  --panel: #f5f5f3;
  --soft: #f0f0ee;
  --ink: #111111;
  --muted: #575757;
  --line: #939393;
  --line-strong: #767676;
  --accent: #111111;
  --shadow: 0 8px 18px rgba(17,17,17,0.08);
}

body {
  background:
    radial-gradient(circle at 12% 18%, rgba(255,255,255,0.22) 0 0.12rem, transparent 0.13rem),
    radial-gradient(circle at 78% 28%, rgba(0,0,0,0.025) 0 0.08rem, transparent 0.09rem),
    radial-gradient(circle at 38% 76%, rgba(0,0,0,0.02) 0 0.06rem, transparent 0.08rem),
    linear-gradient(180deg, #dfdfdd 0%, #d3d3d0 100%);
  background-size: 220px 220px, 190px 190px, 240px 240px, auto;
}

.app-header {
  background: linear-gradient(180deg, rgba(246,246,244,0.96), rgba(238,238,235,0.96));
  border-bottom: 1.5px solid #111;
  box-shadow: 0 2px 0 rgba(17,17,17,0.18), 0 10px 22px rgba(17,17,17,0.06);
}

.eyebrow {
  background: #111;
  color: #f6f6f4;
  padding: 4px 8px;
  border-radius: 3px;
  transform: rotate(-0.5deg);
  box-shadow: 1px 1px 0 rgba(17,17,17,0.14);
}

h1,
.workspace-header h2,
.print-cover h2 {
  font-family: Impact, Haettenschweiler, 'Arial Narrow Bold', sans-serif;
  text-transform: uppercase;
  letter-spacing: 0.025em;
  text-shadow: 1px 1px 0 rgba(255,255,255,0.45);
}

h2,
h3,
.page-label,
.spread-top strong {
  font-family: 'Courier New', Courier, monospace;
}

button, select, input {
  border-radius: 6px;
  border: 1.5px solid #111;
  background: #f8f8f6;
  box-shadow: 1px 1px 0 rgba(17,17,17,0.1);
}

button:hover {
  transform: translateY(-1px);
  box-shadow: 2px 2px 0 rgba(17,17,17,0.12);
}

button.primary {
  box-shadow: 2px 2px 0 rgba(17,17,17,0.18);
}

.panel,
.workspace,
.print-cover,
.sheet {
  background: var(--panel);
  border: 1.5px solid #111;
  border-radius: 10px;
  box-shadow: var(--shadow);
}

.panel {
  background: linear-gradient(180deg, rgba(255,255,255,0.28), rgba(255,255,255,0.12)), var(--panel);
}

.panel section {
  background: rgba(255,255,255,0.18);
  border: 1.5px solid #111;
  border-radius: 10px;
  box-shadow: none;
  position: relative;
  overflow: visible;
}

/* remove the extra inner divider so top edges stay clean and complete */
.panel section + section {
  margin-top: 14px;
  padding-top: 16px;
  border-top: 1.5px solid #111;
}

/* reinforce the full outline in case browsers anti-alias the top edge */
.panel section::before,
.workspace::before,
.print-cover::before,
.sheet::before,
.page-card::before,
.reading-spread::before {
  content: '';
  position: absolute;
  inset: 0;
  border: 1px solid rgba(17,17,17,0.22);
  border-radius: inherit;
  pointer-events: none;
}

.workspace,
.print-cover,
.sheet,
.page-card,
.reading-spread {
  position: relative;
}

.ethos-card {
  background: repeating-linear-gradient(-45deg, rgba(255,255,255,0.03) 0 8px, rgba(255,255,255,0) 8px 16px), #111 !important;
  transform: rotate(-0.25deg);
}

.drop-zone {
  border: 2px dashed #111;
  border-radius: 8px;
  background: linear-gradient(180deg, rgba(255,255,255,0.42), rgba(255,255,255,0.1)), #e6e6e2;
}

.page-card,
.reading-spread {
  border: 1.5px solid #111;
  border-radius: 10px;
  background: #f7f7f4;
  box-shadow: 3px 3px 0 rgba(17,17,17,0.06);
}

.mini-page {
  border: 1.5px solid #111;
  box-shadow: 3px 3px 0 rgba(17,17,17,0.09);
}

.slot {
  background: #e6e6e2;
  border: 1px dashed #111;
}

.slot .remove,
.swap-button,
.small-action,
.checkbox-label {
  border-radius: 6px;
  border: 1.5px solid #111;
  background: #f8f8f6;
}

.spread-body {
  border-radius: 2px;
  box-shadow: inset 0 0 0 1.5px #111;
}

.spread-body .page-card:first-child {
  border-right: 1.5px solid #111;
}

.spread-image-preview {
  background: #ddddda;
}

.spread-image-preview.spread-border {
  background: #f7f7f4;
}

.print-cover {
  background: linear-gradient(180deg, rgba(255,255,255,0.26), rgba(255,255,255,0.1)), var(--panel);
}

.sheet-paper {
  box-shadow: inset 0 0 0 1.5px #111;
}

.checkbox-label {
  padding: 9px 12px;
}

/* v21: equalise left sidebar section spacing after removing image upload section */
.panel > section {
  margin: 0 0 14px !important;
}
.panel > section:last-of-type {
  margin-bottom: 0 !important;
}
.panel section + section {
  margin-top: 0 !important;
}


/* v23: Step 2, larger and more book-like reading-order builder */
.app-shell {
  grid-template-columns: 320px minmax(680px, 1.55fr) minmax(340px, 0.55fr);
  gap: 24px;
}

.workspace {
  padding: 26px;
}

.workspace-header {
  margin-bottom: 26px;
  padding-bottom: 18px;
}

.workspace-header p {
  max-width: 460px;
  line-height: 1.45;
}

.reading-layout {
  gap: 34px;
}

.cover-row {
  padding: 4px 0;
}

.cover-row .page-card {
  width: min(360px, 100%);
}

.page-card {
  display: flex;
  flex-direction: column;
  padding: 16px;
}

.page-card-top {
  order: 2;
  margin: 12px 0 0;
  padding-top: 10px;
  border-top: 1.5px solid #111;
  gap: 8px;
}

.mini-page {
  order: 1;
  width: 100%;
}

.page-label {
  font-size: 12px;
}

.layout-select {
  font-size: 12px;
  padding: 8px 9px;
}

.reading-spread {
  padding: 18px;
  border-radius: 12px;
}

.spread-top {
  margin-bottom: 16px;
  align-items: center;
}

.spread-top strong {
  font-size: 12px;
}

.spread-actions {
  gap: 10px;
}

.small-action {
  font-size: 12px;
  padding: 8px 10px;
}

.spread-body {
  align-items: stretch;
  border-radius: 3px;
}

.spread-body .page-card {
  padding: 18px;
  min-width: 0;
}

.spread-page-card .mini-page {
  max-width: none;
  width: 100%;
}

.spread-body .page-card .page-card-top {
  background: rgba(255,255,255,0.34);
  margin-left: -4px;
  margin-right: -4px;
  padding: 10px 4px 0;
}

.slot {
  font-size: 13px;
  line-height: 1.25;
  padding: 10px;
}

.layout-single-bleed .slot:not(.has-image),
.print-page.layout-single-bleed > .slot:not(.has-image) {
  display: grid;
  place-items: center;
}

.spread-image-preview {
  font-size: 15px;
  min-height: 360px;
}

.swap-button {
  margin-top: 12px;
  font-size: 12px;
  padding: 8px 10px;
}

.print-area .sheet {
  padding: 10px;
}

.print-cover {
  padding: 16px;
}

.print-cover h2 {
  font-size: 22px;
}

@media (max-width: 1500px) {
  .app-shell {
    grid-template-columns: 320px minmax(560px, 1fr);
  }
  .print-area {
    grid-column: 2;
  }
}

@media (max-width: 980px) {
  .app-shell {
    grid-template-columns: 1fr;
  }
  .print-area {
    grid-column: auto;
  }
  .cover-row .page-card {
    width: min(330px, 100%);
  }
  .spread-body {
    grid-template-columns: 1fr;
    gap: 2px;
  }
  .spread-body .page-card:first-child {
    border-right: 0;
    border-bottom: 1.5px solid #111;
  }
}


/* v24: collapsible print preview */
.preview-toggle {
  width: 100%;
  margin-top: 12px;
  font-size: 12px;
  padding: 9px 10px;
}

.app-shell.preview-collapsed {
  grid-template-columns: 320px minmax(680px, 1fr) minmax(230px, 0.28fr);
}

.app-shell.preview-collapsed #imposedSheets {
  display: none;
}

.app-shell.preview-collapsed .print-cover {
  position: sticky;
  top: 116px;
}

.app-shell.preview-collapsed .print-cover p {
  font-size: 12px;
}

.app-shell.preview-collapsed .print-cover h2 {
  font-size: 20px;
}

@media (max-width: 1500px) {
  .app-shell.preview-collapsed {
    grid-template-columns: 320px minmax(560px, 1fr);
  }
  .app-shell.preview-collapsed .print-area {
    grid-column: 2;
  }
}

@media (max-width: 980px) {
  .app-shell.preview-collapsed {
    grid-template-columns: 1fr;
  }
  .app-shell.preview-collapsed .print-area {
    grid-column: auto;
  }
}

/* v25: reading PDF, crop controls and project save/open */
.header-actions {
  gap: 8px;
}

.header-actions button {
  min-height: 38px;
  padding: 9px 10px;
}

.crop-controls {
  position: absolute;
  left: 8px;
  right: 8px;
  bottom: 8px;
  z-index: 8;
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 120ms ease;
}

.slot:hover .crop-controls,
.spread-image-preview:hover + .crop-controls,
.crop-controls:hover {
  opacity: 1;
  pointer-events: auto;
}

.crop-button {
  padding: 4px 6px;
  font-size: 10px;
  line-height: 1;
  border-radius: 4px;
  background: rgba(248,248,246,0.94);
}

.slot img,
.spread-image-preview img {
  transition: transform 120ms ease, object-position 120ms ease;
}

.spread-body > .crop-controls {
  grid-column: 1 / -1;
  position: static;
  opacity: 1;
  pointer-events: auto;
  padding: 8px;
  background: #111;
}

.spread-body > .crop-controls .crop-button {
  background: #f8f8f6;
}


/* v26 fixes: reading PDF portrait, no fold guide output, independent back cover alignment and smaller QR quiet zone */
.fold-line {
  display: none !important;
  border: 0 !important;
}
@media print {
  .fold-line {
    display: none !important;
    border: 0 !important;
  }
}
.back-cover-qr {
  padding: 1px;
}
.qr-h-left { align-self: flex-start !important; }
.qr-h-center { align-self: center !important; }
.qr-h-right { align-self: flex-end !important; }


/* v29: quick-start modal, export confirmation and image quality warnings */
.welcome-modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(17,17,17,0.48);
}
.welcome-modal[hidden] {
  display: none;
}
.welcome-card {
  width: min(560px, 100%);
  background: var(--panel);
  border: 1.5px solid #111;
  border-radius: 10px;
  padding: 24px;
  box-shadow: 8px 8px 0 rgba(17,17,17,0.18);
}
.welcome-card h2 {
  font-family: Impact, Haettenschweiler, 'Arial Narrow Bold', sans-serif;
  font-size: clamp(28px, 5vw, 48px);
  line-height: 0.96;
  letter-spacing: 0.025em;
  margin: 14px 0 16px;
}
.welcome-card ol {
  margin: 0 0 20px 1.2em;
  color: var(--muted);
  line-height: 1.5;
}
.welcome-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}
.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 120;
  max-width: 360px;
  background: #111;
  color: #f7f7f4;
  border: 1.5px solid #111;
  border-radius: 8px;
  padding: 14px 16px;
  box-shadow: 5px 5px 0 rgba(17,17,17,0.18);
}
.toast strong,
.toast span {
  display: block;
}
.toast span {
  margin-top: 4px;
  color: #d8d8d6;
  font-size: 13px;
  line-height: 1.35;
}
.quality-badge {
  position: absolute;
  left: 8px;
  bottom: 8px;
  z-index: 8;
  display: inline-flex;
  align-items: center;
  padding: 3px 6px;
  background: #111;
  color: #f7f7f4;
  border-radius: 3px;
  font: 700 10px/1 'Courier New', Courier, monospace;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  box-shadow: 2px 2px 0 rgba(17,17,17,0.14);
}


/* v31: fit-whole-image layout options for ultra-wide images */
.layout-single-fit {
  padding: 0;
  grid-template-columns: 1fr;
  grid-template-rows: 1fr;
}
.layout-single-fit .slot {
  border: 0;
  background: #ffffff;
}
.layout-single-fit .slot img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  background: #ffffff;
}

.layout-two-stack-fit {
  padding: 5%;
  gap: 5%;
  grid-template-rows: 1fr 1fr;
}
.layout-two-side-fit {
  padding: 5%;
  gap: 5%;
  grid-template-columns: 1fr 1fr;
}
.layout-two-stack-fit .slot,
.layout-two-side-fit .slot {
  background: #ffffff;
}
.layout-two-stack-fit .slot img,
.layout-two-side-fit .slot img {
  object-fit: contain;
  background: #ffffff;
}


/* v33: manual duplex controls */
#rotateBacks {
  width: auto;
}


/* v1.0 beta: flip test button */
.sidebar-action {
  width: 100%;
  margin: 6px 0 10px;
}


/* v1.0.1 beta: instructions modal */
.help-modal .help-card {
  width: min(860px, 100%);
  max-height: 86vh;
  display: flex;
  flex-direction: column;
}
.help-content {
  overflow: auto;
  padding-right: 8px;
  margin-top: 8px;
}
.help-content h3 {
  margin: 18px 0 8px;
}
.help-content p,
.help-content li {
  color: var(--muted);
  line-height: 1.5;
}
.help-content ol,
.help-content ul {
  margin: 0 0 0 1.25em;
}
.help-content code {
  font-family: 'Courier New', Courier, monospace;
  background: rgba(17,17,17,0.06);
  padding: 1px 4px;
  border-radius: 4px;
  color: var(--ink);
}
