:root {
    --bg: #050507;
    --fg: #ffffff;
    --teal: #2dd4bf;
    --burgundy: #9f1239;
    --sans: "IBM Plex Sans", system-ui, sans-serif;
    --mono: "IBM Plex Mono", ui-monospace, monospace;
    /* Frosted-glass surface tokens. */
    --glass: rgba(255, 255, 255, 0.045);
    --glass-strong: rgba(20, 22, 28, 0.55);
    --glass-border: rgba(255, 255, 255, 0.10);
    --glass-blur: 14px;
    --glass-shadow: 0 8px 30px rgba(0, 0, 0, 0.45);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--fg);
    font-family: var(--sans);
    line-height: 1.6;
}

/* Soft colour blooms behind the glass so the blur has something to refract. */
body::before {
    content: "";
    position: fixed;
    inset: 0;
    z-index: -1;
    pointer-events: none;
    background:
        radial-gradient(55rem 55rem at 12% -8%, rgba(45, 212, 191, 0.10), transparent 60%),
        radial-gradient(48rem 48rem at 100% 4%, rgba(159, 18, 57, 0.12), transparent 55%),
        radial-gradient(42rem 42rem at 50% 118%, rgba(56, 189, 248, 0.07), transparent 60%);
}

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

/* Site nav only — scoped so it doesn't hit <header class="post-header"> etc. */
body > header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.5rem;
    position: sticky;
    top: 0;
    z-index: 40;
    border-bottom: 1px solid var(--glass-border);
    background: var(--glass-strong);
    backdrop-filter: blur(var(--glass-blur));
    -webkit-backdrop-filter: blur(var(--glass-blur));
}

.logo {
    color: var(--fg);
    font-weight: 600;
}

nav a {
    font-family: var(--mono);
    margin-left: 1rem;
}

.nav-short {
    display: none;
}

@media (max-width: 48rem) {
    /* Tighten the nav on small screens: shorter "kg" label + less spacing. */
    .nav-full {
        display: none;
    }
    .nav-short {
        display: inline;
    }
    nav a {
        margin-left: 0.7rem;
    }
}

main {
    max-width: 90ch;
    margin: 0 auto;
    padding: 3rem 1.5rem;
}

code {
    font-family: var(--mono);
    color: var(--teal);
}

footer {
    max-width: 90ch;
    margin: 0 auto;
    padding: 2rem 1.5rem;
    text-align: center;
}

.muted {
    color: #9ca3af;
    font-size: 0.9rem;
}

.cta {
    font-family: var(--mono);
}

.hero {
    margin-bottom: 3rem;
}

.lead {
    font-size: 1.15rem;
    max-width: 60ch;
}

.stream {
    margin-bottom: 2.5rem;
}

.stream h2 {
    border-bottom: 1px solid #1a1a1a;
    padding-bottom: 0.4rem;
}

.tiles {
    display: grid;
    gap: 1rem;
}

.tiles-dense {
    gap: 0.4rem;
}

.tile {
    position: relative;
    border: 1px solid var(--glass-border);
    border-radius: 10px;
    padding: 1rem;
    background: var(--glass);
    backdrop-filter: blur(var(--glass-blur));
    -webkit-backdrop-filter: blur(var(--glass-blur));
    box-shadow: var(--glass-shadow);
    transition: border-color 0.2s ease, transform 0.2s ease;
}

.tile:hover {
    border-color: rgba(45, 212, 191, 0.4);
    transform: translateY(-2px);
}

/* Stretch the title link across the whole card so the entire tile is clickable. */
.tile-link::after {
    content: "";
    position: absolute;
    inset: 0;
}

.tile-dense {
    padding: 0.5rem 0.75rem;
}

.tile-title {
    margin: 0;
    font-size: 1.1rem;
}

.tile-subtitle {
    margin: 0.25rem 0 0;
    color: #cbd5e1;
}

.tile-meta {
    display: flex;
    gap: 0.75rem;
    align-items: center;
    margin: 0.5rem 0 0;
}

.badge,
.chip {
    font-family: var(--mono);
    font-size: 0.75rem;
    padding: 0.1rem 0.45rem;
    border-radius: 4px;
    border: 1px solid currentColor;
}

.chip {
    color: #9ca3af;
    margin-right: 0.35rem;
}

