/**
 * PDFox PDF Editor Styles
 * Modular CSS Architecture
 */

/* ==========================================================================
   CSS Variables (Theme)
   ========================================================================== */
:root {
    --color-primary: #E50914;
    --color-primary-dark: #C40812;
    --color-primary-light: rgba(229, 9, 20, 0.4);
    --color-bg-dark: #000000;
    --color-bg-primary: #141414;
    --color-bg-secondary: #1a1a1a;
    --color-bg-tertiary: #2a2a2a;
    --color-bg-hover: #3a3a3a;
    --color-border: #333;
    --color-border-light: #444;
    --color-text-primary: #ffffff;
    --color-text-secondary: #aaaaaa;
    --color-text-muted: #888;
    --color-success: #4CAF50;
    --color-info: #2196F3;
    --color-warning: #ff9800;
    --color-danger: #dc3545;
    --shadow-sm: 0 2px 6px rgba(0, 0, 0, 0.5);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.6);
    --shadow-lg: 0 10px 40px rgba(0, 0, 0, 0.8);
    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 16px;
    --transition-fast: 0.2s ease;
    --transition-normal: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ==========================================================================
   Reset & Base
   ========================================================================== */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

* {
    scrollbar-width: thin;
    scrollbar-color: var(--color-border) var(--color-bg-primary);
}

::-webkit-scrollbar {
    width: 12px;
    height: 12px;
}

::-webkit-scrollbar-track {
    background: var(--color-bg-primary);
    border-radius: 10px;
}

::-webkit-scrollbar-thumb {
    background: var(--color-border);
    border-radius: 10px;
    border: 2px solid var(--color-bg-primary);
}

::-webkit-scrollbar-thumb:hover {
    background: var(--color-primary);
}

::-webkit-scrollbar-corner {
    background: var(--color-bg-primary);
}

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

/* ==========================================================================
   Header
   ========================================================================== */
.header {
    background: var(--color-bg-dark);
    color: white;
    padding: 20px 40px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.8);
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: relative;
    z-index: 600;
    border-bottom: 1px solid var(--color-bg-primary);
}

.header h1 {
    font-size: 36px;
    font-weight: 900;
    display: flex;
    align-items: center;
    gap: 12px;
    letter-spacing: 2px;
    margin: 0;
    font-family: 'Bebas Neue', sans-serif;
    color: var(--color-primary);
    text-shadow: 2px 2px 4px var(--color-primary-light);
}

.header-logo-link {
    color: var(--color-primary);
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    transition: opacity var(--transition-normal);
}

.header-logo-link:hover { opacity: 0.85; }

.header-logo-link svg {
    pointer-events: none;
}

.header-actions {
    display: flex;
    gap: 15px;
}

/* Mobile menu toggle - hidden on desktop */
.mobile-menu-toggle {
    display: none;
}

.header-btn {
    background: #808080;
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: var(--radius-sm);
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-normal);
    box-shadow: var(--shadow-sm);
    font-size: 15px;
}

.header-btn:hover {
    background: #606060;
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.header-btn.primary {
    background: var(--color-primary);
    box-shadow: 0 3px 12px var(--color-primary-light);
}

.header-btn.primary:hover {
    background: var(--color-primary-dark);
    box-shadow: 0 5px 18px rgba(229, 9, 20, 0.5);
}

/* Share Button with Pro Badge */
.header-btn.header-btn-share {
    position: relative;
    background: linear-gradient(135deg, #2a2a2a 0%, #1a1a1a 100%);
    border: 2px solid #444;
    padding-right: 50px;
}

.header-btn.header-btn-share:hover {
    background: linear-gradient(135deg, #333 0%, #222 100%);
    border-color: #E50914;
    box-shadow: 0 4px 15px rgba(229, 9, 20, 0.3);
}

/* Sign button - hidden on desktop, shown on mobile */
.header-btn.header-btn-sign {
    display: none;
    background: linear-gradient(135deg, #E50914 0%, #C40812 100%);
    border: none;
    color: white;
}

.header-btn.header-btn-sign:hover {
    background: linear-gradient(135deg, #ff1a1a 0%, #E50914 100%);
    box-shadow: 0 4px 15px rgba(229, 9, 20, 0.4);
}

/* ==========================================================================
   Open Button Dropdown - Professional File Source Picker
   ========================================================================== */
.header-open-dropdown {
    position: relative;
    display: inline-block;
}

.header-btn.header-btn-open {
    background: linear-gradient(135deg, #E50914 0%, #B00610 100%);
    border: none;
    color: white;
    padding-right: 10px;
    font-weight: 600;
}

.header-btn.header-btn-open:hover {
    background: linear-gradient(135deg, #ff1a1a 0%, #E50914 100%);
    box-shadow: 0 4px 15px rgba(229, 9, 20, 0.4);
}

.header-btn.header-btn-open .dropdown-chevron {
    opacity: 0.6;
    transition: transform 0.2s ease, opacity 0.2s ease;
}

.header-open-dropdown.open .header-btn-open .dropdown-chevron {
    transform: rotate(180deg);
    opacity: 1;
}

/* Dropdown Menu */
.header-open-menu {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    min-width: 220px;
    background: rgba(20, 20, 24, 0.98);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.4);
    padding: 6px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-8px) scale(0.96);
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    z-index: 1000;
}

.header-open-dropdown.open .header-open-menu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

/* Menu Options */
.header-open-option {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 10px 12px;
    background: transparent;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.15s ease;
    text-align: left;
}

.header-open-option:hover {
    background: rgba(255, 255, 255, 0.08);
}

.header-open-option:active {
    background: rgba(229, 9, 20, 0.15);
    transform: scale(0.98);
}

.header-open-option svg {
    flex-shrink: 0;
    opacity: 0.7;
}

.header-open-option:hover svg {
    opacity: 1;
}

.header-open-option .option-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.header-open-option .option-label {
    font-size: 13px;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.9);
}

.header-open-option .option-hint {
    font-size: 11px;
    color: rgba(255, 255, 255, 0.4);
}

.header-open-option:hover .option-hint {
    color: rgba(255, 255, 255, 0.6);
}

/* Remove Document Button - subtle warning on hover */
.header-btn.header-btn-remove {
    background: rgba(85, 85, 85, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.header-btn.header-btn-remove:hover {
    background: rgba(220, 38, 38, 0.2);
    border-color: rgba(220, 38, 38, 0.4);
}

/* Mobile styles for Open dropdown */
@media (max-width: 768px) {
    .header-open-dropdown {
        position: static;
    }

    .header-btn.header-btn-open {
        padding: 8px 10px;
        font-size: 0;
    }

    .header-btn.header-btn-open svg:first-child {
        margin-right: 0 !important;
    }

    .header-btn.header-btn-open .dropdown-chevron {
        display: none;
    }

    .header-open-menu {
        position: fixed;
        top: auto;
        bottom: 80px;
        left: 16px;
        right: 16px;
        min-width: auto;
    }
}

.header-pro-badge {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    background: linear-gradient(135deg, #FFD700 0%, #FFA500 100%);
    color: #1a1a1a;
    font-size: 9px;
    font-weight: 800;
    padding: 3px 6px;
    border-radius: 4px;
    letter-spacing: 0.5px;
    box-shadow: 0 2px 8px rgba(255, 215, 0, 0.4);
    animation: proBadgePulse 2s ease-in-out infinite;
}

@keyframes proBadgePulse {
    0%, 100% {
        box-shadow: 0 2px 8px rgba(255, 215, 0, 0.4);
    }
    50% {
        box-shadow: 0 2px 15px rgba(255, 215, 0, 0.7);
    }
}

/* ==========================================================================
   Toolbar
   ========================================================================== */
/* ==========================================================================
   TOOLBAR - Modern Professional Design
   ========================================================================== */
.toolbar {
    background: linear-gradient(180deg, #1a1a1e 0%, #141416 100%);
    padding: 6px 12px;
    display: flex;
    gap: 0;
    flex-wrap: nowrap;
    align-items: stretch;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    position: relative;
    overflow: visible;
    z-index: 500;
}

.toolbar-visible {
    display: flex;
    gap: 2px;
    flex-wrap: nowrap;
    align-items: stretch;
    flex: 1;
    min-width: 0;
    overflow: visible;
    justify-content: flex-start;
}

.tool-group {
    display: flex;
    flex-direction: column;
    gap: 3px;
    padding: 6px 10px;
    position: relative;
    flex-shrink: 0;
    overflow: visible;
    align-items: center;
    border-radius: 8px;
    margin: 2px 1px;
    background: transparent;
    transition: background 0.2s ease;
}

.tool-group:hover {
    background: rgba(255, 255, 255, 0.03);
}

.tool-group:first-child {
    padding-left: 8px;
}

.tool-group:last-child {
    padding-right: 8px;
}

/* Subtle separator between groups */
.tool-group::after {
    content: '';
    position: absolute;
    right: -1px;
    top: 20%;
    height: 60%;
    width: 1px;
    background: linear-gradient(180deg, transparent 0%, rgba(255,255,255,0.08) 50%, transparent 100%);
}

.tool-group:last-child::after,
.toolbar-overflow-group::after {
    display: none;
}

.tool-group.hidden-in-toolbar {
    display: none !important;
}

/* Primary tools should never be hidden */
.tool-group.primary-tools {
    flex-shrink: 0 !important;
    background: rgba(229, 9, 20, 0.04);
    border: 1px solid rgba(229, 9, 20, 0.08);
}

.tool-group.primary-tools:hover {
    background: rgba(229, 9, 20, 0.08);
}

.tool-group.primary-tools.hidden-in-toolbar {
    display: flex !important;
}

.tool-group-label {
    font-size: 9px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: rgba(255, 255, 255, 0.35);
    text-align: center;
    margin-bottom: 1px;
}

.tool-group:hover .tool-group-label {
    color: rgba(255, 255, 255, 0.5);
}

.tool-group .tool-buttons {
    display: flex;
    gap: 3px;
    overflow: visible;
    justify-content: center;
}

/* ==========================================================================
   MORE MENU - Clean Minimal Design
   ========================================================================== */
.toolbar-overflow-group {
    display: none;
    order: 999;
    padding: 6px 8px;
    margin-left: auto;
    border-radius: 8px;
    background: transparent;
}

.toolbar-overflow-group::after {
    display: none;
}

.toolbar-overflow-group.has-overflow {
    display: flex;
}

/* More Button - Subtle pill design */
.toolbar-overflow-group .tool-btn {
    position: relative;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 20px;
    padding: 6px 14px;
    min-width: auto;
    flex-direction: row;
    gap: 6px;
}

.toolbar-overflow-group .tool-btn svg {
    width: 16px;
    height: 16px;
    opacity: 0.7;
}

.toolbar-overflow-group .tool-btn small {
    font-size: 11px;
    font-weight: 500;
    letter-spacing: 0.3px;
}

.toolbar-overflow-group .tool-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.15);
    transform: none;
}

.toolbar-overflow-group .tool-btn:hover svg {
    opacity: 1;
}

.toolbar-overflow-group .tool-btn.active {
    background: rgba(229, 9, 20, 0.15);
    border-color: rgba(229, 9, 20, 0.3);
    color: white;
}

.toolbar-overflow-group .tool-btn.active small {
    color: rgba(255, 255, 255, 0.9);
}

/* Menu Badge - Modern minimal */
.overflow-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    background: linear-gradient(135deg, #E50914 0%, #B00610 100%);
    color: white;
    font-size: 10px;
    font-weight: 600;
    min-width: 18px;
    height: 18px;
    border-radius: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 5px;
    box-shadow: 0 2px 8px rgba(229, 9, 20, 0.4);
}

/* ==========================================================================
   Overflow Menu Dropdown - Modern Glass Design
   ========================================================================== */
.toolbar-overflow-dropdown {
    position: absolute;
    top: calc(100% + 6px);
    right: 12px;
    left: auto;
    z-index: 10000;
    display: none;
    flex-direction: column;
    width: auto;
    min-width: 320px;
    max-width: 90vw;
    max-height: 75vh;
    padding: 12px;

    /* Glass morphism background */
    background: rgba(20, 20, 24, 0.95);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 16px;
    box-shadow:
        0 24px 48px rgba(0, 0, 0, 0.4),
        0 0 0 1px rgba(255, 255, 255, 0.05) inset;

    /* Scrolling */
    overflow-y: auto;
    overflow-x: hidden;

    /* Scrollbar styling */
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.1) transparent;
}

.toolbar-overflow-dropdown::-webkit-scrollbar {
    width: 4px;
}

.toolbar-overflow-dropdown::-webkit-scrollbar-track {
    background: transparent;
}

.toolbar-overflow-dropdown::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 2px;
}

.toolbar-overflow-dropdown::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.2);
}

.toolbar-overflow-dropdown.open {
    display: flex;
    animation: menuSlideIn 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

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

/* Tool Groups in Dropdown */
.toolbar-overflow-dropdown .tool-group {
    border: none;
    padding: 0;
    margin: 0 0 8px 0;
    display: flex !important;
    flex-direction: column;
    background: rgba(255, 255, 255, 0.02);
    border-radius: 12px;
    overflow: hidden;
}

.toolbar-overflow-dropdown .tool-group::after {
    display: none;
}

.toolbar-overflow-dropdown .tool-group:hover {
    background: rgba(255, 255, 255, 0.04);
}

/* Hide groups that are intentionally hidden (like SELECT/AI Text) */
.toolbar-overflow-dropdown .tool-group[style*="display: none"],
.toolbar-overflow-dropdown .tool-group[style*="display:none"] {
    display: none !important;
}

.toolbar-overflow-dropdown .tool-group:last-child {
    margin-bottom: 0;
}

/* Group Label / Section Header */
.toolbar-overflow-dropdown .tool-group-label {
    padding: 10px 12px 6px;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1.2px;
    color: rgba(229, 9, 20, 0.8);
    margin-bottom: 0;
    border-bottom: none;
    background: transparent;
}

.toolbar-overflow-dropdown .tool-group-label::before {
    display: none;
}

/* Tool Buttons Container */
.toolbar-overflow-dropdown .tool-buttons {
    display: flex !important;
    flex-wrap: wrap;
    gap: 4px;
    padding: 4px 8px 10px 8px;
}

/* Tool Buttons in Dropdown */
.toolbar-overflow-dropdown .tool-btn {
    flex: 0 0 calc(33.333% - 3px);
    min-width: unset;
    padding: 10px 6px;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 8px;
    transition: all 0.15s ease;
    box-shadow: none;
}

.toolbar-overflow-dropdown .tool-btn::before {
    display: none;
}

.toolbar-overflow-dropdown .tool-btn:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.1);
}

.toolbar-overflow-dropdown .tool-btn:active {
    background: rgba(229, 9, 20, 0.25);
    transform: scale(0.97);
}

.toolbar-overflow-dropdown .tool-btn svg {
    width: 18px;
    height: 18px;
    color: rgba(255, 255, 255, 0.85);
    transition: color 0.15s ease;
}

.toolbar-overflow-dropdown .tool-btn:hover svg {
    color: var(--color-primary);
    transform: none;
}

.toolbar-overflow-dropdown .tool-btn small {
    font-size: 9px;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.5);
    margin-top: 4px;
    transition: color 0.15s ease;
}

.toolbar-overflow-dropdown .tool-btn:hover small {
    color: rgba(255, 255, 255, 0.85);
}

/* Active state for tools */
.toolbar-overflow-dropdown .tool-btn.active {
    background: rgba(229, 9, 20, 0.2);
    border-color: var(--color-primary);
}

/* Section Divider */
.toolbar-overflow-dropdown .menu-section-divider {
    height: 1px;
    background: rgba(255, 255, 255, 0.08);
    margin: 4px 8px 8px;
}

