:root {
  --bg: #060915;
  --bg2: #0b1028;
  --ink: #e9e6dc;
  --muted: #9a9cb3;
  --line: rgba(255, 255, 255, 0.09);
  --gold: #f6b85c;
  --dawn: #e2744e;
  --night: #5b63b8;
  --card: rgba(255, 255, 255, 0.035);
}

* { box-sizing: border-box; }

html { background: var(--bg); }

body {
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(1200px 600px at 50% -200px, #151c48 0%, transparent 70%),
    var(--bg);
  font-family: Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

.muted { color: var(--muted); }
.small { font-size: 13px; }

.ayah {
  text-align: center;
  padding: 36px 16px 8px;
  max-width: 900px;
  margin: 0 auto;
}
.ayah .ar {
  font-family: Amiri, "Traditional Arabic", serif;
  font-size: clamp(28px, 5.4vw, 46px);
  line-height: 1.7;
  margin: 0;
}
.ayah .en {
  margin: 4px 0 2px;
  font-size: clamp(14px, 2vw, 17px);
}
.ayah .ref { margin: 0; color: var(--muted); font-size: 12.5px; letter-spacing: 0.02em; }
.ayah span { transition: color 0.6s ease, text-shadow 0.6s ease, opacity 0.6s ease; opacity: 0.55; }
.ayah span.on { opacity: 1; }
#a1.on, #e1.on { color: #b9bff5; text-shadow: 0 0 24px rgba(110, 120, 230, 0.55); }
#a2.on, #e2.on { color: #ffd593; text-shadow: 0 0 24px rgba(246, 184, 92, 0.45); }

main { max-width: 1100px; margin: 0 auto; padding: 8px 16px 24px; }

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr);
  gap: 24px;
  align-items: center;
}
.dial-wrap { width: 100%; aspect-ratio: 1 / 0.92; max-height: 560px; }
#dial { width: 100%; height: 100%; display: block; touch-action: pan-y; cursor: grab; }
#dial.grabbing { cursor: grabbing; }

.panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 20px;
}
.when h1 { font-size: 22px; font-weight: 600; margin: 0; letter-spacing: -0.01em; }
.when p { margin: 2px 0 0; }
.narr {
  margin: 14px 0 16px;
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.04);
  border-left: 3px solid var(--muted);
  min-height: 46px;
}
.narr.n2d { border-left-color: #8d95f0; }
.narr.d2n { border-left-color: var(--gold); }

.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 18px; }
.stats > div { display: flex; flex-direction: column; }
.k { font-size: 11.5px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.v { font-size: 24px; font-weight: 600; font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }
.d { font-size: 12.5px; color: var(--muted); font-variant-numeric: tabular-nums; min-height: 18px; }
.d.up { color: #ffcf86; }
.d.down { color: #a9afef; }

.loc { display: flex; flex-direction: column; gap: 4px; margin-top: 18px; }
#locMeta { margin: 6px 0 0; }

select, input[type="date"], button {
  font: inherit;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 9px;
  padding: 7px 11px;
  min-height: 36px;
}
select option { background: #11152c; color: var(--ink); }
input[type="date"] { color-scheme: dark; }
button { cursor: pointer; white-space: nowrap; }
button:hover, select:hover { background: rgba(255, 255, 255, 0.11); }
button:focus-visible, select:focus-visible, input:focus-visible { outline: 2px solid var(--gold); outline-offset: 1px; }
button.primary { background: var(--gold); color: #1a1205; border-color: var(--gold); font-weight: 600; min-width: 76px; }
button.primary:hover { background: #ffca78; }

.year { margin-top: 28px; }
.controls {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}
.nav, .play { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.chart-wrap {
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
  background: #050812;
}
#yearChart { width: 100%; height: 300px; display: block; touch-action: pan-y; cursor: ew-resize; }
.hint { margin: 10px 2px 0; }

footer { max-width: 1100px; margin: 0 auto; padding: 8px 16px 40px; }
footer p { max-width: 820px; }

@media (max-width: 820px) {
  .hero { grid-template-columns: 1fr; gap: 12px; }
  .dial-wrap { max-width: 520px; margin: 0 auto; aspect-ratio: 1 / 0.95; }
  #yearChart { height: 240px; }
  .controls { justify-content: center; }
  .nav { justify-content: center; }
}
@media (max-width: 480px) {
  .ayah { padding-top: 22px; }
  .panel { padding: 16px; }
  .v { font-size: 21px; }
  .nav button { padding: 7px 9px; }
  #yearChart { height: 220px; }
}
