/* ==========================================================================
   NovaDocs / Docs - Modern Word Processor Stylesheet
   jrdomains.org Cloud Suite
   ========================================================================== */

:root {
    --bg-main: #0b0f19;
    --bg-surface: #111827;
    --bg-surface-elevated: #1e293b;
    --bg-surface-hover: #263449;
    --bg-app-shell: #090d16;
    --bg-toolbar: rgba(17, 24, 39, 0.95);
    --bg-canvas: #090d16;
    --bg-sheet: #ffffff;
    --text-sheet: #0f172a;

    --text-main: #f8fafc;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --text-inverse: #0f172a;

    --border-subtle: rgba(255, 255, 255, 0.08);
    --border-strong: rgba(255, 255, 255, 0.16);
    --border-sheet: rgba(0, 0, 0, 0.08);

    --primary: #38bdf8;
    --primary-hover: #0ea5e9;
    --primary-light: #7dd3fc;
    --primary-glow: rgba(56, 189, 248, 0.25);

    --accent: #818cf8;
    --accent-purple: #c084fc;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #f43f5e;

    --font-ui: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-heading: 'Outfit', 'Inter', sans-serif;
    --font-mono: 'JetBrains Mono', monospace;

    --radius-sm: 6px;
    --radius-md: 9px;
    --radius-lg: 14px;
    --radius-xl: 18px;

    --shadow-sheet: 0 12px 36px -4px rgba(0, 0, 0, 0.5), 0 4px 12px -2px rgba(0, 0, 0, 0.3);
    --shadow-dropdown: 0 16px 36px -6px rgba(0, 0, 0, 0.65), 0 0 0 1px rgba(255, 255, 255, 0.1);
    --shadow-glow: 0 0 20px rgba(56, 189, 248, 0.22);

    --transition-fast: 0.15s ease;
    --transition-normal: 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

[data-theme="light"] {
    --bg-main: #f1f5f9;
    --bg-surface: #ffffff;
    --bg-surface-elevated: #f8fafc;
    --bg-surface-hover: #e2e8f0;
    --bg-app-shell: #e2e8f0;
    --bg-toolbar: rgba(255, 255, 255, 0.95);
    --bg-canvas: #e2e8f0;
    --bg-sheet: #ffffff;
    --text-sheet: #0f172a;

    --text-main: #0f172a;
    --text-secondary: #475569;
    --text-muted: #94a3b8;
    --text-inverse: #f8fafc;

    --border-subtle: rgba(0, 0, 0, 0.08);
    --border-strong: rgba(0, 0, 0, 0.16);
    --border-sheet: rgba(0, 0, 0, 0.12);

    --shadow-sheet: 0 10px 30px -4px rgba(0, 0, 0, 0.12), 0 4px 10px -2px rgba(0, 0, 0, 0.06);
    --shadow-dropdown: 0 16px 32px -6px rgba(0, 0, 0, 0.15), 0 0 0 1px rgba(0, 0, 0, 0.08);
}

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

html,
body {
    height: 100%;
    width: 100%;
    font-family: var(--font-ui);
    background-color: var(--bg-main);
    color: var(--text-main);
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
}

#docs-app {
    display: flex;
    flex-direction: column;
    height: 100vh;
    width: 100vw;
    background-color: var(--bg-main);
}

/* ==========================================================================
   Universal Top Bar (Standard across SkyDrive, Nexus Point, OmniChat, Docs)
   ========================================================================== */
.universal-top-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 60px;
    padding: 0 16px;
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border-subtle);
    flex-shrink: 0;
    z-index: 100;
    gap: 12px;
}

