/* ===== RESET & BASE ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    /* === ROYAL PURPLE PALETTE === */
    --accent: #660099;
    --accent-light: #8a2ec0;
    --accent-lighter: #a855d6;
    --accent-bright: #c77dff;
    --accent-dark: #4a006d;
    --accent-glow: rgba(102, 0, 153, 0.45);
    --accent-glow-strong: rgba(138, 46, 192, 0.6);
    --accent-subtle: rgba(102, 0, 153, 0.1);

    /* === NEAR-BLACK BACKGROUNDS === */
    --bg-darkest: #050509;
    --bg-dark: #090912;
    --bg-medium: #0f0f1c;
    --bg-light: #181830;
    --bg-hover: #222244;

    /* === TEXT === */
    --text-primary: #f0f0f8;
    --text-secondary: #ababc4;
    --text-muted: #5a5a72;

    /* === GLASS EFFECT === */
    --glass-bg: rgba(255, 255, 255, 0.025);
    --glass-bg-hover: rgba(255, 255, 255, 0.055);
    --glass-border: rgba(255, 255, 255, 0.06);
    --glass-border-hover: rgba(255, 255, 255, 0.14);
    --glass-highlight: rgba(255, 255, 255, 0.1);
    --glass-shadow: rgba(0, 0, 0, 0.5);
    --glass-blur: 20px;

    /* === GOLD ACCENT (luxury touch) === */
    --gold: #c9a84c;
    --gold-light: #e0c068;
    --gold-glow: rgba(201, 168, 76, 0.25);
    --gold-subtle: rgba(201, 168, 76, 0.08);

    /* === STATUS COLORS === */
    --danger: #e04060;
    --success: #40c080;
    --warning: #d4a020;

    /* === SPACING & SHAPE === */
    --radius: 16px;
    --radius-sm: 10px;
    --radius-xs: 6px;
    --transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: 0.5s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-luxe: 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

