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

:root {
    --slate-50: #f8fafc;
    --slate-100: #f1f5f9;
    --slate-200: #e2e8f0;
    --slate-300: #cbd5e1;
    --slate-400: #94a3b8;
    --slate-500: #64748b;
    --slate-600: #475569;
    --slate-700: #334155;
    --slate-800: #1e293b;
    --slate-900: #0f172a;
    --green-400: #4ade80;
    --green-500: #22c55e;
    --green-600: #16a34a;
    --font-ui: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-mono: 'JetBrains Mono', 'Fira Code', monospace;
}

html, body {
    height: 100%;
    font-family: var(--font-ui);
    background: var(--slate-900);
    color: var(--slate-200);
    overflow: hidden;
}

.header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    height: 56px;
    background: var(--slate-800);
    border-bottom: 1px solid var(--slate-700);
    gap: 16px;
    z-index: 100;
}

.header-left {
    display: flex;
    align-items: center;
    flex-shrink: 0;
}

.logo {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 18px;
    font-weight: 700;
    color: white;
    letter-spacing: -0.5px;
}

.header-center {
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 1;
}

.stats {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 13px;
    color: var(--slate-400);
}

.stat-divider {
    color: var(--slate-600);
}

.header-right {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    border: none;
    border-radius: 8px;
    font-family: var(--font-ui);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s ease;
    white-space: nowrap;
}

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

.btn-primary:hover {
    background: var(--green-600);
    transform: translateY(-1px);
}

.btn-secondary {
    background: var(--slate-700);
    color: var(--slate-200);
}

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

.btn-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 8px;
    background: transparent;
    color: var(--slate-400);
    cursor: pointer;
    transition: all 0.15s ease;
}

.btn-icon:hover {
    background: var(--slate-700);
    color: white;
}

.theme-select {
    padding: 8px 12px;
    border: 1px solid var(--slate-600);
    border-radius: 8px;
    background: var(--slate-700);
    color: var(--slate-200);
    font-family: var(--font-ui);
    font-size: 13px;
    cursor: pointer;
    outline: none;
}

.theme-select:focus {
    border-color: var(--green-500);
}

.main {
    display: flex;
    height: calc(100vh - 56px);
}

.panel {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-width: 0;
}

.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px;
    background: var(--slate-800);
    border-bottom: 1px solid var(--slate-700);
}

.panel-title {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--slate-400);
}

.shortcut-hint {
    font-size: 11px;
    color: var(--slate-500);
    background: var(--slate-700);
    padding: 2px 8px;
    border-radius: 4px;
}

.editor-wrapper {
    flex: 1;
    overflow: hidden;
}

.editor {
    width: 100%;
    height: 100%;
    padding: 20px;
    border: none;
    outline: none;
    resize: none;
    background: var(--slate-900);
    color: var(--slate-100);
    font-family: var(--font-mono);
    font-size: 14px;
    line-height: 1.7;
    tab-size: 4;
}

.editor::placeholder {
    color: var(--slate-600);
}

.resizer {
    width: 4px;
    background: var(--slate-700);
    cursor: col-resize;
    transition: background 0.15s;
}

.resizer:hover, .resizer.active {
    background: var(--green-500);
}

.preview-wrapper {
    flex: 1;
    overflow: auto;
    background: white;
}

.preview {
    padding: 32px 40px;
    min-height: 100%;
    font-family: var(--font-ui);
    font-size: 15px;
    line-height: 1.7;
    color: var(--slate-800);
}

/* Markdown Body Styles */
.markdown-body h1 {
    font-size: 2em;
    font-weight: 700;
    margin: 0 0 16px;
    padding-bottom: 12px;
    border-bottom: 2px solid var(--slate-200);
    color: var(--slate-900);
}

.markdown-body h2 {
    font-size: 1.5em;
    font-weight: 600;
    margin: 24px 0 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--slate-200);
    color: var(--slate-900);
}

.markdown-body h3 {
    font-size: 1.25em;
    font-weight: 600;
    margin: 20px 0 8px;
    color: var(--slate-900);
}

.markdown-body h4, .markdown-body h5, .markdown-body h6 {
    font-weight: 600;
    margin: 16px 0 8px;
    color: var(--slate-900);
}

.markdown-body p {
    margin: 0 0 16px;
}

.markdown-body a {
    color: var(--green-600);
    text-decoration: none;
}

.markdown-body a:hover {
    text-decoration: underline;
}

.markdown-body strong {
    font-weight: 600;
    color: var(--slate-900);
}

.markdown-body em {
    font-style: italic;
}

.markdown-body code {
    font-family: var(--font-mono);
    font-size: 0.9em;
    background: var(--slate-100);
    padding: 2px 6px;
    border-radius: 4px;
    color: var(--slate-700);
}

.markdown-body pre {
    background: var(--slate-900);
    color: var(--slate-100);
    padding: 16px 20px;
    border-radius: 8px;
    overflow-x: auto;
    margin: 0 0 16px;
    line-height: 1.5;
}

.markdown-body pre code {
    background: none;
    padding: 0;
    color: inherit;
    font-size: 13px;
}

.markdown-body blockquote {
    border-left: 4px solid var(--green-500);
    margin: 0 0 16px;
    padding: 12px 20px;
    background: var(--slate-50);
    color: var(--slate-600);
}

