/*!
 * Phase 213 extraction — layer: p209-product-ui
 * ---------------------------------------------
 * Owner        : MTLE Phase 209 (product UI redesign: cards, Design Preview
 *                compositor, Step 5 receipt, debug gating)
 * Scope attr   : html[data-p209="v1"] (set by /web/mtle/js/p209-product-ui.js)
 * Public hook  : window._p209
 * Cascade      : loads AFTER p208-shell.css, BEFORE p210-cards-preview.css.
 * Contract     : Additive only; no export/preflight contract touched.
 *                Display palette remaps are CSS-only and scoped to
 *                `#preview-panel .mte-pv-svg-host` so production SVG
 *                bytes remain byte-identical.
 */

/* =====================================================================
 * PHASE 209 — MTLE Product UI Redesign: Design Preview compositor,
 * product cards, grouped features, Step 5 export receipt, debug gating.
 *
 * Scope: all rules below target `html[data-p209="v1"]` so activation is
 * additive over Phase 208 and falls back cleanly if the p209 bootstrap
 * is disabled.  No production export bytes touched — palette remaps
 * are CSS-only and scoped to `#preview-panel .mte-pv-svg-host`.
 * =================================================================== */
html[data-p209="v1"] {
  /* Display palette — muted ink on basswood, premium product read. */
  --p209-ink-0:          #1a140a;
  --p209-ink-1:          #2e2619;
  --p209-ink-2:          #4d4030;
  --p209-ink-3:          #7a6b54;
  --p209-ink-soft:       rgba(26,20,10,0.45);
  --p209-paper-plaque:   #f6ecc7;
  --p209-paper-deep:     #c1a26d;
  --p209-water-display:  #4b7394;
  --p209-park-display:   #6d8b5c;
  --p209-road-major:     #2e2619;
  --p209-road-minor:     #6d5e46;
  --p209-building:       #8a7050;
  --p209-label-text:     #3a2f22;
  --p209-boundary:       #8c7641;
  --p209-waterway:       #6893b3;
  --p209-accent-warm:    #c57a2c;
  --p209-card-bg:        #111621;
  --p209-card-bg-hover:  #14192a;
  --p209-card-border:    rgba(255,255,255,0.08);
  --p209-card-border-hi: rgba(94,160,255,0.40);
  --p209-card-shadow:    0 10px 24px -12px rgba(0,0,0,0.60), 0 1px 0 rgba(255,255,255,0.04) inset;
  --p209-receipt-bg:     linear-gradient(180deg, #0e1320, #0a0d15);
  --p209-receipt-head:   linear-gradient(180deg, rgba(52,211,153,0.22), rgba(52,211,153,0.06));
}

/* ----------- Display-mode segmented control (stage chrome) ----------- */
html[data-p209="v1"] .p209-display-mode-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  background: var(--p208-graphite-1);
  border-bottom: 1px solid var(--p208-hairline);
  font-size: 11.5px;
}
html[data-p209="v1"] .p209-display-mode-row .p209-dm-label {
  color: var(--text-secondary);
  letter-spacing: 0.4px;
  text-transform: uppercase;
  font-weight: 600;
  margin-right: 4px;
}
html[data-p209="v1"] .p209-display-mode-group {
  display: inline-flex;
  background: var(--p208-graphite-0);
  border: 1px solid var(--p208-hairline);
  border-radius: 999px;
  padding: 3px;
  gap: 2px;
}
html[data-p209="v1"] .p209-dm-btn {
  appearance: none;
  -webkit-appearance: none;
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 4px 12px;
  font-size: 11.5px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.14s, color 0.14s, border-color 0.14s;
}
html[data-p209="v1"] .p209-dm-btn:hover { color: #dde3ec; }
html[data-p209="v1"] .p209-dm-btn.active {
  background: linear-gradient(180deg, rgba(94,160,255,0.24), rgba(94,160,255,0.08));
  color: var(--p208-accent-strong);
  border-color: rgba(94,160,255,0.40);
  box-shadow: 0 1px 0 rgba(255,255,255,0.06) inset;
}
html[data-p209="v1"] .p209-dm-btn:focus-visible {
  outline: none;
  box-shadow: var(--p208-focus-ring);
}
html[data-p209="v1"] .p209-dm-caption {
  margin-left: auto;
  color: var(--text-muted);
  font-size: 10.5px;
  letter-spacing: 0.3px;
}
html[data-p209="v1"] .p209-dm-caption b { color: var(--p208-accent-strong); font-weight: 600; }

/* ----------- Design Preview compositor overlays ----------- */
html[data-p209="v1"] #preview-panel .preview-area { position: relative; }
html[data-p209="v1"] .p209-design-preview-shell {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 2;
  display: none;
  font-family: var(--font-sans, system-ui);
}
html[data-p209="v1"] #preview-panel[data-p209-display-mode="design_preview"]
  .p209-design-preview-shell { display: block; }
html[data-p209="v1"] .p209-dp-plaque {
  position: absolute;
  top: 14px; left: 50%;
  transform: translateX(-50%);
  background: linear-gradient(180deg, var(--p209-paper-plaque), #e8d4a3);
  color: var(--p209-ink-0);
  padding: 6px 16px 7px;
  border-radius: 3px;
  border: 1px solid var(--p209-boundary);
  box-shadow: 0 2px 6px rgba(0,0,0,0.35), inset 0 1px 0 rgba(255,255,255,0.35);
  font-weight: 600;
  font-size: 12.5px;
  letter-spacing: 0.25px;
  text-align: center;
  min-width: 200px;
  max-width: 60%;
  pointer-events: auto;
}
html[data-p209="v1"] .p209-dp-plaque .p209-dp-plaque-sub {
  display: block;
  font-weight: 400;
  font-size: 10.5px;
  color: var(--p209-ink-2);
  letter-spacing: 0.2px;
  margin-top: 1px;
}
html[data-p209="v1"] .p209-dp-north {
  position: absolute;
  top: 20px; right: 20px;
  width: 42px; height: 42px;
  color: var(--p209-ink-1);
  opacity: 0.88;
  filter: drop-shadow(0 1px 1px rgba(0,0,0,0.35));
}
html[data-p209="v1"] .p209-dp-scale {
  position: absolute;
  /* Phase 209.2: raise above the mte-pv-toolbar (Fit / 100% / + / -)
   * strip so the scale bar doesn't overlap the zoom controls. The
   * toolbar strip is ~32 px tall; 48 px clears it on all viewports. */
  bottom: 48px; left: 20px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 10.5px;
  color: var(--p209-ink-1);
  background: rgba(246,236,199,0.92);
  border: 1px solid var(--p209-boundary);
  padding: 3px 8px 2px;
  border-radius: 2px;
  /* Phase 209.2: scale readout is decorative; never block clicks on the
   * viewer toolbar even if it visually nears the zoom buttons. */
  pointer-events: none;
}
html[data-p209="v1"] .p209-dp-scale .p209-dp-scale-bar {
  display: inline-block;
  width: 60px; height: 5px;
  background:
    linear-gradient(90deg, var(--p209-ink-1) 50%, var(--p209-paper-plaque) 50%);
  border: 1px solid var(--p209-ink-1);
}
html[data-p209="v1"] .p209-dp-corner-tick {
  position: absolute;
  width: 16px; height: 16px;
  border: 2px solid var(--p209-ink-2);
  opacity: 0.45;
}
html[data-p209="v1"] .p209-dp-corner-tick.tl { top: 6px; left: 6px; border-right: none; border-bottom: none; }
html[data-p209="v1"] .p209-dp-corner-tick.tr { top: 6px; right: 6px; border-left: none; border-bottom: none; }
html[data-p209="v1"] .p209-dp-corner-tick.bl { bottom: 6px; left: 6px; border-right: none; border-top: none; }
html[data-p209="v1"] .p209-dp-corner-tick.br { bottom: 6px; right: 6px; border-left: none; border-top: none; }
html[data-p209="v1"] .p209-dp-confidence {
  position: absolute;
  /* Phase 209.2: raise above the mte-pv-toolbar to match the scale bar. */
  bottom: 48px; right: 20px;
  background: rgba(246,236,199,0.92);
  color: var(--p209-ink-1);
  border: 1px solid var(--p209-boundary);
  padding: 4px 10px 3px;
  border-radius: 2px;
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: 0.2px;
  /* Phase 209.2: decorative only; never block clicks on the viewer. */
  pointer-events: none;
}
html[data-p209="v1"] .p209-dp-confidence::before {
  content: "";
  display: inline-block;
  width: 6px; height: 6px;
  border-radius: 999px;
  background: var(--p208-good);
  margin-right: 6px;
  vertical-align: 1px;
  box-shadow: 0 0 6px rgba(52,211,153,0.55);
}

/* Design-preview palette remap — scoped to the preview-viewer inline SVG
 * only.  Works on the browser paint layer without mutating SVG bytes.
 * Raw production attributes stay intact; a Playwright assertion in
 * Phase 209 confirms underlying `stroke`/`fill` attributes are
 * unchanged while computed style differs. */
html[data-p209="v1"] #preview-panel[data-p209-display-mode="design_preview"]
  .mte-pv-svg-host svg [stroke="#FF00FF" i],
html[data-p209="v1"] #preview-panel[data-p209-display-mode="design_preview"]
  .mte-pv-svg-host svg [fill="#FF00FF" i] {
  stroke: var(--p209-building) !important;
  fill-opacity: 0.35 !important;
}
html[data-p209="v1"] #preview-panel[data-p209-display-mode="design_preview"]
  .mte-pv-svg-host svg [stroke="#0000FF" i],
html[data-p209="v1"] #preview-panel[data-p209-display-mode="design_preview"]
  .mte-pv-svg-host svg [stroke="#0000ff" i] {
  stroke: var(--p209-water-display) !important;
}
html[data-p209="v1"] #preview-panel[data-p209-display-mode="design_preview"]
  .mte-pv-svg-host svg [stroke="#0000A0" i] {
  stroke: var(--p209-road-major) !important;
}
html[data-p209="v1"] #preview-panel[data-p209-display-mode="design_preview"]
  .mte-pv-svg-host svg [stroke="#808080" i] {
  stroke: var(--p209-road-minor) !important;
}
html[data-p209="v1"] #preview-panel[data-p209-display-mode="design_preview"]
  .mte-pv-svg-host svg [stroke="#00E000" i],
html[data-p209="v1"] #preview-panel[data-p209-display-mode="design_preview"]
  .mte-pv-svg-host svg [stroke="#00E0E0" i] {
  stroke: var(--p209-park-display) !important;
}
html[data-p209="v1"] #preview-panel[data-p209-display-mode="design_preview"]
  .mte-pv-svg-host svg [stroke="#A0FFA0" i] {
  stroke: var(--p209-park-display) !important;
  stroke-opacity: 0.8 !important;
}
/* Phase 257 FU1: split the road-label palette remap into stroke-only
 * + fill-only rules so a polyline emitted with `stroke="#D0D000"` and
 * `fill="none"` is NOT given a fill by the design-preview palette
 * (which would turn label polylines into solid filled letters and
 * the closed label-box polyline into a solid filled rectangle). */
html[data-p209="v1"] #preview-panel[data-p209-display-mode="design_preview"]
  .mte-pv-svg-host svg [stroke="#D0D000" i],
html[data-p209="v1"] #preview-panel[data-p209-display-mode="design_preview"]
  .mte-pv-svg-host svg [stroke="#FF8000" i] {
  stroke: var(--p209-label-text) !important;
}
html[data-p209="v1"] #preview-panel[data-p209-display-mode="design_preview"]
  .mte-pv-svg-host svg [fill="#D0D000" i],
html[data-p209="v1"] #preview-panel[data-p209-display-mode="design_preview"]
  .mte-pv-svg-host svg [fill="#FF8000" i] {
  fill: var(--p209-label-text) !important;
}
/* Phase 257 FU1: same split for the label-text palette remap.  The
 * pre-FU1 rule applied `fill: var(--p209-label-text) !important` to
 * any element with `stroke="#A000A0"`, which overrode `fill="none"`
 * on every label glyph polyline and the closed label-box polyline,
 * turning them into solid filled letters / a solid filled rectangle.
 * Operator-reported during the Phase 257 closeout review:
 *   "When I have no box enable for Map Label, the letters do not
 *    show the internal character cut outs.  When I enable the box,
 *    I get the black square."
 * Both symptoms collapse to this single CSS bug — the `fill` override
 * only made sense for elements that ALREADY have `fill="#A000A0"`
 * (like backend `<text>` glyphs, where present); polyline-based label
 * geometry (the actual export-correct format) must keep `fill="none"`. */
html[data-p209="v1"] #preview-panel[data-p209-display-mode="design_preview"]
  .mte-pv-svg-host svg [stroke="#A000A0" i] {
  stroke: var(--p209-label-text) !important;
}
html[data-p209="v1"] #preview-panel[data-p209-display-mode="design_preview"]
  .mte-pv-svg-host svg [fill="#A000A0" i] {
  fill: var(--p209-label-text) !important;
}
html[data-p209="v1"] #preview-panel[data-p209-display-mode="design_preview"]
  .mte-pv-svg-host svg [stroke="#A0A000" i],
html[data-p209="v1"] #preview-panel[data-p209-display-mode="design_preview"]
  .mte-pv-svg-host svg [stroke="#A0A0FF" i] {
  stroke: var(--p209-boundary) !important;
}
/* Tame saturated strokes for the wizard-preview only. */
html[data-p209="v1"] #preview-panel[data-p209-display-mode="design_preview"]
  .mte-pv-svg-host svg [stroke] {
  stroke-linejoin: round;
  stroke-linecap: round;
}

/* Cut-plot mode legend — makes the mode obvious to the operator. */
html[data-p209="v1"] .p209-cutplot-legend {
  position: absolute;
  top: 14px; left: 14px;
  z-index: 3;
  display: none;
  background: rgba(10,12,18,0.88);
  color: #ffd899;
  border: 1px solid rgba(245,181,71,0.45);
  padding: 6px 10px;
  border-radius: 4px;
  font-size: 11px;
  letter-spacing: 0.3px;
  pointer-events: auto;
  max-width: 260px;
  line-height: 1.35;
}
html[data-p209="v1"] #preview-panel[data-p209-display-mode="cut_plot"]
  .p209-cutplot-legend { display: block; }
html[data-p209="v1"] .p209-cutplot-legend .p209-cl-title {
  display: block;
  font-weight: 700;
  color: #f5b547;
  margin-bottom: 3px;
}

/* ----------- Customer-facing status panel + debug gating ----------- */
html[data-p209="v1"] .p209-customer-status {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--p208-hairline);
  font-size: 11.5px;
  color: #dde3ec;
  margin-left: auto;
}
html[data-p209="v1"] .p209-cs-dot {
  width: 8px; height: 8px;
  border-radius: 999px;
  background: var(--p208-good);
  box-shadow: 0 0 8px rgba(52,211,153,0.45);
}
html[data-p209="v1"] .p209-cs-dot.updating { background: var(--p208-warn); box-shadow: 0 0 8px rgba(245,181,71,0.45); }
html[data-p209="v1"] .p209-cs-dot.needs { background: var(--p208-bad); box-shadow: 0 0 8px rgba(239,107,107,0.45); }
html[data-p209="v1"] .p209-cs-text { font-weight: 600; letter-spacing: 0.2px; }
html[data-p209="v1"] .p209-cs-sep { color: var(--p208-hairline-hi); }
html[data-p209="v1"] .p209-cs-meta { color: var(--text-secondary); font-weight: 500; }

/* Debug telemetry visibility — hide Phase 208 runtime/status chrome
 * in the default customer view.  Debug flags re-enable via the
 * p209-debug-on class on <html>. */
html[data-p209="v1"]:not(.p209-debug-on) #p208-runtime-hint,
html[data-p209="v1"]:not(.p209-debug-on) #p208-stage-statusbar {
  display: none !important;
}
html[data-p209="v1"].p209-debug-on .p209-customer-status {
  opacity: 0.55;
}
html[data-p209="v1"] .p209-debug-drawer {
  display: none;
  margin-top: 6px;
  padding: 6px 10px;
  font-family: var(--mono);
  font-size: 10.5px;
  color: #dde3ec;
  background: rgba(0,0,0,0.35);
  border: 1px dashed rgba(245,181,71,0.35);
  border-radius: 4px;
  white-space: pre;
  overflow-x: auto;
}
html[data-p209="v1"].p209-debug-on .p209-debug-drawer { display: block; }

