/* Africa since independence: editorial timeline.
   One idea carries the page: rule by force is the only dark mass, so coup eras read at a glance. */

/* ---------- tokens ---------- */
:root {
  --label-w: 232px;
  --row-h: 52px;
  --lane: 8px;    /* top of the event lane inside a row */
  --bar-top: 24px;
  --bar-h: 16px;
  --ui: "IBM Plex Sans", "IBM Plex Sans Arabic", "Helvetica Neue", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  --r: 6px;
}
:root,
:root[data-theme="light"] {
  color-scheme: light;
  --bg: #fcfcfb;
  --surface: #f3f4f6;
  --raise: #eceef1;
  --line: #e1e3e8;
  --grid: #ecedf0;
  --grid-year: #f4f5f7;
  --ink: #1c1f26;
  --ink-2: #4a4f5c;
  --mute: #7a8090;
  --hover: #f3f4f6;
  --coup: #c23b2e;
  --coup-soft: #e8b4ad;
  --elect: #3d7a5c;
  --const: #4d64b0;
  --conflict: #b7791f;
  --indep: #6b72b8;
  /* leader strips: how power was taken */
  --b-independence: #c9cdec;
  --b-election: #bcd7c8;
  --b-succession: #dfd9cd;
  --b-coup: #3f434d;
  --t-light: #1c1f26;
  --t-dark: #ffffff;
  --t-coup: var(--t-dark);
  --flag-ring: rgba(28, 31, 38, 0.14);
  --backdrop: rgba(28, 31, 38, 0.32);
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #14161b;
  --surface: #1b1e24;
  --raise: #23262e;
  --line: #2c3039;
  --grid: #22252c;
  --grid-year: #1a1d22;
  --ink: #eceef2;
  --ink-2: #b4b9c4;
  --mute: #868c9b;
  --hover: #1b1e24;
  --coup: #ff6b5e;
  --coup-soft: #6b3530;
  --elect: #7cc4a0;
  --const: #8ea2e8;
  --conflict: #e0a54a;
  --indep: #a3a9e8;
  --b-independence: #444a7a;
  --b-election: #345a48;
  --b-succession: #4e4a42;
  --b-coup: #d4d7de;
  --t-light: #eceef2;
  --t-dark: #14161b;
  --t-coup: var(--t-dark);
  --flag-ring: rgba(255, 255, 255, 0.16);
  --backdrop: rgba(0, 0, 0, 0.55);
}

* { box-sizing: border-box; }
/* The app lives in .pol-app under the overview.africa header (fixed, about 76px tall). */
.pol-app {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  padding-top: 72px;
  background: var(--bg);
  color: var(--ink);
  font: 400 14px/1.45 var(--ui);
  font-variant-numeric: tabular-nums;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}
