:root {
  --bg: #0e0f13;
  --card: #171920;
  --card2: #1f222b;
  --line: #2b2f3a;
  --text: #f2f2f4;
  --muted: #9a9fac;
  --gold: #ffce00;
  --gold-dark: #3a3000;
  --red: #e63946;
  --green: #2ecc71;
  --radius: 14px;
}
* { box-sizing: border-box; }
html { color-scheme: dark; }
html, body { margin: 0; background: var(--bg); color: var(--text); }

/* Thin rounded scrollbars that float over the page (like EpyonX). */
::-webkit-scrollbar { width: 10px; height: 10px; background: transparent; }
::-webkit-scrollbar-track, ::-webkit-scrollbar-corner { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,.18); border-radius: 99px; border: 3px solid transparent; background-clip: padding-box; min-height: 40px; }
::-webkit-scrollbar-thumb:hover { background-color: rgba(255,206,0,.55); border-width: 2px; }
::-webkit-scrollbar-button { display: none; height: 0; width: 0; }
@supports not selector(::-webkit-scrollbar) { * { scrollbar-width: thin; scrollbar-color: rgba(255,255,255,.22) transparent; } }

/* Dropdowns: dark, with our own small arrow instead of the white system box. */
select {
  -webkit-appearance: none; appearance: none; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%239a9fac' stroke-width='2' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: left 12px center; padding-left: 34px !important;
}
select option { background: #171920; color: var(--text); }

/* Our dropdown (replaces the system list) */
.dsel { position: relative; width: 100%; }
.dsel.auto { display: inline-block; width: auto; min-width: 150px; }
.dsel > select { display: none !important; }
.dsel-btn {
  width: 100%; justify-content: space-between; background: #0b0c10; font-weight: 400; padding: 10px 12px;
  border-radius: 10px; text-align: right; gap: 10px;
}
.dsel-btn::after { content: ''; width: 8px; height: 8px; border: solid var(--muted); border-width: 0 2px 2px 0; transform: rotate(45deg) translateY(-2px); transition: transform .15s; flex: none; }
.dsel.open .dsel-btn { border-color: var(--gold); }
.dsel.open .dsel-btn::after { transform: rotate(-135deg); border-color: var(--gold); }
.dsel-list {
  display: none; position: absolute; z-index: 40; top: calc(100% + 6px); right: 0; left: 0; min-width: 100%;
  max-height: 260px; overflow-y: auto; background: #171920; border: 1px solid #3a3f4c; border-radius: 12px; padding: 5px;
  box-shadow: 0 12px 30px rgba(0,0,0,.55);
}
.dsel.up .dsel-list { top: auto; bottom: calc(100% + 6px); }
.dsel.open .dsel-list { display: block; }
.dsel-opt { padding: 9px 12px; border-radius: 8px; cursor: pointer; white-space: nowrap; }
.dsel-opt:hover { background: var(--card2); }
.dsel-opt.on { background: var(--gold); color: #1a1600; font-weight: 700; }

/* Number box with our own − / + */
.dnum { display: inline-flex; align-items: stretch; max-width: 100%; vertical-align: middle; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: #0b0c10; direction: ltr; }
.dnum:focus-within { border-color: var(--gold); }
.dnum input { flex: 1; min-width: 0 !important; border: 0 !important; border-radius: 0 !important; text-align: center; background: transparent !important; -moz-appearance: textfield; appearance: textfield; min-width: 44px; padding: 8px 4px !important; }
.dnum input::-webkit-inner-spin-button, .dnum input::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.dnum button { border: 0; border-radius: 0; padding: 0 11px; background: var(--card2); color: var(--gold); font-size: 18px; font-weight: 700; }
.dnum button:hover { background: #2a2e39; }

/* Text boxes grow only downwards, never wider than their card. */
textarea { resize: vertical; max-width: 100%; min-height: 90px; }

/* File picker button in the site's colours. */
input[type=file] { padding: 6px; cursor: pointer; color: var(--muted); }
input[type=file]::file-selector-button, input[type=file]::-webkit-file-upload-button {
  font: inherit; font-weight: 700; background: var(--card2); color: var(--gold); border: 1px solid var(--line);
  border-radius: 8px; padding: 7px 14px; margin-left: 10px; cursor: pointer;
}
input[type=file]::file-selector-button:hover { border-color: var(--gold); }

/* Checkboxes: dark rounded box, gold when ticked. */
input[type=checkbox] {
  -webkit-appearance: none; appearance: none; width: 22px !important; height: 22px; flex: none; margin: 0; padding: 0;
  border: 2px solid #3a3f4c; border-radius: 6px; background: #0b0c10; cursor: pointer; display: inline-grid; place-content: center;
  transition: background .15s, border-color .15s;
}
input[type=checkbox]::after { content: ''; width: 11px; height: 6px; border: solid #1a1600; border-width: 0 0 3px 3px; transform: rotate(-45deg) translate(1px, -1px); opacity: 0; }
input[type=checkbox]:checked { background: var(--gold); border-color: var(--gold); }
input[type=checkbox]:checked::after { opacity: 1; }
input[type=checkbox]:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
.checkrow { display: flex !important; gap: 10px; align-items: center; color: var(--text) !important; cursor: pointer; }

/* Settings tab */
.setgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.setgrid .card h3 { margin-bottom: 4px; }
.days { display: flex; flex-wrap: wrap; gap: 6px; }
.days label { margin: 0; }
.days input { display: none; }
.days span { display: inline-block; padding: 7px 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--card2); color: var(--muted); cursor: pointer; font-weight: 700; }
.days input:checked + span { background: var(--gold); color: #1a1600; border-color: var(--gold); }
body {
  font-family: 'Tajawal', system-ui, sans-serif; font-size: 16px; line-height: 1.6;
  -webkit-user-select: none; user-select: none; -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}
input, textarea, select { -webkit-user-select: text; user-select: text; }
img, canvas, video { -webkit-user-drag: none; }
a { color: var(--gold); text-decoration: none; }
.wrap { max-width: 920px; margin: 0 auto; padding: 16px; }
.flag { height: 5px; background: linear-gradient(90deg, #000 0 33.3%, var(--red) 33.3% 66.6%, var(--gold) 66.6%); }
.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px; max-width: 920px; margin: 0 auto; }
.brand { font-weight: 800; font-size: 20px; letter-spacing: .5px; }
.brand b { color: var(--gold); }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.grow { flex: 1; }
.hidden { display: none !important; }
h1, h2, h3 { margin: 0 0 8px; line-height: 1.3; }
h1 { font-size: 24px; } h2 { font-size: 19px; } h3 { font-size: 16px; }

button, .btn {
  font: inherit; font-weight: 700; border: 1px solid var(--line); background: var(--card2); color: var(--text);
  border-radius: 10px; padding: 10px 16px; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; justify-content: center;
}
button:hover, .btn:hover { border-color: #444a58; }
button:active { transform: scale(.98); }
button:disabled { opacity: .5; cursor: default; }
.primary { background: var(--gold); color: #1a1600; border-color: var(--gold); }
.danger { color: var(--red); }
.ok { color: var(--green); }
.ghost { background: transparent; }
input, textarea, select {
  font: inherit; width: 100%; background: #0b0c10; color: var(--text); border: 1px solid var(--line);
  border-radius: 10px; padding: 10px 12px;
}
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--gold); }
label { display: block; font-size: 14px; color: var(--muted); margin: 10px 0 4px; }
.err { color: var(--red); font-size: 14px; min-height: 20px; margin-top: 6px; }

/* Tabs */
.tabs { display: flex; gap: 6px; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 4px; }
.tabs { flex-wrap: wrap; }
.tabs button { flex: 1; background: transparent; border: none; color: var(--muted); white-space: nowrap; padding: 10px 8px; }
.tabs button.on { background: var(--card2); color: var(--gold); }

/* Login */
.hero { text-align: center; padding: 32px 0 20px; }
.hero .logo { font-size: 46px; font-weight: 900; letter-spacing: 2px; }
.hero .logo span { color: var(--gold); }
.auth { max-width: 420px; margin: 0 auto; }

/* Player stats */
.stats { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 10px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 12px; text-align: center; }
.stat .n { font-size: 22px; font-weight: 800; color: var(--gold); }
.stat .l { font-size: 13px; color: var(--muted); }
.xpbar { height: 10px; background: #0b0c10; border-radius: 99px; overflow: hidden; border: 1px solid var(--line); }
.xpbar > div { height: 100%; background: var(--gold); border-radius: 99px; transition: width .6s; }

/* Badges */
.badges { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 10px; }
.badge { text-align: center; padding: 10px 6px; border-radius: 12px; background: var(--card); border: 1px solid var(--line); opacity: .35; filter: grayscale(1); }
.badge.got { opacity: 1; filter: none; border-color: var(--gold); }
.badge .ic { font-size: 28px; }
.badge .t { font-size: 12px; font-weight: 700; }

/* Lesson map */
.map { position: relative; padding: 10px 0 40px; }
.node { display: flex; align-items: center; gap: 14px; margin: 0 0 6px; }
.node:nth-child(4n+2) { padding-right: 18%; }
.node:nth-child(4n+3) { padding-right: 36%; }
.node:nth-child(4n+4) { padding-right: 18%; }
.dot {
  width: 64px; height: 64px; border-radius: 50%; flex: none; display: flex; align-items: center; justify-content: center;
  font-size: 22px; font-weight: 900; border: 3px solid var(--line); background: var(--card); cursor: pointer; position: relative;
}
.node.locked .dot { color: #555b68; cursor: default; }
.node.open .dot { border-color: var(--gold); color: var(--gold); animation: pulse 1.8s infinite; }
.node.pending .dot { border-color: #6c8cff; color: #6c8cff; }
.node.returned .dot { border-color: var(--red); color: var(--red); }
.node.done .dot { background: var(--gold); border-color: var(--gold); color: #1a1600; }
.node .info { min-width: 0; }
.node .info .t { font-weight: 700; }
.node .info .s { font-size: 13px; color: var(--muted); }
.stars { color: var(--gold); letter-spacing: 2px; font-size: 14px; }
@keyframes pulse { 0%,100% { box-shadow: 0 0 0 0 rgba(255,206,0,.5);} 50% { box-shadow: 0 0 0 12px rgba(255,206,0,0);} }

/* Lesson page */
.step { display: flex; align-items: center; gap: 8px; font-weight: 800; margin: 22px 0 10px; }
.step .k { width: 28px; height: 28px; border-radius: 50%; background: var(--gold); color: #1a1600; display: inline-flex; align-items: center; justify-content: center; font-size: 14px; }
.player { position: relative; width: 100%; aspect-ratio: 16/9; background: #000; border-radius: var(--radius); overflow: hidden; }
.player iframe, .player #yt { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.player .shield { position: absolute; inset: 0; z-index: 2; cursor: pointer; }
.player .curtain { position: absolute; inset: 0; z-index: 3; background: #000; display: flex; align-items: center; justify-content: center; cursor: pointer; }
.player .curtain .play { width: 76px; height: 76px; border-radius: 50%; background: var(--gold); color: #1a1600; font-size: 30px; display: flex; align-items: center; justify-content: center; }
.player .bar { position: absolute; left: 0; right: 0; bottom: 0; z-index: 4; display: flex; align-items: center; gap: 8px; padding: 8px 10px; background: rgba(0,0,0,.65); direction: ltr; }
.player .bar button { padding: 4px 10px; font-size: 14px; background: transparent; border: none; }
.player .bar input[type=range] { flex: 1; padding: 0; accent-color: var(--gold); }
.player .bar .time { font-size: 12px; color: #ddd; min-width: 84px; text-align: center; }
.player:fullscreen { border-radius: 0; }
.wm {
  position: absolute; z-index: 5; pointer-events: none; color: rgba(255,255,255,.38); font-weight: 700; font-size: 14px;
  text-shadow: 0 0 3px rgba(0,0,0,.6); white-space: nowrap; transition: top 2s, left 2s; direction: ltr;
}
.pdfbox { background: #2a2d36; border-radius: var(--radius); padding: 10px; max-height: 80vh; overflow: auto; }
.page { position: relative; margin: 0 auto 10px; max-width: 100%; background: #fff; }
.page canvas { display: block; width: 100%; height: auto; }
.page .wmtile { position: absolute; inset: 0; pointer-events: none; overflow: hidden; display: flex; flex-wrap: wrap; align-content: space-around; justify-content: space-around; transform: rotate(-24deg) scale(1.3); }
.page .wmtile span { color: rgba(200,0,0,.13); font-weight: 800; font-size: 18px; padding: 30px; direction: ltr; }
.thumbs { display: flex; gap: 10px; flex-wrap: wrap; }
.thumbs .th { position: relative; width: 92px; height: 120px; border-radius: 10px; overflow: hidden; border: 1px solid var(--line); background: #000; }
.thumbs .th img { width: 100%; height: 100%; object-fit: cover; cursor: zoom-in; }
.thumbs .th button { position: absolute; top: 4px; left: 4px; padding: 2px 8px; font-size: 12px; }
.status { padding: 12px 14px; border-radius: 12px; font-weight: 700; }
.status.pending { background: #1b2340; color: #8aa2ff; }
.status.approved { background: var(--gold-dark); color: var(--gold); }
.status.returned { background: #3a1419; color: #ff8a93; }

/* Daily words */
.pill.big { font-size: 14px; padding: 4px 12px; }
.art { display: inline-block; font-weight: 800; font-size: 13px; padding: 1px 9px; border-radius: 99px; direction: ltr; }
.art-der { background: #1d2b4f; color: #6c9cff; }
.art-die { background: #3a1419; color: #ff6b78; }
.art-das { background: #123a26; color: #3ddc84; }
.art-der-t { color: #6c9cff; } .art-die-t { color: #ff6b78; } .art-das-t { color: #3ddc84; }
.legend { gap: 6px; margin: 4px 0 12px; color: var(--muted); }
.wordgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.wcard { flex-direction: column; align-items: stretch; text-align: center; gap: 4px; padding: 12px 10px; position: relative; font-weight: 400; }
.wcard .art { align-self: center; }
.wcard .noun { font-size: 19px; font-weight: 800; direction: ltr; }
.wcard .ar { font-size: 13px; color: var(--muted); }
.wcard .spk { position: absolute; top: 6px; left: 8px; font-size: 12px; opacity: .6; }
.timer { height: 8px; background: #0b0c10; border-radius: 99px; overflow: hidden; margin: 10px 0 14px; border: 1px solid var(--line); }
.timer > div { height: 100%; width: 100%; background: var(--gold); }
.timer > div.low { background: var(--red); }
.qbox { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 26px 16px 18px; text-align: center; position: relative; min-height: 190px; }
.tnum { position: absolute; top: 10px; left: 14px; font-weight: 800; color: var(--muted); }
.qword { font-size: 36px; font-weight: 900; direction: ltr; margin: 8px 0 4px; }
.qsent { font-size: 24px; font-weight: 800; margin: 10px 0 8px; line-height: 1.5; }
.qsent .gap { color: var(--gold); }
.fb { min-height: 28px; margin-top: 12px; font-weight: 700; }
.choices { direction: ltr; display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 10px; margin: 14px 0 8px; }
.choice { font-size: 22px; padding: 18px 6px; border-width: 2px; direction: ltr; }
.choice.art-der { border-color: #2c4380; } .choice.art-die { border-color: #6a2530; } .choice.art-das { border-color: #1f6440; }
.choice.right { background: var(--green); color: #04220f; border-color: var(--green); }
.choice.bad { background: var(--red); color: #fff; border-color: var(--red); }
.choice:disabled { opacity: 1; }
.daily { color: var(--text); display: flex; align-items: center; gap: 14px; margin-top: 14px; border-color: var(--gold); }
.daily .ic { font-size: 34px; }

.grade { font-weight: 900; padding: 1px 10px; border-radius: 99px; direction: ltr; display: inline-block; font-size: 14px; }
.grade.pass { background: #123a26; color: #3ddc84; }
.grade.fail { background: #3a1419; color: #ff6b78; }
.gradepick { display: grid; grid-template-columns: repeat(11, minmax(0,1fr)); gap: 4px; direction: ltr; }
.gradepick button { padding: 8px 0; font-size: 14px; }
.gradepick button.on { background: var(--gold); color: #1a1600; border-color: var(--gold); }
.gradepick button.low { color: var(--red); }

/* AI */
.aibox { margin-top: 10px; border-color: #3b4a7a; background: #141a2c; }
.mistakes { margin: 6px 0 0; padding-right: 18px; }
.mistakes li { margin-bottom: 6px; }
.aibox pre { white-space: pre-wrap; background: #0b0c10; padding: 10px; border-radius: 8px; }
.tag-exam { background: var(--red); color: #fff; font-size: 12px; padding: 1px 8px; border-radius: 99px; font-weight: 800; }

/* Conversation */
.topics { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 10px; }
.topic { flex-direction: column; align-items: flex-start; text-align: right; gap: 2px; padding: 12px; font-weight: 400; }
.topic .ic { font-size: 26px; }
.topic b { font-size: 15px; }
.topic .de { font-size: 12px; color: var(--muted); direction: ltr; }
.topic.locked { opacity: .45; }
.chat { display: flex; flex-direction: column; gap: 10px; padding: 6px 0 140px; }
.bub { max-width: 86%; padding: 10px 14px; border-radius: 16px; }
.bub.ai { align-self: flex-start; background: var(--card2); border: 1px solid var(--line); border-top-right-radius: 4px; }
.bub.me { align-self: flex-end; background: #2a2410; border: 1px solid #5a4a00; border-top-left-radius: 4px; }
.bub .de { direction: ltr; text-align: left; font-weight: 700; font-size: 17px; }
.bub .ar { font-size: 13px; color: var(--muted); margin-top: 4px; }
.bub .fix { margin-top: 8px; padding-top: 8px; border-top: 1px dashed #5a4a00; font-size: 14px; }
.bub .play { padding: 2px 8px; font-size: 13px; margin-top: 6px; }
.talkbar { position: fixed; left: 0; right: 0; bottom: 0; background: rgba(14,15,19,.96); border-top: 1px solid var(--line); padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); }
.talkbar .in { max-width: 920px; margin: 0 auto; display: flex; gap: 10px; align-items: center; }
.mic { width: 72px; height: 72px; border-radius: 50%; font-size: 30px; background: var(--gold); color: #1a1600; border: none; flex: none; }
.mic.rec { background: var(--red); color: #fff; animation: pulse 1.2s infinite; }
.mic:disabled { opacity: .5; }

/* Mock exams */
.exams { display: grid; gap: 10px; }
.exam { display: flex; align-items: center; gap: 14px; text-align: right; font-weight: 400; width: 100%; }
.lv { display: inline-flex; align-items: center; justify-content: center; min-width: 54px; height: 54px; border-radius: 14px; background: var(--gold); color: #1a1600; font-weight: 900; font-size: 20px; direction: ltr; flex: none; }
h1 .lv { min-width: 44px; height: 38px; font-size: 17px; border-radius: 10px; vertical-align: middle; }
.part.on { background: var(--gold); color: #1a1600; border-color: var(--gold); }
.xtimer { position: fixed; z-index: 45; top: 12px; left: 50%; transform: translateX(-50%); background: var(--card2); border: 1px solid var(--gold);
  border-radius: 99px; padding: 6px 8px 6px 16px; display: flex; gap: 10px; align-items: center; box-shadow: 0 8px 24px rgba(0,0,0,.5); }
.xtimer span { font-size: 20px; font-weight: 900; color: var(--gold); }
.xtimer.low { border-color: var(--red); } .xtimer.low span { color: var(--red); }

/* Overlays */
.overlay { position: fixed; inset: 0; z-index: 50; background: rgba(0,0,0,.85); display: flex; align-items: center; justify-content: center; padding: 16px; }
.overlay img { max-width: 100%; max-height: 92vh; border-radius: 8px; }
.toast {
  position: fixed; z-index: 60; left: 50%; top: 18px; transform: translateX(-50%); background: var(--card2); border: 1px solid var(--gold);
  padding: 12px 18px; border-radius: 12px; font-weight: 700; max-width: 92vw; text-align: center;
}
.celebrate { text-align: center; }
.celebrate .big { font-size: 64px; animation: pop .6s ease; }
@keyframes pop { 0% { transform: scale(.2);} 70% { transform: scale(1.2);} 100% { transform: scale(1);} }
.confetti { position: fixed; top: -10px; width: 8px; height: 14px; z-index: 55; animation: fall linear forwards; }
@keyframes fall { to { transform: translateY(105vh) rotate(720deg); } }

/* Admin */
.metrics { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 10px; }
.metric { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 12px; }
.metric .n { font-size: 26px; font-weight: 800; }
.metric .l { font-size: 13px; color: var(--muted); }
.list { border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.list .it { padding: 12px 14px; border-bottom: 1px solid var(--line); background: var(--card); }
.list .it:last-child { border-bottom: none; }
.pill { font-size: 12px; padding: 2px 10px; border-radius: 99px; background: var(--card2); border: 1px solid var(--line); }
.pill.on { color: var(--green); border-color: #1f5d3a; }
.pill.off { color: var(--gold); border-color: #5a4a00; }
.starpick button { padding: 6px 12px; }
.starpick button.on { background: var(--gold); color: #1a1600; border-color: var(--gold); }
.center { text-align: center; }
.screen-msg { max-width: 460px; margin: 60px auto; text-align: center; }
.screen-msg .ic { font-size: 54px; }

@media (max-width: 640px) {
  .top { padding: 10px 12px; }
  .top button, .top .btn { padding: 7px 11px; font-size: 14px; }
  .top .brand .small { display: none; }
  .metrics { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .node:nth-child(4n+2), .node:nth-child(4n+4) { padding-right: 12%; }
  .node:nth-child(4n+3) { padding-right: 24%; }
  .dot { width: 56px; height: 56px; font-size: 19px; }
}
