:root {
  --bg: #0d1117;
  --panel: #161b22;
  --panel2: #1c2129;
  --line: #2d333b;
  --text: #e6edf3;
  --dim: #8b949e;
  --accent: #3fb950;
  --accent2: #58a6ff;
  --warn: #d29922;
  --bad: #f85149;
  --radius: 14px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0; padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  overscroll-behavior-y: none;
}

@font-face {
  font-family: "Amiri";
  src: url("fonts/Amiri-Regular.ttf") format("truetype");
  font-display: swap;
}
@font-face {
  font-family: "NotoNaskh";
  src: url("fonts/NotoNaskhArabic.ttf") format("truetype");
  font-display: swap;
}

.ar {
  font-family: "Amiri", "NotoNaskh", serif;
  direction: rtl;
  unicode-bidi: isolate;
  line-height: 1.9;
}

.wrap { max-width: 720px; margin: 0 auto; padding: 0 16px 96px; }

/* Header */
header {
  position: sticky; top: 0; z-index: 20;
  background: rgba(13,17,23,.92);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
  padding: 12px 0 0;
}
.hrow { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
h1 { font-size: 17px; margin: 0; font-weight: 600; letter-spacing: -.2px; }
.streak { font-size: 13px; color: var(--dim); display: flex; gap: 10px; align-items: center; }
.streak b { color: var(--accent); }

/* Tabs */
nav { display: flex; gap: 4px; margin-top: 12px; overflow-x: auto; scrollbar-width: none; }
nav::-webkit-scrollbar { display: none; }
nav button {
  flex: 0 0 auto;
  background: none; border: none; color: var(--dim);
  padding: 9px 14px; font-size: 14px; font-weight: 500;
  border-bottom: 2px solid transparent; cursor: pointer;
  border-radius: 8px 8px 0 0;
  font-family: inherit;
}
nav button.on { color: var(--text); border-bottom-color: var(--accent); background: var(--panel); }

/* Cards */
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  margin: 16px 0;
}
.card h2 { font-size: 15px; margin: 0 0 4px; font-weight: 600; }
.card .sub { font-size: 13px; color: var(--dim); margin: 0 0 14px; }

/* Letter grid */
.lgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: 10px; }
.lcell {
  background: var(--panel2); border: 1px solid var(--line);
  border-radius: 10px; padding: 12px 6px 9px;
  text-align: center; cursor: pointer; transition: .12s;
  user-select: none;
}
.lcell:active { transform: scale(.96); }
.lcell .glyph { font-family: "Amiri", serif; font-size: 34px; line-height: 1.2; direction: rtl; }
.lcell .lbl { font-size: 11px; color: var(--dim); margin-top: 4px; }

/* Letter detail */
.ldetail { text-align: center; padding: 8px 0 4px; }
.ldetail .big { font-family: "Amiri", serif; font-size: 96px; line-height: 1.1; direction: rtl; }
.forms { display: flex; justify-content: center; gap: 6px; margin: 16px 0 6px; flex-wrap: wrap; }
.form { background: var(--panel2); border-radius: 8px; padding: 8px 12px; min-width: 64px; }
.form .g { font-family: "Amiri", serif; font-size: 30px; direction: rtl; }
.form .t { font-size: 10px; color: var(--dim); text-transform: uppercase; letter-spacing: .5px; margin-top: 2px; }
.ldetail .sound { color: var(--accent2); font-size: 15px; font-weight: 600; margin-top: 6px; }
.ldetail .note { color: var(--dim); font-size: 14px; margin: 10px 20px 0; line-height: 1.6; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  background: var(--accent); color: #04170a; border: none;
  padding: 13px 22px; border-radius: 10px;
  font-size: 15px; font-weight: 600; cursor: pointer;
  font-family: inherit; transition: .12s;
}
.btn:active { transform: scale(.97); }
.btn.ghost { background: var(--panel2); color: var(--text); border: 1px solid var(--line); }
.btn.wide { width: 100%; }
.btn:disabled { opacity: .4; }
.btnrow { display: flex; gap: 10px; margin-top: 16px; }

