@import url("https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:ital,wght@0,400;0,500;0,600;0,700;1,400&display=swap");

:root {
    color-scheme: light;
    --bg: #f4f6f8;
    --bg-page: #ffffff;
    --bg-elevated: #ffffff;
    --border: #e8ecf0;
    --border-strong: #cbd5e1;
    --text: #0f172a;
    --text-muted: #64748b;
    --accent: #2563eb;
    --accent-soft: #eff6ff;
    --accent-hover: #1d4ed8;
    --success-bg: #ecfdf5;
    --success-border: #10b981;
    --success-text: #065f46;
    --error-bg: #fef2f2;
    --error-border: #f87171;
    --error-text: #991b1b;
    --ai: #7c3aed;
    --ai-soft: #f5f3ff;
    --ai-hover: #6d28d9;
    --danger: #dc2626;
    --danger-hover: #b91c1c;
    --radius: 14px;
    --radius-sm: 8px;
    --shadow: 0 1px 2px rgba(15, 23, 42, 0.04), 0 4px 12px rgba(15, 23, 42, 0.04);
    --shadow-lg: 0 24px 56px -16px rgba(15, 23, 42, 0.14);
    --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
    --font: "Plus Jakarta Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    --mono: ui-monospace, "Cascadia Code", monospace;
    --header-h: 58px;
}

* {
    box-sizing: border-box;
}

html {
    height: 100%;
}

body {
    margin: 0;
    min-height: 100%;
    font-family: var(--font);
    font-size: 15px;
    line-height: 1.55;
    background: var(--bg-page);
    color: var(--text);
    -webkit-font-smoothing: antialiased;
}

@media (prefers-reduced-motion: no-preference) {
    html {
        scroll-behavior: smooth;
    }
}

a {
    color: var(--accent);
    text-decoration: none;
    font-weight: 500;
}

a:hover {
    text-decoration: underline;
    text-underline-offset: 0.14em;
}

/* —— Salto al contenido —— */
.skip-link {
    position: fixed;
    top: 0;
    left: 50%;
    z-index: 10001;
    padding: 0.55rem 1.15rem;
    background: var(--accent);
    color: #fff;
    font-weight: 600;
    font-size: 0.82rem;
    border-radius: 0 0 var(--radius-sm) var(--radius-sm);
    text-decoration: none;
    transform: translate(-50%, -120%);
    transition: transform 0.2s var(--ease-out), box-shadow 0.2s;
    box-shadow: var(--shadow-lg);
}

.skip-link:focus {
    outline: none;
    transform: translate(-50%, 0);
}

.skip-link:focus-visible {
    outline: 2px solid #fff;
    outline-offset: 2px;
}

/* Solo lectores de pantalla */
.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* —— Cabecera —— */
body.has-session {
    padding-top: var(--header-h);
}

.site-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--header-h);
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 clamp(1rem, 3vw, 2rem);
    background: rgba(255, 255, 255, 0.88);
    border-bottom: 1px solid var(--border);
    backdrop-filter: blur(12px);
    box-shadow: var(--shadow);
}

.site-header__brand {
    font-weight: 700;
    font-size: 1.02rem;
    color: var(--text);
    letter-spacing: -0.03em;
}

.site-header__brand:hover {
    color: var(--accent);
    text-decoration: none;
}

.site-header__nav {
    display: flex;
    align-items: center;
    gap: 1.25rem;
}

.site-header__link {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-muted);
}

.site-header__link:hover {
    color: var(--text);
    text-decoration: none;
}

.site-header__link--active {
    color: var(--text);
    background: var(--accent-soft);
    padding: 0.38rem 0.72rem;
    margin: 0 -0.15rem;
    border-radius: var(--radius-sm);
    text-decoration: none;
}

.site-header__link--active:hover {
    color: var(--accent-hover);
    text-decoration: none;
}

.site-header__user {
    font-size: 0.85rem;
    color: var(--text-muted);
    font-weight: 500;
}

.site-header__logout {
    font-size: 0.85rem;
    padding: 0.45rem 0.9rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-strong);
    color: var(--text);
    background: var(--bg-elevated);
    font-weight: 600;
}

