:root {
  --bg: #0d1117;
  --surface: #161b22;
  --border: #21262d;
  --text: #e6edf3;
  --muted: #8b949e;
  --faint: #3d444d;
  --accent: #58a6ff;
  --accent-warm: #d2a679;
  --font-sans: system-ui, -apple-system, sans-serif;
  --font-mono: "JetBrains Mono", "SFMono-Regular", Consolas, monospace;
}

* { box-sizing: border-box; }

html { color-scheme: dark; }

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

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

a:hover { text-decoration: underline; }

a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 2px;
}

.site-shell {
  width: min(100% - 2rem, 860px);
  margin: 0 auto;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ── Header ─────────────────────────────── */

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
  padding: 1.5rem 0;
  border-bottom: 1px solid var(--border);
}

.brand {
  color: var(--text);
  font-size: 0.95rem;
  font-weight: 600;
}

.brand:hover { text-decoration: none; }

.site-nav {
  display: flex;
  gap: 1.5rem;
  font-size: 0.88rem;
}

.site-nav a {
  color: var(--muted);
}

.site-nav a:hover,
.site-nav a[aria-current="page"] {
  color: var(--text);
  text-decoration: none;
}

/* ── Main ────────────────────────────────── */

.site-main {
  flex: 1;
  padding: 3rem 0 4rem;
}

/* ── Footer ──────────────────────────────── */

.site-footer {
  display: flex;
  justify-content: flex-end;
  padding: 1.25rem 0 2rem;
  border-top: 1px solid var(--border);
}

.footer-links {
  display: flex;
  gap: 1.25rem;
  font-size: 0.88rem;
}

.footer-links a {
  color: var(--muted);
}

.footer-links a:hover {
  color: var(--text);
  text-decoration: none;
}

/* ── Typography ──────────────────────────── */

h1, h2, h3 {
  margin-top: 0;
  color: var(--text);
  line-height: 1.2;
  font-weight: 700;
}

h1 { font-size: clamp(1.75rem, 5vw, 2.5rem); margin-bottom: 1rem; }
h2 { font-size: 1.35rem; margin-bottom: 0.75rem; }
h3 { font-size: 1.1rem; margin-bottom: 0.5rem; }

p {
  margin-top: 0;
  color: var(--muted);
  line-height: 1.65;
}

time, code { font-family: var(--font-mono); }

time {
  color: var(--faint);
  font-size: 0.8rem;
}

code {
  color: var(--accent-warm);
  font-size: 0.88em;
}

pre {
  overflow-x: auto;
  padding: 1.25rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  font-family: var(--font-mono);
}

ul { padding-left: 1.25rem; }
li::marker { color: var(--faint); }

/* ── Home: hero ──────────────────────────── */

.hero {
  padding-bottom: 1.5rem;
}

.hero h1 { margin-bottom: 0.75rem; }

.hero-lede {
  font-size: 1.02rem;
  color: var(--muted);
  max-width: 60ch;
  margin-bottom: 1.5rem;
}

.hero-actions {
  display: flex;
  gap: 1.25rem;
  flex-wrap: wrap;
}

.hero-actions a {
  color: var(--text);
  font-size: 0.9rem;
  font-family: var(--font-mono);
}

.hero-actions a:hover {
  color: var(--accent);
  text-decoration: none;
}

/* ── Home: sections ──────────────────────── */

.section-block {
  margin-top: 2.5rem;
  padding-top: 2.5rem;
  border-top: 1px solid var(--border);
}

.section-block h2 {
  font-size: 0.75rem;
  font-family: var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--faint);
  margin-bottom: 1rem;
  font-weight: 600;
}

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

.latest-post time {
  display: block;
  margin-bottom: 0.35rem;
}

.latest-post h3 {
  margin-bottom: 0.35rem;
}

.latest-post h3 a {
  color: var(--text);
}

.latest-post h3 a:hover {
  color: var(--accent);
  text-decoration: none;
}

.latest-post p {
  font-size: 0.92rem;
  margin: 0;
}

.inline-focus {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin: 0;
  padding: 0;
}

.inline-focus div {
  display: flex;
  gap: 0.75rem;
  align-items: baseline;
}

.inline-focus dt {
  font-family: var(--font-mono);
  font-size: 0.82rem;
  color: var(--text);
  font-weight: 600;
  flex-shrink: 0;
  min-width: 6rem;
}

.inline-focus dd {
  margin: 0;
  font-size: 0.92rem;
  color: var(--muted);
}

/* ── Page header ─────────────────────────── */

