:root {
    /* === MATERIAL YOU (MD3) TONAL PALETTE - LIGHT === */
    --primary: #0b57d0;
    --on-primary: #ffffff;
    --primary-container: #d3e3fd;
    --on-primary-container: #041e49;
    
    --secondary: #00639b;
    --on-secondary: #ffffff;
    --secondary-container: #c2e7ff;
    --on-secondary-container: #001d35;
    
    --tertiary: #146c2e;
    --on-tertiary: #ffffff;
    --on-tertiary-container: #072711;
    
    --error: #b3261e;
    --on-error: #ffffff;
    --error-container: #f9dedc;
    --on-error-container: #410e0b;
    
    --background: #faf9fd;
    --on-background: #1a1c1e;
    
    --surface: #faf9fd;
    --on-surface: #1a1c1e;
    --surface-variant: #e1e2ec;
    --on-surface-variant: #44474e;
    
    --outline: #74777f;
    --outline-variant: rgba(68, 71, 78, 0.14);
    
    --surface-container-lowest: #ffffff;
    --surface-container-low: #f4f3f7;
    --surface-container: #eeedf1;
    --surface-container-high: #e8e7ec;
    --surface-container-highest: #e2e2e6;

    --floating-bar-bg: rgba(238, 237, 241, 0.86);
    --floating-bar-border: rgba(26, 28, 30, 0.08);
    --floating-bar-shadow: 0 12px 32px -4px rgba(11, 20, 38, 0.12), 0 4px 12px -2px rgba(11, 20, 38, 0.06);
    
    --radius-xs: 6px;
    --radius-s: 12px;
    --radius-m: 16px;
    --radius-l: 24px;
    --radius-xl: 32px;
    --radius-pill: 9999px;

    --ease-m3: cubic-bezier(0.2, 0.0, 0, 1.0);
    --ease-m3-decel: cubic-bezier(0.05, 0.7, 0.1, 1.0);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

html {
    scroll-behavior: smooth;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: 'Inter', 'Google Sans', 'Roboto', system-ui, -apple-system, sans-serif;
    background-color: var(--background);
    color: var(--on-background);
    min-height: 100dvh;
    padding: 0;
    display: flex;
    flex-direction: column;
    line-height: 1.5;
    transition: background-color 0.25s var(--ease-m3), color 0.25s var(--ease-m3);
    overflow-x: hidden;
}

.container {
    max-width: 1440px;
    width: 100%;
    margin: 0 auto;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
}

/* ===================================================== */
/* === MATERIAL YOU 120HZ FULLSCREEN LIGHTBOX        === */
/* ===================================================== */

.lightbox {
    display: none;
    position: fixed;
    inset: 0;
    width: 100vw;
    height: 100dvh;
    background: rgba(8, 8, 10, 0.96);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    z-index: 2000;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.2s var(--ease-m3);
    will-change: opacity;
}

.lightbox.active {
    opacity: 1;
}

.lightbox-top-bar {
    position: absolute;
    top: max(16px, env(safe-area-inset-top, 16px));
    left: 16px;
    right: 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    z-index: 20;
    pointer-events: none;
}

.lightbox-counter {
    pointer-events: auto;
    background: rgba(255, 255, 255, 0.12);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    color: #f4f4f6;
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 0.02em;
    padding: 8px 16px;
    border-radius: var(--radius-pill);
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.lightbox-content {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    padding: 64px 12px;
}

.media-container {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.media-container img,
.media-container video {
    max-width: 96vw;
    max-height: 82dvh;
    width: auto;
    height: auto;
    object-fit: contain;
    border-radius: var(--radius-m);
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
    transition: opacity 0.18s var(--ease-m3), transform 0.22s var(--ease-m3-decel);
    will-change: transform, opacity;
    user-select: none;
    -webkit-user-drag: none;
    touch-action: none;
}

.lightbox-animate-next-in {
    animation: lightboxSlideInRight 0.28s cubic-bezier(0.2, 0, 0, 1) forwards;
}

.lightbox-animate-prev-in {
    animation: lightboxSlideInLeft 0.28s cubic-bezier(0.2, 0, 0, 1) forwards;
}

.lightbox-animate-dismiss {
    animation: lightboxDismissDown 0.28s cubic-bezier(0.2, 0, 0, 1) forwards;
}

.lightbox-spring-reset {
    transition: transform 0.26s cubic-bezier(0.2, 0, 0, 1), opacity 0.26s cubic-bezier(0.2, 0, 0, 1) !important;
}

@keyframes lightboxSlideInRight {
    0% {
        transform: translate3d(70px, 0, 0) scale(0.92);
        opacity: 0;
    }
    100% {
        transform: translate3d(0, 0, 0) scale(1);
        opacity: 1;
    }
}

@keyframes lightboxSlideInLeft {
    0% {
        transform: translate3d(-70px, 0, 0) scale(0.92);
        opacity: 0;
    }
    100% {
        transform: translate3d(0, 0, 0) scale(1);
        opacity: 1;
    }
}

@keyframes lightboxDismissDown {
    0% {
        transform: translate3d(0, 0, 0) scale(1);
        opacity: 1;
    }
    100% {
        transform: translate3d(0, 80vh, 0) scale(0.85);
        opacity: 0;
    }
}

.nav-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.12);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    color: #ffffff;
    border: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 15;
    transition: background 0.18s var(--ease-m3), transform 0.18s var(--ease-m3);
}

.nav-btn:hover {
    background: rgba(255, 255, 255, 0.22);
    transform: translateY(-50%) scale(1.06);
}

.nav-btn:active {
    transform: translateY(-50%) scale(0.94);
}

.nav-btn .material-icons {
    font-size: 28px;
}

.prev-btn { left: 16px; }
.next-btn { right: 16px; }

.close-btn {
    pointer-events: auto;
    color: #ffffff;
    background: rgba(255, 255, 255, 0.12);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    width: 44px;
    height: 44px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    border: 1px solid rgba(255, 255, 255, 0.1);
    transition: background 0.18s var(--ease-m3), transform 0.18s var(--ease-m3);
}

.close-btn:hover {
    background: rgba(255, 255, 255, 0.22);
}

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

.lightbox-top-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    pointer-events: auto;
}

