/* ==========================================================================
   article-editor.css — หน้าเขียนบทความ (Rich Editor)
   ใช้ design token ของระบบ (--gold, --surface ฯลฯ) ให้เข้าธีมมืด-ทอง
   ========================================================================== */

.mae-compose {
  max-width: 820px;
  margin: 0 auto;
  padding: 16px;
}

/* ชื่อบทความ — ตัวใหญ่ ไม่มีกรอบ ให้รู้สึกเหมือนพิมพ์บนกระดาษ */
.mae-title-input {
  width: 100%;
  background: transparent;
  border: none;
  border-bottom: 2px solid var(--line);
  color: var(--text);
  font-size: 28px;
  font-weight: 700;
  padding: 12px 4px;
  margin-bottom: 8px;
  outline: none;
}
.mae-title-input::placeholder { color: var(--text-mute); }
.mae-title-input:focus { border-bottom-color: var(--gold); }

/* ---------------------------------------------------------------------------
   แถบเครื่องมือ — เหนียวติดด้านบนเวลาเลื่อน (sticky)
   --------------------------------------------------------------------------- */
.mae-toolbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 6px 8px;
  margin-bottom: 10px;
}
.mae-toolbar button {
  min-width: 34px;
  height: 32px;
  padding: 0 8px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 6px;
  color: var(--text);
  font-size: 14px;
  cursor: pointer;
  transition: background .12s, border-color .12s;
}
.mae-toolbar button:hover {
  background: var(--surface);
  border-color: var(--line);
}
.mae-toolbar button:active { background: var(--gold-dim); }
.mae-sep {
  width: 1px;
  height: 20px;
  background: var(--line);
  margin: 0 4px;
}
.mae-color {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  cursor: pointer;
}
.mae-color input[type="color"] {
  width: 24px;
  height: 24px;
  border: none;
  background: none;
  cursor: pointer;
  padding: 0;
}

/* ---------------------------------------------------------------------------
   พื้นที่เขียน — เหมือนกระดาษ อ่านสบายตา
   --------------------------------------------------------------------------- */
.mae-editor {
  min-height: 360px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px 26px;
  color: var(--text);
  font-size: 17px;
  line-height: 1.75;
  outline: none;
}
.mae-editor:focus { border-color: var(--gold-dim); }

/* placeholder จำลอง (contenteditable ไม่มี placeholder จริง) */
.mae-editor.is-empty::before {
  content: attr(data-placeholder);
  color: var(--text-mute);
  pointer-events: none;
}

/* รูปแบบเนื้อหาในตัว editor + หน้าแสดงผล ให้ตรงกัน */
.mae-editor h2,
.mae-article-body h2 {
  font-size: 24px;
  color: var(--gold-soft);
  margin: 24px 0 10px;
}
.mae-editor h3,
.mae-article-body h3 {
  font-size: 20px;
  color: var(--gold);
  margin: 20px 0 8px;
}
.mae-editor blockquote,
.mae-article-body blockquote {
  border-left: 3px solid var(--gold);
  margin: 16px 0;
  padding: 4px 16px;
  color: var(--text-dim);
  font-style: italic;
}
.mae-editor pre,
.mae-article-body pre {
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  overflow-x: auto;
  font-family: monospace;
  font-size: 14px;
}
.mae-editor img,
.mae-article-body img { max-width: 100%; height: auto; border-radius: 8px; }
.mae-editor a,
.mae-article-body a { color: var(--gold-soft); }
.mae-editor ul, .mae-editor ol,
.mae-article-body ul, .mae-article-body ol { padding-left: 26px; }

/* ---------------------------------------------------------------------------
   ข้อมูลบทความ (พับได้)
   --------------------------------------------------------------------------- */
.mae-meta {
  margin-top: 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 4px 16px 16px;
}
.mae-meta summary {
  cursor: pointer;
  padding: 12px 0;
  color: var(--gold);
  font-weight: 600;
  user-select: none;
}
.mae-meta label {
  display: block;
  margin: 12px 0 4px;
  color: var(--text-dim);
  font-size: 14px;
}
.mae-meta input[type="text"],
.mae-meta input[type="url"],
.mae-meta textarea,
.mae-meta select {
  width: 100%;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  padding: 9px 12px;
  font-size: 15px;
  outline: none;
}
.mae-meta input:focus,
.mae-meta textarea:focus,
.mae-meta select:focus { border-color: var(--gold-dim); }
.mae-meta-row {
  display: flex;
  gap: 12px;
}
.mae-meta-row > div { flex: 1; }

