:root {
    --primary-color: #6366f1;
    --primary-hover: #4f46e5;
    --secondary-color: #8b5cf6;
    --bg-color: #0a0a0f;
    --surface-color: #151520;
    --surface-hover: #1f1f2e;
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --border-color: #2d2d3d;
    --success-color: #10b981;
    --error-color: #ef4444;
    --like-color: #ec4899;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 20px 25px -5px rgba(0, 0, 0, 0.5);
    --radius: 16px;
    --radius-sm: 10px;
    --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

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

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

/* Modal */
.modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.9);
    backdrop-filter: blur(20px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 1rem;
}

.modal.hidden { display: none; }

.modal-content {
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    width: 100%;
    max-width: 420px;
    padding: 2.5rem;
    box-shadow: var(--shadow-lg);
}

.modal-header {
    text-align: center;
    margin-bottom: 2rem;
}

.modal-header h2 {
    font-size: 1.75rem;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 0.5rem;
}

.modal-header p {
    color: var(--text-secondary);
    font-size: 0.95rem;
}

.username-input-wrapper {
    display: flex;
    align-items: center;
    background: var(--bg-color);
    border: 2px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 0 1rem;
    margin-bottom: 0.5rem;
    transition: var(--transition);
}

.username-input-wrapper:focus-within {
    border-color: var(--primary-color);
}

.username-prefix {
    color: var(--text-muted);
    font-family: monospace;
    font-size: 0.9rem;
    white-space: nowrap;
}

#usernameInput {
    flex: 1;
    background: transparent;
    border: none;
    padding: 1rem 0.5rem;
    color: var(--text-primary);
    font-size: 1rem;
    outline: none;
}

.username-hint {
    text-align: center;
    color: var(--text-muted);
    font-size: 0.8rem;
    margin-top: 1rem;
}

.username-hint span {
    color: var(--primary-color);
    font-weight: 600;
}

.error-message {
    color: var(--error-color);
    font-size: 0.875rem;
    min-height: 1.5rem;
    margin-bottom: 1rem;
}

.btn-primary {
    width: 100%;
    padding: 1rem;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}

.btn-primary:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 10px 20px -5px rgba(99, 102, 241, 0.4);
}

.btn-primary:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* Navigation */
.navbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background: rgba(21, 21, 32, 0.95);
    backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border-color);
    padding: 1rem 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 100;
}

.nav-brand {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    text-decoration: none;
    font-weight: 700;
    font-size: 1.25rem;
}

.logo { font-size: 1.5rem; }

.brand-text {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.nav-links {
    display: flex;
    gap: 0.5rem;
}

.nav-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.625rem 1.25rem;
    background: transparent;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    text-decoration: none;
    cursor: pointer;
    transition: var(--transition);
    font-size: 0.9rem;
}

.nav-btn:hover {
    background: var(--surface-hover);
    color: var(--text-primary);
}

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

/* Main Content */
.main-content {
    margin-top: 80px;
    padding: 2rem 1.5rem;
    max-width: 720px;
    margin-left: auto;
    margin-right: auto;
    min-height: calc(100vh - 80px);
}

/* Feed */
.feed-container { animation: fadeIn 0.3s ease; }

