/* Classroom design tokens. Components use these, never raw colours. */
:root {
  --bg: #faf8f4;
  --surface: #ffffff;
  --surface-2: #f4f1ea;
  --ink: #1d2133;
  --muted: #565c70;
  --line: #e6e1d6;
  --line-strong: #cfc8b9;

  --primary: #1d4ed8;
  --primary-hover: #1e40af;
  --primary-soft: #eaf0fe;
  --on-primary: #ffffff;
  --accent: #f2b33d;
  --accent-soft: #fff4da;
  --accent-ink: #6b4500;

  --success: #17704b;
  --success-soft: #e2f3ea;
  --danger: #b42318;
  --danger-soft: #fdecea;
  --warn: #7a4f00;
  --warn-soft: #fff4da;

  --indigo: #3940b8;  --indigo-soft: #ecedfb;
  --teal: #0f6e6e;    --teal-soft: #ddf2f0;
  --coral: #b4441f;   --coral-soft: #fde9e1;
  --amber: #7a4f00;   --amber-soft: #fff1cf;
  --violet: #6b3fb0;  --violet-soft: #f1eafc;
  --green: #2f6b1f;   --green-soft: #e6f3dc;

  --radius-sm: 8px;
  --radius: 14px;
  --radius-lg: 22px;
  --shadow: 0 1px 2px rgb(29 33 51 / .05), 0 6px 20px rgb(29 33 51 / .06);
  --shadow-lg: 0 2px 4px rgb(29 33 51 / .05), 0 18px 48px rgb(29 33 51 / .10);
  --ease-out: cubic-bezier(.2, .8, .2, 1);

  --font-head: "Lexend", ui-sans-serif, system-ui, sans-serif;
  --font-body: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans Sinhala", "Noto Sans Tamil", sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.6 var(--font-body); min-height: 100dvh; display: flex; flex-direction: column; }
main { flex: 1; }
a { color: var(--primary); text-underline-offset: 3px; }
img { max-width: 100%; display: block; }
h1, h2, h3, h4 { font-family: var(--font-head); line-height: 1.2; margin: 0 0 .4em; letter-spacing: -.01em; text-wrap: balance; }
h1 { font-size: clamp(30px, 5vw, 46px); font-weight: 700; }
h2 { font-size: clamp(22px, 3vw, 30px); font-weight: 650; }
h3 { font-size: 19px; font-weight: 600; }
h4 { font-size: 16px; font-weight: 600; }
p { margin: 0 0 1em; }
.wrap { width: 100%; max-width: 1440px; margin: 0 auto; padding: 0 clamp(20px, 4vw, 56px); }
.narrow { max-width: 720px; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.tiny { font-size: 13px; }
.num { font-variant-numeric: tabular-nums; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.skip { position: absolute; left: 12px; top: -60px; background: var(--ink); color: #fff; padding: 10px 14px; border-radius: var(--radius-sm); z-index: 100; }
.skip:focus { top: 12px; }
:focus-visible { outline: 3px solid var(--primary); outline-offset: 2px; border-radius: 4px; }
.icon { width: 20px; height: 20px; flex-shrink: 0; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.icon.sm { width: 16px; height: 16px; }
.icon.lg { width: 28px; height: 28px; }
.stack > * + * { margin-top: 16px; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.spread { display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.grid-2 { display: grid; gap: 20px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 340px), 1fr)); }
.section { padding: 56px 0; }
.section-tight { padding: 32px 0; }
.eyebrow { font: 600 13px/1 var(--font-body); letter-spacing: .08em; text-transform: uppercase; color: var(--primary); margin-bottom: 10px; }

/* ---------- Top bar ---------- */
.topbar { position: sticky; top: 0; z-index: 20; background: rgb(250 248 244 / .92); backdrop-filter: saturate(1.4) blur(10px); border-bottom: 1px solid var(--line); }
.topbar-inner { display: flex; align-items: center; gap: 16px; min-height: 64px; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); font: 650 18px/1.1 var(--font-head); margin-right: auto; min-width: 0; }
.brand-mark { width: 36px; height: 36px; border-radius: 11px; background: var(--primary); color: var(--on-primary); display: grid; place-items: center; flex-shrink: 0; }
.brand-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.brand small { display: block; font: 500 12px/1.2 var(--font-body); color: var(--muted); }
.nav { display: flex; align-items: center; gap: 4px; }
.nav a, .nav button.link { display: inline-flex; align-items: center; gap: 6px; padding: 10px 12px; border-radius: 10px; color: var(--muted); text-decoration: none; font-weight: 500; font-size: 15px; min-height: 44px; }
.nav a:hover { color: var(--ink); background: var(--surface-2); }
.nav a[aria-current="page"] { color: var(--ink); background: var(--surface-2); font-weight: 600; }
.bell { position: relative; }
.badge-dot { position: absolute; top: 6px; right: 6px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 99px; background: var(--danger); color: #fff; font: 700 11px/18px var(--font-body); text-align: center; }
.menu-toggle { display: none; }
@media (max-width: 760px) {
  .menu-toggle { display: inline-flex; }
  .nav { display: none; position: absolute; left: 0; right: 0; top: 64px; background: var(--surface); border-bottom: 1px solid var(--line); flex-direction: column; align-items: stretch; padding: 8px 12px 14px; box-shadow: var(--shadow); }
  .nav.open { display: flex; }
  .nav .btn { justify-content: center; }
}

/* ---------- Buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 10px 18px; border-radius: 12px; border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink); font: 600 15px/1.2 var(--font-body); text-decoration: none; cursor: pointer; transition: background .15s, border-color .15s, transform .1s var(--ease-out); touch-action: manipulation; }
.btn:hover { border-color: var(--ink); }
.btn:active { transform: scale(.98); }
.btn-primary { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.btn-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn-accent { background: var(--accent); border-color: var(--accent); color: var(--ink); }
.btn-accent:hover { background: #e6a52d; border-color: #e6a52d; }
.btn-success { background: var(--success); border-color: var(--success); color: #fff; }
.btn-danger-ghost { color: var(--danger); border-color: transparent; background: transparent; }
.btn-danger-ghost:hover { background: var(--danger-soft); border-color: transparent; }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-ghost:hover { background: var(--surface-2); border-color: transparent; }
.btn-lg { min-height: 52px; padding: 14px 24px; font-size: 16px; border-radius: 14px; }
.btn-sm { min-height: 36px; padding: 6px 12px; font-size: 14px; border-radius: 10px; }
.btn-block { width: 100%; }
.btn[disabled], .btn[aria-disabled="true"] { opacity: .45; cursor: not-allowed; pointer-events: none; }
.btn.loading { opacity: .7; pointer-events: none; }
form.inline { display: inline; }

/* ---------- Flash ---------- */
.flash { display: flex; gap: 10px; align-items: flex-start; padding: 14px 16px; border-radius: var(--radius); margin: 20px 0 0; border: 1px solid; font-weight: 500; }
.flash-success { background: var(--success-soft); border-color: #b5dfc8; color: var(--success); }
.flash-error { background: var(--danger-soft); border-color: #f5c2bd; color: var(--danger); }
.flash-info { background: var(--primary-soft); border-color: #cdd0f4; color: var(--primary); }
.flash p { margin: 0; color: var(--ink); }

/* ---------- Cards ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 24px; box-shadow: var(--shadow); }
.card-flat { box-shadow: none; }
.card h3:first-child, .card h2:first-child { margin-top: 0; }
.card-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.card-head h2, .card-head h3 { margin: 0; }
.divider { border: 0; border-top: 1px solid var(--line); margin: 20px 0; }

/* ---------- Chips and badges ---------- */
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 99px; font: 600 13px/1.4 var(--font-body); background: var(--surface-2); color: var(--muted); white-space: nowrap; }
.chip-indigo { background: var(--indigo-soft); color: var(--indigo); }
.chip-teal { background: var(--teal-soft); color: var(--teal); }
.chip-coral { background: var(--coral-soft); color: var(--coral); }
.chip-amber { background: var(--amber-soft); color: var(--amber); }
.chip-violet { background: var(--violet-soft); color: var(--violet); }
.chip-green { background: var(--green-soft); color: var(--green); }
.status { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 99px; font: 600 13px/1.5 var(--font-body); white-space: nowrap; }
.status::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.status-paid, .status-active { background: var(--success-soft); color: var(--success); }
.status-review, .status-pending, .status-leaving { background: var(--warn-soft); color: var(--warn); }
.status-open, .status-failed { background: var(--danger-soft); color: var(--danger); }
.status-void, .status-cancelled, .status-off { background: var(--surface-2); color: var(--muted); }

/* ---------- Hero ---------- */
.hero { padding: 28px 0 56px; position: relative; }
.hero-grid { display: grid; gap: 48px; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-items: center; }
@media (max-width: 860px) { .hero-grid { grid-template-columns: 1fr; } }
.hero h1 .hl { background: linear-gradient(transparent 62%, var(--accent-soft) 62%); padding: 0 4px; }
.hero-lead { font-size: 19px; color: var(--muted); max-width: 560px; }
.hero-cta { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 24px; }
.hero-facts { display: flex; gap: 28px; flex-wrap: wrap; margin-top: 24px; }
.hero-facts div { display: grid; }
.hero-facts strong { font: 700 26px/1.1 var(--font-head); }
.hero-facts span { color: var(--muted); font-size: 14px; }
.hero-photo { position: relative; justify-self: end; width: min(100%, 520px); }

.hero-photo > img { display: block; width: 100%; height: auto; aspect-ratio: 860 / 740; max-height: 440px; object-fit: cover; object-position: center top; border-radius: 28px; background: var(--surface-2); }
.teacher-card { position: absolute; left: -150px; bottom: -132px; width: 560px; background: rgb(255 255 255 / .96); border: 1px solid var(--line); border-radius: 20px; padding: 10px 18px 14px; box-shadow: var(--shadow-lg); }
.tc-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-bottom: 8px; margin-bottom: 10px; border-bottom: 1px solid var(--line); }
.tc-head h3 { margin: 0; font-size: 16px; }
.tc-head h3 span { font: 500 13px var(--font-body); }
.tc-head p { margin: 0; }
.creds { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 20px; }
.creds h4 { margin: 0 0 6px; font: 700 11px/1.4 var(--font-body); text-transform: uppercase; letter-spacing: .06em; color: var(--primary); }
.creds ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.creds li { display: grid; font-size: 12.5px; line-height: 1.35; }
.creds li strong { font-weight: 600; color: var(--ink); }
.creds li span { color: var(--muted); }
.creds-sm { display: none; }
.about-me { display: flow-root; }
.about-photo { float: left; width: 190px; height: auto; aspect-ratio: 4 / 5; object-fit: cover; object-position: center 15%; border-radius: 20px; margin: 4px 28px 12px 0; }
.about-me .row { clear: both; padding-top: 4px; }
@media (max-width: 860px) {
  .hero-photo { justify-self: center; width: min(100%, 360px); margin-bottom: 0; }
  .teacher-card { position: relative; left: auto; bottom: auto; width: auto; margin: -36px 16px 0; padding: 12px 16px; }
  .teacher-card .tc-head { border: 0; padding: 0; margin: 0; }
  .teacher-card .creds, .hero-facts { display: none; }
  .tc-head h3 span { display: none; }
  .hero { padding-bottom: 8px; }
  .creds-sm { display: block; margin: 16px 0; clear: both; }
  .creds-sm .creds { grid-template-columns: 1fr; gap: 16px; }
  .creds-sm .creds li { font-size: 14px; }
  .hero-photo > img { aspect-ratio: 4 / 3; max-height: 280px; }
  .about-photo { width: 110px; margin-right: 18px; }
}
.avatar { width: 84px; height: 84px; border-radius: 24px; background: var(--primary-soft); color: var(--primary); display: grid; place-items: center; font: 700 30px/1 var(--font-head); overflow: hidden; flex-shrink: 0; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar.sm { width: 44px; height: 44px; border-radius: 14px; font-size: 16px; }
.checklist { list-style: none; padding: 0; margin: 16px 0 0; display: grid; gap: 10px; }
.checklist li { display: flex; gap: 10px; align-items: flex-start; }
.checklist .icon { color: var(--success); margin-top: 3px; }

/* ---------- Class finder ---------- */
.filters { display: flex; gap: 8px; flex-wrap: wrap; margin: 20px 0 24px; }
.filter { min-height: 44px; padding: 8px 18px; border-radius: 99px; border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink); font: 600 15px/1 var(--font-body); cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; }
.filter[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: #fff; }
.classes { display: grid; gap: 20px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 340px), 1fr)); }
.class-card { display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); overflow: hidden; box-shadow: var(--shadow); transition: transform .2s var(--ease-out), box-shadow .2s var(--ease-out); }
.class-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.class-top { padding: 22px 22px 16px; border-bottom: 1px solid var(--line); }
.class-top h3 { margin: 10px 0 6px; font-size: 21px; }
.class-top h3 a { color: inherit; text-decoration: none; }
.class-top h3 a:hover { text-decoration: underline; }
.price { font: 700 24px/1 var(--font-head); }
.price small { font: 500 14px var(--font-body); color: var(--muted); }
.groups { display: grid; padding: 8px 10px 12px; }
.group-row { display: grid; grid-template-columns: 1fr auto; gap: 6px 12px; align-items: center; padding: 12px; border-radius: 14px; }
.group-row + .group-row { border-top: 1px dashed var(--line); border-radius: 0 0 14px 14px; }
.group-name { font-weight: 600; }
.group-when { display: flex; gap: 6px; align-items: center; color: var(--muted); font-size: 14px; }
.places { font-size: 13px; color: var(--muted); display: flex; align-items: center; gap: 8px; }
.meter { height: 6px; width: 72px; border-radius: 99px; background: var(--surface-2); overflow: hidden; }
.meter span { display: block; height: 100%; background: var(--success); border-radius: inherit; }
.meter.warn span { background: var(--accent); }
.meter.full span { background: var(--danger); }
.empty { text-align: center; padding: 48px 20px; border: 2px dashed var(--line-strong); border-radius: var(--radius-lg); color: var(--muted); }

/* ---------- Steps, FAQ, contact ---------- */
.steps { display: grid; gap: 20px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 240px), 1fr)); counter-reset: step; }
.step { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 24px; }
.step-num { width: 40px; height: 40px; border-radius: 12px; background: var(--accent-soft); color: var(--accent-ink); display: grid; place-items: center; font: 700 18px/1 var(--font-head); margin-bottom: 14px; }
.band { background: var(--surface); border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.pay-methods { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr)); }
.pay-method { display: flex; gap: 14px; align-items: flex-start; padding: 18px; border-radius: var(--radius); background: var(--surface-2); }
.pay-method .icon-wrap { width: 44px; height: 44px; border-radius: 12px; background: var(--surface); display: grid; place-items: center; color: var(--primary); flex-shrink: 0; }
details.faq { border-bottom: 1px solid var(--line); padding: 4px 0; }
details.faq summary { cursor: pointer; list-style: none; display: flex; justify-content: space-between; gap: 12px; align-items: center; padding: 14px 0; font: 600 17px/1.4 var(--font-head); min-height: 44px; }
details.faq summary::-webkit-details-marker { display: none; }
details.faq summary .icon { transition: transform .2s var(--ease-out); }
details.faq[open] summary .icon { transform: rotate(45deg); }
details.faq p { color: var(--muted); }

