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

:root {
    --tiktok-red: #fe2c55;
    --tiktok-cyan: #25f4ee;
    --text-white: #ffffff;
    --text-gray: #a1a1a1;
    --bg-black: #000000;
    --nav-bg: #0f0f0f;
    --panel-bg: #121212;
}

body {
    font-family: 'Roboto', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-black);
    color: var(--text-white);
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.app-container {
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    position: relative;
    overflow: hidden;
    background: var(--bg-black);
}

.video-feed {
    width: 100%;
    height: 100%;
    position: relative;
}

.loading-indicator {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    color: var(--text-gray);
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(255, 255, 255, 0.1);
    border-top-color: var(--tiktok-red);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

.video-wrapper {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: none;
    background: var(--bg-black);
}

.video-wrapper.active {
    display: block;
}

.video-player {
    width: 100%;
    height: 100%;
    object-fit: contain;
    background-color: var(--bg-black);
    background-size: contain;
    background-position: center;
    background-repeat: no-repeat;
    position: absolute;
    top: 0;
    left: 0;
    z-index: 1;
}

.video-bg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-size: cover;
    background-position: center;
    z-index: 0;
}

.video-wrapper.active .video-bg {
    display: none;
}

.play-pause-indicator {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 5;
    opacity: 0;
    transition: opacity 0.2s ease;
    pointer-events: none;
}

.play-pause-indicator.show {
    opacity: 1;
}

.play-pause-indicator svg {
    fill: rgba(255, 255, 255, 0.8);
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3));
}

.mute-btn {
    position: absolute;
    top: 60px;
    right: 16px;
    z-index: 15;
    opacity: 0;
    transition: opacity 0.3s ease;
    cursor: pointer;
    background: rgba(0, 0, 0, 0.5);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.video-wrapper:hover .mute-btn,
.video-wrapper.show-mute .mute-btn {
    opacity: 1;
}

.mute-btn svg {
    stroke: white;
    fill: none;
}

.overlay-gradient {
    position: absolute;
    bottom: 60px;
    left: 0;
    right: 0;
    height: 35%;
    background: linear-gradient(to top, rgba(0,0,0,0.8) 0%, transparent 100%);
    pointer-events: none;
}

.top-nav {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    padding-top: max(12px, env(safe-area-inset-top));
    background: linear-gradient(to bottom, rgba(0,0,0,0.6) 0%, transparent 100%);
    z-index: 10;
}

.search-btn {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.tab-switcher {
    display: flex;
    align-items: center;
    gap: 8px;
}

.tab {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-gray);
    cursor: pointer;
    transition: color 0.2s;
    position: relative;
}

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

.tab.active::after {
    content: '';
    position: absolute;
    bottom: -4px;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--text-white);
    border-radius: 2px;
}

.tab-divider {
    width: 1px;
    height: 16px;
    background: var(--text-gray);
}

.live-btn {
    padding: 4px 12px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 4px;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    backdrop-filter: blur(4px);
}

.right-sidebar {
    position: absolute;
    right: 8px;
    bottom: 80px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    z-index: 10;
}

.profile-container {
    position: relative;
}

.profile-pic {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: 2px solid var(--text-white);
    overflow: hidden;
    cursor: pointer;
    position: relative;
}

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

.follow-badge {
    position: absolute;
    bottom: -8px;
    left: 50%;
    transform: translateX(-50%);
    width: 20px;
    height: 20px;
    background: var(--tiktok-red);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s;
}

.follow-badge.following {
    background: var(--tiktok-cyan);
    color: #000;
}

.avatar-placeholder {
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, var(--tiktok-red) 0%, var(--tiktok-cyan) 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 600;
    color: #fff;
}

.avatar-placeholder.avatar-sm {
    font-size: 10px;
}

.avatar-placeholder.avatar-md {
    font-size: 14px;
}

.avatar-placeholder.avatar-lg {
    font-size: 18px;
}

.action-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    cursor: pointer;
    transition: transform 0.1s;
}

