/* ==========================================================================
   Miriam's Quiltcaster — Stylesheet
   Typography synced with the exported PDF booklet:
     - Display Serif: DM Serif Display (titles & section headings)
     - UI Sans:       Plus Jakarta Sans (body, buttons, controls)
     - Monospace:     JetBrains Mono (fabric codes, dimensions, yardage)
   Breakpoints:
     - <= 960px: iPad portrait / single-column stack (preview promoted to top)
     - <= 600px: iPhone / narrow mobile (touch-sized targets, 16px inputs)
   ========================================================================== */

@font-face {
  font-family: "DM Serif Display";
  src: url("fonts/DMSerifDisplay-Regular.ttf") format("truetype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Plus Jakarta Sans";
  src: url("fonts/PlusJakartaSans-Regular.ttf") format("truetype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Plus Jakarta Sans";
  src: url("fonts/PlusJakartaSans-SemiBold.ttf") format("truetype");
  font-weight: 600;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Plus Jakarta Sans";
  src: url("fonts/PlusJakartaSans-Bold.ttf") format("truetype");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "JetBrains Mono";
  src: url("fonts/JetBrainsMono-SemiBold.ttf") format("truetype");
  font-weight: 600;
  font-style: normal;
  font-display: swap;
}

:root {
  --font-serif: "DM Serif Display", Georgia, "Times New Roman", serif;
  --font-sans: "Plus Jakarta Sans", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --bg: #f6f2eb;
  --surface: #ffffff;
  --surface-muted: #efe9df;
  --border: #dfd6c7;
  --border-strong: #c8bba6;
  --text: #221f1a;
  --text-muted: #6c6458;
  --accent: #b84d2c;
  --accent-hover: #9d3f22;
  --danger: #b5342a;
  --radius: 14px;
  --radius-sm: 8px;
  --shadow: 0 6px 24px rgba(34, 31, 26, 0.06);
}

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

body {
  font-family: var(--font-sans);
  line-height: 1.45;
  color: var(--text);
  background-color: var(--bg);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
}

/* Header */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.75rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.brand-icon {
  width: 38px;
  height: 38px;
  border-radius: 9px;
  box-shadow: 0 2px 6px rgba(34, 31, 26, 0.16);
  flex-shrink: 0;
  display: block;
}

.brand h1 {
  font-family: var(--font-serif);
  font-size: 1.42rem;
  font-weight: 400;
  letter-spacing: -0.01em;
  line-height: 1.1;
}

.tagline {
  font-size: 0.82rem;
  color: var(--text-muted);
}

/* Buttons & Icons */
.btn {
  font: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  padding: 0.5rem 0.9rem;
  min-height: 38px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  cursor: pointer;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  transition: background-color 0.15s ease, border-color 0.15s ease, transform 0.1s ease;
}

.icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.btn:active {
  transform: translateY(1px);
}

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

.btn-secondary:hover {
  background: var(--surface-muted);
}

.btn-ghost {
  background: var(--surface);
  border-color: var(--border);
  color: var(--text);
}

.btn-ghost:hover {
  background: var(--surface-muted);
  border-color: var(--border-strong);
}

.btn-small {
  font-size: 0.8rem;
  padding: 0.38rem 0.72rem;
  min-height: 34px;
  touch-action: none;
}

.btn-subtle {
  background: var(--surface-muted);
  border-color: var(--border);
  color: var(--text);
  font-size: 0.8rem;
  padding: 0.45rem 0.75rem;
}

.btn-subtle:hover {
  border-color: var(--border-strong);
  background: #e7dfd2;
}

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #ffffff;
  font-size: 0.86rem;
  padding: 0.5rem 1rem;
}

.btn-primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

.btn-primary:disabled {
  opacity: 0.6;
  cursor: wait;
}

.project-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.34rem 0.7rem;
  min-height: 38px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text-muted);
  max-width: 280px;
  cursor: text;
  transition: border-color 0.15s ease, background-color 0.15s ease, box-shadow 0.15s ease;
}

