:root {
  color-scheme: light dark;
  --bg: #ffffff;
  --surface: #f5f6f8;
  --text: #15171c;
  --muted: #5b6270;
  --border: #e2e5ea;
  --accent: #c8102e;
  --critical: #b3141f;
  --high: #b93c06;
  --medium: #8a5a00;
  --low: #15803d;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "Cascadia Code", "SF Mono", Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0c0e11;
    --surface: #14171c;
    --text: #e8eaef;
    --muted: #9ba2ae;
    --border: #262a32;
    --accent: #ff4d5e;
    --critical: #ff6b75;
    --high: #ff9a4d;
    --medium: #f5c542;
    --low: #4ade80;
  }
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 17px/1.65 var(--sans);
}

a { color: var(--accent); text-underline-offset: 3px; }
a:hover { text-decoration-thickness: 2px; }

.wrap { padding-left: clamp(16px, 4vw, 56px); padding-right: clamp(16px, 4vw, 56px); }

.skip { position: absolute; left: -9999px; }
.skip:focus { left: 16px; top: 8px; padding: 6px 10px; background: var(--surface); }

/* Header */

.site-header { border-bottom: 1px solid var(--border); }

.site-header .wrap {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 24px;
  padding-top: 18px;
  padding-bottom: 18px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  font-weight: 700;
  text-decoration: none;
  letter-spacing: -0.01em;
}

.brand::before {
  content: "";
  width: 10px;
  height: 10px;
  background: var(--accent);
}

nav { display: flex; flex-wrap: wrap; gap: 4px 20px; }
nav a { color: var(--muted); font-size: 15px; text-decoration: none; }
nav a:hover { color: var(--text); }
nav a[aria-current="page"] { color: var(--text); box-shadow: inset 0 -2px var(--accent); }

/* Typography */

main { padding-top: 48px; padding-bottom: 64px; }

h1 {
  margin: 0 0 8px;
  font-size: clamp(2rem, 6vw, 2.75rem);
  line-height: 1.1;
  letter-spacing: -0.02em;
}

h2 { margin: 48px 0 16px; font-size: 1.25rem; letter-spacing: -0.01em; }

.lede, .empty { color: var(--muted); }

code { font-family: var(--mono); font-size: 0.9em; }

pre {
  overflow-x: auto;
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.88rem;
  line-height: 1.5;
}

img { max-width: 100%; height: auto; }

/* Intro */

.hero { display: flex; align-items: flex-start; gap: 28px; }

.photo {
  flex: none;
  width: 140px;
  height: 140px;
  object-fit: cover;
  border: 1px solid var(--border);
  border-radius: 50%;
}

.role { margin: 0 0 16px; color: var(--accent); font-size: 0.95rem; font-weight: 600; }
.bio { margin: 0; }

@media (max-width: 560px) {
  .hero { flex-direction: column; gap: 20px; }
  .photo { width: 112px; height: 112px; }
}

/* Stats */

.stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin: 40px 0 0;
  padding: 0;
  list-style: none;
}

.stats li {
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.3;
}

.stats strong {
  display: block;
  margin-bottom: 4px;
  color: var(--text);
  font-size: 1.6rem;
  font-variant-numeric: tabular-nums;
}

@media (max-width: 420px) {
  .stats { gap: 8px; }
  .stats li { padding: 12px; font-size: 0.8rem; }
}

/* Section headers with a trailing link */

.section-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0 16px;
}

.section-head a { font-size: 0.92rem; }

/* Profiles */

.profiles { display: flex; flex-wrap: wrap; gap: 8px; margin: 0; padding: 0; list-style: none; }

.profiles a {
  display: inline-flex;
  align-items: baseline;
  gap: 8px;
  padding: 7px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text);
  font-size: 0.9rem;
  text-decoration: none;
}

.profiles a:hover { border-color: var(--accent); }
.profile-handle { color: var(--muted); font-family: var(--mono); font-size: 0.8rem; }

