/* PrintGrid — N-up print layout generator.
   Shared teal design language: Inter, soft slate surfaces, 18px radii. */

:root {
  color-scheme: light;
  --page: #f8fafc;
  --surface: #fff;
  --surface-soft: #f1f5f9;
  --text: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --brand: #14b8a6;
  --brand-strong: #0d9488;
  --brand-deep: #0f766e;
  --brand-soft: rgba(20, 184, 166, .09);
  --paper: #fff;
  --danger: #b91c1c;
  --danger-solid: #dc2626;
  --danger-border: #fecaca;
  --danger-bg: #fef2f2;
  --shadow: 0 8px 26px rgba(15, 23, 42, .06);
  --shadow-sm: 0 1px 3px rgba(15, 23, 42, .1);
  --shadow-float: 0 14px 34px rgba(15, 23, 42, .18);
  --shadow-teal: 0 7px 17px rgba(20, 184, 166, .22);
  --radius: 18px;
  --radius-md: 13px;
  --radius-sm: 9px;
  --font: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
}

[data-theme="dark"] {
  color-scheme: dark;
  --page: #0b1120;
  --surface: #101a2e;
  --surface-soft: #16223a;
  --text: #e2e8f0;
  --muted: #94a3b8;
  --line: #26354a;
  --brand: #2dd4bf;
  --brand-strong: #14b8a6;
  --brand-deep: #2dd4bf;
  --brand-soft: rgba(45, 212, 191, .1);
  --paper: #fff;
  --danger: #fecaca;
  --danger-border: #7f1d1d;
  --danger-bg: #351c27;
  --shadow: 0 12px 30px rgba(0, 0, 0, .2);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, .35);
  --shadow-float: 0 16px 36px rgba(0, 0, 0, .45);
  --shadow-teal: 0 7px 18px rgba(20, 184, 166, .28);
}

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

[hidden] { display: none !important; }

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

body {
  min-width: 320px;
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0;
  display: flex;
  flex-direction: column;
  background: var(--page);
  color: var(--text);
  font: 16px/1.6 var(--font);
  -webkit-font-smoothing: antialiased;
}

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

button, input, select { font: inherit; }

button { cursor: pointer; }

svg { flex: none; }

:focus-visible {
  outline: 3px solid var(--brand-strong);
  outline-offset: 3px;
}

.page-shell {
  width: min(100% - 48px, 1180px);
  margin: 0 auto;
  padding: 34px 0 52px;
  flex: 1;
}

/* ===== Hero ===== */
.hero {
  max-width: 760px;
  margin: 0 auto 24px;
  text-align: center;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--brand-deep);
  font-size: .72rem;
  font-weight: 800;
  letter-spacing: .12em;
}

.hero h1 { margin: 0; font-size: clamp(1.75rem, 3.4vw, 2.4rem); line-height: 1.15; letter-spacing: -.035em; text-wrap: balance; }

.hero > p:not(.eyebrow) { max-width: 680px; margin: 10px auto 0; color: var(--muted); font-size: 1rem; text-wrap: balance; }

.privacy-note {
  width: fit-content;
  max-width: 100%;
  margin: 16px auto 0;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 13px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  font-size: .8rem;
  text-align: left;
}

.privacy-note svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: var(--brand-deep);
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ===== Shared panels ===== */
.app-shell {
  display: grid;
  gap: 16px;
  min-width: 0;
}

