﻿/* ===================================
   Documents Feature - Desktop Styles
   ===================================
   Document writer desktop/editor styles for the workspace.

   Contains:
   - Document editor core (layout, header, sidebar, toolbar, editor area)
   - AI document dialog styles
   - Coming-soon badge styles
   - Workspace document overrides
   - Futuristic visual effects (Houdini animations, film grain, holo shimmer)

   Companion files (loaded separately):
   - document-mobile.css  — mobile responsive overrides

   Last visual upgrade: February 13, 2026 — Bold Futuristic Effects
   =================================== */

/* ===================================
   @property DECLARATIONS — Houdini Custom Properties
   Enables smooth animation of gradient angles, hues, and opacity
   =================================== */




/* ===================================
   FUTURISTIC KEYFRAMES
   =================================== */

/* Scanning light — traces along borders */


/* Holographic color shift — iridescent accent cycling */


/* Ambient breathing — slow gradient drift */


/* Focus aura — pulsing glow when editor is active */
@keyframes focusAura {
    0%, 100% {
        box-shadow:
            inset 0 0 40px rgba(0, 242, 254, 0.015),
            0 0 0 1px rgba(0, 242, 254, 0.06),
            0 0 20px rgba(0, 242, 254, 0.02);
    }
    50% {
        box-shadow:
            inset 0 0 60px rgba(0, 242, 254, 0.025),
            0 0 0 1px rgba(0, 242, 254, 0.1),
            0 0 40px rgba(0, 242, 254, 0.04);
    }
}

/* Save ripple — expanding sonar ring */
@keyframes saveRipple {
    0% {
        transform: scale(1);
        opacity: 0.6;
        box-shadow: 0 0 0 0 currentColor;
    }
    70% {
        transform: scale(1);
        opacity: 0;
        box-shadow: 0 0 0 8px currentColor;
    }
    100% {
        transform: scale(1);
        opacity: 0;
        box-shadow: 0 0 0 8px currentColor;
    }
}

/* Staggered document list entrance */
@keyframes docSlideIn {
    0% {
        opacity: 0;
        transform: translateX(-12px);
    }
    100% {
        opacity: 1;
        transform: translateX(0);
    }
}

/* Toolbar button magnetic hover */
@keyframes toolbarGlow {
    0%, 100% { box-shadow: 0 0 0 0 rgba(0, 242, 254, 0); }
    50% { box-shadow: 0 0 12px rgba(0, 242, 254, 0.12); }
}

/* Floating ambient orb drift */




/* Flowing gradient text */


/* Animated gradient border rotation */


/* Corner accent breathing */
@keyframes cornerPulse {
    0%, 100% { opacity: 0.4; }
    50% { opacity: 0.8; }
}

/* Shimmer sweep across surface */
@keyframes shimmerSweep {
    0% { left: -100%; }
    100% { left: 100%; }
}

/* Storage bar ambient glow */
@keyframes storageGlow {
    0%, 100% { box-shadow: 0 0 8px rgba(0, 242, 254, 0.3); }
    50% { box-shadow: 0 0 16px rgba(0, 242, 254, 0.5), 0 0 4px rgba(118, 75, 162, 0.3); }
}

/* Preview scan line */
@keyframes scanLineMove {
    0% { top: 0%; opacity: 0; }
    5% { opacity: 0.6; }
    95% { opacity: 0.6; }
    100% { top: 100%; opacity: 0; }
}
#documents-view .suggestion-item:focus-visible,
#documents-view .mode-toggle-btn:focus-visible,
#documents-view .sources-panel-summary:focus-visible,
#documents-view .doc-source-pill:focus-visible,
#documents-view .ai-chat-send-btn:focus-visible,
#ai-document-dialog .modal-close:focus-visible,
#ai-document-dialog .btn:focus-visible,
.r-skip-link:focus-visible {
    /* WCAG 1.4.11 requires ≥3:1 contrast for UI focus indicators.
       Opaque cyan on var(--ws-bg-deep) = ~6.1:1 (passes); the previous 0.6 alpha
       fell to ~2.5:1 (fails). The outer glow is retained as a secondary
       cue but the outline does the contrast work. */
    outline: 2px solid var(--ws-accent);
    outline-offset: 2px;
    box-shadow: 0 0 0 4px rgba(0, 242, 254, 0.18);
}

/* ===================================
   PART 1: MAIN DOCUMENT WRITER STYLES
   =================================== */

/* Document Writer - Quantum Theme Styling */
/* References design-system.css for unified values */
/**
 * The `--doc-*` names below are now ALIASES onto the shared workspace palette in
 * `css/workspace/workspace-tokens.css`.
 *
 * This is where Document Writer stops having its own colour scheme. It previously
 * ran a rival palette (bg var(--ws-bg-deep) vs chat's #0a0e1f, pink var(--ws-accent-pink) vs var(--ws-accent-pink),
 * text .87 vs .85, border .10 vs .08) which is why the workspace read as two
 * different products. Documents now resolves to the same palette as chat.
 *
 * Do NOT add new `--doc-*` colours here. Add `--ws-*` to workspace-tokens.css instead.
 */
:root {
    /* Surfaces — now chat's surfaces */
    --doc-bg-primary: var(--ws-bg-primary);
    --doc-bg-secondary: var(--ws-bg-secondary);
    --doc-bg-tertiary: var(--ws-bg-tertiary);

    /* Accents — now chat's accents */
    --doc-accent-cyan: var(--ws-accent);
    --doc-accent-purple: var(--ws-accent-purple);
    --doc-accent-pink: var(--ws-accent-pink);
    --doc-accent-gold: var(--color-accent-gold, #ffd60a);

    /* Text — now chat's hierarchy */
    --doc-text-primary: var(--ws-text);
    --doc-text-secondary: var(--ws-text-secondary);
    --doc-text-muted: var(--ws-text-muted);

    /* Borders + elevation */
    --doc-border: var(--ws-glass-border);
    --doc-border-glow: var(--ws-glass-border-hover);
    --doc-glass-border: var(--ws-glass-border);
    --doc-glass-border-hover: var(--ws-glass-border-hover);
    --doc-shadow: var(--ws-shadow-sm);
    --doc-shadow-lg: var(--ws-shadow-md);
    --doc-glow: 0 0 20px rgba(0, 242, 254, 0.06);
    --doc-glow-purple: 0 0 20px rgba(118, 75, 162, 0.06);

    /* Semantic state — now the shared scale */
    --doc-save-ok: var(--ws-success);
    --doc-save-active: var(--ws-warning-active);
    --doc-save-unsaved: var(--ws-warning);
    --doc-save-error: var(--ws-danger);
    --doc-success-text: var(--ws-success-text);
    --doc-danger-text: var(--ws-danger-text);
    --doc-danger-hover: var(--ws-danger);

    /* Gradients — rebuilt from the shared accents so no foreign hue leaks in.
       (--doc-gradient-secondary was a magenta var(--ws-accent-pink)→var(--ws-accent-pink) that existed
       nowhere else in the product.) */
    --doc-gradient-primary: var(--gradient-primary, linear-gradient(135deg, var(--ws-accent-purple) 0%, var(--ws-accent-indigo) 50%, var(--ws-accent) 100%));
    --doc-gradient-secondary: linear-gradient(135deg, var(--ws-accent-pink) 0%, var(--ws-accent-purple) 100%);
    --doc-gradient-tertiary: linear-gradient(135deg, var(--ws-accent) 0%, var(--ws-accent-indigo) 100%);
    --doc-gradient-glow: linear-gradient(135deg, rgba(118, 75, 162, 0.1) 0%, rgba(0, 242, 254, 0.08) 100%);

    /* Motion — one curve across the workspace */
    --doc-anim-ease: var(--ws-ease);
    --doc-anim-scan: 6s;
    --doc-anim-holo: 12s;
    --doc-anim-breath: 20s;

    /* Component fills.
       TODO(PR6 — premium components): unify the primary-button fill with chat's
       CTA (--ws-gradient-cta + --ws-cta-ink). Deliberately left alone here: the
       cyan CTA needs dark ink for contrast, and swapping the fill without the
       text colour would fail WCAG AA. That's a component change, not a palette one. */
    --doc-gradient-button: linear-gradient(90deg, var(--ws-accent-indigo) 0%, var(--ws-accent) 100%);
    --doc-gradient-button-hover: linear-gradient(90deg, var(--ws-accent-indigo) 0%, var(--ws-accent) 100%);
    --doc-gradient-card: var(--ws-gradient-surface);
}

/* Mode Toggle Buttons */
/* Top Mode Toggle Container - Centered Below Header */
.top-mode-toggle-container {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 0.5rem 0 0.25rem 0;
    background: transparent;
}

.mode-toggle-wrapper {
    display: flex;
    gap: 0.375rem;
    padding: 0.375rem;
    background: rgba(15, 20, 45, 0.7);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 1rem;
    box-shadow:
        0 4px 16px rgba(0, 0, 0, 0.2),
        0 1px 3px rgba(0, 0, 0, 0.12),
        inset 0 1px 0 rgba(255, 255, 255, 0.04);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
}

.mode-toggle-btn {
    padding: 0.625rem 1.75rem;
    border: 1px solid transparent;
    border-radius: 0.75rem;
    background: transparent;
    color: rgba(255, 255, 255, 0.5);
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.625rem;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    white-space: nowrap;
    position: relative;
    overflow: hidden;
}

.mode-toggle-btn:hover {
    background: rgba(0, 242, 254, 0.06);
    color: rgba(255, 255, 255, 0.85);
    border-color: rgba(0, 242, 254, 0.12);
}

.mode-toggle-btn.active {
    background: linear-gradient(135deg, rgba(0, 242, 254, 0.08) 0%, rgba(118, 75, 162, 0.12) 100%);
    color: white;
    border-color: rgba(255, 255, 255, 0.1);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

.mode-toggle-btn i {
    font-size: 1rem;
    opacity: 0.8;
}

.mode-toggle-btn.active i {
    opacity: 1;
}

/* Documents View Container
   NOTE: position/z-index managed by workspace.css and visibility-system.css.
   This file only handles the visual styling (background, flex layout).
   Do NOT add position:fixed or hardcoded z-index here. */
.documents-view {
    position: relative;
    width: 100%;
    min-height: calc(100vh - var(--doc-content-offset, 120px));
    /* THE ONE AMBIENT (premium-components.css) — identical to chat and the Hub.
       This used to be its own three-gradient wash (including a pink) that
       BREATHED: `animation: ambientBreath` drove --breath-pos so the gradients
       drifted horizontally forever. Documents was a living surface; chat was a
       starfield; the Hub was static. Now all three are the same, and still. */
    background-color: var(--ws-bg-primary);
    background-image: var(--ws-ambient);
    background-attachment: fixed;
    z-index: var(--z-documents-view, 400);
    display: flex;
    flex-direction: column;
    overflow: visible;
}

/* Film-grain overlay REMOVED — a texture only documents had. Chat and the Hub
   never carried it, so it was one more reason the three views felt like three
   different products. */

/* Animation removed - now using consolidated pulse-background-subtle from design-system.css */

/* Document Writer Container */
.document-writer-container {
    display: flex;
    flex-direction: column;
    height: 100%;
    background: transparent;
    color: var(--doc-text-primary);
    position: relative;
}

/* Floating ambient orbs — atmospheric depth */
.document-writer-container::before,
.document-writer-container::after {
    content: '';
    position: absolute;
    border-radius: 50%;
    pointer-events: none;
    filter: blur(80px);
    z-index: 0;
}

.document-writer-container::before {
    width: 300px;
    height: 300px;
    top: 10%;
    right: -5%;
    background: radial-gradient(circle, rgba(0, 242, 254, 0.08) 0%, transparent 70%);
    will-change: transform;
}

.document-writer-container::after {
    width: 250px;
    height: 250px;
    bottom: 15%;
    left: -3%;
    background: radial-gradient(circle, rgba(118, 75, 162, 0.1) 0%, transparent 70%);
    will-change: transform;
}

/* Document Header — Premium Glass */
.document-header {
    display: flex;
    flex-direction: column;
    /* Top padding matches the floating-nav's `top: 16px` so the buttons
       sit level-at-top with the centred Home + Documents pill rather
       than being pushed down beneath it. The pill's width (~190px) is
       narrower than the header-top row's centre gap, so it floats over
       the empty middle of the row without overlapping the left/right
       action buttons. */
    padding: 1rem 2.5rem 1rem;
    background: linear-gradient(180deg, var(--ws-bg-deep) 0%, var(--ws-bg-secondary) 100%);
    backdrop-filter: blur(24px) saturate(1.4);
    -webkit-backdrop-filter: blur(24px) saturate(1.4);
    border-bottom: 1px solid var(--doc-glass-border);
    box-shadow:
        0 4px 30px rgba(0, 0, 0, 0.3),
        0 1px 0 rgba(255, 255, 255, 0.04) inset;
    z-index: var(--z-sticky, 150);
    gap: 0.75rem;
    width: 100%;
    box-sizing: border-box;
    position: relative;
}

/* Scanning accent line at bottom of header — animated light trace */
.document-header::after {
    content: '';
    position: absolute;
    bottom: -1px;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(
        90deg,
        transparent 0%,
        transparent calc(50% + 30% * cos(var(--scan-angle)) - 15%),
        rgba(0, 242, 254, 0.35) calc(50% + 30% * cos(var(--scan-angle))),
        rgba(118, 75, 162, 0.25) calc(50% + 30% * cos(var(--scan-angle)) + 5%),
        transparent calc(50% + 30% * cos(var(--scan-angle)) + 15%),
        transparent 100%
    );
    z-index: 1;
    will-change: --scan-angle;
}

.document-header-left,
.document-header-right {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: nowrap;
}

.document-header-left {
    flex: 1;
    min-width: 0;
    justify-content: flex-start;
}

.document-header-right {
    flex-shrink: 0;
    justify-content: flex-end;
}

/* Top row: Action buttons */
.document-header-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

/* Bottom row: Title and status */
.document-header-bottom {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding-top: 0.25rem;
}

.doc-btn-coming-soon {
    opacity: 0.7;
    cursor: not-allowed;
    position: relative;
    overflow: visible;
}

.doc-btn-coming-soon:hover {
    transform: none;
    box-shadow: none;
}

.document-title-input {
    background: transparent;
    border: none;
    color: var(--doc-text-primary);
    font-size: 1.75rem;
    font-weight: 700;
    padding: 0.4rem 0;
    border-bottom: 2px solid rgba(255, 255, 255, 0.06);
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    flex: 1;
    letter-spacing: -0.5px;
    min-width: 0;
    position: relative;
}

.document-title-input:focus {
    outline: none;
    border-bottom-color: rgba(0, 242, 254, 0.25);
    border-image: linear-gradient(var(--scan-angle, 90deg), rgba(0, 242, 254, 0.4), rgba(118, 75, 162, 0.3), rgba(0, 242, 254, 0.4)) 1;
    color: var(--ws-text);
}

.document-title-input::placeholder {
    color: var(--doc-text-muted);
    opacity: 0.35;
    font-style: italic;
}

.document-status {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--doc-text-muted);
    /* Bumped from 0.7rem (11.2px) to the design system's xs scale
       (12-13px) so ambient status text clears the legibility floor. */
    font-size: var(--font-size-xs);
    white-space: nowrap;
    margin-left: auto;
    padding: 0.3rem 0.85rem;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 2rem;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    letter-spacing: 0.3px;
    font-weight: 500;
}

.document-status i {
    color: rgba(255, 255, 255, 0.45);
    font-size: 0.72rem;
}

/* Document Main Area */
.document-main {
    display: flex;
    flex: 1;
    overflow: hidden;
    max-width: 100%;
}

/* Hide close button on desktop */
.sidebar-close-btn {
    display: none;
}

/* --- Sidebar Title --- */
.sidebar-title {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 2.5px;
    color: rgba(255, 255, 255, 0.35);
    padding: 1.5rem 1.25rem 0.5rem;
    margin: 0;
    position: relative;
    z-index: 1;
}

.sidebar-section {
    padding: 0.5rem 1rem 1rem;
    position: relative;
    z-index: 1;
    flex: 1;
    overflow-y: auto;
    min-height: 0;
}

.sidebar-section h4 {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    margin-bottom: 0.75rem;
    color: rgba(255, 255, 255, 0.35);
}

.sidebar-section h4 i {
    color: var(--doc-accent-cyan);
    font-size: 0.75rem;
    opacity: 0.6;
}

/* --- Document Tabs — Pill Design --- */
.document-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 0.875rem;
    padding: 3px;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.06);
    position: relative;
}