.top-bar-left {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

.brand-logo {
    display: flex;
    align-items: center;
    gap: 9px;
    cursor: pointer;
    user-select: none;
    text-decoration: none;
}

.brand-app-icon {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    object-fit: cover;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
}

.brand-text {
    display: flex;
    flex-direction: column;
    line-height: 1.15;
}

.brand-name {
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 1rem;
    letter-spacing: -0.01em;
    background: linear-gradient(135deg, #60a5fa 0%, #3b82f6 50%, #1d4ed8 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.brand-sub {
    font-size: 0.65rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-weight: 600;
}

/* Universal Ecosystem Navigation Tabs */
.universal-nav-tabs {
    display: flex;
    align-items: center;
    gap: 4px;
    background: rgba(255, 255, 255, 0.04);
    padding: 3px 4px;
    border-radius: 9px;
    border: 1px solid var(--border-subtle);
    margin-left: 8px;
    flex-shrink: 0;
}

.universal-nav-tabs .nav-tab {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 5px 12px;
    border-radius: 7px;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.82rem;
    font-weight: 500;
    transition: var(--transition-fast);
    border: 1px solid transparent;
    white-space: nowrap;
    flex-shrink: 0;
}

.universal-nav-tabs .nav-tab span {
    white-space: nowrap;
}

.universal-nav-tabs .nav-tab:hover {
    color: var(--text-main);
    background: rgba(255, 255, 255, 0.06);
}

.universal-nav-tabs .nav-tab.active {
    color: var(--primary);
    background: rgba(56, 189, 248, 0.12);
    border-color: rgba(56, 189, 248, 0.28);
    font-weight: 600;
}

/* App-Specific Palette Accents on Active Tab matching Logo Colors */
.universal-nav-tabs .nav-tab.active[data-app="skydrive"],
.universal-nav-tabs .nav-tab.active[href="/"] {
    color: #38bdf8 !important;
    background: rgba(56, 189, 248, 0.15) !important;
    border-color: rgba(56, 189, 248, 0.35) !important;
    box-shadow: 0 0 12px -2px rgba(56, 189, 248, 0.25);
}
.universal-nav-tabs .nav-tab.active[data-app="chat"],
.universal-nav-tabs .nav-tab.active[href="/chat"],
.universal-nav-tabs .nav-tab.active[href="/chat/"] {
    color: #34d399 !important;
    background: rgba(16, 185, 129, 0.15) !important;
    border-color: rgba(52, 211, 153, 0.35) !important;
    box-shadow: 0 0 12px -2px rgba(16, 185, 129, 0.25);
}
.universal-nav-tabs .nav-tab.active[data-app="ai"],
.universal-nav-tabs .nav-tab.active[href="/ai"],
.universal-nav-tabs .nav-tab.active[href="/ai/"] {
    color: #c084fc !important;
    background: rgba(139, 92, 246, 0.16) !important;
    border-color: rgba(192, 132, 252, 0.38) !important;
    box-shadow: 0 0 12px -2px rgba(139, 92, 246, 0.25);
}
.universal-nav-tabs .nav-tab.active[data-app="docs"],
.universal-nav-tabs .nav-tab.active[href="/docs"],
.universal-nav-tabs .nav-tab.active[href="/docs/"] {
    color: #4e51f0 !important;
    background: rgba(74, 124, 231, 0.18) !important;
    border-color: rgba(96, 165, 250, 0.38) !important;
    box-shadow: 0 0 12px -2px rgba(37, 99, 235, 0.28);
}
.universal-nav-tabs .nav-tab.active[data-app="calendar"],
.universal-nav-tabs .nav-tab.active[href="/calendar"],
.universal-nav-tabs .nav-tab.active[href="/calendar/"] {
    color: #00fff2 !important;
    background: rgba(13, 253, 253, 0.26) !important;
    border-color: rgba(34, 211, 238, 0.38) !important;
    box-shadow: 0 0 12px -2px rgba(6, 182, 212, 0.25);
}
.universal-nav-tabs .nav-tab.active[data-app="gallery"],
.universal-nav-tabs .nav-tab.active[href="/gallery"],
.universal-nav-tabs .nav-tab.active[href="/gallery/"] {
    color: #f472b6 !important;
    background: rgba(236, 72, 153, 0.16) !important;
    border-color: rgba(244, 114, 182, 0.38) !important;
    box-shadow: 0 0 12px -2px rgba(236, 72, 153, 0.25);
}

.universal-nav-tabs .nav-tab-icon {
    flex-shrink: 0;
}

/* Top bar center: Document Title Bar */
.top-bar-center {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
    max-width: 480px;
    margin: 0 auto;
}

.doc-title-wrapper {
    display: flex;
    align-items: center;
    background: var(--bg-surface-elevated);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 2px 10px;
    width: 100%;
    transition: var(--transition-fast);
}

.doc-title-wrapper:focus-within {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px var(--primary-glow);
}

.doc-title-icon {
    color: var(--primary);
    margin-right: 8px;
    flex-shrink: 0;
}

.doc-title-input {
    background: transparent;
    border: none;
    outline: none;
    color: var(--text-main);
    font-family: var(--font-ui);
    font-size: 0.88rem;
    font-weight: 600;
    width: 100%;
}

.doc-save-badge {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.72rem;
    color: var(--text-muted);
    white-space: nowrap;
    padding-left: 8px;
    user-select: none;
}

.save-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--text-muted);
    transition: var(--transition-fast);
}

.save-dot.saved {
    background: var(--success);
    box-shadow: 0 0 8px rgba(16, 185, 129, 0.5);
}

.save-dot.saving {
    background: var(--primary);
    animation: pulse 1s infinite alternate;
}

.save-dot.unsaved {
    background: var(--warning);
}

@keyframes pulse {
    from {
        opacity: 0.4;
    }

    to {
        opacity: 1;
    }
}

/* Top Bar Right */
.top-bar-right {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.icon-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 6px 10px;
    border-radius: var(--radius-md);
    background: transparent;
    border: 1px solid transparent;
    color: var(--text-secondary);
    font-family: var(--font-ui);
    font-size: 0.82rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition-fast);
    text-decoration: none;
}

.icon-btn:hover {
    background: var(--bg-surface-hover);
    color: var(--text-main);
    border-color: var(--border-subtle);
}

.icon-btn.primary {
    background: linear-gradient(135deg, #0284c7 0%, #0369a1 100%);
    color: #ffffff;
    border: 1px solid rgba(56, 189, 248, 0.3);
    box-shadow: 0 2px 8px rgba(2, 132, 199, 0.35);
}

.icon-btn.primary:hover {
    background: linear-gradient(135deg, #0369a1 0%, #075985 100%);
    box-shadow: 0 4px 12px rgba(2, 132, 199, 0.45);
}

.top-bar-divider {
    width: 1px;
    height: 20px;
    background: var(--border-subtle);
    margin: 0 4px;
}

.theme-toggle-btn {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    background: transparent;
    border: 1px solid var(--border-subtle);
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition-fast);
}

.theme-toggle-btn:hover {
    background: var(--bg-surface-hover);
    color: var(--text-main);
}

.universal-profile-wrap {
    display: flex;
    align-items: center;
}

.user-profile-badge {
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 3px 8px 3px 4px;
    background: var(--bg-surface-elevated);
    border: 1px solid var(--border-subtle);
    border-radius: 9999px;
    font-size: 0.8rem;
    color: var(--text-main);
    cursor: pointer;
}

.user-avatar-wrap {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #0284c7;
    color: #fff;
    font-weight: 700;
    font-size: 0.72rem;
}

.user-avatar-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.pill-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 5px 12px;
    background: var(--bg-surface-elevated);
    border: 1px solid var(--border-subtle);
    border-radius: 9999px;
    color: var(--text-main);
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
}

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

/* ==========================================================================
   Word Processor Ribbon & Formatting Toolbar (TinyMCE Style)
   ========================================================================== */
.docs-toolbar-ribbon {
    background: var(--bg-toolbar);
    border-bottom: 1px solid var(--border-subtle);
    padding: 6px 14px;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    backdrop-filter: blur(12px);
    flex-shrink: 0;
    z-index: 50;
    user-select: none;
}

.toolbar-group {
    display: flex;
    align-items: center;
    gap: 2px;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border-subtle);
    padding: 2px;
    border-radius: var(--radius-md);
}

.toolbar-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition-fast);
}

.toolbar-btn:hover {
    background: var(--bg-surface-hover);
    color: var(--text-main);
    border-color: var(--border-subtle);
}

