:root {
  --paper: #f8f4ec;
  --paper-2: #fdfaf4;
  --ink: #191611;
  --ink-soft: #453f34;
  --muted: #8b8374;
  --line: #e5dcc9;
  --line-2: #efe8d8;
  --accent: #0f5f4d;
  --accent-ink: #0a4a3b;
  --accent-soft: #e4efe8;
  --hl: #f7e2ae;
  --warn: #a8402c;
  --warn-soft: #faeae4;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(25, 22, 17, 0.05), 0 18px 50px -28px rgba(25, 22, 17, 0.35);
  --font: "SF Arabic", "Geeza Pro", "Noto Naskh Arabic", "Noto Sans Arabic", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
}

*,
*::before,
*::after { box-sizing: border-box; }

[hidden] { display: none !important; }

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

html,
body { height: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(120% 80% at 50% -10%, #fffdf7 0%, rgba(255, 253, 247, 0) 60%),
    radial-gradient(90% 60% at 100% 100%, #f3ecdd 0%, rgba(243, 236, 221, 0) 55%),
    var(--paper);
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

body[data-screen="read"] {
  height: 100dvh;
  overflow: hidden;
}

body[data-screen="read"] .shell {
  height: 100dvh;
  overflow: hidden;
}

.shell {
  display: flex;
  flex-direction: column;
  width: min(760px, 100%);
  min-height: 100dvh;
  margin-inline: auto;
  padding: clamp(14px, 2.6vw, 26px) clamp(16px, 4vw, 34px) clamp(12px, 2vw, 20px);
}

.topbar {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 34px;
  flex: 0 0 auto;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 19px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.brand__mark {
  width: 11px;
  height: 11px;
  border-radius: 3px;
  background: var(--accent);
  box-shadow: 0 0 0 3px rgba(15, 95, 77, 0.12);
}

.tag {
  font-size: 11.5px;
  line-height: 1;
  padding: 6px 9px;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--muted);
  background: rgba(255, 255, 255, 0.45);
  white-space: nowrap;
}

.tag--quiet {
  border-color: transparent;
  color: var(--muted);
  background: transparent;
  padding-inline: 0;
}

.topbar__grow { flex: 1 1 auto; }

.main {
  flex: 1 1 auto;
  display: flex;
  min-height: 0;
  position: relative;
}

.screen {
  display: none;
  flex-direction: column;
  width: 100%;
  min-height: 0;
}

.screen.is-on { display: flex; }

.screen.is-on > * { animation: rise 0.42s cubic-bezier(0.22, 0.61, 0.36, 1) both; }

@keyframes rise {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}

.foot {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 12px;
  padding-top: 10px;
  font-size: 11.5px;
  color: var(--muted);
}

.foot__ver { margin-inline-start: auto; opacity: 0.55; font-variant-numeric: tabular-nums; }

body[data-screen="read"] .foot { display: none; }

.screen--start,
.screen--end,
.screen--wait {
  justify-content: center;
  padding-block: clamp(8px, 4vh, 48px);
}

/* start */

.start { text-align: center; padding-bottom: 4vh; }

.kicker {
  margin: 0 0 18px;
  font-size: 12px;
  letter-spacing: 0.14em;
  color: var(--muted);
}

.wordmark {
  margin: 0;
  font-size: clamp(64px, 15vw, 108px);
  line-height: 0.92;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--ink);
}

.lede {
  margin: 20px 0 0;
  font-size: clamp(19px, 2.6vw, 23px);
  line-height: 1.7;
  color: var(--ink-soft);
  font-weight: 400;
}

.lede--sm { font-size: clamp(16px, 2.2vw, 18px); margin-top: 12px; }

.start__cta {
  margin-top: clamp(26px, 5vh, 44px);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.fine {
  margin: 22px 0 0;
  font-size: 12.5px;
  color: var(--muted);
}

/* buttons */

.btn {
  --btn-bg: transparent;
  --btn-fg: var(--ink);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 46px;
  padding: 0 22px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--btn-bg);
  color: var(--btn-fg);
  font-family: inherit;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: transform 0.12s ease, background-color 0.16s ease, border-color 0.16s ease, box-shadow 0.16s ease;
}

.btn:hover { border-color: #d6cab2; }
.btn:active { transform: scale(0.985); }

.btn--primary {
  --btn-bg: var(--accent);
  --btn-fg: #fdfbf4;
  border-color: var(--accent);
  box-shadow: 0 10px 26px -14px rgba(15, 95, 77, 0.75);
}

.btn--primary:hover { background: var(--accent-ink); border-color: var(--accent-ink); }

.btn--lg { min-height: 56px; padding-inline: 34px; font-size: 17px; }

.btn:disabled,
.ctl:disabled {
  opacity: 0.4;
  cursor: default;
  transform: none;
}

.btn--quiet {
  --btn-fg: var(--ink-soft);
  background: rgba(255, 255, 255, 0.5);
}

.btn--block { width: 100%; }

.linkish {
  margin-top: 18px;
  padding: 8px 4px;
  border: 0;
  background: none;
  font-family: inherit;
  font-size: 13.5px;
  color: var(--muted);
  text-decoration: underline;
  text-underline-offset: 4px;
  cursor: pointer;
}

/* read */

.screen--read { gap: 10px; padding-top: 4px; }

.readbar {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12.5px;
  color: var(--muted);
  flex: 0 0 auto;
}

.readbar__meta { display: flex; align-items: center; gap: 8px; }

.chip--cal {
  font-size: 10.5px;
  padding: 4px 8px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-ink);
}

.readbar__speed {
  margin-inline-start: auto;
  font-variant-numeric: tabular-nums;
  color: var(--ink-soft);
}

.track {
  height: 3px;
  border-radius: 999px;
  background: rgba(25, 22, 17, 0.08);
  overflow: hidden;
  flex: 0 0 auto;
}

.track__fill {
  display: block;
  height: 100%;
  width: 0;
  border-radius: 999px;
  background: var(--accent);
  transition: width 0.28s ease;
}

.stage {
  position: relative;
  flex: 1 1 0;
  min-height: 200px;
  overflow: hidden;
  padding: 0;
}

.text-flow {
  position: relative;
  transform: none;
  transition: transform 0.3s cubic-bezier(0.25, 0.6, 0.3, 1);
  will-change: transform;
}

.stage__fade {
  position: absolute;
  inset-inline: 0;
  height: clamp(28px, 8%, 56px);
  pointer-events: none;
}

.stage__fade--top {
  top: 0;
  background: linear-gradient(to bottom, var(--paper) 0%, rgba(248, 244, 236, 0.85) 45%, rgba(248, 244, 236, 0) 100%);
}

.stage__fade--bottom {
  bottom: 0;
  background: linear-gradient(to top, var(--paper) 0%, rgba(248, 244, 236, 0.85) 45%, rgba(248, 244, 236, 0) 100%);
}

.para {
  margin: 0 auto 1.05em;
  max-width: 25.5em;
  font-size: clamp(19px, 2.9vw, 24px);
  line-height: 2.02;
  letter-spacing: 0;
  color: var(--ink);
  font-weight: 400;
}

.para:last-child { margin-bottom: 0; }

.w {
  opacity: 0.2;
  border-radius: 6px;
  padding-block: 0.06em;
  transition: opacity 0.18s ease;
  -webkit-box-decoration-break: clone;
  box-decoration-break: clone;
}

.w.lvl-near { opacity: 0.45; }
.w.lvl-on { opacity: 1; }
.w.is-active {
  background: var(--hl);
  box-shadow: 0 0 0 0.1em var(--hl);
  color: var(--ink);
}

.controls {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  flex: 0 0 auto;
  padding-top: 6px;
}

.ctl {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  min-height: 44px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.55);
  color: var(--ink-soft);
  font-family: inherit;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background-color 0.16s ease, border-color 0.16s ease, color 0.16s ease, transform 0.1s ease;
}

.ctl:hover { background: #fff; border-color: #d6cab2; }
.ctl:active { transform: scale(0.96); }
.ctl svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

.ctl--play {
  width: 54px;
  min-width: 54px;
  height: 54px;
  border-color: var(--accent);
  background: var(--accent);
  color: #fdfbf4;
  margin-inline: 2px;
}

.ctl--play:hover { background: var(--accent-ink); border-color: var(--accent-ink); }
.ctl--play svg { width: 22px; height: 22px; }
.ctl--play .ic-play { fill: currentColor; stroke: none; }
.ctl--play .ic-pause { fill: currentColor; stroke: none; display: none; }
.ctl--play[aria-pressed="true"] .ic-play { display: none; }
.ctl--play[aria-pressed="true"] .ic-pause { display: block; }

.ctl--sm { min-width: 40px; min-height: 40px; font-size: 19px; line-height: 1; }

.speed {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 2px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.4);
}

.speed .ctl { border: 0; background: transparent; min-width: 40px; min-height: 44px; }
.speed .ctl:hover { background: rgba(25, 22, 17, 0.05); }

.speed__val {
  min-width: 38px;
  text-align: center;
  font-size: 13.5px;
  font-variant-numeric: tabular-nums;
  color: var(--ink-soft);
}

.ctl--ghost {
  margin-inline-start: auto;
  padding-inline: 14px;
  border-style: dashed;
  border-color: #ddd2ba;
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 500;
}

.hint {
  margin: 0;
  padding-bottom: 2px;
  font-size: 11px;
  color: var(--muted);
  text-align: center;
  flex: 0 0 auto;
}

/* quiz */

.screen--quiz { justify-content: center; padding-block: clamp(6px, 3vh, 30px); }

.quiz { width: 100%; }

.quiz__head { display: flex; align-items: center; gap: 10px; }

.quiz__head .kicker { margin: 0; }

.quiz__clock {
  font-size: 11.5px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  padding: 3px 8px;
  border-radius: 999px;
  background: rgba(25, 22, 17, 0.05);
}

.quiz__q {
  margin: 14px 0 20px;
  font-size: clamp(22px, 3.6vw, 30px);
  line-height: 1.55;
  font-weight: 700;
  letter-spacing: -0.01em;
  outline: none;
}

.quiz__timer {
  height: 3px;
  border-radius: 999px;
  background: rgba(25, 22, 17, 0.08);
  overflow: hidden;
  margin-bottom: 18px;
}

.quiz__timerfill {
  display: block;
  height: 100%;
  width: 100%;
  background: var(--accent);
}

.quiz__opts { display: flex; flex-direction: column; gap: 10px; }

.opt {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 58px;
  padding: 12px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.62);
  color: var(--ink);
  font-family: inherit;
  font-size: 16.5px;
  line-height: 1.55;
  text-align: start;
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease, transform 0.1s ease;
}

