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

:root {
    --primary: #6366f1;
    --primary-dark: #4f46e5;
    --primary-light: #818cf8;
    --secondary: #64748b;
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    --bg: #0f172a;
    --bg-card: #1e293b;
    --bg-hover: #334155;
    --bg-input: #0f172a;
    --text: #f1f5f9;
    --text-light: #94a3b8;
    --text-muted: #64748b;
    --border: #334155;
    --shadow: 0 4px 6px -1px rgba(0,0,0,0.3);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.4);
    --radius: 12px;
    --radius-sm: 8px;
}

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

a {
    color: inherit;
    text-decoration: none;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

/* Header */
.header {
    background: rgba(30, 41, 59, 0.8);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header .container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 64px;
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text);
}

.logo-icon {
    width: 36px;
    height: 36px;
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
}

.nav {
    display: flex;
    gap: 4px;
}

.nav-link {
    padding: 8px 16px;
    color: var(--text-light);
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s;
}

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

.nav-link.active {
    color: var(--primary-light);
    background: rgba(99, 102, 241, 0.15);
}

.user-area {
    display: flex;
    align-items: center;
    gap: 12px;
}

.username {
    color: var(--text-light);
    font-size: 14px;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 18px;
    font-size: 14px;
    font-weight: 500;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.2s;
    border: none;
    text-decoration: none;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.4);
}

.btn-outline {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-light);
}

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

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

.btn-sm {
    padding: 6px 12px;
    font-size: 13px;
}

.btn-lg {
    padding: 14px 28px;
    font-size: 16px;
}

/* Main */
.main {
    padding: 32px 0;
    min-height: calc(100vh - 64px - 80px);
}

.content-wrapper {
    display: grid;
    grid-template-columns: 1fr 320px;
    gap: 24px;
}

/* Hero Section */
.hero {
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.15) 0%, rgba(139, 92, 246, 0.1) 100%);
    border: 1px solid rgba(99, 102, 241, 0.2);
    border-radius: var(--radius);
    padding: 32px;
    margin-bottom: 24px;
    text-align: center;
}

.hero-title {
    font-size: 1.75rem;
    font-weight: 700;
    margin-bottom: 8px;
    background: linear-gradient(135deg, var(--text), var(--primary-light));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.hero-subtitle {
    color: var(--text-light);
    font-size: 15px;
}

/* Toolbar */
.toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    flex-wrap: wrap;
    gap: 12px;
}

.sort-tabs {
    display: flex;
    gap: 4px;
    background: var(--bg-card);
    padding: 4px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
}

.tab {
    padding: 8px 16px;
    border: none;
    background: transparent;
    cursor: pointer;
    border-radius: 6px;
    font-size: 14px;
    color: var(--text-light);
    font-weight: 500;
    transition: all 0.2s;
}

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

.tab.active {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
}

.search-box {
    display: flex;
    gap: 8px;
}

.search-box input {
    padding: 10px 16px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    width: 240px;
    font-size: 14px;
    transition: all 0.2s;
}

.search-box input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

.search-box input::placeholder {
    color: var(--text-muted);
}

/* Posts */
.posts-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.post-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 24px;
    border: 1px solid var(--border);
    transition: all 0.2s;
}

.post-card:hover {
    border-color: var(--primary);
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.post-header {
    margin-bottom: 12px;
}

.post-title {
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--text);
    line-height: 1.4;
    transition: color 0.2s;
}

.post-title:hover {
    color: var(--primary-light);
}

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

.post-author {
    font-weight: 500;
    color: var(--primary-light);
    transition: opacity 0.2s;
}

.post-author:hover {
    opacity: 0.8;
}

.post-content {
    color: var(--text-light);
    font-size: 14px;
    line-height: 1.7;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    line-clamp: 3;
    -webkit-box-orient: vertical;
}

.post-content img {
    max-width: 100%;
    border-radius: var(--radius-sm);
}

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

.post-content code {
    background: var(--bg);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 13px;
}

.post-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}

.post-topics {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.topic-tag {
    display: inline-flex;
    align-items: center;
    padding: 4px 12px;
    background: rgba(99, 102, 241, 0.15);
    color: var(--primary-light);
    border-radius: 20px;
    font-size: 13px;
    font-weight: 500;
    transition: all 0.2s;
}

.topic-tag:hover {
    background: rgba(99, 102, 241, 0.25);
}

.post-stats {
    display: flex;
    gap: 16px;
}

.like-btn {
    background: none;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--text-muted);
    font-size: 14px;
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    transition: all 0.2s;
}

.like-btn:hover {
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger);
}

.like-btn.liked {
    color: var(--danger);
}

/* Sidebar */
.sidebar {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.widget {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 20px;
    border: 1px solid var(--border);
}

.widget-title {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 16px;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 8px;
}

.topic-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.topic-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 14px;
    background: var(--bg);
    border-radius: var(--radius-sm);
    color: var(--text-light);
    transition: all 0.2s;
}

.topic-item:hover {
    background: var(--bg-hover);
    color: var(--primary-light);
}