.toolbar-btn.active {
    background: rgba(56, 189, 248, 0.18);
    color: var(--primary);
    border-color: rgba(56, 189, 248, 0.4);
}

.toolbar-btn:disabled {
    opacity: 0.35;
    cursor: not-allowed;
}

.toolbar-select {
    height: 30px;
    background: var(--bg-surface-elevated);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    color: var(--text-main);
    font-family: var(--font-ui);
    font-size: 0.8rem;
    font-weight: 500;
    padding: 0 8px;
    outline: none;
    cursor: pointer;
}

.toolbar-select:focus {
    border-color: var(--primary);
}

/* Font Size Group (Combo Input + Stepper) */
.font-size-group {
    display: flex;
    align-items: center;
    gap: 3px;
    padding: 2px 4px;
}

.font-size-input {
    width: 38px;
    height: 26px;
    background: var(--bg-surface-elevated);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    color: var(--text-main);
    font-family: var(--font-ui);
    font-size: 0.84rem;
    font-weight: 600;
    text-align: center;
    outline: none;
    transition: var(--transition-fast);
}

.font-size-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px var(--primary-glow);
}

.font-size-unit {
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--text-muted);
    margin-right: 2px;
    user-select: none;
}

.toolbar-mini-btn {
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: transparent;
    color: var(--text-muted);
    border-radius: 3px;
    font-size: 0.65rem;
    cursor: pointer;
    transition: var(--transition-fast);
}

.toolbar-mini-btn:hover {
    background: var(--bg-surface-hover);
    color: var(--text-main);
}

/* Line Spacing Dropdown & Popovers */
.line-spacing-dropdown {
    position: relative;
}

.dropdown-menu-popover {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    background: var(--bg-surface-elevated);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-dropdown);
    padding: 6px;
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 210px;
    z-index: 100;
    backdrop-filter: blur(12px);
    animation: fadeIn 0.15s ease;
}

.dropdown-menu-popover .menu-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 6px 10px;
    border-radius: var(--radius-sm);
    background: transparent;
    border: 1px solid transparent;
    color: var(--text-main);
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    text-align: left;
    transition: var(--transition-fast);
}

.dropdown-menu-popover .menu-item:hover {
    background: var(--bg-surface-hover);
    border-color: var(--border-subtle);
    color: var(--primary);
}

.dropdown-menu-popover .menu-item.active {
    background: rgba(56, 189, 248, 0.12);
    border-color: rgba(56, 189, 248, 0.3);
    color: var(--primary);
    font-weight: 600;
}

.dropdown-menu-popover .badge-tag {
    font-size: 0.68rem;
    padding: 1px 6px;
    border-radius: 9999px;
    background: rgba(56, 189, 248, 0.18);
    color: var(--primary);
    font-weight: 600;
}

.dropdown-menu-popover .menu-divider {
    height: 1px;
    background: var(--border-subtle);
    margin: 4px 0;
}

/* Color Pickers */
.color-picker-wrap {
    position: relative;
    display: flex;
    align-items: center;
}

.color-input-hidden {
    position: absolute;
    opacity: 0;
    width: 100%;
    height: 100%;
    cursor: pointer;
    left: 0;
    top: 0;
}

.color-indicator-bar {
    position: absolute;
    bottom: 3px;
    left: 6px;
    right: 6px;
    height: 3px;
    border-radius: 2px;
    background: #f8fafc;
}

/* Quick Actions in Ribbon (Drive Save, Open, Export, AI) */
.toolbar-ribbon-actions {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 6px;
}

/* ==========================================================================
   Document Canvas & Paper Sheet Layout
   ========================================================================== */
.docs-main-container {
    flex: 1;
    display: flex;
    background: var(--bg-canvas);
    overflow: hidden;
    position: relative;
}

.docs-viewport {
    flex: 1;
    overflow-y: auto;
    overflow-x: auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 32px 16px 80px 16px;
    scroll-behavior: smooth;
}

/* Document Canvas Viewport Container */
.doc-page-canvas {
    background: transparent;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 32px;
    width: 100%;
    outline: none;
    transition: transform var(--transition-fast);
}

/* Individual Physical Page White Box */
.doc-page-canvas .page {
    background: #ffffff;
    color: #0f172a;
    width: 816px;
    /* Standard US Letter width at 96dpi (8.5 inches) */
    height: 1056px;
    /* Exact US Letter height (11 inches) */
    max-height: 1056px;
    padding: 72px 72px;
    /* Standard 1 inch margins */
    border-radius: 4px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.28), 0 0 0 1px rgba(255, 255, 255, 0.08);
    outline: none;
    font-size: 11pt;
    line-height: 2.0;
    /* Double space */
    font-family: 'Inter', Arial, sans-serif;
    position: relative;
    overflow: hidden;
    /* Clean page boundary */
    box-sizing: border-box;
    word-break: break-word;
    transition: width var(--transition-fast), height var(--transition-fast), padding var(--transition-fast);
}

/* Focused page active halo */
.doc-page-canvas .page:focus,
.doc-page-canvas .page:focus-within {
    box-shadow: 0 6px 28px rgba(0, 0, 0, 0.35), 0 0 0 2px rgba(56, 189, 248, 0.6);
}

/* Paper Size Modifiers applied to canvas */
.doc-page-canvas.paper-letter .page {
    width: 816px;
    height: 1056px;
    max-height: 1056px;
}

.doc-page-canvas.paper-a4 .page {
    width: 794px;
    height: 1123px;
    max-height: 1123px;
}

.doc-page-canvas.paper-legal .page {
    width: 816px;
    height: 1344px;
    max-height: 1344px;
}

/* Margin Modifiers applied to canvas */
.doc-page-canvas.margins-normal .page {
    padding: 72px 72px;
}

.doc-page-canvas.margins-narrow .page {
    padding: 36px 36px;
}

.doc-page-canvas.margins-wide .page {
    padding: 108px 108px;
}



/* Document content styles inside pages */
.doc-page-canvas .page h1 {
    font-size: 24pt;
    font-weight: 700;
    margin-bottom: 16px;
    line-height: 1.25;
    color: #0f172a;
}

