/* ── Tokens ─────────────────────────────────────────────────── */

:root {
  --bg: #f6f4ef;
  --bg-glow-1: rgba(112, 117, 242, 0.13);
  --bg-glow-2: rgba(255, 138, 110, 0.12);
  --surface: #ffffff;
  --surface-2: #f8f7f3;
  --inset: #f1efe9;
  --border: #e9e5dc;
  --border-strong: #dbd6ca;
  --text: #1f2440;
  --muted: #646a85;
  --faint: #9a9fb4;
  --primary: #5b5fe0;
  --primary-hover: #4b4fd2;
  --primary-soft: #eeeffd;
  --primary-ring: rgba(91, 95, 224, 0.35);
  --on-primary: #ffffff;
  --coral: #f2694f;
  --coral-soft: #ffe9e3;
  --green: #1c9a55;
  --green-soft: #e1f5e9;
  --amber: #d99100;
  --amber-soft: #fff3d6;
  --paper: #ffffff;
  --preview-bg: #e8eaf1;
  --preview-dot: #d3d8e6;
  --rule: #e3e6f3;
  --switch-off: #d3d5e0;
  --notice-bg: #fff6e0;
  --notice-text: #7a5300;
  --shadow-sm: 0 1px 2px rgba(31, 36, 64, 0.06);
  --shadow: 0 1px 2px rgba(31, 36, 64, 0.04), 0 8px 24px rgba(31, 36, 64, 0.06);
  --shadow-sheet: 0 1px 3px rgba(31, 36, 64, 0.1), 0 14px 36px rgba(31, 36, 64, 0.12);
  --radius: 22px;
  --radius-sm: 14px;
  --font: 'Figtree', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --font-display: 'Fredoka', 'Figtree', ui-rounded, system-ui, sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121528;
    --bg-glow-1: rgba(112, 117, 242, 0.16);
    --bg-glow-2: rgba(255, 138, 110, 0.07);
    --surface: #1a1e37;
    --surface-2: #20254a;
    --inset: #151931;
    --border: #2a3057;
    --border-strong: #394073;
    --text: #eceefe;
    --muted: #a4a9c9;
    --faint: #6f769c;
    --primary: #8f94ff;
    --primary-hover: #a6aaff;
    --primary-soft: rgba(143, 148, 255, 0.15);
    --primary-ring: rgba(143, 148, 255, 0.45);
    --on-primary: #14173a;
    --coral: #ff8a70;
    --coral-soft: rgba(255, 138, 112, 0.16);
    --green: #45c882;
    --green-soft: rgba(69, 200, 130, 0.15);
    --amber: #ffc34d;
    --amber-soft: rgba(255, 195, 77, 0.14);
    --preview-bg: #0d1022;
    --preview-dot: #1d2244;
    --rule: #2a3057;
    --switch-off: #3a4170;
    --notice-bg: rgba(255, 195, 77, 0.12);
    --notice-text: #ffd78a;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.25), 0 10px 28px rgba(0, 0, 0, 0.25);
    --shadow-sheet: 0 2px 6px rgba(0, 0, 0, 0.35), 0 18px 40px rgba(0, 0, 0, 0.45);
    color-scheme: dark;
  }
}

/* ── Base ───────────────────────────────────────────────────── */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  color: var(--text);
  background-color: var(--bg);
  background-image:
    radial-gradient(60rem 36rem at -10% -12%, var(--bg-glow-1), transparent 60%),
    radial-gradient(50rem 30rem at 110% -8%, var(--bg-glow-2), transparent 60%);
  background-repeat: no-repeat;
  -webkit-font-smoothing: antialiased;
}

h1,
h2,
h3,
p {
  margin: 0;
}

button,
input,
textarea {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
}

svg {
  flex: none;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

:focus-visible {
  outline: 3px solid var(--primary-ring);
  outline-offset: 2px;
}

/* ── Top bar ────────────────────────────────────────────────── */

.topbar {
  display: flex;
  align-items: center;
  gap: 18px;
  max-width: 1480px;
  margin: 0 auto;
  padding: 22px 28px 18px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: inherit;
  text-decoration: none;
  border-radius: 14px;
}

.brand-mark {
  width: 44px;
  height: 44px;
  filter: drop-shadow(0 6px 14px rgba(91, 95, 224, 0.35));
}

.brand-name {
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1;
}

.brand-name span {
  color: var(--primary);
}

.brand-tag {
  color: var(--muted);
  font-size: 15px;
  padding-left: 18px;
  border-left: 1px solid var(--border-strong);
}

.privacy-pill {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-radius: 999px;
  background: var(--green-soft);
  color: var(--green);
  font-size: 13.5px;
  font-weight: 600;
}

.privacy-pill svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
}

