/* PrintTidy — clean, light, low-noise UI */

:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #f0f2f5;
  --border: #e2e5ea;
  --border-strong: #cfd4dc;
  --text: #1a1d21;
  --muted: #6a7280;
  --accent: #2f6fed;
  --accent-dark: #2254c0;
  --danger: #c0392b;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 1px 3px rgba(16, 24, 40, .06);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.65;
  -webkit-text-size-adjust: 100%;
}

.wrap {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 20px;
}

a { color: var(--accent); }

/* ---------- header / nav ---------- */
.site-head {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.site-head .wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 58px;
}
.brand {
  font-weight: 700;
  font-size: 18px;
  letter-spacing: -.2px;
  color: var(--text);
  text-decoration: none;
  white-space: nowrap;
}
.brand span { color: var(--accent); }
.nav {
  display: flex;
  gap: 18px;
  font-size: 14px;
}
.nav a {
  color: var(--muted);
  text-decoration: none;
}
.nav a:hover { color: var(--accent); }

/* ---------- typography ---------- */
h1 {
  font-size: 30px;
  line-height: 1.25;
  letter-spacing: -.5px;
  margin: 28px 0 12px;
}
h2 {
  font-size: 22px;
  line-height: 1.3;
  margin: 40px 0 12px;
  letter-spacing: -.3px;
}
h3 {
  font-size: 17px;
  margin: 26px 0 8px;
}
p { margin: 0 0 14px; }
.lede {
  font-size: 18px;
  color: var(--muted);
  margin-bottom: 24px;
}
@media (max-width: 640px) {
  h1 { font-size: 25px; }
  h2 { font-size: 20px; }
  .lede { font-size: 16px; }
  body { font-size: 15.5px; }
}

/* ---------- surface card ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.pad { padding: 20px; }
@media (max-width: 640px) {
  .pad { padding: 14px; }
}

/* ---------- buttons (light, no heavy blocks) ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 40px;
  padding: 8px 16px;
  border-radius: 8px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  font-size: 14px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: background .15s, border-color .15s;
  white-space: nowrap;
}
.btn:hover { background: var(--surface-2); }
.btn:disabled {
  opacity: .45;
  cursor: not-allowed;
}
.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.btn-primary:hover { background: var(--accent-dark); border-color: var(--accent-dark); }
.btn-quiet {
  border-color: transparent;
  background: transparent;
  color: var(--muted);
  padding: 6px 8px;
  min-height: 34px;
}
.btn-quiet:hover { background: var(--surface-2); color: var(--text); }
.btn-sm { min-height: 34px; padding: 5px 11px; font-size: 13px; }

.btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

/* ---------- tool layout ---------- */
/* Four cards are direct children so phones can re-order them:
   photos -> preview -> settings. Desktop keeps the two-column look. */
.tool {
  display: grid;
  grid-template-columns: 300px 1fr;
  gap: 16px;
  align-items: start;
}
.card-photos  { grid-column: 1; grid-row: 1; }
.card-setup   { grid-column: 1; grid-row: 2; }
.card-preview { grid-column: 2; grid-row: 1; }
.card-save    { grid-column: 2; grid-row: 2; }

@media (max-width: 860px) {
  .tool { grid-template-columns: 1fr; gap: 12px; }
  .card-photos, .card-setup, .card-preview, .card-save {
    grid-column: 1 / -1;
    grid-row: auto;
  }
  .card-photos  { order: 1; }
  .card-preview { order: 2; }
  .card-setup   { order: 3; }
  .card-save    { order: 4; }
}

.panel-title {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .6px;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 12px;
}

/* ---------- dropzone ---------- */
.dropzone {
  border: 1.5px dashed var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 26px 16px;
  text-align: center;
  cursor: pointer;
  transition: border-color .15s, background .15s;
}
.dropzone:hover, .dropzone.over {
  border-color: var(--accent);
  background: #f5f8ff;
}
.dropzone .dz-icon { font-size: 30px; line-height: 1; margin-bottom: 8px; }
.dropzone strong { display: block; font-size: 15px; }
.dropzone .hint { font-size: 13px; color: var(--muted); margin: 2px 0 0; }

