/* CSS Reset and Base Styles */
* { 
    box-sizing: border-box; 
}

/* Suppress mobile Safari context menus and touch callouts */
button,
.toolbtn,
.asset-type-btn,
.asset-action-btn,
.new-asset-btn,
.share-btn,
.download-btn,
.delete-btn,
.dropdown-btn,
.command-btn,
.chip,
.chipbtn,
.library-item,
.asset-card,
.new-asset-card,
.drag-handle,
.dropdown-toggle,
.dropdown-item,
.menu-item,
.intro-continue-button,
[role="button"],
[data-action],
.clickable {
    -webkit-touch-callout: none; /* Prevent callout menu on long press */
    -webkit-tap-highlight-color: transparent; /* Remove tap highlight */
    -webkit-user-select: none; /* Prevent text selection */
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    /* Ensure buttons are clickable and above other elements */
    position: relative;
    z-index: 1;
}

/* Additional mobile Safari specific fixes */
.app {
    -webkit-touch-callout: none;
}

/* Prevent context menu on images and media */
img, video, audio, canvas {
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
}

/* Allow text selection where needed */
input[type="text"],
input[type="search"],
input[type="url"],
input[type="email"],
textarea,
.text-editor,
.CodeMirror,
.editor-preview,
.editor-preview-side,
.text-content {
    -webkit-user-select: text !important;
    -moz-user-select: text !important;
    -ms-user-select: text !important;
    user-select: text !important;
    -webkit-touch-callout: default !important;
}

/* Ensure CodeMirror works properly on mobile */
.CodeMirror {
    -webkit-touch-callout: default !important;
    -webkit-user-select: text !important;
    user-select: text !important;
}

.CodeMirror * {
    -webkit-touch-callout: inherit !important;
    -webkit-user-select: inherit !important;
    user-select: inherit !important;
}

/* Fix for CodeMirror touch selection */
.CodeMirror-lines {
    -webkit-tap-highlight-color: rgba(0, 0, 0, 0.3);
}

/* Ensure proper touch handling for CodeMirror on iOS */
@supports (-webkit-touch-callout: none) {
    .CodeMirror {
        -webkit-overflow-scrolling: touch;
    }
    
    .CodeMirror-scroll {
        -webkit-overflow-scrolling: touch;
    }
    
    /* Force iOS to allow text selection in CodeMirror */
    .CodeMirror-lines,
    .CodeMirror pre,
    .CodeMirror-line,
    .CodeMirror-linewidget {
        -webkit-user-select: text !important;
        -webkit-touch-callout: default !important;
    }
    
    /* Fix for iOS selection handles */
    .CodeMirror-selected {
        background: rgba(0, 122, 255, 0.3) !important;
    }
    
    /* Ensure cursor is visible on mobile */
    .CodeMirror-cursor {
        border-left-width: 2px !important;
        border-left-color: #000 !important;
    }
}

/* Prevent horizontal overflow on mobile */
html, body {
    overflow-x: hidden;
    max-width: 100vw;
    /* Prevent pinch zoom - use manipulation to allow panning but no zoom */
    touch-action: manipulation;
}

/* iOS PWA specific styles */
@supports (padding: env(safe-area-inset-top)) {
    .app {
        padding-top: env(safe-area-inset-top);
        padding-left: env(safe-area-inset-left);
        padding-right: env(safe-area-inset-right);
        padding-bottom: env(safe-area-inset-bottom);
    }
    
    .command-bar {
        padding-bottom: max(16px, env(safe-area-inset-bottom));
    }
}

/* PWA standalone mode adjustments */
@media all and (display-mode: standalone) {
    /* Add any standalone-specific styles here */
}

/* Set up viewport height custom properties with fallbacks */
:root {
    /* Fallback for browsers that don't support new viewport units */
    --vh: 1vh;
    /* Use dynamic viewport height that adjusts with browser chrome */
    --app-height: 100vh;
    --app-height: 100dvh; /* Progressive enhancement */
}

:root {
    /* Color palette from mockup */
    --bg: #f7f7f8;
    --panel: #ffffff;
    --muted: #6b7280;
    --text: #0f172a;
    --border: #e5e7eb;
    --accent: #2563eb;
    --accent-2: #111827;
    --chip: #eef2ff;
    --chip-text: #3730a3;
    --chip-border: #e0e7ff;
    --expiry-bg: #fafafa;
    --focus-ring: #dbeafe;
    --focus-bg: #f8fafc;
    
    /* Shadows */
    --shadow: 0 1px 2px rgba(0,0,0,.06), 0 4px 24px rgba(0,0,0,.06);
    --shadow-button: 0 1px 0 rgba(0,0,0,.02);
    --shadow-send: 0 8px 24px rgba(37,99,235,.35);
    --shadow-preview: 0 10px 30px rgba(0,0,0,.2);
    
    /* Border radius */
    --radius: 14px;
    --radius-sm: 8px;
    --radius-xs: 6px;
    --radius-pill: 999px;
    --radius-lg: 12px;
    --radius-xl: 10px;
}

html, body { 
    height: 100%; 
    margin: 0;
}

body {
    font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Apple Color Emoji", "Segoe UI Emoji";
    font-size: 14px;
    line-height: 1.35;
    color: var(--text);
    background: var(--bg);
}

/* App Layout */
.app {
    display: grid;
    grid-template-columns: 1fr 320px;
    grid-template-rows: 1fr; /* Just content, command bar is fixed */
    gap: 0;
    height: 100vh;
    height: 100dvh; /* Use dynamic viewport height */
    position: relative;
    /* Prevent pinch zoom on app container */
    touch-action: manipulation;
    overflow: hidden; /* Hide overflowing command bar when sliding */
}

.editor-pane {
    grid-column: 1 / 2;
    grid-row: 1 / 2;
    display: flex;
    flex-direction: column;
    overflow: hidden; /* Contain the editor */
    position: relative; /* Establish positioning context for dropdown menus */
    width: 100%;
    max-width: 100vw; /* Prevent expanding beyond viewport */
    height: 100%;
}

.library-pane {
    grid-column: 2 / 3;
    grid-row: 1 / 2;
    border-left: 1px solid var(--border);
    background: var(--panel);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    padding-bottom:74px;
}

.commandbar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    border-top: 1px solid var(--border);
    background: var(--panel);
    z-index: 100;
    transform: translateY(calc(100% + 1px)); /* Add 1px to hide border */
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.commandbar.visible {
    transform: translateY(0);
}

/* Topbar removed - all functionality moved to asset tiles */


/* Text Statistics in Editor */
.editor-stats {
    position: absolute;
    bottom: 12px;
    right: 12px;
    font-size: 11px;
    color: var(--muted);
    background: var(--bg);
    border: 1px solid var(--border);
    padding: 4px 8px;
    border-radius: var(--radius-pill);
    white-space: nowrap;
    z-index: 100;
    font-weight: 500;
    pointer-events: none;
    backdrop-filter: blur(8px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    opacity: 0.95;
}


.editor-stats:empty {
    display: none;
}

/* Pulsing animation for critical countdown - COMMENTED OUT: Expiration display disabled */
/*
.expiry.critical.pulse {
    animation: pulse-critical 2s infinite;
}

@keyframes pulse-critical {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}
*/

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

/* Download Menu */
.download,
.asset-menu {
    position: relative;
    display: inline-block;
}

.menu {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 4px;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow);
    z-index: 100;
    min-width: 160px;
}

/* Asset tile export menu positioning */
.asset-actions .menu {
    top: 100%;
    right: 0;
    margin-top: 2px;
    z-index: 200;
}

.menu button {
    display: block;
    width: 100%;
    padding: 8px 12px;
    border: none;
    background: none;
    color: var(--text);
    font-size: 13px;
    text-align: left;
    cursor: pointer;
    transition: background-color 0.15s ease;
}

.menu button:hover {
    background: var(--focus-bg);
}

.menu button:first-child {
    border-radius: var(--radius-sm) var(--radius-sm) 0 0;
}

.menu button:last-child {
    border-radius: 0 0 var(--radius-sm) var(--radius-sm);
}

.menu.hidden {
    display: none;
}

/* Universal ribbon layout */
#universal-ribbon {
    display: flex;
    align-items: center;
    width: 100%;
    max-width: 100vw; /* Prevent expanding beyond viewport */
    position: relative;
    overflow: visible !important; /* Allow dropdowns to show */
    z-index: 51; /* Above canvas content */
}

.asset-tools {
    display: flex;
    gap: 10px;
    align-items: center;
    flex: 1 1 auto;
    overflow-x: auto;
    overflow-y: visible !important; /* Allow dropdowns to overflow vertically */
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    scroll-behavior: smooth;
    position: relative; /* Positioning context for dropdowns */
}

/* Hide scrollbar on mobile but keep functionality */
@media (max-width: 860px) {
    .asset-tools::-webkit-scrollbar {
        display: none;
    }
    .asset-tools {
        scrollbar-width: none;
    }
}

.ribbon-spacer {
    flex: 1;
}

.ribbon-content {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-shrink: 0; /* Prevent shrinking */
}

.ribbon-content.hidden {
    display: none;
}

.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    background: #fff;
    color: var(--accent-2);
    box-shadow: var(--shadow);
    cursor: pointer;
    user-select: none;
    font-size: 14px;
    font-family: inherit;
    transition: all 0.15s ease;
}

.btn:hover {
    background: var(--focus-bg);
}

.btn.secondary {
    background: var(--accent-2);
    color: #fff;
    border-color: transparent;
}

.btn.secondary:hover {
    background: #374151;
}

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

/* Ribbon */
.ribbon {
    background: var(--panel);
    border-bottom: 1px solid var(--border);
    padding: 8px 12px;
    display: flex;
    gap: 10px;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 100;
    overflow: visible !important; /* Allow dropdown to overflow */
}

/* Allow ribbon overflow to show dropdowns */
.ribbon:has(.dropdown-menu:not(.hidden)) {
    overflow: visible !important;
    z-index: 101;
}

.toolgroup {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding-right: 10px;
    border-right: 1px solid var(--border);
}

.toolgroup:last-child {
    border-right: none;
}

.toolbtn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: #fff;
    box-shadow: var(--shadow-button);
    cursor: pointer;
    transition: all 0.15s ease;
}

.toolbtn:hover {
    background: var(--focus-bg);
}

.toolbtn svg {
    width: 16px;
    height: 16px;
}

/* Dropdown buttons - ensure proper icon sizing */
.dropdown-btn {
    width: auto;
    gap: 0px;
}

.dropdown-btn > svg:first-child {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

.toolbtn[aria-pressed="true"] {
    outline: 2px solid var(--focus-ring);
    background: var(--focus-bg);
}

/* Dropdown styles */
.dropdown-container {
    position: relative;
    display: inline-block;
    z-index: auto; /* Let the menu handle z-index */
}

/* Ensure dropdowns can overflow the ribbon */
.ribbon .dropdown-container,
.ribbon .brightness-control,
.ribbon .resize-control,
.ribbon .contrast-control,
.ribbon .saturation-control {
    position: relative;
}

.dropdown-btn {
    display: flex;
    align-items: center;
    gap: 0px;
}

.heading-icon {
    font-weight: 700;
    font-size: 14px;
    line-height: 1;
    color: currentColor;
}
.capitalization-icon {
    font-weight: 600;
    font-size: 14px;
    line-height: 1;
    color: currentColor;
}

.dropdown-arrow {
    width: 12px;
    height: 12px;
    transition: transform 0.2s;
}

.dropdown-btn[aria-expanded="true"] .dropdown-arrow {
    transform: rotate(180deg);
}

.dropdown-menu {
    position: fixed; /* Use fixed positioning to escape overflow constraints */
    z-index: 10000; /* Very high z-index to ensure it's above everything */
    min-width: 120px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    padding: 4px;
    margin-top: 2px;
    max-height: calc(100vh - 100px); /* Prevent dropdown from going off screen */
    max-height: calc(100dvh - 100px); /* Use dynamic viewport height */
    overflow-y: auto;
}

.dropdown-item {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 6px 8px;
    border: none;
    background: transparent;
    color: var(--text);
    font-size: 13px;
    border-radius: var(--radius-xs);
    cursor: pointer;
    transition: background-color 0.15s;
}

.dropdown-item:hover {
    background: var(--hover);
}

.dropdown-item:active {
    background: var(--accent);
    color: white;
}

.heading-preview {
    font-weight: 600;
    font-size: 11px;
    color: var(--muted);
    width: 20px;
    text-align: left;
}
.case-preview {
    font-weight: 600;
    font-size: 11px;
    color: var(--muted);
    width: 35px;
    text-align: left;
}
.tone-icon, .length-icon {
    width: 16px;
    height: 16px;
    display: inline-block;
    flex-shrink: 0;
}

.tone-icon svg, .length-icon svg {
    width: 100%;
    height: 100%;
}


/* Editor Canvas */
.canvas {
    padding: 0px;
    overflow: hidden; /* Prevent scrolling - editors handle their own scrolling */
    background: var(--bg);
    position: relative;
    flex: 1;
    min-height: 0;
    width: 100%;
    max-width: 100%;
    z-index: 1;
    display: flex;
    flex-direction: column;
}

.artboard {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    width: min(860px, 92%);
    margin: 24px auto;
    padding: 20px;
    position: relative;
    min-height: 400px;
}

/* Canvas placeholder - allow scrolling for empty state */
#canvas-placeholder {
    position: relative;
    width: 100%;
    height: 100%;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    transition: padding-bottom 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Add padding to placeholder when command bar is visible */
body:has(.commandbar.visible) #canvas-placeholder {
    padding-bottom: 60px;
}

