/* InkWoof v2: trilho, cabeçalho do documento, palco, controles flutuantes, gavetas e responsivo.
   Direção de arte da Nova (design/ui-v2/mockups/assets/mock.css), portada para o DOM real do app.
   A geometria vem daqui; cor, raio, sombra, tipo e movimento vêm de theme.css. */

/* ======================================================================
   Casca
   ====================================================================== */
.app-shell.iw { background: var(--iw-void); color: var(--iw-text-1); }
.iw-editor {
  position: relative;
  --agent-w: var(--iw-agent-w);
  --col-agent: var(--iw-agent-collapsed-w);
  display: grid; height: 100dvh; min-height: 0; overflow: hidden;
  grid-template-columns: var(--iw-rail-w) minmax(0, 1fr) var(--col-agent);
  grid-template-rows: minmax(0, 1fr);
  transition: grid-template-columns var(--iw-dur-panel) var(--iw-ease-in-out);
  background: var(--iw-bg);
}
.iw-editor.hal-open { --col-agent: var(--agent-w); }
.iw-editor.no-agent { --col-agent: 0px; }
.iw-editor.is-resizing { transition: none; cursor: col-resize; user-select: none; }
.iw-editor > .main-nav { grid-column: 1; grid-row: 1; }
.iw-editor > .main-content { grid-column: 2; grid-row: 1; padding: 0; }
.iw-editor > .agent-dock, .iw-editor > .iw-agent-mini { grid-column: 3; grid-row: 1; }

/* ======================================================================
   Trilho (editor e início)
   ====================================================================== */
