/* เฟส 3: เกษียนและลงนาม */
.st-signed { background: var(--success-bg); color: var(--success); }
.st-returned { background: var(--danger-bg); color: var(--danger); }

.action-bar {
  display: flex; gap: 16px; align-items: center; justify-content: space-between; flex-wrap: wrap; padding: 16px 20px; border-radius: 18px; color: #fff;
  background: linear-gradient(120deg, var(--navy-800), var(--blue-700)); box-shadow: 0 16px 34px -20px rgba(15, 39, 102, .9);
  position: relative; overflow: hidden;
}
.action-bar::before { content: ""; position: absolute; right: -60px; top: -80px; width: 220px; height: 220px; border-radius: 50%; background: radial-gradient(circle, rgba(249, 115, 22, .7), transparent 65%); animation: drift1 12s ease-in-out infinite; }
.action-bar > * { position: relative; }
.action-bar b { display: flex; gap: 8px; align-items: center; font-size: 16px; }
.action-bar b i { animation: ring 2s ease-in-out infinite; }
.action-bar span { font-size: 13.5px; opacity: .85; }

.note-card { padding: 18px 20px; display: grid; gap: 10px; border-left: 4px solid var(--blue-500); border-radius: 0 var(--radius-lg) var(--radius-lg) 0; }
.note-card.n-director { border-left-color: var(--orange-500); }
.note-head { display: flex; gap: 12px; align-items: center; }
.note-head b { display: block; font-weight: 600; }
.note-head span { font-size: 13px; color: var(--text-3); }
.note-ic { width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center; font-size: 19px; background: var(--blue-50); color: var(--blue-700); flex: none; }
.n-director .note-ic { background: var(--orange-100); color: var(--orange-600); }
.note-card p { white-space: pre-line; font-family: "Sarabun", var(--font); font-size: 16px; color: #1d3a9e; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .note-card p { color: #a9bdff; } }

.review-grid { grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
.review-card { padding: 18px 20px; display: grid; gap: 8px; color: inherit; text-decoration: none !important; position: relative; overflow: hidden; }
.review-card h3 { font-size: 17px; }
.review-card .quote { font-size: 13.5px; color: var(--text-2); background: var(--surface-2); padding: 8px 10px; border-radius: 10px; display: flex; gap: 6px; }
.go-pill { color: var(--orange-600); font-weight: 600; display: inline-flex; gap: 4px; align-items: center; transition: gap .3s var(--ease); }
.review-card:hover .go-pill { gap: 10px; }

.sign-layout { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 18px; align-items: start; }
.sign-form { position: sticky; top: 84px; }
.stage-wrap { padding: 16px; background: color-mix(in srgb, var(--navy-800) 7%, var(--surface-2)); }
.stage { position: relative; margin: 0 auto; width: fit-content; touch-action: none; }
.stage canvas { display: block; background: #fff; border-radius: 4px; box-shadow: 0 10px 30px -12px rgba(6, 15, 43, .55); }
.note-box {
  position: absolute; cursor: grab; border-radius: 6px; outline: 2px dashed var(--orange-500); outline-offset: 2px;
  background: rgba(249, 115, 22, .06); transition: outline-color .2s, box-shadow .2s; animation: glow-box 2.4s ease-in-out infinite;
}
.note-box img { width: 100%; height: 100%; display: block; pointer-events: none; user-select: none; }
.note-box.dragging { cursor: grabbing; box-shadow: 0 16px 34px -12px rgba(234, 88, 12, .6); animation: none; }
.note-box:focus-visible { outline-color: var(--blue-600); }
.note-box .grip { position: absolute; top: -14px; right: -14px; width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; background: var(--grad-orange); color: #fff; font-size: 15px; box-shadow: 0 6px 14px -6px rgba(234, 88, 12, .9); }
@keyframes glow-box { 50% { box-shadow: 0 0 0 6px rgba(249, 115, 22, .14); } }

.prev-note { padding: 12px 14px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--border); }
.prev-note b { font-size: 13px; color: var(--text-3); font-weight: 500; }
.prev-note p { white-space: pre-line; margin-top: 4px; }
.chip-btn { border: 1px solid var(--border-strong); background: var(--surface); border-radius: 999px; padding: 5px 12px; font-size: 13.5px; cursor: pointer; transition: all .25s var(--ease); }
.chip-btn:hover { border-color: var(--orange-500); color: var(--orange-700); transform: translateY(-1px); background: var(--orange-50); }
.chip-btn:active { transform: scale(.96); }
#f-note { font-family: "Sarabun", var(--font); font-size: 16px; line-height: 1.6; }

.sig-row { display: flex; gap: 10px; align-items: center; justify-content: space-between; padding: 10px 12px; border: 1px dashed var(--border-strong); border-radius: 12px; }
.sig-preview { min-height: 60px; display: flex; align-items: center; }
.sig-preview img { max-height: 90px; max-width: 100%; background: repeating-conic-gradient(var(--surface-2) 0 25%, var(--surface) 0 50%) 0 0 / 16px 16px; border-radius: 8px; padding: 6px; }
.small-sig img { max-height: 54px; }

.sig-modal { width: min(640px, calc(100vw - 24px)); }
.sig-pad { position: relative; border: 2px dashed var(--border-strong); border-radius: 14px; background: #fff; overflow: hidden; }
.sig-pad canvas { display: block; width: 100%; height: auto; aspect-ratio: 900 / 320; touch-action: none; cursor: crosshair; }
.sig-hint { position: absolute; inset: 0; display: grid; place-items: center; color: #b6bfd3; font-size: 22px; pointer-events: none; font-family: var(--font-head); }
.sig-line { position: absolute; left: 8%; right: 8%; bottom: 26%; border-bottom: 1px dashed #c9d2e4; pointer-events: none; }

@media (max-width: 1100px) {
  .sign-layout { grid-template-columns: 1fr; }
  .sign-form { position: static; }
}

/* แบบฟอร์มเกษียนของโรงเรียน */
.seg-block { display: flex; width: 100%; }
.seg-block button { flex: 1; justify-content: center; }
.check-list { display: grid; gap: 8px; }
.check-tile { display: flex; gap: 12px; align-items: center; padding: 10px 12px; border: 1px solid var(--border-strong); border-radius: 12px; cursor: pointer; transition: all .2s var(--ease); font-family: "Sarabun", var(--font); font-size: 15.5px; }
.check-tile:hover { border-color: var(--orange-400); }
.check-tile input { position: absolute; opacity: 0; pointer-events: none; }
.check-tile .box { width: 24px; height: 24px; border-radius: 7px; border: 2px solid var(--border-strong); display: grid; place-items: center; color: transparent; transition: all .25s var(--spring); flex: none; }
.check-tile:has(input:checked) { border-color: var(--orange-500); background: var(--orange-50); }
.check-tile:has(input:checked) .box { background: var(--grad-orange); border-color: transparent; color: #fff; transform: scale(1.08); }
.check-tile:has(input:focus-visible) { box-shadow: var(--ring); }
.pick-box { margin-top: 8px; border: 1px solid var(--border); border-radius: 12px; padding: 10px; background: var(--surface-2); }
.pick-box .search .input { width: 100%; }
.pick-list { max-height: 240px; overflow-y: auto; display: grid; gap: 4px; }
.pick-item { display: flex; gap: 10px; align-items: center; padding: 7px 8px; border-radius: 9px; cursor: pointer; }
.pick-item:hover { background: var(--surface); }
.pick-item span { display: grid; }
.pick-item b { font-weight: 500; font-size: 14.5px; }
.pick-item small { color: var(--text-3); font-size: 12.5px; }
.pick-item:has(input:checked) { background: var(--orange-50); }
.ink-pad { position: relative; border: 1px solid var(--border-strong); border-radius: 12px; overflow: hidden; background: #fff; }
.ink-pad::before {
  /* เส้นจุดที่ท้ายแต่ละบรรทัด ตรงกับเส้นจุดในกรอบเกษียน */
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background-image: radial-gradient(circle at 50% 96%, #9aa8c4 1.1px, transparent 1.5px);
  background-size: 7px calc(100% / var(--lines));
}
.ink-pad canvas { position: relative; display: block; width: 100%; height: auto; touch-action: none; cursor: crosshair; }

/* เฟส 4: มอบหมายและรับทราบ */
.st-assigned { background: var(--orange-100); color: var(--orange-700); }
.st-assigned::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; animation: blink 1.6s ease-in-out infinite; }
.st-completed { background: var(--success-bg); color: var(--success); }
.ack-bar { background: linear-gradient(120deg, #9a3412, var(--orange-600) 55%, #f59e0b); }
.ack-bar::before { background: radial-gradient(circle, rgba(59, 130, 246, .55), transparent 65%); }
.progress { height: 8px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border); overflow: hidden; }
.progress span { display: block; height: 100%; background: var(--grad-orange); border-radius: inherit; transition: width .8s var(--ease); }
.roster { list-style: none; margin: 0; padding: 4px 12px 12px; display: grid; gap: 2px; max-height: 360px; overflow-y: auto; }
.roster li { display: flex; gap: 10px; align-items: center; padding: 8px 10px; border-radius: 10px; }
.roster li:hover { background: var(--surface-2); }
.roster .who { flex: 1; min-width: 0; display: grid; }
.roster .who b { font-weight: 500; font-size: 14px; }
.roster .who span { font-size: 12.5px; color: var(--text-3); }

.inbox-list { display: grid; gap: 12px; }
.inbox-card { display: flex; align-items: center; gap: 12px; padding: 4px 16px 4px 4px; position: relative; overflow: hidden; }
.inbox-card.is-new { border-color: color-mix(in srgb, var(--orange-500) 45%, var(--border)); }
.inbox-card.is-new::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--grad-orange); }
.inbox-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-hover); }
.inbox-main { flex: 1; min-width: 0; display: flex; gap: 14px; padding: 14px; color: inherit; text-decoration: none !important; }
.inbox-ic { width: 46px; height: 46px; border-radius: 14px; display: grid; place-items: center; font-size: 22px; flex: none; background: var(--orange-100); color: var(--orange-600); }
.is-done .inbox-ic { background: var(--success-bg); color: var(--success); }
.inbox-txt { min-width: 0; display: grid; gap: 4px; }
.inbox-txt h3 { font-size: 16px; }
.inbox-txt .order { font-family: "Sarabun", var(--font); color: #1d3a9e; display: flex; gap: 6px; align-items: baseline; }
.inbox-txt .meta { font-size: 12.5px; color: var(--text-3); }
.is-done { opacity: .85; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .inbox-txt .order { color: #a9bdff; } }
@media (max-width: 640px) {
  .inbox-card { flex-direction: column; align-items: stretch; padding: 0 0 12px; }
  .inbox-act { padding: 0 14px; }
  .inbox-act .btn { width: 100%; }
}

/* ชิ้นส่วนกรอบเกษียนที่ลากและย่อขยายแยกกันได้ */
.note-box .part-tag { position: absolute; left: 0; top: -22px; font-size: 11.5px; white-space: nowrap; padding: 1px 8px; border-radius: 999px; background: var(--orange-500); color: #fff; opacity: 0; transform: translateY(4px); transition: opacity .2s, transform .2s; pointer-events: none; }
.note-box:hover .part-tag, .note-box.active .part-tag, .note-box.dragging .part-tag, .note-box.resizing .part-tag { opacity: 1; transform: none; }
.note-box .resize { position: absolute; right: -11px; bottom: -11px; width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; background: var(--blue-600); color: #fff; font-size: 13px; cursor: nwse-resize; box-shadow: 0 4px 10px -4px rgba(29, 78, 216, .9); transition: transform .2s var(--spring); }
.note-box .resize:hover { transform: scale(1.15); }
.note-box.active { outline-color: var(--blue-500); z-index: 2; }
.note-box.resizing { cursor: nwse-resize; animation: none; box-shadow: 0 16px 34px -12px rgba(29, 78, 216, .5); }

.font-size { display: flex; align-items: center; gap: 10px; }
.font-size span { min-width: 76px; text-align: center; font-weight: 500; }
.note-box .resize { cursor: ew-resize; }
