/* ============ ROOT & THEME — True Knowledge Zone ============ */
:root {
    --primary: #4F46E5;
    --primary-hover: #4338CA;
    --accent: #F59E0B;
    --accent-hover: #D97706;
    --gradient: linear-gradient(135deg, #4F46E5 0%, #7C3AED 100%);
    --bg-main: #EEF2FF;
    --bg-card: #ffffff;
    --bg-input: #f5f3ff;
    --bg-sidebar: #ffffff;
    --bg-hover: #ede9fe;
    --text-primary: #1e1b4b;
    --text-secondary: #5b5675;
    --text-muted: #78719a;
    --border: #e0e7ff;
    --border-strong: #c7d2fe;
    --upvote: #4F46E5;
    --downvote: #94a3b8;
    --success: #10b981;
    --danger: #ef4444;
    --insightful: #F59E0B;
    --helpful: #10b981;
    --deepdive: #8b5cf6;
    --shadow: 0 2px 8px rgba(79, 70, 229, 0.08);
    --shadow-lg: 0 8px 32px rgba(79, 70, 229, 0.15);
    --radius: 10px;
    --radius-sm: 6px;
    --transition: all 0.2s ease;
}

[data-theme="dark"] {
    --bg-main: #0f0e17;
    --bg-card: #1a1825;
    --bg-input: #252336;
    --bg-sidebar: #1a1825;
    --bg-hover: #2a2740;
    --text-primary: #e8e6f0;
    --text-secondary: #a8a3c4;
    --text-muted: #7c7794;
    --border: #2d2a42;
    --border-strong: #3d3a58;
    --shadow: 0 2px 8px rgba(0,0,0,0.4);
    --shadow-lg: 0 8px 32px rgba(0,0,0,0.6);
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: var(--bg-main);
    color: var(--text-primary);
    font-size: 14px;
    line-height: 1.5;
    transition: var(--transition);
}

button {
    cursor: pointer;
    border: none;
    background: none;
    font-family: inherit;
    color: inherit;
}

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

a:hover { text-decoration: underline; }

/* ============ NAVBAR ============ */
.navbar {
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    height: 56px;
    display: flex;
    align-items: center;
    padding: 0 20px;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow);
}

.nav-left {
    flex: 0 0 auto;
}

.logo {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
}

.logo-text-wrap {
    display: flex;
    flex-direction: column;
    line-height: 1.2;
}

.logo-text {
    font-size: 16px;
    font-weight: 700;
    background: var(--gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.logo-tagline {
    font-size: 10px;
    color: var(--text-muted);
    font-weight: 500;
    letter-spacing: 0.5px;
}

.search-kbd {
    background: var(--bg-card);
    border: 1px solid var(--border-strong);
    border-radius: 4px;
    padding: 2px 6px;
    font-size: 11px;
    color: var(--text-muted);
    font-family: inherit;
}

.nav-center {
    flex: 1;
    max-width: 700px;
    margin: 0 20px;
    position: relative;
}

.search-box {
    background: var(--bg-input);
    border: 1px solid transparent;
    border-radius: 24px;
    padding: 8px 16px;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: var(--transition);
}

.search-box:focus-within {
    background: var(--bg-card);
    border-color: var(--primary);
}

.search-box input {
    flex: 1;
    background: none;
    border: none;
    outline: none;
    color: var(--text-primary);
    font-size: 14px;
}

.search-results {
    position: absolute;
    top: 48px;
    left: 0;
    right: 0;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    max-height: 400px;
    overflow-y: auto;
    z-index: 1000;
    display: none;
}

.search-results.show { display: block; }

.search-result-item {
    padding: 10px 16px;
    cursor: pointer;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 10px;
}

.search-result-item:hover { background: var(--bg-hover); }

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

.btn-icon {
    width: 38px;
    height: 38px;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    position: relative;
}

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

.badge {
    position: absolute;
    top: 4px;
    right: 4px;
    background: var(--primary);
    color: white;
    font-size: 10px;
    padding: 2px 5px;
    border-radius: 10px;
    min-width: 16px;
    text-align: center;
}

.user-menu {
    position: relative;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    border: 1px solid transparent;
    transition: var(--transition);
}

.user-menu:hover {
    border-color: var(--border-strong);
}

.user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--gradient);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 700;
    font-size: 14px;
    flex-shrink: 0;
}