.doc-tab-btn {
    flex: 1;
    padding: 0.5rem 0.75rem;
    background: transparent;
    border: none;
    border-radius: 8px;
    color: rgba(255, 255, 255, 0.45);
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    position: relative;
    overflow: hidden;
    z-index: 1;
}

.doc-tab-btn::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 8px;
    opacity: 0;
    background: linear-gradient(135deg, rgba(0, 242, 254, 0.1), rgba(118, 75, 162, 0.1));
    transition: opacity 0.3s ease;
}

.doc-tab-btn:hover {
    color: rgba(255, 255, 255, 0.8);
}

.doc-tab-btn:hover::before {
    opacity: 1;
}

.doc-tab-btn.active {
    color: var(--ws-text);
    background: linear-gradient(135deg, rgba(118, 75, 162, 0.7), rgba(0, 242, 254, 0.4));
    box-shadow:
        0 2px 12px rgba(0, 0, 0, 0.3),
        0 1px 3px rgba(0, 0, 0, 0.2),
        inset 0 1px 0 rgba(255, 255, 255, 0.1),
        0 0 16px rgba(0, 242, 254, 0.08);
    animation: toolbarGlow 3s ease-in-out infinite;
}

.doc-tab-btn.active::before {
    opacity: 0;
}

.doc-tab-btn i {
    font-size: 0.8rem;
    transition: transform 0.2s ease;
}

.doc-tab-btn:hover i {
    transform: scale(1.1);
}

.trash-count-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 16px;
    height: 16px;
    padding: 0 5px;
    background: linear-gradient(135deg, var(--ws-accent-pink), var(--ws-accent-pink));
    color: white;
    font-size: 0.6rem;
    font-weight: 700;
    border-radius: 8px;
    line-height: 1;
    box-shadow: 0 2px 8px rgba(240, 147, 251, 0.4);
}

/* Mobile hamburger badge — surfaces active-generation count when the
   docs sidebar is collapsed. Anchored to the upper-right of
   #doc-mobile-menu-btn (the only element that contains this badge).
   Hidden by default; JS toggles .is-hidden + sets textContent based on
   documentTasks.activeCount(). Yellow tint to match the in-progress
   card state. */
.active-task-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    background: linear-gradient(135deg, var(--color-warning), var(--ws-warning-active));
    color: var(--ws-bg-deep);
    /* Bumped from 0.65rem (10.4px) to 0.72rem (~11.5px) so two-digit
       counts ("9+") remain legible on small viewports. */
    font-size: 0.72rem;
    font-weight: 700;
    border-radius: 9px;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(251, 191, 36, 0.45);
    pointer-events: none;
}
/* Anchor: the hamburger button needs position:relative for the absolute
   badge. The existing .doc-mobile-menu-toggle rule lacks it; scoped
   here so we don't reach into the original block. */
.doc-mobile-menu-toggle {
    position: relative;
}

/* --- Search Bar — Floating Glass --- */
.document-search {
    position: relative;
    margin-bottom: 1rem;
}

.document-search i {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: rgba(255, 255, 255, 0.3);
    font-size: 0.8rem;
    transition: color 0.3s ease;
    z-index: 1;
}

.document-search input {
    width: 100%;
    padding: 10px 12px 10px 36px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 10px;
    color: var(--doc-text-primary);
    font-size: 0.8rem;
    font-weight: 500;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-sizing: border-box;
}

.document-search input::placeholder {
    color: rgba(255, 255, 255, 0.25);
    font-weight: 400;
}

.document-search input:focus {
    outline: none;
    border-color: rgba(0, 242, 254, 0.35);
    background: rgba(0, 242, 254, 0.04);
    box-shadow:
        0 0 0 3px rgba(0, 242, 254, 0.06),
        0 0 15px rgba(0, 242, 254, 0.08),
        0 4px 16px rgba(0, 0, 0, 0.2);
}

.document-search:has(input:focus) i {
    color: var(--doc-accent-cyan);
}

/* --- Documents List --- */
.documents-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

/* --- Sidebar Brand Header --- */
.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 1.25rem 1.25rem 0.25rem;
    position: relative;
    z-index: 1;
}

.sidebar-brand-icon {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: linear-gradient(135deg, rgba(118, 75, 162, 0.4), rgba(0, 242, 254, 0.3));
    border: 1px solid rgba(0, 242, 254, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
    color: var(--doc-accent-cyan);
    box-shadow:
        0 4px 16px rgba(0, 0, 0, 0.25),
        0 1px 3px rgba(0, 0, 0, 0.15);
    flex-shrink: 0;
    position: relative;
    overflow: hidden;
}

/* Animated gradient border on brand icon */
.sidebar-brand-icon::before {
    content: '';
    position: absolute;
    inset: -1px;
    border-radius: 10px;
    background: linear-gradient(90deg,
        rgba(0, 242, 254, 0.4),
        rgba(118, 75, 162, 0.4),
        rgba(0, 242, 254, 0.4)
    );
    background-size: 300% 100%;
    z-index: -1;
    mask: linear-gradient(var(--ws-text) 0 0) content-box, linear-gradient(var(--ws-text) 0 0);
    mask-composite: exclude;
    -webkit-mask: linear-gradient(var(--ws-text) 0 0) content-box, linear-gradient(var(--ws-text) 0 0);
    -webkit-mask-composite: xor;
    padding: 1px;
}

.sidebar-brand-text {
    min-width: 0;
}

.sidebar-brand-text .sidebar-title {
    font-size: 0.9rem;
    font-weight: 700;
    letter-spacing: 0.5px;
    text-transform: none;
    background: linear-gradient(90deg, var(--ws-text), var(--doc-accent-cyan), var(--doc-accent-purple), var(--ws-text));
    background-size: 300% 100%;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    padding: 0;
    margin: 0;
    line-height: 1.2;
}

.sidebar-doc-count {
    font-size: 0.65rem;
    font-weight: 600;
    color: rgba(0, 242, 254, 0.5);
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

/* --- Sidebar Footer --- */
.sidebar-footer-info {
    margin-top: auto;
    padding: 1rem 1.25rem 1.25rem;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    position: relative;
    z-index: 1;
}

.sidebar-storage {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.storage-label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: rgba(255, 255, 255, 0.3);
}

.storage-label i {
    font-size: 0.6rem;
    color: rgba(0, 242, 254, 0.4);
}

.storage-bar {
    width: 100%;
    height: 3px;
    background: rgba(255, 255, 255, 0.06);
    border-radius: 3px;
    overflow: hidden;
}

.storage-bar-fill {
    height: 100%;
    border-radius: 3px;
    background: linear-gradient(90deg, var(--doc-accent-cyan), var(--doc-accent-purple));
    transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
    animation: storageGlow 3s ease-in-out infinite;
    position: relative;
    overflow: hidden;
}

/* Shimmer highlight on storage bar */
.storage-bar-fill::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 60%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
    animation: shimmerSweep 3s ease-in-out infinite;
}

.storage-text {
    /* 0.7rem ≈ 11.2px — minimum readable size on 1× displays. 0.6rem (9.6px)
     * was illegible without zooming. */
    font-size: 0.7rem;
    color: rgba(255, 255, 255, 0.25);
    font-weight: 500;
    letter-spacing: 0.3px;
}

/* Editor Area */
.document-editor-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    width: 100%;
    max-width: 1600px;
    margin: 0 auto;
}