/* Permanent FINALIZE Section */
.toolbar-overflow-dropdown .overflow-permanent-section {
    margin-top: 8px;
    margin-bottom: 4px;
    padding-top: 8px;
    border-top: 1px solid rgba(229, 9, 20, 0.2);
}

.toolbar-overflow-dropdown .overflow-permanent-section .tool-group-label {
    color: var(--color-primary);
    font-weight: 700;
}

.toolbar-overflow-dropdown .overflow-permanent-section .tool-btn {
    background: rgba(229, 9, 20, 0.08);
}

.toolbar-overflow-dropdown .overflow-permanent-section .tool-btn:hover {
    background: rgba(229, 9, 20, 0.2);
}

/* Ensure last group has extra spacing for scroll visibility */
.toolbar-overflow-dropdown > .tool-group:last-child,
.toolbar-overflow-dropdown > .overflow-permanent-section:last-child {
    margin-bottom: 8px;
}

/* Fill tool wrapper adjustments */
.toolbar-overflow-dropdown .fill-tool-wrapper {
    display: contents;
}

.toolbar-overflow-dropdown .fill-tool-wrapper .tool-btn {
    flex: 0 0 calc(33.333% - 3px);
}

.toolbar-overflow-dropdown .fill-color-picker {
    display: none;
}

/* Stamps section - wrap to show all */
.toolbar-overflow-dropdown .tool-group[data-group="stamps"] .tool-buttons {
    display: flex !important;
    flex-wrap: wrap;
    gap: 6px;
    padding-bottom: 6px;
}

.toolbar-overflow-dropdown .tool-group[data-group="stamps"] .tool-btn {
    flex: 0 0 auto;
    min-width: 56px;
}

/* Responsive */
@media (max-width: 480px) {
    .toolbar-overflow-dropdown {
        width: calc(100vw - 32px);
        left: 8px;
        right: 8px;
    }

    .toolbar-overflow-dropdown .tool-btn {
        flex: 0 0 calc(25% - 3px);
    }
}

/* ==========================================================================
   Toolbar Right Section - Status & Quick Actions
   ========================================================================== */
.toolbar-spacer {
    flex: 1;
    min-width: 16px;
}

.toolbar-right-section {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 8px;
    margin-left: auto;
    flex-shrink: 1;
    min-width: 0;
    overflow: visible;
}

/* Document Status Indicator */
.toolbar-status-group {
    display: flex;
    align-items: center;
}

.doc-status-indicator {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: 20px;
    background: rgba(76, 175, 80, 0.1);
    border: 1px solid rgba(76, 175, 80, 0.25);
    transition: all 0.3s ease;
}

.doc-status-indicator .status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #4CAF50;
    box-shadow: 0 0 6px rgba(76, 175, 80, 0.6);
    transition: all 0.3s ease;
}

.doc-status-indicator .status-text {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #4CAF50;
    transition: color 0.3s ease;
}

/* Unsaved state */
.doc-status-indicator[data-status="unsaved"] {
    background: rgba(255, 152, 0, 0.1);
    border-color: rgba(255, 152, 0, 0.3);
}

.doc-status-indicator[data-status="unsaved"] .status-dot {
    background: #ff9800;
    box-shadow: 0 0 6px rgba(255, 152, 0, 0.6);
    animation: statusPulse 2s ease-in-out infinite;
}

.doc-status-indicator[data-status="unsaved"] .status-text {
    color: #ff9800;
}

/* Saving state */
.doc-status-indicator[data-status="saving"] {
    background: rgba(33, 150, 243, 0.1);
    border-color: rgba(33, 150, 243, 0.3);
}

.doc-status-indicator[data-status="saving"] .status-dot {
    background: #2196F3;
    box-shadow: 0 0 6px rgba(33, 150, 243, 0.6);
    animation: statusPulse 0.8s ease-in-out infinite;
}

.doc-status-indicator[data-status="saving"] .status-text {
    color: #2196F3;
}

@keyframes statusPulse {
    0%, 100% {
        transform: scale(1);
        opacity: 1;
    }
    50% {
        transform: scale(1.2);
        opacity: 0.7;
    }
}

/* Pro Badge in Toolbar */
.toolbar-pro-indicator {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 5px 10px;
    border-radius: 6px;
    background: linear-gradient(135deg, rgba(255, 215, 0, 0.15) 0%, rgba(255, 165, 0, 0.1) 100%);
    border: 1px solid rgba(255, 215, 0, 0.35);
    color: #FFD700;
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 0.8px;
    text-transform: uppercase;
    animation: proBadgeGlow 3s ease-in-out infinite;
}

.toolbar-pro-indicator svg {
    color: #FFD700;
}

@keyframes proBadgeGlow {
    0%, 100% {
        box-shadow: 0 0 8px rgba(255, 215, 0, 0.2);
    }
    50% {
        box-shadow: 0 0 15px rgba(255, 215, 0, 0.4);
    }
}

/* Promo Badge in Toolbar */
.toolbar-promo-indicator {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 4px 8px;
    border-radius: 6px;
    background: linear-gradient(135deg, rgba(168, 85, 247, 0.15) 0%, rgba(99, 102, 241, 0.1) 100%);
    border: 1px solid rgba(168, 85, 247, 0.35);
    color: #a855f7;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.3px;
    white-space: nowrap;
    flex-shrink: 0;
    animation: promoBadgePulse 2s ease-in-out infinite;
}

.toolbar-promo-indicator svg {
    color: #a855f7;
    flex-shrink: 0;
    width: 12px;
    height: 12px;
}

@keyframes promoBadgePulse {
    0%, 100% {
        box-shadow: 0 0 6px rgba(168, 85, 247, 0.2);
    }
    50% {
        box-shadow: 0 0 10px rgba(168, 85, 247, 0.35);
    }
}

/* ============================================
   Bottom Status Bar (VS Code / Figma style)
   ============================================ */
.editor-status-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 24px;
    background: #1a1a1a;
    border-top: 1px solid #2d2d2d;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 12px;
    z-index: 1000;
    font-size: 12px;
    color: #9ca3af;
}

.status-bar-left,
.status-bar-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

.status-bar-item {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 2px 8px;
    border-radius: 3px;
    transition: background 0.15s ease;
    cursor: default;
}

.status-bar-item:hover {
    background: rgba(255, 255, 255, 0.08);
}

/* Promo status - subtle muted purple (following VS Code guidelines: non-intrusive, no animation) */
.status-bar-item.status-promo {
    color: #b8a4c9;
    background: transparent;
    cursor: pointer;
}

.status-bar-item.status-promo:hover {
    background: rgba(184, 164, 201, 0.15);
}

.status-bar-item.status-promo svg {
    width: 14px;
    height: 14px;
    opacity: 0.85;
}

/* Tooltip on hover */
.status-bar-item.status-promo[title] {
    position: relative;
}

/* Pro status - gold theme */
.status-bar-item.status-pro {
    color: #fbbf24;
    background: rgba(251, 191, 36, 0.12);
}

.status-bar-item.status-pro:hover {
    background: rgba(251, 191, 36, 0.2);
}

/* Adjust main content to account for status bar */
.main-content {
    padding-bottom: 24px;
}

/* Hide toolbar promo indicator (moved to status bar) */
.toolbar-promo-indicator {
    display: none !important;
}

/* Compact badges on screens under 1600px */
@media (max-width: 1600px) {
    .toolbar-promo-indicator span,
    .toolbar-pro-indicator span {
        display: none;
    }
    .toolbar-promo-indicator,
    .toolbar-pro-indicator {
        padding: 5px;
    }
    .toolbar-right-section {
        gap: 6px;
    }
}

/* Hide status text on smaller screens */
@media (max-width: 1300px) {
    .doc-status-indicator .status-text {
        display: none;
    }
    .doc-status-indicator {
        padding: 6px;
    }
}

/* Hide status group entirely on small screens */
@media (max-width: 1100px) {
    .toolbar-status-group {
        display: none;
    }
}

/* Help/Shortcuts Button */
.toolbar-help-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    padding: 0;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--color-text-muted);
    cursor: pointer;
    transition: all 0.2s ease;
}

.toolbar-help-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.2);
    color: var(--color-text-primary);
    transform: translateY(-1px);
}

.toolbar-help-btn:active {
    transform: translateY(0);
}

.toolbar-help-btn svg {
    width: 18px;
    height: 18px;
}

/* Hide right section elements on small screens */
@media (max-width: 900px) {
    .toolbar-right-section {
        display: none;
    }

    .toolbar-spacer {
        display: none;
    }
}

/* ==========================================================================
   TOOL BUTTONS - Modern Minimal Style
   ========================================================================== */
.tool-btn {
    background: transparent;
    border: 1px solid transparent;
    padding: 6px 8px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.15s ease;
    font-size: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    box-shadow: none;
    color: rgba(255, 255, 255, 0.7);
    position: relative;
    min-width: 46px;
}

.tool-btn svg {
    width: 18px;
    height: 18px;
    transition: transform 0.15s ease, opacity 0.15s ease;
    opacity: 0.8;
}

.tool-btn:hover svg {
    opacity: 1;
    transform: scale(1.05);
}

.tool-btn small {
    font-size: 9px;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.4);
    transition: color 0.15s ease;
    letter-spacing: 0.2px;
}

.tool-btn:hover small {
    color: rgba(255, 255, 255, 0.7);
}

.tool-btn.active small {
    color: rgba(255, 255, 255, 0.95);
}

/* Fill Tool with Color Picker */
.fill-tool-wrapper {
    display: inline-flex;
    align-items: stretch;
    position: relative;
}

.fill-tool-wrapper .tool-btn {
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
    min-width: auto;
    padding-right: 10px;
}

.fill-color-picker {
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--color-bg-tertiary);
    border: 2px solid transparent;
    border-left: 1px solid var(--color-border);
    border-top-right-radius: 6px;
    border-bottom-right-radius: 6px;
    padding: 0 8px;
    cursor: pointer;
    transition: all var(--transition-normal);
    box-shadow: var(--shadow-sm);
}

.fill-color-picker:hover {
    background: var(--color-bg-hover);
}

.fill-color-picker input[type="color"] {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
    padding: 0;
    border: 0;
    pointer-events: none;
}

.fill-color-swatch {
    display: block;
    width: 18px;
    height: 18px;
    border-radius: 4px;
    background: #FFFFFF;
    border: 2px solid rgba(255, 255, 255, 0.3);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3), inset 0 0 0 1px rgba(0, 0, 0, 0.1);
    transition: all 0.2s ease;
}

.fill-color-picker:hover .fill-color-swatch {
    border-color: var(--color-primary);
    transform: scale(1.1);
}

.fill-tool-wrapper .tool-btn.active + .fill-color-picker {
    background: var(--color-primary);
    border-left-color: rgba(255, 255, 255, 0.2);
}

.tool-btn:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.95);
}

/* Custom tooltips - works for any element with data-tooltip */
[data-tooltip] {
    position: relative;
}

[data-tooltip]::after {
    content: attr(data-tooltip);
    position: absolute;
    top: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    background: var(--color-bg-secondary);
    color: var(--color-text-primary);
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 500;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s ease;
    z-index: 10002;
    border: 1px solid var(--color-border);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    pointer-events: none;
}

[data-tooltip]::before {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 6px solid transparent;
    border-bottom-color: var(--color-border);
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s ease;
    z-index: 10003;
    pointer-events: none;
}

[data-tooltip]:hover::after,
[data-tooltip]:hover::before {
    opacity: 1;
    visibility: visible;
}

/* Hide tooltip when dropdown is open */
.zoom-dropdown-container.open [data-tooltip]::after,
.zoom-dropdown-container.open [data-tooltip]::before {
    display: none;
}

/* ==========================================================================
   Quick Stamps
   ========================================================================== */

/* Stamp elements on canvas */
.stamp-element {
    position: absolute;
    cursor: move;
    user-select: none;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 160;
}

.stamp-element.selected {
    outline: 2px dashed var(--color-primary);
    outline-offset: 4px;
}

.stamp-element .stamp-content {
    pointer-events: none;
    display: flex;
    align-items: center;
    justify-content: center;
}

.stamp-element .stamp-text {
    font-weight: 600;
    white-space: nowrap;
}

/* Resize handles */
.stamp-resize-handle {
    position: absolute;
    width: 10px;
    height: 10px;
    background: white;
    border: 2px solid var(--color-primary);
    border-radius: 50%;
    opacity: 0;
    transition: opacity 0.15s ease;
    z-index: 10;
}

.stamp-element.selected .stamp-resize-handle {
    opacity: 1;
}

.stamp-resize-handle.nw {
    top: -5px;
    left: -5px;
    cursor: nwse-resize;
}

.stamp-resize-handle.ne {
    top: -5px;
    right: -5px;
    cursor: nesw-resize;
}

.stamp-resize-handle.sw {
    bottom: -5px;
    left: -5px;
    cursor: nesw-resize;
}

.stamp-resize-handle.se {
    bottom: -5px;
    right: -5px;
    cursor: nwse-resize;
}

/* Stamp cursor when placing */
#annotationCanvas.cursor-stamp {
    cursor: crosshair !important;
}

/* ==========================================================================
   Stamp Options Popup
   ========================================================================== */
.stamp-options-popup {
    position: fixed;
    z-index: 10001;
    width: 280px;
    background: var(--color-bg-secondary);
    border-radius: var(--radius-lg);
    border: 1px solid var(--color-border);
    box-shadow: var(--shadow-xl);
    overflow: hidden;
    animation: slideUp 0.2s ease;
}

.stamp-popup-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    background: var(--color-bg-tertiary);
    border-bottom: 1px solid var(--color-border);
}

.stamp-popup-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--color-text-primary);
}

.stamp-popup-close {
    background: none;
    border: none;
    padding: 4px;
    cursor: pointer;
    color: var(--color-text-secondary);
    border-radius: 4px;
    transition: all 0.15s ease;
}

.stamp-popup-close:hover {
    background: var(--color-bg-hover);
    color: var(--color-primary);
}

.stamp-popup-preview {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: white;
    min-height: 80px;
}

.stamp-preview-text {
    font-weight: 600;
}

.stamp-popup-options {
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.stamp-option-row {
    display: flex;
    align-items: center;
    gap: 12px;
}

.stamp-option-row label {
    font-size: 13px;
    font-weight: 500;
    color: var(--color-text-secondary);
    min-width: 50px;
}

.stamp-option-row input[type="color"] {
    width: 36px;
    height: 28px;
    border: 2px solid var(--color-border);
    border-radius: 6px;
    cursor: pointer;
    padding: 0;
    background: none;
}

.stamp-option-row input[type="range"] {
    flex: 1;
    height: 6px;
    background: var(--color-bg-tertiary);
    border-radius: 3px;
    appearance: none;
    cursor: pointer;
}

.stamp-option-row input[type="range"]::-webkit-slider-thumb {
    appearance: none;
    width: 16px;
    height: 16px;
    background: var(--color-primary);
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.stamp-option-row input[type="range"]::-moz-range-thumb {
    width: 16px;
    height: 16px;
    background: var(--color-primary);
    border-radius: 50%;
    cursor: pointer;
    border: none;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

#stampSizeValue {
    font-size: 12px;
    color: var(--color-text-secondary);
    min-width: 40px;
    text-align: right;
}

.stamp-popup-actions {
    display: flex;
    gap: 10px;
    padding: 12px 16px 16px;
    border-top: 1px solid var(--color-border);
}

.stamp-popup-actions .modal-btn {
    flex: 1;
    padding: 10px 16px;
    font-size: 13px;
}

/* ==========================================================================
   Patch Tool Styles
   ========================================================================== */

/* Patch selection preview (dashed rectangle while selecting) */
.patch-selection-preview {
    position: absolute;
    border: 2px dashed var(--color-primary);
    background: rgba(229, 9, 20, 0.1);
    pointer-events: none;
    z-index: 1000;
    box-sizing: border-box;
}

/* Patch element on overlay layer */
.patch-element {
    position: absolute;
    cursor: move;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    border-radius: 2px;
    overflow: visible;
    transition: box-shadow 0.15s ease;
}

.patch-element:hover {
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
}

.patch-element.selected {
    outline: 2px dashed var(--color-primary);
    outline-offset: 4px;
}

.patch-element.dragging {
    opacity: 0.8;
    cursor: grabbing;
    z-index: 1000 !important;
}

.patch-element img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: fill;
    pointer-events: none;
    user-select: none;
    -webkit-user-drag: none;
}

/* Patch resize handles */
.patch-resize-handle {
    position: absolute;
    width: 10px;
    height: 10px;
    background: white;
    border: 2px solid var(--color-primary);
    border-radius: 50%;
    opacity: 0;
    transition: opacity 0.15s ease;
    z-index: 10;
}

.patch-element.selected .patch-resize-handle {
    opacity: 1;
}

.patch-resize-handle.nw {
    top: -5px;
    left: -5px;
    cursor: nwse-resize;
}

.patch-resize-handle.ne {
    top: -5px;
    right: -5px;
    cursor: nesw-resize;
}

.patch-resize-handle.sw {
    bottom: -5px;
    left: -5px;
    cursor: nesw-resize;
}

.patch-resize-handle.se {
    bottom: -5px;
    right: -5px;
    cursor: nwse-resize;
}

/* Patch cursor when tool is active */
#annotationCanvas.cursor-patch {
    cursor: crosshair !important;
}

