/* author-trends — layout + components. Mirrors journal-trends.
 * Tokens live in theme.css. Base font is 14px so every chip, table cell and
 * tab feels small and dense — the visual register journal-trends sits in.
 */

* { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 18.5px; }                  /* +20% over 15.4 (≈ +32% over original 14) */
html, body { height: 100%; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  min-height: 100vh;
  padding: 20px 28px;
  line-height: 1.45;
  max-width: 1180px;
  margin: 0 auto;
}

a { color: var(--link); text-decoration: none; }
a:hover { color: var(--link-strong); text-decoration: underline; }

.hidden { display: none !important; }
.dim    { color: var(--text-dim); }
.mono   { font-family: 'Cascadia Code', Consolas, monospace; color: var(--text-muted); font-size: 0.78rem; }

/* ── Top nav ─────────────────────────────────────────────────────────────── */
.topbar {
  display: flex; align-items: center; flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 18px;
  padding: 4px 0 14px;
  border-bottom: 1px solid var(--grid);
  position: relative;
}
.topbar-spacer { flex: 1; }

.brand { display: inline-flex; align-items: center; gap: 12px; text-decoration: none; color: var(--text-strong); }
.brand:hover { text-decoration: none; }
.brand-text { display: flex; flex-direction: column; line-height: 1; }
.brand-name {
  font-size: clamp(1.3rem, 4.8vw, 1.95rem);
  font-weight: 800; letter-spacing: -0.025em; line-height: 1; white-space: nowrap;
}
.brand-author { color: var(--tips-pct); }
.brand-trends { color: var(--trend); padding-left: 0.18ch; }
.brand:hover .brand-author { color: #58a6ff; }
.brand:hover .brand-trends { color: #ffc847; }
.brand-tagline {
  font-size: clamp(0.6rem, 1.4vw, 0.74rem);
  color: var(--text-muted);
  margin-top: 4px;
  letter-spacing: 0.02em;
}

.topbar-link {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid transparent;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.86rem;
  font-family: inherit;
  cursor: pointer;
  transition: color .15s, border-color .15s, background .15s;
}
.topbar-link:hover { color: var(--text); border-color: var(--border); background: var(--surface); }

.topbar-menu {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  font-family: inherit;
  cursor: pointer;
}
.topbar-menu:hover { color: var(--text); background: var(--surface); }

@media (min-width: 601px) {
  .topbar-links { display: flex; align-items: center; gap: 4px; }
  .topbar-menu  { display: none; }
}
@media (max-width: 600px) {
  .topbar-links {
    display: none;
    position: absolute;
    top: 100%; right: 0;
    flex-direction: column; align-items: stretch;
    gap: 0; padding: 6px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: 0 8px 24px rgba(0,0,0,0.4);
    z-index: 50; min-width: 160px;
  }
  .topbar.menu-open .topbar-links { display: flex; }
  .topbar-links .topbar-link { padding: 9px 12px; text-align: left; border-radius: var(--radius-sm); }
  .topbar-links .topbar-link:hover { background: var(--surface-2); }
}

/* ── Page header ─────────────────────────────────────────────────────────── */
header.app-header {
  margin-bottom: 18px;
  text-align: center;
  padding: 4px 0 0;
}
header.app-header h1 { margin: 0 auto 6px; }
header.app-header .subtitle { margin-left: auto; margin-right: auto; }
header.app-header .feature-list {
  list-style: none;
  padding: 0;
  margin: 10px auto;
  display: inline-block;
  text-align: left;
  font-size: 0.84rem;
  color: var(--text-body);
  line-height: 1.55;
  max-width: 660px;
}
header.app-header .feature-list li {
  padding-left: 22px;
  position: relative;
  margin-bottom: 3px;
}
header.app-header .feature-list li::before {
  content: "✓";
  position: absolute;
  left: 0; top: 0;
  color: var(--inst-pct);
  font-weight: 700;
}
.search-wrap { margin-left: auto; margin-right: auto; }
header.app-header h1 .beta-tag {
  display: inline-block;
  font-size: 0.6rem; font-weight: 700;
  background: rgba(252,92,101,0.12);
  color: var(--pps-pct);
  border: 1px solid rgba(252,92,101,0.4);
  padding: 1px 7px;
  border-radius: 999px;
  vertical-align: 3px;
  letter-spacing: 0.06em;
  margin-left: 6px;
}
.beta-note { margin-top: 6px; font-style: italic; }
.beta-note strong { font-style: normal; color: var(--text-strong); }

header.app-header h1 {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-strong);
  margin-bottom: 4px;
  line-height: 1.3;
}
.subtitle {
  font-size: 0.78rem;
  color: var(--text-muted);
  line-height: 1.55;
  max-width: 720px;
}

/* ── Search ──────────────────────────────────────────────────────────────── */
.search-wrap { margin-bottom: 14px; max-width: 720px; }
.search-row  { display: flex; gap: 8px; align-items: stretch; }
.search-input {
  flex: 1; padding: 9px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text); font-size: 0.86rem; font-family: inherit;
  outline: none; transition: border-color .15s;
}
.search-input:focus { border-color: var(--link); }
.search-input::placeholder { color: var(--text-dim); }