/* Placeholder topic hues, refined in the Phase 2 design pass (SoW 7.7). */
.topic-networking { color: #2dd4bf; }
.topic-services   { color: #38bdf8; }
.topic-security   { color: #fb7185; }
.topic-hardware   { color: #fbbf24; }
.topic-systems    { color: #a78bfa; }

.filters {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    font-family: var(--mono);
    font-size: 0.85rem;
    margin-bottom: 1.5rem;
}

.search-form {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin: 1.5rem 0;
}

.search-form input[type="search"] {
    flex: 1 1 16rem;
}

.search-form input,
.search-form select {
    background: #0d0d0d;
    border: 1px solid #333;
    border-radius: 4px;
    color: var(--fg);
    font-family: var(--mono);
    padding: 0.5rem 0.65rem;
}

/* --- knowledge graph --- */
.kg-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
}

.kg-controls {
    display: flex;
    gap: 0.5rem;
}

.kg-controls input,
.kg-controls button {
    font-family: var(--mono);
    font-size: 0.85rem;
}

.kg-controls input {
    background: #0d0d0d;
    border: 1px solid #333;
    border-radius: 4px;
    color: var(--fg);
    padding: 0.4rem 0.6rem;
}

.kg-help {
    margin: 0 0 1rem;
    max-width: 75ch;
    color: #9ca3af;
    font-size: 0.9rem;
}

.kg-graph {
    position: relative;
    width: min(92vw, 1100px);
    margin-left: calc(50% - min(46vw, 550px));
    height: 70vh;
    border-radius: 12px;
    /* Translucent base so the page's colour blooms show through, then frosted —
       matching the rest of the site's glass. The canvas draws on top, so the
       graph's empty space reads as blurred glass. */
    background:
        radial-gradient(60% 60% at 50% 40%, rgba(45, 55, 75, 0.35), transparent 70%),
        rgba(8, 10, 14, 0.5);
    backdrop-filter: blur(var(--glass-blur));
    -webkit-backdrop-filter: blur(var(--glass-blur));
    border: 1px solid var(--glass-border);
    box-shadow: var(--glass-shadow);
    overflow: hidden;
    margin-top: 1.5rem;
}

#kg-canvas {
    display: block;
    cursor: grab;
}

.kg-card {
    position: absolute;
    top: 1rem;
    right: 1rem;
    width: 18rem;
    max-width: 70vw;
    background: var(--glass-strong);
    backdrop-filter: blur(var(--glass-blur));
    -webkit-backdrop-filter: blur(var(--glass-blur));
    border: 1px solid var(--glass-border);
    border-radius: 10px;
    box-shadow: var(--glass-shadow);
    padding: 1rem;
}

.kg-card h3 {
    margin: 0.3rem 0;
    font-size: 1rem;
}

.kg-card-type {
    font-family: var(--mono);
    font-size: 0.75rem;
    margin: 0;
}

.kg-legend {
    position: absolute;
    left: 0.75rem;
    bottom: 0.75rem;
    margin: 0;
    padding: 0.5rem 0.7rem;
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    background: var(--glass-strong);
    backdrop-filter: blur(var(--glass-blur));
    -webkit-backdrop-filter: blur(var(--glass-blur));
    border: 1px solid var(--glass-border);
    border-radius: 8px;
    box-shadow: var(--glass-shadow);
    font-family: var(--mono);
    font-size: 0.72rem;
    pointer-events: none;
}

.kg-legend li {
    display: flex;
    align-items: center;
    gap: 0.45rem;
}

.kg-swatch {
    display: inline-block;
    width: 0.7rem;
    height: 0.7rem;
    border-radius: 50%;
    background: currentColor;
}

.kg-list {
    margin-top: 1.5rem;
}

.kg-group ul {
    list-style: none;
    padding: 0;
}

.kg-group li {
    padding: 0.25rem 0;
}

.filters a.active {
    color: var(--fg);
    text-decoration: underline;
}

.pager {
    display: flex;
    justify-content: space-between;
    margin-top: 2rem;
    font-family: var(--mono);
}

.post-subtitle {
    color: #cbd5e1;
    font-size: 1.15rem;
}

.post-meta {
    display: flex;
    gap: 0.75rem;
    align-items: center;
}

.post-body {
    margin-top: 2rem;
}

/* Keep images within the content column — a 2560px variant must not blow
   out the layout. Applies to published posts and the editor preview. */
.post-body img,
.post-body video {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
    display: block;
    margin: 1rem auto;
}

.post-body audio {
    display: block;
    width: 100%;
    margin: 1rem auto;
}

.post-body pre {
    background: rgba(13, 14, 18, 0.7);
    backdrop-filter: blur(var(--glass-blur));
    -webkit-backdrop-filter: blur(var(--glass-blur));
    border: 1px solid var(--glass-border);
    border-radius: 8px;
    padding: 1rem;
    overflow-x: auto;
}

.post-footer {
    margin-top: 3rem;
    padding-top: 1rem;
    border-top: 1px solid #1a1a1a;
    font-family: var(--mono);
}

.node-ref {
    border: 1px solid var(--glass-border);
    border-left: 3px solid var(--teal);
    border-radius: 6px;
    padding: 0.6rem 0.85rem;
    margin: 1.25rem 0;
    background: var(--glass);
    backdrop-filter: blur(var(--glass-blur));
    -webkit-backdrop-filter: blur(var(--glass-blur));
}

.node-ref summary {
    cursor: pointer;
    font-family: var(--mono);
    font-size: 0.9rem;
}

.node-ref-missing {
    color: #fb7185;
    font-family: var(--mono);
    font-size: 0.85rem;
}

.related {
    margin-top: 3rem;
    border-top: 1px solid #1a1a1a;
    padding-top: 1rem;
}

.related ul {
    list-style: none;
    padding: 0;
}

.related li {
    display: flex;
    gap: 0.6rem;
    align-items: center;
    padding: 0.3rem 0;
}

.reading-progress {
    position: fixed;
    top: 0;
    left: 0;
    height: 3px;
    width: 0;
    background: var(--teal);
    z-index: 50;
}

.share {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 1rem;
}

.share-btn {
    font-family: var(--mono);
    font-size: 0.75rem;
    border: 1px solid var(--glass-border);
    border-radius: 6px;
    padding: 0.3rem 0.6rem;
    background: var(--glass);
    backdrop-filter: blur(var(--glass-blur));
    -webkit-backdrop-filter: blur(var(--glass-blur));
    color: var(--fg);
    cursor: pointer;
    transition: border-color 0.2s ease;
}

.share-btn:hover {
    border-color: rgba(45, 212, 191, 0.5);
}

.toc {
    border: 1px solid var(--glass-border);
    border-radius: 8px;
    padding: 0.6rem 0.9rem;
    margin: 1.5rem 0;
    background: var(--glass);
    backdrop-filter: blur(var(--glass-blur));
    -webkit-backdrop-filter: blur(var(--glass-blur));
}

.toc summary {
    cursor: pointer;
    font-family: var(--mono);
    font-size: 0.85rem;
    color: #9ca3af;
}

.toc ul {
    list-style: none;
    padding: 0.5rem 0 0;
    margin: 0;
    display: grid;
    gap: 0.25rem;
}

.toc .toc-l3 {
    padding-left: 1rem;
    font-size: 0.9rem;
}

/* --- admin --- */
.admin-narrow {
    max-width: 26rem;
    margin: 4rem auto;
    padding: 0 1.5rem;
}

.admin-wide {
    max-width: 60rem;
    margin: 2rem auto;
    padding: 0 1.5rem;
}

/* The post editor needs far more room than other admin pages so the
   write/preview split is usable. */
.admin-editor {
    max-width: min(98vw, 120rem);
}

.admin-form {
    display: grid;
    gap: 1rem;
}

.admin-form label {
    display: grid;
    gap: 0.3rem;
    font-family: var(--mono);
    font-size: 0.85rem;
}

.admin-form input {
    background: #0d0d0d;
    border: 1px solid #333;
    border-radius: 4px;
    color: var(--fg);
    font-family: var(--mono);
    padding: 0.55rem 0.65rem;
}

button {
    background: var(--teal);
    border: none;
    border-radius: 4px;
    color: #000;
    cursor: pointer;
    font-family: var(--mono);
    font-weight: 600;
    padding: 0.55rem 0.9rem;
}

button.danger {
    background: var(--burgundy);
    color: var(--fg);
}

.form-error {
    color: #fb7185;
    font-family: var(--mono);
    font-size: 0.85rem;
}

.totp-secret code {
    font-size: 1.15rem;
    letter-spacing: 0.1em;
    word-break: break-all;
}

.totp-uri code {
    color: #9ca3af;
    word-break: break-all;
}

.admin-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.6rem 1rem;
    border-bottom: 1px solid #1a1a1a;
    padding-bottom: 0.5rem;
}

.admin-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.6rem;
}

.admin-actions form {
    display: inline;
}

.counters {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(8rem, 1fr));
    gap: 1rem;
    margin: 2rem 0;
}