.site-header__logout:hover {
    background: var(--bg);
    text-decoration: none;
}

.site-main {
    width: 100%;
    min-height: calc(100vh - var(--header-h));
    background: var(--bg);
    outline: none;
}

.site-main:focus-visible {
    box-shadow: inset 0 0 0 2px rgba(37, 99, 235, 0.25);
}

/* —— Login —— */
body.auth-only {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    background:
        radial-gradient(ellipse 90% 70% at 50% -25%, rgba(37, 99, 235, 0.06), transparent),
        linear-gradient(180deg, #ffffff 0%, #f1f5f9 100%);
}

.auth-card {
    margin: 0;
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
}

.auth-title {
    margin: 0 0 0.35rem;
    font-size: 1.35rem;
    font-weight: 700;
    letter-spacing: -0.03em;
}

.auth-lead {
    margin: 0 0 1.25rem;
}

.auth-submit {
    width: 100%;
    margin-top: 1.1rem;
}

.auth-hint {
    margin: 1.1rem 0 0;
    font-size: 0.85rem;
}

.auth-card-wrap {
    width: 100%;
    max-width: 420px;
}

/* —— Contenedor pantalla completa —— */
.container {
    width: 100%;
    max-width: none;
    margin: 0;
    padding: 1.25rem clamp(1rem, 2.5vw, 2.75rem) 2.5rem;
}

.container--narrow {
    max-width: 760px;
    margin: 0 auto;
}

.page-header {
    margin-bottom: 1.35rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    justify-content: space-between;
    gap: 1rem;
}

.page-header__title {
    margin: 0;
    font-size: clamp(1.35rem, 2.5vw, 1.75rem);
    font-weight: 700;
    letter-spacing: -0.04em;
    color: var(--text);
}

.page-header__meta {
    margin: 0.35rem 0 0;
    font-size: 0.95rem;
    color: var(--text-muted);
    font-weight: 500;
}

.page-header__meta a {
    color: var(--accent);
    font-weight: 600;
    text-decoration: underline;
    text-underline-offset: 2px;
}

.page-header__meta a:hover {
    color: var(--text);
}

.breadcrumb {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.35rem 0.45rem;
    font-size: 0.84rem;
    margin-bottom: 0.85rem;
    color: var(--text-muted);
    font-weight: 500;
}

.breadcrumb a {
    color: var(--text-muted);
    font-weight: 600;
}

.breadcrumb a:hover {
    color: var(--accent);
}

.breadcrumb__sep {
    color: var(--border-strong);
    font-weight: 400;
    user-select: none;
    pointer-events: none;
}

.breadcrumb > span:last-child {
    color: var(--text);
    font-weight: 600;
}

/* —— Tarjetas —— */
.card {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem 1.35rem;
    margin-bottom: 1rem;
    box-shadow: var(--shadow);
    transition: box-shadow 0.2s var(--ease-out), border-color 0.2s;
}

@media (hover: hover) {
    .card:hover {
        border-color: #dce3ea;
        box-shadow:
            0 1px 2px rgba(15, 23, 42, 0.04),
            0 8px 24px rgba(15, 23, 42, 0.06);
    }

    .card--flat:hover {
        box-shadow: var(--shadow);
    }
}

.card--flat {
    box-shadow: none;
    background: rgba(255, 255, 255, 0.65);
}

.card--muted {
    background: var(--bg);
    box-shadow: none;
    border-style: dashed;
}

.integration-status {
    margin: 1rem 0 1.25rem;
    padding: 0.75rem 1rem;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    line-height: 1.45;
    border: 1px solid var(--border);
}

.integration-status--ok {
    background: rgba(34, 197, 94, 0.08);
    border-color: rgba(34, 197, 94, 0.35);
}

.integration-status--off {
    background: rgba(251, 191, 36, 0.1);
    border-color: rgba(245, 158, 11, 0.35);
}

.integration-form .checkbox-label {
    margin: 0.5rem 0 1rem;
}

.card__title {
    margin: 0 0 0.35rem;
    font-size: 1rem;
    font-weight: 700;
    color: var(--text);
}

.card__lead {
    margin: 0 0 1rem;
    font-size: 0.9rem;
    color: var(--text-muted);
    font-weight: 500;
}

h1, h2, h3 {
    margin-top: 0;
}

/* —— Barra de herramientas de página —— */
.toolbar-page {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.6rem;
    margin-bottom: 1rem;
}

.toolbar-page .btn,
.toolbar-page a.btn-secondary {
    margin-top: 0;
}

/* —— Layout capítulos / dashboard —— */
.layout-split {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(260px, 320px);
    gap: 1.25rem;
    align-items: start;
}

@media (max-width: 960px) {
    .layout-split {
        grid-template-columns: 1fr;
    }
}

.aside-panel {
    position: sticky;
    top: calc(var(--header-h) + 1rem);
}

/* —— Filtros compactos —— */
.filters-inline {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 0.75rem 1rem;
}

.filters-inline .field {
    flex: 1 1 180px;
    min-width: 140px;
}

.filters-inline .field--short {
    flex: 0 0 160px;
    min-width: 120px;
}

.filters-inline label {
    margin-top: 0;
}

.filters-inline button,
.filters-inline a.btn-secondary {
    margin-top: 1.35rem;
}

@media (max-width: 640px) {
    .filters-inline button,
    .filters-inline a.btn-secondary {
        margin-top: 0.5rem;
    }
}

.row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.row--3cols {
    grid-template-columns: repeat(3, 1fr);
}

@media (max-width: 900px) {
    .row {
        grid-template-columns: 1fr;
    }

    .row--3cols {
        grid-template-columns: 1fr;
    }
}

/* —— Formularios —— */
label {
    display: block;
    margin: 0.85rem 0 0.35rem;
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
}

input, select, textarea {
    width: 100%;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-strong);
    padding: 0.65rem 0.8rem;
    font-size: 0.95rem;
    font-family: inherit;
    background: #fff;
    color: var(--text);
    accent-color: var(--accent);
    transition: border-color 0.15s, box-shadow 0.15s;
}

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

