/* --- APP LAYOUT --- */
/* 1. Force the Main Content to be a fixed Flexbox */
main.main-content {
    display: flex !important;
    flex-direction: column !important;
    height: 100vh !important; /* Full Viewport Height */
    overflow: hidden !important;
    padding: 0 !important;
}
/* Personal area: allow main to scroll so user can see all files */
main.main-content:has(.personal-area-page) {
    overflow-y: auto !important;
    overflow-x: hidden !important;
}
/* Blog page: allow vertical scrolling for long posts */
main.main-content:has(.blog-page) {
    overflow-y: auto !important;
    overflow-x: hidden !important;
}

/* Initial homepage SEO content (visible before upload starts) */
.seo-home-content {
    max-width: 900px;
    margin: 0 auto 18px;
    padding: 16px 18px;
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
}
.seo-home-content h1 {
    margin: 0 0 10px;
    font-size: 1.8rem;
    line-height: 1.35;
    color: #4f46e5; /* Fallback if gradient text clipping is unsupported */
    background: linear-gradient(90deg, #3b82f6 0%, #7c3aed 55%, #ec4899 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}
.seo-home-content .seo-hero-subtitle {
    margin: 0 0 16px;
    color: #4b5563;
    font-size: 1rem;
}
.seo-home-content section {
    margin-top: 14px;
}
.seo-home-content h2 {
    margin: 0 0 6px;
    font-size: 1.1rem;
    color: #1f2937;
}
.seo-home-content p {
    margin: 0;
    color: #374151;
    line-height: 1.65;
}
.seo-home-content details {
    margin-top: 8px;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 8px 10px;
    background: #f9fafb;
}
.seo-home-content summary {
    cursor: pointer;
    font-weight: 600;
    color: #111827;
}

/* Global confirm dialog: always a fixed centered popup (e.g. erase account) on any page */
#global-confirm-overlay {
    position: fixed !important;
    inset: 0 !important;
    display: none;
    align-items: center;
    justify-content: center;
    background: rgba(15, 23, 42, 0.5);
    backdrop-filter: blur(6px);
    z-index: 10000 !important;
}
#global-confirm-overlay.is-open {
    display: flex !important;
}
#global-confirm-overlay .personal-dialog {
    background: #fff;
    padding: 24px;
    border-radius: 20px;
    width: min(420px, 92vw);
    box-shadow: 0 20px 48px rgba(15, 23, 42, 0.2);
    animation: globalDialogIn 160ms ease;
}
@keyframes globalDialogIn {
    from { opacity: 0; transform: scale(0.96); }
    to { opacity: 1; transform: scale(1); }
}
#global-confirm-overlay .personal-dialog-message {
    margin: 0 0 20px 0;
    font-size: 1rem;
    line-height: 1.5;
    color: #0f172a;
}
#global-confirm-overlay .personal-dialog-actions {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
}
#global-confirm-overlay .personal-dialog-btn {
    padding: 10px 18px;
    border-radius: 10px;
    font-size: 0.9rem;
    font-weight: 600;
    border: none;
    cursor: pointer;
}
#global-confirm-overlay .personal-dialog-btn.cancel {
    background: #f1f5f9;
    color: #475569;
}
#global-confirm-overlay .personal-dialog-btn.primary.danger {
    background: #dc2626;
    color: #fff;
}
#global-confirm-overlay .personal-dialog-btn.primary.danger:hover {
    background: #b91c1c;
}

/* Burn video progress overlay */
#burn-progress-overlay {
    position: fixed;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    background: rgba(15, 23, 42, 0.3);
    z-index: 11000;
}
.burn-progress-card {
    width: min(520px, 92vw);
    background: #fff;
    border-radius: 14px;
    box-shadow: 0 20px 48px rgba(15, 23, 42, 0.2);
    padding: 16px 18px;
}
.burn-progress-text {
    font-size: 0.95rem;
    color: #111827;
    margin-bottom: 10px;
}
.burn-progress-track {
    width: 100%;
    height: 10px;
    border-radius: 999px;
    background: #e5e7eb;
    overflow: hidden;
}
.burn-progress-fill {
    width: 0%;
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, #2563eb, #60a5fa);
    transition: width 300ms ease;
}

