:root {
  --tab-row-h: 36px;
  --radius: 8px;
  --radius-sm: 5px;
  --sidebar-w: 240px;
  --header-h: 48px;
}

/*
 * Interface themes (js/theme.js sets data-theme on <html>; "System" resolves to light or dark).
 * Only the app's chrome is themed: fabrics, quilt seams in exports, and the printed pattern keep
 * their own colors.
 *   --bg            canvas area behind the quilt
 *   --surface       panels, header, toolbar, menus
 *   --surface-alt   hover rows, tab strip, inputs
 */
:root, [data-theme="light"] {
  color-scheme: light;
  --bg: #E9E9EB;
  --surface: #FFFFFF;
  --surface-alt: #F4F4F5;
  --primary: #2563EB;
  --primary-hover: #1D4ED8;
  --primary-light: #E3ECFD;
  --on-primary: #FFFFFF;
  --accent: #2563EB;
  --border: #CFCFD4;
  --border-light: #E2E2E6;
  --text: #18181B;
  --text-secondary: #52525B;
  --text-muted: #8A8A93;
  --empty-cell: #E4E4E7;
  --danger: #C2362F;
  --danger-bg: #FDECEB;
  --danger-border: #EDB8B4;
  --tooltip-bg: #18181B;
  --tooltip-text: #FFFFFF;
  --support-bg: linear-gradient(135deg, #FFF8D6, var(--surface-alt));
  --shadow: 0 1px 3px rgba(0,0,0,0.08);
  --shadow-lg: 0 8px 30px rgba(0,0,0,0.14);
}

/* Photoshop-style charcoal. */
[data-theme="dark"] {
  color-scheme: dark;
  --bg: #1B1B1D;
  --surface: #2A2A2D;
  --surface-alt: #333337;
  --primary: #5B8DEF;
  --primary-hover: #7BA3F3;
  --primary-light: #2D3B57;
  --on-primary: #FFFFFF;
  --accent: #5B8DEF;
  --border: #4A4A50;
  --border-light: #3A3A3F;
  --text: #ECECEE;
  --text-secondary: #B4B4BB;
  --text-muted: #85858D;
  --empty-cell: #3A3A3F;
  --danger: #F2847C;
  --danger-bg: #43282A;
  --danger-border: #7A3D3A;
  --tooltip-bg: #ECECEE;
  --tooltip-text: #18181B;
  --support-bg: linear-gradient(135deg, #3A3524, var(--surface-alt));
  --shadow: 0 1px 3px rgba(0,0,0,0.4);
  --shadow-lg: 0 8px 30px rgba(0,0,0,0.5);
}

/* Photoshop's medium gray. */
[data-theme="gray"] {
  color-scheme: dark;
  --bg: #3C3C3F;
  --surface: #535357;
  --surface-alt: #5E5E62;
  --primary: #8AB4FF;
  --primary-hover: #A7C6FF;
  --primary-light: #4A5670;
  --on-primary: #17223A;
  --accent: #8AB4FF;
  --border: #6E6E73;
  --border-light: #626267;
  --text: #F4F4F5;
  --text-secondary: #D6D6DA;
  --text-muted: #ACACB2;
  --empty-cell: #66666B;
  --danger: #FFA49D;
  --danger-bg: #5E4446;
  --danger-border: #8F5753;
  --tooltip-bg: #F4F4F5;
  --tooltip-text: #18181B;
  --support-bg: linear-gradient(135deg, #615B45, var(--surface-alt));
  --shadow: 0 1px 3px rgba(0,0,0,0.3);
  --shadow-lg: 0 8px 30px rgba(0,0,0,0.4);
}

/* Deep navy. */
[data-theme="blue"] {
  color-scheme: dark;
  --bg: #0F1626;
  --surface: #182236;
  --surface-alt: #1F2B42;
  --primary: #4F9CFF;
  --primary-hover: #74B1FF;
  --primary-light: #20385E;
  --on-primary: #FFFFFF;
  --accent: #4F9CFF;
  --border: #34466A;
  --border-light: #27354F;
  --text: #E7EEFA;
  --text-secondary: #A9B8D2;
  --text-muted: #7486A6;
  --empty-cell: #27354F;
  --danger: #FF8A80;
  --danger-bg: #3A2433;
  --danger-border: #74404A;
  --tooltip-bg: #E7EEFA;
  --tooltip-text: #0F1626;
  --support-bg: linear-gradient(135deg, #2E3320, var(--surface-alt));
  --shadow: 0 1px 3px rgba(0,0,0,0.45);
  --shadow-lg: 0 8px 30px rgba(0,0,0,0.55);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.45;
  height: 100dvh;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

/* iPad app (js/platform.js): behave like an app, not a page — no text selection or long-press
   callouts outside fields, and no double-tap zoom. */
html.native body { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; touch-action: manipulation; }
html.native :is(input, textarea, [contenteditable]) { -webkit-user-select: text; user-select: text; }

/* ===== App shell ===== */

.app {
  display: flex;
  flex-direction: column;
  height: 100dvh;
}

.app-header {
  height: var(--header-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px;
  background: var(--surface);
  border-bottom: 1px solid var(--border-light);
  flex-shrink: 0;
  z-index: 20;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 2px;
}

/* Tool options bar: replaces the canvas tabs while a tool with options is active.
   Both rows share one height so switching between them never moves the canvas. */

.options-bar {
  display: flex;
  align-items: center;
  gap: 18px;
  height: var(--tab-row-h);
  padding: 0 14px;
  white-space: nowrap;
  overflow-x: auto;
  background: var(--surface-alt);
  border-bottom: 1px solid var(--border-light);
  font-size: 0.75rem;
  color: var(--text-secondary);
  flex-shrink: 0;
}

.options-bar[hidden],
.canvas-tabs:has(~ .options-bar:not([hidden])) { display: none; }

.ob-title {
  font-weight: 700;
  color: var(--text);
}

.ob-field {
  display: flex;
  align-items: center;
  gap: 5px;
}

.ob-field select {
  padding: 3px 4px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font-size: 0.8125rem;
  font-weight: 600;
}

.ob-field input {
  width: 56px;
  padding: 3px 6px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font-size: 0.8125rem;
  font-weight: 600;
  text-align: right;
}

.ob-x { color: var(--text-muted); }

.ob-info { color: var(--text-muted); }

.ob-warn { color: var(--danger); }

.ob-sample {
  position: relative;
  display: inline-block;
  width: 20px;
  height: 20px;
  margin: 0 2px;
  border: 1px solid var(--border);
  border-radius: 3px;
  overflow: hidden;
  vertical-align: middle;
}

.icon-btn {
  width: 34px;
  height: 34px;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font-size: 1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.12s;
}

.icon-btn:not(:disabled):hover { background: var(--primary-light); }
.icon-btn:disabled { opacity: 0.3; cursor: default; }

.sidebar-toggle-btn { display: none; }

.about-btn { color: var(--text-secondary); text-decoration: none; }
.about-btn:hover { color: var(--primary); }

.noscript { max-width: 640px; margin: 40px auto; padding: 0 16px; }
.noscript h1 { font-size: 1.5rem; margin-bottom: 12px; }

/* ===== Body layout ===== */

.app-body {
  display: flex;
  flex: 1;
  min-height: 0;
}

/* ===== Canvas area ===== */

.canvas-column {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
}

/* Canvas tabs (quilt + open blocks), like document tabs in an image editor */

.canvas-tabs {
  height: var(--tab-row-h);
  display: flex;
  align-items: flex-end;
  gap: 2px;
  padding: 6px 10px 0;
  background: var(--surface-alt);
  border-bottom: 1px solid var(--border-light);
  overflow-x: auto;
  flex-shrink: 0;
}

.canvas-tab {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 5px 10px;
  border: 1px solid transparent;
  border-bottom: none;
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  color: var(--text-secondary);
  font-size: 0.75rem;
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
}

.canvas-tab:hover { background: var(--surface); }

.canvas-tab.active {
  background: var(--bg);
  border-color: var(--border-light);
  color: var(--text);
  font-weight: 600;
  margin-bottom: -1px;
  padding-bottom: 6px;
}

.tab-close {
  width: 16px;
  height: 16px;
  border: none;
  border-radius: 3px;
  background: none;
  color: var(--text-muted);
  font-size: 0.875rem;
  line-height: 1;
  cursor: pointer;
}

.tab-close:hover { background: var(--border-light); color: var(--text); }

.canvas-tab-new {
  margin: 0 0 3px 4px;
  width: 22px;
  height: 22px;
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
}

.canvas-tab-new:hover { border-color: var(--primary); color: var(--primary); }

/* The canvas area is a viewport; the canvas inside is panned and zoomed with a transform. */
.canvas-area {
  flex: 1;
  min-height: 0;
  position: relative;
  overflow: hidden;
  background: var(--bg);
  min-width: 0;
  touch-action: none;
}

.canvas-inner {
  position: absolute;
  top: 0;
  left: 0;
  width: max-content;
  padding: 28px;
  transform-origin: 0 0;
}

/* Space held (or panning): the hand cursor wins over every tool's cursor. */
.canvas-area.pan-ready,
.canvas-area.pan-ready * { cursor: grab !important; }
.canvas-area.panning,
.canvas-area.panning * { cursor: grabbing !important; }

.zoom-controls {
  position: absolute;
  right: 12px;
  bottom: 12px;
  display: flex;
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
  z-index: 6;
}

.zoom-btn {
  min-width: 28px;
  height: 28px;
  padding: 0 6px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
}

.zoom-btn:hover { background: var(--primary-light); color: var(--primary); }

.zoom-level {
  min-width: 52px;
  font-size: 0.75rem;
  font-variant-numeric: tabular-nums;
  border-left: 1px solid var(--border-light);
  border-right: 1px solid var(--border-light);
}

/* ===== Grid ===== */

.grid-wrapper {
  position: relative;
  padding: var(--binding-px, 0px);
}

/* Binding: fills the wrapper's padding around the grid (see binding.js). */
.binding-frame {
  position: absolute;
  inset: 0;
  border-radius: 2px;
}

.binding-frame[hidden] { display: none; }
.binding-frame.empty { background: var(--empty-cell); }
.binding-frame.tool-fill { cursor: crosshair; }

.sb-section[hidden] { display: none; }

.quilt-grid {
  position: relative;
  display: grid;
  grid-template-columns: repeat(var(--cols, 10), 1fr);
  gap: 1px;
  background: var(--border);
  padding: 1px;
  border-radius: 2px;
  user-select: none;
  -webkit-user-select: none;
}

.quilt-grid { touch-action: none; }

.quilt-grid.no-lines {
  gap: 0;
  padding: 0;
}
.quilt-grid.tool-fill .quilt-cell { cursor: crosshair; }
.quilt-grid.tool-select .quilt-cell { cursor: cell; }

.quilt-cell {
  position: relative;
  aspect-ratio: var(--cell-aspect, 1);
  background: var(--surface);
  overflow: hidden;
}

/* One square's share of a block placed across several squares: the whole block, shifted. */
.block-part {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.block-part > .sub-grid {
  inset: auto;
  left: var(--bx);
  top: var(--by);
  width: var(--bw);
  height: var(--bh);
}

/* A placed block: the block's pieces fill the square, with faint seams between them. */
.sub-grid {
  position: absolute;
  inset: 0;
  display: grid;
  gap: 0.5px;
  background: rgba(0, 0, 0, 0.12);
  pointer-events: none;
}

.quilt-grid.no-lines .sub-grid { gap: 0; }

.sub-cell {
  position: relative;
  background: var(--surface);
}

.sub-cell.empty { background: var(--empty-cell); }

.quilt-cell.empty,
.half.empty { background: var(--empty-cell); }

/* Second half of a half-square triangle, layered over the square's first half. */
.half {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.half-tl { clip-path: polygon(0 0, 100% 0, 0 100%); }
.half-br { clip-path: polygon(100% 0, 100% 100%, 0 100%); }
.half-tr { clip-path: polygon(0 0, 100% 0, 100% 100%); }
.half-bl { clip-path: polygon(0 0, 100% 100%, 0 100%); }

/* A turned image square: the print is a layer rotated around the square's center. For quarter
   turns the layer swaps width and height (container units) so it still covers a non-square piece. */
.turned { container-type: size; }

.print {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 100cqw;
  height: 100cqh;
  pointer-events: none;
}

.print.turn-1, .print.turn-3 { width: 100cqh; height: 100cqw; }
.print.turn-1 { transform: translate(-50%, -50%) rotate(90deg); }
.print.turn-2 { transform: translate(-50%, -50%) rotate(180deg); }
.print.turn-3 { transform: translate(-50%, -50%) rotate(270deg); }

/* Overlays sit above any triangle half. */
.quilt-cell.selected::after,
.quilt-cell.preview::after {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.quilt-cell.selected::after {
  box-shadow: inset 0 0 0 2px var(--text), inset 0 0 0 4px #fff;
}

.quilt-grid.tool-smart .quilt-cell { cursor: pointer; }
.quilt-grid.tool-triangle .quilt-cell { cursor: crosshair; }
.quilt-grid.tool-stamp .quilt-cell { cursor: copy; }
.quilt-grid.tool-eyedropper .quilt-cell {
  cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke-linecap='round' stroke-linejoin='round'%3E%3Cg stroke='white' stroke-width='4'%3E%3Cpath d='m2 22 1-1h3l9-9'/%3E%3Cpath d='M3 21v-3l9-9'/%3E%3Cpath d='m15 6 3.4-3.4a2.1 2.1 0 1 1 3 3L18 9l.4.4a2.1 2.1 0 1 1-3 3l-3.8-3.8a2.1 2.1 0 1 1 3-3l.4.4Z'/%3E%3C/g%3E%3Cg stroke='%232C3830' stroke-width='2'%3E%3Cpath d='m2 22 1-1h3l9-9'/%3E%3Cpath d='M3 21v-3l9-9'/%3E%3Cpath d='m15 6 3.4-3.4a2.1 2.1 0 1 1 3 3L18 9l.4.4a2.1 2.1 0 1 1-3 3l-3.8-3.8a2.1 2.1 0 1 1 3-3l.4.4Z'/%3E%3C/g%3E%3C/svg%3E") 2 22, crosshair;
}

.quilt-grid.tool-rotate .quilt-cell {
  cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke-linecap='round' stroke-linejoin='round'%3E%3Cg stroke='white' stroke-width='4'%3E%3Cpath d='M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8'/%3E%3Cpath d='M21 3v5h-5'/%3E%3C/g%3E%3Cg stroke='%232C3830' stroke-width='2'%3E%3Cpath d='M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8'/%3E%3Cpath d='M21 3v5h-5'/%3E%3C/g%3E%3C/svg%3E") 12 12, pointer;
}

.quilt-cell.turn-target::after {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  box-shadow: inset 0 0 0 2px var(--primary), inset 0 0 0 3px rgba(255, 255, 255, 0.8);
}

.quilt-cell.preview::after {
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.8);
}

.quilt-cell.selected.preview::after {
  box-shadow: inset 0 0 0 2px var(--text), inset 0 0 0 4px #fff, inset 0 0 0 5px rgba(255,255,255,0.8);
}

.quilt-cell.smart-target {
  outline: 2px solid var(--text);
  outline-offset: -2px;
}

/* ===== Apple Pencil palette (js/pencil.js): double-tap or squeeze, under the Pencil ===== */

.pencil-palette {
  position: fixed;
  z-index: 70;
  display: grid;
  gap: 8px;
  padding: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
}
.pencil-palette[hidden] { display: none; }
.pp-tools { display: flex; gap: 2px; padding-bottom: 8px; border-bottom: 1px solid var(--border-light); }
.pp-fabrics { display: grid; grid-template-columns: repeat(6, 40px); gap: 6px; }
.pp-fabrics .swatch { width: 40px; height: 40px; }

/* ===== Smart select menu ===== */

.smart-popover {
  position: fixed;
  z-index: 70;
  min-width: 210px;
  padding: 4px 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
}

.smart-popover[hidden] { display: none; }

.smart-item {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  padding: 5px 10px;
  border: none;
  background: none;
  color: var(--text);
  font-size: 0.8125rem;
  text-align: left;
  cursor: pointer;
}

.smart-item:hover,
.smart-item:focus-visible { background: var(--primary-light); }

.smart-icon { flex-shrink: 0; color: var(--primary); }

.smart-label { flex: 1; }

.smart-swatch {
  display: inline-block;
  width: 10px;
  height: 10px;
  margin-right: 5px;
  border: 1px solid var(--border);
  border-radius: 2px;
  vertical-align: -1px;
}

.smart-count {
  color: var(--text-muted);
  font-size: 0.6875rem;
  font-variant-numeric: tabular-nums;
}

.smart-divider {
  height: 1px;
  margin: 4px 0;
  background: var(--border-light);
}

.smart-header {
  display: flex;
  align-items: center;
  padding: 4px 10px 6px;
  margin-bottom: 4px;
  border-bottom: 1px solid var(--border-light);
  color: var(--text-secondary);
  font-size: 0.75rem;
}

.smart-header .smart-swatch { margin-left: 5px; }

/* ===== Left toolbar ===== */

.toolbar {
  width: 48px;
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border-light);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 10px 0;
}

.tool-btn {
  width: 36px;
  height: 36px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.12s, color 0.12s;
}

.tool-btn { position: relative; }

.tool-btn:hover { background: var(--surface-alt); color: var(--text); }
.tool-btn:disabled { opacity: 0.3; cursor: default; }
.tool-btn:disabled:hover { background: transparent; color: var(--text-secondary); }
.tooltip-keys { display: inline-flex; }

/* Undo/redo sit at the bottom of the toolbar, below the tools. */
.toolbar-divider.toolbar-history { margin-top: auto; }

/* Tool tooltips */

.tooltip {
  position: absolute;
  left: calc(100% + 10px);
  top: 50%;
  transform: translateY(-50%);
  width: max-content;
  max-width: 220px;
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  background: var(--tooltip-bg);
  color: var(--tooltip-text);
  font-size: 0.75rem;
  line-height: 1.35;
  text-align: left;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.12s, visibility 0.12s;
  z-index: 50;
}

.tooltip::before {
  content: '';
  position: absolute;
  right: 100%;
  top: 50%;
  transform: translateY(-50%);
  border: 5px solid transparent;
  border-right-color: var(--tooltip-bg);
}

.tool-btn:hover .tooltip,
.tool-btn:focus-visible .tooltip {
  opacity: 1;
  visibility: visible;
  transition-delay: 0.35s;
}

.tooltip-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-weight: 600;
}

.tooltip-desc {
  display: block;
  margin-top: 3px;
  color: var(--tooltip-text);
  opacity: 0.75;
}

.tooltip kbd {
  background: color-mix(in srgb, var(--tooltip-text) 15%, transparent);
  border-color: color-mix(in srgb, var(--tooltip-text) 25%, transparent);
  color: var(--tooltip-text);
}

@media (hover: none) {
  .tooltip { display: none; }
}

/* Keycaps */

kbd {
  display: inline-block;
  min-width: 18px;
  padding: 1px 5px;
  border: 1px solid var(--border);
  border-radius: 3px;
  background: var(--surface-alt);
  color: var(--text);
  font-family: inherit;
  font-size: 0.6875rem;
  font-weight: 600;
  line-height: 1.4;
  text-align: center;
}

/* ===== Menu bar ===== */

.header-left {
  display: flex;
  align-items: center;
  gap: 14px;
}

.menubar { display: flex; gap: 2px; }

.menu { position: relative; }

.menu-trigger {
  padding: 4px 9px;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text);
  font-size: 0.8125rem;
  cursor: pointer;
}

.menu-trigger:hover,
.menu-trigger[aria-expanded="true"] { background: var(--surface-alt); }

.menu-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  min-width: 200px;
  padding: 4px 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  z-index: 60;
}

.menu-dropdown[hidden] { display: none; }

.submenu { position: relative; }

/* Overlaps the parent menu slightly so the pointer never crosses a gap on the way in. */
.submenu-dropdown {
  top: -5px;
  left: calc(100% - 4px);
  min-width: 160px;
}

.submenu-arrow {
  margin-left: 16px;
  color: var(--text-muted);
  font-size: 1rem;
  line-height: 1;
}

.submenu-trigger[aria-expanded="true"] { background: var(--primary-light); }

.menu-dropdown .menu-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding-left: 8px;
  white-space: nowrap;
}

.menu-check {
  width: 14px;
  flex-shrink: 0;
  color: var(--primary);
  font-weight: 700;
  visibility: hidden;
}

.menu-item[aria-checked="true"] .menu-check { visibility: visible; }

.menu-label { flex: 1; }

.menu-shortcut {
  display: flex;
  gap: 2px;
  margin-left: 16px;
  color: var(--text-muted);
}

.menu-shortcut .shortcut-plus { margin: 0 1px; }

.menu-divider {
  height: 1px;
  margin: 4px 0;
  background: var(--border-light);
}

.menu-heading {
  padding: 4px 12px 4px 28px;
  font-size: 0.6875rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}

.menu-dropdown .menu-item:disabled {
  color: var(--text-muted);
  cursor: default;
  background: none;
}

.menu-dropdown .menu-item-danger { color: var(--danger); }
.menu-dropdown .menu-item-danger:hover { background: var(--danger-bg); }

/* ===== Shortcuts dialog ===== */

.shortcut-device {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 10px;
}

.shortcut-group { margin-bottom: 16px; }
.shortcut-group:last-child { margin-bottom: 0; }

.shortcut-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 6px 0;
  border-bottom: 1px solid var(--border-light);
  font-size: 0.8125rem;
}

.shortcut-keys {
  display: flex;
  align-items: center;
  gap: 2px;
  flex-shrink: 0;
  white-space: nowrap;
}

.shortcut-plus,
.shortcut-or {
  color: var(--text-muted);
  font-size: 0.6875rem;
  margin: 0 3px;
}

.shortcut-how {
  color: var(--text-secondary);
  text-align: right;
}

.tool-btn[aria-pressed="true"] {
  background: var(--primary-light);
  border-color: var(--primary);
  color: var(--primary);
}

/* Edge controls — absolutely positioned, hover-reveal */

.grid-controls-top,
.grid-controls-bottom,
.grid-controls-left,
.grid-controls-right {
  position: absolute;
  display: flex;
  gap: 4px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
  z-index: 5;
}

.grid-wrapper:hover .grid-controls-top,
.grid-wrapper:hover .grid-controls-bottom,
.grid-wrapper:hover .grid-controls-left,
.grid-wrapper:hover .grid-controls-right {
  opacity: 1;
  pointer-events: auto;
}

.grid-controls-top {
  bottom: 100%;
  left: 0;
  right: 0;
  justify-content: center;
  padding-bottom: 6px;
}

.grid-controls-bottom {
  top: 100%;
  left: 0;
  right: 0;
  justify-content: center;
  padding-top: 6px;
}

.grid-controls-left {
  right: 100%;
  top: 0;
  bottom: 0;
  flex-direction: column;
  justify-content: center;
  padding-right: 6px;
}

.grid-controls-right {
  left: 100%;
  top: 0;
  bottom: 0;
  flex-direction: column;
  justify-content: center;
  padding-left: 6px;
}

.grid-btn {
  transform: scale(var(--inv-zoom, 1));
  width: 22px;
  height: 22px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--surface);
  color: var(--text-secondary);
  font-size: 0.8125rem;
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: background 0.12s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.grid-btn:not(:disabled):hover {
  background: var(--primary-light);
  color: var(--primary);
}

.grid-btn:disabled { opacity: 0.25; cursor: default; }

/* Touch devices: show controls at reduced opacity */
@media (hover: none) {
  .grid-controls-top,
  .grid-controls-bottom,
  .grid-controls-left,
  .grid-controls-right {
    opacity: 0.45;
    pointer-events: auto;
  }
}

/* Centered under the grid without widening the canvas; stays readable at any zoom. */
.grid-dims {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  text-align: center;
  margin-top: 6px;
  white-space: nowrap;
  font-size: calc(0.6875rem * var(--inv-zoom, 1));
  color: var(--text-muted);
}

.canvas-message {
  position: absolute;
  left: 50%;
  bottom: 12px;
  transform: translateX(-50%);
  width: max-content;
  max-width: min(420px, calc(100% - 160px));
  z-index: 6;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  background: var(--surface);
  border: 1px solid var(--border-light);
  color: var(--text-secondary);
  font-size: 0.75rem;
  text-align: center;
}

.canvas-message[hidden] { display: none; }

.app-logo { flex-shrink: 0; margin: 2px 0; }

.toolbar-divider {
  width: 24px;
  height: 1px;
  margin: 4px 0;
  background: var(--border-light);
}

/* ===== Sidebar ===== */

.sidebar {
  width: var(--sidebar-w);
  background: var(--surface);
  border-left: 1px solid var(--border-light);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

/* Panels, Photoshop-style: a header bar that collapses its body (see panels.js). */
.sidebar .sb-section { border-bottom: 1px solid var(--border-light); }

.sidebar .sb-title { margin: 0; }

.sb-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  padding: 8px 12px;
  border: none;
  background: var(--surface-alt);
  color: var(--text-secondary);
  font: inherit;
  text-transform: inherit;
  letter-spacing: inherit;
  text-align: left;
  cursor: pointer;
  user-select: none;
}

.sb-toggle:hover { color: var(--text); }

/* Disclosure chevron (rounded strokes, drawn in currentColor): down when open, right when collapsed. */
.sb-toggle::before {
  content: '';
  width: 10px;
  height: 10px;
  flex-shrink: 0;
  background: currentColor;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 10'%3E%3Cpath d='M2.5 3.75 5 6.25l2.5-2.5' fill='none' stroke='black' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 10'%3E%3Cpath d='M2.5 3.75 5 6.25l2.5-2.5' fill='none' stroke='black' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / contain no-repeat;
  transition: transform 0.15s ease;
}

.sb-section.collapsed .sb-toggle::before { transform: rotate(-90deg); }

.sb-body { padding: 10px 12px 14px; }

.sb-section.collapsed .sb-body { display: none; }

/* Closed from the Window menu (separate from [hidden], which binding.js uses on block tabs). */
.sidebar .sb-section.panel-hidden { display: none; }

/* Dragging a panel by its header to reorder; a line marks where it will land. */
.sb-toggle:active { cursor: grabbing; }
.sb-section.panel-dragging { opacity: 0.45; }
.sidebar .sb-section,
.sidebar .sb-note { position: relative; }

.sb-section.drop-before::before,
.sidebar.drop-at-end .sb-note::before {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 3px;
  background: var(--primary);
  z-index: 1;
}

.sb-title {
  font-size: 0.6875rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 8px;
}

/* Fabric swatches */

.fabric-swatches {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.swatch-wrap {
  position: relative;
  flex-shrink: 0;
}

.swatch {
  width: 32px;
  height: 32px;
  border-radius: 6px;
  border: 2px solid var(--border-light);
  cursor: pointer;
  transition: border-color 0.12s, box-shadow 0.12s;
  position: relative;
  display: block;
}

.swatch:hover { border-color: var(--text-muted); }

.swatch.selected {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px var(--primary);
}

/* Blocks panel */

.block-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: flex-start;
}

.block-thumb {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  width: 58px;
  padding: 4px 3px;
  border: 2px solid transparent;
  border-radius: var(--radius-sm);
  background: none;
  cursor: pointer;
}

.block-thumb:hover { background: var(--surface-alt); }

.block-thumb.armed {
  border-color: var(--primary);
  background: var(--primary-light);
}

.block-preview {
  position: relative;
  display: block;
  width: 44px;
  height: 44px;
  outline: 1px solid var(--border);
  background: var(--empty-cell);
}

.block-name {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.6875rem;
  color: var(--text-secondary);
}

.block-new {
  width: 44px;
  height: 44px;
  margin: 6px 7px;
  border: 2px dashed var(--border);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-muted);
  font-size: 1.125rem;
  cursor: pointer;
}

.block-new:hover { border-color: var(--primary); color: var(--primary); }

/* Delete badge */

.swatch-delete {
  position: absolute;
  top: -5px;
  right: -5px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: none;
  background: var(--danger);
  color: #fff;
  font-size: 10px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s;
  z-index: 2;
  padding: 0;
}

.swatch-wrap:hover .swatch-delete {
  opacity: 1;
  pointer-events: auto;
}

/* Context menu */

.context-menu {
  position: fixed;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  z-index: 200;
  padding: 4px 0;
  min-width: 120px;
}

.context-menu[hidden],
.context-item[hidden] { display: none; }

.palette-message {
  margin-top: 8px;
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  background: var(--surface-alt);
  color: var(--text-secondary);
  font-size: 0.75rem;
  line-height: 1.4;
}

.fabric-swatches.drop-target {
  outline: 2px dashed var(--primary);
  outline-offset: 4px;
  border-radius: var(--radius-sm);
}

.context-item {
  display: block;
  width: 100%;
  padding: 6px 14px;
  border: none;
  background: none;
  color: var(--text);
  font-size: 0.8125rem;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
}

.context-item:hover {
  background: var(--primary-light);
}

#add-fabric-btn {
  width: 32px;
  height: 32px;
  border-radius: 6px;
  border: 2px dashed var(--border);
  background: transparent;
  color: var(--text-muted);
  font-size: 1.125rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: border-color 0.12s, color 0.12s;
}

