:root {
  --bg: #ffffff;
  --text: #22262b;
  --muted: #646c76;
  --line: #e3e6ea;
  --accent: #1f5a96;
  --avatar-bg: #eef2f6;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #15181c;
    --text: #e4e7eb;
    --muted: #9aa3ad;
    --line: #2b3038;
    --accent: #7fb2e5;
    --avatar-bg: #222830;
  }
}

/* Set by the switch button (theme.js) */
:root[data-theme="dark"] {
  --bg: #15181c;
  --text: #e4e7eb;
  --muted: #9aa3ad;
  --line: #2b3038;
  --accent: #7fb2e5;
  --avatar-bg: #222830;
}

* { box-sizing: border-box; }

html { font-size: 17px; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  line-height: 1.6;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Top navigation */
.masthead { border-bottom: 1px solid var(--line); }

.masthead nav {
  max-width: 1040px;
  margin: 0 auto;
  padding: 0 24px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 28px;
  min-height: 60px;
}

.masthead a { color: var(--muted); padding: 6px 0; }
.masthead a:hover { color: var(--text); text-decoration: none; }
.masthead a.site-name { color: var(--text); font-weight: 700; margin-right: auto; }
.masthead a.current { color: var(--text); border-bottom: 2px solid var(--accent); }

#theme-toggle {
  background: none;
  border: 0;
  padding: 4px 6px;
  color: var(--muted);
  font-size: 1.15rem;
  line-height: 1;
  cursor: pointer;
}

#theme-toggle:hover { color: var(--text); }

/* Page layout: sidebar + content */
.layout {
  max-width: 1040px;
  margin: 0 auto;
  padding: 44px 24px 60px;
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  gap: 56px;
  align-items: start;
}

.sidebar { position: sticky; top: 32px; font-size: 0.9rem; }

.avatar {
  width: 170px;
  height: 170px;
  border-radius: 50%;
  object-fit: cover;
  display: block;
  margin-bottom: 18px;
}

.avatar.placeholder {
  background: var(--avatar-bg);
  color: var(--muted);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.6rem;
  font-weight: 600;
  letter-spacing: 0.04em;
}

.sidebar h2 { font-size: 1.15rem; margin: 0 0 4px; }
.sidebar p { margin: 0 0 14px; color: var(--muted); }
.sidebar ul { list-style: none; margin: 0; padding: 0; }
.sidebar li { margin: 5px 0; }

/* Content */
main h1 { font-size: 1.9rem; line-height: 1.25; margin: 0 0 20px; }

main h2 {
  font-size: 1.15rem;
  margin: 40px 0 14px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--line);
}

main p { margin: 0 0 16px; }

.paper { margin: 0 0 20px; }
.paper .title { font-weight: 600; }
.paper .meta { color: var(--muted); font-size: 0.93rem; }

/* Dated lists on the CV page */
.entries { list-style: none; margin: 0; padding: 0; }

.entries li {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  margin: 0 0 12px;
}

.entries .when {
  color: var(--muted);
  font-size: 0.9rem;
  white-space: nowrap;
  text-align: right;
}

.entries .sub { display: block; color: var(--muted); font-size: 0.93rem; }

.button {
  display: inline-block;
  border: 1px solid var(--accent);
  border-radius: 4px;
  padding: 6px 14px;
  font-size: 0.93rem;
}

.button:hover { background: var(--accent); color: var(--bg); text-decoration: none; }

footer {
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.82rem;
  text-align: center;
  padding: 20px 24px 28px;
}

@media (max-width: 760px) {
  .layout { grid-template-columns: 1fr; gap: 28px; padding-top: 28px; }
  .sidebar { position: static; }
  .avatar { width: 120px; height: 120px; }
  .entries li { flex-direction: column; gap: 0; }
  .entries .when { text-align: left; }
}