.app-mode {
    flex: 1;
    display: flex;
    flex-direction: column;

    /* CRITICAL: Subtract the 80px Navbar height so it fits exactly */
    height: calc(100vh - 80px) !important;
    max-height: calc(100vh - 80px) !important;

    background-color: #f8f9fa;
    overflow: hidden !important; /* STOP the page from scrolling */
}

/* 3. Lock the inner container */
.main-app-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: 1000px;
    margin: 0 auto;
    padding: 10px 15px;
    box-sizing: border-box;
    overflow: hidden !important; /* Forces children to stay inside */
    min-height: 0 !important;   /* Critical Flexbox Fix */
}

/* --- AUDIO PLAYER --- */
#audio-player-container {
    flex: 0 0 auto;
    margin-bottom: 12px;
    display: none;
    width: 100%;
}

audio {
    width: 100%;
    height: 40px;
}

/* --- AUDIO PLAYER (default after transcription) --- */
#audio-player-container audio {
    border-radius: 8px;
}

/* --- VIDEO PLAYER (shown when Styled Subtitles is clicked) --- */
#video-wrapper {
    flex: 0 0 auto;
    margin-bottom: 12px;
    gap: 12px;
    align-items: flex-start;
}

#video-wrapper.visible {
    display: flex !important;
    justify-content: center;
}

#video-player-container {
    display: flex;
    justify-content: center;
    align-items: center;
    background: #fff;
    width: 100%;
    max-width: 900px;
    margin: 0 auto;
    max-height: 280px;
    overflow: hidden;
}

/* When audio (m4a/mp3) is shown inside the video player area, match video box size so it's one big "player" */
#video-player-container #audio-player-container {
    width: 100%;
    min-height: 200px;
    margin: 0;
    padding: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #fff;
}
#video-player-container #audio-player-container audio {
    width: 100%;
    max-width: 100%;
}

#main-video {
    max-width: 100%;
    max-height: 280px;
    width: auto;
    height: auto;
    object-fit: contain;
    background: #fff;
    display: block;
}

/* --- SUBTITLE STYLE SELECTOR --- */
#subtitle-style-selector {
    flex-shrink: 0;
}

.subtitle-style-card {
    transition: all 0.2s ease;
    display: block;
}

.subtitle-style-card:hover {
    border-color: #5d5dff !important;
    transform: translateX(2px);
    box-shadow: 0 2px 8px rgba(93, 93, 255, 0.15);
}

.subtitle-style-card.active {
    border-color: #5d5dff !important;
    background: #f0f7ff !important;
    box-shadow: 0 2px 8px rgba(93, 93, 255, 0.2);
}

/* --- SUBTITLE STYLES FOR VIDEO TRACK --- */

/* TikTok Bold Style — bold, large, yellow only */
#main-video.subtitle-style-tiktok::cue {
    font-size: 2.5em;
    font-weight: 700;
    color: #ffd700;
    text-shadow: 
        -2px -2px 0 #000,
        2px -2px 0 #000,
        -2px 2px 0 #000,
        2px 2px 0 #000,
        -3px 0 0 #000,
        3px 0 0 #000,
        0 -3px 0 #000,
        0 3px 0 #000;
    text-align: center;
    line-height: 1.2;
    background: transparent;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

#main-video.subtitle-style-tiktok::cue(.highlight) {
    background: transparent;
    color: #ffd700;
    padding: 2px 4px;
    border-radius: 4px;
}

