@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    overflow-wrap: break-word;
}

:root {
    --bg: #0f172a;
    --bg2: #080e1a;
    --card: #1e293b;
    --card-hover: #243347;
    --text: #f8fafc;
    --muted: #94a3b8;
    --subtle: #64748b;
    --accent: #3b82f6;
    --accent-h: #2563eb;
    --accent-glow: rgba(59, 130, 246, 0.15);
    --green: #10b981;
    --green-h: #059669;
    --red: #ef4444;
    --red-h: #dc2626;
    --border: #334155;
    --r-sm: 6px;
    --r-md: 10px;
    --r-lg: 16px;
    --shadow: 0 4px 24px rgba(0, 0, 0, 0.35);
    --shadow-h: 0 8px 36px rgba(0, 0, 0, 0.5);
    --ease: 0.2s ease;
}

[data-theme="light"] {
    --bg: #f8fafc;
    --bg2: #f1f5f9;
    --card: #ffffff;
    --card-hover: #f8fafc;
    --text: #0f172a;
    --muted: #64748b;
    --subtle: #94a3b8;
    --accent: #2563eb;
    --accent-h: #1d4ed8;
    --accent-glow: rgba(37, 99, 235, 0.12);
    --green: #059669;
    --green-h: #047857;
    --red: #dc2626;
    --red-h: #b91c1c;
    --border: #e2e8f0;
    --shadow: 0 4px 24px rgba(0, 0, 0, 0.08);
    --shadow-h: 0 8px 36px rgba(0, 0, 0, 0.15);
}

/* ── Theme toggle button ─────────────────────────────── */
.btn-theme-toggle {
    background: none;
    border: 1px solid var(--border);
    border-radius: var(--r-sm);
    color: var(--text);
    font-size: 1rem;
    cursor: pointer;
    padding: 0.35rem 0.6rem;
    transition: background var(--ease), border-color var(--ease);
}

.btn-theme-toggle:hover {
    background: var(--card);
    border-color: var(--accent);
}

/* ── Nivel badges ─────────────────────────────────────── */
.nivel-badge {
    display: inline-flex;
    align-items: center;
    padding: 0.15rem 0.6rem;
    border-radius: 50px;
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.nivel-badge.principiante {
    background: rgba(16, 185, 129, 0.12);
    color: var(--green);
    border: 1px solid rgba(16, 185, 129, 0.3);
}

.nivel-badge.intermedio {
    background: rgba(245, 158, 11, 0.12);
    color: #f59e0b;
    border: 1px solid rgba(245, 158, 11, 0.3);
}

.nivel-badge.avanzado {
    background: rgba(239, 68, 68, 0.12);
    color: var(--red);
    border: 1px solid rgba(239, 68, 68, 0.3);
}

/* ── Notification badge ───────────────────────────────── */
.notif-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--red);
    color: #fff;
    border-radius: 50%;
    font-size: 0.65rem;
    font-weight: 800;
    width: 16px;
    height: 16px;
    margin-left: 4px;
    vertical-align: middle;
    line-height: 1;
}


html {
    scroll-behavior: smooth;
    overflow-x: hidden;
}

body {
    font-family: 'Inter', system-ui, sans-serif;
    background: var(--bg);
    color: var(--text);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
}

/* ── Layout ─────────────────────────────────── */
.container {
    flex: 1;
    max-width: 1200px;
    margin: 0 auto;
    width: 100%;
    padding: 0 1.5rem;
}

/* ── Header ─────────────────────────────────── */
header {
    background: var(--card);
    padding: 0.875rem 2rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(12px);
}

.header-left {
    flex-shrink: 0;
}

.header-center {
    flex: 1;
    max-width: 480px;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-shrink: 0;
    margin-left: auto;
}

.logo {
    font-size: 1.35rem;
    font-weight: 800;
    color: var(--text);
    text-decoration: none;
    letter-spacing: -0.02em;
    transition: color var(--ease);
}

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

