:root {
  --primary:  #1d3461;
  --accent:   #2563eb;
  --bg:       #f7f8fa;
  --surface:  #ffffff;
  --border:   #e4e6ea;
  --muted:    #6b7280;
  --text:     #111827;
  --radius:   6px;
  --sans: system-ui, -apple-system, "Segoe UI", Helvetica, Arial, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: var(--sans);
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
  line-height: 1.5;
}

/* ── Header ─────────────────────────────────────────────────────────── */
header {
  background: var(--primary);
  color: #fff;
  padding: 1.1rem 2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

header h1 {
  font-size: 1.15rem;
  font-weight: 600;
  letter-spacing: -.01em;
}

.btn-add {
  font-size: .78rem;
  color: rgba(255, 255, 255, .85);
  text-decoration: none;
  border: 1px solid rgba(255, 255, 255, .35);
  padding: .28rem .7rem;
  border-radius: 4px;
  white-space: nowrap;
  transition: background 120ms, color 120ms;
}

.btn-add:hover {
  background: rgba(255, 255, 255, .1);
  color: #fff;
}

/* ── Main ────────────────────────────────────────────────────────────── */
main {
  padding: 1.5rem 2rem;
  max-width: 1100px;
}

/* ── Search panel ────────────────────────────────────────────────────── */
.search-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .75rem .9rem .65rem;
  margin-bottom: 1rem;
}

.search-row {
  display: flex;
  align-items: center;
  gap: .6rem;
  flex-wrap: wrap;
  margin-bottom: .75rem;
}

#search-input {
  flex: 1;
  min-width: 180px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .4rem .65rem;
  font-size: .88rem;
  font-family: var(--sans);
  background: var(--bg);
  color: var(--text);
}

#search-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, .12);
}


.results-count {
  font-size: .78rem;
  color: var(--muted);
  margin-bottom: .65rem;
}

.results-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: .35rem;
}

/* ── Submit form ─────────────────────────────────────────────────────── */
.submit-main {
  max-width: 480px;
}

.submit-main h2 {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: .35rem;
}

.submit-main > p {
  font-size: .85rem;
  color: var(--muted);
  margin-bottom: 1.5rem;
}

.submit-form {
  display: flex;
  flex-direction: column;
  gap: .3rem;
}

.submit-form label {
  font-size: .68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--muted);
  margin-top: .6rem;
}

.submit-form input {
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: .45rem .6rem;
  font-size: .88rem;
  font-family: var(--sans);
  background: var(--surface);
  color: var(--text);
  width: 100%;
}

.submit-form input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, .12);
}

.submit-form button {
  margin-top: .9rem;
  align-self: flex-start;
  padding: .42rem 1.1rem;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 4px;
  font-size: .85rem;
  font-weight: 500;
  font-family: var(--sans);
  cursor: pointer;
}