.doc-page-canvas .page h2 {
    font-size: 18pt;
    font-weight: 600;
    margin-top: 20px;
    margin-bottom: 12px;
    line-height: 1.3;
    color: #1e293b;
}

.doc-page-canvas .page h3 {
    font-size: 14pt;
    font-weight: 600;
    margin-top: 16px;
    margin-bottom: 8px;
    line-height: 1.35;
    color: #334155;
}

.doc-page-canvas .page h4 {
    font-size: 12pt;
    font-weight: 600;
    margin-top: 14px;
    margin-bottom: 6px;
    color: #475569;
}

.doc-page-canvas .page p {
    margin-bottom: 12px;
}

.doc-page-canvas .page blockquote {
    border-left: 4px solid #38bdf8;
    padding: 8px 16px;
    margin: 14px 0;
    color: #475569;
    font-style: italic;
    background: #f8fafc;
    border-radius: 0 6px 6px 0;
}

.doc-page-canvas .page pre,
.doc-page-canvas .page code {
    font-family: 'JetBrains Mono', monospace;
    background: #f1f5f9;
    color: #0f172a;
    border-radius: 4px;
    padding: 2px 6px;
    font-size: 9.5pt;
}

.doc-page-canvas .page pre {
    padding: 12px;
    margin: 14px 0;
    overflow-x: auto;
    border: 1px solid #e2e8f0;
}

.doc-page-canvas .page ul,
.doc-page-canvas .page ol {
    margin-left: 28px;
    margin-bottom: 14px;
}

.doc-page-canvas .page li {
    margin-bottom: 4px;
}

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

.doc-page-canvas .page th,
.doc-page-canvas .page td {
    border: 1px solid #cbd5e1;
    padding: 8px 12px;
    text-align: left;
}

.doc-page-canvas .page th {
    background: #f1f5f9;
    font-weight: 600;
}

.doc-page-canvas .page img {
    max-width: 100%;
    height: auto;
    border-radius: 4px;
    margin: 12px 0;
}

.doc-page-canvas .page a {
    color: #0284c7;
    text-decoration: underline;
}

.doc-page-canvas .page hr {
    border: none;
    border-top: 1px solid #cbd5e1;
    margin: 20px 0;
}

.doc-page-canvas pre,
.doc-page-canvas code {
    font-family: 'JetBrains Mono', monospace;
    background: #f1f5f9;
    color: #0f172a;
    border-radius: 4px;
    padding: 2px 6px;
    font-size: 9.5pt;
}

.doc-page-canvas pre {
    padding: 12px;
    margin: 14px 0;
    overflow-x: auto;
    border: 1px solid #e2e8f0;
}

.doc-page-canvas ul,
.doc-page-canvas ol {
    margin-left: 28px;
    margin-bottom: 14px;
}

.doc-page-canvas li {
    margin-bottom: 4px;
}

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

.doc-page-canvas th,
.doc-page-canvas td {
    border: 1px solid #cbd5e1;
    padding: 8px 12px;
    text-align: left;
}

.doc-page-canvas th {
    background: #f1f5f9;
    font-weight: 600;
}

.doc-page-canvas img {
    max-width: 100%;
    height: auto;
    border-radius: 4px;
    margin: 12px 0;
}

.doc-page-canvas a {
    color: #0284c7;
    text-decoration: underline;
}

.doc-page-canvas hr {
    border: none;
    border-top: 1px solid #cbd5e1;
    margin: 20px 0;
}

/* AI & Extended NDML Document Components */
.doc-page-canvas subtitle,
.doc-page-canvas .doc-subtitle {
    display: block;
    font-size: 13pt;
    color: #64748b;
    font-style: italic;
    margin-top: -6px;
    margin-bottom: 20px;
    line-height: 1.4;
}

.doc-page-canvas card,
.doc-page-canvas .card {
    display: block;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 14px 18px;
    margin: 14px 0;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.doc-page-canvas card[title]::before,
.doc-page-canvas .card[title]::before {
    content: attr(icon) " " attr(title);
    font-weight: 700;
    font-size: 1.05rem;
    display: block;
    margin-bottom: 6px;
    color: #0f172a;
}

.doc-page-canvas note,
.doc-page-canvas .note {
    display: block;
    background: #eff6ff;
    border-left: 4px solid #38bdf8;
    border-radius: 0 6px 6px 0;
    padding: 12px 16px;
    margin: 14px 0;
    color: #1e40af;
    font-size: 10pt;
    line-height: 1.6;
}

.doc-page-canvas warning,
.doc-page-canvas .warning {
    display: block;
    background: #fffbeb;
    border-left: 4px solid #f59e0b;
    border-radius: 0 6px 6px 0;
    padding: 12px 16px;
    margin: 14px 0;
    color: #92400e;
    font-size: 10pt;
    line-height: 1.6;
}

.doc-page-canvas grid,
.doc-page-canvas .grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 12px;
    margin: 14px 0;
}

.doc-page-canvas timeline,
.doc-page-canvas .timeline {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin: 16px 0;
    padding-left: 16px;
    border-left: 2px solid #38bdf8;
}

.doc-page-canvas event,
.doc-page-canvas .event {
    display: block;
    font-size: 10pt;
    color: #334155;
    line-height: 1.5;
}

.doc-page-canvas event[year]::before,
.doc-page-canvas .event[year]::before {
    content: attr(year) " — " attr(label);
    font-weight: 600;
    color: #0284c7;
    display: block;
}

.doc-page-canvas figure {
    margin: 14px 0;
}

.doc-page-canvas figcaption {
    font-size: 9.5pt;
    color: #64748b;
    margin-top: 6px;
    font-style: italic;
}

/* Page Outline / Table of Contents Drawer */
.docs-toc-drawer {
    width: 240px;
    background: var(--bg-surface);
    border-right: 1px solid var(--border-subtle);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    transition: transform var(--transition-normal);
}

.docs-toc-drawer.closed {
    display: none;
}

