/* ───────── tokens (default = dark) ───────── */
:root, [data-theme="dark"] {
  --bg: #0a0e14;
  --bg-2: #0f141c;
  --card: #11161d;
  --border: #1d242e;
  --border-strong: #2a3340;
  --fg: #d8dee9;
  --fg-dim: #8995a6;
  --fg-mute: #5b6878;
  --accent: #5cf2c1;
  --accent-2: #38c1ff;
  --warn: #ffb86b;
  --bad: #ff6b8b;
  --radius: 10px;
  --shadow: 0 1px 0 rgba(255,255,255,.02), 0 20px 40px -20px rgba(0,0,0,.6);
  --mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Monaco, monospace;
  --sans: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}

/* midnight: deeper, more cinematic, royal-cyan accent */
[data-theme="midnight"] {
  --bg: #050810;
  --bg-2: #08111d;
  --card: #0a1424;
  --border: #142036;
  --border-strong: #1f2f4a;
  --fg: #e2e9f6;
  --fg-dim: #8ea0bd;
  --fg-mute: #54688a;
  --accent: #79e2ff;
  --accent-2: #a78bfa;
}

/* paper: light, recruiter-friendly, paper-like */
[data-theme="paper"] {
  --bg: #faf9f5;
  --bg-2: #f3f1ea;
  --card: #ffffff;
  --border: #e8e3d6;
  --border-strong: #c8c2b1;
  --fg: #1a1a1a;
  --fg-dim: #4d4d4d;
  --fg-mute: #7a7a7a;
  --accent: #138a72;
  --accent-2: #7349a3;
  --shadow: 0 1px 0 rgba(0,0,0,.02), 0 12px 28px -16px rgba(0,0,0,.18);
}
[data-theme="paper"] body {
  background:
    radial-gradient(1200px 600px at 70% -10%, rgba(19,138,114,.06), transparent 60%),
    radial-gradient(900px 500px at 0% 0%, rgba(115,73,163,.04), transparent 70%),
    var(--bg);
}
[data-theme="paper"] .terminal,
[data-theme="paper"] .case-arch,
[data-theme="paper"] .matrix,
[data-theme="paper"] .rule-preview .rp-body { background: #1a1a1a; color: #e6e6e6 }

* { box-sizing: border-box }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body {
  background:
    radial-gradient(1200px 600px at 70% -10%, rgba(92,242,193,.06), transparent 60%),
    radial-gradient(900px 500px at 0% 0%, rgba(56,193,255,.04), transparent 70%),
    var(--bg);
}

a { color: var(--accent); text-decoration: none }
a:hover { color: var(--fg); text-decoration: underline; text-decoration-color: var(--accent); text-underline-offset: 4px }

h1, h2, h3, h4 { font-weight: 600; letter-spacing: -0.01em; color: var(--fg) }
h2 { font-size: 1.75rem; margin: 0 0 1.5rem }
h2 .num { color: var(--accent); font-family: var(--mono); font-size: 1rem; margin-right: .6rem; opacity: .9 }
h3 { font-size: 1.15rem; margin: 0 0 .5rem }

code { font-family: var(--mono); font-size: .95em; background: #1a2230; padding: 1px 6px; border-radius: 4px; color: var(--accent) }

.skip {
  position: absolute; left: -10000px; top: auto; width: 1px; height: 1px; overflow: hidden;
}
.skip:focus { position: fixed; left: 1rem; top: 1rem; width: auto; height: auto; padding: .5rem 1rem; background: var(--accent); color: var(--bg); border-radius: 6px; z-index: 999 }

/* ───────── scroll progress ───────── */
.scroll-progress {
  position: fixed; top: 0; left: 0; height: 2px; width: 0%;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  z-index: 100; transition: width .12s linear;
  box-shadow: 0 0 8px rgba(92,242,193,.6);
}

/* ───────── topbar ───────── */
.topbar {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; justify-content: space-between;
  padding: .9rem 2rem;
  background: rgba(10,14,20,.8);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.brand { display: inline-flex; align-items: center; gap: .6rem; color: var(--fg) }
.brand:hover { text-decoration: none; color: var(--fg) }
.brand-mark {
  display: inline-grid; place-items: center;
  width: 32px; height: 32px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: var(--bg);
  font-family: var(--mono); font-weight: 700; font-size: .85rem;
}
.brand-name { font-family: var(--mono); color: var(--fg-dim); font-size: .9rem }

.nav { display: flex; gap: 1.5rem }
.nav a { color: var(--fg-dim); font-size: .9rem; font-family: var(--mono) }
.nav a:hover { color: var(--accent); text-decoration: none }

.cv-btn {
  padding: .55rem 1rem; border: 1px solid var(--accent);
  border-radius: 8px; color: var(--accent); font-size: .85rem; font-family: var(--mono);
  transition: all .2s ease;
}
.cv-btn:hover { background: rgba(92,242,193,.08); text-decoration: none }

.cmdk-trigger {
  display: inline-flex; align-items: center; gap: .55rem;
  background: var(--bg-2); border: 1px solid var(--border);
  color: var(--fg-mute); font-family: var(--mono); font-size: .78rem;
  padding: .45rem .8rem; border-radius: 8px; cursor: pointer;
  transition: all .15s ease;
}
.cmdk-trigger:hover { color: var(--accent); border-color: var(--accent) }
.cmdk-trigger kbd {
  display: inline-block; padding: .05rem .35rem;
  background: var(--card); border: 1px solid var(--border-strong);
  border-radius: 4px; font-family: var(--mono); font-size: .72rem; color: var(--fg-dim);
  line-height: 1.2;
}
.cmdk-label { color: var(--fg-dim) }

@media (max-width: 720px) {
  .topbar { padding: .8rem 1rem }
  .nav { display: none }
  .cmdk-trigger .cmdk-label { display: none }
  .cv-btn { display: none }
}

/* ───────── hero ───────── */
.hero { position: relative; padding: 5rem 2rem 4rem; overflow: hidden }
.hero-grid {
  position: absolute; inset: 0;
  background-image:
    linear-gradient(rgba(92,242,193,.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(92,242,193,.04) 1px, transparent 1px);
  background-size: 40px 40px;
  mask-image: radial-gradient(ellipse 80% 60% at 50% 30%, #000 40%, transparent 90%);
  -webkit-mask-image: radial-gradient(ellipse 80% 60% at 50% 30%, #000 40%, transparent 90%);
  pointer-events: none;
}
.hero-inner {
  position: relative; max-width: 1100px; margin: 0 auto;
  display: grid; grid-template-columns: 1fr 280px; gap: 3rem; align-items: center;
}
.hero-text { min-width: 0 }
.kicker {
  display: inline-flex; align-items: center; gap: .5rem;
  font-family: var(--mono); font-size: .8rem; color: var(--accent);
  background: rgba(92,242,193,.08); padding: .4rem .9rem;
  border: 1px solid rgba(92,242,193,.2); border-radius: 999px;
  margin: 0 0 1.2rem;
}
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 8px var(--accent); animation: pulse 2s ease-in-out infinite }
@keyframes pulse { 50% { opacity: .4 } }
h1 { font-size: clamp(2rem, 5vw, 3.4rem); line-height: 1.05; margin: 0 0 .5rem }
.role { font-size: clamp(1.05rem, 2.2vw, 1.3rem); color: var(--fg-dim); margin: 0 0 1.4rem; font-weight: 400 }
.lead { color: var(--fg); max-width: 60ch; margin: 0 0 1.6rem }

.terminal {
  background: #060a10; border: 1px solid var(--border-strong);
  border-radius: var(--radius); overflow: hidden;
  box-shadow: var(--shadow);
  margin: 0 0 1.6rem; max-width: 600px;
}
.term-bar {
  display: flex; align-items: center; gap: .4rem;
  background: #0f141c; padding: .6rem .8rem; border-bottom: 1px solid var(--border);
}
.term-bar span { width: 12px; height: 12px; border-radius: 50%; background: #555 }
.term-bar span:nth-child(1) { background: #ff6b6b }
.term-bar span:nth-child(2) { background: var(--warn) }
.term-bar span:nth-child(3) { background: var(--accent) }
.term-bar em { margin-left: auto; font-style: normal; font-family: var(--mono); font-size: .75rem; color: var(--fg-mute) }
.term-body { padding: .9rem 1rem; font-family: var(--mono); font-size: .85rem; line-height: 1.7 }
.term-body p { margin: 0 }
.prompt { color: var(--accent); margin-right: .5rem }
.out { color: var(--fg-dim) }
.cursor { display: inline-block; color: var(--accent); animation: blink 1s steps(1) infinite; margin-left: 4px }
@keyframes blink { 50% { opacity: 0 } }

.hero-cta { display: flex; gap: .75rem; flex-wrap: wrap }
.btn {
  padding: .7rem 1.3rem; border-radius: 8px;
  font-family: var(--mono); font-size: .9rem;
  transition: all .15s ease;
  border: 1px solid var(--border-strong);
}
.btn.primary { background: var(--accent); color: var(--bg); border-color: var(--accent) }
.btn.primary:hover { background: #4cd9ad; transform: translateY(-1px); text-decoration: none }
.btn.ghost { background: transparent; color: var(--fg) }
.btn.ghost:hover { border-color: var(--accent); color: var(--accent); text-decoration: none }

.hero-photo { position: relative; width: 240px; height: 240px; justify-self: end }
.hero-photo img {
  width: 100%; height: 100%; border-radius: 50%;
  object-fit: cover; border: 2px solid var(--border-strong);
  position: relative; z-index: 1;
}
.photo-ring {
  position: absolute; inset: -10px; border-radius: 50%;
  border: 1px dashed rgba(92,242,193,.4);
  animation: spin 30s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg) } }

@media (max-width: 820px) {
  .hero-inner { grid-template-columns: 1fr }
  .hero-photo { justify-self: start; width: 160px; height: 160px; order: -1 }
}

/* ───────── sections ───────── */
.section { max-width: 1100px; margin: 0 auto; padding: 4.5rem 2rem }
.section-lead { color: var(--fg-dim); margin: -.8rem 0 2rem; max-width: 65ch }

/* about */
.about-grid { display: grid; grid-template-columns: 1.5fr 1fr; gap: 2.5rem }
.about-text p { margin: 0 0 1rem; color: var(--fg) }
.about-text strong { color: var(--accent); font-weight: 500 }

.about-card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1.5rem; height: fit-content;
}
.about-card h3 { margin: 0 0 1rem; font-family: var(--mono); font-size: .85rem; color: var(--fg-mute); text-transform: uppercase; letter-spacing: .12em }
.about-card ul { list-style: none; padding: 0; margin: 0 }
.about-card li {
  display: flex; justify-content: space-between; gap: 1rem;
  padding: .7rem 0; border-bottom: 1px solid var(--border);
  font-size: .9rem;
}
.about-card li:last-child { border-bottom: none }
.about-card span { color: var(--fg-mute); font-family: var(--mono); font-size: .8rem }
.about-card strong { color: var(--fg); font-weight: 500; text-align: right }

@media (max-width: 720px) {
  .about-grid { grid-template-columns: 1fr; gap: 1.5rem }
}

/* projects */
.projects {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 1.5rem;
}
.proj.featured { grid-column: 1 / -1 }
.proj.featured .proj-img { aspect-ratio: 16/8 }

.proj {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden;
  display: flex; flex-direction: column;
  transition: all .2s ease;
}
.proj:hover { border-color: var(--accent); transform: translateY(-2px); box-shadow: var(--shadow) }
.proj-img { position: relative; aspect-ratio: 16/9; overflow: hidden; background: var(--bg-2) }
.proj-img img { width: 100%; height: 100%; object-fit: cover; opacity: .85 }
.proj:hover .proj-img img { opacity: 1 }
.badge {
  position: absolute; top: 1rem; right: 1rem;
  padding: .3rem .8rem; background: rgba(10,14,20,.85); backdrop-filter: blur(6px);
  border: 1px solid var(--accent); color: var(--accent);
  font-family: var(--mono); font-size: .7rem; border-radius: 999px;
}
.proj-body { padding: 1.5rem; flex: 1; display: flex; flex-direction: column }
.proj-tagline { color: var(--fg-dim); font-size: .92rem; margin: 0 0 .8rem; font-style: italic }
.proj-body p { margin: 0 0 1rem; color: var(--fg); font-size: .92rem }
.proj-body .tags { list-style: none; padding: 0; margin: auto 0 1rem; display: flex; flex-wrap: wrap; gap: .4rem }
.proj-body .tags li {
  font-family: var(--mono); font-size: .72rem;
  background: var(--bg-2); border: 1px solid var(--border-strong);
  color: var(--fg-dim); padding: .2rem .55rem; border-radius: 4px;
}
.proj-links { font-family: var(--mono); font-size: .85rem }
.proj-links a { color: var(--accent) }

/* stack */
.stack-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 1.2rem }
.stack-card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1.4rem;
}
.stack-card h3 { font-family: var(--mono); font-size: .85rem; color: var(--accent); text-transform: uppercase; letter-spacing: .12em; margin: 0 0 1rem }
.stack-card ul { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: .5rem }
.stack-card li {
  font-family: var(--mono); font-size: .78rem; color: var(--fg);
  background: var(--bg-2); border: 1px solid var(--border-strong);
  padding: .25rem .65rem; border-radius: 4px;
}

/* certs */
.cert-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 1rem }
.cert {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1.1rem 1.3rem;
  border-left: 3px solid var(--accent);
}
.cert h4 { margin: 0 0 .3rem; font-size: .95rem; color: var(--fg) }
.cert span { font-family: var(--mono); font-size: .78rem; color: var(--fg-mute) }

/* contact */
.contact-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 1rem }
.contact-card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1.3rem;
  display: flex; flex-direction: column; gap: .5rem;
  transition: all .2s ease;
  color: var(--fg);
}
.contact-card:hover {
  border-color: var(--accent); color: var(--fg);
  text-decoration: none; transform: translateY(-2px);
}
.c-key { font-family: var(--mono); font-size: .75rem; color: var(--fg-mute); text-transform: uppercase; letter-spacing: .1em }
.c-val { font-family: var(--mono); color: var(--accent); font-size: .95rem }

