/* Shell del episodio + Lab — estructura compartida por las pantallas
 * Hereda layout de C04-A: rail S1→S4 a la izquierda, header sobrio, slot S3
 * (donde vive cada Lab) ocupa el espacio central.
 */

.shell-root {
  display: grid;
  grid-template-rows: auto 1fr;
  height: 100%;
  background: var(--surface-0);
  color: var(--text-primary);
  font-family: var(--font-sans);
}

/* ───── Topbar ───── */
.shell-topbar {
  display: flex;
  align-items: center;
  height: 48px;
  padding: 0 16px;
  border-bottom: 1px solid var(--border-subtle);
  background: var(--surface-1);
  gap: 14px;
  font-size: var(--size-sm);
}
.shell-topbar .crumb { color: var(--text-secondary); }
.shell-topbar .crumb-sep { color: var(--text-disabled); }
.shell-topbar .crumb-current { color: var(--text-primary); font-weight: 600; }
.shell-topbar-right {
  margin-left: auto;
  display: flex;
  gap: 8px;
  align-items: center;
}

/* ───── Body con rail + main ───── */
.shell-body {
  display: grid;
  grid-template-columns: 56px 1fr;
  min-height: 0;
}

/* Rail S1-S4 */
.rail {
  border-right: 1px solid var(--border-subtle);
  background: var(--surface-1);
  padding: 16px 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}
.rail-step {
  width: 38px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 6px 0;
  border-radius: var(--radius-sm);
  cursor: pointer;
  position: relative;
}
.rail-step-num {
  width: 26px; height: 26px;
  display: grid; place-items: center;
  border-radius: 50%;
  background: var(--surface-2);
  color: var(--text-secondary);
  font: var(--weight-semibold) 12px / 1 var(--font-mono);
  border: 1px solid var(--border-default);
}
.rail-step.active .rail-step-num { background: var(--text-primary); color: var(--text-inverse); border-color: var(--text-primary); }
.rail-step.complete .rail-step-num { background: var(--signal-pass-soft); color: var(--signal-pass); border-color: var(--signal-pass); }
.rail-step-label {
  font-size: 9px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.rail-step.active .rail-step-label { color: var(--text-primary); }

/* Main */
.shell-main {
  display: grid;
  grid-template-rows: auto 1fr auto;
  min-height: 0;
}

/* Header del lab (60px) */
.lab-header {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 10px 20px;
  border-bottom: 1px solid var(--border-subtle);
  background: var(--surface-1);
  min-height: 60px;
}
.lab-header-id {
  font: var(--weight-medium) var(--size-xs) / 1 var(--font-mono);
  color: var(--text-muted);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.lab-header-title {
  font: var(--weight-semibold) var(--size-md) / 1.25 var(--font-sans);
  color: var(--text-primary);
}
.lab-header-task {
  font-size: var(--size-sm);
  color: var(--text-secondary);
}
.lab-header-counter {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 12px;
}
.counter-pill {
  font-family: var(--font-mono);
  font-size: var(--size-sm);
  background: var(--surface-2);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  color: var(--text-primary);
}
.counter-pill .label { color: var(--text-muted); margin-right: 6px; }

/* Lab body: chart + toolbar + side panel */
.lab-body {
  display: grid;
  grid-template-columns: 1fr 56px 300px;
  gap: 0;
  min-height: 0;
}
.lab-body-no-panel {
  grid-template-columns: 1fr 56px;
}
.lab-canvas-area {
  position: relative;
  padding: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface-0);
  min-height: 0;
  overflow: hidden;
}
.lab-toolbar {
  border-left: 1px solid var(--border-subtle);
  background: var(--surface-1);
  padding: 12px 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}
.tool-btn {
  width: 40px; height: 40px;
  border-radius: var(--radius-sm);
  display: grid;
  place-items: center;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  position: relative;
  transition: background var(--duration-fast), border-color var(--duration-fast), color var(--duration-fast);
}
.tool-btn:hover { background: var(--surface-2); color: var(--text-primary); }
.tool-btn.active {
  background: var(--surface-3);
  border-color: var(--text-primary);
  color: var(--text-primary);
}
.tool-btn.locked {
  color: var(--text-disabled);
  cursor: not-allowed;
}
.tool-btn.locked:hover { background: transparent; }
.tool-group-sep {
  width: 26px;
  height: 1px;
  background: var(--border-default);
  margin: 6px 0;
}
.tool-tooltip {
  position: absolute;
  right: 100%;
  top: 50%;
  transform: translateY(-50%) translateX(-8px);
  background: var(--surface-3);
  border: 1px solid var(--border-default);
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  white-space: nowrap;
  font-size: var(--size-xs);
  color: var(--text-primary);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--duration-fast);
  box-shadow: var(--shadow-2);
}
.tool-btn:hover .tool-tooltip { opacity: 1; }

/* Side panel */
.lab-side {
  border-left: 1px solid var(--border-subtle);
  background: var(--surface-1);
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.side-section {
  border-bottom: 1px solid var(--border-subtle);
  padding: 12px 14px;
}
.side-section h4 {
  font: var(--weight-semibold) var(--size-xs) / 1 var(--font-sans);
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin: 0 0 10px 0;
  display: flex; align-items: center; gap: 8px;
}
.side-section .count {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-muted);
  background: var(--surface-2);
  padding: 2px 6px;
  border-radius: 2px;
  letter-spacing: 0;
  text-transform: none;
}

