body {
    --primary: #3b82f6;
    --primary-dark: #1d4ed8;
    --surface: rgba(255, 255, 255, 0.78);
    --surface-strong: rgba(255, 255, 255, 0.92);
    --border: rgba(148, 163, 184, 0.35);
    --text: #1f2937;
    height: 100vh;
    --shadow-lg: 0 24px 48px rgba(15, 23, 42, 0.18);
    box-sizing: border-box;
    --radius-lg: 18px;
    overflow-y: hidden;
    --player-max-width: 880px;
    --sidebar-shift: 420px;
    --player-max-video-height: 495px;
}

body {
    font-family: 'Inter', 'Segoe UI', -apple-system, BlinkMacSystemFont, sans-serif;
    background: radial-gradient(circle at 0% 0%, #e0e7ff 0%, #f8fafc 45%, #ffffff 100%);
    color: var(--text);
    display: flex;
    flex-direction: column;
    align-items: center;
    min-height: 100vh;
    margin: 0;
    overflow-x: hidden;
    overflow-y: auto;
    position: relative;
    padding-top: 10px;
}

body::after {
    content: '';
    position: fixed;
    inset: 0;
    background: radial-gradient(1200px circle at 85% 10%, rgba(59, 130, 246, 0.09), transparent 60%),
        radial-gradient(900px circle at 10% 75%, rgba(14, 165, 233, 0.08), transparent 55%);
    pointer-events: none;
    z-index: -1;
}

#initialLoadArea {
    display: flex;
    width: min(100%, 820px);
    min-height: 320px;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    flex-grow: 1;
    text-align: center;
    border: 1px dashed rgba(148, 163, 184, 0.6);
    border-radius: var(--radius-lg);
    margin: 24px 0 32px;
    cursor: pointer;
    background: var(--surface);
    color: var(--text-muted);
    backdrop-filter: blur(18px);
    box-shadow: var(--shadow-lg);
    padding: 48px 30px;
    transition: border-color 0.25s ease, transform 0.25s ease, box-shadow 0.25s ease;
    will-change: transform;
}

#initialLoadArea.dragover {
    border-color: rgba(59, 130, 246, 0.55);
    box-shadow: 0 28px 55px rgba(37, 99, 235, 0.18);
    transform: translateY(-4px);
}

#initialLoadArea p {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text);
    margin: 0;
}

/* Style for when subtitle player is active */
.player-active #initialLoadArea {
    display: none;
}

#srtFile {
    margin-bottom: 20px;
    padding: 10px;
    border: 1px solid #ccc;
    border-radius: 4px;
}

#subtitleDisplay {
    width: min(100%, var(--player-max-width));
    max-width: var(--player-max-width);
    height: 520px;
    overflow-y: auto;
    border: 1px solid rgba(15, 23, 42, 0.08);
    background: #ffffff;
    margin: 24px auto 16px;
    border-radius: var(--radius-lg);
    text-align: left;
    box-shadow: var(--shadow-lg);
    position: relative;
    padding: 32px 0 110px;
    display: none;
    transition: transform 0.32s ease;
    will-change: transform;
}

body.player-active #subtitleDisplay {
    display: block;
}

body.sidebar-open #videoDropArea,
body.sidebar-open #videoPlayer,
body.sidebar-open #initialLoadArea,
body.sidebar-open #subtitleDisplay {
    transform: translateX(calc(-0.5 * var(--sidebar-shift)));
}

@media (max-width: 720px) {
    body.sidebar-open #videoDropArea,
    body.sidebar-open #videoPlayer,
    body.sidebar-open #initialLoadArea,
    body.sidebar-open #subtitleDisplay {
        transform: translateX(0);
    }
}

.subtitle-line {
    position: relative;
    /* ADDED/MODIFIED */
    padding: 12px 18px 12px 48px;
    margin-bottom: 6px;
    line-height: 1.65;
    opacity: 1;
    color: #0b1120;
    font-weight: 500;
    text-align: left;
    letter-spacing: 0.01em;
}