/* ---------- Forms ---------- */
.form { display: grid; gap: 18px; }
.form-row { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 200px), 1fr)); }
.field { display: grid; gap: 6px; align-content: start; }
.field > label, .label { font-weight: 600; font-size: 15px; }
.field .hint { font-size: 14px; color: var(--muted); margin: 0; }
.field .error { font-size: 14px; color: var(--danger); font-weight: 500; margin: 0; display: flex; gap: 6px; align-items: center; }
.input, select.input, textarea.input { width: 100%; min-height: 46px; padding: 10px 14px; border-radius: 12px; border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink); font: 16px/1.4 var(--font-body); transition: border-color .15s, box-shadow .15s; }
textarea.input { min-height: 110px; resize: vertical; }
.input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 4px var(--primary-soft); }
.input[aria-invalid="true"] { border-color: var(--danger); }
fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }
legend { font-weight: 600; margin-bottom: 8px; padding: 0; }
.choice { display: flex; gap: 14px; align-items: flex-start; padding: 16px; border: 1.5px solid var(--line-strong); border-radius: var(--radius); cursor: pointer; background: var(--surface); transition: border-color .15s, background .15s; }
.choice + .choice { margin-top: 10px; }
.choice:has(input:checked) { border-color: var(--primary); background: var(--primary-soft); }
.choice input { margin-top: 4px; width: 20px; height: 20px; accent-color: var(--primary); flex-shrink: 0; }
.choice strong { display: block; }
.choice span { color: var(--muted); font-size: 14px; }
.switch { display: flex; gap: 12px; align-items: center; cursor: pointer; min-height: 44px; }
.switch input { width: 20px; height: 20px; accent-color: var(--primary); }
.reveal { margin-top: 14px; padding: 18px; border-radius: var(--radius); background: var(--surface-2); }
.card-input { letter-spacing: .06em; font-variant-numeric: tabular-nums; }
.secure-note { display: flex; gap: 8px; align-items: center; font-size: 13px; color: var(--muted); }