textarea {
    resize: vertical;
    min-height: 5rem;
}

button {
    cursor: pointer;
    font-family: inherit;
    font-weight: 600;
    font-size: 0.9rem;
    border-radius: var(--radius-sm);
    border: none;
    padding: 0.65rem 1.1rem;
    margin-top: 0.75rem;
    background: var(--accent);
    color: #fff;
    transition: background 0.15s, transform 0.1s;
}

button:hover {
    background: var(--accent-hover);
}

button:active {
    transform: scale(0.98);
}

button:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

/* —— Botones —— */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 0.55rem 1rem;
    font-size: 0.88rem;
    font-weight: 600;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    margin-top: 0;
    text-decoration: none;
    cursor: pointer;
    font-family: inherit;
    background: var(--accent);
    color: #fff;
    border: none;
    transition: background 0.15s var(--ease-out), transform 0.12s var(--ease-out), box-shadow 0.15s;
}

.btn:hover {
    background: var(--accent-hover);
    text-decoration: none;
    color: #fff;
}

.btn:active {
    transform: scale(0.98);
}

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

.btn--ghost {
    background: #fff;
    border: 1px solid var(--border-strong);
    color: var(--text);
}

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

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

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

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

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

.btn--ai-secondary {
    background: #fff;
    color: var(--ai);
    border: 1px solid rgba(124, 58, 237, 0.45);
}

.btn--ai-secondary:hover {
    background: rgba(124, 58, 237, 0.08);
    color: var(--ai-hover);
}

.btn--sm {
    padding: 0.38rem 0.65rem;
    font-size: 0.8rem;
}

a.btn-secondary {
    display: inline-flex;
    align-items: center;
    padding: 0.55rem 1rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-strong);
    color: var(--text);
    background: #fff;
    font-size: 0.88rem;
    font-weight: 600;
    margin-top: 0;
    box-shadow: var(--shadow);
    transition: background 0.15s var(--ease-out), border-color 0.15s, box-shadow 0.15s;
}

a.btn-secondary:hover {
    background: var(--bg);
    text-decoration: none;
}

.form-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem;
    align-items: center;
    margin-top: 1rem;
}

.form-actions button,
.form-actions .btn,
.form-actions a.btn-secondary {
    margin-top: 0;
}