.editor-container {
    display: flex;
    flex-direction: column;
    flex: 1;
    overflow: hidden;
    width: 100%;
    position: relative;
}

/* Animated gradient border — flowing cyan/purple accent */
.editor-container::before {
    content: '';
    position: absolute;
    inset: -1px;
    background: linear-gradient(90deg,
        transparent,
        rgba(0, 242, 254, 0.12),
        rgba(118, 75, 162, 0.12),
        rgba(0, 242, 254, 0.12),
        transparent
    );
    background-size: 300% 100%;
    z-index: -1;
    pointer-events: none;
    mask: linear-gradient(var(--ws-text) 0 0) content-box, linear-gradient(var(--ws-text) 0 0);
    mask-composite: exclude;
    -webkit-mask: linear-gradient(var(--ws-text) 0 0) content-box, linear-gradient(var(--ws-text) 0 0);
    -webkit-mask-composite: xor;
    padding: 1px;
}

/* Editor Toolbar — Floating Glass.
 * `position: relative` (not sticky): the toolbar's parent .editor-container has
 * `overflow: hidden`, which silently disables `position: sticky`. The toolbar
 * was staying visible by flex-column layout coincidence, not stickiness — make
 * the intent explicit. flex-shrink: 0 ensures it never collapses. */
.editor-toolbar {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.625rem 1.25rem;
    background: linear-gradient(180deg, var(--ws-bg-secondary) 0%, var(--ws-bg-secondary) 100%);
    backdrop-filter: blur(20px) saturate(1.3);
    -webkit-backdrop-filter: blur(20px) saturate(1.3);
    border-bottom: 1px solid rgba(0, 242, 254, 0.06);
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.03),
        0 2px 16px rgba(0, 0, 0, 0.25);
    gap: 0.5rem;
    flex-wrap: wrap;
    width: 100%;
    box-sizing: border-box;
    position: relative;
    flex-shrink: 0;
    z-index: var(--z-sticky, 150);
}

.toolbar-group {
    display: flex;
    gap: 2px;
    padding: 3px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 0.625rem;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.toolbar-group:hover {
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(0, 242, 254, 0.12);
    box-shadow: 0 0 12px rgba(0, 242, 254, 0.04), inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.toolbar-btn {
    padding: 0.5rem 0.625rem;
    /* Visible boundary at rest — a formatting control the user can SEE is a
       control, rather than an icon that only reveals itself on hover. */
    background: var(--ws-glass-bg);
    border: 1px solid var(--ws-border-control);
    border-radius: 0.4rem;
    color: rgba(255, 255, 255, 0.5);
    cursor: pointer;
    transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease, box-shadow 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    font-size: 0.875rem;
}

.toolbar-btn i {
    font-size: 0.875rem;
    color: inherit;
    transition: color 0.2s ease;
}

.toolbar-btn:hover {
    background: rgba(255, 255, 255, 0.06);
    border-color: rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.95);
}

.toolbar-btn:active {
    opacity: 0.8;
    transition-duration: 0.1s;
}

.toolbar-btn.active {
    background: linear-gradient(135deg, rgba(0, 242, 254, 0.08) 0%, rgba(118, 75, 162, 0.06) 100%);
    border-color: rgba(0, 242, 254, 0.18);
    color: var(--doc-accent-cyan);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06);
    position: relative;
}

/* Gradient accent underline on active toolbar button */
.toolbar-btn.active::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 10%;
    right: 10%;
    height: 2px;
    background: linear-gradient(90deg, var(--doc-accent-purple), var(--doc-accent-cyan));
    border-radius: 2px;
    opacity: 0.7;
}

.toolbar-btn.active i {
    color: inherit;
}

.heading-label {
    font-weight: 700;
    font-size: 0.8rem;
    letter-spacing: -0.5px;
}

.toolbar-divider {
    width: 1px;
    height: 24px;
    background: linear-gradient(180deg, transparent, rgba(255, 255, 255, 0.1), transparent);
    margin: 0 0.375rem;
}

.toolbar-spacer {
    flex: 1;
}

/* Editor Content */
.editor-content {
    flex: 1;
    display: flex;
    overflow: hidden;
    justify-content: center;
    width: 100%;
    position: relative;
    background-image:
none;  /* graph-paper grid removed — a texture only documents had */
}

/* Corner accent brackets — viewfinder frame */
.editor-content::before,
.editor-content::after {
    content: '';
    position: absolute;
    width: 24px;
    height: 24px;
    pointer-events: none;
    z-index: 2;
    animation: cornerPulse 4s ease-in-out infinite;
}

.editor-content::before {
    top: 8px;
    left: 8px;
    border-top: 2px solid rgba(0, 242, 254, 0.25);
    border-left: 2px solid rgba(0, 242, 254, 0.25);
}

.editor-content::after {
    bottom: 8px;
    right: 8px;
    border-bottom: 2px solid rgba(118, 75, 162, 0.25);
    border-right: 2px solid rgba(118, 75, 162, 0.25);
    animation-delay: -2s;
}

.markdown-editor {
    flex: 1;
    padding: 2.5rem 3.5rem;
    background: var(--ws-bg-primary);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: none;
    color: var(--doc-text-primary);
    /* Reading typography — was monospace (JetBrains Mono), which made
       prose feel like source code. Editor is for writing, not coding;
       monospace stays on inline `code` / fenced blocks in the preview. */
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI',
                 Roboto, 'Helvetica Neue', Arial, sans-serif;
    font-size: 1rem;
    line-height: 1.75;
    resize: none;
    overflow-y: auto;
    /* Reading-comfortable measure (~70ch). Was 900px ≈ 112ch, well past
       the 60-75ch sweet spot. Capped at 720px on smaller viewports so
       it still fills the column on narrow editors. */
    max-width: min(720px, 72ch);
    margin: 0 auto;
    width: 100%;
    box-sizing: border-box;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    caret-color: var(--doc-accent-cyan);
    tab-size: 4;
    letter-spacing: 0.01em;
}

.markdown-editor::placeholder {
    color: var(--doc-text-muted);
    opacity: 0.4;
    font-style: italic;
}

/* Preview crossfade transition */
.preview-crossfade-out {
    opacity: 0 !important;
    transform: translateY(4px) !important;
    transition: opacity 0.25s ease, transform 0.25s ease !important;
}

.markdown-editor:focus {
    outline: none;
    background: var(--ws-bg-primary);
    animation: focusAura 4s ease-in-out infinite;
    will-change: box-shadow;
}
.toolbar-btn:focus-visible,
.doc-tab-btn:focus-visible,
.ai-panel-toggle:focus-visible,
.ai-action-btn:focus-visible {
    outline: 2px solid rgba(0, 242, 254, 0.5);
    outline-offset: 2px;
    box-shadow: 0 0 0 4px rgba(0, 242, 254, 0.08);
}

.document-title-input:focus-visible {
    outline: none;
    border-bottom-color: rgba(0, 242, 254, 0.25);
    box-shadow: 0 2px 0 0 rgba(0, 242, 254, 0.15);
}

.document-search input:focus-visible {
    outline: 2px solid var(--doc-accent-cyan);
    outline-offset: -2px;
}

/* The preview is a READING SURFACE — the same one chat uses. Both editors get
   it: this rule is deliberately unscoped so #blog-writer-view inherits it too.
   (It previously carried a `#documents-view` twin further down this file, which
   is why documents had a calm reading pane and the Hub still had the old one.) */
.preview-pane {
    flex: 1;
    padding: 40px 32px 64px;
    background: var(--ws-bg-primary);
    overflow-y: auto;
    overflow-x: hidden;
    border-left: 1px solid var(--ws-glass-border);
    position: relative;
}

/* The retro scan line and the holographic edge sweep are GONE. Two infinite
   animations were running across the surface you read a document on — chat's
   answer surface has never had them, and "calm reading surface" and "a cyan
   line sweeping down it every 6 seconds" cannot both be true. */
.preview-pane::after,
.preview-pane::before { content: none; }

.preview-content {
    /* Typography is NOT set here. It comes from .pm-prose
       (css/shared/premium-components.css) — the one prose surface.

       This rule used to declare `max-width: 900px; line-height: 1.8; color: ...`
       UNSCOPED, and document-writer.css loads AFTER premium-components.css — so
       at equal (0,1,0) specificity it silently beat .pm-prose and overrode the
       measure and the line-height on BOTH previews. That single rule was the
       biggest reason the same markdown read differently in each service. */
    margin: 0 auto;
}

/* Editor Footer — Premium Glass */
.editor-footer {
    padding: 0.75rem 2rem;
    background: linear-gradient(180deg, rgba(21, 26, 53, 0.75) 0%, var(--ws-bg-secondary) 100%);
    backdrop-filter: blur(20px) saturate(1.3);
    -webkit-backdrop-filter: blur(20px) saturate(1.3);
    border-top: 1px solid rgba(0, 242, 254, 0.06);
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.03),
        0 -2px 16px rgba(0, 0, 0, 0.2);
    width: 100%;
    box-sizing: border-box;
    position: relative;
}

/* Scanning accent line at top of footer — synced light trace */
.editor-footer::before {
    content: '';
    position: absolute;
    top: -1px;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(
        90deg,
        transparent 0%,
        transparent calc(50% + 30% * cos(var(--scan-angle)) - 15%),
        rgba(118, 75, 162, 0.2) calc(50% + 30% * cos(var(--scan-angle))),
        rgba(0, 242, 254, 0.15) calc(50% + 30% * cos(var(--scan-angle)) + 5%),
        transparent calc(50% + 30% * cos(var(--scan-angle)) + 15%),
        transparent 100%
    );
    animation-delay: -3s;
    will-change: --scan-angle;
}

.editor-stats {
    display: flex;
    gap: 2rem;
    font-size: 0.8rem;
    color: rgba(255, 255, 255, 0.45);
    justify-content: center;
    max-width: 1600px;
    margin: 0 auto;
    font-weight: 500;
    letter-spacing: 0.2px;
}

.editor-stats span {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.stat-item {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    white-space: nowrap;
    padding: 0.2rem 0.6rem;
    border-radius: 1rem;
    transition: all 0.3s ease;
}

.stat-item:hover {
    background: rgba(255, 255, 255, 0.04);
    color: rgba(255, 255, 255, 0.7);
}

.stat-item i {
    color: rgba(255, 255, 255, 0.35);
    font-size: 0.7rem;
}

/* Save Indicator (footer) */
.save-indicator {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding-top: 0.35rem;
    /* Bumped from 0.7rem (11.2px) to design-system xs (12-13px). */
    font-size: var(--font-size-xs);
    color: rgba(255, 255, 255, 0.35);
    transition: all 0.3s ease;
    letter-spacing: 0.2px;
}

.save-indicator .save-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--doc-save-ok);
    flex-shrink: 0;
    transition: all 0.3s ease;
    position: relative;
}

/* Ripple ring on save dot */
.save-indicator .save-dot::after {
    content: '';
    position: absolute;
    inset: -3px;
    border-radius: 50%;
    border: 1px solid;
    color: inherit;
    opacity: 0;
    animation: none;
}

.save-indicator.saving .save-dot {
    background: var(--doc-save-active);
    animation: pulse-dot 1s ease-in-out infinite;
}

.save-indicator.saving .save-dot::after {
    color: var(--doc-save-active);
    animation: saveRipple 1.5s ease-out infinite;
}

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

.save-indicator.error .save-dot {
    background: var(--doc-save-error);
}

@keyframes pulse-dot {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.6; transform: scale(1.3); }
}

/* Desktop-only visibility helper */
.desktop-only {
    display: flex;
}

.editor-stats i {
    color: rgba(255, 255, 255, 0.35);
    font-size: 0.75rem;
}

