:root {
  /* Backgrounds */
  --bg-hard: #1d2021;
  --bg: #282828;
  --bg-soft: #32302f;
  --bg-1: #3c3836;
  --bg-2: #504945;
  --bg-3: #665c54;
  --bg-4: #7c6f64;

  /* Foregrounds */
  --fg-hard: #f9f5d7;
  --fg: #ebdbb2;
  --fg-soft: #d5c4a1;
  --fg-1: #bdae93;
  --fg-2: #a89984;
  --fg-3: #928374;

  /* Accents */
  --red: #cc241d;
  --red-bright: #fb4934;
  --green: #98971a;
  --green-bright: #b8bb26;
  --yellow: #d79921;
  --yellow-bright: #fabd2f;
  --blue: #458588;
  --blue-bright: #83a598;
  --purple: #b16286;
  --purple-bright: #d3869b;
  --aqua: #689d6a;
  --aqua-bright: #8ec07c;
  --orange: #d65d0e;
  --orange-bright: #fe8019;

  /* Semantic aliases */
  --accent: var(--yellow-bright);
  --accent-dim: var(--yellow);
  --accent-muted: rgba(250, 189, 47, 0.12);
  --surface: var(--bg-soft);
  --surface-2: var(--bg-1);
  --border: var(--bg-2);
  --border-dim: var(--bg-1);
  --text: var(--fg);
  --text-dim: var(--fg-2);
  --text-faint: var(--fg-3);
  --green-dim: rgba(152, 151, 26, 0.15);
  --shadow-card: 0 12px 40px rgba(0, 0, 0, 0.4);
  --shadow-terminal: 0 20px 60px rgba(0, 0, 0, 0.5), 0 4px 16px rgba(0, 0, 0, 0.4);

  /* Typography */
  --font-mono: "JetBrains Mono", "Fira Code", "Cascadia Code", monospace;
  --font-display: "Syne", "IBM Plex Sans Arabic", system-ui, sans-serif;
  --font-body: "Mulish", "IBM Plex Sans Arabic", system-ui, sans-serif;

  /* Spacing */
  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 16px;
  --radius-xl: 24px;

  /* Transitions */
  --t: 0.3s ease;
}



/* ── Reset ───────────────────────────────────────────────── */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}
html {
  scroll-behavior: smooth;
}
body {
  font-family: var(--font-body);
  background: var(--bg-hard);
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
img,
svg {
  display: block;
  max-width: 100%;
}
a {
  text-decoration: none;
  color: inherit;
}
ul {
  list-style: none;
}
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

/* ── Layout ──────────────────────────────────────────────── */
.container {
  width: min(1200px, 92%);
  margin-inline: auto;
}
.section-padding {
  padding: clamp(4rem, 10vh, 7rem) 0;
}
.flex {
  display: flex;
}
.align-center {
  align-items: center;
}

/* ── Section labels ──────────────────────────────────────── */
.section-header {
  margin-bottom: 2.5rem;
}
.section-header.centered {
  text-align: center;
}
.section-label {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--aqua-bright);
  letter-spacing: 0.1em;
  margin-bottom: 0.5rem;
  display: block;
}
.section-title {
  font-family: var(--font-display);
  font-size: clamp(2rem, 4vw, 2.8rem);
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--fg-hard);
  line-height: 1.1;
}

/* ── Buttons ─────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  font-weight: 700;
  padding: 0.75rem 1.4rem;
  border-radius: var(--radius);
  border: 2px solid transparent;
  cursor: pointer;
  transition: var(--t);
  letter-spacing: 0.04em;
}
.btn-accent {
  background: var(--accent);
  color: var(--bg-hard);
  border-color: var(--accent);
}
.btn-accent:hover {
  background: var(--yellow);
  border-color: var(--yellow);
}
.btn-outline {
  background: transparent;
  color: var(--accent);
  border-color: var(--accent);
}
.btn-outline:hover {
  background: var(--accent-muted);
}
.btn:active {
  transform: translateY(2px);
}
.btn-lg {
  padding: 0.9rem 1.8rem;
  font-size: 0.95rem;
}

/* ── Header ──────────────────────────────────────────────── */
.site-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  background: rgba(29, 32, 33, 0.88);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-dim);
  padding: 0.75rem 0;
}
.site-header .container {
  gap: 2rem;
}
.logo {
  margin-right: auto;
  display: inline-flex;
  align-items: center;
}
.logo-img {
  height: 34px;
  width: auto;
  max-width: 110px;
  object-fit: contain;
}
@media (max-width: 640px) {
  .logo-img {
    height: 28px;
  }
}