.opt:hover:not(:disabled) { background: #fff; border-color: #d3c6ad; }
.opt:active:not(:disabled) { transform: scale(0.995); }
.opt:disabled { cursor: default; }

.opt__key {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 999px;
  background: rgba(25, 22, 17, 0.06);
  color: var(--muted);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.opt__text { flex: 1 1 auto; }

.opt.is-correct {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.opt.is-correct .opt__key { background: var(--accent); color: #fdfbf4; }

.opt.is-wrong {
  border-color: var(--warn);
  background: var(--warn-soft);
}

.opt.is-wrong .opt__key { background: var(--warn); color: #fdfbf4; }

.quiz__fb { margin-top: 18px; }

.quiz__verdict {
  margin: 0 0 6px;
  font-size: 15px;
  font-weight: 700;
  color: var(--accent-ink);
}

.quiz__verdict.is-bad { color: var(--warn); }

.quiz__quote {
  margin: 0 0 20px;
  padding-inline-start: 12px;
  border-inline-start: 2px solid var(--hl);
  font-size: 15px;
  line-height: 1.85;
  color: var(--ink-soft);
}

/* end */

.endcard { text-align: center; }

.bignum {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  margin-top: 4px;
}

.bignum__n {
  font-size: clamp(84px, 22vw, 148px);
  line-height: 0.86;
  font-weight: 800;
  letter-spacing: -0.04em;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}

.bignum__u { font-size: 15px; color: var(--muted); }

.endline {
  margin: 18px 0 0;
  font-size: clamp(17px, 2.4vw, 20px);
  color: var(--ink-soft);
}

.endmeta { margin: 10px 0 0; font-size: 13px; color: var(--muted); }

.endcard__cta {
  margin-top: clamp(28px, 5vh, 44px);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

/* waitlist */

.waitcard {
  width: 100%;
  max-width: 460px;
  margin-inline: auto;
  text-align: center;
}

.waitcard__t {
  margin: 0;
  font-size: clamp(30px, 6vw, 42px);
  font-weight: 800;
  letter-spacing: -0.02em;
}

#wait-form { margin-top: 26px; }

.field { display: block; text-align: start; }

.field__label {
  display: block;
  margin-bottom: 8px;
  font-size: 12.5px;
  color: var(--muted);
}

.field input {
  width: 100%;
  min-height: 52px;
  padding: 0 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.75);
  font-family: var(--font);
  font-size: 16px;
  color: var(--ink);
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.field input::placeholder { color: #b3a996; }

.field input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(15, 95, 77, 0.1);
}

.field input[aria-invalid="true"] {
  border-color: var(--warn);
  box-shadow: 0 0 0 4px rgba(168, 64, 44, 0.08);
}

.field__err {
  margin: 8px 0 0;
  font-size: 12.5px;
  color: var(--warn);
  text-align: start;
}

#wait-form .btn { margin-top: 12px; }

.waitdone {
  margin-top: 26px;
  padding: 22px 18px;
  border: 1px solid #cfe2d8;
  border-radius: var(--radius);
  background: var(--accent-soft);
}

.waitdone__t { margin: 0; font-size: 17px; font-weight: 700; color: var(--accent-ink); }
.waitdone__s { margin: 8px 0 0; font-size: 13px; color: var(--accent-ink); opacity: 0.8; direction: ltr; }

/* misc */

.toast {
  position: fixed;
  inset-inline: 0;
  bottom: max(18px, env(safe-area-inset-bottom));
  margin-inline: auto;
  width: max-content;
  max-width: min(92vw, 380px);
  padding: 10px 16px;
  border-radius: 999px;
  background: rgba(25, 22, 17, 0.9);
  color: #fdfbf4;
  font-size: 12.5px;
  text-align: center;
  opacity: 0;
  transform: translateY(8px);
  pointer-events: none;
  transition: opacity 0.22s ease, transform 0.22s ease;
  z-index: 20;
}

.toast.is-on { opacity: 1; transform: none; }

.sr {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.fatal {
  margin: 40px auto;
  max-width: 40ch;
  text-align: center;
  color: var(--warn);
  font-size: 15px;
  line-height: 1.8;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

@media (max-width: 620px) {
  .shell { padding-inline: 18px; }
  .stage { min-height: 200px; }
  .para { line-height: 1.9; }
  .ctl--ghost { margin-inline-start: 0; flex: 1 1 100%; min-height: 42px; }
  .hint { display: none; }
  .start { padding-bottom: 0; }
}

@media (max-width: 380px) {
  .controls { gap: 6px; }
  .ctl { min-width: 42px; min-height: 42px; }
  .ctl--play { width: 50px; min-width: 50px; height: 50px; }
}

@media (hover: none) {
  .hint { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    transition-duration: 0.001ms !important;
  }
  .text-flow { transition: none; }
}