/* ----------- Step 1 product & size cards ----------- */
html[data-p209="v1"] .p209-card-grid {
  display: grid;
  gap: 10px;
  margin: 10px 0 14px;
}
html[data-p209="v1"] .p209-card-grid.cols-2 { grid-template-columns: 1fr 1fr; }
html[data-p209="v1"] .p209-card-grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
html[data-p209="v1"] .p209-card-grid.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
html[data-p209="v1"] .p209-product-card {
  appearance: none;
  -webkit-appearance: none;
  background: var(--p209-card-bg);
  color: #dde3ec;
  border: 1px solid var(--p209-card-border);
  border-radius: var(--p208-radius-md);
  padding: 10px 10px 12px;
  text-align: left;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 4px;
  transition: background 0.14s, border-color 0.14s, box-shadow 0.14s, transform 0.12s;
  box-shadow: var(--p209-card-shadow);
  min-height: 82px;
}
html[data-p209="v1"] .p209-product-card:hover {
  background: var(--p209-card-bg-hover);
  border-color: var(--p208-hairline-hi);
  transform: translateY(-1px);
}
html[data-p209="v1"] .p209-product-card.selected {
  background: linear-gradient(180deg, rgba(94,160,255,0.14), rgba(94,160,255,0.04));
  border-color: var(--p209-card-border-hi);
  box-shadow: 0 6px 20px -6px var(--p208-accent-glow), inset 0 0 0 1px rgba(94,160,255,0.25);
}
html[data-p209="v1"] .p209-product-card .p209-pc-title {
  font-weight: 600;
  font-size: 12.5px;
  letter-spacing: 0.1px;
  color: #eaf0fa;
  display: flex;
  align-items: center;
  gap: 6px;
}
html[data-p209="v1"] .p209-product-card .p209-pc-badge {
  font-size: 9.5px;
  padding: 1px 6px 2px;
  border-radius: 999px;
  background: rgba(94,160,255,0.18);
  color: var(--p208-accent-strong);
  border: 1px solid rgba(94,160,255,0.30);
  letter-spacing: 0.4px;
  text-transform: uppercase;
  font-weight: 700;
}
html[data-p209="v1"] .p209-product-card .p209-pc-desc {
  font-size: 11.5px;
  color: var(--text-secondary);
  line-height: 1.4;
}
html[data-p209="v1"] .p209-product-card .p209-pc-foot {
  margin-top: auto;
  font-size: 10.5px;
  color: var(--text-muted);
  letter-spacing: 0.2px;
}
html[data-p209="v1"] .p209-product-card .p209-pc-glyph {
  width: 40px; height: 40px;
  color: var(--p208-accent-strong);
  margin-bottom: 2px;
}
html[data-p209="v1"] .p209-product-card.selected .p209-pc-glyph { color: var(--p208-accent-strong); }
html[data-p209="v1"] .p209-product-card:focus-visible {
  outline: none;
  box-shadow: var(--p208-focus-ring);
}