/* ── Layout ─────────────────────────────────────────────────── */

.layout {
  display: grid;
  grid-template-columns: minmax(360px, 430px) minmax(0, 1fr);
  gap: 28px;
  align-items: start;
  max-width: 1480px;
  margin: 0 auto;
  padding: 4px 28px 28px;
}

.panel {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: 0;
}

/* ── Cards ──────────────────────────────────────────────────── */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
}

.card-head {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  margin-bottom: 16px;
}

.card-head h2 {
  font-family: var(--font-display);
  font-size: 19px;
  font-weight: 600;
  line-height: 1.25;
  letter-spacing: -0.005em;
}

.card-head p {
  margin-top: 2px;
  color: var(--muted);
  font-size: 14px;
}

.step {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  flex: none;
  border-radius: 11px;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 16px;
}

.step-1 { background: var(--primary-soft); color: var(--primary); }
.step-2 { background: var(--coral-soft); color: var(--coral); }
.step-3 { background: var(--green-soft); color: var(--green); }
.step-4 { background: var(--amber-soft); color: var(--amber); }

/* ── Text input ─────────────────────────────────────────────── */

.text-wrap {
  position: relative;
}

textarea {
  display: block;
  width: 100%;
  min-height: 92px;
  resize: none;
  padding: 7px 46px 7px 16px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  background-color: var(--surface-2);
  background-image: linear-gradient(to bottom, transparent 35px, var(--rule) 35px, var(--rule) 36px);
  background-size: 100% 36px;
  background-position: 0 7px;
  background-attachment: local;
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 500;
  line-height: 36px;
  transition: border-color 0.15s, box-shadow 0.15s, background-color 0.15s;
}

textarea::placeholder {
  color: var(--faint);
}

textarea:focus {
  outline: none;
  border-color: var(--primary);
  background-color: var(--surface);
  box-shadow: 0 0 0 4px var(--primary-soft);
}

.clear-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--faint);
  transition: background 0.15s, color 0.15s;
}

.clear-btn:hover {
  background: var(--inset);
  color: var(--text);
}

.clear-btn svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.2;
  stroke-linecap: round;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-top: 12px;
}

.chips-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--faint);
  margin-right: 4px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 34px;
  padding: 0 11px;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  background: var(--surface);
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text);
  transition: background 0.15s, border-color 0.15s, color 0.15s, transform 0.1s;
}

.chip:hover {
  background: var(--primary-soft);
  border-color: transparent;
  color: var(--primary);
}

.chip:active {
  transform: scale(0.97);
}

.chip svg {
  width: 15px;
  height: 15px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.notice {
  margin-top: 12px;
  padding: 10px 14px;
  border-radius: 12px;
  background: var(--notice-bg);
  color: var(--notice-text);
  font-size: 14px;
}

.notice kbd {
  display: inline-block;
  min-width: 1.6em;
  padding: 0 5px;
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  font-family: inherit;
  font-weight: 700;
  text-align: center;
  box-shadow: var(--shadow-sm);
}

/* ── Size picker ────────────────────────────────────────────── */

.size-picker {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
}

.size-option,
.tile {
  position: relative;
  display: block;
  min-width: 0;
}

.size-option input,
.tile input,
.segmented input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}

.size-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  height: 100%;
  padding: 8px 4px 10px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  transition: border-color 0.15s, background 0.15s, transform 0.1s;
}

.size-art {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 58px;
  margin-bottom: 7px;
  padding: 4px;
  border-radius: 9px;
  background: var(--paper);
  box-shadow: inset 0 0 0 1px var(--border);
}

.size-art svg {
  display: block;
  height: calc(10px + var(--h) * 34px);
  width: auto;
  max-width: 100%;
}

.size-name {
  font-size: 12.5px;
  font-weight: 700;
  line-height: 1.2;
  white-space: nowrap;
}

.size-inch {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.3;
}

.size-option:hover .size-card,
.tile:hover .tile-body {
  border-color: var(--border-strong);
}

.size-option input:checked + .size-card,
.tile input:checked + .tile-body {
  border-color: var(--primary);
  background: var(--primary-soft);
}

.size-option input:checked + .size-card .size-name,
.tile input:checked + .tile-body .tile-label {
  color: var(--primary);
}

.size-option input:focus-visible + .size-card,
.tile input:focus-visible + .tile-body,
.segmented input:focus-visible + span {
  outline: 3px solid var(--primary-ring);
  outline-offset: 2px;
}