.toc-header {
    padding: 12px 16px;
    font-size: 0.82rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border-subtle);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.toc-list {
    overflow-y: auto;
    padding: 8px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.toc-item {
    display: block;
    padding: 6px 10px;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 0.8rem;
    text-decoration: none;
    transition: var(--transition-fast);
    cursor: pointer;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.toc-item:hover {
    background: var(--bg-surface-hover);
    color: var(--text-main);
}

.toc-item.h1 {
    font-weight: 600;
}

.toc-item.h2 {
    padding-left: 20px;
    font-size: 0.76rem;
}

.toc-item.h3 {
    padding-left: 30px;
    font-size: 0.72rem;
}

/* ==========================================================================
   Footer Live Status Bar
   ========================================================================== */
.docs-status-bar {
    height: 32px;
    background: var(--bg-surface);
    border-top: 1px solid var(--border-subtle);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    font-size: 0.75rem;
    color: var(--text-muted);
    flex-shrink: 0;
    z-index: 60;
    user-select: none;
}

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

.status-metric {
    display: flex;
    align-items: center;
    gap: 5px;
}

.metric-value {
    color: var(--text-main);
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

.status-right {
    display: flex;
    align-items: center;
    gap: 14px;
}

.zoom-controls {
    display: flex;
    align-items: center;
    gap: 6px;
}

.zoom-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2px;
    border-radius: 4px;
}

.zoom-btn:hover {
    color: var(--text-main);
    background: var(--bg-surface-hover);
}

.zoom-label {
    font-variant-numeric: tabular-nums;
    font-weight: 600;
    width: 38px;
    text-align: center;
}

/* ==========================================================================
   Modal Dialogs (Drive File Picker, Save As, Insert Link/Table/Image, Auth)
   ========================================================================== */
.modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 16px;
    animation: fadeIn 0.15s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

.modal-container {
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-dropdown);
    width: 100%;
    max-width: 560px;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

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

.modal-title {
    font-family: var(--font-heading);
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text-main);
    display: flex;
    align-items: center;
    gap: 8px;
}

.modal-close-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 6px;
}

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

.modal-body {
    padding: 18px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.modal-footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    padding: 12px 18px;
    border-top: 1px solid var(--border-subtle);
    background: var(--bg-surface-elevated);
}

/* Form controls in modal */
.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.form-group label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.form-input {
    background: var(--bg-surface-elevated);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    color: var(--text-main);
    padding: 8px 12px;
    font-family: var(--font-ui);
    font-size: 0.88rem;
    outline: none;
}

.form-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px var(--primary-glow);
}

/* File Picker Search Bar */
.drive-search-bar-wrap {
    margin-bottom: 8px;
}

.drive-search-input-box {
    position: relative;
    display: flex;
    align-items: center;
    width: 100%;
    background: var(--bg-surface-elevated);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    transition: var(--transition-fast);
}

.drive-search-input-box:focus-within {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(56, 189, 248, 0.2);
}

.drive-search-icon {
    position: absolute;
    left: 10px;
    font-size: 0.85rem;
    color: var(--text-muted);
    pointer-events: none;
}

.drive-search-input {
    width: 100%;
    padding: 8px 32px 8px 32px;
    background: transparent;
    border: none;
    color: var(--text-main);
    font-size: 0.85rem;
    font-family: inherit;
    outline: none;
}

.drive-search-input::placeholder {
    color: var(--text-muted);
}

.drive-search-clear-btn {
    position: absolute;
    right: 8px;
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 0.85rem;
    padding: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: var(--transition-fast);
}

.drive-search-clear-btn:hover {
    color: var(--text-main);
    background: var(--bg-surface-hover);
}

.drive-file-location {
    font-size: 0.72rem;
    color: var(--text-muted);
    margin-left: 6px;
    opacity: 0.85;
}

/* File Picker List */
.drive-file-list {
    max-height: 320px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 4px;
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    padding: 6px;
    background: var(--bg-surface-elevated);
}

.drive-file-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 0.85rem;
    cursor: pointer;
    transition: var(--transition-fast);
}

.drive-file-item:hover {
    background: var(--bg-surface-hover);
    color: var(--text-main);
}

.drive-file-item.selected {
    background: rgba(56, 189, 248, 0.15);
    color: var(--primary);
    font-weight: 600;
}

.drive-file-icon {
    flex-shrink: 0;
    color: var(--primary);
}

.drive-file-name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.drive-file-meta {
    font-size: 0.72rem;
    color: var(--text-muted);
}

/* Toast Notifications */
.docs-toast {
    position: fixed;
    bottom: 48px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(15, 23, 42, 0.94);
    border: 1px solid var(--primary);
    color: #f8fafc;
    padding: 10px 20px;
    border-radius: 9999px;
    font-size: 0.85rem;
    font-weight: 600;
    box-shadow: var(--shadow-dropdown);
    z-index: 9999;
    backdrop-filter: blur(8px);
    display: none;
    animation: fadeIn 0.2s ease;
}

/* Print Stylesheet */
@media print {

    .universal-top-bar,
    .docs-toolbar-ribbon,
    .docs-status-bar,
    .docs-toc-drawer,
    .modal-backdrop,
    .docs-toast {
        display: none !important;
    }

    body,
    html,
    #docs-app,
    .docs-main-container,
    .docs-viewport {
        background: #ffffff !important;
        height: auto !important;
        overflow: visible !important;
        padding: 0 !important;
        margin: 0 !important;
    }

    .doc-page-canvas {
        box-shadow: none !important;
        border: none !important;
        width: 100% !important;
        min-height: auto !important;
        padding: 0 !important;
        margin: 0 !important;
        display: block !important;
    }

    .doc-page-canvas .page {
        box-shadow: none !important;
        border: none !important;
        width: 100% !important;
        height: auto !important;
        min-height: 100vh !important;
        padding: 1in !important;
        margin: 0 !important;
        page-break-after: always !important;
        break-after: page !important;
    }

    .doc-page-separator {
        display: none !important;
    }
}

