:root {
    --bg-color: var(--vscode-editor-background, #1e1e1e);
    --text-color: var(--vscode-editor-foreground, #d4d4d4);
    --border-color: var(--vscode-panel-border, #3c3c3c);
    --header-bg: var(--vscode-sideBar-background, #252526);
    --button-bg: var(--vscode-button-background, #0e639c);
    --button-hover: var(--vscode-button-hoverBackground, #1177bb);
    --button-secondary-bg: var(--vscode-button-secondaryBackground, #3a3d41);
    --button-secondary-hover: var(--vscode-button-secondaryHoverBackground, #45494e);
}

* {
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-color);
    color: var(--text-color);
    margin: 0;
    padding: 0;
    height: 100vh;
    overflow: hidden;
}

.container {
    display: flex;
    flex-direction: column;
    height: 100vh;
}

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

.title {
    font-size: 16px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
}

.file-info {
    font-size: 12px;
    color: var(--vscode-descriptionForeground, #808080);
}

.controls {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 10px 20px;
    background: var(--header-bg);
    border-bottom: 1px solid var(--border-color);
    gap: 10px;
}

.view-controls {
    display: flex;
    align-items: center;
    gap: 10px;
}

.btn {
    padding: 6px 12px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    background: var(--button-secondary-bg);
    color: var(--text-color);
    transition: background 0.2s;
}

.btn:hover {
    background: var(--button-secondary-hover);
}

.zoom-level {
    font-size: 12px;
    min-width: 50px;
    text-align: center;
    color: var(--vscode-descriptionForeground, #808080);
}

.document-container {
    flex: 1;
    overflow: auto;
    padding: 20px;
    display: flex;
    justify-content: center;
}

.loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 200px;
    color: var(--vscode-descriptionForeground, #808080);
}

.error {
    color: var(--vscode-errorForeground, #f48771);
    padding: 20px;
    text-align: center;
}

.word-content {
    background: var(--vscode-editor-background, #1e1e1e);
    color: var(--vscode-editor-foreground, #d4d4d4);
    padding: 40px 60px;
    min-width: 210mm;
    max-width: 210mm;
    min-height: 297mm;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
    transform-origin: top center;
    transition: transform 0.2s ease;
}

.word-content.docx-mode {
    background: transparent;
    color: inherit;
    padding: 0;
    min-width: auto;
    max-width: none;
    min-height: auto;
    box-shadow: none;
}

.word-content.legacy-mode {
    background: transparent;
    color: #111111;
    padding: 0;
    min-width: 210mm;
    max-width: none;
    min-height: auto;
    box-shadow: none;
    overflow: visible;
}

.word-content.legacy-mode .ov-doc-legacy,
.word-content.legacy-mode .ov-doc-legacy h1,
.word-content.legacy-mode .ov-doc-legacy h2,
.word-content.legacy-mode .ov-doc-legacy p,
.word-content.legacy-mode .ov-doc-legacy li,
.word-content.legacy-mode .ov-doc-legacy td,
.word-content.legacy-mode .ov-doc-legacy th {
    color: #111111;
}

.word-content.legacy-mode .ov-doc-legacy {
    display: block;
    width: fit-content;
    background: transparent;
    overflow: visible;
}

.word-content.legacy-mode .ov-doc-legacy-section + .ov-doc-legacy-section {
    margin-top: 18px;
}

.word-content.legacy-mode .ov-doc-legacy-pages {
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.word-content.legacy-mode .ov-doc-legacy-page {
    width: var(--ov-page-width-mm, 210mm);
    min-height: var(--ov-page-height-mm, 297mm);
    background: #ffffff;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
    overflow: visible;
    position: relative;
}

.word-content.legacy-mode .ov-doc-legacy-page-content {
    --ov-gutter-left-mm: 0mm;
    --ov-gutter-right-mm: 0mm;
    display: block;
    width: 100%;
    min-height: calc(
        var(--ov-page-height-mm, 297mm)
        - var(--ov-page-padding-top-mm, 11.29mm)
        - var(--ov-page-padding-bottom-mm, 11.29mm)
    );
    padding:
        max(var(--ov-page-padding-top-mm, 11.29mm), var(--ov-page-active-header-mm, var(--ov-page-header-mm, 12.70mm)))
        calc(var(--ov-page-padding-right-mm, 17.64mm) + var(--ov-gutter-right-mm))
        max(var(--ov-page-padding-bottom-mm, 11.29mm), var(--ov-page-active-footer-mm, var(--ov-page-footer-mm, 12.70mm)))
        calc(var(--ov-page-padding-left-mm, 17.64mm) + var(--ov-gutter-left-mm));
    overflow: visible;
}

.word-content.legacy-mode .ov-doc-legacy-page-content-custom-columns {
    padding-bottom: 0;
}

.word-content.legacy-mode .ov-doc-legacy-page-columns {
    display: grid;
    height: 100%;
    align-items: start;
    width: 100%;
    min-width: 0;
}

.word-content.legacy-mode .ov-doc-legacy-page-column {
    min-width: 0;
    height: 100%;
    overflow: hidden;
    width: 100%;
}

.word-content.legacy-mode .ov-doc-legacy-page-column-gap {
    min-width: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    background:
        linear-gradient(
            to right,
            transparent calc(50% - (var(--ov-column-rule-width, 0px) / 2)),
            rgba(148, 163, 184, 0.65) calc(50% - (var(--ov-column-rule-width, 0px) / 2)),
            rgba(148, 163, 184, 0.65) calc(50% + (var(--ov-column-rule-width, 0px) / 2)),
            transparent calc(50% + (var(--ov-column-rule-width, 0px) / 2))
        );
}

.word-content.legacy-mode .ov-doc-legacy-page-column > .ov-doc-legacy-block + .ov-doc-legacy-block {
    margin-top: 12px;
}

.word-content.legacy-mode .ov-doc-legacy-page-header,
.word-content.legacy-mode .ov-doc-legacy-page-footer {
    position: absolute;
    left: calc(var(--ov-page-padding-left-mm, 17.64mm) + var(--ov-gutter-left-mm, 0mm));
    right: calc(var(--ov-page-padding-right-mm, 17.64mm) + var(--ov-gutter-right-mm, 0mm));
    font-size: 11px;
    line-height: 1.3;
    color: #4b5563;
    white-space: pre-wrap;
    pointer-events: none;
}

.word-content.legacy-mode .ov-doc-legacy-page-header {
    top: max(4mm, calc(var(--ov-page-active-header-mm, var(--ov-page-header-mm, 12.70mm)) - 4mm));
}

.word-content.legacy-mode .ov-doc-legacy-page-footer {
    bottom: max(4mm, calc(var(--ov-page-active-footer-mm, var(--ov-page-footer-mm, 12.70mm)) - 4mm));
}

.word-content.legacy-mode .ov-doc-legacy-page-header[hidden],
.word-content.legacy-mode .ov-doc-legacy-page-footer[hidden] {
    display: none;
}

.word-content.legacy-mode .ov-doc-legacy-section[data-ov-gutter-side="left"] .ov-doc-legacy-page-content {
    --ov-gutter-left-mm: var(--ov-page-gutter-mm, 0mm);
}

.word-content.legacy-mode .ov-doc-legacy-section[data-ov-gutter-side="right"] .ov-doc-legacy-page-content {
    --ov-gutter-right-mm: var(--ov-page-gutter-mm, 0mm);
}

.word-content.legacy-mode .ov-doc-legacy-block {
    display: block;
    width: 100%;
    max-width: 100%;
    clear: both;
    break-inside: avoid;
    page-break-inside: avoid;
    -webkit-column-break-inside: avoid;
}

.word-content.legacy-mode .ov-doc-legacy-block[data-ov-semantic-role="floating-media"] {
    clear: none;
    margin-bottom: var(--ov-floating-clearance, 12px);
}

.word-content.legacy-mode .ov-doc-legacy-block[data-ov-semantic-role="floating-media"][data-ov-floating-placement="center-block"] {
    clear: both;
}

.word-content.legacy-mode .ov-doc-legacy-block[data-ov-clear-float="true"] {
    clear: both;
    padding-top: var(--ov-clear-float-padding, 4px);
}

.word-content.legacy-mode .ov-doc-legacy-block + .ov-doc-legacy-block {
    margin-top: 12px;
}

.word-content.legacy-mode .ov-doc-legacy-block-overflow {
    break-inside: auto;
    page-break-inside: auto;
}

.word-content.legacy-mode .ov-doc-legacy-page-content h1 {
    font-size: 28px;
    margin: 0 0 18px 0;
    line-height: 1.25;
}

.word-content.legacy-mode .ov-doc-legacy-page-content h2 {
    font-size: 18px;
    margin: 26px 0 10px 0;
    line-height: 1.35;
}

.word-content.legacy-mode .ov-doc-legacy-page-content p {
    display: block;
    width: 100%;
    max-width: 100%;
    clear: both;
    margin: 0;
    line-height: 1.6;
    white-space: pre-wrap;
    tab-size: 4;
}

.word-content.legacy-mode .ov-doc-legacy-page-content ul,
.word-content.legacy-mode .ov-doc-legacy-page-content ol {
    display: block;
    width: 100%;
    max-width: 100%;
    clear: both;
    margin: 0 0 0 24px;
    padding: 0;
}

.word-content.legacy-mode .ov-doc-legacy-page-content li {
    margin: 0 0 8px 0;
    line-height: 1.6;
    white-space: pre-wrap;
    tab-size: 4;
}

.word-content.legacy-mode .ov-doc-legacy-table {
    display: block;
    width: 100%;
    margin: 0;
    max-width: 100%;
    overflow-x: auto;
}

.word-content.legacy-mode .ov-doc-legacy-page-content table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.word-content.legacy-mode .ov-doc-legacy-page-content th,
.word-content.legacy-mode .ov-doc-legacy-page-content td {
    border: 1px solid var(--border-color, #3c3c3c);
    padding: 8px 10px;
    text-align: left;
    vertical-align: top;
}

.word-content.legacy-mode .ov-doc-legacy-table[data-ov-explicit-borders="true"] th,
.word-content.legacy-mode .ov-doc-legacy-table[data-ov-explicit-borders="true"] td {
    border-color: #111111;
}

.word-content.legacy-mode .ov-doc-legacy-page-content th {
    background: #f3f4f6;
    font-weight: 600;
}

.word-content.legacy-mode .ov-doc-legacy-images {
    margin-top: 28px;
}

.word-content.legacy-mode .ov-doc-embedded-sheet {
    display: block;
    clear: both;
    margin: 18px 0;
    width: 100%;
    max-width: 100%;
    overflow: hidden;
}

.word-content.legacy-mode .ov-doc-embedded-sheet-card {
    border: none;
    background: transparent;
    padding: 0;
}

.word-content.legacy-mode .ov-doc-embedded-sheet-head h2 {
    margin: 0 0 12px 0;
}

.word-content.legacy-mode .ov-doc-embedded-chart {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 140px;
    gap: 18px;
    align-items: flex-start;
    margin: 10px 0 24px;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    overflow: hidden;
}

.word-content.legacy-mode .ov-doc-embedded-chart-meta {
    grid-column: 1 / -1;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #6b7280;
}

.word-content.legacy-mode .ov-doc-embedded-chart-frame {
    flex: 1;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    border: none;
    background: transparent;
    padding: 0;
    overflow: hidden;
}

.word-content.legacy-mode .ov-doc-embedded-chart-svg {
    width: 100%;
    max-width: 100%;
    height: auto;
    display: block;
    overflow: hidden;
}

.word-content.legacy-mode .ov-doc-embedded-chart-legend {
    width: 140px;
    min-width: 140px;
    font-size: 13px;
}

.word-content.legacy-mode .ov-doc-embedded-chart-legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}

.word-content.legacy-mode .ov-doc-embedded-chart-swatch {
    width: 12px;
    height: 12px;
    display: inline-block;
}

.word-content.legacy-mode .ov-doc-embedded-table-wrap {
    margin-top: 18px;
    border-top: none;
    padding-top: 0;
}

.word-content.legacy-mode .ov-doc-embedded-table-label {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #6b7280;
    margin-bottom: 8px;
}

.word-content.legacy-mode .ov-doc-legacy-image-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 14px;
}

.word-content.legacy-mode .ov-doc-legacy-image {
    margin: 0;
    border: 1px solid var(--border-color, #3c3c3c);
    background: #f8fafc;
    padding: 10px;
}

.word-content.legacy-mode .ov-doc-legacy-image-inline {
    max-width: min(100%, 360px);
}

.word-content.legacy-mode .ov-doc-legacy-image-floating {
    width: min(44%, 320px);
    max-width: min(44%, 320px);
    float: right;
    margin: 0 0 14px 18px;
    clear: none;
}

.word-content.legacy-mode .ov-doc-legacy-image-floating-narrow {
    width: min(32%, 240px);
    max-width: min(32%, 240px);
}

.word-content.legacy-mode .ov-doc-legacy-image-floating-wide {
    width: min(52%, 400px);
    max-width: min(52%, 400px);
}

.word-content.legacy-mode .ov-doc-legacy-image-floating-left {
    float: left;
    margin: 0 18px 14px 0;
}

.word-content.legacy-mode .ov-doc-legacy-image-floating-center {
    float: none;
    width: min(56%, 360px);
    max-width: min(56%, 360px);
    margin: 0 auto 14px;
    clear: both;
}

.word-content.legacy-mode .ov-doc-legacy-image img {
    display: block;
    width: 100%;
    max-height: 220px;
    object-fit: contain;
    margin-bottom: 8px;
}

.word-content.legacy-mode .ov-doc-legacy-image figcaption {
    font-size: 12px;
    color: #6b7280;
    word-break: break-word;
}

.word-content.legacy-mode .ov-doc-legacy-empty {
    color: #6b7280;
    font-style: italic;
}

@media print {
    .word-content.legacy-mode .ov-doc-legacy-pages {
        gap: 0;
    }

    .word-content.legacy-mode .ov-doc-legacy-page {
        box-shadow: none;
        break-after: page;
        page-break-after: always;
    }

    .word-content.legacy-mode .ov-doc-legacy-page:last-child {
        break-after: auto;
        page-break-after: auto;
    }
}

.word-content.docx-mode .docx-wrapper {
    background: transparent;
}

.word-content.docx-mode p[data-ov-bullet-fix="1"]::before,
.word-content.docx-mode li[data-ov-bullet-fix="1"]::before {
    content: "* " !important;
}

.word-content.docx-mode .ov-chart-card {
    border: 1px solid #c7cbd1;
    background: #f8fafc;
    padding: 14px;
    margin: 14px auto;
    width: min(100%, 760px);
}

.word-content.docx-mode .ov-chart-title {
    font-size: 28px;
    line-height: 1.1;
    font-weight: 700;
    color: #111827;
    margin-bottom: 10px;
}

.word-content.docx-mode .ov-chart-layout {
    display: flex;
    align-items: flex-start;
    gap: 18px;
}

.word-content.docx-mode .ov-chart-svg {
    width: 100%;
    max-width: 560px;
    height: auto;
}

.word-content.docx-mode .ov-chart-legend {
    min-width: 130px;
    padding-top: 18px;
}

.word-content.docx-mode .ov-chart-legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
    color: #111827;
    font-size: 14px;
}

.word-content.docx-mode .ov-chart-legend-color {
    display: inline-block;
    width: 12px;
    height: 12px;
}

.word-content.legacy-mode p[data-ov-chart-spacer="keep"],
.word-content.docx-mode p[data-ov-chart-spacer="keep"] {
    min-height: 0.75em;
    margin: 0;
    line-height: 0;
}

.word-content.legacy-mode p[data-ov-chart-spacer="trim"],
.word-content.docx-mode p[data-ov-chart-spacer="trim"] {
    display: none;
}

.word-content p {
    margin: 0 0 1em 0;
    line-height: 1.6;
}

.word-content h1, .word-content h2, .word-content h3 {
    margin: 1em 0 0.5em 0;
    line-height: 1.3;
}

.word-content ul, .word-content ol {
    margin: 0.5em 0;
    padding-left: 2em;
}

.word-content table {
    border-collapse: collapse;
    width: 100%;
    margin: 1em 0;
}

.word-content table td,
.word-content table th {
    border: 1px solid var(--border-color, #3c3c3c);
    padding: 8px;
}

.word-content img {
    max-width: 100%;
    height: auto;
}

@media print {
    body { background: white; }
    .header, .controls { display: none !important; }
    .document-container { padding: 0; overflow: visible; }
    .word-content {
        box-shadow: none;
        padding: 0;
        min-width: auto;
        max-width: 100%;
        min-height: auto;
        transform: none !important;
    }
}