.lightbox-action-pill {
    pointer-events: auto;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 40px;
    padding: 0 15px;
    border-radius: var(--radius-pill);
    background: rgba(255, 255, 255, 0.14);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    color: #ffffff;
    font-family: inherit;
    font-size: 13px;
    font-weight: 600;
    text-decoration: none;
    border: 1px solid rgba(255, 255, 255, 0.12);
    cursor: pointer;
    transition: background 0.18s var(--ease-m3), transform 0.16s var(--ease-m3);
}

.lightbox-action-pill:hover {
    background: rgba(255, 255, 255, 0.25);
}

.lightbox-action-pill .material-icons {
    font-size: 18px;
}

/* ===================================================== */
/* === MATERIAL YOU PHOTO EDITOR STUDIO MODAL        === */
/* ===================================================== */

.photo-editor-modal {
    position: fixed;
    inset: 0;
    width: 100vw;
    height: 100dvh;
    z-index: 2500;
    background: #09090d;
    color: #f2f2f7;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    overflow: hidden;
}

.photo-editor-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: max(12px, env(safe-area-inset-top, 12px)) 18px 12px;
    background: rgba(18, 18, 24, 0.92);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    flex-wrap: wrap;
}

.photo-editor-title-wrap {
    display: flex;
    align-items: center;
    gap: 10px;
}

.photo-editor-title-wrap h2 {
    color: #ffffff;
    font-size: 16px;
    font-weight: 700;
    margin: 0;
}

.editor-sub-badge {
    font-size: 11px;
    color: #a8c7fa;
    font-weight: 500;
}

.photo-editor-header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.photo-editor-stage {
    flex: 1;
    min-height: 200px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 18px;
    background: radial-gradient(circle at center, #161720 0%, #09090d 100%);
    overflow: hidden;
    user-select: none;
    -webkit-user-select: none;
}

.photo-editor-canvas-wrapper {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    max-width: 100%;
    max-height: 46dvh;
    border-radius: 14px;
    box-shadow: 0 20px 48px rgba(0, 0, 0, 0.65);
    overflow: hidden;
}

#photo-editor-canvas {
    display: block;
    max-width: 100%;
    max-height: 46dvh;
    width: auto;
    height: auto;
    object-fit: contain;
    pointer-events: none;
}

.photo-editor-crop-overlay {
    position: absolute;
    inset: 0;
    pointer-events: none;
    overflow: hidden;
    display: none;
    touch-action: none;
}

.photo-editor-crop-overlay.active {
    display: block;
}

