:root {
  --bg: #181818;
  --text: #f0f0f0;
  --muted: #ababab;
  --border: #3a3a3a;
  --link: #a3d9a5;
  --card: #202020;
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0 auto;
  background: var(--bg);
  color: var(--text);
  font-family: "FiraCode Nerd Font", "Fira Code", monospace;
  line-height: 1.6;
}

img {
  display: block;
  max-width: 100%;
}

a {
  color: var(--link);
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  max-width: 900px;
  margin: 0 auto 56px;
  padding: 18px 24px;
  background: rgba(24, 24, 24, 0.94);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(12px);
}

.site-identity {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  font-weight: 700;
  text-decoration: none;
}

.site-avatar {
  width: 34px;
  height: 34px;
  flex: 0 0 34px;
  object-fit: cover;
  border: 1px solid var(--border);
  border-radius: 50%;
}

nav {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

main {
  display: grid;
  gap: 40px;
  max-width: 820px;
  margin: 0 auto;
  padding: 0 24px;
}

section {
  display: grid;
  gap: 16px;
}

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

.project-scroll {
  display: grid;
  gap: 16px;
  max-height: 520px;
  overflow-y: auto;
  padding-right: 8px;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: 2.4rem;
  line-height: 1.1;
}

h2 {
  font-size: 1.45rem;
}

h3 {
  font-size: 1.1rem;
}

ul {
  margin: 0;
  padding-left: 20px;
}

article:not(.card) {
  line-height: 1.75;
}

article:not(.card) > * + * {
  margin-top: 1.1rem;
}

article:not(.card) h2,
article:not(.card) h3 {
  line-height: 1.25;
}

article:not(.card) h2 {
  margin-top: 2.2rem;
}

article:not(.card) h3 {
  margin-top: 1.5rem;
}

article:not(.card) p + p {
  margin-top: 1rem;
}

article:not(.card) p,
article:not(.card) li {
  white-space: pre-line;
}

article:not(.card) li + li {
  margin-top: 0.9rem;
}

article:not(.card) li > p + p {
  margin-top: 0.8rem;
}

article:not(.card) ul,
article:not(.card) ol {
  display: grid;
  gap: 0.8rem;
  margin-top: 1rem;
  padding-left: 1.4rem;
}

footer {
  max-width: 820px;
  margin-top: 56px;
  margin-right: auto;
  margin-left: auto;
  padding-top: 16px;
  padding-right: 24px;
  padding-bottom: 32px;
  padding-left: 24px;
  border-top: 1px solid var(--border);
  color: var(--muted);
}

.intro {
  padding: 24px 0;
}

.home .site-header {
  margin-bottom: 32px;
}

.home main {
  gap: 28px;
}

.home .intro {
  padding: 8px 0;
}

.home .project-scroll {
  max-height: 300px;
}

.home .card {
  padding: 12px 14px;
}

.card {
  display: grid;
  gap: 8px;
  padding: 16px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 6px;
  line-height: 1.6;
}

.card > * {
  margin: 0;
}

.card p,
.card li {
  white-space: normal;
}

.card ul,
.card ol {
  display: block;
  margin: 0;
  padding-left: 20px;
}

.card .language-inline {
  display: flex;
  gap: 8px 16px;
  margin-top: 2px;
  padding-left: 0;
}

.tags {
  color: var(--muted);
}

.language-inline {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 18px;
  padding: 0;
  color: var(--muted);
  font-size: 0.95rem;
  list-style: none;
}

.language-inline li {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.language-dot {
  width: 12px;
  height: 12px;
  flex: 0 0 12px;
  border-radius: 50%;
}

/* ── Project detail page ──────────────────────────────────────────────────── */

.project-page main {
  max-width: 820px;
  gap: 32px;
}

.project-hero {
  display: grid;
  gap: 10px;
  padding-bottom: 24px;
  border-bottom: 1px solid rgba(163, 217, 165, 0.15);
}

.project-back {
  font-size: 0.9rem;
  display: inline-block;
  margin-bottom: 2px;
}

.project-hero h1 {
  font-size: 2.2rem;
  line-height: 1.15;
}

.project-summary {
  font-size: 0.95rem;
  color: var(--muted);
  line-height: 1.55;
  margin-top: 2px;
}

.post-date {
  font-size: 0.85rem;
  color: var(--muted);
}

/* meta row: bar stretches, legend wraps beside it */
.project-meta {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  margin-top: 6px;
}

.project-meta .language-bar {
  flex: 1;
  min-width: 80px;
}

/* language bar */
.language-bar {
  position: relative;
  display: flex;
  height: 4px;
  overflow: visible;
  background: rgba(255, 255, 255, 0.07);
  border-radius: 999px;
}

.language-bar span {
  min-width: 3px;
}

.language-bar > span:not(.language-tooltip):first-child {
  border-top-left-radius: 999px;
  border-bottom-left-radius: 999px;
}

.language-bar > span:not(.language-tooltip):nth-last-child(2) {
  border-top-right-radius: 999px;
  border-bottom-right-radius: 999px;
}

.language-tooltip {
  position: absolute;
  top: calc(100% + 8px);
  left: var(--tooltip-x, 50%);
  display: none;
  min-width: max-content;
  padding: 3px 7px;
  background: #242424;
  color: var(--text);
  border: 1px solid rgba(163, 217, 165, 0.28);
  border-radius: 5px;
  font-size: 0.8rem;
  line-height: 1.3;
  pointer-events: none;
  transform: translateX(-50%);
}

.language-bar:hover .language-tooltip {
  display: block;
}

/* inline legend beside the bar */
.language-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 14px;
  list-style: none;
  padding: 0;
  margin: 0;
}

.language-legend li {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.82rem;
  color: var(--muted);
}

.lang-name {
  color: var(--text);
}

.lang-pct {
  color: var(--muted);
}

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

@media (max-width: 640px) {
  .site-header {
    display: grid;
    margin-bottom: 40px;
    padding: 16px 18px;
  }

  .section-heading {
    display: grid;
    gap: 6px;
  }

  main,
  footer {
    padding-right: 18px;
    padding-left: 18px;
  }

  h1 {
    font-size: 2rem;
  }

  .project-hero h1 {
    font-size: 1.75rem;
  }

  .project-meta {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }

  .project-meta .language-bar {
    width: 100%;
  }
}
