:root{
  --orange:#ED7D31; --orange-light:#FFC15E;
  --cream:#FBF7F2; --ink:#2B2118; --muted:#8A7C68;
  --sidebar:#3A2E20; --nav-muted:#C9BFB0;
  --border:#F0EAE0; --border2:#F3ECE1; --border3:#EEE3D3;
}
*{box-sizing:border-box;}
html,body{margin:0;padding:0;background:var(--cream);font-family:'Tajawal',sans-serif;color:var(--ink);}
::-webkit-scrollbar{height:8px;width:8px;}
::-webkit-scrollbar-thumb{background:rgba(0,0,0,.15);border-radius:8px;}
a{color:var(--orange);text-decoration:none;}
a:hover{color:#C9601D;}
button{font-family:'Tajawal',sans-serif;}
.heading{font-family:'Baloo Bhaijan 2',sans-serif;}
.hidden{display:none !important;}

/* ---------- Login ---------- */
#login-screen{
  min-height:100vh;width:100%;
  background:linear-gradient(160deg,#FFF3E4,#FDE7D6 45%,#FBD9E8);
  display:flex;align-items:center;justify-content:center;padding:24px;
}
.login-card{width:100%;max-width:400px;background:#fff;border-radius:28px;padding:40px 36px;
  box-shadow:0 30px 60px -20px rgba(0,0,0,.25);text-align:center;}
.login-logo{width:76px;height:76px;border-radius:50%;margin:0 auto 16px;
  background:linear-gradient(135deg,var(--orange),var(--orange-light));
  display:flex;align-items:center;justify-content:center;font-size:36px;}
.login-title{font-weight:700;font-size:21px;margin-bottom:4px;}
.login-sub{font-size:13px;color:var(--muted);margin-bottom:28px;}
.field-label{font-size:13px;font-weight:700;margin-bottom:8px;text-align:start;}
.field-group{margin-bottom:18px;text-align:start;}
#username-input{width:100%;padding:14px 16px;border-radius:14px;border:2px solid var(--border);
  font-size:15px;font-family:'Tajawal',sans-serif;text-align:start;outline:none;background:var(--cream);color:var(--ink);}
#username-input:focus{border-color:var(--orange);}
.pin-dots{display:flex;justify-content:center;gap:14px;margin-bottom:20px;}
.pin-dot{width:16px;height:16px;border-radius:50%;background:var(--border);transition:background .15s;}
.pin-dot.filled{background:var(--orange);}
.login-error{background:#FDEEEE;color:#D33333;font-size:13px;font-weight:700;padding:10px 14px;
  border-radius:12px;margin-bottom:16px;}
.keypad{direction:ltr;display:grid;grid-template-columns:repeat(3,1fr);gap:10px;margin-bottom:20px;}
.keypad button{background:var(--cream);border:2px solid var(--border);color:var(--ink);
  font-family:'Baloo Bhaijan 2',sans-serif;font-weight:700;font-size:19px;padding:14px 0;
  border-radius:14px;cursor:pointer;}
