/* =========================================================
   ระบบคอร์สเรียนออนไลน์ — สไตล์รวม
   ========================================================= */

:root {
  /* สี */
  --primary: #4f46e5;
  --primary-dark: #4338ca;
  --primary-soft: #eef2ff;
  --primary-ring: rgba(79, 70, 229, 0.16);

  --text: #111827;
  --text-soft: #374151;
  --muted: #6b7280;
  --border: #e5e7eb;
  --border-soft: #f1f3f7;

  --bg: #f7f8fb;
  --surface: #ffffff;

  --success: #059669;
  --success-bg: #ecfdf5;
  --success-border: #a7f3d0;
  --danger: #dc2626;
  --danger-bg: #fef2f2;
  --danger-border: #fecaca;
  --warning: #b45309;
  --warning-bg: #fffbeb;
  --info-bg: #eef2ff;

  /* รูปทรงและเงา */
  --radius: 14px;
  --radius-sm: 9px;
  --radius-pill: 999px;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.05);
  --shadow: 0 2px 6px rgba(16, 24, 40, 0.06), 0 1px 2px rgba(16, 24, 40, 0.04);
  --shadow-lg: 0 18px 40px rgba(16, 24, 40, 0.16);

  --font: "IBM Plex Sans Thai", "Sarabun", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.65;
  color: var(--text);
  background:
    radial-gradient(1100px 460px at 50% -220px, #eceafd 0%, rgba(236, 234, 253, 0) 70%),
    var(--bg);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
}

.container { max-width: 940px; margin: 0 auto; padding: 0 20px; }
.container-wide { max-width: 1180px; }

a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-dark); text-decoration: underline; }

h1 { font-size: 25px; line-height: 1.35; margin: 0 0 6px; letter-spacing: -0.01em; }
h2 { font-size: 18px; line-height: 1.4; margin: 0 0 12px; }
.subtitle { color: var(--muted); margin: 0 0 20px; font-size: 14.5px; }
.section-title {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 34px 0 12px;
}
.muted { color: var(--muted); }
.small { font-size: 12.8px; }
.text-warning { color: var(--warning); }
.hidden { display: none !important; }

/* ===== แถบหัวเว็บ ===== */
.site-header {
  background: rgba(255, 255, 255, 0.86);
  backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 40;
}
.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 62px;
  flex-wrap: wrap;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  font-weight: 700;
  font-size: 16.5px;
  color: var(--text);
  letter-spacing: -0.01em;
}
.brand:hover { text-decoration: none; color: var(--primary); }
.brand-mark {
  width: 38px;
  height: 38px;
  object-fit: contain;
  flex-shrink: 0;
}

.nav { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.nav-link {
  padding: 7px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-soft);
  font-size: 14.5px;
  font-weight: 500;
}
.nav-link:hover { background: var(--primary-soft); color: var(--primary-dark); text-decoration: none; }
.nav-link.is-active { background: var(--primary-soft); color: var(--primary-dark); font-weight: 600; }
.nav-user {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--text-soft);
  font-size: 14px;
  padding: 5px 10px 5px 5px;
  border-radius: var(--radius-pill);
}
a.nav-user:hover { background: var(--primary-soft); color: var(--primary-dark); text-decoration: none; }
a.nav-user.is-active { background: var(--primary-soft); color: var(--primary-dark); }
.avatar {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), #8b83f5);
  color: #fff;
  font-size: 13px;
  font-weight: 700;
}

.site-footer {
  margin-top: 56px;
  padding: 22px 0;
  border-top: 1px solid var(--border);
  color: var(--muted);
  text-align: center;
}

/* ===== การ์ด ===== */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 26px 28px;
  margin: 20px 0;
  box-shadow: var(--shadow-sm);
}
.card-narrow { max-width: 430px; margin-left: auto; margin-right: auto; }
.card-wide { max-width: 660px; margin-left: auto; margin-right: auto; }
.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}
.card-head h2 { margin: 0; }