.play-on-hover-btn {
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    display: none;
    cursor: pointer;
    border-radius: 50%;
    width: 32px;
    height: 32px;
    font-size: 15px;
    color: var(--primary);
    background: rgba(59, 130, 246, 0.12);
    transition: background 0.2s ease, transform 0.2s ease;
    box-shadow: 0 10px 18px rgba(59, 130, 246, 0.18);
    align-items: center;
    justify-content: center;
}

.subtitle-line:hover .play-on-hover-btn {
    display: inline-flex;
}

/* .translation-text and .subtitle-line.loading-translation styles removed */

.subtitle-line.highlight {
    font-weight: 600;
    color: var(--primary);
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.12), rgba(59, 130, 246, 0.04));
    opacity: 1;
    border-radius: var(--radius-md);
    transform: translateY(-1px);
    box-shadow: 0 10px 22px rgba(59, 130, 246, 0.15);
}

#controls {
    /* position: fixed; bottom: 0; left: 0; z-index: 1000; removed */
    /* width: 100%; */
    /* Replaced by width: 80% and max-width */
    width: 80%;
    max-width: 800px;
    /* border-top: 1px solid #eaeaea; */
    /* background-color: rgba(30, 30, 30, 0.9); */
    /* Replaced */
    background-color: #ffffff;
    /* Light grey background */
    /* padding: 12px 0; */
    /* Replaced by padding: 10px */
    padding: 10px 15px;
    display: flex;
    /* Kept */
    justify-content: space-between;
    /* Kept */
    align-items: center;
    /* Kept */
    box-sizing: border-box;
    /* Kept */
}

#seekBar {
    width: 80%;
    /* Or other appropriate width */
    margin: 0 15px;
    /* Space around seek bar */
    cursor: pointer;
    /* Optional: Add custom styling for track and thumb if desired later */
}

#playPauseBtn {
    background-color: var(--primary);
    /* Match previous button color or choose new */
    color: white;
    border: none;
    border-radius: 50%;
    /* Make it circular */
    width: 50px;
    /* Fixed width */
    height: 50px;
    /* Fixed height */
    font-size: 24px;
    /* Adjust icon size */
    line-height: 50px;
    /* Center icon vertically - can be redundant with flex */
    text-align: center;
    padding: 0;
    /* Remove default padding */
    margin: 0 10px;
    /* Keep existing margin or adjust */
    cursor: pointer;
    display: flex;
    /* To help center span if needed */
    justify-content: center;
    /* Center icon horizontally */
    align-items: center;
    /* Center icon vertically */
}

#playPauseBtn:disabled {
    background-color: #ccc;
    cursor: not-allowed;
}

#playPauseBtn:hover:not(:disabled) {
    background-color: var(--primary-dark);
    /* Darker on hover */
}

#playPauseIcon {
    display: inline-block;
    /* Allows fine-tuning if needed */
    /* If icon is slightly off, flex properties on button are primary for centering */
}


#controls button {
    /* These styles will apply to other buttons if any are added to #controls later, */
    /* but #playPauseBtn will mostly use its own specific styles. */
    padding: 10px 20px;
    margin: 0 10px;
    border: none;
    background-color: var(--primary);
    color: white;
    border-radius: 50%;
    cursor: pointer;
    font-size: 20px;
}

#controls button:disabled {
    background-color: #ccc;
    cursor: not-allowed;
}

#controls button:hover:not(:disabled) {
    background-color: var(--primary-dark);
}

/* AI Chat Sidebar Styles */
#aiChatSidebar {
    position: fixed;
    top: 0;
    right: -420px;
    width: 420px;
    padding: 28px 28px 32px;
    box-sizing: border-box;
    max-width: 90vw;
    height: 100%;
    background: rgba(248, 250, 252, 0.92);
    border-left: 1px solid rgba(148, 163, 184, 0.35);
    box-shadow: -24px 0 60px rgba(15, 23, 42, 0.18);
    z-index: 1002;
    transition: right 0.32s cubic-bezier(.4, 0, .2, 1);
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    backdrop-filter: blur(22px);
}

