/* ── Reset & Variables ────────────────────────────────────────────────────── */
:root {
    --primary:        #7c3aed;
    --primary-hover:  #6d28d9;
    --primary-light:  #ede9fe;
    --brand:          #7c3aed;
    --bg:             #f3f4f6;
    --bg-secondary:   #f9fafb;
    --white:          #ffffff;
    --text:           #111827;
    --text-primary:   #111827;
    --text-secondary: #374151;
    --text-muted:     #6b7280;
    --border:         #e5e7eb;
    --radius:         10px;
    --shadow:         0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.04);
    --shadow-md:      0 4px 6px rgba(0,0,0,.07), 0 2px 4px rgba(0,0,0,.05);
}

/* ── Dark Mode CSS variable overrides ───────────────────────────────────────── */
html.dark {
    --bg:             #111827;
    --bg-secondary:   #1f2937;
    --white:          #1f2937;
    --text:           #f3f4f6;
    --text-primary:   #f3f4f6;
    --text-secondary: #d1d5db;
    --text-muted:     #9ca3af;
    --border:         #374151;
    --shadow:         0 1px 3px rgba(0,0,0,.4), 0 1px 2px rgba(0,0,0,.3);
}
html.dark .card,
html.dark .post-card,
html.dark .event-card,
html.dark .lesson-card,
html.dark .form-card { background: #1f2937; border-color: #374151; }
html.dark .navbar,
html.dark .sub-nav   { background: #1f2937; border-color: #374151; }

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    font-size: 15px;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

img { max-width: 100%; display: block; }

/* ── Top Navbar ──────────────────────────────────────────────────────────── */
.navbar {
    background: var(--white);
    border-bottom: 1px solid var(--border);
    height: 58px;
    display: flex;
    align-items: center;
    padding: 0 20px;
    position: sticky;
    top: 0;
    z-index: 200;
    gap: 16px;
}

.navbar-brand {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--primary);
    text-decoration: none;
    flex-shrink: 0;
}

.navbar-user {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.875rem;
    color: var(--text-muted);
}

.navbar-user strong { color: var(--text); }

.btn-link {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 0.875rem;
    padding: 4px 8px;
    border-radius: 6px;
    text-decoration: none;
}
.btn-link:hover { background: var(--bg); color: var(--text); text-decoration: none; }

/* ── 3-Column Layout ─────────────────────────────────────────────────────── */
.layout {
    display: grid;
    grid-template-columns: 220px 1fr 260px;
    gap: 20px;
    max-width: 1280px;
    margin: 24px auto;
    padding: 0 16px;
    align-items: start;
}

/* ── Left Sidebar ────────────────────────────────────────────────────────── */
.sidebar-left {
    position: sticky;
    top: 78px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.nav-menu { list-style: none; display: flex; flex-direction: column; gap: 2px; }

.nav-menu a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    border-radius: 8px;
    color: var(--text);
    font-size: 0.9rem;
    font-weight: 500;
    text-decoration: none;
    transition: background .15s;
}
.nav-menu a:hover { background: var(--bg); }
.nav-menu a.active { background: var(--primary-light); color: var(--primary); }

.nav-icon { width: 20px; text-align: center; }

/* ── Right Sidebar ───────────────────────────────────────────────────────── */
.sidebar-right {
    position: sticky;
    top: 78px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* ── Card ────────────────────────────────────────────────────────────────── */
.card {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    box-shadow: var(--shadow);
}

.card-title {
    font-size: 0.8rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--text-muted);
    margin-bottom: 12px;
}

/* ── User Profile Card ───────────────────────────────────────────────────── */
.profile-card {
    text-align: center;
    padding: 20px 16px;
}

.avatar {
    width: 52px; height: 52px;
    border-radius: 50%;
    background: var(--primary-light);
    color: var(--primary);
    font-size: 1.3rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 8px;
    flex-shrink: 0;
}

.avatar-sm { width: 32px; height: 32px; font-size: 0.8rem; }
.avatar-xs { width: 24px; height: 24px; font-size: 0.65rem; }

.profile-name { font-weight: 600; font-size: 0.95rem; }
.profile-meta { font-size: 0.78rem; color: var(--text-muted); margin-top: 2px; }

.level-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 0.72rem;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 20px;
    margin-top: 6px;
    color: #fff;
}

