:root {
  --bg: #ffffff;
  --text: #1a1a1a;
  --muted: #6b6b6b;
  --line: #e2e2e2;
  --accent: #1a1a1a;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121212;
    --text: #ececec;
    --muted: #9a9a9a;
    --line: #2e2e2e;
    --accent: #ececec;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Inter", system-ui, -apple-system, sans-serif;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a { color: inherit; }

/* ---------- Nav ---------- */

nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px 24px;
  max-width: 1100px;
  width: 100%;
  margin: 0 auto;
  padding: 24px;
}

.logo {
  white-space: nowrap;
  font-weight: 600;
  font-size: 1.1rem;
  text-decoration: none;
}

.nav-links {
  display: flex;
  gap: 24px;
  list-style: none;
  margin: 0;
  padding: 0;
}

.nav-links a {
  text-decoration: none;
  color: var(--muted);
  font-size: 0.95rem;
}

.nav-links a:hover,
.nav-links a[aria-current="page"] { color: var(--text); }

/* ---------- Page ---------- */

.page {
  flex: 1;
  padding: 48px 0 80px;
}

.container {
  max-width: 820px;
  margin: 0 auto;
  padding: 0 24px;
}

.page-title {
  font-size: 2rem;
  font-weight: 600;
  margin: 0 0 24px;
}

.epigraph {
  margin: 0 0 24px;
  padding-left: 16px;
  border-left: 2px solid var(--line);
  font-style: italic;
  color: var(--muted);
}

.epigraph cite {
  display: block;
  margin-top: 4px;
  font-style: normal;
  font-size: 0.875rem;
}

.tl-hint {
  margin: 0 0 40px;
  font-size: 0.875rem;
  color: var(--muted);
}

/* ---------- Vertical timeline ---------- */

:root {
  --tl-gutter: 88px;   /* width of the year column */
  --tl-dot: 11px;
}

.timeline {
  position: relative;
}

/* the vertical line */
.timeline::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: var(--tl-gutter);
  width: 1px;
  background: var(--line);
}

.tl-era + .tl-era { margin-top: 24px; }

