﻿/* === THE NANOVERSE - LightBook Professional UI === */
/**
 * A full-featured Word + Excel workspace with modern glassmorphic design.
 * Neo-Minimalism + Organic Futurism (2026 Edition)
 * Follows Microsoft Office design principles with NANOVERSE aesthetics.
 */

/* === VARIABLES & FONTS === */
/* Core document fonts (pre-loaded); the full library is lazy-loaded by ribbon-dropdowns.js */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=JetBrains+Mono:wght@400;500&family=Outfit:wght@300;400;500;600;700&family=Roboto:wght@300;400;500;700&family=Open+Sans:wght@300;400;600;700&family=Lato:wght@300;400;700&family=Montserrat:wght@300;400;500;600;700&family=Poppins:wght@300;400;500;600;700&family=Merriweather:wght@300;400;700&family=Playfair+Display:wght@400;500;600;700&family=Lora:wght@400;500;600;700&family=Source+Code+Pro:wght@300;400;500;700&family=DM+Sans:wght@400;500;700&family=Fira+Code:wght@400;500;700&display=swap');

/* Import new modular CSS if available */
@import url('./css/lightbook-variables.css?v=3.5.0');
@import url('./css/lightbook-animations.css?v=3.5.0');
@import url('./css/lightbook-dropdowns.css?v=3.5.0');

/* Import spreadsheet mode CSS files directly (avoiding nested @import issues) */
@import url('./css/spreadsheet-ui.css?v=3.5.0');
@import url('./css/spreadsheet-ribbon.css?v=3.5.0');
@import url('./css/spreadsheet-grid.css?v=3.5.0');
@import url('./css/spreadsheet-menus.css?v=3.5.0');
@import url('./css/spreadsheet-components.css?v=3.5.0');
@import url('./css/spreadsheet-animations.css?v=3.5.0');
@import url('./css/spreadsheet-formats.css?v=3.5.0');
@import url('./css/spreadsheet-charts.css?v=3.5.0');
@import url('./css/spreadsheet-responsive.css?v=3.5.0');
@import url('./css/word-editor-glass.css?v=3.5.2');
@import url('./css/ai-suggestions.css?v=3.5.3');

/* === ACCESSIBILITY === */
.lb-skip-link {
    position: absolute;
    top: -100px;
    left: 0;
    background: var(--lb-accent-primary, #3b82f6);
    color: #fff;
    padding: 8px 16px;
    z-index: 10000;
    font-size: 14px;
    text-decoration: none;
    border-radius: 0 0 4px 0;
}

.lb-skip-link:focus {
    top: 0;
}

/* Visible focus ring for keyboard navigation */
.ribbon-toolbar button:focus-visible,
.lightbook-sidebar button:focus-visible,
.lightbook-statusbar button:focus-visible,
.lightbook-dropdown-menu .menu-item:focus-visible {
    outline: 2px solid var(--lb-accent-primary, #3b82f6);
    outline-offset: 2px;
    border-radius: 4px;
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* === OFFLINE INDICATOR === */
.lb-offline-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 1px 8px;
    margin-right: 8px;
    font-size: 11px;
    font-weight: 600;
    color: #fbbf24;
    background: rgba(251, 191, 36, 0.12);
    border: 1px solid rgba(251, 191, 36, 0.25);
    border-radius: 3px;
    letter-spacing: 0.3px;
    text-transform: uppercase;
}

.save-status.offline-queued {
    color: #fbbf24;
}

:root {
    /* Core Colors - Neo-Minimalism Dark Theme with Aurora Accents */
    --lb-bg-void: #050810;
    --lb-bg-base: #0a0e17;
    --lb-bg-elevated: #0f1420;
    --lb-bg-surface: #151b28;
    --lb-bg-overlay: #1c2333;
    --lb-bg-hover: #232b3e;
    --lb-bg-active: #2a3449;
    --lb-bg-highlight: #388bfd26;
    
    /* Glassmorphism */
    --lb-glass-primary: rgba(15, 20, 32, 0.85);
    --lb-glass-secondary: rgba(21, 27, 40, 0.75);
    --lb-glass-surface: rgba(28, 35, 51, 0.65);
    --lb-glass-blur: 20px;
    
    /* Text Colors */
    --lb-text-primary: #f8fafc;
    --lb-text-secondary: #94a3b8;
    --lb-text-tertiary: #64748b;
    --lb-text-muted: #475569;
    --lb-text-link: #60a5fa;
    
    /* Aurora Accent Colors */
    --lb-accent-primary: #00d4ff;
    --lb-accent-primary-rgb: 0, 212, 255;
    --lb-accent-cyan: #22d3ee;
    --lb-accent-green: #22c55e;
    --lb-accent-purple: #a855f7;
    --lb-accent-pink: #ec4899;
    --lb-accent-orange: #f97316;
    --lb-accent-red: #ef4444;
    --lb-accent-yellow: #eab308;
    
    /* Aurora Gradients */
    --lb-gradient-aurora: linear-gradient(135deg, #00d4ff 0%, #a855f7 50%, #22c55e 100%);
    --lb-gradient-aurora-soft: linear-gradient(135deg, rgba(0,212,255,0.15) 0%, rgba(168,85,247,0.1) 50%, rgba(34,197,94,0.05) 100%);
    --lb-gradient-primary: linear-gradient(135deg, #00d4ff, #0ea5e9);
    --lb-gradient-surface: linear-gradient(180deg, rgba(15,20,32,0.9) 0%, rgba(10,14,23,0.95) 100%);
    
    /* Borders */
    --lb-border-default: rgba(148, 163, 184, 0.1);
    --lb-border-subtle: rgba(148, 163, 184, 0.05);
    --lb-border-muted: #21262d;
    --lb-border-accent: rgba(0, 212, 255, 0.4);
    --lb-border-glow: rgba(0, 212, 255, 0.2);
    
    /* Shadows */
    --lb-shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --lb-shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
    --lb-shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.5);
    --lb-shadow-xl: 0 16px 48px rgba(0, 0, 0, 0.6);
    --lb-shadow-glow: 0 0 30px rgba(var(--lb-accent-primary-rgb), 0.15);
    --lb-shadow-aurora: 0 0 60px rgba(0, 212, 255, 0.1), 0 0 120px rgba(168, 85, 247, 0.05);
    
    /* Sizing */
    --lb-topbar-height: 52px;
    --lb-ribbon-height: 110px;
    --lb-toolbar-height: 40px;
    --lb-statusbar-height: 32px;
    --lb-mode-nav-width: 56px;
    --lb-sidebar-width: 320px;
    --lb-ai-panel-width: 380px;
    
    /* Border Radius - Organic curves */
    --lb-radius-xs: 4px;
    --lb-radius-sm: 6px;
    --lb-radius-md: 8px;
    --lb-radius-lg: 12px;
    --lb-radius-xl: 16px;
    --lb-radius-2xl: 24px;
    --lb-radius-organic: 20px;
    
    /* Transitions */
    --lb-transition-fast: 0.15s ease;
    --lb-transition-normal: 0.25s ease;
    --lb-transition-slow: 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    --lb-transition-spring: 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
    
    /* Fonts */
    --lb-font-ui: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --lb-font-display: 'Outfit', var(--lb-font-ui);
    --lb-font-mono: 'JetBrains Mono', 'Consolas', monospace;
}

/* === RESET & BASE === */
.lightbook-overlay *,
.lightbook-overlay *::before,
.lightbook-overlay *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

.lightbook-overlay {
    font-family: var(--lb-font-ui);
}

.lightbook-overlay button {
    font-family: inherit;
    cursor: pointer;
    border: none;
    background: none;
    color: inherit;
}

.lightbook-overlay input,
.lightbook-overlay textarea,
.lightbook-overlay select {
    font-family: inherit;
    color: inherit;
    background: transparent;
    border: 1px solid var(--lb-border-default);
    border-radius: var(--lb-radius-sm);
}

.lightbook-overlay input:focus,
.lightbook-overlay textarea:focus,
.lightbook-overlay select:focus {
    outline: none;
    border-color: var(--lb-accent-primary);
    box-shadow: 0 0 0 3px rgba(var(--lb-accent-primary-rgb), 0.15);
}

/* === OVERLAY & CONTAINER === */
.lightbook-overlay,
#lightbook-workspace-overlay {
    position: fixed;
    inset: 0;
    z-index: 100000;
    background: var(--lb-bg-void);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    opacity: 0;
    visibility: hidden;
    transition: opacity var(--lb-transition-slow), visibility var(--lb-transition-slow);
}

/* Aurora background effect */
.lightbook-overlay::before,
#lightbook-workspace-overlay::before {
    content: '';
    position: absolute;
    inset: 0;
    background: 
        radial-gradient(ellipse 80% 50% at 20% 20%, rgba(0, 212, 255, 0.15) 0%, transparent 50%),
        radial-gradient(ellipse 60% 40% at 80% 30%, rgba(168, 85, 247, 0.12) 0%, transparent 50%),
        radial-gradient(ellipse 70% 50% at 50% 80%, rgba(34, 197, 94, 0.08) 0%, transparent 50%);
    animation: auroraShift 20s ease-in-out infinite;
    pointer-events: none;
}

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

.lightbook-overlay.visible,
#lightbook-workspace-overlay.visible {
    opacity: 1;
    visibility: visible;
}

