/* ระบบเช็คชื่อเข้าเรียน — Material You (Material 3), green tonal scheme. Chosen by the teacher 2026-11-23 (mockup #6). */
:root {
  --primary: #4f46b8; --on-primary: #fff;
  --primary-container: #e2dfff; --on-primary-container: #2b2478;
  --bg: #f7f6ff; --surface: #ecebfa; --surface-high: #dedcf3; --surface-low: #fff;
  --text: #1b1a24; --mute: #5e5c72; --outline: #c2c0d8; --line: #d6d4ea;
  --error: #ba1a1a; --error-container: #ffdad6; --on-error-container: #410002;
  --late: #7c5800; --late-container: #ffdea6;
  --leave: #3a5ba9; --leave-container: #dbe1ff;
  --radius: 24px;
  --elev-1: 0 1px 2px rgba(0,0,0,.08), 0 1px 3px 1px rgba(0,0,0,.05);
  --elev-2: 0 1px 2px rgba(0,0,0,.1), 0 2px 6px 2px rgba(0,0,0,.06);
  /* legacy names used in templates */
  --green: var(--primary); --green-2: var(--primary); --green-bg: var(--primary-container);
  --red: var(--error); --red-bg: var(--error-container); --amber: var(--late); --amber-bg: var(--late-container);
  --orange: var(--late); --orange-bg: var(--late-container); --blue: var(--leave); --blue-bg: var(--leave-container);
}
* { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body { font-family: 'Noto Sans Thai', system-ui, sans-serif; background: var(--bg); color: var(--text);
       line-height: 1.55; min-height: 100vh; accent-color: var(--primary); }
a { color: var(--primary); font-weight: 600; text-underline-offset: 3px; }
.wrap { max-width: 1000px; margin: 0 auto; padding: 22px 16px 64px; }
.narrow { max-width: 480px; }
h1 { font-size: 1.6em; line-height: 1.25; font-weight: 700; margin-bottom: 6px; letter-spacing: -.2px; }
h2 { font-size: 1.12em; font-weight: 700; margin: 24px 0 10px; }
p { margin-bottom: 10px; }
.mute { color: var(--mute); }
.small { font-size: .88em; }
.center { text-align: center; }

/* cards = tonal surfaces, no border */
.card { background: var(--surface); border-radius: var(--radius); padding: 20px; margin-bottom: 14px; }

/* filled text fields */
label { display: block; font-weight: 600; font-size: .85em; color: var(--mute); margin: 14px 0 5px; letter-spacing: .1px; }
input, select, textarea { width: 100%; padding: 13px 14px 11px; border: 0; border-bottom: 2px solid var(--outline);
  border-radius: 10px 10px 0 0; font: inherit; background: var(--surface-low); color: var(--text); transition: border-color .15s; }
input:focus, select:focus, textarea:focus { outline: none; border-bottom-color: var(--primary); background: #fdfcff; }
input[type=checkbox] { width: 20px; height: 20px; }
select { appearance: none; -webkit-appearance: none; padding-right: 36px;
  background: var(--surface-low) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%235b6b61' stroke-width='2' fill='none'/%3E%3C/svg%3E") no-repeat right 14px center; }
select:disabled { opacity: 1; color: var(--mute); }
.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: end; }
.row > * { flex: 1 1 140px; }

/* buttons: pill shaped */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid var(--outline);
  background: transparent; color: var(--primary); padding: 10px 20px; border-radius: 99px; font: inherit; font-weight: 600;
  cursor: pointer; text-decoration: none; transition: background .15s, box-shadow .15s; min-height: 40px; }
.btn:hover { background: rgba(79,70,184,.08); }
.btn:disabled { opacity: .45; cursor: default; }
.btn.primary { background: var(--primary); color: var(--on-primary); border-color: transparent; }
.btn.primary:hover { box-shadow: var(--elev-1); background: #3f379c; }
.btn.orange { background: var(--primary-container); color: var(--on-primary-container); border-color: transparent; }
.btn.orange:hover { box-shadow: var(--elev-1); }
.btn.danger { color: var(--error); border-color: #e3b9b5; }
.btn.danger:hover { background: rgba(186,26,26,.07); }
.btn.block { width: 100%; padding: 15px; font-size: 1.05em; min-height: 52px; }
.btn.sm { padding: 6px 14px; font-size: .88em; min-height: 34px; }

.msg { padding: 12px 16px; border-radius: 16px; margin: 12px 0; font-weight: 600; }
.msg.err { background: var(--error-container); color: var(--on-error-container); }
.msg.ok { background: var(--primary-container); color: var(--on-primary-container); }
.msg.info { background: var(--late-container); color: #271900; }

/* chips */
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 3px 12px; border-radius: 8px; font-size: .82em; font-weight: 700; }
.b-present { background: var(--primary-container); color: var(--on-primary-container); }
.b-late { background: var(--late-container); color: var(--late); }
.b-absent { background: var(--error-container); color: var(--error); }
.b-leave { background: var(--leave-container); color: var(--leave); }
.b-pending { background: var(--late-container); color: var(--late); }
.code { font-family: ui-monospace, monospace; background: var(--surface-low); padding: 3px 8px; border-radius: 8px; word-break: break-all; }

/* tables */
.tbl-wrap { overflow-x: auto; border-radius: 20px; background: var(--surface-low); box-shadow: var(--elev-1); }
table { border-collapse: collapse; width: 100%; font-size: .93em; }
th, td { padding: 10px 12px; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
th { background: var(--surface); font-weight: 700; color: var(--mute); font-size: .88em; }
th a { color: inherit; }
td.wrap-cell { white-space: normal; }
td select { padding: 7px 34px 6px 10px; border-radius: 8px 8px 0 0; background-color: var(--bg); }
.thumb { width: 46px; height: 46px; object-fit: cover; border-radius: 12px; background: var(--surface); vertical-align: middle; }

/* top app bar */
.top { background: var(--bg); position: sticky; top: 0; z-index: 10; border-bottom: 1px solid var(--line); }
.top .in { max-width: 1000px; margin: 0 auto; padding: 10px 16px; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.logo { display: inline-flex; align-items: center; gap: 9px; font-weight: 700; color: var(--text); text-decoration: none; font-size: 1.05em; }
.logo .mark { width: 34px; height: 34px; border-radius: 12px; display: grid; place-items: center; background: var(--primary-container);
              color: var(--on-primary-container); font-weight: 800; }
.nav { display: flex; gap: 4px; flex-wrap: wrap; flex: 1; }
.nav a { text-decoration: none; color: var(--mute); padding: 7px 14px; border-radius: 99px; font-weight: 600; font-size: .93em; }
.nav a:hover { background: rgba(79,70,184,.07); }
.nav a.on { background: var(--primary-container); color: var(--on-primary-container); }

/* camera */
.cam { position: relative; width: 100%; max-width: 420px; margin: 0 auto; aspect-ratio: 3 / 4; border-radius: 28px;
       overflow: hidden; background: #0e1a13; box-shadow: var(--elev-2); }
.cam video { width: 100%; height: 100%; object-fit: cover; transform: scaleX(-1); }
.cam .oval { position: absolute; left: 14%; right: 14%; top: 12%; bottom: 18%; border: 3px solid rgba(200,240,214,.9);
             border-radius: 50%; pointer-events: none; box-shadow: 0 0 0 999px rgba(14,26,19,.25); }
.cam .say { position: absolute; left: 12px; right: 12px; bottom: 14px; padding: 10px 14px; text-align: center; color: var(--on-primary-container);
            font-weight: 700; font-size: 1.12em; background: rgba(200,240,214,.94); border-radius: 18px; }
.cam .say:empty { display: none; }
.cam .arrow { position: absolute; top: 40%; width: 64px; height: 64px; border-radius: 50%; display: none; place-items: center; font-size: 34px;
              background: var(--primary); color: #fff; box-shadow: var(--elev-2); animation: nudge 0.8s ease-in-out infinite; }
.cam .arrow.left { left: 10px; display: grid; }
.cam .arrow.right { right: 10px; display: grid; --dir: 1; }
@keyframes nudge { 0%,100% { transform: translateX(0); } 50% { transform: translateX(calc(var(--dir, -1) * 10px)); } }

/* check-in result */
.result { text-align: center; padding: 30px 18px; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.result .big { font-size: 56px; line-height: 1; margin-bottom: 8px; }
.result .name { font-size: 1.45em; font-weight: 700; }
.ring { width: 132px; height: 132px; border-radius: 50%; padding: 6px; background: var(--primary-container); position: relative; margin-bottom: 10px; }
.ring img, .ring .ph { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; background: var(--surface-low); display: grid; place-items: center; font-size: 48px; }
.ring .tick { position: absolute; right: 0; bottom: 6px; width: 38px; height: 38px; border-radius: 50%; background: var(--primary); color: #fff;
              display: grid; place-items: center; font-weight: 800; font-size: 18px; border: 4px solid var(--surface); }
.ring.late { background: var(--late-container); } .ring.late .tick { background: var(--late); }
.ring.info { background: var(--leave-container); } .ring.info .tick { background: var(--leave); }
.bigtime { font-size: 2.6em; font-weight: 800; line-height: 1.1; margin-top: 6px; letter-spacing: -1px; }
.bigtime small { font-size: .4em; font-weight: 600; color: var(--mute); letter-spacing: 0; }

.steps { display: flex; gap: 6px; justify-content: center; margin: 4px 0 14px; }
.steps span { flex: 0 1 60px; height: 6px; border-radius: 6px; background: var(--line); }
.steps span.on { background: var(--primary); }

/* classroom QR screen */
.screen { display: grid; grid-template-columns: minmax(280px, 1.1fr) 1fr; gap: 16px; align-items: start; }
.qrbox { background: var(--surface); border-radius: 28px; padding: 22px; text-align: center; }
.qrbox #qr svg { width: 100%; height: auto; max-width: 520px; background: #fff; border-radius: 20px; padding: 10px; }
.counter { font-size: 3.2em; font-weight: 800; color: var(--primary); line-height: 1; }
.meter { height: 10px; background: var(--surface-low); border-radius: 10px; overflow: hidden; margin: 12px 0 4px; }
.meter i { display: block; height: 100%; width: 0; background: var(--primary); border-radius: 10px; transition: width .6s; }
.live li { list-style: none; padding: 8px 0; border-bottom: 1px solid var(--line); display: flex; gap: 8px; align-items: center; }
.live li:last-child { border-bottom: 0; }
.bar { height: 6px; background: var(--surface-low); border-radius: 6px; overflow: hidden; margin: 12px auto 0; max-width: 520px; }
.bar i { display: block; height: 100%; background: var(--primary); transition: width 1s linear; }
.livechip { background: var(--primary-container); color: var(--on-primary-container); padding: 5px 14px; border-radius: 8px; font-weight: 700; font-size: .88em; }
.livechip::before { content: ''; display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--primary); margin-right: 6px; animation: blink 1.4s infinite; }
@keyframes blink { 50% { opacity: .25; } }
@media (max-width: 760px) { .screen { grid-template-columns: 1fr; } }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* assignments */
.alist { display: flex; flex-direction: column; gap: 10px; }
.aitem { display: flex; gap: 14px; align-items: center; background: var(--surface-low); border-radius: 20px; padding: 14px 16px;
         text-decoration: none; color: var(--text); box-shadow: var(--elev-1); }
.aitem:hover { box-shadow: var(--elev-2); }
.aitem .ic { flex: none; width: 44px; height: 44px; border-radius: 14px; display: grid; place-items: center; font-size: 22px;
             background: var(--primary-container); }
.aitem .t { flex: 1; min-width: 0; }
.aitem .t b { display: block; overflow: hidden; text-overflow: ellipsis; }
.aitem .t span { font-size: .86em; color: var(--mute); font-weight: 400; }
.files { list-style: none; display: flex; flex-direction: column; gap: 8px; margin: 10px 0; }
.files li { display: flex; gap: 10px; align-items: center; background: var(--surface-low); border-radius: 14px; padding: 10px 12px; }
.files li .n { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.files li .n a { color: var(--text); }
.prog { height: 4px; background: var(--line); border-radius: 4px; overflow: hidden; margin-top: 4px; }
.prog i { display: block; height: 100%; width: 0; background: var(--primary); }
.desc { white-space: pre-wrap; overflow-wrap: anywhere; }
.scorebig { font-size: 2.2em; font-weight: 800; color: var(--leave); line-height: 1.1; }
.grade { display: grid; grid-template-columns: 1fr 340px; gap: 16px; align-items: start; }
.grade iframe { width: 100%; height: 75vh; border: 0; border-radius: 16px; background: #fff; box-shadow: var(--elev-1); }
.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }
.tabs button.on { background: var(--primary-container); color: var(--on-primary-container); border-color: transparent; }
.stats { display: flex; gap: 8px; flex-wrap: wrap; margin: 8px 0 14px; }
@media (max-width: 860px) { .grade { grid-template-columns: 1fr; } .grade iframe { height: 60vh; } }
.logo .lg { flex: none; display: block; }
/* student hub tiles */
.tile { display: flex; gap: 14px; align-items: center; background: var(--surface-low); border-radius: 22px; padding: 16px 18px;
        text-decoration: none; color: var(--text); box-shadow: var(--elev-1); margin-top: 14px; font-weight: 400; }
.tile:hover { box-shadow: var(--elev-2); }
.tile .ti { flex: none; width: 48px; height: 48px; border-radius: 16px; display: grid; place-items: center; font-size: 24px; background: var(--primary-container); }
.tile b { display: block; font-size: 1.02em; } .tile small { color: var(--mute); }
.tile.big { background: var(--primary); color: #fff; } .tile.big small { color: #d8f5e3; }
.tile.big .ti { background: rgba(255,255,255,.18); }