.project-chip:hover {
  border-color: var(--border-strong);
  background: var(--surface);
}

.project-chip:focus-within {
  border-color: var(--accent);
  background: var(--surface);
  box-shadow: 0 0 0 3px rgba(184, 77, 44, 0.12);
}

.project-name-input {
  font: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text);
  background: transparent;
  border: none;
  outline: none;
  min-width: 90px;
  width: 155px;
}

.project-chip .icon-edit {
  width: 13px;
  height: 13px;
  opacity: 0.55;
  transition: opacity 0.15s ease, color 0.15s ease;
}

.project-chip:hover .icon-edit,
.project-chip:focus-within .icon-edit {
  opacity: 1;
  color: var(--accent);
}

.action-group {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: wrap;
}

/* Main shell */
.app-shell {
  flex: 1;
  width: 100%;
  max-width: 1280px;
  margin: 0 auto;
  padding: 1.75rem;
  display: flex;
  flex-direction: column;
}

/* Initial Drop Zone */
.drop-stage {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  min-height: 62vh;
}

.drop-zone {
  width: 100%;
  max-width: 580px;
  padding: 3.5rem 2rem;
  background: var(--surface);
  border: 2px dashed var(--border-strong);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  text-align: center;
  cursor: pointer;
  transition: border-color 0.18s ease, background-color 0.18s ease, transform 0.18s ease;
}

.drop-zone:hover,
.drop-zone:focus-visible {
  border-color: var(--accent);
  background: #fdfbf8;
  outline: none;
}

.drop-zone.is-dragover {
  border-color: var(--accent);
  background: #fbf3ee;
  transform: scale(1.015);
}

.drop-icon {
  margin-bottom: 1rem;
  display: flex;
  justify-content: center;
}

.drop-hero-icon {
  width: 76px;
  height: 76px;
  border-radius: 18px;
  box-shadow: 0 6px 18px rgba(34, 31, 26, 0.16);
  display: block;
}

.drop-zone h2 {
  font-family: var(--font-serif);
  font-size: 1.65rem;
  font-weight: 400;
  margin-bottom: 0.45rem;
}

.drop-zone p {
  color: var(--text-muted);
  font-size: 0.95rem;
  margin-bottom: 1.25rem;
}

.drop-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
  max-width: 480px;
  margin: 0 auto 1.25rem;
}

.btn-landing {
  width: 100%;
  min-height: 46px;
  font-size: 0.9rem;
  padding: 0.65rem 1rem;
}

@media (max-width: 520px) {
  .drop-actions {
    grid-template-columns: 1fr;
  }
}

.drop-hint {
  display: inline-block;
  font-size: 0.78rem;
  color: var(--text-muted);
  background: var(--surface-muted);
  padding: 0.3rem 0.75rem;
  border-radius: 999px;
}

.error-banner {
  color: var(--danger);
  background: #fdeceb;
  border: 1px solid #f5c6c2;
  padding: 0.6rem 1rem;
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  max-width: 580px;
  width: 100%;
  text-align: center;
}

/* Workspace Layout */
.workspace {
  display: grid;
  grid-template-columns: 370px minmax(0, 1fr);
  gap: 1.5rem;
  align-items: start;
}

.controls-panel {
  display: flex;
  flex-direction: column;
  gap: 1.15rem;
  min-width: 0;
}

.control-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.15rem 1.2rem;
  box-shadow: var(--shadow);
  min-width: 0;
  overflow: hidden;
}

.control-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 0.65rem;
}

.control-header label {
  font-weight: 700;
  font-size: 0.95rem;
}

.control-value {
  font-family: var(--font-mono);
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}

input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
  cursor: pointer;
}