.lightbook-overlay.hidden,
#lightbook-workspace-overlay.hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.lightbook-container {
    width: 100%;
    height: 100%;
    max-width: 100%;
    max-height: 100%;
    background: var(--lb-glass-primary);
    -webkit-backdrop-filter: blur(var(--lb-glass-blur));
    backdrop-filter: blur(var(--lb-glass-blur));
    border: none;
    box-shadow: var(--lb-shadow-aurora);
    display: grid;
    /* 2-row grid: main + statusbar (activity bar & ribbon are floating) */
    grid-template-rows: 1fr var(--statusbar-h);
    grid-template-columns: 1fr;
    overflow: hidden;
    position: relative;
    transform: scale(0.98) translateY(20px);
    opacity: 0;
    transition: transform var(--lb-transition-spring), opacity var(--lb-transition-slow);
}

.lightbook-overlay.visible .lightbook-container,
#lightbook-workspace-overlay.visible .lightbook-container {
    transform: scale(1) translateY(0);
    opacity: 1;
}

/* === TOP BAR (REMOVED - merged into ribbon head) === */
.lightbook-topbar {
    display: none !important;
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
    min-width: 0;
}

.lightbook-close-btn {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--lb-radius-md);
    color: var(--lb-text-secondary);
    transition: all var(--lb-transition-fast);
    font-size: 18px;
}

.lightbook-close-btn:hover {
    background: var(--lb-bg-overlay);
    color: var(--lb-text-primary);
}

.lightbook-close-btn:active {
    transform: scale(0.95);
}

.document-info {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
    flex: 1;
    max-width: 300px;
}

.document-title {
    flex: 1;
    min-width: 120px;
    padding: 8px 12px;
    font-size: 14px;
    font-weight: 500;
    color: var(--lb-text-primary);
    background: transparent;
    border: 1px solid transparent;
    border-radius: var(--lb-radius-sm);
    transition: all var(--lb-transition-fast);
}

.document-title:hover {
    background: var(--lb-bg-surface);
    border-color: var(--lb-border-default);
}

.document-title:focus {
    background: var(--lb-bg-surface);
    border-color: var(--lb-accent-primary);
}

.save-status {
    font-size: 12px;
    color: var(--lb-text-muted);
    white-space: nowrap;
    padding: 4px 8px;
    border-radius: var(--lb-radius-xs);
    transition: all var(--lb-transition-fast);
}

.save-status.saving {
    color: var(--lb-accent-yellow);
    background: rgba(210, 153, 34, 0.1);
}

.save-status.saved {
    color: var(--lb-accent-green);
}

.save-status.error {
    color: var(--lb-accent-red);
    background: rgba(248, 81, 73, 0.1);
}

/* Top Bar Center - Mode Tabs */
.topbar-center {
    display: flex;
    align-items: center;
    justify-content: center;
}

.mode-tabs {
    display: flex;
    background: var(--lb-bg-surface);
    border-radius: var(--lb-radius-md);
    padding: 4px;
    gap: 4px;
}

.mode-tab {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 24px;
    border-radius: var(--lb-radius-sm);
    font-size: 13px;
    font-weight: 500;
    color: var(--lb-text-secondary);
    transition: all var(--lb-transition-fast);
    position: relative;
}

.mode-tab .icon {
    font-size: 16px;
}

.mode-tab:hover {
    color: var(--lb-text-primary);
    background: var(--lb-bg-overlay);
}

.mode-tab.active {
    background: linear-gradient(135deg, var(--lb-accent-primary), #0099cc);
    color: #000;
    font-weight: 600;
    box-shadow: 0 2px 8px rgba(var(--lb-accent-primary-rgb), 0.3);
}

/* Top Bar Right */
.topbar-right {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
    justify-content: flex-end;
}

.lb-alpha-tag {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 3px 10px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 1.2px;
    text-transform: uppercase;
    color: var(--lb-accent-primary);
    background: rgba(var(--lb-accent-primary-rgb), 0.08);
    border: 1px solid rgba(var(--lb-accent-primary-rgb), 0.25);
    border-radius: 20px;
    -webkit-backdrop-filter: blur(8px);
    backdrop-filter: blur(8px);
    box-shadow: 0 0 12px rgba(var(--lb-accent-primary-rgb), 0.15),
                inset 0 0 8px rgba(var(--lb-accent-primary-rgb), 0.05);
    -webkit-user-select: none;
    user-select: none;
    pointer-events: none;
    white-space: nowrap;
    animation: lb-alpha-pulse 3s ease-in-out infinite;
}

@keyframes lb-alpha-pulse {
    0%, 100% { box-shadow: 0 0 12px rgba(var(--lb-accent-primary-rgb), 0.15), inset 0 0 8px rgba(var(--lb-accent-primary-rgb), 0.05); }
    50% { box-shadow: 0 0 20px rgba(var(--lb-accent-primary-rgb), 0.3), inset 0 0 12px rgba(var(--lb-accent-primary-rgb), 0.1); }
}

.collaborators {
    display: flex;
    align-items: center;
    margin-right: 8px;
}

.collaborator-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 600;
    color: white;
    margin-left: -8px;
    border: 2px solid var(--lb-bg-elevated);
    transition: transform var(--lb-transition-fast);
}

.collaborator-avatar:first-child {
    margin-left: 0;
}

.collaborator-avatar:hover {
    transform: scale(1.15);
    z-index: 1;
}

.topbar-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    border-radius: var(--lb-radius-sm);
    font-size: 13px;
    font-weight: 500;
    color: var(--lb-text-secondary);
    transition: all var(--lb-transition-fast);
}

.topbar-btn:hover {
    background: var(--lb-bg-overlay);
    color: var(--lb-text-primary);
}

.topbar-btn:active {
    transform: scale(0.97);
}

.dropdown-arrow {
    font-size: 10px;
    opacity: 0.6;
}

/* === MAIN CONTENT AREA === */
/* Grid row, flex layout, and editor-canvas rules now handled by word-editor-glass.css */
.lightbook-main {
    grid-column: 1;
    grid-row: 1; /* Row 1 in 2-row grid: main | statusbar (activity bar & ribbon are floating) */
    display: flex;
    min-height: 0;
    overflow: hidden;
    background: var(--lb-bg-base);
    position: relative;
    padding-left: var(--ribbon-left-offset);
    padding-top: 64px; /* ribbon-gap + ribbon height + breathing room */
}

/* Editor canvas takes full space, AI sidebar is flex item */
.lightbook-main .editor-canvas {
    flex: 1;
    min-width: 0;
    flex-direction: row; /* Side-by-side: nav-pane + editor workspace */
}

.lightbook-main .ai-sidebar {
    flex-shrink: 0;
    width: var(--lb-ai-panel-width);
    transition: width var(--lb-transition-normal), opacity var(--lb-transition-normal);
}

.lightbook-main .ai-sidebar:not(.visible) {
    width: 0;
    overflow: hidden;
    opacity: 0;
    pointer-events: none;
}

/* === RIBBON TOOLBAR - Word Style === */
/* All ribbon styling (floating 3D glass) is in word-editor-glass.css */
/* Only keep non-ribbon items below */

.ribbon-btn-dropdown {
    padding-right: 20px;
}

.ribbon-btn-dropdown::after {
    content: '';
    position: absolute;
    right: 6px;
    top: 50%;
    transform: translateY(-50%);
    border: 4px solid transparent;
    border-top-color: currentColor;
}

.ribbon-select {
    padding: 6px 28px 6px 10px;
    background: var(--lb-bg-surface);
    border: 1px solid var(--lb-border-default);
    border-radius: var(--lb-radius-sm);
    color: var(--lb-text-primary);
    font-size: 12px;
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 8px center;
}

.ribbon-select:hover {
    border-color: var(--lb-accent-primary);
}

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

/* === AI SIDEBAR PANEL === */
.ai-sidebar {
    background: var(--lb-glass-secondary);
    -webkit-backdrop-filter: blur(var(--lb-glass-blur));
    backdrop-filter: blur(var(--lb-glass-blur));
    border-left: 1px solid var(--lb-border-default);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: width var(--lb-transition-normal);
}

.ai-sidebar.collapsed {
    width: 48px;
}

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

.ai-sidebar-title {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 14px;
    font-weight: 600;
    color: var(--lb-text-primary);
}