/* footer */
.footer {
  border-top: 1px solid var(--border);
  padding: 2.5rem 2rem;
  text-align: center;
  color: var(--fg-mute);
  font-size: .85rem;
}
.footer .mono { font-family: var(--mono); color: var(--accent); margin-top: .3rem }

/* ───────── stats strip ───────── */
.stats-strip {
  max-width: 1100px; margin: 0 auto; padding: 0 2rem;
}
.stats-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 1px; background: var(--border);
  border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden;
}
.stat {
  background: var(--card); padding: 1.4rem 1.2rem;
  display: flex; flex-direction: column; gap: .3rem;
  transition: background .2s ease;
}
.stat:hover { background: var(--bg-2) }
.stat-num {
  font-family: var(--mono); font-size: 1.9rem; font-weight: 700;
  color: var(--accent); line-height: 1;
  font-variant-numeric: tabular-nums;
}
.stat-label { font-size: .78rem; color: var(--fg-mute); line-height: 1.45 }

/* ───────── case study ───────── */
.case-grid {
  display: grid; grid-template-columns: 1fr 1.4fr; gap: 1.5rem;
  margin: 0 0 1.5rem;
}
@media (max-width: 820px) { .case-grid { grid-template-columns: 1fr } }

.case-meta {
  background: var(--card); border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius); padding: 1.4rem 1.5rem;
  display: flex; flex-direction: column; gap: .9rem;
}
.case-row { display: flex; flex-direction: column; gap: .15rem }
.case-row span {
  font-family: var(--mono); font-size: .72rem;
  color: var(--fg-mute); text-transform: uppercase; letter-spacing: .12em;
}
.case-row strong { color: var(--fg); font-weight: 500; font-size: .94rem }

.case-arch {
  background: #060a10; border: 1px solid var(--border-strong);
  border-radius: var(--radius); padding: 1rem 1.2rem;
  overflow-x: auto;
}
.case-arch pre {
  margin: 0; font-family: var(--mono); font-size: .72rem;
  color: var(--fg-dim); line-height: 1.5;
  white-space: pre;
}

