:root {
    /* Premium Design System Tools - Light Creatium Theme */
    --color-primary: #004D40;
    --color-accent: #004D40;
    --color-accent-hover: #00332B;

    /* Light Ivory Backgrounds */
    --color-bg-main: #FAF9F6;
    --color-bg-white: #FFFFFF;
    --color-bg-paper: transparent;

    --color-border: #E5E7E2;

    /* Dark Text on Light */
    --color-text-main: #1A1A1A;
    --color-text-muted: #666666;

    --color-success: #10B981;
    --color-danger: #EF4444;

    --panel-width: 400px;
    --header-height: 64px;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.5);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.5);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.5);
    --radius-md: 12px;
    --radius-lg: 16px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    color: var(--color-text-main);
    background-color: var(--color-bg-main);
    line-height: 1.5;
    overflow: hidden;
    height: 100vh;
    width: 100vw;
}

/* --- Layout Core --- */

.app-container {
    display: flex;
    flex-direction: row;
    height: 100vh;
    width: 100vw;
    overflow: hidden;
}

/* Main Preview Area (Left - Flexible) */
.preview-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    /* Prevents overflow-x issues with flex */
    background: var(--color-bg-paper);
    height: 100%;
}

.preview-header {
    height: var(--header-height);
    background: rgba(250, 249, 246, 0.8);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--color-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 24px;
    z-index: 100;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.mini-logo {
    height: 32px;
    width: auto;
}

#report-title-display {
    font-size: 1rem;
    font-weight: 600;
    color: var(--color-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 300px;
}

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

.view-toggle {
    display: flex;
    background: rgba(0, 0, 0, 0.05);
    padding: 4px;
    border-radius: 8px;
    border: 1px solid var(--color-border);
}

.btn-xs {
    padding: 6px 12px;
    border: none;
    background: transparent;
    font-size: 0.75rem;
    font-weight: 600;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
    color: var(--color-text-muted);
}

.btn-xs.active {
    background: white;
    color: var(--color-accent);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.btn-xs:hover {
    color: white;
    background: rgba(255, 255, 255, 0.05);
}

/* Canvas Wrapper / Workspace */
.canvas-wrapper {
    flex: 1;
    overflow: hidden;
    /* Main container is hidden, sub-containers handle scroll */
    position: relative;
    background: var(--color-bg-paper);
}

.paper-container {
    width: 100%;
    height: 100%;
    overflow-y: auto;
    padding: 40px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.full-container {
    width: 100%;
    height: 100%;
    overflow: hidden;
}

#editor-canvas {
    width: 21cm;
    min-height: 29.7cm;
    background: white;
    padding: 2.54cm;
    box-shadow: 0 0 40px rgba(0, 0, 0, 0.05);
    margin: 0 auto;
    border-radius: 4px;
}

#pdf-frame,
#oo-container,
#oo-placeholder {
    width: 100%;
    height: 100%;
    border-radius: 4px;
    border: none;
}

/* Sidebar / Prompt Panel (Right - Fixed) */
/* Sidebar / Prompt Panel (Right - Fixed) */
.sidebar {
    width: var(--panel-width);
    background: white;
    border-left: 1px solid var(--color-border);
    display: flex;
    flex-direction: column;
    height: 100vh;
    box-shadow: -10px 0 30px rgba(0, 0, 0, 0.03);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.sidebar.collapsed {
    width: 0;
    min-width: 0;
    border-left: none;
    box-shadow: none;
}

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

.panel-header h3 {
    font-size: 0.85rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--color-text-muted);
}

.header-main-title {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    width: 100%;
}

.btn-collapse {
    background: transparent;
    border: 1px solid var(--color-border);
    color: var(--color-text-muted);
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-collapse:hover {
    background: rgba(255, 255, 255, 0.05);
    color: white;
    border-color: rgba(255, 255, 255, 0.2);
}

.btn-expand-panel {
    display: none;
    /* Removed fixed restore button */
}

.btn-toggle-sidebar-minimal {
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    color: var(--color-text-muted);
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
}

.btn-toggle-sidebar-minimal:hover {
    background: #F1F5F9;
}

.icon-sparkles {
    width: 16px;
    height: 16px;
    color: var(--color-text-muted);
    transition: all 0.2s ease;
}

.btn-toggle-sidebar-minimal:hover .icon-sparkles {
    color: var(--color-accent);
}

/* Active State: When Copilot is Open */
.btn-toggle-sidebar-minimal.active .icon-sparkles {
    color: #00BF9A;
    filter: drop-shadow(0 0 4px rgba(0, 191, 154, 0.4));
}

.btn-toggle-sidebar-minimal.active {
    background: rgba(0, 191, 154, 0.1);
}

.ai-badge {
    display: none;
    /* Removed as requested */
}

.report-status-badge {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    background: #F8FAFC;
    border: 1px solid var(--color-border);
    border-radius: 100px;
    font-size: 0.75rem;
    font-weight: 600;
}

.report-status-badge.generating {
    color: var(--color-accent);
}

.report-status-badge.generating .status-dot {
    animation: pulse 1.5s infinite;
}

.report-status-badge.ready {
    color: var(--color-success);
    border-color: rgba(16, 185, 129, 0.2);
    background: rgba(16, 185, 129, 0.05);
}

.report-status-badge.warning {
    color: #F59E0B;
    border-color: rgba(245, 158, 11, 0.2);
    background: rgba(245, 158, 11, 0.05);
}

@keyframes pulse {
    0% {
        opacity: 0.4;
        transform: scale(0.9);
    }

    50% {
        opacity: 1;
        transform: scale(1.1);
    }

    100% {
        opacity: 0.4;
        transform: scale(0.9);
    }
}

/* Selection Info */
.selection-info {
    background: #E0F2F1;
    border-bottom: 1px solid rgba(0, 191, 154, 0.2);
    padding: 12px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.target-chip {
    display: flex;
    align-items: center;
    gap: 8px;
    background: #004D40;
    color: white;
    padding: 5px 12px;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 600;
}

.btn-clear {
    background: transparent;
    border: none;
    color: var(--color-text-muted);
    font-size: 0.85rem;
    cursor: pointer;
}

.btn-clear:hover {
    color: var(--color-danger);
}

/* Chat Section */
.chat-section {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    background: transparent;
}

.message {
    max-width: 90%;
    margin-bottom: 16px;
    padding: 12px 16px;
    border-radius: 12px;
    font-size: 0.95rem;
    line-height: 1.5;
}

.user-message {
    background: #004D40;
    color: white;
    align-self: flex-end;
    margin-left: auto;
}

.ai-message {
    background: #FFFFFF;
    border: 1px solid var(--color-border);
    color: var(--color-text-main);
    box-shadow: var(--shadow-sm);
}

/* Input Area */
.chat-input-wrapper {
    background: #FFFFFF;
    padding: 20px;
    border-top: 1px solid var(--color-border);
}

.style-presets {
    margin-bottom: 16px;
}

.preset-label {
    display: block;
    font-size: 0.7rem;
    font-weight: 800;
    color: var(--color-text-muted);
    text-transform: uppercase;
    margin-bottom: 8px;
}

.preset-btns {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

/* Presets */
.btn-preset {
    padding: 6px 12px;
    background: #F1F5F9;
    border: 1px solid var(--color-border);
    border-radius: 8px;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--color-text-main);
    cursor: pointer;
    transition: all 0.2s;
}

.btn-preset:hover {
    border-color: var(--color-accent);
    color: var(--color-accent);
}

.suggestion-chips {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 12px;
}

.chip {
    white-space: nowrap;
    padding: 6px 14px;
    background: #F1F5F9;
    border: 1px solid var(--color-border);
    border-radius: 100px;
    font-size: 0.8rem;
    color: var(--color-text-main);
    cursor: pointer;
    transition: all 0.2s;
}

.chip:hover {
    background: white;
    border-color: var(--color-accent);
    color: var(--color-accent);
}

.chat-input-area {
    display: flex;
    gap: 12px;
    background: #F8FAFC;
    border: 1px solid var(--color-border);
    padding: 12px;
    border-radius: 12px;
    transition: all 0.2s;
}

.chat-input-area:focus-within {
    background: white;
    border-color: #004D40;
    box-shadow: 0 0 0 4px rgba(0, 77, 64, 0.1);
}

.chat-input-area textarea {
    flex: 1;
    border: none;
    background: transparent;
    resize: none;
    font-family: inherit;
    font-size: 0.95rem;
    outline: none;
    padding: 4px 0;
}

.btn-icon-send {
    background: #004D40;
    color: white;
    border: none;
    width: 36px;
    height: 36px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.2s;
}

.btn-icon-send:hover {
    background: var(--color-accent-hover);
}

/* Status Log */
.panel-footer {
    padding: 12px 20px;
    background: #FFFFFF;
    border-top: 1px solid var(--color-border);
}

.status-log {
    font-size: 0.75rem;
    color: var(--color-text-muted);
    font-family: 'JetBrains Mono', monospace;
    height: 48px;
    overflow-y: auto;
}

/* --- Document Preview Aesthetics --- */

#editor-canvas {
    background: white;
    width: 21cm;
    min-height: 29.7cm;
    padding: 2.54cm;
    box-shadow: 0 0 40px rgba(0, 0, 0, 0.05);
    margin: 0 auto;
}

.doc-p {
    margin-bottom: 0.75em;
    padding: 4px;
    border-radius: 4px;
    transition: background 0.2s;
    cursor: pointer;
}

.doc-p:hover {
    background: #F1F5F9;
}

.doc-p.selected {
    background: #E0F2F1;
    border-left: 4px solid #004D40;
    padding-left: 12px;
    box-shadow: var(--shadow-sm);
}

.doc-type-h1 {
    font-size: 24pt;
    font-weight: 800;
    color: #0F172A;
    text-align: center;
}

.doc-type-h2 {
    font-size: 18pt;
    font-weight: 700;
    color: #1E293B;
    margin-top: 1.5rem;
    margin-bottom: 0.5rem;
    border-bottom: 1px solid #E2E8F0;
    padding-bottom: 0.3rem;
}

.doc-type-h3 {
    font-size: 14pt;
    font-weight: 600;
    color: #334155;
    margin-top: 1rem;
    margin-bottom: 0.25rem;
}

.doc-type-text {
    font-size: 11pt;
    line-height: 1.7;
    color: #334155;
}

/* --- Setup Overlay (Premium Rescue) --- */

.setup-overlay {
    position: fixed;
    inset: 0;
    background: #F8FAFC;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}

.setup-card {
    background: white;
    width: 100%;
    max-width: 480px;
    padding: 48px;
    border-radius: 24px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.1);
}

.brand-large {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: 40px;
}

.brand-large img {
    height: 80px;
    width: auto;
    margin-bottom: 24px;
    filter: drop-shadow(0 4px 12px rgba(59, 130, 246, 0.15));
}

.brand-large h1 {
    font-size: 1.75rem;
    font-weight: 800;
    color: var(--color-primary);
    letter-spacing: -0.02em;
}

.setup-toggle {
    display: flex;
    background: #F1F5F9;
    padding: 4px;
    border-radius: 14px;
    margin-bottom: 32px;
}

.toggle-btn {
    flex: 1;
    border: none;
    padding: 12px;
    font-weight: 600;
    border-radius: 10px;
    background: transparent;
    cursor: pointer;
    transition: all 0.2s;
}

.toggle-btn.active {
    background: white;
    color: var(--color-accent);
    box-shadow: var(--shadow-sm);
}

.btn-primary {
    background: #004D40;
    color: white;
    border: none;
    padding: 14px;
    border-radius: 12px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-primary:hover {
    background: var(--color-accent-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.2);
}

.btn-sm {
    padding: 8px 16px;
    font-size: 0.85rem;
}

.full-width {
    width: 100%;
}

/* Setup Form Elements */
.setup-form {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.input-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.input-group label {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.input-group input,
.input-group select {
    padding: 12px 16px;
    border: 1.5px solid var(--color-border);
    border-radius: 12px;
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--color-text-main);
    transition: all 0.2s;
    background: #FAFBFC;
}

.input-group input:focus,
.input-group select:focus {
    outline: none;
    border-color: var(--color-accent);
    background: white;
    box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.1);
}

.upload-section {
    margin-top: 10px;
}

.upload-dropzone {
    border: 2px dashed var(--color-border);
    border-radius: 16px;
    padding: 32px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    transition: all 0.2s;
    background: #FAFBFC;
}

.upload-dropzone:hover {
    border-color: var(--color-accent);
    background: #F0F9FF;
}

.upload-dropzone svg {
    color: var(--color-text-muted);
}

.filename {
    font-size: 0.8rem;
    color: var(--color-text-muted);
    margin-top: 8px;
    display: block;
    text-align: center;
}

/* --- Mermaid Diagrams --- */
.mermaid-wrap {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 20px;
    margin: 10px 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
}

.mermaid-img {
    width: 100%;
    max-width: 900px;
    height: auto;
    border-radius: 4px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.mermaid-btns {
    margin-top: 12px;
    opacity: 0.1;
    transition: opacity 0.2s;
}

.mermaid-wrap:hover .mermaid-btns {
    opacity: 1;
}

.btn-mermaid-edit {
    background: white;
    border: 1px solid #cbd5e1;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 600;
    color: #475569;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.btn-mermaid-edit:hover {
    background: #f1f5f9;
    border-color: #94a3b8;
    color: #1e293b;
}

.btn-mermaid-edit span {
    font-size: 0.9rem;
}

.doc-type-list_item {
    font-size: 11pt;
    line-height: 1.7;
    color: #334155;
    padding-left: 2.5rem;
    position: relative;
    margin-bottom: 0.5rem;
}

.doc-type-list_item::before {
    content: "•";
    position: absolute;
    left: 1.2rem;
    color: var(--color-accent);
    font-weight: bold;
}

.doc-type-numbered_item {
    font-size: 11pt;
    line-height: 1.7;
    color: #334155;
    padding-left: 2.5rem;
    position: relative;
    margin-bottom: 0.5rem;
    display: list-item;
    list-style-type: decimal;
    list-style-position: inside;
}