button.btn-danger {
    background: var(--danger);
}

button.btn-danger:hover {
    background: var(--danger-hover);
}

button.btn-ai {
    background: var(--ai);
}

button.btn-ai:hover {
    background: var(--ai-hover);
}

.btn-small {
    padding: 0.35rem 0.55rem;
    font-size: 0.78rem;
}

/* —— Modales —— */
dialog.modal {
    padding: 0;
    border: none;
    border-radius: var(--radius);
    max-width: 560px;
    width: min(94vw, 560px);
    margin: auto;
    background: transparent;
    box-shadow: none;
}

@media (prefers-reduced-motion: no-preference) {
    dialog.modal[open] .modal__panel {
        animation: modalPanelIn 0.24s var(--ease-out) both;
    }
}

@keyframes modalPanelIn {
    from {
        opacity: 0;
        transform: translateY(10px) scale(0.99);
    }

    to {
        opacity: 1;
        transform: none;
    }
}

@media (prefers-reduced-motion: reduce) {
    dialog.modal[open] .modal__panel {
        animation: none;
    }
}

dialog.modal::backdrop {
    background: rgba(15, 23, 42, 0.4);
    backdrop-filter: blur(6px);
}

.modal__panel {
    background: #fff;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
    max-height: min(88vh, 720px);
    display: flex;
    flex-direction: column;
}

.modal__panel--wide {
    width: min(52rem, 96vw);
    max-width: min(52rem, 96vw);
}

.bulk-ai-progress {
    margin: 1rem 0 0.5rem;
}

.bulk-ai-progress__status {
    font-size: 0.85rem;
    margin-bottom: 0.35rem;
}

.bulk-ai-progress__track {
    height: 8px;
    border-radius: 999px;
    background: var(--border);
    overflow: hidden;
}

.bulk-ai-progress__fill {
    height: 100%;
    width: 0%;
    border-radius: 999px;
    background: linear-gradient(90deg, var(--ai), var(--accent));
    transition: width 0.25s var(--ease-out);
}

.bulk-ai-log {
    margin-top: 0.75rem;
    max-height: 11rem;
    overflow: auto;
    padding: 0.5rem 0.65rem;
    font-size: 0.8rem;
    line-height: 1.45;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-elevated);
}

.bulk-ai-log__line {
    margin: 0 0 0.25rem;
}

.chapter-narration-audio {
    display: block;
    width: 100%;
    max-width: 280px;
    margin: 0.35rem 0;
}

.cell-narration {
    vertical-align: top;
}

.cell-narration__form {
    margin-top: 0.25rem;
}

.chapter-editor__narration-card .chapter-editor__narration-actions {
    margin-top: 0.5rem;
}

.modal__header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    padding: 1.1rem 1.25rem;
    border-bottom: 1px solid var(--border);
    background: linear-gradient(180deg, #fafbfc 0%, #fff 100%);
}

.modal__header h2 {
    margin: 0;
    font-size: 1.05rem;
    font-weight: 700;
}