.action-btn:active {
    transform: scale(0.9);
}

.action-btn svg {
    filter: drop-shadow(0 1px 2px rgba(0,0,0,0.5));
}

.like-btn svg {
    fill: var(--text-white);
}

.like-btn.liked svg {
    fill: var(--tiktok-red);
}

.bookmark-btn svg {
    fill: none;
    stroke: var(--text-white);
}

.bookmark-btn.saved svg {
    fill: var(--tiktok-cyan);
    stroke: var(--tiktok-cyan);
}

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

.sound-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    margin-top: 8px;
}

.vinyl {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    overflow: hidden;
    border: 3px solid var(--text-white);
    animation: spin 3s linear infinite;
    animation-play-state: paused;
    position: relative;
}

.vinyl.playing {
    animation-play-state: running;
}

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

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

.sound-wave {
    display: flex;
    align-items: flex-end;
    gap: 2px;
    height: 16px;
}

.sound-wave span {
    width: 3px;
    background: var(--text-white);
    border-radius: 2px;
    animation: wave 0.5s ease-in-out infinite;
    animation-play-state: paused;
}

.sound-wave.playing span {
    animation-play-state: running;
}

.sound-wave span:nth-child(1) { height: 8px; animation-delay: 0s; }
.sound-wave span:nth-child(2) { height: 12px; animation-delay: 0.1s; }
.sound-wave span:nth-child(3) { height: 16px; animation-delay: 0.2s; }
.sound-wave span:nth-child(4) { height: 10px; animation-delay: 0.3s; }
.sound-wave span:nth-child(5) { height: 6px; animation-delay: 0.4s; }

@keyframes wave {
    0%, 100% { transform: scaleY(1); }
    50% { transform: scaleY(0.5); }
}

.bottom-info {
    position: absolute;
    bottom: 70px;
    left: 12px;
    right: 70px;
    z-index: 10;
}

.username {
    font-size: 16px;
    font-weight: 700;
    margin-bottom: 8px;
    text-shadow: 0 1px 3px rgba(0,0,0,0.7);
    cursor: pointer;
}

.description {
    font-size: 14px;
    line-height: 1.4;
    margin-bottom: 8px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-shadow: 0 1px 3px rgba(0,0,0,0.7);
}

.description .hashtag {
    color: white;
    font-weight: 600;
    cursor: pointer;
}

.description .hashtag:active {
    opacity: 0.7;
}

.sound-info {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    text-shadow: 0 1px 3px rgba(0,0,0,0.7);
}

.sound-name {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 180px;
}

.bottom-nav {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    display: flex;
    align-items: center;
    justify-content: space-around;
    padding: 8px 0;
    padding-bottom: max(8px, env(safe-area-inset-bottom));
    background: var(--nav-bg);
    border-top: 1px solid rgba(255,255,255,0.1);
    z-index: 100;
}

.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    cursor: pointer;
    transition: opacity 0.2s;
}

.nav-item svg {
    width: 26px;
    height: 26px;
    fill: var(--text-gray);
    stroke: var(--text-gray);
}

.nav-item.active svg {
    fill: var(--text-white);
    stroke: var(--text-white);
}

.nav-item span {
    font-size: 10px;
    color: var(--text-gray);
}

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

.nav-item.create-btn {
    padding: 0 8px;
}

.create-icon {
    width: 44px;
    height: 28px;
    background: linear-gradient(135deg, var(--tiktok-red) 0%, var(--tiktok-cyan) 100%);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s;
}

.create-icon:active {
    transform: scale(0.95);
}

.create-icon svg {
    fill: none;
    stroke: var(--text-white);
}

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.85);
    z-index: 200;
    display: none;
    justify-content: flex-end;
    align-items: flex-end;
}

.modal-overlay.active {
    display: flex;
}

.comment-panel {
    width: 100%;
    height: 75%;
    background: var(--panel-bg);
    border-radius: 20px 20px 0 0;
    display: flex;
    flex-direction: column;
    animation: slideUp 0.3s ease;
}