.btn {
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  font-size: 0.76rem; font-family: inherit;
  cursor: pointer;
  transition: border-color .15s, color .15s, background .15s;
}
.btn:hover { border-color: var(--link); color: var(--link); }
.btn.primary { background: var(--link-strong); border-color: var(--link-strong); color: #fff; }
.btn.primary:hover { background: #1664d6; border-color: #1664d6; color: #fff; }
.btn:disabled { opacity: .4; cursor: not-allowed; }
#search-btn { padding: 0 16px; font-size: 0.82rem; }

.status { font-size: 0.74rem; color: var(--text-muted); padding: 4px 0; min-height: 1.2em; }
.status.error { color: var(--danger); }
.status.good  { color: var(--inst-pct); }

/* ── Modal ───────────────────────────────────────────────────────────────── */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.7);
  display: none; align-items: center; justify-content: center;
  z-index: 1000;
}
.modal-backdrop.visible { display: flex; }
.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 22px 26px;
  max-width: 540px;
  width: calc(100% - 32px);
  max-height: calc(100vh - 48px);
  overflow-y: auto;
  box-shadow: var(--shadow-tooltip);
}
.modal h2 { font-size: 1.05rem; color: var(--text-strong); margin-bottom: 8px; }
.modal h3 {
  margin-top: 14px; margin-bottom: 6px;
  font-size: 0.72rem; font-weight: 600; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: .07em;
}
.modal p { color: var(--text-body); font-size: 0.82rem; line-height: 1.55; margin-bottom: 12px; }
.modal .about-list { list-style: disc inside; font-size: 0.82rem; color: var(--text-body); line-height: 1.6; margin-bottom: 12px; }
.modal .disclaimer {
  font-size: 0.78rem; line-height: 1.55; color: var(--text-body);
  background: rgba(248,81,73,0.06);
  border: 1px solid rgba(248,81,73,0.25);
  border-radius: var(--radius-sm);
  padding: 10px 12px; margin-bottom: 14px;
}
.modal .modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; }

