:root {
  --bg: #f5f5f7;
  --surface: #ffffff;
  --text: #1d1d1f;
  --muted: #6e6e73;
  --line: #d2d2d7;
  --accent: #0a7a4f;
  --accent-soft: #e3f3ec;
  --warn: #8a5a00;
  --warn-soft: #fff4dc;
  --error: #b42318;
  --radius: 16px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #000000;
    --surface: #1c1c1e;
    --text: #f5f5f7;
    --muted: #a1a1a6;
    --line: #38383a;
    --accent: #4cc38a;
    --accent-soft: #10291d;
    --warn: #f5c060;
    --warn-soft: #2e2410;
    --error: #ff8a80;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, "SF Arabic", "Segoe UI", "Noto Sans Arabic", Tahoma, sans-serif;
}

html[lang="en"] body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Noto Sans Arabic", sans-serif;
  font-size: 17px;
  line-height: 1.6;
  -webkit-text-size-adjust: 100%;
}

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

main, .site-header, .site-footer {
  width: 100%;
  max-width: 760px;
  margin: 0 auto;
  padding-inline: 16px;
}

/* ---------- Header ---------- */

.site-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 24px;
  padding-block: 16px;
}

.brand { font-size: 20px; font-weight: 700; color: var(--text); }
.header-links { margin-inline-start: auto; display: flex; align-items: center; gap: 12px; }
.header-link { font-size: 15px; color: var(--muted); }
.header-link[aria-current="page"] { color: var(--text); font-weight: 600; }
.lang-switch { font-size: 15px; padding: 4px 12px; border-radius: 999px; border: 1px solid var(--line); color: var(--text); }
.lang-switch:hover { text-decoration: none; border-color: var(--accent); }
.site-header .section-nav { flex-basis: 100%; }
.brand:hover { text-decoration: none; }

.section-nav { display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; }
.section-nav::-webkit-scrollbar { display: none; }
.section-nav a {
  padding: 6px 12px;
  border-radius: 999px;
  color: var(--muted);
  white-space: nowrap;
}
.section-nav a:hover { color: var(--text); text-decoration: none; }
.section-nav a[aria-current="page"] { background: var(--surface); color: var(--text); font-weight: 600; }

/* ---------- Type ---------- */

h1 { font-size: 30px; line-height: 1.3; margin: 16px 0 8px; }
h2 { font-size: 19px; margin: 0 0 12px; }
.lead { color: var(--muted); margin: 0 0 20px; }
.note { color: var(--muted); font-size: 15px; }
.section-title { margin: 32px 0 12px; font-size: 22px; }
.eyebrow { color: var(--muted); margin: 0; }
.visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap;
}

.hero { text-align: center; padding-block: 24px 8px; }
.hero h1 { font-size: 34px; }
.hero p { color: var(--muted); margin: 0; }

/* ---------- Surfaces ---------- */

.panel, .today-card, .card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
}

.today-card { text-align: center; padding-block: 28px; margin-top: 16px; }
.today-hijri { font-size: 32px; font-weight: 700; margin: 4px 0; line-height: 1.3; }
.today-gregorian { font-size: 20px; color: var(--muted); margin: 0; }

.cards {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
}
.card { display: block; height: 100%; margin: 0; color: var(--text); }
.card:hover { text-decoration: none; outline: 2px solid var(--accent); }
.card h2 { margin-bottom: 4px; }
.card p { margin: 0; color: var(--muted); font-size: 15px; }
.card.is-soon { opacity: 0.55; }
.card.is-soon:hover { outline: none; }

/* ---------- Rows ---------- */

.list-group h2 { font-size: 15px; color: var(--muted); font-weight: 600; margin: 20px 4px 8px; }