.primary-nav {
  position: relative;
}
.nav-list {
  display: flex;
  gap: 1.5rem;
}
.nav-link {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-dim);
  padding: 0.25rem 0.1rem;
  transition: color var(--t);
  position: relative;
}
.nav-link::after {
  content: "";
  position: absolute;
  bottom: -2px;
  left: 0;
  right: 0;
  height: 1px;
  background: var(--accent);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform var(--t);
}
.nav-link:hover,
.nav-link.active {
  color: var(--accent);
}
.nav-link.active::after,
.nav-link:hover::after {
  transform: scaleX(1);
}

.nav-toggle {
  display: none;
  flex-direction: column;
  gap: 5px;
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 0.5rem 0.25rem;
}
.nav-toggle .bar {
  width: 24px;
  height: 2px;
  background: var(--accent);
  border-radius: 2px;
  transition: var(--t);
}

/* ── Theme Toggle ──────────────────────────────────────────── */

.scanline-overlay {
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(
    0deg,
    rgba(0, 0, 0, 0.03) 0px,
    rgba(0, 0, 0, 0.03) 1px,
    transparent 1px,
    transparent 3px
  );
  pointer-events: none;
  z-index: 0;
}

/* ── Hero ────────────────────────────────────────────────── */
.hero {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  padding-top: 5rem;
  position: relative;
  background:
    radial-gradient(
      ellipse 60% 50% at 10% 80%,
      rgba(215, 153, 33, 0.07),
      transparent
    ),
    radial-gradient(
      ellipse 40% 40% at 90% 20%,
      rgba(104, 157, 106, 0.05),
      transparent
    ),
    var(--bg-hard);
}
.hero-grid {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4rem;
  align-items: center;
  min-height: calc(100dvh - 100px);
}

/* ── Terminal block ──────────────────────────────────────── */
.hero-terminal {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow:
    0 0 0 1px var(--accent-muted),
    var(--shadow-terminal);
  font-family: var(--font-mono);
  font-size: clamp(0.78rem, 1.5vw, 0.9rem);
  max-width: 480px;
}
.terminal-bar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.7rem 1rem;
  background: var(--bg-1);
  border-bottom: 1px solid var(--border-dim);
}
.terminal-title {
  margin-right: auto;
  font-size: 0.72rem;
  color: var(--fg-3);
  letter-spacing: 0.04em;
}
.terminal-body {
  padding: 1.25rem 1.4rem 1.6rem;
  display: grid;
  gap: 0.35rem;
}
.terminal-line {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-top: 0.6rem;
}
.terminal-line:first-child {
  margin-top: 0;
}
.prompt {
  color: var(--green-bright);
  font-weight: 700;
  user-select: none;
}
.cmd {
  color: var(--yellow-bright);
}
.terminal-output {
  color: var(--fg-soft);
  padding-left: 1.4rem;
  line-height: 1.5;
}
.grn {
  color: var(--green-bright);
}

.cursor-block {
  color: var(--accent);
  animation: blink 1.1s step-end infinite;
}
@keyframes blink {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0;
  }
}

/* ── Hero copy ───────────────────────────────────────────── */
.hero-copy {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  z-index: 2;
}
.eyebrow {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--text-faint);
  letter-spacing: 0.1em;
  text-transform: lowercase;
}
.prompt-inline {
  color: var(--aqua-bright);
}
.hero-heading {
  font-family: var(--font-display);
  font-size: clamp(2.8rem, 5.5vw, 4.2rem);
  font-weight: 800;
  line-height: 1.05;
  letter-spacing: -0.03em;
  color: var(--fg-hard);
  display: flex;
  flex-direction: column;
}
.hero-heading .line-two {
  color: var(--accent);
}
.hero-heading em {
  font-style: normal;
}
.tagline {
  font-size: 0.95rem;
  color: var(--text-dim);
  line-height: 1.7;
  max-width: 420px;
}
.hero-socials {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
  margin-top: 0.25rem;
}
.hero-socials a {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-dim);
  font-size: 1rem;
  transition: var(--t);
}
.hero-socials a[data-platform="github"]:hover {
  background: var(--orange-bright);
  color: var(--bg-hard);
  border-color: var(--orange-bright);
}
.hero-socials a[data-platform="linkedin"]:hover {
  background: var(--orange-bright);
  color: var(--bg-hard);
  border-color: var(--orange-bright);
}
.hero-socials a[data-platform="cv"]:hover {
  background: var(--orange-bright);
  color: var(--bg-hard);
  border-color: var(--orange-bright);
}
.hero-cta {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  margin-top: 0.5rem;
}

/* ── Hero responsive ─────────────────────────────────────── */
@media (max-width: 900px) {
  .hero-grid {
    grid-template-columns: 1fr;
    gap: 2.5rem;
    min-height: unset;
    padding: 2rem 0;
  }
  .hero-terminal {
    max-width: 100%;
    margin: 0 auto;
  }
  .hero-copy {
    text-align: center;
    align-items: center;
  }
  .tagline {
    max-width: 500px;
  }
  .hero-heading {
    align-items: center;
  }
  .hero-socials {
    justify-content: center;
  }
  .hero-cta {
    justify-content: center;
  }
}