/* ==========================================================================
   Patch Options Popup
   ========================================================================== */
.patch-options-popup {
    position: fixed;
    z-index: 10001;
    background: var(--color-bg-secondary);
    border-radius: var(--radius-lg);
    border: 1px solid var(--color-border);
    box-shadow: var(--shadow-xl);
    overflow: hidden;
    animation: slideUp 0.2s ease;
}

.patch-popup-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    background: var(--color-bg-tertiary);
    border-bottom: 1px solid var(--color-border);
}

.patch-popup-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--color-text-primary);
}

.patch-popup-close {
    background: none;
    border: none;
    padding: 4px;
    cursor: pointer;
    color: var(--color-text-secondary);
    border-radius: 4px;
    transition: all 0.15s ease;
}

.patch-popup-close:hover {
    background: var(--color-bg-hover);
    color: var(--color-primary);
}

.patch-popup-preview {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    background: #f5f5f5;
    min-height: 100px;
    max-height: 200px;
    overflow: hidden;
}

.patch-popup-preview img {
    max-width: 100%;
    max-height: 180px;
    object-fit: contain;
    border: 1px solid var(--color-border);
    border-radius: 4px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.patch-popup-info {
    padding: 8px 16px;
    font-size: 12px;
    color: var(--color-text-secondary);
    text-align: center;
    background: var(--color-bg-tertiary);
    border-bottom: 1px solid var(--color-border);
}

.patch-popup-options {
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.patch-option-row {
    display: flex;
    align-items: center;
    gap: 12px;
}

.patch-option-row label {
    font-size: 13px;
    font-weight: 500;
    color: var(--color-text-secondary);
    min-width: 60px;
}

.patch-option-row input[type="range"] {
    flex: 1;
    height: 6px;
    background: var(--color-bg-tertiary);
    border-radius: 3px;
    appearance: none;
    cursor: pointer;
}

.patch-option-row input[type="range"]::-webkit-slider-thumb {
    appearance: none;
    width: 16px;
    height: 16px;
    background: var(--color-primary);
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.patch-option-row input[type="range"]::-moz-range-thumb {
    width: 16px;
    height: 16px;
    background: var(--color-primary);
    border-radius: 50%;
    cursor: pointer;
    border: none;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

#patchOpacityValue {
    font-size: 12px;
    color: var(--color-text-secondary);
    min-width: 40px;
    text-align: right;
}

.patch-popup-actions {
    display: flex;
    gap: 10px;
    padding: 12px 16px 16px;
    border-top: 1px solid var(--color-border);
}

.patch-popup-actions .modal-btn {
    flex: 1;
    padding: 10px 16px;
    font-size: 13px;
}

.tool-btn.active {
    background: linear-gradient(135deg, rgba(229, 9, 20, 0.9) 0%, rgba(176, 6, 16, 0.9) 100%);
    color: white;
    border-color: rgba(229, 9, 20, 0.5);
}

.tool-btn.active svg {
    opacity: 1;
}

/* Sign button - prominent styling for key feature */
.tool-btn.tool-btn-sign {
    background: rgba(229, 9, 20, 0.1);
    border: 1px solid rgba(229, 9, 20, 0.25);
}

.tool-btn.tool-btn-sign:hover {
    background: rgba(229, 9, 20, 0.18);
    border-color: rgba(229, 9, 20, 0.4);
    transform: translateY(-1px);
}

.tool-btn.tool-btn-sign svg {
    color: var(--color-primary);
}

.tool-btn.tool-btn-sign small {
    color: var(--color-primary);
    font-weight: 600;
}

.tool-label {
    font-size: 13px;
    font-weight: 500;
    color: var(--color-text-secondary);
    margin-right: 10px;
}

/* ==========================================================================
   Zoom Dropdown - Professional UI Design
   ========================================================================== */

/* Container */
.zoom-dropdown-container {
    position: relative;
    display: inline-flex;
}

/* Trigger Button */
.zoom-dropdown-trigger {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: linear-gradient(135deg, rgba(255,255,255,0.05) 0%, rgba(255,255,255,0.02) 100%);
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    backdrop-filter: blur(10px);
}

.zoom-dropdown-trigger:hover {
    background: linear-gradient(135deg, rgba(229, 9, 20, 0.15) 0%, rgba(229, 9, 20, 0.08) 100%);
    border-color: rgba(229, 9, 20, 0.4);
    transform: translateY(-1px);
}

.zoom-dropdown-container.open .zoom-dropdown-trigger {
    background: linear-gradient(135deg, rgba(229, 9, 20, 0.2) 0%, rgba(229, 9, 20, 0.1) 100%);
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(229, 9, 20, 0.15);
}

.zoom-dropdown-trigger:focus {
    outline: none;
}

/* Arrow Icon */
.zoom-dropdown-arrow {
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    opacity: 0.5;
    color: var(--color-text-secondary);
}

.zoom-dropdown-container.open .zoom-dropdown-arrow {
    transform: rotate(180deg);
    opacity: 1;
    color: var(--color-primary);
}

/* Zoom Display Value */
.zoom-display {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 42px;
    color: var(--color-text-primary);
    font-size: 13px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.02em;
}

/* Dropdown Menu Panel */
.zoom-dropdown-menu {
    position: absolute;
    top: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%) translateY(-8px) scale(0.96);
    width: 200px;
    background: linear-gradient(180deg, #1a1a1a 0%, #141414 100%);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 12px;
    box-shadow:
        0 20px 50px rgba(0, 0, 0, 0.5),
        0 0 0 1px rgba(255, 255, 255, 0.05) inset,
        0 1px 0 rgba(255, 255, 255, 0.05) inset;
    z-index: 10000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    padding: 6px;
    backdrop-filter: blur(20px);
}

.zoom-dropdown-container.open .zoom-dropdown-menu {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(0) scale(1);
}

/* Section Styling */
.zoom-dropdown-section {
    padding: 4px 0;
}

.zoom-dropdown-section:first-child {
    padding-top: 0;
}

/* Section Label */
.zoom-dropdown-section-label {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--color-text-muted);
    padding: 8px 10px 6px;
    opacity: 0.6;
}

/* Divider */
.zoom-dropdown-divider {
    height: 1px;
    background: linear-gradient(90deg, transparent 0%, rgba(255,255,255,0.08) 20%, rgba(255,255,255,0.08) 80%, transparent 100%);
    margin: 6px 0;
}

/* Menu Items */
.zoom-dropdown-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 10px 12px;
    background: transparent;
    border: none;
    border-radius: 8px;
    color: var(--color-text-secondary);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s ease;
    text-align: left;
    position: relative;
}

.zoom-dropdown-item:hover {
    background: rgba(255, 255, 255, 0.06);
    color: var(--color-text-primary);
}

.zoom-dropdown-item:active {
    background: rgba(255, 255, 255, 0.08);
    transform: scale(0.98);
}

/* Active/Selected State */
.zoom-dropdown-item.active {
    background: linear-gradient(135deg, rgba(229, 9, 20, 0.15) 0%, rgba(229, 9, 20, 0.08) 100%);
    color: var(--color-primary);
    font-weight: 600;
}

.zoom-dropdown-item.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 16px;
    background: var(--color-primary);
    border-radius: 0 2px 2px 0;
}

/* Item Icons */
.zoom-dropdown-item svg {
    flex-shrink: 0;
    width: 18px;
    height: 18px;
    opacity: 0.6;
    transition: opacity 0.15s ease;
}

.zoom-dropdown-item:hover svg {
    opacity: 1;
}

.zoom-dropdown-item.active svg {
    opacity: 1;
    color: var(--color-primary);
}

/* Preset Grid */
.zoom-presets {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 4px;
    padding: 4px 0;
}

.zoom-presets .zoom-dropdown-item {
    justify-content: center;
    padding: 8px 4px;
    font-size: 12px;
    font-weight: 500;
    font-variant-numeric: tabular-nums;
    border-radius: 6px;
    min-height: 36px;
}

.zoom-presets .zoom-dropdown-item.active::before {
    display: none;
}

.zoom-presets .zoom-dropdown-item.active {
    background: var(--color-primary);
    color: white;
    font-weight: 600;
    box-shadow: 0 2px 8px rgba(229, 9, 20, 0.4);
}

.zoom-presets .zoom-dropdown-item:hover:not(.active) {
    background: rgba(255, 255, 255, 0.1);
}

/* Keyboard shortcut hints */
.zoom-dropdown-item .shortcut {
    margin-left: auto;
    font-size: 11px;
    color: var(--color-text-muted);
    opacity: 0.5;
    font-weight: 500;
}

.color-picker {
    width: 40px;
    height: 40px;
    border: 2px solid #DDD;
    border-radius: 6px;
    cursor: pointer;
}

/* ==========================================================================
   Main Content & Canvas
   ========================================================================== */
.main-content {
    flex: 1;
    display: flex;
    overflow: hidden;
}

.canvas-container {
    flex: 1;
    background: var(--color-bg-secondary);
    overflow: auto;
    position: relative;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding: 50px;
}

.pdf-viewer {
    position: relative;
    background: white;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    border-radius: var(--radius-md);
    overflow: visible;
    transition: box-shadow var(--transition-normal);
}

.pdf-viewer:hover {
    box-shadow: 0 15px 50px rgba(0, 0, 0, 0.2);
}

/* Hide pdf-viewer initially until PDF loads */
.pdf-viewer:not(.loaded) {
    display: none;
}

.pdf-viewer.loaded {
    display: block;
}

#pdfCanvas {
    display: block;
}

/* ==========================================================================
   Canvas Empty State - Professional branded loading screen
   ========================================================================== */
.canvas-empty-state {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #0d0d0d 0%, #1a1a1a 50%, #141414 100%);
    z-index: 1;
    overflow: hidden;
}

.canvas-empty-state.hidden {
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.5s ease;
}

.empty-state-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    position: relative;
    z-index: 2;
}

/* Animated background pattern */
.empty-state-pattern {
    position: absolute;
    inset: 0;
    z-index: 0;
    opacity: 0.03;
    pointer-events: none;
    background-image:
        radial-gradient(circle at 25% 25%, #E50914 1px, transparent 1px),
        radial-gradient(circle at 75% 75%, #E50914 1px, transparent 1px);
    background-size: 60px 60px;
    animation: patternFloat 20s ease-in-out infinite;
}

@keyframes patternFloat {
    0%, 100% { transform: translate(0, 0); }
    50% { transform: translate(30px, 30px); }
}

/* Logo container with glow effect */
.empty-state-logo {
    position: relative;
    margin-bottom: 24px;
    animation: logoFloat 3s ease-in-out infinite;
}

.empty-state-logo::before {
    content: '';
    position: absolute;
    inset: -20px;
    background: radial-gradient(circle, rgba(229, 9, 20, 0.2) 0%, transparent 70%);
    border-radius: 50%;
    animation: glowPulse 2s ease-in-out infinite;
}

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

@keyframes glowPulse {
    0%, 100% { opacity: 0.5; transform: scale(1); }
    50% { opacity: 0.8; transform: scale(1.1); }
}

/* SVG Logo animations */
.pdfox-logo-animated {
    filter: drop-shadow(0 4px 20px rgba(229, 9, 20, 0.4));
}

.pdfox-logo-animated .doc-body {
    animation: docPulse 3s ease-in-out infinite;
}

.pdfox-logo-animated .edit-circle {
    animation: editBounce 2s ease-in-out infinite;
    transform-origin: 36px 36px;
}

.pdfox-logo-animated .text-line {
    animation: lineReveal 2s ease-in-out infinite;
}

.pdfox-logo-animated .line-1 { animation-delay: 0s; }
.pdfox-logo-animated .line-2 { animation-delay: 0.1s; }
.pdfox-logo-animated .line-3 { animation-delay: 0.2s; }
.pdfox-logo-animated .line-4 { animation-delay: 0.3s; }

@keyframes docPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.9; }
}

@keyframes editBounce {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

@keyframes lineReveal {
    0%, 100% { opacity: 0.8; stroke-dashoffset: 0; }
    50% { opacity: 1; }
}

/* Title styling */
.empty-state-title {
    font-size: 48px;
    font-weight: 800;
    letter-spacing: 8px;
    color: #ffffff;
    text-shadow: 0 2px 20px rgba(229, 9, 20, 0.4);
    margin-bottom: 8px;
    background: linear-gradient(135deg, #ffffff 0%, #E50914 50%, #ffffff 100%);
    background-size: 200% auto;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: shimmer 3s linear infinite;
}

@keyframes shimmer {
    0% { background-position: 200% center; }
    100% { background-position: -200% center; }
}

.empty-state-subtitle {
    font-size: 14px;
    font-weight: 400;
    letter-spacing: 4px;
    text-transform: uppercase;
    color: var(--color-text-muted);
    margin-bottom: 40px;
}

/* Loading indicator */
.empty-state-loader {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    margin-bottom: 40px;
}

.loader-dots {
    display: flex;
    gap: 8px;
}

.loader-dots span {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--color-primary);
    animation: dotBounce 1.4s ease-in-out infinite;
}

.loader-dots span:nth-child(1) { animation-delay: 0s; }
.loader-dots span:nth-child(2) { animation-delay: 0.2s; }
.loader-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes dotBounce {
    0%, 80%, 100% {
        transform: scale(0.6);
        opacity: 0.5;
    }
    40% {
        transform: scale(1);
        opacity: 1;
    }
}

.loader-text {
    font-size: 13px;
    color: var(--color-text-muted);
    letter-spacing: 1px;
}

/* Drop zone hint */
.empty-state-hint {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 16px 28px;
    background: rgba(255, 255, 255, 0.03);
    position: relative;
    z-index: 10;
    border: 1px dashed rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    color: var(--color-text-muted);
    font-size: 13px;
    transition: all 0.3s ease;
}

.empty-state-hint:hover {
    background: rgba(229, 9, 20, 0.05);
    border-color: rgba(229, 9, 20, 0.3);
    color: var(--color-text-secondary);
}

.empty-state-hint svg {
    opacity: 0.6;
}

/* Google Drive import section */
.empty-state-divider {
    display: flex;
    align-items: center;
    gap: 15px;
    width: 200px;
    margin: 15px 0;
    position: relative;
    z-index: 10;
}

.empty-state-divider::before,
.empty-state-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: rgba(255, 255, 255, 0.1);
}

