/* === 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 === */
@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&display=swap');

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

/* Import spreadsheet mode CSS files directly (avoiding nested @import issues) */
@import url('./css/spreadsheet-ui.css');
@import url('./css/spreadsheet-ribbon.css');
@import url('./css/spreadsheet-grid.css');
@import url('./css/spreadsheet-menus.css');
@import url('./css/spreadsheet-components.css');
@import url('./css/spreadsheet-animations.css');
@import url('./css/spreadsheet-formats.css');
@import url('./css/spreadsheet-charts.css');
@import url('./css/spreadsheet-responsive.css');

: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: 360px;
    
    /* 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);
    backdrop-filter: blur(var(--lb-glass-blur));
    -webkit-backdrop-filter: blur(var(--lb-glass-blur));
    border: none;
    box-shadow: var(--lb-shadow-aurora);
    display: grid;
    grid-template-rows: var(--lb-topbar-height) var(--lb-ribbon-height) 1fr var(--lb-statusbar-height);
    grid-template-columns: 1fr;
    overflow: hidden;
    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 - Neo-Minimalism === */
.lightbook-topbar {
    grid-column: 1 / -1;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    background: linear-gradient(180deg, var(--lb-bg-elevated) 0%, var(--lb-bg-base) 100%);
    border-bottom: 1px solid var(--lb-border-default);
    gap: 20px;
    position: relative;
    z-index: 10;
}

.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;
}

.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 === */
.lightbook-main {
    grid-column: 1;
    display: flex; /* Changed from grid to flex for better dynamic sizing */
    overflow: hidden;
    background: var(--lb-bg-base);
    position: relative;
}

/* Editor canvas takes full space, AI sidebar is flex item */
.lightbook-main .editor-canvas {
    flex: 1;
    min-width: 0; /* Allow shrinking */
}

.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 === */
.lightbook-ribbon {
    grid-column: 1 / -1;
    background: linear-gradient(180deg, var(--lb-bg-surface) 0%, var(--lb-bg-elevated) 100%);
    border-bottom: 1px solid var(--lb-border-default);
    display: flex;
    flex-direction: column;
    position: relative;
    z-index: 5;
}

.ribbon-tabs {
    display: flex;
    padding: 0 16px;
    gap: 2px;
    border-bottom: 1px solid var(--lb-border-subtle);
}

.ribbon-tab {
    padding: 10px 18px;
    font-size: 12px;
    font-weight: 500;
    color: var(--lb-text-secondary);
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    cursor: pointer;
    transition: all var(--lb-transition-fast);
    position: relative;
}

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

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

.ribbon-tab.active::after {
    content: '';
    position: absolute;
    bottom: -1px;
    left: 0;
    right: 0;
    height: 2px;
    background: var(--lb-gradient-primary);
    border-radius: 2px 2px 0 0;
}

.ribbon-panel {
    display: none;
    padding: 8px 16px 12px;
    gap: 16px;
    min-height: 70px;
}

.ribbon-panel.active {
    display: flex;
}

.ribbon-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding-right: 16px;
    border-right: 1px solid var(--lb-border-subtle);
}

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

.ribbon-group-label {
    font-size: 10px;
    color: var(--lb-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    text-align: center;
    margin-top: auto;
}

.ribbon-group-content {
    display: flex;
    align-items: center;
    gap: 4px;
    flex: 1;
}

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

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

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

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

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

.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);
    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,
.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-column: 1 / -1;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    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;
}

.lb-editor-content {
    flex: 1;
    display: flex;
    justify-content: center;
    overflow-y: auto;
    padding: 40px 20px;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
}

.lb-editor-page {
    width: 100%;
    max-width: 816px;
    min-height: 1056px;
    background: #1e2746;
    border-radius: var(--lb-radius-lg);
    box-shadow: var(--lb-shadow-lg), 0 0 60px rgba(0, 0, 0, 0.3);
    padding: 72px;
    color: var(--lb-text-primary);
    font-size: 14px;
    line-height: 1.7;
    outline: none;
    transition: box-shadow var(--lb-transition-fast);
}