/* ── Projects ────────────────────────────────────────────── */
.projects {
  background: var(--bg);
}
.projects-grid {
  display: grid;
  gap: 1.5rem;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
}
.project-card {
  background: var(--bg-soft);
  border: 1px solid var(--border-dim);
  border-radius: var(--radius-lg);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition:
    border-color var(--t),
    transform var(--t),
    box-shadow var(--t);
}
.project-card:hover {
  border-color: var(--accent-muted);
  transform: translateY(-4px);
  box-shadow:
    var(--shadow-card),
    0 0 0 1px var(--accent-muted);
}
.project-card.featured {
  border-color: var(--accent-muted);
  flex-direction: row;
}
.project-card.featured .project-media {
  flex: 0 0 45%;
}
.project-card.featured .project-body {
  flex: 1;
}
@media (max-width: 800px) {
  .project-card.featured {
    flex-direction: column;
    grid-column: span 1;
  }
  .project-card.featured .project-media {
    flex: none;
  }
}

.project-media {
  aspect-ratio: 16/9;
  overflow: hidden;
  position: relative;
  background: var(--bg-1);
}
.project-card.featured .project-media {
  aspect-ratio: unset;
  min-height: 240px;
}
.project-media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.5s ease;
}
.project-card:hover .project-media img {
  transform: scale(1.04);
}
.project-media-overlay {
  position: absolute;
  inset: 0;
  background: rgba(29, 32, 33, 0.6);
  display: grid;
  place-items: center;
  opacity: 0;
  transition: opacity var(--t);
}
.project-card:hover .project-media-overlay {
  opacity: 1;
}
.overlay-link {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--bg-hard);
  display: grid;
  place-items: center;
  font-size: 1.25rem;
  transition: transform var(--t);
}
.overlay-link:hover {
  transform: scale(1.1);
}

.placeholder-media {
  aspect-ratio: 16/9;
  background: var(--bg-1);
  display: grid;
  place-items: center;
  border-bottom: 1px solid var(--border-dim);
}
.placeholder-icon {
  font-size: 2.5rem;
  color: var(--aqua-bright);
  opacity: 0.5;
}

.project-body {
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  flex: 1;
}
.project-meta {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}
.project-type {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  color: var(--text-faint);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.project-status {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  display: flex;
  align-items: center;
  gap: 0.3rem;
}
.project-status.live {
  color: var(--green-bright);
}
.live-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--green-bright);
  box-shadow: 0 0 6px var(--green-bright);
  animation: pulse-dot 2s ease-in-out infinite;
}
@keyframes pulse-dot {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.4;
  }
}

.project-title {
  font-family: var(--font-display);
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--fg-hard);
}
.project-text {
  font-size: 0.88rem;
  color: var(--text-dim);
  line-height: 1.65;
}
.project-impact {
  list-style: none;
  display: grid;
  gap: 0.3rem;
  font-size: 0.8rem;
  color: var(--fg-1);
}
.project-impact li::before {
  content: "▸ ";
  color: var(--aqua-bright);
}

.stack-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: auto;
}
.badge {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  font-weight: 600;
  padding: 0.25rem 0.6rem;
  border-radius: var(--radius-sm);
  background: var(--bg-2);
  color: var(--yellow-bright);
  border: 1px solid var(--accent-muted);
  letter-spacing: 0.04em;
}
.project-link {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--accent);
  transition:
    gap var(--t),
    color var(--t);
}
.project-link:hover {
  color: var(--yellow);
  gap: 0.6rem;
}
.project-links {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  margin-top: 0.5rem;
}
.project-link-repo {
  color: var(--text-dim);
  font-weight: 500;
}
.project-link-repo:hover {
  color: var(--accent);
}

/* ── Articles Section ───────────────────────────────────── */
.articles {
  background: var(--bg-hard);
}
.articles-grid {
  display: grid;
  gap: 1.5rem;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
}
.article-card {
  background: var(--bg-soft);
  border: 1px solid var(--border-dim);
  border-radius: var(--radius-lg);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition:
    border-color var(--t),
    transform var(--t),
    box-shadow var(--t);
}
.article-card:hover {
  border-color: var(--accent-muted);
  transform: translateY(-4px);
  box-shadow:
    var(--shadow-card),
    0 0 0 1px var(--accent-muted);
}
.article-card-body {
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  flex: 1;
}
.article-card-meta {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-family: var(--font-mono);
  font-size: 0.65rem;
  color: var(--text-faint);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.article-card-date {
  color: var(--aqua-bright);
}
.article-card-read-time {
  color: var(--text-faint);
}
.article-card-title {
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--fg-hard);
  line-height: 1.3;
}
.article-card-text {
  font-size: 0.88rem;
  color: var(--text-dim);
  line-height: 1.65;
}
.article-card-link {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--accent);
  margin-top: 0.5rem;
  transition:
    gap var(--t),
    color var(--t);
}
.article-card-link:hover {
  color: var(--yellow);
  gap: 0.6rem;
}

