/* Reset & Base Variables */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    --bg-dark: #1A1A2E;
    --bg-darker: #10101C;
    --primary: #10B981;
    --primary-hover: #059669;
    --accent: #3B82F6;
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --border-color: rgba(255, 255, 255, 0.1);
    
    --glass-bg: rgba(26, 26, 46, 0.6);
    --glass-border: rgba(255, 255, 255, 0.08);
    
    --font-ui: system-ui, -apple-system, sans-serif;
    --font-editor: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    --font-preview: 'Inter', system-ui, sans-serif;
}

body {
    background-color: var(--bg-darker);
    color: var(--text-main);
    font-family: var(--font-ui);
    height: 100vh;
    overflow: hidden;
    background-image: radial-gradient(circle at 50% -20%, rgba(16, 185, 129, 0.05), transparent 40%);
}

.glass-panel {
    background: var(--glass-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--glass-border);
}

.app-container {
    display: flex;
    height: 100vh;
}

/* Sidebar Nav */
.sidebar-nav {
    width: 64px;
    background: rgba(0,0,0,0.3);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 1rem 0;
    z-index: 100;
}

.logo {
    color: var(--primary);
    font-weight: bold;
    font-size: 0.8rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.2rem;
    margin-bottom: 2rem;
}

.logo svg {
    width: 20px;
    height: 20px;
}

.sidebar-nav nav {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    flex: 1;
}

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

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

.nav-btn.active {
    color: var(--primary);
    background: rgba(16, 185, 129, 0.1);
}

.nav-btn svg {
    width: 20px;
    height: 20px;
}

/* Main Content Area */
.main-content {
    flex: 1;
    display: flex;
    overflow: hidden;
}

/* Side Panels */
.side-panel {
    width: 300px;
    border-right: 1px solid var(--border-color);
    padding: 1.5rem;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    transition: width 0.3s ease;
}

.side-panel.hidden {
    display: none;
}

.side-panel h3 {
    font-size: 1rem;
    color: var(--text-main);
    margin-bottom: 1.5rem;
    font-weight: 500;
}

.input-group {
    margin-bottom: 1rem;
}

.input-group label {
    display: block;
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 0.4rem;
}

.input-group input, .input-group textarea {
    width: 100%;
    background: rgba(0,0,0,0.2);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    padding: 0.6rem;
    border-radius: 6px;
    font-family: var(--font-ui);
    outline: none;
}

.input-group textarea {
    resize: vertical;
    min-height: 80px;
}

.input-group input:focus, .input-group textarea:focus {
    border-color: var(--primary);
}

/* Lists and Buttons */
.outline-list {
    list-style: none;
}

.outline-list li {
    padding: 0.4rem 0;
    font-size: 0.9rem;
    color: var(--text-muted);
    cursor: pointer;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.outline-list li:hover {
    color: var(--primary);
}

.outline-list .h1 { padding-left: 0; font-weight: bold; color: var(--text-main); }
.outline-list .h2 { padding-left: 1rem; }
.outline-list .h3 { padding-left: 2rem; font-size: 0.85rem;}

.draft-item {
    padding: 0.8rem;
    background: rgba(0,0,0,0.2);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    margin-bottom: 0.8rem;
    cursor: pointer;
    transition: all 0.2s;
}

.draft-item.active {
    border-color: var(--primary);
    background: rgba(16, 185, 129, 0.05);
}

.draft-title {
    font-weight: 500;
    font-size: 0.9rem;
    margin-bottom: 0.2rem;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.draft-date {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.btn {
    padding: 0.6rem 1rem;
    border-radius: 6px;
    font-weight: 500;
    cursor: pointer;
    border: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    font-size: 0.9rem;
    transition: all 0.2s;
}

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

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

.full-width { width: 100%; }
.mt-1 { margin-top: 1rem; }
.success-msg { color: var(--primary); font-size: 0.85rem; text-align: center; margin-top: 1rem; }

/* Workspace */
.workspace {
    flex: 1;
    display: flex;
    overflow: hidden;
}

.workspace.distraction-free .preview-pane {
    display: none;
}

.workspace.distraction-free .editor-pane {
    max-width: 800px;
    margin: 0 auto;
}

.editor-pane {
    flex: 1;
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--border-color);
}

.toolbar {
    padding: 0.5rem 1rem;
    display: flex;
    align-items: center;
    gap: 0.3rem;
    border-bottom: 1px solid var(--border-color);
    border-radius: 0;
    border-top: none;
    border-left: none;
    border-right: none;
}

.toolbar-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    padding: 0.4rem;
    border-radius: 4px;
    cursor: pointer;
}

.toolbar-btn:hover {
    background: rgba(255,255,255,0.1);
    color: var(--text-main);
}

.toolbar-btn svg { width: 16px; height: 16px; }

.divider {
    width: 1px;
    height: 16px;
    background: var(--border-color);
    margin: 0 0.5rem;
}

.markdown-editor {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-main);
    padding: 2rem;
    font-family: var(--font-editor);
    font-size: 1rem;
    line-height: 1.6;
    resize: none;
    outline: none;
}

