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

:root {
    --bg-primary: #f8fafc;
    --bg-secondary: #ffffff;
    --bg-elevated: #f1f5f9;
    --border-color: #e2e8f0;
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-tertiary: #94a3b8;
    --accent-primary: #43b0b3;
    --accent-hover: #359396;
    --accent-glow: rgba(67, 176, 179, 0.15);
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --shadow: 0 2px 12px rgba(15, 23, 42, 0.08);
    --shadow-lg: 0 8px 32px rgba(15, 23, 42, 0.12);
    --sidebar-bg: #1e293b;
    --sidebar-text: #cbd5e1;
    --sidebar-text-muted: #64748b;
    --sidebar-active-bg: rgba(67, 176, 179, 0.15);
    --sidebar-active-text: #43b0b3;
    --sidebar-hover-bg: rgba(255, 255, 255, 0.06);
    --sidebar-border: rgba(255, 255, 255, 0.08);
}

body {
    font-family: 'DM Sans', -apple-system, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    overflow-x: hidden;
}

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

/* ── Sidebar ── */
.sidebar {
    width: 260px;
    background: var(--sidebar-bg);
    border-right: 1px solid rgba(255,255,255,0.05);
    padding: 1.5rem 0;
    position: fixed;
    height: 100vh;
    overflow-y: auto;
    z-index: 100;
}

.logo {
    font-family: 'Crimson Pro', serif;
    font-size: 1.5rem;
    font-weight: 700;
    padding: 0 1.5rem 1.5rem;
    letter-spacing: -0.02em;
    color: #ffffff;
    border-bottom: 1px solid var(--sidebar-border);
    margin-bottom: 0.5rem;
}

.logo span {
    display: inline-block;
    width: 8px;
    height: 8px;
    background: var(--accent-primary);
    border-radius: 50%;
    margin-left: 4px;
    vertical-align: middle;
    margin-bottom: 3px;
}

.nav-section {
    margin: 0.25rem 0;
    padding: 0.75rem 0 0.25rem;
}

.nav-label {
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--sidebar-text-muted);
    padding: 0 1.5rem;
    margin-bottom: 0.375rem;
}

.nav-item {
    padding: 0.625rem 1.5rem;
    color: var(--sidebar-text);
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    transition: all 0.15s ease;
    border-left: 3px solid transparent;
    cursor: pointer;
    font-size: 0.9rem;
}

.nav-item:hover {
    background: var(--sidebar-hover-bg);
    color: #ffffff;
    border-left-color: rgba(67, 176, 179, 0.4);
}

.nav-item.active {
    background: var(--sidebar-active-bg);
    color: var(--sidebar-active-text);
    border-left-color: var(--accent-primary);
    font-weight: 500;
}

.nav-icon {
    font-size: 1rem;
    width: 1.25rem;
    text-align: center;
    flex-shrink: 0;
}

/* ── Main Content ── */
.main-content {
    margin-left: 260px;
    flex: 1;
    padding: 2rem 2.5rem;
    max-width: calc(100vw - 260px);
    background: var(--bg-primary);
    min-height: 100vh;
}

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

.page-title {
    font-family: 'Crimson Pro', serif;
    font-size: 2rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--text-primary);
}

/* ── Buttons ── */
.btn {
    padding: 0.625rem 1.25rem;
    border-radius: 8px;
    border: none;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s ease;
    font-size: 0.9rem;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    font-family: inherit;
}

.btn-primary {
    background: var(--accent-primary);
    color: white;
    box-shadow: 0 2px 8px rgba(67, 176, 179, 0.3);
}

.btn-primary:hover {
    background: var(--accent-hover);
    box-shadow: 0 4px 14px rgba(67, 176, 179, 0.35);
    transform: translateY(-1px);
}

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

.btn-secondary:hover {
    border-color: var(--accent-primary);
    color: var(--accent-primary);
    background: var(--bg-elevated);
}