.page-header {
  margin-bottom: 2.5rem;
}

.page-header h1 {
  font-size: clamp(1.5rem, 4vw, 2.25rem);
  margin-bottom: 0.5rem;
}

.page-header p {
  font-size: 0.95rem;
  margin: 0;
}

/* ── Projects ────────────────────────────── */

.project-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1rem;
}

.project-card {
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
}

.card-header {
  margin-bottom: 0.5rem;
}

.card-header h2 {
  margin: 0;
  font-size: 1.05rem;
  color: var(--text);
}

.card-header h2 a {
  color: var(--text);
}

.card-header h2 a:hover {
  color: var(--accent);
  text-decoration: none;
}

.status {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--faint);
  margin-bottom: 0.3rem;
}

.status::before {
  content: "";
  display: inline-block;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: currentColor;
  flex-shrink: 0;
}

.status-active { color: #57ab5a; }
.status-maintained { color: var(--accent); }
.status-learning { color: var(--accent-warm); }
.status-archived, .status-planned { color: var(--faint); }

.tagline {
  color: var(--text);
  font-size: 0.92rem;
  margin: 0 0 0.5rem;
  font-weight: 600;
}

.project-card > p {
  font-size: 0.88rem;
  color: var(--muted);
  margin: 0 0 0.75rem;
}

.highlight-list {
  margin: 0 0 0.75rem;
  padding-left: 1.1rem;
  color: var(--muted);
  font-size: 0.85rem;
}

.highlight-list li {
  margin-bottom: 0.25rem;
  line-height: 1.5;
}

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  margin-top: auto;
  padding-top: 0.5rem;
}

.chip-row span {
  display: inline-block;
  padding: 0.15rem 0.45rem;
  border-radius: 4px;
  border: 1px solid var(--border);
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.7rem;
}

.card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  padding-top: 0.75rem;
  margin-top: auto;
}

.card-actions a {
  display: inline-flex;
  align-items: center;
  padding: 0.25rem 0.65rem;
  border-radius: 4px;
  border: 1px solid var(--border);
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.75rem;
}

.card-actions a:hover {
  color: var(--text);
  border-color: var(--muted);
  text-decoration: none;
}

/* ── Blog list ───────────────────────────── */

.post-list {
  display: flex;
  flex-direction: column;
}

.post-card {
  padding: 1.25rem 0;
  border-bottom: 1px solid var(--border);
}

.post-card time {
  display: block;
  margin-bottom: 0.35rem;
}

.post-card h2 {
  font-size: 1.05rem;
  margin-bottom: 0.35rem;
}

.post-card h2 a {
  color: var(--text);
}

.post-card h2 a:hover {
  color: var(--accent);
  text-decoration: none;
}

.post-card > p {
  font-size: 0.88rem;
  margin-bottom: 0.5rem;
}

.post-card .chip-row {
  padding-top: 0;
  margin-top: 0;
}

/* ── Post page ───────────────────────────── */

.back-link {
  display: inline-block;
  margin-bottom: 2rem;
  font-size: 0.88rem;
  color: var(--muted);
}

.back-link:hover {
  color: var(--text);
  text-decoration: none;
}

.post-content {
  max-width: 680px;
}

.post-header {
  margin-bottom: 2.5rem;
  padding-bottom: 1.75rem;
  border-bottom: 1px solid var(--border);
}

.post-header h1 {
  font-size: clamp(1.5rem, 4vw, 2.25rem);
  margin-bottom: 0.75rem;
}

.post-header > p {
  font-size: 1rem;
  margin-bottom: 0.75rem;
}

.post-header time {
  display: block;
  margin-bottom: 0.75rem;
}

.post-body {
  font-size: 1rem;
  color: var(--muted);
  line-height: 1.75;
}

.post-body p { margin-bottom: 1.5rem; }

.post-body h2 {
  font-size: 1.4rem;
  color: var(--text);
  margin-top: 2.5rem;
  margin-bottom: 0.75rem;
}

.post-body h3 {
  font-size: 1.1rem;
  color: var(--text);
  margin-top: 2rem;
  margin-bottom: 0.5rem;
}