.lb-editor-page:focus {
    box-shadow: var(--lb-shadow-lg), 0 0 0 3px rgba(var(--lb-accent-primary-rgb), 0.2);
}

.lb-editor-page:empty::before {
    content: 'Start typing here...';
    color: var(--lb-text-muted);
    font-style: italic;
}

.lb-editor-page p {
    margin-bottom: 12px;
}

.lb-editor-page h1 { font-size: 28px; font-weight: 700; margin: 24px 0 16px; }
.lb-editor-page h2 { font-size: 22px; font-weight: 600; margin: 20px 0 12px; }
.lb-editor-page h3 { font-size: 18px; font-weight: 600; margin: 16px 0 10px; }

.lb-editor-page ul, .lb-editor-page ol { margin: 12px 0; padding-left: 28px; }
.lb-editor-page li { margin: 4px 0; }

.lb-editor-page blockquote {
    border-left: 4px solid var(--lb-accent-primary);
    padding-left: 16px;
    margin: 16px 0;
    color: var(--lb-text-secondary);
    font-style: italic;
}

.lb-editor-page table {
    width: 100%;
    border-collapse: collapse;
    margin: 16px 0;
}

.lb-editor-page th, .lb-editor-page td {
    border: 1px solid var(--lb-border-default);
    padding: 10px 12px;
}

.lb-editor-page th {
    background: var(--lb-bg-overlay);
    font-weight: 600;
}

.lb-editor-page a {
    color: var(--lb-accent-primary);
}

.lb-editor-page code {
    font-family: var(--lb-font-mono);
    background: var(--lb-bg-overlay);
    padding: 2px 6px;
    border-radius: var(--lb-radius-xs);
    font-size: 13px;
}

/* === SPREADSHEET EDITOR STYLES === */
.sheet-editor {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.sheet-toolbar-container {
    display: flex;
    flex-direction: column;
    background: var(--lb-bg-elevated);
    border-bottom: 1px solid var(--lb-border-default);
}

.sheet-formula-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 16px;
    border-bottom: 1px solid var(--lb-border-muted);
}

.formula-cell-ref {
    min-width: 70px;
    padding: 7px 10px;
    background: var(--lb-bg-surface);
    border: 1px solid var(--lb-border-default);
    border-radius: var(--lb-radius-sm);
    font-family: var(--lb-font-mono);
    font-size: 12px;
    color: var(--lb-text-primary);
    text-align: center;
}

.formula-input-wrapper {
    flex: 1;
    display: flex;
    align-items: center;
}

.formula-fx {
    padding: 0 12px;
    font-style: italic;
    color: var(--lb-text-muted);
    font-weight: 600;
}

.formula-input {
    flex: 1;
    padding: 7px 12px;
    background: var(--lb-bg-surface);
    border: 1px solid var(--lb-border-default);
    border-radius: var(--lb-radius-sm);
    font-family: var(--lb-font-mono);
    font-size: 13px;
    color: var(--lb-text-primary);
}

.sheet-toolbar {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 4px;
    padding: 6px 16px;
}

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

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

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

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

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

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

.sheet-toolbar-select {
    padding: 5px 8px;
    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);
}

.sheet-toolbar-input {
    width: 45px;
    padding: 5px 6px;
    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);
    text-align: center;
}

/* Sheet Main Area */
.sheet-main {
    flex: 1;
    overflow: hidden;
    position: relative;
    background: var(--lb-bg-base);
}

.sheet-grid-container {
    position: absolute;
    inset: 0;
    overflow: auto;
}

.sheet-grid {
    position: relative;
    min-width: 100%;
    min-height: 100%;
}