@keyframes slideUp {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.comments-count {
    font-size: 16px;
    font-weight: 600;
}

.close-btn {
    background: none;
    border: none;
    color: var(--text-white);
    cursor: pointer;
    padding: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.8;
    transition: opacity 0.2s;
}

.close-btn:hover {
    opacity: 1;
}

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

.comments-empty {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-gray);
    font-size: 14px;
}

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

.comment-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    overflow: hidden;
    flex-shrink: 0;
    position: relative;
}

.comment-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.comment-content {
    flex: 1;
    min-width: 0;
}

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

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

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

.comment-text {
    font-size: 14px;
    line-height: 1.4;
    margin-bottom: 6px;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.mention-link {
    color: var(--tiktok-cyan);
    text-decoration: none;
    font-weight: 500;
}

.mention-link:active {
    opacity: 0.7;
}

.comment-actions {
    display: flex;
    gap: 16px;
}

.comment-action {
    font-size: 13px;
    color: var(--text-gray);
    cursor: pointer;
    transition: color 0.2s;
}

.comment-action:hover {
    color: var(--text-white);
}

.comment-action.liked {
    color: var(--tiktok-red);
}

.like-btn {
    display: flex;
    align-items: center;
    gap: 4px;
    cursor: pointer;
}

.like-btn svg {
    transition: transform 0.2s;
}

.like-btn:active svg {
    transform: scale(1.2);
}

.like-count {
    font-size: 12px;
}

.comment-input-container {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    padding-bottom: max(12px, env(safe-area-inset-bottom));
    border-top: 1px solid rgba(255,255,255,0.1);
    background: var(--panel-bg);
}

.my-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    overflow: hidden;
    flex-shrink: 0;
    position: relative;
}

.my-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.comment-input-wrapper {
    flex: 1;
    position: relative;
}

.comment-input {
    width: 100%;
    background: rgba(255,255,255,0.1);
    border: none;
    border-radius: 20px;
    padding: 10px 16px;
    font-size: 14px;
    color: var(--text-white);
    outline: none;
}

.comment-input::placeholder {
    color: var(--text-gray);
}

.mention-dropdown {
    position: absolute;
    bottom: 100%;
    left: 0;
    right: 0;
    background: var(--panel-bg);
    border-radius: 12px;
    box-shadow: 0 -4px 20px rgba(0,0,0,0.3);
    max-height: 280px;
    overflow-y: auto;
    display: none;
    z-index: 100;
    margin-bottom: 8px;
}

.mention-dropdown.active {
    display: block;
}

.mention-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    cursor: pointer;
    transition: background 0.15s;
}

.mention-item:hover,
.mention-item.selected {
    background: rgba(255,255,255,0.08);
}

.mention-item:active {
    background: rgba(255,255,255,0.15);
}

.mention-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--bg-tertiary);
    overflow: hidden;
    flex-shrink: 0;
}

.mention-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.mention-info {
    flex: 1;
    min-width: 0;
}

.mention-name {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-white);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.mention-username {
    font-size: 12px;
    color: var(--text-gray);
}

.mention-highlight {
    color: var(--tiktok-cyan);
    font-weight: 600;
}

.mention-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    color: var(--text-gray);
    font-size: 13px;
}

.mention-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 24px;
    color: var(--text-gray);
    font-size: 13px;
    text-align: center;
}

.mention-empty svg {
    margin-bottom: 8px;
    opacity: 0.5;
}

.post-btn {
    background: none;
    border: none;
    color: var(--tiktok-red);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    padding: 8px;
}

.post-btn:disabled {
    opacity: 0.5;
}

.share-panel {
    width: 100%;
    height: auto;
    max-height: 70%;
    background: var(--panel-bg);
    border-radius: 20px 20px 0 0;
    padding-bottom: env(safe-area-inset-bottom);
    animation: slideUp 0.3s ease;
}

.share-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    font-size: 16px;
    font-weight: 600;
}

.share-options {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    padding: 20px 16px;
}

