:root {
  --bg: #ffffff;
  --fg: #131313;
  --muted: #666;
  --link: #0b57d0;
  --accent: #1f2328;
  --card: #f7f7f8;
  --border: #e6e6e7;
  --shadow: 0 10px 25px rgba(0,0,0,.05);
  --radius: 18px;
  --radius-lg: 24px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0c0c0c;
    --fg: #e9e9ea;
    --muted: #a2a2a2;
    --link: #8ab4f8;
    --accent: #fafafa;
    --card: #141414;
    --border: #242424;
    --shadow: 0 10px 25px rgba(0,0,0,.35);
  }
}
/* Explicit theme overrides (take precedence over auto) */
html[data-theme="light"] {
  --bg: #ffffff;
  --fg: #131313;
  --muted: #666;
  --link: #0b57d0;
  --accent: #1f2328;
  --card: #f7f7f8;
  --border: #e6e6e7;
  --shadow: 0 10px 25px rgba(0,0,0,.05);
}
html[data-theme="dark"] {
  --bg: #0c0c0c;
  --fg: #e9e9ea;
  --muted: #a2a2a2;
  --link: #8ab4f8;
  --accent: #fafafa;
  --card: #141414;
  --border: #242424;
  --shadow: 0 10px 25px rgba(0,0,0,.35);
}
* { box-sizing: border-box; }
html, body { margin:0; padding:0; }
body {
  font: 16px/1.75 system-ui, -apple-system, "Segoe UI", Roboto, Ubuntu, "Helvetica Neue", Arial, "Noto Sans", "Apple Color Emoji", "Segoe UI Emoji";
  color: var(--fg);
  background: radial-gradient(1200px 1200px at 20% -10%, rgba(11,87,208,.06), transparent 40%), var(--bg);
}
body, section, nav a, .toggle, .project-card, .project-media, .pill, .flip-card, .flip-card-front, .flip-card-back {
  transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease;
}
.wrap { max-width: 980px; margin: 0 auto; padding: 0 1rem; }
h1 { font-size: 2rem; margin: 0 0 .25rem; color: var(--accent); }
.tagline { color: var(--muted); margin: 0.25rem 0 0.75rem; }
.contact a { color: var(--link); text-decoration: none; }
.contact a:hover { text-decoration: underline; }
.toolbar { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.toggle { border:1px solid var(--border); background: var(--card); color: var(--fg); padding:.55rem .9rem; border-radius:var(--radius); cursor:pointer; box-shadow: var(--shadow); }
.site-nav {
  position: sticky;
  top: env(safe-area-inset-top, 0px);
  z-index: 999;
  display:flex;
  flex-wrap: wrap;
  align-items: center;
  gap:.6rem;
  margin: 1.25rem 0 2rem;
  padding: .5rem .75rem;
  background: var(--bg);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
}
.site-nav a {
  position: relative;
  padding:.45rem .75rem;
  border: 1px solid transparent;
  border-radius: var(--radius);
  text-decoration:none;
  color: var(--fg);
  background: transparent;
  box-shadow: none;
  font-weight: 600;
}
.site-nav a:not(.nav-logo):hover,
.site-nav a:not(.nav-logo):focus-visible {
  border-color: var(--border);
  background: var(--card);
  box-shadow: var(--shadow);
}
.site-nav .nav-logo {
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
  display: flex;
  align-items: center;
}
.site-nav .nav-logo img {
  height: 2rem;
  width: auto;
  display: block;
}
section {
  margin: 2rem 0;
  background: var(--card);
  padding: 1.25rem;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  scroll-margin-top: 6.5rem;
}
h2.project-hero__title { margin: 0; }
h2 { margin-top: 0; font-size: 1.4rem; }
h3 { margin-bottom: .25rem; font-size: 1.1rem; }
.two-col { display:grid; grid-template-columns: 1fr; gap: 1rem; }
@media (min-width: 800px) { .two-col { grid-template-columns: 1fr 1fr; } }
.pill { display:inline-block; padding:.25rem .55rem; border:1px solid var(--border); border-radius: 999px; margin:.15rem .25rem 0 0; font-size:.9rem; background: var(--bg); }
.pubs li { margin-bottom: .6rem; }
.agent-list { display: flex; flex-direction: column; gap: 0; margin-top: 1rem; }
.agent-item {
  border-bottom: 1px solid var(--border);
  padding: .15rem 0;
}
.agent-item:first-child { border-top: 1px solid var(--border); }
.agent-item > summary {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: .35rem .75rem;
  cursor: pointer;
  list-style: none;
  padding: .7rem .35rem;
  border-radius: var(--radius);
}
.agent-item > summary::-webkit-details-marker { display: none; }
.agent-item > summary::before {
  content: "▸";
  color: var(--muted);
  font-size: .85rem;
  width: 1rem;
  flex: 0 0 auto;
  transition: transform .15s ease;
}
.agent-item[open] > summary::before { transform: rotate(90deg); }
.agent-item > summary:hover { background: var(--bg); }
.agent-name {
  font-weight: 700;
  text-decoration: none;
  color: var(--link);
  flex: 0 0 auto;
}
.agent-name:hover { text-decoration: underline; }
.agent-pitch { color: var(--muted); font-size: .95rem; flex: 1 1 12rem; }
.agent-body {
  padding: 0 .35rem .9rem 1.7rem;
}
.agent-item[open] > .agent-body {
  display: flex;
  flex-direction: column;
  gap: .65rem;
}
.agent-body > p { margin: 0; }
.agent-highlights { display: flex; flex-wrap: wrap; gap: .2rem; margin: 0; }
.agent-highlights .pill {
  margin: 0;
  font-size: .8rem;
  font-weight: 600;
  letter-spacing: .01em;
  color: var(--fg);
  background: var(--card);
  border-color: var(--border);
}
.agent-install {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .5rem;
  padding: .55rem .7rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: .9rem;
}
.agent-install code { flex: 1 1 auto; word-break: break-all; }
.agent-copy { flex: 0 0 auto; }
footer { margin-top: 3rem; color: var(--muted); font-size: .9rem; }
a { color: var(--link); }
.meta { color: var(--muted); font-size: .95rem; }
/* Project card layout */
.projects-grid { display: grid; grid-template-columns: 1fr; gap: 1.5rem; overflow: visible; }
@media (min-width: 800px) { 
  .projects-grid { grid-template-columns: 1fr 1fr; }
}
.project-card--wide { grid-column: 1 / -1; }

/* Inline diagrams (SVG) */
.diagram-card {
  margin: 1.25rem 0;
  padding: 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--bg);
  overflow: hidden; /* prevents tiny overflow on mobile */
}
.diagram-card h3 { margin-top: 0; }
.diagram-card svg { width: 100%; height: auto; display: block; }
@media (max-width: 640px) {
  .diagram-card { padding: .85rem; }
}
.embed-frame {
  width: 100%;
  aspect-ratio: 16 / 9;
  height: auto;
  border: 0;
  border-radius: var(--radius);
  display: block;
}
.projects-grid--minor {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
  margin-top: 1.25rem; /* extra vertical space from major to minor */
}
@media (min-width: 800px) {
  .projects-grid--minor {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

/* 4x4 project grid: one 2x2 (regular) + four 1x1 (minor) fill the space */
.projects-grid--4x4 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}
@media (min-width: 800px) {
  .projects-grid--4x4 {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}
.project-card--2x2 {
  grid-column: span 2;
  grid-row: span 2;
}
@media (min-width: 800px) {
  .projects-grid--4x4 .project-card--2x2 {
    grid-column: span 2;
    grid-row: span 2;
  }
}
/* Extra spacing between minor projects grid and the flip-game card */
#flip-game { margin-top: 1.25rem; }
@media (min-width: 800px) { #flip-game { margin-top: 1.5rem; } }
.project-card { 
  display:grid; 
  grid-template-columns: 1fr; 
  gap: .6rem; 
  padding: 1rem; 
  border:1px solid var(--border); 
  border-radius: var(--radius-lg); 
  background: var(--bg);
  transition: transform 0.3s ease, box-shadow 0.3s ease;
  position: relative;
}
/* Tighten spacing between title and summary inside project cards */
.project-card h3 { margin: 0; font-size: .95rem; font-weight: 700; }
.project-card .meta { margin: 0; }
.project-card:not(#flip-game):hover {
  transform: scale(1.05);
  box-shadow: 0 15px 35px rgba(0,0,0,.15);
  z-index: 1;
}
@media (prefers-color-scheme: dark) {
  .project-card:not(#flip-game):hover {
    box-shadow: 0 15px 35px rgba(0,0,0,.5);
  }
}
.project-card > * { min-width: 0; }
.project-media { width: 100%; max-width: 100%; aspect-ratio: 16/9; border-radius: var(--radius-lg); background: linear-gradient(135deg, var(--card), transparent); border:1px dashed var(--border); display:flex; align-items:center; justify-content:center; color: var(--muted); font-size:.95rem; overflow: hidden; overflow-wrap: anywhere; margin-bottom: 1rem; }
.project-media img, .project-media video { width: 100%; height: 100%; object-fit: cover; display: block; }
.project-media a { display: contents; }
.project-card .card-cover { position: absolute; inset: 0; z-index: 2; border-radius: var(--radius-lg); }
.project-card .card-cover:focus-visible { outline: 2px solid currentColor; outline-offset: 2px; }
section.project-hero {
  margin: 2rem 0 1.5rem;
  padding: 0;
  background: none;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  position: relative;
  min-height: 260px;
  overflow: hidden;
  display: flex;
  align-items: flex-end;
  background-size: cover;
  background-position: center;
}
section.project-hero::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(0, 0, 0, 0.2) 0%, rgba(0, 0, 0, 0.55) 100%);
  pointer-events: none;
}
.project-hero__content {
  position: relative;
  margin: 2.25rem;
  max-width: min(540px, 100%);
  z-index: 1;
}
.project-hero__title {
  display: inline-block;
  padding: .5rem 1rem;
  border-radius: var(--radius-lg);
  background: rgba(255, 255, 255, 0.88);
  color: #111111;
  font-size: clamp(1.75rem, 2vw + 1rem, 2.4rem);
  line-height: 1.2;
  box-shadow: 0 12px 24px rgba(0, 0, 0, 0.22);
  backdrop-filter: blur(6px);
}
.project-hero__meta {
  margin-top: 1.25rem;
  display: flex;
  flex-wrap: wrap;
  gap: .6rem 1rem;
}
.project-hero__meta-item {
  padding: .4rem .85rem;
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.82);
  color: #111111;
  font-size: .95rem;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.16);
  backdrop-filter: blur(6px);
}
.project-hero__meta-item strong {
  font-weight: 600;
  margin-right: .35rem;
}
@media (max-width: 640px) {
  .project-hero__content {
    margin: 1.75rem;
  }
  .project-hero__meta {
    flex-direction: column;
    gap: .5rem;
  }
  .project-hero__meta-item {
    width: fit-content;
  }
}
section.project-body {
  margin-top: 0;
}
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
/* Image spans full width at all sizes; content follows below */