html[data-p209="v1"] .p209-section-heading {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  color: var(--p208-accent-strong);
  margin: 14px 0 6px;
}
html[data-p209="v1"] .p209-section-heading::before {
  content: "";
  display: inline-block;
  width: 3px; height: 12px;
  background: var(--p208-accent);
  border-radius: 2px;
  box-shadow: 0 0 4px var(--p208-accent-glow);
}
html[data-p209="v1"] .p209-section-subhead {
  font-size: 11.5px;
  color: var(--text-secondary);
  margin-bottom: 8px;
  line-height: 1.45;
}

/* ----------- Step 3 feature groups ----------- */
html[data-p209="v1"] .p209-feature-group {
  margin-top: 10px;
  padding: 10px 12px;
  border: 1px solid var(--p208-hairline);
  border-radius: var(--p208-radius-md);
  background: rgba(255,255,255,0.015);
}
html[data-p209="v1"] .p209-feature-group:first-of-type { margin-top: 4px; }
html[data-p209="v1"] .p209-feature-group-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  color: var(--p208-accent-strong);
  margin-bottom: 6px;
}
html[data-p209="v1"] .p209-feature-group-title .p209-fg-hint {
  font-weight: 400;
  letter-spacing: 0.2px;
  text-transform: none;
  color: var(--text-muted);
  font-size: 10.5px;
  margin-left: 2px;
}
html[data-p209="v1"] .p209-feature-group-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 8px;
}
html[data-p209="v1"] .p209-feature-group-empty {
  font-size: 11px;
  color: var(--text-muted);
  font-style: italic;
}

