/* === Reset & Base === */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --bg-primary: #ffe4ec;
    --bg-secondary: #ffd0de;
    --bg-card: #ffffff;
    --bg-hover: #ffc2d4;
    --text-primary: #4a1528;
    --text-secondary: #8b4a5e;
    --accent: #ff6b8a;
    --accent-hover: #e8456b;
    --border: #f0c0cf;
    --radius: 12px;
    --radius-sm: 8px;
    --max-width: 1400px;
}

html { font-size: 16px; }
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

a { color: var(--text-primary); text-decoration: none; }
a:hover { color: var(--accent); }
img { max-width: 100%; display: block; }
pre { white-space: pre-wrap; font-family: inherit; color: var(--text-primary); }

.container { flex: 1; max-width: var(--max-width); margin: 0 auto; padding: 24px 16px; width: 100%; }

/* === Navbar === */
.navbar {
    display: flex; align-items: center; gap: 10px;
    padding: 0 16px; height: 56px;
    background: var(--bg-secondary); border-bottom: 1px solid var(--border);
    position: sticky; top: 0; z-index: 100; overflow: visible;
}
.logo {
    font-size: 1.4rem; font-weight: 800; color: var(--text-primary);
    white-space: nowrap; display: flex; align-items: center;
}
.nav-center { flex: 1; max-width: 640px; margin: 0 auto; overflow: visible; }
.search-form { display: flex; overflow: visible; }
.search-form input {
    width: 100%; height: 38px; padding: 0 16px;
    background: var(--bg-primary); border: 1px solid var(--border);
    border-radius: 24px 0 0 24px; color: var(--text-primary); outline: none;
    box-sizing: border-box; font-size: 0.9rem;
}
.search-form input:focus { border-color: var(--accent); }
.search-form button {
    height: 38px; padding: 0 20px; background: var(--bg-hover); border: 1px solid var(--border);
    border-left: none; border-radius: 0 24px 24px 0; color: var(--text-primary); cursor: pointer;
    box-sizing: border-box; font-size: 0.9rem; line-height: 38px;
}
.search-form button:hover { background: var(--bg-secondary); }

