/* App Blueprint (blueprint.html, M575, TJ 2026-12-02: "Describe it. We'll draw it."). Builds on hub.css: same colors, fonts,
   buttons, chips and cards, in light and dark. Computers and tablets get the palette | chart | details layout; phones get the
   palette as a row above the chart and the details below it. */
.bp-page {
  --bp-term: #7c3aed; --bp-term-bg: #f3efff; --bp-proc: #4f63f6; --bp-proc-bg: #eef0ff; --bp-dec: #b26a00; --bp-dec-bg: #fff6de;
  --bp-io: #0f8a7e; --bp-io-bg: #e3f7f4; --bp-db: #2563eb; --bp-db-bg: #e8f1ff; --bp-doc: #c0306b; --bp-doc-bg: #fdebf2;
  --bp-con: #5a6278; --bp-con-bg: #f1f2f6; --bp-line: #6b7390; --bp-canvas: #fbfbfe; --bp-dot: #dfe2ee;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .bp-page {
    --bp-term: #b197fc; --bp-term-bg: #1e1636; --bp-proc: #8a98ff; --bp-proc-bg: #161a36; --bp-dec: #f5b94a; --bp-dec-bg: #2a2010;
    --bp-io: #4fd1c5; --bp-io-bg: #0f2624; --bp-db: #6ea8ff; --bp-db-bg: #111f38; --bp-doc: #f47ba8; --bp-doc-bg: #2d1320;
    --bp-con: #a0a7ba; --bp-con-bg: #1b1e2c; --bp-line: #8d94ab; --bp-canvas: #0b0d16; --bp-dot: #20253a;
  }
}

main.bp-main { max-width: 1360px; padding: 28px 16px 8px; }
.bp-head { max-width: 860px; }
.bp-crumb { margin: 0; font-size: .9rem; color: var(--muted); }
.bp-head h1 { margin: 8px 0 10px; }
.bp-head h1 .gradient-text { display: block; font-size: .62em; letter-spacing: -.02em; margin-top: 4px; }
.bp-head .lead { margin: 0 0 22px; max-width: 70ch; font-size: 1.05rem; }

/* Start: AI and templates */
.bp-start { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 16px; margin-bottom: 16px; }
.bp-start .card { margin: 0; }
.bp-start h2 { display: flex; align-items: center; gap: 8px; margin: 0 0 10px; font-size: 1.1rem; }
.bp-ico { width: 20px; height: 20px; color: var(--accent); flex: none; }
.bp-ai label { display: block; font-weight: 600; font-size: .95rem; margin-bottom: 6px; }
.bp-ai textarea { width: 100%; padding: 11px 12px; border-radius: 10px; border: 1px solid var(--rule); background: var(--bg); color: var(--text);
  font: inherit; resize: vertical; min-height: 96px; }
.bp-ai textarea:focus-visible, .bp-side input:focus-visible, .bp-inline textarea:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; border-color: transparent; }
.bp-ai-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-top: 10px; }
.bp-ai-row .grow { flex: 1; }
.bp-ai .notice { margin: 10px 0 0; }
.bp-busy::before { content: ""; display: inline-block; width: 14px; height: 14px; margin-right: 8px; vertical-align: -2px; border-radius: 50%;
  border: 2px solid currentColor; border-right-color: transparent; animation: bp-spin .8s linear infinite; }
@keyframes bp-spin { to { transform: rotate(360deg); } }
.bp-template-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.bp-template { display: grid; gap: 2px; justify-items: start; justify-content: stretch; text-align: left; padding: 10px 12px; border-radius: 12px; background: var(--raised);
  border: 1px solid var(--rule); color: var(--text); font-weight: 400; }
.bp-template b { font-size: .95rem; }
.bp-template span { font-size: .8rem; color: var(--muted); }
.bp-template:hover { border-color: color-mix(in srgb, var(--accent) 40%, var(--rule)); }
.bp-template.blank { border-style: dashed; }
.bp-signin { display: grid; gap: 0; margin-top: 8px; }
.bp-signin p { margin: 0 0 4px; }
.bp-signin .block { margin: 4px 0; padding: 10px 16px; }

