/* ════════════════════════════════════════════════════════════════
   Print HQ Studio — editor chrome (Studio Bazaar "dark studio")
   Loaded AFTER style.css; CONSUMES its token contract (dark default on
   :root, light on html[data-theme="light"]): --bg --panel --panel-2
   --line --text --dim --faint --blue --stage --lime --lime-ink
   --saffron --teal --ok --warn --danger --font-display:'Baloo 2'
   --font-ui:'Inter'. This file owns the editor + designer-flow chrome
   ONLY — shared components (modals, toasts, admin) stay in style.css.
   Reference: public/design/mockup/editor.html (+ editor.css) and
   public/design/penpot-preview/data/editor-dark.js.
   ════════════════════════════════════════════════════════════════ */

/* ── 0. Local chrome vars (theme-flipped; not part of the token contract) ── */
#editor,
#flow-screen {
  --ed-topbar-h: 56px;
  --ed-rail-w: 64px;
  --ed-shadow: 0 24px 70px rgba(0, 0, 0, 0.5);      /* floating pill / menu */
  --ed-shadow-soft: 0 10px 30px rgba(0, 0, 0, 0.4); /* artboard, popovers  */
}
html[data-theme="light"] #editor,
html[data-theme="light"] #flow-screen {
  --ed-shadow: 0 14px 44px rgba(25, 25, 10, 0.16);
  --ed-shadow-soft: 0 8px 26px rgba(25, 25, 10, 0.12);
}

/* ── 1. Top bar ──────────────────────────────────────────────────────────── */
#editor {
  position: relative;                    /* anchor for the floating ctx pill */
  display: flex; flex-direction: column;
  height: 100vh; height: 100dvh;
  background: var(--bg); color: var(--text);
}
#topbar {
  display: flex; justify-content: space-between; align-items: center;
  height: var(--ed-topbar-h); min-height: var(--ed-topbar-h);
  padding: 0 16px; gap: 14px; flex-shrink: 0;
  background: var(--panel); border-bottom: 1px solid var(--line);
}
#topbar h1 { font-size: 17px; white-space: nowrap; }

/* Brand lockup: real PrintHQ wordmark PNG (green on dark / blue on light)
   + "Studio" in the display face. Wordmark asset is ~3.7:1, height-set. */
#topbar .brand, .flow-header .brand, .boot-brand .brand {
  font-family: var(--font-display, 'Baloo 2'), sans-serif;
}
.brand-logo { height: 20px; width: auto; display: block; }
.brand-logo-dark { display: block; }
.brand-logo-light { display: none; }
html[data-theme="light"] .brand-logo-dark { display: none; }
html[data-theme="light"] .brand-logo-light { display: block; }
.brand-sub { color: var(--dim); font-weight: 500; }

.topbar-left, .topbar-right { display: flex; align-items: center; gap: 10px; min-width: 0; }
.topbar-right { flex-wrap: wrap; justify-content: flex-end; }

.product-label {
  font-size: 13px; font-weight: 600; color: var(--text);
  white-space: nowrap; max-width: 180px; overflow: hidden; text-overflow: ellipsis;
}
.dim-label { font-size: 12px; color: var(--faint); white-space: nowrap; }

/* Side tabs: pills — active = panel-2 bg + blue border/text (Penpot). */
.side-tabs { display: flex; gap: 4px; }
.side-tab {
  padding: 5px 14px; min-height: 30px; font-size: 12px; font-weight: 500;
  border: 1px solid var(--line); background: var(--panel); color: var(--dim);
  border-radius: 8px; line-height: 1.2;
}
.side-tab:hover { background: var(--panel-2); color: var(--text); border-color: var(--line); }
.side-tab.active {
  background: var(--panel-2); color: var(--blue);
  border-color: var(--blue); font-weight: 600;
}

/* Icon buttons in the chrome */
#topbar .btn-icon, .panel-close {
  width: 34px; min-width: 34px; height: 34px; min-height: 34px; padding: 0;
  background: transparent; border-color: transparent; color: var(--dim);
  border-radius: 9px;
}
#topbar .btn-icon:hover, .panel-close:hover {
  background: var(--panel-2); border-color: transparent; color: var(--text);
}

/* Lime "Save & preview" pill — the one action color. */
#btn-save {
  background: var(--lime); color: var(--lime-ink); border-color: var(--lime);
  border-radius: 999px; font-weight: 700; padding: 8px 16px;
  box-shadow: 0 6px 18px color-mix(in srgb, var(--lime) 28%, transparent);
}
#btn-save:hover, #btn-save:active {
  background: var(--lime); color: var(--lime-ink); border-color: var(--lime);
  filter: brightness(1.05); transform: translateY(1px);
}

/* Overflow menu */
.menu-wrap { position: relative; display: inline-flex; }
.menu {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 100;
  display: flex; flex-direction: column; gap: 2px; min-width: 190px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
  box-shadow: var(--ed-shadow); padding: 6px;
}
.menu-item { justify-content: flex-start; width: 100%; border: none; background: none; color: var(--text); }
.menu-item:hover { background: var(--panel-2); color: var(--text); }

