/* Same palette and type as the writings site, so the two read as one family. */
:root {
  color-scheme: light dark;
  --bg:     #fafaf8;
  --ink:    #111111;
  --muted:  #6e6e69;
  --rule:   #c8c8c3;
  --card:   #f0efeb;
  --accent: #1f5f8b;
  --on-accent: #ffffff;
  /* One hue per research theme: cards, project rules. */
  --t-surveys: #2a6fb0;
  --t-methods: #7a4fb5;
  --t-life:    #2f8a5b;
  --t-infra:   #b0662a;
}

/* Dark: follow the system unless the switch chose light; or the switch chose dark. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg:     #171613;
    --ink:    #eeece6;
    --muted:  #a09c93;
    --rule:   #3b3934;
    --card:   #22211d;
    --accent: #8cc4ea;
    --on-accent: #10202c;
    --t-surveys: #6aaee8;
    --t-methods: #b294e6;
    --t-life:    #6cc89a;
    --t-infra:   #e3a26a;
  }
}
:root[data-theme="dark"] {
  --bg:     #171613;
  --ink:    #eeece6;
  --muted:  #a09c93;
  --rule:   #3b3934;
  --card:   #22211d;
  --accent: #8cc4ea;
  --on-accent: #10202c;
  --t-surveys: #6aaee8;
  --t-methods: #b294e6;
  --t-life:    #6cc89a;
  --t-infra:   #e3a26a;
}
:root[data-theme="light"] { color-scheme: light; }
:root[data-theme="dark"]  { color-scheme: dark; }

body {
  max-width: 760px;
  margin: 48px auto;
  padding: 0 18px;
  background: var(--bg);
  color: var(--ink);
  font: 18px/1.65 system-ui, -apple-system, "Noto Sans Devanagari",
        "Devanagari Sangam MN", "Kohinoor Devanagari", sans-serif;
}

h1, h2, h3 { line-height: 1.2; }
h1 { margin-bottom: 0.2rem; }
h2 { margin-top: 2.2rem; }
a { color: var(--accent); text-underline-offset: 3px; }
hr { border: 0; border-top: 1px solid var(--rule); }
.meta { color: var(--muted); font-size: 0.92em; }
h1 + p { color: var(--muted); margin-top: 0; }
.portrait {
  float: right;
  width: 170px;
  height: auto;
  margin: 0 0 1rem 1.5rem;
  border-radius: 50%;
}
@media (max-width: 520px) {
  .portrait { width: 110px; margin-left: 1rem; }
}

/* --- Navigation ---------------------------------------------------------- */
nav { display: flex; flex-wrap: wrap; gap: 0.2rem 1rem; }
nav a.navlink { color: var(--ink); opacity: 0.75; text-decoration: none; }
nav a.navlink:hover { opacity: 1; }
/* Sits in the top margin, right edge, so it never competes with the nav for room. */
body { position: relative; }
.theme-toggle {
  position: absolute;
  top: -2.1rem;
  right: 18px;
  padding: 0 0.5rem;
  border: 1px solid var(--rule);
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 0.85em;
  cursor: pointer;
}
.theme-toggle:hover { color: var(--ink); border-color: var(--ink); }
nav a.navlink.nav-active {
  opacity: 1;
  font-weight: 700;
  border-bottom: 2px solid currentColor;
  padding-bottom: 2px;
}