.ai-sidebar-title .ai-icon {
    width: 24px;
    height: 24px;
    background: var(--lb-gradient-aurora);
    border-radius: var(--lb-radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
}

.ai-sidebar-tabs {
    display: flex;
    padding: 0 16px;
    gap: 8px;
    border-bottom: 1px solid var(--lb-border-default);
}

.ai-tab {
    padding: 12px 4px;
    font-size: 12px;
    font-weight: 500;
    color: var(--lb-text-muted);
    border-bottom: 2px solid transparent;
    transition: all var(--lb-transition-fast);
}

.ai-tab:hover {
    color: var(--lb-text-primary);
}

.ai-tab.active {
    color: var(--lb-accent-primary);
    border-bottom-color: var(--lb-accent-primary);
}

.ai-sidebar-content {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
}

.ai-suggestion-card {
    background: var(--lb-bg-surface);
    border: 1px solid var(--lb-border-default);
    border-radius: var(--lb-radius-md);
    padding: 14px;
    margin-bottom: 12px;
    transition: all var(--lb-transition-fast);
    cursor: pointer;
}

.ai-suggestion-card:hover {
    border-color: var(--lb-accent-primary);
    box-shadow: 0 0 20px rgba(var(--lb-accent-primary-rgb), 0.1);
}

.ai-suggestion-type {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 4px 8px;
    border-radius: var(--lb-radius-xs);
    margin-bottom: 8px;
}

.ai-suggestion-type.grammar {
    background: rgba(239, 68, 68, 0.15);
    color: var(--lb-accent-red);
}

.ai-suggestion-type.style {
    background: rgba(168, 85, 247, 0.15);
    color: var(--lb-accent-purple);
}

.ai-suggestion-type.clarity {
    background: rgba(0, 212, 255, 0.15);
    color: var(--lb-accent-primary);
}

.ai-suggestion-content {
    font-size: 13px;
    color: var(--lb-text-primary);
    line-height: 1.5;
    margin-bottom: 10px;
}

.ai-suggestion-preview {
    font-size: 12px;
    color: var(--lb-text-secondary);
    background: var(--lb-bg-overlay);
    padding: 10px;
    border-radius: var(--lb-radius-sm);
    font-style: italic;
}

.ai-suggestion-actions {
    display: flex;
    gap: 8px;
    margin-top: 12px;
}

.ai-action-btn {
    flex: 1;
    padding: 8px;
    border-radius: var(--lb-radius-sm);
    font-size: 12px;
    font-weight: 500;
    transition: all var(--lb-transition-fast);
}

.ai-action-btn.primary {
    background: var(--lb-accent-primary);
    color: #000;
}

.ai-action-btn.primary:hover {
    filter: brightness(1.1);
}

.ai-action-btn.secondary {
    background: var(--lb-bg-overlay);
    color: var(--lb-text-secondary);
}

.ai-action-btn.secondary:hover {
    background: var(--lb-bg-hover);
    color: var(--lb-text-primary);
}

/* AI Chat Section */
.ai-chat-container {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.ai-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
}

.ai-chat-message {
    display: flex;
    gap: 10px;
    margin-bottom: 16px;
}

.ai-chat-avatar {
    width: 28px;
    height: 28px;
    border-radius: var(--lb-radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 12px;
}

.ai-chat-avatar.ai {
    background: var(--lb-gradient-aurora);
}

.ai-chat-avatar.user {
    background: var(--lb-bg-overlay);
    color: var(--lb-text-secondary);
}

.ai-chat-bubble {
    background: var(--lb-bg-surface);
    border-radius: var(--lb-radius-md);
    padding: 12px;
    max-width: 85%;
    font-size: 13px;
    line-height: 1.5;
    color: var(--lb-text-primary);
}

.ai-chat-input-container {
    padding: 16px;
    border-top: 1px solid var(--lb-border-default);
}

.ai-chat-input {
    width: 100%;
    padding: 12px 16px;
    background: var(--lb-bg-surface);
    border: 1px solid var(--lb-border-default);
    border-radius: var(--lb-radius-lg);
    color: var(--lb-text-primary);
    font-size: 13px;
    resize: none;
    transition: all var(--lb-transition-fast);
}

.ai-chat-input:focus {
    border-color: var(--lb-accent-primary);
    box-shadow: 0 0 0 3px rgba(var(--lb-accent-primary-rgb), 0.1);
}

.editor-surface {
    flex: 1;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    opacity: 1;
    transform: translateX(0);
    transition: opacity var(--lb-transition-normal), transform var(--lb-transition-normal);
}

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

.editor-surface.fade-out {
    opacity: 0;
    transform: translateX(-20px);
}

.editor-surface.fade-in {
    animation: slideInRight var(--lb-transition-normal) ease forwards;
}

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

/* Text editor container: block (contenteditable)  glass CSS handles styling */
.sheet-editor-container {
    flex: 1;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

/* === RIGHT SIDEBAR === */
.lightbook-sidebar {
    grid-row: 2;
    grid-column: 2;
    background: var(--lb-bg-elevated);
    border-left: 1px solid var(--lb-border-default);
    padding: 12px 6px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    overflow-y: auto;
}

.sidebar-section {
    margin-bottom: 12px;
}

.sidebar-section h3 {
    font-size: 9px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--lb-text-muted);
    padding: 6px 8px 4px;
}

.sidebar-btn {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 6px;
    border-radius: var(--lb-radius-sm);
    font-size: 10px;
    font-weight: 500;
    color: var(--lb-text-secondary);
    transition: all var(--lb-transition-fast);
    flex-direction: column;
    text-align: center;
}

.sidebar-btn:hover {
    background: var(--lb-bg-surface);
    color: var(--lb-text-primary);
    transform: translateY(-1px);
}

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

.sidebar-btn .icon {
    font-size: 16px;
    margin-bottom: 2px;
}

/* === STATUS BAR === */
.lightbook-statusbar {
    grid-row: 2;
    grid-column: 1 / -1;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    padding-left: var(--ribbon-left-offset);
    background: var(--lb-bg-elevated);
    border-top: 1px solid var(--lb-border-default);
    font-size: 11px;
    color: var(--lb-text-muted);
}

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

.page-info,
.word-count {
    padding: 2px 8px;
    border-radius: var(--lb-radius-xs);
    cursor: default;
    transition: all var(--lb-transition-fast);
}

.page-info:hover,
.word-count:hover {
    background: var(--lb-bg-overlay);
    color: var(--lb-text-secondary);
}

.collab-status {
    display: flex;
    align-items: center;
    gap: 6px;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--lb-text-muted);
    transition: all var(--lb-transition-fast);
}

.status-dot.online {
    background: var(--lb-accent-green);
    box-shadow: 0 0 8px var(--lb-accent-green);
    animation: pulse-glow 2s infinite;
}

@keyframes pulse-glow {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

.zoom-control {
    display: flex;
    align-items: center;
    gap: 4px;
}

.zoom-btn {
    width: 22px;
    height: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--lb-radius-xs);
    font-size: 14px;
    font-weight: 600;
    transition: all var(--lb-transition-fast);
}

.zoom-btn:hover {
    background: var(--lb-bg-overlay);
    color: var(--lb-text-primary);
}

#zoomPercent {
    min-width: 40px;
    text-align: center;
}

/* === DROPDOWN MENUS === */
.lightbook-dropdown-menu {
    position: absolute;
    top: calc(var(--lb-topbar-height) + 4px);
    right: 16px;
    min-width: 240px;
    background: var(--lb-bg-surface);
    border: 1px solid var(--lb-border-default);
    border-radius: var(--lb-radius-md);
    box-shadow: var(--lb-shadow-lg);
    padding: 6px;
    z-index: 1000;
    opacity: 0;
    transform: translateY(-10px);
    transition: all var(--lb-transition-fast);
    pointer-events: none;
}

.lightbook-dropdown-menu.visible {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

.lightbook-dropdown-menu.hidden {
    display: none;
}

.menu-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    border-radius: var(--lb-radius-sm);
    font-size: 13px;
    color: var(--lb-text-primary);
    cursor: pointer;
    transition: background var(--lb-transition-fast);
}

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

.menu-item .shortcut {
    font-size: 11px;
    color: var(--lb-text-muted);
    font-family: var(--lb-font-mono);
}

.menu-divider {
    height: 1px;
    background: var(--lb-border-default);
    margin: 6px 0;
}

/* === DIALOGS === */
.lightbook-dialog {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.7);
    z-index: 100001;
    opacity: 0;
    visibility: hidden;
    transition: all var(--lb-transition-normal);
}

.lightbook-dialog.visible {
    opacity: 1;
    visibility: visible;
}

.lightbook-dialog.hidden {
    display: none;
}

.dialog-content {
    width: 90%;
    max-width: 500px;
    background: var(--lb-bg-surface);
    border: 1px solid var(--lb-border-default);
    border-radius: var(--lb-radius-lg);
    box-shadow: var(--lb-shadow-xl);
    overflow: hidden;
    transform: scale(0.95);
    transition: transform var(--lb-transition-normal);
}

.lightbook-dialog.visible .dialog-content {
    transform: scale(1);
}

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

.dialog-header h2 {
    font-size: 16px;
    font-weight: 600;
    color: var(--lb-text-primary);
}

.dialog-close {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--lb-radius-sm);
    font-size: 20px;
    color: var(--lb-text-muted);
    transition: all var(--lb-transition-fast);
}

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

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

.dialog-body label {
    font-size: 12px;
    font-weight: 500;
    color: var(--lb-text-secondary);
    margin-bottom: 6px;
    display: block;
}

.dialog-body input,
.dialog-body select {
    width: 100%;
    padding: 10px 12px;
    background: var(--lb-bg-base);
    font-size: 14px;
}

.share-link-input {
    display: flex;
    gap: 8px;
}

.share-link-input input {
    flex: 1;
}

.copy-btn,
.invite-btn {
    padding: 10px 16px;
    background: var(--lb-accent-primary);
    color: #000;
    border-radius: var(--lb-radius-sm);
    font-size: 13px;
    font-weight: 600;
    transition: all var(--lb-transition-fast);
}

.copy-btn:hover,
.invite-btn:hover {
    filter: brightness(1.1);
    transform: translateY(-1px);
}

/* === LOADING OVERLAY === */
.lightbook-loading {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: rgba(13, 17, 23, 0.95);
    z-index: 10002;
    gap: 16px;
}