body {
    font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, sans-serif;
    background-color: var(--bg-darkest);
    color: var(--text-primary);
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* ===== ANIMATED AMBIENT BACKGROUND ===== */
body::before {
    content: '';
    position: fixed;
    top: -40%;
    left: 50%;
    transform: translateX(-50%);
    width: 140%;
    height: 80%;
    background:
        radial-gradient(ellipse at 30% 50%, rgba(102, 0, 153, 0.1) 0%, transparent 50%),
        radial-gradient(ellipse at 70% 30%, rgba(201, 168, 76, 0.04) 0%, transparent 45%),
        radial-gradient(ellipse at 50% 80%, rgba(138, 46, 192, 0.06) 0%, transparent 50%);
    pointer-events: none;
    z-index: 0;
    animation: ambientShift 12s ease-in-out infinite alternate;
}

@keyframes ambientShift {
    0% { opacity: 0.7; transform: translateX(-50%) scale(1); }
    50% { opacity: 1; transform: translateX(-48%) scale(1.05); }
    100% { opacity: 0.8; transform: translateX(-52%) scale(1.02); }
}

/* Secondary ambient orb */
body::after {
    content: '';
    position: fixed;
    bottom: -20%;
    right: -10%;
    width: 60%;
    height: 60%;
    background: radial-gradient(
        circle at center,
        rgba(102, 0, 153, 0.06) 0%,
        transparent 60%
    );
    pointer-events: none;
    z-index: 0;
    animation: ambientFloat 16s ease-in-out infinite alternate;
}

@keyframes ambientFloat {
    0% { transform: translate(0, 0); }
    100% { transform: translate(-30px, -20px); }
}

/* ===== TOOLBAR ===== */
.toolbar {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 28px;
    height: 64px;
    background: linear-gradient(
        180deg,
        rgba(16, 16, 28, 0.96) 0%,
        rgba(8, 8, 16, 0.98) 100%
    );
    backdrop-filter: blur(24px) saturate(1.5);
    -webkit-backdrop-filter: blur(24px) saturate(1.5);
    border-bottom: 1px solid var(--glass-border);
    flex-shrink: 0;
    z-index: 10;
}

/* Animated gradient accent line under toolbar */
.toolbar::after {
    content: '';
    position: absolute;
    bottom: -1px;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(
        90deg,
        transparent 0%,
        var(--accent-dark) 15%,
        var(--accent) 30%,
        var(--gold) 50%,
        var(--accent) 70%,
        var(--accent-dark) 85%,
        transparent 100%
    );
    background-size: 200% 100%;
    animation: shimmerLine 6s ease-in-out infinite;
}

@keyframes shimmerLine {
    0% { background-position: 100% 0; }
    50% { background-position: 0% 0; }
    100% { background-position: 100% 0; }
}

.logo {
    font-size: 20px;
    font-weight: 800;
    letter-spacing: -0.5px;
    background: linear-gradient(
        135deg,
        var(--accent-bright) 0%,
        var(--accent-lighter) 40%,
        var(--gold-light) 80%,
        var(--gold) 100%
    );
    background-size: 200% 200%;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: logoShimmer 8s ease-in-out infinite;
    filter: drop-shadow(0 0 8px rgba(102, 0, 153, 0.3));
}

@keyframes logoShimmer {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

.toolbar-center {
    display: flex;
    align-items: center;
    gap: 16px;
}

.filename {
    font-size: 14px;
    color: var(--text-secondary);
    font-weight: 500;
}

.page-info {
    font-size: 13px;
    color: var(--text-muted);
}

/* ===== LIQUID GLASS BUTTONS ===== */
.btn {
    position: relative;
    padding: 10px 22px;
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 0.4px;
    cursor: pointer;
    transition: all var(--transition);
    background: var(--glass-bg);
    color: var(--text-primary);
    backdrop-filter: blur(14px) saturate(1.3);
    -webkit-backdrop-filter: blur(14px) saturate(1.3);
    box-shadow:
        0 2px 10px rgba(0, 0, 0, 0.3),
        0 1px 2px rgba(0, 0, 0, 0.15),
        inset 0 1px 0 var(--glass-highlight),
        inset 0 -1px 0 rgba(0, 0, 0, 0.05);
    overflow: hidden;
}

/* Top shine reflection */
.btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 55%;
    background: linear-gradient(
        180deg,
        rgba(255, 255, 255, 0.14) 0%,
        rgba(255, 255, 255, 0.04) 50%,
        transparent 100%
    );
    border-radius: var(--radius-sm) var(--radius-sm) 0 0;
    pointer-events: none;
    transition: opacity var(--transition);
}

/* Animated shimmer sweep */
.btn::after {
    content: '';
    position: absolute;
    top: -50%;
    left: -120%;
    width: 70%;
    height: 200%;
    background: linear-gradient(
        90deg,
        transparent 0%,
        rgba(255, 255, 255, 0.04) 30%,
        rgba(255, 255, 255, 0.14) 50%,
        rgba(255, 255, 255, 0.04) 70%,
        transparent 100%
    );
    transform: skewX(-20deg);
    transition: left 0.7s cubic-bezier(0.16, 1, 0.3, 1);
    pointer-events: none;
}

.btn:hover::after {
    left: 140%;
}

.btn:hover {
    background: var(--glass-bg-hover);
    border-color: var(--glass-border-hover);
    box-shadow:
        0 8px 28px rgba(0, 0, 0, 0.4),
        0 2px 8px rgba(0, 0, 0, 0.25),
        inset 0 1px 0 rgba(255, 255, 255, 0.16);
    transform: translateY(-2px);
}

.btn:active {
    transform: translateY(0);
    transition-duration: 0.08s;
    box-shadow:
        0 1px 4px rgba(0, 0, 0, 0.3),
        inset 0 2px 6px rgba(0, 0, 0, 0.2);
}

/* === PRIMARY BUTTON (Royal Purple Glass) === */
.btn-primary {
    background: linear-gradient(
        145deg,
        rgba(102, 0, 153, 0.6) 0%,
        rgba(138, 46, 192, 0.4) 40%,
        rgba(168, 85, 214, 0.35) 70%,
        rgba(102, 0, 153, 0.5) 100%
    );
    border: 1px solid rgba(168, 85, 214, 0.3);
    color: white;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
    box-shadow:
        0 4px 20px var(--accent-glow),
        0 1px 3px rgba(0, 0, 0, 0.25),
        inset 0 1px 0 rgba(255, 255, 255, 0.18),
        inset 0 -1px 0 rgba(0, 0, 0, 0.12);
    animation: btnPulse 4s ease-in-out infinite;
}

@keyframes btnPulse {
    0%, 100% { box-shadow: 0 4px 20px var(--accent-glow), 0 1px 3px rgba(0, 0, 0, 0.25), inset 0 1px 0 rgba(255, 255, 255, 0.18); }
    50% { box-shadow: 0 4px 28px var(--accent-glow-strong), 0 0 40px rgba(102, 0, 153, 0.15), 0 1px 3px rgba(0, 0, 0, 0.25), inset 0 1px 0 rgba(255, 255, 255, 0.18); }
}

.btn-primary::before {
    background: linear-gradient(
        180deg,
        rgba(255, 255, 255, 0.22) 0%,
        rgba(255, 255, 255, 0.06) 40%,
        transparent 100%
    );
}

.btn-primary::after {
    background: linear-gradient(
        90deg,
        transparent 0%,
        rgba(255, 255, 255, 0.05) 30%,
        rgba(255, 255, 255, 0.18) 50%,
        rgba(255, 255, 255, 0.05) 70%,
        transparent 100%
    );
}

.btn-primary:hover {
    background: linear-gradient(
        145deg,
        rgba(120, 15, 180, 0.75) 0%,
        rgba(155, 65, 220, 0.6) 40%,
        rgba(180, 100, 230, 0.5) 70%,
        rgba(120, 15, 180, 0.65) 100%
    );
    border-color: rgba(180, 100, 230, 0.5);
    box-shadow:
        0 8px 36px var(--accent-glow-strong),
        0 0 60px rgba(102, 0, 153, 0.25),
        0 0 100px rgba(102, 0, 153, 0.1),
        inset 0 1px 0 rgba(255, 255, 255, 0.22),
        inset 0 -1px 0 rgba(0, 0, 0, 0.1);
    transform: translateY(-3px);
    animation: none;
}

.btn-primary:active {
    transform: translateY(0);
    box-shadow:
        0 2px 10px var(--accent-glow),
        inset 0 2px 6px rgba(0, 0, 0, 0.25);
    animation: none;
}

/* === LARGE BUTTON === */
.btn-large {
    padding: 18px 42px;
    font-size: 16px;
    font-weight: 700;
    letter-spacing: 0.6px;
    border-radius: var(--radius);
}

/* ===== MAIN LAYOUT ===== */
.main-container {
    display: flex;
    flex: 1;
    overflow: hidden;
    position: relative;
    z-index: 1;
}

/* ===== SIDEBAR ===== */
.sidebar {
    width: 200px;
    background: linear-gradient(
        180deg,
        rgba(9, 9, 18, 0.99) 0%,
        rgba(5, 5, 9, 1) 100%
    );
    border-right: 1px solid var(--glass-border);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    position: relative;
}

/* Subtle inner glow on sidebar */
.sidebar::after {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 1px;
    height: 100%;
    background: linear-gradient(
        180deg,
        transparent 0%,
        rgba(102, 0, 153, 0.2) 30%,
        rgba(201, 168, 76, 0.1) 50%,
        rgba(102, 0, 153, 0.2) 70%,
        transparent 100%
    );
    pointer-events: none;
}

.sidebar-header {
    padding: 16px 18px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 2.5px;
    color: var(--text-muted);
    border-bottom: 1px solid var(--glass-border);
    background: rgba(255, 255, 255, 0.015);
}

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

.thumbnail-item {
    margin-bottom: 12px;
    cursor: pointer;
    border-radius: var(--radius-xs);
    border: 2px solid transparent;
    transition: all var(--transition-luxe);
    overflow: hidden;
    background: var(--bg-medium);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.35);
    position: relative;
}