.case-deep {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden;
  transition: border-color .2s ease;
}
.case-deep[open] { border-color: var(--accent) }
.case-deep summary {
  cursor: pointer; padding: 1rem 1.4rem;
  font-family: var(--mono); font-size: .85rem; color: var(--accent);
  list-style: none; display: flex; align-items: center; gap: .6rem;
  user-select: none;
}
.case-deep summary::-webkit-details-marker { display: none }
.case-deep summary::before {
  content: '+'; display: inline-block; width: 18px; height: 18px;
  border-radius: 4px; background: rgba(92,242,193,.1); color: var(--accent);
  text-align: center; line-height: 16px; font-weight: 700;
  transition: transform .2s ease;
}
.case-deep[open] summary::before { content: '−' }
.case-deep-body {
  padding: 0 1.4rem 1.4rem; border-top: 1px solid var(--border);
  padding-top: 1.2rem;
}
.case-deep-body h3 {
  font-family: var(--mono); font-size: .8rem; color: var(--accent);
  text-transform: uppercase; letter-spacing: .12em; margin: 1.2rem 0 .6rem;
}
.case-deep-body h3:first-child { margin-top: 0 }
.case-deep-body ul { margin: 0 0 1rem; padding-left: 1.2rem; color: var(--fg) }
.case-deep-body li { margin: 0 0 .35rem; font-size: .92rem }

/* ───────── now ───────── */
.now-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 1.2rem;
}
.now-card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1.4rem 1.5rem;
  position: relative; overflow: hidden;
  transition: border-color .2s ease, transform .2s ease;
}
.now-card:hover { border-color: var(--accent); transform: translateY(-2px) }
.now-card::before {
  content: ''; position: absolute; top: 0; left: 0; height: 2px; width: 36px;
  background: var(--accent);
}
.now-card h3 {
  font-family: var(--mono); font-size: .8rem; color: var(--fg-mute);
  text-transform: uppercase; letter-spacing: .12em; margin: 0 0 .9rem;
}
.now-card ul { margin: 0; padding-left: 1.2rem; color: var(--fg) }
.now-card li { margin: 0 0 .55rem; font-size: .92rem; line-height: 1.55 }
.now-card code {
  background: var(--bg-2); color: var(--accent);
  font-size: .82em; padding: 1px 5px; border-radius: 3px;
}

/* ───────── command palette ───────── */
.cmdk[hidden] { display: none }
.cmdk {
  position: fixed; inset: 0; z-index: 200;
  display: grid; place-items: start center; padding-top: 12vh;
}
.cmdk-backdrop {
  position: absolute; inset: 0;
  background: rgba(6,10,16,.7);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  animation: fadeIn .15s ease;
}
@keyframes fadeIn { from { opacity: 0 } to { opacity: 1 } }
.cmdk-panel {
  position: relative; width: min(560px, 92vw);
  background: var(--card); border: 1px solid var(--border-strong);
  border-radius: 12px; box-shadow: 0 30px 60px -20px rgba(0,0,0,.7), 0 0 0 1px rgba(92,242,193,.08);
  overflow: hidden; animation: slideIn .18s ease;
}
@keyframes slideIn {
  from { opacity: 0; transform: translateY(-6px) scale(.98) }
  to   { opacity: 1; transform: translateY(0) scale(1) }
}
.cmdk-input-wrap {
  display: flex; align-items: center; gap: .7rem;
  padding: .9rem 1.1rem; border-bottom: 1px solid var(--border);
}
.cmdk-prompt {
  font-family: var(--mono); color: var(--accent); font-size: 1rem;
}
.cmdk-input-wrap input {
  flex: 1; background: transparent; border: 0; outline: 0;
  color: var(--fg); font-family: var(--sans); font-size: .98rem;
}
.cmdk-input-wrap input::placeholder { color: var(--fg-mute) }
.cmdk-input-wrap kbd {
  font-family: var(--mono); font-size: .68rem; color: var(--fg-mute);
  padding: .15rem .45rem; background: var(--bg-2);
  border: 1px solid var(--border-strong); border-radius: 4px;
}
.cmdk-list {
  list-style: none; margin: 0; padding: .4rem 0;
  max-height: 50vh; overflow-y: auto;
}
.cmdk-list li {
  padding: .65rem 1.1rem; cursor: pointer;
  display: flex; align-items: center; gap: .8rem;
  border-left: 2px solid transparent;
}
.cmdk-list li[aria-selected="true"] {
  background: rgba(92,242,193,.06); border-left-color: var(--accent);
}
.cmdk-list .ck-icon {
  font-family: var(--mono); font-size: .85rem; color: var(--fg-mute); width: 18px; text-align: center;
}
.cmdk-list .ck-title { color: var(--fg); font-size: .94rem; flex: 1 }
.cmdk-list .ck-hint {
  font-family: var(--mono); font-size: .72rem; color: var(--fg-mute);
  text-transform: uppercase; letter-spacing: .08em;
}
.cmdk-list li[aria-selected="true"] .ck-title { color: var(--accent) }
.cmdk-list li[aria-selected="true"] .ck-hint { color: var(--accent) }
.cmdk-empty {
  padding: 2rem 1.1rem; text-align: center; color: var(--fg-mute);
  font-family: var(--mono); font-size: .85rem;
}
.cmdk-foot {
  display: flex; gap: 1.2rem; padding: .6rem 1.1rem;
  border-top: 1px solid var(--border);
  background: var(--bg-2);
}
.cmdk-foot span {
  font-family: var(--mono); font-size: .72rem; color: var(--fg-mute);
  display: inline-flex; align-items: center; gap: .35rem;
}
.cmdk-foot kbd {
  padding: .1rem .35rem; background: var(--card);
  border: 1px solid var(--border-strong); border-radius: 3px;
  font-family: var(--mono); font-size: .68rem; color: var(--fg-dim);
}

/* fade-in */
.fade-in { opacity: 0; transform: translateY(12px); transition: opacity .6s ease, transform .6s ease }
.fade-in.in { opacity: 1; transform: translateY(0) }

/* typed cursor */
.typed::after {
  content: '█'; color: var(--accent); margin-left: 1px;
  animation: blink 1s steps(1) infinite;
}
.typed.done::after { display: none }

/* ───────── top actions cluster ───────── */
.top-actions { display: inline-flex; align-items: center; gap: .55rem }

/* ───────── theme toggle ───────── */
.theme-toggle {
  display: inline-flex; align-items: center; gap: .45rem;
  background: var(--bg-2); border: 1px solid var(--border);
  color: var(--fg-dim); font-family: var(--mono); font-size: .76rem;
  padding: .45rem .65rem .45rem .55rem; border-radius: 8px; cursor: pointer;
  transition: all .15s ease;
}
.theme-toggle:hover { color: var(--accent); border-color: var(--accent) }
.th-icon {
  width: 14px; height: 14px; border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: inset -3px -2px 0 0 rgba(0,0,0,.35);
  flex-shrink: 0;
}
.th-label { letter-spacing: .04em }
@media (max-width: 720px) { .th-label { display: none } }

/* ───────── section indicator (right edge sticky list) ───────── */
.section-indicator {
  position: fixed; top: 50%; right: 1rem; transform: translateY(-50%);
  z-index: 30; pointer-events: auto;
  font-family: var(--mono); font-size: .7rem;
}
.section-indicator ol { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .15rem }
.section-indicator li {
  display: flex; align-items: center; gap: .55rem;
  padding: .25rem .55rem .25rem .4rem;
  color: var(--fg-mute); cursor: pointer; user-select: none;
  border-right: 2px solid transparent;
  transition: color .15s ease, border-color .15s ease, transform .15s ease;
}
.section-indicator li:hover { color: var(--accent); transform: translateX(-2px) }
.section-indicator li.active {
  color: var(--accent); border-right-color: var(--accent);
}
.section-indicator .si-num { color: inherit; opacity: .7; font-size: .7em }
.section-indicator .si-name {
  opacity: 0; max-width: 0; overflow: hidden; white-space: nowrap;
  transition: opacity .2s ease, max-width .2s ease;
}
.section-indicator li:hover .si-name,
.section-indicator li.active .si-name { opacity: 1; max-width: 8rem }
@media (max-width: 1100px) { .section-indicator { display: none } }

