/* Modern Glassmorphic UI Variables */
:root {
    --bg-dark: #0a0c10;
    --glass-bg: rgba(20, 25, 35, 0.4);
    --glass-border: rgba(255, 255, 255, 0.08);
    --glass-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    
    --accent: #6d64f4; /* Vibrant Purple/Blue */
    --accent-hover: #8179f8;
    --accent-glow: rgba(109, 100, 244, 0.5);
    
    --radius: 16px;
    --transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    
    /* Print Variables dynamically set by JS */
    --print-font-size: 6pt;
    --print-columns: 4;
}

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

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background-color: var(--bg-dark);
    /* Animated Gradient Background */
    background: linear-gradient(135deg, #0f121b 0%, #150d1e 50%, #0d1a21 100%);
    background-size: 400% 400%;
    animation: gradientBG 15s ease infinite;
    color: var(--text-main);
    line-height: 1.5;
    height: 100vh;
    overflow: hidden;
    position: relative;
}

@keyframes gradientBG {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

/* Abstract Background Shapes for Glass Effect */
.bg-shape {
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
    z-index: -1;
    opacity: 0.5;
}

.shape-1 {
    width: 600px; height: 600px;
    background: #6d64f4;
    top: -200px; left: -200px;
    animation: float1 20s infinite alternate;
}

.shape-2 {
    width: 500px; height: 500px;
    background: #20aabe;
    bottom: -100px; right: -100px;
    animation: float2 25s infinite alternate;
}

.shape-3 {
    width: 400px; height: 400px;
    background: #bd34fe;
    top: 30%; left: 40%;
    animation: float1 18s infinite alternate-reverse;
    opacity: 0.3;
}

@keyframes float1 {
    0% { transform: translate(0, 0) scale(1); }
    100% { transform: translate(100px, 50px) scale(1.1); }
}

@keyframes float2 {
    0% { transform: translate(0, 0) scale(1); }
    100% { transform: translate(-80px, -60px) scale(1.2); }
}

/* Glassmorphism Classes */
.glass-panel {
    background: var(--glass-bg);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border: 1px solid var(--glass-border);
    box-shadow: var(--glass-shadow);
    border-radius: var(--radius);
}

/* Core Layout */
.app-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    max-width: 1400px;
    margin: 0 auto;
    padding: 1rem;
    gap: 1rem;
    z-index: 10;
}

/* Header */
.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    flex-shrink: 0;
}

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

.logo-content {
    display: flex;
    flex-direction: column;
}

.logo h1 {
    font-family: 'Outfit', sans-serif;
    font-weight: 700;
    font-size: 1.6rem;
    background: linear-gradient(90deg, #fff, #b4b8eb);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    letter-spacing: -0.5px;
    line-height: 1;
}

.logo-subtitle {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 400;
    margin-top: 0.15rem;
}

.dot-separator {
    opacity: 0.5;
}

.credit-link {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    color: var(--accent);
    text-decoration: none;
    font-weight: 500;
    transition: var(--transition);
}

.credit-link:hover {
    color: var(--accent-hover);
    filter: brightness(1.2);
}

.logo svg {
    color: var(--accent);
    flex-shrink: 0;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.6rem 1.25rem;
    border-radius: 12px;
    font-family: 'Outfit', sans-serif;
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
    transition: var(--transition);
    border: none;
    outline: none;
}

.btn-primary {
    background: var(--accent);
    color: white;
}

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

.glow-effect {
    box-shadow: 0 0 10px rgba(109, 100, 244, 0.4);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-main);
    border: 1px solid var(--glass-border);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.1);
    transform: translateY(-1px);
}

.full-width { width: 100%; }
.mt-4 { margin-top: 1rem; }
.mt-5 { margin-top: 1.5rem; }

/* Main Content Area */
.main-content {
    display: flex;
    flex: 1;
    gap: 1rem;
    min-height: 0; /* Important for flex-child scrolling */
}

/* Editor Area - Left */
.editor-area {
    flex: 3;
    display: flex;
    flex-direction: column;
}

