:root {
    --bg-primary: #0A0D14;
    --bg-secondary: #121824;
    --bg-panel: #05070A;
    --text-primary: #F8FAFC;
    --text-secondary: #94A3B8;
    --text-muted: #64748B;
    --accent: #38BDF8;
    --accent-hover: #0EA5E9;
    --border: rgba(255, 255, 255, 0.08);
    --border-hover: rgba(255, 255, 255, 0.15);
    --radius: 12px;
    --font-ui: 'Inter', sans-serif;
    --font-mono: 'Fira Code', monospace;
    --transition: all 0.2s ease;
}

body.light-mode {
    --bg-primary: #F8FAFC;
    --bg-secondary: #FFFFFF;
    --bg-panel: #F1F5F9;
    --text-primary: #0F172A;
    --text-secondary: #475569;
    --text-muted: #64748B;
    --accent: #2563EB;
    --accent-hover: #1D4ED8;
    --border: rgba(0, 0, 0, 0.1);
    --border-hover: rgba(0, 0, 0, 0.2);
}

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

body {
    background-color: var(--bg-primary);
    color: var(--text-primary);
    font-family: var(--font-ui);
    line-height: 1.6;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}
::-webkit-scrollbar-track {
    background: var(--bg-panel);
}
::-webkit-scrollbar-thumb {
    background: var(--border-hover);
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* Header */
.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 24px 40px;
    border-bottom: 1px solid var(--border);
    background-color: var(--bg-secondary);
}

.header-content h1 {
    font-size: 34px;
    font-weight: 700;
    letter-spacing: -0.02em;
}

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

.header-content p {
    font-size: 16px;
    color: var(--text-secondary);
    margin-top: 4px;
}

.security-badge {
    display: flex;
    align-items: center;
    gap: 8px;
    background-color: rgba(16, 185, 129, 0.1);
    color: #10B981;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 500;
    border: 1px solid rgba(16, 185, 129, 0.2);
}

/* Workspace Grid */
.workspace {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    padding: 24px 40px;
    flex-grow: 1;
    height: calc(100vh - 180px); /* Adjust based on header/ads */
    min-height: 600px;
}

.pane {
    background-color: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.pane-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    background-color: rgba(0,0,0,0.2);
}

.pane-header h2 {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    font-size: 13px;
    font-weight: 500;
    border-radius: 6px;
    cursor: pointer;
    transition: var(--transition);
    border: none;
    font-family: inherit;
}

.btn-primary {
    background-color: var(--accent);
    color: #fff;
}
.btn-primary:hover { background-color: var(--accent-hover); }

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

.btn-outline {
    background: transparent;
    color: var(--text-secondary);
}
.btn-outline:hover {
    color: #EF4444; /* Red for clear */
}

/* Editors & Areas */
.editor-container, .output-container {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    position: relative;
    background-color: var(--bg-panel);
}

textarea {
    width: 100%;
    height: 100%;
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-family: var(--font-mono);
    font-size: 14px;
    line-height: 1.6;
    padding: 24px;
    resize: none;
    outline: none;
}

textarea::placeholder {
    color: var(--text-muted);
}

/* Tabs */
.tabs-header {
    padding: 12px 20px;
}

.tabs {
    display: flex;
    gap: 8px;
}

.tab-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 500;
    padding: 8px 12px;
    cursor: pointer;
    border-radius: 6px;
    transition: var(--transition);
}

.tab-btn:hover {
    color: var(--text-primary);
    background-color: rgba(255,255,255,0.05);
}

.tab-btn.active {
    background-color: rgba(255,255,255,0.1);
    color: var(--text-primary);
}

.utility-actions {
    display: flex;
    gap: 12px;
}

.tab-content {
    display: none;
    height: 100%;
}

.tab-content.active {
    display: block;
}

/* Markdown Preview Styling (GitHub style dark mode) */
#visualPreview {
    padding: 24px;
    overflow-y: auto;
    height: 100%;
    color: var(--text-primary);
}

