/* Pioneer Medicose — brand colours taken from the logo */
:root {
  --red: #e94b50; --red-d: #c9353a; --red-l: #fdecec;
  --indigo: #4a58a6; --indigo-d: #37438a; --indigo-l: #eceffa;
  --sky: #47c1e2; --sky-l: #e6f7fc;
  --green: #1ea65a; --green-d: #148347; --green-l: #e5f6ec;
  --amber: #e9a23b; --amber-l: #fdf3e2;
  --ink: #1d2433; --ink-2: #4a5468; --ink-3: #7b8597;
  --line: #e3e7ef; --bg: #f5f7fb; --card: #ffffff;
  --radius: 14px; --shadow: 0 1px 2px rgba(20, 30, 60, .05), 0 4px 16px rgba(20, 30, 60, .06);
  --font: 'Poppins', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: var(--font); font-size: 15px; line-height: 1.55; color: var(--ink); background: var(--bg); }
a { color: var(--indigo); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; }
h1, h2, h3, h4 { line-height: 1.25; margin: 0 0 .5em; font-weight: 600; }
h1 { font-size: 1.6rem; } h2 { font-size: 1.3rem; } h3 { font-size: 1.08rem; } h4 { font-size: .98rem; }
p { margin: 0 0 .8em; }
.muted { color: var(--ink-3); } .small { font-size: .85rem; } .tiny { font-size: .76rem; }
.nowrap { white-space: nowrap; } .center { text-align: center; } .right { text-align: right; }
.pre { white-space: pre-wrap; }
hr { border: 0; border-top: 1px solid var(--line); margin: 1.2rem 0; }