.btn-secondary.active {
    border-color: var(--accent-primary);
    color: var(--accent-primary);
    background: var(--accent-glow);
}

.btn-small {
    padding: 0.4rem 0.875rem;
    font-size: 0.8125rem;
}

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

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

/* ── Content Grid ── */
.content-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.25rem;
    margin-bottom: 2rem;
}

.card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 1.25rem;
    transition: all 0.2s ease;
    box-shadow: var(--shadow);
    animation: fadeIn 0.25s ease;
}

.card:hover {
    border-color: var(--accent-primary);
    box-shadow: var(--shadow-lg);
    transform: translateY(-2px);
}

.card-image {
    width: 100%;
    height: 160px;
    background: var(--bg-elevated);
    border-radius: 8px;
    margin-bottom: 1rem;
    object-fit: cover;
}

.card-title {
    font-size: 1.125rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    font-family: 'Crimson Pro', serif;
    color: var(--text-primary);
}

.card-meta {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
    font-size: 0.8125rem;
    color: var(--text-tertiary);
    margin-bottom: 0.75rem;
}

.card-excerpt {
    color: var(--text-secondary);
    font-size: 0.875rem;
    line-height: 1.6;
    margin-bottom: 1rem;
}

.card-actions {
    display: flex;
    gap: 0.5rem;
    padding-top: 0.875rem;
    border-top: 1px solid var(--border-color);
}

.badge {
    display: inline-block;
    padding: 0.2rem 0.625rem;
    border-radius: 6px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.badge-draft {
    background: #f1f5f9;
    color: #64748b;
}

.badge-published {
    background: rgba(16, 185, 129, 0.1);
    color: #059669;
}

/* ── Modal ── */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.5);
    backdrop-filter: blur(4px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 2rem;
    overflow-y: auto;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 2rem;
    max-width: 960px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
    margin: auto;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.75rem;
    padding-bottom: 1.25rem;
    border-bottom: 1px solid var(--border-color);
}

.modal-title {
    font-family: 'Crimson Pro', serif;
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--text-primary);
}

.close-btn {
    background: none;
    border: none;
    color: var(--text-tertiary);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0.375rem;
    line-height: 1;
    border-radius: 6px;
    transition: all 0.15s;
}

.close-btn:hover {
    color: var(--text-primary);
    background: var(--bg-elevated);
}

/* ── Forms ── */
.form-group {
    margin-bottom: 1.25rem;
}

.form-label {
    display: block;
    margin-bottom: 0.375rem;
    font-weight: 500;
    font-size: 0.875rem;
    color: var(--text-primary);
}

