:root {
  --bg: #fbfaf7;
  --surface: #ffffff;
  --text: #1d2230;
  --muted: #5d6475;
  --border: #e4e1d8;
  --accent: #b3261e;      /* BUT/FIT red */
  --accent-soft: #f6e5e3;
  --link: #1f4e8c;
  --serif: "Source Serif 4", Georgia, serif;
  --sans: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  color-scheme: light dark;
}
/* Dark theme: follows the system unless the visitor picked light/dark
   with the switcher (stored as data-theme on <html>). */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #14161c;
    --surface: #1c1f27;
    --text: #e6e6ea;
    --muted: #a0a5b3;
    --border: #2d313c;
    --accent: #ef6b5f;
    --accent-soft: #3a2220;
    --link: #8fb4ef;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
    --bg: #14161c;
    --surface: #1c1f27;
    --text: #e6e6ea;
    --muted: #a0a5b3;
    --border: #2d313c;
    --accent: #ef6b5f;
    --accent-soft: #3a2220;
    --link: #8fb4ef;
    color-scheme: dark;
}
:root[data-theme="light"] { color-scheme: light; }

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 17px/1.65 var(--sans);
}
.container { max-width: 960px; margin: 0 auto; padding: 0 16px; }
main.container { padding-top: 2.5rem; padding-bottom: 4rem; min-height: 60vh; }

a { color: var(--link); text-decoration-thickness: 1px; text-underline-offset: 2px; }
a:hover { color: var(--accent); }

h1, h2, h3 { font-family: var(--serif); font-weight: 600; line-height: 1.25; }
h1 { font-size: 2.2rem; margin: 0 0 1rem; }
h2 { font-size: 1.5rem; margin: 2.5rem 0 .8rem; padding-bottom: .3rem; border-bottom: 1px solid var(--border); }
h3 { font-size: 1.15rem; margin: 1.8rem 0 .5rem; }
.lead { font-size: 1.15rem; color: var(--muted); max-width: 46em; }
.meta { color: var(--muted); font-size: .9rem; margin: 0; }
img { max-width: 100%; height: auto; }

/* Header */
.site-header { background: var(--surface); border-bottom: 3px solid var(--accent); }
.header-inner { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .5rem 2rem; padding-top: .9rem; padding-bottom: .9rem; }
.brand { text-decoration: none; color: var(--text); display: flex; flex-direction: column; }
.brand-name { font-family: var(--serif); font-size: 1.7rem; font-weight: 600; letter-spacing: .01em; line-height: 1.1; }
.brand-name span { color: var(--accent); }
.brand-tag { font-size: .78rem; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; }
.site-nav { display: flex; flex-wrap: wrap; gap: .2rem .9rem; }
.site-nav a { color: var(--text); text-decoration: none; font-size: .95rem; font-weight: 500; padding: .2rem 0; border-bottom: 2px solid transparent; }
.site-nav a:hover, .site-nav a.active { color: var(--accent); border-bottom-color: var(--accent); }
.site-nav { order: 2; }
.header-tools { order: 3; display: flex; align-items: center; gap: .5rem; }
.nav-toggle, .nav-toggle-label { display: none; }

/* Theme switcher */
.theme-toggle { display: inline-flex; align-items: center; justify-content: center; width: 2rem; height: 2rem; padding: 0; background: none; color: var(--muted); border: 1px solid var(--border); border-radius: 4px; cursor: pointer; }
.theme-toggle[hidden] { display: none; }
.theme-toggle:hover { color: var(--accent); border-color: var(--accent); }
.theme-toggle svg { width: 1.1rem; height: 1.1rem; display: none; }
.theme-toggle[data-mode="system"] .i-system,
.theme-toggle[data-mode="light"] .i-light,
.theme-toggle[data-mode="dark"] .i-dark { display: block; }
@media (max-width: 760px) {
  .header-tools { order: 1; }
  .site-nav { order: 3; }
  .nav-toggle-label { display: block; cursor: pointer; font-weight: 600; font-size: .9rem; border: 1px solid var(--border); padding: .25rem .7rem; border-radius: 4px; }
  .site-nav { display: none; width: 100%; flex-direction: column; gap: 0; }
  .site-nav a { padding: .5rem 0; border-bottom: 1px solid var(--border); }
  .nav-toggle:checked ~ .site-nav { display: flex; }
  h1 { font-size: 1.8rem; }
}

