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

:root {
    --primary-color: #FF0050;
    --secondary-color: #00F2EA;
    --background-dark: #010101;
    --background-light: #111111;
    --text-primary: #FFFFFF;
    --text-secondary: #AAAAAA;
    --border-color: #333333;
    --success-color: #4CAF50;
    --error-color: #F44336;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: var(--background-dark);
    color: var(--text-primary);
    overflow: hidden;
    height: 100vh;
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
}

/* Loading Screen */
.loading-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--background-dark);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10000;
}

.loader {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border-color);
    border-top: 3px solid var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* App Container */
.app-container {
    height: 100vh;
    display: flex;
    flex-direction: column;
    max-width: 480px;
    margin: 0 auto;
    background: var(--background-dark);
    position: relative;
}

/* Main Content */
.main-content {
    flex: 1;
    position: relative;
    overflow: hidden;
}

/* Pages */
.page {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    visibility: hidden;
    transform: translateX(100%);
    transition: all 0.3s ease;
}

.page.active {
    opacity: 1;
    visibility: visible;
    transform: translateX(0);
}

/* Home Page - Video Feed */
.video-feed {
    height: 100%;
    scroll-snap-type: y mandatory;
    overflow-y: scroll;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.video-feed::-webkit-scrollbar {
    display: none;
}

.video-container {
    height: 100vh;
    scroll-snap-align: start;
    position: relative;
    background: var(--background-light);
}

.video-container video {
    width: 100%;
    height: 100%;
    object-fit: contain;
    background: var(--background-dark);
}

/* Video Overlay */
.video-overlay {
    position: absolute;
    bottom: 60px;
    left: 10px;
    right: 80px;
    z-index: 10;
    color: white;
}

.video-info {
    text-shadow: 0 1px 3px rgba(0,0,0,0.5);
}

.video-username {
    color: white;
    text-decoration: none;
    font-weight: 600;
    font-size: 16px;
}

.video-caption {
    margin: 8px 0;
    font-size: 14px;
    line-height: 1.4;
}

.video-music {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
}

.video-music svg {
    width: 16px;
    height: 16px;
}

/* Video Actions */
.video-actions {
    position: absolute;
    bottom: 80px;
    right: 10px;
    z-index: 10;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.action-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.profile-link {
    position: relative;
    display: block;
}

.profile-pic {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    overflow: hidden;
    border: 2px solid white;
    background: var(--background-light);
}

.profile-pic img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.add-icon {
    position: absolute;
    bottom: -5px;
    right: -5px;
    width: 20px;
    height: 20px;
    background: var(--primary-color);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid var(--background-dark);
}

.add-icon svg {
    width: 12px;
    height: 12px;
    fill: white;
}

.like-btn, .comment-btn, .share-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
    transition: transform 0.2s ease;
}

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

.like-btn.liked svg {
    fill: var(--primary-color);
}

.action-icon {
    width: 32px;
    height: 32px;
    fill: white;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.3));
    transition: transform 0.2s ease;
}

.like-btn:hover .action-icon,
.comment-btn:hover .action-icon,
.share-btn:hover .action-icon {
    transform: scale(1.1);
}

.action-count {
    font-size: 12px;
    font-weight: 600;
    text-shadow: 0 1px 3px rgba(0,0,0,0.5);
}

.music-spin {
    width: 32px;
    height: 32px;
    background: linear-gradient(45deg, var(--primary-color), var(--secondary-color));
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: spin 3s linear infinite;
}

.music-icon {
    width: 20px;
    height: 20px;
    fill: white;
}

/* Bottom Navigation */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
    max-width: 480px;
    background: rgba(0, 0, 0, 0.9);
    backdrop-filter: blur(20px);
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: space-around;
    align-items: center;
    padding: 8px 0;
    z-index: 1000;
}

.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    color: var(--text-secondary);
    text-decoration: none;
    padding: 4px 12px;
    transition: color 0.2s ease;
    min-width: 44px;
}

.nav-item.active {
    color: var(--text-primary);
}

.nav-icon {
    width: 24px;
    height: 24px;
    fill: currentColor;
}

.nav-item span {
    font-size: 10px;
    font-weight: 500;
}

.upload-btn {
    position: relative;
}

.upload-icon {
    width: 44px;
    height: 44px;
    background: linear-gradient(45deg, var(--primary-color), var(--secondary-color));
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(255, 0, 80, 0.3);
}

.upload-icon svg {
    width: 24px;
    height: 24px;
    fill: white;
}

/* Modals */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.modal.active {
    opacity: 1;
    visibility: visible;
}

.modal-content {
    background: var(--background-light);
    border-radius: 16px;
    width: 90%;
    max-width: 400px;
    max-height: 80vh;
    overflow: hidden;
    transform: scale(0.9);
    transition: transform 0.3s ease;
}

.modal.active .modal-content {
    transform: scale(1);
}

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

.modal-header h3 {
    font-size: 18px;
    font-weight: 600;
}

.close-modal {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 24px;
    cursor: pointer;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background 0.2s ease;
}

.close-modal:hover {
    background: rgba(255, 255, 255, 0.1);
}

/* Upload Form */
.upload-area {
    margin: 20px;
    border: 2px dashed var(--border-color);
    border-radius: 12px;
    padding: 40px 20px;
    text-align: center;
    cursor: pointer;
    transition: border-color 0.2s ease;
}

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

.upload-preview {
    margin-top: 20px;
}

.upload-preview video {
    width: 100%;
    max-height: 300px;
    border-radius: 8px;
}

.form-group {
    margin: 20px;
}