.tl-era-label {
  position: relative;
  margin: 0 0 24px calc(var(--tl-gutter) + 32px);
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.tl-year {
  position: relative;
  display: grid;
  grid-template-columns: var(--tl-gutter) 1fr;
  padding-bottom: 40px;
}

/* the dot */
.tl-year::before {
  content: "";
  position: absolute;
  left: var(--tl-gutter);
  top: 8px;
  width: var(--tl-dot);
  height: var(--tl-dot);
  border-radius: 50%;
  background: var(--bg);
  border: 2px solid var(--accent);
  transform: translateX(-50%);
}

.tl-yl {
  padding-right: 24px;
  text-align: right;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.tl-empty { padding-bottom: 24px; }
.tl-empty::before { border-color: var(--line); }
.tl-empty .tl-yl { color: var(--muted); font-weight: 400; }

.tl-cards {
  grid-column: 2;
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding-left: 32px;
}

/* ---------- Cards ---------- */

.card {
  display: flex;
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
  background: var(--bg);
  color: inherit;
  text-decoration: none;
  transition: border-color 0.15s, transform 0.15s;
}

a.card:hover {
  border-color: var(--muted);
  transform: translateY(-2px);
}

.card-img {
  flex: 0 0 160px;
  background: var(--line);
}

.card-img img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.card-body { padding: 16px 20px; }

.badge {
  display: inline-block;
  margin-bottom: 6px;
  padding: 1px 8px;
  border-radius: 999px;
  background: var(--accent);
  color: var(--bg);
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.card-title {
  font-size: 1.05rem;
  font-weight: 600;
  line-height: 1.35;
}

.card-meta {
  margin: 4px 0 8px;
  font-size: 0.8rem;
  color: var(--muted);
}

.card-mentor {
  margin: -4px 0 8px;
  font-size: 0.8rem;
  color: var(--muted);
}

.card-desc { font-size: 0.95rem; }

.card-links {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 16px;
  margin-top: 10px;
  font-size: 0.875rem;
}

.text-link {
  text-decoration: underline;
  text-decoration-color: var(--line);
  text-underline-offset: 3px;
  overflow-wrap: anywhere;
}

.text-link:hover { text-decoration-color: currentColor; }

/* ---------- Footer ---------- */

footer {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  max-width: 1100px;
  width: 100%;
  margin: 0 auto;
  padding: 24px;
  border-top: 1px solid var(--line);
  font-size: 0.875rem;
  color: var(--muted);
}

/* ---------- Mobile ---------- */

@media (max-width: 600px) {
  :root { --tl-gutter: 5px; }

  nav, footer { padding: 16px; }
  .container { padding: 0 16px; }
  .page-title { font-size: 1.6rem; }

  .tl-era-label { margin-left: 28px; }

  .tl-year {
    grid-template-columns: 1fr;
    padding-left: 28px;
  }

  .tl-yl {
    text-align: left;
    padding-right: 0;
    margin-bottom: 8px;
  }

  .tl-cards { grid-column: 1; padding-left: 0; }

  .card { flex-direction: column; }
  .card-img { flex-basis: auto; aspect-ratio: 16 / 9; }
}

/* ---------- Home ---------- */

.hero {
  display: grid;
  grid-template-columns: 280px 1fr;
  align-items: center;
  gap: 48px;
  padding-top: 32px;
}

.hero-image img {
  display: block;
  width: 100%;
  height: auto;
}

.hero-text { margin-bottom: 32px; }

.hero-text p { margin: 0 0 12px; font-size: 1.1rem; }

.hero-hello {
  font-size: 2.25rem !important;
  font-weight: 600;
  line-height: 1.2;
}

.home-links {
  list-style: none;
  margin: 0;
  padding: 0;
  border-top: 1px solid var(--line);
}

.home-links a {
  display: flex;
  justify-content: space-between;
  padding: 16px 0;
  border-bottom: 1px solid var(--line);
  text-decoration: none;
  font-weight: 500;
}

.home-links .arrow { color: var(--muted); transition: transform 0.15s; }
.home-links a:hover .arrow { color: var(--text); transform: translateX(4px); }

/* ---------- Art ---------- */

.gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 24px;
}

.gallery:empty, .writing-list:empty { display: none; }

.art-item { margin: 0; }

.art-item img {
  display: block;
  width: 100%;
  border-radius: 8px;
  background: var(--line);
}

.art-item figcaption {
  margin-top: 8px;
  font-size: 0.875rem;
  color: var(--muted);
}

/* ---------- Writing ---------- */

.writing-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.writing-item {
  padding: 20px 0;
  border-bottom: 1px solid var(--line);
}

.writing-item:first-child { padding-top: 0; }

.writing-title {
  font-size: 1.05rem;
  font-weight: 600;
}

.empty-note { color: var(--muted); }
/* hide "Coming soon" once something is added */
.gallery:not(:empty) + .empty-note,
.writing-list:not(:empty) + .empty-note { display: none; }

@media (max-width: 600px) {
  .nav-links { gap: 14px; }
  .nav-links a { font-size: 0.9rem; }
  .logo { font-size: 1rem; }
  .hero-hello { font-size: 1.8rem !important; }
  .hero { grid-template-columns: 1fr; gap: 28px; padding-top: 0; }
  .hero-image img { max-width: 240px; }
}

/* ---------- About / story ---------- */

.about { margin-top: 96px; }

.section-title {
  font-size: 1.6rem;
  font-weight: 600;
  margin: 0 0 20px;
}

.about > p { font-size: 1.05rem; }

.about-lead {
  font-size: 1.25rem !important;
  font-weight: 500;
}

.story {
  margin-top: 64px;
  display: flex;
  flex-direction: column;
  gap: 48px;
}

.story-beat p {
  margin: 0 0 16px;
  font-size: 1.2rem;
  text-align: center;
}

.story-beat:nth-child(odd) p { text-align: left; }
.story-beat:nth-child(even) p { text-align: right; }

.aside {
  font-size: 0.95rem;
  color: var(--muted);
}

.story-photos {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 16px;
}

.story-photos img {
  display: block;
  height: 200px;
  width: auto;
  max-width: 100%;
  border-radius: 6px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.12);
  background: var(--line);
  transition: transform 0.2s;
}

.story-photos img:nth-child(odd)  { transform: rotate(-2deg); }
.story-photos img:nth-child(even) { transform: rotate(1.5deg); }
.story-photos img:hover { transform: rotate(0) scale(1.04); }

.story-poem {
  list-style: none;
  margin: 0 0 20px;
  padding: 0;
  text-align: center;
  font-size: 1.05rem;
  line-height: 1.9;
}

.about-closing {
  margin-top: 64px;
  padding-top: 40px;
  border-top: 1px solid var(--line);
  font-size: 1.05rem;
}

.about-final {
  font-size: 1.3rem;
  text-align: center;
  margin-top: 32px;
}

@media (max-width: 600px) {
  .about { margin-top: 64px; }
  .story-photos img { height: 140px; }
  .story-beat:nth-child(n) p { text-align: left; }
}

/* ---------- Project pages ---------- */

.card-more {
  margin-top: 10px;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--muted);
}

a.card:hover .card-more { color: var(--text); }

.project { max-width: 720px; }

.back-link {
  display: block;
  width: fit-content;
  margin-bottom: 28px;
  font-size: 0.9rem;
  color: var(--muted);
  text-decoration: none;
}

.back-link:hover { color: var(--text); }

.project .badge { margin-bottom: 12px; }

.project-title {
  font-size: 1.9rem;
  line-height: 1.25;
  margin-bottom: 12px;
}

.project-meta {
  margin: 0 0 6px;
  color: var(--muted);
}

.project-mentor {
  margin: 0;
  font-size: 0.95rem;
  color: var(--muted);
}

.project-mentor span {
  font-weight: 600;
  color: var(--text);
  margin-right: 4px;
}

.project-section {
  margin-top: 40px;
  padding-top: 28px;
  border-top: 1px solid var(--line);
}