/* ---------- Auth ---------- */
.auth { padding: 48px 0 64px; }
.auth .card { max-width: 560px; margin: 0 auto; }
.auth-split { display: grid; grid-template-columns: minmax(0, 560px) minmax(0, 420px); gap: 48px; justify-content: center; align-items: start; }
.auth-split .card { margin: 0; }
.auth-photo { margin: 0; position: sticky; top: 96px; }
.auth-photo img { display: block; width: 100%; height: auto; border-radius: 24px; }
.auth-photo figcaption { margin-top: 12px; color: var(--muted); font-size: 15px; }
@media (max-width: 960px) { .auth-split { grid-template-columns: minmax(0, 560px); } .auth-photo { display: none; } }
.auth-switch { text-align: center; margin-top: 18px; color: var(--muted); }

/* ---------- Checkout ---------- */
.checkout { display: grid; gap: 28px; grid-template-columns: 1fr 360px; align-items: start; padding: 32px 0 64px; }
@media (max-width: 900px) { .checkout { grid-template-columns: 1fr; } .checkout .summary { order: -1; } }
.summary { position: sticky; top: 84px; }
.summary dl { display: grid; grid-template-columns: auto 1fr; gap: 8px 16px; margin: 16px 0; }
.summary dt { color: var(--muted); }
.summary dd { margin: 0; text-align: right; font-weight: 600; }
.total { display: flex; justify-content: space-between; align-items: baseline; padding-top: 14px; border-top: 1px solid var(--line); font: 700 22px var(--font-head); }
.bank-box { display: grid; grid-template-columns: auto 1fr; gap: 8px 16px; padding: 18px; background: var(--surface); border: 1px dashed var(--line-strong); border-radius: var(--radius); }
.bank-box dt { color: var(--muted); }
.bank-box dd { margin: 0; font-weight: 600; overflow-wrap: anywhere; }
.copy { margin-left: 6px; }

/* ---------- Student area ---------- */
.page-head { padding: 36px 0 8px; }
.page-head p { color: var(--muted); margin: 0; }
.next-class { display: grid; gap: 20px; grid-template-columns: 1fr auto; align-items: center; background: var(--primary); color: var(--on-primary); border-radius: 26px; padding: 28px; box-shadow: var(--shadow-lg); margin-top: 24px; position: relative; overflow: hidden; }
.next-class::after { content: ""; position: absolute; right: -40px; bottom: -60px; width: 220px; height: 220px; border-radius: 50%; background: rgb(255 255 255 / .07); }
.next-class .eyebrow { color: var(--accent); }
.next-class h2 { color: #fff; margin-bottom: 6px; }
.next-class p { color: rgb(255 255 255 / .82); margin: 0; }
.next-class .btn { position: relative; z-index: 1; }
.next-class.locked { background: var(--surface); color: var(--ink); border: 1px solid var(--line); }
.next-class.locked h2 { color: var(--ink); }
.next-class.locked p { color: var(--muted); }
.next-class.locked .eyebrow { color: var(--danger); }
@media (max-width: 640px) { .next-class { grid-template-columns: 1fr; } }
.my-classes { display: grid; gap: 16px; }
.my-class { display: grid; grid-template-columns: 1fr auto; gap: 16px; align-items: center; padding: 20px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); }
@media (max-width: 640px) { .my-class { grid-template-columns: 1fr; } }
.my-class h3 { margin: 6px 0 4px; }
.lock-note { display: flex; gap: 8px; align-items: flex-start; font-size: 14px; color: var(--danger); font-weight: 500; margin-top: 8px; }
.lock-note.warn { color: var(--warn); }
.actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.notes { list-style: none; margin: 0; padding: 0; }
.notes li { display: flex; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.notes li:last-child { border-bottom: 0; }
.notes .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--primary); margin-top: 9px; flex-shrink: 0; }
.notes .read .dot { background: var(--line-strong); }
.notes p { margin: 0; font-size: 15px; }
.notes small { color: var(--muted); }
.two-col { display: grid; gap: 24px; grid-template-columns: 1.6fr 1fr; align-items: start; margin: 28px 0 64px; }
@media (max-width: 900px) { .two-col { grid-template-columns: 1fr; } }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
table { width: 100%; border-collapse: collapse; font-size: 15px; }
th { text-align: left; font: 600 13px/1.4 var(--font-body); color: var(--muted); text-transform: uppercase; letter-spacing: .04em; padding: 12px 16px; background: var(--surface-2); white-space: nowrap; }
td { padding: 14px 16px; border-top: 1px solid var(--line); vertical-align: top; }
td.right, th.right { text-align: right; }
tr.highlight td { background: var(--warn-soft); }

