@layer modules {
  /* The flow workspace fills the window: app bar, canvas, phone rail, dock. */
  body.is-app { height: 100dvh; overflow: hidden; }
  /* The side panel opens wide enough for a condition row to read whole; dragging its edge sets the width inline. */
  .workspace { --dock-height: 320px; --bar: 4.4rem; --gap: 1.2rem; --phone-width: 33.6rem; --inspector-width: clamp(52rem, 38vw, 62rem); position: relative; height: 100dvh; overflow: hidden; background: var(--surface-2); }
  .workspace.is-resizing { cursor: ns-resize; user-select: none; }
  /* Everything around the canvas floats in its corners, Miro-style; panels and the phone open only when asked for. */
  .island { position: absolute; z-index: 6; display: flex; align-items: center; gap: .4rem; padding: .4rem; border: 1px solid var(--line); border-radius: var(--r-card); background: var(--island); box-shadow: var(--shadow-float); backdrop-filter: blur(10px); }
  .island.is-top-left { top: var(--gap); left: var(--gap); padding-right: .6rem; }
  .island.is-top-right { top: var(--gap); right: var(--gap); }
  .island.is-bottom-left { bottom: var(--gap); left: var(--gap); }
  .island.is-left-rail { top: 7.2rem; left: var(--gap); flex-direction: column; padding: .4rem; }
  .island-home { display: grid; place-items: center; width: 3.6rem; height: 3.6rem; border-radius: var(--r-control); text-decoration: none; }
  .island-home:hover { background: var(--surface-2); }
  .island-home .mark { width: 2.8rem; height: 2.8rem; }
  .flow-menu-button { display: flex; align-items: center; gap: .7rem; height: 3.6rem; padding: 0 .8rem; border-radius: var(--r-control); cursor: pointer; }
  .flow-menu-button:hover, .flow-menu[open] > .flow-menu-button { background: var(--surface-2); }
  .flow-title { max-width: 32rem; margin: 0; overflow: hidden; font-size: 1.55rem; font-weight: 650; letter-spacing: -.01em; text-overflow: ellipsis; white-space: nowrap; }
  .chevron { width: .7rem; height: .7rem; margin: -.3rem .1rem 0; border-right: 1.5px solid var(--ink-3); border-bottom: 1.5px solid var(--ink-3); transform: rotate(45deg); }
  .status-dot { flex: none; width: .8rem; height: .8rem; border-radius: 50%; background: var(--ink-3); }
  .status-dot.is-ok { background: var(--ok); }
  .status-dot.is-warned { background: var(--warning); }
  .status-dot.is-broken { background: var(--error); }
  .flow-menu .menu-items { left: 0; right: auto; min-width: 26rem; }
  /* Quiet unless something is waiting or went wrong; the reason for a refusal shows on hover or focus. */
  .sync-mark { position: relative; display: flex; align-items: center; padding: 0 .4rem 0 .2rem; font-size: 1.25rem; font-weight: 550; color: var(--ink-3); white-space: nowrap; }
  .sync-mark[hidden] { display: none; }
  .sync-mark[data-state="offline"] { color: var(--warning); }
  .sync-mark[data-state="failed"] { color: var(--error); }
  .sync-mark-label { display: flex; align-items: center; gap: .5rem; border-radius: var(--r-control); }
  .sync-mark[data-state="offline"] .sync-mark-label::before, .sync-mark[data-state="failed"] .sync-mark-label::before { content: ""; width: .6rem; height: .6rem; border-radius: 50%; background: currentColor; }
  .sync-mark[data-state="failed"] .sync-mark-label { cursor: help; text-decoration: underline dotted; text-underline-offset: .3rem; }
  .sync-mark-label:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
  .sync-mark-reason { position: absolute; top: calc(100% + 1rem); left: 0; z-index: 20; width: max-content; max-width: 32rem; padding: .7rem 1rem; border: 1px solid var(--line); border-radius: var(--r-card); background: var(--surface); box-shadow: var(--shadow-float); color: var(--ink); font-weight: 450; white-space: normal; opacity: 0; visibility: hidden; transition: opacity .12s; }
  .sync-mark:hover .sync-mark-reason, .sync-mark:focus-within .sync-mark-reason { opacity: 1; visibility: visible; }
  .menu-item kbd { margin-left: auto; }
  .menu-divider { height: 1px; margin: .4rem .2rem; background: var(--line); }
  .appbar-publish { position: relative; }
  .appbar-publish.has-changes::after { content: ""; position: absolute; top: -.3rem; right: -.3rem; width: 1rem; height: 1rem; border: 2px solid var(--surface); border-radius: 50%; background: var(--live); }
  .rail-divider { width: 2.4rem; height: 1px; margin: .2rem 0; background: var(--line); }
  .rail-button, .launcher, .island-button { position: relative; display: grid; place-items: center; width: 4rem; height: 4rem; border: 0; border-radius: var(--r-control); background: transparent; color: var(--ink-2); cursor: pointer; }
  .rail-button:hover, .launcher:hover { background: var(--surface-2); color: var(--ink); }
  .rail-button .icon, .launcher .icon { width: 1.8rem; height: 1.8rem; }
  .launcher.is-active { background: var(--surface-2); color: var(--focus); }
  .badge { position: absolute; top: .2rem; right: .2rem; display: grid; place-items: center; min-width: 1.6rem; height: 1.6rem; padding: 0 .4rem; border-radius: 999px; background: var(--ink-3); color: var(--on-accent); font-size: 1rem; font-weight: 700; line-height: 1; }
  .badge.is-error { background: var(--error); }
  .badge.is-warning { background: var(--warning); }
  .badge.is-dot { min-width: 0; width: .9rem; height: .9rem; padding: 0; background: var(--live); border: 2px solid var(--surface); }
  .island-button { display: inline-flex; gap: .6rem; width: auto; height: auto; min-height: 4.2rem; padding: 0 1.2rem; border: 1px solid var(--line); border-radius: var(--r-card); background: var(--island); color: var(--ink); font: inherit; font-size: 1.35rem; font-weight: 600; box-shadow: var(--shadow-float); backdrop-filter: blur(10px); }
  .island-button .icon { width: 1.7rem; height: 1.7rem; }
  .island-button:hover { background: var(--surface); }
  .island-button[aria-pressed="true"] { border-color: var(--focus); color: var(--focus); }
  .journey-float.is-bottom { align-items: flex-end; gap: .6rem; }
  .workspace.has-dock .launchers { bottom: calc(var(--dock-height) + 2 * var(--gap)); }
  .workspace.has-dock .journey-float.is-bottom { bottom: calc(var(--dock-height) + 2 * var(--gap)); }
  .workspace.has-phone .journey-float.is-bottom { right: calc(var(--phone-width) + 2 * var(--gap)); }
  .workspace.has-phone .island.is-top-right { right: var(--gap); }
  /* An open phone closes from its own corner or with P, so its button steps aside and leaves the room to the zoom controls. */
  .workspace.has-phone .try-it { display: none; }
  /* The phone's resize handle is an invisible strip that hangs out to its left; the launchers stay clickable under it. */
  .workspace.has-phone .launchers { z-index: 9; }

  /* The public demo: four steps across the top, with only the one to do now spelled out. */
  .island.is-demo-guide { top: var(--gap); left: 50%; z-index: 5; display: grid; gap: .6rem; width: min(56rem, calc(100% - 84rem)); padding: 1rem 1.4rem 1.2rem; transform: translateX(-50%); }
  .demo-steps { display: flex; flex-wrap: wrap; gap: .4rem 1.6rem; margin: 0; padding: 0; list-style: none; }
  .demo-step { display: flex; align-items: center; gap: .6rem; color: var(--ink-3); font-size: 1.3rem; font-weight: 600; }
  .demo-step.is-current { color: var(--ink); }
  .demo-step.is-done { color: var(--ok-ink); }
  .demo-tick { position: relative; display: grid; place-items: center; flex: none; width: 2rem; height: 2rem; border-radius: 50%; box-shadow: inset 0 0 0 1.5px var(--line-strong); font-size: 1.1rem; }
  .demo-step.is-current .demo-tick { background: var(--ink); box-shadow: none; color: var(--surface); }
  .demo-tick .icon { display: none; width: 2rem; height: 2rem; }
  .demo-step.is-done .demo-tick { box-shadow: none; }
  .demo-step.is-done .demo-number { display: none; }
  .demo-step.is-done .demo-tick .icon { display: block; }
  .demo-body { margin: 0; color: var(--ink-2); font-size: 1.4rem; line-height: 1.45; }
  .demo-link { margin-left: .4rem; font-weight: 600; white-space: nowrap; }
  @media (max-width: 1199px) { .island.is-demo-guide { top: 6.4rem; left: calc(var(--gap) + 6rem); width: min(56rem, calc(100% - 2 * var(--gap) - 6rem)); transform: none; } }
  .pill.is-demo { border-color: transparent; background: var(--live-soft); color: var(--live-ink); }
  .sandbox-noscript { position: absolute; inset: auto 0 0; z-index: 10; margin: 0; padding: 1.6rem; background: var(--surface); text-align: center; }

  .workspace-canvas { position: absolute; inset: 0; }
  .canvas-empty { display: grid; place-content: center; justify-items: start; gap: 1.2rem; height: 100%; padding: 3.2rem; border: 1px dashed var(--line-strong); border-radius: var(--r-section); background: var(--surface); }
  .canvas-empty p { max-width: 52ch; margin: 0; color: var(--ink-2); }
  .canvas-empty-icon { width: 3.2rem; height: 3.2rem; color: var(--error); }
  .workspace-phone { position: absolute; top: calc(var(--gap) + 5.6rem); right: var(--gap); z-index: 8; display: flex; flex-direction: column; width: var(--phone-width); max-width: calc(100% - 2 * var(--gap)); max-height: calc(100% - 6.8rem - 2 * var(--gap)); border: 1px solid var(--line); border-radius: var(--r-section); background: var(--surface); box-shadow: var(--shadow-float); }
  .workspace-phone-scroll { min-height: 0; overflow: auto; padding: 1.2rem 1.4rem 1.4rem; overscroll-behavior: contain; scrollbar-width: thin; }
  .workspace-phone .phone { max-width: none; }
  .workspace-phone .device { zoom: var(--phone-scale, 1); }
  .phone-handle { position: absolute; left: -.6rem; top: 1.4rem; bottom: 1.4rem; z-index: 4; width: 1.2rem; cursor: ew-resize; touch-action: none; }
  .phone-handle::after { content: ""; position: absolute; left: .4rem; top: 50%; width: .4rem; height: 4.8rem; margin-top: -2.4rem; border-radius: 999px; background: var(--line-strong); opacity: 0; transition: opacity .15s; }
  .workspace-phone:hover .phone-handle::after, .phone-handle:focus-visible::after, .workspace.is-resizing-phone .phone-handle::after { opacity: 1; }
  .phone-handle:focus-visible { outline: none; }
  .workspace.is-resizing-phone { cursor: ew-resize; user-select: none; }
  .island:has(details[open]) { z-index: 12; }
  .workspace-phone .section-title { margin: .4rem 0 1rem; }
  .chevron.is-light { border-color: currentColor; opacity: .8; }
  .workspace-phone .phone-head { padding-right: 3.2rem; }
  @media (max-width: 979px) {
    .workspace-phone { left: var(--gap); width: auto; }
    .workspace-phone .device { zoom: 1; }
    .phone-handle { display: none; }
  }
  @media (max-width: 879px) {
    .toggle kbd, .dock-tab kbd, .zoom-level, .journey-help { display: none; }
    .flow-title { max-width: 14rem; }
    .island.is-left-rail { top: auto; bottom: calc(var(--gap) + 5.4rem); flex-direction: row; max-width: calc(100% - 2 * var(--gap)); overflow-x: auto; scrollbar-width: none; }
    .island.is-left-rail .palette { display: flex; }
    .rail-divider { width: 1px; height: 2.4rem; margin: 0 .2rem; }
    .launchers { bottom: var(--gap); }
  }
}
