:root {
  color-scheme: light;
  --paper: #f5ead8;
  --paper-2: #efe0c8;
  --card: #fbf7ef;
  --card-strong: #fffdf8;
  --ink: #231f1b;
  --muted: #746b5e;
  --line: #d8c9b4;
  --orange: #c67139;
  --orange-dark: #934d21;
  --orange-soft: #f7ddca;
  --olive: #7a8a5e;
  --olive-dark: #56633f;
  --olive-soft: #e1e8d4;
  --danger: #a4473f;
  --danger-soft: #f7e4e0;
  --shadow-sm: 0 2px 8px rgba(76, 55, 34, .08);
  --shadow-md: 0 14px 34px rgba(76, 55, 34, .12);
  --r-sm: 12px;
  --r-md: 20px;
  --r-lg: 30px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-height: 100vh;
  font-family: "Tajawal", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background-color: var(--paper);
  background-image:
    repeating-linear-gradient(0deg, transparent 0 31px, rgba(165, 135, 93, .085) 31px 32px),
    linear-gradient(90deg, rgba(198, 113, 57, .055), transparent 20%, transparent 80%, rgba(122, 138, 94, .05));
}
button, input, select, textarea { font: inherit; }
a { color: inherit; }
img { max-width: 100%; display: block; }
h1, h2, h3, .display-title, .brand-title {
  font-family: "Baloo Bhaijaan 2", "Tajawal", sans-serif;
}

/* Shared */
.page-wrap { width: min(1180px, calc(100% - 40px)); margin: 0 auto; }
.page-wrap.narrow { width: min(720px, calc(100% - 32px)); }
.section-gap { display: grid; gap: 18px; }
.muted { color: var(--muted); }
.text-center { text-align: center; }
.text-start { text-align: start; }
.ltr { direction: ltr; unicode-bidi: embed; }
.hidden { display: none !important; }

.brand-logo { width: 150px; height: auto; }
.brand-logo.small { width: 118px; }
.brand-mark { width: 52px; height: 52px; object-fit: contain; }

.panel {
  background: rgba(251, 247, 239, .94);
  border: 1px solid rgba(216, 201, 180, .92);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
  padding: 24px;
}
.panel.soft { background: rgba(239, 224, 200, .72); }
.panel.white { background: rgba(255, 253, 248, .96); }
.panel.compact { padding: 18px; border-radius: var(--r-md); }

.display-title { margin: 0; font-size: clamp(1.65rem, 3vw, 2.45rem); line-height: 1.25; }
.section-title { margin: 0; font-size: 1.25rem; line-height: 1.35; }
.section-subtitle { margin: 5px 0 0; color: var(--muted); line-height: 1.75; }
.eyebrow { color: var(--orange-dark); font-weight: 800; font-size: .82rem; letter-spacing: .01em; }