.modal__close {
    flex-shrink: 0;
    width: 2.25rem;
    height: 2.25rem;
    padding: 0;
    margin: 0;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: #fff;
    color: var(--text-muted);
    font-size: 1.25rem;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal__close:hover {
    background: var(--bg);
    color: var(--text);
}

.modal__body {
    padding: 1.15rem 1.25rem 1.35rem;
    overflow-y: auto;
    flex: 1;
    min-height: 0;
}

.modal__lead {
    margin: 0 0 1rem;
    font-size: 0.88rem;
    color: var(--text-muted);
    font-weight: 500;
    line-height: 1.5;
}

.modal__footer-actions {
    margin-top: 1.25rem;
}

/* —— Tablas —— */
.table-wrap {
    overflow-x: auto;
    margin: 0 -0.15rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
    background: #fff;
}

thead th {
    text-align: left;
    padding: 0.65rem 0.75rem;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
    background: #f8fafc;
    font-weight: 700;
}

tbody tr {
    transition: background 0.12s;
}

tbody tr:hover {
    background: #f8fafc;
}

tbody tr.tr-group {
    background: #eef2f7;
}

tbody tr.tr-group:hover {
    background: #eef2f7;
}

tbody tr.tr-group td {
    font-weight: 700;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    padding: 0.5rem 0.75rem;
    border-bottom: 1px solid var(--border);
}

.table-wrap tbody tr:last-child td {
    border-bottom: none;
}

td {
    padding: 0.75rem 0.75rem;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

td.actions {
    white-space: normal;
    max-width: 240px;
}

.action-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    align-items: center;
}

.inline-form {
    display: inline;
    margin: 0;
}

.inline-form button {
    margin-top: 0;
}

.compact-select {
    width: auto;
    min-width: 128px;
    padding: 0.4rem 0.5rem;
    font-size: 0.82rem;
}

/* —— Badges —— */
.badge {
    display: inline-block;
    padding: 0.18rem 0.55rem;
    border-radius: 999px;
    font-size: 0.68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.badge--ebook {
    background: var(--accent-soft);
    color: var(--accent);
}

.badge--podcast {
    background: var(--ai-soft);
    color: var(--ai);
}

.badge--youtube {
    background: #fee2e2;
    color: #b91c1c;
}

.badge--draft {
    background: #f1f5f9;
    color: #475569;
}

.badge--review {
    background: #fffbeb;
    color: #b45309;
}

.badge--ready {
    background: #ecfdf5;
    color: #047857;
}

.badge--published {
    background: var(--accent-soft);
    color: var(--accent-hover);
}

/* —— Alertas —— */
.muted {
    color: var(--text-muted);
    font-size: 0.9rem;
    font-weight: 500;
}

.error {
    color: var(--error-text);
    background: var(--error-bg);
    border: 1px solid var(--error-border);
    padding: 0.85rem 1rem;
    border-radius: var(--radius-sm);
    margin-bottom: 1rem;
    font-size: 0.9rem;
    font-weight: 500;
}

.success {
    color: var(--success-text);
    background: var(--success-bg);
    border: 1px solid var(--success-border);
    padding: 0.85rem 1rem;
    border-radius: var(--radius-sm);
    margin-bottom: 1rem;
    font-size: 0.9rem;
    font-weight: 500;
}

.hint {
    font-size: 0.84rem;
    color: var(--text-muted);
    margin: 0.35rem 0 0;
    font-weight: 500;
    line-height: 1.45;
}

/* —— Paginación —— */
.pager {
    display: flex;
    align-items: center;
    gap: 0.75rem 1rem;
    flex-wrap: wrap;
    margin-top: 1rem;
    padding-top: 0.85rem;
    border-top: 1px solid var(--border);
}

.pager__meta {
    font-size: 0.88rem;
    color: var(--text-muted);
    font-weight: 500;
}

.pager .btn-secondary {
    font-size: 0.85rem;
    padding: 0.45rem 0.75rem;
}

/* —— Misc —— */
.source-preview {
    white-space: pre-wrap;
    word-break: break-word;
    max-height: 220px;
    overflow: auto;
    background: #f8fafc;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.75rem;
    font-size: 0.82rem;
    font-family: var(--mono);
    margin: 0;
    color: var(--text);
}

.divider {
    border: none;
    border-top: 1px solid var(--border);
    margin: 1.25rem 0;
}

.checkbox-label {
    display: flex;
    align-items: flex-start;
    gap: 0.55rem;
    font-size: 0.88rem;
    font-weight: 500;
    text-transform: none;
    letter-spacing: 0;
    color: var(--text);
    margin: 0.75rem 0;
}

.checkbox-label input {
    width: auto;
    margin-top: 0.2rem;
}

code {
    font-family: var(--mono);
    background: #f1f5f9;
    padding: 0.12rem 0.4rem;
    border-radius: 4px;
    font-size: 0.84em;
    color: #334155;
}

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
    margin-bottom: 1rem;
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.cell-title {
    font-weight: 600;
    color: var(--text);
}

.cell-desc {
    display: block;
    margin-top: 0.2rem;
    font-size: 0.82rem;
    color: var(--text-muted);
    line-height: 1.35;
}

.cell-date {
    font-size: 0.82rem;
    color: var(--text-muted);
    font-variant-numeric: tabular-nums;
}

.cell-stats-head {
    text-align: right;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
    font-weight: 700;
}

.cell-stats {
    font-size: 0.8rem;
    line-height: 1.35;
    text-align: right;
    white-space: nowrap;
}

.cell-stats__num {
    font-variant-numeric: tabular-nums;
    font-weight: 600;
    color: var(--text);
}

.cell-stats__sep {
    opacity: 0.45;
    padding: 0 0.12rem;
}

.cell-stats--time {
    font-weight: 600;
    color: var(--text);
}

.textarea--xl {
    min-height: 320px;
}

.step-list {
    margin: 0;
    padding-left: 1.2rem;
    line-height: 1.75;
    font-weight: 500;
    color: var(--text-muted);
}

.step-list li {
    margin-bottom: 0.35rem;
}

.step-list li:last-child {
    margin-bottom: 0;
}

.aside-hint {
    margin-bottom: 0.75rem;
}

.aside-block {
    margin-top: 1rem;
}

.aside-desc {
    font-size: 0.88rem;
    line-height: 1.5;
}

.aside-h3 {
    margin: 0 0 0.5rem;
    font-size: 0.88rem;
    font-weight: 700;
    color: var(--text);
}

.empty-state {
    text-align: center;
    padding: 2.25rem 1.25rem;
    margin: 0.25rem 0 0;
    color: var(--text-muted);
    font-weight: 500;
    border: 1px dashed var(--border-strong);
    border-radius: var(--radius-sm);
    background: linear-gradient(180deg, #fafbfc 0%, #f8fafc 100%);
}

.empty-state strong {
    display: block;
    color: var(--text);
    margin-bottom: 0.35rem;
    font-size: 1rem;
}

.toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 0.45rem;
    align-items: center;
}

.toolbar form {
    display: inline;
    margin: 0;
}

.toolbar .btn,
.toolbar button {
    margin-top: 0;
}

.filters-form .form-actions {
    margin-top: 0.75rem;
}

.filters-form button {
    width: auto;
    margin-top: 0;
}

/* —— Editor de capítulo (full width) —— */
.chapter-editor__header-actions {
    justify-content: flex-end;
}

.chapter-editor__live {
    min-height: 1.35rem;
    margin: 0 0 0.5rem;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--accent);
}

.chapter-editor__grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(260px, 320px);
    gap: 1.25rem;
    align-items: start;
}