.points-bar-wrap { margin-top: 10px; }
.points-bar-label { font-size: 0.72rem; color: var(--text-muted); margin-bottom: 4px; display: flex; justify-content: space-between; }
.points-bar { height: 6px; background: var(--border); border-radius: 4px; overflow: hidden; }
.points-bar-fill { height: 100%; background: var(--primary); border-radius: 4px; transition: width .4s; }

/* ── Buttons ─────────────────────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 9px 18px;
    border-radius: 8px;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: background .15s, transform .1s;
    text-decoration: none;
}
.btn:active { transform: scale(.97); }
.btn:hover { text-decoration: none; }

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

.btn-outline { background: transparent; color: var(--primary); border: 1.5px solid var(--primary); }
.btn-outline:hover { background: var(--primary-light); }

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

.btn-sm { padding: 5px 12px; font-size: 0.8rem; }
.btn-full { width: 100%; }

/* ── Forms ───────────────────────────────────────────────────────────────── */
.form-group { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }

label { font-size: 0.875rem; font-weight: 500; }

input[type="text"],
input[type="email"],
input[type="password"],
textarea,
select {
    width: 100%;
    padding: 9px 12px;
    border: 1.5px solid var(--border);
    border-radius: 8px;
    font-size: 0.9rem;
    font-family: inherit;
    background: var(--white);
    color: var(--text);
    transition: border-color .15s;
}
input:focus, textarea:focus, select:focus {
    outline: none;
    border-color: var(--primary);
}
textarea { resize: vertical; min-height: 80px; }

.form-error {
    background: #fef2f2;
    border: 1px solid #fca5a5;
    color: #991b1b;
    padding: 10px 14px;
    border-radius: 8px;
    font-size: 0.875rem;
    margin-bottom: 16px;
}

.form-success {
    background: #f0fdf4;
    border: 1px solid #86efac;
    color: #166534;
    padding: 10px 14px;
    border-radius: 8px;
    font-size: 0.875rem;
    margin-bottom: 16px;
}

/* ── Auth Pages ──────────────────────────────────────────────────────────── */
.auth-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px 16px;
    background: var(--bg);
}

.auth-box {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 36px;
    width: 100%;
    max-width: 400px;
    box-shadow: var(--shadow-md);
}

.auth-logo { text-align: center; margin-bottom: 24px; }
.auth-logo h1 { font-size: 1.6rem; color: var(--primary); font-weight: 800; }
.auth-logo p { color: var(--text-muted); font-size: 0.875rem; margin-top: 4px; }
.auth-footer { text-align: center; margin-top: 20px; font-size: 0.875rem; color: var(--text-muted); }

/* ── Post Card ───────────────────────────────────────────────────────────── */
.post-card {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px;
    box-shadow: var(--shadow);
    margin-bottom: 12px;
    transition: border-color .15s;
}
.post-card:hover { border-color: #d1d5db; }

.post-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
}

.post-author-name { font-weight: 600; font-size: 0.875rem; }
.post-time { color: var(--text-muted); font-size: 0.78rem; margin-left: auto; }

