/* ==========================================================================
   Dr. Robin Khosla - faculty site
   Shared stylesheet for index.html, researchlab/index.html, team/index.html

   Page-specific looks are handled with modifier classes rather than separate
   files, e.g.  <div class="hero hero--home">  vs  <div class="hero hero--lab">
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. THEME TOKENS
   -------------------------------------------------------------------------- */
:root {
    --navy:        #0A3254;   /* primary   */
    --navy-light:  #1A5276;   /* secondary */
    --gold:        #D4AF37;   /* accent    */
    --page-bg:     #F4F7F6;
    --card-bg:     #FFFFFF;
    --card-border: #E2E8F0;
    --text:        #333333;
    --text-muted:  #555555;
    --text-on-dark:#D1D5DB;
}

/* --------------------------------------------------------------------------
   2. BASE
   -------------------------------------------------------------------------- */
html { scroll-behavior: smooth; }

body, html {
    margin: 0;
    padding: 0;
    font-family: Arial, Helvetica, sans-serif;
    background-color: var(--page-bg);
    color: var(--text);
    line-height: 1.6;
}

.container {
    width: 90%;
    max-width: 1000px;
    margin: 0 auto;
    padding: 20px;
    /* without this, 90% + 40px padding overflows on narrow phones */
    box-sizing: border-box;
}

/* the team page uses a slightly wider measure for its 4-up card grid */
.container--wide { max-width: 1100px; }

/* --------------------------------------------------------------------------
   3. NAVBAR
   -------------------------------------------------------------------------- */
.navbar {
    background-color: var(--navy);
    border-bottom: 4px solid var(--gold);
    text-align: center;
    /* sticky (not fixed) so the bar reserves its own space in the flow. With 11
       links it wraps to 2 rows below ~1500px, and a fixed bar would sit on top
       of the hero. */
    position: sticky;
    top: 0;
    width: 100%;
    /* leaves room for the absolutely-positioned logo so the centred links can
       never run underneath it */
    padding: 0 90px;
    box-sizing: border-box;
    z-index: 1000;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
    min-height: 50px;
}

.navbar a {
    display: inline-block;
    color: #FFFFFF;
    text-decoration: none;
    padding: 15px 20px;
    font-size: 16px;
    font-weight: bold;
    transition: background-color 0.3s, color 0.3s;
}

.navbar a:hover,
.navbar a:focus-visible { background-color: var(--navy-light); color: var(--gold); }

/* current page marker */
.navbar a[aria-current="page"] { color: var(--gold); }

.nav-logo-link {
    position: absolute;
    left: 20px;
    top: 7px;
    padding: 0 !important;
}
.nav-logo-link:hover,
.nav-logo-link:focus-visible { background-color: transparent !important; }

.nav-logo {
    height: 36px;
    width: auto;
    border: none;
    display: block;
    background-color: #FFFFFF;
    border-radius: 2px;
}

/* Anchor offset - keeps section titles clear of the sticky navbar.
   scroll-margin-top works at any navbar height, unlike a negative-offset
   hack which has to assume a fixed bar height. */
.anchor-offset {
    display: block;
    visibility: hidden;
    scroll-margin-top: 130px;
}

/* --------------------------------------------------------------------------
   4. HERO
   -------------------------------------------------------------------------- */
.hero {
    background-color: var(--navy);
    color: #FFFFFF;
    padding: 40px 20px;
    margin-bottom: 30px;
    overflow: hidden;
}

/* sub-page heroes: photo background, centred title */
.hero--page {
    background-size: cover;
    background-position: center;
    min-height: 300px;
    margin-bottom: 40px;
    text-align: center;
    border-bottom: 5px solid var(--gold);
}
.hero--lab  { padding: 60px 20px 100px 20px; }
.hero--team { padding: 160px 20px 100px 20px; background-position: center 20%; }

.hero--page h1 { margin: 0; font-size: 32px; text-transform: uppercase; letter-spacing: 1px; }
.hero--page p  { color: var(--text-on-dark); font-size: 18px; margin-top: 10px; }

.profile-img {
    float: left;
    width: 180px;
    height: auto;
    border: 4px solid #FFFFFF;
    margin-right: 30px;
    border-radius: 4px;
}