/* The editor */
.bp-editor { min-width: 0; border: 1px solid var(--rule); border-radius: var(--radius); background: var(--surface); overflow: hidden; }
.bp-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 10px; border-bottom: 1px solid var(--rule); background: var(--raised); }
.bp-toolbar .grow { flex: 1; }
.bp-tool-group { display: flex; gap: 4px; }
.bp-tool { padding: 8px 10px; border-radius: 10px; min-height: 40px; min-width: 40px; font-size: .9rem; }
.bp-tool svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.bp-tool:disabled { opacity: .45; cursor: default; filter: none; transform: none; }
.bp-tool.on { background: var(--tint); border-color: var(--accent); color: var(--link); }
.bp-work { display: grid; grid-template-columns: 148px minmax(0, 1fr) 340px; min-height: 640px; }
.bp-palette { display: flex; flex-direction: column; gap: 6px; padding: 10px 8px; border-right: 1px solid var(--rule); background: var(--raised); overflow-y: auto;
  touch-action: pan-y; }
.bp-pal { display: grid; justify-items: center; gap: 2px; padding: 6px 4px 8px; border-radius: 12px; background: transparent; border: 1px solid transparent;
  color: var(--text); font-weight: 550; font-size: .78rem; line-height: 1.25; text-align: center; user-select: none; -webkit-user-select: none; touch-action: pan-y; }
.bp-pal:hover { background: var(--surface); border-color: var(--rule); filter: none; }
.bp-pal-icon { width: 64px; height: 38px; overflow: visible; }
.bp-pal-icon .bp-shape { stroke-width: 2.5; }
.bp-pal-ghost { position: fixed; z-index: 90; pointer-events: none; transform: translate(-50%, -50%); opacity: .85; }
.bp-pal-ghost .bp-pal-icon { width: 96px; height: 58px; }

