:root{
--paper:#f6f2ea; --surface:#fffdf8; --ink:#2b2723; --muted:#6b6155;
--faint:#73685a; --rule:#e6dfd0; --rule-strong:#d8cfbb;
--accent:#b04a24; --accent-ink:#8a3a1c; --accent-wash:#f0e4d8;
--bar:rgba(246,242,234,.9); --shadow:rgba(60,40,20,.2);
--serif:Georgia,serif;
--mono:ui-monospace,Menlo,Consolas,'Liberation Mono',monospace;
--measure:42rem;
}
:root[data-theme="dark"]{
--paper:#1b1714; --surface:#252019; --ink:#ece4d6; --muted:#a3988a;
--faint:#9b907e; --rule:#322c25; --rule-strong:#473f35;
--accent:#d2683c; --accent-ink:#e3854f; --accent-wash:#2e2319;
--bar:rgba(27,23,20,.9); --shadow:rgba(0,0,0,.5);
}

* { box-sizing: border-box; }
html { font-size: 18px; }
body {
    margin: 0;
    background: var(--paper);
    color: var(--ink);
    font-family: var(--serif);
    font-size: 1rem;
    line-height: 1.7;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.topbar {
    position: sticky;
    top: 0;
    z-index: 30;
    background: var(--bar);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    border-bottom: 1px solid var(--rule);
    padding: 1rem;
}
.topbar .inner {
    max-width: var(--measure);
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.nav-links a {
    margin-right: 0.2rem;
    color: var(--muted);
    font-weight: 300;
    padding: 0.4rem 0.8rem;
    border-radius: 6px;
    transition: background-color 0.2s ease, color 0.2s ease;
}
.nav-links a:hover { 
    background-color: var(--rule);
    color: var(--ink);
    text-decoration: none;
}
.theme-toggle {
    background: none;
    border: none;
    color: var(--ink);
    cursor: pointer;
    padding: 0.4rem;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s ease;
}
.theme-toggle:hover {
    background-color: var(--rule);
}
.theme-toggle svg {
    width: 20px;
    height: 20px;
}
/* Show sun when in dark mode (suggesting to switch to light) */
html[data-theme="dark"] .moon-icon { display: none; }
html[data-theme="dark"] .sun-icon { display: block; }
/* Show moon when in light mode */
html[data-theme="light"] .sun-icon { display: none; }
html[data-theme="light"] .moon-icon { display: block; }
/* Default if not set */
.sun-icon { display: none; }
.moon-icon { display: block; }

.content {
    max-width: var(--measure);
    margin: 1.5rem auto;
    padding: 0 1rem;
}

h1, h2, h3, h4 { color: var(--ink); font-weight: normal; margin-top: 1rem; }
h1 { font-size: 2.5rem; margin-bottom: 0.5rem; margin-top: 0; }
h2 { font-size: 1.8rem; }
h3 { font-size: 1.4rem; }
h4 { font-size: 1.2rem; }
.meta { color: var(--muted); font-size: 0.9rem; }
.post-header-meta { display: flex; align-items: center; gap: 0.5rem; margin-bottom: 2rem; border-bottom: 1px dashed var(--rule); padding-bottom: 1rem; }
.post-content { padding-bottom: 5rem; }

.share-btn { display: inline-flex; align-items: center; gap: 0.3rem; color: var(--muted); background: none; border: none; cursor: pointer; font-family: var(--sans); font-size: 0.9rem; padding: 0; margin: 0; transition: color 0.2s; }
.share-btn svg { width: 16px; height: 16px; }
.share-btn:hover { color: var(--ink); }
.share-text { opacity: 0; transition: opacity 0.2s; margin-left: 0.5rem; font-style: italic; }
.share-text.show { opacity: 1; color: var(--accent); }

.socials a { margin-right: 1rem; color: var(--muted); }

.posts-list { margin-top: 0; display: flex; flex-direction: column; }
.post-item { padding: 1.5rem 0; margin-bottom: 0; }
.post-item:first-child { padding-top: 0; }
.post-item:not(:last-child) { border-bottom: 1px dashed var(--rule-strong); }
.post-item h3 { margin: 0 0 0.2rem 0; font-size: 1.2rem; font-weight: normal; }
.post-date { font-family: var(--mono); color: var(--faint); font-size: 0.85rem; margin-bottom: 0.5rem; }
.post-item p { margin: 0; color: var(--muted); font-size: 0.95rem; line-height: 1.5; }
.arrow { color: var(--muted); margin-left: 0.5rem; font-size: 1.1rem; }

.works-list { display: flex; flex-direction: column; }
.work-item { padding: 2rem 0; }
.work-item:first-child { padding-top: 0; }
.work-item:not(:last-child) { border-bottom: 1px dashed var(--rule-strong); }
.work-item h3 { margin: 0 0 0.5rem 0; font-size: 1.4rem; font-weight: normal; font-style: italic; color: var(--ink); }
.work-item p { margin: 0 0 1.2rem 0; color: var(--muted); font-size: 1rem; line-height: 1.6; }

/* Notebook Custom Parser Styles */
.nb-markdown { width: 100%; }
.nb-code .highlight { margin-bottom: 0; border-bottom-left-radius: 0; border-bottom-right-radius: 0; }
.nb-outputs { margin-bottom: 1.5rem; border: 2px dotted var(--rule); border-top: none; border-bottom-left-radius: 6px; border-bottom-right-radius: 6px; }
.nb-outputs pre { background: var(--paper); padding: 0.75rem 1rem; color: var(--muted); border: none; margin: 0; font-family: var(--mono); font-size: 0.85rem; overflow-x: auto; border-bottom-left-radius: 6px; border-bottom-right-radius: 6px; }
.nb-error { color: #d73a49 !important; background: #ffebee !important; border: none !important; }
.nb-html { overflow-x: auto; margin-bottom: 1.5rem; padding-top: 1rem; }
.nb-image { margin: 1rem 0 1.5rem 0; max-width: 100%; height: auto; border-radius: 6px; }

/* Code Highlight (Pygments / Markdown) */
.highlight, .codehilite { background-color: var(--surface); padding: 1rem; border-radius: 6px; font-family: var(--mono); font-size: 0.9rem; overflow-x: auto; margin-bottom: 1.5rem; border: none; }
.highlight pre, .codehilite pre { margin: 0; border: none; padding: 0; background: transparent; }
.highlight code, .codehilite code { padding: 0; background: transparent; }
.nb-code.has-outputs .highlight, .nb-code.has-outputs .codehilite { margin-bottom: 0; border-bottom-left-radius: 0; border-bottom-right-radius: 0; }

.code-block-wrapper { position: relative; }
.code-header { position: absolute; top: 0.5rem; right: 0.5rem; display: flex; align-items: center; gap: 0.5rem; opacity: 0; transition: opacity 0.2s; background: var(--bar); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); border: 1px solid var(--rule); border-radius: 4px; padding: 0.2rem 0.4rem; box-shadow: 0 1px 3px var(--shadow); }
.code-block-wrapper:hover .code-header { opacity: 1; }
.code-lang { font-family: var(--mono); font-size: 0.7rem; color: var(--muted); font-weight: bold; }
.copy-btn { background: none; border: none; color: var(--muted); cursor: pointer; padding: 0; margin: 0; display: flex; align-items: center; justify-content: center; transition: color 0.2s; }
.copy-btn:hover { color: var(--ink); }
.copy-btn.copied { color: var(--accent); }

/* Tables (Markdown & Pandas) */
table.dataframe, .content-body table { border-collapse: collapse; width: 100%; margin-bottom: 1.5rem; font-size: 0.9rem; }
table.dataframe th, table.dataframe td, .content-body th, .content-body td { border: 1px dashed var(--rule); padding: 0.75rem; text-align: left; }
table.dataframe th, .content-body th { background-color: var(--surface); color: var(--ink); font-weight: normal; font-family: var(--mono); }

.work-links { display: flex; align-items: center; font-family: var(--mono); font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.05em; }
.work-links a { color: var(--accent); text-decoration: none; font-weight: bold; }
.work-links a:hover { color: var(--accent-ink); text-decoration: underline; }
.work-links .separator { margin: 0 0.8rem; color: var(--rule-strong); }

pre { background: var(--surface); padding: 1rem; border: none; overflow-x: auto; font-family: var(--mono); font-size: 0.9rem; border-radius: 4px; }
code { font-family: var(--mono); background: var(--surface); padding: 0.1rem 0.3rem; border-radius: 3px; }
img { max-width: 100%; height: auto; border-radius: 4px; display: block; margin: 1.5rem 0; }

.discuss {
    margin-top: 3rem;
    padding-top: 1rem;
    border-top: 1px solid var(--rule);
}
.discuss h2 {
    font-size: 1.4rem;
    margin-top: 0;
}

.tree-list {
    list-style-type: disc;
    padding-left: 1.5rem;
    margin-top: 1.5rem;
}
.tree-list > li {
    margin-bottom: 0.8rem;
}
.tree-list ul {
    list-style-type: circle;
    padding-left: 1.5rem;
    margin-top: 0.3rem;
}
.tree-list ul li {
    margin-bottom: 0.2rem;
}
.tree-list .date {
    font-family: var(--mono);
    color: var(--muted);
    margin-right: 0.5rem;
    font-size: 0.9rem;
}

@media (max-width: 600px) {
    html { font-size: 15px; }
    h1 { font-size: 2rem; }
    h2 { font-size: 1.5rem; }
    .content { padding: 0 1.25rem; }
    .nav-links a { padding: 0.4rem 0.4rem; margin-right: 0; }
}