.form-input,
.form-select,
.form-textarea {
    width: 100%;
    padding: 0.75rem 1rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 0.9rem;
    font-family: inherit;
    transition: all 0.15s ease;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.form-textarea {
    min-height: 120px;
    resize: vertical;
}

.form-hint {
    font-size: 0.8rem;
    color: var(--text-tertiary);
    margin-top: 0.3rem;
}

/* ── Rich Text Editor ── */
.editor-container {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    overflow: hidden;
}

.ql-toolbar {
    background: var(--bg-elevated) !important;
    border: none !important;
    border-bottom: 1px solid var(--border-color) !important;
}

.ql-container {
    background: var(--bg-secondary) !important;
    border: none !important;
    font-size: 1rem;
    min-height: 300px;
}

.ql-editor {
    color: var(--text-primary);
    min-height: 300px;
}

.ql-editor.ql-blank::before {
    color: var(--text-tertiary);
}

.ql-stroke {
    stroke: var(--text-secondary) !important;
}

.ql-fill {
    fill: var(--text-secondary) !important;
}

.ql-picker-label {
    color: var(--text-secondary) !important;
}

.ql-toolbar button:hover .ql-stroke,
.ql-toolbar button.ql-active .ql-stroke {
    stroke: var(--accent-primary) !important;
}

.ql-toolbar button:hover .ql-fill,
.ql-toolbar button.ql-active .ql-fill {
    fill: var(--accent-primary) !important;
}

.ql-customHtml:after {
    content: '<>';
    font-weight: bold;
    font-size: 14px;
}

/* ── Image Picker ── */
.image-picker {
    display: flex;
    gap: 1rem;
    align-items: flex-start;
}

.image-preview {
    width: 180px;
    height: 135px;
    border-radius: 8px;
    background: var(--bg-elevated);
    border: 2px dashed var(--border-color);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    position: relative;
}

.image-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.image-preview-placeholder {
    color: var(--text-tertiary);
    font-size: 2.5rem;
}

.image-actions {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

/* ── Media Grid ── */
.media-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 0.875rem;
    margin-top: 1.25rem;
    max-height: 400px;
    overflow-y: auto;
}

.media-item {
    aspect-ratio: 1;
    border-radius: 8px;
    overflow: hidden;
    cursor: pointer;
    position: relative;
    border: 2px solid var(--border-color);
    transition: all 0.15s ease;
    background: var(--bg-elevated);
}

.media-item:hover {
    border-color: var(--accent-primary);
    transform: scale(1.02);
}

.media-item.selected {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.media-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.upload-zone {
    border: 2px dashed var(--border-color);
    border-radius: 10px;
    padding: 2.5rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.15s ease;
    background: var(--bg-elevated);
    margin-bottom: 1.25rem;
    color: var(--text-secondary);
}

.upload-zone:hover,
.upload-zone.dragover {
    border-color: var(--accent-primary);
    background: var(--accent-glow);
    color: var(--accent-primary);
}

.upload-icon {
    font-size: 2.5rem;
    margin-bottom: 0.75rem;
    opacity: 0.6;
}

/* ── Loading ── */
.loading {
    text-align: center;
    padding: 4rem;
    color: var(--text-secondary);
}

.spinner {
    display: inline-block;
    width: 36px;
    height: 36px;
    border: 3px solid var(--border-color);
    border-top-color: var(--accent-primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ── Empty State ── */
.empty-state {
    text-align: center;
    padding: 5rem 2rem;
    color: var(--text-secondary);
}

.empty-state-icon {
    font-size: 3.5rem;
    margin-bottom: 1rem;
    opacity: 0.4;
}

.empty-state-title {
    font-size: 1.375rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

/* ── Mobile Menu ── */
.mobile-menu-btn {
    display: none;
    position: fixed;
    top: 1rem;
    left: 1rem;
    z-index: 200;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 0.55rem 0.7rem;
    cursor: pointer;
    flex-direction: column;
    gap: 5px;
    transition: all 0.15s ease;
    box-shadow: var(--shadow);
}

.mobile-menu-btn span {
    display: block;
    width: 20px;
    height: 2px;
    background: var(--text-primary);
    border-radius: 2px;
    transition: all 0.15s ease;
}

.mobile-menu-btn:hover {
    border-color: var(--accent-primary);
}

/* ── Sidebar Overlay ── */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.4);
    backdrop-filter: blur(2px);
    z-index: 99;
}

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

/* ── Responsive ── */
@media (max-width: 1024px) {
    .mobile-menu-btn {
        display: flex;
    }

    .main-content {
        padding-top: 4.5rem;
        margin-left: 0;
        max-width: 100vw;
        padding-left: 1.25rem;
        padding-right: 1.25rem;
    }

    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.3s ease;
    }

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

    .image-picker {
        flex-direction: column;
    }
}

/* ── Animations ── */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ── Login ── */
.login-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    background: var(--bg-primary);
}

.login-box {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 2.5rem;
    max-width: 420px;
    width: 100%;
    box-shadow: var(--shadow-lg);
}

.login-logo {
    font-family: 'Crimson Pro', serif;
    font-size: 2.25rem;
    font-weight: 700;
    text-align: center;
    margin-bottom: 0.375rem;
    color: var(--text-primary);
}

.login-subtitle {
    text-align: center;
    color: var(--text-tertiary);
    margin-bottom: 2rem;
    font-size: 0.9rem;
}

.error-message {
    background: rgba(239, 68, 68, 0.08);
    border: 1px solid rgba(239, 68, 68, 0.25);
    color: var(--danger);
    padding: 0.75rem;
    border-radius: 8px;
    margin-bottom: 1.25rem;
    font-size: 0.875rem;
    display: none;
}

.error-message.show {
    display: block;
}

.hidden {
    display: none !important;
}

/* ── Account Page ── */
.account-container {
    max-width: 780px;
    margin: 2rem auto;
    padding: 2rem;
}

.account-title {
    font-family: 'Crimson Pro', serif;
    font-size: 2.25rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    margin-bottom: 2rem;
    text-align: center;
    color: var(--text-primary);
}

.account-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 1.75rem;
    margin-bottom: 1.25rem;
    box-shadow: var(--shadow);
    transition: all 0.2s ease;
}