.control-meta {
  display: flex;
  justify-content: space-between;
  font-size: 0.74rem;
  color: var(--text-muted);
  margin-top: 0.3rem;
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.9rem;
  padding-top: 0.8rem;
  border-top: 1px solid var(--border);
  font-size: 0.85rem;
  color: var(--text);
  cursor: pointer;
  user-select: none;
}

.checkbox-row input {
  accent-color: var(--accent);
  width: 15px;
  height: 15px;
  cursor: pointer;
}

/* Sizing & Seam Allowance */
.unit-toggle {
  display: inline-flex;
  background: var(--surface-muted);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 2px;
  gap: 2px;
}

.unit-btn {
  font: inherit;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0.18rem 0.5rem;
  border: none;
  border-radius: 4px;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: background-color 0.12s ease, color 0.12s ease;
}

.unit-btn.is-active {
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
}

.sizing-inputs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.65rem;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-size: 0.78rem;
  color: var(--text-muted);
  font-weight: 500;
}

.input-with-unit {
  display: flex;
  align-items: center;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  transition: border-color 0.15s ease;
}

.input-with-unit:focus-within {
  border-color: var(--accent);
}

.input-with-unit input[type="number"] {
  width: 100%;
  min-width: 0;
  border: none;
  background: transparent;
  padding: 0.45rem 0.55rem;
  font: inherit;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  outline: none;
}

.unit-suffix {
  padding: 0 0.55rem 0 0.25rem;
  font-size: 0.76rem;
  color: var(--text-muted);
  user-select: none;
}

.dimensions-summary {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.55rem;
  margin-top: 0.85rem;
  padding-top: 0.8rem;
  border-top: 1px solid var(--border);
}

.dimensions-summary-single {
  grid-template-columns: 1fr;
  margin-top: 0.75rem;
  padding-top: 0.7rem;
}

.quilt-size-row {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  margin-top: 0.7rem;
}

.quilt-preset-select {
  width: 100%;
  font: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.45rem 0.6rem;
  cursor: pointer;
  outline: none;
  transition: border-color 0.15s ease;
}

.quilt-preset-select:hover {
  border-color: var(--border-strong);
}

.quilt-preset-select:focus {
  border-color: var(--accent);
}

.field-label {
  font-size: 0.78rem;
  color: var(--text-muted);
  font-weight: 500;
}

.quilt-size-inputs {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  gap: 0.4rem;
}

.size-times {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  user-select: none;
}

.dim-stat-inline {
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
}