/* ---------- thumbs ---------- */
.thumbs {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(84px, 1fr));
  gap: 8px;
  margin-top: 12px;
}
.thumb {
  position: relative;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  background: var(--surface-2);
  aspect-ratio: 1 / 1;
  cursor: grab;
}
.thumb.dragging { opacity: .4; }
.thumb.drop-target { outline: 2px solid var(--accent); }
.thumb img {
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
  -webkit-user-drag: none;
}
.thumb .th-num {
  position: absolute; top: 0; left: 0;
  background: rgba(0,0,0,.6);
  color: #fff;
  font-size: 11px;
  line-height: 1;
  padding: 3px 5px;
  border-bottom-right-radius: 6px;
}
.thumb .th-x {
  position: absolute; top: 0; right: 0;
  border: 0;
  background: rgba(0,0,0,.6);
  color: #fff;
  width: 22px; height: 22px;
  font-size: 13px;
  line-height: 1;
  cursor: pointer;
  border-bottom-left-radius: 6px;
  padding: 0;
}
.thumb .th-move {
  position: absolute; bottom: 0; left: 0; right: 0;
  display: flex;
  border-top: 1px solid var(--border);
}
.thumb .th-move button {
  flex: 1;
  border: 0;
  background: rgba(255,255,255,.92);
  color: var(--muted);
  font-size: 12px;
  line-height: 1;
  padding: 6px 0;
  min-height: 30px;
  cursor: pointer;
}
.thumb .th-move button:hover { background: #fff; color: var(--accent); }
.thumb-meta {
  position: absolute; bottom: 0; left: 0; right: 0;
  font-size: 10px;
  color: #fff;
  background: linear-gradient(transparent, rgba(0,0,0,.65));
  padding: 10px 4px 3px;
  text-align: center;
}

/* ---------- form controls ---------- */
.field { margin-bottom: 14px; }
.field > label,
.field-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 5px;
}
select, input[type="number"] {
  width: 100%;
  min-height: 38px;
  padding: 6px 10px;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
}
select:focus, input:focus { outline: 2px solid rgba(47,111,237,.35); outline-offset: 1px; }

input[type="range"] {
  width: 100%;
  height: 26px;
  -webkit-appearance: none;
  appearance: none;
  background: transparent;
  margin: 0;
}
input[type="range"]::-webkit-slider-runnable-track {
  height: 5px; background: var(--border-strong); border-radius: 3px;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px; height: 18px; border-radius: 50%;
  background: var(--accent); margin-top: -7px; cursor: pointer;
}
input[type="range"]::-moz-range-thumb {
  width: 18px; height: 18px; border-radius: 50%;
  background: var(--accent); border: 0; cursor: pointer;
}

.seg {
  display: flex;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  overflow: hidden;
}
.seg button {
  flex: 1;
  border: 0;
  background: var(--surface);
  color: var(--muted);
  font-size: 13px;
  font-family: inherit;
  min-height: 38px;
  padding: 6px 4px;
  cursor: pointer;
  border-right: 1px solid var(--border);
}
.seg button:last-child { border-right: 0; }
.seg button.on { background: #eaf1ff; color: var(--accent-dark); font-weight: 600; }

.grid-presets {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
}
.grid-presets button {
  border: 1px solid var(--border-strong);
  background: var(--surface);
  border-radius: 8px;
  min-height: 40px;
  font-size: 13px;
  font-family: inherit;
  color: var(--muted);
  cursor: pointer;
}
.grid-presets button.on { border-color: var(--accent); background: #eaf1ff; color: var(--accent-dark); font-weight: 600; }

.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.val-note { font-size: 12px; color: var(--muted); margin-top: 3px; }

/* ---------- preview ---------- */
.preview-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}
.page-nav { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); }
.preview-stage {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  display: flex;
  justify-content: center;
  min-height: 260px;
}
.preview-stage canvas {
  max-width: 100%;
  height: auto;
  background: #fff;
  box-shadow: 0 1px 3px rgba(16,24,40,.12);
  border-radius: 2px;
}
.empty-stage {
  margin: auto;
  text-align: center;
  color: var(--muted);
  font-size: 14px;
  padding: 40px 10px;
}

.status {
  font-size: 13px;
  color: var(--muted);
  min-height: 20px;
  margin-top: 10px;
}
.status.err { color: var(--danger); }

/* ---------- print container ---------- */
#print-root { display: none; }

/* ---------- content blocks ---------- */
.steps { padding-left: 22px; }
.steps li { margin-bottom: 7px; }
ol.steps > li::marker { font-weight: 600; color: var(--accent); }

table.compare {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
  margin: 12px 0 18px;
}
table.compare th, table.compare td {
  border: 1px solid var(--border);
  padding: 8px 10px;
  text-align: left;
  vertical-align: top;
}
table.compare th { background: var(--surface-2); font-weight: 600; }
@media (max-width: 640px) {
  table.compare { font-size: 13px; }
  table.compare th, table.compare td { padding: 6px 7px; }
}

