:root,
:root[data-theme="light"] {
  --bg: #ffffff;
  --fg: #1a1a1a;
  --muted: #888;
  --link: #0050b3;
}

:root[data-theme="dark"] {
  --bg: #0e0e0e;
  --fg: #e6e6e6;
  --muted: #777;
  --link: #6aa9ff;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    --bg: #0e0e0e;
    --fg: #e6e6e6;
    --muted: #777;
    --link: #6aa9ff;
  }
}

.theme-toggle {
  position: fixed;
  top: 1rem;
  right: 1rem;
  background: none;
  border: 1px solid var(--muted);
  color: var(--fg);
  font-family: inherit;
  font-size: 0.8rem;
  padding: 0.3rem 0.6rem;
  cursor: pointer;
  border-radius: 4px;
  opacity: 0.7;
}
.theme-toggle:hover { opacity: 1; }

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Monaco, Consolas, monospace;
  font-size: 15px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

main {
  max-width: 640px;
  margin: 0 auto;
  padding: 4rem 1.5rem 6rem;
}

main:has(.posts) {
  max-width: 1120px;
}

header h1 {
  font-size: 1.05rem;
  font-weight: 600;
  margin: 0 0 0.25rem;
  letter-spacing: -0.01em;
}

.tagline {
  margin: 0 0 1rem;
  color: var(--fg);
}

nav {
  margin-bottom: 3rem;
}

nav a {
  margin-right: 1rem;
}

a {
  color: var(--link);
  text-decoration: underline;
  text-underline-offset: 2px;
  text-decoration-thickness: 1px;
}

a:hover {
  text-decoration-thickness: 2px;
}

.about p {
  margin: 0 0 1rem;
}

.about {
  margin-bottom: 3rem;
}

.section-heading {
  font-size: 0.85rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin: 0 0 1rem;
}

.projects {
  margin-bottom: 3rem;
}

.projects ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

.projects li {
  margin: 0 0 0.9rem;
  line-height: 1.55;
}

.projects .proj-desc {
  color: var(--muted);
  font-size: 0.88rem;
  display: block;
  margin-top: 0.1rem;
}

.achievements li {
  margin-bottom: 0.65rem;
}

.achievements .proj-desc {
  display: inline;
  margin-top: 0;
}

.projects code {
  font-size: 0.85em;
  background: rgba(127,127,127,0.12);
  padding: 0.05em 0.3em;
  border-radius: 3px;
}

.posts ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

.posts li {
  margin: 0.85rem 0;
  display: grid;
  grid-template-columns: 8.5rem minmax(0, 1fr);
  column-gap: 0.7rem;
  align-items: start;
  line-height: 1.4;
}

.posts .date {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  font-size: 0.85rem;
  white-space: nowrap;
}

.posts a {
  color: var(--fg);
  text-decoration: none;
  text-wrap: pretty;
}

.post-item > a,
.tag-index li > a {
  white-space: nowrap;
}

.posts a:hover {
  color: var(--link);
  text-decoration: none;
  text-underline-offset: 3px;
  text-decoration-thickness: 1px;
}

.post-item {
  display: block;
  min-width: 0;
}

.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-top: 0.18rem;
}

.tags span,
.tags a {
  color: var(--muted);
  font-size: 0.72rem;
  line-height: 1.25;
  text-decoration: none;
}

.tags span::before,
.tags a::before {
  content: "#";
  opacity: 0.65;
}

.tags a:hover {
  color: var(--link);
}

.tag-index section {
  margin: 1.8rem 0 0;
  scroll-margin-top: 4rem;
}

.tag-index::after {
  content: "";
  display: block;
  height: 70vh;
}

.tag-index h3 {
  color: var(--fg);
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  margin: 0 0 0.55rem;
}

.tag-index h3::before {
  content: "#";
  color: var(--link);
  opacity: 0.9;
}

@media (max-width: 520px) {
  .posts li {
    grid-template-columns: 1fr;
    row-gap: 0.05rem;
  }
}

@media (max-width: 980px) {
  .post-item > a,
  .tag-index li > a {
    white-space: normal;
  }
}

.post h2 {
  font-size: 1.4rem;
  margin: 0.5rem 0 1.5rem;
  letter-spacing: -0.02em;
}

.post h3 {
  font-size: 1.15rem;
  font-weight: 700;
  margin: 3rem 0 1rem;
  padding-top: 1.5rem;
  border-top: 1px solid rgba(127,127,127,0.25);
  letter-spacing: -0.01em;
  color: var(--fg);
}

.post h3::before {
  content: "§ ";
  color: var(--link);
  font-weight: 400;
}

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

.post p { margin: 0 0 1rem; }

.post hr {
  border: none;
  border-top: 1px solid var(--muted);
  opacity: 0.3;
  margin: 2rem 0;
}

.post code {
  font-size: 0.85em;
  background: rgba(127,127,127,0.12);
  padding: 0.1em 0.35em;
  border-radius: 3px;
}

.post pre {
  background: rgba(127,127,127,0.08);
  padding: 1rem;
  border-radius: 4px;
  overflow-x: auto;
  font-size: 0.82rem;
  line-height: 1.5;
}

.post pre code {
  background: none;
  padding: 0;
}

.post table {
  border-collapse: collapse;
  margin: 1rem 0;
  font-size: 0.9rem;
}

.post th, .post td {
  text-align: left;
  padding: 0.4rem 1rem 0.4rem 0;
  border-bottom: 1px solid rgba(127,127,127,0.2);
}

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

.poc-banner {
  font-size: 0.85rem;
  padding: 0.5rem 0.8rem;
  border-left: 2px solid var(--link);
  background: rgba(127,127,127,0.08);
  margin: 0 0 1.5rem !important;
  color: var(--muted);
}
.poc-banner a { color: var(--link); }

.more-link {
  margin: 0.5rem 0 0;
  font-size: 0.9rem;
}
.more-link a { color: var(--link); }

.cv {
  margin-bottom: 2.5rem;
}

.cv-link {
  color: var(--link);
  font-weight: 500;
  text-decoration: none;
}

.cv-link:hover {
  text-decoration: underline;
}
