:root {
  --ink: #13234B;
  --ink-2: #4B5874;
  --blue: #2C4C8F;
  --blue-soft: #9FB2D9;
  --wash: #EDF0F5;
  --rule: #D9DEE8;
  --dot-empty: #B7C1D3;
  --gilt: #A87A1C;
  --gilt-light: #E2C27A;
  --gilt-frame: #C9A55A;
  --amber-text: #8A5A00;
  --paper: #FFFFFF;
  --danger: #A3261F;
  --font: 'Schibsted Grotesk', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --arabic: 'Amiri', 'Traditional Arabic', serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--paper); color: var(--ink); font-family: var(--font); -webkit-text-size-adjust: 100%; }
body { min-height: 100dvh; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--blue); }
a:hover { color: var(--ink); }
:focus-visible { outline: 3px solid var(--gilt); outline-offset: 2px; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.num { font-variant-numeric: tabular-nums; }
.ar { font-family: var(--arabic); }

.app { max-width: 480px; margin: 0 auto; min-height: 100dvh; display: flex; flex-direction: column; }
.screen { flex: 1; padding: 20px 20px 24px; display: flex; flex-direction: column; gap: 24px; }
.topbar { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.topbar .usrah { font-size: 15px; font-weight: 600; }
.linkish { background: none; border: 0; padding: 8px 0; color: var(--blue); text-decoration: underline; cursor: pointer; font-size: 14px; }

h1 { margin: 0; font-size: 30px; line-height: 1.15; font-weight: 700; letter-spacing: -0.01em; }
h2 { margin: 0; font-size: 22px; line-height: 1.2; font-weight: 700; }
p { margin: 0; }
.lead { font-size: 16px; color: var(--ink-2); line-height: 1.45; }
.quiet { color: var(--ink-2); }
.small { font-size: 13px; line-height: 1.45; }
.stack { display: flex; flex-direction: column; gap: 8px; }
.section { border-top: 1px solid var(--rule); padding-top: 20px; display: flex; flex-direction: column; gap: 12px; }

.btn { min-height: 52px; padding: 0 18px; border-radius: 10px; border: 0; background: var(--ink); color: #fff; font-size: 17px; font-weight: 600; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; text-decoration: none; text-align: center; }
.btn:hover { color: #fff; background: #0c1836; }
.btn[disabled] { background: var(--rule); color: var(--ink-2); cursor: not-allowed; }
.btn.secondary { background: #fff; color: var(--ink); border: 1.5px solid var(--ink); }
.btn.secondary:hover { background: var(--wash); color: var(--ink); }
.btn.block { width: 100%; }
.btn.two-line { flex-direction: column; align-items: flex-start; padding: 12px 16px; min-height: 64px; gap: 3px; text-align: left; }
.btn.two-line .sub { font-size: 14px; font-weight: 400; color: #C9D2E6; }
.btn.secondary.two-line .sub { color: var(--ink-2); }

.field-label { font-size: 14px; color: var(--ink-2); }
.page-input { width: 100%; min-width: 0; border: 0; border-bottom: 2px solid var(--ink); border-radius: 0; background: transparent; font-size: 56px; font-weight: 700; line-height: 1; padding: 4px 0 10px; text-align: center; font-variant-numeric: tabular-nums; }
.page-input.medium { font-size: 36px; text-align: left; width: 150px; }
.page-input::placeholder { color: var(--rule); }
.stepper { display: flex; align-items: center; gap: 12px; }
.step { flex-shrink: 0; width: 56px; height: 56px; display: flex; align-items: center; justify-content: center; border-radius: 10px; border: 1.5px solid var(--ink); background: #fff; cursor: pointer; touch-action: manipulation; user-select: none; -webkit-user-select: none; }
.step.plus { background: var(--ink); border-color: var(--ink); }
.step svg { pointer-events: none; }
.live { text-align: center; font-size: 20px; font-weight: 700; min-height: 26px; }
.live.quiet-live { font-size: 16px; font-weight: 500; color: var(--ink-2); }
.live.warn { color: var(--amber-text); font-size: 16px; }
.hint { text-align: center; font-size: 13px; color: var(--ink-2); line-height: 1.45; }
.error { color: var(--danger); font-size: 15px; line-height: 1.45; }

.names { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--rule); }
.names li { border-bottom: 1px solid var(--rule); }
.names button { width: 100%; min-height: 52px; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 0 6px; background: none; border: 0; font-size: 17px; text-align: left; cursor: pointer; }
.names button:hover { background: var(--wash); }
.names .tag { font-size: 13px; color: var(--ink-2); }

.juz-head { display: flex; justify-content: space-between; align-items: baseline; }
.juz-head .title { font-size: 22px; font-weight: 700; }
.juz-head .ar { font-size: 20px; color: var(--ink-2); }
.bar { height: 14px; border-radius: 7px; background: var(--wash); overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--blue); border-radius: 7px; }
.split { display: flex; justify-content: space-between; gap: 12px; font-size: 14px; color: var(--ink-2); }
.split strong { color: var(--ink); }
.dots { display: flex; justify-content: space-between; align-items: center; margin-top: 8px; }
.dot { width: 9px; height: 9px; border-radius: 50%; border: 1.5px solid var(--dot-empty); background: #fff; }
.dot.d-partial { background: var(--blue-soft); border: 0; }
.dot.d-full { background: var(--blue); border: 0; }
.dot.d-current { border: 3px solid var(--gilt); background: #fff; }
.facts { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin: 6px 0 0; }
.facts.two { grid-template-columns: repeat(2, minmax(0, 1fr)); row-gap: 18px; column-gap: 16px; }
.facts dt { font-size: 13px; color: var(--ink-2); }
.facts dd { margin: 2px 0 0; font-size: 26px; font-weight: 700; }
.facts dd small { font-size: 15px; font-weight: 500; color: var(--ink-2); }

.standing { display: flex; justify-content: space-between; align-items: center; gap: 12px; font-size: 15px; line-height: 1.45; }

.history { list-style: none; margin: 0; padding: 0; }
.history li { display: flex; align-items: center; gap: 12px; min-height: 44px; border-bottom: 1px solid var(--rule); font-size: 15px; }
.history li .when { flex: 1; color: var(--ink-2); }
.history li .what { font-weight: 600; }

.tabbar { display: flex; height: 64px; border-top: 1px solid var(--rule); position: sticky; bottom: 0; background: #fff; }
.tabbar button { flex: 1; background: none; border: 0; font-size: 16px; font-weight: 500; color: var(--ink-2); cursor: pointer; }
.tabbar button[aria-current="page"] { font-weight: 700; color: var(--ink); box-shadow: inset 0 3px 0 var(--ink); }

/* Saved */
.check-icon { width: 36px; height: 36px; }
.days { display: grid; grid-template-columns: repeat(15, minmax(0, 1fr)); gap: 4px; }
.days span { height: 18px; border-radius: 3px; background: var(--wash); }
.days span.read { background: var(--blue); }
.days span.today { background: var(--gilt); }
.nudge { padding: 14px 16px; background: var(--wash); border-radius: 10px; font-size: 15px; line-height: 1.45; }
.quote { margin: 0; padding: 12px 14px; border: 1px solid var(--rule); border-radius: 10px; font-size: 15px; line-height: 1.45; white-space: pre-wrap; word-break: break-word; }

/* Dialog */
.overlay { position: fixed; inset: 0; background: rgba(19, 35, 75, 0.5); display: flex; align-items: flex-end; justify-content: center; z-index: 10; }
.sheet { width: 100%; max-width: 480px; background: #fff; border-radius: 16px 16px 0 0; padding: 28px 20px calc(24px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 14px; }
.sheet .btn { width: 100%; }

/* An-Nas */
.annas { flex: 1; background: var(--ink); color: #fff; padding: 18px; display: flex; }
.annas .frame { flex: 1; border: 5px double var(--gilt-frame); padding: 6px; display: flex; }
.annas .inner { flex: 1; border: 1px solid var(--gilt-frame); padding: 40px 24px 28px; display: flex; flex-direction: column; align-items: center; text-align: center; gap: 18px; }
.annas .ar { font-size: 52px; line-height: 1.3; font-weight: 700; color: var(--gilt-light); margin-top: 24px; }
.annas .sub { color: #C9D2E6; font-size: 15px; }
.annas p.body { color: #DCE2EF; font-size: 16px; line-height: 1.55; max-width: 300px; }
.annas .facts { width: 100%; grid-template-columns: repeat(2, minmax(0, 1fr)); border-top: 1px solid rgba(201,165,90,.5); padding-top: 18px; }
.annas .facts dt { color: #C9D2E6; }
.annas .facts > div + div { border-left: 1px solid rgba(201,165,90,.5); }
.annas .btn { margin-top: auto; align-self: stretch; background: var(--gilt-light); color: var(--ink); }
.annas :focus-visible { outline-color: #fff; }

/* Leaderboards */
.boards-head { padding: 22px 20px 0; }
.scope { display: flex; gap: 22px; padding: 0 20px; margin-top: 10px; border-bottom: 1px solid var(--rule); }
.scope button { padding: 12px 0; background: none; border: 0; font-size: 15px; font-weight: 500; color: var(--ink-2); cursor: pointer; }
.scope button[aria-pressed="true"] { font-weight: 700; color: var(--ink); box-shadow: inset 0 -3px 0 var(--ink); }
.period { margin: 14px 20px 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); height: 40px; border: 1.5px solid var(--ink); border-radius: 8px; overflow: hidden; }
.period button { border: 0; background: #fff; color: var(--ink); font-size: 15px; font-weight: 500; cursor: pointer; }
.period button[aria-pressed="true"] { background: var(--ink); color: #fff; font-weight: 600; }
.metric { margin: 10px 20px 0; display: flex; align-items: center; gap: 16px; font-size: 14px; }
.metric button { min-height: 32px; background: none; border: 0; padding: 0; font-size: 14px; font-weight: 500; color: var(--ink-2); cursor: pointer; }
.metric button[aria-pressed="true"] { color: var(--ink); font-weight: 700; box-shadow: inset 0 -2px 0 var(--ink); }
.board { padding: 14px 20px 24px; flex: 1; display: flex; flex-direction: column; }
.rows { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--rule); }
.rows li { padding: 9px 10px 11px; border-bottom: 1px solid var(--rule); display: flex; flex-direction: column; gap: 7px; }
.rows li.me { background: var(--wash); }
.row { display: flex; align-items: center; gap: 14px; }
.row .rank { width: 24px; font-size: 15px; font-weight: 500; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.row .rank.top { font-weight: 700; color: var(--ink); }
.row .who { flex: 1; display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.row .who .name { font-size: 16px; font-weight: 600; }
.row .who .note { font-size: 13px; color: var(--ink-2); }
.row .who .note.amber { color: var(--amber-text); }
.row .val { text-align: right; display: flex; flex-direction: column; align-items: flex-end; }
.row .val b { font-size: 20px; }
.row .val small { font-size: 12.5px; color: var(--ink-2); }
.meter { margin-left: 38px; height: 4px; background: var(--wash); border-radius: 2px; overflow: hidden; }
.meter span { display: block; height: 100%; background: var(--blue); }
.meter span.mine { background: var(--gilt); }
.me-row { margin-top: 10px; background: var(--wash); border-radius: 8px; padding: 10px; }
.empty { padding: 24px 0; color: var(--ink-2); }

/* Organiser */
.admin { max-width: 960px; margin: 0 auto; padding: 24px 20px 64px; display: flex; flex-direction: column; gap: 28px; }
.admin h1 { font-size: 28px; }
.admin form.inline { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; }
.admin label { display: flex; flex-direction: column; gap: 4px; font-size: 14px; color: var(--ink-2); }
.admin input, .admin select, .admin textarea { min-height: 44px; padding: 8px 10px; border: 1.5px solid var(--rule); border-radius: 8px; background: #fff; font-size: 16px; color: var(--ink); }
.admin textarea { min-height: 120px; width: 100%; }
.admin .btn { min-height: 44px; font-size: 15px; }
.admin details { border: 1px solid var(--rule); border-radius: 10px; }
.admin summary { padding: 14px 16px; cursor: pointer; display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: baseline; }
.admin summary b { font-size: 17px; }
.admin .usrah-body { padding: 0 16px 16px; display: flex; flex-direction: column; gap: 16px; }
.table-wrap { overflow-x: auto; }
.admin table { width: 100%; border-collapse: collapse; font-size: 15px; }
.admin th, .admin td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--rule); white-space: nowrap; }
.admin th { font-size: 13px; color: var(--ink-2); font-weight: 600; }
.admin td.num, .admin th.num { text-align: right; }
.admin .mini { min-height: 36px; padding: 0 10px; font-size: 14px; border-radius: 8px; border: 1.5px solid var(--ink); background: #fff; cursor: pointer; }
.admin .mini.danger { border-color: var(--danger); color: var(--danger); }
.admin .entries { margin: 6px 0 12px; }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 12px 18px; border-radius: 10px; font-size: 15px; z-index: 20; max-width: calc(100% - 32px); }