/* Quiz */
.qprompt { text-align: center; padding: 10px 0 18px; }
.qprompt .glyph { font-family: "Amiri", serif; font-size: 90px; direction: rtl; line-height: 1.1; }
.qprompt .ask { font-size: 14px; color: var(--dim); margin-top: 6px; }
.opts { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.opt {
  background: var(--panel2); border: 1px solid var(--line);
  border-radius: 10px; padding: 15px 10px; cursor: pointer;
  font-size: 16px; color: var(--text); text-align: center;
  font-family: inherit; transition: .12s;
}
.opt:active { transform: scale(.97); }
.opt.good { background: rgba(63,185,80,.16); border-color: var(--accent); color: var(--accent); }
.opt.bad { background: rgba(248,81,73,.14); border-color: var(--bad); color: var(--bad); }
.opt .ar { font-size: 30px; display: block; }

/* Vocab card */
.vcard {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 34px 20px; text-align: center;
  min-height: 230px; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 12px;
}
.vcard .word { font-family: "Amiri", serif; font-size: 56px; direction: rtl; line-height: 1.3; }
.vcard .de { font-size: 22px; color: var(--accent); font-weight: 600; }
.vcard .root { font-size: 13px; color: var(--dim); }
.vcard .hintbtn { font-size: 13px; color: var(--dim); background: none; border: none; cursor: pointer; text-decoration: underline; font-family: inherit; }
.rate { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-top: 16px; }
.rate button {
  background: var(--panel2); border: 1px solid var(--line); color: var(--text);
  border-radius: 10px; padding: 12px 4px; font-size: 13px; cursor: pointer;
  font-family: inherit; font-weight: 500;
}
.rate button:active { transform: scale(.96); }
.rate .r0 { border-color: rgba(248,81,73,.5); color: var(--bad); }
.rate .r1 { border-color: rgba(210,153,34,.5); color: var(--warn); }
.rate .r2 { border-color: rgba(88,166,255,.5); color: var(--accent2); }
.rate .r3 { border-color: rgba(63,185,80,.5); color: var(--accent); }

/* Quran */
.verse { border-bottom: 1px solid var(--line); padding: 18px 0; }
.verse:last-child { border-bottom: none; }
.vnum {
  display: inline-block; font-size: 11px; color: var(--dim);
  border: 1px solid var(--line); border-radius: 20px;
  padding: 1px 9px; margin-bottom: 10px;
}
.vtext {
  font-family: "Amiri", serif; font-size: 30px; direction: rtl;
  text-align: right; line-height: 2.1; word-spacing: 2px;
}
.vtext span {
  cursor: pointer; padding: 2px 1px; border-radius: 5px; transition: .12s;
}
.vtext span.on { background: rgba(88,166,255,.2); color: var(--accent2); }
.vtrans { margin-top: 12px; display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  background: var(--panel2); border: 1px solid var(--line);
  border-radius: 20px; padding: 5px 12px; font-size: 13px;
}
.chip b { color: var(--accent2); font-weight: 600; }
.chip .w { font-family: "Amiri", serif; font-size: 17px; direction: rtl; margin-right: 6px; }
.playbtn {
  background: var(--panel2); border: 1px solid var(--line); color: var(--accent2);
  border-radius: 20px; padding: 6px 14px; font-size: 13px; cursor: pointer;
  font-family: inherit; margin-top: 10px;
}

/* Progress */
.stat { display: flex; justify-content: space-between; padding: 11px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.stat:last-child { border-bottom: none; }
.stat b { color: var(--accent); }
.bar { height: 7px; background: var(--panel2); border-radius: 4px; overflow: hidden; margin-top: 8px; }
.bar > i { display: block; height: 100%; background: var(--accent); border-radius: 4px; transition: .3s; }

.empty { text-align: center; color: var(--dim); padding: 40px 20px; font-size: 14px; }

.hide { display: none !important; }
.center { text-align: center; }
.mt { margin-top: 16px; }
