:root {
    --glass-bg: rgba(255, 255, 255, 0.1);
    --glass-border: rgba(255, 255, 255, 0.2);
    --glass-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.37);
    --text-main: #ffffff;
    --text-muted: #e0e0e0;
    --accent-color: #e6e914;
    /* Vibrant pink/red */
    --accent-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --font-heading: 'Outfit', sans-serif;
    --font-body: 'Poppins', sans-serif;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* Visibility Helper */
.mobile-only {
    display: none !important;
}

body {
    font-family: var(--font-body);
    color: var(--text-main);
    background: #0f0c29;
    /* Fallback */
    overflow-x: hidden;
    overflow-y: auto;
    min-height: 100vh;
}

/* Background Mesh Gradients */
.background-mesh {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: -1;
    overflow: hidden;
    background: linear-gradient(45deg, #1cb5e0 0%, #000046 100%);
}

.mesh-1,
.mesh-2,
.mesh-3 {
    position: absolute;
    filter: blur(80px);
    opacity: 0.6;
    animation: float 10s infinite ease-in-out;
}

.mesh-1 {
    width: 600px;
    height: 600px;
    background: #2a2b35;
    top: -100px;
    left: -100px;
    border-radius: 50%;
}

.mesh-2 {
    width: 500px;
    height: 500px;
    background: #14b783;
    bottom: -100px;
    right: -50px;
    border-radius: 50%;
    animation-delay: 2s;
}

.mesh-3 {
    width: 300px;
    height: 300px;
    background: #c34213;
    top: 40%;
    left: 40%;
    border-radius: 50%;
    animation-delay: 4s;
}

@keyframes float {
    0% {
        transform: translate(0, 0);
    }

    50% {
        transform: translate(30px, 50px) scale(1.1);
    }

    100% {
        transform: translate(0, 0);
    }
}

.app-container {
    display: flex;
    min-height: 100vh;
    width: 100vw;
    backdrop-filter: blur(5px);
    flex-direction: column;
}

/* --- Full Width Layout (No Sidebar) --- */
.glass-content.full-width {
    padding-top: 80px;
    /* Space for Header */
    padding-bottom: 50px;
    width: 100vw;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    /* Center horizontally */
    justify-content: flex-start;
    /* Start from top */
    overflow-y: auto;
}

.main-header {
    position: absolute;
    top: 20px;
    left: 40px;
    /* Symmetrical padding */
    z-index: 10;
}

/* ... existing styles ... */

/* --- Home Dashboard --- */
.home-grid {
    display: flex;
    flex-wrap: wrap;
    /* Allow wrapping */
    gap: 30px;
    /* Reduced gap from 40px */
    padding: 2rem;
    max-width: 1200px;
    /* Limit width for symmetry */
    justify-content: center;
    /* Center grid items */
    margin: 0 auto;
    /* Center container */
}

.tool-card.large {
    width: 250px;
    /* Slightly smaller cards */
    height: 250px;
    /* ... keep other styles ... */
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    font-size: 1.1rem;
    background: rgba(20, 20, 35, 0.6);
    /* Darker background for contrast */
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 20px;
    transition: all 0.3s ease;
    cursor: pointer;
}

.tool-card.large:hover {
    background: rgba(255, 255, 255, 0.15);
    transform: translateY(-5px);
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.2);
}


/* --- Whiteout Element --- */
.whiteout-element {
    position: absolute;
    background: #fff;
    border: 1px dashed #ccc;
    z-index: 15;
    cursor: move;
}

/* --- Edge Crop Elements --- */
.crop-overlay {
    position: absolute;
    background: rgba(0, 0, 0, 0.5);
    z-index: 50;
    pointer-events: none;
    /* Let clicks pass through except on handles */
}

/* 4 Handles: Top, Bottom, Left, Right */
.crop-handle-bar {
    position: absolute;
    background: #ff0076;
    z-index: 60;
}

.crop-handle-bar.top {
    top: 0;
    left: 0;
    right: 0;
    height: 5px;
    cursor: ns-resize;
}

.crop-handle-bar.bottom {
    bottom: 0;
    left: 0;
    right: 0;
    height: 5px;
    cursor: ns-resize;
}

.crop-handle-bar.left {
    top: 0;
    bottom: 0;
    left: 0;
    width: 5px;
    cursor: ew-resize;
}

.crop-handle-bar.right {
    top: 0;
    bottom: 0;
    right: 0;
    width: 5px;
    cursor: ew-resize;
}


/* --- Crop Box --- */
/* --- Crop Box (Improved) --- */
.crop-box {
    position: absolute;
    border: 2px dashed #00e5ff;
    box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.5);
    /* Visual dimmer for outside area */
    z-index: 100;
    cursor: move;
    background: transparent;
}

.resize-handle {
    width: 12px;
    height: 12px;
    background: #00e5ff;
    position: absolute;
    z-index: 110;
    box-shadow: 0 0 2px rgba(0, 0, 0, 0.5);
    border-radius: 50%;
    /* Make them round for better look */
}

.crop-handle {
    width: 10px;
    height: 10px;
    background: #ff0076;
    position: absolute;
    bottom: -5px;
    right: -5px;
    cursor: se-resize;
}

/* --- Cursor Tools --- */
.interaction-layer.whiteout-tool {
    cursor: cell;
    /* Looks a bit like a precision tool */
}

.interaction-layer.crop-tool {
    cursor: default;
}

/* Handles handle the cursor */

/* --- Layout Updates --- */
#pdf-zoom-wrapper {
    width: 100%;
    display: flex;
    justify-content: center;
    transform-origin: top center;
    transition: transform 0.2s ease;
    overflow: auto;
    padding: 20px;
}

.vertical-sep {
    width: 1px;
    height: 30px;
    background: rgba(255, 255, 255, 0.2);
    margin: 0 10px;
}

.zoom-section {
    display: flex;
    align-items: center;
    gap: 10px;
    color: #fff;
    font-weight: 600;
}

.glass-btn.icon-only {
    padding: 8px;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Workspace */
.workspace {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 24px;
    padding: 2rem;
    border: 1px solid var(--glass-border);
    min-height: 400px;
}

.upload-zone {
    border: 2px dashed rgba(255, 255, 255, 0.3);
    border-radius: 16px;
    padding: 4rem 2rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
}

.upload-zone:hover {
    border-color: #fff;
    background: rgba(255, 255, 255, 0.05);
}

.upload-zone i {
    font-size: 3rem;
    margin-bottom: 1rem;
    opacity: 0.8;
}

#pdf-drop-zone {
    margin: auto;
}

.highlight {
    color: #4facfe;
    font-weight: 600;
}

/* Buttons */
.glass-btn {
    padding: 0.8rem 1.5rem;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    font-family: var(--font-body);
    font-weight: 600;
    font-size: 1rem;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    backdrop-filter: blur(5px);
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.glass-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: translateY(-2px);
}

.glass-btn.primary {
    background: var(--accent-gradient);
    border: none;
    box-shadow: 0 4px 15px rgba(118, 75, 162, 0.4);
}

.glass-btn.primary:hover {
    box-shadow: 0 6px 20px rgba(118, 75, 162, 0.6);
}

.glass-btn.danger {
    background: rgba(255, 50, 50, 0.2);
    border-color: rgba(255, 50, 50, 0.4);
}

.glass-btn.danger:hover {
    background: rgba(255, 50, 50, 0.4);
}

.glass-btn.secondary {
    background: rgba(255, 255, 255, 0.15);
}

/* Downloader Specifics */
.downloader-box {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 24px;
    padding: 3rem;
    border: 1px solid var(--glass-border);
    max-width: 800px;
    margin: 0 auto;
}

.input-group {
    display: flex;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    padding: 0.5rem;
    border: 1px solid var(--glass-border);
}

.input-icon {
    padding: 1rem;
    font-size: 1.2rem;
    color: #fff;
}

.input-group input {
    flex: 1;
    background: transparent;
    border: none;
    color: #fff;
    font-size: 1rem;
    outline: none;
    padding: 0 1rem;
}

.input-group input::placeholder {
    color: rgba(255, 255, 255, 0.5);
}

.media-result {
    margin-top: 2rem;
    display: flex;
    gap: 2rem;
    align-items: center;
    background: rgba(255, 255, 255, 0.05);
    padding: 1.5rem;
    border-radius: 16px;
}

.hidden {
    display: none !important;
}

