:root {
    /* Color Palette */
    --bg-dark: #0f111a;
    --bg-pane: rgba(26, 29, 46, 0.7);
    --accent: #7c4dff;
    --accent-glow: rgba(124, 77, 255, 0.3);
    --text-primary: #e0e6ed;
    --text-secondary: #94a3b8;
    --border: rgba(255, 255, 255, 0.08);
    --glass-bg: rgba(255, 255, 255, 0.03);
    --success: #10b981;
}

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

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-dark);
    color: var(--text-primary);
    overflow: hidden; /* Main container handles scroll */
    height: 100vh;
}

h1, h2, h3, h4, .font-heading {
    font-family: 'Outfit', sans-serif;
}

/* Background Decorations */
.bg-glow {
    position: fixed;
    border-radius: 50%;
    filter: blur(100px);
    z-index: -1;
    opacity: 0.15;
}

.bg-glow-1 {
    width: 500px;
    height: 500px;
    background: var(--accent);
    top: -100px;
    right: -100px;
}

.bg-glow-2 {
    width: 600px;
    height: 600px;
    background: #00bcd4;
    bottom: -150px;
    left: -150px;
}

/* App Layout */
.app-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    padding: 1.5rem;
    gap: 1.5rem;
}

/* Header Styling */
.glass-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 2rem;
    background: var(--bg-pane);
    backdrop-filter: blur(12px);
    border: 1px solid var(--border);
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.logo .icon {
    font-size: 1.5rem;
}

.logo h1 {
    font-size: 1.25rem;
    font-weight: 700;
}

.logo h1 span {
    color: var(--accent);
}

.actions {
    display: flex;
    gap: 1rem;
}

/* Buttons */
.btn {
    padding: 0.6rem 1.2rem;
    border-radius: 10px;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.btn-primary {
    background: linear-gradient(135deg, var(--accent), #5e35b1);
    color: white;
    box-shadow: 0 4px 15px var(--accent-glow);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px var(--accent-glow);
}

.btn-secondary {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-primary);
}

.btn-secondary:hover {
    background: var(--glass-bg);
    border-color: var(--accent);
}

.btn-sm {
    padding: 0.4rem 0.8rem;
    font-size: 0.75rem;
}

.btn-icon-only {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 1.2rem;
    padding: 0.2rem 0.5rem;
    border-radius: 6px;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-icon-only:hover {
    background: rgba(0, 0, 0, 0.05);
    color: var(--accent);
}

/* Main Panes */
.main-layout {
    display: flex;
    flex: 1;
    gap: 1.5rem;
    min-height: 0; /* Important for flex child scrolling */
}

.pane {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--bg-pane);
    backdrop-filter: blur(10px);
    border: 1px solid var(--border);
    border-radius: 20px;
    overflow: hidden;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.pane:focus-within {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px var(--accent-glow);
}

.pane-header {
    padding: 0.75rem 1.5rem;
    background: rgba(0, 0, 0, 0.2);
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.upload-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.3rem 0.8rem;
    background: var(--glass-bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.8rem;
    color: var(--text-primary);
    transition: all 0.2s ease;
}

.upload-label:hover {
    background: rgba(124, 77, 255, 0.1);
    border-color: var(--accent);
    color: var(--accent);
}

.pane-title, .pane-controls {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.hidden-on-default {
    display: none !important;
}

.app-fullscreen .hidden-on-default {
    display: flex !important;
}

.app-fullscreen #btn-fullscreen {
    display: none !important;
}

#markdown-input {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-primary);
    padding: 1.5rem;
    font-family: 'Fira Code', 'Monaco', 'Consolas', monospace;
    font-size: 0.95rem;
    line-height: 1.6;
    resize: none;
    outline: none;
}

.preview-pane {
    background: #ffffff; /* Contrast white for reading */
    color: #1a1a1a;
}

.preview-pane .pane-header {
    background: #f8fafc;
    border-bottom: 1px solid #e2e8f0;
    color: #64748b;
}

#preview-container {
    flex: 1;
    overflow-y: auto;
    padding: 2.5rem;
    color: #1a202c;
    line-height: 1.7;
}

/* Markdown Styling */
.markdown-body h1, .markdown-body h2, .markdown-body h3 {
    margin-top: 1.5rem;
    margin-bottom: 1rem;
    font-family: 'Outfit', sans-serif;
    color: #0f172a;
}

.markdown-body h1 { border-bottom: 2px solid #f1f5f9; padding-bottom: 0.5rem; }
.markdown-body hr { border: none; border-top: 2px solid #f1f5f9; margin: 2rem 0; }
.markdown-body ul, .markdown-body ol { padding-left: 1.5rem; margin-bottom: 1rem; }
.markdown-body code { background: #f1f5f9; padding: 0.2rem 0.4rem; border-radius: 4px; font-size: 0.9em; }
.markdown-body pre { background: #1e293b; color: #f8fafc; padding: 1rem; border-radius: 8px; overflow-x: auto; margin: 1rem 0; }
.markdown-body blockquote { border-left: 4px solid var(--accent); padding-left: 1rem; color: #475569; font-style: italic; margin: 1rem 0; }

/* Mermaid Styling */
.mermaid {
    background: white !important;
    display: flex;
    justify-content: center;
    padding: 1rem;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
    margin: 1.5rem 0;
}

/* Fullscreen Mode */
.app-fullscreen .editor-pane,
.app-fullscreen .glass-header,
.app-fullscreen .bg-glow {
    display: none !important;
}

.app-fullscreen .app-container {
    padding: 0;
}

.app-fullscreen .preview-pane {
    border-radius: 0;
    border: none;
    height: 100vh;
}

/* Custom Scrollbar */
.diagram-container {
    position: relative;
    display: inline-block;
    width: 100%;
    margin: 1.5rem 0;
}

.diagram-actions {
    position: absolute;
    top: 10px;
    right: 10px;
    display: flex;
    gap: 0.5rem;
    opacity: 0;
    transition: opacity 0.3s ease;
    z-index: 10;
}

.diagram-container:hover .diagram-actions {
    opacity: 1;
}

.btn-diagram {
    padding: 0.4rem 0.75rem;
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 600;
    color: #475569;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.btn-diagram:hover {
    background: white;
    color: var(--accent);
    transform: translateY(-1px);
}

.btn-diagram:active {
    transform: translateY(0);
}

/* Hide actions in print */
@media print {
    .diagram-actions, .pane-controls {
        display: none !important;
    }
    .diagram-container {
        margin: 1rem 0;
    }
}

::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: rgba(124, 77, 255, 0.2);
    border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--accent);
}

/* Print Styles */
@media print {
    body { background: white; color: black; height: auto; overflow: visible; }
    .glass-header, .editor-pane, .bg-glow, .pane-header { display: none !important; }
    .app-container { padding: 0; display: block; height: auto; }
    .main-layout { display: block; }
    .preview-pane { border: none; box-shadow: none; background: transparent; width: 100%; height: auto; }
    #preview-container { overflow: visible; padding: 0; }
    .pane { border: none; }
}

@media (max-width: 900px) {
    .main-layout { flex-direction: column; }
    .app-container { padding: 1rem; }
}