/* ----------- Step 4 style cards (209.4 compact chip layout) ----------- */
html[data-p209="v1"] .p209-style-card-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin: 8px 0 12px;
}
html[data-p209="v1"] .p209-style-card {
  appearance: none;
  -webkit-appearance: none;
  background: var(--p209-card-bg);
  border: 1px solid var(--p209-card-border);
  color: #dde3ec;
  border-radius: var(--p208-radius-md);
  padding: 6px 8px;
  cursor: pointer;
  text-align: left;
  display: grid;
  grid-template-columns: 24px 1fr;
  column-gap: 8px;
  row-gap: 1px;
  align-items: center;
  transition: background 0.14s, border-color 0.14s, transform 0.1s;
  box-shadow: var(--p209-card-shadow);
}
html[data-p209="v1"] .p209-style-card:hover { transform: translateY(-1px); border-color: var(--p208-hairline-hi); }
html[data-p209="v1"] .p209-style-card.selected {
  background: linear-gradient(180deg, rgba(94,160,255,0.14), rgba(94,160,255,0.04));
  border-color: var(--p209-card-border-hi);
}
html[data-p209="v1"] .p209-style-card-preview {
  grid-row: 1 / span 2;
  grid-column: 1;
  width: 24px;
  height: 24px;
  border-radius: 4px;
  border: 1px solid var(--p209-boundary);
  overflow: hidden;
  align-self: center;
  flex: 0 0 auto;
}
html[data-p209="v1"] .p209-style-card-preview svg {
  display: block;
  width: 100%;
  height: 100%;
}
html[data-p209="v1"] .p209-style-card .pill-label,
html[data-p209="v1"] .p209-style-card-label {
  grid-column: 2;
  font-size: 12px;
  font-weight: 600;
  color: #eaf0fa;
}
html[data-p209="v1"] .p209-style-card .pill-desc,
html[data-p209="v1"] .p209-style-card-desc {
  grid-column: 2;
  font-size: 10.5px;
  color: var(--text-secondary);
  line-height: 1.3;
}
html[data-p209="v1"] .p209-style-card:focus-visible {
  outline: none;
  box-shadow: var(--p208-focus-ring);
}

