:root {
    --bg:         #1a1a1a;
    --bg-sidebar: #141414;
    --fg:         #dddddd;
    --dim:        #666666;
    --dim2:       #444444;
    --mono:       "JetBrains Mono", "Fira Code", monospace;
    --sans:       -apple-system, "Inter", Arial, sans-serif;
    --sidebar-w:  320px;
    --toc-w:      210px;
}

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

html { font-size: 18px; }

body {
    font-family: var(--sans);
    background: var(--bg);
    color: var(--fg);
    line-height: 1.8;
    display: grid;
    grid-template-columns: var(--sidebar-w) 1fr;
    grid-template-rows: 1fr auto;
    min-height: 100vh;
}

/* ── Sidebar ─────────────────────────────────── */

#preamble {
    grid-column: 1;
    grid-row: 1 / 3;
    background: var(--bg-sidebar);
    border-right: 1px solid var(--dim2);
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
}

#preamble a { text-decoration: none; }

.site-sidebar {
    display: flex;
    flex-direction: column;
    height: 100%;
    padding: 2.8em 2em;
}

.sidebar-top {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.sidebar-avatar {
    width: 140px;
    height: 140px;
    border-radius: 50%;
    background: var(--dim2);
    color: var(--fg);
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--mono);
    font-size: 1.8rem;
    font-weight: 600;
    margin-bottom: 1.5em;
    letter-spacing: 0.05em;
    overflow: hidden;
    border: 2px solid var(--dim2);
    flex-shrink: 0;
}

.sidebar-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.sidebar-brand {
    text-align: center;
    margin-bottom: 2em;
    width: 100%;
}

.sidebar-brand a {
    display: block;
    font-size: 1.7rem;
    font-weight: 700;
    line-height: 1.25;
    color: var(--fg);
}

.sidebar-tagline {
    display: block;
    font-size: 0.82rem;
    color: var(--dim);
    margin-top: 0.55em;
    font-style: italic;
}

/* Nav aligné à gauche */
.sidebar-nav {
    display: flex;
    flex-direction: column;
    align-self: flex-start;
    width: 100%;
    gap: 0.1em;
    margin-bottom: 2em;
}

.sidebar-nav a {
    font-size: 1rem;
    color: var(--dim);
    padding: 0.35em 0;
    transition: color 0.1s;
}

.sidebar-nav a:hover { color: var(--fg); }

/* Séparateur bas */
.sidebar-bottom {
    padding-top: 1.8em;
    border-top: 1px solid var(--dim2);
    width: 100%;
}

.sidebar-quote {
    font-size: 0.82rem;
    color: var(--dim);
    font-style: italic;
    line-height: 1.55;
    margin-bottom: 1.5em;
    padding-left: 0.8em;
    border-left: 2px solid var(--dim2);
}

.sidebar-quote cite {
    display: block;
    font-style: normal;
    font-size: 0.75rem;
    margin-top: 0.3em;
    color: var(--dim2);
}

.sidebar-social {
    display: flex;
    flex-wrap: wrap;
    gap: 1em;
    margin-bottom: 1.2em;
}

.sidebar-social a {
    color: var(--dim);
    display: flex;
    align-items: center;
    transition: color 0.1s;
}

.sidebar-social a:hover { color: var(--fg); }

.sidebar-social svg {
    width: 18px;
    height: 18px;
    fill: currentColor;
}

.sidebar-copy {
    font-family: var(--mono);
    font-size: 0.68rem;
    color: var(--dim2);
    line-height: 1.6;
}

/* ── Contenu principal ───────────────────────── */

#content {
    grid-column: 2;
    grid-row: 1;
    width: 100%;
    max-width: 860px;
    padding: 3.5em 4em 5em;
}

/* ── Footer ──────────────────────────────────── */

#postamble {
    grid-column: 2;
    grid-row: 2;
    padding: 1.2em 3.5em;
    border-top: 1px solid var(--dim2);
    font-family: var(--mono);
    color: var(--dim);
    font-size: 0.75rem;
}

/* ── Headings ────────────────────────────────── */

h1, h2, h3, h4, h5, h6 {
    font-weight: 600;
    line-height: 1.35;
    color: var(--fg);
}

h1.title { font-size: 1.6rem; margin-bottom: 0.3em; }
h2 { font-size: 1.05rem; margin: 2em 0 0.5em; }
h3 { font-size: 0.95rem; margin: 1.6em 0 0.4em; color: var(--dim); }
h4 { font-size: 0.88rem; margin: 1.4em 0 0.35em; color: var(--dim); }

/* ── Typographie ─────────────────────────────── */

p { margin: 0.8em 0; }

a {
    color: var(--fg);
    text-decoration: underline;
    text-decoration-color: var(--dim2);
    text-underline-offset: 3px;
    transition: text-decoration-color 0.1s;
}

a:hover { text-decoration-color: var(--fg); }

/* ── Code ────────────────────────────────────── */

pre {
    font-family: var(--mono);
    background: #0e0e0e;
    border: 1px solid var(--dim2);
    border-radius: 3px;
    padding: 1em 1.2em;
    overflow-x: auto;
    margin: 1.2em 0;
    font-size: 0.82rem;
    line-height: 1.6;
}

code { font-family: var(--mono); font-size: 0.87em; }

p code, li code {
    background: #0e0e0e;
    border: 1px solid var(--dim2);
    border-radius: 2px;
    color: var(--fg);
    padding: 0.1em 0.4em;
}