.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin: 30px 0 10px;
}
.page-head h1 { margin-bottom: 4px; }
.page-head .subtitle { margin-bottom: 0; }
.head-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.col-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.col-2 .card { margin: 0 0 20px; }

/* ===== ฟอร์ม ===== */
.field { margin-bottom: 18px; }
.field label {
  display: block;
  margin-bottom: 7px;
  font-weight: 600;
  font-size: 14px;
  color: var(--text-soft);
}
.field .hint { display: block; color: var(--muted); font-size: 12.8px; margin-top: 6px; font-weight: 400; }
.field .hint code, .syntax-item code {
  background: var(--border-soft);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 1px 6px;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--primary-dark);
}
.req { color: var(--danger); }

input[type="text"],
input[type="email"],
input[type="tel"],
input[type="password"],
input[type="file"],
select,
textarea {
  width: 100%;
  padding: 11px 13px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-family: inherit;
  background: #fff;
  color: var(--text);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
textarea { line-height: 1.65; resize: vertical; }
textarea.mono { font-family: var(--font-mono); font-size: 14px; tab-size: 4; }
input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 4px var(--primary-ring);
}
input[type="file"] { padding: 9px 12px; background: var(--border-soft); cursor: pointer; }
input:disabled { background: var(--border-soft); color: var(--muted); cursor: not-allowed; }
select {
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%236b7280' d='M1 1l5 5 5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 36px;
}