.photo-editor-crop-box {
    position: absolute;
    box-sizing: border-box;
    border: 2px solid #ffffff;
    box-shadow: 0 0 0 9999px rgba(5, 6, 10, 0.66), inset 0 0 0 1px rgba(0, 0, 0, 0.35);
    cursor: move;
    pointer-events: auto;
    touch-action: none;
}

.crop-grid-line {
    position: absolute;
    background: rgba(255, 255, 255, 0.42);
    pointer-events: none;
    box-shadow: 0 0 2px rgba(0, 0, 0, 0.45);
}

.crop-grid-h1 {
    left: 0;
    right: 0;
    top: 33.3333%;
    height: 1px;
}

.crop-grid-h2 {
    left: 0;
    right: 0;
    top: 66.6667%;
    height: 1px;
}

.crop-grid-v1 {
    top: 0;
    bottom: 0;
    left: 33.3333%;
    width: 1px;
}

.crop-grid-v2 {
    top: 0;
    bottom: 0;
    left: 66.6667%;
    width: 1px;
}

.crop-box-dimensions-label {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    background: rgba(9, 10, 15, 0.78);
    color: #ffffff;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.02em;
    padding: 4px 10px;
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, 0.22);
    white-space: nowrap;
    pointer-events: none;
    backdrop-filter: blur(8px);
}

.crop-handle {
    position: absolute;
    z-index: 4;
    pointer-events: auto;
    touch-action: none;
}

/* 4 Corner Handles — High-visibility tactile L/Pill corners */
.crop-handle-nw,
.crop-handle-ne,
.crop-handle-se,
.crop-handle-sw {
    width: 22px;
    height: 22px;
    background: #a8c7fa;
    border: 2.5px solid #041e49;
    border-radius: 6px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.55);
}

.crop-handle-nw {
    top: -10px;
    left: -10px;
    cursor: nwse-resize;
}

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

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

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

/* 4 Edge Handles — Pill bars along N, E, S, W */
.crop-handle-n,
.crop-handle-s {
    left: 50%;
    transform: translateX(-50%);
    width: 34px;
    height: 10px;
    background: #ffffff;
    border: 1.5px solid #041e49;
    border-radius: 999px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.45);
    cursor: ns-resize;
}

.crop-handle-n {
    top: -6px;
}

.crop-handle-s {
    bottom: -6px;
}

.crop-handle-e,
.crop-handle-w {
    top: 50%;
    transform: translateY(-50%);
    width: 10px;
    height: 34px;
    background: #ffffff;
    border: 1.5px solid #041e49;
    border-radius: 999px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.45);
    cursor: ew-resize;
}

.crop-handle-e {
    right: -6px;
}

.crop-handle-w {
    left: -6px;
}

.photo-editor-controls {
    background: rgba(20, 21, 28, 0.96);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border-top: 1px solid rgba(255, 255, 255, 0.09);
    padding: 14px 18px max(16px, env(safe-area-inset-bottom, 16px));
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-height: 44dvh;
    overflow-y: auto;
}

.editor-presets-row {
    display: flex;
    align-items: center;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 4px;
}

.editor-preset-chip,
.editor-crop-chip {
    border: 1px solid rgba(255, 255, 255, 0.14);
    background: rgba(255, 255, 255, 0.06);
    color: #e4e4ec;
    font-family: inherit;
    font-size: 12px;
    font-weight: 600;
    padding: 6px 14px;
    border-radius: 999px;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.16s var(--ease-m3);
}

.editor-preset-chip.active,
.editor-crop-chip.active {
    background: #a8c7fa;
    color: #041e49;
    border-color: #a8c7fa;
    font-weight: 700;
}

.editor-sliders-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
    gap: 10px 18px;
}

.editor-slider-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 12px;
    color: #d5d6e0;
}

.editor-slider-label {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.editor-slider-label span {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-weight: 600;
}

.editor-slider-label .material-icons {
    font-size: 15px;
    color: #a8c7fa;
}

.editor-slider-item input[type="range"] {
    width: 100%;
    accent-color: #a8c7fa;
    cursor: pointer;
}

.editor-transform-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    padding-top: 4px;
    border-top: 1px solid rgba(255, 255, 255, 0.07);
}

.editor-tool-group,
.editor-crop-group {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.editor-tool-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    height: 34px;
    padding: 0 12px;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.14);
    background: rgba(255, 255, 255, 0.06);
    color: #f0f0f6;
    font-family: inherit;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.16s var(--ease-m3);
}