#buscador {
    width: 100%;
    padding: 0.55rem 1rem 0.55rem 2.5rem;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 50px;
    color: var(--text);
    font-size: 0.9rem;
    font-family: inherit;
    outline: none;
    transition: border-color var(--ease), box-shadow var(--ease);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cline x1='21' y1='21' x2='16.65' y2='16.65'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: 0.75rem center;
}

#buscador:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

#buscador::placeholder {
    color: var(--subtle);
}

.user-welcome {
    color: var(--muted);
    font-size: 0.875rem;
    white-space: nowrap;
}

/* ── Buttons ─────────────────────────────────── */
.btn {
    padding: 0.5rem 1.1rem;
    border-radius: var(--r-sm);
    text-decoration: none;
    font-weight: 600;
    font-size: 0.875rem;
    cursor: pointer;
    border: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    transition: background var(--ease), transform var(--ease), box-shadow var(--ease);
    white-space: normal;
    text-align: center;
    font-family: inherit;
}

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

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

.btn-primary:hover {
    background: var(--accent-h);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.35);
}

.btn-secondary {
    background: #334155;
    color: var(--text);
}

.btn-secondary:hover {
    background: #475569;
}

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

.btn-admin:hover {
    background: var(--green-h);
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.35);
}

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

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

.btn-full {
    width: 100%;
    justify-content: center;
    padding: 0.8rem 1.5rem;
    font-size: 1rem;
    border-radius: var(--r-md);
}

/* ── Hero ─────────────────────────────────── */
.hero {
    text-align: center;
    padding: 4rem 1rem 2rem;
}

.hero h1 {
    font-size: clamp(2rem, 5vw, 3rem);
    font-weight: 800;
    letter-spacing: -0.03em;
    background: linear-gradient(135deg, var(--text) 0%, var(--accent) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 0.75rem;
}

.hero p {
    color: var(--muted);
    font-size: 1.1rem;
}

/* ── Grid & Cards ─────────────────────────── */
.grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(310px, 1fr));
    gap: 1.5rem;
    padding: 0.5rem 0 3rem;
}

.card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg, var(--r-lg));
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transition: transform var(--ease), box-shadow var(--ease), border-color var(--ease);
    animation: fadeUp 0.4s ease both;
}

.card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-h);
    border-color: var(--accent);
}

.card img {
    width: 100%;
    aspect-ratio: 16/9;
    object-fit: cover;
    display: block;
}

.card-body {
    padding: 1.25rem 1.5rem 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    flex: 1;
}

.categoria {
    display: inline-flex;
    align-items: center;
    background: var(--accent-glow);
    color: var(--accent);
    border: 1px solid rgba(59, 130, 246, 0.3);
    padding: 0.2rem 0.7rem;
    border-radius: 50px;
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    width: fit-content;
}

.card h2 {
    font-size: 1.1rem;
    font-weight: 700;
    line-height: 1.35;
}

