body {
  font: 100%/1.5 system-ui;
  max-width: 100ch;
  margin-inline: max(1em, (100% - 100ch) / 2);
  padding: 1em;
  border: 2px solid #6aaeff;
  border-radius: 12px;
}

nav ul,
nav li {
  display: contents;
}

nav {
  display: flex;
  background-color: canvas;
  --border-color: #6aaeff;
  border-bottom: 1px solid var(--border-color);
}

html {
  --color-accent: #6aaeff;
  accent-color: var(--color-accent);
}

nav a {
  flex: 1;
  text-align: center;
  padding: 1em;
  text-decoration: none;
  border-bottom-color: var(--border-color);
  background: canvas;
  color: canvastext;
}

nav a.current {
  background-color: color-mix(in oklch, var(--color-accent), canvas 80%);
  color: canvastext;
  font-weight: bold;
  border-bottom: 4px solid var(--color-accent);
}

nav a:hover {
  background-color: color-mix(in oklch, var(--color-accent), canvas 90%);
  color: canvastext;
  border-bottom: 4px solid var(--color-accent);
}

input,
textarea,
button {
  font: inherit;
}

form {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 1em;
}

form label {
  display: grid;
  grid-template-columns: subgrid;
  grid-column: 1 / -1;
}

.projects {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(15em, 1fr));
  gap: 2em;
}

.projects article {
  grid-template-rows: subgrid;
  grid-row: span 3;
  gap: 1em;
}

h1, h2, h3, h4, h5, h6 {
  line-height: 1.1;
  text-wrap: balance;
}

h2 {
  color: #418cef;
  border-bottom: 2px solid var(--color-accent);
  padding-bottom: 0.25em;
}

section {
  margin-bottom: 2em;
}

html {
  color-scheme: light dark;
  background-color: canvas;
  color: canvastext;
}

.color-scheme {
  position: absolute;
  top: 1rem;
  right: 1rem;
  font-size: 80%;
  font-family: inherit;
  z-index: 9999;
}

.color-scheme select {
  font-family: inherit;
}

#profile-stats dl {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  text-align: center;
  gap: 0.5em;
}

#profile-stats dt {
  font-weight: bold;
  grid-row: 1;
}

#profile-stats dd {
  margin: 0;
  grid-row: 2;
}

.projects img {
  max-width: 100%;
  height: auto;
  border-radius: 10px;
  object-fit: contain;
}

/* --- PIE CHART & LEGEND LAYOUT --- */
#projects-chart {
  display: flex;
  align-items: flex-start;
  gap: 2rem;
  justify-content: center;
  flex-wrap: wrap;
}

#projects-plot {
  width: 300px;
  height: 300px;
}

/* --- LEGEND --- */
.legend {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  font-size: 0.95rem;
  font-weight: 500;
  padding: 1rem 1.25rem;
  background: color-mix(in oklch, var(--color-accent), canvas 94%);
  border: 1.5px solid var(--color-accent);
  border-radius: 12px;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.08);
  min-width: 180px;
}

.legend li {
  display: flex;
  align-items: center;
  gap: 12px;
  list-style: none;
  cursor: pointer;
  padding: 0.25rem 0.4rem;
  border-radius: 6px;
  transition: background-color 0.25s ease, transform 0.2s ease, font-weight 0.2s ease;
}

.legend li:hover {
  background-color: color-mix(in oklch, var(--color-accent), canvas 87%);
  transform: translateX(3px);
}

.legend .swatch {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--color);
  border: 1px solid color-mix(in oklch, var(--color), black 25%);
  box-shadow: 0 0 3px color-mix(in oklch, var(--color), black 25%);
}

svg:has(path:hover) path:not(:hover) {
  opacity: 0.5;
}

path {
  transition: 300ms;
  cursor: pointer;
}

.selected {
  --color: oklch(60% 45% 0) !important;
}

.selected:is(path) {
  fill: var(--color);
  stroke: #000;
  stroke-width: 2px;
}

.legend .selected {
  font-weight: bold;
  color: oklch(60% 45% 0);
}


svg:has(path:hover) path:not(:hover) {
  opacity: 0.5;
}

path {
  transition: 300ms;
  cursor: pointer;
}

.selected {
  --color: oklch(60% 45% 0) !important;
}

.selected:is(path) {
  fill: var(--color);
  stroke: #000;
  stroke-width: 2px;
}

.legend .selected {
  font-weight: bold;
  color: oklch(60% 45% 0);
}
