:root {
    /* Último tamaño de cuerpo usado en un bloque texto (enunciados de actividades lo reutilizan) */
    --genlibros-read-size: 1.02rem;
    --book-body-size: 1.02rem;
    --primary-color: #4f46e5;
    /* Indigo 600 ? tono algo m?s sobrio */
    --primary-hover: #4338ca;
    --primary-muted: #eef2ff;
    --primary-muted-hover: #e0e7ff;
    --bg-color: #eceef2;
    --surface-color: #ffffff;
    --surface-subtle: #f8f9fb;
    --border-color: #e2e5eb;
    --text-primary: #111827;
    --text-secondary: #6b7280;
    --danger-color: #ef4444;
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;
    --shadow-xs: 0 1px 2px rgba(15, 23, 42, 0.04);
    --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.06), 0 1px 2px rgba(15, 23, 42, 0.04);
    --shadow-md: 0 4px 14px rgba(15, 23, 42, 0.08);
    --focus-ring: 0 0 0 3px rgba(79, 70, 229, 0.22);
    --book-serif: 'Literata', 'Georgia', 'Times New Roman', serif;
    --book-ink: #1a1a1a;
    --book-ink-muted: #4b5563;
    --book-measure: 42rem;
    /* Ritmo vertical (libro / página): separación entre bloques en el lienzo */
    --block-stack-gap: 7px;
    --block-inner-pad-x: 8px;
    --block-inner-pad-y: 6px;
    /* Lienzo del docente (trabajo): idéntico a la vista estudiante para fidelidad 1:1 */
    --canvas-page-pad-y: 32px;
    --canvas-page-pad-x: 28px;
    /* Vista lectura (vista previa): sangría tipo página impresa / ePub */
    --book-read-page-pad-y: 1.45rem;
    --book-read-page-pad-x: clamp(1rem, 2.2vw, 1.55rem);
    /* Hoja tipo impresa a tamaño cuaderno / libro (884px - idéntico a vista estudiante) */
    --sheet-aspect-w: 8.5;
    --sheet-aspect-h: 11;
    --sheet-page-width: min(884px, min(95vw, 100%));
    --book-spread-gap: 32px;
    /* Tema editorial ?libro acad?mico? (prose, citas, aperturas, actividades) */
    --book-heading-rule: #d6d3d1;
    --book-heading-accent: #3730a3;
    --book-drop-cap: #4338ca;
    --book-quote-border: #a5b4fc;
    --book-quote-bg-start: #f5f5ff;
    --book-quote-bg-end: #fafafa;
    --book-marker: #6366f1;
    --book-prose-link: #4f46e5;
    --book-exam-accent: #0f766e;
    --book-reference-accent: #475569;
    --book-activity-bar: rgba(79, 70, 229, 0.38);
    /* Acentos de la biblioteca de bloques (sidebar) */
    --category-content: #3b82f6;
    --category-eval: #f59e0b;
    --category-game: #10b981;
    --category-tech: #8b5cf6;
    --category-math: #6366f1;
    --category-bio: #22c55e;
}

body[data-sheet-format='legal'] {
    --sheet-aspect-h: 14;
}



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

.text-secondary { color: var(--text-secondary); }
.text-danger { color: var(--danger-color); }

.bg-white { background-color: #ffffff; }

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    color: var(--text-primary);
    background-color: var(--bg-color);
    min-height: 100vh;
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-font-smoothing: antialiased;
}

/* Editor a pantalla completa: el scroll va dentro del lienzo (.canvas-container), no en el body */
body.genlibros-editor-active {
    height: 100vh;
    max-height: 100dvh;
    overflow: hidden;
}

::selection {
    background: rgba(79, 70, 229, 0.15);
    color: inherit;
}

.editor-layout {
    display: flex;
    flex-direction: column;
    height: 100%;
}

/* Header */
.editor-header {
    height: 58px;
    background: linear-gradient(180deg, #ffffff 0%, #fafbfc 100%);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 22px;
    flex-shrink: 0;
    box-shadow: var(--shadow-xs);
}

.header-left {
    display: flex;
    align-items: center;
    gap: 0;
    min-width: 0;
    flex: 1;
}

.brand-lockup {
    display: flex;
    flex-direction: column;
    gap: 1px;
    flex-shrink: 0;
}

.brand-mark {
    font-size: 1.125rem;
    font-weight: 800;
    letter-spacing: -0.03em;
    color: var(--primary-color);
    line-height: 1.1;
}

.brand-tagline {
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--text-secondary);
}

.header-divider {
    width: 1px;
    height: 32px;
    background: var(--border-color);
    margin: 0 18px;
    flex-shrink: 0;
}

.header-title-wrap {
    flex: 1;
    min-width: 0;
    max-width: min(440px, 42vw);
}

/* Panel Lector estudiante en la barra lateral */
.toolbar-section-divider {
    height: 1px;
    margin: 1rem 0 0.85rem;
    background: var(--border-color);
    border: 0;
}

.toolbar-doc-section {
    margin-top: 0;
    padding: 0.7rem 0.6rem 0.75rem;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    background: var(--surface-color);
}

.toolbar-doc-section-title {
    margin: 0 0 0.25rem;
    font-size: 0.6875rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-secondary);
}

.toolbar-doc-section-lead {
    margin: 0 0 0.6rem;
    font-size: 0.72rem;
    line-height: 1.4;
    color: var(--text-secondary);
}

.doc-asignacion-group {
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
}

.doc-asignacion-check {
    display: flex;
    align-items: flex-start;
    gap: 0.45rem;
    cursor: pointer;
    font-size: 0.8125rem;
    line-height: 1.35;
    font-weight: 600;
    color: var(--text-primary);
}

.doc-asignacion-check input {
    margin-top: 0.15rem;
    flex-shrink: 0;
    accent-color: var(--primary-color);
}

.doc-asignacion-check--workshop span {
    color: var(--primary-color);
}

.doc-asignacion-rango {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-top: 0.35rem;
    padding-top: 0.5rem;
    border-top: 1px solid var(--border-color);
}

.doc-asignacion-rango--grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
    border-top: none;
    padding-top: 0;
    margin-top: 0.25rem;
}

.doc-asignacion-field {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    min-width: 0;
}

.doc-asignacion-field-label {
    font-size: 0.6875rem;
    font-weight: 600;
    color: var(--text-secondary);
    letter-spacing: 0.02em;
}

.doc-asignacion-input,
.doc-asignacion-select {
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    padding: 0.4rem 0.5rem;
    border-radius: 6px;
    border: 1px solid var(--border-color);
    font-size: 0.8125rem;
    background: var(--surface-color);
    color: var(--text-primary);
}

.doc-asignacion-input:focus,
.doc-asignacion-select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: var(--focus-ring);
}

.doc-asignacion-divider {
    margin: 0.65rem 0;
    border: 0;
    border-top: 1px solid var(--border-color);
    opacity: 0.65;
}

.doc-asignacion-strict-row {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    margin-top: 0.15rem;
}

.doc-asignacion-hint {
    margin: 0;
    font-size: 0.6875rem;
    line-height: 1.4;
    color: var(--text-secondary);
}

.doc-asignacion-hint--compact {
    padding-left: 1.35rem;
}

.book-title-input {
    width: 100%;
    border: 1px solid var(--border-color);
    padding: 9px 14px;
    border-radius: var(--radius-md);
    font-size: 0.9375rem;
    font-weight: 500;
    outline: none;
    transition:
        border-color 0.2s,
        box-shadow 0.2s;
    background: var(--surface-color);
    color: var(--text-primary);
}

.book-title-input::placeholder {
    color: #9ca3af;
    font-weight: 400;
}

.book-title-input:hover {
    border-color: #d1d5db;
}

.book-title-input:focus {
    border-color: var(--primary-color);
    box-shadow: var(--focus-ring);
}

.header-right {
    display: flex;
    align-items: center;
    gap: 10px;
}

.autosave-status-badge {
    --as-bg: #f8fafc;
    --as-fg: #0f172a;
    --as-bd: #e2e8f0;
    --as-dot: #94a3b8;
    font-size: 0.72rem;
    font-weight: 650;
    padding: 5px 11px 5px 9px;
    border-radius: 999px;
    border: 1px solid var(--as-bd);
    background: var(--as-bg);
    color: var(--as-fg);
    display: inline-flex;
    align-items: center;
    gap: 8px;
    max-width: min(220px, 36vw);
    transition:
        background 0.28s ease,
        border-color 0.28s ease,
        color 0.28s ease,
        box-shadow 0.28s ease,
        transform 0.2s ease;
    box-shadow: 0 1px 0 rgba(15, 23, 42, 0.04);
    line-height: 1.15;
    user-select: none;
}

.autosave-status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex: 0 0 auto;
    background: var(--as-dot);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--as-dot) 22%, transparent);
}

.autosave-status-label {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    min-width: 0;
    gap: 1px;
}

.autosave-status-text {
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.01em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}

.autosave-status-sub {
    font-size: 0.62rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    opacity: 0.72;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
    text-transform: none;
}

.autosave-status-badge[data-state='saved'] {
    --as-bg: #ecfdf5;
    --as-fg: #065f46;
    --as-bd: #a7f3d0;
    --as-dot: #10b981;
}

.autosave-status-badge[data-state='saved-local'] {
    --as-bg: #f0fdf4;
    --as-fg: #166534;
    --as-bd: #bbf7d0;
    --as-dot: #22c55e;
}

.autosave-status-badge[data-state='saving'],
.autosave-status-badge[data-state='syncing'] {
    --as-bg: #eff6ff;
    --as-fg: #1e40af;
    --as-bd: #bfdbfe;
    --as-dot: #3b82f6;
}

.autosave-status-badge[data-state='syncing'] .autosave-status-dot {
    animation: autosave-spin-dot 0.9s linear infinite;
    box-shadow: none;
    border: 2px solid color-mix(in srgb, var(--as-dot) 35%, transparent);
    border-top-color: var(--as-dot);
    background: transparent;
    width: 9px;
    height: 9px;
}

.autosave-status-badge[data-state='dirty'] {
    --as-bg: #fffbeb;
    --as-fg: #92400e;
    --as-bd: #fde68a;
    --as-dot: #f59e0b;
}

.autosave-status-badge[data-state='dirty'] .autosave-status-dot {
    animation: autosave-pulse 1.1s ease-in-out infinite alternate;
}

.autosave-status-badge[data-state='offline'] {
    --as-bg: #f8fafc;
    --as-fg: #475569;
    --as-bd: #cbd5e1;
    --as-dot: #94a3b8;
}

.autosave-status-badge[data-state='error'] {
    --as-bg: #fef2f2;
    --as-fg: #991b1b;
    --as-bd: #fecaca;
    --as-dot: #ef4444;
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.08);
}

@keyframes autosave-pulse {
    from {
        transform: scale(0.85);
        opacity: 0.55;
    }
    to {
        transform: scale(1.15);
        opacity: 1;
    }
}

@keyframes autosave-spin-dot {
    to {
        transform: rotate(360deg);
    }
}

/* Compat: si aún existe el ::before legado, no lo usamos con la nueva estructura */
.autosave-status-badge::before {
    display: none !important;
}

.header-help-btn {
    color: var(--text-secondary);
    border-color: transparent;
    background: var(--surface-subtle);
}

.header-help-btn:hover {
    color: var(--primary-color);
    background: var(--primary-muted);
}

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

/* Cabecera minimalista del editor */
.editor-header--minimal {
    height: 50px;
    padding: 0 14px 0 16px;
    gap: 12px;
    background: #fff;
    border-bottom: 1px solid #e8ecf1;
    box-shadow: none;
}

.editor-header--minimal .brand-tagline {
    font-size: 0.6rem;
    letter-spacing: 0.08em;
}

.editor-header--minimal .header-divider {
    height: 28px;
    margin: 0 12px;
}

.editor-header--minimal .book-title-input {
    padding: 7px 12px;
    font-size: 0.875rem;
    border-color: #e5e7eb;
    background: #f9fafb;
}

.editor-header--minimal .book-title-input:focus {
    background: #fff;
}

.editor-header--minimal .header-right {
    gap: 0;
    flex-shrink: 0;
}

.editor-header--minimal .header-status-group {
    display: flex;
    align-items: center;
    gap: 8px;
    padding-right: 10px;
    margin-right: 10px;
    border-right: 1px solid #e8ecf1;
}

.editor-header--minimal .autosave-status-badge {
    font-size: 0.68rem;
    padding: 3px 8px;
}

.editor-header--minimal .header-util-group {
    display: flex;
    align-items: center;
    gap: 2px;
    padding-right: 8px;
    margin-right: 8px;
    border-right: 1px solid #e8ecf1;
}

.editor-header--minimal .header-util-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    min-width: 32px;
    height: 32px;
    padding: 0 8px;
    border: none;
    border-radius: 8px;
    background: transparent;
    color: #64748b;
    font-family: inherit;
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}

.editor-header--minimal .header-util-btn:hover {
    background: #f1f5f9;
    color: #334155;
}

.editor-header--minimal .header-util-btn svg {
    width: 16px;
    height: 16px;
}

.editor-header--minimal .header-util-label {
    display: none;
}

.editor-header--minimal .header-actions-edit {
    gap: 6px;
}

.editor-header--minimal .header-action-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    height: 32px;
    padding: 0 10px;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    background: #fff;
    color: #334155;
    font-family: inherit;
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
    list-style: none;
}

.editor-header--minimal .header-action-btn:hover {
    background: #f8fafc;
    border-color: #cbd5e1;
    color: #1e293b;
}

.editor-header--minimal .header-action-btn svg {
    width: 15px;
    height: 15px;
    flex-shrink: 0;
}

.editor-header--minimal .header-action-btn--primary {
    background: var(--primary-color);
    border-color: var(--primary-color);
    color: #fff;
}

.editor-header--minimal .header-action-btn--primary:hover {
    background: var(--primary-hover);
    border-color: var(--primary-hover);
    color: #fff;
}

.editor-header--minimal .header-chevron {
    width: 14px !important;
    height: 14px !important;
    opacity: 0.85;
}

.editor-header--minimal .header-dropdown summary::-webkit-details-marker {
    display: none;
}

.editor-header--minimal .header-dropdown {
    position: relative;
}

.editor-header--minimal .teacher-session-badge {
    max-width: 9.5rem;
    padding: 2px 7px;
    font-size: 0.68rem;
    font-weight: 600;
    color: #64748b;
    background: #f1f5f9;
    border-radius: 6px;
    border: none;
    margin-right: 0;
}

.editor-header--minimal .book-title-input {
    border-radius: 8px;
    box-shadow: none;
}

.editor-header--minimal .brand-mark {
    font-size: 1rem;
    font-weight: 700;
}

.editor-header--minimal .header-title-wrap {
    max-width: min(520px, 48vw);
}

.editor-header--minimal .header-help-btn:hover {
    color: var(--primary-color);
    background: #f1f5f9;
}

.editor-header--minimal .header-action-label {
    white-space: nowrap;
}

.editor-header--minimal #btn-exit-preview.hidden {
    display: none !important;
}

.editor-header--minimal #btn-exit-preview:not(.hidden) {
    margin-left: 6px;
}

@media (min-width: 1100px) {
    .editor-header--minimal .header-util-label {
        display: inline;
    }
}

@media (max-width: 1024px) {
    .editor-header--minimal .brand-tagline {
        display: none;
    }

    .editor-header--minimal .header-divider {
        margin: 0 10px;
    }
}

@media (max-width: 900px) {
    .editor-header--minimal .header-action-label,
    .editor-header--minimal .header-action-label--sm {
        display: none;
    }

    .editor-header--minimal .header-action-btn {
        padding: 0 8px;
    }

    .editor-header--minimal .teacher-session-badge {
        max-width: 5.5rem;
    }
}

/* Dropdown Menu para limpieza del Header */
.header-dropdown {
    position: relative;
    display: inline-block;
}

.header-dropdown summary {
    list-style: none;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
}

.header-dropdown summary::-webkit-details-marker {
    display: none;
}

.header-dropdown-menu {
    position: absolute;
    top: calc(100% + 4px);
    right: 0;
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
    padding: 8px 0;
    min-width: 260px;
    z-index: 1000;
    display: flex;
    flex-direction: column;
}

.header-dropdown-item {
    background: none;
    border: none;
    text-align: left;
    padding: 10px 16px;
    width: 100%;
    display: flex;
    align-items: center;
    gap: 10px;
    font-family: inherit;
    font-size: 0.9rem;
    color: var(--text-primary);
    cursor: pointer;
    text-decoration: none;
    transition: background 0.15s, color 0.15s;
}

.header-dropdown-item:hover {
    background: var(--surface-subtle);
    color: var(--primary-color);
}

.header-dropdown-item svg {
    width: 16px;
    height: 16px;
}

.header-dropdown-divider {
    height: 1px;
    background: var(--border-color);
    margin: 6px 0;
}

/* Buttons */
.btn {
    padding: 8px 16px;
    border-radius: 6px;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: all 0.2s;
    font-size: 0.9rem;
}

.btn-primary {
    background-color: var(--primary-color);
    color: white;
}

.btn-primary:hover {
    background-color: var(--primary-hover);
}

.btn-danger {
    background-color: var(--danger-color);
    color: #fff;
}

.btn-danger:hover {
    background-color: #dc2626;
    color: #fff;
}

.btn:focus-visible,
.btn-icon:focus-visible,
.sheet-format-select:focus-visible {
    outline: none;
    box-shadow: var(--focus-ring);
}

.btn-outline {
    background-color: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-primary);
}

.btn-outline:hover {
    background-color: var(--bg-color);
}

.btn-sm {
    padding: 6px 12px;
    font-size: 0.8rem;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.btn-sm svg {
    width: 14px;
    height: 14px;
}

a.btn {
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    box-sizing: border-box;
}

.btn-icon {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-secondary);
    padding: 6px;
    border-radius: var(--radius-sm);
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.btn-icon:hover {
    background-color: var(--bg-color);
    color: var(--text-primary);
}

.btn-icon.danger:hover {
    color: var(--danger-color);
    background-color: #fee2e2;
}

/* Main Area */
.editor-main {
    display: flex;
    align-items: stretch;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

.editor-workspace.genlibros-policy--no-block-tools .drag-handle {
    display: none !important;
}

/* Toolbar (Left sidebar) */
.toolbar {
    width: 252px;
    background: #f8fafc;
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    padding: 14px 12px 12px;
    overflow-y: auto;
    flex-shrink: 0;
    align-self: stretch;
    min-height: 0;
    scrollbar-width: thin;
    scrollbar-color: #cbd5e1 transparent;
}

.toolbar::-webkit-scrollbar {
    width: 6px;
}

.toolbar::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 999px;
}

.toolbar::-webkit-scrollbar-track {
    background: transparent;
}

.toolbar-heading {
    font-size: 0.6875rem;
    text-transform: uppercase;
    color: var(--text-secondary);
    margin-bottom: 10px;
    letter-spacing: 0.1em;
    font-weight: 700;
}

.tool-group {
    margin-bottom: 0;
}

.group-title {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-secondary);
    margin-bottom: 10px;
    font-weight: 700;
    padding-left: 10px;
    border-left: 3px solid var(--primary-color);
}

.tool-group-hint {
    font-size: 0.72rem;
    line-height: 1.45;
    color: var(--text-secondary);
    margin: -4px 0 10px;
    padding-left: 10px;
}

.tool-group-hint strong {
    color: var(--text-primary);
    font-weight: 600;
}

.tool-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    background-color: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    margin-bottom: 7px;
    cursor: grab;
    transition:
        border-color 0.2s,
        box-shadow 0.2s,
        transform 0.15s ease;
    box-shadow: var(--shadow-xs);
}

.tool-item:hover {
    border-color: #c7d2fe;
    box-shadow: var(--shadow-sm);
    transform: translateY(-1px);
}

.tool-item:active {
    cursor: grabbing;
    transform: translateY(0);
}

.tool-item-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border-radius: var(--radius-sm);
    background: var(--primary-muted);
    color: var(--primary-color);
    flex-shrink: 0;
}

.tool-item:hover .tool-item-icon {
    background: var(--primary-muted-hover);
}

.tool-item-icon svg,
.tool-item-icon i {
    width: 18px;
    height: 18px;
}

.tool-item-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
    flex: 1;
}

.tool-item-label {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-primary);
    letter-spacing: -0.01em;
}

.tool-item-sub {
    font-size: 0.68rem;
    font-weight: 500;
    color: var(--text-secondary);
    line-height: 1.25;
}

.tool-item:hover .tool-item-label {
    color: var(--primary-hover);
}

.tool-item:hover .tool-item-sub {
    color: var(--text-primary);
}

.toolbar-footer {
    margin-top: auto;
    padding-top: 12px;
    border-top: 1px solid var(--border-color);
    font-size: 0.6875rem;
    line-height: 1.4;
    color: var(--text-secondary);
}

.toolbar-footer-link {
    display: block;
    margin-top: 8px;
    padding: 0;
    border: none;
    background: none;
    font: inherit;
    font-weight: 600;
    color: var(--primary-color);
    cursor: pointer;
    text-align: left;
    text-decoration: underline;
    text-underline-offset: 2px;
}

.toolbar-footer-link:hover {
    color: var(--primary-hover);
}

/* Canvas Area */
.canvas-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 24px 28px 36px;
    overflow-y: auto;
    overflow-x: hidden;
    min-height: 0;
    background: linear-gradient(165deg, #e4e7ec 0%, #eef0f4 42%, #e8eaef 100%);
    -webkit-overflow-scrolling: touch;
}

.canvas-chrome {
    width: 100%;
    max-width: var(--sheet-page-width);
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    padding: 10px 14px;
    margin-bottom: 14px;
}

.canvas-toolbar {
    width: 100%;
    max-width: none;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 0;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.canvas-toolbar-left {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px 16px;
}

.sheet-format-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    user-select: none;
}

.sheet-format-label-text {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-secondary);
}

.sheet-format-select {
    font-family: inherit;
    font-size: 0.8rem;
    font-weight: 600;
    padding: 6px 10px;
    border-radius: 6px;
    border: 1px solid var(--border-color);
    background: var(--surface-color);
    color: var(--text-primary);
    cursor: pointer;
    min-width: 11rem;
}

.sheet-format-select:hover {
    border-color: #c7c9d1;
}

.sheet-format-select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.2);
}

.page-nav {
    display: flex;
    align-items: center;
    gap: 8px;
}

.page-indicator {
    font-weight: 600;
    font-size: 0.8125rem;
    color: var(--text-primary);
    min-width: 0;
    text-align: center;
    padding: 6px 14px;
    background: var(--surface-subtle);
    border-radius: 999px;
    border: 1px solid #e5e7eb;
    letter-spacing: -0.01em;
}

.page-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.pages-stack {
    width: 100%;
    max-width: var(--sheet-page-width);
    display: flex;
    flex-direction: column;
    gap: 16px;
    filter: drop-shadow(0 2px 8px rgba(15, 23, 42, 0.06));
}

.page-glossary-panel {
    width: 100%;
    max-width: var(--sheet-page-width);
    margin-top: 12px;
    padding: 12px 14px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    background: rgba(255, 255, 255, 0.9);
    box-shadow: var(--shadow-sm);
}

.page-glossary-head {
    margin-bottom: 8px;
}

.page-glossary-title {
    font-size: 0.82rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-secondary);
    margin: 0 0 4px;
}

.page-glossary-hint {
    margin: 0;
    font-size: 0.78rem;
    line-height: 1.45;
    color: #64748b;
}

.page-glossary-input {
    width: 100%;
    box-sizing: border-box;
    resize: vertical;
    min-height: 92px;
    padding: 10px 12px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    background: #fff;
    font-family: var(--book-serif);
    font-size: 0.92rem;
    line-height: 1.5;
    color: var(--text-primary);
}

.canvas-area.canvas-area--at-capacity {
    box-shadow: inset 0 0 0 3px var(--danger-color);
    cursor: not-allowed !important;
}

.canvas-area.canvas-area--at-capacity::after {
    content: "HOJA AL L?MITE : Crea una p?gina nueva";
    position: absolute;
    bottom: 10px;
    right: 20px;
    background: var(--danger-color);
    color: white;
    font-size: 10px;
    font-weight: 800;
    padding: 2px 8px;
    border-radius: 4px;
    z-index: 100;
    pointer-events: none;
}

.canvas-area.drag-over.canvas-area--at-capacity {
    background-color: rgba(239, 68, 68, 0.05);
}

.page-glossary-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: var(--focus-ring);
}

/* Overview Panel Styles */
.props-overview-stats {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-top: 15px;
}

.overview-card {
    background: white;
    padding: 12px;
    border-radius: 10px;
    border: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.overview-card-label {
    font-size: 10px;
    text-transform: uppercase;
    font-weight: 700;
    color: var(--text-secondary);
}

.overview-card-value {
    font-size: 18px;
    font-weight: 800;
    color: var(--primary-color);
}

.glossary-action-bar {
    margin-top: 10px;
    display: flex;
    justify-content: flex-end;
}

.btn-magic {
    background: linear-gradient(135deg, #6366f1 0%, #a855f7 100%);
    color: white;
    border: none;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

.btn-magic:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 15px rgba(99, 102, 241, 0.4);
    filter: brightness(1.1);
}

.canvas-page {
    width: 100%;
}

/* --- Marcadores de Inicio de Sección y Botón Organizar --- */
.canvas-page--section-start {
    position: relative;
    border: 3px solid var(--primary-color) !important;
}

.canvas-page--section-start::before {
    content: 'PÁGINA INICIAL / UNIDAD';
    position: absolute;
    top: -12px;
    left: 20px;
    background: var(--primary-color);
    color: white;
    font-size: 0.65rem;
    font-weight: 800;
    padding: 3px 12px;
    border-radius: 6px;
    z-index: 20;
    letter-spacing: 0.05em;
    pointer-events: none;
    box-shadow: 0 4px 10px rgba(79, 70, 229, 0.25);
}

#btn-section-start.is-active {
    background-color: var(--primary-color);
    color: white;
    border-color: var(--primary-hover);
}

#btn-organize-book {
    background: linear-gradient(135deg, #f5f3ff 0%, #fff 100%);
    border: 1.5px solid var(--primary-color);
    color: var(--primary-color);
    transition: all 0.24s cubic-bezier(0.4, 0, 0.2, 1);
}

#btn-organize-book:hover {
    background: var(--primary-color);
    color: white;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.2);
}

/* --- Loading Overlay Premium --- */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(15, 23, 42, 0.7);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.loading-overlay.hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.loading-overlay-content {
    background: white;
    padding: 40px;
    border-radius: 24px;
    text-align: center;
    max-width: 440px;
    width: 90%;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.2);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
}

.loading-spinner-container {
    position: relative;
    width: 100px;
    height: 100px;
    margin-bottom: 10px;
}

.loading-spinner-ring {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: 4px solid #eef2ff;
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 1.2s cubic-bezier(0.5, 0, 0.5, 1) infinite;
}

.loading-spinner-ring.ring-inner {
    top: 15%;
    left: 15%;
    width: 70%;
    height: 70%;
    border-color: #f8fafc;
    border-bottom-color: var(--primary-color);
    animation: spin 0.8s cubic-bezier(0.5, 0, 0.5, 1) infinite reverse;
}

.loading-icon {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: var(--primary-color);
}

.loading-icon i, .loading-icon svg {
    width: 32px;
    height: 32px;
}

.loading-title {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--text-primary);
    margin: 0;
    letter-spacing: -0.02em;
}

.loading-subtitle {
    font-size: 0.9375rem;
    color: var(--text-secondary);
    margin: 0;
    line-height: 1.5;
}

.progress-bar-container {
    width: 100%;
    height: 8px;
    background: #f1f5f9;
    border-radius: 10px;
    overflow: hidden;
    margin-top: 10px;
    box-shadow: inset 0 1px 2px rgba(0,0,0,0.05);
}

.progress-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary-color), #8b5cf6);
    width: 0%;
    transition: width 0.4s ease;
    border-radius: 10px;
}

.loading-step {
    font-size: 0.8125rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--primary-color);
    margin: 0;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* --- Math Exploration Widget (Cartoon Style) --- */
.math-xp-container {
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
    border-radius: 20px;
    padding: 24px;
    border: 3px solid #e2e8f0;
    font-family: 'Outfit', sans-serif;
    display: flex;
    flex-direction: column;
    gap: 20px;
    user-select: none;
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.05);
}

.math-xp-header {
    text-align: center;
    border-bottom: 2px dashed #cbd5e1;
    padding-bottom: 16px;
    margin-bottom: 4px;
}

.math-xp-title {
    font-size: 1.4rem;
    font-weight: 800;
    color: #4338ca; /* Indigo profundo */
    margin: 0 0 4px 0;
    letter-spacing: -0.02em;
}

.math-xp-desc {
    font-size: 0.95rem;
    color: #64748b;
    margin: 0;
    line-height: 1.4;
    font-weight: 500;
}