.user-avatar.small { width: 28px; height: 28px; font-size: 12px; }
.user-avatar.large { width: 80px; height: 80px; font-size: 32px; }

.user-name {
    font-weight: 500;
    color: var(--text-primary);
    max-width: 100px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.user-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    min-width: 220px;
    margin-top: 4px;
    z-index: 1000;
}

.dropdown-item {
    padding: 10px 16px;
    cursor: pointer;
    transition: var(--transition);
    font-size: 14px;
}

.dropdown-item:hover { background: var(--bg-hover); }
.dropdown-item.danger { color: var(--danger); }
.dropdown-divider {
    height: 1px;
    background: var(--border);
    margin: 4px 0;
}

/* ============ MAIN LAYOUT ============ */
.main-container {
    display: grid;
    grid-template-columns: 270px 1fr 320px;
    gap: 24px;
    max-width: 1400px;
    margin: 24px auto;
    padding: 0 24px;
    align-items: flex-start;
}

/* ============ SIDEBAR ============ */
.sidebar {
    background: var(--bg-sidebar);
    border-radius: var(--radius);
    padding: 16px;
    position: sticky;
    top: 80px;
    max-height: calc(100vh - 100px);
    overflow-y: auto;
    box-shadow: var(--shadow);
}

.sidebar-section {
    margin-bottom: 24px;
}

.sidebar-section h3 {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    margin-bottom: 8px;
    padding: 0 8px;
    letter-spacing: 0.5px;
}

.sidebar-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition);
    font-size: 14px;
    margin-bottom: 2px;
    color: var(--text-primary);
}

.sidebar-item:hover { background: var(--bg-hover); }
.sidebar-item.active {
    background: var(--bg-hover);
    font-weight: 600;
}

.sidebar-item .community-icon {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 10px;
    font-weight: 700;
}

.btn-create-community {
    width: 100%;
    padding: 8px;
    background: transparent;
    border: 1px dashed var(--border-strong);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    margin-bottom: 8px;
    transition: var(--transition);
    font-size: 13px;
}

.btn-create-community:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.sidebar-footer {
    padding-top: 16px;
    border-top: 1px solid var(--border);
    color: var(--text-muted);
    font-size: 12px;
}

.sidebar-footer p {
    margin-bottom: 4px;
}

/* ============ CONTENT ============ */
.content {
    min-width: 0;
}

.feed-header {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 16px 20px;
    margin-bottom: 16px;
    box-shadow: var(--shadow);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 16px;
}

.feed-title h2 {
    font-size: 20px;
    margin-bottom: 4px;
}

.feed-title p {
    color: var(--text-secondary);
    font-size: 13px;
}

.feed-sort {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
}

.sort-btn {
    padding: 6px 14px;
    border-radius: 20px;
    color: var(--text-secondary);
    font-weight: 500;
    transition: var(--transition);
    font-size: 13px;
}

.sort-btn:hover { background: var(--bg-hover); }
.sort-btn.active {
    background: var(--bg-input);
    color: var(--text-primary);
    font-weight: 600;
}

/* Quick post */
.quick-post {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 8px 12px;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    transition: var(--transition);
}

.quick-post:hover { border-color: var(--primary); }

.quick-post-input {
    flex: 1;
    padding: 8px 12px;
    background: var(--bg-input);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 14px;
}

/* ============ POSTS FEED ============ */
.posts-feed {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.post-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
    display: grid;
    grid-template-columns: 48px 1fr;
    transition: var(--transition);
    border: 1px solid var(--border);
    cursor: pointer;
}

.post-card:hover {
    border-color: var(--border-strong);
}

.post-vote {
    background: var(--bg-input);
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 8px 4px;
    gap: 4px;
}

.vote-btn {
    width: 30px;
    height: 30px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    transition: var(--transition);
}

.vote-btn:hover { background: var(--bg-hover); }
.vote-btn.upvoted {
    color: var(--upvote);
}
.vote-btn.downvoted {
    color: var(--downvote);
}

.vote-score {
    font-weight: 700;
    font-size: 12px;
    color: var(--text-primary);
}