/* ----------- Step 5 export receipt ----------- */
html[data-p209="v1"] .p209-receipt {
  margin: 14px 0 8px;
  background: var(--p209-receipt-bg);
  border: 1px solid var(--p208-hairline);
  border-radius: var(--p208-radius-lg);
  box-shadow: var(--p209-card-shadow);
  overflow: hidden;
}
html[data-p209="v1"] .p209-receipt-head {
  padding: 14px 16px 12px;
  background: var(--p209-receipt-head);
  border-bottom: 1px solid rgba(52,211,153,0.22);
  display: flex;
  align-items: center;
  gap: 10px;
}
html[data-p209="v1"] .p209-receipt-head.needs {
  background: linear-gradient(180deg, rgba(245,181,71,0.22), rgba(245,181,71,0.06));
  border-bottom-color: rgba(245,181,71,0.28);
}
html[data-p209="v1"] .p209-receipt-head.blocked {
  background: linear-gradient(180deg, rgba(239,107,107,0.22), rgba(239,107,107,0.06));
  border-bottom-color: rgba(239,107,107,0.30);
}
html[data-p209="v1"] .p209-receipt-badge {
  width: 34px; height: 34px;
  border-radius: 999px;
  background: rgba(52,211,153,0.20);
  color: var(--p208-good);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  font-weight: 700;
}
html[data-p209="v1"] .p209-receipt-head.needs .p209-receipt-badge { background: rgba(245,181,71,0.18); color: var(--p208-warn); }
html[data-p209="v1"] .p209-receipt-head.blocked .p209-receipt-badge { background: rgba(239,107,107,0.18); color: var(--p208-bad); }
html[data-p209="v1"] .p209-receipt-title {
  font-size: 16px;
  font-weight: 700;
  color: #eaf0fa;
  letter-spacing: 0.2px;
}
html[data-p209="v1"] .p209-receipt-sub {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 1px;
}
html[data-p209="v1"] .p209-receipt-body {
  padding: 12px 14px 14px;
}
html[data-p209="v1"] .p209-receipt-section {
  margin-top: 10px;
}
html[data-p209="v1"] .p209-receipt-section:first-child { margin-top: 0; }
html[data-p209="v1"] .p209-receipt-section-title {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.55px;
  text-transform: uppercase;
  color: var(--p208-accent-strong);
  margin-bottom: 6px;
}
html[data-p209="v1"] .p209-zip-include-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}
html[data-p209="v1"] .p209-zip-include-card {
  padding: 8px 10px;
  border-radius: var(--p208-radius-sm);
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--p208-hairline);
  font-size: 11.5px;
  color: #dde3ec;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