button, select, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
.vh { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.grow { flex: 1; }
.ui { width: 15px; height: 15px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- event markers (one small shape per category) ---------- */
.m { position: relative; display: inline-block; width: 12px; height: 12px; flex: none; }
.m::before { content: ""; position: absolute; inset: 0; margin: auto; box-sizing: border-box; }
.m-coup::before { width: 8px; height: 8px; background: var(--coup); transform: rotate(45deg); }
.m-coup_attempt::before { width: 7px; height: 7px; border: 1.5px solid var(--coup); background: var(--bg); transform: rotate(45deg); }
.m-election::before { width: 6px; height: 6px; border-radius: 50%; background: var(--elect); }
.m-election.parl::before { background: var(--bg); border: 1.5px solid var(--elect); width: 7px; height: 7px; }
.m-transition::before { width: 2px; height: 10px; background: var(--ink-2); }
.m-constitution::before { width: 6px; height: 6px; border: 1.5px solid var(--const); }
.m-conflict::before { width: 8px; height: 7px; background: var(--conflict); clip-path: polygon(50% 0, 100% 100%, 0 100%); }
.m-other::before { width: 4px; height: 4px; border-radius: 50%; background: var(--mute); }
.m-independence::before { width: 7px; height: 7px; background: var(--indep); }

/* ---------- header ---------- */
.top {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 12px 32px;
  padding: 22px 28px 14px;
}
.title { flex: 1 1 420px; min-width: 0; }
.pol-app h1 { margin: 0; font-size: 22px; line-height: 1.2; font-weight: 600; letter-spacing: -0.01em; }
#stats { margin: 6px 0 0; color: var(--mute); max-width: 82ch; font-size: 13.5px; }
#stats b { color: var(--ink); font-weight: 500; }
.tools, .bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.bar { padding: 0 28px 12px; }

.ctl {
  height: 32px;
  padding: 0 11px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--r);
  font-size: 13px;
}
.ctl:hover { border-color: var(--mute); }
button.ctl { display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
button.ctl.icon { width: 32px; padding: 0; }
button.ctl.solid { background: var(--ink); color: var(--bg); border-color: var(--ink); font-weight: 500; }
button.ctl.solid:hover { opacity: 0.86; }
button.ctl:disabled { opacity: 0.4; cursor: default; }
.search { position: relative; display: block; }
.search .ui { position: absolute; inset-inline-start: 10px; top: 9px; width: 14px; height: 14px; color: var(--mute); pointer-events: none; }
.search input { width: 240px; padding-inline-start: 31px; }
.search input::placeholder { color: var(--mute); }
.seg { display: inline-flex; }
.seg .ctl { border-radius: 0; margin-inline-start: -1px; }
.seg .ctl:first-child { border-radius: var(--r) 0 0 var(--r); margin-inline-start: 0; }
.seg .ctl:last-child { border-radius: 0 var(--r) var(--r) 0; }
[dir="rtl"] .seg .ctl:first-child { border-radius: 0 var(--r) var(--r) 0; }
[dir="rtl"] .seg .ctl:last-child { border-radius: var(--r) 0 0 var(--r); }
.seg .ctl:hover { position: relative; z-index: 1; }
.seg .ctl[aria-pressed="true"] { background: var(--ink); color: var(--bg); border-color: var(--ink); position: relative; z-index: 2; }
.zoom { direction: ltr; }
#theme .moon { display: none; }
:root[data-theme="dark"] #theme .moon { display: block; }
:root[data-theme="dark"] #theme .sun { display: none; }

/* ---------- legend ---------- */
.legend {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 28px;
  padding: 10px 28px;
  border-top: 1px solid var(--line);
  font-size: 12.5px;
  color: var(--ink-2);
}
.filters { display: flex; flex-wrap: wrap; gap: 2px 4px; }
.filters button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 26px;
  padding: 0 8px;
  background: none;
  border: 0;
  border-radius: 4px;
  color: var(--ink);
}
.filters button:hover { background: var(--surface); }
.filters button[aria-pressed="false"] { color: var(--mute); }
.filters button[aria-pressed="false"] .m { opacity: 0.3; }
.strip-key { display: flex; flex-wrap: wrap; gap: 4px 16px; color: var(--mute); }
.strip-key > span { display: inline-flex; align-items: center; gap: 6px; }
.sw { width: 18px; height: 10px; border-radius: 2px; display: inline-block; flex: none; }

.via-independence { background: var(--b-independence); color: var(--t-light); }
.via-election { background: var(--b-election); color: var(--t-light); }
.via-succession { background: var(--b-succession); color: var(--t-light); }
.via-coup { background: var(--b-coup); color: var(--t-coup); }

/* ---------- timeline ---------- */
#scroller {
  flex: 1;
  min-height: 0;
  overflow: auto;
  border-top: 1px solid var(--line);
  overscroll-behavior: contain;
  outline-offset: -2px;
}
#canvas { position: relative; min-height: 100%; padding-bottom: 40px; }
#axis {
  position: sticky;
  top: 0;
  z-index: 6;
  display: flex;
  height: 50px;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}