/* --- Home ---------------------------------------------------------------- */
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 0.8rem;
  margin: 1rem 0;
}
.card {
  --t: var(--accent);
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  padding: 0.8rem 0.9rem;
  border-radius: 10px;
  background: var(--card);
  color: var(--ink);
  text-decoration: none;
  line-height: 1.35;
  border-top: 3px solid var(--t);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.card:hover { transform: translateY(-2px); box-shadow: 0 6px 18px rgba(0,0,0,0.15); }
.card-title { font-weight: 650; }
.card-role { color: var(--muted); font-size: 0.85em; }

.news { list-style: none; padding-left: 0; }
.news li { margin: 0.4rem 0; }
.when { color: var(--muted); font-size: 0.9em; margin-right: 0.4rem; white-space: nowrap; }

/* --- Buttons and chips ---------------------------------------------------- */
.buttons { display: flex; flex-wrap: wrap; gap: 0.5rem; margin: 1rem 0; }
.btn {
  display: inline-block;
  padding: 0.4rem 1rem;
  border: 1.5px solid var(--accent);
  border-radius: 999px;
  color: var(--accent);
  font-weight: 550;
  text-decoration: none;
  line-height: 1.3;
  transition: background 0.15s ease, color 0.15s ease;
}
.btn:hover, .btn-primary { background: var(--accent); color: var(--on-accent); }
.btn-primary:hover { filter: brightness(1.12); }
.btn-sm { padding: 0.2rem 0.75rem; font-size: 0.88em; }
/* Theme buttons on Research take the theme hue. */
.theme-btn { border-color: var(--t); color: var(--t); }
.theme-btn:hover { background: var(--t); color: var(--bg); }

.chip {
  display: inline-block;
  padding: 0 0.5rem;
  border-radius: 6px;
  background: var(--card);
  font-size: 0.85em;
  text-decoration: none;
}
.chip:hover { text-decoration: underline; }

/* --- Research ------------------------------------------------------------ */
.project { margin: 1.4rem 0; padding-left: 0.9rem; border-left: 3px solid var(--t, var(--rule)); }
.theme-surveys { --t: var(--t-surveys); }
.theme-methods { --t: var(--t-methods); }
.theme-life    { --t: var(--t-life); }
.theme-infra   { --t: var(--t-infra); }
.project h3 { margin-bottom: 0.2rem; }
.project .meta { margin: 0 0 0.4rem; }
.project p { margin: 0.4rem 0; }

.badge {
  display: inline-block;
  padding: 0.05rem 0.5rem;
  border: 1px solid currentColor;
  border-radius: 999px;
  font-size: 0.72em;
  font-weight: 400;
  line-height: 1.4;
  color: var(--muted);
  margin-left: 0.4rem;
  vertical-align: middle;
  white-space: nowrap;
}

/* --- Lists (talks, publications) ---------------------------------------- */
.plain-list, .work-list { list-style: none; padding-left: 0; margin: 0.5rem 0 1.5rem; }
.plain-list li, .work-list .work-row { margin: 0.75rem 0; line-height: 1.45; }
.plain-list .year-head, .work-list .year-head {
  margin: 1.6rem 0 0.4rem;
  font-weight: 650;
  color: var(--muted);
  border-bottom: 1px solid var(--rule);
}
.pub-title { font-weight: 550; text-decoration: none; }
.pub-title:hover { text-decoration: underline; }
.pub-authors { font-size: 0.9em; }

.list-controls[hidden] { display: none; }
.list-controls {
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
  margin: 1rem 0 1.25rem;
  padding-bottom: 0.9rem;
  border-bottom: 1px solid var(--rule);
  font-size: 0.92em;
}
.lc-row { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem 1.1rem; }
.lc-chips { gap: 0.45rem; }
.lc-grow { flex: 1 1 14rem; }
.lc-grow input[type="search"] { width: 100%; }
.lc-field { display: inline-flex; align-items: center; gap: 0.4rem; color: var(--muted); }
.lc-field select, .lc-field input[type="search"] {
  border: 1px solid var(--rule);
  border-radius: 999px;
  padding: 0.25rem 0.7rem;
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-size: 0.95em;
}
.lc-field input[type="search"] { width: 14rem; max-width: 100%; }
.lc-field select { max-width: 15rem; text-overflow: ellipsis; }
.lc-count { margin-left: auto; color: var(--muted); }
.lc-clear[hidden] { display: none; }

/* Topic chips: toggle buttons, one active at a time. */
.tchip {
  padding: 0.25rem 0.8rem;
  border: 1.5px solid var(--rule);
  border-radius: 999px;
  background: transparent;
  color: var(--ink);
  font: inherit;
  cursor: pointer;
}
.tchip:hover { border-color: var(--accent); }
.tchip[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.tchip-n { color: var(--muted); font-size: 0.85em; margin-left: 0.2rem; }
.tchip[aria-pressed="true"] .tchip-n { color: inherit; opacity: 0.8; }

.year-n { font-weight: 400; font-size: 0.85em; margin-left: 0.4rem; }
.chip-cites { color: var(--muted); }

/* --- Summary tiles --------------------------------------------------------- */
.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 0.6rem;
  margin: 1.2rem 0 0.5rem;
}
.stat {
  display: flex;
  flex-direction: column;
  padding: 0.7rem 0.9rem;
  border-radius: 10px;
  background: var(--card);
}
.stat-num { font-size: 1.6em; font-weight: 700; line-height: 1.15; font-variant-numeric: tabular-nums; }
.stat-label { color: var(--muted); font-size: 0.82em; }

/* --- Papers-per-year chart --------------------------------------------------
   One series, one hue. Bars are buttons (click = filter to that year), with a
   2px gap, 4px rounded tops anchored to the baseline, and a hit area the full
   column height so short bars are still easy to hit. */
.ychart { position: relative; margin: 0.5rem 0 1rem; }
.ychart figcaption { margin-bottom: 0.5rem; }
.ychart-bars, .ychart-axis {
  display: grid;
  grid-template-columns: repeat(var(--n), 1fr);
  column-gap: 2px;
}
.ychart-bars { height: 120px; border-bottom: 1px solid var(--rule); }
.ybar {
  position: relative;
  height: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
}
.ybar-fill {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: var(--h);
  min-height: 0;
  border-radius: 4px 4px 0 0;
  background: var(--accent);
  transition: height 0.25s ease, opacity 0.15s ease;
}
.ybar:hover .ybar-fill, .ybar:focus-visible .ybar-fill { filter: brightness(1.2); }
.ybar:focus-visible { outline: 2px solid var(--ink); outline-offset: 1px; }
.ybar.is-dim .ybar-fill { opacity: 0.3; }
.ychart-axis { font-size: 0.75em; color: var(--muted); margin-top: 0.2rem; }
.ychart-axis span { white-space: nowrap; transform: translateX(-25%); }
.ytip {
  position: absolute;
  top: 1.6rem;
  transform: translateX(-50%);
  padding: 0.15rem 0.5rem;
  border-radius: 6px;
  background: var(--ink);
  color: var(--bg);
  font-size: 0.8em;
  white-space: nowrap;
  pointer-events: none;
}
.ytip[hidden] { display: none; }

/* --- Imported personal pages ---------------------------------------------- */
/* Old HTML kept as it was: keep it inside the column and readable in both themes. */
.back-link { font-size: 0.9em; color: var(--muted); margin: 0 0 1rem; }
.legacy { overflow-x: auto; }
.legacy img { max-width: 100%; height: auto; }
.legacy table { border-collapse: collapse; margin: 0.8rem 0; }
.legacy td, .legacy th { padding: 0.25rem 0.5rem; vertical-align: top; }
.legacy table[border] td, .legacy table[border] th { border: 1px solid var(--rule); }
.legacy-text, .legacy pre { white-space: pre-wrap; font-size: 0.92em; line-height: 1.5; }
/* Old pages colour table cells (green = have, red = missing); soften for dark mode. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .legacy [bgcolor] { color: #111; }
}
:root[data-theme="dark"] .legacy [bgcolor] { color: #111; }

@media (max-width: 600px) {
  body { margin-top: 40px; font-size: 17px; }
  .lc-count { margin-left: 0; }
}