/* Responsive adjustments */
@media (max-width: 1500px) {
    .universal-nav-tabs .nav-tab span {
        display: none;
    }

    .universal-nav-tabs .nav-tab {
        padding: 5px 8px;
    }

    .doc-page-canvas {
        width: 100%;
        padding: 36px 24px;
    }

    .docs-toc-drawer {
        position: absolute;
        left: 0;
        top: 0;
        bottom: 0;
        z-index: 80;
        box-shadow: var(--shadow-dropdown);
    }
}

/* Visual Page Break Separator between pages */
.doc-page-separator {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 816px;
    margin: -16px 0 -16px 0;
    user-select: none;
    position: relative;
    z-index: 10;
}

.doc-page-separator::before {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    top: 50%;
    height: 1px;
    border-top: 1px dashed rgba(148, 163, 184, 0.5);
    z-index: 1;
}

.doc-page-separator-badge {
    position: relative;
    z-index: 2;
    background: #1e293b;
    color: #94a3b8;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 3px 10px;
    border-radius: 9999px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    align-items: center;
    gap: 6px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
}

.doc-page-remove-break-btn {
    position: relative;
    z-index: 2;
    background: rgba(30, 41, 59, 0.9);
    color: #f87171;
    font-size: 0.68rem;
    font-weight: 600;
    padding: 3px 9px;
    border-radius: 9999px;
    border: 1px solid rgba(248, 113, 113, 0.3);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 4px;
    transition: all var(--transition-fast);
    backdrop-filter: blur(8px);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
}

.doc-page-remove-break-btn:hover {
    background: #dc2626;
    color: #ffffff;
    border-color: #dc2626;
    transform: translateY(-1px);
    box-shadow: 0 4px 10px rgba(220, 38, 38, 0.4);
}

/* ==========================================================================
   Image Resize Overlay, 8 Handles & Google Docs Floating Action Bar
   ========================================================================== */
.image-resize-overlay {
    position: absolute;
    border: 2px solid #38bdf8;
    box-sizing: border-box;
    z-index: 1000;
    pointer-events: none;
    box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.15), 0 0 12px rgba(56, 189, 248, 0.25);
    border-radius: 2px;
}

.resize-handle {
    position: absolute;
    width: 9px;
    height: 9px;
    background: #ffffff;
    border: 2px solid #0284c7;
    border-radius: 2px;
    pointer-events: auto;
    z-index: 1001;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
    box-sizing: border-box;
}

.resize-handle:hover {
    background: #38bdf8;
    transform: scale(1.25);
}

/* 4 Corner Handles */
.resize-handle.nw {
    top: -5px;
    left: -5px;
    cursor: nwse-resize;
}

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

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

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

/* 4 Side Handles */
.resize-handle.n {
    top: -5px;
    left: calc(50% - 4px);
    cursor: ns-resize;
}

.resize-handle.s {
    bottom: -5px;
    left: calc(50% - 4px);
    cursor: ns-resize;
}

.resize-handle.w {
    top: calc(50% - 4px);
    left: -5px;
    cursor: ew-resize;
}

.resize-handle.e {
    top: calc(50% - 4px);
    right: -5px;
    cursor: ew-resize;
}

/* Floating Action Toolbar (Google Docs style) */
.image-action-bar {
    position: absolute;
    left: 50%;
    bottom: -46px;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: 4px;
    background: rgba(15, 23, 42, 0.95);
    backdrop-filter: blur(12px);
    padding: 4px 8px;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.15);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
    pointer-events: auto;
    user-select: none;
    z-index: 1002;
    white-space: nowrap;
}

.image-action-btn {
    background: transparent;
    border: none;
    color: #94a3b8;
    padding: 5px 8px;
    font-size: 0.8rem;
    border-radius: 5px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    transition: all var(--transition-fast);
}

.image-action-btn:hover {
    background: rgba(255, 255, 255, 0.12);
    color: #f8fafc;
}

.image-action-btn.active {
    background: #0284c7;
    color: #ffffff;
}

.image-action-btn.danger {
    color: #f87171;
}

.image-action-btn.danger:hover {
    background: rgba(239, 68, 68, 0.2);
    color: #ef4444;
}

.image-action-divider {
    width: 1px;
    height: 18px;
    background: rgba(255, 255, 255, 0.15);
    margin: 0 3px;
}

/* ═══════════════════════════════════════════════════════════════════════════ */
/* Desktop Shell Integration (Electron)                                       */
/* ═══════════════════════════════════════════════════════════════════════════ */
html.is-desktop-app .brand-logo,
body.is-desktop-app .brand-logo,
html.is-desktop-app .universal-nav-tabs,
body.is-desktop-app .universal-nav-tabs,
html.is-desktop-app #omniUserProfileWrap,
body.is-desktop-app #omniUserProfileWrap {
    display: none !important;
}

/* ═══════════════════════════════════════════════════════════════════════════ */
/* Custom Styles System (.nds)                                                */
/* ==========================================================================
   Insert Elements Dropdown
   ========================================================================== */
.insert-dropdown-wrap {
    position: relative;
    display: inline-block;
}

.insert-btn-primary {
    display: flex;
    align-items: center;
    gap: 6px;
    font-weight: 600;
}

.insert-dropdown-popover {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    min-width: 230px;
    max-height: 480px;
    overflow-y: auto;
    z-index: 200;
}

