:root {
  --bg: #f6f5f1;
  --fg: #1a1a1a;
  --muted: #6b6760;
  --faint: #9a968e;
  --rule: rgba(26, 26, 26, 0.14);
  --link: #1a1a1a;
  --link-underline: rgba(26, 26, 26, 0.35);
  --col: 680px;
}

:root[data-theme="dark"] {
  --bg: #17160f;
  --fg: #e6e2d6;
  --muted: #9a9488;
  --faint: #6a655c;
  --rule: rgba(230, 226, 214, 0.16);
  --link: #e6e2d6;
  --link-underline: rgba(230, 226, 214, 0.4);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--fg);
}

body {
  font-family: "Source Serif 4", "Source Serif Pro", Georgia, serif;
  font-size: 17px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

/* ---------- Theme toggle ---------- */
#theme-toggle {
  position: fixed;
  top: 24px;
  right: 28px;
  width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  padding: 0;
  cursor: pointer;
  color: var(--muted);
  border-radius: 999px;
  transition: color 0.15s ease, background-color 0.15s ease;
}
#theme-toggle:hover { color: var(--fg); background: var(--rule); }

#theme-toggle .icon-sun,
#theme-toggle .icon-moon { display: none; }
:root[data-theme="light"] #theme-toggle .icon-moon { display: block; }
:root[data-theme="dark"]  #theme-toggle .icon-sun  { display: block; }

/* ---------- Page column ---------- */
.page {
  max-width: var(--col);
  margin: 0 auto;
  padding: 120px 24px 160px;
}

/* ---------- Intro ---------- */
.intro { margin-bottom: 44px; }
.intro p { margin: 0; }
.intro-body { margin-bottom: 20px; }
.intro-contact { color: var(--fg); }

a {
  color: var(--link);
  text-decoration: underline;
  text-decoration-color: var(--link-underline);
  text-underline-offset: 3px;
  text-decoration-thickness: 1px;
  transition: text-decoration-color 0.15s ease;
}
a:hover { text-decoration-color: var(--link); }

/* ---------- Rule ---------- */
.rule {
  border: none;
  border-top: 1px solid var(--rule);
  margin: 0 0 44px;
}

/* ---------- Blocks ---------- */
.block { margin-bottom: 44px; }
.block:last-child { margin-bottom: 0; }

.label {
  font-family: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 20px;
}

/* ---------- Currently (key/value) ---------- */
.kv {
  display: grid;
  grid-template-columns: 120px 1fr;
  row-gap: 10px;
  column-gap: 20px;
  margin: 0;
}
.kv-row { display: contents; }
.kv dt {
  font-family: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  color: var(--muted);
  padding-top: 4px;
  letter-spacing: 0.02em;
}
.kv dd { margin: 0; color: var(--fg); }

/* ---------- Experience ---------- */
.exp { list-style: none; padding: 0; margin: 0; }
.exp-item { margin-bottom: 28px; }
.exp-item:last-child { margin-bottom: 0; }

.exp-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 16px;
  margin-bottom: 6px;
}
.exp-role {
  font-weight: 600;
  color: var(--fg);
}
.exp-sep { color: var(--faint); font-weight: 400; margin: 0 2px; }
.exp-company { font-weight: 400; color: var(--fg); }
.exp-meta {
  flex-shrink: 0;
  text-align: right;
  font-family: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px;
  color: var(--muted);
  letter-spacing: 0.02em;
  white-space: nowrap;
}
.exp-prose { margin: 0; color: var(--fg); }

/* ---------- Elsewhere ---------- */
.elsewhere {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 24px;
}
.elsewhere a {
  font-family: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 13px;
  color: var(--fg);
}

/* ---------- Writing ---------- */
.writing { list-style: none; padding: 0; margin: 0; }
.writing-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 16px;
  padding: 6px 0;
}
.writing-title { color: var(--fg); }
.writing-date {
  font-family: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px;
  color: var(--muted);
  letter-spacing: 0.02em;
  white-space: nowrap;
}

/* ---------- Responsive ---------- */
@media (max-width: 640px) {
  body { font-size: 16px; }
  .page { padding: 88px 20px 120px; }
  .kv { grid-template-columns: 100px 1fr; column-gap: 14px; }
  .exp-head { flex-direction: column; gap: 2px; }
  .exp-meta { text-align: left; }
  #theme-toggle { top: 16px; right: 16px; }
}