/* ── Candidate picker ───────────────────────────────────────────────────── */
.candidates {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 8px;
  margin-bottom: 14px;
}
.candidate {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  text-align: left; color: var(--text); font: inherit;
  cursor: pointer;
  transition: border-color .12s, background .12s;
  display: flex; flex-direction: column; gap: 4px;
}
.candidate:hover { border-color: var(--link); background: var(--surface-2); }
.cand-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.cand-name { font-weight: 600; font-size: 0.84rem; color: var(--text-strong); }
.cand-id   { font-size: 0.64rem; color: var(--text-dim); font-family: 'Cascadia Code', Consolas, monospace; }
.cand-meta { font-size: 0.72rem; color: var(--text-body); }
.cand-stats {
  display: flex; flex-wrap: wrap; gap: 8px;
  font-size: 0.68rem; color: var(--text-muted); margin-top: 2px;
}
.cand-stats b { color: var(--text-strong); font-weight: 600; }
.cand-concepts { display: flex; flex-wrap: wrap; gap: 3px; margin-top: 3px; }
.cand-affs {
  list-style: none;
  margin-top: 3px;
  padding-left: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 0.74rem;
  color: var(--text-body);
}
.cand-affs li { line-height: 1.35; }
.aff-years { color: var(--text-dim); font-size: 0.66rem; margin-left: 4px; }

/* Merge indicator — used on both candidate cards and the selected banner. */
.merged-badge {
  display: inline-block;
  font-size: 0.66rem; font-weight: 600;
  background: rgba(130,80,223,0.12);
  color: #8250df;
  border: 1px solid rgba(130,80,223,0.4);
  padding: 2px 8px;
  border-radius: 999px;
  margin-left: 6px;
  vertical-align: 2px;
  letter-spacing: 0.02em;
  text-decoration: none;
}
.merged-badge:hover { background: rgba(130,80,223,0.2); color: #8250df; text-decoration: none; }
.merged-detail { margin-top: 4px; }
.merged-list {
  list-style: none; padding-left: 0; margin-top: 6px;
  font-size: 0.74rem; color: var(--text-body);
  display: flex; flex-direction: column; gap: 3px;
}
.merged-list .mono { font-size: 0.7rem; color: var(--text-muted); }

.chip {
  display: inline-block; font-size: 0.64rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-body);
  padding: 2px 6px; border-radius: 999px;
}

/* ── Selected-source banner ─────────────────────────────────────────────── */
.selected-source {
  display: none;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 11px 14px;
  margin-bottom: 10px;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}
.selected-source.visible { display: flex; }
.selected-source .name { font-weight: 600; color: var(--text-strong); font-size: 0.95rem; }
.selected-source .meta {
  color: var(--text-muted); font-size: 0.72rem; margin-top: 2px;
  display: flex; flex-wrap: wrap; gap: 6px; align-items: center;
}
.selected-source .meta .sep { color: var(--text-dim); }
.selected-source .last-updated { font-size: 0.66rem; margin-top: 2px; opacity: 0.85; }
.selected-source .filter-note  { font-size: 0.7rem; margin-top: 2px; color: var(--text-dim); font-style: italic; }
.selected-source .actions { display: flex; gap: 5px; flex-wrap: wrap; flex-shrink: 0; }
.selected-source .ss-body { min-width: 0; }
/* Headline stat row — big numbers, small uppercase labels underneath. */
.selected-source .stats-inline {
  display: flex; flex-wrap: wrap;
  margin-top: 8px;
  gap: 22px;
  font-size: 0.66rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 600;
}
.selected-source .stats-inline > span {
  display: inline-flex; flex-direction: column; align-items: flex-start; gap: 0;
  min-width: 64px;
}
.selected-source .stats-inline strong {
  font-weight: 800;
  font-size: 1.55rem;
  letter-spacing: -0.01em;
  line-height: 1.05;
  text-transform: none;
  margin-bottom: 1px;
}
@media (max-width: 600px) {
  .selected-source .stats-inline { gap: 14px; }
  .selected-source .stats-inline strong { font-size: 1.25rem; }
}

@media (max-width: 600px) {
  .selected-source { flex-direction: column; align-items: flex-start; padding: 10px 12px; }
  .selected-source .actions { width: 100%; justify-content: flex-start; }
}

