: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;
}

/* Layout Wrapper */
.container {
    height: 100dvh;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
    max-width: 400px;
    margin: 0 auto;
    transition: max-width 0.5s cubic-bezier(0.165, 0.84, 0.44, 1);
}

@media (min-width: 1024px) {
    .container {
        max-width: 400px;
        height: 90vh;
        /* Not full height on desktop, with margin handled by margin: 0 auto + flex center means we might need margin-top on container or flex parent */
        /* Actually body is h-100vh flex center? No body is just h-100vh.
           Let's center container vertically in body or give margins. */
        margin-top: 5vh;
        height: 90vh;
    }

    body.edit-mode .container {
        max-width: 840px;
        /* 400 + 400 + 40 gap */
    }
}

/* The Main "Phone" Card */
.phone-frame {
    flex: 1;
    width: 100%;
    height: 100%;
    background: #000;
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: 0 0 100px rgba(124, 58, 237, 0.2);
    /* In mobile it's full screen. In desktop it has radius/border */
}

@media (min-width: 1024px) {
    .phone-frame {
        max-width: 400px;
        border-radius: 30px;
        border: 4px solid var(--card-bg);
        /* Flex shrink prevented by max-width matching container default?
           Actually container is flex row. phone-frame is item. */
        flex-shrink: 0;
    }
}

/* Header & Nav need to be absolute inside phone-frame or just standard blocks?
   Originally they were absolute/fixed. Inside phone-frame relative container, absolute works. */
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;
}

header h1 {
    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;
}

#dayIndicator {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-secondary);
    -webkit-text-fill-color: var(--text-secondary);
    margin-top: -2px;
}

.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;
    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);
}

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

/* Main Content Area */
.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%;
    /* No width transition handling here anymore */
}

/* Floating Action Button inside Video Feed */
.floating-action-btn {
    position: absolute;
    right: 15px;
    top: 75px;
    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;
}

/* Sidebar Editor - Independent Card */
.subtitle-editor {
    /* Basics */
    background: var(--card-bg);
    display: flex;
    flex-direction: column;
    z-index: 50;
    overflow: hidden;
    /* Hide content when width is 0 */

    /* Layout transition */
    width: 0;
    opacity: 0;
    margin-left: 0;
    transition: all 0.5s cubic-bezier(0.165, 0.84, 0.44, 1);
}

/* Desktop: Side-by-side Layout */
@media (min-width: 1024px) {
    .subtitle-editor {
        /* Independent Card Look */
        height: 100%;
        border-radius: 30px;
        border: 1px solid rgba(167, 139, 250, 0.2);
        box-shadow: 0 0 50px rgba(0, 0, 0, 0.5);
    }

    body.edit-mode .subtitle-editor {
        width: 400px;
        opacity: 1;
        margin-left: 40px;
        /* The gap */
    }
}

/* Mobile: Overlay behavior */
@media (max-width: 1023px) {
    .container {
        /* Fullscreen on mobile */
        max-width: 100%;
        height: 100dvh;
        margin: 0;
    }

    .phone-frame {
        border-radius: 0;
        border: none;
    }

    .subtitle-editor {
        position: absolute;
        top: 0;
        bottom: 0;
        left: 0;
        right: 0;
        width: 100%;
        transform: translateY(100%);
        /* Slide up from bottom or just overlay? */
        /* Let's transform Y for mobile slide up effect */
        transition: transform 0.3s ease-out;
        opacity: 1;
        /* Always opacity 1 for overlay but hidden by transform/display */
        z-index: 200;
        /* Reset width logic from desktop */
        margin-left: 0;
    }

    body.edit-mode .subtitle-editor {
        width: 100%;
        margin-left: 0;
        transform: translateY(0);
    }
}

/* Editor Internals */
.editor-header {
    padding: 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--card-bg);
}

.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;
    overflow-y: auto;
}

.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;
    margin-bottom: 0;
    /* Override global input margin */
}

.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;
    width: 100%;
}

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

.small-btn {
    height: 32px;
    min-width: 60px;
    padding: 0 10px;
    border-radius: 8px;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

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

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


/* Scrollbar Hiding */
.video-feed::-webkit-scrollbar,
.editor-sub-list::-webkit-scrollbar {
    display: none;
}

/* Video Items */
.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 */
.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 Bar */
.progress-container {
    position: absolute;
    bottom: calc(55px + 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 */
.subtitle-overlay {
    position: absolute;
    bottom: calc(80px + 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);
    }
}

/* Nav Bar */
.nav-bar {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: calc(55px + 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;
}

.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.3rem;
}

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

/* Modals */
.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;
}

/* Global Form Elements */
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;
}

/* Day Grid */
.day-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 10px;
    margin-top: 20px;
    margin-bottom: 20px;
}

.day-cell {
    aspect-ratio: 1;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(167, 139, 250, 0.2);
    border-radius: 10px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
}

.day-cell.active {
    background: var(--violet-gradient);
    border: none;
    box-shadow: 0 4px 10px rgba(124, 58, 237, 0.3);
}

.day-cell.disabled {
    opacity: 0.3;
    pointer-events: none;
}

.day-cell .day-num {
    font-size: 0.9rem;
    font-weight: 700;
    color: white;
}

.day-cell .day-status {
    font-size: 0.6rem;
    color: var(--text-secondary);
}

.day-cell.active .day-status {
    color: rgba(255, 255, 255, 0.8);
}

.day-indicator-floating {
    position: absolute;
    left: 15px;
    top: 75px;
    z-index: 150;
    height: 46px;
    display: flex;
    align-items: center;
    font-weight: 700;
    font-size: 0.9rem;
    color: var(--text-primary);
    background: var(--glass);
    padding: 0 16px;
    border-radius: 23px;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(167, 139, 250, 0.3);
    box-shadow: var(--card-shadow);
    pointer-events: none;
    transition: all 0.3s ease;
}


.video-item {
    scroll-margin-top: 0;
    /* Ensures block:start aligns exactly to Top */
}

/* Upload Progress Bar */
.upload-progress-bg {
    width: 100%;
    height: 12px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 6px;
    overflow: hidden;
    border: 1px solid rgba(167, 139, 250, 0.2);
}

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