.card p {
    color: var(--muted);
    font-size: 0.9rem;
    line-height: 1.6;
    flex: 1;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.read-more {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    color: var(--accent);
    text-decoration: none;
    font-weight: 600;
    font-size: 0.875rem;
    margin-top: 0.5rem;
    width: fit-content;
    transition: gap var(--ease), color var(--ease);
}

.read-more:hover {
    gap: 0.6rem;
    color: var(--accent-h);
}

.empty-state {
    grid-column: 1/-1;
    text-align: center;
    padding: 4rem 1rem;
    color: var(--muted);
    font-size: 1.1rem;
}

.error-msg {
    grid-column: 1/-1;
    text-align: center;
    padding: 3rem 1rem;
    color: var(--red);
}

/* ── Skeleton ─────────────────────────────── */
@keyframes shimmer {
    0% {
        background-position: -200% 0;
    }

    100% {
        background-position: 200% 0;
    }
}

.skeleton {
    background: linear-gradient(90deg, var(--card) 25%, var(--card-hover) 50%, var(--card) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.4s infinite;
    border-radius: var(--r-sm);
}

.skeleton-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    overflow: hidden;
}

.skeleton-img {
    width: 100%;
    aspect-ratio: 16/9;
}

.skeleton-body {
    padding: 1.25rem 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.skeleton-badge {
    height: 22px;
    width: 80px;
    border-radius: 50px;
}

.skeleton-title {
    height: 20px;
    width: 85%;
    border-radius: 4px;
}

.skeleton-text {
    height: 13px;
    border-radius: 4px;
}

.skeleton-text:last-child {
    width: 55%;
}

/* ── Feedback messages ───────────────────── */
.mensaje {
    padding: 0.85rem 1.1rem;
    border-radius: var(--r-md);
    font-size: 0.9rem;
    font-weight: 500;
    margin-top: 0.5rem;
    animation: fadeUp 0.3s ease;
}

.mensaje-ok {
    background: rgba(16, 185, 129, 0.12);
    border: 1px solid rgba(16, 185, 129, 0.3);
    color: #34d399;
}

.mensaje-error {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: #f87171;
}

/* ── Auth ─────────────────────────────────── */
.auth-container {
    max-width: 420px;
    margin: 4rem auto;
    padding: 2.5rem 2rem;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    box-shadow: var(--shadow);
}

.auth-container h2 {
    font-size: 1.6rem;
    font-weight: 800;
    letter-spacing: -0.02em;
    margin-bottom: 1.5rem;
}

.auth-form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.auth-form input {
    width: 100%;
    padding: 0.8rem 1rem;
    background: var(--bg);
    border: 1px solid var(--border);
    color: var(--text);
    border-radius: var(--r-sm);
    font-size: 0.95rem;
    font-family: inherit;
    outline: none;
    transition: border-color var(--ease), box-shadow var(--ease);
}

.auth-form input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.auth-form input::placeholder {
    color: var(--subtle);
}

.toggle-form {
    text-align: center;
    margin-top: 1.25rem;
    color: var(--accent);
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    transition: color var(--ease);
}

.toggle-form:hover {
    color: var(--accent-h);
    text-decoration: underline;
}

/* ── Admin Panel ──────────────────────────── */
.admin-container {
    max-width: 900px;
    margin: 0 auto;
    padding: 2rem 1.5rem 3rem;
}

.admin-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    padding-bottom: 1.25rem;
    border-bottom: 1px solid var(--border);
}

.admin-header h1 {
    font-size: 1.75rem;
    font-weight: 800;
    letter-spacing: -0.02em;
}

.admin-table-wrap {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    overflow-x: auto;
}

.admin-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.admin-table th {
    background: var(--bg);
    color: var(--muted);
    font-weight: 600;
    text-align: left;
    padding: 0.85rem 1.25rem;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.admin-table td {
    padding: 1rem 1.25rem;
    border-top: 1px solid var(--border);
    vertical-align: middle;
}

.admin-table tr:hover td {
    background: rgba(255, 255, 255, 0.02);
}

.td-id {
    color: var(--subtle);
    font-family: monospace;
    font-size: 0.8rem;
    width: 50px;
}

.td-titulo {
    font-weight: 600;
}

.td-actions {
    text-align: right;
    white-space: nowrap;
}

/* ── Crear Tutorial / Form ─────────────────── */
.form-container {
    max-width: 820px;
    margin: 2rem auto;
    padding: 2rem 2rem 3rem;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    box-shadow: var(--shadow);
}

.form-container h1 {
    font-size: 1.5rem;
    font-weight: 800;
    letter-spacing: -0.02em;
    margin-bottom: 1.75rem;
}

.form-group {
    margin-bottom: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
}

.form-group label {
    color: var(--accent);
    font-weight: 700;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 0.8rem 1rem;
    background: var(--bg);
    border: 1px solid var(--border);
    color: var(--text);
    border-radius: var(--r-sm);
    font-size: 0.95rem;
    font-family: inherit;
    outline: none;
    transition: border-color var(--ease), box-shadow var(--ease);
}

.form-group input:focus,
.form-group select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.form-group select option {
    background: var(--card);
}

.form-group .hint {
    font-size: 0.8rem;
    color: var(--subtle);
}

#editor {
    height: 400px;
    background: var(--bg);
    color: var(--text);
    border: 1px solid var(--border);
    border-bottom-left-radius: var(--r-sm);
    border-bottom-right-radius: var(--r-sm);
}

.ql-toolbar {
    background: #1e3a5f !important;
    border-color: var(--border) !important;
    border-top-left-radius: var(--r-sm);
    border-top-right-radius: var(--r-sm);
    display: flex;
    flex-wrap: wrap;
}

.ql-toolbar .ql-stroke {
    stroke: var(--muted);
}

.ql-toolbar .ql-fill {
    fill: var(--muted);
}

.ql-toolbar button:hover .ql-stroke {
    stroke: var(--accent);
}

/* ── Tutorial Detail ──────────────────────── */
.tutorial-container {
    max-width: 800px;
    margin: 2rem auto;
    padding: 2rem 1.5rem;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
}

.portada-detalle {
    width: 100%;
    max-height: 420px;
    object-fit: cover;
    border-radius: var(--r-md);
    margin-bottom: 2rem;
    display: block;
}

.meta-datos {
    color: var(--muted);
    font-size: 0.875rem;
    margin: 0.75rem 0 2rem;
    padding-bottom: 1.25rem;
    border-bottom: 1px solid var(--border);
}

.ql-editor {
    padding: 0 !important;
    font-size: 1.05rem;
    line-height: 1.8;
    color: var(--text);
    font-family: inherit;
}

.ql-editor img {
    max-width: 100%;
    border-radius: var(--r-sm);
    margin: 1rem 0;
}

.ql-editor h1,
.ql-editor h2,
.ql-editor h3 {
    color: var(--text);
    margin: 1.5rem 0 0.5rem;
}

.ql-editor p {
    margin-bottom: 1rem;
}

.ql-editor pre {
    background: var(--bg);
    padding: 1rem;
    border-radius: var(--r-sm);
    overflow-x: auto;
    font-size: 0.9rem;
}

.ql-editor blockquote {
    border-left: 3px solid var(--accent);
    padding-left: 1rem;
    color: var(--muted);
    margin: 1rem 0;
}

/* ── Footer ───────────────────────────────── */
footer {
    background: var(--bg2);
    padding: 2rem;
    text-align: center;
    color: var(--subtle);
    font-size: 0.875rem;
    border-top: 1px solid var(--border);
}

footer p {
    margin: 0.3rem 0;
}

/* ── Animations ───────────────────────────── */
@keyframes fadeUp {
    from {
        opacity: 0;
        transform: translateY(14px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ── Responsive ───────────────────────────── */
@media (max-width: 1024px) {
    .header-center {
        max-width: 350px;
    }

    .admin-stats {
        grid-template-columns: repeat(2, 1fr);
    }

    .hero h1 {
        font-size: clamp(1.8rem, 4vw, 2.5rem);
    }
}

@media (max-width: 768px) {
    header {
        padding: 0.75rem 1rem;
        flex-wrap: wrap;
    }

    .header-center {
        order: 3;
        max-width: 100%;
        width: 100%;
        flex: unset;
        margin-top: 0.5rem;
    }

    .header-left {
        flex: 1;
    }

    .header-right {
        flex-shrink: 0;
    }

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

    .hero {
        padding: 2.5rem 1rem 1.5rem;
    }

    .auth-container {
        margin: 2rem 1rem;
        padding: 1.5rem;
    }

    .form-container {
        margin: 1rem;
        padding: 1.5rem 1rem 2rem;
    }

    .tutorial-container {
        margin: 1rem;
        padding: 1.25rem 1rem;
    }

    .admin-container {
        padding: 1.5rem 1rem 3rem;
    }

    .admin-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }

    .td-fecha {
        display: none;
    }

    /* Flex fixes for small screens */
    .perfil-card {
        flex-direction: column;
        text-align: center;
        gap: 1rem;
        padding: 1.25rem;
    }

    .serie-item {
        flex-direction: column;
        gap: 0.5rem;
        padding: 1.25rem;
    }

    .tutorial-actions {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
        padding: 1rem 0;
    }

    .admin-stats {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 480px) {
    .user-welcome {
        display: none;
    }

    .btn {
        padding: 0.45rem 0.8rem;
        font-size: 0.8rem;
    }

    .filtro-chip {
        padding: 0.3rem 0.8rem;
        font-size: 0.8rem;
    }

    .auth-container {
        margin: 1rem;
        padding: 1.5rem 1rem;
    }

    .container {
        padding: 0 1rem;
    }

    .hero {
        padding: 1.5rem 1rem;
    }
}

/* ── Filtros de categoría ─────────────────────────────── */
.filtros-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    padding: 0 0 1.5rem;
}

.filtro-chip {
    padding: 0.4rem 1rem;
    border-radius: 50px;
    border: 1px solid var(--border);
    background: var(--card);
    color: var(--muted);
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    font-family: inherit;
    transition: background var(--ease), color var(--ease), border-color var(--ease), transform var(--ease);
}

.filtro-chip:hover {
    border-color: var(--accent);
    color: var(--accent);
    transform: translateY(-1px);
}

.filtro-chip.activo {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
    font-weight: 600;
}

/* ── Comentarios ──────────────────────────────────────── */
.comentarios-section {
    margin-top: 3rem;
    padding-top: 2rem;
    border-top: 1px solid var(--border);
}

.comentarios-titulo {
    font-size: 1.3rem;
    font-weight: 700;
    margin-bottom: 1.5rem;
    letter-spacing: -0.01em;
}

.comentario {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    padding: 1rem 1.25rem;
    margin-bottom: 1rem;
    animation: fadeUp 0.3s ease;
}

.comentario-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
    gap: 1rem;
    flex-wrap: wrap;
}

.comentario-autor {
    font-weight: 700;
    font-size: 0.9rem;
    color: var(--accent);
}

.comentario-fecha {
    font-size: 0.78rem;
    color: var(--subtle);
}

.comentario-texto {
    color: var(--text);
    font-size: 0.95rem;
    line-height: 1.6;
    margin: 0;
    white-space: pre-wrap;
    word-break: break-word;
}

.sin-comentarios {
    color: var(--muted);
    font-style: italic;
    padding: 1rem 0;
    margin-bottom: 1.5rem;
}

.comentario-nuevo {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    padding: 1.5rem;
    margin-top: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.comentario-nuevo h4 {
    font-size: 1rem;
    font-weight: 700;
    margin: 0;
}

.comentario-nuevo textarea {
    width: 100%;
    padding: 0.8rem 1rem;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--r-sm);
    color: var(--text);
    font-family: inherit;
    font-size: 0.95rem;
    resize: vertical;
    outline: none;
    transition: border-color var(--ease), box-shadow var(--ease);
    min-height: 100px;
}

.comentario-nuevo textarea:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.login-prompt {
    color: var(--muted);
    font-size: 0.9rem;
    margin-top: 1.5rem;
    padding: 1rem;
    background: var(--card);
    border-radius: var(--r-md);
    border: 1px solid var(--border);
    text-align: center;
}

.login-prompt a {
    color: var(--accent);
    font-weight: 600;
    text-decoration: none;
}

.login-prompt a:hover {
    text-decoration: underline;
}

/* ── Admin Tabs ───────────────────────────────────────── */
.admin-tabs {
    display: flex;
    gap: 0;
    border-bottom: 1px solid var(--border);
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}

.admin-tab {
    padding: 0.75rem 1.4rem;
    border: none;
    background: transparent;
    color: var(--muted);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    transition: color var(--ease), border-color var(--ease);
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.admin-tab:hover {
    color: var(--text);
}

.admin-tab.activo {
    color: var(--accent);
    border-bottom-color: var(--accent);
}

.tab-content {
    display: none;
}

.tab-content.activo {
    display: block;
    animation: fadeUp 0.25s ease;
}

/* ── Admin Stats ──────────────────────────────────────── */
.admin-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    padding: 1.25rem 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    transition: border-color var(--ease), transform var(--ease);
}

.stat-card:hover {
    border-color: var(--accent);
    transform: translateY(-2px);
}

.stat-num {
    font-size: 2.2rem;
    font-weight: 800;
    color: var(--accent);
    letter-spacing: -0.03em;
    line-height: 1;
}

.stat-label {
    font-size: 0.8rem;
    color: var(--muted);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* ── Role badges ──────────────────────────────────────── */
.role-badge {
    display: inline-flex;
    align-items: center;
    padding: 0.2rem 0.65rem;
    border-radius: 50px;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.role-badge.admin {
    background: rgba(16, 185, 129, 0.12);
    color: var(--green);
    border: 1px solid rgba(16, 185, 129, 0.3);
}

.role-badge.usuario {
    background: rgba(148, 163, 184, 0.1);
    color: var(--muted);
    border: 1px solid rgba(148, 163, 184, 0.25);
}

.role-badge.autor {
    background: rgba(59, 130, 246, 0.12);
    color: var(--accent);
    border: 1px solid rgba(59, 130, 246, 0.3);
}

/* ── Comment preview ──────────────────────────────────── */
.comment-preview {
    max-width: 300px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--muted);
    font-size: 0.875rem;
}

@media (max-width: 640px) {
    .admin-stats {
        grid-template-columns: 1fr;
    }

    .admin-tab {
        padding: 0.6rem 0.9rem;
        font-size: 0.8rem;
    }
}

/* ── Publish mode tabs ────────────────────────────────── */
.publish-options {
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border);
}

.form-label-small {
    display: block;
    color: var(--accent);
    font-weight: 700;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.6rem;
}

.pub-tabs {
    display: flex;
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    overflow: hidden;
}

.pub-tab {
    flex: 1;
    padding: 0.65rem 0.5rem;
    border: none;
    background: var(--bg);
    color: var(--muted);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    transition: background var(--ease), color var(--ease);
    border-right: 1px solid var(--border);
}

.pub-tab:last-child {
    border-right: none;
}

.pub-tab:hover {
    background: var(--card);
    color: var(--text);
}

.pub-tab.activo {
    background: var(--accent);
    color: #fff;
}

.datetime-input {
    width: 100%;
    padding: 0.8rem 1rem;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--r-sm);
    color: var(--text);
    font-family: inherit;
    font-size: 0.95rem;
    outline: none;
    transition: border-color var(--ease), box-shadow var(--ease);
    color-scheme: dark;
}

.datetime-input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

/* ── Estado badges ────────────────────────────────────── */
.estado-badge {
    display: inline-flex;
    align-items: center;
    padding: 0.15rem 0.6rem;
    border-radius: 50px;
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.estado-badge.publicado {
    background: rgba(16, 185, 129, 0.12);
    color: var(--green);
    border: 1px solid rgba(16, 185, 129, 0.3);
}

.estado-badge.borrador {
    background: rgba(148, 163, 184, 0.1);
    color: var(--muted);
    border: 1px solid rgba(148, 163, 184, 0.25);
}

.estado-badge.programado {
    background: rgba(59, 130, 246, 0.12);
    color: var(--accent);
    border: 1px solid rgba(59, 130, 246, 0.3);
}

/* ── Barra de progreso de lectura ─────────────────────── */
#reading-progress {
    position: fixed;
    top: 0;
    left: 0;
    height: 3px;
    z-index: 9999;
    background: linear-gradient(90deg, var(--accent), #a78bfa);
    width: 0%;
    transition: width 0.1s linear;
    box-shadow: 0 0 8px var(--accent-glow);
}

/* ── Card meta (visitas, likes, tiempo) ───────────────── */
.card-meta {
    display: flex;
    gap: 1rem;
    font-size: 0.8rem;
    color: var(--muted);
    margin-bottom: 0.75rem;
    flex-wrap: wrap;
}

/* ── Highlight búsqueda ───────────────────────────────── */
mark {
    background: rgba(251, 191, 36, 0.25);
    color: inherit;
    border-radius: 2px;
    padding: 0 2px;
}

/* ── Paginación ───────────────────────────────────────── */
.paginacion {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    padding: 2rem 0;
    flex-wrap: wrap;
}

/* ── Tutorial actions (like + share) ─────────────────── */
.tutorial-actions {
    display: flex;
    gap: 1rem;
    align-items: center;
    padding: 1.5rem 0;
    border-top: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
    margin: 2rem 0;
}

.btn-like {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.6rem 1.2rem;
    border-radius: 50px;
    border: 1px solid var(--border);
    background: var(--card);
    color: var(--text);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    transition: all var(--ease);
}

.btn-like:hover {
    border-color: #ef4444;
    color: #ef4444;
    transform: scale(1.05);
}

.btn-like.liked {
    border-color: #ef4444;
    color: #ef4444;
    background: rgba(239, 68, 68, 0.08);
}

/* ── TOC ──────────────────────────────────────────────── */
.toc-box {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    padding: 1.25rem 1.5rem;
    margin-bottom: 2rem;
}

.toc-title {
    font-size: 0.9rem;
    font-weight: 700;
    display: block;
    margin-bottom: 0.75rem;
}

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

.toc-link {
    color: var(--muted);
    font-size: 0.875rem;
    text-decoration: none;
    transition: color var(--ease);
}

.toc-link:hover {
    color: var(--accent);
}

/* ── Tutoriales relacionados ──────────────────────────── */
.relacionados-section {
    margin: 2rem 0;
}

.relacionados-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1rem;
    margin-top: 1rem;
}

.relacionado-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    padding: 1rem;
    text-decoration: none;
    color: var(--text);
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    transition: border-color var(--ease), transform var(--ease);
}