.blue   { color: var(--tips-pct); }
.amber  { color: var(--trend); }
.green  { color: var(--inst-pct); }
.purple { color: #a55eea; }
.red    { color: var(--pps-pct); }

/* ── Progress ───────────────────────────────────────────────────────────── */
.progress-wrap {
  display: none;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 11px 14px;
  margin-bottom: 12px;
}
.progress-wrap.visible { display: block; }
.progress-status {
  font-size: 0.76rem; color: var(--text-body);
  margin-bottom: 6px;
  display: flex; justify-content: space-between; gap: 12px;
}
.progress-status .pct { color: var(--link); font-weight: 600; }
.progress-bar {
  height: 5px; background: var(--grid);
  border-radius: 4px; overflow: hidden;
}
.progress-bar-fill {
  height: 100%;
  background: var(--link-strong);
  width: 0%;
  transition: width .25s ease;
}

/* ── Tabs ───────────────────────────────────────────────────────────────── */
.tabs-wrap { display: none; }
.tabs-wrap.visible { display: block; }

.tabs {
  display: flex; gap: 0; flex-wrap: wrap;
  margin-bottom: 12px;
  border-bottom: 1px solid var(--border);
}
.tab {
  padding: 8px 14px;
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 0.78rem; font-family: inherit;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: color .15s, border-color .15s;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--link); border-bottom-color: var(--link); }
.tab-panel { display: none; }
.tab-panel.active { display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; }
.tab-panel.active > * { min-width: 0; }

@media (max-width: 600px) {
  .tab { padding: 7px 10px; font-size: 0.74rem; }
}

/* ── Cards / charts ─────────────────────────────────────────────────────── */
.card, .chart-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  min-width: 0;        /* let cards shrink inside grid/flex parents */
  overflow: hidden;    /* prevent canvas pixel-rounding from leaking outside */
}
.card-title {
  font-size: 0.68rem; font-weight: 600;
  color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.08em;
  margin-bottom: 10px;
}
.sub-title {
  font-size: 0.62rem; font-weight: 600;
  color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.08em;
  margin-bottom: 5px;
}

.chart-wrap     { position: relative; height: 280px; width: 100%; max-width: 100%; min-width: 0; }
.chart-wrap-sm  { height: 180px; }
.chart-wrap-md  { height: 240px; }
.chart-wrap-lg  { height: 340px; }
.chart-wrap canvas { max-width: 100% !important; display: block; }

.two-col-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 14px;
}
.two-col-grid > * { min-width: 0; }
@media (max-width: 760px) {
  .two-col-grid { grid-template-columns: minmax(0, 1fr); }
}

/* Profile-tab metric cards — bigger than .chip, smaller than chart cards. */
.metric-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 8px;
}
.metric {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  display: flex; flex-direction: column; gap: 1px;
}
.metric-val { font-size: 1.2rem; font-weight: 700; line-height: 1.2; }
.metric-lbl { font-size: 0.7rem; color: var(--text-body); font-weight: 600; }
.metric-sub { font-size: 0.6rem; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.05em; }

/* ── Legend ─────────────────────────────────────────────────────────────── */
.legend {
  display: flex; flex-wrap: wrap; gap: 4px 10px;
  margin-top: 10px; font-size: 0.68rem; color: var(--text-body);
}
.lg-item {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  cursor: pointer;
  padding: 3px 8px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  user-select: none;
  transition: opacity .15s, border-color .12s, background .12s;
}
.lg-item:hover          { background: var(--surface-2); }
.lg-item.dimmed         { opacity: 0.3; }
.lg-item.locked         { border-color: var(--link); background: var(--surface-2); }
.lg-item.legend-hovered { border-color: var(--text-muted); background: var(--surface-2); }
.lg-sw   { display: inline-block; width: 10px; height: 10px; border-radius: 2px; flex-shrink: 0; }
.lg-extra { color: var(--text-dim); margin-left: 3px; }

