:root {
  color-scheme: light;
  --paper: #fff;
  --surface: #fff;
  --ink: #24292e;
  --muted: #66717c;
  --line: #dce3ea;
  --navy: #1f3b52;
  --teal: #315f85;
  --blue: #06c;
  --accent: #06c;
  --accent-soft: #eef5ff;
  --gold: #2f6fa3;
  --shadow: none;
}

* { box-sizing: border-box; }

html, body { margin: 0; min-height: 100%; }

body {
  background: var(--paper);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button { font: inherit; }

.app-shell { width: min(1500px, 100%); margin: 0 auto; padding: 34px 34px 20px; }

.page-header {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 32px;
  margin-bottom: 23px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--teal);
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

h1, h2, p { margin-top: 0; }
h1 {
  max-width: 800px;
  margin-bottom: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(2rem, 4vw, 3.7rem);
  font-weight: 500;
  letter-spacing: -0.045em;
  line-height: 0.98;
}

.intro { max-width: 390px; margin-bottom: 4px; color: var(--muted); font-size: 0.95rem; line-height: 1.55; }

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(470px, 0.85fr);
  gap: 18px;
}

.panel {
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 70px;
  padding: 17px 20px;
  border-bottom: 1px solid var(--line);
}

.panel-heading > div { display: flex; align-items: center; gap: 11px; }
.panel-index {
  display: grid;
  width: 26px;
  height: 26px;
  place-items: center;
  border-radius: 50%;
  background: var(--navy);
  color: white;
  font-family: Georgia, serif;
  font-size: 0.82rem;
}

h2 { margin-bottom: 0; font-family: Georgia, "Times New Roman", serif; font-size: 1.2rem; font-weight: 600; }
.hint { color: var(--muted); font-size: 0.72rem; white-space: nowrap; }

.mobius-canvas {
  position: relative;
  height: clamp(480px, 61vh, 700px);
  cursor: grab;
  background: radial-gradient(circle at center, #f2f7fb 0%, #fff 68%);
}

.mobius-canvas:active { cursor: grabbing; }
.mobius-canvas canvas { display: block; width: 100%; height: 100%; }

.simplicial-panel { display: flex; flex-direction: column; }
.simplicial-map {
  --degree-column: 104px;
  --degree-gap: 14px;
  display: grid;
  grid-template-columns: var(--degree-column) minmax(0, 1fr);
  gap: var(--degree-gap);
  flex: 1;
  min-height: 670px;
  padding: 24px 20px 12px;
}
.degree-diagram {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto minmax(0, 1fr) auto;
  height: 100%;
  padding: 90% 12px;
  align-items: center;
 
}
.simplicial-levels {
  position: relative;
  display: grid;
  grid-template-rows: repeat(3, minmax(0, 1fr));
  min-width: 0;
  height: 100%;
}
.face-links { position: absolute; inset: 0; z-index: 0; width: 100%; height: 100%; pointer-events: none; overflow: visible; }
.face-links > path { fill: none; stroke: var(--accent); stroke-width: 1.8; stroke-linecap: round; opacity: 0.44; }
.face-links marker path { fill: var(--accent); stroke: none; }
.face-links text { fill: #174f80; font-family: Georgia, serif; font-size: 13px; font-style: italic; paint-order: stroke; stroke: var(--surface); stroke-width: 5px; }

.degree-row {
  position: relative;
  z-index: 1;
  display: flex;
  min-height: 0;
  align-items: center;
  justify-content: center;
}
.degree-row:not(:last-of-type)::after {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  border-bottom: 1px dashed var(--line);
  content: "";
  pointer-events: none;
}

.face-operators {
  display: flex;
  width: 100%;
  height: 100%;
  justify-content: space-around;
  gap: 0;
  padding: 12px 0;
  color: var(--accent);
  font-size: 0.82rem;
  pointer-events: none;
}
.face-operators > span {
  position: relative;
  display: block;
  flex: 1 1 1;
  height: 100%;
}
.face-operators .math-label {
  position: absolute;
  top: 50%;
  right: 1%;
  line-height: 1;
}
.face-operators b {
  position: absolute;
  top: 0;
  left: 68%;
  width: 1px;
  height: 100%;
  background: currentColor;
}
.face-operators b::after {
  position: absolute;
  bottom: -1px;
  left: -3px;
  width: 6px;
  height: 6px;
  border-right: 1px solid currentColor;
  border-bottom: 1px solid currentColor;
  content: "";
  transform: rotate(45deg);
}



.degree-label { color: var(--navy); font-size: 1.7rem; text-align: center; }
.degree-label small { display: block; margin-top: 3px; color: var(--muted); font-family: Inter, sans-serif; font-size: 0.64rem; letter-spacing: 0.06em; text-transform: uppercase; }
.math-label mjx-container,
.simplex mjx-container,
.selection-readout mjx-container {
  margin: 0 !important;
}

.simplex-list {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 9px;
}
.triangles-list {
  display: grid;
  grid-template-columns: repeat(3, 68px);
  gap: 18px 20px;
  align-content: center;
  justify-content: center;
}
.edges-list {
  display: grid;
  grid-template-columns: repeat(4, max-content);
  gap: 14px 18px;
  align-content: center;
  justify-content: center;
}
.vertices-list { gap: 14px; }
.simplex {
  position: relative;
  display: inline-grid;
  place-items: center;
  border: 1px solid var(--line);
  background: white;
  color: var(--navy);
  transition: transform 160ms ease, border-color 160ms ease, background 160ms ease, color 160ms ease, box-shadow 160ms ease, opacity 180ms ease, filter 180ms ease;
}

button.simplex { cursor: pointer; }
button.simplex:hover { transform: translateY(-2px); border-color: var(--teal); opacity: 0.7; filter: none; }
button.simplex.is-selected:hover, button.simplex.is-related:hover { opacity: 1; }
button.simplex:focus-visible { outline: 3px solid rgba(228, 86, 58, 0.25); outline-offset: 2px; }
.simplicial-map.has-selection .simplex:not(.is-selected):not(.is-related) { opacity: 0.18; filter: grayscale(0.7); }
.simplex.is-related { opacity: 1; filter: none; border-color: #79a7cf; background: var(--accent-soft); color: #174f80; box-shadow: none; }
.simplex.is-selected { opacity: 1; filter: none; transform: translateY(-3px); border-color: var(--accent); background: var(--accent); color: white; box-shadow: 0 4px 12px rgba(0, 102, 204, 0.18); }

.triangle-simplex { width: 68px; height: 45px; border-radius: 8px; }
.triangle-simplex strong { font-size: 1rem; font-weight: 400; }
.edge-simplex { min-width: 56px; height: 39px; padding: 0 10px; border-radius: 7px; font-size: 1rem; }
.vertex-simplex { width: 40px; height: 40px; border-radius: 50%; font-family: Georgia, serif; font-weight: 700; }

.selection-readout {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  min-height: 78px;
  padding: 14px 20px;
  border-top: 1px solid var(--line);
  background: #f7faff;
}
.selected-name span { display: block; margin-bottom: 2px; color: var(--muted); font-size: 0.65rem; letter-spacing: 0.08em; text-transform: uppercase; }
.selected-name strong { font-family: Georgia, serif; font-size: 1.6rem; color: var(--accent); }
.face-expression { display: flex; align-items: center; gap: 12px; font-family: Georgia, serif; color: var(--navy); }
.face-expression span { padding: 6px 9px; border-bottom: 2px solid rgba(228, 86, 58, 0.5); }
.face-expression b { color: var(--accent); font-weight: 400; }

.legend { display: flex; align-items: center; gap: 22px; padding: 15px 4px 0; color: var(--muted); font-size: 0.74rem; }
.legend > span { display: inline-flex; align-items: center; gap: 7px; }
.legend-mark { display: inline-block; }
.triangle-mark { width: 0; height: 0; border-right: 7px solid transparent; border-bottom: 12px solid var(--teal); border-left: 7px solid transparent; }
.edge-mark { width: 16px; border-top: 3px solid var(--accent); }
.vertex-mark { width: 8px; height: 8px; border-radius: 50%; background: var(--navy); }
.legend .count { margin-left: auto; font-weight: 700; color: var(--navy); }

@media (max-width: 1020px) {
  .app-shell { padding: 24px 20px 18px; }
  .page-header { align-items: start; flex-direction: column; gap: 13px; }
  .workspace { grid-template-columns: 1fr; }
  .mobius-canvas { height: 520px; }
  .simplicial-map { min-height: 670px; }
}

@media (max-width: 620px) {
  .app-shell { padding: 18px 12px; }
  h1 { font-size: 2.2rem; }
  .panel-heading { align-items: start; gap: 8px; }
  .hint { white-space: normal; text-align: right; }
  .mobius-canvas { height: 420px; }
  .simplicial-map {
    --degree-column: 53px;
    --degree-gap: 8px;
    padding: 9px 12px 4px;
  }
  .degree-diagram { padding: 190% 4px; }
  .degree-label { font-size: 1.35rem; }
  .face-operators { font-size: 0.68rem; }
  .triangle-simplex { width: 58px; height: 42px; }
  .triangles-list { grid-template-columns: repeat(3, 58px); gap: 16px 18px; }
  .edge-simplex { min-width: 42px; padding: 0 6px; }
  .edges-list { grid-template-columns: repeat(4, max-content); gap: 13px 12px; }
  .selection-readout { align-items: start; flex-direction: column; gap: 7px; }
  .legend { flex-wrap: wrap; gap: 10px 17px; }
  .legend .count { width: 100%; margin-left: 0; }
}

/* Presentación compacta cuando la visualización forma parte de las notas. */
.embedded body { background: #f3f7fc; }
.embedded .app-shell { width: 100%; padding: 0; background: #f3f7fc; }
.embedded .page-header,
.embedded .legend { display: none; }
.embedded .workspace { gap: 12px; }
.embedded .panel {
  border: 0;
  border-radius: 0;
  background: rgba(255, 255, 255, 0.5);
  box-shadow: none;
}
.embedded .geometry-panel { border-right: 1px solid var(--line); }
.embedded .panel-heading { min-height: 52px; padding: 10px 16px; }
.embedded .panel-index { display: none; }
.embedded .panel-heading h2 {
  color: #06c;
  font-family: "Lucida Grande", Arial, Helvetica, sans-serif;
  font-size: 1rem;
  font-weight: 600;
}
.embedded .hint { font-size: 0.68rem; }
.embedded .mobius-canvas { height: 620px; }
.embedded .mobius-canvas { background: radial-gradient(circle at center, #eaf3fb 0%, #f6f9fd 72%); }
.embedded .simplicial-map { min-height: 620px; padding-top: 10px; background: #f7faff; }
.embedded .degree-row { min-height: 195px; }
.embedded .degree-label { color: #06c; }
.embedded .selection-readout { background: #f1f6fc; }

@media (max-width: 900px) {
  .embedded .workspace { grid-template-columns: 1fr; }
  .embedded .geometry-panel { border-right: 0; border-bottom: 1px solid var(--line); }
  .embedded .mobius-canvas { height: 460px; }
}

/* Dentro de las notas se conservan dos columnas hasta llegar a ancho de teléfono. */
@media (min-width: 521px) and (max-width: 1020px) {
  .embedded .workspace {
    grid-template-columns: minmax(0, 0.92fr) minmax(0, 1.08fr);
    gap: 8px;
  }
  .embedded .geometry-panel {
    border-right: 1px solid var(--line);
    border-bottom: 0;
  }
  .embedded .mobius-canvas { height: 620px; }
  .embedded .panel-heading { padding-inline: 10px; }
  .embedded .simplicial-map {
    --degree-column: 56px;
    --degree-gap: 18px;
    padding-inline: 18px 6px;
  }
  .embedded .triangle-simplex { width: 52px; height: 40px; }
  .embedded .triangles-list {
    grid-template-columns: repeat(3, 52px);
    gap: 12px;
  }
  .embedded .edge-simplex { min-width: 39px; padding-inline: 4px; }
  .embedded .edges-list { gap: 11px 8px; }
  .embedded .vertices-list { gap: 7px; }
  .embedded .vertex-simplex { width: 32px; height: 32px; }
  .embedded .selection-readout {
    min-height: 66px;
    padding: 9px 10px;
  }
  .embedded .face-expression {
    width: 100%;
    flex-wrap: wrap;
    gap: 4px 7px;
    font-size: 0.82rem;
  }
  .embedded .face-expression span { padding: 3px 4px; }
}