.lightbook-loading.hidden {
    display: none;
}

.loading-spinner {
    width: 44px;
    height: 44px;
    border: 3px solid var(--lb-border-default);
    border-top-color: var(--lb-accent-primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

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

/* === TEXT EDITOR STYLES === */
.lb-text-editor {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* DEPRECATED: Old lb-text-toolbar is no longer used.
   Formatting is now handled by the main ribbon-toolbar.
   Force hide any legacy instances. */
.lb-text-toolbar,
#lb-text-toolbar,
.lb-text-editor > .lb-text-toolbar {
    display: none !important;
    visibility: hidden !important;
    height: 0 !important;
    overflow: hidden !important;
    pointer-events: none !important;
}

/* LEGACY SUPPORT: In case old structure exists, make editor fill space */
.lb-text-editor {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.lb-text-editor .lb-editor-main {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.lb-text-editor .lb-editor-content {
    flex: 1;
    overflow: auto;
}

/* Original .lb-text-toolbar styles removed - toolbar is deprecated */
/*
.lb-text-toolbar {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 4px;
    padding: 8px 16px;
    background: var(--lb-bg-elevated);
    border-bottom: 1px solid var(--lb-border-default);
    min-height: var(--lb-toolbar-height);
}
*/

.lb-toolbar-group {
    display: flex;
    align-items: center;
    gap: 2px;
    padding: 0 10px;
    border-right: 1px solid var(--lb-border-muted);
}

.lb-toolbar-group:last-child {
    border-right: none;
}

.lb-toolbar-btn {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--lb-radius-sm);
    font-size: 14px;
    color: var(--lb-text-secondary);
    transition: all var(--lb-transition-fast);
    position: relative;
}

.lb-toolbar-btn:hover {
    background: var(--lb-bg-overlay);
    color: var(--lb-text-primary);
    transform: translateY(-1px);
}

.lb-toolbar-btn.active {
    background: var(--lb-accent-primary);
    color: #000;
}

.lb-toolbar-btn:active {
    transform: scale(0.93);
}

.lb-toolbar-btn[title]::after {
    content: attr(title);
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    padding: 6px 10px;
    background: var(--lb-bg-overlay);
    color: var(--lb-text-primary);
    font-size: 11px;
    white-space: nowrap;
    border-radius: var(--lb-radius-sm);
    opacity: 0;
    visibility: hidden;
    transition: all var(--lb-transition-fast);
    pointer-events: none;
    z-index: 100;
}

.lb-toolbar-btn:hover[title]::after {
    opacity: 1;
    visibility: visible;
}

.lb-toolbar-select {
    padding: 6px 10px;
    background: var(--lb-bg-surface);
    border: 1px solid var(--lb-border-default);
    border-radius: var(--lb-radius-sm);
    font-size: 12px;
    color: var(--lb-text-primary);
    min-width: 100px;
    cursor: pointer;
}

.lb-editor-main {
    flex: 1;
    display: flex;
    overflow: hidden;
    background: #1a1a2e;
}

/* Legacy .lb-editor-content / .lb-editor-page ï¿½ only used inside the
   text-editor.js fallback structure.  When the class is added to
   .text-editor-container inside the glass .editor-page, all visual
   properties are neutralised so a second "page" is never rendered. */
.lb-editor-content {
    flex: 1;
    display: flex;
    justify-content: center;
    overflow-y: auto;
    padding: 40px 20px;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
}

/* Neutralise .lb-editor-page when injected inside the glass .editor-page
   by text-editor.js (it adds lb-editor-page to the contenteditable div). */
.editor-page .lb-editor-page {
    /* Reset all legacy visual properties */
    background: transparent;
    box-shadow: none;
    border-radius: 0;
    padding: 0;
    min-height: 0;
    max-width: none;
    width: auto;
    color: inherit;
    font-size: inherit;
    line-height: inherit;
    outline: none;
}

.editor-page .lb-editor-page:focus {
    box-shadow: none;
    outline: none;
}

.editor-page .lb-editor-page:empty::before {
    display: none; /* Glass CSS handles the placeholder */
}

/* === SPREADSHEET EDITOR STYLES ===
   All spreadsheet/sheet styles are now in modular CSS files:
   - css/spreadsheet-ui.css     (layout, formula bar, tabs, status bar)
   - css/spreadsheet-grid.css   (grid, cells, headers, frozen panes)
   - css/spreadsheet-ribbon.css (ribbon buttons, dropdowns, color picker)
   - css/spreadsheet-menus.css  (context menu, dialogs, tooltips)
   - css/spreadsheet-components.css (autocomplete, validation, find/replace, charts)
   - css/spreadsheet-animations.css (keyframes, micro-interactions)
   - css/spreadsheet-formats.css    (number formats, conditional formatting)
   - css/spreadsheet-charts.css     (chart containers, legends, sparklines)
   - css/spreadsheet-responsive.css (breakpoints, print, touch, retina)
*/

/* === ACCESSIBILITY === */
.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;
}

.lightbook-overlay *:focus-visible {
    outline: 2px solid var(--lb-accent-primary);
    outline-offset: 2px;
}

.skip-link {
    position: absolute;
    top: -100%;
    left: 50%;
    transform: translateX(-50%);
    padding: 12px 24px;
    background: var(--lb-accent-primary);
    color: #000;
    font-weight: 600;
    border-radius: var(--lb-radius-md);
    z-index: 100001;
    transition: top var(--lb-transition-fast);
}

.skip-link:focus {
    top: 20px;
}

/* === SCROLLBAR === */
.lightbook-overlay ::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

.lightbook-overlay ::-webkit-scrollbar-track {
    background: var(--lb-bg-base);
}

.lightbook-overlay ::-webkit-scrollbar-thumb {
    background: var(--lb-bg-overlay);
    border-radius: 5px;
    border: 2px solid var(--lb-bg-base);
}

.lightbook-overlay ::-webkit-scrollbar-thumb:hover {
    background: var(--lb-text-muted);
}

/* === RESPONSIVE === */
@media (max-width: 1200px) {
    .lightbook-sidebar {
        display: none;
    }
    
    .lightbook-container {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .mode-tab .label { display: none; }
    .topbar-btn .label { display: none; }
    .document-info { max-width: 150px; }
    .lb-editor-page { padding: 40px 24px; }
}

/* Sheet toolbar ribbon styles now in css/spreadsheet-ui.css + css/spreadsheet-ribbon.css */

/* === PRINT === */
@media print {
    .lightbook-overlay {
        position: static;
        background: white;
    }
    
    .lightbook-topbar,
    .lightbook-sidebar,
    .lightbook-statusbar,
    .lb-text-toolbar,
    .sheet-toolbar-container,
    .sheet-tabs-bar,
    .ribbon-toolbar,
    .lightbook-dropdown-menu,
    .lb-find-replace-bar,
    .lb-comments-panel,
    .lb-ai-sidebar {
        display: none !important;
    }
    
    .lightbook-container {
        display: block;
        border: none;
        box-shadow: none;
    }
    
    .lightbook-main-content {
        margin: 0;
        padding: 0;
    }
    
    .lb-editor-page {
        box-shadow: none;
        background: white;
        color: black;
        margin: 0;
        padding: 20mm;
        max-width: none;
        width: 100%;
    }
    
    h1, h2, h3, h4, h5, h6 {
        page-break-after: avoid;
    }
    
    table, figure, img, blockquote, pre {
        page-break-inside: avoid;
    }
    
    @page {
        margin: 15mm;
        size: A4;
    }
}

/* === ENHANCED RIBBON TOOLBAR === */
/* Floating 3D glass ribbon ï¿½ main styling in word-editor-glass.css */
.ribbon-toolbar {
    /* position: absolute set in word-editor-glass.css ï¿½ do NOT override to relative */
    z-index: 50;
}

/* .ribbon-btn.large and .ribbon-btn.accent styles are in word-editor-glass.css */

.color-picker-btn {
    position: relative;
    flex-direction: column;
    gap: 2px;
}

.color-picker-btn .color-preview {
    position: absolute;
    bottom: 4px;
    left: 50%;
    transform: translateX(-50%);
    width: 14px;
    height: 3px;
    border-radius: 1px;
}

.color-picker-btn .color-input {
    position: absolute;
    opacity: 0;
    width: 100%;
    height: 100%;
    cursor: pointer;
}

/* Editor canvas & ruler ï¿½ all styling now in word-editor-glass.css.
   The .lightbook-main .editor-canvas rule at line ~473 provides
   the flex layout; glass CSS provides background + everything else.
   Ruler system (horizontal + vertical) is also in word-editor-glass.css. */

/* Editor page container & page ï¿½ advanced styling now in word-editor-glass.css */

/* === ENHANCED AI SIDEBAR === */
.ai-sidebar {
    width: var(--lb-ai-panel-width);
    transition: width var(--lb-transition-normal), opacity var(--lb-transition-normal);
}

.ai-sidebar:not(.visible) {
    width: 0;
    opacity: 0;
    pointer-events: none;
}

.ai-sidebar-close {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--lb-radius-sm);
    color: var(--lb-text-muted);
    transition: all var(--lb-transition-fast);
}

.ai-sidebar-close:hover {
    background: var(--lb-bg-overlay);
    color: var(--lb-text-primary);
}

.ai-tabs {
    display: flex;
    padding: 0 16px;
    gap: 8px;
    border-bottom: 1px solid var(--lb-border-default);
}

.ai-tab-content {
    display: none;
    flex-direction: column;
    flex: 1;
    overflow: hidden;
}

.ai-tab-content.active {
    display: flex;
}

.ai-suggestions-container {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
}

.ai-empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    text-align: center;
    color: var(--lb-text-muted);
}

.ai-empty-state svg {
    opacity: 0.5;
    margin-bottom: 16px;
}

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

.ai-hint {
    font-size: 12px;
    color: var(--lb-text-muted);
}

.ai-quick-actions {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    padding: 16px;
    border-top: 1px solid var(--lb-border-default);
}

.ai-quick-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 12px;
    background: var(--lb-bg-surface);
    border: 1px solid var(--lb-border-default);
    border-radius: var(--lb-radius-sm);
    color: var(--lb-text-secondary);
    font-size: 12px;
    font-weight: 500;
    transition: all var(--lb-transition-fast);
}

.ai-quick-btn:hover {
    background: var(--lb-bg-hover);
    border-color: var(--lb-accent-primary);
    color: var(--lb-text-primary);
}

.ai-chat-container {
    flex: 1;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.ai-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
}

.ai-chat-welcome {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 40px 20px;
}

.ai-chat-welcome svg {
    opacity: 0.7;
    margin-bottom: 16px;
    color: var(--lb-accent-primary);
}

.ai-chat-welcome h3 {
    font-size: 16px;
    font-weight: 600;
    color: var(--lb-text-primary);
    margin-bottom: 8px;
}

.ai-chat-welcome p {
    font-size: 13px;
    color: var(--lb-text-secondary);
}

.ai-message {
    margin-bottom: 16px;
}

.ai-message-user {
    display: flex;
    justify-content: flex-end;
}

.ai-message-user .ai-message-content {
    background: var(--lb-accent-primary);
    color: #000;
    border-radius: var(--lb-radius-md) var(--lb-radius-md) 4px var(--lb-radius-md);
    padding: 10px 14px;
    max-width: 80%;
    font-size: 13px;
}

.ai-message-assistant .ai-message-content {
    background: var(--lb-bg-surface);
    color: var(--lb-text-primary);
    border-radius: var(--lb-radius-md) var(--lb-radius-md) var(--lb-radius-md) 4px;
    padding: 10px 14px;
    max-width: 90%;
    font-size: 13px;
    line-height: 1.5;
}

/* Streaming indicator pulse */
.ai-message-streaming .ai-message-content {
    border-left: 2px solid var(--lb-accent-primary);
    animation: streamPulse 1.2s ease-in-out infinite;
}
@keyframes streamPulse {
    0%, 100% { border-left-color: var(--lb-accent-primary); }
    50% { border-left-color: transparent; }
}

/* ─── Typing Animator Skip Button ─────────────────────────── */
.lb-typing-skip-btn {
    position: fixed;
    bottom: 42px;
    right: 24px;
    z-index: 9999;
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    font-size: 12px;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.85);
    background: rgba(0, 212, 255, 0.15);
    border: 1px solid rgba(0, 212, 255, 0.3);
    border-radius: 6px;
    backdrop-filter: blur(12px);
    cursor: pointer;
    transition: background 0.2s, border-color 0.2s;
    animation: skipBtnFadeIn 0.25s ease-out;
}
.lb-typing-skip-btn:hover {
    background: rgba(0, 212, 255, 0.25);
    border-color: rgba(0, 212, 255, 0.5);
}
@keyframes skipBtnFadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ═══════════════════════════════════════════════════════════
   STUDIO-GRADE MARKDOWN RENDERING — Chat Assistant Messages
   ═══════════════════════════════════════════════════════════ */

