/* ================================================
   sesión-13 — Robótica e IA en el Mundo Físico
   Paleta: slate-navy + orange (robótica) + emerald (éxito) + amber (advertencia)
================================================ */

/* ================================================
   LOOP DIAGRAM — Percibir → Procesar → Decidir → Actuar
================================================ */

.loop-diagram {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.6rem;
  margin: 1.4rem 0;
}

.loop-step {
  border-radius: 14px;
  padding: 1rem 0.85rem;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  border: 1.5px solid;
}

.loop-step-perceive { background: #eff6ff; border-color: #93c5fd; }
.loop-step-process  { background: #f5f3ff; border-color: #c4b5fd; }
.loop-step-decide   { background: #fff7ed; border-color: #fed7aa; }
.loop-step-act      { background: #f0fdf4; border-color: #86efac; }

.loop-step-icon {
  font-size: 1.4rem;
  display: block;
  line-height: 1;
  margin-bottom: 0.1rem;
}

.loop-step-num {
  font-size: 0.58rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #94a3b8;
  display: block;
}

.loop-step-title {
  font-size: 0.88rem;
  font-weight: 700;
  color: #1f2937;
  margin: 0;
  line-height: 1.2;
}

.loop-step-example {
  font-size: 0.73rem;
  color: #64748b;
  line-height: 1.5;
  margin: 0;
}

/* ================================================
   AUTONOMY DIAGRAM — niveles 0–5 + autonomía vs IA
================================================ */

.autonomy-wrap {
  margin: 1.2rem 0 1.8rem;
  overflow-x: auto;
}

.autonomy-diagram {
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
  margin: 1.2rem 0;
}

.autonomy-scale {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.75rem;
}

.autonomy-step {
  background: #fff;
  border: 1.5px solid #e2e8f0;
  border-radius: 14px;
  padding: 0.9rem 0.95rem;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.autonomy-step-title {
  font-size: 0.86rem;
  font-weight: 700;
  color: #0f172a;
  margin: 0;
  line-height: 1.3;
}

.autonomy-step-body {
  font-size: 0.76rem;
  color: #475569;
  line-height: 1.6;
  margin: 0;
}

.autonomy-step-example {
  font-size: 0.69rem;
  color: #64748b;
  line-height: 1.55;
  margin: 0.05rem 0 0;
  font-style: italic;
}

.autonomy-compare {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.75rem;
}

.autonomy-compare-card {
  background: #f8fafc;
  border: 1.5px solid #e2e8f0;
  border-radius: 14px;
  padding: 0.9rem 0.95rem;
}

.autonomy-compare-card-wide {
  background: #fff7ed;
  border-color: #fed7aa;
}

.autonomy-compare-title {
  font-size: 0.8rem;
  font-weight: 700;
  color: #0f172a;
  margin: 0 0 0.25rem;
}

.autonomy-compare-body {
  font-size: 0.75rem;
  color: #475569;
  line-height: 1.6;
  margin: 0;
}

/* ── Autonomy: cognitive dissonance block ───────────────── */
.autonomy-question {
  background: linear-gradient(135deg, #f0f9ff 0%, #eff6ff 100%);
  border: 1.5px solid #bae6fd;
  border-radius: 14px;
  padding: 1.4rem 1.6rem;
  margin: 1.4rem 0;
}
.autonomy-question-prompt {
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: #0369a1;
  margin: 0 0 0.5rem;
}
.autonomy-question-text {
  font-size: 1.05rem;
  font-weight: 600;
  color: #0f172a;
  margin: 0 0 1rem;
}
.autonomy-question-cards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.9rem;
  margin-bottom: 1rem;
}
.autonomy-question-card {
  background: white;
  border-radius: 10px;
  padding: 0.9rem 1rem;
  border: 1.5px solid #e2e8f0;
}
.autonomy-question-icon {
  font-size: 1.6rem;
  display: block;
  margin-bottom: 0.4rem;
}
.autonomy-question-card strong {
  display: block;
  margin-bottom: 0.35rem;
  color: #0f172a;
  font-size: 0.9rem;
}
.autonomy-question-card p {
  margin: 0;
  font-size: 0.82rem;
  color: #64748b;
  line-height: 1.5;
}
.autonomy-question-reveal {
  background: #fef3c7;
  border-left: 3.5px solid #f59e0b;
  padding: 0.75rem 1.1rem;
  border-radius: 0 8px 8px 0;
  font-size: 0.9rem;
  color: #78350f;
  line-height: 1.6;
}

/* ── Autonomy: AI badge on scale steps ───────────────────── */
.autonomy-ai-badge {
  display: inline-block;
  margin-top: 0.45rem;
  padding: 0.18rem 0.6rem;
  background: #eff6ff;
  border: 1px solid #93c5fd;
  border-radius: 20px;
  font-size: 0.67rem;
  font-weight: 700;
  color: #1d4ed8;
  letter-spacing: 0.04em;
}
.autonomy-ai-badge-high {
  background: #ede9fe;
  border-color: #a78bfa;
  color: #6d28d9;
}

/* ── Autonomy: 2×2 matrix ────────────────────────────────── */
.autonomy-matrix {
  display: grid;
  grid-template-columns: 130px 1fr 1fr;
  gap: 3px;
  background: #e2e8f0;
  border-radius: 12px;
  overflow: hidden;
  margin: 1.4rem 0 0.5rem;
}
.autonomy-matrix-corner { background: #f8fafc; }
.autonomy-matrix-col-header {
  background: #f1f5f9;
  padding: 0.75rem 1rem;
  font-size: 0.78rem;
  font-weight: 700;
  color: #475569;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.2rem;
}
.autonomy-matrix-col-header-ai {
  background: #f5f3ff;
  color: #6d28d9;
}
.autonomy-matrix-subhead {
  font-size: 0.64rem;
  font-weight: 400;
  font-style: italic;
  color: #94a3b8;
}
.autonomy-matrix-col-header-ai .autonomy-matrix-subhead { color: #a78bfa; }
.autonomy-matrix-row-header {
  background: #f1f5f9;
  padding: 0.75rem 0.8rem;
  font-size: 0.75rem;
  font-weight: 700;
  color: #475569;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 0.2rem;
  line-height: 1.3;
}
.autonomy-matrix-row-header-auto {
  background: #f0fdf4;
  color: #15803d;
}
.autonomy-matrix-row-header-auto .autonomy-matrix-subhead { color: #86efac; }
.autonomy-matrix-cell {
  background: white;
  padding: 1rem 1.1rem;
}
.autonomy-matrix-cell strong {
  display: block;
  margin-bottom: 0.3rem;
  color: #0f172a;
  font-size: 0.88rem;
}
.autonomy-matrix-cell p {
  margin: 0 0 0.4rem;
  color: #64748b;
  font-size: 0.81rem;
  line-height: 1.5;
}
.autonomy-matrix-tag {
  display: inline-block;
  padding: 0.15rem 0.55rem;
  border-radius: 20px;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  background: #f1f5f9;
  color: #64748b;
}
.autonomy-matrix-cell-ai { background: #faf5ff; }
.autonomy-matrix-cell-ai .autonomy-matrix-tag { background: #ede9fe; color: #6d28d9; }
.autonomy-matrix-cell-auto { background: #f0fdf4; }
.autonomy-matrix-cell-auto .autonomy-matrix-tag { background: #dcfce7; color: #15803d; }
.autonomy-matrix-cell-both {
  background: linear-gradient(135deg, #f0fdf4 0%, #f5f3ff 100%);
  border-left: 3px solid #22c55e;
}
.autonomy-matrix-cell-both .autonomy-matrix-tag {
  background: linear-gradient(90deg, #dcfce7, #ede9fe);
  color: #1f2937;
}

.autonomy-outer {
  border-radius: 12px;
  overflow: hidden;
  border: 1.5px solid #e2e8f0;
}

.autonomy-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
}

.autonomy-colhead {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 0.6rem 1rem;
  text-align: left;
  border-bottom: 1.5px solid #e2e8f0;
  background: #f8fafc;
  color: #64748b;
}

.autonomy-row td {
  padding: 0.68rem 1rem;
  border-top: 1px solid #f1f5f9;
  vertical-align: middle;
  color: #374151;
  line-height: 1.55;
}

.autonomy-row:nth-child(even) td {
  background: #fafafa;
}

.autonomy-cell-level {
  text-align: center;
  font-weight: 800;
  font-size: 1rem;
  color: #1f2937;
  white-space: nowrap;
}

.autonomy-badge {
  display: inline-block;
  font-size: 0.62rem;
  font-weight: 700;
  border-radius: 999px;
  padding: 0.1rem 0.5rem;
  white-space: nowrap;
}

.autonomy-badge-0 { background: #f1f5f9; color: #475569; border: 1px solid #cbd5e1; }
.autonomy-badge-1 { background: #eff6ff; color: #1d4ed8; border: 1px solid #93c5fd; }
.autonomy-badge-2 { background: #f5f3ff; color: #6d28d9; border: 1px solid #c4b5fd; }
.autonomy-badge-3 { background: #fff7ed; color: #c2410c; border: 1px solid #fed7aa; }
.autonomy-badge-4 { background: #fef9c3; color: #854d0e; border: 1px solid #fde047; }
.autonomy-badge-5 { background: #f0fdf4; color: #15803d; border: 1px solid #86efac; }

.autonomy-source {
  font-size: 0.68rem;
  color: #94a3b8;
  font-style: italic;
  margin: 0.4rem 0 0;
  text-align: right;
}

/* ================================================
   STORY CARD — RL explainer (image left + content right)
================================================ */

.story-card {
  display: flex;
  gap: 1.5rem;
  background: #ffffff;
  border: 1.5px solid #e2e8f0;
  border-left: 4px solid #f97316;
  border-radius: 12px;
  padding: 1.4rem 1.5rem;
  margin: 0.5rem 0 1.8rem;
  align-items: flex-start;
}

.story-img-placeholder {
  flex-shrink: 0;
  width: 110px;
  height: 145px;
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
}

.story-embed-placeholder {
  flex-shrink: 0;
  width: 190px;
  min-height: 145px;
  border-radius: 10px;
  background: linear-gradient(160deg, #0f172a 0%, #1e3a6e 55%, #334155 100%);
  border: 1.5px dashed rgba(255, 255, 255, 0.22);
  padding: 0.85rem 0.9rem;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 0.35rem;
}

.story-embed-kicker {
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.7);
}

.story-embed-title {
  font-size: 0.84rem;
  font-weight: 700;
  color: #fff;
  line-height: 1.35;
}

.story-embed-copy {
  font-size: 0.7rem;
  color: rgba(255, 255, 255, 0.82);
  line-height: 1.5;
}

.story-img-rl {
  background: linear-gradient(160deg, #0f1b3d 0%, #1e3a6e 45%, #7c3aed 80%, #f97316 100%);
}

.sip-emoji {
  font-size: 1.8rem;
  display: block;
  line-height: 1;
}

.sip-journal {
  font-size: 0.62rem;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.9);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  text-align: center;
}

.sip-year {
  font-size: 0.75rem;
  color: rgba(255, 255, 255, 0.72);
}

.story-content {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  min-width: 0;
  flex: 1;
}

.story-kicker {
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #f97316;
  margin: 0;
}

.story-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: #0f172a;
  margin: 0;
  line-height: 1.3;
}

.story-source {
  font-size: 0.75rem;
  color: #64748b;
  margin: 0;
  font-style: italic;
}

.story-body {
  font-size: 0.84rem;
  color: #374151;
  line-height: 1.75;
  margin: 0;
}

/* ================================================
   RL CANVAS ANIMATION
================================================ */

.rl-anim-wrap {
  flex-shrink: 0;
  width: 190px;
  border-radius: 10px;
  overflow: hidden;
  background: #0f172a;
  align-self: flex-start;
}

#rl-canvas {
  display: block;
  width: 100%;
  height: auto;
}

/* ================================================
   CASO FLIPPER — tab switcher + panels
================================================ */

.caso-flipper {
  margin: 1.2rem 0;
  border: 1.5px solid #e2e8f0;
  border-radius: 18px;
  overflow: hidden;
  background: #ffffff;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.05);
}

.caso-tabs {
  display: flex;
  background: #f1f5f9;
  border-bottom: 1px solid #e2e8f0;
}

.caso-tab {
  flex: 1;
  padding: 0.75rem 1rem;
  font-size: 0.82rem;
  font-weight: 600;
  color: #64748b;
  background: transparent;
  border: none;
  border-bottom: 3px solid transparent;
  cursor: pointer;
  transition: color 0.15s, background 0.15s, border-color 0.15s;
  text-align: center;
  line-height: 1.4;
}

.caso-tab:hover {
  color: #1f2937;
  background: #e8edf4;
}

.caso-tab.active[data-variant="success"] {
  color: #15803d;
  background: #f0fdf4;
  border-bottom-color: #22c55e;
}

.caso-tab.active[data-variant="warning"] {
  color: #92400e;
  background: #fffbeb;
  border-bottom-color: #f59e0b;
}

.caso-panel {
  padding: 1.4rem 1.5rem 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.caso-panel[hidden] {
  display: none;
}

.caso-label {
  display: inline-block;
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  border-radius: 999px;
  padding: 0.15rem 0.65rem;
  width: fit-content;
}

.caso-label-success {
  background: #dcfce7;
  color: #15803d;
  border: 1px solid #86efac;
}

.caso-label-warning {
  background: #fef9c3;
  color: #854d0e;
  border: 1px solid #fde047;
}

.caso-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: #0f172a;
  margin: 0;
  line-height: 1.3;
}

.caso-subtitle {
  font-size: 0.76rem;
  color: #64748b;
  margin: 0;
  font-style: italic;
}

.caso-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  margin: 0.4rem 0;
}

.caso-fact {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 0.8rem 0.9rem;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.caso-fact-label {
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #94a3b8;
  display: block;
}

.caso-fact-value {
  font-size: 0.82rem;
  color: #374151;
  line-height: 1.65;
}

.caso-insight {
  border-radius: 12px;
  padding: 0.9rem 1rem;
  font-size: 0.84rem;
  line-height: 1.7;
  margin-top: 0.2rem;
}

.caso-insight-success {
  background: #f0fdf4;
  border: 1.5px solid #86efac;
  color: #166534;
}

.caso-insight-warning {
  background: #fffbeb;
  border: 1.5px solid #fcd34d;
  color: #78350f;
}

/* ================================================
   PREGUNTA GRID — 4 preguntas éticas
================================================ */

.pregunta-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.9rem;
  margin: 1.2rem 0;
}

.pregunta-card {
  background: #ffffff;
  border: 1.5px solid #e2e8f0;
  border-radius: 18px;
  padding: 1.1rem 1.05rem;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.04);
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  transition: box-shadow 0.2s, border-color 0.2s;
}

.pregunta-card:hover {
  box-shadow: 0 6px 20px rgba(55, 90, 170, 0.09);
  border-color: #c7d2fe;
}

.pregunta-icon {
  font-size: 1.5rem;
  display: block;
  margin-bottom: 0.1rem;
}

.pregunta-title {
  font-size: 0.91rem;
  font-weight: 700;
  color: #1f2937;
  margin: 0;
  line-height: 1.35;
}

.pregunta-body {
  font-size: 0.8rem;
  color: #475569;
  line-height: 1.65;
  margin: 0;
}

/* ================================================
   ROUTE CARDS — rutas para seguir
================================================ */

.route-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 0.9rem;
  margin: 1.2rem 0;
}

.route-card {
  background: #fff;
  border: 1.5px solid #e2e8f0;
  border-radius: 18px;
  padding: 1rem 1.05rem;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.05);
  transition: box-shadow 0.2s, border-color 0.2s;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.route-card:hover {
  box-shadow: 0 6px 22px rgba(55, 90, 170, 0.12);
  border-color: #6495ed;
}

a.route-card {
  text-decoration: none;
  color: inherit;
  cursor: pointer;
}

a.route-card .route-name {
  color: #1d4ed8;
}

a.route-card:hover .route-name {
  text-decoration: underline;
}

.route-card-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.2rem;
}

.route-logo-emoji {
  font-size: 1.4rem;
  flex-shrink: 0;
}

.route-name {
  font-size: 0.9rem;
  font-weight: 700;
  color: #1f2937;
  margin: 0;
}

.route-name-featured {
  font-size: 1.05rem;
  letter-spacing: 0.02em;
}

.route-summary {
  font-size: 0.76rem;
  font-weight: 600;
  color: #334155;
  line-height: 1.55;
  margin: 0;
}

.route-org {
  font-size: 0.7rem;
  color: #64748b;
  margin: 0;
}

.route-desc {
  font-size: 0.79rem;
  color: #475569;
  line-height: 1.6;
  margin: 0;
  flex: 1;
}

.route-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  margin-top: 0.2rem;
}

.route-tag {
  font-size: 0.63rem;
  font-weight: 700;
  border-radius: 999px;
  padding: 0.1rem 0.45rem;
}

.route-tag-free     { background: #f0fdf4; color: #16a34a; border: 1px solid #86efac; }
.route-tag-es       { background: #eff6ff; color: #1d4ed8; border: 1px solid #93c5fd; }
.route-tag-en       { background: #fef9c3; color: #92400e; border: 1px solid #fde68a; }
.route-tag-browser  { background: #f8fafc; color: #475569; border: 1px solid #e2e8f0; }

.route-problem {
  font-size: 0.76rem;
  color: #78350f;
  background: #fffbeb;
  border-left: 2.5px solid #f59e0b;
  padding: 0.32rem 0.55rem 0.32rem 0.6rem;
  border-radius: 0 6px 6px 0;
  line-height: 1.58;
  margin: 0.1rem 0;
}

.route-ai-role {
  font-size: 0.76rem;
  color: #4c1d95;
  background: #faf5ff;
  border-left: 2.5px solid #7c3aed;
  padding: 0.32rem 0.55rem 0.32rem 0.6rem;
  border-radius: 0 6px 6px 0;
  line-height: 1.58;
  margin: 0.1rem 0;
}

.route-zone-label {
  display: block;
  font-size: 0.58rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin-bottom: 0.12rem;
  opacity: 0.6;
}

/* ================================================
   RESPONSIVE
================================================ */

html {
  scroll-behavior: smooth;
}

@media (max-width: 680px) {
  .loop-diagram {
    grid-template-columns: 1fr 1fr;
  }

  .autonomy-scale,
  .autonomy-compare {
    grid-template-columns: 1fr;
  }
  .autonomy-question-cards {
    grid-template-columns: 1fr;
  }
  .autonomy-matrix {
    grid-template-columns: 80px 1fr 1fr;
  }
  .autonomy-matrix-row-header {
    font-size: 0.65rem;
    padding: 0.5rem;
  }

  .caso-grid {
    grid-template-columns: 1fr;
  }

  .pregunta-grid {
    grid-template-columns: 1fr;
  }

  .story-card {
    flex-direction: column;
    gap: 1rem;
    align-items: center;
  }

  .story-img-placeholder,
  .story-embed-placeholder {
    width: 100%;
    height: 110px;
  }

  .rl-anim-wrap {
    width: 100%;
  }

  .caso-tabs {
    flex-direction: column;
  }

  .caso-tab {
    border-bottom: none;
    border-left: 3px solid transparent;
    text-align: left;
  }

  .caso-tab.active[data-variant="success"] {
    border-bottom: none;
    border-left-color: #22c55e;
  }

  .caso-tab.active[data-variant="warning"] {
    border-bottom: none;
    border-left-color: #f59e0b;
  }
}

@media (max-width: 480px) {
  .loop-diagram {
    grid-template-columns: 1fr;
  }

  .route-grid {
    grid-template-columns: 1fr;
  }
}

/* ================================================
   SENSOR CARDS — tipos de sensores
================================================ */

.sensor-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 0.7rem;
  margin: 1.2rem 0;
}

.sensor-card {
  background: #fff;
  border: 1.5px solid #e2e8f0;
  border-radius: 14px;
  padding: 0.85rem 0.8rem;
  display: flex;
  flex-direction: column;
  gap: 0.28rem;
}

.sensor-icon {
  font-size: 1.4rem;
  display: block;
  margin-bottom: 0.1rem;
}

.sensor-name {
  font-size: 0.86rem;
  font-weight: 700;
  color: #1f2937;
  margin: 0;
}

.sensor-what {
  font-size: 0.75rem;
  color: #374151;
  line-height: 1.6;
  margin: 0;
}

.sensor-limit {
  font-size: 0.7rem;
  color: #92400e;
  background: #fffbeb;
  border-radius: 6px;
  padding: 0.18rem 0.4rem;
  margin: 0.05rem 0;
  line-height: 1.5;
}

.sensor-use {
  font-size: 0.7rem;
  color: #64748b;
  margin: 0;
  font-style: italic;
}

/* ================================================
   SENSOR VISUAL — cámara vs LiDAR diagrams
================================================ */

.sensor-visual {
  display: flex;
  gap: 2rem;
  align-items: flex-start;
  justify-content: center;
  margin: 1.3rem 0 0.5rem;
  flex-wrap: wrap;
}

.sensor-visual-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
}

.sensor-visual-label {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #475569;
}

.sensor-visual-caption {
  font-size: 0.7rem;
  color: #94a3b8;
  font-style: italic;
  text-align: center;
  max-width: 140px;
  line-height: 1.5;
}

/* ================================================
   ROBOT GRID SIMULATOR
================================================ */

.robot-sim {
  border: 1.5px solid #e2e8f0;
  border-radius: 18px;
  overflow: hidden;
  background: #ffffff;
  box-shadow: 0 4px 16px rgba(0,0,0,0.05);
  margin: 1.2rem 0;
}

.sim-header {
  background: #f8fafc;
  border-bottom: 1px solid #e2e8f0;
  padding: 0.75rem 1.2rem;
  display: flex;
  align-items: center;
  gap: 1.2rem;
  flex-wrap: wrap;
}

.sim-status {
  font-size: 0.83rem;
  color: #374151;
  flex: 1;
  min-width: 160px;
  font-weight: 500;
  line-height: 1.5;
}

.sim-stats {
  display: flex;
  gap: 1rem;
  align-items: flex-start;
  flex-shrink: 0;
}

.sim-stat-label {
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #94a3b8;
  display: block;
  margin-bottom: 0.18rem;
}

.sim-battery-wrap,
.sim-moves-wrap {
  display: flex;
  flex-direction: column;
}

.sim-battery-row {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.sim-battery-bar {
  width: 68px;
  height: 7px;
  background: #e2e8f0;
  border-radius: 999px;
  overflow: hidden;
}

.sim-battery-fill {
  height: 100%;
  background: #22c55e;
  border-radius: 999px;
  transition: width 0.3s, background 0.3s;
}

.sim-battery-fill.low      { background: #f59e0b; }
.sim-battery-fill.critical { background: #ef4444; }

.sim-battery-pct {
  font-size: 0.72rem;
  font-weight: 700;
  color: #374151;
}

.sim-moves-count {
  font-size: 1.2rem;
  font-weight: 800;
  color: #1f2937;
  line-height: 1;
}

.sim-body {
  display: flex;
  align-items: stretch;
}

.sim-grid-wrap {
  padding: 1rem 0.8rem 1rem 1.2rem;
  flex-shrink: 0;
}

.sim-grid {
  display: grid;
  grid-template-columns: repeat(6, 46px);
  grid-template-rows: repeat(6, 46px);
  gap: 3px;
}

.sim-cell {
  width: 46px;
  height: 46px;
  border-radius: 7px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.15rem;
  background: #f1f5f9;
  border: 1.5px solid #e2e8f0;
  transition: background 0.15s;
  user-select: none;
}

.sim-cell-obstacle {
  background: #334155;
  border-color: #1e293b;
  font-size: 0.85rem;
  color: #64748b;
}

.sim-cell-goal {
  background: #fef9c3;
  border-color: #fde047;
}

.sim-cell-robot {
  background: #eff6ff;
  border-color: #3b82f6;
  transform: scale(1.06);
  position: relative;
  z-index: 1;
}

.sim-cell-robot.bump {
  animation: sim-bump 0.22s ease;
}

@keyframes sim-bump {
  0%   { transform: scale(1.06); }
  45%  { transform: scale(0.88); }
  100% { transform: scale(1.06); }
}

.sim-cell-won {
  animation: sim-celebrate 0.45s ease forwards;
}

@keyframes sim-celebrate {
  0%   { transform: scale(1.06); }
  50%  { transform: scale(1.35); }
  100% { transform: scale(1.15); }
}

.sim-side {
  flex: 1;
  display: flex;
  flex-direction: column;
  border-left: 1px solid #f1f5f9;
  padding: 1rem 1.2rem;
  gap: 1.1rem;
  min-width: 175px;
}

.sim-sensors {
  display: flex;
  flex-direction: column;
  gap: 0.42rem;
}

.sim-sensors-title,
.sim-controls-title {
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #94a3b8;
  margin-bottom: 0.05rem;
}

.sim-sensor-row {
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

.sim-sensor-dir {
  font-size: 0.7rem;
  color: #64748b;
  width: 38px;
  flex-shrink: 0;
}

.sim-sensor-bar-wrap {
  flex: 1;
  height: 6px;
  background: #f1f5f9;
  border-radius: 999px;
  overflow: hidden;
}

.sim-sensor-bar {
  height: 100%;
  border-radius: 999px;
  transition: width 0.25s, background 0.25s;
}

.sim-sensor-val {
  font-size: 0.7rem;
  font-weight: 700;
  color: #374151;
  width: 18px;
  text-align: right;
  flex-shrink: 0;
}

.sim-controls {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.sim-dpad {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
}

.sim-dpad-mid {
  display: flex;
  align-items: center;
  gap: 3px;
}

.sim-dpad-center {
  width: 36px;
  height: 36px;
}

.sim-btn {
  width: 36px;
  height: 36px;
  border: 1.5px solid #e2e8f0;
  border-radius: 8px;
  background: #f8fafc;
  cursor: pointer;
  font-size: 1rem;
  color: #475569;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.12s, border-color 0.12s, transform 0.08s;
  -webkit-tap-highlight-color: transparent;
  line-height: 1;
}

.sim-btn:hover:not(:disabled) {
  background: #e0e7ff;
  border-color: #818cf8;
  color: #3730a3;
}

.sim-btn:active:not(:disabled) {
  transform: scale(0.9);
}

.sim-btn:disabled {
  opacity: 0.38;
  cursor: not-allowed;
}

.sim-btn-reset {
  width: auto;
  padding: 0 0.85rem;
  font-size: 0.76rem;
  font-weight: 600;
  border-color: #cbd5e1;
  color: #64748b;
  align-self: flex-start;
  height: 32px;
}

.sim-btn-reset:hover:not(:disabled) {
  background: #fee2e2;
  border-color: #fca5a5;
  color: #b91c1c;
}

.sim-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem 0.9rem;
  border-top: 1px solid #f1f5f9;
  padding: 0.75rem 1.2rem;
}

.sim-legend-item {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.69rem;
  color: #64748b;
}

.sim-legend-dot {
  width: 14px;
  height: 14px;
  border-radius: 4px;
  flex-shrink: 0;
  border: 1.5px solid;
}

.sim-legend-dot-robot    { background: #eff6ff; border-color: #3b82f6; }
.sim-legend-dot-goal     { background: #fef9c3; border-color: #fde047; }
.sim-legend-dot-obstacle { background: #334155; border-color: #1e293b; }
.sim-legend-dot-free     { background: #f1f5f9; border-color: #e2e8f0; }

@media (max-width: 620px) {
  .sim-body        { flex-direction: column; }
  .sim-side        { border-left: none; border-top: 1px solid #f1f5f9;
                     flex-direction: row; flex-wrap: wrap; gap: 1rem; }
  .sim-grid        { grid-template-columns: repeat(6, 40px);
                     grid-template-rows: repeat(6, 40px); }
  .sim-cell        { width: 40px; height: 40px; font-size: 1rem; }
}