.category-badge {
    font-size: 0.7rem;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 20px;
    text-transform: uppercase;
    letter-spacing: .04em;
}
.cat-general   { background: #e0f2fe; color: #0369a1; }
.cat-anuncios  { background: #fef3c7; color: #92400e; }
.cat-preguntas { background: #ede9fe; color: #6d28d9; }
.cat-logros    { background: #d1fae5; color: #065f46; }

.post-title { font-size: 1rem; font-weight: 700; margin-bottom: 6px; }
.post-title a { color: var(--text); }
.post-title a:hover { color: var(--primary); text-decoration: none; }

.post-content { color: #374151; font-size: 0.9rem; line-height: 1.65; }
.post-content-preview {
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Quill-rendered HTML inside posts and comments */
.quill-content p     { margin: 0 0 0.5em; }
.quill-content p:last-child { margin-bottom: 0; }
.quill-content ul, .quill-content ol { margin: 0.4em 0 0.4em 1.4em; padding: 0; }
.quill-content li    { margin-bottom: 2px; }
.quill-content blockquote {
    border-left: 3px solid var(--primary);
    padding-left: 10px;
    margin: 6px 0;
    color: var(--text-muted);
    font-style: italic;
}
.quill-content a     { color: var(--primary); text-decoration: underline; }
.quill-content strong { font-weight: 700; }
.quill-content em    { font-style: italic; }
.quill-content pre   { background: #f3f4f6; border-radius: 4px; padding: 8px 12px; font-size: 0.82rem; overflow-x: auto; }

/* Override Quill Snow theme border inside forms */
#quill-post-editor .ql-container,
#quill-comment-editor .ql-container { border-color: #d1d5db; border-radius: 0 0 4px 4px; }
#quill-post-editor .ql-toolbar,
#quill-comment-editor .ql-toolbar  { border-color: #d1d5db; border-radius: 4px 4px 0 0; }

.post-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 14px;
    padding-top: 12px;
    border-top: 1px solid var(--border);
}

/* ── Like Button ─────────────────────────────────────────────────────────── */
.like-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    background: var(--bg);
    border: 1.5px solid var(--border);
    border-radius: 20px;
    padding: 5px 12px;
    cursor: pointer;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-muted);
    transition: all .2s;
    font-family: inherit;
}
.like-btn:hover { border-color: #f87171; color: #dc2626; }
.like-btn.liked  { border-color: #f87171; background: #fef2f2; color: #dc2626; }
.like-btn svg { width: 14px; height: 14px; }

.comment-count-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 0.82rem;
    color: var(--text-muted);
    text-decoration: none;
    padding: 5px 10px;
    border-radius: 20px;
}
.comment-count-btn:hover { background: var(--bg); color: var(--text); text-decoration: none; }

/* ── Create Post Form ────────────────────────────────────────────────────── */
.create-post-card { margin-bottom: 16px; }
.create-post-toggle {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    color: var(--text-muted);
    font-size: 0.9rem;
}
.create-post-input-fake {
    flex: 1;
    background: var(--bg);
    border: 1.5px solid var(--border);
    border-radius: 20px;
    padding: 8px 16px;
    font-size: 0.875rem;
    color: var(--text-muted);
}
.create-post-input-fake:hover { border-color: var(--primary); }

#create-post-form { display: none; margin-top: 14px; }
#create-post-form.open { display: block; }

/* ── Comments ────────────────────────────────────────────────────────────── */
.comments-section { margin-top: 20px; }
.comments-title { font-weight: 700; margin-bottom: 14px; font-size: 0.95rem; }

.comment {
    display: flex;
    gap: 10px;
    margin-bottom: 14px;
}
.comment-body { flex: 1; }
.comment-bubble {
    background: var(--bg);
    border-radius: 0 10px 10px 10px;
    padding: 10px 14px;
    font-size: 0.875rem;
    line-height: 1.55;
}
.comment-author { font-weight: 600; font-size: 0.8rem; margin-bottom: 2px; }
.comment-meta { font-size: 0.72rem; color: var(--text-muted); margin-top: 5px; display: flex; gap: 10px; }
.reply-toggle { cursor: pointer; color: var(--primary); background: none; border: none; font-size: 0.72rem; font-family: inherit; }
.reply-toggle:hover { text-decoration: underline; }

.comment-replies { margin-left: 42px; margin-top: 10px; }

.reply-form { margin-top: 8px; display: none; }
.reply-form.open { display: flex; gap: 8px; }
.reply-input { flex: 1; }

.add-comment-form { display: flex; gap: 10px; align-items: flex-start; margin-top: 16px; }
.add-comment-form textarea { min-height: 60px; }

/* ── Leaderboard ─────────────────────────────────────────────────────────── */
.leaderboard-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 0;
    border-bottom: 1px solid var(--border);
    font-size: 0.82rem;
}
.leaderboard-item:last-child { border-bottom: none; }
.lb-rank { width: 18px; font-weight: 700; color: var(--text-muted); flex-shrink: 0; text-align: center; }
.lb-name { flex: 1; font-weight: 500; }
.lb-pts  { color: var(--primary); font-weight: 600; }

/* ── Upcoming Events (sidebar) ───────────────────────────────────────────── */
.event-item { padding: 8px 0; border-bottom: 1px solid var(--border); font-size: 0.82rem; }
.event-item:last-child { border-bottom: none; }
.event-item-date { font-size: 0.72rem; color: var(--text-muted); }
.event-item-title { font-weight: 600; margin-top: 1px; }

/* ── Classroom ───────────────────────────────────────────────────────────── */
.courses-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 16px;
    margin-top: 8px;
}

.course-card {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    gap: 10px;
    position: relative;
}

.course-card.locked { opacity: .7; }

.course-icon {
    width: 44px; height: 44px;
    border-radius: 10px;
    background: var(--primary-light);
    display: flex; align-items: center; justify-content: center;
    font-size: 1.4rem;
}

.course-title { font-weight: 700; font-size: 0.95rem; }
.course-desc  { font-size: 0.82rem; color: var(--text-muted); line-height: 1.5; flex: 1; }

.lock-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    padding: 3px 10px;
    border-radius: 20px;
    background: #f3f4f6;
    color: #6b7280;
    width: fit-content;
}

/* ── Lesson Player ───────────────────────────────────────────────────────── */
.classroom-layout {
    display: grid;
    grid-template-columns: 280px 1fr;
    gap: 0;
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    min-height: 500px;
    box-shadow: var(--shadow);
}

.lesson-sidebar {
    border-right: 1px solid var(--border);
    overflow-y: auto;
    max-height: 80vh;
}

.lesson-sidebar-header {
    padding: 16px;
    font-weight: 700;
    font-size: 0.875rem;
    border-bottom: 1px solid var(--border);
    background: var(--bg);
    position: sticky; top: 0;
}

.module-group { border-bottom: 1px solid var(--border); }
.module-title { padding: 10px 16px; font-size: 0.8rem; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: .04em; }

.lesson-link {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 9px 16px 9px 24px;
    font-size: 0.85rem;
    color: var(--text);
    text-decoration: none;
    border-left: 3px solid transparent;
    transition: background .15s;
}
.lesson-link:hover { background: var(--bg); text-decoration: none; }
.lesson-link.active { border-left-color: var(--primary); background: var(--primary-light); color: var(--primary); font-weight: 600; }

.lesson-main { padding: 24px; overflow-y: auto; }
.lesson-main h1 { font-size: 1.2rem; margin-bottom: 16px; }

.video-wrapper {
    position: relative;
    padding-top: 56.25%;
    border-radius: 8px;
    overflow: hidden;
    background: #000;
    margin-bottom: 20px;
}
.video-wrapper iframe { position: absolute; top: 0; left: 0; width: 100%; height: 100%; border: none; }

.lesson-content { font-size: 0.9rem; line-height: 1.75; color: #374151; }

/* ── Events ──────────────────────────────────────────────────────────────── */
.event-card {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
    display: flex;
    gap: 16px;
    margin-bottom: 12px;
    align-items: flex-start;
}

.event-date-block {
    flex-shrink: 0;
    text-align: center;
    background: var(--primary-light);
    color: var(--primary);
    border-radius: 10px;
    padding: 10px 14px;
    min-width: 58px;
}
.event-date-day   { font-size: 1.4rem; font-weight: 800; line-height: 1; }
.event-date-month { font-size: 0.72rem; font-weight: 600; text-transform: uppercase; }

.event-info { flex: 1; }
.event-title { font-weight: 700; margin-bottom: 4px; }
.event-desc  { font-size: 0.875rem; color: var(--text-muted); margin-bottom: 10px; }
.event-time  { font-size: 0.8rem; color: var(--text-muted); margin-bottom: 8px; }

/* ── Page Header ─────────────────────────────────────────────────────────── */
.page-header { margin-bottom: 16px; }
.page-header h1 { font-size: 1.25rem; font-weight: 800; }
.page-header p  { font-size: 0.875rem; color: var(--text-muted); margin-top: 2px; }

/* ── Sort Bar ────────────────────────────────────────────────────────────── */
.sort-bar { display: flex; gap: 6px; margin-bottom: 14px; }
.sort-btn {
    padding: 5px 14px; border-radius: 20px; font-size: 0.8rem; font-weight: 600;
    cursor: pointer; border: 1.5px solid var(--border); background: var(--white); color: var(--text-muted);
    text-decoration: none;
}
.sort-btn.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.sort-btn:hover { text-decoration: none; border-color: var(--primary); color: var(--primary); }
.sort-btn.active:hover { color: #fff; }

/* ── Navbar Search ───────────────────────────────────────────────────────────── */
.navbar-search {
    flex: 1;
    max-width: 420px;
    display: flex;
    gap: 0;
    margin: 0 16px;
}

.navbar-search input[type="search"] {
    flex: 1;
    padding: 7px 14px;
    border: 1.5px solid var(--border);
    border-right: none;
    border-radius: 8px 0 0 8px;
    font-size: 0.875rem;
    background: var(--bg);
    color: var(--text);
    min-width: 0;
}
.navbar-search input[type="search"]:focus {
    outline: none;
    border-color: var(--primary);
    background: var(--white);
}

.navbar-search button {
    padding: 7px 12px;
    border: 1.5px solid var(--border);
    border-left: none;
    border-radius: 0 8px 8px 0;
    background: var(--white);
    cursor: pointer;
    font-size: 0.875rem;
    transition: background .15s;
}
.navbar-search button:hover { background: var(--bg); }

/* ── Filter Toolbar (feed) ───────────────────────────────────────────────────── */
.filter-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 14px;
    align-items: center;
}

.filter-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-left: auto;
}

/* ── Pagination ──────────────────────────────────────────────────────────────── */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    margin-top: 20px;
    padding: 12px 0;
}

.page-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 34px;
    height: 34px;
    padding: 0 10px;
    border: 1.5px solid var(--border);
    border-radius: 8px;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-muted);
    background: var(--white);
    text-decoration: none;
    transition: all .15s;
}
.page-btn:hover { border-color: var(--primary); color: var(--primary); text-decoration: none; }
.page-btn.active { background: var(--primary); border-color: var(--primary); color: #fff; }

.page-ellipsis {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 34px;
    height: 34px;
    font-size: 0.82rem;
    color: var(--text-muted);
}

/* ── Search Results ──────────────────────────────────────────────────────────── */
.search-section-title {
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--text-muted);
    margin: 20px 0 10px;
}