.insert-dropdown-header {
    padding: 8px 12px 4px;
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.menu-category-title {
    padding: 6px 12px 3px;
    font-size: 0.68rem;
    font-weight: 700;
    color: var(--primary);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    opacity: 0.9;
}

.highlight-action {
    background: rgba(192, 132, 252, 0.08) !important;
    border-radius: var(--radius-sm);
}

.highlight-action:hover {
    background: rgba(192, 132, 252, 0.18) !important;
}

/* ==========================================================================
   Text Casing Dropdown
   ========================================================================== */
.casing-dropdown-wrap {
    position: relative;
    display: inline-block;
}

.casing-dropdown-popover {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    min-width: 170px;
    z-index: 200;
}

/* ==========================================================================
   Rich Document Styling & Elements (Word / LibreOffice Inspired)
   ========================================================================== */
.doc-page-canvas h1.doc-title {
    font-size: 2.25rem !important;
    font-weight: 800 !important;
    letter-spacing: -0.02em !important;
    margin-bottom: 0.4em !important;
    color: var(--text-sheet) !important;
    border-bottom: 2px solid var(--border-sheet);
    padding-bottom: 0.3em;
}

.doc-page-canvas p.doc-subtitle {
    font-size: 1.15rem !important;
    color: #64748b !important;
    margin-top: -0.2em !important;
    margin-bottom: 1.2em !important;
    font-style: italic;
}

.doc-page-canvas p.lead-paragraph {
    font-size: 1.15rem !important;
    line-height: 1.7 !important;
    color: #334155 !important;
}

.doc-page-canvas blockquote.pull-quote {
    font-size: 1.2rem !important;
    font-style: italic !important;
    text-align: center !important;
    padding: 16px 24px !important;
    margin: 24px 32px !important;
    border-top: 2px solid var(--primary) !important;
    border-bottom: 2px solid var(--primary) !important;
    border-left: none !important;
    background: transparent !important;
    color: #1e293b !important;
}

/* Callout Boxes */
.doc-callout {
    display: flex;
    gap: 12px;
    padding: 14px 16px;
    margin: 16px 0;
    border-radius: 8px;
    font-size: 0.95rem;
    line-height: 1.6;
    border-left: 5px solid #38bdf8;
    background: #f0f9ff;
    color: #0c4a6e;
}

.doc-callout.callout-info {
    border-left-color: #38bdf8;
    background: #f0f9ff;
    color: #0369a1;
}

.doc-callout.callout-tip {
    border-left-color: #eab308;
    background: #fefce8;
    color: #854d0e;
}

.doc-callout.callout-warning {
    border-left-color: #f97316;
    background: #fff7ed;
    color: #9a3412;
}

.doc-callout.callout-success {
    border-left-color: #10b981;
    background: #f0fdf4;
    color: #166534;
}

/* Interactive Checkbox / Task Lists */
.doc-task-list {
    list-style: none !important;
    padding-left: 4px !important;
    margin: 12px 0 !important;
}

.doc-task-list .task-item {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin-bottom: 6px;
    line-height: 1.6;
}

.doc-task-list .task-checkbox {
    appearance: none;
    -webkit-appearance: none;
    width: 17px;
    height: 17px;
    border: 2px solid #94a3b8;
    border-radius: 4px;
    margin-top: 4px;
    cursor: pointer;
    flex-shrink: 0;
    position: relative;
    background: #ffffff;
    transition: all 0.15s ease;
}

.doc-task-list .task-checkbox:checked {
    background: #10b981;
    border-color: #10b981;
}

.doc-task-list .task-checkbox:checked::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 5px;
    width: 4px;
    height: 8px;
    border: solid #ffffff;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

.doc-task-list .task-item.completed {
    text-decoration: line-through;
    color: #94a3b8;
}

/* Inline code and blocks */
code {
    font-family: var(--font-mono);
    background: rgba(0, 0, 0, 0.06);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.9em;
    color: #e11d48;
}

/* ==========================================================================
   Custom HTML Injection Modal
   ========================================================================== */
.custom-html-editor {
    font-family: var(--font-mono) !important;
    font-size: 0.85rem !important;
    line-height: 1.5 !important;
    tab-size: 2;
    background: var(--bg-surface-elevated) !important;
    color: #38bdf8 !important;
}

.html-snippet-chips {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
    margin-top: 8px;
}

.chips-label {
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--text-muted);
}

.snippet-chip {
    font-size: 0.72rem;
    padding: 3px 8px;
    border-radius: 9999px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid var(--border-subtle);
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition-fast);
}

.snippet-chip:hover {
    background: var(--primary-glow);
    border-color: var(--primary);
    color: var(--primary);
}

.custom-html-preview-wrap {
    margin-top: 14px;
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    overflow: hidden;
}

.preview-header {
    background: var(--bg-surface-elevated);
    padding: 6px 12px;
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border-subtle);
}

.custom-html-preview-sandbox {
    padding: 16px;
    background: #ffffff;
    color: #0f172a;
    min-height: 80px;
    max-height: 180px;
    overflow-y: auto;
}

/* ==========================================================================
   Floating OmniChat AI Assistant Bubble & Flyout
   ========================================================================== */
.omni-ai-fab-container {
    position: fixed;
    bottom: 40px;
    right: 25px;
    z-index: 999;
}

.omni-ai-fab-btn {
    position: relative;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: linear-gradient(135deg, #0284c7 0%, #6366f1 50%, #a855f7 100%);
    border: 1.5px solid rgba(255, 255, 255, 0.35);
    color: #ffffff;
    font-size: 0.95rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 6px 18px -3px rgba(99, 102, 241, 0.5), 0 0 12px rgba(56, 189, 248, 0.25);
    transition: all 0.22s cubic-bezier(0.16, 1, 0.3, 1);
}

.omni-ai-fab-btn:hover {
    transform: translateY(-2px) scale(1.08);
    box-shadow: 0 8px 24px -3px rgba(99, 102, 241, 0.65), 0 0 18px rgba(56, 189, 248, 0.4);
}

.omni-ai-fab-btn:active {
    transform: translateY(0) scale(0.96);
}

.omni-ai-fab-glow {
    position: absolute;
    inset: -2px;
    border-radius: 50%;
    background: inherit;
    filter: blur(6px);
    opacity: 0.4;
    z-index: -1;
    animation: fabPulse 3s ease-in-out infinite;
}

@keyframes fabPulse {

    0%,
    100% {
        opacity: 0.3;
        transform: scale(1);
    }

    50% {
        opacity: 0.6;
        transform: scale(1.08);
    }
}

/* OmniChat AI Flyout Card */
.omni-ai-flyout {
    position: fixed;
    bottom: 68px;
    right: 22px;
    width: 385px;
    max-width: calc(100vw - 36px);
    max-height: 580px;
    background: var(--bg-surface);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-lg);
    box-shadow: 0 20px 48px -8px rgba(0, 0, 0, 0.7), 0 0 0 1px rgba(255, 255, 255, 0.08);
    display: flex;
    flex-direction: column;
    z-index: 1000;
    overflow: hidden;
    animation: flyoutSlideUp 0.22s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes flyoutSlideUp {
    from {
        opacity: 0;
        transform: translateY(12px) scale(0.96);
    }

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

.ai-flyout-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 14px;
    background: var(--bg-surface-elevated);
    border-bottom: 1px solid var(--border-subtle);
}

.ai-flyout-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 0.92rem;
    color: var(--text-main);
}

