:root {
  --bg: #1b2845;
  --fg: #e5e7eb;
  --muted: #cbd5e1;
  --link: #93c5fd;
  --accent: #f1f5f9;
  --chip: #f8fafc;
  --chip-bg: rgba(255, 255, 255, 0.10);
  --chip-border: rgba(255, 255, 255, 0.25);
  --kbd-fg: #f1f5f9;
  --kbd-bg: rgba(255, 255, 255, 0.08);
  --kbd-border: rgba(255, 255, 255, 0.30);
  --terminal: #1f2937;
  --maxw: 900px;
  --border: rgba(255, 255, 255, 0.35);
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

html, body {
  margin: 0;
  padding: 0;
  color: var(--fg);
  font: 16px/1.6 Inter, system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial;
}

/* Totoro wallpaper — fixed full-page background, Safari-Start-Page style */
body {
  background-color: #1b2845;
  background-image: url("/assets/images/torro.jpg");
  background-size: cover;
  background-position: center top;
  background-attachment: fixed;
  background-repeat: no-repeat;
}

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

.wrap { max-width: var(--maxw); margin: 0 auto; padding: 24px 20px 80px; }

/* Header / nav */
header {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 6px 0 18px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: rgba(255, 255, 255, 0.8);
  backdrop-filter: saturate(120%) blur(8px);
  z-index: 10;
}

.avatar {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  object-fit: cover;
  border: 1px solid var(--border);
}

.title { display: flex; flex-direction: column; }
.title h1 { font: 700 20px/1.2 Inter; margin: 0; }
.title .sub {
  font: 500 12px/1.3 var(--mono);
  color: var(--muted);
  letter-spacing: -0.01em;
}

/* Mono nav for that terminal-y feel */
nav a {
  font-family: var(--mono);
  font-size: 13px;
  letter-spacing: -0.01em;
}

nav {
  margin-left: auto;
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
}
nav a { font-weight: 600; color: var(--accent); }
nav a.active { color: var(--link); }

main { margin-top: 22px; }
h2 { font: 700 22px/1.2 Inter; margin: 0 0 18px; color: #f8fafc; }
h3 { font: 600 16px/1.25 Inter; margin: 14px 0 6px; color: #f1f5f9; }

p, li { color: #e5e7eb; }
strong { color: #ffffff; }
a { color: #93c5fd; }
a:hover { color: #bfdbfe; }

.muted { color: #cbd5e1; }
.lead { font: 400 18px/1.7 "PT Serif", Georgia, serif; color: #f1f5f9; }

/* Page-level headings sit directly on the wallpaper — give them contrast */
main > h2,
main > p {
  color: #f1f5f9;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.6);
}
main > p.muted {
  color: #cbd5e1;
}

ul.clean { list-style: none; padding: 0; margin: 0; }
ul.clean li {
  padding: 6px 0;
  border-bottom: 1px dashed rgba(255, 255, 255, 0.18);
  color: #e5e7eb;
}
ul.clean li:last-child { border-bottom: 0; }

footer {
  margin-top: 36px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 13px;
}

/* Home page two-column */
.home {
  display: grid;
  grid-template-columns: 1fr;
  gap: 28px;
  margin-top: 22px;
}
@media (min-width: 980px) {
  .home { grid-template-columns: 1.1fr .9fr; align-items: start; }
}

.card {
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: 12px;
  padding: 18px;
  background: rgba(255, 255, 255, 0.06);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  color: #e5e7eb;
}
.card h2 { font: 700 18px/1.2 Inter; margin: 0 0 8px; color: #ffffff; }
.card h3 { color: #f1f5f9; }
.card p, .card li { color: #e5e7eb; }

.news-year { font-weight: 700; margin-top: 14px; color: #ffffff; }
.news-list { margin: 8px 0 0 0; padding: 0 0 0 16px; }
.news-list li { margin: 4px 0; color: #e5e7eb; }

/* Card grids — projects, courses, hobbies */
.tile-grid {
  display: grid;
  gap: 20px;
  grid-template-columns: 1fr;
}
@media (min-width: 700px) {
  .tile-grid { grid-template-columns: 1fr 1fr; }
}

.tile {
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: 16px;
  padding: 18px;
  background: rgba(255, 255, 255, 0.06);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  color: #e5e7eb;
  transition: box-shadow 0.2s ease, transform 0.2s ease, border-color 0.2s ease;
}
.tile:hover {
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.35);
  border-color: rgba(255, 255, 255, 0.6);
  transform: translateY(-2px);
}
.tile-title { color: #ffffff; }
.tile-desc, .tile p { color: #e5e7eb; }
.tile a { color: #93c5fd; }
.tile-img {
  width: 100%;
  max-height: 160px;
  object-fit: cover;
  border-radius: 12px;
  margin-bottom: 10px;
}
.tile-icon { font-size: 26px; margin-bottom: 6px; }
.tile-title { font: 600 17px/1.3 Inter; margin: 0 0 6px; }
.tile-desc { margin: 0 0 8px; font-size: 15px; }
.tile-meta {
  color: var(--muted);
  font-size: 13px;
  font-family: var(--mono);
  letter-spacing: -0.01em;
}

/* Work card variant — full-width image header */
.work-grid {
  display: grid;
  gap: 24px;
  grid-template-columns: 1fr;
}
@media (min-width: 750px) {
  .work-grid { grid-template-columns: 1fr 1fr; }
}

.work-card {
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: 16px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.06);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  color: #e5e7eb;
  transition: box-shadow 0.2s ease, transform 0.2s ease, border-color 0.2s ease;
  display: flex;
  flex-direction: column;
}
.work-card:hover {
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.35);
  border-color: rgba(255, 255, 255, 0.6);
  transform: translateY(-2px);
}
.work-card .work-title { color: #ffffff; }
.work-card .work-role { color: #cbd5e1; }
.work-card .work-desc { color: #e5e7eb; }
.work-card .work-desc a { color: #93c5fd; }
.work-card .work-link a { color: #bae6fd; }
.work-img { width: 100%; height: 150px; object-fit: cover; }
.work-content { padding: 16px; display: flex; flex-direction: column; }
.work-title { font: 600 17px/1.3 Inter; margin: 0 0 4px; }
.work-role { font-size: 15px; margin: 0 0 10px; color: var(--accent); }
.work-desc { flex-grow: 1; font-size: 15px; margin: 0 0 10px; }
.work-meta {
  font-size: 13px;
  color: var(--muted);
  font-family: var(--mono);
  letter-spacing: -0.01em;
}

/* Date pill next to the work title — stays on the right on wide cards */
.work-dates {
  float: right;
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 500;
  color: #cbd5e1;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 4px;
  padding: 1px 8px;
  margin-left: 6px;
  margin-top: 2px;
  letter-spacing: -0.01em;
  white-space: nowrap;
}

/* Inline "View project →" link in a work card */
.work-link {
  font-family: var(--mono);
  font-size: 13px;
  margin: 0 0 10px;
  letter-spacing: -0.01em;
}

/* Home page — Safari Start Page mode: full-viewport, perfectly centered, no header */
html, body { height: 100%; }
body.page-home .wrap {
  min-height: 100vh;
  width: 100%;
  max-width: none;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
  margin: 0;
  box-sizing: border-box;
}
body.page-home main {
  margin: 0;
  width: 100%;
  max-width: 760px;
  display: flex;
  align-items: center;
  justify-content: center;
}
body.page-home .favorites { margin: 0; width: 100%; }
.home-favorites .favorites-grid {
  justify-content: center;
}
.home-favorites .favorites-title {
  text-align: center;
  padding-left: 0;
}

/* Floating browser-style back / forward / home buttons (non-home pages) */
.histbar {
  position: fixed;
  top: 18px;
  left: 18px;
  z-index: 50;
  display: flex;
  gap: 8px;
}
.histbtn {
  width: 38px;
  height: 38px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.45);
  border: 1px solid rgba(255, 255, 255, 0.30);
  color: #f1f5f9;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.15s ease;
  text-decoration: none;
  padding: 0;
}
.histbtn:hover {
  background: rgba(0, 0, 0, 0.65);
  border-color: rgba(255, 255, 255, 0.55);
  transform: translateY(-1px);
  text-decoration: none;
}
.histbtn:active { transform: translateY(0); }
.histbtn svg { display: block; }

/* About page — avatar header (replaces the missing top nav avatar) */
.about-header {
  display: flex;
  align-items: center;
  gap: 18px;
  margin: 8px 0 22px;
}
.about-avatar {
  width: 84px;
  height: 84px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid rgba(255, 255, 255, 0.35);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
}
.about-id h1 {
  font: 700 24px/1.2 Inter;
  margin: 0 0 4px;
  color: #ffffff;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
}
.about-id .about-sub {
  font: 500 13px/1.3 var(--mono);
  margin: 0;
  color: #cbd5e1;
  letter-spacing: -0.01em;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
}

/* Safari-Start-Page-style "Favorites" launcher */
.favorites {
  margin: 24px 0 8px;
}
.favorites-title {
  font: 600 14px/1.2 var(--mono);
  color: #f1f5f9;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  margin: 0 0 12px;
  padding-left: 4px;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
}
.favorites-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 18px;
  padding: 4px;
}
.fav {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  text-decoration: none;
  color: var(--accent);
  width: 76px;
}
.fav:hover { text-decoration: none; }
.fav-icon {
  width: 64px;
  height: 64px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--mono);
  font-weight: 700;
  font-size: 18px;
  letter-spacing: -0.02em;
  background: var(--kbd-bg);
  border: 1px solid rgba(0, 0, 0, 0.04);
  box-shadow:
    0 1px 2px rgba(0, 0, 0, 0.05),
    inset 0 1px 0 rgba(255, 255, 255, 0.4);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.fav:hover .fav-icon {
  transform: translateY(-3px);
  box-shadow:
    0 6px 14px rgba(0, 0, 0, 0.12),
    inset 0 1px 0 rgba(255, 255, 255, 0.5);
}
.fav-label {
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: -0.01em;
  color: #f1f5f9;
  text-align: center;
  line-height: 1.2;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.6);
}
@media (max-width: 600px) {
  .favorites-grid { gap: 14px; justify-content: flex-start; }
  .fav { width: 68px; }
  .fav-icon { width: 56px; height: 56px; border-radius: 12px; font-size: 16px; }
}

/* Hero banner — Bay Area photo across the top of the home page */
.hero-banner {
  position: relative;
  margin-top: 16px;
  height: 220px;
  border-radius: 14px;
  overflow: hidden;
  background-image: url("/assets/images/hero_bg.jpg");
  background-size: cover;
  background-position: center 35%;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}
.hero-banner__overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg,
    rgba(11, 15, 20, 0.0) 0%,
    rgba(11, 15, 20, 0.10) 55%,
    rgba(11, 15, 20, 0.55) 100%);
  display: flex;
  align-items: flex-end;
  padding: 16px 22px;
}
.hero-banner__tag {
  font-family: var(--mono);
  font-size: 13px;
  letter-spacing: 0.02em;
  color: #ffffff;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}

/* Lead figure for project pages — a single hero photo above the body.
   Sized to FIT (not crop) and capped so it never towers over the screen. */
.lead-figure {
  margin: 18px auto 4px;
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  background: #0b0d10;
  max-width: 720px;
}
.lead-figure img {
  display: block;
  width: 100%;
  height: auto;
  max-height: 320px;
  object-fit: contain;
  margin: 0 auto;
}
.lead-figure figcaption {
  font-family: var(--mono);
  font-size: 13px;
  color: var(--muted);
  padding: 10px 14px;
  background: #f9fafb;
  letter-spacing: -0.01em;
}

/* Embedded interactive diagrams (DiabloAvionics overview, etc.) */
.iframe-wrap {
  margin: 14px 0 6px;
}
.iframe-wrap iframe { display: block; }

.detail pre {
  font-family: var(--mono);
  font-size: 12.5px;
  line-height: 1.55;
  background: #0f172a;
  color: #e2e8f0;
  padding: 14px 16px;
  border-radius: 8px;
  overflow-x: auto;
  margin: 10px 0;
}
.detail pre code {
  background: transparent;
  border: 0;
  padding: 0;
  color: inherit;
}

/* Inline code-ish elements: chip names, course numbers, paths */
code {
  font-family: var(--mono);
  font-size: 0.92em;
  background: rgba(255, 255, 255, 0.10);
  color: #f8fafc;
  padding: 1px 6px;
  border-radius: 4px;
  border: 1px solid rgba(255, 255, 255, 0.25);
}

/* Quick-fact pills (Quick facts section on home) */
.kbd {
  display: inline-block;
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 600;
  color: #f1f5f9;
  background: rgba(255, 255, 255, 0.10);
  border: 1px solid rgba(255, 255, 255, 0.30);
  border-radius: 4px;
  padding: 1px 6px;
  margin-right: 4px;
  letter-spacing: -0.01em;
}

/* Small "current"/"co-lead" badge on work cards and project tiles */
.badge {
  display: inline-block;
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 600;
  color: #0f5132;
  background: #d1e7dd;
  border: 1px solid #badbcc;
  padding: 1px 6px;
  border-radius: 999px;
  vertical-align: 1px;
  margin-left: 6px;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

/* Terminal prompt above hero */
.prompt {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 6px;
  letter-spacing: -0.01em;
}
.prompt::before { content: ""; }

/* model-viewer: wrapper + fallback poster */
.model-wrap {
  margin: 14px 0 6px;
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  background: #101418;
}
model-viewer {
  width: 100%;
  display: block;
}
.model-fallback {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  font-family: var(--mono);
  color: #9ca3af;
  font-size: 14px;
}
.model-links {
  list-style: none;
  padding: 0;
  margin: 6px 0 0;
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  font-family: var(--mono);
  font-size: 13px;
}
.model-links a::before { content: "↓ "; color: var(--muted); }

/* Hero banner — Bay Area photo across the top of the home page */
.hero-banner {
  position: relative;
  margin-top: 16px;
  height: 220px;
  border-radius: 14px;
  overflow: hidden;
  background-image: url("/assets/images/hero_bg.jpg");
  background-size: cover;
  background-position: center 35%;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}
.hero-banner__overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg,
    rgba(11, 15, 20, 0.0) 0%,
    rgba(11, 15, 20, 0.10) 55%,
    rgba(11, 15, 20, 0.55) 100%);
  display: flex;
  align-items: flex-end;
  padding: 16px 22px;
}
.hero-banner__tag {
  font-family: var(--mono);
  font-size: 13px;
  letter-spacing: 0.02em;
  color: #ffffff;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}

/* Lead figure for project pages — a single hero photo above the body */
.lead-figure {
  margin: 18px 0 4px;
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  background: #0b0d10;
}
.lead-figure img {
  display: block;
  width: 100%;
  max-height: 380px;
  object-fit: cover;
}
.lead-figure figcaption {
  font-family: var(--mono);
  font-size: 13px;
  color: var(--muted);
  padding: 10px 14px;
  background: #f9fafb;
  letter-spacing: -0.01em;
}

/* Detail-page (BOEM, STAR, ...) section spacing */
.detail {
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: 16px;
  padding: 22px 26px 28px;
  background: rgba(255, 255, 255, 0.05);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  color: #e5e7eb;
  margin-top: 4px;
}
.detail .back { display: inline-block; margin-bottom: 8px; color: #bae6fd; }
.detail h1 { font-size: 28px; margin: 8px 0 6px; color: #ffffff; }
.detail h2 { font-size: 22px; margin-top: 28px; color: #ffffff; }
.detail h3 { color: #f1f5f9; }
.detail p, .detail li { color: #e5e7eb; }
.detail strong { color: #ffffff; }
.detail .meta { color: #cbd5e1; margin: 0 0 18px; }
.detail .muted { color: #cbd5e1; }
.detail section { margin-top: 20px; }
.detail a { color: #93c5fd; }

/* Schematic figures (Flipper-style) */
.schematic {
  margin: 18px 0 28px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fafafa;
  transition: box-shadow 0.2s ease;
}
.schematic:hover {
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.06);
}
.schematic a { display: block; }
.schematic img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 8px;
  background: #fff;
  border: 1px solid #eee;
}
.schematic figcaption {
  margin-top: 10px;
  font-size: 14px;
  color: var(--muted);
  font-style: italic;
}