/* Details toggle styling */
details { margin-top: .5rem; }
details > summary { cursor: pointer; color: var(--link); font-weight: 600; }
details > summary::-webkit-details-marker { display: none; }


/* Flip card minigame - granular columns so portrait doesn’t get larger cards than landscape */
.flip-ui { display: flex; align-items: center; justify-content: space-between; gap: .75rem; }
.flip-stats { display: flex; gap: 1rem; color: var(--muted); }
.flip-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: .6rem;
}
@media (min-width: 360px) {
  .flip-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (min-width: 560px) {
  .flip-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
@media (min-width: 768px) {
  .flip-grid { grid-template-columns: repeat(6, minmax(0, 1fr)); }
}
@media (min-width: 1024px) {
  .flip-grid { grid-template-columns: repeat(8, minmax(0, 1fr)); }
}

.flip-card { position: relative; width: 100%; aspect-ratio: 1 / 1; border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--card); padding: 0; cursor: pointer; box-shadow: var(--shadow); -webkit-tap-highlight-color: transparent; }
.flip-card:disabled { cursor: default; opacity: .9; }
.flip-card { appearance: none; border: 1px solid var(--border); }
.flip-card-inner { position: absolute; inset: 0; border-radius: inherit; transform-style: preserve-3d; transition: transform .45s ease; }
.flip-card.is-flipped .flip-card-inner, .flip-card.is-matched .flip-card-inner { transform: rotateY(180deg); }
.flip-card-front, .flip-card-back { position: absolute; inset: 0; border-radius: inherit; backface-visibility: hidden; overflow: hidden; display: flex; align-items: center; justify-content: center; }
.flip-card-front { background: linear-gradient(135deg, var(--card), transparent); border: 1px dashed var(--border); color: var(--muted); font-weight: 600; }
.flip-card-back { transform: rotateY(180deg); background: var(--bg); }
.flip-card-back img { width: 100%; height: 100%; object-fit: cover; display: block; }
.flip-message { margin-top: .5rem; color: var(--accent); font-weight: 600; }

/*
#wc-container { width: 720px !important; min-width: 720px !important; }
#wc-container { height: 720px !important; min-height: 720px !important; }
#wc-container > svg { width: 100% !important; height: 100% !important; display: block; } */

/* ---------- Persona 3 style landing menu ---------- */
.p3-root {
  position: relative;
  width: 100%;
  min-height: 100svh;
  background: #04060f;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Bebas Neue', 'Oswald', 'Arial Narrow', sans-serif;
}
.p3-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  pointer-events: none;
  display: block;
}
.p3-menu {
  position: relative;
  z-index: 20;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  max-width: 100%;
  padding: 16px 32px;
  /* Compact - rows can visually overlap via their inner .p3-rot transforms
     without affecting their axis-aligned hit areas. */
  gap: 2px;
}