.thumbnail-wrapper {
    width: 200px;
    height: 112px;
    border-radius: 12px;
    overflow: hidden;
    position: relative;
    background: #000;
}

.thumbnail-wrapper.square {
    height: 200px;
    width: 200px;
}

.thumbnail-wrapper img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.play-icon {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #fff;
    font-size: 2rem;
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.5);
}

.media-info h3 {
    margin-bottom: 1rem;
    font-weight: 400;
}

.download-options {
    display: flex;
    gap: 10px;
}

/* PDF Preview Specifics */
.preview-area {
    margin-top: 1rem;
    max-height: 500px;
    overflow-y: auto;
    padding: 1rem;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 12px;
}

#pdf-pages-list {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    justify-content: center;
}

.pdf-page-thumb {
    width: 150px;
    height: 200px;
    background: white;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
    position: relative;
    overflow: hidden;
    /* For cropping simulation logic later */
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 8px;
}

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

::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* --- Sejda Style Layout --- */

.workspace-container {
    width: 100%;
    height: calc(100vh - 60px);
    /* Full height minus navbar */
    overflow: hidden;
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
    padding: 0;
    padding-left: 72px;
    /* Reserve space for fixed sidebar */
}

.workspace-container.sidebar-collapsed {
    padding-left: 0;
}

.pdf-scroll-view {
    display: flex;
    flex-direction: column;
    gap: 20px;
    align-items: center;
    width: 100%;
    max-width: 900px;
    margin: 0 auto;
    padding: 20px 10px 120px 10px;
    overflow-y: auto;
    height: 100%;
    /* Fill the container height */
    flex: 1;
}

/* Page Wrapper & Selection */
.page-wrapper {
    position: relative;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    border-radius: 4px;
}

.page-wrapper canvas {
    display: block;
}

.page-wrapper.selected-page {
    border: 4px solid #00e5ff;
    /* Bright Cyan */
    box-shadow: 0 0 20px rgba(0, 229, 255, 0.5);
    transform: scale(1.02);
    /* Slight pop */
    z-index: 5;
    /* Bring to front */
}

.interaction-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10;
    cursor: text;
    /* Default to text tool feel if active */
}

.interaction-layer.cursor-tool {
    cursor: default;
}

.interaction-layer.text-tool {
    cursor: text;
}

.interaction-layer.image-tool {
    cursor: crosshair;
}

/* Overlay elements: Text & Image */
.added-text-element,
.added-image-element {
    position: absolute;
    z-index: 20;
    border: 1px solid transparent;
    border-radius: 4px;
    transition: border-color 0.15s;
    min-width: 50px;
    min-height: 40px;
    cursor: default;
    display: flex;
    flex-direction: column;
}

.added-text-element:hover,
.added-text-element:focus-within,
.added-image-element:hover {
    border-color: #4facfe;
    box-shadow: 0 0 0 2px rgba(79, 172, 254, 0.25);
}

/* Drag bar at the top */
.element-drag-bar {
    width: 100%;
    height: 22px;
    min-height: 22px;
    background: rgba(79, 172, 254, 0.85);
    border-radius: 3px 3px 0 0;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: grab;
    color: #fff;
    font-size: 0.7rem;
    letter-spacing: 2px;
    user-select: none;
    -webkit-user-select: none;
    opacity: 0;
    transition: opacity 0.2s;
}

.added-text-element:hover .element-drag-bar,
.added-text-element:focus-within .element-drag-bar,
.added-image-element:hover .element-drag-bar {
    opacity: 1;
}

.element-drag-bar:active {
    cursor: grabbing;
    background: rgba(79, 172, 254, 1);
}

@media (hover: none) {

    /* Always show controls on touch devices */
    .element-drag-bar {
        opacity: 1;
    }
}

/* Delete (✕) button */
.element-delete-btn {
    position: absolute;
    top: -10px;
    right: -10px;
    width: 22px;
    height: 22px;
    background: #ff4444;
    border: 2px solid #fff;
    border-radius: 50%;
    color: #fff;
    font-size: 0.75rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    padding: 0;
    line-height: 1;
    z-index: 35;
    opacity: 0;
    transition: opacity 0.15s, transform 0.15s;
    transform: scale(0.8);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
}

.added-text-element:hover .element-delete-btn,
.added-text-element:focus-within .element-delete-btn,
.added-image-element:hover .element-delete-btn {
    opacity: 1;
    transform: scale(1);
}

.element-delete-btn:hover {
    background: #cc0000;
    transform: scale(1.15) !important;
}

@media (hover: none) {
    .element-delete-btn {
        opacity: 1;
        transform: scale(1);
        width: 28px;
        height: 28px;
        font-size: 0.9rem;
    }
}

/* Text content area */
.added-text-element .text-content {
    flex: 1;
    outline: none;
    padding: 4px 6px;
    white-space: nowrap;
    overflow: visible;
    cursor: text;
    line-height: 1.4;
    color: inherit;
    font-size: inherit;
    font-family: inherit;
    background: transparent;
}

/* Image fills remaining space below drag bar */
.added-image-element img {
    flex: 1;
    width: 100%;
    min-height: 0;
    object-fit: contain;
    display: block;
    pointer-events: none;
}

/* Resize handle at bottom-right */
.element-resize-handle {
    position: absolute;
    bottom: -8px;
    right: -8px;
    width: 18px;
    height: 18px;
    background: #00e5ff;
    border: 2px solid #fff;
    border-radius: 50%;
    cursor: se-resize;
    z-index: 35;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.35);
    opacity: 0;
    transition: opacity 0.15s, transform 0.15s;
    transform: scale(0.8);
}

.added-text-element:hover .element-resize-handle,
.added-text-element:focus-within .element-resize-handle,
.added-image-element:hover .element-resize-handle {
    opacity: 1;
    transform: scale(1);
}

@media (hover: none) {

    /* Keep always visible on touch */
    .element-resize-handle {
        opacity: 1;
        transform: scale(1);
        width: 26px;
        height: 26px;
        bottom: -13px;
        right: -13px;
    }
}


/* --- Bottom Toolbar --- */
.bottom-toolbar {
    position: fixed;
    bottom: 3px;
    left: 50%;
    transform: translateX(-50%);
    width: auto;
    min-width: 600px;
    max-width: calc(100vw - 120px);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    padding: 12px 30px;
    z-index: 9999;
    box-shadow: 0 15px 50px rgba(0, 0, 0, 0.6);
    background: rgba(5, 5, 10, 0.95) !important;
    border: 1px solid rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-radius: 16px;
}

.toolbar-section {
    display: flex;
    align-items: center;
    gap: 15px;
    /* More space between buttons */
}

.divider {
    width: 1px;
    height: 30px;
    background: rgba(255, 255, 255, 0.15);
}

.tool-btn {
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid transparent;
    /* Prevent layout shift on hover */
    color: #ffffff;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.8);
    /* Pop out text */
    /* Full opacity */
    font-size: 1.1rem;
    padding: 10px 18px;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    font-size: 0.85rem;
    gap: 6px;
    font-weight: 500;
}

.tool-btn i {
    font-size: 1.3rem;
}

.tool-btn:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.1);
    transform: translateY(-2px);
}

.tool-btn.active {
    color: #fff;
    background: var(--accent-gradient);
    /* Use the vibrant gradient */
    box-shadow: 0 4px 15px rgba(118, 75, 162, 0.5);
    border-color: rgba(255, 255, 255, 0.2);
}

.danger-text {
    color: #ff4b4b;
}

/* Text Options */
#text-options {
    position: absolute;
    bottom: 110%;
    /* Place above the toolbar */
    left: 50%;
    transform: translateX(-50%);
    background: rgba(10, 10, 20, 0.95);
    border: 1px solid rgba(255, 255, 255, 0.2);
    padding: 10px 20px;
    border-radius: 12px;
    display: flex;
    gap: 15px;
    z-index: 101;
    width: max-content;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.5);
}

#text-options.hidden {
    display: none !important;
}

.glass-select {
    background: rgba(128, 99, 99, 0.3);
    border: 1px solid var(--glass-border);
    color: #fff;
    padding: 5px;
    border-radius: 5px;
}

input[type="color"] {
    width: 30px;
    height: 30px;
    background: none;
    border: none;
    cursor: pointer;
}

input[type="range"] {
    width: 100px;
}

/* --- Home Dashboard --- */
.flex-center {
    display: flex;
    align-items: center;
    justify-content: center;
}