.post-body a {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.post-body a:hover { color: var(--text); }

.post-body code {
  background: var(--surface);
  color: var(--accent-warm);
  padding: 0.1rem 0.35rem;
  border-radius: 3px;
  font-size: 0.87em;
  border: 1px solid var(--border);
}

.post-body pre { margin: 1.5rem 0; }

.post-body pre code {
  background: transparent;
  color: var(--text);
  padding: 0;
  border: none;
  font-size: 0.87rem;
}

.post-body blockquote {
  border-left: 3px solid var(--border);
  margin: 1.75rem 0;
  padding: 0.5rem 1.25rem;
}

.post-body blockquote p {
  margin: 0;
  font-style: italic;
}

.post-body ul, .post-body ol { margin-bottom: 1.5rem; }

pre::-webkit-scrollbar { height: 5px; }
pre::-webkit-scrollbar-track { background: transparent; }
pre::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 9999px;
}

/* ── Project link row ────────────────────── */

.link-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  padding-top: 0.75rem;
  margin-top: auto;
}

.link-row a {
  display: inline-flex;
  align-items: center;
  padding: 0.25rem 0.65rem;
  border-radius: 4px;
  border: 1px solid var(--border);
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.75rem;
}

.link-row a:hover {
  color: var(--text);
  border-color: var(--muted);
  text-decoration: none;
}

/* ── CV ──────────────────────────────────── */

.cv {
  max-width: 760px;
}

.cv-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1.5rem;
  margin-bottom: 2.5rem;
  padding-bottom: 1.75rem;
  border-bottom: 1px solid var(--border);
}

.cv-header h1 {
  font-size: clamp(1.5rem, 4vw, 2rem);
  margin-bottom: 0.25rem;
}

.cv-subtitle {
  color: var(--muted);
  font-size: 0.92rem;
  margin: 0;
}

.cv-contact {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.35rem;
  font-size: 0.85rem;
  flex-shrink: 0;
}

.cv-contact a {
  color: var(--muted);
}

.cv-contact a:hover {
  color: var(--text);
  text-decoration: none;
}

.cv-section {
  margin-bottom: 2.5rem;
}

.cv-section h2 {
  font-size: 0.75rem;
  font-family: var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--faint);
  font-weight: 600;
  margin-bottom: 1.25rem;
}

.cv-entry {
  margin-bottom: 1.5rem;
}

.cv-entry:last-child {
  margin-bottom: 0;
}

.cv-entry-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.2rem;
}

.cv-entry-header strong {
  color: var(--text);
  font-size: 0.95rem;
}

.cv-dates {
  color: var(--faint);
  font-size: 0.8rem;
  font-family: var(--font-mono);
  flex-shrink: 0;
}

.cv-stack {
  font-family: var(--font-sans);
  color: var(--muted);
}

.cv-role {
  color: var(--muted);
  font-size: 0.88rem;
  margin: 0 0 0.5rem;
}

.cv-entry ul {
  margin: 0;
  padding-left: 1.1rem;
  color: var(--muted);
  font-size: 0.88rem;
}

.cv-entry li {
  margin-bottom: 0.3rem;
  line-height: 1.55;
}

.cv-skill-row {
  display: flex;
  gap: 1.5rem;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.88rem;
  align-items: baseline;
}

.cv-skill-row:first-of-type {
  border-top: 1px solid var(--border);
}

.cv-skill-cat {
  color: var(--text);
  font-weight: 600;
  flex-shrink: 0;
  min-width: 10rem;
  font-size: 0.85rem;
}

.cv-skill-items {
  color: var(--muted);
}

.cv-proj-links {
  display: flex;
  gap: 0.75rem;
  margin: 0.35rem 0 0.5rem;
  font-size: 0.82rem;
}

.cv-proj-links a {
  color: var(--accent);
}

/* ── 404 ─────────────────────────────────── */

.error-page {
  padding: 2rem 0;
}

.compiler-error {
  font-family: var(--font-mono);
  font-size: 0.9rem;
  line-height: 1.7;
  color: var(--text);
  background: none;
  border: none;
  padding: 0;
  margin: 0;
  white-space: pre;
}

.err-header { color: #f85149; font-weight: 600; }
.err-arrow  { color: var(--accent); }
.err-pipe   { color: var(--accent); }
.err-underline { color: #f85149; }
.err-note   { color: var(--accent-warm); }

.compiler-error a {
  color: var(--accent);
  text-decoration: underline;
}

/* ── Responsive ──────────────────────────── */

@media (max-width: 640px) {
  .project-grid {
    grid-template-columns: 1fr;
  }

  .site-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.75rem;
  }

  .site-nav { gap: 1rem; }

  .inline-focus div {
    flex-direction: column;
    gap: 0.1rem;
  }

  .inline-focus dt { min-width: auto; }

  .cv-header {
    flex-direction: column;
    gap: 1rem;
  }

  .cv-contact {
    align-items: flex-start;
  }
}