.panel,
.sidebar,
.preview-area,
.thumb-strip,
.bottom-actions,
.content-section {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.panel { padding: clamp(18px, 2.8vw, 24px); }

.panel-heading {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  min-width: 0;
}

.panel-heading > div { min-width: 0; }

.step-number {
  display: grid;
  width: 36px;
  height: 36px;
  flex: none;
  place-items: center;
  border-radius: 11px;
  background: var(--brand-soft);
  color: var(--brand-deep);
  font-size: .75rem;
  font-weight: 800;
  letter-spacing: .02em;
}

.panel-heading h2 {
  font-size: 1.08rem;
  line-height: 1.35;
  letter-spacing: -.02em;
}

.panel-heading p {
  margin-top: 2px;
  color: var(--muted);
  font-size: .84rem;
}

/* ===== Upload / empty state ===== */
.upload-section { padding-bottom: clamp(16px, 2.4vw, 20px); }

.upload-section .panel-heading { margin-bottom: 16px; }

.upload-area {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: clamp(24px, 4.2vw, 38px) 18px;
  border: 2px dashed var(--line);
  border-radius: 14px;
  background: var(--page);
  text-align: center;
  cursor: pointer;
  transition: border-color .16s ease, background-color .16s ease;
}

.upload-area:hover,
.upload-area.drag-over {
  border-color: var(--brand);
  background: var(--brand-soft);
}

.upload-icon {
  display: grid;
  place-items: center;
  width: 64px;
  height: 64px;
  margin-bottom: 6px;
  border-radius: 18px;
  background: var(--brand-soft);
  color: var(--brand-deep);
}

.upload-text {
  margin-top: 2px;
  font-size: 1.02rem;
  font-weight: 700;
}

.upload-hint {
  color: var(--muted);
  font-size: .79rem;
}

.upload-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  margin-top: 14px;
  padding: 9px 20px;
  border: 1px solid transparent;
  border-radius: 11px;
  background: linear-gradient(135deg, var(--brand-deep), var(--brand));
  color: #fff;
  font-size: .84rem;
  font-weight: 700;
  transition: transform .16s ease, box-shadow .16s ease;
}

.upload-btn:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-teal);
}

.upload-btn:active { transform: none; }

.upload-meta {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 4px 16px;
  margin-top: 14px;
  color: var(--muted);
  font-size: .72rem;
}

.upload-meta span + span { position: relative; }

.upload-meta span + span::before {
  content: "";
  position: absolute;
  left: -9px;
  top: 50%;
  width: 3px;
  height: 3px;
  margin-top: -1px;
  border-radius: 50%;
  background: var(--line);
}

/* ===== Workspace layout ===== */
.workspace {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  min-width: 0;
}

/* ===== Settings sidebar ===== */
.sidebar {
  flex: 0 0 306px;
  width: 306px;
  max-width: 100%;
  min-width: 0;
  padding: 18px;
}

.sidebar-heading { margin-bottom: 4px; }

.settings-card {
  margin-top: 13px;
  padding-top: 13px;
  border-top: 1px solid var(--line);
}

.sidebar-heading + .settings-card {
  margin-top: 0;
  padding-top: 0;
  border-top: 0;
}

.settings-title {
  margin-bottom: 9px;
  color: var(--muted);
  font-size: .72rem;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.settings-desc {
  margin: -4px 0 9px;
  color: var(--muted);
  font-size: .75rem;
}

.control-row {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  margin-bottom: 9px;
}

.control-row:last-child { margin-bottom: 0; }

.control-label {
  flex: 0 0 58px;
  color: var(--muted);
  font-size: .76rem;
  font-weight: 600;
}

.control-select {
  flex: 1;
  min-width: 0;
  min-height: 38px;
  padding: 7px 30px 7px 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background-color: var(--surface-soft);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  color: var(--text);
  font-size: .8rem;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
  transition: border-color .16s ease, box-shadow .16s ease;
}

.control-select:hover { border-color: var(--brand); }

.control-select:focus-visible {
  outline: 0;
  border-color: var(--brand-strong);
  box-shadow: 0 0 0 3px var(--brand-soft);
}

/* Range sliders */
.control-range {
  flex: 1;
  min-width: 0;
  height: 20px;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  accent-color: var(--brand-strong);
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
}

.control-range::-webkit-slider-runnable-track {
  height: 4px;
  border-radius: 999px;
  background: var(--line);
}

.control-range::-moz-range-track {
  height: 4px;
  border-radius: 999px;
  background: var(--line);
}

.control-range::-webkit-slider-thumb {
  width: 16px;
  height: 16px;
  margin-top: -6px;
  border: 2px solid var(--surface);
  border-radius: 50%;
  background: var(--brand-strong);
  box-shadow: var(--shadow-sm);
  -webkit-appearance: none;
  appearance: none;
}

.control-range::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border: 2px solid var(--surface);
  border-radius: 50%;
  background: var(--brand-strong);
  box-shadow: var(--shadow-sm);
}