/* Modern AI aesthetic - full editor area */
.artboard.canvas-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    min-height: 100%;
    padding: 2rem;
    position: relative;
    background: transparent;
    border: none;
    border-radius: 0;
    box-shadow: none;
    margin: 0;
    z-index: 1;
    pointer-events: auto;
    overflow: visible; /* Let parent canvas handle scrolling */
}

/* Make canvas take full width when library is hidden */
@media (min-width: 769px) {
    .app:has(.library-pane[style*="display: none"]) .canvas {
        margin-right: 0;
    }
}

/* Editor containers always account for command bar */
#text-editor-container,
#table-editor-container,
#image-editor-container,
#audio-editor-container {
    bottom: 74px; /* Height of command bar */
}

/* Removed canvas-placeholder-wrapper - no longer needed */

/* AI-style gradient background */
.canvas::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    min-height: 100%;
    background: 
        radial-gradient(ellipse at 20% 0%, rgba(99, 102, 241, 0.15) 0%, transparent 40%),
        radial-gradient(ellipse at 80% 50%, rgba(139, 92, 246, 0.12) 0%, transparent 40%),
        radial-gradient(circle at 50% 100%, rgba(59, 130, 246, 0.08) 0%, transparent 60%);
    pointer-events: none;
}

/* Animated gradient orb */
.canvas::after {
    content: '';
    position: fixed; /* Fixed so it stays in viewport */
    width: 600px;
    height: 600px;
    background: radial-gradient(circle, rgba(124, 58, 237, 0.08) 0%, rgba(99, 102, 241, 0.05) 40%, transparent 70%);
    border-radius: 50%;
    top: -200px;
    right: -150px;
    animation: float-orb 30s ease-in-out infinite;
    pointer-events: none;
}

@keyframes float-orb {
    0%, 100% { transform: translate(0, 0) scale(1) rotate(0deg); }
    25% { transform: translate(-80px, 60px) scale(1.1) rotate(90deg); }
    50% { transform: translate(40px, -40px) scale(0.9) rotate(180deg); }
    75% { transform: translate(-60px, -80px) scale(1.05) rotate(270deg); }
}

/* Canvas Placeholder */
.canvas-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    color: var(--text);
    padding: var(--spacing-2xl);
    height: 100%;
    position: relative;
    z-index: 1;
}

.placeholder-content {
    width: 100%;
    max-width: 1000px; /* Wider max width to fill editor */
    margin: 0 auto;
    padding: 2rem;
    position: relative;
    z-index: 2;
    text-align: center;
}

/* Center the description text */
#empty-state-description {
    text-align: center;
}

/* Modern AI product typography - larger for full editor */
#empty-state-title {
    font-size: 72px;
    font-weight: 800;
    margin-bottom: 24px;
    letter-spacing: -0.03em;
    line-height: 1;
}

/* FullSpark Logo SVG Styles */
.fullspark-logo {
    width: 40px;
    height: 40px;
    display: inline-block;
    vertical-align: middle;
    animation: pulse-glow 2.5s ease-in-out infinite;
}

/* FullSpark text styling */
#empty-state-title .full-text {
    color: #8b5cf6;
    font-weight: 800;
}

#empty-state-title .spark-text {
    color: #1e293b;
    font-weight: 800;
}

.fullspark-logo .lightning-bolt {
    filter: drop-shadow(0 1px 3px rgba(99, 102, 241, 0.3));
}

/* Simple pulsing effect */
@keyframes pulse-glow {
    0%, 100% {
        transform: scale(1);
        filter: drop-shadow(0 0 0 rgba(99, 102, 241, 0));
    }
    50% {
        transform: scale(1.05);
        filter: drop-shadow(0 0 8px rgba(139, 92, 246, 0.5));
    }
}

/* Hover effect */
#empty-state-title:hover .fullspark-logo {
    animation: none;
    transform: scale(1.1);
    filter: drop-shadow(0 0 12px rgba(139, 92, 246, 0.7));
}

#empty-state-description {
    font-size: 24px;
    line-height: 1.6;
    color: #64748b;
    margin-bottom: 64px;
    font-weight: 400;
    letter-spacing: -0.01em;
    text-align: center;
}

.placeholder-content h2 {
    font-size: 36px;
    font-weight: 700;
    margin-bottom: 24px;
    letter-spacing: -0.02em;
    line-height: 1.2;
    color: var(--text);
}

.placeholder-content p {
    font-size: 18px;
    line-height: 1.7;
    color: #64748b;
    margin-bottom: 32px;
    font-weight: 400;
}

.placeholder-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
}

.canvas-placeholder h2 {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--text);
}

.canvas-placeholder p {
    margin: 0 auto 8px auto;
    max-width: 32rem;
    color: var(--muted);
}

/* New user introduction styles */
.new-user-intro {
    margin-bottom: 24px;
    
}

.intro-main {
    font-size: 16px;
    color: var(--text);
    margin-bottom: 20px !important;
    text-align: center;
}

.intro-features {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 32px;
    margin: 48px auto;
    max-width: 900px;
}

.feature {
    display: flex;
    align-items: center;
    gap: 10px;
    text-align: left;
    padding: 12px 16px;
    background: var(--bg);
    border-radius: var(--radius);
    border: 1px solid var(--border);
}

.intro-feature {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    text-align: center;
    padding: 32px;
    border-radius: 16px;
    transition: all 0.3s ease;
    background: white;
    border: 1px solid rgba(0, 0, 0, 0.1);
}

.intro-feature:hover {
    background: white;
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(99, 102, 241, 0.1);
    border-color: #6366f1;
}

.feature-icon {
    flex-shrink: 0;
    width: 64px;
    height: 64px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border-radius: 0;
    transition: all 0.3s ease;
}

.feature-icon svg {
    width: 32px;
    height: 32px;
    color: #6366f1;
    transition: all 0.3s ease;
}

.intro-feature:hover .feature-icon {
    background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
    transform: scale(1.05);
}

.intro-feature:hover .feature-icon svg {
    color: white;
}

/* Add subtle rotation animation to AI icon on hover */
.intro-feature:nth-child(1):hover .feature-icon svg {
    animation: rotate-pulse 2s ease-in-out infinite;
}

/* Add subtle pulse animation to shield icon on hover */
.intro-feature:nth-child(2):hover .feature-icon svg {
    animation: shield-pulse 2s ease-in-out infinite;
}

/* Add lightning animation to share icon on hover */
.intro-feature:nth-child(3):hover .feature-icon svg {
    animation: lightning-pulse 1.5s ease-in-out infinite;
}

@keyframes rotate-pulse {
    0%, 100% { transform: rotate(0deg) scale(1); }
    50% { transform: rotate(180deg) scale(1.1); }
}

@keyframes shield-pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.15); }
}

@keyframes lightning-pulse {
    0%, 100% { transform: translateX(0) scale(1); }
    25% { transform: translateX(-2px) scale(1.05); }
    75% { transform: translateX(2px) scale(1.05); }
}

.feature-text {
    font-size: 16px;
    color: #64748b;
    line-height: 1.6;
    font-weight: 400;
}

.feature-text strong {
    font-weight: 600;
    color: #1e293b;
    letter-spacing: -0.01em;
}

/* Continue button for new users */
.intro-continue-button {
    margin-top: 3rem;
    padding: 1rem 3rem;
    font-size: 1.125rem;
    font-weight: 600;
    color: white;
    background: #6366f1; /* Explicit purple color for consistency */
    border: 1px solid transparent; /* Prevent layout shift on hover */
    border-radius: 2rem;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
    z-index: 10;
    letter-spacing: -0.01em;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    /* Prevent iOS text selection on button */
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
}

.intro-continue-button svg {
    width: 1.25rem;
    height: 1.25rem;
    transition: transform 0.2s ease;
}

.intro-continue-button:hover {
    background: #5558e3; /* Slightly darker purple for better contrast */
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(99, 102, 241, 0.35);
    border: 1px solid rgba(99, 102, 241, 0.3);
}

.intro-continue-button:hover svg {
    transform: translateX(2px);
}

.intro-continue-button:active {
    transform: scale(1);
}

/* Removed duplicate hover state */

/* Removed duplicate active state */

.create-section-intro h3 {
    font-size: 16px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 16px;
    text-align: center;
}

/* Enhanced Empty State Styles */
.clipboard-suggestions {
    /* Base container - styling will be applied via clipboard-suggestion-box class */
}

.clipboard-suggestions h3 {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 1rem;
    color: var(--text);
}

.clipboard-options {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.clipboard-btn {
    display: flex;
    align-items: center;
    padding: 0.75rem 1rem;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: left;
}

.clipboard-btn:hover {
    background: var(--focus-bg);
    border-color: var(--accent);
}

.clipboard-btn-icon {
    width: 1.25rem;
    height: 1.25rem;
    margin-right: 0.75rem;
    color: var(--muted);
    flex-shrink: 0;
}

.clipboard-btn:hover .clipboard-btn-icon {
    color: var(--accent);
}

.clipboard-btn-content {
    flex: 1;
}

.clipboard-btn-title {
    font-weight: 600;
    color: var(--text);
    margin-bottom: 0.25rem;
}

.clipboard-btn-description {
    font-size: 12px;
    color: var(--muted);
}

.clipboard-permission-btn {
    border-color: var(--accent);
    background: var(--chip);
}

.clipboard-permission-btn:hover {
    background: var(--focus-ring);
    border-color: var(--accent);
}

/* Clipboard prompt for user-initiated check */
.clipboard-prompt {
    text-align: center;
    padding: 1.5rem;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    margin-bottom: 1.5rem;
}

.clipboard-prompt p {
    margin-bottom: 1rem;
    color: var(--text);
    font-size: 14px;
}

.clipboard-prompt .btn {
    padding: 8px 20px;
}

/* Refined Clipboard Suggestion Layout */
.clipboard-suggestion-box {
    width: min(480px, 100%); /* Prefer 480px but allow responsiveness */
    max-width: 480px; /* Cap at 480px when space allows */
    height: 320px; /* Fixed height for all suggestions */
    margin: 0 auto 1.5rem;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 1.25rem;
    box-shadow: var(--shadow);
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    flex-direction: column;
}

.clipboard-suggestion-box:hover {
    border-color: var(--accent);
    box-shadow: var(--shadow), 0 0 0 3px var(--focus-ring);
}

.clipboard-suggestion-box:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: var(--shadow), 0 0 0 3px var(--focus-ring);
}

.clipboard-suggestion-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1rem;
    flex-shrink: 0; /* Don't let header shrink */
}

.clipboard-suggestion-icon {
    flex-shrink: 0;
    width: 20px;
    height: 20px;
    color: var(--muted);
}

.clipboard-suggestion-icon svg {
    width: 100%;
    height: 100%;
}

.clipboard-suggestion-title {
    font-weight: 500;
    font-size: 14px;
    color: var(--text);
    line-height: 1.2;
}

.clipboard-suggestion-preview {
    flex: 1; /* Take remaining space in the flex container */
    min-height: 240px; /* Force minimum height to fill available space */
    max-height: 240px; /* Also set max height to prevent overflow */
    width: 100%;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-xs);
    padding: 0.75rem;
    overflow: hidden;
    display: flex;
    align-items: stretch; /* Allow content to fill vertical space */
    justify-content: flex-start; /* Left-align by default (good for text) */
    position: relative; /* For better image containment */
    /* Height will be approximately 240px after header, padding, and margins */
}