html[data-p209="v1"] .p209-zip-include-card .p209-zi-title {
  font-weight: 600;
  color: #eaf0fa;
  font-size: 12px;
  display: flex;
  align-items: center;
  gap: 5px;
}
html[data-p209="v1"] .p209-zip-include-card .p209-zi-desc {
  color: var(--text-secondary);
  font-size: 10.5px;
  line-height: 1.35;
}
html[data-p209="v1"] .p209-piece-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}
html[data-p209="v1"] .p209-piece-card {
  padding: 8px 10px 10px;
  border-radius: var(--p208-radius-md);
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--p208-hairline);
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 11.5px;
  color: #dde3ec;
}
html[data-p209="v1"] .p209-piece-card .p209-piece-head {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 600;
  color: #eaf0fa;
}
html[data-p209="v1"] .p209-piece-card .p209-piece-num {
  width: 20px; height: 20px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 10.5px;
  font-weight: 700;
  background: rgba(94,160,255,0.18);
  color: var(--p208-accent-strong);
  border: 1px solid rgba(94,160,255,0.30);
}
html[data-p209="v1"] .p209-piece-card .p209-piece-ops {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}
html[data-p209="v1"] .p209-piece-op {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.3px;
  text-transform: uppercase;
  padding: 1px 7px 2px;
  border-radius: 999px;
}
html[data-p209="v1"] .p209-piece-op.cut {
  background: rgba(239,107,107,0.14);
  color: #ff8f8f;
  border: 1px solid rgba(239,107,107,0.28);
}
html[data-p209="v1"] .p209-piece-op.engrave {
  background: rgba(94,160,255,0.14);
  color: var(--p208-accent-strong);
  border: 1px solid rgba(94,160,255,0.28);
}
html[data-p209="v1"] .p209-piece-op.score {
  background: rgba(245,181,71,0.14);
  color: #ffc97a;
  border: 1px solid rgba(245,181,71,0.28);
}
html[data-p209="v1"] .p209-edit-row {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 2px;
  font-size: 11.5px;
  color: var(--text-secondary);
  border-top: 1px dashed var(--p208-hairline);
}
html[data-p209="v1"] .p209-edit-row:first-child { border-top: none; }
html[data-p209="v1"] .p209-edit-row .p209-er-value { color: #dde3ec; font-weight: 500; }
html[data-p209="v1"] .p209-edit-row a {
  color: var(--p208-accent-strong);
  text-decoration: none;
  font-weight: 500;
}
html[data-p209="v1"] .p209-edit-row a:hover { text-decoration: underline; }
html[data-p209="v1"] .p209-receipt-validation {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: var(--p208-radius-sm);
  background: rgba(52,211,153,0.10);
  border: 1px solid rgba(52,211,153,0.28);
  color: #b2f7cf;
  font-size: 11.5px;
  font-weight: 500;
}
html[data-p209="v1"] .p209-receipt-validation.blocked {
  background: rgba(239,107,107,0.10);
  border-color: rgba(239,107,107,0.28);
  color: #ffc2c2;
}
html[data-p209="v1"] .p209-receipt-validation.needs {
  background: rgba(245,181,71,0.10);
  border-color: rgba(245,181,71,0.28);
  color: #ffd899;
}
html[data-p209="v1"] .p209-receipt-cta {
  margin-top: 12px;
  padding: 12px 14px;
  border-top: 1px solid var(--p208-hairline);
  background: rgba(0,0,0,0.20);
  display: grid;
  gap: 6px;
}

/* ----------- Phase 209.2: hide duplicated legacy controls ------------
 * The Phase 209 customer view surfaces:
 *   - Display-mode segmented control (Design Preview / Assembly /
 *     Linework Review — Phase 239 rename of "Cut Plot")
 *   - Customer-language feature groups (Linework / Areas / Labels / Other)
 * The legacy #previewModeRow dropdown and the original #featureGrid /
 * #featureGridSecondary chip lists are kept in the DOM so the state
 * and action dispatch (onPreviewModeChange, feature toggles) survive
 * unchanged — but they are visually hidden unless the operator opts
 * into the debug overlay, which re-shows the legacy chrome.  The
 * p209 feature group chips are click-forwarded to the canonical
 * hidden chips, so API payload keys never drift. */
html[data-p209="v1"]:not(.p209-debug-on) #previewModeRow { display: none !important; }
html[data-p209="v1"]:not(.p209-debug-on) #featureGrid { display: none !important; }
html[data-p209="v1"]:not(.p209-debug-on) #featureGridSecondary { display: none !important; }
html[data-p209="v1"]:not(.p209-debug-on) #featuresAdvancedToggle { display: none !important; }
/* When debug is ON, separate the legacy chrome from the p209 groups
 * visually so the duplication is obvious to the operator. */
html[data-p209="v1"].p209-debug-on #featureGrid,
html[data-p209="v1"].p209-debug-on #featureGridSecondary,
html[data-p209="v1"].p209-debug-on #previewModeRow {
  outline: 1px dashed rgba(245,181,71,0.45);
  outline-offset: 3px;
}