.iw-rail {
  position: relative; z-index: var(--iw-z-panel); display: flex; flex-direction: column; align-items: center; gap: 2px;
  width: var(--iw-rail-w); min-height: 0; padding: 10px 2px 12px; background: var(--iw-bg); border-right: 1px solid var(--iw-line-1); overflow: hidden;
}
.iw-rail-logo {
  position: relative; isolation: isolate; width: 48px; height: 48px; flex: none; display: grid; place-items: center; margin: 0 0 10px; padding: 0; border-radius: 14px;
  transition: transform var(--iw-dur-fast) var(--iw-ease-spring);
}
.iw-rail-logo:hover { transform: rotate(-4deg) scale(1.04); }
.iw-rail-logo::before { content: ""; position: absolute; inset: 2px; z-index: -1; border-radius: 50%; background: radial-gradient(closest-side, rgba(245, 194, 94, .28), transparent); }
.iw-rail-logo img, .iw-rail-logo .product-symbol { width: 44px; height: 44px; object-fit: contain; filter: drop-shadow(0 6px 10px rgba(0, 0, 0, .45)); }
.iw-rail-logo .product-name { display: none; }
.iw-rail > nav { flex: 1; width: 100%; min-height: 0; display: flex; flex-direction: column; align-items: center; gap: 2px; overflow-y: auto; overflow-x: hidden; scrollbar-width: none; }
.iw-rail > nav::-webkit-scrollbar { display: none; }
.iw-rail-tools { display: flex; flex-direction: column; align-items: center; gap: 2px; width: 100%; }
.iw-rail-foot { margin-top: auto; display: flex; flex-direction: column; align-items: center; gap: 6px; padding-top: 8px; width: 100%; }
.iw-rail-btn {
  position: relative; width: 60px; min-height: 54px; flex: none; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  padding: 0; border: 0; border-radius: 12px; background: none; color: var(--iw-text-3);
  font-size: 10.5px; letter-spacing: -.005em; line-height: var(--iw-lh-2xs); font-weight: 500; letter-spacing: 0; text-align: center;
  transition: background var(--iw-dur-fast) var(--iw-ease-out), color var(--iw-dur-fast) var(--iw-ease-out);
}
.iw-rail-btn svg { width: 20px; height: 20px; }
.iw-rail-btn span, .iw-rail-btn:focus-visible > span {
  display: block; position: static; transform: none; width: auto; max-width: 100%; margin: 0; padding: 0; border: 0; border-radius: 0; background: none; box-shadow: none;
  color: inherit; font: inherit; line-height: inherit; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; pointer-events: none;
}
.iw-rail-btn:hover:not(:disabled) { color: var(--iw-text-1); background: var(--iw-surface-2); }
.iw-rail-btn.active, .iw-rail-btn.is-active, .iw-rail-btn[aria-current="page"] { color: var(--iw-text-1); background: var(--iw-surface-3); box-shadow: inset 0 0 0 1px var(--iw-line-2), inset 0 1px 0 var(--iw-highlight); }
.iw-rail-btn.active svg, .iw-rail-btn.is-active svg, .iw-rail-btn[aria-current="page"] svg { color: var(--iw-accent-text); }
.iw-rail-btn:disabled { color: var(--iw-text-4); cursor: not-allowed; }
.iw-rail-btn[data-state="working"]::after, .iw-rail-btn[data-state="attention"]::after {
  content: ""; position: absolute; top: 8px; right: 13px; width: 8px; height: 8px; border-radius: 50%; box-shadow: 0 0 0 2px var(--iw-bg);
}
.iw-rail-btn[data-state="working"]::after { background: var(--iw-accent-text); animation: iw-heartbeat 1.8s var(--iw-ease-out) infinite; animation-play-state: var(--iw-loop-state); }
.iw-rail-btn[data-state="attention"]::after { background: var(--iw-warning); }
.iw-avatar {
  width: 36px; height: 36px; flex: none; display: grid; place-items: center; padding: 0; border-radius: 50%;
  font-weight: 650; font-size: 13px; color: var(--iw-text-1); background: linear-gradient(140deg, #2A3354, #1B2238); box-shadow: inset 0 0 0 1px var(--iw-line-3);
}
.iw-avatar:hover { box-shadow: inset 0 0 0 1px var(--iw-accent-line), 0 0 0 3px var(--iw-accent-soft); }
.iw-rail-agent > .iw-dot { position: absolute; top: 9px; right: 14px; width: 8px; height: 8px; box-shadow: 0 0 0 2px var(--iw-bg); }
.iw-rail-agent > .iw-dot:not(.iw-dot-ok) { background: var(--iw-text-4); }

/* Menu da conta (tema, convites, sair) */
.iw-account-menu {
  position: fixed; z-index: var(--iw-z-popover); left: calc(var(--iw-rail-w) + 8px); bottom: 12px; width: 280px; padding: 8px; border-radius: 16px;
  background: var(--iw-surface-2); box-shadow: var(--iw-shadow-3); animation: iw-pop-in var(--iw-dur-base) var(--iw-ease-out) both; transform-origin: 0 100%;
}
.iw-account-menu header { display: flex; align-items: center; gap: 10px; padding: 8px 8px 10px; border-bottom: 1px solid var(--iw-line-1); margin-bottom: 6px; }
.iw-account-menu header b { display: block; font-size: 14px; font-weight: 600; }
.iw-account-menu header small { font-size: 12px; color: var(--iw-text-3); }
.iw-account-menu h4 { margin: 8px 8px 6px; font-size: 11.5px; font-weight: 600; letter-spacing: var(--iw-ls-caps); text-transform: uppercase; color: var(--iw-text-3); }
.iw-account-menu .iw-menu-item { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 40px; padding: 0 10px; border-radius: 10px; text-align: left; font-size: 13.5px; color: var(--iw-text-1); }
.iw-account-menu .iw-menu-item:hover { background: var(--iw-surface-3); }
.iw-account-menu .iw-menu-item.is-danger { color: var(--iw-danger); }
@media (max-width: 700px) { .iw-account-menu { left: auto; right: 12px; top: 60px; bottom: auto; transform-origin: 100% 0; } }
@keyframes iw-pop-in { from { opacity: 0; transform: translateY(calc(var(--iw-move) * 6px)) scale(calc(1 - var(--iw-move) * .03)); } to { opacity: 1; transform: none; } }

/* ======================================================================
   Área de trabalho
   ====================================================================== */
.iw-work { position: relative; display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--iw-bg); container: work / inline-size; overflow: hidden; }
.iw-doc-header {
  position: relative; z-index: var(--iw-z-float); flex: none; display: flex; align-items: center; gap: 8px; height: var(--iw-header-h); padding: 0 12px 0 8px;
  background: color-mix(in oklab, var(--iw-bg) 86%, transparent); border-bottom: 1px solid var(--iw-line-1); backdrop-filter: blur(14px);
}
.iw-doc-id { display: flex; align-items: center; gap: 4px; min-width: 0; flex: 0 1 auto; }
.iw-doc-history, .iw-doc-actions, .iw-doc-meta { flex: none; }
.iw-doc-title { display: flex; flex-direction: column; min-width: 0; padding-left: 2px; }
.iw-doc-title input {
  width: clamp(120px, 24cqw, 320px); height: 24px; min-height: 24px; padding: 0 6px; margin-left: -6px; border: 0; border-radius: 6px; box-shadow: none;
  background: transparent; font-size: 14px; font-weight: 600; color: var(--iw-text-1); text-overflow: ellipsis;
}
.iw-doc-title input:hover:not(:focus, [readonly]) { background: var(--iw-surface-3); }
.iw-doc-title input:focus { background: var(--iw-surface-3); box-shadow: inset 0 0 0 1.5px var(--iw-accent-text); }
.iw-save { display: inline-flex; align-items: center; gap: 6px; font-size: var(--iw-fs-xs); line-height: 16px; color: var(--iw-text-3); white-space: nowrap; }
.iw-save::before { content: ""; width: 6px; height: 6px; border-radius: 50%; flex: none; background: var(--iw-success); }
.iw-save.dirty { color: var(--iw-warning); }
.iw-save.dirty::before { background: var(--iw-warning); }
.iw-save.save-error { color: var(--iw-danger); }
.iw-save.save-error::before { background: var(--iw-danger); }
.iw-doc-history { display: flex; align-items: center; gap: 2px; margin-left: 8px; }
.iw-doc-meta {
  margin: 0 auto; display: inline-flex; align-items: center; gap: 8px; height: 30px; padding: 0 12px; border-radius: 999px; font-size: var(--iw-fs-xs); color: var(--iw-text-2);
  background: var(--iw-surface-2); box-shadow: inset 0 0 0 1px var(--iw-line-1); white-space: nowrap; transition: background var(--iw-dur-fast), box-shadow var(--iw-dur-fast);
}
button.iw-doc-meta:hover { background: var(--iw-surface-3); box-shadow: inset 0 0 0 1px var(--iw-accent-line); color: var(--iw-text-1); }
.iw-doc-meta .iw-fmt-dot { width: 10px; height: 12px; border-radius: 2px; box-shadow: inset 0 0 0 1.5px var(--iw-format-carousel); flex: none; }
.iw-doc-meta .mono { color: var(--iw-text-3); }
.iw-doc-actions { display: flex; align-items: center; gap: 6px; }
.iw-doc-actions .iw-btn { height: 40px; }
.iw-doc-actions .iw-btn svg { width: 16px; height: 16px; }
.permission-pill { padding: 6px 12px; border-radius: 999px; font-size: 12px; font-weight: 600; color: var(--iw-text-2); background: var(--iw-surface-3); }
.conflict-banner { flex: none; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 10px 16px; background: var(--iw-warning-soft); border-bottom: 1px solid color-mix(in oklab, var(--iw-warning) 30%, transparent); color: var(--iw-text-1); font-size: 13px; }
.conflict-banner p { flex: 1; min-width: 200px; }
.iw-workspace { position: relative; flex: 1 1 0; min-height: 0; display: flex; flex-direction: row; overflow: hidden; background: var(--iw-bg); }

