:root {
  --bg: #f6f7f5;
  --surface: #ffffff;
  --surface-2: #f0f3f1;
  --text: #17201d;
  --muted: #5b6763;
  --border: #e0e6e3;
  --primary: #0b7a5e;
  --primary-ink: #ffffff;
  --primary-soft: #e5f3ee;
  --accent: #b7832a;
  --accent-soft: #fbf3e4;
  --danger: #b42318;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(16, 24, 20, .05), 0 4px 16px rgba(16, 24, 20, .04);
  --font: "IBM Plex Sans Arabic", "Segoe UI", Tahoma, "Noto Sans Arabic", system-ui, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1412;
    --surface: #151d1a;
    --surface-2: #1b2522;
    --text: #e7eeeb;
    --muted: #9aa8a2;
    --border: #26322e;
    --primary: #35c49a;
    --primary-ink: #052419;
    --primary-soft: #12302a;
    --accent: #e0b25c;
    --accent-soft: #2b2416;
    --danger: #f97066;
    --shadow: none;
    color-scheme: dark;
  }
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 17px;
  line-height: 1.75;
  color: var(--text);
  background: var(--bg);
}
img, svg { display: inline-block; vertical-align: middle; }
a { color: var(--primary); text-underline-offset: 3px; }
h1, h2, h3 { line-height: 1.35; margin: 0 0 .6em; }
h1 { font-size: clamp(1.55rem, 4.2vw, 2.1rem); font-weight: 700; }
h2 { font-size: 1.3rem; margin-top: 1.8em; }
h3 { font-size: 1.08rem; margin-top: 1.4em; }
p { margin: 0 0 1em; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.num { font-variant-numeric: tabular-nums; direction: ltr; unicode-bidi: isolate; }

.container { width: 100%; max-width: 980px; margin: 0 auto; padding: 0 16px; }
.skip { position: absolute; inset-inline-start: -9999px; }
.skip:focus { inset-inline-start: 16px; top: 8px; background: var(--surface); padding: 8px 12px; border-radius: 8px; z-index: 10; }

/* Header / footer */
.site-header { background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 5; }
.site-header__inner { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 60px; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--text); }
.brand__name { font-weight: 700; font-size: 1.25rem; }
.site-nav { display: flex; gap: 18px; overflow-x: auto; scrollbar-width: none; }
.site-nav a { color: var(--muted); text-decoration: none; font-size: .92rem; white-space: nowrap; }
.site-nav a:hover { color: var(--primary); }
@media (max-width: 640px) { .site-nav { display: none; } }

.site-footer { margin-top: 56px; padding: 32px 0 24px; background: var(--surface); border-top: 1px solid var(--border); }
.site-footer__inner { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 16px; }
.site-footer__brand { font-weight: 700; margin-bottom: 4px; }
.site-footer__links { display: flex; flex-wrap: wrap; gap: 8px 20px; }
.site-footer__links a { color: var(--muted); text-decoration: none; }
.site-footer__links a:hover { color: var(--primary); }
.disclaimer { font-size: .85rem; color: var(--muted); border-top: 1px solid var(--border); padding-top: 16px; margin-top: 16px; }

/* Breadcrumbs */
.crumbs { font-size: .85rem; color: var(--muted); margin: 18px 0 6px; display: flex; flex-wrap: wrap; gap: 6px; }
.crumbs a { color: var(--muted); text-decoration: none; }
.crumbs a:hover { color: var(--primary); }
.crumbs__sep { opacity: .5; }

/* Page intro */
.intro { margin: 8px 0 20px; }
.intro p { color: var(--muted); font-size: 1.02rem; margin: 0; }
.updated { display: inline-block; font-size: .82rem; color: var(--primary); background: var(--primary-soft); padding: 2px 10px; border-radius: 999px; margin: 10px 0 0; }

/* Home */
.hero { padding: 36px 0 12px; }
.hero h1 { font-size: clamp(1.7rem, 5vw, 2.5rem); }
.hero p { color: var(--muted); font-size: 1.08rem; max-width: 640px; }
.cat { margin-top: 28px; }
.cat__title { display: flex; align-items: center; gap: 10px; font-size: 1.15rem; color: var(--text); margin: 0 0 12px; }
.cat__title svg { color: var(--primary); }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.card { display: flex; flex-direction: column; gap: 4px; padding: 16px 18px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); text-decoration: none; color: var(--text); box-shadow: var(--shadow); transition: border-color .15s, transform .15s; }
.card:hover { border-color: var(--primary); transform: translateY(-1px); }
.card__title { font-weight: 700; }
.card__desc { color: var(--muted); font-size: .9rem; line-height: 1.6; }
.pillars { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; margin-top: 12px; }
.pillar { background: var(--surface-2); border-radius: var(--radius); padding: 16px 18px; }
.pillar strong { display: block; margin-bottom: 4px; }

