/* ==========================================================================
   Harsimranjeet Singh — personal site
   One stylesheet, no build step. Mobile-first.
   ========================================================================== */

/* ---- Design tokens ---------------------------------------------------- */
:root {
  color-scheme: light;
  --bg: #fafaf8;
  --bg-elev: #ffffff;
  --bg-sunken: #f1f2ef;
  --text: #17191a;
  --text-2: #464b4d;
  --muted: #61676a;          /* 5.6:1 on --bg */
  --line: #e2e4e0;
  --line-strong: #cfd3ce;
  --accent: #0b6b62;          /* deep teal, 6.4:1 on --bg */
  --accent-soft: #e3f1ee;
  --trace: #0b6b62;
  --trace-opacity: .14;
  --placeholder-bg: #fff6db;
  --placeholder-text: #6b5310;
  --wip: #8a5a00;
  --wip-bg: #fdf1d8;
  --shadow: 0 1px 2px rgba(16, 24, 24, .04), 0 8px 24px -12px rgba(16, 24, 24, .12);

  --font-sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", "Noto Sans", Arial, sans-serif;
  --font-mono: ui-monospace, "SF Mono", "JetBrains Mono", "Cascadia Mono", Menlo, Consolas, "Liberation Mono", monospace;

  --radius: 10px;
  --radius-sm: 6px;
  --wrap: 72rem;
  --wrap-text: 42rem;
  --gutter: 1rem;
  --space-section: clamp(3.5rem, 8vw, 6.5rem);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0d1111;
    --bg-elev: #141a1a;
    --bg-sunken: #111616;
    --text: #eceeed;
    --text-2: #c3c8c6;
    --muted: #949b98;
    --line: #232b2a;
    --line-strong: #2f3938;
    --accent: #5fd4c4;
    --accent-soft: #12302c;
    --trace: #5fd4c4;
    --trace-opacity: .10;
    --placeholder-bg: #2c2512;
    --placeholder-text: #e6c66e;
    --wip: #f0b74a;
    --wip-bg: #2b2210;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 10px 30px -14px rgba(0, 0, 0, .6);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0d1111;
  --bg-elev: #141a1a;
  --bg-sunken: #111616;
  --text: #eceeed;
  --text-2: #c3c8c6;
  --muted: #949b98;
  --line: #232b2a;
  --line-strong: #2f3938;
  --accent: #5fd4c4;
  --accent-soft: #12302c;
  --trace: #5fd4c4;
  --trace-opacity: .10;
  --placeholder-bg: #2c2512;
  --placeholder-text: #e6c66e;
  --wip: #f0b74a;
  --wip-bg: #2b2210;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 10px 30px -14px rgba(0, 0, 0, .6);
}

/* ---- Base ------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; scroll-padding-top: 5rem; }
@media (prefers-reduced-motion: no-preference) { html { scroll-behavior: smooth; } }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 1.0625rem;
  line-height: 1.65;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

img, svg { display: block; max-width: 100%; height: auto; }
h1, h2, h3, h4 { line-height: 1.2; letter-spacing: -.015em; margin: 0 0 .6em; font-weight: 650; text-wrap: balance; }
h1 { font-size: clamp(2.25rem, 6vw, 3.6rem); letter-spacing: -.03em; font-weight: 700; }
h2 { font-size: clamp(1.5rem, 3.2vw, 2rem); }
h3 { font-size: 1.15rem; }
p { margin: 0 0 1.1em; text-wrap: pretty; }
ul, ol { padding-left: 1.2em; margin: 0 0 1.1em; }
li + li { margin-top: .35em; }
strong { font-weight: 640; }
code, kbd { font-family: var(--font-mono); font-size: .88em; background: var(--bg-sunken); border: 1px solid var(--line); border-radius: 4px; padding: .05em .35em; }
hr { border: 0; border-top: 1px solid var(--line); margin: 2.5rem 0; }

a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: .2em; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 3px; }

.skip-link {
  position: absolute; left: 1rem; top: -3rem; z-index: 100;
  background: var(--text); color: var(--bg); padding: .5rem .9rem; border-radius: var(--radius-sm);
  text-decoration: none; font-weight: 600;
}
.skip-link:focus { top: 1rem; }

.visually-hidden {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ---- Layout ----------------------------------------------------------- */
.wrap { width: 100%; max-width: var(--wrap); margin-inline: auto; padding-inline: var(--gutter); }
.wrap-text { max-width: var(--wrap-text); }
.section { padding-block: var(--space-section); }
.section + .section { border-top: 1px solid var(--line); }
.section-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: .5rem 1.5rem; margin-bottom: 2rem; }
.section-head h2 { margin: 0; }