.rows {
  list-style: none;
  padding: 0;
  margin: 0;
  background: var(--surface);
  border-radius: var(--radius);
  overflow: hidden;
}
.panel .rows { background: none; border-radius: 0; }
.rows li { border-bottom: 1px solid var(--line); }
.rows li:last-child { border-bottom: 0; }
.rows li > a, .rows li > div {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  color: var(--text);
}
.panel .rows li > div { padding-inline: 0; }
.rows li:has(> button) { display: flex; align-items: center; gap: 12px; }
.rows li:has(> button) > div { flex: 1; flex-direction: column; align-items: flex-start; gap: 2px; }
.rows li > a:hover { background: var(--bg); text-decoration: none; }
.row-title { font-weight: 600; }
.row-value { color: var(--muted); text-align: end; }
.rows li > a .row-value { color: var(--accent); font-weight: 600; white-space: nowrap; }

button.copy {
  font: inherit;
  font-size: 15px;
  border: 0;
  border-radius: 999px;
  padding: 6px 14px;
  background: var(--accent-soft);
  color: var(--accent);
  cursor: pointer;
}

/* ---------- Countdown & numbers ---------- */

.countdown {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(64px, 1fr));
  gap: 8px;
  text-align: center;
}
.countdown div { background: var(--bg); border-radius: 12px; padding: 14px 4px; }
.countdown strong {
  display: block;
  font-size: 34px;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}
.countdown span { color: var(--muted); font-size: 14px; }
.target-label { margin: 0 0 12px; text-align: center; font-weight: 700; font-size: 18px; }
.countdown-today { text-align: center; font-weight: 700; color: var(--accent); font-size: 20px; }

.target { margin: 20px 0 8px; display: grid; gap: 6px; }
.target div { display: flex; justify-content: space-between; gap: 12px; }
.target dt { color: var(--muted); }
.target dd { margin: 0; font-weight: 600; text-align: end; }

.badge {
  display: inline-block;
  font-size: 14px;
  padding: 2px 10px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
}
.badge.is-expected { background: var(--warn-soft); color: var(--warn); }
.source { color: var(--muted); font-size: 15px; margin-bottom: 0; }

/* ---------- Forms ---------- */

.split { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 16px; }
.split .panel { margin: 0; }

.date-fields { display: grid; grid-template-columns: 1fr 2fr 1.4fr; gap: 8px; }
.date-fields label span { display: block; font-size: 14px; color: var(--muted); margin-bottom: 4px; }
select, input[type="number"] {
  width: 100%;
  font: inherit;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px;
  min-height: 46px;
}
select:focus, input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

.field { display: block; margin-top: 16px; }
.field span { display: block; font-size: 14px; color: var(--muted); margin-bottom: 4px; }
.hint { color: var(--muted); font-size: 14px; margin: 6px 0 0; }
.panel h2 + .date-fields, .panel [data-date] { margin-bottom: 16px; }
.eos-form .calendar-choice { margin: 16px 0 0; }
.choices { display: grid; gap: 6px; }
.choices label { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border-radius: 10px; background: var(--bg); cursor: pointer; }
.choices input { accent-color: var(--accent); margin-top: 6px; }
.calc-result { display: block; }

.result { display: block; margin-top: 16px; min-height: 92px; }
.result-label { margin: 0; color: var(--muted); }
.result-main { margin: 0; font-size: 24px; font-weight: 700; }
.result-sub { margin: 0; color: var(--muted); text-align: end; }
.error { color: var(--error); margin: 0; }
.age-result .error { background: var(--surface); padding: 16px 20px; border-radius: var(--radius); }

.calendar-choice { border: 0; padding: 0; margin: 0 0 16px; }
.calendar-choice legend { padding: 0; font-size: 14px; color: var(--muted); margin-bottom: 6px; }
.segmented { display: flex; gap: 4px; background: var(--bg); border-radius: 12px; padding: 4px; }
.segmented label { flex: 1; position: relative; }
.segmented input { position: absolute; opacity: 0; }
.segmented span { display: block; text-align: center; padding: 8px; border-radius: 9px; cursor: pointer; }
.segmented input:checked + span { background: var(--surface); font-weight: 600; box-shadow: 0 1px 3px rgb(0 0 0 / 0.12); }
.segmented input:focus-visible + span { outline: 2px solid var(--accent); }