#aiChatSidebar.open {
    right: 0;
}

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 12px;
    margin-bottom: 16px;
    padding-right: 50px;
}

.sidebar-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

.sidebar-icon-btn {
    background: rgba(255, 255, 255, 0.7);
    border: 1px solid rgba(148, 163, 184, 0.3);
    color: var(--text);
    border-radius: 8px;
    padding: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    backdrop-filter: blur(8px);
}

.sidebar-icon-btn:hover {
    background: rgba(59, 130, 246, 0.1);
    border-color: rgba(59, 130, 246, 0.4);
    color: var(--primary);
    transform: translateY(-1px);
}

.sidebar-icon-btn:active {
    transform: translateY(0);
}

.sidebar-icon-btn svg {
    display: block;
}

.sidebar-action-btn {
    background: linear-gradient(135deg, var(--primary), #60a5fa);
    color: #fff;
    border: none;
    border-radius: 999px;
    padding: 8px 18px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 12px 22px rgba(59, 130, 246, 0.28);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    margin-right: 50px;
}

.sidebar-action-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 16px 28px rgba(37, 99, 235, 0.32);
}

@media (max-width: 500px) {

    #aiChatSidebar,
    #aiChatSidebar.open {
        width: 100vw;
        right: 0;
        padding: 24px 20px 28px;
    }
}

#sidebarCloseBtn {
    position: absolute;
    top: 18px;
    right: 20px;
    background: rgba(15, 23, 42, 0.04);
    border: 1px solid rgba(148, 163, 184, 0.4);
    color: var(--text-muted);
    font-size: 20px;
    cursor: pointer;
    padding: 6px 12px;
    border-radius: 999px;
    line-height: 1;
    transition: background 0.2s ease, color 0.2s ease;
}

#sidebarCloseBtn:hover {
    background: rgba(59, 130, 246, 0.12);
    color: var(--primary);
}

#aiChatSidebar h3 {
    font-size: 1.05rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    color: var(--text);
    margin: 0;
}

#aiChatSidebar h3:first-of-type {
    margin-top: 0;
}


#sidebarSentenceContext {
    font-size: 0.95em;
}

#sidebarChatHistory {
    flex-grow: 1;
    overflow-y: auto;
    border: 1px solid rgba(148, 163, 184, 0.35);
    padding: 18px 18px 12px;
    margin-bottom: 18px;
    background-color: rgba(255, 255, 255, 0.82);
    border-radius: var(--radius-md);
    display: flex;
    flex-direction: column;
    gap: 12px;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.45);
}


.sidebar-input-area {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: auto;
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid rgba(148, 163, 184, 0.32);
    border-radius: var(--radius-md);
    padding: 16px;
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.4);
}

.sidebar-context {
    background: linear-gradient(140deg, rgba(59, 130, 246, 0.12), rgba(59, 130, 246, 0.03));
    border: 1px solid rgba(59, 130, 246, 0.25);
    border-radius: var(--radius-md);
    padding: 14px 18px 16px;
    position: relative;
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.6);
}

.sidebar-context::before {
    content: '';
    position: absolute;
    left: 12px;
    bottom: -10px;
    width: 16px;
    height: 16px;
    background: inherit;
    border-left: inherit;
    border-bottom: inherit;
    transform: rotate(45deg);
    border-radius: 0 0 0 4px;
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.5);
}

.context-label {
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--primary);
    text-transform: uppercase;
    letter-spacing: 0.12em;
    margin-bottom: 6px;
}

#sidebarSentenceContext {
    max-height: 140px;
    overflow-y: auto;
    margin: 0;
    padding-left: 14px;
    border-left: 3px solid rgba(59, 130, 246, 0.45);
    color: var(--text);
    font-style: italic;
    line-height: 1.55;
    background: transparent;
}

