/* ==========================================================================
   StatsML site styles (Nov 2026 redesign)
   Loaded after Bootstrap 3 (components: navbar collapse, modal, forms) and the
   Bootstrap 5 grid (rows/cols/utilities). Replaces the old theme's style.css.
   ========================================================================== */

:root {
    --ink: #1b2430;          /* main text, dark surfaces */
    --ink-2: #4a5565;        /* secondary text */
    --ink-3: #6b7380;        /* tertiary text, captions */
    --line: #e4e1db;         /* borders, dividers */
    --bg: #ffffff;
    --bg-soft: #f7f5f1;      /* alternating sections (a nod to the old beige) */
    --brand: #e10600;        /* logo red: small accents only */
    --brand-ink: #b3141c;    /* red for text/links (AA on white) */
    --brand-tint: #fdecea;
    --radius: 10px;
    --shadow: 0 1px 2px rgba(27, 36, 48, .06), 0 4px 16px rgba(27, 36, 48, .06);
    --shadow-hover: 0 2px 4px rgba(27, 36, 48, .08), 0 10px 28px rgba(27, 36, 48, .10);
    --shadow-pop: 0 24px 60px rgba(27, 36, 48, .25);
    /* Theme tokens (redefined for dark mode at the end of this file) */
    --surface: #ffffff;      /* cards, panels, inputs */
    --solid: #1b2430;        /* filled buttons, active chips */
    --solid-hover: #2c394a;
    --on-solid: #ffffff;     /* text on --solid */
    --nav-bg: rgba(255, 255, 255, .96);
    --nav-shadow: 0 2px 12px rgba(27, 36, 48, .08);
    --footer-bg: #1b2430;
    --media-bg: #1b2430;     /* behind hero pictures/videos */
    --figure-bg: #ffffff;    /* behind diagrams, which often have transparent backgrounds */
    --photo-bg: #eceae6;     /* behind member photos */
    --code-bg: #f6f7f9;
    --input-border: #cfd4db;
    --focus-ring: rgba(27, 36, 48, .12);
    --backdrop: rgba(27, 36, 48, .5);
    --danger-line: #e7b9bc;
    --warn-bg: #fff1d6;
    --warn-ink: #8a5a00;
    --hidden-row: #fffaf0;
    --admin-badge: #fde8e9;
    --tile-1: #161d27; --tile-2: #1b2430; --tile-3: #222c3a; --tile-4: #293545; --tile-hover: #313f52;
    color-scheme: light;
    --serif: 'Source Serif 4', Georgia, 'Times New Roman', serif;
    --sans: 'Source Sans 3', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --nav-h: 72px;
}

/* ---------- Base ---------- */
html { font-size: 16px; -webkit-font-smoothing: antialiased; }
body {
    font-family: var(--sans);
    font-size: 1.0625rem;
    line-height: 1.65;
    color: var(--ink);
    background: var(--bg);
    padding-top: var(--nav-h);
    overflow-x: hidden;
}
h1, h2, h3, h4, h5, h6 {
    font-family: var(--serif);
    color: var(--ink);
    font-weight: 600;
    line-height: 1.25;
    letter-spacing: -0.01em;
    margin: 0 0 .5em;
}
h1 { font-size: clamp(2rem, 4vw, 2.75rem); }
h2 { font-size: clamp(1.6rem, 3vw, 2rem); }
h3 { font-size: 1.35rem; }
h4 { font-size: 1.125rem; }
p { margin: 0 0 1em; color: var(--ink); font-size: inherit; line-height: inherit; }
a { color: var(--brand-ink); text-decoration: none; transition: color .15s ease; }
a:hover, a:focus { color: var(--ink); text-decoration: underline; text-underline-offset: 3px; }
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
    outline: 2px solid var(--brand-ink);
    outline-offset: 2px;
}
strong, b { font-weight: 600; }
img { max-width: 100%; }
::selection { background: var(--brand-tint); }

.wrap { width: 100%; max-width: 1180px; margin: 0 auto; padding: 0 24px; }
.wrap-narrow { max-width: 860px; }
.section { padding: 72px 0; }
.section-soft { background: var(--bg-soft); }
.section + .section:not(.section-soft) { border-top: 1px solid var(--line); }
.muted { color: var(--ink-2); }
.small-caps {
    font-family: var(--sans);
    font-size: .8125rem;
    font-weight: 600;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--brand-ink);
}
.section-head { display: flex; align-items: baseline; gap: 12px; margin-bottom: 28px; flex-wrap: wrap; }
.section-head h2 { margin: 0; }
.section-head .count { color: var(--ink-3); font-family: var(--sans); font-size: .95rem; }