/* ----------- Phase 209.2 / Phase 239: Linework Review high-contrast read ---
 * In Design Preview the basswood paper dominates the stage (Phase
 * 208 repaint of `rect[data-role*="canvas"]`).  In Linework Review
 * that basswood covers the layer palette and muddies the
 * high-contrast review read — override it back to white so the
 * operator sees the layer linework on plain white paper.  The final
 * ZIP remains the only production-truth artifact; this view is for
 * visual review only.  Phase 239 renamed the customer-facing label
 * from "Cut Plot" to "Linework Review" to stop implying byte-level
 * production-vector fidelity.  The internal display-mode key
 * `cut_plot` is preserved for testid + state continuity. */
html[data-p209="v1"] #preview-panel[data-p209-display-mode="cut_plot"]
  .mte-pv-svg-host svg rect[data-role*="canvas"] {
  fill: #ffffff !important;
}
/* Linework Review drops the basswood paper shadow so the stage reads
 * plainer / more technical for visual review. */
html[data-p209="v1"] #preview-panel[data-p209-display-mode="cut_plot"]
  .mte-pv-svg-host svg {
  background: #ffffff !important;
  box-shadow:
    0 18px 40px -20px rgba(0,0,0,0.55),
    0 2px 4px rgba(0,0,0,0.35),
    0 0 0 1px #c7c7c7 !important;
}
/* Linework Review stage floor cools down to emphasize the review mood. */
html[data-p209="v1"] #preview-panel[data-p209-display-mode="cut_plot"]
  .preview-area {
  background-color: #0a0c12 !important;
}