/* ---------- layout ---------- */
.topbar { position: sticky; top: 0; z-index: 30; background: #fff; border-bottom: 1px solid var(--line); }
.topbar-in { max-width: 1200px; margin: 0 auto; display: flex; align-items: center; gap: 12px; padding: 10px 16px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; color: var(--red); font-size: 1.15rem; white-space: nowrap; }
.brand img { width: 34px; height: 34px; }
.brand:hover { text-decoration: none; }
.nav { display: flex; gap: 4px; margin-left: auto; align-items: center; }
.nav a { color: var(--ink-2); padding: 8px 12px; border-radius: 10px; font-weight: 500; font-size: .93rem; }
.nav a:hover, .nav a.active { background: var(--indigo-l); color: var(--indigo); text-decoration: none; }
.bell { position: relative; }
.bell .dot { position: absolute; top: 2px; right: 4px; background: var(--red); color: #fff; border-radius: 9px; font-size: .65rem; padding: 0 5px; line-height: 16px; }
.wrap { max-width: 1200px; margin: 0 auto; padding: 20px 16px 96px; }
.narrow { max-width: 760px; margin-left: auto; margin-right: auto; }
.tabbar { display: none; }
@media (max-width: 760px) {
  .nav .hide-m { display: none; }
  .tabbar { display: flex; position: fixed; bottom: 0; left: 0; right: 0; z-index: 30; background: #fff; border-top: 1px solid var(--line);
    padding: 4px 0 calc(4px + env(safe-area-inset-bottom)); }
  .tabbar a { flex: 1; text-align: center; color: var(--ink-3); font-size: .7rem; padding: 4px 0; }
  .tabbar a .ic { display: block; font-size: 1.25rem; line-height: 1.3; }
  .tabbar a.active { color: var(--red); text-decoration: none; }
  h1 { font-size: 1.35rem; }
}
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.g3 { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.g4 { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
#pr { scroll-margin-top: 80px; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.stack > * + * { margin-top: 12px; }
.spacer { flex: 1; }

/* ---------- cards & components ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }
.card.flat { box-shadow: none; }
.card h3 { margin-bottom: .35em; }
.card-link { display: block; color: inherit; transition: transform .12s, box-shadow .12s; }
.card-link:hover { text-decoration: none; transform: translateY(-2px); box-shadow: 0 6px 22px rgba(20, 30, 60, .1); }
.stat { padding: 16px; }
.stat .v { font-size: 1.6rem; font-weight: 700; line-height: 1.2; }
.stat .l { color: var(--ink-3); font-size: .82rem; }
.stat.red .v { color: var(--red); } .stat.indigo .v { color: var(--indigo); } .stat.green .v { color: var(--green); } .stat.sky .v { color: #1d97b8; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid transparent; border-radius: 10px;
  padding: 10px 16px; font: inherit; font-weight: 600; font-size: .92rem; cursor: pointer; background: var(--indigo); color: #fff;
  text-decoration: none; min-height: 42px; }
.btn:hover { background: var(--indigo-d); text-decoration: none; }
.btn.red { background: var(--red); } .btn.red:hover { background: var(--red-d); }
.btn.green { background: var(--green); } .btn.green:hover { background: var(--green-d); }
.btn.ghost { background: #fff; color: var(--ink); border-color: var(--line); }
.btn.ghost:hover { background: var(--bg); }
.btn.link { background: none; color: var(--indigo); padding: 6px 8px; min-height: 0; }
.btn.danger { background: #fff; color: var(--red); border-color: #f3c2c4; }
.btn.danger:hover { background: var(--red-l); }
.btn.sm { padding: 6px 10px; min-height: 32px; font-size: .83rem; border-radius: 8px; }
.btn.block { width: 100%; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }

.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: .74rem; font-weight: 600; background: var(--indigo-l); color: var(--indigo); white-space: nowrap; }
.badge.red { background: var(--red-l); color: var(--red-d); } .badge.green { background: var(--green-l); color: var(--green-d); }
.badge.amber { background: var(--amber-l); color: #a86a0e; } .badge.sky { background: var(--sky-l); color: #127b97; }
.badge.grey { background: #eef0f4; color: var(--ink-2); }

.bar { height: 8px; background: #edf0f5; border-radius: 99px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: linear-gradient(90deg, var(--green), var(--sky)); border-radius: 99px; }

.alert { padding: 12px 14px; border-radius: 10px; background: var(--indigo-l); color: var(--indigo-d); font-size: .9rem; }
.alert.red { background: var(--red-l); color: var(--red-d); } .alert.green { background: var(--green-l); color: var(--green-d); }
.alert.amber { background: var(--amber-l); color: #8a560a; }

/* ---------- forms ---------- */
label { display: block; font-weight: 500; font-size: .87rem; margin-bottom: 4px; color: var(--ink-2); }
.field { margin-bottom: 14px; }
input, select, textarea { width: 100%; font: inherit; font-size: 16px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: #fff; color: var(--ink); }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--sky); outline-offset: 0; border-color: var(--sky); }
input[type=checkbox], input[type=radio] { width: auto; }
textarea { min-height: 90px; resize: vertical; }
.check { display: flex; gap: 8px; align-items: center; font-weight: 400; color: var(--ink); }
.form-grid { display: grid; gap: 0 14px; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.hint { font-size: .78rem; color: var(--ink-3); margin-top: 3px; }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; }
table { width: 100%; border-collapse: collapse; font-size: .88rem; }
th, td { padding: 10px 12px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { background: #fafbfd; font-weight: 600; color: var(--ink-2); white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
tr.me td { background: var(--sky-l); }

/* ---------- home ---------- */
.hero { background: linear-gradient(135deg, var(--indigo) 0%, #3b4a96 55%, #2f8fb0 100%); color: #fff; border-radius: 20px; padding: 36px 28px; position: relative; overflow: hidden; }
.hero h1 { font-size: 2rem; } .hero p { opacity: .92; max-width: 560px; }
.hero .tiles { position: absolute; right: -30px; top: -30px; width: 240px; opacity: .18; }
@media (max-width: 760px) { .hero { padding: 26px 18px; } .hero h1 { font-size: 1.5rem; } .hero .tiles { width: 160px; } }
.course-card { display: flex; flex-direction: column; height: 100%; }
.course-card .top { height: 6px; border-radius: 6px; margin: -6px 0 12px; }
.price { font-weight: 700; font-size: 1.15rem; color: var(--ink); }
.price s { color: var(--ink-3); font-weight: 400; font-size: .9rem; margin-left: 6px; }
.quote { border-left: 3px solid var(--sky); padding-left: 12px; }
.wa-float { position: fixed; right: 16px; bottom: 20px; z-index: 40; width: 54px; height: 54px; border-radius: 50%; background: #25d366;
  display: flex; align-items: center; justify-content: center; box-shadow: 0 4px 14px rgba(0, 0, 0, .2); }
.wa-float svg { width: 30px; height: 30px; fill: #fff; }
@media (max-width: 760px) { .wa-float { bottom: 76px; width: 48px; height: 48px; } }

/* ---------- syllabus / player ---------- */
.syl-subject { font-weight: 600; padding: 10px 0 4px; color: var(--indigo); }
.syl-module { font-weight: 500; font-size: .9rem; padding: 6px 0; color: var(--ink-2); display: flex; justify-content: space-between; gap: 8px; }
.syl-lec { display: flex; gap: 10px; align-items: center; padding: 8px 10px; border-radius: 10px; color: var(--ink); font-size: .9rem; }
a.syl-lec:hover { background: var(--bg); text-decoration: none; }
.syl-lec.current { background: var(--indigo-l); }
.syl-lec .ic { width: 22px; text-align: center; flex-shrink: 0; }
.syl-lec.locked { color: var(--ink-3); }
.player-layout { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 18px; }
@media (max-width: 960px) { .player-layout { grid-template-columns: 1fr; } }
.video-box { position: relative; background: #000; border-radius: var(--radius); overflow: hidden; aspect-ratio: 16 / 9; user-select: none; -webkit-user-select: none; }
.video-box video, .video-box iframe { width: 100%; height: 100%; border: 0; display: block; }
.watermark { position: absolute; pointer-events: none; color: rgba(255, 255, 255, .42); font-size: 13px; font-weight: 600; text-shadow: 0 0 2px rgba(0, 0, 0, .5);
  transition: top 1.2s ease, left 1.2s ease; white-space: nowrap; z-index: 5; }
.video-empty { color: #cdd3df; display: flex; align-items: center; justify-content: center; height: 100%; text-align: center; padding: 20px; }
.syl-scroll { max-height: 70vh; overflow: auto; }

/* ---------- exam ---------- */
.exam { user-select: none; -webkit-user-select: none; }
.exam-head { position: sticky; top: 0; z-index: 20; background: #fff; border-bottom: 1px solid var(--line); }
.exam-head-in { max-width: 1200px; margin: 0 auto; padding: 10px 16px; display: flex; gap: 12px; align-items: center; }
.timer { font-variant-numeric: tabular-nums; font-weight: 700; font-size: 1.15rem; padding: 6px 12px; border-radius: 10px; background: var(--indigo-l); color: var(--indigo); }
.timer.low { background: var(--red-l); color: var(--red); }
.exam-body { max-width: 1200px; margin: 0 auto; padding: 16px; display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 18px; }
@media (max-width: 900px) { .exam-body { grid-template-columns: 1fr; } .palette-card { order: 2; } }
.stem { font-size: 1.04rem; white-space: pre-wrap; }
.opt { display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; border: 1.5px solid var(--line); border-radius: 12px; cursor: pointer; margin-bottom: 10px; background: #fff; width: 100%; text-align: left; font: inherit; color: inherit; }
.opt:hover { border-color: var(--sky); }
.opt .l { flex-shrink: 0; width: 28px; height: 28px; border-radius: 50%; border: 1.5px solid var(--line); display: flex; align-items: center; justify-content: center; font-weight: 600; font-size: .85rem; }
.opt.sel { border-color: var(--indigo); background: var(--indigo-l); }
.opt.sel .l { background: var(--indigo); border-color: var(--indigo); color: #fff; }
.opt.correct { border-color: var(--green); background: var(--green-l); }
.opt.correct .l { background: var(--green); border-color: var(--green); color: #fff; }
.opt.wrong { border-color: var(--red); background: var(--red-l); }
.opt.wrong .l { background: var(--red); border-color: var(--red); color: #fff; }
.opt[disabled] { cursor: default; }
.palette { display: grid; grid-template-columns: repeat(auto-fill, minmax(38px, 1fr)); gap: 6px; max-height: 50vh; overflow: auto; }
.palette button { height: 36px; border-radius: 8px; border: 1px solid var(--line); background: #fff; font: inherit; font-size: .82rem; cursor: pointer; position: relative; }
.palette button.answered { background: var(--green); border-color: var(--green); color: #fff; }
.palette button.marked { background: var(--amber); border-color: var(--amber); color: #fff; }
.palette button.answered.marked { background: var(--amber); box-shadow: inset 0 -4px 0 var(--green-d); }
.palette button.current { outline: 2px solid var(--indigo); outline-offset: 1px; }
.legend { display: flex; flex-wrap: wrap; gap: 10px; font-size: .75rem; color: var(--ink-3); margin-top: 10px; }
.legend i { display: inline-block; width: 12px; height: 12px; border-radius: 3px; vertical-align: -2px; margin-right: 4px; border: 1px solid var(--line); }
.exam-nav { display: grid; grid-template-columns: 1fr auto 1fr; gap: 8px; margin-top: 12px; }
.exam-nav #next { justify-self: end; } .exam-nav #prev { justify-self: start; }
@media (max-width: 600px) { .exam-nav { grid-template-columns: 1fr 1fr; grid-template-areas: 'mark mark' 'prev next'; }
  .exam-nav #mark { grid-area: mark; } .exam-nav #prev { grid-area: prev; justify-self: stretch; } .exam-nav #next { grid-area: next; justify-self: stretch; } }
.save-state { font-size: .78rem; color: var(--ink-3); }
.save-state.err { color: var(--red); }
.explain { background: var(--sky-l); border-radius: 10px; padding: 12px 14px; font-size: .92rem; white-space: pre-wrap; }

/* ---------- result ---------- */
.score-ring { width: 140px; height: 140px; border-radius: 50%; display: flex; align-items: center; justify-content: center; flex-direction: column; margin: 0 auto; }
.score-ring .p { font-size: 1.9rem; font-weight: 700; line-height: 1; }
.hbar { display: grid; grid-template-columns: 140px 1fr 60px; gap: 10px; align-items: center; font-size: .86rem; margin-bottom: 8px; }
@media (max-width: 500px) { .hbar { grid-template-columns: 100px 1fr 50px; } }

/* ---------- admin ---------- */
.admin-layout { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 20px; }
.side { position: sticky; top: 74px; align-self: start; }
.side a { display: block; padding: 9px 12px; border-radius: 10px; color: var(--ink-2); font-size: .92rem; font-weight: 500; }
.side a:hover, .side a.active { background: var(--indigo-l); color: var(--indigo); text-decoration: none; }
.side .count { float: right; background: var(--red); color: #fff; border-radius: 9px; font-size: .7rem; padding: 0 6px; line-height: 18px; margin-top: 2px; }
@media (max-width: 900px) {
  .admin-layout { grid-template-columns: 1fr; }
  .side { position: static; display: flex; overflow-x: auto; gap: 4px; padding-bottom: 6px; -webkit-overflow-scrolling: touch; }
  .side a { white-space: nowrap; }
  .side .count { float: none; margin-left: 4px; }
}
.tree-subject { border: 1px solid var(--line); border-radius: 12px; margin-bottom: 12px; background: #fff; }
.tree-subject > .head { padding: 10px 14px; background: #fafbfd; border-bottom: 1px solid var(--line); border-radius: 12px 12px 0 0; }
.tree-module { padding: 10px 14px; border-bottom: 1px dashed var(--line); }
.tree-module:last-child { border-bottom: 0; }
.tree-lec { display: flex; gap: 8px; align-items: center; padding: 6px 0 6px 14px; font-size: .9rem; flex-wrap: wrap; }
.err-row td { background: var(--red-l); }
.warn-row td { background: var(--amber-l); }
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.toolbar input, .toolbar select { width: auto; min-width: 140px; flex: 1 1 160px; max-width: 260px; }
.share-card { width: 540px; max-width: 100%; background: linear-gradient(160deg, #fff 0%, #f2f5fd 100%); border: 1px solid var(--line); border-radius: 18px; padding: 22px; }
.share-card .head { display: flex; gap: 12px; align-items: center; border-bottom: 2px solid var(--red); padding-bottom: 10px; margin-bottom: 10px; }
.share-card .head img { width: 46px; }
.share-card table { font-size: .86rem; } .share-card td, .share-card th { padding: 6px 8px; }

/* ---------- modal & toast ---------- */
.modal-back { position: fixed; inset: 0; background: rgba(15, 20, 35, .5); z-index: 100; display: flex; align-items: flex-start; justify-content: center; padding: 5vh 12px; overflow: auto; }
.modal { background: #fff; border-radius: 16px; width: 100%; max-width: 620px; padding: 20px; box-shadow: 0 20px 60px rgba(0, 0, 0, .25); }
.modal.wide { max-width: 900px; }
.toasts { position: fixed; top: 70px; right: 12px; left: 12px; z-index: 200; display: flex; flex-direction: column; align-items: flex-end; gap: 8px; pointer-events: none; }
.toast { background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 10px; font-size: .9rem; max-width: 420px; box-shadow: var(--shadow); pointer-events: auto; }
.toast.err { background: var(--red); } .toast.ok { background: var(--green); }
.loading { padding: 40px; text-align: center; color: var(--ink-3); }
.empty { padding: 28px; text-align: center; color: var(--ink-3); border: 1.5px dashed var(--line); border-radius: var(--radius); background: #fff; }
.footer { border-top: 1px solid var(--line); padding: 20px 16px 90px; text-align: center; color: var(--ink-3); font-size: .82rem; background: #fff; }
.footer a { color: var(--ink-2); margin: 0 6px; }
@media print { .topbar, .tabbar, .wa-float, .footer, .no-print, .side { display: none !important; } body { background: #fff; } .card { box-shadow: none; } }