/* ── Article Page ───────────────────────────────────────── */
.article-page {
  padding-top: 7rem;
  background: var(--bg);
  min-height: 100dvh;
}
.article-container {
  max-width: 720px;
  margin-inline: auto;
}
.article-header {
  margin-bottom: 0.75rem;
}
.article-title {
  font-family: var(--font-display);
  font-size: clamp(1.8rem, 4vw, 2.6rem);
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--fg-hard);
  line-height: 1.15;
  margin-top: 0.5rem;
}
.article-meta-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 0.75rem;
}
.article-meta {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-faint);
}
.article-meta-date {
  color: var(--aqua-bright);
}

/* ── Article Actions ──────────────────────────────────────── */
.article-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.share-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--bg-soft);
  border: 1px solid var(--border-dim);
  color: var(--text-dim);
  display: grid;
  place-items: center;
  cursor: pointer;
  font-size: 0.85rem;
  transition: var(--t);
}
.share-btn:hover {
  color: var(--accent);
  border-color: var(--accent);
}

/* ── Language Toggle ──────────────────────────────────────── */
.lang-toggle {
  display: flex;
  gap: 0.25rem;
  background: var(--bg-soft);
  border: 1px solid var(--border-dim);
  border-radius: var(--radius);
  padding: 0.2rem;
  width: fit-content;
}
.lang-btn {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0.35rem 0.8rem;
  border: none;
  border-radius: calc(var(--radius) - 3px);
  cursor: pointer;
  background: transparent;
  color: var(--text-faint);
  transition: var(--t);
  letter-spacing: 0.04em;
}
.lang-btn.active {
  background: var(--accent);
  color: var(--bg-hard);
}
.lang-btn:not(.active):hover {
  color: var(--accent);
}

/* ── Table of Contents ──────────────────────────────────────── */
.article-toc {
  margin-bottom: 1.5rem;
  font-family: var(--font-body);
  font-size: 0.82rem;
}
.toc-toggle {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  width: 100%;
  background: var(--bg-soft);
  border: 1px solid var(--border-dim);
  border-radius: var(--radius);
  padding: 0.6rem 1rem;
  cursor: pointer;
  font-family: var(--font-body);
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-dim);
  transition: var(--t);
}
.toc-toggle:hover {
  color: var(--accent);
  border-color: var(--accent);
}
.toc-arrow {
  margin-left: auto;
  transition: transform var(--t);
}
.toc-toggle[aria-expanded="true"] .toc-arrow {
  transform: rotate(180deg);
}
.toc-list {
  max-height: 0;
  opacity: 0;
  overflow: hidden;
  list-style: none;
  margin: 0;
  padding: 0 1rem;
  border: 1px solid var(--border-dim);
  border-top: none;
  border-radius: 0 0 var(--radius) var(--radius);
  background: var(--bg);
  transition: max-height 0.35s ease, opacity 0.3s ease, padding 0.3s ease;
}
.toc-toggle[aria-expanded="true"] + .toc-list {
  max-height: 2000px;
  opacity: 1;
  padding: 0.75rem 1rem;
}

/* Section (h2) items */
.toc-section {
  margin-bottom: 0.25rem;
}
.toc-heading-row {
  display: flex;
  align-items: baseline;
}
.toc-heading-row > a {
  flex: 1;
  min-width: 0;
  color: var(--text-dim);
  text-decoration: none;
  padding: 0.2rem 0;
  transition: color var(--t);
  line-height: 1.4;
  cursor: pointer;
}
.toc-section:hover .toc-heading-row > a,
.toc-heading-row > a.active {
  color: var(--accent);
}
.toc-section-toggle {
  background: none;
  border: none;
  padding: 0;
  margin: 0;
  cursor: pointer;
  color: var(--text-dim);
  font-size: 0.65rem;
  line-height: inherit;
  display: inline-flex;
  align-items: center;
  transition: color var(--t), transform 0.25s ease;
  margin-inline-end: 0.2rem;
}
.toc-section-toggle:hover {
  color: var(--accent);
}
.toc-section.toc-expanded .toc-section-toggle i {
  transform: rotate(0deg);
}
.toc-section:not(.toc-expanded) .toc-section-toggle i {
  transform: rotate(-90deg);
}
.toc-section-toggle i {
  transition: transform 0.25s ease;
}