.size-option:active .size-card,
.tile:active .tile-body {
  transform: scale(0.98);
}

/* ── Settings rows ──────────────────────────────────────────── */

.setting {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 13px 0;
  border-top: 1px solid var(--border);
}

.card-head + .setting {
  border-top: 0;
  padding-top: 0;
}

.setting-last {
  padding-bottom: 0;
}

.setting-text label,
.setting-title {
  display: block;
  font-weight: 600;
  font-size: 15.5px;
  cursor: pointer;
}

.setting-title {
  cursor: default;
}

.setting-text p {
  color: var(--muted);
  font-size: 13.5px;
  line-height: 1.4;
}

.setting.is-disabled {
  opacity: 0.45;
}

.setting.is-disabled label {
  cursor: default;
}

.switch {
  appearance: none;
  -webkit-appearance: none;
  position: relative;
  flex: none;
  width: 50px;
  height: 30px;
  margin: 0;
  border-radius: 999px;
  background: var(--switch-off);
  cursor: pointer;
  transition: background 0.2s;
}

.switch::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(20, 24, 50, 0.25);
  transition: transform 0.2s cubic-bezier(0.3, 0.7, 0.4, 1.2);
}

.switch:checked {
  background: var(--primary);
}

.switch:checked::after {
  transform: translateX(20px);
}

.switch:disabled {
  cursor: default;
}

.stepper {
  display: inline-flex;
  align-items: center;
  flex: none;
  padding: 3px;
  border-radius: 999px;
  background: var(--inset);
}

.stepper button {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-sm);
  transition: transform 0.1s, color 0.15s;
}

.stepper button:hover:not([aria-disabled='true']) {
  color: var(--primary);
}

.stepper button:active:not([aria-disabled='true']) {
  transform: scale(0.92);
}

.stepper button[aria-disabled='true'] {
  opacity: 0.4;
  cursor: default;
  box-shadow: none;
}

.stepper svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.4;
  stroke-linecap: round;
}

.stepper output {
  min-width: 34px;
  text-align: center;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 18px;
}

/* ── Look & paper ───────────────────────────────────────────── */

.field {
  margin-bottom: 16px;
  min-width: 0;
}

.field-label {
  display: block;
  margin-bottom: 8px;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.tiles {
  display: grid;
  gap: 8px;
}

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

.tiles-3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.tile-body {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  height: 100%;
  padding: 7px 7px 8px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  transition: border-color 0.15s, background 0.15s, transform 0.1s;
}

.tile-art {
  display: flex;
  justify-content: center;
  width: 100%;
  padding: 6px 0;
  border-radius: 9px;
  background: var(--paper);
  box-shadow: inset 0 0 0 1px var(--border);
}

.tile-art svg {
  display: block;
  height: 34px;
  width: auto;
  max-width: 100%;
}

.tile-label {
  font-size: 13.5px;
  font-weight: 600;
  line-height: 1.2;
  text-align: center;
}

.segmented {
  display: flex;
  gap: 4px;
  padding: 4px;
  border-radius: var(--radius-sm);
  background: var(--inset);
}

.segmented label {
  position: relative;
  flex: 1;
  min-width: 0;
}

.segmented span {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 36px;
  padding: 0 8px;
  border-radius: 10px;
  font-size: 14.5px;
  font-weight: 600;
  color: var(--muted);
  transition: background 0.15s, color 0.15s, box-shadow 0.15s;
}

.segmented label:hover span {
  color: var(--text);
}

.segmented input:checked + span {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-sm), 0 0 0 1px var(--border);
}

.orient-icon {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
}

/* ── Preview ────────────────────────────────────────────────── */

.preview {
  position: sticky;
  top: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  height: calc(100vh - 32px);
  height: calc(100dvh - 32px);
  min-width: 0;
}

.preview-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 4px;
}

.preview-title {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 4px 12px;
  min-width: 0;
}

.preview-title h2 {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 600;
}

.summary {
  color: var(--muted);
  font-size: 14px;
  font-weight: 500;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  height: 48px;
  padding: 0 22px;
  border: 0;
  border-radius: 14px;
  font-size: 16px;
  font-weight: 700;
  white-space: nowrap;
  transition: transform 0.12s, box-shadow 0.15s, background 0.15s;
}

.btn svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.btn-primary {
  background: var(--primary);
  color: var(--on-primary);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.25) inset, 0 8px 20px -6px var(--primary-ring);
}

.btn-primary:hover {
  background: var(--primary-hover);
  transform: translateY(-1px);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.25) inset, 0 12px 24px -8px var(--primary-ring);
}

.btn-primary:active {
  transform: translateY(0);
}