.status-bar {
    padding: 0.5rem 1rem;
    font-size: 0.75rem;
    color: var(--text-muted);
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    background: rgba(0,0,0,0.2);
}

.stats {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.divider-dot { color: var(--border-color); }

/* Preview Pane */
.preview-pane {
    flex: 1;
    display: flex;
    flex-direction: column;
    border-radius: 0;
    border: none;
    background: var(--bg-dark);
}

.preview-header {
    padding: 0.8rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.preview-title {
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
}

.toggle-preview-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
}

.toggle-preview-btn:hover { color: var(--text-main); }
.toggle-preview-btn svg { width: 16px; height: 16px; }

.markdown-preview-content {
    flex: 1;
    padding: 2rem;
    overflow-y: auto;
    font-family: var(--font-preview);
    line-height: 1.7;
    font-size: 1.05rem;
    color: #e2e8f0;
}

/* Rendered Markdown Styles */
.markdown-preview-content h1, 
.markdown-preview-content h2, 
.markdown-preview-content h3 {
    margin-top: 1.5em;
    margin-bottom: 0.5em;
    color: var(--text-main);
    font-weight: 600;
}

.markdown-preview-content h1 { font-size: 2.2em; border-bottom: 1px solid var(--border-color); padding-bottom: 0.3em; margin-top: 0;}
.markdown-preview-content h2 { font-size: 1.8em; }
.markdown-preview-content h3 { font-size: 1.4em; }

.markdown-preview-content p { margin-bottom: 1.2em; }

.markdown-preview-content a { color: var(--primary); text-decoration: none; }
.markdown-preview-content a:hover { text-decoration: underline; }

.markdown-preview-content ul, .markdown-preview-content ol { margin-bottom: 1.2em; padding-left: 2em; }
.markdown-preview-content li { margin-bottom: 0.3em; }

.markdown-preview-content blockquote {
    border-left: 4px solid var(--primary);
    padding: 0.5em 1em;
    color: var(--text-muted);
    background: rgba(16, 185, 129, 0.05);
    margin-bottom: 1.2em;
}

.markdown-preview-content pre {
    background: #1a1b26; /* match tokyo night */
    padding: 1rem;
    border-radius: 8px;
    overflow-x: auto;
    margin-bottom: 1.2em;
    border: 1px solid rgba(255,255,255,0.05);
}

.markdown-preview-content code {
    font-family: var(--font-editor);
    font-size: 0.9em;
}

/* Inline code specifically */
.markdown-preview-content p code, .markdown-preview-content li code {
    background: rgba(0,0,0,0.3);
    padding: 0.2em 0.4em;
    border-radius: 4px;
    color: var(--accent);
}

.markdown-preview-content img {
    max-width: 100%;
    border-radius: 8px;
    margin-bottom: 1.2em;
}

.markdown-preview-content table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 1.2em;
}

.markdown-preview-content th, .markdown-preview-content td {
    border: 1px solid var(--border-color);
    padding: 0.6rem;
    text-align: left;
}

.markdown-preview-content th {
    background: rgba(255,255,255,0.05);
}

/* Modals */
.modal-backdrop {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-backdrop.hidden { display: none; }

.modal {
    width: 300px;
    padding: 1.5rem;
}

.modal h3 {
    margin-bottom: 1rem;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.8rem;
    margin-top: 1.5rem;
}