.editor-tool-btn:hover,
.editor-tool-btn.active {
    background: rgba(168, 199, 250, 0.22);
    border-color: #a8c7fa;
    color: #a8c7fa;
}

.editor-tool-btn .material-icons {
    font-size: 16px;
}

.crop-label {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    font-weight: 600;
    color: #b8bac6;
    margin-right: 4px;
}

.crop-label .material-icons {
    font-size: 15px;
}

/* Tipografia */
h1, h2, h3, p {
    transition: color 0.2s var(--ease-m3);
}

h1 {
    font-size: 22px;
    font-weight: 600;
    line-height: 28px;
    letter-spacing: -0.02em;
    color: var(--on-surface);
}

h2 {
    font-size: 17px;
    font-weight: 600;
    line-height: 24px;
    letter-spacing: -0.01em;
    color: var(--on-surface);
}

h3 {
    font-size: 15px;
    font-weight: 600;
    line-height: 22px;
    color: var(--on-surface);
}

p {
    font-size: 13px;
    line-height: 18px;
    color: var(--on-surface-variant);
}

@media (max-width: 768px) {
    .nav-btn {
        width: 42px;
        height: 42px;
    }
    .prev-btn { left: 10px; }
    .next-btn { right: 10px; }
}

/* ===================================================== */
/* === MATERIAL YOU (MD3) TONAL PALETTE - DARK MODE  === */
/* ===================================================== */

body.dark-mode {
    --primary: #a8c7fa;
    --on-primary: #062e6f;
    --primary-container: #0842a0;
    --on-primary-container: #d3e3fd;

    --secondary: #7fcfff;
    --on-secondary: #003355;
    --secondary-container: #004a77;
    --on-secondary-container: #c2e7ff;

    --tertiary: #6dd58c;
    --on-tertiary: #0a3818;
    --on-tertiary-container: #c4eed0;

    --error: #f2b8b5;
    --on-error: #601410;
    --error-container: #8c1d18;
    --on-error-container: #f9dedc;

    --background: #0e0e11;
    --on-background: #e3e2e6;

    --surface: #0e0e11;
    --on-surface: #e3e2e6;
    --surface-variant: #44474e;
    --on-surface-variant: #c4c6d0;

    --outline: #8e9099;
    --outline-variant: rgba(196, 198, 208, 0.12);

    --surface-container-lowest: #09090b;
    --surface-container-low: #16161a;
    --surface-container: #1c1c22;
    --surface-container-high: #25262e;
    --surface-container-highest: #30313a;

    --floating-bar-bg: rgba(28, 28, 34, 0.86);
    --floating-bar-border: rgba(255, 255, 255, 0.09);
    --floating-bar-shadow: 0 16px 40px -4px rgba(0, 0, 0, 0.55), 0 4px 14px -2px rgba(0, 0, 0, 0.35);
}

/* --- Integrated Document & Media Viewer Modal --- */
.document-viewer-modal {
    position: fixed;
    inset: 0;
    width: 100vw;
    height: 100dvh;
    z-index: 3200;
    background: var(--surface);
    color: var(--on-surface);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    overflow: hidden;
}

.document-viewer-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: max(12px, env(safe-area-inset-top, 12px)) 20px 12px;
    background: var(--surface-container-high);
    border-bottom: 1px solid var(--outline-variant);
    flex-shrink: 0;
}

.document-viewer-header h2 {
    margin: 0;
    font-size: 16px;
    font-weight: 700;
    color: var(--on-surface);
}

.document-viewer-header .editor-sub-badge {
    color: var(--primary);
    font-weight: 600;
}

.document-viewer-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
    padding: 10px 20px;
    background: var(--surface-container-low);
    border-bottom: 1px solid var(--outline-variant);
    flex-shrink: 0;
}

.document-viewer-toolbar:empty {
    display: none;
}

.doc-toolbar-group {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.doc-toolbar-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    font-weight: 600;
    color: var(--on-surface-variant);
    background: var(--surface-container);
    border: 1px solid var(--outline-variant);
    padding: 4px 12px;
    border-radius: 999px;
}

.doc-toolbar-pill input[type="number"] {
    width: 48px;
    height: 24px;
    border-radius: 6px;
    border: 1px solid var(--outline-variant);
    background: var(--surface);
    color: var(--on-surface);
    text-align: center;
    font-family: inherit;
    font-size: 12px;
    font-weight: 700;
}