/* Center images specifically, but keep text left-aligned */
.clipboard-suggestion-preview img {
    margin: auto; /* This will center the image within the flex container */
}

/* Ensure text content is left-aligned and takes full width */
.clipboard-suggestion-preview .clipboard-preview-text,
.clipboard-suggestion-preview .clipboard-preview-table {
    width: 100%;
    text-align: left;
}

/* Removed - whole box is now clickable */

/* Preview Content Styling */
.clipboard-preview-image {
    max-width: 100%;
    max-height: 220px; /* Explicit height constraint to prevent overflow */
    width: auto;
    height: auto;
    object-fit: contain;
    border-radius: var(--radius-xs);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.clipboard-preview-table {
    width: 100%;
    font-size: 11px;
    line-height: 1.2;
    border-collapse: collapse;
    margin: 0; /* Remove any default margin */
    max-height: 220px; /* Increased to accommodate more rows */
    overflow: hidden; /* Hide overflow content */
    background: #ffffff; /* White background for entire table */
}

.clipboard-preview-table th {
    background: var(--panel);
    border: 1px solid var(--border);
    padding: 0.25rem 0.375rem;
    font-weight: 500;
    color: var(--text);
    text-align: left;
    font-size: 10px;
}

.clipboard-preview-table td {
    border: 1px solid var(--border);
    padding: 0.25rem 0.375rem;
    color: var(--muted);
    font-size: 10px;
    background: #ffffff; /* White background for table cells */
}

.clipboard-preview-table .more-rows {
    text-align: center;
    font-style: italic;
    color: var(--muted);
}

.clipboard-preview-text {
    width: 100%;
    height: 100%; /* Fill the available vertical space */
    max-height: 100%; /* Ensure it doesn't exceed container */
    font-size: 12px; /* Slightly larger for the bigger preview */
    line-height: 1.4;
    color: var(--muted);
    overflow: hidden;
    overflow-y: auto; /* Allow scrolling if content is too long */
    word-wrap: break-word;
    word-break: break-word; /* Break long words if needed */
    display: block; /* Change from flex to block for better text flow */
    padding-right: 4px; /* Space for scrollbar */
    scrollbar-width: thin; /* Firefox */
    scrollbar-color: var(--border) transparent; /* Firefox */
}

/* Webkit scrollbar styling */
.clipboard-preview-text::-webkit-scrollbar {
    width: 6px;
}

.clipboard-preview-text::-webkit-scrollbar-track {
    background: transparent;
}

.clipboard-preview-text::-webkit-scrollbar-thumb {
    background-color: var(--border);
    border-radius: 3px;
}

.clipboard-preview-text::-webkit-scrollbar-thumb:hover {
    background-color: var(--muted);
}

.clipboard-preview-markdown {
    /* Markdown-specific styling for better formatting */
}

.clipboard-preview-markdown strong {
    font-weight: 600;
    color: var(--text);
}

.clipboard-preview-markdown em {
    font-style: italic;
}

.clipboard-preview-markdown code {
    background: var(--chip);
    padding: 0.125rem 0.25rem;
    border-radius: 3px;
    font-family: ui-monospace, 'SF Mono', 'Monaco', 'Cascadia Code', 'Roboto Mono', 'Consolas', monospace;
    font-size: 10px;
}

.clipboard-preview-empty {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    font-size: 11px;
    color: var(--muted);
    font-style: italic;
}

/* Safari clipboard button styles */
.safari-clipboard-prompt {
    padding: 16px;
    text-align: left;
    min-height: auto;
    display: flex;
    align-items: center;
    gap: 12px;
}

/* Safari paste hint styles */
.safari-paste-hint-wrapper {
    height: 20px; /* Reserve space to prevent layout shift */
    margin-top: 16px;
    margin-bottom: 0;
    text-align: center;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.safari-paste-hint-wrapper.show {
    opacity: 1;
}

.safari-hint-text {
    font-size: 12px;
    color: var(--muted);
    opacity: 0.5; /* Fainter text */
}

.safari-hint-text kbd {
    display: inline-block;
    padding: 2px 4px;
    margin: 0 2px;
    background: white;
    border: 1px solid var(--border);
    border-radius: 3px;
    font-family: monospace;
    font-size: 11px;
    box-shadow: 0 1px 0 rgba(0,0,0,0.03);
}

.create-asset-section {
    margin-top: 2rem;
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.create-asset-section h3 {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 1.5rem;
    color: var(--text);
}

.asset-type-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.75rem;
    margin-bottom: 2rem;
    max-width: 480px; /* Fit 4 buttons comfortably */
    margin-left: auto;
    margin-right: auto;
}

.asset-type-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 1rem 0.5rem;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: center;
    box-shadow: var(--shadow);
    min-height: 80px;
}

.asset-type-btn:hover {
    background: var(--focus-bg);
    border-color: var(--accent);
    transform: translateY(-1px);
    box-shadow: var(--shadow-preview);
}

.asset-type-btn:active {
    transform: translateY(0);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.1);
}

.asset-icon {
    width: 48px;
    height: 48px;
    color: #6366f1;
    stroke-width: 1.5;
}

.asset-type-btn:hover .asset-icon {
    color: var(--accent);
}

.asset-label {
    font-size: 18px;
    font-weight: 600;
    color: #0f172a;
    letter-spacing: -0.01em;
}

.asset-description {
    font-size: 14px;
    color: #64748b;
    line-height: 1.5;
    margin-top: 8px;
    display: block;
}

/* Descriptions always visible in full-width design */

.auto-save-note {
    font-size: 12px;
    color: var(--muted);
    margin-top: 2rem;
    margin-bottom: 0;
}

/* Image Mock (from original mockup) */
.image-mock {
    width: 720px;
    height: 420px;
    border-radius: var(--radius);
    background: linear-gradient(180deg, #dbeafe, #bfdbfe);
    position: relative;
    overflow: hidden;
    display: grid;
    place-items: center;
    color: #0b3a75;
    font-weight: 600;
    letter-spacing: .02em;
}

.image-mock:before {
    content: "";
    position: absolute;
    border: 2px dashed rgba(17,24,39,.25);
    inset: 18px;
    border-radius: 12px;
}

.handle {
    position: absolute;
    width: 10px;
    height: 10px;
    background: #fff;
    border: 2px solid var(--accent);
    border-radius: var(--radius-pill);
    box-shadow: 0 2px 6px rgba(0,0,0,.2);
}

.h-tl { top: 12px; left: 12px; }
.h-tr { top: 12px; right: 12px; }
.h-bl { bottom: 12px; left: 12px; }
.h-br { bottom: 12px; right: 12px; }

.preview-bar {
    position: absolute;
    bottom: -18px;
    left: 50%;
    transform: translateX(-50%);
    display: inline-flex;
    gap: 10px;
    background: var(--accent-2);
    color: #fff;
    padding: 10px 14px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-preview);
}

.preview-bar .pbtn {
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background 0.15s ease;
}

.preview-bar .pbtn:hover {
    background: rgba(255,255,255,0.1);
}

.preview-bar .pbtn.secondary {
    background: #fff;
    color: var(--accent-2);
}

.preview-bar .pbtn.secondary:hover {
    background: var(--focus-bg);
}