/* ---------------------------------------------------------------------------
   ปุ่มบันทึก
   --------------------------------------------------------------------------- */
.mae-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 18px;
  position: sticky;
  bottom: 0;
  padding: 12px 0;
  background: linear-gradient(to top, var(--bg) 60%, transparent);
}
.mae-actions button {
  padding: 11px 22px;
  border-radius: 10px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
}
.mae-actions .btn-ghost {
  background: var(--surface-2);
  border-color: var(--line);
  color: var(--text);
}
.mae-actions .btn-ghost:hover { background: var(--surface); }
.mae-actions .btn-primary {
  background: var(--gold);
  color: #1a1414;
}
.mae-actions .btn-primary:hover { background: var(--gold-soft); }

/* มือถือ */
@media (max-width: 640px) {
  .mae-compose { padding: 10px; }
  .mae-title-input { font-size: 22px; }
  .mae-editor { padding: 16px; font-size: 16px; }
  .mae-meta-row { flex-direction: column; gap: 0; }
  .mae-actions .btn-ghost span,
  .mae-actions button { padding: 10px 16px; font-size: 14px; }
}

/* ==========================================================================
   หน้าแสดงบทความ (อ่าน)
   ========================================================================== */
.mae-article {
  max-width: 780px;
  margin: 0 auto;
  padding: 16px;
}
/* 🖼️ [27 ต.ค. 2569 · ชุด B · มติเจ้าของ 1ก] กรอบปก 16:9 คงที่ = จองที่ก่อนรูปมา หน้าไม่กระตุก
   ตำแหน่งแนวตั้งมาจาก cover_pos (style="object-position" บน img) · ไม่ตั้ง = กลาง เหมือนการ์ด */