/* AI Assistant Panel — Premium Glass */
.document-ai-panel {
    width: 300px;
    background: linear-gradient(180deg, rgba(15, 20, 45, 0.92) 0%, rgba(10, 14, 39, 0.95) 100%);
    backdrop-filter: blur(24px) saturate(1.3);
    -webkit-backdrop-filter: blur(24px) saturate(1.3);
    border-left: 1px solid rgba(255, 255, 255, 0.04);
    box-shadow:
        -4px 0 16px rgba(0, 0, 0, 0.15),
        -1px 0 3px rgba(0, 0, 0, 0.1),
        inset 1px 0 0 rgba(255, 255, 255, 0.03);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
}

/* Holographic accent line on left edge — iridescent shift */
.document-ai-panel::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 1px;
    height: 100%;
    background: linear-gradient(
        180deg,
        transparent 0%,
        hsla(calc(200 + var(--holo-hue, 0deg)), 70%, 55%, 0.15) 30%,
        hsla(calc(280 + var(--holo-hue, 0deg)), 60%, 50%, 0.12) 70%,
        transparent 100%
    );
    z-index: 1;
    animation-delay: -4s;
    will-change: --holo-hue;
}

.document-ai-panel.collapsed {
    width: 0;
    overflow: hidden;
}

.ai-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.25rem;
    background: rgba(255, 255, 255, 0.02);
    border-bottom: 1px solid rgba(0, 242, 254, 0.06);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

.ai-panel-title {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    font-weight: 700;
    font-size: 0.875rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--doc-text-primary);
}

.ai-panel-title i {
    color: var(--doc-accent-purple);
    font-size: 1rem;
}

.ai-panel-toggle {
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.08);
    color: rgba(255, 255, 255, 0.5);
    width: 30px;
    height: 30px;
    border-radius: 0.5rem;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
    justify-content: center;
}

.ai-panel-toggle:hover {
    background: rgba(255, 255, 255, 0.06);
    border-color: rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.8);
}

.ai-panel-content {
    flex: 1;
    overflow-y: auto;
    padding: 1.25rem;
}

.ai-suggestions-section,
.ai-actions-section,
.ai-chat-section {
    margin-bottom: 2rem;
}

.ai-suggestions-section h4,
.ai-actions-section h4,
.ai-chat-section h4 {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--doc-text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.75px;
    margin-bottom: 0.875rem;
}

.ai-suggestions-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.suggestion-item {
    display: flex;
    align-items: flex-start;
    gap: 0.625rem;
    padding: 0.75rem;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 0.75rem;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.suggestion-item::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    width: 2px;
    height: 100%;
    background: linear-gradient(180deg, rgba(0, 242, 254, 0.2), rgba(118, 75, 162, 0.15));
    opacity: 0;
    transition: opacity 0.3s ease;
}

.suggestion-item:hover::before {
    opacity: 1;
}

.suggestion-item:hover {
    background: rgba(0, 242, 254, 0.04);
    border-color: rgba(0, 242, 254, 0.12);
    transform: translateX(4px);
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.15);
}

.suggestion-item i {
    color: var(--doc-accent-cyan);
    font-size: 0.875rem;
    margin-top: 0.125rem;
}

.suggestion-item span {
    font-size: 0.875rem;
    line-height: 1.5;
}

.ai-action-btn {
    width: 100%;
    padding: 0.75rem 1rem;
    margin-bottom: 0.5rem;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 0.75rem;
    color: rgba(255, 255, 255, 0.7);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 0.85rem;
    font-weight: 500;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.ai-action-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(0, 242, 254, 0.05), rgba(255, 255, 255, 0.06), rgba(0, 242, 254, 0.05), transparent);
    transition: left 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.ai-action-btn:hover::before {
    left: 100%;
}

.ai-action-btn:hover {
    background: rgba(0, 242, 254, 0.06);
    border-color: rgba(0, 242, 254, 0.15);
    color: var(--doc-accent-cyan);
    transform: translateX(4px) scale(1.01);
    box-shadow: 0 2px 16px rgba(0, 0, 0, 0.15), 0 0 16px rgba(0, 242, 254, 0.06);
}

.ai-action-btn i {
    font-size: 0.875rem;
}

.ai-chat-input-wrapper {
    display: flex;
    gap: 0.5rem;
}

.ai-chat-input {
    flex: 1;
    padding: 0.75rem;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 0.75rem;
    color: var(--doc-text-primary);
    font-size: 0.85rem;
    transition: all 0.3s ease;
}

.ai-chat-input:focus {
    outline: none;
    border-color: rgba(0, 242, 254, 0.15);
    box-shadow: 0 0 0 2px rgba(0, 242, 254, 0.04);
    background: rgba(255, 255, 255, 0.04);
}

.ai-chat-send-btn {
    padding: 0.75rem 1rem;
    background: linear-gradient(135deg, rgba(0, 242, 254, 0.1) 0%, rgba(118, 75, 162, 0.12) 100%);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 0.75rem;
    color: white;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.ai-chat-send-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    border-color: rgba(0, 242, 254, 0.15);
}

/* Responsive Design */
@media (max-width: 1440px) {
    .document-title-input {
        font-size: 1.5rem;
    }
}

@media (max-width: 1200px) {
    .document-ai-panel {
        width: 280px;
    }
    
    .document-title-input {
        font-size: 1.35rem;
    }
}

@media (max-width: 1024px) {
    .document-header-top {
        flex-direction: column;
        gap: 0.75rem;
    }
    
    .document-header-left,
    .document-header-right {
        width: 100%;
        justify-content: center;
    }
    
    .document-title-input {
        font-size: 1.25rem;
    }

    .document-main {
        flex-direction: column;
    }

    .sidebar-brand {
        width: 100%;
        padding: 0.75rem 1rem 0.25rem;
    }

    .sidebar-footer-info {
        display: none;
    }
    
    .document-ai-panel {
        width: 100%;
        border-left: none;
        border-top: 1px solid var(--doc-border);
        max-height: 300px;
    }
}

/* Mobile overrides moved to document-mobile.css with higher specificity */

/* Scrollbar Styling (sidebar has its own scrollbar above) */
.markdown-editor::-webkit-scrollbar,
.preview-pane::-webkit-scrollbar,
.ai-panel-content::-webkit-scrollbar {
    width: 6px;
}

.markdown-editor::-webkit-scrollbar-track,
.preview-pane::-webkit-scrollbar-track,
.ai-panel-content::-webkit-scrollbar-track {
    background: var(--ws-glass-bg);
    border-radius: 6px;
    margin: 4px;
}

.markdown-editor::-webkit-scrollbar-thumb,
.preview-pane::-webkit-scrollbar-thumb,
.ai-panel-content::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 6px;
}

.markdown-editor::-webkit-scrollbar-thumb:hover,
.preview-pane::-webkit-scrollbar-thumb:hover,
.ai-panel-content::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.18);
}

/* ===================================
   PART 2: AI DOCUMENT GENERATION DIALOG
   =================================== */

#ai-document-dialog.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: var(--z-max, 10000);
    animation: fadeIn 0.3s ease;
    padding: 40px 20px;
    overflow-y: auto;
}

#ai-document-dialog .modal-container {
    background: linear-gradient(135deg, var(--ws-bg-secondary) 0%, var(--ws-bg-deep) 100%);
    border-radius: 20px;
    border: 1px solid rgba(0, 242, 254, 0.15);
    box-shadow:
        0 25px 80px rgba(0, 0, 0, 0.5),
        0 0 40px rgba(0, 242, 254, 0.06),
        inset 0 0 0 1px rgba(255, 255, 255, 0.04);
    max-width: 700px;
    width: 100%;
    /* vh fallback, then svh (small viewport height) override for iOS Safari.
     * `100vh` on iOS doesn't account for the bottom browser chrome, which
     * was clipping the modal footer. `svh` reports the visible viewport. */
    max-height: calc(100vh - 80px);
    max-height: calc(100svh - 80px);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    animation: premiumModalIn 0.45s cubic-bezier(0.16, 1, 0.3, 1) forwards;
    margin: auto;
    position: relative;
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
}

/* Exit animation class applied by JS */
#ai-document-dialog .modal-container.modal-exiting {
    animation: premiumModalOut 0.25s ease-in forwards;
    pointer-events: none;
}

#ai-document-dialog .modal-header {
    padding: 24px 28px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: linear-gradient(135deg, var(--ws-bg-secondary) 0%, var(--ws-bg-secondary) 100%);
    flex-shrink: 0;
    min-height: 70px;
    position: relative;
}

#ai-document-dialog .modal-header::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(90deg, transparent, rgba(0, 242, 254, 0.3), rgba(118, 75, 162, 0.2), rgba(240, 147, 251, 0.15), transparent);
    animation: docShimmer 4s ease-in-out infinite;
}

/* Renamed from shimmer to avoid collision with chat.css shimmer (bg-position based) */
@keyframes docShimmer {
    0%, 100% { opacity: 0.3; }
    50% { opacity: 1; }
}

#ai-document-dialog .modal-header h2 {
    margin: 0;
    font-size: 20px;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.9);
    display: flex;
    align-items: center;
    gap: 12px;
    text-transform: none;
}

#ai-document-dialog .modal-header h2 i {
    color: rgba(0, 242, 254, 0.7);
    font-size: 24px;
    filter: drop-shadow(0 0 8px rgba(0, 242, 254, 0.4));
}

#ai-document-dialog .modal-close {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: var(--doc-danger-text);
    width: 36px;
    height: 36px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 18px;
}

#ai-document-dialog .modal-close:hover {
    background: rgba(239, 68, 68, 0.15);
    border-color: rgba(239, 68, 68, 0.4);
    color: var(--ws-danger);
    transform: rotate(90deg) scale(1.1);
}

#ai-document-dialog .modal-body {
    padding: 28px;
    overflow-y: auto;
    overflow-x: hidden;
    flex: 1;
    min-height: 0;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.1) transparent;
    background: var(--ws-bg-primary);
}

#ai-document-dialog .modal-body::-webkit-scrollbar {
    width: 6px;
}

#ai-document-dialog .modal-body::-webkit-scrollbar-track {
    background: var(--ws-glass-bg);
    border-radius: 4px;
}

#ai-document-dialog .modal-body::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
}

#ai-document-dialog .modal-body::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.18);
}

#ai-document-dialog .form-group {
    margin-bottom: 24px;
}

#ai-document-dialog .form-group label {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.87);
    font-size: 14px;
    text-transform: none;
    letter-spacing: normal;
}

#ai-document-dialog .form-group label i {
    color: rgba(0, 242, 254, 0.5);
    font-size: 18px;
}

#ai-document-dialog .form-control {
    width: 100%;
    padding: 14px 16px;
    background: var(--ws-bg-primary);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 12px;
    color: rgba(255, 255, 255, 0.9);
    font-size: 15px;
    transition: all 0.3s ease;
    font-family: inherit;
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.1);
}

#ai-document-dialog .form-control:hover {
    border-color: rgba(255, 255, 255, 0.12);
    background: var(--ws-bg-deep);
}

#ai-document-dialog .form-control:focus {
    outline: none;
    border-color: rgba(0, 242, 254, 0.3);
    box-shadow:
        0 0 0 3px rgba(0, 242, 254, 0.08),
        0 0 20px rgba(0, 242, 254, 0.05),
        inset 0 1px 3px rgba(0, 0, 0, 0.1);
    background: var(--ws-bg-deep);
}

#ai-document-dialog .form-control::placeholder {
    color: rgba(255, 255, 255, 0.3);
    opacity: 0.7;
}

#ai-document-dialog select.form-control {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2300f2fe' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 20px;
    padding-right: 40px;
}

#ai-document-dialog textarea.form-control {
    resize: vertical;
    min-height: 120px;
    line-height: 1.6;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

#ai-document-dialog .form-hint {
    display: block;
    margin-top: 8px;
    font-size: 12px;
    color: rgba(255, 255, 255, 0.38);
    font-style: italic;
}