.counter {
    border: 1px solid #1a1a1a;
    border-radius: 6px;
    padding: 1rem;
    display: grid;
    gap: 0.25rem;
}

.counter .num {
    font-size: 1.8rem;
    font-weight: 600;
}

.counter .label {
    color: #9ca3af;
    font-family: var(--mono);
    font-size: 0.8rem;
}

.diff-wrap {
    overflow-x: auto;
    margin-top: 1rem;
}

table.diff {
    font-family: var(--mono);
    font-size: 0.78rem;
    border-collapse: collapse;
    width: 100%;
}

table.diff td {
    padding: 0 0.4rem;
    white-space: pre-wrap;
}

.diff_header {
    color: #6b7280;
}

td.diff_header {
    text-align: right;
}

.diff_next {
    color: #6b7280;
}

.diff_add {
    background: #13361f;
}

.diff_chg {
    background: #33310f;
}

.diff_sub {
    background: #3a1620;
}

.settings-nav {
    list-style: none;
    padding: 0;
    display: grid;
    gap: 0.6rem;
}

.settings-nav a {
    font-family: var(--mono);
}

.inline-form {
    display: inline-flex;
    gap: 0.3rem;
    flex-wrap: wrap;
}

.inline-form input,
.inline-form select {
    background: #0d0d0d;
    border: 1px solid #333;
    border-radius: 4px;
    color: var(--fg);
    font-family: var(--mono);
    font-size: 0.8rem;
    padding: 0.3rem 0.45rem;
}

