/* ==========================================================================
   ANED — Neobrutalism Light Study Theme (mates.lluyotlabs.com/aned)
   High readability, crisp dark borders, clean offset shadows, elegant contrast
   ========================================================================== */

:root {
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', 'Courier New', monospace;

  /* Sophisticated Neobrutalist Light Palette (Glare-free, high contrast, academic) */
  --bg-main: #f8fafc;
  --bg-card: #ffffff;
  --bg-sidebar: #f1f5f9;
  --border-color: #0f172a;
  --text-main: #0f172a;
  --text-muted: #334155;
  --text-dim: #64748b;

  /* Refined Pastel Accent Tones with Dark High-Contrast Text */
  --c-yellow: #fef9c3;
  --c-yellow-dark: #fef08a;
  --c-yellow-text: #854d0e;

  --c-pink: #ffe4e6;
  --c-pink-dark: #fecdd3;
  --c-pink-text: #9f1239;

  --c-blue: #e0f2fe;
  --c-blue-dark: #bae6fd;
  --c-blue-text: #0369a1;

  --c-green: #dcfce7;
  --c-green-dark: #bbf7d0;
  --c-green-text: #15803d;

  --c-purple: #ede9fe;
  --c-purple-dark: #ddd6fe;
  --c-purple-text: #5b21b6;

  --c-orange: #ffedd5;
  --c-orange-dark: #fed7aa;
  --c-orange-text: #9a3412;

  /* Shadows: crisp, tight, neobrutalist */
  --shadow-sm: 2px 2px 0px var(--border-color);
  --shadow-md: 3.5px 3.5px 0px var(--border-color);
  --shadow-lg: 5px 5px 0px var(--border-color);
  --shadow-xl: 7px 7px 0px var(--border-color);
}

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

html {
  scroll-behavior: smooth;
  scroll-padding-top: 130px;
}

body {
  background-color: var(--bg-main);
  color: var(--text-main);
  font-family: var(--font-sans);
  line-height: 1.65;
  font-size: 15.5px;
  -webkit-font-smoothing: antialiased;
}

/* ==========================================================================
   TOP NAVBAR & CONTROLS
   ========================================================================== */

:root {
  --topbar-h: 128px;
}

.top-navbar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--bg-main);
  border-bottom: 3px solid var(--border-color);
  padding: 10px 20px;
  transform: translateY(0);
  transition: transform 0.26s cubic-bezier(0.2, 0.9, 0.2, 1),
              margin-bottom 0.26s cubic-bezier(0.2, 0.9, 0.2, 1);
  will-change: transform, margin-bottom;
}

body.topbar-collapsed .top-navbar {
  transform: translateY(-100%);
  margin-bottom: calc(-1 * var(--topbar-h, 128px));
  pointer-events: none;
}

.nav-container {
  max-width: 1540px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  padding-left: 88px;
}

.brand-section {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-badge {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  font-weight: 800;
  background: #ffffff;
  color: var(--text-main);
  text-decoration: none;
  border: 2.5px solid var(--border-color);
  box-shadow: var(--shadow-sm);
  padding: 5px 12px;
  border-radius: 4px;
  transition: all 0.15s;
}

.brand-badge:hover {
  transform: translate(-1px, -1px);
  box-shadow: var(--shadow-md);
  background: #f1f5f9;
}

.breadcrumb-tag {
  font-family: var(--font-mono);
  font-size: 0.82rem;
  font-weight: 700;
  background: #f1f5f9;
  color: #334155;
  border: 2px solid var(--border-color);
  padding: 4px 10px;
  border-radius: 4px;
}

.nav-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.btn-brutal {
  font-family: var(--font-mono);
  font-size: 0.82rem;
  font-weight: 700;
  background: #ffffff;
  color: var(--text-main);
  border: 2.5px solid var(--border-color);
  box-shadow: var(--shadow-sm);
  padding: 6px 14px;
  border-radius: 4px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  text-decoration: none;
  transition: all 0.15s;
}

.btn-brutal:hover {
  transform: translate(-2px, -2px);
  box-shadow: var(--shadow-md);
}

.btn-brutal:active {
  transform: translate(2px, 2px);
  box-shadow: 1px 1px 0px var(--border-color);
}

.btn-brutal.primary {
  background: var(--c-pink);
}

/* Minimalist Neobrutalist Icon Buttons */
.btn-icon-brutal {
  font-family: var(--font-mono);
  width: 38px;
  height: 38px;
  background: #ffffff;
  color: var(--text-main);
  border: 2.5px solid var(--border-color);
  box-shadow: 2px 2px 0px var(--border-color);
  border-radius: 4px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  transition: all 0.12s cubic-bezier(0.2, 0.9, 0.2, 1);
  padding: 0;
  flex-shrink: 0;
  position: relative;
}

.btn-icon-brutal.sm {
  width: 30px;
  height: 30px;
  border-width: 2px;
  box-shadow: 2px 2px 0px var(--border-color);
}

.btn-icon-brutal:hover {
  transform: translate(-2px, -2px);
  box-shadow: 3.5px 3.5px 0px var(--border-color);
  background: var(--c-yellow);
}

.btn-icon-brutal:active {
  transform: translate(1px, 1px);
  box-shadow: 1px 1px 0px var(--border-color);
}

.btn-icon-brutal.active-state {
  background: var(--c-yellow);
  box-shadow: 1px 1px 0px var(--border-color);
  transform: translate(1px, 1px);
}

#btn-toggle-zen.active-state {
  background: var(--c-pink);
}

#btn-toggle-topbar.active-state {
  background: var(--c-blue);
}

/* Compact PDF button */
.btn-pdf-brutal {
  font-family: var(--font-mono);
  font-size: 0.82rem;
  font-weight: 800;
  height: 38px;
  padding: 0 12px;
  background: #0f172a;
  color: #ffffff;
  border: 2.5px solid var(--border-color);
  box-shadow: 2px 2px 0px var(--border-color);
  border-radius: 4px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  text-decoration: none;
  transition: all 0.12s cubic-bezier(0.2, 0.9, 0.2, 1);
  flex-shrink: 0;
}

.btn-pdf-brutal:hover {
  transform: translate(-2px, -2px);
  box-shadow: 3.5px 3.5px 0px var(--border-color);
  background: #1e293b;
  color: #ffffff;
}

.btn-pdf-brutal:active {
  transform: translate(1px, 1px);
  box-shadow: 1px 1px 0px var(--border-color);
}

