/* Shared UI for the signed-in timeline, projects and portfolio pages.
   Dark theme; everything is scoped to new class names so the landing page is untouched. */
:root {
  --ui-bg: #0d0d0d;
  --ui-surface: #141518;
  --ui-surface-2: #1b1d21;
  --ui-line: rgba(255, 255, 255, 0.08);
  --ui-line-strong: rgba(255, 255, 255, 0.16);
  --ui-text: #f0f0f0;
  --ui-muted: #a3a8b0;
  --ui-faint: #8b9099; /* AA contrast on every surface it sits on */
  --ui-accent: #3d9bff;
  --ui-accent-soft: rgba(61, 155, 255, 0.14);
  --ui-radius: 12px;
  --ui-font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --ui-ease: cubic-bezier(0.22, 1, 0.36, 1);
}

/* ---------- Top navigation ---------- */
.topbar {
  position: sticky; top: 0; z-index: 50;
  background: rgba(13, 13, 13, 0.82);
  -webkit-backdrop-filter: saturate(140%) blur(12px); backdrop-filter: saturate(140%) blur(12px);
  border-bottom: 1px solid var(--ui-line);
  font-family: var(--ui-font);
}
.topnav {
  max-width: 1100px; margin: 0 auto; padding: 0 20px; height: 56px;
  display: flex; align-items: center; gap: 24px;
}
.topnav .brand { color: var(--ui-text); font-weight: 600; letter-spacing: 0.2px; text-decoration: none; white-space: nowrap; }
.topnav ul { display: flex; gap: 4px; list-style: none; margin: 0 0 0 auto; padding: 0; }
.topnav ul a, .topnav .lock {
  display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 12px; border-radius: 8px;
  color: var(--ui-muted); text-decoration: none; font-size: 14px; font-weight: 500; background: none; border: 0; cursor: pointer; font-family: inherit;
  transition: color 0.15s, background-color 0.15s;
}
.topnav ul a:hover, .topnav .lock:hover { color: var(--ui-text); background: rgba(255, 255, 255, 0.06); }
.topnav ul a[aria-current="page"] { color: var(--ui-text); background: rgba(255, 255, 255, 0.08); }
.topnav form { margin: 0; }
.topnav .lock { border: 1px solid var(--ui-line-strong); }
@media (max-width: 640px) {
  .topnav { gap: 8px; padding: 0 10px; height: 52px; }
  .topnav .brand { display: none; }
  .topnav ul { margin: 0; flex: 1; justify-content: space-between; }
  .topnav ul a, .topnav .lock { padding: 0 9px; font-size: 13.5px; }
}

/* Visible keyboard focus everywhere in the new UI */
.topbar a:focus-visible, .topbar button:focus-visible, .ui :is(a, button, [tabindex]):focus-visible, .ov :is(a, button):focus-visible {
  outline: 2px solid var(--ui-accent); outline-offset: 2px; border-radius: 8px;
}