/* Glow ring on hover */
.thumbnail-item::after {
    content: '';
    position: absolute;
    inset: -2px;
    border-radius: var(--radius-xs);
    background: linear-gradient(
        135deg,
        var(--accent) 0%,
        var(--accent-light) 50%,
        var(--gold) 100%
    );
    z-index: -1;
    opacity: 0;
    transition: opacity var(--transition);
}

.thumbnail-item:hover {
    border-color: transparent;
    transform: translateY(-2px) scale(1.02);
    box-shadow:
        0 6px 24px rgba(0, 0, 0, 0.5),
        0 0 24px rgba(102, 0, 153, 0.15);
}

.thumbnail-item:hover::after {
    opacity: 0.5;
}

.thumbnail-item.active {
    border-color: transparent;
    box-shadow:
        0 6px 24px rgba(0, 0, 0, 0.5),
        0 0 30px var(--accent-glow);
}

.thumbnail-item.active::after {
    opacity: 1;
}

.thumbnail-item img {
    width: 100%;
    display: block;
    position: relative;
    z-index: 1;
}

.thumbnail-label {
    position: relative;
    z-index: 1;
    text-align: center;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    padding: 6px 0;
    background: var(--bg-dark);
    letter-spacing: 0.5px;
}

.empty-state-sidebar {
    padding: 24px;
    text-align: center;
    color: var(--text-muted);
    font-size: 12px;
}

/* ===== VIEWER ===== */
.viewer {
    flex: 1;
    overflow-y: auto;
    display: flex;
    justify-content: center;
    background-color: var(--bg-darkest);
    background-image:
        radial-gradient(ellipse at 50% 0%, rgba(102, 0, 153, 0.06) 0%, transparent 45%),
        radial-gradient(ellipse at 85% 85%, rgba(201, 168, 76, 0.025) 0%, transparent 35%),
        radial-gradient(ellipse at 15% 60%, rgba(102, 0, 153, 0.03) 0%, transparent 40%);
}

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    gap: 20px;
    color: var(--text-secondary);
}

.empty-icon {
    font-size: 80px;
    opacity: 0.3;
    filter: drop-shadow(0 0 30px rgba(102, 0, 153, 0.4));
    animation: iconFloat 5s ease-in-out infinite;
}

@keyframes iconFloat {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-8px); }
}