/* Calculator */
.calc { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; align-items: start; }
@media (max-width: 820px) { .calc { grid-template-columns: minmax(0, 1fr); } }
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); }
.panel h2 { margin-top: 0; font-size: 1.1rem; }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field > label, .field > .label { font-weight: 500; font-size: .95rem; }
.hint { font-size: .82rem; color: var(--muted); line-height: 1.55; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.row-3 { display: grid; grid-template-columns: 1fr 1.4fr 1fr; gap: 8px; }
@media (max-width: 420px) { .row { grid-template-columns: 1fr; } }
input[type="text"], input[type="number"], input[type="date"], select {
  width: 100%; font: inherit; font-size: 1rem; color: var(--text); background: var(--surface);
  border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; min-height: 46px;
}
input:focus, select:focus { outline: 2px solid var(--primary); outline-offset: 1px; border-color: var(--primary); }
input[inputmode="decimal"], input[inputmode="numeric"] { direction: ltr; text-align: right; }
.choices { display: flex; flex-wrap: wrap; gap: 8px; }
.choice { position: relative; }
.choice input { position: absolute; opacity: 0; pointer-events: none; }
.choice span { display: inline-block; padding: 8px 14px; border: 1px solid var(--border); border-radius: 999px; cursor: pointer; font-size: .93rem; background: var(--surface); }
.choice input:checked + span { background: var(--primary); color: var(--primary-ink); border-color: var(--primary); }
.choice input:focus-visible + span { outline: 2px solid var(--primary); outline-offset: 2px; }
.check { display: flex; align-items: flex-start; gap: 8px; font-size: .93rem; cursor: pointer; }
.check input { margin-top: 6px; accent-color: var(--primary); width: 18px; height: 18px; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; font: inherit; font-size: .92rem; font-weight: 500; padding: 8px 14px; min-height: 40px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface); color: var(--text); cursor: pointer; text-decoration: none; }
.btn:hover { border-color: var(--primary); color: var(--primary); }
.btn--primary { background: var(--primary); color: var(--primary-ink); border-color: var(--primary); }
.btn--primary:hover { color: var(--primary-ink); filter: brightness(1.05); }
.btn--wa { background: #1fa855; border-color: #1fa855; color: #fff; }
.btn--wa:hover { color: #fff; filter: brightness(1.05); }

.result { position: sticky; top: 76px; }
@media (max-width: 820px) { .result { position: static; } }
.result__label { color: var(--muted); font-size: .9rem; margin-bottom: 2px; }
.result__value { font-size: clamp(1.9rem, 6vw, 2.5rem); font-weight: 700; color: var(--primary); line-height: 1.25; }
.result__value small { font-size: 1rem; font-weight: 500; color: var(--muted); }
.result__note { margin: 10px 0 0; padding: 10px 12px; border-radius: 10px; background: var(--primary-soft); font-size: .92rem; line-height: 1.65; }
.result__note.is-warn { background: var(--accent-soft); }
.result__empty { color: var(--muted); }
.breakdown { width: 100%; border-collapse: collapse; margin-top: 14px; font-size: .93rem; }
.breakdown th, .breakdown td { padding: 8px 4px; border-bottom: 1px solid var(--border); text-align: start; vertical-align: top; }
.breakdown td:last-child { text-align: end; white-space: nowrap; font-variant-numeric: tabular-nums; }
.breakdown tr.total td { font-weight: 700; border-bottom: 0; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.error { color: var(--danger); font-size: .9rem; }

/* Article content */
.content { margin-top: 28px; }
.content table { width: 100%; border-collapse: collapse; margin: 8px 0 18px; font-size: .95rem; display: block; overflow-x: auto; }
.content th, .content td { border: 1px solid var(--border); padding: 8px 10px; text-align: start; }
.content th { background: var(--surface-2); font-weight: 500; }
.content ul, .content ol { padding-inline-start: 1.3em; margin: 0 0 1em; }
.content li { margin-bottom: .35em; }
.formula { background: var(--surface-2); border-radius: 10px; padding: 12px 14px; margin: 0 0 1em; font-weight: 500; }
.callout { border-inline-start: 4px solid var(--accent); background: var(--accent-soft); padding: 12px 14px; border-radius: 8px; margin: 0 0 1em; }
.sources { font-size: .92rem; }

/* FAQ */
.faq { margin-top: 32px; }
.faq__item { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 0 16px; margin-bottom: 8px; }
.faq__item summary { cursor: pointer; padding: 13px 0; font-weight: 500; list-style: none; position: relative; padding-inline-end: 24px; }
.faq__item summary::-webkit-details-marker { display: none; }
.faq__item summary::after { content: "+"; position: absolute; inset-inline-end: 0; top: 10px; font-size: 1.3rem; color: var(--primary); }
.faq__item[open] summary::after { content: "−"; }
.faq__a { padding-bottom: 14px; color: var(--muted); }
.faq__a p:last-child { margin: 0; }

/* Related */
.related { margin-top: 32px; }
.related__grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 8px; }
.related__link { display: flex; align-items: center; gap: 8px; padding: 12px 14px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; text-decoration: none; color: var(--text); font-size: .95rem; }
.related__link svg { color: var(--primary); flex: none; }
.related__link:hover { border-color: var(--primary); }

/* Ads */
.ad { margin: 24px 0; min-height: 100px; text-align: center; }
.ad__label { display: block; font-size: .72rem; color: var(--muted); margin-bottom: 4px; }
.ad--placeholder { display: flex; align-items: center; justify-content: center; border: 1px dashed var(--border); border-radius: 12px; color: var(--muted); font-size: .85rem; background: repeating-linear-gradient(45deg, transparent 0 10px, var(--surface-2) 10px 20px); }

/* Home search */
.search { margin-top: 18px; max-width: 560px; }
.search input { width: 100%; font: inherit; font-size: 1.02rem; padding: 12px 16px; min-height: 50px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.search input:focus { outline: 2px solid var(--primary); outline-offset: 1px; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Repeating rows (GPA courses) */
.rows { display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; }
.rows__item { display: grid; grid-template-columns: 2.2rem 1fr 1fr; gap: 8px; align-items: center; }
.rows__num { color: var(--muted); font-size: .9rem; text-align: center; }

/* Small stat grid inside results */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 8px; margin-top: 12px; }
.stat { background: var(--surface-2); border-radius: 10px; padding: 10px 12px; }
.stat__label { font-size: .8rem; color: var(--muted); }
.stat__value { font-weight: 700; font-size: 1.05rem; }

/* Many small inputs (inheritance) */
.grid-inputs { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 4px 10px; margin-bottom: 8px; }
.grid-inputs .field { margin-bottom: 8px; }
.grid-inputs .check { padding: 6px 0; }
table.inh td:first-child { white-space: normal; }
.result-wide { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 20px; box-shadow: var(--shadow); }

/* Imsakiya / timetables */
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 12px 0; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); }
table.imsak { width: 100%; border-collapse: collapse; font-size: .88rem; min-width: 640px; }
table.imsak th, table.imsak td { padding: 8px 6px; border-bottom: 1px solid var(--border); text-align: center; white-space: nowrap; }
table.imsak th { background: var(--surface-2); font-weight: 500; position: sticky; top: 0; }
table.imsak td:nth-child(3), table.imsak td:nth-child(7) { font-weight: 700; color: var(--primary); }
table.imsak tr.is-today td { background: var(--accent-soft); }
.related__link[aria-current="page"] { border-color: var(--primary); background: var(--primary-soft); }

/* Countdown */
.countdown { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 12px 0; direction: rtl; }
.countdown__cell { background: var(--primary-soft); border-radius: 12px; padding: 12px 6px; text-align: center; }
.countdown__num { display: block; font-size: clamp(1.6rem, 7vw, 2.4rem); font-weight: 700; color: var(--primary); font-variant-numeric: tabular-nums; line-height: 1.2; }
.countdown__unit { font-size: .85rem; color: var(--muted); }

/* Today strip (dates) */
.today { display: flex; flex-wrap: wrap; gap: 6px 16px; padding: 12px 16px; background: var(--primary-soft); border-radius: 12px; margin-bottom: 16px; font-weight: 500; }

@media print {
  .site-header, .site-footer, .ad, .actions, .related, .faq, .content, .crumbs { display: none !important; }
  .calc { grid-template-columns: 1fr; }
  body { background: #fff; }
}