.relacionado-card:hover {
    border-color: var(--accent);
    transform: translateY(-2px);
}

.relacionado-card strong {
    font-size: 0.9rem;
    line-height: 1.4;
}

/* ── Perfil ───────────────────────────────────────────── */
.perfil-card {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    padding: 1.5rem;
    margin-bottom: 2rem;
}

.perfil-avatar {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent), #a78bfa);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.8rem;
    font-weight: 800;
    color: #fff;
    flex-shrink: 0;
}

.perfil-info h1 {
    font-size: 1.5rem;
    font-weight: 800;
    margin: 0 0 0.25rem;
}

.comentario-autor {
    color: var(--accent);
    font-weight: 700;
    font-size: 0.9rem;
    text-decoration: none;
}

.comentario-autor:hover {
    text-decoration: underline;
}

/* ── Serie lista ──────────────────────────────────────── */
.serie-lista {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.serie-item {
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    padding: 1rem 1.25rem;
    text-decoration: none;
    color: var(--text);
    transition: border-color var(--ease), transform var(--ease);
}

.serie-item:hover {
    border-color: var(--accent);
    transform: translateX(4px);
}

.serie-num {
    min-width: 32px;
    height: 32px;
    background: var(--accent-glow);
    border: 1px solid var(--accent);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 0.85rem;
    color: var(--accent);
    flex-shrink: 0;
}

/* ── Admin stats bars ─────────────────────────────────── */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.stat-box {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    padding: 1.25rem;
    text-align: center;
}

.stat-box-num {
    font-size: 2rem;
    font-weight: 800;
    color: var(--accent);
    display: block;
}

.stat-box-label {
    font-size: 0.78rem;
    color: var(--muted);
    font-weight: 600;
    text-transform: uppercase;
}

.top-lista {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.top-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.top-bar-wrap {
    flex: 1;
    background: var(--border);
    border-radius: 4px;
    height: 8px;
    overflow: hidden;
}

.top-bar {
    height: 100%;
    background: var(--accent);
    border-radius: 4px;
    transition: width 0.5s ease;
}

.top-label {
    font-size: 0.85rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 200px;
    color: var(--text);
}

.top-value {
    font-size: 0.8rem;
    color: var(--muted);
    font-weight: 700;
    white-space: nowrap;
}


/* ── User welcome como enlace ─────────────────────────── */
a.user-welcome {
    color: var(--text);
    text-decoration: none;
    font-size: 0.9rem;
    padding: 0.3rem 0.6rem;
    border-radius: var(--r-sm);
    transition: background var(--ease), color var(--ease);
}

a.user-welcome:hover {
    background: var(--card);
    color: var(--accent);
}

/* ── Botón volver arriba ──────────────────────────────── */
#btn-top {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--accent);
    color: #fff;
    border: none;
    font-size: 1.2rem;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(59, 130, 246, 0.35);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--ease), transform var(--ease);
    z-index: 100;
}