/* .p3-row is the INTERACTION box. It stays axis-aligned (no transform) so
   its hit area is a simple rectangle that never overlaps neighbors. */
.p3-row {
  position: relative;
  cursor: pointer;
  display: block;
  text-decoration: none;
  line-height: 1;
  padding: 1px 40px 1px 12px;
}

/* .p3-rot is the VISUAL layer. The tilt and translateY shift live here so
   the row's hit area stays clean while the label + SVG composition can lean
   and drift freely. pointer-events: none makes the visual subtree invisible
   to hit-testing - events land on the <a> parent. */
.p3-rot {
  --tilt: 0deg;
  --shift: 0px;
  position: relative;
  display: flex;
  align-items: center;
  opacity: 0;
  transform: translate(-36px, var(--shift)) rotate(var(--tilt));
  transform-origin: center center;
  transition: opacity 0.38s ease, transform 0.38s cubic-bezier(0.22,1,0.36,1);
  pointer-events: none;
}
.p3-row.mounted .p3-rot {
  opacity: 1;
  transform: translate(0, var(--shift)) rotate(var(--tilt));
}

/* The old CSS wedge pseudo-element approach was replaced by an SVG composition
   (see .p3-hero below). Keep the wrapper element as a no-op so existing JS can
   still reference it without layout effects. */