.home-grid {
    display: flex;
    gap: 40px;
    padding: 2rem;
}

.tool-card.large {
    width: 300px;
    height: 300px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    font-size: 1.2rem;
}

.icon-large {
    font-size: 4rem;
    margin-bottom: 2rem;
    color: #fff;
}

/* --- Crop Visuals (Extra) --- */
.crop-dimmer {
    position: absolute;
    background: rgba(0, 0, 0, 0.5);
    z-index: 90;
}

/* --- Modals (Missing Styles Added) --- */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(8px);
    z-index: 2000;
    /* High z-index to be on top of everything */
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 1;
    transition: opacity 0.3s ease;
}

.modal-overlay.hidden {
    opacity: 0;
    pointer-events: none;
    display: none !important;
}

.glass-panel {
    background: gray;
    backdrop-filter: blur(16px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
    border-radius: 20px;
    padding: 2.5rem;
    color: white;
    text-align: center;
}

.modal-content {
    max-width: 450px;
    width: 90%;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.modal-actions {
    margin-top: 25px;
    display: flex;
    gap: 20px;
    justify-content: center;
    width: 100%;
}

.large-btn {
    padding: 1rem 2rem;
    font-size: 1.1rem;
}

/* Spinner */
.spinner {
    width: 60px;
    height: 60px;
    border: 6px solid rgba(255, 255, 255, 0.1);
    border-top: 6px solid #00e5ff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 20px;
    box-shadow: 0 0 15px rgba(0, 229, 255, 0.3);
}

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

    100% {
        transform: rotate(360deg);
    }
}

/* Progress Bar */
.progress-bar-container {
    width: 100%;
    height: 10px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 5px;
    margin-top: 15px;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.progress-bar-fill {
    height: 100%;
    width: 0%;
    background: var(--accent-gradient);
    transition: width 0.2s ease;
    box-shadow: 0 0 10px rgba(118, 75, 162, 0.5);
}

.file-badge {
    background: rgba(0, 0, 0, 0.4);
    padding: 10px 20px;
    border-radius: 8px;
    margin: 20px 0;
    font-family: 'Courier New', monospace;
    color: #00e5ff;
    border: 1px solid rgba(0, 229, 255, 0.2);
}

/* --- AI Sidebar --- */
.ai-sidebar {
    position: fixed;
    top: 0;
    right: 0;
    width: 400px;
    height: 100vh;
    background: rgba(15, 12, 41, 0.95);
    backdrop-filter: blur(20px);
    box-shadow: -10px 0 30px rgba(0, 0, 0, 0.5);
    z-index: 1500;
    transform: translateX(0);
    transition: transform 0.3s ease-in-out;
    display: flex;
    flex-direction: column;
    border-left: 1px solid rgba(255, 255, 255, 0.1);
}

.ai-sidebar.hidden {
    transform: translateX(100%);
    display: flex !important;
    /* Keep flex layout, just move it off-screen */
}

.sidebar-header {
    padding: 20px;
    background: rgba(255, 255, 255, 0.05);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.sidebar-content {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    font-size: 0.95rem;
    line-height: 1.6;
    color: #e0e0e0;
}

.sidebar-content h1,
.sidebar-content h2,
.sidebar-content h3 {
    margin-top: 1.5rem;
    margin-bottom: 0.5rem;
    color: #fff;
}

.sidebar-content ul {
    padding-left: 20px;
}

.sidebar-content code {
    background: rgba(255, 255, 255, 0.1);
    padding: 2px 5px;
    border-radius: 4px;
}

/* --- Audio Player --- */
.audio-controls {
    display: flex;
    gap: 15px;
    justify-content: center;
    margin-bottom: 10px;
}

#voice-status {
    color: #00e5ff;
    font-size: 0.9rem;
    margin-bottom: 15px;
    min-height: 20px;
}

/* ==============================
   VIEW TRANSITION ANIMATIONS
   ============================== */
@keyframes fadeSlideIn {
    from {
        opacity: 0;
        transform: translateY(24px) scale(0.98);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes fadeSlideOut {
    from {
        opacity: 1;
        transform: translateY(0) scale(1);
    }

    to {
        opacity: 0;
        transform: translateY(-16px) scale(0.98);
    }
}

.view-enter {
    animation: fadeSlideIn 0.45s cubic-bezier(0.23, 1, 0.32, 1) forwards;
}

.view-exit {
    animation: fadeSlideOut 0.25s cubic-bezier(0.23, 1, 0.32, 1) forwards;
}

/* ==============================
   STAGGERED CARD ENTRANCE
   ============================== */
@keyframes cardEntrance {
    from {
        opacity: 0;
        transform: translateY(30px) scale(0.92);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.card-animate {
    opacity: 0;
    animation: cardEntrance 0.5s cubic-bezier(0.23, 1, 0.32, 1) forwards;
}

/* ==============================
   RIPPLE CLICK EFFECT
   ============================== */
.tool-card.large {
    position: relative;
    overflow: hidden;
}

.ripple {
    position: absolute;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.25);
    transform: scale(0);
    animation: rippleEffect 0.6s ease-out;
    pointer-events: none;
    z-index: 5;
}

@keyframes rippleEffect {
    to {
        transform: scale(4);
        opacity: 0;
    }
}

/* ==============================
   UPLOAD ZONE DRAG PULSE
   ============================== */
@keyframes dragPulse {
    0% {
        border-color: rgba(129, 140, 248, 0.4);
        box-shadow: 0 0 0 0 rgba(129, 140, 248, 0.3);
    }

    50% {
        border-color: rgba(129, 140, 248, 0.8);
        box-shadow: 0 0 20px 4px rgba(129, 140, 248, 0.2);
    }

    100% {
        border-color: rgba(129, 140, 248, 0.4);
        box-shadow: 0 0 0 0 rgba(129, 140, 248, 0.3);
    }
}

.upload-zone.drag-over {
    animation: dragPulse 1s ease-in-out infinite;
    background: rgba(99, 102, 241, 0.08);
}

/* ==============================
   ICON HOVER MICRO-INTERACTIONS
   ============================== */
@keyframes iconBounce {
    0% {
        transform: scale(1);
    }

    40% {
        transform: scale(1.2) rotate(-5deg);
    }

    60% {
        transform: scale(1.1) rotate(3deg);
    }

    80% {
        transform: scale(1.15) rotate(-2deg);
    }

    100% {
        transform: scale(1.15);
    }
}

.tool-card.large:hover .icon-large {
    animation: iconBounce 0.5s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

.tool-card.large .icon-large {
    transition: color 0.3s ease, filter 0.3s ease;
}

.tool-card.large:hover .icon-large {
    color: #a5b4fc;
    filter: drop-shadow(0 0 8px rgba(129, 140, 248, 0.5));
}

/* ==============================
   REORDER PAGES TOOL
   ============================== */
.reorder-pages-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 16px;
    padding: 16px;
    width: 100%;
    max-width: 700px;
    min-height: 100px;
}

.reorder-page-item {
    position: relative;
    background: rgba(255, 255, 255, 0.06);
    border: 2px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 8px;
    cursor: grab;
    transition: transform 0.2s, box-shadow 0.2s, border-color 0.2s;
    text-align: center;
}

.reorder-page-item:hover {
    border-color: rgba(129, 140, 248, 0.5);
    box-shadow: 0 4px 16px rgba(99, 102, 241, 0.2);
    transform: translateY(-3px);
}

.reorder-page-item.dragging {
    opacity: 0.4;
    transform: scale(0.95);
}

.reorder-page-item.drag-over-item {
    border-color: #00e5ff;
    box-shadow: 0 0 16px rgba(0, 229, 255, 0.3);
}

.reorder-page-item canvas {
    width: 100%;
    height: auto;
    border-radius: 6px;
    pointer-events: none;
}

.reorder-page-item .page-label {
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.6);
    margin-top: 6px;
    font-family: 'Outfit', sans-serif;
}

/* ==============================
   METADATA VIEWER
   ============================== */
.metadata-grid {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 10px 16px;
    width: 100%;
    max-width: 450px;
    padding: 16px 20px;
    background: rgba(0, 0, 0, 0.25);
    border-radius: 14px;
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.metadata-grid .meta-label {
    color: rgba(255, 255, 255, 0.5);
    font-size: 0.85rem;
    font-family: 'Outfit', sans-serif;
    text-align: right;
    white-space: nowrap;
}

.metadata-grid .meta-value {
    color: #a5b4fc;
    font-size: 0.9rem;
    font-family: 'Outfit', sans-serif;
    word-break: break-all;
}

/* ==============================
   TYPE SIGNATURE
   ============================== */
#sig-type-area {
    width: 100%;
    padding: 16px;
    text-align: center;
}

#sig-type-input {
    width: 100%;
    padding: 12px 16px;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: white;
    border-radius: 10px;
    font-size: 1rem;
    outline: none;
    margin-bottom: 12px;
    transition: border-color 0.3s;
}

#sig-type-input:focus {
    border-color: rgba(129, 140, 248, 0.6);
}

#sig-type-preview {
    width: 100%;
    height: 80px;
    background: white;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    color: #1a1a2e;
    overflow: hidden;
}

/* ==============================
   TOAST NOTIFICATIONS
   ============================== */
#toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
}