#ai-document-dialog .form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

#ai-document-dialog .form-col {
    margin-bottom: 0;
}

#ai-document-dialog .checkbox-label {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    margin-right: 20px;
    margin-bottom: 8px;
    cursor: pointer;
    color: rgba(255, 255, 255, 0.87);
    font-size: 14px;
    transition: color 0.2s ease;
    text-transform: none;
}

#ai-document-dialog .checkbox-label:hover {
    color: rgba(0, 242, 254, 0.7);
}

#ai-document-dialog .checkbox-label input[type="checkbox"] {
    width: 20px;
    height: 20px;
    cursor: pointer;
    accent-color: var(--doc-accent-cyan);
    border-radius: 4px;
}

/* In-dialog status panel CSS removed 2026-05-12 along with the
   corresponding markup and JS. Generation progress now surfaces
   via yellow/green/red cards in the documents sidebar (see
   .document-item.is-generating / .is-completed / .is-failed)
   so the dialog can close immediately on submit. */

#ai-document-dialog .modal-footer {
    padding: 20px 28px;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 12px;
    background: linear-gradient(135deg, var(--ws-bg-secondary) 0%, var(--ws-bg-secondary) 100%);
    flex-shrink: 0;
}

#ai-document-dialog .btn {
    padding: 12px 24px;
    border-radius: 0.625rem;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.3s ease;
    border: none;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    text-transform: none;
    letter-spacing: normal;
}

#ai-document-dialog .btn-secondary {
    background: rgba(255, 255, 255, 0.04);
    color: rgba(255, 255, 255, 0.7);
    border: 1px solid rgba(255, 255, 255, 0.08);
}

#ai-document-dialog .btn-secondary:hover {
    background: rgba(255, 255, 255, 0.08);
    color: rgba(255, 255, 255, 0.9);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

#ai-document-dialog .btn-primary {
    /* Opaque CTA gradient — was rgba(...0.2) translucent and read as a
       muted secondary, indistinguishable from the actual secondary
       button next to it. The primary action in the dialog needs visual
       weight; this gradient matches the header "Generate Document" CTA
       so users see the same affordance in both surfaces. */
    background: linear-gradient(135deg, var(--ws-accent-indigo) 0%, var(--ws-accent) 100%);
    color: white;
    border: 1px solid rgba(0, 242, 254, 0.6);
    box-shadow: 0 4px 20px rgba(0, 242, 254, 0.25), 0 2px 6px rgba(0, 0, 0, 0.3);
    position: relative;
    overflow: hidden;
}

#ai-document-dialog .btn-primary:hover:not(:disabled) {
    background: linear-gradient(135deg, var(--ws-accent-indigo) 0%, var(--ws-accent) 100%);
    transform: translateY(-2px);
    box-shadow: 0 8px 28px rgba(0, 242, 254, 0.40), 0 4px 12px rgba(0, 0, 0, 0.35);
    border-color: rgba(0, 242, 254, 0.85);
}

#ai-document-dialog .btn-primary:active:not(:disabled) {
    transform: translateY(0);
}

#ai-document-dialog .btn-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

#ai-document-dialog .btn i {
    font-size: 16px;
}

/* @keyframes fadeIn and spin defined in design-system.css */

@keyframes premiumModalIn {
    from {
        transform: translateY(30px) scale(0.95);
        opacity: 0;
    }
    to {
        transform: translateY(0) scale(1);
        opacity: 1;
    }
}

@keyframes premiumModalOut {
    from {
        transform: translateY(0) scale(1);
        opacity: 1;
    }
    to {
        transform: translateY(-15px) scale(0.97);
        opacity: 0;
    }
}

/* ===================================
   PART 3: COMING SOON COMPONENTS
   =================================== */

html body .nav-item-coming-soon {
    position: relative;
    opacity: 0.7;
    cursor: not-allowed;
    pointer-events: none;
}

.nav-item-content {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.nav-coming-soon-badge {
    position: absolute;
    top: 8px;
    right: 12px;
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.6) 0%, rgba(118, 75, 162, 0.6) 100%);
    color: white;
    font-size: 8px;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
    z-index: var(--z-dropdown, 100);
}

.nav-item-tooltip {
    position: absolute;
    left: 100%;
    top: 50%;
    transform: translateY(-50%);
    margin-left: 15px;
    background: linear-gradient(135deg, rgba(21, 26, 53, 0.98) 0%, rgba(30, 37, 64, 0.98) 100%);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 0.75rem;
    padding: 1rem 1.25rem;
    min-width: 280px;
    max-width: 320px;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    z-index: var(--z-tooltip, 1250);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    pointer-events: none;
}

.nav-item-coming-soon:hover .nav-item-tooltip {
    opacity: 1;
    visibility: visible;
    margin-left: 20px;
}

.nav-item-tooltip strong {
    display: block;
    color: rgba(0, 242, 254, 0.7);
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 0.5rem;
    letter-spacing: 0.3px;
}

.nav-item-tooltip p {
    color: rgba(255, 255, 255, 0.85);
    font-size: 13px;
    line-height: 1.6;
    margin: 0;
}

.nav-item-tooltip::before {
    content: '';
    position: absolute;
    left: -8px;
    top: 50%;
    transform: translateY(-50%);
    width: 0;
    height: 0;
    border-top: 8px solid transparent;
    border-bottom: 8px solid transparent;
    border-right: 8px solid rgba(255, 255, 255, 0.08);
}

.coming-soon-badge {
    position: absolute;
    top: -8px;
    right: -8px;
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.6) 0%, rgba(118, 75, 162, 0.6) 100%);
    color: white;
    font-size: 10px;
    font-weight: 600;
    padding: 3px 8px;
    border-radius: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
    z-index: var(--z-dropdown, 100);
}

/* (pulse-glow @keyframes removed — defined but unreferenced) */

html body .document-ai-panel-coming-soon {
    display: flex;
    width: 300px;
    min-width: 300px;
    flex-shrink: 0;
    background: var(--doc-gradient-card);
    border-left: 1px solid var(--doc-glass-border);
    border-radius: 0;
    backdrop-filter: blur(24px) saturate(1.3);
    -webkit-backdrop-filter: blur(24px) saturate(1.3);
    box-shadow:
        -4px 0 16px rgba(0, 0, 0, 0.15),
        -1px 0 3px rgba(0, 0, 0, 0.1),
        inset 1px 0 0 rgba(255, 255, 255, 0.03);
    overflow: hidden;
    position: relative;
}

.coming-soon-badge-top {
    position: absolute;
    top: 16px;
    right: 16px;
    background: linear-gradient(135deg, rgba(118, 75, 162, 0.3) 0%, rgba(0, 242, 254, 0.2) 100%);
    color: rgba(255, 255, 255, 0.85);
    font-size: 9px;
    font-weight: 600;
    padding: 4px 10px;
    border-radius: 2rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    border: 1px solid rgba(0, 242, 254, 0.15);
    box-shadow: 0 2px 12px rgba(0, 242, 254, 0.1);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: var(--z-dropdown, 100);
    display: inline-block;
}

.document-ai-panel-coming-soon::before {
    z-index: var(--z-base, 1);
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: 
        radial-gradient(ellipse at 30% 20%, rgba(0, 242, 254, 0.04) 0%, transparent 50%),
        radial-gradient(ellipse at 70% 80%, rgba(118, 75, 162, 0.05) 0%, transparent 50%);
    pointer-events: none;
}



.coming-soon-container {
    width: 100%;
    padding: 3rem 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    z-index: var(--z-base, 1);
}

.coming-soon-content {
    text-align: center;
    max-width: 400px;
}

.coming-soon-icon {
    font-size: 4rem;
    background: linear-gradient(135deg, rgba(0, 242, 254, 0.7) 0%, rgba(118, 75, 162, 0.6) 50%, rgba(240, 147, 251, 0.5) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 1.5rem;
    animation: float 4s ease-in-out infinite;
}

/* (iconGlow @keyframes removed — defined with both stops as no-op `filter: none` and unreferenced) */

/* @keyframes float — local fallback so this animation works even when
 * shared-crypto.css is not loaded (e.g. user role that doesn't include
 * crypto features, or load-order drift). If shared-crypto.css IS loaded
 * its definition supersedes this one harmlessly. */
@keyframes float {
    0%, 100% { transform: translateY(0); }
    50%      { transform: translateY(-10px); }
}

.coming-soon-title {
    font-size: 1.5rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--ws-text) 0%, var(--doc-accent-cyan) 50%, var(--doc-accent-purple) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 0.75rem;
    letter-spacing: -0.3px;
}

.coming-soon-description {
    font-size: 0.9rem;
    color: rgba(255, 255, 255, 0.45);
    line-height: 1.65;
    margin-bottom: 1.75rem;
}

.coming-soon-features {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-bottom: 2rem;
}

.feature-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(0, 242, 254, 0.06);
    border-radius: 0.75rem;
    color: rgba(255, 255, 255, 0.7);
    font-size: 0.85rem;
    font-weight: 500;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.feature-item::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(0, 242, 254, 0.06), rgba(255, 255, 255, 0.06), rgba(0, 242, 254, 0.06), transparent);
    transition: left 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.feature-item:hover::before {
    left: 100%;
}

.feature-item:hover {
    background: rgba(0, 242, 254, 0.04);
    border-color: rgba(0, 242, 254, 0.15);
    transform: translateX(6px) scale(1.01);
    box-shadow: 0 2px 16px rgba(0, 0, 0, 0.15), 0 0 20px rgba(0, 242, 254, 0.06);
}

.feature-item i {
    color: rgba(0, 242, 254, 0.45);
    font-size: 1rem;
}

.coming-soon-badge-large {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.625rem 1.5rem;
    background: linear-gradient(135deg, rgba(118, 75, 162, 0.25) 0%, rgba(0, 242, 254, 0.15) 100%);
    color: rgba(255, 255, 255, 0.85);
    font-size: 0.85rem;
    font-weight: 700;
    border-radius: 2rem;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    border: 1px solid rgba(0, 242, 254, 0.15);
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.2);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

/* (pulse-badge @keyframes removed — defined but unreferenced) */

.coming-soon-badge-large i {
    animation: rocket 1.5s ease-in-out infinite;
}

@keyframes rocket {
    0%, 100% {
        transform: translateY(0px) rotate(-45deg);
    }
    50% {
        transform: translateY(-5px) rotate(-45deg);
    }
}

/* ===================================
   PART 4: WORKSPACE DOCUMENTS VIEW OVERRIDES
   =================================== */

#documents-view,
#documents-view.documents-view {
    position: relative;
    top: auto;
    left: auto;
    right: auto;
    bottom: auto;
    width: 100%;
    height: auto;
    min-height: calc(100vh - 120px);
}

/* Visibility: #documents-view.is-hidden defined in workspace/workspace.css */

#documents-view .document-writer-container {
    height: 100%;
    width: 100%;
    display: flex;
    flex-direction: column;
}

/* ========== Quality flags warning banner (Phase 4) ========== */
/* Appears above the editor/preview when the writer service returned
   document.quality_flags (citations_unavailable, sections_unavailable,
   research_unavailable). Gives users a clear amber signal that the
   document shipped with known limitations. */