.search-comment-card { margin-bottom: 10px; }
.search-lesson-card  { margin-bottom: 10px; }

.search-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 16px;
    border-bottom: 2px solid var(--border);
    padding-bottom: 0;
}

.search-tab {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-muted);
    text-decoration: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: color .15s, border-color .15s;
}
.search-tab:hover { color: var(--text); text-decoration: none; }
.search-tab.active { color: var(--primary); border-bottom-color: var(--primary); }

.search-tab-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 20px;
    font-size: 0.7rem;
    font-weight: 700;
    padding: 1px 6px;
    min-width: 20px;
}
.search-tab.active .search-tab-badge { background: var(--primary-light); border-color: var(--primary-light); color: var(--primary); }

.search-see-all {
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--primary);
    text-decoration: none;
    margin-left: auto;
}
.search-see-all:hover { text-decoration: underline; }

.search-section-title {
    display: flex;
    align-items: center;
}

/* ── Profile Page ────────────────────────────────────────────────────────────── */
.profile-header-card { margin-bottom: 16px; }

.profile-hero {
    display: flex;
    gap: 20px;
    align-items: flex-start;
    margin-bottom: 20px;
}

.profile-avatar {
    width: 72px;
    height: 72px;
    font-size: 1.8rem;
    flex-shrink: 0;
}