.vote-score.upvoted { color: var(--upvote); }
.vote-score.downvoted { color: var(--downvote); }

.post-content {
    padding: 12px 16px;
    min-width: 0;
}

.post-meta {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 8px;
    flex-wrap: wrap;
}

.post-community {
    font-weight: 700;
    color: var(--text-primary);
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.post-community:hover { text-decoration: underline; }

.post-author {
    color: var(--text-muted);
}

.post-author:hover { 
    text-decoration: underline; 
    color: var(--primary);
    cursor: pointer;
}

.post-flair {
    background: var(--bg-input);
    color: var(--text-primary);
    padding: 2px 8px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
}

.post-badges { display: flex; gap: 4px; }

.post-badge {
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
}

.badge-nsfw { background: #ff585b; color: white; }
.badge-spoiler { background: #4a4a4a; color: white; }
.badge-oc { background: #00a8ff; color: white; }
.badge-pinned { background: var(--success); color: white; }

.post-title {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--text-primary);
    line-height: 1.3;
}

.post-body {
    color: var(--text-primary);
    margin-bottom: 12px;
    max-height: 240px;
    overflow: hidden;
    position: relative;
    line-height: 1.5;
    word-wrap: break-word;
}

.post-body.long::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 60px;
    background: linear-gradient(transparent, var(--bg-card));
    pointer-events: none;
}

.post-body img, .post-body video {
    max-width: 100%;
    border-radius: var(--radius-sm);
    margin: 8px 0;
}

.post-body pre {
    background: var(--bg-input);
    padding: 12px;
    border-radius: var(--radius-sm);
    overflow-x: auto;
}

.post-body code {
    background: var(--bg-input);
    padding: 2px 6px;
    border-radius: 3px;
    font-family: monospace;
}

.post-body blockquote {
    border-left: 3px solid var(--primary);
    padding-left: 12px;
    margin: 8px 0;
    color: var(--text-secondary);
}

.post-images {
    display: grid;
    gap: 4px;
    margin: 8px 0;
    border-radius: var(--radius-sm);
    overflow: hidden;
}

.post-images.count-1 { grid-template-columns: 1fr; max-height: 500px; }
.post-images.count-2 { grid-template-columns: 1fr 1fr; }
.post-images.count-3 { grid-template-columns: 1fr 1fr; }
.post-images.count-3 img:first-child { grid-row: span 2; }
.post-images.count-4 { grid-template-columns: 1fr 1fr; }

.post-images img, .post-images video {
    width: 100%;
    height: 100%;
    max-height: 500px;
    object-fit: cover;
    cursor: pointer;
}

.post-link-preview {
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 12px;
    background: var(--bg-input);
    margin: 8px 0;
    display: block;
}

.post-link-preview:hover {
    border-color: var(--primary);
    text-decoration: none;
}

.post-poll {
    margin: 12px 0;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 12px;
}

.poll-option-result {
    margin: 6px 0;
    padding: 8px 12px;
    background: var(--bg-input);
    border-radius: var(--radius-sm);
    cursor: pointer;
    position: relative;
    overflow: hidden;
    transition: var(--transition);
}

.poll-option-result:hover { background: var(--bg-hover); }

.poll-option-result.voted::before {
    content: '';
    position: absolute;
    top: 0; left: 0;
    height: 100%;
    background: rgba(79, 70, 229, 0.2);
    width: var(--percent, 0%);
    transition: width 0.5s ease;
}

/* Reactions */
.post-reactions {
    display: flex;
    gap: 6px;
    margin: 8px 0;
    flex-wrap: wrap;
}

.reaction-btn {
    padding: 4px 10px;
    border-radius: 20px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

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

.reaction-btn.active-insightful {
    background: rgba(245, 158, 11, 0.15);
    border-color: var(--insightful);
    color: var(--insightful);
}

.reaction-btn.active-helpful {
    background: rgba(16, 185, 129, 0.15);
    border-color: var(--helpful);
    color: var(--helpful);
}

.reaction-btn.active-deepdive {
    background: rgba(139, 92, 246, 0.15);
    border-color: var(--deepdive);
    color: var(--deepdive);
}

.reading-time {
    font-size: 11px;
    color: var(--text-muted);
    font-weight: 500;
}

.follow-btn {
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    border: 1px solid var(--primary);
    color: var(--primary);
    transition: var(--transition);
}

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

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

.preview-pane {
    margin-top: 8px;
    border-radius: var(--radius-sm);
}

.scroll-top-btn {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--gradient);
    color: white;
    font-size: 20px;
    font-weight: 700;
    box-shadow: var(--shadow-lg);
    z-index: 500;
    transition: var(--transition);
}

.scroll-top-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 40px rgba(79, 70, 229, 0.3);
}

.shortcut-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.shortcut-item {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 14px;
}

.shortcut-item kbd {
    background: var(--bg-input);
    border: 1px solid var(--border-strong);
    border-radius: 4px;
    padding: 4px 10px;
    font-family: inherit;
    font-weight: 600;
    min-width: 36px;
    text-align: center;
}

.poll-option-result span { position: relative; z-index: 1; }

.post-actions {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-wrap: wrap;
}

.post-action {
    padding: 6px 10px;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 6px;
    transition: var(--transition);
    font-weight: 600;
    font-size: 12px;
}

.post-action:hover { background: var(--bg-hover); color: var(--text-primary); }
.post-action.saved { color: var(--primary); }

.post-tags {
    display: flex;
    gap: 6px;
    margin-top: 8px;
    flex-wrap: wrap;
}

.post-tag {
    background: var(--bg-input);
    color: var(--text-secondary);
    padding: 2px 10px;
    border-radius: 20px;
    font-size: 11px;
    cursor: pointer;
}

.post-tag:hover { background: var(--primary); color: white; }

/* ============ RIGHT SIDEBAR ============ */
.right-sidebar {
    display: flex;
    flex-direction: column;
    gap: 16px;
    position: sticky;
    top: 80px;
    max-height: calc(100vh - 100px);
    overflow-y: auto;
}

.info-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 16px;
    box-shadow: var(--shadow);
}

