/* ฟอนต์ไทย-ละติน IBM Plex Sans Thai (ฝังในเครื่อง) */
@font-face {
  font-family: 'IBM Plex Sans Thai';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url(/static/plex-thai-1.woff2) format('woff2');
  unicode-range: U+0460-052F, U+1C80-1C8A, U+20B4, U+2DE0-2DFF, U+A640-A69F, U+FE2E-FE2F;
}
@font-face {
  font-family: 'IBM Plex Sans Thai';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url(/static/plex-thai-2.woff2) format('woff2');
  unicode-range: U+02D7, U+0303, U+0331, U+0E01-0E5B, U+200C-200D, U+25CC;
}
@font-face {
  font-family: 'IBM Plex Sans Thai';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url(/static/plex-thai-3.woff2) format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: 'IBM Plex Sans Thai';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url(/static/plex-thai-4.woff2) format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'IBM Plex Sans Thai';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url(/static/plex-thai-5.woff2) format('woff2');
  unicode-range: U+0460-052F, U+1C80-1C8A, U+20B4, U+2DE0-2DFF, U+A640-A69F, U+FE2E-FE2F;
}
@font-face {
  font-family: 'IBM Plex Sans Thai';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url(/static/plex-thai-6.woff2) format('woff2');
  unicode-range: U+02D7, U+0303, U+0331, U+0E01-0E5B, U+200C-200D, U+25CC;
}
@font-face {
  font-family: 'IBM Plex Sans Thai';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url(/static/plex-thai-7.woff2) format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: 'IBM Plex Sans Thai';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url(/static/plex-thai-8.woff2) format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'IBM Plex Sans Thai';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url(/static/plex-thai-9.woff2) format('woff2');
  unicode-range: U+0460-052F, U+1C80-1C8A, U+20B4, U+2DE0-2DFF, U+A640-A69F, U+FE2E-FE2F;
}
@font-face {
  font-family: 'IBM Plex Sans Thai';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url(/static/plex-thai-10.woff2) format('woff2');
  unicode-range: U+02D7, U+0303, U+0331, U+0E01-0E5B, U+200C-200D, U+25CC;
}
@font-face {
  font-family: 'IBM Plex Sans Thai';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url(/static/plex-thai-11.woff2) format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: 'IBM Plex Sans Thai';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url(/static/plex-thai-12.woff2) format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'IBM Plex Sans Thai';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url(/static/plex-thai-13.woff2) format('woff2');
  unicode-range: U+0460-052F, U+1C80-1C8A, U+20B4, U+2DE0-2DFF, U+A640-A69F, U+FE2E-FE2F;
}
@font-face {
  font-family: 'IBM Plex Sans Thai';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url(/static/plex-thai-14.woff2) format('woff2');
  unicode-range: U+02D7, U+0303, U+0331, U+0E01-0E5B, U+200C-200D, U+25CC;
}
@font-face {
  font-family: 'IBM Plex Sans Thai';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url(/static/plex-thai-15.woff2) format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: 'IBM Plex Sans Thai';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url(/static/plex-thai-16.woff2) format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}


:root {
  --brand: #e2570d;
  --brand-dark: #b8460a;
  --brand-soft: #fff0e4;
  --gold: #f0a24b;
  --ink: #1f1611;
  --muted: #6e5b4e;
  --line: #f0dfd0;
  --bg: #fdf8f3;
  --surface: #ffffff;
  --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);
  /* ขอบขาวรอบตัวอักษรบนป้ายสถานะ — อ่านชัดเมื่ออยู่บนพื้นสี */
  --white-edge: -1px -1px 0 #fff, 1px -1px 0 #fff, -1px 1px 0 #fff, 1px 1px 0 #fff,
                0 -1px 0 #fff, 0 1px 0 #fff, -1px 0 0 #fff, 1px 0 0 #fff;
}

