:root {
    --bg:         #f7f7f5;
    --text:       #1e1e1e;
    --muted:      #666;
    --accent:     #005afe;
    --accent-h:   #0044d4;
    --border:     #ddd;
    --surface:    #ececea;
    --btn-fg:     #fff;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg:       #191926;
        --text:     #d0d0cc;
        --muted:    #888;
        --accent:   #7eb3ff;
        --accent-h: #aaceff;
        --border:   #2e2e42;
        --surface:  #22223a;
        --btn-fg:   #111;
    }
}

*, *::before, *::after { box-sizing: border-box; }

#starfield {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: -1;
}

body {
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    font-size: 1rem;
    line-height: 1.75;
    background: var(--bg);
    color: var(--text);
    margin: 0;
    padding: 0 1rem;
}

a             { color: var(--accent); }
a:hover       { color: var(--accent-h); }
img           { max-width: 100%; height: auto; }

h1, h2, h3   { line-height: 1.25; margin-top: 1.5em; }
h1            { font-size: 1.5rem; }
h2            { font-size: 1.25rem; }
h3            { font-size: 1.1rem; color: var(--muted); font-weight: 600; }

code {
    font-size: 0.875em;
    background: var(--surface);
    padding: 0.1em 0.35em;
    border-radius: 3px;
}
pre           { background: var(--surface); padding: 1em; border-radius: 4px; overflow-x: auto; }
pre code      { background: none; padding: 0; }

/* layout */
header, .container {
    max-width: 740px;
    margin: 0 auto;
}

header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.75rem;
    padding: 1.25rem 0;
    border-bottom: 1px solid var(--border);
    margin-bottom: 2.5rem;
}

a.logo svg         { fill: var(--accent); width: 130px; height: auto; display: block; }
a.logo:hover svg   { fill: var(--accent-h); }

nav.header         { display: flex; gap: 0.25rem; flex-wrap: wrap; }
nav.header a {
    text-decoration: none;
    color: var(--muted);
    font-size: 0.9rem;
    text-transform: lowercase;
    padding: 0.25em 0.6em;
    border-radius: 3px;
}
nav.header a:hover { color: var(--text); background: var(--surface); }

/* posts list */
article {
    margin-bottom: 2.5rem;
    padding: 1rem 1rem 2.5rem 1rem;
    border-bottom: 1px solid var(--border);
    background-color: var(--bg);
}
article:last-of-type { border-bottom: none; }

aside { color: var(--muted); font-size: 0.85rem; margin-bottom: 0.25rem; }
aside a { color: var(--muted); }
aside a:hover { color: var(--accent); }

.post-categories, .post-tags { font-size: 0.82rem; color: var(--muted); margin: 0.5em 0; }

/* buttons */
.button-std, a.button-std {
    display: inline-block;
    padding: 0.3em 0.85em;
    background: var(--accent);
    color: var(--btn-fg);
    text-decoration: none;
    border-radius: 3px;
    font-size: 0.85rem;
    border: none;
    cursor: pointer;
}
.button-std:hover, a.button-std:hover {
    background: var(--accent-h);
    color: var(--btn-fg);
}

/* pagination */
.pagination {
    display: flex;
    justify-content: space-between;
    margin-top: 2rem;
}
.pagination a:only-child { margin-left: auto; }

/* images + captions */
.alignleft  { float: left;  margin: 0.25em 1.5em 1em 0;  max-width: 400px; }
.alignright { float: right; margin: 0.25em 0 1em 1.5em;  max-width: 400px; }
.aligncenter, img.aligncenter { display: block; margin: 0 auto; max-width: 85%; }

.image-caption {
    background: var(--surface);
    border-radius: 4px;
    text-align: center;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: flex-start;
    gap: 0.5rem;
    padding: 0.5rem;
}
.image-caption.aligncenter { max-width: 100%; }
.image-caption img { display: block; max-width: 100%; }
/* 2-col grid when there are multiple linked images */
.image-caption:has(a ~ a) a   { width: calc(50% - 0.25rem); max-width: 256px; }
.image-caption:has(a ~ a) img { width: 100%; image-rendering: pixelated; }
.image-caption p { width: 100%; margin: 0.25em 0.6em 0.4em; color: var(--muted); font-size: 0.85rem; }