/* ---------- Teacher area ---------- */
.teach { display: grid; grid-template-columns: 240px 1fr; gap: 32px; padding: 28px 0 64px; align-items: start; }
.side { position: sticky; top: 84px; display: grid; gap: 4px; }
.side a { display: flex; align-items: center; gap: 10px; padding: 11px 14px; border-radius: 12px; color: var(--muted); text-decoration: none; font-weight: 500; min-height: 44px; }
.side a:hover { background: var(--surface-2); color: var(--ink); }
.side a[aria-current="page"] { background: var(--surface); color: var(--ink); font-weight: 600; box-shadow: var(--shadow); }
.side .count { margin-left: auto; background: var(--danger); color: #fff; border-radius: 99px; padding: 0 8px; font-size: 12px; font-weight: 700; }
@media (max-width: 900px) {
  .teach { grid-template-columns: 1fr; gap: 16px; }
  .side { position: static; display: flex; overflow-x: auto; gap: 6px; padding-bottom: 4px; }
  .side a { white-space: nowrap; }
}
.stats { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 200px), 1fr)); }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 20px; }
.stat .label { color: var(--muted); font-size: 14px; font-weight: 500; display: flex; gap: 8px; align-items: center; }
.stat .value { font: 700 28px/1.2 var(--font-head); margin: 8px 0 2px; font-variant-numeric: tabular-nums; }
.stat .sub { font-size: 14px; color: var(--muted); }
.stat.alert { border-color: #f5c2bd; background: var(--danger-soft); }
.stat.alert .value { color: var(--danger); }
.bar { height: 8px; border-radius: 99px; background: var(--surface-2); overflow: hidden; margin-top: 10px; }
.bar span { display: block; height: 100%; background: var(--success); }
.agenda { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.agenda li { display: grid; grid-template-columns: 92px 1fr auto; gap: 12px; align-items: center; padding: 12px 14px; border-radius: var(--radius); background: var(--surface-2); }
.agenda time { font: 600 15px var(--font-head); }
@media (max-width: 560px) { .agenda li { grid-template-columns: 1fr; } }
.group-edit { border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 20px; background: var(--surface); }
.group-edit + .group-edit { margin-top: 16px; }
.slot-row { display: grid; grid-template-columns: 1.2fr 1fr 1fr; gap: 10px; }
.slot-row + .slot-row { margin-top: 8px; }
.slip-thumb { width: 64px; height: 64px; border-radius: 10px; object-fit: cover; border: 1px solid var(--line); background: var(--surface-2); }
.review-item { display: grid; grid-template-columns: auto 1fr auto; gap: 16px; align-items: center; padding: 16px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.review-item + .review-item { margin-top: 12px; }
@media (max-width: 640px) { .review-item { grid-template-columns: 1fr; } }
.demo-banner { background: var(--accent-soft); color: var(--accent-ink); font-size: 14px; text-align: center; padding: 8px 16px; border-bottom: 1px solid #f3dca6; }
.demo-banner a { color: inherit; font-weight: 600; }

/* ---------- Footer ---------- */
.footer { border-top: 1px solid var(--line); padding: 32px 0; color: var(--muted); font-size: 14px; margin-top: auto; }
.footer-inner { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.footer a { color: var(--muted); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: .01ms !important; animation-duration: .01ms !important; scroll-behavior: auto !important; }
  .class-card:hover { transform: none; }
}

/* Overrides that must win over .btn and .nav a */
.btn.menu-toggle { display: none; }
@media (max-width: 760px) { .btn.menu-toggle { display: inline-flex; } }
.nav a.btn-primary, .nav a.btn-primary:hover { color: var(--on-primary); background: var(--primary); }
/* Let grid content shrink instead of pushing the page wider. */
.teach { grid-template-columns: 220px minmax(0, 1fr); }
.two-col { grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); }
.checkout { grid-template-columns: minmax(0, 1fr) 360px; }
@media (max-width: 900px) { .teach, .two-col, .checkout { grid-template-columns: minmax(0, 1fr); } }
.card h2 { font-size: 22px; }
td.num, td .num, .status { white-space: nowrap; }

/* Wide screens: use the width for lists and dashboards, keep forms and reading text comfortable. */
.checkout { max-width: 1120px; margin-inline: auto; }
@media (min-width: 1280px) {
  .teach { grid-template-columns: 240px minmax(0, 1fr); gap: 40px; }
  .classes { grid-template-columns: repeat(auto-fill, minmax(min(100%, 360px), 1fr)); }
}

/* ---------- Teacher calendar ---------- */
.wrap-wide { max-width: none; }
.teach-cal { padding-top: 20px; }
.cal { display: grid; grid-template-columns: 244px minmax(0, 1fr); gap: 20px; align-items: start; min-width: 0; }
.cal-side { display: grid; gap: 22px; position: sticky; top: 84px; }
.cal-create { justify-self: start; border-radius: 16px; padding: 12px 18px; box-shadow: var(--shadow); }
.icon-btn { min-width: 40px; justify-content: center; font-size: 20px; line-height: 1; padding-inline: 10px; }

.ev-indigo { --ev: var(--indigo); --ev-soft: var(--indigo-soft); }
.ev-teal   { --ev: var(--teal);   --ev-soft: var(--teal-soft); }
.ev-coral  { --ev: var(--coral);  --ev-soft: var(--coral-soft); }
.ev-amber  { --ev: var(--amber);  --ev-soft: var(--amber-soft); }
.ev-violet { --ev: var(--violet); --ev-soft: var(--violet-soft); }
.ev-green  { --ev: var(--green);  --ev-soft: var(--green-soft); }
.swatch { display: inline-block; width: 12px; height: 12px; border-radius: 4px; flex: none; background: var(--ev, var(--muted)); }
.sw-indigo { background: var(--indigo); } .sw-teal { background: var(--teal); } .sw-coral { background: var(--coral); }
.sw-amber { background: var(--amber); } .sw-violet { background: var(--violet); } .sw-green { background: var(--green); }
.sw-bill { background: var(--accent); } .sw-lock { background: var(--danger); }

/* Mini month */
.mini-head { display: flex; align-items: center; gap: 2px; margin-bottom: 6px; }
.mini-head strong { flex: 1; font-size: 15px; }
.mini-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; text-align: center; font-size: 12.5px; }
.mini-dow { color: var(--muted); font-weight: 600; font-size: 11px; padding: 4px 0; }
.mini-grid a { position: relative; display: grid; place-items: center; aspect-ratio: 1; border-radius: 50%; color: var(--ink); text-decoration: none; font-variant-numeric: tabular-nums; }
.mini-grid a:hover { background: var(--surface-2); }
.mini-grid a.other { color: #a3a6b4; }
.mini-grid a.in-range { background: var(--primary-soft); border-radius: 8px; }
.mini-grid a.today { background: var(--primary); color: var(--on-primary); font-weight: 700; border-radius: 50%; }
.mini-grid a i { position: absolute; bottom: 3px; width: 4px; height: 4px; border-radius: 50%; background: var(--primary); }
.mini-grid a.today i { background: var(--on-primary); }

.cal-filters { display: grid; gap: 8px; font-size: 14px; }
.cal-filters strong { font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.cal-filters .check { display: flex; align-items: center; gap: 9px; cursor: pointer; min-height: 28px; }
.cal-filters .check input { width: 17px; height: 17px; accent-color: var(--primary); }
.cal-filters .legend { display: flex; align-items: center; gap: 9px; color: var(--muted); font-size: 13px; }
.cal-total { margin: 0; }
.cal-keys summary { font-size: 13px; color: var(--muted); cursor: pointer; }
.cal-keys dl { display: grid; grid-template-columns: auto 1fr; gap: 6px 10px; font-size: 13px; margin: 8px 0 0; }
.cal-keys dt { font-family: ui-monospace, monospace; background: var(--surface); border: 1px solid var(--line); border-radius: 5px; padding: 0 6px; text-align: center; }
.cal-keys dd { margin: 0; color: var(--muted); }

/* Main panel */
.cal-main { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); box-shadow: var(--shadow); min-width: 0; overflow: clip; }
.cal-head { display: flex; align-items: center; gap: 8px; padding: 14px 16px; border-bottom: 1px solid var(--line); flex-wrap: wrap; position: sticky; top: 65px; background: var(--surface); z-index: 5; }
.cal-head h1 { margin: 0 8px; font-size: 22px; flex: 1; white-space: nowrap; }
.seg { display: inline-flex; background: var(--surface-2); border-radius: 12px; padding: 3px; gap: 2px; }
.seg a { padding: 7px 14px; border-radius: 9px; color: var(--muted); text-decoration: none; font-weight: 500; font-size: 14px; }
.seg a:hover { color: var(--ink); }
.seg a[aria-current="page"] { background: var(--surface); color: var(--ink); font-weight: 600; box-shadow: 0 1px 3px rgb(29 33 51 / .12); }
.cal-empty { text-align: center; padding: 28px 16px; margin: 0; }

/* Day and week time grid */
.tg-head, .tg-allday, .tg-grid { display: grid; grid-template-columns: 60px repeat(var(--days), minmax(0, 1fr)); }
.tg-head { border-bottom: 1px solid var(--line); }
.tg-day { display: grid; justify-items: center; gap: 2px; padding: 10px 0 8px; text-decoration: none; color: var(--muted); font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.tg-day b { font-family: var(--font-head); font-size: 22px; color: var(--ink); width: 40px; height: 40px; display: grid; place-items: center; border-radius: 50%; letter-spacing: 0; }
.tg-day:hover b { background: var(--surface-2); }
.tg-day.today { color: var(--primary); }
.tg-day.today b { background: var(--primary); color: var(--on-primary); }
.tg-allday { border-bottom: 1px solid var(--line); min-height: 30px; }
.tg-allday > div { border-left: 1px solid var(--line); padding: 3px; display: grid; gap: 3px; align-content: start; }
.tg-label { font-size: 11px; color: var(--muted); text-align: right; padding: 6px 8px 0 0; }
.marker { display: block; font-size: 11.5px; font-weight: 600; padding: 2px 7px; border-radius: 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.marker-bill { background: var(--accent-soft); color: var(--accent-ink); }
.marker-lock { background: var(--danger-soft); color: var(--danger); }
.tg-grid { position: relative; }
.tg-hours { position: relative; }
.tg-hours span { display: block; height: var(--hour); font-size: 11px; color: var(--muted); text-align: right; padding-right: 8px; transform: translateY(-7px); }
.tg-hours span:first-child { visibility: hidden; }
.tg-col { position: relative; border-left: 1px solid var(--line);
  background-image: repeating-linear-gradient(to bottom, var(--line) 0 1px, transparent 1px var(--hour)); }
.tg-col.today { background-color: color-mix(in srgb, var(--primary-soft) 45%, transparent); }
.now-line { position: absolute; left: -1px; right: 0; height: 2px; background: var(--danger); z-index: 4; pointer-events: none; }
.now-line::before { content: ""; position: absolute; left: -5px; top: -4px; width: 10px; height: 10px; border-radius: 50%; background: var(--danger); }
.cal-ev { position: absolute; z-index: 2; display: grid; align-content: start; gap: 1px; text-align: left; font: inherit; font-size: 12px; line-height: 1.3;
  background: var(--ev-soft); color: var(--ink); border: 0; border-left: 4px solid var(--ev); border-radius: 8px; padding: 5px 8px; overflow: hidden; cursor: pointer;
  box-shadow: 0 0 0 1px var(--surface); transition: box-shadow .15s var(--ease-out), transform .15s var(--ease-out); }
.cal-ev:hover { box-shadow: 0 0 0 1px var(--surface), 0 6px 18px rgb(29 33 51 / .16); z-index: 3; }
.cal-ev:focus-visible { outline: 3px solid var(--ev); outline-offset: 1px; }
.cal-ev strong { color: var(--ev); font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cal-ev span { color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cal-ev.short { display: flex; gap: 6px; align-items: center; padding-block: 0; }
.cal-ev.past { opacity: .55; }
.cal-ev.live { box-shadow: 0 0 0 2px var(--ev); }

/* Month grid */
.mg-head, .mg-week { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); }
.mg-head span { padding: 10px; font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); border-bottom: 1px solid var(--line); }
.mg-cell { min-height: 118px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); padding: 6px; display: grid; gap: 3px; align-content: start; min-width: 0; }
.mg-cell:nth-child(7n) { border-right: 0; }
.mg-cell.other { background: var(--surface-2); }
.mg-cell.other .mg-date { color: #a3a6b4; }
.mg-date { justify-self: start; width: 28px; height: 28px; display: grid; place-items: center; border-radius: 50%; font-weight: 600; font-size: 13px; color: var(--ink); text-decoration: none; }
.mg-date:hover { background: var(--surface-2); }
.mg-cell.today .mg-date { background: var(--primary); color: var(--on-primary); }
.mg-ev { display: grid; grid-template-columns: 8px minmax(0, 1fr); column-gap: 6px; align-items: center; width: 100%; font: inherit; font-size: 12px; line-height: 1.3; text-align: left; border: 0; background: none; padding: 3px 6px; border-radius: 6px; cursor: pointer; color: var(--ink); }
.mg-ev > span { grid-column: 2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mg-title { font-weight: 600; }
.mg-ev:hover { background: var(--ev-soft); }
.mg-ev i { width: 8px; height: 8px; border-radius: 50%; background: var(--ev); flex: none; }
.mg-ev .num { color: var(--muted); font-size: 11px; }
.mg-ev.past { opacity: .55; }
.mg-more { font-size: 12px; font-weight: 600; color: var(--muted); padding: 2px 6px; text-decoration: none; }
.mg-more:hover { color: var(--ink); }

/* List */
.agenda-list { list-style: none; margin: 0; padding: 0; }
.al-day { display: grid; grid-template-columns: 120px minmax(0, 1fr); gap: 16px; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.al-day:last-child { border-bottom: 0; }
.al-date { display: flex; align-items: baseline; gap: 8px; text-decoration: none; color: var(--muted); font-size: 12px; font-weight: 600; text-transform: uppercase; }
.al-date b { font-family: var(--font-head); font-size: 24px; color: var(--ink); }
.al-day.today .al-date b { color: var(--primary); }
.al-items { display: grid; gap: 4px; }
.al-items .marker { justify-self: start; }
.al-ev { display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; font: inherit; background: none; border: 0; border-radius: 10px; padding: 8px 10px; cursor: pointer; color: var(--ink); }
.al-ev:hover { background: var(--surface-2); }
.al-ev.past { opacity: .55; }
.al-time { width: 150px; flex: none; color: var(--muted); font-size: 14px; }
.live-badge { display: inline-flex; align-items: center; gap: 6px; margin: 0; background: var(--danger-soft); color: var(--danger); font-size: 12px; font-weight: 700; padding: 2px 8px; border-radius: 99px; }

/* Event details (HTML popover) */
.cal-pop { width: min(420px, calc(100vw - 24px)); border: 0; border-radius: 18px; padding: 22px; background: var(--surface); color: var(--ink); box-shadow: 0 24px 64px rgb(29 33 51 / .28); }
.cal-pop:popover-open { display: grid; gap: 10px; }
.cal-pop::backdrop { background: rgb(29 33 51 / .25); }
.cal-pop h3 { margin: 0; padding-right: 28px; }
.cal-pop .chip { justify-self: start; }
.cal-pop dl { display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; margin: 4px 0; font-size: 14px; }
.cal-pop dt { color: var(--muted); }
.cal-pop dd { margin: 0; }
.pop-x { position: absolute; top: 12px; right: 12px; width: 36px; height: 36px; border: 0; border-radius: 50%; background: none; font-size: 22px; color: var(--muted); cursor: pointer; }
.pop-x:hover { background: var(--surface-2); color: var(--ink); }

@media (max-width: 1180px) {
  .cal { grid-template-columns: minmax(0, 1fr); }
  .cal-side { position: static; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); align-items: start; }
  .cal-keys, .cal-total { display: none; }
}
@media (max-width: 760px) {
  .cal-head { position: static; padding: 10px; }
  .cal-head h1 { order: -1; flex-basis: 100%; margin: 0 0 4px; font-size: 19px; }
  .seg { margin-left: auto; }
  .seg a { padding: 6px 10px; }
  .tg-head, .tg-allday, .tg-grid { grid-template-columns: 40px repeat(var(--days), minmax(0, 1fr)); }
  .tg-day b { width: 32px; height: 32px; font-size: 17px; }
  .cal-ev { padding: 3px 4px; font-size: 11px; }
  .cal-ev span { display: none; }
  .mg-cell { min-height: 84px; padding: 3px; }
  .mg-ev { padding: 2px; font-size: 11px; }
  .mg-ev .num { display: none; }
  .al-day { grid-template-columns: 1fr; gap: 6px; }
  .al-ev { flex-wrap: wrap; gap: 4px 10px; }
  .al-time { width: auto; }
}

/* ---------- Teacher inbox (CRM) ---------- */
.teach-inbox { padding-top: 20px; }
.inbox { display: grid; grid-template-columns: 360px minmax(0, 1fr) 300px; gap: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); box-shadow: var(--shadow); overflow: hidden; min-height: calc(100dvh - 140px); min-width: 0; }
.inbox:not(.has-conv) { grid-template-columns: 360px minmax(0, 1fr); }
.inbox-list { border-right: 1px solid var(--line); display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.inbox-tools { display: grid; gap: 10px; padding: 16px; border-bottom: 1px solid var(--line); }
.inbox-tools h1 { font-size: 24px; margin: 0; }
.seg.seg-fill { display: flex; margin-left: 0; }
.seg-fill a { flex: 1 1 auto; text-align: center; padding: 6px 6px; font-size: 13px; white-space: nowrap; }
.seg-fill a span { color: var(--muted); font-weight: 500; font-variant-numeric: tabular-nums; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip-f { font-size: 12.5px; font-weight: 500; padding: 5px 10px; border-radius: 99px; border: 1px solid var(--line-strong); color: var(--muted); text-decoration: none; }
.chip-f:hover { color: var(--ink); border-color: var(--ink); }
.chip-f.on { background: var(--ink); border-color: var(--ink); color: #fff; }
.conv-list { overflow-y: auto; max-height: calc(100dvh - 330px); min-height: 200px; }
.conv { display: flex; gap: 12px; padding: 12px 16px; text-decoration: none; color: var(--ink); border-bottom: 1px solid var(--line); border-left: 3px solid transparent; }
.conv:hover { background: var(--surface-2); }
.conv.on { background: var(--primary-soft); border-left-color: var(--primary); }
.conv-av { position: relative; flex: none; width: 40px; height: 40px; border-radius: 50%; background: var(--surface-2); color: var(--ink); display: grid; place-items: center; font-weight: 700; font-size: 14px; }
.conv.on .conv-av { background: var(--surface); }
.conv-av i { position: absolute; right: -4px; bottom: -4px; width: 20px; height: 20px; border-radius: 50%; display: grid; place-items: center; background: var(--surface); box-shadow: 0 0 0 2px var(--surface); }
.conv-av i .icon { width: 13px; height: 13px; }
.ch-whatsapp { color: #128c4a; } .ch-phone { color: var(--coral); } .ch-web { color: var(--primary); }
.conv-body { display: grid; gap: 2px; min-width: 0; flex: 1; }
.conv-top { display: flex; gap: 8px; align-items: baseline; }
.conv-top strong { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 600; }
.conv.unread .conv-top strong { font-weight: 800; }
.conv-top small { color: var(--muted); white-space: nowrap; font-size: 12px; }
.conv-snip { color: var(--muted); font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv.unread .conv-snip { color: var(--ink); }
.conv-tags { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; margin-top: 3px; }
.tag { font-size: 11px; font-weight: 600; padding: 1px 7px; border-radius: 99px; background: var(--surface-2); color: var(--muted); }
.tag-stage { background: var(--accent-soft); color: var(--accent-ink); }
.tag-urgent { background: var(--danger-soft); color: var(--danger); }
.tag-muted { background: none; border: 1px solid var(--line-strong); }
.unread-dot { margin-left: auto; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 99px; background: var(--primary); color: #fff; font-size: 11px; font-weight: 700; display: grid; place-items: center; }
.conv-empty { padding: 20px 16px; margin: 0; }

.thread { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.thread-head { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.thread-who { flex: 1; display: grid; min-width: 0; }
.thread-who .icon { width: 14px; height: 14px; vertical-align: -2px; }
.back-to-list { display: none; }
.msgs { flex: 1; overflow-y: auto; padding: 20px 18px; display: flex; flex-direction: column; gap: 12px; background: var(--bg); max-height: calc(100dvh - 330px); min-height: 260px; }
.msg { display: grid; gap: 3px; max-width: min(78%, 560px); }
.msg .bubble { padding: 10px 14px; border-radius: 16px; white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.5; }
.msg-in { align-self: flex-start; }
.msg-in .bubble { background: var(--surface); border: 1px solid var(--line); border-bottom-left-radius: 6px; }
.msg-out { align-self: flex-end; justify-items: end; }
.msg-out .bubble { background: var(--primary); color: var(--on-primary); border-bottom-right-radius: 6px; }
.msg-note { align-self: flex-end; justify-items: end; }
.msg-note .bubble { background: var(--accent-soft); color: var(--accent-ink); border: 1px dashed #e6c36a; }
.msg-label { display: block; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; margin-bottom: 2px; }
.msg-meta { font-size: 11.5px; color: var(--muted); }
.msg-sys { align-self: center; font-size: 12px; color: var(--muted); background: var(--surface-2); padding: 3px 10px; border-radius: 99px; }
.composer { border-top: 1px solid var(--line); padding: 12px 16px; display: grid; gap: 8px; background: var(--surface); }
.composer textarea { resize: vertical; min-height: 76px; }
.composer-foot { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.composer-foot .muted { margin-right: auto; }
.input.slim { width: auto; padding: 7px 10px; font-size: 14px; }

.contact { border-left: 1px solid var(--line); padding: 16px; display: grid; gap: 16px; align-content: start; overflow-y: auto; max-height: calc(100dvh - 140px); }
.contact-card { display: flex; gap: 12px; align-items: center; }
.contact-card > div { display: grid; }
.avatar { width: 48px; height: 48px; border-radius: 50%; background: var(--primary-soft); color: var(--primary); font-weight: 700; display: grid; place-items: center; flex: none; }
.contact-block { display: grid; gap: 10px; padding-top: 14px; border-top: 1px solid var(--line); }
.contact-block .field { margin: 0; }
h3.sub { font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin: 0; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 12px; margin: 0; font-size: 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; min-width: 0; }

.empty-thread { padding: 28px; overflow-y: auto; max-height: calc(100dvh - 140px); }
.empty-inner { max-width: 620px; display: grid; gap: 20px; }
.empty-inner h2 { margin: 0; }
.empty-inner > p { margin: 0; }
.choice-sm { display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; border: 1px solid var(--line-strong); border-radius: 99px; cursor: pointer; font-weight: 500; }
.choice-sm:has(input:checked) { border-color: var(--primary); background: var(--primary-soft); color: var(--primary); }
.choice-sm input { accent-color: var(--primary); }

/* Student Messages and homepage question form */
.student-thread { padding: 0; overflow: hidden; margin-top: 20px; }
.msgs-plain { max-height: 60vh; }
.ask { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.3fr); gap: 40px; padding: 36px; }
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }

@media (max-width: 1280px) {
  .inbox.has-conv { grid-template-columns: 300px minmax(0, 1fr); }
  .inbox.has-conv .contact { grid-column: 1 / -1; border-left: 0; border-top: 1px solid var(--line); max-height: none; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
  .inbox.has-conv .contact .contact-block { border-top: 0; padding-top: 0; }
}
@media (max-width: 900px) {
  .inbox, .inbox:not(.has-conv), .inbox.has-conv { grid-template-columns: minmax(0, 1fr); min-height: 0; }
  .inbox.has-conv .inbox-list { display: none; }
  .back-to-list { display: inline-flex; }
  .thread-who { flex-basis: calc(100% - 60px); }
  .thread-head form { margin-left: auto; }
  .inbox-list { border-right: 0; }
  .conv-list, .msgs { max-height: none; }
  .msgs { max-height: 65vh; }
  .ask { grid-template-columns: 1fr; padding: 24px; gap: 20px; }
  .msg { max-width: 88%; }
}
.notice { padding: 16px 18px; border-radius: var(--radius); background: var(--primary-soft); color: var(--ink); }
.notice p { margin: 0; }

/* ---------- Assignments ---------- */
.status-submitted, .status-late { background: var(--warn-soft); color: var(--warn); }
.status-returned, .status-released { background: var(--success-soft); color: var(--success); }
.status-missing, .status-overdue { background: var(--danger-soft); color: var(--danger); }
.status-draft { background: var(--surface-2); color: var(--muted); }
.task-list { display: grid; gap: 12px; }
.task { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px 20px; align-items: center; padding: 18px 20px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); text-decoration: none; color: inherit; transition: border-color .15s, box-shadow .15s; }
a.task:hover { border-color: var(--primary); box-shadow: var(--shadow); }
.task h3 { margin: 4px 0 2px; font-size: 18px; }
.task .meta { display: flex; flex-wrap: wrap; gap: 6px 14px; color: var(--muted); font-size: 14px; }
.task .meta .icon { width: 15px; height: 15px; vertical-align: -2px; }
.task .score { font: 700 22px/1 var(--font-head); color: var(--primary); text-align: right; }
.task .score small { display: block; font: 500 12px/1.4 var(--font-body); color: var(--muted); }
.progress-line { display: flex; gap: 14px; font-size: 14px; color: var(--muted); }
.progress-line strong { color: var(--ink); }
@media (max-width: 640px) { .task { grid-template-columns: 1fr; } .task .score { text-align: left; } }
.section-label { font: 600 13px/1.4 var(--font-body); text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 28px 0 10px; }
.instructions { white-space: pre-wrap; font-size: 16px; line-height: 1.65; margin: 0; }
.paper { border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: var(--surface-2); }
.paper img { width: 100%; height: auto; }
.paper iframe { width: 100%; height: min(80vh, 900px); border: 0; display: block; background: #fff; }
.paper-bar { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 8px 12px; background: var(--surface); border-bottom: 1px solid var(--line); font-size: 14px; }
.paper-bar a { white-space: nowrap; }
.pages { display: grid; gap: 16px; }
.page-thumbs { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px; }
.page-thumb { position: relative; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: var(--surface-2); aspect-ratio: 3 / 4; display: grid; place-items: center; text-align: center; font-size: 13px; color: var(--muted); }
.page-thumb img { width: 100%; height: 100%; object-fit: cover; }
.page-thumb .num { position: absolute; left: 6px; top: 6px; background: rgb(0 0 0 / .6); color: #fff; border-radius: 6px; padding: 1px 7px; font-size: 12px; }
.page-thumb form { position: absolute; right: 4px; top: 4px; }
.page-thumb .btn { min-height: 32px; padding: 4px 8px; background: rgb(255 255 255 / .92); }
.drop { display: grid; place-items: center; gap: 6px; text-align: center; padding: 28px 16px; border: 2px dashed var(--line-strong); border-radius: var(--radius-lg); background: var(--surface-2); cursor: pointer; transition: border-color .15s, background .15s; }
.drop:hover, .drop.over { border-color: var(--primary); background: var(--primary-soft); }
.drop .icon { width: 28px; height: 28px; color: var(--primary); }
.drop input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.picked { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; }
.picked:empty { display: none; }
.picked figure { margin: 0; aspect-ratio: 3 / 4; border-radius: 8px; overflow: hidden; border: 1px solid var(--line); display: grid; place-items: center; background: var(--surface-2); font-size: 12px; color: var(--muted); padding: 4px; text-align: center; }
.picked img { width: 100%; height: 100%; object-fit: cover; }
.result { display: flex; align-items: center; gap: 18px; padding: 20px; border-radius: var(--radius-lg); background: var(--primary-soft); }
.result .big { font: 700 40px/1 var(--font-head); color: var(--primary); white-space: nowrap; }
.result .big small { font-size: 18px; color: var(--muted); }
.feedback { white-space: pre-wrap; margin: 0; }
.mark-layout { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 24px; align-items: start; }
.mark-side { position: sticky; top: 16px; }
@media (max-width: 1000px) { .mark-layout { grid-template-columns: 1fr; } .mark-side { position: static; } }
.markup { position: relative; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: #fff; }
.markup canvas { display: block; width: 100%; height: auto; touch-action: none; }
.markup.editing canvas { cursor: crosshair; }
.toolbar { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; padding: 8px; background: var(--surface); border-bottom: 1px solid var(--line); }
.toolbar .sep { width: 1px; height: 26px; background: var(--line); margin: 0 4px; }
.tool { display: inline-grid; place-items: center; min-width: 38px; height: 38px; padding: 0 8px; border-radius: 9px; border: 1px solid transparent; background: transparent; color: var(--ink); font: 600 14px/1 var(--font-body); cursor: pointer; }
.tool:hover { background: var(--surface-2); }
.tool[aria-pressed="true"] { background: var(--primary-soft); border-color: var(--primary); color: var(--primary); }
.tool .icon { width: 18px; height: 18px; }
.swatch { width: 26px; height: 26px; border-radius: 50%; border: 2px solid #fff; box-shadow: 0 0 0 1px var(--line-strong); cursor: pointer; padding: 0; }
.swatch[aria-pressed="true"] { box-shadow: 0 0 0 2px var(--ink); }
.text-input { position: absolute; z-index: 3; font: 600 18px/1.2 var(--font-body); border: 1px dashed var(--primary); background: rgb(255 255 255 / .9); padding: 2px 4px; min-width: 120px; outline: none; }

/* ---------- Class room ---------- */
body.bare { background: #0f172a; color: #e2e8f0; min-height: 100dvh; }
.room { display: grid; grid-template-rows: auto 1fr auto; height: 100dvh; background: #0f172a; color: #e2e8f0; }
.room .muted, .room .hint { color: #94a3b8; }
.room-top { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px clamp(12px, 2vw, 20px); border-bottom: 1px solid #1e293b; }
.room-title { display: flex; flex-direction: column; min-width: 0; }
.room-title strong { font: 600 16px/1.3 var(--font-head); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.room-title span { font-size: 13px; color: #94a3b8; }
.room-meta { display: flex; align-items: center; gap: 14px; font-size: 14px; color: #cbd5e1; }
.room-meta .icon { width: 16px; height: 16px; vertical-align: -3px; }
.live-dot { display: inline-flex; align-items: center; gap: 6px; padding: 2px 10px; border-radius: 99px; background: #7f1d1d; color: #fecaca; font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .05em; }
.live-dot::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: #f87171; animation: pulse 1.6s infinite; }
@keyframes pulse { 50% { opacity: .35; } }
@media (prefers-reduced-motion: reduce) { .live-dot::before { animation: none; } }

.prejoin { display: grid; place-items: center; padding: 20px; overflow: auto; }
.prejoin[hidden] { display: none; }
.prejoin-card { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr); gap: 32px; align-items: center; width: min(100%, 980px); }
.prejoin h1 { font-size: clamp(26px, 3vw, 34px); color: #fff; margin: 0 0 6px; }
.prejoin-side { display: grid; gap: 14px; justify-items: start; }
.prejoin-side .btn-lg { width: 100%; justify-content: center; }
.prejoin-side .btn-ghost { color: #cbd5e1; width: 100%; justify-content: center; }
.preview { position: relative; aspect-ratio: 16 / 9; background: #1e293b; border-radius: 18px; overflow: hidden; }
.preview video { width: 100%; height: 100%; object-fit: cover; transform: scaleX(-1); }
.preview-off { position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; gap: 8px; color: #94a3b8; }
.preview-off[hidden] { display: none; }
.preview-off .icon { width: 36px; height: 36px; }
@media (max-width: 760px) { .prejoin-card { grid-template-columns: 1fr; gap: 18px; } }

.room-main { position: relative; display: grid; grid-template-columns: minmax(0, 1fr) auto; min-height: 0; }
.room-main[hidden] { display: none; }
.stage { position: relative; display: grid; grid-template-columns: minmax(0, 1fr) 220px; grid-template-rows: minmax(0, 1fr); gap: 12px; padding: 12px; min-height: 0; }
.room[data-mode="gallery"] .stage { grid-template-columns: minmax(0, 1fr); }
.board-wrap, .screen-wrap { display: flex; flex-direction: column; gap: 8px; min-height: 0; min-width: 0; justify-content: center; }
.board-wrap[hidden], .screen-wrap[hidden] { display: none; }
.board { position: relative; width: min(100%, calc((100dvh - 250px) * 16 / 9)); margin: 0 auto; border-radius: 12px; overflow: hidden; box-shadow: 0 10px 30px rgb(0 0 0 / .4); }
.board canvas { display: block; width: 100%; background: #fff; touch-action: none; }
.room[data-teacher="1"] .board canvas { cursor: crosshair; }
.board-tools { justify-content: center; border-radius: 12px; border: 0; background: #1e293b; margin: 0 auto; max-width: 100%; }
.board-tools .tool { color: #e2e8f0; }
.board-tools .tool:hover { background: #334155; }
.board-tools .tool[aria-pressed="true"] { background: #1d4ed8; border-color: #3b82f6; color: #fff; }
.board-tools .sep { background: #334155; }
.board-tools .swatch { border-color: #1e293b; }
.board-tools .swatch[aria-pressed="true"] { box-shadow: 0 0 0 2px #fff; }
.board-pages { display: flex; justify-content: center; align-items: center; gap: 8px; font-size: 14px; color: #cbd5e1; }
.board-pages .tool { color: #e2e8f0; min-width: 34px; height: 34px; }
.board-pages .tool:hover { background: #1e293b; }
.board .text-input { color: #111; }
.screen-wrap { position: relative; }
.screen-wrap video { width: 100%; height: 100%; max-height: calc(100dvh - 160px); object-fit: contain; background: #000; border-radius: 12px; }
.screen-wrap video[hidden] { display: none; }
.presenting { display: grid; place-content: center; justify-items: center; gap: 12px; text-align: center; height: 100%; min-height: 240px; border: 2px dashed #334155; border-radius: 16px; color: #cbd5e1; padding: 24px; }
.presenting[hidden] { display: none; }
.presenting .icon { width: 40px; height: 40px; color: #60a5fa; }

.gallery { display: grid; gap: 10px; align-content: center; min-height: 0; }
.room[data-mode="gallery"] .gallery { grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr)); max-width: calc((100dvh - 170px) * 16 / 9 * 1.6); width: 100%; margin: 0 auto; }
.room[data-mode="gallery"] .gallery[data-count="1"] { grid-template-columns: minmax(0, 860px); justify-content: center; }
.room[data-mode="gallery"] .gallery[data-count="2"] { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.room:not([data-mode="gallery"]) .gallery { grid-auto-rows: max-content; align-content: start; overflow-y: auto; }
.tile { position: relative; aspect-ratio: 16 / 9; background: #1e293b; border-radius: 12px; overflow: hidden; outline: 2px solid transparent; transition: outline-color .2s; }
.tile.teacher { outline-color: #3b82f6; }
.tile.raised { outline-color: #f59e0b; }
.tile.weak::after { content: "Weak connection"; position: absolute; top: 6px; left: 6px; font-size: 11px; background: #7f1d1d; color: #fff; padding: 1px 6px; border-radius: 6px; }
.tile video { width: 100%; height: 100%; object-fit: cover; }
.tile.self video { transform: scaleX(-1); }
.tile .avatar { position: absolute; inset: 0; display: none; place-items: center; font: 700 clamp(18px, 3vw, 34px)/1 var(--font-head); color: #fff; }
.tile .avatar::before { content: ""; position: absolute; width: clamp(48px, 30%, 96px); aspect-ratio: 1; border-radius: 50%; background: #334155; z-index: 0; }
.tile.cam-off .avatar { display: grid; }
.tile.cam-off video { opacity: 0; }
.tile .avatar { isolation: isolate; }
.tile .tag { position: absolute; left: 6px; bottom: 6px; display: flex; align-items: center; gap: 6px; max-width: calc(100% - 12px); padding: 2px 8px; border-radius: 7px; background: rgb(15 23 42 / .75); font-size: 13px; color: #fff; }
.tile .nm { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile .micoff { width: 14px; height: 14px; color: #f87171; flex-shrink: 0; }
.tile .hand { position: absolute; top: 6px; right: 8px; font-size: 22px; }
.tile .hand[hidden] { display: none; }
.tile-acts { position: absolute; top: 6px; right: 6px; display: flex; gap: 4px; opacity: 0; transition: opacity .15s; }
.tile:hover .tile-acts, .tile:focus-within .tile-acts { opacity: 1; }
.tile.raised .tile-acts { opacity: 1; top: 36px; }
.tile-acts .btn { min-height: 28px; padding: 2px 8px; font-size: 12px; }
.waiting { position: absolute; inset: 12px; display: grid; place-items: center; text-align: center; pointer-events: none; }
.waiting[hidden] { display: none; }
.waiting p { background: rgb(15 23 42 / .85); padding: 18px 22px; border-radius: 14px; border: 1px solid #334155; }

.chat { width: 320px; display: grid; grid-template-rows: auto 1fr auto; border-left: 1px solid #1e293b; background: #111c33; min-height: 0; }
.chat[hidden] { display: none; }
.chat-head { display: flex; justify-content: space-between; align-items: center; padding: 10px 14px; border-bottom: 1px solid #1e293b; }
.chat-head .tool { color: #e2e8f0; }
.chat-list { list-style: none; margin: 0; padding: 12px 14px; overflow-y: auto; display: grid; gap: 10px; align-content: start; }
.chat-list b { font-size: 12px; color: #93c5fd; }
.chat-list .mine b { color: #86efac; }
.chat-list p { margin: 2px 0 0; font-size: 14px; overflow-wrap: anywhere; }
.chat-form { display: flex; gap: 8px; padding: 10px; border-top: 1px solid #1e293b; }
.chat-form .input { background: #0f172a; color: #fff; border-color: #334155; min-width: 0; }

.controls { display: flex; justify-content: center; align-items: center; flex-wrap: wrap; gap: 8px; padding: 10px; border-top: 1px solid #1e293b; }
.controls[hidden] { display: none; }
.controls form { display: contents; }
.ctl { position: relative; display: inline-flex; flex-direction: column; align-items: center; gap: 3px; min-width: 72px; min-height: 56px; padding: 7px 10px; border-radius: 14px; border: 0; background: #1e293b; color: #e2e8f0; font: 500 12px/1.2 var(--font-body); cursor: pointer; }
.ctl .icon { width: 22px; height: 22px; }
.ctl:hover { background: #334155; }
.ctl:focus-visible { outline: 2px solid #60a5fa; outline-offset: 2px; }
#c-mic[aria-pressed="false"], #c-cam[aria-pressed="false"], #pj-mic[aria-pressed="false"], #pj-cam[aria-pressed="false"] { background: #7f1d1d; color: #fee2e2; }
#c-share[aria-pressed="true"], #c-board[aria-pressed="true"], #c-chat[aria-pressed="true"] { background: #1d4ed8; color: #fff; }
#c-hand[aria-pressed="true"] { background: #b45309; color: #fff; }
.ctl-leave { background: #dc2626; color: #fff; }
.ctl-leave:hover { background: #b91c1c; }
.ctl-end { background: transparent; color: #fca5a5; border: 1px solid #7f1d1d; }
.ctl .badge { position: absolute; top: 4px; right: 12px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: #ef4444; color: #fff; font: 700 11px/18px var(--font-body); font-style: normal; }
.ctl .badge[hidden] { display: none; }
.prejoin .ctl { flex-direction: row; min-height: 44px; gap: 8px; font-size: 14px; }

.toasts { position: fixed; left: 50%; bottom: 92px; transform: translateX(-50%); display: grid; gap: 8px; z-index: 50; width: min(92vw, 420px); }
.toast { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 14px; border-radius: 12px; background: #f8fafc; color: #0f172a; box-shadow: 0 10px 30px rgb(0 0 0 / .35); font-size: 14px; }
.ended { position: fixed; inset: 0; display: grid; place-items: center; background: rgb(15 23 42 / .92); z-index: 60; text-align: center; color: #fff; }

@media (max-width: 860px) {
  .stage { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto auto; align-content: start; padding: 8px; }
  .room:not([data-mode="gallery"]) .gallery { grid-auto-flow: column; grid-auto-columns: 140px; overflow-x: auto; overflow-y: hidden; }
  .board { width: 100%; }
  .chat { position: absolute; inset: 0; width: auto; z-index: 20; }
  .ctl { min-width: 56px; padding: 6px; }
  .ctl span { display: none; }
  .room-meta #clock { display: none; }
}
