body {
  display: grid;
  grid-template-rows: auto 1fr;
  grid-template-columns: 1fr;
  height: 100dvh;
  margin: 0;
  overflow: hidden;
  position: relative;
  background-color: var(--site-bg);
}

#app-main {
  position: relative;
  width: 100vw;
  height: 100%;
  overflow: hidden;
}

#canvas-container {
  position: absolute;
  inset: 0;
  z-index: 0;
  touch-action: none;
  background-color: var(--site-bg);
}

/* ── Floating Glass Sidebars (Desktop/Tablet ≥ 900px) ── */
#sidebar, #inspector {
  position: absolute;
  top: 16px;
  bottom: 16px;
  z-index: 10;
  background-color: var(--site-surface);
  backdrop-filter: var(--glass-backdrop);
  -webkit-backdrop-filter: var(--glass-backdrop);
  border: 1px solid var(--site-border);
  border-radius: var(--site-radius-lg);
  box-shadow: var(--site-shadow-floating);
  display: flex;
  flex-direction: column;
  transition: transform 0.3s ease, opacity 0.3s ease;
}

#sidebar {
  left: 16px;
  width: 260px;
  overflow: hidden;
}

#sidebar.collapsed {
  transform: translateX(-150%);
  opacity: 0;
  pointer-events: none;
}

#inspector {
  right: 16px;
  width: 280px;
  overflow: hidden;
}

#inspector.collapsed {
  transform: translateX(150%);
  opacity: 0;
  pointer-events: none;
}

/* Sheet Handle only shown on mobile */
.sheet-handle { display: none; }

/* Mobile sheet tab bar – hidden on desktop */
.mobile-sheet-tabs { display: none; }
.tab-view { flex: 1; display: flex; flex-direction: column; overflow: hidden; }

/* ── Mobile Layout (≤ 900px — covers both phones and iPads) ── */
@media (max-width: 900px) {
  .sheet-handle {
    display: block;
    width: 36px;
    height: 4px;
    background: var(--site-border);
    border-radius: 2px;
    margin: 8px auto 4px;
    flex-shrink: 0;
    cursor: grab;
  }

  #sidebar, #inspector {
    top: auto;
    bottom: 0;
    left: 0;
    right: 0;
    height: 55vh;
    width: 100%;
    max-width: none;
    border-radius: 20px 20px 0 0;
    border-bottom: none;
    border-left: none;
    border-right: none;
    border-top: 1px solid var(--site-border);
    box-shadow: 0 -6px 28px rgba(0, 0, 0, 0.2);
    z-index: 200;
    transform: translateY(110%);
    opacity: 0;
    pointer-events: none;
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.25s ease;
  }

  #sidebar:not(.collapsed), #inspector:not(.collapsed) {
    transform: translateY(0);
    opacity: 1;
    pointer-events: auto;
  }

  #inspector {
    display: none !important; /* Hidden on mobile — integrated into sidebar tabs */
  }

  .mobile-sheet-tabs {
    display: flex;
    flex-shrink: 0;
    padding: 4px;
    background: var(--site-bg-secondary);
    border-bottom: 1px solid var(--site-border);
    gap: 4px;
  }

  .mobile-tab-btn {
    flex: 1;
    background: transparent;
    border: none;
    padding: 8px 12px;
    font-size: 12px;
    font-weight: 700;
    color: var(--site-text-secondary);
    border-radius: var(--site-radius-sm);
    cursor: pointer;
    transition: all 0.15s ease;
  }

  .mobile-tab-btn.active {
    background: var(--site-surface);
    color: var(--site-accent);
  }
}

/* ── Modal Overlays ── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background-color: rgba(15, 23, 42, 0.5);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}
.modal-overlay.hidden { display: none; }

.modal-content {
  background-color: var(--site-surface-solid);
  padding: 28px;
  border-radius: var(--site-radius-lg);
  box-shadow: var(--site-shadow-lg);
  max-width: 440px;
  width: 90%;
  border: 1px solid var(--site-border);
}

.btn-primary {
  background: var(--site-accent-gradient);
  color: var(--site-accent-text);
  border: none;
  padding: 10px 20px;
  border-radius: var(--site-radius);
  cursor: pointer;
  font-weight: 600;
  font-size: 13px;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  box-shadow: 0 4px 14px rgba(99, 102, 241, 0.35);
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(99, 102, 241, 0.45);
}

kbd {
  background: var(--site-bg-secondary);
  border: 1px solid var(--site-border);
  padding: 3px 7px;
  border-radius: 6px;
  font-family: var(--site-font-mono);
  font-size: 11px;
  color: var(--site-text);
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}