.toast {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 20px;
    border-radius: 12px;
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    color: white;
    font-size: 0.9rem;
    font-family: 'Outfit', sans-serif;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    transform: translateX(120%);
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    pointer-events: auto;
    max-width: 400px;
}

.toast.show {
    transform: translateX(0);
}

.toast i {
    font-size: 1.2rem;
    flex-shrink: 0;
}

.toast-info {
    background: rgba(99, 102, 241, 0.85);
    border: 1px solid rgba(129, 140, 248, 0.4);
}

.toast-success {
    background: rgba(16, 185, 129, 0.85);
    border: 1px solid rgba(52, 211, 153, 0.4);
}

.toast-warning {
    background: rgba(245, 158, 11, 0.85);
    border: 1px solid rgba(251, 191, 36, 0.4);
}

.toast-error {
    background: rgba(239, 68, 68, 0.85);
    border: 1px solid rgba(248, 113, 113, 0.4);
}

/* ==============================
   COMPRESS STATS
   ============================== */
.compress-stats {
    margin: 15px 0;
    padding: 12px 16px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.compress-stats .stat-row {
    display: flex;
    justify-content: space-between;
    padding: 4px 0;
    color: rgba(255, 255, 255, 0.8);
    font-size: 0.9rem;
}

.compress-stats .stat-good strong {
    color: #34d399;
}

.compress-stats .stat-bad strong {
    color: #fbbf24;
}

.file-info-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    background: rgba(99, 102, 241, 0.15);
    border: 1px solid rgba(129, 140, 248, 0.3);
    border-radius: 10px;
    color: #a5b4fc;
    font-size: 0.9rem;
    margin-bottom: 15px;
}

.file-info-bar i {
    color: #ef4444;
}

.file-size-badge {
    background: rgba(0, 0, 0, 0.3);
    padding: 2px 8px;
    border-radius: 6px;
    font-size: 0.8rem;
    color: #fbbf24;
}

.compress-stats-container {
    margin-top: 10px;
}

/* ==============================
   GLASS FORM INPUTS
   ============================== */
.glass-input,
.glass-select {
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: white;
    padding: 8px 12px;
    border-radius: 8px;
    font-family: 'Outfit', sans-serif;
    font-size: 0.9rem;
    transition: border-color 0.3s;
}

.glass-input:focus,
.glass-select:focus {
    outline: none;
    border-color: rgba(129, 140, 248, 0.6);
}

.glass-select option {
    background: #1a1a2e;
    color: white;
}

/* ==============================
   CENTER BOX
   ============================== */
.center-box {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
    max-width: 500px;
    width: 100%;
}

.center-box h2 {
    font-family: 'Outfit', sans-serif;
    font-weight: 700;
    font-size: 1.8rem;
    background: linear-gradient(135deg, #a5b4fc, #00e5ff);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.glass-panel {
    background: rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 16px;
}

.glass-panel h4 {
    color: rgba(255, 255, 255, 0.8);
    font-family: 'Outfit', sans-serif;
    font-weight: 600;
    font-size: 0.95rem;
    margin-bottom: 4px;
}

/* ==============================
   ROTATE RADIO BUTTONS
   ============================== */
.rotate-option {
    cursor: pointer;
}

.rotate-option input[type="radio"] {
    display: none;
}

.rotate-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 20px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 12px;
    color: rgba(255, 255, 255, 0.7);
    font-family: 'Outfit', sans-serif;
    transition: all 0.3s;
}

.rotate-option input[type="radio"]:checked+.rotate-btn {
    background: rgba(99, 102, 241, 0.3);
    border-color: #818cf8;
    color: white;
    box-shadow: 0 0 15px rgba(99, 102, 241, 0.3);
}

.rotate-btn:hover {
    background: rgba(255, 255, 255, 0.12);
    border-color: rgba(255, 255, 255, 0.25);
}

/* ==============================
   FOOTER
   ============================== */
.site-footer {
    margin-top: auto;
    padding: 20px;
    text-align: center;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.footer-content p {
    color: rgba(255, 255, 255, 0.4);
    font-size: 0.8rem;
    font-family: 'Outfit', sans-serif;
    margin: 4px 0;
}

.footer-content i {
    margin-right: 4px;
}

/* ==============================
   HEADER TAGLINE
   ============================== */
.header-tagline {
    color: rgba(255, 255, 255, 0.5);
    font-family: 'Outfit', sans-serif;
    font-size: 0.85rem;
    font-weight: 300;
    letter-spacing: 1px;
    margin-top: 4px;
}

/* ==============================
   FILE BADGE
   ============================== */
.file-badge {
    background: rgba(99, 102, 241, 0.15);
    border: 1px solid rgba(129, 140, 248, 0.3);
    padding: 6px 14px;
    border-radius: 8px;
    color: #a5b4fc;
    font-family: 'Outfit', sans-serif;
    font-size: 0.85rem;
    margin: 8px 0;
    word-break: break-all;
}

/* Large button style for modal download */
.large-btn {
    padding: 12px 28px;
    font-size: 1rem;
}

/* ==============================
   GLASS BUTTON SMALL VARIANT
   ============================== */
.glass-btn.small {
    padding: 6px 14px;
    font-size: 0.8rem;
}

/* ==============================
   TOOL CARD HOVER ANIMATIONS
   ============================== */
.tool-card.large {
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1),
        box-shadow 0.3s ease,
        border-color 0.3s ease;
}

.tool-card.large:hover {
    transform: translateY(-6px) scale(1.03);
    box-shadow: 0 16px 40px rgba(99, 102, 241, 0.2);
    border-color: rgba(129, 140, 248, 0.4);
}

.tool-card.large:active {
    transform: translateY(-2px) scale(1.01);
}

/* Range slider styling */
input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    height: 6px;
    background: rgba(255, 255, 255, 0.15);
    border-radius: 3px;
    outline: none;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #818cf8;
    cursor: pointer;
    border: 2px solid rgba(255, 255, 255, 0.3);
}

/* Spinner utility */
.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(255, 255, 255, 0.1);
    border-top-color: #818cf8;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto;
}

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

/* ==============================
   REDACT PDF TOOL
   ============================== */
.redact-pages-container {
    display: flex;
    flex-direction: column;
    gap: 20px;
    align-items: center;
    width: 100%;
    max-height: 70vh;
    overflow-y: auto;
    padding: 10px;
}

.redact-page-wrapper {
    cursor: crosshair;
    border: 2px solid rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
}

.redact-page-wrapper canvas {
    display: block;
    max-width: 100%;
    height: auto;
}

.redact-box {
    position: absolute;
    background: rgba(0, 0, 0, 0.75);
    border: 2px solid #f87171;
    border-radius: 3px;
    pointer-events: none;
    z-index: 10;
}

/* ==============================
   COMPARE PDFs TOOL
   ============================== */
.compare-side-by-side {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 12px;
    width: 100%;
}

.compare-panel {
    background: rgba(0, 0, 0, 0.25);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 12px;
    padding: 10px;
    text-align: center;
    overflow: hidden;
}

.compare-panel h4 {
    color: #a5b4fc;
    font-family: 'Outfit', sans-serif;
    font-size: 0.85rem;
    margin-bottom: 8px;
    font-weight: 600;
}

.compare-panel canvas {
    width: 100%;
    height: auto;
    border-radius: 6px;
    display: block;
}

/* ==============================
   PDF TO MARKDOWN TOOL
   ============================== */
.markdown-preview-box {
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 16px;
    max-height: 400px;
    overflow-y: auto;
    text-align: left;
    color: #e2e8f0;
    font-family: 'Outfit', sans-serif;
}

