:root {
  --bg: #faf7f1;
  --bg-side: #f2ece1;
  --ink: #201c17;
  --muted: #6e6357;
  --accent: #a8431f;
  --line: #ddd3c2;
  --sidebar-width: 320px;
  --content-max: 760px;
}

:root[data-theme="dark"] {
  --bg: #171410;
  --bg-side: #1d1913;
  --ink: #efe9df;
  --muted: #a49a8a;
  --accent: #e0824f;
  --line: #322c24;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #171410;
    --bg-side: #1d1913;
    --ink: #efe9df;
    --muted: #a49a8a;
    --accent: #e0824f;
    --line: #322c24;
  }
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background-color: var(--bg);
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='120' height='120'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/><feColorMatrix type='saturate' values='0'/></filter><rect width='100%25' height='100%25' filter='url(%23n)' opacity='0.025'/></svg>");
  color: var(--ink);
  font-family: "Source Serif 4", Georgia, "Times New Roman", serif;
  font-size: 17px;
  line-height: 1.65;
  transition: background-color 0.2s ease, color 0.2s ease;
}

a {
  color: var(--accent);
  text-decoration-color: color-mix(in srgb, var(--accent) 40%, transparent);
}

/* Layout */
.layout {
  display: grid;
  grid-template-columns: var(--sidebar-width) 1fr;
  min-height: 100vh;
}

/* Sidebar */
.sidebar {
  border-right: 1px solid var(--line);
  background: var(--bg-side);
}

.sidebar-inner {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 48px 32px;
  overflow-y: auto;
}

.sidebar-name {
  font-family: "Fraunces", serif;
  font-weight: 600;
  font-size: 1.25rem;
  line-height: 1.3;
  letter-spacing: -0.01em;
  white-space: nowrap;
  margin: 0 0 14px;
}

.sidebar-role {
  font-family: "JetBrains Mono", ui-monospace, monospace;
  color: var(--accent);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  line-height: 1.5;
  white-space: nowrap;
  margin: 0 0 40px;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.sidebar-nav a {
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  text-decoration: none;
  color: var(--muted);
  padding: 8px 0 8px 14px;
  border-left: 2px solid transparent;
  transition: color 0.15s ease, border-color 0.15s ease;
}

.sidebar-nav a:hover { color: var(--ink); }
.sidebar-nav a.active {
  color: var(--accent);
  border-left-color: var(--accent);
}

.sidebar-footer {
  padding-top: 36px;
  margin-top: 36px;
  border-top: 1px solid var(--line);
}

.sidebar-meta {
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 0.8rem;
  color: var(--muted);
  margin: 0 0 10px;
}

.sidebar-links {
  display: flex;
  gap: 16px;
  margin-bottom: 20px;
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 0.8rem;
}

.sidebar-links a { text-decoration: none; border-bottom: 1px solid color-mix(in srgb, var(--accent) 40%, transparent); }
.sidebar-links a:hover { border-color: var(--accent); }

.theme-toggle {
  align-self: flex-start;
  background: none;
  border: 1px solid var(--line);
  color: var(--muted);
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 6px 12px;
  cursor: pointer;
}

.theme-toggle:hover { color: var(--accent); border-color: var(--accent); }

/* Content */
.content {
  padding: 0 56px;
  min-width: 0;
}

.section {
  max-width: var(--content-max);
  padding: 52px 0;
  border-bottom: 1px solid var(--line);
}

.content .section:first-child { padding-top: 56px; }
.section:last-of-type { border-bottom: none; }

.section-label {
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
  margin: 0 0 26px;
  font-weight: 500;
}

.body-text {
  color: var(--ink);
  font-size: 1.03rem;
}

.section-intro {
  margin: -14px 0 30px;
  color: var(--muted);
  font-style: italic;
  font-size: 1rem;
}

.body-text strong { font-weight: 600; }

.stat-row {
  margin: 36px 0 0;
  padding-top: 28px;
  border-top: 1px solid var(--line);
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 20px;
}

.stat dt {
  font-family: "Fraunces", serif;
  font-weight: 600;
  font-size: 1.5rem;
  color: var(--accent);
}

.stat dd {
  margin: 4px 0 0;
  font-size: 0.8rem;
  color: var(--muted);
  line-height: 1.4;
}

/* Entries (experience / education) */
.entry {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 0 24px;
}

.entry + .entry {
  margin-top: 34px;
  padding-top: 34px;
  border-top: 1px solid var(--line);
}

.entry-compact + .entry-compact {
  margin-top: 22px;
  padding-top: 22px;
}

.entry-date {
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 0.78rem;
  color: var(--muted);
  padding-top: 3px;
}

.entry-body h4 {
  font-family: "Fraunces", serif;
  font-weight: 600;
  font-size: 1.1rem;
  margin: 0 0 4px;
}

.entry-org {
  font-weight: 400;
  color: var(--muted);
}

.entry-sub {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 0.92rem;
}

.entry-body ul {
  margin: 10px 0 0;
  padding-left: 18px;
  color: var(--muted);
  font-size: 0.98rem;
}

.entry-body li + li { margin-top: 5px; }

/* Skills */
.skill-list {
  margin: 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px 40px;
}

.skill-row dt {
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 0.8rem;
  color: var(--accent);
  margin-bottom: 4px;
}

.skill-row dd {
  margin: 0;
  color: var(--ink);
  font-size: 0.96rem;
}

/* Contact */
.contact-link {
  display: inline-block;
  margin-top: 6px;
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 1rem;
  text-decoration: none;
  border-bottom: 1px solid var(--accent);
  padding-bottom: 2px;
}

/* Footer */
.footer {
  padding: 24px 0 56px;
  border-bottom: none;
}

.footer p {
  margin: 0;
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 0.78rem;
  color: var(--muted);
}

/* Scroll reveal */
[data-reveal] {
  opacity: 0;
  transform: translateY(14px);
  transition: opacity 0.6s ease, transform 0.6s ease;
}

[data-reveal].is-visible {
  opacity: 1;
  transform: none;
}

@media (prefers-reduced-motion: reduce) {
  [data-reveal] {
    opacity: 1;
    transform: none;
    transition: none;
  }
}

/* Responsive */
@media (max-width: 900px) {
  .layout {
    display: block;
  }
  .sidebar {
    border-right: none;
    border-bottom: 1px solid var(--line);
  }
  .sidebar-inner {
    position: static;
    height: auto;
    padding: 36px 28px;
  }
  .sidebar-nav {
    flex-direction: row;
    flex-wrap: wrap;
    gap: 4px 18px;
    margin-bottom: 28px;
  }
  .sidebar-nav a {
    padding: 4px 0;
    border-left: none;
    border-bottom: 2px solid transparent;
  }
  .sidebar-nav a.active { border-left: none; border-bottom-color: var(--accent); }
  .content { padding: 0 28px; }
  .content .section:first-child { padding-top: 40px; }
}

@media (max-width: 560px) {
  .skill-list {
    grid-template-columns: 1fr;
    gap: 18px;
  }
  .entry {
    grid-template-columns: 1fr;
    gap: 4px;
  }
  .stat-row {
    grid-template-columns: repeat(2, 1fr);
    gap: 24px 16px;
  }
  .section { padding: 40px 0; }
}
