:root {
    --bg: #ffffff;
    --text: #333333;
    --border-strong: #222222;
    --border-light: #cccccc;
    --footer-text: #777777;
}

/* Automatically switch to dark mode if OS prefers it */
@media (prefers-color-scheme: dark) {
    :root {
        --bg: #111111;
        --text: #e5e5e5;
        --border-strong: #ffffff;
        --border-light: #444444;
        --footer-text: #aaaaaa;
    }
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    max-width: 800px;
    margin: 40px auto;
    padding: 0 20px;
    line-height: 1.6;
    color: var(--text);
    background-color: var(--bg);
}

h1 {
    font-size: 2.2em;
    margin-bottom: 0.2em;
    border-bottom: 2px solid var(--border-strong);
    padding-bottom: 0.3em;
}

h2 {
    margin-top: 1.5em;
    border-bottom: 1px solid var(--border-light);
    padding-bottom: 0.2em;
}

h3 {
    margin-bottom: 0.2em;
}

p {
    margin: 0.5em 0;
}

ul {
    margin: 0.5em 0 1em 1.2em;
}

li {
    margin-bottom: 0.3em;
}

strong {
    font-weight: 600;
}

footer {
    margin-top: 40px;
    padding-top: 10px;
    border-top: 1px solid var(--border-light);
    font-size: 0.9em;
    color: var(--footer-text);
    text-align: center;
}

@media print {
    body {
        margin: 0;
    }
}

/* Make images responsive inside markdown content */
img {
    max-width: 100%;
    height: auto;
    display: block;
}

/* Optional: center standalone markdown images */
p>img:only-child {
    margin: 1em auto;
}

/* If markdown wraps images in links */
a>img {
    max-width: 100%;
    height: auto;
}

.lightbox {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.92);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.lightbox img {
    max-width: 92%;
    max-height: 92%;
    box-shadow: 0 0 25px #000;
    border-radius: 4px;
}

/* Side navigation buttons */
.lightbox button {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255, 255, 255, 0.15);
    border: none;
    color: white;
    font-size: 2rem;
    padding: 0.5em 0.8em;
    cursor: pointer;
    backdrop-filter: blur(4px);
    transition: background 0.2s ease;
}

.lightbox button:hover {
    background: rgba(255, 255, 255, 0.3);
}

.lightbox .prev {
    left: 15px;
}

.lightbox .next {
    right: 15px;
}

/* Make buttons larger on touch devices */
@media (pointer: coarse) {
    .lightbox button {
        font-size: 2.5rem;
        padding: 0.8em 1em;
    }
}

/* Top-right controls container */
.lightbox .top-controls {
    position: absolute;
    top: 15px;
    right: 15px;
    display: flex;
    gap: 10px;
}

/* Open-in-new button */
.lightbox .open-new {
    background: rgba(255, 255, 255, 0.15);
    border: none;
    color: white;
    font-size: 0.9rem;
    padding: 0.5em 0.8em;
    cursor: pointer;
    backdrop-filter: blur(4px);
    transition: background 0.2s ease;
}

.lightbox .open-new:hover {
    background: rgba(255, 255, 255, 0.3);
}