/* ---------- Buttons ---------- */
.btn-solid, .btn-ghost {
    display: inline-flex; align-items: center; gap: .5em;
    font-family: var(--sans); font-weight: 600; font-size: 1rem;
    padding: .7em 1.3em; border-radius: 999px; border: 1.5px solid transparent;
    cursor: pointer; transition: background .15s, color .15s, border-color .15s;
    text-decoration: none !important; line-height: 1.2;
}
.btn-solid { background: var(--solid); color: var(--on-solid); }
.btn-solid:hover, .btn-solid:focus { background: var(--brand-ink); color: var(--on-brand, #fff); }
.btn-ghost { background: transparent; color: var(--ink); border-color: var(--ink); }
.btn-ghost:hover, .btn-ghost:focus { background: var(--solid); border-color: var(--solid); color: var(--on-solid); }
.link-arrow { font-weight: 600; }
.link-arrow::after { content: ' \2192'; }

/* ---------- Navbar ---------- */
.site-nav {
    position: fixed; top: 0; left: 0; right: 0; z-index: 1030;
    height: var(--nav-h);
    background: var(--nav-bg);
    backdrop-filter: saturate(160%) blur(8px);
    border-bottom: 1px solid var(--line);
    transition: box-shadow .2s;
}
.site-nav.is-scrolled { box-shadow: var(--nav-shadow); }
.site-nav .wrap { height: 100%; display: flex; align-items: center; justify-content: space-between; gap: 24px;
    max-width: none; padding: 0 clamp(16px, 3vw, 40px); }   /* navbar spans the full viewport */
.site-brand { display: flex; align-items: center; gap: 14px; text-decoration: none !important; }
.site-brand img { height: 44px; width: auto; display: block; }
.site-brand-text { display: flex; flex-direction: column; line-height: 1.2; border-left: 1px solid var(--line); padding-left: 14px; }
.site-brand-text b { font-family: var(--sans); font-size: .9rem; color: var(--ink); font-weight: 600; }
.site-brand-text span { font-size: .78rem; color: var(--ink-3); line-height: 1.3; white-space: nowrap; }
.site-menu { display: flex; align-items: center; gap: 4px; list-style: none; margin: 0; padding: 0; }
.site-menu a {
    display: block; padding: 8px 14px; white-space: nowrap; border-radius: 8px;
    color: var(--ink-2); font-weight: 500; font-size: 1rem; text-decoration: none !important;
}
.site-menu a:hover { color: var(--ink); background: var(--bg-soft); }
.site-menu li.active > a { color: var(--ink); box-shadow: inset 0 -2px 0 var(--brand); border-radius: 0; }
.site-menu .menu-admin a { color: var(--brand-ink); }
.nav-toggle {
    display: none; background: none; border: 0; padding: 10px; margin-right: -10px; cursor: pointer;
}
.nav-toggle span { display: block; width: 22px; height: 2px; background: var(--ink); margin: 5px 0; border-radius: 2px; }

/* The three-line subtitle needs room; below this width only the logo is shown */
@media (max-width: 1140px) {
    .site-brand-text { display: none; }
}
@media (max-width: 991px) {
    .nav-toggle { display: block; }
    .site-menu-wrap {
        position: absolute; top: var(--nav-h); left: 0; right: 0;
        background: var(--surface); border-bottom: 1px solid var(--line);
        box-shadow: var(--nav-shadow);
        display: none;
    }
    .site-menu-wrap.open { display: block; }
    .site-menu { flex-direction: column; align-items: stretch; padding: 8px 16px 16px; }
    .site-menu a { padding: 12px 8px; }
    .site-menu li.active > a { box-shadow: inset 3px 0 0 var(--brand); padding-left: 14px; }
}

/* ---------- Page header (inner pages) ---------- */
.page-head { background: var(--bg-soft); border-bottom: 1px solid var(--line); padding: 56px 0 44px; }
.page-head h1 { margin: 6px 0 10px; }
.page-head p { color: var(--ink-2); max-width: 720px; margin: 0; font-size: 1.125rem; }

/* ---------- Home: hero ---------- */
.hero { display: grid; grid-template-columns: 1fr 1fr; min-height: min(78vh, 720px); background: var(--bg-soft); border-bottom: 1px solid var(--line); }
.hero-media { position: relative; overflow: hidden; background: var(--media-bg); min-height: 320px; }
.hero-media img, .hero-media video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block; }
.hero-body { display: flex; flex-direction: column; justify-content: center; padding: 56px clamp(24px, 6vw, 88px); }
.hero-body h1 { font-size: clamp(2.1rem, 3.6vw, 3.1rem); margin: 10px 0 18px; }
.hero-body .lead { font-size: 1.2rem; color: var(--ink-2); max-width: 34em; margin-bottom: 28px; }
.hero-actions { display: flex; gap: 12px; flex-wrap: wrap; }
@media (max-width: 860px) {
    .hero { grid-template-columns: 1fr; min-height: 0; }
    .hero-media { height: 46vh; }
    .hero-body { padding: 40px 24px 48px; }
}

/* Video hero: the video column takes the video's own shape (6:5, 1440x1200), as wide as half the
   screen but never taller than the window below the navbar, so nothing is cropped on wide screens.
   The video sits in the normal flow (not absolutely positioned) so its own height sizes the row in
   every browser; Safari mis-sized a box whose height came only from aspect-ratio (it spilled up
   under the navbar). Letterbox colour = the video's background (#161d27). */
.hero.hero-has-video { grid-template-columns: min(50%, calc((100vh / var(--page-zoom, 1) - var(--nav-h)) * 1.2)) 1fr; min-height: 0; align-items: center; }
.hero-has-video .hero-media { min-height: 0; background: #161d27; }
.hero-has-video .hero-media video { position: relative; inset: auto; width: 100%; height: auto; aspect-ratio: 6 / 5; object-fit: contain; }
@media (max-width: 860px) {
    .hero.hero-has-video { grid-template-columns: 1fr; }
    .hero-has-video .hero-media { height: auto; }
    .hero-has-video .hero-media video { max-height: 70vh; }
}

/* ---------- Home: stats strip ---------- */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.stat { padding: 24px 28px; border-left: 1px solid var(--line); }
.stat:first-child { border-left: 0; }
.stat b { display: block; font-family: var(--serif); font-size: 2.25rem; line-height: 1.1; color: var(--ink); }
.stat span { color: var(--ink-2); font-size: .95rem; }
@media (max-width: 760px) {
    .stats { grid-template-columns: repeat(2, 1fr); }
    .stat:nth-child(3) { border-left: 0; }
    .stat:nth-child(n+3) { border-top: 1px solid var(--line); }
}

/* ---------- Home: news ---------- */
.news-list { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line); }
.news-item { display: grid; grid-template-columns: 110px 1fr; gap: 24px; padding: 18px 0; border-bottom: 1px solid var(--line); }
.news-item time { color: var(--ink-3); font-size: .95rem; font-variant-numeric: tabular-nums; padding-top: 1px; white-space: nowrap; }
.news-item p { margin: 0; }
.news-list .is-extra { display: none; }
.news-list.show-all .is-extra { display: grid; }
.news-more { margin-top: 20px; background: none; border: 0; padding: 0; color: var(--brand-ink); font-weight: 600; cursor: pointer; }
.news-more:hover { color: var(--ink); text-decoration: underline; }
@media (max-width: 600px) { .news-item { grid-template-columns: 1fr; gap: 2px; } }

/* ---------- Members ---------- */
.people-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 24px; }
.person {
    background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
    overflow: hidden; display: flex; flex-direction: column;
    box-shadow: var(--shadow); transition: box-shadow .2s, transform .2s;
}
.person:hover { box-shadow: var(--shadow-hover); transform: translateY(-2px); }
.person-photo { aspect-ratio: 4 / 4.4; background: var(--photo-bg); position: relative; }
.person-photo img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: 50% 22%; }
.person-avatar { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: #fff; font-family: var(--serif); font-size: 3.25rem; letter-spacing: .04em; }
.person-body { padding: 16px 18px 18px; display: flex; flex-direction: column; flex: 1; }
.person-name { font-family: var(--sans); font-size: 1.1rem; font-weight: 600; margin: 0 0 2px; }
.person-meta { color: var(--ink-3); font-size: .9rem; margin: 0 0 10px; word-break: break-word; }
.person-bio { color: var(--ink-2); font-size: .95rem; line-height: 1.55; margin: 0;
    display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; }
.person-bio.expanded { display: block; -webkit-line-clamp: unset; }
.bio-toggle { align-self: flex-start; margin-top: 8px; background: none; border: 0; padding: 0; color: var(--brand-ink); font-weight: 600; font-size: .9rem; cursor: pointer; }
.bio-toggle:hover { color: var(--ink); text-decoration: underline; }
.person-links { margin-top: auto; padding-top: 12px; }
.chip {
    display: inline-flex; align-items: center; gap: 6px;
    font-size: .85rem; font-weight: 600; padding: 4px 10px; border-radius: 999px;
    background: var(--bg-soft); color: var(--ink-2); border: 1px solid var(--line);
}
a.chip:hover { background: var(--solid); color: var(--on-solid); border-color: var(--solid); text-decoration: none; }

/* Faculty: horizontal card */
.person-wide { flex-direction: row; max-width: 900px; }
.person-wide .person-photo { aspect-ratio: auto; width: 260px; flex: 0 0 260px; min-height: 300px; }
.person-wide .person-body { padding: 28px 32px; }
.person-wide .person-name { font-family: var(--serif); font-size: 1.6rem; }
.person-wide .person-bio { font-size: 1.05rem; -webkit-line-clamp: unset; display: block; }
@media (max-width: 640px) {
    .person-wide { flex-direction: column; }
    .person-wide .person-photo { width: 100%; flex-basis: auto; aspect-ratio: 4 / 3.6; min-height: 0; }
}

/* Alumni list (modal + inline) */
.alumni-year { font-family: var(--sans); font-size: .85rem; font-weight: 700; letter-spacing: .08em; color: var(--ink-3); text-transform: uppercase; margin: 18px 0 6px; }
.alumni-year:first-child { margin-top: 0; }
.alumni-names { list-style: none; margin: 0; padding: 0; columns: 2; column-gap: 32px; }
.alumni-names li { padding: 3px 0; break-inside: avoid; }
@media (max-width: 560px) { .alumni-names { columns: 1; } }

/* ---------- Publications ---------- */
.year-nav { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 22px; }
.year-nav a { font-size: .9rem; font-weight: 600; padding: 4px 12px; border-radius: 999px; background: var(--surface); border: 1px solid var(--line); color: var(--ink-2); text-decoration: none; }
.year-nav a:hover { background: var(--solid); border-color: var(--solid); color: var(--on-solid); }
.pub-year { display: grid; grid-template-columns: 120px 1fr; gap: 32px; padding: 36px 0; border-top: 1px solid var(--line); scroll-margin-top: calc(var(--nav-h) + 16px); }
.pub-year:first-child { border-top: 0; padding-top: 0; }
.pub-year > h2 { font-size: 1.75rem; color: var(--ink-3); position: sticky; top: calc(var(--nav-h) + 24px); align-self: start; margin: 0; }
.pub-list { list-style: none; margin: 0; padding: 0; }
.pub { padding: 0 0 22px; margin-bottom: 22px; border-bottom: 1px dashed var(--line); }
.pub:last-child { border-bottom: 0; margin-bottom: 0; padding-bottom: 0; }
.pub-title { font-family: var(--serif); font-size: 1.2rem; font-weight: 600; line-height: 1.35; margin: 0 0 6px; }
.pub-title button { all: unset; cursor: pointer; color: var(--ink); }
.pub-title button:hover, .pub-title button:focus-visible { color: var(--brand-ink); text-decoration: underline; text-underline-offset: 3px; }
.pub-authors { color: var(--ink-2); margin: 0 0 4px; font-size: 1rem; }
.pub-venue { color: var(--ink-3); font-style: italic; margin: 0; font-size: .98rem; }
@media (max-width: 760px) {
    .pub-year { grid-template-columns: 1fr; gap: 12px; }
    .pub-year > h2 { position: static; }
}

/* ---------- Research / project cards ---------- */
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 28px; }
.card {
    display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--line);
    border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow);
    color: var(--ink); text-decoration: none !important; transition: box-shadow .2s, transform .2s;
}
.card:hover { box-shadow: var(--shadow-hover); transform: translateY(-2px); color: var(--ink); }
.card-media { aspect-ratio: 16 / 10; background: var(--figure-bg); border-bottom: 1px solid var(--line); overflow: hidden; }
.card-media img { width: 100%; height: 100%; object-fit: cover; display: block; }
.card-media.contain img { object-fit: contain; padding: 12px; }
.card-body { padding: 20px 22px 22px; display: flex; flex-direction: column; flex: 1; }
.card-body h3 { font-size: 1.2rem; margin-bottom: 8px; }
.card-body p { color: var(--ink-2); font-size: .98rem; margin-bottom: 14px; }
.card-body .link-arrow { margin-top: auto; color: var(--brand-ink); }