.btn-block {
  width: 100%;
}

.pages {
  --sheet-ratio: 612 / 792;
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 28px;
  min-height: 0;
  padding: 32px;
  overflow: auto;
  overscroll-behavior: contain;
  border-radius: var(--radius);
  background-color: var(--preview-bg);
  background-image: radial-gradient(var(--preview-dot) 1.2px, transparent 1.2px);
  background-size: 20px 20px;
  box-shadow: inset 0 0 0 1px var(--border);
}

.sheet {
  flex: none;
  width: 100%;
  max-width: 720px;
  aspect-ratio: var(--sheet-ratio);
  border-radius: 6px;
  background: #fff;
  box-shadow: var(--shadow-sheet);
  overflow: hidden;
}

.pages.is-landscape .sheet {
  max-width: 960px;
}

.sheet svg {
  display: block;
  width: 100%;
  height: 100%;
}

.print-tip {
  text-align: center;
  color: var(--muted);
  font-size: 13.5px;
}

.print-tip strong {
  color: var(--text);
  font-weight: 700;
}

/* ── Footer ─────────────────────────────────────────────────── */

.site-footer {
  max-width: 1480px;
  margin: 0 auto;
  padding: 8px 28px 36px;
  color: var(--faint);
  font-size: 13.5px;
  text-align: center;
}

.mobile-print {
  display: none;
}

.noscript {
  max-width: 480px;
  margin: 24px auto;
  padding: 16px;
  border-radius: 12px;
  background: var(--notice-bg);
  color: var(--notice-text);
  text-align: center;
}

/* ── Responsive ─────────────────────────────────────────────── */

@media (max-width: 1080px) {
  .brand-tag {
    display: none;
  }
}

@media (max-width: 960px) {
  .layout {
    grid-template-columns: minmax(0, 1fr);
    max-width: 720px;
    padding: 0 16px 16px;
    gap: 22px;
  }

  .topbar {
    max-width: 720px;
    padding: 16px 16px 14px;
    flex-wrap: wrap;
    gap: 12px;
  }

  .preview {
    position: static;
    height: auto;
  }

  .preview .btn-primary {
    display: none;
  }

  .pages {
    flex: none;
    padding: 18px;
    gap: 18px;
    overflow: visible;
  }

  .site-footer {
    padding-bottom: 110px;
  }

  .mobile-print {
    display: block;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 10;
    padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
    background: color-mix(in srgb, var(--bg) 82%, transparent);
    -webkit-backdrop-filter: blur(14px);
    backdrop-filter: blur(14px);
    border-top: 1px solid var(--border);
  }

  .mobile-print .btn {
    max-width: 688px;
    margin: 0 auto;
    display: flex;
  }
}

@media (max-width: 520px) {
  .privacy-pill {
    margin-left: 0;
    width: 100%;
    justify-content: center;
  }

  .card {
    padding: 16px;
    border-radius: 18px;
  }

  .size-picker {
    gap: 6px;
  }

  .size-card {
    padding: 6px 2px 8px;
  }

  .size-art {
    height: 48px;
  }

  .size-art svg {
    height: calc(8px + var(--h) * 28px);
  }

  .size-name {
    font-size: 11px;
  }

  .tile-art svg {
    height: 28px;
  }

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

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition: none !important;
  }
}

/* ── Print: only the sheets ─────────────────────────────────── */

@media screen {
  .print-root {
    display: none;
  }
}

@media print {
  html,
  body {
    margin: 0 !important;
    padding: 0 !important;
    background: #fff !important;
  }

  /* Hide everything but the sheets, including anything the host injects
     (Netlify adds a fixed "Powered by Netlify" badge that would print on every page). */
  body > :not(.print-root) {
    display: none !important;
  }

  .print-root {
    display: block !important;
  }

  /* With the page margin at 0 the sheet fills the paper at exact size. If the
     browser keeps margins anyway (a remembered Margins setting, or a header and
     footer), 100vw/100vh shrink to the printable area and the sheet scales down
     to fit instead of spilling onto a second page. The box is a hair shorter
     than the page so rounding never adds a blank page; only the sheet's blank
     bottom margin is clipped. */
  .print-sheet {
    width: min(var(--print-w), 100vw);
    height: calc(min(var(--print-h), 100vh) - 0.03in);
    overflow: hidden;
    break-after: page;
    page-break-after: always;
    break-inside: avoid;
  }

  .print-sheet:last-child {
    break-after: auto;
    page-break-after: auto;
  }

  .print-sheet svg {
    display: block;
    width: 100%;
    height: min(var(--print-h), 100vh);
  }

  * {
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
}
