:root {
  --brand: #8a3e12;
  --brand-dark: #5f2a0b;
  --brand-soft: #f6e7db;
  --gold: #b8860b;
  --ink: #241d16;
  --muted: #6f6153;
  --line: #e3d9cb;
  --bg: #f8f4ed;
  --surface: #fffdfa;
  --ok: #1d6b45;
  --ok-bg: #e4f2ea;
  --warn: #91570a;
  --warn-bg: #fbeed6;
  --bad: #9c2b26;
  --bad-bg: #fbe4e2;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(60, 40, 20, .06), 0 6px 18px rgba(60, 40, 20, .05);
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "IBM Plex Sans Thai", "Sarabun", "Noto Sans Thai", "Leelawadee UI", "Tahoma", system-ui, sans-serif;
  font-size: 17px;
  line-height: 1.72;
  display: flex;
  min-height: 100vh;
  flex-direction: column;
}

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

.wrap { width: 100%; max-width: 1040px; margin: 0 auto; padding: 0 20px; }
.wrap.wide { max-width: 1240px; }

main.wrap { flex: 1 0 auto; padding-top: 26px; padding-bottom: 48px; }

/* ---------- หัวเว็บ ---------- */
.site-head {
  background: linear-gradient(180deg, var(--brand) 0%, var(--brand-dark) 100%);
  color: #fdf8ef;
  border-bottom: 3px solid var(--gold);
}
.head-in { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; padding-top: 12px; padding-bottom: 12px; }
.brand { display: flex; align-items: center; gap: 10px; color: inherit; flex: 1 1 auto; min-width: 0; }
.brand-logo { width: 46px; height: 46px; border-radius: 50%; background: #fff; padding: 2px;
  object-fit: contain; flex: 0 0 auto; box-shadow: 0 0 0 1px rgba(255,255,255,.35); }