.doc-tool-btn,
.doc-sheet-tab {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    height: 34px;
    padding: 0 12px;
    border-radius: 999px;
    border: 1px solid var(--outline-variant);
    background: var(--surface-container);
    color: var(--on-surface);
    font-family: inherit;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.16s var(--ease-m3);
}

.doc-tool-btn:hover:not(:disabled),
.doc-sheet-tab:hover {
    background: var(--surface-container-highest);
}

.doc-tool-btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.doc-sheet-tabs-row {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.doc-sheet-tab.active {
    background: var(--primary);
    color: var(--on-primary);
    border-color: var(--primary);
}

.doc-search-input-wrap {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 34px;
    padding: 0 12px;
    border-radius: 999px;
    border: 1px solid var(--outline-variant);
    background: var(--surface-container);
    color: var(--on-surface-variant);
}

.doc-search-input-wrap .material-icons {
    font-size: 17px;
}

.doc-search-input-wrap input {
    border: none;
    outline: none;
    background: transparent;
    color: var(--on-surface);
    font-family: inherit;
    font-size: 13px;
    min-width: 180px;
}

.document-viewer-stage {
    position: relative;
    flex: 1;
    overflow: auto;
    display: flex;
    flex-direction: column;
    background: var(--surface-container-lowest);
    padding: 20px;
}

.doc-loading-state {
    margin: auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
    color: var(--on-surface-variant);
}

.doc-spinner {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 3px solid var(--outline-variant);
    border-top-color: var(--primary);
    animation: docSpin 0.8s linear infinite;
}

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

/* PDF Viewer */
.doc-pdf-container {
    flex: 1;
    width: 100%;
    min-height: 520px;
    overflow: auto;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    background: #14161d;
    border-radius: 16px;
    padding: 16px;
}

.doc-pdf-zoom-wrapper {
    min-height: 620px;
    background: #ffffff;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 12px 36px rgba(0, 0, 0, 0.35);
    transition: width 0.2s ease;
}

.doc-pdf-frame {
    width: 100%;
    height: 72dvh;
    min-height: 520px;
    border: none;
    display: block;
}

.doc-pdf-fallback-sheet {
    width: min(820px, 100%);
    min-height: 540px;
    margin: 0 auto;
    background: var(--surface-container);
    color: var(--on-surface);
    border: 1px solid var(--outline-variant);
    border-radius: 16px;
    padding: 36px 42px;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.25);
}

/* Word / ODT / RTF Paper View */
.doc-paper-sheet {
    width: min(840px, 100%);
    min-height: 620px;
    margin: 0 auto;
    background: var(--surface-container);
    color: var(--on-surface);
    border: 1px solid var(--outline-variant);
    border-radius: 16px;
    padding: 40px 48px;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.18);
    line-height: 1.68;
}

.doc-heading-1,
.doc-heading-2,
.doc-heading-3 {
    margin: 1.1em 0 0.45em;
    color: var(--primary);
    line-height: 1.3;
}

.doc-heading-1 { font-size: 1.6em; }
.doc-heading-2 { font-size: 1.35em; }
.doc-heading-3 { font-size: 1.15em; }

.doc-paragraph {
    margin: 0 0 0.85em;
    white-space: pre-wrap;
    word-break: break-word;
    color: var(--on-surface);
}

.doc-list-item {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    margin: 0 0 0.5em 0.5em;
}

.doc-bullet {
    color: var(--primary);
    font-weight: 700;
}

.doc-table-scroll {
    overflow-x: auto;
    margin: 14px 0;
}

.doc-word-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.95em;
}

.doc-word-table th,
.doc-word-table td {
    border: 1px solid var(--outline-variant);
    padding: 8px 12px;
    text-align: left;
}

.doc-word-table th {
    background: var(--surface-container-high);
    font-weight: 700;
}

.doc-search-highlight {
    background: rgba(250, 204, 21, 0.35);
    color: inherit;
    padding: 0 2px;
    border-radius: 3px;
}

/* Spreadsheet Viewer */
.doc-spreadsheet-wrap {
    flex: 1;
    overflow: auto;
    background: var(--surface-container);
    border: 1px solid var(--outline-variant);
    border-radius: 14px;
}

