#app-container {
  display: grid;
  grid-template-rows: 60px 1fr 100px;
  grid-template-columns: auto 1fr auto;
  grid-template-areas:
    "topbar topbar topbar"
    "sidebar center detail"
    "footer footer footer";
  width: 100vw;
  height: 100vh;
  position: relative;
  z-index: 10;
  gap: var(--space-md);
  padding: var(--space-md);
}

.background-effects {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  z-index: 0;
  pointer-events: none;
}

#ambient-canvas {
  position: absolute;
  top: 0; left: 0; width: 100%; height: 100%;
}

.bg-gradient {
  position: absolute;
  top: 0; left: 0; width: 100%; height: 100%;
  background: radial-gradient(circle at 50% 50%, var(--bg-deep) 0%, var(--bg-void) 100%);
}

.scanlines {
  position: absolute;
  top: 0; left: 0; width: 100%; height: 100%;
  background: linear-gradient(transparent 50%, rgba(0,0,0,0.1) 50%);
  background-size: 100% 4px;
  pointer-events: none;
  opacity: 0.3;
}

/* Layout Areas */
.topbar {
  grid-area: topbar;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--space-lg);
}

.sidebar {
  grid-area: sidebar;
  display: flex;
  flex-direction: column;
  width: 280px;
  min-width: 200px;
  max-width: 500px;
  resize: horizontal;
  overflow: hidden;
}

.center-area {
  grid-area: center;
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
  position: relative;
  min-height: 0; /* Important for flex children scrolling */
}

.universe-view {
  flex: 3;
  min-height: 0;
  display: flex;
  flex-direction: column;
  position: relative;
}

.bottom-views {
  flex: 2;
  min-height: 0;
  display: flex;
  gap: var(--space-md);
}

.timelines-view {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  position: relative;
}

.causal-graph {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  transition: opacity var(--duration-normal);
}

.causal-graph.hidden {
  display: none !important;
}

.detail-panel {
  grid-area: detail;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  width: 320px;
  min-width: 250px;
  max-width: 600px;
  resize: horizontal;
  direction: rtl; /* Handle on bottom-left */
}

.detail-panel > * {
  direction: ltr; /* Restore content direction */
}

.footer-highlights {
  grid-area: footer;
  display: flex;
  gap: var(--space-md);
}

.canvas-container {
  flex: 1;
  position: relative;
  overflow: hidden;
  width: 100%;
  height: 100%;
}

canvas {
  display: block;
  width: 100%;
  height: 100%;
}