.dim-stat {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.5rem 0.6rem;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.dim-label {
  font-size: 0.7rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.dim-value {
  font-family: var(--font-mono);
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.preview-title {
  display: flex;
  align-items: baseline;
  gap: 0.65rem;
  flex-wrap: wrap;
}

.preview-heading {
  font-family: var(--font-serif);
  font-size: 1.15rem;
  font-weight: 400;
  color: var(--text);
}

.preview-dimensions {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  flex-wrap: wrap;
}

.wof-note {
  margin-top: 0.55rem;
  font-size: 0.72rem;
  color: var(--text-muted);
}

.swatch-header-row {
  display: flex;
  align-items: center;
  gap: 0.28rem;
  min-width: 0;
}

.swatch-code {
  display: inline-grid;
  place-items: center;
  min-width: 18px;
  height: 18px;
  padding: 0 0.24rem;
  border-radius: 4px;
  background: var(--surface-muted);
  border: 1px solid var(--border);
  font-family: var(--font-mono);
  font-size: 0.65rem;
  font-weight: 600;
  color: var(--text);
  flex-shrink: 0;
}

.swatch-fabric {
  font-family: var(--font-mono);
  font-size: 0.66rem;
  font-weight: 600;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* Palette Swatches */
.palette-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.5rem;
  margin-top: 0.95rem;
}

.swatch-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.4rem 0.45rem;
  min-width: 0;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  transition: border-color 0.15s ease;
}

.swatch-item:hover {
  border-color: var(--border-strong);
}

.swatch-color-wrap {
  position: relative;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  border: 1px solid rgba(0, 0, 0, 0.16);
  overflow: hidden;
  flex-shrink: 0;
  cursor: pointer;
}

.swatch-color-wrap input[type="color"] {
  position: absolute;
  inset: -6px;
  width: calc(100% + 12px);
  height: calc(100% + 12px);
  border: none;
  padding: 0;
  cursor: pointer;
  background: none;
}

.swatch-info {
  min-width: 0;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}

.swatch-hex {
  font-size: 0.76rem;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.swatch-count {
  font-size: 0.68rem;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.swatch-remove {
  width: 20px;
  height: 20px;
  border-radius: 999px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 0.95rem;
  line-height: 1;
  display: grid;
  place-items: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: background-color 0.12s ease, color 0.12s ease;
}

.swatch-remove:hover:not(:disabled) {
  background: #f5d8d5;
  color: var(--danger);
}

.swatch-remove:disabled {
  opacity: 0.25;
  cursor: not-allowed;
}

.palette-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.9rem;
}

.palette-actions .btn {
  flex: 1;
}

/* Preview Panel */
.preview-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.preview-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.85rem 1.15rem;
  border-bottom: 1px solid var(--border);
  background: #fcfaf7;
}

.preview-toolbar-actions {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  flex-wrap: wrap;
}

.btn-ghost.is-cropped {
  border-color: var(--accent);
  color: var(--accent);
  background: #fbf3ee;
}

/* Interactive Crop Stage */
.crop-stage {
  display: flex;
  flex-direction: column;
}

.crop-presets {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  flex-wrap: wrap;
}

.crop-aspect-btn.is-active {
  background: var(--accent);
  border-color: var(--accent);
  color: #ffffff;
}

.crop-canvas-frame {
  user-select: none;
  -webkit-user-select: none;
}

#crop-canvas {
  max-width: 100%;
  max-height: 68vh;
  width: auto;
  height: auto;
  border-radius: 4px;
  box-shadow: 0 10px 30px rgba(34, 31, 26, 0.16);
  display: block;
  touch-action: none;
  cursor: grab;
}

.crop-reextract-row {
  margin-top: 0;
  padding-top: 0;
  border-top: none;
}

.canvas-frame {
  position: relative;
  padding: 1.35rem 1.5rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 460px;
  background-image: radial-gradient(var(--border) 1px, transparent 1px);
  background-size: 16px 16px;
}

.quilt-measure-wrap {
  display: inline-grid;
  grid-template-columns: auto 28px;
  grid-template-rows: 26px auto;
  gap: 0.45rem 0.5rem;
  align-items: stretch;
  justify-items: stretch;
  max-width: 100%;
}

.ruler-top {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

.ruler-line {
  flex: 1;
  height: 1px;
  background: var(--border-strong);
  position: relative;
}

.ruler-line:first-child::before,
.ruler-line:last-child::after {
  content: "";
  position: absolute;
  top: -4px;
  width: 1px;
  height: 9px;
  background: var(--border-strong);
}

.ruler-line:first-child::before { left: 0; }
.ruler-line:last-child::after { right: 0; }

.ruler-side {
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.45rem;
}

.ruler-line-v {
  flex: 1;
  width: 1px;
  background: var(--border-strong);
  position: relative;
}

.ruler-line-v:first-child::before,
.ruler-line-v:last-child::after {
  content: "";
  position: absolute;
  left: -4px;
  width: 9px;
  height: 1px;
  background: var(--border-strong);
}

.ruler-line-v:first-child::before { top: 0; }
.ruler-line-v:last-child::after { bottom: 0; }

.ruler-badge {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.1rem 0.48rem;
  white-space: nowrap;
  box-shadow: 0 1px 3px rgba(34, 31, 26, 0.06);
}

.ruler-side .ruler-badge {
  writing-mode: vertical-rl;
  padding: 0.48rem 0.1rem;
}

#quilt-canvas {
  max-width: 100%;
  border-radius: 4px;
  box-shadow: 0 10px 30px rgba(34, 31, 26, 0.14);
  display: block;
}

.drop-overlay {
  position: absolute;
  inset: 0.75rem;
  border: 2px dashed var(--accent);
  border-radius: var(--radius-sm);
  background: rgba(251, 243, 238, 0.92);
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--accent);
  pointer-events: none;
}