/* Secondary Filter Bar */
.filter-bar {
  background: #ffffff;
  border-bottom: 3px solid var(--border-color);
  padding: 10px 20px;
}

.filter-container {
  max-width: 1540px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}

.search-box {
  position: relative;
  flex: 1;
  min-width: 280px;
  max-width: 460px;
}

.search-input {
  width: 100%;
  background: var(--bg-main);
  border: 2.5px solid var(--border-color);
  box-shadow: var(--shadow-sm);
  border-radius: 4px;
  color: var(--text-main);
  font-family: var(--font-mono);
  font-size: 0.85rem;
  font-weight: 600;
  padding: 8px 12px 8px 36px;
  outline: none;
  transition: all 0.15s;
}

.search-input:focus {
  background: #ffffff;
  box-shadow: var(--shadow-md);
}

.search-icon {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  width: 18px;
  height: 18px;
  color: var(--text-main);
  pointer-events: none;
}

.filter-pills {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.pill-brutal {
  font-family: var(--font-mono);
  font-size: 0.76rem;
  font-weight: 700;
  background: #ffffff;
  color: #334155;
  border: 2px solid var(--border-color);
  box-shadow: 2px 2px 0px var(--border-color);
  padding: 5px 12px;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.12s;
  white-space: nowrap;
}

.pill-brutal:hover {
  transform: translate(-1px, -1px);
  box-shadow: 3px 3px 0px var(--border-color);
  background: #f8fafc;
}

.pill-brutal.active {
  background: #0f172a;
  color: #ffffff;
  border-color: #0f172a;
  transform: translate(1px, 1px);
  box-shadow: 1px 1px 0px var(--border-color);
}

.pill-brutal.fire.active {
  background: #be123c;
  color: #ffffff;
  border-color: #0f172a;
}

/* ==========================================================================
   MAIN LAYOUT (SIDEBAR + CONTENT)
   ========================================================================== */

.app-layout {
  max-width: 1540px;
  margin: 0 auto;
  display: flex;
  position: relative;
}

/* Sticky Sidebar Table of Contents */
.sidebar {
  width: 320px;
  flex-shrink: 0;
  background: var(--bg-sidebar);
  border-right: 3px solid var(--border-color);
  height: calc(100vh - var(--topbar-h, 128px));
  position: sticky;
  top: var(--topbar-h, 128px);
  overflow-y: auto;
  padding: 20px 14px 60px 18px;
  transition: margin-left 0.26s cubic-bezier(0.2, 0.9, 0.2, 1),
              top 0.26s cubic-bezier(0.2, 0.9, 0.2, 1),
              height 0.26s cubic-bezier(0.2, 0.9, 0.2, 1);
  will-change: margin-left, top, height;
}

body.topbar-collapsed .sidebar {
  top: 0;
  height: 100vh;
  padding-top: 56px;
}

body.sidebar-collapsed .sidebar {
  margin-left: -320px;
  pointer-events: none;
}

.sidebar-heading {
  font-family: var(--font-mono);
  font-size: 0.82rem;
  font-weight: 800;
  text-transform: uppercase;
  background: #121212;
  color: #ffffff;
  padding: 6px 10px;
  border-radius: 3px;
  display: inline-block;
  margin-bottom: 14px;
}

.toc-group {
  margin-bottom: 20px;
}

.toc-group-title {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  font-weight: 800;
  color: var(--text-main);
  text-transform: uppercase;
  padding: 4px 6px;
  border-bottom: 2px solid var(--border-color);
  margin-bottom: 6px;
}

.toc-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 8px;
  font-size: 0.83rem;
  font-weight: 600;
  color: var(--text-main);
  text-decoration: none;
  border: 1.5px solid transparent;
  border-radius: 4px;
  margin-bottom: 3px;
  transition: all 0.15s;
}

.toc-link:hover {
  background: #ffffff;
  border-color: var(--border-color);
  box-shadow: 2px 2px 0px var(--border-color);
}

.toc-link.active {
  background: var(--c-yellow);
  border-color: var(--border-color);
  box-shadow: 2px 2px 0px var(--border-color);
  font-weight: 800;
}

.toc-badge {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  font-weight: 800;
  padding: 1px 6px;
  border-radius: 3px;
  border: 1.5px solid var(--border-color);
  background: var(--c-pink);
}

/* Main Content Area */
.main-content {
  flex: 1;
  padding: 30px 40px 100px 40px;
  max-width: 1080px;
  min-width: 0;
  transition: max-width 0.26s cubic-bezier(0.2, 0.9, 0.2, 1);
}

body.sidebar-collapsed .main-content {
  max-width: 1360px;
  width: 100%;
  margin: 0 auto;
}

body.topbar-collapsed .main-content {
  padding-top: 60px;
}

/* ==========================================================================
   HERO / BANNER NEOBRUTALISTA
   ========================================================================== */

.hero-brutal {
  background: #ffffff;
  border: 3.5px solid var(--border-color);
  box-shadow: var(--shadow-lg);
  border-radius: 6px;
  padding: 30px;
  margin-bottom: 36px;
  position: relative;
}

.hero-top-tag {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  font-weight: 800;
  background: var(--c-yellow);
  border: 2px solid var(--border-color);
  padding: 3px 10px;
  border-radius: 4px;
  margin-bottom: 12px;
  box-shadow: 2px 2px 0px var(--border-color);
}

.hero-title {
  font-size: 2.2rem;
  font-weight: 900;
  line-height: 1.15;
  letter-spacing: -0.03em;
  margin-bottom: 12px;
}

.hero-desc {
  font-size: 1.05rem;
  color: var(--text-muted);
  line-height: 1.55;
  margin-bottom: 24px;
}

.hero-meta-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
}

.hero-meta-card {
  background: var(--bg-main);
  border: 2px solid var(--border-color);
  box-shadow: 3px 3px 0px var(--border-color);
  padding: 12px 16px;
  border-radius: 4px;
}

.meta-num {
  font-family: var(--font-mono);
  font-size: 1.4rem;
  font-weight: 900;
}

.meta-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-dim);
}

/* ==========================================================================
   SECTION HEADINGS NEOBRUTALISTAS
   ========================================================================== */

.section-banner,
.section-banner.blue,
.section-banner.green,
.section-banner.pink,
.section-banner.yellow {
  background: #ffffff;
  border: 2.5px solid var(--border-color);
  border-left: 8px solid #0f172a;
  box-shadow: var(--shadow-md);
  padding: 16px 20px;
  border-radius: 6px;
  margin: 44px 0 22px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.section-title {
  font-size: 1.25rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--text-main);
  line-height: 1.35;
}

