:root {
  --bg: #ffffff;
  --text: #444444;
  --heading: #222222;
  --link: #3273dc;
  --visited: #8b6fcb;
  --code-bg: #f2f2f2;
  --code-fg: #222222;
  --border: #e0e0e0;
  --muted: #777777;
  --focus: #ff6e3c;
  --max-width: 720px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #01242e;
    --text: #dddddd;
    --heading: #eeeeee;
    --link: #8cc2dd;
    --visited: #8b6fcb;
    --code-bg: #000000;
    --code-fg: #dddddd;
    --border: #1a3a44;
    --muted: #88aabb;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

body {
  font: 1em/1.6 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 20px;
  background: var(--bg);
  color: var(--text);
  word-wrap: break-word;
}

h1, h2, h3, h4 {
  font-family: inherit;
  color: var(--heading);
  line-height: 1.3;
}
h1 { font-size: 1.6em; margin: 0 0 0.5em; }
h2 {
  font-size: 1.25em;
  margin: 2em 0 0.5em;
  padding-top: 0.5em;
  border-top: 1px solid var(--border);
}
h3 { font-size: 1.1em; margin: 1.2em 0 0.4em; }
h4 { font-size: 1em; margin: 1em 0 0.3em; }

a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }
a:visited { color: var(--visited); }
a:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
  border-radius: 2px;
}

nav { font-size: 0.95em; margin-top: 0.5em; }
nav a { margin-right: 4px; padding: 6px 4px; display: inline-block; }
strong, b { color: var(--heading); }

code, pre, kbd, samp {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
}
code {
  font-size: 0.92em;
  padding: 2px 5px;
  background: var(--code-bg);
  color: var(--code-fg);
  border-radius: 3px;
}
pre {
  font-size: 0.88em;
  padding: 10px 15px;
  background: var(--code-bg);
  color: var(--code-fg);
  border-radius: 3px;
  overflow-x: auto;
  line-height: 1.4;
}
pre code { padding: 0; background: none; border-radius: 0; }

blockquote {
  border-left: 1px solid #999;
  padding-left: 20px;
  font-style: italic;
  color: var(--text);
  margin: 1em 0;
}
hr { border: 0; border-top: 1px dashed var(--border); margin: 2em 0; }
img { max-width: 100%; height: auto; }

header { margin-bottom: 2em; }
header h1 a { color: var(--heading); }

footer {
  margin-top: 3em;
  padding-top: 1.5em;
  border-top: 1px dashed var(--border);
  text-align: center;
  color: var(--muted);
  font-size: 0.9em;
}

time { font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace; font-size: 0.95em; color: var(--muted); }
p { margin: 0.8em 0; }
section { margin-bottom: 2em; }
article header { margin-bottom: 1.5em; }
.back-link { margin-top: 2em; font-size: 0.95em; }

::selection { background: var(--link); color: var(--bg); }

/* Skip link */
.skip-link {
  position: absolute;
  top: -100px;
  left: 0;
  padding: 8px 16px;
  background: var(--heading);
  color: var(--bg);
  z-index: 100;
  text-decoration: none;
  font-weight: bold;
  border-radius: 0 0 4px 0;
}
.skip-link:focus { top: 0; }

/* Visually hidden */
.visually-hidden {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0);
  white-space: nowrap; border: 0;
}

/* Article headings: underline, with extra gap between sections */
article h2, article h3, article h4 {
  text-decoration: underline;
  text-decoration-color: var(--heading);
  text-decoration-thickness: 1px;
  text-underline-offset: 5px;
}
article h3 { margin-top: 2.5em; }
article header h2 { border-top: none; padding-top: 0; margin-top: 0.5em; }

/* Post list (writing section on home) */
ul.posts { list-style: none; padding: 0; margin: 1em 0; }
ul.posts li { display: flex; gap: 1em; margin: 0.5em 0; align-items: baseline; }
ul.posts time { flex: 0 0 100px; }
ul.posts a { flex: 1; }

/* Projects list */
ul.projects { list-style: none; padding: 0; margin: 1em 0; }
ul.projects li {
  padding: 0.7em 0;
  border-bottom: 1px solid var(--border);
}
ul.projects li:last-child { border-bottom: none; }
ul.projects .p-title {
  display: block;
  font-weight: bold;
  color: var(--heading);
  margin: 0;
  font-size: 1.05em;
}
ul.projects .p-title a,
ul.projects .p-title a:visited { color: var(--heading); }
ul.projects .p-desc {
  color: var(--text);
  font-size: 0.95em;
  margin: 0.25em 0 0;
}
ul.projects .p-links {
  margin: 0.3em 0 0;
  font-size: 0.85em;
}
ul.projects .p-links a { margin-right: 10px; }

/* Contact list */
ul.contact { list-style: none; padding: 0; margin: 1em 0; }
ul.contact li {
  display: flex;
  align-items: baseline;
  gap: 0.6em;
  margin: 0.3em 0;
  flex-wrap: wrap;
}
ul.contact .k {
  flex: 0 0 110px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  color: var(--muted);
  font-size: 0.95em;
}

/* Mobile */
@media (max-width: 480px) {
  body { padding: 16px; }
  ul.contact .k { flex: 0 0 88px; }
  ul.posts li { flex-direction: column; gap: 0.15em; }
  ul.posts time { flex: 0 0 auto; }
  h2 { margin-top: 1.6em; }
  nav { line-height: 1.9; }
  nav a { padding: 8px 6px; }
}
