/* ROsecurify blog theme — extracted from the design prototype. Dark default; add class "light" on <body> for light theme. */
  :root {
    --bg: #0a0b0a;
    --bg-2: #0f1110;
    --bg-3: #14171501;
    --fg: #e8ebe6;
    --fg-2: #a8ada3;
    --muted: #6b7268;
    --dim: #3a3f38;
    --rule: #1f2420;
    --accent: #ff4d4d;
    --accent-2: #e03c3c;
    --danger: #ff4d4d;
    --warn: #ffb020;
    --str: #d69d85;
    --kw: #00ff88;
    --fn: #9cdcfe;
    --num: #ffb020;
    --mono: 'JetBrains Mono', ui-monospace, Menlo, Consolas, monospace;
    --sans: 'Inter', system-ui, -apple-system, sans-serif;
  }
  body.light {
    --bg: #fbfaf7;
    --bg-2: #f3efe7;
    --fg: #1a1a1a;
    --fg-2: #3a3a3a;
    --muted: #8a8680;
    --dim: #c8c4bd;
    --rule: #e4e0d7;
    --accent: #c62828;
    --accent-2: #a31f1f;
    --danger: #c62828;
    --warn: #b07600;
    --str: #a85a1f;
    --kw: #1a9957;
    --fn: #1e6ea8;
    --num: #b07600;
  }

  * { box-sizing: border-box; }
  html { scroll-behavior: smooth; }
  html, body { margin: 0; padding: 0; background: var(--bg); color: var(--fg); font-family: var(--sans); font-size: 16px; line-height: 1.7; -webkit-font-smoothing: antialiased; transition: background .2s, color .2s; }
  body { overflow-x: hidden; }
  a { color: inherit; text-decoration: none; }
  button { font: inherit; color: inherit; background: none; border: none; cursor: pointer; padding: 0; }

  /* subtle scan lines only in dark mode */
  body:not(.light)::before {
    content: ""; position: fixed; inset: 0; pointer-events: none; z-index: 1;
    background: repeating-linear-gradient(0deg, rgba(255,255,255,0.012) 0 1px, transparent 1px 3px);
  }

  /* GRID BG — ASCII art background, dark red + gray */
  .grid-bg {
    position: fixed; inset: 0; pointer-events: none; z-index: 0;
    overflow: hidden;
    background-color: var(--bg);
  }
  .grid-bg::after {
    content: ""; position: absolute; inset: 0;
    background: radial-gradient(ellipse 75% 85% at 50% 50%,
      color-mix(in srgb, var(--bg) 96%, transparent) 0%,
      color-mix(in srgb, var(--bg) 88%, transparent) 35%,
      color-mix(in srgb, var(--bg) 55%, transparent) 70%,
      transparent 100%);
  }
  .ascii-bg {
    position: absolute; inset: 0;
    font-family: var(--mono);
    font-size: 12px;
    line-height: 14px;
    letter-spacing: 0;
    white-space: pre;
    color: var(--muted);
    overflow: hidden;
    user-select: none;
    padding: 6px 8px;
  }
  .ascii-bg .r { color: var(--danger); opacity: 0.55; }
  .ascii-bg .g { color: var(--muted); opacity: 0.35; }
  .ascii-bg .d { color: var(--dim); opacity: 0.4; }
  body.light .ascii-bg .r { opacity: 0.32; }
  body.light .ascii-bg .g { opacity: 0.18; }
  body.light .ascii-bg .d { opacity: 0.20; }

  .wrap { max-width: 1200px; margin: 0 auto; padding: 0 32px; position: relative; z-index: 2; }

  /* HEADER */
  header.site {
    position: sticky; top: 0; z-index: 50;
    backdrop-filter: blur(12px);
    background: color-mix(in srgb, var(--bg) 82%, transparent);
    border-bottom: 1px solid var(--rule);
  }
  .site-inner { display: flex; align-items: center; gap: 36px; height: 60px; }
  .brand {
    font-family: var(--mono); font-weight: 700;
    font-size: 18px; letter-spacing: -0.01em; color: var(--fg);
    display: inline-flex; align-items: center; gap: 10px; white-space: nowrap;
  }
  .brand { font-size: 19px; }
  .tk{display:flex;align-items:center;gap:.11em;font-weight:800;letter-spacing:-.035em;line-height:1;white-space:nowrap}
  .tk>span{padding:.12em .19em .08em}
  .tk .ro{box-shadow:inset 0 0 0 .055em var(--fg);color:var(--fg)}
  .tk .sx{background:#c41e3a;color:#0a0b0a}
  .tk .cu{padding-left:.04em;padding-right:0;color:var(--fg)}
  .cyc .ro{animation:cro 7.5s infinite steps(1)}.cyc .cu{animation:ccu 7.5s infinite steps(1)}
  @keyframes cro{0%,32%{color:var(--fg);box-shadow:inset 0 0 0 .055em var(--fg)}33%,65%{color:var(--dim);box-shadow:inset 0 0 0 .055em var(--dim)}66%,100%{color:var(--fg);box-shadow:inset 0 0 0 .055em var(--fg)}}
  @keyframes ccu{0%,32%{color:var(--dim)}33%,100%{color:var(--fg)}}
  .gl{position:relative;display:inline-block}
  .gl>.layer{position:absolute;inset:0;pointer-events:none;opacity:0}
  .gl>.l1 *{color:#00d4ff!important;background-color:transparent!important;box-shadow:inset 0 0 0 .055em #00d4ff!important}
  .gl>.l2 *{color:#ff3355!important;background-color:transparent!important;box-shadow:inset 0 0 0 .055em #ff3355!important}
  .gl>.layer .cu{box-shadow:none!important}
  .gl>.base{animation:h0 7.5s infinite steps(1)}.gl>.l1{animation:h1 7.5s infinite steps(1)}.gl>.l2{animation:h2 7.5s infinite steps(1)}
  @keyframes h0{0%,100%{transform:none}32%{transform:translateX(2px)}34%{transform:none}65%{transform:translateX(-2px)}67%{transform:none}}
  @keyframes h1{0%,31%,35%,64%,68%,98.5%,100%{opacity:0}32%{opacity:.85;transform:translate(-3px,0);clip-path:inset(15% 0 55% 0)}33.5%{opacity:.85;transform:translate(3px,0);clip-path:inset(60% 0 15% 0)}65.5%{opacity:.85;transform:translate(-3px,0);clip-path:inset(35% 0 40% 0)}99%{opacity:.85;transform:translate(2px,0);clip-path:inset(5% 0 75% 0)}}
  @keyframes h2{0%,31%,35%,64%,68%,98.5%,100%{opacity:0}32.5%{opacity:.8;transform:translate(3px,0);clip-path:inset(45% 0 30% 0)}34%{opacity:.8;transform:translate(-2px,0);clip-path:inset(80% 0 3% 0)}66%{opacity:.8;transform:translate(3px,0);clip-path:inset(8% 0 78% 0)}99.5%{opacity:.8;transform:translate(-3px,0);clip-path:inset(50% 0 25% 0)}}
  body.no-glitch .gl>*{animation:none!important}body.no-glitch .gl>.layer{opacity:0!important}
  .nav-main { display: flex; gap: 24px; margin-left: 8px; font-family: var(--mono); font-size: 13px; }
  .nav-main a { color: var(--fg-2); position: relative; padding: 4px 0; }
  .nav-main a .first { color: var(--accent); }
  .nav-main a::after { content: ""; position: absolute; left: 0; right: 0; bottom: -2px; height: 1px; background: var(--accent); transform: scaleX(0); transform-origin: left; transition: transform .2s; }
  .nav-main a:hover { color: var(--fg); }
  .nav-main a:hover::after { transform: scaleX(1); }
  .header-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }
  .sub-pill {
    display: inline-flex; align-items: stretch; height: 34px;
    background: var(--bg-2); border: 1px solid var(--rule);
    font-family: var(--mono); font-size: 12px; color: var(--fg-2);
    transition: border-color .15s;
  }
  .sub-pill:focus-within { border-color: var(--accent); }
  .sub-pill .envelope { color: var(--muted); font-size: 12px; display: flex; align-items: center; padding-left: 12px; }
  .sub-pill input { background: none; border: none; outline: none; color: var(--fg); font: inherit; width: 150px; padding: 0 10px; }
  .sub-pill input::placeholder { color: var(--muted); }
  .sub-pill .go {
    display: inline-flex; align-items: center; justify-content: center;
    width: 34px; background: var(--accent); color: #001a0e; font-size: 13px;
    border-left: 1px solid var(--rule); flex-shrink: 0;
    transition: filter .15s;
  }
  .sub-pill .go:hover { filter: brightness(1.1); }
  .icon-btn {
    width: 34px; height: 34px; display: inline-flex; align-items: center; justify-content: center;
    color: var(--fg-2); border: 1px solid transparent;
  }
  .icon-btn:hover { color: var(--accent); border-color: var(--rule); background: var(--bg-2); }
  .icon-btn svg { width: 16px; height: 16px; }

  /* TICKER */
  .ticker {
    background: #2a0606; color: #ffdede;
    overflow: hidden; white-space: nowrap; height: 26px;
    display: flex; align-items: center;
    font-family: var(--mono); font-size: 11px;
    border-bottom: 1px solid #3a0a0a;
  }
  .ticker-track { display: inline-flex; gap: 40px; animation: scroll 45s linear infinite; padding-left: 100%; }
  .ticker b { color: #ff9898; margin-right: 10px; font-weight: 700; letter-spacing: 0.08em; }
  .ticker span.sep { color: #7a3a3a; }
  @keyframes scroll { from { transform: translateX(0); } to { transform: translateX(-100%); } }

  /* POST HEADER STRIP */
  .post-hero { padding: 40px 0 28px; border-bottom: 1px solid var(--rule); }
  .post-hero .crumbs { font-family: var(--mono); font-size: 11px; color: var(--muted); margin-bottom: 20px; letter-spacing: 0.06em; }
  .post-hero .crumbs a { color: var(--muted); }
  .post-hero .crumbs a:hover { color: var(--accent); }
  .post-hero .crumbs .sep { margin: 0 8px; color: var(--dim); }
  h1.post-title {
    font-family: var(--mono); font-weight: 700;
    font-size: clamp(30px, 3.8vw, 48px); letter-spacing: -0.02em;
    line-height: 1.08; margin: 0 0 16px; color: var(--fg);
  }
  h1.post-title .glitch { position: relative; display: inline-block; }
  h1.post-title .glitch::before, h1.post-title .glitch::after {
    content: attr(data-text); position: absolute; inset: 0; pointer-events: none;
  }
  h1.post-title .glitch::before { color: var(--accent); mix-blend-mode: screen; animation: gl1 4s infinite steps(1); }
  h1.post-title .glitch::after { color: #ff00aa; mix-blend-mode: screen; animation: gl2 3.3s infinite steps(1); }
  body.light h1.post-title .glitch::before,
  body.light h1.post-title .glitch::after { display: none; }
  @keyframes gl1 {
    0%, 94%, 100% { transform: translate(0,0); clip-path: inset(0 0 0 0); opacity: 0; }
    95% { transform: translate(-2px,1px); clip-path: inset(20% 0 50% 0); opacity: .7; }
    97% { transform: translate(2px,-1px); clip-path: inset(60% 0 10% 0); opacity: .7; }
  }
  @keyframes gl2 {
    0%, 90%, 100% { transform: translate(0,0); opacity: 0; }
    92% { transform: translate(2px,0); clip-path: inset(30% 0 40% 0); opacity: .5; }
  }
  .post-meta {
    font-family: var(--mono); font-size: 12px; color: var(--muted);
    display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px;
    margin-bottom: 24px;
  }
  .post-meta time { color: var(--fg-2); }
  .post-meta a.tag {
    color: var(--muted); padding: 2px 8px; border: 1px solid var(--rule);
    transition: all .15s;
  }
  .post-meta a.tag:hover { color: var(--accent); border-color: var(--accent); }
  .post-meta .sep { color: var(--dim); }

  .post-stats {
    display: flex; gap: 28px; flex-wrap: wrap;
    font-family: var(--mono); font-size: 12px; color: var(--muted);
    padding-top: 4px;
  }
  .post-stats span b { color: var(--fg); font-weight: 500; }

  /* LAYOUT */
  .page { display: grid; grid-template-columns: 180px minmax(0, 1fr) 300px; gap: 40px; padding: 40px 0 80px; }
  .page article { min-width: 0; grid-column: 2; }

  /* TOC */
  nav.toc { position: sticky; top: 100px; align-self: start; font-family: var(--mono); font-size: 12px; padding-right: 16px; border-right: 1px solid var(--rule); }
  nav.toc h5 { font-size: 10px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted); font-weight: 500; margin: 0 0 14px; }
  nav.toc h5::before { content: "["; color: var(--dim); }
  nav.toc h5::after { content: "]"; color: var(--dim); }
  nav.toc ol { list-style: none; margin: 0; padding: 0; counter-reset: toc; }
  nav.toc li { counter-increment: toc; margin: 0; }
  nav.toc li a {
    display: block; padding: 6px 0 6px 22px; position: relative;
    color: var(--muted); line-height: 1.4; font-size: 12px;
    border-left: 1px solid var(--rule); margin-left: -1px;
    transition: color .15s, border-color .15s;
  }
  nav.toc li a::before {
    content: counter(toc, decimal-leading-zero);
    position: absolute; left: 8px; color: var(--dim); font-size: 10px; top: 8px;
  }
  nav.toc li a:hover { color: var(--fg); }
  nav.toc li a.active { color: var(--accent); border-left-color: var(--accent); }
  nav.toc li a.active::before { color: var(--accent); }

  /* ARTICLE BODY */
  article p, article ul, article ol, article blockquote { font-family: var(--sans); font-size: 16.5px; line-height: 1.75; color: var(--fg); }
  article p { margin: 0 0 22px; }
  article p b, article p strong { font-weight: 700; color: var(--fg); }
  article a:not(.anchor):not(.btn) { color: var(--accent); border-bottom: 1px solid color-mix(in srgb, var(--accent) 35%, transparent); transition: border-color .15s; }
  article a:not(.anchor):not(.btn):hover { border-bottom-color: var(--accent); }
  article h2 {
    font-family: var(--mono); font-weight: 700; font-size: 26px; letter-spacing: -0.01em;
    margin: 48px 0 20px; line-height: 1.25;
    padding-top: 28px; border-top: 1px solid var(--rule); color: var(--fg);
    scroll-margin-top: 100px;
  }
  article h2 .anchor { color: var(--accent); margin-left: 8px; opacity: 0; transition: opacity .15s; font-weight: 400; font-size: 20px; }
  article h2:hover .anchor { opacity: 1; }
  article h3 { font-family: var(--mono); font-weight: 600; font-size: 18px; margin: 34px 0 14px; color: var(--fg); scroll-margin-top: 100px; }
  article h3 .anchor { color: var(--accent); margin-left: 8px; opacity: 0; transition: opacity .15s; }
  article h3:hover .anchor { opacity: 1; }
  article code {
    font-family: var(--mono); font-size: 0.86em;
    background: var(--bg-2); color: var(--accent);
    padding: 2px 7px; border: 1px solid var(--rule);
  }
  article ol, article ul { margin: 18px 0 22px; padding-left: 26px; }
  article li { margin-bottom: 10px; }
  article li::marker { color: var(--accent); font-family: var(--mono); }
  article ol { counter-reset: ol-c; list-style: none; padding-left: 0; }
  article ol li { counter-increment: ol-c; padding-left: 40px; position: relative; }
  article ol li::before {
    content: counter(ol-c, decimal-leading-zero) ".";
    position: absolute; left: 0; top: 0;
    font-family: var(--mono); color: var(--accent); font-weight: 600;
  }
  article blockquote {
    margin: 28px 0; padding: 16px 22px;
    background: var(--bg-2); border-left: 3px solid var(--accent);
    color: var(--fg); font-style: italic;
    font-family: var(--sans); font-size: 17px;
  }
  article blockquote::before { content: "\201C"; color: var(--accent); font-size: 32px; line-height: 0; vertical-align: -4px; margin-right: 4px; font-family: var(--mono); }

  /* CODE BLOCKS */
  .code-block { margin: 24px 0; border: 1px solid var(--rule); background: var(--bg-2); position: relative; overflow: hidden; }
  .code-block .code-head {
    display: flex; justify-content: space-between; align-items: center;
    padding: 8px 12px; border-bottom: 1px solid var(--rule);
    font-family: var(--mono); font-size: 11px; color: var(--muted);
  }
  .code-block .code-head .lang { display: inline-flex; align-items: center; gap: 8px; }
  .code-block .code-head .lang::before { content: ""; width: 8px; height: 8px; background: var(--accent); box-shadow: 0 0 6px var(--accent); }
  .code-block .copy-btn {
    font-family: var(--mono); font-size: 11px; color: var(--muted);
    padding: 4px 8px; border: 1px solid var(--rule);
    transition: all .15s;
  }
  .code-block .copy-btn:hover { color: var(--accent); border-color: var(--accent); }
  .code-block .copy-btn.copied { color: var(--accent); border-color: var(--accent); }
  .code-block pre { margin: 0; padding: 16px 18px; overflow-x: auto; background: transparent; }
  .code-block pre code {
    background: none; border: none; padding: 0; font-size: 13px;
    color: var(--fg-2); font-family: var(--mono); line-height: 1.65; display: block;
  }
  .tok-kw { color: var(--kw); font-weight: 600; }
  .tok-fn { color: var(--fn); }
  .tok-str { color: var(--str); }
  .tok-num { color: var(--num); }
  .tok-cmt { color: var(--muted); font-style: italic; }
  .tok-punct { color: var(--fg-2); }
  .tok-method { color: var(--warn); }
  .tok-url { color: var(--str); }

  /* POST NAV */
  .post-nav {
    margin-top: 64px; padding-top: 32px; border-top: 1px solid var(--rule);
    display: grid; grid-template-columns: 1fr 1fr; gap: 16px;
  }
  .post-nav a {
    display: block; padding: 18px 20px;
    border: 1px solid var(--rule); background: var(--bg-2);
    font-family: var(--mono); transition: all .15s;
  }
  .post-nav a:hover { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 6%, var(--bg-2)); }
  .post-nav a .lbl { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: 0.1em; display: block; margin-bottom: 6px; }
  .post-nav a .ttl { color: var(--fg); font-size: 14px; }
  .post-nav a:hover .ttl { color: var(--accent); }
  .post-nav a.next { text-align: right; }

  /* SIDEBAR */
  aside.side { grid-column: 3; font-family: var(--mono); position: sticky; top: 100px; align-self: start; max-height: calc(100vh - 120px); overflow-y: auto; padding-right: 4px; }
  aside.side::-webkit-scrollbar { width: 4px; }
  aside.side::-webkit-scrollbar-thumb { background: var(--rule); }
  .side-card {
    background: var(--bg-2); border: 1px solid var(--rule);
    padding: 12px 14px; margin-bottom: 24px;
    display: flex; align-items: center; gap: 10px; transition: border-color .15s;
  }
  .side-card:hover { border-color: var(--accent); }
  .side-card .fresh {
    background: var(--accent); color: #001a0e;
    font-family: var(--mono); font-size: 10px; font-weight: 700;
    letter-spacing: 0.05em; text-transform: uppercase; padding: 3px 7px; flex-shrink: 0;
  }
  body.light .side-card .fresh { color: #fff; }
  .side-card .title { font-size: 13px; color: var(--fg); flex: 1; }
  .side-card .arrow { color: var(--muted); font-size: 14px; }

  aside.side h4 {
    font-family: var(--mono); font-size: 10px; letter-spacing: 0.14em;
    text-transform: uppercase; color: var(--muted); font-weight: 500;
    margin: 28px 0 14px;
  }
  aside.side h4::before { content: "["; color: var(--dim); }
  aside.side h4::after { content: "]"; color: var(--dim); }

  .whoami { display: grid; grid-template-columns: 56px 1fr; gap: 14px; align-items: start; }
  .whoami .avatar {
    width: 56px; height: 56px;
    border: 1px solid var(--rule); background: var(--bg-2);
    display: flex; align-items: center; justify-content: center;
    color: var(--accent); font-size: 11px; line-height: 1;
    font-family: var(--mono); font-weight: 700;
    white-space: pre; text-align: center;
    position: relative; overflow: hidden;
  }
  .whoami .avatar::before {
    content: ""; position: absolute; inset: 0;
    background-image: repeating-linear-gradient(45deg, transparent 0 6px, rgba(255,77,77,0.04) 6px 12px);
  }
  .whoami .avatar span { position: relative; z-index: 1; }
  .whoami .bio p { margin: 0 0 8px; font-size: 13px; line-height: 1.5; font-family: var(--mono); }
  .whoami .bio p.lead { color: var(--fg); font-weight: 500; }
  .whoami .bio p.sub { color: var(--muted); font-size: 12px; }
  .socials { display: flex; gap: 14px; margin-top: 10px; grid-column: 1 / -1; }
  .socials a { color: var(--muted); }
  .socials a:hover { color: var(--accent); }
  .socials svg { width: 15px; height: 15px; }

  .adv-list .adv-item { display: block; padding: 11px 0; border-bottom: 1px dashed var(--rule); color: var(--fg); }
  .adv-list .adv-item:last-of-type { border-bottom: none; }
  .adv-list .adv-item .rid { font-family: var(--mono); font-size: 11px; color: var(--accent); font-weight: 600; }
  .adv-list .adv-item .rid .d { color: var(--muted); margin: 0 6px; font-weight: 400; }
  .adv-list .adv-item .at { font-family: var(--mono); font-size: 12px; color: var(--fg-2); display: block; margin-top: 3px; line-height: 1.45; }
  .adv-list .adv-item:hover .at { color: var(--accent); }
  .all-link {
    display: block; font-family: var(--mono); font-size: 10px; color: var(--muted);
    padding: 12px 0 0; border-top: 1px solid var(--rule); margin-top: 8px;
    text-transform: uppercase; letter-spacing: 0.1em;
  }
  .all-link:hover { color: var(--accent); }

  .latest-list a {
    display: flex; justify-content: space-between; gap: 12px; padding: 7px 0;
    font-family: var(--mono); font-size: 12px; color: var(--fg-2); align-items: baseline;
  }
  .latest-list a .d { color: var(--muted); font-size: 10px; white-space: nowrap; }
  .latest-list a:hover { color: var(--accent); }

  /* BACK TO TOP */
  .to-top {
    position: fixed; right: 24px; bottom: 24px; z-index: 40;
    width: 40px; height: 40px;
    background: var(--bg-2); border: 1px solid var(--rule);
    display: flex; align-items: center; justify-content: center;
    color: var(--fg-2); font-family: var(--mono); font-size: 14px;
    opacity: 0; pointer-events: none; transition: all .2s;
  }
  .to-top.on { opacity: 1; pointer-events: auto; }
  .to-top:hover { color: var(--accent); border-color: var(--accent); }

  /* RESPONSIVE */
  @media (max-width: 1100px) {
    .page { grid-template-columns: minmax(0, 1fr) 280px; gap: 36px; }
    .page article { grid-column: 1; }
    aside.side { grid-column: 2; }
    nav.toc { display: none; }
  }
  @media (max-width: 840px) {
    .wrap { padding: 0 16px; }
    .page { grid-template-columns: 1fr; padding: 28px 16px 64px; }
    aside.side { position: static; grid-column: 1; max-height: none; }
    .sub-pill input { width: 100px; }
  }
  @media (max-width: 520px) {
    .sub-pill { display: none; }
    h1.post-title { font-size: 28px; }
    .post-meta { gap: 8px 8px; }
    .post-meta a.tag { padding: 8px 10px; }
    .post-meta time { padding: 6px 0; }
  }

  body.no-glitch h1.post-title .glitch::before, body.no-glitch h1.post-title .glitch::after { animation: none !important; opacity: 0 !important; }
  @media (prefers-reduced-motion: reduce) { .gl>*, h1.post-title .glitch::before, h1.post-title .glitch::after, .ticker-track { animation: none !important; } .gl>.layer { display: none; } }