/* Theme toggle (wired by /js/theme.js via [data-theme-toggle]) */
.mode-btn {
  display: inline-flex; align-items: center; gap: 7px;
  background: var(--panel-2); border: 1px solid var(--line); color: var(--text);
  font-size: 11.5px; font-weight: 600; padding: 6px 12px; border-radius: 999px;
  min-height: 32px; line-height: 1;
}
.mode-btn:hover { background: var(--panel-2); border-color: var(--dim); color: var(--text); }
.mode-dot {
  width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0;
  background: var(--lime);
}

/* ── 2. Left tool rail (64px) + flyout panel ─────────────────────────────── */
#main { flex: 1; min-height: 0; display: flex; overflow: hidden; }
#toolpanel {
  display: flex; flex-direction: row; flex-shrink: 0; overflow: hidden;
  background: var(--panel); border-right: 1px solid var(--line);
}
#tool-tabs {
  display: flex; flex-direction: column; gap: 2px;
  width: var(--ed-rail-w); min-width: var(--ed-rail-w); flex-shrink: 0;
  padding: 10px 0; overflow-y: auto; border-right: none;
  background: var(--panel);
}
.tool-tab {
  width: 52px; min-height: 50px; margin: 0 auto; padding: 8px 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3px; border: 1px solid transparent; border-radius: 11px;
  background: transparent; color: var(--dim);
  font-size: 9px; font-weight: 600; letter-spacing: 0.02em; line-height: 1;
}
.tool-tab .icon { width: 17px; height: 17px; }
.tool-tab:hover { background: var(--panel-2); color: var(--text); }
.tool-tab.active {
  background: color-mix(in srgb, var(--blue) 14%, var(--panel-2));
  border-color: color-mix(in srgb, var(--blue) 55%, var(--line));
  color: var(--blue);
}

#panel-container {
  position: relative; width: 300px; overflow-y: auto; flex-shrink: 0;
  background: var(--panel); padding: 12px;
}
#toolpanel.collapsed #panel-container { display: none; }
.panel-close { position: absolute; top: 8px; right: 8px; z-index: 2; }
.panel { display: none; }
.panel.active { display: block; }
.panel h3 { font-size: 14px; margin-bottom: 10px; color: var(--text); }
.panel h4 { font-size: 12px; margin: 8px 0 4px; color: var(--dim); }
.panel .empty-msg { color: var(--dim); }

.panel select, .panel input[type="text"], .panel input[type="number"] {
  background: var(--panel-2); border: 1px solid var(--line); color: var(--text);
}
#clipart-category { width: 100%; margin-bottom: 4px; }

/* Text presets */
.text-preset { justify-content: flex-start; background: var(--panel-2); border-color: var(--line); color: var(--text); }
.text-preset:hover { background: var(--panel-2); border-color: var(--blue); color: var(--text); }
.preset-heading { font-size: 18px; font-weight: 700; }
.preset-subheading { font-size: 14px; font-weight: 600; }
.preset-body { font-size: 13px; font-weight: 400; }

/* Effect grid + samples */
.panel-subhead {
  font-size: 11px; font-weight: 600; color: var(--dim);
  text-transform: uppercase; letter-spacing: 0.05em;
  margin: 16px 0 8px; padding-top: 12px; border-top: 1px solid var(--line);
}
.effect-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.effect-btn {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 8px 4px 6px; min-height: 44px;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 9px;
  color: var(--text);
}
.effect-btn:hover { border-color: var(--blue); background: var(--panel-2); color: var(--text); }
.effect-btn.active {
  border-color: var(--blue);
  background: color-mix(in srgb, var(--blue) 14%, var(--panel-2));
}
.effect-btn .effect-name { font-size: 10.5px; color: var(--dim); }
.effect-btn.active .effect-name { color: var(--blue); font-weight: 600; }
.effect-sample { font-size: 18px; font-weight: 700; line-height: 1.2; color: var(--text); }
.fx-shadow { text-shadow: 2px 2px 2px rgba(0, 0, 0, 0.55); }
.fx-lift { text-shadow: 0 3px 6px rgba(0, 0, 0, 0.45); }
.fx-hollow { color: transparent; -webkit-text-stroke: 1.2px var(--text); }
.fx-splice { color: transparent; -webkit-text-stroke: 1px var(--text); text-shadow: 3px 3px 0 var(--line); }
.fx-neon { color: #EC4899; text-shadow: 0 0 6px rgba(236, 72, 153, 0.9); }
.fx-background { background: var(--lime); color: var(--lime-ink); border-radius: 2px; padding: 0 4px; }
.fx-curve { display: inline-block; transform: rotate(-8deg) translateY(-1px); }
.effect-field { margin-top: 12px; margin-bottom: 0; }
.effect-field input[type="range"] { width: 100%; }
.effect-color-field input[type="color"] { width: 44px; height: 32px; padding: 1px; }
#text-letterspacing { width: 62px; }

/* Upload + asset grids (clipart, templates) */
.upload-label { cursor: pointer; }
.asset-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-top: 8px; }
.asset-grid .asset-item {
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 9px;
  padding: 6px; cursor: pointer; text-align: center;
  transition: border-color .15s, transform .15s;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  min-height: 60px; color: var(--dim);
  /* A tile is a native <button> (audit finding 25), so it must not fall
     back to the user agent's button font. */
  font: inherit;
}
.asset-item:hover { border-color: var(--blue); transform: scale(1.04); color: var(--text); }
.asset-item img { max-width: 100%; max-height: 48px; }
.asset-item span {
  font-size: 10px; color: var(--dim); margin-top: 3px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; width: 100%;
}
.tpl-card .tpl-thumb {
  max-width: 100%; max-height: 72px; width: auto; border-radius: 2px;
  background: var(--panel-2);
}