.empty-state-divider span {
    color: var(--color-text-muted);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.google-drive-btn {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 12px 24px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    color: var(--color-text-secondary);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
    z-index: 10;
}

.google-drive-btn:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.2);
    color: var(--color-text-primary);
    transform: translateY(-1px);
}

.google-drive-btn:active {
    transform: translateY(0);
}

.google-drive-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.google-drive-btn svg {
    flex-shrink: 0;
}

.google-drive-status {
    font-size: 12px;
    color: var(--color-text-muted);
    margin-top: 8px;
    text-align: center;
}

.google-drive-status.error {
    color: var(--color-danger);
}

.google-drive-status.success {
    color: var(--color-success);
}

/* ==========================================================================
   Google Drive Status Indicator (Toolbar)
   Follows the same design pattern as doc-status-indicator
   ========================================================================== */
#gdriveStatusGroup {
    display: flex;
    align-items: center;
}

.gdrive-status-indicator {
    position: relative;
}

.gdrive-status-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: 20px;
    background: rgba(136, 136, 136, 0.1);
    border: 1px solid rgba(136, 136, 136, 0.25);
    cursor: pointer;
    transition: all 0.3s ease;
    color: rgba(255, 255, 255, 0.7);
}

.gdrive-status-btn:hover {
    background: rgba(136, 136, 136, 0.2);
    border-color: rgba(136, 136, 136, 0.4);
}

.gdrive-status-btn svg {
    width: 18px;
    height: 18px;
    opacity: 0.7;
    transition: opacity 0.2s ease;
}

.gdrive-status-btn:hover svg {
    opacity: 1;
}

.gdrive-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #888;
    transition: all 0.3s ease;
}

.gdrive-text {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #888;
    transition: color 0.3s ease;
}

/* Connected state */
.gdrive-status-indicator[data-status="connected"] .gdrive-status-btn {
    background: rgba(76, 175, 80, 0.1);
    border-color: rgba(76, 175, 80, 0.25);
}

.gdrive-status-indicator[data-status="connected"] .gdrive-dot {
    background: #4CAF50;
    box-shadow: 0 0 6px rgba(76, 175, 80, 0.6);
}

.gdrive-status-indicator[data-status="connected"] .gdrive-text {
    color: #4CAF50;
}

.gdrive-status-indicator[data-status="connected"] .gdrive-status-btn svg {
    color: #4CAF50;
    opacity: 1;
}

/* Syncing state */
.gdrive-status-indicator[data-status="syncing"] .gdrive-status-btn {
    background: rgba(33, 150, 243, 0.1);
    border-color: rgba(33, 150, 243, 0.3);
}

.gdrive-status-indicator[data-status="syncing"] .gdrive-dot {
    background: #2196F3;
    box-shadow: 0 0 6px rgba(33, 150, 243, 0.6);
    animation: statusPulse 0.8s ease-in-out infinite;
}

.gdrive-status-indicator[data-status="syncing"] .gdrive-text {
    color: #2196F3;
}

.gdrive-status-indicator[data-status="syncing"] .gdrive-status-btn svg {
    color: #2196F3;
    opacity: 1;
}

/* Error state */
.gdrive-status-indicator[data-status="error"] .gdrive-status-btn {
    background: rgba(244, 67, 54, 0.1);
    border-color: rgba(244, 67, 54, 0.3);
}

.gdrive-status-indicator[data-status="error"] .gdrive-dot {
    background: #f44336;
    box-shadow: 0 0 6px rgba(244, 67, 54, 0.6);
}

.gdrive-status-indicator[data-status="error"] .gdrive-text {
    color: #f44336;
}

.gdrive-status-indicator[data-status="error"] .gdrive-status-btn svg {
    color: #f44336;
    opacity: 1;
}

/* Dropdown panel */
.gdrive-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    min-width: 180px;
    background: rgba(20, 20, 24, 0.98);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.4);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-8px) scale(0.96);
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    z-index: 1001;
    padding: 8px;
}

.gdrive-status-indicator.open .gdrive-dropdown {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

.gdrive-dropdown-header {
    padding: 8px 10px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    margin-bottom: 6px;
}

.gdrive-dropdown-title {
    display: block;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: rgba(255, 255, 255, 0.5);
    margin-bottom: 4px;
}

.gdrive-dropdown-status {
    font-size: 12px;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.9);
}

.gdrive-dropdown-status.connected {
    color: #4CAF50;
}

.gdrive-dropdown-status.error {
    color: #f44336;
}

.gdrive-dropdown-actions {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.gdrive-action-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 10px 12px;
    background: transparent;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.15s ease;
    text-align: left;
}

.gdrive-action-btn svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    opacity: 0.7;
}

.gdrive-action-btn span {
    font-size: 13px;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.9);
}

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

.gdrive-action-btn:hover svg {
    opacity: 1;
}

.gdrive-action-btn.gdrive-connect svg {
    color: #4CAF50;
}

.gdrive-action-btn.gdrive-connect:hover {
    background: rgba(76, 175, 80, 0.1);
}

.gdrive-action-btn.gdrive-disconnect svg {
    color: #f44336;
}

.gdrive-action-btn.gdrive-disconnect:hover {
    background: rgba(244, 67, 54, 0.1);
}

/* Show/hide buttons based on connection state */
.gdrive-status-indicator:not([data-status="connected"]) .gdrive-disconnect {
    display: none;
}

.gdrive-status-indicator[data-status="connected"] .gdrive-connect {
    display: none;
}

/* Responsive: Hide text on smaller screens */
@media (max-width: 1300px) {
    .gdrive-text {
        display: none;
    }
    .gdrive-status-btn {
        padding: 6px 8px;
    }
}

/* Hide entire group on very small screens */
@media (max-width: 1100px) {
    #gdriveStatusGroup {
        display: none;
    }
}

/* Drag and drop state */
.canvas-container.drag-over {
    background: rgba(229, 9, 20, 0.05);
}

.canvas-empty-state.drag-over {
    background: linear-gradient(135deg, #1a0d0d 0%, #1a1a1a 50%, #1a1414 100%);
}

.canvas-empty-state.drag-over .empty-state-hint {
    background: rgba(229, 9, 20, 0.1);
    border-color: rgba(229, 9, 20, 0.5);
    color: var(--color-text-primary);
    transform: scale(1.02);
}

.canvas-empty-state.drag-over .empty-state-hint svg {
    opacity: 1;
    color: var(--color-primary);
}

.canvas-empty-state.drag-over .pdfox-logo-animated {
    animation: dragPulse 0.5s ease-in-out infinite;
}

@keyframes dragPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .empty-state-logo svg {
        width: 80px;
        height: 80px;
    }

    .empty-state-title {
        font-size: 32px;
        letter-spacing: 4px;
    }

    .empty-state-subtitle {
        font-size: 11px;
        letter-spacing: 2px;
    }

    .empty-state-hint {
        padding: 12px 20px;
        font-size: 12px;
    }
}

#annotationCanvas {
    position: absolute;
    top: 0;
    left: 0;
    cursor: default;
    pointer-events: none;
    z-index: 50; /* Below text layer (100) and overlay layer (150) */
}

/* Tool-specific cursors for annotation canvas */
/* Draw tool - Pencil/pen cursor */
#annotationCanvas.cursor-draw {
    cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24'%3E%3Cpath d='M3 17.25V21h3.75L17.81 9.94l-3.75-3.75L3 17.25zM20.71 7.04a.996.996 0 000-1.41l-2.34-2.34a.996.996 0 00-1.41 0l-1.83 1.83 3.75 3.75 1.83-1.83z' fill='%23E50914'/%3E%3C/svg%3E") 0 24, crosshair !important;
}

/* Rectangle tool cursor - crosshair */
#annotationCanvas.cursor-rectangle {
    cursor: crosshair !important;
}

/* Circle tool cursor - crosshair */
#annotationCanvas.cursor-circle {
    cursor: crosshair !important;
}

/* Fill tool cursor */
#annotationCanvas.cursor-fill {
    cursor: crosshair !important;
}

/* OCR Select tool cursor */
#annotationCanvas.cursor-ocr {
    cursor: crosshair !important;
}

/* Add Text tool cursor - text cursor */
#annotationCanvas.cursor-addText {
    cursor: text !important;
}

/* ==========================================================================
   Text Layer
   ========================================================================== */
#textLayer {
    position: absolute;
    left: 0;
    top: 0;
    right: 0;
    bottom: 0;
    overflow: hidden;
    line-height: 1.0;
    pointer-events: none;
    z-index: 10;
}

#textLayer.editable {
    pointer-events: none; /* Container stays none, children get auto */
    z-index: 100;
}

#textLayer.editable > span,
#textLayer.editable .text-edit-overlay {
    pointer-events: auto; /* Only text spans catch clicks, empty space passes through */
}

#textLayer:not(.editable) > span:not(.edited) { opacity: 0; }

#textLayer .text-edit-overlay { opacity: 1 !important; }

#textLayer > span {
    color: transparent;
    position: absolute;
    white-space: pre;
    cursor: pointer;
    transform-origin: 0% 0%;
    padding: 2px;
    margin: -2px;
    text-indent: 0;
    letter-spacing: 0;
    word-spacing: 0;
}

/* When text layer is editable, show subtle highlight so users know text is clickable */
/* Design: Uses brand-aligned colors (primary red) for visual consistency */
#textLayer.editable > span {
    background: rgba(229, 9, 20, 0.08);
    border-radius: var(--radius-sm);
    cursor: pointer;
    /* Extend highlight horizontally to connect adjacent text fragments */
    padding: 3px 8px;
    margin: -3px -8px;
    /* Subtle border for definition without being overwhelming */
    box-shadow: inset 0 0 0 1px rgba(229, 9, 20, 0.15);
    /* Use box-decoration-break for better visual continuity */
    box-decoration-break: clone;
    -webkit-box-decoration-break: clone;
    transition: all var(--transition-fast);
}

#textLayer.editable > span:hover {
    background: rgba(229, 9, 20, 0.15);
    box-shadow:
        inset 0 0 0 1px rgba(229, 9, 20, 0.3),
        0 2px 8px rgba(229, 9, 20, 0.2);
    /* Larger padding on hover for better clickability */
    padding: 4px 10px;
    margin: -4px -10px;
    z-index: 10;
    cursor: grab;
}

#textLayer > span.edited {
    opacity: 1 !important;
    box-shadow: none;
    border: 2px solid transparent;
    padding: 4px 8px !important;
    margin: -4px -8px !important;
    cursor: move !important;
    user-select: none;
    pointer-events: auto !important;
    transition: all var(--transition-fast);
    border-radius: 2px;
}

#textLayer > span.edited:hover {
    border-color: rgba(229, 9, 20, 0.5);
}

#textLayer > span.edited.selected {
    border: 2px solid var(--color-primary);
    box-shadow: 0 0 0 3px rgba(229, 9, 20, 0.2), 0 4px 16px rgba(0, 0, 0, 0.3);
    z-index: 200;
}

#textLayer > span.dragging,
#textLayer > span.edited.dragging {
    opacity: 0.7;
    box-shadow: 0 0 0 3px rgba(229, 9, 20, 0.4);
    z-index: 1000 !important;
    cursor: grabbing !important;
}

/* Edit text delete button */
#textLayer > span.edited .edit-delete-btn {
    position: absolute;
    top: -12px;
    right: -12px;
    width: 24px;
    height: 24px;
    background: var(--color-primary);
    border: 2px solid white;
    border-radius: 50%;
    color: white;
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: bold;
    z-index: 201;
    transition: all var(--transition-fast);
}

#textLayer > span.edited .edit-delete-btn:hover {
    background: var(--color-primary-dark);
    transform: scale(1.1);
}

#textLayer > span.edited.selected .edit-delete-btn {
    display: flex;
}

/* Edit text resize handles */
#textLayer > span.edited .edit-resize-handle {
    position: absolute;
    width: 10px;
    height: 10px;
    background: var(--color-primary);
    border: 2px solid white;
    border-radius: 50%;
    display: none;
    z-index: 201;
}

#textLayer > span.edited .edit-resize-handle:hover {
    transform: scale(1.2);
}

#textLayer > span.edited.selected .edit-resize-handle {
    display: block;
}

#textLayer > span.edited .edit-resize-handle.se { bottom: -5px; right: -5px; cursor: nwse-resize; }
#textLayer > span.edited .edit-resize-handle.sw { bottom: -5px; left: -5px; cursor: nesw-resize; }
#textLayer > span.edited .edit-resize-handle.ne { top: -5px; right: -5px; cursor: nesw-resize; }
#textLayer > span.edited .edit-resize-handle.nw { top: -5px; left: -5px; cursor: nwse-resize; }

/* ==========================================================================
   Overlay Layer
   ========================================================================== */
#overlayLayer {
    position: absolute;
    left: 0;
    top: 0;
    right: 0;
    bottom: 0;
    overflow: visible;
    pointer-events: none;
    z-index: 150; /* Above annotation canvas (which has no z-index, so defaults to auto) */
}

#overlayLayer > * { pointer-events: auto; }

/* ==========================================================================
   Text Overlays
   ========================================================================== */
.text-overlay {
    position: absolute;
    padding: 2px 4px;
    background-color: transparent;
    border: 1px dashed transparent;
    box-shadow: none;
    cursor: move;
    user-select: none;
    white-space: pre-wrap;
    word-wrap: break-word;
    transition: border-color 0.15s ease;
    z-index: 100;
    line-height: 1.2;
}

.text-overlay:hover {
    border-color: rgba(100, 100, 100, 0.4);
}

.text-overlay.selected {
    border: 1px solid rgba(229, 9, 20, 0.6);
    z-index: 200;
}

.text-overlay .delete-btn {
    position: absolute;
    top: -10px;
    right: -10px;
    width: 20px;
    height: 20px;
    background: #666;
    color: white;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: normal;
    z-index: 201;
    opacity: 0.8;
    transition: opacity 0.15s ease, background 0.15s ease;
}

.text-overlay .delete-btn:hover {
    background: var(--color-primary);
    opacity: 1;
}

.text-overlay.selected .delete-btn { display: flex; }
.text-overlay.dragging {
    opacity: 0.8;
    cursor: grabbing;
    z-index: 1000 !important;
}

/* Resize handles - minimal corner squares */
.resize-handle {
    position: absolute;
    width: 8px;
    height: 8px;
    background: rgba(229, 9, 20, 0.8);
    border: none;
    border-radius: 1px;
    display: none;
    z-index: 202;
    transition: background 0.15s ease;
}

.resize-handle:hover {
    background: var(--color-primary);
}

.text-overlay.selected .resize-handle { display: block; }

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

/* ==========================================================================
   Sidebar & Layers Panel
   ========================================================================== */
.sidebar {
    width: 320px;
    background: var(--color-bg-primary);
    padding: 25px;
    box-shadow: -4px 0 20px rgba(0, 0, 0, 0.8);
    overflow-y: auto;
    border-left: 1px solid #222;
}

/* Hide mobile close button on desktop */
.sidebar-close-btn {
    display: none;
}

.sidebar h3 {
    font-size: 16px;
    margin-bottom: 15px;
    color: var(--color-text-primary);
}

.property-group { margin-bottom: 20px; }

.property-label {
    font-size: 14px;
    font-weight: 500;
    color: var(--color-text-secondary);
    margin-bottom: 8px;
    display: block;
}

.property-input {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    font-size: 14px;
    background: var(--color-bg-tertiary);
    color: var(--color-text-primary);
}

/* Layers Panel */
.layers-panel {
    margin-top: 20px;
    border-top: 1px solid var(--color-border);
    padding-top: 20px;
}

.layers-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

.layers-panel-header h4 {
    color: var(--color-primary);
    font-size: 14px;
    font-weight: 600;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.layers-panel-header .layer-count {
    background: var(--color-primary);
    color: white;
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 10px;
    font-weight: 600;
}

.layers-list {
    max-height: 350px;
    overflow-y: auto;
    overflow-x: hidden;
}

.layer-item {
    display: flex;
    align-items: center;
    padding: 10px 12px;
    margin: 6px 0;
    background: var(--color-bg-tertiary);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-fast);
    border: 2px solid transparent;
}

