:root {
    /* Project Vault Dark Theme (Exact Match) */
    --bg-main: #0a0a0c;
    --bg-card: #121216;
    --bg-input: #1c1c21;
    --text-primary: #ffffff;
    --text-secondary: #a0a0b0;
    --accent: #6b21a8;
    --accent-hover: #9333ea;
    --border-color: #27272a;
    --shadow-soft: 0 4px 20px rgba(0, 0, 0, 0.4);
    --danger: #dc2626;
    --success: #16a34a;
}

[data-theme="light"] {
    --bg-main: #f5f6fa;
    --bg-card: #ffffff;
    --bg-input: #f5f6fa;
    --text-primary: #2f3640;
    --text-secondary: #718093;
    --accent: #0984e3;
    --accent-hover: #74b9ff;
    --border-color: #dcdde1;
}

* {
    box-sizing: border-box;
}

body {
    background-color: var(--bg-main);
    color: var(--text-primary);
    font-family: 'Inter', sans-serif;
    margin: 0;
    padding: 0;
    transition: background-color 0.3s, color 0.3s;
}

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

.sidebar {
    flex: 1 1 260px;
    max-width: 100%;
    position: sticky;
    top: 0;
    max-height: 100vh;
    overflow-y: auto;
    padding: 24px;
    z-index: 100;
    border-right: 1px solid var(--border-color);
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-card);
    transition: background-color 0.3s, border-color 0.3s;
}

/* Premium Glassmorphism */
@supports (backdrop-filter: blur(16px)) {
    .sidebar {
        background: rgba(18, 18, 22, 0.75);
        backdrop-filter: blur(16px);
        -webkit-backdrop-filter: blur(16px);
    }
    [data-theme="light"] .sidebar {
        background: rgba(255, 255, 255, 0.85);
    }
}

.sidebar-brand {
    margin-bottom: 24px;
}