/* ==============================
   FORM FILLER TOOL
   ============================== */
.form-fields-container {
    display: flex;
    flex-direction: column;
    gap: 16px;
    width: 100%;
    max-width: 600px;
    margin: 0 auto;
}

.form-field-item {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 14px 18px;
    transition: border-color 0.3s;
}

.form-field-item:hover {
    border-color: rgba(129, 140, 248, 0.3);
}

.form-field-label {
    color: #a5b4fc;
    font-family: 'Outfit', sans-serif;
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 8px;
    display: block;
}

.form-field-item .glass-input,
.form-field-item .glass-select {
    width: 100%;
    margin-top: 4px;
}

.form-field-item textarea.glass-input {
    resize: vertical;
    min-height: 60px;
}

/* ==============================
   DELETE PAGES TOOL
   ============================== */
.delete-pages-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 16px;
    padding: 16px;
    width: 100%;
    max-width: 700px;
    min-height: 100px;
}

.delete-page-item {
    position: relative;
    background: rgba(255, 255, 255, 0.06);
    border: 2px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 8px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    text-align: center;
    user-select: none;
}

.delete-page-item:hover {
    border-color: rgba(248, 113, 113, 0.4);
    transform: translateY(-3px);
    box-shadow: 0 4px 16px rgba(239, 68, 68, 0.15);
}

.delete-page-item canvas {
    width: 100%;
    height: auto;
    border-radius: 6px;
    pointer-events: none;
}

.delete-page-item .page-label {
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.6);
    margin-top: 6px;
    font-family: 'Outfit', sans-serif;
}

.delete-page-item .delete-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(239, 68, 68, 0.35);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s;
    pointer-events: none;
}

.delete-page-item .delete-overlay i {
    font-size: 2rem;
    color: white;
    filter: drop-shadow(0 2px 8px rgba(0, 0, 0, 0.5));
}

.delete-page-item.selected-for-delete {
    border-color: #f87171;
    box-shadow: 0 0 20px rgba(239, 68, 68, 0.3);
}

.delete-page-item.selected-for-delete .delete-overlay {
    opacity: 1;
}

.delete-page-item.selected-for-delete canvas {
    filter: brightness(0.5);
}

/* ==============================
   EDITOR SIDEBAR - ALL IN ONE
   ============================== */
.editor-body {
    display: flex;
    width: 100%;
    height: calc(100vh - 60px);
    /* Fixed height so sidebar can be sticky */
    min-height: 0;
    position: relative;
    overflow: hidden;
    /* Only the scroll-view inside should scroll */
}

.editor-sidebar {
    width: 72px;
    background: rgba(15, 12, 41, 0.95);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-right: 1px solid rgba(255, 255, 255, 0.08);
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 8px 0;
    transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    flex-shrink: 0;
    z-index: 50;
    position: fixed;
    top: 60px;
    /* Below the site navbar */
    left: 0;
    height: calc(100vh - 60px);
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-width: none;
    box-shadow: 4px 0 20px rgba(0, 0, 0, 0.3);
}

.editor-sidebar::-webkit-scrollbar {
    display: none;
}

.editor-sidebar.collapsed {
    width: 0;
    padding: 0;
    border-right: none;
    overflow: hidden;
}

.sidebar-toggle {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.6);
    width: 36px;
    height: 36px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    margin-bottom: 8px;
    transition: all 0.3s;
    font-size: 0.8rem;
    flex-shrink: 0;
}

.sidebar-toggle:hover {
    background: rgba(99, 102, 241, 0.2);
    border-color: rgba(129, 140, 248, 0.4);
    color: white;
}

.sidebar-open-btn {
    position: absolute;
    top: 12px;
    left: 12px;
    z-index: 60;
    width: 38px;
    height: 38px;
    border-radius: 12px;
    border: 1px solid rgba(129, 140, 248, 0.4);
    background: rgba(99, 102, 241, 0.25);
    color: #a5b4fc;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 0.85rem;
    transition: all 0.25s;
    box-shadow: 0 4px 16px rgba(99, 102, 241, 0.2);
}

.sidebar-open-btn:hover {
    background: rgba(99, 102, 241, 0.4);
    color: white;
    box-shadow: 0 4px 20px rgba(99, 102, 241, 0.35);
}

.sidebar-tools-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
    width: 100%;
    padding: 0 6px;
}

.sidebar-tool-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    padding: 10px 4px;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 10px;
    color: rgba(255, 255, 255, 0.55);
    cursor: pointer;
    font-family: 'Outfit', sans-serif;
    font-size: 0.65rem;
    transition: all 0.25s;
    width: 100%;
}

.sidebar-tool-btn i {
    font-size: 1.15rem;
    transition: transform 0.25s, color 0.25s;
}

.sidebar-tool-btn span {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 60px;
}

.sidebar-tool-btn:hover {
    background: rgba(99, 102, 241, 0.12);
    border-color: rgba(129, 140, 248, 0.2);
    color: rgba(255, 255, 255, 0.85);
}

.sidebar-tool-btn:hover i {
    transform: scale(1.15);
    color: #a5b4fc;
}

.sidebar-tool-btn.active {
    background: rgba(99, 102, 241, 0.25);
    border-color: rgba(129, 140, 248, 0.5);
    color: white;
    box-shadow: 0 0 12px rgba(99, 102, 241, 0.15);
}

.sidebar-tool-btn.active i {
    color: #a5b4fc;
}

/* Editor body: PDF preview fills remaining space */
.editor-body #pdf-zoom-wrapper {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    display: flex;
    justify-content: center;
}

/* ==============================
   FLOATING TOOL PANEL
   ============================== */
.editor-tool-panel {
    position: fixed;
    top: 80px;
    right: 20px;
    width: 320px;
    max-height: calc(100vh - 160px);
    z-index: 500;
    border-radius: 16px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: 0 16px 64px rgba(0, 0, 0, 0.5);
    animation: panelSlideIn 0.3s cubic-bezier(0.23, 1, 0.32, 1);
}

@keyframes panelSlideIn {
    from {
        opacity: 0;
        transform: translateX(20px) scale(0.96);
    }

    to {
        opacity: 1;
        transform: translateX(0) scale(1);
    }
}

.tool-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 18px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.tool-panel-header h3 {
    color: #a5b4fc;
    font-family: 'Outfit', sans-serif;
    font-size: 1rem;
    font-weight: 700;
    margin: 0;
}

.tool-panel-body {
    padding: 16px 18px;
    overflow-y: auto;
    flex: 1;
}

.tool-panel-footer {
    padding: 12px 18px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    display: flex;
    justify-content: flex-end;
}

/* ==============================
   PAGE RESIZE TOOL
   ============================== */
.resize-preset.active {
    background: rgba(99, 102, 241, 0.3) !important;
    border-color: #818cf8 !important;
    color: white !important;
    box-shadow: 0 0 15px rgba(99, 102, 241, 0.3);
}

/* ==============================
   MOBILE RESPONSIVE - TABLET (≤768px)
   ============================== */
