*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  overflow: hidden;
  font-family: var(--font-ui);
  background: var(--bg-app);
  color: var(--text-primary);
  -webkit-font-smoothing: antialiased;
}

/* ── Main layout ─────────────────────────────── */
#main {
  display: flex;
  height: calc(100vh - 68px);  /* toolbar is now 68px */
  overflow: hidden;
  position: relative;
}

/* ── Canvas wrapper ──────────────────────────── */
#canvas-wrapper {
  flex: 1;
  overflow: hidden;
  position: relative;
  cursor: grab;
  background: var(--bg-canvas);
  /* Dot grid — 80px units para escala 4× */
  background-image: radial-gradient(circle, rgba(0,0,0,0.13) 2px, transparent 2px);
  background-size: 80px 80px;
}

#canvas-wrapper:active { cursor: grabbing; }

/* ── Canvas ──────────────────────────────────── */
#canvas {
  position: relative;
  transform-origin: 0 0;
  will-change: transform;
}

/* ── SVG layer ───────────────────────────────── */
#connections-svg {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: visible;
}

/* ── Phase sections (on light canvas) — 4× scale ── */
.phase-section {
  position: absolute;
  background: var(--phase-bg);
  border: 3px solid var(--phase-border);
  border-radius: 52px;
  box-shadow: 0 2px 16px rgba(0,0,0,0.06);
  pointer-events: none;
}

.phase-section__label {
  position: absolute;
  top: 70px;
  left: 160px;
  box-sizing: border-box;
  font-size: 76px;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  padding: 24px 40px;
  border-radius: 20px;
  background: #ffffff;
  color: var(--canvas-text-primary);
  border: 2px solid rgba(0,0,0,0.12);
  box-shadow: 0 4px 20px rgba(0,0,0,0.10);
  white-space: nowrap;
  line-height: 1;
}

/* ── Side panel ──────────────────────────────── */
#panel {
  width: 520px;
  min-width: 520px;
  background: var(--bg-panel);
  border-left: 1px solid rgba(255,255,255,0.07);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: var(--shadow-panel);
  transition: width var(--t-normal), min-width var(--t-normal), opacity var(--t-normal);
}

#panel.panel--closed {
  width: 0;
  min-width: 0;
  opacity: 0;
  pointer-events: none;
}

#panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px;
  border-bottom: 1px solid rgba(255,255,255,0.07);
  flex-shrink: 0;
}

#panel-content {
  flex: 1;
  overflow-y: auto;
  padding: 18px 18px 62px 18px;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.1) transparent;
}

/* ── Study bar ───────────────────────────────── */
#study-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 52px;
  background: rgba(17,17,17,0.97);
  border-top: 1px solid rgba(255,255,255,0.1);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 20px;
  z-index: 50;
  backdrop-filter: blur(8px);
}

#study-bar.hidden { display: none; }

/* ── Legend / footer bar ─────────────────────── */
#legend {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 44px;
  background: #111111;
  border-top: 1px solid rgba(255,255,255,0.08);
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 0 20px;
  z-index: 40;
}

.legend__label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.35);
  white-space: nowrap;
  margin-right: 4px;
  flex-shrink: 0;
}

.legend__item {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  white-space: nowrap;
  padding: 4px 12px;
  border-radius: 5px;
}

.legend__credit {
  margin-left: auto;
  font-size: 13px;
  font-weight: 500;
  color: rgba(255,255,255,0.55);
  white-space: nowrap;
}

/* ── Toast ───────────────────────────────────── */
#toast-container {
  position: fixed;
  bottom: 56px;
  right: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 200;
}

.toast {
  background: #1a1a1a;
  border: 1px solid rgba(255,255,255,0.12);
  color: #f0f0f0;
  padding: 11px 18px;
  border-radius: 8px;
  font-size: 13px;
  box-shadow: var(--shadow-modal);
  animation: toastIn 0.2s ease forwards;
}

@keyframes toastIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.hidden { display: none !important; }