.feed-header {
    margin-bottom: 2rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.feed-header h1 {
    font-size: 1.75rem;
    font-weight: 700;
}

.feed-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.current-user {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.current-user strong {
    color: var(--primary-color);
}

.btn-secondary {
    padding: 0.5rem 1rem;
    background: var(--surface-hover);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 0.875rem;
    transition: var(--transition);
}

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

/* Composer */
.composer-card {
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 1.5rem;
    margin-bottom: 2rem;
    box-shadow: var(--shadow);
}

.composer-card textarea {
    width: 100%;
    background: var(--bg-color);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 1rem;
    color: var(--text-primary);
    font-size: 1rem;
    resize: vertical;
    min-height: 120px;
    font-family: inherit;
    transition: var(--transition);
}

.composer-card textarea:focus {
    outline: none;
    border-color: var(--primary-color);
}

.composer-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 1rem;
}

.char-count {
    color: var(--text-muted);
    font-size: 0.875rem;
}

.char-count.warning { color: var(--error-color); }

.btn-publish {
    padding: 0.75rem 1.5rem;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}

.btn-publish:hover:not(:disabled) {
    background: var(--primary-hover);
    transform: translateY(-1px);
}

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

/* Posts */
.posts-feed {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.loading-feed {
    text-align: center;
    padding: 4rem;
    color: var(--text-secondary);
    font-style: italic;
}

.empty-state {
    text-align: center;
    padding: 4rem 2rem;
    color: var(--text-secondary);
}

.empty-state-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

/* Post Card */
.post-card {
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 1.5rem;
    box-shadow: var(--shadow);
    transition: var(--transition);
    animation: slideIn 0.3s ease;
}

.post-card:hover {
    border-color: rgba(99, 102, 241, 0.2);
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

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

.post-username-link {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 600;
    font-size: 0.95rem;
    transition: var(--transition);
}

.post-username-link:hover {
    color: var(--secondary-color);
    text-decoration: underline;
}

.post-timestamp {
    color: var(--text-muted);
    font-size: 0.8rem;
}

.post-content {
    margin-bottom: 1.25rem;
}

.post-text {
    color: var(--text-primary);
    line-height: 1.7;
    white-space: pre-wrap;
    word-wrap: break-word;
    font-size: 1.05rem;
}

.post-actions {
    display: flex;
    gap: 0.75rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
}

.action-btn {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.5rem 1rem;
    background: transparent;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition);
    font-size: 0.9rem;
}

.action-btn:hover {
    background: var(--surface-hover);
    color: var(--text-primary);
}

.like-btn.liked {
    color: var(--like-color);
    background: rgba(236, 72, 153, 0.1);
}

.share-btn:hover {
    color: var(--success-color);
}

/* Comments */
.comment-section {
    margin-top: 1.25rem;
    padding-top: 1.25rem;
    border-top: 1px solid var(--border-color);
}

.comment-section.hidden { display: none; }

.comments-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-bottom: 1rem;
    max-height: 400px;
    overflow-y: auto;
}

.comment-item {
    background: var(--bg-color);
    padding: 1rem;
    border-radius: var(--radius-sm);
    border-left: 3px solid var(--primary-color);
}

.comment-username {
    color: var(--primary-color);
    font-weight: 600;
    font-size: 0.85rem;
    margin-right: 0.5rem;
}

.comment-text {
    color: var(--text-secondary);
    font-size: 0.95rem;
    line-height: 1.5;
}

.comment-meta {
    color: var(--text-muted);
    font-size: 0.75rem;
    margin-top: 0.5rem;
}

.comment-input-wrapper {
    display: flex;
    gap: 0.5rem;
}

.comment-input {
    flex: 1;
    padding: 0.75rem 1rem;
    background: var(--bg-color);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 0.95rem;
}

.comment-input:focus {
    outline: none;
    border-color: var(--primary-color);
}

.comment-submit {
    padding: 0.75rem 1.25rem;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}

.comment-submit:hover:not(:disabled) {
    background: var(--primary-hover);
}

/* Profile View */
.profile-container { animation: fadeIn 0.3s ease; }

.profile-header {
    background: linear-gradient(135deg, var(--surface-color), rgba(99, 102, 241, 0.1));
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 2.5rem;
    text-align: center;
    margin-bottom: 2rem;
    box-shadow: var(--shadow);
}

.profile-info h1 {
    font-size: 2rem;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

.profile-url {
    color: var(--text-muted);
    font-family: monospace;
    font-size: 0.9rem;
    margin-bottom: 1.5rem;
}

.profile-stats {
    display: flex;
    justify-content: center;
    gap: 3rem;
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border-color);
}

.stat {
    text-align: center;
}

.stat-number {
    display: block;
    font-size: 2rem;
    font-weight: 700;
    color: var(--primary-color);
}

.stat-label {
    color: var(--text-secondary);
    font-size: 0.875rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.profile-posts {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

/* Animations */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

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

/* Toast Notification */
.toast {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 1rem 2rem;
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-lg);
    z-index: 2000;
    opacity: 0;
    transition: all 0.3s ease;
}

.toast.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

.toast.success {
    border-color: var(--success-color);
    background: rgba(16, 185, 129, 0.1);
}

/* Responsive */
@media (max-width: 640px) {
    .navbar {
        padding: 0.75rem 1rem;
    }
    
    .brand-text { display: none; }
    
    .nav-text { display: none; }
    
    .nav-btn {
        padding: 0.5rem;
    }
    
    .main-content {
        padding: 1rem;
    }
    
    .modal-content {
        padding: 1.5rem;
    }
    
    .profile-header {
        padding: 1.5rem;
    }
    
    .profile-stats {
        gap: 2rem;
    }
    
    .composer-footer {
        flex-direction: column;
        align-items: stretch;
        gap: 1rem;
    }
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-color);
}

::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

.hidden { display: none !important; }
/* Loading States */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--bg-primary);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    transition: opacity 0.3s ease;
}