/* Library Pane */
.library-header {
    padding: 12px 14px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.library-header h3 {
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: var(--muted);
    margin: 0;
    font-weight: 600;
}

.library-content {
    flex: 1;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.library-list {
    padding: 10px;
    padding-bottom: 0; /* Remove bottom padding to prevent overlap with footer */
    overflow: auto;
    display: flex;
    flex-direction: column;
    gap: 10px;
    flex: 1;
    align-content: flex-start;
    /* Ensure last item has space before footer */
    padding-bottom: 10px;
}

.asset-item {
    display: grid;
    grid-template-columns: 48px 1fr;
    align-items: start;
    gap: 10px;
    padding: 8px;
    min-height: 56px;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: #fff;
    cursor: pointer;
    transition: all 0.15s ease;
}

.asset-item:hover {
    box-shadow: var(--shadow);
    border-color: var(--focus-ring);
}

.asset-item.selected {
    border-color: var(--accent);
    box-shadow: 0 0 0 1px var(--accent);
}

/* Asset tile actions for selected asset */
.asset-actions {
    position: absolute;
    bottom: 4px;
    right: 8px;
    display: flex;
    gap: 4px;
    opacity: 0;
    transition: opacity 0.15s ease;
}

.asset-item:hover .asset-actions,
.asset-item.selected .asset-actions {
    opacity: 1;
}

.asset-action-btn {
    width: 24px;
    height: 24px;
    border: 1px solid var(--border);
    border-radius: var(--radius-xs);
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(8px);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
    color: var(--muted);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.asset-action-btn:hover {
    background: var(--panel);
    color: var(--text);
    border-color: var(--accent);
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.asset-action-btn svg {
    width: 12px;
    height: 12px;
}

.asset-action-btn.delete-btn {
    color: #dc2626;
    border-color: #fecaca;
}

.asset-action-btn.delete-btn:hover {
    background: #fef2f2;
    color: #dc2626;
    border-color: #dc2626;
}

.asset-item {
    position: relative;
}

/* Shared asset subtitle styling */
.sub-shared {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #1976D2;
}

.sub-shared svg {
    width: 12px;
    height: 12px;
    stroke: currentColor;
    flex-shrink: 0;
}

/* Time ago indicator */
.time-ago {
    color: var(--muted);
    font-size: 12px;
}

/* Share countdown styling */
.share-countdown {
    font-size: 11px;
    padding: 2px 6px;
    border-radius: 3px;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.share-countdown svg {
    width: 12px;
    height: 12px;
    stroke: currentColor;
    flex-shrink: 0;
}

/* Color-coded countdown backgrounds */
.share-countdown.share-green {
    background: rgba(34, 197, 94, 0.1);
    color: rgb(34, 197, 94);
}

.share-countdown.share-yellow {
    background: rgba(251, 191, 36, 0.1);
    color: rgb(217, 119, 6);
}

.share-countdown.share-red {
    background: rgba(239, 68, 68, 0.1);
    color: rgb(220, 38, 38);
}

.share-countdown.expired {
    background: rgba(220, 38, 38, 0.1);
    color: rgb(220, 38, 38);
}

/* New Asset Button */
.new-asset-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 12px;
    border: 1px dashed var(--accent);
    border-radius: var(--radius-lg);
    background: rgba(37, 99, 235, 0.05);
    color: var(--accent);
    cursor: pointer;
    transition: all 0.15s ease;
    font-weight: 500;
    margin-bottom: 0;
    width: 100%;
    font-family: inherit;
    font-size: 14px;
    height: 52px; /* Match asset item height */
}

.new-asset-btn:hover {
    background: rgba(37, 99, 235, 0.1);
    border-style: solid;
    transform: translateY(-1px);
    box-shadow: var(--shadow);
}

.new-asset-btn svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

.new-asset-btn span {
    flex-shrink: 0;
}

/* New Asset Dropdown */
.new-asset-dropdown {
    position: relative;
    padding: 0 10px; /* Match library-list padding */
    margin-top: 10px; /* Gap above New button from header */
    margin-bottom: 10px; /* Gap between New button and asset list */
    z-index: 10; /* Ensure it's above other content */
}

.dropdown-arrow {
    width: 14px;
    height: 14px;
    flex-shrink: 0;
    transition: transform 0.2s ease;
}

.new-asset-dropdown.open .dropdown-arrow {
    transform: rotate(180deg);
}

.new-asset-menu {
    position: absolute;
    left: 0;
    right: 0;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    z-index: 1000;
    overflow: hidden;
    margin-top: 0;
    margin-bottom: 0;
}

.new-asset-menu.hidden {
    display: none;
}

.menu-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    width: 100%;
    border: none;
    background: transparent;
    color: var(--text);
    cursor: pointer;
    transition: background 0.15s ease;
    font-family: inherit;
    font-size: 14px;
    font-weight: 500;
}

.menu-item:hover {
    background: var(--focus-bg);
}

.menu-item:not(:last-child) {
    border-bottom: 1px solid var(--border);
}

.menu-item svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

.thumb {
    width: 48px;
    height: 36px;
    border-radius: var(--radius-sm);
    background: linear-gradient(180deg, #e5e7eb, #f3f4f6);
    display: grid;
    place-items: center;
    font-size: 10px;
    color: var(--muted);
    font-weight: 600;
    letter-spacing: 0.05em;
}

.thumb svg {
    width: 16px;
    height: 16px;
}

.library-footer {
    padding: 8px 16px;
    border-top: 1px solid var(--border);
    text-align: center;
    margin-top: auto;
    flex-shrink: 0; /* Prevent footer from shrinking */
    background: var(--panel); /* Ensure footer has background */
    position: relative; /* Ensure footer stays above content */
    z-index: 1; /* Keep footer above scrolling content */
}

/* macOS paste area for native clipboard formats */
.macos-paste-area {
    min-height: 120px;
    border: 2px dashed var(--border);
    border-radius: var(--radius-lg);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    background: var(--bg);
    outline: none;
}

.macos-paste-area:hover {
    border-color: var(--accent);
    background: var(--hover);
}

.macos-paste-area:focus {
    border-color: var(--accent);
    border-style: solid;
    background: var(--hover);
}

.macos-paste-area .paste-hint {
    font-size: 14px;
    color: var(--text);
    margin-bottom: 8px;
}

.macos-paste-area .paste-subhint {
    font-size: 12px;
    color: var(--muted);
}

.macos-paste-area kbd {
    display: inline-block;
    padding: 2px 6px;
    font-size: 12px;
    font-family: var(--font-mono);
    background: var(--chip);
    border: 1px solid var(--border);
    border-radius: 4px;
    box-shadow: 0 1px 0 rgba(0,0,0,0.1);
}

.meta {
    min-width: 0;
    padding-top: 2px;
}

.meta .name {
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 2px;
}

/* Inline name editing */
.asset-name-input {
    font-weight: 600;
    font-size: inherit; /* Inherit from parent */
    line-height: inherit; /* Inherit line height */
    font-family: inherit;
    color: inherit;
    background: transparent;
    border: 1px solid var(--accent);
    border-radius: 4px;
    padding: 1px 4px;
    margin: -2px -5px;
    width: calc(100% + 10px);
    max-width: 200px;
    outline: none;
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.2);
}

.asset-name-input:focus {
    background: white;
}

.asset-item.editing .asset-name {
    cursor: text;
}

.asset-item.editing {
    z-index: 10;
}

/* Indicate name is clickable for selected asset */
.asset-item.selected .asset-name {
    cursor: pointer;
    transition: color 0.15s ease;
}

.asset-item.selected .asset-name:hover {
    color: var(--accent);
}

.meta .sub {
    font-size: 12px;
    color: var(--muted);
}

.chip {
    padding: 2px 8px;
    font-size: 11px;
    border-radius: var(--radius-pill);
    background: var(--chip);
    color: var(--chip-text);
    border: 1px solid var(--chip-border);
    white-space: nowrap;
    font-weight: 500;
}

/* Expiry chip states for asset tiles - COMMENTED OUT: Expiration display disabled */
/*
.chip.expiry-normal {
    background: #f0fdf4;
    border-color: #bbf7d0;
    color: #166534;
}

.chip.expiry-warning {
    background: #fffbeb;
    border-color: #fed7aa;
    color: #ea580c;
}

.chip.expiry-critical {
    background: #fef2f2;
    border-color: #fecaca;
    color: #dc2626;
    animation: pulse-critical 2s infinite;
}

.chip.expiry-expired {
    background: #f3f4f6;
    border-color: #d1d5db;
    color: var(--muted);
}
*/

/* Share status chip */
.chip.shared {
    background: #e3f2fd;
    border-color: #bbdefb;
    color: #1565c0;
}

/* Command Bar */
.commandbar {
    padding: 10px 14px;
    display: flex;
    gap: 10px;
    align-items: center;
}

.command-input {
    flex: 1;
    display: flex;
    gap: 10px;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: var(--radius-pill);
    padding: 8px 12px;
    align-items: center;
    box-shadow: var(--shadow);
    transition: all 0.15s ease;
}

.command-input:focus-within {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.command-input input {
    flex: 1;
    border: none;
    outline: none;
    font-size: 14px;
    font-family: inherit;
    color: var(--text);
}

.command-input input::placeholder {
    color: var(--muted);
}

.send {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-pill);
    border: none;
    background: var(--accent);
    color: #fff;
    display: grid;
    place-items: center;
    box-shadow: var(--shadow-send);
    cursor: pointer;
    transition: all 0.15s ease;
}

.send:hover {
    background: #1d4ed8;
    transform: translateY(-1px);
}

.send:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.send svg {
    width: 16px;
    height: 16px;
}

.chips {
    display: flex;
    gap: 8px;
    padding: 0 6px 6px 6px;
    flex-wrap: wrap;
}

.chipbtn {
    border: 1px dashed var(--border);
    background: #fff;
    color: var(--muted);
    padding: 6px 10px;
    font-size: 12px;
    border-radius: var(--radius-pill);
    cursor: pointer;
    transition: all 0.15s ease;
    font-family: inherit;
}

.chipbtn:hover {
    border-color: var(--accent);
    color: var(--accent);
    background: var(--chip);
}

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

/* Icons */
.i {
    width: 16px;
    height: 16px;
    display: inline-block;
}

/* Drawer Toggle (Mobile) */
.drawer-toggle {
    display: none;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: var(--radius-pill);
    padding: 0;
    width: 52px;
    height: 52px;
    cursor: pointer;
    color: var(--muted);
    transition: all 0.15s ease;
    box-shadow: var(--shadow);
    flex-shrink: 0;
}

.drawer-toggle:hover {
    background: var(--focus-bg);
    color: var(--text);
    border-color: var(--accent);
}

.drawer-toggle:active {
    transform: scale(0.95);
}

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

/* Library backdrop for mobile */
.library-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.library-backdrop.show {
    opacity: 1;
    pointer-events: auto;
}

/* Mobile Responsive Design */
@media (max-width: 1100px) {
    .app {
        grid-template-columns: 1fr 280px;
    }
    
    .artboard {
        width: 95%;
    }
    
    .title input {
        width: 200px;
    }
}

@media (max-width: 860px) {
    .app {
        grid-template-columns: 1fr;
        grid-template-rows: 1fr auto;
        max-width: 100vw;
        overflow-x: hidden;
    }
    
    .editor-pane {
        height: 100%;
        display: flex;
        flex-direction: column;
    }
    
    /* Ensure all editor containers stay within viewport */
    #text-editor-container,
    #table-editor-container,
    #image-editor-container,
    #audio-editor-container {
        max-width: 100vw;
        overflow-x: hidden;
    }
    
    /* Library drawer as bottom sheet */
    .library-pane {
        grid-column: 1 / 2;
        grid-row: 3 / 4;
        border-left: none;
        border-top: 1px solid var(--border);
        height: calc(100vh - 80px); /* Almost full height, leaving room for top */
        height: calc(100dvh - 80px); /* Use dynamic viewport height */
        max-height: calc(100dvh - 80px);
        position: fixed;
        top: auto;
        bottom: 0;
        left: 0;
        right: 0;
        z-index: 1000;
        transform: translateY(100%);
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        border-radius: var(--radius) var(--radius) 0 0;
        box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.15);
        padding-bottom:0px;
    }
    
    .library-pane.open {
        transform: translateY(0);
    }
    
    /* Swipe indicator handle */
    .library-pane::before {
        content: '';
        position: absolute;
        top: 12px;
        left: 50%;
        transform: translateX(-50%);
        width: 40px;
        height: 4px;
        background: var(--border);
        border-radius: var(--radius-pill);
        transition: background 0.2s ease;
    }
    
    .library-pane.dragging::before {
        background: var(--accent);
    }
    
    
    /* Adjust library header for mobile */
    .library-header {
        padding-top: 24px; /* Space for handle */
        touch-action: pan-y;
        cursor: grab;
    }
    
    .library-header:active {
        cursor: grabbing;
    }
    
    /* Enable momentum scrolling */
    .library-list {
        -webkit-overflow-scrolling: touch;
        overflow-scrolling: touch;
        scroll-behavior: smooth;
    }
    
    .commandbar {
        grid-row: 2 / 3;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        z-index: 999;
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 12px;
        background: var(--panel);
        border-top: 1px solid var(--border);
    }
    
    .drawer-toggle {
        display: block;
    }
    
    /* Restructure ribbon for mobile scrolling */
    .ribbon {
        overflow: visible !important; /* Allow dropdowns to show */
        position: sticky;
        top: 0;
        z-index: 50;
        background: var(--panel);
    }
    
    /* Ensure horizontal containment but allow vertical scrolling */
    .editor-pane {
        overflow-x: hidden;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    /* Create a scrollable wrapper for asset tools */
    #asset-tools {
        overflow-x: auto !important;
        overflow-y: visible !important;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        -ms-overflow-style: none;
        padding-right: 90px !important; /* Space for fixed undo/redo */
        white-space: nowrap;
        position: relative;
        overflow:visible !important;
    }
    
    #asset-tools::-webkit-scrollbar {
        display: none;
    }
    
    /* Ensure toolgroups stay inline */
    #asset-tools .toolgroup {
        display: inline-flex !important;
        flex-shrink: 0;
    }
    
    /* Keep undo/redo fixed on right */
    .ribbon > .toolgroup:last-child {
        position: absolute !important;
        right: 12px;
        top: 50%;
        transform: translateY(-50%);
        background: var(--panel);
        padding: 4px;
        border-radius: var(--radius-sm);
        box-shadow: -4px 0 8px rgba(0, 0, 0, 0.1);
        z-index: 5;
    }
    
    .title {
        flex: 1;
        min-width: 0;
    }
    
    .title input {
        width: 100%;
        max-width: 200px;
    }
    
    .expiry {
        display: none;
    }
    
    .actions {
        gap: 6px;
    }
    
    .btn {
        padding: 6px 10px;
        font-size: 13px;
    }
    
    .chips {
        display: none; /* Hide on mobile to save space */
    }
    
    /* Improve touch targets */
    .toolbtn {
        min-width: 44px;
        min-height: 44px;
        width: 44px;
        height: 44px;
    }
    
    .asset-action-btn {
        width: 32px;
        height: 32px;
    }
    
    /* Better asset tile spacing for mobile */
    .asset-item {
        min-height: 72px;
        padding: 12px;
    }
    
    /* Larger new asset button */
    .new-asset-btn {
        height: 60px;
        font-size: 15px;
    }
    
    /* Show photo library button on mobile */
    #btn-photo-library {
        display: inline-flex;
    }
}

@media (max-width: 480px) {
    .topbar,
    .ribbon,
    .commandbar {
        padding-left: 8px;
        padding-right: 8px;
    }
    
    /* Removed conflicting canvas rule */
    
    .artboard {
        margin: 0;
        padding: 1rem;
        width: 100%;
    }
    
    /* Removed conflicting artboard.canvas-placeholder rule */
    
    .placeholder-content {
        width: 100%;
        padding: 0;
        display: flex;
        flex-direction: column;
        align-items: center;
    }
    
    .btn span {
        display: none; /* Hide button text on very small screens */
    }
    
    .toolgroup {
        gap: 4px;
    }
    
    /* Even smaller library drawer on small screens */
    .library-pane {
        height: calc(100vh - 60px);
        height: calc(100dvh - 60px); /* Use dynamic viewport height */
        max-height: calc(100dvh - 60px);
    }
    
    /* Adjust modal for small screens */
    .modal-content,
    .ai-preview-container {
        width: 95%;
        margin: 10px;
    }
    
    /* Stack asset type buttons 2x2 on very small screens */
    .asset-type-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
        max-width: 100%;
        margin: 0 auto;
    }
    
    .asset-type-btn {
        padding: 32px 20px;
    }
}

/* Prevent zoom on all inputs and textareas */
input, textarea, select {
    font-size: 16px !important;
}

/* SimpleMDE Text Editor Styles */
#text-editor-container {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    /* bottom is set to 74px in the general editor rule above */
    max-width: 100%; /* Prevent expanding beyond container */
    overflow: hidden; /* Prevent horizontal overflow */
}

#text-editor-container.drag-over .CodeMirror {
    background: rgba(37, 99, 235, 0.05);
    border: 2px dashed var(--accent);
}

/* Override SimpleMDE styles to match our design */
.CodeMirror {
    border: none;
    border-radius: 0;
    box-shadow: none;
    font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 16px !important;
    line-height: 1.6;
    color: var(--text);
    background: var(--bg);
    height: 100%;
    flex: 1;
    width: min(750px, 100%);
    max-width: 750px;
}