.search-input-wrap { position: relative; flex: 1; display: flex; align-items: center; }
.search-history {
    position: fixed;
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    box-shadow: 0 4px 16px rgba(0,0,0,0.15); z-index: 9999;
    max-height: 280px; overflow-y: auto;
}
.sh-item {
    display: flex; align-items: center; padding: 8px 14px;
    border-bottom: 1px solid rgba(0,0,0,0.04); cursor: default;
}
.sh-item:hover { background: var(--bg-hover); }
.sh-text { flex: 1; font-size: 0.85rem; color: var(--text-primary); cursor: pointer; }
.sh-del {
    background: none; border: none; color: var(--text-secondary);
    font-size: 1rem; cursor: pointer; padding: 0 4px; line-height: 1;
}
.sh-del:hover { color: #e74c3c; }
.sh-actions { padding: 6px 14px; text-align: right; }
.sh-actions button {
    background: none; border: none; color: var(--text-secondary);
    font-size: 0.75rem; cursor: pointer;
}
.sh-actions button:hover { color: var(--accent); }

.nav-right { display: flex; align-items: center; gap: 12px; white-space: nowrap; }
.user-name { color: var(--text-secondary); font-size: 0.9rem; }
.nav-right .btn-upload, .nav-right .btn-login, .nav-right .btn-register,
.nav-right .btn-logout {
    padding: 6px 14px; border-radius: 18px; font-size: 0.85rem; border: none; cursor: pointer; transition: background .15s;
}
.btn-upload { background: var(--accent); color: #fff; }
.btn-upload:hover { background: var(--accent-hover); }
.btn-login { color: #d6336c; background: transparent; border: 1px solid #d6336c !important; }
.btn-login:hover { background: rgba(62,166,255,.1); }
.btn-register { background: #d6336c; color: #000; }
.btn-register:hover { background: #e8456b; }
.btn-logout { background: transparent; border: 1px solid var(--border) !important; color: var(--text-secondary); }
.btn-logout:hover { color: var(--accent); }

.menu-toggle { display: none; flex-direction: column; gap: 4px; background: none; border: none; cursor: pointer; }
.menu-toggle span { width: 22px; height: 2px; background: var(--text-primary); }

/* === Video Grid === */
.video-grid-page { padding: 0 8px; }
.page-title { font-size: 1.3rem; margin-bottom: 20px; }
.search-count { color: var(--text-secondary); margin-bottom: 8px; }
.search-section-title { font-size: 1rem; margin: 20px 0 12px; padding-bottom: 6px; border-bottom: 1px solid var(--border); color: var(--text-primary); }
.video-grid {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 20px;
}
.video-card { display: block; background: var(--bg-card); border-radius: var(--radius); overflow: hidden; transition: background .15s; }
.video-card:hover { background: var(--bg-hover); }
.card-thumb { position: relative; aspect-ratio: 16/9; background: var(--bg-secondary); overflow: hidden; }
.card-thumb img { width: 100%; height: 100%; object-fit: cover; }
.card-duration {
    position: absolute; bottom: 6px; right: 6px;
    background: rgba(0,0,0,.8); color: #fff; padding: 2px 6px; border-radius: 4px; font-size: 0.8rem; font-weight: 500;
}
.card-body { padding: 12px; }
.card-title { font-size: 0.95rem; font-weight: 600; margin-bottom: 6px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card-meta { font-size: 0.8rem; color: var(--text-secondary); }

/* === Video Page === */
.video-page { display: flex; gap: 24px; }
.video-main { flex: 1; min-width: 0; }
.video-sidebar { width: 360px; flex-shrink: 0; }
.video-sidebar h3 { margin-bottom: 16px; font-size: 1rem; }

.player-wrapper {
    background: #0d0d0d; border-radius: var(--radius);
    overflow: hidden; margin-bottom: 16px; position: relative;
    border: 1px solid var(--border);
    box-shadow: 0 2px 12px rgba(0,0,0,0.08);
    cursor: pointer;
}
.video-player { width: 100%; aspect-ratio: 16/9; display: block; }

/* Custom Video Controls */
.custom-controls {
    position: absolute; bottom: 0; left: 0; right: 0;
    padding: 32px 16px 14px;
    background: linear-gradient(transparent, rgba(0,0,0,0.8));
    display: flex; align-items: center; gap: 10px;
    opacity: 0; transition: opacity 0.3s;
    z-index: 5; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}
.custom-controls.visible { opacity: 1; }
.ctrl-play {
    background: none; border: none; color: #fff;
    font-size: 1.15rem; cursor: pointer; padding: 4px; width: 28px; line-height: 1;
}
.ctrl-time { font-size: 0.8rem; color: #ddd; min-width: 40px; text-align: center; font-variant-numeric: tabular-nums; font-weight: 500; letter-spacing: 0.3px; }
.ctrl-progress {
    flex: 1; height: 6px; background: rgba(255,255,255,0.2);
    border-radius: 3px; position: relative; cursor: pointer;
    transition: height 0.15s;
}
.ctrl-progress:hover { height: 8px; }
.ctrl-progress-filled {
    height: 100%; background: #d6336c; border-radius: 3px;
    position: absolute; left: 0; top: 0; pointer-events: none;
}
.ctrl-progress-thumb {
    position: absolute; top: 50%; transform: translate(-50%, -50%);
    width: 15px; height: 15px; background: #fff;
    border-radius: 50%; pointer-events: auto; cursor: pointer;
    box-shadow: 0 0 4px rgba(0,0,0,0.3);
    display: none;
}
.ctrl-progress:hover .ctrl-progress-thumb { display: block; }
.ctrl-volume {
    background: none; border: none; color: #fff;
    font-size: 0.9rem; cursor: pointer; padding: 4px; line-height: 1;
}
.ctrl-volume-slider {
    width: 60px; height: 4px; background: rgba(255,255,255,0.2);
    border-radius: 2px; cursor: pointer; position: relative;
    transition: width 0.15s; flex-shrink: 0;
}
.ctrl-volume-slider:hover { width: 76px; }
.ctrl-volume-filled {
    height: 100%; background: #d6336c; border-radius: 2px;
}
.ctrl-fullscreen {
    background: none; border: none; color: #fff;
    font-size: 1rem; cursor: pointer; padding: 4px; line-height: 1;
}

/* Quality Selector */
.quality-selector {
    position: absolute; bottom: 52px; right: 10px; z-index: 10;
    user-select: none;
}
.quality-btn {
    padding: 4px 10px; background: rgba(0,0,0,0.7); color: #fff;
    border: 1px solid rgba(255,255,255,0.3); border-radius: 4px;
    font-size: 0.75rem; cursor: pointer; font-weight: 500;
    transition: background 0.15s;
    display: flex; align-items: center; gap: 4px;
}
.quality-btn::after { content: '▾'; font-size: 0.6rem; }
.quality-btn:hover { background: rgba(0,0,0,0.9); border-color: rgba(255,255,255,0.6); }
.quality-menu {
    position: absolute; bottom: 28px; right: 0;
    background: rgba(0,0,0,0.9); border: 1px solid rgba(255,255,255,0.2);
    border-radius: 6px; padding: 4px 0; min-width: 80px;
}
.quality-option {
    display: block; width: 100%; padding: 6px 16px;
    background: none; border: none; color: #ccc;
    font-size: 0.8rem; cursor: pointer; text-align: left;
    transition: background 0.1s, color 0.1s;
}
.quality-option:hover { background: rgba(255,255,255,0.15); color: #fff; }
.quality-option.active { color: #ff6b8a; font-weight: 600; }
.quality-option.active::before { content: '✓ '; }

.video-title { font-size: 1.2rem; margin-bottom: 2px; }
.video-num { font-size: 0.78rem; color: var(--text-secondary); margin-bottom: 8px; }

.video-info-bar {
    display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 12px;
    padding: 12px 0; border-bottom: 1px solid var(--border); margin-bottom: 16px;
}
.video-meta { display: flex; gap: 16px; font-size: 0.85rem; color: var(--text-secondary); }
.video-actions { display: flex; gap: 8px; }

.btn-react {
    padding: 8px 16px; background: var(--bg-card); border: 1px solid var(--border);
    border-radius: 24px; color: var(--text-primary); cursor: pointer; font-size: 0.9rem; transition: background .15s;
}
.btn-react:hover { background: var(--bg-hover); }
.btn-react.active { background: #fce4ec; border-color: #d6336c; }
.btn-delete { color: #e74c3c; border-color: #e74c3c; }
.btn-delete:hover { background: rgba(231,76,60,.1); }
.btn-download { color: #27ae60; border-color: #27ae60; display: inline-block; }
.btn-download:hover { background: rgba(39,174,96,.1); }

.video-desc { background: var(--bg-card); border-radius: var(--radius-sm); padding: 12px; margin-bottom: 24px; }

/* === Comments === */
.comments-section { margin-top: 24px; }
.comments-section h2 { font-size: 1rem; margin-bottom: 16px; }

.comment-form { margin-bottom: 8px; }
.comment-form textarea, .reply-form textarea {
    width: 100%; padding: 12px; background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius-sm); color: var(--text-primary); resize: vertical; font-size: 0.9rem;
}
.comment-form textarea:focus, .reply-form textarea:focus { outline: none; border-color: #d6336c; }
.comment-form button, .reply-form button {
    margin-top: 8px; padding: 7px 18px; background: #d6336c; border: none;
    border-radius: 18px; color: #000; cursor: pointer; font-weight: 500;
}
.comment-login-hint { color: var(--text-secondary); margin-bottom: 16px; }

.comment-item { display: flex; gap: 16px; margin-bottom: 20px; }
.comment-avatar { flex-shrink: 0; }
.comment-avatar img { border-radius: 50%; width: 36px; height: 36px; }
.comment-body { flex: 1; }
.comment-header { margin-bottom: 4px; }
.comment-user { font-size: 0.85rem; font-weight: 600; text-decoration: none; color: var(--text-primary); }
.comment-user:hover { color: #d6336c; }
.comment-time { font-size: 0.75rem; color: var(--text-secondary); margin-left: 8px; }
.comment-content { font-size: 0.9rem; margin-bottom: 6px; }
.comment-actions { display: flex; gap: 8px; align-items: center; }
.btn-reply-sm {
    background: none; border: none; color: var(--text-secondary); cursor: pointer; font-size: 0.8rem; padding: 2px 4px;
}
.btn-reply-sm:hover { color: var(--text-primary); }
.btn-reply-sm.active { color: #d6336c; }
.btn-cancel { background: transparent !important; color: var(--text-secondary) !important; }
.r-count { font-size: 0.75rem; }

.reply-form { margin-top: 8px; }
.replies { margin-top: 12px; margin-left: 0; padding-left: 0; }
.replies .comment-item { margin-bottom: 10px; }

/* === Related Videos === */
.related-item { display: flex; gap: 8px; margin-bottom: 12px; padding: 4px; border-radius: var(--radius-sm); }
.related-item:hover { background: var(--bg-hover); }
.related-thumb { position: relative; width: 168px; aspect-ratio: 16/9; border-radius: var(--radius-sm); overflow: hidden; flex-shrink: 0; background: var(--bg-secondary); }
.related-thumb img { width: 100%; height: 100%; object-fit: cover; }
.related-duration { position: absolute; bottom: 4px; right: 4px; background: rgba(0,0,0,.8); color: #fff; padding: 1px 4px; border-radius: 3px; font-size: 0.7rem; }
.related-info { min-width: 0; }
.related-info h4 { font-size: 0.85rem; font-weight: 500; margin-bottom: 4px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.related-info p { font-size: 0.75rem; color: var(--text-secondary); }

/* === Forms === */
.form-page { max-width: 480px; margin: 60px auto; }
.form-page h1 { font-size: 1.5rem; text-align: center; margin-bottom: 24px; }

.auth-form label, .upload-form label { display: block; margin-bottom: 16px; }
.auth-form label span, .upload-form label span { display: block; font-size: 0.85rem; color: var(--text-secondary); margin-bottom: 4px; }
.auth-form input, .upload-form input[type="text"], .upload-form textarea {
    width: 100%; padding: 10px 14px; background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius-sm); color: var(--text-primary); font-size: 0.95rem; outline: none;
}
.auth-form input:focus, .upload-form input:focus, .upload-form textarea:focus { border-color: #d6336c; }

.type-tabs { display: flex; gap: 8px; flex-wrap: wrap; }
.type-tab {
    padding: 8px 18px; border: 1px solid var(--border); border-radius: var(--radius-sm);
    background: var(--bg-card); color: var(--text-secondary); font-size: 0.9rem;
    cursor: pointer; transition: all 0.15s;
}
.type-tab:hover { border-color: #d6336c; color: #d6336c; }
.type-tab.active { background: #d6336c; color: #fff; border-color: #d6336c; }

.file-input-wrapper { display: flex; align-items: center; gap: 12px; }
.file-input-wrapper input[type="file"] { display: none; }
.file-label {
    padding: 8px 20px; background: #d6336c; color: #000; border-radius: 18px;
    cursor: pointer; font-size: 0.85rem; font-weight: 500; white-space: nowrap;
}
.file-name { font-size: 0.85rem; color: var(--text-secondary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.progress-wrapper { margin-top: 16px; }
.progress-bar {
    width: 100%; height: 10px; background: var(--bg-secondary);
    border-radius: 5px; overflow: hidden;
}
.progress-fill {
    height: 100%; width: 0%;
    background: linear-gradient(90deg, #d6336c, #ff6b8a);
    border-radius: 5px; transition: width 0.2s;
}
.progress-text {
    display: block; text-align: center; font-size: 0.85rem;
    color: var(--text-secondary); margin-top: 4px;
}

.btn-submit {
    width: 100%; padding: 12px; background: #d6336c; border: none; border-radius: 24px;
    color: #000; font-size: 1rem; font-weight: 600; cursor: pointer; transition: background .15s;
}
.btn-submit:hover { background: #e8456b; }

.form-switch { text-align: center; margin-top: 16px; font-size: 0.9rem; color: var(--text-secondary); }
.form-switch a { color: #d6336c; }

.alert { padding: 10px 14px; border-radius: var(--radius-sm); margin-bottom: 16px; }
.alert-error { background: rgba(255,68,68,.15); border: 1px solid rgba(255,68,68,.3); color: #ff6b6b; }

/* === Pagination === */
.pagination { display: flex; justify-content: center; gap: 8px; margin-top: 32px; }
.page-link {
    padding: 8px 16px; background: var(--bg-card); border-radius: var(--radius-sm);
    font-size: 0.9rem; border: 1px solid var(--border);
}
.page-link:hover { background: var(--bg-hover); }
.page-link.active { background: #d6336c; color: #000; border-color: #d6336c; }

/* === Error Page === */
.error-page { text-align: center; padding: 100px 0; }
.error-page h1 { font-size: 6rem; color: var(--text-secondary); }
.error-page p { font-size: 1.2rem; margin: 12px 0 24px; color: var(--text-secondary); }
.error-page a { color: #d6336c; font-size: 1rem; }

/* === Empty State === */
.empty-state { text-align: center; padding: 80px 0; color: var(--text-secondary); }
.empty-state a { color: #d6336c; }

/* === Footer === */
.footer { text-align: center; padding: 24px; color: var(--text-secondary); font-size: 0.8rem; border-top: 1px solid var(--border); }

/* === Nav Links === */
.nav-left { display: flex; align-items: center; gap: 14px; flex-shrink: 0; }
.nav-link { font-size: 1.1rem; font-weight: 400; color: var(--text-primary); }
.nav-link:hover { color: var(--accent); }
.nav-link::before { content: '|'; color: var(--border); margin-right: 14px; font-weight: 300; }
.nav-link:first-of-type::before { display: none; }
.logo-img { height: 36px; width: auto; border-radius: 4px; margin-right: 4px; }

/* === Banner === */
.banner-carousel { position: relative; width: 100%; max-width: var(--max-width); margin: 0 auto 24px auto; overflow: hidden; background: #000; border-radius: var(--radius); }
.carousel-track { display: flex; align-items: center; justify-content: center; }
.carousel-img { width: 100%; max-height: 300px; object-fit: contain; display: none; cursor: pointer; border-radius: var(--radius); }
.carousel-img.active { display: block; }
.carousel-btn {
    position: absolute; top: 50%; transform: translateY(-50%);
    background: rgba(0,0,0,.4); color: #fff; border: none; font-size: 1.2rem;
    padding: 8px 12px; cursor: pointer; border-radius: 4px; z-index: 3;
}
.carousel-btn:hover { background: rgba(0,0,0,.6); }
.carousel-prev { left: 8px; }
.carousel-next { right: 8px; }
.carousel-dots {
    position: absolute; bottom: 8px; left: 50%; transform: translateX(-50%);
    display: flex; gap: 6px; z-index: 3;
}
.carousel-dot {
    width: 8px; height: 8px; border-radius: 50%; background: rgba(255,255,255,.5);
    cursor: pointer; transition: background .2s;
}
.carousel-dot.active { background: #fff; }
.banner-edit-btn {
    position: absolute; top: 8px; right: 12px;
    background: rgba(0,0,0,.4); color: #fff; border: none; text-decoration: none;
    padding: 4px 10px; border-radius: 12px; cursor: pointer; font-size: 0.85rem; z-index: 5;
}
.banner-edit-btn:hover { background: rgba(0,0,0,.6); color: #fff; }
.banner-empty { padding: 10px 24px; background: var(--bg-secondary); display: flex; align-items: center; font-size: 0.85rem; }
.banner-hint { flex: 1; color: var(--text-secondary); }
.banner-preview-list { margin-top: 12px; display: flex; flex-direction: column; gap: 8px; }
.banner-preview-item { display: flex; align-items: center; gap: 10px; padding: 8px; background: var(--bg-hover); border-radius: 8px; }

/* === Home Sections === */
.home-section {
    margin-bottom: 32px; padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
}
.home-section:last-child { border-bottom: none; }
.section-pinned {
    background: linear-gradient(135deg, rgba(255,184,0,0.08), rgba(255,184,0,0.02));
    border: 1px solid rgba(255,184,0,0.2); border-radius: var(--radius);
    padding: 16px 20px 20px; margin-bottom: 36px;
}
.section-title {
    font-size: 1.15rem; font-weight: 600; color: var(--text-primary);
    margin-bottom: 16px; display: flex; align-items: center; gap: 8px;
}
.section-icon { font-size: 1.2rem; }
.section-more { font-size: 0.8rem; font-weight: 400; color: var(--text-secondary); margin-left: auto; }
.section-more:hover { color: var(--accent); }
.section-grid { display: grid; gap: 16px; }
.section-grid.cols-4 { grid-template-columns: repeat(4, 1fr); }
.section-grid.cols-3 { grid-template-columns: repeat(3, 1fr); }

/* Feed Card */
.feed-card {
    background: var(--bg-card); border-radius: var(--radius-sm);
    border: 1px solid var(--border); overflow: hidden;
    transition: border-color 0.15s, transform 0.15s;
}
.feed-card:hover { border-color: var(--accent); transform: translateY(-2px); }
.feed-card.pinned { border-color: #ffb800; }
.feed-thumb {
    display: block; aspect-ratio: 16/9; background: var(--bg-secondary);
    overflow: hidden; position: relative;
}
.feed-thumb img { width: 100%; height: 100%; object-fit: cover; }
.feed-body { padding: 10px 12px 12px; }
.feed-header { display: flex; align-items: center; gap: 6px; margin-bottom: 6px; }
.feed-type {
    font-size: 0.65rem; font-weight: 700; padding: 2px 7px;
    border-radius: 8px; color: #fff; letter-spacing: 0.5px;
}
.type-video { background: #d6336c; }
.type-article { background: #3498db; }
.type-resource { background: #27ae60; }
.type-link { background: #8e44ad; }
.feed-pinned { font-size: 0.65rem; }
.feed-title {
    font-size: 0.9rem; font-weight: 500; color: var(--text-primary);
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
    overflow: hidden; margin-bottom: 6px; line-height: 1.4;
}
.feed-title:hover { color: var(--accent); }
.feed-excerpt {
    font-size: 0.78rem; color: var(--text-secondary);
    margin-bottom: 8px; line-height: 1.5;
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
    overflow: hidden;
}
.feed-meta { font-size: 0.75rem; color: var(--text-secondary); }
.feed-meta a { color: var(--text-secondary); }
.feed-meta a:hover { color: var(--accent); }
.pin-btn {
    margin-top: 6px; padding: 2px 8px; font-size: 0.7rem;
    background: none; border: 1px solid var(--border);
    border-radius: 8px; color: var(--text-secondary); cursor: pointer;
}
.pin-btn:hover { border-color: #ffb800; color: #ffb800; }

/* Compact cards (no thumbnail) */
.feed-card:not(:has(.feed-thumb)) .feed-body { padding: 10px 14px; min-height: 60px; display: flex; flex-direction: column; justify-content: center; }
.feed-card:not(:has(.feed-thumb)) .feed-title { font-size: 0.88rem; -webkit-line-clamp: 2; margin-bottom: 4px; }
.feed-card:not(:has(.feed-thumb)) .feed-excerpt { font-size: 0.78rem; }

/* Article card — 3/4 original height */
.feed-article .feed-thumb { aspect-ratio: 21/9; }

@media (max-width: 1000px) {
    .section-grid.cols-4 { grid-template-columns: repeat(2, 1fr); }
    .section-grid.cols-3 { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 600px) {
    .section-grid.cols-4, .section-grid.cols-3 { grid-template-columns: 1fr; }
}

/* === Category Tabs === */
.category-tabs { display: flex; gap: 8px; margin-bottom: 24px; flex-wrap: wrap; }
.cat-tab {
    padding: 6px 16px; border-radius: 18px; font-size: 0.85rem;
    background: var(--bg-card); border: 1px solid var(--border);
    transition: all .15s;
}
.cat-tab:hover { background: var(--bg-hover); }
.cat-tab.active { background: #d6336c; color: #fff; border-color: #d6336c; }

.cat-select {
    width: 100%; padding: 10px 14px; background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius-sm); color: var(--text-primary); font-size: 0.95rem; outline: none;
}

/* === Articles === */
.articles-page { max-width: 800px; margin: 0 auto; }
.articles-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 24px; }
.btn-write {
    padding: 8px 20px; background: #d6336c; color: #fff; border-radius: 18px;
    font-size: 0.9rem; font-weight: 500;
}
.btn-write:hover { background: #e8456b; }

.articles-list { display: flex; flex-direction: column; gap: 16px; }
.article-card { display: flex; gap: 16px; background: var(--bg-card); border-radius: var(--radius); padding: 16px; border: 1px solid var(--border); }
.article-card:hover { border-color: #d6336c; }
.article-cover { width: 200px; flex-shrink: 0; border-radius: var(--radius-sm); overflow: hidden; }
.article-cover img { width: 100%; aspect-ratio: 16/10; object-fit: cover; }
.article-body { flex: 1; min-width: 0; }
.article-title { font-size: 1.05rem; margin-bottom: 8px; }
.article-excerpt { font-size: 0.85rem; color: var(--text-secondary); margin-bottom: 12px; }
.article-meta { display: flex; align-items: center; gap: 6px; font-size: 0.8rem; color: var(--text-secondary); }
.article-author-avatar { width: 20px; height: 20px; border-radius: 50%; object-fit: cover; }

.article-detail { max-width: 800px; margin: 0 auto; }
.article-detail-title { font-size: 1.8rem; margin-bottom: 16px; }
.article-detail-meta { display: flex; align-items: center; gap: 16px; margin-bottom: 24px; font-size: 0.85rem; color: var(--text-secondary); flex-wrap: wrap; }
.article-author { display: flex; align-items: center; gap: 8px; }
.article-author:hover { color: var(--text-primary); }
.article-cover-img { width: 100%; border-radius: var(--radius); margin-bottom: 24px; }
.article-content { font-size: 1rem; line-height: 1.8; margin-bottom: 40px; }
.article-content p { margin-bottom: 12px; }
.article-content img { max-width: 100%; border-radius: var(--radius-sm); cursor: pointer; transition: opacity .15s; }
.article-content img:hover { opacity: 0.85; }
.article-cover-img { cursor: pointer; transition: opacity .15s; }
.article-cover-img:hover { opacity: 0.85; }

.a-comment-avatar { width: 32px; height: 32px; border-radius: 50%; object-fit: cover; flex-shrink: 0; }
.comment-item.reply { margin-left: 44px; }

.btn-delete-sm {
    padding: 4px 12px; background: none; border: 1px solid #e74c3c; border-radius: 12px;
    color: #e74c3c; cursor: pointer; font-size: 0.8rem;
}
.btn-delete-sm:hover { background: rgba(231,76,60,.1); }

/* === Ranking === */
.ranking-list { display: flex; flex-direction: column; gap: 8px; }
.ranking-item {
    display: flex; align-items: center; gap: 16px;
    background: var(--bg-card); border-radius: var(--radius); padding: 12px 16px;
    border: 1px solid var(--border); transition: border-color .15s;
}
.ranking-item:hover { border-color: #d6336c; }
.rank-num { font-size: 1.4rem; font-weight: 800; color: var(--text-secondary); width: 40px; text-align: center; flex-shrink: 0; }
.rank-num.top1 { color: #ffb800; }
.rank-num.top2 { color: #a0a0a0; }
.rank-num.top3 { color: #cd7f32; }
.rank-thumb { width: 160px; aspect-ratio: 16/9; border-radius: var(--radius-sm); overflow: hidden; position: relative; flex-shrink: 0; background: var(--bg-secondary); }
.rank-thumb img { width: 100%; height: 100%; object-fit: cover; }
.rank-body { flex: 1; min-width: 0; }
.rank-title { font-size: 0.95rem; margin-bottom: 4px; display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical; overflow: hidden; }
.rank-meta { font-size: 0.8rem; color: var(--text-secondary); }
.rank-views { font-size: 0.9rem; color: var(--accent); font-weight: 600; flex-shrink: 0; }

/* === Watch History === */
.history-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
.history-header .page-title { margin-bottom: 0; }
.history-list { display: flex; flex-direction: column; gap: 0; }
.history-item {
    display: flex; align-items: center; gap: 16px;
    padding: 12px 0; border-bottom: 1px solid var(--border);
    transition: background 0.15s;
}
.history-item:hover { background: var(--bg-hover); margin: 0 -12px; padding: 12px; border-radius: var(--radius-sm); }
.history-thumb {
    width: 200px; aspect-ratio: 16/9; border-radius: var(--radius-sm);
    overflow: hidden; position: relative; flex-shrink: 0; background: var(--bg-secondary);
}
.history-thumb img { width: 100%; height: 100%; object-fit: cover; }
.history-body { flex: 1; min-width: 0; }
.history-title {
    font-size: 1rem; font-weight: 500; color: var(--text-primary);
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
    margin-bottom: 6px;
}
.history-title:hover { color: var(--accent); }
.history-meta { font-size: 0.82rem; color: var(--text-secondary); }
.history-meta a { color: var(--text-secondary); }
.history-meta a:hover { color: var(--accent); }
.history-time { color: var(--accent); }

@media (max-width: 640px) {
    .rank-thumb { width: 100px; }
    .rank-views { display: none; }
}

.profile-articles { margin-top: 32px; }
.profile-articles h2 { font-size: 1.1rem; margin-bottom: 16px; }
.profile-article-item { display: block; padding: 12px; border-radius: var(--radius-sm); border: 1px solid var(--border); margin-bottom: 8px; }
.profile-article-item:hover { border-color: #d6336c; }
.profile-article-item h4 { font-size: 0.95rem; margin-bottom: 4px; }
.profile-article-item span { font-size: 0.8rem; color: var(--text-secondary); }

@media (max-width: 640px) {
    .article-card { flex-direction: column; }
    .article-cover { width: 100%; }
}

/* === Avatar & Profile === */
.nav-avatar {
    width: 28px; height: 28px; border-radius: 50%; object-fit: cover;
    vertical-align: middle; margin-right: 4px;
}
.nav-user-link { display: flex; align-items: center; gap: 4px; }
.nav-user-link:hover { opacity: 0.85; }

.profile-page { max-width: 1000px; margin: 0 auto; }
.profile-header { display: flex; gap: 24px; align-items: center; margin-bottom: 32px; padding-bottom: 24px; border-bottom: 1px solid var(--border); }
.profile-avatar-section { text-align: center; }
.profile-avatar {
    width: 100px; height: 100px; border-radius: 50%; object-fit: cover;
    border: 3px solid var(--accent); margin-bottom: 8px;
}
.avatar-upload-btn {
    font-size: 0.8rem; color: #d6336c; cursor: pointer;
    display: inline-block; padding: 4px 12px; border-radius: 12px;
    border: 1px solid #d6336c; transition: all .15s;
}
.avatar-upload-btn:hover { background: #d6336c; color: #fff; }
.profile-info h1 { font-size: 1.5rem; margin-bottom: 4px; }
.profile-joined { font-size: 0.85rem; color: var(--text-secondary); }
.profile-uid { font-size: 0.85rem; color: #d6336c; font-weight: 600; margin: 4px 0; }

/* === Avatar Crop Modal === */
.crop-overlay {
    position: fixed; top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.85); z-index: 9999;
    display: flex; align-items: center; justify-content: center;
}
.crop-modal {
    background: var(--bg-card); border-radius: var(--radius); padding: 24px;
    max-width: 560px; width: 95%;
}
.crop-modal h3 { margin-bottom: 12px; font-size: 1.1rem; }
.crop-stage {
    text-align: center; background: #000; border-radius: 8px;
    overflow: hidden; line-height: 0;
}
.crop-stage canvas {
    display: block; max-width: 100%; height: auto; margin: 0 auto;
    cursor: grab; touch-action: none;
}
.crop-controls {
    display: flex; align-items: center; gap: 12px;
    margin: 12px 0 6px; padding: 0 4px;
}
.crop-controls input[type=range] { flex: 1; accent-color: #d6336c; }
.crop-controls span {
    font-size: 0.85rem; color: var(--text-secondary);
    min-width: 36px; text-align: right;
}
.crop-hint { text-align: center; font-size: 0.8rem; color: var(--text-secondary); margin: 4px 0 12px; }
.crop-actions { display: flex; gap: 12px; justify-content: flex-end; }
.crop-actions .btn-cancel {
    padding: 10px 24px; background: transparent; border: 1px solid var(--border);
    border-radius: 20px; cursor: pointer; color: var(--text-secondary);
}
.uid-search { margin-right: 8px; }
.uid-input {
    width: 80px; padding: 5px 10px; background: var(--bg-card); border: 1px solid var(--border);
    border-radius: 14px; color: var(--text-primary); font-size: 0.8rem; outline: none; text-align: center;
}
.uid-input:focus { border-color: #d6336c; }

/* === Admin === */
.admin-page { max-width: 700px; margin: 0 auto; }
.admin-page h1 { margin-bottom: 24px; }
.admin-section { margin-bottom: 32px; background: var(--bg-card); padding: 20px; border-radius: var(--radius); border: 1px solid var(--border); }
.admin-section h2 { font-size: 1.05rem; margin-bottom: 12px; }
.admin-table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
.admin-table th { text-align: left; padding: 8px 10px; border-bottom: 2px solid var(--border); color: var(--text-secondary); }
.admin-table td { padding: 8px 10px; border-bottom: 1px solid var(--border); }
.admin-table tr:hover td { background: var(--bg-hover); }
.rename-box { display: flex; gap: 8px; align-items: center; margin: 8px 0; }
.rename-box input {
    padding: 6px 12px; background: var(--bg-card); border: 1px solid var(--border);
    border-radius: 8px; color: var(--text-primary); font-size: 0.85rem; outline: none; width: 160px;
}
.profile-videos { margin-top: 24px; }
.profile-videos h2 { font-size: 1.1rem; margin-bottom: 16px; }

.video-author-link { display: flex; align-items: center; gap: 8px; }
.video-author-avatar { width: 40px; height: 40px; border-radius: 50%; object-fit: cover; }

/* === Friends === */
.friends-page { max-width: 650px; margin: 0 auto; }
.friends-page h1 { margin-bottom: 20px; }
.add-friend-box { display: flex; gap: 10px; margin-bottom: 8px; }
.add-friend-box input {
    flex: 1; padding: 10px 14px; background: var(--bg-card); border: 1px solid var(--border);
    border-radius: 24px; color: var(--text-primary); outline: none;
}
.btn-add-friend { padding: 10px 20px; background: #d6336c; color: #fff; border: none; border-radius: 24px; cursor: pointer; font-weight: 500; }
.result-msg { font-size: 0.85rem; margin-bottom: 16px; }
.result-msg.ok { color: #27ae60; }
.result-msg.error { color: #e74c3c; }

.friends-section { margin-top: 28px; }
.friends-section h2 { font-size: 1rem; margin-bottom: 12px; }
.friend-list { display: flex; flex-direction: column; gap: 8px; }
.friend-item {
    display: flex; align-items: center; gap: 12px;
    padding: 10px 14px; background: var(--bg-card); border-radius: var(--radius-sm); border: 1px solid var(--border);
}
.friend-avatar, .conv-avatar, .msg-avatar { width: 40px; height: 40px; border-radius: 50%; object-fit: cover; }
.friend-name { flex: 1; font-size: 0.95rem; font-weight: 500; }
.pending-tag { font-size: 0.8rem; color: var(--text-secondary); }

.friend-actions { display: flex; gap: 8px; }
.btn-accept, .btn-reject, .btn-msg, .btn-remove {
    padding: 5px 14px; border-radius: 16px; font-size: 0.8rem; border: 1px solid var(--border); cursor: pointer; background: var(--bg-card); color: var(--text-primary);
}
.btn-accept { background: #27ae60; color: #fff; border-color: #27ae60; }
.btn-reject { color: #e74c3c; border-color: #e74c3c; }
.btn-msg { color: #d6336c; border-color: #d6336c; }
.btn-msg:hover { background: rgba(214,51,108,.1); }
.btn-remove { color: var(--text-secondary); }
.btn-remove:hover { color: #e74c3c; }
.empty-hint { color: var(--text-secondary); font-size: 0.9rem; }

/* === Messages === */
.messages-page { display: flex; height: calc(100vh - 120px); }
.msg-sidebar {
    width: 280px; border-right: 1px solid var(--border); padding-right: 16px; overflow-y: auto; flex-shrink: 0;
}
.msg-sidebar h2 { font-size: 1rem; margin-bottom: 12px; }

.conv-list { display: flex; flex-direction: column; gap: 4px; }
.conv-item {
    display: flex; align-items: center; gap: 10px; padding: 10px; border-radius: var(--radius-sm);
    transition: background .15s;
}
.conv-item:hover { background: var(--bg-hover); }
.conv-item.active { background: rgba(214,51,108,.15); }
.conv-info { min-width: 0; }
.conv-name { display: block; font-size: 0.9rem; font-weight: 500; }
.conv-preview { display: block; font-size: 0.78rem; color: var(--text-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.msg-main { flex: 1; display: flex; flex-direction: column; margin-left: 24px; min-width: 0; }
.msg-header { padding: 8px 0 16px; border-bottom: 1px solid var(--border); margin-bottom: 12px; }
.msg-partner { display: flex; align-items: center; gap: 10px; }
.msg-partner span { font-weight: 600; }

.msg-list { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; padding: 8px 0; }
.msg-bubble { max-width: 70%; }
.msg-mine { align-self: flex-end; }
.msg-theirs { align-self: flex-start; }
.msg-text { padding: 10px 14px; border-radius: 18px; font-size: 0.9rem; line-height: 1.4; }
.msg-mine .msg-text { background: #d6336c; color: #fff; border-bottom-right-radius: 4px; }
.msg-theirs .msg-text { background: var(--bg-card); border-bottom-left-radius: 4px; }
.msg-time { font-size: 0.7rem; color: var(--text-secondary); padding: 2px 8px; }

.msg-input-bar { display: flex; gap: 10px; margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--border); }
.msg-input-bar input {
    flex: 1; padding: 10px 14px; background: var(--bg-card); border: 1px solid var(--border);
    border-radius: 24px; color: var(--text-primary); outline: none;
}
.msg-input-bar button { padding: 10px 20px; background: #d6336c; color: #fff; border: none; border-radius: 24px; cursor: pointer; font-weight: 500; }
.msg-empty { flex: 1; display: flex; align-items: center; justify-content: center; color: var(--text-secondary); }

/* Nav badges */
.nav-icon-link { font-size: 1.15rem; position: relative; margin: 0 4px; }
.msg-bell { position: relative; }
.msg-badge { position: absolute; top: -6px; right: -10px; background: #e74c3c; color: #fff; font-size: 0.65rem; padding: 1px 4px; border-radius: 8px; min-width: 16px; text-align: center; line-height: 1.4; }

/* === Resources === */
.resources-page { max-width: 900px; margin: 0 auto; }
.resources-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
.resources-header h1 { font-size: 1.3rem; }

.resource-list { display: flex; flex-direction: column; gap: 8px; }
.resource-item {
    display: flex; align-items: center; gap: 16px;
    padding: 14px 18px; background: var(--bg-card); border-radius: var(--radius); border: 1px solid var(--border);
}
.resource-item:hover { border-color: #d6336c; }
.res-icon { font-size: 2rem; flex-shrink: 0; width: 48px; text-align: center; }
.res-body { flex: 1; min-width: 0; }
.res-title { font-size: 0.95rem; margin-bottom: 4px; }
.res-meta { font-size: 0.8rem; color: var(--text-secondary); }
.res-desc { font-size: 0.8rem; color: var(--text-secondary); margin-top: 4px; }
.res-actions { display: flex; gap: 8px; align-items: center; flex-shrink: 0; }
.btn-download {
    padding: 6px 16px; background: #27ae60; color: #fff; border-radius: 18px;
    font-size: 0.85rem; font-weight: 500;
}
.btn-download:hover { background: #219a52; color: #fff; }

@media (max-width: 600px) {
    .resource-item { flex-wrap: wrap; }
    .res-actions { width: 100%; justify-content: flex-end; }
}

/* === Links === */
.add-link-box { display: flex; gap: 8px; margin-bottom: 20px; }
.link-input {
    flex: 1; padding: 8px 12px; background: var(--bg-card); border: 1px solid var(--border);
    border-radius: 8px; color: var(--text-primary); font-size: 0.9rem; outline: none;
}
.link-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.link-card {
    display: block; padding: 16px; background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius); transition: border-color .15s;
}
.link-card:hover { border-color: #d6336c; }
.link-title { font-size: 0.95rem; margin-bottom: 6px; }
.link-desc { font-size: 0.8rem; color: var(--text-secondary); margin-bottom: 8px; }
.link-url-text { font-size: 0.75rem; color: #d6336c; }

@media (max-width: 700px) {
    .messages-page { flex-direction: column; height: auto; }
    .msg-sidebar { width: 100%; border-right: none; padding-right: 0; margin-bottom: 16px; }
    .msg-main { margin-left: 0; min-height: 400px; }
}

/* === Responsive === */
@media (max-width: 900px) {
    .video-page { flex-direction: column; }
    .video-sidebar { width: 100%; }
    .video-grid { grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); }
}
/* === Image Lightbox === */
.lightbox-overlay {
    position: fixed; top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.92); z-index: 9999;
    display: flex; align-items: center; justify-content: center;
    cursor: zoom-out;
}
.lightbox-img-wrap {
    max-width: 95vw; max-height: 95vh;
    overflow: hidden;
    position: relative;
}
.lightbox-img-wrap img {
    max-width: 100%; max-height: 95vh;
    object-fit: contain; display: block;
    transition: transform 0.1s ease;
    cursor: grab; user-select: none;
}
.lightbox-img-wrap img.grabbing { cursor: grabbing; }
.lightbox-close {
    position: fixed; top: 16px; right: 24px;
    font-size: 2rem; color: #fff; background: none; border: none;
    cursor: pointer; z-index: 10000; line-height: 1;
}
.lightbox-close:hover { opacity: 0.7; }
.lightbox-controls {
    position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%);
    display: flex; gap: 10px; z-index: 10000;
    background: rgba(255,255,255,0.15); border-radius: 24px; padding: 6px 12px;
}
.lightbox-controls button {
    padding: 8px 16px; border: none; border-radius: 16px;
    background: rgba(255,255,255,0.2); color: #fff;
    font-size: 1rem; cursor: pointer; transition: background .15s;
}
.lightbox-controls button:hover { background: rgba(255,255,255,0.35); }
.zoom-indicator {
    position: fixed; top: 16px; left: 50%; transform: translateX(-50%);
    color: #fff; font-size: 0.9rem; background: rgba(255,255,255,0.15);
    padding: 4px 14px; border-radius: 12px; z-index: 10000;
}

@media (max-width: 640px) {
    .navbar { padding: 0 12px; gap: 8px; }
    .menu-toggle { display: flex; }
    .nav-center { display: none; }
    .nav-center.show { display: block; position: absolute; top: 56px; left: 0; right: 0; padding: 12px; background: var(--bg-secondary); border-bottom: 1px solid var(--border); }
    .nav-center.show .search-form { max-width: 100%; }
    .nav-right { font-size: 0.8rem; gap: 8px; }
    .video-grid { grid-template-columns: 1fr; }
    .related-thumb { width: 120px; }
}
