/* Alicerce — style.css
 * Layout mobile-first, componentes de wireframe, splash, gaveta, diálogos e impressão.
 * As cores vêm de themes.css (tokens semânticos). */

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body { height: 100%; margin: 0; }
body {
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent;
}
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3, p { margin: 0; }

.visually-hidden {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}
.muted { color: var(--text-muted); }

:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

.skip-link {
  position: absolute; left: 8px; top: -80px; z-index: 3000;
  background: var(--accent-bg); color: var(--accent-fg);
  border: 2px solid var(--btn-border); border-radius: 8px; padding: 10px 14px;
}
.skip-link:focus { top: 8px; }

#app { height: 100dvh; display: flex; flex-direction: column; min-width: 0; }

/* ---------- Ícones e botões ---------- */
.icon {
  width: 22px; height: 22px; flex: none;
  fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
}
.icon-sm { width: 16px; height: 16px; }
.icon-fill { fill: currentColor; stroke: none; }

.icon-btn {
  position: relative;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-width: 44px; min-height: 44px; padding: 0 8px;
  border: 2px solid transparent; border-radius: 10px;
  background: transparent; color: inherit; cursor: pointer; text-decoration: none;
  white-space: nowrap;
}
.icon-btn:hover:not(:disabled) { background: var(--surface-2); border-color: var(--border); }
.icon-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.icon-btn[aria-pressed="true"] {
  background: var(--accent-bg); color: var(--accent-fg); border-color: var(--btn-border);
}
.icon-btn[aria-pressed="true"]::after {
  content: ""; position: absolute; right: 3px; top: 3px; width: 8px; height: 8px;
  border-radius: 50%; background: currentColor;
}
.btn-text { font-size: 0.9rem; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 0 16px; border-radius: 10px; cursor: pointer;
  border: 2px solid var(--border); background: var(--bg); color: var(--text); font-weight: 600;
}
.btn-primary { background: var(--accent-bg); color: var(--accent-fg); border-color: var(--btn-border); }
.btn-secondary:hover { background: var(--surface-2); }
.btn-danger { background: var(--danger-bg); color: var(--danger-fg); border-color: var(--danger-fg); }
.btn:hover { box-shadow: inset 0 0 0 2px currentColor; }

/* ---------- Cabeçalho (suporta Window Controls Overlay) ---------- */
.app-header {
  display: flex; align-items: center; gap: 6px;
  min-height: max(56px, env(titlebar-area-height, 0px));
  padding: 4px max(10px, calc(100vw - env(titlebar-area-x, 0px) - env(titlebar-area-width, 100vw))) 4px max(10px, env(titlebar-area-x, 0px));
  background: var(--header-bg); color: var(--header-fg);
  -webkit-app-region: drag; app-region: drag;
}
.app-header button, .app-header a, .app-header select, .app-header label { -webkit-app-region: no-drag; app-region: no-drag; }
.app-header .icon-btn { color: var(--header-fg); }
.app-header .icon-btn:hover:not(:disabled) { background: transparent; border-color: currentColor; }
.app-header :focus-visible { outline-color: var(--header-fg); }
.spacer { flex: 1; }
.hdr-actions { display: flex; align-items: center; gap: 4px; flex: none; }
.hdr-actions > * { flex: none; }

.brand { display: inline-flex; align-items: center; gap: 8px; color: inherit; text-decoration: none; min-height: 44px; padding: 0 6px; border-radius: 10px; border: 2px solid transparent; }
.brand:hover { border-color: currentColor; }
.brand img { border-radius: 8px; background: #FFFFFF; }
.brand-name { font-weight: 800; font-size: 1.15rem; letter-spacing: 0.02em; }

.project-name {
  display: inline-flex; align-items: center; gap: 6px; min-height: 44px; max-width: 40vw;
  padding: 0 10px; border-radius: 10px; cursor: pointer;
  background: transparent; color: var(--header-fg); border: 2px dashed currentColor;
}
.project-name span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.app-header .hdr-select {
  width: auto; min-width: 0; max-width: 170px; min-height: 44px; padding: 0 10px; border-radius: 10px; cursor: pointer;
  background: var(--header-bg); color: var(--header-fg); border: 2px solid currentColor;
}

.accent-strip { height: 4px; background: var(--itten-gradient); flex: none; }

/* ---------- Barra de ferramentas ---------- */
.toolbar {
  display: flex; align-items: center; gap: 4px; padding: 4px 8px; flex: none;
  overflow-x: auto; background: var(--surface); border-bottom: 2px solid var(--divider);
  scrollbar-width: thin;
}
.tb-group { display: flex; align-items: center; gap: 2px; padding-right: 8px; margin-right: 4px; border-right: 2px solid var(--divider); flex: none; }
.zoom-label { min-width: 62px; font-variant-numeric: tabular-nums; font-weight: 700; }
.save-status { margin-left: auto; padding-left: 8px; font-size: 0.8rem; color: var(--text-muted); white-space: nowrap; flex: none; }

/* ---------- Abas de telas ---------- */
.screens-bar { display: flex; align-items: stretch; gap: 4px; padding: 0 8px; flex: none; background: var(--bg); border-bottom: 2px solid var(--divider); }
.tabs { display: flex; flex: 1; overflow-x: auto; min-width: 0; scrollbar-width: thin; }
.tab {
  flex: none; min-height: 48px; padding: 0 16px; cursor: pointer; white-space: nowrap;
  background: transparent; color: var(--text); border: 2px solid transparent; border-bottom: 4px solid transparent;
}
.tab:hover { background: var(--surface-2); }
.tab[aria-selected="true"] { font-weight: 800; background: var(--surface); border-bottom-color: var(--accent); }
.tab[aria-selected="true"]::before { content: "● "; font-size: 0.7em; vertical-align: 2px; }
.tab-actions { display: flex; align-items: center; flex: none; }

/* ---------- Layout principal ---------- */
.main { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr) auto; }
.workspace { order: 1; }
.palette { order: 2; }

.palette {
  display: flex; flex-direction: row; align-items: stretch; gap: 6px; padding: 6px 8px;
  overflow-x: auto; background: var(--surface); border-top: 2px solid var(--divider);
}
.palette-title { display: none; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-muted); }
.palette-list { display: flex; gap: 6px; }
.palette-group { display: none; margin: 10px 0 2px; font-size: 0.72rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-muted); }
.palette-group:first-child { margin-top: 0; }
.palette-item {
  flex: none; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  min-width: 78px; min-height: 56px; padding: 4px 8px; font-size: 0.72rem; line-height: 1.2; text-align: center;
  background: var(--bg); color: var(--text); border: 2px solid var(--border); border-radius: 10px; cursor: pointer;
  touch-action: manipulation; user-select: none;
}
.palette-item:hover { background: var(--surface-2); }
.drag-ghost {
  position: fixed; z-index: 2500; pointer-events: none; display: flex; align-items: center; gap: 8px;
  padding: 8px 12px; background: var(--bg); color: var(--text); border: 2px dashed var(--accent); border-radius: 10px;
  box-shadow: 0 6px 20px rgba(0,0,0,.3); transform: translate(-50%, -50%);
}
body.is-dragging, body.is-dragging * { cursor: grabbing !important; user-select: none; }