.quality-warning-banner {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 12px 16px;
    margin: 0 0 12px 0;
    background: linear-gradient(
        135deg,
        rgba(251, 191, 36, 0.08),
        rgba(251, 191, 36, 0.03)
    );
    border: 1px solid rgba(251, 191, 36, 0.3);
    border-left: 3px solid rgba(251, 191, 36, 0.8);
    border-radius: 0.5rem;
    color: rgba(254, 243, 199, 0.95);
    font-size: 0.9rem;
    line-height: 1.5;
}
.quality-warning-banner.is-hidden {
    display: none;
}
.quality-warning-banner .qfb-icon {
    flex-shrink: 0;
    color: rgba(251, 191, 36, 0.9);
    font-size: 1.1rem;
    padding-top: 2px;
}
.quality-warning-banner .qfb-body {
    flex: 1;
    min-width: 0;
}
.quality-warning-banner .qfb-title {
    font-weight: 600;
    color: rgba(254, 243, 199, 1);
    margin-bottom: 6px;
}
.quality-warning-banner .qfb-list {
    margin: 0;
    padding-left: 18px;
    list-style: disc;
}
.quality-warning-banner .qfb-list li {
    margin: 2px 0;
}
.quality-warning-banner .qfb-flag {
    background: rgba(251, 191, 36, 0.12);
    color: rgba(254, 243, 199, 1);
    padding: 1px 6px;
    border-radius: 0.25rem;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.8em;
    border: 1px solid rgba(251, 191, 36, 0.25);
}
.quality-warning-banner .qfb-dismiss {
    flex-shrink: 0;
    background: transparent;
    border: none;
    color: rgba(254, 243, 199, 0.6);
    font-size: 1.4rem;
    line-height: 1;
    cursor: pointer;
    /* WCAG 2.5.5 Target Size: ≥44×44px touch target. The previous
     * `padding: 0 4px` produced ~22×22px which is below the AA minimum
     * for touch / fat-finger interaction. Padding inflates the hit area;
     * negative margin keeps the visual position unchanged. */
    padding: 12px;
    min-width: 44px;
    min-height: 44px;
    margin: -12px;
    transition: color 0.15s ease;
}
.quality-warning-banner .qfb-dismiss:hover {
    color: rgba(254, 243, 199, 1);
}

/* ========== Structured sources panel (Phase 4) ========== */
/* Collapsible <details> panel below the editor/preview that lists
   every source returned by the writer's sources array. Native
   <details> means it can't overlap content (the previous sources
   pills panel was removed for exactly that reason). */

.sources-panel {
    margin: 16px 0 24px 0;
    background: linear-gradient(
        135deg,
        rgba(118, 75, 162, 0.04),
        rgba(0, 242, 254, 0.03)
    );
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 0.75rem;
    overflow: hidden;
    color: var(--doc-text-primary);
}
.sources-panel.is-hidden {
    display: none;
}
.sources-panel-summary {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    cursor: pointer;
    user-select: none;
    list-style: none;
    font-size: 0.95rem;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.9);
    transition: background 0.15s ease;
}
.sources-panel-summary::-webkit-details-marker {
    display: none;
}
.sources-panel-summary:hover {
    background: rgba(255, 255, 255, 0.03);
}
.sources-panel-icon {
    color: rgba(0, 242, 254, 0.8);
    font-size: 0.9rem;
}
.sources-panel-label {
    flex: 0 0 auto;
}
.sources-panel-count {
    flex: 0 0 auto;
    background: rgba(0, 242, 254, 0.12);
    color: rgba(0, 242, 254, 0.95);
    border: 1px solid rgba(0, 242, 254, 0.25);
    padding: 1px 8px;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 700;
    font-family: 'JetBrains Mono', monospace;
}
.sources-panel-chevron {
    margin-left: auto;
    color: rgba(255, 255, 255, 0.4);
    font-size: 0.75rem;
    transition: transform 0.2s ease;
}
.sources-panel[open] .sources-panel-chevron {
    transform: rotate(180deg);
}
/* When the panel is open, cap height + scroll. A research doc can return
 * 20+ sources; without this the list pushes everything below it off-screen
 * and the user can't see the editor footer / stats. */
.sources-panel[open] {
    max-height: 400px;
    overflow-y: auto;
}
.sources-panel-list {
    list-style: decimal;
    margin: 0;
    padding: 0 16px 16px 42px;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    padding-top: 14px;
}
.sources-panel-item {
    margin: 10px 0;
    padding: 6px 0;
    color: rgba(255, 255, 255, 0.85);
}
.sources-panel-item::marker {
    color: rgba(0, 242, 254, 0.7);
    font-weight: 700;
    font-family: 'JetBrains Mono', monospace;
}
.sources-panel-link {
    color: rgba(0, 242, 254, 0.9);
    text-decoration: none;
    font-weight: 500;
    line-height: 1.4;
    display: inline-block;
    transition: color 0.15s ease;
}
.sources-panel-link:hover {
    color: rgba(118, 75, 162, 1);
    text-decoration: underline;
}
.sources-panel-meta {
    margin-top: 4px;
    font-size: 0.8rem;
    color: rgba(255, 255, 255, 0.45);
}
.sources-panel-meta-author {
    font-weight: 600;
    color: rgba(255, 255, 255, 0.6);
}
.sources-panel-meta-section {
    font-style: italic;
    color: rgba(0, 242, 254, 0.6);
}

/* ========== Export buttons compact styling (Phase 4) ========== */
/* The Copy MD / Copy HTML / Print buttons sit in the header alongside
   Preview and Save. The header row is flex-wrap: nowrap, so with the
   full "Copy MD" / "Copy HTML" / "Print" labels the row overflows and
   overlaps neighbouring buttons on normal-width screens. Drop the
   visible labels entirely (tooltips on the <button title="..."> still
   give users affordance on hover) and tighten padding so each button
   becomes an icon chip rather than a wide pill. */

#copy-markdown-btn .btn-label,
#copy-html-btn .btn-label,
#print-document-btn .btn-label {
    display: none;
}
#copy-markdown-btn,
#copy-html-btn,
#print-document-btn {
    padding: 0.6rem 0.75rem;
}

/* ========== Print stylesheet (Phase 4) ========== */
/* Strip every UI chrome element when the user prints the page so
   they get a clean, readable document on paper. The JS print handler
   ensures the preview pane is populated and visible before calling
   window.print(); this stylesheet then hides everything except the
   preview content and converts the dark theme to a high-contrast
   light theme suitable for ink. */

/* `@page` MUST sit at the top level of the stylesheet. Safari \u226415
   silently ignores `@page` rules nested inside `@media print { \u2026 }`,
   which strips the controlled page margins and lets the browser default
   (varies by user setting) take over. Hoisting it outside `@media print`
   guarantees consistent margins across browsers. */
@page {
    margin: 1.5cm 1.8cm;
}

@media print {
    /* Kill the dark background \u2014 printers and reader apps expect
       white paper. */
    html, body {
        background: white !important;
        color: #000 !important;
    }

    /* Apply print-color-adjust to the entire preview pane container too,
       not just .preview-content. The legacy direct-print path (Ctrl+P
       without opening the modal) prints #preview-pane directly; without
       this rule Chrome strips the pane's background and any pseudo-element
       tinting before sending to the printer/PDF engine. */
    #preview-pane {
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }
    .document-header,
    .mobile-save-indicator,
    .mobile-overflow-btn,
    .editor-toolbar,
    .editor-footer,
    .editor-sidebar,
    .smart-editor-panel,
    .doc-mobile-menu-toggle,
    #quality-flags-banner,
    .markdown-editor,
    .sources-panel-summary .sources-panel-chevron,
    .workspace-sidebar,
    .workspace-navbar,
    .workspace-header {
        display: none !important;
    }

    /* Force the preview pane visible even when the editor was the
       active view \u2014 the JS handler toggles this at runtime, but
       the stylesheet is the safety net. */
    #preview-pane,
    #preview-pane.is-hidden {
        display: block !important;
        position: static !important;
        width: 100% !important;
        max-width: 100% !important;
        height: auto !important;
        overflow: visible !important;
        padding: 0 !important;
        background: white !important;
    }

    /* Preview content: light theme but PRESERVES the preview's premium feel
       (typography scale, generous line-height, brand cyan as accent). This
       block was previously aggressive about stripping styling for "print-
       safety"; the result was a black-and-white doc that bore no resemblance
       to the on-screen preview the user just authored. We can keep brand
       identity AND be ink-friendly — modern colour laser/inkjet handles
       light cyan tints just fine, and screen colour intent is to be
       *suggested* in print, not surgically removed.

       `print-color-adjust: exact` (and the legacy -webkit- prefix) asks the
       browser to honour background colours instead of stripping them as
       a "save ink" optimisation. Critical for the metadata header pill. */
    .preview-content,
    .preview-content * {
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }
    .preview-content {
        max-width: 100% !important;
        margin: 0 !important;
        padding: 0 !important;
        color: #1a1a1a !important;
        background: white !important;
        /* 12pt + 1.75 line-height matches the preview's 18px/1.8 ratio at
           A4/Letter widths — readable, with breathing room. */
        font-size: 12pt !important;
        line-height: 1.75 !important;
    }

    /* Sources panel: always expanded, visible, light-themed. */
    .sources-panel {
        background: white !important;
        border: 1px solid #888 !important;
        color: #111 !important;
        page-break-inside: avoid;
    }
    .sources-panel[open],
    .sources-panel {
        /* force open so collapsed state doesn't hide sources */
        padding-bottom: 8px !important;
    }
    .sources-panel-list {
        display: block !important;
        border-top: 1px solid #888 !important;
        color: #111 !important;
    }
    .sources-panel-link {
        color: #0645ad !important;
    }
    .sources-panel-summary {
        color: #000 !important;
    }
    .sources-panel-count {
        background: #e8e8e8 !important;
        color: #000 !important;
        border-color: #888 !important;
    }

    /* ---- Print preview modal scoping ----
       When the print-preview modal is open, the user has explicitly
       opted into the curated paper canvas. Hide every workspace
       chrome element AND the modal's own controls, leaving only the
       `.print-preview-paper` content visible. The existing chrome-
       hiding rules above still apply for the legacy direct Ctrl+P
       path. */
    body.is-print-preview-active .workspace-sidebar,
    body.is-print-preview-active .workspace-navbar,
    body.is-print-preview-active .workspace-header,
    body.is-print-preview-active .ambient-background,
    body.is-print-preview-active .floating-nav,
    body.is-print-preview-active #ai-document-dialog,
    body.is-print-preview-active .toast-container,
    body.is-print-preview-active #documents-view {
        display: none !important;
    }
    body.is-print-preview-active .print-preview-modal {
        position: static !important;
        background: white !important;
        display: block !important;
        padding: 0 !important;
        margin: 0 !important;
        height: auto !important;
        overflow: visible !important;
    }
    body.is-print-preview-active .print-preview-modal .print-preview-header,
    body.is-print-preview-active .print-preview-modal .print-preview-actions {
        display: none !important;
    }
    body.is-print-preview-active .print-preview-modal .print-preview-body {
        position: static !important;
        background: white !important;
        padding: 0 !important;
        margin: 0 !important;
        height: auto !important;
        overflow: visible !important;
    }
    body.is-print-preview-active .print-preview-modal .print-preview-paper {
        position: static !important;
        width: 100% !important;
        max-width: 100% !important;
        margin: 0 !important;
        padding: 0 !important;
        background: white !important;
        box-shadow: none !important;
        border: none !important;
        border-radius: 0 !important;
        min-height: 0 !important;
    }
}

/* ============================================================================
   Active task cards (yellow / green / red states)
   ============================================================================
   Rendered above the saved-docs list in #recent-documents-list. State is
   conveyed through both an accent border-left and an icon so colour alone
   isn't the only cue (WCAG 1.4.1).
   - is-generating  = yellow  = AI generation in progress
   - is-completed   = green   = saved to DB, awaiting user to open it
   - is-failed      = red     = task failed; user can dismiss / regenerate
   ============================================================================ */