.sheet-corner {
    position: sticky;
    top: 0;
    left: 0;
    width: 50px;
    height: 28px;
    background: var(--lb-bg-elevated);
    border-right: 1px solid var(--lb-border-default);
    border-bottom: 1px solid var(--lb-border-default);
    z-index: 3;
}

.sheet-col-headers-wrapper {
    position: sticky;
    top: 0;
    margin-left: 50px;
    height: 28px;
    z-index: 2;
    overflow: hidden;
}

.sheet-col-headers {
    display: flex;
    height: 100%;
}

.sheet-col-header {
    min-width: 100px;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--lb-bg-elevated);
    border-right: 1px solid var(--lb-border-default);
    border-bottom: 1px solid var(--lb-border-default);
    font-size: 12px;
    font-weight: 500;
    color: var(--lb-text-secondary);
    -webkit-user-select: none;
    user-select: none;
    position: relative;
    transition: background var(--lb-transition-fast);
}

.sheet-col-header:hover {
    background: var(--lb-bg-overlay);
    color: var(--lb-text-primary);
}

.sheet-col-header.selected {
    background: var(--lb-bg-highlight);
    color: var(--lb-accent-primary);
}

.sheet-col-resizer {
    position: absolute;
    right: 0;
    top: 0;
    width: 5px;
    height: 100%;
    cursor: col-resize;
}

.sheet-col-resizer:hover {
    background: var(--lb-accent-primary);
}

.sheet-row-headers {
    position: sticky;
    left: 0;
    width: 50px;
    z-index: 2;
}

.sheet-row-header {
    width: 100%;
    height: 26px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--lb-bg-elevated);
    border-right: 1px solid var(--lb-border-default);
    border-bottom: 1px solid var(--lb-border-default);
    font-size: 12px;
    font-weight: 500;
    color: var(--lb-text-secondary);
    -webkit-user-select: none;
    user-select: none;
    transition: background var(--lb-transition-fast);
}

.sheet-row-header:hover {
    background: var(--lb-bg-overlay);
    color: var(--lb-text-primary);
}

.sheet-row-header.selected {
    background: var(--lb-bg-highlight);
    color: var(--lb-accent-primary);
}

/* Cells */
.sheet-cells-viewport {
    position: absolute;
    top: 28px;
    left: 50px;
}

.sheet-cell {
    position: absolute;
    display: flex;
    align-items: center;
    padding: 0 8px;
    background: var(--lb-bg-base);
    border-right: 1px solid var(--lb-border-muted);
    border-bottom: 1px solid var(--lb-border-muted);
    font-size: 13px;
    color: var(--lb-text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    transition: background var(--lb-transition-fast);
}

.sheet-cell:hover {
    background: var(--lb-bg-surface);
}

.sheet-cell.selected {
    background: var(--lb-bg-highlight);
    outline: 2px solid var(--lb-accent-primary);
    outline-offset: -1px;
    z-index: 1;
}

.sheet-cell.editing {
    padding: 0;
    background: white;
}

.sheet-cell-input {
    width: 100%;
    height: 100%;
    padding: 0 8px;
    background: white;
    color: #1a1a1a;
    border: none;
    font-size: 13px;
    font-family: inherit;
    outline: none;
}

.sheet-selection-range {
    position: absolute;
    border: 2px solid var(--lb-accent-primary);
    background: rgba(var(--lb-accent-primary-rgb), 0.1);
    pointer-events: none;
    z-index: 1;
}

.sheet-selection-handle {
    position: absolute;
    right: -4px;
    bottom: -4px;
    width: 8px;
    height: 8px;
    background: var(--lb-accent-primary);
    border: 2px solid var(--lb-bg-base);
    cursor: crosshair;
    z-index: 2;
}

/* Sheet Tabs */
.sheet-tabs-bar {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: var(--lb-bg-elevated);
    border-top: 1px solid var(--lb-border-default);
    min-height: 40px;
}

.sheet-tabs-controls {
    display: flex;
    align-items: center;
    gap: 4px;
}

.sheet-nav-btn,
.sheet-add-btn {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--lb-radius-sm);
    font-size: 14px;
    color: var(--lb-text-muted);
    transition: all var(--lb-transition-fast);
}