/* CVE list */

.cve-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 12px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.cve {
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
}

.cve-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.cve-id { font-family: var(--mono); font-size: 0.95rem; font-weight: 600; }

.sev {
  padding: 2px 8px;
  border-radius: 6px;
  background: color-mix(in srgb, var(--sev) 14%, transparent);
  color: var(--sev);
  font-size: 0.78rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.sev-critical { --sev: var(--critical); }
.sev-high { --sev: var(--high); }
.sev-medium { --sev: var(--medium); }
.sev-low { --sev: var(--low); }

.cve-title { margin: 6px 0 2px; font-weight: 600; }
.cve-meta { margin: 0; color: var(--muted); font-size: 0.88rem; }

/* Writeup lists and posts */

.post-list { margin: 0; padding: 0; list-style: none; }
.post-list li { padding: 12px 0; border-bottom: 1px solid var(--border); }
.post-list a { font-weight: 600; }
.post-list time { display: block; color: var(--muted); font-size: 0.85rem; }
.post-list p { margin: 4px 0 0; color: var(--muted); }

.byline { margin: 0 0 32px; color: var(--muted); font-size: 0.92rem; }

.post h2 { margin-top: 40px; }
.post img { border: 1px solid var(--border); border-radius: 8px; }
.post .back { margin-top: 48px; font-size: 0.92rem; }

.post table {
  display: block;
  overflow-x: auto;
  margin: 0 0 24px;
  border-collapse: collapse;
  font-size: 0.92rem;
}

.post th, .post td {
  padding: 6px 12px;
  border: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
}

.post th:empty { padding: 0; border: 0; }
.post td:first-child { color: var(--muted); white-space: nowrap; }

/* Syntax highlighting (Rouge) */

.highlight .c, .highlight .c1, .highlight .cm, .highlight .cp { color: var(--muted); }
.highlight .gd { color: var(--critical); }
.highlight .gi { color: var(--low); }
.highlight .gu, .highlight .gh { color: var(--muted); font-weight: 600; }
.highlight .s, .highlight .s1, .highlight .s2 { color: var(--medium); }
.highlight .k, .highlight .kd, .highlight .nb { color: var(--accent); }

/* Badges */

.badges {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.badges a {
  display: flex;
  flex-direction: column;
  height: 100%;
  padding: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  text-decoration: none;
}

.badges a:hover { border-color: var(--accent); }

.badge-art {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 120px;
  margin-bottom: 10px;
  border-radius: 6px;
  overflow: hidden;
}

.badge-art img { max-width: 100%; max-height: 104px; }
.badge-title { font-size: 0.88rem; font-weight: 600; line-height: 1.3; }
.badge-issuer { margin-top: 2px; color: var(--muted); font-size: 0.8rem; }

/* Projects */

.projects {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 12px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.projects li {
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
}

.projects a { font-weight: 600; }
.project-kind { display: block; color: var(--muted); font-size: 0.82rem; }
.projects p { margin: 8px 0 0; font-size: 0.92rem; }

/* About */

.timeline { margin: 0; padding: 0; list-style: none; }
.timeline li { padding: 0 0 20px 18px; border-left: 2px solid var(--border); }
.timeline li:first-child { border-left-color: var(--accent); }
.timeline h3 { margin: 0; font-size: 1rem; line-height: 1.4; }
.timeline .meta { margin: 2px 0 6px; color: var(--muted); font-size: 0.88rem; }
.timeline p { margin: 0; }

.certs {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  column-gap: 32px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.certs li { padding: 10px 0; border-bottom: 1px solid var(--border); }
.certs span { display: block; color: var(--muted); font-size: 0.85rem; }

/* Footer */

.site-footer { border-top: 1px solid var(--border); color: var(--muted); font-size: 0.88rem; }
.site-footer .wrap { padding-top: 24px; padding-bottom: 32px; }
.site-footer p { margin: 0 0 6px; }
.footer-links a { color: var(--muted); }
