:root {
  --bg: #fafafa;
  --panel: #fff;
  --text: #222;
  --muted: #888;
  --border: #ddd;
  --border-soft: #eee;
  --row-border: #f2f2f2;
  --accent: #2c3e50;
  --accent-hover: #1a2530;
  --link: #2c3e50;
  --tag-bg: #eef;
  --tag-fg: #447;
  --code-bg: #f2f2f2;
  --status-bg: #fafafa;
  --input-bg: #fff;
  --input-border: #ccc;
}
body[data-theme="dark"] {
  --bg: #15181c;
  --panel: #1e2227;
  --text: #e6e8ea;
  --muted: #8a929b;
  --border: #2a2f36;
  --border-soft: #23272d;
  --row-border: #23272d;
  --accent: #4a90d9;
  --accent-hover: #6aa8e8;
  --link: #6aa8e8;
  --tag-bg: #2a3446;
  --tag-fg: #9bb7e0;
  --code-bg: #262b32;
  --status-bg: #181b1f;
  --input-bg: #262b32;
  --input-border: #3a4048;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; font: 14px/1.4 -apple-system, system-ui, "Segoe UI", sans-serif; color: var(--text); background: var(--bg); }
body { display: flex; flex-direction: column; }
header { padding: 10px 16px; border-bottom: 1px solid var(--border); background: var(--panel); }
.titlebar { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; }
h1 { margin: 0; font-size: 16px; font-weight: 600; }
h1 .sub { font-weight: 400; color: var(--muted); font-size: 12px; margin-left: 8px; }
.controls { display: flex; flex-wrap: wrap; gap: 10px 14px; align-items: center; font-size: 13px; }
.controls input, .controls select, .controls button { font: inherit; padding: 4px 8px; border: 1px solid var(--input-border); border-radius: 3px; background: var(--input-bg); color: var(--text); }
.controls button#go,
.controls button#topic-go,
.controls button#country-go,
.controls button#professor-open,
.controls button#professor-add,
.controls button#professor-overview-refresh,
.controls button#professor-overview-add-country { cursor: pointer; background: var(--accent); color: #fff; border: 0; padding: 6px 16px; border-radius: 3px; }
.controls button#go:hover,
.controls button#topic-go:hover,
.controls button#country-go:hover,
.controls button#professor-open:hover,
.controls button#professor-add:hover,
.controls button#professor-overview-refresh:hover,
.controls button#professor-overview-add-country:hover { background: var(--accent-hover); }
.controls button#professor-save-md,
.controls button#professor-overview-save-md,
.controls button#professor-import-md,
.controls button#professor-overview-import-md {
  cursor: pointer;
  background: #1f8a70;
  color: #fff;
  border: 0;
  padding: 6px 16px;
  border-radius: 3px;
}
.controls button#professor-save-md:hover,
.controls button#professor-overview-save-md:hover,
.controls button#professor-import-md:hover,
.controls button#professor-overview-import-md:hover { background: #166b57; }
.controls button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}
.controls button#back { cursor: pointer; padding: 4px 10px; background: var(--input-bg); color: var(--text); border: 1px solid var(--input-border); }
.controls button#back:disabled { opacity: 0.4; cursor: not-allowed; }
.mode-tabs { display: flex; gap: 4px; margin-left: auto; }
.mode-tabs button,
#theme-toggle { cursor: pointer; font: inherit; padding: 4px 10px; border: 1px solid var(--input-border); border-radius: 3px; background: var(--input-bg); color: var(--text); }
.mode-tabs button.active { background: var(--accent); border-color: var(--accent); color: #fff; }
[hidden] { display: none !important; }
.badge { display: inline-block; padding: 1px 6px; border-radius: 10px; font-size: 10px; font-weight: 500; margin-left: 4px; vertical-align: middle; text-decoration: none; }
a.badge:hover { filter: brightness(1.1); text-decoration: none; }
.badge-hiring { background: #d4efdf; color: #196f3d; }
.badge-stable { background: #fdebd0; color: #9c640c; }
.badge-unclear { background: #eaecee; color: #7f8c8d; }
body[data-theme="dark"] .badge-hiring { background: #1e4d2f; color: #82e0aa; }
body[data-theme="dark"] .badge-stable { background: #5a3a10; color: #f5b041; }
body[data-theme="dark"] .badge-unclear { background: #2a2f36; color: #95a5a6; }
.seniority-badge { display: inline-flex; align-items: center; gap: 4px; padding: 1px 6px; margin-right: 5px; border-radius: 10px; font-size: 10px; font-weight: 600; vertical-align: middle; white-space: nowrap; }
.seniority-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; flex: 0 0 8px; }
.seniority-badge.seniority-senior { color: #1d4ed8; background: #dbeafe; }
.seniority-badge.seniority-junior { color: #15803d; background: #dcfce7; }
.seniority-badge.seniority-basic { color: #a93226; background: #fde2df; }
.seniority-senior .seniority-dot, .seniority-dot.seniority-senior { background: #3b82f6; }
.seniority-junior .seniority-dot, .seniority-dot.seniority-junior { background: #22c55e; }
.seniority-basic .seniority-dot, .seniority-dot.seniority-basic { background: #e74c3c; }
.person-row { border-left: 3px solid #e74c3c; padding-left: 8px; }
.person-row.seniority-senior { border-left-color: #3b82f6; }
.person-row.seniority-junior { border-left-color: #22c55e; }
body[data-theme="dark"] .seniority-badge.seniority-senior { color: #93c5fd; background: #1e3a5f; }
body[data-theme="dark"] .seniority-badge.seniority-junior { color: #86efac; background: #173d2a; }
body[data-theme="dark"] .seniority-badge.seniority-basic { color: #fca5a5; background: #4a2323; }
.seniority-legend { display: flex; flex-direction: column; gap: 3px; padding: 6px 8px; border: 1px solid var(--border); border-radius: 4px; background: color-mix(in srgb, var(--panel) 92%, transparent); color: var(--text); box-shadow: 0 1px 4px rgb(0 0 0 / 18%); font: 11px/1.2 -apple-system, system-ui, "Segoe UI", sans-serif; }
.seniority-legend span { display: flex; align-items: center; gap: 5px; }
.topics label { margin-right: 6px; font-weight: normal; }
main { display: grid; grid-template-columns: 1fr 400px; flex: 1; min-height: 0; }
#map { height: 100%; background: var(--bg); }
#panel { border-left: 1px solid var(--border); display: flex; flex-direction: column; overflow: hidden; background: var(--panel); }
#profile { padding: 10px 16px; border-bottom: 1px solid var(--border-soft); font-size: 13px; }
#profile h2 { margin: 0 0 4px; font-size: 15px; font-weight: 600; }
#profile .affil { color: var(--muted); font-size: 12px; }
.tabs { display: flex; border-bottom: 1px solid var(--border-soft); }
.tabs button { flex: 1; background: none; border: 0; padding: 8px; cursor: pointer; font: inherit; color: var(--muted); border-bottom: 2px solid transparent; }
.tabs button.active { color: var(--link); border-bottom-color: var(--link); }
.tab { display: none; flex: 1; overflow: auto; padding: 4px 16px; }
.tab.active { display: block; }
.row { padding: 8px 0; border-bottom: 1px solid var(--row-border); }
.row:last-child { border-bottom: 0; }
.title, .name { font-weight: 500; font-size: 13px; }
.title a, .name a { color: var(--link); text-decoration: none; }
.title a:hover, .name a:hover { text-decoration: underline; }
.meta { font-size: 11px; color: var(--muted); margin-top: 2px; }
.tag { display: inline-block; padding: 1px 5px; margin-right: 4px; background: var(--tag-bg); color: var(--tag-fg); border-radius: 2px; font-size: 10px; }
.w { font-size: 11px; color: var(--muted); font-weight: normal; margin-left: 6px; }
.ext { font-size: 11px; color: var(--muted); text-decoration: none; margin-left: 4px; }
.ext:hover { color: var(--link); }
.copy-inspire { margin-left: 6px; padding: 1px 6px; border: 1px solid var(--input-border); border-radius: 3px; background: var(--input-bg); color: var(--muted); font: inherit; font-size: 10px; line-height: 1.4; cursor: pointer; vertical-align: middle; }
.copy-inspire:hover { color: var(--link); border-color: var(--link); }
.copy-inspire.copied { color: #196f3d; border-color: #27ae60; background: #d4efdf; }
body[data-theme="dark"] .copy-inspire.copied { color: #82e0aa; border-color: #58d68d; background: #1e4d2f; }
#status { padding: 6px 16px; font-size: 11px; color: var(--muted); border-top: 1px solid var(--border-soft); background: var(--status-bg); }
code { background: var(--code-bg); padding: 1px 4px; border-radius: 2px; font-size: 12px; }
.leaflet-popup-content { font: 12px system-ui; }
.leaflet-popup-content b { color: var(--accent); }
.leaflet-popup-content a.popup-author-link { color: var(--link); font-weight: 600; text-decoration: none; }
.leaflet-popup-content a.popup-author-link:hover { text-decoration: underline; }
body[data-theme="dark"] .leaflet-popup-content-wrapper,
body[data-theme="dark"] .leaflet-popup-tip { background: #262b32; color: #e6e8ea; }
body[data-theme="dark"] .leaflet-container { background: #15181c; }
/* Tint only the basemap; preserve researcher markers, lines and attribution. */
.hepnet-basemap-dark { filter: invert(100%) hue-rotate(180deg) brightness(85%) saturate(65%); }


footer { padding: 7px 14px; border-top: 1px solid var(--border); background: var(--panel); color: var(--muted); font-size: 12px; }
footer a { color: var(--link); }
#map, #panel { min-width: 0; }
.controls { row-gap: 10px; }
#profile, .title, .name { font-size: 14px; }
.meta, #profile .affil, #status { font-size: 12px; }
@media (max-width: 760px) {
  body { height: auto; min-height: 100dvh; overflow: auto; }
  .titlebar { flex-wrap: wrap; gap: 10px; }
  h1 .sub { display: block; margin: 4px 0 0; }
  .mode-tabs { margin-left: 0; }
  .controls { font-size: 14px; padding: 10px; }
  .controls input { max-width: 85vw; }
  main { display: flex; flex-direction: column; min-height: 75vh; }
  #map { height: 48vh; min-height: 300px; flex: none; }
  #panel { border-left: 0; min-height: 340px; }
  .tab { max-height: 65vh; }
}
