/* ClassHub: calm, readable, built for long study sessions */
:root {
  --ink: #17212b;
  --paper: #f4f6f7;
  --card: #ffffff;
  --line: #d9e0e4;
  --muted: #5b6b77;
  --teal: #0e5a64;
  --teal-dark: #0a3f47;
  --teal-soft: #e3f0f1;
  --marigold: #f0a500;
  --ok: #1e7a4c;
  --danger: #b3261e;
  --font-head: 'Bricolage Grotesque', 'Segoe UI', sans-serif;
  --font-body: 'Hanken Grotesk', 'Segoe UI', system-ui, sans-serif;
}
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--paper); color: var(--ink); font-family: var(--font-body); font-size: 1rem; line-height: 1.6; min-height: 100vh; display: flex; flex-direction: column; }
h1, h2, h3 { font-family: var(--font-head); line-height: 1.2; margin: 0 0 .5rem; letter-spacing: -.01em; }
h1 { font-size: clamp(1.6rem, 3vw, 2.2rem); }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.05rem; }
p { margin: 0 0 .75rem; }
a { color: var(--teal); }
a:hover { color: var(--teal-dark); }
:focus-visible { outline: 3px solid var(--marigold); outline-offset: 2px; }
.container { width: min(1180px, 100% - 2rem); margin-inline: auto; }
.page { flex: 1; padding-block: 1.75rem 3rem; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.right { text-align: right; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.row { display: flex; gap: .75rem; flex-wrap: wrap; align-items: center; }
.row-between { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; }

/* Top bar */
.topbar { background: var(--teal-dark); color: #fff; position: sticky; top: 0; z-index: 20; }
.topbar-inner { display: flex; align-items: center; justify-content: space-between; min-height: 60px; gap: 1rem; }
.brand { color: #fff; text-decoration: none; font-family: var(--font-head); font-weight: 700; font-size: 1.25rem; display: flex; gap: .5rem; align-items: center; }
.brand i { color: var(--marigold); }
.mainnav { display: flex; align-items: center; gap: 1.25rem; }
.mainnav a, .mainnav .linklike { color: #e6f1f2; text-decoration: none; font-weight: 500; }
.mainnav a:hover, .mainnav .linklike:hover { color: #fff; text-decoration: underline; }
.nav-toggle { display: none; background: none; border: 0; color: #fff; font-size: 1.4rem; padding: .5rem; cursor: pointer; }
.inline-form { display: inline; margin: 0; }
.linklike { background: none; border: 0; padding: 0; font: inherit; color: var(--teal); cursor: pointer; }
.linklike.danger { color: var(--danger); }
.subnav { background: #fff; border-bottom: 1px solid var(--line); }
.subnav .container { display: flex; gap: 1.5rem; overflow-x: auto; }
.subnav a { padding: .8rem 0; color: var(--muted); text-decoration: none; font-weight: 600; border-bottom: 3px solid transparent; white-space: nowrap; }
.subnav a.active { color: var(--teal-dark); border-bottom-color: var(--marigold); }

/* Buttons */
.btn { display: inline-flex; align-items: center; gap: .5rem; justify-content: center; background: var(--teal); color: #fff; border: 1px solid var(--teal); border-radius: 8px; padding: .65rem 1.1rem; font: 600 .95rem var(--font-body); text-decoration: none; cursor: pointer; transition: background .15s; }
.btn:hover { background: var(--teal-dark); color: #fff; }
.btn-ghost { background: transparent; color: var(--teal-dark); border-color: var(--line); }
.btn-ghost:hover { background: var(--teal-soft); color: var(--teal-dark); }
.btn-danger { background: #fff; color: var(--danger); border-color: #e7c4c1; }
.btn-danger:hover { background: var(--danger); color: #fff; }
.btn-done { background: var(--ok); border-color: var(--ok); }
.btn-done:hover { background: #17613c; }
.btn-small { padding: .4rem .8rem; font-size: .85rem; }
.mainnav .btn-small { background: var(--marigold); border-color: var(--marigold); color: var(--ink); }

/* Alerts */
.alert { padding: .8rem 1rem; border-radius: 8px; margin-bottom: 1rem; border: 1px solid; font-weight: 500; }
.alert-success { background: #e6f4ec; border-color: #b7dfc7; color: #14543a; }
.alert-error { background: #fbe9e7; border-color: #f0c3be; color: #8c1d16; }
.notice { background: var(--teal-soft); border: 1px solid #bcd8db; border-radius: 8px; padding: .8rem 1rem; margin-block: 1rem; display: flex; gap: .75rem; align-items: center; flex-wrap: wrap; }
.notice[hidden] { display: none; }

/* Forms */
.form { display: grid; gap: 1rem; }
.form label { display: grid; gap: .3rem; font-weight: 600; font-size: .92rem; }
.form label.check { display: flex; gap: .6rem; align-items: center; font-weight: 500; }
input[type=text], input[type=email], input[type=password], input[type=search], input[type=number], select, textarea {
  width: 100%; padding: .65rem .8rem; border: 1px solid #b8c4cb; border-radius: 8px; font: inherit; background: #fff; color: var(--ink);
}
input[type=file] { font: inherit; max-width: 100%; }
textarea { resize: vertical; }
.form-row { display: flex; gap: .75rem; align-items: end; flex-wrap: wrap; }
.form-row > label { flex: 1 1 200px; }
.form-row > label.narrow { flex: 0 0 90px; }
.inline-add { display: flex; gap: .75rem; margin-bottom: 1.25rem; flex-wrap: wrap; }
.inline-add input, .inline-add select { flex: 1 1 240px; width: auto; }
.auth-card { max-width: 440px; margin: 2rem auto; background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 2rem; }
.auth-card .btn { width: 100%; }

/* Cards and grid */
.page-head { margin-bottom: 1.5rem; }
.filters { display: flex; gap: .75rem; flex-wrap: wrap; margin-top: .75rem; }
.filters input { flex: 2 1 260px; width: auto; }
.filters select { flex: 1 1 180px; width: auto; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 1.25rem; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.card.pad { padding: 1.25rem; margin-bottom: 1.25rem; }
.card-body { padding: 1rem 1.1rem 1.15rem; }
.card-body h3 a { color: var(--ink); text-decoration: none; }
.card-body h3 a:hover { color: var(--teal); }
.thumb { display: block; position: relative; aspect-ratio: 16 / 9; background: var(--teal-soft); }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb-fallback { position: absolute; inset: 0; display: grid; place-items: center; font: 700 2.6rem var(--font-head); color: var(--teal); background: repeating-linear-gradient(135deg, #e3f0f1 0 14px, #d6e8ea 14px 28px); }
.chip { display: inline-block; background: var(--teal-soft); color: var(--teal-dark); padding: .1rem .6rem; border-radius: 999px; font-size: .8rem; font-weight: 600; margin-bottom: .35rem; }
.badge { display: inline-block; border-radius: 6px; padding: .1rem .55rem; font-size: .78rem; font-weight: 700; }
.badge-draft { background: #fdf0c9; color: #7a5600; }
.badge-live { background: #dff1e6; color: #14543a; }
.thumb .badge { position: absolute; top: .6rem; left: .6rem; }
.progress { height: 8px; background: #e4eaed; border-radius: 99px; overflow: hidden; margin: .4rem 0; }
.progress span { display: block; height: 100%; background: var(--marigold); border-radius: 99px; transition: width .3s; }
.progress-lg { height: 12px; max-width: 420px; }
.empty { background: #fff; border: 1px dashed #b8c4cb; border-radius: 12px; padding: 2rem 1.25rem; text-align: center; margin-block: 1rem; }

/* Course page */
.course-head { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 1.75rem; margin-bottom: 2rem; }
.lead { max-width: 70ch; color: #36434d; font-size: 1.05rem; }
.lesson-list { list-style: none; padding: 0; margin: 0; background: #fff; border: 1px solid var(--line); border-radius: 12px; }
.lesson-list li + li { border-top: 1px solid var(--line); }
.lesson-list a, .lesson-list .locked { display: flex; gap: .75rem; padding: .9rem 1.1rem; align-items: center; text-decoration: none; color: var(--ink); }
.lesson-list a:hover { background: var(--teal-soft); }
.lesson-list .locked { color: var(--muted); }
.done { color: var(--ok); }

/* Lesson player */
.crumbs { margin-bottom: 1rem; }
.crumbs a { text-decoration: none; font-weight: 600; }
.lesson-layout { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 1.5rem; align-items: start; }
.player-frame { background: #0b1a1d; border-radius: 12px; overflow: hidden; aspect-ratio: 16 / 9; }
#player-wrap, #player-wrap iframe, #player { width: 100%; height: 100%; display: block; border: 0; }
.lesson-title { margin-top: 1.1rem; }
.lesson-actions { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; margin-bottom: .5rem; }
.materials { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 1rem 1.25rem; margin-top: 1.25rem; }
.materials ul { list-style: none; padding: 0; margin: 0; display: grid; gap: .5rem; }
.prev-next { display: flex; justify-content: space-between; gap: 1rem; margin-top: 1.5rem; flex-wrap: wrap; }
.lesson-side { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 1.1rem; position: sticky; top: 76px; max-height: calc(100vh - 100px); overflow-y: auto; }
.lesson-side h2 { font-size: 1.05rem; }
.playlist { list-style: none; padding: 0; margin: .75rem 0 0; }
.playlist li a { display: grid; grid-template-columns: 1.8rem 1fr; gap: .5rem; padding: .6rem .5rem; border-radius: 8px; text-decoration: none; color: var(--ink); align-items: start; }
.playlist li a:hover { background: var(--paper); }
.playlist li.current a { background: var(--teal-soft); font-weight: 700; box-shadow: inset 3px 0 0 var(--teal); }
.pl-mark { color: var(--muted); font-weight: 600; text-align: center; }

/* Admin */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 1rem; margin-bottom: 2rem; }
.stat { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 1rem 1.25rem; }
.stat strong { display: block; font: 700 2rem var(--font-head); color: var(--teal-dark); }
.stat span { color: var(--muted); }
.table-wrap { overflow-x: auto; background: #fff; border: 1px solid var(--line); border-radius: 12px; margin-bottom: 1.5rem; }
.table { width: 100%; border-collapse: collapse; min-width: 560px; }
.table th, .table td { padding: .8rem 1rem; text-align: left; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table th { font-size: .85rem; color: var(--muted); font-weight: 600; background: #fafbfb; }
.table tr:last-child td { border-bottom: 0; }
.actions { display: flex; gap: .4rem; justify-content: flex-end; flex-wrap: wrap; }
.actions form { margin: 0; }
.thumb-preview { max-width: 220px; border-radius: 8px; border: 1px solid var(--line); }
.two-col { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 1.25rem; align-items: start; }
.lesson-admin .form-row { margin-bottom: .75rem; }
.lesson-tools { display: flex; gap: .75rem; flex-wrap: wrap; align-items: center; border-top: 1px dashed var(--line); padding-top: .75rem; }
.chip-form { display: inline-flex; gap: .6rem; align-items: center; background: var(--paper); padding: .3rem .7rem; border-radius: 8px; margin: 0; }
.upload-row { align-items: center; margin: 0; }
.upload-row input[type=text] { width: 220px; }
.lesson-tools > .right { margin-left: auto; }

.footer { border-top: 1px solid var(--line); padding: 1.25rem 0; color: var(--muted); font-size: .9rem; }

@media (max-width: 960px) {
  .lesson-layout { grid-template-columns: 1fr; }
  .lesson-side { position: static; max-height: none; }
}
@media (max-width: 720px) {
  .nav-toggle { display: block; }
  .mainnav { display: none; position: absolute; top: 60px; left: 0; right: 0; background: var(--teal-dark); flex-direction: column; align-items: flex-start; padding: 1rem; gap: .9rem; border-top: 1px solid #1c5a63; }
  .mainnav.open { display: flex; }
  .auth-card { padding: 1.25rem; margin-block: 1rem; }
  .course-head { padding: 1.1rem; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* ===== Phase 3 + 4 additions ===== */
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .92em; }
.good { color: var(--ok); }
.bad { color: var(--danger); }
.inline-form { display: inline; margin: 0; }
.no-scroll { overflow: hidden; }
.is-past { opacity: .55; }
.row a.strong { font-weight: 700; text-decoration: none; color: var(--ink); }
ul.plain { list-style: none; padding: 0; margin: .5rem 0; display: grid; gap: .4rem; }
code { background: var(--teal-soft); padding: .05rem .35rem; border-radius: 4px; }

/* price + ratings */
.price-tag { position: absolute; right: .6rem; bottom: .6rem; background: var(--ink); color: #fff; border-radius: 6px; padding: .1rem .6rem; font-weight: 700; font-size: .9rem; }
.price-tag.free { background: var(--ok); }
.price-big { font: 700 2rem var(--font-head); color: var(--teal-dark); }
.buy-box { display: flex; gap: 1rem; align-items: center; flex-wrap: wrap; }
.meta-line { display: flex; gap: 1rem; flex-wrap: wrap; align-items: center; }
.stars { color: var(--marigold); letter-spacing: 1px; white-space: nowrap; }
.star-input { border: 0; padding: 0; margin: 0 0 .75rem; display: inline-flex; flex-direction: row-reverse; gap: .15rem; }
.star-input input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.star-input label { cursor: pointer; color: #c9d2d7; font-size: 1.6rem; margin: 0; }
.star-input input:checked ~ label, .star-input label:hover, .star-input label:hover ~ label { color: var(--marigold); }
.star-input input:focus-visible + label { outline: 3px solid var(--marigold); border-radius: 4px; }
.review { border-bottom: 1px solid var(--line); padding: .8rem 0; }
.review p { margin: .25rem 0 0; }
.cert-box h2 { font-size: 1.2rem; }

/* checkout + receipt */
.checkout .summary { margin: 1rem 0; }
.summary > div { display: flex; justify-content: space-between; padding: .35rem 0; border-bottom: 1px solid var(--line); }
.summary dt, .summary dd { margin: 0; }
.summary .total { font-weight: 700; font-size: 1.15rem; border-bottom: 0; }
.steps { padding-left: 1.2rem; display: grid; gap: .75rem; }
.upi-open { margin-top: .4rem; }
.receipt { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 2rem; max-width: 760px; margin: 0 auto; }
.receipt-head { display: flex; justify-content: space-between; gap: 1.5rem; flex-wrap: wrap; border-bottom: 2px solid var(--ink); padding-bottom: 1rem; margin-bottom: 1rem; }
.receipt-head h1 { font-size: 1.5rem; }
.receipt-table { min-width: 0; margin: 1rem 0; }
.receipt-table .total td { border-top: 2px solid var(--ink); font-size: 1.1rem; }

/* live classes */
.live-list { display: grid; gap: 1rem; }
.live-card { display: flex; justify-content: space-between; gap: 1rem; align-items: center; flex-wrap: wrap; margin-bottom: 0; }
.live-card h3 { margin: .3rem 0 0; }
.jitsi-frame { aspect-ratio: 16 / 10; min-height: 420px; background: #0b1a1d; border-radius: 12px; overflow: hidden; }
#jitsi, #jitsi iframe { width: 100%; height: 100%; }

/* player: watermark + our own full-screen */
.player-frame { position: relative; }
.watermark { position: absolute; z-index: 5; pointer-events: none; user-select: none; color: rgba(255, 255, 255, .45); font: 600 .8rem var(--font-body); text-shadow: 0 0 3px rgba(0, 0, 0, .8); transition: left 1.6s ease, top 1.6s ease; max-width: 60%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fs-btn { position: absolute; z-index: 6; right: .6rem; bottom: 3.2rem; background: rgba(0, 0, 0, .55); color: #fff; border: 0; border-radius: 6px; width: 2.1rem; height: 2.1rem; cursor: pointer; opacity: .75; }
.fs-btn:hover, .fs-btn:focus-visible { opacity: 1; }
.player-frame:fullscreen { border-radius: 0; aspect-ratio: auto; width: 100%; height: 100%; }
.player-frame:-webkit-full-screen { border-radius: 0; aspect-ratio: auto; width: 100%; height: 100%; }
.player-frame.pseudo-fs { position: fixed; inset: 0; z-index: 100; border-radius: 0; aspect-ratio: auto; width: 100%; height: 100%; }

/* quiz + comments */
.quiz-box h2 { font-size: 1.15rem; }
.quiz .q { margin-bottom: 1rem; border: 1px solid var(--line); }
.quiz .q legend { font-weight: 700; padding: 0 .4rem; }
.quiz .q-ok { border-color: #b7dfc7; background: #f4fbf7; }
.quiz .q-bad { border-color: #f0c3be; background: #fdf6f5; }
label.check { display: flex; gap: .6rem; align-items: flex-start; padding: .3rem 0; font-weight: 500; }
label.check input { width: auto; margin-top: .35rem; }
.qlist { padding-left: 1.2rem; display: grid; gap: 1rem; }
.comments { margin-top: 2rem; }
.comment { border-bottom: 1px solid var(--line); padding: .8rem 0; }
.comment.reply { margin-left: 1.75rem; border-left: 3px solid var(--teal-soft); padding-left: .9rem; }
.comment p { margin: .25rem 0 .4rem; }
.reply-box summary { cursor: pointer; color: var(--teal); font-weight: 600; }

/* certificate */
.certificate { background: #fff; border: 6px double var(--teal); outline: 2px solid var(--marigold); outline-offset: -14px; border-radius: 4px; padding: 3rem 2rem; text-align: center; max-width: 900px; margin: 0 auto; }
.certificate h1 { font-size: 2.2rem; margin-bottom: 1rem; }
.cert-org { letter-spacing: .15em; color: var(--teal); font-weight: 700; }
.cert-small { color: var(--muted); margin: .6rem 0; }
.cert-name { font: italic 700 2.6rem Georgia, 'Times New Roman', serif; color: var(--teal-dark); margin: .4rem 0; overflow-wrap: anywhere; }
.cert-course { font: 700 1.5rem var(--font-head); margin: .4rem 0 1.4rem; }
.cert-id { color: var(--muted); font-size: .8rem; margin-top: 2rem; }

@media print {
  .topbar, .subnav, .footer, .no-print, .flash, .alert { display: none !important; }
  body { background: #fff; }
  .page { padding: 0; }
  .receipt, .certificate { border-color: #999; box-shadow: none; }
  @page { margin: 12mm; }
}
@media (prefers-reduced-motion: reduce) { .watermark { transition: none; } }
