/* ===================================================================
   ระบบสอบออนไลน์ - Shared Stylesheet (v3 — "Bright Analytics" design system)
   ---------------------------------------------------------------
   แนวคิด: แดชบอร์ดสอบที่ดูทันสมัย สดใส อ่านง่าย น่าเชื่อถือ
   - พื้นหลังฟ้าอ่อนอมม่วง แผงข้อมูลสีขาวลอยตัว มุมโค้งมน เงานุ่ม
   - การ์ดสถิติไล่สีสด (blue / mint / amber / violet / rose) พร้อมไอคอนวงกลม
   - หัวเรื่องตัวหนาแบบ display พร้อมคำเน้นไล่สี (gradient text)
   - ตัวพิมพ์: Kanit (หัวข้อ) + IBM Plex Sans Thai (เนื้อหา) + IBM Plex Mono (ข้อมูล/รหัส)
   =================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Kanit:wght@500;600;700;800&family=IBM+Plex+Sans+Thai:wght@400;500;600;700&family=IBM+Plex+Mono:wght@500;600;700&display=swap');

:root {
  /* ---- surfaces & ink ---- */
  --paper: #eef1fb;
  --card: #ffffff;
  --ink: #171a2b;
  --ink-soft: #656b82;
  --line: #e7e9f5;
  --line-soft: #f2f3fb;

  /* ---- brand: indigo/blue (precision / system) ---- */
  --brand-900: #171b45;
  --brand-700: #29308c;
  --brand-600: #3448d1;
  --brand-500: #4f6df5;
  --brand-100: #e7ecff;

  /* ---- mint/emerald: verified / trustworthy ---- */
  --mint-700: #0a7a5c;
  --mint-600: #15a874;
  --mint-100: #dbf7ea;

  /* ---- amber: caution / highlight ---- */
  --amber-600: #b5730f;
  --amber-500: #f0930f;
  --amber-100: #fdf0da;

  /* ---- rose: risk ---- */
  --rose-600: #c2373f;
  --rose-500: #ef4453;
  --rose-100: #fde3e6;

  /* ---- violet: secondary accent (stat cards) ---- */
  --violet-600: #6c3ce0;
  --violet-500: #7c5cf5;
  --violet-100: #ece5ff;

  /* legacy aliases kept so nothing else in the codebase breaks */
  --navy-900: var(--brand-900);
  --navy-800: var(--brand-700);
  --navy-700: var(--brand-600);
  --teal-500: var(--mint-600);
  --teal-600: var(--mint-700);
  --teal-100: var(--mint-100);
  --red-500: var(--rose-500);
  --red-100: var(--rose-100);
  --green-600: var(--mint-700);
  --green-100: var(--mint-100);

  --radius: 20px;
  --radius-sm: 12px;
  --radius-lg: 28px;
  --shadow: 0 1px 2px rgba(23, 26, 43, 0.04), 0 10px 28px rgba(41, 48, 110, 0.08);
  --shadow-lift: 0 20px 46px rgba(30, 27, 82, 0.18);
  --mono: 'IBM Plex Mono', monospace;
  --sans: 'IBM Plex Sans Thai', 'Sarabun', sans-serif;
  --display: 'Kanit', 'IBM Plex Sans Thai', sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

/* soft color-wash background, mirrors a bright analytics dashboard */
body {
  background:
    radial-gradient(760px 420px at 8% -6%, rgba(79, 109, 245, 0.16), transparent 60%),
    radial-gradient(680px 420px at 96% 0%, rgba(124, 92, 245, 0.14), transparent 55%),
    radial-gradient(900px 600px at 50% 110%, rgba(21, 168, 116, 0.08), transparent 60%),
    var(--paper);
  background-attachment: fixed;
}

a { color: var(--mint-700); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3, h4 {
  margin: 0 0 8px;
  font-weight: 700;
  color: var(--brand-900);
  font-family: var(--display);
  letter-spacing: 0.01em;
}
h1 { font-size: 2.4rem; font-weight: 800; letter-spacing: 0; }
h2 { font-size: 1.4rem; font-weight: 700; }
h3 { font-size: 1.05rem; font-weight: 600; }
p { margin: 0 0 12px; color: var(--ink-soft); }

.mono { font-family: var(--mono); letter-spacing: 0.02em; }

/* gradient headline accent — use by wrapping the emphasized word(s) */
.grad-text {
  background: linear-gradient(100deg, var(--brand-600) 10%, var(--mint-600) 90%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

/* ---------- layout shells ---------- */
.page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  background: rgba(255, 255, 255, 0.72);
  backdrop-filter: blur(10px);
  color: var(--brand-900);
  padding: 16px 26px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 30;
}
.topbar .brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-family: var(--display);
  font-size: 1.08rem;
  letter-spacing: 0.01em;
  color: var(--brand-900);
}
/* signature scan-ring mark, replaces the old plain dot */
.topbar .brand .dot {
  width: 36px; height: 36px;
  flex-shrink: 0;
  position: relative;
  display: inline-block;
  border-radius: 0;
  background: url("../assets/sirichai-secure-exam-icon.png") center / contain no-repeat;
  box-shadow: none;
}
.topbar .brand .dot::before {
  content: none;
}
.topbar .brand .dot::after {
  content: none;
}
.topbar a.back,
.topbar button.back {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--brand-700);
  font-size: 0.88rem;
  font-weight: 600;
  padding: 8px 16px;
  border-radius: 20px;
  background: var(--brand-100);
  transition: background .15s, color .15s;
  border: 0;
  cursor: pointer;
  font-family: inherit;
}
.topbar a.back .ic,
.topbar button.back .ic {
  width: 18px;
  height: 18px;
}
.topbar a.back:hover,
.topbar button.back:hover { background: var(--brand-600); color: #fff; text-decoration: none; }

.container {
  width: 100%;
  max-width: 980px;
  margin: 0 auto;
  padding: 40px 20px 64px;
  flex: 1;
}
.container.wide { max-width: 1240px; }

/* ---------- eyebrow / pill badge (matches reference "TEACHER ANALYTICS DASHBOARD") ---------- */
.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--sans);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--brand-600);
  background: var(--brand-100);
  padding: 8px 16px;
  border-radius: 999px;
  margin-bottom: 16px;
}

/* ---------- cards & sections ---------- */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 28px 30px;
  margin-bottom: 20px;
  position: relative;
  overflow: hidden;
}
.card + .card { margin-top: 0; }