.control-range:hover::-webkit-slider-thumb { background: var(--brand-deep); }
.control-range:hover::-moz-range-thumb { background: var(--brand-deep); }

.control-range:focus-visible {
  outline: 0;
}

.control-range:focus-visible::-webkit-slider-thumb {
  box-shadow: 0 0 0 4px var(--brand-soft);
}

.control-range:focus-visible::-moz-range-thumb {
  box-shadow: 0 0 0 4px var(--brand-soft);
}

.range-value {
  flex: 0 0 38px;
  color: var(--muted);
  font-size: .71rem;
  font-variant-numeric: tabular-nums;
  text-align: right;
}

/* Orientation segmented control */
.orientation-btns {
  display: flex;
  flex: 1;
  gap: 3px;
  min-width: 0;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--surface-soft);
}

.orient-btn {
  display: flex;
  flex: 1;
  align-items: center;
  justify-content: center;
  gap: 5px;
  min-width: 0;
  min-height: 30px;
  padding: 4px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-size: .74rem;
  font-weight: 650;
  transition: background-color .16s ease, color .16s ease, box-shadow .16s ease;
}

.orient-btn:hover { color: var(--brand-deep); }

.orient-btn.active {
  background: var(--surface);
  color: var(--brand-deep);
  box-shadow: var(--shadow-sm);
}

/* Grid presets */
.grid-presets {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 5px;
}

.grid-btn {
  min-height: 34px;
  padding: 5px 2px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font-size: .75rem;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
  text-align: center;
  transition: border-color .14s ease, background-color .14s ease, color .14s ease, transform .14s ease;
}

.grid-btn:hover {
  border-color: var(--brand);
  color: var(--brand-deep);
  background: var(--brand-soft);
}

.grid-btn:active { transform: scale(.97); }

.grid-btn.active {
  border-color: transparent;
  background: linear-gradient(135deg, var(--brand-deep), var(--brand));
  color: #fff;
  box-shadow: var(--shadow-teal);
}

.grid-btn-custom { color: var(--muted); }

.grid-btn-custom.active {
  border-color: var(--brand);
  background: var(--brand-soft);
  color: var(--brand-deep);
  box-shadow: none;
}

.grid-info {
  margin-top: 10px;
  padding: 7px 10px;
  border-radius: 10px;
  background: var(--brand-soft);
  color: var(--brand-deep);
  font-size: .77rem;
  font-weight: 600;
  text-align: center;
}

.grid-info-value strong { font-size: .9rem; font-weight: 800; }

/* Custom grid + custom margins */
.custom-grid-form {
  margin-bottom: 9px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--page);
}

.custom-grid-inputs {
  display: flex;
  align-items: flex-end;
  gap: 6px;
}

.custom-input-group {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}

.custom-input-group label {
  color: var(--muted);
  font-size: .62rem;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
}

.custom-input-group input {
  width: 100%;
  min-width: 0;
  min-height: 34px;
  padding: 5px 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font-size: .8rem;
  text-align: center;
  transition: border-color .16s ease, box-shadow .16s ease;
}

.custom-input-group input:focus-visible {
  outline: 0;
  border-color: var(--brand-strong);
  box-shadow: 0 0 0 3px var(--brand-soft);
}

.custom-x {
  padding-bottom: 7px;
  color: var(--muted);
  font-size: .8rem;
}