@media (min-width: 40rem) { :root { --gutter: 1.5rem; } }
@media (min-width: 64rem) { :root { --gutter: 2rem; } }

/* Mono "label" used for eyebrows, metadata, captions */
.eyebrow, .label {
  font-family: var(--font-mono);
  font-size: .78rem;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--muted);
}
.eyebrow { color: var(--accent); margin: 0 0 1rem; }
.muted { color: var(--muted); }
.lead { font-size: clamp(1.15rem, 2.2vw, 1.35rem); line-height: 1.55; color: var(--text-2); }

/* ---- Header ----------------------------------------------------------- */
.site-header {
  position: sticky; top: 0; z-index: 50;
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  -webkit-backdrop-filter: saturate(160%) blur(10px);
  backdrop-filter: saturate(160%) blur(10px);
  border-bottom: 1px solid var(--line);
}
.site-header .wrap { display: flex; align-items: center; justify-content: space-between; gap: 1rem; min-height: 3.75rem; }
.brand {
  display: inline-flex; align-items: center; gap: .6rem;
  color: var(--text); text-decoration: none; font-weight: 650; letter-spacing: -.01em; white-space: nowrap;
}
.brand-mark {
  display: inline-grid; place-items: center; width: 1.9rem; height: 1.9rem; flex: none;
  border: 1.5px solid var(--text); border-radius: 7px;
  font-family: var(--font-mono); font-size: .72rem; font-weight: 700; letter-spacing: 0;
}
.brand-name { display: none; }
@media (min-width: 30rem) { .brand-name { display: inline; } }

.nav { display: flex; align-items: center; gap: .25rem; }
.nav a {
  color: var(--text-2); text-decoration: none; font-size: .95rem;
  padding: .45rem .65rem; border-radius: var(--radius-sm);
}
.nav a:hover { color: var(--text); background: var(--bg-sunken); }
.nav a[aria-current="page"] { color: var(--text); font-weight: 600; }

.theme-toggle {
  display: inline-grid; place-items: center; width: 2.25rem; height: 2.25rem; margin-left: .25rem;
  border: 1px solid var(--line); border-radius: var(--radius-sm); background: transparent; color: var(--text-2);
  cursor: pointer; padding: 0;
}
.theme-toggle:hover { color: var(--text); border-color: var(--line-strong); }
.theme-toggle svg { width: 1.05rem; height: 1.05rem; }
.theme-toggle .icon-sun { display: none; }
:root[data-theme="dark"] .theme-toggle .icon-sun { display: block; }
:root[data-theme="dark"] .theme-toggle .icon-moon { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle .icon-sun { display: block; }
  :root:not([data-theme="light"]) .theme-toggle .icon-moon { display: none; }
}
.no-js .theme-toggle { display: none; }

/* ---- Hero ------------------------------------------------------------- */
.hero { position: relative; overflow: hidden; padding-block: clamp(4rem, 12vw, 8.5rem) clamp(3.5rem, 9vw, 6rem); }
.hero > .wrap { position: relative; z-index: 1; }
.hero h1 { margin-bottom: .35em; }
.hero .lead { max-width: 38rem; margin-bottom: 1.6rem; }
.hero .intro { max-width: 40rem; color: var(--text-2); }

/* Subtle PCB-trace motif (decorative SVG) */
.traces {
  position: absolute; inset: 0 0 0 auto; width: min(60rem, 100%); height: 100%;
  color: var(--trace); opacity: var(--trace-opacity); pointer-events: none; z-index: 0;
}
.traces path { fill: none; stroke: currentColor; stroke-width: 1.5; }
.traces circle { fill: currentColor; }
@media (max-width: 47.99rem) { .traces { opacity: calc(var(--trace-opacity) * .6); } }

.hero-links { display: flex; flex-wrap: wrap; gap: .75rem; margin-top: 2rem; }