/* ปุ่มเกียรติบัตร */
.btn-cert {
  background: linear-gradient(135deg, #f59e0b, #f97316);
  border-color: transparent;
  color: #fff;
}
.btn-cert:hover { background: linear-gradient(135deg, #d97706, #ea580c); color: #fff; }

/* ช่องค้นหาในหน้ารายชื่อผู้เรียน */
.search-form { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.search-form input[type="text"] { width: 250px; }

.row { display: flex; gap: 14px; }
.row .field { flex: 1; }
.form-actions { display: flex; gap: 10px; margin-top: 24px; flex-wrap: wrap; }
.form-footer { margin-top: 22px; text-align: center; font-size: 14px; color: var(--muted); }
.form-links { display: flex; justify-content: flex-end; font-size: 13.5px; margin: -4px 0 18px; }
.checkbox, .radio { font-weight: 400; display: inline-flex; align-items: center; gap: 8px; cursor: pointer; }
.radio-row { display: flex; gap: 18px; flex-wrap: wrap; }
.fieldset {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  margin: 0 0 18px;
  background: #fcfcfe;
}
.fieldset legend { font-size: 13.5px; font-weight: 600; padding: 0 8px; color: var(--text-soft); }
.choice-row { display: flex; align-items: center; gap: 10px; margin-bottom: 9px; }
.choice-row input[type="text"] { flex: 1; }

/* ===== ปุ่ม ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  background: var(--primary);
  color: #fff;
  border: 1px solid transparent;
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  font-size: 14.5px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  text-align: center;
  line-height: 1.4;
  box-shadow: var(--shadow-sm);
  transition: background 0.15s ease, transform 0.08s ease, box-shadow 0.15s ease;
}
.btn:hover { background: var(--primary-dark); color: #fff; text-decoration: none; box-shadow: var(--shadow); }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: none; box-shadow: 0 0 0 4px var(--primary-ring); }
.btn:disabled, .btn[disabled] { opacity: 0.5; cursor: not-allowed; box-shadow: none; }
.btn-block { display: flex; width: 100%; }
.btn-sm { padding: 7px 13px; font-size: 13.5px; }
.btn-outline { background: transparent; color: var(--primary); border-color: var(--primary); box-shadow: none; }
.btn-outline:hover { background: var(--primary-soft); color: var(--primary-dark); border-color: var(--primary); }
.btn-secondary { background: #fff; color: var(--text-soft); border-color: var(--border); box-shadow: none; }
.btn-secondary:hover { background: var(--border-soft); color: var(--text); border-color: #d7dbe3; }
.btn-danger { background: #fff; color: var(--danger); border-color: var(--danger-border); box-shadow: none; }
.btn-danger:hover { background: var(--danger-bg); border-color: var(--danger); color: var(--danger); }
.btn.is-locked {
  background: #eceef3;
  color: #9aa1ad;
  border-color: #eceef3;
  box-shadow: none;
  pointer-events: none;
}
.btn-icon {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 6px;
  width: 27px;
  height: 24px;
  font-size: 9px;
  line-height: 1;
  color: var(--muted);
  cursor: pointer;
  transition: all 0.15s ease;
}
.btn-icon:hover:not(:disabled) { background: var(--primary-soft); color: var(--primary); border-color: var(--primary); }
.btn-icon:disabled { opacity: 0.3; cursor: not-allowed; }

/* ===== แจ้งเตือน ===== */
.alert {
  padding: 13px 16px;
  border-radius: var(--radius-sm);
  margin: 18px 0;
  font-size: 14px;
  border: 1px solid transparent;
  border-left-width: 3px;
}
.alert-error { background: var(--danger-bg); color: #9f1239; border-color: var(--danger-border); border-left-color: var(--danger); }
.alert-success { background: var(--success-bg); color: #065f46; border-color: var(--success-border); border-left-color: var(--success); }
.alert-info { background: var(--info-bg); color: #3730a3; border-color: #c7d2fe; border-left-color: var(--primary); }
.error-list { margin: 0; padding-left: 20px; }
.error-list li { margin: 3px 0; }

/* ===== ป้ายสถานะ ===== */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: var(--radius-pill);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  vertical-align: middle;
  border: 1px solid transparent;
}
.badge-ok { background: var(--success-bg); color: #047857; border-color: var(--success-border); }
.badge-off { background: #f3f4f6; color: #6b7280; border-color: #e5e7eb; }
.badge-info { background: var(--primary-soft); color: var(--primary-dark); border-color: #c7d2fe; }
.badge-alt { background: #fdf4ff; color: #a21caf; border-color: #f0abfc; }
.badge-danger { background: var(--danger-bg); color: #b91c1c; border-color: var(--danger-border); }
.badge-admin { background: #fff7ed; color: #c2410c; border-color: #fed7aa; margin-left: 5px; }

/* ===== แผง admin ===== */
.admin-bar { border-bottom: 1px solid var(--border); margin-bottom: 2px; }
.admin-tabs { display: flex; gap: 6px; }
.admin-tab {
  padding: 13px 4px;
  margin-right: 14px;
  color: var(--muted);
  font-size: 14.5px;
  font-weight: 500;
  border-bottom: 2px solid transparent;
}
.admin-tab:hover { color: var(--text); text-decoration: none; }
.admin-tab.is-active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }

.breadcrumb { font-size: 13.5px; color: var(--muted); padding: 18px 0 0; }
.breadcrumb .crumb-sep { margin: 0 7px; color: #cbd5e1; }

/* ===== การ์ดสถิติ ===== */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(185px, 1fr));
  gap: 14px;
  margin: 22px 0 10px;
}
.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  box-shadow: var(--shadow-sm);
}
.stat-label { color: var(--muted); font-size: 13px; font-weight: 500; }
.stat-value { font-size: 29px; font-weight: 700; line-height: 1.2; letter-spacing: -0.02em; }
.stat-sub { color: var(--muted); font-size: 12.5px; }

/* ===== ตาราง ===== */
.table-wrap { overflow-x: auto; margin: 0 -4px; padding: 0 4px; }
.table { width: 100%; border-collapse: collapse; font-size: 14.5px; }
.table th, .table td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border-soft);
  text-align: left;
  vertical-align: top;
}
.table th {
  font-size: 12.5px;
  color: var(--muted);
  font-weight: 600;
  white-space: nowrap;
  background: #fafbfd;
  border-bottom-color: var(--border);
}
.table th:first-child { border-top-left-radius: var(--radius-sm); }
.table th:last-child { border-top-right-radius: var(--radius-sm); }
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: #fafbfd; }
.table .num { text-align: center; white-space: nowrap; }
.table .actions-col { text-align: right; }
.row-off { background: #fcfcfd; color: var(--muted); }
.note { margin-top: 16px; }
.empty { color: var(--muted); text-align: center; padding: 30px 0; margin: 0; }

.actions { display: flex; gap: 6px; justify-content: flex-end; flex-wrap: wrap; align-items: center; }
.inline-form { display: inline; margin: 0; }
.order-cell { display: flex; align-items: center; gap: 8px; justify-content: center; }
.order-no { font-weight: 700; color: var(--muted); min-width: 16px; }
.order-btns { display: flex; flex-direction: column; gap: 2px; }

.lesson-cell { display: flex; gap: 13px; align-items: flex-start; }
.thumb {
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  object-fit: cover;
  background: #eef1f5;
  flex-shrink: 0;
}

/* ===== แถบความคืบหน้า ===== */
.progress-row { margin: 16px 0; }
.progress-label {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 14px;
  margin-bottom: 7px;
}
.progress-label strong { font-size: 15px; font-variant-numeric: tabular-nums; }
.progress-bar { background: #eceef4; border-radius: var(--radius-pill); height: 9px; overflow: hidden; }
.progress-bar.slim { height: 5px; margin-top: 9px; }
.progress-fill {
  background: linear-gradient(90deg, var(--primary), #8b83f5);
  height: 100%;
  border-radius: var(--radius-pill);
  transition: width 0.35s ease;
}
.progress-fill.is-pass { background: linear-gradient(90deg, var(--success), #34d399); }
.progress-meta { color: var(--muted); font-size: 12.5px; margin-top: 7px; }
.progress-card { margin: 14px 0; }
.progress-card .card-head h2 { font-size: 17.5px; }

/* ===== การ์ดคอร์ส ===== */
.course-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(268px, 1fr));
  gap: 18px;
  margin: 14px 0 0;
}
.course-card {
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 7px;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.course-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.course-card h2 { font-size: 16.5px; margin-bottom: 2px; }
.course-card-foot { margin-top: auto; padding-top: 16px; }

/* ===== รายการบทเรียน ===== */
.lesson-list { list-style: none; margin: 0; padding: 0; }
.lesson-item {
  display: flex;
  gap: 15px;
  align-items: flex-start;
  padding: 17px 0;
  border-bottom: 1px solid var(--border-soft);
}
.lesson-item:last-child { border-bottom: none; }
.lesson-no {
  width: 31px;
  height: 31px;
  flex-shrink: 0;
  border-radius: 10px;
  background: #eef1f5;
  color: var(--muted);
  display: grid;
  place-items: center;
  font-size: 13px;
  font-weight: 700;
}
.lesson-item.status-completed .lesson-no { background: var(--success-bg); color: #047857; }
.lesson-item.status-in_progress .lesson-no { background: var(--primary-soft); color: var(--primary-dark); }
.lesson-main { flex: 1; min-width: 0; }
.lesson-title { font-weight: 600; color: var(--text); }
.lesson-side { display: flex; flex-direction: column; align-items: flex-end; gap: 7px; flex-shrink: 0; }

/* ===== หน้าเรียน ===== */
.player-card { margin: 18px 0; }
.video-frame {
  position: relative;
  padding-top: 56.25%;
  background: #000;
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}
.video-frame iframe,
.video-frame #yt-player { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.video-shield { position: absolute; inset: 0; cursor: default; }
.player-controls {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  margin: 16px 0 4px;
}
.player-time { font-variant-numeric: tabular-nums; font-size: 14px; color: var(--muted); }
.lesson-nav { display: flex; justify-content: space-between; gap: 12px; margin: 22px 0 0; }

/* ===== โจทย์แบบฝึกหัด ===== */
.exercise-card { margin: 16px 0; }
.question-body {
  background: #fbfcfe;
  border: 1px solid var(--border);
  border-left: 3px solid var(--primary);
  border-radius: var(--radius-sm);
  padding: 16px 18px;
  margin: 0 0 16px;
  font-size: 15.5px;
}
.question-text { white-space: pre-wrap; word-break: break-word; }
.question-text + .question-code, .question-code + .question-text { margin-top: 12px; }
.question-code {
  background: #1e2433;
  color: #e6e9f2;
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  overflow-x: auto;
  margin: 0;
  white-space: pre;
}
.question-code code {
  font-family: var(--font-mono);
  font-size: 13.5px;
  line-height: 1.6;
  background: none;
  padding: 0;
  color: inherit;
}
/* สูตร LaTeX ที่ KaTeX render ออกมา */
.question-body .katex { font-size: 1.08em; }
.katex-display { margin: 0.7em 0; overflow-x: auto; overflow-y: hidden; padding: 2px 0; }

.question-image {
  display: block;
  margin: 0 0 16px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--border-soft);
  max-width: 520px;
}
.question-image img { display: block; width: 100%; height: auto; }
.question-image:hover { border-color: var(--primary); }

/* ตัวอักษรกำกับตัวเลือกแบบไทย ก ข ค ง */
@counter-style thai-choice {
  system: fixed;
  symbols: "ก" "ข" "ค" "ง" "จ" "ฉ";
  suffix: ". ";
}

/* ตัวเลือก — ฝั่ง admin (แสดงเฉลย) */
.choice-list { list-style: none; margin: 0 0 12px; padding: 0; counter-reset: choice; }
.choice-list li {
  position: relative;
  padding: 7px 0 7px 34px;
  counter-increment: choice;
}
.choice-list li::before {
  content: counter(choice, thai-choice);
  position: absolute;
  left: 6px;
  color: var(--muted);
  font-weight: 600;
}
.choice-list li.is-correct { color: #047857; font-weight: 600; }
.choice-list li.is-selected-wrong { color: #b91c1c; }

/* ตัวเลือก — ฝั่งผู้เรียน (กดตอบ) */
.answer-choices { display: flex; flex-direction: column; gap: 10px; margin: 4px 0 0; counter-reset: pick; }
.answer-choice::before {
  content: counter(pick, thai-choice);
  counter-increment: pick;
  flex-shrink: 0;
  width: 26px;
  height: 26px;
  border-radius: 8px;
  background: var(--border-soft);
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  display: grid;
  place-items: center;
  line-height: 1;
}
.answer-choice:has(input:checked)::before { background: var(--primary); color: #fff; }
.answer-choice {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 13px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  background: #fff;
  font-weight: 400;
  transition: border-color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
}
.answer-choice:hover { border-color: var(--primary); background: var(--primary-soft); }
.answer-choice input { margin-top: 4px; accent-color: var(--primary); }
.answer-choice:has(input:checked) {
  border-color: var(--primary);
  background: var(--primary-soft);
  box-shadow: 0 0 0 3px var(--primary-ring);
}

.exercise-card.answer-correct { border-left: 3px solid var(--success); }
.exercise-card.answer-wrong { border-left: 3px solid var(--danger); }
.answer-line { margin: 0 0 12px; }
.answer-chip {
  display: inline-block;
  background: var(--success-bg);
  color: #047857;
  border: 1px solid var(--success-border);
  border-radius: 6px;
  padding: 3px 9px;
  margin-right: 6px;
  font-family: var(--font-mono);
  font-size: 13px;
}
.answer-chip.is-wrong { background: var(--danger-bg); color: #b91c1c; border-color: var(--danger-border); }
.explanation {
  background: var(--info-bg);
  border: 1px solid #c7d2fe;
  border-radius: var(--radius-sm);
  padding: 13px 16px;
  font-size: 14.2px;
  color: #3730a3;
}

/* กล่องคะแนน */
.score-card { display: flex; align-items: center; gap: 24px; border-left: 3px solid var(--danger); }
.score-card.is-pass { border-left-color: var(--success); }
.score-value { font-size: 36px; font-weight: 700; line-height: 1; white-space: nowrap; letter-spacing: -0.02em; }
.score-card.is-pass .score-value { color: var(--success); }
.score-detail { display: flex; flex-direction: column; gap: 3px; }

/* ===== modal ===== */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(17, 24, 39, 0.55);
  backdrop-filter: blur(2px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 60;
}
.modal {
  background: #fff;
  border-radius: 18px;
  padding: 30px;
  max-width: 470px;
  width: 100%;
  box-shadow: var(--shadow-lg);
  animation: modal-in 0.18s ease-out;
}
@keyframes modal-in {
  from { opacity: 0; transform: translateY(10px) scale(0.985); }
  to   { opacity: 1; transform: none; }
}
.modal h2 { margin-bottom: 12px; font-size: 19px; }
.modal p { margin: 0 0 10px; }
.modal-actions { display: flex; gap: 10px; margin-top: 22px; }
.is-blurred { filter: blur(4px); pointer-events: none; user-select: none; }

/* ===== แบนเนอร์สรุปผล ===== */
.result-banner { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; border-left: 3px solid var(--muted); }
.result-banner.is-pass { border-left-color: var(--success); background: linear-gradient(100deg, var(--success-bg), #fff 60%); }
.result-banner.is-fail { border-left-color: #f59e0b; background: linear-gradient(100deg, var(--warning-bg), #fff 60%); }
.result-banner p { margin: 0; }
.result-badge { display: inline-block; padding: 7px 16px; border-radius: var(--radius-pill); font-weight: 700; font-size: 14px; }

/* ===== ตัวช่วยเขียนโจทย์ (ฝั่ง admin) ===== */
.syntax-help {
  margin-top: 10px;
  padding: 13px 15px;
  background: #fbfcfe;
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: var(--text-soft);
  display: flex;
  flex-direction: column;
  gap: 7px;
}
.syntax-item strong { color: var(--text); margin-right: 6px; }

.preview-box { margin-top: 14px; border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; }
.preview-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 14px;
  background: var(--border-soft);
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  font-weight: 600;
  color: var(--text-soft);
}
.preview-body { padding: 16px; background: #fff; }
.preview-body .question-body { margin: 0; }

.current-image {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  margin-bottom: 12px;
  padding: 12px;
  background: var(--border-soft);
  border-radius: var(--radius-sm);
  flex-wrap: wrap;
}
.current-image img { max-width: 210px; border-radius: 8px; border: 1px solid var(--border); display: block; }
.image-preview { margin-top: 12px; }
.image-preview img { max-width: 260px; border-radius: 8px; border: 1px solid var(--border); display: block; }

/* ===== จอเล็ก ===== */
@media (max-width: 860px) {
  .col-2 { grid-template-columns: 1fr; }
}

@media (max-width: 620px) {
  body { font-size: 14.5px; }
  .container { padding: 0 15px; }
  .card { padding: 20px; border-radius: 12px; }
  h1 { font-size: 21px; }
  .row { flex-direction: column; gap: 0; }
  .page-head { flex-direction: column; align-items: stretch; }
  .actions { justify-content: flex-start; }
  .lesson-cell .thumb { display: none; }
  .lesson-item { flex-wrap: wrap; }
  .lesson-side { flex-direction: row; align-items: center; width: 100%; justify-content: space-between; }
  .nav-user { display: none; }
  .score-card { gap: 16px; }
  .header-inner { min-height: 56px; }
}