.custom-apply-btn {
  min-height: 34px;
  padding: 5px 11px;
  border: 0;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--brand-deep), var(--brand));
  color: #fff;
  font-size: .74rem;
  font-weight: 700;
  transition: box-shadow .16s ease;
}

.custom-apply-btn:hover { box-shadow: var(--shadow-teal); }

.custom-margins-toggle { margin-bottom: 7px; }

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  font-size: .75rem;
  cursor: pointer;
  user-select: none;
}

.checkbox-label input {
  width: 15px;
  height: 15px;
  margin: 0;
  accent-color: var(--brand-strong);
  cursor: pointer;
}

.custom-margins { padding: 3px 0 9px; }

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

.margin-hint {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  font-size: .66rem;
  text-align: right;
}

.reset-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  width: 100%;
  min-height: 40px;
  margin-top: 14px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--surface);
  color: var(--muted);
  font-size: .77rem;
  font-weight: 650;
  transition: border-color .16s ease, background-color .16s ease, color .16s ease;
}

.reset-btn:hover {
  border-color: var(--danger-border);
  background: var(--danger-bg);
  color: var(--danger);
}

/* ===== Preview ===== */
.preview-area {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  position: sticky;
  top: 18px;
}

.preview-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 12px;
  padding: 11px 16px;
  border-bottom: 1px solid var(--line);
}

.sheet-nav {
  display: flex;
  align-items: center;
  gap: 6px;
}

.nav-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  min-height: 32px;
  padding: 4px 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font-size: .75rem;
  font-weight: 650;
  transition: border-color .14s ease, background-color .14s ease, color .14s ease;
}

.nav-btn:hover:not(:disabled) {
  border-color: var(--brand);
  background: var(--brand-soft);
  color: var(--brand-deep);
}

.nav-btn:disabled {
  opacity: .45;
  cursor: not-allowed;
}

.sheet-info {
  min-width: 88px;
  color: var(--text);
  font-size: .8rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  text-align: center;
}

.sheet-stats {
  color: var(--muted);
  font-size: .72rem;
  line-height: 1.5;
}

.sheet-stats span { font-variant-numeric: tabular-nums; }

.preview-canvas-wrapper {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 300px;
  padding: clamp(12px, 2vw, 20px);
  background: var(--surface-soft);
}

#previewCanvas {
  display: block;
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: min(64vh, 680px);
  border-radius: 3px;
  background: var(--paper);
  box-shadow: 0 12px 30px rgba(15, 23, 42, .16);
}

[data-theme="dark"] #previewCanvas {
  box-shadow: 0 12px 30px rgba(0, 0, 0, .45);
}

/* ===== Thumbnails ===== */
.thumb-strip { overflow: hidden; }

.thumb-strip-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--line);
}

.thumb-strip-title {
  color: var(--muted);
  font-size: .76rem;
  font-weight: 800;
  letter-spacing: .07em;
  text-transform: uppercase;
}

.thumb-strip-title span { color: var(--brand-deep); }

.thumb-strip-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.thumb-hint {
  color: var(--muted);
  font-size: .71rem;
}

.strip-action-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 32px;
  padding: 5px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--muted);
  font-size: .73rem;
  font-weight: 650;
  transition: border-color .14s ease, background-color .14s ease, color .14s ease;
}

.strip-action-btn:hover {
  border-color: var(--brand);
  background: var(--brand-soft);
  color: var(--brand-deep);
}

.thumb-list {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 12px 16px;
  overflow-x: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--line) transparent;
}

.thumb-list::-webkit-scrollbar { height: 6px; }
.thumb-list::-webkit-scrollbar-track { background: transparent; }

.thumb-list::-webkit-scrollbar-thumb {
  border-radius: 999px;
  background: var(--line);
}