#add-fabric-btn:hover { border-color: var(--primary); color: var(--primary); }

/* Pattern panel */

.pattern-empty,
.pattern-note {
  font-size: 0.75rem;
  color: var(--text-muted);
  line-height: 1.45;
}

.pattern-note { margin-top: 6px; }

.pattern-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.pattern-icon {
  flex-shrink: 0;
  border-radius: 3px;
  outline: 1px solid var(--border-light);
}

.pattern-name {
  font-size: 0.8125rem;
  font-weight: 700;
}

.pattern-fields {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 10px;
}

.pattern-field {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.pattern-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-secondary);
  white-space: nowrap;
}

.role-swatch {
  width: 12px;
  height: 12px;
  border: 1px solid var(--border);
  border-radius: 3px;
}

.role-select {
  width: 110px;
  padding: 4px 6px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font-size: 0.75rem;
}

.stepper,
.segmented {
  display: flex;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.stepper button,
.segmented button {
  min-width: 26px;
  padding: 3px 7px;
  border: none;
  background: var(--surface);
  color: var(--text-secondary);
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
}

.segmented button + button { border-left: 1px solid var(--border); }

.stepper button:not(:disabled):hover,
.segmented button:hover { background: var(--surface-alt); }

.stepper button:disabled { opacity: 0.3; cursor: default; }

.segmented button[aria-pressed="true"] {
  background: var(--primary-light);
  color: var(--primary);
}

.stepper-value {
  min-width: 24px;
  padding: 3px 4px;
  border-left: 1px solid var(--border);
  border-right: 1px solid var(--border);
  font-size: 0.75rem;
  font-weight: 600;
  text-align: center;
  font-variant-numeric: tabular-nums;
}


/* Buttons */

.btn {
  padding: 7px 14px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 0.8125rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.12s;
  white-space: nowrap;
}

.btn-sm { padding: 5px 10px; font-size: 0.75rem; }

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


.btn-outline {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-outline:hover { background: var(--primary-light); }

.btn-danger {
  background: var(--surface);
  color: var(--danger);
  border: 1px solid var(--danger-border);
}
.btn-danger:hover { background: var(--danger-bg); }

.btn-block { width: 100%; }

/* Buy Me a Coffee card: pinned to the bottom of the sidebar, below every panel. */
.sb-support {
  margin: auto 12px 12px;
  padding: 10px 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  background: var(--support-bg);
  color: var(--text);
  text-decoration: none;
  transition: border-color 0.15s, box-shadow 0.15s, transform 0.15s;
}
.sb-support:hover {
  border-color: #E8C800;
  box-shadow: 0 4px 14px rgba(232, 200, 0, 0.22);
  transform: translateY(-1px);
}
.sb-support:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

.support-cup { flex-shrink: 0; color: var(--text-muted); }
.support-cup .steam { opacity: 0.5; transition: opacity 0.2s; }
.sb-support:hover .support-cup .steam { opacity: 1; animation: steam 1.6s ease-in-out infinite; }
@keyframes steam {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-1.5px); }
}
@media (prefers-reduced-motion: reduce) {
  .sb-support, .sb-support:hover { transform: none; }
  .sb-support:hover .support-cup .steam { animation: none; }
}

