:root {
  --bg: #0e1320;
  --panel: #161d2d;
  --panel2: #1e2739;
  --line: #2b3549;
  --text: #eaeef6;
  --muted: #8a94aa;
  --sun: #f6b90d;
  --green: #22b566;
  --red: #ef4b4b;
  --orange: #ff9a3d;
  --f-lp: #8b6cff; --f-lr: #3aa7ff; --f-lm: #1fc9a0; --f-li: #f6b90d; --f-ri: #ff8a3d; --f-th: #9aa3b5;
  --font: 'Noto Sans Arabic', 'Segoe UI', Tahoma, sans-serif;
}
* { box-sizing: border-box; }
html { background: var(--bg); }
body {
  margin: 0; min-height: 100vh; color: var(--text); font-family: var(--font); font-size: 16px;
  background: radial-gradient(1200px 500px at 50% -200px, #1b2640 0%, transparent 70%), var(--bg);
  display: flex; flex-direction: column;
}
button { font: inherit; color: inherit; cursor: pointer; }
.muted { color: var(--muted); }
.center { text-align: center; }
h1 { font-size: 1.35rem; margin: 0 0 .2rem; font-weight: 800; }
h2 { margin: 0; font-weight: 800; }

/* header */
.top {
  display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap;
  padding: 14px clamp(16px, 4vw, 40px); border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--bg) 80%, transparent); backdrop-filter: blur(8px);
  position: sticky; top: 0; z-index: 5;
}
.brand { display: flex; align-items: center; gap: 10px; color: inherit; text-decoration: none; }
.brand svg { width: 40px; height: 40px; fill: var(--sun); stroke: var(--sun); stroke-width: 4; stroke-linecap: round; }
.brand span { display: flex; flex-direction: column; line-height: 1.2; }
.brand b { font-size: 1.5rem; font-weight: 800; }
.brand small { color: var(--muted); font-size: .8rem; }
.tabs { display: flex; gap: 4px; background: var(--panel); padding: 4px; border-radius: 12px; border: 1px solid var(--line); flex-wrap: wrap; }
.tabs button { background: none; border: 0; padding: 8px 16px; border-radius: 9px; color: var(--muted); font-weight: 600; }
.tabs button:hover { color: var(--text); }
.tabs button.on { background: var(--sun); color: #1a1400; }

main { flex: 1; width: 100%; max-width: 1180px; margin: 0 auto; padding: 24px clamp(16px, 3vw, 32px) 32px; }
.view { display: none; }
.view.on { display: block; animation: fade .25s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } }

.stage { background: var(--panel); border: 1px solid var(--line); border-radius: 18px; padding: clamp(16px, 2.5vw, 28px); }
.stage-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.stage-head p { margin: 0; }
.chips { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.chip { background: var(--panel2); border: 1px solid var(--line); padding: 6px 12px; border-radius: 999px; color: var(--muted); font-size: .9rem; }
.chip b { color: var(--text); font-size: 1.05rem; }
.chip.timer b { color: var(--sun); font-size: 1.3rem; }
.ghost { background: var(--panel2); border: 1px solid var(--line); padding: 7px 14px; border-radius: 10px; }
.ghost:hover { border-color: var(--sun); }
.primary { background: var(--sun); color: #1a1400; border: 0; padding: 10px 18px; border-radius: 10px; font-weight: 800; }
.primary:hover { filter: brightness(1.08); }
.primary:disabled { opacity: .5; cursor: default; }
.seg { display: flex; background: var(--panel2); border: 1px solid var(--line); border-radius: 10px; padding: 3px; }
.seg button { background: none; border: 0; padding: 6px 14px; border-radius: 8px; color: var(--muted); }
.seg button.on { background: var(--bg); color: var(--sun); font-weight: 700; }

/* learn */
.learn-grid { display: grid; grid-template-columns: 250px 1fr; gap: 18px; align-items: start; }
.lessons { background: var(--panel); border: 1px solid var(--line); border-radius: 18px; padding: 14px; display: flex; flex-direction: column; gap: 6px; }
.lessons h2 { font-size: 1rem; color: var(--muted); padding: 4px 6px 8px; }
.lesson { display: flex; align-items: center; gap: 10px; text-align: right; background: none; border: 1px solid transparent; border-radius: 12px; padding: 8px; }
.lesson:hover { background: var(--panel2); }
.lesson.on { background: var(--panel2); border-color: var(--sun); }
.lesson .n { width: 30px; height: 30px; border-radius: 9px; background: var(--bg); display: grid; place-items: center; font-weight: 800; color: var(--sun); flex: none; }
.lesson .t { flex: 1; display: flex; flex-direction: column; font-weight: 700; font-size: .95rem; }
.lesson .t small { color: var(--muted); font-weight: 400; font-size: .78rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 130px; }
.st, .stars { color: var(--sun); font-size: .8rem; letter-spacing: 1px; white-space: nowrap; }
.st i, .stars i { color: var(--line); font-style: normal; }
.stars { font-size: 2.4rem; }

/* typing box */
.typebox {
  --lh: 2.1em;
  position: relative; overflow: hidden; font-size: clamp(22px, 2.6vw, 30px); line-height: var(--lh); height: calc(var(--lh) * 3);
  background: var(--bg); border: 1px solid var(--line); border-radius: 14px; padding: 0 22px; direction: rtl; user-select: none;
}
.typebox.big { font-size: clamp(28px, 3.4vw, 40px); height: calc(var(--lh) * 2); }
.typebox .inner { position: relative; transition: transform .18s ease; }
.typebox .w { white-space: nowrap; }
.c { color: #5d677d; transition: color .08s; }
.c.ok { color: var(--text); }
.c.bad { color: var(--red); background: rgba(239, 75, 75, .15); }
.c.fix:not(.ok) { color: var(--orange); }
.c.fix.ok { color: var(--orange); }
.c.cur { background: rgba(246, 185, 13, .28); box-shadow: inset 0 -3px 0 var(--sun); border-radius: 3px; color: var(--sun); }
.c.sp.bad { background: rgba(239, 75, 75, .35); }
.typebox.shake { animation: shake .22s; }
@keyframes shake { 25% { transform: translateX(-5px); } 75% { transform: translateX(5px); } }

.finger { text-align: center; color: var(--muted); margin: 12px 0; min-height: 1.5em; }
.finger b { color: var(--sun); }
.timebar { height: 4px; background: var(--panel2); border-radius: 4px; margin-bottom: 14px; overflow: hidden; }
.timebar i { display: block; height: 100%; background: var(--sun); transition: width .1s linear; margin-inline-start: auto; }
#tHint { margin: 12px 0; font-size: .9rem; }

.switch { display: inline-flex; gap: 8px; align-items: center; color: var(--muted); font-size: .9rem; margin-top: 14px; cursor: pointer; }
.switch input { accent-color: var(--sun); width: 16px; height: 16px; }

/* keyboard */
.kb { direction: ltr; display: flex; flex-direction: column; gap: 6px; max-width: 900px; margin: 0 auto; padding: 12px; background: #0b0f19; border: 1px solid var(--line); border-radius: 16px; }
.kb-row { display: flex; gap: 6px; }
.key {
  flex: 1 1 0; min-width: 0; height: 54px; border-radius: 9px; background: var(--panel2); border: 1px solid var(--line); border-bottom-width: 3px;
  position: relative; display: grid; place-items: center; font-size: 22px; transition: background .12s, transform .08s, box-shadow .12s;
}
.key.mod { font-family: 'Segoe UI', sans-serif; font-size: 12px; color: var(--muted); }
.key .b { line-height: 1; }
.key .s { position: absolute; top: 3px; right: 6px; font-size: 12px; color: var(--muted); line-height: 1.2; }
.key .lat { position: absolute; bottom: 3px; left: 6px; font-size: 10px; color: #4f5a71; font-family: 'Segoe UI', sans-serif; }
.key.bump::after { content: ''; position: absolute; bottom: 7px; width: 12px; height: 2px; border-radius: 2px; background: var(--muted); }
.kb.fingers .key[data-finger^="lp"], .kb.fingers .key[data-finger^="rp"] { border-bottom-color: var(--f-lp); }
.kb.fingers .key[data-finger^="lr"], .kb.fingers .key[data-finger^="rr"] { border-bottom-color: var(--f-lr); }
.kb.fingers .key[data-finger^="lm"], .kb.fingers .key[data-finger^="rm"] { border-bottom-color: var(--f-lm); }
.kb.fingers .key[data-finger="li"] { border-bottom-color: var(--f-li); }
.kb.fingers .key[data-finger="ri"] { border-bottom-color: var(--f-ri); }
.kb.fingers .key[data-finger="th"] { border-bottom-color: var(--f-th); }
.key.target { background: var(--sun); color: #1a1400; border-color: #ffd65a; transform: translateY(-2px); box-shadow: 0 0 0 3px rgba(246, 185, 13, .25), 0 6px 18px rgba(246, 185, 13, .35); }
.key.target .s, .key.target .lat, .key.target.mod { color: #3b2e00; }
.key.target .b { font-weight: 700; }
.key.hit { background: var(--green) !important; color: #fff; transform: translateY(1px); }
.key.miss { background: var(--red) !important; color: #fff; transform: translateY(1px); }
.kb.small .key { height: 44px; font-size: 18px; }
.kb.nohelp .key.target { background: var(--panel2); color: inherit; border-color: var(--line); transform: none; box-shadow: none; }
.kb.nohelp .key.target .s, .kb.nohelp .key.target .lat { color: var(--muted); }

/* finder */
.letters { display: grid; grid-template-columns: repeat(auto-fill, minmax(54px, 1fr)); gap: 8px; margin: 18px 0; direction: rtl; }
.letters button { background: var(--panel2); border: 1px solid var(--line); border-radius: 12px; font-size: 26px; padding: 6px 0; }
.letters button:hover { border-color: var(--sun); }
.letters button.on { background: var(--sun); color: #1a1400; }
.find-info { text-align: center; font-size: 1.1rem; margin: 6px 0 16px; min-height: 1.7em; color: var(--muted); }
.find-info b { color: var(--sun); }

/* modal */
.modal { position: fixed; inset: 0; background: rgba(5, 8, 15, .7); backdrop-filter: blur(4px); display: grid; place-items: center; z-index: 20; padding: 16px; animation: fade .2s; }
.modal[hidden] { display: none; }
.card.result { background: var(--panel); border: 1px solid var(--line); border-radius: 20px; padding: 28px; width: min(460px, 100%); text-align: center; display: flex; flex-direction: column; gap: 14px; box-shadow: 0 20px 60px rgba(0, 0, 0, .5); }
.big-stats { display: flex; justify-content: center; gap: 12px; }
.big-stats div { flex: 1; background: var(--bg); border: 1px solid var(--line); border-radius: 14px; padding: 12px 8px; display: flex; flex-direction: column; }
.big-stats b { font-size: 2.4rem; color: var(--sun); line-height: 1.2; }
.big-stats span { color: var(--muted); font-size: .85rem; }
.rating { margin: 0; font-weight: 700; }
.result p { margin: 0; }
.save { display: flex; gap: 8px; }
.save input { flex: 1; min-width: 0; background: var(--bg); border: 1px solid var(--line); color: var(--text); border-radius: 10px; padding: 10px 12px; font: inherit; }
.save input:focus { outline: none; border-color: var(--sun); }
.save-msg { min-height: 1.4em; color: var(--green); }
.save-msg b { color: var(--sun); }
.row { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }

/* leaderboard */
.board { width: 100%; border-collapse: collapse; margin-top: 8px; }
.board th { text-align: right; color: var(--muted); font-weight: 600; font-size: .85rem; padding: 10px 12px; border-bottom: 1px solid var(--line); }
.board td { padding: 12px; border-bottom: 1px solid var(--line); }
.board td:first-child { width: 56px; font-size: 1.2rem; }
.board td b { color: var(--sun); font-size: 1.15rem; }
.board tr.top1 td { background: rgba(246, 185, 13, .08); }
.board tr.me td { box-shadow: inset 0 0 0 9999px rgba(34, 181, 102, .08); }

.foot { text-align: center; color: var(--muted); font-size: .8rem; padding: 18px 16px 26px; border-top: 1px solid var(--line); margin-top: 24px; }
.foot p { margin: 10px 0 0; }
.foot .by { display: inline-flex; align-items: center; gap: 6px; color: var(--text); text-decoration: none; font-size: .9rem; padding: 6px 14px; border: 1px solid var(--line); border-radius: 999px; transition: border-color .15s; }
.foot .by:hover { border-color: var(--sun); }
.foot .by b { font-family: 'Segoe UI', sans-serif; letter-spacing: .5px; color: var(--sun); }
.mobile-note { display: none; margin: 12px 16px 0; padding: 10px 14px; border-radius: 10px; background: rgba(246, 185, 13, .12); color: var(--sun); text-align: center; font-size: .9rem; }

@media (max-width: 860px) {
  .learn-grid { grid-template-columns: 1fr; }
  .lessons { flex-direction: row; overflow-x: auto; }
  .lessons h2 { display: none; }
  .lesson { flex: none; }
  .lesson .t small { display: none; }
  .key { height: 40px; font-size: 16px; border-radius: 6px; }
  .key .lat, .key .s { font-size: 9px; }
  .kb, .kb-row { gap: 3px; }
  .kb { padding: 6px; }
}
@media (hover: none) and (pointer: coarse) { .mobile-note { display: block; } }

/* ================= home ================= */
.hero { display: grid; grid-template-columns: 1fr 1.05fr; gap: clamp(20px, 4vw, 48px); align-items: center; padding: clamp(8px, 3vw, 36px) 0 clamp(28px, 5vw, 56px); }
.badge { display: inline-block; background: rgba(246, 185, 13, .12); color: var(--sun); border: 1px solid rgba(246, 185, 13, .3); padding: 6px 14px; border-radius: 999px; font-size: .85rem; font-weight: 600; }
.hero-title { font-size: clamp(2.3rem, 5.4vw, 4rem); line-height: 1.25; margin: 18px 0 30px; }
.hero-title em { font-style: normal; color: var(--sun); position: relative; }
.hero-title em::after { content: ''; position: absolute; inset-inline: 0; bottom: .05em; height: .12em; background: var(--green); border-radius: 4px; opacity: .8; }
.lead { color: var(--muted); font-size: 1.08rem; line-height: 1.9; margin: 0 0 24px; max-width: 34em; }
.cta { display: flex; gap: 10px; flex-wrap: wrap; }
.lg { padding: 13px 24px; font-size: 1.05rem; border-radius: 12px; }
.hero-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-top: 30px; }
.hero-stats div { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 12px 8px; text-align: center; display: flex; flex-direction: column; }
.hero-stats b { font-size: 1.6rem; color: var(--sun); line-height: 1.3; }
.hero-stats span { font-size: .8rem; color: var(--muted); }

.hero-demo { background: var(--panel); border: 1px solid var(--line); border-radius: 20px; padding: 0 16px 16px; box-shadow: 0 30px 80px rgba(0, 0, 0, .45), 0 0 0 1px rgba(246, 185, 13, .06); transform: perspective(1200px) rotateY(-6deg) rotateX(3deg); }
.demo-bar { display: flex; align-items: center; gap: 6px; padding: 12px 2px; direction: ltr; }
.demo-bar i { width: 10px; height: 10px; border-radius: 50%; background: var(--line); }
.demo-bar i:first-child { background: var(--red); } .demo-bar i:nth-child(2) { background: var(--sun); } .demo-bar i:nth-child(3) { background: var(--green); }
.demo-bar span { margin-left: auto; color: var(--muted); font-size: .8rem; }
.demo-text { background: var(--bg); border: 1px solid var(--line); border-radius: 12px; font-size: clamp(20px, 2.2vw, 28px); padding: 14px 18px; min-height: 2.6em; line-height: 1.6; margin-bottom: 14px; white-space: nowrap; overflow: hidden; }
.demo-text .done { color: var(--text); }
.demo-text .rest { color: #4f5a71; }
.demo-text .caret { display: inline-block; width: 2px; height: 1.1em; background: var(--sun); vertical-align: middle; margin: 0 1px; animation: blink 1s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }
.kb.mini { padding: 8px; gap: 4px; }
.kb.mini .kb-row { gap: 4px; }
.kb.mini .key { height: 34px; font-size: 14px; border-radius: 6px; border-bottom-width: 2px; }
.kb.mini .key .s, .kb.mini .key .lat, .kb.mini .key.bump::after { display: none; }
.kb.mini .key.mod { font-size: 9px; }

.sec-title { font-size: clamp(1.3rem, 2.4vw, 1.7rem); margin: 0 0 18px; }
.features { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 48px; }
.feat { text-align: right; background: var(--panel); border: 1px solid var(--line); border-radius: 18px; padding: 22px 20px; transition: transform .15s, border-color .15s; }
.feat:hover { transform: translateY(-4px); border-color: var(--sun); }
.feat .ico { font-size: 1.6rem; display: grid; place-items: center; width: 48px; height: 48px; border-radius: 14px; background: var(--panel2); margin-bottom: 14px; }
.feat h3 { margin: 0 0 8px; font-size: 1.1rem; }
.feat p { margin: 0; color: var(--muted); font-size: .92rem; line-height: 1.8; }

.split { display: grid; grid-template-columns: 1.2fr 1fr; gap: 18px; margin-bottom: 48px; }
.steps, .top3 { background: var(--panel); border: 1px solid var(--line); border-radius: 18px; padding: 24px; }
.steps ol { list-style: none; margin: 0; padding: 0; counter-reset: s; display: flex; flex-direction: column; gap: 16px; }
.steps li { counter-increment: s; display: grid; grid-template-columns: 44px 1fr; column-gap: 14px; }
.steps li::before { content: counter(s, arabic-indic); grid-row: span 2; width: 44px; height: 44px; border-radius: 12px; background: var(--sun); color: #1a1400; display: grid; place-items: center; font-weight: 800; font-size: 1.2rem; }
.steps li b { font-size: 1.05rem; }
.steps li span { color: var(--muted); font-size: .92rem; }
.top3 { display: flex; flex-direction: column; gap: 14px; }
.top3-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.top3-head .sec-title { margin: 0; }
.top3 ol { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; flex: 1; }
.top3 li { display: flex; align-items: center; gap: 12px; background: var(--bg); border: 1px solid var(--line); border-radius: 12px; padding: 10px 14px; }
.top3 li .m { font-size: 1.4rem; }
.top3 li .nm { flex: 1; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.top3 li b { color: var(--sun); font-size: 1.3rem; }
.top3 li small { color: var(--muted); }
.top3 li.empty { color: var(--muted); justify-content: center; padding: 22px; }
.top3 .ghost { align-self: flex-start; }

.faq { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 48px; }
.faq details { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 14px 18px; }
.faq details[open] { border-color: rgba(246, 185, 13, .5); }
.faq summary { cursor: pointer; font-weight: 700; list-style: none; display: flex; justify-content: space-between; gap: 10px; }
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after { content: '+'; color: var(--sun); font-size: 1.3rem; line-height: 1; }
.faq details[open] summary::after { content: '−'; }
.faq p { color: var(--muted); margin: 10px 0 0; line-height: 1.8; }

.band { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; padding: 28px 32px; border-radius: 20px;
  background: linear-gradient(120deg, rgba(246, 185, 13, .16), rgba(34, 181, 102, .12)); border: 1px solid rgba(246, 185, 13, .3); }
.band h2 { font-size: 1.6rem; }
.band p { margin: 4px 0 0; color: var(--muted); }

@media (max-width: 960px) {
  .hero { grid-template-columns: 1fr; }
  .hero-demo { transform: none; }
  .features { grid-template-columns: 1fr 1fr; }
  .split, .faq { grid-template-columns: 1fr; }
}
@media (max-width: 520px) {
  .features { grid-template-columns: 1fr; }
  .hero-stats { grid-template-columns: repeat(2, 1fr); }
  .tabs button { padding: 7px 10px; font-size: .9rem; }
}