.account-card:hover {
    border-color: var(--accent-primary);
    box-shadow: var(--shadow-lg);
}

.account-card h3 {
    font-family: 'Crimson Pro', serif;
    font-size: 1.375rem;
    font-weight: 600;
    margin-bottom: 1.25rem;
    color: var(--text-primary);
}

.account-form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.account-form label {
    font-weight: 500;
    font-size: 0.875rem;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
}

.account-form input {
    width: 100%;
    padding: 0.75rem 1rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 0.9rem;
    font-family: inherit;
    transition: all 0.15s ease;
}

.account-form input:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.account-button {
    padding: 0.625rem 1.25rem;
    border-radius: 8px;
    border: none;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s ease;
    font-size: 0.9rem;
    background: var(--accent-primary);
    color: white;
    box-shadow: 0 2px 8px rgba(67, 176, 179, 0.3);
    width: 100%;
    font-family: inherit;
}

.account-button:hover {
    background: var(--accent-hover);
    transform: translateY(-1px);
}

.account-button-danger {
    background: var(--danger) !important;
    box-shadow: 0 2px 8px rgba(239, 68, 68, 0.2) !important;
}

.account-button-danger:hover {
    background: #dc2626 !important;
}

.account-info-row {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.875rem 0;
    border-bottom: 1px solid var(--border-color);
}

.account-info-row:last-child {
    border-bottom: none;
}

.account-info-label {
    font-weight: 600;
    min-width: 140px;
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.info-text {
    flex: 1;
    color: var(--text-primary);
}

.info-text input {
    flex: 1;
    width: 100%;
}

.edit-btn {
    background: var(--bg-elevated);
    border: 1px solid var(--border-color);
    padding: 0.4rem 0.6rem;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.15s ease;
    font-size: 0.9rem;
}

.edit-btn:hover {
    border-color: var(--accent-primary);
    background: var(--accent-glow);
}

/* ── Screen Banner ── */
.screen-banner {
    position: fixed;
    top: 1.5rem;
    right: 1.5rem;
    padding: 0.875rem 1.25rem;
    border-radius: 10px;
    background: var(--success);
    color: white;
    font-weight: 500;
    font-size: 0.9rem;
    box-shadow: var(--shadow-lg);
    z-index: 1000;
    opacity: 0;
    transform: translateX(100px);
    transition: all 0.25s ease;
    pointer-events: none;
}

.screen-banner.show {
    opacity: 1;
    transform: translateX(0);
}

.screen-banner.error {
    background: var(--danger);
}

/* ── Back link ── */
.back-link {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-secondary);
    text-decoration: none;
    margin-bottom: 1.75rem;
    padding: 0.4rem 0.875rem;
    border-radius: 8px;
    font-size: 0.875rem;
    transition: all 0.15s ease;
}

.back-link:hover {
    color: var(--accent-primary);
    background: var(--accent-glow);
}
