:root {
    --bg-color: #0c0812;
    --card-bg: #1a1225;
    --accent: #a78bfa;
    --accent-hover: #c4b5fd;
    --text-primary: #f5f3ff;
    --text-secondary: #94a3b8;
    --glass: rgba(139, 92, 246, 0.15);
    --violet-gradient: linear-gradient(135deg, #7c3aed 0%, #c084fc 100%);
    --card-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.4);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

body {
    background: var(--bg-color);
    color: var(--text-primary);
    font-family: 'Pretendard', -apple-system, sans-serif;
    overflow: hidden;
    height: 100vh;
}

.container {
    max-width: 450px;
    margin: 0 auto;
    height: 100dvh;
    display: flex;
    flex-direction: column;
    position: relative;
    background: #000;
    box-shadow: 0 0 100px rgba(124, 58, 237, 0.2);
}

@media (min-width: 1024px) {
    .container {
        max-width: 400px;
        height: min(850px, 90vh);
        margin: 5vh auto;
        border-radius: 30px;
        overflow: hidden;
        border: 4px solid var(--card-bg);
        transition: max-width 0.5s cubic-bezier(0.165, 0.84, 0.44, 1), transform 0.5s cubic-bezier(0.165, 0.84, 0.44, 1);
    }

    body.edit-mode .container {
        max-width: 810px;
    }
}

header {
    padding: 20px;
    padding-top: calc(20px + env(safe-area-inset-top));
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: linear-gradient(to bottom, rgba(12, 8, 18, 0.9), transparent);
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    z-index: 100;
    transition: width 0.5s cubic-bezier(0.165, 0.84, 0.44, 1);
}

@media (min-width: 1024px) {
    body.edit-mode header {
        width: 400px;
        right: auto;
    }
}

header h1 {
    width: 180px;
    height: 40px;
    line-height: 40px;
    font-size: 1.4rem;
    font-weight: 800;
    letter-spacing: -0.5px;
    background: var(--violet-gradient);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    white-space: nowrap;
    flex-shrink: 0;
    display: flex;
    align-items: center;
}

.header-right {
    display: flex;
    gap: 12px;
    align-items: center;
    justify-content: flex-end;
    min-width: 140px;
}

.lang-toggle {
    background: var(--glass);
    border: 1px solid rgba(167, 139, 250, 0.3);
    color: var(--text-primary);
    width: 44px;
    /* Slightly wider for stable UA/KO */
    height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    backdrop-filter: blur(10px);
    flex-shrink: 0;
    padding: 0;
}

.upload-btn {
    background: var(--violet-gradient);
    border: none;
    width: 80px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 16px;
    color: white;
    font-size: 0.8rem;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(124, 58, 237, 0.4);
}

.floating-action-btn {
    position: absolute;
    right: 15px;
    top: 75px;
    /* Increased from 20px to sit below the header */
    z-index: 150;
    width: 46px;
    height: 46px;
    border-radius: 50%;
    background: var(--glass);
    border: 1px solid rgba(167, 139, 250, 0.3);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    cursor: pointer;
    backdrop-filter: blur(10px);
    box-shadow: var(--card-shadow);
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

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

.edit-mode .floating-action-btn {
    opacity: 0;
    pointer-events: none;
}

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

.main-content {
    flex: 1;
    display: flex;
    overflow: hidden;
    position: relative;
    width: 100%;
}

.video-feed {
    flex: 1;
    overflow-y: scroll;
    scroll-snap-type: y mandatory;
    height: 100%;
    transition: all 0.5s cubic-bezier(0.165, 0.84, 0.44, 1);
}

@media (min-width: 1024px) {
    body.edit-mode .video-feed {
        width: 400px;
        flex: none;
    }
}

.subtitle-editor {
    width: 0;
    background: var(--card-bg);
    border-left: 1px solid rgba(167, 139, 250, 0.2);
    overflow-y: auto;
    transition: all 0.5s cubic-bezier(0.165, 0.84, 0.44, 1);
    display: flex;
    flex-direction: column;
    opacity: 0;
    position: absolute;
    top: 0;
    bottom: 0;
    right: 0;
    z-index: 50;
}

@media (min-width: 1024px) {
    body.edit-mode .subtitle-editor {
        width: 400px;
        opacity: 1;
        position: relative;
    }
}

@media (max-width: 600px) {
    .edit-mode .subtitle-editor {
        width: 100%;
        position: absolute;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 200;
    }
}

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

.editor-header h3 {
    font-size: 1.1rem;
    background: var(--violet-gradient);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.close-editor {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1.2rem;
    cursor: pointer;
}

.editor-sub-list {
    flex: 1;
    padding: 15px;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.sub-edit-item {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 12px;
    padding: 12px;
    border: 1px solid rgba(167, 139, 250, 0.1);
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.sub-edit-inputs {
    display: flex;
    gap: 8px;
}

.sub-edit-inputs input {
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: white;
    padding: 4px 8px;
    border-radius: 6px;
    font-size: 0.8rem;
    width: 60px;
}

.sub-edit-content {
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: white;
    padding: 8px;
    border-radius: 6px;
    font-size: 0.9rem;
    resize: none;
    height: 60px;
    font-family: inherit;
}

.sub-edit-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

.small-btn {
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 0.75rem;
    cursor: pointer;
    border: none;
}

.save-btn {
    background: var(--violet-gradient);
    color: white;
}

.del-btn {
    background: rgba(239, 68, 68, 0.2);
    color: #ef4444;
}

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

.video-item {
    height: 100%;
    width: 100%;
    scroll-snap-align: start;
    position: relative;
    background: #000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.play-pause-indicator {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.5);
    width: 80px;
    height: 80px;
    background: rgba(0, 0, 0, 0.5);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2.5rem;
    color: white;
    opacity: 0;
    pointer-events: none;
    z-index: 100;
    backdrop-filter: blur(5px);
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.play-pause-indicator.show {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
    animation: fadeOutStatus 0.8s forwards;
}

@keyframes fadeOutStatus {
    0% {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.5);
    }

    20% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }

    80% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }

    100% {
        opacity: 0;
        transform: translate(-50%, -50%) scale(1.2);
    }
}

.progress-container {
    position: absolute;
    bottom: calc(75px + env(safe-area-inset-bottom));
    left: 0;
    right: 0;
    height: 4px;
    background: rgba(255, 255, 255, 0.2);
    cursor: pointer;
    z-index: 110;
    transition: height 0.2s;
}

.progress-container:hover {
    height: 8px;
}

.progress-bar {
    height: 100%;
    background: var(--violet-gradient);
    width: 0%;
    position: relative;
    transition: width 0.1s linear;
}

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

.subtitle-overlay {
    position: absolute;
    bottom: calc(100px + env(safe-area-inset-bottom));
    left: 20px;
    right: 20px;
    text-align: center;
    pointer-events: none;
    z-index: 10;
}

.subtitle-text {
    background: rgba(30, 12, 43, 0.8);
    color: white;
    padding: 10px 20px;
    border-radius: 15px;
    font-size: 1.1rem;
    display: inline-block;
    backdrop-filter: blur(8px);
    border: 1px solid rgba(167, 139, 250, 0.3);
    box-shadow: var(--card-shadow);
    animation: fadeIn 0.3s ease-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Removed .video-actions as it's moved to header */

.action-btn {
    width: 50px;
    height: 50px;
    border-radius: 25px;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(10px);
    font-size: 1.2rem;
    cursor: pointer;
    transition: background 0.2s;
}

.action-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

.nav-bar {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: calc(75px + env(safe-area-inset-bottom));
    padding-bottom: env(safe-area-inset-bottom);
    background: linear-gradient(to top, rgba(26, 18, 37, 1) 0%, rgba(26, 18, 37, 0.9) 70%, transparent 100%);
    backdrop-filter: blur(20px);
    display: flex;
    justify-content: space-around;
    align-items: center;
    border-top: 1px solid rgba(167, 139, 250, 0.1);
    z-index: 100;
    transition: width 0.5s cubic-bezier(0.165, 0.84, 0.44, 1);
}

@media (min-width: 1024px) {
    body.edit-mode .nav-bar {
        width: 400px;
        right: auto;
    }
}

.nav-item {
    color: var(--text-secondary);
    font-size: 0.75rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    text-decoration: none;
    transition: color 0.2s;
    width: 60px;
    text-align: center;
}

.nav-item .icon {
    font-size: 1.5rem;
}

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

.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(12, 8, 18, 0.85);
    backdrop-filter: blur(10px);
    z-index: 1000;
    padding: 20px;
}

.modal-content {
    background: var(--card-bg);
    border-radius: 30px;
    padding: 40px;
    width: 100%;
    max-width: 400px;
    margin: 15vh auto;
    border: 1px solid rgba(167, 139, 250, 0.2);
    box-shadow: var(--card-shadow);
}

.modal-content h2 {
    margin-bottom: 25px;
    font-weight: 800;
    background: var(--violet-gradient);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

input,
select,
textarea {
    width: 100%;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(167, 139, 250, 0.2);
    padding: 14px;
    border-radius: 12px;
    color: white;
    margin-bottom: 20px;
    outline: none;
    transition: border-color 0.2s;
}

input:focus {
    border-color: var(--accent);
}

.primary-btn {
    width: 100%;
    padding: 16px;
    border-radius: 15px;
    border: none;
    background: var(--violet-gradient);
    color: white;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(124, 58, 237, 0.3);
    transition: transform 0.2s;
}

.primary-btn:active {
    transform: scale(0.98);
}

.secondary-btn {
    width: 100%;
    padding: 14px;
    border-radius: 12px;
    border: 1px solid rgba(167, 139, 250, 0.3);
    background: transparent;
    color: var(--text-primary);
    margin-top: 10px;
    cursor: pointer;
}