/* ── Tables ─────────────────────────────────────────────────────────────── */
.ret-table {
  width: 100%; border-collapse: collapse;
  font-size: 0.72rem; margin-top: 8px;
}
.ret-table th, .ret-table td {
  border-bottom: 1px solid var(--border);
  padding: 5px 7px; text-align: left; vertical-align: top;
}
.ret-table th {
  color: var(--text-muted); font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.06em; font-size: 0.6rem;
}
.ret-table tbody tr:hover { background: var(--surface-2); }
.ret-table-scroll { overflow-x: auto; }
.ret-title { font-weight: 600; color: var(--text-strong); margin-bottom: 2px; line-height: 1.3; }

.ret-source-row { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0 8px; }
.ret-src {
  display: inline-block;
  font-size: 0.66rem; font-weight: 600;
  padding: 2px 8px; border-radius: 999px;
  text-transform: uppercase; letter-spacing: 0.05em;
  border: 1px solid var(--border);
  background: var(--surface-2); color: var(--text-muted);
}
.ret-src-pps  { color: var(--pps-pct); border-color: rgba(252,92,101,0.4); background: rgba(252,92,101,0.10); }
.ret-src-oa   { color: var(--link);    border-color: rgba(31,111,235,0.4); background: rgba(31,111,235,0.10); }
.ret-src-both { color: #8250df;        border-color: rgba(130,80,223,0.4); background: rgba(130,80,223,0.10); }

/* ── Expandable ─────────────────────────────────────────────────────────── */
details.expandable { margin-top: 6px; border-top: 1px dashed var(--border); }
details.expandable > summary {
  list-style: none;
  cursor: pointer;
  padding: 7px 4px;
  font-size: 0.7rem;
  color: var(--link);
  user-select: none;
  display: inline-flex; align-items: center; gap: 5px;
}
details.expandable > summary::-webkit-details-marker { display: none; }
details.expandable > summary::before {
  content: "▸"; color: var(--text-dim);
  transition: transform .15s; display: inline-block;
}
details.expandable[open] > summary::before { transform: rotate(90deg); }
details.expandable > summary:hover { color: var(--link-strong); }

/* OpenAlex "fix an attribution" note. Lives between the tabs and the
 * Similar-Authors strip. Visible whenever the tabs container is. */
.openalex-note {
  display: none;
  margin: 14px 0 4px;
  padding: 11px 14px;
  font-size: 0.78rem;
  line-height: 1.5;
  color: var(--text-body);
  background: rgba(31, 111, 235, 0.08);
  border: 1px solid rgba(31, 111, 235, 0.35);
  border-radius: var(--radius-md);
}
.tabs-wrap.visible ~ .openalex-note { display: block; }
.openalex-note strong { color: var(--text-strong); font-weight: 700; }

/* PPS detector glossary block */
details.detector-info { margin-top: 12px; }
.detector-list { list-style: none; padding-left: 0; display: flex; flex-direction: column; gap: 9px; margin-top: 8px; }
.detector-row-head { display: flex; gap: 8px; align-items: center; }
.detector-name {
  font-weight: 600; color: var(--text-strong); font-size: 0.82rem;
  font-family: 'Cascadia Code', Consolas, monospace;
}
.detector-signal {
  display: inline-block;
  font-size: 0.62rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 2px 7px;
  border-radius: 999px;
  font-weight: 600;
}
.sig-strong  { background: rgba(252,92,101,0.15);  color: var(--pps-pct); border: 1px solid rgba(252,92,101,0.35); }
.sig-medium  { background: rgba(247,183,49,0.15);  color: var(--trend);   border: 1px solid rgba(247,183,49,0.35); }
.sig-weak    { background: rgba(139,148,158,0.15); color: var(--text-muted); border: 1px solid var(--border); }
.sig-neutral { background: rgba(31,111,235,0.12);  color: var(--link);    border: 1px solid rgba(31,111,235,0.35); }
.detector-blurb { font-size: 0.78rem; color: var(--text-body); margin-top: 3px; line-height: 1.45; }
.detector-footer {
  font-size: 0.72rem; color: var(--text-muted); margin-top: 10px;
  padding-top: 8px; border-top: 1px dashed var(--border);
  line-height: 1.45;
}

/* ── Tooltip ────────────────────────────────────────────────────────────── */
#tooltip {
  position: fixed; pointer-events: none;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 9px 12px;
  font-size: 0.72rem; color: var(--text);
  min-width: 200px; max-width: 340px;
  box-shadow: var(--shadow-tooltip);
  opacity: 0; transition: opacity .1s; z-index: 9999;
}
#tooltip.vis { opacity: 1; }
.tt-head {
  font-weight: 600; color: var(--text-strong);
  border-bottom: 1px solid var(--border);
  padding-bottom: 5px; margin-bottom: 5px;
}
.tt-row {
  display: grid; grid-template-columns: 11px 1fr auto; gap: 7px;
  align-items: center; padding: 2px 0;
}
.tt-sw  { width: 9px; height: 9px; border-radius: 2px; }
.tt-lbl { color: var(--text-body); }
.tt-val { color: var(--text-strong); font-variant-numeric: tabular-nums; }