/* Footer */
.site-footer { border-top: 1px solid var(--border); background: var(--surface); color: var(--muted); font-size: .9rem; }
.footer-inner { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 1rem; padding-top: 1.5rem; padding-bottom: 1.5rem; }
.footer-links { text-align: right; }
@media (max-width: 760px) { .footer-links { text-align: left; } }

/* Hero on home page */
.hero { padding: 1rem 0 1.5rem; }
.hero h1 { font-size: 2.6rem; max-width: 18em; }
@media (max-width: 760px) { .hero h1 { font-size: 2rem; } }

/* Cards / grids */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 1rem; margin: 1rem 0; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 6px; padding: 1rem 1.1rem; }
.card h3 { margin: 0 0 .3rem; font-size: 1.05rem; }
.card p { margin: 0; color: var(--muted); font-size: .93rem; }
.tag { display: inline-block; background: var(--accent-soft); color: var(--accent); font-size: .72rem; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; padding: .1rem .45rem; border-radius: 3px; margin-bottom: .4rem; }

/* People */
.people { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: .6rem 1.2rem; list-style: none; padding: 0; }
.people li { padding: .35rem 0; border-bottom: 1px solid var(--border); }
.people .name { font-weight: 500; }
.people .note { display: block; color: var(--muted); font-size: .85rem; }

/* Tables (projects) */
table { width: 100%; border-collapse: collapse; font-size: .93rem; margin: 1rem 0; }
th, td { text-align: left; vertical-align: top; padding: .5rem .6rem; border-bottom: 1px solid var(--border); }
th { font-weight: 600; color: var(--muted); font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; }
.table-wrap { overflow-x: auto; }
td:first-child { white-space: nowrap; }

/* News list */
.news { list-style: none; padding: 0; }
.news li { display: flex; gap: 1rem; padding: .5rem 0; border-bottom: 1px solid var(--border); }
.news time { flex: 0 0 7.5rem; color: var(--muted); font-size: .9rem; padding-top: .1rem; }
@media (max-width: 760px) { .news li { flex-direction: column; gap: 0; } .news time { flex: none; } }

/* Language switch */
.site-nav a.lang-switch { color: var(--muted); font-weight: 600; font-size: .85rem; border: 1px solid var(--border); border-radius: 4px; padding: .15rem .55rem; align-self: center; }
.site-nav a.lang-switch:hover { color: var(--accent); border-color: var(--accent); }
@media (max-width: 760px) { .site-nav a.lang-switch { align-self: flex-start; margin-top: .6rem; } }

/* ---------- Awards ---------- */
:root {
  --c-paper: #1f5fa8;
  --c-competition: #b7791f;
  --c-thesis: #2f855a;
  --c-prize: #7b4fa8;
  --gold: #d4a514;
  --silver: #a3aab3;
  --bronze: #b8733d;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { --c-paper: #7fb0ef; --c-competition: #e3b25c; --c-thesis: #6fcf97; --c-prize: #c39be8; }
}
:root[data-theme="dark"] { --c-paper: #7fb0ef; --c-competition: #e3b25c; --c-thesis: #6fcf97; --c-prize: #c39be8; }

.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem; margin: 1.5rem 0 2rem; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: 6px; padding: 1rem 1.1rem; }
.stat-num { display: block; font-family: var(--serif); font-size: 2.2rem; font-weight: 600; line-height: 1.1; color: var(--accent); }
.stat-label { color: var(--muted); font-size: .9rem; }
.stat-sub { display: flex; align-items: center; gap: .35rem; margin-top: .15rem; font-weight: 600; color: var(--text); }
.stat-sub .medal-dot { --m: var(--gold); }
@media (max-width: 760px) { .stats { grid-template-columns: repeat(2, 1fr); } .stat-num { font-size: 1.8rem; } }

.award-filters { display: flex; flex-wrap: wrap; gap: .5rem; margin-bottom: 1.5rem; }
.award-filters[hidden] { display: none; }
.award-filters button { font: inherit; font-size: .88rem; font-weight: 500; color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: 999px; padding: .3rem .9rem; cursor: pointer; }
.award-filters button:hover { border-color: var(--accent); }
.award-filters button[aria-pressed="true"] { background: var(--text); color: var(--bg); border-color: var(--text); }