#visualPreview h1, #visualPreview h2, #visualPreview h3 {
    margin-top: 24px;
    margin-bottom: 16px;
    font-weight: 600;
    border-bottom: 1px solid var(--border);
    padding-bottom: 8px;
}

#visualPreview p { margin-bottom: 16px; }
#visualPreview a { color: var(--accent); text-decoration: none; }
#visualPreview a:hover { text-decoration: underline; }
#visualPreview ul, #visualPreview ol { margin-bottom: 16px; padding-left: 24px; }
#visualPreview code {
    background-color: rgba(255,255,255,0.1);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: var(--font-mono);
    font-size: 0.9em;
}
#visualPreview pre {
    background-color: #000;
    padding: 16px;
    border-radius: 8px;
    overflow-x: auto;
    margin-bottom: 16px;
}
#visualPreview pre code {
    background-color: transparent;
    padding: 0;
}
#visualPreview blockquote {
    border-left: 4px solid var(--border-hover);
    padding-left: 16px;
    color: var(--text-secondary);
    margin-bottom: 16px;
}
#visualPreview table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 16px;
}
#visualPreview th, #visualPreview td {
    border: 1px solid var(--border);
    padding: 8px 12px;
}
#visualPreview th { background-color: rgba(255,255,255,0.05); }

/* Documentation Section */
.documentation {
    padding: 60px 40px;
    max-width: 800px;
    margin: 0 auto;
}

.documentation h2 {
    font-size: 28px;
    text-align: center;
    margin-bottom: 8px;
}

.doc-subtitle {
    text-align: center;
    color: var(--text-secondary);
    margin-bottom: 40px;
}

.accordion {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.accordion-item {
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
    background-color: var(--bg-secondary);
}

.accordion-header {
    width: 100%;
    text-align: left;
    padding: 16px 20px;
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.accordion-header::after {
    content: '+';
    font-size: 20px;
    color: var(--text-muted);
}

.accordion-item.active .accordion-header::after {
    content: '−';
}

.accordion-content {
    padding: 0 20px;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease, padding 0.3s ease;
}

.accordion-item.active .accordion-content {
    padding: 0 20px 20px;
    max-height: 500px; /* arbitrary max height for animation */
}

.accordion-content pre {
    background-color: var(--bg-panel);
    padding: 12px;
    border-radius: 6px;
    margin: 12px 0;
    font-family: var(--font-mono);
    font-size: 13px;
    color: var(--text-secondary);
}

/* AdSense Placeholders */
.ads-container {
    width: 100%;
    display: flex;
    justify-content: center;
    padding: 20px 0;
    background-color: var(--bg-primary);
}

.bottom-ads {
    border-top: 1px solid var(--border);
}

.ads-placeholder {
    width: 728px;
    height: 90px;
    background-color: rgba(255,255,255,0.02);
    border: 1px dashed var(--border-hover);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    font-size: 12px;
    border-radius: 4px;
}

/* Toast */
.toast {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background-color: var(--accent);
    color: #fff;
    padding: 12px 24px;
    border-radius: 30px;
    font-size: 14px;
    font-weight: 500;
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    z-index: 1000;
    box-shadow: 0 10px 20px rgba(0,0,0,0.2);
}

.toast.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

/* Responsive */
@media (max-width: 1024px) {
    .workspace {
        grid-template-columns: 1fr;
        height: auto;
    }
    
    .editor-pane {
        min-height: 400px;
    }
    
    .output-pane {
        min-height: 500px;
    }
    
    .app-header {
        flex-direction: column;
        gap: 16px;
        text-align: center;
    }
}

@media (max-width: 768px) {
    .pane-header.tabs-header {
        flex-direction: column;
        gap: 16px;
        align-items: flex-start;
    }
    
    .ads-placeholder {
        width: 320px;
        height: 100px;
    }
}
