:root {
    --text: rgb(55, 53, 47);
    --text-muted: rgba(55, 53, 47, 0.65);
    --text-caption: rgba(55, 53, 47, 0.5);
    --bg: #ffffff;
    --bg-callout: rgba(241, 241, 239, 1);
    --bg-hover: rgba(55, 53, 47, 0.06);
    --link-underline: rgba(55, 53, 47, 0.45);
    --link-hover: rgba(55, 53, 47, 0.9);
    --divider: rgba(55, 53, 47, 0.16);
    --shadow: rgba(15, 15, 15, 0.1) 0 0 0 1px, rgba(15, 15, 15, 0.1) 0 2px 4px;
    --code-bg: rgba(135, 131, 120, 0.15);
    --code-color: #eb5757;
    --quote-border: currentColor;
}

@media (prefers-color-scheme: dark) {
    :root {
        --text: rgba(255, 255, 255, 0.9);
        --text-muted: rgba(255, 255, 255, 0.6);
        --text-caption: rgba(255, 255, 255, 0.45);
        --bg: rgb(25, 25, 25);
        --bg-callout: rgba(45, 45, 45, 1);
        --bg-hover: rgba(255, 255, 255, 0.055);
        --link-underline: rgba(255, 255, 255, 0.4);
        --link-hover: rgba(255, 255, 255, 0.9);
        --divider: rgba(255, 255, 255, 0.13);
        --shadow: rgba(0, 0, 0, 0.1) 0 0 0 1px, rgba(0, 0, 0, 0.2) 0 2px 4px;
        --code-bg: rgba(135, 131, 120, 0.15);
        --code-color: #ff7369;
    }
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--text);
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, 'Apple Color Emoji', Arial, sans-serif, 'Segoe UI Emoji', 'Segoe UI Symbol';
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
    font-size: 16px;
    line-height: 1.5;
}

/* ----- Cover ----- */
.cover {
    width: 100%;
    height: 30vh;
    min-height: 180px;
    max-height: 320px;
    overflow: hidden;
    position: relative;
    background: #1f1f1f;
}

.cover img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center 33%;
    display: block;
}

/* ----- Page container ----- */
.page {
    max-width: 708px;
    margin: 0 auto;
    padding: 0 96px 120px;
    position: relative;
}

.page-full-width {
    max-width: 1280px;
    padding-left: 80px;
    padding-right: 80px;
}

.page-header {
    margin-top: -45px;
    margin-bottom: 8px;
}

.page-icon-img {
    width: 96px;
    height: 96px;
    border-radius: 50%;
    object-fit: cover;
    box-shadow: var(--shadow);
    background: var(--bg);
    display: block;
}

.page-title {
    font-size: 40px;
    font-weight: 700;
    line-height: 1.2;
    margin: 16px 0 12px;
    letter-spacing: -0.01em;
}

.intro {
    margin: 0 0 16px;
    padding: 3px 2px;
}

/* ----- Paragraphs / links ----- */
p {
    margin: 0 0 8px;
    padding: 3px 2px;
}

a {
    color: inherit;
    text-decoration: underline;
    text-decoration-color: var(--link-underline);
    text-decoration-thickness: 1px;
    text-underline-offset: 2px;
    transition: text-decoration-color 120ms ease;
}

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

/* ----- Two-column layout ----- */
.columns {
    display: grid;
    grid-template-columns: 25% 75%;
    gap: 22px;
    margin: 14px 0 32px;
    align-items: start;
}

.col { min-width: 0; }

.callout {
    display: flex;
    gap: 9px;
    background: var(--bg-callout);
    border-radius: 4px;
    padding: 14px 14px 14px 12px;
    margin-bottom: 8px;
    line-height: 1.5;
}

.callout-icon {
    flex: 0 0 auto;
    font-size: 18px;
    line-height: 1.5;
    width: 22px;
    text-align: center;
}

.callout-body { flex: 1; min-width: 0; }

.image-block { margin: 0; }

.image-block img {
    display: block;
    width: 100%;
    height: auto;
    border-radius: 2px;
}

.image-block figcaption {
    font-size: 14px;
    color: var(--text-caption);
    margin-top: 8px;
    padding: 0 2px;
}

/* ----- Posts section ----- */
.section-title {
    font-size: 20px;
    font-weight: 600;
    margin: 24px 0 12px;
    letter-spacing: -0.01em;
}

.posts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 14px;
    margin: 0 0 24px;
}

