:root {
    --bg-color: #0d1117;
    --text-color: #c9d1d9;
    --accent-color: #58a6ff;
    --code-bg: #1f2428;
    --border-color: #30363d;
}

body.light-mode {
    --bg-color: #ffffff;
    --text-color: #24292f;
    --accent-color: #0969da;
    --code-bg: #f6f8fa;
    --border-color: #d0d7de;
}

body {
    background-color: var(--bg-color);
    color: var(--text-color);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", monospace;
    line-height: 1.6;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* Header: Top Right Alignment */
.site-header {
    padding: 20px 40px;
    display: flex;
    justify-content: flex-end;
    /* Pushes content to the right */
}

.header-right {
    display: flex;
    align-items: center;
    gap: 20px;
    text-align: right;
}

.brand h1 {
    margin: 0;
    font-size: 1.5rem;
    letter-spacing: 1px;
}

.brand p {
    margin: 0;
    font-size: 0.9rem;
    opacity: 0.7;
}

.brand-link {
    color: inherit;
    text-decoration: none;
}

.brand-link:hover {
    text-decoration: none;
}

#theme-toggle {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-color);
    padding: 0;
}

/* Main Content */
.content {
    flex: 1;
    /* Pushes footer down */
    max-width: 1200px;
    /* <--- CHANGED FROM 800px */
    width: 100%;
    margin: 0 auto;
    padding: 40px 20px;
    box-sizing: border-box;
}

.content img {
    max-width: 100%;
    border: 1px solid var(--border-color);
    border-radius: 4px;
}

pre,
code {
    background-color: var(--code-bg);
    border-radius: 4px;
    font-family: Consolas, monospace;
}

pre {
    padding: 15px;
    overflow-x: auto;
}

code {
    padding: 2px 5px;
}

pre code {
    padding: 0;
}

a {
    color: var(--accent-color);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

/* Post List (Homepage) */
.post-list {
    list-style: none;
    padding: 0;
}

.post-list li {
    margin-bottom: 25px;
}

.post-meta {
    font-size: 0.85rem;
    opacity: 0.7;
    display: block;
}

.post-link {
    font-size: 1.3rem;
    font-weight: bold;
}

.tag {
    background: var(--code-bg);
    border: 1px solid var(--border-color);
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.7rem;
    text-transform: uppercase;
    margin-right: 5px;
}

/* Footer: Bottom Right Alignment */
.site-footer {
    padding: 20px 40px;
    display: flex;
    justify-content: flex-end;
}

.social-links a {
    margin-left: 20px;
    font-weight: bold;
}

/* ---------- Kill Chain flow diagram ---------- */
.killchain {
    margin: 24px 0;
}

.kc-stage {
    border: 1px solid var(--border-color);
    border-left: 3px solid var(--accent-color);
    border-radius: 6px;
    padding: 14px 18px;
    background: var(--code-bg);
}

.kc-title {
    font-weight: bold;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
}

.kc-num {
    color: var(--accent-color);
}

.kc-steps {
    margin: 0;
    padding-left: 18px;
}

.kc-steps li {
    margin: 3px 0;
    font-size: 0.9rem;
    line-height: 1.55;
}

.kc-steps code {
    font-size: 0.85em;
}

.kc-arrow {
    position: relative;
    height: 32px;
    margin: 2px 0;
}

.kc-arrow::before {
    content: "";
    position: absolute;
    top: 0;
    left: 50%;
    width: 2px;
    height: 22px;
    margin-left: -1px;
    background: var(--accent-color);
}

.kc-arrow::after {
    content: "";
    position: absolute;
    top: 18px;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 0;
    border-left: 7px solid transparent;
    border-right: 7px solid transparent;
    border-top: 11px solid var(--accent-color);
}

/* Smooth scrolling for TOC anchor jumps */
html {
    scroll-behavior: smooth;
}

/* ---------- Post Layout ---------- */
.post-title {
    margin: 0 0 12px 0;
    font-size: 2rem;
    line-height: 1.2;
}

.post-header {
    margin-bottom: 32px;
}

.post-meta {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    font-size: 0.85rem;
    opacity: 0.75;
}

/* Two-column body: sticky TOC sidebar + content */
.post-body {
    display: flex;
    gap: 40px;
    align-items: flex-start;
}

.post-content {
    flex: 1;
    min-width: 0;
}

.post-content h1[id],
.post-content h2[id] {
    scroll-margin-top: 24px;
}

/* ---------- Table of Contents ---------- */
.toc {
    flex: 0 0 250px;
    position: sticky;
    top: 20px;
    max-height: calc(100vh - 40px);
    display: flex;
    flex-direction: column;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background: var(--code-bg);
    overflow: hidden;
}

.toc-toggle {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    padding: 12px 16px;
    background: none;
    border: none;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-color);
    font-family: inherit;
    font-size: 0.85rem;
    font-weight: bold;
    letter-spacing: 1px;
    text-transform: uppercase;
    cursor: pointer;
}

.toc-arrow {
    display: none;
}

.toc-list-wrap {
    overflow-y: auto;
    padding: 10px 0;
}

.toc-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.toc-list ul {
    list-style: none;
    margin: 0;
    padding: 0 0 0 12px;
}

.toc-list a {
    display: block;
    padding: 3px 12px;
    font-size: 0.82rem;
    line-height: 1.45;
    color: var(--text-color);
    opacity: 0.75;
    text-decoration: none;
    border-left: 2px solid transparent;
}

.toc-list a:hover {
    opacity: 1;
}

.toc-list a.active {
    opacity: 1;
    color: var(--accent-color);
    border-left-color: var(--accent-color);
}

/* Top-level entries (h1) stand out */
.toc-list > li > a {
    font-weight: bold;
    opacity: 0.9;
}

/* On desktop the TOC header is just a static label (no collapsing). */
@media (min-width: 901px) {
    .toc-toggle {
        cursor: default;
        pointer-events: none;
    }
}

/* Mobile: TOC collapses to a box above the content. */
@media (max-width: 900px) {
    .post-body {
        flex-direction: column;
    }

    .toc {
        position: static;
        flex: none;
        width: 100%;
        max-height: none;
    }

    .toc-arrow {
        display: inline-block;
        transition: transform 0.2s;
    }

    .toc-list-wrap {
        display: none;
    }

    .toc.open .toc-list-wrap {
        display: block;
    }

    .toc.open .toc-arrow {
        transform: rotate(180deg);
    }
}