.empty-state h2 {
    font-size: 26px;
    font-weight: 700;
    letter-spacing: -0.3px;
    background: linear-gradient(135deg, var(--text-primary) 0%, var(--accent-bright) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.empty-state p {
    font-size: 14px;
    color: var(--text-muted);
    margin-bottom: 8px;
}

.page-container {
    padding: 28px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 28px;
}

.page-wrapper {
    background-color: white;
    border-radius: 4px;
    box-shadow:
        0 16px 56px rgba(0, 0, 0, 0.6),
        0 6px 16px rgba(0, 0, 0, 0.35),
        0 0 100px rgba(102, 0, 153, 0.08);
    transition: all var(--transition-luxe);
    position: relative;
}

/* Subtle purple ambient glow behind pages */
.page-wrapper::before {
    content: '';
    position: absolute;
    inset: -20px;
    background: radial-gradient(
        ellipse at center,
        rgba(102, 0, 153, 0.06) 0%,
        transparent 70%
    );
    z-index: -1;
    transition: all var(--transition-slow);
    border-radius: 20px;
}

.page-wrapper:hover {
    box-shadow:
        0 20px 64px rgba(0, 0, 0, 0.65),
        0 8px 20px rgba(0, 0, 0, 0.4),
        0 0 120px rgba(102, 0, 153, 0.12);
    transform: translateY(-2px);
}

.page-wrapper:hover::before {
    inset: -30px;
    background: radial-gradient(
        ellipse at center,
        rgba(102, 0, 153, 0.1) 0%,
        transparent 70%
    );
}

.page-wrapper img {
    display: block;
    max-width: 800px;
    width: 100%;
    height: auto;
}

/* ===== LOADING OVERLAY ===== */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(3, 3, 6, 0.94);
    backdrop-filter: blur(16px) saturate(0.7);
    -webkit-backdrop-filter: blur(16px) saturate(0.7);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 24px;
    z-index: 1000;
}

/* Upgraded spinner with double ring */
.spinner {
    width: 56px;
    height: 56px;
    border: 3px solid transparent;
    border-top-color: var(--accent-light);
    border-bottom-color: var(--gold);
    border-radius: 50%;
    animation: spin 0.9s linear infinite;
    box-shadow:
        0 0 30px var(--accent-glow),
        inset 0 0 15px rgba(102, 0, 153, 0.1);
    position: relative;
}

.spinner::before {
    content: '';
    position: absolute;
    inset: 6px;
    border: 2px solid transparent;
    border-left-color: var(--accent-bright);
    border-right-color: rgba(201, 168, 76, 0.5);
    border-radius: 50%;
    animation: spin 1.4s linear infinite reverse;
}

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

.loading-overlay p {
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 500;
    letter-spacing: 1px;
    text-transform: uppercase;
}

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar {
    width: 5px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: linear-gradient(180deg, var(--bg-light) 0%, var(--accent-dark) 100%);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(180deg, var(--accent-dark) 0%, var(--accent) 100%);
}

/* ===== DRAG AND DROP ===== */
.viewer.drag-over {
    background-image:
        radial-gradient(ellipse at 50% 50%, rgba(102, 0, 153, 0.18) 0%, transparent 50%),
        radial-gradient(ellipse at 50% 50%, rgba(201, 168, 76, 0.06) 0%, transparent 60%);
    outline: 2px dashed var(--accent-bright);
    outline-offset: -14px;
    animation: dragPulse 1.5s ease-in-out infinite;
}

@keyframes dragPulse {
    0%, 100% { outline-color: var(--accent-bright); }
    50% { outline-color: var(--gold); }
}

/* ===== SELECTION COLOR ===== */
::selection {
    background: rgba(102, 0, 153, 0.45);
    color: white;
}

/* ===== FOCUS STYLES (accessibility) ===== */
.btn:focus-visible {
    outline: 2px solid var(--accent-bright);
    outline-offset: 2px;
}

/* ============================================
   PHASE 2: TOOLBAR ACTIONS, DRAG OVERLAY, TOAST
   ============================================ */

/* ===== TOOLBAR RIGHT SECTION ===== */
.toolbar-right {
    display: flex;
    align-items: center;
    gap: 10px;
}

.toolbar-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    animation: fadeSlideIn 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes fadeSlideIn {
    from {
        opacity: 0;
        transform: translateX(12px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.toolbar-divider {
    width: 1px;
    height: 28px;
    background: linear-gradient(
        180deg,
        transparent 0%,
        var(--glass-border-hover) 50%,
        transparent 100%
    );
    margin: 0 4px;
}

/* ===== BUTTON VARIANTS ===== */
.btn-icon {
    margin-right: 6px;
    font-size: 14px;
}

.btn-ghost {
    background: transparent;
    border-color: transparent;
    color: var(--text-secondary);
    box-shadow: none;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
}

.btn-ghost::before,
.btn-ghost::after {
    display: none;
}

.btn-ghost:hover {
    background: rgba(255, 255, 255, 0.05);
    border-color: var(--glass-border);
    color: var(--text-primary);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    transform: translateY(-1px);
}

.btn-ghost:active {
    transform: translateY(0);
    background: rgba(255, 255, 255, 0.03);
}

.btn-secondary {
    background: linear-gradient(
        145deg,
        rgba(255, 255, 255, 0.06) 0%,
        rgba(255, 255, 255, 0.02) 100%
    );
    border-color: var(--glass-border-hover);
    color: var(--text-primary);
    box-shadow:
        0 2px 10px rgba(0, 0, 0, 0.25),
        inset 0 1px 0 var(--glass-highlight);
}

.btn-secondary:hover {
    background: linear-gradient(
        145deg,
        rgba(255, 255, 255, 0.1) 0%,
        rgba(255, 255, 255, 0.04) 100%
    );
    border-color: rgba(255, 255, 255, 0.2);
    box-shadow:
        0 6px 20px rgba(0, 0, 0, 0.35),
        inset 0 1px 0 rgba(255, 255, 255, 0.14);
}

/* ===== FILE DETAILS ===== */
.file-details {
    font-size: 12px;
    color: var(--text-muted);
    font-weight: 500;
    letter-spacing: 0.3px;
}

/* ===== FULL-WINDOW DRAG OVERLAY ===== */
.drag-overlay {
    position: fixed;
    inset: 0;
    background: rgba(4, 4, 10, 0.92);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: all 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

.drag-overlay.visible {
    opacity: 1;
    visibility: visible;
}

.drag-overlay-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    padding: 60px 80px;
    border-radius: 24px;
    border: 2px dashed var(--accent-light);
    background: rgba(102, 0, 153, 0.08);
    box-shadow:
        0 0 60px var(--accent-glow),
        inset 0 0 40px rgba(102, 0, 153, 0.05);
    animation: dragContentPulse 2s ease-in-out infinite;
}

@keyframes dragContentPulse {
    0%, 100% {
        border-color: var(--accent-light);
        box-shadow: 0 0 60px var(--accent-glow), inset 0 0 40px rgba(102, 0, 153, 0.05);
    }
    50% {
        border-color: var(--gold);
        box-shadow: 0 0 80px var(--accent-glow-strong), 0 0 40px var(--gold-glow), inset 0 0 40px rgba(102, 0, 153, 0.08);
    }
}

.drag-overlay-icon {
    font-size: 72px;
    animation: iconFloat 3s ease-in-out infinite;
    filter: drop-shadow(0 0 20px rgba(102, 0, 153, 0.4));
}

.drag-overlay-content h2 {
    font-size: 28px;
    font-weight: 700;
    background: linear-gradient(135deg, var(--text-primary) 0%, var(--accent-bright) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.drag-overlay-content p {
    font-size: 14px;
    color: var(--text-muted);
}

/* ===== TOAST NOTIFICATIONS ===== */
.toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    padding: 14px 28px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 500;
    z-index: 3000;
    opacity: 0;
    transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    pointer-events: none;
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--glass-border);
    box-shadow:
        0 8px 32px rgba(0, 0, 0, 0.5),
        inset 0 1px 0 var(--glass-highlight);
}

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

.toast-info {
    background: rgba(20, 20, 40, 0.9);
    color: var(--text-primary);
    border-color: rgba(102, 0, 153, 0.3);
}

.toast-error {
    background: rgba(40, 10, 15, 0.9);
    color: #ff8090;
    border-color: rgba(224, 64, 96, 0.3);
    box-shadow:
        0 8px 32px rgba(0, 0, 0, 0.5),
        0 0 20px rgba(224, 64, 96, 0.1),
        inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

.toast-success {
    background: rgba(10, 30, 20, 0.9);
    color: #80ffa0;
    border-color: rgba(64, 192, 128, 0.3);
    box-shadow:
        0 8px 32px rgba(0, 0, 0, 0.5),
        0 0 20px rgba(64, 192, 128, 0.1),
        inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

/* ============================================
   PHASE 3: TEXT EDITING & WHITEOUT TOOLS
   ============================================ */

/* ===== TOOL BUTTONS ===== */
.tool-group {
    display: flex;
    align-items: center;
    gap: 2px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-sm);
    padding: 3px;
}

.btn-tool {
    position: relative;
    padding: 6px 12px;
    border: 1px solid transparent;
    border-radius: var(--radius-xs);
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    transition: all var(--transition);
    background: transparent;
    color: var(--text-secondary);
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    box-shadow: none;
    overflow: hidden;
}

.btn-tool::before,
.btn-tool::after {
    display: none;
}

.btn-tool .btn-icon {
    margin-right: 0;
    font-size: 15px;
}

.btn-tool:hover {
    background: rgba(255, 255, 255, 0.06);
    color: var(--text-primary);
    transform: none;
    box-shadow: none;
}

.btn-tool-active {
    background: linear-gradient(
        145deg,
        rgba(102, 0, 153, 0.45) 0%,
        rgba(138, 46, 192, 0.3) 100%
    );
    color: white;
    border-color: rgba(138, 46, 192, 0.3);
    box-shadow: 0 0 12px var(--accent-glow);
}

.btn-tool-active:hover {
    background: linear-gradient(
        145deg,
        rgba(102, 0, 153, 0.55) 0%,
        rgba(138, 46, 192, 0.4) 100%
    );
    color: white;
}

/* ===== FORMAT BAR ===== */
.format-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 20px;
    background: linear-gradient(
        180deg,
        rgba(14, 14, 24, 0.98) 0%,
        rgba(10, 10, 18, 0.99) 100%
    );
    border-bottom: 1px solid var(--glass-border);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    z-index: 9;
    animation: fadeSlideDown 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes fadeSlideDown {
    from {
        opacity: 0;
        transform: translateY(-8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.format-select {
    padding: 6px 10px;
    background: var(--bg-medium);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-xs);
    color: var(--text-primary);
    font-size: 13px;
    cursor: pointer;
    transition: border-color var(--transition);
    outline: none;
}

.format-select:hover,
.format-select:focus {
    border-color: var(--accent);
}

.format-select-sm {
    width: 65px;
}

.format-divider {
    width: 1px;
    height: 24px;
    background: var(--glass-border);
    margin: 0 4px;
}

.format-btn {
    padding: 5px 10px;
    background: var(--bg-medium);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-xs);
    color: var(--text-secondary);
    font-size: 14px;
    cursor: pointer;
    transition: all var(--transition);
    min-width: 32px;
    text-align: center;
}

.format-btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
    border-color: var(--glass-border-hover);
}

.format-btn-active {
    background: linear-gradient(
        145deg,
        rgba(102, 0, 153, 0.4) 0%,
        rgba(138, 46, 192, 0.25) 100%
    );
    color: white;
    border-color: rgba(138, 46, 192, 0.3);
    box-shadow: 0 0 8px var(--accent-glow);
}

.format-btn-danger:hover {
    background: rgba(224, 64, 96, 0.2);
    border-color: rgba(224, 64, 96, 0.3);
    color: var(--danger);
}

.format-color {
    width: 32px;
    height: 32px;
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-xs);
    background: var(--bg-medium);
    cursor: pointer;
    padding: 2px;
}

.format-color::-webkit-color-swatch-wrapper {
    padding: 2px;
}

.format-color::-webkit-color-swatch {
    border: none;
    border-radius: 3px;
}

/* ===== EDIT LAYER (overlay on each page) ===== */
.edit-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 2;
}

.page-wrapper {
    position: relative;
}

/* ===== EDIT BOXES ===== */
.edit-box {
    position: absolute;
    cursor: move;
}

.edit-box-selected {
    outline: 2px solid var(--accent-light);
    outline-offset: 2px;
    box-shadow: 0 0 16px var(--accent-glow);
}

/* Text edit box */
.edit-box-text {
    min-width: 120px;
    min-height: 30px;
    padding: 2px;
}

.edit-textarea {
    width: 200px;
    min-height: 28px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px dashed rgba(102, 0, 153, 0.4);
    border-radius: 3px;
    color: #000000;
    padding: 4px 6px;
    font-size: 14px;
    line-height: 1.3;
    resize: none;
    overflow: hidden;
    outline: none;
    transition: border-color var(--transition), background var(--transition);
}

.edit-textarea:focus {
    border-color: var(--accent-light);
    background: rgba(255, 255, 255, 0.1);
}

.edit-textarea::placeholder {
    color: rgba(100, 100, 100, 0.5);
}

/* Whiteout box */
.edit-box-whiteout {
    background-color: white;
    border: none;
    min-width: 10px;
    min-height: 10px;
}

/* Whiteout preview while drawing */
.whiteout-preview {
    position: absolute;
    background-color: rgba(255, 255, 255, 0.7);
    border: 2px dashed var(--accent);
    pointer-events: none;
    z-index: 10;
}

/* ============================================
   ROUND 1: ZOOM, CONTEXT MENU, UNSAVED BADGE
   ============================================ */

/* ===== ZOOM DISPLAY ===== */
.zoom-display {
    min-width: 52px;
    text-align: center;
    font-size: 12px !important;
    font-weight: 600 !important;
    letter-spacing: 0.3px;
    color: var(--text-secondary) !important;
    cursor: pointer;
}

.zoom-display:hover {
    color: var(--text-primary) !important;
}

/* ===== UNSAVED BADGE ===== */
.unsaved-badge {
    font-size: 11px;
    font-weight: 600;
    color: var(--gold);
    letter-spacing: 0.3px;
    animation: unsavedPulse 2s ease-in-out infinite;
}

@keyframes unsavedPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* ===== CONTEXT MENU ===== */
.context-menu {
    position: fixed;
    z-index: 5000;
    min-width: 200px;
    background: rgba(16, 16, 28, 0.97);
    backdrop-filter: blur(24px) saturate(1.4);
    -webkit-backdrop-filter: blur(24px) saturate(1.4);
    border: 1px solid var(--glass-border-hover);
    border-radius: var(--radius-sm);
    padding: 6px 0;
    box-shadow:
        0 12px 48px rgba(0, 0, 0, 0.6),
        0 4px 12px rgba(0, 0, 0, 0.4),
        0 0 40px rgba(102, 0, 153, 0.08);
    opacity: 0;
    visibility: hidden;
    transform: scale(0.95) translateY(-4px);
    transition: all 0.15s cubic-bezier(0.16, 1, 0.3, 1);
    pointer-events: none;
}

.context-menu-visible {
    opacity: 1;
    visibility: visible;
    transform: scale(1) translateY(0);
    pointer-events: auto;
}

.context-item {
    display: flex;
    align-items: center;
    padding: 8px 14px;
    font-size: 13px;
    color: var(--text-primary);
    cursor: pointer;
    transition: background 0.12s ease;
    gap: 10px;
}

.context-item:hover {
    background: rgba(102, 0, 153, 0.2);
}

.context-icon {
    width: 20px;
    text-align: center;
    font-size: 14px;
}

.context-shortcut {
    margin-left: auto;
    font-size: 11px;
    color: var(--text-muted);
    font-weight: 500;
}

.context-separator {
    height: 1px;
    background: var(--glass-border);
    margin: 4px 8px;
}

.context-item-danger {
    color: var(--danger);
}

.context-item-danger:hover {
    background: rgba(224, 64, 96, 0.15);
}

.context-item-disabled {
    opacity: 0.3;
    pointer-events: none;
}

/* ===== ZOOMED PAGE WRAPPER ===== */
.page-wrapper {
    position: relative;
    transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ============================================
   ROUND 2A: MARQUEE DRAW + RESIZE HANDLES
   ============================================ */

/* ===== MARQUEE PREVIEW ===== */
.marquee-preview {
    position: absolute;
    pointer-events: none;
    z-index: 10;
}

.marquee-text {
    border: 2px dashed var(--accent-light);
    background: rgba(102, 0, 153, 0.08);
    border-radius: 2px;
}

.marquee-whiteout {
    border: 2px dashed var(--accent);
    background: rgba(255, 255, 255, 0.5);
}

/* ===== EDIT BOX UPDATES ===== */
.edit-box-text {
    min-width: 10px;
    min-height: 10px;
    padding: 0;
}

.edit-textarea {
    width: 100%;
    min-height: 24px;
    background: transparent;
    border: 1px dashed rgba(102, 0, 153, 0.25);
    border-radius: 2px;
    color: #000000;
    padding: 4px 6px;
    font-size: 14px;
    line-height: 1.3;
    resize: none;
    overflow: hidden;
    outline: none;
    transition: border-color var(--transition), background var(--transition);
    box-sizing: border-box;
}

.edit-textarea:focus {
    border-color: var(--accent-light);
    background: rgba(255, 255, 255, 0.06);
}

/* ===== RESIZE HANDLES ===== */
.resize-handle {
    position: absolute;
    width: 8px;
    height: 8px;
    background: var(--accent-light);
    border: 2px solid rgba(255, 255, 255, 0.9);
    border-radius: 2px;
    z-index: 20;
    opacity: 0;
    transition: opacity 0.15s ease;
    pointer-events: none;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.4);
}

.edit-box-selected .resize-handle {
    opacity: 1;
    pointer-events: auto;
}

/* Corner handles */
.resize-handle-nw { top: -4px; left: -4px; cursor: nw-resize; }
.resize-handle-ne { top: -4px; right: -4px; cursor: ne-resize; }
.resize-handle-sw { bottom: -4px; left: -4px; cursor: sw-resize; }
.resize-handle-se { bottom: -4px; right: -4px; cursor: se-resize; }

/* Edge handles */
.resize-handle-n { top: -4px; left: 50%; transform: translateX(-50%); cursor: n-resize; }
.resize-handle-s { bottom: -4px; left: 50%; transform: translateX(-50%); cursor: s-resize; }
.resize-handle-w { top: 50%; left: -4px; transform: translateY(-50%); cursor: w-resize; }
.resize-handle-e { top: 50%; right: -4px; transform: translateY(-50%); cursor: e-resize; }

/* ===== SELECTED STATE ===== */
.edit-box-selected {
    outline: 2px solid var(--accent-light);
    outline-offset: 1px;
    box-shadow: 0 0 16px var(--accent-glow);
}

/* ===== WHITEOUT PREVIEW (old style removal) ===== */
.whiteout-preview {
    position: absolute;
    background-color: rgba(255, 255, 255, 0.7);
    border: 2px dashed var(--accent);
    pointer-events: none;
    z-index: 10;
}

/* ============================================
   ROUND 2B: ALIGNMENT GUIDES
   ============================================ */

.alignment-guide {
    position: absolute;
    background: var(--accent-light);
    z-index: 50;
    pointer-events: none;
    opacity: 0.7;
    box-shadow: 0 0 4px var(--accent-glow);
}

/* ===== LOCKED TEXTAREA (select mode) ===== */
.edit-textarea-locked {
    cursor: move !important;
    user-select: none;
    -webkit-user-select: none;
    pointer-events: auto;
    caret-color: transparent;
}

.edit-textarea-locked::selection {
    background: transparent;
}

/* ===== SELECT TOOL CURSOR ON TEXT BOXES ===== */
.edit-box-text {
    cursor: default;
}

.edit-box-text .edit-textarea {
    cursor: text;
}

.edit-box-text .edit-textarea-locked {
    cursor: move !important;
}

.edit-box-selected .edit-textarea-locked {
    cursor: move !important;
}

/* ===== MULTI-SELECT ===== */
.edit-box-multi-selected {
    outline: 2px solid var(--accent-bright);
    outline-offset: 1px;
    box-shadow: 0 0 12px var(--accent-glow);
}

.marquee-select {
    border: 2px dashed var(--accent-bright);
    background: rgba(102, 0, 153, 0.12);
    border-radius: 2px;
    z-index: 100;
}

/* ===== PAGE LOADING PLACEHOLDERS ===== */
.page-wrapper-loading {
    position: relative;
}

.page-wrapper-loading::after {
    content: 'Loading...';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: var(--text-muted);
    font-size: 13px;
    font-weight: 500;
    letter-spacing: 0.5px;
    z-index: 1;
    pointer-events: none;
}

.page-img-loading {
    filter: blur(2px);
    opacity: 0.6;
    transition: filter 0.4s ease, opacity 0.4s ease;
}

/* ============================================
   ROUND 3: ANNOTATION TOOLS
   ============================================ */

/* ===== FORMAT BAR EXTRAS ===== */
.format-label {
    font-size: 12px;
    color: var(--text-secondary);
    font-weight: 500;
    white-space: nowrap;
}

.format-checkbox-wrap {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    color: var(--text-secondary);
    cursor: pointer;
}

.format-checkbox-wrap input[type="checkbox"] {
    width: 14px;
    height: 14px;
    cursor: pointer;
    accent-color: var(--accent);
}

/* ===== SVG EDIT LAYER ===== */
.edit-svg-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 3;
    pointer-events: none;
}

.edit-svg-layer.drawing-active {
    pointer-events: auto;
    cursor: crosshair;
}

/* SVG elements when selectable */
.svg-edit-element {
    cursor: pointer;
    pointer-events: stroke;
}

.svg-edit-element:hover {
    filter: drop-shadow(0 0 3px var(--accent-light));
}

.svg-edit-selected {
    filter: drop-shadow(0 0 4px var(--accent-light));
}

/* ===== HIGHLIGHT OVERLAY ===== */
.highlight-rect {
    pointer-events: auto;
    cursor: pointer;
    transition: opacity 0.15s ease;
}

.highlight-rect:hover {
    opacity: 0.8 !important;
}

/* ===== FREEHAND PATH ===== */
.freehand-path {
    fill: none;
    pointer-events: stroke;
    cursor: pointer;
}

.freehand-path:hover {
    filter: drop-shadow(0 0 3px var(--accent-light));
}

/* ============================================
   PAGE MANAGEMENT
   ============================================ */

.sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.sidebar-actions {
    display: flex;
    gap: 4px;
}

.sidebar-btn {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-xs);
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    transition: all var(--transition);
}

.sidebar-btn:hover {
    background: rgba(102, 0, 153, 0.25);
    color: var(--text-primary);
    border-color: rgba(102, 0, 153, 0.3);
}

/* ===== THUMBNAIL PAGE CONTROLS ===== */
.thumbnail-controls {
    display: flex;
    justify-content: center;
    gap: 2px;
    padding: 3px 4px;
    background: var(--bg-dark);
    opacity: 0;
    transition: opacity 0.2s ease;
}

.thumbnail-item:hover .thumbnail-controls {
    opacity: 1;
}

.thumb-btn {
    width: 22px;
    height: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    border-radius: 3px;
    color: var(--text-muted);
    font-size: 11px;
    cursor: pointer;
    transition: all 0.15s ease;
}

.thumb-btn:hover {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-primary);
}