.thumb-item {
  position: relative;
  flex: 0 0 88px;
  width: 88px;
  overflow: hidden;
  border: 2px solid transparent;
  border-radius: 11px;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  cursor: grab;
  transition: border-color .15s ease, box-shadow .15s ease, transform .15s ease, opacity .15s ease;
}

.thumb-item:hover,
.thumb-item:focus-within {
  border-color: var(--brand);
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}

.thumb-item:active { cursor: grabbing; }

.thumb-item.dragging {
  opacity: .4;
  transform: scale(.96);
}

.thumb-item.drag-over {
  border-color: var(--brand-strong);
  box-shadow: 0 0 0 3px var(--brand-soft);
}

.thumb-item canvas,
.thumb-item img {
  display: block;
  width: 100%;
  height: 96px;
  object-fit: contain;
  background: var(--paper);
}

.thumb-item-label {
  padding: 4px 5px;
  overflow: hidden;
  border-top: 1px solid var(--line);
  background: var(--surface-soft);
  color: var(--muted);
  font-size: .63rem;
  font-weight: 600;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.thumb-item-actions {
  position: absolute;
  top: 4px;
  right: 4px;
  display: flex;
  gap: 3px;
  opacity: 0;
  transition: opacity .15s ease;
}

.thumb-item:hover .thumb-item-actions,
.thumb-item:focus-within .thumb-item-actions { opacity: 1; }

.thumb-action {
  display: grid;
  width: 22px;
  height: 22px;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: rgba(15, 23, 42, .68);
  color: #fff;
  font-size: .82rem;
  line-height: 1;
  transition: background-color .14s ease, transform .14s ease;
}

.thumb-action:hover {
  background: rgba(15, 23, 42, .88);
  transform: scale(1.08);
}

.thumb-action.delete:hover { background: var(--danger-solid); }

@media (hover: none) {
  .thumb-item-actions { opacity: 1; }
}

/* ===== Actions ===== */
.bottom-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  padding: 12px 16px;
}

.action-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 42px;
  padding: 9px 16px;
  border: 1px solid transparent;
  border-radius: 11px;
  font-size: .81rem;
  font-weight: 700;
  transition: transform .16s ease, box-shadow .16s ease, border-color .16s ease, background-color .16s ease, color .16s ease;
}

.action-btn:hover { transform: translateY(-1px); }
.action-btn:active { transform: none; }

.action-btn-primary {
  background: linear-gradient(135deg, var(--brand-deep), var(--brand));
  color: #fff;
}

.action-btn-primary:hover { box-shadow: var(--shadow-teal); }

.action-btn-secondary {
  border-color: var(--line);
  background: var(--surface);
  color: var(--text);
}

.action-btn-secondary:hover {
  border-color: var(--brand);
  background: var(--brand-soft);
  color: var(--brand-deep);
}

/* Teal gradients get bright in dark mode, so pair them with dark ink. */
[data-theme="dark"] .upload-btn,
[data-theme="dark"] .custom-apply-btn,
[data-theme="dark"] .action-btn-primary,
[data-theme="dark"] .grid-btn.active {
  color: #04211e;
}

/* ===== Loading ===== */
.loading-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  background: var(--page);
  background: color-mix(in srgb, var(--page) 90%, transparent);
  -webkit-backdrop-filter: blur(5px);
  backdrop-filter: blur(5px);
}

.loading-spinner {
  width: 38px;
  height: 38px;
  border: 3px solid var(--line);
  border-top-color: var(--brand-strong);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}