/* Bottom Export Bar (underneath image preview) */
.export-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.95rem 1.25rem;
  border-top: 1px solid var(--border);
  background: #fcfaf7;
  flex-wrap: wrap;
}

.export-title-field {
  display: flex;
  flex-direction: column;
  gap: 0.22rem;
  flex: 1 1 200px;
  min-width: 180px;
}

.export-title-field label {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}

.pattern-title-input {
  font: inherit;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.42rem 0.65rem;
  outline: none;
  transition: border-color 0.15s ease;
}

.pattern-title-input:focus {
  border-color: var(--accent);
}

.export-actions {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  flex-wrap: wrap;
}

.segmented {
  display: inline-flex;
  background: var(--surface-muted);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 2px;
  gap: 2px;
}

.segmented-btn {
  font: inherit;
  font-size: 0.78rem;
  font-weight: 600;
  padding: 0.35rem 0.7rem;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background-color 0.12s ease, color 0.12s ease;
}

.segmented-btn.is-active {
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
}

[hidden] {
  display: none !important;
}

/* Tablet / iPad & Mobile responsiveness */
@media (max-width: 960px) {
  .workspace {
    grid-template-columns: minmax(0, 1fr);
  }

  /* Show the live quilt preview at the top on tablet portrait & iPhone */
  .preview-panel {
    order: -1;
  }

  .palette-grid {
    grid-template-columns: repeat(auto-fill, minmax(155px, 1fr));
  }

  .app-shell {
    padding: 1rem;
  }

  .topbar {
    padding: 0.85rem 1rem;
    flex-wrap: wrap;
  }

  .canvas-frame {
    min-height: 300px;
    padding: 1rem;
  }
}

/* iPhone & narrow mobile screens */
@media (max-width: 600px) {
  .app-shell {
    padding: 0.75rem;
  }

  .topbar {
    flex-direction: column;
    align-items: stretch;
    gap: 0.65rem;
    padding: 0.75rem 0.85rem;
  }

  .topbar-actions {
    flex-direction: column;
    align-items: stretch;
    gap: 0.45rem;
  }

  .project-chip {
    max-width: 100%;
    justify-content: center;
  }

  .action-group {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.4rem;
  }

  .action-group .btn {
    padding: 0.45rem 0.4rem;
    font-size: 0.78rem;
  }

  .drop-stage {
    min-height: 54vh;
  }

  .drop-zone {
    padding: 2rem 1.15rem;
  }

  .drop-zone h2 {
    font-size: 1.18rem;
  }

  .preview-toolbar {
    padding: 0.7rem 0.85rem;
    flex-wrap: wrap;
  }

  .canvas-frame {
    min-height: 240px;
    padding: 0.75rem;
  }

  #quilt-canvas {
    max-height: 52vh;
  }

  .export-bar {
    flex-direction: column;
    align-items: stretch;
    padding: 0.85rem;
    gap: 0.75rem;
  }

  .export-actions {
    width: 100%;
    display: flex;
    gap: 0.5rem;
  }

  .export-actions #export-pdf-btn {
    flex: 1;
  }

  .control-card {
    padding: 1rem;
  }

  /* Prevent iOS Safari auto-zoom on input focus */
  .input-with-unit input[type="number"],
  .pattern-title-input,
  .project-name-input,
  .quilt-preset-select {
    font-size: 16px;
  }

  .project-name-input {
    width: 100%;
    flex: 1;
  }

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