.p3-highlight { display: none; }

/* SVG-based highlighted-item composition. One .p3-hero per row, positioned
   absolutely over the label and sized via inline style from the JS builder.
   Contains: shadow text, top red wedge, bottom pink wedge, dark base text, and
   a bright text layer clipped to the top wedge so the letters read brighter
   where the banner covers them and darker where it doesn't. */
.p3-hero {
  position: absolute;
  top: 50%;
  left: 0;
  transform: translate(0, -50%);
  opacity: 0;
  transition: opacity 0.22s ease;
  z-index: 2;
  /* Pointer events are nailed off on the whole SVG subtree so the banner
     never steals hovers from adjacent rows. Only the parent <a> handles hits. */
  pointer-events: none;
}
.p3-hero, .p3-hero * { pointer-events: none; }
.p3-label { pointer-events: none; }
/* Active row floats above neighbors so its SVG, which extends past the row
   box, can't visually or behaviorally interfere with the stack. */
.p3-row.active { z-index: 5; }
.p3-row.active .p3-hero { opacity: 1; }
.p3-row.active .p3-label { visibility: hidden; }

.p3-hero-svg {
  display: block;
  overflow: visible;
  width: 100%;
  height: 100%;
  pointer-events: none;
}
.p3-hero-text {
  font-family: 'Bebas Neue', 'Oswald', 'Arial Narrow', sans-serif;
  font-weight: 400;
  letter-spacing: 2px;
  text-rendering: geometricPrecision;
}
.p3-hero-shadow  { fill: #060206; opacity: 0.55; }
.p3-hero-dark    { fill: #8a1427; }
.p3-hero-bright  { fill: #ffffff; }
.p3-hero-wedge-top    { fill: #c4001a; filter: drop-shadow(0 8px 22px rgba(196, 0, 26, 0.35)); }
.p3-hero-wedge-bottom { fill: #f38493; }

.p3-label {
  font-family: 'Bebas Neue', 'Oswald', 'Arial Narrow', sans-serif;
  display: block;
  color: #2a5ca8;
  letter-spacing: 2px;
  line-height: 0.85;
  position: relative;
  z-index: 1;
  opacity: var(--p3-idle-opacity, 1);
  transition: color 0.12s ease, opacity 0.12s ease, transform 0.18s ease;
  font-weight: 400;
  text-shadow: 0 2px 14px rgba(0,0,0,0.35);
}
/* Hover / keyboard-focus / keyboard-active all share the same label treatment. */
.p3-row:hover .p3-label,
.p3-row:focus-visible .p3-label,
.p3-row.active .p3-label {
  color: #ffffff;
  opacity: 1;
  transform: translateX(6px);
}

.p3-hint {
  position: absolute;
  bottom: 24px; right: 28px;
  z-index: 20;
  display: flex; flex-direction: column;
  align-items: flex-end; gap: 5px;
  font-family: 'Bebas Neue', 'Oswald', 'Arial Narrow', sans-serif;
  opacity: 0;
  transition: opacity 0.5s ease 0.9s;
}
.p3-hint.mounted { opacity: 1; }
.p3-hint-row {
  display: flex; align-items: center; gap: 8px;
  font-size: 13px; letter-spacing: 2px;
  color: rgba(255,255,255,0.35);
}
.p3-hint-key {
  border: 1px solid rgba(255,255,255,0.25);
  border-radius: 3px;
  padding: 1px 7px; font-size: 12px;
  color: rgba(255,255,255,0.6);
  background: rgba(0,0,0,0.25);
}

/* Responsive scaling - label font-size set inline via JS is treated as px base;
   we scale it down on narrow viewports using transform-origin on the menu. */
@media (max-width: 760px) {
  .p3-menu { padding: 24px; transform: scale(0.72); transform-origin: center center; }
}
@media (max-width: 480px) {
  .p3-menu { transform: scale(0.52); }
}

/* Branding plate - shared between landing page (.p3-root) and sub-page headers
   (.page-head). Base rules cover layout + typography; the landing-only rules
   below add absolute positioning, white-on-dark coloring, and fade-in. */
.p3-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}
.p3-brand img {
  height: 36px;
  width: auto;
}
.p3-brand-name {
  font-family: 'Bebas Neue', 'Oswald', 'Arial Narrow', sans-serif;
  font-size: 22px;
  letter-spacing: 3px;
  line-height: 1;
}
.p3-brand-sub {
  font-family: 'Bebas Neue', 'Oswald', 'Arial Narrow', sans-serif;
  font-size: 12px;
  letter-spacing: 4px;
  margin-top: 2px;
}
.p3-brand-links {
  display: flex;
  align-items: center;
  gap: 14px;
  font-family: 'Bebas Neue', 'Oswald', 'Arial Narrow', sans-serif;
  font-size: 13px;
  letter-spacing: 3px;
}
.p3-brand-links a {
  text-decoration: none;
  padding: 4px 2px;
  border-bottom: 1px solid transparent;
  transition: color 0.15s ease, border-color 0.15s ease;
}
.p3-theme-toggle {
  font-family: 'Bebas Neue', 'Oswald', 'Arial Narrow', sans-serif;
  font-size: 13px;
  letter-spacing: 3px;
  background: transparent;
  border: 0;
  border-bottom: 1px solid transparent;
  padding: 4px 2px;
  cursor: pointer;
  transition: color 0.15s ease, border-color 0.15s ease;
}
.p3-theme-toggle:focus-visible { outline: none; }

/* Landing-page context: absolute positioning overlays the sphere canvas, and
   the p3-menu.js mount adds .mounted for the staggered fade-in. */
.p3-root .p3-brand {
  position: absolute;
  top: 28px;
  left: 40px;
  z-index: 20;
  color: #fff;
  opacity: 0;
  transform: translateY(-8px);
  transition: opacity 0.6s ease 0.1s, transform 0.6s cubic-bezier(0.22,1,0.36,1) 0.1s;
  pointer-events: none;
}
.p3-root .p3-brand.mounted { opacity: 1; transform: translateY(0); }
.p3-root .p3-brand img {
  filter: drop-shadow(0 2px 6px rgba(0,0,0,0.5));
  pointer-events: auto;
}
.p3-root .p3-brand a,
.p3-root .p3-brand button { pointer-events: auto; }
.p3-root .p3-brand-name { color: #fff; }
.p3-root .p3-brand-sub { color: rgba(255,255,255,0.5); }
.p3-root .p3-brand-links {
  position: absolute;
  top: 28px;
  right: 40px;
  z-index: 20;
  opacity: 0;
  transition: opacity 0.6s ease 0.2s;
}
.p3-root .p3-brand-links.mounted { opacity: 1; }
.p3-root .p3-brand-links a,
.p3-root .p3-theme-toggle {
  color: rgba(255,255,255,0.55);
}
.p3-root .p3-brand-links a:hover,
.p3-root .p3-theme-toggle:hover,
.p3-root .p3-theme-toggle:focus-visible {
  color: #fff;
  border-bottom-color: #c4001a;
}

/* Landing page, light theme: the sphere background goes white, so the
   default translucent-white treatment becomes invisible. Switch to dark ink,
   keep the red accent for the hover underline. */
html[data-theme="light"] .p3-root .p3-brand,
html[data-theme="light"] .p3-root .p3-brand-name {
  color: #14151a;
}
html[data-theme="light"] .p3-root .p3-brand img {
  filter: drop-shadow(0 2px 6px rgba(0,0,0,0.18));
}
html[data-theme="light"] .p3-root .p3-brand-sub {
  color: rgba(20,20,24,0.55);
}
html[data-theme="light"] .p3-root .p3-brand-links a,
html[data-theme="light"] .p3-root .p3-theme-toggle {
  color: rgba(20,20,24,0.65);
}
html[data-theme="light"] .p3-root .p3-brand-links a:hover,
html[data-theme="light"] .p3-root .p3-theme-toggle:hover,
html[data-theme="light"] .p3-root .p3-theme-toggle:focus-visible {
  color: #14151a;
}
html[data-theme="light"] .p3-label {
  color: #5c1a23;
  text-shadow: 0 2px 14px rgba(0,0,0,0.08);
}
html[data-theme="light"] .p3-row:hover .p3-label,
html[data-theme="light"] .p3-row:focus-visible .p3-label,
html[data-theme="light"] .p3-row.active .p3-label {
  color: #14151a;
}
html[data-theme="light"] .p3-hint-row {
  color: rgba(20,20,24,0.45);
}
html[data-theme="light"] .p3-hint-key {
  color: rgba(20,20,24,0.7);
  border-color: rgba(20,20,24,0.25);
  background: rgba(255,255,255,0.6);
}

/* Sub-page header: same brand components, in-flow, theme-aware colors. */
.page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  padding: 1.25rem 0;
  margin: 0 0 1rem;
  border-bottom: 1px solid var(--border);
}
.page-head .p3-brand a {
  display: inline-flex;
  line-height: 0;
}
.page-head .p3-brand-name {
  color: var(--accent);
  font-size: 15px;
  font-weight: 700;
}
.page-head .p3-brand-sub {
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
}
.page-head .p3-brand-links,
.page-head .p3-theme-toggle {
  font-size: 11px;
  font-weight: 700;
}
.page-head .p3-brand-links a,
.page-head .p3-theme-toggle {
  color: var(--fg);
  opacity: 0.7;
}
.page-head .p3-brand-links a:hover,
.page-head .p3-theme-toggle:hover,
.page-head .p3-theme-toggle:focus-visible {
  color: var(--link);
  border-bottom-color: var(--link);
  opacity: 1;
}

/* Landing header: below this width the absolutely-positioned brand and
   links would collide, so drop the links to a second row (matches the
   sub-page header wrap). */
@media (max-width: 820px) {
  .p3-root .p3-brand-links { top: 80px; left: 40px; right: auto; }
}

@media (max-width: 600px) {
  .p3-root .p3-brand { top: 16px; left: 20px; }
  .p3-root .p3-brand-links { top: 60px; left: 20px; right: auto; font-size: 11px; gap: 10px; }
  .p3-brand img { height: 28px; }
  .p3-brand-name { font-size: 16px; }
  .p3-brand-sub { font-size: 10px; }
  .page-head { padding: 1rem 0; }
  .page-head .p3-brand-name { font-size: 13px; }
  .page-head .p3-brand-sub { font-size: 9px; }
  .page-head .p3-brand-links,
  .page-head .p3-theme-toggle { font-size: 10px; }
}

/* Persona-menu body. Theme-aware: pitch-black in dark, pure white in light.
   The WebGL canvas paints over this, but the body color is what shows briefly
   before the canvas inits and serves as a fallback when WebGL is unavailable. */
.p3-body {
  background: #000000;
  color: #fff;
}
html[data-theme="light"] .p3-body,
html[data-theme="light"] .p3-root {
  background: #ffffff;
}
html[data-theme="dark"] .p3-body,
html[data-theme="dark"] .p3-root {
  background: #000000;
}


/* Section headings inside project detail pages - bold + an underline rule so
   they read clearly against the body copy (added per feedback: hard to see). */
.project-body h3 {
  font-weight: 700;
  border-bottom: 2px solid var(--fg);
  padding-bottom: .3rem;
  margin-bottom: .6rem;
}
.project-body h4 {
  font-weight: 700;
  border-bottom: 1px solid var(--border);
  padding-bottom: .25rem;
  margin-bottom: .5rem;
}
/* Diagram-card titles already sit inside a bordered card - keep them plain. */
.project-body .diagram-card h3 {
  border-bottom: none;
  padding-bottom: 0;
  margin-bottom: .25rem;
}

/* ---- Project detail banner: right-aligned content, back button, sticky bar ---- */
section.project-hero { justify-content: flex-end; }
.project-hero__content { text-align: right; }
.project-hero__meta { justify-content: flex-end; }

/* Round "back to projects" button on the LEFT of the expanded banner */
.project-hero__back {
  position: absolute;
  left: 1.25rem; top: 50%;
  transform: translateY(-50%);
  z-index: 2;
  width: 44px; height: 44px;
  box-sizing: border-box; padding-bottom: 6px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.9);
  color: #111111;
  font-size: 1.7rem; line-height: 1;
  text-decoration: none;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.22);
  backdrop-filter: blur(6px);
  transition: background .15s ease, transform .15s ease;
}
.project-hero__back:hover { background: #ffffff; transform: translateY(-50%) scale(1.06); }

/* Compact bar that freezes to the top once the banner scrolls away */
.project-hero-bar {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 50;
  display: flex; align-items: center; gap: 1rem;
  padding: .55rem 1rem;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
  transform: translateY(-100%);
  transition: transform .25s ease;
}
.project-hero-bar.visible { transform: translateY(0); }
.project-hero-bar__back {
  flex: 0 0 auto;
  width: 34px; height: 34px;
  box-sizing: border-box; padding-bottom: 5px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--fg);
  font-size: 1.35rem; line-height: 1;
  text-decoration: none;
}
.project-hero-bar__back:hover { background: var(--card); }
.project-hero-bar__label {
  margin-left: auto;
  text-align: right;
  font-weight: 600;
  color: var(--fg);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}
@media (max-width: 640px) {
  .project-hero__back { top: 1rem; left: 1rem; transform: none; width: 38px; height: 38px; font-size: 1.4rem; }
  .project-hero__back:hover { transform: scale(1.06); }
  .project-hero-bar__label { font-size: .9rem; }
}