/* Shape buttons */
.shape-buttons { display: flex; gap: 6px; flex-wrap: wrap; }
.shape-buttons button {
  width: 48px; height: 48px; padding: 0;
  background: var(--panel-2); border: 1px solid var(--line); color: var(--dim);
  border-radius: 9px;
}
.shape-buttons button:hover { background: var(--panel-2); border-color: var(--blue); color: var(--text); }

/* Layers list */
#layers-list { max-height: 300px; overflow-y: auto; }
.layer-item {
  display: flex; align-items: center; gap: 6px; padding: 8px; min-height: 40px;
  cursor: pointer; border: 1px solid transparent; border-radius: 9px;
  font-size: 12px; color: var(--dim); transition: background .1s, border-color .1s;
}
.layer-item:hover { background: var(--panel-2); }
.layer-item.selected {
  border-color: color-mix(in srgb, var(--blue) 45%, var(--line));
  background: color-mix(in srgb, var(--blue) 12%, var(--panel-2));
  color: var(--text);
}
.layer-item .layer-icon { width: 20px; text-align: center; }
.layer-item .layer-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.layer-item .layer-lock { flex-shrink: 0; opacity: .6; }
/* A hidden layer stays in the list — it still exists, it just prints nothing. */
.layer-item.is-hidden .layer-name { opacity: .45; text-decoration: line-through; }
/* Row actions: show/hide + the customer's own lock. */
.layer-item .layer-action {
  flex-shrink: 0; display: inline-flex; align-items: center; justify-content: center;
  width: 26px; height: 26px; min-height: 26px; padding: 0;
  border: 1px solid transparent;
  background: transparent; color: var(--dim); border-radius: 7px; cursor: pointer;
}
.layer-item .layer-action:hover { background: var(--panel-2); color: var(--text); }
.layer-item .layer-action[aria-pressed="true"] { color: var(--text); }
.layer-item .layer-action[data-action="user-lock"][aria-pressed="true"] {
  color: var(--blue); border-color: color-mix(in srgb, var(--blue) 45%, var(--line));
}
/* Inline rename (double-click a layer name). */
.layer-item .layer-rename {
  flex: 1; min-width: 0; padding: 2px 6px; font-size: 12px;
  background: var(--panel); border: 1px solid var(--blue); color: var(--text);
  border-radius: 6px;
}
/* The row's select control (public/js/editor-layers-a11y.js): a real button
 * so the layer can be picked with the keyboard. */
.layer-item .layer-select {
  display: flex; align-items: center; gap: 6px; flex: 1; min-width: 0;
  padding: 0; border: none; background: none; color: inherit; font: inherit;
  text-align: left; cursor: pointer; border-radius: 6px;
}
.layer-item .layer-select .layer-name { flex: 1; min-width: 0; }

/* Arrange: align + distribute the current selection (plan A4). */
.align-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; }
.align-grid .btn-sm {
  width: 100%; display: inline-flex; align-items: center; justify-content: center;
}

/* ── 3. Canvas stage ─────────────────────────────────────────────────────── */
#canvas-wrapper {
  flex: 1; min-width: 0; position: relative;
  display: flex; flex-direction: column; overflow: hidden;
  background: radial-gradient(circle at 50% 42%,
    color-mix(in srgb, var(--panel-2) 70%, transparent) 0%, var(--stage) 75%);
}
#canvas-scroll { flex: 1; min-height: 0; overflow: auto; display: flex; padding: 20px; }
#canvas-container {
  position: relative; margin: auto; flex-shrink: 0;
  box-shadow: var(--ed-shadow-soft); border-radius: 2px;
}

