/* Screen layout. The drawing fills the screen; tools and panels float on
   it. Breakpoints follow the width the app has (container queries), not
   the device, so split screens and narrow windows get the same rules:
     ≥ 1280  desktop  both panels pinned, labels under tools from 1440
     1024–   laptop   left panel → icon rail (opens over the drawing)
     600–    tablet   properties → card opened with a button
     < 600   phone    every panel is a bottom sheet; tools at the bottom
   Stacking: drawing 0 · empty state 1 · edit bar 4 · panels 5 · dock and
   top bar 6 · overlay panels 7 · menus 8. */

#app {
  position: fixed;
  inset: 0;
  overflow: hidden;
  /* Re-applied here: the theme redefines the variables on #app, and colors
     inherited from body would keep the dark theme's values. */
  background: var(--canvas);
  color: var(--text);
  container: app / inline-size;
  --panel-top: calc(var(--safe-t) + var(--gap) + var(--top-h) + var(--gap));
}

#stage { position: absolute; inset: 0; z-index: 0; }
#stage canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }

.float { background: var(--panel); border-radius: var(--r-panel); box-shadow: var(--shadow); }

/* ---- top bar ---- */
.topbar {
  position: absolute;
  top: calc(var(--safe-t) + var(--gap));
  left: calc(var(--safe-l) + var(--gap));
  right: calc(var(--safe-r) + var(--gap));
  display: flex;
  justify-content: space-between;
  gap: 8px;
  z-index: 6;
  pointer-events: none;
}
.topbar > * { pointer-events: auto; }
.top-l,
.top-r { height: var(--top-h); display: flex; align-items: center; }
.top-l { flex: 0 1 auto; min-width: 0; gap: 6px; padding: 0 8px; }
.top-r { flex: none; gap: 2px; padding: 0 8px; }

/* ---- side panels ---- */
.nav,
.inspector {
  position: absolute;
  top: var(--panel-top);
  bottom: calc(var(--safe-b) + var(--gap));
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 5;
}
.nav { left: calc(var(--safe-l) + var(--gap)); width: var(--left-w); }
.inspector { right: calc(var(--safe-r) + var(--gap)); width: var(--right-w); }

.rail {
  position: absolute;
  top: var(--panel-top);
  left: calc(var(--safe-l) + var(--gap));
  width: 52px;
  display: none;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 8px 0;
  z-index: 5;
}

/* Panels opened over the drawing: cloud on the left, PDF on the right. */
.overlay-l,
.overlay-r {
  position: absolute;
  top: var(--panel-top);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 7;
}
.overlay-l:not(.open),
.overlay-r:not(.open) { display: none; }
.overlay-l {
  left: calc(var(--safe-l) + var(--gap));
  bottom: calc(var(--safe-b) + var(--gap));
  width: 360px;
  max-width: calc(100% - 2 * var(--gap));
}
.overlay-r {
  right: calc(var(--safe-r) + var(--gap));
  width: 300px;
  max-width: calc(100% - 2 * var(--gap));
  max-height: calc(100% - var(--panel-top) - var(--gap));
}

/* Sheet grip, shown on phones only. */
.handle { display: none; width: 40px; height: 4px; flex: none; margin: 8px auto 0; border-radius: 2px; background: var(--line); }

/* ---- dock: prompt, keypad, tools; centered between the panels ---- */
/* Where the dock sits: between the side panels. The insets are set on the
   dock itself — a container query cannot restyle its container (#app). */
.dock {
  --dock-l: calc(var(--safe-l) + var(--left-w) + 2 * var(--gap));
  --dock-r: calc(var(--safe-r) + var(--right-w) + 2 * var(--gap));
  position: absolute;
  left: var(--dock-l);
  right: var(--dock-r);
  bottom: calc(var(--safe-b) + 16px);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  z-index: 6;
  pointer-events: none;
}
.dock > * { pointer-events: auto; max-width: 100%; }

/* Selection edit bar: placed over the selection by ui/context-bar.js. */
.ctx {
  position: absolute;
  left: var(--ctx-x, 50%);
  top: var(--ctx-y, var(--panel-top));
  transform: translateX(-50%);
  z-index: 4;
}

/* Menus and other popovers. */
.popover { position: absolute; z-index: 8; overflow-y: auto; overscroll-behavior: contain; }