.sheet-nav-btn:hover,
.sheet-add-btn:hover {
    background: var(--lb-bg-overlay);
    color: var(--lb-text-primary);
}

.sheet-tabs-list {
    display: flex;
    align-items: center;
    gap: 4px;
    overflow-x: auto;
    flex: 1;
}

.sheet-tab {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    background: var(--lb-bg-surface);
    border-radius: var(--lb-radius-sm) var(--lb-radius-sm) 0 0;
    font-size: 12px;
    color: var(--lb-text-secondary);
    cursor: pointer;
    transition: all var(--lb-transition-fast);
    white-space: nowrap;
    border-bottom: 2px solid transparent;
}

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

.sheet-tab.active {
    background: var(--lb-bg-base);
    color: var(--lb-accent-primary);
    border-bottom-color: var(--lb-accent-primary);
}

.sheet-status-bar {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 16px;
    padding: 0 12px;
}

.sheet-status-item {
    font-size: 11px;
    color: var(--lb-text-muted);
}

/* === 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 === */
.sheet-toolbar {
    background: var(--lb-bg-elevated);
    border-bottom: 1px solid var(--lb-border-default);
}

.sheet-toolbar .toolbar-tabs {
    display: flex;
    gap: 2px;
    padding: 6px 16px;
    background: var(--lb-bg-surface);
    border-bottom: 1px solid var(--lb-border-muted);
}

.sheet-toolbar .tab-btn {
    padding: 6px 16px;
    background: transparent;
    border: none;
    color: var(--lb-text-secondary);
    font-size: 12px;
    font-weight: 500;
    border-radius: var(--lb-radius-sm);
    cursor: pointer;
    transition: all var(--lb-transition-fast);
}

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

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

.sheet-toolbar .toolbar-panels {
    padding: 8px 16px;
}

.sheet-toolbar .toolbar-panel {
    display: none;
}

.sheet-toolbar .toolbar-panel.active {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
}

.sheet-toolbar .toolbar-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding-right: 16px;
    border-right: 1px solid var(--lb-border-muted);
}

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

.sheet-toolbar .group-label {
    font-size: 9px;
    color: var(--lb-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    text-align: center;
}

.sheet-toolbar .group-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 2px;
    align-items: center;
}

.sheet-toolbar .toolbar-btn {
    min-width: 28px;
    height: 28px;
    padding: 4px 8px;
    background: transparent;
    border: none;
    color: var(--lb-text-secondary);
    font-size: 12px;
    border-radius: var(--lb-radius-sm);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    transition: all var(--lb-transition-fast);
}

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

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

.sheet-toolbar .toolbar-btn .icon {
    font-size: 14px;
}

.sheet-toolbar .toolbar-btn .label {
    font-size: 11px;
}

.sheet-toolbar .toolbar-btn.small {
    min-width: 24px;
    height: 24px;
    padding: 2px;
}

.sheet-toolbar .toolbar-btn.dropdown .dropdown-arrow {
    font-size: 8px;
    opacity: 0.6;
}

.sheet-toolbar .toolbar-select {
    padding: 4px 8px;
    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: 11px;
    cursor: pointer;
}

.sheet-toolbar .toolbar-select:focus {
    border-color: var(--lb-accent-primary);
    outline: none;
}

.sheet-toolbar .font-family {
    width: 120px;
}

.sheet-toolbar .font-size {
    width: 55px;
}

.sheet-toolbar .number-format {
    width: 100px;
}

.sheet-toolbar .toolbar-color-picker {
    position: relative;
}