/* ---- Buttons / link pills -------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; gap: .5rem;
  padding: .6rem 1rem; border-radius: var(--radius-sm);
  font-size: .95rem; font-weight: 560; text-decoration: none;
  border: 1px solid var(--line-strong); color: var(--text); background: var(--bg-elev);
  transition: border-color .15s, background-color .15s;
}
.btn:hover { border-color: var(--text-2); }
.btn-primary { background: var(--text); color: var(--bg); border-color: var(--text); }
.btn-primary:hover { background: color-mix(in srgb, var(--text) 85%, var(--bg)); }
.btn svg { width: 1rem; height: 1rem; flex: none; }

/* ---- Stats strip ------------------------------------------------------ */
.stats { display: grid; grid-template-columns: 1fr; gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; margin: 0; }
.stats > div { background: var(--bg); padding: 1.25rem 1.25rem 1.1rem; }
.stats dd { order: -1; margin: 0 0 .2rem; font-size: 1.6rem; font-weight: 650; letter-spacing: -.02em; line-height: 1.2; }
.stats > div { display: flex; flex-direction: column; }
@media (min-width: 40rem) { .stats { grid-template-columns: repeat(3, 1fr); } }

/* ---- Project cards ---------------------------------------------------- */
.card-grid { display: grid; grid-template-columns: 1fr; gap: 1.25rem; list-style: none; padding: 0; margin: 0; }
.card-grid > li { margin: 0; }
@media (min-width: 44rem) { .card-grid { grid-template-columns: repeat(2, 1fr); gap: 1.5rem; } }

.card {
  position: relative; display: flex; flex-direction: column; height: 100%;
  background: var(--bg-elev); border: 1px solid var(--line); border-radius: var(--radius);
  overflow: hidden; transition: border-color .2s, box-shadow .2s, transform .2s;
}
.card:hover { border-color: var(--line-strong); box-shadow: var(--shadow); }
@media (prefers-reduced-motion: no-preference) { .card:hover { transform: translateY(-2px); } }
.card-media { aspect-ratio: 3 / 2; background: var(--bg-sunken); overflow: hidden; border-bottom: 1px solid var(--line); }
.card-media img { width: 100%; height: 100%; object-fit: cover; }
.card-media img.plot { object-fit: contain; background: #fff; padding: 0.5rem; }
.card-body { display: flex; flex-direction: column; gap: .5rem; padding: 1.15rem 1.25rem 1.35rem; flex: 1; }
.card-body h3 { margin: 0; font-size: 1.15rem; }
.card-body h3 a { color: var(--text); text-decoration: none; }
.card-body h3 a::after { content: ""; position: absolute; inset: 0; }   /* whole card clickable */
.card-body h3 a:focus-visible { outline: none; }
.card:has(a:focus-visible) { outline: 2px solid var(--accent); outline-offset: 3px; }
.card-body p { margin: 0; color: var(--text-2); font-size: .97rem; }
.card-meta { display: flex; flex-wrap: wrap; gap: .4rem .9rem; align-items: center; margin-top: auto; padding-top: .6rem; }

.tags { display: flex; flex-wrap: wrap; gap: .4rem; list-style: none; padding: 0; margin: 0; }
.tags li { margin: 0; font-family: var(--font-mono); font-size: .72rem; color: var(--muted); border: 1px solid var(--line); border-radius: 999px; padding: .15rem .55rem; }

.status { display: inline-flex; align-items: center; gap: .45rem; font-family: var(--font-mono); font-size: .74rem; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); }
.status::before { content: ""; width: .5rem; height: .5rem; border-radius: 50%; background: var(--accent); flex: none; }
.status-wip { color: var(--wip); }
.status-wip::before { background: var(--wip); }
.wip-badge {
  position: absolute; top: .8rem; left: .8rem; z-index: 1;
  font-family: var(--font-mono); font-size: .7rem; letter-spacing: .06em; text-transform: uppercase;
  color: var(--wip); background: var(--wip-bg); border: 1px solid color-mix(in srgb, var(--wip) 35%, transparent);
  padding: .2rem .55rem; border-radius: 999px;
}

/* ---- Availability ----------------------------------------------------- */
.contact { display: grid; gap: 1.5rem; }
.contact p { margin: 0; }
.availability { display: inline-flex; align-items: center; gap: .6rem; color: var(--text-2); }
.availability::before { content: ""; width: .5rem; height: .5rem; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); flex: none; }
.contact-links { display: flex; flex-wrap: wrap; gap: .75rem; }

/* ---- Prose / about ---------------------------------------------------- */
.prose { max-width: var(--wrap-text); }
.prose h2 { margin-top: 2.6rem; }
.prose h2:first-child { margin-top: 0; }
.prose h3 { margin-top: 2rem; }
.prose ul li::marker { color: var(--muted); }