/* ── Similar authors (below tabs) ───────────────────────────────────────── */
.similar-wrap {
  margin: 18px 0 0;
  padding: 14px 16px;
}
.similar-title {
  font-size: 0.66rem; font-weight: 600;
  color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.08em;
  margin-bottom: 8px;
}
.similar-list { display: flex; flex-wrap: wrap; gap: 6px; }
.similar-item {
  flex: 1 1 240px; min-width: 240px; max-width: 340px;
  display: flex; flex-direction: row; align-items: center; gap: 8px;
  padding: 7px 10px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-body);
  transition: border-color .15s, background .15s;
}
.similar-item:hover { border-color: var(--link); background: var(--surface); }
.similar-body { display: flex; flex-direction: column; gap: 1px; min-width: 0; flex: 1 1 auto; }
.similar-name {
  font-size: 0.78rem; font-weight: 600; color: var(--text-strong);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.similar-meta {
  display: flex; gap: 6px; font-size: 0.64rem; color: var(--text-muted);
  flex-wrap: wrap;
}
.similar-meta strong { color: var(--text-body); font-weight: 600; }
.similar-item .similar-go {
  flex: 0 0 auto; font-size: 0.66rem; padding: 4px 9px; white-space: nowrap;
}

/* ── Blog / FAQ articles ────────────────────────────────────────────────── */
.post {
  max-width: 760px;
  margin: 0 auto;
  padding: 6px 0 40px;
}
.post-head { margin-bottom: 18px; }
.post-tag {
  font-size: 0.66rem; font-weight: 700;
  color: var(--text-muted);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin-bottom: 6px;
}
.post h1 {
  font-size: 1.45rem; font-weight: 700;
  color: var(--text-strong);
  line-height: 1.25;
  margin-bottom: 8px;
  letter-spacing: -0.01em;
}
.post-lede { font-size: 0.92rem; color: var(--text-body); line-height: 1.55; }
.post h2 {
  font-size: 1rem; font-weight: 700;
  color: var(--text-strong);
  margin: 22px 0 8px;
}
.post p { font-size: 0.86rem; color: var(--text-body); line-height: 1.6; margin: 8px 0; }
.post-list { padding-left: 20px; font-size: 0.86rem; color: var(--text-body); line-height: 1.6; }
.post-list li { margin-bottom: 6px; }
.post-back {
  margin-top: 32px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}
.post-meme {
  margin: 14px 0 22px;
  text-align: center;
}
.post-meme img,
.post-meme svg {
  max-width: 100%;
  height: auto;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
}
.post-meme figcaption {
  margin-top: 6px;
  font-size: 0.74rem;
  color: var(--text-muted);
  font-style: italic;
}

.faq-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  margin-bottom: 8px;
  padding: 0 14px;
}
.faq-item > summary {
  list-style: none;
  cursor: pointer;
  padding: 11px 0;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-strong);
  user-select: none;
  display: flex; align-items: center; gap: 10px;
}
.faq-item > summary::-webkit-details-marker { display: none; }
.faq-item > summary::before {
  content: "▸"; color: var(--text-muted);
  transition: transform .15s;
  font-weight: 400;
  flex-shrink: 0;
}
.faq-item[open] > summary::before { transform: rotate(90deg); }
.faq-item > p, .faq-item > ul {
  margin-bottom: 11px;
}