.corner {
  position: sticky;
  left: 0;
  z-index: 2;
  flex: none;
  width: var(--label-w);
  display: flex;
  align-items: flex-end;
  padding: 0 16px 6px 28px;
  font-size: 11.5px;
  line-height: 1.25;
  color: var(--mute);
  background: var(--bg);
  border-right: 1px solid var(--line);
}
.axis-track { position: relative; flex: none; }
.tick { position: absolute; top: 8px; font-size: 12px; color: var(--mute); transform: translateX(-50%); }
.tick.major { color: var(--ink); font-weight: 500; }
.hist { position: absolute; bottom: 0; background: var(--coup-soft); }
.hist.won { background: var(--coup); }

.row { display: flex; height: var(--row-h); }
.row-label {
  position: sticky;
  left: 0;
  z-index: 4;
  flex: none;
  width: var(--label-w);
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 0 16px 0 28px;
  background: var(--bg);
  border: 0;
  border-right: 1px solid var(--line);
  text-align: start;
}
.row-label img { width: 22px; height: 15px; object-fit: fill; border-radius: 2px; box-shadow: 0 0 0 1px var(--flag-ring); flex: none; }
.row-label .nm { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-label .cd { display: none; font-weight: 500; }
.row-label .yr { color: var(--mute); font-size: 12px; }
.row:hover .row-label, .row:hover .track { background-color: var(--hover); }
.row:hover .row-label .nm { font-weight: 500; }
/* hovering one country quietens the others */
#rows:hover .row:not(:hover) .track > * { opacity: 0.38; }
.track > * { transition: opacity 0.12s; }
.group {
  position: sticky;
  left: 0;
  width: min(100vw, 600px);
  padding: 22px 28px 8px;
  font-weight: 600;
  font-size: 13.5px;
}
.track {
  position: relative;
  flex: none;
  background-image: linear-gradient(to right, var(--grid) 1px, transparent 1px);
  background-size: var(--decade) 100%;
  background-position: var(--decade-off) 0;
}
.yearly .track {
  background-image: linear-gradient(to right, var(--grid) 1px, transparent 1px), linear-gradient(to right, var(--grid-year) 1px, transparent 1px);
  background-size: var(--decade) 100%, var(--year) 100%;
  background-position: var(--decade-off) 0, var(--decade-off) 0;
}
.start-flag {
  position: absolute;
  top: calc(var(--bar-top) + 1px);
  height: 14px;
  transform: translateX(-100%);
  padding: 0;
  border: 0;
  border-radius: 2px;
  overflow: hidden;
  background: none;
  box-shadow: 0 0 0 1px var(--flag-ring);
  z-index: 2;
}
.start-flag img { height: 14px; width: auto; max-width: 28px; display: block; }
.start-flag.sel { outline: 2px solid var(--ink); outline-offset: 2px; }
.tenure {
  position: absolute;
  top: var(--bar-top);
  height: var(--bar-h);
  padding: 0 6px;
  border: 0;
  border-radius: 2px;
  font-size: 11px;
  font-weight: 500;
  line-height: var(--bar-h);
  text-align: start;
  white-space: nowrap;
  overflow: hidden;
}
/* very short periods: a compact tick, named on hover */
.tenure.short { top: calc(var(--bar-top) - 3px); height: calc(var(--bar-h) + 6px); padding: 0; border-radius: 1px; }
.tenure:hover { filter: brightness(0.94); }
:root[data-theme="dark"] .tenure:hover { filter: brightness(1.15); }
.tenure.sel { box-shadow: 0 0 0 2px var(--bg), 0 0 0 3.5px var(--ink); z-index: 1; }
.has-hit .tenure:not(.hit) { opacity: 0.25; }
.mk {
  position: absolute;
  top: var(--lane);
  width: 12px;
  height: 12px;
  margin-left: -6px;
  padding: 0;
  border: 0;
  background: none;
  z-index: 1;
}
.mk.m-coup, .mk.m-coup_attempt { z-index: 2; }
.mk:hover { transform: scale(1.5); z-index: 5; }
.mk.sel { outline: 1.5px solid var(--ink); outline-offset: 2px; border-radius: 2px; z-index: 5; }
.hide-election .mk.m-election,
.hide-coup .mk.m-coup,
.hide-coup_attempt .mk.m-coup_attempt,
.hide-transition .mk.m-transition,
.hide-constitution .mk.m-constitution,
.hide-conflict .mk.m-conflict,
.hide-other .mk.m-other { display: none; }

#cross { position: absolute; top: 0; bottom: 0; width: 1px; background: var(--ink); opacity: 0.18; pointer-events: none; z-index: 5; }
#cross b {
  position: sticky;
  top: 30px;
  display: block;
  width: max-content;
  transform: translateX(-50%);
  padding: 1px 6px;
  border-radius: 3px;
  background: var(--ink);
  color: var(--bg);
  font-size: 11.5px;
  font-weight: 500;
}
#empty { position: sticky; left: 0; padding: 40px 28px; color: var(--mute); max-width: 100vw; }