.info-card h3 {
    font-size: 14px;
    margin-bottom: 12px;
    color: var(--text-primary);
}

.info-card p {
    color: var(--text-secondary);
    font-size: 13px;
    margin-bottom: 12px;
}

.stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin-bottom: 8px;
    padding: 12px 0;
    border-top: 1px solid var(--border);
}

.stats-secondary {
    border-top: none;
    border-bottom: 1px solid var(--border);
    margin-bottom: 12px;
    padding-top: 0;
}

.wisdom-card {
    background: var(--gradient);
    color: white;
}

.wisdom-card h3 {
    color: white;
}

.wisdom-card blockquote {
    font-size: 14px;
    font-style: italic;
    line-height: 1.6;
    margin-bottom: 8px;
    opacity: 0.95;
}

.wisdom-card cite {
    font-size: 12px;
    opacity: 0.8;
    font-style: normal;
}

.stat {
    text-align: center;
}

.stat strong {
    display: block;
    font-size: 16px;
    color: var(--text-primary);
}

.stat span {
    color: var(--text-muted);
    font-size: 11px;
}

.rules-list {
    padding-left: 20px;
    color: var(--text-secondary);
    font-size: 13px;
}

.rules-list li {
    padding: 4px 0;
    border-bottom: 1px solid var(--border);
}

.rules-list li:last-child { border-bottom: none; }

.trending-item {
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    transition: var(--transition);
}

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

.trending-item:last-child { border-bottom: none; }

.trending-rank {
    color: var(--text-muted);
    font-weight: 700;
    margin-right: 8px;
}

/* ============ BUTTONS ============ */
.btn-primary, .btn-secondary, .btn-danger {
    padding: 8px 16px;
    border-radius: 20px;
    font-weight: 600;
    transition: var(--transition);
    font-size: 13px;
}

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

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

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

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

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

.btn-danger:hover { opacity: 0.9; }

.btn-link {
    color: var(--primary);
    background: none;
    padding: 4px 0;
    font-size: 13px;
}

.btn-link:hover { text-decoration: underline; }

.full { width: 100%; margin-bottom: 8px; }

/* ============ MODALS ============ */
.modal {
    position: fixed;
    top: 0; left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
}

.modal.hidden { display: none; }

.modal-content {
    background: var(--bg-card);
    border-radius: var(--radius);
    width: 100%;
    max-width: 600px;
    max-height: 90vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-lg);
    animation: slideUp 0.2s ease;
}