.share-option {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    transition: transform 0.2s;
}

.share-option:active {
    transform: scale(0.95);
}

.share-option span {
    font-size: 12px;
    color: var(--text-gray);
}

.share-icon {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
}

.share-icon.messenger { background: #0084ff; }
.share-icon.whatsapp { background: #25d366; }
.share-icon.sms { background: #667db6; }
.share-icon.twitter { background: #000000; border: 1px solid rgba(255,255,255,0.2); }
.share-icon.facebook { background: #1877f2; }
.share-icon.copy { background: #ff4757; }
.share-icon.email { background: #2ecc71; }
.share-icon.more { background: rgba(255,255,255,0.2); }

.share-link-container {
    display: flex;
    gap: 8px;
    padding: 0 16px 20px;
}

.share-link-input {
    flex: 1;
    background: rgba(255,255,255,0.1);
    border: none;
    border-radius: 8px;
    padding: 12px;
    font-size: 13px;
    color: var(--text-gray);
    outline: none;
}

.copy-link-btn {
    background: var(--tiktok-red);
    border: none;
    border-radius: 8px;
    padding: 12px 20px;
    font-size: 14px;
    font-weight: 600;
    color: white;
    cursor: pointer;
    transition: transform 0.2s, opacity 0.2s;
}

.copy-link-btn:active {
    transform: scale(0.95);
}

.toast {
    position: fixed;
    bottom: 100px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: rgba(255,255,255,0.9);
    color: #000;
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    z-index: 300;
    opacity: 0;
    transition: transform 0.3s ease, opacity 0.3s ease;
    pointer-events: none;
}

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

.replies-panel {
    width: 100%;
    height: 75%;
    background: var(--panel-bg);
    border-radius: 20px 20px 0 0;
    display: flex;
    flex-direction: column;
    animation: slideUp 0.3s ease;
}

.replies-title {
    font-size: 16px;
    font-weight: 600;
}

.parent-comment {
    padding: 16px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.replies-list {
    flex: 1;
    overflow-y: auto;
    padding: 12px 16px;
}

.reply-item {
    display: flex;
    gap: 10px;
    margin-bottom: 16px;
    padding-left: 16px;
}

.reply-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    overflow: hidden;
    flex-shrink: 0;
    position: relative;
}

.reply-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.reply-content {
    flex: 1;
    min-width: 0;
}

.reply-header {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 2px;
}

.reply-username {
    font-size: 13px;
    font-weight: 600;
}

.reply-time {
    font-size: 11px;
    color: var(--text-gray);
}

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

.reply-actions {
    display: flex;
    gap: 12px;
}

.reply-action {
    font-size: 12px;
    color: var(--text-gray);
    cursor: pointer;
    transition: color 0.2s;
}

.reply-action:hover {
    color: var(--text-white);
}

.reply-action.liked {
    color: var(--tiktok-red);
}

.view-replies-btn {
    font-size: 13px;
    color: var(--text-gray);
    cursor: pointer;
    margin-left: 52px;
    margin-bottom: 12px;
    display: block;
}

.view-replies-btn:hover {
    color: var(--text-white);
}

.empty-comments {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-gray);
    font-size: 14px;
}

@media (min-width: 500px) {
    .app-container {
        max-width: 430px;
        max-height: 932px;
        margin: 20px auto;
        border-radius: 24px;
        border: 8px solid #1a1a1a;
        box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    }
    
    .modal-overlay {
        max-width: 430px;
        left: 50%;
        transform: translateX(-50%);
    }
    
    .modal-overlay.active {
        justify-content: flex-end;
    }
}

.double-tap-heart {
    position: absolute;
    z-index: 20;
    animation: doubleTapHeart 1s ease-out forwards;
    pointer-events: none;
}

@keyframes doubleTapHeart {
    0% {
        transform: scale(0);
        opacity: 1;
    }
    50% {
        transform: scale(1.2);
        opacity: 1;
    }
    100% {
        transform: scale(1);
        opacity: 0;
    }
}