.loading-overlay.fade-out {
    opacity: 0;
    pointer-events: none;
}

.loading-spinner i {
    font-size: 3rem;
    color: var(--accent);
    animation: spin 1s linear infinite;
}

.loading-overlay p {
    margin-top: 1rem;
    color: var(--text-muted);
    font-size: 1.1rem;
}

/* Skeleton Loader */
.skeleton-loader {
    background: var(--bg-card);
    border-radius: 1.5rem;
    padding: 1.5rem;
    margin-bottom: 1rem;
    border: 1px solid var(--border);
    animation: pulse 1.5s ease-in-out infinite;
}

.skeleton-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1rem;
}

.skeleton-avatar {
    width: 40px;
    height: 40px;
    background: var(--border-light);
    border-radius: 50%;
}

.skeleton-line {
    height: 16px;
    background: var(--border-light);
    border-radius: 8px;
    margin-bottom: 0.5rem;
}

.skeleton-content {
    margin-bottom: 1rem;
}

.skeleton-actions {
    display: flex;
    gap: 1rem;
    margin-top: 1rem;
}

.skeleton-button {
    width: 60px;
    height: 32px;
    background: var(--border-light);
    border-radius: 1rem;
}

/* Spinner Loader */
.spinner-loader {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 2rem;
    color: var(--text-muted);
}

.spinner-loader i {
    font-size: 1.5rem;
    color: var(--accent);
}

/* Infinite Scroll Loader */
.infinite-loader {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    padding: 2rem;
    color: var(--text-muted);
    border-top: 1px solid var(--border);
}

.infinite-loader i {
    font-size: 1.25rem;
    color: var(--accent);
}

/* Post Content Link */
.post-content-link {
    text-decoration: none;
    color: inherit;
    display: block;
    transition: opacity 0.2s;
}

.post-content-link:hover {
    opacity: 0.9;
}

/* Profile Enhancements */
.profile-cover {
    height: 120px;
    background: linear-gradient(135deg, var(--accent) 0%, var(--accent-hover) 100%);
    border-radius: 1.5rem 1.5rem 0 0;
    position: relative;
    margin-bottom: 40px;
}

.profile-avatar {
    position: absolute;
    bottom: -30px;
    left: 2rem;
}

.profile-avatar i {
    font-size: 80px;
    color: white;
    background: var(--bg-card);
    border-radius: 50%;
    border: 4px solid var(--bg-card);
}

.profile-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.btn-icon {
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    width: 2.5rem;
    height: 2.5rem;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
}

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

.stat-card {
    text-align: center;
    padding: 1rem;
    background: var(--bg-card);
    border-radius: 1rem;
    border: 1px solid var(--border);
    flex: 1;
}

.stat-number {
    display: block;
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
}

.stat-label {
    color: var(--text-muted);
    font-size: 0.875rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.25rem;
}

.profile-tabs {
    display: flex;
    gap: 0.5rem;
    margin: 2rem 0;
    border-bottom: 1px solid var(--border);
    padding-bottom: 0.5rem;
}

.tab-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.2s;
    border-radius: 2rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.tab-btn i {
    font-size: 1rem;
}

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

.tab-btn.active {
    color: var(--accent);
    background: rgba(59, 130, 246, 0.1);
}

.tab-btn.active i {
    color: var(--accent);
}

.hidden {
    display: none !important;
}

/* Animations */
@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* Modal Icon */
.modal-icon {
    font-size: 3rem;
    color: var(--accent);
    margin-bottom: 1rem;
}

/* Responsive */
@media (max-width: 640px) {
    .profile-cover {
        height: 80px;
    }
    
    .profile-avatar {
        left: 50%;
        transform: translateX(-50%);
    }
    
    .profile-avatar i {
        font-size: 60px;
    }
    
    .profile-info {
        text-align: center;
    }
    
    .profile-actions {
        justify-content: center;
    }
    
    .profile-stats {
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .tab-btn {
        flex: 1;
        justify-content: center;
        padding: 0.75rem 0.5rem;
    }
    
    .tab-btn span {
        display: none;
    }
    
    .tab-btn i {
        font-size: 1.25rem;
    }
}