/* ---------- tooltip ---------- */
#tip {
  position: fixed;
  z-index: 30;
  max-width: 280px;
  padding: 7px 10px;
  background: var(--ink);
  color: var(--bg);
  border-radius: 4px;
  font-size: 12.5px;
  line-height: 1.35;
  pointer-events: none;
}
#tip b { display: block; font-weight: 500; }
#tip span { opacity: 0.72; }

/* ---------- detail panel ---------- */
#panel {
  position: fixed;
  z-index: 20;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(440px, 100vw);
  background: var(--bg);
  border-left: 1px solid var(--line);
  overflow: auto;
  animation: slide 0.16s ease-out;
}
[dir="rtl"] #panel { right: auto; left: 0; border-left: 0; border-right: 1px solid var(--line); }
@keyframes slide { from { transform: translateX(16px); opacity: 0; } }
#panel .x {
  position: sticky;
  top: 14px;
  float: inline-end;
  margin: 14px 14px 0;
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--bg);
  z-index: 2;
}
#panel .x:hover { border-color: var(--mute); }
#panelBody { padding: 26px 30px 36px; }
.p-country { display: inline-flex; align-items: center; gap: 9px; padding: 0; border: 0; background: none; font-weight: 500; color: var(--ink-2); }
.p-country:hover span { text-decoration: underline; text-underline-offset: 3px; }
.p-country img { height: 15px; width: auto; border-radius: 2px; box-shadow: 0 0 0 1px var(--flag-ring); }
.p-kind { display: flex; align-items: center; gap: 7px; margin: 26px 0 8px; color: var(--mute); font-size: 13px; }
.p-kind .sw { width: 14px; height: 9px; }
#panel h2 { margin: 0 0 18px; font-size: 22px; line-height: 1.25; font-weight: 600; letter-spacing: -0.01em; text-wrap: balance; }
.facts { display: grid; grid-template-columns: max-content 1fr; gap: 6px 18px; margin: 0 0 20px; padding: 14px 0; border-block: 1px solid var(--line); font-size: 13px; }
.facts dt { color: var(--mute); }
.facts dd { margin: 0; }
.prose { font-size: 15px; line-height: 1.65; max-width: 62ch; }
.prose p { margin: 0 0 0.85em; }
.prose a { color: inherit; text-underline-offset: 3px; }
.more { display: inline-flex; align-items: center; gap: 5px; font-size: 13px; color: var(--ink-2); text-underline-offset: 3px; }
.more:hover { color: var(--ink); }
.more .ui { width: 13px; height: 13px; }
.p-nav { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 28px; }
.p-nav button, .p-edit {
  min-height: 40px;
  padding: 8px 12px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--r);
  font-size: 13px;
  text-align: start;
  color: var(--ink);
}
.p-nav button:last-child { text-align: end; }
.p-nav button:disabled { opacity: 0.4; cursor: default; }
.p-nav small { display: block; color: var(--mute); font-size: 12px; }
.p-edit { width: 100%; margin-top: 8px; display: flex; align-items: center; justify-content: center; gap: 7px; }
.p-nav button:not(:disabled):hover, .p-edit:hover { border-color: var(--mute); }
.p-flag { height: 48px; width: auto; border-radius: 3px; box-shadow: 0 0 0 1px var(--flag-ring); margin-bottom: 16px; display: block; }
.ev-list { list-style: none; margin: 16px 0 0; padding: 0; }
.ev-list h3 { margin: 26px 0 6px; font-size: 12.5px; font-weight: 500; color: var(--mute); }
.ev-list button {
  display: grid;
  grid-template-columns: 82px 12px 1fr;
  gap: 10px;
  align-items: start;
  width: 100%;
  padding: 6px 8px;
  background: none;
  border: 0;
  border-radius: 4px;
  text-align: start;
  font-size: 13px;
  color: var(--ink);
}
.ev-list button:hover { background: var(--surface); }
.ev-list time { color: var(--mute); }
.ev-list .m { margin-top: 3px; }
.ev-list small { color: var(--mute); }