.CodeMirror:focus-within {
    outline: none;
}

.CodeMirror-scroll {
    padding: 2rem;
}

/* Ensure SimpleMDE fills the container */
#text-editor-container .CodeMirror {
    height: 100% !important;
}

/* Placeholder styling */
.CodeMirror-placeholder {
    color: var(--muted) !important;
    font-style: italic;
}

/* Hide SimpleMDE toolbar since we're using our own */
.editor-toolbar {
    display: none !important;
}

/* Our custom ribbon connects to SimpleMDE */
#text-ribbon + div .CodeMirror {
    border-top: none;
    border-radius: 0 0 var(--radius) var(--radius);
}

/* Preview styles */
.editor-preview, .editor-preview-side {
    background: #fff;
    font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 16px;
    line-height: 1.6;
    color: var(--text);
    padding: 2rem;
}

.editor-preview h1, .editor-preview-side h1 {
    color: var(--accent-2);
    font-weight: 700;
}

.editor-preview h2, .editor-preview-side h2 {
    color: var(--accent-2);
    font-weight: 600;
}

.editor-preview code, .editor-preview-side code {
    background: #f5f5f5;
    padding: 2px 4px;
    border-radius: 3px;
    font-size: 14px;
}

.editor-preview pre, .editor-preview-side pre {
    background: #f5f5f5;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 1rem;
    overflow-x: auto;
}

.editor-preview blockquote, .editor-preview-side blockquote {
    border-left: 4px solid var(--accent);
    margin-left: 0;
    padding-left: 1rem;
    color: var(--muted);
}

/* Hide/show editor elements */
.hidden {
    display: none !important;
}

.editor-surface.hidden {
    display: none;
}

.canvas-placeholder.hidden {
    display: none;
}

/* Text Ribbon Specific Styles */
#text-ribbon {
    background: var(--panel);
    border-bottom: 1px solid var(--border);
}

#text-ribbon .toolbtn {
    font-weight: 600;
    font-size: 14px;
}

#text-ribbon .toolbtn[data-cmd="bold"] b,
#text-ribbon .toolbtn[data-cmd="italic"] i,
#text-ribbon .toolbtn[data-cmd="underline"] u {
    font-family: inherit;
}

/* Active formatting button states */
.toolbtn.active {
    background: var(--focus-bg);
    border-color: var(--accent);
    color: var(--accent);
}

.toolbtn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    pointer-events: none;
}

.toolbtn:disabled:hover {
    background: #fff;
    border-color: var(--border);
}

/* Hide camera and photo library buttons in ribbon (they're now in placeholder) */
#btn-camera,
#btn-photo-library {
    display: none;
}

/* Placeholder action buttons */
.placeholder-buttons {
    display: flex;
    gap: 8px;
    margin-top: 20px;
    justify-content: center;
}

.placeholder-action-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: #fff;
    box-shadow: var(--shadow-button);
    cursor: pointer;
    transition: all 0.15s ease;
    font-size: 13px;
    font-weight: 500;
    color: var(--text);
    pointer-events: auto;
    position: relative;
    z-index: 10;
}

.placeholder-action-btn:hover {
    background: var(--focus-bg);
}

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

/* Offline indicator */
.offline-indicator {
    position: fixed;
    top: 16px;
    left: 50%;
    transform: translateX(-50%);
    background: #ff9800;
    color: white;
    padding: 8px 16px;
    border-radius: var(--radius-pill);
    font-size: 14px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 8px;
    z-index: 10001;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.offline-indicator.hidden {
    opacity: 0;
    transform: translateX(-50%) translateY(-20px);
    pointer-events: none;
}

.offline-indicator svg {
    flex-shrink: 0;
}

@media (max-width: 768px) {
    .offline-indicator {
        font-size: 12px;
        padding: 6px 12px;
    }
    
    .offline-indicator svg {
        width: 14px;
        height: 14px;
    }
}

/* Toast Notifications */
.toast {
    position: absolute; /* Absolute within editor area */
    bottom: 100px; /* Bottom of editor area */
    left: 24px;
    max-width: 420px; /* Wider for better readability */
    padding: 16px 24px;
    border-radius: var(--radius-lg);
    color: var(--text);
    background: var(--panel);
    border: 1px solid var(--border);
    font-weight: 400;
    font-size: 14px;
    line-height: 1.5;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    z-index: 1000; /* Higher z-index to ensure visibility */
    animation: toast-in 0.3s ease;
    cursor: default;
    display: flex;
    align-items: center;
    gap: 12px;
}

/* No color distinctions - all toasts look the same */

/* Processing toast with thinking animation */
.toast.processing .thinking-dots {
    display: inline-flex;
    gap: 2px;
}

.thinking-dots span {
    display: inline-block;
    width: 6px;
    height: 6px;
    background: var(--muted);
    border-radius: 50%;
    animation: thinking-pulse 1.4s ease-in-out infinite both;
}

.thinking-dots span:nth-child(1) { animation-delay: -0.32s; }
.thinking-dots span:nth-child(2) { animation-delay: -0.16s; }
.thinking-dots span:nth-child(3) { animation-delay: 0s; }

@keyframes thinking-pulse {
    0%, 80%, 100% { 
        transform: scale(0.8);
        opacity: 0.5;
    }
    40% { 
        transform: scale(1);
        opacity: 1;
    }
}

@keyframes toast-in {
    from {
        opacity: 0;
        transform: translateX(-20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes toast-out {
    from {
        opacity: 1;
        transform: translateX(0);
    }
    to {
        opacity: 0;
        transform: translateX(-20px);
    }
}

/* Mobile responsive adjustments for toast */
@media (max-width: 860px) {
    .toast {
        left: 16px;
        bottom: 80px; /* Above command bar on mobile */
        right: 16px;
        max-width: none;
    }
}

@media (max-width: 480px) {
    .toast {
        left: 12px;
        bottom: 70px; /* Above command bar on small screens */
        right: 12px;
        max-width: none;
        font-size: 13px;
        padding: 12px 16px;
    }
}

/* Editor States */
.editor-surface.saving {
    border-color: var(--accent);
    box-shadow: 0 0 0 1px var(--accent);
}

.editor-surface.error {
    border-color: #dc2626;
    box-shadow: 0 0 0 1px #dc2626;
}

/* Responsive adjustments for SimpleMDE */
@media (max-width: 860px) {
    .CodeMirror {
        font-size: 16px !important;
        width: 100%;
        max-width: 100%; /* Constrain to viewport width */
        height: 100%; /* Fill available space in scrollable area */
    }
    
    .CodeMirror-scroll {
        padding: 1.5rem;
    }
    
    .editor-preview, .editor-preview-side {
        padding: 1.5rem;
        font-size: 15px;
    }
    
    /* Adjust artboard for mobile */
    .artboard {
        min-height: calc(100vh - 140px);
    }
}

@media (max-width: 480px) {
    .CodeMirror {
        font-size: 16px !important;
        height: calc(100vh - 120px);
    }
    
    .CodeMirror-scroll {
        padding: 1rem;
    }
    
    .editor-preview, .editor-preview-side {
        padding: 1rem;
        font-size: 14px;
    }
    
    .editor-toolbar a {
        padding: 8px 6px;
    }
    
    /* Removed min-height rule that was causing layout issues */
}

/* AI Preview Modal */
.ai-preview-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 2000;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    animation: modal-fade-in 0.2s ease;
}

.ai-preview-modal.hidden {
    display: none;
}

@keyframes modal-fade-in {
    from {
        opacity: 0;
        transform: scale(0.95);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.ai-preview-container {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-preview);
    width: min(1000px, 90vw);
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.ai-preview-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    background: var(--bg);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.ai-preview-header h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    color: var(--text);
}

.ai-preview-close {
    width: 24px;
    height: 24px;
    border: none;
    background: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-xs);
    color: var(--muted);
    transition: all 0.15s ease;
}

.ai-preview-close:hover {
    background: var(--focus-bg);
    color: var(--text);
}

.ai-preview-content {
    flex: 1;
    display: grid;
    grid-template-columns: 1fr 1fr;
    overflow: hidden;
}

.ai-preview-column {
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.ai-preview-column:first-child {
    border-right: 1px solid var(--border);
}

.ai-preview-column-header {
    padding: 12px 16px;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    font-size: 13px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--muted);
}

.ai-preview-column-content {
    flex: 1;
    overflow: auto;
    padding: 16px;
    font-size: 15px;
    line-height: 1.6;
}

.ai-preview-original {
    opacity: 0.8;
}

.ai-preview-transformed {
    position: relative;
}

.ai-preview-transformed::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--accent), #60a5fa);
    border-radius: var(--radius-xs);
}

.ai-preview-footer {
    padding: 16px 20px;
    border-top: 1px solid var(--border);
    background: var(--bg);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
}

.ai-preview-info {
    font-size: 12px;
    color: var(--muted);
    display: flex;
    align-items: center;
    gap: 8px;
}

.ai-preview-actions {
    display: flex;
    gap: 8px;
}

.ai-preview-btn {
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s ease;
    display: flex;
    align-items: center;
    gap: 6px;
}

.ai-preview-btn-cancel {
    border: 1px solid var(--border);
    background: var(--panel);
    color: var(--text);
}

.ai-preview-btn-cancel:hover {
    background: var(--focus-bg);
}

.ai-preview-btn-apply {
    border: 1px solid var(--accent);
    background: var(--accent);
    color: white;
    box-shadow: var(--shadow-send);
}

.ai-preview-btn-apply:hover {
    background: #1d4ed8;
    transform: translateY(-1px);
}

.ai-preview-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* AI Processing Indicator */
.ai-processing {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 1500;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px 24px;
    box-shadow: var(--shadow-preview);
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 14px;
    color: var(--text);
}

.ai-processing.hidden {
    display: none;
}

.ai-spinner {
    width: 20px;
    height: 20px;
    border: 2px solid var(--border);
    border-top: 2px solid var(--accent);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* Loading state for library */
.loading-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem 1rem;
    color: var(--muted);
}

.loading-state .spinner {
    width: 24px;
    height: 24px;
    border: 2px solid #f3f3f3;
    border-top: 2px solid #2196F3;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.ai-cancel-btn {
    margin-left: 12px;
    padding: 4px 8px;
    border: 1px solid var(--border);
    background: var(--panel);
    color: var(--muted);
    border-radius: var(--radius-xs);
    font-size: 12px;
    cursor: pointer;
    transition: all 0.15s ease;
}

.ai-cancel-btn:hover {
    background: var(--focus-bg);
    color: var(--text);
}

/* AI Quota Error */
.ai-quota-error {
    position: fixed;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%);
    padding: 12px 20px;
    border-radius: var(--radius-lg);
    color: var(--text);
    background: var(--panel);
    border: 1px solid var(--border);
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
    z-index: 1000;
    max-width: 480px;
    width: calc(100% - 40px);
    font-size: 14px;
    animation: toast-in 0.3s ease;
}

.ai-quota-error.hidden {
    display: none;
}

/* Download Processing Overlay */
.download-processing-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    animation: fade-in 0.2s ease;
}

.download-processing-overlay.hidden {
    display: none;
}

.download-processing-content {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 24px;
    text-align: center;
    box-shadow: var(--shadow);
    min-width: 250px;
}

.download-spinner {
    width: 32px;
    height: 32px;
    border: 3px solid var(--border);
    border-top: 3px solid var(--accent);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 16px;
}

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

/* Download quota error toast */
.download-quota-error {
    position: fixed;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%);
    padding: 12px 20px;
    border-radius: var(--radius-lg);
    color: var(--text);
    background: var(--panel);
    border: 1px solid var(--border);
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
    z-index: 1000;
    max-width: 480px;
    width: calc(100% - 40px);
    font-size: 14px;
    animation: toast-in 0.3s ease;
}

.download-quota-error.hidden {
    display: none;
}

@keyframes fade-in {
    0% { opacity: 0; }
    100% { opacity: 1; }
}


/* Command bar enabled state */
.command-input.ai-enabled {
    border-color: var(--accent);
    box-shadow: 0 0 0 1px rgba(37, 99, 235, 0.1);
}

.command-input.ai-enabled input::placeholder {
    color: var(--accent);
}

