/* ซ่อนเนื้อหาเริ่มต้นชั่วครู่ระหว่างโหลดเนื้อหาที่บันทึกไว้ (ไม่เกิน 2 วินาที) */
.cms-wait main, .cms-wait .site-foot { visibility: hidden; }

/* แถบเครื่องมือผู้ดูแล */
body.cms-admin { padding-bottom: 96px; }
#cms-bar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 60;
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
  padding: 10px 16px calc(10px + env(safe-area-inset-bottom, 0px));
  background: #071A20; color: #EAF6F3;
  border-top: 1px solid rgba(227, 179, 65, .45);
  box-shadow: 0 -12px 30px rgba(0, 0, 0, .25);
  font: 14px/1.4 "Anuphan", system-ui, sans-serif;
}
#cms-bar .cms-who { display: grid; margin-right: 6px; line-height: 1.25; }
#cms-bar .cms-who b { color: #E3B341; font-weight: 600; font-size: 12px; letter-spacing: .06em; }
#cms-bar .cms-who span { font-size: 13px; color: #A9CBC6; }
#cms-bar button, #cms-tools button {
  font: inherit; cursor: pointer; border-radius: 999px;
  padding: 7px 14px; border: 1px solid rgba(234, 246, 243, .28);
  background: rgba(255, 255, 255, .06); color: #EAF6F3;
}
#cms-bar button:hover:not(:disabled), #cms-tools button:hover { background: rgba(227, 179, 65, .18); }
#cms-bar button:disabled { opacity: .45; cursor: default; }
#cms-bar button:focus-visible, #cms-tools button:focus-visible { outline: 2px solid #E3B341; outline-offset: 2px; }
#cms-bar .cms-toggle[aria-pressed="true"] { background: #2E8FA3; border-color: #2E8FA3; }
#cms-bar .cms-primary { background: linear-gradient(180deg, #F4CD62, #DDA732); color: #1A1300; border-color: transparent; font-weight: 600; }
#cms-bar .cms-primary:disabled { background: rgba(255, 255, 255, .06); color: #EAF6F3; }
#cms-bar .cms-quiet { border-color: transparent; }
#cms-bar .cms-status { flex: 1 1 220px; color: #A9CBC6; font-size: 13px; }
#cms-bar .cms-status.cms-bad { color: #FFB4A8; }
@media (max-width: 700px) {
  body.cms-admin { padding-bottom: 170px; }
  #cms-bar { gap: 6px; }
  #cms-bar button { padding: 6px 11px; font-size: 13px; }
}

/* เครื่องมือของรายการที่เลือก */
#cms-tools {
  position: fixed; z-index: 61; display: flex; flex-wrap: wrap; gap: 4px;
  padding: 5px; border-radius: 12px; background: #071A20;
  border: 1px solid rgba(227, 179, 65, .45); box-shadow: 0 10px 24px rgba(0, 0, 0, .35);
  font: 13px/1.3 "Anuphan", system-ui, sans-serif; max-width: calc(100vw - 16px);
}
#cms-tools button { padding: 5px 11px; }
#cms-tools .cms-danger { background: #9E2A20; border-color: #9E2A20; }
#cms-tools .cms-danger:hover { background: #B3261E; }

/* สิ่งที่แก้ได้ในโหมดแก้ไข */
.cms-editing [data-block] [contenteditable] {
  outline: 1px dashed rgba(227, 179, 65, .75); outline-offset: 2px; border-radius: 3px; cursor: text;
}
.cms-editing [data-block] [contenteditable]:hover { background: rgba(227, 179, 65, .08); }
.cms-editing [data-block] [contenteditable]:focus { outline: 2px solid #E3B341; background: rgba(227, 179, 65, .12); }
.cms-editing [data-block] img { cursor: pointer; }
.cms-editing [data-block] .cms-current { outline: 2px solid #2E8FA3 !important; outline-offset: 4px; }
.cms-editing .figure button img { transition: none; }
.cms-editing .figure button:hover img { transform: none; }

/* แถบเครื่องมือ: แถวปุ่ม + แถวสี/ฟอนต์ */
#cms-tools { flex-direction: column; align-items: stretch; gap: 6px; width: max-content; max-width: min(460px, calc(100vw - 16px)); }
#cms-tools [hidden] { display: none !important; }
#cms-tools .cms-actions { display: flex; flex-wrap: wrap; gap: 4px; }
#cms-tools .cms-style { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; padding: 6px 4px 2px; border-top: 1px solid rgba(227, 179, 65, .25); }
#cms-tools .cms-actions:empty + .cms-style, #cms-tools .cms-style:first-child { border-top: 0; padding-top: 2px; }
#cms-tools .cms-lbl { color: #A9CBC6; font-size: 12px; }
#cms-tools .cms-swatches { display: flex; flex-wrap: wrap; gap: 5px; align-items: center; }
#cms-tools .cms-swatch { width: 22px; height: 22px; padding: 0; border-radius: 50%; border: 2px solid rgba(234, 246, 243, .55); }
#cms-tools .cms-swatch:hover { transform: scale(1.12); background-blend-mode: normal; }
#cms-tools .cms-picker { width: 26px; height: 26px; padding: 0; border: 2px dashed rgba(234, 246, 243, .55); border-radius: 50%; background: none; cursor: pointer; }
#cms-tools .cms-picker::-webkit-color-swatch-wrapper { padding: 2px; }
#cms-tools .cms-picker::-webkit-color-swatch { border: 0; border-radius: 50%; }
#cms-tools .cms-fontbtn { min-width: 120px; text-align: left; }
#cms-tools .cms-quiet { border-color: transparent; color: #A9CBC6; }
#cms-tools .cms-fontlist { flex-basis: 100%; display: grid; grid-template-columns: 1fr 1fr; gap: 4px; max-height: 220px; overflow-y: auto; padding: 4px; background: rgba(255, 255, 255, .04); border-radius: 10px; }
#cms-tools .cms-fontlist button { border-radius: 8px; text-align: left; font-size: 15px; padding: 6px 10px; }
#cms-tools .cms-hint { flex-basis: 100%; margin: 0; font-size: 11.5px; color: #8FB0AB; }