.layer-item:hover { background: var(--color-bg-hover); }

.layer-item.selected {
    background: rgba(229, 9, 20, 0.15);
    border-color: var(--color-primary);
}

.layer-item-icon {
    width: 32px;
    height: 32px;
    min-width: 32px;
    min-height: 32px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 12px;
    font-size: 14px;
    flex-shrink: 0;
    overflow: hidden;
    position: relative;
}

.layer-item-icon.text-edit {
    background: rgba(76, 175, 80, 0.2);
    color: var(--color-success);
}

.layer-item-icon.text-overlay {
    background: rgba(33, 150, 243, 0.2);
    color: var(--color-info);
}

.layer-item-icon.signature {
    background: rgba(156, 39, 176, 0.2);
    color: #9C27B0;
}

.layer-item-icon.annotation-draw {
    background: rgba(229, 9, 20, 0.15);
    color: #E50914;
}

.layer-item-icon.annotation-draw svg {
    stroke: #E50914;
}

.layer-item-icon.annotation-rectangle {
    background: rgba(255, 152, 0, 0.15);
    color: #FF9800;
}

.layer-item-icon.annotation-rectangle svg {
    stroke: #FF9800;
}

.layer-item-icon.annotation-circle {
    background: rgba(0, 188, 212, 0.15);
    color: #00BCD4;
}

.layer-item-icon.annotation-circle svg {
    stroke: #00BCD4;
}

.layer-item-icon.fill {
    background: rgba(156, 39, 176, 0.2);
    color: #9C27B0;
}

/* Stamp layer icons */
.layer-item-icon.stamp-check {
    background: rgba(34, 197, 94, 0.2);
    color: #22c55e;
}

.layer-item-icon.stamp-x {
    background: rgba(239, 68, 68, 0.2);
    color: #ef4444;
}

.layer-item-icon.stamp-circle,
.layer-item-icon.stamp-dot {
    background: rgba(59, 130, 246, 0.2);
    color: #3b82f6;
}

.layer-item-icon.stamp-date {
    background: rgba(107, 114, 128, 0.2);
    color: #6b7280;
}

.layer-item-icon.stamp-na {
    background: rgba(107, 114, 128, 0.2);
    color: #6b7280;
}

.layer-item-icon.patch {
    background: rgba(139, 92, 246, 0.2);
    color: #8b5cf6;
}

.layer-item-icon svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    display: block;
}

.layer-item-content {
    flex: 1;
    min-width: 0;
}

.layer-item-title {
    font-size: 13px;
    font-weight: 500;
    color: var(--color-text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.layer-item-preview {
    font-size: 11px;
    color: var(--color-text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-top: 2px;
}

.layer-item-actions {
    display: flex;
    gap: 4px;
    opacity: 0;
    transition: opacity var(--transition-fast);
}

.layer-item:hover .layer-item-actions { opacity: 1; }

.layer-action-btn {
    width: 26px;
    height: 26px;
    border: none;
    border-radius: var(--radius-sm);
    background: var(--color-border-light);
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    transition: all var(--transition-fast);
}

.layer-action-btn:hover { background: var(--color-primary); }
.layer-action-btn.duplicate:hover { background: var(--color-success, #28a745); }
.layer-action-btn.delete:hover { background: var(--color-danger); }

.layers-empty {
    text-align: center;
    padding: 30px 15px;
    color: #666;
    font-size: 13px;
}

.layers-empty svg {
    margin-bottom: 10px;
    opacity: 0.5;
}

/* ==========================================================================
   Floating Page & Zoom Controls - Bottom Right
   ========================================================================== */
.page-controls {
    position: fixed;
    bottom: 24px;
    right: 24px;
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 6px 8px;
    background: linear-gradient(180deg, rgba(30, 30, 30, 0.95) 0%, rgba(20, 20, 20, 0.98) 100%);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 12px;
    box-shadow:
        0 8px 32px rgba(0, 0, 0, 0.4),
        0 2px 8px rgba(0, 0, 0, 0.3),
        inset 0 1px 0 rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(20px);
    z-index: 100;
    transition: all 0.2s ease;
}

.page-controls:hover {
    box-shadow:
        0 12px 40px rgba(0, 0, 0, 0.5),
        0 4px 12px rgba(0, 0, 0, 0.3),
        inset 0 1px 0 rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.12);
}

/* Control Groups */
.page-nav-group,
.zoom-nav-group {
    display: flex;
    align-items: center;
    gap: 2px;
}

/* Divider between groups */
.controls-divider {
    width: 1px;
    height: 24px;
    background: linear-gradient(180deg, transparent 0%, rgba(255,255,255,0.15) 50%, transparent 100%);
    margin: 0 8px;
}

/* Control Buttons */
.control-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background: transparent;
    border: none;
    border-radius: 8px;
    color: var(--color-text-secondary);
    cursor: pointer;
    transition: all 0.15s ease;
}

.control-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--color-text-primary);
    transform: scale(1.05);
}

.control-btn:active {
    transform: scale(0.95);
    background: rgba(255, 255, 255, 0.15);
}

.control-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
    transform: none;
}

.control-btn:disabled:hover {
    background: transparent;
    transform: none;
}

.control-btn svg {
    width: 16px;
    height: 16px;
}

/* Page Info Display */
.page-info {
    font-size: 12px;
    font-weight: 600;
    color: var(--color-text-secondary);
    min-width: 48px;
    text-align: center;
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.02em;
    padding: 0 4px;
}

/* Zoom controls in bottom bar - adjust dropdown position */
.page-controls .zoom-dropdown-container {
    position: relative;
}

.page-controls .zoom-dropdown-trigger {
    padding: 4px 8px;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 6px;
    min-width: auto;
}

.page-controls .zoom-dropdown-trigger:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: transparent;
    transform: none;
}

.page-controls .zoom-dropdown-container.open .zoom-dropdown-trigger {
    background: rgba(229, 9, 20, 0.15);
    border-color: rgba(229, 9, 20, 0.3);
    box-shadow: none;
}

.page-controls .zoom-display {
    font-size: 12px;
    min-width: 36px;
    font-weight: 600;
}

.page-controls .zoom-dropdown-arrow {
    width: 8px;
    height: 8px;
}

/* Dropdown opens upward from bottom bar */
.page-controls .zoom-dropdown-menu {
    bottom: calc(100% + 8px);
    top: auto;
    transform: translateX(-50%) translateY(8px) scale(0.96);
}

.page-controls .zoom-dropdown-container.open .zoom-dropdown-menu {
    transform: translateX(-50%) translateY(0) scale(1);
}

/* Responsive adjustments */
@media (max-width: 600px) {
    .page-controls {
        right: 12px;
        bottom: 12px;
        padding: 4px 6px;
        gap: 2px;
    }

    .control-btn {
        width: 28px;
        height: 28px;
    }

    .controls-divider {
        margin: 0 4px;
        height: 20px;
    }

    .page-info {
        font-size: 11px;
        min-width: 40px;
    }

    .page-controls .zoom-display {
        font-size: 11px;
        min-width: 32px;
    }
}

/* ==========================================================================
   Loading Spinner
   ========================================================================== */
.loading {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.loading-content {
    background: var(--color-bg-secondary);
    padding: 40px;
    border-radius: var(--radius-lg);
    text-align: center;
    box-shadow: var(--shadow-lg);
    animation: fadeInScale 0.3s var(--transition-normal);
    border: 1px solid var(--color-border);
}

.spinner {
    border: 5px solid rgba(229, 9, 20, 0.2);
    border-top: 5px solid var(--color-primary);
    border-radius: 50%;
    width: 60px;
    height: 60px;
    animation: spin 0.8s cubic-bezier(0.5, 0, 0.5, 1) infinite;
    margin: 0 auto 24px;
    box-shadow: 0 4px 15px var(--color-primary-light);
}

.loading-content > div:last-child {
    color: var(--color-text-primary);
    font-size: 17px;
    font-weight: 500;
}

/* ==========================================================================
   Modals
   ========================================================================== */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    display: none;
}

.modal-overlay.active { display: block; }

.custom-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 10000;
}

.custom-modal-content {
    background: var(--color-bg-secondary);
    border-radius: var(--radius-lg);
    padding: 32px;
    max-width: 440px;
    width: 90%;
    box-shadow: var(--shadow-lg);
    text-align: center;
    border: 1px solid var(--color-border);
}

.modal-icon {
    margin-bottom: 20px;
    display: flex;
    justify-content: center;
    align-items: center;
}

.modal-icon svg {
    filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.1));
}

.modal-message {
    font-size: 16px;
    line-height: 1.6;
    color: var(--color-text-primary);
    margin-bottom: 28px;
    white-space: pre-line;
}

.modal-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
}

.modal-btn {
    padding: 12px 32px;
    border: none;
    border-radius: 10px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-normal);
    min-width: 100px;
}

.modal-btn-primary {
    background: var(--color-primary);
    color: white;
    box-shadow: 0 4px 12px var(--color-primary-light);
}

.modal-btn-primary:hover {
    background: var(--color-primary-dark);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(229, 9, 20, 0.5);
}

.modal-btn-secondary {
    background: var(--color-bg-tertiary);
    color: var(--color-text-primary);
    box-shadow: var(--shadow-sm);
}

.modal-btn-secondary:hover {
    background: var(--color-bg-hover);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

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

/* Edit Modal */
.edit-modal {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: var(--color-bg-secondary);
    padding: 30px;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    z-index: 1001;
    min-width: 400px;
    display: none;
    border: 1px solid var(--color-border);
}

.edit-modal.active { display: block; }
.edit-modal h3 { margin-bottom: 15px; color: var(--color-text-primary); }

.edit-modal textarea {
    width: 100%;
    min-height: 100px;
    padding: 10px;
    border: 2px solid var(--color-primary);
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-family: Arial, sans-serif;
    resize: vertical;
    background: var(--color-bg-tertiary);
    color: var(--color-text-primary);
}

.edit-modal-actions {
    display: flex;
    gap: 10px;
    margin-top: 15px;
    justify-content: flex-end;
}

.edit-modal-btn {
    padding: 12px 24px;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    font-weight: 600;
    transition: all var(--transition-normal);
    font-size: 14px;
}

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

.edit-modal-btn.primary {
    background: var(--color-primary);
    color: white;
    box-shadow: 0 4px 12px var(--color-primary-light);
}

.edit-modal-btn.primary:hover {
    background: var(--color-primary-dark);
    box-shadow: 0 6px 18px rgba(229, 9, 20, 0.5);
}

.edit-modal-btn.secondary {
    background: var(--color-bg-tertiary);
    color: var(--color-text-primary);
    border: 2px solid var(--color-border);
}

.edit-modal-btn.secondary:hover {
    background: var(--color-bg-hover);
    border-color: var(--color-border-light);
}

/* Edit Modal Overlay (for modals like OCR results) */
.edit-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 10000;
    padding: 20px;
}

.edit-modal-overlay .edit-modal {
    position: relative;
    top: auto;
    left: auto;
    transform: none;
    display: block;
    max-height: 90vh;
    overflow-y: auto;
    animation: modalSlideIn 0.25s ease-out;
}

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

.edit-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 1px solid var(--color-border);
}

.edit-modal-header h3 {
    margin: 0;
    display: flex;
    align-items: center;
    font-size: 18px;
}

.edit-modal-body {
    margin-bottom: 20px;
}

.edit-modal-footer {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    padding-top: 15px;
    border-top: 1px solid var(--color-border);
}

.edit-modal-footer .edit-modal-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* ==========================================================================
   Signature Modal
   ========================================================================== */
.signature-modal-content {
    background: var(--color-bg-secondary);
    border-radius: var(--radius-lg);
    padding: 0;
    max-width: 600px;
    width: 90%;
    max-height: 80vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    animation: slideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    border: 1px solid var(--color-border);
}

.signature-modal-header {
    padding: 24px 24px 16px;
    border-bottom: 2px solid var(--color-border);
}

.signature-modal-header h2 {
    font-size: 24px;
    color: var(--color-text-primary);
    margin: 0;
    display: flex;
    align-items: center;
    gap: 12px;
}

.signature-tabs {
    display: flex;
    gap: 8px;
    padding: 0 24px;
    background: #0a0a0a;
}

.signature-tab {
    padding: 12px 24px;
    background: transparent;
    border: none;
    color: var(--color-text-secondary);
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    border-bottom: 3px solid transparent;
    transition: all var(--transition-fast);
}

.signature-tab:hover {
    color: var(--color-primary);
    background: rgba(229, 9, 20, 0.1);
}

.signature-tab.active {
    color: var(--color-primary);
    border-bottom-color: var(--color-primary);
    background: var(--color-bg-secondary);
}

.signature-tab-content {
    display: none;
    padding: 24px;
    flex: 1;
    overflow-y: auto;
}

.signature-tab-content.active { display: block; }

.signature-canvas-container {
    border: 2px solid var(--color-border);
    border-radius: 12px;
    overflow: hidden;
    background: white;
    box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.2);
}

#signatureCanvas {
    display: block;
    cursor: crosshair;
    touch-action: none;
}

.signature-canvas-controls {
    margin-top: 16px;
    display: flex;
    gap: 12px;
    align-items: center;
}

.signature-hint {
    color: var(--color-text-secondary);
    font-size: 14px;
}