.award-year { display: grid; grid-template-columns: 5.5rem 1fr; gap: 1.5rem; padding: 1.25rem 0; border-top: 1px solid var(--border); }
.award-year[hidden] { display: none; }
.award-year-label { margin: 0; padding: 0; border: 0; font-size: 1.7rem; color: var(--muted); position: sticky; top: 1rem; align-self: start; }
.award-items { display: grid; gap: .9rem; }
@media (max-width: 760px) {
  .award-year { grid-template-columns: 1fr; gap: .6rem; }
  .award-year-label { position: static; font-size: 1.4rem; }
}

.award { --c: var(--muted); background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--c); border-radius: 6px; padding: .9rem 1.1rem; }
.award[hidden] { display: none; }
.award--paper { --c: var(--c-paper); }
.award--competition { --c: var(--c-competition); }
.award--thesis { --c: var(--c-thesis); }
.award--prize { --c: var(--c-prize); }
.award-meta { display: flex; flex-wrap: wrap; gap: .3rem .8rem; align-items: baseline; font-size: .78rem; text-transform: uppercase; letter-spacing: .06em; font-weight: 600; }
.award-type { color: var(--c); }
.award-venue { color: var(--muted); }
.award-title { margin: .25rem 0 .2rem; font-size: 1.12rem; }
.award-title a { color: inherit; text-decoration-color: var(--border); }
.award-title a:hover { color: var(--accent); }
.award-subject { margin: .1rem 0; font-family: var(--serif); font-style: italic; font-size: 1.02rem; }
.award-medals { display: flex; flex-wrap: wrap; gap: .4rem .8rem; align-items: center; margin: .45rem 0 .2rem; font-size: .88rem; }
.medal { display: inline-flex; align-items: center; gap: .35rem; font-weight: 600; }
.medal-dot { width: .8rem; height: .8rem; border-radius: 50%; background: var(--m); box-shadow: inset 0 -2px 0 rgba(0,0,0,.18); }
.medal--gold { --m: var(--gold); }
.medal--silver { --m: var(--silver); }
.medal--bronze { --m: var(--bronze); }
.award-wins { color: var(--muted); }
.award-people { margin: .3rem 0 0; color: var(--muted); font-size: .9rem; }
.award-note { margin: .3rem 0 0; font-size: .92rem; }

/* ---------- Publications ---------- */
.pub-tools { margin: 1rem 0 1.5rem; }
.pub-tools[hidden] { display: none; }
.pub-search { width: 100%; font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: 6px; padding: .55rem .8rem; margin-bottom: .8rem; }
.pub-search:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: transparent; }
.pub-filters { margin-bottom: .6rem; }
.pub-count { color: var(--muted); font-size: .9rem; margin: 0; }

.publications h2.bibliography { font-size: 1.5rem; color: var(--muted); margin: 2rem 0 .6rem; }
.publications h2[hidden], .publications ol[hidden], .publications li[hidden] { display: none; }
.publications ol.bibliography { list-style: none; padding: 0; margin: 0; }
.publications ol.bibliography > li { padding: .7rem 0; border-bottom: 1px solid var(--border); }
.pub-ref { font-size: .97rem; line-height: 1.55; }
.pub-ref strong { font-weight: 600; }
.pub-ref a { word-break: break-word; }
.pub-links { display: flex; flex-wrap: wrap; align-items: baseline; gap: .2rem .8rem; margin-top: .3rem; font-size: .82rem; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.pub-links a { text-decoration: none; }
.pub-links a:hover { text-decoration: underline; }
.pub-bibtex summary { cursor: pointer; color: var(--link); }
.pub-bibtex[open] { flex-basis: 100%; }
.pub-bibtex pre { text-transform: none; letter-spacing: 0; font-weight: 400; font-size: .8rem; line-height: 1.45; background: var(--surface); border: 1px solid var(--border); border-radius: 6px; padding: .7rem .9rem; overflow-x: auto; margin: .4rem 0 0; }
.pub-source { color: var(--muted); font-size: .88rem; margin-top: 2rem; }