/* Clean Pro Style */
#main-video.subtitle-style-clean::cue {
    font-size: 1.4em;
    font-weight: 500;
    color: white;
    text-shadow: 
        0 1px 3px rgba(0, 0, 0, 0.8),
        0 2px 6px rgba(0, 0, 0, 0.6);
    text-align: center;
    line-height: 1.3;
    background: transparent;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    padding-bottom: 10%;
}

/* Cinematic Dramatic Style */
#main-video.subtitle-style-cinematic::cue {
    font-size: 1.6em;
    font-weight: 400;
    color: #f5f5f5;
    text-shadow: 
        0 2px 4px rgba(0, 0, 0, 0.7),
        0 4px 8px rgba(0, 0, 0, 0.5);
    text-align: center;
    line-height: 1.4;
    background: transparent;
    font-family: "Times New Roman", Times, serif;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    padding-bottom: 8%;
}

/* --- SUBTITLE LOOK ON MOBILE: no gray background; TikTok centered via VTT only --- */
@media (max-width: 768px) {
    #main-video.subtitle-style-tiktok::cue,
    #main-video.subtitle-style-tiktok::cue(.highlight),
    #main-video.subtitle-style-clean::cue,
    #main-video.subtitle-style-cinematic::cue {
        background: transparent !important;
        background-color: transparent !important;
        background-image: none !important;
        background-clip: unset !important;
        -webkit-background-clip: unset !important;
        outline: none !important;
        box-shadow: none !important;
    }
    #main-video.subtitle-style-tiktok::cue {
        font-size: 1.15em;
    }
    #main-video.subtitle-style-tiktok::cue(.highlight) {
        font-size: 1.15em;
    }
    #main-video.subtitle-style-clean::cue {
        font-size: 1.05em;
    }
    #main-video.subtitle-style-cinematic::cue {
        font-size: 1.1em;
    }
}

/* --- HORIZONTAL CONTROLS BAR --- */
.controls-bar {
    flex: 0 0 auto;
    padding: 8px 15px;
    background: #f1f3f5;
    border: 1px solid #e5e7eb;
    border-bottom: none;
    border-radius: 8px 8px 0 0;
    display: none; /* Shown by logic after transcription */
    justify-content: space-between;
    align-items: center;
}

.toggles-group, .toolbar-group, .action-buttons {
    display: flex;
    gap: 15px;
    align-items: center;
}

/* --- TOGGLE SWITCH STYLING --- */
.controls-bar label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 0.85rem;
}

.toggle-switch {
    position: relative;
    display: inline-block;
    width: 34px;
    height: 18px;
}

.toggle-switch input { opacity: 0; width: 0; height: 0; }

.slider {
    position: absolute;
    cursor: pointer;
    top: 0; left: 0; right: 0; bottom: 0;
    background-color: #ccc;
    transition: .4s;
    border-radius: 34px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 12px;
    width: 12px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
}

input:checked + .slider { background-color: #5d5dff; }
input:checked + .slider:before { transform: translateX(16px); }

/* --- TOOLBAR BUTTONS --- */
.btn-icon {
    background: #fff;
    border: 1px solid #ccc;
    border-radius: 8px;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: #333;
    transition: all 0.2s;
}

.btn-icon:hover {
    background: #f0f0f0;
    border-color: #bbb;
}

/* Styled Subtitles button - image button with hover tooltip "edit and style subtitles" */
.btn-styled-subtitles {
    padding: 0;
    border: none;
    background: transparent;
    cursor: pointer;
    transition: transform 0.2s;
    vertical-align: middle;
    line-height: 0;
}

.btn-styled-subtitles:hover {
    transform: scale(1.05);
}

.btn-styled-subtitles-img {
    display: block;
    height: 36px;
    width: auto;
    max-width: 120px;
    object-fit: contain;
}

.btn-icon svg {
    width: 20px;
    height: 20px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
}


/* 4. The Wrapper must NOT grow. It must force the scrollbar */
.transcription-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;

    min-height: 0 !important;    /* Allows the child to shrink/scroll */
    overflow: hidden !important; /* Forces scrollbar to appear on child */
    position: relative;
    margin-bottom: 10px;
}
/* 5. The Window ITSELF handles the scroll */
#transcript-window {
    flex: 1;
    overflow-y: auto !important; /* Scrollbar lives here */
    height: auto !important;     /* Let Flex handle the height */
    padding: 20px;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 0 0 8px 8px;
    direction: rtl;
    text-align: right;
    /* Visual Fixes */
    display: block;
}
/* While editing: text cursor (I-beam), no jump on click */
#transcript-window.transcript-editing,
#transcript-window.transcript-editing .paragraph-row p {
    cursor: text;
}
.paragraph-row {
    display: flex;
    gap: 15px;
    margin-bottom: 20px;
    direction: rtl;
}