.support-text { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.support-title { font-size: 0.6875rem; color: var(--text-secondary); }
.support-cta { font-size: 0.875rem; font-weight: 700; }
.support-cta span { display: inline-block; transition: transform 0.15s; }
.sb-support:hover .support-cta span { transform: translateX(3px); }

/* ===== Yardage modal ===== */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 16px;
}

.modal-backdrop[hidden] {
  display: none;
}

.modal {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 420px;
  max-height: 85dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-light);
}

.modal-header h3 {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
}

.modal-close {
  width: 30px;
  height: 30px;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-secondary);
  font-size: 1.25rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-close:hover { background: var(--surface-alt); }

.modal-body {
  padding: 16px;
  overflow-y: auto;
}

.modal-wide { max-width: 680px; }

/* Dialogs move by dragging the title bar; double-click it to re-center. */
.modal-header[data-draggable] {
  cursor: move;
  user-select: none;
  touch-action: none;
}

.modal.dragging { box-shadow: 0 16px 40px rgba(0,0,0,0.28); }

.modal-message { max-width: 380px; }

.dialog-message {
  font-size: 0.875rem;
  line-height: 1.5;
  color: var(--text);
}

.dialog-message + .dialog-input { margin-top: 10px; }

.dialog-input {
  width: 100%;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font: inherit;
  font-size: 0.875rem;
  color: var(--text);
  background: var(--surface);
}