.section-label {
  font-family: var(--mono);
  font-size: 0.7rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--mint-700);
  font-weight: 600;
  margin-bottom: 8px;
  display: block;
}
.section-label::before {
  content: "◆ ";
  color: var(--brand-500);
  font-size: 0.65rem;
}

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 20px; }
@media (max-width: 720px) {
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .image-link-tools { grid-template-columns: 1fr; }
}

/* ---------- form elements ---------- */
label { display: block; font-size: 0.86rem; font-weight: 600; color: var(--brand-900); margin-bottom: 6px; }
.field { margin-bottom: 20px; }
.hint { font-size: 0.8rem; color: var(--ink-soft); margin-top: 4px; }
.hint .mono { color: var(--brand-700); font-weight: 600; }
.hint li { margin-bottom: 4px; }

/* ---------- docx import pattern box ---------- */
.docx-pattern-box {
  background: var(--line-soft);
  border: 1.5px dashed #c9cdec;
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 0.78rem;
  line-height: 1.38;
  color: var(--ink);
  white-space: normal;
  max-height: 260px;
  overflow-y: auto;
  scrollbar-gutter: stable;
}
.docx-pattern-box > div {
  margin: 0 0 3px;
}
.docx-pattern-box > div[style*="height"] {
  height: 5px !important;
}
.docx-pattern-note {
  color: var(--mint-700);
  font-weight: 600;
  font-family: var(--sans);
}

input[type="text"], input[type="password"], input[type="number"], input[type="date"],
textarea, select {
  width: 100%;
  padding: 13px 16px;
  border: 1.5px solid var(--line);
  border-radius: var(--radius-sm);
  font-family: var(--sans);
  font-size: 0.96rem;
  background: var(--line-soft);
  color: var(--ink);
  transition: border-color .15s, box-shadow .15s, background .15s;
}
input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--brand-500);
  background: #fff;
  box-shadow: 0 0 0 4px rgba(79, 109, 245, 0.15);
}
textarea { resize: vertical; min-height: 84px; }
.rich-text-toolbar {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px;
  margin-bottom: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}