.editor-wrapper {
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
}

.panel-header {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--glass-border);
}

.panel-header h2 {
    font-family: 'Outfit', sans-serif;
    font-size: 1.1rem;
    font-weight: 500;
    color: var(--text-muted);
}

.modern-textarea {
    flex: 1;
    width: 100%;
    background: transparent;
    border: none;
    padding: 1.5rem;
    color: var(--text-main);
    font-family: 'Fira Code', monospace;
    font-size: 0.95rem;
    line-height: 1.6;
    resize: none;
    outline: none;
}

/* Custom Scrollbar for Textarea */
.modern-textarea::-webkit-scrollbar {
    width: 8px;
}
.modern-textarea::-webkit-scrollbar-track {
    background: transparent;
}
.modern-textarea::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
}
.modern-textarea::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* Sidebar - Right */
.sidebar {
    flex: 1;
    min-width: 320px;
    display: flex;
    flex-direction: column;
}

.settings-panel, .tips-panel {
    padding: 1.5rem;
}

.sidebar h2 {
    font-family: 'Outfit', sans-serif;
    font-size: 1.15rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: #fff;
}

.divider {
    height: 1px;
    background: var(--glass-border);
    margin: 1.5rem 0;
}

/* Controls */
.control-group {
    margin-bottom: 1.25rem;
}

.control-group label {
    display: flex;
    justify-content: space-between;
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
    font-family: 'Outfit', sans-serif;
}

.control-group label span {
    color: var(--text-main);
    font-weight: 600;
}

.slider {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 6px;
    border-radius: 3px;  
    background: rgba(255,255,255,0.1);
    outline: none;
}

.slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%; 
    background: #fff;
    cursor: pointer;
    box-shadow: 0 0 10px rgba(255,255,255,0.5);
    transition: var(--transition);
}

.slider::-webkit-slider-thumb:hover {
    transform: scale(1.15);
}

/* Custom Toggle Switch */
.toggle-control {
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    cursor: pointer;
}

.toggle-control input {
    display: none;
}

.toggle-slider {
    position: relative;
    width: 44px;
    height: 24px;
    background-color: rgba(255,255,255,0.1);
    border-radius: 20px;
    transition: var(--transition);
    flex-shrink: 0;
}

.toggle-slider::before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: var(--transition);
    border-radius: 50%;
}

.toggle-control input:checked + .toggle-slider {
    background-color: var(--accent);
    box-shadow: 0 0 8px var(--accent-glow);
}

.toggle-control input:checked + .toggle-slider::before {
    transform: translateX(20px);
}

.toggle-text {
    display: flex;
    flex-direction: column;
}

.toggle-text strong {
    font-size: 0.95rem;
    color: var(--text-main);
    font-family: 'Outfit', sans-serif;
}

.toggle-text span {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 2px;
}

/* Tips Panel */
.tips-panel h3 {
    font-size: 1rem;
    color: #e2e8f0;
    margin-bottom: 0.75rem;
}