.about-grid { display: grid; gap: 2rem; }
@media (min-width: 56rem) { .about-grid { grid-template-columns: 13rem 1fr; gap: 3rem; } }
.about-grid > h2 { font-size: 1.05rem; font-family: var(--font-mono); font-weight: 500; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin: .35rem 0 0; }

/* Photo slot (unused until a portrait is added) */
.portrait { width: 9rem; height: 9rem; border-radius: 50%; object-fit: cover; border: 1px solid var(--line); margin-bottom: 1.5rem; }

/* Placeholders the owner still needs to fill in */
.placeholder {
  color: var(--placeholder-text); background: var(--placeholder-bg);
  font-family: var(--font-mono); font-size: .86em; font-style: normal;
  padding: .05em .4em; border-radius: 4px; white-space: normal;
  -webkit-box-decoration-break: clone; box-decoration-break: clone;
}

/* Education block */
.edu-list { display: grid; gap: 1rem; }
.edu p { margin: 0; color: var(--text-2); }
.edu { border: 1px solid var(--line); border-radius: var(--radius); background: var(--bg-elev); padding: 1.4rem 1.5rem; }
.edu h3 { margin: 0 0 .2rem; }
.edu .label { display: block; margin-bottom: .9rem; }
.edu .label:last-child { margin-bottom: 0; }
.edu dl { display: grid; grid-template-columns: 1fr; gap: .2rem 1.5rem; margin: 1rem 0 0; }
.edu dt { font-weight: 600; margin-top: .6rem; }
.edu dd { margin: 0; color: var(--text-2); }
@media (min-width: 40rem) { .edu dl { grid-template-columns: 9rem 1fr; } .edu dt { margin-top: 0; } }

/* Timeline */
.timeline { list-style: none; padding: 0; margin: 0; position: relative; }
.timeline::before { content: ""; position: absolute; left: .3rem; top: .5rem; bottom: .5rem; width: 1px; background: var(--line-strong); }
.timeline > li { position: relative; padding-left: 2rem; margin: 0 0 2.2rem; }
.timeline > li:last-child { margin-bottom: 0; }
.timeline > li::before {
  content: ""; position: absolute; left: 0; top: .45rem; width: .65rem; height: .65rem;
  border-radius: 50%; background: var(--bg); border: 2px solid var(--accent);
}
.timeline h3 { margin: 0 0 .15rem; }
.timeline .when { display: block; margin-bottom: .6rem; }
.timeline p { color: var(--text-2); }
.timeline ul { color: var(--text-2); }

/* Skills */
.skills { display: grid; gap: 1.25rem; grid-template-columns: 1fr; }
@media (min-width: 40rem) { .skills { grid-template-columns: repeat(2, 1fr); } }
.skill-group { border: 1px solid var(--line); border-radius: var(--radius); padding: 1.2rem 1.3rem 1.3rem; background: var(--bg-elev); }
.skill-group h3 { font-size: 1rem; margin: 0 0 .8rem; }

/* ---- Case-study pages ------------------------------------------------- */
.breadcrumb { font-size: .9rem; margin-bottom: 1.5rem; }
.breadcrumb ol { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: .4rem; }
.breadcrumb li { margin: 0; color: var(--muted); }
.breadcrumb li + li::before { content: "/"; margin-right: .4rem; color: var(--line-strong); }
.breadcrumb a { color: var(--muted); text-decoration: none; }
.breadcrumb a:hover { color: var(--text); text-decoration: underline; }

.case-head { padding-block: clamp(2.5rem, 7vw, 4.5rem) 2rem; }
.case-head h1 { font-size: clamp(2rem, 5vw, 3rem); margin-bottom: .4em; }
.case-head .lead { max-width: 46rem; }
.case-head .status { margin-bottom: 1.2rem; }

.facts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; margin: 2rem 0 0; }
.facts > div { background: var(--bg); padding: .9rem 1rem; min-width: 0; }
.facts dt { font-family: var(--font-mono); font-size: .7rem; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin-bottom: .25rem; }
.facts dd { margin: 0; font-weight: 560; font-size: .97rem; overflow-wrap: anywhere; }
@media (min-width: 48rem) { .facts { grid-template-columns: repeat(4, minmax(0, 1fr)); } }