.math-xp-explanation {
    background: #fff;
    border: 2px solid #cbd5e1;
    border-radius: 16px;
    padding: 18px 22px;
    min-height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    font-size: 1.1rem;
    font-weight: 600;
    color: #334155;
    line-height: 1.4;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.math-xp-explanation.has-update {
    transform: scale(1.02);
    border-color: #fb923c;
    background: #fffaf0;
}

.math-xp-model-area {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    padding: 20px 0;
}

.math-xp-bar {
    display: flex;
    width: 100%;
    height: 60px;
    background: #fff;
    border: 4px solid #475569;
    border-radius: 14px;
    overflow: hidden;
    box-shadow: 0 8px 0 #cbd5e1;
    transition: all 0.3s ease;
}

.math-xp-bar.highlight-all {
    transform: scale(1.05);
    border-color: #6366f1;
    box-shadow: 0 0 0 6px rgba(99, 102, 241, 0.2), 0 12px 0 #c7d2fe;
}

.math-xp-segment {
    flex: 1;
    border-right: 2px solid #475569;
    background: #f8fafc;
    transition: all 0.3s ease;
}

.math-xp-segment:last-child {
    border-right: none;
}

.math-xp-segment.is-filled {
    background: #fbbf24; /* Ámbar/Naranja vibrante */
}

.math-xp-segment.highlight {
    background: #4ade80 !important; /* Verde brillante */
    transform: translateY(-5px);
    box-shadow: inset 0 -4px 0 rgba(0,0,0,0.1);
}

.math-xp-segment.highlight-single {
    background: #f472b6 !important; /* Rosa brillante */
    transform: scale(1.1);
    border: 4px solid #db2777;
    border-radius: 8px;
    z-index: 2;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
}

.math-xp-notation {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 10px 20px;
    border-radius: 12px;
    transition: all 0.3s ease;
}

.math-xp-notation.highlight-notation {
    background: #e0f2fe;
    transform: scale(1.2);
    box-shadow: 0 0 20px rgba(14, 165, 233, 0.2);
}

.math-xp-numerator, .math-xp-denominator {
    font-size: 2.5rem;
    font-weight: 800;
    line-height: 1;
    color: #1e293b;
}

.math-xp-numerator { color: #d97706; }
.math-xp-denominator { color: #1e293b; }

.math-xp-fraction-line {
    width: 60px;
    height: 6px;
    background: #1e293b;
    margin: 4px 0;
    border-radius: 3px;
}

.math-xp-controls {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
    gap: 12px;
}

.math-xp-btn {
    background: #fff;
    border: 2px solid #e2e8f0;
    border-bottom: 4px solid #e2e8f0;
    border-radius: 12px;
    padding: 12px 16px;
    font-size: 0.9rem;
    font-weight: 700;
    color: #475569;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.math-xp-btn:hover {
    transform: translateY(-2px);
    border-color: #94a3b8;
    background: #f8fafc;
}

.math-xp-btn:active {
    transform: translateY(2px);
    border-bottom-width: 2px;
}

.math-xp-btn[data-action="numerator"] { color: #d97706; border-color: #fcd34d; }
.math-xp-btn[data-action="unit"] { color: #db2777; border-color: #f9a8d4; }
.math-xp-btn[data-action="denominator"] { color: #1e293b; border-color: #94a3b8; }
.math-xp-btn[data-action="proper"] { color: #0284c7; border-color: #7dd3fc; }

.math-xp-btn--reset {
    grid-column: 1 / -1;
    background: #f1f5f9;
    border-color: #cbd5e1;
    color: #64748b;
}

.math-xp-btn--reset i {
    width: 16px;
    height: 16px;
}

/* ?? Portada (primera hoja): imagen tipo libro ?? */
.canvas-page--cover .canvas-area {
    padding: 0.65rem 0.75rem 0.85rem;
}

/* Portada con imagen a p?gina completa: menos marco para acercarse al borde de la hoja */
.canvas-page--cover:has(.block-image--cover-full) .canvas-area {
    padding: 0.35rem 0.4rem 0.45rem;
}

.canvas-page--cover .block-image:not(.block-image--cover-full) .book-figure {
    max-width: 100%;
}

.canvas-page--cover .block-image:not(.block-image--cover-full) .book-figure__inner:not(.book-figure__inner--cropped):not([data-cropped="1"]):not([style*="aspect-ratio"]) {
    aspect-ratio: auto;
    max-height: min(36vh, 280px);
    margin-left: auto;
    margin-right: auto;
}

.canvas-page--cover .block-image:not(.block-image--cover-full) .book-figure__img {
    width: 100%;
    height: auto;
    max-height: min(36vh, 280px);
    object-fit: cover;
    object-position: center;
}

.editor-preview-mode .canvas-page--cover .block-image:not(.block-image--cover-full) .book-figure__inner,
.genlibros-reader .canvas-page--cover .block-image:not(.block-image--cover-full) .book-figure__inner {
    max-height: min(36vh, 280px);
}

.editor-preview-mode .canvas-page--cover .block-image:not(.block-image--cover-full) .book-figure__img,
.genlibros-reader .canvas-page--cover .block-image:not(.block-image--cover-full) .book-figure__img {
    max-height: min(36vh, 280px);
}

/* Portada / imagen: ocupar todo el ?rea ?til de la hoja (clip), opci?n del bloque */
.canvas-sheet-inner:has(.block-image--cover-full) {
    display: flex;
    flex-direction: column;
    min-height: 100%;
}

.canvas-sheet-inner > .canvas-block:not(.block-image--cover-full) {
    flex: 0 0 auto;
}

.block-image--cover-full {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
    margin-bottom: 0 !important;
}

.block-image--cover-full .block-controls {
    flex: 0 0 auto;
}

.block-image--cover-full .block-content {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
    padding: 0 !important;
}

.block-image--cover-full .book-figure {
    flex: 1 1 auto;
    min-height: 0;
    max-width: none;
    margin: 0;
}

.block-image--cover-full .book-figure__inner {
    flex: 1 1 auto;
    min-height: 0;
    max-height: none;
    aspect-ratio: unset;
    border-radius: 4px;
}

.block-image--cover-full .book-figure__img {
    width: 100%;
    height: 100%;
    min-height: 0;
    max-height: none;
    object-fit: cover;
    object-position: center;
}

.editor-preview-mode .block-image--cover-full .book-figure__inner,
.genlibros-reader .block-image--cover-full .book-figure__inner {
    border-radius: 2px;
}

.image-cover-full-option {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    margin-top: 10px;
    padding: 8px 10px;
    background: #f3f4f6;
    border-radius: 6px;
    font-size: 0.8125rem;
    line-height: 1.35;
    color: var(--text-primary);
    cursor: pointer;
    user-select: none;
}

.image-cover-full-option.hidden {
    display: none !important;
}

.image-cover-full-cb {
    margin-top: 2px;
    flex-shrink: 0;
}

.image-cover-full-text {
    font-weight: 500;
}

.editor-preview-mode .image-cover-full-option {
    display: none !important;
}

/* ?? ?ndice autom?tico ?? */
.block-toc .block-content {
    padding-top: 0.5rem;
}

.book-toc-root {
    font-family: var(--book-serif);
    max-width: 32rem;
    margin: 0 auto;
    padding: 1rem 0.5rem;
}

.book-toc-kicker {
    margin: 0 0 0.35rem;
    text-align: center;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.2em;
    font-weight: 700;
    color: var(--book-heading-accent, #3730a3);
}

.book-toc-book-title {
    font-size: 1.55rem;
    font-weight: 700;
    margin: 0 0 0.8rem;
    text-align: center;
    line-height: 1.25;
    color: var(--text-primary);
    font-style: italic;
}

.book-toc-divider {
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0.5rem 0 1.75rem;
}

.book-toc-divider::before,
.book-toc-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: linear-gradient(to right, transparent, rgba(15, 23, 42, 0.15), transparent);
}

.book-toc-divider::before {
    margin-right: 12px;
}

.book-toc-divider::after {
    margin-left: 12px;
}

.book-toc-divider span {
    display: block;
    width: 6px;
    height: 6px;
    transform: rotate(45deg);
    border: 1px solid rgba(15, 23, 42, 0.3);
    background: transparent;
}

.book-toc-nav {
    margin-top: 0.25rem;
}

.book-toc-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.book-toc-item {
    margin: 0.7rem 0;
    line-height: 1.4;
}

.book-toc-item--h2 {
    font-weight: 600;
    font-size: 1.05rem;
    color: var(--text-primary);
    margin-top: 1.2rem;
}

.book-toc-item--h3 {
    padding-left: 1.6rem;
    font-weight: 400;
    font-size: 0.92rem;
    color: var(--text-secondary);
    margin-top: 0.35rem;
    margin-bottom: 0.35rem;
}

.book-toc-item a {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    color: inherit;
    text-decoration: none;
    width: 100%;
    transition: color 0.15s ease;
}

.book-toc-item a:hover {
    color: var(--primary-color, #4f46e5);
}

.book-toc-item a:hover .book-toc-title-text {
    text-decoration: underline;
    text-underline-offset: 3px;
}

.book-toc-title-text {
    flex-shrink: 1;
    max-width: 85%;
    overflow-wrap: break-word;
}

.book-toc-leader {
    flex-grow: 1;
    border-bottom: 1.5px dotted rgba(15, 23, 42, 0.18);
    margin: 0 8px;
    align-self: stretch;
    min-width: 15px;
    height: 0.85em;
}

.book-toc-item--h3 .book-toc-leader {
    border-bottom: 1.2px dotted rgba(15, 23, 42, 0.12);
}

.book-toc-page-num {
    flex-shrink: 0;
    font-variant-numeric: tabular-nums;
    font-weight: 600;
    color: var(--text-primary);
    font-size: 0.95rem;
}

.book-toc-item--h3 .book-toc-page-num {
    font-weight: 500;
    color: var(--text-secondary);
    font-size: 0.88rem;
}

.book-toc-empty {
    font-size: 0.9rem;
    color: var(--text-secondary);
    line-height: 1.6;
    margin: 1rem 0 0;
    text-align: center;
    padding: 1.25rem;
    background: #f8fafc;
    border: 1px dashed #cbd5e1;
    border-radius: 8px;
}

/* ?? Instrucciones sobre actividades ?? */
.activity-instruction-editor {
    margin-bottom: 0.65rem;
}

.activity-instruction-label {
    margin-bottom: 0.35rem !important;
}

.activity-instruction-input {
    width: 100%;
    max-width: var(--book-measure);
    margin-left: auto;
    margin-right: auto;
    display: block;
    box-sizing: border-box;
    padding: 10px 12px;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    font-family: var(--book-serif);
    font-size: var(--genlibros-read-size, 1rem);
    line-height: 1.65;
    resize: none;
    overflow-y: hidden;
    min-height: 2.75rem;
    color: var(--book-ink, #1f2937);
    background: rgba(255, 255, 255, 0.7);
    transition:
        border-color 0.15s,
        box-shadow 0.15s;
}

.activity-instruction-input:focus {
    outline: none;
    border-color: #c7d2fe;
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.12);
}

.book-activity-instruction {
    margin: 0 auto 0.85rem;
    padding: 0;
    font-family: var(--book-serif);
    font-size: var(--genlibros-read-size, 1rem);
    line-height: 1.78;
    letter-spacing: 0.01em;
    font-style: italic;
    color: var(--book-ink, #1f2937);
    white-space: pre-wrap;
    max-width: var(--book-measure);
    box-sizing: border-box;
}

/* Instrucci?n en modo lector / vista previa: misma familia visual que el editor, sin ?caja blanca? suelta */
.activity-instruction-read {
    margin: 0 auto 0.85rem;
    padding: 12px 14px;
    max-width: var(--book-measure);
    border-radius: 10px;
    border: 1px solid #e2e8f0;
    background: linear-gradient(180deg, #f8fafc 0%, #f1f5f9 100%);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.75);
    color: #334155;
    font-style: normal;
}

.editor-preview-mode .book-activity-instruction {
    font-size: calc(var(--genlibros-read-size, 1rem) * 1.07);
    line-height: 1.82;
    color: var(--book-ink, #1f2937);
}

.editor-preview-mode .activity-instruction-input {
    font-size: calc(var(--genlibros-read-size, 1rem) * 1.07);
    line-height: 1.75;
}

.canvas-page {
    width: 100%;
    container-type: inline-size;
}

.canvas-page--preview {
    margin-bottom: 8px;
}

.canvas-page--preview .canvas-area {
    min-height: auto;
}

/* --- Ajuste de Tamaño y Escala Adaptativa de Bloques --- */
.canvas-block {
    position: relative;
    box-sizing: border-box;
    transition: width 0.22s cubic-bezier(0.4, 0, 0.2, 1), margin 0.22s cubic-bezier(0.4, 0, 0.2, 1);
}

.canvas-block.block-resizing {
    transition: none !important;
    user-select: none !important;
}

.canvas-block .block-resize-handle {
    user-select: none;
    touch-action: none;
}

.canvas-block .block-resize-handle:hover {
    opacity: 1 !important;
    transform: scale(1.15);
}

.canvas-block--reader .block-resize-handle,
.editor-preview-mode .block-resize-handle {
    display: none !important;
}

/* Adaptación fluida del contenido interno del bloque al nuevo tamaño */
.canvas-block .block-content {
    width: 100%;
    box-sizing: border-box;
}

.canvas-block .block-content img,
.canvas-block img {
    max-width: 100%;
    height: auto;
}

.canvas-area {
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: var(--sheet-page-width);
    /* Calculamos el height estricto usando aspect ratio o container queries para que no crezca como acordeón */
    aspect-ratio: var(--sheet-aspect-w) / var(--sheet-aspect-h);
    height: calc(100cqi * (var(--sheet-aspect-h) / var(--sheet-aspect-w)));
    max-height: calc(var(--sheet-page-width) * (var(--sheet-aspect-h) / var(--sheet-aspect-w)));
    overflow: hidden;
    overflow-y: auto; /* Permite scroll si un bloque (ej. video) es más grande, preservando la caja de la hoja */
    scrollbar-width: thin;
    scrollbar-color: rgba(148, 163, 184, 0.5) transparent;
    
    background: linear-gradient(180deg, #ffffff 0%, #fcfcfd 100%);
    box-shadow:
        0 1px 2px rgba(15, 23, 42, 0.04),
        0 8px 28px rgba(15, 23, 42, 0.08);
    border-radius: var(--radius-md);
    padding: var(--canvas-page-pad-y) var(--canvas-page-pad-x);
    position: relative;
    border: 1px solid rgba(15, 23, 42, 0.06);
    outline: 2px dashed transparent;
    outline-offset: 2px;
    transition:
        border-color 0.2s,
        outline-color 0.2s,
        box-shadow 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-sizing: border-box;
    overflow: hidden;
}

/* Recorte fijo de la ?caja? de p?gina; el contenido escala dentro sin barra de scroll */
.canvas-sheet-clip {
    flex: 1 1 0;
    min-height: 0;
    position: relative;
    overflow: hidden;
    width: 100%;
}

.canvas-sheet-inner {
    position: absolute;
    left: 50%;
    top: 0;
    transform: translateX(-50%) scale(1);
    transform-origin: top center;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    will-change: transform;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    display: flex;
    flex-wrap: wrap;
    align-content: flex-start;
    align-items: flex-start;
    row-gap: 12px;
}

.canvas-area.drag-over {
    outline-color: rgba(79, 70, 229, 0.45);
    background-color: #f5f7ff;
    box-shadow:
        0 0 0 1px rgba(79, 70, 229, 0.12),
        0 12px 32px rgba(79, 70, 229, 0.12);
}

/* P?gina con escala ya baja: aviso visual; el editor bloquea nuevos bloques desde la barra hasta crear otra hoja */
.canvas-area--at-capacity {
    box-shadow:
        0 0 0 2px rgba(245, 158, 11, 0.55),
        0 8px 24px rgba(15, 23, 42, 0.08);
    background: linear-gradient(180deg, #fffbeb 0%, #ffffff 28%);
}

.canvas-area--at-capacity::after {
    content: 'Hoja llena ? nueva p?gina para seguir';
    display: block;
    margin: 0 calc(-1 * var(--canvas-page-pad-x)) calc(-1 * var(--canvas-page-pad-y));
    margin-top: 8px;
    padding: 8px 12px;
    font-size: 0.75rem;
    font-weight: 600;
    color: #92400e;
    background: rgba(251, 191, 36, 0.2);
    border-top: 1px solid rgba(245, 158, 11, 0.35);
    border-radius: 0 0 var(--radius-md) var(--radius-md);
    text-align: center;
}

.empty-state {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    color: var(--text-secondary);
    pointer-events: none;
    max-width: 19rem;
    padding: 1.35rem 1.25rem;
    border: 2px dashed #e2e5eb;
    border-radius: var(--radius-lg);
    background: rgba(255, 255, 255, 0.82);
    backdrop-filter: blur(6px);
}

.empty-state-icon-wrap {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 56px;
    height: 56px;
    margin: 0 auto 12px;
    border-radius: 14px;
    background: linear-gradient(145deg, var(--primary-muted), var(--primary-muted-hover));
    color: var(--primary-color);
}

.empty-state .large-icon,
.empty-state-icon-wrap svg {
    width: 26px;
    height: 26px;
    opacity: 1;
}

.empty-state-msg {
    font-size: 0.8125rem;
    line-height: 1.55;
    color: var(--text-secondary);
    margin: 0;
    font-weight: 500;
}

/* Properties Panel (Right sidebar - hidden by default) */
.properties-panel {
    width: 288px;
    background: linear-gradient(180deg, #ffffff 0%, #fafbfc 100%);
    border-left: 1px solid var(--border-color);
    box-shadow: -4px 0 24px rgba(15, 23, 42, 0.04);
    padding: 20px 18px;
    overflow-y: auto;
    flex-shrink: 0;
    min-height: 0;
    align-self: stretch;
    -webkit-overflow-scrolling: touch;
}

.properties-panel.hidden {
    display: none;
}

.properties-head {
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 14px;
    margin-bottom: 16px;
    padding-left: 12px;
    margin-left: -12px;
    border-left: 3px solid var(--primary-color);
}

.properties-title {
    font-size: 0.6875rem;
    text-transform: uppercase;
    color: var(--text-secondary);
    letter-spacing: 0.1em;
    font-weight: 700;
}

.props-placeholder {
    font-size: 0.875rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

.props-card {
    font-size: 0.875rem;
}

.props-label {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-secondary);
    margin-bottom: 4px;
    margin-top: 12px;
}

.props-label:first-child {
    margin-top: 0;
}

.props-value {
    font-weight: 600;
    color: var(--text-primary);
}

.props-code {
    display: block;
    font-size: 0.7rem;
    background: #f3f4f6;
    padding: 8px;
    border-radius: 6px;
    word-break: break-all;
    margin-top: 4px;
}

.props-hint {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-top: 8px;
    line-height: 1.4;
}

.props-guided {
    margin-top: 10px;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 10px;
    background: #f8fafc;
}

.props-guided-title {
    margin: 0 0 8px;
    font-size: 0.76rem;
    text-transform: uppercase;
    color: #475569;
    letter-spacing: 0.06em;
    font-weight: 700;
}

.props-guided-list {
    margin: 0;
    padding-left: 1rem;
    font-size: 0.82rem;
    color: #334155;
    line-height: 1.45;
}

.props-guided-list li + li {
    margin-top: 4px;
}

.props-warning-list {
    margin: 10px 0 0;
    padding: 8px 10px;
    border: 1px solid #fcd34d;
    border-radius: 8px;
    background: #fffbeb;
    color: #92400e;
    font-size: 0.8rem;
    line-height: 1.45;
}

.props-template-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
    margin-top: 10px;
}

/* Referencias de portada (panel derecho, p?gina 1) */
.editor-cover-presets-wrap {
    margin-top: 1.1rem;
    padding-top: 1rem;
    border-top: 1px dashed var(--border-color);
}

.editor-cover-presets-head {
    margin-bottom: 0.65rem;
}

.editor-cover-presets-title {
    margin: 0 0 0.35rem;
    font-size: 0.6875rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    font-weight: 700;
    color: var(--text-secondary);
}

.editor-cover-presets-hint {
    margin: 0;
    font-size: 0.75rem;
    line-height: 1.45;
    color: var(--text-secondary);
}

.editor-cover-presets-grid {
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
}

.editor-cover-preset-btn {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 0.5rem;
    width: 100%;
    margin: 0;
    padding: 0.4rem 0.45rem;
    text-align: left;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background: var(--surface-subtle);
    cursor: pointer;
    transition:
        border-color 0.15s ease,
        background 0.15s ease,
        box-shadow 0.15s ease;
}

.editor-cover-preset-btn:hover {
    border-color: #c7d2fe;
    background: #fafbff;
}

.editor-cover-preset-btn:focus {
    outline: none;
}

.editor-cover-preset-btn:focus-visible {
    border-color: var(--primary-color);
    box-shadow: var(--focus-ring);
}

.editor-cover-preset-thumb {
    flex-shrink: 0;
    width: 48px;
    height: 48px;
    border-radius: 8px;
    background-size: cover;
    background-position: center;
    border: 1px solid var(--border-color);
}

.editor-cover-preset-meta {
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
    min-width: 0;
}

.editor-cover-preset-label {
    font-size: 0.78rem;
    font-weight: 700;
    color: var(--text-primary);
}

.editor-cover-preset-desc {
    font-size: 0.68rem;
    line-height: 1.35;
    color: var(--text-secondary);
}

/* Block Styles */
.canvas-block {
    position: relative;
    background: transparent;
    border: 1px solid transparent;
    border-radius: var(--radius-md);
    margin-bottom: var(--block-stack-gap);
    transition:
        box-shadow 0.22s ease,
        border-color 0.2s ease,
        background 0.2s ease;
}

.canvas-block:last-child {
    margin-bottom: 0;
}

.canvas-block:hover {
    background: rgba(255, 255, 255, 0.6);
    box-shadow: var(--shadow-sm);
    border-color: #e2e8f0;
}

.canvas-block.block-dragging {
    opacity: 0.85;
    box-shadow: 0 8px 24px rgba(99, 102, 241, 0.2);
}

.block--preview {
    border-color: transparent !important;
}

.block--preview:hover {
    border-color: transparent !important;
    box-shadow: none;
}

.editor-preview-mode .toolbar,
.editor-preview-mode .properties-panel {
    display: none !important;
}

/* =============================================================================
   Solo lectura premium (colaborador viewer): shell limpio desde el 1.er paint
   ============================================================================= */
html.gl-view-only-boot,
body.editor-view-only {
    --gl-view-only-banner-h: 28px;
}

html.gl-view-only-boot body,
body.editor-view-only {
    background: radial-gradient(circle at center, #243040 0%, #161e29 100%) !important;
}

/* Ocultar chrome de edición desde el primer pixel (sin esperar a JS) */
html.gl-view-only-boot .header-actions-edit,
html.gl-view-only-boot #btn-item-bank,
html.gl-view-only-boot #btn-help,
html.gl-view-only-boot .toolbar,
html.gl-view-only-boot .properties-panel,
html.gl-view-only-boot .page-glossary-panel,
html.gl-view-only-boot .sheet-format-label,
html.gl-view-only-boot .canvas-toolbar .page-actions,
html.gl-view-only-boot .page-actions,
body.editor-view-only .header-actions-edit,
body.editor-view-only #btn-item-bank,
body.editor-view-only #btn-help,
body.editor-view-only .toolbar,
body.editor-view-only .properties-panel,
body.editor-view-only .page-glossary-panel,
body.editor-view-only .sheet-format-label,
body.editor-view-only .canvas-toolbar .page-actions,
body.editor-view-only .page-actions {
    display: none !important;
}

body.editor-view-only #btn-exit-preview {
    display: inline-flex !important;
    visibility: visible !important;
    opacity: 1 !important;
}

/* Título no editable (aspecto de lectura) */
body.editor-view-only .book-title-input {
    pointer-events: none;
    border: none !important;
    background: transparent !important;
    box-shadow: none !important;
    color: #f8fafc !important;
    font-weight: 600;
    max-width: min(42vw, 28rem);
}

body.editor-view-only .autosave-status-badge {
    --as-bg: rgba(251, 191, 36, 0.14);
    --as-fg: #fde68a;
    --as-bd: rgba(251, 191, 36, 0.35);
    --as-dot: #fbbf24;
}

body.editor-view-only.editor-preview-mode::before {
    content: 'Solo lectura · Material compartido';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--gl-view-only-banner-h);
    z-index: 10050;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: #0f172a;
    background: linear-gradient(90deg, #fde68a, #fcd34d, #fde68a);
    padding: 0 12px;
    pointer-events: none;
    box-shadow: 0 1px 0 rgba(15, 23, 42, 0.1);
}

body.editor-view-only.editor-preview-mode .editor-header,
body.editor-view-only.editor-preview-mode .app-header,
body.editor-view-only .editor-header {
    margin-top: var(--gl-view-only-banner-h);
    background: rgba(15, 23, 42, 0.72);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid rgba(148, 163, 184, 0.18);
}

/* Barra de paginación limpia (solo flechas) */
body.editor-view-only .canvas-chrome {
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    max-width: min(920px, 96vw);
    margin: 0 auto 10px;
    padding: 6px 0 4px !important;
}

body.editor-view-only .canvas-toolbar {
    justify-content: center;
    gap: 16px;
}

body.editor-view-only .canvas-toolbar-left {
    justify-content: center;
    width: 100%;
}

body.editor-view-only .page-nav {
    background: rgba(15, 23, 42, 0.55);
    border: 1px solid rgba(148, 163, 184, 0.28);
    border-radius: 999px;
    padding: 6px 14px;
    color: #e2e8f0;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
}

body.editor-view-only #page-indicator {
    color: #f1f5f9;
    font-weight: 600;
    min-width: 9rem;
    text-align: center;
}

/* Contenedor del libro: aire lateral para el doble page y sin recorte */
body.editor-view-only.editor-preview-mode .canvas-container,
body.editor-view-only .canvas-container {
    padding: 12px max(20px, 3vw) 40px !important;
    overflow-x: auto !important;
    overflow-y: auto !important;
    background: transparent !important;
}

body.editor-view-only.editor-preview-mode .pages-stack {
    max-width: min(1280px, 94vw);
    margin: 0 auto;
    min-height: calc(100vh - 160px);
    align-items: center;
    justify-content: center;
}

/* Fade-in premium cuando el spread ya está listo */
body.editor-view-only:not(.editor-view-only-ready) .pages-stack {
    opacity: 0;
    transform: translateY(8px) scale(0.992);
}

body.editor-view-only.editor-view-only-ready .pages-stack {
    opacity: 1;
    transform: none;
    transition: opacity 0.35s ease, transform 0.4s cubic-bezier(0.22, 1, 0.36, 1);
}

@media (min-width: 850px) {
    body.editor-view-only.editor-preview-mode .pages-stack {
        max-width: min(1180px, 92vw);
        gap: 0;
    }

    body.editor-view-only.editor-preview-mode .pages-stack .canvas-page:not([hidden]) {
        flex: 0 0 50% !important;
        max-width: 50% !important;
        width: 50% !important;
        overflow: visible !important;
    }

    /* Evitar que la escala de hoja del editor se desborde del 50% */
    body.editor-view-only.editor-preview-mode .canvas-page.book-page--spread-left,
    body.editor-view-only.editor-preview-mode .canvas-page.book-page--spread-right {
        overflow: visible !important;
        min-height: 0;
    }

    body.editor-view-only.editor-preview-mode .canvas-page .canvas-sheet-clip {
        width: 100% !important;
        max-width: 100% !important;
        height: auto !important;
        max-height: min(78vh, 980px);
        overflow: hidden !important;
    }

    body.editor-view-only.editor-preview-mode .canvas-page .canvas-area {
        /* El fit de hoja se aplica con transform; anclar en el centro de cada mitad */
        max-width: 100%;
    }
}

.editor-preview-mode .canvas-container {
    padding-top: 24px;
    background: linear-gradient(160deg, #c8ccd4 0%, #d5d8de 45%, #cfd3d9 100%);
}

.editor-preview-mode .page-glossary-panel {
    display: none;
}

.editor-preview-mode .canvas-chrome {
    background: transparent;
    border: none;
    box-shadow: none;
    padding: 0 0 12px;
    margin-bottom: 6px;
}

.editor-preview-mode .canvas-area {
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.15), 0 5px 10px rgba(0, 0, 0, 0.08);
    border-radius: 2px;
    /* Sangr?a interior del libro: no confundir con el lienzo de edici?n */
    padding: var(--book-read-page-pad-y) var(--book-read-page-pad-x);
}

/* Ritmo entre bloques solo en lectura (m?s aire que en el editor) */
.editor-preview-mode .canvas-block {
    margin-bottom: 14px;
}

.editor-preview-mode .canvas-block:last-child {
    margin-bottom: 0;
}

/* El contenido respeta el marco de la p?gina; sin doble relleno lateral */
.editor-preview-mode .canvas-block > .block-content {
    padding: 0.25rem 0 0.65rem;
}

.editor-preview-mode .block-text .block-content {
    padding: 0;
}

.editor-preview-mode .block-image .block-content {
    padding: 0.35rem 0 0.85rem;
}

/* Sangr?a de p?rrafo cl?sica (solo lectura): primera l?nea tras otro p?rrafo */
.editor-preview-mode .book-prose p + p {
    text-indent: 1.15em;
}

.editor-preview-mode .book-prose p:first-child,
.editor-preview-mode .book-prose h2 + p,
.editor-preview-mode .book-prose h3 + p,
.editor-preview-mode .book-prose blockquote + p,
.editor-preview-mode .book-prose ul + p,
.editor-preview-mode .book-prose ol + p {
    text-indent: 0;
}

.editor-preview-mode .canvas-toolbar {
    max-width: min(1720px, 98vw);
}

/* En lectura: s? se puede pasar p?gina; acciones de edici?n siguen desactivadas */
.editor-preview-mode .canvas-toolbar .page-nav {
    opacity: 1;
    pointer-events: auto;
}

.editor-preview-mode .canvas-toolbar .page-actions {
    opacity: 0.45;
    pointer-events: none;
}

/* Fondo oscuro inmersivo para la vista previa del editor (igual que el lector) */
body.editor-preview-mode {
    background: radial-gradient(circle at center, #243040 0%, #161e29 100%) !important;
}

/* ?? Libro abierto (vista previa, pantalla ancha) ?? */
.editor-preview-mode .pages-stack {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.25rem;
    width: 100%;
    max-width: min(1720px, 98vw);
    margin: 0 auto;
    position: relative;
    perspective: 2000px;
    transform-style: preserve-3d;
}

@media (min-width: 850px) {
    .editor-preview-mode .pages-stack {
        flex-direction: row;
        flex-wrap: nowrap;
        justify-content: center;
        align-items: stretch;
        gap: 0;
        max-width: min(1840px, 96vw);
        margin: 0 auto;
        position: relative;
        perspective: 1800px;
    }

    /* (El tubo central artificial con degradado ha sido eliminado para dejar ver el hundimiento natural) */

    .editor-preview-mode .pages-stack .canvas-page:not([hidden]) {
        flex: 0 0 50% !important;
        max-width: 50% !important;
        min-width: 0 !important;
        box-sizing: border-box !important;
    }

    .editor-preview-mode .canvas-page.book-page--spread-left {
        display: flex !important;
        justify-content: flex-end !important;
        border: none !important;
        background: transparent !important;
        box-shadow: none !important;
    }

    .editor-preview-mode .canvas-page.book-page--spread-right {
        display: flex !important;
        justify-content: flex-start !important;
        border: none !important;
        background: transparent !important;
        box-shadow: none !important;
    }

    /* Efecto 3D Realista de Páginas Apiladas e Impresión Física */
    .editor-preview-mode .canvas-page.book-page--spread-left .canvas-area {
        margin-left: auto !important;
        margin-right: 0 !important;
        border-radius: 6px 0 0 6px !important;
        border-top: 1px solid #e2e8f0 !important;
        border-bottom: 1px solid #e2e8f0 !important;
        border-left: 1px solid #e2e8f0 !important;
        border-right: none !important;
        /* Gradiente ultra sutil para dar volumen a la hoja (ligeramente oscurecida hacia el lomo) */
        background: linear-gradient(to right, #ffffff 70%, #fcfcfd 90%, #f1f5f9 100%) !important;
        box-shadow: 
            /* Pliegue profundo y afilado en el centro del lomo */
            inset -3px 0 6px -1px rgba(0, 0, 0, 0.15),
            /* Sombra curva suave del lomo */
            inset -25px 0 35px -10px rgba(0, 0, 0, 0.08),
            /* 1. Grosor de las hojas laterales (stack) - simulando 10 páginas súper nítidas */
            -1px 0 0 #ffffff, -2px 0 0 #cbd5e1, 
            -3px 0 0 #ffffff, -4px 0 0 #94a3b8, 
            -5px 0 0 #ffffff, -6px 0 0 #cbd5e1, 
            -7px 0 0 #f8fafc, -8px 0 0 #94a3b8,
            -9px 0 0 #ffffff, -10px 0 0 #64748b,
            /* 2. Sombra inferior/superior que las hojas proyectan sobre la tapa */
            0 1px 2px rgba(0,0,0,0.15), 0 -1px 2px rgba(0,0,0,0.15),
            /* 3. Tapa dura oscura (Hardcover) sobresaliendo 3px a los lados y 4px arriba/abajo */
            -13px 4px 0 #1e293b, -13px -4px 0 #1e293b, 
            0 4px 0 #1e293b, 0 -4px 0 #1e293b,
            /* Sombra proyectada (Drop shadow) amplia y ultra suave en el escritorio */
            -20px 24px 50px rgba(0, 0, 0, 0.65) !important;
    }

    .editor-preview-mode .canvas-page.book-page--spread-right .canvas-area {
        margin-left: 0 !important;
        margin-right: auto !important;
        border-radius: 0 6px 6px 0 !important;
        border-top: 1px solid #e2e8f0 !important;
        border-bottom: 1px solid #e2e8f0 !important;
        border-right: 1px solid #e2e8f0 !important;
        border-left: none !important;
        /* Gradiente ultra sutil para dar volumen a la hoja (ligeramente oscurecida hacia el lomo) */
        background: linear-gradient(to left, #ffffff 70%, #fcfcfd 90%, #f1f5f9 100%) !important;
        box-shadow: 
            /* Pliegue profundo y afilado en el centro del lomo */
            inset 3px 0 6px -1px rgba(0, 0, 0, 0.15),
            /* Sombra curva suave del lomo */
            inset 25px 0 35px -10px rgba(0, 0, 0, 0.08),
            /* 1. Grosor de las hojas laterales (stack) - simulando 10 páginas súper nítidas */
            1px 0 0 #ffffff, 2px 0 0 #cbd5e1, 
            3px 0 0 #ffffff, 4px 0 0 #94a3b8, 
            5px 0 0 #ffffff, 6px 0 0 #cbd5e1, 
            7px 0 0 #f8fafc, 8px 0 0 #94a3b8,
            9px 0 0 #ffffff, 10px 0 0 #64748b,
            /* 2. Sombra inferior/superior que las hojas proyectan sobre la tapa */
            0 1px 2px rgba(0,0,0,0.15), 0 -1px 2px rgba(0,0,0,0.15),
            /* 3. Tapa dura oscura (Hardcover) sobresaliendo 3px a los lados y 4px arriba/abajo */
            13px 4px 0 #1e293b, 13px -4px 0 #1e293b, 
            0 4px 0 #1e293b, 0 -4px 0 #1e293b,
            /* Sombra proyectada (Drop shadow) amplia y ultra suave en el escritorio */
            20px 24px 50px rgba(0, 0, 0, 0.65) !important;
    }

    /* En previsualización: lienzo transparente para que la sombra interior (inset) funcione */
    .editor-preview-mode .canvas-sheet-clip {
        background-color: transparent !important;
        background-image: none !important;
        box-shadow: none !important;
    }

    /* Una sola hoja visible al final (total impar) */
    .editor-preview-mode .canvas-page.book-page--spread-alone .canvas-area {
        border-radius: 6px;
        box-shadow: 0 12px 32px rgba(0, 0, 0, 0.35);
        border: none;
    }
}

@media (max-width: 849px) {
    .editor-preview-mode .pages-stack::after {
        display: none;
    }
}

/* Animaci?n al cambiar de doble p?gina */
@keyframes bookSpreadExitFwd {
    from {
        transform: perspective(1600px) rotateY(0deg) translateX(0);
        opacity: 1;
        filter: blur(0);
    }
    to {
        transform: perspective(1600px) rotateY(-26deg) translateX(-18px);
        opacity: 0.15;
        filter: blur(1px);
    }
}

@keyframes bookSpreadExitBack {
    from {
        transform: perspective(1600px) rotateY(0deg) translateX(0);
        opacity: 1;
        filter: blur(0);
    }
    to {
        transform: perspective(1600px) rotateY(26deg) translateX(18px);
        opacity: 0.15;
        filter: blur(1px);
    }
}

@keyframes bookSpreadEnter {
    from {
        transform: perspective(1600px) rotateY(20deg) scale(0.97);
        opacity: 0;
    }
    to {
        transform: perspective(1600px) rotateY(0deg) scale(1);
        opacity: 1;
    }
}

@keyframes bookSpreadEnterBack {
    from {
        transform: perspective(1600px) rotateY(-20deg) scale(0.97);
        opacity: 0;
    }
    to {
        transform: perspective(1600px) rotateY(0deg) scale(1);
        opacity: 1;
    }
}

.editor-preview-mode .pages-stack.book-spread-animating.book-spread-forward .canvas-page:not([hidden]) {
    animation: bookSpreadExitFwd 0.42s cubic-bezier(0.45, 0, 0.55, 1) forwards;
}

.editor-preview-mode .pages-stack.book-spread-animating.book-spread-back .canvas-page:not([hidden]) {
    animation: bookSpreadExitBack 0.42s cubic-bezier(0.45, 0, 0.55, 1) forwards;
}

.editor-preview-mode .pages-stack.book-spread-enter:not(.book-spread-enter-from-back) .canvas-page:not([hidden]) {
    animation: bookSpreadEnter 0.5s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

.editor-preview-mode .pages-stack.book-spread-enter.book-spread-enter-from-back .canvas-page:not([hidden]) {
    animation: bookSpreadEnterBack 0.5s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

@media (prefers-reduced-motion: reduce) {
    .editor-preview-mode .pages-stack.book-spread-animating .canvas-page:not([hidden]),
    .editor-preview-mode .pages-stack.book-spread-enter .canvas-page:not([hidden]) {
        animation: none !important;
        opacity: 1 !important;
        transform: none !important;
        filter: none !important;
    }
}

.block-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 10px;
    background: linear-gradient(180deg, #fafbfc 0%, #f3f4f6 100%);
    border-bottom: 1px solid var(--border-color);
    border-radius: var(--radius-md) var(--radius-md) 0 0;
    opacity: 0;
    transition: opacity 0.22s ease;
}

/* `hidden` debe ocultar del todo; si no, `display:flex` de arriba anula al navegador */
.block-controls[hidden] {
    display: none !important;
}

.canvas-block:hover .block-controls:not([hidden]) {
    opacity: 1;
}

/* Vista previa / libro: nunca barras de docente (mover, ajustes, borrar) */
.editor-preview-mode .canvas-block .block-controls,
.canvas-block.block--preview .block-controls {
    display: none !important;
    opacity: 0 !important;
    pointer-events: none !important;
    visibility: hidden !important;
}

.drag-handle {
    cursor: grab;
    color: var(--text-secondary);
}

.drag-handle:active {
    cursor: grabbing;
}

.block-content {
    padding: var(--block-inner-pad-y) var(--block-inner-pad-x) calc(var(--block-inner-pad-y) + 2px);
}

.block-text .block-content {
    padding: 0;
}

/* ?? Bloque de texto tipo libro digital (ePub / lectura web) ?? */
.book-text-block {
    display: flex;
    flex-direction: column;
    gap: 0;
    border-radius: 10px;
    overflow: hidden;
    background: transparent;
    border: none;
    box-shadow: none;
    /* Cuerpo en puntos (Word); título h2 independiente; h3 ≈ 80% del título */
    --book-body-size: 12pt;
    --book-heading-size: 18pt;
    --book-font-family: var(--book-serif);
}

.book-text-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 8px 12px;
    padding: 8px 12px 10px;
    background:
        linear-gradient(180deg, #ffffff 0%, #f4f6f9 100%);
    border-bottom: 1px solid #d8dee8;
    border-radius: 10px 10px 0 0;
    box-shadow: 0 1px 0 rgba(255, 255, 255, 0.8) inset, 0 1px 3px rgba(15, 23, 42, 0.04);
}

.book-toolbar-word {
    /* Cinta compacta tipo Word / documentos premium */
    row-gap: 10px;
}

.book-toolbar-group {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    flex-wrap: wrap;
}

.book-toolbar-group--type {
    gap: 10px;
}

.book-ribbon-field {
    display: flex;
    flex-direction: column;
    gap: 3px;
    min-width: 0;
}

.book-ribbon-field-label {
    font-size: 0.62rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: #94a3b8;
    line-height: 1;
    padding-left: 2px;
    user-select: none;
}

.book-ribbon-field--size {
    flex-direction: row;
    align-items: flex-end;
    gap: 6px;
}

.book-ribbon-field--size .book-ribbon-field-label {
    display: none;
}

.book-size-combo {
    display: inline-flex;
    align-items: stretch;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    overflow: hidden;
    background: #fff;
    box-shadow: 0 1px 1px rgba(15, 23, 42, 0.04);
    transition: border-color 0.15s, box-shadow 0.15s;
}

.book-size-combo:focus-within {
    border-color: #6366f1;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.16);
}

.book-text-size-select {
    appearance: none;
    width: 3.4rem;
    height: 32px;
    padding: 0 4px 0 10px;
    border: none;
    background: transparent;
    color: #0f172a;
    font-size: 0.88rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    font-family: Inter, system-ui, sans-serif;
    text-align: center;
    cursor: pointer;
    outline: none;
}

.book-size-unit {
    display: inline-flex;
    align-items: center;
    padding: 0 9px 0 2px;
    font-size: 0.68rem;
    font-weight: 700;
    color: #94a3b8;
    letter-spacing: 0.04em;
    border-left: 1px solid #e2e8f0;
    background: #f8fafc;
    user-select: none;
}

.book-text-style-select {
    appearance: none;
    min-width: 8.5rem;
    height: 32px;
    padding: 0 28px 0 10px;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    background-color: #fff;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2.5'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    color: #1e293b;
    font-size: 0.78rem;
    font-weight: 600;
    font-family: Inter, system-ui, sans-serif;
    cursor: pointer;
    outline: none;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.book-text-style-select:hover,
.book-text-style-select:focus {
    border-color: #6366f1;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

.book-toolbar-size-box,
.book-toolbar-heading-sizes {
    display: flex;
    align-items: center;
    gap: 4px;
}

.book-toolbar-pill-group {
    display: inline-flex;
    align-items: center;
    background: #f1f5f9;
    padding: 2px;
    border-radius: 7px;
    border: 1px solid #e2e8f0;
    gap: 1px;
}

.book-toolbar-btn-group {
    display: inline-flex;
    align-items: center;
    background: #f8fafc;
    padding: 2px;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
    gap: 2px;
    height: 32px;
    box-sizing: border-box;
}

.book-text-tool {
    border: none;
    background: transparent;
    color: #4b5563;
    font-size: 0.78rem;
    font-weight: 600;
    padding: 5px 8px;
    border-radius: 5px;
    cursor: pointer;
    font-family: Inter, system-ui, sans-serif;
    transition: background 0.15s, color 0.15s, box-shadow 0.15s;
    height: 100%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.book-text-tool:hover {
    background: #e0e7ff;
    color: #3730a3;
}

.book-text-tool.is-active {
    background: #4f46e5;
    color: #ffffff;
    box-shadow: 0 1px 2px rgba(79, 70, 229, 0.25);
}

.book-text-tool-label {
    font-weight: 700;
}

.book-text-tool--bold .book-text-tool-label {
    font-weight: 900;
    font-family: Inter, system-ui, sans-serif;
    font-size: 0.85rem;
}

.book-text-tool--italic .book-text-tool-label--i {
    font-style: italic;
    font-family: Georgia, serif;
    font-weight: 700;
    font-size: 0.88rem;
}

.book-text-tool--wide {
    padding-left: 10px;
    padding-right: 10px;
}

.book-text-tool-sep {
    width: 1px;
    height: 22px;
    background: #cbd5e1;
    margin: 0 4px;
    flex-shrink: 0;
    opacity: 0.7;
}

.book-text-size-label {
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #94a3b8;
    padding: 0 4px 0 2px;
    user-select: none;
}

.book-text-tool--size {
    min-width: 1.85rem;
    font-variant-numeric: tabular-nums;
    text-align: center;
}

/* Paleta editorial (textos didácticos): muestras compactas en la barra */
.book-text-color-palette {
    display: inline-flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 5px;
    margin: 0 2px 0 4px;
    vertical-align: middle;
}

.book-text-color-swatch {
    box-sizing: border-box;
    width: 22px;
    height: 22px;
    min-width: 22px;
    min-height: 22px;
    padding: 0;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    flex-shrink: 0;
    background-color: var(--book-text-swatch, #1a1a1a);
    box-shadow:
        0 0 0 1px rgba(17, 24, 39, 0.12),
        0 1px 2px rgba(0, 0, 0, 0.06);
    transition: transform 0.12s ease, box-shadow 0.12s ease;
}

.book-text-color-swatch:hover {
    transform: scale(1.15);
    box-shadow:
        0 0 0 2px rgba(79, 70, 229, 0.4),
        0 2px 4px rgba(0, 0, 0, 0.1);
}

.book-text-color-swatch:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

.book-text-frame {
    padding: 0.65rem 0.75rem 0.85rem;
    min-height: 72px;
}

/* Tipografía editorial (cuerpo del libro) */
.book-prose {
    font-family: var(--book-font-family, var(--book-serif));
    font-size: var(--book-body-size, 1rem);
    font-weight: 400;
    line-height: 1.78;
    letter-spacing: 0.01em;
    color: var(--book-ink);
    max-width: var(--book-measure);
    margin: 0 auto;
    min-height: 3.25rem;
    outline: none;
    text-align: justify;
    hyphens: auto;
    -webkit-hyphens: auto;
    overflow-wrap: break-word;
    word-wrap: break-word;
}

/* Fragmentos tipográficos del bloque de texto (docente + estudiante) */
.book-prose span[style*="font-size"],
.book-prose span[style*="font-family"],
.book-prose .gl-ts-xs,
.book-prose .gl-ts-s,
.book-prose .gl-ts-m,
.book-prose .gl-ts-l,
.book-prose .gl-ts-xl {
    line-height: inherit;
}

.book-prose .gl-ts-xs { font-size: 0.82em !important; }
.book-prose .gl-ts-s { font-size: 0.92em !important; }
.book-prose .gl-ts-m { font-size: 1em !important; }
.book-prose .gl-ts-l { font-size: 1.14em !important; }
.book-prose .gl-ts-xl { font-size: 1.32em !important; }

.book-text-font-select {
    appearance: none;
    max-width: 14.5rem;
    min-width: 11rem;
    height: 32px;
    padding: 0 28px 0 10px;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    background-color: #fff;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2.5'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    color: #1e293b;
    font-size: 0.78rem;
    font-weight: 600;
    font-family: Inter, system-ui, sans-serif;
    cursor: pointer;
    outline: none;
    transition: border-color 0.15s, box-shadow 0.15s;
    box-shadow: 0 1px 1px rgba(15, 23, 42, 0.04);
}

.book-text-font-select:hover,
.book-text-font-select:focus {
    border-color: #6366f1;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

.book-text-size-hint {
    font-size: 0.62rem;
    font-weight: 700;
    color: #64748b;
    letter-spacing: 0.04em;
    padding: 4px 7px;
    border-radius: 999px;
    background: #f1f5f9;
    text-transform: uppercase;
    white-space: nowrap;
    transition: all 0.2s ease;
    align-self: center;
    margin-bottom: 2px;
}

.book-text-toolbar.has-text-selection .book-text-size-hint {
    background: #e0e7ff;
    color: #4338ca;
    box-shadow: 0 0 0 1px rgba(99, 102, 241, 0.3);
}

.book-text-toolbar.has-text-selection .book-size-combo {
    border-color: #a5b4fc;
    background: #eef2ff;
}

.book-text-toolbar.has-text-selection .book-toolbar-pill-group {
    border-color: #a5b4fc;
    background: #eef2ff;
}

.book-prose:focus {
    outline: none;
}

.book-prose[data-empty="true"]::before {
    content: attr(aria-placeholder);
    color: #9ca3af;
    pointer-events: none;
    display: block;
    font-family: var(--book-font-family, var(--book-serif));
    font-style: italic;
    font-size: 0.95em;
    line-height: 1.65;
    text-align: left;
}

.book-prose p {
    margin: 0 0 1.05em;
    text-indent: 0;
}

.book-prose p:last-child {
    margin-bottom: 0;
}

/* Primera l?nea del primer p?rrafo: aire de apertura de cap?tulo */
.book-prose>p:first-of-type {
    margin-top: 0;
}

/* Letra capital solo si se solicita explícitamente con la clase .with-drop-cap */
.book-prose.with-drop-cap>p:first-child::first-letter {
    float: left;
    font-size: 3.15em;
    font-weight: 700;
    line-height: 0.82;
    margin-right: 0.1em;
    margin-top: 0.06em;
    padding-bottom: 0.05em;
    color: var(--book-drop-cap);
    font-family: var(--book-serif);
}

.book-prose.with-drop-cap .book-chapter-opener + p::first-letter {
    float: left;
    font-size: 3.15em;
    font-weight: 700;
    line-height: 0.82;
    margin-right: 0.1em;
    margin-top: 0.06em;
    padding-bottom: 0.05em;
    color: var(--book-drop-cap);
    font-family: var(--book-serif);
}

.book-prose h2,
.book-prose h3 {
    font-family: var(--book-font-family, var(--book-serif));
    font-weight: 700;
    color: var(--book-heading-accent, #111827);
    text-align: left;
    text-wrap: balance;
    hyphens: none;
    letter-spacing: -0.02em;
}

.book-prose h2 {
    /* Independiente del tama?o de p?rrafo (--book-body-size) */
    font-size: var(--book-heading-size, 1.35rem);
    line-height: 1.28;
    margin: 1.35em 0 0.65em;
    padding-bottom: 0.35em;
    border-bottom: 1px solid var(--book-heading-rule);
}

.book-prose h3 {
    /* Subt?tulo claramente menor que el t?tulo (h2): jerarqu?a tipo manual escolar */
    font-size: calc(var(--book-heading-size, 1.35rem) * 0.8);
    font-weight: 600;
    line-height: 1.38;
    margin: 1.2em 0 0.5em;
    color: var(--book-heading-accent, #374151);
    opacity: 0.9; /* Para que h3 se diferencie de h2 siendo ligeramente más suave, aunque use el mismo acento */
}

.book-prose h2:first-child,
.book-prose h3:first-child {
    margin-top: 0;
}

.book-prose ul,
.book-prose ol {
    margin: 0.75em 0 1.1em;
    padding-left: 1.35em;
    text-align: left;
}

.book-prose li {
    margin-bottom: 0.45em;
    padding-left: 0.25em;
}

.book-prose li::marker {
    color: var(--book-marker);
}

/* Aperturas de unidad, examen o referencia (marcado en el HTML del libro) */
.book-prose .book-chapter-opener {
    margin: 0 0 1rem;
    padding-top: 0.45rem;
    border-top: 3px solid var(--book-heading-accent);
}

.book-prose .book-kicker {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--book-heading-accent);
    margin: 0 0 0.35rem;
}

.book-prose .book-chapter-opener h2 {
    margin-top: 0;
    padding-bottom: 0.4em;
    border-bottom-width: 2px;
    border-bottom-color: var(--book-heading-rule);
}

.book-prose .book-chapter-opener--exam {
    border-top-color: var(--book-exam-accent);
}

.book-prose .book-chapter-opener--exam .book-kicker {
    color: var(--book-exam-accent);
}

.book-prose .book-chapter-opener--reference {
    border-top-color: var(--book-reference-accent);
}

.book-prose .book-chapter-opener--reference .book-kicker {
    color: var(--book-reference-accent);
}

.book-prose blockquote {
    margin: 1.15em 0;
    padding: 1rem 1.15rem 1rem 1.25rem;
    border-left: 4px solid var(--book-quote-border);
    background: linear-gradient(90deg, var(--book-quote-bg-start) 0%, var(--book-quote-bg-end) 100%);
    font-style: italic;
    color: var(--book-ink-muted);
    text-align: left;
    border-radius: 0 8px 8px 0;
}

.book-prose blockquote p {
    margin-bottom: 0.6em;
}

.book-prose blockquote p:last-child {
    margin-bottom: 0;
}

.book-prose a {
    color: var(--book-prose-link);
    text-decoration: underline;
    text-underline-offset: 3px;
    text-decoration-thickness: 1px;
}

.book-prose a:hover {
    color: var(--primary-hover);
}

.book-prose strong {
    font-weight: 700;
    color: #111827;
}

.book-prose em {
    font-style: italic;
}

.editor-preview-mode .book-text-toolbar {
    display: none !important;
}

.editor-preview-mode .book-text-block {
    border-color: transparent;
    background: transparent;
    box-shadow: none;
}

.editor-preview-mode .book-text-frame {
    padding: 0.35rem 0 0.65rem;
}

.editor-preview-mode .book-prose {
    font-size: calc(var(--book-body-size, 1rem) * 1.07);
    line-height: 1.82;
}

.editor-preview-mode .book-prose h2 {
    font-size: calc(var(--book-heading-size, 1.35rem) * 1.07);
}

.editor-preview-mode .book-prose h3 {
    font-size: calc(var(--book-heading-size, 1.35rem) * 0.8 * 1.07);
}

/* Math */
.math-viewer {
    min-height: 40px;
    cursor: pointer;
    text-align: center;
    padding: 10px;
    border-radius: 4px;
}

.math-viewer:hover {
    background-color: #f3f4f6;
}

.math-editor {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.math-input {
    width: 100%;
    padding: 10px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-family: monospace;
    font-size: 1rem;
}

.math-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

.math-error {
    color: var(--danger-color);
    font-size: 0.9rem;
}

/* Misma columna que el texto del libro (márgenes laterales alineados) */
.block-fill-blank .block-content,
.block-quiz-mc .block-content,
.block-order-steps .block-content,
.block-true-false .block-content,
.block-open-question .block-content,
.block-wordsearch .block-content,
.block-crossword .block-content,
.block-match .block-content,
.block-math-guided .block-content,
.block-math-find-error .block-content,
.block-math-classify .block-content,
.block-math-equiv .block-content,
.block-math .block-content,
.block-table .block-content,
.block-chart .block-content {
    max-width: var(--book-measure);
    margin-left: auto;
    margin-right: auto;
    width: 100%;
    box-sizing: border-box;
    min-width: 0;
}

/* Vista lectura: acento lateral suave en actividades interactivas */
.editor-preview-mode .canvas-block.block-quiz-mc .block-content,
.editor-preview-mode .canvas-block.block-match .block-content,
.editor-preview-mode .canvas-block.block-math-equiv .block-content,
.editor-preview-mode .canvas-block.block-math-classify .block-content,
.editor-preview-mode .canvas-block.block-order-steps .block-content,
.editor-preview-mode .canvas-block.block-math-find-error .block-content,
.editor-preview-mode .canvas-block.block-math-guided .block-content,
.editor-preview-mode .canvas-block.block-true-false .block-content,
.editor-preview-mode .canvas-block.block-open-question .block-content,
.editor-preview-mode .canvas-block.block-fill-blank .block-content,
.editor-preview-mode .canvas-block.block-wordsearch .block-content,
.editor-preview-mode .canvas-block.block-crossword .block-content {
    border-left: 3px solid var(--book-activity-bar);
    padding-left: 12px;
}

.block-wordsearch .block-content {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.block-crossword .block-content {
    overflow-x: hidden;
    overflow-y: visible;
    -webkit-overflow-scrolling: auto;
}

/* Matem?ticas: no salirse de la hoja; desplazamiento horizontal si la f?rmula es larga */
.block-math .math-viewer {
    max-width: 100%;
    min-width: 0;
    overflow-x: auto;
    overflow-y: visible;
    -webkit-overflow-scrolling: touch;
    text-align: center;
    box-sizing: border-box;
    padding: 10px 6px;
}

.block-math .math-viewer::-webkit-scrollbar {
    height: 7px;
}

.block-math .math-viewer::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 4px;
}

.block-math .math-viewer::-webkit-scrollbar-track {
    background: #f1f5f9;
    border-radius: 4px;
}

.block-math .katex-display {
    margin: 0.35em auto;
    overflow-x: auto;
    overflow-y: hidden;
    max-width: 100%;
    padding: 0.2em 0 0.35em;
    text-align: center;
    box-sizing: border-box;
}

.block-math .katex-display > .katex {
    white-space: nowrap;
}

.block-math .math-viewer .katex-error {
    white-space: normal;
    overflow-wrap: break-word;
    text-align: left;
}

/* ?? Tabla editorial ?? */
.table-viewer {
    min-height: 48px;
}

.book-table-empty {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin: 0;
    padding: 0.5rem 0;
}

.book-table-scroll {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    max-width: 100%;
}

.book-table {
    width: 100%;
    border-collapse: collapse;
    font-family: var(--book-serif);
    font-size: calc(var(--genlibros-read-size, 1.02rem) * 0.97);
    line-height: 1.5;
    color: var(--book-ink);
    border: 1px solid #d1d5db;
    border-radius: 6px;
    overflow: hidden;
}

.book-table-caption {
    caption-side: top;
    text-align: left;
    font-weight: 600;
    font-size: 0.92em;
    padding: 0 0 0.5rem;
    color: var(--text-primary);
}

.book-table th,
.book-table td {
    border: 1px solid #e5e7eb;
    padding: 0.45rem 0.65rem;
    text-align: left;
    vertical-align: top;
}

.book-table thead th {
    background: #f3f4f6;
    font-weight: 600;
    color: #374151;
}

.book-table tbody tr:nth-child(even) {
    background: #fafafa;
}

.book-table-placeholder {
    color: var(--text-secondary);
    font-style: italic;
}

.table-header-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.875rem;
    margin: 6px 0 12px;
    cursor: pointer;
    color: var(--text-primary);
}

.table-caption-input {
    width: 100%;
    box-sizing: border-box;
    padding: 8px 10px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 0.875rem;
    margin-bottom: 4px;
}

.table-editor-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin: 10px 0 8px;
}

.table-edit-hint {
    font-size: 0.8125rem;
    line-height: 1.45;
    color: var(--text-secondary);
    margin: 0 0 10px;
}

.table-grid-scroll {
    max-height: min(52vh, 420px);
    overflow: auto;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    background: #fafafa;
    margin-bottom: 12px;
    -webkit-overflow-scrolling: touch;
}

.table-edit-grid {
    width: 100%;
    border-collapse: separate;
    border-spacing: 2px;
    table-layout: fixed;
}

.table-edit-grid td {
    padding: 0;
    vertical-align: middle;
    background: #fff;
}

.table-edit-cell {
    width: 100%;
    min-width: 5.5rem;
    box-sizing: border-box;
    padding: 8px 10px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 0.875rem;
    font-family: inherit;
    background: #fff;
    transition:
        border-color 0.15s,
        box-shadow 0.15s;
}

.table-edit-cell:hover {
    border-color: #a5b4fc;
}

.table-edit-cell:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.2);
}

.table-tsv-fallback {
    margin: 12px 0 4px;
    padding: 10px 12px;
    background: #f9fafb;
    border-radius: 8px;
    border: 1px solid #e5e7eb;
}

.table-tsv-summary {
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--text-secondary);
    cursor: pointer;
    user-select: none;
}

.table-tsv-summary:hover {
    color: var(--primary-color);
}

.table-tsv-hint {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin: 8px 0;
    line-height: 1.4;
}

.table-tsv-input {
    width: 100%;
    box-sizing: border-box;
    margin: 8px 0;
    padding: 8px 10px;
    font-family: ui-monospace, 'Cascadia Code', monospace;
    font-size: 0.8125rem;
    line-height: 1.4;
    border: 1px solid var(--border-color);
    border-radius: 6px;
}

.table-parse-tsv-btn {
    margin-top: 4px;
}

.editor-preview-mode .book-table {
    font-size: calc(var(--genlibros-read-size, 1rem) * 1.07);
}

.editor-preview-mode .book-table th,
.editor-preview-mode .book-table td {
    padding: 0.5rem 0.7rem;
}

/* ?? Gr?ficas (Chart.js) ?? */
.chart-viewer {
    min-height: 200px;
}

.chart-canvas-wrap {
    position: relative;
    width: 100%;
    height: min(280px, 42vh);
    min-height: 200px;
    max-height: 360px;
}

.chart-canvas {
    display: block;
    width: 100% !important;
    height: 100% !important;
}

.chart-fallback {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin: 0;
    padding: 1rem 0;
}

.chart-type-select,
.chart-title-input,
.chart-dataset-input,
.chart-labels-input,
.chart-values-input {
    width: 100%;
    margin-bottom: 10px;
    padding: 8px 10px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 0.875rem;
    box-sizing: border-box;
}

.chart-type-select {
    background: #fff;
}

/* Formularios en bloques */
.field-label {
    font-size: 0.85rem;
    color: var(--text-secondary);
    display: block;
    margin-bottom: 8px;
}

.field-label code {
    font-size: 0.8rem;
    background: #f3f4f6;
    padding: 2px 6px;
    border-radius: 4px;
}

.field-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 10px;
}

.fb-input {
    width: 100%;
    min-height: 80px;
    padding: 10px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-family: inherit;
    resize: vertical;
}

/* —— Rellenar huecos: editor de composición y vista con saltos de línea —— */
.fb-compose {
    display: flex;
    flex-direction: column;
    gap: 0.55rem;
    padding: 0.95rem 1rem 1rem;
    margin: 0 0 0.75rem;
    border-radius: 12px;
    border: 1px solid rgba(148, 163, 184, 0.35);
    background:
        linear-gradient(180deg, rgba(248, 250, 252, 0.95) 0%, rgba(241, 245, 249, 0.55) 100%);
    box-shadow: 0 1px 0 rgba(255, 255, 255, 0.7) inset;
}

.fb-compose--code {
    margin-bottom: 0;
}

.fb-compose-head {
    margin: 0 0 0.15rem;
}

.fb-compose-kicker {
    display: block;
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #64748b;
    margin-bottom: 0.2rem;
}

.fb-compose-title {
    margin: 0;
    font-size: 1.02rem;
    font-weight: 700;
    color: #0f172a;
    letter-spacing: -0.02em;
    line-height: 1.25;
}

.fb-compose-lead {
    margin: 0.35rem 0 0;
    font-size: 0.84rem;
    line-height: 1.5;
    color: #64748b;
}

.fb-compose-lead--compact {
    margin: 0.15rem 0 0.35rem;
}

.fb-compose-lead code {
    font-size: 0.8em;
    padding: 0.08em 0.35em;
    border-radius: 4px;
    background: rgba(99, 102, 241, 0.1);
    color: #4338ca;
    font-weight: 600;
}

.fb-compose-label {
    font-size: 0.78rem;
    font-weight: 600;
    color: #475569;
}

.fb-compose-textarea,
.activity-visual-editor .fb-visual-text.fb-compose-textarea,
.activity-visual-editor .fb-input.fb-compose-textarea {
    width: 100%;
    min-height: 11.5rem;
    margin: 0;
    padding: 0.85rem 0.95rem;
    border: 1px solid rgba(148, 163, 184, 0.5);
    border-radius: 10px;
    background: #ffffff;
    color: #0f172a;
    font-family: 'Literata', 'Source Serif 4', Georgia, 'Times New Roman', serif;
    font-size: 0.98rem;
    line-height: 1.65;
    white-space: pre-wrap;
    overflow-wrap: break-word;
    resize: vertical;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.fb-compose-textarea:focus,
.activity-visual-editor .fb-visual-text.fb-compose-textarea:focus,
.activity-visual-editor .fb-input.fb-compose-textarea:focus {
    outline: none;
    border-color: rgba(99, 102, 241, 0.65);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

.fb-compose-textarea::placeholder {
    color: #94a3b8;
    font-style: italic;
    opacity: 0.9;
}

.fb-compose-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.65rem 1rem;
    margin-top: 0.15rem;
}

.fb-compose-tip {
    margin: 0;
    flex: 1 1 12rem;
    font-size: 0.78rem;
    line-height: 1.4;
    color: #64748b;
}

.fb-compose-tip strong {
    color: #334155;
    font-weight: 600;
}

.fb-blanks-empty {
    padding: 0.85rem 1rem;
    border-radius: 10px;
    border: 1px dashed rgba(148, 163, 184, 0.55);
    background: rgba(248, 250, 252, 0.8);
}

.fb-blanks-empty-title {
    margin: 0 0 0.2rem;
    font-size: 0.88rem;
    font-weight: 650;
    color: #475569;
}

.fb-blanks-empty-text {
    margin: 0;
    font-size: 0.82rem;
    color: #94a3b8;
    line-height: 1.45;
}

.fb-blanks-empty-text code {
    font-size: 0.85em;
    color: #6366f1;
}

.fb-blanks-panel {
    border-radius: 12px;
    border: 1px solid rgba(148, 163, 184, 0.35);
    background: #fff;
    overflow: hidden;
}

.fb-blanks-panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    padding: 0.55rem 0.85rem;
    background: linear-gradient(180deg, #f8fafc 0%, #f1f5f9 100%);
    border-bottom: 1px solid rgba(148, 163, 184, 0.28);
}

.fb-blanks-panel-title {
    font-size: 0.8rem;
    font-weight: 700;
    color: #334155;
    letter-spacing: 0.01em;
}

.fb-blanks-panel-count {
    min-width: 1.5rem;
    height: 1.5rem;
    padding: 0 0.4rem;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 700;
    color: #4338ca;
    background: rgba(99, 102, 241, 0.12);
}

.fb-blanks-list {
    list-style: none;
    margin: 0;
    padding: 0.45rem;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.fb-blank-row {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    padding: 0.3rem 0.35rem;
    border-radius: 8px;
}

.fb-blank-row:hover {
    background: rgba(241, 245, 249, 0.85);
}

.fb-blank-index {
    flex: 0 0 1.55rem;
    height: 1.55rem;
    border-radius: 6px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 700;
    color: #475569;
    background: #e2e8f0;
}

.fb-blank-label {
    flex: 1;
    min-width: 0;
    margin: 0;
}

.fb-blank-answer-input {
    width: 100%;
    padding: 0.45rem 0.65rem;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 600;
    color: #0f172a;
    background: #fff;
    box-sizing: border-box;
}

.fb-blank-answer-input:focus {
    outline: none;
    border-color: rgba(99, 102, 241, 0.6);
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.12);
}

/* Visor del libro: párrafos y huecos entre conceptos */
.fill-blank-viewer {
    width: 100%;
}

.fill-blank-body {
    display: flex;
    flex-direction: column;
    gap: 0;
    width: 100%;
}

.fill-blank-para {
    margin: 0 0 0.35em;
    padding: 0;
    line-height: 2.05;
    font-size: 1.05rem;
    color: inherit;
    white-space: normal;
    overflow-wrap: break-word;
    word-break: normal;
}

.fill-blank-para:last-child {
    margin-bottom: 0;
}

.fill-blank-para--empty {
    color: #94a3b8;
    font-style: italic;
    line-height: 1.5;
}

.fill-blank-gap {
    flex: 0 0 auto;
    width: 100%;
    min-height: 0.55em;
    pointer-events: none;
}

.fill-blank-gap--1 {
    min-height: 0.55em;
}

.fill-blank-gap--2 {
    min-height: 1rem;
}

.fill-blank-gap--3 {
    min-height: 1.35rem;
}

/* Compat: clases antiguas que aún pudieran referenciarse */
.fill-blank-line {
    line-height: 2.2;
    font-size: 1.05rem;
    padding: 4px 0;
    white-space: pre-wrap;
}

.fill-blank-input {
    padding: 4px 6px;
    margin: 0 5px;
    border: none;
    border-bottom: 2px solid var(--primary-color);
    background: #eef2ff;
    color: var(--primary-color);
    font-weight: 600;
    text-align: center;
    outline: none;
    border-radius: 4px 4px 0 0;
}

.fill-blank-input:disabled {
    cursor: default;
    opacity: 0.95;
}

/* Estilos compactos y de alta calidad para inputs dentro de fórmulas KaTeX */
.katex .fill-blank-input {
    padding: 2px 4px !important;
    margin: 0 2px !important;
    height: 1.45em !important;
    line-height: 1.1 !important;
    font-size: 0.85em !important;
    border-radius: 3px !important;
    border: 1px solid #cbd5e1;
    background: #f8fafc;
    display: inline-block !important;
    box-sizing: border-box !important;
    vertical-align: middle !important;
}

.katex .fill-blank-input:focus {
    border-color: var(--primary-color);
    background: #ffffff;
}

/* Accesibilidad: etiquetas solo para lectores de pantalla */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.book-activity-error {
    font-size: 0.88rem;
    line-height: 1.5;
    color: #92400e;
    background: linear-gradient(135deg, #fffbeb 0%, #fef3c7 100%);
    border: 1px solid #fcd34d;
    border-radius: var(--radius-md);
    padding: 12px 14px;
    margin: 4px 0 8px;
}

.book-activity-error code {
    font-size: 0.82em;
    background: rgba(255, 255, 255, 0.7);
    padding: 1px 5px;
    border-radius: 4px;
}

/* ?? Cuestionario opci?n m?ltiple ?? */
.book-quiz-editor-hint {
    font-size: 0.78rem;
    color: var(--text-secondary);
    margin: 0 0 12px;
    line-height: 1.45;
}

.book-quiz-multi {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.book-quiz-pack-meta {
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin: 0 0 2px;
}

/* Nuevo diseño de cuestionario tipo ICFES */
.book-quiz-container {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin: 12px 0;
    font-family: 'Outfit', 'Inter', -apple-system, sans-serif;
}

.book-quiz-context-header {
    font-size: 0.72rem;
    font-weight: 800;
    color: #4b5563;
    letter-spacing: 0.12em;
    background: #e5e7eb;
    padding: 4px 10px;
    border-radius: 4px;
    display: inline-block;
    align-self: flex-start;
    margin-bottom: -6px;
}

.book-quiz-context {
    border: 1px solid #cbd5e1;
    background: #f8fafc;
    border-radius: 12px;
    padding: 16px;
    margin: 0;
    font-size: 0.95rem;
    line-height: 1.6;
    color: #334155;
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.02);
}

.book-quiz-context p {
    margin: 0 0 10px 0;
}
.book-quiz-context p:last-child {
    margin-bottom: 0;
}

.book-quiz-context-image-wrapper {
    display: flex;
    justify-content: center;
    align-items: center;
    margin-top: 12px;
    background: #fff;
    padding: 8px;
    border-radius: 8px;
    border: 1px dashed #e2e8f0;
}

.book-quiz-context-image {
    max-width: 100%;
    max-height: 280px;
    border-radius: 6px;
    object-fit: contain;
}

.book-quiz-fieldset {
    border: none;
    padding: 0;
    margin: 0;
    background: transparent;
}

.book-quiz-question {
    font-family: var(--book-serif, Georgia, serif);
    font-size: 1.12rem;
    font-weight: 700;
    color: #1e293b;
    padding: 0;
    margin: 0 0 16px 0;
    line-height: 1.5;
}

.book-quiz-num {
    background: var(--primary-color, #4f46e5);
    color: #ffffff;
    border-radius: 6px;
    padding: 2px 8px;
    font-size: 0.9rem;
    font-weight: bold;
    margin-right: 8px;
}

/* Panel de numeración del cuestionario (editor visual) */
.quiz-mc-numbering-panel {
    margin: 0 0 14px;
    padding: 12px 12px 10px;
    border-radius: 10px;
    border: 1px solid #e0e7ff;
    background: linear-gradient(180deg, #f8fafc 0%, #eef2ff 100%);
    box-sizing: border-box;
}

.quiz-mc-numbering-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 10px;
}

.quiz-mc-numbering-title {
    font-size: 0.88rem;
    font-weight: 700;
    color: #312e81;
}

.quiz-mc-numbering-preview {
    font-size: 0.78rem;
    font-weight: 600;
    color: #4338ca;
    background: #fff;
    border: 1px solid #c7d2fe;
    border-radius: 999px;
    padding: 3px 10px;
    white-space: nowrap;
}

.quiz-mc-numbering-modes {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 10px;
}

.quiz-mc-numbering-option {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    margin: 0;
    padding: 8px 10px;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
    background: #fff;
    cursor: pointer;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.quiz-mc-numbering-option:has(input:checked) {
    border-color: #818cf8;
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.12);
}

.quiz-mc-numbering-option input {
    margin-top: 3px;
    flex-shrink: 0;
}

.quiz-mc-numbering-option strong {
    display: block;
    font-size: 0.84rem;
    color: #1e293b;
}

.quiz-mc-numbering-option small {
    display: block;
    margin-top: 2px;
    font-size: 0.75rem;
    color: #64748b;
    line-height: 1.35;
}

.quiz-mc-numbering-fixed-label {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.84rem;
    font-weight: 600;
    color: #334155;
    margin: 0;
}

.quiz-mc-numbering-fixed-label.is-disabled {
    opacity: 0.55;
}

.quiz-mc-question-number-input {
    width: 72px;
    padding: 6px 8px;
    border-radius: 6px;
    border: 1px solid #cbd5e1;
    font-size: 0.9rem;
    font-weight: 700;
    text-align: center;
}

.quiz-mc-question-number-input:disabled {
    background: #f1f5f9;
    color: #64748b;
    cursor: not-allowed;
}

.quiz-mc-editor-num-badge {
    display: inline-block;
    margin-left: 6px;
    padding: 2px 8px;
    border-radius: 999px;
    background: #e0e7ff;
    color: #3730a3;
    font-size: 0.78rem;
    font-weight: 700;
    vertical-align: middle;
}

.book-quiz-options {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.book-quiz-option {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-radius: 10px;
    border: 1.5px solid #e2e8f0;
    background: #ffffff;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.02);
}

.book-quiz-option:hover {
    border-color: #cbd5e1;
    background: #f8fafc;
    transform: translateY(-1px);
    box-shadow: 0 4px 6px rgba(0,0,0,0.04);
}

.book-quiz-option:has(.book-quiz-radio:checked) {
    border-color: var(--primary-color, #4f46e5);
    background: #f5f3ff;
}

.book-quiz-option-letter-badge {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: 1.5px solid #cbd5e1;
    color: #64748b;
    font-weight: 700;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #ffffff;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.book-quiz-option:hover .book-quiz-option-letter-badge {
    border-color: #94a3b8;
    color: #475569;
}

.book-quiz-option:has(.book-quiz-radio:checked) .book-quiz-option-letter-badge {
    background: var(--primary-color, #4f46e5);
    color: #ffffff;
    border-color: var(--primary-color, #4f46e5);
    box-shadow: 0 2px 4px rgba(79, 70, 229, 0.2);
}

.book-quiz-option-content {
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex: 1;
}

.book-quiz-option-text {
    font-size: 1rem;
    line-height: 1.45;
    color: #334155;
    font-weight: 500;
}

.book-quiz-option-image-wrapper {
    display: flex;
    justify-content: flex-start;
    align-items: center;
    background: #f8fafc;
    padding: 6px;
    border-radius: 6px;
    border: 1px solid #f1f5f9;
    max-width: fit-content;
}

.book-quiz-option-image {
    max-width: 240px;
    max-height: 140px;
    border-radius: 4px;
    object-fit: contain;
}

/* Verificación de respuestas */
.book-quiz-option.book-quiz-option--ok {
    border-color: #10b981 !important;
    background: #ecfdf5 !important;
    transform: none;
    box-shadow: none;
}

.book-quiz-option.book-quiz-option--ok .book-quiz-option-letter-badge {
    background: #10b981 !important;
    color: #ffffff !important;
    border-color: #10b981 !important;
}

.book-quiz-option.book-quiz-option--bad {
    border-color: #ef4444 !important;
    background: #fef2f2 !important;
    transform: none;
    box-shadow: none;
}

.book-quiz-option.book-quiz-option--bad .book-quiz-option-letter-badge {
    background: #ef4444 !important;
    color: #ffffff !important;
    border-color: #ef4444 !important;
}

.quiz-mc-input,
.order-steps-format-help {
    margin: 0 0 10px;
    padding: 10px 12px;
    font-size: 0.78rem;
    line-height: 1.5;
    color: #475569;
    background: #f8fafc;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
}

.order-steps-format-help code {
    font-size: 0.85em;
    padding: 1px 4px;
    border-radius: 4px;
    background: #fff;
    border: 1px solid #e2e8f0;
}

.order-steps-input,
.true-false-input {
    width: 100%;
    min-height: 140px;
    padding: 10px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-family: inherit;
    font-size: 0.88rem;
    line-height: 1.45;
    resize: vertical;
}

/* Pregunta Abierta */
.open-question-textarea {
    width: 100%;
    box-sizing: border-box;
    padding: 12px 14px;
    border-radius: 8px;
    border: 1px solid var(--border-color, #d1d5db);
    background: var(--bg-color, #ffffff);
    color: var(--text-color, #1f2937);
    font-family: inherit;
    font-size: 0.95rem;
    line-height: 1.5;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s, background-color 0.2s;
    resize: vertical;
}

.open-question-textarea:focus {
    border-color: #6366f1;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

.open-question-textarea:disabled {
    background-color: #f3f4f6;
    color: #6b7280;
    cursor: not-allowed;
    border-color: #e5e7eb;
}

.open-question-counter {
    transition: color 0.2s;
}

.open-question-rubric {
    animation: fadeIn 0.3s ease-out;
}

.order-steps-layout-select {
    width: 100%;
    max-width: 260px;
    margin: 0 0 10px;
}

/* ?? Ordenar pasos ?? */
.book-order-lead {
    font-size: 0.88rem;
    color: var(--text-secondary);
    margin: 0 0 12px;
    line-height: 1.45;
}

.book-order-lead--editor {
    color: #6b7280;
}

.order-steps-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.order-steps-list--correct {
    list-style: decimal;
    padding-left: 1.35rem;
}

.order-steps-list--horizontal {
    display: flex;
    gap: 10px;
    overflow-x: auto;
    padding-bottom: 4px;
}

.order-steps-list--horizontal .order-steps-item {
    min-width: 260px;
    max-width: 320px;
    margin-bottom: 0;
}

.order-steps-list--horizontal.order-steps-list--correct {
    list-style: none;
    padding-left: 0;
}

.order-steps-item {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 10px 12px;
    margin-bottom: 8px;
    border-radius: 8px;
    border: 1px solid #e5e7eb;
    background: #fff;
    box-shadow: var(--shadow-xs);
}

.order-steps-item--locked {
    cursor: default;
}

.order-steps-list--interactive .order-steps-item {
    cursor: grab;
}

.order-steps-list--interactive .order-steps-item:active {
    cursor: grabbing;
}

.order-steps-item--dragging {
    opacity: 0.65;
}

.order-steps-grip {
    color: #9ca3af;
    font-size: 1rem;
    line-height: 1;
    user-select: none;
    flex-shrink: 0;
    align-self: center;
}

.order-steps-num {
    font-weight: 700;
    color: var(--primary-color);
    min-width: 1.5rem;
    flex-shrink: 0;
}

.order-steps-text {
    flex: 1;
    font-size: 0.95rem;
    line-height: 1.45;
    color: var(--text-primary);
}

.order-steps-body--media {
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex: 1;
    min-width: 0;
    align-items: stretch;
}

.order-steps-media {
    display: block;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid #e5e7eb;
    background: #f9fafb;
    max-width: 100%;
}

.order-steps-img {
    display: block;
    max-height: 180px;
    max-width: 100%;
    width: auto;
    height: auto;
    object-fit: contain;
    margin: 0 auto;
    user-select: none;
    -webkit-user-drag: none;
}

.order-steps-caption {
    font-size: 0.92rem;
    line-height: 1.45;
    color: var(--text-primary);
}

.order-steps-move {
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex-shrink: 0;
    align-self: center;
}

.order-steps-list--horizontal .order-steps-move {
    flex-direction: row;
    align-self: flex-start;
}

.order-steps-move .btn-icon {
    padding: 2px 6px;
    font-size: 0.75rem;
    min-height: 26px;
}

.order-steps-item--ok {
    border-color: #10b981;
    background: #ecfdf5;
}

.order-steps-item--bad {
    border-color: #fca5a5;
    background: #fef2f2;
}

/* ?? Verdadero / Falso ?? */
.book-tf-list {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.book-tf-row {
    border: 1px solid #e7e5e4;
    border-radius: var(--radius-md);
    padding: 12px 14px;
    background: linear-gradient(180deg, #fafaf9 0%, #ffffff 50%);
}

.book-tf-statement {
    font-family: var(--book-serif);
    font-size: 0.98rem;
    line-height: 1.55;
    color: var(--text-primary);
    margin: 0 0 10px;
}

.book-tf-choices {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.book-tf-btn {
    padding: 8px 18px;
    border-radius: 8px;
    border: 2px solid #e5e7eb;
    background: #fff;
    font-weight: 600;
    font-size: 0.85rem;
    cursor: pointer;
    color: var(--text-secondary);
    transition: border-color 0.15s, background 0.15s, color 0.15s;
}

.book-tf-btn:hover {
    border-color: #c7d2fe;
    color: var(--primary-color);
}

.book-tf-btn--selected {
    border-color: var(--primary-color);
    background: var(--primary-muted);
    color: var(--primary-color);
}

.book-tf-answer-key {
    font-size: 0.82rem;
    color: var(--text-secondary);
    margin: 0;
}

.book-tf-row--ok {
    border-color: #10b981;
    background: #ecfdf5;
}

.book-tf-row--bad {
    border-color: #f87171;
    background: #fef2f2;
}

/* Imagen */
.image-preview {
    text-align: center;
    padding: 12px 14px;
    border: 2px dashed var(--border-color);
    border-radius: 8px;
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s;
}

.image-preview:hover {
    border-color: var(--primary-color);
    background: #f5f7ff;
}

.image-preview-icon {
    width: 32px;
    height: 32px;
    color: #9ca3af;
    margin-bottom: 10px;
}

.image-preview-hint {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.url-input {
    width: 100%;
    padding: 10px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    margin-top: 10px;
}

/* Imagen: enlace + archivo, ajustes editoriales (recorte, fondo claro) */
.image-uploader {
    padding: 4px 2px 10px;
}

.image-uploader-lead {
    font-size: 0.82rem;
    line-height: 1.45;
    color: var(--text-secondary);
    margin-bottom: 12px;
}

.image-uploader-lead strong {
    color: var(--text-primary);
    font-weight: 600;
}

.image-url-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    margin-bottom: 10px;
}

.image-url-row .url-input {
    flex: 1 1 200px;
    min-width: 0;
    margin-top: 0;
}

.image-file-row {
    display: flex;
    justify-content: flex-start;
}

.image-edit-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid #ebe8e4;
}

.image-edit-bar.hidden {
    display: none !important;
}

.image-edit-btn.is-active {
    background: var(--primary-muted);
    color: var(--primary-color);
    border-color: #c7d2fe;
}

/* ?Quitar? fondo blanco v?a multiplicar (PNG real sigue siendo lo ideal) */
.book-figure--blend-light .book-figure__inner {
    background: #fafaf9;
    isolation: isolate;
}

.book-figure--blend-light .book-figure__img {
    mix-blend-mode: multiply;
}

/* Modal de recorte (im?genes por URL o archivo, sin subir a servidor) */
.image-crop-modal {
    position: fixed;
    inset: 0;
    z-index: 120000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease, visibility 0.2s ease;
}

.image-crop-modal--open {
    opacity: 1;
    visibility: visible;
}

.image-crop-modal__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.45);
    backdrop-filter: blur(2px);
}

.image-crop-modal__panel {
    position: relative;
    z-index: 1;
    max-width: min(920px, 96vw);
    max-height: 92vh;
    background: var(--surface-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.image-crop-modal__head {
    padding: 16px 44px 12px 18px;
    border-bottom: 1px solid var(--border-color);
    position: relative;
}

.image-crop-modal__title {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.image-crop-modal__hint {
    font-size: 0.78rem;
    color: var(--text-secondary);
    line-height: 1.4;
    max-width: 56ch;
}

.image-crop-modal__close {
    position: absolute;
    top: 10px;
    right: 10px;
}

.image-crop-modal__body {
    padding: 14px 16px;
    overflow: auto;
    flex: 1;
    min-height: 0;
    background: #f4f4f5;
}

.image-crop-stage-wrap {
    display: flex;
    justify-content: center;
    align-items: flex-start;
}

.image-crop-stage {
    position: relative;
    display: inline-block;
    max-width: 100%;
    vertical-align: top;
    box-shadow: var(--shadow-sm);
    border-radius: 8px;
    overflow: hidden;
}

.image-crop-stage__img {
    display: block;
    max-width: min(820px, 85vw);
    height: auto;
    vertical-align: top;
}

.image-crop-stage__layer {
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    cursor: crosshair;
    touch-action: none;
}

.image-crop-selection {
    position: absolute;
    box-sizing: border-box;
    border: 2px solid #fff;
    box-shadow: 0 0 0 9999px rgba(15, 23, 42, 0.5);
    cursor: move;
    min-width: 24px;
    min-height: 24px;
}

.image-crop-handle {
    position: absolute;
    width: 14px;
    height: 14px;
    background: #fff;
    border: 2px solid var(--primary-color);
    border-radius: 2px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
    z-index: 10;
}

.image-crop-handle--nw {
    left: -6px;
    top: -6px;
    cursor: nwse-resize;
}

.image-crop-handle--ne {
    right: -6px;
    top: -6px;
    cursor: nesw-resize;
}

.image-crop-handle--sw {
    left: -6px;
    bottom: -6px;
    cursor: nesw-resize;
}

.image-crop-handle--se {
    right: -6px;
    bottom: -6px;
    cursor: nwse-resize;
}


.image-crop-modal__foot {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 12px 16px;
    border-top: 1px solid var(--border-color);
    background: var(--surface-subtle);
}

/* Figura editorial (docente y estudiante) */
.book-figure {
    margin: 0 auto;
    max-width: min(100%, 36rem);
    padding: 0;
}

.book-figure__inner {
    border-radius: 10px;
    overflow: hidden;
    background: linear-gradient(180deg, #f4f4f5 0%, #ececee 100%);
    box-shadow:
        0 1px 0 rgba(255, 255, 255, 0.85) inset,
        0 4px 20px rgba(15, 23, 42, 0.08),
        0 1px 3px rgba(15, 23, 42, 0.06);
    line-height: 0;
}

.book-figure__img {
    width: 100%;
    height: auto;
    max-height: min(52vh, 480px);
    object-fit: contain;
    object-position: center;
    display: block;
    margin: 0 auto;
}

.block-image .block-content {
    padding-left: 0;
    padding-right: 0;
    padding-top: var(--block-inner-pad-y);
    padding-bottom: calc(var(--block-inner-pad-y) + 2px);
}

/* Lectura: imagen m?s protagonista */
.editor-preview-mode .book-figure {
    max-width: min(100%, 40rem);
}

.editor-preview-mode .book-figure__inner {
    border-radius: 12px;
    box-shadow:
        0 1px 0 rgba(255, 255, 255, 0.9) inset,
        0 12px 40px rgba(15, 23, 42, 0.12),
        0 4px 12px rgba(15, 23, 42, 0.06);
}

.editor-preview-mode .book-figure__img {
    max-height: min(60vh, 540px);
}

/* Portada a p?gina completa: las reglas de lectura de figura no deben limitar altura/ancho (evita ?solo un recorte?) */
.editor-preview-mode .block-image--cover-full .book-figure,
.genlibros-reader .block-image--cover-full .book-figure {
    max-width: none !important;
}

.editor-preview-mode .block-image--cover-full .book-figure__img,
.genlibros-reader .block-image--cover-full .book-figure__img {
    max-height: none !important;
    height: 100% !important;
    width: 100% !important;
    object-fit: cover !important;
    object-position: center;
}

/* Sopa de letras — layout premium, editor amplio y chips a ancho completo */
.block-wordsearch {
    width: 100% !important;
    max-width: 100%;
    min-width: 0;
    box-sizing: border-box;
    margin-left: 0 !important;
    margin-right: 0 !important;
}

.editor-preview-mode .canvas-block.block-wordsearch,
.canvas-block--reader.block-wordsearch {
    width: 100% !important;
    max-width: 100%;
    margin-left: 0 !important;
    margin-right: 0 !important;
}

.block-wordsearch .block-content {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    overflow-x: hidden;
    box-sizing: border-box;
}

.ws-viewer {
    display: flex;
    flex-direction: column;
    gap: 18px;
    align-items: stretch;
    width: 100%;
    min-width: 0;
}

.block-wordsearch .ws-viewer {
    justify-content: flex-start;
}

.ws-grid-wrap {
    width: 100%;
    max-width: 100%;
    padding: 12px;
    border-radius: 12px;
    border: 1px solid #e2e8f0;
    background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
    box-sizing: border-box;
    box-shadow: 0 4px 14px rgba(15, 23, 42, 0.04);
    display: flex;
    justify-content: center;
    container-type: inline-size;
    container-name: ws-board;
}

.ws-grid {
    display: grid;
    gap: 2px;
    padding: 4px;
    width: 100%;
    max-width: min(100%, calc(var(--ws-size, 12) * 42px));
    margin: 0 auto;
    box-sizing: border-box;
}

.ws-cell {
    width: 100%;
    aspect-ratio: 1 / 1;
    min-width: 0;
    min-height: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #fff;
    border: 1px solid #d1d5db;
    border-radius: 4px;
    font-weight: 700;
    /* Letras más grandes y legibles, proporcionales al tamaño del tablero */
    font-size: clamp(0.88rem, calc(100cqw / var(--ws-size, 12) * 0.58), 1.4rem);
    color: #1f2937;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
    user-select: none;
    cursor: default;
    box-sizing: border-box;
}

.editor-preview-mode .ws-cell,
.canvas-block--reader .ws-cell {
    cursor: pointer;
}

.ws-cell--pick {
    background: #e0e7ff !important;
    border-color: #6366f1 !important;
    color: #3730a3 !important;
}

.ws-cell--found {
    background: #a7f3d0 !important;
    border-color: #059669 !important;
    color: #065f46 !important;
}

.ws-cell--miss {
    background: #fecaca !important;
    border-color: #f87171 !important;
}

.ws-words {
    width: 100%;
    min-width: 0;
    box-sizing: border-box;
}

.ws-words-head {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 6px;
}

.ws-heading {
    margin: 0;
    color: var(--primary-color);
    text-transform: uppercase;
    font-size: 0.85rem;
    letter-spacing: 0.05em;
}

.ws-words-count {
    font-size: 0.75rem;
    font-weight: 700;
    color: #64748b;
    background: #f1f5f9;
    border: 1px solid #e2e8f0;
    border-radius: 999px;
    padding: 2px 10px;
}

.ws-heading-bar {
    height: 2px;
    width: 40px;
    background: var(--primary-color);
    margin-bottom: 12px;
    border-radius: 2px;
}

/* Chips en rejilla: aprovecha todo el ancho (2–4 columnas según espacio) */
.ws-word-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(148px, 1fr));
    gap: 8px 10px;
    width: 100%;
}

.ws-chip {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 36px;
    padding: 8px 12px;
    background: #eef2ff;
    color: #3730a3;
    border: 1px solid #c7d2fe;
    border-radius: 10px;
    font-weight: 700;
    font-size: 0.78rem;
    letter-spacing: 0.02em;
    text-align: center;
    line-height: 1.25;
    box-sizing: border-box;
    transition:
        background 0.15s ease,
        color 0.15s ease,
        border-color 0.15s ease;
}

.ws-chip-text {
    overflow-wrap: anywhere;
    word-break: break-word;
}

.ws-chip--found {
    background: #10b981 !important;
    border-color: #059669 !important;
    color: #fff !important;
    text-decoration: line-through;
    text-decoration-thickness: 2px;
}

.ws-empty {
    color: var(--danger-color);
    grid-column: 1 / -1;
}

/* Editor de palabras — panel amplio y profesional */
.ws-editor {
    width: 100%;
    min-width: 0;
}

.ws-editor-card {
    width: 100%;
    box-sizing: border-box;
    padding: 14px 16px 16px;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
    box-shadow: 0 4px 16px rgba(15, 23, 42, 0.04);
}

.ws-editor-hint {
    margin: 0 0 10px;
    font-size: 0.82rem;
    color: #64748b;
    line-height: 1.45;
}

.ws-editor-hint code {
    font-size: 0.78rem;
    background: #f1f5f9;
    padding: 1px 6px;
    border-radius: 4px;
}

.ws-input {
    display: block;
    width: 100%;
    min-height: 180px;
    max-height: 360px;
    padding: 12px 14px;
    border: 1px solid #cbd5e1;
    border-radius: 10px;
    font-family: ui-monospace, 'Cascadia Code', 'Segoe UI', monospace;
    font-size: 0.95rem;
    line-height: 1.55;
    color: #0f172a;
    background: #fff;
    resize: vertical;
    box-sizing: border-box;
}

.ws-input:focus {
    outline: none;
    border-color: #6366f1;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

.ws-editor-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-top: 8px;
    margin-bottom: 12px;
}

.ws-editor-count {
    font-size: 0.78rem;
    font-weight: 700;
    color: #4338ca;
    background: #eef2ff;
    border: 1px solid #c7d2fe;
    border-radius: 999px;
    padding: 3px 10px;
}

.ws-editor-tip {
    font-size: 0.78rem;
    color: #94a3b8;
}

.ws-editor-actions {
    margin-top: 0;
    justify-content: flex-end;
}

/* Interacción alumno (docente preview + lector) */
.ws-play-hint,
.cw-play-hint {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    margin: 0 0 10px;
    padding: 10px 12px;
    border-radius: 10px;
    background: linear-gradient(135deg, #eff6ff 0%, #f8fafc 100%);
    border: 1px solid #bfdbfe;
    color: #1e3a5f;
    font-size: 0.84rem;
    line-height: 1.4;
}

.ws-play-hint.hidden,
.cw-play-hint.hidden {
    display: none !important;
}

.ws-cell--path {
    background: #e0e7ff !important;
    border-color: #6366f1 !important;
    color: #312e81 !important;
}

.ws-words-count--done {
    background: #d1fae5;
    border-color: #6ee7b7;
    color: #065f46;
}

.cw-clue-card--focus {
    border-color: #60a5fa !important;
    background: #f0f9ff !important;
    box-shadow: 0 2px 10px rgba(37, 99, 235, 0.12);
}

.ws-grid {
    touch-action: none;
}

/* Crucigrama — usa todo el ancho del bloque (sin miniatura ni márgenes vacíos) */
.block-crossword {
    width: 100% !important;
    max-width: 100%;
    min-width: 0;
    box-sizing: border-box;
    margin-left: 0 !important;
    margin-right: 0 !important;
}

.editor-preview-mode .canvas-block.block-crossword,
.canvas-block--reader.block-crossword {
    width: 100% !important;
    max-width: 100%;
    margin-left: 0 !important;
    margin-right: 0 !important;
}

.block-crossword .block-content {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    overflow-x: auto;
    overflow-y: visible;
    box-sizing: border-box;
}

.cw-viewer {
    display: flex;
    flex-direction: column;
    gap: 14px;
    width: 100%;
    min-width: 0;
}

.cw-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    width: 100%;
}

.cw-toolbar-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.cw-meta-chip {
    display: inline-flex;
    align-items: center;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    text-transform: uppercase;
    color: #1e3a5f;
    background: linear-gradient(180deg, #f8fafc 0%, #f1f5f9 100%);
    border: 1px solid #e2e8f0;
    border-radius: 999px;
    padding: 3px 10px;
}

.cw-meta-chip--soft {
    font-weight: 600;
    text-transform: none;
    letter-spacing: 0;
    color: #64748b;
    background: #fff;
    border-color: #e2e8f0;
}

/*
 * Contenedor: el tablero SIEMPRE cabe en el ancho (sin barra horizontal).
 * El tamaño de casilla lo calcula JS (--cw-cell-size) o el CSS de respaldo.
 */
.cw-board-shell {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    overflow-x: hidden;
    overflow-y: visible;
    border-radius: 14px;
    container-type: inline-size;
    container-name: cw-board;
}

.cw-grid-placeholder {
    display: flex;
    justify-content: center;
    width: 100%;
    box-sizing: border-box;
    padding: 14px 12px;
    background: #f8fafc;
    border-radius: 12px;
    border: 1px dashed #cbd5e1;
}

.cw-grid-placeholder--live {
    display: flex;
    justify-content: center;
    align-items: flex-start;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    background: linear-gradient(180deg, #f8fafc 0%, #ffffff 55%);
    border: 1px solid #e2e8f0;
    border-radius: 14px;
    padding: 12px 10px;
    box-sizing: border-box;
    box-shadow:
        0 1px 0 rgba(255, 255, 255, 0.9) inset,
        0 8px 22px rgba(15, 23, 42, 0.05);
    overflow: hidden;
}

/*
 * Tablero editorial premium:
 * - Solo casillas con letra (bordes oscuros).
 * - Huecos transparentes.
 * - Encaja en 100 % del ancho: casillas se reducen si hay muchas columnas.
 */
.cw-grid {
    /* Respaldo: reparto equitativo del ancho útil (sin mínimo alto que desborde) */
    --cw-cell-size: min(34px, calc((100cqw - 8px) / max(var(--cw-cols, 1), 1)));
    display: grid;
    width: max-content;
    max-width: 100%;
    margin: 0 auto;
    box-sizing: border-box;
    grid-template-columns: repeat(var(--cw-cols, 1), var(--cw-cell-size));
    grid-auto-rows: var(--cw-cell-size);
    gap: 0;
    border: none;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
}

@supports not (width: 1cqw) {
    .cw-grid {
        --cw-cell-size: min(34px, 4.8vmin);
        width: 100%;
        max-width: 100%;
        grid-template-columns: repeat(var(--cw-cols, 1), minmax(0, 1fr));
        grid-auto-rows: auto;
    }

    .cw-grid .cw-cell {
        width: 100%;
        height: auto;
        aspect-ratio: 1 / 1;
    }
}

.cw-cell {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: var(--cw-cell-size);
    height: var(--cw-cell-size);
    min-width: 0;
    min-height: 0;
    aspect-ratio: unset;
    box-sizing: border-box;
    background: #ffffff;
    border: 1.5px solid #1e293b;
    color: #0f172a;
    font-weight: 800;
    font-size: max(9px, calc(var(--cw-cell-size) * 0.48));
    line-height: 1;
    font-family: "Segoe UI", "Helvetica Neue", Arial, sans-serif;
    user-select: none;
    z-index: 1;
}

/* Huecos invisibles: se ve la forma de las palabras, no un mar de celdas vacías */
.cw-cell--void {
    background: transparent !important;
    border: 0 !important;
    box-shadow: none !important;
    outline: none !important;
    pointer-events: none !important;
    z-index: 0;
}

.cw-cell--active {
    background: #dbeafe !important;
    box-shadow: inset 0 0 0 2px #2563eb;
    z-index: 2;
}

.cw-cell-num {
    position: absolute;
    top: 1px;
    left: 2px;
    font-size: max(6px, calc(var(--cw-cell-size) * 0.24));
    font-weight: 800;
    color: #0f172a;
    line-height: 1;
    pointer-events: none;
    z-index: 2;
}

.cw-cell-letter {
    text-transform: uppercase;
    letter-spacing: 0;
    color: #0f172a;
}

.cw-cell-input {
    width: 100%;
    height: 100%;
    border: none;
    background: transparent;
    text-align: center;
    font-weight: 800;
    font-size: inherit;
    text-transform: uppercase;
    outline: none;
    padding: 0;
    margin: 0;
    color: inherit;
    caret-color: #2563eb;
    font-family: inherit;
}

.cw-cell-input.cw-cell--ok {
    color: #047857;
    background: #d1fae5;
}

.cw-cell-input.cw-cell--bad {
    color: #b91c1c;
    background: #fee2e2;
}

.cw-grid-inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    color: var(--primary-color);
    text-align: center;
}

.cw-grid-icon {
    width: 48px;
    height: 48px;
    margin-bottom: 10px;
    opacity: 0.85;
}

.cw-grid-title {
    font-weight: 700;
    font-size: 1.05rem;
}

.cw-grid-sub {
    font-size: 0.85rem;
    margin-top: 6px;
    opacity: 0.85;
    max-width: 320px;
    line-height: 1.4;
}

.cw-empty-msg {
    color: var(--danger-color);
    padding: 16px;
    text-align: center;
    margin: 0;
    font-size: 0.95rem;
}

.cw-clues-panel {
    width: 100%;
    min-width: 0;
}

.cw-clues-title {
    margin: 0 0 12px;
    border-bottom: 2px solid var(--border-color);
    padding-bottom: 6px;
    display: inline-block;
    color: var(--primary-color);
    font-size: 1rem;
}

.cw-clues {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
    align-items: start;
    width: 100%;
}

.cw-clue-col-title {
    margin: 0 0 10px;
    font-weight: 700;
    color: #374151;
    font-size: 0.92rem;
    display: flex;
    align-items: center;
    gap: 8px;
}

.cw-clue-col-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    border-radius: 6px;
    background: #1e3a5f;
    color: #fff;
    font-size: 0.75rem;
    font-weight: 800;
}

.cw-clue-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.cw-clue-card {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    padding: 10px 12px;
    display: flex;
    gap: 10px;
    align-items: flex-start;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.editor-preview-mode .cw-clue-card {
    cursor: pointer;
}

.editor-preview-mode .cw-clue-card:hover {
    border-color: #93c5fd;
    box-shadow: 0 2px 8px rgba(37, 99, 235, 0.1);
}

.cw-clue-num {
    background: var(--primary-color, #1e3a5f);
    color: #fff;
    font-weight: 700;
    border-radius: 50%;
    width: 22px;
    height: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 0.7rem;
}

.cw-clue-body {
    min-width: 0;
}

.cw-clue-text {
    display: block;
    font-size: 0.88rem;
    line-height: 1.4;
    color: #334155;
}

.cw-clue-word {
    display: block;
    font-size: 0.86rem;
    margin-bottom: 3px;
    color: #0f172a;
}

.cw-editor-hint {
    margin: 0 0 8px;
    font-size: 0.82rem;
    color: #6b7280;
    line-height: 1.4;
}

.cw-limit-banner {
    margin: 0 0 10px;
    padding: 10px 12px;
    border-radius: 10px;
    border: 1px solid #c7d2fe;
    background: linear-gradient(180deg, #eef2ff 0%, #f8fafc 100%);
    color: #312e81;
    font-size: 0.84rem;
    line-height: 1.45;
}

.cw-limit-banner strong {
    font-weight: 700;
}

.cw-limit-count {
    display: block;
    margin-top: 4px;
    font-weight: 700;
    color: #4338ca;
}

.cw-limit-banner--warn {
    border-color: #fcd34d;
    background: linear-gradient(180deg, #fffbeb 0%, #fefce8 100%);
    color: #92400e;
}

.cw-limit-banner--warn .cw-limit-count {
    color: #b45309;
}

.cw-limit-banner--bad {
    border-color: #fca5a5;
    background: linear-gradient(180deg, #fef2f2 0%, #fff 100%);
    color: #991b1b;
}

.cw-limit-banner--bad .cw-limit-count {
    color: #b91c1c;
}

.cw-input {
    width: 100%;
    min-height: 150px;
    padding: 12px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-family: ui-monospace, monospace;
    line-height: 1.5;
    font-size: 0.95rem;
}

@media (max-width: 720px) {
    .cw-clues {
        grid-template-columns: 1fr;
    }
}

/* Match: siempre reservar un canal central para las curvas SVG (evita que columnas se toquen con texto largo) */
.match-columns {
    display: flex;
    flex-direction: row;
    align-items: flex-start;
    /* Hueco m?nimo entre columnas; crece un poco en hojas anchas */
    gap: clamp(1.75rem, min(12vw, 7rem), 8rem);
    position: relative;
    min-height: 120px;
    padding: 12px 22px;
    background: #fafafa;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    box-sizing: border-box;
}

.match-col {
    display: flex;
    flex-direction: column;
    gap: 14px;
    z-index: 2;
    /* Reparto equitativo: el gap queda garantizado; el texto envuelve dentro de cada mitad */
    flex: 1 1 0;
    min-width: 0;
}

.match-svg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1;
}

.match-pill {
    padding: 8px 14px;
    background: #fff;
    border-radius: 8px;
    font-weight: 600;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    box-sizing: border-box;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    overflow-wrap: anywhere;
    word-break: break-word;
    hyphens: auto;
}

.match-pill--left {
    border: 2px solid var(--primary-color);
}

.match-pill--right {
    border: 2px solid #d1d5db;
}

.match-input {
    width: 100%;
    min-height: 120px;
    padding: 12px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-family: ui-monospace, monospace;
    font-size: 0.95rem;
}

/* ==========================================================================
   Biblioteca de bloques — categorías (minimal)
   ========================================================================== */

.toolbar-content-details,
.toolbar-eval-details,
.toolbar-game-details,
.toolbar-tech-details,
.toolbar-math-details,
.toolbar-bio-details {
    border-radius: 8px;
    border: 1px solid var(--border-color);
    background: #fff;
    overflow: hidden;
    margin-bottom: 6px;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.tool-group--content .toolbar-content-details {
    border-left: 3px solid var(--category-content);
}
.tool-group--content .toolbar-content-details[open] {
    border-color: var(--border-color);
    border-left-color: var(--category-content);
    box-shadow: 0 2px 8px rgba(15, 23, 42, 0.05);
}

.tool-group--eval .toolbar-eval-details {
    border-left: 3px solid var(--category-eval);
}
.tool-group--eval .toolbar-eval-details[open] {
    border-color: var(--border-color);
    border-left-color: var(--category-eval);
    box-shadow: 0 2px 8px rgba(15, 23, 42, 0.05);
}

.tool-group--game .toolbar-game-details {
    border-left: 3px solid var(--category-game);
}
.tool-group--game .toolbar-game-details[open] {
    border-color: var(--border-color);
    border-left-color: var(--category-game);
    box-shadow: 0 2px 8px rgba(15, 23, 42, 0.05);
}

.tool-group--tech .toolbar-tech-details {
    border-left: 3px solid var(--category-tech);
}
.tool-group--tech .toolbar-tech-details[open] {
    border-color: var(--border-color);
    border-left-color: var(--category-tech);
    box-shadow: 0 2px 8px rgba(15, 23, 42, 0.05);
}

.tool-group--math .toolbar-math-details {
    border-left: 3px solid var(--category-math);
}
.tool-group--math .toolbar-math-details[open] {
    border-color: var(--border-color);
    border-left-color: var(--category-math);
    box-shadow: 0 2px 8px rgba(15, 23, 42, 0.05);
}

.tool-group--bio .toolbar-bio-details {
    border-left: 3px solid var(--category-bio);
}
.tool-group--bio .toolbar-bio-details[open] {
    border-color: var(--border-color);
    border-left-color: var(--category-bio);
    box-shadow: 0 2px 8px rgba(15, 23, 42, 0.05);
}

.toolbar-content-summary,
.toolbar-eval-summary,
.toolbar-game-summary,
.toolbar-tech-summary,
.toolbar-math-summary,
.toolbar-bio-summary {
    list-style: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    user-select: none;
    transition: background 0.12s ease;
}

.toolbar-content-summary::-webkit-details-marker,
.toolbar-eval-summary::-webkit-details-marker,
.toolbar-game-summary::-webkit-details-marker,
.toolbar-tech-summary::-webkit-details-marker,
.toolbar-math-summary::-webkit-details-marker,
.toolbar-bio-summary::-webkit-details-marker {
    display: none;
}

.toolbar-content-summary:hover,
.toolbar-eval-summary:hover,
.toolbar-game-summary:hover,
.toolbar-tech-summary:hover,
.toolbar-math-summary:hover,
.toolbar-bio-summary:hover {
    background: #f8fafc;
}

.toolbar-content-summary-icon,
.toolbar-eval-summary-icon,
.toolbar-game-summary-icon,
.toolbar-tech-summary-icon,
.toolbar-math-summary-icon,
.toolbar-bio-summary-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    min-width: 28px;
    border-radius: 6px;
    flex-shrink: 0;
}

.tool-group--content .toolbar-content-summary-icon {
    background: rgba(59, 130, 246, 0.1);
    color: var(--category-content);
}
.tool-group--eval .toolbar-eval-summary-icon {
    background: rgba(245, 158, 11, 0.12);
    color: #b45309;
}
.tool-group--game .toolbar-game-summary-icon {
    background: rgba(16, 185, 129, 0.1);
    color: #047857;
}
.tool-group--tech .toolbar-tech-summary-icon {
    background: rgba(139, 92, 246, 0.1);
    color: #6d28d9;
}
.tool-group--math .toolbar-math-summary-icon {
    background: rgba(99, 102, 241, 0.1);
    color: var(--category-math);
}
.tool-group--bio .toolbar-bio-summary-icon {
    background: rgba(34, 197, 94, 0.1);
    color: #15803d;
}

.toolbar-content-summary-icon svg,
.toolbar-eval-summary-icon svg,
.toolbar-game-summary-icon svg,
.toolbar-tech-summary-icon svg,
.toolbar-math-summary-icon svg,
.toolbar-bio-summary-icon svg {
    width: 15px;
    height: 15px;
}

.toolbar-content-summary-text,
.toolbar-eval-summary-text,
.toolbar-game-summary-text,
.toolbar-tech-summary-text,
.toolbar-math-summary-text,
.toolbar-bio-summary-text {
    display: flex;
    flex-direction: column;
    gap: 1px;
    min-width: 0;
    flex: 1;
}

.toolbar-content-title,
.toolbar-eval-title,
.toolbar-game-title,
.toolbar-tech-title,
.toolbar-math-title,
.toolbar-bio-title {
    font-size: 0.78rem;
    font-weight: 600;
    letter-spacing: -0.01em;
    color: var(--text-primary);
}

.toolbar-content-sub,
.toolbar-eval-sub,
.toolbar-game-sub,
.toolbar-tech-sub,
.toolbar-math-sub,
.toolbar-bio-sub {
    font-size: 0.65rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.toolbar-content-chevron,
.toolbar-eval-chevron,
.toolbar-game-chevron,
.toolbar-tech-chevron,
.toolbar-math-chevron,
.toolbar-bio-chevron {
    display: flex;
    align-items: center;
    color: #94a3b8;
    transition: transform 0.15s ease;
}

.toolbar-content-chevron svg,
.toolbar-eval-chevron svg,
.toolbar-game-chevron svg,
.toolbar-tech-chevron svg,
.toolbar-math-chevron svg,
.toolbar-bio-chevron svg {
    width: 14px;
    height: 14px;
}

.toolbar-content-details[open] .toolbar-content-chevron,
.toolbar-eval-details[open] .toolbar-eval-chevron,
.toolbar-game-details[open] .toolbar-game-chevron,
.toolbar-tech-details[open] .toolbar-tech-chevron,
.toolbar-math-details[open] .toolbar-math-chevron,
.toolbar-bio-details[open] .toolbar-bio-chevron {
    transform: rotate(180deg);
}

.toolbar-content-panel,
.toolbar-eval-panel,
.toolbar-game-panel,
.toolbar-tech-panel,
.toolbar-math-panel,
.toolbar-bio-panel {
    padding: 0 8px 8px;
    border-top: 1px solid var(--border-color);
}

.toolbar-content-lead,
.toolbar-eval-lead,
.toolbar-game-lead,
.toolbar-tech-lead,
.toolbar-math-lead,
.toolbar-bio-lead {
    display: none;
}

.toolbar-content-grid,
.toolbar-eval-grid,
.toolbar-game-grid,
.toolbar-tech-grid,
.toolbar-math-grid,
.toolbar-bio-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 5px;
    padding-top: 6px;
}

.toolbar-content-grid .tool-item,
.toolbar-eval-grid .tool-item,
.toolbar-game-grid .tool-item,
.toolbar-tech-grid .tool-item,
.toolbar-math-grid .tool-item,
.toolbar-bio-grid .tool-item {
    background: #f8fafc;
    border-radius: 6px;
    border: 1px solid transparent;
    transition: border-color 0.12s ease, background 0.12s ease;
    margin-bottom: 0;
    align-items: center;
    min-width: 0;
    padding: 6px 8px;
    gap: 8px;
    box-shadow: none;
    transform: none;
}

.toolbar-content-grid .tool-item-icon,
.toolbar-eval-grid .tool-item-icon,
.toolbar-game-grid .tool-item-icon,
.toolbar-tech-grid .tool-item-icon,
.toolbar-math-grid .tool-item-icon,
.toolbar-bio-grid .tool-item-icon {
    width: 28px;
    height: 28px;
    margin-top: 0;
    flex-shrink: 0;
    background: #fff;
}

.toolbar-content-grid .tool-item-icon svg,
.toolbar-eval-grid .tool-item-icon svg,
.toolbar-game-grid .tool-item-icon svg,
.toolbar-tech-grid .tool-item-icon svg,
.toolbar-math-grid .tool-item-icon svg,
.toolbar-bio-grid .tool-item-icon svg {
    width: 14px;
    height: 14px;
}

.toolbar-content-grid .tool-item-label,
.toolbar-eval-grid .tool-item-label,
.toolbar-game-grid .tool-item-label,
.toolbar-tech-grid .tool-item-label,
.toolbar-math-grid .tool-item-label,
.toolbar-bio-grid .tool-item-label {
    flex: 1;
    min-width: 0;
    font-size: 0.78rem;
    font-weight: 500;
    white-space: normal;
    overflow-wrap: break-word;
    word-break: break-word;
    line-height: 1.3;
}

.toolbar-content-grid .tool-item-text,
.toolbar-eval-grid .tool-item-text,
.toolbar-game-grid .tool-item-text,
.toolbar-tech-grid .tool-item-text,
.toolbar-math-grid .tool-item-text,
.toolbar-bio-grid .tool-item-text {
    flex: 1;
    min-width: 0;
}

[class*='-grid'] .tool-item:hover {
    background: #fff;
    border-color: var(--border-color);
}

/* ==========================================================================
   Barra lateral minimalista (.toolbar--clean)
   ========================================================================== */
.toolbar--clean {
    width: 240px;
    padding: 12px 10px 10px;
    background: #fafbfc;
    border-right-color: #e8ecf0;
}

.toolbar--clean .toolbar-heading {
    margin-bottom: 10px;
    padding: 0 4px;
    font-size: 0.65rem;
    letter-spacing: 0.12em;
}

.toolbar--clean .toolbar-scroll {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    margin: 0 -2px;
    padding: 0 2px 8px;
}

.toolbar--clean .tool-group {
    margin-bottom: 6px;
}

.toolbar--clean .toolbar-content-details,
.toolbar--clean .toolbar-eval-details,
.toolbar--clean .toolbar-game-details,
.toolbar--clean .toolbar-tech-details,
.toolbar--clean .toolbar-math-details,
.toolbar--clean .toolbar-bio-details,
.toolbar--clean .toolbar-reader-details {
    margin-bottom: 6px;
    border-radius: 8px;
    border: 1px solid #e8ecf0;
    background: #ffffff;
    box-shadow: none;
    overflow: hidden;
}

.toolbar--clean .tool-group--content .toolbar-content-details {
    border-left: 3px solid var(--category-content);
}
.toolbar--clean .tool-group--eval .toolbar-eval-details {
    border-left: 3px solid var(--category-eval);
}
.toolbar--clean .tool-group--game .toolbar-game-details {
    border-left: 3px solid var(--category-game);
}
.toolbar--clean .tool-group--tech .toolbar-tech-details {
    border-left: 3px solid var(--category-tech);
}
.toolbar--clean .tool-group--math .toolbar-math-details {
    border-left: 3px solid var(--category-math);
}
.toolbar--clean .tool-group--bio .toolbar-bio-details {
    border-left: 3px solid var(--category-bio);
}
.toolbar--clean .toolbar-reader-details {
    border-left: 3px solid #64748b;
    margin-top: 4px;
}

.toolbar--clean .toolbar-content-details[open],
.toolbar--clean .toolbar-eval-details[open],
.toolbar--clean .toolbar-game-details[open],
.toolbar--clean .toolbar-tech-details[open],
.toolbar--clean .toolbar-math-details[open],
.toolbar--clean .toolbar-bio-details[open],
.toolbar--clean .toolbar-reader-details[open] {
    box-shadow: 0 2px 10px rgba(15, 23, 42, 0.06);
}

.toolbar--clean .toolbar-content-summary,
.toolbar--clean .toolbar-eval-summary,
.toolbar--clean .toolbar-game-summary,
.toolbar--clean .toolbar-tech-summary,
.toolbar--clean .toolbar-math-summary,
.toolbar--clean .toolbar-bio-summary,
.toolbar--clean .toolbar-reader-summary {
    padding: 8px 10px;
    gap: 8px;
}

.toolbar--clean .toolbar-content-summary-icon,
.toolbar--clean .toolbar-eval-summary-icon,
.toolbar--clean .toolbar-game-summary-icon,
.toolbar--clean .toolbar-tech-summary-icon,
.toolbar--clean .toolbar-math-summary-icon,
.toolbar--clean .toolbar-bio-summary-icon,
.toolbar--clean .toolbar-reader-summary-icon {
    width: 28px;
    height: 28px;
    min-width: 28px;
    border-radius: 7px;
    box-shadow: none;
}

.toolbar--clean .toolbar-reader-summary-icon {
    background: linear-gradient(145deg, #475569, #64748b);
    color: #fff;
}

.toolbar--clean .toolbar-content-summary-icon svg,
.toolbar--clean .toolbar-eval-summary-icon svg,
.toolbar--clean .toolbar-game-summary-icon svg,
.toolbar--clean .toolbar-tech-summary-icon svg,
.toolbar--clean .toolbar-math-summary-icon svg,
.toolbar--clean .toolbar-bio-summary-icon svg,
.toolbar--clean .toolbar-reader-summary-icon svg {
    width: 15px;
    height: 15px;
}

.toolbar--clean .toolbar-content-title,
.toolbar--clean .toolbar-eval-title,
.toolbar--clean .toolbar-game-title,
.toolbar--clean .toolbar-tech-title,
.toolbar--clean .toolbar-math-title,
.toolbar--clean .toolbar-bio-title,
.toolbar--clean .toolbar-reader-title {
    font-size: 0.78rem;
    font-weight: 600;
    color: #1e293b;
}

.toolbar--clean .toolbar-content-sub,
.toolbar--clean .toolbar-eval-sub,
.toolbar--clean .toolbar-game-sub,
.toolbar--clean .toolbar-tech-sub,
.toolbar--clean .toolbar-math-sub,
.toolbar--clean .toolbar-bio-sub,
.toolbar--clean .toolbar-reader-sub {
    font-size: 0.62rem;
    color: #94a3b8;
}

.toolbar--clean .toolbar-reader-summary-text {
    display: flex;
    flex-direction: column;
    gap: 0;
    min-width: 0;
    flex: 1;
}

.toolbar--clean .toolbar-reader-chevron {
    display: flex;
    align-items: center;
    color: #94a3b8;
    transition: transform 0.2s ease;
}

.toolbar--clean .toolbar-reader-details[open] .toolbar-reader-chevron {
    transform: rotate(180deg);
}

.toolbar--clean .toolbar-reader-summary::-webkit-details-marker {
    display: none;
}

.toolbar--clean .toolbar-content-panel,
.toolbar--clean .toolbar-eval-panel,
.toolbar--clean .toolbar-game-panel,
.toolbar--clean .toolbar-tech-panel,
.toolbar--clean .toolbar-math-panel,
.toolbar--clean .toolbar-bio-panel,
.toolbar--clean .toolbar-reader-panel {
    padding: 6px 8px 10px;
    border-top: 1px solid #f1f5f9;
}

.toolbar--clean .toolbar-content-lead,
.toolbar--clean .toolbar-eval-lead,
.toolbar--clean .toolbar-game-lead,
.toolbar--clean .toolbar-tech-lead,
.toolbar--clean .toolbar-math-lead,
.toolbar--clean .toolbar-bio-lead {
    display: none;
}

.toolbar--clean [class*='-grid'] {
    gap: 4px;
}

.toolbar--clean [class*='-grid'] .tool-item {
    padding: 5px 8px;
    gap: 8px;
    border-radius: 6px;
    border-color: #eef2f6;
    box-shadow: none;
}

.toolbar--clean [class*='-grid'] .tool-item:hover {
    transform: none;
    border-color: #c7d2fe;
    box-shadow: 0 1px 4px rgba(79, 70, 229, 0.08);
}

.toolbar--clean [class*='-grid'] .tool-item-icon {
    width: 26px;
    height: 26px;
    margin-top: 0;
}

.toolbar--clean [class*='-grid'] .tool-item-icon svg {
    width: 14px;
    height: 14px;
}

.toolbar--clean [class*='-grid'] .tool-item-label {
    font-size: 0.78rem;
    font-weight: 500;
    line-height: 1.25;
}

.toolbar--clean .toolbar-reader-panel {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toolbar--clean .toolbar-doc-section {
    margin-top: 4px;
    padding: 0.55rem 0.5rem 0.6rem;
    border-radius: 8px;
    border: 1px solid #e8ecf0;
    background: #fff;
    box-shadow: none;
}

.toolbar--clean .toolbar-doc-section-title {
    margin-bottom: 0.2rem;
    font-size: 0.65rem;
    letter-spacing: 0.08em;
}

.toolbar--clean .toolbar-doc-section-lead {
    margin-bottom: 0.5rem;
    font-size: 0.68rem;
}

.toolbar--clean .toolbar-section-divider {
    display: none;
}

.toolbar--clean .doc-asignacion-check {
    font-size: 0.78rem;
    font-weight: 500;
    gap: 0.4rem;
}

.toolbar--clean .doc-asignacion-check--workshop span {
    font-weight: 600;
    color: var(--primary-color);
}

.toolbar--clean .doc-asignacion-rango {
    flex-direction: row;
    gap: 6px;
    margin-top: 0;
    padding-top: 0;
    border-top: none;
}

.toolbar--clean .doc-asignacion-rango .doc-asignacion-field {
    flex: 1;
    min-width: 0;
}

.toolbar--clean .doc-asignacion-field-label {
    font-size: 0.68rem;
}

.toolbar--clean .doc-asignacion-input {
    padding: 0.35rem 0.45rem;
    font-size: 0.85rem;
}

.toolbar--clean .doc-asignacion-select {
    width: 100%;
}

.toolbar--clean .doc-asignacion-strict-row {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-top: 2px;
    padding-top: 8px;
    border-top: 1px dashed #e8ecf0;
}

.toolbar--clean .doc-asignacion-hint {
    margin: 0;
    font-size: 0.68rem;
    line-height: 1.35;
    color: #94a3b8;
}

.toolbar--clean .doc-asignacion-hint--compact {
    margin-top: -2px;
}

.toolbar--clean .doc-asignacion-kiosk-details {
    border: none;
    background: transparent;
}

.toolbar--clean .doc-asignacion-kiosk-details summary {
    font-size: 0.68rem;
    font-weight: 600;
    color: #64748b;
    cursor: pointer;
    padding: 2px 0;
    list-style: none;
}

.toolbar--clean .doc-asignacion-kiosk-details summary::-webkit-details-marker {
    display: none;
}

.toolbar--clean .doc-asignacion-kiosk-details .doc-asignacion-hint {
    margin-top: 4px;
}

.toolbar--clean .toolbar-footer {
    flex-shrink: 0;
    margin-top: 0;
    padding: 10px 4px 2px;
    font-size: 0.68rem;
    line-height: 1.4;
    color: #94a3b8;
    border-top: 1px solid #e8ecf0;
}

.toolbar--clean .toolbar-footer-link {
    display: inline;
    margin-top: 0;
    margin-left: 4px;
    font-size: 0.68rem;
}

/* Bloques matem?ticas (contenido) */
.math-block-empty {
    margin: 0;
    padding: 12px 14px;
    font-size: 0.9rem;
    color: #64748b;
    background: #f8fafc;
    border-radius: 8px;
    border: 1px dashed #cbd5e1;
}

.math-guided-stack {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.math-guided-row {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.math-guided-prompt {
    font-size: 0.95rem;
    line-height: 1.5;
    color: #0f172a;
}

.math-guided-num {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.5rem;
    height: 1.5rem;
    margin-right: 8px;
    border-radius: 6px;
    background: #eef2ff;
    color: #4338ca;
    font-size: 0.75rem;
    font-weight: 700;
    vertical-align: middle;
}

.math-guided-student-input {
    width: 100%;
    max-width: 100%;
    padding: 10px 12px;
    border-radius: 8px;
    border: 1px solid #cbd5e1;
    font-size: 0.95rem;
    font-variant-numeric: tabular-nums;
}

.math-fe-work-wrap {
    display: flex;
    flex-direction: column;
    gap: 0;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid #e2e8f0;
    background: #fff;
}

.math-fe-line {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    padding: 10px 12px;
    border-bottom: 1px solid #f1f5f9;
}

.math-fe-line:last-child {
    border-bottom: none;
}

.math-fe-line-num {
    flex-shrink: 0;
    min-width: 1.75rem;
    text-align: center;
    padding: 2px 6px;
    border-radius: 4px;
    background: #f1f5f9;
    color: #475569;
    font-size: 0.8rem;
}

.math-fe-line-txt {
    font-family: ui-monospace, 'Cascadia Code', monospace;
    font-size: 0.9rem;
    line-height: 1.45;
    color: #0f172a;
}

.math-fe-question {
    margin: 14px 0 8px;
    font-weight: 600;
    font-size: 0.9rem;
    color: #334155;
}

.math-fe-radios {
    display: flex;
    flex-wrap: wrap;
    gap: 10px 16px;
}

.math-fe-radio {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.875rem;
    cursor: pointer;
    color: #334155;
}

.math-cl-table {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.math-cl-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px 14px;
    padding: 12px 14px;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
    background: #fafafa;
}

.math-cl-item-txt {
    flex: 1 1 200px;
    min-width: 0;
    font-size: 0.95rem;
    line-height: 1.45;
    color: #0f172a;
}

.math-cl-select {
    min-width: 180px;
    max-width: 100%;
    padding: 8px 10px;
    border-radius: 8px;
    border: 1px solid #cbd5e1;
    font-size: 0.9rem;
    background: #fff;
}

/* Equivalencias (unir) ? variante matem?tica (mismo criterio de canal central que .match-columns) */
.math-eq-columns {
    display: flex;
    flex-direction: row;
    align-items: flex-start;
    gap: clamp(1.75rem, min(12vw, 7rem), 8rem);
    position: relative;
    min-height: 120px;
    padding: 12px 22px;
    background: linear-gradient(180deg, #f0fdfa 0%, #fafafa 100%);
    border-radius: 8px;
    border: 1px solid rgba(13, 148, 136, 0.25);
    box-sizing: border-box;
}

.math-eq-col {
    display: flex;
    flex-direction: column;
    gap: 14px;
    z-index: 2;
    flex: 1 1 0;
    min-width: 0;
}

.math-eq-svg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1;
}

.math-eq-pill {
    padding: 8px 14px;
    background: #fff;
    border-radius: 8px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    box-sizing: border-box;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    overflow-wrap: anywhere;
    word-break: break-word;
    hyphens: auto;
}

.math-eq-pill--left {
    border: 2px solid #0d9488;
}

.math-eq-pill--right {
    border: 2px solid #94a3b8;
}

.math-eq-input {
    width: 100%;
    min-height: 120px;
    padding: 12px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-family: ui-monospace, monospace;
    font-size: 0.95rem;
}

/* Toasts */
.toast-host {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
    max-width: min(380px, calc(100vw - 48px));
}

.toast {
    padding: 13px 18px;
    border-radius: var(--radius-md);
    font-size: 0.8125rem;
    font-weight: 600;
    letter-spacing: -0.01em;
    line-height: 1.4;
    box-shadow: 0 12px 40px rgba(15, 23, 42, 0.14);
    opacity: 0;
    transform: translateY(10px);
    transition: opacity 0.28s ease, transform 0.28s cubic-bezier(0.22, 1, 0.36, 1);
    pointer-events: auto;
}

.toast--visible {
    opacity: 1;
    transform: translateY(0);
}

.toast--success {
    background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.toast--info {
    background: #fff;
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-md);
}

.toast--warning {
    background: #fef3c7;
    color: #92400e;
    border: 1px solid #fcd34d;
}

.toast--error {
    background: #fef2f2;
    color: #b91c1c;
    border: 1px solid #fecaca;
}

.hidden {
    display: none !important;
}

/* Di?logos de aplicaci?n (confirmar / texto ? integrados con la UI) */
#app-dialog-host {
    position: relative;
    z-index: 150000;
}

.app-dialog-layer {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.app-dialog-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.48);
    backdrop-filter: blur(3px);
}

.app-dialog-panel {
    position: relative;
    z-index: 1;
    width: min(440px, 100%);
    max-height: min(88vh, 100%);
    overflow-y: auto;
    background: var(--surface-color);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-md);
    padding: 20px 22px 18px;
}

.app-dialog-title {
    font-size: 1.05rem;
    font-weight: 700;
    margin: 0 0 10px;
    color: var(--text-primary);
    letter-spacing: -0.02em;
}

.app-dialog-message {
    margin: 0 0 16px;
    font-size: 0.875rem;
    line-height: 1.5;
    color: var(--text-secondary);
}

.app-dialog-message--multiline {
    line-height: 1.55;
}

.app-dialog-field-label {
    display: block;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.app-dialog-input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    margin-bottom: 18px;
    font-family: inherit;
    box-sizing: border-box;
}

.app-dialog-input:focus {
    outline: none;
    box-shadow: var(--focus-ring);
    border-color: var(--primary-color);
}

.app-dialog-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: flex-end;
}

.app-dialog-panel--rich {
    max-height: min(90vh, 100%);
}

.app-dialog-rich-body {
    margin-bottom: 14px;
    max-height: min(62vh, 560px);
    overflow-y: auto;
    padding-right: 4px;
}

.teacher-resolution-section {
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 12px;
    margin-bottom: 10px;
    background: #f8fafc;
}

.teacher-resolution-section h4 {
    margin: 0 0 8px;
    font-size: 0.9rem;
    color: var(--text-primary);
}

.teacher-resolution-section p,
.teacher-resolution-section li {
    font-size: 0.84rem;
    line-height: 1.5;
    color: var(--text-secondary);
}

.teacher-resolution-question + .teacher-resolution-question {
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px dashed var(--border-color);
}

.teacher-resolution-answer {
    color: #0f766e;
}

.teacher-resolution-switch-bar {
    display: inline-flex;
    gap: 6px;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 4px;
    background: #f8fafc;
    margin-bottom: 10px;
}

.teacher-switch-btn {
    border: 0;
    background: transparent;
    color: var(--text-secondary);
    padding: 7px 12px;
    border-radius: 8px;
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
}

.teacher-switch-btn:hover {
    background: #e2e8f0;
}

.teacher-switch-btn.is-active {
    background: #1d4ed8;
    color: #fff;
}

.teacher-resolution-view {
    display: none;
}

.teacher-resolution-view.is-active {
    display: block;
}

.teacher-student-preview {
    border: 1px solid #dbeafe;
    background: #f8fbff;
    border-radius: 8px;
    padding: 10px;
    margin-bottom: 10px;
}

.teacher-student-preview-title {
    margin: 0 0 8px;
    font-size: 0.8rem;
    font-weight: 700;
    color: #1d4ed8;
}

.teacher-student-preview-options {
    display: grid;
    gap: 6px;
}

.teacher-student-preview-option {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.84rem;
    color: var(--text-primary);
}

.teacher-student-preview-text {
    font-size: 0.86rem;
    line-height: 1.5;
    color: var(--text-primary);
}

.teacher-student-preview-step {
    display: grid;
    grid-template-columns: auto 1fr 130px;
    gap: 8px;
    align-items: center;
    margin-bottom: 6px;
}

.teacher-student-preview-num {
    font-size: 0.82rem;
    font-weight: 700;
    color: #0f172a;
}

.teacher-student-preview-step input {
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 6px 8px;
    font-size: 0.8rem;
    background: #fff;
}

.book-quiz-context {
    border: 1px solid #dbeafe;
    background: #f8fbff;
    border-radius: 10px;
    padding: 10px 12px;
    margin-bottom: 10px;
    font-size: 0.86rem;
    line-height: 1.5;
}

.book-quiz-context table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 8px;
}

.book-quiz-context th,
.book-quiz-context td {
    border: 1px solid #cbd5e1;
    padding: 6px 8px;
    text-align: left;
}

.quiz-mc-context-tools {
    margin: 8px 0 12px;
    padding: 10px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: #f8fafc;
}

.quiz-mc-table-builder {
    display: flex;
    gap: 10px;
    align-items: end;
    flex-wrap: wrap;
}

.quiz-mc-table-builder label {
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.quiz-mc-table-builder input {
    width: 84px;
    padding: 6px 8px;
    border-radius: 6px;
    border: 1px solid var(--border-color);
    font-size: 0.85rem;
}

.quiz-mc-table-builder select {
    min-width: 220px;
    padding: 6px 8px;
    border-radius: 6px;
    border: 1px solid var(--border-color);
    font-size: 0.85rem;
    background: #fff;
}

.props-teacher-guide-input,
.props-quiz-distractors-input {
    width: 100%;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 10px 12px;
    font: inherit;
    font-size: 0.84rem;
    line-height: 1.45;
    resize: vertical;
    box-sizing: border-box;
}

.props-teacher-guide-input:focus,
.props-quiz-distractors-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: var(--focus-ring);
}

/* Panel de ayuda (Ctrl+/) */
.help-overlay {
    position: fixed;
    inset: 0;
    z-index: 10050;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: rgba(15, 23, 42, 0.45);
    backdrop-filter: blur(4px);
}

.help-overlay.is-open {
    display: flex;
}

.help-dialog {
    width: 100%;
    max-width: 520px;
    max-height: min(86vh, 640px);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    background: var(--surface-color);
    border-radius: var(--radius-lg);
    box-shadow: 0 24px 64px rgba(15, 23, 42, 0.2);
    border: 1px solid var(--border-color);
}

.help-dialog-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 16px 18px;
    border-bottom: 1px solid var(--border-color);
    background: linear-gradient(180deg, #fafbfc 0%, #ffffff 100%);
    flex-shrink: 0;
}

.help-dialog-title {
    font-size: 1.0625rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--text-primary);
}

.help-dialog-body {
    padding: 16px 18px 20px;
    overflow-y: auto;
    font-size: 0.875rem;
    line-height: 1.5;
    color: var(--text-primary);
}

.help-lead {
    margin-bottom: 14px;
    color: var(--text-secondary);
    font-size: 0.8125rem;
}

.help-shortcuts {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8125rem;
    margin-bottom: 18px;
}

.help-shortcuts th,
.help-shortcuts td {
    text-align: left;
    padding: 8px 10px;
    border-bottom: 1px solid var(--border-color);
    vertical-align: top;
}

.help-shortcuts th {
    font-weight: 700;
    color: var(--text-secondary);
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.help-kbd {
    display: inline-block;
    padding: 2px 7px;
    font-family: ui-monospace, 'Cascadia Code', monospace;
    font-size: 0.75rem;
    font-weight: 600;
    background: var(--surface-subtle);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    box-shadow: 0 1px 0 rgba(15, 23, 42, 0.06);
    color: var(--text-primary);
}

.help-kbd-plus {
    margin: 0 2px;
    color: var(--text-secondary);
    font-weight: 500;
}

.help-mac-hint {
    display: block;
    margin-top: 4px;
    font-size: 0.75rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.help-section-title {
    font-size: 0.8125rem;
    font-weight: 700;
    margin: 4px 0 8px;
    color: var(--text-primary);
}

.help-tips {
    padding-left: 1.15rem;
    margin: 0;
    color: var(--text-secondary);
    font-size: 0.8125rem;
}

.help-tips li {
    margin-bottom: 8px;
}

.help-tips li strong {
    color: var(--text-primary);
}

.help-prose-muted {
    font-size: 0.8125rem;
    color: var(--text-secondary);
    line-height: 1.52;
    margin: 0 0 12px;
}

.help-roadmap {
    font-size: 0.78rem;
    color: var(--text-secondary);
    line-height: 1.55;
    margin: 0 0 4px;
    padding: 10px 12px;
    background: var(--surface-subtle);
    border-radius: 8px;
    border-left: 3px solid #c7d2fe;
}

.help-close-btn {
    flex-shrink: 0;
}

/* Cabecera compacta: pantallas estrechas o bajas */
@media (max-width: 920px) {
    .editor-header {
        height: auto;
        min-height: 58px;
        flex-direction: column;
        align-items: stretch;
        padding: 12px 16px;
        gap: 12px;
    }

    .header-left {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }

    .header-divider {
        display: none;
    }

    .header-title-wrap {
        max-width: 100%;
        width: 100%;
    }

    .header-right {
        width: 100%;
        justify-content: space-between;
        flex-wrap: wrap;
        gap: 8px;
    }

    .header-actions-edit {
        flex-wrap: wrap;
        justify-content: flex-end;
    }
}

@media (max-height: 680px) {
    .editor-header {
        height: auto;
        min-height: 52px;
        padding-top: 8px;
        padding-bottom: 8px;
    }

    .brand-tagline {
        display: none;
    }
}

/* ========================================================= */
/* PREMIUM UI OVERRIDES (Llevando GenLibros al Siguiente Nivel) */
/* ========================================================= */

:root {
    --primary-color: #5b21b6; /* Un p?rpura/?ndigo m?s vibrante y premium */
    --primary-hover: #4c1d95;
    --primary-muted: #f5f3ff;
    --primary-muted-hover: #ede9fe;
    --surface-color: rgba(255, 255, 255, 0.7);
    --surface-subtle: rgba(248, 249, 251, 0.6);
    --bg-color: #f1f3f8;
    --shadow-sm: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
    --shadow-md: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -2px rgba(0, 0, 0, 0.04);
}

body {
    font-family: 'Outfit', system-ui, -apple-system, sans-serif;
    background: linear-gradient(135deg, #fdfbfb 0%, #ebedee 100%);
}

/* Glassmorphism Header (sin aplicar a la variante minimalista) */
.editor-header:not(.editor-header--minimal) {
    background: rgba(255, 255, 255, 0.65);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.5);
    box-shadow: 0 4px 24px -12px rgba(0, 0, 0, 0.1);
}

/* Glassmorphism Toolbar */
.toolbar {
    background: rgba(253, 254, 255, 0.75);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-right: 1px solid rgba(255, 255, 255, 0.6);
}

/* Canvas Area (Background) */
.canvas-container {
    background: transparent;
}

/* Micro-animations and Premium Buttons */
.btn, .tool-item {
    transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.tool-item {
    background-color: rgba(255, 255, 255, 0.9);
    border: 1px solid rgba(226, 229, 235, 0.8);
    box-shadow: 0 2px 4px rgba(0,0,0,0.02);
}

.tool-item:hover {
    border-color: #c4b5fd;
    box-shadow: 0 6px 14px rgba(91, 33, 182, 0.08);
    transform: translateY(-2px) scale(1.01);
}

.tool-item-icon {
    background: linear-gradient(135deg, var(--primary-muted), #ffffff);
    box-shadow: inset 0 2px 4px rgba(255,255,255,0.5);
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary-color), #7c3aed);
    box-shadow: 0 4px 10px rgba(91, 33, 182, 0.25);
    border: none;
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 14px rgba(91, 33, 182, 0.35);
}

/* Paper effect for the canvas */
.canvas-chrome {
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(8px);
    border: 1px solid rgba(255, 255, 255, 0.9);
}

.canvas-sheet-clip {
    box-shadow: 
        0 0 0 1px rgba(0,0,0,0.03),
        0 14px 28px rgba(0,0,0,0.05),
        0 10px 10px rgba(0,0,0,0.02);
    /* Subtle paper texture using multiple backgrounds */
    background-color: #ffffff;
    background-image: linear-gradient(to right, rgba(0,0,0,0.02) 1px, transparent 1px),
                      linear-gradient(to bottom, rgba(0,0,0,0.02) 1px, transparent 1px);
    background-size: 20px 20px;
    border-radius: 2px;
}

/* Drop Zone Highlight */
.canvas-area.drag-over .canvas-sheet-clip {
    box-shadow: 0 0 0 4px rgba(91, 33, 182, 0.3), 0 20px 40px rgba(91, 33, 182, 0.08);
    transform: scale(1.005);
    transition: all 0.2s ease;
}

.canvas-area.drag-over::after {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    pointer-events: none;
    background: rgba(91, 33, 182, 0.02);
    border-radius: 4px;
    z-index: 10;
}

/* === NEW MULTIDISCIPLINARY BLOCKS CSS === */
.flashcard-scene { perspective: 1000px; width: 100%; max-width: 400px; height: 250px; margin: 1rem auto; }
.flashcard { width: 100%; height: 100%; position: relative; transition: transform 0.6s cubic-bezier(0.4, 0, 0.2, 1); transform-style: preserve-3d; cursor: pointer; }
.flashcard.is-flipped { transform: rotateY(180deg); }
.flashcard-face { position: absolute; width: 100%; height: 100%; -webkit-backface-visibility: hidden; backface-visibility: hidden; display: flex; align-items: center; justify-content: center; font-size: 1.5rem; font-weight: 600; text-align: center; padding: 2rem; border-radius: 16px; box-shadow: 0 8px 32px rgba(0,0,0,0.1); background: rgba(255, 255, 255, 0.7); backdrop-filter: blur(20px); border: 1px solid rgba(255, 255, 255, 0.4); color: #1e293b; }
.flashcard-back { transform: rotateY(180deg); background: linear-gradient(135deg, #1e293b, #0f172a); color: #e2e8f0; border-color: rgba(0,0,0,0); }
.flashcard-controls { display: flex; justify-content: center; align-items: center; gap: 1rem; margin-top: 1.5rem; }
.il-chip { padding: 0.5rem 1rem; background: #f1f5f9; border: 1px solid #cbd5e1; border-radius: 20px; cursor: pointer; transition: all 0.2s ease-in-out; font-weight: 500; color: #334155; user-select: none; }
.il-chip:hover { background: #e2e8f0; }
.il-chip.selected { background: #3b82f6; color: #fff; border-color: #2563eb; box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3); transform: scale(1.05); }
.il-pin-student { position: absolute; transform: translate(-50%, -50%); display: flex; flex-direction: column; align-items: center; cursor: pointer; transition: all 0.2s; }
.il-pin-dot { width: 22px; height: 22px; background: #ef4444; border: 3px solid #fff; border-radius: 50%; box-shadow: 0 0 0 2px rgba(239, 68, 68, 0.5), 0 4px 6px rgba(0,0,0,0.1); animation: il-pulse 2s infinite; transition: background 0.3s, box-shadow 0.3s; }
@keyframes il-pulse { 0% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7); } 70% { box-shadow: 0 0 0 10px rgba(239, 68, 68, 0); } 100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); } }
.il-pin-student.filled .il-pin-dot { background: #3b82f6; animation: none; box-shadow: 0 2px 4px rgba(0,0,0,0.2); }
.il-pin-student.correct .il-pin-dot { background: #10b981; }
.il-pin-student.incorrect .il-pin-dot { background: #f59e0b; }
.il-pin-label { background: rgba(255,255,255,0.95); padding: 2px 8px; border-radius: 12px; font-size: 0.8rem; font-weight: bold; margin-top: 4px; color: #1e293b; box-shadow: 0 4px 10px rgba(0,0,0,0.1); white-space: nowrap; transition: opacity 0.2s; opacity: 0; pointer-events: none; }
.il-pin-student.filled .il-pin-label { opacity: 1; }

/* Banco de ?tems (docente) ? el atributo hidden debe poder ocultar (display:flex gana al [hidden] por defecto). */
.item-bank-dialog--premium {
    width: min(720px, 96vw);
    max-height: min(88vh, 900px);
    display: flex;
    flex-direction: column;
}
.item-bank-dialog--premium .item-bank-head {
    align-items: flex-start;
    gap: 12px;
}
.item-bank-dialog--premium .item-bank-lead {
    margin: 0.35rem 0 0;
    max-width: 52ch;
}
.item-bank-toolbar {
    display: grid;
    grid-template-columns: 1.4fr 1fr 1fr 1fr;
    gap: 10px;
    margin: 0 0 12px;
}
@media (max-width: 720px) {
    .item-bank-toolbar {
        grid-template-columns: 1fr 1fr;
    }
}
.item-bank-filter {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
}
.item-bank-filter-label {
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: #64748b;
}
.item-bank-select {
    cursor: pointer;
}
.item-bank-stats {
    font-size: 0.82rem;
    color: #475569;
    margin: 0 0 10px;
    font-weight: 600;
}
.item-bank-fields--save {
    margin-top: 4px;
}
.item-bank-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}
.item-bank-list {
    flex: 1;
    overflow: auto;
    min-height: 180px;
    max-height: min(42vh, 420px);
}
.item-bank-badge {
    display: inline-block;
    margin-left: 6px;
    padding: 1px 7px;
    border-radius: 999px;
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 0.03em;
    vertical-align: middle;
    text-transform: uppercase;
}
.item-bank-badge--auto {
    background: #e0e7ff;
    color: #3730a3;
}
.props-item-bank-filters {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-bottom: 8px;
}
.props-item-bank-filters .props-item-bank-field:last-child {
    grid-column: 1 / -1;
}
.props-item-bank-filter-materia,
.props-item-bank-filter-grado,
.props-item-bank-filter-q {
    width: 100%;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    padding: 6px 8px;
    font-size: 0.82rem;
    background: #fff;
}
.item-bank-overlay {
    position: fixed;
    inset: 0;
    z-index: 12000;
    background: rgba(15, 23, 42, 0.45);
    padding: 16px;
    box-sizing: border-box;
}
.item-bank-overlay[hidden] {
    display: none !important;
}
.item-bank-overlay:not([hidden]) {
    display: flex;
    align-items: center;
    justify-content: center;
}
.item-bank-dialog {
    width: min(520px, 100%);
    max-height: min(90vh, 720px);
    overflow: auto;
    background: var(--surface-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    padding: 20px 22px;
}
.item-bank-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 10px;
}
.item-bank-title {
    margin: 0;
    font-size: 1.15rem;
    font-weight: 700;
}
.item-bank-lead {
    margin: 0 0 14px;
    font-size: 0.92rem;
    color: var(--text-secondary);
    line-height: 1.45;
}
.item-bank-fields {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 12px;
}
.item-bank-label {
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-primary);
}
.item-bank-input {
    font: inherit;
    padding: 8px 10px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
}
.item-bank-actions {
    margin-bottom: 16px;
}
.item-bank-subtitle {
    margin: 0 0 8px;
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-secondary);
}
.item-bank-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.item-bank-empty {
    padding: 12px;
    border-radius: var(--radius-sm);
    background: var(--surface-subtle);
    color: var(--text-secondary);
    font-size: 0.9rem;
}
.item-bank-row {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    justify-content: space-between;
    gap: 10px;
    padding: 10px 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background: var(--surface-subtle);
}
.item-bank-row-text {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
}
.item-bank-meta {
    font-size: 0.8rem;
    color: var(--text-secondary);
}
.item-bank-row-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}
.props-card--pista {
    margin-top: 12px;
}
.props-pista-input {
    width: 100%;
    margin-top: 8px;
    padding: 8px 10px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font: inherit;
    resize: vertical;
    min-height: 72px;
}

/* ??? STEM: puntos calientes, c?digo ejecutable, f?sica ??? */
.input-grow {
    flex: 1 1 auto;
    min-width: 0;
}

/* Hotspot diagram — imagen a ancho completo, sin huecos laterales */
.hs-viewer {
    position: relative;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

/* Stage en bloque: alto y ancho siguen a la imagen (capa 100% alineada) */
.hs-stage {
    position: relative;
    display: block;
    width: 100%;
    max-width: 100%;
    margin: 0;
    border-radius: 14px;
    overflow: hidden;
    border: 1px solid rgba(148, 163, 184, 0.28);
    background: rgba(15, 23, 42, 0.04);
    box-shadow:
        0 1px 0 rgba(255, 255, 255, 0.85) inset,
        0 12px 32px rgba(15, 23, 42, 0.08);
    line-height: 0;
    box-sizing: border-box;
}

.hs-stage:not(:has(.hs-img[src])) {
    min-height: 120px;
    background:
        radial-gradient(100% 80% at 50% 0%, rgba(99, 102, 241, 0.07), transparent 55%),
        linear-gradient(180deg, #f8fafc 0%, #eef2ff 100%);
}

.hs-img {
    display: block;
    width: 100%;
    max-width: 100%;
    height: auto;
    margin: 0;
    vertical-align: top;
    background: transparent;
}

.hs-layer {
    position: absolute;
    inset: 0;
    pointer-events: none;
}

.hs-hit {
    position: absolute;
    pointer-events: auto;
    border: 2px solid rgba(14, 116, 144, 0.72);
    background:
        radial-gradient(circle at 30% 25%, rgba(255, 255, 255, 0.35), transparent 55%),
        rgba(6, 182, 212, 0.18);
    cursor: pointer;
    padding: 0;
    margin: 0;
    appearance: none;
    -webkit-appearance: none;
    box-shadow:
        0 0 0 1px rgba(255, 255, 255, 0.35) inset,
        0 6px 16px rgba(8, 51, 68, 0.18);
    transition:
        transform 0.18s ease,
        box-shadow 0.18s ease,
        background 0.18s ease,
        border-color 0.18s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #083344;
    font-weight: 700;
    font-size: clamp(0.62rem, 1.35vw, 0.78rem);
    line-height: 1;
    z-index: 3;
    overflow: visible;
}

.hs-hit.hs-shape--circle {
    border-radius: 50%;
}

.hs-hit.hs-shape--square {
    border-radius: 10px;
}

.hs-hit.hs-shape--rect {
    border-radius: 8px;
}

.hs-hit-ring {
    position: absolute;
    inset: -5px;
    border-radius: inherit;
    border: 1.5px solid rgba(34, 211, 238, 0.55);
    opacity: 0.75;
    animation: hs-ring-pulse 2.4s ease-out infinite;
    pointer-events: none;
}

.hs-hit-core {
    position: relative;
    z-index: 1;
    min-width: 1.1em;
    text-align: center;
    text-shadow: 0 1px 0 rgba(255, 255, 255, 0.45);
    pointer-events: none;
}

.hs-hit:hover,
.hs-hit.is-active {
    border-color: rgba(8, 145, 178, 0.95);
    background:
        radial-gradient(circle at 30% 25%, rgba(255, 255, 255, 0.45), transparent 55%),
        rgba(6, 182, 212, 0.32);
    box-shadow:
        0 0 0 1px rgba(255, 255, 255, 0.5) inset,
        0 10px 24px rgba(8, 51, 68, 0.28);
    transform: translate(-50%, -50%) scale(1.04);
    z-index: 5;
}

.hs-hit:focus-visible {
    outline: 2px solid #0e7490;
    outline-offset: 3px;
}

@keyframes hs-ring-pulse {
    0% {
        transform: scale(0.92);
        opacity: 0.85;
    }
    70% {
        transform: scale(1.08);
        opacity: 0.15;
    }
    100% {
        transform: scale(1.12);
        opacity: 0;
    }
}

/* Panel de descripción premium (amplio y elegante) */
.hs-tooltip {
    position: absolute;
    z-index: 12000;
    min-width: min(260px, calc(100% - 20px));
    max-width: min(440px, calc(100% - 20px));
    width: max-content;
    padding: 0;
    border-radius: 16px;
    background:
        linear-gradient(165deg, rgba(15, 23, 42, 0.98) 0%, rgba(8, 47, 73, 0.98) 55%, rgba(12, 74, 110, 0.96) 100%);
    color: #f1f5f9;
    font-size: 0.92rem;
    line-height: 1.55;
    box-shadow:
        0 0 0 1px rgba(125, 211, 252, 0.18) inset,
        0 18px 48px rgba(2, 6, 23, 0.42),
        0 4px 14px rgba(8, 51, 68, 0.25);
    border: 1px solid rgba(125, 211, 252, 0.28);
    pointer-events: none;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    overflow: hidden;
}

.hs-tooltip.is-pinned {
    pointer-events: auto;
}

.hs-tooltip::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 4px;
    background: linear-gradient(180deg, #67e8f9 0%, #0891b2 55%, #0e7490 100%);
}

.hs-tip-card {
    padding: 14px 16px 16px 18px;
    box-sizing: border-box;
}

.hs-tip-top {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}

.hs-tip-index {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.55rem;
    height: 1.55rem;
    padding: 0 6px;
    border-radius: 999px;
    background: linear-gradient(135deg, #22d3ee, #0891b2);
    color: #083344;
    font-size: 0.72rem;
    font-weight: 800;
    letter-spacing: 0.02em;
    box-shadow: 0 2px 8px rgba(6, 182, 212, 0.35);
}

.hs-tip-meta {
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: #7dd3fc;
    opacity: 0.95;
}

.hs-tip-title {
    display: block;
    margin: 0 0 8px;
    font-weight: 700;
    font-size: 1.02rem;
    line-height: 1.3;
    color: #f0f9ff;
    font-family: 'Outfit', system-ui, sans-serif;
    letter-spacing: -0.01em;
}

.hs-tip-desc {
    margin: 0;
    color: #dbeafe;
    font-size: 0.9rem;
    line-height: 1.55;
    white-space: pre-wrap;
    word-break: break-word;
    max-height: min(38vh, 220px);
    overflow-y: auto;
}

/* Compat: markup antiguo (strong + p) */
.hs-tooltip > strong {
    display: block;
    margin: 14px 16px 6px 18px;
    font-weight: 700;
    color: #f0f9ff;
    font-size: 1rem;
}

.hs-tooltip > p {
    margin: 0 16px 14px 18px;
    color: #dbeafe;
}

.hs-uploader-lead {
    font-size: 0.82rem;
    margin: 0 0 10px;
    color: #64748b;
    line-height: 1.45;
}

.hs-upload-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 12px;
}

.hs-shape-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    border-radius: 12px;
    border: 1px solid rgba(14, 116, 144, 0.18);
    background:
        linear-gradient(135deg, rgba(236, 254, 255, 0.9), rgba(240, 249, 255, 0.95));
    margin-bottom: 4px;
}

.hs-shape-toolbar-label {
    font-size: 0.78rem;
    font-weight: 700;
    color: #0e7490;
    margin-right: 4px;
}

.hs-shape-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    border-radius: 999px;
    border: 1px solid rgba(14, 116, 144, 0.22);
    background: #fff;
    color: #155e75;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

.hs-shape-btn:hover {
    border-color: rgba(8, 145, 178, 0.55);
    background: #ecfeff;
}

.hs-shape-btn.is-active {
    background: linear-gradient(135deg, #0891b2, #0e7490);
    border-color: transparent;
    color: #ecfeff;
    box-shadow: 0 4px 12px rgba(8, 145, 178, 0.28);
}

.hs-shape-ico {
    display: inline-block;
    width: 12px;
    height: 12px;
    border: 1.5px solid currentColor;
    opacity: 0.9;
}

.hs-shape-ico--circle {
    border-radius: 50%;
}

.hs-shape-ico--square {
    border-radius: 2px;
}

.hs-shape-ico--rect {
    width: 16px;
    height: 10px;
    border-radius: 2px;
}

/* Formulario modal premium de zona */
.hs-form-overlay {
    position: fixed;
    inset: 0;
    z-index: 20050;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 18px;
    background: rgba(15, 23, 42, 0.48);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    box-sizing: border-box;
}

.hs-form-overlay.hidden,
.hs-form-overlay[hidden] {
    display: none !important;
}

.hs-form-panel {
    width: min(520px, 100%);
    max-height: min(90vh, 720px);
    overflow: auto;
    border-radius: 18px;
    background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
    border: 1px solid rgba(14, 116, 144, 0.18);
    box-shadow: 0 28px 64px rgba(2, 6, 23, 0.28);
}

.hs-form-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    padding: 16px 18px 12px;
    border-bottom: 1px solid #e2e8f0;
}

.hs-form-kicker {
    margin: 0 0 2px;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #0891b2;
}

.hs-form-title {
    margin: 0;
    font-size: 1.1rem;
    color: #0f172a;
    font-family: 'Outfit', system-ui, sans-serif;
}

.hs-form-close {
    border: none;
    background: #f1f5f9;
    width: 32px;
    height: 32px;
    border-radius: 10px;
    font-size: 1.2rem;
    line-height: 1;
    cursor: pointer;
    color: #475569;
}

.hs-form-body {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 14px 18px 8px;
}

.hs-form-label {
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 0.82rem;
    font-weight: 600;
    color: #334155;
}

.hs-form-title-input,
.hs-form-desc-input,
.hs-form-r-input,
.hs-form-w-input,
.hs-form-h-input {
    font: inherit;
    font-weight: 500;
    padding: 9px 11px;
    border-radius: 10px;
    border: 1px solid #cbd5e1;
    background: #fff;
    color: #0f172a;
}

.hs-form-desc-input {
    min-height: 110px;
    resize: vertical;
    line-height: 1.5;
}

.hs-form-shape-field {
    margin: 0;
    padding: 10px 12px;
    border-radius: 12px;
    border: 1px solid #e2e8f0;
    background: #f8fafc;
}

.hs-form-shape-field legend {
    padding: 0 4px;
    font-size: 0.78rem;
    font-weight: 700;
    color: #0e7490;
}

.hs-form-shape-row {
    display: flex;
    flex-wrap: wrap;
    gap: 10px 14px;
}

.hs-form-shape-opt {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.85rem;
    font-weight: 600;
    color: #334155;
    cursor: pointer;
}

.hs-form-size-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
}

.hs-form-size-grid .is-hidden {
    display: none;
}

.hs-form-tip {
    margin: 0;
    font-size: 0.78rem;
    color: #64748b;
    line-height: 1.4;
}

.hs-form-footer {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding: 12px 18px 16px;
    border-top: 1px solid #e2e8f0;
}

@media (max-width: 560px) {
    .hs-form-size-grid {
        grid-template-columns: 1fr;
    }

    .hs-tooltip {
        max-width: calc(100% - 16px);
        min-width: 0;
        width: calc(100% - 16px);
    }
}

.hs-editor {
    display: flex;
    flex-direction: column;
    gap: 12px;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

.hs-url-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
}

.hs-src-input {
    flex: 1 1 200px;
    min-width: 0;
    padding: 8px 10px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font: inherit;
}

.hs-hint {
    margin: 0 0 12px;
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.45;
}

.hs-edit-stage-wrap {
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    border: 1px solid rgba(99, 102, 241, 0.22);
    border-radius: 16px;
    padding: 14px;
    background:
        radial-gradient(120% 90% at 50% 0%, rgba(99, 102, 241, 0.06), transparent 52%),
        linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
    box-shadow: 0 10px 30px rgba(15, 23, 42, 0.05);
}

/* Lienzo de edicion: 100% del ancho del bloque — sin franja blanca lateral */
.hs-edit-stage {
    position: relative;
    display: block;
    width: 100%;
    max-width: 100%;
    margin: 0;
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid rgba(148, 163, 184, 0.32);
    background: #f1f5f9;
    box-shadow: 0 6px 20px rgba(15, 23, 42, 0.06);
    line-height: 0;
    box-sizing: border-box;
}

.hs-edit-stage:not(:has(.hs-edit-img[src])) {
    min-height: 200px;
    background:
        linear-gradient(135deg, rgba(99, 102, 241, 0.04) 0%, transparent 50%),
        repeating-linear-gradient(
            -45deg,
            transparent,
            transparent 10px,
            rgba(148, 163, 184, 0.06) 10px,
            rgba(148, 163, 184, 0.06) 11px
        ),
        #f8fafc;
}

.hs-edit-img {
    display: block;
    width: 100%;
    max-width: 100%;
    height: auto;
    margin: 0;
    vertical-align: top;
    background: transparent;
}

.hs-edit-layer {
    position: absolute;
    inset: 0;
}

/* Maximiza el ancho util del bloque en la hoja */
.canvas-block.block-hotspot-diagram > .block-content {
    padding-left: 4px;
    padding-right: 4px;
}

.hs-edit-hit {
    position: absolute;
    border: 2px dashed rgba(8, 145, 178, 0.75);
    background: rgba(6, 182, 212, 0.14);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: grab;
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
    box-shadow: 0 2px 10px rgba(8, 145, 178, 0.18);
    transition: box-shadow 0.15s ease, background 0.15s ease, border-color 0.15s ease;
    z-index: 2;
    overflow: visible;
}

.hs-edit-hit.hs-shape--circle {
    border-radius: 50%;
}

.hs-edit-hit.hs-shape--square {
    border-radius: 10px;
}

.hs-edit-hit.hs-shape--rect {
    border-radius: 8px;
}

.hs-edit-hit:hover {
    background: rgba(6, 182, 212, 0.24);
    border-color: rgba(14, 116, 144, 0.95);
}

.hs-edit-hit.is-dragging,
.hs-edit-hit.is-resizing {
    cursor: grabbing;
    z-index: 6;
    background: rgba(6, 182, 212, 0.32);
    border-color: #0e7490;
    border-style: solid;
    box-shadow: 0 8px 22px rgba(8, 145, 178, 0.35);
}

.hs-edit-index {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    font-size: 0.7rem;
    font-weight: 800;
    color: #0e7490;
    pointer-events: none;
    opacity: 0.85;
}

.hs-edit-badge {
    position: absolute;
    bottom: calc(100% + 6px);
    left: 50%;
    transform: translateX(-50%);
    margin-bottom: 0;
    padding: 3px 8px;
    border-radius: 6px;
    font-size: 0.7rem;
    font-weight: 600;
    background: linear-gradient(135deg, #0f172a, #155e75);
    color: #ecfeff;
    white-space: nowrap;
    max-width: 160px;
    overflow: hidden;
    text-overflow: ellipsis;
    pointer-events: none;
    box-shadow: 0 4px 12px rgba(8, 51, 68, 0.25);
    border: 1px solid rgba(103, 232, 249, 0.25);
}

.hs-resize-handle {
    position: absolute;
    right: -5px;
    bottom: -5px;
    width: 12px;
    height: 12px;
    border-radius: 3px;
    background: linear-gradient(135deg, #22d3ee, #0e7490);
    border: 1.5px solid #fff;
    box-shadow: 0 2px 6px rgba(8, 51, 68, 0.3);
    cursor: nwse-resize;
    z-index: 4;
    touch-action: none;
}

.hs-del-hotspot {
    position: absolute;
    top: -8px;
    right: -8px;
    z-index: 5;
    cursor: pointer;
    width: 22px;
    height: 22px;
    padding: 0;
    border-radius: 999px;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* Code runner */
.cr-wrap {
    display: flex;
    flex-direction: column;
    gap: 12px;
    border: 1px solid #dbe3ef;
    border-radius: 14px;
    padding: 12px;
    background: linear-gradient(180deg, #f8fbff 0%, #f1f5f9 100%);
    box-shadow: 0 10px 24px rgba(15, 23, 42, 0.06);
}
.cr-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 8px 10px;
    border-radius: 10px;
    border: 1px solid #dbe3ef;
    background: #ffffff;
}
.cr-lang-label {
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
}
.cr-lang-select {
    font: inherit;
    padding: 6px 10px;
    border-radius: var(--radius-sm);
    border: 1px solid #cbd5e1;
    background: #f8fafc;
    min-width: 150px;
}
.cr-editor {
    width: 100%;
    box-sizing: border-box;
    font-family: ui-monospace, 'Cascadia Code', 'Consolas', monospace;
    font-size: 0.875rem;
    line-height: 1.55;
    padding: 14px 16px;
    border-radius: 12px;
    border: 1px solid #1e293b;
    background: #0b1220;
    color: #dbeafe;
    resize: vertical;
    min-height: 210px;
    tab-size: 4;
    box-shadow: inset 0 0 0 1px rgba(148, 163, 184, 0.14);
}
.cr-editor:focus {
    outline: none;
    border-color: #60a5fa;
    box-shadow: 0 0 0 3px rgba(96, 165, 250, 0.25);
}
.cr-actions {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 10px;
}
.cr-actions .btn {
    border-radius: 9px;
    font-weight: 600;
    letter-spacing: 0.01em;
}
.cr-output-host {
    border-radius: 12px;
    border: 1px solid #dbe3ef;
    background: #ffffff;
    padding: 10px 12px;
    box-shadow: 0 6px 16px rgba(15, 23, 42, 0.05);
}
.cr-output-title {
    margin: 0 0 6px;
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #64748b;
}
.cr-output {
    margin: 0;
    white-space: pre-wrap;
    word-break: break-word;
    font-family: ui-monospace, 'Cascadia Code', 'Consolas', monospace;
    font-size: 0.86rem;
    line-height: 1.45;
    color: #0f172a;
    max-height: 240px;
    overflow: auto;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    padding: 10px 12px;
}
.cr-html-host {
    margin-top: 2px;
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid #dbe3ef;
    min-height: 180px;
    background: #fff;
}
.cr-html-frame {
    display: block;
    width: 100%;
    min-height: 240px;
    border: 0;
    background: #fff;
}


/* Physics lab */
.phys-wrap {
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.phys-editor-panel .phys-fields {
    display: flex;
    flex-wrap: wrap;
    gap: 12px 20px;
    margin: 8px 0;
}
.phys-editor-panel label {
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
}
.phys-editor-panel input[type='number'] {
    width: 6rem;
    padding: 6px 8px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
    font: inherit;
}
.phys-canvas-wrap {
    border-radius: var(--radius-md);
    overflow: hidden;
    border: 1px solid var(--border-color);
    max-width: 100%;
}
.phys-canvas {
    display: block;
    width: 100%;
    height: auto;
    max-width: 560px;
}
.phys-controls {
    display: flex;
    flex-direction: column;
    gap: 8px;
    font-size: 0.8rem;
    color: var(--text-secondary);
}
.phys-controls label {
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.phys-controls input[type='range'] {
    width: 100%;
    max-width: 420px;
}
.phys-readout {
    margin: 0;
    font-size: 0.85rem;
    line-height: 1.45;
    color: var(--text-secondary);
}

/* ??? Balanza algebraica ??? */
.eb-wrap {
    display: flex;
    flex-direction: column;
    gap: 14px;
}
.eb-fields {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}
.eb-fields label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
}
.eb-balance {
    position: relative;
    min-height: 120px;
    margin: 8px 0;
}
.eb-beam {
    position: absolute;
    left: 10%;
    right: 10%;
    top: 48px;
    height: 6px;
    background: linear-gradient(90deg, #94a3b8, #cbd5e1);
    border-radius: 3px;
    transform-origin: 50% 50%;
}
.eb-fulcrum {
    position: absolute;
    left: 50%;
    bottom: 0;
    transform: translateX(-50%);
    width: 0;
    height: 0;
    border-left: 16px solid transparent;
    border-right: 16px solid transparent;
    border-bottom: 44px solid #64748b;
}
.eb-pan {
    position: absolute;
    top: 12px;
    width: 42%;
    min-height: 56px;
    padding: 8px;
    border-radius: var(--radius-md);
    border: 2px dashed var(--border-color);
    background: var(--surface-subtle);
    font-size: 0.8rem;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
}
.eb-pan--left {
    left: 2%;
}
.eb-pan--right {
    right: 2%;
}
.eb-equation {
    font-size: 1.15rem;
    font-weight: 600;
    text-align: center;
    margin: 0.5rem 0;
    font-family: ui-monospace, monospace;
}
.eb-eq-eq {
    margin: 0 0.5rem;
    color: var(--primary-color);
}
.eb-btn-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
}
.eb-status {
    font-size: 0.88rem;
    color: var(--text-secondary);
    text-align: center;
}
.eb-ok {
    color: #059669;
}
.eb-chip {
    display: inline-block;
    padding: 4px 8px;
    border-radius: 6px;
    background: var(--surface-color);
    border: 1px solid var(--border-color);
}

/* ??? Decodificador ??? */
.cd-wrap {
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.cd-cipher-box {
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 10px 12px;
    background: var(--surface-subtle);
}
.cd-cipher-text {
    margin: 0;
    white-space: pre-wrap;
    word-break: break-all;
    font-family: ui-monospace, monospace;
    font-size: 0.85rem;
}
.cd-dial-label {
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 0.85rem;
    font-weight: 600;
}
.cd-dial-readout {
    margin: 0 0 8px;
    font-size: 0.8rem;
    color: var(--text-secondary);
}
.cd-input--ok {
    border-color: #10b981 !important;
}
.cd-input--bad {
    border-color: #ef4444 !important;
}
.cd-preview-box {
    font-size: 0.9rem;
}

/* ??? Laberinto bloques ??? */
.mb-wrap {
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.mb-row {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    align-items: flex-start;
}
.mb-grid {
    display: grid;
    gap: 2px;
    background: #334155;
    padding: 4px;
    border-radius: 8px;
    width: fit-content;
}
.mb-cell {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.65rem;
    font-weight: 700;
}
.mb-wall {
    background: #1e293b;
}
.mb-floor {
    background: #f8fafc;
}
.mb-start {
    background: #bbf7d0;
}
.mb-goal {
    background: #fde68a;
}
.mb-robot {
    font-size: 1rem;
}
.mb-palette {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}
.mb-program {
    min-height: 36px;
    padding: 8px;
    border: 1px dashed var(--border-color);
    border-radius: var(--radius-sm);
    background: var(--surface-subtle);
}
.mb-chip {
    display: inline-block;
    margin: 2px;
    padding: 2px 8px;
    border-radius: 6px;
    background: #e0e7ff;
    font-size: 0.75rem;
}
.mb-log {
    font-size: 0.75rem;
    max-height: 120px;
    overflow: auto;
    margin: 8px 0 0;
    padding: 8px;
    background: #0f172a;
    color: #e2e8f0;
    border-radius: 6px;
}

/* ??? Flujograma debug ??? */
.fd-flow {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 10px;
}
.fd-node {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
    padding: 10px 12px;
    border-radius: var(--radius-md);
    border: 2px solid var(--border-color);
    background: var(--surface-color);
    cursor: pointer;
    text-align: left;
    font: inherit;
    width: 100%;
    max-width: 420px;
}
.fd-node--trace {
    border-color: #818cf8;
    background: rgba(129, 140, 248, 0.08);
}
.fd-node--pick {
    outline: 3px solid #6366f1;
    outline-offset: 2px;
}
.fd-node-id {
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--text-secondary);
    text-transform: uppercase;
}
.fd-node-label {
    font-size: 0.9rem;
    color: var(--text-primary);
}
.fd-editor-hint,
.fd-lead,
.fd-trace {
    font-size: 0.88rem;
    line-height: 1.45;
    color: var(--text-secondary);
}

/* ??? Protoboard ??? */
.bb-circuit {
    padding: 12px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    background: var(--surface-subtle);
}
.bb-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
}
.bb-part {
    padding: 10px 14px;
    border-radius: 8px;
    font-weight: 600;
    font-size: 0.85rem;
}
.bb-bat {
    background: #fecaca;
    color: #991b1b;
}
.bb-res-wrap label {
    display: block;
    font-size: 0.7rem;
    margin-bottom: 4px;
}
.bb-wire {
    flex: 0 0 24px;
    height: 4px;
    background: #64748b;
    border-radius: 2px;
}
.bb-led {
    padding: 12px 16px;
    border-radius: 8px;
    background: #1e293b;
    color: #94a3b8;
}
.bb-led--bright {
    background: #fef08a;
    color: #854d0e;
    box-shadow: 0 0 20px rgba(250, 204, 21, 0.7);
}
.bb-led--dim {
    background: #422006;
    color: #a8a29e;
}
.bb-led--burn {
    background: #1c1917;
    color: #57534e;
    text-decoration: line-through;
}
.bb-msg {
    margin: 8px 0 0;
    font-size: 0.85rem;
}

/* ??? Compuertas ??? */
.lg-io {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin: 10px 0;
}
.lg-wire-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin: 12px 0;
}
.lg-out {
    padding: 8px 14px;
    border-radius: 8px;
    font-weight: 700;
    font-family: ui-monospace, monospace;
}
.lg-out--on {
    background: #22c55e;
    color: #052e16;
}
.lg-out--off {
    background: #334155;
    color: #94a3b8;
}
.lg-story-read {
    font-size: 0.92rem;
    line-height: 1.5;
    margin: 0 0 8px;
}
.lg-editor-hint {
    font-size: 0.88rem;
    color: var(--text-secondary);
}
.lg-hint,
.lg-note {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

/* ==========================================================================
   WIDGET: SUMA DE FRACCIONES HETEROG?NEAS (MCM) - MODO ASISTENTE
   ========================================================================== */
:root {
    --mfs-color-1: #10b981;
    --mfs-color-2: #f59e0b;
    --mfs-bg-step: #f8fafc;
    --mfs-border: #e2e8f0;
    --mfs-stepper-size: 32px;
}

.mfs-container {
    padding: 20px;
    background: #fff;
    border-radius: 12px;
    font-family: var(--font-main, sans-serif);
    color: var(--text-primary);
    box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1);
}

.mfs-inputs {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 30px;
    margin-bottom: 25px;
    padding: 20px;
    background: #f1f5f9;
    border-radius: 12px;
}

.mfs-input-group label {
    display: block;
    text-align: center;
    font-weight: 600;
    margin-bottom: 10px;
    font-size: 0.9rem;
    color: #475569;
}

.mfs-fraction-fields {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
}

.mfs-fraction-fields input {
    width: 60px;
    text-align: center;
    border: 2px solid #cbd5e1;
    border-radius: 6px;
    padding: 5px;
    font-size: 1.2rem;
    font-weight: 700;
}

.mfs-fraction-fields .divider {
    width: 50px;
    height: 3px;
    background: #475569;
    border-radius: 2px;
}

.mfs-plus {
    font-size: 2rem;
    font-weight: 800;
    color: #64748b;
}

.mfs-actions {
    text-align: center;
    margin-bottom: 20px;
}

/* Stepper Navigation */
.mfs-stepper {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-bottom: 30px;
    padding: 10px 0;
}

.mfs-step-indicator {
    width: var(--mfs-stepper-size);
    height: var(--mfs-stepper-size);
    border-radius: 50%;
    background: #e2e8f0;
    color: #64748b;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.25s ease;
    border: 2px solid transparent;
}

.mfs-step-indicator.is-active {
    background: var(--accent-color);
    color: #fff;
    transform: scale(1.15);
    box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.2);
}

.mfs-step-indicator.is-completed {
    background: #10b981;
    color: #fff;
}

.mfs-step-line {
    width: 30px;
    height: 2px;
    background: #e2e8f0;
}

/* Infograf?a Content */
.mfs-steps-container {
    min-height: 250px;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.mfs-step-content {
    background: var(--mfs-bg-step);
    padding: 25px;
    border-radius: 12px;
    border: 1px solid var(--mfs-border);
}

.mfs-fade-in {
    animation: mfsFadeIn 0.35s ease-out;
}

@keyframes mfsFadeIn {
    from { opacity: 0; transform: scale(0.98); }
    to { opacity: 1; transform: scale(1); }
}

.mfs-step-title {
    margin: 0 0 20px 0;
    font-size: 1rem;
    font-weight: 700;
    color: #1e293b;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-bottom: 2px solid #e2e8f0;
    padding-bottom: 10px;
    text-align: center;
}

.mfs-grid-row {
    display: flex;
    justify-content: space-around;
    gap: 20px;
    flex-wrap: wrap;
}

.mfs-grid-box {
    flex: 1;
    min-width: 180px;
    background: #fff;
    padding: 15px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.mfs-label {
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 15px;
    font-weight: 600;
    font-size: 1.1rem;
    min-height: 2.5rem;
}

.mfs-visual-grid {
    height: 60px;
    border: 2px solid #334155;
    border-radius: 4px;
    overflow: hidden;
    gap: 2px;
    background: #f1f5f9;
    grid-auto-rows: 1fr;
}

.mfs-grid-cell {
    border: 1px solid rgba(0,0,0,0.1);
    transition: background-color 0.3s ease;
    height: 100%;
}

.mfs-grid-cell.is-shaded {
    box-shadow: inset 0 0 10px rgba(0,0,0,0.1);
}

/* Paso 2: LCM */
.mfs-lcm-result {
    text-align: center;
}

.mfs-lcm-formula {
    font-size: 1.6rem;
    font-weight: 800;
    color: #1e293b;
    margin-bottom: 10px;
}

.mfs-step-desc {
    font-size: 1rem;
    color: #64748b;
    text-align: center;
}

/* Paso 3: Equiv */
.mfs-equiv-row {
    display: flex;
    flex-direction: column;
    gap: 15px;
    align-items: center;
}

.mfs-equiv-calc {
    font-size: 1.25rem;
    background: #fff;
    padding: 12px 24px;
    border-radius: 8px;
    border: 1px dashed #cbd5e1;
    min-height: 3.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Paso 5: Final */
.mfs-final-result-box {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
}

.mfs-visual-final {
    width: 100%;
    max-width: 500px;
    height: 80px;
}

.mfs-final-equation {
    font-size: 1.8rem;
    font-weight: 800;
    min-height: 3.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.mfs-final-label {
    font-size: 1.1rem;
    background: var(--accent-light, #eef2ff);
    padding: 8px 16px;
    border-radius: 20px;
    color: var(--accent-color);
}

/* Navigation Controls */
.mfs-nav-controls {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 25px;
    padding-top: 20px;
    border-top: 1px solid #e2e8f0;
}

.mfs-step-text {
    font-weight: 600;
    color: #64748b;
    font-size: 0.9rem;
}

.mfs-nav-controls .btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
}

.mfs-nav-controls .btn:disabled {
    opacity: 0.3;
    pointer-events: none;
}

/* Legend */
.mfs-footer {
    margin-top: 20px;
    padding-top: 20px;
}

.mfs-legend {
    display: flex;
    justify-content: center;
    gap: 25px;
    margin-bottom: 10px;
}

.mfs-legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
    font-weight: 500;
}

.mfs-legend-item .swatch {
    width: 14px;
    height: 14px;
    border-radius: 3px;
}

.mfs-legend-item .swatch.s1 { background: var(--mfs-color-1); }
.mfs-legend-item .swatch.s2 { background: var(--mfs-color-2); }

.mfs-instruction {
    text-align: center;
    font-style: italic;
    font-size: 0.85rem;
    color: #94a3b8;
    max-width: 500px;
    margin: 0 auto;
}


/* ==========================================================================
   WIDGET: SIMULADOR DE MCM (M?ltiplos)
   ========================================================================== */
.mlcm-container {
    padding: 20px;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1);
}

.mlcm-input-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 20px;
    margin-bottom: 20px;
    background: #f8fafc;
    padding: 15px;
    border-radius: 8px;
}

.mlcm-field {
    text-align: center;
}

.mlcm-field label {
    display: block;
    font-size: 0.8rem;
    font-weight: 600;
    color: #64748b;
    margin-bottom: 5px;
}

.mlcm-field input {
    width: 60px;
    text-align: center;
    font-size: 1.2rem;
    font-weight: 700;
    border: 2px solid #cbd5e1;
    border-radius: 6px;
    padding: 4px;
}

.mlcm-vs {
    font-weight: 800;
    color: #94a3b8;
    margin-top: 15px;
}

.mlcm-visual-section {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin: 20px 0;
}

.mlcm-multiples-row {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.mlcm-row-label {
    font-weight: 700;
    color: #1e293b;
    font-size: 0.95rem;
}

.mlcm-bubbles {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.mlcm-bubble {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: #f1f5f9;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.9rem;
    color: #475569;
    border: 1px solid #e2e8f0;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.mlcm-bubble.is-common {
    background: #fef9c3;
    border-color: #fde047;
    color: #854d0e;
    transform: scale(1.05);
}

.mlcm-bubble.is-lcm {
    background: #10b981;
    color: #fff;
    border-color: #059669;
    box-shadow: 0 0 0 4px rgba(16, 185, 129, 0.2);
    transform: scale(1.15);
}

/* Result Card */
.mlcm-result-card {
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
    border-radius: 12px;
    padding: 20px;
    text-align: center;
    margin-top: 25px;
}

.mlcm-common-found {
    color: #166534;
    font-size: 1rem;
    margin-bottom: 15px;
}

.mlcm-final-formula {
    font-size: 1.8rem;
    font-weight: 800;
    color: #064e3b;
}


/* ==========================================================================
   WIDGET: CUADRO DE PUNNETT (BIOLOG?A)
   ========================================================================== */
:root {
    --punnett-dom-color: #ef4444; /* Rojo */
    --punnett-rec-color: #e5e7eb; /* Blanco (Gris muy claro) */
    --punnett-border: #cbd5e1;
    --punnett-bg-header: #f0fdf4; /* Verde suave */
}

.punnett-container {
    padding: 20px;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 4px 6px -1px var(--border-color);
}

.punnett-controls {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-bottom: 25px;
    padding: 15px;
    background: var(--punnett-bg-header);
    border-radius: 8px;
}

.punnett-field label {
    display: block;
    font-size: 0.85rem;
    font-weight: 700;
    color: #166534;
    margin-bottom: 8px;
}

.punnett-field select {
    padding: 6px 10px;
    border-radius: 6px;
    border: 1px solid var(--punnett-border);
    font-family: inherit;
}

.punnett-grid-wrapper {
    display: flex;
    justify-content: center;
    margin-bottom: 30px;
}

.punnett-table {
    border-collapse: collapse;
    width: 300px;
    height: 300px;
}

.punnett-table th, .punnett-table td {
    width: 100px;
    height: 100px;
    border: 2px solid var(--punnett-border);
    text-align: center;
    vertical-align: middle;
}

.punnett-table th {
    background: #f8fafc;
    font-size: 1.4rem;
    font-weight: 800;
    color: #475569;
}

.punnett-corner {
    border: none !important;
    background: transparent !important;
}

.punnett-cell {
    background: #fff;
    position: relative;
    padding: 10px;
}

.punnett-genotype {
    display: block;
    font-size: 1.5rem;
    font-weight: 800;
    margin-bottom: 5px;
}

.punnett-phenotype-icon {
    display: flex;
    justify-content: center;
    align-items: center;
}

.punnett-results {
    display: flex;
    gap: 20px;
}

.punnett-res-box {
    flex: 1;
    background: #f9fafb;
    padding: 15px;
    border-radius: 10px;
}

.punnett-res-box h5 {
    margin-bottom: 12px;
    color: #334155;
    font-weight: 700;
}

.punnett-res-box ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.punnett-res-box li {
    font-size: 0.95rem;
    margin-bottom: 6px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
}
.dot.dom { background: var(--punnett-dom-color); border: 1px solid rgba(0,0,0,0.1); }
.dot.rec { background: #fff; border: 1px solid #cbd5e1; }


/* ==========================================================================
   WIDGET: REDES TR?FICAS (BIOLOG?A)
   ========================================================================== */
.foodweb-container {
    padding: 20px;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 4px 6px -1px rgba(0,0,0,0.1);
}

.foodweb-diagram {
    display: flex;
    justify-content: space-around;
    align-items: center;
    background: #f8fafc;
    padding: 30px 10px;
    border-radius: 15px;
    margin-bottom: 25px;
    flex-wrap: wrap;
    gap: 15px;
}

.foodweb-node {
    text-align: center;
    width: 100px;
    transition: opacity 0.5s ease;
}

.node-icon {
    font-size: 2.5rem;
    margin-bottom: 5px;
}

.node-label {
    font-size: 0.8rem;
    font-weight: 700;
    color: #475569;
    text-transform: uppercase;
}

.node-pop {
    font-size: 1.2rem;
    font-weight: 800;
    color: var(--accent-color);
}

.node-plants .node-pop { color: #22c55e; }
.node-rabbits .node-pop { color: #eab308; }
.node-wolves .node-pop { color: #ef4444; }

.foodweb-arrow {
    font-size: 1.5rem;
    color: #cbd5e1;
}

.foodweb-controls {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    margin-bottom: 25px;
}

.btn-event {
    padding: 10px;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    background: #fff;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    text-align: left;
}

.btn-event:hover {
    background: #f1f5f9;
    border-color: #cbd5e1;
}

.btn-reset {
    grid-column: span 2;
    text-align: center;
    background: #f8fafc;
}

.foodweb-graph-container {
    background: #1e293b;
    padding: 15px;
    border-radius: 8px;
    position: relative;
}

.foodweb-svg-graph {
    width: 100%;
    height: 150px;
    display: block;
}

.graph-legend {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin-top: 10px;
    font-size: 0.75rem;
    font-weight: 600;
}

.invasive-container {
    display: flex;
    align-items: center;
    gap: 10px;
}


/* Corregir contraste del bot?n de simulaci?n */
.foodweb-controls .btn-primary.btn-toggle-sim {
    background-color: #166534; /* Verde oscuro Biolog?a */
    color: #ffffff !important;
    border: none;
    padding: 10px 20px;
    box-shadow: 0 4px 6px -1px rgba(22, 101, 52, 0.4);
}

.foodweb-controls .btn-primary.btn-toggle-sim:hover {
    background-color: #15803d;
    transform: translateY(-1px);
}

.foodweb-controls .btn-primary.btn-toggle-sim i {
    margin-right: 8px;
    vertical-align: middle;
}

/* Estado cuando ya est? corriendo */
.foodweb-controls .btn-primary.btn-toggle-sim.is-running {
    background-color: #991b1b; /* Rojo para pausar */
    box-shadow: 0 4px 6px -1px rgba(153, 27, 27, 0.4);
}


/* Estilos para los Sliders de Poblaci?n (Redes Tr?ficas) */
.pop-slider {
    -webkit-appearance: none;
    width: 100%;
    height: 4px;
    border-radius: 5px;
    background: #cbd5e1;
    outline: none;
    margin-top: 10px;
}

.pop-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    cursor: pointer;
    border: 2px solid white;
}

.node-plants .pop-slider::-webkit-slider-thumb { background: #22c55e; }
.node-rabbits .pop-slider::-webkit-slider-thumb { background: #eab308; }
.node-wolves .pop-slider::-webkit-slider-thumb { background: #ef4444; }
.node-invasive .pop-slider::-webkit-slider-thumb { background: #a855f7; }

.pop-slider::-moz-range-thumb {
    width: 14px;
    height: 14px;
    border: 2px solid white;
    border-radius: 50%;
    cursor: pointer;
}

.node-plants .pop-slider::-moz-range-thumb { background: #22c55e; }
.node-rabbits .pop-slider::-moz-range-thumb { background: #eab308; }
.node-wolves .pop-slider::-moz-range-thumb { background: #ef4444; }
.node-invasive .pop-slider::-moz-range-thumb { background: #a855f7; }


/* ==========================================================================
   WIDGETS: ENCABEZADOS Y DESCRIPCIONES
   ========================================================================== */
.widget-header {
    border-left: 5px solid var(--accent-color);
    background: #f8fafc;
    padding: 12px 18px;
    margin-bottom: 20px;
    border-radius: 4px 8px 8px 4px;
}

.widget-header.math { border-left-color: #3b82f6; }
.widget-header.bio { border-left-color: #22c55e; }
.widget-header.stem { border-left-color: #6366f1; }

.widget-title {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1.1rem;
    font-weight: 800;
    color: #1e293b;
    margin-bottom: 4px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.widget-title i {
    font-size: 1rem;
    color: var(--accent-color);
}

.widget-description {
    font-size: 0.9rem;
    line-height: 1.5;
    color: #64748b;
    font-weight: 500;
}


/* ==========================================================================
   WIDGET: LABORATORIO DE FOTOS?NTESIS
   ========================================================================== */
.photo-container { padding: 20px; background: white; border-radius: 12px; }

.photo-scene {
    height: 250px;
    background: linear-gradient(to bottom, #f0f9ff, #e0f2fe);
    border-radius: 12px;
    position: relative;
    overflow: hidden;
    margin-bottom: 20px;
    border: 1px solid #bae6fd;
}

.light-rays {
    position: absolute;
    top: -50px; left: -50px;
    width: 200px; height: 300px;
    background: radial-gradient(circle, rgba(254,240,138,0.5) 0%, transparent 70%);
    filter: blur(20px);
    transition: opacity 0.5s;
    pointer-events: none;
}

.beaker {
    position: absolute;
    bottom: 20px; left: 50%;
    transform: translateX(-50%);
    width: 120px; height: 160px;
    border: 3px solid rgba(255,255,255,0.8);
    border-top: none;
    border-radius: 0 0 10px 10px;
    background: rgba(186,230,253,0.3);
}

.water-level {
    position: absolute;
    bottom: 0; width: 100%; height: 80%;
    background: rgba(56,189,248,0.3);
}

.test-tube {
    position: absolute;
    top: -40px; left: 50%;
    transform: translateX(-50%);
    width: 30px; height: 140px;
    border: 2px solid white;
    border-radius: 0 0 15px 15px;
    background: rgba(255,255,255,0.2);
}

.oxygen-gas {
    position: absolute;
    top: 0; width: 100%; height: 0;
    background: rgba(255,255,255,0.4);
    transition: height 0.5s;
}

.photo-bubble {
    position: absolute;
    background: white;
    border-radius: 50%;
    opacity: 0.6;
    pointer-events: none;
}

.photo-controls {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 15px;
}

.btn-toggle-photo.is-running { background: #991b1b; color: white; }

/* ==========================================================================
   WIDGET: MICROSCOPIO VIRTUAL
   ========================================================================== */
.micro-container { display: flex; gap: 20px; padding: 20px; background: #1e293b; border-radius: 15px; color: white; }

.micro-view {
    flex: 1;
    aspect-ratio: 1;
    background: black;
    border-radius: 50%;
    border: 10px solid #475569;
    position: relative;
    overflow: hidden;
    box-shadow: inset 0 0 50px rgba(0,0,0,1);
}

.micro-ocular {
    width: 100%; height: 100%;
    display: flex; justify-content: center; align-items: center;
}

.micro-slide-container { width: 100%; height: 100%; transition: filter 0.2s ease; }

.micro-slide-content { position: relative; width: 100%; height: 100%; transition: transform 0.1s linear; }

.micro-canvas { width: 100%; height: 100%; display: block; }

.micro-vignette {
    position: absolute; inset: 0;
    background: radial-gradient(circle, transparent 50%, rgba(0,0,0,0.8) 100%);
    pointer-events: none;
}

.micro-panel { width: 200px; display: flex; flex-direction: column; gap: 15px; }

.micro-group label { font-size: 0.75rem; color: #94a3b8; display: block; margin-bottom: 5px; }

.micro-group select, .micro-group input[type=range] { width: 100%; background: #334151; color: white; border: none; border-radius: 4px; padding: 5px; }

.micro-zoom-btns { display: flex; gap: 5px; }
.micro-zoom-btns .btn { flex: 1; padding: 5px; font-size: 0.8rem; background: #475569; border: none; color: white; cursor: pointer; }
.micro-zoom-btns .btn:hover { background: #64748b; }

.micro-joystick { display: flex; flex-direction: column; align-items: center; gap: 5px; }
.joy-mid { display: flex; gap: 20px; }
.btn-joy { width: 30px; height: 30px; background: #475569; border: none; border-radius: 4px; color: white; cursor: pointer; }

.micro-hotspot {
    position: absolute;
    padding: 2px 8px;
    background: rgba(255,255,255,0.9);
    color: #1e293b;
    border-radius: 4px;
    font-size: 10px;
    font-weight: 800;
    pointer-events: none;
    opacity: 0;
    transform: translate(-50%, -50%);
    transition: opacity 0.3s;
}
.micro-hotspot.visible { opacity: 1; }


/* ==========================================================================
   WIDGET: EXPLORADOR DE GEOMETR?A
   ========================================================================== */
.geo-container { display: flex; gap: 20px; padding: 20px; background: white; border-radius: 12px; }

.geo-workspace {
    flex: 2;
    background: #f8fafc;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    position: relative;
    touch-action: none; /* Prevenir scroll al arrastrar en tablets */
}

.geo-svg { width: 100%; height: auto; cursor: crosshair; }

.geo-handle {
    fill: white;
    stroke: #3b82f6;
    stroke-width: 2px;
    cursor: grab;
    transition: r 0.2s, fill 0.2s;
}

.geo-handle:hover { r: 10; fill: #dbeafe; }
.geo-handle:active { cursor: grabbing; fill: #3b82f6; }

.geo-panel { flex: 1; display: flex; flex-direction: column; gap: 20px; }

.geo-toggle-group { display: flex; gap: 5px; }

.geo-stats {
    background: #eff6ff;
    padding: 15px;
    border-radius: 10px;
    border: 1px solid #bfdbfe;
}

.geo-stat-item { display: flex; justify-content: space-between; margin-bottom: 8px; font-weight: 700; }
.geo-stat-item .value { color: #2563eb; }

.geo-formula {
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px dashed #bfdbfe;
    font-size: 0.85rem;
    color: #475569;
    line-height: 1.6;
    font-family: monospace;
}


/* ==========================================================================
   WIDGET: GR?FICOS ESTAD?STICOS
   ========================================================================== */
.charts-container { display: flex; gap: 20px; padding: 20px; background: white; border-radius: 12px; }

.charts-table { width: 100%; border-collapse: collapse; margin-bottom: 10px; font-size: 0.85rem; }
.charts-table th { text-align: left; padding: 8px; border-bottom: 2px solid #e2e8f0; }
.charts-table td { padding: 5px; }
.charts-table input { width: 100%; border: 1px solid #cbd5e1; border-radius: 4px; padding: 4px; font-size: 0.85rem; }

.charts-visual { flex: 2; display: flex; flex-direction: column; align-items: center; }
.charts-svg { width: 100%; max-width: 400px; height: auto; }

.charts-legend { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 20px; font-size: 0.8rem; }
.legend-item { display: flex; align-items: center; gap: 5px; }
.legend-color { width: 12px; height: 12px; border-radius: 2px; }

/* ==========================================================================
   WIDGET: PLANO CARTESIANO
   ========================================================================== */
.cartesian-container { display: flex; gap: 20px; padding: 20px; background: white; border-radius: 12px; }

.cartesian-workspace { flex: 2; background: #f8fafc; border: 2px solid #e2e8f0; border-radius: 8px; }

.cartesian-svg { width: 100%; height: auto; }

.cartesian-panel { flex: 1; display: flex; flex-direction: column; gap: 15px; }

.cartesian-input-row { display: flex; gap: 5px; }
.cartesian-input-row input { width: 50px; padding: 5px; border: 1px solid #cbd5e1; border-radius: 4px; }

.cartesian-list { font-size: 0.85rem; color: #475569; }
.points-ul { list-style: none; padding: 0; margin-top: 5px; max-height: 150px; overflow-y: auto; }

/* ==========================================================================
   WIDGET: LABORATORIO DE PROBABILIDAD
   ========================================================================== */
.prob-container { display: flex; gap: 30px; padding: 20px; background: white; border-radius: 12px; }

.prob-vis { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 20px; }

.wheel-box { position: relative; width: 220px; height: 220px; }
.wheel-pointer { 
    position: absolute; top: -10px; left: 50%; transform: translateX(-50%); 
    font-size: 24px; color: #ef4444; z-index: 10; text-shadow: 0 2px 4px rgba(0,0,0,0.2);
}
.prob-wheel { width: 100%; height: 100%; filter: drop-shadow(0 4px 6px rgba(0,0,0,0.1)); }

.prob-stats { flex: 1.5; }
.prob-table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
.prob-table th { text-align: left; padding: 8px; border-bottom: 3px solid #f1f5f9; color: #64748b; }
.prob-table td { padding: 10px 8px; border-bottom: 1px solid #f1f5f9; }

.prob-chip { display: inline-block; width: 12px; height: 12px; border-radius: 50%; border: 1px solid rgba(0,0,0,0.1); }


/* ==========================================================================
   TOOLBAR RESTORATION (Premium Vertical Stack)
   ========================================================================== */
.toolbar {
    width: 280px !important;
    min-width: 280px !important;
    max-width: 280px !important;
    display: flex !important;
    flex-direction: column !important;
    background: #f8fafc;
    border-right: 1px solid var(--border-color);
}

.tool-group {
    display: block !important;
    width: 100% !important;
    margin-bottom: 12px !important;
    padding: 0 !important;
}


/* ==========================================================================
   Widgets premium: GEN-BIT (rob?tica), diagrama de fuerzas, pasos algebraicos
   (visor + editor ? tarjeta clara, laboratorio oscuro solo en el banco de pruebas)
   ========================================================================== */

.robotics-container,
.physics-force-container,
.algebra-steps-container {
    --gl-widget-font-math: var(--book-serif, 'Literata', Georgia, 'Times New Roman', serif);
    --gl-widget-radius: 14px;
    border-radius: var(--gl-widget-radius);
    border: 1px solid rgba(15, 23, 42, 0.08);
    background: #ffffff;
    box-shadow: var(--shadow-sm);
    color: var(--text-primary);
}

/* ??? Rob?tica GEN-BIT ??? */
.robotics-container {
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding: 16px;
    max-width: 100%;
}

@media (min-width: 720px) {
    .robotics-container {
        flex-direction: row;
        align-items: stretch;
    }
}

.robotics-workspace {
    flex: 1 1 58%;
    min-height: 260px;
    display: flex;
    flex-direction: row;
    align-items: stretch;
    gap: 12px;
    padding: 14px;
    background: linear-gradient(165deg, #0f172a 0%, #1e293b 100%);
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.06);
    overflow: hidden;
}

.mcu-board {
    flex: 0 0 auto;
    width: 118px;
    margin: 0;
    padding: 12px 10px;
    display: flex;
    flex-direction: column;
    align-items: center;
    background: linear-gradient(180deg, #166534 0%, #14532d 100%);
    border: 1px solid #052e16;
    border-radius: 10px;
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.12),
        0 6px 16px rgba(0, 0, 0, 0.35);
    color: #ecfdf5;
}

.mcu-header {
    width: 100%;
    text-align: center;
    font-size: 0.5625rem;
    font-weight: 700;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: #bbf7d0;
    padding-bottom: 8px;
    margin-bottom: 8px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.12);
    font-family: ui-monospace, 'Cascadia Code', monospace;
}

.mcu-pins {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.mcu-pin {
    display: flex;
    align-items: center;
    gap: 6px;
    width: 100%;
}

.pin-id {
    font-size: 0.625rem;
    font-weight: 600;
    color: #d1fae5;
    width: 28px;
    font-family: ui-monospace, monospace;
}

.pin-hole {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    cursor: pointer;
    background: radial-gradient(circle at 30% 30%, #fde68a, #ca8a04);
    border: 2px solid #92400e;
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.35);
    flex-shrink: 0;
}

.components-stage {
    flex: 1;
    min-width: 0;
    border-radius: 10px;
    background: rgba(15, 23, 42, 0.5);
    border: 1px dashed rgba(148, 163, 184, 0.25);
    padding: 10px;
    overflow: auto;
}

.stage-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-content: flex-start;
    min-height: 80px;
}

.connected-component {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 10px 12px;
    min-width: 88px;
    max-width: 120px;
    background: rgba(30, 41, 59, 0.95);
    border: 1px solid rgba(148, 163, 184, 0.2);
    border-radius: 10px;
    color: #e2e8f0;
    font-size: 0.6875rem;
    text-align: center;
    transition:
        border-color 0.2s,
        box-shadow 0.2s;
}

.connected-component .comp-icon {
    color: #a5b4fc;
}

.connected-component.active {
    border-color: #fbbf24;
    box-shadow: 0 0 0 1px rgba(251, 191, 36, 0.5), 0 8px 20px rgba(251, 191, 36, 0.15);
}

.robotics-panel {
    flex: 1 1 38%;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.robotics-panel .panel-section {
    padding: 12px 14px;
    border-radius: 10px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
}

.robotics-panel .panel-section h4 {
    margin: 0 0 10px;
    font-size: 0.6875rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: #64748b;
}

.component-palette {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.palette-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 10px 12px;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
    background: #fff;
    color: #334155;
    font-size: 0.8125rem;
    font-weight: 600;
    cursor: pointer;
    transition:
        background 0.15s,
        border-color 0.15s,
        transform 0.15s;
}

.palette-item:hover {
    border-color: #6366f1;
    background: #eef2ff;
    transform: translateY(-1px);
}

.palette-item svg {
    width: 18px;
    height: 18px;
    color: #4f46e5;
    flex-shrink: 0;
}

.logic-rules {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 10px;
}

.logic-rule-row {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 10px 12px;
    border-radius: 10px;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-left: 3px solid #6366f1;
    font-size: 0.8125rem;
}

.logic-rule-row .rule-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.logic-rule-row .rule-tag {
    font-size: 0.625rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: #6366f1;
}

.logic-rule-row .rule-del {
    border: none;
    background: transparent;
    padding: 4px;
    cursor: pointer;
    color: #94a3b8;
    border-radius: 6px;
}

.logic-rule-row .rule-del:hover {
    color: #ef4444;
    background: #fef2f2;
}

.logic-rule-row .rule-body {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.logic-rule-row .rule-clause {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
}

.logic-rule-row .keyword {
    font-weight: 800;
    font-size: 0.6875rem;
    color: #4338ca;
    font-family: ui-monospace, monospace;
}

.logic-rule-row select,
.logic-rule-row input.val-input {
    padding: 6px 8px;
    border-radius: 6px;
    border: 1px solid #cbd5e1;
    background: #f8fafc;
    color: #0f172a;
    font-size: 0.8125rem;
    min-width: 0;
}

.sim-controls {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.sim-controls label {
    font-size: 0.8125rem;
    font-weight: 600;
    color: #475569;
}

.sim-controls input[type='range'] {
    width: 100%;
}

.robotics-panel .btn-sm,
.robotics-panel #add-rule {
    align-self: flex-start;
}

/* ??? Diagrama de cuerpo libre ??? */
.physics-force-container {
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding: 16px;
    max-width: 100%;
}

@media (min-width: 720px) {
    .physics-force-container {
        flex-direction: row;
        align-items: stretch;
    }
}

.physics-force-workspace {
    flex: 1 1 55%;
    position: relative;
    min-height: 240px;
    padding: 28px 12px 12px;
    border-radius: 12px;
    border: 1px solid #e2e8f0;
    background-color: #fafbfc;
    background-image:
        linear-gradient(rgba(15, 23, 42, 0.04) 1px, transparent 1px),
        linear-gradient(90deg, rgba(15, 23, 42, 0.04) 1px, transparent 1px);
    background-size: 18px 18px;
}

.workspace-label {
    position: absolute;
    top: 10px;
    left: 14px;
    font-size: 0.625rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: #94a3b8;
}

.physics-svg {
    display: block;
    width: 100%;
    max-width: 420px;
    margin: 0 auto;
    height: auto;
    min-height: 220px;
}

.physics-force-panel {
    flex: 1 1 40%;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 0;
    border: none;
}

@media (min-width: 720px) {
    .physics-force-panel {
        padding-left: 16px;
        border-left: 1px solid #e2e8f0;
    }
}

.physics-force-panel .panel-section {
    padding: 12px 14px;
    border-radius: 10px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
}

.physics-force-panel .panel-section h4 {
    margin: 0 0 10px;
    font-size: 0.6875rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: #64748b;
}

.forces-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 10px;
}

.force-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
    background: #fff;
    font-size: 0.8125rem;
}

.force-color {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    flex-shrink: 0;
    box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.06);
}

.f-label {
    flex: 1;
    min-width: 0;
    border: none;
    background: transparent;
    font-weight: 600;
    color: #334155;
    font-size: 0.875rem;
}

.force-stats {
    padding: 14px 16px;
    border-radius: 10px;
    background: linear-gradient(135deg, #1e293b 0%, #334155 100%);
    color: #f1f5f5;
    font-size: 0.875rem;
    font-weight: 600;
    line-height: 1.6;
    border: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

.force-stats span {
    font-family: ui-monospace, 'Cascadia Code', monospace;
    font-weight: 700;
    color: #7dd3fc;
}

.res-total {
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px dashed rgba(255, 255, 255, 0.2);
    font-size: 0.9375rem;
    color: #fde68a;
}

.res-total span {
    color: #fef08a;
}

/* ??? Validador de pasos algebraicos ??? */
.algebra-steps-container {
    padding: 18px 16px 20px;
    max-width: 100%;
    background: #fdfdfd;
    background-image: radial-gradient(#e5e7eb 1px, transparent 1px);
    background-size: 18px 18px;
}

.algebra-steps-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 12px 16px;
    margin-bottom: 18px;
    padding: 14px 16px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.92);
    border: 1px solid #e2e8f0;
    box-shadow: var(--shadow-xs);
}

.step-initial-label {
    flex: 1 1 100%;
    text-align: center;
    font-size: 0.6875rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #64748b;
}

@media (min-width: 520px) {
    .step-initial-label {
        flex: 0 0 auto;
        text-align: left;
    }
}

.step-initial-val {
    font-family: var(--gl-widget-font-math);
    font-size: clamp(1.15rem, 2.8vw, 1.65rem);
    font-weight: 700;
    color: #0f172a;
    text-align: center;
    line-height: 1.3;
}

.algebra-steps-header .btn-icon {
    flex-shrink: 0;
}

.initial-editor {
    flex: 1 1 100%;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    justify-content: center;
}

.initial-editor.hidden {
    display: none;
}

.initial-editor input {
    flex: 1 1 200px;
    min-width: 160px;
    padding: 8px 12px;
    border-radius: 8px;
    border: 1px solid #cbd5e1;
    font-size: 0.875rem;
}

.steps-workspace {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.step-row {
    display: grid;
    grid-template-columns: 36px minmax(0, 1fr) 36px;
    align-items: start;
    gap: 10px 12px;
    padding: 10px 8px;
    border-radius: 10px;
    transition: background 0.15s;
}

.step-row:hover {
    background: rgba(241, 245, 249, 0.65);
}

.step-num {
    width: 32px;
    height: 32px;
    margin-top: 6px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8125rem;
    font-weight: 700;
    color: #fff;
    background: linear-gradient(145deg, #4f46e5, #6366f1);
    box-shadow: 0 2px 8px rgba(79, 70, 229, 0.25);
}

.step-input-wrap {
    min-width: 0;
}

.step-input {
    width: 100%;
    box-sizing: border-box;
    padding: 10px 12px;
    border-radius: 8px;
    border: 1px solid #cbd5e1;
    background: #fff;
    font-family: var(--gl-widget-font-math);
    font-size: 1rem;
    line-height: 1.4;
    color: #0f172a;
    transition:
        border-color 0.2s,
        box-shadow 0.2s,
        background 0.2s;
}

.step-input::placeholder {
    color: #94a3b8;
    font-style: italic;
}

.step-input:focus {
    outline: none;
    border-color: #6366f1;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
}

.step-input.valid {
    border-color: #22c55e;
    background: #f0fdf4;
}

.step-input.invalid {
    border-color: #ef4444;
    background: #fef2f2;
}

.step-status {
    margin-top: 6px;
    min-height: 22px;
}

.status-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
}

.status-pill.valid {
    background: #dcfce7;
    color: #166534;
}

.status-pill.invalid {
    background: #fee2e2;
    color: #991b1b;
}

.status-pill svg {
    width: 14px;
    height: 14px;
}

.step-del {
    margin-top: 4px;
    width: 36px;
    height: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: none;
    border-radius: 8px;
    background: transparent;
    color: #94a3b8;
    cursor: pointer;
    transition:
        color 0.15s,
        background 0.15s;
}

.step-del:hover {
    color: #ef4444;
    background: #fef2f2;
}

.steps-footer {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    margin-top: 16px;
}

.btn-add-step {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 11px 20px;
    border: none;
    border-radius: 10px;
    background: linear-gradient(135deg, #4f46e5, #4338ca);
    color: #fff;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.28);
    transition:
        transform 0.15s,
        box-shadow 0.15s;
}

.btn-add-step:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(79, 70, 229, 0.35);
}

.steps-hint-box {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    max-width: 36rem;
    padding: 10px 14px;
    border-radius: 10px;
    background: #fffbeb;
    border: 1px solid #fde68a;
    color: #854d0e;
    font-size: 0.8125rem;
    line-height: 1.45;
}

.steps-hint-box svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    color: #ca8a04;
    margin-top: 1px;
}

/* ==========================================================================
   TEACHER PANEL & INSTRUCTION OVERHAUL
   ========================================================================== */
.activity-instruction-editor {
    background: linear-gradient(180deg, #f8fafc 0%, #f1f5f9 100%) !important;
    border: 1px solid #e2e8f0 !important;
    border-radius: 10px !important;
    padding: 12px 14px !important;
    font-size: 0.9rem !important;
    color: #475569 !important;
    margin-bottom: 14px !important;
    font-family: Inter, system-ui, -apple-system, sans-serif !important;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.75);
}

.activity-instruction-editor .activity-instruction-input {
    background: rgba(255, 255, 255, 0.72) !important;
    border: 1px solid #e2e8f0 !important;
    resize: none !important;
    overflow-y: hidden !important;
}

.activity-instruction-display {
    background: linear-gradient(180deg, #f8fafc 0%, #f1f5f9 100%) !important;
    border: 1px solid #e2e8f0 !important;
    border-left: 3px solid #6366f1 !important;
    padding: 12px 16px !important;
    margin-bottom: 14px !important;
    border-radius: 10px !important;
    font-size: 0.95rem !important;
    color: #334155 !important;
    font-style: normal;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.75);
}

.btn-primary {
 background: linear-gradient(135deg, #4f46e5 0%, #4338ca 100%) !important;
 border: none !important;
 color: white !important;
 font-weight: 600 !important;
 padding: 8px 16px !important;
 border-radius: 8px !important;
 box-shadow: 0 4px 6px -1px rgba(79, 70, 229, 0.2) !important;
 transition: all 0.2s !important;
}

.btn-primary:hover {
 transform: translateY(-1px) !important;
 box-shadow: 0 10px 15px -3px rgba(79, 70, 229, 0.3) !important;
}

/* --- Math Mixed Number Converter Widget --- */
.math-mx-container {
    background: #fff;
    border-radius: 24px;
    padding: 28px;
    border: 3px solid #e2e8f0;
    font-family: 'Outfit', sans-serif;
    display: flex;
    flex-direction: column;
    gap: 20px;
    box-shadow: 0 10px 25px -5px rgba(0,0,0,0.05);
}

.math-mx-header {
    text-align: center;
}

.math-mx-title {
    font-size: 1.5rem;
    font-weight: 800;
    color: #4f46e5;
    margin: 0;
}

.math-mx-desc {
    font-size: 0.95rem;
    color: #64748b;
    margin: 5px 0 0 0;
}

.math-mx-guide {
    background: #f8fafc;
    border: 2px solid #e2e8f0;
    border-radius: 16px;
    padding: 16px 20px;
    min-height: 70px;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    font-size: 1.05rem;
    font-weight: 600;
    color: #1e293b;
    line-height: 1.4;
    transition: all 0.3s ease;
}

.math-mx-guide.has-update {
    animation: mathPopIn 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    background: #f1f5f9;
}

.math-mx-visual-area {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 30px;
    padding: 20px 0;
}

.math-mx-bars {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 15px;
    width: 100%;
}

.math-mx-bar-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    transition: all 0.3s ease;
}

.math-mx-bar {
    display: flex;
    width: 150px;
    height: 45px;
    background: #fff;
    border: 3px solid #1e293b;
    border-radius: 10px;
    overflow: hidden;
    transition: all 0.3s ease;
}

.math-mx-bar-wrapper.is-highlighted .math-mx-bar {
    transform: scale(1.05);
    border-color: #4f46e5;
    box-shadow: 0 0 0 4px rgba(79, 70, 229, 0.15);
}

.math-mx-bar-wrapper.is-whole .math-mx-bar {
    border-color: #059669;
    background: #ecfdf5;
}

.math-mx-segment {
    flex: 1;
    border-right: 2px solid #1e293b;
    background: #fff;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.math-mx-bar-wrapper.is-whole .math-mx-segment {
    border-right-color: transparent;
}

.math-mx-segment:last-child {
    border-right: none;
}

.math-mx-segment.is-filled {
    background: #6366f1;
}

.math-mx-segment.is-leftover {
    background: #f43f5e;
}

.math-mx-label {
    font-size: 0.85rem;
    font-weight: 800;
    color: #059669;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    height: 20px;
}

.math-mx-formula-area {
    display: flex;
    align-items: center;
    gap: 15px;
    opacity: 0;
    transform: translateY(10px);
    transition: all 0.4s ease;
}

.math-mx-formula-area.is-visible {
    opacity: 1;
    transform: translateY(0);
}

.math-mx-formula {
    display: flex;
    align-items: center;
    font-size: 2rem;
    font-weight: 800;
    color: #1e293b;
    visibility: hidden;
}

.math-mx-formula.is-visible {
    visibility: visible;
}

.math-mx-formula--mixed {
    gap: 8px;
}

.math-mx-whole {
    font-size: 3rem;
    line-height: 1;
    color: #4f46e5;
}

.math-mx-frac {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    vertical-align: middle;
}

.math-mx-num, .math-mx-den {
    font-size: 1.4rem;
    line-height: 1.1;
}

.math-mx-line {
    width: 100%;
    height: 3px;
    background: currentColor;
    margin: 2px 0;
    border-radius: 2px;
}

.math-mx-formula--mixed.is-highlighted .math-mx-num,
.math-mx-formula--mixed.is-highlighted .math-mx-den,
.math-mx-formula--mixed.is-highlighted .math-mx-line {
    color: #f43f5e;
}

.math-mx-controls {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.math-mx-steps {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
    gap: 10px;
}

.math-mx-step-btn {
    background: #fff;
    border: 2px solid #e2e8f0;
    border-radius: 12px;
    padding: 10px;
    font-size: 0.85rem;
    font-weight: 700;
    color: #64748b;
    cursor: pointer;
    transition: all 0.2s ease;
}

.math-mx-step-btn:hover {
    border-color: #cbd5e1;
    background: #f8fafc;
}

.math-mx-step-btn.is-active {
    background: #4f46e5;
    border-color: #4f46e5;
    color: #fff;
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.25);
}

.math-mx-btn-reset {
    background: #f1f5f9;
    border: none;
    padding: 12px;
    border-radius: 12px;
    color: #64748b;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.math-mx-btn-reset:hover {
    background: #e2e8f0;
    color: #475569;
}

@keyframes mathPopIn {
    0% { transform: scale(0.95); opacity: 0.5; }
    100% { transform: scale(1); opacity: 1; }
}

/* --- Fraction Transmuter Widget (Triple Panel) --- */
.math-tr-container {
    background: #fdfdfd;
    border-radius: 24px;
    padding: 30px;
    border: 1px solid #e2e8f0;
    font-family: 'Outfit', sans-serif;
    display: flex;
    flex-direction: column;
    gap: 25px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.03);
}

.math-tr-main-title {
    font-size: 1.6rem;
    font-weight: 800;
    color: #1e293b;
    text-align: center;
    margin: 0;
}

.math-tr-controls-panel {
    background: #fff;
    border: 2px solid #f1f5f9;
    border-radius: 20px;
    padding: 20px;
    display: flex;
    flex-wrap: wrap;
    gap: 30px;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(0,0,0,0.02);
}

.math-tr-sliders {
    display: flex;
    flex-direction: column;
    gap: 12px;
    flex: 1;
    min-width: 280px;
}

.math-tr-slider-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.math-tr-slider-group label {
    font-size: 0.85rem;
    font-weight: 700;
    color: #64748b;
    display: flex;
    justify-content: space-between;
}

.math-tr-val {
    color: #4f46e5;
    font-weight: 800;
}

.math-tr-range {
    width: 100%;
    accent-color: #4f46e5;
    cursor: pointer;
}

.math-tr-actions {
    display: flex;
    gap: 12px;
}

.math-tr-btn {
    padding: 12px 20px;
    border-radius: 12px;
    font-weight: 700;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s ease;
    border: none;
}

.math-tr-btn--convert {
    background: #10b981;
    color: #fff;
    box-shadow: 0 4px 0 #059669;
}

.math-tr-btn--convert:hover {
    transform: translateY(-2px);
    background: #34d399;
}

.math-tr-btn--reset {
    background: #f1f5f9;
    color: #64748b;
    display: flex;
    align-items: center;
    gap: 8px;
}

.math-tr-alert {
    background: #fffbeb;
    border: 1px solid #fcd34d;
    color: #92400e;
    padding: 12px 16px;
    border-radius: 12px;
    font-size: 0.85rem;
    font-weight: 600;
    text-align: center;
    line-height: 1.4;
    display: none;
    animation: mathPopIn 0.3s ease;
}

.math-tr-alert.is-visible {
    display: block;
}

.math-tr-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
}

.math-tr-panel {
    background: #fff;
    border-radius: 20px;
    border: 2px solid #f1f5f9;
    overflow: hidden;
    transition: all 0.3s ease;
    opacity: 0.6;
    filter: grayscale(0.8);
}

.math-tr-panel.is-active {
    opacity: 1;
    filter: grayscale(0);
    border-color: #cbd5e1;
    box-shadow: 0 10px 20px rgba(0,0,0,0.05);
}

.math-tr-panel--proper.is-active { border-color: #fbbf24; background: #fffdf5; }
.math-tr-panel--improper.is-active { border-color: #f87171; background: #fffafa; }
.math-tr-panel--mixed.is-active { border-color: #6366f1; background: #f5f3ff; }

.math-tr-panel-head {
    padding: 15px;
    text-align: center;
    border-bottom: 2px solid #f1f5f9;
}

.math-tr-icons {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-bottom: 8px;
    color: #94a3b8;
}

.math-tr-panel.is-active .math-tr-icons { color: #475569; }

.math-tr-panel h3 {
    font-size: 0.9rem;
    font-weight: 800;
    margin: 0;
    letter-spacing: 0.05em;
}

.math-tr-panel-content {
    padding: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
}

.math-tr-visuals {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 20px;
    align-items: center;
    min-height: 120px;
    justify-content: center;
}

.math-tr-svg-container {
    width: 100%;
}

.math-tr-svg-container svg {
    max-height: 50px;
    width: 100%;
}

/* SVG Colors & Interaction */
.math-tr-svg-unit-bg { fill: #f8fafc; }
.math-tr-svg-fill { fill: #fbbf24; }
.math-tr-panel--improper .math-tr-svg-fill { fill: #f87171; }
.math-tr-panel--mixed .math-tr-svg-fill { fill: #6366f1; }

.math-tr-svg-line { 
    stroke: #e2e8f0; 
    stroke-width: 1; 
}
.math-tr-svg-border { 
    fill: none; 
    stroke: #1e293b; 
    stroke-width: 2; 
    border-radius: 4px;
}

.math-tr-label-status {
    font-size: 0.8rem;
    font-weight: 700;
    color: #94a3b8;
    margin-top: 10px;
    text-transform: uppercase;
}

.math-tr-panel.is-active .math-tr-label-status { color: #64748b; }

.math-tr-placeholder {
    font-size: 0.85rem;
    font-style: italic;
    color: #cbd5e1;
}

.math-tr-equation {
    font-size: 1.1rem;
    font-weight: 800;
    color: #4338ca;
    margin-top: 5px;
    text-align: center;
}

/* --- LCM Simulator Overhaul --- */
.mlcm-container {
    background: #fff;
    border-radius: 24px;
    padding: 24px;
    border: 1px solid #e2e8f0;
    font-family: 'Outfit', sans-serif;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.mlcm-header {
    text-align: center;
    border-bottom: 2px solid #f8fafc;
    padding-bottom: 16px;
}

.mlcm-badge {
    display: inline-block;
    background: #e0e7ff;
    color: #4338ca;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 800;
    text-transform: uppercase;
    margin-bottom: 8px;
}

.mlcm-title {
    font-size: 1.4rem;
    font-weight: 800;
    color: #1e293b;
    margin: 0;
}

.mlcm-desc {
    font-size: 0.9rem;
    color: #64748b;
    margin: 4px 0 0 0;
}

.mlcm-config-panel {
    background: #f8fafc;
    border-radius: 16px;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    border: 1px solid #f1f5f9;
}

.mlcm-config-panel.is-locked {
    background: #fdfdfd;
    border-style: dashed;
}

.mlcm-inputs-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    justify-content: center;
    align-items: flex-end;
}

.mlcm-input-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.mlcm-input-item label {
    font-size: 0.75rem;
    font-weight: 800;
    color: #94a3b8;
    text-align: center;
}

.mlcm-num-in {
    width: 60px;
    padding: 8px;
    border: 2px solid #e2e8f0;
    border-radius: 10px;
    text-align: center;
    font-weight: 700;
    font-size: 1.1rem;
    color: #1e293b;
}

.mlcm-num-in:focus {
    border-color: #6366f1;
    outline: none;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.mlcm-btn-add {
    width: 44px;
    height: 44px;
    border-radius: 10px;
    border: 2px dashed #cbd5e1;
    background: transparent;
    color: #94a3b8;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.mlcm-btn-add:hover {
    border-color: #6366f1;
    color: #6366f1;
    background: #f5f3ff;
}

.mlcm-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
    flex-wrap: wrap;
}

.mlcm-main-btns {
    display: flex;
    gap: 12px;
}

.mlcm-btn-calc {
    background: #4f46e5;
    color: #fff;
    border: none;
    padding: 10px 24px;
    border-radius: 12px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s;
}

.mlcm-btn-calc:hover {
    background: #4338ca;
    transform: translateY(-1px);
}

.mlcm-btn-reset {
    background: #f1f5f9;
    color: #64748b;
    border: 1px solid #e2e8f0;
    padding: 10px 16px;
    border-radius: 12px;
    font-weight: 700;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 6px;
}

.mlcm-btn-reset:hover {
    background: #e2e8f0;
    color: #475569;
}

.mlcm-switch-control {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 600;
    color: #475569;
}

.mlcm-explorer {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.mlcm-row {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.mlcm-row-header {
    font-size: 0.85rem;
    font-weight: 800;
    color: #64748b;
}

.mlcm-row-header span {
    color: #6366f1;
}

.mlcm-row-bubbles {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding: 4px 0 12px 0;
    scrollbar-width: thin;
}

.mlcm-bubble {
    flex: 0 0 40px;
    height: 40px;
    border-radius: 50%;
    background: #f8fafc;
    border: 2px solid #e2e8f0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    font-weight: 700;
    color: #64748b;
    transition: all 0.3s ease;
}

.mlcm-bubble.is-common {
    background: #fef3c7;
    border-color: #fbbf24;
    color: #92400e;
}

.mlcm-bubble.is-lcm {
    background: #dcfce7;
    border-color: #22c55e;
    color: #15803d;
    transform: scale(1.1);
    box-shadow: 0 4px 10px rgba(34, 197, 94, 0.2);
}

.mlcm-result-area {
    margin-top: 10px;
}

.mlcm-card {
    background: #f5f3ff;
    border-radius: 16px;
    padding: 16px;
    text-align: center;
    border: 2px solid #e0e7ff;
}

.mlcm-card-text {
    font-size: 0.9rem;
    font-weight: 800;
    color: #4338ca;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 4px;
}

.mlcm-card-formula {
    font-size: 1.1rem;
    font-weight: 700;
    color: #1e293b;
}

.mlcm-card-formula span {
    font-size: 1.8rem;
    color: #4f46e5;
    margin-left: 8px;
}
/* ==========================================================================
   WIDGET: INSTRUCCIONES PEDAGÓGICAS (Estilo Premium)
   ========================================================================== */

.book-activity-instruction {
    margin: 0 0 1.5rem;
    padding: 0;
    background: transparent;
    border: none;
}

.ai-card {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05), 0 1px 2px rgba(0,0,0,0.03);
    transition: transform 0.2s ease;
}

.ai-card-header {
    background: #f8fafc;
    border-bottom: 1px solid #e2e8f0;
    padding: 8px 16px;
    display: flex;
    align-items: center;
    gap: 10px;
    color: #475569;
    font-size: 0.8rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.ai-card-header svg {
    width: 14px;
    height: 14px;
    color: #3b82f6;
}

.ai-card-body {
    padding: 20px;
    font-size: 0.95rem;
    line-height: 1.6;
    color: #334155;
    border-left: 4px solid #3b82f6;
}

.ai-title-blue {
    color: #2563eb;
    font-weight: 800;
    font-size: 1rem;
    margin: 1.2rem 0 0.8rem;
    display: flex;
    align-items: center;
    gap: 8px;
}

.ai-title-blue::before {
    content: "➤";
    font-size: 0.9rem;
}

/* Ajustes para tríada */
.ai-card-body strong {
    color: #1e293b;
}

/* Una sola tarjeta visible: quitar marco “libro” duplicado alrededor de .ai-card */
.book-activity-instruction.activity-instruction-read:has(.ai-card) {
    margin: 0 auto 1.25rem;
    padding: 0;
    max-width: var(--book-measure);
    border: none;
    background: transparent;
    box-shadow: none;
    font-style: normal;
    font-family: Inter, system-ui, "Segoe UI", sans-serif;
    white-space: normal;
}

.book-activity-instruction.activity-instruction-read:has(.ai-card) .ai-card {
    margin: 0;
}

.ai-card-body--prose {
    font-family: Inter, system-ui, "Segoe UI", sans-serif;
    font-size: 0.9375rem;
    line-height: 1.65;
    color: #334155;
    border-left: none;
    padding: 18px 20px 20px;
    border-top: 1px solid #e2e8f0;
    background: linear-gradient(180deg, #fafbfc 0%, #fff 18%);
}

.ai-card-body--prose > *:first-child {
    margin-top: 0;
}

.ai-para {
    margin: 0 0 0.85rem;
}

.ai-para:last-child {
    margin-bottom: 0;
}

.ai-instr-title {
    margin: 0 0 1rem;
    padding: 0 0 0.65rem 14px;
    border-bottom: 1px solid #e2e8f0;
    border-left: 4px solid #3b82f6;
    font-size: 0.95rem;
    font-weight: 700;
    line-height: 1.38;
    letter-spacing: 0.01em;
    color: #0f172a;
}

.ai-instr-title-text {
    display: block;
}

.ai-triad-section {
    margin: 0 0 1rem;
    padding: 12px 14px;
    background: #f8fafc;
    border-radius: 10px;
    border: 1px solid #e2e8f0;
}

.ai-triad-section:last-child {
    margin-bottom: 0;
}

.ai-triad-hd {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 0.45rem;
}

.ai-triad-num {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.65rem;
    height: 1.65rem;
    padding: 0 6px;
    font-size: 0.75rem;
    font-weight: 800;
    color: #fff;
    background: linear-gradient(135deg, #475569, #334155);
    border-radius: 6px;
}

.ai-triad-name {
    font-size: 0.7rem;
    font-weight: 800;
    letter-spacing: 0.07em;
    text-transform: uppercase;
    color: #64748b;
}

.ai-triad-content {
    font-size: 0.9rem;
    color: #475569;
    line-height: 1.62;
    padding-top: 4px;
}

.ai-inline-code {
    font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
    font-size: 0.86em;
    padding: 0.1em 0.4em;
    border-radius: 4px;
    background: #f1f5f9;
    color: #0f172a;
    border: 1px solid #e2e8f0;
}

.ai-code-ref {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px 10px;
    margin: 0.25rem 0 1rem;
    padding: 10px 14px;
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    border-radius: 8px;
}

.ai-code-ref-k {
    font-size: 0.68rem;
    font-weight: 800;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: #1d4ed8;
}

.ai-code-ref-k::after {
    content: ":";
    font-weight: 700;
    margin-left: 1px;
}

.ai-code-ref code {
    font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
    font-size: 0.88rem;
    font-weight: 600;
    color: #b91c1c;
    background: #fff;
    padding: 4px 10px;
    border-radius: 6px;
    border: 1px solid #e2e8f0;
}

/* --- Stem Food Classifier Block --- */
.food-classifier-widget {
    background: linear-gradient(135deg, #f0f9ff 0%, #e0f2fe 100%);
    border-radius: 24px;
    padding: 24px;
    border: 4px solid #bae6fd;
    font-family: 'Outfit', sans-serif;
    position: relative;
    overflow: hidden;
    min-height: 500px;
}

.food-classifier-intro {
    margin-bottom: 14px;
    text-align: left;
}

.food-classifier-title {
    margin: 0 0 4px;
    font-size: 1.15rem;
    font-weight: 800;
    color: #0f172a;
    letter-spacing: 0.01em;
}

.food-classifier-description {
    margin: 0;
    color: #334155;
    font-size: 0.92rem;
    line-height: 1.45;
}

.classifier-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

.avatar-container {
    display: flex;
    align-items: center;
    gap: 12px;
}

.classifier-avatar {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: white;
    border: 3px solid #7dd3fc;
    padding: 4px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.05);
}

.battery-wrap {
    width: 150px;
    background: #fff;
    padding: 4px;
    border-radius: 12px;
    border: 2px solid #cbd5e1;
}

.battery-label {
    font-size: 0.75rem;
    font-weight: 800;
    color: #475569;
    text-transform: uppercase;
    margin-bottom: 4px;
    display: flex;
    justify-content: space-between;
}

.battery-bar {
    height: 12px;
    background: #f1f5f9;
    border-radius: 6px;
    overflow: hidden;
}

.battery-fill {
    height: 100%;
    background: #10b981;
    width: 60%;
    transition: width 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

.classifier-streak-badge {
    background: #fef3c7;
    color: #b45309;
    padding: 6px 12px;
    border-radius: 20px;
    font-weight: 800;
    font-size: 0.85rem;
    border: 2px solid #fbbf24;
}

.classifier-streak {
    display: flex;
    align-items: center;
    gap: 8px;
}

.classifier-reset-btn {
    padding: 6px 10px;
    font-size: 0.78rem;
    font-weight: 700;
    border-radius: 999px;
    background: #fff;
    border-color: #cbd5e1;
    color: #334155;
}

.classifier-arena {
    display: flex;
    flex-direction: column;
    gap: 40px;
}

.food-dock {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    justify-content: center;
    min-height: 100px;
    padding: 16px;
    background: rgba(255, 255, 255, 0.4);
    border-radius: 20px;
    border: 2px dashed #bae6fd;
}

.draggable-food {
    width: 80px;
    display: flex;
    flex-direction: column;
    align-items: center;
    cursor: grab;
    transition: transform 0.2s;
    user-select: none;
    touch-action: none;
    z-index: 5;
}

.draggable-food.drag-placeholder {
    opacity: 0;
    pointer-events: none;
}

.draggable-food:active {
    cursor: grabbing;
}

.food-icon-img {
    width: 100%;
    height: 80px;
    object-fit: contain;
    filter: drop-shadow(0 4px 6px rgba(0,0,0,0.1));
}

.food-label {
    background: white;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 0.7rem;
    font-weight: 700;
    color: #334155;
    margin-top: -8px;
    border: 1px solid #e2e8f0;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.baskets-container {
    display: flex;
    justify-content: space-around;
    gap: 20px;
    align-items: flex-end;
}

.classifier-basket {
    flex: 1;
    max-width: 180px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    position: relative;
    padding-bottom: 10px;
    transition: transform 0.3s;
}

.basket-visual {
    width: 120px;
    height: 100px;
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center bottom;
    transition: filter 0.3s, transform 0.3s;
}

.classifier-basket.drag-over .basket-visual {
    filter: brightness(1.2) drop-shadow(0 0 15px currentColor);
    transform: scale(1.1);
}

.basket-label {
    text-align: center;
    font-weight: 800;
    font-size: 0.8rem;
    text-transform: uppercase;
    color: #4b5563;
    line-height: 1.2;
}

.basket-tag {
    font-size: 0.65rem;
    font-weight: 600;
    opacity: 0.7;
}

/* Animations & Feedback */
@keyframes food-poof {
    0% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.5); opacity: 0.5; filter: brightness(2); }
    100% { transform: scale(3); opacity: 0; }
}

.animate-poof {
    animation: food-poof 0.4s ease-out forwards;
}

@keyframes food-shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-10px); }
    75% { transform: translateX(10px); }
}

.animate-shake {
    animation: food-shake 0.3s ease-in-out;
}

.mision-popup {
    position: absolute;
    inset: 0;
    background: rgba(16, 185, 129, 0.9);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: white;
    z-index: 100;
    text-align: center;
    padding: 20px;
    backdrop-filter: blur(4px);
    display: none;
}

.mision-popup.active {
    display: flex;
    animation: fadeIn 0.5s ease;
}

.mision-title {
    font-size: 2.5rem;
    font-weight: 900;
    margin-bottom: 10px;
}

.mision-sub {
    font-size: 1.2rem;
    opacity: 0.9;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* Temas de Color Profesionales para Libros */
body.book-theme-indigo {
    /* Indigo (Por defecto) - ya definido en :root */
}

body.book-theme-biology {
    --book-heading-accent: #15803d; 
    --book-drop-cap: #16a34a; 
    --book-quote-border: #86efac; 
    --book-quote-bg-start: #f0fdf4; 
    --book-quote-bg-end: #fafafa;
    --book-marker: #22c55e; 
    --book-prose-link: #16a34a;
    --book-activity-bar: rgba(22, 163, 74, 0.38);
}

body.book-theme-math {
    --book-heading-accent: #1e3a8a; 
    --book-drop-cap: #2563eb; 
    --book-quote-border: #93c5fd; 
    --book-quote-bg-start: #eff6ff; 
    --book-quote-bg-end: #fafafa;
    --book-marker: #3b82f6; 
    --book-prose-link: #2563eb;
    --book-activity-bar: rgba(37, 99, 235, 0.38);
}

body.book-theme-humanities {
    --book-heading-accent: #9a3412; 
    --book-drop-cap: #d97706; 
    --book-quote-border: #fcd34d; 
    --book-quote-bg-start: #fffbeb; 
    --book-quote-bg-end: #fafafa;
    --book-marker: #f59e0b; 
    --book-prose-link: #d97706;
    --book-activity-bar: rgba(217, 119, 6, 0.38);
}

body.book-theme-creative {
    --book-heading-accent: #6b21a8; 
    --book-drop-cap: #9333ea; 
    --book-quote-border: #d8b4fe; 
    --book-quote-bg-start: #faf5ff; 
    --book-quote-bg-end: #fafafa;
    --book-marker: #a855f7; 
    --book-prose-link: #9333ea;
    --book-activity-bar: rgba(147, 51, 234, 0.38);
}

body.book-theme-neutral {
    --book-heading-accent: #374151; 
    --book-drop-cap: #4b5563; 
    --book-quote-border: #d1d5db; 
    --book-quote-bg-start: #f9fafb; 
    --book-quote-bg-end: #fafafa;
    --book-marker: #6b7280; 
    --book-prose-link: #4b5563;
    --book-activity-bar: rgba(75, 85, 99, 0.38);
}

/* Pestañas de modo de edición */
.editor-tab-nav {
    display: flex;
    gap: 4px;
    border-bottom: 2px solid var(--border-color, #e5e7eb);
    margin-bottom: 16px;
    background: #f9fafb;
    padding: 4px 4px 0;
    border-radius: 6px 6px 0 0;
}

.editor-tab-btn {
    border: none;
    background: none;
    padding: 8px 16px;
    font-size: 0.88rem;
    font-weight: 500;
    color: #6b7280;
    cursor: pointer;
    border-radius: 4px 4px 0 0;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: all 0.2s ease;
}

.editor-tab-btn:hover {
    color: #1f2937;
    background: rgba(0, 0, 0, 0.02);
}

.editor-tab-btn.is-active {
    color: #4f46e5;
    border-bottom-color: #4f46e5;
    background: #ffffff;
    font-weight: 600;
}

/* Panel lateral minimalista (editor docente) */
.properties-panel {
    width: 248px;
    padding: 14px 12px;
}

.props-card--compact .props-block-type {
    margin: 0 0 10px;
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    line-height: 1.3;
}

.props-card--compact .props-edit-btn {
    width: 100%;
    margin-top: 4px;
}

.props-alert {
    margin: 0 0 10px;
    padding: 8px 10px;
    font-size: 0.78rem;
    line-height: 1.4;
    color: #92400e;
    background: #fffbeb;
    border-radius: 6px;
    border: 1px solid rgba(245, 158, 11, 0.35);
}

.props-details {
    margin-top: 12px;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    background: #fafbfc;
    overflow: hidden;
}

.props-details summary {
    padding: 8px 10px;
    font-size: 0.8rem;
    font-weight: 600;
    color: #4b5563;
    cursor: pointer;
    list-style: none;
    user-select: none;
}

.props-details summary::-webkit-details-marker {
    display: none;
}

.props-details[open] summary {
    border-bottom: 1px solid #e5e7eb;
}

.props-details .props-template-grid,
.props-details .props-theme-grid,
.props-details .props-pista-input {
    padding: 8px 10px 10px;
}

.props-details .props-pista-input {
    width: 100%;
    box-sizing: border-box;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 0.85rem;
    resize: vertical;
    min-height: 52px;
}

.props-template-grid,
.props-theme-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
}

.props-item-bank-body {
    padding: 8px 10px 10px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.props-item-bank-hint {
    margin: 0;
    font-size: 0.72rem;
    line-height: 1.35;
    color: #6b7280;
}

.props-item-bank-field {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.props-item-bank-label {
    font-size: 0.72rem;
    font-weight: 600;
    color: #4b5563;
}

.props-item-bank-sublabel {
    font-size: 0.68rem;
    line-height: 1.35;
    color: #6b7280;
}

.props-item-bank-topic-select,
.props-item-bank-topic,
.props-item-bank-name,
.props-item-bank-select {
    width: 100%;
    box-sizing: border-box;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 0.82rem;
    padding: 6px 8px;
    background: #fff;
}

.props-item-bank-topic-select {
    margin-bottom: 6px;
    color: #374151;
}

.props-item-bank-select:disabled {
    color: #9ca3af;
    background: #f3f4f6;
}

.props-item-bank-actions {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.props-item-bank-actions .btn {
    width: 100%;
    justify-content: center;
}

.props-overview-stats--compact {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
    margin-bottom: 12px;
}

.props-overview-stats--compact .overview-card {
    padding: 8px 6px;
    text-align: center;
    border-radius: 8px;
    background: #f8fafc;
    border: 1px solid #e5e7eb;
}

.props-overview-stats--compact .overview-card-value {
    display: block;
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.2;
}

.props-overview-stats--compact .overview-card-label {
    display: block;
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-secondary);
    margin-top: 2px;
}

body.genlibros-editor-active .activity-instruction-editor {
    margin-bottom: 0.5rem !important;
    padding: 8px 10px !important;
}

body.genlibros-editor-active .activity-instruction-label {
    font-size: 0.72rem !important;
    margin-bottom: 4px !important;
}

body.genlibros-editor-active .activity-instruction-input {
    min-height: 2.25rem !important;
    padding: 6px 8px !important;
    font-size: 0.88rem !important;
}

/* Editores visuales de actividades: asegurar interacción dentro del lienzo escalado */
.activity-visual-editor,
.quiz-mc-editor {
    position: relative;
    z-index: 2;
}

.activity-visual-editor input,
.activity-visual-editor textarea,
.activity-visual-editor select,
.activity-visual-editor button,
.quiz-mc-editor input,
.quiz-mc-editor textarea,
.quiz-mc-editor select,
.quiz-mc-editor button {
    pointer-events: auto;
    user-select: text;
    -webkit-user-select: text;
}

.activity-visual-editor .field-hint {
    line-height: 1.45;
}

.activity-visual-editor .field-hint code {
    font-size: 0.92em;
    background: #f3f4f6;
    padding: 1px 5px;
    border-radius: 4px;
}

/* Editor Visual Cuestionario (Quiz-MC) */
.editor-question-card {
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 16px;
    position: relative;
    transition: box-shadow 0.2s;
}

.editor-question-card:hover {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.editor-option-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
}

.editor-option-row input[type="text"] {
    flex: 1;
}

/* Botones toggle interactivos para Verdadero/Falso */
.editor-tf-toggle {
    display: flex;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    overflow: hidden;
    max-width: 160px;
}

.editor-tf-btn {
    flex: 1;
    border: none;
    background: #ffffff;
    padding: 6px 12px;
    font-size: 0.82rem;
    font-weight: 600;
    color: #4b5563;
    cursor: pointer;
    transition: all 0.15s ease;
    text-align: center;
}

.editor-tf-btn:first-child {
    border-right: 1px solid #d1d5db;
}

.editor-tf-btn.is-selected[data-val="true"] {
    background: #10b981;
    color: #ffffff;
}

.editor-tf-btn.is-selected[data-val="false"] {
    background: #ef4444;
    color: #ffffff;
}

/* ==========================================================================
   DISEÑO MINIMALISTA Y PREMIUM (OVERRIDES DE INTERFAZ DEL EDITOR)
   ========================================================================== */

/* 1. Fondo del lienzo tipo Cuadrícula Figma Premium */
.canvas-container {
    background-color: #f8fafc !important;
    background-image: 
        radial-gradient(#e2e8f0 1.5px, transparent 1.5px), 
        radial-gradient(#e2e8f0 1.5px, #f8fafc 1.5px) !important;
    background-size: 24px 24px !important;
    background-position: 0 0, 12px 12px !important;
    padding: 32px 48px !important;
    transition: background 0.3s ease !important;
}

html[data-app-theme='dark'] body.genlibros-editor-active .canvas-container {
    background-color: #090d16 !important;
    background-image: 
        radial-gradient(rgba(148, 163, 184, 0.08) 1.5px, transparent 1.5px), 
        radial-gradient(rgba(148, 163, 184, 0.08) 1.5px, #090d16 1.5px) !important;
}

/* 2. Realce de la Hoja de Trabajo (.canvas-area) */
.canvas-area {
    border-radius: 12px !important;
    border: 1px solid rgba(15, 23, 42, 0.04) !important;
    box-shadow: 
        0 0 0 1px rgba(15, 23, 42, 0.01),
        0 2px 4px rgba(15, 23, 42, 0.01),
        0 16px 40px -4px rgba(15, 23, 42, 0.07),
        0 24px 48px -12px rgba(15, 23, 42, 0.04) !important;
    transition: transform 0.24s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.24s cubic-bezier(0.4, 0, 0.2, 1) !important;
}

.canvas-area:hover {
    box-shadow: 
        0 0 0 1px rgba(15, 23, 42, 0.02),
        0 4px 10px rgba(15, 23, 42, 0.02),
        0 24px 50px -4px rgba(15, 23, 42, 0.11),
        0 32px 64px -12px rgba(15, 23, 42, 0.06) !important;
}

html[data-app-theme='dark'] body.genlibros-editor-active .canvas-area {
    border-color: rgba(148, 163, 184, 0.08) !important;
    box-shadow: 
        0 0 0 1px rgba(0, 0, 0, 0.2),
        0 16px 40px -4px rgba(0, 0, 0, 0.45),
        0 24px 48px -12px rgba(0, 0, 0, 0.3) !important;
}

/* 3. Barra de Formato Compacta tipo Píldora de Vidrio Traslúcido */
.canvas-chrome {
    background: rgba(255, 255, 255, 0.85) !important;
    backdrop-filter: blur(12px) !important;
    -webkit-backdrop-filter: blur(12px) !important;
    border: 1px solid rgba(226, 232, 240, 0.9) !important;
    border-radius: 9999px !important;
    padding: 6px 20px !important;
    margin-bottom: 24px !important;
    box-shadow: 
        0 4px 20px -2px rgba(15, 23, 42, 0.03),
        0 8px 30px rgba(15, 23, 42, 0.02) !important;
    max-width: fit-content !important;
    margin-left: auto !important;
    margin-right: auto !important;
    display: flex !important;
    justify-content: center !important;
    align-items: center !important;
}

html[data-app-theme='dark'] body.genlibros-editor-active .canvas-chrome {
    background: rgba(21, 28, 40, 0.85) !important;
    border-color: rgba(148, 163, 184, 0.15) !important;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.35) !important;
}

/* Estilo interno para controles en la barra de formato */
.canvas-toolbar {
    flex-wrap: nowrap !important;
}

.sheet-format-select {
    padding: 4px 8px !important;
    font-size: 0.76rem !important;
    border-radius: 6px !important;
    border-color: rgba(15, 23, 42, 0.08) !important;
}

html[data-app-theme='dark'] body.genlibros-editor-active .sheet-format-select {
    border-color: rgba(148, 163, 184, 0.15) !important;
}

/* 4. Barras Laterales Planas y Minimalistas */
.toolbar {
    background: #ffffff !important;
    border-right: 1px solid rgba(15, 23, 42, 0.06) !important;
    padding: 20px 16px !important;
}

.properties-panel {
    background: #ffffff !important;
    border-left: 1px solid rgba(15, 23, 42, 0.06) !important;
    padding: 24px 20px !important;
    box-shadow: none !important;
}

html[data-app-theme='dark'] body.genlibros-editor-active .toolbar {
    background: #0f172a !important;
    border-right-color: rgba(148, 163, 184, 0.1) !important;
}

html[data-app-theme='dark'] body.genlibros-editor-active .properties-panel {
    background: #0f172a !important;
    border-left-color: rgba(148, 163, 184, 0.1) !important;
}

/* 5. Biblioteca de Bloques: Acordeones Premium */
.toolbar--clean .toolbar-content-details,
.toolbar--clean .toolbar-eval-details,
.toolbar--clean .toolbar-game-details,
.toolbar--clean .toolbar-tech-details,
.toolbar--clean .toolbar-math-details,
.toolbar--clean .toolbar-bio-details,
.toolbar--clean .toolbar-reader-details {
    border: 1px solid rgba(15, 23, 42, 0.05) !important;
    background: #f8fafc !important;
    border-radius: 10px !important;
    margin-bottom: 8px !important;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1) !important;
    border-left-width: 4px !important;
}

.toolbar--clean .toolbar-content-details:hover,
.toolbar--clean .toolbar-eval-details:hover,
.toolbar--clean .toolbar-game-details:hover,
.toolbar--clean .toolbar-tech-details:hover,
.toolbar--clean .toolbar-math-details:hover,
.toolbar--clean .toolbar-bio-details:hover,
.toolbar--clean .toolbar-reader-details:hover {
    border-color: rgba(15, 23, 42, 0.12) !important;
    background: #ffffff !important;
    box-shadow: 0 4px 12px rgba(15, 23, 42, 0.03) !important;
}

.toolbar--clean .toolbar-content-details[open],
.toolbar--clean .toolbar-eval-details[open],
.toolbar--clean .toolbar-game-details[open],
.toolbar--clean .toolbar-tech-details[open],
.toolbar--clean .toolbar-math-details[open],
.toolbar--clean .toolbar-bio-details[open],
.toolbar--clean .toolbar-reader-details[open] {
    border-color: rgba(79, 70, 229, 0.25) !important;
    background: #ffffff !important;
    box-shadow: 
        0 4px 16px rgba(15, 23, 42, 0.03),
        0 1px 3px rgba(15, 23, 42, 0.01) !important;
}

html[data-app-theme='dark'] body.genlibros-editor-active .toolbar-content-details,
html[data-app-theme='dark'] body.genlibros-editor-active .toolbar-eval-details,
html[data-app-theme='dark'] body.genlibros-editor-active .toolbar-game-details,
html[data-app-theme='dark'] body.genlibros-editor-active .toolbar-tech-details,
html[data-app-theme='dark'] body.genlibros-editor-active .toolbar-math-details,
html[data-app-theme='dark'] body.genlibros-editor-active .toolbar-bio-details,
html[data-app-theme='dark'] body.genlibros-editor-active .toolbar-reader-details {
    border-color: rgba(148, 163, 184, 0.06) !important;
    background: rgba(30, 41, 59, 0.4) !important;
}

html[data-app-theme='dark'] body.genlibros-editor-active .toolbar-content-details[open],
html[data-app-theme='dark'] body.genlibros-editor-active .toolbar-eval-details[open],
html[data-app-theme='dark'] body.genlibros-editor-active .toolbar-game-details[open],
html[data-app-theme='dark'] body.genlibros-editor-active .toolbar-tech-details[open],
html[data-app-theme='dark'] body.genlibros-editor-active .toolbar-math-details[open],
html[data-app-theme='dark'] body.genlibros-editor-active .toolbar-bio-details[open],
html[data-app-theme='dark'] body.genlibros-editor-active .toolbar-reader-details[open] {
    border-color: rgba(129, 140, 248, 0.3) !important;
    background: rgba(30, 41, 59, 0.6) !important;
}

/* 6. Tarjetas de Bloques Biblioteca (.tool-item) */
.tool-item {
    border-radius: 8px !important;
    border: 1px solid rgba(15, 23, 42, 0.05) !important;
    background: #ffffff !important;
    box-shadow: none !important;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1) !important;
    padding: 8px 10px !important;
    margin-bottom: 6px !important;
}

.tool-item:hover {
    border-color: rgba(79, 70, 229, 0.25) !important;
    background: #ffffff !important;
    box-shadow: 
        0 4px 12px rgba(79, 70, 229, 0.04),
        0 1px 2px rgba(15, 23, 42, 0.02) !important;
    transform: translateY(-1px) scale(1.01) !important;
}

html[data-app-theme='dark'] body.genlibros-editor-active .tool-item {
    border-color: rgba(148, 163, 184, 0.08) !important;
    background: #1e293b !important;
}

html[data-app-theme='dark'] body.genlibros-editor-active .tool-item:hover {
    border-color: rgba(129, 140, 248, 0.35) !important;
    background: #1e293b !important;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25) !important;
}

/* 7. Sección Lector Estudiante en Sidebar Izquierdo */
.toolbar-doc-section {
    border-radius: 10px !important;
    border: 1px solid rgba(15, 23, 42, 0.05) !important;
    background: #f8fafc !important;
    padding: 12px !important;
    box-shadow: none !important;
}

html[data-app-theme='dark'] body.genlibros-editor-active .toolbar-doc-section {
    border-color: rgba(148, 163, 184, 0.08) !important;
    background: rgba(30, 41, 59, 0.4) !important;
}

/* 8. Cabecera Minimalista */
.editor-header--minimal {
    border-bottom: 1px solid rgba(15, 23, 42, 0.05) !important;
    background: #ffffff !important;
    height: 52px !important;
    box-shadow: none !important;
}

html[data-app-theme='dark'] body.genlibros-editor-active .editor-header--minimal {
    background: #0f172a !important;
    border-bottom-color: rgba(148, 163, 184, 0.1) !important;
}

.editor-header--minimal .book-title-input {
    border-color: rgba(15, 23, 42, 0.06) !important;
    background: #f8fafc !important;
    border-radius: 8px !important;
    padding: 6px 12px !important;
    font-size: 0.85rem !important;
    font-weight: 500 !important;
    transition: all 0.2s ease !important;
}

.editor-header--minimal .book-title-input:focus {
    background: #ffffff !important;
    border-color: var(--primary-color) !important;
}

html[data-app-theme='dark'] body.genlibros-editor-active .editor-header--minimal .book-title-input {
    background: #0f1626 !important;
    border-color: rgba(148, 163, 184, 0.15) !important;
}
html[data-app-theme='dark'] body.genlibros-editor-active .editor-header--minimal .book-title-input:focus {
    background: #151c28 !important;
}

/* Botones de Cabecera Refinados */
.editor-header--minimal .header-action-btn {
    border-radius: 6px !important;
    font-size: 0.76rem !important;
    height: 30px !important;
    padding: 0 10px !important;
    border-color: rgba(15, 23, 42, 0.08) !important;
    background: #ffffff !important;
    transition: all 0.15s ease !important;
    font-weight: 600 !important;
}

.editor-header--minimal .header-action-btn:hover {
    background: #f8fafc !important;
    border-color: rgba(15, 23, 42, 0.15) !important;
}

.editor-header--minimal .header-action-btn--primary {
    background: var(--primary-color) !important;
    border-color: var(--primary-color) !important;
    color: #ffffff !important;
}

.editor-header--minimal .header-action-btn--primary:hover {
    background: var(--primary-hover) !important;
    border-color: var(--primary-hover) !important;
}

html[data-app-theme='dark'] body.genlibros-editor-active .editor-header--minimal .header-action-btn {
    background: #1e293b !important;
    border-color: rgba(148, 163, 184, 0.2) !important;
}
html[data-app-theme='dark'] body.genlibros-editor-active .editor-header--minimal .header-action-btn:hover {
    background: #334155 !important;
}
html[data-app-theme='dark'] body.genlibros-editor-active .editor-header--minimal .header-action-btn--primary {
    background: var(--primary-color) !important;
    border-color: var(--primary-color) !important;
}

/* === TABLE ACTIVITY BLOCK === */
.book-table-activity-cell {
    padding: 6px !important;
    vertical-align: middle;
}
.table-activity-input {
    width: 100%;
    box-sizing: border-box;
    padding: 8px 12px;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    font-size: 1rem;
    font-family: inherit;
    color: #1e293b;
    background: #f8fafc;
    transition: all 0.2s ease;
    text-align: center;
    font-weight: 600;
}
.table-activity-input:focus {
    outline: none;
    border-color: #6366f1;
    background: #ffffff;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}
.table-activity-input.is-valid {
    border-color: #10b981;
    background: #ecfdf5;
    color: #047857;
}
.table-activity-input.is-invalid {
    border-color: #ef4444;
    background: #fef2f2;
    color: #b91c1c;
}

/* ==========================================================================
   OPTIMIZACIÓN DE EVENTOS TÁCTILES IPAD (Eliminación de Latencia 300ms)
   ========================================================================== */
button,
input,
textarea,
select,
a,
.btn,
.btn-icon,
.table-activity-input,
.fill-blank-input,
.book-quiz-option {
    touch-action: manipulation;
}

/* ===== WEB EMBED BLOCK (Premium UI) ===== */
.web-embed-wrapper {
    position: relative;
    width: 100%;
    margin-bottom: 1.5rem;
    border-radius: 16px;
    background: #ffffff;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.05), 0 8px 10px -6px rgba(0, 0, 0, 0.01);
    border: 1px solid rgba(226, 232, 240, 0.8);
    overflow: hidden;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.web-embed-wrapper:hover {
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.08), 0 10px 10px -5px rgba(0, 0, 0, 0.03);
    border-color: rgba(148, 163, 184, 0.5);
}

.web-embed-viewer {
    width: 100%;
    height: 70vh;
    min-height: 500px;
    position: relative;
    background: #f8fafc;
    z-index: 1;
}

.web-embed-viewer.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 350px;
    min-height: 350px;
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
    cursor: pointer;
}

.web-embed-empty-state {
    text-align: center;
    color: #475569;
    padding: 2rem;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.6);
    backdrop-filter: blur(8px);
    border: 1px solid rgba(255, 255, 255, 0.8);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
    transition: transform 0.2s ease;
}

.web-embed-viewer.empty-state:hover .web-embed-empty-state {
    transform: translateY(-2px);
    background: rgba(255, 255, 255, 0.9);
}

.web-embed-icon {
    width: 54px;
    height: 54px;
    color: #3b82f6;
    margin-bottom: 1.2rem;
    filter: drop-shadow(0 4px 6px rgba(59, 130, 246, 0.25));
}

.web-embed-title {
    font-size: 1.4rem;
    font-weight: 700;
    margin: 0 0 0.5rem 0;
    color: #1e293b;
    letter-spacing: -0.02em;
}

.web-embed-desc {
    font-size: 0.95rem;
    margin: 0 0 1.5rem 0;
    color: #64748b;
}

.web-embed-iframe {
    width: 100%;
    height: 100%;
    border: none;
    display: block;
    background: #ffffff;
}

/* Inline Editor Overlay */
.web-embed-editor {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.web-embed-editor.active {
    opacity: 1;
    pointer-events: auto;
}

.web-embed-editor-panel {
    background: #ffffff;
    width: 90%;
    max-width: 600px;
    border-radius: 16px;
    padding: 2.5rem;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    transform: translateY(20px);
    transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.web-embed-editor.active .web-embed-editor-panel {
    transform: translateY(0);
}

.web-embed-editor-header {
    display: flex;
    align-items: center;
    margin-bottom: 1.5rem;
}

.web-embed-editor-header i {
    color: #3b82f6;
    margin-right: 12px;
}

.web-embed-editor-header h3 {
    margin: 0;
    font-size: 1.25rem;
    color: #0f172a;
    font-weight: 700;
}

.web-embed-input-wrapper {
    position: relative;
    margin-bottom: 1.5rem;
}

.web-embed-input {
    width: 100%;
    padding: 1rem 1.2rem;
    font-size: 1rem;
    color: #334155;
    background: #f8fafc;
    border: 2px solid #e2e8f0;
    border-radius: 12px;
    outline: none;
    transition: all 0.2s ease;
}

.web-embed-input:focus {
    background: #ffffff;
    border-color: #3b82f6;
    box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.1);
}

.web-embed-error-msg {
    color: #ef4444;
    font-size: 0.85rem;
    margin-top: 0.5rem;
    display: flex;
    align-items: center;
    background: #fef2f2;
    padding: 0.75rem;
    border-radius: 8px;
    border-left: 4px solid #ef4444;
}

.web-embed-actions {
    display: flex;
    justify-content: flex-end;
    gap: 1rem;
}

.web-embed-actions .btn {
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    font-weight: 600;
    transition: all 0.2s;
    cursor: pointer;
}

.web-embed-actions .btn-outline {
    background: transparent;
    border: 2px solid #e2e8f0;
    color: #475569;
}

.web-embed-actions .btn-outline:hover {
    background: #f1f5f9;
    border-color: #cbd5e1;
    color: #1e293b;
}

.web-embed-actions .btn-primary {
    background: #3b82f6;
    border: 2px solid #3b82f6;
    color: white;
    box-shadow: 0 4px 6px -1px rgba(59, 130, 246, 0.4);
}

.web-embed-actions .btn-primary:hover {
    background: #2563eb;
    border-color: #2563eb;
    box-shadow: 0 6px 8px -1px rgba(59, 130, 246, 0.5);
    transform: translateY(-1px);
}

/* ==========================================================================
   FIDELIDAD DE RENDERIZADO DE IMÁGENES Y BLOQUES (EDITOR & LECTOR)
   ========================================================================== */
/* Anular restricciones de alto y encuadre en imágenes recortadas por el docente */
.book-figure__inner--cropped,
.book-figure__inner[data-cropped="1"],
.book-figure__inner[style*="aspect-ratio"] {
    max-width: 100% !important;
}

.book-figure__inner--cropped .book-figure__img,
.book-figure__inner[data-cropped="1"] .book-figure__img,
.book-figure__inner[style*="aspect-ratio"] .book-figure__img {
    max-height: none !important;
    max-width: none !important;
    object-fit: fill !important;
}

/* Permitir que el contenedor de figura respete el ancho personalizado del docente */
.block-image:not(.block-image--cover-full) .book-figure {
    width: 100% !important;
    max-width: 100% !important;
    height: auto !important;
    margin: 0 auto !important;
}

.block-image:not(.block-image--cover-full) .book-figure__inner:not(.book-figure__inner--cropped):not([data-cropped="1"]):not([style*="aspect-ratio"]) {
    height: auto !important;
    max-height: none !important;
    aspect-ratio: auto !important;
}

.block-image:not(.block-image--cover-full) .book-figure__inner:not(.book-figure__inner--cropped):not([data-cropped="1"]):not([style*="aspect-ratio"]) .book-figure__img {
    width: 100% !important;
    height: auto !important;
    max-height: min(52vh, 480px) !important;
    object-fit: contain !important;
    object-position: center !important;
}