/* Subsections (h3) */
.toc-subsections {
  max-height: 0;
  overflow: hidden;
  list-style: none;
  margin: 0;
  padding: 0;
  padding-left: calc(0.65rem + 0.2rem);
  transition: max-height 0.3s ease;
}
.toc-section.toc-expanded .toc-subsections {
  max-height: 2000px;
}
.toc-subsections li {
  margin-bottom: 0.2rem;
}
.toc-subsections a {
  color: var(--text-dim);
  text-decoration: none;
  display: block;
  padding: 0.15rem 0;
  font-size: 0.75rem;
  transition: color var(--t);
  line-height: 1.3;
}
.toc-subsections a:hover,
.toc-subsections a.active {
  color: var(--accent);
}
.article-toc[dir="rtl"] .toc-subsections {
  padding-left: 0;
  padding-right: calc(0.65rem + 0.2rem);
}
.article-toc[dir="rtl"] .toc-arrow {
  margin-left: 0;
  margin-right: auto;
}
.article-toc[dir="rtl"] .toc-section:not(.toc-expanded) .toc-section-toggle i {
  transform: rotate(90deg);
}

/* ── Article Body Typography ────────────────────────────── */
.article-body {
  font-size: 1rem;
  line-height: 1.8;
  color: var(--text);
}
.article-body p {
  margin-bottom: 1.25rem;
}
.article-body h2 {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--fg-hard);
  margin-top: 2.5rem;
  margin-bottom: 0.75rem;
  letter-spacing: -0.01em;
}
.article-body h3 {
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--accent);
  margin-top: 1.75rem;
  margin-bottom: 0.5rem;
}
.article-body strong {
  color: var(--fg-hard);
}
.article-body ol {
  list-style: none;
  counter-reset: step;
  padding: 0;
  margin-bottom: 1.25rem;
}
.article-body ol li {
  counter-increment: step;
  padding: 0.55rem 0 0.55rem 2.2rem;
  position: relative;
  color: var(--text);
  line-height: 1.65;
  border-bottom: 1px solid var(--border-dim);
}
.article-body ol li:last-child {
  border-bottom: none;
}
.article-body ol li::before {
  content: counter(step);
  position: absolute;
  left: 0;
  top: 0.55rem;
  width: 1.6rem;
  height: 1.6rem;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--bg-hard);
  background: var(--accent);
  border-radius: var(--radius-sm);
  line-height: 1;
}
.article-content[dir="rtl"] ol li {
  padding: 0.55rem 2.2rem 0.55rem 0;
}
.article-content[dir="rtl"] ol li::before {
  content: counter(step);
  left: auto;
  right: 0;
}
.article-body em {
  font-style: normal;
  color: var(--accent);
}
.article-body code {
  font-family: var(--font-mono);
  font-size: 0.85em;
  background: var(--bg-1);
  color: var(--orange-bright);
  padding: 0.15em 0.4em;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-dim);
}
.article-body ul {
  list-style: none;
  margin-bottom: 1.25rem;
  display: grid;
  gap: 0.6rem;
}
.article-body ul li {
  padding-left: 1.4rem;
  color: var(--text-dim);
  font-size: 0.95rem;
  line-height: 1.7;
}
[dir="rtl"] .article-content ul li {
  padding-left: 0;
  padding-right: 1.4rem;
}
[dir="rtl"] .article-content ul li::before {
  left: auto;
  right: 0;
}
.article-body ul li strong {
  color: var(--fg-soft);
}
.article-body blockquote {
  border-left: 3px solid var(--accent-dim);
  background: var(--bg-soft);
  padding: 1rem 1.25rem;
  margin-bottom: 1.25rem;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}
[dir="rtl"] .article-content blockquote {
  border-left: none;
  border-right: 3px solid var(--accent-dim);
  border-radius: var(--radius-sm) 0 0 var(--radius-sm);
}
.article-body blockquote p {
  margin-bottom: 0;
  font-size: 0.9rem;
  color: var(--fg-soft);
}
.article-body hr {
  border: none;
  height: 1px;
  background: var(--border);
  margin: 2.5rem 0;
}

/* ── Loading Skeleton ──────────────────────────────────────── */
.skeleton {
  display: grid;
  gap: 0.75rem;
  padding: 0.5rem 0;
}
.skeleton-line {
  height: 0.85rem;
  border-radius: var(--radius-sm);
  background: linear-gradient(90deg, var(--bg-1) 25%, var(--bg-2) 50%, var(--bg-1) 75%);
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.5s ease-in-out infinite;
}
.skeleton-line:first-child {
  height: 1.1rem;
  margin-bottom: 0.25rem;
}
.skeleton-line:nth-child(2) {
  height: 0.85rem;
}
.skeleton-line:last-child {
  height: 0.85rem;
}
@keyframes skeleton-shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ── Series Nav ─────────────────────────────────────────────── */
.series-nav {
  margin-top: 2rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border);
}
.series-label {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--text-faint);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: 0.75rem;
}
.series-links {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
}
.series-links a {
  font-family: var(--font-body);
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--accent);
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  transition:
    gap var(--t),
    color var(--t);
  max-width: 45%;
}
.series-links a:hover {
  color: var(--yellow);
  gap: 0.6rem;
}
.series-prev {
  margin-right: auto;
}
.series-next {
  margin-left: auto;
  text-align: right;
}