.profile-hero-info { flex: 1; }
.profile-hero-name { font-size: 1.3rem; font-weight: 800; margin-bottom: 2px; }

.profile-points-bar-wrap { margin-top: 12px; max-width: 340px; }

.profile-stats {
    display: flex;
    gap: 0;
    border-top: 1px solid var(--border);
    padding-top: 16px;
}

.stat-item {
    flex: 1;
    text-align: center;
    padding: 4px 0;
    border-right: 1px solid var(--border);
}
.stat-item:last-child { border-right: none; }

.stat-value { font-size: 1.3rem; font-weight: 800; color: var(--primary); line-height: 1.2; }
.stat-label { font-size: 0.72rem; color: var(--text-muted); margin-top: 2px; }

/* ── Post author link ────────────────────────────────────────────────────────── */
.post-author-link { color: var(--text); text-decoration: none; }
.post-author-link:hover { color: var(--primary); text-decoration: none; }

.lb-name { color: var(--text); text-decoration: none; }
.lb-name:hover { color: var(--primary); text-decoration: underline; }

/* ── Admin Panel ─────────────────────────────────────────────────────────── */
.admin-bar {
    display: flex;
    gap: 4px;
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 8px 12px;
    margin-bottom: 16px;
    flex-wrap: wrap;
    align-items: center;
}