.active-task-cards {
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.active-task-cards.is-empty {
    /* Don't reserve list space when no tasks are running. */
    display: none;
}

/* Dismiss-X focus ring on red/green cards. */
.doc-task-dismiss:focus-visible {
    outline: 2px solid var(--color-error);
    outline-offset: 2px;
    background: rgba(239, 68, 68, 0.15);
}

/* State icons */
.doc-task-icon {
    margin-right: 8px;
    font-size: 0.95rem;
    vertical-align: -1px;
}

.task-topic {
    font-weight: 500;
}
.task-stage,
.task-ready,
.task-error {
    font-size: 0.78rem;
    /* 0.85 alpha for AA contrast against the tinted card backgrounds.
       At 0.7 the small text fell into WCAG borderline (~4.8:1). */
    color: rgba(224, 230, 237, 0.85);
}
.task-error {
    color: rgba(254, 202, 202, 0.95);
}
/* Live 10-minute countdown on the yellow (generating) card. margin-left:auto
   pushes it to the right edge of the .document-meta row — and since the
   generating card has no .document-actions, that edge is the card's right
   edge, so the timer sits bottom-right. Tabular figures keep it from
   shifting width as the digits change. */
.task-countdown {
    margin-left: auto;
    font-size: 0.78rem;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    letter-spacing: 0.5px;
    color: var(--doc-accent-cyan, var(--ws-accent));
    white-space: nowrap;
}
/* Inline "Generation started" panel that briefly replaces the AI dialog
   body before the modal closes — gives the user a prominent confirmation
   instead of just a corner toast. */
.ai-dialog-success-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 36px 32px 24px;
    min-height: 220px;
    animation: aiDialogSuccessIn 240ms cubic-bezier(0.4, 0, 0.2, 1);
}
.ai-dialog-success-state.is-hidden {
    display: none !important;
}
.ai-dialog-success-icon {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: radial-gradient(circle at 30% 30%,
        rgba(16, 185, 129, 0.35) 0%,
        rgba(16, 185, 129, 0.12) 60%,
        rgba(16, 185, 129, 0) 100%);
    box-shadow:
        0 0 0 4px rgba(16, 185, 129, 0.15),
        0 8px 28px rgba(16, 185, 129, 0.25);
    color: var(--color-success);
    font-size: 1.6rem;
    margin-bottom: 16px;
    animation: aiDialogSuccessIcon 360ms cubic-bezier(0.34, 1.56, 0.64, 1);
}
.ai-dialog-success-title {
    margin: 0 0 8px;
    font-size: 1.15rem;
    font-weight: 600;
    color: var(--doc-text-primary, var(--ws-text-secondary));
    letter-spacing: -0.01em;
}
.ai-dialog-success-body {
    margin: 0;
    font-size: 0.92rem;
    line-height: 1.55;
    color: rgba(224, 230, 237, 0.7);
    max-width: 420px;
}
@keyframes aiDialogSuccessIn {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
}
@keyframes aiDialogSuccessIcon {
    0%   { transform: scale(0.4); opacity: 0; }
    60%  { transform: scale(1.15); opacity: 1; }
    100% { transform: scale(1); }
}
@media (prefers-reduced-motion: reduce) {
    .ai-dialog-success-state,
    .ai-dialog-success-icon {
        animation: none !important;
    }
}

/* ── Generating / Ready / Failed dialog panel variants ────────────────────
   All three render into the shared .ai-dialog-success-state container. The
   generating panel adds explore links + a live countdown; the failed panel
   recolors the icon. */

/* Generating icon: swap the green success gradient for the brand button
   gradient so a spinner reads as "in progress", not "done". */
.ai-dialog-generating-icon {
    background: radial-gradient(circle at 30% 30%,
        rgba(123, 104, 238, 0.38) 0%,
        rgba(0, 242, 254, 0.14) 60%,
        rgba(0, 242, 254, 0) 100%);
    box-shadow:
        0 0 0 4px rgba(123, 104, 238, 0.15),
        0 8px 28px rgba(0, 242, 254, 0.22);
    color: var(--doc-accent-cyan, var(--ws-accent));
}

/* Failed icon: danger tint. */
.ai-dialog-failed-icon {
    background: radial-gradient(circle at 30% 30%,
        rgba(239, 68, 68, 0.35) 0%,
        rgba(239, 68, 68, 0.12) 60%,
        rgba(239, 68, 68, 0) 100%);
    box-shadow:
        0 0 0 4px rgba(239, 68, 68, 0.15),
        0 8px 28px rgba(239, 68, 68, 0.25);
    color: var(--doc-danger-text, var(--ws-danger-text));
}

/* "Explore other services" links shown while the document generates. */
.ai-dialog-explore-links {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
    margin: 18px 0 4px;
}
.ai-dialog-explore-link {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 44px;
    padding: 10px 18px;
    border-radius: 999px;
    border: 1px solid var(--doc-glass-border, rgba(255, 255, 255, 0.08));
    background: rgba(255, 255, 255, 0.04);
    color: var(--doc-text-secondary, rgba(255, 255, 255, 0.87));
    font-size: 0.9rem;
    font-weight: 600;
    text-decoration: none;
    transition: background 160ms ease, border-color 160ms ease, color 160ms ease, transform 160ms ease;
}
.ai-dialog-explore-link i {
    color: var(--doc-accent-cyan, var(--ws-accent));
    font-size: 0.95rem;
}
.ai-dialog-explore-link:hover {
    background: rgba(123, 104, 238, 0.16);
    border-color: rgba(123, 104, 238, 0.45);
    color: var(--ws-text);
    transform: translateY(-1px);
}
.ai-dialog-explore-link:focus-visible {
    outline: 2px solid var(--doc-accent-cyan, var(--ws-accent));
    outline-offset: 2px;
}

/* Big live countdown beneath the explore links. */
.ai-dialog-countdown {
    margin-top: 18px;
    font-size: 2.1rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    letter-spacing: 0.5px;
    line-height: 1;
    color: var(--doc-text-primary, var(--ws-text));
}
.ai-dialog-countdown-caption {
    margin: 6px 0 0;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--doc-text-muted, rgba(255, 255, 255, 0.6));
}

/* Terminal-state action row (Open document / Try again / Close). */
.ai-dialog-ready-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
    margin-top: 20px;
}

/* Reduced motion: kill the spinner on the generating icon (numbers still
   tick — that's text content, not animation). */
@media (prefers-reduced-motion: reduce) {
    .ai-dialog-generating-icon .fa-spin {
        animation: none !important;
    }
}

/* The dismiss X on red/green cards reuses the .doc-action-btn shape
   but with a tinted hover so the affordance reads as destructive. */
.doc-task-dismiss:hover {
    background: rgba(239, 68, 68, 0.15);
    color: var(--ws-danger-text);
}

/* Respect reduced-motion: stop the spinner animation on yellow cards. */
@media (prefers-reduced-motion: reduce) {
}

/* ============================================================================
   Print preview modal
   ============================================================================
   Full-screen overlay that previews the document on a paper-style canvas
   before printing. Triggered by the Print button; closed via Esc, the
   close X, or backdrop click. The actual printing happens via
   window.print() while body.is-print-preview-active is set \u2014 the @media
   print rules above scope output to .print-preview-paper.
   ============================================================================ */
.print-preview-modal {
    position: fixed;
    inset: 0;
    z-index: 10050;
    display: flex;
    flex-direction: column;
    background: rgba(6, 9, 24, 0.86);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    animation: ppmFadeIn 0.18s ease-out;
}
.print-preview-modal[aria-hidden="true"] {
    display: none;
}

@keyframes ppmFadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

.print-preview-header {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    /* `max()` with the safe-area inset keeps Close/Print clear of the iPhone
       notch / Dynamic Island. Falls back to 14px on devices without insets. */
    padding: max(14px, env(safe-area-inset-top, 0px)) max(22px, env(safe-area-inset-right, 0px)) 14px max(22px, env(safe-area-inset-left, 0px));
    background: rgba(20, 26, 48, 0.92);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.35);
}
.print-preview-header h2 {
    margin: 0;
    color: var(--ws-text-secondary);
    font-size: 1rem;
    font-weight: 600;
    letter-spacing: -0.2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 60%;
}
.print-preview-actions {
    display: flex;
    gap: 10px;
    align-items: center;
}
/* Keep Print + Close from shrinking when the document title is long;
   the h2 already truncates with ellipsis via overflow:hidden. */
.print-preview-actions > button {
    flex-shrink: 0;
}

.print-preview-body {
    flex: 1 1 auto;
    overflow: auto;
    padding: 32px;
    display: flex;
    justify-content: center;
    align-items: flex-start;
}

.print-preview-paper {
    width: 100%;
    max-width: 820px;
    min-height: calc(11in - 64px);
    background: white;
    color: #1a1a1a;
    padding: 64px 72px;
    box-shadow:
        0 4px 24px rgba(0, 0, 0, 0.45),
        0 0 0 1px rgba(255, 255, 255, 0.04);
    border-radius: 4px;
    /* Faint horizontal page-break indicators every ~11in so the user
       gets a sense of where pages will split. The line sits 3px above
       the implied page edge so it doesn't visually collide with the
       paper's bottom border on a single-page document. */
    background-image: repeating-linear-gradient(
        to bottom,
        transparent 0,
        transparent calc(11in - 4px),
        rgba(0, 0, 0, 0.08) calc(11in - 4px),
        rgba(0, 0, 0, 0.08) calc(11in - 3px),
        transparent calc(11in - 3px),
        transparent 11in
    );
}

/* The paper's .preview-content reuses the existing on-screen preview
   styling so the user sees what they're about to print, exactly. */
.print-preview-paper .preview-content {
    color: #1a1a1a;
    font-size: 12pt;
    line-height: 1.75;
    /* A sheet of A4 is not a screen reading column: the 68ch measure .pm-prose
       gives the on-screen preview would leave a third of the page blank. */
    max-width: 100%;
}

/* Small-screen + reduced-motion fall-backs */
@media (max-width: 720px) {
    .print-preview-body { padding: 14px; }
    .print-preview-paper { padding: 24px 18px; min-height: 0; }
    .print-preview-header h2 { font-size: 0.92rem; max-width: 50%; }
}
@media (prefers-reduced-motion: reduce) {
    .print-preview-modal { animation: none; }
}

/* Visually-hidden utility for off-screen text that screen readers
   should still announce. Used by #task-announce (the polite live
   region for generation state transitions) and any future a11y
   announcements. Standard pattern; no other .sr-only exists at
   workspace scope. */
.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;
}

#documents-view .document-header {
    flex-shrink: 0;
}

#documents-view .document-main {
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

body.documents-mode #documents-view {
    display: flex;
}

/* Hide workspace help hint in documents mode to prevent overlap */
body.documents-mode .workspace-help-hint {
    display: none;
}

/* ===================================
   RESPONSIVE ADJUSTMENTS (Mobile)
   =================================== */

@media screen and (max-width: 767px) {
    .coming-soon-container {
        padding: 2rem 1.5rem;
    }
    
    .coming-soon-icon {
        font-size: 3rem;
        margin-bottom: 1rem;
    }
    
    .coming-soon-title {
        font-size: 1.5rem;
        margin-bottom: 0.75rem;
    }
    
    .coming-soon-description {
        font-size: 0.9rem;
        margin-bottom: 1.5rem;
    }
    
    .coming-soon-features {
        gap: 0.5rem;
        margin-bottom: 1.5rem;
    }
    
    .feature-item {
        padding: 0.5rem 0.75rem;
        font-size: 0.85rem;
    }
    
    .coming-soon-badge-large {
        padding: 0.5rem 1rem;
        font-size: 0.85rem;
    }
    
    .coming-soon-badge {
        font-size: 9px;
        padding: 2px 6px;
    }

    #ai-document-dialog.modal-overlay {
        padding: 20px 15px;
    }

    #ai-document-dialog .modal-container {
        max-width: 100%;
        width: 100%;
        max-height: calc(100vh - 40px);
        max-height: calc(100svh - 40px);
    }

    #ai-document-dialog .modal-header {
        padding: 20px;
    }

    #ai-document-dialog .modal-header h2 {
        font-size: 18px;
    }

    #ai-document-dialog .modal-body {
        padding: 20px;
    }

    #ai-document-dialog .form-row {
        grid-template-columns: 1fr;
        gap: 0;
    }

    #ai-document-dialog .modal-footer {
        padding: 16px 20px;
        flex-direction: column;
        gap: 10px;
    }

    #ai-document-dialog .btn {
        width: 100%;
        justify-content: center;
    }
}

