:root {
  --navy: #16304E;
  --navy-deep: #0F2238;
  --steel: #2E5C8A;
  --ink: #1F2A36;
  --muted: #5B6B7C;
  --paper: #F5F7FA;
  --white: #FFFFFF;
  --line: #D8E0E8;
  --gold: #B8903F;
  --sidebar-w: 280px;
  --measure: 70ch;
  font-size: 17px;
  box-sizing: border-box;
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

*, *::before, *::after { box-sizing: inherit; }

html { scroll-behavior: smooth; scroll-padding-top: 4.5rem; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: "Public Sans", "Helvetica Neue", Arial, sans-serif;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--steel); }
a:focus-visible { outline: 3px solid var(--gold); outline-offset: 3px; }

h1, h2, h3, .sidebar-name, .resume-head h3 {
  font-family: "Newsreader", Georgia, "Times New Roman", serif;
  font-weight: 500;
  line-height: 1.15;
  margin: 0;
}

/* Sidebar (desktop) */
.sidebar {
  position: fixed;
  top: 0; left: 0; bottom: 0;
  width: var(--sidebar-w);
  background: var(--navy);
  color: var(--white);
  overflow-y: auto;
}
.sidebar-inner { padding: 3rem 2rem; display: flex; flex-direction: column; min-height: 100%; }
.sidebar-name {
  color: var(--white);
  text-decoration: none;
  font-size: 2rem;
  letter-spacing: 0.005em;
}
.sidebar-role {
  margin: 0.9rem 0 2.5rem;
  font-size: 0.86rem;
  line-height: 1.5;
  color: #BFD0E3;
}
.sidebar-nav { display: flex; flex-direction: column; gap: 0.15rem; }
.sidebar-nav a {
  color: #E6EEF7;
  text-decoration: none;
  font-size: 0.95rem;
  padding: 0.42rem 0.75rem;
  margin-left: -0.75rem;
  border-left: 3px solid transparent;
  border-radius: 0 4px 4px 0;
}
.sidebar-nav a:hover { background: rgba(255,255,255,0.07); }
.sidebar-nav a.active { border-left-color: var(--gold); color: var(--white); background: rgba(255,255,255,0.09); }
.sidebar-foot {
  margin-top: auto;
  padding-top: 2.5rem;
  font-size: 0.8rem;
  line-height: 1.6;
  color: #BFD0E3;
}
.sidebar-foot a { color: #DCE7F2; text-decoration: none; word-break: break-all; }

/* Top bar (mobile) */
.topbar { display: none; }

/* Content */
.content {
  margin-left: var(--sidebar-w);
  padding: 0 clamp(1.5rem, 6vw, 5rem) 5rem;
  max-width: calc(var(--sidebar-w) + 56rem);
}

.hero {
  padding: 6rem 0 4rem;
  border-bottom: 1px solid var(--line);
}
.hero-kicker {
  margin: 0 0 1rem;
  font-size: 0.85rem;
  color: var(--gold);
  font-weight: 600;
}
.hero h1 {
  font-size: clamp(2.6rem, 5vw, 4rem);
  color: var(--navy);
}
.hero-sub {
  font-family: "Newsreader", Georgia, serif;
  font-size: 1.35rem;
  line-height: 1.4;
  color: var(--steel);
  max-width: 34ch;
  margin: 1.2rem 0 2rem;
}
.hero-body { max-width: var(--measure); }
.hero-body p { margin: 0 0 1rem; }
.hero-links { display: flex; flex-wrap: wrap; gap: 0.75rem; margin-top: 1.75rem; }

.btn {
  display: inline-block;
  background: var(--navy);
  color: var(--white);
  text-decoration: none;
  font-size: 0.92rem;
  font-weight: 500;
  padding: 0.7rem 1.1rem;
  border-radius: 4px;
  border: 1px solid var(--navy);
}
.btn:hover { background: var(--navy-deep); }
.btn-quiet { background: transparent; color: var(--navy); }
.btn-quiet:hover { background: #E7EDF4; }

.section { padding: 4rem 0 1rem; border-bottom: 1px solid var(--line); }
.section-last { border-bottom: 0; }
.section h2 {
  font-size: 2rem;
  color: var(--navy);
  margin-bottom: 1.5rem;
}
.section > p, .section-intro { max-width: var(--measure); }
.section-intro { margin: 0 0 2rem; color: var(--ink); }

/* Cover letter */
.letter {
  background: var(--white);
  border: 1px solid var(--line);
  padding: clamp(1.5rem, 4vw, 3.5rem);
  max-width: 46rem;
  margin-bottom: 3rem;
  line-height: 1.65;
}
.letter-from, .letter-to { margin-bottom: 1.25rem; line-height: 1.5; }
.letter-date { margin: 0 0 1.25rem; }
.letter-re { margin: 0 0 1.25rem; }
.letter p { margin: 0 0 1rem; }
.letter-sign { font-family: "Newsreader", Georgia, serif; font-size: 1.3rem; margin-top: 0.25rem; }

/* Resume */
.resume {
  background: var(--white);
  border: 1px solid var(--line);
  padding: clamp(1.5rem, 4vw, 3rem);
  max-width: 52rem;
  margin-bottom: 3rem;
}
.resume-head { border-bottom: 2px solid var(--navy); padding-bottom: 1rem; margin-bottom: 1.5rem; }
.resume-head h3 { font-size: 1.9rem; color: var(--navy); }
.resume-head p { margin: 0.4rem 0 0; font-size: 0.9rem; color: var(--muted); }
.resume h4 {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--steel);
  margin: 1.75rem 0 0.6rem;
  padding-bottom: 0.3rem;
  border-bottom: 1px solid var(--line);
}
.resume p { margin: 0 0 0.75rem; }
.resume ul { margin: 0.3rem 0 0.5rem; padding-left: 1.2rem; }
.resume li { margin-bottom: 0.25rem; }
.skills {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.2rem 1.5rem;
  list-style: none;
  padding: 0 !important;
}
.skills li { padding-left: 1rem; position: relative; }
.skills li::before { content: ""; position: absolute; left: 0; top: 0.72em; width: 6px; height: 6px; background: var(--gold); border-radius: 50%; }
.entry { margin-bottom: 1.1rem; }
.entry-head { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 0.25rem 1rem; }
.entry-head span { color: var(--muted); font-size: 0.9rem; }
.entry-sub { color: var(--muted); font-size: 0.92rem; margin: 0.15rem 0 0.4rem !important; }

/* Items with figures */
.item {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr);
  gap: 2.5rem;
  padding: 2rem 0;
  border-top: 1px solid var(--line);
}
.item:last-of-type { margin-bottom: 2rem; }
.item-wide { grid-template-columns: minmax(0, 1fr); max-width: var(--measure); }
.item h3 { font-size: 1.4rem; color: var(--navy); margin-bottom: 0.35rem; }
.item-meta { color: var(--muted); font-size: 0.9rem; margin: 0 0 0.9rem; }
.item-text p:last-child { margin-bottom: 0; }
.item-figure, .gallery figure { margin: 0; }
.item-figure img, .gallery img {
  display: block;
  width: 100%;
  max-width: 100%;
  height: auto;
  border: 1px solid var(--line);
  background: var(--white);
}
figcaption { font-size: 0.82rem; color: var(--muted); margin-top: 0.5rem; }