/* Mobile responsive adjustments for all modals */
@media (max-width: 768px) {
    /* General modal improvements */
    .modal-overlay {
        padding: 0;
    }
    
    .modal-content {
        width: 100%;
        height: 100%;
        max-width: none;
        max-height: 100vh;
        border-radius: 0;
        margin: 0;
        display: flex;
        flex-direction: column;
    }
    
    .modal-body {
        flex: 1;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    /* AI preview modal specific */
    .ai-preview-modal {
        padding: 0;
    }
    
    .ai-preview-container {
        width: 100%;
        height: 100%;
        max-height: 100vh;
        border-radius: 0;
    }
    
    .ai-preview-content {
        grid-template-columns: 1fr;
        grid-template-rows: 1fr 1fr;
    }
    
    .ai-preview-column:first-child {
        border-right: none;
        border-bottom: 1px solid var(--border);
    }
    
    .ai-preview-footer {
        flex-direction: column;
        gap: 8px;
        position: sticky;
        bottom: 0;
        background: var(--bg);
        box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
    }
    
    .ai-preview-actions {
        width: 100%;
        justify-content: stretch;
    }
    
    .ai-preview-btn {
        flex: 1;
        justify-content: center;
        padding: 12px 16px;
        font-size: 15px;
    }
    
    /* Form inputs in modals */
    .form-group input[type="number"] {
        font-size: 16px; /* Prevent zoom on iOS */
    }
}

@media (max-width: 480px) {
    .modal-header {
        padding: 12px 16px;
    }
    
    .modal-body {
        padding: 16px;
    }
    
    .modal-footer {
        padding: 12px 16px;
    }
    
    .ai-preview-header h3 {
        font-size: 14px;
    }
    
    .ai-preview-column-content {
        padding: 12px;
        font-size: 14px;
    }
}

/* Table Editor Styles */
#table-editor-container {
    display: flex;
    flex-direction: column;
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    background: var(--panel);
    border-radius: var(--radius);
    overflow: hidden;
}

#table-editor-container.drag-over {
    background: rgba(59, 130, 246, 0.05);
    border: 2px dashed var(--accent);
}

/* Virtualized Table Grid */
.table-grid {
    flex: 1;
    overflow: auto;
    border: 1px solid #e5e5e5;
    background: #fff;
    font-size: 13px;
    line-height: 1.4;
    position: relative;
}

.table-grid:focus {
    outline: none;
}

.grid-table {
    border-collapse: collapse;
    width: 100%;
    table-layout: fixed;
}

.grid-table th,
.grid-table td {
    border: 1px solid #eee;
    padding: 6px 8px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1;
    vertical-align: middle;
}

.grid-table th {
    position: sticky;
    top: 0;
    background: #fafafa;
    cursor: text;
    font-weight: 600;
    z-index: 10;
    position: relative;
    text-align: center;
}

.grid-table th .header-content {
    display: inline-block;
    margin: 0 16px; /* Space for drag handle (left) and sort arrow (right) */
    text-align: center;
    width: calc(100% - 32px);
    overflow: hidden;
    text-overflow: ellipsis;
}

.grid-table th.editing {
    padding: 0;
    background: #fff;
    border: 2px solid var(--accent);
}

.grid-table th:not(.selected-cell):hover {
    background: #f0f0f0;
}

/* Column Drag Handle */
.column-drag-handle {
    position: absolute;
    left: 4px;
    top: 50%;
    transform: translateY(-50%);
    width: 12px;
    height: 16px;
    cursor: grab;
    user-select: none;
    color: #999;
    font-size: 11px;
    line-height: 8px;
    text-align: center;
    opacity: 0;
    transition: opacity 0.2s ease;
    z-index: 2;
    font-weight: bold;
}

.grid-table th:hover .column-drag-handle {
    opacity: 0.8;
}

.column-drag-handle:hover {
    color: var(--accent);
    opacity: 1;
}

.column-drag-handle.dragging {
    cursor: grabbing;
    opacity: 1;
}

/* Header content wrapper */
.header-content {
    display: inline-block;
    margin-left: 16px;
    flex: 1;
}


.sort-arrow {
    position: absolute;
    right: 6px;
    top: 50%;
    transform: translateY(-50%);
    width: 0;
    height: 0;
    border-style: solid;
    opacity: 0;
    transition: opacity 0.2s ease;
    cursor: pointer;
    user-select: none;
    z-index: 1;
}

.sort-arrow-up {
    border-left: 3px solid transparent;
    border-right: 3px solid transparent;
    border-bottom: 4px solid #999;
}

.sort-arrow-down {
    border-left: 3px solid transparent;
    border-right: 3px solid transparent;
    border-top: 4px solid #999;
}

.grid-table th:hover .sort-arrow {
    opacity: 1;
}

.sort-arrow:hover {
    border-bottom-color: var(--accent) !important;
    border-top-color: var(--accent) !important;
}

.grid-row {
    height: 28px;
}


.grid-table tr:nth-child(even) {
    background: #fafafa;
}

.grid-table tr:hover {
    background: var(--focus-bg);
}

/* Cell Editing Styles */
.grid-table td.editing {
    padding: 0;
    background: #fff;
    border: 2px solid var(--accent);
}

.cell-editor {
    width: 100%;
    height: 100%;
    border: none;
    padding: 6px 8px;
    font-size: 13px !important;
    font-family: inherit;
    line-height: 1;
    background: transparent;
    outline: none;
    resize: none;
    vertical-align: top;
}

.grid-table td:not(.editing):not(.selected-cell):hover {
    background: var(--focus-bg);
    cursor: text;
}

/* Active Cell Selection - use outline to avoid size changes */
.grid-table td.active-cell {
    outline: 2px solid var(--accent);
    outline-offset: -2px;
    background: rgba(59, 130, 246, 0.1);
}

.grid-table th.active-cell {
    outline: 2px solid var(--accent);
    outline-offset: -2px;
    background: rgba(59, 130, 246, 0.15);
}

/* Prevent text selection during drag operations */
.grid-table.dragging {
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
}

.grid-table.dragging * {
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
}

/* Range Selection Styles */
.grid-table td.selected-cell {
    background: rgba(59, 130, 246, 0.12);
}

.grid-table th.selected-cell {
    background: rgba(59, 130, 246, 0.15);
}

/* Active cell within selection has stronger outline */
.grid-table td.selected-cell.active-cell {
    background: rgba(59, 130, 246, 0.18);
    outline: 2px solid var(--accent);
    outline-offset: -2px;
}

.grid-table th.selected-cell.active-cell {
    background: rgba(59, 130, 246, 0.22);
    outline: 2px solid var(--accent);
    outline-offset: -2px;
}

/* Column Type Alignment */
.grid-table td.col-type-number,
.grid-table td.col-type-date {
    text-align: right;
}

.grid-table th.col-type-number .header-content,
.grid-table th.col-type-date .header-content {
    text-align: right;
}

/* Virtual row and column styles */
.virtual-header {
    background: #f8f9fa;
    border: 1px dashed #ddd;
    text-align: center;
    cursor: pointer;
    user-select: none;
    color: #666;
    font-weight: normal;
    position: relative;
}

.virtual-header:hover {
    background: var(--focus-bg);
    color: var(--accent);
}

.virtual-cell {
    background: #f8f9fa;
    border: 1px dashed #ddd;
    text-align: center;
    cursor: pointer;
    user-select: none;
    color: #666;
}

.virtual-cell:hover {
    background: var(--focus-bg);
    color: var(--accent);
}

/* Context Menu */
.table-context-menu {
    position: fixed;
    background: white;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow), 0 4px 12px rgba(0,0,0,0.15);
    padding: 4px 0;
    z-index: 1000;
    min-width: 160px;
    display: none;
}

.context-menu-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    font-size: 14px;
    color: var(--text);
    cursor: pointer;
    border: none;
    background: none;
    width: 100%;
    text-align: left;
    transition: background 0.15s ease;
}

.context-menu-item:hover {
    background: var(--focus-bg);
}

.context-menu-item:disabled {
    color: var(--muted);
    cursor: not-allowed;
}

.context-menu-item:disabled:hover {
    background: transparent;
}

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

.grid-table td:focus {
    outline: 2px solid var(--accent);
    outline-offset: -2px;
}

#table-preview {
    flex: 1;
    overflow: auto;
    padding: 20px;
}

#table-preview table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 14px;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    overflow: hidden;
}

#table-preview th {
    background: var(--bg);
    padding: 12px 16px;
    text-align: left;
    font-weight: 600;
    color: var(--text);
    border-bottom: 2px solid var(--border);
    border-right: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 10;
}

#table-preview th:last-child {
    border-right: none;
}

#table-preview td {
    padding: 10px 16px;
    border-bottom: 1px solid var(--border);
    border-right: 1px solid var(--border);
    vertical-align: top;
    color: var(--text);
}

#table-preview td:last-child {
    border-right: none;
}

#table-preview tr:last-child td {
    border-bottom: none;
}

#table-preview tr:hover {
    background: var(--focus-bg);
}

.table-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 300px;
    color: var(--muted);
    text-align: center;
}

.table-placeholder-icon {
    font-size: 48px;
    margin-bottom: 16px;
    opacity: 0.7;
}

.table-placeholder h3 {
    margin: 0 0 8px 0;
    font-size: 18px;
    font-weight: 600;
    color: var(--text);
}

.table-placeholder p {
    margin: 0 0 16px 0;
    font-size: 14px;
    max-width: 400px;
    line-height: 1.4;
}

/* Table stats inherit from .editor-stats base class */

/* Mobile responsive adjustments for table editor */
@media (max-width: 860px) {
    #table-editor-container {
        height: 100%; /* Fill available space in scrollable area */
        max-height: 100%;
    }
    
    .table-grid {
        font-size: 12px;
    }
    
    .grid-table th,
    .grid-table td {
        padding: 4px 6px;
    }
    
    /* Make table horizontally scrollable on mobile */
    .table-grid {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    #table-preview {
        padding: 15px;
    }
    
    #table-preview table {
        font-size: 13px;
    }
    
    #table-preview th,
    #table-preview td {
        padding: 8px 12px;
    }
    
    .table-placeholder {
        height: 250px;
    }
    
    .table-placeholder-icon {
        font-size: 36px;
    }
    
    .table-placeholder h3 {
        font-size: 16px;
    }
    
    .table-placeholder p {
        font-size: 13px;
        padding: 0 20px;
    }
}

@media (max-width: 480px) {
    #table-editor-container {
        height: 100%; /* Fill available space in scrollable area */
        max-height: 100%;
    }
    
    .table-grid {
        font-size: 11px;
    }
    
    .grid-table th,
    .grid-table td {
        padding: 3px 4px;
    }
    
    #table-preview {
        padding: 10px;
    }
    
    #table-preview table {
        font-size: 12px;
    }
    
    #table-preview th,
    #table-preview td {
        padding: 6px 8px;
    }
    
    .table-placeholder {
        height: 200px;
    }
}

/* Image Editor Styles */
#image-editor-container {
    display: flex;
    flex-direction: column;
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    background: var(--panel);
    border-radius: var(--radius);
    overflow: hidden;
    width: 100%;
    max-width: 100%; /* Prevent expanding beyond container */
}

.image-canvas-wrapper {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f8f9fa;
    border: 1px solid #e5e5e5;
    position: relative;
    overflow: hidden; /* Contain the image */
    transition: all 0.2s ease;
    width: 100%;
    max-width: 100%; /* Prevent expanding beyond container */
}

.image-canvas-wrapper.drag-over {
    background: rgba(37, 99, 235, 0.05);
    border: 2px dashed var(--accent);
    border-radius: var(--radius);
}

/* Editor placeholder styles */
.editor-placeholder {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f8f9fa;
}

.editor-placeholder .placeholder-border {
    position: absolute;
    inset: 10px;
    border: 2px dashed #dee2e6;
    border-radius: var(--radius-sm);
    pointer-events: none;
}

.editor-placeholder .placeholder-content {
    position: relative;
    text-align: center;
    z-index: 1;
    pointer-events: auto;
}

.editor-placeholder .placeholder-text {
    color: #6c757d;
    font-size: 16px;
    margin-bottom: 10px;
}

.editor-placeholder .placeholder-icon {
    font-size: 24px;
}

/* AI image editing overlay */
.image-editing-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    border-radius: 8px;
    z-index: 100;
}

.image-editing-overlay.hidden {
    display: none;
}

.editing-message {
    text-align: center;
    color: white;
}

.editing-title {
    font-size: 20px;
    font-weight: 500;
    margin-bottom: 8px;
    color: #ffffff;
}

.editing-subtitle {
    font-size: 16px;
    margin-bottom: 8px;
    color: #cccccc;
}

