/* ===== Design tokens (kept in sync with portfolio style.css) ===== */
:root {
  --bg:       #0d1117;
  --bg-alt:   #161b22;
  --bg-card:  #161b22;
  --border:   #30363d;
  --text:     #c9d1d9;
  --muted:    #8b949e;
  --accent:   #ff4444;
  --accent-h: #ff6666;
  --green:    #7ee787;
  --blue:     #58a6ff;
  --yellow:   #e3b341;
  --nav-bg:   rgba(13,17,23,0.92);
  --mono:     'JetBrains Mono', 'Fira Code', monospace;
  --sans:     'Inter', system-ui, sans-serif;
  --topbar-h: 56px;
  --sidebar-w: 290px;
  --toc-w: 240px;
}
[data-theme="light"] {
  --bg:#ffffff; --bg-alt:#f6f8fa; --bg-card:#ffffff; --border:#d0d7de;
  --text:#24292f; --muted:#57606a; --accent:#cf222e; --accent-h:#a40e26;
  --green:#1a7f37; --blue:#0969da; --yellow:#9a6700; --nav-bg:rgba(255,255,255,0.92);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body { background: var(--bg); color: var(--text); font-family: var(--sans); line-height: 1.6; }
a { color: var(--blue); text-decoration: none; }

/* ===== Top bar ===== */
.wu-topbar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 100; height: var(--topbar-h);
  background: var(--nav-bg); backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 18px; padding: 0 18px;
}
.wu-brand { font-family: var(--mono); font-size: 14px; font-weight: 700; color: var(--text); white-space: nowrap; }
.wu-brand .accent { color: var(--accent); }
.wu-brand .muted  { color: var(--muted); }
.wu-spaces { display: flex; gap: 4px; margin-left: 6px; }
.wu-space-tab {
  font-family: var(--mono); font-size: 12.5px; color: var(--muted);
  padding: 6px 12px; border-radius: 7px; cursor: pointer; border: 1px solid transparent;
  display: inline-flex; align-items: center; gap: 7px; transition: .15s; background: none;
}
.wu-space-tab:hover { color: var(--text); border-color: var(--border); }
.wu-space-tab.active { color: var(--accent); border-color: var(--accent); background: rgba(255,68,68,.08); }
.wu-topbar-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.wu-search-btn {
  display: flex; align-items: center; gap: 10px; width: 100%;
  background: var(--bg-alt); border: 1px solid var(--border); color: var(--muted);
  font-family: var(--mono); font-size: 12px; padding: 9px 12px; border-radius: 8px; cursor: pointer;
  transition: .15s;
}
.wu-search-btn:hover { border-color: var(--accent); color: var(--text); }
.wu-search-btn kbd {
  margin-left: auto; font-family: var(--mono); font-size: 10.5px;
  background: var(--bg); border: 1px solid var(--border); border-radius: 4px; padding: 1px 6px; color: var(--muted);
}
.wu-icon-btn {
  width: 34px; height: 34px; border-radius: 8px; cursor: pointer;
  background: var(--bg-card); border: 1px solid var(--border); color: var(--text);
  display: inline-flex; align-items: center; justify-content: center; font-size: 14px; transition: .15s;
}
.wu-icon-btn:hover { border-color: var(--accent); color: var(--accent); }
.wu-back { font-family: var(--mono); font-size: 12px; color: var(--muted); white-space: nowrap; }
.wu-back:hover { color: var(--accent); }
.wu-hamburger { display: none; }

/* ===== Shell layout ===== */
.wu-shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr) var(--toc-w);
  max-width: 1500px; margin: 0 auto;
  padding-top: var(--topbar-h);   /* clear the fixed topbar so sticky panes start below it */
}

/* ===== Sidebar ===== */
.wu-sidebar {
  position: sticky; top: var(--topbar-h); align-self: start;
  height: calc(100vh - var(--topbar-h));
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
}
.wu-sidebar-search { flex-shrink: 0; padding: 14px 12px; border-bottom: 1px solid var(--border); }
.wu-sidebar-nav {
  flex: 1; overflow-y: auto; padding: 14px 12px 60px;
  scrollbar-width: thin; scrollbar-color: var(--border) transparent;
}
.wu-sidebar-nav::-webkit-scrollbar { width: 8px; }
.wu-sidebar-nav::-webkit-scrollbar-thumb { background: var(--border); border-radius: 8px; }
.wu-space-title {
  font-family: var(--mono); font-size: 11px; text-transform: uppercase; letter-spacing: .12em;
  color: var(--muted); padding: 6px 12px 12px; display: flex; align-items: center; gap: 8px;
}
.wu-space-title i, .wu-space-title .wu-svg-ico { color: var(--accent); }