.submit-form button:hover { background: #1d4ed8; }

/* ── Heatmap animation ───────────────────────────────────────────────── */
@keyframes hmFadeIn {
  from { opacity: 0; transform: translateY(5px); }
  to   { opacity: 1; transform: translateY(0);   }
}

#heatmap.hm-fade-in { animation: hmFadeIn 180ms ease-out; }

/* ── Heatmap breadcrumb ──────────────────────────────────────────────── */
.hm-breadcrumb {
  font-size: .72rem;
  color: var(--muted);
  padding-bottom: .4rem;
  display: flex;
  align-items: center;
  gap: .25rem;
}

.hm-bc-link {
  color: var(--accent);
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.hm-bc-link:hover { color: #1d4ed8; }

.hm-bc-current {
  color: var(--text);
  font-weight: 500;
}

/* ── Heatmap ─────────────────────────────────────────────────────────── */
#heatmap {
  display: grid;
  gap: 2px;
  align-items: end;
}

.hm-col-label {
  writing-mode: vertical-rl;
  transform: rotate(180deg);
  font-size: .6rem;
  font-weight: 600;
  color: var(--muted);
  text-align: left;
  padding-bottom: 5px;
  line-height: 1;
  transition: color 100ms;
}

.hm-col-label.active { color: var(--accent); }

.hm-row-label {
  font-size: .72rem;
  color: var(--text);
  padding-right: .6rem;
  white-space: nowrap;
  text-align: right;
  line-height: 1;
  align-self: center;
  transition: color 100ms;
  cursor: pointer;
}

.hm-row-label:hover { color: var(--accent); }

.hm-country-label {
  font-size: .65rem;
  color: var(--muted);
  padding-left: .6rem;
  cursor: default;
}

.hm-row-label.active {
  color: var(--accent);
  font-weight: 600;
}

.hm-cell {
  aspect-ratio: 1;
  border-radius: 3px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .65rem;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.6);
  transition: transform 80ms, box-shadow 80ms, color 80ms;
  user-select: none;
}

.hm-cell:not(:empty) { cursor: pointer; }

.hm-cell:not(:empty):hover {
  transform: scale(1.07);
  box-shadow: 0 2px 8px rgba(0, 0, 0, .2);
  color: #fff;
  position: relative;
  z-index: 1;
}

.hm-cell.active {
  box-shadow: 0 0 0 2px var(--accent);
  transform: scale(1.09);
  color: #fff;
  position: relative;
  z-index: 2;
}

/* ── Card ────────────────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .65rem .9rem;
  transition: border-color 120ms, box-shadow 120ms;
}

.card:hover {
  border-color: #b0bcd4;
  box-shadow: 0 1px 5px rgba(0, 0, 0, .06);
}

.card-top {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: .35rem;
  margin-bottom: .22rem;
}

.period {
  font-size: .82rem;
  font-weight: 700;
  color: var(--primary);
}

.tag {
  font-size: .68rem;
  font-weight: 500;
  background: #eef1f8;
  color: #374a6d;
  padding: .07rem .42rem;
  border-radius: 10px;
  cursor: pointer;
  transition: background 100ms, color 100ms;
}

.tag:hover { background: #d6dfef; color: #1d3461; }

.country-tags {
  display: flex;
  flex-wrap: wrap;
  gap: .25rem;
  margin-bottom: .15rem;
}

.country-tag {
  font-size: .62rem;
  font-weight: 500;
  background: #f0f2f8;
  color: #5a6a8a;
  padding: .05rem .38rem;
  border-radius: 8px;
  cursor: pointer;
  transition: background 100ms, color 100ms;
}

.country-tag:hover { background: #dde2f0; color: #374a6d; }

.card-title {
  font-size: .92rem;
  font-weight: 500;
  line-height: 1.4;
  color: var(--text);
  margin-bottom: .18rem;
}

.card-abstract {
  font-size: .76rem;
  line-height: 1.45;
  color: var(--muted);
  margin-bottom: .2rem;
}

/* Collapsed: single line, abruptly clipped; the "…" button is the clip indicator. */
.card-abstract[data-collapsed="true"] {
  display: flex;
  align-items: baseline;
  gap: .25rem;
}

.card-abstract[data-collapsed="true"] .abstract-text {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
}

.card-abstract[data-collapsed="false"] .abstract-text {
  white-space: normal;
}

.abstract-toggle {
  flex: 0 0 auto;
  background: none;
  border: none;
  padding: 0 0 0 .15rem;
  cursor: pointer;
  color: var(--primary);
  font-size: .76rem;
  font-weight: 700;
  line-height: 1.45;
}

.abstract-toggle:hover { text-decoration: underline; }

.card-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: .12rem;
}

.card-authors {
  font-size: .76rem;
  color: var(--muted);
}

.card-links {
  display: flex;
  align-items: center;
  gap: .5rem;
  flex-shrink: 0;
  margin-left: .75rem;
}

.btn-data {
  display: inline-block;
  background: var(--accent);
  color: #fff;
  text-decoration: none;
  padding: .22rem .6rem;
  border-radius: 4px;
  font-size: .76rem;
  font-weight: 500;
  white-space: nowrap;
}

.btn-data:hover { background: #1d4ed8; }

.btn-article {
  font-size: .76rem;
  color: var(--muted);
  text-decoration: none;
  white-space: nowrap;
}

.btn-article:hover { color: var(--accent); text-decoration: underline; }

.btn-error {
  font-size: .72rem;
  color: #9ca3af;
  text-decoration: none;
  white-space: nowrap;
}

.btn-error:hover { color: #dc2626; text-decoration: underline; }