/* ── Footer attributions ─────────────────────────────────────────────────── */
.attributions {
  margin-top: 30px;
  padding-top: 22px;
  border-top: 1px solid var(--border);
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
  color: var(--text-muted);
}
@media (max-width: 700px) { .attributions { grid-template-columns: 1fr; gap: 14px; } }
.attr-block { line-height: 1.55; }
.attr-label {
  font-size: 0.66rem; font-weight: 700; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 0.08em; margin-bottom: 4px;
}
.attr-body { font-size: 0.78rem; color: var(--text-body); }
.attr-cite { color: var(--text-muted); }
.disclaimer-block { grid-column: 1 / -1; }
.disclaimer { font-style: italic; }

/* Yellow-tinted disclaimer banner shown on the Retractions / PPS /
 * Delisted cards. */
.disclaimer-note {
  margin: 8px 0 12px;
  padding: 9px 12px;
  font-size: 0.78rem;
  line-height: 1.5;
  color: var(--text-body);
  background: rgba(247, 183, 49, 0.10);
  border: 1px solid rgba(247, 183, 49, 0.35);
  border-radius: var(--radius-md);
}
.disclaimer-note code {
  background: rgba(247, 183, 49, 0.18);
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 0.92em;
}

/* ── Custom hover tooltip on merged badges (slick, themed) ──────────────── */
.merged-badge { position: relative; }
.merged-badge[data-tip] { cursor: help; }
.merged-badge[data-tip]:hover::after {
  content: attr(data-tip);
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 8px 11px;
  font-size: 0.7rem;
  font-weight: 500;
  text-transform: none;
  letter-spacing: 0;
  white-space: pre-line;
  min-width: 200px;
  max-width: 320px;
  box-shadow: var(--shadow-tooltip);
  z-index: 200;
  pointer-events: none;
  line-height: 1.5;
}
.merged-badge[data-tip]:hover::before {
  content: "";
  position: absolute;
  bottom: calc(100% + 2px);
  left: 50%;
  transform: translateX(-50%) rotate(45deg);
  width: 8px; height: 8px;
  background: var(--surface-2);
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  z-index: 201;
  pointer-events: none;
}

/* ── Sortable table headers ─────────────────────────────────────────────── */
.ret-table th.sortable {
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
  font-size: 0.78rem;       /* bigger than the default uppercase-table TH */
  letter-spacing: 0.03em;
  padding: 9px 10px;
  background: var(--surface);
  position: relative;
  transition: color .12s, background .12s;
}
.ret-table th.sortable:hover { color: var(--link); background: var(--surface-2); }
.ret-table th.sortable::after {
  content: " ⇅";
  color: var(--text-dim);
  font-size: 0.92em;
  margin-left: 5px;
}
.ret-table th.sort-desc::after { content: " ▼"; color: var(--link); }
.ret-table th.sort-asc::after  { content: " ▲"; color: var(--link); }