.sidebar-send-row {
    display: flex;
    gap: 10px;
}

#sidebarQuestionInput {
    flex: 1;
    padding: 12px 16px;
    border: 1px solid rgba(148, 163, 184, 0.4);
    border-radius: var(--radius-md);
    font-size: 0.95em;
    background: rgba(248, 250, 252, 0.9);
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

#sidebarQuestionInput:focus {
    outline: none;
    border-color: rgba(59, 130, 246, 0.55);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.18);
}

#sidebarSendQuestionBtn {
    padding: 12px 20px;
    background: linear-gradient(135deg, var(--primary), #60a5fa);
    color: white;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    font-size: 0.95em;
    font-weight: 600;
    box-shadow: 0 12px 24px rgba(59, 130, 246, 0.28);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    flex-shrink: 0;
}

#sidebarSendQuestionBtn:hover {
    transform: translateY(-1px);
    box-shadow: 0 16px 30px rgba(37, 99, 235, 0.32);
}

/* Styles for chat messages (add more as needed) */
.user-message {
    text-align: right;
    display: flex;
    justify-content: flex-end;
}

.user-message p {
    background: linear-gradient(135deg, var(--primary), #60a5fa);
    color: #f8fafc;
    padding: 10px 14px;
    border-radius: 20px 20px 4px 20px;
    display: inline-block;
    max-width: 82%;
    margin: 0;
    box-shadow: 0 14px 28px rgba(37, 99, 235, 0.22);
}

.ai-message {
    text-align: left;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
    background: rgba(15, 23, 42, 0.04);
    border-radius: 18px 18px 18px 6px;
    padding: 10px 14px;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.65), 0 10px 22px rgba(15, 23, 42, 0.12);
}

.ai-message p {
    color: var(--text);
    padding: 0;
    display: block;
    width: 100%;
    margin: 0;
    white-space: normal;
}

.quick-prompt-btn {
    background: rgba(59, 130, 246, 0.12);
    color: var(--primary);
    border: 1px solid rgba(59, 130, 246, 0.25);
    border-radius: 999px;
    padding: 8px 16px;
    font-size: 0.85rem;
    font-weight: 600;
    letter-spacing: 0.01em;
    cursor: pointer;
    transition: background 0.2s ease, transform 0.2s ease, color 0.2s ease;
}

.quick-prompt-btn:hover {
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.22), rgba(96, 165, 250, 0.28));
    color: #0f172a;
    transform: translateY(-1px);
}

#quickPromptButtons {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 12px;
}

#subtitleDisplay,
#sidebarChatHistory,
#sidebarSentenceContext {
    scrollbar-width: thin;
    scrollbar-color: rgba(59, 130, 246, 0.35) transparent;
}

.correction-modal {
    position: fixed;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1100;
}

.correction-modal.open {
    display: flex;
}

.correction-modal__overlay {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.45);
    backdrop-filter: blur(2px);
}