.editing-timer {
    font-weight: 600;
    color: #ffffff;
    font-family: monospace;
    font-size: 20px;
    background-color: rgba(255, 255, 255, 0.1);
    padding: 4px 12px;
    border-radius: 4px;
    margin-bottom: 16px;
    display: inline-block;
}

.editing-dots {
    font-size: 24px;
    color: #ffffff;
}

.editing-dots span {
    animation: editing-pulse 1.4s ease-in-out infinite both;
}

.editing-dots span:nth-child(1) { animation-delay: -0.32s; }
.editing-dots span:nth-child(2) { animation-delay: -0.16s; }
.editing-dots span:nth-child(3) { animation-delay: 0s; }

@keyframes editing-pulse {
    0%, 80%, 100% { 
        opacity: 0.3;
        transform: scale(1);
    }
    40% { 
        opacity: 1;
        transform: scale(1.2);
    }
}

#image-canvas {
    max-width: calc(100% - 40px); /* Account for padding */
    max-height: calc(100% - 40px); /* Account for padding */
    width: auto;
    height: auto;
    display: block;
    object-fit: contain; /* Ensure image fits within bounds */
    border: 1px solid #ddd;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    cursor: crosshair;
    
    /* Checkered transparency background pattern - only behind the canvas */
    background-color: #fff;
    background-image: 
        linear-gradient(45deg, #f0f0f0 25%, transparent 25%),
        linear-gradient(-45deg, #f0f0f0 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, #f0f0f0 75%),
        linear-gradient(-45deg, transparent 75%, #f0f0f0 75%);
    background-size: 16px 16px;
    background-position: 0 0, 0 8px, 8px -8px, -8px 0px;
}

#image-canvas.cropping {
    cursor: crosshair;
}

#image-canvas.resizing {
    cursor: nw-resize;
}

/* Image stats inherit from .editor-stats base class */

/* Image placeholder when no image loaded */
.image-placeholder {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    color: var(--muted);
    pointer-events: none;
}

.image-placeholder-icon {
    font-size: 48px;
    margin-bottom: 16px;
    opacity: 0.5;
}

.image-placeholder h3 {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--text);
}

.image-placeholder p {
    font-size: 14px;
    line-height: 1.5;
    max-width: 300px;
    margin: 0 auto;
}

/* Crop overlay styles */
.crop-overlay {
    position: absolute;
    border: 2px dashed var(--accent);
    background: rgba(37, 99, 235, 0.1);
    pointer-events: none;
    z-index: 10;
}

.crop-handle {
    position: absolute;
    width: 8px;
    height: 8px;
    background: var(--accent);
    border: 2px solid #fff;
    border-radius: 50%;
    cursor: grab;
    pointer-events: all;
}

.crop-handle:active {
    cursor: grabbing;
}

.crop-handle.nw { top: -4px; left: -4px; cursor: nw-resize; }
.crop-handle.ne { top: -4px; right: -4px; cursor: ne-resize; }
.crop-handle.sw { bottom: -4px; left: -4px; cursor: sw-resize; }
.crop-handle.se { bottom: -4px; right: -4px; cursor: se-resize; }

/* Active crop tool button styling - subtle available state */
.toolbtn.active {
    background: var(--focus-bg);
    border-color: var(--focus-ring);
    color: var(--accent);
}

.toolbtn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background: var(--border);
    color: var(--muted);
}

/* Mobile responsive adjustments for image editor */
@media (max-width: 860px) {
    .image-canvas-wrapper {
        padding: 10px;
    }
    
    #image-canvas {
        max-width: calc(100vw - 40px);
        max-height: calc(100% - 40px); /* Relative to container */
    }
    
    .image-placeholder-icon {
        font-size: 36px;
    }
    
    .image-placeholder h3 {
        font-size: 16px;
    }
    
    .image-placeholder p {
        font-size: 13px;
        padding: 0 20px;
    }
    
    /* Optimize editor stats position on mobile */
    .editor-stats {
        bottom: 8px;
        right: 8px;
        font-size: 10px;
        padding: 3px 6px;
    }
}

@media (max-width: 480px) {
    .image-canvas-wrapper {
        padding: 5px;
    }
    
    #image-canvas {
        max-width: calc(100vw - 20px);
        max-height: calc(100% - 20px); /* Relative to container */
    }
}

/* Selection dimensions overlay */
.selection-dimensions {
    position: absolute;
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 3px 8px;
    font-size: 10px;
    font-weight: 500;
    border-radius: 3px;
    pointer-events: none;
    z-index: 10;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    white-space: nowrap;
}

/* Audio Editor Styles */
#audio-editor-container {
    display: flex;
    flex-direction: column;
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    background: var(--panel);
    border-radius: var(--radius);
    overflow: hidden;
    width: 100%;
    max-width: 100%; /* Prevent expanding beyond container */
}

/* Permission denied state for record button */
#btn-audio-record.permission-denied {
    border-color: #dc2626;
    color: #dc2626;
}

#btn-audio-record.permission-denied:hover {
    background: rgba(220, 38, 38, 0.1);
}

#btn-audio-effects {
    width: auto;
}

.audio-waveform-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: #f8f9fa;
    padding: 20px;
    position: relative;
    overflow: hidden;
    min-height: 200px;
    width: 100%;
    max-width: 100%; /* Prevent expanding beyond container */
}

.audio-waveform-wrapper.drag-over {
    background: rgba(37, 99, 235, 0.05);
    border: 2px dashed var(--accent);
}

#audio-waveform {
    width: 100%;
    max-width: 100%; /* Prevent expanding beyond container */
    height: 160px;
    border: 1px solid #ddd;
    background: #fff;
    border-radius: var(--radius-sm);
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.audio-trim-handles {
    position: relative;
    width: 100%;
    height: 0;
    pointer-events: none;
}

.trim-handle {
    position: absolute;
    top: -160px;
    width: 4px;
    height: 160px;
    background: #007aff;
    cursor: ew-resize;
    pointer-events: auto;
    border-radius: 2px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    z-index: 2;
}

.trim-handle:hover {
    background: #0056cc;
}

.trim-handle::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 12px;
    height: 20px;
    background: rgba(255, 255, 255, 0.9);
    border-radius: 2px;
    border: 1px solid #007aff;
}

.trim-region {
    position: absolute;
    top: -160px;
    height: 160px;
    background: rgba(0, 122, 255, 0.08);
    pointer-events: none;
    z-index: 1;
}

.audio-timer {
    font-family: 'SF Mono', Monaco, 'Cascadia Code', 'Roboto Mono', Consolas, 'Courier New', monospace;
    font-size: 14px;
    font-weight: 500;
    color: var(--muted);
    background: rgba(0, 0, 0, 0.05);
    padding: 4px 8px;
    border-radius: var(--radius-xs);
    margin-left: 8px;
}

/* Audio stats inherit from .editor-stats base class */

/* Audio recording state */
.recording {
    animation: pulse-red 1s infinite;
}

@keyframes pulse-red {
    0%, 100% {
        background-color: #dc2626;
    }
    50% {
        background-color: #ef4444;
    }
}

/* Audio ribbon specific styles */
.audio-timer.recording {
    color: #dc2626;
    background: rgba(220, 38, 38, 0.1);
    border: 1px solid rgba(220, 38, 38, 0.2);
}

/* Mobile responsive adjustments for audio editor */
@media (max-width: 768px) {
    .audio-waveform-wrapper {
        padding: 10px;
        min-height: 150px;
    }
    
    #audio-waveform {
        height: 120px;
        max-width: calc(100% - 20px); /* Use percentage instead of viewport units */
    }
    
    .trim-handle {
        top: -120px;
        height: 120px;
    }
    
    .trim-region {
        top: -120px;
        height: 120px;
    }
}

@media (max-width: 480px) {
    .audio-waveform-wrapper {
        padding: 5px;
        min-height: 120px;
    }
    
    #audio-waveform {
        height: 100px;
        max-width: calc(100% - 10px); /* Use percentage instead of viewport units */
    }
    
    .trim-handle {
        top: -100px;
        height: 100px;
    }
    
    .trim-region {
        top: -100px;
        height: 100px;
    }
}

/* Modal Components */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 1;
    transition: opacity 0.2s ease;
}

.modal-overlay.hidden {
    display: none;
}

.modal-content {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    max-width: 480px;
    width: 90%;
    max-height: 90vh;
    overflow: hidden;
    animation: modalSlideIn 0.2s ease;
}

/* Export Dialog Styles */
.export-dialog .modal-content {
    padding: 24px;
}

.export-dialog h3 {
    margin: 0 0 20px 0;
    font-size: 20px;
    font-weight: 500;
}

.export-options {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 20px;
}

.export-option {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    padding: 16px;
    border: 2px solid var(--border);
    border-radius: 8px;
    background: var(--bg);
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: left;
}

.export-option:hover {
    border-color: var(--primary);
    background: var(--hover);
}

.export-option.selected {
    border-color: var(--primary);
    background: var(--selected);
}

.format-name {
    font-size: 16px;
    font-weight: 500;
    margin-bottom: 4px;
}

.format-desc {
    font-size: 13px;
    color: var(--muted);
}

.quality-control {
    margin-bottom: 20px;
    padding: 16px;
    background: var(--hover);
    border-radius: 8px;
}

.quality-control label {
    display: block;
    margin-bottom: 8px;
    font-size: 14px;
}

.quality-control input[type="range"] {
    width: 100%;
}

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

.modal-actions button {
    padding: 8px 16px;
    border-radius: 4px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.modal-actions button:not(.primary) {
    background: var(--bg);
    border: 1px solid var(--border);
    color: var(--text);
}

.modal-actions button:not(.primary):hover {
    background: var(--hover);
}

.modal-actions button.primary {
    background: var(--accent);
    border: none;
    color: white;
}

.modal-actions button.primary:hover:not(:disabled) {
    background: var(--accent-2);
}

.modal-actions button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

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

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

.modal-header h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    color: var(--fg);
}

.modal-close {
    background: none;
    border: none;
    padding: 4px;
    cursor: pointer;
    color: var(--muted);
    border-radius: 4px;
    transition: background-color 0.2s ease;
}

.modal-close:hover {
    background: var(--hover);
    color: var(--fg);
}

.modal-close svg {
    width: 16px;
    height: 16px;
}

.modal-body {
    padding: 20px;
}

.modal-footer {
    padding: 16px 20px;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

/* Resize Form Styles */
.resize-form {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

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

.form-group label {
    font-size: 13px;
    font-weight: 500;
    color: var(--fg);
}

.form-group input[type="number"] {
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--bg);
    color: var(--fg);
    font-size: 14px;
    font-family: inherit;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.form-group input[type="number"]:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.1);
}

.form-info {
    padding: 12px;
    background: var(--hover);
    border-radius: 4px;
    border: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.form-info label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--fg);
    cursor: pointer;
}

.form-info input[type="checkbox"] {
    margin: 0;
    accent-color: var(--accent);
}

.current-size {
    font-size: 12px;
    color: var(--muted);
}

/* Button Styles for Modal */
.btn-primary, .btn-secondary {
    padding: 8px 16px;
    border-radius: 4px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 1px solid;
}

.btn-primary {
    background: var(--accent);
    border-color: var(--accent);
    color: white;
}

.btn-primary:hover {
    background: #2563eb;
    border-color: #2563eb;
}

.btn-secondary {
    background: var(--bg);
    border-color: var(--border);
    color: var(--fg);
}

.btn-secondary:hover {
    background: var(--hover);
    border-color: var(--accent);
}

/* Touch interaction improvements */
@media (hover: none) and (pointer: coarse) {
    /* Touch-specific styles */
    .toolbtn:active {
        transform: scale(0.95);
        transition: transform 0.1s ease;
    }
    
    .asset-item:active {
        transform: scale(0.98);
        transition: transform 0.1s ease;
    }
    
    .btn:active {
        transform: scale(0.95);
    }
    
    /* Disable hover states on touch devices */
    .asset-item:hover {
        box-shadow: none;
        border-color: var(--border);
    }
    
    /* Show asset actions on tap instead of hover */
    .asset-actions {
        opacity: 1;
    }
    
    /* Larger hit areas for small buttons */
    .asset-action-btn::before {
        content: '';
        position: absolute;
        top: -8px;
        left: -8px;
        right: -8px;
        bottom: -8px;
    }
}

/* Reduce motion for accessibility */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    
    .library-pane {
        transition: none;
    }
}