.tips-panel ul {
    list-style-type: none;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.tips-panel li {
    font-size: 0.85rem;
    color: var(--text-muted);
    display: flex;
    align-items: center;
}

.tips-panel li::before {
    content: "•";
    color: var(--accent);
    margin-right: 0.5rem;
    font-size: 1.2rem;
}

code {
    background: rgba(255,255,255,0.1);
    padding: 2px 4px;
    border-radius: 4px;
    font-family: 'Fira Code', monospace;
    font-size: 0.8em;
    color: #b4b8eb;
}

/* Credits Panel */
.credits-panel {
    padding: 1rem 1.5rem;
    margin-top: auto;
}

.credit-content {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.github-link {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    color: #fff;
    text-decoration: none;
    font-weight: 600;
    font-family: 'Outfit', sans-serif;
    transition: var(--transition);
    padding: 4px 8px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.05);
}

.github-link:hover {
    color: var(--accent);
    background: rgba(109, 100, 244, 0.1);
    transform: translateY(-1px);
}

/* Modal Preview Layout */
.hidden {
    display: none !important;
}

.modal {
    position: fixed;
    top: 0; left: 0; width: 100vw; height: 100vh;
    background: rgba(0,0,0,0.6);
    backdrop-filter: blur(5px);
    z-index: 100;
    display: flex;
    justify-content: center;
    align-items: center;
}

.modal-content {
    width: 90vw;
    height: 90vh;
    display: flex;
    flex-direction: column;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    padding: 1rem;
    border-bottom: 1px solid var(--glass-border);
}

.icon-btn {
    background: none; border: none; font-size: 1.5rem; color: #fff; cursor: pointer;
}

.modal-body {
    flex: 1;
    overflow-y: auto;
    background: white; /* PREVIEW NEEDS TO LOOK LIKE PAPER */
    padding: 10mm;
}

.modal-footer {
    padding: 0.5rem 1rem;
    text-align: center;
    border-top: 1px solid var(--glass-border);
}

.text-xs { font-size: 0.75rem; }

/* -----------------------------------
   DENSE MICRO-CONTENT TYPOGRAPHY 
   (Used strictly for Print and final Render)
   ----------------------------------- */
.micro-document {
    column-count: var(--print-columns);
    column-gap: 3mm;
    font-size: var(--print-font-size);
    font-family: 'Times New Roman', serif;
    line-height: 1.1;
    text-align: left;
    word-wrap: break-word;
    color: #000;
}

/* Markdown Specific Resets for maximum density */
.micro-document h1, .micro-document h2, .micro-document h3, .micro-document h4 {
    font-family: Arial, sans-serif;
    margin: 2px 0;
    line-height: 1.1;
    page-break-after: avoid;
    break-after: avoid;
}

.micro-document h1 { font-size: 1.25em; border-bottom: 0.5px solid #000; }
.micro-document h2 { font-size: 1.15em; font-weight: bold; }
.micro-document h3 { font-size: 1.05em; font-weight: bold; }

.micro-document p {
    margin: 0 0 2px 0;
}

.micro-document ul, .micro-document ol {
    margin: 0 0 2px 0;
    padding-left: 3mm;
}

.micro-document li {
    margin: 0;
    padding: 0;
}

/* Tables in Print - Purely B&W, extreme density */
.micro-document table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 2px;
    font-size: 0.9em;
}

.micro-document th, .micro-document td {
    border: 0.5px solid #000;
    padding: 1px 2px;
    text-align: left;
}

.micro-document th {
    font-weight: bold;
    background-color: transparent !important; /* Save Ink */
}

/* Code Blocks in Print - Purely B&W, monospace */
.micro-document pre {
    margin: 1px 0 2px 0;
    padding: 2px;
    border: 0.5px dashed #666; /* Light dashed border to separate */
    white-space: pre-wrap;
    word-break: break-all;
    page-break-inside: avoid;
    break-inside: avoid;
}

.micro-document code {
    font-family: 'Courier New', Courier, monospace;
    font-size: 0.9em;
    background: none !important;
    color: #000 !important;
    padding: 0;
}

/* KaTeX Override for density */
.micro-document .katex {
    font-size: 1.1em !important; /* KaTeX baseline is sometimes small */
    line-height: 1.1;
}

.micro-document .katex-display {
    margin: 1px 0;
}


/* -----------------------------------
   PRINT MEDIA QUERIES
   ----------------------------------- */
.print-only {
    display: none;
}

@media print {
    @page {
        margin: 5mm; /* Maximize printable area */
        size: auto;
    }
    
    .no-print {
        display: none !important;
    }
    
    .print-only {
        display: block !important;
        width: 100%;
        height: 100%;
    }

    body {
        background: white;
        color: black;
        overflow: visible;
        height: auto;
        /* Strip the glassmorphism gradient for print */
        animation: none;
    }

    #print-container {
        width: 100%;
        background: white;
    }
    
    .micro-document {
        column-count: var(--print-columns);
        font-size: var(--print-font-size);
    }
}