/* ── Gruvbox Code Theme ─────────────────────────────────────── */
.article-body pre {
  background: var(--bg);
  border: 1px solid var(--border-dim);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  overflow-x: auto;
  margin-bottom: 1.25rem;
  font-size: 0.82rem;
  line-height: 1.55;
}
.article-body pre code {
  background: none;
  padding: 0;
  border: none;
  border-radius: 0;
  color: var(--fg);
  font-size: inherit;
}
.article-body pre code.language-text {
  display: grid;
  place-items: center;
  direction: ltr;
  color: var(--aqua-bright);
  font-size: 0.75rem;
  line-height: 1.5;
  letter-spacing: 0.02em;
}
.article-body pre:has(code.language-text) {
  background: var(--bg-soft);
  border-color: var(--border);
  padding: 1.25rem;
}

/* ── Terminal Block ──────────────────────────────────────────── */
.terminal-block {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 1.25rem;
}
.terminal-header {
  display: flex;
  align-items: center;
  padding: 0.5rem 1rem;
  background: var(--bg-soft);
  border-bottom: 1px solid var(--border-dim);
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--text-dim);
}
.terminal-title {
  margin-left: auto;
}
.terminal-block pre {
  margin: 0;
  border: none;
  border-radius: 0;
  background: var(--bg);
}

/* ── Directory Tree ──────────────────────────────────────────── */
.tree-block {
  display: flex;
  justify-content: center;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem 1.25rem;
  margin-bottom: 1.25rem;
  font-family: var(--font-mono);
  font-size: 0.82rem;
  line-height: 1.7;
  overflow-x: auto;
  direction: ltr;
}
.tree-block code {
  background: none;
  color: var(--fg);
  white-space: pre;
  letter-spacing: 0.02em;
}
.tree-block .tree-dir {
  color: var(--aqua-bright);
  font-weight: 700;
}
.tree-block .tree-file {
  color: var(--fg);
}
.tree-block .tree-branch {
  color: var(--text-dim);
}

/* ── Article Tables ──────────────────────────────────────────── */
.article-body table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  margin: 1.25rem auto;
  font-size: 0.88rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
@media (max-width: 640px) {
  .article-body table {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
}
.article-body thead {
  background: var(--bg-soft);
}
.article-body th {
  font-family: var(--font-display);
  font-weight: 700;
  color: var(--fg-hard);
  text-align: left;
  padding: 0.7rem 1rem;
  border-bottom: 2px solid var(--border);
  font-size: 0.82rem;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}
.article-body td {
  padding: 0.65rem 1rem;
  color: var(--text);
  line-height: 1.55;
}
.article-body tbody tr:not(:last-child) td {
  border-bottom: 1px solid var(--border-dim);
}
.article-body tbody tr:hover {
  background: var(--bg-soft);
}
.article-body td:first-child {
  font-weight: 600;
  color: var(--fg);
  white-space: nowrap;
}

/* ── Link Buttons ────────────────────────────────────────────── */
.link-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.45rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-soft);
  color: var(--fg);
  font-family: var(--font-mono);
  font-size: 0.82rem;
  text-decoration: none;
  transition:
    gap var(--t),
    border-color var(--t),
    color var(--t),
    background var(--t);
  margin: 0.15rem 0;
}
.link-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--bg);
  gap: 0.6rem;
}
.link-btn-repo {
  color: var(--text-dim);
}
.link-btn-repo:hover {
  color: var(--accent);
}
.link-btn i {
  font-size: 1rem;
}