/* Lista de drawings */
.draw-list { display: flex; flex-direction: column; gap: 4px; }
.draw-item {
  display: grid;
  grid-template-columns: 20px 1fr auto;
  gap: 8px;
  align-items: center;
  padding: 8px 10px;
  background: var(--surface-2);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  font-size: var(--size-xs);
}
.draw-item.discarded { opacity: 0.4; background: transparent; border-style: dashed; }
.draw-item-icon {
  width: 16px; height: 16px;
  display: grid;
  place-items: center;
  color: var(--tool-trendline);
}
.draw-item-meta { color: var(--text-secondary); font-family: var(--font-mono); }
.draw-item-meta .ok { color: var(--signal-pass); font-weight: 600; }
.draw-item-meta .warn { color: var(--signal-warning); font-weight: 600; }
.draw-item-remove {
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  padding: 0 2px;
}
.draw-item-remove:hover { color: var(--text-primary); }
.draw-collapsed {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px dashed var(--border-subtle);
  font-size: var(--size-xs);
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
}

/* Footer del lab — banner de feedback */
.lab-footer {
  display: flex;
  align-items: center;
  padding: 12px 20px;
  border-top: 1px solid var(--border-subtle);
  background: var(--surface-1);
  min-height: 56px;
  gap: 12px;
}
.feedback-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: var(--size-sm);
  flex: 1;
}
.feedback-icon {
  width: 20px; height: 20px;
  display: grid; place-items: center;
  border-radius: 50%;
  font-weight: 700;
  font-size: 11px;
}
.feedback-banner.pass { color: var(--signal-pass); }
.feedback-banner.pass .feedback-icon { background: var(--signal-pass-soft); color: var(--signal-pass); }
.feedback-banner.warn { color: var(--signal-warning); }
.feedback-banner.warn .feedback-icon { background: var(--signal-warning-soft); color: var(--signal-warning); }
.feedback-banner.fail { color: var(--signal-fail); }
.feedback-banner.fail .feedback-icon { background: var(--signal-fail-soft); color: var(--signal-fail); }
.feedback-banner.neutral { color: var(--text-secondary); }
.feedback-banner.neutral .feedback-icon { background: var(--surface-2); color: var(--text-muted); }
.feedback-quote {
  font-style: italic;
  color: var(--text-secondary);
  margin-left: 12px;
  font-size: var(--size-xs);
}

/* Bar replay controls */
.replay-controls {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 16px;
  background: var(--surface-2);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
}
.replay-controls .speed {
  font-family: var(--font-mono);
  font-size: var(--size-xs);
  color: var(--text-secondary);
}
.replay-controls .bar-count {
  font-family: var(--font-mono);
  font-size: var(--size-xs);
  color: var(--text-primary);
  margin-left: auto;
}
.replay-track {
  flex: 1;
  height: 4px;
  background: var(--surface-3);
  border-radius: 2px;
  position: relative;
  overflow: hidden;
}
.replay-track .fill {
  position: absolute;
  inset: 0 auto 0 0;
  background: var(--text-primary);
  border-radius: 2px;
}
.replay-track .commits {
  position: absolute;
  top: -2px; bottom: -2px;
  width: 2px;
  background: var(--signal-info);
}
.replay-cement-notice {
  font-size: var(--size-xs);
  color: var(--text-muted);
  font-style: italic;
}

/* Glosario / tutor accesos */
.tutor-fab {
  position: absolute;
  bottom: 16px;
  right: 16px;
  width: 44px; height: 44px;
  border-radius: 50%;
  background: var(--surface-2);
  border: 1px solid var(--border-default);
  display: grid; place-items: center;
  cursor: pointer;
  color: var(--voice-tutor);
  box-shadow: var(--shadow-2);
}

/* Convicción slider */
.conviction {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 8px;
}
.conviction-dot {
  width: 22px; height: 22px;
  border-radius: 50%;
  border: 1px solid var(--border-default);
  background: var(--surface-2);
  display: grid; place-items: center;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-secondary);
  cursor: pointer;
}
.conviction-dot.selected {
  background: var(--text-primary);
  color: var(--text-inverse);
  border-color: var(--text-primary);
}
.conviction-label {
  font-size: var(--size-xs);
  color: var(--text-muted);
  margin-right: 8px;
}

/* Voice bubbles para S1/S2 */
.voice-bubble {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 12px;
  margin-bottom: 14px;
  align-items: start;
}
.voice-avatar {
  width: 28px; height: 28px;
  border-radius: 50%;
  display: grid; place-items: center;
  font: var(--weight-semibold) 11px var(--font-sans);
  color: var(--text-inverse);
}
.voice-avatar.sofia { background: var(--voice-sofia); }
.voice-avatar.mateo { background: var(--voice-mateo); }
.voice-avatar.tutor { background: var(--voice-tutor); }
.voice-content { font-size: var(--size-sm); line-height: var(--lh-normal); color: var(--text-primary); }
.voice-name {
  font-weight: var(--weight-semibold);
  font-size: var(--size-xs);
  margin-bottom: 2px;
  color: var(--text-secondary);
}
.voice-content.sofia .voice-name { color: var(--voice-sofia); }
.voice-content.mateo .voice-name { color: var(--voice-mateo); }
.voice-content.tutor .voice-name { color: var(--voice-tutor); }

/* Glossary inline */
.gloss {
  border-bottom: 1px dotted var(--text-muted);
  cursor: help;
  color: inherit;
}
.gloss:hover { color: var(--signal-info); border-bottom-color: var(--signal-info); }

/* Trendline shopping notice */
.shopping-notice {
  display: flex;
  align-items: start;
  gap: 10px;
  padding: 10px 12px;
  background: var(--signal-warning-soft);
  border-left: 2px solid var(--signal-warning);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-size: var(--size-xs);
  color: var(--signal-warning);
}
.shopping-notice strong { color: var(--text-primary); }