@media (max-width: 1100px) {
    .chapter-editor__grid {
        grid-template-columns: 1fr;
    }
}

.chapter-editor__meta-card .card__title {
    margin-bottom: 0.25rem;
}

.chapter-editor__meta-grid {
    display: grid;
    gap: 1rem 1.25rem;
    grid-template-columns: 1fr;
}

@media (min-width: 720px) {
    .chapter-editor__meta-grid {
        grid-template-columns: minmax(0, 2fr) 110px minmax(160px, 1fr);
    }
}

.chapter-editor__field-grow {
    min-width: 0;
}

.chapter-editor__body-card {
    padding: 0;
    overflow: hidden;
}

.chapter-editor__body-head {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.75rem 1rem;
    padding: 1.15rem 1.25rem 0.85rem;
    border-bottom: 1px solid var(--border);
    background: linear-gradient(180deg, #fafbfc 0%, #fff 100%);
}

.chapter-editor__body-head .card__title {
    margin-bottom: 0.2rem;
}

.chapter-editor__body-head .card__lead {
    margin-bottom: 0;
}

.chapter-editor__wc {
    flex-shrink: 0;
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--text-muted);
    padding: 0.35rem 0.65rem;
    border-radius: 999px;
    background: #f1f5f9;
    border: 1px solid var(--border);
}

.editor-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 1rem 1.25rem;
    padding: 0.85rem 1.25rem;
    background: #fff;
    border-bottom: 1px solid var(--border);
}

.editor-toolbar__group {
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
    min-width: 0;
}

.editor-toolbar__label {
    font-size: 0.68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
}

.editor-toolbar__buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
}

.editor-toolbar__buttons .btn {
    margin-top: 0;
}

