:root {
  color-scheme: light;
  --ink: #26342f;
  --muted: #5c6964;
  --line: #c6cdc3;
  --line-strong: #87948d;
  --surface: #fffdf4;
  --surface-soft: #f1f2e9;
  --canvas: #eaf0e8;
  --green: #29473d;
  --green-dark: #172e27;
  --green-soft: #dde9df;
  --amber: #efb64f;
  --amber-soft: #fff0bf;
  --amber-dark: #6a480b;
  --teal: #36766b;
  --red: #a85340;
  --red-soft: #fae7df;
  --wood: #ad6f42;
  --shadow: 5px 5px 0 rgba(34, 49, 43, 0.18);
  --shadow-small: 2px 2px 0 rgba(34, 49, 43, 0.17);
  --radius: 12px;
  --radius-small: 7px;
  font-family: ui-rounded, "Avenir Next", "Nunito Sans", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { min-width: 320px; min-height: 100%; margin: 0; }
body { background: #dce4da; color: var(--ink); }
button, input, select { font: inherit; }
button, label, select { -webkit-tap-highlight-color: transparent; }
button { color: inherit; }
button:focus-visible, input:focus-visible, select:focus-visible, summary:focus-visible, a:focus-visible, svg:focus-visible {
  outline: 3px solid rgba(239, 182, 79, 0.72);
  outline-offset: 2px;
}

.app-shell { min-height: 100vh; display: flex; flex-direction: column; }
.topbar {
  position: relative;
  z-index: 20;
  min-height: 74px;
  padding: 0 22px;
  display: flex;
  align-items: center;
  gap: 20px;
  background: var(--green);
  border-bottom: 3px solid var(--green-dark);
}
.brand { display: inline-flex; align-items: center; gap: 11px; flex: 0 0 auto; color: #fffaf0; text-decoration: none; }
.brand-mark {
  width: 45px;
  height: 45px;
  display: grid;
  place-items: center;
  border: 2px solid var(--green-dark);
  border-radius: 9px;
  background: var(--amber);
  box-shadow: 3px 3px 0 var(--green-dark);
}
.brand-mark svg { width: 34px; height: 34px; fill: #9a623b; stroke: var(--green-dark); stroke-width: 1.7; }
.brand-mark .mark-grain { fill: none; stroke: #fff8e8; stroke-linecap: round; stroke-width: 1.2; }
.brand-copy { display: flex; flex-direction: column; }
.brand-copy h1 { margin: 0; font-size: 16px; line-height: 1.15; }
.brand-copy small { margin-top: 2px; color: #cbd9d1; font-size: 11px; font-weight: 550; }
.topbar-purpose {
  min-width: 0;
  margin-right: auto;
  padding: 7px 10px;
  display: flex;
  align-items: center;
  gap: 9px;
  color: #d4dfd9;
  border: 1px solid rgba(235, 243, 235, 0.22);
  border-radius: 6px;
  background: rgba(9, 31, 25, 0.28);
  white-space: nowrap;
}
.purpose-badge { padding: 2px 6px; color: var(--green-dark); background: var(--amber); border: 1px solid var(--green-dark); border-radius: 3px; box-shadow: 1px 1px 0 var(--green-dark); font-size: 8px; font-weight: 850; letter-spacing: .03em; text-transform: uppercase; }
.purpose-copy { min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.purpose-copy strong { color: #fffaf0; font-size: 10px; font-weight: 800; }
.purpose-copy small { color: #c3d2cb; font-size: 8.5px; font-weight: 570; }
.topbar-actions { display: flex; align-items: center; gap: 7px; }
.save-status { margin-right: 5px; display: inline-flex; align-items: center; gap: 7px; color: #d7e0dc; font-size: 11px; font-weight: 650; white-space: nowrap; }
.save-status i { width: 7px; height: 7px; border-radius: 50%; background: #91d0a6; box-shadow: 0 0 0 2px rgba(145, 208, 166, .18); }
.save-status.is-saving i { background: var(--amber); }
.solar-link, .header-button, .icon-button {
  min-height: 36px;
  border: 2px solid var(--green-dark);
  border-radius: 7px;
  background: var(--surface);
  box-shadow: 2px 2px 0 var(--green-dark);
  color: var(--green-dark);
  cursor: pointer;
  text-decoration: none;
}
.solar-link { padding: 0 10px; display: inline-flex; align-items: center; font-size: 10px; font-weight: 800; }
.header-button { padding: 0 11px; display: inline-flex; align-items: center; gap: 7px; font-size: 11px; font-weight: 800; }
.header-button svg, .icon-button svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.8; }
.pledge-button { background: #e5eee4; }
.icon-button { width: 36px; padding: 0; display: grid; place-items: center; }
.solar-link:hover, .header-button:hover, .icon-button:hover:not(:disabled) { background: var(--amber-soft); box-shadow: 1px 1px 0 var(--green-dark); transform: translate(1px, 1px); }
.icon-button:disabled { opacity: .42; cursor: not-allowed; box-shadow: none; }

.workspace { min-height: calc(100vh - 74px); display: grid; grid-template-columns: minmax(360px, 410px) minmax(600px, 1fr); overflow: hidden; }
.controls-panel {
  height: calc(100vh - 74px);
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 15px 14px 42px;
  background: #e9ece3;
  border-right: 2px solid var(--line-strong);
}
.global-settings-section {
  margin-bottom: 12px;
  padding: 10px 11px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-small);
  background: #dfe5da;
}
.global-settings-section > div:first-child { display: flex; align-items: center; gap: 9px; }
.global-label { font-size: 9px; font-weight: 850; letter-spacing: .07em; text-transform: uppercase; }
.measurement-picker { display: inline-flex; padding: 2px; border: 1px solid var(--line-strong); border-radius: 5px; background: var(--surface-soft); }
.measurement-picker button { min-height: 26px; padding: 0 8px; border: 0; border-radius: 3px; background: transparent; font-size: 9px; font-weight: 800; cursor: pointer; }
.measurement-picker button[aria-pressed="true"] { background: var(--green); color: #fffaf0; box-shadow: 1px 1px 0 var(--green-dark); }
.global-actions { display: flex; gap: 8px; }
.global-actions button { padding: 0; border: 0; border-bottom: 1px solid currentColor; background: transparent; color: var(--green); font-size: 9px; font-weight: 800; cursor: pointer; }

.control-section, .sidebar-note {
  margin-bottom: 13px;
  padding: 16px;
  border: 1.5px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-small);
}
.section-heading { margin-bottom: 9px; display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.eyebrow { margin: 0 0 3px; color: var(--amber-dark); font-size: 9px; font-weight: 900; letter-spacing: .09em; text-transform: uppercase; }
.section-heading h2, .cut-card h2 { margin: 0; font-size: 17px; letter-spacing: -.02em; line-height: 1.12; }
.section-badge, .count-badge { padding: 3px 6px; border-radius: 4px; background: var(--green-soft); color: var(--green); font-size: 8.5px; font-weight: 800; white-space: nowrap; }
.section-intro { margin: 0 0 12px; color: var(--muted); font-size: 10px; line-height: 1.45; }
label > span:first-child, .stock-fieldset legend { display: block; margin-bottom: 5px; color: var(--ink); font-size: 9.5px; font-weight: 800; }
input, select { min-width: 0; border: 1.5px solid var(--line-strong); border-radius: 6px; background: #fffef9; color: var(--ink); }
input:hover, select:hover { border-color: var(--green); }
input { height: 36px; padding: 0 9px; }
select { width: 100%; height: 36px; padding: 0 28px 0 9px; cursor: pointer; }
.dimension-grid { display: grid; grid-template-columns: minmax(0, 1fr) 16px minmax(0, 1fr); align-items: end; gap: 7px; }
.dimension-times { padding-bottom: 10px; color: var(--line-strong); font-weight: 800; text-align: center; }
.input-with-unit { position: relative; display: block; }
.input-with-unit input { width: 100%; padding-right: 34px; font-weight: 750; }
.input-with-unit b { position: absolute; top: 50%; right: 9px; color: var(--muted); font-size: 9px; transform: translateY(-50%); pointer-events: none; }
.house-edge-note { margin-top: 10px; padding: 7px 9px; display: flex; align-items: center; gap: 8px; border: 1px dashed #b28a42; border-radius: 6px; background: #fff7da; color: #6c511e; font-size: 9px; }
.house-edge-note > span:first-child { width: 23px; height: 23px; display: grid; place-items: center; border-radius: 4px; background: var(--amber); color: var(--green-dark); font-size: 14px; }
.openings-details, .advanced-details { margin-top: 11px; border-top: 1px solid var(--line); }
.openings-details summary, .advanced-details summary { padding: 10px 1px 0; display: flex; align-items: center; justify-content: space-between; gap: 8px; color: var(--green); font-size: 10px; font-weight: 850; cursor: pointer; list-style-position: inside; }
.openings-details > p, .advanced-details > p { margin: 8px 0; color: var(--muted); font-size: 9px; line-height: 1.4; }
.obstacle-list { display: grid; gap: 6px; margin: 9px 0; }
.obstacle-item { padding: 7px 8px; display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 7px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface-soft); }
.obstacle-item strong, .obstacle-item small { display: block; }
.obstacle-item strong { font-size: 9.5px; }
.obstacle-item small { margin-top: 2px; color: var(--muted); font-size: 8px; }
.obstacle-item button { width: 25px; height: 25px; border: 1px solid #bf8c80; border-radius: 4px; background: var(--red-soft); color: var(--red); cursor: pointer; }

.select-field { display: block; }
.two-field-grid { margin-top: 10px; display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
.stock-fieldset { min-width: 0; margin: 13px 0 0; padding: 11px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface-soft); }
.stock-fieldset legend { padding: 0 4px; margin: 0; }
.stock-fieldset > p { margin: 0 0 8px; color: var(--muted); font-size: 8.5px; }
.stock-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.stock-chip { position: relative; }
.stock-chip input { position: absolute; opacity: 0; pointer-events: none; }
.stock-chip span { min-width: 45px; height: 31px; padding: 0 8px; display: inline-flex; align-items: center; justify-content: center; border: 1.5px solid var(--line-strong); border-radius: 5px; background: var(--surface); font-size: 9px; font-weight: 850; cursor: pointer; }
.stock-chip input:checked + span { border-color: var(--green-dark); background: var(--green); color: #fffaf0; box-shadow: 2px 2px 0 var(--amber); }
.stock-chip.is-custom span::after { content: " ×"; margin-left: 4px; opacity: .72; }
.custom-stock-row { margin-top: 9px; display: grid; grid-template-columns: auto minmax(70px, 1fr) auto; align-items: end; gap: 6px; }
.custom-stock-row > label { padding-bottom: 9px; color: var(--muted); font-size: 8.5px; font-weight: 750; }
.custom-stock-row button { height: 36px; padding: 0 10px; border: 1.5px solid var(--green); border-radius: 6px; background: var(--green-soft); color: var(--green); font-size: 9px; font-weight: 850; cursor: pointer; }

.direction-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.direction-card { min-width: 0; padding: 9px; display: grid; grid-template-columns: 43px 1fr; grid-template-rows: auto auto; column-gap: 8px; text-align: left; border: 1.5px solid var(--line); border-radius: 8px; background: var(--surface-soft); cursor: pointer; }
.direction-card:hover { border-color: var(--green); }
.direction-card.is-active { border-color: var(--green-dark); background: var(--amber-soft); box-shadow: 2px 2px 0 var(--green-dark); }
.direction-card strong { align-self: end; font-size: 9px; line-height: 1.2; }
.direction-card small { align-self: start; margin-top: 2px; color: var(--muted); font-size: 7.5px; }
.direction-preview { grid-row: 1 / span 2; width: 43px; height: 36px; display: block; overflow: hidden; border: 1px solid var(--line-strong); border-radius: 4px; background-color: #d2a070; }
.direction-preview i { width: 100%; height: 100%; display: block; }
.preview-horizontal i { background: repeating-linear-gradient(0deg, transparent 0 6px, rgba(255,255,255,.7) 6px 7px); }
.preview-vertical i { background: repeating-linear-gradient(90deg, transparent 0 6px, rgba(255,255,255,.7) 6px 7px); }
.preview-diagonal-right i { background: repeating-linear-gradient(45deg, transparent 0 6px, rgba(255,255,255,.72) 6px 7px); }
.preview-diagonal-left i { background: repeating-linear-gradient(-45deg, transparent 0 6px, rgba(255,255,255,.72) 6px 7px); }
.secondary-button, .primary-button { min-height: 39px; padding: 0 13px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 2px solid var(--green-dark); border-radius: 7px; font-size: 10px; font-weight: 850; cursor: pointer; }
.secondary-button { background: var(--surface); color: var(--green); box-shadow: var(--shadow-small); }
.primary-button { background: var(--amber); color: var(--green-dark); box-shadow: 3px 3px 0 var(--green-dark); }
.secondary-button:hover, .primary-button:hover { box-shadow: 1px 1px 0 var(--green-dark); transform: translate(1px, 1px); }
.secondary-button svg, .primary-button svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.8; }
.compact-button { min-height: 33px; width: 100%; font-size: 9px; }
.compare-button { width: 100%; margin-top: 10px; }

.gap-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 7px; }
.gap-grid label > span:first-child { min-height: 24px; line-height: 1.25; }
.info-dot { width: 15px; height: 15px; padding: 0; display: inline-grid; place-items: center; border: 1px solid var(--line-strong); border-radius: 50%; background: var(--surface-soft); color: var(--muted); font-size: 8px; font-weight: 850; cursor: help; }
.gap-caution { margin-top: 9px; padding: 7px 8px; display: flex; align-items: flex-start; gap: 7px; border: 1px solid #d5b774; border-radius: 6px; background: #fff8dc; color: #70561e; font-size: 8px; line-height: 1.4; }
.gap-caution svg { width: 16px; height: 16px; flex: 0 0 auto; fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.8; }
.seam-fields { margin-top: 11px; }
.advanced-details[open] { padding-bottom: 3px; }
.check-row { margin-top: 9px; display: grid; grid-template-columns: auto 1fr; align-items: flex-start; gap: 8px; cursor: pointer; }
.check-row input { width: 16px; height: 16px; margin: 1px 0 0; accent-color: var(--green); }
.check-row span { display: flex; flex-direction: column; gap: 1px; }
.check-row strong { font-size: 9px; }
.check-row small { color: var(--muted); font-size: 8px; line-height: 1.3; }
.generate-button { width: 100%; min-height: 49px; margin-top: 13px; }
.generate-button > span { display: flex; flex-direction: column; align-items: flex-start; }
.generate-button strong { font-size: 11px; }
.generate-button small { margin-top: 1px; font-size: 8px; font-weight: 650; }
.field-error { margin: 8px 0 0; padding: 7px; border-radius: 5px; background: var(--red-soft); color: var(--red); font-size: 9px; font-weight: 750; }
.sidebar-note { position: relative; background: #fff5c9; border-color: #b59a57; transform: rotate(-.35deg); }
.sidebar-note p { margin: 0; color: #675530; font-size: 9px; line-height: 1.5; }
.sidebar-note a { margin-top: 7px; display: inline-block; color: var(--green); font-size: 9px; font-weight: 850; }
.pencil-mark { position: absolute; top: 8px; right: 10px; color: #b58c3f; font-size: 16px; transform: rotate(12deg); }

.planner { min-width: 0; height: calc(100vh - 74px); padding: 15px 16px 36px; overflow-y: auto; overscroll-behavior: contain; }
.summary-card { margin-bottom: 12px; display: grid; grid-template-columns: minmax(185px, .82fr) minmax(460px, 1.8fr); border: 1.5px solid var(--line-strong); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow-small); overflow: hidden; }
.summary-message { min-width: 0; padding: 12px 14px; display: flex; flex-direction: column; justify-content: center; border-right: 1px solid var(--line); background: #f5f1e3; }
.summary-kicker, .canvas-kicker { color: var(--amber-dark); font-size: 8px; font-weight: 900; letter-spacing: .08em; text-transform: uppercase; }
.summary-message strong { margin-top: 2px; font-size: 11px; line-height: 1.25; }
.summary-message > span:last-child { margin-top: 3px; color: var(--muted); font-size: 8px; line-height: 1.35; }
.stats-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); }
.stat-item { min-width: 0; padding: 10px 11px; display: flex; flex-direction: column; justify-content: center; border-right: 1px solid var(--line); }
.stat-item:last-child { border-right: 0; }
.stat-item > span { color: var(--muted); font-size: 7.5px; font-weight: 800; letter-spacing: .04em; text-transform: uppercase; }
.stat-item strong { margin-top: 2px; overflow: hidden; font-size: 15px; letter-spacing: -.02em; text-overflow: ellipsis; white-space: nowrap; }
.stat-item small { margin-top: 2px; overflow: hidden; color: var(--muted); font-size: 7.5px; text-overflow: ellipsis; white-space: nowrap; }
.waste-stat strong { color: var(--teal); }
.canvas-card { border: 1.5px solid var(--line-strong); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); overflow: hidden; }
.canvas-toolbar { min-height: 57px; padding: 8px 11px; display: flex; align-items: center; justify-content: space-between; gap: 12px; border-bottom: 1px solid var(--line); }
.canvas-title-group { min-width: 0; display: grid; grid-template-columns: auto auto; column-gap: 8px; align-items: baseline; }
.canvas-title-group .canvas-kicker { grid-column: 1 / span 2; }
.canvas-title-group strong { font-size: 12px; }
.canvas-title-group small { color: var(--muted); font-size: 8px; }
.toolbar-actions { display: flex; align-items: center; gap: 7px; }
.label-toggle { min-height: 33px; padding: 0 8px; display: inline-flex; align-items: center; gap: 5px; border: 1px solid var(--line); border-radius: 5px; background: var(--surface-soft); font-size: 8px; font-weight: 800; cursor: pointer; }
.label-toggle input { width: 14px; height: 14px; accent-color: var(--green); }
.toolbar-button { min-height: 33px; padding: 0 9px; display: inline-flex; align-items: center; gap: 5px; border: 1px solid var(--line-strong); border-radius: 5px; background: var(--surface-soft); font-size: 8px; font-weight: 800; cursor: pointer; }
.toolbar-button:hover { border-color: var(--green); background: var(--green-soft); }
.toolbar-button svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.8; }
.selected-piece-bar { min-height: 44px; padding: 6px 10px 6px 13px; display: flex; align-items: center; gap: 12px; border-bottom: 1px solid #bb8b56; background: #fff0cf; }
.selected-piece-bar > span:first-child { min-width: 0; display: flex; flex-direction: column; }
.selected-piece-bar strong { font-size: 9px; }
.selected-piece-bar small { margin-top: 1px; color: var(--muted); font-size: 8px; }
.selected-stock { margin-left: auto; padding: 4px 7px; border: 1px solid #c79454; border-radius: 4px; background: #fffaf0; color: #75502d; font-size: 8px; font-weight: 800; }
.selected-piece-bar button { width: 25px; height: 25px; border: 0; background: transparent; font-size: 18px; cursor: pointer; }
.canvas-wrap { position: relative; height: clamp(480px, calc(100vh - 260px), 760px); min-height: 420px; overflow: hidden; background: var(--canvas); cursor: grab; touch-action: none; }
.canvas-wrap.is-panning { cursor: grabbing; }
#deck-canvas { width: 100%; height: 100%; display: block; user-select: none; }
#canvas-background { pointer-events: all; }
.deck-shadow-shape { fill: #f8f3e3; stroke: var(--green-dark); stroke-width: 1.8; filter: url(#deck-shadow); vector-effect: non-scaling-stroke; }
.deck-inner-shape { fill: #e5d4bb; stroke: #80552f; stroke-width: 1.1; vector-effect: non-scaling-stroke; }
.house-edge-line { stroke: var(--green-dark); stroke-width: 5; stroke-linecap: round; vector-effect: non-scaling-stroke; }
.house-edge-tick { stroke: #fffaf0; stroke-width: 1.2; vector-effect: non-scaling-stroke; }
.joist-line { stroke: #426d64; stroke-width: .8; stroke-dasharray: 5 4; opacity: .55; vector-effect: non-scaling-stroke; }
.board-piece { stroke: rgba(58, 38, 22, .72); stroke-width: .65; vector-effect: non-scaling-stroke; cursor: pointer; transition: filter .1s, opacity .1s; }
.board-piece:hover { filter: brightness(1.08); stroke: var(--green-dark); stroke-width: 1.4; }
.board-piece.is-selected { stroke: #fff8dc; stroke-width: 2.7; filter: drop-shadow(0 0 3px rgba(20, 43, 35, .8)); }
.board-grain { fill: none; stroke: rgba(255,255,255,.34); stroke-width: .45; pointer-events: none; vector-effect: non-scaling-stroke; }
.board-end { stroke: rgba(43, 31, 20, .92); stroke-width: 1.1; pointer-events: none; vector-effect: non-scaling-stroke; }
.piece-label { fill: #fffdf4; stroke: rgba(38,52,47,.8); stroke-width: 2.5; paint-order: stroke; font-size: 7px; font-weight: 850; text-anchor: middle; pointer-events: none; }
.obstacle-shape { fill: #f5e4de; stroke: var(--red); stroke-width: 1.5; vector-effect: non-scaling-stroke; }
.obstacle-hatch { fill: url(#obstacle-hatch); opacity: .55; }
.obstacle-label { fill: var(--red); font-size: 8px; font-weight: 850; text-anchor: middle; }
.dimension-line { fill: none; stroke: #6e500e; stroke-width: 1; vector-effect: non-scaling-stroke; }
.dimension-label-bg { fill: var(--surface); stroke: #8b7753; stroke-width: .7; vector-effect: non-scaling-stroke; }
.dimension-label { fill: #65470e; font-size: 8px; font-weight: 850; text-anchor: middle; }
.house-label { fill: var(--green-dark); font-size: 8px; font-weight: 900; letter-spacing: .06em; text-anchor: middle; }
.orientation-arrow { fill: none; stroke: var(--green); stroke-width: 2; marker-end: url(#arrow-end); vector-effect: non-scaling-stroke; }
.zoom-controls { position: absolute; right: 10px; bottom: 10px; display: inline-flex; align-items: center; border: 1px solid var(--green-dark); border-radius: 6px; background: var(--surface); box-shadow: var(--shadow-small); overflow: hidden; }
.zoom-controls button { width: 32px; height: 31px; border: 0; background: transparent; font-weight: 850; cursor: pointer; }
.zoom-controls button:hover { background: var(--amber-soft); }
.zoom-controls span { min-width: 47px; color: var(--muted); font-size: 8px; font-weight: 800; text-align: center; }
.canvas-toast { position: absolute; left: 50%; bottom: 12px; z-index: 5; max-width: calc(100% - 170px); padding: 8px 12px; border: 1px solid var(--green-dark); border-radius: 6px; background: var(--green-dark); box-shadow: var(--shadow-small); color: #fffaf0; font-size: 9px; font-weight: 750; transform: translateX(-50%); }
.canvas-footer { min-height: 38px; padding: 7px 10px; display: flex; flex-wrap: wrap; align-items: center; gap: 5px 13px; border-top: 1px solid var(--line); color: var(--muted); font-size: 7.5px; }
.canvas-footer b { padding: 2px 4px; border: 1px solid var(--line); border-radius: 3px; background: var(--surface-soft); color: var(--ink); }
.canvas-disclaimer { margin-left: auto; font-style: italic; }

.cut-card { margin-top: 14px; padding: 16px; border: 1.5px solid var(--line-strong); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow-small); }
.cut-card-heading { display: flex; justify-content: space-between; gap: 15px; }
.cut-card-heading p:last-child { margin: 5px 0 0; color: var(--muted); font-size: 9px; }
.cut-actions { display: flex; gap: 6px; }
.cut-actions button { height: 32px; padding: 0 9px; border: 1px solid var(--line-strong); border-radius: 5px; background: var(--surface-soft); font-size: 8px; font-weight: 800; cursor: pointer; }
.purchase-strip { margin: 13px 0 10px; display: flex; flex-wrap: wrap; gap: 7px; }
.purchase-pill { min-width: 92px; padding: 7px 9px; border: 1px solid #b99868; border-radius: 6px; background: #fff4d6; }
.purchase-pill strong, .purchase-pill small { display: block; }
.purchase-pill strong { font-size: 10px; }
.purchase-pill small { margin-top: 1px; color: var(--muted); font-size: 7.5px; }
.cut-table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 7px; }
table { width: 100%; border-collapse: collapse; font-size: 9px; }
th { padding: 7px 9px; background: var(--green); color: #fffaf0; font-size: 7.5px; letter-spacing: .04em; text-align: left; text-transform: uppercase; }
td { padding: 7px 9px; border-top: 1px solid var(--line); }
tbody tr:nth-child(even) { background: var(--surface-soft); }
td:first-child { width: 52px; font-weight: 850; }
.cut-notes { margin-top: 10px; display: grid; grid-template-columns: repeat(3, 1fr); gap: 7px; }
.cut-note { padding: 8px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface-soft); color: var(--muted); font-size: 8px; line-height: 1.4; }
.cut-note strong { display: block; margin-bottom: 2px; color: var(--ink); font-size: 8.5px; }

.app-dialog { width: min(650px, calc(100vw - 28px)); max-height: min(820px, calc(100vh - 30px)); padding: 20px; overflow: auto; border: 2px solid var(--green-dark); border-radius: 12px; background: var(--surface); box-shadow: 8px 8px 0 rgba(23, 46, 39, .38); color: var(--ink); }
.app-dialog::backdrop { background: rgba(16, 31, 27, .58); backdrop-filter: blur(2px); }
.dialog-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.dialog-heading h2 { margin: 0; font-size: 21px; letter-spacing: -.025em; }
.dialog-close { width: 32px; height: 32px; flex: 0 0 auto; border: 1px solid var(--line-strong); border-radius: 6px; background: var(--surface-soft); font-size: 21px; line-height: 1; cursor: pointer; }
.dialog-copy { margin: 10px 0 15px; color: var(--muted); font-size: 10px; line-height: 1.5; }
.dialog-actions { margin-top: 17px; display: flex; justify-content: flex-end; gap: 9px; }
.tutorial-paths { margin-top: 16px; display: grid; grid-template-columns: repeat(3, 1fr); gap: 9px; }
.tutorial-paths section { position: relative; padding: 37px 11px 11px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface-soft); }
.tutorial-number { position: absolute; top: 9px; left: 10px; width: 22px; height: 22px; display: grid; place-items: center; border: 1px solid var(--green-dark); border-radius: 50%; background: var(--amber); font-size: 10px; font-weight: 900; }
.tutorial-paths h3 { margin: 0; font-size: 11px; }
.tutorial-paths p { margin: 5px 0 0; color: var(--muted); font-size: 9px; line-height: 1.45; }
.dialog-callout { margin-top: 11px; padding: 10px; display: flex; gap: 8px; border: 1px dashed #b18d4e; border-radius: 7px; background: #fff7dc; font-size: 9px; line-height: 1.45; }
.dialog-callout strong { white-space: nowrap; }
.compare-dialog { width: min(860px, calc(100vw - 28px)); }
.compare-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.compare-card { position: relative; padding: 13px; border: 1.5px solid var(--line); border-radius: 9px; background: var(--surface-soft); }
.compare-card.is-best { border-color: var(--green); background: #e8f1e7; box-shadow: var(--shadow-small); }
.best-badge { position: absolute; top: -8px; right: 10px; padding: 3px 7px; border: 1px solid var(--green-dark); border-radius: 4px; background: var(--amber); color: var(--green-dark); font-size: 7px; font-weight: 900; text-transform: uppercase; }
.compare-card h3 { margin: 0; font-size: 12px; }
.compare-card > p { margin: 4px 0 9px; color: var(--muted); font-size: 8.5px; }
.compare-metrics { display: grid; grid-template-columns: repeat(3, 1fr); border: 1px solid var(--line); border-radius: 6px; background: var(--surface); overflow: hidden; }
.compare-metrics span { padding: 7px; display: flex; flex-direction: column; border-right: 1px solid var(--line); }
.compare-metrics span:last-child { border: 0; }
.compare-metrics strong { font-size: 11px; }
.compare-metrics small { color: var(--muted); font-size: 7px; }
.compare-card button { width: 100%; height: 34px; margin-top: 9px; border: 1.5px solid var(--green); border-radius: 5px; background: var(--surface); color: var(--green); font-size: 8.5px; font-weight: 850; cursor: pointer; }
.compare-card.is-current button { background: var(--green); color: #fffaf0; }
.dialog-field-grid { margin-top: 15px; display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.wide-field { grid-column: 1 / -1; }
.share-field span { display: block; margin-bottom: 5px; font-size: 9px; font-weight: 800; }
.share-field input { width: 100%; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 9px; }
.export-grid { margin-top: 15px; display: grid; grid-template-columns: repeat(2, 1fr); gap: 9px; }
.export-grid button { min-height: 64px; padding: 10px; display: flex; flex-direction: column; align-items: flex-start; border: 1.5px solid var(--line); border-radius: 8px; background: var(--surface-soft); cursor: pointer; }
.export-grid button:hover { border-color: var(--green); background: var(--green-soft); }
.export-grid strong { font-size: 10px; }
.export-grid small { margin-top: 3px; color: var(--muted); font-size: 8px; }
.pledge-grid { margin-top: 15px; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.pledge-grid > span { padding: 10px; display: grid; grid-template-columns: 24px 1fr; grid-template-rows: auto auto; column-gap: 7px; border: 1px solid var(--line); border-radius: 7px; background: var(--surface-soft); }
.pledge-grid b { grid-row: 1 / span 2; width: 23px; height: 23px; display: grid; place-items: center; border-radius: 50%; background: var(--green); color: #fffaf0; }
.pledge-grid strong { font-size: 9px; }
.pledge-grid small { color: var(--muted); font-size: 8px; }
.support-link { color: var(--green); font-size: 10px; font-weight: 850; }
.destructive-button { background: var(--red); color: #fff; }

@media (max-width: 1180px) {
  .workspace { grid-template-columns: 360px minmax(520px, 1fr); }
  .topbar-purpose { display: none; }
  .save-status { display: none; }
  .summary-card { grid-template-columns: 1fr; }
  .summary-message { border-right: 0; border-bottom: 1px solid var(--line); }
  .canvas-wrap { height: 560px; }
}

@media (max-width: 860px) {
  .topbar { min-height: 66px; padding: 0 12px; }
  .brand-mark { width: 40px; height: 40px; }
  .brand-copy small, .solar-link, .pledge-button, .header-button span { display: none; }
  .header-button { width: 36px; padding: 0; justify-content: center; }
  .workspace { display: block; overflow: visible; }
  .controls-panel, .planner { height: auto; overflow: visible; }
  .controls-panel { padding: 12px 10px 5px; border-right: 0; }
  .planner { padding: 8px 10px 30px; }
  .canvas-wrap { height: min(72vh, 620px); min-height: 430px; }
  .summary-card { position: static; }
}

@media (max-width: 560px) {
  .topbar { gap: 8px; }
  .brand { margin-right: auto; }
  .brand-copy h1 { font-size: 13px; }
  .topbar-actions { gap: 5px; }
  .icon-button, .header-button { width: 34px; min-height: 34px; }
  .global-settings-section { align-items: flex-start; }
  .global-settings-section > div:first-child { align-items: flex-start; flex-direction: column; }
  .global-actions { flex-direction: column; align-items: flex-end; gap: 5px; }
  .control-section { padding: 14px; }
  .dimension-grid { grid-template-columns: 1fr; }
  .dimension-times { display: none; }
  .direction-grid { grid-template-columns: 1fr; }
  .gap-grid { grid-template-columns: 1fr; }
  .gap-grid label { display: grid; grid-template-columns: 1fr 104px; align-items: center; gap: 8px; }
  .gap-grid label > span:first-child { min-height: 0; margin: 0; }
  .two-field-grid { grid-template-columns: 1fr; }
  .summary-message { padding: 10px; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .stat-item { border-bottom: 1px solid var(--line); }
  .stat-item:nth-child(2) { border-right: 0; }
  .stat-item:nth-child(n+3) { border-bottom: 0; }
  .canvas-toolbar { align-items: flex-start; }
  .canvas-title-group { display: flex; flex-direction: column; }
  .canvas-title-group small, .label-toggle span, .toolbar-button span { display: none; }
  .label-toggle, .toolbar-button { width: 34px; padding: 0; justify-content: center; }
  .label-toggle input { width: 16px; }
  .canvas-wrap { height: 66vh; min-height: 390px; }
  .canvas-footer span:nth-child(n+3):not(.canvas-disclaimer) { display: none; }
  .canvas-disclaimer { width: 100%; margin-left: 0; }
  .cut-card-heading { flex-direction: column; }
  .cut-actions button { flex: 1; }
  .cut-notes { grid-template-columns: 1fr; }
  th, td { padding: 7px 6px; }
  .tutorial-paths, .compare-grid, .pledge-grid, .export-grid { grid-template-columns: 1fr; }
  .dialog-actions { flex-direction: column-reverse; }
  .dialog-actions > * { width: 100%; }
}

@media print {
  @page { size: landscape; margin: .4in; }
  body { background: #fff; }
  .topbar, .controls-panel, .canvas-toolbar, .canvas-footer, .cut-actions, .zoom-controls, .selected-piece-bar { display: none !important; }
  .workspace { display: block; min-height: 0; overflow: visible; }
  .planner { height: auto; padding: 0; overflow: visible; }
  .summary-card, .canvas-card, .cut-card { break-inside: avoid; box-shadow: none; }
  .canvas-wrap { height: 5.6in; min-height: 0; }
  .cut-card { margin-top: .15in; padding: .12in; }
  .cut-table-wrap { max-height: 2.1in; overflow: hidden; }
  .cut-notes { display: none; }
}