.rich-text-btn {
  width: 32px;
  height: 30px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: var(--brand-800);
  font-weight: 800;
  cursor: pointer;
}
.rich-text-btn:hover,
.rich-text-btn:focus {
  border-color: var(--brand-200);
  background: #fff;
  outline: none;
}
.rich-text-input {
  width: 100%;
  min-height: 96px;
  padding: 13px 16px;
  border: 1.5px solid var(--line);
  border-radius: 6px;
  background: #fff;
  line-height: 1.55;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.rich-text-input-sm {
  min-height: 46px;
  flex: 1;
}
.rich-text-input:focus {
  outline: none;
  border-color: var(--brand-500);
  box-shadow: 0 0 0 3px rgba(64, 119, 173, 0.14);
}
.rich-text-input:empty::before {
  content: attr(data-placeholder);
  color: #8995a6;
  pointer-events: none;
}
.qTextOut,
.option-text,
.part-instruction-text {
  overflow-wrap: anywhere;
}

/* ---------- buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  justify-content: center;
  padding: 13px 24px;
  border-radius: 999px;
  border: none;
  font-family: var(--sans);
  font-weight: 600;
  font-size: 0.94rem;
  cursor: pointer;
  transition: transform .1s, box-shadow .15s, background .15s, filter .15s;
}
.btn:active { transform: translateY(1px) scale(0.99); }
.btn-primary { background: linear-gradient(135deg, var(--brand-600), var(--brand-500)); color: #fff; box-shadow: 0 8px 18px rgba(52, 72, 209, 0.32); }
.btn-primary:hover { filter: brightness(1.06); }
.btn-navy { background: linear-gradient(135deg, var(--mint-700), var(--mint-600)); color: #fff; box-shadow: 0 8px 18px rgba(21, 168, 116, 0.28); }
.btn-navy:hover { filter: brightness(1.06); }
.btn-outline { background: #fff; color: var(--brand-700); border: 1.5px solid var(--line); }
.btn-outline:hover { border-color: var(--brand-500); color: var(--brand-600); background: var(--brand-100); }
.btn-danger { background: var(--rose-500); color: #fff; }
.btn-danger:hover { background: var(--rose-600); }
.btn-sm { padding: 9px 18px; font-size: 0.85rem; border-radius: 999px; }

.draft-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 46px;
  padding: 10px 12px;
  border: 1.5px solid var(--line);
  border-radius: 12px;
  background: #fff;
  color: var(--muted);
  font-size: 0.9rem;
}
.btn-block { width: 100%; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* icon glyphs used inside buttons/links (replaces emoji) */
.ic { display: inline-flex; width: 1em; height: 1em; flex-shrink: 0; }
.ic svg { width: 100%; height: 100%; }

/* ---------- choice cards (home page) ---------- */
.choice-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  margin-top: 32px;
}
@media (max-width: 720px) { .choice-grid { grid-template-columns: 1fr; } }
.choice-card {
  background: var(--card);
  border: 1.5px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 40px 28px;
  text-align: center;
  cursor: pointer;
  transition: transform .18s cubic-bezier(.2,.8,.2,1), box-shadow .18s, border-color .18s;
  text-decoration: none;
  display: block;
  position: relative;
  overflow: hidden;
}
.choice-card:hover {
  transform: translateY(-6px);
  box-shadow: var(--shadow-lift);
  border-color: transparent;
}
.choice-card .icon {
  width: 68px; height: 68px; border-radius: 22px;
  background: linear-gradient(135deg, var(--brand-100), #fff);
  color: var(--brand-600);
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 20px;
  box-shadow: inset 0 0 0 1.5px rgba(79, 109, 245, 0.18);
}
.choice-card:nth-child(2) .icon {
  background: linear-gradient(135deg, var(--mint-100), #fff);
  color: var(--mint-700);
  box-shadow: inset 0 0 0 1.5px rgba(21, 168, 116, 0.2);
}
.choice-card .icon svg { width: 36px; height: 36px; }
.choice-card h3 { margin-bottom: 6px; font-size: 1.2rem; }
.choice-card p { margin: 0; font-size: 0.9rem; }

/* ---------- stat cards (colorful gradient KPI tiles) ---------- */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 18px;
  margin: 22px 0 28px;
}
.stat-card {
  border-radius: var(--radius);
  padding: 22px 22px 24px;
  color: #fff;
  position: relative;
  overflow: hidden;
  box-shadow: 0 14px 30px -12px rgba(23, 26, 43, 0.35);
  min-height: 132px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}
.stat-card::after {
  content: "";
  position: absolute;
  right: -30px; bottom: -34px;
  width: 120px; height: 120px;
  border-radius: 50%;
  background: rgba(255,255,255,0.10);
}
.stat-card .stat-top {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 0.78rem; font-weight: 700; letter-spacing: 0.02em;
  opacity: 0.95; position: relative; z-index: 1;
}
.stat-card .stat-top .stat-ic {
  width: 30px; height: 30px; border-radius: 9px;
  background: rgba(255,255,255,0.2);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.stat-card .stat-top .stat-ic svg { width: 16px; height: 16px; }
.stat-card .stat-value {
  font-family: var(--display); font-weight: 800; font-size: 2.1rem;
  margin: 10px 0 4px; position: relative; z-index: 1; line-height: 1;
}
.stat-card .stat-desc { font-size: 0.78rem; opacity: 0.92; margin: 0; position: relative; z-index: 1; }

.stat-blue   { background: linear-gradient(135deg, #2f6fed, #4f6df5); }
.stat-mint   { background: linear-gradient(135deg, #0f9a6c, #22c08c); }
.stat-amber  { background: linear-gradient(135deg, #e08a12, #f5a635); }
.stat-violet { background: linear-gradient(135deg, #6c3ce0, #8b6cf7); }
.stat-rose   { background: linear-gradient(135deg, #d43b4a, #ef6a76); }

/* ---------- question builder ---------- */
.q-block {
  border: 1.5px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
  background: var(--line-soft);
  position: relative;
  transition: border-color .15s;
}
.q-block:hover { border-color: #c9cdec; }
.instruction-block,
.preview-part-instruction,
.exam-part-instruction {
  border-color: #bfdbfe;
  background: #eff6ff;
}
.instruction-block .q-num,
.part-instruction-text {
  color: #163b66;
}
.part-instruction-text {
  margin-top: 8px;
  white-space: pre-wrap;
  font-weight: 600;
  line-height: 1.55;
}
.q-block.drag-ready,
.q-block.dragging {
  border-color: var(--brand-500);
}
.q-block.dragging {
  opacity: 0.88;
  box-shadow: var(--shadow-lift);
  background: #fff;
  cursor: grabbing;
}
.q-block.q-flash {
  animation: qFlash 0.9s ease;
}
@keyframes qFlash {
  0% { box-shadow: 0 0 0 4px rgba(21, 168, 116, 0.18); border-color: var(--mint-600); }
  100% { box-shadow: var(--shadow); border-color: var(--line); }
}
.q-block .q-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 14px;
  gap: 10px;
}
.q-title {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.drag-handle {
  width: 32px;
  height: 32px;
  border: 1.5px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: var(--ink-soft);
  cursor: grab;
  touch-action: none;
  font-family: var(--mono);
  font-size: 1.05rem;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.drag-handle:hover {
  border-color: var(--brand-500);
  color: var(--brand-600);
  background: var(--brand-100);
}
.drag-handle:active,
.question-dragging .drag-handle {
  cursor: grabbing;
}
.q-num {
  font-family: var(--mono);
  font-weight: 600;
  color: var(--brand-600);
  font-size: 0.83rem;
  background: var(--brand-100);
  padding: 3px 10px;
  border-radius: 20px;
}
.opt-row {
  display: flex; align-items: center; gap: 10px; margin-bottom: 8px;
}
.opt-row .opt-letter {
  font-family: var(--mono); font-weight: 700; color: var(--brand-600);
  width: 24px; text-align: center; flex-shrink: 0;
  background: var(--brand-100); border-radius: 6px; padding: 2px 0;
}
.opt-row input[type="text"] { flex: 1; }
.opt-row input[type="radio"] { width: 19px; height: 19px; accent-color: var(--mint-600); flex-shrink: 0; }
.icon-btn {
  background: none; border: none; cursor: pointer; color: var(--ink-soft);
  font-size: 1rem; padding: 6px 9px; border-radius: 8px;
  display: inline-flex; align-items: center; justify-content: center;
  transition: background .15s, color .15s;
}
.icon-btn:hover { background: var(--rose-100); color: var(--rose-500); }
.icon-btn.neutral:hover { background: var(--brand-100); color: var(--brand-600); }
.thumb-preview {
  max-width: 220px; max-height: 140px; border-radius: 12px; margin-top: 10px;
  border: 1px solid var(--line); display: block;
}
.thumb-gallery {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 10px;
}
.image-link-tools {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: end;
  margin-top: 10px;
}
.image-link-tools textarea {
  min-height: 72px;
  resize: vertical;
}
@media (max-width: 720px) {
  .image-link-tools { grid-template-columns: 1fr; }
}
.thumb-item {
  position: relative;
  width: 150px;
}
.thumb-item .thumb-preview {
  width: 150px;
  height: 96px;
  object-fit: contain;
  background: #fff;
  margin-top: 0;
}
.thumb-item .removeImageBtn {
  position: absolute;
  top: 4px;
  right: 4px;
  background: rgba(255,255,255,0.92);
}
.thumb-error,
.image-load-message {
  display: none;
  border: 1px dashed var(--rose-500);
  border-radius: 8px;
  background: var(--rose-100);
  color: var(--rose-600);
  padding: 12px;
  font-size: 0.82rem;
  line-height: 1.45;
}
.thumb-error {
  width: 150px;
  height: 96px;
  align-items: center;
  justify-content: center;
  text-align: center;
}
.image-load-failed .thumb-preview {
  display: none;
}
.image-load-failed .thumb-error {
  display: flex;
}
.image-load-message {
  display: block;
  margin-top: 10px;
}
.qTextOut,
.question-text,
.option-text {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.question-images {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 34px 14px;
  background: rgba(20, 24, 42, 0.45);
  overflow: auto;
}
.modal-card {
  width: min(860px, 100%);
  max-height: calc(100vh - 68px);
  overflow: auto;
  background: #fff;
  border-radius: 18px;
  box-shadow: var(--shadow-lift);
  padding: 22px;
}
.modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}
.preview-instructions {
  padding: 14px 16px;
  border: 1.5px solid var(--line);
  border-radius: 12px;
  background: var(--brand-100);
  color: var(--ink);
  white-space: pre-wrap;
  margin-bottom: 14px;
}
.preview-question {
  margin-bottom: 14px;
}
.question-image {
  max-width: 100%;
  max-height: 360px;
  object-fit: contain;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
}

/* ---------- badges & tags ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 12px; border-radius: 999px;
  font-size: 0.76rem; font-weight: 700;
  font-family: var(--mono);
}
.badge::before {
  content: "";
  width: 6px; height: 6px; border-radius: 50%;
  background: currentColor;
  flex-shrink: 0;
}
.badge-green { background: var(--mint-100); color: var(--mint-700); }
.badge-amber { background: var(--amber-100); color: var(--amber-600); }
.badge-red { background: var(--rose-100); color: var(--rose-600); }
.badge-teal { background: var(--mint-100); color: var(--mint-700); }
.badge-gray { background: #eceef7; color: var(--ink-soft); }

/* ---------- reliability ring (signature element) ---------- */
.ring-wrap { display: flex; align-items: center; gap: 14px; }
.ring {
  width: 58px; height: 58px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--mono); font-weight: 600; font-size: 0.8rem;
  flex-shrink: 0;
  filter: drop-shadow(0 4px 10px rgba(30, 27, 82, 0.12));
}
.ring-label { font-size: 0.78rem; color: var(--ink-soft); }
.ring-label strong { display: block; font-size: 0.95rem; color: var(--ink); font-family: var(--display); }

/* ---------- tables ---------- */
table.data {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 0.9rem;
}
table.data th {
  text-align: left;
  font-family: var(--mono);
  font-size: 0.7rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-soft);
  border-bottom: 2px solid var(--line);
  padding: 13px 12px;
  white-space: nowrap;
  background: var(--line-soft);
}
table.data th:first-child { border-radius: 12px 0 0 12px; }
table.data th:last-child { border-radius: 0 12px 12px 0; }
table.data td {
  padding: 14px 12px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}
table.data tr:hover td { background: #fafaff; }

.dashboard-tools {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(220px, 1fr);
  gap: 14px;
  align-items: end;
  margin: 8px 0 12px;
}
.dashboard-tools .field { margin-bottom: 0; }

.exam-filter-panel {
  display: grid;
  grid-template-columns: minmax(260px, 1.35fr) minmax(220px, 0.65fr);
  gap: 14px;
  align-items: end;
  margin: 14px 0 8px;
}
.exam-filter-panel .field { margin-bottom: 0; }
@media (max-width: 720px) {
  .dashboard-tools,
  .exam-filter-panel { grid-template-columns: 1fr; }
}

/* ---------- alerts / banners ---------- */
.banner {
  border-radius: var(--radius-sm);
  padding: 13px 18px;
  font-size: 0.9rem;
  margin-bottom: 18px;
  display: none;
  border-left: 4px solid transparent;
  font-weight: 500;
}
.banner.show { display: block; }
.banner-error { background: var(--rose-100); color: var(--rose-600); border-left-color: var(--rose-500); }
.banner-success { background: var(--mint-100); color: var(--mint-700); border-left-color: var(--mint-600); }
.banner-info { background: var(--brand-100); color: var(--brand-700); border-left-color: var(--brand-500); }

/* ---------- exam-taking chrome ---------- */
.exam-header {
  position: sticky; top: 0; z-index: 20;
  background: linear-gradient(120deg, var(--brand-900) 0%, var(--brand-700) 100%);
  color: #fff;
  padding: 16px 26px;
  display: flex; align-items: center; justify-content: space-between;
  box-shadow: var(--shadow);
}
.exam-header .student-name { font-size: 0.85rem; color: #cbd3f5; }
.exam-header .subject { font-weight: 700; font-family: var(--display); }
.exam-pills {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}
.exam-header .timer-pill {
  font-family: var(--mono);
  font-size: 0.95rem;
  font-weight: 700;
  background: rgba(255,255,255,0.2);
  padding: 7px 15px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  white-space: nowrap;
}
.exam-header .timer-pill.warn {
  background: rgba(224, 69, 78, 0.24);
  color: #fff;
}
.exam-header .status-pill {
  font-family: var(--mono); font-size: 0.75rem; font-weight: 600;
  background: rgba(255,255,255,0.14); padding: 7px 15px; border-radius: 999px;
  display: inline-flex; align-items: center; gap: 7px;
}
.exam-header .status-pill::before {
  content: "";
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--mint-600);
  box-shadow: 0 0 0 3px rgba(15, 148, 136, 0.35);
}
.exam-header .status-pill.warn { background: rgba(224, 69, 78, 0.22); }
.exam-header .status-pill.warn::before {
  background: var(--rose-500);
  box-shadow: 0 0 0 3px rgba(224, 69, 78, 0.35);
}

.question-progress-card {
  position: sticky;
  top: 78px;
  z-index: 18;
  padding: 16px 18px;
}
.progress-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}
.progress-head .section-label {
  margin-bottom: 0;
}
.progress-summary {
  font-weight: 700;
  color: var(--brand-900);
  font-size: 0.9rem;
}
.question-progress-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}
.question-jump {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  border: 1px solid transparent;
  font-family: var(--mono);
  font-weight: 700;
  cursor: pointer;
}
.question-jump.done {
  background: var(--mint-100);
  border-color: rgba(47, 138, 95, 0.35);
  color: var(--mint-700);
}
.question-jump.todo {
  background: var(--rose-100);
  border-color: rgba(201, 77, 88, 0.35);
  color: var(--rose-600);
}
.question-jump:hover {
  transform: translateY(-1px);
  box-shadow: 0 5px 14px rgba(16, 43, 70, 0.12);
}
.progress-legend {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  color: var(--ink-soft);
  font-size: 0.82rem;
  margin-top: 10px;
}
.progress-legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.progress-legend i {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
}
.progress-legend i.done {
  background: var(--mint-600);
}
.progress-legend i.todo {
  background: var(--rose-500);
}

.no-select,
.exam-lockdown #mainContainer,
.exam-lockdown .q-view,
.exam-lockdown .qTextOut,
.exam-lockdown .optionsOut,
.exam-lockdown .question-images,
.exam-lockdown #instructionsCard {
  user-select: none;
  -webkit-user-select: none;
  -ms-user-select: none;
  -webkit-touch-callout: none;
}
.exam-lockdown #mainContainer,
.exam-lockdown #mainContainer * {
  -webkit-user-drag: none;
}
.exam-lockdown textarea,
.exam-lockdown input,
.exam-lockdown [contenteditable="true"] {
  user-select: text;
  -webkit-user-select: text;
  -ms-user-select: text;
  -webkit-touch-callout: default;
}

.watermark-notice {
  font-size: 0.78rem; color: var(--ink-soft); text-align: center; padding: 12px;
  display: flex; align-items: center; justify-content: center; gap: 6px;
}

/* ---------- footer ---------- */
.foot {
  text-align: center; padding: 26px; color: var(--ink-soft); font-size: 0.82rem;
}

/* ---------- spinner ---------- */
.spinner {
  width: 18px; height: 18px; border-radius: 50%;
  border: 2.5px solid rgba(255,255,255,0.4); border-top-color: #fff;
  animation: spin 0.7s linear infinite;
  display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

.empty-state {
  text-align: center; padding: 44px 20px; color: var(--ink-soft);
}
.empty-state .icon {
  width: 52px; height: 52px; margin: 0 auto 14px;
  color: var(--brand-500); opacity: 0.7;
  display: flex; align-items: center; justify-content: center;
}
.empty-state .icon svg { width: 100%; height: 100%; }

/* ===================================================================
   School Admin Theme
   A calmer back-office look inspired by school MIS dashboards.
   =================================================================== */
:root {
  --paper: #f5f7fb;
  --card: #ffffff;
  --ink: #0f2240;
  --ink-soft: #637083;
  --muted: #7a8597;
  --line: #d9e1ec;
  --line-soft: #f8fafc;
  --brand-900: #102b46;
  --brand-800: #123452;
  --brand-700: #183f63;
  --brand-600: #245c8f;
  --brand-500: #4077ad;
  --brand-100: #edf4fb;
  --mint-700: #2f8a5f;
  --mint-600: #55ad76;
  --mint-100: #eaf6ef;
  --amber-600: #bd8b21;
  --amber-500: #d9a935;
  --amber-100: #fbf3df;
  --rose-600: #c94d58;
  --rose-500: #d95d68;
  --rose-100: #fae7ea;
  --violet-600: #5d72a0;
  --violet-500: #7088bb;
  --violet-100: #eef2f8;
  --radius: 8px;
  --radius-sm: 6px;
  --radius-lg: 8px;
  --shadow: 0 1px 2px rgba(16, 43, 70, 0.04), 0 10px 30px rgba(16, 43, 70, 0.05);
  --shadow-lift: 0 18px 44px rgba(16, 43, 70, 0.16);
}

body {
  background: var(--paper);
}

h1, h2, h3, h4 {
  color: var(--ink);
  letter-spacing: 0;
}

.topbar {
  background: #fff;
  border-bottom: 1px solid var(--line);
  box-shadow: none;
}
.topbar .brand .dot {
  border-radius: 0;
  background: url("../assets/sirichai-secure-exam-icon.png") center / contain no-repeat;
  box-shadow: none;
}
.topbar a.back,
.topbar button.back {
  background: #fff;
  border: 1px solid var(--line);
  color: var(--brand-700);
}

.container {
  padding-top: 26px;
}

.card {
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 24px 26px;
}

.eyebrow {
  background: transparent;
  color: var(--ink-soft);
  padding: 0;
  border-radius: 0;
  letter-spacing: 0.04em;
  margin-bottom: 8px;
}

.section-label {
  color: var(--ink);
  letter-spacing: 0.04em;
}
.section-label::before {
  content: "";
}

input[type="text"], input[type="password"], input[type="number"], input[type="date"],
textarea, select {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  padding: 12px 14px;
}
input:focus, textarea:focus, select:focus {
  border-color: var(--brand-500);
  box-shadow: 0 0 0 3px rgba(64, 119, 173, 0.14);
}

.btn {
  border-radius: 6px;
  padding: 11px 18px;
  box-shadow: none;
}
.btn-primary,
.btn-navy {
  background: var(--brand-900);
  color: #fff;
  box-shadow: none;
}
.btn-primary:hover,
.btn-navy:hover {
  background: var(--brand-700);
  filter: none;
}
.btn-outline {
  background: #fff;
  color: var(--brand-700);
  border: 1px solid #bfcbd9;
}
.btn-outline:hover {
  background: var(--brand-100);
  color: var(--brand-900);
  border-color: var(--brand-500);
}
.btn-danger {
  background: #fff;
  color: var(--rose-600);
  border: 1px solid #e5b3ba;
}
.btn-danger:hover {
  background: var(--rose-100);
}
.btn-sm {
  border-radius: 6px;
  padding: 8px 13px;
}

.draft-panel,
.docx-pattern-box,
.q-block {
  background: #fbfcfe;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.q-block {
  padding: 18px;
}
.q-block:hover {
  border-color: #b9c7d8;
}
.instruction-block,
.preview-part-instruction,
.exam-part-instruction {
  background: #eff6ff;
  border-color: #bfdbfe;
}
.q-num,
.opt-row .opt-letter {
  background: #eef3f8;
  color: var(--brand-700);
  border-radius: 5px;
}
.drag-handle {
  border-radius: 6px;
}

.stat-grid {
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: #fff;
  box-shadow: var(--shadow);
}
.stat-card {
  min-height: 112px;
  border-radius: 0;
  border-right: 1px solid var(--line);
  box-shadow: none;
  color: var(--ink);
  background: #fff;
  padding: 20px 24px;
}
.stat-card:last-child {
  border-right: none;
}
.stat-card::after {
  display: none;
}
.stat-card .stat-top {
  color: var(--ink);
  opacity: 1;
}
.stat-card .stat-top .stat-ic {
  width: 38px;
  height: 38px;
  border-radius: 8px;
  background: var(--brand-100);
  color: var(--brand-600);
}
.stat-card .stat-value {
  color: var(--ink);
  font-size: 1.85rem;
  font-family: var(--sans);
  font-weight: 700;
}
.stat-card .stat-desc {
  color: var(--ink-soft);
  opacity: 1;
}
.stat-blue,
.stat-mint,
.stat-amber,
.stat-violet,
.stat-rose {
  background: #fff;
}
.stat-mint .stat-ic { background: var(--mint-100); color: var(--mint-700); }
.stat-amber .stat-ic { background: var(--amber-100); color: var(--amber-600); }
.stat-violet .stat-ic { background: var(--violet-100); color: var(--violet-600); }
.stat-rose .stat-ic { background: var(--rose-100); color: var(--rose-600); }

table.data {
  border-collapse: collapse;
}
table.data th {
  background: #f7f9fc;
  color: var(--ink);
  border-bottom: 1px solid var(--line);
  font-family: var(--sans);
  font-size: 0.82rem;
  letter-spacing: 0;
  text-transform: none;
}
table.data th:first-child,
table.data th:last-child {
  border-radius: 0;
}
table.data td {
  color: var(--ink);
}
table.data tr:hover td {
  background: #f9fbfd;
}

.badge {
  border-radius: 6px;
  font-family: var(--sans);
  font-size: 0.76rem;
  padding: 3px 9px;
}
.badge::before {
  display: none;
}

.modal-card {
  border-radius: 8px;
}
.preview-instructions {
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.exam-header {
  background: var(--brand-900);
  box-shadow: none;
}

.teacher-shell {
  background: var(--paper);
}
.teacher-shell .page {
  min-height: 100vh;
  display: block;
  padding-left: 270px;
}
.teacher-shell .topbar {
  display: none;
}
.teacher-shell .container {
  max-width: 1280px;
  padding: 26px 28px 56px;
}
.teacher-shell .teacher-quick-nav {
  display: none !important;
}
.save-strip {
  position: sticky;
  top: 14px;
  z-index: 35;
  display: flex;
  align-items: stretch;
  gap: 12px;
  justify-content: flex-end;
  margin-bottom: 14px;
  pointer-events: none;
}
.save-strip .btn {
  pointer-events: auto;
  box-shadow: 0 10px 26px rgba(16, 43, 70, 0.16);
}
.payload-meter {
  width: min(360px, 100%);
  pointer-events: auto;
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  box-shadow: 0 10px 26px rgba(16, 43, 70, 0.08);
}
.payload-meter-top {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--ink);
}
.payload-meter-track {
  height: 7px;
  border-radius: 999px;
  background: var(--line);
  overflow: hidden;
  margin-top: 7px;
}
.payload-meter-track span {
  display: block;
  width: 0%;
  height: 100%;
  background: var(--mint-600);
  transition: width 0.2s ease, background 0.2s ease;
}
.payload-meter.warn .payload-meter-track span { background: var(--amber-500); }
.payload-meter.danger .payload-meter-track span { background: var(--rose-500); }
.payload-meter .hint {
  margin: 6px 0 0;
  font-size: 0.75rem;
}
.date-range-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.exam-list-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

.qr-modal-card {
  width: min(760px, 100%);
}
.qr-share-layout {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 22px;
  align-items: center;
}
.qr-image-box {
  display: flex;
  align-items: center;
  justify-content: center;
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
}
.qr-image-box canvas {
  width: min(280px, 100%);
  aspect-ratio: 1;
  height: auto;
}
.qr-share-info .field {
  margin-bottom: 12px;
}
.qr-code-text {
  background: var(--line-soft);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  font-weight: 800;
  color: var(--brand-900);
}

.teacher-sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: 270px;
  padding: 28px 18px;
  background: linear-gradient(180deg, #0f2d49 0%, #102640 100%);
  color: #fff;
  display: flex;
  flex-direction: column;
  z-index: 80;
}
.side-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  color: #fff;
  text-decoration: none;
  margin-bottom: 34px;
  padding: 0 8px;
}
.side-brand:hover {
  text-decoration: none;
}
.side-logo {
  width: 46px;
  height: 46px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(255,255,255,0.98) url("../assets/sirichai-secure-exam-icon.png") center / 82% auto no-repeat;
  color: transparent;
  font-weight: 800;
  font-family: var(--display);
  overflow: hidden;
}
.side-brand strong,
.side-brand small {
  display: block;
  line-height: 1.25;
}
.side-brand strong {
  font-size: 1rem;
}
.side-brand small {
  color: #c6d2df;
  font-size: 0.82rem;
  margin-top: 2px;
}
.side-nav {
  display: grid;
  gap: 8px;
}
.side-nav a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 12px;
  border-radius: 8px;
  color: #e7edf5;
  font-weight: 600;
  text-decoration: none;
}
.side-nav a span {
  width: 22px;
  text-align: center;
  color: #dce7f4;
}
.side-nav .nav-icon {
  height: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 22px;
}
.side-nav .nav-icon svg {
  width: 20px;
  height: 20px;
}
.side-nav a:hover,
.side-nav a.active {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  text-decoration: none;
}
.side-footer {
  margin-top: auto;
  border-top: 1px solid rgba(255,255,255,0.14);
  padding: 18px 8px 0;
  color: #d4dfeb;
  font-size: 0.84rem;
}
.side-footer strong,
.side-footer span {
  display: block;
}
.side-footer strong {
  color: #fff;
  margin-bottom: 3px;
}
.side-logout {
  width: 100%;
  margin-top: 10px;
  padding: 10px 12px;
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 8px;
  background: rgba(255,255,255,0.08);
  color: #fff;
  font-family: var(--sans);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  text-align: left;
}
.side-logout:hover {
  background: rgba(255,255,255,0.16);
}

.floating-actions {
  position: fixed;
  right: 22px;
  top: 50%;
  transform: translateY(-50%);
  z-index: 90;
  display: grid;
  gap: 8px;
}
.float-action {
  width: 44px;
  height: 44px;
  border: 1px solid rgba(16, 43, 70, 0.16);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.96);
  color: var(--brand-900);
  box-shadow: 0 12px 30px rgba(16, 43, 70, 0.14);
  backdrop-filter: blur(10px);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--sans);
  font-size: 1.1rem;
  font-weight: 800;
  line-height: 1;
  text-decoration: none;
  cursor: pointer;
  transition: transform 0.18s ease, background 0.18s ease, color 0.18s ease, box-shadow 0.18s ease;
}
.float-action svg {
  width: 21px;
  height: 21px;
}
.float-action:hover {
  background: var(--brand-900);
  color: #fff;
  transform: translateY(-1px);
  box-shadow: 0 16px 34px rgba(16, 43, 70, 0.22);
  text-decoration: none;
}

.teacher-shell .foot {
  display: none;
}

@media (max-width: 860px) {
  .teacher-shell .page {
    padding-left: 0;
  }
  .teacher-sidebar {
    position: sticky;
    top: 0;
    width: 100%;
    min-height: auto;
    padding: 10px 14px;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    row-gap: 8px;
    gap: 12px;
  }
  .side-brand {
    order: 1;
    margin: 0;
    flex: 0 1 auto;
    min-width: 0;
  }
  .side-brand small,
  .side-footer {
    display: none;
  }
  .side-footer {
    order: 2;
    display: block;
    margin: 0 0 0 auto;
    padding: 0;
    border-top: 0;
  }
  .side-footer strong {
    display: none;
  }
  .side-logout {
    width: auto;
    margin-top: 0;
    padding: 10px 12px;
    text-align: center;
    white-space: nowrap;
  }
  .side-nav {
    order: 3;
    flex: 1 1 100%;
    width: 100%;
    display: flex;
    gap: 6px;
    overflow-x: auto;
    margin-left: 0;
    padding-bottom: 2px;
    -webkit-overflow-scrolling: touch;
  }
  .side-nav a {
    white-space: nowrap;
    padding: 10px 14px;
    background: rgba(255, 255, 255, 0.06);
    flex: 0 0 auto;
  }
  .side-nav a:hover,
  .side-nav a.active {
    background: rgba(255, 255, 255, 0.16);
  }
  .teacher-shell .container {
    padding: 18px 14px 42px;
  }
  .save-strip {
    top: 76px;
    display: grid;
    justify-content: stretch;
  }
  .save-strip .btn {
    width: 100%;
  }
  .payload-meter {
    width: 100%;
  }
  .date-range-grid {
    grid-template-columns: 1fr;
  }
  .exam-list-actions {
    justify-content: flex-start;
  }
  .qr-share-layout {
    grid-template-columns: 1fr;
  }
  .floating-actions {
    left: 50%;
    right: auto;
    bottom: 16px;
    top: auto;
    transform: translateX(-50%);
    display: flex;
    flex-direction: row;
    gap: 10px;
    padding: 6px;
    background: rgba(16, 43, 70, 0.85);
    border-radius: 16px;
    backdrop-filter: blur(10px);
  }
  .float-action {
    width: 42px;
    height: 42px;
    background: rgba(255, 255, 255, 0.96);
  }
  .stat-grid {
    display: grid;
    grid-template-columns: 1fr;
  }
  .stat-card {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
}

/* ===================================================================
   Live Monitor (แท็บดูสดในหน้า teacher-dashboard)
   =================================================================== */
.tab-bar {
  display: flex;
  gap: 22px;
  margin: 16px 0 20px;
  border-bottom: 1px solid var(--line, #e3e6ee);
}
.tab-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 10px 2px;
  font-size: 0.95rem;
  font-weight: 600;
  font-family: inherit;
  color: var(--ink-soft, #6b7280);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.tab-btn:hover { color: var(--ink, #1f2430); }
.tab-btn.active { color: var(--mint-700); border-bottom-color: var(--mint-600); }

.live-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--rose-500);
  margin-right: 7px;
  position: relative;
  top: -1px;
  animation: liveDotPulse 1.4s ease-in-out infinite;
}
@keyframes liveDotPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(239, 68, 83, 0.35); opacity: 1; }
  50% { box-shadow: 0 0 0 5px rgba(239, 68, 83, 0); opacity: 0.55; }
}

.live-stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}
.live-stat-card {
  background: #f7f8fc;
  border-radius: 14px;
  padding: 14px 16px;
}
.live-stat-card .live-stat-value {
  font-size: 1.8rem;
  font-weight: 700;
  font-family: "IBM Plex Mono", monospace;
  color: var(--ink, #1f2430);
}
.live-stat-card .live-stat-label {
  font-size: 0.8rem;
  color: var(--ink-soft, #6b7280);
  margin-top: 2px;
}

.live-progress-bar {
  width: 100%;
  min-width: 90px;
  height: 6px;
  border-radius: 4px;
  background: #e6e8f2;
  overflow: hidden;
}
.live-progress-bar > span {
  display: block;
  height: 100%;
  background: var(--mint-600);
  transition: width 0.3s ease;
}

/* ===================================================================
   Batch Grading (แท็บ "ตรวจอัตนัย" ในหน้า teacher-dashboard)
   =================================================================== */
.batch-progress-wrap {
  display: flex;
  align-items: center;
  gap: 14px;
  margin: 4px 0 16px;
}
.batch-progress-bar {
  flex: 1;
  min-width: 120px;
  height: 10px;
  border-radius: 6px;
  background: #e6e8f2;
  overflow: hidden;
}
.batch-progress-bar > span {
  display: block;
  height: 100%;
  background: var(--mint-600);
  transition: width 0.25s ease;
}
.batch-progress-wrap strong {
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.9rem;
  color: var(--ink);
  white-space: nowrap;
}

.batch-alert {
  background: var(--rose-100);
  color: var(--rose-600);
  border: 1px solid #f3b8be;
  border-radius: 10px;
  padding: 12px 16px;
  margin-bottom: 16px;
  font-size: 0.88rem;
}
.batch-alert ul {
  margin: 6px 0 0;
  padding-left: 20px;
}
.batch-alert li { margin-bottom: 2px; }

.batch-row {
  display: grid;
  grid-template-columns: 32px minmax(150px, 200px) 1fr 130px;
  gap: 14px;
  align-items: start;
  border: 1.5px solid var(--line);
  border-radius: 12px;
  background: var(--card);
  padding: 12px 14px;
  margin-bottom: 10px;
  transition: border-color 0.2s ease, box-shadow 0.2s ease, opacity 0.2s ease;
}
.batch-row:focus-within { border-color: var(--mint-600); box-shadow: 0 0 0 3px rgba(21, 168, 116, 0.15); }
.batch-row-flagged { border-color: var(--rose-500); background: #fffafa; }
.batch-row-saving { opacity: 0.6; }
.batch-row-check { padding-top: 3px; }
.batch-row-info { display: flex; flex-direction: column; gap: 3px; font-size: 0.85rem; }
.batch-row-info strong { font-size: 0.92rem; }
.batch-row-info .badge { align-self: flex-start; margin-top: 2px; cursor: help; }
.batch-row-answer {
  white-space: pre-wrap;
  font-size: 0.9rem;
  line-height: 1.55;
  color: var(--ink);
  background: var(--line-soft);
  border-radius: 8px;
  padding: 8px 10px;
  max-height: 180px;
  overflow-y: auto;
}
.batch-row-answer em { color: var(--ink-soft); }
.batch-row-score { display: flex; align-items: center; gap: 6px; }
.batch-row-score input {
  width: 72px;
  padding: 8px 10px;
  border: 1.5px solid var(--line);
  border-radius: 8px;
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.95rem;
  text-align: center;
}
.batch-row-score input:focus { border-color: var(--mint-600); outline: none; }

@media (max-width: 720px) {
  .batch-row { grid-template-columns: 1fr; }
  .batch-row-score { justify-content: flex-start; }
}

/* Secure exam display guard: blocks interaction while iPad is in Split View,
   Slide Over, Stage Manager/windowed mode, or after leaving exam fullscreen. */
.display-security-guard {
  position: fixed;
  inset: 0;
  z-index: 100000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(15, 23, 42, 0.96);
  backdrop-filter: blur(8px);
}
.display-security-guard.is-visible { display: flex; }
.display-security-card {
  width: min(520px, 100%);
  padding: 28px;
  border-radius: 18px;
  background: #fff;
  text-align: center;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.35);
}
.display-security-card h2 { margin: 10px 0; color: var(--rose-600); }
.display-security-card p { line-height: 1.65; }
.display-security-icon {
  display: grid;
  place-items: center;
  width: 56px;
  height: 56px;
  margin: 0 auto;
  border-radius: 50%;
  background: var(--rose-100);
  color: var(--rose-600);
  font-size: 2rem;
  font-weight: 800;
}
.exam-display-blocked body { overflow: hidden; }
.register-back-link { display: inline-flex; align-items: center; gap: 8px; margin-bottom: 18px; padding: 9px 13px; border: 1px solid var(--line); border-radius: 8px; background: rgba(255,255,255,.82); color: var(--brand-700); font-size: .88rem; font-weight: 600; text-decoration: none; box-shadow: 0 4px 12px rgba(16,43,70,.06); transition: background .16s ease, border-color .16s ease, color .16s ease, transform .16s ease; }
.register-back-link svg { width: 18px; height: 18px; flex: 0 0 auto; }
.register-back-link:hover { background: var(--brand-100); border-color: var(--brand-500); color: var(--brand-900); text-decoration: none; transform: translateX(-2px); }
.teacher-register-card { text-align: center; }
.teacher-register-card .field, .teacher-register-card .hint, .teacher-register-card button { text-align: left; }
.register-icon { width: 76px; height: 76px; margin: 0 auto 14px; display: grid; place-items: center; border-radius: 22px; color: var(--brand-600); background: linear-gradient(145deg, var(--brand-100), #fff); box-shadow: inset 0 0 0 1px rgba(64,119,173,.18), 0 10px 22px rgba(16,43,70,.08); }
.register-icon svg { width: 46px; height: 46px; }

.teacher-profile { min-width: 0; margin-bottom: 10px; }
.teacher-profile strong { display: block; color: #fff; font-size: .94rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.teacher-profile-email, .teacher-profile-code { display: block; color: #c6d2df; font-size: .76rem; line-height: 1.45; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.teacher-profile-code { color: #a9d9c2; margin-top: 2px; }

/* ---------- final polish: consistent spacing, controls and responsive rhythm ---------- */
:root {
  --control-h: 46px;
  --control-radius: 8px;
  --focus-ring: 0 0 0 3px rgba(64, 119, 173, 0.16);
}

button, input, textarea, select { box-sizing: border-box; }
button { -webkit-tap-highlight-color: transparent; }

.container { padding-left: clamp(16px, 3vw, 32px); padding-right: clamp(16px, 3vw, 32px); }
.card { padding: clamp(18px, 2.4vw, 26px); }
.field { margin-bottom: 16px; }
.field:last-child { margin-bottom: 0; }

input[type="text"], input[type="password"], input[type="number"], input[type="date"],
input[type="email"], input[type="url"], textarea, select {
  min-height: var(--control-h);
  border-radius: var(--control-radius);
  line-height: 1.4;
}
textarea { min-height: 96px; }
input::placeholder, textarea::placeholder { color: #8995a6; opacity: 1; }
input:focus, textarea:focus, select:focus { box-shadow: var(--focus-ring); }

.btn { min-height: var(--control-h); border-radius: var(--control-radius); padding: 10px 18px; transition: transform .16s ease, box-shadow .16s ease, background .16s ease, border-color .16s ease; }
.btn:hover:not(:disabled) { transform: translateY(-1px); }
.btn:focus-visible, .icon-btn:focus-visible, .tab-btn:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.btn-sm { min-height: 38px; }

.form-actions, .actions, .exam-list-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.form-actions { margin-top: 20px; }
.form-actions .btn, .actions .btn { min-width: 120px; }

.grid-2, .grid-3, .choice-grid { gap: clamp(14px, 2vw, 22px); }
.q-block { padding: clamp(14px, 2vw, 20px); }
.opt-row { gap: 8px; }

@media (max-width: 560px) {
  h1 { font-size: 1.85rem; }
  h2 { font-size: 1.25rem; }
  .topbar { padding: 12px 16px; }
  .topbar .brand { font-size: .98rem; }
  .card { border-radius: 8px; }
  .form-actions, .actions { flex-direction: column; align-items: stretch; }
  .form-actions .btn, .actions .btn { width: 100%; min-width: 0; }
  .q-block .q-head { align-items: flex-start; }
  .opt-row { align-items: flex-start; }
}

/* loading-progress-feature */
.loading-progress-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(10, 30, 50, 0.58);
  backdrop-filter: blur(5px);
}
.loading-progress-overlay.is-visible { display: flex; }
.loading-progress-card {
  width: min(440px, 100%);
  border-radius: 24px;
  padding: 24px;
  background: #fff;
  color: var(--ink, #0f2742);
  box-shadow: 0 24px 80px rgba(9, 31, 58, 0.26);
}
.loading-progress-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  margin-bottom: 14px;
}
.loading-progress-title {
  margin: 0;
  font-size: 1.12rem;
  font-weight: 800;
  color: var(--brand-900, #102f4e);
}
.loading-progress-percent {
  flex: 0 0 auto;
  font-weight: 900;
  font-size: 1.22rem;
  color: var(--mint-700, #13835c);
}
.loading-progress-bar {
  height: 12px;
  overflow: hidden;
  border-radius: 999px;
  background: #dfe8f2;
}
.loading-progress-fill {
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--mint-500, #2bbd86), var(--brand-500, #2d7dd2));
  transition: width 0.28s ease;
}
.loading-progress-message {
  margin: 13px 0 0;
  color: var(--muted, #65758b);
  line-height: 1.55;
}
.loading-progress-detail {
  margin-top: 8px;
  min-height: 1.35em;
  color: var(--muted, #65758b);
  font-size: 0.88rem;
}
.loading-progress-stuck {
  display: none;
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: 14px;
  background: var(--amber-100, #fff3d0);
  color: var(--amber-700, #8a5b00);
  font-size: 0.88rem;
  line-height: 1.45;
}
.loading-progress-overlay.is-stuck .loading-progress-stuck { display: block; }