/* Signature checkbox option - custom styled checkbox */
.signature-checkbox-option {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 16px;
    padding: 14px 16px;
    background: var(--color-bg-tertiary);
    border: 1px solid var(--color-border);
    border-radius: 10px;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.signature-checkbox-option:hover {
    border-color: var(--color-primary);
    background: rgba(229, 9, 20, 0.05);
}

.signature-checkbox-option input[type="checkbox"] {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.signature-checkbox-option .checkbox-custom {
    width: 22px;
    height: 22px;
    border: 2px solid var(--color-border);
    border-radius: 6px;
    background: var(--color-bg-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
    flex-shrink: 0;
}

.signature-checkbox-option .checkbox-custom::after {
    content: '';
    width: 12px;
    height: 12px;
    background: var(--color-primary);
    border-radius: 3px;
    opacity: 0;
    transform: scale(0);
    transition: all var(--transition-fast);
}

.signature-checkbox-option input[type="checkbox"]:checked + .checkbox-custom {
    border-color: var(--color-primary);
    background: rgba(229, 9, 20, 0.1);
}

.signature-checkbox-option input[type="checkbox"]:checked + .checkbox-custom::after {
    opacity: 1;
    transform: scale(1);
}

.signature-checkbox-option .checkbox-label {
    font-size: 14px;
    font-weight: 500;
    color: var(--color-text-primary);
}

.type-signature-input {
    width: 100%;
    padding: 16px;
    font-size: 32px;
    border: 2px solid var(--color-border);
    border-radius: 12px;
    margin-bottom: 20px;
    transition: border-color var(--transition-fast);
    background: var(--color-bg-tertiary);
    color: var(--color-text-primary);
}

.type-signature-input:focus {
    outline: none;
    border-color: var(--color-primary);
}

.font-selector {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 12px;
    margin-bottom: 20px;
}

.font-option {
    padding: 20px 16px;
    border: 2px solid var(--color-border);
    border-radius: 12px;
    background: var(--color-bg-tertiary);
    cursor: pointer;
    text-align: center;
    font-size: 24px;
    transition: all var(--transition-fast);
    color: var(--color-text-primary);
}

.font-option:hover {
    border-color: var(--color-primary);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px var(--color-primary-light);
}

.font-option.selected {
    border-color: var(--color-primary);
    background: rgba(229, 9, 20, 0.1);
}

.signature-color-picker {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 20px;
}

.signature-color-picker label {
    font-weight: 500;
    color: var(--color-text-primary);
}

.signature-color-picker input[type="color"] {
    width: 60px;
    height: 40px;
    border: 2px solid #e0e0e0;
    border-radius: var(--radius-md);
    cursor: pointer;
}

.upload-area {
    border: 3px dashed var(--color-border);
    border-radius: var(--radius-lg);
    padding: 48px 24px;
    text-align: center;
    background: #0a0a0a;
    transition: all var(--transition-normal);
    cursor: pointer;
}

.upload-area:hover {
    border-color: var(--color-primary);
    background: rgba(229, 9, 20, 0.1);
}

.upload-area.drag-over {
    border-color: var(--color-primary);
    background: rgba(229, 9, 20, 0.15);
}

.upload-icon {
    font-size: 48px;
    margin-bottom: 16px;
    color: var(--color-primary);
}

.upload-text {
    font-size: 16px;
    color: var(--color-text-secondary);
    margin-bottom: 8px;
}

.upload-hint {
    font-size: 13px;
    color: #777;
}

#signatureFileInput { display: none; }

.signature-preview-container {
    margin-top: 24px;
    display: none;
}

.signature-preview {
    max-width: 100%;
    max-height: 200px;
    border: 2px solid var(--color-border);
    border-radius: 12px;
    padding: 16px;
    background: var(--color-bg-tertiary);
}

.signature-modal-footer {
    padding: 16px 24px;
    border-top: 2px solid var(--color-border);
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    background: var(--color-bg-secondary);
}

/* ==========================================================================
   Animations
   ========================================================================== */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes fadeInScale {
    from { opacity: 0; transform: scale(0.9); }
    to { opacity: 1; transform: scale(1); }
}

@keyframes slideUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

@keyframes pulse {
    0%, 100% {
        transform: scale(1);
        box-shadow: 0 4px 12px rgba(220, 31, 38, 0.3);
    }
    50% {
        transform: scale(1.05);
        box-shadow: 0 6px 20px rgba(220, 31, 38, 0.5);
    }
}

@keyframes layerHighlight {
    0% { box-shadow: 0 0 0 3px rgba(229, 9, 20, 0.8); }
    50% { box-shadow: 0 0 0 6px rgba(229, 9, 20, 0.4); }
    100% { box-shadow: 0 0 0 3px rgba(229, 9, 20, 0.8); }
}

.layer-highlight {
    box-shadow: 0 0 0 3px rgba(229, 9, 20, 0.8) !important;
    z-index: 1000 !important;
}

/* ==========================================================================
   Overlay List (Legacy)
   ========================================================================== */
.overlay-list-item {
    padding: 10px;
    margin: 8px 0;
    background: var(--color-bg-tertiary);
    border-radius: 6px;
    cursor: pointer;
    transition: background var(--transition-fast);
    font-size: 13px;
    color: var(--color-text-primary);
}

.overlay-list-item:hover { background: var(--color-bg-hover); }

.overlay-list-item.active {
    background: rgba(229, 9, 20, 0.2);
    border: 2px solid var(--color-primary);
}

.overlay-list-item .overlay-text-preview {
    color: var(--color-text-secondary);
    font-size: 12px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-top: 4px;
}

/* ==========================================================================
   Unified Text Editor Modal
   ========================================================================== */
.unified-editor-modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(6px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    animation: fadeIn 0.2s ease-out;
}

/* ==========================================================================
   Eyedropper Active Indicator
   Best practice: When eyedropper is active, modal minimizes and clear
   instructions appear so users can pick colors from the document
   ========================================================================== */
.eyedropper-active-indicator {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%) translateY(-20px);
    z-index: 10001;
    opacity: 0;
    pointer-events: none;
    transition: all 0.2s ease-out;
}

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

.eyedropper-indicator-content {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 20px;
    background: linear-gradient(135deg, rgba(30, 30, 35, 0.95) 0%, rgba(40, 40, 45, 0.95) 100%);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    box-shadow:
        0 8px 32px rgba(0, 0, 0, 0.4),
        0 0 0 1px rgba(255, 255, 255, 0.05) inset;
    backdrop-filter: blur(20px);
    color: #ffffff;
    font-size: 14px;
    font-weight: 500;
}

.eyedropper-indicator-content svg {
    color: var(--color-primary);
    flex-shrink: 0;
}

.eyedropper-indicator-content span {
    color: #ffffff;
}

.eyedropper-indicator-content small {
    color: rgba(255, 255, 255, 0.5);
    font-size: 12px;
    margin-left: 8px;
    padding-left: 12px;
    border-left: 1px solid rgba(255, 255, 255, 0.2);
}

/* Eyedropper button styles */
.eyedropper-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    background: var(--color-bg-primary);
    color: var(--color-text-secondary);
    cursor: pointer;
    transition: all 0.15s ease;
}

.eyedropper-btn:hover:not(:disabled) {
    background: var(--color-bg-tertiary);
    border-color: var(--color-primary);
    color: var(--color-primary);
}

.eyedropper-btn:active:not(:disabled) {
    transform: scale(0.95);
}

.eyedropper-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* Color input group with eyedropper */
.color-input-group {
    display: flex;
    gap: 8px;
    align-items: center;
}

.color-input-group input[type="color"] {
    width: 60px;
    height: 36px;
    padding: 2px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    background: var(--color-bg-primary);
    cursor: pointer;
}

.color-input-group input[type="color"]::-webkit-color-swatch-wrapper {
    padding: 2px;
}

.color-input-group input[type="color"]::-webkit-color-swatch {
    border-radius: 4px;
    border: none;
}

.unified-editor-modal {
    background: var(--color-bg-secondary);
    border-radius: var(--radius-lg);
    width: 95%;
    max-width: 560px;
    max-height: 90vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    border: 1px solid var(--color-border);
    box-shadow: var(--shadow-lg);
    animation: slideUp 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Header */
.unified-editor-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    padding: 20px 24px 16px;
    border-bottom: 1px solid var(--color-border);
    background: linear-gradient(180deg, var(--color-bg-tertiary) 0%, var(--color-bg-secondary) 100%);
}

.unified-editor-title {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    flex: 1;
}

.unified-editor-title svg {
    flex-shrink: 0;
    margin-top: 2px;
}

.unified-editor-title h3 {
    font-size: 20px;
    font-weight: 600;
    color: var(--color-text-primary);
    margin: 0;
    line-height: 1.3;
}

.unified-editor-title .subtitle {
    font-size: 13px;
    color: var(--color-text-muted);
    margin: 4px 0 0;
}

.unified-editor-title .original {
    font-size: 12px;
    color: var(--color-text-muted);
    margin: 6px 0 0;
}

.unified-editor-title .original span {
    color: var(--color-text-secondary);
    font-style: italic;
}

.ocr-info {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 0;
}

.ocr-confidence {
    font-size: 12px;
    color: var(--color-success);
    background: rgba(76, 175, 80, 0.15);
    padding: 4px 10px;
    border-radius: 12px;
}

.unified-editor-close {
    background: transparent;
    border: none;
    color: var(--color-text-muted);
    cursor: pointer;
    padding: 8px;
    margin: -4px -8px 0 8px;
    border-radius: var(--radius-sm);
    transition: all var(--transition-fast);
}

.unified-editor-close:hover {
    color: var(--color-text-primary);
    background: var(--color-bg-hover);
}

/* Body */
.unified-editor-body {
    padding: 20px 24px;
    overflow-y: auto;
    flex: 1;
}

.unified-editor-field {
    margin-bottom: 20px;
}

.unified-editor-field:last-child {
    margin-bottom: 0;
}

.unified-editor-field label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--color-text-secondary);
    margin-bottom: 8px;
}

.unified-editor-field .value-display {
    color: var(--color-primary);
    font-weight: 600;
}

.unified-editor-field textarea,
.unified-editor-field .ute-rich-editor {
    width: 100%;
    min-height: 120px;
    padding: 12px 14px;
    border: 2px solid var(--color-border);
    border-radius: var(--radius-md);
    background: var(--color-bg-tertiary);
    color: var(--color-text-primary);
    font-size: 14px;
    font-family: inherit;
    line-height: 1.5;
    resize: vertical;
    transition: border-color var(--transition-fast);
    box-sizing: border-box;
    overflow-y: auto;
    max-height: 300px;
}

.unified-editor-field textarea:focus,
.unified-editor-field .ute-rich-editor:focus {
    outline: none;
    border-color: var(--color-primary);
}

.unified-editor-field textarea::placeholder,
.unified-editor-field .ute-rich-editor:empty::before {
    color: var(--color-text-muted);
}

/* Placeholder for contenteditable */
.unified-editor-field .ute-rich-editor:empty::before {
    content: attr(data-placeholder);
    pointer-events: none;
}

/* Link styling in rich editor */
.ute-rich-editor .ute-link,
.ute-rich-editor a {
    color: var(--color-primary);
    text-decoration: underline;
    cursor: pointer;
}

.ute-rich-editor .ute-link:hover,
.ute-rich-editor a:hover {
    color: var(--color-primary-dark);
    text-decoration: underline;
}

/* Link styling in text overlays on canvas */
.text-overlay .overlay-content {
    pointer-events: auto;
}

.text-overlay .overlay-link,
.text-overlay a {
    color: #0000EE;
    text-decoration: underline;
    cursor: pointer;
    pointer-events: auto;
}

.text-overlay .overlay-link:hover,
.text-overlay a:hover {
    color: #551A8B;
    text-decoration: underline;
}

.text-overlay .overlay-link:visited,
.text-overlay a:visited {
    color: #551A8B;
}

.word-count {
    font-size: 11px;
    color: var(--color-text-muted);
    text-align: right;
    margin-top: 6px;
}

/* Font Size Control */
.font-size-control {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.font-size-control input[type="range"] {
    width: 100%;
    height: 6px;
    border-radius: 3px;
    background: var(--color-bg-tertiary);
    accent-color: var(--color-primary);
    cursor: pointer;
}

.font-size-presets {
    display: flex;
    gap: 6px;
}

.font-size-preset {
    flex: 1;
    padding: 8px 0;
    background: var(--color-bg-tertiary);
    border: 1px solid var(--color-border-light);
    border-radius: var(--radius-sm);
    color: var(--color-text-secondary);
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.font-size-preset:hover {
    background: var(--color-bg-hover);
    border-color: var(--color-primary);
    color: var(--color-text-primary);
}

/* Style Controls Row */
.unified-editor-row {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 16px;
}

@media (max-width: 500px) {
    .unified-editor-row {
        grid-template-columns: 1fr 1fr;
    }
    .unified-editor-row > .unified-editor-field:last-child {
        grid-column: 1 / -1;
    }
}

.unified-editor-field input[type="color"] {
    width: 100%;
    height: 42px;
    border: 2px solid var(--color-border);
    border-radius: var(--radius-md);
    background: var(--color-bg-tertiary);
    cursor: pointer;
    padding: 2px;
    transition: border-color var(--transition-fast);
}

.unified-editor-field input[type="color"]:hover {
    border-color: var(--color-border-light);
}

.unified-editor-field input[type="color"]:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.unified-editor-field select {
    width: 100%;
    padding: 10px 12px;
    border: 2px solid var(--color-border);
    border-radius: var(--radius-md);
    background: var(--color-bg-tertiary);
    color: var(--color-text-primary);
    font-size: 13px;
    cursor: pointer;
    transition: border-color var(--transition-fast);
}

.unified-editor-field select:focus {
    outline: none;
    border-color: var(--color-primary);
}

/* Background Color Control */
.bg-color-control {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.transparent-toggle {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--color-text-muted);
    cursor: pointer;
}

.transparent-toggle input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--color-primary);
    cursor: pointer;
}

.transparent-toggle span {
    user-select: none;
}

/* Color Input Group with Eyedropper */
.color-input-group {
    display: flex;
    gap: 6px;
    align-items: stretch;
}

.color-input-group input[type="color"] {
    flex: 1;
}

.eyedropper-btn {
    width: 42px;
    height: 42px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--color-bg-tertiary);
    border: 2px solid var(--color-border);
    border-radius: var(--radius-md);
    color: var(--color-text-secondary);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.eyedropper-btn:hover:not(:disabled) {
    border-color: var(--color-primary);
    color: var(--color-primary);
    background: rgba(229, 9, 20, 0.1);
}

.eyedropper-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.eyedropper-btn svg {
    width: 18px;
    height: 18px;
}

/* Font Style Controls */
.font-style-field {
    grid-column: 1 / -1;
}

.font-style-buttons {
    display: flex;
    gap: 10px;
}

.font-style-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    border: 2px solid var(--color-border);
    border-radius: var(--radius-md);
    background: var(--color-bg-tertiary);
    color: var(--color-text-muted);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.font-style-btn:hover {
    border-color: var(--color-border-light);
    color: var(--color-text-primary);
}

.font-style-btn.active {
    border-color: var(--color-primary);
    background: rgba(229, 9, 20, 0.15);
    color: var(--color-primary);
}

.font-style-btn svg {
    flex-shrink: 0;
}

/* Footer */
.unified-editor-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 24px 20px;
    border-top: 1px solid var(--color-border);
    background: var(--color-bg-secondary);
}

.unified-editor-actions {
    display: flex;
    gap: 10px;
}

.unified-editor-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 20px;
    border-radius: var(--radius-md);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-fast);
    border: none;
}

.unified-editor-btn.secondary {
    background: var(--color-bg-tertiary);
    color: var(--color-text-primary);
    border: 2px solid var(--color-border);
}

.unified-editor-btn.secondary:hover {
    background: var(--color-bg-hover);
    border-color: var(--color-border-light);
}

.unified-editor-btn.primary {
    background: var(--color-primary);
    color: white;
    box-shadow: 0 4px 12px var(--color-primary-light);
}

.unified-editor-btn.primary:hover {
    background: var(--color-primary-dark);
}

.unified-editor-btn svg {
    flex-shrink: 0;
}

/* Insert Link Button & Dialog */
.unified-editor-field-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
}

.unified-editor-field-header label {
    margin-bottom: 0;
}

.insert-link-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: var(--color-bg-tertiary);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    color: var(--color-text-secondary);
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.insert-link-btn:hover {
    background: var(--color-bg-hover);
    border-color: var(--color-primary);
    color: var(--color-primary);
}

.insert-link-btn svg {
    flex-shrink: 0;
}

/* Link Insert Dialog */
.link-insert-dialog {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-lg);
    z-index: 10;
    animation: fadeIn 0.15s ease-out;
}

.link-dialog-content {
    background: var(--color-bg-secondary);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    width: 90%;
    max-width: 400px;
    box-shadow: var(--shadow-lg);
    animation: slideUp 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.link-dialog-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 16px;
    border-bottom: 1px solid var(--color-border);
    background: var(--color-bg-tertiary);
    border-radius: var(--radius-md) var(--radius-md) 0 0;
}

.link-dialog-header svg {
    color: var(--color-primary);
    flex-shrink: 0;
}

.link-dialog-header span {
    flex: 1;
    font-size: 14px;
    font-weight: 600;
    color: var(--color-text-primary);
}

.link-dialog-close {
    background: transparent;
    border: none;
    color: var(--color-text-muted);
    cursor: pointer;
    padding: 4px;
    border-radius: var(--radius-sm);
    transition: all var(--transition-fast);
}

.link-dialog-close:hover {
    color: var(--color-text-primary);
    background: var(--color-bg-hover);
}

.link-dialog-body {
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.link-dialog-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.link-dialog-field label {
    font-size: 12px;
    font-weight: 500;
    color: var(--color-text-secondary);
}

.link-dialog-field input {
    padding: 10px 12px;
    border: 2px solid var(--color-border);
    border-radius: var(--radius-md);
    background: var(--color-bg-tertiary);
    color: var(--color-text-primary);
    font-size: 14px;
    transition: border-color var(--transition-fast);
}

.link-dialog-field input:focus {
    outline: none;
    border-color: var(--color-primary);
}

.link-dialog-field input::placeholder {
    color: var(--color-text-muted);
}

.link-dialog-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 12px 16px;
    border-top: 1px solid var(--color-border);
}