/* ── System Architecture Diagram ──────────────────────────── */
.sys-diagram {
  display: grid;
  gap: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  margin: 1.5rem 0;
  font-family: var(--font-mono);
  font-size: 0.82rem;
  overflow: hidden;
}
.sys-layer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.25rem 1rem 2.5rem;
  background: var(--bg-soft);
  position: relative;
  border-top: 1px solid var(--border-dim);
}
.sys-layer:first-of-type {
  border-top: none;
}
.sys-layer::before {
  content: "↑";
  position: absolute;
  left: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-faint);
}
.sys-layer:first-of-type::before {
  content: "–";
}
.sys-layer:last-of-type::before {
  content: "⏏";
}
.sys-layer-name {
  font-weight: 700;
  color: var(--accent);
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}
.sys-layer-name span {
  font-size: 0.68rem;
  font-weight: 400;
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.sys-layer-detail {
  text-align: right;
  color: var(--text-dim);
  font-size: 0.78rem;
}
.article-body .hljs-keyword,
.article-body .hljs-selector-tag,
.article-body .hljs-type { color: var(--red-bright); }

.article-body .hljs-string,
.article-body .hljs-addition,
.article-body .hljs-attribute { color: var(--green-bright); }

.article-body .hljs-number,
.article-body .hljs-literal { color: var(--purple-bright); }

.article-body .hljs-title,
.article-body .hljs-title.function_,
.article-body .hljs-title.class_ { color: var(--yellow-bright); }

.article-body .hljs-built_in,
.article-body .hljs-title.class_.inherited__ { color: var(--aqua-bright); }

.article-body .hljs-comment,
.article-body .hljs-quote { color: var(--fg-3); font-style: italic; }

.article-body .hljs-variable,
.article-body .hljs-template-variable { color: var(--orange-bright); }

.article-body .hljs-attr,
.article-body .hljs-params { color: var(--fg); }

.article-body .hljs-meta { color: var(--blue-bright); }

.article-body .hljs-section { color: var(--yellow-bright); font-weight: 700; }

.article-body .hljs-deletion { color: var(--red); }

.article-body .hljs-link { color: var(--blue-bright); text-decoration: underline; }
.reading-progress {
  position: fixed;
  top: 0;
  left: 0;
  height: 3px;
  background: var(--accent);
  z-index: 101;
  width: 0%;
}

/* ── Back Link ─────────────────────────────────────────────── */
.back-link {
  margin-top: 2rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}
.back-link a {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-dim);
  transition:
    gap var(--t),
    color var(--t);
}
.back-link a:hover {
  color: var(--accent);
  gap: 0.6rem;
}
.back-link-top {
  margin: 1rem 0;
}
.back-link-top a {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-faint);
  transition:
    gap var(--t),
    color var(--t);
}
.back-link-top a:hover {
  color: var(--accent);
  gap: 0.5rem;
}

/* ── Back to Top ───────────────────────────────────────────── */
.back-to-top {
  position: fixed;
  bottom: 5.5rem;
  right: 2rem;
  z-index: 99;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--bg-hard);
  border: none;
  cursor: pointer;
  display: grid;
  place-items: center;
  font-size: 1.2rem;
  opacity: 0;
  transform: translateY(12px);
  pointer-events: none;
  transition:
    opacity var(--t),
    transform var(--t),
    background var(--t);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
}
.back-to-top.visible {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}
.back-to-top:hover {
  background: var(--yellow);
}

/* ── About ───────────────────────────────────────────────── */
.about {
  background: var(--bg-hard);
}
.about-layout {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 4rem;
  align-items: start;
}
@media (max-width: 900px) {
  .about-layout {
    grid-template-columns: 1fr;
    gap: 2.5rem;
  }
}

.about-narrative {
  font-size: 0.95rem;
  color: var(--text-dim);
  line-height: 1.8;
  margin-bottom: 1rem;
}
.about-narrative em {
  font-style: normal;
  color: var(--accent);
  font-weight: 600;
}

/* Timeline */
.timeline {
  margin-top: 2.5rem;
  display: grid;
  gap: 0;
}
.timeline-item {
  display: flex;
  gap: 1.25rem;
  position: relative;
  padding-bottom: 2rem;
}
.timeline-item:last-child {
  padding-bottom: 0;
}
.timeline-item::before {
  content: "";
  position: absolute;
  left: 16px;
  top: 34px;
  bottom: 0;
  width: 1px;
  background: var(--border);
}
.timeline-item:last-child::before {
  display: none;
}
.timeline-icon {
  flex: 0 0 34px;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--bg-2);
  border: 1px solid var(--border);
  display: grid;
  place-items: center;
  color: var(--accent);
  font-size: 0.85rem;
  position: relative;
  z-index: 1;
}
.timeline-body {
  flex: 1;
}
.timeline-header {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.25rem;
}
.timeline-role {
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 700;
  color: var(--fg-hard);
}
.timeline-company {
  font-size: 0.85rem;
  color: var(--text-faint);
}
.timeline-company a {
  color: var(--accent);
}
.timeline-company a:hover {
  text-decoration: underline;
}
.timeline-date {
  display: block;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--text-faint);
  letter-spacing: 0.06em;
  margin-bottom: 0.6rem;
}
.timeline-desc {
  font-size: 0.85rem;
  color: var(--text-dim);
  line-height: 1.7;
}

/* Skills sidebar */
.about-skills {
  background: var(--bg);
  border: 1px solid var(--border-dim);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  display: grid;
  gap: 1.4rem;
  position: sticky;
  top: 80px;
}
.skills-block {
  display: grid;
  gap: 0.6rem;
}
.skills-category {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--aqua-bright);
}
.skills-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}
.skill-tag {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  padding: 0.25rem 0.65rem;
  border-radius: 30px;
  background: var(--bg-1);
  color: var(--fg-1);
  border: 1px solid var(--border-dim);
  transition:
    background var(--t),
    color var(--t),
    border-color var(--t);
}
.skill-tag:hover {
  background: var(--accent-muted);
  color: var(--accent);
  border-color: var(--accent-dim);
}