.hero-text { float: left; max-width: 700px; }
.hero-text h1 { margin: 0 0 5px 0; font-size: 32px; color: #FFFFFF; }
.hero-text h2 { margin: 0 0 15px 0; font-size: 18px; font-weight: normal; color: var(--card-border); }

.bio {
    font-size: 15px;
    color: var(--text-on-dark);
    margin-bottom: 20px;
    line-height: 1.5;
    text-align: justify;
}

/* --------------------------------------------------------------------------
   5. BUTTONS
   -------------------------------------------------------------------------- */
.btn-group { margin-top: 15px; }

.btn {
    display: inline-block;
    background-color: var(--gold);
    color: var(--navy);
    padding: 10px 20px;
    text-decoration: none;
    font-weight: bold;
    font-size: 14px;
    border-radius: 4px;
    margin-right: 10px;
    margin-bottom: 10px;
    border: 2px solid var(--gold);
    transition: all 0.3s ease;
}
.btn-outline { background-color: transparent; color: var(--gold); }
.btn:hover, .btn:focus-visible { background-color: #FFFFFF; color: var(--navy); border-color: #FFFFFF; }

.btn-small {
    display: inline-block;
    background-color: transparent;
    color: var(--navy-light);
    padding: 5px 10px;
    text-decoration: none;
    font-size: 12px;
    font-weight: bold;
    border: 1px solid var(--navy-light);
    border-radius: 3px;
    transition: 0.3s;
}
.btn-small:hover, .btn-small:focus-visible { background-color: var(--navy-light); color: #FFFFFF; }

/* --------------------------------------------------------------------------
   6. SECTION CARDS & HEADINGS
   -------------------------------------------------------------------------- */
.section-card {
    background-color: var(--card-bg);
    border: 1px solid var(--card-border);
    padding: 30px;
    margin-bottom: 30px;
    border-radius: 6px;
    transition: box-shadow 0.3s ease;
}
.section-card:hover { box-shadow: 0 4px 15px rgba(0,0,0,0.08); }

.news-box      { border-left: 5px solid var(--gold); background-color: #FAFAFA; }

/* --- scrollable news list -------------------------------------------------
   Caps the section height so older items can be kept without the box growing.
   Below the cap it behaves like a normal list - no scrollbar, no dead space. */
.news-scroll {
    max-height: 220px;
    overflow-y: auto;
    /* stops a flick inside the list from scrolling the whole page once it
       reaches the end */
    overscroll-behavior: contain;
    position: relative;
    padding-right: 8px;
}
.news-scroll ul { margin-bottom: 0; }

/* slim scrollbar in the site palette (Firefox + WebKit) */
.news-scroll { scrollbar-width: thin; scrollbar-color: var(--navy-light) #EDEDED; }
.news-scroll::-webkit-scrollbar { width: 8px; }
.news-scroll::-webkit-scrollbar-track { background: #EDEDED; border-radius: 4px; }
.news-scroll::-webkit-scrollbar-thumb { background: var(--navy-light); border-radius: 4px; }
.news-scroll::-webkit-scrollbar-thumb:hover { background: var(--navy); }

/* script.js adds this only when the content actually overflows */
.news-scroll.is-scrollable { border-bottom: 1px solid var(--card-border); }

.news-more {
    display: none;
    font-size: 12px;
    color: var(--text-muted);
    font-style: italic;
    margin: 6px 0 0 0;
}
.news-scroll.is-scrollable + .news-more { display: block; }
.positions-box { border-left: 5px solid var(--navy-light); background-color: #E8F0FE; }

.section-title {
    color: var(--navy);
    font-size: 24px;
    border-bottom: 2px solid var(--gold);
    padding-bottom: 5px;
    margin-top: 0;
    margin-bottom: 20px;
}
/* headings that sit inside a coloured box do not need the gold rule */
.section-title--plain { border-bottom: none; margin-bottom: 10px; }

.sub-title { color: var(--navy-light); font-size: 18px; margin-top: 20px; margin-bottom: 10px; }

/* team / lab page section headers with a count pill */
.section-header {
    border-bottom: 2px solid var(--gold);
    margin-bottom: 30px;
    padding-bottom: 10px;
    color: var(--navy);
    display: flex; align-items: center; justify-content: space-between;
}
.section-header h2 { margin: 0; font-size: 24px; text-transform: uppercase; }
.section-count { background: var(--navy-light); color: #FFFFFF; padding: 2px 10px; border-radius: 12px; font-size: 14px; }

/* --------------------------------------------------------------------------
   7. LISTS, TAGS, PUBLICATION LINKS
   -------------------------------------------------------------------------- */
ul { margin: 0 0 20px 0; padding-left: 20px; }
ul li { margin-bottom: 8px; }

ol { padding-left: 25px; margin-left: 50px; margin-bottom: 20px; list-style-type: decimal; }
/* chemical formulae and DOIs are long unbreakable tokens - let them wrap
   rather than push the card wider than the screen */
ol li { margin-bottom: 12px; text-align: justify; overflow-wrap: anywhere; }

.pub-link {
    font-size: 12px;
    background-color: var(--card-border);
    color: var(--navy);
    text-decoration: none;
    padding: 2px 6px;
    border-radius: 3px;
    margin-left: 5px;
    font-weight: bold;
    transition: background-color 0.2s;
}
.pub-link:hover, .pub-link:focus-visible { background-color: var(--navy-light); color: #FFFFFF; }

.tag {
    display: inline-block;
    background-color: var(--card-border);
    color: var(--navy);
    padding: 5px 12px;
    margin: 0 5px 10px 0;
    font-size: 14px;
    border-radius: 15px;
    transition: background-color 0.3s, color 0.3s;
}
.tag:hover { background-color: var(--navy-light); color: #FFFFFF; }

/* --------------------------------------------------------------------------
   8. PUBLICATION SEARCH & FILTER
   -------------------------------------------------------------------------- */
.pub-tools {
    /* hidden until script.js switches it on, so it is never a dead search
       box for anyone browsing with JavaScript turned off */
    display: none;
    flex-wrap: wrap; gap: 10px; align-items: center;
    margin-bottom: 20px; padding: 15px;
    background: #FAFAFA; border: 1px solid var(--card-border); border-radius: 6px;
}
.pub-tools label { font-size: 13px; font-weight: bold; color: var(--navy); }

.pub-search {
    flex: 1 1 220px;
    padding: 8px 12px;
    border: 1px solid #CCCCCC;
    border-radius: 4px;
    font-size: 14px;
    font-family: inherit;
    min-width: 0;
}
.pub-search:focus, .pub-year:focus { outline: 2px solid var(--navy-light); outline-offset: 1px; }

.pub-year {
    padding: 8px 10px;
    border: 1px solid #CCCCCC;
    border-radius: 4px;
    font-size: 14px;
    font-family: inherit;
    background: #FFFFFF;
}

.pub-count { font-size: 13px; color: var(--text-muted); margin-left: auto; }

/* type filter buttons sit on their own row under the search controls */
.pub-types { flex: 1 0 100%; display: flex; flex-wrap: wrap; gap: 8px; }

.pub-type-btn {
    background: #FFFFFF;
    border: 1px solid var(--navy-light);
    color: var(--navy-light);
    padding: 5px 12px;
    border-radius: 14px;
    font-size: 13px;
    font-weight: bold;
    font-family: inherit;
    cursor: pointer;
    transition: background-color 0.2s, color 0.2s;
}
.pub-type-btn:hover { background: var(--navy-light); color: #FFFFFF; }
.pub-type-btn[aria-pressed="true"] { background: var(--navy); border-color: var(--navy); color: #FFFFFF; }

/* hidden by the filter - display:none keeps <ol> numbering intact for the
   items that remain visible */
.pub-hidden { display: none; }

.pub-empty {
    padding: 15px; margin-bottom: 20px;
    background: #FFF3E0; border: 1px solid #FFE0B2; border-radius: 4px;
    color: #8a5a00; font-size: 14px;
}

/* --------------------------------------------------------------------------
   9. CONTACT TABLE
   -------------------------------------------------------------------------- */
.contact-layout { display: flex; flex-wrap: wrap; gap: 25px; align-items: flex-start; }

.contact-table { flex: 1 1 340px; text-align: left; border-collapse: separate; border-spacing: 10px; }
.contact-table td { vertical-align: top; }
.contact-table td.label { width: 150px; font-weight: bold; color: var(--navy); }

/* office location map */
.office-map { flex: 1 1 280px; min-width: 0; }
.office-map iframe {
    width: 100%;
    height: 220px;
    border: 1px solid var(--card-border);
    border-radius: 6px;
    display: block;
    /* the embed has its own white background; this keeps the frame tidy
       while it loads */
    background: var(--page-bg);
}
.office-map .btn-small { margin-top: 10px; }

/* --------------------------------------------------------------------------
   10. TEAM GRID
   -------------------------------------------------------------------------- */
.team-grid {
    display: grid;
    /* 200px track gives 4-5 columns instead of 3, so each card is compact.
       min() keeps it from overflowing very narrow phones. */
    grid-template-columns: repeat(auto-fill, minmax(min(200px, 100%), 1fr));
    gap: 20px;
    margin-bottom: 40px;
}

.member-card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 8px;
    padding: 20px 14px;
    text-align: center;
    transition: transform 0.3s, box-shadow 0.3s;
    border-top: 4px solid var(--navy);
    position: relative;
}
.member-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 20px rgba(0,0,0,0.08);
    border-top-color: var(--gold);
}
/* masters cards carry a distinct top border */
.member-card--masters { border-top-color: var(--navy-light); }

.member-img {
    width: 100px; height: 100px;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid var(--page-bg);
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
    margin-bottom: 10px;
}

/* alumni numbering */
.member-number {
    position: absolute;
    top: 8px; left: 8px;
    width: 22px; height: 22px;
    line-height: 22px;
    text-align: center;
    background: var(--navy);
    color: #FFFFFF;
    border-radius: 50%;
    font-size: 11px;
    font-weight: bold;
}
.member-card:hover .member-number { background: var(--gold); color: var(--navy); }

.member-name  { color: var(--navy); font-size: 15px; font-weight: bold; margin: 3px 0; line-height: 1.25; }
.member-role  { color: var(--gold); font-size: 11px; font-weight: bold; text-transform: uppercase; letter-spacing: 0.4px; margin-bottom: 6px; }
.member-topic { color: var(--text-muted); font-size: 12.5px; margin-bottom: 0; font-style: italic; min-height: 34px; line-height: 1.35; }
.member-now   { color: var(--text-muted); font-size: 12.5px; margin: 0; min-height: 34px; line-height: 1.35; }

/* --------------------------------------------------------------------------
   10b. COURSE CARDS
   Same visual language as the equipment cards, minus the photo.
   -------------------------------------------------------------------------- */
.course-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(260px, 100%), 1fr));
    gap: 20px;
}

.course-card {
    background: #FAFAFA;
    border: 1px solid var(--card-border);
    border-left: 5px solid var(--navy);
    border-radius: 6px;
    padding: 20px;
    position: relative;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}
.course-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 20px rgba(0,0,0,0.10);
    border-left-color: var(--gold);
}
/* the course being taught this semester */
.course-card--current { border-left-color: var(--gold); background: #FFFDF5; }

.course-badge {
    position: absolute;
    top: 14px; right: 14px;
    background: #E8F5E9; color: #2E7D32; border: 1px solid #C8E6C9;
    padding: 3px 9px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: bold;
    text-transform: uppercase;
}

.course-code {
    color: var(--navy-light);
    font-size: 13px;
    font-weight: bold;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}

.course-name {
    margin: 0 0 8px 0;
    color: var(--navy);
    font-size: 17px;
    /* override the global .sub-title-ish h4 spacing inside cards */
    line-height: 1.3;
}

.course-desc { font-size: 14px; color: var(--text-muted); margin: 0 0 12px 0; line-height: 1.45; }

/* definition list rendered as a compact label/value table */
.course-meta {
    margin: 0;
    display: grid;
    /* minmax(0,...) lets both tracks shrink; without it the nowrap label sets a
       floor that overflows the card on a 320px phone */
    grid-template-columns: minmax(0, auto) minmax(0, 1fr);
    gap: 3px 10px;
    font-size: 13px;
}
.course-meta dt { color: var(--navy); font-weight: bold; white-space: nowrap; }
.course-meta dd { margin: 0; color: var(--text-muted); overflow-wrap: anywhere; }

/* below this the two-column label/value pairing has no room left, so stack */
@media only screen and (max-width: 430px) {
    .course-meta { grid-template-columns: 1fr; gap: 0; }
    .course-meta dt { margin-top: 8px; }
}

/* --------------------------------------------------------------------------
   11. EQUIPMENT GRID
   -------------------------------------------------------------------------- */
.equip-grid {
    display: grid;
    /* min() keeps the 280px track from overflowing viewports narrower than
       280px + container padding (e.g. a 320px phone) */
    grid-template-columns: repeat(auto-fill, minmax(min(280px, 100%), 1fr));
    gap: 20px;
}

.equip-item {
    background: #FAFAFA;
    border: 1px solid var(--card-border);
    border-radius: 6px;
    position: relative;
    overflow: hidden;              /* clips the image at the corners */
    border-left: 5px solid var(--navy);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    padding: 0;                    /* removes whitespace around the image */
    display: flex;
    flex-direction: column;
}
.equip-item:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 20px rgba(0,0,0,0.15);
    border-left-color: var(--gold);
}

.equip-img {
    width: 100%;
    height: 180px;                 /* fixed height keeps the grid uniform */
    object-fit: cover;             /* prevents stretching */
    border-bottom: 4px solid var(--gold);
}

.equip-content { padding: 20px; flex-grow: 1; }
.equip-item h3 { margin: 0 0 8px 0; color: var(--navy); font-size: 18px; font-weight: bold; }
.equip-item p  { font-size: 14px; color: var(--text-muted); margin-bottom: 0; line-height: 1.4; }

.badge-overlay {
    position: absolute;
    top: 10px; right: 10px;
    background: rgba(255, 255, 255, 0.95);
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: bold;
    text-transform: uppercase;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
    z-index: 2;
}
.badge-active { background: #E8F5E9; color: #2E7D32; border: 1px solid #C8E6C9; }
.badge-busy   { background: #FFF3E0; color: #EF6C00; border: 1px solid #FFE0B2; }

/* --------------------------------------------------------------------------
   12. FOOTER, SOCIAL, BACK TO TOP
   -------------------------------------------------------------------------- */
.social-icon { display: inline-block; margin: 0 10px 0 0; transition: transform 0.3s ease; }
.social-icon:hover { transform: scale(1.1); }

.social-block { margin-top: 30px; padding-top: 20px; border-top: 1px solid var(--card-border); }
.social-block--center { text-align: center; }
.social-block--center .social-icon { margin: 0 10px; }
.social-heading { font-weight: bold; color: var(--navy); font-size: 16px; display: block; margin-bottom: 12px; }

.back-link { text-align: center; margin-bottom: 40px; }
.back-link .btn-small { padding: 10px 20px; font-size: 14px; }

.back-to-top {
    position: fixed;
    bottom: 20px; right: 20px;
    background-color: var(--navy);
    color: #FFFFFF;
    padding: 10px 15px;
    border-radius: 5px;
    text-decoration: none;
    font-weight: bold;
    box-shadow: 0 2px 5px rgba(0,0,0,0.3);
    z-index: 1000;
}
.back-to-top:hover, .back-to-top:focus-visible { background-color: var(--navy-light); color: var(--gold); }

.footer {
    text-align: center;
    padding: 20px;
    background: var(--navy);
    color: var(--text-on-dark);
    font-size: 14px;
    border-top: 4px solid var(--gold);
    margin-top: 40px;
}
.footer-updated { font-size: 12px; color: #9FB3C8; margin-top: 10px; }
/* empty until script.js fills it in, so no stray "Last updated:" label */
.footer-updated:empty { display: none; }

/* --------------------------------------------------------------------------
   SKIP LINK
   With 12 navigation links, a keyboard user would otherwise tab through all
   of them on every page before reaching the content (WCAG 2.4.1).
   -------------------------------------------------------------------------- */
.skip-link {
    position: absolute;
    left: -9999px;
    top: 0;
    background: var(--navy);
    color: #FFFFFF;
    padding: 12px 20px;
    font-weight: bold;
    text-decoration: none;
    z-index: 10001;
    border-bottom: 3px solid var(--gold);
    border-radius: 0 0 4px 0;
}
.skip-link:focus { left: 0; }

/* --------------------------------------------------------------------------
   13. CHAT WIDGET
   -------------------------------------------------------------------------- */
#chat-icon {
    position: fixed; bottom: 100px; right: 20px;
    background: var(--navy); color: #FFFFFF; border-radius: 50%;
    width: 60px; height: 60px; text-align: center;
    line-height: 60px; font-size: 16px; font-weight: bold; cursor: pointer;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3); z-index: 9999;
    animation: chatPulse 2s infinite;
    transition: transform 0.3s ease;
    border: none; padding: 0; font-family: inherit;
}
#chat-icon:hover { transform: scale(1.05); }

@keyframes chatPulse {
    0%   { box-shadow: 0 0 0 0 rgba(0, 51, 102, 0.7); }
    70%  { box-shadow: 0 0 0 15px rgba(0, 51, 102, 0); }
    100% { box-shadow: 0 0 0 0 rgba(0, 51, 102, 0); }
}

.chat-tooltip {
    position: fixed;
    bottom: 195px; right: 30px;
    background-color: var(--gold);
    color: var(--text);
    padding: 8px 12px;
    border-radius: 5px;
    font-size: 14px;
    font-weight: bold;
    z-index: 999;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
    animation: floatUp 3s infinite ease-in-out;
    cursor: pointer;
    border: none; font-family: inherit;
    max-width: 220px; text-align: left;
}
.chat-tooltip::after {
    content: '';
    position: absolute;
    bottom: -5px; right: 20px;
    border-width: 5px 5px 0;
    border-style: solid;
    border-color: var(--gold) transparent transparent transparent;
}

@keyframes floatUp {
    0%, 100% { transform: translateY(0); }
    50%      { transform: translateY(-5px); }
}

#chat-container {
    position: fixed; bottom: 90px; right: 20px;
    width: 350px; max-width: calc(100vw - 40px);
    height: 500px; max-height: calc(100vh - 120px);
    background: #FFFFFF;
    border-radius: 12px; display: none; flex-direction: column;
    box-shadow: 0 5px 20px rgba(0,0,0,0.2); z-index: 9999;
    font-family: Arial, sans-serif; overflow: hidden; border: 1px solid #CCCCCC;
}
#chat-container.is-open { display: flex; }

#chat-header {
    background: var(--navy); color: #FFFFFF; padding: 15px;
    font-weight: bold; display: flex; justify-content: space-between; align-items: center;
}
.chat-header-actions { display: flex; align-items: center; gap: 6px; }

#chat-close, #chat-restart {
    background: none; border: none; color: #FFFFFF;
    cursor: pointer; line-height: 1; padding: 4px 8px;
    border-radius: 4px; font-family: inherit;
}
#chat-close { font-size: 18px; }
#chat-restart { font-size: 12px; border: 1px solid rgba(255,255,255,0.4); }
#chat-close:hover, #chat-restart:hover { background: rgba(255,255,255,0.15); }

#chat-box {
    flex: 1; padding: 15px; overflow-y: auto;
    display: flex; flex-direction: column; gap: 12px; background: #F9F9F9;
}

.bot-msg {
    background: #E1EEFC; color: var(--text); padding: 10px 14px;
    border-radius: 12px 12px 12px 0; align-self: flex-start;
    max-width: 85%; font-size: 14px; line-height: 1.4; border: 1px solid #D0E0F0;
}
.user-msg {
    background: var(--navy); color: #FFFFFF; padding: 10px 14px;
    border-radius: 12px 12px 0 12px; align-self: flex-end;
    max-width: 85%; font-size: 14px;
}

/* "assistant is typing" dots */
.chat-typing { display: flex; gap: 4px; align-items: center; padding: 14px; }
.chat-typing span {
    width: 7px; height: 7px; border-radius: 50%;
    background: var(--navy-light); opacity: 0.4;
    animation: typingDot 1.2s infinite ease-in-out;
}
.chat-typing span:nth-child(2) { animation-delay: 0.15s; }
.chat-typing span:nth-child(3) { animation-delay: 0.3s; }
@keyframes typingDot {
    0%, 60%, 100% { opacity: 0.3; transform: translateY(0); }
    30%           { opacity: 1;   transform: translateY(-3px); }
}

/* pre-send confirmation summary */
.chat-summary {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 2px 10px;
    margin: 8px 0 0 0;
    font-size: 13px;
}
.chat-summary dt { font-weight: bold; color: var(--navy); white-space: nowrap; }
.chat-summary dd { margin: 0; overflow-wrap: anywhere; }

.chat-options { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 5px; }
.chat-btn {
    background: #FFFFFF; border: 1px solid var(--navy); color: var(--navy);
    padding: 8px 12px; border-radius: 4px; cursor: pointer;
    font-size: 13px; transition: all 0.2s; margin-bottom: 5px; font-family: inherit;
}
.chat-btn:hover { background: var(--navy); color: #FFFFFF; }

#chat-input-area { display: flex; padding: 10px; background: #FFFFFF; border-top: 1px solid #EEEEEE; }
#user-input { flex: 1; border: 1px solid #DDDDDD; padding: 10px; border-radius: 4px; outline: none; font-family: inherit; min-width: 0; }
#send-btn {
    background: var(--navy); border: none; color: #FFFFFF;
    font-weight: bold; cursor: pointer; margin-left: 10px;
    padding: 0 15px; border-radius: 4px; font-family: inherit;
}
/* the input is switched off on steps that expect a button press, so it can
   never look like a dead end */
#user-input:disabled { background: #F2F2F2; color: #999999; cursor: not-allowed; }
#send-btn:disabled { background: #B8C4CE; cursor: not-allowed; }

/* honeypot - hidden from people, visible to naive bots */
.hp-field {
    position: absolute !important;
    left: -9999px !important;
    width: 1px; height: 1px; overflow: hidden;
}

/* visible focus ring for keyboard users everywhere */
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible {
    outline: 3px solid var(--gold);
    outline-offset: 2px;
}

/* --------------------------------------------------------------------------
   14. NOSCRIPT FALLBACK
   -------------------------------------------------------------------------- */
.noscript-note {
    margin: 0 0 20px 0; padding: 15px;
    background: #FFF3E0; border: 1px solid #FFE0B2; border-radius: 6px;
    color: #8a5a00; font-size: 14px;
}

/* --------------------------------------------------------------------------
   15. RESPONSIVE
   -------------------------------------------------------------------------- */
@media only screen and (max-width: 768px) {
    /* The 11 nav links wrap to ~3 rows on a phone. A sticky bar that tall would
       permanently eat a fifth of the screen, so it scrolls away instead. */
    .navbar { position: static; padding: 0; }
    .navbar a { padding: 10px 8px; font-size: 14px; }
    .nav-logo-link { position: static; display: block; margin: 10px auto 0 auto; width: max-content; }
    .anchor-offset { scroll-margin-top: 0; }

    .profile-img { float: none; display: block; margin: 0 auto 20px auto; }
    .hero-text   { float: none; text-align: center; }
    .btn-group   { text-align: center; }

    .hero--lab   { padding: 40px 20px 60px 20px; }
    .hero--team  { padding: 80px 20px 60px 20px; }
    .hero--page h1 { font-size: 26px; }
    .hero--page p  { font-size: 16px; }

    .section-header { flex-direction: column; align-items: flex-start; gap: 6px; }

    /* a 150px label column plus the address leaves too little room on a phone,
       so the contact rows stack */
    .contact-table, .contact-table tbody, .contact-table tr, .contact-table td { display: block; width: auto; }
    .contact-table td.label { width: auto; margin-top: 10px; }

    .pub-count { margin-left: 0; }

    /* 50px + 25px of indent is a quarter of a phone screen; and justified text
       in a narrow column opens up rivers of whitespace */
    ol { margin-left: 0; padding-left: 22px; }
    ol li { text-align: left; }

    /* stack the contact details above the map rather than squeezing both */
    .contact-layout { flex-direction: column; gap: 20px; }
    .office-map { width: 100%; }

    .back-to-top { bottom: 10px; right: 10px; padding: 8px 12px; font-size: 12px; }
    .chat-tooltip { display: none; }
}

/* --------------------------------------------------------------------------
   16. REDUCED MOTION (WCAG 2.3.3)
   -------------------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* --------------------------------------------------------------------------
   17. PRINT
   -------------------------------------------------------------------------- */
@media print {
    body { background-color: #FFFFFF; color: #000000; font-size: 12pt; }
    .navbar, .btn-group, .back-to-top, .footer, .pub-tools,
    #chat-icon, #chat-container, .chat-tooltip { display: none !important; }
    .hero { background-color: #FFFFFF; color: #000000; padding: 0; margin-bottom: 20px; page-break-inside: avoid; }
    .hero-text h1, .section-title { color: #000000 !important; border-bottom: 2px solid #000000; }
    .hero-text h2, .bio { color: #333333 !important; }
    .section-card { border: none; box-shadow: none; padding: 0; margin-bottom: 20px; page-break-inside: avoid; }
    .tag { border: 1px solid #000000; background-color: #FFFFFF; color: #000000; }
    a { color: #000000; text-decoration: underline; }
    .pub-link { border: 1px solid #000000; background-color: #FFFFFF; color: #000000; }
    /* a filtered list should still print in full */
    .pub-hidden { display: list-item !important; }
    /* and the news box must not print clipped to its scroll height */
    .news-scroll { max-height: none !important; overflow: visible !important; }
    .news-more { display: none !important; }
    @page { margin: 1in; }
}