.dialog-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px var(--primary-light);
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid var(--border-light);
}

/* Image scale dialog */

.scale-body {
  display: flex;
  flex-wrap: wrap;
  gap: 18px;
  align-items: flex-start;
}

.scale-figure { flex-shrink: 0; }

#scale-preview {
  display: block;
  border-radius: var(--radius-sm);
}

.scale-caption {
  max-width: 346px;
  margin-top: 6px;
  font-size: 0.6875rem;
  line-height: 1.4;
  color: var(--text-muted);
}

.scale-controls {
  flex: 1;
  min-width: 220px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.scale-label {
  font-size: 0.8125rem;
  font-weight: 600;
}

.scale-input-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.scale-input-row input {
  width: 80px;
  padding: 5px 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  text-align: right;
}

.scale-input-row .unit {
  font-size: 0.8125rem;
  color: var(--text-secondary);
}

#scale-slider {
  width: 100%;
  accent-color: var(--primary);
}

.scale-slider-ends {
  display: flex;
  justify-content: space-between;
  margin-top: -6px;
  font-size: 0.6875rem;
  color: var(--text-muted);
}

.scale-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.chip {
  padding: 3px 9px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text-secondary);
  font-size: 0.75rem;
  cursor: pointer;
}


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

.scale-info {
  font-size: 0.8125rem;
  line-height: 1.45;
  color: var(--text);
}