.modal-content.large { max-width: 800px; }
.modal-content.xlarge { max-width: 1000px; }
.modal-content.small { max-width: 400px; }

@keyframes slideUp {
    from { transform: translateY(20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.modal-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h2 {
    font-size: 18px;
}

.btn-close {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    font-size: 24px;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

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

.modal-body {
    padding: 20px;
    overflow-y: auto;
    flex: 1;
}

.modal-footer {
    padding: 16px 20px;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

/* ============ FORMS ============ */
.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    margin-bottom: 6px;
    font-weight: 600;
    color: var(--text-primary);
    font-size: 13px;
}

.form-input {
    width: 100%;
    padding: 10px 12px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 14px;
    transition: var(--transition);
    outline: none;
}

.form-input:focus { border-color: var(--primary); }

textarea.form-input { resize: vertical; min-height: 80px; }

.input-prefix {
    display: flex;
    align-items: center;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    overflow: hidden;
}

.input-prefix span {
    padding: 10px 12px;
    color: var(--text-muted);
    background: var(--border);
}

.input-prefix input {
    border: none;
    background: transparent;
}

.flag-options {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
}

.flag-options label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
}

.post-type-tabs {
    display: flex;
    border-bottom: 2px solid var(--border);
    margin-bottom: 16px;
    overflow-x: auto;
}

.tab-btn {
    padding: 10px 20px;
    color: var(--text-secondary);
    font-weight: 600;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    white-space: nowrap;
    font-size: 13px;
    transition: var(--transition);
}

.tab-btn.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

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

.editor-toolbar {
    display: flex;
    gap: 4px;
    padding: 6px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-bottom: none;
    border-radius: var(--radius-sm) var(--radius-sm) 0 0;
    flex-wrap: wrap;
}

.editor-toolbar button {
    padding: 4px 10px;
    border-radius: 3px;
    color: var(--text-secondary);
    font-size: 13px;
    transition: var(--transition);
}

.editor-toolbar button:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.rich-editor {
    min-height: 200px;
    padding: 12px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 0 0 var(--radius-sm) var(--radius-sm);
    outline: none;
    color: var(--text-primary);
    line-height: 1.6;
}

.rich-editor:empty::before {
    content: attr(placeholder);
    color: var(--text-muted);
}

.upload-area {
    border: 2px dashed var(--border-strong);
    border-radius: var(--radius);
    padding: 40px;
    text-align: center;
    cursor: pointer;
    transition: var(--transition);
}

.upload-area:hover {
    border-color: var(--primary);
    background: var(--bg-hover);
}

.upload-area p {
    color: var(--text-secondary);
    margin-top: 12px;
}

.image-preview-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 8px;
    margin-top: 16px;
}

.image-preview-item {
    position: relative;
    border-radius: var(--radius-sm);
    overflow: hidden;
    aspect-ratio: 1;
}

.image-preview-item img, .image-preview-item video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.image-preview-item .remove-btn {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 24px;
    height: 24px;
    background: rgba(0,0,0,0.7);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.poll-option {
    margin-bottom: 8px;
}

/* ============ COMMENTS ============ */
.comments-section {
    margin-top: 24px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}

.comment-form {
    margin-bottom: 24px;
    padding: 12px;
    background: var(--bg-input);
    border-radius: var(--radius-sm);
}

.comment-form textarea {
    width: 100%;
    min-height: 80px;
    padding: 10px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: inherit;
    resize: vertical;
    outline: none;
}

.comment-form textarea:focus { border-color: var(--primary); }

.comment-form-footer {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 8px;
}

.comment-sort {
    display: flex;
    gap: 4px;
    margin-bottom: 16px;
    align-items: center;
}

.comment-sort span {
    color: var(--text-muted);
    font-size: 12px;
    margin-right: 8px;
}

.comment {
    margin-left: 0;
    padding: 8px 0;
    border-left: 2px solid var(--border);
    padding-left: 12px;
    margin-bottom: 8px;
}

.comment.nested { margin-left: 24px; }

.comment-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
    font-size: 12px;
    color: var(--text-muted);
    flex-wrap: wrap;
}

.comment-author {
    font-weight: 700;
    color: var(--text-primary);
    cursor: pointer;
}

.comment-author:hover { color: var(--primary); }

.comment-author.op {
    color: var(--primary);
}

.comment-body {
    color: var(--text-primary);
    margin-bottom: 6px;
    word-wrap: break-word;
    line-height: 1.5;
}

.comment-actions {
    display: flex;
    gap: 4px;
    align-items: center;
    flex-wrap: wrap;
}

.comment-action {
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    font-size: 11px;
    font-weight: 600;
    transition: var(--transition);
    display: flex;
    align-items: center;
    gap: 4px;
}

.comment-action:hover { background: var(--bg-hover); color: var(--text-primary); }

.collapse-btn {
    background: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 11px;
    margin-right: 4px;
}

.comment.collapsed .comment-body,
.comment.collapsed .comment-actions,
.comment.collapsed .replies {
    display: none;
}

/* ============ POST VIEW ============ */
.post-view {
    background: var(--bg-card);
    border-radius: var(--radius);
}

.post-view .post-title { font-size: 22px; }
.post-view .post-body { max-height: none; }
.post-view .post-body::after { display: none; }

/* ============ IMAGE VIEWER ============ */
.image-viewer {
    background: rgba(0,0,0,0.95);
    cursor: zoom-out;
}

.image-viewer img {
    max-width: 95%;
    max-height: 95vh;
    object-fit: contain;
}

.image-viewer-close {
    position: absolute;
    top: 20px;
    right: 30px;
    color: white;
    font-size: 40px;
    cursor: pointer;
}

/* ============ TOAST ============ */
.toast-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    padding: 12px 20px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-left: 4px solid var(--primary);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    min-width: 250px;
    animation: slideIn 0.3s ease;
    color: var(--text-primary);
}

.toast.success { border-left-color: var(--success); }
.toast.error { border-left-color: var(--danger); }
.toast.info { border-left-color: var(--downvote); }

@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

/* ============ PROFILE ============ */
.profile-header {
    display: flex;
    gap: 16px;
    align-items: center;
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border);
}