/* ---------- Courses ---------- */
.course-year { display: grid; grid-template-columns: 120px 1fr; gap: 32px; padding: 28px 0; border-top: 1px solid var(--line); }
.course-year:first-child { border-top: 0; padding-top: 0; }
.course-year > h2 { font-size: 1.5rem; color: var(--ink-3); margin: 0; }
.course-list { list-style: none; margin: 0; padding: 0; }
.course { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; padding: 10px 0; border-bottom: 1px dashed var(--line); }
.course:last-child { border-bottom: 0; }
.course-name { font-weight: 600; font-size: 1.08rem; }
.course-code { color: var(--ink-3); font-variant-numeric: tabular-nums; white-space: nowrap; font-size: .95rem; }
.course-name a { color: var(--ink); }
.course-name a:hover { color: var(--brand-ink); }
.course-name .no-link { color: var(--ink-3); font-weight: 500; }
@media (max-width: 760px) { .course-year { grid-template-columns: 1fr; gap: 6px; } }

/* ---------- Openings ---------- */
.prose { font-size: 1.0625rem; }
.prose h2 { margin-top: 1.6em; }
.prose ul, .prose ol { padding-left: 1.3em; margin: 0 0 1.2em; }
.prose li { margin: .35em 0; color: var(--ink); }
.role-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 28px 32px; margin-bottom: 24px; box-shadow: var(--shadow); }
.role-card h2 { margin-top: 0; font-size: 1.5rem; }
.role-card h3 { font-family: var(--sans); font-size: .85rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-3); margin: 0 0 8px; }
.callout { background: var(--bg-soft); border-left: 3px solid var(--brand); padding: 18px 22px; border-radius: 0 var(--radius) var(--radius) 0; margin: 28px 0; }
.callout p:last-child { margin-bottom: 0; }