/* ----------- Phase 209.3: lighter basswood paper tone ------------
 * User feedback: the Phase 208.1 basswood (`#ecd9a6` body + `#c9b074`
 * outer edge) reads too dark in customer mode.  Override the three
 * Phase 208 paper tokens inside the p209 scope so the Design Preview
 * paper reads like a fresh veneer sheet rather than an aged panel.
 * Phase 208 behavior is unchanged when p209 is not active. */
html[data-p209="v1"] {
  --p208-paper-hi:  #fff2cf;
  --p208-paper:     #f6e4b7;
  --p208-paper-lo:  #e2c086;
  --p208-paper-edge: #a58a4c;
  /* Mirror into a p209-specific token for the compositor plaque. */
  --p209-paper-plaque: #fbeec5;
  --p209-paper-deep:   #d6b982;
}
/* The plaque gradient and scale-bar chips read from the tokens above,
 * but the plaque is hand-tuned with a gradient; keep the deep tone
 * in lockstep with the new basswood. */
html[data-p209="v1"] .p209-dp-plaque {
  background: linear-gradient(180deg, var(--p209-paper-plaque), #eddaaa);
}
html[data-p209="v1"] .p209-dp-scale,
html[data-p209="v1"] .p209-dp-confidence {
  background: rgba(251,238,197,0.92);
}

/* ----------- Phase 209.3: single customer readiness surface ----------
 * Customer feedback: three "Ready" indicators in the top-right.
 * Sources:
 *   1) #statusText in the app header (global app ready state).
 *   2) #previewStatus legacy pill inside the preview header.
 *   3) #p209-customer-status pill (the Phase 209 customer surface).
 * The Phase 209 pill is the canonical customer readiness indicator;
 * hide (1) and (2) unless the operator flips into debug mode. Both
 * remain in the DOM so existing JS setters still write into them
 * without error. */
html[data-p209="v1"]:not(.p209-debug-on) #statusText,
html[data-p209="v1"]:not(.p209-debug-on) #previewStatus { display: none !important; }
html[data-p209="v1"].p209-debug-on #statusText,
html[data-p209="v1"].p209-debug-on #previewStatus {
  outline: 1px dashed rgba(245,181,71,0.40);
  outline-offset: 2px;
}

/* Phase 209.5 — the p209 export receipt supersedes the legacy Phase
 * 154 export-confidence card, Phase 152 export-summary card, and the
 * Settings Summary card. In customer view they duplicate the receipt
 * content and push the primary Export ZIP button below the sidebar
 * fold. Keep them in the DOM (#ecPreflight text transitions drive
 * the receipt header via MutationObserver) but hide them visually. */
html[data-p209="v1"]:not(.p209-debug-on) #exportConfidenceCard,
html[data-p209="v1"]:not(.p209-debug-on) #exportSummaryCard,
html[data-p209="v1"]:not(.p209-debug-on) .card:has(> .card-title + #summaryTable) {
  display: none !important;
}
html[data-p209="v1"].p209-debug-on #exportConfidenceCard,
html[data-p209="v1"].p209-debug-on #exportSummaryCard {
  outline: 1px dashed rgba(245,181,71,0.40);
  outline-offset: 2px;
}

/* Phase 209.5 — hide operator-only CTAs on Step 5. Linework Review is
 * reachable via the p209 display-mode segmented control (Phase 239
 * rename of "Cut Plot"); Refresh Preview is redundant because Phase
 * 180 auto-refreshes; Start Over is a rare destructive operator
 * action. Keeping only the primary Export ZIP makes the customer
 * CTA obvious. */
html[data-p209="v1"]:not(.p209-debug-on) #refreshPreviewBtn,
html[data-p209="v1"]:not(.p209-debug-on) #p209-export-secondary,
html[data-p209="v1"]:not(.p209-debug-on) .step-panel[data-step="5"] .export-actions .btn-danger-outline {
  display: none !important;
}

/* Phase 209.5 — stick the Export ZIP action to the bottom of the
 * Step 5 scroll container so the primary CTA is always visible,
 * regardless of how much the customer has scrolled through the
 * receipt. A gradient fade keeps content readable behind it. */
/* Phase 422A (Codex): the scroll content needs clearance >= the sticky
 * CTA's height so the last card (the glance) can scroll fully above it. */
html[data-p209="v1"]:not(.p209-debug-on) .step-panel[data-step="5"] { padding-bottom: 110px; }
html[data-p209="v1"]:not(.p209-debug-on) .step-panel[data-step="5"] .export-actions {
  position: sticky;
  bottom: -1px;
  background: linear-gradient(180deg, rgba(14,19,32,0) 0%, var(--bg-secondary) 22%);
  padding-top: 16px;
  padding-bottom: 4px;
  margin-top: 8px;
  z-index: 5;
}