/* ── 4. Context toolbar — floating pill (desktop) / pinned strip (≤640) ──── */
#context-bar {
  display: flex; align-items: center; gap: 8px; min-height: 48px;
  padding: 6px 12px; background: var(--panel);
  border: 1px solid var(--line); border-radius: 12px;
  overflow-x: auto; white-space: nowrap; z-index: 40;
  -webkit-overflow-scrolling: touch;
  box-shadow: var(--ed-shadow);
}
@media (min-width: 641px) {
  #context-bar {
    position: absolute; top: calc(var(--ed-topbar-h) + 10px);
    /* Centred over the CANVAS, not over the whole editor: the pill is up to
       980 px wide, and centred on the editor it covered the top of the left
       tool panel — with a text selected, the panel's first button ("Add a
       heading") was unclickable. */
    left: calc(50% + (var(--ed-rail-w) + var(--panel-width)) / 2);
    transform: translateX(-50%);
    max-width: min(calc(100% - 32px - var(--ed-rail-w) - var(--panel-width)), 980px);
  }
}
.ctx-group { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.ctx-sep { width: 1px; height: 20px; background: var(--line); flex-shrink: 0; margin: 0 2px; }
.ctx-field {
  display: flex; flex-direction: column; align-items: flex-start; gap: 1px;
  font-size: 10px; font-weight: 600; color: var(--dim);
  text-transform: uppercase; letter-spacing: 0.03em; flex-shrink: 0;
}
#context-bar select, #context-bar input[type="number"] {
  width: auto; padding: 5px 8px; font-size: 13px; min-height: 32px;
  background: var(--panel-2); border: 1px solid var(--line); color: var(--text);
  border-radius: 8px;
}
#text-font-family { max-width: 150px; }
#text-font-size, #shape-stroke-width, #text-lineheight { width: 62px; }
#context-bar input[type="range"] { width: 88px; accent-color: var(--blue); }
#context-bar input[type="color"] {
  width: 32px; height: 28px; padding: 1px;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 6px;
}
#context-bar .btn-icon {
  flex-shrink: 0; width: 30px; min-width: 30px; height: 30px; min-height: 30px;
  padding: 0; background: transparent; border-color: transparent; color: var(--dim);
}
#context-bar .btn-icon:hover { background: var(--panel-2); color: var(--text); }
#context-bar .btn-sm {
  flex-shrink: 0; background: var(--panel-2); border-color: var(--line); color: var(--text);
}
#context-bar .btn-sm:hover { background: var(--panel-2); border-color: var(--dim); color: var(--text); }
.ctx-lock-group .btn-sm { display: inline-flex; align-items: center; gap: 4px; }
.ctx-lock-group .btn-sm[aria-pressed="true"] {
  background: var(--blue); border-color: var(--blue); color: var(--on-blue);
}
/* Pressed state for the editor's own toggles: the text-style buttons
   (bold/italic/underline/strikethrough + the three alignments) and the
   image-filter buttons both show the SELECTED object's current state. */
#context-bar .btn-icon[aria-pressed="true"],
#image-props .btn-sm[aria-pressed="true"] {
  background: color-mix(in srgb, var(--blue) 16%, transparent);
  border-color: color-mix(in srgb, var(--blue) 40%, transparent);
  color: var(--text);
}
/* Shrink-to-fit ("Fit", text props) behaves like the style toggles: pressed
   while the selected text shrinks to its box. */
#text-props .btn-sm[aria-pressed="true"] {
  background: color-mix(in srgb, var(--blue) 16%, transparent);
  border-color: color-mix(in srgb, var(--blue) 40%, transparent);
  color: var(--text);
}
/* "Cannot fit" — the text does not fit its box even at the 6 pt print
   minimum. Amber, not red: the size left behind still meets the print
   floor (the tiny-text check stays quiet); it is the FIT that failed. */
#text-props .btn-sm.shrink-overflow {
  background: var(--warn-bg);
  border-color: var(--warn-border);
  color: var(--text);
}

/* ── 5. Guide legend strip (under the canvas) + zoom cluster ─────────────── */
#legend-strip {
  display: flex; align-items: center; gap: 16px; flex-shrink: 0;
  min-height: 36px; padding: 0 16px;
  background: var(--panel); border-top: 1px solid var(--line);
  font-size: 11.5px; color: var(--dim);
}
#print-legend {
  position: relative; flex: 1; min-width: 0;
  top: auto; right: auto; bottom: auto; left: auto;   /* was a floating chip */
  display: flex; align-items: center; gap: 12px;
  font-size: 11.5px; max-width: none;
}
.legend-items { display: flex; align-items: center; gap: 18px; overflow-x: auto; scrollbar-width: none; }
.legend-items::-webkit-scrollbar { display: none; }
#print-legend .legend-item {
  display: flex; align-items: center; gap: 7px; white-space: nowrap;
  background: transparent; color: var(--dim); padding: 0; border-radius: 0;
}
#print-legend .legend-swatch {
  display: inline-block; width: 18px; height: 10px; flex-shrink: 0;
  border-top: 2px solid; border-radius: 3px;
  background: var(--guide-surface);
}
/* Swatches must never disagree with the canvas guides designer.js draws —
   always read the --guide-* tokens (style.css :root, identical in both modes).
   The chip sits on paper (--guide-surface, the artboard's default white) so
   the trim line is legible on the dark strip AND identical to the canvas. */