.ai-model-tag {
    font-size: 0.65rem;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: 9999px;
    background: rgba(56, 189, 248, 0.15);
    color: var(--primary);
    border: 1px solid rgba(56, 189, 248, 0.3);
}

.ai-flyout-actions {
    display: flex;
    align-items: center;
    gap: 4px;
}

.ai-header-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    width: 26px;
    height: 26px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    transition: var(--transition-fast);
}

.ai-header-btn:hover {
    color: var(--text-main);
    background: var(--bg-surface-hover);
}

.ai-flyout-body {
    padding: 12px 14px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    overflow-y: auto;
    max-height: 420px;
}

/* Context Banner */
.ai-context-banner {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 8px 10px;
}

.ai-context-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--primary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 4px;
}

.ai-html-tag-badge {
    font-size: 0.65rem;
    padding: 1px 6px;
    border-radius: 4px;
    background: rgba(168, 85, 247, 0.15);
    color: #c084fc;
    border: 1px solid rgba(168, 85, 247, 0.3);
    text-transform: none;
    letter-spacing: normal;
    display: flex;
    align-items: center;
    gap: 4px;
}

.ai-context-snippet {
    font-size: 0.78rem;
    color: var(--text-secondary);
    line-height: 1.4;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-family: var(--font-mono);
    opacity: 0.9;
}

/* Quick Action Chips */
.ai-quick-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
}

.ai-chip {
    font-size: 0.74rem;
    font-weight: 500;
    padding: 4px 9px;
    border-radius: 9999px;
    background: var(--bg-surface-elevated);
    border: 1px solid var(--border-subtle);
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition-fast);
    white-space: nowrap;
}

.ai-chip:hover {
    background: var(--primary-glow);
    border-color: var(--primary);
    color: var(--text-main);
    transform: translateY(-1px);
}

/* Diff & Result Visualization */
.ai-result-area {
    display: flex;
    flex-direction: column;
    gap: 8px;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-md);
    padding: 10px;
}

.ai-diff-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.ai-diff-tabs {
    display: flex;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    padding: 2px;
    gap: 2px;
}

.ai-diff-tab {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 0.7rem;
    font-weight: 600;
    padding: 4px 8px;
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 4px;
    transition: var(--transition-fast);
}

.ai-diff-tab:hover {
    color: var(--text-main);
}

.ai-diff-tab.active {
    background: var(--primary);
    color: #ffffff;
    box-shadow: 0 1px 4px rgba(2, 132, 199, 0.4);
}

.diff-legend {
    display: flex;
    gap: 8px;
    font-size: 0.65rem;
}

.legend-del {
    color: var(--danger);
    text-decoration: line-through;
}

.legend-ins {
    color: var(--success);
    text-decoration: underline;
}

.ai-diff-container {
    background: #ffffff;
    color: #0f172a;
    border-radius: var(--radius-sm);
    padding: 10px 12px;
    font-size: 0.86rem;
    line-height: 1.6;
    max-height: 200px;
    overflow-y: auto;
    word-break: break-word;
}

.ai-diff-container.ai-code-diff {
    background: #0f172a;
    color: #f8fafc;
    white-space: pre-wrap;
    border: 1px solid #334155;
}

.ai-diff-container.ai-rendered-preview {
    white-space: normal;
}

.ai-diff-container.ai-rendered-preview p {
    margin: 0 0 8px 0;
}

.ai-diff-container.ai-rendered-preview p:last-child {
    margin-bottom: 0;
}

.diff-ins {
    background-color: #dcfce7;
    color: #15803d;
    text-decoration: none;
    padding: 1px 3px;
    border-radius: 3px;
    font-weight: 600;
}

.diff-del {
    background-color: #fee2e2;
    color: #b91c1c;
    text-decoration: line-through;
    padding: 1px 3px;
    border-radius: 3px;
    opacity: 0.75;
}

.diff-eq {
    color: inherit;
}

.ai-diff-actions {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 4px;
}

.ai-diff-actions .icon-btn.sm {
    padding: 5px 10px;
    font-size: 0.75rem;
    border-radius: var(--radius-sm);
}

/* Loading & Error States */
.ai-loading-state {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    border-radius: var(--radius-md);
    background: rgba(56, 189, 248, 0.08);
    color: var(--primary);
    font-size: 0.8rem;
    font-weight: 500;
}

.ai-error-banner {
    padding: 8px 12px;
    border-radius: var(--radius-md);
    background: rgba(244, 63, 94, 0.1);
    border: 1px solid rgba(244, 63, 94, 0.3);
    color: var(--danger);
    font-size: 0.78rem;
    line-height: 1.4;
}

/* AI Footer & Input */
.ai-flyout-footer {
    padding: 10px 14px 12px;
    background: var(--bg-surface-elevated);
    border-top: 1px solid var(--border-subtle);
}

.ai-input-wrap {
    display: flex;
    align-items: flex-end;
    gap: 6px;
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 6px 8px;
    transition: var(--transition-fast);
}

.ai-input-wrap:focus-within {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px var(--primary-glow);
}

.ai-prompt-textarea {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-main);
    font-family: inherit;
    font-size: 0.84rem;
    line-height: 1.4;
    resize: none;
    outline: none;
    max-height: 80px;
}

.ai-send-btn {
    background: var(--primary);
    border: none;
    color: #ffffff;
    width: 32px;
    height: 32px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 0.85rem;
    flex-shrink: 0;
    transition: var(--transition-fast);
}

.ai-send-btn:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
}

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