/* ── Mobile ─────────────────────────────────────────────────────────────── */
@media (max-width: 600px) {
  body { padding: 14px; }
  header.app-header h1 { font-size: 1rem; }
  .subtitle { font-size: 0.74rem; }

  .search-input { padding: 8px 12px; font-size: 0.82rem; }
  #search-btn   { padding: 0 12px; font-size: 0.76rem; }

  .candidates   { grid-template-columns: 1fr; gap: 6px; }
  .candidate    { padding: 8px 10px; }
  .cand-name    { font-size: 0.82rem; }

  .profile-stats { gap: 5px; }
  .stat          { padding: 6px 9px; min-width: 68px; }
  .stat-val      { font-size: 0.9rem; }

  .card, .chart-card { padding: 12px 12px; }
  .chart-wrap     { height: 220px; }
  .chart-wrap-sm  { height: 150px; }
  .chart-wrap-md  { height: 190px; }
  .chart-wrap-lg  { height: 260px; }

  .legend { max-height: 90px; overflow-y: auto; -webkit-overflow-scrolling: touch; }

  .ret-table { font-size: 0.7rem; }
  .ret-table th, .ret-table td { padding: 4px 5px; }

  .similar-item { min-width: 100%; max-width: 100%; }
}

@media (max-width: 380px) {
  body { padding: 10px; }
  .brand-tagline { display: none; }
  .chart-wrap     { height: 190px; }
  .chart-wrap-sm  { height: 140px; }
  .chart-wrap-md  { height: 170px; }
  .chart-wrap-lg  { height: 220px; }
}

/* ── "View Horizontally" mobile-only landscape mode ─────────────────────── */
/* Hidden on desktop. The card itself stays in place; tapping the button
 * promotes it into a fixed full-viewport rotated overlay. */
.landscape-toggle, .landscape-close { display: none; }

.landscape-backdrop {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 9000;
}
body.landscape-active .landscape-backdrop { display: block; }
body.landscape-active { overflow: hidden; }

@media (max-width: 700px) {
  .card { position: relative; }
  .landscape-toggle {
    display: inline-flex;
    align-items: center; gap: 4px;
    position: absolute; top: 7px; right: 8px;
    padding: 3px 7px;
    background: var(--bg);
    color: var(--text-muted);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font: 600 0.54rem/1.1 inherit;
    text-transform: uppercase; letter-spacing: 0.04em;
    cursor: pointer;
    z-index: 3;
    transition: color .15s, border-color .15s, background .15s;
  }
  .landscape-toggle .lsb-icon { font-size: 0.78rem; line-height: 1; }
  .landscape-toggle .lsb-text {
    display: inline-flex; flex-direction: column;
    line-height: 1.1; text-align: left;
  }
  /* Hide the toggle once the card is in landscape — the ✕ close button
   * takes its place and would be visually noisy otherwise. */
  .card.landscape > .landscape-toggle { display: none; }
  .landscape-toggle:hover,
  .landscape-toggle:active { color: var(--link); border-color: var(--link); }

  /* The landscape-active card: rotate 90deg, take up the full viewport
   * (width becomes the screen height, height becomes the screen width).
   * Centered with translate so it sits visually in the middle. */
  .card.landscape {
    position: fixed;
    z-index: 9500;
    top: 50%;
    left: 50%;
    width: 100vh;
    height: 96vw;
    transform: translate(-50%, -50%) rotate(90deg);
    transform-origin: center center;
    overflow-y: auto;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 14px 18px;
    box-shadow: 0 12px 36px rgba(0, 0, 0, 0.4);
  }
  /* Chart wrap fills the landscape card height. */
  .card.landscape .chart-wrap,
  .card.landscape .chart-wrap-sm,
  .card.landscape .chart-wrap-md,
  .card.landscape .chart-wrap-lg {
    height: calc(96vw - 100px);
    max-height: 80vh;
  }
  .landscape-close {
    display: inline-flex;
    align-items: center; justify-content: center;
    position: absolute; top: 8px; right: 10px;
    width: 32px; height: 28px;
    padding: 0;
    background: var(--surface-2);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 15px; font-family: inherit;
    cursor: pointer;
    z-index: 4;
  }
}