#print-legend .swatch-bleed { border-top-color: var(--guide-bleed); }
#print-legend .swatch-trim  { border-top-style: solid; border-top-color: var(--guide-trim); }
#print-legend .swatch-safe  { border-top-style: dashed; border-top-color: var(--guide-safe); }
.legend-info {
  order: 0; flex-shrink: 0;
  width: 26px; min-width: 26px; height: 26px; min-height: 26px; padding: 0;
  border-radius: 8px; background: transparent; border-color: transparent; color: var(--dim);
}
.legend-info:hover { background: var(--panel-2); border-color: transparent; color: var(--text); }
.legend-pop {
  position: absolute; left: 0; bottom: calc(100% + 10px); width: 264px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px;
  box-shadow: var(--ed-shadow-soft); padding: 10px 14px;
  font-size: 12px; color: var(--dim); white-space: normal; z-index: 45;
}

/* Zoom cluster — restyled INLINE inside the strip (ids unchanged). */
.zoom-cluster {
  position: static; margin-left: auto; flex-shrink: 0;
  display: flex; align-items: center; gap: 2px;
  background: transparent; border-radius: 0; box-shadow: none; padding: 0;
}
.zoom-cluster .btn-icon {
  width: 26px; min-width: 26px; height: 26px; min-height: 26px; padding: 0;
  background: transparent; border: none; color: var(--dim); border-radius: 7px;
  font-size: 14px;
}
.zoom-cluster .btn-icon:hover { background: var(--panel-2); color: var(--text); }
#zoom-level {
  min-width: 44px; text-align: center; margin: 0 2px;
  font-size: 11.5px; font-weight: 600; color: var(--text);
  font-variant-numeric: tabular-nums;
}

/* ── 6. Print check — per-side cards strip ───────────────────────────────── */
#print-check {
  position: static; left: auto; right: auto; bottom: auto; transform: none;
  display: flex; align-items: stretch; gap: 12px;
  width: auto; max-width: none; overflow-x: auto;
  padding: 8px 14px; flex-shrink: 0;
  background: var(--panel); border: none; border-top: 1px solid var(--line);
  border-radius: 0; box-shadow: none;
  font-size: 12px; color: var(--text);
}
#print-check.expanded { width: auto; max-width: none; max-height: 38vh; overflow-y: auto; }
/* The panel's live region (audit finding 27): the summary line is announced
   to screen readers from here, not from the panel itself — so patching the
   panel never re-announces every message on every side. Visually hidden: the
   panel already shows the same words on screen. */
#print-check-status {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
/* Header = worst-status dot + "Print check · n to check" + expander. */
#print-check .pc-header {
  display: flex; align-items: center; gap: 8px; flex: none; align-self: center;
  font-weight: 600; font-size: 12px; color: var(--dim); white-space: nowrap;
  border: 1px solid var(--line); background: transparent; border-radius: 9px;
  padding: 8px 12px; min-height: 0; width: auto; text-align: left; cursor: pointer;
}
#print-check .pc-header:hover { background: var(--panel-2); color: var(--text); }
.pc-count { color: var(--faint); font-weight: 500; }
.pc-chevron { display: block; margin-left: auto; transition: transform .15s; transform: rotate(180deg); }
#print-check.expanded .pc-chevron { transform: none; }

.pc-card {
  flex: 1; min-width: 210px;
  display: flex; flex-direction: column; gap: 2px;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 12px;
  padding: 8px 12px;
}
.pc-card:has(.pc-dot.pc-red)   { border-color: color-mix(in srgb, var(--danger) 45%, var(--line)); }
.pc-card:has(.pc-dot.pc-amber) { border-color: color-mix(in srgb, var(--warn) 45%, var(--line)); }
.pc-side { display: flex; align-items: center; gap: 8px; margin: 0; }
.pc-side-name { font-weight: 600; color: var(--text); white-space: nowrap; }
.pc-side-summary { color: var(--dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pc-side-summary::before { content: "·\00a0"; color: var(--faint); }
/* The panel says WHAT is wrong: the per-side messages stay visible without
   expanding it (the phone sheet keeps its own collapsed pill — see the
   ≤640px block below, where the whole card is hidden until it is opened). */
#print-check:not(.expanded) .pc-items { display: flex; }
.pc-card .pc-items { max-height: 132px; overflow-y: auto; }
.pc-items { list-style: none; margin: 4px 0 0 0; display: flex; flex-direction: column; gap: 3px; }
.pc-items li { padding: 4px 8px; border-radius: 7px; font-size: 11.5px; }
.pc-items li.pc-item-red {
  background: color-mix(in srgb, var(--danger) 12%, transparent);
  border: 1px solid color-mix(in srgb, var(--danger) 40%, transparent);
  color: var(--danger);
}
.pc-items li.pc-item-amber {
  background: color-mix(in srgb, var(--warn) 12%, transparent);
  border: 1px solid color-mix(in srgb, var(--warn) 40%, transparent);
  color: var(--warn);
}
.pc-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; background: var(--faint); }
.pc-dot.pc-green { background: var(--ok); }
.pc-dot.pc-amber { background: var(--warn); }
.pc-dot.pc-red   { background: var(--danger); }

/* The proof-approval modal reuses the card markup — neutralize chrome there. */
#proof-print-check .pc-card {
  background: none; border: none; border-radius: 0; padding: 0; min-width: 0;
  flex: none; box-shadow: none;
}
#proof-print-check .pc-items { margin-left: 18px; font-size: 12px; }