@media (max-width: 480px) {
    #ai-document-dialog.modal-overlay {
        padding: 10px;
    }
    
    #ai-document-dialog .modal-container {
        max-height: calc(100vh - 20px);
        max-height: calc(100svh - 20px);
    }

    #ai-document-dialog .modal-header {
        padding: 16px;
    }

    #ai-document-dialog .modal-body {
        padding: 16px;
    }

    #ai-document-dialog .modal-footer {
        padding: 12px 16px;
    }
}

@media screen and (min-width: 768px) {
    .document-ai-panel-coming-soon {
        min-height: 500px;
    }
}

/* ========================================
   18. REDUCED-MOTION & ACCESSIBILITY GUARDS
   ======================================== */

@media (prefers-reduced-motion: reduce) {
    /* Disable all ambient / looping animations */
    .documents-view,
    .document-header::after,
    .editor-footer::before,
    .document-ai-panel::before,
    .preview-pane::before,
    .markdown-editor:focus,
    .doc-tab-btn.active,
    .save-indicator.saving .save-dot::after,
    .save-indicator.saving .save-dot,
    .sidebar-brand-icon,
    .storage-bar-fill,
    .document-title-input:focus,
    .document-writer-container::before,
    .document-writer-container::after,
    .editor-container::before,
    .editor-content::before,
    .editor-content::after,
    .preview-pane::after,
    .storage-bar-fill::after,
    .sidebar-brand-icon::before,
    .sidebar-brand-text .sidebar-title{
        animation: none !important;
    }

    /* Remove grain overlay */
    .documents-view::before {
        display: none !important;
    }
    .toolbar-btn,
    .feature-item,
    .ai-action-btn,
    .sidebar-brand-icon,
    .storage-bar-fill,
    .doc-tab-btn,
    .document-search input{
        transition-duration: 0.01ms !important;
    }

    /* Disable new onboarding animations */
    .ai-coach-mark,
    .coach-mark-fade-out {
        animation: none !important;
    }

    .empty-state-card,
    .doc-btn-ai {
        transition-duration: 0.01ms !important;
    }

    /* (in-dialog progress-bar reduced-motion override removed 2026-05-12;
       generation no longer renders progress inside the dialog. Task-card
       reduced-motion rules live alongside the cards themselves.) */
}



/* ========================================
   AI WRITE BUTTON
   ======================================== */
.doc-btn-ai {
    background: linear-gradient(135deg, rgba(123, 104, 238, 0.25) 0%, rgba(0, 242, 254, 0.2) 100%);
    color: var(--ws-text);
    border: 1px solid rgba(123, 104, 238, 0.35);
    font-weight: 700;
    box-shadow:
        0 2px 10px rgba(123, 104, 238, 0.15),
        inset 0 1px 0 rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    overflow: hidden;
    position: relative;
}

.doc-btn-ai::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(105deg, transparent 40%, rgba(255, 255, 255, 0.12) 50%, transparent 60%);
    transition: left 0.5s ease;
    pointer-events: none;
    z-index: 1;
}

.doc-btn-ai:hover::before {
    left: 100%;
}

.doc-btn-ai:hover {
    background: linear-gradient(135deg, rgba(123, 104, 238, 0.4) 0%, rgba(0, 242, 254, 0.3) 100%);
    border-color: rgba(123, 104, 238, 0.5);
    box-shadow:
        0 4px 16px rgba(123, 104, 238, 0.25),
        0 0 20px rgba(0, 242, 254, 0.1),
        inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

/* Allow coach mark tooltip to overflow the button */
.doc-btn-ai.has-coach-mark {
    overflow: visible;
}

.doc-btn-ai.has-coach-mark::before {
    display: none;
}

/* ========================================
   EMPTY STATE WELCOME
   ======================================== */
.document-empty-state {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
}

.empty-state-content {
    text-align: center;
    max-width: 640px;
}

.empty-state-icon {
    font-size: 3rem;
    color: rgba(0, 242, 254, 0.2);
    margin-bottom: 1.25rem;
}

.empty-state-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--ws-text);
    margin: 0 0 0.5rem;
    letter-spacing: -0.01em;
}

.empty-state-subtitle {
    font-size: 0.95rem;
    color: rgba(255, 255, 255, 0.5);
    margin: 0 0 2rem;
}

.empty-state-cards {
    display: flex;
    gap: 1.25rem;
    justify-content: center;
    flex-wrap: wrap;
}

.empty-state-card {
    flex: 1;
    min-width: 220px;
    max-width: 280px;
    padding: 1.75rem 1.5rem;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 1rem;
    cursor: pointer;
    text-align: center;
    transition: background 0.25s ease, border-color 0.25s ease, box-shadow 0.25s ease, transform 0.25s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
    color: inherit;
    font-family: inherit;
    font-size: inherit;
}

.empty-state-card:hover {
    background: rgba(255, 255, 255, 0.06);
    border-color: rgba(0, 242, 254, 0.2);
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.2), 0 0 30px rgba(0, 242, 254, 0.06);
    transform: translateY(-2px);
}

.empty-state-card:focus-visible {
    outline: 2px solid rgba(0, 242, 254, 0.6);
    outline-offset: 2px;
    border-color: rgba(0, 242, 254, 0.3);
}

/* Tactile press feedback — without :active the cards feel unresponsive
 * to the click that just hover-lifted them. */
.empty-state-card:active {
    transform: translateY(0);
    box-shadow: none;
    transition-duration: 0.08s;
}

.empty-card-icon {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.35rem;
}

.empty-card-icon-ai {
    background: linear-gradient(135deg, rgba(123, 104, 238, 0.2) 0%, rgba(0, 242, 254, 0.15) 100%);
    color: rgba(123, 104, 238, 0.9);
    border: 1px solid rgba(123, 104, 238, 0.2);
}

.empty-card-icon-blank {
    background: rgba(0, 242, 254, 0.08);
    color: rgba(0, 242, 254, 0.7);
    border: 1px solid rgba(0, 242, 254, 0.15);
}

.empty-card-title {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--ws-text);
    margin: 0;
}

.empty-card-desc {
    font-size: 0.82rem;
    color: rgba(255, 255, 255, 0.45);
    line-height: 1.5;
    margin: 0;
}

.empty-card-cta {
    font-size: 0.8rem;
    font-weight: 600;
    color: rgba(0, 242, 254, 0.7);
    margin-top: auto;
    display: flex;
    align-items: center;
    gap: 0.35rem;
    transition: color 0.2s ease;
}

.empty-state-card:hover .empty-card-cta {
    color: rgba(0, 242, 254, 1);
}

/* ========================================
   AI COACH MARK TOOLTIP
   ======================================== */
.ai-coach-mark {
    position: absolute;
    top: calc(100% + 10px);
    left: 50%;
    transform: translateX(-50%);
    background: linear-gradient(135deg, rgba(123, 104, 238, 0.9) 0%, rgba(88, 70, 200, 0.95) 100%);
    color: var(--ws-text);
    padding: 0.5rem 0.85rem;
    border-radius: 0.6rem;
    font-size: 0.78rem;
    font-weight: 600;
    white-space: nowrap;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3), 0 0 20px rgba(123, 104, 238, 0.2);
    z-index: 1000;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    animation: coachMarkEntry 0.4s ease-out;
    pointer-events: auto;
}

.ai-coach-mark::before {
    content: '';
    position: absolute;
    top: -6px;
    left: 50%;
    transform: translateX(-50%);
    border-left: 6px solid transparent;
    border-right: 6px solid transparent;
    border-bottom: 6px solid rgba(123, 104, 238, 0.9);
}

.coach-mark-text i {
    margin-right: 0.3rem;
}

.coach-mark-close {
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.7);
    font-size: 1rem;
    cursor: pointer;
    padding: 0 0 0 0.25rem;
    line-height: 1;
}

.coach-mark-close:hover {
    color: var(--ws-text);
}

.coach-mark-fade-out {
    animation: coachMarkExit 0.3s ease-in forwards;
}

@keyframes coachMarkEntry {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(6px);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

@keyframes coachMarkExit {
    from {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
    to {
        opacity: 0;
        transform: translateX(-50%) translateY(6px);
    }
}

@media (max-width: 520px) {
    .empty-state-cards {
        flex-direction: column;
        align-items: center;
    }
    .empty-state-card {
        max-width: 100%;
        min-width: 0;
    }
    .ai-coach-mark {
        font-size: 0.72rem;
        padding: 0.4rem 0.7rem;
    }
}
/* ========================================
   DOCUMENT SOURCE PILLS
   ======================================== */

.document-sources-panel {
    padding: 16px 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(0, 0, 0, 0.15);
    flex-shrink: 0;
    max-height: 120px;
    overflow-y: auto;
}

.document-sources-panel .sources-header {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: rgba(255, 255, 255, 0.6);
    margin-bottom: 12px;
}

.document-sources-panel .sources-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.doc-source-pill {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 500;
    text-decoration: none;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    backdrop-filter: blur(10px);
    cursor: pointer;
}

.doc-source-pill.orange {
    background: rgba(255, 152, 0, 0.12);
    border: 1px solid rgba(255, 152, 0, 0.3);
    color: var(--ws-warning);
}

.doc-source-pill.blue {
    background: rgba(33, 150, 243, 0.12);
    border: 1px solid rgba(33, 150, 243, 0.3);
    color: var(--ws-accent-blue);
}

.doc-source-pill.green {
    background: rgba(76, 175, 80, 0.12);
    border: 1px solid rgba(76, 175, 80, 0.3);
    color: var(--ws-success);
}

.doc-source-pill:hover {
    transform: translateY(-2px) scale(1.05);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
    filter: brightness(1.2);
}

.doc-source-pill i {
    font-size: 0.75rem;
    opacity: 0.8;
}

/* ========================================
   MOBILE STYLES
   ========================================
   All mobile-specific styles are in document-mobile.css
   which loads AFTER this file with higher specificity.
   DO NOT add mobile overrides here — they create
   z-index conflicts and value duplication.
   ======================================== */


/* ============================================================================
   PREMIUM SURFACES (workspace consistency pass)
   ----------------------------------------------------------------------------
   Brings the document writer onto the same visual language as chat. Typography
   for rendered markdown is NOT defined here — #preview-content carries .pm-prose
   and inherits the shared reading surface (css/shared/premium-components.css).
   This block only handles the surrounding chrome.
   ============================================================================ */

/* The preview is a reading surface: centred, generous, capped measure. */
/* `#documents-view .preview-pane` and `#documents-view .preview-content` used to
   live here — the calm pane and the 68ch measure, scoped to DOCUMENTS ONLY. The
   Hub carries the identical markup and got neither. Both are now unscoped (the
   .preview-pane rule above; the measure comes from .pm-prose), so the two
   editors read the same because they are literally the same rules. */

/* Generating panel inside the dialog */
#ai-document-dialog .ai-dialog-generating-icon {
    color: var(--ws-accent);
}

#ai-document-dialog .ai-dialog-countdown {
    font-variant-numeric: tabular-nums;
    color: var(--ws-text);
    letter-spacing: 0.02em;
}

#ai-document-dialog .ai-dialog-countdown-caption {
    color: var(--ws-text-subtle);
}

/* Empty state — the shared .pm-empty language. */
#documents-view .document-empty-state {
    background: var(--ws-bg-primary);
}

#documents-view .empty-state-card {
    background: var(--ws-glass-bg);
    border: 1px solid var(--ws-glass-border);
    border-radius: var(--ws-radius-lg);
    transition: border-color var(--ws-t-fast), background var(--ws-t-fast);
}

#documents-view .empty-state-card:hover {
    border-color: var(--ws-glass-border-hover);
    background: var(--ws-glass-hover);
}