.editor-textarea {
    display: block;
    width: 100%;
    min-height: min(70vh, 720px);
    margin: 0;
    padding: 1.35rem 1.5rem 1.5rem;
    border: none;
    border-radius: 0;
    font-size: 1.06rem;
    line-height: 1.75;
    resize: vertical;
    background: #fdfefe;
    color: var(--text);
    box-shadow: none;
}

.editor-textarea:focus {
    outline: none;
    box-shadow: inset 0 0 0 2px rgba(37, 99, 235, 0.2);
}

.chapter-editor__savebar {
    margin: 0;
    padding: 1rem 1.25rem 1.2rem;
    border-top: 1px solid var(--border);
    background: linear-gradient(180deg, #fff 0%, #f8fafc 100%);
}

.chapter-editor__aside-title {
    margin: 0 0 0.5rem;
    font-size: 0.82rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
}

.chapter-editor__hint-list {
    margin: 0;
    padding-left: 1.1rem;
    font-size: 0.88rem;
    color: var(--text-muted);
    font-weight: 500;
    line-height: 1.55;
}

.chapter-editor__hint-list li {
    margin-bottom: 0.35rem;
}

.chapter-editor__hint-card--muted {
    background: #fafbfc;
}

.chapter-editor__project-desc {
    margin: 0;
    font-size: 0.88rem;
    line-height: 1.55;
    color: var(--text-muted);
    font-weight: 500;
}

dialog.modal.modal--lg {
    max-width: min(94vw, 720px);
    width: min(94vw, 720px);
}

.chapter-editor__stats {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem 0.85rem;
    justify-content: flex-end;
}

.chapter-editor__extra-stats {
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
}

.chapter-editor__workspace {
    display: block;
    border-top: 1px solid var(--border);
}

.chapter-editor__workspace.chapter-editor__workspace--split {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0;
}

@media (max-width: 960px) {
    .chapter-editor__workspace.chapter-editor__workspace--split {
        grid-template-columns: 1fr;
        grid-template-rows: minmax(42vh, auto) minmax(42vh, auto);
    }
}

.chapter-editor__workspace--split .editor-textarea {
    min-height: min(52vh, 560px);
    border-right: 1px solid var(--border);
}

@media (max-width: 960px) {
    .chapter-editor__workspace--split .editor-textarea {
        border-right: none;
        border-bottom: 1px solid var(--border);
    }
}

.editor-preview {
    display: none;
    margin: 0;
    padding: 1.25rem 1.35rem 1.5rem;
    min-height: min(52vh, 560px);
    overflow: auto;
    font-size: 1.02rem;
    line-height: 1.72;
    color: var(--text);
    background: #f8fafc;
}

.chapter-editor__workspace--split .editor-preview {
    display: block;
}

.editor-preview__p {
    margin: 0 0 1rem;
}

.editor-preview__bq {
    margin: 0 0 1rem;
    padding: 0.85rem 1rem;
    border-left: 4px solid var(--accent);
    background: #fff;
    color: var(--text-muted);
    font-style: italic;
}

.editor-preview__tag {
    margin: 0 0 0.75rem;
    padding: 0.65rem 0.85rem;
    font-size: 0.88rem;
    font-family: var(--mono);
    background: #fff;
    border: 1px dashed var(--border-strong);
    border-radius: var(--radius-sm);
    white-space: pre-wrap;
}

.editor-preview__break {
    margin: 1rem 0;
    text-align: center;
    letter-spacing: 0.35em;
    color: var(--text-muted);
    font-weight: 600;
}

.editor-preview__muted {
    margin: 0;
    color: var(--text-muted);
    font-weight: 500;
}

.editor-outline {
    list-style: none;
    margin: 0.5rem 0 0;
    padding: 0;
    max-height: 280px;
    overflow: auto;
}

.editor-outline li {
    margin-bottom: 0.25rem;
}

.editor-outline__btn {
    display: block;
    width: 100%;
    text-align: left;
    padding: 0.4rem 0.45rem;
    margin: 0;
    border: none;
    border-radius: var(--radius-sm);
    background: transparent;
    font-size: 0.82rem;
    font-weight: 500;
    color: var(--text);
    cursor: pointer;
    font-family: inherit;
    line-height: 1.35;
}

.editor-outline__btn:hover {
    background: #f1f5f9;
}

.chapter-editor__draft-banner {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem 1rem;
    padding: 0.85rem 1rem;
    margin-bottom: 1rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--accent);
    background: var(--accent-soft);
}

