/* USTAZ Aqeedah Platform — Official Identity (Forest Green #0f5c52, Gold #c8a25a, Stone #fafaf9) */
:root {
  --green-900: #0b3f38;
  --green: #0f5c52;
  --green-300: #6ee7d5;
  --gold: #c8a25a;
  --gold-light: #fef8eb;
  --s50: #fafaf9;
  --s100: #f5f5f4;
  --s200: #e7e5e4;
  --s300: #d6d3d1;
  --s400: #a8a29e;
  --s500: #78716c;
  --s600: #57534e;
  --s700: #44403c;
  --s800: #292524;
  --s900: #1c1917;
  --ok: #0f5c52;
  --bad: #b91c1c;
  --font-ui: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-display: 'Lora', Georgia, 'Amiri', serif;
  --font-ar: 'Amiri', 'Traditional Arabic', serif;
  --safe-b: env(safe-area-inset-bottom, 0px);
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0;
  min-height: 100dvh;
  background: var(--s50);
  color: var(--s700);
  font-family: var(--font-ui);
  font-size: 15px;
  line-height: 1.7;
  -webkit-tap-highlight-color: transparent;
  overflow-wrap: anywhere;
}
body.no-scroll { overflow: hidden; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--green); outline-offset: 2px; border-radius: 6px; }

.ar, .ar-sub { font-family: var(--font-ar); }
.en-main { display: block; font-family: var(--font-ui); line-height: 1.6; }
.ar-sub { display: block; margin-top: .25rem; color: var(--s500); font-size: .95em; }

/* Sticky Top Navigation */
.top {
  position: sticky;
  top: 0;
  z-index: 30;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--s200);
}
.top-in {
  max-width: 56rem;
  margin: 0 auto;
  padding: .65rem 1rem;
  display: flex;
  align-items: center;
  gap: .75rem;
}
.brand {
  display: flex;
  align-items: center;
  gap: .65rem;
  min-width: 0;
}
.mark {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  background: #fff;
  object-fit: contain;
  padding: 2px;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .08);
  flex: none;
}
.brand-t { line-height: 1.15; min-width: 0; }
.wordmark {
  display: block;
  font-family: 'Lora', Georgia, serif;
  font-weight: 700;
  letter-spacing: .06em;
  font-size: 1.05rem;
  color: var(--green-900);
}
.brand-sub {
  display: block;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .08em;
  color: var(--s400);
  white-space: nowrap;
}
.top-sp { flex: 1; }
.user-chip {
  font-size: .8rem;
  color: var(--s600);
  display: flex;
  align-items: center;
  gap: .5rem;
  white-space: nowrap;
}
.link {
  background: none;
  border: 0;
  padding: 0;
  color: var(--green);
  text-decoration: underline;
  font-size: inherit;
  cursor: pointer;
}
.lang {
  min-width: 44px;
  min-height: 36px;
  padding: 0 .75rem;
  border: 1px solid var(--s300);
  background: #fff;
  border-radius: .5rem;
  font-weight: 600;
  font-size: .82rem;
  color: var(--s700);
  transition: all .15s;
}
.lang:hover { border-color: var(--green); color: var(--green); }

/* Owner Admin Bar */
.admin-bar {
  background: #064e3b;
  color: #ecfdf5;
  border-bottom: 1px solid #047857;
  padding: .5rem 1rem;
  font-size: .85rem;
}
.admin-bar-in {
  max-width: 56rem;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: .6rem;
}
.admin-badge {
  background: #047857;
  color: #a7f3d0;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: .78rem;
}
.admin-actions {
  display: flex;
  gap: .5rem;
  align-items: center;
  flex-wrap: wrap;
}
.btn-adm {
  background: rgba(255, 255, 255, 0.15);
  border: 1px solid rgba(255, 255, 255, 0.3);
  color: #fff;
  padding: 4px 10px;
  border-radius: 6px;
  font-size: .78rem;
  font-weight: 600;
  cursor: pointer;
}
.btn-adm:hover { background: rgba(255, 255, 255, 0.25); }