.btn {
  appearance: none;
  border: 0;
  min-height: 48px;
  padding: 12px 22px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  text-decoration: none;
  cursor: pointer;
  font-weight: 800;
  transition: transform .16s ease, box-shadow .16s ease, background .16s ease;
}
.btn:hover { transform: translateY(-1px); }
.btn-primary { background: var(--orange); color: #fff; box-shadow: 0 8px 20px rgba(198, 113, 57, .22); }
.btn-primary:hover { background: var(--orange-dark); }
.btn-secondary { background: var(--card-strong); color: var(--ink); border: 1px solid var(--line); }
.btn-olive { background: var(--olive); color: #fff; }
.btn-block { width: 100%; }
.btn svg { width: 20px; height: 20px; flex: 0 0 auto; }

.field { display: grid; gap: 7px; }
.field + .field { margin-top: 14px; }
.field label { font-size: .88rem; color: var(--muted); font-weight: 800; }
.input, .select {
  width: 100%;
  min-height: 50px;
  border: 1.5px solid var(--line);
  background: var(--card-strong);
  color: var(--ink);
  border-radius: 14px;
  padding: 11px 14px;
  outline: none;
  transition: border-color .16s ease, box-shadow .16s ease;
}
.input:focus, .select:focus { border-color: var(--orange); box-shadow: 0 0 0 4px rgba(198, 113, 57, .12); }
.form-actions { margin-top: 18px; display: flex; gap: 10px; flex-wrap: wrap; }

.notice { border-radius: 16px; padding: 14px 16px; line-height: 1.7; border: 1px solid transparent; }
.notice-success { background: var(--olive-soft); color: var(--olive-dark); border-color: rgba(122,138,94,.25); }
.notice-warning { background: var(--orange-soft); color: var(--orange-dark); border-color: rgba(198,113,57,.22); }
.notice-danger { background: var(--danger-soft); color: var(--danger); border-color: rgba(164,71,63,.18); }

.badge { display: inline-flex; align-items: center; gap: 5px; padding: 5px 10px; border-radius: 999px; font-size: .75rem; font-weight: 800; }
.badge-olive { background: var(--olive-soft); color: var(--olive-dark); }
.badge-orange { background: var(--orange-soft); color: var(--orange-dark); }
.badge-neutral { background: #eee6d8; color: var(--muted); }

.progress { width: 100%; height: 8px; background: #e6dac9; border-radius: 999px; overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--olive); border-radius: inherit; }

/* Auth / onboarding */
.auth-page { min-height: 100vh; display: grid; place-items: center; padding: 34px 20px; }
.auth-shell { width: min(1040px, 100%); display: grid; grid-template-columns: 1fr 440px; gap: 28px; align-items: stretch; }
.auth-intro, .auth-card { min-height: 520px; }
.auth-intro {
  padding: 46px;
  border-radius: 38px;
  background: linear-gradient(145deg, rgba(235, 221, 197, .96), rgba(247, 232, 213, .9));
  border: 1px solid rgba(216, 201, 180, .9);
  display: flex;
  flex-direction: column;
  justify-content: center;
  box-shadow: var(--shadow-md);
}
.auth-intro .brand-logo { width: 205px; margin-bottom: 24px; }
.auth-intro h1 { margin: 0 0 10px; font-size: clamp(1.9rem, 4vw, 3rem); line-height: 1.2; }
.auth-intro p { color: var(--muted); font-size: 1.02rem; line-height: 1.95; max-width: 520px; }
.auth-tags { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 16px; }
.auth-card {
  background: rgba(255, 253, 248, .97);
  border-radius: 38px;
  border: 1px solid rgba(216, 201, 180, .95);
  padding: 38px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  box-shadow: var(--shadow-md);
}
.auth-card .brand-logo.mobile-only { display: none; width: 150px; margin: 0 auto 20px; }
.google-btn {
  width: 100%;
  min-height: 54px;
  background: #fff;
  border: 1.5px solid #ded6c8;
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 11px;
  text-decoration: none;
  font-weight: 800;
  box-shadow: 0 3px 10px rgba(60,50,35,.06);
}
.google-btn:hover { border-color: #c9b89e; }
.or-row { display: grid; grid-template-columns: 1fr auto 1fr; gap: 12px; align-items: center; color: var(--muted); margin: 21px 0; font-size: .84rem; }
.or-row::before, .or-row::after { content: ""; height: 1px; background: var(--line); }
.student-entry {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 15px;
  border-radius: 16px;
  background: var(--olive-soft);
  color: var(--olive-dark);
  text-decoration: none;
}
.student-entry .icon-circle { width: 42px; height: 42px; border-radius: 50%; background: rgba(255,255,255,.66); display: grid; place-items: center; }
.student-entry strong { display: block; }
.student-entry small { display: block; color: var(--muted); margin-top: 2px; }
.privacy-note { font-size: .78rem; color: var(--muted); margin: 18px 0 0; line-height: 1.7; }
.admin-login-link { margin-top: 14px; text-align: center; font-size: .78rem; color: var(--muted); }
.admin-login-link a { text-decoration: none; }

.account-chip { display: flex; align-items: center; gap: 12px; margin-bottom: 22px; }
.avatar { width: 48px; height: 48px; border-radius: 50%; background: var(--orange-soft); color: var(--orange-dark); display: grid; place-items: center; font-weight: 900; flex: 0 0 auto; }
.avatar.olive { background: var(--olive-soft); color: var(--olive-dark); }
.account-chip strong { display: block; }
.account-chip small { color: var(--muted); }

.role-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin: 22px 0; }
.role-option { position: relative; display: block; cursor: pointer; }
.role-option input { position: absolute; opacity: 0; pointer-events: none; }
.role-card {
  min-height: 190px;
  border: 2px solid var(--line);
  border-radius: 22px;
  background: var(--card-strong);
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  transition: border-color .16s ease, transform .16s ease, box-shadow .16s ease;
}
.role-option:hover .role-card { transform: translateY(-2px); box-shadow: var(--shadow-sm); }
.role-option input:checked + .role-card { border-color: var(--orange); box-shadow: 0 0 0 4px rgba(198,113,57,.10); }
.role-option.olive input:checked + .role-card { border-color: var(--olive); box-shadow: 0 0 0 4px rgba(122,138,94,.10); }
.role-icon { width: 52px; height: 52px; border-radius: 16px; display: grid; place-items: center; background: var(--orange-soft); color: var(--orange-dark); }
.role-option.olive .role-icon { background: var(--olive-soft); color: var(--olive-dark); }
.role-card strong { font-size: 1.1rem; }
.role-card p { margin: 0; color: var(--muted); line-height: 1.65; font-size: .9rem; }

.pending-hero { text-align: center; padding: 42px 28px; }
.pending-icon { width: 74px; height: 74px; margin: 0 auto 18px; border-radius: 24px; display: grid; place-items: center; background: var(--olive-soft); color: var(--olive-dark); }
.pending-icon.danger { background: var(--danger-soft); color: var(--danger); }
.timeline { display: grid; gap: 0; margin-top: 10px; }
.timeline-row { display: grid; grid-template-columns: 38px 1fr; gap: 12px; position: relative; padding-bottom: 20px; }
.timeline-row:not(:last-child)::before { content: ""; position: absolute; right: 18px; top: 34px; bottom: -1px; width: 2px; background: var(--line); }
.timeline-dot { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; background: var(--card-strong); border: 2px solid var(--line); color: var(--muted); z-index: 1; }
.timeline-row.done .timeline-dot { background: var(--olive); color: #fff; border-color: var(--olive); }
.timeline-row.current .timeline-dot { background: var(--orange); color: #fff; border-color: var(--orange); }
.timeline-row strong { display: block; margin-top: 2px; }
.timeline-row small { color: var(--muted); }

/* App layout */
.app-page { min-height: 100vh; }
.app-shell { display: grid; grid-template-columns: 252px minmax(0, 1fr); min-height: 100vh; }
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 26px 18px;
  background: rgba(235, 221, 197, .94);
  border-inline-end: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 20px;
}
.sidebar .brand-logo { width: 145px; margin: 0 auto 8px; }
.sidebar-user { display: flex; align-items: center; gap: 10px; padding: 11px; border-radius: 16px; background: rgba(255,253,248,.55); }
.sidebar-user .avatar { width: 40px; height: 40px; }
.sidebar-user strong { display: block; font-size: .9rem; }
.sidebar-user small { color: var(--muted); font-size: .74rem; }
.side-nav { display: grid; gap: 7px; }
.side-nav a, .side-nav button {
  width: 100%;
  min-height: 44px;
  border: 0;
  background: transparent;
  border-radius: 14px;
  padding: 10px 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  text-decoration: none;
  font-weight: 800;
  cursor: pointer;
}
.side-nav a.active, .side-nav a:hover, .side-nav button:hover { background: var(--card-strong); color: var(--orange-dark); }
.sidebar-bottom { margin-top: auto; }
.sidebar-bottom form { margin: 0; }

.app-main { padding: 34px clamp(22px, 4vw, 58px) 60px; min-width: 0; }
.app-content { width: min(1060px, 100%); margin: 0 auto; }
.mobile-topbar { display: none; }
.page-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; margin-bottom: 22px; }
.page-heading h1 { margin: 0; font-size: clamp(1.65rem, 2.7vw, 2.25rem); }
.page-heading p { margin: 4px 0 0; color: var(--muted); }

.goal-box { display: grid; grid-template-columns: 1fr auto; gap: 10px; align-items: end; }
.goal-box .field { margin: 0; }

.subject-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.subject-card {
  min-height: 176px;
  padding: 18px;
  background: rgba(255,253,248,.95);
  border: 1px solid var(--line);
  border-radius: 22px;
  text-decoration: none;
  display: flex;
  flex-direction: column;
  gap: 14px;
  box-shadow: var(--shadow-sm);
  transition: transform .16s ease, box-shadow .16s ease;
}
a.subject-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); }
.subject-card.locked { opacity: .72; }
.subject-icon-wrap { width: 50px; height: 50px; border-radius: 16px; display: grid; place-items: center; background: var(--orange-soft); }
.subject-card:nth-child(even) .subject-icon-wrap { background: var(--olive-soft); }
.subject-card h3 { margin: 0; font-size: 1.06rem; }
.subject-card p { margin: 3px 0 0; color: var(--muted); font-size: .82rem; line-height: 1.55; }
.subject-card .progress { margin-top: auto; }

.unit-list { display: grid; gap: 16px; }
.lesson-list { display: grid; gap: 9px; }
.lesson-link, .lesson-static {
  min-height: 58px;
  border-radius: 15px;
  padding: 14px 16px;
  background: var(--card-strong);
  border: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  text-decoration: none;
  font-weight: 800;
}
.lesson-link:hover { border-color: var(--orange); }
.lesson-static { opacity: .7; }

.lesson-head { display: grid; grid-template-columns: 1fr auto; gap: 16px; align-items: start; }
.back-link { display: inline-flex; align-items: center; gap: 7px; color: var(--orange-dark); font-weight: 800; text-decoration: none; margin-bottom: 13px; }
.explanation-box { margin-top: 18px; padding: 20px; border-radius: 18px; background: var(--olive-soft); color: var(--olive-dark); line-height: 1.95; }
.qa-list { display: grid; gap: 10px; }
.qa-card { border: 1px solid var(--line); background: var(--card-strong); border-radius: 18px; padding: 17px; }
.qa-question { display: flex; gap: 10px; font-weight: 800; }
.qa-number { width: 30px; height: 30px; border-radius: 50%; background: var(--orange-soft); color: var(--orange-dark); display: grid; place-items: center; flex: 0 0 auto; }
.qa-answer { padding-inline-start: 40px; color: var(--muted); margin-top: 7px; line-height: 1.75; }

.student-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.student-card { padding: 20px; border-radius: 22px; background: rgba(255,253,248,.95); border: 1px solid var(--line); box-shadow: var(--shadow-sm); }
.student-head { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.student-head h2 { margin: 0; font-size: 1.1rem; }
.student-head p { margin: 2px 0 0; color: var(--muted); font-size: .83rem; }
.subject-progress-list { display: grid; gap: 13px; }
.subject-progress-row { display: grid; grid-template-columns: 38px 1fr; gap: 10px; align-items: center; }
.subject-progress-copy { min-width: 0; }
.subject-progress-meta { display: flex; justify-content: space-between; gap: 8px; margin-bottom: 5px; font-size: .8rem; }
.copy-field { display: grid; grid-template-columns: 1fr auto; gap: 8px; margin-top: 16px; }
.copy-field .input { direction: ltr; text-align: left; font-size: .78rem; min-width: 0; }

.teacher-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap; }
.pills { display: flex; flex-wrap: wrap; gap: 8px; }
.pill { padding: 9px 14px; border-radius: 999px; background: var(--card-strong); border: 1px solid var(--line); color: var(--muted); text-decoration: none; font-weight: 800; font-size: .82rem; }
.pill.active { background: var(--orange); color: #fff; border-color: var(--orange); }
.teacher-lessons { display: grid; gap: 10px; }
.teacher-lesson { border: 1px solid var(--line); border-radius: 18px; background: var(--card-strong); padding: 17px; }
.teacher-lesson-head { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }
.teacher-lesson h3 { margin: 0; font-size: 1rem; }
.teacher-lesson p { margin: 3px 0 0; color: var(--muted); font-size: .82rem; }
.teacher-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.teacher-actions form { margin: 0; }
.teacher-actions .btn { min-height: 40px; padding: 8px 13px; font-size: .78rem; }
.stat-row { display: flex; align-items: baseline; gap: 9px; }
.stat-number { font-family: "Baloo Bhaijaan 2", "Tajawal", sans-serif; color: var(--orange-dark); font-size: 2.1rem; font-weight: 800; }

.request-list { margin: 15px 0 0; padding: 0; list-style: none; display: grid; gap: 8px; }
.request-list li { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.request-list li:last-child { border-bottom: 0; }

/* Responsive */
@media (max-width: 1080px) {
  .subject-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .student-grid { grid-template-columns: 1fr; }
}

@media (max-width: 820px) {
  body { background-image: repeating-linear-gradient(0deg, transparent 0 31px, rgba(165,135,93,.075) 31px 32px); }
  .auth-page { padding: 18px 14px; align-items: start; }
  .auth-shell { display: block; width: min(520px, 100%); }
  .auth-intro { display: none; }
  .auth-card { min-height: auto; border-radius: 28px; padding: 26px 20px; margin-top: 22px; }
  .auth-card .brand-logo.mobile-only { display: block; }
  .role-grid { grid-template-columns: 1fr; }
  .role-card { min-height: 136px; }

  .app-shell { display: block; }
  .sidebar { display: none; }
  .mobile-topbar {
    display: flex;
    position: sticky;
    top: 0;
    z-index: 20;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    min-height: 70px;
    padding: 10px 16px;
    background: rgba(245,234,216,.92);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid rgba(216,201,180,.85);
  }
  .mobile-topbar .brand-logo { width: 112px; }
  .mobile-user { display: flex; align-items: center; gap: 8px; }
  .mobile-user .avatar { width: 38px; height: 38px; }
  .app-main { padding: 22px 16px 44px; }
  .page-heading { display: block; }
  .page-heading .badge { margin-top: 10px; }
  .subject-grid { grid-template-columns: 1fr; }
  .subject-card { min-height: 150px; }
  .goal-box { grid-template-columns: 1fr; }
  .goal-box .btn { width: 100%; }
  .lesson-head { grid-template-columns: 1fr; }
  .copy-field { grid-template-columns: 1fr; }
  .copy-field .btn { width: 100%; }
}

@media (max-width: 480px) {
  .panel { padding: 19px; border-radius: 22px; }
  .auth-card { margin-top: 6px; box-shadow: none; }
  .display-title { font-size: 1.7rem; }
  .student-entry { align-items: flex-start; }
  .teacher-toolbar { display: grid; }
  .pills { overflow-x: auto; flex-wrap: nowrap; padding-bottom: 4px; }
  .pill { white-space: nowrap; }
  .form-actions .btn { width: 100%; }
}