.chapter-editor__draft-banner-text {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text);
    max-width: 52rem;
}

.chapter-editor__draft-banner-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.45rem;
}

.chapter-editor__hint-list--compact {
    font-size: 0.82rem;
}

.chapter-editor__hint-list kbd {
    display: inline-block;
    padding: 0.08rem 0.35rem;
    margin: 0 0.05rem;
    font-size: 0.72rem;
    font-family: var(--mono);
    font-weight: 600;
    border: 1px solid var(--border-strong);
    border-radius: 4px;
    background: #fff;
    box-shadow: 0 1px 0 var(--border);
}

.form-actions--wrap {
    flex-wrap: wrap;
    gap: 0.45rem;
}

.form-actions--wrap .btn {
    margin-top: 0;
}

.chapter-editor--zen .breadcrumb,
.chapter-editor--zen .page-header {
    display: none;
}

.chapter-editor--zen .chapter-editor__aside,
.chapter-editor--zen .chapter-editor__meta-card {
    display: none;
}

.chapter-editor--zen .chapter-editor__grid {
    grid-template-columns: 1fr;
}

.chapter-editor--zen .editor-textarea {
    min-height: min(88vh, 900px);
}

.chapter-editor--zen .chapter-editor__workspace--split .editor-textarea {
    min-height: min(40vh, 480px);
}

.chapter-editor__zen-exit {
    position: fixed;
    bottom: 1.25rem;
    right: 1.25rem;
    z-index: 250;
    padding: 0.55rem 1rem;
    font-size: 0.85rem;
    font-weight: 700;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-strong);
    background: #fff;
    box-shadow: var(--shadow-lg);
    cursor: pointer;
    font-family: inherit;
}

.chapter-editor__zen-exit:hover {
    background: var(--bg);
}

/* —— Editor capítulo: estudio + TinyMCE —— */
.page-chapter-editor .chapter-editor.container {
    max-width: min(1360px, 100%);
    margin-inline: auto;
}

.chapter-editor--studio .chapter-editor__grid {
    gap: 1.5rem;
}

.chapter-editor--studio .chapter-editor__workspace--wysiwyg {
    min-height: min(68vh, 820px);
}

.chapter-editor--wysiwyg .editor-plain-only {
    display: none !important;
}

.chapter-editor--wysiwyg:not(.chapter-editor--tinymce-ready) [data-snippet] {
    pointer-events: none;
    opacity: 0.55;
}

.chapter-editor--wysiwyg .editor-textarea--wysiwyg {
    min-height: 8rem;
}

.chapter-editor--wysiwyg .tox-tinymce {
    border: none !important;
    border-radius: 0 !important;
}

.chapter-editor--wysiwyg .tox .tox-edit-area__iframe {
    background: #fdfefe;
}

.chapter-editor--wysiwyg .tox .tox-toolbar__primary {
    background: linear-gradient(180deg, #fafbfc 0%, #fff 100%);
}

.chapter-editor__workspace--split .tox-tinymce {
    min-height: min(52vh, 560px);
}

.editor-preview__wysiwyg {
    font-size: 0.95rem;
    line-height: 1.62;
    color: var(--text);
    padding: 1rem 1.25rem 1.5rem;
}

.editor-preview__wysiwyg h2,
.editor-preview__wysiwyg h3 {
    margin: 1em 0 0.4em;
}

.editor-preview__wysiwyg blockquote {
    margin: 0.85em 0;
    padding: 0.5rem 0 0.5rem 1rem;
    border-left: 3px solid #cbd5e1;
    background: #f8fafc;
}

.chapter-editor--zen .chapter-editor__zen-exit {
    z-index: 12050;
}

.chapter-editor--zen .tox-fullscreen .tox.tox-tinymce,
.chapter-editor--zen .tox-fullscreen .tox.tox-tinymce-aux {
    z-index: 12000 !important;
}
