body {
    background-color: var(--background);
    color: var(--foreground);
    font-family: 'Nunito', sans;
    line-height: 1.6;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
}

img {
    max-width: 100%;
    height: auto;
    border-radius: 4px;
    cursor: pointer;
    transition: transform 0.2s ease;
}

img:hover {
    transform: scale(1.02);
}

figure {
  margin: 2rem 0;
  text-align: center;
}

figure img {
  max-width: 100%;
  height: auto;
}

figcaption {
  font-size: 0.9rem;
  color: var(--accent-1);
  margin-top: 0.5rem;
  opacity: 0.85;
}

pre code {
    display: block;
    padding: 1rem;
    overflow-x: auto;
    background: linear-gradient(145deg, #1b1b1b, #222);
    color: var(--foreground);
    border-radius: 10px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.4);
    line-height: 1.5;
    font-family: 'Fira Code', monospace;
    font-size: 0.95em;
}

code {
    background-color: #1e1e1e;
    color: #ffdd88;
    padding: 0.2em 0.4em;
    border-radius: 4px;
    font-family: 'Fira Code', monospace;
    font-size: 0.95em;
}

main {
    flex: 3;
    min-width: 0;
}

.go-back {
    font-size: 1.5rem;
    display: inline-block;
    margin-bottom: 1rem;
}

.modal {
    display: none;
    position: fixed;
    z-index: 999;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: rgba(0, 0, 0, 0.9);
    justify-content: center;
    align-items: center;
}

.modal-content {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    max-width: 90%;
    margin: auto;
    text-align: center;
}

.modal-caption {
    margin-top: 0.5rem;
    font-size: 0.9rem;
    color: var(--accent-1);
    text-align: center;
    max-width: 90%;
    opacity: 0.85;
    word-wrap: break-word;
    max-width: 100%;
}

.modal img {
    max-width: 90vw;
    max-height: 90vh;
    box-shadow: 0 0 32px black;
}

.close-btn {
    position: absolute;
    top: -2rem;
    right: 0;
    font-size: 2rem;
    color: var(--foreground);
    background: transparent;
    border: none;
    cursor: pointer;
    z-index: 10;
}

#toc {
    position: relative;
    top: unset;
    width: 95%;
    max-width: 600px;
    margin: 0 auto 2rem auto;
    /* center with bottom spacing */
    padding: 1rem;
    border-left: none;
    border-bottom: 4px solid var(--accent-1);
    background-color: var(--background-accent);
    box-sizing: border-box;
}

#toc a.active {
    font-weight: bold;
    text-decoration: underline;
}

aside#toc {
    flex: 1;
    max-width: 250px;
    position: sticky;
    top: 2rem;
    align-self: flex-start;
    background-color: var(--background-accent);
    padding: 1rem;
    border-left: 4px solid var(--accent-1);
    height: fit-content;
}

#toc h2 {
    margin-top: 0;
}

#toc ul {
    list-style: none;
    padding-left: 0;
    margin: 0;
}

#toc li {
    margin-bottom: 0.5rem;
}

#toc li ul {
    padding-left: 1rem;
    margin-top: 0.25rem;
}

#toc a {
    text-decoration: none;
}

@media (max-width: 768px) {
    #toc ul {
        padding: 0 1rem;
    }

    aside#toc {
        position: relative;
        top: unset;
        max-width: 100%;
        margin-bottom: 2rem;
    }

    .go-back {
        font-size: 1.2rem;
    }
}