.admin-tab {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    border-radius: 7px;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-muted);
    text-decoration: none;
    transition: background .15s, color .15s;
}
.admin-tab:hover { background: var(--bg); color: var(--text); text-decoration: none; }
.admin-tab.active { background: var(--primary-light); color: var(--primary); }

.admin-table-wrap { overflow-x: auto; }

.admin-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}
.admin-table th {
    text-align: left;
    padding: 8px 12px;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--text-muted);
    border-bottom: 1.5px solid var(--border);
    background: var(--bg);
}
.admin-table td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}
.admin-table tr:last-child td { border-bottom: none; }
.admin-table tr:hover td { background: var(--bg); }

/* ── Course Progress Bar ─────────────────────────────────────────────────── */
.course-progress { margin-top: 8px; }
.course-progress-bar {
    height: 6px;
    background: var(--border);
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 4px;
}
.course-progress-fill {
    height: 100%;
    background: var(--primary);
    border-radius: 4px;
    transition: width .4s;
}
.course-progress-label { font-size: 0.72rem; color: var(--text-muted); }

/* ── Event Attendees ─────────────────────────────────────────────────────── */
.event-attendees {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-top: 8px;
    flex-wrap: wrap;
}
.event-attendee-count { font-size: 0.78rem; color: var(--text-muted); margin-left: 4px; }
.rsvp-group { display: flex; gap: 6px; margin-top: 10px; flex-wrap: wrap; }

/* ── Notification Bell ───────────────────────────────────────────────────── */
.notif-bell {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 8px;
    cursor: pointer;
    transition: background .15s;
    flex-shrink: 0;
}
.notif-bell:hover { background: var(--bg); }

.notif-badge {
    position: absolute;
    top: 2px;
    right: 2px;
    background: #dc2626;
    color: #fff;
    border-radius: 20px;
    font-size: 0.6rem;
    font-weight: 700;
    padding: 1px 4px;
    min-width: 16px;
    text-align: center;
    line-height: 1.4;
    pointer-events: none;
}