.markdown-body ul, .markdown-body ol {
    margin: 0 0 16px;
    padding-left: 28px;
}

.markdown-body li {
    margin-bottom: 4px;
}

.markdown-body table {
    width: 100%;
    border-collapse: collapse;
    margin: 0 0 16px;
}

.markdown-body th, .markdown-body td {
    border: 1px solid var(--slate-200);
    padding: 10px 14px;
    text-align: left;
}

.markdown-body th {
    background: var(--slate-100);
    font-weight: 600;
    color: var(--slate-900);
}

.markdown-body hr {
    border: none;
    height: 2px;
    background: var(--slate-200);
    margin: 24px 0;
}

.markdown-body img {
    max-width: 100%;
    border-radius: 8px;
}

.markdown-body input[type="checkbox"] {
    margin-right: 8px;
    accent-color: var(--green-500);
}

/* Cheatsheet Sidebar */
.cheatsheet-sidebar {
    position: fixed;
    top: 56px;
    right: -340px;
    width: 340px;
    height: calc(100vh - 56px);
    background: var(--slate-800);
    border-left: 1px solid var(--slate-700);
    z-index: 90;
    transition: right 0.25s ease;
    display: flex;
    flex-direction: column;
}

.cheatsheet-sidebar.open {
    right: 0;
}

.cheatsheet-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--slate-700);
}

.cheatsheet-header h3 {
    font-size: 15px;
    font-weight: 600;
    color: white;
}

.close-btn {
    color: var(--slate-400);
}

.cheatsheet-content {
    flex: 1;
    overflow-y: auto;
    padding: 16px 20px;
}

.cheatsheet-section {
    margin-bottom: 20px;
}

.cheatsheet-section h4 {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--green-400);
    margin-bottom: 8px;
}

.cheatsheet-section pre {
    background: var(--slate-900);
    border-radius: 6px;
    padding: 10px 14px;
    font-size: 12px;
    line-height: 1.6;
    color: var(--slate-300);
    font-family: var(--font-mono);
    white-space: pre-wrap;
}

/* Custom CSS Modal */
.custom-css-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 200;
}

.custom-css-modal.open {
    display: flex;
}

.modal-content {
    width: 500px;
    max-height: 80vh;
    background: var(--slate-800);
    border-radius: 12px;
    border: 1px solid var(--slate-700);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--slate-700);
}

.modal-header h3 {
    font-size: 15px;
    font-weight: 600;
    color: white;
}

.custom-css-input {
    flex: 1;
    min-height: 300px;
    padding: 16px 20px;
    border: none;
    outline: none;
    background: var(--slate-900);
    color: var(--slate-100);
    font-family: var(--font-mono);
    font-size: 13px;
    line-height: 1.6;
    resize: vertical;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding: 12px 20px;
    border-top: 1px solid var(--slate-700);
}

/* AdSense Banner */
.adsense-banner {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 90px;
    background: var(--slate-800);
    border-top: 1px solid var(--slate-700);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 50;
}

/* Toast notification */
.toast {
    position: fixed;
    bottom: 110px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: var(--slate-800);
    color: white;
    padding: 10px 20px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    border: 1px solid var(--slate-600);
    opacity: 0;
    transition: all 0.25s ease;
    z-index: 300;
    pointer-events: none;
}

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

.toast.success {
    border-color: var(--green-500);
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--slate-900);
}

::-webkit-scrollbar-thumb {
    background: var(--slate-600);
    border-radius: 4px;
}

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

.preview-wrapper::-webkit-scrollbar-track {
    background: var(--slate-100);
}

.preview-wrapper::-webkit-scrollbar-thumb {
    background: var(--slate-300);
}

/* Print / PDF Export Theme Overrides */
.pdf-theme-default {
    font-family: var(--font-ui);
    color: var(--slate-800);
}

.pdf-theme-github .markdown-body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif;
    color: #24292e;
}

.pdf-theme-dark .markdown-body {
    background: var(--slate-900) !important;
    color: var(--slate-200) !important;
}

.pdf-theme-dark .markdown-body h1,
.pdf-theme-dark .markdown-body h2,
.pdf-theme-dark .markdown-body h3 {
    color: white !important;
}

.pdf-theme-dark .markdown-body pre {
    background: var(--slate-800) !important;
}

.pdf-theme-dark .markdown-body code {
    background: var(--slate-800) !important;
    color: var(--slate-200) !important;
}

.pdf-theme-dark .markdown-body table th,
.pdf-theme-dark .markdown-body table td {
    border-color: var(--slate-600) !important;
}

.pdf-theme-dark .markdown-body table th {
    background: var(--slate-800) !important;
}

.pdf-theme-academic .markdown-body {
    font-family: 'Times New Roman', Times, serif;
    font-size: 12pt;
    line-height: 1.8;
    color: #000;
}

.pdf-theme-academic .markdown-body h1 {
    font-size: 18pt;
    text-align: center;
    margin-bottom: 24pt;
}

.pdf-theme-academic .markdown-body h2 {
    font-size: 14pt;
}

.pdf-theme-academic .markdown-body pre {
    background: #f5f5f5 !important;
    border: 1px solid #ddd;
}

@media (max-width: 900px) {
    .header-right .btn:not(.btn-primary) {
        display: none;
    }
    .header-center {
        display: none;
    }
}