.wu-nav-link {
  display: flex; align-items: center; gap: 9px;
  font-size: 13.5px; color: var(--muted); padding: 7px 12px; border-radius: 7px;
  cursor: pointer; transition: .12s; position: relative; line-height: 1.35;
}
.wu-nav-link:hover { color: var(--text); background: var(--bg-alt); }
.wu-nav-link .lk-icon { width: 15px; text-align: center; font-size: 12px; opacity: .8; flex-shrink: 0; }
.wu-svg-ico { display: inline-flex; align-items: center; justify-content: center; width: 16px; height: 16px; flex-shrink: 0; }
.wu-svg-ico svg { width: 100%; height: 100%; display: block; }
.wu-nav-link .lk-label { flex: 1; }
.wu-nav-link .lk-lock { font-size: 10px; color: var(--muted); opacity: .6; }
.wu-nav-link.active {
  color: var(--accent); background: rgba(255,68,68,.10); font-weight: 600;
}
.wu-nav-link.active::before {
  content: ''; position: absolute; left: 0; top: 6px; bottom: 6px; width: 2.5px;
  background: var(--accent); border-radius: 2px;
}
.wu-badge {
  font-family: var(--mono); font-size: 8.5px; font-weight: 700; letter-spacing: .04em;
  color: var(--accent); border: 1px solid var(--accent); border-radius: 20px; padding: 1px 7px;
}

/* groups (collapsible) */
.wu-group { margin-bottom: 2px; }
.wu-group > summary {
  list-style: none; cursor: pointer; display: flex; align-items: center; gap: 9px;
  font-size: 13.5px; color: var(--text); padding: 7px 12px; border-radius: 7px; transition: .12s; user-select: none;
}
.wu-group > summary::-webkit-details-marker { display: none; }
.wu-group > summary:hover { background: var(--bg-alt); }
.wu-group > summary .lk-icon { width: 15px; text-align: center; font-size: 12px; color: var(--muted); flex-shrink: 0; }
.wu-group > summary .lk-label { flex: 1; }
.wu-chevron { font-size: 10px; color: var(--muted); transition: transform .2s; }
.wu-group[open] > summary .wu-chevron { transform: rotate(90deg); }
.wu-group-children { margin: 2px 0 6px 14px; padding-left: 8px; border-left: 1px solid var(--border); }

/* ===== Main content ===== */
.wu-main { padding: 30px 52px 90px; min-width: 0; }
.wu-breadcrumbs {
  font-family: var(--mono); font-size: 12px; color: var(--muted);
  display: flex; flex-wrap: wrap; align-items: center; gap: 7px; margin-bottom: 26px;
}
.wu-breadcrumbs span.sep { opacity: .5; }
.wu-breadcrumbs a { color: var(--muted); }
.wu-breadcrumbs a:hover { color: var(--accent); }
.wu-breadcrumbs .crumb-current { color: var(--text); }

.wu-article { max-width: 720px; }
.wu-article h1 { font-size: 31px; font-weight: 700; line-height: 1.2; margin-bottom: 14px; letter-spacing: -.01em; }
.wu-article h2 {
  font-size: 23px; font-weight: 600; margin: 42px 0 16px; padding-top: 24px;
  border-top: 1px solid var(--border); scroll-margin-top: 80px;
}
.wu-article h3 { font-size: 18px; font-weight: 600; margin: 28px 0 12px; scroll-margin-top: 80px; }
.wu-article p { color: var(--text); margin-bottom: 16px; }
.wu-article a { color: var(--blue); }
.wu-article a:hover { text-decoration: underline; }
.wu-article ul, .wu-article ol { margin: 0 0 16px 22px; color: var(--text); }
.wu-article li { margin-bottom: 6px; }
.wu-article code {
  font-family: var(--mono); font-size: 85%; background: var(--bg-alt);
  border: 1px solid var(--border); border-radius: 5px; padding: 1px 6px;
}
.wu-article pre {
  background: var(--bg-alt); border: 1px solid var(--border); border-radius: 10px;
  padding: 16px; overflow-x: auto; margin-bottom: 18px; position: relative;
}
.wu-article pre code { background: none; border: none; padding: 0; font-size: 13px; }