/* ───────── MITRE ATT&CK matrix ───────── */
.matrix-wrap { margin: 0 0 1.5rem; }
.matrix-legend {
  display: flex; gap: 1.4rem; flex-wrap: wrap;
  margin: 0 0 1rem;
  font-family: var(--mono); font-size: .76rem; color: var(--fg-mute);
}
.matrix-legend .lg { display: inline-flex; align-items: center; gap: .45rem }
.matrix-legend .lg i {
  display: inline-block; width: 12px; height: 12px; border-radius: 3px;
  background: var(--bg-2); border: 1px solid var(--border-strong);
}
.matrix-legend .covered i { background: rgba(92,242,193,.6); border-color: var(--accent); box-shadow: inset 0 0 0 2px rgba(0,0,0,.3) }
.matrix-legend .planned i { background: rgba(255,184,107,.4); border-color: var(--warn) }
.matrix-legend .out i { background: var(--bg-2); border-style: dashed }

.matrix {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 1rem;
  background: #060a10;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  padding: 1.2rem;
  position: relative;
}
[data-theme="paper"] .matrix { background: #fdfdf8; border-color: #d8d2bf }

.tactic { display: flex; flex-direction: column; gap: .4rem }
.tactic-name {
  font-family: var(--mono); font-size: .7rem; font-weight: 700;
  color: var(--accent); text-transform: uppercase; letter-spacing: .1em;
  border-bottom: 1px solid var(--border); padding: 0 0 .5rem;
  margin: 0;
}
.tactic ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .2rem }

.ttp {
  position: relative;
  padding: .35rem .55rem;
  font-family: var(--mono); font-size: .72rem;
  background: var(--bg-2);
  border: 1px solid var(--border-strong);
  border-radius: 4px;
  color: var(--fg-dim);
  cursor: default;
  transition: all .15s ease;
  display: flex; align-items: center; gap: .4rem;
  outline: none;
}
.ttp .ttp-id { color: var(--fg-mute); font-size: .68rem; flex-shrink: 0 }
.ttp .ttp-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap }
.ttp[data-state="covered"] {
  background: linear-gradient(135deg, rgba(92,242,193,.18), rgba(56,193,255,.08));
  border-color: var(--accent); color: var(--fg);
  box-shadow: 0 0 0 0 rgba(92,242,193,0);
}
.ttp[data-state="covered"]:hover, .ttp[data-state="covered"]:focus {
  background: linear-gradient(135deg, rgba(92,242,193,.32), rgba(56,193,255,.16));
  box-shadow: 0 0 18px -4px rgba(92,242,193,.45);
  transform: translateY(-1px);
}
.ttp[data-state="planned"] {
  border-color: var(--warn); color: var(--fg-dim);
  background: rgba(255,184,107,.08);
}
.ttp[data-state="out"] { border-style: dashed; opacity: .55 }
.ttp[data-state="covered"]::before {
  content: ''; width: 6px; height: 6px; border-radius: 50%;
  background: var(--accent); box-shadow: 0 0 8px var(--accent);
  flex-shrink: 0;
}

.matrix-foot {
  margin: 1rem 0 0; font-family: var(--mono); font-size: .76rem;
  color: var(--fg-mute);
}
.matrix-foot a { color: var(--accent) }

/* live rule preview */
.rule-preview {
  margin: 1.4rem 0 0;
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden;
  transition: border-color .2s ease;
}
.rule-preview.live { border-color: var(--accent) }
.rp-bar {
  display: flex; align-items: center; gap: .7rem;
  padding: .7rem 1.1rem; border-bottom: 1px solid var(--border);
  background: var(--bg-2);
  font-family: var(--mono); font-size: .78rem;
}
.rp-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--accent); box-shadow: 0 0 8px var(--accent);
  animation: pulse 2s ease-in-out infinite;
}
.rp-title { color: var(--fg); font-weight: 500 }
.rp-tag { margin-left: auto; color: var(--fg-mute); text-transform: uppercase; letter-spacing: .1em; font-size: .7rem }
.rp-body {
  margin: 0; padding: 1rem 1.2rem;
  font-family: var(--mono); font-size: .78rem;
  line-height: 1.6;
  background: #060a10; color: var(--fg);
  overflow-x: auto;
}
.rp-body code { background: transparent; color: inherit; padding: 0 }

/* ───────── CRT / scanline overlay (subtle) ───────── */
.crt-overlay {
  position: fixed; inset: 0; pointer-events: none; z-index: 5;
  background:
    repeating-linear-gradient(180deg, rgba(255,255,255,0) 0px, rgba(255,255,255,0) 2px, rgba(255,255,255,.012) 3px, rgba(255,255,255,.012) 3px),
    radial-gradient(ellipse at center, transparent 60%, rgba(0,0,0,.25) 100%);
  mix-blend-mode: overlay;
  opacity: 0;
  transition: opacity .4s ease;
}
[data-fx="crt"] .crt-overlay { opacity: 1 }

/* ───────── footer kbd hint ───────── */
.footer .kbd-hint {
  margin-top: .8rem; opacity: .55; font-size: .72rem;
  display: flex; gap: .3rem; align-items: center; justify-content: center; flex-wrap: wrap;
}
.footer .kbd-hint kbd {
  font-family: var(--mono); font-size: .68rem;
  background: var(--bg-2); border: 1px solid var(--border-strong);
  padding: .05rem .35rem; border-radius: 3px; color: var(--fg-dim);
  margin: 0 .1rem;
}
@media (max-width: 720px) { .footer .kbd-hint { display: none } }

/* ───────── keyboard help modal (?) ───────── */
.khelp[hidden] { display: none }
.khelp {
  position: fixed; inset: 0; z-index: 200;
  display: grid; place-items: center; padding: 2rem;
}
.khelp-backdrop {
  position: absolute; inset: 0;
  background: rgba(6,10,16,.7); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  animation: fadeIn .15s ease;
}
.khelp-panel {
  position: relative; width: min(520px, 92vw);
  background: var(--card); border: 1px solid var(--border-strong);
  border-radius: 12px; box-shadow: 0 30px 60px -20px rgba(0,0,0,.7);
  padding: 1.6rem; animation: slideIn .18s ease;
}
.khelp-panel header {
  display: flex; align-items: center; justify-content: space-between;
  border-bottom: 1px solid var(--border); padding: 0 0 1rem; margin: 0 0 1rem;
}
.khelp-panel header h3 { margin: 0; font-family: var(--mono); font-size: .9rem; color: var(--accent) }
.khelp-x {
  background: transparent; border: 0; color: var(--fg-mute); font-size: 1.4rem;
  cursor: pointer; padding: 0 .4rem; line-height: 1;
}
.khelp-x:hover { color: var(--accent) }
.khelp-grid {
  display: grid; grid-template-columns: max-content 1fr; gap: .55rem 1.1rem;
  font-size: .88rem;
}
.khelp-grid > div:nth-child(odd) {
  font-family: var(--mono); color: var(--fg-dim); white-space: nowrap;
}
.khelp-grid > div:nth-child(even) { color: var(--fg) }
.khelp-grid kbd {
  font-family: var(--mono); font-size: .72rem;
  background: var(--bg-2); border: 1px solid var(--border-strong);
  padding: .08rem .4rem; border-radius: 3px; color: var(--fg);
  margin: 0 .1rem;
}

/* ───────── scroll-to-top FAB ───────── */
.totop {
  position: fixed; right: 1.4rem; bottom: 1.4rem; z-index: 40;
  width: 38px; height: 38px; border-radius: 50%;
  background: var(--card); border: 1px solid var(--border-strong);
  color: var(--accent); cursor: pointer;
  display: grid; place-items: center;
  font-family: var(--mono); font-size: .8rem;
  opacity: 0; transform: translateY(8px) scale(.94);
  transition: all .2s ease; pointer-events: none;
}
.totop.visible { opacity: 1; transform: translateY(0) scale(1); pointer-events: auto }
.totop:hover { color: var(--bg); background: var(--accent); border-color: var(--accent) }
@media (max-width: 720px) { .totop { right: 1rem; bottom: 1rem } }