/* ---------- editor ---------- */
#editor {
  width: min(1280px, calc(100vw - 24px));
  height: calc(100dvh - 24px);
  max-width: none;
  max-height: none;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}
#editor[open] { display: flex; flex-direction: column; }
#editor::backdrop { background: var(--backdrop); }
.ed-bar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 12px 14px; border-bottom: 1px solid var(--line); }
#edStatus { color: var(--mute); font-size: 13px; }
#edStatus.bad { color: var(--coup); }
#edStatus.good { color: var(--elect); }
.ed-main { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); }
#edText {
  width: 100%;
  height: 100%;
  padding: 18px 20px;
  background: var(--surface);
  border: 0;
  border-inline-end: 1px solid var(--line);
  resize: none;
  font: 13px/1.6 ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  tab-size: 2;
  outline: none;
}
.ed-side { overflow: auto; padding: 14px 16px 20px; }
#edProblems button {
  display: block;
  width: 100%;
  margin-bottom: 6px;
  padding: 8px 11px;
  background: none;
  border: 1px solid var(--coup);
  border-radius: var(--r);
  text-align: start;
  font-size: 13px;
  color: var(--ink);
}
#edPreview .ev-list { margin-top: 4px; }
.ed-help { margin-top: 18px; color: var(--mute); font-size: 13px; }
.ed-help summary { cursor: pointer; color: var(--ink); }
.ed-help pre { overflow: auto; padding: 12px; background: var(--surface); border-radius: var(--r); font: 12px/1.5 ui-monospace, Menlo, monospace; }

@media (min-width: 1100px) {
  body.has-panel #scroller, body.has-panel .top, body.has-panel .bar, body.has-panel .legend { margin-inline-end: 440px; }
}

/* ---------- languages ---------- */
:lang(zh) .prose, :lang(ar) .prose { font-size: 15.5px; line-height: 1.8; }
:lang(ar) h1, :lang(ar) #panel h2, :lang(zh) h1, :lang(zh) #panel h2 { letter-spacing: 0; }

/* ---------- small screens ---------- */
@media (max-width: 760px) {
  :root { --label-w: 64px; --row-h: 48px; --bar-top: 22px; }
  .top { padding: 16px 16px 10px; }
  .bar { padding: 0 16px 10px; }
  .legend { padding: 8px 16px; }
  .strip-key { display: none; }
  .search { flex: 1 1 100%; }
  .search input { width: 100%; }
  .row-label { padding: 0 6px 0 12px; gap: 6px; }
  .row-label .nm, .row-label .yr { display: none; }
  .row-label .cd { display: inline; font-size: 12px; }
  .corner { padding: 0 4px 6px 12px; font-size: 0; }
  #panel, [dir="rtl"] #panel { top: 20%; left: 0; right: 0; width: auto; border: 0; border-top: 1px solid var(--line); border-radius: 12px 12px 0 0; }
  @keyframes slide { from { transform: translateY(16px); opacity: 0; } }
  .ed-main { grid-template-columns: 1fr; grid-template-rows: 1.4fr 1fr; }
  #edText { border-inline-end: 0; border-bottom: 1px solid var(--line); }
}
@media (prefers-reduced-motion: reduce) {
  #panel { animation: none; }
  .track > * { transition: none; }
  .mk:hover { transform: none; }
}