/* Yardage-specific styles */

.bolt-width-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}

.bolt-width-row label {
  font-size: 0.8125rem;
  color: var(--text-secondary);
}

.bolt-width-row input {
  width: 64px;
  padding: 5px 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font-size: 0.8125rem;
  text-align: center;
}

.bolt-width-row .unit {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.bolt-validation {
  color: var(--danger);
  font-size: 0.8125rem;
  margin-bottom: 8px;
}

.yardage-card {
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  margin-bottom: 8px;
}

.yardage-card:last-child { margin-bottom: 0; }

.yardage-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}

.yardage-swatch {
  width: 18px;
  height: 18px;
  border-radius: 4px;
  border: 1px solid var(--border);
  flex-shrink: 0;
}

.yardage-header strong { font-size: 0.8125rem; }

.yardage-details {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1px 12px;
}

.yardage-row { display: contents; }

.yardage-row span:first-child {
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.yardage-row span:last-child {
  font-size: 0.75rem;
  text-align: right;
  font-weight: 500;
}

.yardage-row.purchase span {
  font-size: 0.875rem;
  color: var(--primary);
  font-weight: 700;
  padding-top: 3px;
  border-top: 1px solid var(--border-light);
}

.empty-state {
  font-size: 0.8125rem;
  color: var(--text-muted);
  text-align: center;
  padding: 20px 0;
}

.assumptions {
  margin-top: 12px;
  font-size: 0.6875rem;
  color: var(--text-muted);
  line-height: 1.5;
}

/* ===== Mobile overlay for sidebar ===== */

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.3);
  z-index: 29;
}