.link-dialog-footer .unified-editor-btn {
    padding: 10px 16px;
    font-size: 13px;
}

/* ==========================================================================
   Annotation Style Panel
   ========================================================================== */
.annotation-style-panel {
    position: fixed;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: var(--color-bg-secondary);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: 16px 20px;
    box-shadow: var(--shadow-lg);
    z-index: 1000;
    display: none;
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.annotation-style-panel.visible {
    display: flex;
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.annotation-style-panel-inner {
    display: flex;
    align-items: center;
    gap: 20px;
}

.style-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.style-group-label {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--color-text-muted);
}

.style-group-content {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Color Picker Styles */
.style-color-picker {
    width: 36px;
    height: 36px;
    border: 2px solid var(--color-border);
    border-radius: var(--radius-md);
    cursor: pointer;
    padding: 0;
    background: none;
    transition: all var(--transition-fast);
}

.style-color-picker:hover {
    border-color: var(--color-primary);
    transform: scale(1.05);
}

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

.style-color-picker::-webkit-color-swatch {
    border: none;
    border-radius: 4px;
}

/* Fill Toggle Button */
.style-fill-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border: 2px solid var(--color-border);
    border-radius: var(--radius-md);
    background: var(--color-bg-tertiary);
    cursor: pointer;
    transition: all var(--transition-fast);
    color: var(--color-text-secondary);
}

.style-fill-toggle:hover {
    border-color: var(--color-border-light);
    background: var(--color-bg-hover);
}

.style-fill-toggle.active {
    border-color: var(--color-primary);
    background: rgba(229, 9, 20, 0.15);
    color: var(--color-primary);
}

/* Opacity Slider */
.style-opacity-container {
    display: flex;
    align-items: center;
    gap: 8px;
}

.style-slider {
    -webkit-appearance: none;
    appearance: none;
    width: 80px;
    height: 6px;
    border-radius: 3px;
    background: var(--color-bg-tertiary);
    outline: none;
    cursor: pointer;
}

.style-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--color-primary);
    cursor: pointer;
    transition: transform var(--transition-fast);
    box-shadow: 0 2px 6px rgba(229, 9, 20, 0.4);
}

.style-slider::-webkit-slider-thumb:hover {
    transform: scale(1.15);
}

.style-slider::-moz-range-thumb {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--color-primary);
    cursor: pointer;
    border: none;
}

.style-value {
    font-size: 12px;
    font-weight: 600;
    color: var(--color-text-primary);
    min-width: 36px;
    text-align: center;
    background: var(--color-bg-tertiary);
    padding: 4px 8px;
    border-radius: var(--radius-sm);
}

/* Line Style Buttons */
.style-line-options {
    display: flex;
    gap: 4px;
}

.style-line-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border: 2px solid var(--color-border);
    border-radius: var(--radius-md);
    background: var(--color-bg-tertiary);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.style-line-btn:hover {
    border-color: var(--color-border-light);
    background: var(--color-bg-hover);
}

.style-line-btn.active {
    border-color: var(--color-primary);
    background: rgba(229, 9, 20, 0.15);
}

.style-line-btn svg {
    color: var(--color-text-secondary);
}

.style-line-btn.active svg {
    color: var(--color-primary);
}

/* Size Controls */
.style-size-container {
    display: flex;
    align-items: center;
    gap: 8px;
}

.style-size-slider {
    -webkit-appearance: none;
    appearance: none;
    width: 100px;
    height: 6px;
    border-radius: 3px;
    background: linear-gradient(to right, var(--color-bg-tertiary) 0%, var(--color-primary) 100%);
    outline: none;
    cursor: pointer;
}

.style-size-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: white;
    cursor: pointer;
    border: 3px solid var(--color-primary);
    transition: transform var(--transition-fast);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.style-size-slider::-webkit-slider-thumb:hover {
    transform: scale(1.1);
}

.style-size-slider::-moz-range-thumb {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: white;
    cursor: pointer;
    border: 3px solid var(--color-primary);
}

/* Divider */
.style-divider {
    width: 1px;
    height: 40px;
    background: var(--color-border);
}

/* Panel Close Button */
.style-panel-close {
    position: absolute;
    top: -10px;
    right: -10px;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--color-bg-tertiary);
    border: 2px solid var(--color-border);
    color: var(--color-text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
}

.style-panel-close:hover {
    background: var(--color-primary);
    border-color: var(--color-primary);
    color: white;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .annotation-style-panel {
        bottom: 100px;
        padding: 12px 16px;
        max-width: calc(100vw - 32px);
    }

    .annotation-style-panel-inner {
        flex-wrap: wrap;
        gap: 12px;
    }

    .style-slider,
    .style-size-slider {
        width: 60px;
    }

    .style-divider {
        display: none;
    }
}

/* ==========================================================================
   Custom Context Menu
   ========================================================================== */
.context-menu {
    position: fixed;
    z-index: 10000;
    min-width: 200px;
    max-width: 280px;
    background: linear-gradient(180deg, rgba(32, 32, 32, 0.98) 0%, rgba(24, 24, 24, 0.99) 100%);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    box-shadow:
        0 20px 60px rgba(0, 0, 0, 0.5),
        0 8px 24px rgba(0, 0, 0, 0.4),
        inset 0 1px 0 rgba(255, 255, 255, 0.06);
    backdrop-filter: blur(20px);
    padding: 6px;
    opacity: 0;
    visibility: hidden;
    transform: scale(0.95) translateY(-4px);
    transition: all 0.15s cubic-bezier(0.4, 0, 0.2, 1);
    transform-origin: top left;
}

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

.context-menu.origin-bottom-left {
    transform-origin: bottom left;
}

.context-menu.origin-top-right {
    transform-origin: top right;
}

.context-menu.origin-bottom-right {
    transform-origin: bottom right;
}

/* Menu Header */
.context-menu-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    margin-bottom: 4px;
}

.context-menu-header-icon {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--color-primary) 0%, #b30710 100%);
    border-radius: 8px;
    color: white;
}

.context-menu-header-icon svg {
    width: 16px;
    height: 16px;
}

.context-menu-header-text {
    flex: 1;
}

.context-menu-header-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--color-text-primary);
    line-height: 1.2;
}

.context-menu-header-subtitle {
    font-size: 11px;
    color: var(--color-text-muted);
    margin-top: 2px;
}

/* Menu Items */
.context-menu-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 10px 12px;
    background: transparent;
    border: none;
    border-radius: 8px;
    color: var(--color-text-secondary);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.12s ease;
    text-align: left;
    position: relative;
}

.context-menu-item:hover {
    background: rgba(255, 255, 255, 0.08);
    color: var(--color-text-primary);
}

.context-menu-item:active {
    background: rgba(255, 255, 255, 0.12);
    transform: scale(0.98);
}

.context-menu-item.danger {
    color: #f87171;
}

.context-menu-item.danger:hover {
    background: rgba(248, 113, 113, 0.15);
    color: #fca5a5;
}

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

.context-menu-item.primary:hover {
    background: rgba(229, 9, 20, 0.15);
    color: #ff4d5a;
}

.context-menu-item:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    pointer-events: none;
}

.context-menu-item-icon {
    width: 18px;
    height: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.7;
    flex-shrink: 0;
}

.context-menu-item:hover .context-menu-item-icon {
    opacity: 1;
}

.context-menu-item-icon svg {
    width: 16px;
    height: 16px;
}

.context-menu-item-label {
    flex: 1;
}

.context-menu-item-shortcut {
    font-size: 11px;
    color: var(--color-text-muted);
    opacity: 0.6;
    font-family: var(--font-mono);
    padding: 2px 6px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 4px;
}

/* Divider */
.context-menu-divider {
    height: 1px;
    background: linear-gradient(90deg, transparent 0%, rgba(255, 255, 255, 0.1) 20%, rgba(255, 255, 255, 0.1) 80%, transparent 100%);
    margin: 6px 0;
}

/* Submenu indicator */
.context-menu-item-arrow {
    width: 12px;
    height: 12px;
    opacity: 0.5;
}

.context-menu-item:hover .context-menu-item-arrow {
    opacity: 1;
}

/* Group Label */
.context-menu-group-label {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--color-text-muted);
    padding: 8px 12px 4px;
    opacity: 0.6;
}

/* Responsive */
@media (max-width: 480px) {
    .context-menu {
        min-width: 180px;
        padding: 4px;
    }

    .context-menu-item {
        padding: 8px 10px;
        font-size: 12px;
    }

    .context-menu-item-shortcut {
        display: none;
    }
}

/* ==========================================================================
   Upgrade Modal (Pro Upsell)
   ========================================================================== */
.upgrade-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(8px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    animation: fadeIn 0.2s ease-out;
}

.upgrade-modal.active {
    display: flex;
}

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

.upgrade-modal-content {
    background: linear-gradient(135deg, #1a1a1a 0%, #0d0d0d 100%);
    border-radius: 20px;
    padding: 40px;
    max-width: 460px;
    width: 90%;
    box-shadow: 0 25px 80px rgba(0, 0, 0, 0.8), 0 0 0 1px rgba(229, 9, 20, 0.2);
    position: relative;
    animation: slideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.upgrade-modal-close {
    position: absolute;
    top: 16px;
    right: 16px;
    width: 36px;
    height: 36px;
    border: none;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    color: #888;
}

.upgrade-modal-close:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    transform: scale(1.05);
}

.upgrade-modal-icon {
    width: 64px;
    height: 64px;
    background: linear-gradient(135deg, rgba(229, 9, 20, 0.2) 0%, rgba(229, 9, 20, 0.05) 100%);
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 24px;
    border: 1px solid rgba(229, 9, 20, 0.3);
}

.upgrade-modal-icon svg {
    width: 32px;
    height: 32px;
    color: var(--color-primary);
}

.upgrade-modal-title {
    font-size: 26px;
    font-weight: 700;
    color: #ffffff;
    text-align: center;
    margin-bottom: 12px;
    letter-spacing: -0.5px;
}

.upgrade-modal-subtitle {
    font-size: 15px;
    color: #888;
    text-align: center;
    margin-bottom: 28px;
    line-height: 1.5;
}

.upgrade-modal-features {
    background: rgba(255, 255, 255, 0.03);
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 28px;
    border: 1px solid rgba(255, 255, 255, 0.06);
}

.upgrade-modal-feature {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.upgrade-modal-feature:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.upgrade-modal-feature:first-child {
    padding-top: 0;
}

.upgrade-modal-feature-icon {
    width: 24px;
    height: 24px;
    background: rgba(76, 175, 80, 0.15);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.upgrade-modal-feature-icon svg {
    width: 14px;
    height: 14px;
    color: #4CAF50;
}

.upgrade-modal-feature-text {
    font-size: 14px;
    color: #ccc;
}

.upgrade-modal-feature-text strong {
    color: #fff;
}

.upgrade-modal-cta {
    width: 100%;
    padding: 16px 24px;
    background: linear-gradient(135deg, #E50914 0%, #B8070F 100%);
    color: white;
    border: none;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    box-shadow: 0 4px 20px rgba(229, 9, 20, 0.4);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.upgrade-modal-cta:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 30px rgba(229, 9, 20, 0.5);
}

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

.upgrade-modal-price {
    font-size: 14px;
    font-weight: 400;
    opacity: 0.9;
}

.upgrade-modal-secondary {
    width: 100%;
    padding: 14px;
    background: transparent;
    color: #888;
    border: none;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s ease;
    margin-top: 12px;
    text-decoration: underline;
    text-underline-offset: 3px;
}

.upgrade-modal-secondary:hover {
    color: #fff;
}

/* Responsive adjustments */
@media (max-width: 480px) {
    .upgrade-modal-content {
        padding: 28px 20px;
        margin: 16px;
    }

    .upgrade-modal-title {
        font-size: 22px;
    }

    .upgrade-modal-icon {
        width: 56px;
        height: 56px;
    }

    .upgrade-modal-icon svg {
        width: 28px;
        height: 28px;
    }
}

/* ==========================================================================
   Mobile & Tablet Responsive Design
   ========================================================================== */

/* Mobile Notification Banner */
.mobile-notification {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 10001;
    background: linear-gradient(135deg, #1a1a1a 0%, #2a2a2a 100%);
    border-bottom: 2px solid var(--color-primary);
    padding: 12px 16px;
    animation: slideDown 0.3s ease-out;
}

@keyframes slideDown {
    from { transform: translateY(-100%); }
    to { transform: translateY(0); }
}

.mobile-notification-content {
    display: flex;
    align-items: center;
    gap: 12px;
    max-width: 100%;
}

.mobile-notification-icon {
    flex-shrink: 0;
    width: 32px;
    height: 32px;
    background: var(--color-primary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.mobile-notification-icon svg {
    width: 18px;
    height: 18px;
    fill: white;
}

.mobile-notification-text {
    flex: 1;
    font-size: 13px;
    line-height: 1.4;
    color: var(--color-text-secondary);
}

.mobile-notification-text strong {
    color: var(--color-text-primary);
    display: block;
    margin-bottom: 2px;
}

.mobile-notification-close {
    flex-shrink: 0;
    background: transparent;
    border: none;
    color: var(--color-text-muted);
    padding: 8px;
    cursor: pointer;
    border-radius: 50%;
    transition: all var(--transition-fast);
}

.mobile-notification-close:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--color-text-primary);
}

/* Mobile Menu Toggle Button */
.mobile-menu-toggle {
    display: none;
    background: transparent;
    border: none;
    color: var(--color-text-primary);
    padding: 8px;
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: all var(--transition-fast);
}

.mobile-menu-toggle:hover {
    background: rgba(255, 255, 255, 0.1);
}

.mobile-menu-toggle svg {
    width: 24px;
    height: 24px;
}

/* Mobile Tool FAB (Floating Action Button) */
.mobile-tool-fab {
    display: none;
    position: fixed;
    bottom: 80px;
    right: 16px;
    z-index: 999;
    width: 56px;
    height: 56px;
    background: var(--color-primary);
    border: none;
    border-radius: 50%;
    color: white;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(229, 9, 20, 0.4);
    transition: all var(--transition-normal);
}

.mobile-tool-fab:hover,
.mobile-tool-fab:active {
    transform: scale(1.1);
    box-shadow: 0 6px 25px rgba(229, 9, 20, 0.5);
}

.mobile-tool-fab svg {
    width: 24px;
    height: 24px;
}

/* Mobile Tool Drawer (Bottom Sheet) */
.mobile-tool-drawer {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 10000;
    background: var(--color-bg-primary);
    border-top-left-radius: 20px;
    border-top-right-radius: 20px;
    box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.5);
    transform: translateY(100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    max-height: 70vh;
    overflow-y: auto;
}

.mobile-tool-drawer.open {
    transform: translateY(0);
}

.mobile-tool-drawer-handle {
    width: 40px;
    height: 4px;
    background: var(--color-border);
    border-radius: 2px;
    margin: 12px auto;
}

.mobile-tool-drawer-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px 16px;
    border-bottom: 1px solid var(--color-border);
}

.mobile-tool-drawer-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--color-text-primary);
}

.mobile-tool-drawer-close {
    background: transparent;
    border: none;
    color: var(--color-text-muted);
    padding: 8px;
    cursor: pointer;
    border-radius: 50%;
}

.mobile-tool-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    padding: 20px;
}

.mobile-tool-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 12px 8px;
    background: var(--color-bg-secondary);
    border: 1px solid transparent;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-fast);
    min-height: 72px;
}

.mobile-tool-item:active {
    transform: scale(0.95);
}