/* ── 7. DPI badge ────────────────────────────────────────────────────────── */
#dpi-badge {
  position: absolute; z-index: 20; pointer-events: none;
  font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 999px;
  color: var(--on-status); white-space: nowrap; box-shadow: var(--ed-shadow-soft);
}
#dpi-badge.dpi-green { background: var(--ok); color: var(--on-status); }
#dpi-badge.dpi-amber { background: var(--warn); color: var(--on-status); }
#dpi-badge.dpi-red   { background: var(--danger); color: var(--on-status); }

/* ── 8. Designer flow screens (product picker / options) ─────────────────── */
#flow-screen {
  min-height: 100vh; min-height: 100dvh;
  display: flex; align-items: flex-start; justify-content: center;
  padding: 32px 24px;
  background: var(--bg); color: var(--text);
}
.flow-step { max-width: 860px; width: 100%; text-align: center; }
.flow-header {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  margin-bottom: 24px;
}
.flow-header-end { justify-content: flex-end; }
.flow-step h1 { font-size: 28px; margin-bottom: 6px; }
.flow-hero {
  font-family: var(--font-display, 'Baloo 2'), sans-serif;
  font-weight: 700; font-size: 36px !important; letter-spacing: -0.01em; color: var(--text);
}
.flow-step h2 { font-size: 28px; margin-bottom: 4px; color: var(--text); }
#flow-options h2 { font-family: var(--font-display, 'Baloo 2'), sans-serif; }
.flow-step .stepper { margin-bottom: 24px; }
.flow-sub { color: var(--dim); font-size: 14px; margin-bottom: 20px; }

/* Stepper */
.stepper { display: flex; align-items: center; justify-content: center; gap: 8px; font-size: 12px; color: var(--faint); }
.stepper .step { display: inline-flex; align-items: center; gap: 6px; }
.stepper .step-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--line); flex-shrink: 0; }
.stepper .step.current { color: var(--blue); font-weight: 600; }
.stepper .step.current .step-dot { background: var(--blue); box-shadow: 0 0 0 3px color-mix(in srgb, var(--blue) 22%, transparent); }
.stepper .step.done { color: var(--ok); }
.stepper .step.done .step-dot { background: var(--ok); }
.stepper .step-line { width: 24px; height: 1px; background: var(--line); }

/* Product cards */
.product-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; }
.product-card {
  display: flex; flex-direction: column; align-items: flex-start; gap: 4px;
  min-height: 132px; padding: 16px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 14px;
  cursor: pointer; text-align: left; color: var(--text);
  transition: box-shadow .15s, transform .15s, border-color .15s;
}
.product-card:hover {
  background: var(--panel-2); border-color: var(--blue); transform: translateY(-2px);
}
.product-card-icon { color: var(--blue); margin-bottom: 2px; }
.product-card-name { font-size: 16px; font-weight: 600; color: var(--text); }
.product-card-size, .product-card-info { font-size: 13px; color: var(--dim); }
.product-card-info { font-size: 12px; }
.product-card-price {
  font-size: 13px; color: var(--blue); font-weight: 600;
  margin-top: auto; padding-top: 2px;
}
.reassurance-strip {
  display: flex; align-items: center; justify-content: center; gap: 6px; flex-wrap: wrap;
  margin-top: 32px; font-size: 13px; color: var(--dim);
}
.reassurance-strip .icon { color: var(--ok); }

/* Options step */
#flow-options { max-width: 440px; text-align: left; }
#flow-options .stepper { justify-content: flex-start; }
#options-trim { margin-bottom: 16px; }
.btn-back { background: transparent; border-color: transparent; color: var(--dim); margin: 0 0 14px -8px; }
.btn-back:hover { background: var(--panel-2); border-color: transparent; color: var(--text); }
.well.options-well {
  background: var(--panel-2); border: 1px solid var(--line);
  text-align: left; margin-bottom: 20px; padding: 12px 16px; border-radius: 12px;
}
.options-well-title { display: block; font-size: 12px; font-weight: 600; color: var(--text); margin-bottom: 2px; }
.spec-summary { font-size: 13px; color: var(--dim); margin: 0; }
.options-group { border: none; padding: 0; margin-bottom: 20px; text-align: left; }
.options-group legend { font-size: 12px; font-weight: 600; color: var(--dim); padding: 0; margin-bottom: 6px; }