#btn-top.visible {
    opacity: 1;
    pointer-events: auto;
}

#btn-top:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 24px rgba(59, 130, 246, 0.45);
}

/* ── Ordenar tutoriales ───────────────────────────────── */
.sort-bar {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}

.sort-bar label {
    color: var(--muted);
    font-size: 0.85rem;
    font-weight: 600;
}

.sort-select {
    padding: 0.4rem 0.8rem;
    background: var(--card);
    border: 1px solid var(--border);
    color: var(--text);
    border-radius: var(--r-sm);
    font-family: inherit;
    font-size: 0.85rem;
    cursor: pointer;
    outline: none;
    transition: border-color var(--ease);
}

.sort-select:focus {
    border-color: var(--accent);
}

/* ── Cabeceras de Código Modernas ───────────────────────── */
.code-block-wrapper {
    margin: 1.5rem 0;
    border-radius: var(--r-md);
    overflow: hidden;
    background: #1e1e1e;
    border: 1px solid var(--border);
}

.code-block-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 1rem;
    background: #2d2d2d;
    border-bottom: 1px solid #404040;
}

.code-block-lang {
    color: #a3a3a3;
    font-size: 0.75rem;
    font-family: monospace;
    text-transform: uppercase;
    font-weight: 600;
}

.code-copy-btn {
    background: transparent;
    border: none;
    color: #a3a3a3;
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    transition: color var(--ease);
    display: flex;
    align-items: center;
    gap: 0.3rem;
}

.code-copy-btn:hover {
    color: #ffffff;
}

.ql-editor pre.ql-syntax {
    margin: 0 !important;
    border-radius: 0 !important;
    background: #1e1e1e !important;
    border: none !important;
    padding: 1rem !important;
}

/* ── Mejoras UX Adicionales ───────────────────────────── */
.comentario-nuevo .ql-editor.ql-blank::before {
    color: var(--text) !important;
    opacity: 0.8;
    font-style: normal;
}

.comentario-hijo {
    margin-left: 2.5rem;
    border-left: 2px solid var(--accent);
    padding-left: 1rem;
    margin-top: 0.5rem;
}

.btn-responder {
    background: none;
    border: none;
    color: var(--muted);
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    padding: 0;
    transition: color var(--ease);
}
.btn-responder:hover {
    color: var(--accent);
}

.password-strength-container {
    height: 4px;
    background: var(--border);
    border-radius: 2px;
    margin-top: -0.5rem;
    margin-bottom: 0.5rem;
    overflow: hidden;
}
.password-strength-bar {
    height: 100%;
    width: 0%;
    transition: width 0.3s ease, background 0.3s ease;
}
.email-valid { border-color: var(--green) !important; }
.email-invalid { border-color: var(--red) !important; }