/* ---------- Hijri calendar ---------- */

.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.chips a { padding: 4px 12px; border-radius: 999px; background: var(--surface); color: var(--text); font-size: 15px; }
.chips a:hover { text-decoration: none; outline: 1px solid var(--accent); }
.chips a[aria-current="page"] { background: var(--accent); color: #fff; }

.month h2 span { display: block; font-size: 14px; font-weight: 400; color: var(--muted); margin-top: 2px; }
.month-meta { color: var(--muted); font-size: 14px; margin: -6px 0 12px; }
.month-grid { width: 100%; border-collapse: separate; border-spacing: 3px; table-layout: fixed; }
.month-grid th { font-size: 12px; color: var(--muted); font-weight: 500; padding-bottom: 4px; }
.month-grid td { text-align: center; padding: 6px 0; border-radius: 8px; vertical-align: top; }
.month-grid td[data-g] { background: var(--bg); }
.month-grid td b { display: block; font-size: 17px; line-height: 1.2; }
.month-grid td small { display: block; font-size: 11px; color: var(--muted); }
.month-grid td:nth-child(6)[data-g], .month-grid td:nth-child(7)[data-g] { color: var(--muted); }
.month-grid td.is-occasion { background: var(--warn-soft); color: var(--warn); }
.month-grid td.is-today, .month-grid td.is-today:nth-child(n) { background: var(--accent); color: #fff; }
.month-grid td.is-today small { color: #fff; }
.occasions { margin: 12px 0 0; padding-inline-start: 18px; font-size: 15px; color: var(--muted); }
.occasions b { color: var(--text); font-weight: 600; }

/* ---------- FAQ & prose ---------- */

.faq { margin-top: 32px; }
.faq details { background: var(--surface); border-radius: 12px; padding: 14px 16px; margin-bottom: 8px; }
.faq summary { cursor: pointer; font-weight: 600; }
.faq p { margin: 8px 0 0; color: var(--muted); }
.prose p:first-child { margin-top: 0; }
.prose p:last-child { margin-bottom: 0; }

/* ---------- Footer ---------- */

.site-footer { color: var(--muted); font-size: 14px; padding-block: 32px; text-align: center; }
.site-footer p { margin: 4px 0; }

@media (max-width: 480px) {
  h1 { font-size: 26px; }
  .today-hijri { font-size: 27px; }
  .countdown strong { font-size: 28px; }
  .date-fields { grid-template-columns: 1fr 1fr; }
  .date-fields label:nth-child(2) { grid-column: 1 / -1; grid-row: 1; }
}

/* Upcoming dates table on countdown pages */
.table-wrap { overflow-x: auto; margin: 0 -4px; }
.dates { width: 100%; border-collapse: collapse; font-size: 15px; white-space: nowrap; }
.dates th, .dates td { padding: 10px 8px; text-align: start; border-bottom: 1px solid var(--line); }
.dates thead th { color: var(--muted); font-weight: 500; font-size: 13px; }
.dates tbody th { font-weight: 600; }
.dates tbody tr:last-child th, .dates tbody tr:last-child td { border-bottom: 0; }
.dates .badge { font-size: 12px; }

/* Previous / next year links */
.pager { display: flex; justify-content: space-between; gap: 12px; margin: 24px 0; }
.dates tr[aria-current] th, .dates tr[aria-current] td { background: var(--accent-soft); }

/* Embed code on the widget page */
.code { background: var(--bg); border-radius: 10px; padding: 12px; overflow-x: auto; font-size: 13px; white-space: pre-wrap; word-break: break-all; margin: 0 0 12px; }
