:root {
    /* โทนสี กปภ. — น้ำเงินองค์กร + น้ำใส */
    --bg: #e9f3fa;
    --card: #ffffff;
    --line: #c5d9eb;
    --text: #0c2d4a;
    --muted: #5a7a94;
    --blue: #0055a5;
    --blue-mid: #0077c8;
    --blue-light: #4aa3d9;
    --dark: #003a70;
    --accent: #00a0e3;
}

* { box-sizing: border-box; }
html { font-size: 16px; }
body {
    margin: 0;
    font-family: "Segoe UI", "Noto Sans Thai", sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 1rem;
    line-height: 1.55;
}

.box { width: min(1180px, 100%); margin: 0 auto; padding: 16px 20px 36px; }

.bar {
    background: linear-gradient(90deg, #002b5c 0%, var(--dark) 45%, #0055a5 100%);
    color: #e8eef6;
}
.bar-in {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding-top: 12px;
    padding-bottom: 12px;
}
.brand { display: flex; gap: 12px; align-items: center; }
.mark {
    width: 44px; height: 44px; border-radius: 12px;
    background: linear-gradient(145deg, var(--accent), var(--blue));
    display: grid; place-items: center;
    font-weight: 800; color: #fff;
    font-size: 14px;
    box-shadow: 0 2px 8px rgba(0, 85, 165, .35);
}
.brand strong { display: block; font-size: 17px; }
.brand small { color: #a8c8e8; font-size: 13px; }
.back {
    color: #fff; text-decoration: none; font-size: 14px; font-weight: 600;
    background: rgba(255,255,255,.12); padding: 8px 14px; border-radius: 8px;
}

.panel {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 18px 20px;
    margin-bottom: 14px;
}
.panel h1 { margin: 0 0 6px; font-size: 26px; }
.panel h2 { margin: 0 0 10px; font-size: 18px; }
.sub { margin: 0 0 12px; color: var(--muted); font-size: 15px; }

/* รูป: แถวบน 1–6 · แถวล่าง 7–9 */
.map {
    position: relative;
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 10px;
    overflow: hidden;
    background: #dceef8;
    line-height: 0;
}
.map img {
    display: block;
    width: 100%;
    height: auto;
}
.spot-layer {
    position: absolute;
    left: 2%;
    right: 2%;
    top: 16%;
    bottom: 3%;
    display: flex;
    flex-direction: column;
    gap: 3%;
}
.spot-row {
    flex: 1;
    min-height: 0;
    display: grid;
    gap: 6px;
}
.spot-row-top {
    /* 5 ช่อง: 1, 2, กวนเร็ว+กวนช้า, 5, 6 */
    box-sizing: border-box;
    margin-left: -2.5%;
    width: calc(100% + 2.5%);
    padding-right: 2.5%;
    grid-template-columns: 1.1fr 1.1fr 2.7fr 1.15fr 1fr;
}
.spot-row-bottom {
    grid-template-columns: repeat(12, minmax(0, 1fr));
}
.spot-row-bottom .spot:nth-child(1) { grid-column: 1 / 4; }  /* 7 เล็กลง */
.spot-row-bottom .spot:nth-child(2) { grid-column: 4 / 7; }  /* 8 เล็กลง */
.spot-row-bottom .spot:nth-child(3) { grid-column: 7 / 13; } /* 9 กว้างขึ้น */

.spot {
    min-width: 0;
    border: 2px solid transparent;
    background: transparent;
    border-radius: 8px;
    text-decoration: none;
}
.spot:hover {
    background: rgba(0, 85, 165, .14);
    border-color: rgba(0, 160, 227, .45);
}

.steps {
    list-style: none;
    margin: 12px 0 0;
    padding: 0;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
}
.steps a {
    display: block;
    text-decoration: none;
    color: inherit;
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 10px;
    background: #f3f9fd;
}
.steps a:hover { border-color: var(--blue-light); background: #e8f4fc; }
.steps b { display: block; font-size: 13px; margin-bottom: 2px; }
.steps span { font-size: 12px; color: var(--muted); }

.note { background: linear-gradient(180deg, #dff0fb, #f5fafd); border-color: #8ec4e8; }
.note p { margin: 0 0 8px; font-size: 14px; }
.note p:last-child { margin-bottom: 0; }
.inline-link {
    color: var(--blue);
    font-weight: 700;
    font-size: 14px;
}
.audience {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-top: 12px;
}
.audience > div {
    background: #fff;
    border: 1px solid #bfdbfe;
    border-radius: 10px;
    padding: 12px;
}
.audience strong { display: block; margin-bottom: 4px; color: var(--dark); }
.audience p { margin: 0; font-size: 13px; color: #334155; }

.panel.goal {
    background: linear-gradient(180deg, #ecfdf5, #fff);
    border-color: #86efac;
}
.eyebrow {
    margin: 0 0 4px;
    font-size: 12px;
    font-weight: 800;
    color: #15803d;
    letter-spacing: .04em;
    text-transform: uppercase;
}
.panel.goal h1 {
    font-size: clamp(18px, 2.4vw, 22px);
    margin: 0 0 8px;
}
.who {
    margin: 0;
    font-size: 14px;
    color: #334155;
}

.panel.howto { border-color: #93c5fd; }
.howto-steps {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    gap: 10px;
}
.howto-steps li {
    display: grid;
    grid-template-columns: 28px 1fr;
    gap: 10px;
    align-items: start;
    background: #f8fbff;
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 10px 12px;
}
.step-no {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--blue);
    color: #fff;
    font-size: 13px;
    font-weight: 800;
    display: grid;
    place-items: center;
}
.step-text { font-size: 14px; padding-top: 3px; }

.panel.check {
    background: #fff7ed;
    border-color: #fdba74;
}

@media (max-width: 720px) {
    .audience { grid-template-columns: 1fr; }
}

.tag {
    display: inline-block;
    font-size: 12px;
    font-weight: 800;
    padding: 3px 8px;
    border-radius: 999px;
    vertical-align: middle;
}
.tag-ois { background: #ffedd5; color: #9a3412; }
.tag-spm { background: #dcfce7; color: #166534; }
.tag-ocs { background: #dbeafe; color: #1d4ed8; }
.tag-ocs-spm { background: #ede9fe; color: #5b21b6; }

.source-box {
    margin-top: 12px;
    border-radius: 10px;
    padding: 12px;
    border: 1px solid var(--line);
}
.source-ois { background: #fff7ed; border-color: #fdba74; }
.source-spm { background: #f0fdf4; border-color: #86efac; }
.source-ocs { background: #eff6ff; border-color: #93c5fd; }
.source-ocs-spm { background: #f5f3ff; border-color: #c4b5fd; }
.source-title {
    font-size: 13px;
    font-weight: 700;
    margin-bottom: 6px;
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}
.source-box p { margin: 0 0 6px; font-size: 14px; }
.source-box p:last-child { margin-bottom: 0; }
.link-note { color: #334155; }

.path {
    background: #eef6fb;
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 12px;
}
.path-label {
    font-size: 12px;
    font-weight: 700;
    color: var(--muted);
    margin-bottom: 6px;
}
.path code {
    display: block;
    font-family: ui-monospace, Consolas, monospace;
    font-size: 14px;
    color: var(--blue);
    white-space: normal;
}

.plain { margin: 0; padding-left: 18px; }
.plain li { margin-bottom: 6px; font-size: 14px; }

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td {
    border-bottom: 1px solid var(--line);
    padding: 9px 8px;
    text-align: left;
    vertical-align: top;
}
th { background: #e4f0f8; font-size: 13px; }
td a { color: var(--blue); font-weight: 600; text-decoration: none; }
td a:hover { text-decoration: underline; }
code {
    font-family: ui-monospace, Consolas, monospace;
    font-size: 12px;
    color: var(--blue);
}

.pager {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    align-items: center;
    margin-top: 4px;
}
.pager a {
    text-decoration: none;
    font-weight: 700;
    font-size: 13px;
    color: #fff;
    background: var(--blue);
    padding: 9px 12px;
    border-radius: 9px;
}
.pager a.ghost { background: #d0e4f2; color: #003a70; }

/* ปุ่มกลับ / ไปหน้า — กะทัดรัด ไม่ยืดเต็มจอ */
.block.block-page-nav {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    padding: 6px 0;
    background: transparent;
    border: none;
    border-radius: 0;
    box-shadow: none;
    width: 100%;
}
.block-page-nav.is-align-start { justify-content: flex-start; }
.block-page-nav.is-align-center { justify-content: center; }
.block-page-nav.is-align-end { justify-content: flex-end; }
.block-page-nav.is-align-between { justify-content: space-between; }
.page-nav-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    width: auto;
    max-width: 100%;
    flex: 0 0 auto;
    text-decoration: none;
    font-weight: 700;
    white-space: nowrap;
    border-radius: 8px;
    border: 1px solid transparent;
    transition: background .12s, border-color .12s, color .12s, transform .12s;
}
.page-nav-link.size-sm {
    font-size: 12px;
    padding: 5px 11px;
    border-radius: 7px;
}
.page-nav-link.size-md {
    font-size: 14px;
    padding: 8px 14px;
}
.page-nav-link.size-lg {
    font-size: 15px;
    padding: 11px 18px;
    border-radius: 10px;
}
.page-nav-link.style-ghost {
    background: #eef5fb;
    color: var(--dark);
    border-color: #c5d9eb;
}
.page-nav-link.style-outline {
    background: #fff;
    color: var(--blue);
    border-color: var(--blue);
}
.page-nav-link.style-solid {
    background: var(--blue);
    color: #fff;
    border-color: var(--blue);
}
.page-nav-link.is-accent.style-ghost {
    background: var(--blue);
    color: #fff;
    border-color: var(--blue);
}
.page-nav-link:hover {
    transform: translateY(-1px);
}
.page-nav-link.style-ghost:hover {
    background: #dceaf6;
    border-color: #8eb6d6;
}
.page-nav-link.style-outline:hover {
    background: #eef6fc;
}
.page-nav-link.style-solid:hover,
.page-nav-link.is-accent.style-ghost:hover {
    background: var(--blue-mid);
    border-color: var(--blue-mid);
}

/* manage: สร้าง/ลบหน้า */
.create-page-form {
    display: grid;
    gap: 10px;
}
.create-page-form label {
    display: block;
    font-size: 13px;
    font-weight: 600;
}
.create-page-form input,
.create-page-form select {
    display: block;
    width: 100%;
    margin-top: 4px;
    padding: 8px 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    font-size: 14px;
    font-weight: 400;
    background: #fff;
}
.manage-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 8px;
}
.manage-filter-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    font-weight: 600;
    margin: 0;
}
.manage-filter-select {
    min-width: 220px;
    padding: 8px 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    font-size: 14px;
    font-weight: 400;
    background: #fff;
}
.manage-toolbar-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}
.manage-cat-btn,
.manage-modal-actions .ghost-btn {
    display: inline-flex;
    align-items: center;
    padding: 8px 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff !important;
    color: #334155 !important;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
}
.manage-cat-btn:hover,
.manage-modal-actions .ghost-btn:hover {
    background: #f1f5f9 !important;
}
.manage-view-hint {
    margin: 0 0 12px;
}
.manage-empty {
    padding: 28px 12px;
    text-align: center;
    color: var(--muted);
    font-size: 14px;
}
.manage-pages-wrap table {
    margin-bottom: 8px;
}
body.manage-modal-open {
    overflow: hidden;
}
.manage-modal {
    position: fixed;
    inset: 0;
    z-index: 80;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}
.manage-modal[hidden] {
    display: none !important;
}
.manage-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.45);
}
.manage-modal-card {
    position: relative;
    z-index: 1;
    width: min(480px, 100%);
    max-height: min(90vh, 720px);
    overflow: auto;
    background: #fff;
    border-radius: 12px;
    border: 1px solid var(--line);
    box-shadow: 0 18px 50px rgba(15, 23, 42, 0.18);
    padding: 18px 18px 16px;
}
.manage-modal-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 12px;
}
.manage-modal-head h2 {
    margin: 0;
    font-size: 18px;
}
.manage-modal-x {
    border: none;
    background: transparent;
    font-size: 24px;
    line-height: 1;
    color: var(--muted);
    cursor: pointer;
    padding: 0 4px;
}
.manage-modal-x:hover { color: #0f172a; }
.manage-modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 4px;
}
.cat-list {
    list-style: none;
    margin: 14px 0 0;
    padding: 0;
    display: grid;
    gap: 8px;
}
.cat-list li {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #f8fafc;
}
.cat-list-main {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 8px 12px;
    min-width: 0;
}
.cat-list-main code {
    font-size: 12px;
    color: var(--muted);
}
.cat-list-actions {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}
.btn-cat-rename,
.btn-cat-delete {
    border: 1px solid var(--line);
    background: #fff;
    color: #334155;
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
}
.btn-cat-rename:hover { background: #f1f5f9; }
.btn-cat-delete {
    border-color: #fecaca;
    background: #fef2f2;
    color: #b91c1c;
}
.btn-cat-delete:hover { background: #fee2e2; }
.cat-heading {
    display: flex;
    align-items: baseline;
    gap: 10px;
    flex-wrap: wrap;
}
.cat-count {
    font-size: 13px;
    font-weight: 600;
    color: var(--muted);
}
.group-heading {
    margin: 16px 0 8px;
    font-size: 15px;
    font-weight: 700;
    color: #334155;
}
.manage-pages-wrap .group-heading:first-child {
    margin-top: 4px;
}
.page-cat-select {
    max-width: 220px;
    padding: 4px 8px;
    border: 1px solid var(--line);
    border-radius: 6px;
    font-size: 13px;
    background: #fff;
}
.btn-create {
    justify-self: start;
    padding: 10px 16px;
    border: none;
    border-radius: 8px;
    background: var(--blue);
    color: #fff;
    font-weight: 700;
    cursor: pointer;
}
.btn-create:hover { background: var(--blue-mid); }
.row-actions {
    display: flex;
    gap: 10px;
    align-items: center;
    white-space: nowrap;
}
.btn-delete {
    border: 1px solid #fecaca;
    background: #fef2f2;
    color: #b91c1c;
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
}
.btn-delete:hover { background: #fee2e2; }
.btn-duplicate {
    border: 1px solid #bfdbfe;
    background: #eff6ff;
    color: #1d4ed8;
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
}
.btn-duplicate:hover { background: #dbeafe; }
.muted-lock {
    font-size: 12px;
    color: var(--muted);
}

@media (max-width: 720px) {
    .steps { grid-template-columns: 1fr 1fr; }
    .spot span { font-size: 9px; padding: 2px 4px; }
}
@media (max-width: 480px) {
    .steps { grid-template-columns: 1fr; }
}

/* Page view blocks */
.bar-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }

.auth-nav {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-left: 4px;
    padding-left: 10px;
    border-left: 1px solid rgba(15, 45, 74, .14);
    max-width: min(280px, 46vw);
}
.auth-nav-name {
    font-size: 13px;
    font-weight: 700;
    color: #0f2d4a;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 160px;
}
.auth-nav-relogin {
    font-size: 12px;
    font-weight: 600;
    color: #1a5fb4;
    text-decoration: none;
    white-space: nowrap;
}
.auth-nav-relogin:hover { text-decoration: underline; }
a.auth-nav-login {
    display: inline-flex;
    align-items: center;
    padding: 7px 14px;
    border-radius: 8px;
    border: 1px solid #1a5fb4;
    background: #1a5fb4;
    color: #fff !important;
    font-size: 13px;
    font-weight: 700;
    text-decoration: none;
    white-space: nowrap;
}
a.auth-nav-login:hover {
    background: #154a8f;
    border-color: #154a8f;
}
.ghost-btn { background: rgba(255,255,255,.12) !important; }
.edit-btn { background: var(--blue-mid) !important; }

.page-view .blocks {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    gap: 14px;
    align-items: flex-start;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 18px 20px;
}
.page-view .block {
    background: transparent;
    border: none;
    border-radius: 0;
    padding: 0;
    box-shadow: none;
    flex: 1 1 100%;
    max-width: 100%;
    min-width: 0;
}
/* บล็อกปุ่มที่ติดกัน ให้อยู่แถวเดียวกันแบบชิดกลุ่ม (ไม่ยืดแบ่งครึ่งจนมีช่องว่างใหญ่) */
.page-view .blocks > .block-buttons {
    flex: 0 0 auto;
    width: auto;
    max-width: 100%;
}
.page-view .blocks > .block-buttons .nav-buttons {
    width: auto;
    max-width: 100%;
}
/* หลายปุ่มในบล็อกเดียว / เรียงแนวตั้ง / ปุ่มใหญ่เต็มแถว → กว้างเต็มแถว */
.page-view .blocks > .block-buttons:has(.nav-btn ~ .nav-btn),
.page-view .blocks > .block-buttons:has([data-layout="stack"]),
.page-view .blocks > .block-buttons:has(.nav-buttons-stack),
.page-view .blocks > .block-buttons:has([data-size="lg"]),
.page-view .blocks > .block-buttons:has(.size-lg) {
    flex: 1 1 100%;
}
.page-view .blocks > .block-buttons:has(.nav-btn ~ .nav-btn) .nav-buttons,
.page-view .blocks > .block-buttons:has([data-layout="stack"]) .nav-buttons,
.page-view .blocks > .block-buttons:has(.nav-buttons-stack) .nav-buttons,
.page-view .blocks > .block-buttons:has([data-size="lg"]) .nav-buttons,
.page-view .blocks > .block-buttons:has(.size-lg) .nav-buttons {
    width: 100%;
}
/* ชิดขวา: ดันกลุ่มไปขวา — ปุ่มถัดไปที่ชิดขวาเหมือนกันให้ติดกัน (ไม่เว้นครึ่งจอ) */
.page-view .blocks > .block-buttons:has(.nav-buttons.is-align-end) {
    margin-left: auto;
}
.page-view .blocks > .block-buttons:has(.nav-buttons.is-align-end) + .block-buttons:has(.nav-buttons.is-align-end) {
    margin-left: 0;
}
/* กึ่งกลาง: จัดกลุ่มตรงกลาง */
.page-view .blocks > .block-buttons:has(.nav-buttons.is-align-center) {
    margin-left: auto;
    margin-right: 0;
}
.page-view .blocks > .block-buttons:has(.nav-buttons.is-align-center) + .block-buttons:has(.nav-buttons.is-align-center) {
    margin-left: 0;
}
.page-view .blocks > .block-buttons:has(.nav-buttons.is-align-center):not(:has(+ .block-buttons:has(.nav-buttons.is-align-center))) {
    margin-right: auto;
}
/* ซ้าย+ขวา คนละบล็อก: ปุ่มขวาถูกดันด้วย margin-left:auto ด้านบนอยู่แล้ว */
.block-heading h1, .block-heading h2, .block-heading h3 { margin: 0; line-height: 1.35; }
.block-heading h1 { font-size: 1.75rem; }
.block-heading h2 { font-size: 1.4rem; }
.block-heading h3 { font-size: 1.2rem; }
.block-text .rich-text { font-size: 1.05rem; line-height: 1.7; }
.rich-text i, .rich-text em { font-style: italic; }
.rich-text b, .rich-text strong { font-weight: 700; }
/* contenteditable มักห่อบรรทัดด้วย div — อย่าใส่ margin ท้าย ทำให้ระยะไม่เท่ากัน */
.rich-text,
.rich-text-col {
    font-size: 1.05rem;
    line-height: 1.7;
}
.rich-text [style*="font-size"],
.rich-text-col [style*="font-size"] {
    line-height: 1.35;
}
.rich-text p,
.rich-text > div,
.rich-text-col p,
.rich-text-col > div {
    margin-top: 0;
    margin-right: 0;
    margin-bottom: 0;
    /* ไม่รีเซ็ต margin-left — คงย่อหน้าจาก editor */
    padding-top: 0;
    padding-right: 0;
    padding-bottom: 0;
    line-height: inherit;
    min-height: 1.7em;
}
.rich-text [data-indent="1"],
.rich-text-col [data-indent="1"] { text-indent: 24px !important; padding-left: 0 !important; margin-left: 0 !important; }
.rich-text [data-indent="2"],
.rich-text-col [data-indent="2"] { text-indent: 48px !important; padding-left: 0 !important; margin-left: 0 !important; }
.rich-text [data-indent="3"],
.rich-text-col [data-indent="3"] { text-indent: 72px !important; padding-left: 0 !important; margin-left: 0 !important; }
.rich-text [data-indent="4"],
.rich-text-col [data-indent="4"] { text-indent: 96px !important; padding-left: 0 !important; margin-left: 0 !important; }
.rich-text [data-indent="5"],
.rich-text-col [data-indent="5"] { text-indent: 120px !important; padding-left: 0 !important; margin-left: 0 !important; }
.rich-text [data-indent="6"],
.rich-text-col [data-indent="6"] { text-indent: 144px !important; padding-left: 0 !important; margin-left: 0 !important; }
.rich-text [data-indent="7"],
.rich-text-col [data-indent="7"] { text-indent: 168px !important; padding-left: 0 !important; margin-left: 0 !important; }
.rich-text [data-indent="8"],
.rich-text-col [data-indent="8"] { text-indent: 192px !important; padding-left: 0 !important; margin-left: 0 !important; }
.rich-text [data-indent="9"],
.rich-text-col [data-indent="9"] { text-indent: 216px !important; padding-left: 0 !important; margin-left: 0 !important; }
.rich-text [data-indent="10"],
.rich-text-col [data-indent="10"] { text-indent: 240px !important; padding-left: 0 !important; margin-left: 0 !important; }
.rich-text [data-lh="1.15"],
.rich-text-col [data-lh="1.15"] { line-height: 1.15 !important; }
.rich-text [data-lh="1.35"],
.rich-text-col [data-lh="1.35"] { line-height: 1.35 !important; }
.rich-text [data-lh="1.5"],
.rich-text-col [data-lh="1.5"] { line-height: 1.5 !important; }
.rich-text [data-lh="1.7"],
.rich-text-col [data-lh="1.7"] { line-height: 1.7 !important; }
.rich-text [data-lh="2"],
.rich-text-col [data-lh="2"] { line-height: 2 !important; }
.rich-text [data-lh="2.5"],
.rich-text-col [data-lh="2.5"] { line-height: 2.5 !important; }
.rich-text [data-space="0"],
.rich-text-col [data-space="0"] { margin-bottom: 0 !important; }
.rich-text [data-space="8"],
.rich-text-col [data-space="8"] { margin-bottom: 8px !important; }
.rich-text [data-space="12"],
.rich-text-col [data-space="12"] { margin-bottom: 12px !important; }
.rich-text [data-space="16"],
.rich-text-col [data-space="16"] { margin-bottom: 16px !important; }
.rich-text [data-space="24"],
.rich-text-col [data-space="24"] { margin-bottom: 24px !important; }
.rich-text [data-space="32"],
.rich-text-col [data-space="32"] { margin-bottom: 32px !important; }
.rich-text [data-align="left"],
.rich-text [style*="text-align:left"],
.rich-text [style*="text-align: left"],
.rich-text [align="left"],
.rich-text-col [data-align="left"],
.rich-text-col [style*="text-align:left"],
.rich-text-col [style*="text-align: left"],
.rich-text-col [align="left"],
.text-col [data-align="left"],
.text-col [style*="text-align:left"],
.text-col [style*="text-align: left"] {
    text-align: left !important;
}
.rich-text [data-align="center"],
.rich-text [style*="text-align:center"],
.rich-text [style*="text-align: center"],
.rich-text [align="center"],
.rich-text-col [data-align="center"],
.rich-text-col [style*="text-align:center"],
.rich-text-col [style*="text-align: center"],
.rich-text-col [align="center"],
.text-col [data-align="center"],
.text-col [style*="text-align:center"],
.text-col [style*="text-align: center"] {
    text-align: center !important;
    text-indent: 0 !important;
}
.rich-text [data-align="right"],
.rich-text [style*="text-align:right"],
.rich-text [style*="text-align: right"],
.rich-text [align="right"],
.rich-text-col [data-align="right"],
.rich-text-col [style*="text-align:right"],
.rich-text-col [style*="text-align: right"],
.rich-text-col [align="right"],
.text-col [data-align="right"],
.text-col [style*="text-align:right"],
.text-col [style*="text-align: right"] {
    text-align: right !important;
    text-indent: 0 !important;
}
.rich-text [data-align="justify"],
.rich-text [style*="text-align:justify"],
.rich-text [style*="text-align: justify"],
.rich-text [align="justify"],
.rich-text-col [data-align="justify"],
.rich-text-col [style*="text-align:justify"],
.rich-text-col [style*="text-align: justify"],
.rich-text-col [align="justify"],
.text-col [data-align="justify"],
.text-col [style*="text-align:justify"],
.text-col [style*="text-align: justify"] {
    text-align: justify !important;
    text-justify: inter-character;
}
.rich-text p + p,
.rich-text-col p + p {
    margin-top: 0.55em;
}
.rich-text-cols {
    display: grid;
    gap: 12px 18px;
    align-items: start;
}
.rich-text-cols.cols-2 { grid-template-columns: 1fr 1fr; }
.rich-text-cols.cols-3 { grid-template-columns: 1fr 1fr 1fr; }
.rich-text-col {
    min-width: 0;
}
.compare-text,
.compare-text .rich-text,
.block-media-text .text-col,
.block-media-text .text-col .rich-text,
.block-heading .rich-text {
    font-size: 1.05rem;
    line-height: 1.7;
}
@media (max-width: 720px) {
    .rich-text-cols.cols-2,
    .rich-text-cols.cols-3 {
        grid-template-columns: 1fr;
    }
}

.hotspot-trigger {
    color: #0f3f66;
    font-weight: 700;
    cursor: pointer;
    border-bottom: 2px dotted #7eb6d9;
    background: rgba(0, 160, 227, .08);
    padding: 0 2px;
    border-radius: 3px;
    text-decoration: none;
    display: inline;
    white-space: normal;
    vertical-align: baseline;
}
.rich-text a:not(.hotspot-trigger),
.text-col a:not(.hotspot-trigger),
.compare-text a:not(.hotspot-trigger) {
    color: var(--blue);
    font-weight: 700;
    text-decoration: none;
    border-bottom: 2px solid rgba(0, 160, 227, .45);
    display: inline;
    vertical-align: baseline;
}
.rich-text a:not(.hotspot-trigger):hover,
.text-col a:not(.hotspot-trigger):hover,
.compare-text a:not(.hotspot-trigger):hover {
    border-bottom-color: var(--accent);
    background: rgba(0, 160, 227, .08);
}
.page-anchor {
    scroll-margin-top: 88px;
}
.page-jump-link {
    color: var(--blue);
    font-weight: 700;
    text-decoration: none;
    border-bottom: 2px solid rgba(0, 160, 227, .45);
}
.page-jump-link:hover {
    border-bottom-color: var(--accent);
    background: rgba(0, 160, 227, .08);
}
.page-jump-flash {
    animation: page-jump-flash 1.6s ease;
    outline: 3px solid #f59e0b !important;
    outline-offset: 3px;
    box-shadow: 0 0 0 6px rgba(245, 158, 11, .28) !important;
    z-index: 5;
    position: relative;
}
@keyframes page-jump-flash {
    0%, 100% { background-color: transparent; }
    20%, 50% { background-color: rgba(245, 158, 11, .35); }
}
.block[id],
.block-page-nav[id] {
    scroll-margin-top: 88px;
}
a.hotspot-trigger {
    color: var(--blue);
    cursor: pointer;
    border-bottom: 2px solid var(--accent);
    background: rgba(0, 160, 227, .12);
}
a.hotspot-trigger:hover {
    background: rgba(0, 160, 227, .22);
}
span.hotspot-trigger::after {
    content: none;
}
.switch-trigger {
    background: #e8f4fc;
    border: 1px solid #8ec4e8;
    color: var(--blue);
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 6px;
    cursor: pointer;
    font-size: inherit;
}
.switch-trigger:hover { background: #d0e8f7; }

.block-image, .block-image-switcher { text-align: center; }
.block-image.align-left { text-align: left; }
.block-image.align-center { text-align: center; }
.block-image.align-right { text-align: right; }
.block-image-dual { text-align: left; }
.block-compare .compare-grid,
.block-image-dual .compare-grid,
.compare-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 12px;
    align-items: start;
    width: 100%;
}
.compare-side {
    margin: 0;
    text-align: center;
    min-width: 0;
    max-width: 100%;
}
.compare-side .compare-img-wrap {
    display: block;
    box-sizing: border-box;
    width: 100%;
    max-width: 100%;
    margin-left: auto;
    margin-right: auto;
    vertical-align: top;
}
.rich-text .inline-guide-table {
    width: 100%;
    border-collapse: collapse;
    margin: 10px 0;
    font-size: 14px;
}
.rich-text .inline-guide-table th,
.rich-text .inline-guide-table td {
    border: 1px solid var(--line);
    padding: 8px 10px;
    text-align: left;
}
.rich-text .inline-guide-table th {
    background: #eef6fc;
    font-weight: 700;
}
.image-wrap {
    display: inline-block;
    box-sizing: border-box;
    max-width: 100%;
    margin: 0 auto;
    vertical-align: top;
}
.image-stage {
    position: relative;
    display: block;
    width: 100%;
    max-width: 100%;
    line-height: 0;
    /* พื้นหลังลายตารางอ่อน — รูปพื้นขาวไม่กลืนกับจอ */
    background-color: #f1f5f9;
    background-image:
        linear-gradient(45deg, #e2e8f0 25%, transparent 25%),
        linear-gradient(-45deg, #e2e8f0 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, #e2e8f0 75%),
        linear-gradient(-45deg, transparent 75%, #e2e8f0 75%);
    background-size: 16px 16px;
    background-position: 0 0, 0 8px, 8px -8px, -8px 0;
    border-radius: 8px;
    box-shadow: 0 0 0 1px rgba(15, 45, 74, .18), 0 1px 3px rgba(15, 45, 74, .08);
    overflow: hidden;
}
.image-stage img {
    display: block;
    width: 100%;
    max-width: 100%;
    height: auto;
    border-radius: 8px;
    border: 1px solid rgba(15, 45, 74, .28);
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .35);
    background: transparent;
}
.frame-layer { position: absolute; inset: 0; pointer-events: none; }
.block-image-map .frame-layer.is-menu-layer {
    pointer-events: none;
}
.block-image-map .hotspot-frame.is-menu-frame {
    pointer-events: auto;
    border-color: var(--frame-border, #f59e0b);
    box-shadow: 0 0 0 2px var(--frame-glow, rgba(245, 158, 11, .28));
    cursor: default;
}
.block-image-map .hotspot-frame.is-menu-frame.is-clickable {
    cursor: pointer;
}
.block-image-map .hotspot-frame.is-menu-frame.is-clickable:hover,
.block-image-map .hotspot-frame.is-menu-frame.active {
    background: var(--frame-fill, rgba(245, 158, 11, .25));
    box-shadow: 0 0 0 3px var(--frame-glow, rgba(245, 158, 11, .35));
}
.hotspot-frame-label {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    max-width: 92%;
    padding: 2px 6px;
    border-radius: 4px;
    background: rgba(15, 23, 42, .72);
    color: #fff;
    font-size: 12px;
    font-weight: 700;
    line-height: 1.25;
    text-align: center;
    pointer-events: none;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
a.hotspot-frame {
    display: block;
    text-decoration: none;
    color: inherit;
    box-sizing: border-box;
}
.hotspot-frame {
    position: absolute;
    border: 2px solid transparent;
    border-radius: 4px;
    background: transparent;
    transition: border-color .15s, background .15s, box-shadow .15s;
    pointer-events: auto;
    cursor: pointer;
}
.hotspot-frame.is-clickable { cursor: pointer; }
.block-compare .hotspot-frame { cursor: crosshair; }
.block-compare .hotspot-frame.is-clickable { cursor: pointer; }
/* โชว์ตลอดเวลา — เห็นกรอบเบาๆ ตลอด · ชี้/active = ไฮไลท์แรงขึ้น */
.hotspot-frame.is-always-visible {
    border-color: var(--frame-border, #f59e0b);
    box-shadow: 0 0 0 1px var(--frame-glow, rgba(245, 158, 11, .18));
}
.hotspot-frame.is-always-visible[data-fill-mode="fill"] {
    background: var(--frame-fill, rgba(245, 158, 11, .12));
}
.hotspot-frame.active {
    border-color: var(--frame-border, #f59e0b);
    box-shadow: 0 0 0 3px var(--frame-glow, rgba(245, 158, 11, .3));
}
.hotspot-frame.is-always-visible.active {
    box-shadow: 0 0 0 4px var(--frame-glow, rgba(245, 158, 11, .42));
}
.hotspot-frame:hover:not(.active) {
    border-color: var(--frame-border, #f59e0b);
    box-shadow: 0 0 0 2px var(--frame-glow, rgba(245, 158, 11, .22));
}
.hotspot-frame.is-always-visible:hover:not(.active) {
    box-shadow: 0 0 0 3px var(--frame-glow, rgba(245, 158, 11, .32));
}
.hotspot-frame:hover:not(.active)[data-fill-mode="fill"] {
    background: var(--frame-fill, rgba(245, 158, 11, .18));
}
.hotspot-frame.active[data-fill-mode="fill"] {
    background: var(--frame-fill, rgba(245, 158, 11, .25));
}
.hotspot-frame.is-always-visible.active[data-fill-mode="fill"] {
    background: var(--frame-fill, rgba(245, 158, 11, .36));
}
.hotspot-frame.active[data-fill-mode="clear"] {
    background: transparent;
}
.img-caption { margin: 8px 0 0; font-size: 13px; color: var(--muted); }

.switcher-tabs {
    display: flex;
    gap: 6px;
    justify-content: center;
    flex-wrap: wrap;
    margin-top: 10px;
}
.switcher-tab {
    padding: 7px 14px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: #f8fbff;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
}
.switcher-tab.active, .switcher-tab:hover {
    background: var(--blue);
    color: #fff;
    border-color: var(--blue);
}

.compare-side .image-stage {
    position: relative;
    display: block;
    width: 100%;
    max-width: 100%;
    line-height: 0;
}
.compare-side img {
    display: block;
    width: 100%;
    max-width: 100%;
    height: auto;
    border-radius: 8px;
    border: 1px solid rgba(15, 45, 74, .28);
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .35);
    background: transparent;
}
.compare-placeholder {
    display: grid;
    place-items: center;
    min-height: 120px;
    border: 1px dashed var(--line);
    border-radius: 8px;
    color: var(--muted);
    font-size: 13px;
    background: #f8fbff;
}
.compare-side figcaption {
    margin-top: 6px;
    font-size: 13px;
    font-weight: 700;
    text-align: center;
    color: var(--muted);
}
.block-compare .compare-text {
    margin-top: 16px;
    font-size: 1.05rem;
    line-height: 1.7;
}
.block-compare .compare-text p,
.block-compare .compare-text > .rich-text > div,
.block-compare .compare-text .rich-text-col > div {
    margin-top: 0;
    margin-right: 0;
    margin-bottom: 0;
    /* คง margin-left สำหรับย่อหน้า */
    line-height: inherit;
}

.block-table h3 { margin: 0 0 10px; font-size: 15px; }
.table-wrap { overflow: auto; }

.empty-page { text-align: center; padding: 40px 20px; }
.empty-page h1 { margin-bottom: 8px; }
.empty-page a { color: var(--blue); font-weight: 700; }

/* ปุ่มนำทาง (บล็อก buttons) */
.page-view .block-buttons { padding: 0; }
.block-buttons { padding: 14px 16px; }
.buttons-title {
    margin: 0 0 12px;
    font-size: 18px;
    text-align: center;
}
.block-buttons .nav-buttons,
.nav-buttons {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    width: 100%;
}
/* เรียงต่อกัน = แถวเดียวแนวนอน */
.block-buttons .nav-buttons[data-layout="wrap"],
.block-buttons .nav-buttons-wrap,
.nav-buttons[data-layout="wrap"],
.nav-buttons-wrap {
    display: flex !important;
    flex-direction: row !important;
    flex-wrap: nowrap !important;
    align-items: center !important;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 2px;
}
.nav-buttons.is-align-start { justify-content: flex-start; }
.nav-buttons.is-align-center { justify-content: center; }
.nav-buttons.is-align-end { justify-content: flex-end; }
/* เรียงแนวตั้ง */
.block-buttons .nav-buttons[data-layout="stack"],
.block-buttons .nav-buttons-stack,
.nav-buttons[data-layout="stack"],
.nav-buttons-stack {
    display: flex !important;
    flex-direction: column !important;
    flex-wrap: nowrap !important;
    align-items: stretch !important;
    overflow-x: visible;
}
.nav-buttons-stack.is-align-start,
.nav-buttons[data-layout="stack"].is-align-start { align-items: flex-start !important; }
.nav-buttons-stack.is-align-center,
.nav-buttons[data-layout="stack"].is-align-center { align-items: center !important; }
.nav-buttons-stack.is-align-end,
.nav-buttons[data-layout="stack"].is-align-end { align-items: flex-end !important; }

.block-buttons .nav-btn,
.nav-btn {
    display: inline-flex !important;
    flex-direction: row !important;
    align-items: center;
    gap: 10px;
    width: auto !important;
    max-width: none;
    flex: 0 0 auto !important;
    text-decoration: none;
    padding: 10px 14px;
    border-radius: 10px;
    border: 2px solid transparent;
    transition: transform .12s, box-shadow .12s, background .12s;
    box-sizing: border-box;
    vertical-align: middle;
}
.nav-buttons-wrap .nav-btn,
.nav-buttons[data-layout="wrap"] .nav-btn {
    white-space: nowrap;
    width: auto !important;
    max-width: none !important;
    flex: 0 0 auto !important;
}
.nav-buttons.size-sm .nav-btn,
.nav-buttons[data-size="sm"] .nav-btn {
    gap: 6px;
    padding: 5px 11px;
    border-radius: 7px;
    border-width: 1px;
}
.nav-buttons.size-md .nav-btn,
.nav-buttons[data-size="md"] .nav-btn {
    padding: 8px 14px;
}
/* ปุ่มใหญ่ = เต็มแถวเสมอ (ไม่ว่าเรียงต่อกันหรือแนวตั้ง) */
.block-buttons .nav-buttons.size-lg,
.block-buttons .nav-buttons[data-size="lg"],
.block-buttons .nav-buttons-wrap.size-lg,
.block-buttons .nav-buttons[data-layout="wrap"][data-size="lg"],
.nav-buttons.size-lg,
.nav-buttons[data-size="lg"] {
    display: flex !important;
    flex-direction: column !important;
    flex-wrap: nowrap !important;
    align-items: stretch !important;
    overflow-x: visible;
    width: 100%;
}
.block-buttons .nav-buttons.size-lg .nav-btn,
.block-buttons .nav-buttons[data-size="lg"] .nav-btn,
.nav-buttons.size-lg .nav-btn,
.nav-buttons[data-size="lg"] .nav-btn,
.nav-buttons-wrap.size-lg .nav-btn,
.nav-buttons[data-layout="wrap"][data-size="lg"] .nav-btn,
.nav-buttons-stack.size-lg .nav-btn,
.nav-buttons[data-layout="stack"][data-size="lg"] .nav-btn {
    display: flex !important;
    flex-direction: row !important;
    align-items: center;
    width: 100% !important;
    max-width: 100% !important;
    flex: 0 0 auto !important;
    white-space: normal;
    padding: 16px 18px;
    border-radius: 12px;
    gap: 12px;
}
.nav-buttons.size-lg .nav-btn .nav-btn-body,
.nav-buttons[data-size="lg"] .nav-btn .nav-btn-body {
    flex: 1 1 auto;
    min-width: 0;
}
.nav-btn.has-arrow-right .nav-btn-arrow {
    margin-left: auto;
}
.nav-btn.has-arrow-left .nav-btn-arrow {
    margin-right: 0;
}
.nav-btn.has-arrow-none .nav-btn-arrow {
    display: none;
}
.nav-buttons-stack.size-sm .nav-btn,
.nav-buttons-stack.size-md .nav-btn,
.nav-buttons[data-layout="stack"][data-size="sm"] .nav-btn,
.nav-buttons[data-layout="stack"][data-size="md"] .nav-btn {
    width: auto !important;
}
.nav-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 18px rgba(0, 85, 165, .18);
}
.nav-btn-primary {
    background: linear-gradient(135deg, #0055a5, #0077c8);
    color: #fff;
}
.nav-btn-secondary {
    background: #e8f4fc;
    color: #003a70;
    border-color: #8ec4e8;
}
.nav-btn-outline {
    background: #fff;
    color: #0055a5;
    border-color: #0055a5;
}
.nav-btn-num {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    font-weight: 800;
    font-size: 13px;
    background: rgba(255,255,255,.2);
    flex: 0 0 auto;
}
.nav-buttons.size-sm .nav-btn-num {
    width: 22px;
    height: 22px;
    font-size: 11px;
}
.nav-buttons.size-lg .nav-btn-num {
    width: 40px;
    height: 40px;
    font-size: 16px;
}
.nav-btn-secondary .nav-btn-num,
.nav-btn-outline .nav-btn-num {
    background: #0055a5;
    color: #fff;
}
.nav-btn-body { text-align: left; min-width: 0; }
.nav-btn-body strong {
    display: block;
    font-size: 14px;
    line-height: 1.3;
}
.nav-buttons.size-sm .nav-btn-body strong { font-size: 12px; }
.nav-buttons.size-lg .nav-btn-body strong { font-size: 16px; }
.nav-btn-body small {
    display: block;
    margin-top: 3px;
    font-size: 13px;
    opacity: .85;
    font-weight: 400;
}
.nav-buttons.size-sm .nav-btn-body small,
.nav-buttons.size-md .nav-btn-body small { display: none; }
.nav-btn-arrow { font-size: 16px; opacity: .8; flex: 0 0 auto; }
.nav-buttons.size-sm .nav-btn-arrow { font-size: 13px; }
.nav-buttons.size-lg .nav-btn-arrow { font-size: 20px; }

/* รูป + ข้อความ */
.block-media-text {
    display: flex;
    flex-wrap: wrap;
    gap: 16px 20px;
    align-items: flex-start;
}
.block-media-text.layout-split-left,
.block-media-text.layout-split-right {
    flex-wrap: nowrap;
}
.block-media-text.layout-split-left .media-col {
    flex: 0 0 var(--img-col, 45%);
    width: var(--img-col, 45%);
    max-width: var(--img-col, 45%);
}
.block-media-text.layout-split-left .text-col {
    flex: 1 1 0;
    min-width: 0;
}
.block-media-text.layout-split-right {
    flex-direction: row-reverse;
}
.block-media-text.layout-split-right .media-col {
    flex: 0 0 var(--img-col, 45%);
    width: var(--img-col, 45%);
    max-width: var(--img-col, 45%);
}
.block-media-text.layout-split-right .text-col {
    flex: 1 1 0;
    min-width: 0;
}
.block-media-text.layout-stack {
    display: flex;
    flex-direction: column;
    flex-wrap: nowrap;
    align-items: stretch;
}
.block-media-text.layout-stack .media-col,
.block-media-text.layout-stack .text-col {
    flex: 0 0 auto;
    width: 100%;
    max-width: 100%;
}
.block-media-text.layout-stack .image-wrap {
    margin: 0 auto;
}
.block-media-text .media-col {
    min-width: 0;
    max-width: 100%;
    overflow: hidden;
}
.block-media-text .text-col {
    min-width: 0;
    font-size: 1.05rem;
    line-height: 1.7;
}
.block-media-text .image-wrap {
    display: block;
    box-sizing: border-box;
    width: var(--img-size, 100%);
    max-width: 100%;
    min-width: 0;
    margin-left: auto;
    margin-right: auto;
}
.block-media-text .image-stage {
    width: 100%;
    max-width: 100%;
}
.block-media-text .image-stage img {
    display: block;
    width: 100%;
    max-width: 100%;
    height: auto;
}

@media (max-width: 640px) {
    .block-compare .compare-grid,
    .block-image-dual .compare-grid,
    .compare-grid {
        grid-template-columns: 1fr;
    }
    .block-media-text.layout-split-left,
    .block-media-text.layout-split-right {
        flex-wrap: wrap;
        flex-direction: column;
    }
    .block-media-text.layout-split-left .media-col,
    .block-media-text.layout-split-right .media-col,
    .block-media-text.layout-split-left .text-col,
    .block-media-text.layout-split-right .text-col {
        flex: 1 1 100%;
        width: 100%;
        max-width: 100%;
    }
}

/* คลิกรูป → ดูใหญ่ + ซูม */
.blocks .image-stage img.is-zoomable,
.blocks .compare-side img.is-zoomable {
    cursor: zoom-in;
}
.blocks .image-stage img.is-zoomable:hover,
.blocks .compare-side img.is-zoomable:hover {
    outline: 2px solid rgba(0, 119, 200, .45);
    outline-offset: 2px;
}
body.img-lightbox-open { overflow: hidden; }
.img-lightbox {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 12px;
}
.img-lightbox[hidden] { display: none !important; }
.img-lightbox-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(8, 20, 36, .82);
}
.img-lightbox-panel {
    position: relative;
    z-index: 1;
    width: min(1100px, 100%);
    height: min(90vh, 900px);
    display: flex;
    flex-direction: column;
    background: #0b1c2c;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, .12);
    box-shadow: 0 20px 60px rgba(0, 0, 0, .45);
    overflow: hidden;
    min-height: 0;
}
.img-lightbox-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    padding: 10px 12px;
    background: rgba(255, 255, 255, .06);
    border-bottom: 1px solid rgba(255, 255, 255, .1);
}
.img-lb-btn {
    min-width: 40px;
    height: 36px;
    padding: 0 12px;
    border: 1px solid rgba(255, 255, 255, .2);
    border-radius: 8px;
    background: rgba(255, 255, 255, .1);
    color: #fff;
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
}
.img-lb-btn:hover { background: rgba(255, 255, 255, .2); }
.img-lb-close { margin-left: auto; background: #b91c1c; border-color: #dc2626; }
.img-lb-zoom-label {
    min-width: 56px;
    text-align: center;
    color: #e2e8f0;
    font-size: 13px;
    font-weight: 700;
}
.img-lightbox-stage {
    flex: 1;
    min-height: 0;
    position: relative;
    overflow: hidden;
    cursor: default;
    touch-action: none;
    background:
        radial-gradient(circle at 30% 20%, rgba(0, 119, 200, .15), transparent 50%),
        #07131f;
}
.img-lightbox-stage.is-pannable { cursor: grab; }
.img-lightbox-stage.is-zoomed { cursor: grab; }
.img-lightbox-stage.is-dragging { cursor: grabbing; }
.img-lightbox-img {
    position: absolute;
    left: 50%;
    top: 50%;
    max-width: none;
    max-height: none;
    width: auto;
    height: auto;
    object-fit: contain;
    transform-origin: center center;
    user-select: none;
    -webkit-user-drag: none;
}
.img-lightbox-hint {
    margin: 0;
    padding: 8px 12px;
    font-size: 12px;
    color: rgba(226, 232, 240, .75);
    text-align: center;
    border-top: 1px solid rgba(255, 255, 255, .08);
}
@media (max-width: 640px) {
    .img-lightbox-panel { height: 85vh; }
    .img-lightbox-hint { font-size: 11px; }
}

/* ========== App shell + left navbar ========== */
body.has-sidebar { background: var(--bg); }
.app-shell {
    display: flex;
    min-height: 100vh;
    align-items: stretch;
}
.app-sidebar {
    width: 260px;
    flex-shrink: 0;
    background: linear-gradient(180deg, #002b5c 0%, #003a70 55%, #0055a5 100%);
    color: #e8eef6;
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    z-index: 40;
    overflow: hidden;
    transition: width .22s ease, min-width .22s ease, margin .22s ease, opacity .18s ease;
}
body.sidebar-collapsed .app-sidebar {
    width: 0;
    min-width: 0;
    margin: 0;
    opacity: 0;
    pointer-events: none;
    border: none;
}
.side-brand {
    display: flex;
    gap: 10px;
    align-items: center;
    padding: 16px 14px 12px;
    border-bottom: 1px solid rgba(255,255,255,.12);
}
.side-brand-text { flex: 1; min-width: 0; }
.side-brand strong { display: block; font-size: 15px; }
.side-brand small { color: #a8c8e8; font-size: 12px; }
.side-collapse {
    width: 32px;
    height: 32px;
    border: none;
    border-radius: 8px;
    background: rgba(255,255,255,.12);
    color: #fff;
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    flex-shrink: 0;
    line-height: 1;
}
.side-collapse:hover { background: rgba(255,255,255,.22); }
.side-scroll {
    flex: 1;
    overflow: auto;
    padding: 10px 8px 16px;
}
.side-nav, .side-sub {
    list-style: none;
    margin: 0;
    padding: 0;
}
.side-sub {
    display: none;
    padding-left: 10px;
    margin: 2px 0 6px;
    border-left: 2px solid rgba(255,255,255,.18);
    margin-left: 10px;
}
.side-item.is-open > .side-sub { display: block; }
.side-row {
    display: flex;
    align-items: center;
    gap: 2px;
}
.side-link {
    flex: 1;
    text-align: left;
    color: #e8eef6;
    text-decoration: none;
    font-size: 14px;
    font-weight: 600;
    padding: 8px 10px;
    border-radius: 8px;
    border: none;
    background: transparent;
    cursor: pointer;
    font-family: inherit;
}
.side-link:hover { background: rgba(255,255,255,.1); }
.side-link.current {
    background: rgba(0, 160, 227, .35);
    box-shadow: inset 0 0 0 1px rgba(255,255,255,.2);
}
.side-caret {
    width: 28px;
    height: 28px;
    border: none;
    border-radius: 6px;
    background: rgba(255,255,255,.08);
    color: #fff;
    cursor: pointer;
    flex-shrink: 0;
    line-height: 1;
}
.side-item.is-open > .side-row > .side-caret { transform: rotate(0deg); }
.side-item:not(.is-open) > .side-row > .side-caret { transform: rotate(-90deg); }
.side-footer {
    padding: 10px;
    border-top: 1px solid rgba(255,255,255,.12);
    display: grid;
    gap: 6px;
}
.side-tool {
    display: block;
    text-align: center;
    color: #fff;
    text-decoration: none;
    font-size: 13px;
    font-weight: 600;
    padding: 8px 10px;
    border-radius: 8px;
    background: rgba(255,255,255,.1);
}
.side-tool:hover { background: rgba(255,255,255,.18); }
.side-user {
    padding: 8px 14px;
    font-size: 12px;
    color: #a8c8e8;
    border-bottom: 1px solid rgba(255,255,255,.12);
    word-break: break-word;
}
.side-tool.is-disabled {
    opacity: .7;
    cursor: default;
    background: rgba(255,255,255,.06);
    pointer-events: none;
}
.app-main {
    flex: 1;
    min-width: 0;
    padding: 0 0 32px;
}
.app-top {
    background: linear-gradient(90deg, #002b5c 0%, var(--dark) 45%, #0055a5 100%);
    color: #e8eef6;
}
.app-top .bar-in { width: min(1180px, 100%); margin: 0 auto; }
.app-content { width: min(1180px, 100%); margin: 0 auto; padding: 16px 20px 0; }
.app-content.wide { width: min(1400px, 100%); }

.side-toggle {
    display: grid;
    place-items: center;
    position: fixed;
    top: 12px;
    left: 12px;
    z-index: 50;
    width: 42px;
    height: 42px;
    border: none;
    border-radius: 10px;
    background: var(--dark);
    color: #fff;
    font-size: 18px;
    cursor: pointer;
    box-shadow: 0 2px 10px rgba(0,0,0,.25);
    transition: left .22s ease, opacity .18s ease, background .15s ease;
}
/* เดสก์ท็อป: ซ่อนปุ่มลอยเมื่อเมนูเปิดอยู่ (มีปุ่ม « ในแถบแล้ว) */
body.has-sidebar:not(.sidebar-collapsed) .side-toggle {
    opacity: 0;
    pointer-events: none;
}
body.has-sidebar.sidebar-collapsed .side-toggle {
    opacity: 1;
    pointer-events: auto;
}
.side-toggle:hover { background: #0055a5; }

/* Menu manager */
.menu-guide-picker {
    display: grid;
    gap: 6px;
    margin-bottom: 14px;
    padding: 14px 16px;
    background: linear-gradient(135deg, #dbeafe 0%, #eff6ff 100%);
    border: 1px solid #93c5fd;
    border-radius: 12px;
}
.menu-guide-picker label {
    display: grid;
    gap: 4px;
    font-size: 13px;
    font-weight: 700;
    color: var(--dark);
}
.menu-guide-picker select {
    max-width: 420px;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    font: inherit;
    font-weight: 600;
    color: var(--text);
    background: #fff;
}
.menu-guide-hint {
    margin: 0;
    font-size: 13px;
    font-weight: 500;
    color: var(--muted);
}
.side-guide-tag {
    margin: 0 12px 8px;
    padding: 6px 10px;
    font-size: 12px;
    font-weight: 700;
    color: var(--dark);
    background: #e8f4fc;
    border: 1px solid #b6d4ea;
    border-radius: 8px;
}
.side-menu-empty {
    margin: 12px;
    padding: 10px;
    font-size: 13px;
    color: var(--muted);
    background: #f8fbff;
    border-radius: 8px;
}
.menu-howto b { color: var(--text); }
.menu-quick-add {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: end;
    margin-bottom: 14px;
    padding: 12px;
    background: #eef6fc;
    border: 1px solid var(--line);
    border-radius: 12px;
}
.menu-quick-label {
    display: grid;
    gap: 4px;
    flex: 1 1 240px;
    font-size: 13px;
    font-weight: 600;
    color: var(--muted);
}
.menu-quick-label select {
    padding: 8px 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    font: inherit;
    color: var(--text);
    background: #fff;
}
.btn-add-from-page {
    border: 1px solid var(--blue);
    background: #fff;
    color: var(--blue);
    border-radius: 8px;
    padding: 8px 14px;
    font: inherit;
    font-weight: 700;
    cursor: pointer;
}
.btn-add-from-page:hover { background: #e8f4fc; }
.menu-builder { display: grid; gap: 12px; }
.menu-empty { margin: 8px 0 0; }
.menu-card {
    background: #f7fbfe;
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 12px 14px;
}
.menu-card.is-root {
    background: #fff;
    box-shadow: 0 1px 3px rgba(15, 45, 74, .06);
}
.menu-card.is-child {
    background: #f3f9fd;
}
.menu-card-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
}
.menu-badge {
    display: inline-block;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .02em;
    text-transform: uppercase;
    padding: 3px 8px;
    border-radius: 999px;
    background: #dbeafe;
    color: #1d4ed8;
}
.menu-card.is-child .menu-badge {
    background: #e0e7ff;
    color: #4338ca;
}
.menu-link-hint {
    font-size: 13px;
    color: var(--muted);
}
.menu-link-hint.is-folder { color: var(--blue); }
.menu-link-hint.is-warn { color: #b45309; }
.menu-card-row {
    display: grid;
    grid-template-columns: 1fr 1.2fr;
    gap: 10px;
    align-items: end;
}
.menu-card label {
    display: grid;
    gap: 4px;
    font-size: 13px;
    color: var(--muted);
    font-weight: 600;
}
.menu-card input, .menu-card select {
    padding: 8px 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    font: inherit;
    color: var(--text);
    background: #fff;
}
.menu-advanced {
    margin-top: 8px;
    font-size: 13px;
    color: var(--muted);
}
.menu-advanced summary {
    cursor: pointer;
    font-weight: 600;
    user-select: none;
}
.menu-advanced label {
    margin-top: 8px;
}
.menu-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 10px;
}
.menu-actions button, .menu-toolbar button, .btn-create {
    border: 1px solid var(--line);
    background: #fff;
    border-radius: 8px;
    padding: 7px 12px;
    font: inherit;
    font-weight: 600;
    cursor: pointer;
    color: var(--text);
}
.menu-actions button:hover, .menu-toolbar button:hover { background: #eef6fc; }
.menu-actions button.danger-lite {
    color: #b91c1c;
    border-color: #fecaca;
}
.menu-actions button.danger-lite:hover { background: #fef2f2; }
.menu-children {
    margin-top: 12px;
    padding: 10px 0 0 14px;
    border-left: 3px solid #93c5fd;
    display: grid;
    gap: 10px;
}
.menu-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    margin-bottom: 12px;
}
.menu-toolbar .btn-save-menu {
    background: #0077c8;
    color: #fff;
    border-color: #0077c8;
}
.menu-toolbar .btn-save-menu:hover { background: #0055a5; color: #fff; }
.menu-status { color: var(--muted); font-size: 14px; min-height: 1.2em; }

/* ทางเข้าตั้งค่าเมนูจากหน้าจัดการ */
.manage-menu-callout {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 14px;
    padding: 14px 16px;
    background: linear-gradient(135deg, #e8f4fc 0%, #f5fafd 100%);
    border: 1px solid #8ec4e8;
    border-radius: 12px;
}
.manage-menu-callout-text strong {
    display: block;
    color: var(--text);
    font-size: 15px;
}
.manage-menu-callout-text span {
    font-size: 13px;
    color: var(--muted);
}
.manage-menu-callout-btn {
    display: inline-block;
    padding: 9px 16px;
    border-radius: 8px;
    background: var(--blue);
    color: #fff !important;
    font-weight: 700;
    text-decoration: none;
    border: none;
}
.manage-menu-callout-btn:hover { background: var(--dark); }

/* ปุ่มลอยขึ้นบนสุด */
.back-to-top {
    position: fixed;
    right: 20px;
    bottom: 22px;
    z-index: 1200;
    width: 48px;
    height: 48px;
    padding: 0;
    border: none;
    border-radius: 50%;
    display: grid;
    place-items: center;
    cursor: pointer;
    color: #fff;
    background: linear-gradient(160deg, var(--blue-mid) 0%, var(--blue) 55%, var(--dark) 100%);
    box-shadow: 0 4px 16px rgba(0, 55, 112, .35);
    transition: transform .18s ease, box-shadow .18s ease, background .18s ease;
}
.back-to-top:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 55, 112, .42);
    background: linear-gradient(160deg, var(--accent) 0%, var(--blue-mid) 50%, var(--blue) 100%);
}
.back-to-top:active {
    transform: translateY(0);
}
.back-to-top:focus-visible {
    outline: 3px solid rgba(0, 160, 227, .55);
    outline-offset: 3px;
}
.back-to-top svg {
    display: block;
}

@media (max-width: 900px) {
    .back-to-top {
        right: 14px;
        bottom: 16px;
        width: 44px;
        height: 44px;
    }
    .app-sidebar {
        position: fixed;
        left: 0;
        top: 0;
        width: 260px;
        transform: translateX(-105%);
        transition: transform .2s ease;
        box-shadow: 4px 0 24px rgba(0,0,0,.2);
        opacity: 1;
        pointer-events: auto;
    }
    body.sidebar-collapsed .app-sidebar {
        width: 260px;
        min-width: 260px;
        opacity: 1;
        pointer-events: auto;
    }
    body.sidebar-open .app-sidebar { transform: translateX(0); }
    body.has-sidebar .side-toggle,
    body.has-sidebar:not(.sidebar-collapsed) .side-toggle,
    body.has-sidebar.sidebar-collapsed .side-toggle {
        display: grid;
        opacity: 1;
        pointer-events: auto;
        left: 10px;
    }
    body.sidebar-open .side-toggle { left: 270px; }
    .menu-card-row { grid-template-columns: 1fr; }
    .menu-quick-add { flex-direction: column; align-items: stretch; }
}