.form-group input,
.form-group textarea {
    width: 100%;
    padding: 12px 16px;
    background: var(--background-dark);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 16px;
    transition: border-color 0.2s ease;
}

.form-group input:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary-color);
}

.upload-submit-btn,
.login-btn {
    width: calc(100% - 40px);
    margin: 20px;
    padding: 14px;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s ease;
}

.upload-submit-btn:hover,
.login-btn:hover {
    background: #E60047;
}

/* Login/Register Modal */
.login-modal {
    text-align: center;
}

.login-header {
    padding: 40px 20px 20px;
}

.login-header h2 {
    font-size: 28px;
    font-weight: 700;
    margin-bottom: 8px;
    background: linear-gradient(45deg, var(--primary-color), var(--secondary-color));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.login-header p {
    color: var(--text-secondary);
    font-size: 14px;
}

.login-footer {
    padding: 20px;
    border-top: 1px solid var(--border-color);
    font-size: 14px;
}

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

/* Discover Page */
.discover-header {
    padding: 20px;
    background: var(--background-light);
    border-bottom: 1px solid var(--border-color);
}

.discover-header h2 {
    font-size: 20px;
    font-weight: 600;
    margin-bottom: 16px;
}

.search-bar {
    position: relative;
}

.search-bar input {
    width: 100%;
    padding: 12px 16px 12px 44px;
    background: var(--background-dark);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    color: var(--text-primary);
    font-size: 16px;
}

.search-bar svg {
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    width: 20px;
    height: 20px;
    fill: var(--text-secondary);
}

.trending-section {
    padding: 20px;
}

.trending-section h3 {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 16px;
}

.trending-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.trending-item {
    position: relative;
    aspect-ratio: 9/16;
    border-radius: 8px;
    overflow: hidden;
    background: var(--background-light);
}

.trending-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.trending-info {
    position: absolute;
    bottom: 8px;
    left: 8px;
    right: 8px;
    color: white;
    font-size: 12px;
    text-shadow: 0 1px 3px rgba(0,0,0,0.8);
}

/* Profile Page */
.profile-header {
    padding: 20px;
    background: var(--background-light);
}

.profile-info {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 20px;
}

.profile-avatar {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--border-color);
}

.profile-details {
    flex: 1;
}

.profile-username {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 4px;
}

.profile-fullname {
    color: var(--text-secondary);
    font-size: 14px;
    margin-bottom: 4px;
}

.profile-bio {
    color: var(--text-primary);
    font-size: 14px;
    line-height: 1.4;
}

.edit-profile-btn {
    background: var(--background-dark);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    padding: 8px 16px;
    border-radius: 4px;
    font-size: 14px;
    cursor: pointer;
    transition: background 0.2s ease;
}

.edit-profile-btn:hover {
    background: var(--border-color);
}

.profile-stats {
    display: flex;
    justify-content: space-around;
    padding: 16px 0;
    border-top: 1px solid var(--border-color);
    border-bottom: 1px solid var(--border-color);
}

.stat-item {
    text-align: center;
}

.stat-number {
    display: block;
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 4px;
}

.stat-label {
    font-size: 12px;
    color: var(--text-secondary);
}

.profile-tabs {
    display: flex;
    background: var(--background-light);
}

.tab-btn {
    flex: 1;
    padding: 12px;
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: all 0.2s ease;
}

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

.profile-content {
    padding: 20px;
}

.videos-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.videos-grid.hidden {
    display: none;
}

.video-item {
    position: relative;
    aspect-ratio: 9/16;
    border-radius: 8px;
    overflow: hidden;
    background: var(--background-light);
    cursor: pointer;
}

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

.video-item-plays {
    position: absolute;
    bottom: 8px;
    left: 8px;
    color: white;
    font-size: 12px;
    display: flex;
    align-items: center;
    gap: 4px;
    text-shadow: 0 1px 3px rgba(0,0,0,0.8);
}

/* Comments Modal */
.comments-modal {
    width: 100%;
    max-width: 100%;
    height: 60vh;
    max-height: 60vh;
    margin: 20vh auto;
}

.comments-container {
    display: flex;
    flex-direction: column;
    height: calc(100% - 60px);
}

.comments-list {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
}

.comment-item {
    display: flex;
    gap: 12px;
    margin-bottom: 16px;
}

.comment-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
}

.comment-content {
    flex: 1;
}

.comment-username {
    font-weight: 600;
    font-size: 14px;
    margin-bottom: 4px;
}

.comment-text {
    font-size: 14px;
    line-height: 1.4;
    margin-bottom: 4px;
}

.comment-time {
    font-size: 12px;
    color: var(--text-secondary);
}

.comment-form {
    padding: 16px 20px;
    border-top: 1px solid var(--border-color);
    display: flex;
    gap: 12px;
}

.comment-form input {
    flex: 1;
    padding: 8px 12px;
    background: var(--background-dark);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    color: var(--text-primary);
    font-size: 14px;
}

.comment-form button {
    padding: 8px 16px;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
}

/* Responsive Design */
@media (min-width: 768px) {
    .app-container {
        max-width: 100%;
    }
    
    .bottom-nav {
        max-width: 480px;
    }
}

@media (max-width: 320px) {
    .nav-item span {
        display: none;
    }
    
    .nav-item {
        padding: 4px 8px;
    }
}

/* Utility Classes */
.hidden {
    display: none !important;
}

.text-center {
    text-align: center;
}

.mb-20 {
    margin-bottom: 20px;
}

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.fade-in {
    animation: fadeIn 0.3s ease forwards;
}