.ai-message-assistant .md-heading {
    margin: 12px 0 6px;
    font-weight: 700;
    line-height: 1.3;
    color: var(--lb-text-primary);
}
.ai-message-assistant .md-h1 { font-size: 18px; border-bottom: 1px solid var(--lb-border-subtle); padding-bottom: 4px; }
.ai-message-assistant .md-h2 { font-size: 16px; }
.ai-message-assistant .md-h3 { font-size: 14px; }
.ai-message-assistant .md-h4,
.ai-message-assistant .md-h5,
.ai-message-assistant .md-h6 { font-size: 13px; }

.ai-message-assistant .md-paragraph {
    margin: 6px 0;
    line-height: 1.6;
}

.ai-message-assistant .md-hr {
    border: none;
    border-top: 1px solid var(--lb-border-subtle);
    margin: 12px 0;
}

/* Inline code */
.ai-message-assistant .md-inline-code {
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid var(--lb-border-subtle);
    border-radius: 4px;
    padding: 1px 5px;
    font-family: 'JetBrains Mono', 'Fira Code', Consolas, monospace;
    font-size: 12px;
    color: var(--lb-accent-primary);
}

/* Fenced code blocks */
.ai-message-assistant .md-code-block {
    background: rgba(0, 0, 0, 0.35);
    border: 1px solid var(--lb-border-subtle);
    border-radius: var(--lb-radius-md);
    padding: 12px 14px;
    margin: 8px 0;
    overflow-x: auto;
    font-family: 'JetBrains Mono', 'Fira Code', Consolas, monospace;
    font-size: 12px;
    line-height: 1.55;
    color: #d4d4d4;
    tab-size: 4;
}
.ai-message-assistant .md-code-block code {
    background: none;
    border: none;
    padding: 0;
    font-size: inherit;
    color: inherit;
}

/* Blockquotes */
.ai-message-assistant .md-blockquote {
    border-left: 3px solid var(--lb-accent-primary);
    background: rgba(0, 212, 255, 0.04);
    padding: 8px 12px;
    margin: 8px 0;
    border-radius: 0 var(--lb-radius-sm) var(--lb-radius-sm) 0;
    font-style: italic;
    color: var(--lb-text-secondary);
}
.ai-message-assistant .md-blockquote p { margin: 2px 0; }

/* Lists */
.ai-message-assistant .md-list {
    margin: 6px 0;
    padding-left: 20px;
}
.ai-message-assistant .md-list li {
    margin: 3px 0;
    line-height: 1.55;
}

/* Task list items */
.ai-message-assistant .task-list-item {
    list-style: none;
    margin-left: -20px;
    display: flex;
    align-items: baseline;
    gap: 6px;
}
.ai-message-assistant .task-list-item input[type="checkbox"] {
    accent-color: var(--lb-accent-primary);
    margin: 0;
}

/* Tables */
.ai-message-assistant .md-table {
    width: 100%;
    border-collapse: collapse;
    margin: 8px 0;
    font-size: 12px;
}
.ai-message-assistant .md-table th,
.ai-message-assistant .md-table td {
    border: 1px solid var(--lb-border-subtle);
    padding: 6px 10px;
    text-align: left;
}
.ai-message-assistant .md-table th {
    background: rgba(255, 255, 255, 0.05);
    font-weight: 600;
    color: var(--lb-text-primary);
}
.ai-message-assistant .md-table tr:nth-child(even) td {
    background: rgba(255, 255, 255, 0.02);
}

/* Links in assistant messages */
.ai-message-assistant a {
    color: var(--lb-accent-primary);
    text-decoration: none;
    border-bottom: 1px dotted var(--lb-accent-primary);
}
.ai-message-assistant a:hover {
    opacity: 0.85;
}

/* Strong / emphasis */
.ai-message-assistant strong { font-weight: 700; color: var(--lb-text-primary); }
.ai-message-assistant em { font-style: italic; }

.ai-chat-input-area {
    display: flex;
    gap: 8px;
    padding: 16px;
    border-top: 1px solid var(--lb-border-default);
}

.ai-chat-input {
    flex: 1;
    padding: 10px 14px;
    background: var(--lb-bg-surface);
    border: 1px solid var(--lb-border-default);
    border-radius: var(--lb-radius-lg);
    color: var(--lb-text-primary);
    font-size: 13px;
    resize: none;
    transition: all var(--lb-transition-fast);
}

.ai-chat-input:focus {
    border-color: var(--lb-accent-primary);
}

.ai-chat-send {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    border-radius: 0;
    padding: 0;
    cursor: pointer;
    color: var(--lb-text-muted);
    transition: color 0.25s ease, filter 0.25s ease, transform 0.15s ease;
}

.ai-chat-send svg {
    transition: filter 0.3s ease, stroke 0.3s ease;
    stroke: var(--lb-text-muted);
}