.segmented {
  display: inline-flex; gap: 3px; padding: 3px;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 999px;
}
.segmented label, .segmented .segment {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px 16px; min-height: 38px; border-radius: 999px;
  font-size: 14px; color: var(--dim); cursor: pointer;
  transition: background .15s, color .15s, box-shadow .15s;
}
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented label:has(input:checked), .segmented .segment.active {
  background: var(--panel); box-shadow: inset 0 0 0 1px var(--blue);
  color: var(--blue); font-weight: 600;
}
.segmented label:has(input:focus-visible) { box-shadow: var(--focus-ring, 0 0 0 3px color-mix(in srgb, var(--blue) 25%, transparent)); }
.segmented-full { display: flex; width: 100%; }
.segmented-full label { flex: 1; min-height: 48px; font-size: 14px; text-align: center; }

/* Quantity tiers — active row = panel-2 bg + blue border (Penpot pattern). */
.qty-grid {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 12px; overflow: hidden;
}
.qty-row {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; min-height: 44px; cursor: pointer;
  border-bottom: 1px solid var(--line); border-left: 2px solid transparent;
  font-size: 14px; color: var(--text); transition: background .15s, border-color .15s;
}
.qty-row:last-child { border-bottom: none; }
.qty-row:hover { background: var(--panel-2); }
.qty-row:has(input:checked) {
  background: var(--panel-2);
  border-left-color: var(--blue);
  box-shadow: inset 0 0 0 1px var(--blue);
}
.qty-row:has(input:focus-visible) { box-shadow: inset var(--focus-ring, 0 0 0 3px color-mix(in srgb, var(--blue) 25%, transparent)); }
.qty-row input[type="radio"] { width: 16px; height: 16px; flex-shrink: 0; margin: 0; accent-color: var(--blue); }
.qty-count { font-weight: 600; min-width: 76px; font-variant-numeric: tabular-nums; }
.qty-unit { font-size: 13px; color: var(--dim); font-variant-numeric: tabular-nums; }
.qty-total { margin-left: auto; font-weight: 600; color: var(--blue); font-variant-numeric: tabular-nums; }
.qty-note { font-size: 12px; color: var(--faint); margin-top: 6px; }
.price-request {
  display: flex; align-items: center; gap: 8px;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 12px;
  padding: 12px 16px; margin-bottom: 20px;
  font-size: 13px; color: var(--dim); text-align: left;
}
.price-request .icon { color: var(--blue); flex-shrink: 0; }
.options-cta { margin-top: 8px; }
.btn-start {
  width: 100%; padding: 12px 24px; min-height: 48px; font-size: 16px;
  background: var(--lime); border-color: var(--lime); color: var(--lime-ink);
  border-radius: 999px; font-weight: 700;
  box-shadow: 0 6px 18px color-mix(in srgb, var(--lime) 28%, transparent);
}
.btn-start:hover, .btn-start:active {
  background: var(--lime); border-color: var(--lime); color: var(--lime-ink);
  filter: brightness(1.05);
}
.options-footnote { font-size: 12px; color: var(--faint); margin-top: 12px; text-align: center; }

/* Boot screen rides the same surface */
#boot { background: var(--bg); color: var(--text); }
#boot .sk { background: linear-gradient(90deg, var(--panel-2) 25%, var(--line) 50%, var(--panel-2) 75%); background-size: 200% 100%; }
.boot-status { color: var(--faint); }
#boot-error p { color: var(--dim); }

