:root {
  color-scheme: light;
  --ink: #3C2415;
  --muted: #695b51;
  --paper: #f3f0e8;
  --card: #fffefb;
  --green: #603913;
  --green-soft: #f0e8dc;
  --line: #d7d8d1;
  --gold: #A97C50;
  --danger: #a53f39;
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
.debug-only { display: none !important; }
.debug-mode .debug-only { display: block !important; }
.debug-mode .examples { display: flex !important; }
.debug-mode .state-pill { display: inline-block !important; }
.debug-mode .button.debug-only { display: inline-flex !important; }
html, body { margin: 0; min-height: 100%; background: var(--paper); color: var(--ink); }
body { min-height: 100dvh; display: flex; flex-direction: column; }
html:has(dialog[open]), body:has(dialog[open]) { overflow: hidden; }
button, input, label { font: inherit; }
button, label { -webkit-tap-highlight-color: transparent; }
button:disabled { opacity: .43; cursor: not-allowed; }
button, label.button, a.button { border-radius: 9px; box-shadow: 0 3px 0 rgba(45, 26, 14, .23), 0 6px 11px rgba(45, 26, 14, .13); transition: background-color .15s ease, border-color .15s ease, color .15s ease, transform .14s ease, box-shadow .14s ease, filter .14s ease; }
button:not(:disabled):active, label.button:active, a.button:active { transform: translateY(3px); box-shadow: 0 1px 0 rgba(45, 26, 14, .24), 0 2px 5px rgba(45, 26, 14, .12); filter: brightness(.91); }
button[data-busy="true"] { opacity: 1; cursor: progress; }
button[data-busy="true"]::before { content: ""; width: 17px; height: 17px; flex: 0 0 17px; margin-right: 9px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .8s linear infinite; }
:where(button, input, select, a, .button):focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { button, .button { transition: none; } .spinner, button[data-busy="true"]::before, button[data-state="processing"]::before { animation-duration: 1.8s; } }

.topbar {
  min-height: 66px; padding: max(12px, env(safe-area-inset-top)) clamp(16px, 4vw, 32px) 12px;
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
  background: var(--ink); color: white;
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand-logo { display: block; width: 43px; height: 43px; flex: 0 0 43px; object-fit: contain; padding: 3px; border-radius: 10px; background: #f8f3ec; }
.brand span { min-width: 0; }
.topbar strong, .topbar small { display: block; }
.topbar strong { font-size: 17px; }
.topbar small { margin-top: 2px; color: #cad3ce; font-size: 12px; }
.state-pill { padding: 7px 10px; border: 1px solid #506058; border-radius: 999px; color: #dbe2de; font-size: 12px; white-space: nowrap; }
.state-pill.ready { background: #165d4e; border-color: #438c79; }
.state-pill.error { background: #6d332f; border-color: #9a5e58; }
.topbar-actions { display: flex; align-items: center; gap: 9px; }
.topbar-actions > button { min-height: 40px; padding: 8px 12px; border: 1px solid #ab8d73; border-radius: 10px; background: transparent; color: white; cursor: pointer; }
.topbar > div, .topbar-actions, .topbar-actions > button { min-width: 0; }

.workspace { width: min(1220px, 100%); margin: 0 auto; padding: 18px; display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 18px; flex: 1; }
.password-saved-notice { width: min(1184px, calc(100% - 36px)); margin: 18px auto 0; padding: 15px 52px 15px 18px; position: relative; border: 2px solid #4d8b67; border-radius: 14px; background: #e9f5ec; color: #194c2e; box-shadow: 0 5px 16px rgba(25,76,46,.12); }
.password-saved-notice strong, .password-saved-notice span { display: block; line-height: 1.4; }
.password-saved-notice strong { font-size: 17px; }
.password-saved-notice span { margin-top: 3px; font-size: 14px; }
.password-saved-notice button { position: absolute; top: 8px; right: 10px; width: 36px; height: 36px; border: 0; background: transparent; color: inherit; font-size: 25px; cursor: pointer; box-shadow: none; }
.stage-card, .controls { background: var(--card); border: 1px solid var(--line); border-radius: 18px; box-shadow: 0 10px 28px rgba(23,34,29,.07); }
.stage-card { position: relative; min-height: 640px; overflow: hidden; display: grid; place-items: center; }
.photo-actions { position: absolute; z-index: 8; top: 12px; right: 12px; }
.photo-actions .button { min-height: 42px; padding: 9px 13px; background: rgba(255,255,255,.94); box-shadow: 0 4px 16px rgba(23,34,29,.14); }
.inspection-controls { position: absolute; z-index: 7; inset-inline: 12px; bottom: 12px; display: grid; grid-template-columns: auto minmax(80px, 1fr) auto; align-items: center; gap: 12px; padding: 9px 12px; border: 1px solid rgba(215,216,209,.9); border-radius: 14px; background: rgba(255,254,251,.94); box-shadow: 0 4px 18px rgba(23,34,29,.16); backdrop-filter: blur(10px); }
.inspection-zoom-label { display: flex; gap: 7px; align-items: baseline; color: var(--muted); font-size: 13px; white-space: nowrap; }
.inspection-zoom-label output { min-width: 29px; color: var(--ink); font-weight: 750; }
.inspection-controls input[type="range"] { min-width: 80px; margin: 0; }
.inspection-controls button { min-height: 36px; padding: 6px 9px; border: 1px solid #cbd6d1; border-radius: 9px; background: white; color: #35665a; font-size: 12px; font-weight: 650; white-space: nowrap; cursor: pointer; }
.inspection-toast { position: absolute; z-index: 9; top: 14px; left: 50%; transform: translateX(-50%); padding: 10px 15px; border: 1px solid #c9ddd4; border-radius: 999px; background: rgba(220,238,232,.96); color: #174f41; font-size: 14px; font-weight: 750; box-shadow: 0 4px 14px rgba(23,34,29,.16); }
.empty-state { width: 100%; max-width: 900px; padding: 32px 22px; text-align: center; }
.prototype-options { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin: 20px auto 0; }
.prototype-card { min-width: 0; padding: 12px; display: grid; grid-template-rows: minmax(150px, 210px) auto; gap: 10px; align-items: center; border: 1px solid var(--line); border-radius: 14px; background: #fff; color: var(--ink); cursor: pointer; }
.prototype-card:hover { border-color: var(--gold); background: #fcf8f1; }
.prototype-card strong { font-size: clamp(13px, 1.5vw, 16px); line-height: 1.2; }
.prototype-image { position: relative; min-width: 0; min-height: 0; height: 100%; display: grid; place-items: center; overflow: hidden; border-radius: 10px; background: #ebe8e1; }
.prototype-image img { position: absolute; inset: 0; display: block; width: 100%; height: 100%; object-fit: contain; }
.prototype-upload .prototype-image { background: #f0e8dc; }
.prototype-upload svg { width: 64px; height: 64px; fill: none; stroke: var(--ink); stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
h1 { margin: 0 0 10px; font: 600 clamp(28px, 5vw, 42px)/1.1 Georgia, serif; }
.empty-state > p { margin: 0 0 24px; color: var(--muted); font-size: 16px; }
.empty-state > .photo-error { margin: 18px 0 0; padding: 12px; border: 2px solid var(--danger); border-radius: 10px; background: #fff0ee; color: #8e302b; font-weight: 700; }
.photo-preview-actions .photo-error { width: 100%; margin: 8px 0 0; padding: 10px; border: 2px solid var(--danger); border-radius: 10px; background: #fff0ee; color: #8e302b; font-weight: 700; }
.button-row { display: flex; justify-content: center; flex-wrap: wrap; gap: 10px; }
.examples { margin-top: 24px; display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 8px; }
.examples span { width: 100%; color: var(--muted); font-size: 13px; }
.examples button { min-height: 42px; border: 1px solid var(--line); border-radius: 10px; background: white; padding: 8px 11px; color: #31564b; cursor: pointer; }

.button { min-height: 48px; padding: 12px 17px; border-radius: 12px; border: 1px solid transparent; display: inline-flex; align-items: center; justify-content: center; font-weight: 680; cursor: pointer; }
.primary { background: var(--ink); color: white; }
.secondary { background: white; color: var(--ink); border-color: #aeb6b1; }
.quiet { background: #f7f6f1; color: #425149; border-color: var(--line); }
.full { width: 100%; }

.editor, .canvas-wrap { width: 100%; height: 100%; min-height: 640px; }
.canvas-wrap { position: relative; display: grid; place-items: center; overflow: hidden; background: #d8d8d3; touch-action: pan-y; }
canvas { position: absolute; max-width: 100%; max-height: 100%; width: auto; height: auto; }
#photoCanvas { z-index: 1; }
#materialCanvas { z-index: 2; pointer-events: none; }
#maskCanvas { z-index: 3; pointer-events: none; }
#interactionCanvas { z-index: 4; touch-action: none; }

.busy { position: absolute; z-index: 10; inset: 0; padding: 28px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; text-align: center; background: rgba(23,34,29,.9); color: white; }
.busy[hidden] { display: none; }
.busy span { color: #d6ddd9; }
.spinner { width: 34px; height: 34px; border: 3px solid #718078; border-top-color: #dfbd7a; border-radius: 50%; animation: spin .85s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.controls { align-self: start; padding: 16px; }
.status-card { padding: 14px; border-radius: 14px; background: var(--green-soft); }
.status-card strong { display: block; margin-top: 2px; }
.status-card p { margin: 4px 0 0; color: #36574e; font-size: 13px; line-height: 1.4; }
.status-card.status-error { border: 2px solid var(--danger); background: #fff0ee; }
.status-card.status-error strong, .status-card.status-error p { color: #8e302b; }
.status-card #retryPreparationButton { margin-top: 12px; min-height: 40px; padding: 8px 14px; border: 1px solid var(--danger); color: #8e302b; background: white; }
.progress { margin-top: 12px; padding: 10px 6px; display: grid; grid-template-columns: auto 1fr auto 1fr auto; align-items: center; gap: 6px; }
.progress > div { display: grid; justify-items: center; gap: 4px; min-width: 58px; color: #929a96; }
.progress > div span { width: 28px; height: 28px; display: grid; place-items: center; border: 1px solid #b9bfbc; border-radius: 50%; background: white; font-size: 12px; font-weight: 750; }
.progress > div strong { font-size: 11px; font-weight: 650; }
.progress > i { height: 2px; margin-bottom: 18px; background: #d6d9d7; }
.progress > div[data-state="active"] { color: var(--green); }
.progress > div[data-state="active"] span { border-color: var(--green); box-shadow: inset 0 0 0 2px var(--green-soft); }
.progress > div[data-state="completed"] { color: #315f4f; }
.progress > div[data-state="completed"] span { border-color: var(--green); background: var(--green); color: white; }
.stage-panel { margin-top: 12px; padding: 14px; border: 1px solid var(--line); border-radius: 14px; background: white; }
.stage-panel.current-step { border-color: var(--green); box-shadow: inset 0 0 0 1px var(--green); }
.stage-heading { display: flex; align-items: flex-start; gap: 11px; margin-bottom: 12px; }
.stage-heading h2 { margin-bottom: 3px; }
.stage-heading p { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.4; }
.stage-number { flex: 0 0 auto; width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; background: var(--green); color: white; font-weight: 750; }
.optional-stage { background: #fbfbf8; }
.candidate-section { margin-top: 14px; padding-top: 14px; border-top: 1px solid #e7e7e1; }
.candidate-section h3 { margin: 0 0 10px; font-size: 14px; }
.selection-actions { margin-top: 12px; }
h2 { margin: 0 0 11px; font-size: 15px; }
.tool-grid { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 8px; }
.tool { min-height: 52px; border: 1px solid var(--line); border-radius: 11px; background: white; color: var(--ink); cursor: pointer; }
.tool.active { border-color: var(--green); background: var(--green-soft); color: #105b4b; box-shadow: inset 0 0 0 1px var(--green); }
.tool[aria-pressed="true"]::after { content: "✓"; margin-left: 4px; font-weight: 800; }
.tool.danger { color: var(--danger); }
.tool.danger.active { border-color: var(--danger); background: #fae8e6; box-shadow: inset 0 0 0 1px var(--danger); }
#addButton { border-color: #8bbda7; background: #edf8f0; color: #195b40; box-shadow: 0 3px 0 #7aa68e; font-weight: 750; }
#addButton.active { border-color: #28764f; background: #bde8cd; color: #154b31; box-shadow: inset 0 0 0 2px #28764f, 0 2px 0 #609878; }
#removeButton { border-color: #e3ada8; background: #fff1ef; color: #8b3430; box-shadow: 0 3px 0 #c98d88; font-weight: 750; }
#removeButton.active { border-color: #ae5750; background: #ffd9d4; color: #782823; box-shadow: inset 0 0 0 2px #ae5750, 0 2px 0 #b37771; }
#addButton:active, #removeButton:active { transform: translateY(2px); box-shadow: inset 0 1px 3px #0003; }
#addButton.active .state-label, #removeButton.active .state-label { text-decoration: underline; text-underline-offset: 3px; }
@media (pointer: coarse) {
  .correction-tools #moveButton { display: none; }
  .correction-tools .tool-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
}
.hint { margin: 9px 0 13px; color: var(--muted); font-size: 13px; line-height: 1.45; }
.range-label { margin-top: 14px; display: flex; justify-content: space-between; color: var(--muted); font-size: 13px; }
input[type="range"] { width: 100%; margin: 12px 0 0; accent-color: var(--green); }
.action-stack { display: grid; gap: 9px; }
.optional-copy { margin: 13px 0 8px; color: var(--muted); font-size: 12px; line-height: 1.4; }
.stateful { gap: 8px; }
.state-icon { width: 19px; display: inline-grid; place-items: center; font-weight: 800; }
.stateful[data-state="active"] { background: #e3f1ed; border-color: var(--green); color: #105b4b; box-shadow: inset 0 0 0 1px var(--green); }
.stateful[data-state="completed"] { background: #e5f2e7; border-color: #579268; color: #245d35; }
.stateful[data-state="processing"] { background: #eceeea; color: #4e5953; border-color: #9ca49f; cursor: progress; }
.correction-tools { margin-top: 4px; }
.correction-note { margin: 8px 0 14px; color: var(--muted); font-size: 12px; line-height: 1.4; }
.tool-help { min-height: 19px; margin: 8px 0 2px; color: #4f5e57; font-size: 13px; line-height: 1.4; }
.fit-image-button { display: block; margin: 2px 0 0 auto; padding: 7px 2px; border: 0; background: transparent; color: #35665a; font-size: 12px; font-weight: 650; cursor: pointer; }
.correction-action-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-bottom: 12px; }
.correction-action-row > button { min-width: 0; width: 100%; min-height: 42px; margin: 0; white-space: normal; }
.correction-tools { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 8px; margin-top: 0; }
.correction-tools .brush-label,
.correction-tools #brushSize,
.correction-tools .tool-grid,
.correction-tools #zoomSize,
.correction-tools .tool-help { grid-column: 1 / -1; }
.correction-tools .range-label { margin-top: 0; min-width: 0; gap: 8px; }
.correction-tools input[type="range"] { margin: 0; }
.correction-tools .tool-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.correction-tools .tool { min-height: 42px; padding: 6px 8px; }
.correction-tools #moveButton { grid-column: 1 / -1; }
.correction-tools .zoom-label,
.correction-tools .fit-image-button { margin-top: 4px; }
.correction-tools .zoom-label { grid-column: 1; flex-wrap: wrap; }
.correction-tools .fit-image-button { grid-column: 2; margin-bottom: 0; white-space: nowrap; }
.correction-tools .tool-help { min-height: 0; margin: 0; }
.correction-tools:has(#moveButton.active) .tool-help { display: none; }

.zones-panel { margin-top: 12px; padding: 14px; border: 1px solid #c9d7d1; border-radius: 14px; background: #f5faf8; }
.zones-heading { display: flex; align-items: center; justify-content: space-between; }
.zones-heading h2 { margin-bottom: 2px; }
.zones-heading p { margin: 0; color: var(--muted); font-size: 12px; }
.zones-list { display: grid; gap: 8px; margin-top: 11px; }
.zone-item { padding: 10px; border: 1px solid var(--line); border-radius: 11px; background: white; }
.zone-item.selected { border-color: var(--green); box-shadow: inset 0 0 0 1px var(--green); }
.zone-summary { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.zone-summary strong { font-size: 13px; }
.zone-summary span { color: var(--muted); font-size: 12px; }
.zone-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 7px; margin-top: 9px; }
.zone-actions button { min-height: 42px; padding: 7px; border: 1px solid var(--line); border-radius: 9px; background: #f8f8f5; color: var(--ink); font-size: 12px; cursor: pointer; }
.zone-actions button.delete-zone { color: var(--danger); border-color: #e2c3c0; }

.material-grid { display: grid; gap: 8px; margin-bottom: 12px; }
.category-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px; margin: 0 0 16px; }
.category-choice { width: 100%; min-width: 0; min-height: 86px; display: grid; grid-template-columns: 72px minmax(0, 1fr) 24px; align-items: center; gap: 14px; padding: 7px 14px 7px 7px; border: 1px solid #d3d6cd; border-radius: 15px; background: #fff; color: var(--ink); text-align: left; cursor: pointer; box-shadow: 0 2px 7px #21170d10; }
.category-choice:hover, .category-choice:focus-visible { border-color: #348264; background: #f3faf6; outline-offset: 2px; }
.category-choice:active { transform: translateY(1px); }
.category-choice strong { min-width: 0; font-size: clamp(15px, 2.5vw, 19px); line-height: 1.25; }
.category-visual { width: 72px; height: 72px; display: grid; place-items: center; overflow: hidden; border-radius: 10px; background: #eee9e1; color: #766754; font-size: 30px; }
.category-visual img { width: 100%; height: 100%; object-fit: cover; }
.category-arrow { color: #46735e; font-size: 29px; line-height: 1; text-align: right; }
.catalog-filters { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-bottom: 10px; }
.catalog-filters label { display: grid; gap: 5px; min-width: 0; font-size: 13px; font-weight: 750; color: #264c3b; }
.catalog-filters select { width: 100%; min-width: 0; min-height: 48px; padding: 9px 10px; border: 1.5px solid #5a9a78; border-radius: 11px; background: #e7f3ea; color: #173b2a; font-size: 15px; font-weight: 700; }
.catalog-filters select:focus-visible { outline: 3px solid #9cccb0; outline-offset: 2px; }
.catalog-status { margin: 0 0 10px; color: #396257; font-size: 12px; }
.catalog-status:empty { display: none; }
.texture-pending { width: 52px; height: 52px; display: grid; place-items: center; border-radius: 8px; background: #eee; color: #777; }
.material-choice:disabled { opacity: .6; cursor: not-allowed; }
.account-dialog { width: min(480px, calc(100vw - 24px)); max-height: calc(100vh - 24px); max-height: calc(100dvh - 24px); overflow-x: hidden; overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; border: 1px solid var(--line); border-radius: 18px; padding: clamp(16px, 3vw, 24px); background: #fff; color: var(--ink); box-shadow: 0 18px 50px #0004; }
.account-dialog::backdrop { background: #14251f99; }
.account-dialog h2 { margin: 0 44px 12px 0; line-height: 1.3; }
.account-intro { color: var(--muted); margin: 0 0 16px; }
.profile-details { margin: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.profile-details > div { min-width: 0; padding: 11px 12px; border: 1px solid var(--line); border-radius: 10px; background: #faf9f6; }
.profile-details dt { color: var(--muted); font-size: 12px; font-weight: 650; }
.profile-details dd { margin: 4px 0 0; color: var(--ink); font-size: 15px; font-weight: 650; overflow-wrap: anywhere; }
.account-security { margin-top: 18px; padding: 15px; border: 1px solid var(--line); border-radius: 12px; background: #f8f6f1; }
.account-security h3 { margin: 0 0 4px; font-size: 16px; }
.account-security p { margin: 0 0 12px; color: var(--muted); font-size: 13px; }
.account-security .button { width: 100%; }
.dialog-close { position: sticky; top: 0; z-index: 2; float: right; min-width: 44px; min-height: 44px; margin: -8px -8px 0 0; border: 0; border-radius: 10px; background: #fff; color: var(--ink); font-size: 28px; cursor: pointer; }
.account-tabs { display: grid; grid-template-columns: .85fr 1.25fr 1.1fr; gap: 6px; margin: 12px 0 16px; }
.account-tabs button { min-width: 0; min-height: 44px; border: 1px solid var(--line); border-radius: 8px; background: #f4f1ea; color: var(--ink); padding: 7px 5px; font-size: 13px; font-weight: 650; white-space: nowrap; cursor: pointer; }
.account-tabs button[aria-current="page"] { border-color: var(--green); background: var(--green-soft); color: var(--green); }
.account-form { display: grid; gap: 11px; }
.account-form label { display: grid; gap: 4px; font-size: 13px; font-weight: 600; }
.account-form input,.account-form select { width: 100%; min-width: 0; min-height: 44px; padding: 10px; border: 1px solid var(--line); border-radius: 8px; font-size: 16px; }
.account-form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.account-form .account-check { display: flex; align-items: flex-start; gap: 10px; min-height: 44px; line-height: 1.45; font-size: 14px; font-weight: 500; }
.account-check input[type="checkbox"] { flex: 0 0 20px; width: 20px; min-height: 20px; height: 20px; margin: 1px 0 0; padding: 0; accent-color: var(--green); }
.account-check span { min-width: 0; flex: 1; }
.account-check a { color: var(--green); text-decoration-thickness: 1px; text-underline-offset: 2px; }
.account-message,#projectMessage,#projectsMessage { min-height: 18px; font-size: 14px; color: #4e3422; line-height: 1.45; }
.account-message[data-kind="error"],#projectMessage[data-kind="error"],#projectsMessage[data-kind="error"] { padding: 12px; border: 2px solid #a53f39; border-radius: 10px; background: #fff0ee; color: #842923; font-weight: 700; }
.account-message[data-kind="success"],#projectMessage[data-kind="success"],#projectsMessage[data-kind="success"] { padding: 12px; border: 2px solid #2d7757; border-radius: 10px; background: #e8f5ec; color: #18543c; font-weight: 700; }
.account-password-email { margin: 0 0 14px; color: #4e3422; font-size: 14px; font-weight: 700; overflow-wrap: anywhere; }
.account-form [aria-invalid="true"] { border: 2px solid #ad3c35; background: #fff3f1; }
.account-form .field-error { display: block; margin-top: 3px; color: #a22f28; font-size: 14px; font-weight: 750; line-height: 1.35; }
.registration-success { display: grid; gap: 10px; padding: 14px; border: 1px solid #c6aa8b; border-radius: 12px; background: #fbf6ef; }
.registration-success h3 { margin: 0; font-size: 21px; }
.registration-success p { margin: 0; line-height: 1.45; }
.save-success-actions { display: grid; gap: 9px; margin-top: 16px; }
.project-list-item { display: grid; gap: 7px; padding: 12px; border: 1px solid var(--line); border-radius: 10px; margin: 8px 0; }
.project-list-item .project-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.project-list-item button { border: 1px solid var(--line); background: #f7f7f4; border-radius: 8px; padding: 7px 10px; cursor: pointer; }
.project-list-item button[data-busy="true"] { display: inline-flex; align-items: center; gap: 7px; color: #4e3422; opacity: 1; }
.project-list-item button[data-busy="true"]::before { content: ""; width: 14px; height: 14px; flex: none; border: 2px solid #c9b8a8; border-top-color: #4e3422; border-radius: 50%; animation: spin .85s linear infinite; }
.material-row { display: grid; grid-template-columns: minmax(0, 65fr) minmax(0, 35fr); gap: 7px; align-items: stretch; }
.material-row > * { min-width: 0; }
.material-row .material-choice { grid-template-columns: 40px minmax(0, 1fr) auto; gap: 6px; padding: 6px; }
.material-row .material-choice img { width: 40px; height: 40px; }
.material-choice { width: 100%; display: grid; grid-template-columns: 52px 1fr auto; align-items: center; gap: 10px; padding: 9px; border: 1px solid var(--line); border-radius: 11px; background: white; color: var(--ink); text-align: left; cursor: pointer; }
.material-choice.selected { border: 2px solid var(--green); background: var(--green-soft); }
.material-choice img { width: 52px; height: 52px; border-radius: 8px; object-fit: cover; }
.material-choice strong, .material-choice small { display: block; }
.material-choice small { margin-top: 3px; color: #396257; font-size: 11px; }
.material-choice b { color: var(--green); font-size: 18px; }
.material-inquiry { display: flex; flex-direction: column; justify-content: center; align-items: center; gap: 4px; min-height: 70px; padding: 7px 5px; border: 1px solid #8bbca3; border-radius: 11px; background: #e8f5ed; color: #184d35; text-decoration: none; text-align: center; cursor: pointer; }
.material-inquiry:hover { background: #d9efdf; }
.material-inquiry:focus-visible { outline: 3px solid #458f6b; outline-offset: 2px; }
.material-inquiry-heading { display: inline-flex; align-items: center; justify-content: center; gap: 4px; max-width: 100%; color: #17694d; font-size: 13px; line-height: 1.15; }
.material-inquiry-heading img { width: 20px; height: 20px; flex: none; }
.material-inquiry-description { color: #171d19; font-size: 12px; font-weight: 600; line-height: 1.25; overflow-wrap: normal; }
.material-choice > span { min-width: 0; }
.material-choice strong { overflow-wrap: anywhere; }
.post-actions { margin-top: 12px; }
.limit-copy { margin: 0; padding: 9px; border-radius: 9px; background: #f7ede0; color: #76532a; text-align: center; font-size: 12px; }
.correction-actions { margin-top: 18px; padding-top: 12px; border-top: 1px solid var(--line); }
.correction-actions h2 { margin-bottom: 5px; color: #7a837e; font-size: 11px; letter-spacing: .1em; text-transform: uppercase; }
.correction-actions > div { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.text-action { min-height: 44px; padding: 8px 5px; border: 0; background: transparent; color: #53615a; font-size: 12px; cursor: pointer; }
.danger-text { color: var(--danger); }
.destructive, .destructive-outline { color: white; background: var(--danger); border-color: var(--danger); }
.destructive-outline { background: white; color: var(--danger); }

.confirm-dialog { width: min(420px, calc(100% - 32px)); padding: 0; border: 0; border-radius: 16px; box-shadow: 0 20px 60px rgba(0,0,0,.28); }
.confirm-dialog::backdrop { background: rgba(13,21,17,.62); }
.confirm-dialog form { padding: 20px; }
.confirm-dialog h2 { margin: 0 0 8px; font-size: 18px; line-height: 1.35; }
.confirm-dialog p { margin: 0 0 18px; color: var(--muted); font-size: 14px; line-height: 1.45; }
.confirm-dialog h2 + .dialog-actions { margin-top: 18px; }
.dialog-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }

.candidate-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.candidate-instruction { margin: 0 0 12px; padding: 12px 14px; border: 1px solid #a9c8bd; border-radius: 12px; background: var(--green-soft); color: var(--ink); }
.candidate-instruction[hidden] { display: none; }
.candidate-instruction strong { display: block; font-size: 14px; line-height: 1.4; }
.candidate-instruction p { margin: 4px 0 0; color: #36574e; font-size: 12px; line-height: 1.4; }
.touch-instruction { display: none; }
@media (hover: none), (pointer: coarse) {
  .pointer-instruction { display: none; }
  .touch-instruction { display: inline; }
}
.candidate { padding: 4px; border: 2px solid transparent; border-radius: 11px; background: #f2f2ed; cursor: pointer; }
.candidate.selected { position: relative; border-color: var(--green); background: var(--green-soft); box-shadow: inset 0 0 0 1px var(--green); }
.candidate.selected::after { content: "✓"; position: absolute; top: 8px; right: 8px; width: 26px; height: 26px; display: grid; place-items: center; border-radius: 50%; background: var(--green); color: white; font-weight: 800; box-shadow: 0 2px 6px rgba(0,0,0,.18); }
.candidate canvas { position: static; display: block; width: 100%; height: auto; border-radius: 7px; }
.candidate span { display: block; padding: 6px 2px 3px; font-size: 12px; font-weight: 650; }

.metrics { margin-top: 16px; padding: 14px; border: 1px solid var(--line); border-radius: 12px; background: #fbfbf8; }
.metrics dl { margin: 0; display: grid; gap: 8px; }
.metrics dl div { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; font-size: 13px; }
.metrics dt { color: var(--muted); }
.metrics dd { margin: 0; font-weight: 680; text-align: right; }
footer { padding: 13px 18px max(13px, env(safe-area-inset-bottom)); text-align: center; color: var(--muted); font-size: 12px; }

/* Flujo guiado: una vista y una tarea principal. */
.flow-progress { width: min(520px, calc(100% - 32px)); margin: 12px auto 0; }
.simulation-notice { display: none; grid-column: 1 / -1; align-self: start; width: min(720px, calc(100% - 24px)); justify-self: center; margin: 8px auto; padding: 12px 16px; border: 2px solid #3b8a62; border-radius: 14px; background: #e0f3e7; color: #111; font-size: 15px; line-height: 1.4; font-weight: 750; text-align: center; box-shadow: 0 3px 10px #245b3b30; }
body[data-view="result"] .simulation-notice { display: block; }
.zone-tap-notice { grid-column: 1 / -1; align-self: start; width: min(720px, calc(100% - 24px)); justify-self: center; margin: 0 auto; padding: 9px 14px; border: 1px solid #3b8a62; border-radius: 12px; background: #e0f3e7; color: #111; font-size: 14px; line-height: 1.35; text-align: center; }
.zone-tap-notice strong, .zone-tap-notice span { display: block; }
.zone-tap-notice span { margin-top: 2px; font-size: 12px; }
body[data-zone-tap="true"] #statusCard:not(.status-error) { display: none; }
.photo-preview-actions { position: absolute; z-index: 8; inset-inline: 14px; bottom: 14px; display: grid; grid-template-columns: 1fr 1fr; gap: 9px; padding: 10px; border-radius: 14px; background: rgba(255,255,255,.94); box-shadow: 0 8px 24px rgba(23,34,29,.2); backdrop-filter: blur(10px); }
.photo-preview-actions[hidden] { display: none; }
.back-action { min-height: 42px; margin: -4px 0 10px; padding: 7px 2px; border: 0; background: transparent; color: #35665a; font-weight: 700; cursor: pointer; }
.result-heading { padding: 14px; border-radius: 13px; background: var(--green-soft); }
.result-heading strong { display: block; }
.result-heading p, .finished-state p { margin: 4px 0 0; color: #36574e; font-size: 13px; }
.finished-state { padding: 18px; border: 1px solid #bcd4ca; border-radius: 13px; background: #f2f8f5; text-align: center; }
.material-grid { padding-bottom: 74px; }
#materialButton { position: sticky; z-index: 6; bottom: max(8px, env(safe-area-inset-bottom)); box-shadow: 0 8px 24px rgba(23,34,29,.22); }
.selection-actions { position: sticky; z-index: 6; bottom: max(8px, env(safe-area-inset-bottom)); padding: 9px; border-radius: 13px; background: rgba(255,255,255,.95); box-shadow: 0 8px 24px rgba(23,34,29,.18); backdrop-filter: blur(9px); }

body[data-view="photo"] .workspace { grid-template-columns: minmax(0, 900px); justify-content: center; }
body[data-view="photo"] .photo-actions,
body[data-view="photo"] #controls,
body[data-view="material"] .photo-actions,
body[data-view="zone"] .photo-actions { display: none !important; }
body:not([data-view="zone"]) #interactionCanvas { pointer-events: none; }
body[data-view="zone"] #interactionCanvas { pointer-events: auto; touch-action: pan-y; }
body[data-adjusting="true"] #interactionCanvas { touch-action: none; }
body[data-view="result"] #interactionCanvas { pointer-events: auto; touch-action: none; }
body[data-view="result"] .canvas-wrap { touch-action: none; }
body[data-adjusting="true"] .status-card { display: none; }
body[data-view="zone"] #step1 .stage-heading,
body[data-view="zone"] #step2 .stage-heading,
body[data-view="material"] .status-card,
body[data-view="result"] .status-card { display: none; }
body[data-view="material"] .status-card.status-error { display: block; }
body[data-view="zone"] .zones-panel,
body[data-view="material"] .zones-panel { display: none !important; }
body[data-view="result"] #step1,
body[data-view="result"] #step2,
body[data-view="result"] #step3,
body[data-view="result"] #step4 { display: none !important; }
body[data-view="photo"] .correction-actions,
body[data-view="zone"] .correction-actions,
body[data-view="material"] .correction-actions { display: none; }

@media (max-width: 820px) {
  .workspace { display: block; padding: 0; }
  .stage-card, .controls { border-radius: 0; border-inline: 0; box-shadow: none; }
  .flow-progress { margin-block: 6px; padding-block: 6px; }
  .simulation-notice { margin: 8px auto; padding: 11px 13px; font-size: 14px; }
  .stage-card { min-height: 50dvh; }
  .editor, .canvas-wrap { min-height: 50dvh; }
  .controls { padding-bottom: max(18px, env(safe-area-inset-bottom)); }
  body[data-view="material"] .stage-card { display: none; }
  body[data-view="material"] .controls { min-height: calc(100dvh - 126px); }
  body[data-view="result"] .stage-card { min-height: 52dvh; }
  body[data-view="result"] .editor,
  body[data-view="result"] .canvas-wrap { min-height: 52dvh; }
  body[data-view="zone"] .controls { padding-top: 10px; }
  .zone-tap-notice { margin: 8px auto; padding: 8px 12px; font-size: 13px; }
  .zone-tap-notice span { font-size: 12px; }
  body[data-view="zone"] .status-card { position: static; margin-bottom: 10px; }
  body[data-view="zone"] .stage-panel { margin-top: 0; }
  .empty-state { padding: 24px 14px; }
  .prototype-options { gap: 8px; }
  .prototype-card { padding: 8px; grid-template-rows: 150px auto; gap: 7px; }
  .prototype-card strong { font-size: 13px; }
  .material-grid { grid-template-columns: minmax(0, 1fr); }
  .material-choice { grid-template-columns: 46px 1fr auto; }
  .material-choice img { width: 46px; height: 46px; }
}
@media (max-width: 420px) {
  .prototype-options { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .prototype-upload { grid-column: 1 / -1; grid-template-columns: 66px 1fr; grid-template-rows: auto; min-height: 74px; text-align: left; }
  .prototype-upload .prototype-image { width: 56px; height: 56px; }
  .prototype-upload svg { width: 34px; height: 34px; }
}

@media (max-width: 390px) {
  .topbar { padding-inline: 12px; }
  .topbar small { display: none; }
  .state-pill { max-width: 130px; overflow: hidden; text-overflow: ellipsis; }
  .zone-actions { grid-template-columns: 1fr; }
  .inspection-controls { inset-inline: 8px; bottom: 8px; grid-template-columns: auto minmax(56px, 1fr) auto; gap: 8px; padding: 8px; }
  .inspection-controls button { padding-inline: 7px; font-size: 11px; }
}

@media (max-width: 600px) {
  .material-grid { grid-template-columns: minmax(0, 1fr); }
  .material-choice { min-height: 64px; grid-template-columns: 52px minmax(0,1fr) auto; }
  .material-choice img { width: 52px; height: 52px; }
  .material-choice strong { font-size: 15px; line-height: 1.25; }
  .material-choice small { font-size: 12px; }
  .topbar { display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; padding: max(10px, env(safe-area-inset-top)) 12px 10px; }
  .topbar strong { font-size: 16px; }
  .brand-logo { width: 38px; height: 38px; flex-basis: 38px; }
  .topbar small { display: block; font-size: 11px; }
  .topbar-actions { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 7px; }
  .topbar-actions > button { min-height: 44px; padding: 7px 4px; font-size: 13px; white-space: nowrap; }
  .flow-progress { margin-block: 4px; padding-block: 4px; }
  .empty-state { padding: 28px 18px; }
  .empty-state h1 { font-size: clamp(25px, 7vw, 32px); }
  .account-dialog { width: calc(100vw - 20px); max-height: calc(100dvh - 20px - env(safe-area-inset-top) - env(safe-area-inset-bottom)); border-radius: 14px; padding: 16px; }
  .account-form-row { grid-template-columns: 1fr; }
  .profile-details { grid-template-columns: 1fr; gap: 8px; }
  .account-tabs button { font-size: 12px; }
  .photo-preview-actions .button { min-width: 0; padding-inline: 8px; font-size: 14px; }
}

@media (max-width: 340px) {
  .account-dialog { padding: 12px; }
  .account-tabs { gap: 4px; }
  .account-tabs button { padding-inline: 2px; }
  .catalog-filters { grid-template-columns: minmax(0, 1fr); }
  .material-grid { grid-template-columns: minmax(0, 1fr); }
}

/* Encabezado aprobado: dos renglones, textura real y logotipo existente. */
.topbar {
  display: block;
  min-height: 0;
  padding: max(9px, env(safe-area-inset-top)) clamp(10px, 3vw, 24px) 13px;
  background: #a7460b url("assets/piel-cognac-encabezado.png") repeat center center / 307px 185px;
  color: #fff;
}
.topbar-inner { width: min(100%, 1040px); margin: auto; display: grid; gap: 9px; }
.topbar-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-width: 0; }
.brand { flex: 1 1 auto; gap: clamp(7px, 1.5vw, 12px); }
.brand-logo { width: clamp(43px, 6vw, 56px); height: clamp(43px, 6vw, 56px); flex-basis: clamp(43px, 6vw, 56px); padding: 3px; border-radius: 11px; box-shadow: 0 3px 5px #3c210aaa; }
.topbar strong { color: #fff; font-size: clamp(18px, 2.5vw, 27px); line-height: 1.08; text-shadow: 0 1px 3px #5b260f; }
.topbar small { color: #fff3e8; font-size: clamp(11px, 1.5vw, 15px); line-height: 1.2; text-shadow: 0 1px 3px #5b260f; }
.topbar-actions { display: grid; grid-template-columns: repeat(3, minmax(0, 220px)); justify-content: space-between; gap: 8px; min-width: 0; }
.topbar-actions > button, .share-app-button {
  min-width: 0; min-height: 48px; padding: 7px 10px;
  display: flex; align-items: center; justify-content: center; gap: 7px;
  border: 1px solid #a67d58; border-radius: 13px;
  color: #fff; font-weight: 730; font-size: clamp(12px, 1.6vw, 17px); line-height: 1.15;
  text-align: center; text-shadow: 0 1px 2px #1d0f09;
  box-shadow: inset 0 1px 1px #fff5, inset 0 -2px 2px #150c0999, 0 4px 0 #23110b, 0 7px 11px #22120cb3;
  cursor: pointer;
}
.topbar-actions > button { background: #2d1d17 url("assets/piel-cafe-navegacion.png") no-repeat center center / 320px auto; }
.topbar-actions > button:hover { filter: brightness(1.08); }
.topbar-actions > button:active, .share-app-button:active {
  transform: translateY(4px);
  box-shadow: inset 0 2px 4px #120b0a99, 0 1px 0 #23110b, 0 2px 4px #22120c88;
  filter: brightness(.9);
}
.topbar-actions svg, .share-app-button svg { width: clamp(17px, 2.5vw, 26px); height: clamp(17px, 2.5vw, 26px); flex: 0 0 auto; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.topbar-actions span { min-width: 0; overflow-wrap: normal; }
.share-app-button {
  flex: 0 0 220px; width: 220px; min-height: 54px;
  border-color: #1769a9;
  background: linear-gradient(135deg, #00569cdb, #001c55eb), url("assets/piel-cafe-navegacion.png") no-repeat center center / 320px auto;
  box-shadow: inset 0 1px 1px #d5edff99, inset 0 -2px 3px #001538bb, 0 4px 0 #001c42, 0 7px 11px #102c43aa;
}
.share-app-button:active { box-shadow: inset 0 2px 4px #001538bb, 0 1px 0 #001c42, 0 2px 4px #102c4388; }
.share-app-button span { white-space: nowrap; }
.state-pill.debug-only { justify-self: start; }

.topbar-utilities { display: flex; align-items: center; gap: 8px; flex: 0 0 auto; }
.topbar-utilities > button { cursor: pointer; }
.help-button, .install-app-button {
  min-height: 48px; border: 1px solid #7b592f; color: #fff;
  text-shadow: 0 1px 2px #1d0f09;
  box-shadow: inset 0 1px 1px #fff5, inset 0 -2px 2px #150c0999, 0 4px 0 #23110b, 0 7px 11px #22120cb3;
}
.help-button { width: 48px; height: 48px; border-radius: 50%; background: linear-gradient(135deg, #29855aab, #0d573aeb), url("assets/piel-cafe-navegacion.png") center / 180px; font-size: 27px; font-weight: 800; }
.install-app-button { width: 138px; display: flex; align-items: center; justify-content: center; gap: 7px; border-radius: 13px; background: #2d1d17 url("assets/piel-cafe-navegacion.png") no-repeat center / 320px auto; font-size: clamp(12px, 1.5vw, 16px); font-weight: 730; line-height: 1.15; text-align: center; }
.install-app-button svg { width: 24px; height: 24px; flex: 0 0 auto; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.help-button:active, .install-app-button:active { transform: translateY(4px); box-shadow: inset 0 2px 4px #120b0a99, 0 1px 0 #23110b, 0 2px 4px #22120c88; filter: brightness(.9); }
.share-app-button { width: 138px; flex-basis: 138px; }
.demo-chair { display: block; width: auto; max-width: 100%; height: min(48dvh, 460px); margin: 0 auto 20px; object-fit: contain; }
.initial-actions .button { min-width: 180px; text-transform: uppercase; font-size: 13px; }
.selection-help { margin: 12px 0; padding: 15px; border: 2px solid #75a798; border-radius: 14px; background: #eef9f5; color: #173f34; line-height: 1.45; }
.selection-help strong { display: block; margin-bottom: 8px; font-size: 15px; }
.selection-help p { margin: 5px 0; font-size: 13px; }
.selection-help button { margin-top: 8px; min-height: 40px; }
.material-choice .outlet-tag { color: #b00020; font-weight: 900; font-size: 1.05em; }
.material-choice .automotive-tag { display: inline-block; margin-left: 6px; padding: 2px 7px; border-radius: 999px; background: #17694d; color: #fff; font-weight: 800; font-size: .9em; line-height: 1.4; vertical-align: middle; }
.demo-intro-dialog p, .install-dialog p, .install-dialog li { line-height: 1.5; }
.demo-intro-dialog .dialog-actions { display: flex; flex-wrap: wrap; gap: 9px; }
.install-dialog ol { padding-left: 24px; }
.install-dialog li { margin: 10px 0; }
.install-dialog .install-icon { display: inline-grid; width: 27px; height: 27px; place-items: center; margin-right: 7px; border: 1px solid #b7a391; border-radius: 7px; color: #145b83; font-weight: 800; }
.demo-dialog { width: min(900px, calc(100vw - 20px)); max-height: calc(100dvh - 20px); overflow: auto; padding: clamp(14px, 2vw, 22px); border: 1px solid #d7d8d1; border-radius: 18px; background: #fff; color: var(--ink); box-shadow: 0 18px 50px #0005; }
.demo-dialog::backdrop { background: #112219b8; }
.demo-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.demo-top h2 { margin: 4px 0 15px; font-size: clamp(17px, 3vw, 23px); }
.demo-top .dialog-close { position: static; float: none; margin: -7px -7px 0 0; }
.demo-body { display: grid; grid-template-columns: minmax(120px, .82fr) minmax(220px, 1.18fr); gap: clamp(12px, 2vw, 24px); min-height: 330px; }
.demo-photo { position: relative; display: grid; place-items: center; overflow: hidden; min-height: 320px; border-radius: 14px; background: #f6f4ef; }
.demo-photo img { width: auto; max-width: 100%; height: min(53dvh, 475px); object-fit: contain; }
.demo-selection { position: absolute; width: 49%; height: 34%; top: 17%; left: 26%; border: 3px dashed #00a77b; border-radius: 45% 45% 20% 20%; background: #32d0a950; pointer-events: none; }
.demo-material { position: absolute; width: 58%; height: 27%; top: 48%; left: 21%; border-radius: 50%; background: url("assets/tecoman-aqua.png") center / 120px; opacity: .68; mix-blend-mode: multiply; pointer-events: none; }
.demo-explanation { display: flex; flex-direction: column; justify-content: center; min-width: 0; }
.demo-step-label { margin: 0 0 14px; color: #704628; font-weight: 800; text-transform: uppercase; letter-spacing: .03em; }
.demo-control { position: relative; min-height: 90px; display: grid; place-items: center; border: 1px dashed #b6c7c0; border-radius: 15px; background: #f8faf8; }
.demo-target { max-width: calc(100% - 30px); min-width: 150px; pointer-events: none; box-shadow: 0 4px 0 #352113, 0 6px 11px #22120c77; }
.demo-target.demo-pressed { transform: translateY(4px); box-shadow: 0 1px 0 #352113, 0 2px 5px #22120c77; }
.demo-pointer { position: absolute; z-index: 2; left: calc(50% + 48px); top: 3px; font-size: 37px; transform: translate(0, 0) rotate(-18deg); opacity: 0; transition: transform .55s ease, opacity .25s ease; pointer-events: none; filter: drop-shadow(0 2px 2px #0007); }
.demo-pointer.demo-moving { opacity: 1; transform: translate(-55px, 34px) rotate(-5deg); }
.demo-bubble { align-self: center; min-height: 120px; margin-top: 17px; padding: 17px; border: 2px solid #86c6e5; border-radius: 16px; background: #dff4ff; color: #111; box-shadow: 0 5px 16px #12445b2b; font-size: clamp(15px, 1.9vw, 18px); line-height: 1.45; }
.demo-final { text-align: center; padding: 25px 15px; }
.demo-final h3 { font-size: 25px; }
.demo-transport { display: flex; align-items: center; flex-wrap: wrap; gap: 9px; border-top: 1px solid var(--line); margin-top: 14px; padding-top: 14px; }
.demo-transport .button { min-height: 40px; padding: 8px 12px; }
.demo-transport span { margin-left: auto; font-weight: 700; }
@media (max-width: 600px) {
  .topbar-head { gap: 3px; }
  .topbar-utilities { gap: 4px; }
  .brand-logo { width: 39px; height: 39px; flex-basis: 39px; }
  .brand { gap: 5px; }
  .topbar strong { font-size: clamp(15px, 4vw, 19px); }
  .topbar small { font-size: 10px; }
  .help-button { width: 38px; height: 38px; min-height: 38px; font-size: 23px; }
  .share-app-button, .install-app-button { width: clamp(59px, 17vw, 76px); flex-basis: clamp(59px, 17vw, 76px); min-height: 42px; padding: 3px 2px; gap: 2px; font-size: 10px; }
  .share-app-button svg, .install-app-button svg { width: 15px; height: 15px; }
  .demo-body { grid-template-columns: 1fr; }
  .demo-photo { min-height: 180px; }
  .demo-photo img { height: min(28dvh, 270px); }
  .demo-bubble { min-height: 0; }
}
@media (max-width: 360px) { .topbar small { display: none; } .share-app-button, .install-app-button { width: 59px; flex-basis: 59px; } }

/* La guía conserva el orden Foto, Zona, Material sin ocupar más altura. */
.flow-progress {
  width: 100%; max-width: none; min-height: 65px; margin: 0;
  padding: 9px max(12px, calc((100vw - 900px) / 2));
  background: #f7f4ef; border-bottom: 1px solid #d7d0c8;
  gap: clamp(5px, 2vw, 18px);
}
.flow-progress > div { min-width: 58px; gap: 3px; }
.flow-progress > div span { width: 30px; height: 30px; border-width: 2px; font-size: 15px; box-shadow: 0 1px 3px #3c241533; }
.flow-progress > div strong { font-size: clamp(11px, 1.5vw, 14px); }
.flow-progress > i { margin-bottom: 17px; height: 2px; background: #c9c8c7; }
.flow-progress > div[data-state="active"] { color: #5a2f17; }
.flow-progress > div[data-state="active"] span { border-color: #a34d19; box-shadow: 0 2px 4px #3c241544; }

button[data-state="processing"] { opacity: 1; cursor: progress; }
button[data-state="processing"]::before {
  content: ""; display: inline-block; width: 17px; height: 17px; flex: 0 0 17px;
  margin-right: 6px; border: 2px solid currentColor; border-right-color: transparent;
  border-radius: 50%; animation: spin .8s linear infinite;
}
.share-dialog > p:not(.share-status) { margin: 0 0 15px; color: var(--muted); }
.share-options { display: grid; gap: 9px; }
.share-options a.button { text-decoration: none; }
.share-status { min-height: 1.3em; margin: 12px 0 0; color: #386747; font-weight: 700; }
.share-status[data-kind="error"] { color: var(--danger); }
.model-status { display: flex; align-items: center; justify-content: center; gap: 8px; margin: 15px 0 0 !important; color: #704628 !important; font-size: 12px !important; font-weight: 650; }
.mini-spinner, .catalog-status[data-loading="true"]::before, #projectsMessage[data-loading="true"]::before {
  display: inline-block; width: 15px; height: 15px; flex: 0 0 15px;
  border: 2px solid #c6a78c; border-top-color: #633817; border-radius: 50%;
  animation: spin .8s linear infinite; vertical-align: -3px;
}
.catalog-status[data-loading="true"]::before, #projectsMessage[data-loading="true"]::before { content: ""; margin-right: 7px; }

@media (max-width: 600px) {
  .topbar { padding: max(9px, env(safe-area-inset-top)) 11px 13px; }
  .topbar-inner { gap: 8px; }
  .topbar strong { font-size: clamp(17px, 5vw, 22px); }
  .topbar small { display: block; font-size: clamp(10px, 3vw, 12px); }
  .brand-logo { width: 46px; height: 46px; flex-basis: 46px; }
  .topbar-actions { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 7px; }
  .topbar-actions > button { min-height: 46px; padding: 5px 3px; font-size: clamp(11px, 3vw, 13px); white-space: normal; }
  .share-app-button { flex-basis: calc((100% - 14px) / 3); width: calc((100% - 14px) / 3); min-height: 48px; padding: 4px 3px; font-size: clamp(11px, 3vw, 13px); }
  .topbar-actions svg, .share-app-button svg { width: 19px; height: 19px; }
  .flow-progress { margin: 0; padding-block: 8px; }
}
@media (max-width: 360px) {
  .topbar-actions > button { gap: 3px; font-size: 11px; }
  .topbar-actions svg, .share-app-button svg { width: 16px; height: 16px; }
  .share-app-button { gap: 3px; font-size: 11px; }
}
@media (max-width: 600px) {
  .topbar .brand-logo { width: 39px; height: 39px; flex-basis: 39px; }
  .topbar .brand strong { font-size: clamp(15px, 4vw, 19px); }
  .topbar .brand small { font-size: 10px; }
  .topbar-utilities .share-app-button, .topbar-utilities .install-app-button { width: clamp(59px, 17vw, 76px); flex-basis: clamp(59px, 17vw, 76px); min-height: 42px; padding: 3px 2px; gap: 2px; font-size: 10px; }
  .topbar-utilities .share-app-button svg, .topbar-utilities .install-app-button svg { width: 15px; height: 15px; }
}
@media (max-width: 360px) { .topbar .brand small { display: none; } }

/* Sólo el botón Compartir: conservamos dimensiones, textura, relieve y presión. */
.topbar-utilities .share-app-button { justify-content: center; align-items: center; text-align: center; }
.topbar-utilities .share-app-button span { display: block; width: 100%; white-space: normal; line-height: 1.13; }

/* Reproducción guiada aislada de la aplicación real. */
.demo-dialog { width: min(960px, calc(100vw - 16px)); height: min(870px, calc(100dvh - 16px)); max-height: calc(100dvh - 16px); overflow: hidden; padding: 12px; }
.demo-dialog[open] { display: flex; flex-direction: column; }
.demo-top { flex: 0 0 auto; align-items: center; }
.demo-top h2 { margin: 2px 0 9px; }
.demo-body { display: block; flex: 1 1 auto; min-height: 0; overflow: hidden; }
.demo-app { position: relative; height: 100%; overflow-y: auto; overflow-x: hidden; border: 1px solid #d9d2c7; border-radius: 13px; background: #fff; overscroll-behavior: contain; scrollbar-gutter: stable; }
.demo-app button { cursor: default; pointer-events: none; }
.demo-app-header { position: sticky; top: 0; z-index: 3; display: grid; grid-template-columns: minmax(0,1fr) auto; gap: 8px; padding: 10px; background: #a7460b url("assets/piel-cognac-encabezado.png") repeat center/307px 185px; color: #fff; }
.demo-app-brand { display: flex; align-items: center; gap: 8px; min-width: 0; }
.demo-app-brand img { width: 40px; height: 40px; padding: 2px; border-radius: 9px; background: #fff; }
.demo-app-brand span { display: grid; min-width: 0; }
.demo-app-brand strong { font-size: clamp(17px,2.4vw,24px); line-height: 1.05; }
.demo-app-brand small { font-size: clamp(10px,1.45vw,13px); }
.demo-app-utilities { display: flex; align-items: center; gap: 6px; }
.demo-app-utilities button, .demo-app-nav button { color: #fff; font-weight: 750; text-align: center; line-height: 1.15; text-shadow: 0 1px 2px #180b05; box-shadow: inset 0 1px 1px #fff7, inset 0 -2px 2px #110c08a9, 0 3px 0 #23110b, 0 5px 7px #22120c8c; border-radius: 10px; }
.demo-app-utilities button { min-width: 69px; min-height: 39px; padding: 4px 7px; border: 1px solid #ad7a4d; font-size: 11px; }
.demo-help { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 50%; background: #1c7655; font-weight: 800; }
.demo-app-utilities .demo-blue { background: linear-gradient(135deg,#00569cdb,#001c55eb),url("assets/piel-cafe-navegacion.png") center/320px auto; border-color: #1769a9; box-shadow: inset 0 1px 1px #d5edff99, inset 0 -2px 3px #001538bb, 0 3px 0 #001c42, 0 5px 7px #102c43aa; }
.demo-nav { background: #2d1d17 url("assets/piel-cafe-navegacion.png") center/320px auto; }
.demo-app-nav { grid-column: 1/-1; display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 6px; }
.demo-app-nav button { min-height: 41px; padding: 5px 3px; display: flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid #a67d58; font-size: clamp(11px,1.5vw,15px); }
.demo-app-nav svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.8; flex: 0 0 auto; }
.demo-app button.demo-pressed { transform: translateY(3px); filter: brightness(.9); box-shadow: inset 0 2px 4px #120b0a99, 0 1px 0 #23110b; }
.demo-flow { display: flex; align-items: center; gap: 12px; padding: 9px 13px; background: #f7f4ef; border-bottom: 1px solid #d7d0c8; color: #929596; font-size: 13px; font-weight: 800; }
.demo-flow span.active { color: #673617; }
.demo-flow i { flex: 1; height: 2px; background: #c9c8c7; }
.demo-main { display: grid; grid-template-columns: minmax(0,1.1fr) minmax(250px,.9fr); gap: 13px; align-items: start; padding: 14px; }
.demo-main.photo { display: block; }
.demo-photo-intro { text-align: center; }
.demo-photo-intro h3, .demo-panel h3 { margin: 2px 0 7px; color: #1c3028; font-size: clamp(17px,2vw,21px); line-height: 1.2; }
.demo-panel { display: grid; gap: 9px; align-content: start; min-width: 0; }
.demo-panel p { margin: 0 0 6px; color: #64736d; font-size: 14px; line-height: 1.35; }
.demo-image-box { position: relative; display: grid; place-items: center; overflow: hidden; min-height: 315px; border-radius: 12px; background: #efefeb; }
.demo-main.photo .demo-image-box { width: min(100%,300px); min-height: 300px; margin: 0 auto 12px; }
.demo-image-inner { position: relative; width: min(100%,250px); aspect-ratio: 9/16; transform-origin: 50% 48%; transition: transform .4s ease; }
.demo-image-inner img { display: block; width: 100%; height: 100%; object-fit: contain; }
.demo-main.photo .demo-image-inner { width: min(100%,165px); }
.demo-image-hotspot { position: absolute; left: 29%; top: 15%; width: 43%; height: 30%; border: 2px dashed #12745d; border-radius: 45% 45% 25% 25%; background: #0dbea018; }
.demo-mask-back, .demo-upholstery { position: absolute; left: 28%; top: 14%; width: 45%; height: 33%; border-radius: 44% 44% 28% 28%; pointer-events: none; }
.demo-mask-back { border: 2px dashed #14846d; background: #36c9a352; }
.demo-upholstery { border: 2px solid #0f7767; background: url("assets/tecoman-aqua.png") center/80px; opacity: .92; mix-blend-mode: color; }
.demo-upholstery.second-material { background-image: url("assets/vibrant-dove.png"); }
.demo-upholstery.pending-material { opacity: 0; }
.demo-app[data-effect="apply"] .demo-upholstery.pending-material { opacity: .92; }
.demo-app[data-effect="apply2"] .demo-upholstery { background-image: url("assets/vibrant-dove.png"); }
.demo-app.has-material .demo-mask-back { display: none; }
.demo-app[data-effect="apply"] .demo-mask-back { display: none; }
.demo-mask-add, .demo-mask-remove { position: absolute; opacity: 0; pointer-events: none; }
.demo-mask-add { left: 26%; top: 25%; width: 9%; height: 11%; border-radius: 50%; background: #20c99b9e; }
.demo-mask-remove { left: 65%; top: 37%; width: 9%; height: 10%; border-radius: 50%; background: #ff68448f; }
.demo-brush-ring { position: absolute; left: 65%; top: 39%; width: 20px; height: 20px; border: 2px solid #072c25; border-radius: 50%; opacity: 0; }
.demo-app[data-screen="correction"] .demo-mask-remove { opacity: 1; }
.demo-app[data-screen="correction"] .demo-mask-add { opacity: .3; }
.demo-app.has-added .demo-mask-add { opacity: 1; }
.demo-app.has-removed .demo-mask-remove { opacity: 0; }
.demo-app.is-zoomed .demo-image-inner { transform: scale(1.5); }
.demo-app[data-effect="add"] .demo-mask-add, .demo-app[data-effect="brush"] .demo-mask-add, .demo-app[data-effect="remove"] .demo-mask-add, .demo-app[data-effect="zoom"] .demo-mask-add, .demo-app[data-effect="fit"] .demo-mask-add, .demo-app[data-effect="confirm"] .demo-mask-add { opacity: 1; }
.demo-app[data-effect="remove"] .demo-mask-remove, .demo-app[data-effect="zoom"] .demo-mask-remove, .demo-app[data-effect="fit"] .demo-mask-remove, .demo-app[data-effect="confirm"] .demo-mask-remove { opacity: 0; }
.demo-app[data-effect="brush"] .demo-brush-ring { opacity: 1; width: 16px; height: 16px; }
.demo-app[data-effect="zoom"] .demo-image-inner { transform: scale(1.5); }
.demo-app[data-effect="neutralPan"] .demo-image-inner { transform: translate(18px, -8px); }
.demo-app[data-effect="pinchIn"] .demo-image-inner { transform: scale(1.5); }
.demo-app[data-effect="pinchOut"] .demo-image-inner { transform: scale(1); }
.demo-app[data-effect="pinchPan"] .demo-image-inner { transform: translate(16px, -10px) scale(1.5); }
.demo-finger { position: absolute; z-index: 3; width: 31px; height: 31px; border: 3px solid #196587; border-radius: 50%; background: #dff4ffbb; box-shadow: 0 2px 8px #0008; opacity: 0; pointer-events: none; transition: transform 1s ease, opacity .2s ease; }
.demo-finger.first { left: 45%; top: 48%; }
.demo-finger.second { left: 55%; top: 48%; }
.demo-app[data-effect="neutralPan"] .demo-finger.first, .demo-app[data-effect="paint"] .demo-finger.first, .demo-app[data-effect="erase"] .demo-finger.first, .demo-app[data-effect="pinchIn"] .demo-finger.first, .demo-app[data-effect="pinchOut"] .demo-finger.first, .demo-app[data-effect="pinchPan"] .demo-finger.first { opacity: 1; }
.demo-app[data-effect="pinchIn"] .demo-finger.second, .demo-app[data-effect="pinchOut"] .demo-finger.second, .demo-app[data-effect="pinchPan"] .demo-finger.second { opacity: 1; }
.demo-app[data-effect="neutralPan"] .demo-finger.first { transform: translate(24px, -12px); }
.demo-app[data-effect="paint"] .demo-finger.first { transform: translate(-20px, 22px); }
.demo-app[data-effect="erase"] .demo-finger.first { transform: translate(26px, 14px); }
.demo-app[data-effect="pinchIn"] .demo-finger.first { transform: translate(-31px, 0); }
.demo-app[data-effect="pinchIn"] .demo-finger.second { transform: translate(31px, 0); }
.demo-app[data-effect="pinchOut"] .demo-finger.first { transform: translate(9px, 0); }
.demo-app[data-effect="pinchOut"] .demo-finger.second { transform: translate(-9px, 0); }
.demo-app[data-effect="pinchPan"] .demo-finger.first { transform: translate(12px, -14px); }
.demo-app[data-effect="pinchPan"] .demo-finger.second { transform: translate(12px, -14px); }
.demo-photo-buttons { display: flex; justify-content: center; gap: 9px; flex-wrap: wrap; }
.demo-photo-buttons .button { min-height: 43px; text-transform: uppercase; font-size: 12px; }
.demo-candidates { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 7px; }
.demo-candidate { min-width: 0; padding: 6px; border: 1px solid #d8d6d0; border-radius: 10px; background: #f5f4f0; color: #0876bf; font-weight: 800; font-size: 12px; }
.demo-candidate.chosen { border: 2px solid #13846e; }
.demo-candidate-mini { display: block; position: relative; width: 100%; height: 86px; overflow: hidden; background: #eaeae7; }
.demo-candidate-mini img { display: block; height: 100%; margin: auto; }
.demo-candidate-mini i { position: absolute; left: 39%; top: 13%; width: 21%; height: 34%; border-radius: 40%; background: #2acc9c88; }
.demo-candidate.variant-2 .demo-candidate-mini i { left: 29%; top: 38%; width: 43%; height: 23%; border-radius: 50%; }
.demo-candidate.variant-3 .demo-candidate-mini i { left: 40%; top: 14%; width: 19%; height: 26%; }
.demo-candidate.variant-4 .demo-candidate-mini i { left: 29%; top: 13%; width: 43%; height: 48%; border-radius: 35%; }
.demo-tools { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 5px; }
.demo-tool, .demo-fit { min-height: 39px; padding: 5px; border: 1px solid #b8bfb8; border-radius: 9px; background: #f7f8f6; color: #18392f; font-weight: 750; font-size: 12px; }
.demo-add { background: #edf8f0; border-color: #8bbda7; color: #195b40; }
.demo-remove { background: #fff1ef; border-color: #e3ada8; color: #8b3430; }
.demo-app[data-effect="addToggle"] .demo-add, .demo-app[data-effect="paint"] .demo-add { background: #bde8cd; border: 2px solid #28764f; text-decoration: underline; }
.demo-app[data-effect="removeToggle"] .demo-remove, .demo-app[data-effect="erase"] .demo-remove, .demo-app[data-effect="pinchIn"] .demo-remove, .demo-app[data-effect="pinchOut"] .demo-remove, .demo-app[data-effect="pinchPan"] .demo-remove { background: #ffd9d4; border: 2px solid #ae5750; text-decoration: underline; }
.demo-range-label { display: flex; justify-content: space-between; margin-top: 5px; font-size: 13px; font-weight: 750; }
.demo-range { position: relative; width: 100%; height: 27px; border: 0; background: transparent; }
.demo-range::before { content: ""; position: absolute; left: 2px; right: 2px; top: 12px; height: 4px; border-radius: 3px; background: #a2afa8; }
.demo-range span { position: absolute; top: 3px; left: 25%; width: 20px; height: 20px; border: 3px solid #fff; border-radius: 50%; background: #176f60; box-shadow: 0 1px 4px #1237; }
.demo-app[data-effect="zoom"] [data-demo="zoom"] span { left: 53%; }
.demo-app[data-effect="brush"] [data-demo="brush"] span { left: 13%; }
.demo-category-list { display: grid; gap: 5px; }
.demo-category-card { display: grid; grid-template-columns: 34px minmax(0,1fr) 14px; align-items: center; gap: 8px; width: 100%; min-height: 42px; padding: 4px 9px 4px 4px; border: 1px solid #d4d8d0; border-radius: 9px; background: #fff; color: #203d32; text-align: left; }
.demo-category-card strong { font-size: 12px; }
.demo-category-placeholder { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 6px; background: #eee9e1; color: #766754; font-size: 18px; }
.demo-app[data-effect="categoryClick"] [data-demo="categoryCard"] { border: 2px solid #18836b; background: #f3faf6; }
.demo-filter-row { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 6px; }
.demo-filter { display: grid; min-width: 0; gap: 4px; font-size: 12px; font-weight: 750; color: #264c3b; }
.demo-select { width: 100%; min-width: 0; min-height: 43px; padding: 6px 8px; border: 1px solid #5a9a78; border-radius: 9px; background: #e7f3ea; text-align: left; color: #173b2a; font-weight: 700; }
.demo-category-options { display: grid; gap: 2px; margin: 3px 0; padding: 4px; border: 1px solid #9fbdab; border-radius: 8px; background: #fff; font-size: 11px; }
.demo-category-options > * { min-height: 25px; padding: 4px 8px; border: 0; background: transparent; color: #173b2a; text-align: left; font: inherit; }
.demo-category-options [data-demo="categoryOption"] { background: #dff2e7; font-weight: 800; }
.demo-material-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 7px; }
.demo-swatch { display: grid; gap: 3px; min-width: 0; padding: 7px; border: 1px solid #d5dad4; border-radius: 9px; background: #fff; color: #1a3027; font-size: 12px; font-weight: 700; }
.demo-swatch img { width: 100%; height: 54px; object-fit: cover; border-radius: 5px; }
.demo-app[data-effect="variant"] [data-demo="variant"], .demo-app[data-effect="variant2"] [data-demo="variant2"] { border: 3px solid #18836b; }
.demo-result-buttons { display: grid; gap: 7px; }
.demo-pointer { position: fixed; z-index: 8; width: 31px; height: 31px; pointer-events: none; transform: translate(-5px,-4px); filter: drop-shadow(0 2px 2px #000b); opacity: 1; }
.demo-pointer svg { display: block; width: 100%; height: 100%; fill: #fff; stroke: #17252a; stroke-width: 2.3; stroke-linejoin: round; }
.demo-bubble { position: fixed; z-index: 9; margin: 0; min-height: 0; padding: 12px 13px; border: 2px solid #86c6e5; border-radius: 13px; background: #dff4ff; color: #111; box-shadow: 0 5px 16px #12445b4d; font-size: clamp(13px,1.7vw,16px); line-height: 1.37; font-weight: 650; overflow: auto; }
.demo-transport { flex: 0 0 auto; margin-top: 8px; padding-top: 8px; gap: 6px; }
.demo-transport .button { min-height: 38px; }
.demo-transport span { font-size: 12px; }
.demo-final { flex: 1; display: grid; place-content: center; }
.demo-final[hidden], .demo-body[hidden], .demo-bubble[hidden], .demo-pointer[hidden] { display: none !important; }
@media (max-width: 640px) {
  .demo-dialog { width: 100vw; max-width: 100vw; height: 100dvh; max-height: 100dvh; margin: 0; padding: max(8px,env(safe-area-inset-top)) 7px max(8px,env(safe-area-inset-bottom)); border-radius: 0; }
  .demo-app { scrollbar-gutter: auto; }
  .demo-main { grid-template-columns: 1fr; padding: 10px; gap: 10px; }
  .demo-image-box { min-height: 240px; max-height: 310px; }
  .demo-image-inner { width: min(100%,165px); }
  .demo-main:not(.photo) .demo-image-box { min-height: 180px; max-height: 180px; }
  .demo-main:not(.photo) .demo-image-inner { width: min(100%,101px); }
  .demo-main.photo .demo-image-box { min-height: 245px; max-height: 300px; }
  .demo-main.photo .demo-image-inner { width: min(100%,170px); }
  .demo-panel { padding-bottom: 7px; }
  .demo-app-header { padding: 7px; }
  .demo-app-brand img { width: 35px; height: 35px; }
  .demo-app-brand strong { font-size: 15px; }
  .demo-app-brand small { font-size: 9px; }
  .demo-app-utilities { gap: 3px; }
  .demo-help { width: 27px; height: 27px; }
  .demo-app-utilities button { min-width: 51px; min-height: 34px; padding: 3px; font-size: 9px; }
  .demo-app-nav button { min-height: 36px; gap: 3px; font-size: 10px; }
  .demo-app-nav svg { width: 15px; height: 15px; }
  .demo-flow { gap: 6px; padding: 7px; font-size: 11px; }
  .demo-transport .button { min-height: 36px; padding: 6px 8px; font-size: 12px; }
  .demo-transport span { width: 100%; margin: 0; text-align: center; }
}

/* Área de trabajo: foto y zonas disponibles dentro de la misma pantalla. */
body[data-view="result"] .flow-progress { display: grid; width: min(1220px, 100%); height: 60px; margin: 0 auto; padding: 4px 18px; background: #f8f6f2; }
body[data-view="result"] .workspace {
  width: min(1220px, 100%);
  flex: 0 0 auto;
  height: calc(var(--workspace-viewport-height, 100dvh) - 60px);
  min-height: 540px;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 8px;
  padding: 8px 14px max(10px, env(safe-area-inset-bottom));
  overflow: hidden;
}
body[data-view="result"] .simulation-notice { grid-column: 1; width: 100%; margin: 0; padding: 8px 12px; font-size: 12px; }
body[data-view="result"] .stage-card { min-width: 0; min-height: 0; height: 100%; border-radius: 18px; }
body[data-view="result"] .editor,
body[data-view="result"] .canvas-wrap { min-height: 0; height: 100%; }
body[data-view="result"] .controls {
  display: block;
  min-width: 0;
  max-height: min(48dvh, 400px);
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 8px 12px 10px;
  border-radius: 18px;
}
body[data-view="result"] .zones-panel { margin: 0; padding: 0; border: 0; background: transparent; }
body[data-view="result"] .zones-heading h2 { margin: 0; font-size: 18px; color: #382519; }
body[data-view="result"] .zones-heading p { font-size: 12px; }
.zone-selector-row { display: flex; align-items: stretch; gap: 8px; min-width: 0; margin-top: 8px; }
body[data-view="result"] .zones-list {
  display: flex;
  flex: 1 1 auto;
  min-width: 0;
  gap: 8px;
  margin: 0;
  padding: 1px 1px 5px;
  overflow-x: auto;
  overflow-y: hidden;
  scroll-snap-type: x proximity;
  scrollbar-width: thin;
}
body[data-view="result"] .zone-item {
  display: flex;
  align-items: center;
  flex: 0 0 158px;
  gap: 8px;
  min-width: 0;
  min-height: 65px;
  padding: 6px;
  text-align: left;
  scroll-snap-align: start;
  cursor: pointer;
}
.zone-item canvas { position: static; display: block; flex: 0 0 48px; width: 48px; height: 48px; border-radius: 8px; background: #edece8; }
.zone-item > span { min-width: 0; }
.zone-item strong, .zone-item small { display: block; }
.zone-item strong { color: #332216; font-size: 14px; }
.zone-item small { margin-top: 3px; color: #5d625e; font-size: 11px; line-height: 1.2; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
body[data-view="result"] .zone-item.selected { border: 2px solid #409174; background: #edf8f3; box-shadow: 0 2px 6px #143f2c30; }
.add-zone-card { flex: 0 0 108px; min-height: 65px; padding: 6px; display: flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid #b8d5ca; border-radius: 12px; background: #eef8f4; color: #1c4738; font-size: 12px; line-height: 1.15; font-weight: 750; cursor: pointer; }
.add-zone-card span { width: 27px; height: 27px; flex: 0 0 auto; display: grid; place-items: center; border-radius: 50%; background: #237457; color: white; font-size: 23px; line-height: 1; }
.add-zone-card:disabled { opacity: .48; cursor: not-allowed; }
.selected-zone-details { margin-top: 7px; padding: 9px 11px; border: 1px solid #d4ddd6; border-radius: 14px; background: #fff; }
.selected-zone-heading { display: flex; align-items: center; gap: 7px; min-width: 0; }
.selected-zone-heading strong { font-size: 15px; color: #332216; }
.selected-pill { padding: 3px 7px; border-radius: 99px; background: #d7efe3; color: #205a44; font-size: 11px; font-weight: 750; }
#selectedZoneSummary { margin-left: auto; min-width: 0; color: #625e59; font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.selected-material { display: flex; align-items: center; gap: 8px; margin: 7px 0; }
.selected-material img { width: 44px; height: 44px; flex: 0 0 44px; object-fit: cover; border-radius: 8px; background: #eeece8; }
.selected-material strong, .selected-material span { display: block; }
.selected-material strong { font-size: 13px; color: #30241c; }
.selected-material span { margin-top: 2px; font-size: 12px; color: #69655f; }
.selected-zone-actions { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 6px; }
.selected-zone-actions button { min-width: 0; min-height: 43px; padding: 5px 7px; border: 1px solid #c8c9c3; border-radius: 9px; background: #fdfcf9; color: #36291e; font-size: 11px; line-height: 1.2; font-weight: 750; cursor: pointer; box-shadow: 0 2px 0 #b7b7b0; }
.selected-zone-actions .delete-zone { border-color: #dcaaa5; background: #fff1ef; color: #a43731; box-shadow: 0 2px 0 #d8aaa5; }
.selected-zone-actions button:active { transform: translateY(2px); box-shadow: none; }
body[data-view="result"] .post-actions { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 7px; margin: 7px 0 0; }
body[data-view="result"] .post-actions .result-heading { display: none; }
body[data-view="result"] .post-actions .button { min-height: 37px; padding: 7px; font-size: 12px; }
body[data-view="result"] .post-actions .finished-state { grid-column: 1 / -1; padding: 7px; }
body[data-view="result"] .correction-actions { margin: 5px 0 0; padding: 0; border: 0; }
body[data-view="result"] .correction-actions h2 { display: none; }
body[data-view="result"] .correction-actions > div { display: flex; justify-content: space-between; gap: 6px; }
body[data-view="result"] .correction-actions button { min-height: 25px; padding: 0; font-size: 11px; }
.selected-zone-marker { position: absolute; z-index: 5; transform: translate(-50%, -100%); padding: 5px 10px; border: 2px solid white; border-radius: 999px; background: #bc4542; color: white; font-size: 12px; font-weight: 800; white-space: nowrap; box-shadow: 0 3px 10px #0005; pointer-events: none; }
body[data-view="result"] .workspace-toolbar { position: absolute; z-index: 7; top: 10px; right: 10px; width: 94px; max-height: calc(100% - 20px); overflow-y: auto; overscroll-behavior: contain; padding: 4px; border: 1px solid #fff9; border-radius: 18px; background: #fffffff0; box-shadow: 0 5px 18px #0003; backdrop-filter: blur(12px); touch-action: pan-y; }
.workspace-toolbar .toolbar-heading { display: flex; justify-content: space-between; gap: 4px; }
.workspace-toolbar .toolbar-heading button { width: 32px; height: 27px; border: 0; border-radius: 9px; background: #f1f0ed; color: #443021; font-size: 20px; line-height: 1; cursor: pointer; }
.workspace-toolbar .toolbar-heading .toolbar-drag { cursor: grab; touch-action: none; }
.workspace-toolbar.dragging .toolbar-drag { cursor: grabbing; }
.workspace-toolbar .toolbar-body { display: grid; gap: 4px; }
.workspace-toolbar.collapsed { width: 39px; padding: 3px; }
.workspace-toolbar.collapsed .toolbar-body, .workspace-toolbar.collapsed .toolbar-drag { display: none; }
.workspace-toolbar.collapsed .toolbar-heading { justify-content: center; }
.workspace-toolbar .toolbar-action { width: 100%; min-height: 55px; display: grid; place-items: center; gap: 2px; padding: 4px 2px; border: 0; border-radius: 12px; background: #fff; color: #35291f; font-size: 11px; line-height: 1.1; font-weight: 720; cursor: pointer; }
.workspace-toolbar .toolbar-action > span:first-child { font-size: 22px; line-height: 1; }
body[data-view="result"] .inspection-controls { position: static; display: flex; flex-direction: column; align-items: center; gap: 1px; width: 100%; padding: 2px; border: 0; border-radius: 12px; background: #fff; box-shadow: none; backdrop-filter: none; }
body[data-view="result"] .inspection-controls button { width: 30px; height: 28px; min-height: 28px; border: 0; font-size: 20px; line-height: 1; }
body[data-view="result"] .inspection-controls input[type="range"] { width: 32px; height: clamp(72px, 16dvh, 200px); min-width: 32px; margin: 3px 0; writing-mode: vertical-lr; direction: rtl; appearance: none; -webkit-appearance: none; background: linear-gradient(#9f9c96, #653c1d) center / 6px 100% no-repeat; border-radius: 20px; touch-action: none; cursor: pointer; }
body[data-view="result"] .inspection-controls input[type="range"]::-webkit-slider-runnable-track { width: 32px; height: 100%; background: transparent; }
body[data-view="result"] .inspection-controls input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; width: 28px; height: 28px; border: 2px solid #e7e2d9; border-radius: 50%; background: #fff; box-shadow: 0 2px 7px #0004; }
body[data-view="result"] .inspection-controls input[type="range"]::-moz-range-track { width: 6px; border-radius: 10px; background: #775233; }
body[data-view="result"] .inspection-controls input[type="range"]::-moz-range-thumb { width: 25px; height: 25px; border: 2px solid #e7e2d9; border-radius: 50%; background: #fff; box-shadow: 0 2px 7px #0004; }
body[data-view="result"] .inspection-zoom-label { display: grid; justify-items: center; gap: 0; font-size: 11px; }
body[data-view="result"] .inspection-zoom-label output { font-size: 12px; text-align: center; }
@media (max-height: 900px) {
  body[data-view="result"] .workspace-toolbar { top: 7px; max-height: calc(100% - 14px); }
  body[data-view="result"] .workspace-toolbar .toolbar-heading button { height: 22px; }
  body[data-view="result"] .workspace-toolbar .toolbar-action { min-height: 38px; font-size: 10px; }
  body[data-view="result"] .workspace-toolbar .toolbar-action > span:first-child { font-size: 18px; }
  body[data-view="result"] .inspection-controls button { height: 23px; min-height: 23px; }
  body[data-view="result"] .inspection-zoom-label { font-size: 10px; }
}
@media (max-width: 820px) {
  body[data-view="result"] .workspace { display: grid; padding: 4px 0 max(6px, env(safe-area-inset-bottom)); gap: 5px; }
  body[data-view="result"] .stage-card { min-height: 0; border-radius: 0; }
  body[data-view="result"] .editor, body[data-view="result"] .canvas-wrap { min-height: 0; }
  body[data-view="result"] .controls { max-height: min(49dvh, 410px); padding: 9px 10px; border-radius: 17px 17px 0 0; }
  body[data-view="result"] .zone-item { flex-basis: 132px; }
  body[data-view="result"] .simulation-notice { font-size: 11px; }
}
@media (max-height: 650px) {
  body[data-view="result"] .controls { max-height: 52dvh; }
  .selected-material { margin: 4px 0; }
  .selected-material img { width: 36px; height: 36px; flex-basis: 36px; }
}

/* La guía muestra los mismos controles del panel final sin llamar al motor. */
.demo-work-image { position: relative; }
.demo-app[data-screen="result"] .demo-main { grid-template-columns: minmax(0,1fr); grid-template-rows: minmax(0,1fr) auto; }
.demo-app[data-screen="result"] .demo-work-image { display: grid; place-items: center; min-height: 0; }
.demo-app[data-screen="result"] .demo-image-box { width: 100%; min-height: 240px; max-height: min(46dvh,370px); }
.demo-app[data-screen="result"] .demo-image-inner { width: min(100%,210px); }
@media (max-width: 640px) {
  .demo-app[data-screen="result"] .demo-image-box { min-height: 180px; max-height: 190px; }
  .demo-app[data-screen="result"] .demo-image-inner { width: min(100%,101px); }
}
.demo-result-zone-label { position: absolute; z-index: 4; top: 18%; left: 40%; padding: 5px 9px; border: 2px solid white; border-radius: 99px; background: #bc4542; color: white; font-size: 11px; font-weight: 800; }
.demo-app.zone-unselected .demo-result-zone-label, .demo-app.zone-unselected .demo-zone-detail, .demo-app.zone-unselected[data-screen="result"] .demo-mask-back { display: none; }
.demo-app.zone-unselected[data-screen="result"] .demo-upholstery { border-color: transparent; -webkit-mask-image: radial-gradient(ellipse at center, #000 52%, transparent 76%); mask-image: radial-gradient(ellipse at center, #000 52%, transparent 76%); }
.demo-result-toolbar { position: absolute; z-index: 5; top: 8px; right: 8px; width: 62px; padding: 4px; display: grid; gap: 4px; border-radius: 14px; background: #fffd; box-shadow: 0 3px 12px #0003; }
.demo-result-toolbar.collapsed { width: 28px; }
.demo-toolbar-head { display: flex; gap: 2px; }
.demo-result-toolbar button { min-width: 0; min-height: 31px; padding: 3px; display: grid; place-items: center; border: 1px solid #e2e0db; border-radius: 8px; background: white; color: #3b291d; font-size: 15px; line-height: 1; }
.demo-result-toolbar small { font-size: 9px; line-height: 1.1; }
.demo-result-zoom { display: grid; justify-items: center; gap: 2px; padding: 2px; border-radius: 9px; background: #fff; }
.demo-result-zoom button { width: 28px; height: 23px; min-height: 23px; }
.demo-result-zoom input[type="range"] { width: 25px; height: clamp(44px, 9dvh, 83px); margin: 2px 0; writing-mode: vertical-lr; direction: rtl; accent-color: #754c30; }
.demo-result-zoom small { display: grid; justify-items: center; }
.demo-result-toolbar.collapsed .demo-toolbar-head [data-demo="toolbarMove"] { display: none; }
.demo-zones-panel h3 { display: flex; justify-content: space-between; align-items: center; }
.demo-zones-panel h3 small { font-size: 11px; font-weight: 500; }
.demo-zone-strip { display: flex; gap: 5px; overflow-x: auto; padding-bottom: 3px; }
.demo-zone-card, .demo-zone-add { flex: 0 0 105px; min-height: 44px; padding: 4px; display: flex; align-items: center; gap: 4px; border: 1px solid #d4d8d2; border-radius: 8px; background: white; color: #30291f; text-align: left; font-size: 10px; }
.demo-zone-card.selected { border: 2px solid #469778; background: #eaf6f0; }
.demo-app.zone-unselected .demo-zone-card.selected { border: 1px solid #d4d8d2; background: white; }
.demo-zone-card > span { width: 27px; height: 27px; display: grid; place-items: center; border-radius: 5px; background: #cfb3a8; }
.demo-zone-card b small { display: block; margin-top: 2px; color: #5d665f; white-space: nowrap; }
.demo-zone-add { flex-basis: 85px; background: #edf8f3; color: #27604a; font-weight: 750; }
.demo-zone-detail { margin-top: 7px; padding: 7px; border: 1px solid #d7ddd6; border-radius: 9px; background: white; }
.demo-zone-detail > strong { font-size: 12px; }
.demo-zone-detail > strong small { padding: 2px 5px; border-radius: 99px; background: #d7efe3; color: #205a44; font-size: 10px; }
.demo-zone-detail p { margin: 3px 0 6px; font-size: 11px; }
.demo-zone-actions { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 4px; }
.demo-zone-actions button { min-height: 32px; padding: 4px; border: 1px solid #c9cac4; border-radius: 7px; background: #fdfcf9; color: #34291d; font-size: 10px; }
.demo-zone-actions [data-demo="deleteZone"] { border-color: #dca8a4; background: #fff1ef; color: #a43731; }
.demo-zones-panel .demo-result-buttons { grid-template-columns: repeat(2, minmax(0,1fr)); margin-top: 7px; }
.demo-zones-panel .demo-result-buttons .button { min-height: 30px; padding: 4px; font-size: 10px; }
.demo-app[data-effect="toolbarHide"] .demo-result-toolbar { opacity: .45; }
.demo-app[data-effect="toolbarMove"] .demo-result-toolbar { right: auto; left: 9px; }
.demo-app[data-effect="resultGesture"] .demo-image-inner { transform: scale(1.14) translateX(-5px); }
.demo-app[data-effect="resultGesture"] .demo-finger { opacity: 1; }
