/* ธีมโรงเรียน: ฟ้าตามโลโก้ + น้ำเงินเครื่องแบบ (ชุดเดียวกับระบบห้องพยาบาล) */
:root {
  --sky: #7FD0F0; --blue: #2489C2; --navy: #1F3A68; --ink: #1d2433; --muted: #5b6475;
  --paper: #ffffff; --bg: #eef6fb; --line: #c9d6e2; --ok: #1f8a4c; --warn: #b76e00; --err: #b3261e;
  --font: 'Sarabun', 'TH Sarabun New', 'Leelawadee UI', Tahoma, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font-family: var(--font); color: var(--ink); background: var(--bg); font-size: 18px; line-height: 1.55; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }

.topbar { background: var(--navy); color: #fff; display: flex; align-items: center; gap: 12px; padding: 8px 16px; position: sticky; top: 0; z-index: 10; }
.topbar img { width: 40px; height: 40px; border-radius: 50%; background: #fff; }
.topbar .t { font-weight: 700; font-size: 20px; }
.topbar .who { margin-left: auto; font-size: 16px; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.wrap { max-width: 1000px; margin: 0 auto; padding: 16px; }
.btn { text-decoration: none; display: inline-block; border: 0; border-radius: 10px; padding: 10px 18px; background: var(--blue); color: #fff; font-weight: 600; }
.btn:hover { filter: brightness(1.08); }
.btn.ghost { background: #fff; color: var(--navy); border: 1px solid var(--line); }
.btn.small { padding: 5px 12px; font-size: 15px; }
.btn.ok { background: var(--ok); }
.btn:disabled { opacity: .5; cursor: default; }
.card { background: #fff; border-radius: 14px; padding: 18px; box-shadow: 0 1px 3px rgba(0,0,0,.08); margin-bottom: 14px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 10px; }
.pick { background: #fff; border: 2px solid var(--line); border-radius: 12px; padding: 12px; text-align: left; }
.pick:hover { border-color: var(--blue); }
.pick b { color: var(--navy); font-size: 22px; margin-right: 6px; }
.pick small { color: var(--muted); display: block; }
.big { font-size: 28px; text-align: center; padding: 22px; }
.msg { padding: 10px 14px; border-radius: 10px; margin: 10px 0; }
.msg.err { background: #fdecea; color: var(--err); }
.msg.ok { background: #e6f4ec; color: var(--ok); }
.pill { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 15px; background: #eef1f5; color: var(--muted); }
.pill.draft { background: #fff4e0; color: var(--warn); }
.pill.submitted { background: #e6f4ec; color: var(--ok); }
h2.sec { color: var(--navy); margin: 6px 0 12px; font-size: 22px; }

/* ---------- ใบงานบนจอ (หน้าตาเหมือนกระดาษ) ---------- */
.sheet { background: var(--paper); max-width: 21cm; margin: 0 auto; padding: 1.27cm; box-shadow: 0 2px 10px rgba(0,0,0,.12); border-radius: 4px; }
.ws-head { display: flex; gap: 12px; align-items: center; border-bottom: 1.5px solid #000; padding-bottom: 6px; }
.ws-logo { width: 58px; height: 58px; }
.ws-school, .ws-subject { font-weight: 700; }
.ws-subject { font-size: .88em; }
.ws-name { font-weight: 700; margin: 10px 0 8px; display: flex; flex-wrap: wrap; gap: 4px; align-items: baseline; }
.ws-fillname { flex: 1; min-width: 40%; border-bottom: 1.5px dotted #000; padding: 0 6px; font-weight: 400; }
.ws-fillno { display: inline-block; min-width: 3em; border-bottom: 1.5px dotted #000; text-align: center; font-weight: 400; }
.ws-obj { border: 1px solid #000; padding: 4px 10px; font-size: .9em; margin-bottom: 10px; }
.ws-title { font-size: 1em; text-align: center; margin: 10px 0 4px; }
.ws-h { font-size: 1em; margin: 14px 0 4px; }
.ws-p { margin: 4px 0; }
.ws-fill { line-height: 2.1; }
.in-blank { border: 0; border-bottom: 2px dotted var(--blue); background: #f4fbff; padding: 0 6px; margin: 0 4px; border-radius: 4px 4px 0 0; }
.in-lines { width: 100%; border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; background: #f9fcff; resize: vertical;
  background-image: linear-gradient(transparent calc(1.55em + 7px), #dfe8f0 0); background-size: 100% calc(1.55em); background-attachment: local; line-height: 1.55em; }
.in-lines:focus, .in-blank:focus, .in-cell textarea:focus { outline: 3px solid var(--sky); background-color: #fff; }
.in-check input { width: 22px; height: 22px; vertical-align: middle; }
.in-choice { display: inline-flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: 0 4px; }
.in-choice small { color: var(--muted); }
.in-choice label span, .ws-self label span { display: inline-block; border: 1.5px solid var(--line); border-radius: 999px; padding: 0 14px; background: #fff; cursor: pointer; }
.in-choice input, .ws-self input { position: absolute; opacity: 0; pointer-events: none; }
.in-choice input:checked + span, .ws-self input:checked + span { background: var(--blue); border-color: var(--blue); color: #fff; }
.in-choice input:focus-visible + span, .ws-self input:focus-visible + span { outline: 3px solid var(--sky); }
.ws-tablewrap { overflow-x: auto; margin: 4px 0 10px; }
.ws-table { border-collapse: collapse; width: 100%; }
.ws-table th, .ws-table td { border: 1px solid #000; padding: 2px 6px; vertical-align: top; }
.ws-table th { text-align: center; }
.in-cell { padding: 0 !important; }
.in-cell textarea { width: 100%; min-height: 2.4em; border: 0; resize: vertical; padding: 4px 6px; background: #f9fcff; display: block; }
.ws-img { text-align: center; margin: 8px 0; }
.ws-img img { width: 100%; cursor: zoom-in; border: 1px solid var(--line); }
.ws-img figcaption { font-size: 14px; color: var(--muted); }
.ws-self { border: 2px solid var(--sky); border-radius: 12px; margin-top: 18px; display: flex; flex-wrap: wrap; gap: 8px; }
.ws-self legend { font-weight: 700; color: var(--navy); padding: 0 6px; }
.ws-self small { display: block; font-size: 13px; opacity: .8; }
.ws-self label span { border-radius: 12px; padding: 4px 12px; text-align: center; }
textarea[readonly], input:disabled { background: #fff !important; }
.zoom { position: fixed; inset: 0; background: rgba(0,0,0,.85); display: flex; align-items: center; justify-content: center; z-index: 50; cursor: zoom-out; padding: 16px; }
.zoom img { max-width: 100%; max-height: 100%; background: #fff; }

.actionbar { position: sticky; bottom: 0; background: rgba(238,246,251,.96); padding: 10px 16px; display: flex; gap: 10px; align-items: center; justify-content: center; flex-wrap: wrap; border-top: 1px solid var(--line); }
.save-state { color: var(--muted); font-size: 16px; min-width: 12em; text-align: center; }

/* ---------- ครู ---------- */
.tbl { border-collapse: collapse; width: 100%; background: #fff; font-size: 16px; }
.tbl th, .tbl td { border: 1px solid var(--line); padding: 4px 6px; text-align: center; }
.tbl td.nm { text-align: left; white-space: nowrap; }
.tbl th.ws { min-width: 64px; font-size: 14px; }
.st { border: 0; background: none; font-size: 20px; padding: 0 4px; }
.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }
.tabs button { border: 1px solid var(--line); background: #fff; border-radius: 10px; padding: 6px 14px; }
.tabs button.on { background: var(--navy); color: #fff; border-color: var(--navy); }
.wslist { display: grid; gap: 6px; }
.wsrow { display: flex; gap: 10px; align-items: center; background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 6px 10px; flex-wrap: wrap; }
.wsrow .ttl { flex: 1; min-width: 240px; }
.switch { display: inline-flex; align-items: center; gap: 6px; }
.switch input { width: 22px; height: 22px; }
dialog { border: 0; border-radius: 14px; padding: 0; width: min(23cm, 96vw); max-height: 94vh; }
dialog::backdrop { background: rgba(0,0,0,.5); }
.dlg-bar { position: sticky; top: 0; background: var(--navy); color: #fff; padding: 8px 14px; display: flex; gap: 8px; align-items: center; z-index: 2; }
.dlg-bar .sp { flex: 1; }
.scroll { overflow-x: auto; }

@media (max-width: 700px) {
  .sheet { padding: 14px; }
  body { font-size: 17px; }
}