/* ---------- Buttons and chips ---------- */
.ui { font-family: var(--ui-font); color: var(--ui-text); }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 42px; padding: 0 18px;
  border-radius: 10px; border: 1px solid transparent; background: var(--ui-accent); color: #fff; font: 600 15px/1 var(--ui-font);
  text-decoration: none; cursor: pointer; transition: transform 0.15s var(--ui-ease), background-color 0.15s, border-color 0.15s;
  background-color: #1769d1; /* white text at 4.5:1+ (WCAG AA) */
}
.btn:hover { background: #1f74e0; }
.btn:active { transform: translateY(1px); }
.btn-ghost { background: transparent; color: var(--ui-text); border-color: var(--ui-line-strong); }
.btn-ghost:hover { background: rgba(255, 255, 255, 0.06); border-color: rgba(255, 255, 255, 0.28); }
.chip {
  height: 34px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--ui-line-strong); background: transparent;
  color: var(--ui-muted); font: 500 13.5px/1 var(--ui-font); cursor: pointer; white-space: nowrap; transition: all 0.15s;
}
.chip:hover { color: var(--ui-text); border-color: rgba(255, 255, 255, 0.3); }
.chip[aria-pressed="true"] { background: var(--ui-text); color: #0d0d0d; border-color: var(--ui-text); }

/* ---------- Signed-in intro ---------- */
.intro-card { font-family: var(--ui-font); max-width: 760px; margin: 4px auto 0; text-align: left; }
.intro-card .lead { font-size: 17px; line-height: 1.7; color: var(--ui-text); margin: 0 0 14px; }
.intro-card .sub { font-size: 15px; line-height: 1.7; color: var(--ui-muted); margin: 0 0 18px; }
.intro-card .actions { display: flex; gap: 10px; flex-wrap: wrap; }
.intro-card strong { color: #fff; font-weight: 600; }

/* ---------- Timeline ---------- */
.timeline.ui-timeline { border-left: 0; padding-left: 0; }
.timeline.ui-timeline::before { display: none; }
.tl-toolbar {
  font-family: var(--ui-font); display: flex; align-items: center; gap: 12px; margin: 8px 0 18px;
  position: sticky; top: 56px; z-index: 5; padding: 10px 0; background: linear-gradient(var(--ui-bg) 75%, transparent);
}
.tl-filters { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; flex: 1; padding: 2px; }
.tl-filters::-webkit-scrollbar { display: none; }
.tl-expand-all { flex: none; background: none; border: 0; color: var(--ui-accent); font: 500 14px var(--ui-font); cursor: pointer; padding: 6px 4px; }
.tl-expand-all:hover { text-decoration: underline; }
.tl { list-style: none; margin: 0; padding: 0 0 0 22px; position: relative; font-family: var(--ui-font); }
.tl::before { content: ""; position: absolute; left: 5px; top: 8px; bottom: 8px; width: 2px; background: linear-gradient(var(--ui-accent), rgba(61, 155, 255, 0.15)); border-radius: 2px; }
.tl-item { position: relative; margin: 0 0 10px; }
.tl-item[hidden] { display: none; }
.tl-item::before {
  content: ""; position: absolute; left: -22px; top: 22px; width: 12px; height: 12px; border-radius: 50%;
  background: var(--ui-bg); border: 2px solid var(--ui-accent); transition: background-color 0.2s, box-shadow 0.2s;
}
.tl-item.open::before { background: var(--ui-accent); box-shadow: 0 0 0 4px var(--ui-accent-soft); }
.tl-head { margin: 0; font-size: inherit; font-weight: inherit; }
.tl-toggle {
  width: 100%; display: grid; grid-template-columns: 1fr auto; grid-template-areas: "date chev" "title chev" "meta chev";
  gap: 2px 16px; align-items: center; text-align: left; padding: 14px 18px; border-radius: var(--ui-radius);
  background: var(--ui-surface); border: 1px solid var(--ui-line); color: var(--ui-text); font: inherit; cursor: pointer;
  transition: background-color 0.2s, border-color 0.2s;
}
.tl-toggle:hover { background: var(--ui-surface-2); border-color: var(--ui-line-strong); }
.tl-item.open .tl-toggle { border-bottom-left-radius: 0; border-bottom-right-radius: 0; background: var(--ui-surface-2); }
.tl-date { grid-area: date; font-size: 12.5px; letter-spacing: 0.6px; text-transform: uppercase; color: var(--ui-accent); font-weight: 600; }
.tl-title { grid-area: title; font-size: 17px; font-weight: 600; line-height: 1.35; }
.tl-age { display: none; }
.tl-meta { grid-area: meta; font-size: 13px; color: var(--ui-faint); }
.tl-meta:empty { display: none; }
.tl-chevron { grid-area: chev; width: 10px; height: 10px; border-right: 2px solid var(--ui-muted); border-bottom: 2px solid var(--ui-muted); transform: rotate(45deg) translateY(-3px); transition: transform 0.3s var(--ui-ease); }
.tl-item.open .tl-chevron { transform: rotate(-135deg) translate(-2px, -2px); }
.tl-body { display: grid; grid-template-rows: 0fr; transition: grid-template-rows 0.35s var(--ui-ease); }
.tl-item.open .tl-body { grid-template-rows: 1fr; }
.tl-inner {
  overflow: hidden; min-height: 0; background: var(--ui-surface); border: 1px solid var(--ui-line); border-top: 0;
  border-radius: 0 0 var(--ui-radius) var(--ui-radius); padding: 0 18px; visibility: hidden; transition: padding 0.35s var(--ui-ease), visibility 0s 0.35s;
}
.tl-item.open .tl-inner { padding: 6px 18px 18px; visibility: visible; transition: padding 0.35s var(--ui-ease); }
.tl-inner > p { font-size: 15.5px; line-height: 1.7; color: #d6d9de; margin: 10px 0 0; max-width: 72ch; }
.tl-inner a { color: var(--ui-accent); }
.tl-note { color: var(--ui-muted) !important; font-style: italic; }
.tl-highlights { list-style: none; margin: 14px 0 0; padding: 0; display: grid; gap: 10px; }
.tl-highlights li { background: rgba(61, 155, 255, 0.06); border: 1px solid rgba(61, 155, 255, 0.16); border-radius: 10px; padding: 12px 14px; }
.tl-highlights h4 { margin: 0 0 4px; font-size: 14.5px; font-weight: 600; color: #cfe5ff; }
.tl-highlights p { margin: 0; font-size: 14.5px; line-height: 1.6; color: #c8ccd2; }
.tl-media { margin-top: 16px; }
.tl-more { margin: 16px 0 0; }

/* Tabs */
.tab-list { display: flex; gap: 6px; border-bottom: 1px solid var(--ui-line); margin-bottom: 14px; overflow-x: auto; }
.tab {
  display: inline-flex; align-items: center; gap: 8px; padding: 10px 12px; margin-bottom: -1px; background: none; border: 0;
  border-bottom: 2px solid transparent; color: var(--ui-muted); font: 500 14px var(--ui-font); cursor: pointer; white-space: nowrap;
}
.tab:hover { color: var(--ui-text); }
.tab[aria-selected="true"] { color: var(--ui-text); border-bottom-color: var(--ui-accent); }
.tab-count { font-size: 12px; padding: 1px 7px; border-radius: 999px; background: rgba(255, 255, 255, 0.08); color: var(--ui-muted); }

/* Photo grid */
.gal { display: grid; grid-template-columns: repeat(auto-fill, minmax(132px, 1fr)); gap: 6px; }
.gal-item {
  position: relative; aspect-ratio: 1; padding: 0; border: 0; border-radius: 8px; overflow: hidden; cursor: zoom-in; background: #1f2126;
}
.gal-item img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform 0.4s var(--ui-ease), opacity 0.2s; }
.gal-item:hover img { transform: scale(1.04); }
.gal-video { cursor: pointer; }
.gal-play { position: absolute; inset: 0; margin: auto; width: 46px; height: 46px; border-radius: 50%; background: rgba(0, 0, 0, 0.65); border: 2px solid #fff; }
.gal-play::after { content: ""; position: absolute; left: 17px; top: 12px; border-style: solid; border-width: 10px 0 10px 15px; border-color: transparent transparent transparent #fff; }
@media (max-width: 520px) { .gal { grid-template-columns: repeat(3, 1fr); gap: 4px; } }

/* Document list */
.docs { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 8px; }
.doc {
  width: 100%; display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 10px; text-align: left;
  background: var(--ui-surface-2); border: 1px solid var(--ui-line); color: var(--ui-text); font: 500 14.5px var(--ui-font);
  cursor: pointer; text-decoration: none; transition: border-color 0.15s, background-color 0.15s;
}
.doc:hover { border-color: rgba(61, 155, 255, 0.5); background: #20242b; }
.doc-icon { flex: none; width: 36px; height: 36px; border-radius: 8px; display: grid; place-items: center; font-size: 11px; font-weight: 700; letter-spacing: 0.5px; color: #ffb4a8; background: rgba(255, 99, 71, 0.12); }
.doc-title { flex: 1; min-width: 0; }
.doc-size { flex: none; font-size: 12.5px; color: var(--ui-faint); }

/* ---------- Overlays (lightbox, PDF viewer, video) ---------- */
html.ov-open { overflow: hidden; }
.ov {
  position: fixed; inset: 0; z-index: 1000; background: rgba(5, 6, 8, 0.94); display: flex; flex-direction: column;
  font-family: var(--ui-font); color: var(--ui-text); opacity: 0; transition: opacity 0.2s ease;
}
.ov.in { opacity: 1; }
.ov-bar { display: flex; align-items: center; gap: 12px; padding: 10px 12px 10px 18px; min-height: 56px; }
.ov-title { flex: 1; min-width: 0; font-weight: 600; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ov-count { font-size: 13px; color: var(--ui-muted); font-variant-numeric: tabular-nums; }
.ov-link { color: var(--ui-accent); font-size: 14px; text-decoration: none; white-space: nowrap; }
.ov-link:hover { text-decoration: underline; }
.ov-close, .ov-nav {
  display: grid; place-items: center; width: 42px; height: 42px; border-radius: 50%; border: 0; cursor: pointer;
  background: rgba(255, 255, 255, 0.08); color: #fff; font-size: 26px; line-height: 1; transition: background-color 0.15s;
}
.ov-close:hover, .ov-nav:hover { background: rgba(255, 255, 255, 0.18); }
.ov-stage { flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; padding: 0 64px 24px; }
.ov-img { max-width: 100%; max-height: 100%; object-fit: contain; border-radius: 6px; opacity: 0; transform: scale(0.985); transition: opacity 0.25s, transform 0.25s var(--ui-ease); }
.ov-img.ready { opacity: 1; transform: none; }
.ov-photo .ov-nav { position: absolute; top: 50%; transform: translateY(-50%); font-size: 30px; }
.ov-photo .ov-prev { left: 14px; }
.ov-photo .ov-next { right: 14px; }
.ov-doc .ov-stage { padding: 0 12px 12px; }
.ov-frame { width: 100%; height: 100%; border: 0; border-radius: 8px; background: #fff; }
.ov-video { width: min(100%, 1100px); aspect-ratio: 16 / 9; }
.ov-video iframe { width: 100%; height: 100%; border: 0; border-radius: 8px; }
@media (max-width: 700px) {
  .ov-stage { padding: 0 0 12px; }
  .ov-photo .ov-nav { top: auto; bottom: 18px; transform: none; }
  .ov-photo .ov-prev { left: calc(50% - 54px); }
  .ov-photo .ov-next { right: calc(50% - 54px); }
  .ov-photo .ov-stage { padding-bottom: 80px; }
}

/* ---------- Page shell for projects / portfolio ---------- */
body.page { background: var(--ui-bg); color: var(--ui-text); font-family: var(--ui-font); margin: 0; line-height: 1.6; -webkit-text-size-adjust: 100%; }
.page-main { max-width: 1100px; margin: 0 auto; padding: 40px 20px 64px; }
.page-head { margin: 0 0 28px; }
.eyebrow { font-size: 12.5px; letter-spacing: 1px; text-transform: uppercase; color: var(--ui-accent); font-weight: 600; margin: 0 0 8px; }
.page-head h1 { font-size: clamp(28px, 4vw, 40px); line-height: 1.15; margin: 0 0 10px; letter-spacing: -0.5px; font-weight: 700; }
.page-head p { color: var(--ui-muted); max-width: 64ch; margin: 0; font-size: 16.5px; }
.section-title { font-size: 20px; margin: 44px 0 14px; font-weight: 650; letter-spacing: -0.2px; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 14px; }
.card {
  background: var(--ui-surface); border: 1px solid var(--ui-line); border-radius: var(--ui-radius); padding: 20px;
  display: flex; flex-direction: column; gap: 10px; transition: border-color 0.2s, transform 0.2s var(--ui-ease);
}
.card:hover { border-color: var(--ui-line-strong); }
.card h3 { margin: 0; font-size: 17.5px; line-height: 1.35; font-weight: 650; }
.card .facts { display: flex; flex-wrap: wrap; gap: 6px; margin: 0; padding: 0; list-style: none; }
.card .facts li { font-size: 12.5px; color: #cfd3d9; background: rgba(255, 255, 255, 0.06); border-radius: 999px; padding: 3px 10px; }
.card p { margin: 0; color: #c8ccd2; font-size: 14.5px; line-height: 1.65; }
.card .role { color: var(--ui-muted); font-size: 13.5px; }
.card .links { display: flex; flex-wrap: wrap; gap: 8px; margin-top: auto; padding-top: 6px; }
.card .links a, .card .links span.locked {
  display: inline-flex; align-items: center; gap: 6px; font-size: 13.5px; font-weight: 500; color: var(--ui-accent); text-decoration: none;
  padding: 7px 12px; border-radius: 8px; background: var(--ui-accent-soft);
}
.card .links a:hover { background: rgba(61, 155, 255, 0.24); }
.card .links .locked { color: var(--ui-muted) !important; background: rgba(255, 255, 255, 0.06) !important; }
.hero-card {
  display: flex; align-items: center; justify-content: space-between; gap: 20px; flex-wrap: wrap;
  background: linear-gradient(135deg, rgba(61, 155, 255, 0.16), rgba(61, 155, 255, 0.03)); border: 1px solid rgba(61, 155, 255, 0.28);
  border-radius: 16px; padding: 24px;
}
.hero-card h2 { margin: 0 0 4px; font-size: 20px; }
.hero-card p { margin: 0; color: var(--ui-muted); }
.page-foot { border-top: 1px solid var(--ui-line); margin-top: 56px; padding-top: 22px; color: var(--ui-faint); font-size: 14px; display: flex; gap: 16px; flex-wrap: wrap; justify-content: space-between; }
.page-foot a { color: var(--ui-muted); text-decoration: none; }
.page-foot a:hover { color: var(--ui-text); }
@media (max-width: 520px) {
  .page-main { padding: 28px 16px 48px; }
  .cards { grid-template-columns: 1fr; }
}

/* ---------- Motion ---------- */
@keyframes ui-rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
.timeline.active .tl-item { animation: ui-rise 0.5s var(--ui-ease) both; }
.timeline.active .tl-item:nth-child(-n+8) { animation-delay: calc(var(--i, 0) * 40ms); }
@media (prefers-reduced-motion: reduce) {
  /* iteration-count: 1 matters: a 0.01ms animation left on "infinite" is sampled at a random phase every
     frame, which made the portrait pulse flicker on phones with Reduce Motion turned on. */
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; scroll-behavior: auto !important; }
  /* The portrait keeps its original gentle pulse (scale 1 -> 1.03 and a soft blue glow, no opacity change). */
  .profile:not(.pulse-stopped) { animation: pulse 1.729s cubic-bezier(0.4, 0, 0.6, 1) infinite !important; }
}

/* ---------- Portfolio download + misc page bits ---------- */
.skip { position: absolute; left: -9999px; top: 8px; z-index: 100; background: #fff; color: #000; padding: 8px 12px; border-radius: 8px; }
.skip:focus { left: 8px; }
.card .links .sz { color: var(--ui-faint); font-weight: 400; font-size: 12px; }
.download { max-width: 640px; }
.download-card {
  display: flex; align-items: center; gap: 16px; padding: 20px 22px; border-radius: 16px; text-decoration: none; color: var(--ui-text);
  background: linear-gradient(135deg, rgba(61, 155, 255, 0.18), rgba(61, 155, 255, 0.04)); border: 1px solid rgba(61, 155, 255, 0.35);
  transition: transform 0.2s var(--ui-ease), border-color 0.2s;
}
.download-card:hover { border-color: rgba(61, 155, 255, 0.7); transform: translateY(-1px); }
.download-icon { flex: none; width: 52px; height: 52px; border-radius: 12px; display: grid; place-items: center; font-weight: 700; font-size: 13px; color: #ffb4a8; background: rgba(255, 99, 71, 0.14); }
.download-text { flex: 1; display: flex; flex-direction: column; gap: 2px; }
.download-text strong { font-size: 18px; }
.download-text span { color: var(--ui-muted); font-size: 14px; }
.download-arrow { display: grid; place-items: center; color: var(--ui-accent); transition: transform 0.2s var(--ui-ease); }
.download-card:hover .download-arrow { transform: translateY(2px); }
.download-alt { color: var(--ui-muted); margin: 16px 2px 0; }
.download-alt a { color: var(--ui-accent); }

/* ---------- Round 2 polish ---------- */
/* Smooth cross-page fades (Chrome/Edge/Safari 18.2+; others just navigate normally). */
/* Desktop only: on phones the collapsing URL bar resizes the viewport mid-navigation, which aborts the transition with a console error. */
@media (hover: hover) and (pointer: fine) { @view-transition { navigation: auto; } }
::view-transition-old(root), ::view-transition-new(root) { animation-duration: 0.28s; animation-timing-function: var(--ui-ease); }
@media (prefers-reduced-motion: reduce) { @view-transition { navigation: none; } }

/* The legacy side rail duplicates the new timeline line and "Expand all"; hide it once signed in. */
body.is-unlocked .expand-all-button { display: none; }

/* Sticky filter bar: solid backing with a soft fade below, so cards never peek through it. */
.tl-toolbar { background: var(--ui-bg); }
.tl-toolbar::after { content: ""; position: absolute; left: 0; right: 0; top: 100%; height: 14px; background: linear-gradient(var(--ui-bg), transparent); pointer-events: none; }
.tl-item { scroll-margin-top: 124px; }
.tl-filters { -webkit-mask-image: linear-gradient(90deg, #000 calc(100% - 28px), transparent); mask-image: linear-gradient(90deg, #000 calc(100% - 28px), transparent); padding-right: 24px; }
.tl-toggle:active { transform: scale(0.997); }
.tl-toggle { transition: background-color 0.2s, border-color 0.2s, transform 0.12s; }

/* Photo tiles: subtle lift and focus ring that sits inside the rounded tile. */
.gal-item::after { content: ""; position: absolute; inset: 0; border-radius: inherit; box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.06); transition: box-shadow 0.2s; pointer-events: none; }
.gal-item:hover::after { box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.22); }
.ui .gal-item:focus-visible { outline: 0; }
.ui .gal-item:focus-visible::after { box-shadow: inset 0 0 0 2px var(--ui-accent); }
.gal-item img { opacity: 0; }
.gal-item img.loaded, .gal-item img[data-loaded] { opacity: 1; }

/* Project cards: gentle lift on hover. */
@media (hover: hover) { .card:hover { transform: translateY(-2px); } }
.card h3 { text-wrap: balance; }
.page-head h1, .section-title { text-wrap: balance; }
.page-main { animation: ui-rise 0.45s var(--ui-ease) both; }

/* Back to top */
.to-top {
  position: fixed; right: 18px; bottom: calc(18px + env(safe-area-inset-bottom)); z-index: 40; width: 44px; height: 44px; border-radius: 50%;
  border: 1px solid var(--ui-line-strong); background: rgba(27, 29, 33, 0.9); color: var(--ui-text); cursor: pointer;
  -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px); display: grid; place-items: center; font: 600 18px/1 var(--ui-font);
  opacity: 0; transform: translateY(8px); pointer-events: none; transition: opacity 0.2s, transform 0.2s var(--ui-ease), background-color 0.15s;
}
.to-top.show { opacity: 1; transform: none; pointer-events: auto; }
.to-top:hover { background: #262a30; }
.to-top:focus-visible { outline: 2px solid var(--ui-accent); outline-offset: 2px; }

/* Phones: bigger tap targets, nav that never clips, safe areas. */
@media (max-width: 640px) {
  .tl-toolbar { top: 52px; }
  .topnav { padding: 0 max(8px, env(safe-area-inset-left)); }
  .topnav ul a, .topnav .lock { height: 40px; padding: 0 8px; }
  .topnav ul { gap: 0; }
  .chip { height: 38px; }
  .tl-expand-all { min-height: 38px; font-size: 13.5px; }
  .tl { padding-left: 18px; }
  .tl-item::before { left: -18px; }
  .tl::before { left: 4px; }
  .tl-toggle { padding: 13px 14px; }
  .tl-item.open .tl-inner { padding: 4px 14px 16px; }
  .tl-inner > p { font-size: 15px; }
  .docs { grid-template-columns: 1fr; }
  .doc { min-height: 52px; }
}
@media (max-width: 360px) { .topnav ul a, .topnav .lock { padding: 0 6px; font-size: 13px; } }

/* site.css pins body to 100vh, which made the sticky nav scroll away after one screen. */
body.is-unlocked, body:has(> .topbar) { height: auto; min-height: 100vh; }
/* overflow:hidden on .timeline (site.css) silently disabled the sticky filter bar; clip keeps the reveal without that side effect. */
.timeline.ui-timeline { overflow: clip; display: flow-root; }

/* ---------- Round 3: brand, cards with covers, portfolio, 404 ---------- */
.topnav .brand { display: inline-flex; align-items: center; gap: 10px; }
.topnav .brand img { display: block; border-radius: 8px; transition: transform 0.25s var(--ui-ease); }
.topnav .brand:hover img { transform: rotate(-6deg) scale(1.04); }
.topnav .ico { flex: none; opacity: 0.7; }
.topnav ul a .ico { margin-left: 1px; }
.topnav .lock .ico { opacity: 0.85; }
@media (max-width: 640px) {
  .topnav .brand { display: inline-flex; }
  .topnav .brand span { display: none; }
  .topnav .brand img { width: 30px; height: 30px; }
  .topnav ul { justify-content: flex-end; gap: 2px; }
  .topnav .lock { width: 40px; padding: 0; justify-content: center; }
  .topnav .lock .lock-text { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
}
@media (max-width: 380px) { .topnav ul a .ico { display: none; } }

/* Typography rhythm for content pages */
.page-head { margin-bottom: 36px; }
.page-head h1 { letter-spacing: -0.8px; }
.section-title { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; margin: 52px 0 16px; }
.section-title .sub { font-size: 15px; font-weight: 500; color: var(--ui-muted); letter-spacing: 0; }
.section-title .count { font-size: 12.5px; font-weight: 600; color: var(--ui-muted); background: rgba(255, 255, 255, 0.07); border-radius: 999px; padding: 2px 9px; letter-spacing: 0; }
.page-head + .section-title { margin-top: 0; }
.hero-card { margin-top: 44px; }

/* Cards with a cover image */
.card { padding: 0; overflow: hidden; gap: 0; }
.card-body { padding: 18px 20px 20px; display: flex; flex-direction: column; gap: 10px; flex: 1; }
.cover { display: block; position: relative; aspect-ratio: 16 / 10; background: #f4f4f2; overflow: hidden; border-bottom: 1px solid var(--ui-line); }
.cover img { width: 100%; height: 100%; object-fit: cover; object-position: center; display: block; transition: transform 0.5s var(--ui-ease); }
.cover::after { content: ""; position: absolute; inset: 0; background: linear-gradient(transparent 60%, rgba(0, 0, 0, 0.18)); pointer-events: none; }
@media (hover: hover) { .card:hover .cover img { transform: scale(1.035); } }
.cover-empty {
  display: grid; place-items: center; background-color: #10161f;
  background-image: linear-gradient(rgba(61, 155, 255, 0.07) 1px, transparent 1px), linear-gradient(90deg, rgba(61, 155, 255, 0.07) 1px, transparent 1px);
  background-size: 22px 22px; background-position: -1px -1px;
}
.cover-empty::after { display: none; }
.cover-empty span { display: inline-flex; align-items: center; gap: 8px; color: #9fb8d6; font-size: 13.5px; font-weight: 500; padding: 8px 14px; border: 1px solid rgba(61, 155, 255, 0.25); border-radius: 999px; background: rgba(13, 13, 13, 0.6); }
.card .links a, .card .links span.locked { transition: background-color 0.15s, color 0.15s; }
.card .links a:focus-visible { outline: 2px solid var(--ui-accent); outline-offset: 2px; }

/* Compact academic cards */
.cards-compact { grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); }
.card-sm .cover { aspect-ratio: 4 / 3; }
.card-sm .card-body { padding: 14px 16px 16px; gap: 8px; }
.card-sm h3 { font-size: 16px; }
.card-sm p { font-size: 14px; }
@media (max-width: 520px) {
  .card-sm { flex-direction: row; }
  .card-sm .cover { flex: none; width: 112px; aspect-ratio: auto; border-bottom: 0; border-right: 1px solid var(--ui-line); }
  .card-sm .card-body { padding: 12px 14px; }
  .card-sm .facts { display: none; }
}

/* Footer */
.page-foot nav { display: flex; gap: 18px; flex-wrap: wrap; }

/* Portfolio: download + project mosaic */
.split { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 56px; align-items: center; }
.split .download-card { max-width: 520px; }
.mosaic { display: block; position: relative; text-decoration: none; border-radius: 18px; overflow: hidden; border: 1px solid var(--ui-line); background: var(--ui-surface); }
.mosaic ul { list-style: none; margin: 0; padding: 6px; display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.mosaic li { aspect-ratio: 1; border-radius: 10px; overflow: hidden; background: #f4f4f2; }
.mosaic img { width: 100%; height: 100%; object-fit: cover; object-position: center; display: block; transition: transform 0.5s var(--ui-ease); }
.mosaic:hover img { transform: scale(1.04); }
.mosaic-cta { position: absolute; left: 50%; bottom: 16px; transform: translateX(-50%); display: inline-flex; align-items: center; gap: 6px; white-space: nowrap;
  padding: 9px 16px; border-radius: 999px; background: rgba(13, 13, 13, 0.82); -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px); color: var(--ui-text); font-size: 14px; font-weight: 600; border: 1px solid var(--ui-line-strong); }
.mosaic:focus-visible { outline: 2px solid var(--ui-accent); outline-offset: 3px; }
@media (max-width: 820px) { .split { grid-template-columns: 1fr; gap: 32px; } }

/* 404 */
.nf { min-height: calc(100vh - 56px - 120px); display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; }
.nf-code { margin: 0; font-size: clamp(88px, 18vw, 160px); line-height: 1; font-weight: 800; letter-spacing: -4px;
  background: linear-gradient(180deg, #f0f0f0, rgba(240, 240, 240, 0.15)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.nf h1 { font-size: 26px; margin: 14px 0 8px; }
.nf p { color: var(--ui-muted); margin: 0 0 24px; }
.nf-actions { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }

.tl-heading { font-family: var(--ui-font); font-size: 12.5px; letter-spacing: 1px; text-transform: uppercase; color: var(--ui-accent); font-weight: 600; margin: 34px 0 0; text-align: left; }
.tl-heading + .tl-toolbar { margin-top: 0; }

/* ---------- Phase 3: landing ---------- */
body:not(.is-unlocked):not(:has(> .topbar)) {
  background:
    radial-gradient(900px 520px at 50% -10%, rgba(0, 116, 217, 0.10), transparent 70%),
    #0b0c0f;
  height: auto; min-height: 100vh; min-height: 100svh;
}
body:not(.is-unlocked) .container {
  min-height: 100vh; min-height: 100svh; display: flex; flex-direction: column; padding: 76px 20px 12px;
}
body:not(.is-unlocked) .intro { position: relative; margin: auto 0; padding: 0 0 6vh; gap: 0; }
body:not(.is-unlocked) .intro::before {
  content: ""; position: absolute; top: -90px; left: 50%; width: 340px; height: 340px; margin-left: -170px; border-radius: 50%;
  background: radial-gradient(circle, rgba(0, 116, 217, 0.22), rgba(0, 116, 217, 0.06) 45%, transparent 68%); pointer-events: none; z-index: -1;
}
body:not(.is-unlocked) .profile { width: 152px; height: 152px; }
body:not(.is-unlocked) #profileTitle {
  margin: 28px 0 0; font: 650 clamp(28px, 3.4vw, 36px)/1.15 var(--ui-font); letter-spacing: -0.025em; color: #f5f6f8;
}
.landing-tagline {
  margin: 10px 0 0; font: 500 13px/1.4 var(--ui-font); letter-spacing: 0.16em; text-transform: uppercase; color: #a3a8b0;
}
.landing-tagline span { color: #5c6370; margin: 0 0.35em; }
body.is-unlocked .landing-tagline { display: none; }
body:not(.is-unlocked) .password-container { margin-top: 34px; width: 100%; display: flex; flex-direction: column; align-items: center; }
body:not(.is-unlocked) .timeline-password {
  width: min(100%, 290px); max-width: 290px; height: 48px; padding: 0 46px; border-radius: 999px;
  font: 500 16px/1 'Roboto Mono', ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: 0.06em; color: #f5f6f8;
  background: rgba(255, 255, 255, 0.045) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238b9099' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='4' y='11' width='16' height='10' rx='2'/%3E%3Cpath d='M8 11V7a4 4 0 0 1 8 0v4'/%3E%3C/svg%3E") no-repeat 19px 50% / 15px 15px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05), 0 14px 34px -16px rgba(0, 0, 0, 0.8);
  transition: border-color 0.2s, box-shadow 0.2s, background-color 0.2s;
}
body:not(.is-unlocked) .timeline-password::placeholder { color: #80868f; letter-spacing: 0.04em; }
body:not(.is-unlocked) .timeline-password:hover { border-color: rgba(255, 255, 255, 0.22); background-color: rgba(255, 255, 255, 0.06); }
body:not(.is-unlocked) .timeline-password:focus {
  outline: none; border-color: rgba(61, 155, 255, 0.75); background-color: rgba(61, 155, 255, 0.06);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%233d9bff' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='4' y='11' width='16' height='10' rx='2'/%3E%3Cpath d='M8 11V7a4 4 0 0 1 8 0v4'/%3E%3C/svg%3E");
  box-shadow: 0 0 0 4px rgba(61, 155, 255, 0.16), 0 14px 34px -16px rgba(0, 116, 217, 0.6);
}
body:not(.is-unlocked) .password-status { margin-top: 12px; }
body:not(.is-unlocked) .password-status:empty { margin: 0; }
body:not(.is-unlocked) #expandAllButton { display: none; }
body:not(.is-unlocked) .timeline-wrapper { margin-top: 0; }
body:not(.is-unlocked) .contact-links { margin: 0; padding: 18px 0 calc(8px + env(safe-area-inset-bottom)); }
body:not(.is-unlocked) .contact-links .apple-id { font: 500 14px var(--ui-font); color: #a3a8b0; letter-spacing: 0.02em; opacity: 1; }
body:not(.is-unlocked) .contact-links .apple-id:hover { color: var(--ui-accent); }
body:not(.is-unlocked) .watermark:has(#timestamp:empty) { display: none; }
/* Public links, top right (they double as the skip-style site nav for keyboard users) */
body:not(.is-unlocked) .sr-nav { position: absolute; top: 18px; right: 22px; z-index: 10; display: flex; gap: 2px; font: 500 14px var(--ui-font); }
body:not(.is-unlocked) .sr-nav a {
  position: static; width: auto; height: auto; overflow: visible; padding: 8px 12px; border-radius: 8px; border: 0;
  color: #a3a8b0; text-decoration: none; background: none; transition: color 0.15s, background-color 0.15s;
}
body:not(.is-unlocked) .sr-nav a:hover { color: #fff; background: rgba(255, 255, 255, 0.06); }
body:not(.is-unlocked) .sr-nav a:focus-visible { outline: 2px solid var(--ui-accent); outline-offset: 2px; color: #fff; }
@media (max-width: 600px) {
  body:not(.is-unlocked) .sr-nav { left: 0; right: 0; top: 12px; justify-content: center; }
  body:not(.is-unlocked) .container { padding-top: 64px; }
  body:not(.is-unlocked) .profile { width: 140px; height: 140px; }
  .landing-tagline { font-size: 12px; letter-spacing: 0.06em; white-space: nowrap; }
  .landing-tagline span { margin: 0 0.25em; }
}
body:not(.is-unlocked) .sr-nav a { display: inline-flex; align-items: center; gap: 6px; }
body:not(.is-unlocked) .sr-nav .ico { opacity: 0.7; }

/* ---------- Theme: in-car touchscreen look ----------
   Near-black surfaces, flat rounded cards, muted grey secondary text, one blue accent for active
   states, pill / segmented controls, large tap targets, sheet-style viewers. */
:root {
  --ui-bg: #0f1012;
  --ui-surface: #1a1b1e;
  --ui-surface-2: #222327;
  --ui-line: rgba(255, 255, 255, 0.06);
  --ui-line-strong: rgba(255, 255, 255, 0.12);
  --ui-text: #ededee;
  --ui-muted: #9a9ca3;
  --ui-faint: #8a8c93;
  --ui-accent: #7d9df2;          /* accent for text on dark (AA) */
  --ui-accent-fill: #3e6ae1;     /* accent for filled active states (white text AA) */
  --ui-accent-soft: rgba(62, 106, 225, 0.16);
  --ui-radius: 16px;
  --ui-font: system-ui, -apple-system, "Inter", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
body.page, body.is-unlocked { background: var(--ui-bg); }
.ui, .topbar, .tl, .intro-card { letter-spacing: 0.005em; }

/* Top bar: flat, minimal, icon-forward */
.topbar { background: rgba(15, 16, 18, 0.88); border-bottom: 0; box-shadow: 0 1px 0 rgba(255, 255, 255, 0.04); }
.topnav { height: 60px; }
.topnav ul a, .topnav .lock { height: 40px; border-radius: 999px; padding: 0 14px; color: var(--ui-muted); }
.topnav ul a:hover, .topnav .lock:hover { background: var(--ui-surface-2); color: var(--ui-text); }
.topnav ul a[aria-current="page"] { background: var(--ui-surface-2); color: #fff; box-shadow: inset 0 -2px 0 var(--ui-accent-fill); }
.topnav .lock { border: 0; background: var(--ui-surface); width: 40px; padding: 0; justify-content: center; }
.topnav .lock .lock-text { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.topnav .brand img { border-radius: 10px; }
.tl-toolbar { top: 60px; }
@media (max-width: 640px) { .topnav { height: 56px; } .tl-toolbar { top: 56px; } }

/* Buttons */
.btn { min-height: 46px; border-radius: 12px; background: var(--ui-accent-fill); font-weight: 500; }
.btn:hover { background: #4a76ea; }
.btn-ghost { background: var(--ui-surface-2); border-color: transparent; color: var(--ui-text); }
.btn-ghost:hover { background: #2b2c31; border-color: transparent; }

/* Segmented controls: timeline filters and document tabs */
.tl-filters { background: var(--ui-surface); border-radius: 14px; padding: 4px; gap: 2px; flex: 0 1 auto; -webkit-mask-image: none; mask-image: none; }
.chip { height: 40px; padding: 0 16px; border: 0; border-radius: 10px; background: transparent; color: var(--ui-muted); font-weight: 500; transition: background-color 0.2s, color 0.2s; }
.chip:hover { color: var(--ui-text); background: var(--ui-surface-2); }
.chip[aria-pressed="true"] { background: var(--ui-accent-fill); color: #fff; }
.tl-expand-all { color: var(--ui-muted); background: var(--ui-surface); border-radius: 999px; padding: 0 16px; min-height: 40px; }
.tl-expand-all:hover { color: var(--ui-text); background: var(--ui-surface-2); text-decoration: none; }
.tl-toolbar { gap: 10px; }
.tab-list { display: inline-flex; gap: 2px; border: 0; background: var(--ui-surface-2); border-radius: 12px; padding: 4px; max-width: 100%; }
.tab { border: 0; margin: 0; border-radius: 9px; padding: 0 14px; min-height: 38px; }
.tab[aria-selected="true"] { background: #33353a; color: #fff; border: 0; }
.tab-count { background: rgba(255, 255, 255, 0.08); }

/* Timeline: flat cards, quiet rail, accent only when open */
.tl::before { background: rgba(255, 255, 255, 0.08); }
.tl-item::before { background: var(--ui-bg); border-color: #4a4c52; }
.tl-item.open::before { background: var(--ui-accent-fill); border-color: var(--ui-accent-fill); box-shadow: 0 0 0 4px var(--ui-accent-soft); }
.tl-item { margin-bottom: 12px; }
.tl-toggle { border: 0; background: var(--ui-surface); padding: 18px 20px; min-height: 64px; transition: background-color 0.2s; }
.tl-toggle:hover { background: var(--ui-surface-2); }
.tl-item.open .tl-toggle { background: var(--ui-surface); }
.tl-inner { background: var(--ui-surface); border-radius: 0 0 var(--ui-radius) var(--ui-radius); }
.tl-date { color: var(--ui-muted); font-weight: 500; letter-spacing: 0.08em; }
.tl-item.open .tl-date { color: var(--ui-accent); }
.tl-title { font-weight: 500; font-size: 17.5px; }
.tl-highlights li { background: var(--ui-surface-2); border: 0; border-radius: 12px; }
.tl-highlights h4 { color: var(--ui-text); font-weight: 500; }
.tl-heading { color: var(--ui-muted); font-weight: 500; letter-spacing: 0.12em; }
.gal { gap: 8px; }
.gal-item { border-radius: 12px; }
.doc { border: 0; background: var(--ui-surface-2); border-radius: 12px; min-height: 56px; }
.doc:hover { background: #2b2c31; border: 0; }
.doc-icon { background: rgba(255, 255, 255, 0.08); color: var(--ui-text); border-radius: 10px; }

/* Cards (projects) */
.card { border: 0; background: var(--ui-surface); border-radius: 18px; }
.card:hover { border: 0; background: var(--ui-surface-2); box-shadow: none; }
.cover { border-bottom: 0; }
.card h3 { font-weight: 500; }
.card .facts li { background: rgba(255, 255, 255, 0.06); color: #c9cbd0; }
.card .links a { background: var(--ui-accent-soft); color: var(--ui-accent); border-radius: 999px; padding: 9px 14px; }
.card .links a:hover { background: rgba(62, 106, 225, 0.28); }
.card .links .locked { border-radius: 999px; }
.section-title { font-weight: 500; }
.section-title .count { background: var(--ui-surface-2); color: var(--ui-muted); }
.page-head h1 { font-weight: 500; letter-spacing: -0.02em; }
.eyebrow, .page-head .eyebrow { color: var(--ui-muted); font-weight: 500; letter-spacing: 0.14em; font-size: 12.5px; }
.hero-card { background: var(--ui-surface); border: 0; border-radius: 20px; }
.download-card { background: var(--ui-surface); border: 0; border-radius: 20px; padding: 22px 24px; }
.download-card:hover { background: var(--ui-surface-2); border: 0; transform: none; }
.download-icon { color: var(--ui-text); background: var(--ui-surface-2); border-radius: 14px; }
.mosaic { border: 0; background: var(--ui-surface); border-radius: 20px; }
.mosaic-cta { background: rgba(15, 16, 18, 0.85); }
.page-foot { border-top-color: var(--ui-line); }
.intro-card strong { font-weight: 600; }

/* Viewers: bottom sheet */
.ov { inset: 2.5vh 0 0 0; border-radius: 22px 22px 0 0; background: #121315; box-shadow: 0 0 0 100vmax rgba(0, 0, 0, 0.62), 0 -12px 40px rgba(0, 0, 0, 0.5);
  transform: translateY(28px); transition: opacity 0.22s ease, transform 0.32s var(--ui-ease); }
.ov.in { transform: none; }
.ov::before { content: ""; position: absolute; top: 8px; left: 50%; width: 40px; height: 5px; margin-left: -20px; border-radius: 3px; background: rgba(255, 255, 255, 0.22); }
.ov-bar { padding-top: 18px; }
.ov-close, .ov-nav { width: 44px; height: 44px; background: var(--ui-surface-2); }
.ov-close:hover, .ov-nav:hover { background: #2f3035; }
.ov-link { color: var(--ui-accent); }
@media (prefers-reduced-motion: reduce) { .ov { transform: none; } }

/* Landing */
body:not(.is-unlocked):not(:has(> .topbar)) { background: radial-gradient(900px 520px at 50% -12%, rgba(62, 106, 225, 0.08), transparent 70%), #0b0c0d; }
body:not(.is-unlocked) #profileTitle { font-weight: 500; letter-spacing: -0.02em; }
.landing-tagline { color: var(--ui-muted); font-weight: 500; }
.landing-tagline span { color: #55575d; }
body:not(.is-unlocked) .timeline-password { background-color: var(--ui-surface); border-color: transparent; box-shadow: none; height: 52px; }
body:not(.is-unlocked) .timeline-password:hover { background-color: var(--ui-surface-2); border-color: transparent; }
body:not(.is-unlocked) .timeline-password:focus { background-color: var(--ui-surface-2); border-color: var(--ui-accent-fill); box-shadow: 0 0 0 4px var(--ui-accent-soft); }
body:not(.is-unlocked) .sr-nav a { border-radius: 999px; padding: 10px 14px; color: var(--ui-muted); }
body:not(.is-unlocked) .sr-nav a:hover { background: var(--ui-surface); color: #fff; }
body:not(.is-unlocked) .contact-links .apple-id { color: var(--ui-muted); }
body:not(.is-unlocked) .contact-links .apple-id:hover { color: var(--ui-text); }
body:not(.is-unlocked) .timeline-password { font: 500 16px/1 var(--ui-font); letter-spacing: 0.02em; }
body:not(.is-unlocked) .timeline-password::placeholder { letter-spacing: 0.01em; }
.cover-empty { background-color: #16171a; background-image: linear-gradient(rgba(255, 255, 255, 0.035) 1px, transparent 1px), linear-gradient(90deg, rgba(255, 255, 255, 0.035) 1px, transparent 1px); }
.cover-empty span { color: var(--ui-muted); border-color: var(--ui-line-strong); background: var(--ui-surface); }