/* ── Listes ──────────────────────────────────── */

ul, ol { margin: 0.8em 0; padding-left: 1.4em; }
li { margin: 0.3em 0; }
ul > li::marker, ol > li::marker { color: var(--dim); }

/* ── Blockquote ──────────────────────────────── */

blockquote {
    border-left: 2px solid var(--dim2);
    padding-left: 1.2em;
    margin: 1.2em 0;
    color: var(--dim);
    font-style: italic;
}

/* ── Table ───────────────────────────────────── */

table {
    width: 100%;
    border-collapse: collapse;
    margin: 1.2em 0;
    font-size: 0.88rem;
    font-family: var(--mono);
}

th, td { text-align: left; padding: 0.5em 0.8em; border-bottom: 1px solid var(--dim2); }
th { color: var(--dim); font-weight: 500; font-size: 0.78rem; letter-spacing: 0.04em; text-transform: uppercase; }

/* ── HR ──────────────────────────────────────── */

hr { border: none; border-top: 1px solid var(--dim2); margin: 2.5em 0; }

/* ── Liste d'articles (accueil + blog.html) ──── */

.post-list { list-style: none; padding: 0; margin: 0; }

.post-list li {
    padding: 1.4em 0;
    border-bottom: 1px solid var(--dim2);
}

.post-list li:last-child { border-bottom: none; }

/* Ligne titre · date */
.post-list li > p:first-child {
    font-size: 0.97rem;
    font-weight: 500;
    margin: 0 0 0.4em;
    line-height: 1.4;
}

.post-list li > p:first-child a {
    color: var(--fg);
    text-decoration: none;
}

.post-list li > p:first-child a:hover {
    text-decoration: underline;
    text-decoration-color: var(--dim);
}

/* Date inline */
.post-list li > p:first-child .post-date,
.post-list li > p:first-child {
    color: var(--dim);
}

.post-list li > p:first-child a { color: var(--fg); }

/* Extrait */
.post-list li > p + p {
    font-size: 0.85rem;
    color: var(--dim);
    margin: 0;
    line-height: 1.6;
}

/* ── Post meta (article individuel) ─────────── */

.post-meta {
    font-family: var(--mono);
    color: var(--dim);
    font-size: 0.82rem;
    margin-bottom: 2.5em;
    padding-bottom: 1.2em;
    border-bottom: 1px solid var(--dim2);
}

/* ── Tags ────────────────────────────────────── */

.tag {
    display: inline-block;
    font-family: var(--mono);
    font-size: 0.72rem;
    color: var(--dim);
    border: 1px solid var(--dim2);
    border-radius: 2px;
    padding: 0.1em 0.45em;
    margin-right: 0.3em;
}

/* ── TOC droite ──────────────────────────────── */

body.has-toc {
    grid-template-columns: var(--sidebar-w) 1fr var(--toc-w);
}

#toc-panel {
    grid-column: 3;
    grid-row: 1;
    border-left: 1px solid var(--dim2);
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    padding: 3em 1.4em;
}

#table-of-contents > h2 {
    font-family: var(--mono);
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--dim2);
    font-weight: 500;
    margin-bottom: 1em;
}

#table-of-contents ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

#table-of-contents ul ul {
    padding-left: 0.85em;
    border-left: 1px solid var(--dim2);
    margin: 0.1em 0 0.1em 0.2em;
}

#table-of-contents li { margin: 0; }

#table-of-contents a {
    font-size: 0.8rem;
    color: var(--dim);
    text-decoration: none;
    display: block;
    padding: 0.22em 0;
    line-height: 1.4;
    transition: color 0.1s;
}

#table-of-contents a:hover { color: var(--fg); }

/* ── Misc ────────────────────────────────────── */

::selection { background: var(--dim2); color: var(--fg); }

/* ── Responsive ──────────────────────────────── */

@media (max-width: 1100px) {
    body.has-toc { grid-template-columns: var(--sidebar-w) 1fr; }
    #toc-panel { display: none; }
}

@media (max-width: 800px) {
    body,
    body.has-toc {
        grid-template-columns: 1fr;
        grid-template-rows: auto 1fr auto;
    }

    #preamble {
        grid-column: 1;
        grid-row: 1;
        height: auto;
        position: static;
        border-right: none;
        border-bottom: 1px solid var(--dim2);
    }

    .site-sidebar {
        flex-direction: row;
        align-items: center;
        padding: 1em 1.5em;
        gap: 1.2em;
    }

    .sidebar-top { flex-direction: row; align-items: center; gap: 0.8em; flex: 1; justify-content: space-between; }
    .sidebar-avatar { width: 46px; height: 46px; font-size: 0.9rem; margin-bottom: 0; flex-shrink: 0; }
    .sidebar-tagline { display: none; }
    .sidebar-brand { text-align: left; margin-bottom: 0; flex: 1; }
    .sidebar-brand a { font-size: 1rem; white-space: nowrap; }
    .sidebar-nav { flex-direction: row; gap: 1.2em; margin-bottom: 0; align-self: auto; width: auto; }
    .sidebar-bottom { display: none; }

    #content { grid-column: 1; grid-row: 2; padding: 2em 1.2em 4em; }
    #postamble { grid-column: 1; grid-row: 3; padding: 1.2em; }

    .post-header { flex-direction: column; gap: 0.1em; }
    .post-list li { flex-direction: column; gap: 0.1em; }
}