.post-card {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 14px 16px;
    background: var(--bg-callout);
    border-radius: 6px;
    color: inherit;
    text-decoration: none;
    line-height: 1.4;
    transition: background 120ms ease, transform 120ms ease;
}

.post-card:hover {
    background: var(--bg-hover);
    transform: translateY(-1px);
}

.post-card-icon {
    font-size: 18px;
    line-height: 1;
}

.post-card-title {
    font-weight: 600;
    font-size: 15px;
}

.post-card-date {
    font-size: 12px;
    color: var(--text-caption);
}

.post-card-tldr {
    font-size: 13px;
    color: var(--text-muted);
    line-height: 1.45;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* ----- Divider & file card ----- */
.divider {
    border: 0;
    border-top: 1px solid var(--divider);
    margin: 28px 0;
}

.file {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: 4px;
    border: 1px solid var(--divider);
    text-decoration: none;
    color: var(--text);
    transition: background 120ms ease;
    max-width: 480px;
}

.file:hover { background: var(--bg-hover); }

.file-icon {
    width: 28px;
    height: 34px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text);
}

.file-icon svg { width: 28px; height: 34px; }

.file-info {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.file-name {
    font-size: 14px;
    line-height: 1.3;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.file-size {
    font-size: 12px;
    color: var(--text-caption);
    line-height: 1.3;
}

/* ----- Post page ----- */
.post-page .page {
    max-width: 708px;
    padding: 48px 96px 120px;
}

.post-nav {
    margin-bottom: 24px;
}

.post-nav-bottom { margin-top: 24px; }

.back-link {
    font-size: 14px;
    color: var(--text-muted);
    text-decoration: none;
}

.back-link:hover { color: var(--text); }

.post-header {
    margin: 0 0 24px;
}

.post-title {
    font-size: 40px;
    font-weight: 700;
    line-height: 1.2;
    margin: 0 0 6px;
    letter-spacing: -0.01em;
}

.post-date {
    font-size: 14px;
    color: var(--text-caption);
    margin: 0;
}

.post-body h1,
.post-body h2,
.post-body h3 {
    line-height: 1.3;
    letter-spacing: -0.01em;
    margin: 28px 0 6px;
}

.post-body h1 { font-size: 30px; font-weight: 700; }
.post-body h2 { font-size: 24px; font-weight: 600; }
.post-body h3 { font-size: 20px; font-weight: 600; }

.post-body p,
.post-body ul,
.post-body ol {
    margin: 0 0 12px;
}

.post-body ul, .post-body ol {
    padding-left: 1.6em;
}

.post-body li {
    margin: 4px 0;
}

.post-body img {
    max-width: 100%;
    height: auto;
    border-radius: 3px;
    margin: 16px 0 6px;
    display: block;
}

.post-body img + em {
    display: block;
    font-size: 14px;
    color: var(--text-caption);
    margin-bottom: 16px;
}

.post-body blockquote {
    margin: 12px 0;
    padding: 4px 0 4px 14px;
    border-left: 3px solid var(--text);
    font-size: 1.2em;
    line-height: 1.5;
}

.post-body code {
    background: var(--code-bg);
    color: var(--code-color);
    padding: 1px 6px;
    border-radius: 3px;
    font-family: 'SFMono-Regular', Menlo, Consolas, 'PT Mono', 'Liberation Mono', Courier, monospace;
    font-size: 0.85em;
}

.post-body pre {
    background: var(--bg-callout);
    padding: 16px;
    border-radius: 4px;
    overflow-x: auto;
    margin: 12px 0;
}

.post-body pre code {
    background: none;
    color: inherit;
    padding: 0;
    font-size: 0.9em;
}

.post-body hr {
    border: 0;
    border-top: 1px solid var(--divider);
    margin: 24px 0;
}

.loading {
    color: var(--text-muted);
    font-size: 14px;
}

/* ----- Responsive ----- */
@media (max-width: 900px) {
    .page-full-width {
        padding-left: 48px;
        padding-right: 48px;
    }
    .columns {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 700px) {
    .page,
    .page-full-width,
    .post-page .page {
        padding-left: 24px;
        padding-right: 24px;
        padding-bottom: 80px;
    }
    .post-page .page { padding-top: 32px; }
    .page-title, .post-title { font-size: 32px; }
    .cover { height: 24vh; min-height: 150px; }
    .page-icon-img { width: 72px; height: 72px; }
    .page-header { margin-top: -36px; }
    .post-body h1 { font-size: 26px; }
    .post-body h2 { font-size: 22px; }
}