.correction-modal__dialog {
    position: relative;
    z-index: 1101;
    width: min(480px, 90vw);
    background: rgba(255, 255, 255, 0.98);
    border-radius: var(--radius-lg);
    box-shadow: 0 40px 80px rgba(15, 23, 42, 0.25);
    padding: 28px 32px 32px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.correction-modal__close {
    position: absolute;
    top: 18px;
    right: 22px;
    border: none;
    background: transparent;
    font-size: 22px;
    color: var(--text-muted);
    cursor: pointer;
}

.correction-modal__hint {
    margin: -4px 0 4px;
    font-size: 0.88rem;
    color: var(--text-muted);
}

.correction-modal__form {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.correction-modal__field {
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 0.9rem;
    color: var(--text);
}

.correction-modal__field input,
.correction-modal__field textarea {
    border: 1px solid rgba(148, 163, 184, 0.4);
    border-radius: var(--radius-md);
    padding: 10px 12px;
    font-size: 0.95rem;
    resize: vertical;
    min-height: 42px;
    background: rgba(248, 250, 252, 0.9);
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.correction-modal__field input:focus,
.correction-modal__field textarea:focus {
    outline: none;
    border-color: rgba(59, 130, 246, 0.55);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.18);
}

.correction-modal__actions {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    margin-top: 6px;
}

.modal-btn {
    padding: 10px 20px;
    border-radius: var(--radius-md);
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.modal-btn--primary {
    background: linear-gradient(135deg, var(--primary), #60a5fa);
    color: #fff;
    box-shadow: 0 16px 28px rgba(59, 130, 246, 0.28);
}

.modal-btn--primary:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    box-shadow: none;
}

.modal-btn--secondary {
    background: rgba(148, 163, 184, 0.18);
    color: var(--text);
    border: 1px solid rgba(148, 163, 184, 0.32);
}

.modal-btn:hover:not(:disabled) {
    transform: translateY(-1px);
}

.correction-modal__feedback {
    min-height: 18px;
    font-size: 0.85rem;
    color: var(--primary);
    margin: 4px 0 0;
}

.correction-modal__feedback--error {
    color: #dc2626;
}

#subtitleDisplay::-webkit-scrollbar,
#sidebarChatHistory::-webkit-scrollbar,
#sidebarSentenceContext::-webkit-scrollbar {
    width: 6px;
}

#subtitleDisplay::-webkit-scrollbar-thumb,
#sidebarChatHistory::-webkit-scrollbar-thumb,
#sidebarSentenceContext::-webkit-scrollbar-thumb {
    background: rgba(59, 130, 246, 0.35);
    border-radius: 999px;
}

#subtitleDisplay::-webkit-scrollbar-track,
#sidebarChatHistory::-webkit-scrollbar-track,
#sidebarSentenceContext::-webkit-scrollbar-track {
    background: transparent;
}

.subtitle-line:hover {
    background: rgba(15, 23, 42, 0.04);
    opacity: 0.92;
    cursor: pointer;
}

#videoDropArea {
    width: min(100%, var(--player-max-width));
    height: 460px;
    background: linear-gradient(145deg, rgba(15, 23, 42, 0.92), rgba(30, 41, 59, 0.82));
    color: #f8fafc;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    cursor: pointer;
    transition: transform 0.25s ease, box-shadow 0.25s ease, background 0.25s ease;
    border-radius: var(--radius-lg);
    box-shadow: 0 28px 55px rgba(15, 23, 42, 0.35);
    position: relative;
    overflow: hidden;
    margin: 0 auto;
    will-change: transform;
}

#videoDropArea::after {
    content: '';
    position: absolute;
    inset: 0;
    border: 1px solid rgba(148, 163, 184, 0.28);
    border-radius: inherit;
    pointer-events: none;
}

#videoDropArea.dragover {
    transform: translateY(-4px) scale(1.01);
    box-shadow: 0 32px 65px rgba(37, 99, 235, 0.28);
    background: linear-gradient(145deg, rgba(59, 130, 246, 0.92), rgba(14, 165, 233, 0.82));
}

#videoPlayer {
    display: none;
    width: min(100%, var(--player-max-width));
    max-width: var(--player-max-width);
    aspect-ratio: 16 / 9;
    height: auto;
    border-radius: var(--radius-lg);
    box-shadow: 0 32px 60px rgba(15, 23, 42, 0.26);
    background: #000;
    position: sticky;
    z-index: 900;
    transition: transform 0.32s ease;
    will-change: transform;
}

@media (max-width: 900px) {
    #subtitleDisplay {
        margin: 28px auto 16px;
        height: 480px;
        padding: 28px 0 96px;
    }

}

@media (max-width: 600px) {
    #subtitleDisplay {
        margin: 24px auto 16px;
        height: 360px;
        padding: 24px 0 80px;

    }

    #videoDropArea {
        height: 320px;
    }

    .sidebar-input-area {
        padding: 14px;
    }

    #sidebarSendQuestionBtn {
        padding-inline: 16px;
    }

}