/* lead / intro */
.wu-lead { font-size: 16px; color: var(--muted); margin-bottom: 30px; max-width: 640px; }

/* space landing cards */
.wu-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; margin-top: 8px; }
.wu-card {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: 12px;
  padding: 20px; cursor: pointer; transition: .18s; display: flex; flex-direction: column; gap: 8px;
}
.wu-card:hover { border-color: var(--accent); transform: translateY(-3px); }
.wu-card-head { display: flex; align-items: center; gap: 10px; }
.wu-card-head i { font-size: 18px; color: var(--accent); }
.wu-card h3 { font-family: var(--mono); font-size: 15px; color: var(--text); }
.wu-card p { font-size: 12.5px; color: var(--muted); line-height: 1.55; flex: 1; }
.wu-card-meta { font-family: var(--mono); font-size: 11px; color: var(--muted); display: flex; align-items: center; gap: 6px; }

/* ===== Machine grid (HTB-style) ===== */
.wu-filters { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; margin: 4px 0 14px; }
.wu-fgroup { display: inline-flex; gap: 4px; background: var(--bg-alt); border: 1px solid var(--border); border-radius: 9px; padding: 3px; }
.wu-fbtn { font-family: var(--mono); font-size: 12px; color: var(--muted); background: none; border: none; cursor: pointer; padding: 5px 11px; border-radius: 6px; transition: .12s; }
.wu-fbtn:hover { color: var(--text); }
.wu-fbtn.active { color: #fff; background: var(--accent); }
.wu-fsearch { flex: 1; min-width: 160px; background: var(--bg-alt); border: 1px solid var(--border); color: var(--text); border-radius: 9px; padding: 8px 12px; font-family: var(--sans); font-size: 13px; outline: none; }
.wu-fsearch:focus { border-color: var(--accent); }
.wu-fsort { background: var(--bg-alt); border: 1px solid var(--border); color: var(--text); border-radius: 9px; padding: 8px 12px; font-family: var(--mono); font-size: 12px; cursor: pointer; }
.wu-mcount { font-family: var(--mono); font-size: 12px; color: var(--muted); margin-bottom: 16px; }
.wu-mgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); gap: 14px; }
.wu-mcard { display: flex; gap: 14px; align-items: center; background: var(--bg-card); border: 1px solid var(--border); border-radius: 12px; padding: 14px; transition: .16s; }
.wu-mcard:hover { border-color: var(--accent); transform: translateY(-3px); }
.wu-mcard-av { width: 56px; height: 56px; border-radius: 50%; object-fit: cover; flex-shrink: 0; border: 1px solid var(--border); background: var(--bg-alt); }
.wu-mcard-ph { display: flex; align-items: center; justify-content: center; font-size: 22px; color: var(--accent); }
.wu-mcard-body { min-width: 0; flex: 1; }
.wu-mcard-top { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.wu-mcard-top h3 { font-family: var(--mono); font-size: 14px; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wu-mcard-meta { display: flex; flex-wrap: wrap; gap: 12px; font-family: var(--mono); font-size: 11px; color: var(--muted); margin-bottom: 7px; }
.wu-mcard-meta i { color: var(--accent); margin-right: 3px; }
.wu-mcard .wu-tags { gap: 5px; }
.wu-mcard .wu-tag { font-size: 9.5px; padding: 1px 6px; }

/* ===== Locked state ===== */
.wu-locked {
  border: 1px dashed var(--border); border-radius: 16px; padding: 56px 32px;
  text-align: center; background: var(--bg-alt); margin-top: 10px;
}
.wu-lock-orb {
  width: 64px; height: 64px; border-radius: 50%; margin: 0 auto 22px;
  display: flex; align-items: center; justify-content: center; font-size: 24px;
  color: var(--accent); border: 1px solid var(--accent);
  background: rgba(255,68,68,.07); box-shadow: 0 0 22px rgba(255,68,68,.18);
}
.wu-locked h1 { font-size: 26px; margin-bottom: 10px; }
.wu-locked .wu-locked-note { color: var(--muted); font-size: 14px; max-width: 420px; margin: 0 auto 20px; }
.wu-chip {
  display: inline-flex; align-items: center; gap: 7px; font-family: var(--mono); font-size: 12px;
  color: var(--muted); border: 1px solid var(--border); border-radius: 20px; padding: 5px 14px;
}
.wu-chip i { color: var(--accent); }

/* ===== Pager (prev/next) ===== */
.wu-pager { display: flex; gap: 14px; margin-top: 56px; max-width: 720px; }
.wu-pager a {
  flex: 1; border: 1px solid var(--border); border-radius: 10px; padding: 14px 16px;
  transition: .15s; min-width: 0;
}
.wu-pager a:hover { border-color: var(--accent); }
.wu-pager .pg-dir { font-family: var(--mono); font-size: 11px; color: var(--muted); display: block; margin-bottom: 4px; }
.wu-pager .pg-title { font-size: 14px; color: var(--text); display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wu-pager .next { text-align: right; }

/* ===== Right TOC ===== */
.wu-toc {
  position: sticky; top: var(--topbar-h); align-self: start;
  height: calc(100vh - var(--topbar-h)); overflow-y: auto; padding: 30px 18px 60px;
}
.wu-toc-title { font-family: var(--mono); font-size: 11px; text-transform: uppercase; letter-spacing: .12em; color: var(--muted); margin-bottom: 14px; }
.wu-toc a {
  display: block; font-size: 12.5px; color: var(--muted); padding: 4px 0 4px 12px;
  border-left: 2px solid var(--border); transition: .12s; line-height: 1.4;
}
.wu-toc a.sub { padding-left: 24px; }
.wu-toc a:hover { color: var(--text); }
.wu-toc a.active { color: var(--accent); border-left-color: var(--accent); }
.wu-toc-empty { font-size: 12px; color: var(--muted); opacity: .5; }

/* ===== Search modal ===== */
.wu-search-modal {
  display: none; position: fixed; inset: 0; z-index: 300;
  background: rgba(0,0,0,.55); backdrop-filter: blur(3px); padding-top: 12vh; justify-content: center;
}
.wu-search-modal.open { display: flex; }
.wu-search-box {
  width: min(580px, 92vw); height: max-content; max-height: 70vh; background: var(--bg-card);
  border: 1px solid var(--border); border-radius: 14px; overflow: hidden;
  box-shadow: 0 24px 70px rgba(0,0,0,.6); display: flex; flex-direction: column;
}
.wu-search-input-wrap { display: flex; align-items: center; gap: 12px; padding: 16px 18px; border-bottom: 1px solid var(--border); }
.wu-search-input-wrap i { color: var(--muted); }
.wu-search-input {
  flex: 1; background: none; border: none; outline: none; color: var(--text);
  font-family: var(--sans); font-size: 15px;
}
.wu-search-results { overflow-y: auto; padding: 8px; }
.wu-result {
  display: flex; align-items: center; gap: 12px; padding: 11px 14px; border-radius: 9px; cursor: pointer;
}
.wu-result i { color: var(--muted); width: 16px; text-align: center; }
.wu-result .r-label { font-size: 14px; color: var(--text); }
.wu-result .r-path { font-family: var(--mono); font-size: 11px; color: var(--muted); margin-left: auto; }
.wu-result.active, .wu-result:hover { background: var(--bg-alt); }
.wu-result.active i, .wu-result.active .r-label { color: var(--accent); }
.wu-search-empty { padding: 30px; text-align: center; color: var(--muted); font-size: 13px; }

/* ===== Rendered writeup (Markdown) ===== */
.wu-loading { color: var(--muted); font-family: var(--mono); font-size: 13px; padding: 20px 0; }
.wu-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 14px; margin: 0 0 14px; font-family: var(--mono); font-size: 12.5px; color: var(--muted); }
.wu-meta-item { display: inline-flex; align-items: center; gap: 6px; }
.wu-meta-item i { color: var(--accent); }
.wu-diff { font-family: var(--mono); font-size: 11px; font-weight: 700; padding: 2px 10px; border-radius: 20px; border: 1px solid var(--border); }
.wu-diff.easy   { color: var(--green);  border-color: rgba(126,231,135,.4); background: rgba(126,231,135,.10); }
.wu-diff.medium { color: var(--yellow); border-color: rgba(227,179,65,.4);  background: rgba(227,179,65,.10); }
.wu-diff.hard   { color: var(--accent); border-color: rgba(255,68,68,.4);   background: rgba(255,68,68,.10); }
.wu-diff.insane { color: #c084fc;       border-color: rgba(192,132,252,.4); background: rgba(192,132,252,.10); }
.wu-tags { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 26px; }
.wu-tag { font-family: var(--mono); font-size: 10.5px; color: var(--muted); background: var(--bg-alt); border: 1px solid var(--border); border-radius: 4px; padding: 2px 8px; }

.wu-md table { width: 100%; border-collapse: collapse; margin: 0 0 18px; font-size: 14px; }
.wu-md th, .wu-md td { border: 1px solid var(--border); padding: 8px 12px; text-align: left; }
.wu-md th { background: var(--bg-alt); font-weight: 600; }
.wu-md blockquote { border-left: 3px solid var(--accent); background: var(--bg-alt); margin: 0 0 18px; padding: 12px 16px; border-radius: 0 8px 8px 0; color: var(--muted); }
.wu-md blockquote p { margin: 0; }
.wu-md img { max-width: 100%; border-radius: 8px; border: 1px solid var(--border); margin: 6px 0; }
.wu-md hr { border: none; border-top: 1px solid var(--border); margin: 28px 0; }
/* avoid a double rule: when a --- precedes a heading, the heading's own
   border-top divider would stack with the <hr> — drop one. */
.wu-md hr + h2, .wu-md hr + h3 { border-top: none; padding-top: 0; margin-top: 22px; }
/* the hero card already draws a divider, so the first section heading under it
   shouldn't draw a second one right below it */
.wu-hero + .wu-md > h2:first-child, .wu-hero + .wu-md > h3:first-child { border-top: none; padding-top: 0; margin-top: 8px; }

/* HTB-style machine hero card */
.wu-hero { display: flex; gap: 22px; align-items: center; margin-bottom: 26px; padding-bottom: 24px; border-bottom: 1px solid var(--border); }
.wu-hero-avatar { width: 96px; height: 96px; border-radius: 50%; object-fit: cover; border: 1px solid var(--border); background: var(--bg-alt); flex-shrink: 0; }
.wu-hero-ph { display: flex; align-items: center; justify-content: center; font-size: 34px; color: var(--accent); }
.wu-hero-info { min-width: 0; }
.wu-hero-info h1 { margin-bottom: 10px; }
.wu-hero-info .wu-meta, .wu-hero-info .wu-tags { margin-bottom: 10px; }
.wu-htb-btn { display: inline-flex; align-items: center; gap: 8px; margin-top: 4px; font-family: var(--mono); font-size: 12px; color: #9fef00; border: 1px solid #9fef00; border-radius: 7px; padding: 6px 13px; transition: .15s; }
.wu-htb-btn:hover { background: #9fef00; color: #0d1117; }
@media (max-width: 560px) { .wu-hero { flex-direction: column; align-items: flex-start; gap: 14px; } }
.wu-md pre { background: #0b0f14; }
[data-theme="light"] .wu-md pre { background: var(--bg-alt); }
.wu-md pre code.hljs { background: transparent; padding: 0; }

/* ===== Footer (mirrors portfolio) ===== */
.wu-footer { padding: 36px 24px; border-top: 1px solid var(--border); text-align: center; }
.wu-footer .footer-cmd { font-family: var(--mono); font-size: 13px; }
.wu-footer .footer-cmd .muted { color: var(--muted); }
.wu-footer .footer-out { font-size: 12px; color: var(--muted); margin-top: 4px; }

/* ===== Mobile ===== */
.wu-overlay { display: none; position: fixed; inset: var(--topbar-h) 0 0; background: rgba(0,0,0,.5); z-index: 90; }
@media (max-width: 1100px) {
  .wu-shell { grid-template-columns: var(--sidebar-w) minmax(0, 1fr); }
  .wu-toc { display: none; }
}
@media (max-width: 860px) {
  .wu-shell { grid-template-columns: 1fr; }
  .wu-hamburger { display: inline-flex; }
  .wu-spaces { display: none; }
  .wu-back { display: none; }
  .wu-sidebar {
    position: fixed; top: var(--topbar-h); left: 0; bottom: 0; width: 300px; z-index: 95;
    background: var(--bg); transform: translateX(-100%); transition: transform .25s ease;
    border-right: 1px solid var(--border);
  }
  .wu-sidebar.open { transform: translateX(0); }
  .wu-overlay.open { display: block; }
  .wu-main { padding: 24px 22px 80px; }
  .wu-mobile-spaces { display: flex; gap: 6px; padding: 0 4px 14px; flex-wrap: wrap; }
}
@media (min-width: 861px) { .wu-mobile-spaces { display: none; } }