.callout {
  border-left: 3px solid var(--accent);
  background: #f5f8ff;
  padding: 12px 14px;
  border-radius: 0 8px 8px 0;
  margin: 16px 0;
  font-size: 15px;
}
.callout p:last-child { margin-bottom: 0; }

details.faq {
  border-bottom: 1px solid var(--border);
  padding: 12px 0;
}
details.faq summary {
  cursor: pointer;
  font-weight: 600;
  font-size: 16px;
  list-style: none;
}
details.faq summary::-webkit-details-marker { display: none; }
details.faq summary::before {
  content: "+";
  display: inline-block;
  width: 18px;
  color: var(--accent);
  font-weight: 700;
}
details.faq[open] summary::before { content: "\2013"; }
details.faq > div { padding: 8px 0 4px 18px; }

.toc {
  font-size: 15px;
}
.toc ol { padding-left: 20px; margin: 4px 0 0; }

.privacy-note {
  font-size: 13.5px;
  color: var(--muted);
  margin-top: 16px;
}

.site-foot {
  margin-top: 56px;
  border-top: 1px solid var(--border);
  padding: 22px 0 40px;
  font-size: 13px;
  color: var(--muted);
}
.site-foot nav { display: flex; gap: 16px; flex-wrap: wrap; margin-bottom: 8px; }
.site-foot a { color: var(--muted); text-decoration: none; }
.site-foot a:hover { color: var(--accent); }

/* ---------- print styles ---------- */
@media print {
  @page { margin: 0; }
  body > *:not(#print-root) { display: none !important; }
  #print-root { display: block !important; }
  #print-root .print-page { page-break-after: always; break-after: page; }
  #print-root .print-page:last-child { page-break-after: auto; break-after: auto; }
  #print-root img { display: block; width: 100%; height: auto; }
}

/* ============================================================
   Touch and small-screen refinements
   Both Apple and Google put the comfortable hit target at 44px.
   ============================================================ */
@media (max-width: 860px), (pointer: coarse) {
  .btn { min-height: 46px; padding: 10px 16px; font-size: 15px; }
  .btn-sm { min-height: 44px; padding: 8px 14px; font-size: 14px; }
  .btn-quiet { min-height: 44px; padding: 10px 12px; }

  /* 16px keeps iOS Safari from zooming the whole page when a field is focused */
  select, input[type="number"] { min-height: 46px; font-size: 16px; }
  .seg button { min-height: 46px; font-size: 14px; }
  .grid-presets button { min-height: 48px; font-size: 15px; }

  input[type="range"] { height: 42px; }
  input[type="range"]::-webkit-slider-runnable-track { height: 6px; border-radius: 3px; }
  input[type="range"]::-webkit-slider-thumb { width: 26px; height: 26px; margin-top: -10px; }
  input[type="range"]::-moz-range-thumb { width: 26px; height: 26px; }

  .thumbs { grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 10px; }

  /* Visual size stays modest so it does not cover the photo, but the actual
     tap area is widened with a pseudo-element (Apple's own recommended trick). */
  .thumb .th-x { width: 40px; height: 40px; font-size: 18px; }
  .thumb .th-x::after { content: ""; position: absolute; inset: -5px; }
  .thumb .th-move button { min-height: 42px; font-size: 15px; }
}

@media (max-width: 860px) {
  .dropzone { padding: 22px 14px; }
  .preview-stage { padding: 8px; min-height: 0; }

  /* An empty preview card just eats the first screenful on a phone.
     It appears the moment a photo is added. */
  .tool:not(.has-photos) .card-preview,
  .tool:not(.has-photos) .card-save { display: none; }

  /* The preview sits directly under the photos so you see the layout the
     moment you add pictures. It is deliberately NOT sticky: pinning it
     covered the first controls in the settings card. */
  .card-preview canvas {
    max-height: 52vh;
    max-width: 100%;
    width: auto;
    height: auto;
  }
  .card-preview .status { margin-top: 6px; }
}

@media (max-width: 700px) {
  .site-head .wrap { gap: 10px; min-height: 54px; }
  .brand { font-size: 17px; }
  .nav {
    gap: 14px;
    overflow-x: auto;
    white-space: nowrap;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }
  .nav::-webkit-scrollbar { display: none; }

  /* The comparison table is genuinely wide; let it scroll instead of
     squeezing four columns into 350px. */
  table.compare { display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  table.compare thead,
  table.compare tbody { display: table; width: 100%; min-width: 620px; }

  .callout { font-size: 14.5px; }
  .toc ol { padding-left: 18px; }
}