.figure { margin: 0; }
.figure a { display: block; }
.figure img { width: 100%; border-radius: var(--radius); border: 1px solid var(--line); background: var(--bg-sunken); }
.figure figcaption { margin-top: .6rem; font-size: .88rem; color: var(--muted); }
.figure-hero { margin-block: 2rem 0; }
.figure-hero img { max-height: min(46rem, 80vh); object-fit: contain; }
.section.section-tight { padding-top: 1.5rem; border-top: 0; }
.figure-wip { position: relative; }

.gallery { display: grid; grid-template-columns: 1fr; gap: 1.5rem; }
@media (min-width: 44rem) { .gallery { grid-template-columns: repeat(2, 1fr); } }
.gallery .figure-wide { grid-column: 1 / -1; max-width: 56rem; justify-self: center; width: 100%; }

.case-body { display: grid; gap: 3rem; }
.case-body > section > h2 { margin-bottom: .9rem; }

.numbers { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 13rem), 1fr)); gap: 1rem; list-style: none; padding: 0; margin: 0; }
.numbers li { margin: 0; border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem 1.1rem; background: var(--bg-elev); }
.numbers strong { display: block; font-size: 1.35rem; letter-spacing: -.02em; line-height: 1.25; margin-bottom: .2rem; }
.numbers span { color: var(--muted); font-size: .9rem; }

.callout { border-left: 3px solid var(--line-strong); padding: .2rem 0 .2rem 1.1rem; color: var(--text-2); }
.callout-wip { border-left-color: var(--wip); }

.case-nav { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 1rem; }
.case-nav a { text-decoration: none; display: flex; flex-direction: column; gap: .15rem; max-width: 100%; }
.case-nav a span:last-child { color: var(--text); font-weight: 600; }
.case-nav a:hover span:last-child { text-decoration: underline; }
.case-nav .next { text-align: right; margin-left: auto; }

/* Projects index list */
.project-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 2.5rem; }
.group-title { font-family: var(--font-mono); font-size: .8rem; font-weight: 500; letter-spacing: .08em; text-transform: uppercase; color: var(--accent); margin: 2.5rem 0 1.25rem; padding-bottom: .5rem; border-bottom: 1px solid var(--line); }
.section-note + .group-title { margin-top: 0; }
.project-list > li { margin: 0; }
.project-row { display: grid; gap: 1.25rem; align-items: center; position: relative; }
@media (min-width: 52rem) { .project-row { grid-template-columns: 1.1fr 1fr; gap: 2.5rem; } }
.project-row .card-media { position: relative; border: 1px solid var(--line); border-radius: var(--radius); }
.project-row h2 { font-size: 1.5rem; margin: .3rem 0 .5rem; }
.project-row h2 a { color: var(--text); text-decoration: none; }
.project-row h2 a::after { content: ""; position: absolute; inset: 0; }
.project-row:hover h2 a { text-decoration: underline; text-decoration-thickness: 1px; }
.project-row p { color: var(--text-2); }

/* ---- 404 -------------------------------------------------------------- */
.notfound { min-height: 60vh; display: grid; align-content: center; }
.notfound .code { font-family: var(--font-mono); color: var(--accent); font-size: .9rem; letter-spacing: .1em; }

/* ---- Footer ----------------------------------------------------------- */
.site-footer { border-top: 1px solid var(--line); padding-block: 2.5rem; color: var(--muted); font-size: .9rem; }
.site-footer .wrap { display: flex; flex-wrap: wrap; gap: 1rem 2rem; justify-content: space-between; align-items: center; }
.site-footer ul { display: flex; flex-wrap: wrap; gap: .4rem 1.25rem; list-style: none; padding: 0; margin: 0; }
.site-footer li { margin: 0; }
.site-footer a { color: var(--muted); text-decoration: none; }
.site-footer a:hover { color: var(--text); text-decoration: underline; }
.site-footer p { margin: 0; }