/* gallery grid */
.gallery-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; margin: 1rem 0 2rem; }
.gallery-item { cursor: pointer; overflow: hidden; border-radius: 3px; }
.gallery-item img { display: block; width: 100%; height: 180px; object-fit: cover; transition: opacity 0.15s; }
.gallery-item:hover img { opacity: 0.8; }

@media (max-width: 600px) {
    .gallery-grid { grid-template-columns: repeat(2, 1fr); }
}

/* lightbox */
#lb { display: none; position: fixed; inset: 0; z-index: 200; align-items: center; justify-content: center; }
#lb.open { display: flex; }
#lb-bg { position: absolute; inset: 0; background: rgba(0,0,0,0.88); }
#lb-panel {
    position: relative; z-index: 1;
    display: flex; flex-direction: column; align-items: center;
    max-width: 90vw; max-height: 90vh; overflow-y: auto;
    padding: 1.25rem; border-radius: 4px;
    background: var(--bg); color: var(--text);
}
#lb-img    { max-width: 100%; max-height: 70vh; object-fit: contain; display: block; }
#lb-caption { margin: 0.75rem 0 0; font-size: 0.9rem; text-align: center; font-weight: 600; }
#lb-desc    { margin: 0.4rem 0 0; font-size: 0.82rem; text-align: center; opacity: 0.75; }
#lb-tools   { list-style: none; padding: 0; margin: 0.5rem 0 0; display: flex; flex-wrap: wrap; justify-content: center; gap: 0 0.25rem; font-size: 0.78rem; opacity: 0.6; }
#lb-tools li + li::before { content: '·'; margin-right: 0.25rem; }
#lb-prev, #lb-next, #lb-close {
    position: absolute; z-index: 2;
    background: rgba(0,0,0,0.5); color: #fff;
    border: none; cursor: pointer; border-radius: 3px;
    font-size: 1.1rem; line-height: 1; padding: 0.5rem 0.7rem;
}
#lb-prev  { left: 1rem;   top: 50%; transform: translateY(-50%); }
#lb-next  { right: 1rem;  top: 50%; transform: translateY(-50%); }
#lb-close { top: 0.75rem; right: 0.75rem; }

/* work index list */
.index-list ul { list-style: none; padding: 0; display: grid; grid-template-columns: repeat(2, 1fr); gap: 1rem; margin: 1rem 0; }
.index-list li { background: var(--surface); border-radius: 4px; padding: 1rem; }
.index-list li a { display: block; font-weight: 600; font-size: 1.05rem; margin-bottom: 0.4rem; text-decoration: none; }
.index-list li a:hover { color: var(--accent-h); }
.index-desc { margin: 0; font-size: 0.88rem; color: var(--muted); line-height: 1.5; }

@media (max-width: 600px) {
    .index-list ul { grid-template-columns: 1fr; }
}

/* table of contents */
.toc             { border-left: 2px solid var(--border); padding: 0.4em 0 0.4em 1em; margin-bottom: 2em; font-size: 0.9rem; }
.toc ul          { list-style: none; padding: 0; margin: 0; }
.toc ul ul       { padding-left: 1em; }
.toc a           { color: var(--muted); text-decoration: none; }
.toc a:hover     { color: var(--accent); }
.toc > ul > li > a  { display: none; }
.toc > ul > li > ul { padding-left: 0; }

/* key buttons */
.key-button {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 3px;
    padding: 1px 5px;
    font-size: 0.8em;
    white-space: nowrap;
}

/* file icons */
a.file-icon { padding-left: 22px; background-repeat: no-repeat; background-position: 2px center; }
a.icon-zip         { background-image: url(/images/icon-zip.png); }
a.icon-aco         { background-image: url(/images/icon-aco.png); }
a.icon-vssettings  { background-image: url(/images/icon-vssettings.png); }

/* footer */
.container > footer {
    display: flex;
    justify-content: space-between;
    padding: 1.25rem 0;
    border-top: 1px solid var(--border);
    color: var(--muted);
    font-size: 0.82rem;
    margin-top: 2rem;
}

/* responsive */
@media (max-width: 600px) {
    header { flex-direction: column; align-items: flex-start; }
    .alignleft, .alignright { float: none; display: block; margin: 1em auto; max-width: 100%; }
}