.loading-text {
  color: var(--muted);
  font-size: .87rem;
  font-weight: 600;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ===== Content below the app ===== */
.content-section {
  margin-top: 20px;
  padding: clamp(18px, 3vw, 26px);
}

.section-heading { margin-bottom: 15px; }

.section-heading .eyebrow { margin-bottom: 4px; }

.section-heading h2 {
  font-size: clamp(1.2rem, 2.8vw, 1.5rem);
  letter-spacing: -.03em;
}

.steps-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.steps-grid li {
  display: flex;
  gap: 11px;
  padding: 14px;
  border-radius: var(--radius-md);
  background: var(--page);
}

.steps-grid li > span {
  color: var(--brand-deep);
  font-size: .72rem;
  font-weight: 800;
}

.steps-grid h3 {
  margin-bottom: 4px;
  font-size: .89rem;
}

.steps-grid p,
.faq-section details p {
  color: var(--muted);
  font-size: .83rem;
}

.faq-section details { border-top: 1px solid var(--line); }

.faq-section summary {
  padding: 12px 2px;
  font-weight: 700;
  cursor: pointer;
}

.faq-section summary::marker { color: var(--brand-deep); }

.faq-section details p { padding: 0 2px 14px; }

.print-container { display: none; }

/* ===== Responsive ===== */
@media (max-width: 900px) {
  .workspace {
    flex-direction: column;
    gap: 14px;
  }

  .preview-area {
    order: 1;
    position: static;
    width: 100%;
  }

  .sidebar {
    order: 2;
    width: 100%;
    flex: none;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0 24px;
    align-items: start;
  }

  .sidebar-heading,
  .reset-btn { grid-column: 1 / -1; }

  .sidebar-heading + .settings-card {
    margin-top: 13px;
    padding-top: 13px;
    border-top: 1px solid var(--line);
  }

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

  .orientation-btns { max-width: 320px; }

  #previewCanvas { max-height: 52vh; }
}

@media (max-width: 700px) {
  .page-shell {
    width: min(100% - 32px, 560px);
    padding: 28px 0 150px;
  }

  .hero { margin-bottom: 20px; }

  .sidebar {
    display: flex;
    flex-direction: column;
    gap: 0;
    padding: 16px;
  }

  .sidebar-heading + .settings-card {
    margin-top: 0;
    padding-top: 0;
    border-top: 0;
  }

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

  .orientation-btns { max-width: none; }

  .preview-header { padding: 10px 12px; }

  .preview-canvas-wrapper { min-height: 260px; padding: 12px; }

  #previewCanvas { max-height: 44vh; }

  .thumb-hint { display: none; }

  .bottom-actions {
    position: fixed;
    right: 12px;
    bottom: calc(12px + env(safe-area-inset-bottom, 0px));
    left: 12px;
    z-index: 60;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    width: auto;
    max-width: 536px;
    margin: 0 auto;
    padding: 10px;
    border-radius: 16px;
    box-shadow: var(--shadow-float);
  }

  .action-btn {
    flex: 1 1 calc(50% - 4px);
    min-height: 44px;
    padding: 8px 10px;
    font-size: .8rem;
  }

  .action-btn-primary { flex-basis: 100%; }

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

@media (max-width: 440px) {
  .page-shell {
    width: min(100% - 24px, 400px);
    padding-top: 22px;
  }

  .hero h1 { font-size: 2rem; }

  .hero > p:not(.eyebrow) { font-size: .94rem; }

  .privacy-note {
    align-items: flex-start;
    border-radius: 12px;
    font-size: .75rem;
  }

  .panel,
  .sidebar,
  .content-section { padding: 16px; }

  .upload-section { padding-bottom: 14px; }

  .upload-area { padding: 24px 14px; }

  .upload-icon { width: 56px; height: 56px; }

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

  .control-label { flex-basis: 52px; }

  .sheet-stats {
    width: 100%;
    text-align: left;
  }

  .preview-canvas-wrapper { min-height: 220px; }

  #previewCanvas { max-height: 40vh; }

  .thumb-strip-header { padding: 10px 12px; }

  .thumb-list { padding: 10px 12px; }

  .thumb-item { flex-basis: 80px; width: 80px; }

  .thumb-item canvas,
  .thumb-item img { height: 88px; }

  .bottom-actions {
    right: 8px;
    left: 8px;
    bottom: calc(8px + env(safe-area-inset-bottom, 0px));
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}