/* Milestones */
.milestones { max-width: var(--measure); border-top: 1px solid var(--line); }
.milestone { padding: 1.25rem 0; border-bottom: 1px solid var(--line); }
.milestone h3 { font-size: 1.25rem; color: var(--navy); margin-bottom: 0.2rem; }
.milestone p { margin: 0; }
.milestone .item-meta { margin-bottom: 0.4rem; }

.gallery {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 2rem;
  margin: 2.5rem 0 3rem;
}

/* Contact */
.contact { margin: 1.5rem 0 3rem; max-width: 30rem; }
.contact div { display: flex; gap: 1rem; padding: 0.6rem 0; border-top: 1px solid var(--line); }
.contact div:last-child { border-bottom: 1px solid var(--line); }
.contact dt { width: 6rem; color: var(--muted); font-size: 0.9rem; flex-shrink: 0; }
.contact dd { margin: 0; }
.contact a { text-decoration: none; }
.foot { font-size: 0.8rem; color: var(--muted); }

/* Mobile */
@media (max-width: 860px) {
  :root { --sidebar-w: 0px; }
  .sidebar { display: none; }
  .topbar {
    display: block;
    position: sticky;
    top: env(safe-area-inset-top, 0px);
    z-index: 10;
    background: var(--navy);
    color: var(--white);
    padding: 0.8rem 1.25rem 0;
  }
  body::before { content: ""; position: fixed; inset: 0 0 auto; height: env(safe-area-inset-top, 0px); background: var(--navy); z-index: 11; }
  .topbar-name {
    display: block;
    color: var(--white);
    text-decoration: none;
    font-family: "Newsreader", Georgia, serif;
    font-size: 1.3rem;
    margin-bottom: 0.5rem;
  }
  .topbar-nav {
    display: flex;
    gap: 0.25rem;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    margin: 0 -1.25rem;
    padding: 0 1.25rem 0.75rem;
  }
  .topbar-nav::-webkit-scrollbar { display: none; }
  .topbar-nav a {
    flex: 0 0 auto;
    color: #E6EEF7;
    text-decoration: none;
    font-size: 0.85rem;
    padding: 0.35rem 0.7rem;
    border-radius: 999px;
    background: rgba(255,255,255,0.08);
  }
  .content { margin-left: 0; padding: 0 1.25rem 4rem; max-width: 100%; }
  .hero { padding: 3rem 0 2.5rem; }
  .section { padding: 2.75rem 0 0.5rem; }
  .section h2 { font-size: 1.7rem; }
  .item, .gallery { grid-template-columns: minmax(0, 1fr); gap: 1.25rem; }
  .skills { grid-template-columns: 1fr; }
}