.mae-article-cover {
  margin: -16px -16px 20px;
  aspect-ratio: 16 / 9;
  max-width: calc(100% + 32px);
  overflow: hidden;
  background: var(--surface-2, #221a1a);
  border-radius: 0 0 var(--radius) var(--radius);
}
.mae-article-cover img { width: 100%; height: 100%; object-fit: cover; display: block; }
.mae-article-title {
  font-size: 34px;
  line-height: 1.25;
  color: var(--text);
  margin: 8px 0 12px;
}
.mae-article-byline {
  color: var(--text-mute);
  font-size: 14px;
  margin-bottom: 8px;
}
.mae-article-byline a { color: var(--gold-soft); text-decoration: none; }
.mae-cat {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 1px 10px;
  font-size: 12px;
}
.mae-article-owner-bar { margin: 12px 0 20px; }
.mae-article-owner-bar .btn-ghost {
  display: inline-block;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  padding: 7px 16px;
  text-decoration: none;
  font-size: 14px;
}
.mae-article-body {
  font-size: 18px;
  line-height: 1.8;
  color: var(--text);
  margin-top: 20px;
}
.mae-article-body p { margin: 0 0 18px; }
.mae-article-tags {
  margin-top: 28px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.mae-tag {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 3px 12px;
  font-size: 13px;
  color: var(--text-dim);
}
@media (max-width: 640px) {
  .mae-article-title { font-size: 26px; }
  .mae-article-body { font-size: 16px; }
}

/* ==========================================================================
   โมดัลเลือกบล็อกพิเศษ
   ========================================================================== */
.mae-block-btn {
  background: var(--gold-dim) !important;
  color: #fff !important;
  font-weight: 600;
}
.mae-block-modal {
  position: fixed;
  inset: 0;
  z-index: 3000;
  background: rgba(0, 0, 0, .6);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.mae-block-modal-inner {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  width: 100%;
  max-width: 480px;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: var(--shadow);
}
.mae-block-modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px;
  border-bottom: 1px solid var(--line);
  color: var(--gold);
}
.mae-block-close {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 18px;
  cursor: pointer;
}
.mae-block-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  padding: 16px;
}
.mae-block-choice {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 16px 8px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 13px;
  cursor: pointer;
  transition: border-color .12s, background .12s;
}
.mae-block-choice:hover { border-color: var(--gold); background: var(--surface); }
.mae-block-icon { font-size: 26px; }
.mae-block-form { padding: 16px; }
.mae-bf-fields label {
  display: block;
  margin: 12px 0 4px;
  color: var(--text-dim);
  font-size: 14px;
}
.mae-bf-fields input,
.mae-bf-fields textarea {
  width: 100%;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  padding: 9px 12px;
  font-size: 15px;
  outline: none;
}
.mae-bf-fields input:focus,
.mae-bf-fields textarea:focus { border-color: var(--gold-dim); }
.mae-bf-actions {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-top: 18px;
}
.mae-bf-actions button {
  padding: 10px 20px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
}
.mae-bf-actions .btn-ghost { background: var(--surface-2); border-color: var(--line); color: var(--text); }
.mae-bf-actions .btn-primary { background: var(--gold); color: #1a1414; }
@media (max-width: 480px) {
  .mae-block-grid { grid-template-columns: repeat(2, 1fr); }
}

/* ==========================================================================
   [ข้อ 3] เทมเพลตบทความ — ตัวเลือกเทมเพลต / หน้าปลดล็อก / หลังบ้าน
   ========================================================================== */

/* แถบเลือกเทมเพลตในหน้าเขียน */
.mae-tpl-picker {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  margin-bottom: 14px;
  padding: 4px 14px 12px;
}
.mae-tpl-picker summary {
  cursor: pointer;
  padding: 12px 0;
  color: var(--gold);
  font-weight: 600;
  user-select: none;
}
.mae-tpl-strip {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding-bottom: 6px;
}
.mae-tpl-card {
  flex: 0 0 auto;
  width: 110px;
  text-align: center;
  text-decoration: none;
  color: var(--text-dim);
  font-size: 13px;
  background: var(--surface-2);
  border: 2px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 10px 6px;
  position: relative;
  transition: border-color .12s;
}
.mae-tpl-card:hover { border-color: var(--gold-dim); }
.mae-tpl-card.is-active { border-color: var(--gold); color: var(--text); }
.mae-tpl-card.is-locked { opacity: .75; }
.mae-tpl-thumb {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 56px;
  font-size: 26px;
  margin-bottom: 6px;
  overflow: hidden;
  border-radius: 6px;
  background: var(--bg-soft);
}
.mae-tpl-thumb img { width: 100%; height: 100%; object-fit: cover; }
.mae-tpl-lock {
  display: block;
  margin-top: 4px;
  font-size: 12px;
  color: var(--gold-soft);
}

/* หน้าปลดล็อก */
.mae-unlock {
  max-width: 480px;
  margin: 40px auto;
  padding: 16px;
}
.mae-unlock-box { padding: 32px 24px; text-align: center; }
.mae-unlock-icon { font-size: 48px; margin-bottom: 8px; }
.mae-unlock-box h1 { font-size: 24px; margin: 0 0 14px; color: var(--text); }
.mae-unlock-preview {
  width: 100%;
  border-radius: var(--radius-sm);
  margin-bottom: 16px;
}
.mae-unlock-price { font-size: 18px; color: var(--gold-soft); margin: 12px 0 4px; }
.mae-unlock-form .mae-actions { justify-content: center; }
.mae-unlock .btn-ghost {
  display: inline-block;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--text);
  padding: 11px 22px;
  text-decoration: none;
  font-weight: 600;
}

/* หลังบ้าน: จัดการเทมเพลต */
.mae-tpl-admin .mae-tpl-form { padding: 20px; margin-bottom: 24px; }
.mae-tpl-admin .mae-tpl-form label {
  display: block;
  margin: 14px 0 4px;
  color: var(--text-dim);
  font-size: 14px;
}
.mae-tpl-admin input[type="text"],
.mae-tpl-admin input[type="url"],
.mae-tpl-admin input[type="number"],
.mae-tpl-admin select,
.mae-tpl-admin textarea {
  width: 100%;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  padding: 9px 12px;
  font-size: 15px;
  outline: none;
}
.mae-tpl-json { font-family: monospace; font-size: 13px; }
.mae-tpl-list { display: flex; flex-direction: column; gap: 8px; }
.mae-tpl-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 16px;
  gap: 12px;
  flex-wrap: wrap;
}
.mae-tpl-item.is-off { opacity: .6; }
.mae-tpl-info { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.mae-tpl-badge {
  font-size: 12px;
  padding: 2px 10px;
  border-radius: 20px;
  border: 1px solid var(--line);
  color: var(--text-dim);
}
.mae-tpl-badge.b-free { color: var(--ok); border-color: var(--ok); }
.mae-tpl-badge.b-unlock { color: var(--gold); border-color: var(--gold-dim); }
.mae-tpl-badge.b-off { color: var(--red-soft); border-color: var(--red); }
.mae-tpl-acts { display: flex; gap: 8px; }
.mae-tpl-acts .btn-ghost {
  display: inline-block;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  padding: 7px 14px;
  text-decoration: none;
  font-size: 14px;
  cursor: pointer;
}
.small { font-size: 13px; }

/* ==========================================================================
   หลังบ้าน: จัดการบทความ
   ========================================================================== */
.mae-admin-bar { display: flex; gap: 10px; flex-wrap: wrap; margin: 16px 0; }
.mae-admin-bar a {
  display: inline-block;
  padding: 10px 18px;
  border-radius: 10px;
  text-decoration: none;
  font-weight: 600;
  font-size: 14px;
  border: 1px solid var(--line);
}
.mae-admin-bar .btn-primary { background: var(--gold); color: #1a1414; border-color: var(--gold); }
.mae-admin-bar .btn-ghost { background: var(--surface-2); color: var(--text); }

.mae-admin-filters, .mae-admin-pager {
  display: flex; gap: 8px; flex-wrap: wrap; margin: 14px 0;
}
.mae-chip {
  padding: 6px 14px;
  border-radius: 20px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--text-dim);
  text-decoration: none;
  font-size: 14px;
}
.mae-chip.is-active { border-color: var(--gold); color: var(--gold); }

.mae-admin-list { display: flex; flex-direction: column; gap: 8px; }
.mae-admin-item {
  display: flex; justify-content: space-between; align-items: center;
  gap: 12px; padding: 14px 16px; flex-wrap: wrap;
}
.mae-admin-main { flex: 1; min-width: 200px; }
.mae-admin-title { color: var(--text); font-weight: 600; text-decoration: none; }
.mae-admin-title:hover { color: var(--gold-soft); }
.mae-admin-meta { color: var(--text-mute); font-size: 13px; margin-top: 4px; }
.mae-status {
  display: inline-block;
  font-size: 12px;
  padding: 1px 9px;
  border-radius: 20px;
  border: 1px solid var(--line);
  margin-right: 4px;
}
.mae-status.s-published { color: var(--ok); border-color: var(--ok); }
.mae-status.s-draft { color: var(--warn); border-color: var(--warn); }
.mae-status.s-archived { color: var(--text-mute); }
.mae-admin-acts { display: flex; gap: 6px; flex-wrap: wrap; }
.mae-admin-acts .btn-ghost {
  display: inline-block;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  padding: 6px 12px;
  text-decoration: none;
  font-size: 13px;
  cursor: pointer;
}
.mae-admin-acts .btn-ghost.danger { color: var(--red-soft); border-color: var(--red); }

.mae-board-list { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.mae-board-item { display: flex; align-items: center; gap: 8px; padding: 10px 16px; }
.mae-board-form { padding: 20px; margin-top: 10px; }
.mae-board-form label {
  display: block; margin: 12px 0 4px; color: var(--text-dim); font-size: 14px;
}
.mae-board-form input, .mae-board-form select {
  width: 100%;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  padding: 9px 12px;
  font-size: 15px;
  outline: none;
}

/* ===========================================================================
   [เพิ่มใหม่ — โฮสต์ที่สอง] หน้าเขียนบทความยืมร่างกล่องพิมพ์กลาง
   ===========================================================================
   โหมดบทความไม่มี .composer-modal-overlay (ตัวที่ fixed เต็มจอ) ฟอร์มจึงไหล
   ตามหน้าอยู่แล้ว — ที่นี่แค่จัดระยะรอบนอก + ของเฉพาะบทความ 3 ชิ้น
   ห้ามไปแก้ composer.css เด็ดขาด (ไฟล์นั้นเสิร์ฟทุกหน้าทั้งเว็บ) */

.composer-article-host {
    margin-top: 12px;
}
/* กล่องพิมพ์ในโหมดบทความสูงขึ้น — งานเขียนยาว ไม่ใช่โพสต์สั้น */
.composer-article-form .magic-docs-tiptap-container {
    min-height: 320px;
}

/* แถวรูปปก: ช่อง URL + ปุ่ม "ใช้รูปแรกในบทความ" เรียงแนวนอน (มือถือ = ซ้อน) */
.mae-cover-row {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}
.mae-cover-row input[type="url"] { flex: 1; min-width: 200px; }
/* 🖼️ [27 ต.ค. 2569 · ชุด B] ตัวปรับตำแหน่งปก (หน้าเขียน) — กรอบ 16:9 เท่าหน้าอ่าน */
.mae-cover-pos { display: grid; gap: 8px; margin: 8px 0 14px; max-width: 520px; }
.mae-cover-pos[hidden] { display: none; }
.mae-cover-pos-frame {
  position: relative; aspect-ratio: 16 / 9; max-width: 100%; overflow: hidden;
  border-radius: 12px; border: 2px solid var(--gold-dim, #8a7128); background: var(--surface-2, #221a1a);
  cursor: grab; touch-action: none; user-select: none; -webkit-user-select: none;
}
.mae-cover-pos-frame.is-drag { cursor: grabbing; border-color: var(--gold, #d4af37); }
.mae-cover-pos-frame img { width: 100%; height: 100%; object-fit: cover; display: block; pointer-events: none; }
.mae-cover-pos-hint {
  position: absolute; left: 50%; bottom: 8px; transform: translateX(-50%);
  background: rgba(0, 0, 0, .6); color: #fff; font-size: .8rem; padding: 3px 10px; border-radius: 999px; pointer-events: none;
}
.mae-cover-pos input[type="range"] { width: 100%; accent-color: var(--gold, #d4af37); }
.mae-cover-pos-foot { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.mae-cover-pos-txt { font-size: .82rem; color: var(--text-dim, #a1938c); margin-left: auto; }

/* วูบทองสั้น ๆ ยืนยันว่าหยิบรูปปกสำเร็จแล้ว (คนกดจะได้ไม่กดซ้ำ) */
.mae-cover-flash {
    box-shadow: 0 0 0 2px var(--gold, #e5c07b);
    transition: box-shadow .3s;
}

/* ปุ่มลอยเรียกบล็อกพิเศษ — มุมล่างขวา กดได้ตลอดไม่ว่าจะเลื่อนเขียนถึงไหน
   วางฝั่งขวาเหนือระดับนิ้วโป้ง ไม่ทับปุ่มบันทึกท้ายฟอร์ม */
.mae-block-fab {
    position: fixed;
    right: 14px;
    bottom: 84px;
    z-index: 40;
    padding: 10px 16px;
    border-radius: 999px;
    border: 1px solid var(--gold, #e5c07b);
    background: var(--surface, #16181d);
    color: var(--gold, #e5c07b);
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 4px 14px rgba(0, 0, 0, .35);
}
.mae-block-fab:active { transform: scale(.97); }

/* ===========================================================================
   [เพิ่มใหม่ — โหมดสตูดิโอ 🎬] แถบบนตอนเข้าหน้าเขียนจากหลังบ้าน
   =========================================================================== */
.mae-studio-bar {
    position: sticky;
    top: 0;
    z-index: 60;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    background: var(--surface, #16181d);
    border-bottom: 1px solid var(--gold, #e5c07b);
    margin-bottom: 12px;
}
.mae-studio-title {
    font-weight: 700;
    color: var(--gold, #e5c07b);
}

/* ===========================================================================
   [ข้อ 3 — เพิ่มใหม่] dock บน/ล่างนิ่ง เฉพาะโหมดสตูดิโอ ตรงกลาง (บทความ)
   เลื่อนได้ตามปกติ — ไม่ตัดปุ่ม/ฟังก์ชันเดิมออกเลยแม้แต่ปุ่มเดียว แค่เปลี่ยน
   ตำแหน่งที่มันนิ่งอยู่ตอนเลื่อนหน้าเท่านั้น (ดูเหตุผลใน composer.php ตรง
   ที่เติมคลาส is-sticky-dock — ผูกกับ $maeStudio ตัวเดียวกับที่มีอยู่แล้ว)
   =========================================================================== */
.composer-dock-top.is-sticky-dock {
    position: sticky;
    /* ใช้ตัวแปรที่ JS วัดความสูงจริงของ .mae-studio-bar มาเติมให้ (ดู composer.js
       ฟังก์ชัน mesSyncStudioDockOffset) ไม่เดาเลขคงที่ เพราะฟอนต์/ปุ่มอาจสูง
       ไม่เท่ากันในแต่ละเครื่อง ค่า 56px เป็นแค่ fallback กันพังก่อน JS รันเสร็จ */
    top: var(--mae-studio-bar-h, 56px);
    z-index: 55;
    background: var(--surface, #16181d);
    padding-top: 8px;
    padding-bottom: 10px;
    border-bottom: 1px solid rgba(229, 192, 123, .25);
}
.composer-bottom-tools.is-sticky-dock {
    position: sticky;
    bottom: 0;
    z-index: 55;
    background: var(--surface, #16181d);
    padding-top: 8px;
    padding-bottom: 8px;
    border-top: 1px solid rgba(229, 192, 123, .25);
}

/* [เพิ่ม 18 ส.ค.] แถวสกัดรูป + จอพรีวิวสดในฟอร์มบล็อก (ใช้ทั้งโมดัลบทความและตัวสร้างแพทเทิร์น) */
.bf-extract-row {
    display: flex;
    gap: 6px;
    margin: 4px 0 10px;
}
.bf-extract-row .bf-extract-src { flex: 1; min-width: 0; }
.bf-extract-row .bf-extract-btn {
    white-space: nowrap;
    padding: 6px 10px;
    border-radius: 8px;
    border: 1px solid var(--gold, #e5c07b);
    background: transparent;
    color: var(--gold, #e5c07b);
    cursor: pointer;
}
.bf-live-preview {
    margin: 10px 0;
    padding: 10px;
    border: 1px dashed var(--line, #2a2d34);
    border-radius: 10px;
    min-height: 44px;
    overflow-x: hidden;
}
.bf-preview-empty { color: var(--text-mute, #8b8f98); font-size: .85rem; text-align: center; }

/* [เพิ่มใหม่ — กันงานหาย 23 ส.ค.] ป้ายเล็ก ๆ แจ้งว่า autosave ทำงานแล้ว
   จางเข้า/จางออกเบา ๆ ไม่รบกวนสายตา อยู่หน้าปุ่มบันทึก/เผยแพร่ */
.mae-autosave-indicator {
    align-self: center;
    margin-right: auto;
    font-size: .82rem;
    color: var(--text-mute, #8b8f98);
    opacity: 0;
    transition: opacity .3s;
}
.mae-autosave-indicator.is-visible { opacity: 1; }

/* ---------------------------------------------------------------------------
 * [เพิ่มใหม่ — schema/156-157 ราคา/ซีรีส์ 16 ก.ย. 2569]
 * หน้าล็อกตอนใน article-single / หน้ารวมตอน article-series
 * ------------------------------------------------------------------------- */
.mae-article-locked {
  position: relative;
  max-height: 160px;
  overflow: hidden;
  text-align: center;
}
.mae-article-locked::after {
  content: '';
  position: absolute; left: 0; right: 0; bottom: 0; height: 70px;
  background: linear-gradient(transparent, var(--bg-soft, #141010) 92%);
}
.mae-article-locked .mae-unlock-icon { font-size: 26px; margin-top: 10px; }
.mae-unlock-cta {
  text-align: center;
  border: 1px solid var(--gold-dim);
  border-radius: 12px;
  padding: 14px;
  margin-top: -4px;
}
.mae-hint { font-size: 12px; color: var(--text-mute, #6f6360); margin: 4px 0 10px; }

.mae-series-hub { max-width: 640px; margin: 0 auto; padding: 12px; }
.mae-series-head { text-align: center; }
.mae-series-cover { width: 90px; border-radius: 8px; margin-bottom: 8px; }
.mae-badge { display: inline-block; font-size: 12px; padding: 2px 10px; border-radius: 20px; }
.mae-badge.done { background: #12233a; color: #7fb3e0; border: 1px solid #1f3a5c; }
.mae-badge.ongoing { background: #2b230f; color: var(--warn, #d98a1f); border: 1px solid #4a3a14; }
.mae-ep-list { display: flex; flex-direction: column; gap: 8px; }
.mae-ep-item {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px;
  color: var(--text); text-decoration: none;
}
.mae-ep-item:hover { border-color: var(--gold-dim); }
.mae-bundle-box { text-align: center; }
.mae-bundle-save { font-size: 12px; color: var(--text-mute, #6f6360); margin-top: 6px; }

/* หลังบ้าน — ตาราง/สวิตช์ตั้งค่าราคา (admin/article-price-tiers.php) */
.admin-table { width: 100%; border-collapse: collapse; margin: 10px 0 18px; }
.admin-table td { padding: 8px; border-bottom: 1px solid var(--line); font-size: 13.5px; }
.switch { display: flex; align-items: center; justify-content: space-between; margin: 10px 0; }


/* 📚 [22 ก.ย. 2569] สารคดีตอน 1 / เรื่องเดี่ยว — อ่านฟรี X% แรก
   กรอบล็อกเดิมตัดความสูง (ทำไว้สำหรับคำโปรยสั้น) → ส่วนที่ให้อ่านฟรีถูกตัดเหลือไม่กี่บรรทัด
   ปลดเพดานความสูงเฉพาะกรอบนี้ · เงาจางเหลือแค่ช่วงท้ายให้รู้ว่ามีต่อ · เนื้อหาหลัง X% ไม่ถูกส่งมาใน HTML อยู่แล้ว */
.mae-article-locked.mae-docu-preview { max-height: none; overflow: visible; }
.mae-article-locked.mae-docu-preview::after { height: 60px; }
.mae-docu-preview-note {
  position: relative; z-index: 1; text-align: center; font-weight: 700;
  color: var(--gold, #d4af37); margin: 14px 0 0;
}
.mae-footnotes { margin: 22px 0 8px; padding: 14px; border: 1px solid var(--line, rgba(255,255,255,.12)); border-radius: 12px; font-size: .9rem; }
.mae-footnotes h3 { margin: 0 0 8px; font-size: 1rem; }
.mae-footnotes-body { line-height: 1.8; overflow-wrap: anywhere; color: var(--text-dim, #bfb3a3); }
.mae-footnote-box { margin-top: 10px; }

/* ✂️ [22 ก.ย. 2569] ปุ่มผู้ช่วยแบ่งตอน (ใต้ประเภทงาน) */
.mae-split-cta { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 10px 0;
  padding: 10px 12px; border: 1px solid rgba(212,175,55,.4); border-radius: 12px; background: rgba(212,175,55,.08); font-size: .88rem; }
.mae-split-cta span { flex: 1 1 220px; }

/* 📖 [18 ต.ค. 2569 · เลน A] แถบความคืบหน้าการอ่าน (ใต้แถบเมนู · JS ตั้ง top) + แถบอ่านต่อจากที่ค้าง + เวลาอ่าน */
.mae-read-progress { position: fixed; left: 0; right: 0; top: 0; height: 3px; z-index: 299; pointer-events: none; }
.mae-read-progress > i { display: block; height: 100%; width: 100%; transform-origin: 0 50%; transform: scaleX(0);
  background: linear-gradient(90deg, var(--gold-dim, #8a7128), var(--gold, #d4af37)); }
.mae-read-resume { position: sticky; top: 64px; z-index: 40; display: flex; align-items: center; gap: 8px; margin: 10px 0;
  padding: 8px 10px; border: 1px solid var(--gold-dim, #8a7128); border-radius: 10px; background: var(--surface, #1a1414);
  box-shadow: 0 6px 18px rgba(0, 0, 0, .45); font-size: .9rem; }
.mae-read-resume[hidden] { display: none; }
.mae-read-resume-t { flex: 1; min-width: 0; }
.mae-read-resume .btn-gold { padding: 4px 14px; font-size: .86rem; }
.mae-read-resume-x { background: none; border: 0; color: var(--text-dim, #a1938c); font-size: 1.05rem; cursor: pointer; padding: 2px 6px; }
.mae-readtime { color: var(--gold-soft, #f0d98a); }

/* 📚 [19 ต.ค. 2569 · ซีซั่น] ป้ายซีซั่นบนหน้าอ่าน + แท็บซีซั่นหน้าซีรีส์ */
.mae-season-label { display: inline-block; margin: 0 0 6px; font-size: .9rem; color: var(--gold-soft, #f0d98a); text-decoration: none; }
.mae-season-label small { color: var(--text-dim, #a1938c); }
.mae-season-tabs a { padding: 6px 12px; border-radius: 10px; text-decoration: none; }

/* 🧭 [21 ต.ค. 2569 · แม่บท 5 #3] ช่อง "ผลงานนี้เป็นแบบไหน" ในแผง ราคา / ซีรีส์ */
.mae-kind { display: flex; flex-direction: column; gap: 6px; margin-bottom: 8px; }
.mae-kind-q { margin-bottom: 2px; }
.mae-kind-opt { display: flex; gap: 8px; align-items: flex-start; border: 1px solid rgba(255, 255, 255, .14); border-radius: 10px; padding: 8px 10px; cursor: pointer; }
.mae-kind-opt:has(input:checked) { border-color: var(--gold, #d4af37); background: rgba(212, 175, 55, .08); }
.mae-kind-opt input { margin-top: 4px; }
.mae-kind-opt span { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.mae-kind-opt small { color: #a1938c; font-size: .78rem; }
.mae-kind-eg { opacity: .8; }
.mae-kind-res { border: 1px dashed rgba(255, 255, 255, .18); border-radius: 10px; padding: 8px 10px; font-size: .82rem; }
.mae-kind-res ul { margin: 4px 0 4px 18px; padding: 0; }
.mae-kind-help summary { cursor: pointer; font-size: .85rem; }

/* 🧭 [21 ต.ค. 2569 · แม่บท 5-2] หมวดกลาง — กล่องเลือกรูปแบบ/หมวด/จังหวัด/แฮชแท็ก (composer.php #mae-cc) */
.mae-cc { display: flex; flex-direction: column; gap: 6px; margin: 10px 0; padding: 12px; border: 1px solid var(--line, #2e2323); border-radius: var(--radius-sm, 9px); background: var(--bg-soft, #141010); }
.mae-cc-lbl { font-size: .88rem; margin-top: 4px; }
.mae-cc-req { color: var(--red-soft, #e0434d); }
.mae-cc-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.mae-cc-chip { position: relative; display: inline-flex; cursor: pointer; }
.mae-cc-chip input { position: absolute; opacity: 0; width: 1px; height: 1px; pointer-events: none; }
.mae-cc-chip span { border: 1px solid var(--line, #2e2323); background: var(--surface-2, #221a1a); color: var(--text, #ece5e0); border-radius: 999px; padding: 5px 11px; font-size: .86rem; }
.mae-cc-chip input:checked + span { border-color: var(--gold, #d4af37); color: var(--gold, #d4af37); font-weight: 700; }
.mae-cc-chip input:focus-visible + span { outline: 2px solid var(--gold, #d4af37); outline-offset: 2px; }
.mae-cc-chip.is-off span, .mae-cc.is-locked .mae-cc-chip span { opacity: .4; cursor: not-allowed; }
.mae-cc.is-locked .mae-cc-chip input:checked + span { opacity: 1; }


/* 💎 [23 ต.ค. 2569 · 1.8 C] พรีเมียมอ่านฟรี — ป้ายเหนือเนื้อเรื่อง · ข้อความหมดอายุบนกำแพง · ปุ่มชวนพรีเมียม */
.mae-premium-note{display:flex;gap:.5rem;align-items:center;flex-wrap:wrap;background:rgba(212,175,55,.1);border:1px solid var(--gold-dim);border-radius:10px;padding:.5rem .8rem;margin:.6rem 0;font-size:.92rem}
.mae-premium-lapsed{color:var(--warn);font-size:.9rem;margin:.2rem 0 .5rem}
.mae-premium-join{margin-left:.4rem}
