/* ==========================================================
   Student portal + staff console (black and gold, like the site)
   ========================================================== */
:root {
  color-scheme: dark;
  --bg: #0a0a0c;
  --bg-alt: #111114;
  --surface: #16161a;
  --surface-2: #1d1d22;
  --line: #2a2a31;
  --line-soft: #202026;
  --text: #f6f3ec;
  --muted: #a9a59b;
  --gold: #f2b71e;
  --gold-hi: #ffe68a;
  --gold-grad: linear-gradient(180deg, #ffe68a 0%, #f2b71e 48%, #c48a0a 100%);
  --good: #4fd18b;
  --warn: #f2b71e;
  --low: #ff8f6b;
  --danger: #ff6b5b;
  --info: #6ea8ff;
  --display: "Archivo", "Arial Black", system-ui, sans-serif;
  --sans: "DM Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --radius: 14px;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.55 var(--sans); -webkit-font-smoothing: antialiased; }
[hidden] { display: none !important; }
h1, h2, h3 { font-family: var(--display); line-height: 1.15; margin: 0; }
h1 { font-size: clamp(1.6rem, 4vw, 2.2rem); font-weight: 800; }
h2 { font-size: 1.15rem; font-weight: 700; }
h3 { font-size: 1.05rem; font-weight: 700; }
p { margin: 0; }
a { color: inherit; }
.muted { color: var(--muted); font-size: .92rem; }
.fine { color: var(--muted); font-size: .82rem; }
.error { color: var(--danger); font-weight: 600; min-height: 1.2em; font-size: .92rem; }
.empty, .loading { color: var(--muted); padding: 18px; text-align: center; background: var(--surface); border: 1px dashed var(--line); border-radius: var(--radius); }
.notice { background: rgba(242,183,30,.08); border: 1px solid rgba(242,183,30,.4); color: var(--gold-hi); padding: 14px 16px; border-radius: var(--radius); }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }

/* ---------- controls ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; font: 700 .95rem/1 var(--sans); padding: .8em 1.2em; border-radius: 10px; border: 1px solid transparent; cursor: pointer; text-decoration: none; color: var(--text); white-space: nowrap; transition: transform .15s, border-color .2s, background .2s; }
.btn:hover { transform: translateY(-1px); }
.btn-gold { background: var(--gold-grad); color: #1a1204; }
.btn-ghost { background: var(--surface); border-color: var(--line); }
.btn-ghost:hover { border-color: var(--gold); }
.btn-danger { background: transparent; border-color: rgba(255,107,91,.5); color: var(--danger); }
.btn-sm { padding: .6em .9em; font-size: .88rem; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: .55; cursor: progress; transform: none; }
input, select, textarea { width: 100%; font: 400 1rem var(--sans); color: var(--text); background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: .7em .85em; }
select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23f2b71e' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; background-size: 16px; padding-right: 34px; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--gold); }
label { display: block; font-weight: 600; font-size: .88rem; margin: 10px 0 6px; }
.chip { display: inline-flex; align-items: center; gap: 6px; font-size: .82rem; font-weight: 700; padding: .4em .8em; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line); color: var(--gold-hi); text-decoration: none; }
.chip.waiting { color: var(--muted); }

/* ---------- sign in / sign up ---------- */
.gate { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px;
  background: radial-gradient(60% 50% at 50% 25%, rgba(242,183,30,.13), transparent 70%), var(--bg); }
.gate-card { width: min(560px, 100%); background: var(--surface); border: 1px solid var(--line); border-radius: 22px; padding: clamp(24px, 5vw, 38px); text-align: center; box-shadow: 0 30px 80px rgba(0,0,0,.5); }
.gate-card > img { margin: 0 auto 18px; display: block; height: auto; }
.gate-card h1 { font-size: 1.8rem; }
.tabs { display: flex; gap: 6px; background: var(--bg); border: 1px solid var(--line); border-radius: 999px; padding: 4px; margin: 22px 0 6px; }
.tab { flex: 1; font: 700 .95rem var(--sans); color: var(--muted); background: none; border: 0; border-radius: 999px; padding: .7em; cursor: pointer; }
.tab.is-active { background: var(--gold-grad); color: #1a1204; }
.gate-form { text-align: left; margin-top: 10px; }
.gate-form .row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.gate-form .btn { margin-top: 16px; }
.gate-form .fine { margin-top: 12px; text-align: center; }
.gate-done h2 { margin: 18px 0 8px; font-size: 1.4rem; }
.gate-done .btn { margin-top: 18px; }
.back { display: inline-block; margin-top: 20px; color: var(--muted); font-size: .88rem; }
@media (max-width: 520px) { .gate-form .row { grid-template-columns: 1fr; gap: 0; } }

/* ---------- app shell ---------- */
.topbar { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 12px 20px; background: rgba(10,10,12,.92); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line-soft); }
.brand img { object-fit: contain; height: auto; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; }
.brand span { display: flex; flex-direction: column; line-height: 1.15; }
.brand strong { font-family: var(--display); font-size: 1.05rem; }
.brand small { color: var(--gold); font-size: .8rem; font-weight: 600; }
.tabbar { display: flex; gap: 4px; padding: 10px 20px 0; border-bottom: 1px solid var(--line-soft); overflow-x: auto; }
.navtab { font: 700 .95rem var(--sans); color: var(--muted); background: none; border: 0; border-bottom: 2px solid transparent; padding: .7em 1em; cursor: pointer; white-space: nowrap; }
.navtab.is-active { color: var(--text); border-bottom-color: var(--gold); }
.view { max-width: 980px; margin: 0 auto; padding: 24px 20px 72px; display: flex; flex-direction: column; gap: 22px; }
.hello { font-size: clamp(1.7rem, 5vw, 2.4rem); }
.sub { margin-top: -12px; }
.back-link { align-self: flex-start; background: none; border: 0; color: var(--gold); font: 600 .95rem var(--sans); cursor: pointer; padding: 0; }

/* ---------- blocks and cards ---------- */
.block { display: flex; flex-direction: column; gap: 10px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; }
.row-card { display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.row-card h3 { margin-bottom: 2px; }
.link-card { text-decoration: none; transition: border-color .2s; }
.link-card:hover { border-color: var(--gold); }
.tiles { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.tile { background: var(--surface); border: 1px solid var(--line); border-top: 3px solid var(--gold); border-radius: var(--radius); padding: 14px 16px; display: flex; flex-direction: column; gap: 2px; }
.tile strong { font-family: var(--display); font-size: 1.9rem; line-height: 1; }
.tile span { color: var(--muted); font-size: .8rem; font-weight: 600; text-transform: uppercase; letter-spacing: .07em; }
@media (max-width: 760px) { .tiles { grid-template-columns: 1fr 1fr; } }

/* ---------- homework / exam cards ---------- */
.work { display: flex; flex-direction: column; gap: 12px; }
.work header h3 { margin-bottom: 2px; }
.instructions { white-space: pre-wrap; color: var(--text); font-size: .95rem; }
.work .chip { align-self: flex-start; }
.status { font-size: .9rem; font-weight: 600; }
.status.waiting { color: var(--warn); }
.submit { display: flex; flex-direction: column; gap: 10px; border-top: 1px dashed var(--line); padding-top: 12px; }
.filepick { display: flex; align-items: center; gap: 12px; margin: 0; background: var(--bg); border: 1px dashed var(--line); border-radius: 10px; padding: 12px 14px; cursor: pointer; }
.filepick span { font-weight: 600; font-size: .92rem; }
.filepick input { padding: 0; border: 0; background: none; font-size: .85rem; }
.submit-actions { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.mark { background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; display: flex; flex-direction: column; gap: 8px; }
.score { display: flex; align-items: baseline; gap: 10px; }
.score strong { font-family: var(--display); font-size: 1.5rem; }
.percent { font-weight: 700; font-size: .9rem; padding: .2em .6em; border-radius: 999px; }
.percent.good { color: var(--good); background: rgba(79,209,139,.12); }
.percent.ok { color: var(--warn); background: rgba(242,183,30,.12); }
.percent.low { color: var(--low); background: rgba(255,143,107,.12); }
.feedback { white-space: pre-wrap; font-size: .95rem; }

/* ---------- marks list ---------- */
.marks { display: flex; flex-direction: column; gap: 10px; }
.mark-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.mark-main { display: flex; flex-direction: column; gap: 4px; }
.mark-score { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; white-space: nowrap; }
.mark-score strong { font-family: var(--display); font-size: 1.2rem; }

/* ---------- chart ---------- */
.chart { position: relative; margin: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }
.chart-svg { width: 100%; height: auto; display: block; overflow: visible; }
.chart-svg .grid { stroke: var(--line); stroke-width: 1; }
.chart-svg .axis { fill: var(--muted); font: 11px var(--sans); }
.chart-svg .area { fill: rgba(242,183,30,.10); }
.chart-svg .line { fill: none; stroke: var(--gold); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart-svg .dot { fill: var(--gold); stroke: var(--surface); stroke-width: 2; }
.chart-svg .hit { fill: transparent; cursor: pointer; }
.chart-svg .point-label { fill: var(--gold-hi); font: 700 12px var(--sans); }
.chart-tip { position: absolute; transform: translate(-50%, -140%); background: var(--surface-2); border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; pointer-events: none; display: flex; flex-direction: column; font-size: .82rem; box-shadow: 0 8px 24px rgba(0,0,0,.5); white-space: nowrap; }
.chart-tip strong { font-family: var(--display); font-size: 1rem; color: var(--gold-hi); }

/* ---------- toast ---------- */
.toast { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); background: var(--surface-2); border: 1px solid var(--line); padding: 11px 16px; border-radius: 10px; z-index: 60; box-shadow: 0 10px 30px rgba(0,0,0,.45); font-weight: 600; max-width: calc(100% - 32px); }
.toast.good { border-color: rgba(79,209,139,.5); color: var(--good); }
.toast.bad { border-color: rgba(255,107,91,.5); color: var(--danger); }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* ---------- bell ---------- */
.bell { position: relative; display: grid; place-items: center; width: 40px; height: 40px; border-radius: 10px;
  background: var(--surface); border: 1px solid var(--line); color: var(--text); cursor: pointer; }
.bell:hover { border-color: var(--gold); }
.bell .ic { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.bell .badge { position: absolute; top: -6px; right: -6px; }
.badge { display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 6px;
  border-radius: 999px; background: var(--gold-grad); color: #1a1204; font: 700 .75rem var(--sans); }
.note.unread { border-left: 3px solid var(--gold); }
.topbar-actions { display: flex; align-items: center; gap: 8px; }

/* ---------- settings ---------- */
.switches { display: flex; flex-direction: column; gap: 4px; }
.switch-row { display: flex; align-items: flex-start; gap: 12px; margin: 0; padding: 12px 0; border-bottom: 1px solid var(--line-soft); cursor: pointer; }
.switch-row:last-child { border-bottom: 0; }
.switch-row input { width: 20px; height: 20px; margin-top: 2px; accent-color: var(--gold); flex: none; }
.switch-row span { display: flex; flex-direction: column; }
.switch-row small { color: var(--muted); font-size: .85rem; }
.fee-head, .fee-row { display: grid; grid-template-columns: 2fr 1fr 1fr auto; gap: 8px; align-items: center; }
.fee-head { color: var(--muted); font-size: .8rem; text-transform: uppercase; letter-spacing: .08em; margin-bottom: 6px; }
.fee-rows { display: flex; flex-direction: column; gap: 8px; margin-bottom: 10px; }
hr { border: 0; border-top: 1px dashed var(--line); margin: 16px 0; }

/* ---------- attendance ---------- */
.att-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.att-pick { display: flex; gap: 6px; flex-wrap: wrap; }
.att-btn { font: 600 .85rem var(--sans); padding: .45em .8em; border-radius: 999px; border: 1px solid var(--line);
  background: var(--bg); color: var(--muted); cursor: pointer; }
.att-btn.is-on { background: var(--gold-grad); border-color: transparent; color: #1a1204; }
.checkin-card { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.checkin-code { font-family: var(--display); font-size: 2rem; letter-spacing: .2em; color: var(--gold-hi); margin: 0; }
.checkin-row { display: flex; gap: 10px; align-items: center; }
.code-input { font-family: var(--display); font-size: 1.3rem; letter-spacing: .25em; text-align: center; max-width: 180px; }
.chip.att-present { color: var(--good); } .chip.att-late { color: var(--warn); }
.chip.att-absent { color: var(--low); } .chip.att-excused, .chip.att-none { color: var(--muted); }

/* ---------- profile ---------- */
.avatar { border-radius: 50%; object-fit: cover; border: 2px solid var(--gold); background: var(--surface-2); }
.avatar-text { display: grid; place-items: center; font-family: var(--display); font-weight: 800; color: var(--gold-hi); }
.profile-card { display: flex; align-items: center; gap: 18px; }

/* ---------- AI checker ---------- */
.question { display: flex; flex-direction: column; gap: 6px; }
.q-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.method { white-space: pre-wrap; font-size: .95rem; line-height: 1.6; }
.bubble { padding: 12px 14px; }
.bubble.from-me { background: var(--surface-2); margin-left: 24px; }
.bubble.from-ai { border-left: 3px solid var(--gold); }
/* Homework capture and feedback */
.submission-choices,.submission-tags,.scan-actions { display:flex; flex-wrap:wrap; gap:10px; align-items:center; }
.selected-file { font-weight:600; overflow-wrap:anywhere; }
.late,.appeal-status { color:var(--gold-hi); }
.work-feedback { margin-top:22px; padding-top:20px; border-top:1px solid var(--line); }
.work-feedback h3 { margin-bottom:12px; }
.work-feedback .ai-score { color:var(--gold-hi); font-weight:700; }
.feedback-question { margin:12px 0; border:1px solid var(--line); border-radius:12px; padding:14px; background:var(--surface); }
.feedback-question summary { cursor:pointer; font-weight:600; line-height:1.6; }
.feedback-question p { margin:10px 0; overflow-wrap:anywhere; }
.feedback-question textarea { margin:12px 0; }
.ai-explanation { white-space:pre-wrap; }
.ai-followup { margin:12px 0; padding:2px 0 2px 14px; border-left:3px solid var(--gold-hi); }
.deadline-info { margin-top:16px; }
.scan-dialog { background:var(--bg-alt,#111318); color:var(--text,#f4efe4); border:1px solid var(--line,#444); border-radius:18px; width:min(860px,96vw); max-height:92dvh; padding:24px; overflow:auto; }
.scan-dialog::backdrop { background:#000b; }
.scan-dialog video,.scan-crop { display:block; width:100%; max-height:55dvh; object-fit:contain; margin:16px 0; background:#08090b; }
.scan-crop { width:auto; max-width:100%; height:auto; max-height:none; touch-action:none; }
.scan-dialog [hidden] { display:none!important; }
.scan-actions { margin:16px 0; }
.scan-corners { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:10px; }
.scan-corners > div { display:flex; flex-wrap:wrap; align-items:center; gap:8px; }
.scan-corners span { width:100%; font-weight:600; }
.scan-corners label { display:flex; align-items:center; gap:6px; }
.scan-corners input { width:75px; }
.scan-pages { display:grid; grid-template-columns:repeat(auto-fit,minmax(140px,1fr)); gap:16px; }
.scan-pages > div { padding:12px; border:1px solid var(--line,#444); border-radius:12px; display:flex; flex-direction:column; gap:8px; }
.scan-pages img { width:100%; height:160px; object-fit:contain; background:white; }
@media(max-width:600px) { .scan-dialog {padding:16px} .scan-corners {grid-template-columns:1fr} }

/* ---------- progress bars: uploads, compression, imports ---------- */
.progress { display: grid; gap: 6px; margin: 12px 0; }
.progress-track { position: relative; display: block; height: 10px; border-radius: 99px; background: var(--surface-2); border: 1px solid var(--line); overflow: hidden; }
.progress-fill {
  position: absolute; inset: 0 auto 0 0; width: 0; border-radius: inherit;
  background: var(--gold-grad);
  transition: width .25s ease-out;
}
/* moving stripes while it works, so a slow stretch still looks alive */
.progress-fill::after {
  content: ""; position: absolute; inset: 0;
  background: repeating-linear-gradient(-45deg, rgba(255,255,255,.28) 0 8px, transparent 8px 16px);
  background-size: 22.6px 22.6px;
  animation: progress-stripes .8s linear infinite;
}
.progress-text { font-size: .85rem; color: var(--muted); font-variant-numeric: tabular-nums; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.progress.is-done .progress-fill { background: var(--good); }
.progress.is-done .progress-fill::after, .progress.is-failed .progress-fill::after { animation: none; background: none; }
.progress.is-done .progress-text { color: var(--good); }
.progress.is-failed .progress-fill { background: var(--danger); }
.progress.is-failed .progress-text { color: var(--danger); }
@keyframes progress-stripes { to { background-position: 22.6px 0; } }
@media (prefers-reduced-motion: reduce) { .progress-fill::after { animation: none; } }

/* ---------- joining online lessons ---------- */
.online-card { display: grid; gap: 6px; }
.online-card.is-live { border-color: var(--gold); box-shadow: 0 0 0 1px rgba(242,183,30,.35); }
.online-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.online-in-class { display: grid; gap: 10px; margin: 16px 0; }
.zoom-name { background: var(--surface-2); border: 1px dashed var(--line); border-radius: var(--radius); padding: 12px 14px; }
.zoom-name .fine { margin: 4px 0; }
.zoom-name-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.zoom-name-row strong { font-family: var(--display); color: var(--gold-hi); overflow-wrap: anywhere; }

/* ---------- full-screen layers: attendance QR and camera ---------- */
.overlay { position: fixed; inset: 0; z-index: 1000; background: var(--bg); display: flex; flex-direction: column; overflow: auto; }
.overlay-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 14px 16px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--bg); }
.overlay-head h2 { font-size: 1.1rem; }
.overlay-body { flex: 1; display: grid; align-content: start; justify-items: center; gap: 14px; padding: 20px 16px 32px; text-align: center; }
.qr-big svg { width: min(78vmin, 520px); height: auto; border-radius: 16px; display: block; }
.qr-timer { width: min(78vmin, 520px); height: 6px; border-radius: 99px; background: var(--surface-2); overflow: hidden; }
.qr-timer span { display: block; height: 100%; width: 100%; background: var(--gold-grad); }
.qr-count { font-family: var(--display); font-size: 1.6rem; color: var(--gold-hi); margin: 0; }
.qr-code-text { font-family: var(--display); font-size: 1.4rem; letter-spacing: .08em; color: var(--gold-hi); margin: 0; }
.scan-video { width: min(92vw, 520px); aspect-ratio: 3 / 4; object-fit: cover; border-radius: 16px; background: #000; }
.scan-log { list-style: none; margin: 0; padding: 0; width: min(92vw, 520px); display: grid; gap: 6px; text-align: left; }
.scan-log li { padding: 10px 12px; border-radius: 10px; background: var(--surface); border: 1px solid var(--line); }
.scan-log li.ok { border-color: rgba(79,209,139,.5); color: var(--good); }
.scan-log li.bad { border-color: rgba(255,107,91,.5); color: var(--danger); }
@media (prefers-reduced-motion: reduce) { .qr-timer span { transition: none !important; } }
.player { width: min(96vw, 1100px); max-height: 78vh; border-radius: 12px; background: #000; }
/* the protected player: the student's name drifting over the video, and a faint repeated copy */
.player-wrap { position: relative; width: min(96vw, 1100px); border-radius: 12px; overflow: hidden; background: #000; -webkit-user-select: none; user-select: none; }
.player-wrap .player { display: block; width: 100%; border-radius: 0; }
.wm-moving { position: absolute; z-index: 2; pointer-events: none; max-width: 70%; padding: 2px 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  font: 600 clamp(11px, 1.6vw, 16px)/1.3 system-ui, sans-serif; color: rgba(255, 255, 255, .6); text-shadow: 0 0 3px rgba(0, 0, 0, .9);
  transition: left 1.5s ease, top 1.5s ease; }
.wm-tiled { position: absolute; inset: -25%; z-index: 1; pointer-events: none; display: flex; flex-wrap: wrap; align-content: space-around; justify-content: space-around;
  gap: 56px 72px; transform: rotate(-24deg); opacity: .12; overflow: hidden; }
.wm-tiled span { font: 600 13px system-ui, sans-serif; color: #fff; white-space: nowrap; }
/* full screen via the Full screen button: the wrapper (with the name) fills the screen */
.player-wrap:fullscreen { width: 100vw; height: 100vh; border-radius: 0; display: flex; align-items: center; }
.player-wrap:-webkit-full-screen { width: 100vw; height: 100vh; border-radius: 0; display: flex; align-items: center; }
.player-wrap:fullscreen .player { height: 100%; max-height: none; }
.player-wrap:-webkit-full-screen .player { height: 100%; max-height: none; }
/* where a page can't go full screen (iPhone), the player fills the window, name and all */
.player-wrap.filled { position: fixed; inset: 0; z-index: 3000; width: 100vw; height: 100vh; height: 100dvh; border-radius: 0; display: flex; align-items: center; }
.player-wrap.filled .player { height: 100%; max-height: none; }
/* the protected player's own controls (portal-common.js protectedControls): the browser's are off */
.pc-bar { position: absolute; left: 0; right: 0; bottom: 0; z-index: 3; display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
  padding: 18px 10px 8px; background: linear-gradient(transparent, rgba(0, 0, 0, .78)); }
.pc-btn { min-width: 40px; height: 34px; padding: 0 10px; border: 0; border-radius: 8px; background: rgba(255, 255, 255, .16); color: #fff;
  font: 600 13px system-ui, sans-serif; cursor: pointer; }
.pc-btn:hover, .pc-btn:focus-visible { background: rgba(255, 255, 255, .28); }
.pc-time { color: #fff; font: 500 13px system-ui, sans-serif; font-variant-numeric: tabular-nums; white-space: nowrap; }
.pc-seek { flex: 1 1 140px; width: auto; min-width: 100px; padding: 0; border: 0; background: none; accent-color: var(--gold); }
.pc-speed { width: auto; padding: 6px 8px; border: 0; border-radius: 8px; background: rgba(255, 255, 255, .16); color: #fff; font: 600 13px system-ui, sans-serif; }
.pc-speed option { color: #000; }
.player-wrap:focus { outline: none; }
.player-wrap:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
.row-card.locked { opacity: .92; flex-wrap: wrap; } /* the access form drops below the title on a phone */
.row-card.locked h3::before { content: "🔒 "; }
.ask-access { display: grid; gap: 8px; min-width: min(320px, 100%); }

/* ---------- AI explanations: maths, steps, mark schemes, topics ---------- */
.q-part { margin: 10px 0; }
.q-part > .fine { margin: 0 0 4px; text-transform: uppercase; letter-spacing: .06em; font-size: .72rem; }
.steps-list { margin: 0; padding-left: 22px; display: grid; gap: 6px; line-height: 1.6; }
.math-block { display: block; overflow-x: auto; overflow-y: hidden; padding: 4px 0; }
.katex { font-size: 1.08em; }
.topic-chip { justify-self: start; margin: 4px 0; }
.practice-request { margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--line); display: grid; gap: 8px; }
.practice-request h4, .practice-request-history p { margin: 0 0 6px; }
.practice-request-history { display: grid; gap: 8px; }
.practice-request textarea { width: 100%; }
.practice-feedback { margin: 16px 0; }
.practice-feedback .btn { display: inline-block; }
.topic-row { display: grid; grid-template-columns: minmax(120px, 1fr) 2fr auto; gap: 12px; align-items: center; }
.topic-bar { height: 8px; border-radius: 99px; background: var(--surface-2); overflow: hidden; }
.topic-bar span { display: block; height: 100%; border-radius: inherit; }
.topic-bar .low { background: var(--danger); } .topic-bar .ok { background: var(--warn); } .topic-bar .good { background: var(--good); }
@media (max-width: 560px) { .topic-row { grid-template-columns: 1fr auto; } .topic-row .topic-bar { grid-column: 1 / -1; } }

.question.teacher-updated { border: 2px solid var(--gold); box-shadow: inset 4px 0 var(--gold); }
.teacher-update-label { color: var(--gold); font-weight: 700; margin: 0 0 12px; }
/* "The website was updated. Reload" (portal-live.js) */
.update-banner { position: fixed; left: 50%; bottom: 16px; transform: translateX(-50%); z-index: 2000; display: flex; align-items: center; gap: 12px;
  max-width: calc(100% - 32px); padding: 10px 14px; background: var(--bg); border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 8px 28px rgba(0, 0, 0, .45); }
/* Long lists kept short: a search box, the first rows and "Show more" (portal-common.js shortList) */
.short-list-search { max-width: 460px; margin: 4px 0 10px; }
.short-list .row-end { margin-top: 6px; }
/* a timed mock exam on the student class page (student.js timedExamCard) */
.timed-exam { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; margin-top: 8px; }
.exam-modes { display: grid; grid-template-columns: auto 1fr; gap: 8px 12px; align-items: center; }
.exam-modes .fine { margin: 0; }
@media (max-width: 560px) { .exam-modes { grid-template-columns: 1fr; } }
/* Uploads that carry on in the background (uploads.js): a corner panel above the drawer (40),
   below toasts (60) and full-screen layers */
/* bottom left: the drawer opens on the right and the tray must not cover its buttons */
.upload-tray { position: fixed; left: 16px; bottom: 16px; z-index: 50; width: min(360px, calc(100% - 32px)); max-height: min(60vh, 520px);
  display: flex; flex-direction: column; background: var(--bg-alt); border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 12px 36px rgba(0, 0, 0, .5); }
.upload-tray-head { display: flex; align-items: center; gap: 10px; padding: 10px 12px; }
.upload-tray-head strong { font-family: var(--display); font-size: .95rem; }
.upload-tray-sum { flex: 1; min-width: 0; color: var(--muted); font-size: .82rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.upload-tray-list { overflow: auto; padding: 0 12px 6px; border-top: 1px solid var(--line-soft); }
.upload-row { padding: 10px 0; border-bottom: 1px solid var(--line-soft); }
.upload-row:last-child { border-bottom: 0; }
.upload-label { margin: 0; font-weight: 700; font-size: .9rem; overflow-wrap: anywhere; }
.upload-row .progress { margin: 6px 0 4px; }
.upload-row .progress-text { display: none; }
.upload-status { margin: 0; color: var(--muted); font-size: .82rem; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.upload-row.is-failed .upload-status { color: var(--danger); }
.upload-row.is-done .upload-status { color: var(--good); }
.upload-spoken { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; }
.upload-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; margin-top: 6px; }
.upload-actions:empty { display: none; }
@media (max-width: 560px) {
  .upload-tray { left: 8px; right: 8px; bottom: 8px; width: auto; max-height: 45vh; }
  .upload-tray-head { padding: 8px 10px; }
  .upload-tray-list { padding: 0 10px 4px; }
  .upload-row { padding: 8px 0; }
}

/* ---------- the Help button and its chat (js/help-chat.js): bottom right, under drawers and overlays ---------- */
.help-fab { position: fixed; right: 16px; bottom: 16px; z-index: 25; min-width: 64px; height: 48px; padding: 0 18px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--gold-grad); color: #1a1204; font: 800 .95rem/1 var(--sans); cursor: pointer;
  box-shadow: 0 10px 30px rgba(0,0,0,.45); }
.help-fab[aria-expanded="true"] { background: var(--surface-2); color: var(--text); }
.help-panel { position: fixed; right: 16px; bottom: 76px; z-index: 26; width: min(380px, calc(100% - 32px)); height: min(70vh, 560px);
  display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: 0 16px 40px rgba(0,0,0,.55); overflow: hidden; }
.help-head { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-bottom: 1px solid var(--line-soft); }
.help-title { flex: 1; font-family: var(--display); font-size: 1rem; }
.help-list { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 12px; display: flex; flex-direction: column; gap: 8px; }
.help-msg { max-width: 88%; padding: 8px 12px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--line-soft); }
.help-msg p { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; font-size: .93rem; }
.help-user { align-self: flex-end; background: rgba(242,183,30,.14); border-color: rgba(242,183,30,.35); }
.help-assistant { align-self: flex-start; }
.help-pending { opacity: .75; }
.help-wait p { color: var(--muted); font-style: italic; }
.help-error, .help-notice { border-color: rgba(255,143,107,.45); }
.help-error p, .help-notice p { color: var(--low); }
.help-note { margin: 0; padding: 6px 12px; color: var(--muted); font-size: .75rem; border-top: 1px solid var(--line-soft); }
.help-form { padding: 8px 12px 12px; display: grid; gap: 6px; }
.help-input { width: 100%; resize: none; min-height: 44px; max-height: 120px; padding: 8px 10px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--bg-alt); color: var(--text); font: inherit; font-size: .95rem; }
.help-form-row { display: flex; align-items: center; gap: 8px; }
.help-left { flex: 1; margin: 0; color: var(--muted); font-size: .78rem; }
@media (max-width: 560px) {
  .help-fab { right: 8px; bottom: 8px; }
  .help-panel { left: 8px; right: 8px; bottom: 64px; width: auto; height: min(72vh, 560px); }
}
/* Up to 800px wide the Uploads box (bottom left) and the open chat (bottom right) would overlap, and on a phone
   the box spans the bottom of the screen: while the box shows, it stays under 45% of the height and the button
   and chat sit above it */
@media (max-width: 800px) {
  .upload-tray { max-height: 45vh; }
  body:has(.upload-tray:not([hidden])) .help-fab { bottom: calc(45vh + 16px); }
  body:has(.upload-tray:not([hidden])) .help-panel { bottom: calc(45vh + 72px); height: min(40vh, 420px); }
}
@media print { .help-fab, .help-panel { display: none !important; } }