/* ───────── PRINT mode (?print or window.matchMedia print) ───────── */
@media print {
  body { background: #fff !important; color: #111 !important; font-size: 11pt }
  .scroll-progress, .crt-overlay, .section-indicator, .topbar .nav, .top-actions, .totop, .khelp, .cmdk, .cmdline, .ticker, .liveops, .warroom, .boot, .footer .kbd-hint, .photo-ring, .now-grid, .stats-strip, .case-deep, .rule-preview, #achievements, #offensive .killchain, .purple-stats, .purple-deep { display: none !important }
  .terminal, .case-arch, .hero-grid { display: none !important }
  .topbar { position: static; border-bottom: 2px solid #111; padding: .8rem 0; background: #fff; backdrop-filter: none }
  .brand-mark { background: #111 !important; color: #fff !important }
  .brand-name { color: #111 !important }
  .hero { padding: 1rem 0 .5rem; }
  .hero-inner { display: block; max-width: none }
  .hero-photo { display: none }
  h1 { font-size: 22pt; color: #111 }
  .role { color: #444 }
  .lead { color: #222 }
  .kicker { background: transparent; border-color: #111; color: #111 }
  .section { padding: 1rem 0; max-width: none; page-break-inside: avoid }
  .section h2 { color: #111; border-bottom: 1px solid #111; padding-bottom: .25rem }
  h2 .num { color: #111 }
  .about-grid { grid-template-columns: 1fr 1fr; gap: 1rem }
  .about-card { background: #fff; border: 1px solid #111 }
  .about-card span, .about-card strong { color: #111 }
  .case-grid { grid-template-columns: 1fr; gap: 0 }
  .case-meta { background: #fff; border: 1px solid #111 }
  .case-row span { color: #111; font-weight: 700 }
  .case-row strong { color: #222 }
  .matrix { background: #fff; border: 1px solid #111; padding: .8rem }
  .ttp { background: #fff; color: #222 !important; border: 1px solid #888 !important }
  .ttp[data-state="covered"] { background: #cdeede !important; border-color: #138a72 !important; color: #0a3a30 !important }
  .ttp[data-state="covered"]::before { background: #138a72 !important; box-shadow: none !important }
  .projects { display: block }
  .proj { background: #fff; border: 1px solid #111; margin: 0 0 .6rem; page-break-inside: avoid }
  .proj-img { display: none }
  .proj-tagline { color: #444 }
  .stack-grid { grid-template-columns: repeat(2, 1fr); gap: .6rem }
  .stack-card { background: #fff; border: 1px solid #111 }
  .stack-card h3 { color: #111 }
  .stack-card li { background: #fff; color: #111; border: 1px solid #aaa }
  .cert { background: #fff; border: 1px solid #111; border-left: 3px solid #138a72 }
  .cert h4, .cert span { color: #111 }
  .contact-grid { grid-template-columns: 1fr 1fr 1fr 1fr; gap: .5rem }
  .contact-card { background: #fff; border: 1px solid #111 }
  .c-key, .c-val { color: #111 }
  a { color: #111; text-decoration: underline }
  .footer { border-top: 1px solid #111; padding: .8rem 0; color: #444 }
  .typed::after, .cursor { display: none !important }
  .typed { color: inherit }
  /* Reveal sections that have data-typed by replacing them with their data-typed value */
  [data-typed]::before { content: attr(data-typed) }
  [data-typed] { color: inherit }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important }
}

/* ═══════════════════════════════════════════════════════════
 * v2 — blue + red + purple
 * ─────────────────────────────────────────────────────────── */

/* ── team palette (works in every theme) ── */
:root {
  --team-blue: #5cf2c1;
  --team-red:  #ff6b8b;
  --team-purple: #a78bfa;
}
[data-theme="midnight"] {
  --team-blue: #79e2ff;
  --team-red:  #ff7a99;
  --team-purple: #a78bfa;
}
[data-theme="paper"] {
  --team-blue: #138a72;
  --team-red:  #b1284b;
  --team-purple: #7349a3;
}

/* ── phosphor: green-on-black CRT, fourth theme ── */
[data-theme="phosphor"] {
  --bg: #020604;
  --bg-2: #051209;
  --card: #061a0e;
  --border: #0a3a1c;
  --border-strong: #126b34;
  --fg: #b6ffcc;
  --fg-dim: #6dd394;
  --fg-mute: #2f9259;
  --accent: #5cff9e;
  --accent-2: #38ffc1;
  --warn: #fff36b;
  --bad: #ff7a99;
  --shadow: 0 1px 0 rgba(92,255,158,.05), 0 20px 40px -20px rgba(0,0,0,.85);
  --team-blue: #5cff9e;
  --team-red:  #ff7a99;
  --team-purple: #c79bff;
}
[data-theme="phosphor"] body {
  background:
    radial-gradient(1200px 600px at 70% -10%, rgba(92,255,158,.08), transparent 60%),
    radial-gradient(900px 500px at 0% 0%, rgba(56,255,193,.05), transparent 70%),
    var(--bg);
}
[data-theme="phosphor"] body::before {
  content: ''; pointer-events: none; position: fixed; inset: 0; z-index: 1;
  background: repeating-linear-gradient(0deg, rgba(0,0,0,0) 0, rgba(0,0,0,0) 2px, rgba(0,0,0,.18) 3px, rgba(0,0,0,0) 4px);
  mix-blend-mode: multiply;
}
[data-theme="phosphor"] code,
[data-theme="phosphor"] .terminal,
[data-theme="phosphor"] .case-arch,
[data-theme="phosphor"] .matrix,
[data-theme="phosphor"] .rule-preview .rp-body { background: #030d06; color: var(--fg) }
[data-theme="phosphor"] h1, [data-theme="phosphor"] h2, [data-theme="phosphor"] h3, [data-theme="phosphor"] h4 { text-shadow: 0 0 6px rgba(92,255,158,.45) }

/* ── role tags (hero) ── */
.role-tag {
  display: inline-block;
  padding: .15rem .55rem;
  border-radius: 6px;
  font-family: var(--mono);
  font-size: .8em;
  letter-spacing: .04em;
  border: 1px solid currentColor;
  margin: 0 .15rem;
  vertical-align: 2%;
}
.role-tag.blue   { color: var(--team-blue) }
.role-tag.red    { color: var(--team-red) }
.role-tag.purple { color: var(--team-purple) }
.role-plus { color: var(--fg-mute); font-family: var(--mono); margin: 0 .1rem; opacity: .55 }

/* ── nav team accents ── */
.nav .nav-blue   { color: var(--team-blue) }
.nav .nav-red    { color: var(--team-red) }
.nav .nav-purple { color: var(--team-purple) }
.nav .nav-blue:hover, .nav .nav-red:hover, .nav .nav-purple:hover {
  text-decoration: underline; text-underline-offset: 4px; text-decoration-color: currentColor;
}

/* ── section-indicator team-coloured leader ── */
.section-indicator li[data-team="blue"]   .si-num { color: var(--team-blue) }
.section-indicator li[data-team="red"]    .si-num { color: var(--team-red) }
.section-indicator li[data-team="purple"] .si-num { color: var(--team-purple) }

/* ── team pills (next to section h2) ── */
.team-pill {
  display: inline-block;
  margin-left: .8rem;
  padding: .2rem .65rem;
  border-radius: 999px;
  font-family: var(--mono); font-size: .68rem; font-weight: 500;
  letter-spacing: .08em; text-transform: lowercase;
  border: 1px solid;
  vertical-align: 4px;
}
.team-pill.blue   { color: var(--team-blue);   border-color: var(--team-blue);   background: color-mix(in srgb, var(--team-blue)   12%, transparent) }
.team-pill.red    { color: var(--team-red);    border-color: var(--team-red);    background: color-mix(in srgb, var(--team-red)    12%, transparent) }
.team-pill.purple { color: var(--team-purple); border-color: var(--team-purple); background: color-mix(in srgb, var(--team-purple) 12%, transparent) }

.team-tag {
  display: inline-block;
  margin-right: .55rem;
  padding: 0 .45rem;
  border-radius: 4px;
  font-family: var(--mono); font-size: .65rem; font-weight: 600;
  letter-spacing: .08em; text-transform: uppercase;
  border: 1px solid var(--border-strong); color: var(--fg-dim);
  vertical-align: 1px;
}
.team-tag.blue   { color: var(--team-blue);   border-color: var(--team-blue) }
.team-tag.red    { color: var(--team-red);    border-color: var(--team-red) }
.team-tag.purple { color: var(--team-purple); border-color: var(--team-purple) }

/* ── section accents (left rail per team) ── */
.section-team { position: relative }
.section-team::before {
  content: ''; position: absolute; left: 1rem; top: 1.5rem; bottom: 1.5rem; width: 2px;
  background: linear-gradient(180deg, var(--rail), transparent 90%);
  opacity: .55; pointer-events: none;
}
.section-team[data-team="blue"]   { --rail: var(--team-blue) }
.section-team[data-team="red"]    { --rail: var(--team-red) }
.section-team[data-team="purple"] { --rail: var(--team-purple) }
@media (max-width: 720px) { .section-team::before { display: none } }

/* ─────────── THREAT-INTEL TICKER ─────────── */
.ticker {
  position: sticky; top: 0; z-index: 49;
  display: flex; align-items: center; gap: .9rem;
  height: 30px;
  padding: 0 0 0 .8rem;
  background: linear-gradient(90deg, color-mix(in srgb, var(--bg-2) 96%, transparent), transparent 18%, transparent 82%, color-mix(in srgb, var(--bg-2) 96%, transparent));
  border-bottom: 1px solid var(--border);
  font-family: var(--mono); font-size: .76rem; color: var(--fg-mute);
  overflow: hidden; white-space: nowrap;
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
}
.tk-tag {
  flex: 0 0 auto;
  color: var(--accent);
  font-weight: 500;
  border-right: 1px solid var(--border);
  padding-right: .9rem;
}
.tk-track {
  display: inline-flex; gap: 2.4rem; align-items: center;
  flex: 1 1 auto;
  animation: tickerScroll 80s linear infinite;
  will-change: transform;
}
.tk-track:hover { animation-play-state: paused }
.tk-track > span { flex: 0 0 auto }
.tk-track code { background: transparent; color: var(--fg-dim); padding: 0; font-size: inherit }
.tk-blue   { color: var(--team-blue);   font-family: var(--mono); font-weight: 500 }
.tk-red    { color: var(--team-red);    font-family: var(--mono); font-weight: 500 }
.tk-purple { color: var(--team-purple); font-family: var(--mono); font-weight: 500 }
@keyframes tickerScroll {
  from { transform: translateX(0) }
  to   { transform: translateX(-50%) }
}
@media (prefers-reduced-motion: reduce) {
  .tk-track { animation: none; transform: translateX(0); white-space: normal; }
}
@media (max-width: 720px) {
  .ticker { font-size: .7rem }
  .tk-tag { display: none }
}

/* ─────────── KILL CHAIN (red section) ─────────── */
.killchain {
  list-style: none; counter-reset: kc;
  margin: 0 0 2rem; padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: .6rem;
}
.killchain li {
  position: relative;
  background: var(--card);
  border: 1px solid var(--border);
  border-left: 3px solid var(--team-red);
  border-radius: var(--radius);
  padding: .85rem .95rem;
}
.killchain .kc-num {
  display: inline-block;
  font-family: var(--mono); font-size: .68rem;
  color: var(--team-red); letter-spacing: .12em;
  background: color-mix(in srgb, var(--team-red) 12%, transparent);
  padding: .15rem .55rem; border-radius: 4px; margin-bottom: .4rem;
}
.killchain strong { display: block; font-size: 1rem; color: var(--fg); margin: .15rem 0 .3rem }
.killchain p { margin: 0 0 .5rem; color: var(--fg-dim); font-size: .87rem; line-height: 1.45 }
.killchain code { display: block; font-size: .78rem; padding: .35rem .5rem; background: var(--bg-2); color: var(--fg-mute); border-radius: 4px; word-break: break-word; white-space: normal }

/* off-cards: red supporting cards */
.offensive-grid {
  display: grid; gap: .9rem;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}
.off-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-top: 2px solid var(--team-red);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
  display: flex; flex-direction: column; gap: .5rem;
  transition: transform .18s ease, border-color .18s ease;
}
.off-card:hover { transform: translateY(-2px); border-color: var(--team-red) }
.off-card header span {
  font-family: var(--mono); font-size: .9rem; color: var(--team-red); font-weight: 500;
}
.off-card p { color: var(--fg-dim); font-size: .9rem; line-height: 1.55; margin: 0; flex: 1 }
.off-card footer { padding-top: .4rem; border-top: 1px dashed var(--border); }
.off-card footer a { font-family: var(--mono); font-size: .82rem; color: var(--team-red) }
.off-card .off-meta { font-family: var(--mono); font-size: .78rem; color: var(--fg-mute) }

/* ─────────── PURPLE-LOOP ─────────── */
.purple-loop {
  list-style: none; counter-reset: pl;
  margin: 0 0 1.5rem; padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: .6rem;
  position: relative;
}
.purple-loop li {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
  position: relative; overflow: hidden;
}
.purple-loop li::before {
  content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 3px;
  background: linear-gradient(180deg, var(--team-blue) 0%, var(--team-purple) 50%, var(--team-red) 100%);
  opacity: .85;
}
.purple-loop .pl-num {
  display: inline-block; font-family: var(--mono); font-size: .68rem;
  color: var(--team-purple); letter-spacing: .12em;
  background: color-mix(in srgb, var(--team-purple) 12%, transparent);
  padding: .15rem .55rem; border-radius: 4px; margin-bottom: .35rem;
}
.purple-loop h4 { font-size: .98rem; color: var(--fg); margin: 0 0 .35rem }
.purple-loop p { margin: 0; color: var(--fg-dim); font-size: .87rem; line-height: 1.5 }

.purple-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: .6rem;
  margin: 0 0 1.4rem;
}
.ps-card {
  background: color-mix(in srgb, var(--team-purple) 7%, var(--card));
  border: 1px solid color-mix(in srgb, var(--team-purple) 28%, var(--border));
  border-radius: var(--radius);
  padding: .9rem 1rem;
  display: flex; flex-direction: column; gap: .15rem;
}
.ps-num {
  font-family: var(--mono); font-size: 1.55rem; color: var(--team-purple); font-weight: 700;
}
.ps-lbl { font-size: .8rem; color: var(--fg-dim) }

.purple-deep {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-left: 3px solid var(--team-purple);
  border-radius: var(--radius);
  padding: 0;
  overflow: hidden;
}
.purple-deep summary {
  cursor: pointer;
  padding: .8rem 1rem;
  font-family: var(--mono); font-size: .88rem; color: var(--team-purple);
  list-style: none;
}
.purple-deep summary::-webkit-details-marker { display: none }
.purple-deep summary::before { content: '> '; color: var(--fg-mute) }
.purple-deep[open] summary::before { content: 'v ' }
.purple-deep-body { padding: 0 1.1rem 1rem; border-top: 1px dashed var(--border) }
.purple-deep-body p { margin: .55rem 0; color: var(--fg-dim); font-size: .9rem; line-height: 1.55 }
.purple-deep-body strong { color: var(--fg) }

/* ─────────── ACHIEVEMENTS WALL ─────────── */
.ach-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: .8rem;
}
.ach {
  position: relative;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.05rem 1.1rem 1.15rem;
  display: flex; flex-direction: column; gap: .35rem;
  transition: transform .18s ease, border-color .18s ease;
}
.ach:hover { transform: translateY(-2px) }
.ach .ach-icon {
  display: inline-grid; place-items: center;
  width: 36px; height: 36px;
  border-radius: 8px;
  font-size: 1.15rem; font-weight: 700;
  border: 1px solid var(--border-strong);
  margin: 0 0 .4rem;
}
.ach h4 { margin: 0; font-size: 1rem; color: var(--fg) }
.ach p  { margin: 0; color: var(--fg-dim); font-size: .87rem; line-height: 1.5; flex: 1 }
.ach code { font-size: .8rem }
.ach .ach-meta {
  font-family: var(--mono); font-size: .7rem;
  color: var(--fg-mute); letter-spacing: .06em;
  margin-top: .25rem;
}
.ach.blue        { border-top: 2px solid var(--team-blue) }
.ach.red         { border-top: 2px solid var(--team-red) }
.ach.purple      { border-top: 2px solid var(--team-purple) }
.ach.blue   .ach-icon   { color: var(--team-blue);   border-color: var(--team-blue);   background: color-mix(in srgb, var(--team-blue)   8%, transparent) }
.ach.red    .ach-icon   { color: var(--team-red);    border-color: var(--team-red);    background: color-mix(in srgb, var(--team-red)    8%, transparent) }
.ach.purple .ach-icon   { color: var(--team-purple); border-color: var(--team-purple); background: color-mix(in srgb, var(--team-purple) 8%, transparent) }
.ach[data-state="progress"] { border-style: dashed }
.ach[data-state="progress"]::after {
  content: 'in progress'; position: absolute; right: .7rem; top: .7rem;
  font-family: var(--mono); font-size: .65rem; letter-spacing: .1em;
  color: var(--warn);
  padding: .15rem .5rem; border-radius: 4px;
  background: color-mix(in srgb, var(--warn) 10%, transparent);
  border: 1px solid color-mix(in srgb, var(--warn) 35%, transparent);
}

/* ─────────── LIVE OPS WIDGET ─────────── */
.liveops {
  position: fixed; left: 1rem; bottom: 1rem; z-index: 60;
  width: 230px;
  background: color-mix(in srgb, var(--bg-2) 92%, transparent);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  font-family: var(--mono); font-size: .75rem;
  color: var(--fg-dim);
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  transition: transform .25s ease, opacity .25s ease;
}
.liveops.hidden { transform: translateY(140%); opacity: 0; pointer-events: none }
.lo-head {
  display: flex; align-items: center; gap: .5rem;
  padding: .45rem .6rem;
  border-bottom: 1px solid var(--border);
}
.lo-led {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 6px var(--accent);
  animation: pulse 2s ease-in-out infinite;
}
.lo-name { color: var(--accent); flex: 1 }
.lo-x {
  background: transparent; border: 0; color: var(--fg-mute);
  cursor: pointer; font-family: var(--mono); font-size: 1rem; line-height: 1;
}
.lo-x:hover { color: var(--accent) }
.lo-rows { margin: 0; padding: .55rem .6rem }
.lo-rows > div { display: flex; justify-content: space-between; gap: .5rem; padding: .15rem 0 }
.lo-rows dt { color: var(--fg-mute) }
.lo-rows dd { margin: 0; color: var(--fg) }
.lo-pill {
  display: inline-block;
  font-size: .65rem; padding: 0 .35rem; border-radius: 3px;
  margin-left: .15rem; border: 1px solid currentColor;
}
.lo-pill.blue   { color: var(--team-blue) }
.lo-pill.red    { color: var(--team-red) }
.lo-pill.purple { color: var(--team-purple) }
@media (max-width: 720px) {
  .liveops { left: .6rem; right: .6rem; width: auto; bottom: .6rem }
}

/* ─────────── VIM CMDLINE ─────────── */
.cmdline[hidden] { display: none }
.cmdline {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 70;
  display: flex; align-items: center; gap: .55rem;
  padding: .55rem .9rem;
  background: var(--bg-2);
  border-top: 1px solid var(--accent);
  font-family: var(--mono); font-size: .92rem;
  color: var(--fg);
  box-shadow: 0 -8px 24px -12px rgba(0,0,0,.6);
}
.cl-colon { color: var(--accent); font-weight: 700 }
.cmdline input {
  flex: 1 1 auto;
  background: transparent; border: 0; outline: none;
  color: var(--fg); font: inherit;
  caret-color: var(--accent);
}
.cl-hint { color: var(--fg-mute); font-size: .82rem; flex: 0 0 auto }
.cl-hint code { background: transparent; color: var(--accent); padding: 0; font-size: inherit }

/* ─────────── BOOT OVERLAY (first visit) ─────────── */
.boot[hidden] { display: none }
.boot {
  position: fixed; inset: 0; z-index: 200;
  background: #02050a;
  display: grid; place-items: center;
  font-family: var(--mono);
  color: #79e2ff;
  animation: bootFade .25s ease-out;
}
.boot::before {
  content: ''; position: absolute; inset: 0; pointer-events: none;
  background: repeating-linear-gradient(0deg, rgba(0,0,0,0) 0, rgba(0,0,0,0) 2px, rgba(0,0,0,.45) 3px, rgba(0,0,0,0) 4px);
}
.boot-screen {
  width: min(640px, 90vw);
  padding: 1.4rem 1.6rem;
  position: relative;
}
.boot-banner {
  margin: 0 0 .8rem; color: #5cf2c1; font-size: .82rem; line-height: 1.4;
}
.boot-log { list-style: none; margin: 0; padding: 0; min-height: 240px }
.boot-log li {
  padding: .12rem 0; font-size: .82rem; color: #c8d4e6; opacity: 0;
  animation: bootLine .3s ease-out forwards;
}
.boot-log li b { color: #5cf2c1; margin-right: .55rem }
.boot-log li.warn b  { color: #ffb86b }
.boot-log li.bad  b  { color: #ff6b8b }
.boot-log li.done b  { color: #5cf2c1 }
.boot-skip {
  margin: 1rem 0 0; color: #54688a; font-size: .72rem;
}
.boot-skip kbd {
  display: inline-block; padding: 0 .35rem;
  border: 1px solid #1f2f4a; border-radius: 4px;
  font-family: inherit; font-size: .68rem; color: #79e2ff;
}
@keyframes bootFade { from { opacity: 0 } to { opacity: 1 } }
@keyframes bootLine { from { opacity: 0; transform: translateX(-4px) } to { opacity: 1; transform: translateX(0) } }

/* ─────────── WAR-ROOM (Konami) ─────────── */
.warroom[hidden] { display: none }
.warroom {
  position: fixed; inset: 0; z-index: 220;
  display: grid; place-items: center;
  animation: bootFade .2s ease-out;
}
.wr-backdrop {
  position: absolute; inset: 0;
  background: radial-gradient(ellipse at 30% 30%, rgba(167,139,250,.15), rgba(0,0,0,.85));
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
}
.wr-panel {
  position: relative;
  width: min(620px, 92vw);
  background: var(--card);
  border: 1px solid var(--team-purple);
  border-radius: var(--radius);
  box-shadow: 0 30px 60px -20px rgba(0,0,0,.7), 0 0 0 1px rgba(167,139,250,.3);
  overflow: hidden;
}
.wr-head {
  display: flex; align-items: center; gap: .6rem;
  padding: .65rem .9rem;
  background: var(--bg-2); border-bottom: 1px solid var(--border);
  font-family: var(--mono); font-size: .8rem; color: var(--fg-dim);
}
.wr-dots { display: inline-flex; gap: .35rem }
.wr-dots i { width: 10px; height: 10px; border-radius: 50%; background: #2a3340; display: inline-block }
.wr-dots i:nth-child(1) { background: #ff6b8b }
.wr-dots i:nth-child(2) { background: #ffb86b }
.wr-dots i:nth-child(3) { background: var(--team-purple) }
.wr-title { flex: 1; color: var(--team-purple) }
.wr-x {
  background: transparent; border: 0; color: var(--fg-mute);
  cursor: pointer; font-family: var(--mono); font-size: 1.2rem; line-height: 1;
}
.wr-x:hover { color: var(--team-purple) }
.wr-body {
  padding: .9rem 1.1rem 1.2rem;
  font-family: var(--mono); font-size: .85rem;
}
.wr-line, .wr-out { margin: .25rem 0; color: var(--fg-dim) }
.wr-prompt { color: var(--accent); margin-right: .35rem }
.wr-flag {
  display: inline-block;
  margin: .35rem 0 .8rem;
  padding: .35rem .65rem;
  background: color-mix(in srgb, var(--team-purple) 15%, transparent);
  border: 1px dashed var(--team-purple);
  border-radius: 4px;
  color: var(--team-purple); font-weight: 600;
}
.wr-files { list-style: none; margin: .4rem 0 .8rem; padding: 0 0 0 1.2rem }
.wr-files li { padding: .12rem 0; color: var(--fg) }
.wr-files li::before { content: '↳ '; color: var(--fg-mute) }
.wr-files li span { color: var(--fg-mute); margin-left: .4rem }
.wr-cur {
  display: inline-block; width: .55em; background: var(--accent);
  animation: blink 1s steps(1) infinite;
}
@keyframes blink { 50% { opacity: 0 } }

/* khelp-grid foot row spans both columns */
.khelp-grid .kh-foot {
  grid-column: 1 / -1;
  padding-top: .8rem; margin-top: .4rem;
  border-top: 1px dashed var(--border);
  color: var(--fg-mute) !important; font-size: .78rem;
}
.khelp-grid .kh-foot kbd { font-family: var(--mono); font-size: .7rem; padding: 0 .3rem; border: 1px solid var(--border-strong); border-radius: 3px; margin: 0 1px }

/* ═══════════════════════════════════════════════════════════
 * v2.1 — playground (sigma → multi-engine) + detection heatmap
 * ─────────────────────────────────────────────────────────── */

/* ─────────── PLAYGROUND ─────────── */
#playground { padding-top: 1.2rem }
.pg-toolbar {
  display: flex; align-items: center; gap: .8rem;
  padding: .6rem .9rem;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin: 1rem 0 .9rem;
  font-family: var(--mono); font-size: .82rem;
  color: var(--fg-dim);
  flex-wrap: wrap;
}
.pg-tool { display: inline-flex; align-items: center; gap: .5rem }
.pg-tool-k { color: var(--fg-mute); font-size: .72rem; text-transform: uppercase; letter-spacing: .08em }
.pg-tool select {
  background: var(--card); color: var(--fg);
  border: 1px solid var(--border-strong); border-radius: 4px;
  font-family: var(--mono); font-size: .8rem;
  padding: .3rem .55rem;
  cursor: pointer;
}
.pg-tool select:focus { outline: 2px solid var(--team-purple); outline-offset: 1px }
.pg-status {
  padding: .15rem .5rem; border-radius: 999px;
  background: color-mix(in srgb, var(--team-purple) 15%, transparent);
  border: 1px solid var(--team-purple); color: var(--team-purple);
  font-size: .72rem;
}
.pg-status[data-state="error"] {
  background: color-mix(in srgb, var(--bad) 15%, transparent);
  border-color: var(--bad); color: var(--bad);
}
.pg-spacer { flex: 1 1 auto }
.pg-meta { color: var(--fg-mute); font-size: .72rem }

.pg-grid {
  display: grid;
  grid-template-columns: minmax(320px, 1fr) minmax(360px, 1.2fr);
  gap: 1rem;
}
@media (max-width: 920px) {
  .pg-grid { grid-template-columns: 1fr }
}
.pg-pane, .pg-out {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex; flex-direction: column;
}
.pg-pane-h {
  display: flex; align-items: center; gap: .6rem;
  padding: .55rem .85rem;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  font-family: var(--mono); font-size: .76rem;
}
.pg-pane-t { color: var(--team-purple); letter-spacing: .04em }
.pg-pane-meta { color: var(--fg-mute); font-size: .7rem; flex: 1; text-align: right }
.pg-input textarea {
  width: 100%; flex: 1;
  min-height: 360px;
  background: transparent; color: var(--fg);
  border: 0; outline: none; resize: vertical;
  padding: .9rem 1rem;
  font-family: var(--mono); font-size: .82rem; line-height: 1.55;
  caret-color: var(--accent);
  tab-size: 2;
}
.pg-input textarea:focus { background: color-mix(in srgb, var(--team-purple) 4%, transparent) }
.pg-tabs {
  display: flex; gap: 0;
  padding: 0;
  background: var(--card);
  border-bottom: 1px solid var(--border);
}
.pg-tab {
  flex: 1;
  background: transparent; border: 0;
  padding: .6rem .9rem;
  font-family: var(--mono); font-size: .76rem;
  color: var(--fg-mute);
  cursor: pointer;
  border-right: 1px solid var(--border);
  border-bottom: 2px solid transparent;
  transition: color .12s ease, border-color .12s ease, background .12s ease;
}
.pg-tab:last-child { border-right: 0 }
.pg-tab:hover { color: var(--fg) }
.pg-tab.is-active {
  color: var(--team-purple);
  border-bottom-color: var(--team-purple);
  background: color-mix(in srgb, var(--team-purple) 8%, transparent);
}
.pg-panes {
  flex: 1; min-height: 360px;
  display: grid;
  grid-template-columns: 1fr;
  position: relative;
}
.pg-pane-out {
  grid-row: 1 / 2; grid-column: 1 / 2;
  margin: 0; padding: .9rem 1rem;
  font-family: var(--mono); font-size: .8rem; line-height: 1.5;
  color: var(--fg);
  background: transparent;
  overflow: auto;
  white-space: pre;
  opacity: 0; pointer-events: none;
  transition: opacity .12s ease;
}
.pg-pane-out.is-active { opacity: 1; pointer-events: auto }
.pg-pane-out code { background: transparent; padding: 0; font-size: inherit; color: inherit }
.pg-foot {
  display: flex; align-items: center; gap: .8rem;
  padding: .55rem .85rem;
  background: var(--card);
  border-top: 1px solid var(--border);
  font-size: .72rem; color: var(--fg-mute);
}
.pg-btn {
  background: transparent; color: var(--team-purple);
  border: 1px solid var(--team-purple); border-radius: 4px;
  padding: .25rem .65rem;
  font-family: var(--mono); font-size: .72rem;
  cursor: pointer; transition: background .12s ease;
}
.pg-btn:hover { background: color-mix(in srgb, var(--team-purple) 15%, transparent) }
.pg-btn[data-copied="1"] { color: var(--accent); border-color: var(--accent) }
.pg-foot-hint { flex: 1 }

/* keyword highlighting inside output */
.pg-pane-out .pg-k  { color: var(--team-purple) }
.pg-pane-out .pg-s  { color: var(--accent) }
.pg-pane-out .pg-c  { color: var(--fg-mute); font-style: italic }
.pg-pane-out .pg-n  { color: var(--warn) }
.pg-pane-out .pg-o  { color: var(--accent-2) }

/* ─────────── DETECTION HEATMAP ─────────── */
#heatmap { padding-top: 1.2rem }
.hm-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: .8rem;
  margin: 1rem 0 1.1rem;
}
@media (max-width: 720px) {
  .hm-stats { grid-template-columns: repeat(2, 1fr) }
}
.hm-stat {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .8rem 1rem;
  display: flex; flex-direction: column; gap: .15rem;
}
.hm-stat-n {
  font-family: var(--mono); font-size: 1.4rem; color: var(--team-blue); font-weight: 600;
}
.hm-stat-l { font-size: .72rem; color: var(--fg-mute); text-transform: uppercase; letter-spacing: .06em }

.hm-wrap {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.2rem 1.1rem;
}
.hm-months {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 0;
  margin: 0 0 .35rem 36px;
  font-family: var(--mono); font-size: .68rem; color: var(--fg-mute);
}
.hm-row { display: flex; gap: .55rem; align-items: stretch }
.hm-days {
  display: grid;
  grid-template-rows: repeat(7, 1fr);
  width: 30px;
  font-family: var(--mono); font-size: .65rem; color: var(--fg-mute);
  align-items: center;
  text-align: right;
  padding-right: .3rem;
}
.hm-grid {
  flex: 1;
  width: 100%;
  height: auto;
  max-height: 130px;
  overflow: visible;
}
.hm-grid rect.hm-c {
  rx: 2; ry: 2;
  cursor: pointer;
  transition: transform .12s ease;
}
.hm-grid rect.hm-c:hover {
  stroke: var(--team-blue);
  stroke-width: 1.5;
}
.hm-grid rect.hm-c[data-l="0"] { fill: color-mix(in srgb, var(--team-blue) 8%, var(--bg)) }
.hm-grid rect.hm-c[data-l="1"] { fill: color-mix(in srgb, var(--team-blue) 22%, var(--bg)) }
.hm-grid rect.hm-c[data-l="2"] { fill: color-mix(in srgb, var(--team-blue) 42%, var(--bg)) }
.hm-grid rect.hm-c[data-l="3"] { fill: color-mix(in srgb, var(--team-blue) 65%, var(--bg)) }
.hm-grid rect.hm-c[data-l="4"] { fill: var(--team-blue) }
.hm-legend {
  display: flex; align-items: center; gap: .35rem;
  margin-top: .8rem;
  font-family: var(--mono); font-size: .7rem; color: var(--fg-mute);
}
.hm-legend i.hm-l { display: inline-block; width: 12px; height: 12px; border-radius: 2px }
.hm-l.hm-l0 { background: color-mix(in srgb, var(--team-blue) 8%, var(--bg)) }
.hm-l.hm-l1 { background: color-mix(in srgb, var(--team-blue) 22%, var(--bg)) }
.hm-l.hm-l2 { background: color-mix(in srgb, var(--team-blue) 42%, var(--bg)) }
.hm-l.hm-l3 { background: color-mix(in srgb, var(--team-blue) 65%, var(--bg)) }
.hm-l.hm-l4 { background: var(--team-blue) }
.hm-tip {
  margin-left: 1rem; flex: 1;
  font-size: .72rem; color: var(--fg);
  font-family: var(--mono);
  padding-left: 1rem;
  border-left: 1px solid var(--border);
}
@media (max-width: 720px) {
  .hm-tip { display: none }
}