@media screen and (max-width: 768px) {
    body {
        overflow-y: auto;
        height: auto;
    }

    .app-container {
        height: auto;
        min-height: 100vh;
        overflow-x: hidden;
        overflow-y: auto;
        flex-direction: column;
    }

    .glass-content.full-width {
        height: auto;
        min-height: 100vh;
        overflow-y: visible;
        padding-top: 100px;
        padding-bottom: 100px;
    }

    /* Header */
    .main-header {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        z-index: 200;
        background: rgba(15, 12, 41, 0.92);
        backdrop-filter: blur(16px);
        -webkit-backdrop-filter: blur(16px);
        padding: 12px 20px;
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 12px;
        border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    }

    .logo {
        font-size: 1.2rem;
    }

    .header-tagline {
        display: none;
    }

    /* Tool Grid - 2 columns */
    .home-grid {
        display: grid !important;
        grid-template-columns: 1fr 1fr;
        gap: 14px;
        padding: 1rem;
        max-width: 100%;
    }

    .tool-card.large {
        width: 100% !important;
        height: auto !important;
        min-height: 140px;
        padding: 1.2rem;
        border-radius: 16px;
    }

    .tool-card.large h2 {
        font-size: 0.95rem;
    }

    .tool-card.large p {
        font-size: 0.75rem;
        opacity: 0.7;
    }

    .icon-large {
        font-size: 2.2rem;
        margin-bottom: 0.8rem;
    }

    /* Center Box */
    .center-box {
        width: 95%;
        padding: 0 12px;
        max-width: 100%;
    }

    .center-box h2 {
        font-size: 1.4rem;
    }

    /* Upload Zones */
    .upload-zone {
        padding: 2.5rem 1.5rem;
    }

    .upload-zone i {
        font-size: 2.2rem;
    }

    /* Bottom Toolbar */
    .bottom-toolbar {
        left: 0;
        right: 0;
        bottom: 0;
        transform: none;
        width: 100%;
        min-width: unset;
        max-width: unset;
        border-radius: 16px 16px 0 0;
        flex-wrap: nowrap;
        overflow-x: auto;
        justify-content: flex-start;
        padding: 10px 12px;
        gap: 8px;
        scrollbar-width: none;
        -ms-overflow-style: none;
        -webkit-overflow-scrolling: touch;
    }

    .bottom-toolbar::-webkit-scrollbar {
        display: none;
    }

    .toolbar-section {
        flex-shrink: 0;
    }

    .toolbar-section.main-tools {
        gap: 6px;
    }

    .tool-btn {
        padding: 8px 10px;
        font-size: 0.7rem;
        min-width: 48px;
        min-height: 48px;
    }

    .tool-btn i {
        font-size: 1.1rem;
    }

    .vertical-sep {
        height: 24px;
        margin: 0 4px;
    }

    .divider {
        height: 24px;
    }

    /* Text Options */
    #text-options {
        bottom: 120%;
        width: calc(100vw - 24px);
        left: 50%;
        padding: 8px 12px;
        gap: 8px;
        flex-wrap: wrap;
        justify-content: center;
    }

    /* Glass Buttons */
    .glass-btn {
        padding: 0.7rem 1rem;
        font-size: 0.85rem;
    }

    .glass-btn.small {
        padding: 5px 10px;
        font-size: 0.75rem;
    }

    /* Modals */
    .modal-content {
        width: 92%;
        padding: 1.5rem;
        max-width: 100%;
    }

    .modal-actions {
        flex-direction: column;
        gap: 10px;
    }

    .modal-actions .glass-btn {
        width: 100%;
        justify-content: center;
    }

    /* Signature Modal */
    #signature-canvas {
        width: 100% !important;
        height: 150px !important;
    }

    /* AI Sidebar - Full Screen on Mobile */
    .ai-sidebar {
        width: 100vw;
        border-left: none;
    }

    /* Typography */
    h1 {
        font-size: 1.8rem;
    }

    h2 {
        font-size: 1.3rem;
    }

    h3 {
        font-size: 1.1rem;
    }

    /* Editor Workspace */
    .workspace-container {
        height: auto;
        min-height: calc(100vh - 80px);
        padding-bottom: 120px;
    }

    /* Toast */
    #toast-container {
        top: 70px;
        right: 10px;
        left: 10px;
    }

    .toast {
        max-width: 100%;
        font-size: 0.82rem;
        padding: 10px 14px;
    }

    /* Download / Media */
    .download-options {
        flex-direction: column;
    }

    .media-result {
        flex-direction: column;
        text-align: center;
    }

    /* Compress Options */
    #compress-options div[style*="display:flex"] {
        flex-wrap: wrap;
    }

    /* Reorder Grid */
    .reorder-pages-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 10px;
        padding: 10px;
    }

    /* Metadata Grid */
    .metadata-grid {
        grid-template-columns: 1fr;
        gap: 6px;
        padding: 12px 14px;
    }

    .metadata-grid .meta-label {
        text-align: left;
        font-weight: 600;
        color: rgba(255, 255, 255, 0.4);
        font-size: 0.75rem;
    }

    /* Compare Tool - stack vertically */
    .compare-side-by-side {
        grid-template-columns: 1fr;
        gap: 16px;
    }

    /* Delete Pages Grid */
    .delete-pages-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 10px;
        padding: 10px;
    }

    /* Redact Container */
    .redact-pages-container {
        max-height: 60vh;
    }

    /* Editor Sidebar - Tablet */
    .editor-sidebar {
        width: 58px;
    }

    .sidebar-tool-btn span {
        font-size: 0.58rem;
    }

    .editor-tool-panel {
        width: 280px;
        right: 10px;
        top: 70px;
    }

    /* Footer */
    .site-footer {
        padding: 16px 12px;
    }

    .footer-content p {
        font-size: 0.72rem;
    }
}

/* ==============================
   MOBILE RESPONSIVE - PHONE (≤480px)
   ============================== */
@media screen and (max-width: 480px) {
    .glass-content.full-width {
        padding-top: 80px;
        padding-bottom: 80px;
    }

    /* Single column grid on phone */
    .home-grid {
        grid-template-columns: 1fr !important;
        gap: 12px;
        padding: 0.75rem;
    }

    .tool-card.large {
        min-height: 110px;
        padding: 1rem;
        flex-direction: row;
        gap: 14px;
        text-align: left;
    }

    .tool-card.large .icon-large {
        font-size: 1.8rem;
        margin-bottom: 0;
    }

    .tool-card.large h2 {
        font-size: 0.9rem;
        margin-bottom: 2px;
    }

    .tool-card.large p {
        font-size: 0.72rem;
        margin: 0;
    }

    /* Upload zones tighter */
    .upload-zone {
        padding: 2rem 1rem;
    }

    .upload-zone i {
        font-size: 1.8rem;
        margin-bottom: 0.5rem;
    }

    .upload-zone p {
        font-size: 0.85rem;
    }

    /* Center box */
    .center-box {
        width: 100%;
        padding: 0 10px;
    }

    .center-box h2 {
        font-size: 1.2rem;
    }

    /* Toolbar */
    .bottom-toolbar {
        padding: 8px;
        gap: 6px;
    }

    .tool-btn {
        padding: 6px 8px;
        font-size: 0.65rem;
        min-width: 44px;
        min-height: 44px;
        gap: 3px;
    }

    /* Larger touch targets on mobile */
    .resize-handle {
        width: 20px !important;
        height: 20px !important;
    }

    /* .interaction-layer: JS handles scroll prevention when using tools */

    .crop-box {
        touch-action: none;
    }

    /* .added-text-element, .added-image-element, .whiteout-element: JS handles dragging */

    .tool-btn i {
        font-size: 1rem;
    }

    /* Glass panel / options */
    .glass-panel {
        border-radius: 12px;
    }

    /* Buttons */
    .glass-btn {
        padding: 0.6rem 0.9rem;
        font-size: 0.8rem;
        border-radius: 10px;
    }

    /* Reorder Grid */
    .reorder-pages-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
    }

    /* Rotate buttons */
    .rotate-btn {
        padding: 8px 12px;
        font-size: 0.8rem;
    }

    /* Delete Pages Grid Phone */
    .delete-pages-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
    }

    /* Editor Sidebar - Phone: hidden by default */
    .editor-sidebar {
        position: fixed;
        left: 0;
        top: 0;
        height: 100vh;
        z-index: 300;
        width: 64px;
        transform: translateX(-100%);
        transition: transform 0.3s;
    }

    .editor-sidebar:not(.collapsed) {
        transform: translateX(0);
    }

    .editor-sidebar.collapsed {
        transform: translateX(-100%);
    }

    .editor-body {
        flex-direction: column;
    }

    .editor-tool-panel {
        width: calc(100vw - 20px);
        right: 10px;
        left: 10px;
        top: auto;
        bottom: 100px;
        max-height: 50vh;
    }
}

/* ================================================================
   SITE NAVBAR — Responsive, Glassmorphic, Cross-Browser
   ================================================================ */

.site-navbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 9990;
    background: rgba(5, 5, 20, 0.85);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.12);
    box-shadow: 0 4px 30px rgba(0, 0, 0, 0.4);
}

.navbar-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    height: 60px;
    max-width: 1400px;
    margin: 0 auto;
    width: 100%;
}

.navbar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    color: #fff;
    text-decoration: none;
    font-family: 'Outfit', sans-serif;
    font-weight: 700;
    font-size: 1.25rem;
    letter-spacing: -0.5px;
    background: linear-gradient(135deg, #00e5ff, #ff0076);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    flex-shrink: 0;
}

.navbar-brand i {
    -webkit-text-fill-color: #00e5ff;
}

.navbar-links {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-wrap: nowrap;
}