.doc-spreadsheet-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.doc-spreadsheet-table th,
.doc-spreadsheet-table td {
    border: 1px solid var(--outline-variant);
    padding: 8px 12px;
    text-align: left;
    white-space: nowrap;
    max-width: 320px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.doc-spreadsheet-table thead th {
    position: sticky;
    top: 0;
    background: var(--surface-container-high);
    color: var(--on-surface);
    font-weight: 700;
    z-index: 2;
}

.doc-sheet-row-num,
.doc-sheet-corner {
    background: var(--surface-container-low);
    color: var(--on-surface-variant);
    font-weight: 600;
    text-align: center !important;
    width: 46px;
}

.doc-sheet-first-row {
    font-weight: 700;
    background: var(--surface-container-low);
}

/* Presentation Viewer */
.doc-presentation-layout {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
}

.doc-slide-canvas {
    width: min(880px, 100%);
    min-height: 420px;
    margin: auto;
    background: linear-gradient(145deg, var(--surface-container-high), var(--surface-container));
    border: 1px solid var(--outline-variant);
    border-radius: 22px;
    padding: 42px 52px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.25);
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.doc-slide-badge {
    display: inline-flex;
    align-self: flex-start;
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0.08em;
    color: var(--on-primary-container);
    background: var(--primary-container);
    padding: 4px 10px;
    border-radius: 999px;
}

.doc-slide-title {
    margin: 0;
    font-size: 26px;
    font-weight: 800;
    color: var(--on-surface);
}

.doc-slide-bullets {
    margin: 4px 0 0;
    padding-left: 22px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    font-size: 16px;
    line-height: 1.55;
}

.doc-slide-notes {
    margin-top: auto;
    padding: 12px 16px;
    border-radius: 12px;
    background: var(--surface-container-low);
    border: 1px solid var(--outline-variant);
    font-size: 12px;
    color: var(--on-surface-variant);
}

.doc-slide-strip {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    overflow-x: auto;
    padding: 8px 4px;
}

.doc-slide-thumb {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    border-radius: 12px;
    border: 1px solid var(--outline-variant);
    background: var(--surface-container);
    color: var(--on-surface);
    font-family: inherit;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
}

.doc-slide-thumb.active {
    background: var(--primary-container);
    color: var(--on-primary-container);
    border-color: var(--primary);
}

.slide-thumb-num {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: var(--surface-container-highest);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 700;
}

/* Text / Code Viewer */
.doc-code-viewer {
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-size: 13px;
    background: var(--surface-container);
    border: 1px solid var(--outline-variant);
    border-radius: 14px;
    padding: 12px 0;
    overflow: auto;
}

.doc-code-line {
    display: grid;
    grid-template-columns: 54px 1fr;
    gap: 14px;
    padding: 2px 16px;
    line-height: 1.55;
}

.doc-code-line:hover {
    background: var(--surface-container-high);
}

.doc-code-ln {
    color: var(--on-surface-variant);
    text-align: right;
    user-select: none;
    opacity: 0.7;
}

.doc-code-content {
    white-space: pre-wrap;
    word-break: break-all;
}

/* Audio & External App Chooser Cards */
.doc-external-card {
    margin: auto;
    padding: 36px 32px;
    max-width: 520px;
    width: 100%;
    background: var(--surface-container);
    border: 1px solid var(--outline-variant);
    border-radius: 24px;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.22);
}

.doc-external-icon-wrap {
    width: 64px;
    height: 64px;
    border-radius: 20px;
    background: var(--primary-container);
    color: var(--on-primary-container);
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.doc-external-icon-wrap .material-icons {
    font-size: 32px;
}

.doc-external-meta {
    font-size: 12px;
    color: var(--on-surface-variant);
}

.doc-external-desc {
    font-size: 13px;
    color: var(--on-surface-variant);
    max-width: 420px;
}

.doc-external-status-msg {
    font-size: 12px;
    color: var(--primary);
    background: var(--primary-container);
    color: var(--on-primary-container);
    padding: 8px 14px;
    border-radius: 10px;
}

.doc-audio-player {
    width: 100%;
    margin-top: 8px;
}

.doc-external-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
    margin-top: 8px;
}

.doc-empty-notice {
    padding: 24px;
    text-align: center;
    color: var(--on-surface-variant);
}

@media (max-width: 768px) {
    .document-viewer-stage {
        padding: 12px;
    }
    .doc-paper-sheet,
    .doc-slide-canvas {
        padding: 24px 20px;
    }
}