.tag-actions {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    flex-wrap: wrap;
}

.featured-list {
    list-style: none;
    padding: 0;
    display: grid;
    gap: 0.4rem;
    margin-bottom: 1rem;
}

.featured-list label {
    font-family: var(--mono);
    font-size: 0.9rem;
}

.button-link {
    font-family: var(--mono);
    font-size: 0.85rem;
    border: 1px solid var(--teal);
    border-radius: 4px;
    padding: 0.35rem 0.6rem;
}

.mono {
    font-family: var(--mono);
    font-size: 0.85rem;
}

.admin-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 1rem;
}

.admin-table th,
.admin-table td {
    text-align: left;
    padding: 0.5rem 0.6rem;
    border-bottom: 1px solid #1a1a1a;
}

.admin-table th {
    font-family: var(--mono);
    font-size: 0.75rem;
    color: #9ca3af;
    text-transform: uppercase;
}

.status-draft { color: #9ca3af; }
.status-scheduled { color: #fbbf24; }
.status-published { color: var(--teal); }
.status-archived { color: #fb7185; }

.post-editor {
    display: grid;
    grid-template-columns: 1fr 16rem;
    gap: 1.5rem;
    align-items: start;
}

.editor-main {
    display: grid;
    gap: 1rem;
}

.editor-split {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.editor-side {
    display: grid;
    gap: 1rem;
    align-content: start;
}

.post-editor label {
    display: grid;
    gap: 0.3rem;
    font-family: var(--mono);
    font-size: 0.8rem;
}

.post-editor input,
.post-editor select,
.post-editor textarea {
    background: #0d0d0d;
    border: 1px solid #333;
    border-radius: 4px;
    color: var(--fg);
    font-family: var(--mono);
    padding: 0.5rem 0.6rem;
}

.post-editor textarea {
    resize: vertical;
    min-height: 20rem;
}

.seo-panel {
    border: 1px solid #1a1a1a;
    border-radius: 6px;
    padding: 1rem;
    display: grid;
    gap: 0.75rem;
}

.seo-panel legend {
    font-family: var(--mono);
    font-size: 0.8rem;
    color: #9ca3af;
    padding: 0 0.4rem;
}

.seo-panel textarea {
    min-height: 3rem;
}

.counter {
    font-family: var(--mono);
    font-size: 0.7rem;
    color: #9ca3af;
}

.counter.over {
    color: #fb7185;
}

.seo-checks {
    list-style: none;
    padding: 0;
    margin: 0;
    font-family: var(--mono);
    font-size: 0.8rem;
    display: grid;
    gap: 0.3rem;
}

.seo-checks .ok::before {
    content: "✓ ";
    color: var(--teal);
}

.seo-checks .warn::before {
    content: "! ";
    color: #fbbf24;
}

.preview-pane {
    border: 1px solid #1a1a1a;
    border-radius: 6px;
    padding: 0.75rem;
    overflow-x: auto;
}

@media (max-width: 60rem) {
    .post-editor { grid-template-columns: 1fr; }
    .editor-split { grid-template-columns: 1fr; }
}

.editor-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.4rem;
    font-family: var(--mono);
    font-size: 0.8rem;
}

.editor-toolbar button {
    background: #0d0d0d;
    color: var(--fg);
    border: 1px solid #333;
    border-radius: 4px;
    font-weight: 400;
    padding: 0.3rem 0.5rem;
    min-width: 2rem;
}

.editor-toolbar button:hover {
    border-color: var(--teal);
}

.editor-toolbar select {
    background: #0d0d0d;
    border: 1px solid #333;
    border-radius: 4px;
    color: var(--fg);
    font-family: var(--mono);
    font-size: 0.8rem;
    padding: 0.25rem 0.4rem;
}

.toolbar-sep {
    width: 1px;
    align-self: stretch;
    background: #333;
    margin: 0 0.3rem;
}

.ai-generate-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.6rem;
}

.inline-file {
    display: inline-flex;
    gap: 0.4rem;
    align-items: center;
}

.media-upload {
    display: flex;
    gap: 0.6rem;
    align-items: center;
    margin: 1rem 0 2rem;
    flex-wrap: wrap;
}

.media-upload input[name="alt_text"] {
    background: #0d0d0d;
    border: 1px solid #333;
    border-radius: 4px;
    color: var(--fg);
    font-family: var(--mono);
    padding: 0.45rem 0.6rem;
}

.media-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(14rem, 1fr));
    gap: 1.25rem;
}