* { 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: #fff8f2;
  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: #fff8f2;
}
.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: #f9dcc6; }
.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: #fff8f2; color: var(--brand-dark); font-weight: 600; }
.who { display: flex; align-items: center; gap: 8px; font-size: 14px; color: #f9dcc6; }
.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: #fffcf8; 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); text-shadow: var(--white-edge); }
.badge-warn { background: var(--warn-bg); color: var(--warn); }
.badge-bad { background: var(--bad-bg); color: var(--bad); text-shadow: var(--white-edge); }
.badge-info { background: var(--brand-soft); color: var(--brand-dark); }
.badge-gold { background: #f9efd2; color: #8a5200; }

/* ---------- ตาราง ---------- */
.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: #fffcf8; }
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: #5b3520; }
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; max-width: 100%; }
input[type=file]::file-selector-button {
  font: inherit; font-size: 14px; font-weight: 600; color: var(--brand);
  background-color: #fff; background-repeat: no-repeat; background-position: 9px center;
  background-size: 17px 17px; border: 1px solid var(--line); border-radius: 9px;
  padding: 7px 13px 7px 32px; margin-right: 10px; cursor: pointer;
}
input[type=file]:hover::file-selector-button { border-color: #f6c9a6; background-color: #fff9f2; }
input[type=file]:focus-visible::file-selector-button { outline: 2px solid var(--brand); outline-offset: 2px; }
/* ไอค่อนตามชนิดไฟล์ที่ช่องนั้นรับ — ลำดับความสำคัญ: ไฟล์เอกสาร > รูป > วิดีโอ
   (กฎที่อยู่ท้ายสุดชนะเมื่อช่องเดียวรับได้หลายชนิด) */
input[type=file][accept*="video"]::file-selector-button {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%232f5d8a' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='2' y='6' width='14' height='12' rx='2'/%3E%3Cpath d='M16 10.5l6-3.5v10l-6-3.5z'/%3E%3C/svg%3E");
}
input[type=file][accept*="image"]::file-selector-button {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%231d6b45' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='3' y='4' width='18' height='16' rx='2'/%3E%3Ccircle cx='8.5' cy='9.5' r='1.5'/%3E%3Cpath d='M21 16l-5.7-5.7a1.4 1.4 0 0 0-2 0L4 20'/%3E%3C/svg%3E");
}
input[type=file][accept*=".pdf"]::file-selector-button,
input[type=file][accept*=".csv"]::file-selector-button {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238a3e12' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M14 3H7a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V8z'/%3E%3Cpath d='M14 3v5h5'/%3E%3Cpath d='M9 13h6'/%3E%3Cpath d='M9 17h4'/%3E%3C/svg%3E");
}

/* ---------- ข้อความ ---------- */
.muted { color: var(--muted); }
.small { font-size: 14px; }
.lead { font-size: 18px; color: #5b3520; }
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: #5b3520; }
.prose p { margin: 0 0 14px; }
.prose ul { margin: 0 0 14px; padding-left: 22px; }
.prose li { margin-bottom: 6px; }
.prose code { background: #faf0e6; 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: #5b3520; }
.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: #5b3520; }
.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: #f6c9a6; }
.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: #f6c9a6; 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; }

/* ชื่อนักเรียนบนหน้าวิชาของฉัน — ตัวใหญ่กลางจอ สีน้ำตาล ขอบเรืองแสงสีส้ม
   ตัวอักษรยังเป็นน้ำตาลเข้มบนพื้นครีม (คอนทราสต์พออ่าน) เรืองแสงเป็นแค่แสงนุ่มรอบตัวอักษร */
.my-name {
  font-size: 33px; font-weight: 700; line-height: 1.25;
  margin: 14px 0 18px; text-align: center; color: var(--brand);
  text-shadow: 0 0 2px rgba(233, 140, 38, .95), 0 0 10px rgba(233, 140, 38, .70),
               0 0 24px rgba(233, 140, 38, .45), 0 0 48px rgba(233, 140, 38, .26);
}
.my-name-meta {
  display: block; font-size: 15px; font-weight: 400; color: var(--muted);
  margin-top: 6px; text-align: center; text-shadow: none;
}
@media (max-width: 640px) {
  .my-name { font-size: 26px; }
}

/* ---------- รายการแบบแถว ---------- */
.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: #f6c9a6; }
.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: #f6c9a6; }
.file-icon { font-size: 11px; font-weight: 800; letter-spacing: .5px; background: var(--bad-bg);
  color: var(--bad); padding: 4px 8px; border-radius: 7px; }
/* ป้ายตามชนิดไฟล์: PDF สีแดง (ค่าตั้งต้น) · Word ฟ้า · Excel เขียว · สไลด์ ส้ม · ข้อความ เทา */
.file-icon.word { background: #e6eefb; color: #1d4f9c; }
.file-icon.xls { background: #e4f4ea; color: #1a7440; }
.file-icon.ppt { background: #fceade; color: #a8501a; }
.file-icon.txt { background: #eef0f3; color: #46505e; }
.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); }
/* ---------- ลิงก์/คลิปที่ครูวางไว้ในใบความรู้ ---------- */
.file-icon.link { background: #e8eef7; color: #24507e; }
.link-list { display: flex; flex-direction: column; gap: 12px; margin-bottom: 14px; }
.link-card { border: 1px solid var(--line); border-radius: 12px; background: #fff; padding: 12px 14px; }
.link-head { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
/* ตัวเล่น 16:9 — ยืดเต็มความกว้างการ์ด แต่ไม่สูงเกินจอ */
/* ใช้ padding-top 56.25% แทน aspect-ratio — เบราว์เซอร์รุ่นเก่าในมือถือก็ได้สัดส่วน 16:9 ถูก */
.yt-frame { position: relative; width: 100%; max-width: 720px; padding-top: 56.25%;
  border-radius: 10px; overflow: hidden; background: #000; }
.yt-frame iframe { position: absolute; top: 0; left: 0; width: 100%; height: 100%; border: 0; }
.link-open { display: inline-block; margin-top: 8px; font-size: 13px; }
/* ---------- ไฟล์เสียงในใบความรู้: ครูอัป mp3 นักเรียนกดเล่นในหน้า ---------- */
.file-icon.audio { background: #eae7fb; color: #4a3a99; }
.audio-list { display: flex; flex-direction: column; gap: 10px; margin-bottom: 14px; }
.audio-card { border: 1px solid var(--line); border-radius: 12px; background: #fff; padding: 10px 14px 12px; }
.audio-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }
.audio-card audio, .audio-open audio { display: block; width: 100%; max-width: 560px; }
.audio-open { padding: 2px 0; }

/* =========================================================================
   ธีมพื้นดำตัวขาว — ลูกค้าเลือกได้ด้วยปุ่ม "โหมดมืด" ในหัวเว็บ
   ค่าเก็บไว้กับบัญชี (users.theme) จึงติดไปทุกเครื่องที่ล็อกอินด้วยไอดีเดิม
   ========================================================================= */
[data-theme="dark"] {
  color-scheme: dark;              /* ช่องกรอก/สกอลบาร์/ปุ่มเลือกไฟล์เป็นโทนมืดด้วย */
  --brand: #ff8a4c;                /* ลิงก์และตัวเน้นบนพื้นดำ (สว่างพอให้อ่านชัด) */
  --brand-dark: #ffb07a;
  --brand-soft: #341e12;
  --gold: #f2b858;
  --ink: #f6eee7;                  /* ตัวหนังสือหลัก: ขาวนวล ไม่ขาวจ้า */
  --muted: #bca897;
  --line: #3a2c24;
  --bg: #120d0a;                   /* พื้นดำ */
  --surface: #1c1511;              /* พื้นการ์ด */
  --ok: #7fd3a4;
  --ok-bg: #1c3328;
  --warn: #f0b967;
  --warn-bg: #3a2c15;
  --bad: #f5968f;
  --bad-bg: #3a1e1b;
  --shadow: 0 1px 2px rgba(0, 0, 0, .55), 0 6px 18px rgba(0, 0, 0, .35);
  --white-edge: none;              /* ขอบขาวรอบตัวอักษรบนป้าย: ไม่ใช้บนพื้นดำ */
}
/* หัวเว็บและปุ่มหลักยังเป็นโทนน้ำตาลเดิม แต่เข้มลงให้อยู่กับพื้นดำ */
[data-theme="dark"] .site-head { background: linear-gradient(180deg, #341b0e 0%, #1d0f07 100%); }
[data-theme="dark"] .btn-primary { background: #c2410c; border-color: #e2570d; color: #fff8ef; }
[data-theme="dark"] .btn-primary:hover { background: #d9540f; }
[data-theme="dark"] .site-nav a.on { background: #fff8f2; color: #8a2f08; }

/* กล่องที่เดิมใช้พื้นขาว/ครีมตายตัว — เปลี่ยนตามพื้นการ์ดของธีม */
[data-theme="dark"] .btn,
[data-theme="dark"] .btn-danger,
[data-theme="dark"] .file-row,
[data-theme="dark"] .img-card,
[data-theme="dark"] .link-card,
[data-theme="dark"] .audio-card,
[data-theme="dark"] .tt-card,
[data-theme="dark"] .act-btn,
[data-theme="dark"] .q,
[data-theme="dark"] .class-block,
[data-theme="dark"] .work-row,
[data-theme="dark"] .task-row,
[data-theme="dark"] .absent-row,
[data-theme="dark"] input[type=text],
[data-theme="dark"] input[type=password],
[data-theme="dark"] input[type=number],
[data-theme="dark"] input[type=date],
[data-theme="dark"] textarea,
[data-theme="dark"] select,
[data-theme="dark"] input[type=file]::file-selector-button {
  background: var(--surface);
  color: var(--ink);
}
[data-theme="dark"] .btn:hover,
[data-theme="dark"] .choice:hover,
[data-theme="dark"] .absent-row:hover,
[data-theme="dark"] input[type=file]:hover::file-selector-button { background: #2a211b; }
[data-theme="dark"] .btn-danger { border-color: #5c332f; }
[data-theme="dark"] .card-head,
[data-theme="dark"] table.tbl th,
[data-theme="dark"] .submit-all.waiting,
[data-theme="dark"] .add-topic form,
[data-theme="dark"] .class-head,
[data-theme="dark"] .answer-box,
[data-theme="dark"] .tt-card img { background: #241f1a; }
[data-theme="dark"] .site-foot { background: #191512; border-top-color: var(--line); }
[data-theme="dark"] .badge-muted,
[data-theme="dark"] .prose code,
[data-theme="dark"] .mono { background: #2a211b; color: #e6dccd; }
[data-theme="dark"] .badge-gold { background: #3a2f12; color: #f2b858; }
[data-theme="dark"] .pdf-frame iframe { background: #0f0d0b; }
[data-theme="dark"] .error-code { color: #a08a76; }   /* ตัวเลข 404 จาง ๆ แต่ยังอ่านออกบนพื้นดำ */
/* ชื่อนักเรียนบนพื้นดำ: ลดแสงเรืองลง ไม่ให้จ้าเป็นนีออน */
[data-theme="dark"] .my-name {
  color: #ffcf9b;
  text-shadow: 0 0 10px rgba(233, 140, 38, .32), 0 0 26px rgba(233, 140, 38, .16);
}
[data-theme="dark"] .cell-miss { color: #7c7268; }
[data-theme="dark"] .field label,
[data-theme="dark"] .lead,
[data-theme="dark"] h4,
[data-theme="dark"] .steps li,
[data-theme="dark"] .empty-main,
[data-theme="dark"] .role-desc,
[data-theme="dark"] .act-col-name { color: #d9cdbe; }
[data-theme="dark"] .tile:hover,
[data-theme="dark"] .row-card:hover,
[data-theme="dark"] .course-card:hover,
[data-theme="dark"] .role-card:hover,
[data-theme="dark"] .file-row:hover,
[data-theme="dark"] .act-btn:hover,
[data-theme="dark"] .task-row:hover { border-color: #6a5544; }
[data-theme="dark"] .flash-ok { border-color: #2c5140; }
[data-theme="dark"] .flash-err { border-color: #5a2f2b; }
[data-theme="dark"] .flash-info { border-color: #4a3626; }

/* ป้ายชนิดไฟล์และสถานะที่เดิมใช้พื้นสีอ่อน */
[data-theme="dark"] .file-icon.word { background: #1d2c44; color: #9dc0f0; }
[data-theme="dark"] .file-icon.xls { background: #16301f; color: #8fd6a8; }
[data-theme="dark"] .file-icon.ppt { background: #382213; color: #f0b98a; }
[data-theme="dark"] .file-icon.txt { background: #262a2f; color: #c3ccd6; }
[data-theme="dark"] .file-icon.link { background: #1c2a3a; color: #9cc0e8; }
[data-theme="dark"] .file-icon.audio { background: #271f3c; color: #bda9f2; }
[data-theme="dark"] .role-teacher .role-mark { background: #1c2a3a; color: #9cc0e8; }
[data-theme="dark"] .role-admin .role-mark { background: #382f14; color: #f2b858; }

/* งาน/สถานะ: พื้นแดงอ่อน (ยังไม่ทำ) · พื้นเขียวอ่อน (ทำแล้ว) */
[data-theme="dark"] .task-row.task-todo { background: #2a1512; border-color: #5c332f; border-left-color: #c9564c; }
[data-theme="dark"] .task-row.task-todo:hover { border-color: #c9564c; }
[data-theme="dark"] .task-row.task-todo .task-order { background: #45231f; color: #f0a49c; }
[data-theme="dark"] .task-row.task-done,
[data-theme="dark"] .act-done,
[data-theme="dark"] .submit-all.done { background: #17281f; border-color: #2f6a49; }
[data-theme="dark"] .task-row.task-done { border-left-color: #3f8b60; }
[data-theme="dark"] .task-row.task-done .task-order { background: #1f3b2c; color: var(--ok); }
[data-theme="dark"] tr.ok td { background: #17281f; }
[data-theme="dark"] tr.bad td { background: #2a1512; }
[data-theme="dark"] .absent-row.is-absent { background: #2a1512; border-color: #6b3b36; }

/* ปุ่มสลับธีมในหัวเว็บ: ให้กลืนกับแถบน้ำตาล ไม่แย่งสายตาจากเมนู */
.theme-btn { border-color: rgba(255, 255, 255, .28); background: rgba(255, 255, 255, .08);
  color: #fff8f2; font-weight: 600; }
.theme-btn:hover { background: rgba(255, 255, 255, .18); border-color: rgba(255, 255, 255, .45); }
[data-theme="dark"] .theme-btn { background: rgba(255, 255, 255, .1);
  border-color: rgba(255, 255, 255, .3); color: #fff8f2; }
[data-theme="dark"] .theme-btn:hover { background: rgba(255, 255, 255, .2); }

/* ---------- คลิปวิดีโอที่นักเรียนส่ง (ย่อ 240p) ---------- */
.clip-box { margin-top: 12px; }
.clip-box video { display: block; width: 100%; max-width: 480px; border-radius: 10px;
  border: 1px solid var(--line); background: #000; }
.clip-box .small { margin-top: 4px; }

/* ---------- ถังขยะไฟล์งาน ---------- */
.trash-thumb-cell { width: 64px; }
.trash-thumb { width: 56px; height: 56px; object-fit: cover; border-radius: 9px; border: 1px solid var(--line); display: block; }
.trash-thumb-file { display: flex; align-items: center; justify-content: center; height: 56px; border-radius: 9px;
  border: 1px solid var(--line); background: var(--brand-soft); color: var(--brand-dark);
  font-size: 11px; font-weight: 700; letter-spacing: .5px; }
.trash-actions { display: flex; gap: 8px; align-items: center; white-space: nowrap; }
.trash-actions form { margin: 0; }

/* ---------- ตารางสอนครู ---------- */
.tt-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.tt-card { border: 1px solid var(--line); border-radius: 12px; background: #fff; overflow: hidden;
  display: flex; flex-direction: column; }
.tt-card img { display: block; width: 100%; height: auto; background: #f7f2ea; }
.tt-meta { display: flex; flex-direction: column; gap: 2px; padding: 10px 12px; font-size: 13px;
  word-break: break-word; }
.tt-card form { margin: 0; padding: 0 12px 12px; }

/* ---------- ปุ่มงานในหัวข้อ ---------- */
.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: #f6c9a6; }
.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: #fff9f2; }
.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: #faf0e6; 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: #f6c9a6; 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: #8a5200; }
.role-name { font-size: 19px; font-weight: 700; margin-top: 4px; }
.role-desc { font-size: 14px; color: #5b3520; }
.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: #fffcf8; 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: #5b3520; }
.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; }
.work-right { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* ---------- หัวข้อ = ชุดงานที่ทำต่อกัน ---------- */
.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: #f6c9a6; }
.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: #fffcf8; }
.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: #fffcf8; }

/* ---------- สถานะงานของนักเรียน: ค้าง = แดง · ส่งแล้ว/ผ่าน = เขียว ---------- */
.todo-red { color: var(--bad); font-weight: 700; text-shadow: var(--white-edge); }
.done-green { color: var(--ok); font-weight: 700; text-shadow: var(--white-edge); }
/* งานที่ยังไม่ทำ: กรอบแดง + ฟิลเตอร์แดงอ่อนทั้งใบ */
.task-row.task-todo { background: #fdf1ee; border-color: #cf8b84; border-left: 4px solid #b8433a; }
.task-row.task-todo:hover { border-color: #b8433a; }
.task-row.task-todo .task-order { background: #f8d9d5; color: #8f2b24; }
.task-row.task-todo .task-state { color: var(--bad); text-shadow: var(--white-edge); }
/* งานที่ส่งแล้ว/ทำเสร็จ: กรอบเขียว */
.task-row.task-done { background: #f1faf4; border-color: #93cbad; border-left: 4px solid #2f7f57; }
.task-row.task-done:hover { border-color: #2f7f57; }
.task-row.task-done .task-state { color: var(--ok); text-shadow: var(--white-edge); }

/* ---------- เช็คชื่อ ---------- */
.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: #fff9f2; }
.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; }

/* ---------- รหัสผ่านของบัญชีครู: ซ่อนไว้ กด “ดู” แล้วจึงเห็น ---------- */
.pw-cell { min-width: 178px; }
.pw-val { font-family: ui-monospace, "Consolas", monospace; letter-spacing: 1px; }
.pw-line { display: flex; align-items: center; gap: 6px; margin-bottom: 6px; min-height: 30px; }
.pw-form { display: flex; align-items: center; gap: 6px; }
.pw-form input[type=text] { width: 104px; padding: 6px 9px; font-size: 14px; }

/* ---------- รูปประจำตัวนักเรียน (วงกลมบนหน้าวิชาของฉัน) ---------- */
.me-row { display: flex; align-items: center; gap: 16px; margin: 8px 0 12px; flex-wrap: wrap; }
.avatar-form { display: flex; align-items: center; gap: 10px; }
.avatar { position: relative; width: 96px; height: 96px; border-radius: 50%; overflow: hidden;
  border: 2px dashed var(--line); display: flex; align-items: center; justify-content: center;
  cursor: pointer; background: #fff8ef; flex: 0 0 auto; }
.avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.avatar-ph { display: flex; flex-direction: column; align-items: center; font-size: 22px;
  color: var(--muted); line-height: 1.15; }
.avatar-ph .small { font-size: 11px; }
.avatar input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
.avatar:focus-within { outline: 2px solid var(--brand); outline-offset: 2px; }

/* ---------- หน้าวิชาของฉัน: ระยะห่างระหว่างรายวิชากับการ์ดกราฟ ---------- */
.home-subjects { margin-bottom: 22px; }

/* ---------- กราฟพัฒนาการ (จุดละ 1 วัน · ไล่สีตามคะแนน) ---------- */
.progress-chart { width: 100%; height: auto; display: block; margin: 10px 0 4px;
  background: #fffcf8; border: 1px solid var(--line); border-radius: 12px; padding: 6px; }
.chart-filters { display: flex; flex-wrap: wrap; gap: 8px; }
.chart-legend { display: flex; flex-wrap: wrap; gap: 16px; margin-top: 6px;
  font-size: 13.5px; color: var(--muted); }
.chart-legend .lg { display: inline-flex; align-items: center; gap: 6px; }
.chart-legend .dot { width: 12px; height: 12px; border-radius: 50%; display: inline-block; }
/* ---------- บันทึกคะแนนเอง: รายชื่อนักเรียนให้กรอกคะแนน ---------- */
.score-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(232px, 1fr));
  gap: 8px; max-height: 420px; overflow: auto; margin: 10px 0 4px; }
.score-row { display: flex; align-items: center; gap: 10px; padding: 7px 10px;
  border: 1px solid var(--line); border-radius: 10px; }
.score-no { width: 22px; color: var(--muted); font-size: 13px; }
.score-name { flex: 1; font-size: 14.5px; }
.score-row input[type=number] { width: 74px; flex: 0 0 auto; padding: 6px 8px; font-size: 14px; }
.score-photo { flex: 0 0 auto; position: relative; display: inline-flex; align-items: center;
  justify-content: center; gap: 2px; min-width: 46px; height: 34px; padding: 0 6px;
  border: 1px solid var(--line); border-radius: 8px; cursor: pointer; font-size: 16px;
  line-height: 1; }
.score-photo .ph-n { font-size: 12px; color: var(--muted); }
.score-photo.has-photo { border-color: #2f7f57; background: #eef7f1; }
.score-photo.has-photo .ph-n { color: #2f7f57; font-weight: 700; }
.score-photo:hover { background: #f6efe4; }
.score-photo input { position: absolute; width: 1px; height: 1px; opacity: 0; overflow: hidden; }
.score-photo:focus-within { outline: 2px solid var(--brand); outline-offset: 1px; }
.scorebook-row { padding: 10px 0; border-bottom: 1px solid var(--line); }
.scorebook-row:last-child { border-bottom: none; }
.scorebook-row .img-strip { margin-top: 8px; }
.scorebook[open] > summary, .scorebook-one[open] > summary { margin-bottom: 8px; }
.scorebook-one > summary { display: inline-flex; }
.score-one-actions { display: flex; align-items: center; gap: 12px; margin-top: 12px; }

/* ---------- รายการคะแนนที่บันทึกแล้ว (แก้ไข/ลบรูปได้) ---------- */
.scored-row { padding: 10px 0; border-bottom: 1px solid var(--line); }
.scored-row:last-child { border-bottom: none; }
.scored-head { display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap; }
.photo-strip { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.photo-chip { position: relative; display: inline-block; }
.photo-chip img { width: 86px; height: 86px; object-fit: cover; border-radius: 8px;
  border: 1px solid var(--line); display: block; }
.photo-chip .photo-x { position: absolute; top: -7px; right: -7px; width: 24px; height: 24px;
  border-radius: 50%; border: 1px solid #e2b7b3; background: #fff; color: var(--bad);
  font-size: 15px; line-height: 1; cursor: pointer; padding: 0; }
.photo-chip .photo-x:hover { background: var(--bad); color: #fff; }
.scored-edit { margin-top: 8px; }
.scored-edit > summary { display: inline-flex; list-style: none; cursor: pointer; }
.scored-edit > summary::-webkit-details-marker { display: none; }
.scored-edit > summary::marker { content: ""; }
.scored-edit[open] > summary { margin-bottom: 8px; }
.score-one-actions .score-photo { min-width: 54px; height: 40px; font-size: 18px; }

.score-form { display: flex; gap: 6px; align-items: center; justify-content: flex-end; }
.score-form input { width: 84px; padding: 6px 8px; font-size: 14px; }

/* ---------- คลังความรู้: รายการให้ติ๊กเลือกตอนสั่งงาน ---------- */
.kb-list { border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; }
.kb-item { display: flex; align-items: center; gap: 10px; padding: 9px 4px; border-bottom: 1px solid var(--line); }
.kb-item:last-child { border-bottom: none; }
.kb-item input { width: 18px; height: 18px; flex: 0 0 auto; }
.kb-item a { font-weight: 600; }
