/* =====================================================================
   MI E-Learning — theme
   Colour themes follow the Mekong Institute logo (azure / sky / deep blue).
   The active theme is set with <html data-theme="…"> (see js/theme.js).
   ===================================================================== */
:root {
  /* theme: ocean (default) */
  --brand: #0b8fdc;
  --brand-2: #22c1ee;
  --navy: #0a2c52;
  --navy-2: #134a86;
  --top-bg: linear-gradient(120deg, #0a2c52 0%, #0f4a86 60%, #0b8fdc 130%);
  --top-fg: #ffffff;
  --page-glow: rgba(34, 193, 238, .16);

  --brand-soft: color-mix(in srgb, var(--brand) 11%, #fff);
  --brand-ink: color-mix(in srgb, var(--brand) 55%, #0a1a2f);
  --ok: #129a6b;
  --ok-soft: #e0f6ed;
  --ok-ink: #0a6b4a;
  --amber: #d98a00;
  --amber-soft: #fff4de;
  --amber-ink: #8a5800;
  --red: #d13b30;
  --red-soft: #fdecea;
  --ink: #17212f;
  --muted: #5b6a7b;
  --line: #e0e7ef;
  --bg: #f1f5fa;
  --card: #ffffff;
  --radius: 18px;
  --shadow: 0 1px 2px rgba(10, 44, 82, .05), 0 10px 30px rgba(10, 44, 82, .08);
  --shadow-lg: 0 2px 4px rgba(10, 44, 82, .06), 0 18px 44px rgba(10, 44, 82, .14);
}

html[data-theme="cobalt"] {
  --brand: #2563d8; --brand-2: #5b8def;
  --navy: #0b2259; --navy-2: #1b3f95;
  --top-bg: linear-gradient(120deg, #0b2259 0%, #1b3f95 65%, #2563d8 135%);
  --page-glow: rgba(91, 141, 239, .16);
}
html[data-theme="aqua"] {
  --brand: #0899b0; --brand-2: #2fd3d0;
  --navy: #073a4b; --navy-2: #0b5d75;
  --top-bg: linear-gradient(120deg, #073a4b 0%, #0b5d75 62%, #0899b0 135%);
  --page-glow: rgba(47, 211, 208, .15);
}
html[data-theme="sky"] {
  --brand: #0a86d4; --brand-2: #4cc3f5;
  --navy: #0d3560; --navy-2: #1a5fa3;
  --top-bg: #ffffff;
  --top-fg: #0d3560;
  --bg: #eef6fc;
  --page-glow: rgba(76, 195, 245, .22);
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: 'IBM Plex Sans Thai', system-ui, sans-serif;
  background:
    radial-gradient(900px 420px at 85% -80px, var(--page-glow), transparent 70%),
    radial-gradient(700px 380px at -10% 10%, var(--page-glow), transparent 70%),
    var(--bg);
  background-attachment: fixed;
  color: var(--ink);
  line-height: 1.6;
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
}
button, input, select { font: inherit; }
[hidden] { display: none !important; }
main { animation: rise .35s ease both; }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: var(--top-bg); color: var(--top-fg);
  padding: 12px 24px;
  display: flex; align-items: center; gap: 14px;
  box-shadow: 0 4px 24px rgba(10, 44, 82, .18);
}
html[data-theme="sky"] .topbar { box-shadow: 0 1px 0 var(--line), 0 6px 24px rgba(10, 44, 82, .07); }
.topbar .brand { display: flex; align-items: center; gap: 12px; font-weight: 700; letter-spacing: .01em; }
/* โลโก้มีพื้นขาว จึงวางในกรอบขาวมุมมนบนแถบสี */
.topbar .logo-box {
  background: #fff; border-radius: 12px; padding: 3px 10px; height: 46px;
  display: flex; align-items: center; flex: none; box-shadow: 0 2px 10px rgba(0, 0, 0, .15);
}
.topbar .logo-box img { height: 40px; width: auto; display: block; }
.topbar .brand > div, .topbar .btn { white-space: nowrap; }
@media (max-width: 480px) {
  .topbar .brand > div { display: none; }  /* จอมือถือ: แสดงเฉพาะโลโก้ */
}
.topbar .brand small { display: block; font-weight: 400; opacity: .75; font-size: 12px; line-height: 1.2; }
.topbar .spacer { flex: 1; }
.topbar .who { font-size: 14px; opacity: .95; text-align: right; line-height: 1.3; font-weight: 600; }
.topbar .who small { display: block; opacity: .7; font-size: 12px; font-weight: 400; }

/* site theme options (Admin → Appearance) */
.theme-options { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 16px; }
.theme-option {
  display: flex; flex-direction: column; align-items: flex-start; gap: 4px; text-align: left; cursor: pointer;
  background: var(--card); border: 2px solid var(--line); border-radius: var(--radius); padding: 14px;
  font: inherit; color: var(--ink); box-shadow: var(--shadow); transition: border-color .15s, transform .15s;
}
.theme-option:hover { transform: translateY(-2px); border-color: color-mix(in srgb, var(--brand) 45%, var(--line)); }
.theme-option[aria-pressed="true"] { border-color: var(--brand); cursor: default; transform: none; }
.theme-option .swatch { display: block; width: 100%; height: 64px; border-radius: 12px; margin-bottom: 8px; box-shadow: inset 0 0 0 1px rgba(10, 44, 82, .12); }
.theme-option .chip { margin-top: 6px; }
.chip.ok { background: var(--ok-soft); color: var(--ok-ink); }

.wrap { max-width: 980px; margin: 0 auto; padding: 32px 18px 72px; }
.wrap.narrow { max-width: 460px; padding-top: 56px; }

.card {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  border: 1px solid rgba(224, 231, 239, .8);
  padding: 28px;
}
.card + .card { margin-top: 18px; }
h1 { font-size: 26px; margin: 0 0 6px; line-height: 1.3; letter-spacing: -.01em; color: var(--navy); }
h2 { font-size: 20px; margin: 0 0 12px; line-height: 1.3; color: var(--navy); }
.muted { color: var(--muted); }
.small { font-size: 14px; }

/* ---------- buttons / forms ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 0; border-radius: 12px; padding: 11px 22px; cursor: pointer;
  background: linear-gradient(135deg, var(--brand), var(--brand-2)); color: #fff; font-weight: 600;
  box-shadow: 0 4px 14px color-mix(in srgb, var(--brand) 35%, transparent);
  transition: transform .15s, box-shadow .15s, filter .15s;
}
.btn:hover { transform: translateY(-1px); box-shadow: 0 8px 22px color-mix(in srgb, var(--brand) 42%, transparent); }
.btn:active { transform: translateY(0); }
.btn:focus-visible { outline: 3px solid color-mix(in srgb, var(--brand) 35%, transparent); outline-offset: 2px; }
.btn:disabled { background: #c3ced9; box-shadow: none; cursor: not-allowed; transform: none; }
.btn.secondary {
  background: #fff; color: var(--navy); border: 1px solid var(--line); box-shadow: none;
}
.btn.secondary:hover { border-color: var(--brand); color: var(--brand-ink); box-shadow: 0 4px 14px rgba(10, 44, 82, .08); }
.btn.secondary:disabled { background: #f3f6f9; color: #9aa8b6; }
.btn.ghost {
  background: transparent; color: var(--top-fg); border: 1px solid color-mix(in srgb, var(--top-fg) 40%, transparent);
  padding: 7px 14px; font-weight: 500; box-shadow: none;
}
.btn.ghost:hover { background: color-mix(in srgb, var(--top-fg) 12%, transparent); box-shadow: none; }
.btn.danger { background: var(--red); box-shadow: 0 4px 14px rgba(209, 59, 48, .3); }
.btn.ghost:disabled { background: transparent; opacity: .4; }
.btn.block { width: 100%; }
.btn.lg { padding: 15px 28px; font-size: 17px; border-radius: 14px; }

label.field { display: block; margin-bottom: 16px; }
label.field span { display: block; font-size: 14px; font-weight: 600; margin-bottom: 6px; color: var(--navy); }
input[type=text], input[type=email], input[type=password], input[type=number], select, textarea {
  width: 100%; padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px;
  background: #fff; color: var(--ink); transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus {
  outline: 0; border-color: var(--brand);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--brand) 18%, transparent);
}
.error { color: var(--red); font-size: 14px; min-height: 1.4em; margin: 4px 0 0; }

/* ---------- login ---------- */
#view-login .card { padding: 36px 32px; text-align: center; box-shadow: var(--shadow-lg); position: relative; overflow: hidden; }
#view-login .card::before {
  content: ''; position: absolute; inset: 0 0 auto 0; height: 6px;
  background: linear-gradient(90deg, var(--navy), var(--brand), var(--brand-2));
}
#view-login form { text-align: left; margin-top: 22px; }

/* ---------- progress / sections ---------- */
.progress { height: 10px; background: #e5edf5; border-radius: 99px; overflow: hidden; }
.progress > i { display: block; height: 100%; background: linear-gradient(90deg, var(--brand), var(--brand-2)); border-radius: 99px; transition: width .3s; }

.steps { list-style: none; margin: 22px 0 0; padding: 0; display: grid; gap: 12px; }
.steps li {
  display: flex; align-items: center; gap: 14px;
  border: 1px solid var(--line); border-radius: 16px; padding: 14px 18px; background: #fff;
  transition: box-shadow .15s, transform .15s;
}
.steps li:hover { box-shadow: var(--shadow); }
.steps .num {
  flex: none; width: 40px; height: 40px; border-radius: 50%;
  display: grid; place-items: center; font-weight: 700; background: #e9eff6; color: var(--muted);
}
.steps .t { flex: 1; min-width: 0; }
.steps .t b { display: block; font-weight: 600; color: var(--navy); }
.steps .badge { font-size: 13px; padding: 4px 12px; border-radius: 99px; white-space: nowrap; }
.steps li.done .num { background: var(--ok); color: #fff; }
.steps li.done .badge { background: var(--ok-soft); color: var(--ok-ink); }
.steps li.current { border-color: var(--brand); box-shadow: 0 0 0 4px color-mix(in srgb, var(--brand) 16%, transparent); }
.steps li.current .num { background: linear-gradient(135deg, var(--brand), var(--brand-2)); color: #fff; }
.steps li.current .badge { background: var(--amber-soft); color: var(--amber-ink); }
.steps li.locked { opacity: .6; }
.steps li.locked .badge { background: #eef2f6; color: var(--muted); }

.notice {
  border-radius: 14px; padding: 13px 18px; font-size: 14px;
  background: var(--amber-soft); color: #6b4700; border: 1px solid #f3dca8;
}
.notice.ok { background: var(--ok-soft); color: var(--ok-ink); border-color: #b9e6d3; }
.notice ul { margin: 6px 0 0; padding-left: 20px; }

/* ---------- catalog ---------- */
.course-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 20px; margin-top: 20px; }
.course-card {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  display: flex; flex-direction: column; overflow: hidden; border: 1px solid rgba(224, 231, 239, .8);
  transition: transform .2s, box-shadow .2s;
}
.course-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-lg); }
.course-card .cover {
  background: linear-gradient(135deg, var(--navy), var(--navy-2) 60%, var(--brand));
  color: #fff; padding: 20px; display: flex; align-items: flex-end; aspect-ratio: 5 / 2;
}
.course-card .cover h3 { margin: 0; font-size: 20px; line-height: 1.4; }
.course-card .cover-img { aspect-ratio: 5 / 2; background: #e5edf5 center/cover no-repeat; }
.course-card .card-title { margin: 0; font-size: 18px; line-height: 1.4; color: var(--navy); }
.course-card.soon .cover-img { filter: grayscale(.6); }
.home-banner {
  margin: -28px -28px 22px; aspect-ratio: 5 / 2; max-height: 300px; width: calc(100% + 56px);
  background: #e5edf5 center/cover no-repeat; border-radius: var(--radius) var(--radius) 0 0;
}
.course-card .body { padding: 18px 22px 22px; display: flex; flex-direction: column; gap: 12px; flex: 1; }
.course-card .body p { margin: 0; font-size: 14px; color: var(--muted); }
.course-card .facts { display: flex; gap: 8px; flex-wrap: wrap; }
.course-card .foot { margin-top: auto; display: grid; gap: 10px; }
.course-card.soon { opacity: .7; }
.course-card.soon:hover { transform: none; box-shadow: var(--shadow); }
.course-card.soon .cover { background: linear-gradient(135deg, #5d6b7a, #8795a3); }

/* ---------- player ---------- */
.player-head { display: flex; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 16px; }
.player-head .grow { flex: 1; min-width: 220px; }
.video-box {
  position: relative; width: 100%; aspect-ratio: 16 / 9; background: #000;
  border-radius: 16px; overflow: hidden; box-shadow: var(--shadow-lg);
}
.video-box #yt, .video-box iframe { position: absolute; inset: 0; width: 100%; height: 100%; }
/* ชั้นใสบังวิดีโอ: กันคลิก/เลื่อน/เปิดเมนู YouTube */
.video-shield {
  position: absolute; inset: 0; z-index: 2; cursor: default;
  display: grid; place-items: center;
}
.video-shield .big-play {
  width: 88px; height: 88px; border-radius: 50%; border: 0; cursor: pointer;
  background: linear-gradient(135deg, var(--brand), var(--brand-2)); color: #fff; font-size: 32px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, .4), 0 0 0 10px rgba(255, 255, 255, .18);
  transition: transform .15s;
}
.video-shield .big-play:hover { transform: scale(1.06); }
.controls {
  display: flex; align-items: center; gap: 14px; margin-top: 14px; flex-wrap: wrap;
}
.controls .progress { flex: 1; min-width: 160px; }
.controls .time { font-variant-numeric: tabular-nums; font-size: 14px; color: var(--muted); white-space: nowrap; }
.controls #plCC[aria-pressed="true"] { background: var(--brand-soft); border-color: var(--brand); color: var(--brand-ink); }
.meta-row { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 14px; }
.chip {
  font-size: 13px; background: var(--brand-soft); color: var(--brand-ink); border-radius: 99px; padding: 5px 14px; font-weight: 500;
}

/* ---------- modal ---------- */
.modal-back {
  position: fixed; inset: 0; z-index: 50; background: rgba(8, 22, 42, .65); backdrop-filter: blur(5px);
  display: grid; place-items: center; padding: 16px; animation: fade .2s ease both;
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.modal {
  background: #fff; border-radius: 22px; max-width: 580px; width: 100%;
  padding: 28px; box-shadow: 0 30px 80px rgba(0, 0, 0, .4);
  max-height: calc(100vh - 32px); overflow: auto; animation: rise .25s ease both;
}
.modal .tag {
  display: inline-block; font-size: 12px; font-weight: 600; letter-spacing: .03em;
  background: var(--amber-soft); color: var(--amber-ink); border-radius: 99px; padding: 4px 12px; margin-bottom: 10px;
}
.modal h3 { margin: 0 0 16px; font-size: 19px; line-height: 1.45; color: var(--navy); }
.modal .actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 20px; flex-wrap: wrap; }
.shake { animation: shake .35s; }
@keyframes shake {
  20%, 60% { transform: translateX(-6px); }
  40%, 80% { transform: translateX(6px); }
}

.choices { display: grid; gap: 10px; }
.choice {
  display: flex; gap: 12px; align-items: flex-start; text-align: left;
  border: 1.5px solid var(--line); border-radius: 14px; padding: 12px 16px; background: #fff;
  cursor: pointer; width: 100%; color: var(--ink); transition: border-color .15s, background .15s;
}
.choice:hover { border-color: var(--brand); background: color-mix(in srgb, var(--brand) 4%, #fff); }
.choice input { margin-top: 5px; accent-color: var(--brand); }
.choice.selected { border-color: var(--brand); background: var(--brand-soft); }

/* ---------- quiz ---------- */
.q-item { padding: 20px 0; border-top: 1px solid var(--line); }
.q-item:first-of-type { border-top: 0; }
.q-item .q { font-weight: 600; margin-bottom: 12px; color: var(--navy); }
.result-box { text-align: center; padding: 30px 16px; }
.result-box .score { font-size: 48px; font-weight: 700; line-height: 1.1; }
.result-box.fail .score { color: var(--red); }
.result-box.pass .score { color: var(--ok); }

/* ---------- congrats ---------- */
.congrats { text-align: center; padding: 40px 20px; }
.congrats .medal {
  width: 104px; height: 104px; margin: 0 auto 18px; border-radius: 50%;
  background: linear-gradient(135deg, var(--ok), #34c98f); color: #fff; display: grid; place-items: center; font-size: 50px;
  box-shadow: 0 0 0 10px var(--ok-soft), 0 12px 30px rgba(18, 154, 107, .35);
}
.congrats h1 { font-size: 28px; }
.congrats .course { color: var(--navy-2); font-weight: 600; font-size: 18px; margin: 10px 0; }

.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%); z-index: 60;
  background: var(--navy); color: #fff; padding: 13px 20px; border-radius: 14px;
  box-shadow: var(--shadow-lg); font-size: 15px; max-width: calc(100% - 32px);
}

/* ---------- admin ---------- */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 18px; }
.stat {
  background: #fff; border-radius: 16px; box-shadow: var(--shadow); padding: 16px 18px;
  border: 1px solid rgba(224, 231, 239, .8); border-left: 5px solid var(--brand);
}
.stat:nth-child(2) { border-left-color: var(--amber); }
.stat:nth-child(3) { border-left-color: var(--brand-2); }
.stat:nth-child(4) { border-left-color: var(--ok); }
.stat .n { font-size: 30px; font-weight: 700; line-height: 1.2; color: var(--navy); }
.stat .l { font-size: 13px; color: var(--muted); }
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; align-items: center; }
.toolbar input, .toolbar select { width: auto; flex: 1; min-width: 160px; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 12px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 12px; color: var(--muted); font-weight: 600; white-space: nowrap; text-transform: uppercase; letter-spacing: .04em; background: #f7fafd; }
th:first-child { border-radius: 10px 0 0 10px; }
th:last-child { border-radius: 0 10px 10px 0; }
tbody tr { transition: background .12s; }
tbody tr:hover { background: color-mix(in srgb, var(--brand) 4%, #fff); }
td .sub { display: block; color: var(--muted); font-size: 12px; }
.pill { display: inline-block; font-size: 12px; padding: 3px 10px; border-radius: 99px; white-space: nowrap; font-weight: 500; }
.pill.ok { background: var(--ok-soft); color: var(--ok-ink); }
.pill.wait { background: var(--amber-soft); color: var(--amber-ink); }
.pill.no { background: #eef2f6; color: var(--muted); }
.mini-bar { width: 96px; height: 6px; background: #e5edf5; border-radius: 99px; overflow: hidden; margin-top: 4px; }
.mini-bar i { display: block; height: 100%; background: linear-gradient(90deg, var(--brand), var(--brand-2)); }
.link-btn { background: none; border: 0; color: var(--red); cursor: pointer; font-size: 13px; padding: 0; }
.link-btn:hover { text-decoration: underline; }
.dept-cell { white-space: nowrap; }
.dept-cell .edit-dept {
  border: 0; background: none; cursor: pointer; color: var(--muted); font-size: 14px; padding: 0 4px; border-radius: 6px;
}
.dept-cell .edit-dept:hover { color: var(--brand-ink); background: var(--brand-soft); }
.dept-cell input { width: 150px; padding: 6px 10px; border-radius: 8px; }

/* ---------- admin: tabs + course editor ---------- */
.tabs { display: flex; gap: 6px; margin-bottom: 22px; flex-wrap: wrap; background: #fff; border-radius: 14px; padding: 5px; width: fit-content; box-shadow: var(--shadow); max-width: 100%; }
.tab {
  border: 0; background: none; padding: 9px 18px; cursor: pointer; color: var(--muted);
  font-weight: 600; border-radius: 10px; transition: background .15s, color .15s;
}
.tab:hover { color: var(--navy); }
.tab.active { color: #fff; background: linear-gradient(135deg, var(--brand), var(--brand-2)); box-shadow: 0 4px 12px color-mix(in srgb, var(--brand) 35%, transparent); }
.section-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.section-head > div { flex: 1; min-width: 200px; }
.sticky-head {
  position: sticky; top: 70px; z-index: 5; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(8px);
  padding: 12px 0; border-bottom: 1px solid var(--line);
}
.btn.sm { padding: 7px 14px; font-size: 14px; font-weight: 500; border-radius: 10px; }
.icon-btn {
  border: 1px solid var(--line); background: #fff; border-radius: 10px; cursor: pointer;
  width: 34px; height: 34px; display: inline-grid; place-items: center; color: var(--ink); flex: none;
  transition: border-color .15s, background .15s;
}
.icon-btn:hover { border-color: var(--brand); background: var(--brand-soft); }
.icon-btn.del:hover { border-color: var(--red); color: var(--red); background: var(--red-soft); }
.icon-btn:disabled { opacity: .35; cursor: default; }
.row-actions { display: flex; gap: 6px; justify-content: flex-end; flex-wrap: wrap; }
textarea { font: inherit; resize: vertical; min-height: 64px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.grid-3 { display: grid; grid-template-columns: 90px 1fr 1fr; gap: 0 16px; }
.ed-block { border: 1px solid var(--line); border-radius: 16px; padding: 18px; margin-bottom: 16px; background: #fbfdff; }
.ed-block-head { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.ed-block-head b { flex: 1; color: var(--navy); }
.yt-row { display: flex; gap: 12px; align-items: flex-start; }
.yt-row .field { flex: 1; }
.yt-thumb { width: 160px; aspect-ratio: 16/9; border-radius: 10px; background: #e5edf5 center/cover; flex: none; margin-top: 28px; }
.q-block { border: 1.5px dashed #c5d2df; border-radius: 14px; padding: 14px; margin: 12px 0; background: #fff; }
.q-block .ed-block-head { margin-bottom: 8px; }
.choice-row { display: flex; align-items: center; gap: 8px; margin-top: 6px; }
.choice-row input[type=text] { flex: 1; padding: 8px 12px; }
.choice-row input[type=radio] { accent-color: var(--brand); width: 18px; height: 18px; }
.hint { font-size: 12px; color: var(--muted); }
.banner-upload { display: flex; gap: 16px; align-items: flex-start; flex-wrap: wrap; }
.banner-preview {
  width: 100%; max-width: 420px; aspect-ratio: 5 / 2; border-radius: 16px; cursor: pointer;
  border: 2px dashed #c5d2df; background: #f5f9fc center/cover no-repeat;
  display: grid; place-items: center; text-align: center; color: var(--muted); font-size: 14px; line-height: 1.5;
  transition: border-color .15s;
}
.banner-preview[style*="background-image"] { border-style: solid; border-color: var(--line); }
.banner-preview:hover, .banner-preview.drag { border-color: var(--brand); }
.banner-actions { display: flex; flex-direction: column; gap: 8px; align-items: flex-start; flex: 1; min-width: 200px; }
.course-cell { display: flex; gap: 12px; align-items: center; }
.course-cell .thumb {
  width: 100px; aspect-ratio: 5 / 2; border-radius: 8px; flex: none; background: #eef2f6 center/cover;
  display: grid; place-items: center; font-size: 10px; color: var(--muted);
}
.sub-title { font-size: 14px; font-weight: 600; color: var(--navy-2); margin: 14px 0 4px; }

@media (max-width: 720px) {
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .yt-row { flex-direction: column; }
  .yt-thumb { margin-top: 0; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .card { padding: 20px; }
  .home-banner { margin: -20px -20px 18px; width: calc(100% + 40px); }
  .topbar { padding: 10px 16px; }
  .topbar .who { display: none; }
  .wrap.narrow { padding-top: 32px; }
  .sticky-head { top: 62px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* =====================================================================
   Certificate of completion (js/certificate.js)
   Fixed A4-landscape canvas 1123 × 794 px, scaled on screen, real size when printed.
   Colours are the certificate's own (accent chosen by the admin), not the site theme.
   ===================================================================== */
.cert-stage { position: relative; width: 100%; overflow: hidden; border-radius: 6px; box-shadow: var(--shadow-lg); background: #fff; }
.cert-scaler { position: absolute; top: 0; left: 0; width: 1123px; height: 794px; transform-origin: 0 0; }
.cert {
  --c-accent: #0b6fb8;
  --c-ink: #1d2733;
  --c-soft: color-mix(in srgb, var(--c-accent) 12%, #fff);
  position: relative; width: 1123px; height: 794px; overflow: hidden;
  background: #fff; color: var(--c-ink);
  font-family: 'IBM Plex Sans Thai', system-ui, sans-serif;
  -webkit-print-color-adjust: exact; print-color-adjust: exact;
}
.cert-bg { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.cert-inner {
  position: absolute; inset: 70px 110px 80px; z-index: 1;
  display: flex; flex-direction: column; align-items: center; text-align: center;
}
.cert-logo { height: 78px; width: auto; margin-bottom: 18px; }
.cert-heading {
  font-family: 'Playfair Display', 'IBM Plex Sans Thai', serif; font-weight: 700;
  font-size: 46px; line-height: 1.15; color: var(--c-accent); letter-spacing: .02em;
}
.cert-rule { width: 120px; height: 3px; background: var(--c-accent); margin: 18px 0 22px; border-radius: 3px; }
.cert-intro, .cert-body, .cert-date { font-size: 19px; color: #4a5664; }
.cert-name {
  font-family: 'Playfair Display', 'IBM Plex Sans Thai', serif; font-style: italic; font-weight: 600;
  font-size: 50px; line-height: 1.2; margin: 10px 0 12px; padding: 0 30px 8px;
  border-bottom: 1px solid color-mix(in srgb, var(--c-accent) 40%, #fff); min-width: 520px;
}
.cert-course { font-size: 27px; font-weight: 700; line-height: 1.3; margin: 10px 0 14px; color: var(--c-ink); max-width: 820px; }
.cert-date { margin-top: 2px; }
.cert-signers { margin-top: auto; display: flex; gap: 120px; justify-content: center; }
.cert-signer { width: 260px; display: flex; flex-direction: column; align-items: center; }
.cert-sig { height: 62px; display: flex; align-items: flex-end; justify-content: center; }
.cert-sig img { max-height: 62px; max-width: 240px; }
.cert-sig-line { width: 100%; height: 1px; background: #8995a3; margin: 4px 0 8px; }
.cert-sig-name { font-weight: 600; font-size: 17px; }
.cert-sig-title { font-size: 14px; color: #5b6a7b; }
.cert-no { position: absolute; right: 58px; bottom: 44px; font-size: 12px; color: #7b8794; letter-spacing: .04em; z-index: 1; }

/* Classic: double border in the accent colour */
.cert--classic .cert-frame {
  position: absolute; inset: 22px; border: 3px solid var(--c-accent);
  outline: 1px solid var(--c-accent); outline-offset: -12px;
  background: linear-gradient(180deg, #fff, var(--c-soft));
}
.cert--classic .cert-band { display: none; }

/* Modern: colour band on the left, text left-aligned */
.cert--modern .cert-frame { display: none; }
.cert--modern .cert-band {
  position: absolute; left: 0; top: 0; bottom: 0; width: 240px;
  background: linear-gradient(160deg, var(--c-accent), color-mix(in srgb, var(--c-accent) 55%, #0a1a2f));
}
.cert--modern .cert-band::after {
  content: ''; position: absolute; right: -60px; top: 0; bottom: 0; width: 60px;
  background: linear-gradient(90deg, var(--c-soft), transparent);
}
.cert--modern .cert-inner { inset: 70px 90px 80px 330px; align-items: flex-start; text-align: left; }
.cert--modern .cert-name { padding-left: 0; }
.cert--modern .cert-signers { justify-content: flex-start; gap: 80px; }

/* Minimal: white page, accent line only */
.cert--minimal .cert-frame { position: absolute; left: 0; right: 0; top: 0; height: 10px; background: var(--c-accent); }
.cert--minimal .cert-band { display: none; }
.cert--minimal .cert-heading { font-family: 'IBM Plex Sans Thai', system-ui, sans-serif; text-transform: uppercase; letter-spacing: .12em; font-size: 36px; }
.cert--minimal .cert-name { font-style: normal; border-bottom: 0; }

/* With an uploaded background the admin's artwork provides the frame */
.cert.has-bg .cert-frame, .cert.has-bg .cert-band { display: none; }

/* Trainee certificate view */
.cert-toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 16px; }
.cert-toolbar .grow { flex: 1; }

/* Admin: certificate editor */
.cert-editor { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.25fr); gap: 20px; align-items: start; }
.cert-editor .cert-preview-wrap { position: sticky; top: 150px; }   /* below the top bar + sticky editor toolbar */
.signer-block { border: 1px dashed #c9d3dd; border-radius: 10px; padding: 12px; margin-bottom: 10px; background: #fff; }
.sig-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.sig-thumb { width: 150px; height: 50px; border: 1px solid var(--line); border-radius: 6px; background: #fff center/contain no-repeat; }
.check-row { display: flex; gap: 18px; flex-wrap: wrap; margin: 4px 0 14px; }
.check-row label { display: flex; align-items: center; gap: 6px; font-size: 14px; cursor: pointer; }
input[type=color] { width: 56px; height: 40px; padding: 2px; border: 1px solid var(--line); border-radius: 8px; background: #fff; cursor: pointer; }

/* Admin: certificate overlay for reprinting */
.cert-overlay { position: fixed; inset: 0; z-index: 60; background: rgba(9, 22, 40, .72); display: grid; place-items: center; padding: 16px; }
.cert-overlay .panel { background: var(--card); border-radius: 16px; padding: 18px; width: min(1000px, 100%); max-height: calc(100vh - 32px); overflow: auto; }

@media (max-width: 900px) {
  .cert-editor { grid-template-columns: 1fr; }
  .cert-editor .cert-preview-wrap { position: static; }
}

/* Printing a certificate: only the certificate, on one A4 landscape page */
#cert-print { display: none; }
@media print {
  html.cert-printing body > *:not(#cert-print) { display: none !important; }
  html.cert-printing body { background: #fff !important; margin: 0; }
  html.cert-printing #cert-print { display: block; }
  html.cert-printing #cert-print .cert { width: 297mm; height: 210mm; }
  @page { size: A4 landscape; margin: 0; }
}

/* Quiz answer review (shown after passing) */
.review h2 { margin-bottom: 8px; }
.rv-item { border-top: 1px solid var(--line); padding: 16px 0; }
.rv-q { display: flex; gap: 10px; font-weight: 600; margin-bottom: 10px; }
.rv-mark {
  flex: none; width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center;
  font-size: 13px; color: #fff; margin-top: 1px;
}
.rv-ok .rv-mark { background: var(--ok); }
.rv-bad .rv-mark { background: var(--red); }
.rv-choices { list-style: none; margin: 0; padding: 0 0 0 34px; display: grid; gap: 6px; }
.rv-choices li {
  display: flex; justify-content: space-between; gap: 12px; align-items: center;
  border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; font-size: 15px;
}
.rv-choices li em { font-style: normal; font-size: 12px; font-weight: 600; white-space: nowrap; }
.rv-choices li.right { border-color: var(--ok); background: var(--ok-soft); }
.rv-choices li.right em { color: var(--ok-ink); }
.rv-choices li.wrong { border-color: var(--red); background: var(--red-soft); }
.rv-choices li.wrong em { color: var(--red); }

/* score on the Congratulations card */
.done-score {
  display: inline-flex; flex-direction: column; align-items: center; gap: 2px; margin-top: 14px;
  padding: 12px 28px; border-radius: 16px; background: var(--ok-soft); color: var(--ok-ink);
}
.done-score small { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; font-weight: 600; }
.done-score b { font-size: 34px; line-height: 1.1; font-variant-numeric: tabular-nums; }
.done-score a { font-size: 13px; color: var(--ok-ink); margin-top: 2px; }