/* ---------- Footer ---------- */
.site-footer { background: var(--footer-bg); color: #c9ced6; padding: 56px 0 28px; margin-top: 0; }
.site-footer a { color: #fff; }
.site-footer a:hover { color: #fff; }
.footer-grid { display: grid; grid-template-columns: 1.4fr 1fr 1fr; gap: 40px; }
.footer-grid img { height: 46px; width: auto; margin-bottom: 14px; }
.footer-grid h4 { color: #fff; font-family: var(--sans); font-size: .85rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; margin-bottom: 12px; }
.footer-grid p, .footer-grid li { color: #c9ced6; font-size: .95rem; line-height: 1.7; margin: 0; }
.footer-grid ul { list-style: none; padding: 0; margin: 0; }
.footer-bottom { border-top: 1px solid rgba(255, 255, 255, .12); margin-top: 40px; padding-top: 20px; display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; font-size: .85rem; color: #9aa3ae; }
.footer-bottom a { color: #c9ced6; }
@media (max-width: 760px) { .footer-grid { grid-template-columns: 1fr; gap: 28px; } }

/* ---------- Modals (Bootstrap 3) ---------- */
.modal-content { border-radius: 14px; border: 0; box-shadow: var(--shadow-pop); background: var(--surface); color: var(--ink); }
.modal-header { padding: 20px 28px; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; }
.modal-header::before, .modal-header::after { display: none; }
.modal-title { font-family: var(--serif); font-size: 1.35rem; font-weight: 600; margin: 0; color: var(--ink); }
.modal-header .close { margin: 0; font-size: 1.8rem; opacity: .5; }
.modal-body { padding: 24px 28px; }
.modal-footer { padding: 16px 28px; border-top: 1px solid var(--line); }
.modal-backdrop.in { opacity: .45; }
.paper-modal-title { font-family: var(--serif); font-size: 1.45rem; line-height: 1.3; margin: 0 0 10px; }
.paper-modal-authors { color: var(--ink-2); margin-bottom: 16px; }
.paper-modal-links { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 20px; }
.paper-modal-abstract { color: var(--ink); line-height: 1.7; }
.paper-modal-label { font-family: var(--sans); font-size: .8rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-3); margin: 0 0 6px; }

/* ---------- Forms (login + admin) ---------- */
.form-label { display: block; font-weight: 600; font-size: .92rem; color: var(--ink-2); margin-bottom: 6px; }
.form-control {
    height: auto; padding: 10px 12px; font-size: 1rem; color: var(--ink);
    border: 1px solid var(--input-border); border-radius: 8px; box-shadow: none; background-color: var(--surface);
    font-family: var(--sans);
}
.form-control:focus { border-color: var(--ink-2); box-shadow: 0 0 0 3px var(--focus-ring); }
textarea.form-control { line-height: 1.5; }
.input-group-addon { border-color: var(--input-border); color: var(--ink-2); background: var(--bg-soft); border-radius: 0 8px 8px 0; }
.input-group .form-control:first-child { border-radius: 8px 0 0 8px; }
.alert { border-radius: 8px; }

.login-wrap { min-height: calc(100vh - var(--nav-h) - 260px); display: flex; align-items: center; justify-content: center; padding: 64px 24px; background: var(--bg-soft); }
.login-card { width: 100%; max-width: 400px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 36px 32px; box-shadow: var(--shadow); }
.login-card h1 { font-size: 1.75rem; margin-bottom: 4px; }
.login-card .muted { margin-bottom: 24px; }
.login-card .form-control { margin-bottom: 16px; }
.login-card .btn-solid { width: 100%; justify-content: center; border-radius: 8px; }

/* ---------- Admin (styles Bootstrap 3 panels/buttons in the admin view) ---------- */
.admin-page { background: var(--bg-soft); padding: 40px 0 72px; min-height: 70vh; }
.admin-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 28px; }
.admin-head h1 { margin: 0; font-size: 1.9rem; }
.admin-head .muted { margin: 2px 0 0; }
.admin-page .panel-group { margin: 0; }
.admin-page .panel {
    border: 1px solid var(--line); border-radius: var(--radius) !important; box-shadow: var(--shadow);
    margin-bottom: 16px !important; overflow: hidden; background: var(--surface);
}
.admin-page .panel-heading { background: var(--surface); border: 0; padding: 0; }
.admin-page .panel-title { font-family: var(--sans); font-size: 1.1rem; font-weight: 600; letter-spacing: 0; text-transform: none; margin: 0; padding: 0; }
.admin-page .panel-title > a, .admin-page .panel-title .accordion-toggle {
    display: flex; justify-content: space-between; align-items: center;
    padding: 18px 24px; color: var(--ink); text-decoration: none;
}
.admin-page .panel-title .accordion-toggle::after { content: '\25BE'; color: var(--ink-3); transition: transform .2s; }
.admin-page .panel-heading:hover .accordion-toggle { background: var(--bg-soft); }
.admin-page .panel-collapse.in ~ * { }
.admin-page .panel-body { border-top: 1px solid var(--line) !important; padding: 24px; text-align: left !important; }
.admin-page .panel-body h3 { font-family: var(--sans); font-size: 1.05rem; font-weight: 700; text-align: left !important; margin: 0 0 14px; }
.admin-page .panel-body h3 small { font-weight: 400; color: var(--ink-3); }
.admin-page .panel-body hr { border-color: var(--line); margin: 28px 0; }
.admin-page .panel-body > .row > [class*="col-"] { margin-bottom: 12px; }
.admin-page .btn { border-radius: 8px; font-weight: 600; padding: 9px 16px; font-size: .95rem; border-width: 1.5px; }
.admin-page .btn-primary { background: var(--solid); border-color: var(--solid); color: var(--on-solid); }
.admin-page .btn-primary:hover, .admin-page .btn-primary:focus { background: var(--solid-hover); border-color: var(--solid-hover); color: var(--on-solid); }
.admin-page .btn-danger { background: var(--surface); color: var(--brand-ink); border-color: var(--danger-line); }
.admin-page .btn-danger:hover, .admin-page .btn-danger:focus { background: var(--brand-ink); color: var(--on-brand, #fff); border-color: var(--brand-ink); }
.admin-page .mb-3 { margin-bottom: 12px !important; }
.admin-note { color: var(--ink-3); font-size: .95rem; margin: 0; }
.admin-row { padding: 14px 0; border-bottom: 1px solid var(--line); }
.admin-row.is-hidden { background: var(--hidden-row); margin: 0 -24px; padding: 14px 24px; }
.news-edit { display: grid; grid-template-columns: 150px 1fr auto; gap: 14px; align-items: start; }
.news-edit > form { display: none; }
.news-visible { display: flex; align-items: center; gap: 6px; font-weight: 400; margin: 8px 0 0; font-size: .92rem; }
.news-visible input { margin: 0; }
.news-actions { display: flex; flex-direction: column; gap: 8px; }
@media (max-width: 760px) {
    .news-edit { grid-template-columns: 1fr; }
    .news-actions { flex-direction: row; }
}
.badge-hidden { display: inline-block; font-size: .75rem; font-weight: 700; background: var(--warn-bg); color: var(--warn-ink); border-radius: 999px; padding: 1px 8px; margin-left: 4px; }

/* ---------- Utilities ---------- */
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
}

/* ---------- Research post ---------- */
.post-head { background: var(--bg-soft); border-bottom: 1px solid var(--line); padding: 44px 0 36px; }
.post-crumb { margin: 0 0 18px; font-size: .95rem; }
.post-crumb a { color: var(--ink-2); }
.post-head h1 { font-size: clamp(1.9rem, 3.4vw, 2.6rem); margin: 6px 0 14px; }
.post-summary { font-size: 1.2rem; color: var(--ink-2); margin-bottom: 16px; }
.post-meta { display: flex; flex-wrap: wrap; gap: 6px 18px; color: var(--ink-3); font-size: .98rem; margin-bottom: 20px; }
.post-meta span + time::before { content: ''; }
.post-cover { margin: 36px 0 0; }
.post-cover img { width: 100%; border-radius: var(--radius); border: 1px solid var(--line); background: var(--figure-bg); }
.post-body { padding: 40px 0 80px; font-size: 1.1rem; line-height: 1.75; }
.post-body > :first-child { margin-top: 0; }
.post-body h2 { font-size: 1.6rem; margin: 2em 0 .6em; }
.post-body h3 { font-size: 1.25rem; margin: 1.6em 0 .5em; }
.post-body p, .post-body ul, .post-body ol { margin: 0 0 1.15em; }
.post-body ul, .post-body ol { padding-left: 1.4em; }
.post-body li { margin: .3em 0; }
.post-body img, .post-body video, .post-body iframe { max-width: 100%; height: auto; border-radius: 8px; display: block; margin: 0 auto; }
.post-body figure { margin: 2em 0; text-align: center; }
.post-body figure img, .post-body figure video { border: 1px solid var(--line); background: var(--figure-bg); }
.post-body figcaption { color: var(--ink-3); font-size: .95rem; margin-top: 10px; line-height: 1.5; }
.post-body blockquote { margin: 1.5em 0; padding: 4px 0 4px 20px; border-left: 3px solid var(--brand); color: var(--ink-2); }
.post-body code { font-size: .9em; background: var(--bg-soft); border: 1px solid var(--line); border-radius: 4px; padding: 1px 5px; color: var(--ink); }
.post-body pre { background: var(--code-bg); border: 1px solid var(--line); border-radius: 8px; padding: 16px 18px; overflow-x: auto; font-size: .92rem; line-height: 1.55; }
.post-body pre code { background: none; border: 0; padding: 0; font-size: inherit; }
.post-body .table-wrap { overflow-x: auto; margin: 1.5em 0; }
.post-body table { width: 100%; border-collapse: collapse; font-size: .98rem; }
.post-body th, .post-body td { border-bottom: 1px solid var(--line); padding: 8px 12px; text-align: left; }
.post-body th { font-weight: 600; background: var(--bg-soft); }
.post-body hr { border: 0; border-top: 1px solid var(--line); margin: 2.5em 0; }
.post-body mjx-container[display="true"] { overflow-x: auto; overflow-y: hidden; padding: 4px 0; }
.post-body .video-grid { display: grid; grid-template-columns: 1fr; gap: 20px; margin: 2em 0; }
.post-body .video-grid figure { margin: 0; }

/* ---------- Admin: post editor ---------- */
.editor-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; align-items: start; }
.editor-grid textarea { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .92rem; line-height: 1.55; min-height: 560px; }
.editor-preview { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 8px 24px; max-height: 760px; overflow: auto; }
.editor-preview .post-body { padding: 16px 0; font-size: 1rem; }
.editor-meta { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px 20px; margin-bottom: 20px; }
.editor-meta .full { grid-column: 1 / -1; }
.editor-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-top: 20px; }
.editor-help { font-size: .9rem; color: var(--ink-3); }
.editor-help code { font-size: .85rem; }
.post-table { width: 100%; border-collapse: collapse; }
.post-table td, .post-table th { padding: 12px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.post-table th { font-size: .85rem; color: var(--ink-3); font-weight: 600; text-transform: uppercase; letter-spacing: .06em; }
.upload-box { border: 1.5px dashed var(--input-border); border-radius: 8px; padding: 14px 16px; background: var(--bg-soft); }
.upload-result { margin-top: 10px; font-size: .9rem; word-break: break-all; }
@media (max-width: 991px) { .editor-grid, .editor-meta { grid-template-columns: 1fr; } }
.admin-link { display: flex !important; justify-content: space-between; align-items: center; padding: 18px 24px; color: var(--ink); text-decoration: none !important; }
.admin-link:hover { background: var(--bg-soft) !important; color: var(--ink); }
.admin-link .link-arrow { color: var(--brand-ink); }

/* ---------- Admin frame ---------- */
.admin-bar { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; margin-bottom: 28px; border-bottom: 1px solid var(--line); }
.admin-tabs { display: flex; gap: 2px; flex-wrap: wrap; }
.admin-tabs a { padding: 10px 14px; color: var(--ink-2); font-weight: 600; font-size: .95rem; text-decoration: none !important; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.admin-tabs a:hover { color: var(--ink); }
.admin-tabs a.active { color: var(--ink); border-bottom-color: var(--brand); }
.admin-user { font-size: .9rem; color: var(--ink-3); padding-bottom: 8px; }
.admin-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 24px; margin-bottom: 20px; }
.admin-card > h2 { font-family: var(--sans); font-size: 1.1rem; font-weight: 700; margin: 0 0 16px; }
.admin-card > h2 small { font-weight: 400; color: var(--ink-3); font-size: .9rem; }
.admin-title { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.admin-title h1 { margin: 0; font-size: 1.8rem; }
.admin-title p { margin: 4px 0 0; color: var(--ink-2); }
.admin-title .actions { display: flex; gap: 10px; flex-wrap: wrap; }
.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px 20px; }
.form-grid .full { grid-column: 1 / -1; }
.form-grid .form-control { width: 100%; }
.field-help { font-size: .85rem; color: var(--ink-3); margin: 5px 0 0; }
.check { display: flex; align-items: center; gap: 8px; font-weight: 500; margin: 0; }
.check input { margin: 0; width: 18px; height: 18px; }
.form-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-top: 20px; }
.danger-zone { margin-top: 28px; padding-top: 20px; border-top: 1px solid var(--line); }
.btn-danger-text { background: none; border: 1.5px solid var(--danger-line); color: var(--brand-ink); border-radius: 8px; padding: 8px 14px; font-weight: 600; cursor: pointer; }
.btn-danger-text:hover { background: var(--brand-ink); border-color: var(--brand-ink); color: var(--on-brand, #fff); }
.data-table { width: 100%; border-collapse: collapse; }
.data-table th { font-size: .78rem; color: var(--ink-3); font-weight: 700; text-transform: uppercase; letter-spacing: .06em; text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); }
.data-table td { padding: 12px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
.data-table tr:last-child td { border-bottom: 0; }
.data-table .t-main { font-weight: 600; color: var(--ink); }
.data-table .t-sub { font-size: .88rem; color: var(--ink-3); margin-top: 2px; }
.data-table .t-actions { text-align: right; white-space: nowrap; }
.data-table a.t-main:hover { color: var(--brand-ink); }
.btn-small { display: inline-block; padding: 5px 12px; border-radius: 7px; font-size: .88rem; font-weight: 600; border: 1.5px solid var(--line); color: var(--ink); background: var(--surface); text-decoration: none !important; cursor: pointer; }
.btn-small:hover { border-color: var(--ink-2); }
.btn-small.primary { background: var(--solid); border-color: var(--solid); color: var(--on-solid); }
.btn-small.primary:hover { background: var(--solid-hover); border-color: var(--solid-hover); }
.table-filter { max-width: 360px; margin-bottom: 14px; }
.dash-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 18px; }
.dash-card { display: flex; flex-direction: column; gap: 6px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 22px; color: var(--ink); text-decoration: none !important; transition: box-shadow .2s, transform .2s; }
.dash-card:hover { box-shadow: var(--shadow-hover); transform: translateY(-2px); color: var(--ink); }
.dash-card h2 { font-family: var(--sans); font-size: 1.1rem; font-weight: 700; margin: 0; }
.dash-card .big { font-family: var(--serif); font-size: 2rem; line-height: 1.1; }
.dash-card p { color: var(--ink-2); font-size: .95rem; margin: 0; }
.dash-card .link-arrow { color: var(--brand-ink); margin-top: auto; padding-top: 8px; font-size: .95rem; }
.status-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; vertical-align: middle; }
.status-dot.on { background: #2e9e5b; } .status-dot.off { background: #c4c9d0; }
.thumb { width: 44px; height: 44px; border-radius: 50%; object-fit: cover; background: var(--photo-bg); display: inline-block; vertical-align: middle; }
.member-row { display: flex; align-items: center; gap: 12px; }
@media (max-width: 760px) { .form-grid { grid-template-columns: 1fr; } .data-table .hide-sm { display: none; } }

/* Alumni lines: name + programme/years */
.alumni-names .alumni-name { font-weight: 500; }
.alumni-names .alumni-meta { display: block; font-size: .85rem; color: var(--ink-3); line-height: 1.4; }
.alumni-names li { padding: 5px 0; }

/* ---------- Member profile dialog ("Read more") ---------- */

.people-grid { align-items: stretch; }
.person-dialog {
    width: min(760px, calc(100vw - 32px)); max-height: calc(100vh - 48px);
    padding: 0; border: 0; border-radius: 14px; overflow: hidden;
    box-shadow: var(--shadow-pop); color: var(--ink);
}
.person-dialog[open] { display: grid; grid-template-columns: 240px 1fr; animation: dialog-in .18s ease-out; }
.person-dialog::backdrop { background: var(--backdrop); }
@keyframes dialog-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.person-dialog-photo { position: relative; background: var(--photo-bg); min-height: 280px; }
.person-dialog-photo img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: 50% 22%; }
.person-dialog-photo .person-avatar { position: absolute; inset: 0; }
.person-dialog-body { padding: 32px 36px 32px 32px; overflow-y: auto; max-height: calc(100vh - 48px); }
.person-dialog-name { font-size: 1.6rem; margin: 0 0 4px; padding-right: 32px; }
.person-dialog-meta { color: var(--ink-3); font-size: .95rem; margin: 0 0 18px; }
.person-dialog-meta:empty { display: none; }
.person-dialog-bio p { font-size: 1.05rem; line-height: 1.7; color: var(--ink-2); margin: 0; }
.person-dialog-links:not(:empty) { margin-top: 20px; }
.person-dialog-close {
    position: absolute; top: 12px; right: 14px; z-index: 2;
    width: 36px; height: 36px; border: 0; border-radius: 50%;
    background: var(--nav-bg); color: var(--ink); font-size: 1.6rem; line-height: 1; cursor: pointer;
}
.person-dialog-close:hover { background: var(--bg-soft); }
@media (max-width: 640px) {
    .person-dialog[open] { grid-template-columns: 1fr; overflow-y: auto; }
    .person-dialog-photo { min-height: 0; aspect-ratio: 4 / 3; }
    .person-dialog-body { max-height: none; padding: 24px; }
}

/* ---------- Home: four-way explore strip (full width) ----------
   One tonal family: four steps of the site's navy ink, darkest on the left,
   with the logo red only as a thin accent line that grows on hover. */
.explore-grid { display: grid; grid-template-columns: repeat(4, 1fr); }
.explore-tile {
    --tile: var(--ink);
    position: relative;
    display: flex; flex-direction: column; gap: 8px;
    padding: 44px clamp(24px, 3vw, 48px) 40px;
    background: var(--tile); color: #fff; text-decoration: none !important;
    border-left: 1px solid rgba(255, 255, 255, .08);
    transition: background-color .2s ease;
}
.explore-tile:first-child { border-left: 0; }
.explore-tile::before {
    content: ''; position: absolute; left: 0; top: 0; height: 3px; width: 48px;
    background: var(--brand); transition: width .25s ease;
}
.explore-tile:hover::before, .explore-tile:focus-visible::before { width: 100%; }
.explore-tile.t-research { --tile: var(--tile-1); }
.explore-tile.t-papers   { --tile: var(--tile-2); }
.explore-tile.t-people   { --tile: var(--tile-3); }
.explore-tile.t-teaching { --tile: var(--tile-4); }
.explore-tile:hover, .explore-tile:focus-visible { background: var(--tile-hover); color: #fff; }
.explore-tile:focus-visible { outline: 3px solid #fff; outline-offset: -6px; }
.explore-tile i { font-size: 1.6rem; color: #f1a7a9; margin-bottom: 6px; }
.explore-tile h2 { font-size: 1.4rem; margin: 0; color: #fff; }
.explore-tile p { color: rgba(255, 255, 255, .78); font-size: .98rem; margin: 0; }
.explore-tile .link-arrow { margin-top: auto; padding-top: 12px; color: #fff; font-size: .95rem; font-weight: 600; }
.explore-tile .link-arrow::after { display: inline-block; margin-left: 6px; transition: transform .2s ease; }
.explore-tile:hover .link-arrow::after { transform: translateX(4px); }
@media (max-width: 960px) {
    .explore-grid { grid-template-columns: repeat(2, 1fr); }
    .explore-tile:nth-child(3) { border-left: 0; }
    .explore-tile:nth-child(n+3) { border-top: 1px solid rgba(255, 255, 255, .08); }
}
@media (max-width: 560px) {
    /* Phones: compact 2x2 grid, icon + title only */
    .explore-tile { padding: 22px 18px; gap: 4px; }
    .explore-tile p, .explore-tile .link-arrow { display: none; }
    .explore-tile i { font-size: 1.35rem; margin-bottom: 2px; }
    .explore-tile h2 { font-size: 1.1rem; }
}


/* ---------- Half-and-half page headers (Research, Publications, Courses, Openings, posts) ---------- */
.page-hero { min-height: min(56vh, 500px); }
.page-hero .hero-body { padding-top: 48px; padding-bottom: 48px; }
.page-hero .hero-body h1 { font-size: clamp(2rem, 3.2vw, 2.8rem); margin-top: 4px; }
.page-hero .lead { margin-bottom: 0; }
.page-hero .year-nav { margin-top: 24px; }
.page-hero.no-image { grid-template-columns: 1fr; }
.hero-media.is-contain { background: var(--figure-bg); border-right: 1px solid var(--line); }
.hero-media.is-contain img { object-fit: contain; padding: 24px; }
@media (max-width: 860px) {
    .page-hero .hero-media { height: 34vh; min-height: 220px; }
    .page-hero .hero-body { padding: 32px 24px 36px; }
}
.page-hero .post-meta { margin: 18px 0 0; }
.page-hero .post-meta + p { margin-top: 18px; }
.page-hero .small-caps .post-crumb-link { color: inherit; text-decoration: none; }
.page-hero .small-caps .post-crumb-link:hover { text-decoration: underline; }
.post .page-hero h1 { font-size: clamp(1.8rem, 2.8vw, 2.5rem); }

/* ---------- Event pages (index.php/events/<slug>) ---------- */
.event-facts { list-style: none; padding: 0; margin: 20px 0 0; display: grid; gap: 8px; color: var(--ink-2); }
.event-facts li { display: flex; gap: 10px; align-items: baseline; }
.event-facts i { color: var(--brand-ink); width: 1.1em; text-align: center; }
.event-body { padding-bottom: 24px; }
.event-after { padding-bottom: 72px; }
.event-people { margin: 40px 0; }
.event-people h2 { font-size: 1.6rem; margin: 0 0 20px; padding-bottom: 10px; border-bottom: 1px solid var(--line); }
.event-people-grid { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 28px 20px; }
.event-person { text-align: center; margin: 0; }
.event-person-photo { width: 120px; height: 120px; margin: 0 auto 12px; border-radius: 50%; overflow: hidden; background: var(--photo-bg); position: relative; }
.event-person-photo img { width: 100%; height: 100%; object-fit: cover; object-position: 50% 25%; display: block; }
.event-person-initials { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: #fff; font-family: var(--serif); font-size: 2.4rem; }
.event-person-name { font-weight: 600; margin: 0; line-height: 1.3; text-align: center; hyphens: manual; }
.event-person-name a { color: var(--ink); }
.event-person-aff { color: var(--ink-3); font-size: .9rem; margin: 4px 0 0; line-height: 1.4; text-align: center; hyphens: manual; }
/* Sponsors / partners: whole logo on a light card */
.event-people.is-logos .event-people-grid { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); }
.event-people.is-logos .event-person { position: relative; }
.event-people.is-logos .event-person-photo { width: 100%; height: 110px; border-radius: var(--radius); background: var(--figure-bg); border: 1px solid var(--line); padding: 14px; }
.event-people.is-logos .event-person-photo img { object-fit: contain; }
.event-logo-link { position: absolute; inset: 0; }
@media (max-width: 560px) {
    .event-people-grid { grid-template-columns: repeat(2, 1fr); gap: 24px 12px; }
    .event-person-photo { width: 104px; height: 104px; }
}

/* Admin: people rows in the event editor */
.people-row { display: grid; grid-template-columns: 112px 1fr 1.2fr 1.4fr 1.2fr 76px 84px; gap: 10px; align-items: end; padding: 12px 0; border-top: 1px solid var(--line); }
.people-row:first-child { border-top: 0; }
.people-row label { margin: 0; font-weight: normal; }
.people-row .form-label { display: block; font-size: .8rem; margin-bottom: 4px; }
.people-row-photo { display: flex; align-items: center; gap: 8px; }
.people-thumb { width: 44px; height: 44px; flex: 0 0 44px; border-radius: 50%; background: var(--photo-bg) center / cover no-repeat; border: 1px solid var(--line); }
.people-upload { cursor: pointer; margin: 0; }
.people-remove { display: flex; align-items: center; gap: 6px; padding-bottom: 8px; color: var(--ink-2); }
.people-row.is-removed { opacity: .45; }
@media (max-width: 991px) {
    .people-row { grid-template-columns: 1fr 1fr; }
    .people-row-photo { grid-column: 1 / -1; }
}

/* ---------- Numbered citations + References list (Markdown footnotes) ---------- */
.post-body sup.cite { font-size: .72em; line-height: 0; margin-left: 1px; }
.post-body sup.cite a { text-decoration: none; font-weight: 600; }
.post-body sup.cite a:hover { text-decoration: underline; }
.post-body .references { margin-top: 3em; padding-top: 1.5em; border-top: 1px solid var(--line); }
.post-body .references h2 { font-size: 1.35rem; margin-top: 0; }
.post-body .references ol { font-size: .95rem; color: var(--ink-2); padding-left: 1.6em; }
.post-body .references li { margin: .5em 0; line-height: 1.55; scroll-margin-top: calc(var(--nav-h) + 16px); }
.post-body .references li:target { background: var(--brand-tint); border-radius: 4px; }
.post-body .references .ref-back { text-decoration: none; margin-left: 4px; }
.post-body [id^="cite-"] { scroll-margin-top: calc(var(--nav-h) + 24px); }

/* Admin: course page options */
.page-modes { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 16px; }
.page-mode { display: flex; gap: 10px; align-items: flex-start; border: 1.5px solid var(--line); border-radius: 8px; padding: 12px 14px; cursor: pointer; font-weight: 400; margin: 0; }
.page-mode input { margin-top: 4px; }
.page-mode small { color: var(--ink-3); }
.page-mode.selected { border-color: var(--ink-2); background: var(--bg-soft); }
.page-mode-panel { margin-bottom: 8px; }
@media (max-width: 760px) { .page-modes { grid-template-columns: 1fr; } }

/* ---------- Admin: my account + users ---------- */
.account-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 24px; align-items: start; }
.account-grid h2 { font-size: 1.25rem; margin: 0 0 16px; }
.form-stack { display: grid; gap: 16px; }
.form-stack .form-control { width: 100%; }
.role-badge { display: inline-block; font-size: .8rem; font-weight: 700; border-radius: 999px; padding: 2px 10px; background: var(--bg-soft); color: var(--ink-2); }
.role-badge.role-admin { background: var(--admin-badge); color: var(--brand-ink); }
@media (max-width: 860px) { .account-grid { grid-template-columns: 1fr; } }

/* Home: "Explore" button. The arrow points right; on click it turns down and the
   page scrolls just far enough to bring the tiles (and the start of the news) into view. */
#explore { scroll-margin-top: var(--nav-h); }
.explore-btn i { margin-left: 8px; font-size: .85em; transition: transform .35s cubic-bezier(.4, 0, .2, 1); }
.explore-btn:hover i { transform: translateX(3px); }
.explore-btn.is-down i { transform: rotate(90deg); }

/* ---------- Justified body text ----------
   Paragraph-style text is justified, with automatic hyphenation (the page is
   lang="en") so long words split instead of leaving wide gaps between words.
   Headings, captions, tables, buttons, short labels and the narrow card
   previews (member bios, research cards) keep left alignment, where justifying
   would leave wide gaps between words;
   reference lists stay left-aligned because their long URLs can't be hyphenated. */
.post-body p, .post-body li, .post-body blockquote,
.prose p, .prose li,
.lead, .news-item p,
.person-dialog-bio p,
.paper-modal-abstract {
    text-align: justify;
    text-justify: inter-word;
    -webkit-hyphens: auto;
    hyphens: auto;
    hyphenate-limit-chars: 7 3 3;   /* only words of 7+ letters, at least 3 on each side */
}
.post-body .references li, .post-body figcaption, .post-body td, .post-body th { text-align: left; -webkit-hyphens: manual; hyphens: manual; }
.post-body a, .prose a { overflow-wrap: anywhere; }
/* Phones: the column is too narrow for justified text to space evenly */
@media (max-width: 640px) {
    .post-body p, .post-body li, .post-body blockquote,
    .prose p, .prose li, .lead, .news-item p,
    .person-dialog-bio p, .paper-modal-abstract { text-align: left; }
}


/* ==========================================================================
   Dark theme
   Follows the system setting by default; the navbar toggle stores an explicit
   choice in localStorage ('sml-theme'), which head.php applies as
   <html data-theme="light|dark"> before the page is drawn. The palette is
   slate-based with the logo red kept for small accents; only the tokens change,
   so every component above adapts automatically.
   ========================================================================== */
:root[data-theme="dark"] {
    --ink: #e3e7ec;
    --ink-2: #b3bcc8;
    --ink-3: #8c96a4;
    --line: #2a333f;
    --bg: #12171e;
    --bg-soft: #161c24;
    --brand: #e5383b;
    --brand-ink: #ee8f93;
    --brand-tint: #3a1f22;
    --on-brand: #12171e;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 16px rgba(0, 0, 0, .25);
    --shadow-hover: 0 2px 4px rgba(0, 0, 0, .35), 0 10px 28px rgba(0, 0, 0, .35);
    --shadow-pop: 0 24px 60px rgba(0, 0, 0, .55);
    --surface: #1a212b;
    --solid: #dfe4ea;
    --solid-hover: #c6cdd7;
    --on-solid: #12171e;
    --nav-bg: rgba(18, 23, 30, .92);
    --nav-shadow: 0 2px 12px rgba(0, 0, 0, .4);
    --footer-bg: #0d1116;
    --media-bg: #0d1116;
    --figure-bg: #e6e9ee;
    --photo-bg: #232b36;
    --code-bg: #151b23;
    --input-border: #3a4451;
    --focus-ring: rgba(223, 228, 234, .16);
    --backdrop: rgba(0, 0, 0, .6);
    --danger-line: #6b3236;
    --warn-bg: #3a2f15;
    --warn-ink: #e8c27a;
    --hidden-row: #1f1c14;
    --admin-badge: #3a1f22;
    --tile-1: #18202a; --tile-2: #1c2531; --tile-3: #212b38; --tile-4: #26313f; --tile-hover: #2e3a4b;
    color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --ink: #e3e7ec;
        --ink-2: #b3bcc8;
        --ink-3: #8c96a4;
        --line: #2a333f;
        --bg: #12171e;
        --bg-soft: #161c24;
        --brand: #e5383b;
        --brand-ink: #ee8f93;
        --brand-tint: #3a1f22;
        --on-brand: #12171e;
        --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 16px rgba(0, 0, 0, .25);
        --shadow-hover: 0 2px 4px rgba(0, 0, 0, .35), 0 10px 28px rgba(0, 0, 0, .35);
        --shadow-pop: 0 24px 60px rgba(0, 0, 0, .55);
        --surface: #1a212b;
        --solid: #dfe4ea;
        --solid-hover: #c6cdd7;
        --on-solid: #12171e;
        --nav-bg: rgba(18, 23, 30, .92);
        --nav-shadow: 0 2px 12px rgba(0, 0, 0, .4);
        --footer-bg: #0d1116;
        --media-bg: #0d1116;
        --figure-bg: #e6e9ee;
        --photo-bg: #232b36;
        --code-bg: #151b23;
        --input-border: #3a4451;
        --focus-ring: rgba(223, 228, 234, .16);
        --backdrop: rgba(0, 0, 0, .6);
        --danger-line: #6b3236;
        --warn-bg: #3a2f15;
        --warn-ink: #e8c27a;
        --hidden-row: #1f1c14;
        --admin-badge: #3a1f22;
        --tile-1: #18202a; --tile-2: #1c2531; --tile-3: #212b38; --tile-4: #26313f; --tile-hover: #2e3a4b;
        color-scheme: dark;
    }
}

/* Things that are not plain tokens */
.logo-on-dark { display: none !important; }
:root[data-theme="dark"] .logo-on-light { display: none !important; }
:root[data-theme="dark"] .logo-on-dark { display: block !important; }
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .logo-on-light { display: none !important; }
    :root:not([data-theme="light"]) .logo-on-dark { display: block !important; }
}
.close { color: var(--ink); text-shadow: none; }
.close:hover, .close:focus { color: var(--ink); }
.alert-success { background: color-mix(in srgb, #2e9e5b 14%, var(--surface)); border-color: color-mix(in srgb, #2e9e5b 40%, var(--surface)); color: var(--ink); }
.alert-danger { background: color-mix(in srgb, var(--brand) 12%, var(--surface)); border-color: color-mix(in srgb, var(--brand) 40%, var(--surface)); color: var(--ink); }
.form-control::placeholder { color: var(--ink-3); opacity: 1; }
select.form-control option { background: var(--surface); color: var(--ink); }
/* Photos look harsh at full brightness on a dark page */
:root[data-theme="dark"] .person-photo img, :root[data-theme="dark"] .post-cover img { filter: brightness(.92); }
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .person-photo img, :root:not([data-theme="light"]) .post-cover img { filter: brightness(.92); }
}

/* ---------- Theme toggle (navbar) ---------- */
.nav-actions { display: flex; align-items: center; gap: 4px; }
.site-menu-wrap { margin-left: auto; }
.theme-toggle {
    display: inline-flex; align-items: center; justify-content: center;
    width: 38px; height: 38px; border-radius: 50%;
    background: none; border: 1px solid var(--line); color: var(--ink-2);
    cursor: pointer; transition: background-color .2s, color .2s, border-color .2s;
}
.theme-toggle:hover { background: var(--bg-soft); color: var(--ink); border-color: var(--ink-3); }
.theme-toggle:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
/* Half-filled "contrast" circle; it turns half a turn when the theme switches */
.theme-icon { display: block; transition: transform .45s cubic-bezier(.4, 0, .2, 1); }
:root[data-theme="dark"] .theme-icon { transform: rotate(180deg); }
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .theme-icon { transform: rotate(180deg); }
}

/* Home hero: thin progress line along the top of the video (filled by site.js) */
.hero-progress { position: absolute; left: 0; right: 0; top: 0; height: 3px; background: rgba(255, 255, 255, .14); z-index: 2; pointer-events: none; }
.hero-progress span { display: block; height: 100%; width: 100%; background: var(--brand); transform-origin: left center; transform: scaleX(0); }
@media (prefers-reduced-motion: reduce) { .hero-progress { display: none; } }
/* Home hero: play/pause button in the video's top-right corner (site.js keeps it in sync).
   Shows "play" when the video is paused, e.g. if the browser blocked autoplay (iOS Low Power Mode). */
.hero-play { position: absolute; top: 14px; right: 14px; z-index: 3; width: 40px; height: 40px; padding: 0; border: 1px solid rgba(255, 255, 255, .28); border-radius: 50%;
    background: rgba(13, 17, 22, .55); color: #fff; display: flex; align-items: center; justify-content: center; cursor: pointer;
    -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); opacity: .75; transition: opacity .2s, background-color .2s; }
.hero-play:hover, .hero-play:focus-visible { opacity: 1; background: rgba(13, 17, 22, .8); }
.hero-play:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
.hero-play svg { width: 18px; height: 18px; fill: currentColor; }
.hero-play .i-play { display: none; margin-left: 2px; }
.hero-play.is-paused { opacity: 1; }
.hero-play.is-paused .i-play { display: block; }
.hero-play.is-paused .i-pause { display: none; }

/* Very large screens (2K/4K monitors at 100% scaling): scale the whole page up, so it lays out as
   if the window were roughly 2000 CSS px wide instead of leaving small text in a sea of space.
   Screens with OS scaling (e.g. a 4K Mac at 200%) report a smaller width and are unaffected. */
@media (min-width: 1700px) { html { zoom: 1.125; --page-zoom: 1.125; } }
@media (min-width: 2200px) { html { zoom: 1.3; --page-zoom: 1.3; } }
@media (min-width: 2900px) { html { zoom: 1.6; --page-zoom: 1.6; } }
@media (min-width: 3600px) { html { zoom: 2; --page-zoom: 2; } }