/* ===== Responsive ===== */

@media (max-width: 768px) {
  .sidebar-toggle-btn { display: flex; }

  .sidebar {
    position: fixed;
    top: var(--header-h);
    right: 0;
    bottom: 0;
    z-index: 30;
    width: 260px;
    transform: translateX(100%);
    transition: transform 0.25s ease;
    box-shadow: var(--shadow-lg);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .sidebar.open ~ .sidebar-overlay,
  .sidebar-overlay.visible {
    display: block;
  }

  .toolbar { width: 42px; }
  .tool-btn { width: 32px; height: 32px; }

  .canvas-inner {
    padding: 20px;
  }

  .grid-btn {
    width: 20px;
    height: 20px;
    font-size: 0.75rem;
  }
}

@media (max-width: 400px) {
  .swatch { width: 28px; height: 28px; }
  #add-fabric-btn { width: 28px; height: 28px; }
}

/* ===== Printed pattern (File → Export Pattern) ===== */

.print-doc { display: none; }

@media print {
  @page { size: letter; margin: 0.6in; }

  html, body {
    height: auto;
    overflow: visible;
    background: #fff;
  }

  body > :not(.print-doc) { display: none !important; }

  .print-doc {
    display: block;
    color: #2B2B2B;
    font-size: 10pt;
    line-height: 1.45;
  }
}

.print-doc h2 {
  font-size: 15pt;
  margin-bottom: 10pt;
  color: #2B2B2B;
}

.print-doc h3 {
  font-size: 10pt;
  margin-bottom: 4pt;
}

.pd-break { break-before: page; }

.pd-header {
  border-bottom: 2px solid #596D62;
  padding-bottom: 8pt;
  margin-bottom: 12pt;
}

.pd-kicker {
  font-size: 8pt;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #596D62;
}

.pd-header h1 { font-size: 22pt; line-height: 1.2; }
.pd-date { font-size: 9pt; color: #6B6B6B; }

.pd-facts {
  display: flex;
  flex-wrap: wrap;
  gap: 6pt 22pt;
  margin-bottom: 16pt;
}

.pd-facts dt {
  font-size: 7.5pt;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #6B6B6B;
}

.pd-facts dd { font-size: 11pt; font-weight: 600; }

.pd-mockup { text-align: center; }

.pd-mockup-img {
  max-width: 100%;
  max-height: 7in;
  border: 1px solid #D4CFC8;
}

.pd-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 18pt;
}

.pd-table th {
  text-align: left;
  font-size: 7.5pt;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #6B6B6B;
  border-bottom: 1.5px solid #2B2B2B;
  padding: 4pt 6pt;
}

.pd-table td {
  vertical-align: top;
  border-bottom: 1px solid #E2DDD5;
  padding: 7pt 6pt;
}

.pd-table tr { break-inside: avoid; }

.pd-table tfoot td {
  border-bottom: none;
  border-top: 1.5px solid #2B2B2B;
  font-weight: 700;
}

.pd-num { text-align: right; white-space: nowrap; }
.pd-buy { font-weight: 700; font-size: 11pt; }
.pd-muted { color: #6B6B6B; }

.pd-fabric {
  display: flex;
  align-items: center;
  gap: 8pt;
  font-weight: 600;
  min-width: 1.6in;
}

.pd-swatch {
  width: 0.4in;
  height: 0.4in;
  border: 1px solid #D4CFC8;
  border-radius: 3pt;
  flex-shrink: 0;
}

.pd-section-title { margin-top: 4pt; break-after: avoid; }

.pd-group-title {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-top: 10pt;
  padding-bottom: 3pt;
  border-bottom: 1.5px solid #2B2B2B;
  font-size: 10.5pt;
  break-after: avoid;
}

.pd-group-title span {
  font-size: 8.5pt;
  font-weight: 600;
  color: #6B6B6B;
}

.pd-cutting { margin-bottom: 18pt; }

/* Cutting List: a printable checklist */
.pd-checklist { list-style: none; }

.pd-checklist li {
  display: flex;
  align-items: flex-start;
  gap: 8pt;
  padding: 6pt 0;
  border-bottom: 1px solid #E2DDD5;
  break-inside: avoid;
}

.pd-box {
  width: 10pt;
  height: 10pt;
  margin-top: 2pt;
  border: 1.2px solid #6B6B6B;
  border-radius: 2pt;
  flex-shrink: 0;
}

.pd-count {
  min-width: 0.45in;
  font-size: 12pt;
  font-weight: 700;
  text-align: right;
  line-height: 1.2;
}

.pd-item .pd-swatch {
  width: 11pt;
  height: 11pt;
  border-radius: 2pt;
  vertical-align: -2pt;
  margin-right: 4pt;
}


.pd-blocks-title { break-after: avoid; }

.pd-blocks {
  display: flex;
  flex-wrap: wrap;
  gap: 14pt;
  margin-bottom: 18pt;
}

.pd-block {
  width: 1.5in;
  break-inside: avoid;
}

.pd-block-img {
  width: 1.5in;
  height: 1.5in;
  border: 1px solid #D4CFC8;
}

.pd-block figcaption {
  display: flex;
  flex-direction: column;
  font-size: 8.5pt;
  margin-top: 4pt;
}

.pd-notes {
  break-inside: avoid;
  border-top: 1px solid #E2DDD5;
  padding-top: 8pt;
  font-size: 8.5pt;
  color: #4A4A4A;
}

.pd-notes p + p { margin-top: 4pt; }