.notif-dropdown {
    display: none;
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    width: 320px;
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    z-index: 500;
    overflow: hidden;
}
.notif-dropdown.open { display: block; }

.notif-header {
    padding: 12px 16px;
    font-weight: 700;
    font-size: 0.875rem;
    border-bottom: 1px solid var(--border);
    background: var(--bg);
}
.notif-footer {
    padding: 8px 12px;
    border-top: 1px solid var(--border);
    background: var(--bg);
}

#notif-list { max-height: 340px; overflow-y: auto; }

.notif-item {
    border-bottom: 1px solid var(--border);
    transition: background .15s;
}
.notif-item:last-child { border-bottom: none; }
.notif-item:hover { background: var(--bg); }
.notif-unread { background: #faf5ff; }
.notif-unread:hover { background: #f3e8ff; }

.notif-item-inner {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 10px 14px;
}

/* ── Conversation List ───────────────────────────────────────────────────── */
.conv-row { color: var(--text); transition: background .15s; }
.conv-row:hover { background: var(--bg); text-decoration: none; }
.conv-unread { background: #faf5ff; }
.conv-unread:hover { background: #f3e8ff; }

/* ── Chat Bubbles ────────────────────────────────────────────────────────── */
.chat-msg { display: flex; flex-direction: column; max-width: 72%; }
.chat-msg-mine { align-self: flex-end; align-items: flex-end; }
.chat-msg-theirs { align-self: flex-start; align-items: flex-start; }

.chat-msg-name { font-size: 0.72rem; color: var(--text-muted); margin-bottom: 3px; }

.chat-bubble {
    padding: 9px 14px;
    border-radius: 16px;
    font-size: 0.875rem;
    line-height: 1.5;
    word-break: break-word;
    white-space: pre-wrap;
}
.chat-msg-mine   .chat-bubble { background: var(--primary); color: #fff; border-bottom-right-radius: 4px; }
.chat-msg-theirs .chat-bubble { background: var(--bg); color: var(--text); border-bottom-left-radius: 4px; border: 1px solid var(--border); }

.chat-msg-time { font-size: 0.68rem; color: var(--text-muted); margin-top: 3px; }

/* ── Responsive ──────────────────────────────────────────────────────────── */
@media (max-width: 1024px) {
    .layout { grid-template-columns: 200px 1fr; }
    .sidebar-right { display: none; }
}

@media (max-width: 700px) {
    .layout { grid-template-columns: 1fr; }
    .sidebar-left { position: static; }
    .nav-menu { flex-direction: row; flex-wrap: wrap; }
    .classroom-layout { grid-template-columns: 1fr; }
    .lesson-sidebar { max-height: 250px; border-right: none; border-bottom: 1px solid var(--border); }
    .navbar-search { display: none; }
    .filter-toolbar { flex-direction: column; align-items: flex-start; }
    .filter-bar { margin-left: 0; }
    .profile-hero { flex-direction: column; align-items: center; text-align: center; }
    .profile-points-bar-wrap { max-width: 100%; }
    .owner-actions { flex-wrap: wrap; }
    .post-actions { flex-wrap: wrap; gap: 6px; }
    .post-meta { flex-wrap: wrap; gap: 4px 8px; }
    #toast-container { left: 12px; right: 12px; bottom: 12px; max-width: none; }
    .btn { min-height: 38px; }
}

/* -- Phase 4: Pin, video embed, mentions ------------------------------------ */
.post-pinned { border-left: 3px solid var(--primary) !important; }
.video-embed-wrap { position:relative; padding-bottom:56.25%; height:0; overflow:hidden; border-radius:8px; margin:10px 0; }
.video-embed-wrap iframe { position:absolute; top:0; left:0; width:100%; height:100%; border:none; }
.mention-link { color: var(--primary); font-weight:600; text-decoration:none; }
.mention-link:hover { text-decoration:underline; }

/* ── Fase 0: Toasts ────────────────────────────────────────────────────────── */
#toast-container {
    position: fixed;
    right: 20px;
    bottom: 20px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-width: min(360px, calc(100vw - 40px));
}
.toast {
    background: #1f2937;
    color: #fff;
    padding: 12px 16px;
    border-radius: 10px;
    font-size: 0.875rem;
    line-height: 1.35;
    box-shadow: 0 6px 24px rgba(0,0,0,0.18);
    opacity: 0;
    transform: translateY(12px);
    transition: opacity .25s ease, transform .25s ease;
    border-left: 4px solid #6b7280;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast-success { border-left-color: #16a34a; }
.toast-error   { border-left-color: #dc2626; }
.toast-info    { border-left-color: var(--primary); }

/* ── Fase 1: Imágenes en posts + estado editado ───────────────────────────── */
.post-image {
    max-width: 100%;
    border-radius: 8px;
    margin: 10px 0;
    display: block;
    border: 1px solid var(--border);
}
.post-edited { font-size: 0.7rem; color: var(--text-muted); font-style: italic; margin-left: 6px; }

/* Botones de acción del autor (editar/eliminar) */
.owner-actions { display: inline-flex; gap: 4px; }
.owner-actions form { display: inline; margin: 0; }

/* ── Fase 2: Estados vacíos ───────────────────────────────────────────────── */
.empty-state { text-align: center; padding: 48px 24px; color: var(--text-muted); }
.empty-state-icon { font-size: 2.5rem; margin-bottom: 12px; }
.empty-state-title { font-weight: 700; color: var(--text); margin-bottom: 6px; }
.empty-state-text { font-size: 0.9rem; margin-bottom: 16px; }

/* ── Fase 3: Guardar y reacciones ─────────────────────────────────────────── */
.save-btn {
    background: none;
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 4px 12px;
    font-size: 0.78rem;
    color: var(--text-muted);
    cursor: pointer;
    transition: all .15s;
}
.save-btn:hover { border-color: var(--primary); color: var(--primary); }
.save-btn.saved { background: var(--primary-light); border-color: var(--primary); color: var(--primary); font-weight: 600; }

.reaction-bar { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.reaction-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 3px 10px;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all .15s;
}
.reaction-btn:hover { border-color: var(--primary); transform: translateY(-1px); }
.reaction-btn.active { background: var(--primary-light); border-color: var(--primary); }
.reaction-btn .re-count { font-size: 0.72rem; color: var(--text-muted); font-weight: 600; }
.reaction-btn.active .re-count { color: var(--primary); }

/* ── Fase 4: Encuestas ────────────────────────────────────────────────────── */
.poll { margin: 14px 0; display: flex; flex-direction: column; gap: 8px; }
.poll-question { font-weight: 600; margin-bottom: 4px; }
.poll-option {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    width: 100%;
    text-align: left;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 10px 14px;
    cursor: pointer;
    overflow: hidden;
    font-size: 0.9rem;
    transition: border-color .15s;
}
.poll-option:hover { border-color: var(--primary); }
.poll-option.voted-mine { border-color: var(--primary); font-weight: 600; }
.poll-bar {
    position: absolute;
    left: 0; top: 0; bottom: 0;
    background: var(--primary-light);
    z-index: 0;
    transition: width .4s ease;
}
.poll-opt-text, .poll-opt-pct { position: relative; z-index: 1; }
.poll-opt-pct { color: var(--text-muted); font-size: 0.8rem; font-weight: 600; }
.poll-total { font-size: 0.78rem; color: var(--text-muted); }

/* ── Fase 5: Tarjeta de bienvenida (onboarding) ───────────────────────────── */
.welcome-card { border-left: 4px solid var(--primary); background: linear-gradient(135deg, var(--primary-light), var(--white)); }
html.dark .welcome-card { background: #1f2937; }