.sidebar-brand h2 {
    color: var(--text-primary);
    margin: 0 0 4px 0;
    font-size: 26px;
    font-weight: 800;
    background: linear-gradient(90deg, var(--accent), var(--accent-hover));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.sidebar-brand p {
    color: var(--text-secondary);
    margin: 0;
    font-size: 13px;
    font-weight: 500;
}

.sidebar nav {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.sidebar nav a {
    flex: 1 1 180px;
    color: var(--text-secondary);
    text-decoration: none;
    padding: 12px 16px;
    border-radius: 10px;
    font-weight: 500;
    transition: all 0.25s cubic-bezier(0.25, 0.8, 0.25, 1);
    display: flex;
    align-items: center;
    gap: 10px;
    background: transparent;
    border: 1px solid transparent;
}

.sidebar nav a:hover {
    background: var(--bg-main);
    color: var(--text-primary);
    transform: translateX(4px);
    box-shadow: var(--shadow-soft);
    border-color: var(--border-color);
}

.sidebar nav a.danger {
    color: var(--danger);
}
.sidebar nav a.danger:hover {
    background: rgba(220, 38, 38, 0.1);
    border-color: rgba(220, 38, 38, 0.2);
}

.sidebar hr {
    flex: 1 1 100%;
    border: none;
    border-bottom: 1px solid var(--border-color);
    margin: 10px 0;
}

.theme-switch-wrapper {
    flex: 1 1 180px;
}

.theme-switch {
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    padding: 12px 16px;
    border-radius: 10px;
    cursor: pointer;
    font-family: inherit;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    transition: all 0.25s cubic-bezier(0.25, 0.8, 0.25, 1);
}

.theme-switch:hover {
    background: var(--bg-main);
    color: var(--text-primary);
    border-color: var(--accent);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.theme-switch svg {
    width: 20px;
    height: 20px;
    fill: currentColor;
}

.main {
    flex: 999 1 0%;
    min-width: 320px;
    padding: 40px;
}

.standalone-main {
    max-width: 960px;
    width: 100%;
    min-height: auto;
    margin: 0 auto;
    padding: 32px;
}

.hero {
    background: var(--bg-card);
    padding: 32px;
    border-radius: 14px;
    margin-bottom: 30px;
    border: 1px solid var(--border-color);
    transition: background-color 0.3s, border-color 0.3s;
}

.hero h1 {
    margin: 0 0 10px 0;
    font-size: 34px;
    line-height: 1.15;
    letter-spacing: 0;
}

.hero p {
    color: var(--text-secondary);
    margin: 0;
}

.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
}

.card {
    background: var(--bg-card);
    padding: 30px;
    border-radius: 16px;
    border: 1px solid var(--border-color);
    transition: transform 0.3s cubic-bezier(0.25, 0.8, 0.25, 1), border-color 0.3s, box-shadow 0.3s;
    min-width: 0;
    position: relative;
}
.card:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 30px rgba(0,0,0,0.15);
    border-color: var(--accent);
}

.card h2 {
    margin: 0 0 10px 0;
}

.card p {
    color: var(--text-secondary);
    margin: 0 0 20px 0;
}

.btn {
    background: var(--accent);
    color: #fff;
    border: none;
    padding: 10px 20px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    transition: background 0.2s;
    text-decoration: none;
    display: inline-block;
    text-align: center;
}

.btn:hover {
    background: var(--accent-hover);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(107, 33, 168, 0.4);
}

.atlas-input, .atlas-textarea {
    width: 100%;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 20px;
    font-family: inherit;
    transition: background-color 0.3s, border-color 0.3s, color 0.3s;
}

.atlas-textarea {
    height: 150px;
    resize: vertical;
}

.atlas-editor {
    min-height: 450px;
    resize: vertical;
}

select.atlas-input {
    appearance: none;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th, td {
    border-bottom: 1px solid var(--border-color);
    padding: 10px;
    text-align: left;
}

th {
    color: var(--text-secondary);
}

.table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.form-row {
    display: flex;
    gap: 12px;
    align-items: flex-start;
}

.form-row .atlas-input {
    margin-bottom: 0;
}

.muted {
    color: var(--text-secondary);
}

.success {
    color: var(--success);
}

.danger {
    color: var(--danger);
}

/* Public specific styles */
.public-header { background: var(--bg-card); opacity: 0.95; backdrop-filter: blur(10px); padding: 20px 50px; display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid var(--border-color); position: sticky; top: 0; z-index: 100;}
.public-header h1 { margin: 0; font-size: 24px; font-weight: 800; background: linear-gradient(90deg, var(--text-primary), var(--text-secondary)); -webkit-background-clip: text; -webkit-text-fill-color: transparent; letter-spacing: 0;}
.public-header a { text-decoration: none; }
.public-hero {
    padding: 100px 20px;
    text-align: center;
    background: radial-gradient(circle at top, var(--bg-input) 0%, var(--bg-main) 100%);
    border-bottom: 1px solid var(--border-color);
    position: relative;
    overflow: hidden;
}
.public-hero h1 {
    font-size: 3.5rem;
    font-weight: 800;
    margin-bottom: 20px;
    background: -webkit-linear-gradient(45deg, #fff, #a0a0b0);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    letter-spacing: -2px;
}
.public-hero p { color: var(--text-secondary); font-size: 20px; max-width: 620px; margin: 0 auto; line-height: 1.6;}

.public-container { max-width: 1200px; margin: 60px auto; padding: 0 20px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 40px; }
.article-card { background: var(--bg-card); border: 1px solid var(--border-color); border-radius: 14px; padding: 30px; transition: transform 0.3s cubic-bezier(0.25, 0.8, 0.25, 1), border-color 0.3s, box-shadow 0.3s; cursor: pointer; text-decoration: none; color: inherit; display: flex; flex-direction: column; position: relative; overflow: hidden;}
.article-card::before { content: ''; position: absolute; top: 0; left: 0; width: 100%; height: 4px; background: linear-gradient(90deg, var(--accent), var(--accent-hover)); opacity: 0; transition: opacity 0.3s; }
.article-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 20px rgba(0,0,0,0.4);
    border-color: var(--accent);
}
.article-card:hover::before { opacity: 1; }
.article-card h2 { margin: 0 0 15px 0; font-size: 22px; line-height: 1.4; font-weight: 700; color: var(--text-primary);}
.article-card p { color: var(--text-secondary); font-size: 15px; line-height: 1.6; flex-grow: 1; margin-bottom: 30px;}
.meta { font-size: 13px; color: var(--text-secondary); display: flex; justify-content: space-between; align-items: center; border-top: 1px solid var(--border-color); padding-top: 20px;}

.meta-author { display: flex; align-items: center; gap: 8px;}
.meta-author span { font-weight: 500; color: var(--text-secondary); }
.meta-views { background: var(--bg-input); color: var(--text-primary); padding: 4px 10px; border-radius: 20px; font-weight: 600; border: 1px solid var(--border-color);}

.footer { text-align: center; padding: 60px 20px; color: var(--text-secondary); font-size: 14px; border-top: 1px solid var(--border-color); margin-top: 80px;}

/* Reader specific styles */
.article-container { max-width: 800px; margin: 60px auto; padding: 0 20px; }
.article-title { font-size: 42px; font-weight: 800; line-height: 1.2; margin-bottom: 20px; letter-spacing: -1px; color: var(--text-primary);}
.article-meta { display: flex; align-items: center; gap: 15px; margin-bottom: 40px; padding-bottom: 20px; border-bottom: 1px solid var(--border-color); color: var(--text-secondary); font-size: 14px;}
.author-badge { background: var(--bg-input); color: var(--text-primary); padding: 5px 12px; border-radius: 20px; font-weight: 600; border: 1px solid var(--border-color);}

.article-content { font-size: 18px; line-height: 1.8; color: var(--text-primary); }
.article-content h1, .article-content h2, .article-content h3 { color: var(--text-primary); margin-top: 40px; margin-bottom: 20px; font-weight: 700; }
.article-content h1 { font-size: 32px; letter-spacing: -0.5px;}
.article-content h2, .article-content h3 { 
    border-bottom: 2px solid var(--border-color); 
    padding-bottom: 15px; 
    letter-spacing: -0.5px;
    margin-top: 60px;
    margin-bottom: 30px;
    position: relative;
}
.article-content h2 { font-size: 26px; }
.article-content h3 { font-size: 22px; }

.article-content h2::after, .article-content h3::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    width: 60px;
    height: 2px;
    background: var(--accent);
}
.article-content p { margin-bottom: 25px; color: var(--text-secondary); }
.article-content > p:first-of-type {
    font-size: 20px;
    font-weight: 300;
    line-height: 1.6;
    color: var(--text-primary);
    margin-bottom: 30px;
}
.article-content ul, .article-content ol { margin-bottom: 25px; padding-left: 20px; color: var(--text-secondary);}
.article-content li { margin-bottom: 10px; }
.article-content a { color: var(--accent); text-decoration: none; border-bottom: 1px dashed var(--accent); transition: border-color 0.2s;}
.article-content a:hover { border-bottom-style: solid; }
.article-content strong { color: var(--text-primary); font-weight: 600; }

.article-content blockquote { 
    border-left: 4px solid var(--accent); 
    margin: 30px 0; 
    padding: 20px 25px; 
    background: var(--bg-input); 
    border-radius: 0 8px 8px 0; 
    color: var(--text-secondary); 
    font-style: italic;
    font-size: 19px;
    box-shadow: var(--shadow-soft);
}
.article-content blockquote p { margin: 0; }

.article-content pre { 
    background: #282c34; 
    border: 1px solid rgba(255,255,255,0.1); 
    border-radius: 8px; 
    padding: 40px 20px 20px 20px; 
    overflow-x: auto; 
    margin: 30px 0; 
    position: relative;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
}
.article-content pre::before {
    content: '';
    position: absolute;
    top: 15px;
    left: 15px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #ff5f56;
    box-shadow: 20px 0 0 #ffbd2e, 40px 0 0 #27c93f;
}
.article-content pre code { color: #abb2bf; }
.article-content code { font-family: 'Consolas', monospace; font-size: 14px; color: var(--text-primary); }
.article-content p code, .article-content li code { background: var(--bg-input); padding: 3px 6px; border-radius: 4px; border: 1px solid var(--border-color); font-size: 14px; color: var(--text-primary); }

.article-content img { max-width: 100%; height: auto; border-radius: 12px; margin: 30px 0; border: 1px solid var(--border-color); box-shadow: 0 10px 20px rgba(0,0,0,0.2); }

/* Editor specific styles */
.editor-layout { display: flex; flex-wrap: wrap; gap: 30px; margin-top: 30px; align-items: flex-start; }
.left-panel { flex: 1 1 350px; max-width: 100%; min-width: 0; }
.right-panel { flex: 2 1 500px; max-width: 100%; min-width: 0; }

@media (max-width: 1024px) {
    .editor-layout { flex-direction: column; }
}

.atlas-editor {
    width: 100%;
    height: 400px;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 20px;
    border-radius: 12px;
    margin-bottom: 20px;
    font-family: inherit;
    font-size: 16px;
    line-height: 1.6;
    resize: vertical;
    transition: background-color 0.3s, border-color 0.3s, color 0.3s;
}
.toolbar { display: flex; gap: 15px; margin-top: 25px; flex-wrap: wrap; align-items: center; }
.pipeline { list-style: none; padding: 0; margin: 0; }
.pipeline li { padding: 10px 0; border-bottom: 1px solid var(--border-color); color: var(--text-secondary); }
.pipeline li:last-child { border-bottom: none; }

/* Preview specific styles */
.preview-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 320px;
    gap: 24px;
    align-items: start;
}

.preview-main,
.preview-side {
    min-width: 0;
}

.preview-side {
    display: grid;
    gap: 20px;
}

.edit-actions {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 15px;
}

.edit-actions > div {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.markdown-editor {
    width: 100%;
    min-height: 420px;
    background: var(--bg-input);
    color: var(--text-primary);
    padding: 20px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-family: Consolas, Monaco, monospace;
    margin-bottom: 20px;
}

.login-page {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 24px;
}

.login-card {
    background: var(--bg-card);
    padding: 40px;
    border-radius: 12px;
    width: min(400px, 100%);
    box-shadow: var(--shadow-soft);
    border: 1px solid var(--border-color);
    text-align: center;
}

.login-card h1 {
    margin: 0 0 30px 0;
    color: var(--text-primary);
}

.error-msg {
    background: rgba(231, 76, 60, 0.16);
    color: var(--danger);
    padding: 10px;
    border-radius: 8px;
    margin-bottom: 20px;
    text-align: left;
}

.login-card input {
    width: 100%;
    margin-bottom: 20px;
}

.login-card button {
    width: 100%;
    padding: 15px;
    font-size: 16px;
}

.empty-state {
    grid-column: 1 / -1;
    text-align: center;
    color: var(--text-secondary);
    padding: 80px 20px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 14px;
}

.empty-state h3 {
    margin: 0;
    color: var(--text-primary);
}

/* Responsiveness */
@media (max-width: 1100px) {
    .preview-layout {
        grid-template-columns: 1fr;
    }

    .preview-side {
        grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    }
}

@media (max-width: 768px) {
    /* Fluid layout handles sidebar and main natively */

    .standalone-main {
        padding: 18px;
    }

    .dashboard-grid,
    .grid {
        grid-template-columns: 1fr;
    }

    .card {
        padding: 18px;
    }

    .hero {
        padding: 24px 18px;
        margin-bottom: 20px;
    }

    .hero h1 {
        font-size: 28px;
    }

    .public-header {
        padding: 14px 16px;
    }

    .public-hero {
    padding: 100px 20px;
    text-align: center;
    background: radial-gradient(circle at top, var(--bg-input) 0%, var(--bg-main) 100%);
    border-bottom: 1px solid var(--border-color);
    position: relative;
    overflow: hidden;
}

    .public-hero h1 {
    font-size: 3.5rem;
    font-weight: 800;
    margin-bottom: 20px;
    background: -webkit-linear-gradient(45deg, #fff, #a0a0b0);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    letter-spacing: -2px;
}

    .public-hero p {
        font-size: 16px;
    }

    .public-container,
    .article-container {
        padding: 0 16px;
        margin: 36px auto;
    }

    .article-card {
        padding: 20px;
    }

    .article-title {
        font-size: 32px;
    }

    .article-meta {
        align-items: flex-start;
        flex-direction: column;
        gap: 10px;
    }

    .article-content {
        font-size: 16px;
    }

    .form-row,
    .edit-actions {
        flex-direction: column;
    }

    .form-row .atlas-input,
    .form-row .btn,
    .toolbar .btn,
    .edit-actions .btn,
    .edit-actions > div {
        width: 100%;
    }

    .edit-actions > div {
        justify-content: stretch;
    }
}

@media (max-width: 420px) {
    /* Fluid layout scales padding automatically, but we can override if desired */
    .main { padding: 20px; }

    .standalone-main {
        padding: 14px;
    }

    .card {
        padding: 16px;
    }

    .public-header h1 {
        font-size: 20px;
    }

    .public-hero {
    padding: 100px 20px;
    text-align: center;
    background: radial-gradient(circle at top, var(--bg-input) 0%, var(--bg-main) 100%);
    border-bottom: 1px solid var(--border-color);
    position: relative;
    overflow: hidden;
}

    .public-hero h1 {
    font-size: 3.5rem;
    font-weight: 800;
    margin-bottom: 20px;
    background: -webkit-linear-gradient(45deg, #fff, #a0a0b0);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    letter-spacing: -2px;
}

    .login-page {
        padding: 16px;
    }

    .login-card {
        padding: 28px 20px;
    }
}

/* Public Profile Specifics */
.profile-section {
    padding-top: 40px;
    padding-bottom: 20px;
}
.profile-layout {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 30px;
}
.video-container {
    position: relative;
    width: 100%;
    aspect-ratio: 16 / 9;
    border-radius: 14px;
    overflow: hidden;
    box-shadow: var(--shadow-soft);
    border: 1px solid var(--border-color);
}
.video-container iframe {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
}
.socials-container {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 14px;
    padding: 30px;
    display: flex;
    flex-direction: column;
}
.socials-container h3 {
    margin: 0 0 10px 0;
    color: var(--text-primary);
    font-size: 20px;
}
.socials-container p {
    color: var(--text-secondary);
    font-size: 14px;
    margin-bottom: 25px;
    line-height: 1.5;
}
.social-links {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 12px;
}
.social-btn {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-primary);
    text-decoration: none;
    font-weight: 500;
    transition: all 0.2s ease;
}
.social-btn:hover {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(0,0,0,0.1);
}
@media (max-width: 992px) {
    .profile-layout {
        grid-template-columns: 1fr;
    }
}