.ai-chat-send.active svg {
    stroke: url(#aiSendGradient);
    filter: drop-shadow(0 0 6px rgba(0, 212, 255, 0.5)) drop-shadow(0 0 14px rgba(168, 85, 247, 0.3));
}

.ai-chat-send:hover {
    transform: scale(1.1);
}

.ai-chat-send:hover svg {
    filter: drop-shadow(0 0 8px rgba(0, 212, 255, 0.6)) drop-shadow(0 0 18px rgba(168, 85, 247, 0.35));
}

.ai-chat-send:active {
    transform: scale(0.92);
}

.ai-history-container {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
}

/* === GLASS BUTTON STYLE === */
.glass-btn {
    background: var(--lb-glass-surface);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    border: 1px solid var(--lb-border-subtle);
}

.glass-btn:hover {
    background: var(--lb-bg-hover);
    border-color: var(--lb-border-default);
}

.glass-btn.active {
    background: rgba(var(--lb-accent-primary-rgb), 0.2);
    border-color: var(--lb-accent-primary);
    color: var(--lb-accent-primary);
}

/* === STATUS BAR ENHANCEMENTS === */
.status-center {
    display: flex;
    align-items: center;
    gap: 8px;
}

.editing-mode {
    font-size: 11px;
    color: var(--lb-text-muted);
    padding: 2px 8px;
    background: var(--lb-bg-surface);
    border-radius: var(--lb-radius-xs);
}

.divider {
    color: var(--lb-border-default);
}

.char-count {
    padding: 2px 8px;
    border-radius: var(--lb-radius-xs);
    cursor: default;
    transition: all var(--lb-transition-fast);
}

.char-count:hover {
    background: var(--lb-bg-overlay);
    color: var(--lb-text-secondary);
}

/* === MENU ITEM ENHANCEMENTS === */
.menu-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
}

.menu-item .menu-icon {
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--lb-text-secondary);
}

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

.menu-item .shortcut {
    font-size: 11px;
    color: var(--lb-text-muted);
    font-family: var(--lb-font-mono);
}

.menu-item .arrow {
    color: var(--lb-text-muted);
}

/* === DIALOG ENHANCEMENTS === */
.dialog-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
}

.dialog-header h2 {
    display: flex;
    align-items: center;
    gap: 10px;
}

.dialog-header h2 svg {
    color: var(--lb-accent-primary);
}

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

.permission-option {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
}

.permission-option input {
    display: none;
}

.permission-option .option-label {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    background: var(--lb-bg-overlay);
    border: 1px solid var(--lb-border-default);
    border-radius: var(--lb-radius-sm);
    width: 100%;
    transition: all var(--lb-transition-fast);
}

.permission-option input:checked + .option-label {
    background: rgba(var(--lb-accent-primary-rgb), 0.1);
    border-color: var(--lb-accent-primary);
    color: var(--lb-accent-primary);
}

.invite-input-group {
    display: flex;
    gap: 8px;
}

.invite-input-group input {
    flex: 1;
}

/* === LOADING CONTENT === */
.loading-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
}

.loading-spinner svg {
    animation: spin 1s linear infinite;
    color: var(--lb-accent-primary);
}

/* === SAVE STATUS DOT === */
.save-status .save-dot {
    display: inline-block;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--lb-accent-green);
    margin-right: 6px;
}

.save-status.saving .save-dot {
    background: var(--lb-accent-yellow);
    animation: pulse-glow 1s infinite;
}

.save-status.error .save-dot {
    background: var(--lb-accent-red);
}

/* === RESPONSIVE ADJUSTMENTS === */
@media (max-width: 1200px) {
    .ai-sidebar {
        width: 340px;
    }
    
    :root {
        --lb-ai-panel-width: 340px;
    }
}

@media (max-width: 992px) {
    .ai-sidebar {
        position: absolute;
        right: 0;
        top: 0;
        bottom: 0;
        z-index: 20;
        box-shadow: var(--lb-shadow-xl);
    }
    
    .lightbook-main {
        grid-template-columns: 1fr;
    }
    
    .ribbon-group-label {
        display: none;
    }
}

@media (max-width: 768px) {
    .ribbon-tabs {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    .ribbon-tab {
        padding: 8px 12px;
        white-space: nowrap;
    }
    
    .ribbon-panel {
        overflow-x: auto;
    }
    
    .topbar-btn .label {
        display: none;
    }
    
    .mode-tab .label {
        display: none;
    }
    
    .editor-page-container {
        padding: 16px;
    }
    
    .editor-page {
        width: 100%;
        min-width: auto;
    }
    
    .editor-page .text-editor-container {
        padding: 48px;
    }
}

/* === NOTIFICATION TOAST === */
.lb-notification {
    position: fixed;
    bottom: 60px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 100010;
    animation: slideUp 0.3s ease;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translate(-50%, 20px);
    }
    to {
        opacity: 1;
        transform: translate(-50%, 0);
    }
}

.lb-notification.fade-out {
    opacity: 0;
    transform: translate(-50%, -10px);
    transition: all 0.3s ease;
}

.notification-content {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 20px;
    background: var(--lb-bg-surface);
    border: 1px solid var(--lb-border-default);
    border-radius: var(--lb-radius-lg);
    box-shadow: var(--lb-shadow-lg);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
}

.lb-notification-info .notification-content {
    border-color: var(--lb-accent-primary);
}

.lb-notification-success .notification-content {
    border-color: var(--lb-accent-green);
}

.lb-notification-warning .notification-content {
    border-color: var(--lb-accent-yellow);
}

.lb-notification-error .notification-content {
    border-color: var(--lb-accent-red);
}

.notification-message {
    font-size: 13px;
    color: var(--lb-text-primary);
}

.notification-close {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--lb-radius-sm);
    color: var(--lb-text-muted);
    font-size: 18px;
    transition: all var(--lb-transition-fast);
}

.notification-close:hover {
    background: var(--lb-bg-overlay);
    color: var(--lb-text-primary);
}


/* â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•
   FILE CANVAS â€” Centered document browser
   6-step glass recipe: gradient bg â†’ backdrop-filter â†’ differential
   border â†’ multi-layer shadow â†’ specular highlight â†’ ambient glow
   â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â• */

.lb-file-canvas {
    position: absolute;
    inset: 0;
    z-index: 50;
    display: flex;
    align-items: center;
    justify-content: center;
    background: radial-gradient(ellipse at 50% 30%, rgba(0, 212, 255, 0.04) 0%, transparent 60%),
                var(--lb-bg-base);
    opacity: 1;
    transition: opacity 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden;
}

.lb-file-canvas.hidden {
    display: none !important;
}

/* Step 1: Glass surface with gradient bg */
.lb-fc-surface {
    position: relative;
    width: min(820px, 90vw);
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    background: linear-gradient(
        168deg,
        rgba(21, 27, 40, 0.88) 0%,
        rgba(13, 17, 23, 0.92) 50%,
        rgba(21, 27, 40, 0.85) 100%
    );
    /* Step 2: Frosted glass */
    backdrop-filter: blur(32px) saturate(1.4);
    -webkit-backdrop-filter: blur(32px) saturate(1.4);
    /* Step 3: Differential border */
    border: 1px solid;
    border-image: linear-gradient(
        to bottom,
        rgba(148, 163, 184, 0.18) 0%,
        rgba(148, 163, 184, 0.06) 100%
    ) 1;
    border-radius: var(--lb-radius-xl);
    border-image: none; /* border-radius needs solid border */
    border-color: rgba(148, 163, 184, 0.12);
    border-top-color: rgba(148, 163, 184, 0.2);
    /* Step 4: Multi-layer shadow */
    box-shadow:
        0 2px 4px rgba(0, 0, 0, 0.3),
        0 8px 24px rgba(0, 0, 0, 0.35),
        0 24px 48px rgba(0, 0, 0, 0.25),
        inset 0 1px 0 rgba(255, 255, 255, 0.04),
        0 0 80px rgba(0, 212, 255, 0.04);
    overflow: hidden;
    animation: fcSurfaceIn 0.45s cubic-bezier(0.16, 1, 0.3, 1) both;
}

@keyframes fcSurfaceIn {
    from {
        opacity: 0;
        transform: translateY(24px) scale(0.97);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* Step 5: Specular highlight */
.lb-fc-surface::before {
    content: '';
    position: absolute;
    top: 0;
    left: 16px;
    right: 16px;
    height: 1px;
    background: linear-gradient(
        90deg,
        transparent 0%,
        rgba(255, 255, 255, 0.12) 20%,
        rgba(0, 212, 255, 0.15) 50%,
        rgba(255, 255, 255, 0.12) 80%,
        transparent 100%
    );
    pointer-events: none;
    z-index: 1;
}

/* Step 6: Ambient glow */
.lb-fc-surface::after {
    content: '';
    position: absolute;
    top: -40px;
    left: 50%;
    transform: translateX(-50%);
    width: 260px;
    height: 80px;
    background: radial-gradient(ellipse, rgba(0, 212, 255, 0.08) 0%, transparent 70%);
    pointer-events: none;
    z-index: 0;
}

/* â”€â”€ Header band â”€â”€ */
.lb-fc-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 24px 0 24px;
    position: relative;
    z-index: 2;
}

.lb-fc-title-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.lb-fc-logo {
    color: var(--lb-accent-primary);
    opacity: 0.85;
}

.lb-fc-brand {
    font-size: 15px;
    font-weight: 600;
    letter-spacing: 0.3px;
    color: var(--lb-text-primary);
}

.lb-fc-actions {
    display: flex;
    align-items: center;
    gap: 4px;
}

.lb-fc-btn {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--lb-radius-sm);
    background: transparent;
    border: none;
    color: var(--lb-text-secondary);
    cursor: pointer;
    transition: all 0.18s ease;
}

.lb-fc-btn:hover {
    background: rgba(148, 163, 184, 0.1);
    color: var(--lb-text-primary);
}

.lb-fc-new-btn:hover {
    background: rgba(0, 212, 255, 0.12);
    color: var(--lb-accent-primary);
}

.lb-fc-close-btn.hidden {
    display: none;
}