/* ---- Print ------------------------------------------------------------ */
@media print {
  .site-header, .theme-toggle, .traces, .skip-link { display: none !important; }
  body { background: #fff; color: #000; }
  a { color: #000; }
}

/* ---- Equations on university case studies ----------------------------- */
.case-body > *, .prose { min-width: 0; }
.eqn { max-width: 100%; box-sizing: border-box; font-family: var(--font-mono); font-size: .88rem; line-height: 1.7; color: var(--text); background: var(--bg-sunken); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: .9rem 1.1rem; margin: 1rem 0 1.2rem; overflow-x: auto; white-space: pre; }
.code-block { max-width: 100%; box-sizing: border-box; font-family: var(--font-mono); font-size: .82rem; line-height: 1.6; color: var(--text); background: var(--bg-sunken); border: 1px solid var(--line); border-left: 3px solid var(--accent); border-radius: var(--radius-sm); padding: .9rem 1.1rem; margin: 1rem 0 1.2rem; overflow-x: auto; white-space: pre; tab-size: 4; }
.code-block code { background: none; border: 0; padding: 0; font-size: inherit; color: inherit; }
.table-wrap { max-width: 100%; overflow-x: auto; margin: 1rem 0 1.2rem; border: 1px solid var(--line); border-radius: var(--radius-sm); }
.data-table { border-collapse: collapse; width: 100%; font-size: .86rem; font-variant-numeric: tabular-nums; }
.data-table th, .data-table td { padding: .5rem .7rem; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; vertical-align: top; }
.data-table thead th { background: var(--bg-sunken); color: var(--muted); font-weight: 600; }
.data-table tbody tr:last-child td { border-bottom: 0; }
.data-table code { font-size: .92em; }
.section-note { color: var(--muted); max-width: var(--wrap-text); margin: -1rem 0 2rem; }
.section-title { margin: 0 0 2rem; }

/* Compact project entry (no case-study page) */
@media (min-width: 52rem) { .project-row.project-row-compact { grid-template-columns: minmax(0, 1fr); } }
.project-row-compact { border: 1px solid var(--line); border-radius: var(--radius); background: var(--bg-elev); padding: 1.25rem 1.35rem; }
.project-row-compact > div { max-width: var(--wrap-text); }
.project-row-compact p.muted { font-size: .9rem; color: var(--muted); }

/* ---- Hero layout + "now" terminal card ------------------------------- */
.hero-grid { display: grid; gap: 2.5rem; align-items: center; }
@media (min-width: 62rem) { .hero-grid { grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr); gap: 3.5rem; } }
.btn-icon { padding: .6rem .7rem; }
.btn-icon svg { width: 1.1rem; height: 1.1rem; }

.term {
  --term-bg: color-mix(in srgb, var(--accent-soft) 40%, var(--bg-elev));
  position: relative; min-width: 0; max-width: 34rem; width: 100%;
  background: var(--term-bg); border: 1px solid var(--line-strong); border-radius: var(--radius);
  box-shadow: var(--shadow), 0 18px 40px -24px color-mix(in srgb, var(--accent) 45%, transparent);
  font-family: var(--font-mono); font-size: .86rem; line-height: 1.6; overflow: hidden;
}
.term-bar { display: flex; align-items: center; gap: .4rem; padding: .6rem .85rem; border-bottom: 1px solid var(--line); background: color-mix(in srgb, var(--bg-sunken) 70%, var(--term-bg)); }
.term-dot { width: .62rem; height: .62rem; border-radius: 50%; background: var(--line-strong); }
.term-dot:nth-child(1) { background: #e06c5f; } .term-dot:nth-child(2) { background: #e5b84e; } .term-dot:nth-child(3) { background: #5bb974; }
.term-title { margin-left: auto; margin-right: auto; padding-right: 2.2rem; color: var(--muted); font-size: .74rem; letter-spacing: .04em; }
.term-body { margin: 0; padding: 1rem 1.1rem 1.15rem; display: grid; gap: .55rem; }
.term-body > div { min-width: 0; }
.term-body dt { color: var(--text); font-weight: 600; }
.term-body dt::before { content: "$ "; color: var(--accent); }
.term-body dd { margin: 0; color: var(--text-2); overflow-wrap: anywhere; }
.term-body dd::before { content: "→ "; color: var(--accent); }
.term-body a { color: var(--accent); text-underline-offset: 2px; }
.term-cursor { display: inline-block; width: .55em; height: 1.05em; margin-left: .15em; vertical-align: -.17em; background: var(--accent); }
@media (prefers-reduced-motion: no-preference) { .term-cursor { animation: term-blink 1.05s steps(1) infinite; } }
@keyframes term-blink { 50% { opacity: 0; } }
.term.is-typing > .term-body:not(.term-anim) { opacity: 0; }
.term-anim { position: absolute; left: 0; right: 0; top: 0; pointer-events: none; }
@media (max-width: 61.99rem) { .term { max-width: 30rem; } }
@media (max-width: 30rem) { .term { font-size: .8rem; } }

/* ---- Featured project card (home) ------------------------------------- */
@media (min-width: 44rem) {
  .card-grid > li:has(> .card-feature) { grid-column: 1 / -1; }
  .card-feature { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); }
  .card-feature .card-media { border-bottom: 0; border-right: 1px solid var(--line); aspect-ratio: auto; min-height: 100%; }
  .card-feature .card-body { justify-content: center; padding: 1.6rem 1.75rem; }
  .card-feature .card-body h3 { font-size: 1.35rem; }
}

/* ---- About: experience "show more" and skill chips -------------------- */
.timeline details.more { margin-top: -.35rem; color: var(--text-2); }
.timeline details.more > ul { margin-top: .4rem; }
.timeline summary {
  display: inline-flex; align-items: center; gap: .4rem; cursor: pointer; list-style: none;
  font-family: var(--font-mono); font-size: .78rem; letter-spacing: .04em; color: var(--accent);
  padding: .2rem 0; border-radius: var(--radius-sm);
}
.timeline summary::-webkit-details-marker { display: none; }
.timeline summary::before { content: "+"; display: inline-grid; place-items: center; width: 1.1rem; height: 1.1rem; border: 1px solid currentColor; border-radius: 4px; font-size: .8rem; line-height: 1; }
.timeline details[open] summary::before { content: "−"; }
.timeline summary:hover { text-decoration: underline; text-underline-offset: 3px; }
.timeline summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.skill-group .tags { gap: .45rem; }
.skill-group .tags li { font-size: .8rem; color: var(--text); background: var(--bg-sunken); border-color: var(--line-strong); padding: .25rem .7rem; }

/* ---- Click-to-load 3D viewer ----------------------------------------- */
.viewer3d-stage { position: relative; }
.viewer3d-btn { position: absolute; right: .9rem; bottom: .9rem; z-index: 2; box-shadow: var(--shadow); }
.viewer3d-btn[disabled] { opacity: .85; cursor: progress; }
.viewer3d-mv {
  display: block; width: 100%; height: auto; aspect-ratio: 1600 / 1052; max-height: min(46rem, 80vh);
  border-radius: var(--radius); border: 1px solid var(--line); background: var(--bg-sunken);
  --poster-color: transparent;
}
.viewer3d-mv:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.timeline details .when-open, .timeline details[open] .when-closed { display: none; }
.timeline details[open] .when-open { display: inline; }

/* ---- Home: compact professional-work cards --------------------------- */
@media (min-width: 64rem) { .card-grid-mini { grid-template-columns: repeat(4, 1fr); gap: 1.25rem; } }
.card-mini .card-body { gap: .45rem; padding: 1.1rem 1.15rem 1.2rem; }
.card-mini .card-body h3 { font-size: 1.05rem; }
.card-mini .card-body p { font-size: .93rem; }
.card-mini .status { font-size: .7rem; }

/* ---- Home: tighter spacing between the project groups ---------------- */
.section-group { padding-block: clamp(2.5rem, 5vw, 4rem); }

/* ---- About: selected coursework -------------------------------------- */
.course-groups { display: grid; gap: 1.25rem; grid-template-columns: 1fr; }
@media (min-width: 48rem) { .course-groups { grid-template-columns: repeat(2, 1fr); } }
.course-group { border: 1px solid var(--line); border-radius: var(--radius); padding: 1.2rem 1.3rem 1.3rem; background: var(--bg-elev); min-width: 0; }
.course-group h3 { font-size: 1rem; margin: 0 0 .8rem; }
.course-list { list-style: none; padding: 0; margin: 0; display: grid; gap: .85rem; }
.course-list li { margin: 0; }
.course-list .course { display: block; font-weight: 600; font-size: .97rem; line-height: 1.35; }
.course-list .course .code { font-family: var(--font-mono); font-size: .8rem; font-weight: 500; color: var(--accent); margin-right: .4rem; letter-spacing: .02em; }
.course-list .course .subject { font-weight: 500; color: var(--text-2); }
.course-list p { margin: .2rem 0 0; color: var(--text-2); font-size: .93rem; }
.course-note { color: var(--muted); font-size: .9rem; margin: 0 0 1.25rem; }

/* Figures placed inside a prose section (graduate case study) */
.prose > .figure, .prose > .gallery { margin-block: 1.6rem 1.8rem; }