/* ---------- Prancheta ---------- */
.workspace {
  position: relative; display: flex; overflow: auto; padding: 16px;
  background: var(--surface-2); touch-action: none; user-select: none; -webkit-user-select: none;
}
.workspace:focus-visible { outline-offset: -4px; }
.workspace.is-panning { cursor: grabbing; }
.workspace.is-hand, .workspace.is-hand .wf, .workspace.is-hand .wf * { cursor: grab; }
.workspace.is-hand.is-panning, .workspace.is-hand.is-panning .wf, .workspace.is-hand.is-panning .wf * { cursor: grabbing; }
.workspace.is-hand .handle { pointer-events: none; }
.workspace.is-hand .wf { touch-action: none; }
.workspace.is-space { cursor: grab; }
.workspace.is-space .wf { cursor: grab; }
.marquee { position: absolute; z-index: 50; pointer-events: none; box-sizing: border-box; border: calc(1.5px * var(--inv, 1)) dashed var(--art-sel); background: color-mix(in srgb, var(--art-sel) 14%, transparent); }
/* cadeado: elemento travado em sua posição */
.wf.is-locked { cursor: default; }
.wf.is-locked::before {
  content: ""; position: absolute; top: -9px; right: -9px; width: 22px; height: 22px; box-sizing: border-box; z-index: 6; pointer-events: none;
  border: 2px solid #1F2430; border-radius: 50%; background: #FFFFFF url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%231F2430' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='5' y='11' width='14' height='9' rx='2' fill='%231F2430'/%3E%3Cpath d='M8 11V8a4 4 0 018 0v3'/%3E%3C/svg%3E") center / 12px 12px no-repeat;
  transform: scale(var(--inv, 1)); transform-origin: 100% 0;
}
.wf.is-locked.is-selected::after { border-style: dashed; }
.stage-wrap { flex: none; margin: auto; position: relative; }
.stage {
  --wf-ink: #1F2430; --wf-muted: #5B6270; --wf-fill: #EEF0F4; --wf-paper: #FFFFFF; --wf-light: #C9CED8; --wf-soft: #F7F8FA;
  position: relative; transform-origin: 0 0; background: var(--wf-paper);
  box-shadow: 0 0 0 2px var(--border), 0 8px 24px rgba(0, 0, 0, 0.18);
  touch-action: none;
}
.stage.grid-on {
  background-image:
    linear-gradient(to right, #D3D7DF 1px, transparent 1px),
    linear-gradient(to bottom, #D3D7DF 1px, transparent 1px),
    linear-gradient(to right, #EEF0F4 1px, transparent 1px),
    linear-gradient(to bottom, #EEF0F4 1px, transparent 1px);
  background-size: 50px 50px, 50px 50px, 10px 10px, 10px 10px;
}

/* ---------- Elementos do wireframe (também usados na impressão) ---------- */
.wf {
  --wf-ink: #1F2430; --wf-muted: #5B6270; --wf-fill: #EEF0F4; --wf-paper: #FFFFFF; --wf-light: #C9CED8; --wf-soft: #F7F8FA;
  --wf-line: var(--c-line, var(--wf-ink));
  --wf-txt: var(--c-text, var(--wf-ink));
  --wf-mark: var(--c-line, var(--c-text, var(--wf-ink)));
  position: absolute; box-sizing: border-box; color: var(--wf-txt);
  font: 14px/20px system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  cursor: move; touch-action: none; user-select: none; -webkit-user-select: none;
}
.wf-body {
  position: absolute; inset: 0; box-sizing: border-box; overflow: hidden; pointer-events: none;
  display: flex; align-items: center;
}
.wf-label { display: block; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wf-muted { color: var(--c-text, var(--wf-muted)); }

.wf-container .wf-body { border: 2px solid var(--wf-line); border-radius: var(--c-radius, 8px); align-items: flex-start; background: var(--c-bg, transparent); }
.wf-container .wf-label { margin: 8px 12px; font-weight: 600; font-size: 13px; }

.wf-button .wf-body { border: 2px solid var(--wf-line); border-radius: var(--c-radius, 8px); background: var(--c-bg, var(--wf-fill)); justify-content: center; padding: 0 12px; font-weight: 600; }

.wf-input .wf-body { border: 2px solid var(--wf-line); border-radius: var(--c-radius, 6px); background: var(--c-bg, var(--wf-paper)); padding: 0 12px; }

.wf-navbar .wf-body { border: 2px solid var(--wf-line); border-radius: var(--c-radius, 0); background: var(--c-bg, var(--wf-fill)); padding: 0 12px; gap: 16px; }
.wf-navbar .wf-label { font-weight: 600; font-size: 16px; }
.wf-ico { width: 24px; height: 24px; flex: none; }
.wf-ico path, .wf-fill-svg path { fill: none; stroke: var(--wf-mark); stroke-width: 2; stroke-linecap: round; }

.wf-hamburger .wf-body { border: 2px solid var(--wf-line); border-radius: var(--c-radius, 8px); padding: 6px; background: var(--c-bg, transparent); }
.wf-fill-svg { width: 100%; height: 100%; display: block; }
.wf-fill-svg line { stroke: var(--wf-line); stroke-width: 2; }

.wf-image .wf-body { border: 2px solid var(--wf-line); border-radius: var(--c-radius, 0); background: var(--c-bg, var(--wf-soft)); }

.wf-text .wf-body { padding: 4px; align-items: flex-start; background: var(--c-bg, transparent); border-radius: var(--c-radius, 4px); }
.wf-text .wf-text-content { white-space: pre-wrap; word-break: break-word; }

.wf-list .wf-body { border: 2px solid var(--wf-line); border-radius: var(--c-radius, 8px); flex-direction: column; align-items: stretch; justify-content: flex-start; background: var(--c-bg, var(--wf-paper)); }
.wf-li { display: flex; align-items: center; gap: 12px; height: 32px; padding: 0 12px; flex: none; border-bottom: 1px solid var(--wf-light); }
.wf-li:last-child { border-bottom: 0; }
.wf-li i { width: 10px; height: 10px; flex: none; border: 2px solid var(--wf-mark); border-radius: 2px; }

.wf-toggle .wf-body, .wf-checkbox .wf-body, .wf-radio .wf-body { padding: 0 2px; gap: 10px; background: var(--c-bg, transparent); border-radius: 6px; }
.wf-toggle .wf-body { justify-content: space-between; }
.wf-toggle .wf-label, .wf-checkbox .wf-label, .wf-radio .wf-label { flex: 1; }
.wf-switch { width: 44px; height: 24px; flex: none; }
.wf-switch .wf-track { stroke: var(--wf-mark); stroke-width: 2; fill: none; }
.wf-switch .wf-track.on { fill: var(--wf-mark); }
.wf-switch .wf-knob { fill: var(--wf-mark); }
.wf-switch .wf-knob.on { fill: var(--c-bg, var(--wf-paper)); }
.wf-check { width: 20px; height: 20px; flex: none; }
.wf-check rect { fill: var(--c-bg, var(--wf-paper)); stroke: var(--wf-mark); stroke-width: 2; }
.wf-check path { fill: none; stroke: var(--wf-mark); stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }

.wf-divider .wf-body { align-items: center; }
.wf-line { display: block; width: 100%; height: 0; border-top: 2px solid var(--wf-line); }

/* seleção e alças */
.wf:focus-visible { outline: 3px solid var(--art-sel); outline-offset: 4px; }
.wf.is-selected::after {
  content: ""; position: absolute; inset: -4px; border: 2px solid var(--art-sel); border-radius: 4px; pointer-events: none;
}
.wf .handle {
  position: absolute; width: 24px; height: 24px; display: block;
  transform: translate(-50%, -50%) scale(var(--inv, 1)); touch-action: none; z-index: 5;
}
.wf .handle::after {
  content: ""; position: absolute; left: 50%; top: 50%; width: 12px; height: 12px; transform: translate(-50%, -50%);
  background: #FFFFFF; border: 2px solid var(--art-sel);
}
.handle[data-h="nw"] { left: 0; top: 0; cursor: nwse-resize; }
.handle[data-h="n"]  { left: 50%; top: 0; cursor: ns-resize; }
.handle[data-h="ne"] { left: 100%; top: 0; cursor: nesw-resize; }
.handle[data-h="e"]  { left: 100%; top: 50%; cursor: ew-resize; }
.handle[data-h="se"] { left: 100%; top: 100%; cursor: nwse-resize; }
.handle[data-h="s"]  { left: 50%; top: 100%; cursor: ns-resize; }
.handle[data-h="sw"] { left: 0; top: 100%; cursor: nesw-resize; }
.handle[data-h="w"]  { left: 0; top: 50%; cursor: ew-resize; }
.handle[data-h="n"]::after, .handle[data-h="s"]::after, .handle[data-h="e"]::after, .handle[data-h="w"]::after { border-radius: 50%; }

.wf-editor {
  position: absolute; inset: 0; z-index: 10; width: 100%; height: 100%; resize: none; touch-action: auto;
  padding: 6px 10px; margin: 0; background: #FFFFFF; color: #1F2430;
  border: 2px solid var(--art-sel); border-radius: 4px; font: 14px/20px system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  user-select: text; -webkit-user-select: text; cursor: text;
}

/* ---------- Inspetor ---------- */
.inspector { display: none; position: relative; padding: 12px; background: var(--surface); overflow-y: auto; overscroll-behavior: contain; }
body.inspector-open .workspace { padding-bottom: 58vh; }
body.inspector-open .inspector {
  display: block; position: fixed; left: 0; right: 0; bottom: 0; z-index: 40; max-height: 55vh;
  border-top: 3px solid var(--accent); box-shadow: 0 -8px 24px rgba(0,0,0,.25);
}
.inspector-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.inspector-title { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-muted); }
.insp-empty { color: var(--text-muted); font-size: 0.9rem; }
.insp-tabs { display: flex; gap: 6px; margin-bottom: 10px; }
.insp-tab { flex: 1; min-height: 40px; padding: 6px 8px; background: var(--bg); color: var(--text); border: 2px solid var(--border); border-radius: 10px; cursor: pointer; font-size: 0.85rem; font-weight: 600; }
.insp-tab[aria-selected="true"] { background: var(--accent-bg); color: var(--accent-fg); border-color: var(--btn-border); }
.inspector[data-tab="props"] #panel-layers { display: none; }
.inspector[data-tab="layers"] > :not(.inspector-head):not(.insp-tabs):not(#panel-layers) { display: none; }
.layers-hint { margin: 0 0 8px; font-size: 0.78rem; color: var(--text-muted); }
.layers-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.layer-row { position: relative; display: grid; grid-template-columns: minmax(0, 1fr) auto auto auto auto; align-items: center; gap: 2px; background: var(--bg); border: 2px solid var(--border); border-radius: 10px; padding: 2px; }
.layer-row[aria-selected="true"] { border-color: var(--accent); background: var(--surface-2); box-shadow: inset 4px 0 0 var(--accent); }
.layer-row.is-dragging { opacity: 0.45; }
.layer-row.drop-before::before, .layer-row.drop-after::after { content: ""; position: absolute; left: 4px; right: 4px; height: 4px; border-radius: 2px; background: var(--accent); }
.layer-row.drop-before::before { top: -5px; }
.layer-row.drop-after::after { bottom: -5px; }
.layer-main { display: flex; align-items: center; gap: 8px; min-width: 0; min-height: 40px; padding: 2px 6px; background: transparent; color: var(--text); border: 0; border-radius: 8px; cursor: pointer; text-align: left; font: inherit; }
.layer-num { flex: none; min-width: 22px; height: 22px; display: inline-grid; place-items: center; border: 2px solid var(--border); border-radius: 6px; font-size: 0.72rem; font-weight: 700; }
.layer-ico { flex: none; width: 20px; height: 20px; }
.layer-txt { display: flex; flex-direction: column; min-width: 0; line-height: 1.2; }
.layer-name { font-size: 0.85rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.layer-type { font-size: 0.7rem; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.layer-btn { width: 32px; height: 36px; display: inline-grid; place-items: center; padding: 0; background: transparent; color: var(--text); border: 0; border-radius: 8px; cursor: pointer; }
.layer-btn:hover:not(:disabled) { background: var(--surface-2); }
.layer-btn:disabled { opacity: 0.35; cursor: default; }
.layer-btn .icon { width: 18px; height: 18px; }
.layer-btn[aria-pressed="true"] { background: var(--accent-bg); color: var(--accent-fg); }
.layer-row.is-off .layer-main { opacity: 0.55; }
.wf.is-hidden { display: none !important; }
.insp-type { margin-bottom: 10px; }

.field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 12px; min-width: 0; flex: 1; }
.field label, fieldset legend { font-size: 0.85rem; font-weight: 600; }
.field input[type="text"], .field input[type="number"], .field textarea, select {
  width: 100%; min-height: 44px; padding: 8px 10px; border: 2px solid var(--border); border-radius: 8px;
  background: var(--bg); color: var(--text);
}
.field textarea { resize: vertical; min-height: 76px; }
.field-row { display: flex; gap: 10px; }
.field-check { flex-direction: row; align-items: center; gap: 10px; min-height: 44px; }
.field-check input { width: 24px; height: 24px; accent-color: var(--accent); }

/* ---------- Componentes adicionais ---------- */
.wf-fab .wf-body { border: 2px solid var(--wf-line); border-radius: 50%; background: var(--c-bg, var(--wf-fill)); justify-content: center; }
.wf-fab .wf-fill-svg { width: 60%; height: 60%; }
.wf-iconbutton .wf-body { border: 2px solid var(--wf-line); border-radius: var(--c-radius, 8px); background: var(--c-bg, var(--wf-paper)); justify-content: center; padding: 0 6px; font-size: 20px; font-weight: 600; }
.wf-select .wf-body { border: 2px solid var(--wf-line); border-radius: var(--c-radius, 6px); background: var(--c-bg, var(--wf-paper)); padding: 0 12px; gap: 8px; }
.wf-select .wf-label { flex: 1; }
.wf-chev { width: 16px; height: 16px; flex: none; }
.wf-chev path { fill: none; stroke: var(--wf-mark); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.wf-radio-ico circle { fill: var(--c-bg, var(--wf-paper)); stroke: var(--wf-mark); stroke-width: 2; }
.wf-radio-ico circle.dot { fill: var(--wf-mark); stroke: none; }
.wf-slider .wf-body { padding: 0 12px; }
.wf-sl-track { position: relative; width: 100%; height: 8px; box-sizing: border-box; border: 2px solid var(--wf-line); border-radius: 999px; background: var(--c-bg, var(--wf-paper)); overflow: hidden; }
.wf-sl-fill { position: absolute; left: 0; top: 0; bottom: 0; width: 40%; background: var(--wf-mark); }
.wf-sl-thumb { position: absolute; top: 50%; left: calc(14px + 0.4 * (100% - 28px)); width: 20px; height: 20px; box-sizing: border-box; border: 2px solid var(--wf-line); border-radius: 50%; background: var(--c-bg, var(--wf-paper)); transform: translate(-50%, -50%); }
.is-flip-h .wf-sl-fill { left: auto; right: 0; }
.is-flip-h .wf-sl-thumb { left: calc(14px + 0.6 * (100% - 28px)); }
.wf-tabs .wf-body { align-items: stretch; border-bottom: 2px solid var(--wf-line); background: var(--c-bg, transparent); }
.wf-tab { flex: 1; min-width: 0; display: flex; align-items: center; justify-content: center; padding: 0 8px; font-weight: 500; border-bottom: 4px solid transparent; overflow: hidden; white-space: nowrap; }
.wf-tab.on { font-weight: 700; border-bottom-color: var(--wf-mark); }
.is-flip-v.wf-tabs .wf-body { border-bottom: 0; border-top: 2px solid var(--wf-line); }
.is-flip-v .wf-tab { border-bottom: 0; border-top: 4px solid transparent; }
.is-flip-v .wf-tab.on { border-top-color: var(--wf-mark); }
.wf-breadcrumb .wf-body { padding: 0 2px; gap: 8px; background: var(--c-bg, transparent); }
.wf-crumb, .wf-sep { flex: none; white-space: nowrap; }
.wf-crumb:not(.last) { text-decoration: underline; }
.wf-crumb.last { font-weight: 700; }
.wf-bottomnav .wf-body { border: 2px solid var(--wf-line); border-radius: var(--c-radius, 0); background: var(--c-bg, var(--wf-paper)); align-items: stretch; }
.wf-bn { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; }
.wf-bn-ico { width: 20px; height: 20px; box-sizing: border-box; border: 2px solid var(--wf-mark); border-radius: 6px; flex: none; }
.wf-bn.on .wf-bn-ico { background: var(--wf-mark); }
.wf-bn-lbl { font-size: 12px; line-height: 15px; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wf-bn.on .wf-bn-lbl { font-weight: 700; }
.wf-sidebar .wf-body { border: 2px solid var(--wf-line); border-radius: var(--c-radius, 0); background: var(--c-bg, var(--wf-paper)); flex-direction: column; align-items: stretch; justify-content: flex-start; }
.wf-sb-title { flex: none; box-sizing: border-box; height: 45px; padding: 14px 14px 10px; font-size: 16px; font-weight: 700; line-height: 20px; border-bottom: 1px solid var(--wf-light); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wf-sb-item { flex: none; height: 40px; display: flex; align-items: center; gap: 12px; padding: 0 14px; }
.wf-sb-item i { width: 16px; height: 16px; box-sizing: border-box; flex: none; border: 2px solid var(--wf-mark); border-radius: 4px; }
.wf-sb-item.on { background: color-mix(in srgb, var(--wf-txt) 12%, transparent); font-weight: 600; }
.is-flip-h .wf-sb-item { flex-direction: row-reverse; }
.is-flip-h .wf-sb-title { text-align: right; }
.is-flip-v.wf-sidebar .wf-body { flex-direction: column-reverse; }
.is-flip-v .wf-sb-title { border-bottom: 0; border-top: 1px solid var(--wf-light); }
.wf-scrollbar .wf-body { border: 2px solid var(--wf-line); border-radius: 999px; background: var(--c-bg, var(--wf-paper)); }
.wf-sbthumb { position: absolute; left: 2px; right: 2px; top: 2px; height: 40%; background: var(--wf-mark); border-radius: 999px; }
.is-horiz .wf-sbthumb { top: 2px; bottom: 2px; left: 2px; right: auto; width: 40%; height: auto; }
.is-flip-v:not(.is-horiz) .wf-sbthumb { top: auto; bottom: 2px; }
.is-flip-h.is-horiz .wf-sbthumb { left: auto; right: 2px; }
.wf-card .wf-body { border: 2px solid var(--wf-line); border-radius: var(--c-radius, 8px); background: var(--c-bg, var(--wf-paper)); flex-direction: column; align-items: stretch; justify-content: flex-start; }
.wf-card-img { position: relative; flex: 1 1 0; min-height: 0; box-sizing: border-box; border-bottom: 2px solid var(--wf-line); }
.wf-card-img .wf-fill-svg { position: absolute; inset: 0; }
.wf-card-txt { flex: 1 1 0; min-height: 0; padding: 12px; overflow: hidden; display: flex; flex-direction: column; }
.wf-card-title { flex: none; font-size: 15px; font-weight: 700; line-height: 20px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wf-card-desc { font-size: 13px; line-height: 18px; margin-top: 4px; white-space: pre-wrap; overflow: hidden; }
.wf-card-desc:empty { display: none; }
.is-flip-h .wf-card-txt { text-align: right; }
.is-flip-v.wf-card .wf-body { flex-direction: column-reverse; }
.is-flip-v .wf-card-img { border-bottom: 0; border-top: 2px solid var(--wf-line); }
.is-flip-v .wf-card-txt { justify-content: flex-end; }
.wf-modal .wf-body { border: 2px solid var(--wf-line); border-radius: var(--c-radius, 8px); background: var(--c-bg, var(--wf-paper)); flex-direction: column; align-items: stretch; justify-content: flex-start; }
.wf-md-head { flex: none; box-sizing: border-box; height: 46px; padding: 0 14px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--wf-light); }
.wf-md-title { min-width: 0; font-size: 15px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wf-md-x { flex: none; margin-left: 12px; font-size: 20px; line-height: 1; }
.wf-md-body { flex: 1 1 auto; min-height: 0; padding: 14px; font-size: 14px; line-height: 20px; white-space: pre-wrap; overflow: hidden; }
.wf-md-foot { flex: none; box-sizing: border-box; height: 56px; padding: 0 12px; display: flex; align-items: center; justify-content: flex-end; gap: 8px; border-top: 1px solid var(--wf-light); }
.wf-md-btn { box-sizing: border-box; height: 32px; padding: 0 12px; display: flex; align-items: center; font-size: 13px; font-weight: 600; border: 2px solid var(--wf-line); border-radius: 6px; background: var(--c-bg, var(--wf-paper)); }
.wf-md-btn.ghost { border-color: transparent; background: transparent; }
.is-flip-h .wf-md-head, .is-flip-h .wf-md-foot { flex-direction: row-reverse; }
.is-flip-h .wf-md-body, .is-flip-h .wf-md-title { text-align: right; }
.is-flip-h .wf-md-x { margin-left: 0; margin-right: 12px; }
.is-flip-v.wf-modal .wf-body { flex-direction: column-reverse; }
.is-flip-v .wf-md-head { border-bottom: 0; border-top: 1px solid var(--wf-light); }
.is-flip-v .wf-md-foot { border-top: 0; border-bottom: 1px solid var(--wf-light); }
.is-flip-v .wf-md-body { display: flex; flex-direction: column; justify-content: flex-end; }
.wf-toast .wf-body { border: 2px solid var(--wf-line); border-radius: var(--c-radius, 8px); background: var(--c-bg, var(--wf-fill)); padding: 0 14px; gap: 12px; }
.wf-toast .wf-label { flex: 1; font-size: 14px; }
.wf-act { flex: none; font-size: 13px; font-weight: 700; text-decoration: underline; }
.wf-badge .wf-body { border: 2px solid var(--wf-line); border-radius: var(--c-radius, 999px); background: var(--c-bg, var(--wf-fill)); justify-content: center; padding: 0 8px; font-size: 12px; font-weight: 700; }
.wf-chip .wf-body { border: 2px solid var(--wf-line); border-radius: var(--c-radius, 999px); background: var(--c-bg, var(--wf-fill)); justify-content: center; padding: 0 10px; gap: 6px; font-size: 14px; }
.wf-chip-x { width: 12px; height: 12px; flex: none; }
.wf-chip-x path { fill: none; stroke: var(--wf-mark); stroke-width: 2; stroke-linecap: round; }
.wf-tip-box { position: absolute; left: 0; right: 0; top: 0; bottom: 8px; box-sizing: border-box; border: 2px solid var(--wf-line); border-radius: var(--c-radius, 6px); background: var(--c-bg, var(--wf-paper)); display: flex; align-items: center; justify-content: center; padding: 0 10px; font-size: 13px; overflow: hidden; }
.wf-tip-arrow { position: absolute; left: 18px; bottom: 0; width: 16px; height: 10px; }
.wf-tip-arrow .tip-fill { fill: var(--c-bg, var(--wf-paper)); stroke: none; }
.wf-tip-arrow .tip-line { fill: none; stroke: var(--wf-line); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.is-flip-h .wf-tip-arrow { left: auto; right: 18px; }
.is-flip-v .wf-tip-box { top: 8px; bottom: 0; }
.is-flip-v .wf-tip-arrow { bottom: auto; top: 0; transform: scaleY(-1); }
.wf-progress .wf-body { border: 2px solid var(--wf-line); border-radius: 999px; background: var(--c-bg, var(--wf-paper)); }
.wf-pg-fill { position: absolute; left: 0; top: 0; bottom: 0; width: 60%; background: var(--wf-mark); }
.is-flip-h .wf-pg-fill { left: auto; right: 0; }
.wf-skeleton .wf-body { gap: 12px; }
.wf-sk-av { width: 40px; height: 40px; border-radius: 50%; flex: none; background: var(--c-bg, var(--wf-light)); }
.wf-sk-col { flex: 1; min-width: 0; display: flex; flex-direction: column; justify-content: center; gap: 8px; }
.wf-sk-bar { display: block; height: 10px; border-radius: 5px; background: var(--c-bg, var(--wf-light)); }
.is-flip-h .wf-sk-col { align-items: flex-end; }

/* ---------- Espelhamento (Flip): inverte o layout, o texto continua legível ---------- */
.is-flip-h:not(:is(.wf-list, .wf-sidebar, .wf-card, .wf-modal, .wf-tooltip)) .wf-body { flex-direction: row-reverse; }
.is-flip-h .wf-label, .is-flip-h .wf-text-content { text-align: right; }
.is-flip-h .wf-li { flex-direction: row-reverse; }
.is-flip-v.wf-container .wf-body, .is-flip-v.wf-text .wf-body { align-items: flex-end; }
.is-flip-v.wf-list .wf-body { flex-direction: column-reverse; }
.is-flip-v .wf-li { border-bottom: 0; border-top: 1px solid var(--wf-light); }
.is-flip-v .wf-li:last-child { border-top: 0; }

/* ---------- Painel de cantos ---------- */
.insp-lock { margin-top: 12px; padding-top: 10px; border-top: 2px solid var(--divider); }
.insp-corners { margin-top: 14px; padding-top: 12px; border-top: 2px solid var(--divider); }
.radius-presets { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 6px; margin-bottom: 10px; }
.radius-btn {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; min-height: 56px; padding: 4px 2px;
  background: var(--bg); color: var(--text); border: 2px solid var(--border); border-radius: 10px; cursor: pointer; font-size: 0.72rem; font-weight: 600; min-width: 0;
}
.radius-btn[aria-pressed="true"] { background: var(--accent-bg); color: var(--accent-fg); border-color: var(--btn-border); }
.radius-btn svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2.5; }
#radius-range { width: 100%; min-height: 32px; accent-color: var(--accent); }
.corners-grid { margin-bottom: 8px; }
.corner-preview-wrap { display: flex; justify-content: center; align-items: center; min-height: 84px; margin: 6px 0 10px; border: 2px dashed var(--border); border-radius: 10px; background: var(--bg); }
.corner-preview { border: 3px solid var(--text); background: var(--surface); box-sizing: border-box; }

/* ---------- Painel de cores ---------- */
.insp-colors { margin-top: 14px; padding-top: 12px; border-top: 2px solid var(--divider); }
.insp-sub { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-muted); margin-bottom: 8px; }
.seg { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; border: 0; padding: 0; margin: 0 0 10px; }
.seg-opt {
  position: relative; display: flex; flex-direction: column; align-items: flex-start; gap: 2px; min-height: 58px; padding: 6px 8px;
  border: 2px solid var(--border); border-radius: 10px; background: var(--bg); cursor: pointer; font-size: 0.85rem; font-weight: 600; min-width: 0;
}
.seg-opt input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.seg-opt:has(input:checked) { border-width: 4px; padding: 4px 6px; background: var(--surface-2); }
.seg-opt:has(input:checked)::after { content: "✓"; position: absolute; right: 6px; bottom: 3px; font-size: 0.8rem; }
.seg-opt:has(input:focus-visible) { outline: 3px solid var(--focus); outline-offset: 2px; }
.seg-top { display: flex; align-items: center; gap: 6px; }
.seg-chip { width: 16px; height: 16px; border: 2px solid var(--text); border-radius: 4px; flex: none; background: var(--bg); }
.seg-chip.is-default { background: repeating-linear-gradient(135deg, var(--bg) 0 3px, var(--divider) 3px 6px); }
.seg-val { font-weight: 400; font-size: 0.72rem; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: calc(100% - 14px); }
.sw-group { font-size: 0.72rem; font-weight: 700; color: var(--text-muted); margin: 8px 0 4px; }
.sw-row { display: flex; flex-wrap: wrap; gap: 6px; }
.swatch-btn {
  position: relative; width: 34px; height: 34px; padding: 0; cursor: pointer; border-radius: 8px;
  border: 2px solid var(--text); display: inline-flex; align-items: center; justify-content: center;
}
.swatch-btn .icon { width: 20px; height: 20px; stroke-width: 3; visibility: hidden; }
.swatch-btn[aria-pressed="true"] { outline: 3px solid var(--text); outline-offset: 2px; }
.swatch-btn[aria-pressed="true"] .icon { visibility: visible; }
.swatch-btn:hover { transform: scale(1.08); }
.color-custom { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.color-custom label { font-size: 0.85rem; font-weight: 600; flex: 1 1 100%; }
.color-custom input[type="color"] { width: 56px; height: 44px; padding: 2px; border: 2px solid var(--border); border-radius: 8px; background: var(--bg); cursor: pointer; }
.color-custom .btn { flex: 1; min-height: 44px; padding: 0 10px; font-size: 0.85rem; }
.color-info { margin-top: 10px; padding: 8px 10px; border: 2px solid var(--border); border-radius: 8px; font-size: 0.85rem; background: var(--bg); }
.color-info.is-bad { border-width: 4px; border-style: double; }

/* ---------- Rodapé ---------- */
.app-footer {
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 8px; flex: none; min-height: 52px;
  padding: 4px 10px max(4px, env(safe-area-inset-bottom)); background: var(--surface); border-top: 2px solid var(--divider);
}
.footer-tag { font-size: 0.8rem; color: var(--text-muted); }
.footer-links { display: flex; align-items: center; justify-content: flex-end; gap: 6px; }
.footer-zoom { display: flex; align-items: center; justify-content: center; gap: 2px; }
.hdr-sep { width: 2px; height: 28px; margin: 0 4px; background: currentColor; opacity: .35; flex: none; }
.footer-logo img { border-radius: 6px; background: #FFFFFF; }


/* ---------- Barra flutuante do elemento selecionado ---------- */
.sel-bar {
  position: fixed; z-index: 35; display: flex; flex-wrap: wrap; align-items: center; gap: 2px 4px; padding: 4px;
  max-width: calc(100vw - 16px); background: var(--surface); color: var(--text);
  border: 2px solid var(--border); border-radius: 12px; box-shadow: 0 6px 22px rgba(0,0,0,.28);
}
.sel-bar[hidden] { display: none; }
.sel-bar .sb-group { display: flex; align-items: center; gap: 2px; padding-right: 4px; margin-right: 0; border-right: 2px solid var(--divider); }
.sel-bar .sb-group[hidden] { display: none; }
.sel-bar .sb-group:last-child { border-right: 0; padding-right: 0; }
.insp-align-row { display: flex; flex-wrap: wrap; gap: 4px; }
.insp-align-row .icon-btn { border: 2px solid var(--border); border-radius: 8px; }

/* ---------- Gaveta ---------- */
.drawer-backdrop { position: fixed; inset: 0; z-index: 1500; background: var(--overlay); }
.drawer {
  position: fixed; top: 0; bottom: 0; left: 0; z-index: 1600; width: min(340px, 88vw);
  display: flex; flex-direction: column; background: var(--bg); color: var(--text);
  border-right: 3px solid var(--accent); box-shadow: 8px 0 30px rgba(0,0,0,.35);
  transform: translateX(-102%); visibility: hidden; transition: transform .22s ease, visibility 0s linear .22s;
}
.drawer.open { transform: translateX(0); visibility: visible; transition: transform .22s ease, visibility 0s; }
#confirm-msg { white-space: pre-line; }
.drawer-head { display: flex; align-items: center; justify-content: space-between; padding: 8px 10px; background: var(--header-bg); color: var(--header-fg); min-height: 60px; }
.drawer-head .icon-btn { color: var(--header-fg); }
.drawer-head .icon-btn:hover { background: transparent; border-color: currentColor; }
.drawer-head :focus-visible { outline-color: var(--header-fg); }
.drawer-nav { flex: 1; overflow-y: auto; padding: 8px 10px 20px; display: flex; flex-direction: column; gap: 2px; }
.drawer-group { margin: 14px 4px 4px; font-size: 0.75rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-muted); }
.nav-item {
  display: flex; align-items: center; gap: 12px; width: 100%; min-height: 48px; padding: 8px 12px; cursor: pointer;
  border: 2px solid transparent; border-radius: 10px; background: transparent; color: var(--text); text-align: left; text-decoration: none;
}
.nav-item:hover { background: var(--surface-2); border-color: var(--border); }
.theme-fieldset { border: 0; margin: 0; padding: 0; min-width: 0; }
.theme-list { display: flex; flex-direction: column; gap: 6px; }
.theme-opt {
  display: flex; align-items: center; gap: 12px; min-height: 52px; padding: 6px 12px; cursor: pointer;
  border: 2px solid var(--border); border-radius: 10px; background: var(--bg);
}
.theme-opt input { width: 22px; height: 22px; accent-color: var(--accent); flex: none; }
.theme-opt .swatch { width: 44px; height: 28px; border-radius: 6px; flex: none; border: 2px solid var(--text); }
.theme-opt .theme-name { flex: 1; font-weight: 600; }
.theme-opt .theme-sub { display: block; font-size: 0.75rem; font-weight: 400; color: var(--text-muted); }
.theme-opt .icon { visibility: hidden; }
.theme-opt:has(input:checked) { border-width: 4px; padding: 4px 10px; background: var(--surface-2); }
.theme-opt:has(input:checked) .icon { visibility: visible; }
.theme-opt:has(input:focus-visible) { outline: 3px solid var(--focus); outline-offset: 2px; }

/* ---------- Diálogos ---------- */
dialog {
  padding: 0; width: min(520px, calc(100vw - 24px)); max-height: calc(100dvh - 24px); overflow: auto;
  background: var(--surface); color: var(--text); border: 3px solid var(--accent); border-radius: 14px;
}
dialog.dlg-wide { width: min(720px, calc(100vw - 24px)); }
dialog::backdrop { background: var(--overlay); }
.dlg-form { padding: 18px 20px 20px; display: flex; flex-direction: column; gap: 12px; }
.dlg-form h2 { font-size: 1.25rem; }
.dlg-form h3 { font-size: 1rem; margin-top: 6px; }
.dlg-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.dlg-actions { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 8px; margin-top: 6px; }
.action-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 8px; }
.action-grid .btn { justify-content: flex-start; }
.vp-choice { display: flex; gap: 10px; border: 0; padding: 0; margin: 0; flex-wrap: wrap; }
.vp-choice legend { padding: 0; margin-bottom: 6px; }
.vp-option { flex: 1; min-width: 150px; display: flex; align-items: center; gap: 10px; min-height: 56px; padding: 8px 12px; border: 2px solid var(--border); border-radius: 10px; cursor: pointer; background: var(--bg); }
.vp-option small { display: block; color: var(--text-muted); }
.vp-option input { width: 22px; height: 22px; accent-color: var(--accent); }
.vp-option:has(input:checked) { border-width: 4px; padding: 6px 10px; background: var(--surface-2); }
.projects-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; max-height: 55vh; overflow-y: auto; }
.proj-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 10px 12px; border: 2px solid var(--border); border-radius: 10px; background: var(--bg); }
.proj-row.is-current { border-width: 4px; padding: 8px 10px; }
.proj-info { flex: 1 1 200px; min-width: 0; }
.proj-name { font-weight: 700; overflow-wrap: anywhere; }
.proj-meta { font-size: 0.8rem; color: var(--text-muted); }
.proj-actions { display: flex; flex-wrap: wrap; gap: 4px; }
.proj-actions .btn { min-height: 40px; padding: 0 10px; font-size: 0.85rem; }
.about-hero { display: flex; align-items: center; gap: 14px; }
.about-hero img { border-radius: 16px; background: #FFFFFF; border: 2px solid var(--border); }
.about p { line-height: 1.55; }
.shortcuts { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 6px 16px; margin: 0; }
.shortcuts div { display: flex; gap: 10px; align-items: baseline; }
.shortcuts dt { flex: none; min-width: 120px; padding: 1px 6px; font: 600 0.8rem ui-monospace, Consolas, monospace; border: 2px solid var(--border); border-radius: 6px; background: var(--bg); }
.shortcuts dd { margin: 0; font-size: 0.9rem; }
dialog a { color: var(--link); text-decoration: underline; }

/* ---------- Toasts ---------- */
.toasts { position: fixed; z-index: 4000; left: 50%; bottom: 76px; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; width: min(520px, calc(100vw - 24px)); pointer-events: none; }
.toast { padding: 12px 16px; background: var(--toast-bg); color: var(--toast-fg); border: 2px solid var(--toast-fg); border-radius: 10px; box-shadow: 0 6px 20px rgba(0,0,0,.35); font-weight: 600; }
.toast-error { border-width: 4px; border-style: double; }

/* ---------- Splash cinematográfica (exatos 3 s) ---------- */
#splash {
  position: fixed; inset: 0; z-index: 5000; display: grid; place-items: center; overflow: hidden;
  background: var(--itten-gradient); background-size: 160% 160%;
  animation: splash-life 3s linear forwards, splash-bg 3s ease-in-out forwards;
}
@keyframes splash-life { 0%, 86% { opacity: 1; } 100% { opacity: 0; } }
@keyframes splash-bg { from { background-position: 0% 0%; } to { background-position: 100% 100%; } }

.splash-ring { position: absolute; left: 50%; top: 50%; width: 30vmin; height: 30vmin; border-radius: 50%; border: 3px solid rgba(255,255,255,.65); transform: translate(-50%, -50%) scale(.2); opacity: 0; animation: ring 2.4s ease-out infinite; }
.splash-ring.r2 { animation-delay: .5s; }
.splash-ring.r3 { animation-delay: 1s; }
@keyframes ring { 0% { transform: translate(-50%, -50%) scale(.2); opacity: .9; } 100% { transform: translate(-50%, -50%) scale(4.5); opacity: 0; } }
.splash-sweep { position: absolute; inset: -20%; background: linear-gradient(110deg, transparent 40%, rgba(255,255,255,.28) 50%, transparent 60%); transform: translateX(-100%); animation: sweep 1.6s .5s ease-in-out forwards; }
@keyframes sweep { to { transform: translateX(100%); } }

.splash-inner { position: relative; z-index: 2; display: flex; flex-direction: column; align-items: center; gap: clamp(16px, 4vh, 32px); padding: 24px; text-align: center; }
.splash-logo {
  width: clamp(104px, 24vmin, 192px); height: auto; aspect-ratio: 1; border-radius: 24%; background: #FFFFFF;
  padding: 6%; box-shadow: 0 18px 50px rgba(0,0,0,.45);
  animation: logo-in 1.1s cubic-bezier(.2, .9, .2, 1) both, logo-float 3s ease-in-out infinite;
}
@keyframes logo-in { from { transform: scale(.4) rotate(-12deg); opacity: 0; } to { transform: scale(1) rotate(0); opacity: 1; } }
@keyframes logo-float { 0%, 100% { translate: 0 0; } 50% { translate: 0 -8px; } }
.splash-text { display: flex; flex-direction: column; align-items: center; gap: 12px; }
.splash-pill { background: var(--splash-pill-bg); color: var(--splash-pill-fg); border: 3px solid var(--splash-pill-fg); border-radius: 999px; padding: 6px 28px; }
.splash-title { font-size: clamp(2rem, 8vmin, 4rem); font-weight: 800; line-height: 1.2; letter-spacing: .08em; }
.splash-title span { display: inline-block; opacity: 0; animation: letter .6s calc(.5s + var(--i) * .08s) cubic-bezier(.2, .9, .2, 1) forwards; }
@keyframes letter { from { opacity: 0; transform: translateY(24px) scale(.8); } to { opacity: 1; transform: none; } }
.splash-tag { font-size: clamp(.9rem, 2.6vmin, 1.25rem); font-weight: 600; opacity: 0; animation: letter .7s 1.3s ease-out forwards; }
.splash-bar { position: absolute; left: 0; right: 0; bottom: 0; height: 8px; background: #FFFFFF; z-index: 2; }
.splash-bar span { display: block; height: 100%; width: 0; background: var(--splash-pill-bg); animation: bar 3s linear forwards; }
@keyframes bar { to { width: 100%; } }

@media (orientation: landscape) and (min-width: 900px) {
  .splash-inner { flex-direction: row; gap: 56px; text-align: left; }
  .splash-text { align-items: flex-start; }
}
@media (prefers-reduced-motion: reduce) {
  .splash-ring, .splash-sweep, .splash-logo { animation: none; }
  .splash-ring, .splash-sweep { display: none; }
  .splash-title span, .splash-tag { animation: none; opacity: 1; }
  .drawer { transition: none; }
}

/* ---------- Responsividade ---------- */
@media (max-width: 1279.98px) { .hide-mid { display: none !important; } }
@media (min-width: 900px) and (max-width: 1049.98px) {
  .app-header .brand-name { display: none; }
  .project-name { max-width: 20vw; }
  .app-header .hdr-select { max-width: 120px; }
  .hdr-sep { margin: 0 1px; }
}
.only-narrow { display: inline-flex; }
@media (max-width: 899.98px) {
  .hide-narrow { display: none !important; }
  .brand-name { font-size: 1.05rem; }
  .project-name { max-width: 34vw; }
}
@media (min-width: 900px) {
  .only-narrow { display: none !important; }
  .main { grid-template-columns: 208px minmax(0, 1fr) 264px; grid-template-rows: minmax(0, 1fr); }
  .palette { order: 0; flex-direction: column; overflow-x: hidden; overflow-y: auto; border-top: 0; border-right: 2px solid var(--divider); padding: 10px; }
  .palette-title { display: block; margin-bottom: 4px; }
  .palette-list { flex-direction: column; }
  .palette-group { display: block; }
  .palette-item { flex-direction: row; justify-content: flex-start; gap: 10px; min-height: 46px; font-size: 0.9rem; text-align: left; cursor: grab; }
  .workspace { order: 0; padding: 24px; }
  .inspector { display: block; order: 2; border-left: 2px solid var(--divider); }
  body.inspector-open .workspace { padding-bottom: 24px; }
  body.inspector-open .inspector { position: static; max-height: none; box-shadow: none; border-top: 0; }
  .toasts { bottom: 24px; }
}
@media (min-width: 1600px) {
  .main { grid-template-columns: 240px minmax(0, 1fr) 300px; }
}

/* ---------- Impressão limpa: todas as telas do projeto ---------- */
#print-area { display: none; }
@page { margin: 10mm; }
@media print {
  html, body { height: auto; background: #FFFFFF; color: #000000; }
  #app, #drawer, #drawer-backdrop, #splash, dialog, .toasts, .skip-link, .sel-bar { display: none !important; }
  #print-area {
    display: block !important;
    -webkit-print-color-adjust: exact; print-color-adjust: exact;
  }
  .print-page { break-after: page; page-break-after: always; padding: 0; }
  .print-page:last-child { break-after: auto; page-break-after: auto; }
  .print-title { font: 700 14px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif; margin: 0 0 8px; color: #000000; }
  .print-stage-box { position: relative; overflow: hidden; border: 2px solid #1F2430; background: #FFFFFF; }
  .print-stage { position: absolute; left: 0; top: 0; background: #FFFFFF; transform-origin: 0 0; }
  .print-stage .wf { cursor: default; }
  .print-stage .wf::before { display: none !important; }
}

/* Aba Camadas: painel lateral mais largo para caber nome + ações */
@media (min-width: 900px) { body.layers-wide .main { grid-template-columns: 208px minmax(0, 1fr) 340px; } }
@media (min-width: 1600px) { body.layers-wide .main { grid-template-columns: 240px minmax(0, 1fr) 380px; } }
.insp-align { margin-top: 12px; padding-top: 10px; border-top: 2px solid var(--divider); }

/* ---------- Grupos ---------- */
.group-box { position: absolute; z-index: 49; pointer-events: none; box-sizing: border-box; border: calc(1.5px * var(--inv, 1)) dashed var(--art-sel); border-radius: 4px; }
.layer-grp { flex: none; margin-left: 4px; padding: 0 5px; font-size: 11px; font-weight: 700; line-height: 18px; border: 2px solid var(--border); border-radius: 9px; }

/* ---------- Guias inteligentes ---------- */
.snap-guide { position: absolute; z-index: 48; pointer-events: none; background: #d6246e; }
.snap-guide.is-v { width: calc(1px * var(--inv, 1)); margin-left: calc(-0.5px * var(--inv, 1)); }
.snap-guide.is-h { height: calc(1px * var(--inv, 1)); margin-top: calc(-0.5px * var(--inv, 1)); }

/* ---------- Componentes salvos ---------- */
.palette-tabs { display: flex; flex-direction: column; gap: 4px; flex: none; }
.ptab { padding: 6px 10px; font: inherit; font-size: 0.8rem; font-weight: 700; color: var(--text); background: var(--bg); border: 2px solid var(--border); border-radius: 8px; cursor: pointer; text-align: left; }
.ptab[aria-selected="true"] { background: var(--accent-bg); color: var(--accent-fg); }
.ptab-count { font-weight: 400; opacity: .85; }
.saved-panel { display: flex; gap: 6px; }
.saved-panel[hidden], .palette-list[hidden] { display: none; }
.saved-add { flex: none; min-height: 56px; }
.saved-empty { margin: 0; align-self: center; max-width: 34ch; font-size: 0.8rem; color: var(--text-muted); }
.saved-empty[hidden] { display: none; }
.saved-row { display: flex; align-items: stretch; gap: 2px; flex: none; }
.saved-row .palette-item { flex: 1; min-width: 0; }
.saved-row .palette-item span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 12ch; }
.saved-row .saved-n { font-size: 0.7rem; color: var(--text-muted); }
.saved-acts { display: flex; flex-direction: column; justify-content: center; gap: 2px; }
.saved-act { width: 30px; height: 26px; display: grid; place-items: center; padding: 0; color: var(--text); background: var(--bg); border: 2px solid var(--border); border-radius: 6px; cursor: pointer; }
.saved-act .icon { width: 14px; height: 14px; }
@media (min-width: 900px) {
  .palette-tabs { flex-direction: row; margin-bottom: 6px; }
  .ptab { flex: 1; text-align: center; }
  .saved-panel { flex-direction: column; }
  .saved-row .palette-item span { max-width: 14ch; }
}

/* ---------- Modelos de tela ---------- */
.tpl-choice { border: 0; padding: 0; margin: 10px 0 0; }
.tpl-choice legend { padding: 0; margin-bottom: 6px; font-size: 0.85rem; font-weight: 600; }
.tpl-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.tpl-opt { position: relative; display: flex; flex-direction: column; gap: 4px; min-height: 96px; padding: 8px; border: 2px solid var(--border); border-radius: 10px; background: var(--bg); cursor: pointer; min-width: 0; }
.tpl-opt input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.tpl-opt:has(input:checked) { border-width: 4px; padding: 6px; background: var(--surface-2); }
.tpl-opt:has(input:checked)::after { content: "✓"; position: absolute; right: 8px; bottom: 4px; font-size: 0.9rem; }
.tpl-opt:has(input:focus-visible) { outline: 3px solid var(--focus); outline-offset: 2px; }
.tpl-opt strong { font-size: 0.9rem; }
.tpl-opt small { color: var(--text-muted); font-size: 0.75rem; line-height: 1.25; }
.tpl-thumb { display: block; width: 100%; height: 44px; color: var(--text); }
.tpl-hint { margin: 8px 0 0; min-height: 1.3em; font-size: 0.82rem; color: var(--text-muted); }

/* Seta de fluxo e nota (v1.12) */
.wf-arrow .wf-body { padding: 0; }
.wf-arrow-svg { display: block; width: 100%; height: 100%; overflow: visible; }
.wf-arrow-svg line, .wf-arrow-svg polyline { stroke: var(--wf-line); stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round; fill: none; }
.wf-arrow-svg polygon { fill: var(--wf-line); stroke: var(--wf-line); stroke-width: 2; stroke-linejoin: round; }
.wf-note .wf-body { position: relative; align-items: flex-start; box-sizing: border-box; padding: 10px 12px; border: 2px solid var(--wf-line); border-radius: var(--c-radius, 2px); background: var(--c-bg, #FFF3B0); overflow: hidden; }
.wf-note .wf-body::after { content: ''; position: absolute; top: 0; right: 0; width: 16px; height: 16px; background: linear-gradient(45deg, rgba(31,36,48,.22) 50%, transparent 50%); }
.wf-note .wf-text-content { white-space: pre-wrap; word-break: break-word; font-size: 14px; line-height: 20px; }
.is-flip-v.wf-note .wf-body { align-items: flex-end; }

/* Visão geral das telas (v1.13) */
dialog.dlg-overview { width: min(980px, calc(100vw - 24px)); }
.ov-grid { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; max-height: 60vh; overflow: auto; padding: 4px; }
.ov-card { display: flex; flex-direction: column; gap: 6px; padding: 8px; border: 2px solid var(--border); border-radius: 10px; background: var(--bg); }
.ov-card.is-current { border-width: 4px; padding: 6px; }
.ov-card.is-drag { opacity: .45; }
.ov-card.is-over { outline: 3px dashed var(--accent, currentColor); outline-offset: 2px; }
.ov-open { display: block; width: 100%; padding: 0; border: 1px solid var(--border); border-radius: 6px; background: #fff; cursor: pointer; overflow: hidden; }
.ov-open canvas { display: block; width: 100%; height: auto; max-height: 260px; object-fit: contain; }
.ov-meta { display: flex; align-items: center; gap: 4px; }
.ov-name { flex: 1; min-width: 0; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ov-meta .icon-btn { width: 32px; height: 32px; }

/* Réguas (v1.15) */
.ruler { display: none; position: fixed; z-index: 20; pointer-events: none; background: var(--surface); }
body.rulers-on .ruler { display: block; }
body.rulers-on .workspace { margin: 18px 0 0 18px; }
@media print { .ruler { display: none !important; } }
@media (max-width: 520px) { body.rulers-on .workspace { margin: 0; } body.rulers-on .ruler { display: none; } }
@media (max-width: 520px) { .footer-tag { display: none; } .app-footer { grid-template-columns: auto auto; justify-content: space-between; } }

/* Telas estreitas: sem rolagem lateral (v1.16) */
@media (max-width: 680px) {
  .toolbar { flex-wrap: wrap; overflow-x: visible; row-gap: 2px; }
  .toolbar .tb-group { padding-right: 4px; margin-right: 0; }
}
@media (max-width: 420px) { .hide-xs { display: none !important; } }
@media (max-width: 380px) { .app-header .brand-name { display: none; } .hide-xxs { display: none !important; } }

.wf-arrow .wf-body { overflow: visible; }
.wf.is-bound .handle { display: none; }
.wf.is-bound { cursor: pointer; }

.wf-arrow .wf-body { position: relative; }
.wf-arrow-label { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); max-width: 240px; padding: 2px 7px; border: 1.5px solid var(--wf-line); border-radius: 4px; background: var(--wf-paper, #fff); font-size: 12px; font-weight: 600; line-height: 18px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; pointer-events: none; }

/* ---- modo de teste do protótipo (v1.20) ---- */
.wf-go{position:absolute;right:-5px;top:-5px;width:14px;height:14px;border-radius:50%;background:var(--art-sel,#2563eb) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M5 12h13M13 6l6 6-6 6' fill='none' stroke='white' stroke-width='3'/%3E%3C/svg%3E") center/10px no-repeat;z-index:3;pointer-events:none}
.workspace.is-preview .handle,.workspace.is-preview .sel-bar{display:none!important}
.workspace.is-preview .wf{cursor:default}
.workspace.is-preview .wf.has-go{cursor:pointer;animation:goPulse 1.6s ease-in-out infinite}
@keyframes goPulse{0%,100%{box-shadow:0 0 0 0 rgba(37,99,235,.0)}50%{box-shadow:0 0 0 4px rgba(37,99,235,.35)}}
@media (prefers-reduced-motion:reduce){.workspace.is-preview .wf.has-go{animation:none;outline:2px dashed var(--art-sel,#2563eb)}}
.preview-bar{position:fixed;left:50%;bottom:64px;transform:translateX(-50%);z-index:60;display:flex;align-items:center;gap:10px;max-width:calc(100vw - 24px);padding:8px 10px;background:var(--surface,#fff);color:var(--text,#111);border:2px solid var(--art-sel,#2563eb);border-radius:12px;box-shadow:0 6px 24px rgba(0,0,0,.25)}
.preview-bar[hidden]{display:none}
.preview-name{font-weight:600;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
body.preview-on [data-action="preview"]{outline:2px solid var(--art-sel,#2563eb)}

/* ---- alça de rota das setas em L/Z (v1.23) ---- */
.route-handle{position:absolute;width:16px;height:16px;margin:-8px 0 0 -8px;border-radius:50%;background:var(--art-sel,#2563eb);border:2px solid #fff;box-shadow:0 0 0 1px var(--art-sel,#2563eb);cursor:grab;z-index:5;touch-action:none}
.route-handle::after{content:"";position:absolute;inset:-10px}
.workspace.is-preview .route-handle{display:none}

/* ---- religar pontas das setas conectoras (v1.24) ---- */
.end-handle{position:absolute;width:14px;height:14px;margin:-7px 0 0 -7px;border-radius:3px;background:#fff;border:2px solid var(--art-sel,#2563eb);cursor:crosshair;z-index:6;touch-action:none}
.end-handle::after{content:"";position:absolute;inset:-10px}
.wf.is-link-target{outline:3px dashed var(--art-sel,#2563eb);outline-offset:3px}
.workspace.is-preview .end-handle{display:none}

/* lado de ancoragem durante o arrasto */
.wf.is-link-target[data-anchor="t"]{box-shadow:0 -6px 0 0 var(--art-sel,#2563eb)}
.wf.is-link-target[data-anchor="b"]{box-shadow:0 6px 0 0 var(--art-sel,#2563eb)}
.wf.is-link-target[data-anchor="l"]{box-shadow:-6px 0 0 0 var(--art-sel,#2563eb)}
.wf.is-link-target[data-anchor="r"]{box-shadow:6px 0 0 0 var(--art-sel,#2563eb)}

/* ---- mapa do fluxo (v1.29) ---- */
.fm-scroll{max-height:50vh;overflow:auto;border:1px solid var(--border);border-radius:10px;background:var(--bg)}
.fm-wrap{position:relative}
.fm-svg{position:absolute;left:0;top:0;color:var(--text,#111);pointer-events:none}
.fm-edge{fill:none;stroke:currentColor;stroke-width:2.2}
.fm-label-bg{fill:var(--surface,#fff);stroke:currentColor;stroke-width:1.2}
.fm-label{font:600 11px system-ui,sans-serif;fill:currentColor}
.fm-card{position:absolute;display:flex;flex-direction:column;gap:6px;padding:6px;border:2px solid var(--border);border-radius:10px;background:var(--surface,#fff);color:inherit;cursor:pointer;text-align:left}
.fm-card.is-current{border-width:4px;padding:4px}
.fm-card canvas{display:block;width:100%;height:auto;border:1px solid var(--border);border-radius:6px;background:#fff}
.fm-name{font-weight:600;font-size:.9rem;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.fm-list{margin:8px 0 0;padding-left:20px;font-size:.85rem;color:var(--text-muted);max-height:84px;overflow:auto}
.fm-list:empty{display:none}