.project-section h2 {
  margin: 0 0 12px;
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.project-section ul { margin: 0; padding-left: 20px; }
.project-section li { margin-bottom: 6px; }

.project-links { list-style: none; padding-left: 0 !important; }

.project-figure { margin: 24px 0; }
.project-figure img { display: block; width: 100%; border-radius: 8px; }
.project-figure figcaption { margin-top: 8px; font-size: 0.875rem; color: var(--muted); }

.project-pager {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-top: 64px;
}

.project-pager a {
  display: block;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 10px;
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
  line-height: 1.4;
}

.project-pager a:hover { border-color: var(--muted); }

.project-pager span {
  display: block;
  margin-bottom: 4px;
  font-size: 0.8rem;
  font-weight: 400;
  color: var(--muted);
}

.pager-next { text-align: right; }

@media (max-width: 600px) {
  .project-title { font-size: 1.5rem; }
  .project-pager { grid-template-columns: 1fr; }
  .pager-next { text-align: left; }
}

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 20px;
  padding: 10px 18px;
  border-radius: 999px;
  background: var(--accent);
  color: var(--bg);
  font-size: 0.95rem;
  font-weight: 500;
  text-decoration: none;
  transition: opacity 0.15s;
}

.btn:hover { opacity: 0.85; }

/* ---------- Lab notebook ---------- */

.nb-kicker {
  margin: 0 0 8px;
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

nav.nb-jump {
  display: block;
  max-width: none;
  margin: 28px 0 0;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 10px;
}

.nb-jump span {
  display: block;
  margin-bottom: 8px;
  font-size: 0.8rem;
  color: var(--muted);
}

.nb-jump ul {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  list-style: none;
  margin: 0;
  padding: 0;
}

.nb-jump a {
  display: inline-block;
  min-width: 32px;
  padding: 4px 8px;
  border-radius: 6px;
  background: var(--line);
  text-align: center;
  font-size: 0.85rem;
  text-decoration: none;
  font-variant-numeric: tabular-nums;
}

.nb-jump a:hover { background: var(--accent); color: var(--bg); }

.nb-entry {
  margin-top: 36px;
  padding-top: 24px;
  border-top: 1px solid var(--line);
  scroll-margin-top: 16px;
}

.nb-entry h2 {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 12px;
  margin: 0 0 12px;
  font-size: 1.15rem;
}

.nb-date {
  font-size: 0.9rem;
  font-weight: 400;
  color: var(--muted);
}

.nb-entry ul { margin: 0; padding-left: 20px; }
.nb-entry li { margin-bottom: 6px; }
.nb-entry li ul { margin-top: 6px; list-style: circle; }
.nb-entry li li { color: var(--muted); font-size: 0.95rem; }

.nb-entry code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.82em;
  padding: 1px 5px;
  border-radius: 4px;
  background: var(--line);
  color: var(--text);
  overflow-wrap: anywhere;
}

.nb-table {
  margin: 12px auto 16px;
  border-collapse: collapse;
  font-size: 0.95rem;
  font-variant-numeric: tabular-nums;
}

.nb-table th, .nb-table td {
  padding: 6px 16px;
  border-bottom: 1px solid var(--line);
  text-align: left;
}

.nb-table th { font-weight: 600; font-size: 0.85rem; color: var(--muted); }

.nb-figs {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 16px;
  margin: 16px 0 4px;
}

.nb-figs figure { margin: 0; flex: 0 1 calc(50% - 8px); }

@media (max-width: 560px) {
  .nb-figs figure { flex-basis: 100%; }
}

.nb-figs img {
  display: block;
  width: 100%;
  height: auto;
  border: 1px solid var(--line);
}

.nb-figs figcaption {
  margin-top: 6px;
  line-height: 1.45;
  font-size: 0.8rem;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.nb-current {
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 10px;
}

.project-poster { margin: 32px 0 0; }

.project-poster img {
  display: block;
  width: 100%;
  height: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.project-poster figcaption {
  margin-top: 8px;
  font-size: 0.85rem;
  color: var(--muted);
}

/* ---------- Divided abstract ---------- */

.abstract-part {
  display: grid;
  grid-template-columns: 120px 1fr;
  gap: 24px;
  padding: 20px 0;
  border-bottom: 1px solid var(--line);
}

.abstract-part:last-child { border-bottom: none; padding-bottom: 0; }

.abstract-part h3 {
  margin: 2px 0 0;
  font-size: 0.95rem;
  font-weight: 600;
}

.abstract-part p { margin: 0 0 12px; line-height: 1.7; }
.abstract-part p:last-child { margin-bottom: 0; }

.cite { font-size: 0.7em; line-height: 0; }
.cite a { text-decoration: none; color: var(--muted); padding: 0 1px; }
.cite a:hover { color: var(--text); text-decoration: underline; }

.references ol { padding-left: 22px; margin: 0; }
.references li {
  margin-bottom: 10px;
  font-size: 0.9rem;
  color: var(--muted);
  scroll-margin-top: 16px;
}
.references li:target { color: var(--text); }

@media (max-width: 600px) {
  .abstract-part { grid-template-columns: 1fr; gap: 8px; }
}