/* Main Container */
main#view {
  max-width: 56rem;
  margin: 0 auto;
  padding: 1.25rem 1rem calc(6.5rem + var(--safe-b));
  min-height: 60dvh;
}
.foot {
  max-width: 56rem;
  margin: 0 auto;
  padding: 0 1rem calc(2rem + var(--safe-b));
  text-align: center;
  font-size: 11px;
  color: var(--s400);
}
.foot a { text-decoration: underline; }

/* General UI Components */
.h1 { font-size: 1.55rem; line-height: 1.35; margin: .25rem 0 .5rem; color: var(--s900); font-weight: 700; }
.display { font-family: var(--font-display); }
.h2 { font-size: 1.25rem; margin: 0 0 .5rem; color: var(--s900); font-family: var(--font-display); }
.h3 { font-size: 1rem; margin: 1rem 0 .35rem; color: var(--green); font-family: var(--font-display); }
.lead { color: var(--s600); max-width: 60ch; margin: .25rem 0 1rem; line-height: 1.75; }
.label { font-size: 10px; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; color: var(--s400); }
.sect { margin: 1.75rem 0 .5rem; }
.meta { font-size: .8rem; color: var(--s500); }
.clip { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 65vw; }
.tip { margin-top: 1.25rem; font-size: .82rem; color: var(--s400); text-align: center; }
.empty, .loading { text-align: center; color: var(--s500); padding: 2.5rem 0; font-size: 1.05rem; }

.badge {
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  font-size: 12px;
  font-weight: 600;
  padding: 5px 14px;
  border-radius: 999px;
  border: 1px solid rgba(15, 92, 82, .2);
  background: rgba(15, 92, 82, .05);
  color: var(--green);
}
.dot { width: 6px; height: 6px; border-radius: 999px; background: var(--green); }
.tag {
  display: inline-block;
  font-size: 11px;
  color: var(--s500);
  background: var(--s100);
  border-radius: 999px;
  padding: 3px 12px;
}
.tag.gold { background: rgba(200, 162, 90, .14); color: #7a5a1a; font-weight: 600; }

.card {
  border: 1px solid var(--s200);
  border-radius: .95rem;
  background: #fff;
  padding: 1.35rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .03);
}
.card.narrow { max-width: 28rem; margin: 1rem auto; }
.center { text-align: center; }
.big-n { font-family: var(--font-display); font-size: 2.3rem; color: var(--green); margin: .25rem 0 1rem; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .4rem;
  min-height: 44px;
  padding: .5rem 1.15rem;
  border-radius: .6rem;
  border: 1px solid transparent;
  font-weight: 600;
  font-size: .92rem;
  background: transparent;
  transition: all .15s;
  text-align: center;
}
.btn.primary { background: var(--green); color: #fff; }
.btn.primary:hover { background: var(--green-900); }
.btn.ghost { border-color: var(--s300); color: var(--s700); background: #fff; }
.btn.ghost:hover { border-color: var(--green); color: var(--green); }
.btn.block { display: flex; width: 100%; margin-top: .6rem; }
.btn.small { min-height: 38px; padding: .25rem .75rem; font-size: .84rem; }
.btn[disabled], .btn[aria-disabled="true"] { opacity: .4; pointer-events: none; }
.btn.again { background: rgba(185, 28, 28, .07); border-color: rgba(185, 28, 28, .25); color: var(--bad); font-weight: 700; }
.btn.got { background: rgba(15, 92, 82, .08); border-color: rgba(15, 92, 82, .28); color: var(--green); font-weight: 700; }

.icon {
  min-width: 42px;
  min-height: 42px;
  border: 0;
  background: transparent;
  border-radius: .5rem;
  font-size: 1rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.icon:hover { background: var(--s100); }
.chip {
  border: 1px solid var(--s300);
  background: #fff;
  border-radius: 999px;
  padding: .25rem .8rem;
  font-size: .82rem;
  color: var(--green);
  min-height: 32px;
}
.chip:hover { border-color: var(--green); }
.progress { height: 6px; background: var(--s200); border-radius: 999px; overflow: hidden; flex: 1; }
.progress-fill { height: 100%; background: var(--green); border-radius: 999px; transition: width .25s ease; }
.back { display: inline-flex; align-items: center; gap: .4rem; font-size: .88rem; color: var(--s500); min-height: 44px; }
.back:hover { color: var(--green); }
.row-between { display: flex; justify-content: space-between; gap: .5rem; }

/* Home Hero with Signature Ustaz Pattern */
.hero {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--s200);
  border-radius: 1.1rem;
  background: #fff;
  box-shadow: 0 4px 20px -8px rgba(15, 92, 82, .15);
}
.hero .pattern {
  position: absolute;
  inset: 0;
  background-image: radial-gradient(circle at 1px 1px, rgba(15, 92, 82, .14) 1px, transparent 0);
  background-size: 22px 22px;
  -webkit-mask-image: linear-gradient(to bottom left, black, transparent 65%);
  mask-image: linear-gradient(to bottom left, black, transparent 65%);
  opacity: .75;
  pointer-events: none;
}
.hero-in { position: relative; padding: 1.8rem 1.4rem; }
.hero .h1 { font-size: 2rem; margin-top: .85rem; color: var(--s900); }

/* Continue Card */
.cont {
  display: flex;
  flex-direction: column;
  gap: .2rem;
  margin-top: 1.25rem;
  padding: 1rem 1.25rem;
  border: 1px solid var(--green);
  border-radius: .95rem;
  background: rgba(15, 92, 82, .05);
}
.cont-title { font-weight: 700; color: var(--green); font-size: 1.05rem; }

/* Book Selection Cards */
.books { display: grid; gap: 1rem; }
.book {
  display: block;
  border: 1px solid var(--s200);
  border-radius: 1rem;
  background: #fff;
  padding: 1.4rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .03), 0 14px 34px -22px rgba(15, 92, 82, .25);
  transition: all .2s;
}
.book:hover { border-color: var(--green); transform: translateY(-2px); }
.book:active { transform: scale(.995); }
.book-title {
  font-family: var(--font-display);
  font-size: 1.35rem;
  margin: .65rem 0 .15rem;
  color: var(--green-900);
}
.book-author { margin: 0; color: var(--s600); font-size: .92rem; }
.book-blurb { margin: .5rem 0 1rem; color: var(--s500); font-size: .88rem; line-height: 1.6; }
.book-foot { display: flex; align-items: center; gap: .85rem; }

/* Horizontal Track Filter Pills */
.pills {
  display: flex;
  gap: .5rem;
  overflow-x: auto;
  padding: .25rem 0 .6rem;
  margin: 0 -1rem;
  padding-inline: 1rem;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.pills::-webkit-scrollbar { display: none; }
.pill {
  flex: none;
  border: 1px solid var(--s200);
  background: #fff;
  border-radius: 999px;
  padding: .45rem 1rem;
  font-size: .84rem;
  color: var(--s600);
  min-height: 40px;
  white-space: nowrap;
}
.pill:hover { border-color: var(--green); color: var(--green); }
.pill[aria-pressed="true"] {
  background: var(--green);
  border-color: var(--green);
  color: #fff;
  font-weight: 700;
}

/* Sessions List */
.searchbox { margin: .25rem 0 .85rem; }
.inp {
  width: 100%;
  min-height: 46px;
  border: 1px solid var(--s300);
  background: #fff;
  border-radius: .65rem;
  padding: .5rem .9rem;
}
.inp:focus {
  border-color: var(--green);
  outline: none;
  box-shadow: 0 0 0 3px rgba(15, 92, 82, .12);
}
.list { display: flex; flex-direction: column; gap: .6rem; }
.row {
  display: flex;
  align-items: center;
  gap: .95rem;
  border: 1px solid var(--s200);
  background: #fff;
  border-radius: .95rem;
  padding: .9rem 1.15rem;
  min-height: 68px;
  transition: border-color .15s;
}
.row:hover { border-color: var(--green); }
.row.is-locked { opacity: .55; }
.row.is-done {
  border-color: rgba(15, 92, 82, .35);
  background: rgba(15, 92, 82, .03);
}
.num {
  flex: none;
  width: 2.6rem;
  height: 2.6rem;
  display: grid;
  place-items: center;
  border-radius: .65rem;
  background: var(--s100);
  color: var(--gold);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1rem;
}
.is-done .num { background: var(--green); color: #fff; }
.row-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: .15rem; }
.row-title {
  font-weight: 700;
  color: var(--s900);
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.row-meta { font-size: .78rem; color: var(--s500); }
.row-state { flex: none; color: var(--green); font-weight: 700; }

/* Sticky Sub-Tabs */
.tabs-wrap {
  position: sticky;
  top: 53px;
  z-index: 20;
  background: var(--s50);
  margin: 0 -1rem;
  padding: .45rem 1rem;
  border-bottom: 1px solid var(--s200);
}
.tabs {
  display: flex;
  gap: .4rem;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  flex: none;
  min-height: 42px;
  padding: .4rem 1.05rem;
  border: 1px solid var(--s200);
  background: #fff;
  border-radius: 999px;
  font-size: .88rem;
  color: var(--s600);
  white-space: nowrap;
}
.tab[aria-selected="true"] {
  background: var(--green);
  border-color: var(--green);
  color: #fff;
  font-weight: 700;
}
.tab.ask {
  border-color: var(--gold);
  color: #7a5a1a;
  background: rgba(200, 162, 90, .14);
}
.s-body { padding-top: 1.15rem; }

/* Bottom Mobile Action Bar */
.bar {
  position: fixed;
  inset-inline: 0;
  bottom: 0;
  z-index: 25;
  display: flex;
  gap: .5rem;
  justify-content: center;
  align-items: center;
  padding: .65rem 1rem calc(.65rem + var(--safe-b));
  background: rgba(255, 255, 255, .95);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-top: 1px solid var(--s200);
}
.bar .btn { flex: 1; max-width: 14rem; padding-inline: .5rem; }
.bar .btn.primary, .bar #btn-done { flex: 1.4; }

/* Corrected Clean Text Reader */
.tools { display: flex; flex-direction: column; gap: .6rem; margin-bottom: .85rem; }
.tools-row { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.tools-row .inp[type=search] { flex: 1; min-width: 0; }
.inp.small { min-height: 38px; width: auto; max-width: 50vw; padding: .25rem .6rem; font-size: .85rem; }

.matn-card {
  border: 1px solid var(--green);
  background: rgba(15, 92, 82, .04);
  border-radius: .95rem;
  padding: 1.1rem 1.25rem;
  margin-bottom: 1rem;
}
.matn-card .matn-h {
  font-size: .85rem;
  font-weight: 700;
  letter-spacing: .08em;
  color: var(--green);
  text-transform: uppercase;
  margin-bottom: .5rem;
}
.matn-card .ar {
  font-size: 1.35rem;
  line-height: 2.15;
  color: var(--green-900);
  font-family: var(--font-ar);
}

.pg {
  border: 1px solid var(--s200);
  background: #fff;
  border-radius: .95rem;
  margin-bottom: .85rem;
  scroll-margin-top: 7rem;
  transition: box-shadow .3s, border-color .3s;
}
.pg.flash { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(200, 162, 90, .35); }
.pg-h {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: .25rem .6rem .25rem 1.1rem;
  border-bottom: 1px solid var(--s100);
  min-height: 44px;
}
.pn { font-size: .82rem; font-weight: 700; color: var(--gold); letter-spacing: .04em; }
.acts { display: flex; }
.pg-b {
  padding: .85rem 1.25rem 1.25rem;
  font-family: var(--font-ar);
  direction: rtl;
  text-align: justify;
  line-height: 2.2;
  color: var(--s800);
}
.pg-b p { margin: 0 0 1em; }
mark { background: rgba(200, 162, 90, .4); color: inherit; padding: 0 .1em; border-radius: 3px; }

/* Interactive Lessons */
.acc { display: flex; flex-direction: column; gap: .75rem; }
.lesson { border: 1px solid var(--s200); background: #fff; border-radius: .95rem; }
.lesson > summary {
  display: flex;
  flex-direction: column;
  gap: .2rem;
  padding: .95rem 1.15rem;
  cursor: pointer;
  font-weight: 700;
  color: var(--s900);
  min-height: 52px;
}
.lb { padding: 0 1.15rem 1.15rem; }
.body { line-height: 2; margin: .35rem 0; font-size: 1.05rem; }
.kp { padding-inline-start: 1.2rem; margin: .35rem 0 .85rem; }
.kp li { margin-bottom: .5rem; line-height: 1.85; }
.adv { border-top: 1px dashed var(--s200); margin-top: .85rem; padding-top: .6rem; }
.adv > summary { color: var(--green); cursor: pointer; font-weight: 700; min-height: 40px; display: flex; align-items: center; }

/* Glossary */
.gl { margin: .85rem 0 0; display: flex; flex-direction: column; gap: .75rem; }
.gl-i { border: 1px solid var(--s200); background: #fff; border-radius: .85rem; padding: .95rem 1.15rem; }
.gl dt { font-weight: 700; color: var(--green-900); display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; font-size: 1.05rem; }
.gl dd { margin: .4rem 0 0; color: var(--s700); line-height: 1.8; }

/* Flashcards 3D Engine */
.scene { perspective: 1200px; margin: .85rem 0 1.15rem; }
.fc {
  position: relative;
  min-height: 16rem;
  transform-style: preserve-3d;
  transition: transform .55s cubic-bezier(.2, .8, .2, 1);
  cursor: pointer;
}
.fc.flipped { transform: rotateY(180deg); }
.face {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: .75rem;
  padding: 1.75rem 1.25rem;
  text-align: center;
  border: 1px solid var(--s200);
  border-radius: 1.1rem;
  background: #fff;
  overflow: auto;
  box-shadow: 0 1px 2px rgba(0, 0, 0, .03), 0 14px 36px -22px rgba(15, 92, 82, .3);
}
.face.front .face-t { font-size: 1.35rem; color: var(--green-900); font-weight: 700; line-height: 1.8; }
.face.front .ar { font-size: 1.55rem; }
.face.back { transform: rotateY(180deg); background: rgba(15, 92, 82, .04); border-color: var(--green); }
.face.back .face-t { font-size: 1.15rem; line-height: 2; color: var(--s800); }
.hint { font-size: .8rem; color: var(--s400); }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; margin-top: .75rem; }

/* Quiz */
.qh { font-size: 1.15rem; line-height: 1.85; margin: 0 0 1rem; color: var(--s900); font-weight: 700; }
.ops { display: flex; flex-direction: column; gap: .6rem; }
.op {
  text-align: start;
  min-height: 52px;
  padding: .75rem 1.15rem;
  border: 1px solid var(--s300);
  background: #fff;
  border-radius: .75rem;
  line-height: 1.75;
  font-weight: 500;
  transition: all .15s;
}
.op:not([disabled]):hover { border-color: var(--green); background: rgba(15, 92, 82, .02); }
.op.right { border-color: var(--green); background: rgba(15, 92, 82, .09); color: var(--green-900); font-weight: 700; }
.op.wrong { border-color: var(--bad); background: rgba(185, 28, 28, .07); color: var(--bad); font-weight: 700; }
.fb { margin-top: 1rem; padding: .85rem 1.15rem; border-radius: .75rem; line-height: 1.8; }
.fb.ok { background: rgba(15, 92, 82, .07); border: 1px solid rgba(15, 92, 82, .2); }
.fb.no { background: rgba(185, 28, 28, .06); border: 1px solid rgba(185, 28, 28, .2); }

/* Floating AI Tutor Sheet / Dialog */
.sheet-bg { position: fixed; inset: 0; z-index: 90; background: rgba(28, 25, 23, .55); }
.sheet {
  position: fixed;
  z-index: 91;
  inset-inline: 0;
  bottom: 0;
  top: 7dvh;
  background: #fff;
  border-radius: 1.25rem 1.25rem 0 0;
  display: flex;
  flex-direction: column;
  max-width: 46rem;
  margin-inline: auto;
  box-shadow: 0 -12px 40px rgba(0, 0, 0, .25);
  overflow: hidden;
}
.sheet-h {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: .5rem;
  padding: .75rem 1.15rem;
  border-bottom: 1px solid var(--s200);
  background: var(--s50);
}
.msgs {
  flex: 1;
  overflow-y: auto;
  padding: 1rem 1.15rem;
  display: flex;
  flex-direction: column;
  gap: .75rem;
  -webkit-overflow-scrolling: touch;
}
.msg { max-width: 90%; padding: .75rem 1rem; border-radius: .95rem; line-height: 1.9; font-size: .95rem; }
.msg.user { align-self: flex-start; background: var(--green); color: #fff; }
.msg.bot { align-self: flex-end; background: var(--s100); border: 1px solid var(--s200); }
.msg.err { background: #fef2f2; border-color: #fecaca; color: #991b1b; }
.sugs { display: flex; gap: .4rem; overflow-x: auto; padding: .35rem 1.15rem; scrollbar-width: none; }
.sugs::-webkit-scrollbar { display: none; }
.sugs .chip { flex: none; }
.tin { display: flex; gap: .5rem; padding: .65rem 1.15rem; align-items: flex-end; }
.tin textarea { flex: 1; border: 1px solid var(--s300); border-radius: .75rem; padding: .6rem .9rem; resize: none; min-height: 48px; background: #fff; }
.sheet-f { padding: .35rem 1.15rem calc(.85rem + var(--safe-b)); display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
.sheet-f .meta { width: 100%; margin: .25rem 0 0; }

/* Student Codes Modal & Modals */
.modal-bg { position: fixed; inset: 0; z-index: 100; background: rgba(0, 0, 0, .6); display: flex; align-items: center; justify-content: center; padding: 1rem; }
.modal-dlg { background: #fff; border-radius: 1.1rem; max-width: 520px; width: 100%; padding: 1.5rem; box-shadow: 0 20px 40px rgba(0, 0, 0, .3); }

#toast {
  position: fixed;
  inset-inline: 0;
  bottom: calc(5rem + var(--safe-b));
  margin-inline: auto;
  width: fit-content;
  max-width: 90vw;
  background: var(--s900);
  color: #fff;
  padding: .6rem 1.25rem;
  border-radius: 999px;
  font-size: .88rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s;
  z-index: 120;
}
#toast.show { opacity: 1; }

@media (min-width: 640px) {
  .books { grid-template-columns: 1fr 1fr; }
  .sheet { top: 6dvh; bottom: 6dvh; border-radius: 1.25rem; }
  .h1 { font-size: 1.85rem; }
  .hero .h1 { font-size: 2.35rem; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .fc, .progress-fill { transition: none; }
}
@media print { .top, .bar, .tabs-wrap, .tools, .admin-bar { display: none; } }


/* ==========================================================================
   BILINGUAL READING MODE & TRIPLE SWITCHER (Matching Student Mockup)
   ========================================================================== */

/* Top Bar Segmented Language Switcher */
.lang-segmented {
  display: inline-flex;
  align-items: center;
  background: rgba(11, 63, 56, 0.4);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 999px;
  padding: 2px;
}
.lang-seg-btn {
  border: none;
  background: transparent;
  color: rgba(255, 255, 255, 0.85);
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.76rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  min-height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.lang-seg-btn:hover {
  color: #fff;
}
.lang-seg-btn.active {
  background: var(--gold);
  color: #0b3f38;
  font-weight: 700;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

/* Session View Reading Mode Switcher (Matching Prototype Toggle) */
.view-lang-toggle {
  display: inline-flex;
  align-items: center;
  background: var(--s200);
  border: 1px solid var(--s300);
  border-radius: 999px;
  padding: 3px;
  gap: 2px;
}
.v-seg-btn {
  border: none;
  background: transparent;
  color: var(--s700);
  padding: 6px 14px;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.v-seg-btn:hover {
  color: var(--green-900);
}
.v-seg-btn.active {
  background: var(--green);
  color: #fff;
  font-weight: 700;
  box-shadow: 0 1px 3px rgba(0,0,0,0.15);
}

/* Prototype Lesson Cards */
.lessons-stream {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  margin-top: 1rem;
}
.lesson-card {
  background: #fff;
  border: 1px solid var(--s200);
  border-radius: 1.25rem;
  padding: 1.5rem;
  box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}
.lesson-top-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--green);
}
.lesson-t-ar {
  font-family: 'Amiri', 'Traditional Arabic', serif;
  font-size: 1.45rem;
  font-weight: 700;
  color: var(--green-900);
  line-height: 1.45;
  margin: 0 0 0.35rem 0;
}
.lesson-t-en {
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 0.95rem;
  color: var(--s600);
  line-height: 1.5;
  margin: 0 0 1.25rem 0;
}

/* Section Badges */
.sec-badge {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #92400e;
  margin-bottom: 0.4rem;
}

/* Original Text Box (Matn) */
.matn-box {
  background: rgba(15, 92, 82, 0.06);
  border: 1px solid rgba(15, 92, 82, 0.18);
  border-radius: 0.85rem;
  padding: 1rem 1.25rem;
  margin: 0.75rem 0 1.25rem 0;
}
.matn-box .bi-ar {
  font-family: 'Amiri', serif;
  font-size: 1.22rem;
  font-weight: 700;
  color: var(--green-900);
  line-height: 1.8;
}
.matn-box .bi-en {
  font-family: 'Lora', serif;
  font-size: 0.94rem;
  color: #374151;
  line-height: 1.6;
  margin-top: 0.65rem;
  padding-top: 0.65rem;
  border-top: 1px dashed rgba(15, 92, 82, 0.2);
}

/* Key Distinction / Distinction Boxes */
.distinction-box {
  background: #fef3c7;
  border-radius: 0.75rem;
  padding: 0.9rem 1.15rem;
  margin-top: 0.6rem;
  border-inline-start: 4px solid var(--gold);
}
.distinction-box .bi-ar {
  font-weight: 700;
  color: #78350f;
  font-size: 1.05rem;
  line-height: 1.6;
}
.distinction-box .bi-en {
  color: #92400e;
  font-size: 0.88rem;
  line-height: 1.5;
  margin-top: 0.35rem;
}

/* Dual Paragraph Block */
.bi-block {
  margin-bottom: 0.75rem;
}
.bi-block .bi-ar {
  font-size: 1.05rem;
  color: var(--s900);
  line-height: 1.85;
}
.bi-block .bi-en {
  font-size: 0.9rem;
  color: #57534e;
  line-height: 1.6;
  margin-top: 0.35rem;
  padding-inline-start: 0.75rem;
  border-inline-start: 3px solid var(--gold);
}

/* Flashcards Bilingual Layout */
.face-content {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  text-align: center;
}
.face-t-ar {
  font-family: 'Amiri', serif;
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--green-900);
  line-height: 1.6;
}
.face-t-en {
  font-family: 'Inter', sans-serif;
  font-size: 0.95rem;
  color: var(--s600);
  line-height: 1.5;
}

/* Quiz Bilingual Layout */
.quiz-q-ar {
  font-family: 'Amiri', serif;
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--green-900);
  line-height: 1.6;
}
.quiz-q-en {
  font-family: 'Inter', sans-serif;
  font-size: 0.92rem;
  color: var(--s600);
  margin-top: 0.35rem;
  line-height: 1.5;
}
.op-ar {
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.5;
}
.op-en {
  font-size: 0.82rem;
  opacity: 0.85;
  margin-top: 0.25rem;
  line-height: 1.4;
}
.why-ar {
  font-size: 0.95rem;
  line-height: 1.6;
  margin-top: 0.35rem;
}
.why-en {
  font-size: 0.85rem;
  opacity: 0.9;
  margin-top: 0.25rem;
  line-height: 1.5;
}

/* Session Title Dual */
.s-title-ar {
  display: block;
}
.s-title-en {
  display: block;
  font-family: 'Lora', serif;
  font-size: 1.05rem;
  color: var(--s600);
  font-weight: 400;
  margin-top: 0.25rem;
}

/* ==========================================================================
   AI TUTOR API SETTINGS PANEL & STEP-BY-STEP GUIDE
   ========================================================================== */
.api-panel {
  background: var(--s100);
  border: 1px solid var(--s300);
  border-radius: 0.85rem;
  padding: 1rem;
  margin-bottom: 0.85rem;
}
.api-panel-h {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--s200);
  padding-bottom: 0.5rem;
}
.badge-active {
  background: rgba(16, 185, 129, 0.15);
  color: #065f46;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 999px;
  border: 1px solid rgba(16, 185, 129, 0.3);
}
.badge-idle {
  background: var(--s200);
  color: var(--s600);
  font-size: 0.75rem;
  padding: 3px 8px;
  border-radius: 999px;
}
.api-guide {
  margin-top: 0.85rem;
  background: #fff;
  border: 1px solid var(--s200);
  border-radius: 0.65rem;
  padding: 0.75rem;
}
.api-guide summary {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--green);
  cursor: pointer;
}
.guide-steps {
  margin: 0.5rem 0 0 1.25rem;
  padding: 0;
  font-size: 0.8rem;
  color: var(--s700);
  line-height: 1.7;
}
.guide-steps li {
  margin-bottom: 0.35rem;
}
.api-status {
  margin-top: 0.4rem;
  font-size: 0.8rem;
  padding: 0.35rem 0.6rem;
  border-radius: 0.4rem;
}
.api-status.ok {
  background: #ecfdf5;
  color: #065f46;
  border: 1px solid #a7f3d0;
}
.api-status.err {
  background: #fef2f2;
  color: #991b1b;
  border: 1px solid #fecaca;
}

/* ==========================================================================
   OFFICIAL USTAZ RICH FOOTER (Matching ustaz_cloudflare_site)
   ========================================================================== */
.ustaz-footer {
  background: #0b3f38;
  color: #e7e5e4;
  border-top: 3px solid var(--gold);
  margin-top: 3rem;
  font-size: 0.88rem;
}
.foot-top {
  max-width: 1200px;
  margin: 0 auto;
  padding: 3rem 1.25rem 2rem 1.25rem;
  display: grid;
  grid-template-columns: 1fr;
  gap: 2rem;
}
@media (min-width: 768px) {
  .foot-top {
    grid-template-columns: 1.3fr 1fr 1fr 1fr;
    gap: 2rem;
  }
}
.foot-col-title {
  color: #fff;
  font-size: 1rem;
  font-weight: 700;
  margin: 0 0 1rem 0;
  position: relative;
  padding-bottom: 0.4rem;
  border-bottom: 2px solid rgba(200, 162, 90, 0.4);
}
.foot-logo-wrap {
  margin-bottom: 1rem;
}
.foot-logo {
  height: 48px;
  width: auto;
  object-fit: contain;
  filter: brightness(0) invert(1);
}
.foot-desc {
  font-size: 0.85rem;
  color: #d6d3d1;
  line-height: 1.75;
  margin-bottom: 1rem;
}
.foot-badges {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}
.foot-badge {
  display: inline-block;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: #fef08a;
  font-size: 0.76rem;
  padding: 4px 10px;
  border-radius: 999px;
  width: fit-content;
}
.foot-links {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}
.foot-links a {
  color: #d6d3d1;
  text-decoration: none;
  transition: color 0.2s;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  line-height: 1.5;
}
.foot-links a:hover {
  color: var(--gold);
  text-decoration: underline;
}
.foot-contact-item {
  display: flex;
  gap: 0.75rem;
  align-items: flex-start;
  margin-bottom: 0.85rem;
}
.foot-contact-icon {
  font-size: 1.25rem;
  line-height: 1;
}
.foot-contact-sub {
  font-size: 0.76rem;
  color: #a8a29e;
  margin-top: 2px;
}
.foot-link {
  color: #6ee7b7;
  text-decoration: none;
  font-weight: 600;
}
.foot-link:hover {
  color: #fff;
  text-decoration: underline;
}
.foot-wa-btn {
  display: inline-flex;
  flex-direction: column;
  background: rgba(16, 185, 129, 0.18);
  border: 1px solid rgba(16, 185, 129, 0.4);
  color: #6ee7b7;
  padding: 6px 12px;
  border-radius: 8px;
  text-decoration: none;
  font-size: 0.8rem;
  font-weight: 600;
  transition: all 0.2s;
}
.foot-wa-btn:hover {
  background: #10b981;
  color: #fff;
}
.foot-bot {
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(0, 0, 0, 0.2);
  padding: 1.25rem;
}
.foot-bot-in {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  align-items: center;
  text-align: center;
  font-size: 0.8rem;
  color: #a8a29e;
}
@media (min-width: 640px) {
  .foot-bot-in {
    flex-direction: row;
    justify-content: space-between;
    text-align: right;
  }
}
.foot-legal {
  display: flex;
  gap: 0.6rem;
  align-items: center;
}
.foot-legal a {
  color: #a8a29e;
  text-decoration: none;
}
.foot-legal a:hover {
  color: var(--gold);
}