.mobile-tool-item.active {
    background: rgba(229, 9, 20, 0.15);
    border-color: var(--color-primary);
}

.mobile-tool-item svg {
    width: 24px;
    height: 24px;
    color: var(--color-text-secondary);
}

.mobile-tool-item.active svg {
    color: var(--color-primary);
}

.mobile-tool-item span {
    font-size: 10px;
    color: var(--color-text-muted);
    text-align: center;
    line-height: 1.2;
}

/* Mobile Sidebar Drawer */
.sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    z-index: 9998;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.sidebar-backdrop.visible {
    opacity: 1;
}

/* Mobile Page Controls (Bottom Bar) */
.mobile-page-bar {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 998;
    background: var(--color-bg-primary);
    border-top: 1px solid var(--color-border);
    padding: 8px 16px;
    padding-bottom: max(8px, env(safe-area-inset-bottom));
}

.mobile-page-bar-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.mobile-page-btn {
    background: var(--color-bg-tertiary);
    border: none;
    color: var(--color-text-primary);
    width: 44px;
    height: 44px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.mobile-page-btn:active {
    background: var(--color-bg-hover);
    transform: scale(0.95);
}

.mobile-page-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.mobile-page-info {
    flex: 1;
    text-align: center;
    font-size: 14px;
    color: var(--color-text-secondary);
}

.mobile-page-info strong {
    color: var(--color-text-primary);
}

.mobile-zoom-controls {
    display: flex;
    gap: 4px;
}

/* Touch-friendly canvas interactions */
canvas {
    touch-action: none;
}

.signature-element,
.text-overlay,
.annotation-element {
    touch-action: none;
    -webkit-user-select: none;
    user-select: none;
}

/* Larger touch targets for resize handles */
.resize-handle {
    min-width: 24px;
    min-height: 24px;
}

/* ==========================================================================
   Tablet Breakpoint (768px - 992px)
   ========================================================================== */
@media (max-width: 992px) {
    .header {
        padding: 16px 24px;
    }

    .header h1 {
        font-size: 28px;
    }

    .header-btn {
        padding: 10px 18px;
        font-size: 14px;
    }

    .canvas-container {
        padding: 30px;
    }

    .sidebar {
        width: 280px;
        padding: 20px;
    }

    .tool-group {
        padding: 6px 8px;
    }
}

/* ==========================================================================
   Tablet Portrait & Large Phone Breakpoint (768px)
   ========================================================================== */
@media (max-width: 768px) {
    /* Show mobile notification */
    .mobile-notification {
        display: block;
    }

    body.notification-dismissed .mobile-notification {
        display: none;
    }

    /* =======================================================================
       MOBILE HEADER - Professional UI/UX Design
       Following Apple HIG & Material Design principles
       ======================================================================= */

    .header {
        padding: 8px 12px;
        flex-wrap: nowrap;
        gap: 0;
        height: 56px;
        background: linear-gradient(180deg, #1a1a1a 0%, #0d0d0d 100%);
        border-bottom: 1px solid rgba(255,255,255,0.08);
    }

    /* Logo - Compact on mobile */
    .header h1 {
        font-size: 18px;
        gap: 6px;
        flex: 1;
        justify-content: flex-start;
        margin-left: 8px;
    }

    .header h1 svg {
        width: 24px;
        height: 24px;
    }

    /* Hide text on small screens, keep icon */
    .header h1 span:not(:first-child) {
        display: none;
    }

    /* Header Actions - Icon buttons only */
    .header-actions {
        display: flex;
        align-items: center;
        gap: 4px;
    }

    /* Hide ALL default header buttons on mobile */
    .header-btn {
        display: none !important;
    }

    /* Mobile Action Buttons - Icon only, 44px touch targets */
    .header-btn.primary,
    .header-btn.header-btn-share,
    .header-btn.header-btn-sign,
    .header-btn.header-btn-remove {
        display: flex !important;
        align-items: center;
        justify-content: center;
        width: 44px;
        height: 44px;
        padding: 0;
        border-radius: 12px;
        font-size: 0; /* Hide text */
        background: rgba(255,255,255,0.08);
        border: 1px solid rgba(255,255,255,0.12);
        transition: all 0.2s ease;
    }

    .header-btn.primary svg,
    .header-btn.header-btn-share svg,
    .header-btn.header-btn-sign svg,
    .header-btn.header-btn-remove svg {
        margin: 0 !important;
        width: 22px;
        height: 22px;
    }

    /* Sign Button - Secondary style */
    .header-btn.header-btn-sign {
        background: rgba(229, 9, 20, 0.15);
        border-color: rgba(229, 9, 20, 0.3);
    }

    .header-btn.header-btn-sign:active {
        background: rgba(229, 9, 20, 0.3);
        transform: scale(0.95);
    }

    /* Remove Button - Subtle warning style */
    .header-btn.header-btn-remove {
        background: rgba(85, 85, 85, 0.3);
        border-color: rgba(85, 85, 85, 0.5);
    }

    .header-btn.header-btn-remove:active {
        background: rgba(220, 38, 38, 0.4);
        transform: scale(0.95);
    }

    /* Share Button - Secondary style */
    .header-btn.header-btn-share {
        padding-right: 0;
    }

    .header-btn.header-btn-share:active {
        background: rgba(255,255,255,0.15);
        transform: scale(0.95);
    }

    /* Hide PRO badge on mobile */
    .header-btn.header-btn-share .header-pro-badge {
        display: none;
    }

    /* Save Button - Primary action, prominent */
    .header-btn.primary {
        background: linear-gradient(135deg, #E50914 0%, #B8070F 100%);
        border: none;
        box-shadow: 0 2px 8px rgba(229, 9, 20, 0.4);
    }

    .header-btn.primary:active {
        background: linear-gradient(135deg, #ff1a1a 0%, #E50914 100%);
        transform: scale(0.95);
    }

    .header-btn.primary svg path {
        stroke: white;
    }

    /* Mobile Menu Toggle - Clean hamburger */
    .mobile-menu-toggle {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 44px;
        height: 44px;
        padding: 0;
        background: transparent;
        border: none;
        border-radius: 12px;
        cursor: pointer;
        transition: all 0.2s ease;
    }

    .mobile-menu-toggle:active {
        background: rgba(255,255,255,0.1);
        transform: scale(0.95);
    }

    .mobile-menu-toggle svg {
        width: 24px;
        height: 24px;
        color: #fff;
    }

    /* Hide toolbar completely on mobile */
    .toolbar {
        display: none !important;
    }

    /* Enlarge canvas/preview area - full height */
    .main-content {
        height: calc(100vh - 56px);
    }

    .canvas-container {
        padding: 8px;
        height: 100%;
        overflow: auto;
        -webkit-overflow-scrolling: touch;
        touch-action: pan-x pan-y;
    }

    /* PDF viewer touch behavior - allow panning and pinch-zoom */
    .pdf-viewer {
        touch-action: manipulation;
    }

    .pdf-page-canvas {
        max-width: 100%;
        height: auto;
    }

    /* Prevent text selection during touch */
    .canvas-container * {
        -webkit-user-select: none;
        user-select: none;
    }

    /* Sidebar becomes drawer */
    .sidebar {
        position: fixed;
        top: 0;
        right: 0;
        bottom: 0;
        width: 300px;
        max-width: 85vw;
        z-index: 9999;
        transform: translateX(100%);
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        padding-top: 60px;
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .sidebar-backdrop {
        display: block;
        pointer-events: none;
    }

    .sidebar-backdrop.visible {
        pointer-events: auto;
    }

    /* Show close button in sidebar on mobile */
    .sidebar-close-btn {
        display: flex;
        position: absolute;
        top: 12px;
        right: 12px;
        background: var(--color-bg-tertiary);
        border: none;
        color: var(--color-text-primary);
        width: 36px;
        height: 36px;
        border-radius: 50%;
        align-items: center;
        justify-content: center;
        cursor: pointer;
        z-index: 10;
    }

    /* Canvas adjustments */
    .canvas-container {
        padding: 20px;
    }

    /* Show mobile page bar */
    .mobile-page-bar {
        display: block;
    }

    /* Hide desktop page controls */
    .page-controls {
        display: none;
    }

    /* Show mobile FAB */
    .mobile-tool-fab {
        display: flex;
        align-items: center;
        justify-content: center;
    }

    /* Modal adjustments */
    .modal-content,
    .share-modal-content {
        margin: 16px;
        max-width: calc(100vw - 32px);
        max-height: calc(100vh - 32px);
    }

    /* Signature modal */
    .signature-tabs {
        flex-wrap: wrap;
    }

    #signatureCanvas {
        width: 100% !important;
        height: 150px !important;
    }

    /* Layers panel */
    .layers-list {
        max-height: 250px;
    }

    /* Empty state */
    .empty-state-logo svg {
        width: 60px;
        height: 60px;
    }

    .empty-state-title {
        font-size: 28px;
    }

    .empty-state-subtitle {
        font-size: 16px;
    }

    .empty-state-features {
        gap: 16px;
    }

    .feature-card {
        padding: 16px;
    }
}

/* ==========================================================================
   Large Phone Breakpoint (600px)
   ========================================================================== */
@media (max-width: 600px) {
    /* More compact header on smaller phones */
    .header {
        padding: 6px 8px;
        height: 52px;
    }

    .header h1 {
        font-size: 16px;
        margin-left: 4px;
    }

    .header h1 svg {
        width: 22px;
        height: 22px;
    }

    /* Slightly smaller action buttons */
    .header-btn.primary,
    .header-btn.header-btn-share,
    .header-btn.header-btn-sign,
    .header-btn.header-btn-remove {
        width: 40px;
        height: 40px;
        border-radius: 10px;
    }

    .header-btn.primary svg,
    .header-btn.header-btn-share svg,
    .header-btn.header-btn-sign svg,
    .header-btn.header-btn-remove svg {
        width: 20px;
        height: 20px;
    }

    .mobile-menu-toggle {
        width: 40px;
        height: 40px;
    }

    .mobile-menu-toggle svg {
        width: 22px;
        height: 22px;
    }

    .header-actions {
        gap: 3px;
    }

    /* Adjust main content for smaller header */
    .main-content {
        height: calc(100vh - 52px);
    }

    /* Canvas adjustments */
    .canvas-container {
        padding: 6px;
    }

    .pdf-viewer {
        border-radius: var(--radius-sm);
    }

    /* Tool drawer enabled */
    .mobile-tool-drawer {
        display: block;
    }

    /* Modal full-screen on mobile */
    .modal-content,
    .share-modal-content,
    .upgrade-modal-content {
        margin: 0;
        max-width: 100%;
        max-height: 100%;
        height: 100%;
        border-radius: 0;
    }

    .modal-header,
    .share-modal-header {
        padding: 16px;
    }

    .modal-body {
        padding: 16px;
    }

    /* Empty state adjustments */
    .empty-state-title {
        font-size: 24px;
    }

    .empty-state-features {
        flex-direction: column;
    }

    .feature-card {
        padding: 14px;
    }

    .upload-zone {
        padding: 30px 20px;
    }

    /* Annotation panel */
    .annotation-style-panel {
        left: 8px;
        right: 8px;
        bottom: 80px;
        padding: 10px 14px;
    }

    /* Context menu */
    .context-menu {
        max-width: calc(100vw - 32px);
    }
}

/* ==========================================================================
   Medium Phone Breakpoint (480px)
   ========================================================================== */
@media (max-width: 480px) {
    /* Minimal header */
    .header {
        padding: 8px 12px;
    }

    .header h1 {
        font-size: 18px;
        letter-spacing: 1px;
    }

    .header-btn {
        padding: 6px 10px;
        font-size: 11px;
    }

    .header-btn span:not(.header-pro-badge) {
        display: none;
    }

    .header-btn svg {
        margin: 0;
    }

    /* Toolbar scroll */
    .toolbar {
        padding: 6px 8px;
        gap: 4px;
    }

    .tool-group {
        padding: 4px 6px;
    }

    .tool-group-label {
        display: none;
    }

    .tool-btn {
        min-width: 44px;
        min-height: 44px;
    }

    /* Canvas minimal padding */
    .canvas-container {
        padding: 8px;
    }

    /* Sidebar full width */
    .sidebar {
        width: 100%;
        max-width: 100%;
    }

    /* Mobile tool grid 3 columns */
    .mobile-tool-grid {
        grid-template-columns: repeat(3, 1fr);
        padding: 16px;
        gap: 6px;
    }

    .mobile-tool-item {
        padding: 10px 6px;
        min-height: 64px;
    }

    /* Signature canvas smaller */
    #signatureCanvas {
        height: 120px !important;
    }

    /* Empty state compact */
    .empty-state-logo svg {
        width: 48px;
        height: 48px;
    }

    .empty-state-title {
        font-size: 20px;
    }

    .empty-state-subtitle {
        font-size: 14px;
        padding: 0 16px;
    }

    .upload-zone {
        padding: 24px 16px;
    }

    .upload-zone-icon svg {
        width: 40px;
        height: 40px;
    }
}

/* ==========================================================================
   Small Phone Breakpoint (360px)
   ========================================================================== */
@media (max-width: 360px) {
    .header h1 {
        font-size: 16px;
    }

    .header h1 svg {
        width: 20px;
        height: 20px;
    }

    .header-btn {
        padding: 6px 8px;
    }

    .mobile-tool-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 4px;
        padding: 12px;
    }

    .mobile-tool-item {
        padding: 8px 4px;
        min-height: 56px;
    }

    .mobile-tool-item svg {
        width: 20px;
        height: 20px;
    }

    .mobile-tool-item span {
        font-size: 9px;
    }

    .empty-state-title {
        font-size: 18px;
    }
}

/* ==========================================================================
   Landscape Orientation on Mobile
   ========================================================================== */
@media (max-height: 500px) and (orientation: landscape) {
    .header {
        padding: 6px 16px;
    }

    .header h1 {
        font-size: 18px;
    }

    .toolbar {
        padding: 4px 12px;
    }

    .canvas-container {
        padding: 8px;
    }

    .mobile-page-bar {
        padding: 4px 12px;
    }

    .mobile-tool-fab {
        bottom: 60px;
        width: 48px;
        height: 48px;
    }

    .mobile-tool-drawer {
        max-height: 60vh;
    }

    /* Signature modal landscape */
    #signatureCanvas {
        height: 100px !important;
    }
}

/* ==========================================================================
   Safe Area Insets (Notch Support)
   ========================================================================== */
@supports (padding: env(safe-area-inset-top)) {
    .header {
        padding-top: max(12px, env(safe-area-inset-top));
        padding-left: max(16px, env(safe-area-inset-left));
        padding-right: max(16px, env(safe-area-inset-right));
    }

    .mobile-page-bar {
        padding-bottom: max(8px, env(safe-area-inset-bottom));
        padding-left: max(16px, env(safe-area-inset-left));
        padding-right: max(16px, env(safe-area-inset-right));
    }

    .mobile-tool-drawer {
        padding-bottom: env(safe-area-inset-bottom);
    }

    .sidebar {
        padding-bottom: env(safe-area-inset-bottom);
    }
}

/* ==========================================================================
   High DPI / Retina Displays
   ========================================================================== */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .pdf-viewer {
        image-rendering: -webkit-optimize-contrast;
    }
}

/* ==========================================================================
   Reduced Motion
   ========================================================================== */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }

    .mobile-tool-drawer,
    .sidebar {
        transition: none;
    }
}

/* ==========================================================================
   Print Styles
   ========================================================================== */
@media print {
    .header,
    .toolbar,
    .sidebar,
    .mobile-notification,
    .mobile-tool-fab,
    .mobile-page-bar,
    .page-controls {
        display: none !important;
    }

    .canvas-container {
        padding: 0;
        overflow: visible;
    }

    .pdf-viewer {
        box-shadow: none;
        border-radius: 0;
    }
}