/* Active subtitle highlight (desktop + mobile) */
.active-highlight {
    background-color: #f0f7ff !important;
    border-left: 4px solid #1e3a8a !important;
}

.ts-col {
    min-width: 55px;
    color: #9ca3af;
    font-family: monospace;
    font-size: 0.85rem;
    text-align: left;
}

.speaker-label {
    display: block;
    color: #4f46e5; /* Primary Indigo Color for Speakers */
    font-weight: 700;
    font-size: 0.95rem;
    margin-bottom: 4px;
}

.clickable-sent {
    cursor: pointer;
    transition: background 0.15s;
    padding: 2px 0;
}

.clickable-sent:hover { background-color: #fef9c3; }

.is-editing .clickable-sent {
    cursor: text;
    border-bottom: 1px dashed #ccc;
}

.hide-time .ts-col, .hide-speaker .speaker-label {
    display: none !important;
}

/* --- DROPDOWN --- */
.dropdown-menu {
    position: absolute;
    top: 110%; right: 0;
    background: white;
    border: 1px solid #ddd;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    display: none;
    flex-direction: column;
    min-width: 140px;
    z-index: 100;
}

.dropdown-menu.show { display: flex; }

.dropdown-item {
    padding: 10px 15px;
    cursor: pointer;
    border: none;
    background: none;
    text-align: left;
    width: 100%;
}

.dropdown-item:hover {
    background: #f0f0ff;
    color: #5d5dff;
}

/* --- BAR-GRAPH (PROGRESS BAR) --- */
.progress-container {
    height: 10px;
    background: #e5e7eb;
    border-radius: 10px;
    overflow: hidden;
}

#progress-bar {
    height: 100%;
    width: 0%;
    background: #5d5dff;
    transition: width 0.3s ease;
}

/* --- UPLOAD ZONE & SHADED BUTTON --- */
.upload-zone {
    flex: 0 0 auto;
    padding: 15px;
    text-align: center;
    background: #f8f9fa;
    border-top: 1px solid #eee;
}

.btn-primary {
    padding: 10px 40px;
    background: #5d5dff;
    color: #fff;
    border: none;
    border-radius: 25px;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 3px 8px rgba(93, 93, 255, 0.2);
    transition: all 0.2s;
}

.btn-primary:hover {
    background: #4f46e5;
}

/* SHADED DISABLED STATE */
.btn-primary:disabled {
    background: #9ca3af !important;
    cursor: not-allowed;
    opacity: 0.7;
    box-shadow: none;
}
/* --- NEW CONTROLS STYLING --- */

/* Single row: [Detect Speakers] [Upload and Process] [Status] — more space for transcript */
.upload-controls-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
    align-items: center;
    gap: 12px;
    margin-bottom: 10px;
    direction: rtl;
    width: 100%;
}
.upload-control-left {
    justify-self: start;
    min-width: 0;
}
.upload-controls-row .btn.btn-primary {
    justify-self: center;
}
.upload-status {
    justify-self: end;
    margin: 0;
    font-size: 0.9rem;
    color: #666;
    min-width: 0;
    text-align: end;
    direction: ltr;
}
html[dir="rtl"] .upload-status {
    text-align: right;
}