.topic-count {
    font-size: 12px;
    color: var(--text-muted);
    background: var(--bg-card);
    padding: 2px 10px;
    border-radius: 10px;
}

/* Pagination */
.pagination {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-top: 32px;
}

.page-btn {
    padding: 10px 16px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 14px;
    color: var(--text-light);
    transition: all 0.2s;
}

.page-btn:hover:not(:disabled) {
    border-color: var(--primary);
    color: var(--primary-light);
}

.page-btn.active {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
    border-color: var(--primary);
}

.page-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Footer */
.footer {
    background: var(--bg-card);
    border-top: 1px solid var(--border);
    padding: 24px 0;
    text-align: center;
    color: var(--text-muted);
    font-size: 14px;
}

/* Forms */
.form-group {
    margin-bottom: 20px;
}

.form-label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    font-size: 14px;
    color: var(--text-light);
}

.form-input, .form-textarea {
    width: 100%;
    padding: 12px 16px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-size: 15px;
    transition: all 0.2s;
}

.form-input:focus, .form-textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

.form-input::placeholder, .form-textarea::placeholder {
    color: var(--text-muted);
}

.form-textarea {
    min-height: 200px;
    resize: vertical;
    font-family: inherit;
}

/* Card */
.card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 24px;
    border: 1px solid var(--border);
}

.card-title {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 24px;
    color: var(--text);
}

/* Auth */
.auth-container {
    max-width: 420px;
    margin: 60px auto;
}

.auth-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 40px;
    border: 1px solid var(--border);
    box-shadow: var(--shadow-lg);
}

.auth-logo {
    text-align: center;
    margin-bottom: 32px;
}

.auth-logo-icon {
    width: 64px;
    height: 64px;
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 16px;
    font-size: 28px;
}

.auth-title {
    font-size: 1.5rem;
    font-weight: 600;
}

.auth-subtitle {
    color: var(--text-light);
    font-size: 14px;
    margin-top: 4px;
}

/* Post Detail */
.post-detail {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 32px;
    border: 1px solid var(--border);
}

.post-detail .post-title {
    font-size: 1.75rem;
    margin-bottom: 16px;
    cursor: default;
}

.post-detail .post-content {
    display: block;
    -webkit-line-clamp: unset;
    line-clamp: unset;
    font-size: 15px;
}

.post-images {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 12px;
    margin: 24px 0;
}

.post-image {
    width: 100%;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: transform 0.2s;
}

.post-image:hover {
    transform: scale(1.02);
}

.attachments-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 24px;
}

.attachment-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px;
    background: var(--bg);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
}

.attachment-info {
    display: flex;
    align-items: center;
    gap: 16px;
}

.attachment-icon {
    width: 48px;
    height: 48px;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 14px;
}

.attachment-name {
    font-weight: 500;
    color: var(--text);
}

.attachment-size {
    font-size: 13px;
    color: var(--text-muted);
}

/* Alert */
.alert {
    padding: 14px 18px;
    border-radius: var(--radius-sm);
    margin-bottom: 16px;
    font-size: 14px;
}

.alert-error {
    background: rgba(239, 68, 68, 0.15);
    color: #fca5a5;
    border: 1px solid rgba(239, 68, 68, 0.3);
}

.alert-success {
    background: rgba(16, 185, 129, 0.15);
    color: #6ee7b7;
    border: 1px solid rgba(16, 185, 129, 0.3);
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.8);
    backdrop-filter: blur(4px);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.modal.active {
    display: flex;
}

.modal img {
    max-width: 90%;
    max-height: 90%;
    border-radius: var(--radius);
}

.modal-close {
    position: absolute;
    top: 20px;
    right: 20px;
    background: var(--bg-card);
    border: none;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 20px;
    color: var(--text);
    transition: all 0.2s;
}

.modal-close:hover {
    background: var(--danger);
}

/* Loading */
.loading {
    text-align: center;
    padding: 60px;
    color: var(--text-light);
}

.spinner {
    width: 44px;
    height: 44px;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 16px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 80px 20px;
    color: var(--text-muted);
}

.empty-icon {
    font-size: 64px;
    margin-bottom: 16px;
    opacity: 0.5;
}

/* Responsive */
@media (max-width: 900px) {
    .content-wrapper {
        grid-template-columns: 1fr;
    }
    
    .sidebar {
        order: -1;
    }
    
    .topic-list {
        flex-direction: row;
        flex-wrap: wrap;
    }
    
    .topic-item {
        flex: 1;
        min-width: 150px;
    }
}

@media (max-width: 600px) {
    .header .container {
        flex-wrap: wrap;
        height: auto;
        padding: 12px 20px;
        gap: 12px;
    }
    
    .nav {
        order: 3;
        width: 100%;
        justify-content: center;
    }
    
    .toolbar {
        flex-direction: column;
        align-items: stretch;
    }
    
    .search-box {
        width: 100%;
    }
    
    .search-box input {
        flex: 1;
        width: auto;
    }
    
    .hero {
        padding: 24px;
    }
    
    .hero-title {
        font-size: 1.5rem;
    }
}