.section-tag {
  font-family: var(--font-mono);
  font-size: 0.76rem;
  font-weight: 800;
  background: #f1f5f9;
  color: #0f172a;
  border: 1.5px solid var(--border-color);
  box-shadow: 1.5px 1.5px 0px var(--border-color);
  padding: 4px 10px;
  border-radius: 4px;
  white-space: nowrap;
  flex-shrink: 0;
}

/* Sub-headings */
h3.subsection-title {
  font-size: 1.15rem;
  font-weight: 800;
  margin: 28px 0 12px 0;
  padding-bottom: 4px;
  border-bottom: 2px dashed var(--border-color);
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ==========================================================================
   NEOBRUTALIST ITEM CARDS (THEOREMS, LEMMAS, DEFINITIONS, EXERCISES)
   ========================================================================== */

.brutal-card {
  background: #ffffff;
  border: 3px solid var(--border-color);
  box-shadow: var(--shadow-md);
  border-radius: 6px;
  padding: 22px;
  margin-bottom: 28px;
  transition: all 0.15s;
}

.brutal-card:hover {
  transform: translate(-2px, -2px);
  box-shadow: var(--shadow-lg);
}

.card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 12px;
  border-bottom: 2px solid var(--border-color);
  padding-bottom: 10px;
}

.card-title-group {
  flex: 1;
  min-width: 260px;
}

.card-label {
  font-family: var(--font-mono);
  font-size: 0.74rem;
  font-weight: 800;
  text-transform: uppercase;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  border: 1.5px solid var(--border-color);
  border-radius: 4px;
  margin-bottom: 6px;
  box-shadow: 1.5px 1.5px 0px var(--border-color);
  cursor: pointer;
  user-select: none;
  transition: transform 0.12s ease, box-shadow 0.12s ease, filter 0.12s ease;
}

.card-label:hover {
  transform: translate(-1.5px, -1.5px);
  box-shadow: 3px 3px 0px var(--border-color);
  filter: brightness(0.96);
}

.card-label:active {
  transform: translate(1px, 1px);
  box-shadow: 0.5px 0.5px 0px var(--border-color);
}

.card-label.teo {
  background: var(--c-purple);
  color: var(--c-purple-text);
}

.card-label.lema {
  background: var(--c-green);
  color: var(--c-green-text);
}

.card-label.def {
  background: var(--c-blue);
  color: var(--c-blue-text);
}

.card-label.corolario {
  background: var(--c-pink);
  color: var(--c-pink-text);
}

.card-label.ej {
  background: var(--c-yellow);
  color: var(--c-yellow-text);
}

.card-label.matlab {
  background: #ccfbf1;
  color: #0f766e;
}

.card-title {
  font-size: 1.22rem;
  font-weight: 800;
  letter-spacing: -0.015em;
  line-height: 1.3;
}

/* Badges Neobrutalistas */
.badge-priority {
  font-family: var(--font-mono);
  font-size: 0.74rem;
  font-weight: 800;
  padding: 4px 10px;
  border: 1.5px solid var(--border-color);
  box-shadow: 1.5px 1.5px 0px var(--border-color);
  border-radius: 4px;
  white-space: nowrap;
}

.badge-priority.fire {
  background: var(--c-pink);
  color: var(--c-pink-text);
}

.badge-priority.high {
  background: var(--c-orange);
  color: var(--c-orange-text);
}

.badge-priority.medium {
  background: var(--c-green);
  color: var(--c-green-text);
}

.badge-priority.info {
  background: #f1f5f9;
  color: #334155;
}

/* Content Box (Enunciado) */
.card-body {
  font-size: 0.98rem;
  line-height: 1.7;
  color: var(--text-main);
  margin-bottom: 16px;
}

.card-body p {
  margin-bottom: 10px;
}

/* POST-IT GMAIL / PINCELADA DEL COMPAÑERO */
.postit-gmail {
  background: #fef9c3;
  border: 2px solid var(--border-color);
  box-shadow: 2.5px 2.5px 0px var(--border-color);
  padding: 12px 16px;
  border-radius: 5px;
  margin: 14px 0;
  font-size: 0.92rem;
  color: #1e293b;
}

.postit-header {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
  color: #713f12;
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.postit-gmail.pink {
  background: #ffe4e6;
}

.postit-gmail.pink .postit-header {
  color: #9f1239;
}

.postit-gmail.blue {
  background: #e0f2fe;
}

.postit-gmail.blue .postit-header {
  color: #0369a1;
}
/* DEMOSTRACIÓN RIGUROSA PLEGABLE */
.details-brutal {
  margin-top: 14px;
  margin-bottom: 8px;
  border-radius: 6px;
  transition: all 0.15s ease;
}

/* Colapsado: Botón discreto a la derecha, tono grisáceo/blanco sutil sin saturar */
.details-brutal:not([open]) {
  width: fit-content;
  max-width: 100%;
  border: none;
  background: transparent;
  box-shadow: none;
  margin-left: auto;
  margin-right: 0;
  display: block;
}

.details-brutal:not([open]) summary {
  background: #f8fafc;
  color: #475569;
  border: 1.5px solid #cbd5e1;
  border-radius: 5px;
  box-shadow: 1.5px 1.5px 0px #cbd5e1;
  padding: 4px 11px;
  gap: 6px;
  font-size: 0.78rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  cursor: pointer;
  user-select: none;
  list-style: none;
  transition: all 0.12s cubic-bezier(0.2, 0.9, 0.2, 1);
}

.details-brutal:not([open]) summary::-webkit-details-marker {
  display: none;
}

.details-brutal:not([open]) summary:hover {
  background: #ffffff;
  border-color: #94a3b8;
  color: #0f172a;
  transform: translate(-1px, -1px);
  box-shadow: 2px 2px 0px #94a3b8;
}

.details-brutal:not([open]) summary:active {
  transform: translate(1px, 1px);
  box-shadow: 0.5px 0.5px 0px #94a3b8;
}

.details-brutal:not([open]) .demo-tag {
  background: transparent;
  border: none;
  padding: 0;
  color: inherit;
  font-size: 0.78rem;
  letter-spacing: 0.02em;
}

.details-brutal:not([open]) .demo-source {
  display: none !important; /* Esconde el título largo mientras esté colapsado */
}

.details-brutal:not([open]) .demo-chevron {
  color: #94a3b8;
  font-size: 0.65rem;
  margin-left: 2px;
}

/* Abierto: Despliegue completo con encabezado y pasos rigurosos */
.details-brutal[open] {
  width: 100%;
  background: #ffffff;
  border: 2px solid var(--border-color);
  border-radius: 6px;
  box-shadow: 3px 3px 0px var(--border-color);
  overflow: hidden;
  margin-top: 14px;
  margin-bottom: 14px;
}

.details-brutal[open] summary {
  background: #f1f5f9;
  border-bottom: 2px solid var(--border-color);
  padding: 10px 14px;
  cursor: pointer;
  user-select: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  list-style: none;
  transition: background 0.15s ease;
}

.details-brutal[open] summary::-webkit-details-marker {
  display: none;
}

.details-brutal[open] summary:hover {
  background: #e2e8f0;
}

.details-brutal[open] .demo-tag {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  background: #0f172a;
  color: #ffffff;
  padding: 3px 8px;
  border-radius: 4px;
  border: 1px solid #0f172a;
  flex-shrink: 0;
}

.details-brutal[open] .demo-source {
  font-family: var(--font-sans);
  font-size: 0.88rem;
  font-weight: 700;
  color: #0f172a;
  background: transparent;
  border: none;
  padding: 0;
  line-height: 1.35;
  display: inline-block !important;
}

.details-brutal[open] .demo-chevron {
  font-size: 0.75rem;
  font-weight: 900;
  color: var(--border-color);
  transform: rotate(180deg);
  display: inline-block;
  flex-shrink: 0;
  margin-left: 8px;
}

.demo-summary-content {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 0;
}

.demo-inner {
  padding: 18px 20px;
  font-size: 0.95rem;
  line-height: 1.75;
  color: var(--text-main);
  background: #fafaf9;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* Botón y bloque especial: Ejercicio Examen (Junio 2025) */
.details-brutal.exam-demo {
  margin-top: 16px;
}

.details-brutal.exam-demo:not([open]) {
  margin-left: auto;
  margin-right: 0;
}

.details-brutal.exam-demo:not([open]) summary {
  background: #faf5ff;
  border: 1.5px solid #d8b4fe;
  color: #7e22ce;
  box-shadow: 1.5px 1.5px 0px #e9d5ff;
}

.details-brutal.exam-demo:not([open]) summary:hover {
  background: #f3e8ff;
  border-color: #c084fc;
  color: #6b21a8;
  box-shadow: 2px 2px 0px #c084fc;
}

.details-brutal.exam-demo:not([open]) .demo-tag.exam-tag {
  color: #7e22ce;
  font-weight: 800;
}

.details-brutal.exam-demo[open] {
  border-color: #4f46e5;
  box-shadow: 3.5px 3.5px 0px #312e81;
}

.details-brutal.exam-demo[open] summary {
  background: #eef2ff;
  border-bottom: 2px solid #4f46e5;
}

.details-brutal.exam-demo[open] .demo-tag.exam-tag {
  background: #4f46e5;
  color: #ffffff;
}

.details-brutal.exam-demo[open] .demo-inner {
  background: #f8fafc;
  border-left: 4px solid #4f46e5;
}

/* Apartados individuales de teoremas con demostraciones separadas */
.card-part {
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1.5px dashed #cbd5e1;
}

.card-part:last-child {
  margin-bottom: 0;
  padding-bottom: 0;
  border-bottom: none;
}

.part-statement {
  margin-bottom: 8px;
}

.details-brutal.part-demo {
  margin-top: 8px;
}

/* Pasos individuales de la demostración */
.demo-step {
  margin: 0;
  padding: 16px 20px;
  background: #ffffff;
  border: 1.5px solid var(--border-color);
  box-shadow: 2px 2px 0px var(--border-color);
  border-radius: 5px;
  position: relative;
}

.step-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
  padding-bottom: 8px;
  border-bottom: 1.5px dashed #cbd5e1;
  flex-wrap: wrap;
}

/* Píldoras de pasos de demostración: UNIFORMES en todas las pruebas */
.step-pill,
.step-pill.step-blue,
.step-pill.step-green,
.step-pill.step-purple,
.step-pill.step-pink,
.step-pill.step-yellow,
.step-pill.step-orange {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
  padding: 2.5px 9px;
  border-radius: 4px;
  border: 1.5px solid #000000;
  background: #0f172a;
  color: #ffffff;
  box-shadow: 1px 1px 0px #000000;
}

.step-title {
  font-family: var(--font-sans);
  font-size: 0.92rem;
  font-weight: 800;
  color: #0f172a;
}

.demo-step strong:first-child:not(.step-head *) {
  display: block;
  font-family: var(--font-mono);
  font-size: 0.88rem;
  font-weight: 800;
  color: #121212;
  margin-bottom: 8px;
  padding-bottom: 6px;
  border-bottom: 1.5px dashed #cbd5e1;
}

.demo-step p {
  margin: 8px 0;
}

/* Cajas de llamada matemática (Herramientas auxiliares y desigualdades clave) - Uniforme ámbar cálido */
.math-callout,
.math-callout.yellow,
.math-callout.green,
.math-callout.blue,
.math-callout.purple {
  background: #fffdf5;
  border: 1.5px solid var(--border-color);
  border-left: 5px solid #d97706;
  box-shadow: 2px 2px 0px var(--border-color);
  border-radius: 5px;
  padding: 12px 16px;
  margin: 12px 0;
}

.math-callout-title {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 6px;
}

/* Conclusión final de la demostración (Q.E.D. / Demostrado) */
.demo-qed {
  background: #f0fdf4;
  border: 1.5px solid #16a34a;
  box-shadow: 2px 2px 0px var(--border-color);
  border-radius: 5px;
  padding: 10px 14px;
  font-size: 0.88rem;
  font-weight: 700;
  color: #15803d;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 14px;
}

.demo-qed .qed-badge {
  font-family: var(--font-mono);
  font-size: 0.74rem;
  font-weight: 800;
  text-transform: uppercase;
  background: #15803d;
  color: #ffffff;
  padding: 2px 8px;
  border-radius: 3px;
}

.demo-qed .qed-symbol {
  font-size: 0.95rem;
  font-weight: 900;
  color: #15803d;
}

.katex-display {
  margin: 12px 0 !important;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 4px 0;
}

/* ==========================================================================
   CODE BLOCKS
   ========================================================================== */

.code-box {
  background: #18181b;
  color: #f4f4f5;
  border: 2.5px solid var(--border-color);
  box-shadow: 3px 3px 0px var(--border-color);
  border-radius: 4px;
  margin: 14px 0;
  overflow: hidden;
}

.code-header {
  background: #27272a;
  border-bottom: 2px solid #3f3f46;
  padding: 6px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-family: var(--font-mono);
  font-size: 0.76rem;
  font-weight: 700;
  color: #a1a1aa;
}

.btn-copy-code {
  background: var(--c-yellow);
  color: #121212;
  border: 1.5px solid #121212;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 800;
  padding: 2px 8px;
  border-radius: 3px;
  cursor: pointer;
  transition: all 0.1s;
}

.btn-copy-code:hover {
  transform: translate(-1px, -1px);
}

pre {
  margin: 0;
  padding: 14px;
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 0.84rem;
  line-height: 1.55;
}

/* KaTeX custom tweaks */
.katex-display {
  margin: 0.8em 0 !important;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 4px 0;
}

/* Empty State */
.empty-state-card {
  background: #ffffff;
  border: 3px solid var(--border-color);
  box-shadow: 4px 4px 0px var(--border-color);
  border-radius: 6px;
  padding: 48px 24px;
  text-align: center;
  margin: 30px auto;
  max-width: 520px;
}

.empty-state-icon {
  font-size: 2.8rem;
  margin-bottom: 12px;
}

.empty-state-card h3 {
  font-family: var(--font-mono);
  font-size: 1.25rem;
  font-weight: 800;
  margin-bottom: 8px;
  color: var(--text-main);
}

.empty-state-card p {
  color: #52525b;
  font-size: 0.94rem;
  margin-bottom: 20px;
  line-height: 1.5;
}

/* ==========================================================================
   UNIFIED LEFT CONTROLS (Ultra-compact 2-button pill on the left)
   ========================================================================== */

.app-controls {
  position: fixed;
  top: 11px;
  left: 16px;
  z-index: 1001;
  display: inline-flex;
  align-items: center;
  gap: 3px;
  background: #ffffff;
  padding: 3px;
  border: 2.5px solid var(--border-color);
  border-radius: 5px;
  box-shadow: 2px 2px 0px var(--border-color);
}

.ctrl-btn {
  width: 32px;
  height: 32px;
  background: transparent;
  border: 1.5px solid transparent;
  border-radius: 3px;
  color: var(--text-main);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: all 0.12s cubic-bezier(0.2, 0.9, 0.2, 1);
}

.ctrl-btn:hover {
  background: #f1f5f9;
  border-color: var(--border-color);
  box-shadow: 1.5px 1.5px 0px var(--border-color);
  transform: translate(-1px, -1px);
}

.ctrl-btn:active {
  transform: translate(1px, 1px);
  box-shadow: none;
}

.ctrl-btn.active-state {
  background: #0f172a;
  color: #ffffff;
  border-color: #0f172a;
  box-shadow: 1.5px 1.5px 0px var(--border-color);
}

/* Chevron direction on topbar toggle */
.icon-chevron-down {
  display: none;
}

body.topbar-collapsed .icon-chevron-up {
  display: none;
}

body.topbar-collapsed .icon-chevron-down {
  display: block;
}

body.topbar-collapsed #btn-ctrl-topbar {
  background: #0f172a;
  color: #ffffff;
  border-color: var(--border-color);
  box-shadow: 1.5px 1.5px 0px var(--border-color);
}

/* ==========================================================================
   MOBILE SIDEBAR DRAWER & BACKDROP
   ========================================================================== */

.sidebar-backdrop {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(15, 23, 42, 0.5);
  backdrop-filter: blur(2px);
  z-index: 1999;
  opacity: 0;
  transition: opacity 0.24s ease;
}

.sidebar-header-row {
  display: none;
}

.btn-close-sidebar {
  display: none;
}

/* ==========================================================================
   RESPONSIVE DESIGN (TABLETS & MOBILE)
   ========================================================================== */

@media (max-width: 1024px) {
  /* Sidebar as mobile drawer */
  .sidebar {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 300px !important;
    max-width: 84vw !important;
    height: 100vh !important;
    z-index: 2000 !important;
    background: #ffffff !important;
    border-right: 3px solid var(--border-color) !important;
    box-shadow: 6px 0 0 rgba(0,0,0,0.1), 0 0 25px rgba(0,0,0,0.25) !important;
    transform: translateX(-100%);
    transition: transform 0.25s cubic-bezier(0.2, 0.9, 0.2, 1);
    display: block !important;
    padding: 18px 16px 80px 16px !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch;
  }

  body.mobile-sidebar-open .sidebar {
    transform: translateX(0) !important;
  }

  body.mobile-sidebar-open .sidebar-backdrop {
    display: block;
    opacity: 1;
  }

  .sidebar-header-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
    padding-bottom: 8px;
    border-bottom: 2px dashed #e2e8f0;
  }

  .btn-close-sidebar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    background: #ffffff;
    border: 2px solid var(--border-color);
    border-radius: 4px;
    box-shadow: 1.5px 1.5px 0 var(--border-color);
    font-family: var(--font-mono);
    font-size: 0.9rem;
    font-weight: 900;
    cursor: pointer;
  }

  .main-content {
    padding: 20px 16px 80px 16px;
    max-width: 100%;
    overflow-x: hidden;
  }

  .hero-title {
    font-size: 1.8rem;
  }
}

@media (max-width: 768px) {
  /* Prevent any horizontal screen wobbling */
  html, body {
    max-width: 100vw;
    overflow-x: hidden;
  }

  /* Compact controls on mobile */
  .app-controls {
    top: 8px;
    left: 8px;
    padding: 2px;
    gap: 2px;
    border-width: 2px;
    box-shadow: 1.5px 1.5px 0px var(--border-color);
  }

  .ctrl-btn {
    width: 30px;
    height: 30px;
  }

  .ctrl-btn svg {
    width: 15px;
    height: 15px;
  }

  /* Compact Top Navbar in a single clean row */
  .top-navbar {
    padding: 8px 10px;
    border-bottom-width: 2px;
  }

  .nav-container {
    padding-left: 74px; /* Space for the 68px wide controls */
    padding-right: 0;
    gap: 6px;
    flex-wrap: nowrap;
    align-items: center;
    justify-content: space-between;
  }

  .brand-section {
    gap: 6px;
    min-width: 0;
    flex-shrink: 1;
  }

  .brand-badge {
    font-size: 0.78rem;
    padding: 4px 8px;
    border-width: 2px;
    box-shadow: 1.5px 1.5px 0px var(--border-color);
    max-width: 145px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  /* Hide verbose breadcrumb on mobile to fit everything in 1 line */
  .breadcrumb-tag {
    display: none;
  }

  .nav-actions {
    gap: 5px;
    flex-shrink: 0;
  }

  .btn-icon-brutal {
    width: 32px;
    height: 32px;
    border-width: 2px;
    box-shadow: 1.5px 1.5px 0px var(--border-color);
  }

  .btn-icon-brutal svg {
    width: 15px;
    height: 15px;
  }

  .btn-pdf-brutal {
    height: 32px;
    padding: 0 8px;
    font-size: 0.72rem;
    border-width: 2px;
    box-shadow: 1.5px 1.5px 0px var(--border-color);
    gap: 4px;
  }

  .btn-pdf-brutal svg {
    width: 13px;
    height: 13px;
  }

  /* Filter Bar on Mobile: search + horizontal swipeable chips */
  .filter-bar {
    padding: 6px 10px 8px 10px;
    border-bottom-width: 2px;
  }

  .filter-container {
    flex-direction: column;
    align-items: stretch;
    gap: 6px;
  }

  .search-box {
    max-width: 100%;
    min-width: 0;
  }

  .search-input {
    font-size: 0.8rem;
    padding: 6px 10px 6px 30px;
    height: 34px;
    border-width: 2px;
    box-shadow: 1.5px 1.5px 0px var(--border-color);
  }

  .search-icon {
    width: 15px;
    height: 15px;
    left: 8px;
  }

  .filter-pills {
    display: flex;
    flex-wrap: nowrap;
    overflow-x: auto;
    gap: 6px;
    padding: 2px 1px 4px 1px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }

  .filter-pills::-webkit-scrollbar {
    display: none;
  }

  .pill-brutal {
    flex-shrink: 0;
    white-space: nowrap;
    font-size: 0.72rem;
    padding: 4px 9px;
    border-width: 1.5px;
    box-shadow: 1.5px 1.5px 0px var(--border-color);
  }

  /* Main Content Padding */
  .main-content {
    padding: 14px 10px 80px 10px;
    max-width: 100%;
    overflow-x: hidden;
  }

  /* Hero Section */
  .hero-card {
    padding: 14px 12px;
    border-width: 2px;
    box-shadow: 2.5px 2.5px 0px var(--border-color);
    margin-bottom: 18px;
  }

  .hero-title {
    font-size: 1.4rem;
    line-height: 1.25;
  }

  .hero-desc {
    font-size: 0.86rem;
    line-height: 1.5;
    margin-bottom: 14px;
  }

  .hero-meta-grid {
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }

  .hero-meta-card {
    padding: 8px 10px;
    border-width: 1.5px;
    box-shadow: 1.5px 1.5px 0 var(--border-color);
  }

  .meta-num {
    font-size: 1.15rem;
  }

  .meta-label {
    font-size: 0.7rem;
  }

  /* Section Banners */
  .section-banner {
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
    padding: 12px 14px;
    margin: 28px 0 16px 0;
    border-width: 2px;
    border-left-width: 6px;
    box-shadow: 2px 2px 0 var(--border-color);
  }

  .section-title {
    font-size: 1.05rem;
    line-height: 1.35;
    word-break: break-word;
  }

  .section-tag {
    font-size: 0.7rem;
    padding: 2px 8px;
    border-width: 1.5px;
  }

  h3.subsection-title {
    font-size: 1rem;
    margin: 20px 0 10px 0;
  }

  /* Theorem Cards */
  .brutal-card {
    padding: 14px 12px;
    margin-bottom: 16px;
    border-width: 2px;
    box-shadow: 2.5px 2.5px 0px var(--border-color);
    border-radius: 6px;
    max-width: 100%;
    overflow-x: hidden;
  }

  .card-top {
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
    padding-bottom: 8px;
    margin-bottom: 10px;
    border-bottom-width: 1.5px;
  }

  .card-title-group {
    min-width: 0;
    width: 100%;
  }

  .card-title {
    font-size: 1.05rem;
    line-height: 1.32;
    word-break: break-word;
  }

  .card-label {
    font-size: 0.68rem;
    padding: 2px 7px;
  }

  .badge-priority {
    font-size: 0.68rem;
    padding: 3px 8px;
  }

  .card-body {
    font-size: 0.9rem;
    line-height: 1.62;
    margin-bottom: 12px;
    word-break: break-word;
  }

  /* Math Equations KaTeX horizontal scroll */
  .katex-display {
    margin: 8px 0 !important;
    padding: 4px 0 !important;
    overflow-x: auto !important;
    overflow-y: hidden !important;
    -webkit-overflow-scrolling: touch;
    max-width: 100% !important;
  }

  .katex {
    font-size: 0.95em;
  }

  /* Details and Demos */
  .details-brutal {
    border-width: 1.5px;
    box-shadow: 2px 2px 0 var(--border-color);
    margin-top: 12px;
  }

  .details-brutal summary {
    padding: 8px 10px;
  }

  .demo-summary-content {
    gap: 6px;
    flex-wrap: wrap;
  }

  .demo-tag {
    font-size: 0.68rem;
    padding: 2px 6px;
  }

  .demo-source {
    font-size: 0.8rem;
    line-height: 1.25;
    word-break: break-word;
  }

  .demo-inner {
    padding: 12px 10px;
    gap: 12px;
  }

  .demo-step {
    padding: 12px;
    border-width: 1.5px;
    box-shadow: 1.5px 1.5px 0 var(--border-color);
  }

  .step-head {
    gap: 6px;
    margin-bottom: 8px;
    padding-bottom: 6px;
  }

  .step-pill {
    font-size: 0.68rem;
    padding: 2px 6px;
  }

  .step-title {
    font-size: 0.85rem;
    line-height: 1.25;
  }

  .math-callout {
    padding: 10px 12px;
    border-width: 1.5px;
    border-left-width: 4px;
    box-shadow: 1.5px 1.5px 0 var(--border-color);
  }

  .math-callout-title {
    font-size: 0.72rem;
  }

  .demo-qed {
    padding: 8px 12px;
    font-size: 0.8rem;
    border-width: 1.5px;
    box-shadow: 1.5px 1.5px 0 var(--border-color);
    flex-wrap: wrap;
    gap: 6px;
  }
}

@media (max-width: 480px) {
  .brand-badge {
    max-width: 125px;
    font-size: 0.74rem;
    padding: 3px 6px;
  }

  .btn-pdf-brutal span {
    display: none; /* Icon only on very small screens */
  }

  .btn-pdf-brutal {
    padding: 0 7px;
    width: 32px;
    justify-content: center;
  }

  .hero-meta-grid {
    grid-template-columns: 1fr;
  }
}

/* ==========================================================================
   MODO ESTUDIO / MODO FOCO (TRUE FULLSCREEN SPLIT VIEW)
   ========================================================================== */

.focus-modal {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  z-index: 10000;
  background: #ffffff;
  padding: 0;
  display: none;
  overflow: hidden;
}

.focus-modal.active {
  display: flex;
  flex-direction: column;
}

body.focus-mode-open {
  overflow: hidden !important;
}

.focus-modal-dialog {
  width: 100vw;
  height: 100vh;
  max-width: 100vw;
  max-height: 100vh;
  background: #f8fafc;
  border: none;
  border-radius: 0;
  box-shadow: none;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Modal Header: Slim 40px with Centered Fixed Navigation Buttons */
.focus-header {
  height: 40px;
  background: #ffffff;
  border-bottom: 2px solid #000000;
  padding: 0 16px;
  display: flex;
  align-items: center;
  position: relative;
  flex-shrink: 0;
}

.focus-header-left {
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: 40%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.focus-badge {
  font-family: var(--font-mono);
  font-size: 0.76rem;
  font-weight: 900;
  text-transform: uppercase;
  background: #0f172a;
  color: #ffffff;
  padding: 2px 7px;
  border-radius: 4px;
  border: 1.5px solid #000000;
  flex-shrink: 0;
}

.focus-counter {
  font-family: var(--font-mono);
  font-size: 0.74rem;
  font-weight: 800;
  background: #f1f5f9;
  border: 1.5px solid var(--border-color);
  padding: 2px 6px;
  border-radius: 4px;
  color: var(--text-dim);
  flex-shrink: 0;
}

.focus-cat-tag {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 700;
  background: #fef08a;
  color: #854d0e;
  border: 1.5px solid #ca8a04;
  padding: 2px 6px;
  border-radius: 4px;
  flex-shrink: 0;
}

/* BOTONES DE NAVEGACIÓN CENTRALES: FIJOS AL 50% - NUNCA SE MUEVEN */
.focus-header-center {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  align-items: center;
  gap: 8px;
  z-index: 10;
}

.focus-nav-btn {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  font-weight: 800;
  background: #ffffff;
  color: #0f172a;
  border: 1.5px solid #000000;
  border-radius: 4px;
  padding: 3px 13px;
  height: 28px;
  box-shadow: 1.5px 1.5px 0px #000000;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  transition: all 0.1s ease;
}

.focus-nav-btn:hover:not(:disabled) {
  background: #e2e8f0;
  transform: translate(-1px, -1px);
  box-shadow: 2.5px 2.5px 0px #000000;
}

.focus-nav-btn:active:not(:disabled) {
  transform: translate(1px, 1px);
  box-shadow: 0.5px 0.5px 0px #000000;
}

.focus-nav-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
  box-shadow: none;
}

/* CONTROLES DE LA DERECHA */
.focus-header-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
  z-index: 10;
}

.focus-action-btn {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 800;
  background: #f1f5f9;
  color: #334155;
  border: 1.5px solid #64748b;
  border-radius: 4px;
  padding: 3px 9px;
  height: 28px;
  box-shadow: 1.5px 1.5px 0px #64748b;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: all 0.1s ease;
}

.focus-action-btn:hover {
  background: #e2e8f0;
  color: #0f172a;
  transform: translate(-1px, -1px);
  box-shadow: 2px 2px 0px #0f172a;
}

.focus-close-btn {
  font-family: var(--font-mono);
  font-size: 0.95rem;
  font-weight: 900;
  background: #fee2e2;
  color: #b91c1c;
  border: 1.5px solid #b91c1c;
  border-radius: 4px;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 1.5px 1.5px 0px #b91c1c;
  cursor: pointer;
  transition: all 0.1s ease;
}

.focus-close-btn:hover {
  background: #fecaca;
  transform: translate(-1px, -1px);
  box-shadow: 2.5px 2.5px 0px #b91c1c;
}

/* Modal Body */
.focus-modal-body {
  flex: 1;
  height: calc(100vh - 40px);
  overflow: hidden;
  padding: 10px 18px 12px 18px;
  background: #f1f5f9;
  display: flex;
  flex-direction: column;
}

/* Custom subtle scrollbar */
.focus-demo-container::-webkit-scrollbar,
.focus-top-stmt-body::-webkit-scrollbar,
.focus-modal-body::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

.focus-demo-container::-webkit-scrollbar-track,
.focus-top-stmt-body::-webkit-scrollbar-track,
.focus-modal-body::-webkit-scrollbar-track {
  background: #e2e8f0;
  border-radius: 3px;
}

.focus-demo-container::-webkit-scrollbar-thumb,
.focus-top-stmt-body::-webkit-scrollbar-thumb,
.focus-modal-body::-webkit-scrollbar-thumb {
  background: #94a3b8;
  border-radius: 3px;
}

.focus-demo-container::-webkit-scrollbar-thumb:hover,
.focus-top-stmt-body::-webkit-scrollbar-thumb:hover,
.focus-modal-body::-webkit-scrollbar-thumb:hover {
  background: #64748b;
}

/* ==========================================================================
   CASO 1: TEOREMA / RESULTADO SIN DEMOSTRACIÓN (OCUPA TODO EL HUECO)
   ========================================================================== */
.focus-no-demo-layout {
  max-width: 1040px;
  margin: 10px auto;
  width: 100%;
  overflow-y: auto;
}

.focus-single-card {
  background: #ffffff;
  border: 2.5px solid #000000;
  border-radius: 8px;
  box-shadow: 3.5px 3.5px 0px #000000;
  padding: 22px 30px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.focus-single-card .card-top {
  border-bottom: 2px solid var(--border-color);
  padding-bottom: 10px;
  margin-bottom: 2px;
}

.focus-single-card .card-title {
  font-size: 1.3rem;
  font-weight: 900;
  line-height: 1.3;
}

.focus-single-card .card-body {
  font-size: 1rem;
  line-height: 1.7;
}

/* ==========================================================================
   CASO 2: CON DEMOSTRACIÓN (ENUNCIADO ARRIBA EN FRENTE + DEMO COMPLETA)
   ========================================================================== */
.focus-study-layout {
  max-width: 1180px;
  margin: 0 auto;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 0;
}

/* Tarjeta del Enunciado Superior (Compacta, ancha, fija sin scrolls molestos) */
.focus-top-stmt-card {
  background: #ffffff;
  border: 2px solid #000000;
  border-radius: 6px;
  box-shadow: 2.5px 2.5px 0px #000000;
  padding: 8px 14px;
  flex-shrink: 0;
  transition: all 0.15s ease;
}

.focus-top-stmt-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 4px;
}

.focus-top-stmt-info {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  overflow: hidden;
}

.focus-top-stmt-title {
  font-size: 0.95rem;
  font-weight: 800;
  color: #0f172a;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.focus-stmt-collapse-btn {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 800;
  background: #f8fafc;
  color: #475569;
  border: 1.5px solid #cbd5e1;
  border-radius: 4px;
  padding: 2px 7px;
  cursor: pointer;
  transition: all 0.1s ease;
  flex-shrink: 0;
}

.focus-stmt-collapse-btn:hover {
  background: #e2e8f0;
  color: #0f172a;
  border-color: #000000;
}

/* Barra de pestañas dedicada para apartados (en una fila propia y limpia) */
.focus-part-tabs-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-bottom: 5px;
  margin-bottom: 5px;
  border-bottom: 1.5px dashed #e2e8f0;
}

.focus-part-tabs {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  background: #e2e8f0;
  border: 1.5px solid #000000;
  border-radius: 6px;
  padding: 2.5px;
  flex-wrap: wrap;
}

.focus-part-tab {
  font-family: var(--font-mono);
  font-size: 0.73rem;
  font-weight: 700;
  background: transparent;
  color: #475569;
  border: 1px solid transparent;
  border-radius: 4px;
  padding: 3px 9px;
  cursor: pointer;
  transition: all 0.12s ease;
  white-space: nowrap;
}

.focus-part-tab:hover {
  background: #cbd5e1;
  color: #0f172a;
}

.focus-part-tab.active {
  background: #ffffff;
  color: #000000;
  font-weight: 800;
  border: 1.5px solid #000000;
  box-shadow: 1.5px 1.5px 0px #000000;
  transform: translate(-0.5px, -0.5px);
}

.focus-part-tab.tab-all {
  color: #64748b;
  border-left: 1px dashed #94a3b8;
}

.focus-part-tab.tab-all.active {
  background: #0f172a;
  color: #ffffff;
  border: 1.5px solid #000000;
  box-shadow: 1.5px 1.5px 0px #000000;
}

.focus-top-stmt-body {
  font-size: 0.82rem;
  line-height: 1.45;
  color: #1e293b;
  max-height: 26vh;
  overflow-y: auto;
}

.focus-top-stmt-body p {
  margin: 2px 0 4px 0 !important;
}

.focus-top-stmt-body p:last-child {
  margin-bottom: 0 !important;
}

.focus-top-stmt-body .katex-display {
  margin: 3px 0 !important;
  font-size: 0.95em !important;
}

.focus-top-stmt-card.collapsed .focus-top-stmt-body {
  display: none;
}

.focus-top-stmt-card.collapsed .focus-part-tabs-bar {
  border-bottom: none;
  margin-bottom: 0;
  padding-bottom: 0;
}

/* Área de Demostración Completa */
.focus-demo-container {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.focus-demo-card {
  background: #ffffff;
  border: 2px solid #000000;
  border-radius: 6px;
  box-shadow: 2.5px 2.5px 0px #000000;
  padding: 12px 18px;
}

.focus-demo-card .details-brutal {
  width: 100% !important;
  border: none !important;
  background: transparent !important;
  box-shadow: none !important;
  margin: 0 !important;
}

.focus-demo-card .details-brutal summary {
  display: none !important;
}

.focus-demo-card .demo-inner {
  padding: 0 !important;
  background: transparent !important;
  gap: 8px !important;
}

.focus-demo-card .demo-step {
  margin: 0 !important;
  padding: 8px 12px !important;
  background: #ffffff;
  border: 1.5px solid var(--border-color);
  box-shadow: 1.5px 1.5px 0px var(--border-color);
  border-radius: 4px;
}

.focus-demo-card .step-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
  padding-bottom: 3px;
  border-bottom: 1px dashed #cbd5e1;
}

.focus-demo-card .step-pill {
  font-size: 0.68rem;
  font-weight: 800;
  padding: 1.5px 6px;
  border-radius: 3px;
}

.focus-demo-card .step-title {
  font-size: 0.82rem;
  font-weight: 800;
  color: #0f172a;
}

.focus-demo-card .demo-step p {
  font-size: 0.84rem;
  line-height: 1.45;
  margin: 3px 0 !important;
}

.focus-demo-card .demo-step .katex-display {
  margin: 4px 0 !important;
  font-size: 0.96em !important;
}

.focus-demo-card .math-callout {
  padding: 6px 10px;
  margin: 6px 0;
  font-size: 0.82rem;
}

.focus-demo-card .math-callout .katex-display {
  margin: 3px 0 !important;
}

.focus-demo-card .demo-qed {
  margin-top: 6px !important;
  padding: 4px 10px !important;
  font-size: 0.8rem !important;
}

/* Botón de continuación al pie del apartado */
.focus-part-nav-footer {
  margin-top: 8px;
  padding-top: 6px;
  border-top: 1.5px dashed #cbd5e1;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

.focus-btn-next-part {
  font-family: var(--font-mono);
  font-size: 0.76rem;
  font-weight: 800;
  background: #0f172a;
  color: #ffffff;
  border: 1.5px solid #000000;
  border-radius: 5px;
  padding: 5px 12px;
  box-shadow: 1.5px 1.5px 0px #000000;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.1s ease;
}

.focus-btn-next-part:hover {
  background: #1e293b;
  transform: translate(-1px, -1px);
  box-shadow: 2px 2px 0px #000000;
}

.focus-btn-prev-part {
  font-family: var(--font-mono);
  font-size: 0.76rem;
  font-weight: 700;
  background: #f8fafc;
  color: #475569;
  border: 1.5px solid #cbd5e1;
  border-radius: 5px;
  padding: 5px 12px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.1s ease;
}

.focus-btn-prev-part:hover {
  background: #e2e8f0;
  color: #0f172a;
  border-color: #000000;
}

@media (max-width: 768px) {
  .focus-modal-body {
    overflow-y: auto;
    padding: 8px;
    height: calc(100vh - 40px);
  }

  .focus-study-layout {
    height: auto;
    min-height: 100%;
  }

  .focus-demo-container {
    overflow: visible;
  }

  .focus-header-left {
    max-width: 32%;
  }

  .focus-top-stmt-title {
    font-size: 0.86rem;
  }
}