/* The Container for Source/Task/Speakers (legacy) */
.controls-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 20px;
    margin-bottom: 15px;
    direction: rtl; /* Keep RTL for Hebrew flow */
}

/* The White Box for Radio Buttons */
.task-group {
    display: flex;
    align-items: center;
    gap: 15px;
    background: #fff;
    padding: 8px 20px;
    border-radius: 20px;
    border: 1px solid #eee;
    box-shadow: 0 2px 5px rgba(0,0,0,0.03);
}

.radio-label {
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.95rem;
    color: #333;
    margin: 0; /* Remove default margins */
}

.separator {
    width: 1px;
    height: 20px;
    background: #ddd;
}

/* Inputs & Selects */
.control-item {
    display: flex;
    align-items: center;
    gap: 8px;
}

.control-label {
    font-weight: bold;
    color: #555;
    margin: 0;
}

.styled-select, .styled-input {
    padding: 6px 10px;
    border-radius: 8px;
    border: 1px solid #ccc;
    background: #fff;
    font-size: 1rem;
}

.styled-input {
    width: 50px;
    text-align: center;
}

/* --- MOBILE RESPONSIVENESS --- */
@media (max-width: 768px) {

    /* Keep CTA visible on mobile: compact SEO text block */
    .seo-home-content {
        max-height: 170px;
        overflow-y: auto;
        margin-bottom: 8px;
        padding: 12px;
    }
    .seo-home-content h1 {
        font-size: 1.35rem;
        line-height: 1.25;
        margin-bottom: 6px;
    }
    .seo-home-content .seo-hero-subtitle {
        font-size: 0.9rem;
        margin-bottom: 0;
    }
    .seo-home-content section {
        display: none;
    }

    /* Upload row: keep one row, compact — more space for transcript */
    .upload-controls-row {
        gap: 8px;
        margin-bottom: 8px;
    }
    .upload-control-left .control-label {
        font-size: 0.85rem;
    }
    .upload-controls-row .btn.btn-primary {
        font-size: 0.9rem;
        padding: 10px 14px;
    }
    .upload-status {
        font-size: 0.8rem;
        max-width: 35%;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        justify-self: end;
    }

    /* 1. Stack the controls vertically (legacy controls-row) */
    .controls-row {
        flex-direction: column;
        gap: 15px;
        width: 100%;
    }

    /* 2. Make the white box fill the width */
    .task-group {
        width: 100%;
        justify-content: space-around;
        box-sizing: border-box;
    }

    /* 3. More space for transcript: reduce padding */
    .main-app-container {
        padding: 8px;
        width: 98%;
    }
    .upload-zone {
        margin-bottom: 8px;
    }
    .transcription-wrapper {
        min-height: 0;
    }
    #transcript-window {
        min-height: 200px;
    }
    
    /* 4. Stack video wrapper vertically on mobile */
    #video-wrapper {
        flex-direction: column;
    }
    
    #subtitle-style-selector {
        width: 100% !important;
        margin-bottom: 12px;
    }
    
    #subtitle-style-selector > div {
        flex-direction: row !important;
        flex-wrap: wrap;
        gap: 8px;
    }
    
    #subtitle-style-selector .subtitle-style-card {
        flex: 1;
        min-width: 100px;
    }

    /* Mobile transcript toolbar: no horizontal scrolling, compact layout */
    .controls-bar {
        display: grid;
        grid-template-columns: minmax(88px, auto) minmax(0, 1fr);
        align-items: center;
        gap: 8px 10px;
        justify-content: stretch;
        width: 100%;
        max-width: 100%;
        overflow-x: hidden;
        overflow-x: clip;
        box-sizing: border-box;
        touch-action: pan-y;
    }
    .toggles-group {
        flex-direction: column;
        align-items: flex-start;
        justify-content: center;
        gap: 6px;
        width: 100%;
        max-width: 100%;
        margin: 0;
        min-width: 0;
    }
    .toggles-group label {
        font-size: 0.78rem;
        gap: 6px;
        margin: 0;
        white-space: nowrap;
    }
    .toolbar-group {
        justify-content: flex-end;
        gap: 8px;
        min-width: 0;
        flex-wrap: wrap;
        width: 100%;
        max-width: 100%;
        overflow-x: hidden;
        overflow-x: clip;
    }
    .toolbar-group > * {
        flex: 0 0 auto;
    }
    .toolbar-group .btn-icon {
        width: 34px;
        height: 34px;
    }
}
/* --- MOBILE "APP MODE" (One Page Layout) --- */
@media screen and (max-width: 768px) {
    /* 1. LOCK THE VIEWPORT */
    html, body {
        height: 100% !important;
        margin: 0 !important;
        overflow: hidden !important; /* Prevents the whole page from scrolling */
        position: fixed; /* Stops iOS "bounce" scroll */
        width: 100%;
    }

    /* 2. FLEX CONTAINER FOR THE WHOLE PAGE */
    .app-mode {
        height: 100% !important;
        display: flex !important;
        flex-direction: column !important;
        padding: 0 !important;
    }

    /* 3. MAIN CONTAINER STACK */
    .main-app-container {
        flex: 1;                /* Take all vertical space */
        display: flex !important;
        flex-direction: column !important;
        overflow: hidden !important; /* No spillover */
        padding: 10px !important;
    }

    /* 4. THE TRANSCRIPT WINDOW (The only thing that scrolls) */
    .transcription-wrapper {
        flex: 1 !important;        /* Grow to fill ALL empty space */
        overflow-y: auto !important; /* Scroll INSIDE this box */
        overflow-x: hidden !important;
        min-height: 0 !important;  /* Critical Fix for Flexbox scrolling */
        margin-bottom: 10px !important;
        border: 1px solid #eee;    /* Optional: helps see the boundary */
    }

    /* Ensure the transcript content doesn't force width issues */
    #transcript-window {
        height: auto !important;
        max-height: none !important; /* Let the wrapper handle the height */
        overflow-x: hidden !important;
    }

    /* 5. FIXED BOTTOM CONTROLS (Upload Zone) */
    .upload-zone {
        flex-shrink: 0 !important; /* Never shrink this section */
        background: #fff;
        z-index: 100;
        padding-bottom: 20px !important; /* Safety for iPhone Home Bar */
        box-shadow: 0 -4px 12px rgba(0,0,0,0.05); /* Visual separation */
    }

    /* 6. HIDE EXTRAS */
    footer, .footer, .copyright-text {
        display: none !important;
    }

    /* Optional: Compact the header to save more space */
    .navbar {
        padding: 0.5rem 1rem !important;
        min-height: auto !important;
    }
    /* --- BASE NAVBAR STYLES (Desktop) --- */