.brand:hover { text-decoration: none; }
.brand-mark {
  width: 40px; height: 40px; border-radius: 10px;
  background: rgba(253, 248, 239, .14);
  border: 1px solid rgba(253, 248, 239, .35);
  display: grid; place-items: center;
  font-size: 22px; font-weight: 700; color: #fdf8ef;
}
.brand-text { display: flex; flex-direction: column; line-height: 1.28; min-width: 0; }
.brand-text strong { font-size: 15px; letter-spacing: .1px; font-weight: 700; }
.brand-text small { font-size: 12.5px; color: #f0dcc6; }
.site-nav { display: flex; gap: 4px; margin-left: auto; flex-wrap: wrap; }
.site-nav a {
  color: #f4e3d2; padding: 8px 13px; border-radius: 9px; font-size: 15.5px;
}
.site-nav a:hover { background: rgba(255, 255, 255, .1); text-decoration: none; }
.site-nav a.on { background: #fdf8ef; color: var(--brand-dark); font-weight: 600; }
.who { display: flex; align-items: center; gap: 8px; font-size: 14px; color: #f0dcc6; }
.who-name { max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.inline-form { display: inline; margin: 0; }

/* ---------- การ์ด ---------- */
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); margin-bottom: 20px; overflow: hidden;
}
.card-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 18px; border-bottom: 1px solid var(--line); background: #fffaf3; flex-wrap: wrap;
}
.card-title { margin: 0; font-size: 18px; font-weight: 650; }
.card-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.card-body { padding: 18px; }
.card-body > :first-child { margin-top: 0; }
.card-body > :last-child { margin-bottom: 0; }

/* ---------- ปุ่ม ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 11px 18px; border-radius: 10px; font-size: 15.5px; font-weight: 600;
  border: 1px solid var(--line); background: #fff; color: var(--ink);
  cursor: pointer; font-family: inherit; line-height: 1.3;
}
.btn:hover { text-decoration: none; background: #f6efe4; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff8ef; }
.btn-primary:hover { background: var(--brand-dark); }
.btn-danger { background: #fff; border-color: #e2b7b3; color: var(--bad); }
.btn-danger:hover { background: var(--bad-bg); }
.btn-sm { padding: 8px 13px; font-size: 14.5px; border-radius: 8px; }
.btn-link { background: none; border: none; padding: 0; color: var(--brand); font-weight: 600; }

/* ---------- ป้ายสถานะ ---------- */
.badge {
  display: inline-block; padding: 2px 9px; border-radius: 999px;
  font-size: 13.5px; font-weight: 600; border: 1px solid transparent; white-space: nowrap;
}
.badge-muted { background: #efe9e0; color: var(--muted); }
.badge-ok { background: var(--ok-bg); color: var(--ok); }
.badge-warn { background: var(--warn-bg); color: var(--warn); }
.badge-bad { background: var(--bad-bg); color: var(--bad); }
.badge-info { background: var(--brand-soft); color: var(--brand-dark); }
.badge-gold { background: #f9efd2; color: #7a5a05; }

/* ---------- ตาราง ---------- */
.tbl-wrap { overflow-x: auto; margin: 0 -18px -18px; padding: 0 18px 4px; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 15.5px; }
table.tbl th, table.tbl td { text-align: left; padding: 10px 10px; vertical-align: top; border-bottom: 1px solid var(--line); }
table.tbl th { font-size: 13.5px; text-transform: none; color: var(--muted); font-weight: 600; letter-spacing: .2px; background: #fffaf3; }
table.tbl tr:last-child td { border-bottom: none; }
table.tbl td.num, table.tbl th.num { text-align: right; white-space: nowrap; }
table.tbl td.nowrap { white-space: nowrap; }

/* ---------- ฟอร์ม ---------- */
.field { margin-bottom: 16px; }
.field label { display: block; font-size: 13.5px; font-weight: 600; margin-bottom: 6px; color: #4a3d31; }
input[type=text], input[type=password], input[type=number], input[type=date], textarea, select {
  width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px;
  font-family: inherit; font-size: 15px; background: #fff; color: var(--ink);
}
input:focus, textarea:focus, select:focus { outline: 2px solid #e9c9a8; outline-offset: 1px; border-color: var(--brand); }
textarea { resize: vertical; min-height: 90px; }
.hint { margin: 6px 0 0; font-size: 13.5px; color: var(--muted); }
.form-row { display: flex; gap: 14px; flex-wrap: wrap; }
.form-row > .field { flex: 1 1 200px; margin-bottom: 16px; }
.form-actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-top: 4px; }
.checkline { display: flex; align-items: center; gap: 9px; font-size: 14.5px; margin-bottom: 8px; }
.checkline input { width: auto; }
input[type=file] { font-size: 14px; }

/* ---------- ข้อความ ---------- */
.muted { color: var(--muted); }
.small { font-size: 14px; }
.lead { font-size: 18px; color: #4a3d31; }
h1 { font-size: 27px; line-height: 1.35; margin: 0 0 6px; }
h2 { font-size: 19px; }
h3 { font-size: 17px; margin: 22px 0 8px; }
h4 { font-size: 15.5px; margin: 18px 0 6px; color: #4a3d31; }
.prose p { margin: 0 0 14px; }
.prose ul { margin: 0 0 14px; padding-left: 22px; }
.prose li { margin-bottom: 6px; }
.prose code { background: #f1eae0; padding: 1px 5px; border-radius: 5px; font-size: 13.5px; }
.answer-box {
  background: #fdfaf5; border: 1px solid var(--line); border-left: 4px solid var(--brand-soft);
  border-radius: 10px; padding: 14px 16px;
}
.page-head { margin-bottom: 20px; }
.page-head .crumb { font-size: 13px; color: var(--muted); margin-bottom: 4px; }
.page-head .sub { color: var(--muted); font-size: 15.5px; }

/* ---------- แจ้งเตือน ---------- */
.flash {
  padding: 11px 16px; border-radius: 11px; margin-bottom: 18px; font-size: 14.5px;
  border: 1px solid transparent;
}
.flash-ok { background: var(--ok-bg); color: var(--ok); border-color: #c3e3d2; }
.flash-err { background: var(--bad-bg); color: var(--bad); border-color: #eec6c3; }
.flash-info { background: var(--brand-soft); color: var(--brand-dark); border-color: #ecd3bd; }

/* ---------- สถานะว่าง ---------- */
.empty { text-align: center; padding: 26px 14px; }
.empty-main { margin: 0 0 4px; font-weight: 600; color: #4a3d31; }
.empty-sub { margin: 0; color: var(--muted); font-size: 14px; }

/* ---------- ตัวเลขสรุป ---------- */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 20px; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); }
.kpi .n { font-size: 30px; font-weight: 700; line-height: 1.1; color: var(--brand-dark); }
.kpi .t { font-size: 14px; color: var(--muted); }
.kpi.alert .n { color: var(--bad); }

/* ---------- หน้าแรกก่อนล็อกอิน ---------- */
.hero { display: grid; grid-template-columns: 1.25fr .85fr; gap: 26px; align-items: start; margin: 10px 0 30px; }
.hero h1 { font-size: 32px; line-height: 1.3; margin-bottom: 12px; }
.hero .pill { display: inline-block; font-size: 12.5px; font-weight: 700; letter-spacing: .4px; color: var(--brand-dark); background: var(--brand-soft); padding: 4px 11px; border-radius: 999px; margin-bottom: 14px; }
.steps { list-style: none; padding: 0; margin: 22px 0 0; display: grid; gap: 10px; }
.steps li { display: flex; gap: 12px; align-items: flex-start; font-size: 14.5px; color: #4a3d31; }
.steps .n { flex: 0 0 26px; height: 26px; border-radius: 50%; background: var(--brand-soft); color: var(--brand-dark); font-weight: 700; display: grid; place-items: center; font-size: 13px; }
.login-card { position: sticky; top: 20px; }
.login-card .card-body { padding: 20px; }

/* ---------- ท้ายเว็บ ---------- */
.site-foot {
  background: #f1e8db; border-top: 1px solid var(--line); color: var(--muted);
  padding: 20px 0; font-size: 13.5px;
}
.site-foot p { margin: 0 0 4px; }
.foot-links a { color: var(--muted); text-decoration: underline; }

/* ---------- หน้า error ---------- */
.error-page { text-align: center; padding: 60px 10px; }
.error-code { font-size: 46px; font-weight: 800; color: var(--brand-soft); margin: 0; letter-spacing: 2px; }

/* ---------- มือถือ ---------- */
@media (max-width: 820px) {
  .hero { grid-template-columns: 1fr; }
  .login-card { position: static; }
  .hero h1 { font-size: 26px; }
}
@media (max-width: 640px) {
  .wrap { padding: 0 14px; }
  .head-in { gap: 8px; }
  .brand-text strong { font-size: 13px; }
  .brand-logo { width: 38px; height: 38px; }
  .row-card { flex-wrap: wrap; }
  .row-side { width: 100%; text-align: left; }
  .site-nav { order: 3; width: 100%; margin-left: 0; overflow-x: auto; padding-bottom: 2px; }
  .site-nav a { padding: 6px 10px; font-size: 13.5px; }
  .who { margin-left: auto; }
  body { font-size: 16.5px; }
  h1 { font-size: 23px; }
  .hide-sm { display: none; }
  .card-body { padding: 14px; }
  .tbl-wrap { margin: 0 -14px -14px; padding: 0 14px 4px; }
  table.tbl th, table.tbl td { padding: 9px 7px; }
}

@media print {
  .site-head, .site-foot, .btn, .flash { display: none; }
  .card { box-shadow: none; border-color: #ccc; }
}

/* ---------- สองคอลัมน์ (บทเรียน + สารบัญ) ---------- */
.two-col { display: grid; grid-template-columns: 1fr 290px; gap: 20px; align-items: start; }
.lesson-list { margin: 0; padding-left: 20px; font-size: 14.5px; }
.lesson-list li { margin-bottom: 8px; }
.lesson-list li.on a { font-weight: 700; color: var(--brand-dark); }
.course-card { display: block; color: inherit; }
.course-card:hover { text-decoration: none; border-color: #d9b892; }
.courses-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.courses-grid .card { margin-bottom: 0; }

/* ---------- คิวตรวจ ---------- */
.queue-item { display: flex; gap: 14px; align-items: flex-start; padding: 13px 0; border-bottom: 1px solid var(--line); }
.queue-item:last-child { border-bottom: none; padding-bottom: 0; }
.queue-item:first-child { padding-top: 0; }
.queue-main { flex: 1 1 auto; min-width: 0; }
.queue-main .t { font-weight: 600; }
.queue-side { flex: 0 0 auto; text-align: right; }
.student-chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0 0; }

@media (max-width: 900px) {
  .two-col { grid-template-columns: 1fr; }
}

/* ---------- กระเบื้องเลือกชั้น/ชื่อ/วิชา ---------- */
.hero-simple { text-align: center; margin: 14px 0 26px; }
.hero-simple .pill { display: inline-block; font-size: 12.5px; font-weight: 700; letter-spacing: .3px;
  color: var(--brand-dark); background: var(--brand-soft); padding: 4px 11px; border-radius: 999px; margin-bottom: 12px; }
.hero-simple h1 { font-size: 28px; margin-bottom: 8px; }
.hero-simple .lead { max-width: 620px; margin: 0 auto; }
.center { text-align: center; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 14px; }
.tile { display: flex; flex-direction: column; gap: 3px; padding: 18px; background: var(--surface);
  border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); color: inherit;
  transition: border-color .12s, transform .12s; }
.tile:hover { text-decoration: none; border-color: #d9b892; transform: translateY(-1px); }
.tile-name { font-weight: 700; font-size: 18.5px; line-height: 1.35; }
.tile-sub, .tile-meta { font-size: 14px; color: var(--muted); }
.tile-no { font-size: 12px; color: var(--muted); }
.tiles-name { grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }
.tiles-name .tile { flex-direction: row; align-items: center; gap: 10px; padding: 13px 15px; }
.tiles-name .tile-no { flex: 0 0 26px; height: 26px; border-radius: 50%; background: var(--brand-soft);
  color: var(--brand-dark); font-weight: 700; display: grid; place-items: center; font-size: 12px; }
.tiles-name .tile-name { font-size: 15.5px; font-weight: 600; }
.tag-new { margin-left: auto; font-size: 11.5px; font-weight: 700; color: var(--warn);
  background: var(--warn-bg); border-radius: 999px; padding: 2px 8px; white-space: nowrap; }
.tile-subject .tile-name { font-size: 18px; }

/* ---------- ฟอร์มเข้าเรียน ---------- */
.gate { max-width: 460px; margin: 10px auto 40px; }
.who-line { font-size: 17px; margin: 0 0 16px; line-height: 1.5; }

/* ---------- รายการแบบแถว ---------- */
.row-card { display: flex; align-items: center; gap: 14px; padding: 16px 18px; background: var(--surface);
  border: 1px solid var(--line); border-radius: 12px; margin-bottom: 10px; color: inherit; }
.row-card:hover { text-decoration: none; border-color: #d9b892; }
.row-main { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.row-side { flex: 0 0 auto; }

/* ---------- ไฟล์และรูป ---------- */
.file-list { display: flex; flex-direction: column; gap: 10px; }
.file-row { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border: 1px solid var(--line);
  border-radius: 12px; background: #fff; color: inherit; }
.file-row:hover { text-decoration: none; border-color: #d9b892; }
.file-icon { font-size: 11px; font-weight: 800; letter-spacing: .5px; background: var(--bad-bg);
  color: var(--bad); padding: 4px 8px; border-radius: 7px; }
.file-name { flex: 1 1 auto; min-width: 0; }
.file-size { font-size: 12px; color: var(--muted); }
.img-stack { display: flex; flex-direction: column; gap: 12px; margin-top: 14px; }
.img-card { display: block; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: #fff; }
.img-card img { display: block; width: 100%; height: auto; }
.img-cap { display: block; padding: 8px 12px; font-size: 13px; color: var(--muted); }
.img-full { max-width: 100%; height: auto; display: block; margin: 0 auto; border-radius: 10px; }
.pdf-frame iframe { width: 100%; height: 78vh; border: 0; border-radius: 10px; background: #f2ece2; }
.img-strip { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.img-strip img { width: 104px; height: 104px; object-fit: cover; border-radius: 9px; border: 1px solid var(--line); }

/* ---------- ปุ่มงานในหัวข้อ ---------- */
.act-btn { display: flex; flex-direction: column; gap: 3px; padding: 14px 16px; border-radius: 12px;
  border: 1px solid var(--line); background: #fff; margin-bottom: 10px; color: inherit; }
.act-btn:hover { text-decoration: none; border-color: #d9b892; }
.act-kind { font-size: 12px; font-weight: 700; letter-spacing: .3px; color: var(--brand); }
.act-title { font-weight: 600; }
.act-due { font-size: 12px; color: var(--muted); display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.act-state { font-size: 13px; font-weight: 700; color: var(--muted); }
.act-done { background: #f2faf5; border-color: #b9e0cb; }
.act-done .act-state { color: var(--ok); }
.act-todo .act-state { color: var(--warn); }

/* ---------- ข้อสอบ ---------- */
.q { border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; margin-bottom: 12px; background: #fff; }
.q-head { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.q-prompt { font-weight: 600; margin-bottom: 10px; }
.q-img { max-width: 100%; border-radius: 8px; margin: 8px 0; display: block; }
.choice { display: flex; gap: 10px; align-items: flex-start; padding: 9px 12px; border: 1px solid var(--line);
  border-radius: 10px; margin-bottom: 8px; cursor: pointer; }
.choice:hover { background: #fdf7ef; }
.choice input { width: auto; margin-top: 5px; }
.choice-key { font-weight: 700; }
tr.ok td { background: #f5fbf7; }
tr.bad td { background: #fdf4f4; }
.answer-box.graded { border-left-color: var(--ok); }

/* ---------- ตารางช่วยเหลือ CSV ---------- */
.mono { font-family: ui-monospace, "Consolas", "Courier New", monospace; font-size: 13px;
  background: #f1eae0; padding: 12px 14px; border-radius: 9px; overflow-x: auto; white-space: pre; }
.csv-table { font-size: 13px; }
.admin-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.form-inline { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
.form-inline .field { margin-bottom: 0; flex: 1 1 180px; }

/* ---------- หน้าเปิดเอกสาร PDF ---------- */
.pdf-open { text-align: center; padding: 26px 10px; }
.pdf-name { font-weight: 600; margin: 0 0 16px; word-break: break-word; }
.btn-lg { padding: 14px 26px; font-size: 16.5px; border-radius: 12px; }

/* ---------- หน้าแรก: เลือกประเภทผู้ใช้ ---------- */
.roles { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; max-width: 900px; margin: 0 auto; }
.role-card { display: flex; flex-direction: column; gap: 6px; padding: 22px; border-radius: 16px;
  background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow); color: inherit;
  transition: border-color .12s, transform .12s; }
.role-card:hover { text-decoration: none; border-color: #d9b892; transform: translateY(-2px); }
.role-mark { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center;
  font-size: 21px; font-weight: 700; background: var(--brand-soft); color: var(--brand-dark); }
.role-teacher .role-mark { background: #e8eef7; color: #2b4a72; }
.role-admin .role-mark { background: #f7ecd8; color: #7a5a05; }
.role-name { font-size: 19px; font-weight: 700; margin-top: 4px; }
.role-desc { font-size: 14px; color: #4a3d31; }
.role-note { font-size: 12.5px; color: var(--muted); }
.role-go { margin-top: 10px; font-size: 14px; font-weight: 700; color: var(--brand); }

/* ---------- งานรอตรวจแยกตามชั้นเรียน ---------- */
.class-block { border: 1px solid var(--line); border-radius: 12px; margin-bottom: 14px; background: #fff; overflow: hidden; }
.class-block:last-child { margin-bottom: 0; }
.class-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 12px 16px;
  background: #fffaf3; border-bottom: 1px solid var(--line); }
.class-name { font-weight: 700; font-size: 16.5px; }
.class-chip { margin-left: auto; }
.class-body { padding: 4px 16px 14px; }
.class-body .queue-item:first-child { padding-top: 12px; }

/* ---------- ตารางคะแนน ---------- */
.tbl-grades th.act-col { min-width: 92px; vertical-align: bottom; }
.act-col-name { display: block; font-weight: 700; font-size: 12.5px; color: #4a3d31; }
.act-col-sub { display: block; font-size: 11px; color: var(--muted); font-weight: 500; }
.tbl-grades td, .tbl-grades th { white-space: nowrap; }
.cell-miss { color: #bdb1a4; }
.cell-wait { color: var(--warn); font-size: 12px; }
.cell-ok { font-weight: 600; }

/* ---------- รายการงานของนักเรียน (เรียงลงมา อ่านบนมือถือง่าย) ---------- */
.work-row { border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px;
  margin-bottom: 10px; background: #fff; }
.work-row:last-child { margin-bottom: 0; }
.work-head { display: flex; justify-content: space-between; align-items: center; gap: 10px;
  flex-wrap: wrap; margin-bottom: 4px; font-size: 16.5px; }

/* ---------- หัวข้อ = ชุดงานที่ทำต่อกัน ---------- */
.task-row { display: flex; align-items: center; gap: 12px; padding: 15px 16px; border-radius: 12px;
  border: 1px solid var(--line); background: #fff; margin-bottom: 10px; color: inherit; }
.task-row:hover { text-decoration: none; border-color: #d9b892; }
.task-row:last-of-type { margin-bottom: 0; }
.task-order { flex: 0 0 30px; height: 30px; border-radius: 50%; display: grid; place-items: center;
  background: var(--brand-soft); color: var(--brand-dark); font-weight: 700; font-size: 14px; }
.task-main { flex: 1 1 auto; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.task-kind { font-size: 12.5px; font-weight: 700; color: var(--brand); letter-spacing: .2px; }
.task-title { font-size: 16.5px; font-weight: 600; }
.task-state { flex: 0 0 auto; font-size: 14px; font-weight: 700; color: var(--warn); text-align: right; }
.task-row.task-done { background: #f2faf5; border-color: #b9e0cb; }
.task-row.task-done .task-order { background: #d5efe0; color: var(--ok); }
.task-row.task-done .task-state { color: var(--ok); }
.submit-all { margin-top: 18px; padding: 20px; border-radius: 14px; border: 1px solid var(--line);
  background: var(--surface); text-align: center; box-shadow: var(--shadow); }
.submit-all .submit-note { margin: 0 0 14px; font-size: 16.5px; font-weight: 600; }
.submit-all.waiting { background: #fffaf3; }
.submit-all.waiting .submit-note { color: var(--warn); font-weight: 600; }
.submit-all.done { background: #f2faf5; border-color: #b9e0cb; color: var(--ok);
  font-size: 18px; font-weight: 700; }
details.adv { margin-top: 18px; }
details.adv summary { cursor: pointer; font-weight: 600; color: var(--muted); font-size: 14.5px; }

@media (max-width: 640px) {
  .task-row { flex-wrap: wrap; }
  .task-state { flex: 1 1 100%; margin-left: 42px; text-align: left; }
  .submit-all { padding: 16px 14px; }
}

/* ---------- ปุ่มเพิ่มหัวข้อ (กดแล้วกางกล่องกรอก) ---------- */
.add-topic { margin-top: 20px; display: flex; flex-direction: column; align-items: center; }
.add-topic > summary { display: inline-flex; list-style: none; cursor: pointer; }
.add-topic > summary::-webkit-details-marker { display: none; }
.add-topic > summary::marker { content: ""; }
.add-topic[open] > summary { margin-bottom: 4px; }
.add-topic form { text-align: left; width: 100%; margin-top: 14px; padding: 16px;
  border: 1px solid var(--line); border-radius: 12px; background: #fffaf3; }

/* ---------- สถานะงานของนักเรียน: ค้าง = แดง · ส่งแล้ว/ผ่าน = เขียว ---------- */
.todo-red { color: var(--bad); font-weight: 700; }
.done-green { color: var(--ok); font-weight: 700; }
.task-row.task-todo .task-state { color: var(--bad); }
.task-row.task-todo { border-left: 4px solid #e6b8b4; }
.task-row.task-done { border-left: 4px solid #a9d9c0; }

/* ---------- เช็คชื่อ ---------- */
.absent-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 8px; }
.absent-row { display: flex; align-items: center; gap: 10px; padding: 11px 13px;
  border: 1px solid var(--line); border-radius: 10px; cursor: pointer; background: #fff; }
.absent-row:hover { background: #fdf7ef; }
.absent-row input { width: 20px; height: 20px; flex: 0 0 auto; }
.absent-no { flex: 0 0 26px; color: var(--muted); font-size: 13px; }
.absent-name { font-size: 15.5px; }
.absent-row.is-absent { background: #fdf3f2; border-color: #e0a9a4; }
.absent-row.is-absent .absent-name { color: var(--bad); font-weight: 600; }
