:root {
  --paper: #f4f6f8;
  --ink: #0e1726;
  --green: #0a7a4b;
  --green-soft: #e3f1ea;
  --blue: #2e6ff2;
  --line: #dce1e7;
  --muted: #5b6675;
  font-family: "IBM Plex Sans Arabic", system-ui, sans-serif;
  color-scheme: light;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; background: var(--paper); color: var(--ink); }
body { min-height: 100dvh; font-size: 16px; line-height: 1.6; max-width: 760px; margin-inline: auto; }
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.top { padding: 22px 20px 6px; }
.title-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
h1 { margin: 0; font-family: "Noto Kufi Arabic", sans-serif; font-weight: 900; font-size: 40px; line-height: 1.15; letter-spacing: -0.5px; }
.country select {
  appearance: none; border: 1.5px solid var(--ink); border-radius: 8px; background: transparent; padding: 6px 30px 6px 12px; font-weight: 600; cursor: pointer;
  background-image: linear-gradient(45deg, transparent 50%, var(--ink) 50%), linear-gradient(135deg, var(--ink) 50%, transparent 50%);
  background-position: 14px 52%, 9px 52%; background-size: 5px 5px; background-repeat: no-repeat;
}
.pulse { display: block; width: 100%; height: 34px; margin: 6px 0 2px; }
.pulse path { fill: none; stroke: var(--green); stroke-width: 2.5; stroke-linejoin: round; stroke-dasharray: 520; stroke-dashoffset: 0; }
.pulse.beat path { animation: beat 1.4s ease-out 1; }
@keyframes beat { from { stroke-dashoffset: 520; } to { stroke-dashoffset: 0; } }
.refresh-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.stamp { margin: 0; color: var(--muted); font-size: 14px; }
.refresh {
  flex: none; border: 0; border-radius: 10px; background: var(--green); color: #fff; font-weight: 600; padding: 10px 16px; cursor: pointer;
}
.refresh:disabled { opacity: .5; cursor: not-allowed; }
.error { margin: 12px 0 0; padding: 12px 14px; border-radius: 10px; background: #fff4e5; border: 1px solid #f2c48d; }
.error p { margin: 0 0 8px; } .error p:last-child { margin: 0; }
.error-action { display: inline-block; border: 0; border-radius: 8px; background: var(--ink); color: #fff; padding: 6px 12px; text-decoration: none; cursor: pointer; font-weight: 600; }

main { padding: 6px 20px 24px; }
.filters { display: flex; gap: 6px; flex-wrap: wrap; margin: 10px 0 6px; }
.filters button { border: 1.5px solid var(--line); background: #fff; border-radius: 999px; padding: 4px 12px; font-size: 14px; cursor: pointer; }
.filters button[aria-pressed="true"] { border-color: var(--ink); background: var(--ink); color: #fff; }
.status { color: var(--muted); }
.empty { color: var(--muted); max-width: 44ch; }

.list { list-style: none; margin: 0; padding: 0; }
.item {
  display: grid; grid-template-columns: 74px 1fr auto; align-items: center; gap: 14px; padding: 14px 0; border-bottom: 1px solid var(--line);
}
.rank {
  font-family: "Noto Kufi Arabic", sans-serif; font-weight: 900; font-size: 54px; line-height: 1; color: var(--green); text-align: center;
  font-variant-numeric: tabular-nums;
}
.item:nth-child(n+4) .rank { color: var(--ink); font-size: 40px; opacity: .85; }
.item:nth-child(n+11) .rank { font-size: 30px; opacity: .55; }
.name { font-family: "Noto Kufi Arabic", sans-serif; font-weight: 800; font-size: 19px; line-height: 1.45; overflow-wrap: anywhere; }
.item:nth-child(-n+3) .name { font-size: 22px; }
.ctx { display: block; color: var(--muted); font-size: 14px; }
.pick {
  border: 1.5px solid var(--line); background: #fff; border-radius: 999px; padding: 6px 12px; font-size: 13px; font-weight: 600; cursor: pointer; white-space: nowrap;
}
.pick[aria-pressed="true"] { border-color: var(--blue); color: var(--blue); background: #eef3ff; }
.search-x { color: var(--muted); font-size: 13px; text-decoration: underline; }

.compare {
  position: sticky; bottom: 0; background: #fff; border-top: 2px solid var(--ink); padding: 16px 20px 20px;
  box-shadow: 0 -10px 30px rgba(14, 23, 38, .08); max-height: 82dvh; overflow-y: auto;
}
.compare-head { display: flex; justify-content: space-between; align-items: baseline; }
.compare h2 { margin: 0; font-family: "Noto Kufi Arabic", sans-serif; font-weight: 800; font-size: 20px; }
.link { border: 0; background: none; color: var(--muted); cursor: pointer; text-decoration: underline; }
.hint { color: var(--muted); font-size: 14px; margin: 4px 0 10px; }
.kw { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.kw span { display: inline-flex; align-items: center; gap: 6px; padding: 4px 6px 4px 12px; border-radius: 999px; font-weight: 600; font-size: 14px; color: #fff; }
.kw span:nth-child(1) { background: var(--green); }
.kw span:nth-child(2) { background: var(--blue); }
.kw span button { border: 0; background: rgba(255, 255, 255, .25); color: #fff; width: 22px; height: 22px; border-radius: 50%; cursor: pointer; line-height: 1; }
.kw-add { display: flex; gap: 8px; }
.kw-add input { flex: 1; min-width: 0; border: 1.5px solid var(--line); border-radius: 10px; padding: 9px 12px; background: var(--paper); font-size: 16px; }
.ghost { border: 1.5px solid var(--ink); background: transparent; border-radius: 10px; padding: 8px 14px; font-weight: 600; cursor: pointer; }
.range { display: flex; gap: 16px; margin: 12px 0; font-size: 15px; }
.range input { accent-color: var(--green); }
#compare-go { width: 100%; padding: 12px; font-size: 16px; }

.chart { margin: 16px 0 0; }
.chart svg { width: 100%; height: auto; display: block; }
.chart .grid { stroke: var(--line); stroke-width: 1; }
.chart .axis { fill: var(--muted); font-size: 11px; font-family: "IBM Plex Sans Arabic", sans-serif; }
.chart .s0 { stroke: var(--green); } .chart .s1 { stroke: var(--blue); }
.chart path { fill: none; stroke-width: 2.5; stroke-linejoin: round; stroke-linecap: round; }
.chart figcaption { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 8px; font-size: 14px; }
.chart figcaption b { font-family: "Noto Kufi Arabic", sans-serif; }
.chart .peak { color: var(--muted); }

.credit { padding: 14px 20px 24px; color: var(--muted); font-size: 12px; }
@media (prefers-reduced-motion: reduce) { .pulse.beat path { animation: none; } }
