:root {
  --font-serif: "Fraunces", "Noto Serif JP", serif;
  --font-sans: "Inter", "Noto Sans JP", system-ui, sans-serif;
  --accent: #1e3a5f;
}

[data-theme="light"] {
  --bg: #f6f7f9;       /* page / margin */
  --surface: #ffffff;   /* content card */
  --ink: #1a1a1a;
  --muted: #6c757d;
  --link: #1e3a5f;
  --halo-ring: rgba(0, 0, 0, 0.06);
  --halo-spread: #ffffff;
  --halo-shadow: rgba(0, 0, 0, 0.3);
}

[data-theme="dark"] {
  --bg: #16181d;       /* page / margin */
  --surface: #1f2227;   /* content card */
  --ink: #e5e7eb;
  --muted: #9ca3af;
  --link: #92b0d4;
  --halo-ring: rgba(255, 255, 255, 0.08);
  --halo-spread: #2a2e34;
  --halo-shadow: rgba(0, 0, 0, 0.5);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }

body {
  font-family: var(--font-sans);
  font-size: 1rem;
  line-height: 1.5;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3 {
  font-family: var(--font-serif);
  font-weight: 600;
  letter-spacing: -0.01em;
}

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

/* ===== Navbar ===== */
.site-nav {
  background: var(--accent);
  color: rgba(255, 255, 255, 0.85);
  position: sticky;
  top: 0;
  z-index: 10;
}
.nav-inner {
  max-width: 880px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 1.5rem;
  gap: 1rem;
  flex-wrap: wrap;
}
.nav-left, .nav-right {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}
.nav-left a,
.nav-right a,
.theme-toggle {
  color: rgba(255, 255, 255, 0.85);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.35rem 0.55rem;
  border-radius: 0.25rem;
  transition: color 0.18s ease, background 0.18s ease;
}
.nav-left a:hover,
.nav-right a:hover,
.theme-toggle:hover {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.08);
}
.brand {
  font-weight: 600;
  font-size: 1.05rem;
  margin-right: 0.5rem;
  white-space: nowrap;
}
.nav-left i { font-size: 1rem; }
.theme-toggle {
  border: none;
  background: transparent;
  cursor: pointer;
  font: inherit;
}

/* Show the icon matching the current theme (sun for light, moon for dark). */
[data-theme="light"] .icon-moon { display: none; }
[data-theme="dark"] .icon-sun { display: none; }

/* ===== About section ===== */
.about {
  max-width: 880px;
  margin: 1.5rem auto 1rem;
  padding: 1.5rem 2rem;
  background: var(--surface);
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-areas:
    "head image"
    "bio  bio";
  column-gap: 2rem;
  row-gap: 1.25rem;
  align-items: center;
}
.about-head {
  grid-area: head;
  min-width: 0;
  margin: 0;
}
.about-head h1 {
  margin: 0;
  font-size: clamp(2rem, 4vw, 2.6rem);
  line-height: 1.1;
}
.about-head .subtitle {
  font-family: "Noto Serif JP", serif;
  font-weight: 600;
  color: var(--muted);
  font-size: 1.05rem;
  margin: 0.35rem 0 0;
}

.headshot {
  grid-area: image;
  width: 9em;
  height: 9em;
  object-fit: cover;
  border-radius: 50%;
  box-shadow:
    0 0 0 1px var(--halo-ring),
    0 0 0 6px var(--halo-spread),
    0 8px 28px -10px var(--halo-shadow);
}

.bio { grid-area: bio; }
.bio p {
  margin: 0 0 0.85rem;
  line-height: 1.7;
}
.bio p:last-child { margin-bottom: 0; }

/* ===== Content sections (works, presentations, awards) ===== */
.section {
  max-width: 880px;
  margin: 0 auto 1rem;
  padding: 1.5rem 2rem;
  background: var(--surface);
}
.section h2 {
  margin: 0 0 1rem;
  font-size: 1.5rem;
}
.section ul,
.section ol {
  margin: 0;
  padding-left: 1.25rem;
}
.section li + li { margin-top: 0.5rem; }
.section li { line-height: 1.6; }

.works {
  list-style: none;
  padding-left: 0;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}
.works li + li { margin-top: 0; }
.work-title {
  margin: 0 0 0.3rem;
  font-weight: 600;
  line-height: 1.4;
}
.work-meta {
  margin: 0 0 0.5rem;
  color: var(--muted);
  font-size: 0.92rem;
}
.work-meta + .work-meta { margin-top: -0.35rem; }
.work-meta code {
  font-family: ui-monospace, monospace;
  font-size: 0.88em;
}
.work-tldr {
  margin: 0;
  line-height: 1.65;
}
.work-links {
  margin: 0.5rem 0 0;
  font-size: 0.9rem;
  color: var(--muted);
}
.work-links a { color: var(--link); }
.see-more {
  margin: 1.5rem 0 0;
  font-size: 0.92rem;
}

/* ===== Footer ===== */
.site-footer {
  max-width: 880px;
  margin: 0 auto;
  padding: 1.5rem 1.5rem 2.5rem;
  text-align: center;
  color: var(--muted);
  font-size: 0.85rem;
}

/* ===== Responsive: stack on narrow viewports ===== */
@media (max-width: 600px) {
  .nav-inner {
    flex-wrap: nowrap;
    padding: 0.65rem 0.55rem;
    gap: 0.25rem;
  }
  .nav-left,
  .nav-right {
    gap: 0.05rem;
  }
  .brand {
    font-size: 0.86rem;
    margin-right: 0.15rem;
  }
  .nav-left a,
  .theme-toggle {
    padding: 0.35rem 0.28rem;
  }

  .about {
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas:
      "head image"
      "bio  bio";
    column-gap: 0.85rem;
    row-gap: 1rem;
    margin: 1rem auto;
    padding: 1.25rem 1rem;
  }
  .about-head h1 { font-size: clamp(1.75rem, 8vw, 2.05rem); }
  .about-head .subtitle { font-size: 0.95rem; }
  .headshot {
    justify-self: end;
    width: clamp(4.5rem, 22vw, 5.5rem);
    height: clamp(4.5rem, 22vw, 5.5rem);
  }
  .section { padding: 1.25rem 1rem; }
}

/* ===== 404 page ===== */
.error-page {
  max-width: 600px;
  margin: 6rem auto;
  padding: 0 1.5rem;
  text-align: center;
}
.error-page h1 {
  font-size: clamp(3rem, 8vw, 5rem);
  margin: 0 0 1rem;
  line-height: 1;
}
.error-page p { line-height: 1.6; }