/* ── Contact ─────────────────────────────────────────────── */
.contact {
  background: var(--bg);
}
.contact-inner {
  max-width: 700px;
  margin-inline: auto;
  text-align: center;
}
.contact-sub {
  font-size: 0.95rem;
  color: var(--text-dim);
  line-height: 1.7;
  margin-bottom: 2.5rem;
  max-width: 500px;
  margin-inline: auto;
  margin-top: 0.75rem;
}
.contact-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 1rem;
  margin-bottom: 2rem;
}
.contact-card {
  background: var(--bg-soft);
  border: 1px solid var(--border-dim);
  border-radius: var(--radius-lg);
  padding: 1.4rem 1rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  transition:
    border-color var(--t),
    transform var(--t),
    background var(--t);
  cursor: pointer;
}
.contact-card:hover {
  border-color: var(--accent-dim);
  background: var(--accent-muted);
  transform: translateY(-3px);
}
.contact-icon {
  font-size: 1.5rem;
  color: var(--accent);
}
.contact-label {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-faint);
}
.contact-value {
  font-size: 0.8rem;
  color: var(--text-dim);
  font-weight: 500;
  word-break: break-all;
}
.contact-cta {
  display: flex;
  gap: 1rem;
  justify-content: center;
  flex-wrap: wrap;
  margin-bottom: 1.5rem;
}
.contact-location {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-faint);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
}

/* ── Footer ──────────────────────────────────────────────── */
.site-footer {
  background: var(--bg-hard);
  border-top: 1px solid var(--border-dim);
  padding: 1.5rem 0;
}
.footer-inner {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}
.footer-brand {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1rem;
  color: var(--accent);
  margin-right: auto;
}
.footer-copy {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--text-faint);
}
.footer-socials {
  display: flex;
  gap: 0.75rem;
}
.footer-socials a {
  font-size: 0.9rem;
  color: var(--text-faint);
  transition: color var(--t);
}
.footer-socials a:hover {
  color: var(--accent);
}

/* ── Mobile nav ──────────────────────────────────────────── */
@media (max-width: 860px) {
  .nav-toggle {
    display: flex;
  }
  .nav-list {
    position: absolute;
    top: calc(100% + 0.5rem);
    right: 0;
    flex-direction: column;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1rem 1.25rem;
    min-width: 180px;
    opacity: 0;
    transform: translateY(-8px);
    pointer-events: none;
    transition:
      opacity var(--t),
      transform var(--t);
  }
  .nav-list.open {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
  }
  .nav-link {
    padding: 0.4rem 0;
    font-size: 0.85rem;
  }
}

/* ── Content visibility on mobile ────────────────────────── */
@media (max-width: 640px) {
  #projects,
  #articles,
  #about,
  #contact {
    content-visibility: auto;
    contain-intrinsic-size: 0 600px;
  }
  html {
    scroll-padding-top: 6rem;
  }
  .section-padding {
    padding: 3rem 0;
  }
  .article-page {
    padding-top: 5rem;
  }
  .hero-terminal {
    max-width: 100%;
    font-size: 0.65rem;
  }
  .terminal-bar {
    padding: 0.5rem 0.7rem;
  }
  .terminal-body {
    padding: 0.7rem 0.7rem 1rem;
  }
  .terminal-line {
    gap: 0.4rem;
  }
  .terminal-output {
    padding-left: 1.05rem;
  }
  .hero-cta,
  .contact-cta {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.75rem;
  }
  .hero-cta .btn,
  .contact-cta .btn {
    width: 100%;
    justify-content: center;
    padding: 0.75rem 1rem;
    font-size: 0.82rem;
  }
  .contact-cta .btn-lg {
    padding: 0.75rem 1rem;
    font-size: 0.82rem;
  }
  main section[id] {
    scroll-margin-top: 6rem;
  }
  .article-meta-row {
    flex-wrap: nowrap;
    gap: 0.5rem;
  }
  .article-meta {
    font-size: 0.62rem;
  }
  .lang-btn {
    font-size: 0.6rem;
    padding: 0.2rem 0.5rem;
  }
  .share-btn {
    width: 26px;
    height: 26px;
    font-size: 0.7rem;
  }
  .article-actions {
    gap: 0.3rem;
  }
}

/* ── Reduced motion ──────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  .cursor-block {
    animation: none;
  }
  .live-dot {
    animation: none;
  }
  * {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
  }
}

/* ── Utility ─────────────────────────────────────────────── */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  border: 0;
}