.keypad button:active{background:#F3ECD9;}
.login-submit{width:100%;background:var(--orange);color:#fff;font-weight:700;font-size:15px;
  padding:14px;border-radius:14px;border:none;cursor:pointer;}

/* ---------- Dashboard shell ---------- */
#dashboard{width:100%;background:var(--cream);display:flex;flex-wrap:wrap;}
.sidebar{width:220px;background:var(--sidebar);padding:28px 18px;display:flex;flex-direction:column;
  gap:6px;flex-shrink:0;}
.brand{display:flex;align-items:center;gap:10px;padding:0 8px 24px;}
.brand-icon{width:36px;height:36px;border-radius:10px;background:var(--orange);
  display:flex;align-items:center;justify-content:center;font-size:18px;}
.brand-name{font-weight:700;font-size:16px;color:#fff;}
.nav-btn{background:transparent;color:var(--nav-muted);font-weight:400;font-size:14px;
  padding:12px 14px;border-radius:12px;display:flex;align-items:center;gap:10px;border:none;
  text-align:start;cursor:pointer;width:100%;box-sizing:border-box;}
.nav-btn.active{background:var(--orange);color:#fff;font-weight:700;}
.logout-btn{margin-top:auto;background:transparent;border:none;color:var(--nav-muted);
  font-size:14px;padding:12px 14px;display:flex;align-items:center;gap:10px;cursor:pointer;
  text-align:start;width:100%;}
.lang-toggle{background:#fff;border:1px solid var(--border3);color:var(--ink);font-weight:700;
  font-size:13px;padding:8px 14px;border-radius:14px;cursor:pointer;}

.main{flex:1;min-width:640px;padding:36px 40px;}
.main-header{display:flex;align-items:center;justify-content:space-between;flex-wrap:wrap;
  gap:16px;margin-bottom:28px;}
.page-title{font-weight:700;font-size:24px;}
.page-subtitle{font-size:14px;color:var(--muted);margin-top:4px;}
.header-right{display:flex;align-items:center;gap:12px;}
.points-pill{background:#fff;border:1px solid var(--border3);padding:8px 16px;border-radius:14px;
  display:flex;align-items:center;gap:8px;font-weight:700;font-size:15px;}
.level-pill{background:var(--orange);color:#fff;padding:8px 16px;border-radius:14px;
  font-weight:700;font-size:15px;}
.avatar{width:44px;height:44px;border-radius:50%;background:#FFE3CE;display:flex;
  align-items:center;justify-content:center;font-size:20px;}

.card{background:#fff;border-radius:18px;box-shadow:0 8px 20px -12px rgba(0,0,0,.12);}
.section-title{font-weight:700;font-size:16px;margin-bottom:12px;}

/* home page */
.home-grid{display:grid;grid-template-columns:1.4fr 1fr;gap:24px;}
.col{display:flex;flex-direction:column;gap:24px;min-width:0;}
.subjects-grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(130px,1fr));gap:14px;}
.subject-card{padding:18px 14px;border-top:4px solid var(--c);}
.subject-icon{font-size:26px;margin-bottom:8px;}
.subject-name{font-weight:700;font-size:14px;margin-bottom:8px;}
.bar-track{width:100%;height:8px;border-radius:999px;background:var(--border);overflow:hidden;margin-bottom:6px;}
.bar-fill{height:100%;border-radius:999px;}
.subject-pct{font-size:12px;font-weight:700;}

.hw-row{display:flex;align-items:center;gap:14px;padding:14px 18px;border-bottom:1px solid var(--border2);
  flex-wrap:wrap;cursor:pointer;}
.hw-row:last-child{border-bottom:none;}
.hw-icon{width:38px;height:38px;border-radius:10px;display:flex;align-items:center;justify-content:center;
  font-size:17px;flex-shrink:0;}
.hw-info{flex:1;min-width:160px;}
.hw-title{font-weight:700;font-size:14px;}
.hw-meta{font-size:12px;color:var(--muted);}
.hw-status{font-size:12px;font-weight:700;padding:6px 14px;border-radius:999px;color:#fff;}

.xp-card{padding:20px;}
.xp-top{display:flex;justify-content:space-between;align-items:center;margin-bottom:10px;}
.xp-label{font-weight:700;font-size:14px;}
.xp-pct{font-size:12px;font-weight:700;color:var(--orange);}
.streak-line{display:flex;align-items:center;gap:8px;margin-top:14px;font-size:13px;color:var(--muted);}

.badges-card{padding:20px;}
.badges-grid{display:grid;grid-template-columns:repeat(4,1fr);gap:10px;}
.badge{text-align:center;}
.badge-circle{width:44px;height:44px;border-radius:50%;margin:0 auto 4px;display:flex;
  align-items:center;justify-content:center;font-size:18px;background:#FFF3E7;border:2px solid #EED9BE;}
.badge-circle.locked{border-style:dashed;}
.badge-name{font-size:9px;color:var(--muted);}

.messages-card{padding:20px;}
.msg-row{display:flex;gap:10px;}
.msg-row + .msg-row{margin-top:12px;}
.msg-avatar{width:32px;height:32px;border-radius:50%;background:#FFE3CE;display:flex;
  align-items:center;justify-content:center;font-size:14px;flex-shrink:0;}
.msg-name{font-weight:700;font-size:12px;}
.msg-text{font-size:11px;color:var(--muted);margin-top:2px;}
.msg-dot{width:8px;height:8px;border-radius:50%;}
.msg-dot.unread{background:var(--orange);}

/* homework filters */
.filters{display:flex;gap:10px;margin-bottom:18px;flex-wrap:wrap;}
.filter-btn{background:#fff;color:var(--muted);font-weight:500;font-size:13px;padding:8px 16px;
  border-radius:999px;border:1px solid var(--border3);cursor:pointer;}
.filter-btn.active{background:var(--orange);color:#fff;font-weight:700;border:none;}

/* achievements */
.level-track{display:flex;align-items:center;gap:8px;}
.lv-node{display:flex;align-items:center;gap:8px;flex:1;}
.lv-circle{width:40px;height:40px;border-radius:50%;display:flex;align-items:center;justify-content:center;
  font-weight:700;font-size:14px;flex-shrink:0;}
.lv-line{flex:1;height:4px;}
.big-badges-grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(140px,1fr));gap:16px;}
.big-badge{text-align:center;padding:16px 8px;background:var(--cream);border-radius:16px;}
.big-badge-circle{width:56px;height:56px;border-radius:50%;margin:0 auto 8px;display:flex;
  align-items:center;justify-content:center;font-size:24px;background:#FFF3E7;border:2px solid #EED9BE;}
.big-badge-circle.locked{border-style:dashed;}
.big-badge-name{font-size:12px;font-weight:700;margin-bottom:2px;}
.big-badge-desc{font-size:10px;color:var(--muted);}

/* messages full page */
.msg-full-row{display:flex;gap:14px;padding:18px 20px;border-bottom:1px solid var(--border2);}
.msg-full-row:last-child{border-bottom:none;}
.msg-full-avatar{width:40px;height:40px;border-radius:50%;background:#FFE3CE;display:flex;
  align-items:center;justify-content:center;font-size:17px;flex-shrink:0;}
.msg-full-time{font-size:11px;color:#C9BFB0;margin-top:6px;}

/* schedule */
.schedule-grid{display:grid;grid-template-columns:80px repeat(5,1fr);gap:8px;min-width:720px;}
.schedule-day{text-align:center;font-weight:700;font-size:13px;padding:8px 0;}
.schedule-time{display:flex;align-items:center;justify-content:center;font-size:12px;color:var(--muted);font-weight:700;}
.schedule-cell{border-radius:10px;padding:10px 6px;text-align:center;font-size:12px;font-weight:700;
  display:flex;flex-direction:column;align-items:center;gap:2px;background:var(--cream);}
.schedule-cell.filled{background:var(--bg);color:var(--fg);}

/* practice */
.practice-desc{font-size:14px;color:var(--muted);margin-bottom:18px;}
.practice-grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(200px,1fr));gap:16px;}
.practice-card{padding:22px;border-top:4px solid var(--c);cursor:pointer;}
.practice-icon{font-size:30px;margin-bottom:10px;}
.practice-name{font-weight:700;font-size:16px;margin-bottom:6px;}
.practice-count{font-size:12px;color:var(--muted);}

/* profile */
.profile-grid{display:grid;grid-template-columns:1.4fr 1fr;gap:24px;}
.profile-head{padding:24px;display:flex;align-items:center;gap:18px;}
.profile-avatar{width:72px;height:72px;border-radius:50%;background:#FFE3CE;display:flex;
  align-items:center;justify-content:center;font-size:34px;flex-shrink:0;}
.profile-name{font-weight:700;font-size:19px;}
.profile-meta{font-size:13px;color:var(--muted);margin-top:2px;}
.family-card{padding:20px;}
.family-row{display:flex;align-items:center;gap:12px;flex-wrap:wrap;}
.family-text{flex:1;min-width:200px;}
.family-title{font-size:13px;font-weight:500;}
.family-sub{font-size:12px;color:var(--muted);margin-top:2px;}
.family-btn{background:var(--orange);color:#fff;font-weight:700;font-size:13px;padding:10px 16px;
  border-radius:12px;border:none;cursor:pointer;white-space:nowrap;}
.subjects-teacher-card{padding:20px;}
.subject-teacher-row{display:flex;align-items:center;gap:12px;}
.subject-teacher-row + .subject-teacher-row{margin-top:10px;}
.subject-teacher-icon{width:34px;height:34px;border-radius:10px;display:flex;
  align-items:center;justify-content:center;font-size:15px;flex-shrink:0;}
.stats-grid{display:grid;grid-template-columns:repeat(2,1fr);gap:12px;}
.stat-card{padding:16px;text-align:center;}
.stat-value{font-weight:800;font-size:18px;}
.stat-label{font-size:11px;color:var(--muted);}
.settings-card{padding:8px;}
.settings-row{padding:12px 16px;font-size:14px;display:flex;align-items:center;justify-content:space-between;}
.settings-row.bordered{border-bottom:1px solid var(--border2);}
.toggle{width:42px;height:24px;border-radius:999px;border:none;cursor:pointer;padding:2px;
  display:flex;background:var(--border);}
.toggle.on{background:var(--orange);justify-content:flex-start;}
.toggle:not(.on){justify-content:flex-end;}
.toggle-knob{width:20px;height:20px;border-radius:50%;background:#fff;display:block;}

/* ---------- Solve assignment (full screen) ---------- */
#solve-screen{min-height:100vh;width:100%;background:#EAF4FB;display:flex;flex-direction:column;}
.solve-topbar{background:#fff;box-shadow:0 2px 10px rgba(0,0,0,.06);padding:18px 32px;}
.solve-topbar-inner{display:flex;align-items:center;justify-content:space-between;
  gap:16px;flex-wrap:wrap;}
.solve-score{display:flex;align-items:center;gap:6px;color:#22A559;font-weight:700;font-size:16px;}
.solve-timer-wrap{display:flex;align-items:center;gap:8px;background:#F3F7FB;
  border-radius:999px;padding:6px 8px 6px 14px;}
.pause-btn{background:#fff;border:none;width:26px;height:26px;border-radius:50%;cursor:pointer;
  font-size:11px;display:flex;align-items:center;justify-content:center;}
.solve-timer-text{font-weight:700;font-size:14px;}
.solve-center{text-align:center;}
.solve-hw-title{font-weight:700;font-size:17px;}
.solve-q-count{font-size:13px;color:var(--muted);margin-top:2px;}
.solve-cancel{background:none;border:none;color:var(--muted);font-weight:700;font-size:14px;
  cursor:pointer;display:flex;align-items:center;gap:6px;}
.solve-progress-track{width:100%;height:6px;border-radius:999px;background:#EDF2F7;overflow:hidden;margin-top:14px;}
.solve-progress-fill{height:100%;border-radius:999px;background:linear-gradient(90deg,var(--orange),var(--orange-light));}
.solve-content{flex:1;display:flex;align-items:center;justify-content:center;padding:40px 20px;}
.solve-card{background:#fff;border-radius:24px;box-shadow:0 20px 50px -20px rgba(0,0,0,.18);text-align:center;}
.solve-card.completed, .solve-card.paused{padding:48px;max-width:420px;}
.solve-card.question{padding:48px 56px;max-width:640px;width:100%;}
.solve-card.score{padding:48px;max-width:460px;}
.solve-emoji{font-size:44px;margin-bottom:12px;}
.solve-headline{font-weight:700;font-size:20px;margin-bottom:6px;}
.solve-sub{font-size:14px;color:var(--muted);}
.question-text{font-weight:900;font-size:28px;margin-bottom:36px;}
.options-grid{display:grid;grid-template-columns:1fr 1fr;gap:16px;}
.option-btn{font-weight:700;font-size:19px;padding:22px 14px;border-radius:16px;border:2px solid transparent;
  background:#F3F5F7;color:var(--ink);cursor:pointer;transition:all .15s;}
.option-btn.correct{background:#E8F8EF;color:#1C8A4C;border-color:#22A559;cursor:default;}
.option-btn.wrong{background:#FDEEEE;color:#D33333;border-color:#E5484D;cursor:default;}
.option-btn.dim{opacity:.55;cursor:default;}
.resume-btn{background:var(--orange);color:#fff;font-weight:700;font-size:14px;padding:12px 28px;
  border-radius:14px;border:none;cursor:pointer;margin-top:16px;}
.score-headline{font-weight:700;font-size:22px;margin-bottom:8px;}
.score-sub{font-size:15px;color:var(--muted);margin-bottom:8px;}
.score-time{font-size:13px;color:var(--muted);margin-bottom:20px;}
.earned-pill{display:inline-flex;align-items:center;gap:8px;background:#FFF3E7;color:var(--orange);
  font-weight:700;font-size:14px;padding:10px 20px;border-radius:999px;margin-bottom:24px;}
.back-btn{background:var(--orange);color:#fff;font-weight:700;font-size:14px;padding:12px 24px;
  border-radius:14px;border:none;cursor:pointer;}

/* ================= hamburger menu (mobile) ================= */
.menu-toggle{display:none;background:#fff;border:1px solid var(--border3);border-radius:12px;
  width:40px;height:40px;align-items:center;justify-content:center;font-size:18px;cursor:pointer;
  flex-shrink:0;}
.menu-overlay{display:none;position:fixed;inset:0;background:rgba(30,20,10,.45);z-index:55;}
.menu-overlay.open{display:block;}

/* ================= RESPONSIVE ================= */
@media (max-width: 980px){
  #dashboard{flex-direction:column;}
  .menu-toggle{display:flex;}
  .sidebar{
    position:fixed; inset-inline-start:0; top:0; height:100vh; width:260px; max-width:82vw;
    flex-direction:column; align-items:stretch; overflow-y:auto; overflow-x:hidden;
    padding:28px 18px; gap:6px; z-index:60;
    transform:translateX(-100%); transition:transform .25s ease;
  }
  [dir="rtl"] .sidebar{ transform:translateX(100%); }
  .sidebar.open{ transform:translateX(0); }
  .brand{padding:0 8px 24px;}
  .brand-name{white-space:nowrap;}
  .nav-btn, .logout-btn{width:100%;white-space:nowrap;}
  .logout-btn{margin-top:auto;margin-inline-start:0;}
  .main{min-width:0;padding:24px 20px;}
  .home-grid, .profile-grid{grid-template-columns:1fr;}
}

@media (max-width: 640px){
  .main{padding:16px;}
  .main-header{flex-wrap:wrap;align-items:flex-start;gap:12px;}
  .header-right{width:100%;justify-content:space-between;}
  .page-title{font-size:20px;}
  .subjects-grid{grid-template-columns:repeat(2,1fr);}
  .badges-grid{grid-template-columns:repeat(4,1fr);}
  .stats-grid{grid-template-columns:repeat(2,1fr);}
  .login-card{padding:28px 22px;}
  .options-grid{grid-template-columns:1fr;}
  .solve-card.question{padding:28px 20px;}
  .question-text{font-size:22px;margin-bottom:24px;}
  .solve-topbar{padding:14px 16px;}
  .solve-center{order:3;width:100%;text-align:center;}
  .solve-content{padding:20px 14px;}
  .hw-row{padding:12px 14px;}
  .hw-info{min-width:120px;}
}

@media (max-width: 420px){
  .subjects-grid{grid-template-columns:1fr 1fr;}
  .badges-grid{grid-template-columns:repeat(3,1fr);}
  .stats-grid{grid-template-columns:1fr 1fr;}
}