.bp-canvas-wrap { position: relative; min-width: 0; background: var(--bp-canvas); }
.bp-svg { display: block; width: 100%; height: 100%; min-height: 640px; touch-action: none; user-select: none; -webkit-user-select: none; cursor: grab; }
.bp-svg:active { cursor: grabbing; }
.bp-svg:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; border-radius: 0; }
.bp-bg { fill: url(#bp-grid); }
.bp-grid-dot { fill: var(--bp-dot); }
.bp-canvas-help { position: absolute; left: 10px; bottom: 10px; max-width: min(520px, calc(100% - 20px)); margin: 0; padding: 6px 12px; border-radius: 12px;
  background: color-mix(in srgb, var(--raised) 92%, transparent); border: 1px solid var(--rule); color: var(--muted); pointer-events: none; }
.bp-canvas-help[hidden] { display: none; }
.bp-hint { position: absolute; top: 10px; left: 50%; transform: translateX(-50%); max-width: calc(100% - 24px); padding: 8px 14px; border-radius: 99px;
  background: var(--text); color: var(--bg); font-size: .88rem; font-weight: 600; box-shadow: var(--shadow); text-align: center; pointer-events: none; }

/* Shapes on screen */
.bp-node { cursor: move; outline: none; }
.bp-node .bp-shape { stroke-width: 2; transition: filter .15s ease; }
.bp-text { font-size: 13px; font-weight: 550; fill: var(--text); pointer-events: none; }
.bp-terminator .bp-shape { fill: var(--bp-term-bg); stroke: var(--bp-term); }
.bp-process .bp-shape { fill: var(--bp-proc-bg); stroke: var(--bp-proc); }
.bp-decision .bp-shape { fill: var(--bp-dec-bg); stroke: var(--bp-dec); }
.bp-io .bp-shape { fill: var(--bp-io-bg); stroke: var(--bp-io); }
.bp-database .bp-shape { fill: var(--bp-db-bg); stroke: var(--bp-db); }
.bp-document .bp-shape { fill: var(--bp-doc-bg); stroke: var(--bp-doc); }
.bp-connector .bp-shape { fill: var(--bp-con-bg); stroke: var(--bp-con); }
.bp-node.selected .bp-shape, .bp-node:focus-visible .bp-shape { stroke-width: 3.5; filter: drop-shadow(0 0 6px color-mix(in srgb, var(--accent) 45%, transparent)); }
.bp-node:focus-visible .bp-shape { stroke-dasharray: 6 3; }
.bp-node.from .bp-shape, .bp-node.target .bp-shape { stroke: var(--good); stroke-width: 3.5; }
.bp-handle { fill: var(--accent); stroke: var(--bg); stroke-width: 3; cursor: crosshair; }
@media (pointer: coarse) { .bp-handle { r: 12; } }
.bp-edge { outline: none; cursor: pointer; }
.bp-edge-hit { fill: none; stroke: transparent; stroke-width: 16; }
.bp-edge-line { fill: none; stroke: var(--bp-line); stroke-width: 1.8; }
.bp-arrow-tip { fill: var(--bp-line); }
.bp-arrow-tip.sel { fill: var(--accent); }
.bp-edge.selected .bp-edge-line, .bp-edge:focus-visible .bp-edge-line { stroke: var(--accent); stroke-width: 3; }
.bp-edge-label { fill: var(--raised); stroke: var(--rule); }
.bp-edge-text { font-size: 12px; font-weight: 650; fill: var(--text); pointer-events: none; }
.bp-ghost { fill: none; stroke: var(--accent); stroke-width: 2; stroke-dasharray: 6 4; pointer-events: none; }
.bp-ghost[hidden] { display: none; }

/* Text editor over a shape */
.bp-inline { position: absolute; z-index: 5; padding: 10px; border-radius: 14px; background: var(--raised); border: 1px solid var(--rule); box-shadow: 0 18px 50px rgba(0, 0, 0, .22); }
.bp-inline[hidden] { display: none; }
.bp-inline textarea { width: 100%; padding: 8px 10px; border-radius: 10px; border: 1px solid var(--rule); background: var(--bg); color: var(--text); font: inherit; resize: none; }
.bp-inline-row { display: flex; align-items: center; gap: 6px; margin-top: 6px; }
.bp-inline-row .grow { flex: 1; }
.bp-inline-row button { padding: 7px 12px; font-size: .9rem; }
.hp-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Details: name, features, estimate, save and send */
.bp-side { border-left: 1px solid var(--rule); background: var(--raised); padding: 6px 16px 16px; overflow-y: auto; max-height: 760px; }
.bp-panel { padding: 12px 0; border-bottom: 1px solid var(--rule); }
.bp-panel:last-child { border-bottom: 0; }
.bp-panel h2 { display: flex; align-items: center; gap: 8px; margin: 0 0 10px; font-size: 1.02rem; }
.bp-panel > p { margin: 0 0 10px; }
.bp-side label:not(.chip) { display: grid; gap: 4px; font-weight: 600; font-size: .9rem; margin-bottom: 10px; }
.bp-side input:not([type=checkbox]) { width: 100%; padding: 9px 11px; border-radius: 10px; border: 1px solid var(--rule); background: var(--bg); color: var(--text); font: inherit; font-weight: 400; }
.bp-stats { margin: 0 0 10px; }
.bp-save-row { display: flex; gap: 8px; }
.bp-save-row button { flex: 1; padding: 10px 14px; }
.bp-side .notice { margin: 10px 0 0; font-size: .9rem; }
.bp-tag { font-size: .7rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; padding: 3px 8px; border-radius: 99px; background: var(--tint); color: var(--link); }
.bp-chips { gap: 6px; }
.bp-chips .chip { padding: 6px 10px; font-size: .82rem; font-weight: 550; box-shadow: none; border-radius: 10px; gap: 6px; }
.bp-chips .chip .tick { width: 16px; height: 16px; border-radius: 5px; }
.bp-chips .chip .tick svg { width: 11px; height: 11px; }
.bp-chips .chip:hover { transform: none; }
.bp-estimate { margin-top: 12px; padding: 12px; border-radius: 12px; background: var(--surface); border: 1px solid var(--rule); }
.bp-estimate p { margin: 0 0 4px; }
.bp-total { font-weight: 750; font-size: 1.02rem; }
.bp-send .block { margin: 0; }
.bp-export { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 10px; }
.bp-export button { padding: 9px 10px; font-size: .9rem; }
.bp-danger { color: var(--bad); }

/* Dialogs */
.bp-dialog { border: 0; border-radius: 18px; padding: 22px; background: var(--bg); color: var(--text); width: min(520px, calc(100vw - 32px)); box-shadow: 0 30px 80px rgba(0, 0, 0, .35); }
.bp-dialog::backdrop { background: rgba(8, 10, 26, .55); }
.bp-dialog h2 { margin: 0 0 8px; font-size: 1.2rem; }
.bp-dialog p { margin: 0 0 10px; }
.bp-dialog-buttons { display: flex; justify-content: flex-end; gap: 8px; margin-top: 14px; flex-wrap: wrap; }
.bp-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; max-height: 50vh; overflow-y: auto; }
.bp-list li { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border: 1px solid var(--rule); border-radius: 12px; background: var(--raised); }
.bp-list .grow { flex: 1; min-width: 0; display: grid; }
.bp-list small { color: var(--muted); }
.bp-list button { padding: 7px 12px; font-size: .88rem; }

/* Super Admin view (?ticket=) */
.bp-review { display: grid; gap: 14px; }
.bp-review[hidden] { display: none; }
.bp-review-bar { display: flex; justify-content: flex-end; }
.bp-review-item h2 { margin: 0 0 4px; }
.bp-review-item > p { margin: 0 0 12px; }
.bp-chart-box { background: #fff; border: 1px solid var(--rule); border-radius: 14px; padding: 8px; overflow: auto; max-height: 80vh; }
.bp-chart { display: block; width: 100%; height: auto; max-width: 1000px; margin: 0 auto; }
.bp-feature-list { margin: 0 0 12px; padding: 0; list-style: none; display: flex; flex-wrap: wrap; gap: 6px; }
.bp-feature-list li { padding: 4px 10px; border-radius: 99px; background: var(--tint); font-size: .88rem; font-weight: 600; }
.bp-review-actions { display: flex; gap: 8px; }
.bp-print-area { display: none; }

/* Tablets: the details go under the chart, in columns */
@media (max-width: 1100px) {
  .bp-work { grid-template-columns: 132px minmax(0, 1fr); }
  .bp-side { grid-column: 1 / -1; border-left: 0; border-top: 1px solid var(--rule); max-height: none; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0 20px; }
  .bp-panel { border-bottom: 0; }
}
@media (max-width: 900px) {
  .bp-start { grid-template-columns: minmax(0, 1fr); }
  .bp-work { min-height: 0; }
  .bp-svg { min-height: 560px; }
  .bp-side { grid-template-columns: 1fr 1fr; }
  .bp-send { grid-column: 1 / -1; }
}
/* Phones: palette in a row above the chart, details stacked */
@media (max-width: 640px) {
  main.bp-main { padding-top: 16px; }
  .bp-work { grid-template-columns: minmax(0, 1fr); }
  .bp-palette { flex-direction: row; overflow-x: auto; overflow-y: hidden; border-right: 0; border-bottom: 1px solid var(--rule); padding: 6px; touch-action: pan-x; }
  .bp-pal { flex: 0 0 84px; font-size: .72rem; touch-action: pan-x; }
  .bp-pal-icon { width: 52px; height: 30px; }
  .bp-svg { min-height: 440px; }
  .bp-side { grid-template-columns: minmax(0, 1fr); }
  .bp-tool.wide span { display: none; }
  .bp-toolbar { gap: 6px; padding: 8px; }
  .bp-toolbar .grow { display: none; }
  .bp-template-list { grid-template-columns: 1fr 1fr; }
  .bp-canvas-help { display: none; }
}

/* Save as PDF: only the name, the chart and the features */
@media print {
  @page { margin: 14mm; }
  body { background: #fff !important; color: #000; display: block; min-height: 0; }
  header.top, footer, .skip, .to-top, .bp-head, #bp-editor-area, .bp-dialog, .bp-review-bar, .bp-review-actions { display: none !important; }
  main.bp-main { max-width: none; padding: 0; }
  .bp-print-area { display: block; color: #000; }
  .bp-review-mode .bp-print-area { display: none; }
  .bp-print-area h1 { margin: 0 0 4px; font-size: 22pt; }
  .bp-print-area h2 { font-size: 14pt; margin: 18px 0 6px; }
  .bp-print-area .muted, .bp-review .muted { color: #444; }
  .bp-chart { max-width: 100%; max-height: 220mm; width: auto; margin: 10px 0; }
  .bp-review-item { break-inside: avoid; border: 0; background: #fff; padding: 0; }
  .bp-chart-box { border: 0; max-height: none; overflow: visible; padding: 0; }
  .bp-feature-list li { background: #eef0ff; color: #000; }
}