/* â”€â”€ Mode filter tabs â”€â”€ */
.lb-fc-tabs {
    display: flex;
    gap: 2px;
    padding: 16px 24px 0 24px;
    position: relative;
    z-index: 2;
}

.lb-fc-tab {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 7px 14px;
    border: none;
    border-radius: var(--lb-radius-sm);
    background: transparent;
    color: var(--lb-text-muted);
    font-size: 12.5px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    letter-spacing: 0.2px;
}

.lb-fc-tab:hover {
    background: rgba(148, 163, 184, 0.08);
    color: var(--lb-text-secondary);
}

.lb-fc-tab.active {
    background: rgba(0, 212, 255, 0.1);
    color: var(--lb-accent-primary);
}

.lb-fc-tab.active svg {
    stroke: var(--lb-accent-primary);
}

/* â”€â”€ Document grid â”€â”€ */
.lb-fc-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 14px;
    padding: 18px 24px 24px 24px;
    overflow-y: auto;
    flex: 1;
    position: relative;
    z-index: 2;
    scrollbar-width: thin;
    scrollbar-color: rgba(148, 163, 184, 0.15) transparent;
}

.lb-fc-grid::-webkit-scrollbar {
    width: 5px;
}

.lb-fc-grid::-webkit-scrollbar-track {
    background: transparent;
}

.lb-fc-grid::-webkit-scrollbar-thumb {
    background: rgba(148, 163, 184, 0.15);
    border-radius: 10px;
}

/* â”€â”€ Document card â”€â”€ */
.lb-fc-card {
    position: relative;
    display: flex;
    flex-direction: column;
    padding: 16px;
    border-radius: var(--lb-radius-lg);
    background: linear-gradient(
        168deg,
        rgba(30, 38, 55, 0.65) 0%,
        rgba(21, 27, 40, 0.7) 100%
    );
    border: 1px solid rgba(148, 163, 184, 0.08);
    border-top-color: rgba(148, 163, 184, 0.13);
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    min-height: 130px;
}

.lb-fc-card:hover {
    border-color: rgba(0, 212, 255, 0.2);
    background: linear-gradient(
        168deg,
        rgba(30, 38, 55, 0.8) 0%,
        rgba(21, 27, 40, 0.85) 100%
    );
    box-shadow:
        0 4px 16px rgba(0, 0, 0, 0.3),
        0 0 24px rgba(0, 212, 255, 0.06);
    transform: translateY(-2px);
}

.lb-fc-card-icon {
    width: 34px;
    height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--lb-radius-md);
    margin-bottom: 12px;
    flex-shrink: 0;
}

.lb-fc-card-icon.text-icon {
    background: rgba(0, 212, 255, 0.1);
    color: var(--lb-accent-primary);
}

.lb-fc-card-icon.sheet-icon {
    background: rgba(52, 211, 153, 0.1);
    color: #34d399;
}

.lb-fc-card-title {
    font-size: 13.5px;
    font-weight: 550;
    color: var(--lb-text-primary);
    margin-bottom: 4px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    line-height: 1.3;
}

.lb-fc-card-meta {
    font-size: 11.5px;
    color: var(--lb-text-muted);
    line-height: 1.4;
}

.lb-fc-card-actions {
    position: absolute;
    top: 10px;
    right: 10px;
    display: flex;
    gap: 2px;
    opacity: 0;
    transition: opacity 0.18s ease;
}

.lb-fc-card:hover .lb-fc-card-actions {
    opacity: 1;
}

.lb-fc-card-action {
    width: 26px;
    height: 26px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--lb-radius-xs);
    background: rgba(13, 17, 23, 0.7);
    border: 1px solid rgba(148, 163, 184, 0.1);
    color: var(--lb-text-muted);
    cursor: pointer;
    transition: all 0.15s ease;
}

.lb-fc-card-action:hover {
    background: rgba(248, 113, 113, 0.15);
    border-color: rgba(248, 113, 113, 0.25);
    color: #f87171;
}

/* ── Local DOCX file card variant ── */
.lb-fc-card-local {
    border-color: rgba(168, 85, 247, 0.12);
    border-top-color: rgba(168, 85, 247, 0.2);
}

.lb-fc-card-local:hover {
    border-color: rgba(168, 85, 247, 0.3);
    box-shadow:
        0 4px 16px rgba(0, 0, 0, 0.3),
        0 0 24px rgba(168, 85, 247, 0.08);
}

.lb-fc-card-local .lb-fc-card-icon {
    background: rgba(168, 85, 247, 0.1);
    color: #a855f7;
}

/* Source badge (Desktop / Downloads / Documents / LightBook) */
.lb-fc-card-badge {
    position: absolute;
    top: 10px;
    right: 10px;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    border-radius: 999px;
    background: rgba(168, 85, 247, 0.1);
    border: 1px solid rgba(168, 85, 247, 0.18);
    color: #c084fc;
    font-size: 10px;
    font-weight: 550;
    letter-spacing: 0.3px;
    line-height: 1.6;
    pointer-events: none;
}

/* Section divider for local files in all mode */
.lb-fc-local-divider {
    grid-column: 1 / -1;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 0 4px 0;
    color: var(--lb-text-muted);
    font-size: 11.5px;
    font-weight: 550;
    letter-spacing: 0.4px;
}

.lb-fc-local-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: linear-gradient(90deg, rgba(168, 85, 247, 0.2), transparent 80%);
}

.lb-fc-local-divider svg {
    color: #a855f7;
    opacity: 0.7;
    flex-shrink: 0;
}

/* Local file icon accent */
.local-icon {
    background: rgba(168, 85, 247, 0.1);
    color: #a855f7;
}

/* â”€â”€ Empty state â”€â”€ */
.lb-fc-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 48px 24px;
    gap: 14px;
    flex: 1;
    position: relative;
    z-index: 2;
}

.lb-fc-empty.hidden {
    display: none;
}

.lb-fc-empty-text {
    font-size: 14px;
    color: var(--lb-text-muted);
    letter-spacing: 0.2px;
}

.lb-fc-create-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 9px 20px;
    border-radius: var(--lb-radius-md);
    background: rgba(0, 212, 255, 0.12);
    border: 1px solid rgba(0, 212, 255, 0.2);
    color: var(--lb-accent-primary);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    margin-top: 4px;
}

.lb-fc-create-btn:hover {
    background: rgba(0, 212, 255, 0.18);
    border-color: rgba(0, 212, 255, 0.35);
    box-shadow: 0 0 20px rgba(0, 212, 255, 0.1);
}

/* â”€â”€ Loading skeleton â”€â”€ */
.lb-fc-loading {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 14px;
    padding: 18px 24px 24px 24px;
    flex: 1;
    position: relative;
    z-index: 2;
}

.lb-fc-loading.hidden {
    display: none;
}

.lb-fc-skeleton {
    height: 130px;
    border-radius: var(--lb-radius-lg);
    background: linear-gradient(
        110deg,
        rgba(30, 38, 55, 0.4) 25%,
        rgba(50, 60, 80, 0.3) 37%,
        rgba(30, 38, 55, 0.4) 63%
    );
    background-size: 200% 100%;
    animation: fcShimmer 1.6s ease infinite;
}

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

/* â”€â”€ Responsive â”€â”€ */
@media (max-width: 640px) {
    .lb-fc-surface {
        width: 96vw;
        max-height: 88vh;
        border-radius: var(--lb-radius-lg);
    }

    .lb-fc-grid {
        grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
        gap: 10px;
        padding: 14px 16px 20px 16px;
    }

    .lb-fc-header {
        padding: 14px 16px 0 16px;
    }

    .lb-fc-tabs {
        padding: 12px 16px 0 16px;
    }

    .lb-fc-card {
        min-height: 110px;
        padding: 12px;
    }
}

/* ============================================
   FOCUS MODE - Full-page WYSIWYG Experience
   ============================================ */

/* Focus Mode - Hide all UI except editor canvas */
.lightbook-overlay.focus-mode .lightbook-topbar,
.lightbook-overlay.focus-mode .ribbon-toolbar,
.lightbook-overlay.focus-mode .lightbook-statusbar,
.lightbook-overlay.focus-mode .ai-sidebar-panel,
.lightbook-overlay.focus-mode .ai-sidebar,
.lightbook-overlay.focus-mode .lightbook-sidebar,
.lightbook-overlay.focus-mode .sheet-tabs-bar,
.lightbook-overlay.focus-mode .lb-ruler-area,
.lightbook-overlay.focus-mode .lb-ruler-v {
    display: none !important;
}

.lightbook-overlay.focus-mode .lightbook-container {
    grid-template-rows: 1fr !important;
    grid-template-columns: 1fr !important;
}

.lightbook-overlay.focus-mode .editor-canvas {
    grid-column: 1 !important;
    grid-row: 1 !important;
    height: 100vh !important;
    max-height: 100vh !important;
    border-radius: 0 !important;
}

.lightbook-overlay.focus-mode .editor-surface {
    height: 100% !important;
    padding: 80px 120px !important;
    display: flex;
    justify-content: center;
}

.lightbook-overlay.focus-mode .lb-editor-page,
.lightbook-overlay.focus-mode #textEditorContainer {
    max-width: 900px !important;
    width: 100% !important;
    min-height: 100% !important;
    margin: 0 auto !important;
    padding: 60px 80px !important;
    background: var(--lb-bg-page) !important;
    box-shadow: 
        0 0 100px rgba(0, 217, 255, 0.05),
        0 0 60px rgba(157, 0, 255, 0.03) !important;
}

