:root {
    --bg-primary: #f8fafc;
    --bg-secondary: #ffffff;
    --border-color: #e2e8f0;
    --text-primary: #0f172a;
    --text-secondary: #64748b;
    --text-tertiary: #94a3b8;
    --accent-color: #2563eb;
    --accent-hover: #1d4ed8;
    --danger-color: #ef4444;
    --sidebar-width: 320px;
}

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

body {
    font-family: 'Plus Jakarta Sans', sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    display: flex;
    height: 100vh;
    overflow: hidden;
}

/* Mobile Header Bar */
.mobile-header {
    display: none;
    height: 56px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    padding: 0 1rem;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    position: fixed;
    top: 0;
    left: 0;
    z-index: 10;
}

.mobile-header .brand {
    margin-bottom: 0;
}

.icon-btn {
    background: transparent;
    border: none;
    color: var(--text-primary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem;
    border-radius: 6px;
}

.icon-btn:hover {
    background: var(--bg-primary);
}

.mobile-close-btn {
    display: none;
}

/* Sidebar Styles */
.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    height: 100%;
    z-index: 100;
    transition: transform 0.3s ease-in-out;
}

.sidebar-header {
    padding: 1.25rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.brand {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--text-primary);
}

.search-box {
    padding: 0.75rem 1.25rem;
    position: relative;
}

.search-box input {
    width: 100%;
    padding: 0.5rem 0.75rem 0.5rem 2.25rem;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background: var(--bg-primary);
    font-size: 0.875rem;
    outline: none;
}

.search-box .search-icon {
    position: absolute;
    left: 1.75rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-tertiary);
}

.post-list {
    flex: 1;
    overflow-y: auto;
    padding: 0.5rem;
}

.post-item {
    padding: 0.875rem 1rem;
    border-radius: 8px;
    cursor: pointer;
    margin-bottom: 0.25rem;
    transition: background 0.15s ease;
}

.post-item:hover {
    background: var(--bg-primary);
}

.post-item.active {
    background: #eff6ff;
    border-left: 3px solid var(--accent-color);
}

.post-item .title {
    font-size: 0.925rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.post-item .date {
    font-size: 0.75rem;
    color: var(--text-tertiary);
}

.sidebar-footer {
    padding: 1rem;
    border-top: 1px solid var(--border-color);
    font-size: 0.75rem;
    color: var(--text-tertiary);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.status-indicator {
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

.status-dot {
    width: 8px;
    height: 8px;
    background-color: #10b981;
    border-radius: 50%;
}

.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(15, 23, 42, 0.4);
    backdrop-filter: blur(2px);
    z-index: 90;
}

/* Main Content Area */
.main-content {
    flex: 1;
    height: 100%;
    overflow-y: auto;
    background: var(--bg-secondary);
    display: flex;
    flex-direction: column;
}

.view-section {
    padding: 2rem;
    max-width: 900px;
    width: 100%;
    margin: 0 auto;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.hidden {
    display: none !important;
}

.view-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}

.view-title {
    font-size: 1.5rem;
    font-weight: 700;
}

.action-bar {
    display: flex;
    gap: 0.75rem;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.6rem 1.2rem;
    border-radius: 6px;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    border: 1px solid transparent;
    transition: all 0.15s ease;
}

.btn-sm {
    padding: 0.4rem 0.6rem;
}

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

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

.btn-secondary {
    background: #fff;
    border-color: var(--border-color);
    color: var(--text-secondary);
}

.btn-secondary:hover {
    background: var(--bg-primary);
}

.btn-danger {
    background: #fef2f2;
    color: var(--danger-color);
    border-color: #fecaca;
}

.btn-danger:hover {
    background: #fee2e2;
}

.btn-new {
    width: 100%;
}

/* Editor Section */
.title-input {
    width: 100%;
    font-size: 1.75rem;
    font-weight: 700;
    border: none;
    border-bottom: 2px solid var(--border-color);
    padding-bottom: 0.5rem;
    outline: none;
    margin-bottom: 1.5rem;
}

.editor-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.ql-toolbar {
    border-radius: 6px 6px 0 0;
    border-color: var(--border-color) !important;
}

.ql-container {
    border-radius: 0 0 6px 6px;
    border-color: var(--border-color) !important;
    min-height: 350px;
    font-size: 1rem;
}

/* Reader View Section */
.reader-container {
    max-width: 750px;
    margin: 0 auto;
    width: 100%;
}

.reader-title {
    font-family: 'Lora', serif;
    font-size: 2.25rem;
    line-height: 1.25;
    margin-bottom: 1rem;
}

.reader-meta {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    color: var(--text-tertiary);
    font-size: 0.875rem;
    margin-bottom: 1.5rem;
}

.divider {
    border: none;
    border-top: 1px solid var(--border-color);
    margin-bottom: 2rem;
}

.reader-content {
    font-family: 'Lora', serif;
    font-size: 1.1rem;
    line-height: 1.8;
    color: #334155;
    word-break: break-word;
}

.reader-content img {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
    margin: 1.5rem 0;
}

/* Empty State */
.empty-state {
    text-align: center;
    margin: auto;
    color: var(--text-secondary);
}

.empty-state h3 {
    margin-top: 1rem;
    font-size: 1.25rem;
    color: var(--text-primary);
}

/* =========================================================
   RESPONSIVE MEDIA QUERIES (MOBILE FIX)
   ========================================================= */
@media (max-width: 768px) {
    body {
        flex-direction: column;
    }

    .mobile-header {
        display: flex;
    }

    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        width: 82vw;
        max-width: 320px;
        height: 100vh;
        transform: translateX(-100%);
        box-shadow: 4px 0 16px rgba(0, 0, 0, 0.15);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .sidebar-overlay.active {
        display: block;
    }

    .sidebar-header {
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
    }

    .sidebar-header .btn-new {
        display: none; /* Accessible via mobile header + button */
    }

    .mobile-close-btn {
        display: flex;
    }

    .main-content {
        margin-top: 56px;
        height: calc(100vh - 56px);
    }

    .view-section {
        padding: 1.25rem;
    }

    .reader-title {
        font-size: 1.75rem;
    }

    .title-input {
        font-size: 1.4rem;
    }

    .ql-toolbar {
        display: flex;
        flex-wrap: wrap;
    }
}