.thumb-btn-danger:hover {
    background: rgba(224, 64, 96, 0.2);
    color: var(--danger);
}

/* ===== DRAGGABLE THUMBNAILS ===== */
.thumbnail-item.dragging {
    opacity: 0.4;
}

.thumbnail-item.drag-over-above {
    border-top: 2px solid var(--accent-light);
}

.thumbnail-item.drag-over-below {
    border-bottom: 2px solid var(--accent-light);
}

/* ============================================
   SAVE OPTIONS MODAL
   ============================================ */

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(4, 4, 10, 0.88);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    z-index: 4000;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal-card {
    background: linear-gradient(180deg, var(--bg-medium) 0%, var(--bg-dark) 100%);
    border: 1px solid var(--glass-border-hover);
    border-radius: var(--radius);
    width: 460px;
    max-width: 92vw;
    box-shadow:
        0 24px 80px rgba(0, 0, 0, 0.6),
        0 0 60px rgba(102, 0, 153, 0.08);
    animation: modalSlideIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes modalSlideIn {
    from { opacity: 0; transform: translateY(-16px) scale(0.97); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 18px 22px;
    border-bottom: 1px solid var(--glass-border);
}

.modal-header h3 {
    font-size: 16px;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.2px;
}

.modal-close {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    border-radius: var(--radius-xs);
    color: var(--text-muted);
    font-size: 16px;
    cursor: pointer;
    transition: all 0.15s ease;
}

.modal-close:hover {
    background: rgba(255, 255, 255, 0.06);
    color: var(--text-primary);
}

.modal-body {
    padding: 18px 22px 22px;
}

.modal-desc {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 16px;
    line-height: 1.5;
}

.modal-options {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.modal-option {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 16px;
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition);
    text-align: left;
    color: var(--text-primary);
}

.modal-option:hover {
    background: rgba(102, 0, 153, 0.12);
    border-color: rgba(102, 0, 153, 0.3);
    box-shadow: 0 0 20px rgba(102, 0, 153, 0.1);
    transform: translateY(-1px);
}

.modal-option:active {
    transform: translateY(0);
}

.modal-option-icon {
    font-size: 28px;
    flex-shrink: 0;
}

.modal-option-title {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 2px;
}

.modal-option-desc {
    font-size: 12px;
    color: var(--text-muted);
    line-height: 1.4;
}