/* Focus mode typing animation */
.lightbook-overlay.focus-mode #textEditorContainer::after {
    content: '';
    position: fixed;
    bottom: 20px;
    right: 20px;
    padding: 8px 16px;
    background: rgba(20, 25, 40, 0.8);
    border: 1px solid var(--lb-border-subtle);
    border-radius: var(--lb-radius-md);
    color: var(--lb-text-muted);
    font-size: 11px;
    font-family: var(--lb-font-sans);
    content: 'Press ESC to exit Focus Mode';
    opacity: 0.6;
    -webkit-backdrop-filter: blur(8px);
    backdrop-filter: blur(8px);
    transition: opacity 0.3s ease;
}

.lightbook-overlay.focus-mode:hover #textEditorContainer::after {
    opacity: 1;
}

/* ============================================
   VIEW MODES - Print & Web Layout
   ============================================ */

/* Print Layout Mode */
.lightbook-overlay.view-print .editor-surface {
    background: #e8e8e8;
}

.lightbook-overlay.view-print .lb-editor-page,
.lightbook-overlay.view-print #textEditorContainer {
    background: white !important;
    color: #1a1a1a !important;
    box-shadow: 
        0 2px 8px rgba(0, 0, 0, 0.1),
        0 0 0 1px rgba(0, 0, 0, 0.05) !important;
    max-width: 816px !important; /* 8.5 inches at 96dpi */
    min-height: 1056px !important; /* 11 inches at 96dpi */
    padding: 96px 72px !important; /* 1 inch margins */
}

/* Web Layout Mode - Full width continuous */
.lightbook-overlay.view-web .lb-editor-page,
.lightbook-overlay.view-web #textEditorContainer {
    max-width: 100% !important;
    min-height: auto !important;
    box-shadow: none !important;
    border-radius: 0 !important;
    background: var(--lb-bg-surface) !important;
}

/* ============================================
   LIGHT MODE THEME
   ============================================ */

.lightbook-overlay.light-mode {
    --lb-bg-deep: #f5f5f7;
    --lb-bg-base: #ffffff;
    --lb-bg-surface: #fafafa;
    --lb-bg-elevated: #f0f0f0;
    --lb-bg-overlay: rgba(0, 0, 0, 0.05);
    --lb-bg-page: #ffffff;
    --lb-text-primary: #1a1a1a;
    --lb-text-secondary: #4a4a4a;
    --lb-text-muted: #8a8a8a;
    --lb-border-default: rgba(0, 0, 0, 0.1);
    --lb-border-subtle: rgba(0, 0, 0, 0.05);
}

.lightbook-overlay.light-mode .lightbook-topbar,
.lightbook-overlay.light-mode .ribbon-toolbar {
    background:
        linear-gradient(165deg,
            rgba(255, 255, 255, 0.84) 0%,
            rgba(246, 248, 252, 0.90) 42%,
            rgba(237, 241, 247, 0.94) 100%);
    border-color: rgba(255, 255, 255, 0.62);
}

.lightbook-overlay.light-mode .editor-surface {
    background: #e8e8ec;
}

/* === FINAL FLOATING RIBBON CASCADE GUARD === */
.lightbook-overlay .ribbon-toolbar,
#lightbook-workspace-overlay .ribbon-toolbar {
    position: absolute;
    top: var(--ribbon-gap);
    left: var(--ribbon-left-offset);
    right: var(--ribbon-gap);
    display: flex;
    flex-direction: column;
    z-index: 50;
    border-radius: var(--ribbon-radius, 16px);
    background:
        linear-gradient(168deg,
            rgba(22, 28, 44, 0.58) 0%,
            rgba(14, 18, 32, 0.65) 40%,
            rgba(10, 14, 24, 0.70) 100%);
    -webkit-backdrop-filter: blur(44px) saturate(140%);
    backdrop-filter: blur(44px) saturate(140%);
    border: 1px solid rgba(255,255,255,0.08);
    border-top-color: rgba(255,255,255,0.12);
    border-bottom-color: rgba(0,0,0,0.18);
    box-shadow:
        0 4px 16px rgba(0, 0, 0, 0.35),
        0 1px 4px rgba(0, 0, 0, 0.25),
        0 12px 48px -8px rgba(0, 0, 0, 0.20),
        0 8px 32px -8px rgba(0, 212, 255, 0.03),
        inset 0 1px 0 rgba(255,255,255,0.10),
        inset 0 -1px 0 rgba(0,0,0,0.10);
    overflow: hidden;
}

.lightbook-overlay .ribbon-tabs,
#lightbook-workspace-overlay .ribbon-tabs {
    height: 38px;
    padding: 0 10px;
    align-items: center;
    border-bottom: 1px solid rgba(255,255,255,0.04);
}

.lightbook-overlay .ribbon-tab,
#lightbook-workspace-overlay .ribbon-tab {
    padding: 6px 14px;
    border: none;
    border-radius: 8px;
    color: rgba(200, 210, 230, 0.55);
    background: transparent;
    letter-spacing: 0.35px;
}

.lightbook-overlay .ribbon-tab:hover,
#lightbook-workspace-overlay .ribbon-tab:hover {
    color: rgba(220, 228, 242, 0.85);
    background: rgba(255,255,255,0.04);
}

.lightbook-overlay .ribbon-tab.active,
#lightbook-workspace-overlay .ribbon-tab.active {
    color: var(--lb-accent-primary);
    background: rgba(0,212,255,0.06);
    box-shadow: inset 0 -2px 0 var(--lb-accent-primary), 0 0 12px rgba(0,212,255,0.04);
}

.lightbook-overlay .ribbon-panel,
#lightbook-workspace-overlay .ribbon-panel {
    padding: 8px 14px 10px;
    min-height: 78px;
    overflow: visible;
}

.lightbook-overlay .ribbon-group-label,
#lightbook-workspace-overlay .ribbon-group-label {
    font-size: 9px;
    letter-spacing: 0.8px;
    color: rgba(200,210,230,0.30);
}

.lightbook-overlay .ribbon-btn,
#lightbook-workspace-overlay .ribbon-btn {
    border-radius: 8px;
    background:
        linear-gradient(180deg,
            rgba(255,255,255,0.05) 0%,
            rgba(255,255,255,0.015) 100%);
    border: 1px solid rgba(255,255,255,0.06);
    color: rgba(200,212,230,0.70);
    box-shadow:
        0 1px 3px rgba(0,0,0,0.22),
        inset 0 1px 0 rgba(255,255,255,0.08),
        inset 0 -1px 0 rgba(0,0,0,0.06);
}

.lightbook-overlay .ribbon-btn:hover,
#lightbook-workspace-overlay .ribbon-btn:hover {
    background:
        linear-gradient(180deg,
            rgba(0,212,255,0.10) 0%,
            rgba(0,212,255,0.03) 100%);
    border-color: rgba(0,212,255,0.20);
    color: rgba(230,240,255,0.95);
    box-shadow:
        0 2px 8px rgba(0,212,255,0.12),
        0 1px 3px rgba(0,0,0,0.25),
        inset 0 1px 0 rgba(255,255,255,0.12),
        inset 0 -1px 0 rgba(0,0,0,0.08);
}

.lightbook-overlay .ribbon-btn.active,
#lightbook-workspace-overlay .ribbon-btn.active {
    background:
        linear-gradient(180deg,
            rgba(0,212,255,0.14) 0%,
            rgba(0,212,255,0.06) 100%);
    border-color: rgba(0,212,255,0.28);
    color: var(--lb-accent-primary);
    box-shadow:
        0 0 12px rgba(0,212,255,0.12),
        0 2px 6px rgba(0,0,0,0.20),
        inset 0 1px 0 rgba(0,212,255,0.15),
        inset 0 -1px 0 rgba(0,0,0,0.10);
}

.lightbook-overlay .ribbon-collapse-btn,
#lightbook-workspace-overlay .ribbon-collapse-btn {
    border-radius: 8px;
    background:
        linear-gradient(180deg,
            rgba(255,255,255,0.06) 0%,
            rgba(255,255,255,0.02) 100%);
    border: 1px solid rgba(255,255,255,0.10);
    box-shadow:
        0 1px 3px rgba(0,0,0,0.25),
        inset 0 1px 0 rgba(255,255,255,0.08);
}

/* ============================================
   LAYOUT-CRITICAL CASCADE GUARDS
   Protect A4 dimensions, ruler, and tiptap-host
   from being overridden by word-editor-glass.css
   ============================================ */

.lightbook-overlay .editor-page {
    width: 794px;
    min-height: 1123px;
    border-radius: 12px;
    /* Reduced shadow — page sections carry individual depth via footer/header */
    box-shadow:
        0 1px 2px rgba(0,0,0,0.06),
        0 2px 8px rgba(0,0,0,0.08),
        inset 0 1px 0 rgba(255,255,255,0.03),
        0 0 0 1px rgba(255,255,255,0.015);
}

.lightbook-overlay .editor-page .text-editor-container.lb-tiptap-host {
    padding: 0;
}

/* ============================================
   HIDDEN UTILITY CLASSES
   ============================================ */

.hide-gridlines .sheet-grid-line {
    display: none !important;
}