/* --- MOBILE STYLES (Hamburger & Centered Logo) --- */
@media screen and (max-width: 768px) {
    .navbar {
        padding: 1rem;
    }

    /* 1. Center the Logo */
    .brand-logo {
        position: absolute;
        left: 50%;
        transform: translateX(-50%);
        width: auto;
    }

    /* 2. Show the Hamburger Icon (3 Lines) */
    .hamburger-menu {
        display: flex;
        flex-direction: column;
        justify-content: space-between;
        width: 30px;
        height: 21px;
        cursor: pointer;
        position: absolute;
        right: 20px; /* Place it on the right */
        top: 50%;
        transform: translateY(-50%);
    }

    .hamburger-menu span {
        display: block;
        height: 3px;
        width: 100%;
        background: #333;
        border-radius: 3px;
        transition: 0.3s;
    }

    /* Animation for "X" when open */
    .hamburger-menu.open span:nth-child(1) { transform: rotate(45deg) translate(5px, 6px); }
    .hamburger-menu.open span:nth-child(2) { opacity: 0; }
    .hamburger-menu.open span:nth-child(3) { transform: rotate(-45deg) translate(5px, -6px); }

    /* 3. Mobile Dropdown Menu */
    .nav-links {
        display: none; /* Hidden by default */
        position: absolute;
        top: 100%;
        left: 0;
        width: 100%;
        background: #fff;
        flex-direction: column;
        text-align: center;
        box-shadow: 0 4px 6px rgba(0,0,0,0.1);
        padding: 10px 0;
    }

    .nav-links.active {
        display: flex; /* Show when active */
    }

    .nav-links a {
        margin: 0;
        padding: 15px;
        display: block;
        border-bottom: 1px solid #f0f0f0;
    }
    .paragraph-row {
    border-radius: 4px;
    border-left: 4px solid transparent;
    }

    /* This is the class our JS will manipulate via inline styles,
       but you can also define a class here for easier management */
    .active-highlight {
        background-color: #f0f7ff !important;
        border-left: 4px solid #1e3a8a !important;
    }
}
:root {
    --bg-page: #f8fafc;
    --bg-surface: #ffffff;
    --bg-surface-soft: #f9fafb;
    --bg-hover: #f3f4f6;
  
    --text-primary: #0f172a;
    --text-secondary: #475569;
  
    --border-soft: #e2e8f0;
    --border-subtle: #f1f5f9;
  
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.04);
    --shadow-md: 0 8px 24px rgba(15,23,42,0.08);
    --shadow-lg: 0 20px 48px rgba(15,23,42,0.16);
  
    --radius-sm: 8px;
    --radius-md: 14px;
    --radius-lg: 20px;
  
    --transition-fast: 120ms ease;
    --transition-base: 180ms ease;
  }
  .personal-area-page {
    padding: 32px 20px;
    max-width: 1100px;
    margin-inline: auto;
    background: var(--bg-page);
  }
  
  .personal-area-page h1 {
    font-size: 1.75rem;
    font-weight: 650;
    color: var(--text-primary);
    margin-bottom: 24px;
    letter-spacing: -0.02em;
  }
  .personal-area-header-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 16px;
  }
  .personal-area-header-row h1 {
    margin-bottom: 0;
  }
  .personal-close-btn {
    display: inline-flex;
    align-items: center;
    padding: 8px 14px;
    border-radius: 999px;
    border: 1px solid var(--border-soft);
    background: var(--bg-surface);
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.85rem;
    font-weight: 600;
    transition: all var(--transition-fast);
    white-space: nowrap;
  }
  .personal-close-btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
  }
  .personal-table-container {
    max-height: calc(100vh - 240px);
    overflow: auto;
    background: var(--bg-surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
  }
  .personal-files-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 0.95rem;
  }
  
  .personal-files-table th,
  .personal-files-table td {
    padding: 14px 18px;
    text-align: start;
  }
  
  .personal-files-table thead th {
    position: sticky;
    top: 0;
    background: var(--bg-surface);
    color: var(--text-secondary);
    font-weight: 600;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    border-bottom: 1px solid var(--border-soft);
  }
  .personal-files-table tbody tr {
    transition: background var(--transition-fast);
  }
  
  .personal-files-table tbody tr:not(:last-child) td {
    border-bottom: 1px solid var(--border-subtle);
  }
  
  .personal-files-table tbody tr:hover {
    background: var(--bg-hover);
  }
  .personal-dropdown-btn {
    padding: 8px 14px;
    border-radius: 999px;
    background: var(--bg-surface-soft);
    border: 1px solid var(--border-soft);
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
  }
  
  .personal-dropdown-btn:hover {
    background: var(--bg-hover);
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
  }
  
    /* Smooth Slide-down animation */
    @keyframes dropdownSlide {
        from { opacity: 0; transform: translateY(-5px); }
        to { opacity: 1; transform: translateY(0); }
    }
    .personal-dropdown-menu {
        position: absolute;
        top: calc(100% + 8px);
        inset-inline-end: 0;   /* RTL safe */
      
        min-width: 220px;
        padding: 8px;
      
        background: #ffffff;
        border-radius: 18px;
      
        box-shadow:
          0 10px 30px rgba(0, 0, 0, 0.12);
      
        opacity: 0;
        transform: translateY(-6px) scale(0.98);
        pointer-events: none;
      
        transition: all 160ms cubic-bezier(.2,.8,.2,1);
      
        z-index: 999;
      }
    

    .personal-dropdown-menu.open {
        opacity: 1;
        transform: translateY(0) scale(1);
        pointer-events: auto;
      }

 /* The items inside the list */
 .personal-dropdown-menu button {
    display: block;
    width: 100%;
  
    padding: 10px 14px;
    border: none;
    background: transparent;
  
    border-radius: 12px;
  
    font-size: 0.9rem;
    font-weight: 500;
  
    text-align: start;
    color: #334155;
  
    cursor: pointer;
    transition: background 120ms ease, transform 120ms ease;
  }
  
    /* Edge-to-edge hover effect */
    .personal-dropdown-menu button:hover {
        background: #f1f5f9;
        transform: translateX(3px);
    }

    .personal-dialog-overlay {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(15, 23, 42, 0.45);
    backdrop-filter: blur(6px);
  }
  .personal-dialog {
    background: var(--bg-surface);
    padding: 24px;
    border-radius: var(--radius-lg);
    width: min(420px, 92%);
    box-shadow: var(--shadow-lg);
    animation: dialogIn 160ms ease;
  }
  @keyframes dialogIn {
    from { opacity: 0; transform: scale(0.96); }
    to { opacity: 1; transform: scale(1); }
  }
  .personal-dialog-btn {
    padding: 8px 16px;
    border-radius: 999px;
    font-size: 0.85rem;
    font-weight: 500;
    border: none;
    cursor: pointer;
    transition: transform var(--transition-fast);
  }
  
  .personal-dialog-btn:hover {
    transform: translateY(-1px);
  }
  .personal-dialog-btn.primary {
    background: #2563eb;
    color: white;
  }
  .personal-dropdown-menu button.danger {
    color: #dc2626;
  }
  
  .personal-dropdown-menu button.danger:hover {
    background: rgba(220,38,38,0.08);
  }
  .personal-dropdown-menu {
    backdrop-filter: blur(10px);
  }

  .personal-dialog-btn.danger {
    background: #dc2626;
    color: white;
  }
  
  .personal-dialog-btn.cancel {
    background: var(--bg-surface-soft);
    color: var(--text-secondary);
  }
  .personal-row-actions {
    position: relative;
    display: inline-block;
  }
 }

/* Personal area mobile: keep table usable without breaking layout */
@media (max-width: 900px) {
  .personal-area-page {
    padding: 14px 10px;
  }
  .personal-area-header-row {
    flex-wrap: wrap;
    align-items: flex-start;
    gap: 10px;
  }
  .personal-area-header-row h1 {
    font-size: 1.3rem;
  }
  .personal-close-btn {
    width: 100%;
    justify-content: center;
  }
  .personal-table-container {
    max-height: calc(100vh - 210px);
    overflow-x: auto;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
  .personal-files-table {
    min-width: 700px;
  }
  .personal-files-table th,
  .personal-files-table td {
    white-space: nowrap;
    padding: 10px 12px;
    font-size: 0.85rem;
  }
  .personal-dropdown-menu {
    min-width: 190px;
  }
}

.personal-rotate-hint {
  display: none;
}
@media (max-width: 900px) and (orientation: portrait) {
  .personal-rotate-hint {
    display: block;
    margin: 0 0 10px;
    color: #64748b;
    font-size: 0.82rem;
  }
}

[dir="ltr"] .upload-disclaimer-box {
    text-align: left;
    direction: ltr;
}