/* ---------- floating country timeline (js/country-timeline.js) ---------- */
:root, :root[data-theme="light"] {
  --ct-bg: #f1f2f5;
  --ct-card: #ffffff;
  --ct-line: #c7cad3;
  --ct-dot: #1c1f26;
}
:root[data-theme="dark"] {
  --ct-bg: #1b1e24;
  --ct-card: #262a33;
  --ct-line: #424754;
  --ct-dot: #eceef2;
}
.ct {
  position: fixed;
  z-index: 22;
  top: 12px;
  left: 12px;
  right: 12px;
  height: min(620px, calc(100dvh - 24px));
  display: flex;
  flex-direction: column;
  background: var(--ct-bg);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: 0 18px 40px rgba(20, 24, 33, 0.14);
  overflow: hidden;
  transform: translateY(calc(-100% - 24px));
  visibility: hidden;
  transition: transform 0.4s cubic-bezier(0.22, 0.8, 0.24, 1), visibility 0s 0.4s;
}
.ct.open { transform: none; visibility: visible; transition: transform 0.4s cubic-bezier(0.22, 0.8, 0.24, 1); }
@media (min-width: 1100px) {
  body.has-panel .ct { right: 452px; }
  [dir="rtl"] body.has-panel .ct { right: 12px; left: 452px; }
}
.ct-head { display: flex; align-items: center; gap: 12px; padding: 14px 16px 12px 20px; border-bottom: 1px solid var(--line); }
.ct-flag { height: 22px; width: auto; border-radius: 2px; box-shadow: 0 0 0 1px var(--flag-ring); }
.ct-titles { flex: 1; min-width: 0; }
.ct h2 { margin: 0; font-size: 17px; line-height: 1.2; font-weight: 600; }
.ct-meta { margin: 2px 0 0; color: var(--mute); font-size: 12.5px; }
.ct-nav { display: flex; align-items: center; gap: 6px; direction: ltr; }
.ct-count { min-width: 60px; text-align: center; font-size: 12.5px; color: var(--mute); }
.ct-btn {
  height: 30px;
  padding: 0 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: var(--ct-card);
  border: 1px solid var(--line);
  border-radius: 6px;
  font-size: 12.5px;
}
.ct-btn.icon { width: 30px; padding: 0; }
.ct-btn:hover { border-color: var(--mute); }
.ct-btn:disabled { opacity: 0.35; cursor: default; }
.ct-btn .ui { width: 14px; height: 14px; }
.ct-body { position: relative; flex: 1; min-height: 0; }
.ct-scroll { height: 100%; overflow-x: auto; overflow-y: hidden; cursor: grab; transition: opacity 0.17s; scrollbar-width: thin; }
.ct-scroll.dragging { cursor: grabbing; user-select: none; }
.ct-scroll.swap { opacity: 0; }
.ct-track { --ct-card-w: 232px; position: relative; height: 100%; min-width: 100%; display: grid; grid-template-rows: 1fr 60px 1fr; }
.ct-lane { position: relative; }
.ct-axis { position: relative; }
.ct-line { position: absolute; left: 0; right: 0; top: 18px; height: 1px; background: var(--ct-line); }
.ct-tick { position: absolute; top: 18px; width: 1px; height: 6px; background: var(--ct-line); }
.ct-year { position: absolute; top: 36px; transform: translateX(-50%); font-size: 11.5px; color: var(--mute); }
.ct-year.dec { color: var(--ink); font-weight: 500; }
.ct-dot {
  position: absolute;
  top: 18px;
  width: 9px;
  height: 9px;
  margin: -4.5px 0 0 -4.5px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--ct-dot);
  z-index: 1;
  transition: transform 0.15s;
}
.ct-dot.photo { width: 26px; height: 26px; margin: -13px 0 0 -13px; overflow: hidden; background: var(--ct-card); border: 2px solid var(--ct-card); box-shadow: 0 0 0 1px var(--ct-dot); }
.ct-dot.photo img { width: 100%; height: 100%; object-fit: cover; display: block; border-radius: 50%; filter: grayscale(1); }
.ct-dot:hover, .ct-dot.on { transform: scale(1.3); z-index: 2; }
.ct-dot.on:not(.photo) { box-shadow: 0 0 0 3px var(--ct-bg), 0 0 0 4px var(--ct-dot); }
.ct-item { position: absolute; width: var(--ct-card-w); max-height: calc(100% - 6px); transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; }
.above .ct-item { bottom: 0; }
.below .ct-item { top: 0; }
.ct-stem { flex: none; width: 1px; height: 16px; background: var(--ct-line); }
.below .ct-stem { order: -1; }
.ct-card {
  width: 100%;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 12px 14px;
  background: var(--ct-card);
  border: 1px solid transparent;
  border-radius: 6px;
  overflow: hidden;
  cursor: pointer;
  transition: border-color 0.15s;
}
.ct-card:hover { border-color: var(--line); }
.ct-item.on .ct-card { border-color: var(--ink); }
.ct-item.on .ct-stem { background: var(--ink); }
.ct-photo { flex: none; margin: -12px -14px 4px; height: 72px; overflow: hidden; background: var(--raise); }
.ct-photo img { width: 100%; height: 100%; object-fit: cover; display: block; filter: grayscale(1) contrast(1.05); }
.ct-date { margin: 0; font-size: 11.5px; color: var(--mute); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ct-card h3 { margin: 0; font-size: 14px; line-height: 1.3; font-weight: 600; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.ct-text { margin: 0; font-size: 12.5px; line-height: 1.45; color: var(--ink-2); display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.has-photo .ct-text { -webkit-line-clamp: 2; }
.ct-more { align-self: flex-start; margin-top: 2px; padding: 0; border: 0; background: none; font-size: 12.5px; font-weight: 500; text-decoration: underline; text-decoration-color: var(--ct-line); text-underline-offset: 3px; }
.ct-more:hover { text-decoration-color: currentColor; }
.ct-detail { position: absolute; inset: 0; z-index: 3; overflow: auto; padding: 22px 28px 36px; background: var(--ct-card); animation: ct-fade 0.2s ease-out; }
@keyframes ct-fade { from { opacity: 0; transform: translateY(6px); } }
.ct-detail-in { max-width: 680px; margin: 0 auto; }
.ct-back { margin-bottom: 18px; }
.ct-figure { margin: 0 0 18px; }
.ct-figure img { width: 100%; max-height: 300px; object-fit: cover; display: block; border-radius: 4px; filter: grayscale(1) contrast(1.05); }
.ct-figure figcaption { margin-top: 6px; font-size: 11.5px; color: var(--mute); }
.ct-detail h3 { margin: 4px 0 16px; font-size: 22px; line-height: 1.25; font-weight: 600; text-wrap: balance; }
.row.ct-on .row-label { box-shadow: inset 3px 0 0 var(--ink); }
.row.ct-on .row-label .nm { font-weight: 600; }
@media (max-height: 760px) {
  .ct-photo { height: 52px; }
  .has-photo .ct-text { display: none; }
  .ct-text { -webkit-line-clamp: 2; }
}
@media (max-width: 760px) {
  .ct { top: 0; left: 0; right: 0; height: min(88dvh, 640px); border-radius: 0 0 12px 12px; border-top: 0; }
  .ct-head { flex-wrap: wrap; padding: 12px 12px 10px 14px; gap: 8px 10px; }
  .ct-titles { flex: 1 1 calc(100% - 40px); }
  .ct-profile { margin-inline-end: auto; }
  .ct-track { --ct-card-w: 196px; }
  .ct-detail { padding: 18px 16px 28px; }
}
@media (prefers-reduced-motion: reduce) {
  .ct, .ct.open { transition: none; }
  .ct-scroll, .ct-dot, .ct-card { transition: none; }
  .ct-detail { animation: none; }
}

/* ---------- inside overview.africa ----------
   The country panel fills the page below the site header (fixed, about 72px tall),
   and detail photos keep their own proportions instead of being cropped to a strip. */
.pol-app .ct {
  top: 72px;
  left: 0;
  right: 0;
  bottom: 0;
  height: auto;
  border-width: 1px 0 0;
  border-radius: 0;
  box-shadow: none;
}
@media (min-width: 1100px) {
  body.has-panel .pol-app .ct { right: 440px; }
  [dir="rtl"] body.has-panel .pol-app .ct { right: 0; left: 440px; }
}
.pol-app .ct-figure { display: flex; flex-direction: column; align-items: center; }
.pol-app .ct-figure img {
  width: auto;
  max-width: 100%;
  height: auto;
  max-height: min(52vh, 460px);
  object-fit: contain;
  border-radius: 6px;
  background: var(--raise);
}
.pol-app .ct-figure figcaption { align-self: stretch; }
/* Card thumbnails stay small strips but favour the upper part, where faces usually are. */
.pol-app .ct-photo img { object-position: 50% 22%; }

/* Event panel: Earlier / Later and Edit live in a footer pinned to the bottom,
   so the buttons sit in the same place whatever the length of the event text. */
#panelBody { min-height: 100%; display: flex; flex-direction: column; }
.p-foot {
  position: sticky;
  bottom: 0;
  margin: auto -30px -36px;
  padding: 14px 30px 18px;
  background: var(--bg);
  border-top: 1px solid var(--line);
}
.p-foot .p-nav { margin-top: 0; }
.p-foot .p-nav button { min-height: 66px; }
.p-foot .p-nav span { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; }
/* Inside overview.africa the panel starts below the site header. */
.pol-app #panel { top: 72px; }

/* Editing controls: never shown to visitors who may not save. */
#edit[hidden] { display: none; }
.pol-app[data-can-edit="0"] #edit, .pol-app[data-can-edit="0"] .p-edit { display: none !important; }

/* Leader portrait and party emblem (Wikimedia Commons, see politics/media/index.json). */
.p-person.has-photo { display: grid; grid-template-columns: 96px 1fr; gap: 16px; align-items: end; margin-bottom: 18px; }
.p-person.has-photo h2 { margin-bottom: 0; }
.p-portrait {
  width: 96px; height: 120px; object-fit: cover; object-position: 50% 18%;
  border-radius: var(--r); background: var(--raise);
  filter: grayscale(1) contrast(1.05);
  box-shadow: 0 0 0 1px var(--line);
}
.p-party { display: inline-flex; align-items: center; gap: 8px; }
.p-party img { height: 26px; width: auto; max-width: 52px; object-fit: contain; flex: none; }
.p-credits { margin: 28px 0 0; padding-top: 12px; border-top: 1px solid var(--line); font-size: 11px; line-height: 1.5; color: var(--mute); }
.p-credits a { color: inherit; text-decoration: none; }
.p-credits a:hover { text-decoration: underline; }
.tip-portrait { float: inline-start; width: 44px; height: 54px; margin: 2px 10px 2px 0; object-fit: cover; object-position: 50% 18%; border-radius: 4px; filter: grayscale(1); }
[dir="rtl"] .tip-portrait { margin: 2px 0 2px 10px; }

.tip-office { display: block; color: var(--mute); font-size: 12px; margin-bottom: 2px; }

.p-life { margin: 4px 0 0; font-size: 13px; color: var(--mute); }
.p-person:not(.has-photo) .p-life { margin-bottom: 18px; }

/* previous / next leader in the leader panel */
.p-nav--leaders { margin: 6px 0 26px; }
.p-nav--leaders button span { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; }