.nav-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    color: rgba(255, 255, 255, 0.85);
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 500;
    border-radius: 8px;
    border: none;
    background: transparent;
    cursor: pointer;
    font-family: 'Poppins', sans-serif;
    transition: background 0.2s ease, color 0.2s ease;
    white-space: nowrap;
}

.nav-link:hover {
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
}

.nav-link-highlight {
    background: rgba(0, 229, 255, 0.12);
    color: #00e5ff !important;
    border: 1px solid rgba(0, 229, 255, 0.25);
}

.nav-link-highlight:hover {
    background: rgba(0, 229, 255, 0.2) !important;
}

.nav-link-donate {
    color: #ff6b9d !important;
}

.nav-link-donate:hover {
    background: rgba(255, 0, 118, 0.15) !important;
}

/* --- Support Dropdown --- */
.nav-dropdown-wrap {
    position: relative;
}

.nav-support-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    color: rgba(255, 255, 255, 0.85);
    border: none;
    background: transparent;
    font-size: 0.875rem;
    font-weight: 500;
    border-radius: 8px;
    cursor: pointer;
    font-family: 'Poppins', sans-serif;
    transition: background 0.2s ease;
    white-space: nowrap;
}

.nav-support-btn:hover {
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
}

.nav-dropdown {
    display: none;
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    background: rgba(10, 10, 30, 0.95);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 12px;
    padding: 8px;
    min-width: 180px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
    z-index: 10000;
}

.nav-dropdown.open {
    display: block;
    animation: fadeIn 0.15s ease;
}

.dropdown-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    color: rgba(255, 255, 255, 0.85);
    text-decoration: none;
    border-radius: 8px;
    font-size: 0.875rem;
    transition: background 0.2s ease;
    white-space: nowrap;
}

.dropdown-item:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
}

/* --- Hamburger Button --- */
.nav-hamburger {
    display: none;
    flex-direction: column;
    gap: 5px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
    border-radius: 8px;
    transition: background 0.2s;
}

.nav-hamburger:hover {
    background: rgba(255, 255, 255, 0.1);
}

.nav-hamburger span {
    display: block;
    width: 22px;
    height: 2px;
    background: #fff;
    border-radius: 2px;
    transition: all 0.3s ease;
}

/* --- Mobile Drawer --- */
.nav-drawer-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 9995;
    backdrop-filter: blur(4px);
}

.nav-drawer-overlay.open {
    display: block;
}

.nav-drawer {
    position: fixed;
    top: 0;
    right: -300px;
    width: 280px;
    height: 100vh;
    background: rgba(8, 8, 25, 0.98);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-left: 1px solid rgba(255, 255, 255, 0.12);
    z-index: 9996;
    transition: right 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.nav-drawer.open {
    right: 0;
}

.drawer-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.drawer-brand {
    font-family: 'Outfit', sans-serif;
    font-weight: 700;
    font-size: 1.1rem;
    background: linear-gradient(135deg, #00e5ff, #ff0076);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.drawer-close {
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.7);
    font-size: 1.2rem;
    cursor: pointer;
    padding: 6px;
    border-radius: 6px;
    transition: background 0.2s;
}

.drawer-close:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
}

.drawer-links {
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex: 1;
}

.drawer-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    color: rgba(255, 255, 255, 0.85);
    text-decoration: none;
    border-radius: 10px;
    font-size: 0.95rem;
    font-weight: 500;
    transition: background 0.2s ease;
}

.drawer-link:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
}

.drawer-divider {
    height: 1px;
    background: rgba(255, 255, 255, 0.1);
    margin: 8px 0;
}

.drawer-section-title {
    color: rgba(255, 255, 255, 0.4);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    padding: 8px 16px 4px;
    font-weight: 600;
}

.drawer-social {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 8px 16px 16px;
}

.social-chip {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 10px;
    color: #fff;
    font-size: 1.1rem;
    text-decoration: none;
    transition: all 0.2s ease;
}

.social-chip:hover {
    background: rgba(255, 255, 255, 0.18);
    transform: translateY(-2px);
}