.media-item {
    border: 1px solid #1a1a1a;
    border-radius: 6px;
    padding: 0.75rem;
    display: grid;
    gap: 0.5rem;
}

.media-item img {
    width: 100%;
    height: 9rem;
    object-fit: cover;
    border-radius: 4px;
    background: #0d0d0d;
}

.media-meta {
    display: grid;
    gap: 0.4rem;
}

.media-meta input {
    background: #0d0d0d;
    border: 1px solid #333;
    border-radius: 4px;
    color: var(--fg);
    font-family: var(--mono);
    font-size: 0.8rem;
    padding: 0.4rem 0.5rem;
}

/* --- code highlighting (Pygments monokai, scoped to .codehilite) --- */
.post-body pre {
    position: relative;
}

.copy-code {
    position: absolute;
    top: 0.4rem;
    right: 0.4rem;
    font-family: var(--mono);
    font-size: 0.7rem;
    padding: 0.2rem 0.45rem;
    border: 1px solid #333;
    border-radius: 4px;
    background: #1a1a1a;
    color: #cbd5e1;
    cursor: pointer;
}

.codehilite .hll { background-color: #49483e }
.codehilite .c, .codehilite .ch, .codehilite .cm, .codehilite .cp, .codehilite .cpf,
.codehilite .c1, .codehilite .cs, .codehilite .gu { color: #959077 }
.codehilite .err { color: #ed007e }
.codehilite .k, .codehilite .kc, .codehilite .kd, .codehilite .kp, .codehilite .kr,
.codehilite .kt, .codehilite .go { color: #66d9ef }
.codehilite .o, .codehilite .ow, .codehilite .kn, .codehilite .nt, .codehilite .gd { color: #ff4689 }
.codehilite .l, .codehilite .m, .codehilite .mb, .codehilite .mf, .codehilite .mh,
.codehilite .mi, .codehilite .mo, .codehilite .il, .codehilite .se { color: #ae81ff }
.codehilite .s, .codehilite .sa, .codehilite .sb, .codehilite .sc, .codehilite .dl,
.codehilite .sd, .codehilite .s2, .codehilite .sh, .codehilite .si, .codehilite .sx,
.codehilite .sr, .codehilite .s1, .codehilite .ss, .codehilite .ld { color: #e6db74 }
.codehilite .na, .codehilite .nc, .codehilite .nd, .codehilite .ne, .codehilite .nf,
.codehilite .nx, .codehilite .fm, .codehilite .gi { color: #a6e22e }
.codehilite .no, .codehilite .kc { color: #66d9ef }

/* --- search modal --- */
.search-modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding-top: 12vh;
    z-index: 100;
}

/* The display:flex above outranks the UA [hidden] rule, so the modal must be
   explicitly hidden when the attribute is set — otherwise it sits open over
   every page. */
.search-modal[hidden] {
    display: none;
}

.search-box {
    width: min(92vw, 640px);
    background: var(--glass-strong);
    backdrop-filter: blur(var(--glass-blur));
    -webkit-backdrop-filter: blur(var(--glass-blur));
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    box-shadow: var(--glass-shadow);
    padding: 1rem;
    height: fit-content;
}

.search-box input {
    width: 100%;
    background: #000;
    border: 1px solid #333;
    border-radius: 4px;
    color: var(--fg);
    font-family: var(--mono);
    padding: 0.6rem 0.7rem;
    box-sizing: border-box;
}

.search-results {
    list-style: none;
    padding: 0;
    margin: 0.75rem 0 0;
    display: grid;
    gap: 0.25rem;
    max-height: 55vh;
    overflow-y: auto;
}

.search-results li a {
    display: flex;
    gap: 0.5rem;
    align-items: baseline;
    padding: 0.4rem 0.3rem;
}