/* Menu compacto de ações (celular) */
.mobile-editor-menu { display: none; position: relative; }
.mobile-editor-menu > summary { list-style: none; cursor: pointer; display: grid; place-items: center; width: 40px; height: 40px; border-radius: 10px; color: var(--iw-text-2); }
.mobile-editor-menu > summary::-webkit-details-marker { display: none; }
.mobile-editor-menu > div { position: absolute; right: 0; top: 46px; min-width: 210px; padding: 6px; border-radius: 14px; background: var(--iw-surface-2); box-shadow: var(--iw-shadow-3); z-index: var(--iw-z-popover); }
.mobile-editor-menu > div > button { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 44px; padding: 0 12px; border-radius: 10px; font-size: 13.5px; text-align: left; color: var(--iw-text-1); }
.mobile-editor-menu > div > button:hover { background: var(--iw-surface-3); }

/* ======================================================================
   Palco
   ====================================================================== */
.iw-stage {
  --stage-top: 64px; --stage-bottom: 92px;
  position: relative; flex: 1 1 0; min-width: 0; min-height: 0; overflow: hidden; isolation: isolate; display: block; padding: 0; border: 0; margin: 0;
  background: var(--iw-stage-bg); container: stage / inline-size;
}
.iw-stage::before { /* cone da luminária e halo da arte (a cor vem da própria página) */
  content: ""; position: absolute; inset: 0; z-index: -1; pointer-events: none; transition: --glow-a var(--iw-dur-slow) var(--iw-ease-out), --glow-b var(--iw-dur-slow) var(--iw-ease-out);
  background:
    radial-gradient(ellipse 34% 52% at 50% 52%, var(--glow-a, transparent) 0%, var(--glow-a, transparent) 52%, var(--glow-b, transparent) 76%, transparent 100%),
    radial-gradient(34% 46% at 50% -6%, rgba(255, 255, 255, .07), transparent 72%);
}
.iw-stage::after { /* grão: matéria, não pixel liso */
  content: ""; position: absolute; inset: 0; pointer-events: none; z-index: -1; opacity: calc(var(--iw-grain-opacity) * .8); mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='180' height='180'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 1  0 0 0 0 1  0 0 0 0 1  0 0 0 .9 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
}
@property --glow-a { syntax: "<color>"; inherits: true; initial-value: transparent; }
@property --glow-b { syntax: "<color>"; inherits: true; initial-value: transparent; }
.iw-stage .canvas-caption { display: none; }
.iw-stage .artboard-viewport {
  position: absolute; left: 0; right: 0; top: var(--stage-top); bottom: var(--stage-bottom); margin: 0; padding: 0; border: 0; background: transparent;
  display: block; overflow: auto; scrollbar-width: thin; scrollbar-color: var(--iw-surface-5) transparent; overscroll-behavior: contain;
}
.iw-stage .page-workspace-book { padding: 14px 40px 28px; gap: 56px; min-height: 100%; }
.iw-page-label, .page-sheet-header { min-height: 30px; margin-bottom: 6px; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.page-sheet-title { display: flex; align-items: center; gap: 8px; min-width: 0; padding: 4px 0; border: 0; background: none; color: var(--iw-text-3); font-size: var(--iw-fs-xs); text-align: left; }
.page-sheet-number { font-size: 12px; font-weight: 600; color: var(--iw-text-2); white-space: nowrap; }
.page-sheet-name { font-size: 12px; font-weight: 400; color: var(--iw-text-3); max-width: 240px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.page-sheet-editing { display: none; font-size: 11px; font-weight: 500; color: var(--iw-accent-text); background: var(--iw-accent-soft); padding: 2px 7px; border: 0; border-radius: 999px; white-space: nowrap; }
.page-sheet.is-active .page-sheet-editing { display: inline-block; }
.page-sheet.is-active .page-sheet-number { color: var(--iw-text-1); }
.page-sheet-actions { display: flex; gap: 0; opacity: .75; }
.page-sheet-actions > button { width: 32px; height: 32px; padding: 0; display: grid; place-items: center; border: 0; border-radius: 8px; background: none; color: var(--iw-text-3); }
.page-sheet-actions > button svg { width: 16px; height: 16px; }
.page-sheet-actions > button:hover:not(:disabled) { color: var(--iw-text-1); background: var(--iw-surface-3); border: 0; }
.page-sheet-actions > button:disabled { opacity: .35; }
.page-sheet:hover .page-sheet-actions, .page-sheet:focus-within .page-sheet-actions { opacity: 1; }
.page-sheet-body { background: var(--iw-surface-3); border: 0; border-radius: var(--iw-radius-art); box-shadow: var(--iw-shadow-art); transition: box-shadow var(--iw-dur-base) var(--iw-ease-out), filter var(--iw-dur-base) var(--iw-ease-out); }
.page-sheet:not(.is-active) > .page-sheet-body { filter: brightness(.86) saturate(.9); }
.page-sheet:not(.is-active) > .page-sheet-body:hover { filter: none; box-shadow: 0 0 0 2px var(--iw-accent-line), var(--iw-shadow-art); }
.page-sheet.is-active > .page-sheet-body { box-shadow: var(--iw-shadow-art), 0 0 140px -30px rgba(255, 255, 255, .07); }
.artboard { background: var(--iw-surface-3); box-shadow: none; }
.page-preview-state { color: #5F6779; background: rgba(255, 255, 255, .92); border: 0; border-radius: 6px; font-size: 11px; }
.page-preview-state.is-error { color: #8A5E00; background: #FFF4D6; }
.page-add-after { color: var(--iw-text-3); border: 0; border-radius: 12px; min-height: 36px; font-size: 12.5px; opacity: .85; }
.page-add-after:hover { color: var(--iw-text-1); background: var(--iw-surface-3); border: 0; }
/* o botão de adicionar página vive na tira de páginas */
.page-sheet:last-child > .page-add-after { display: none; }
#render-warning { position: absolute; left: 16px; top: 16px; z-index: var(--iw-z-float); max-width: 46%; padding: 6px 12px; border-radius: 999px; font-size: 12px; color: var(--iw-warning); background: var(--iw-glass-bg-strong); backdrop-filter: var(--iw-glass-blur); box-shadow: var(--iw-shadow-2); }
#render-warning:empty { display: none; }

/* Faixa de estado do agente no palco */
.iw-stage-banner {
  position: absolute; top: 12px; left: 50%; transform: translateX(-50%); z-index: var(--iw-z-float); display: flex; align-items: center; gap: 10px; height: 44px; padding: 0 6px 0 12px;
  border-radius: 999px; background: var(--iw-glass-bg-strong); backdrop-filter: var(--iw-glass-blur); box-shadow: var(--iw-shadow-2); font-size: 13px; color: var(--iw-text-2); white-space: nowrap; max-width: calc(100% - 24px);
  animation: iw-pop-down var(--iw-dur-base) var(--iw-ease-out) both;
}
.iw-stage-banner b { color: var(--iw-text-1); font-weight: 600; }
.iw-stage-banner .iw-orb { width: 20px; height: 20px; }
.iw-stage-banner .iw-btn { height: 32px; min-height: 32px; padding: 0 12px; font-size: 12.5px; border-radius: 999px; }
.iw-stage-banner > span:not(.iw-orb) { overflow: hidden; text-overflow: ellipsis; }

/* Barra contextual da seleção (fixa no topo do palco: estável, nunca sobre a arte) */
.iw-selbar, #contextual-tools {
  position: absolute; top: 12px; left: 50%; transform: translateX(-50%); z-index: var(--iw-z-float);
  display: flex; align-items: center; flex-wrap: nowrap; gap: 2px; height: 48px; max-width: calc(100% - 24px); padding: 4px; border-radius: 14px;
  background: var(--iw-glass-bg-strong); backdrop-filter: var(--iw-glass-blur); box-shadow: var(--iw-shadow-2); white-space: nowrap;
  animation: iw-pop-down var(--iw-dur-base) var(--iw-ease-out) both; overflow: visible;
}
.iw-stage.has-banner .iw-selbar, .iw-stage.has-banner #contextual-tools { top: 62px; }
#contextual-tools[hidden] { display: none; }
#contextual-tools > * { flex: none; }
.contextual-name, .rich-text-mode { padding: 0 10px; height: 28px; display: inline-flex; align-items: center; border-radius: 999px; font-size: 12px; font-weight: 600; color: var(--iw-accent-text); background: var(--iw-accent-soft); margin: 0 4px 0 6px; }
.contextual-button, .contextual-menu > summary {
  position: relative; display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 40px; min-width: 40px; padding: 0 10px; border-radius: 10px;
  font-size: 13px; font-weight: 500; color: var(--iw-text-2); cursor: pointer; list-style: none; white-space: nowrap; border: 0; background: none;
  transition: background var(--iw-dur-fast), color var(--iw-dur-fast);
}
.contextual-menu > summary::-webkit-details-marker { display: none; }
.contextual-button svg { width: 16px; height: 16px; }
.contextual-button:hover:not(:disabled), .contextual-menu > summary:hover { background: var(--iw-surface-3); color: var(--iw-text-1); }
.contextual-button.danger:hover:not(:disabled) { background: var(--iw-danger-soft); color: var(--iw-danger); }
.contextual-button:disabled { color: var(--iw-text-4); cursor: default; }
.contextual-menu[open] > summary { background: var(--iw-accent-soft); color: var(--iw-accent-text); }
.contextual-font select, .contextual-size input {
  height: 32px; min-height: 32px; border: 0; border-radius: 8px; background: var(--iw-surface-3); color: var(--iw-text-1); font-size: 13px; padding: 0 10px; box-shadow: none;
}
.contextual-font select { max-width: 150px; padding-right: 28px; font-weight: 500; }
.contextual-size input { width: 56px; text-align: center; font: 500 13px/1 var(--iw-font-mono); padding: 0 6px; }
.contextual-color input[type="color"] { width: 40px; height: 40px; min-height: 40px; padding: 8px; border: 0; border-radius: 10px; background: none; box-shadow: none; cursor: pointer; }
.contextual-toggle { min-width: 40px; height: 40px; padding: 0 8px; border: 0; border-radius: 10px; background: none; color: var(--iw-text-2); font-size: 13px; }
.contextual-toggle:hover { background: var(--iw-surface-3); }
.contextual-toggle[aria-pressed="true"] { background: var(--iw-accent-soft); color: var(--iw-accent-text); }
.rich-finish { color: var(--iw-accent-text); font-weight: 600; }
.contextual-menu { position: relative; }
.contextual-menu > div {
  position: absolute; top: calc(100% + 10px); left: 0; z-index: var(--iw-z-popover); width: 250px; padding: 8px; border-radius: 16px; display: grid; gap: 2px;
  background: var(--iw-surface-2); box-shadow: var(--iw-shadow-3); animation: iw-pop-in var(--iw-dur-base) var(--iw-ease-out) both; transform-origin: top left;
}
.contextual-menu > div p { margin: 0 0 4px 6px; font-size: 11.5px; font-weight: 600; color: var(--iw-text-3); }
.contextual-menu > div button { min-height: 36px; padding: 0 10px; border: 0; border-radius: 8px; background: none; text-align: left; font-size: 13px; color: var(--iw-text-1); }
.contextual-menu > div button:hover:not(:disabled) { background: var(--iw-accent-soft); color: var(--iw-accent-text); }
.contextual-menu .align-options { display: grid; grid-template-columns: 1fr 1fr; gap: 2px; }
.contextual-menu hr { border: 0; height: 1px; background: var(--iw-line-1); margin: 6px 0; }
.iw-selbar-ask, .contextual-ask {
  display: inline-flex; align-items: center; gap: 8px; height: 40px; padding: 0 14px 0 10px; border-radius: 10px; margin-left: 2px; border: 0;
  font-size: 13px; font-weight: 600; color: var(--iw-accent-text); background: var(--iw-accent-soft); box-shadow: inset 0 0 0 1px var(--iw-accent-line); white-space: nowrap;
}
.iw-selbar-ask:hover, .contextual-ask:hover { background: var(--iw-accent-soft-2); }
.iw-selbar-ask .iw-orb, .contextual-ask .iw-orb { width: 18px; height: 18px; }
@keyframes iw-pop-down { from { opacity: 0; transform: translate(-50%, calc(var(--iw-move) * -6px)); } to { opacity: 1; transform: translate(-50%, 0); } }
@supports (anchor-name: --a) {
  .contextual-menu { anchor-name: --ctx-menu; }
  .contextual-menu > div { position: fixed; position-anchor: --ctx-menu; top: calc(anchor(bottom) + 10px); left: anchor(left); position-try-fallbacks: flip-inline; }
}
@container stage (max-width: 860px) {
  .contextual-button span, .contextual-ask span { display: none; }
  .contextual-button, .contextual-ask { padding: 0; width: 40px; justify-content: center; }
}
@container stage (max-width: 620px) {
  .contextual-font, .contextual-name { display: none; }
  #contextual-tools { overflow-x: auto; scrollbar-width: none; justify-content: flex-start; }
  #contextual-tools::-webkit-scrollbar { display: none; }
}

/* Controles flutuantes (vidro) */
.iw-float {
  position: absolute; z-index: var(--iw-z-float); display: flex; align-items: center; gap: 2px; padding: 4px; border-radius: 14px;
  background: var(--iw-glass-bg); backdrop-filter: var(--iw-glass-blur); box-shadow: var(--iw-shadow-2);
}
.iw-pagestrip { left: 50%; bottom: 20px; transform: translateX(-50%); gap: 6px; padding: 6px; border-radius: 16px; max-width: calc(100% - 460px); overflow: hidden; }
@container stage (max-width: 980px) { .iw-pagestrip { left: 16px; transform: none; max-width: calc(100% - 236px); } }
.iw-pagestrip .filmstrip-track { display: flex; align-items: center; gap: 6px; overflow-x: auto; scrollbar-width: none; padding: 3px; margin: -3px; }
.iw-pagestrip .filmstrip-track::-webkit-scrollbar { display: none; }
.iw-thumb {
  position: relative; flex: none; width: var(--thumb-w, 40px); height: 50px; padding: 0; border: 0; border-radius: 6px; overflow: hidden; background: var(--iw-surface-3);
  box-shadow: var(--iw-shadow-thumb); transition: transform var(--iw-dur-fast) var(--iw-ease-spring), box-shadow var(--iw-dur-fast);
  animation: iw-att-in var(--iw-dur-base) var(--iw-ease-spring) both; animation-delay: calc(var(--i, 0) * var(--iw-stagger-list));
}
.iw-thumb canvas { display: block; width: 100%; height: 100%; opacity: 0; transition: opacity var(--iw-dur-slow); }
.iw-thumb canvas.is-painted { opacity: 1; }
.iw-thumb:hover { transform: translateY(calc(var(--iw-move) * -3px)); }
.iw-thumb.is-active { box-shadow: 0 0 0 2px var(--iw-surface-1), 0 0 0 4px var(--iw-select); }
.iw-thumb b { position: absolute; left: 3px; bottom: 3px; min-width: 14px; height: 14px; padding: 0 3px; border-radius: 4px; font: 600 9.5px/14px var(--iw-font-mono); text-align: center; color: #fff; background: rgba(8, 9, 13, .72); }
.iw-strip-add { width: 40px; height: 50px; flex: none; display: grid; place-items: center; border-radius: 6px; color: var(--iw-text-3); box-shadow: inset 0 0 0 1px var(--iw-line-2); }
.iw-strip-add:hover { color: var(--iw-text-1); background: var(--iw-surface-3); }
.iw-zoom { right: 16px; bottom: 20px; height: 48px; }
.iw-zoom-val { position: relative; display: grid; place-items: center; min-width: 62px; height: 40px; padding: 0 6px; border-radius: 10px; font: 500 12.5px/1 var(--iw-font-mono); color: var(--iw-text-2); transition: background var(--iw-dur-fast), color var(--iw-dur-fast); }
.iw-zoom-val:hover { background: var(--iw-surface-3); color: var(--iw-text-1); }
.iw-zoom-val:focus-within { outline: 2px solid var(--iw-focus); outline-offset: 1px; }
.iw-zoom-val output { pointer-events: none; }
.iw-zoom-val select#zoom { position: absolute; inset: 0; width: 100%; height: 100%; min-height: 0; opacity: 0; cursor: pointer; padding: 0; border: 0; font-size: 14px; appearance: none; background: none; box-shadow: none; }
.iw-zoom .iw-icon-btn { width: 40px; }
.iw-zoom #zoom-slider { display: none; }
@keyframes iw-att-in { from { opacity: 0; transform: translateY(calc(var(--iw-move) * 8px)) scale(calc(1 - var(--iw-move) * .1)); } to { opacity: 1; transform: none; } }

/* Referência minimizada (reference-dock.js mantém o markup; aqui ela ganha a cara do mockup) */
.iw-stage .reference-dock { position: absolute; left: 16px; right: auto; bottom: 20px; top: auto; width: auto; height: auto; min-height: 0; padding: 0; border: 0; background: none; display: flex; align-items: flex-end; z-index: var(--iw-z-float); pointer-events: none; font-family: var(--iw-font-ui); color: var(--iw-text-1); }
.iw-stage .reference-dock-rail { width: auto; max-width: 230px; min-height: 62px; padding: 6px 12px 6px 6px; gap: 10px; border: 0; border-radius: 14px; background: var(--iw-glass-bg); backdrop-filter: var(--iw-glass-blur); box-shadow: var(--iw-shadow-2); color: var(--iw-text-1); font: 600 12.5px/1.25 var(--iw-font-ui); }
.iw-stage .reference-dock-rail:hover { background: var(--iw-glass-bg-strong); }
.iw-stage .reference-dock-rail[data-empty="1"] { display: none; }
.iw-stage .reference-dock-rail-copy small { display: none; }
.iw-stage .reference-dock-rail-copy b { font-size: 12.5px; font-weight: 600; color: var(--iw-text-1); }
.iw-stage .reference-dock-rail-count { font: 650 10.5px/18px var(--iw-font-mono); min-width: 20px; height: 18px; padding: 0 5px; border-radius: 999px; background: var(--iw-accent); color: #fff; text-align: center; }
.iw-stage .reference-dock-rail-thumb { width: 40px; height: 50px; flex: 0 0 40px; border: 0; border-radius: 6px; box-shadow: var(--iw-shadow-thumb); }
.iw-stage .reference-dock-panel {
  position: absolute; left: 16px; right: auto; top: auto; bottom: 20px; width: min(420px, calc(100% - 32px)); height: min(560px, calc(100% - 120px)); border: 0; border-radius: 18px;
  background: var(--iw-surface-2); color: var(--iw-text-1); box-shadow: var(--iw-shadow-3); animation: iw-pop-in var(--iw-dur-base) var(--iw-ease-out) both; transform-origin: bottom left; z-index: var(--iw-z-popover);
}
.iw-stage .reference-dock-panel > header { background: var(--iw-surface-3); border-bottom: 1px solid var(--iw-line-1); }
.iw-stage .reference-dock-panel h2 { color: var(--iw-text-1); font-size: 16px; }

/* ======================================================================
   Gavetas (modelos, elementos, páginas e camadas, ajustes)
   ====================================================================== */
.iw-workspace > .slide-panel, .iw-workspace > .design-library-host, .iw-workspace > .inspector {
  display: none; position: relative; inset: auto; order: 1; flex: 0 0 var(--drawer-w, 320px); width: var(--drawer-w, 320px); max-width: var(--drawer-w, 320px);
  height: 100%; min-height: 0; border: 0; border-right: 1px solid var(--iw-line-1); border-radius: 0; background: var(--iw-surface-1); color: var(--iw-text-1);
  box-shadow: none; z-index: var(--iw-z-panel); visibility: visible; pointer-events: auto;
}
.iw-workspace[data-bench-panel="pages"] > .slide-panel { display: flex; flex-direction: column; animation: iw-drawer-in var(--iw-dur-panel) var(--iw-ease-out) both; }
.iw-workspace[data-bench-panel="library"] > .design-library-host:not(.is-collapsed) { display: flex; animation: iw-drawer-in var(--iw-dur-panel) var(--iw-ease-out) both; }
.iw-workspace[data-bench-panel="properties"] > .inspector { display: block; overflow: auto; animation: iw-drawer-in var(--iw-dur-panel) var(--iw-ease-out) both; }
@keyframes iw-drawer-in { from { opacity: 0; transform: translateX(calc(var(--iw-move) * -18px)); } to { opacity: 1; transform: none; } }
.iw-workspace > .canvas-area { order: 2; }
.design-library-host { grid-template-columns: minmax(0, 1fr); font-family: var(--iw-font-ui); }
.design-library-host .library-drawer { width: 100%; flex: 1; }
.design-library-host .library-tool-rail { display: none; }
.bench-panel-close { position: absolute; right: 10px; top: 12px; z-index: 6; display: grid; place-items: center; width: 36px; height: 36px; padding: 0; border: 0; border-radius: 10px; background: none; color: var(--iw-text-3); }
.bench-panel-close:hover { background: var(--iw-surface-3); color: var(--iw-text-1); }
.bench-panel-close svg { width: 18px; height: 18px; }

.slide-panel { overflow: hidden; }
.slide-panel .panel-tabs { display: flex; gap: 2px; margin: 12px 56px 10px 12px; padding: 3px; flex: none; border-radius: 12px; background: var(--iw-surface-2); box-shadow: inset 0 0 0 1px var(--iw-line-1); }
.slide-panel .panel-tabs button { flex: 1; min-height: 34px; padding: 0 12px; border: 0; border-radius: 9px; background: none; color: var(--iw-text-3); font-size: 13px; font-weight: 600; }
.slide-panel .panel-tabs button:hover { color: var(--iw-text-1); }
.slide-panel .panel-tabs button[aria-selected="true"] { background: var(--iw-surface-4); color: var(--iw-text-1); box-shadow: inset 0 1px 0 var(--iw-highlight); }
.slide-panel #slides-list, .slide-panel #layers-list { flex: 1 1 0; min-height: 0; overflow-y: auto; padding: 4px 14px 14px; scrollbar-width: thin; scrollbar-color: var(--iw-surface-5) transparent; }
.slide-panel-footer { flex: none; margin: 0; padding: 12px 14px 14px; border-top: 1px solid var(--iw-line-1); }
.slide-item { margin-bottom: 14px; border-radius: 12px; }
.slide-select { grid-template-columns: 18px 1fr; gap: 8px; }
.slide-number { padding-top: 8px; font: 600 11px/1 var(--iw-font-mono); color: var(--iw-text-3); }
.slide-thumbnail { min-height: 90px; background: var(--iw-surface-3); border: 0; border-radius: 8px; box-shadow: var(--iw-shadow-thumb), 0 0 0 1px rgba(255, 255, 255, .09); transition: box-shadow var(--iw-dur-fast), transform var(--iw-dur-fast) var(--iw-ease-spring); }
.slide-item:hover .slide-thumbnail { transform: translateY(calc(var(--iw-move) * -2px)); }
.slide-item.selected .slide-thumbnail { box-shadow: 0 0 0 2px var(--iw-surface-1), 0 0 0 4px var(--iw-select); }
.slide-title { font-size: 12px; font-weight: 500; color: var(--iw-text-3); }
.slide-item.selected .slide-title, .slide-item.selected .slide-number { color: var(--iw-accent-text); }
.slide-controls .icon-button { width: 32px; height: 32px; }
.layer-row { padding: 10px; font-size: 13px; color: var(--iw-text-2); border-radius: 10px; gap: 10px; border: 0; background: none; }
.layer-row:hover { background: var(--iw-surface-3); color: var(--iw-text-1); }
.layer-row.selected { background: var(--iw-accent-soft); color: var(--iw-accent-text); }
.panel-empty { font-size: 13px; line-height: 1.6; color: var(--iw-text-3); padding: 14px 6px; }
.inspector { scrollbar-width: thin; scrollbar-color: var(--iw-surface-5) transparent; }
.inspector-heading { position: sticky; top: 0; z-index: 4; min-height: 56px; padding: 16px 56px 12px 16px; background: var(--iw-surface-1); border-bottom: 1px solid var(--iw-line-1); backdrop-filter: none; }
.inspector-heading h2 { font-size: 17px; font-weight: 650; color: var(--iw-text-1); }
.inspector-heading > span { font: 500 11px/1 var(--iw-font-mono); color: var(--iw-text-3); }
.inspector-section { padding: 16px; border-bottom: 1px solid var(--iw-line-1); }
.inspector-section h3 { font-size: 12px; font-weight: 600; color: var(--iw-text-3); margin: 0 0 12px; }
.inspector .field { margin-bottom: 12px; }
.inspector .field > span { font-size: 12px; font-weight: 600; color: var(--iw-text-2); }
.inspector :where(input:not([type="checkbox"], [type="color"], [type="range"]), select, textarea) { min-height: 36px; font-size: 13px; border-radius: 10px; }
.inspector .field-grid input[type="number"] { font-family: var(--iw-font-mono); font-size: 12.5px; }
.inspector .color-control { min-height: 36px; gap: 8px; padding: 4px 6px; border-radius: 10px; background: var(--iw-surface-3); box-shadow: inset 0 0 0 1px var(--iw-line-2); border: 0; }
.inspector .color-control span { font: 500 12px/1 var(--iw-font-mono); color: var(--iw-text-3); }
.inspector .lock-control { padding: 5px 10px; border-radius: 999px; background: var(--iw-surface-3); border: 0; color: var(--iw-text-3); font-size: 12px; }
.inspector .lock-control:has(input:checked) { background: var(--iw-accent-soft); color: var(--iw-accent-text); }
.inspector-guidance { padding: 24px 16px; color: var(--iw-text-3); }
.inspector-guidance > svg { width: 26px; height: 26px; color: var(--iw-accent-text); margin-bottom: 12px; }
.inspector-guidance h3 { font-size: 14px; font-weight: 650; color: var(--iw-text-1); }
.inspector-guidance p { font-size: 13px; line-height: 1.6; }
.inspector details { background: none; border-bottom: 1px solid var(--iw-line-1); }
.inspector details > summary { color: var(--iw-text-2); font-size: 13px; }
.inspector details > summary:hover { background: var(--iw-surface-2); color: var(--iw-text-1); }
.design-library-host { background: var(--iw-surface-1); color: var(--iw-text-1); border-right: 1px solid var(--iw-line-1); }
.library-header { padding: 18px 56px 12px 16px; }
.library-header h2 { font-size: 17px; font-weight: 650; letter-spacing: -0.01em; color: var(--iw-text-1); }
.library-header p { max-width: none; font-size: 13px; line-height: 1.5; color: var(--iw-text-3); }
.library-query { padding: 0 16px 12px; }
.library-search { min-height: 40px; padding: 0 12px; display: flex; align-items: center; gap: 8px; border: 0; border-radius: 12px; background: var(--iw-surface-3); box-shadow: inset 0 0 0 1px var(--iw-line-2); }
.library-search:focus-within { box-shadow: inset 0 0 0 1.5px var(--iw-accent-text), 0 0 0 4px var(--iw-accent-soft); }
.library-search input { border: 0; box-shadow: none; min-height: 38px; padding: 0; background: transparent; font-size: 14px; }
.library-results { padding: 0 16px; }
.library-footer { padding: 12px 16px; font-size: 12px; color: var(--iw-text-3); border-top: 1px solid var(--iw-line-1); background: var(--iw-surface-1); }
.library-provider-label { font-size: 12px; color: var(--iw-text-3); }

/* ======================================================================
   Coluna do agente recolhida
   ====================================================================== */
.iw-agent-mini {
  display: none; position: relative; flex-direction: column; align-items: center; gap: 10px; padding: 10px 0; min-height: 0; height: 100%;
  background: var(--iw-surface-1); border-left: 1px solid var(--iw-line-1);
}
.iw-editor:not(.hal-open):not(.no-agent) > .iw-agent-mini { display: flex; }
.iw-agent-mini .iw-vlabel { writing-mode: vertical-rl; transform: rotate(180deg); font-size: 12px; font-weight: 600; color: var(--iw-text-2); letter-spacing: .02em; margin-top: 6px; }
.iw-agent-mini .iw-dot { margin-top: auto; margin-bottom: 8px; }
.iw-agent-mini[data-state="working"] .iw-dot { background: var(--iw-accent-text); }
.iw-agent-mini[data-state="attention"] .iw-dot { background: var(--iw-warning); }

/* ======================================================================
   Responsivo
   ====================================================================== */
@container work (max-width: 1180px) {
  .iw-doc-meta { display: none; }
  .mobile-editor-menu { display: block; }
  .iw-doc-actions > [data-action="feedback"] { display: none; }
}
@container work (max-width: 960px) {
  .iw-doc-actions .iw-btn-secondary span { display: none; }
  .iw-doc-actions .iw-btn-secondary { width: 40px; padding: 0; }
  .iw-doc-history .h-hist { display: none; }
  .iw-stage .reference-dock { display: none; }
}
@container work (max-width: 560px) { .iw-doc-history, .iw-zoom { display: none; } }
@media (max-width: 1280px) { .iw-editor { --iw-rail-w: 60px; } .iw-rail-btn { width: 58px; font-size: 10px; } }
@media (max-height: 780px) and (min-width: 700px) { .iw-rail-btn { min-height: 46px; gap: 2px; } .iw-rail-logo { width: 42px; height: 42px; margin-bottom: 6px; } .iw-rail-logo img { width: 38px; height: 38px; } .iw-stage { --stage-bottom: 84px; } }
@media (max-width: 1023px) {
  .iw-editor, .iw-editor.hal-open { --col-agent: 0px; }
  .iw-editor > .iw-agent-mini { display: none !important; }
  .iw-workspace > .slide-panel, .iw-workspace > .design-library-host, .iw-workspace > .inspector { position: absolute; left: 0; top: 0; bottom: 0; max-width: calc(100% - 24px); box-shadow: var(--iw-shadow-3); }
}
@media (max-width: 700px) {
  .iw-editor { --iw-rail-w: 56px; }
  .iw-rail { padding: 8px 2px 8px; }
  .iw-rail-logo { width: 40px; height: 40px; margin-bottom: 6px; }
  .iw-rail-logo img { width: 36px; height: 36px; }
  .iw-rail-btn { width: 52px; min-height: 52px; font-size: 10px; }
  .iw-doc-header { padding: 0 8px; gap: 4px; }
  .iw-doc-title input { width: 100%; }
  .iw-doc-history .h-hist, .iw-doc-actions > [data-action="feedback"], .iw-doc-actions > [data-action="share"], .iw-doc-meta { display: none; }
  .iw-doc-actions .iw-btn-primary { width: 40px; padding: 0; }
  .iw-doc-actions .iw-btn-primary span { display: none; }
  .mobile-editor-menu { display: block; }
  .iw-stage { --stage-top: 56px; --stage-bottom: 84px; }
  .iw-stage .page-workspace-book { padding: 12px 14px 20px; gap: 36px; }
  .iw-workspace > .slide-panel, .iw-workspace > .design-library-host, .iw-workspace > .inspector { width: 100%; max-width: 100%; flex-basis: 100%; z-index: 28; }
  .iw-pagestrip { max-width: calc(100% - 24px); bottom: 12px; }
  .iw-zoom { display: none; }
  .iw-stage .reference-dock { left: auto; right: 10px; top: 10px; bottom: auto; }
  .iw-stage .reference-dock-panel { left: 8px; right: 8px; width: auto; bottom: 12px; height: min(60dvh, 480px); }
  .iw-selbar, #contextual-tools { top: 8px; }
  .contextual-empty { display: none; }
}
@media (prefers-reduced-motion: reduce) { .iw-thumb, .iw-stage-banner, .iw-selbar { animation: none; } }