.profile-info h2 { margin-bottom: 4px; }
.profile-info p { color: var(--text-secondary); font-size: 13px; }

.profile-stats {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
    margin-bottom: 16px;
}

.profile-tabs {
    display: flex;
    border-bottom: 2px solid var(--border);
    margin-bottom: 16px;
}

/* ============ EMPTY STATE ============ */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-secondary);
}

.empty-state svg {
    margin-bottom: 16px;
    opacity: 0.3;
}

.empty-state h3 {
    margin-bottom: 8px;
    color: var(--text-primary);
}

/* ============ COMMUNITY BANNER ============ */
.community-banner {
    background: var(--gradient);
    color: white;
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 16px;
    box-shadow: var(--shadow);
}

.community-banner h2 {
    font-size: 24px;
    margin-bottom: 4px;
}

.community-banner p {
    opacity: 0.95;
    font-size: 14px;
    margin-bottom: 12px;
}

.community-banner .meta {
    display: flex;
    gap: 16px;
    font-size: 12px;
    opacity: 0.9;
}

/* ============ HIDDEN ============ */
.hidden { display: none !important; }

/* ============ RESPONSIVE ============ */
@media (max-width: 1100px) {
    .main-container {
        grid-template-columns: 240px 1fr;
    }
    .right-sidebar { display: none; }
}

@media (max-width: 768px) {
    .main-container {
        grid-template-columns: 1fr;
        padding: 0 12px;
        margin: 12px auto;
    }
    .sidebar {
        position: static;
        max-height: none;
    }
    .nav-center { margin: 0 8px; }
    .user-name { display: none; }
    .logo-tagline { display: none; }
    .logo-text { font-size: 14px; }
    .search-kbd { display: none; }
    .navbar { padding: 0 12px; }
    .post-card { grid-template-columns: 1fr; }
    .post-vote {
        flex-direction: row;
        justify-content: flex-start;
        padding: 6px 12px;
        border-bottom: 1px solid var(--border);
    }
    .feed-header { flex-direction: column; align-items: flex-start; }
    .feed-sort { width: 100%; overflow-x: auto; }
}

/* ============ SCROLLBAR ============ */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: var(--bg-input); }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }
