:root {
  --night: #0F2A2E;
  --ink: #12282C;
  --paper: #EEF2F0;
  --surface: #FFFFFF;
  --green: #1F6B57;
  --green-dark: #17533F;
  --gold: #C39A45;
  --gold-soft: #F4EBD6;
  --lapis: #2E5A88;
  --line: #D6DEDA;
  --muted: #56676A;
  --room: #0E2427;
  --room-2: #163236;
  --danger: #B4492F;
  --display: "Amiri", Georgia, "Times New Roman", serif;
  --body: "Readex Pro", system-ui, -apple-system, "Segoe UI", sans-serif;
  --pattern: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='44' height='44' viewBox='0 0 44 44'%3E%3Cg fill='none' stroke='%23C39A45' stroke-width='1.2'%3E%3Crect x='12' y='12' width='20' height='20'/%3E%3Crect x='12' y='12' width='20' height='20' transform='rotate(45 22 22)'/%3E%3Ccircle cx='22' cy='22' r='3'/%3E%3C/g%3E%3C/svg%3E");
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font-family: var(--body); color: var(--ink); background: var(--paper); font-size: 16px; line-height: 1.5; }
[hidden] { display: none !important; }

.topbar { display: flex; align-items: center; justify-content: space-between; padding: 18px 28px; }
.brand { font-family: var(--display); font-size: 1.5rem; font-weight: 700; color: var(--ink); text-decoration: none; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font: 600 1rem var(--body); padding: 12px 22px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  cursor: pointer; text-decoration: none;
}
.btn:hover { border-color: var(--green); }
.btn.primary { background: var(--green); border-color: var(--green); color: #fff; }
.btn.primary:hover { background: var(--green-dark); }
.btn.small { padding: 8px 14px; font-size: .9rem; }
.btn:disabled { opacity: .55; cursor: wait; }
.btn:focus-visible, .ctl:focus-visible, input:focus-visible, .icon-btn:focus-visible {
  outline: 3px solid var(--gold); outline-offset: 2px;
}

input {
  font: inherit; padding: 12px 14px; border: 1px solid var(--line); border-radius: 10px;
  background: #fff; color: var(--ink); width: 100%;
}
label { font-weight: 600; font-size: .95rem; display: block; margin-bottom: 6px; }
.muted { color: var(--muted); }
.notice {
  background: #FBF3E4; border: 1px solid #E8D3AC; color: #6B4E1B;
  padding: 10px 12px; border-radius: 10px; font-size: .92rem; margin: 0;
}

/* ---------- Home page ---------- */
.home-main {
  max-width: 1040px; margin: 0 auto; padding: 24px 28px 64px;
  display: grid; grid-template-columns: 1.15fr 1fr; gap: 56px; align-items: center;
  min-height: calc(100vh - 80px);
}
.illumination {
  position: relative; padding: 48px 40px 48px 84px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 4px;
}
.illumination::before {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 44px;
  background-color: var(--ink);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='44' height='44' viewBox='0 0 44 44'%3E%3Cg fill='none' stroke='%23B58A3C' stroke-width='1.2'%3E%3Crect x='12' y='12' width='20' height='20'/%3E%3Crect x='12' y='12' width='20' height='20' transform='rotate(45 22 22)'/%3E%3Ccircle cx='22' cy='22' r='3'/%3E%3C/g%3E%3C/svg%3E");
  background-repeat: repeat-y; background-size: 44px 44px;
}
.bismillah {
  font-family: var(--display); font-size: clamp(1.9rem, 4vw, 2.8rem); color: var(--gold);
  margin: 0 0 20px; line-height: 1.7;
}
.home-title { font-family: var(--display); font-size: clamp(2rem, 4vw, 2.7rem); line-height: 1.15; margin: 0 0 16px; }
.home-lead { font-size: 1.1rem; color: var(--muted); max-width: 34em; margin: 0; }

.start-card { display: flex; flex-direction: column; gap: 16px; }
.start-card .btn.primary { padding: 16px 22px; font-size: 1.05rem; }
.or { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: .9rem; }
.or::before, .or::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.join-row { display: flex; gap: 10px; }
.join-row input { flex: 1; }

/* ---------- Before joining ---------- */
.prejoin-grid {
  max-width: 1040px; margin: 0 auto; padding: 16px 28px 48px;
  display: grid; grid-template-columns: 1.4fr 1fr; gap: 40px; align-items: center;
  min-height: calc(100vh - 80px);
}
.preview { position: relative; aspect-ratio: 16 / 9; background: var(--room); border-radius: 14px; overflow: hidden; }
.preview video { width: 100%; height: 100%; object-fit: cover; transform: scaleX(-1); }
.preview-empty { position: absolute; inset: 0; display: grid; place-items: center; color: #CFD8D3; }
.preview-controls { position: absolute; bottom: 14px; left: 0; right: 0; display: flex; justify-content: center; gap: 12px; }
.prejoin-form { display: flex; flex-direction: column; gap: 14px; }
.prejoin-form h1 { font-family: var(--display); font-size: 2.2rem; margin: 0; line-height: 1.2; }
.prejoin-form p { margin: 0; }

/* ---------- Round control buttons ---------- */
.ctl {
  position: relative; width: 52px; height: 52px; border-radius: 50%; border: none;
  background: rgba(255, 255, 255, .14); color: #fff; display: grid; place-items: center; cursor: pointer;
}
.ctl:hover { background: rgba(255, 255, 255, .24); }
.ctl svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.ctl.off { background: var(--danger); }
.ctl.off::after { content: ""; position: absolute; width: 28px; height: 2px; background: #fff; transform: rotate(-45deg); }
.ctl.active { background: var(--gold); color: var(--ink); }
.ctl.leave { background: var(--danger); width: auto; border-radius: 26px; padding: 0 22px; font: 600 .95rem var(--body); }
.ctl.leave:hover { background: #963722; }
.dot { position: absolute; top: 9px; right: 9px; width: 10px; height: 10px; border-radius: 50%; background: var(--gold); border: 2px solid var(--room); }

/* ---------- In class ---------- */
.call {
  position: fixed; inset: 0; background: var(--room); color: #EEF2EF;
  display: grid; grid-template-columns: 1fr auto; grid-template-rows: 1fr auto;
}
.stage { position: relative; grid-column: 1; grid-row: 1; padding: 16px 16px 0; min-height: 0; }
.remote-tile { position: relative; width: 100%; height: 100%; background: var(--room-2); border-radius: 14px; overflow: hidden; }
.remote-tile video { width: 100%; height: 100%; object-fit: contain; background: #000; }
.remote-tile video.cam-hidden { visibility: hidden; }
.avatar { position: absolute; inset: 0; display: grid; place-items: center; }
.avatar span {
  width: 120px; height: 120px; border-radius: 50%; background: var(--green);
  display: grid; place-items: center; font: 700 3.2rem var(--display); color: #fff;
}
.tile-name {
  position: absolute; left: 12px; bottom: 12px; background: rgba(0, 0, 0, .55);
  padding: 4px 10px; border-radius: 8px; font-size: .9rem; display: flex; gap: 8px; align-items: center;
}
.muted-badge { color: #F3B7A8; }
.waiting {
  position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; padding: 24px; gap: 6px;
}
.waiting p { margin: 0; }
.waiting-title { font-family: var(--display); font-size: 1.9rem; margin: 0 0 4px; }
.link-box {
  display: flex; gap: 10px; align-items: center; background: rgba(255, 255, 255, .08);
  padding: 8px 8px 8px 14px; border-radius: 10px; max-width: 100%; margin-top: 10px;
}
.link-box span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .95rem; }

.local-tile {
  position: absolute; right: 32px; bottom: 16px; width: clamp(140px, 22%, 280px); aspect-ratio: 16 / 9;
  border-radius: 10px; overflow: hidden; background: var(--room-2);
  border: 2px solid rgba(181, 138, 60, .7); box-shadow: 0 6px 24px rgba(0, 0, 0, .45);
}
.local-tile video { width: 100%; height: 100%; object-fit: cover; }
.local-tile video.mirror { transform: scaleX(-1); }
.local-tile.cam-off video { visibility: hidden; }
.local-tile.cam-off::after {
  content: "Camera off"; position: absolute; inset: 0; display: grid; place-items: center; font-size: .85rem; color: #CFD8D3;
}
.local-tile .tile-name { left: 8px; bottom: 8px; font-size: .8rem; padding: 2px 8px; }

.status {
  position: absolute; top: 28px; left: 50%; transform: translateX(-50%);
  background: rgba(0, 0, 0, .65); padding: 8px 14px; border-radius: 8px; margin: 0; max-width: 90%; text-align: center;
}
.controls { grid-column: 1 / -1; grid-row: 2; display: flex; justify-content: center; gap: 12px; padding: 14px 16px 18px; flex-wrap: wrap; }

.chat {
  grid-column: 2; grid-row: 1; width: 340px; background: var(--paper); color: var(--ink);
  display: flex; flex-direction: column; margin: 16px 16px 0 0; border-radius: 14px; overflow: hidden;
}
.chat-head { display: flex; justify-content: space-between; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.chat-head h2 { font: 700 1.25rem var(--display); margin: 0; }
.icon-btn { background: none; border: none; font-size: 1.7rem; cursor: pointer; color: var(--ink); line-height: 1; padding: 0 4px; }
.messages { list-style: none; margin: 0; padding: 12px 16px; flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 12px; }
.messages:empty::before { content: "Messages you send here are seen by everyone in the class."; color: var(--muted); font-size: .9rem; }
.msg-meta { font-size: .8rem; color: var(--muted); display: flex; gap: 8px; }
.msg-meta strong { color: var(--ink); }
.msg.me .msg-meta strong { color: var(--green); }
.msg-text { white-space: pre-wrap; overflow-wrap: anywhere; font-size: 1rem; }
.chat-form { display: flex; gap: 8px; padding: 12px; border-top: 1px solid var(--line); }

.ended { min-height: 100vh; display: grid; place-items: center; text-align: center; padding: 24px; }
.ended h1 { font-family: var(--display); font-size: 2.2rem; margin: 0 0 8px; }
.ended p { color: var(--muted); margin: 0 0 24px; }
.ended .actions { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }

.toast {
  position: fixed; bottom: 100px; left: 50%; transform: translateX(-50%);
  background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 10px; z-index: 20;
  border: 1px solid rgba(181, 138, 60, .6);
}

@media (max-width: 760px) {
  .home-main, .prejoin-grid { grid-template-columns: 1fr; gap: 28px; min-height: 0; }
  .illumination { padding: 32px 22px 32px 62px; }
  .illumination::before { width: 36px; background-size: 36px 36px; }
  .chat { position: fixed; inset: 0; width: auto; margin: 0; border-radius: 0; z-index: 10; }
  .local-tile { right: 26px; bottom: 10px; width: 36%; }
  .ctl { width: 46px; height: 46px; }
  .controls { gap: 8px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* =====================================================
   Phase 3: logins, dashboard, admin tools
   ===================================================== */
select, textarea {
  font: inherit; padding: 11px 12px; border: 1px solid var(--line); border-radius: 10px;
  background: #fff; color: var(--ink); width: 100%;
}
textarea { resize: vertical; }
select:focus-visible, textarea:focus-visible, .link-btn:focus-visible, .tabs button:focus-visible, .seg button:focus-visible {
  outline: 3px solid var(--gold); outline-offset: 2px;
}
.small { font-size: .88rem; }
.card-title { font-family: var(--display); font-size: 1.8rem; margin: 0; }

.field { display: flex; flex-direction: column; gap: 6px; margin: 0; font-weight: 400; border: 0; padding: 0; min-width: 0; }
.field-label { font-weight: 600; font-size: .95rem; padding: 0; }
.field-hint { color: var(--muted); font-size: .85rem; }
.field-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; }
.inline { display: flex; gap: 8px; align-items: center; }
.inline input { flex: 1; }
.check { display: flex; gap: 10px; align-items: center; font-weight: 500; }
.check input { width: auto; }
.days { display: flex; flex-wrap: wrap; gap: 8px; }
.day {
  display: inline-flex; align-items: center; gap: 6px; padding: 7px 12px; border: 1px solid var(--line);
  border-radius: 999px; font-weight: 500; font-size: .92rem; cursor: pointer; background: #fff; margin: 0;
}
.day input { width: auto; margin: 0; }
.day:has(input:checked) { background: var(--green); border-color: var(--green); color: #fff; }

/* App shell */
.app-page { background: var(--paper); }
.app-bar { border-bottom: 1px solid var(--line); background: var(--surface); gap: 16px; flex-wrap: wrap; }
.who { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: .95rem; }
.app { max-width: 1180px; margin: 0 auto; padding: 24px 24px 64px; }
.page-title { font-family: var(--display); font-size: 2.1rem; margin: 4px 0 16px; line-height: 1.2; }
.section-title { font-family: var(--display); font-size: 1.45rem; margin: 28px 0 12px; }
.info-box {
  background: var(--surface); border: 1px solid var(--line); border-left: 4px solid var(--gold);
  padding: 12px 16px; border-radius: 8px; margin: 0 0 16px; color: var(--ink);
}

/* Class cards (teacher and student) */
.class-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.class-card {
  display: grid; grid-template-columns: minmax(150px, 220px) 1fr auto; gap: 16px; align-items: center;
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 14px 18px;
}
.class-card.live { border-color: var(--green); box-shadow: 0 0 0 3px rgba(37, 97, 74, .12); }
.class-card.cancelled { opacity: .6; }
.class-when { display: flex; flex-direction: column; }
.class-when span, .class-who { color: var(--muted); }
.class-who strong { color: var(--ink); }
.class-list.past .class-card { background: transparent; }
.chip-list { list-style: none; display: flex; flex-wrap: wrap; gap: 8px; padding: 0; margin: 0; }
.chip { background: var(--surface); border: 1px solid var(--line); border-radius: 999px; padding: 6px 14px; }

.pill {
  display: inline-block; font-size: .8rem; font-weight: 600; padding: 3px 10px; border-radius: 999px;
  background: #E7EBE4; color: var(--muted); margin-left: 6px; white-space: nowrap;
}
.pill.ok { background: #DDEEE5; color: var(--green-dark); }
.pill.warn { background: #F8E3DC; color: #8E3420; }

/* Admin tabs and panels */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 20px; overflow-x: auto; }
.tabs button {
  position: relative; background: none; border: none; font: 600 1rem var(--body); color: var(--muted);
  padding: 12px 16px; cursor: pointer; border-bottom: 3px solid transparent; white-space: nowrap;
}
.tabs button.active { color: var(--ink); border-bottom-color: var(--gold); }
.badge {
  display: inline-block; min-width: 20px; padding: 1px 6px; margin-left: 6px; border-radius: 999px;
  background: var(--danger); color: #fff; font-size: .78rem; text-align: center;
}
.panel-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.panel-head h2 { font-family: var(--display); font-size: 1.8rem; margin: 0; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; margin-bottom: 14px; background: #fff; }
.seg button { background: none; border: none; padding: 9px 16px; font: 500 .95rem var(--body); cursor: pointer; color: var(--muted); }
.seg button + button { border-left: 1px solid var(--line); }
.seg button.active { background: var(--ink); color: #fff; }

.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; }
.table { width: 100%; border-collapse: collapse; font-size: .94rem; }
.table th {
  text-align: left; font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted);
  padding: 12px 14px; border-bottom: 1px solid var(--line); white-space: nowrap; background: #FAFBF8;
}
.table td { padding: 11px 14px; border-bottom: 1px solid #ECEFE8; vertical-align: top; }
.table tr:last-child td { border-bottom: none; }
.table tr.cancelled td { color: var(--muted); }
.table tr.warn-row td { background: #FDF6F3; }
.table td.absent { color: #8E3420; font-weight: 600; }
.link-btn { background: none; border: none; padding: 0; color: var(--green); font: 600 .94rem var(--body); cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }
.link-btn.danger { color: var(--danger); }

.alert-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 12px; }
.alert-item { background: var(--surface); border: 1px solid var(--line); border-left: 4px solid var(--danger); border-radius: 10px; padding: 14px 16px; display: flex; flex-direction: column; gap: 6px; }
.alert-item.reviewed { border-left-color: var(--line); opacity: .75; }
.alert-head { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.alert-head .pill { margin-left: 0; }
.alert-item blockquote { margin: 4px 0; padding: 8px 12px; background: var(--paper); border-radius: 8px; }
.alert-item .btn { align-self: flex-start; }

.settings-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 20px; }
.card-form { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 20px; display: flex; flex-direction: column; gap: 14px; }
.card-form h2 { font-family: var(--display); font-size: 1.5rem; margin: 0; }
.card-form .btn { align-self: flex-start; }

/* Dialogs */
.dlg { border: none; border-radius: 14px; padding: 0; width: min(640px, calc(100vw - 24px)); max-height: calc(100vh - 32px); color: var(--ink); background: var(--paper); box-shadow: 0 20px 60px rgba(0, 0, 0, .3); }
.dlg::backdrop { background: rgba(20, 48, 42, .55); }
.dlg-form { display: flex; flex-direction: column; max-height: calc(100vh - 32px); }
.dlg-head { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--line); background: var(--surface); }
.dlg-head h2 { font-family: var(--display); font-size: 1.5rem; margin: 0; }
.dlg-body { padding: 18px 20px; display: flex; flex-direction: column; gap: 14px; overflow-y: auto; }
.dlg-form > .notice { margin: 0 20px 12px; }
.dlg-actions { display: flex; justify-content: flex-end; gap: 10px; padding: 14px 20px; border-top: 1px solid var(--line); background: var(--surface); }
.dlg-sub { font-size: 1rem; margin: 8px 0 0; padding-top: 12px; border-top: 1px dashed var(--line); }
.creds { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 14px; white-space: pre-wrap; font-size: .95rem; margin: 0; }
.admin-log { max-height: 60vh; padding: 0; }

/* Chat extras */
.msg.system { color: var(--muted); font-size: .85rem; font-style: italic; background: #EEF1EA; padding: 8px 10px; border-radius: 8px; }
.msg.blocked .msg-text { color: #8E3420; text-decoration: line-through; }

@media (max-width: 760px) {
  .app { padding: 16px 14px 48px; }
  .class-card { grid-template-columns: 1fr; gap: 8px; }
  .class-card .btn, .class-card .pill { justify-self: start; margin-left: 0; }
  .who span { display: none; }
}
.danger-zone { display: flex; flex-direction: column; gap: 8px; }
.danger-zone p { margin: 0; }
.danger-btn { border-color: var(--danger); color: var(--danger); align-self: flex-start; }
.danger-btn:hover { background: #FDF1EE; border-color: var(--danger); }

/* Several people in a class (teacher, student, supervisor) */
.tiles { position: absolute; inset: 16px 16px 0; display: grid; gap: 12px; grid-template-columns: 1fr; grid-auto-rows: 1fr; }
.tiles.two { grid-template-columns: 1fr 1fr; }
.tiles .remote-tile { min-height: 0; }
.stage > .waiting { inset: 16px 16px 0; background: var(--room-2); border-radius: 14px; }
.supervisor-badge {
  position: absolute; top: 28px; left: 28px; z-index: 3; background: var(--gold); color: var(--ink);
  padding: 6px 14px; border-radius: 999px; font-weight: 600; font-size: .9rem; box-shadow: 0 4px 14px rgba(0,0,0,.3);
}
@media (max-width: 760px) {
  .tiles.two { grid-template-columns: 1fr; }
  .supervisor-badge { top: 22px; left: 22px; font-size: .8rem; }
}
.live-wrap:empty { display: none; }
.live-wrap { margin-bottom: 20px; }
.live-title { display: flex; align-items: center; gap: 10px; margin-top: 0; }
.live-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--danger); box-shadow: 0 0 0 4px rgba(180, 69, 47, .2); }
.presence { display: flex; flex-wrap: wrap; gap: 6px; }
.presence .pill { margin-left: 0; }
.alert-item.warning.high { border-left-color: var(--danger); }
.alert-item.warning.medium { border-left-color: var(--gold); }
.people-list { margin: 4px 0; padding-left: 20px; display: flex; flex-direction: column; gap: 4px; }
.panel-head.spaced { margin-top: 36px; }

/* =====================================================
   Shared Mushaf page and whiteboard
   ===================================================== */
.doc-area {
  position: absolute; inset: 16px 272px 0 16px; z-index: 1; display: flex; flex-direction: column;
  background: #0B1916; border-radius: 14px; overflow: hidden;
}
.doc-toolbar { display: flex; flex-wrap: wrap; gap: 8px 14px; align-items: center; padding: 8px 10px; background: #0B1916; border-bottom: 1px solid rgba(255,255,255,.08); }
.doc-group { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.doc-btn {
  background: rgba(255,255,255,.1); color: #fff; border: none; border-radius: 8px; padding: 8px 12px;
  font: 600 .88rem var(--body); cursor: pointer; white-space: nowrap;
}
.doc-btn:hover { background: rgba(255,255,255,.2); }
.doc-btn.active { background: var(--gold); color: var(--ink); }
.doc-btn:disabled { opacity: .35; cursor: default; }
.doc-btn:focus-visible, .doc-select:focus-visible, .doc-page-input:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }
.doc-close { background: rgba(180, 69, 47, .9); }
.doc-select, .doc-page-input {
  width: auto; padding: 7px 10px; border-radius: 8px; border: 1px solid rgba(255,255,255,.2);
  background: #16302A; color: #fff; font: 500 .9rem var(--body);
}
.doc-page-input { width: 76px; }
.doc-label { color: #CFD8D3; font-size: .9rem; }
.doc-scroll { flex: 1; min-height: 0; overflow: auto; display: flex; padding: 8px; }
.doc-page { position: relative; margin: auto; flex: none; background: #fff; box-shadow: 0 6px 24px rgba(0,0,0,.4); }
.doc-page img { display: block; width: 100%; height: 100%; user-select: none; pointer-events: none; }
.doc-page canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.doc-page.board {
  background-color: #fff;
  background-image: linear-gradient(#E3EAF4 1px, transparent 1px);
  background-size: 100% 12.5%;
}
.ptr {
  position: absolute; width: 20px; height: 20px; margin: -10px 0 0 -10px; border-radius: 50%;
  border: 3px solid #fff; box-shadow: 0 0 0 2px rgba(0,0,0,.35), 0 0 14px rgba(0,0,0,.25);
  pointer-events: none; transition: left .06s linear, top .06s linear; z-index: 2;
}
.ptr.teacher { background: #C62828; }
.ptr.student { background: #1565C0; }

/* While a page is open, the videos move to a column on the right */
.call.doc-mode .tiles { inset: 16px 16px auto auto; width: 240px; grid-template-columns: 1fr; grid-auto-rows: 140px; }
.call.doc-mode .tiles.two { grid-template-columns: 1fr; }
.call.doc-mode .stage > .waiting { inset: 16px 16px auto auto; width: 240px; height: 140px; padding: 10px; }
.call.doc-mode .waiting-title { font-size: 1.05rem; }
.call.doc-mode #waitingText { display: none; }
.call.doc-mode .local-tile { right: 16px; width: 240px; }
.call.doc-mode .supervisor-badge { top: auto; left: auto; right: 24px; bottom: 150px; }
.call.doc-mode .avatar span { width: 60px; height: 60px; font-size: 1.7rem; }

@media (max-width: 760px) {
  .doc-area { inset: 8px 8px 132px 8px; }
  .doc-toolbar { gap: 6px; padding: 6px; }
  .doc-btn { padding: 7px 9px; font-size: .8rem; }
  .call.doc-mode .tiles { inset: auto 34% 0 8px; width: auto; height: 120px; grid-template-columns: 1fr; grid-auto-flow: column; grid-auto-columns: 1fr; grid-auto-rows: 120px; }
  .call.doc-mode .tiles.two { grid-template-columns: none; }
  .call.doc-mode .stage > .waiting { inset: auto 34% 0 8px; width: auto; height: 120px; }
  .call.doc-mode .local-tile { right: 8px; bottom: 0; width: calc(34% - 16px); height: 120px; aspect-ratio: auto; }
  .call.doc-mode .supervisor-badge { bottom: 128px; right: 12px; }
}
.upload-bar { width: 100%; height: 12px; accent-color: var(--green); }
.setup-page { max-width: 100%; max-height: 50vh; align-self: center; border: 1px solid var(--line); border-radius: 6px; background: #fff; }
.setup-nav { flex-wrap: wrap; }

/* =====================================================
   Design refresh: illumination (tazhib) identity
   ===================================================== */
body { font-weight: 350; letter-spacing: .005em; }
strong, b { font-weight: 600; }
.btn, .doc-btn, .tabs button, .seg button, .link-btn { font-family: var(--body); }

/* Brand */
.brand { display: inline-flex; align-items: center; gap: 10px; }
.brand-mark { width: 28px; height: 28px; color: var(--gold); flex: none; }
.brand span { font-family: var(--display); font-weight: 700; font-size: 1.45rem; line-height: 1; }

/* Buttons */
.btn { border-radius: 10px; font-weight: 500; transition: background-color .15s, border-color .15s, color .15s; }
.btn.primary { background: var(--green); border-color: var(--green); }
.btn.primary:hover { background: var(--green-dark); border-color: var(--green-dark); }
.btn.gold { background: var(--gold); border-color: var(--gold); color: var(--night); font-weight: 600; }
.btn.gold:hover { background: #D5AE5C; border-color: #D5AE5C; }
.btn.large { padding: 15px 28px; font-size: 1.05rem; }

/* ---------- Login and setup ---------- */
.home-main { gap: 0; padding: 32px 28px 64px; max-width: 1080px; align-items: stretch; min-height: calc(100vh - 90px); }
.illumination {
  background: var(--night); color: #E6EEEA; border: none; border-radius: 18px 0 0 18px;
  padding: 56px 48px 56px 92px; display: flex; flex-direction: column; justify-content: center;
}
.illumination::before { background-color: #0A2023; background-image: var(--pattern); width: 52px; border-radius: 18px 0 0 18px; }
.illumination .bismillah { color: var(--gold); font-size: clamp(2rem, 4.2vw, 3rem); margin-bottom: 28px; }
.home-title { color: #fff; font-size: clamp(2.1rem, 4vw, 2.9rem); }
.home-lead { color: #B9CBC4; font-size: 1.08rem; max-width: 30em; }
.start-card {
  background: var(--surface); border-radius: 0 18px 18px 0; padding: 48px 44px; justify-content: center;
  border: 1px solid var(--line); border-left: none;
}
.card-title { font-size: 2rem; margin-bottom: 4px; }

/* ---------- App shell ---------- */
.app-bar { background: var(--surface); padding: 14px 28px; }
.who { gap: 14px; }
.who span { font-size: .92rem; }
.app { max-width: 1240px; }
.page-title { font-size: 2.3rem; margin: 6px 0 4px; }
.page-date { color: var(--muted); margin: 0 0 22px; }
.info-box { border-left-color: var(--gold); background: var(--surface); }
.note-from-office { margin-top: 36px; font-size: .92rem; color: var(--muted); background: transparent; border: 1px dashed var(--line); border-left: 3px solid var(--gold); }

/* Tables: quiet sentence-case headings */
.table th { text-transform: none; letter-spacing: 0; font-size: .85rem; font-weight: 500; color: var(--muted); background: #F6F8F7; }
.table td { padding: 12px 14px; }
.table tbody tr:hover td { background: #F8FAF9; }

/* ---------- Next class: the illuminated panel ---------- */
.next-class {
  position: relative; display: grid; grid-template-columns: 1fr auto; gap: 18px 32px; align-items: center;
  background: var(--night); color: #E6EEEA; border-radius: 16px; padding: 30px 92px; margin: 8px 0 34px;
  box-shadow: inset 0 0 0 1px rgba(195, 154, 69, .55), inset 0 0 0 7px var(--night), inset 0 0 0 8px rgba(195, 154, 69, .35);
}
.next-class::before, .next-class::after {
  content: ""; position: absolute; top: 14px; bottom: 14px; width: 44px;
  background-image: var(--pattern); background-size: 44px 44px; background-position: center; opacity: .9;
}
.next-class::before { left: 22px; }
.next-class::after { right: 22px; }
.next-label { margin: 0 0 6px; color: var(--gold); font-size: .95rem; }
.next-when { font-family: var(--display); font-size: clamp(1.8rem, 3.6vw, 2.5rem); line-height: 1.15; margin: 0; color: #fff; font-weight: 700; }
.next-who { margin: 8px 0 0; color: #C9D8D2; font-size: 1.05rem; }
.next-who strong { color: #fff; font-weight: 500; }
.next-action { display: flex; flex-direction: column; align-items: flex-end; gap: 8px; text-align: right; }
.next-status { color: #B9CBC4; font-size: .92rem; margin: 0; }
.next-class.open .next-status { color: #8FD3B5; }
.next-class.empty { grid-template-columns: 1fr; }
.next-class.empty .next-when { font-size: 1.6rem; }

/* ---------- Schedule grouped by day ---------- */
.day-group { margin-bottom: 18px; }
.day-head { font-family: var(--display); font-size: 1.25rem; margin: 0 0 6px; color: var(--ink); }
.day-head span { font-family: var(--body); font-size: .88rem; color: var(--muted); margin-left: 8px; font-weight: 400; }
.schedule { list-style: none; margin: 0; padding: 0; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; }
.schedule-row { display: grid; grid-template-columns: 120px 1fr auto; gap: 16px; align-items: center; padding: 13px 18px; }
.schedule-row + .schedule-row { border-top: 1px solid #E7ECEA; }
.schedule-row .time { font-weight: 500; font-variant-numeric: tabular-nums; }
.schedule-row .length { display: block; color: var(--muted); font-size: .84rem; }
.schedule-row .who-cell { color: var(--muted); }
.schedule-row .who-cell strong { color: var(--ink); }
.schedule-row.cancelled { opacity: .55; }
.schedule-row.cancelled .time { text-decoration: line-through; }
.schedule-row.past { color: var(--muted); }
.schedule-row .pill { margin-left: 0; }

/* ---------- Admin: side menu ---------- */
.app.admin-app { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 32px; align-items: start; }
.admin-app .tabs {
  flex-direction: column; border-bottom: none; gap: 2px; margin: 0; position: sticky; top: 20px;
  background: var(--night); border-radius: 14px; padding: 14px 10px 64px; overflow: hidden;
}
.admin-app .tabs::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 48px;
  background-image: var(--pattern); background-size: 44px 44px; opacity: .55;
}
.admin-app .tabs button {
  display: flex; align-items: center; gap: 12px; text-align: left; color: #B9CBC4; font-weight: 400;
  border-bottom: none; border-radius: 9px; padding: 11px 12px; font-size: .98rem;
}
.admin-app .tabs button svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.admin-app .tabs button:hover { background: rgba(255, 255, 255, .06); color: #fff; }
.admin-app .tabs button.active { background: rgba(195, 154, 69, .16); color: #fff; box-shadow: inset 3px 0 0 var(--gold); }
.admin-app .tabs .badge { margin-left: auto; }
.panel-head h2 { font-size: 2rem; }
.lede { color: var(--muted); font-size: 1.02rem; margin: -6px 0 18px; }
.lede strong { color: var(--ink); }

/* Classes tab: live classes stand out */
.live-wrap .class-card.live { border-color: var(--green); box-shadow: none; border-left: 4px solid var(--green); }
.class-card { border-radius: 12px; }

/* Pills */
.pill { font-weight: 500; font-size: .78rem; background: #E8EDEB; }
.pill.ok { background: #DCEEE6; color: #155440; }
.pill.warn { background: #F7E2DB; color: #8E3420; }

/* Dialogs */
.dlg { border-radius: 16px; }
.dlg-head { background: var(--surface); }
.dlg-head h2 { font-size: 1.6rem; }

/* ---------- Classroom ---------- */
.call { background: var(--room); }
.controls { padding: 12px 16px 30px; gap: 14px; }
.ctl { background: rgba(255, 255, 255, .1); }
.ctl[data-label]::before {
  content: attr(data-label); position: absolute; top: calc(100% + 6px); left: 50%; transform: translateX(-50%);
  font: 400 .72rem var(--body); color: #A9BDB6; white-space: nowrap; pointer-events: none;
}
.ctl.active { background: var(--gold); color: var(--night); }
.ctl.leave { margin-left: 10px; }
.tile-name { background: rgba(14, 36, 39, .78); border-radius: 8px; }
.remote-tile { border-radius: 16px; }
.local-tile { border-color: rgba(195, 154, 69, .8); }
.prejoin-grid { gap: 48px; }
.preview { border-radius: 18px; box-shadow: 0 0 0 1px rgba(195, 154, 69, .45), 0 18px 40px rgba(15, 42, 46, .18); }
.prejoin-form h1 { font-size: 2.4rem; }
.ended h1 { font-size: 2.4rem; }

@media (max-width: 960px) {
  .app.admin-app { grid-template-columns: 1fr; gap: 16px; }
  .admin-app .tabs { flex-direction: row; position: static; padding: 6px; overflow-x: auto; }
  .admin-app .tabs::after { display: none; }
  .admin-app .tabs button { white-space: nowrap; padding: 9px 12px; }
  .admin-app .tabs button.active { box-shadow: inset 0 -3px 0 var(--gold); }
}
@media (max-width: 760px) {
  .illumination { border-radius: 16px 16px 0 0; padding: 36px 24px 36px 72px; }
  .illumination::before { border-radius: 16px 0 0 0; }
  .start-card { border-radius: 0 0 16px 16px; border-left: 1px solid var(--line); border-top: none; padding: 32px 24px; }
  .home-main { padding: 12px 14px 40px; }
  .next-class { grid-template-columns: 1fr; padding: 26px 62px; }
  .next-class::before { left: 12px; width: 34px; background-size: 34px 34px; }
  .next-class::after { right: 12px; width: 34px; background-size: 34px 34px; }
  .next-action { align-items: flex-start; text-align: left; }
  .schedule-row { grid-template-columns: 1fr; gap: 6px; }
  .schedule-row .btn, .schedule-row .pill { justify-self: start; }
  .ctl[data-label]::before { display: none; }
  .controls { padding-bottom: 16px; }
  .brand span { font-size: 1.2rem; }
}

/* Review fixes */
body { font-weight: 400; }
.table td { color: var(--ink); }
.link-btn.danger { color: var(--muted); text-decoration: none; font-weight: 500; }
.link-btn.danger:hover, .link-btn.danger:focus-visible { color: var(--danger); text-decoration: underline; }
.next-class .btn:disabled {
  background: transparent; border: 1px solid rgba(195, 154, 69, .55); color: #D9C79E; opacity: 1; cursor: default;
}
.who span { color: var(--muted); }
.table td.muted { color: var(--muted); }