/* ── 9. Mobile ≤640px — re-theme the existing arrangement, no restructuring ─ */
@media (max-width: 640px) {
  /* Top bar: compact (style.css hides brand text + dim label; colors here). */
  #topbar { height: auto; min-height: 48px; padding: 4px 10px; gap: 4px 8px; align-items: flex-start; }
  #topbar .topbar-left { flex: 1 1 auto; min-width: 0; flex-wrap: wrap; gap: 4px 8px; }
  #topbar .topbar-right { flex-shrink: 0; flex-wrap: nowrap; margin-left: auto; gap: 6px; }
  #topbar .brand-logo { height: 16px; }
  .mode-btn { padding: 6px 8px; min-height: 36px; }
  #topbar .mode-btn [data-theme-label] { display: none; } /* dot-only in the compact bar */
  #btn-save { padding: 8px 12px; }

  /* Undo / redo: floating round buttons over the canvas (thumb zone). */
  #btn-undo, #btn-redo {
    position: fixed; z-index: 32;
    bottom: calc(174px + env(safe-area-inset-bottom));
    width: 42px; min-width: 42px; height: 42px; min-height: 42px; padding: 0;
    border-radius: 50%; border: 1px solid var(--line);
    background: var(--panel); color: var(--text); box-shadow: var(--ed-shadow-soft);
  }
  #btn-undo { left: 10px; }
  #btn-redo { left: 60px; }

  /* Tool tabs → fixed bottom toolbar (same nodes). */
  #toolpanel { position: static; width: 0; min-width: 0; border: none; overflow: visible; background: transparent; }
  #tool-tabs {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
    flex-direction: row; width: auto; min-width: 0; justify-content: space-around;
    padding: 4px 2px calc(4px + env(safe-area-inset-bottom));
    border-right: none; border-top: 1px solid var(--line); background: var(--panel);
    overflow: visible;
  }
  .tool-tab { flex: 1; width: auto; min-width: 0; min-height: 48px; margin: 0; border-radius: 9px; }
  .tool-tab-label { font-size: 10px; }

  /* Flyout panel → bottom sheet above the toolbar. */
  #panel-container {
    position: fixed; left: 0; right: 0;
    bottom: calc(56px + env(safe-area-inset-bottom)); z-index: 90;
    width: auto; max-height: 45vh; max-height: 45dvh; overflow-y: auto;
    background: var(--panel); border-top: 1px solid var(--line);
    border-radius: 16px 16px 0 0; box-shadow: 0 -8px 28px rgba(0, 0, 0, 0.45);
    padding: 20px 16px 16px;
  }
  #panel-container::before {
    content: ""; display: block; width: 36px; height: 4px; border-radius: 2px;
    background: var(--line); margin: -10px auto 10px;
  }

  /* Context bar: scrollable strip pinned ABOVE the toolbar (unchanged shape). */
  #context-bar {
    position: fixed; left: 0; right: 0; bottom: calc(56px + env(safe-area-inset-bottom));
    top: auto; transform: none; max-width: none;
    z-index: 91; border-radius: 0; border-left: none; border-right: none;
    border-top: 1px solid var(--line); border-bottom: none;
    box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.35); min-height: 52px;
    background: var(--panel);
  }

  /* Room for the fixed bottom toolbar under the canvas well. */
  #main { padding-bottom: calc(56px + env(safe-area-inset-bottom)); }
  #canvas-scroll { padding: 12px; }

  /* Legend strip: measurements hide, ⓘ + zoom stay reachable. */
  #legend-strip { gap: 8px; padding: 0 8px; min-height: 40px; }
  .legend-items { display: none; }
  #print-legend { flex: none; }
  .legend-pop { width: min(280px, calc(100vw - 24px)); }
  .zoom-cluster .btn-icon { width: 34px; min-width: 34px; height: 34px; min-height: 34px; }

  /* Print check: collapsed pill over the canvas; expanding reveals the cards. */
  #print-check {
    position: absolute; left: 8px; right: 8px; bottom: calc(48px + 8px);
    display: block; width: auto; max-width: none; overflow: visible;
    background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
    box-shadow: var(--ed-shadow-soft); padding: 6px 10px;
    z-index: 33;
  }
  #print-check .pc-header { width: 100%; min-height: 44px; padding: 4px 6px; border: none; }
  #print-check:not(.expanded) .pc-card { display: none; }
  #print-check.expanded {
    display: flex; flex-direction: column; gap: 8px;
    max-height: 55vh; max-height: 55dvh; overflow-y: auto;
    border-radius: 14px; z-index: 33;
  }
  #print-check.expanded .pc-header { width: auto; align-self: flex-start; }
  .pc-card { min-width: 0; }

  /* Flow screens at phone width */
  #flow-screen { padding: 20px 16px 32px; }
  .flow-hero { font-size: 28px !important; }
  .flow-header { margin-bottom: 16px; }
  .product-cards { grid-template-columns: repeat(2, minmax(150px, 1fr)); }
  /* Sticky options CTA stays reachable above the safe area. */
  .options-cta {
    position: sticky; bottom: 0; z-index: 30;
    padding: 12px 0 calc(8px + env(safe-area-inset-bottom));
    background: linear-gradient(to top, var(--bg) 70%, transparent);
  }
}

/* ── 10. Small polish ────────────────────────────────────────────────────── */
#editor ::-webkit-scrollbar { width: 8px; height: 8px; }
#editor ::-webkit-scrollbar-track { background: transparent; }
#editor ::-webkit-scrollbar-thumb { background: var(--line); border-radius: 4px; }
#editor ::-webkit-scrollbar-thumb:hover { background: var(--faint); }

/* ── 11. Save dialog — download section (§9.2, doory preset-card port) ───── */
/* Lives in editor.css (not style.css) per the ask's file scope; scoped to
   #save-modal so the shared-modal sheet in style.css is untouched. Contract
   tokens only — dark default, light via html[data-theme="light"]. */
.save-download {
  border-top: 1px solid var(--line);
  margin-top: var(--s-4); padding-top: var(--s-4);
}
.dl-summary { font-size: var(--fs-12); color: var(--dim); margin: 0 0 10px; }
.dl-summary:empty { display: none; }
.dl-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 10px; }
.dl-card {
  display: flex; flex-direction: column; gap: 3px; text-align: left;
  padding: 10px 12px; cursor: pointer; font: inherit;
  background: var(--panel-2); border: 1px solid var(--line);
  border-radius: var(--r-md); color: var(--text);
}
.dl-card:hover { border-color: var(--lime); }
.dl-card:active { transform: translateY(1px); }
.dl-card-title { font-size: 14px; font-weight: 600; color: var(--text); }
.dl-card-hint { font-size: var(--fs-12); color: var(--dim); }
.dl-note { font-size: var(--fs-12); color: var(--faint); margin: 0; }
@media (max-width: 640px) {
  .dl-cards { grid-template-columns: 1fr; }   /* bottom sheet: stack the cards */
}