/* Additional utility classes */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Brightness, Resize, Contrast and Saturation control styles */
.brightness-control,
.resize-control,
.contrast-control,
.saturation-control {
    position: relative;
    display: inline-flex;
    flex-direction: column;
    align-items: center;
}

.brightness-control .toolbtn.active,
.resize-control .toolbtn.active,
.contrast-control .toolbtn.active,
.saturation-control .toolbtn.active {
    background: var(--focus-bg);
    border-color: var(--accent);
    color: var(--accent);
}

.slider-container {
    position: fixed; /* Use fixed positioning to escape overflow constraints */
    background: #fff;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-dropdown);
    padding: 12px;
    padding-top: 24px; /* Extra space for the title */
    z-index: 10000; /* Match dropdown z-index */
    min-width: 200px;
}

.slider-container.hidden {
    display: none;
}

/* Consistent styles for all sliders */
#brightness-slider,
#resize-slider,
#contrast-slider,
#saturation-slider {
    width: 100%;
    height: 4px;
    background: var(--border);
    outline: none;
    border-radius: 2px;
    appearance: none;
    -webkit-appearance: none;
    margin: 8px 0;
}

#brightness-slider::-webkit-slider-thumb,
#resize-slider::-webkit-slider-thumb,
#contrast-slider::-webkit-slider-thumb,
#saturation-slider::-webkit-slider-thumb {
    appearance: none;
    -webkit-appearance: none;
    width: 16px;
    height: 16px;
    background: var(--accent);
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

#brightness-slider::-moz-range-thumb,
#resize-slider::-moz-range-thumb,
#contrast-slider::-moz-range-thumb,
#saturation-slider::-moz-range-thumb {
    width: 16px;
    height: 16px;
    background: var(--accent);
    border-radius: 50%;
    cursor: pointer;
    border: none;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.slider-title {
    position: absolute;
    top: 6px;
    right: 12px;
    font-size: 10px;
    color: #666;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    z-index: 1;
    pointer-events: none;
    background: #fff;
    padding: 0 4px;
}

.slider-labels {
    display: flex;
    justify-content: space-between;
    font-size: 11px;
    color: var(--muted);
    margin-top: 4px;
}

.slider-value {
    margin-top: 8px;
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
    text-align: center;
}



/* Asset loading overlay for library tiles */
.asset-loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    border-radius: 8px;
    z-index: 10;
}

.asset-spinner {
    width: 24px;
    height: 24px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.asset-loading-text {
    color: white;
    font-size: 11px;
    margin-top: 8px;
    font-weight: 500;
}

/* Drag over state for empty canvas placeholder */
#canvas-placeholder.drag-over {
    background: rgba(37, 99, 235, 0.05);
    border: 2px dashed var(--accent);
}

#canvas-placeholder.drag-over .placeholder-content {
    opacity: 0.7;
}

/* Modern AI product style for asset creation grid - full width */
.asset-type-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 24px;
    margin-top: 48px;
    width: 100%;
    max-width: 900px;
    margin-left: auto;
    margin-right: auto;
}

.asset-type-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    padding: 48px 32px;
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: 16px;
    background: white;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
    /* Override any previous button styles */
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
}

.asset-type-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, transparent 0%, rgba(99, 102, 241, 0.05) 100%);
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
}

.asset-type-btn:hover {
    transform: translateY(-2px);
    background: white;
    border-color: #6366f1;
    box-shadow: 0 8px 24px rgba(99, 102, 241, 0.15);
}

.asset-type-btn:hover::before {
    opacity: 1;
}

.asset-type-btn svg {
    width: 32px;
    height: 32px;
    stroke: #6366f1;
    stroke-width: 1.5;
    transition: all 0.3s ease;
}

.asset-type-btn:hover svg {
    stroke: #5558e3;
    transform: scale(1.1);
}

.asset-type-btn span {
    font-size: 16px;
    font-weight: 600;
    color: #1e293b;
    letter-spacing: -0.01em;
}

.asset-type-btn:hover span {
    color: #0f172a;
}

/* Add subtle animation on page load */
.asset-type-btn:not(.no-fade-in) {
    animation: fade-in-up 0.5s ease-out;
    animation-fill-mode: both;
}

.asset-type-btn:not(.no-fade-in):nth-child(1) { animation-delay: 0.1s; }
.asset-type-btn:not(.no-fade-in):nth-child(2) { animation-delay: 0.2s; }
.asset-type-btn:not(.no-fade-in):nth-child(3) { animation-delay: 0.3s; }
.asset-type-btn:not(.no-fade-in):nth-child(4) { animation-delay: 0.4s; }

@keyframes fade-in-up {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes bounce {
    0%, 20%, 50%, 80%, 100% {
        transform: translateY(0);
    }
    40% {
        transform: translateY(-20px);
    }
    60% {
        transform: translateY(-10px);
    }
}

.asset-type-btn.bounce,
.clipboard-suggestions.bounce,
.clipboard-suggestion-box.bounce {
    animation: bounce 0.6s ease-out;
}

/* Style the create section intro */
.create-section-intro {
    margin-bottom: 24px;
}

.create-section-intro p {
    font-size: 16px;
    color: #64748b;
    line-height: 1.6;
    text-align: center;
}

/* Responsive for smaller screens */
@media (max-width: 480px) {
    #empty-state-title {
        margin-top:0;
        font-size: 48px;
    }
    
    #empty-state-description {
        font-size: 18px;
        margin-bottom: 10px;
        text-align: center;
    }
    
    .intro-main {
        font-size: 18px;
        margin-bottom: 32px;
        text-align: center;
    }
    
    .intro-features {
        grid-template-columns: 1fr;
        gap: 20px;
        margin: 32px auto;
    }
    
    .intro-feature {
        padding: 12px;
        gap: 16px;
        margin: 0 -12px;
    }
    
    .feature-icon {
        width: 36px;
        height: 36px;
    }
    
    .feature-text strong {
        font-size: 15px;
    }
    
    .feature-text {
        font-size: 13px;
    }

    .intro-continue-button {
        margin-top: 0;
        font-size: 1rem;
        padding: 0.875rem 2rem;
        width: auto;
        max-width: none;
        border-radius: 1.5rem;
    }
    
    .intro-continue-button svg {
        width: 1rem;
        height: 1rem;
    }
    
    .asset-type-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }
    
    .asset-type-btn {
        padding: 24px 20px;
        flex-direction: row;
        justify-content: flex-start;
    }
}

/* Missing Empty State Styles */
.asset-types {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 1rem;
    margin-top: 2rem;
    width: 100%;
    max-width: 600px;
    margin-left: auto;
    margin-right: auto;
}

.create-section {
    margin-top: 2rem;
    text-align: center;
}

.create-section h2 {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 1rem;
    color: var(--text);
}

.welcome-content {
    text-align: center;
    max-width: 800px;
    margin: 0 auto;
}

.welcome-title {
    font-size: 3rem;
    font-weight: 700;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.welcome-tagline {
    font-size: 1.25rem;
    color: var(--muted);
    margin-bottom: 3rem;
}

.welcome-benefits {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 2rem;
    margin-bottom: 3rem;
    text-align: left;
}

.benefit {
    padding: 1.5rem;
    background: var(--panel);
    border-radius: var(--radius);
    border: 1px solid var(--border);
}

.benefit svg {
    width: 2rem;
    height: 2rem;
    margin-bottom: 0.5rem;
    color: var(--accent);
}

.benefit h3 {
    font-size: 1.125rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--text);
}

.benefit p {
    font-size: 0.875rem;
    color: var(--muted);
    line-height: 1.5;
}

.fullspark-logo {
    width: 3rem;
    height: 3rem;
    color: var(--accent);
}

.full-text {
    color: var(--text);
}

.spark-text {
    color: var(--accent);
}
EOF < /dev/null
/* Responsive styles for welcome/empty states */
@media (max-width: 860px) {
    .welcome-content {
        padding: 1rem;
    }
    
    .welcome-title {
        font-size: 2rem;
    }
    
    .welcome-tagline {
        font-size: 1rem;
        margin-bottom: 2rem;
    }
    
    .welcome-benefits {
        grid-template-columns: 1fr;
        gap: 1rem;
        margin-bottom: 2rem;
    }
    
    .benefit {
        padding: 1rem;
    }
    
    .benefit h3 {
        font-size: 1rem;
    }
    
    .benefit p {
        font-size: 0.813rem;
    }
    
    .fullspark-logo {
        width: 3rem;
        height: 3rem;
    }
    
    .intro-continue-button {
        padding: 0.75rem 1.75rem;
        font-size: 0.9375rem;
        border-radius: 1.5rem;
    }
    
    /* Fix canvas placeholder on mobile */
    .canvas-placeholder.artboard {
        border: none;
        box-shadow: none;
        margin: 0;
        padding: 1rem;
        width: 100%;
        max-width: none;
        background: transparent;
    }
    
    /* Allow welcome content to use full width on mobile */
    .canvas-placeholder.artboard .welcome-content {
        max-width: none;
        width: 100%;
        padding: 1rem;
    }
}

@media (max-width: 480px) {
    .welcome-title {
        font-size: 1.5rem;
        flex-direction: column;
    }
    
    .welcome-tagline {
        font-size: 0.875rem;
    }
    
    .benefit {
        padding: 0.75rem;
    }
    
    .benefit svg {
        width: 1.5rem;
        height: 1.5rem;
    }
    
    .benefit h3 {
        font-size: 0.875rem;
    }
    
    .benefit p {
        font-size: 0.75rem;
    }
    
    .create-section h2 {
        font-size: 1.25rem;
    }
}
EOF < /dev/null
/* Simple clipboard preview styles */
.clipboard-preview {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    margin-bottom: 0.5rem;
}

.clipboard-preview svg {
    width: 1.25rem;
    height: 1.25rem;
    flex-shrink: 0;
    color: var(--accent);
}

.clipboard-text {
    flex: 1;
    font-size: 0.875rem;
    color: var(--text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.clipboard-hint {
    display: block;
    font-size: 0.75rem;
    color: var(--muted);
    text-align: center;
}

.clipboard-detected {
    cursor: pointer;
    transition: all 0.2s ease;
}

.clipboard-detected:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow);
}

/* Clipboard suggestion text styles */
.clipboard-suggestion-text h3 {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
    margin: 0 0 0.25rem 0;
}

.clipboard-suggestion-text p {
    font-size: 12px;
    color: var(--muted);
    margin: 0;
}

.clipboard-suggestion-preview {
    flex: 1;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}


/* Camera Modal Styles */
.camera-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.9);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.camera-modal.hidden {
    display: none;
}

.camera-container {
    background: var(--bg);
    border-radius: var(--radius);
    max-width: 90vw;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

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

.camera-header h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    color: var(--text);
}

.camera-close-btn {
    width: 32px;
    height: 32px;
    border: none;
    background: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-xs);
    color: var(--muted);
    transition: all 0.15s ease;
}

.camera-close-btn:hover {
    background: var(--hover-bg);
    color: var(--text);
}

.camera-view {
    position: relative;
    width: 640px;
    height: 480px;
    background: #000;
    display: flex;
    align-items: center;
    justify-content: center;
}

@media (max-width: 768px) {
    .camera-view {
        width: 100vw;
        height: 75vw;
    }
}

#camera-video,
#camera-canvas,
#camera-preview {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.camera-controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 20px;
    padding: 20px;
    background: var(--panel);
    border-top: 1px solid var(--border);
}

.camera-capture-btn {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    border: 4px solid var(--border-strong);
    background: var(--bg);
    cursor: pointer;
    position: relative;
    transition: all 0.2s ease;
}

.camera-capture-btn:hover {
    transform: scale(1.05);
}

.camera-capture-btn:active {
    transform: scale(0.95);
}

.capture-icon {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--accent);
    margin: auto;
}

.camera-btn {
    padding: 8px 16px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
    cursor: pointer;
    transition: all 0.15s ease;
}

.camera-btn:hover {
    background: #f3f4f6;
    border-color: var(--border);
}

.camera-use-btn {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
}

.camera-use-btn:hover {
    background: var(--accent-2);
    border-color: var(--accent-2);
}

.camera-switch-container {
    position: absolute;
    top: 20px;
    right: 20px;
    z-index: 10;
}

.camera-switch-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    background: rgba(0, 0, 0, 0.5);
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.camera-switch-btn:hover {
    background: rgba(0, 0, 0, 0.7);
    transform: scale(1.1);
}

.camera-switch-btn svg {
    width: 24px;
    height: 24px;
}