.sheet-toolbar .color-bar {
    position: absolute;
    bottom: 2px;
    left: 50%;
    transform: translateX(-50%);
    width: 16px;
    height: 3px;
    background: currentColor;
    border-radius: 1px;
}

.sheet-toolbar .color-input {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

/* === PRINT === */
@media print {
    .lightbook-overlay {
        position: static;
        background: white;
    }
    
    .lightbook-topbar,
    .lightbook-sidebar,
    .lightbook-statusbar,
    .lb-text-toolbar,
    .sheet-toolbar-container,
    .sheet-tabs-bar {
        display: none !important;
    }
    
    .lightbook-container {
        display: block;
        border: none;
        box-shadow: none;
    }
    
    .lb-editor-page {
        box-shadow: none;
        background: white;
        color: black;
    }
}

/* === ENHANCED RIBBON TOOLBAR === */
.ribbon-toolbar {
    grid-column: 1 / -1;
    background: linear-gradient(180deg, var(--lb-bg-surface) 0%, var(--lb-bg-elevated) 100%);
    border-bottom: 1px solid var(--lb-border-default);
    display: flex;
    flex-direction: column;
    position: relative;
    z-index: 5;
}

.ribbon-btn.large {
    flex-direction: column;
    padding: 8px 12px;
    min-width: 54px;
    height: auto;
    gap: 4px;
}

.ribbon-btn.large svg {
    width: 24px;
    height: 24px;
}

.ribbon-btn.large span {
    font-size: 10px;
    white-space: nowrap;
}

.ribbon-btn.accent {
    background: linear-gradient(135deg, rgba(var(--lb-accent-primary-rgb), 0.2), rgba(168, 85, 247, 0.15));
    border: 1px solid rgba(var(--lb-accent-primary-rgb), 0.3);
}

.ribbon-btn.accent:hover {
    background: linear-gradient(135deg, rgba(var(--lb-accent-primary-rgb), 0.3), rgba(168, 85, 247, 0.25));
}

.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;
}

/* === ENHANCED EDITOR CANVAS === */
.editor-canvas {
    flex: 1;
    overflow: auto;
    background: var(--lb-bg-base);
    display: flex;
    flex-direction: column;
}

.editor-ruler {
    height: 24px;
    background: var(--lb-bg-elevated);
    border-bottom: 1px solid var(--lb-border-default);
    display: none;
    align-items: center;
    padding: 0 16px;
}

.editor-ruler.visible {
    display: flex;
}

.editor-page-container {
    flex: 1;
    overflow: auto;
    padding: 32px;
    display: flex;
    justify-content: center;
}

.editor-page {
    width: 816px; /* 8.5in at 96dpi */
    min-height: 1056px; /* 11in at 96dpi */
    background: #ffffff;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.3);
    border-radius: var(--lb-radius-sm);
    overflow: hidden;
}

.editor-page .text-editor-container {
    padding: 96px 96px 120px;
    color: #1a1a1a;
    font-size: 12pt;
    line-height: 1.6;
    min-height: 100%;
    outline: none;
}

.editor-page .text-editor-container:focus {
    outline: none;
}

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

.ai-sidebar:not(.visible) {
    width: 0;
    transform: translateX(100%);
    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;
}

.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: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--lb-gradient-primary);
    border-radius: var(--lb-radius-md);
    color: #000;
    transition: all var(--lb-transition-fast);
}

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

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

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

/* === GLASS BUTTON STYLE === */
.glass-btn {
    background: var(--lb-glass-surface);
    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: 300px;
    }
    
    :root {
        --lb-ai-panel-width: 300px;
    }
}

@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);
    backdrop-filter: blur(10px);
    -webkit-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);
}

/* ============================================
   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 {
    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;
    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(180deg, #ffffff 0%, #f8f8fa 100%);
    border-color: rgba(0, 0, 0, 0.08);
}

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

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

.lb-ruler.hidden,
.hide-gridlines .sheet-grid-line {
    display: none !important;
}