/* Adjust content top padding for navbar */
.glass-content.full-width {
    padding-top: 75px !important;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-5px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ================================================================
   IMAGE EDITOR TOOLS — UI Components
   ================================================================ */

/* Enhance sliders */
.enhance-sliders {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.slider-row {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.slider-row label {
    display: flex;
    justify-content: space-between;
    color: rgba(255, 255, 255, 0.8);
    font-size: 0.85rem;
}

.slider-row label span {
    color: #00e5ff;
    font-weight: 600;
}

.img-slider {
    width: 100%;
    accent-color: #00e5ff;
    height: 4px;
    cursor: pointer;
}

/* Image edit toolbar */
.img-edit-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 10px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    margin-bottom: 10px;
}

.edit-mode-btn.active-mode {
    background: rgba(0, 229, 255, 0.2) !important;
    border-color: #00e5ff !important;
    color: #00e5ff;
}

/* Canvas scroll container */
.img-canvas-scroll {
    width: 100%;
    overflow: auto;
    border-radius: 10px;
    background: rgba(0, 0, 0, 0.2);
    padding: 10px;
    -webkit-overflow-scrolling: touch;
}

/* Rotate / Flip action grid */
.img-action-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin-top: 10px;
}

@media (max-width: 400px) {
    .img-action-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Site footer */
.site-footer {
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    padding: 20px 30px;
    text-align: center;
    color: rgba(255, 255, 255, 0.6);
    font-size: 0.85rem;
    line-height: 2;
    position: relative;
    z-index: 10;
}

.site-footer a {
    color: #a5b4fc;
    text-decoration: none;
}

.site-footer a:hover {
    text-decoration: underline;
}

/* ================================================================
   NAVBAR MODALS
   ================================================================ */

.modal-close-x {
    position: absolute;
    top: 12px;
    right: 12px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #fff;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    transition: background 0.2s;
    z-index: 1;
}

.modal-close-x:hover {
    background: rgba(255, 77, 77, 0.3);
}

/* Help FAQ */
.help-faq {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.faq-item {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 10px;
    padding: 12px 15px;
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.faq-item strong {
    color: #00e5ff;
    font-size: 0.9rem;
    display: block;
    margin-bottom: 4px;
}

.faq-item p {
    color: rgba(255, 255, 255, 0.75);
    font-size: 0.85rem;
    margin: 0;
    line-height: 1.6;
}

/* Star Rating */
.star-rating {
    display: flex;
    gap: 8px;
}

.star {
    font-size: 1.8rem;
    color: rgba(255, 255, 255, 0.2);
    cursor: pointer;
    transition: color 0.15s ease, transform 0.15s ease;
}

.star:hover,
.star.active {
    color: #ffd700;
    transform: scale(1.2);
}

/* Donate buttons */
.donate-options {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin: 20px 0;
    align-items: center;
}

.donate-btn {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 12px 24px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 12px;
    color: #fff;
    text-decoration: none;
    font-size: 0.95rem;
    font-weight: 600;
    font-family: 'Poppins', sans-serif;
    transition: all 0.2s ease;
    min-width: 200px;
    justify-content: center;
}

.donate-btn:hover {
    background: rgba(255, 255, 255, 0.18);
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.2);
}

/* ================================================================
   RESPONSIVE — MOBILE FIRST
   ================================================================ */

@media (max-width: 900px) {
    .navbar-links {
        display: none;
    }

    .nav-hamburger {
        display: flex;
    }
}

@media (max-width: 600px) {
    .home-grid {
        gap: 16px;
        padding: 1rem;
    }

    .tool-card.large {
        width: 140px;
        height: 140px;
        padding: 1rem;
    }

    .tool-card.large h2 {
        font-size: 0.8rem;
    }

    .tool-card.large p {
        font-size: 0.72rem;
    }

    .icon-large {
        font-size: 1.8rem !important;
    }

    .center-box {
        padding: 15px !important;
    }

    .img-edit-toolbar {
        gap: 5px;
    }

    .img-edit-toolbar .glass-btn {
        padding: 6px 8px;
        font-size: 0.75rem;
    }

    .glass-panel {
        padding: 15px !important;
    }

    .modal-content {
        margin: 10px;
        width: calc(100vw - 20px) !important;
        max-width: none !important;
    }

    .enhance-sliders {
        gap: 10px;
    }

    .donate-btn {
        min-width: 160px;
        padding: 10px 16px;
    }

    .navbar-inner {
        padding: 0 12px;
    }

    .navbar-brand span {
        font-size: 1rem;
    }
}

@media (max-width: 400px) {
    .tool-card.large {
        width: 120px;
        height: 120px;
    }

    .bottom-toolbar {
        min-width: unset;
        width: calc(100vw - 10px);
        padding: 8px 10px;
        gap: 8px;
        flex-wrap: wrap;
    }

    .img-action-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Touch target optimization for mobile */
@media (hover: none) {

    .nav-link,
    .drawer-link,
    .dropdown-item {
        min-height: 44px;
    }

    .img-slider {
        height: 6px;
        cursor: pointer;
    }

    .upload-zone {
        min-height: 120px;
    }
}

/* ===============================
   CROP TOOL OVERLAY STYLES
   =============================== */
.crop-dim {
    position: absolute;
    background: rgba(0, 0, 0, 0.6);
    pointer-events: none;
    z-index: 10;
}

#crop-box-el {
    z-index: 11;
    box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.5);
}

.crop-grid-line {
    position: absolute;
    background: rgba(255, 255, 255, 0.5);
    pointer-events: none;
}

.crop-grid-v1 {
    top: 0;
    bottom: 0;
    left: 33.33%;
    width: 1px;
}

.crop-grid-v2 {
    top: 0;
    bottom: 0;
    left: 66.66%;
    width: 1px;
}

.crop-grid-h1 {
    left: 0;
    right: 0;
    top: 33.33%;
    height: 1px;
}

.crop-grid-h2 {
    left: 0;
    right: 0;
    top: 66.66%;
    height: 1px;
}

.crop-h {
    position: absolute;
    width: 14px;
    height: 14px;
    background: #00e5ff;
    border: 2px solid #fff;
    border-radius: 50%;
    z-index: 12;
    transform: translate(-50%, -50%);
}

.crop-h[data-h="nw"] {
    top: 0;
    left: 0;
    cursor: nwse-resize;
}

.crop-h[data-h="n"] {
    top: 0;
    left: 50%;
    cursor: ns-resize;
}

.crop-h[data-h="ne"] {
    top: 0;
    left: 100%;
    cursor: nesw-resize;
}

.crop-h[data-h="e"] {
    top: 50%;
    left: 100%;
    cursor: ew-resize;
}

.crop-h[data-h="se"] {
    top: 100%;
    left: 100%;
    cursor: nwse-resize;
}

.crop-h[data-h="s"] {
    top: 100%;
    left: 50%;
    cursor: ns-resize;
}

.crop-h[data-h="sw"] {
    top: 100%;
    left: 0;
    cursor: nesw-resize;
}

.crop-h[data-h="w"] {
    top: 50%;
    left: 0;
    cursor: ew-resize;
}

/* In mode "ratio", hide the edge handles since we only want corner resizing */
.crop-mode-ratio .crop-h[data-h="n"],
.crop-mode-ratio .crop-h[data-h="e"],
.crop-mode-ratio .crop-h[data-h="s"],
.crop-mode-ratio .crop-h[data-h="w"] {
    display: none;
}

/* ==============================
   MOBILE BOTTOM TOOLBAR REDESIGN
   ============================== */
@media screen and (max-width: 768px) {

    /* Hide the mobile sidebar since we are using a bottom toolbar now */
    .editor-sidebar {
        display: none !important;
    }

    .workspace-container {
        padding-left: 0 !important;
    }

    .desktop-only {
        display: none !important;
    }

    .mobile-only {
        display: flex !important;
    }

    .pdf-scroll-view {
        padding-bottom: 90px !important;
        /* give room for bottom toolbar */
    }

    /* Redesigned Bottom Toolbar */
    .bottom-toolbar:not(.hidden) {
        display: flex !important;
    }

    .bottom-toolbar {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        width: 100%;
        display: none;
        /* Hidden by default until JS shows it */
        justify-content: space-around;
        align-items: center;
        background: rgba(15, 23, 42, 0.9);
        backdrop-filter: blur(16px);
        -webkit-backdrop-filter: blur(16px);
        border-top: 1px solid rgba(255, 255, 255, 0.1);
        border-radius: 16px 16px 0 0;
        padding: 10px 8px;
        z-index: 1000;
        box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.3);
    }

    .bottom-toolbar .toolbar-section {
        display: none;
        /* Hide all other sections like zoom, save */
    }

    .bottom-toolbar .toolbar-section.main-tools {
        display: flex;
        width: 100%;
        justify-content: space-around;
        overflow-x: auto;
        gap: 6px;
    }

    .bottom-toolbar .tool-btn {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 4px;
        padding: 6px;
        background: transparent;
        border: none;
        color: rgba(255, 255, 255, 0.6);
        min-width: 52px;
        border-radius: 12px;
    }

    .bottom-toolbar .tool-btn i {
        font-size: 1.2rem;
        margin-bottom: 2px;
    }

    .bottom-toolbar .tool-btn span {
        font-size: 0.6rem;
        font-weight: 500;
        display: inline-block;
    }

    .bottom-toolbar .tool-btn.active {
        color: #fff;
        background: rgba(255, 255, 255, 0.15);
    }

    .bottom-toolbar .divider {
        display: none;
    }

    .vertical-sep.mobile-only {
        display: block;
        width: 1px;
        height: 30px;
        background: rgba(255, 255, 255, 0.2);
        margin: 0 4px;
        align-self: center;
    }

    /* Mobile "More" Grid Popup */
    .mobile-more-menu {
        position: fixed;
        bottom: 80px;
        left: 50%;
        transform: translateX(-50%) translateY(20px);
        width: 90%;
        max-width: 400px;
        background: rgba(20, 25, 45, 0.95);
        backdrop-filter: blur(20px);
        -webkit-backdrop-filter: blur(20px);
        border: 1px solid rgba(255, 255, 255, 0.15);
        border-radius: 20px;
        padding: 20px;
        z-index: 999;
        box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
        opacity: 0;
        pointer-events: none;
        transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    }

    .mobile-more-menu.show {
        transform: translateX(-50%) translateY(0);
        opacity: 1;
        pointer-events: auto;
    }

    .more-menu-grid {
        display: grid;
        grid-template-columns: repeat(3, 1fr);
        gap: 16px;
    }

    .more-grid-item {
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 8px;
        background: transparent;
        border: none;
        color: #fff;
        cursor: pointer;
        padding: 8px;
        border-radius: 12px;
        transition: background 0.2s;
    }

    .more-grid-item:active {
        background: rgba(255, 255, 255, 0.1);
    }

    .more-grid-item .icon-wrap {
        width: 48px;
        height: 48px;
        border-radius: 14px;
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 1.4rem;
        background: rgba(255, 255, 255, 0.05);
    }

    .more-grid-item span {
        font-size: 0.7rem;
        font-weight: 500;
        color: rgba(255, 255, 255, 0.9);
    }

    /* Vibrant icon colors */
    .color-rotate {
        color: #3b82f6;
        border: 1.5px solid rgba(59, 130, 246, 0.5);
        background: rgba(59, 130, 246, 0.1);
    }

    .color-compress {
        color: #10b981;
        border: 1.5px solid rgba(16, 185, 129, 0.5);
        background: rgba(16, 185, 129, 0.1);
    }

    .color-pagenums {
        color: #f59e0b;
        border: 1.5px solid rgba(245, 158, 11, 0.5);
        background: rgba(245, 158, 11, 0.1);
    }

    .color-resize {
        color: #8b5cf6;
        border: 1.5px solid rgba(139, 92, 246, 0.5);
        background: rgba(139, 92, 246, 0.1);
    }

    .color-redact {
        color: #ef4444;
        border: 1.5px solid rgba(239, 68, 68, 0.5);
        background: rgba(239, 68, 68, 0.1);
    }

    .color-delete {
        color: #f43f5e;
        border: 1.5px solid rgba(244, 63, 94, 0.5);
        background: rgba(244, 63, 94, 0.1);
    }

    .color-extract {
        color: #0ea5e9;
        border: 1.5px solid rgba(14, 165, 233, 0.5);
        background: rgba(14, 165, 233, 0.1);
    }

    .color-watermark {
        color: #06b6d4;
        border: 1.5px solid rgba(6, 182, 212, 0.5);
        background: rgba(6, 182, 212, 0.1);
    }

    .color-info {
        color: #6366f1;
        border: 1.5px solid rgba(99, 102, 241, 0.5);
        background: rgba(99, 102, 241, 0.1);
    }
}