.fade-highlight {
    transition: background-color 1s ease, color 1s ease;
}

.theme-toggle-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.25rem;
    height: 2.25rem;
    margin: 0 0.1rem;
    padding: 0 !important;
    border: 0;
    border-radius: 0.65rem;
    background: transparent;
    color: inherit;
    cursor: pointer;
}

.theme-toggle-icon__graphic {
    font-size: 1.05rem;
    line-height: 1;
}

.theme-toggle-icon--dark .theme-toggle-icon__graphic {
    color: #ffd76a;
}

.theme-toggle-icon:not(.theme-toggle-icon--dark) .theme-toggle-icon__graphic {
    color: #8eb4ff;
}

.theme-toggle-auth {
    position: fixed;
    top: max(12px, env(safe-area-inset-top));
    left: max(12px, env(safe-area-inset-left));
    z-index: 1050;
    background: rgba(0, 0, 0, 0.28);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.18);
}

html[data-theme="light"] body:not(.dark-mode) .theme-toggle-auth {
    background: rgba(255, 255, 255, 0.82);
    box-shadow: 0 4px 14px rgba(15, 23, 42, 0.08);
}

.key-copyable {
    cursor: pointer;
}

.key-copyable.is-copied {
    color: #28a745 !important;
    background-color: rgba(40, 167, 69, 0.2) !important;
}

/*
 * กันหน้าบีบเข้า/ออก + แถบเทาข้างสกอลล์ตอนเปิด modal (addkey / Other) หรือ Swal
 *
 * สาเหตุ: Bootstrap ใส่ class modal-open → overflow:hidden แล้วซ่อนสกอลล์
 * พร้อมชดเชยด้วย padding-right ≈ ความกว้างสกอลล์ → เนื้อหาหด/ขยาย
 * และ scrollbar-gutter:stable ทำให้เหลือช่องว่างเทาข้างขวา
 *
 * แก้: คงสกอลล์ไว้ตลอด + ห้าม padding ชดเชย + พื้นหลัง html เท่า body
 * (อย่าใช้ scrollbar-gutter:stable — มันคือแถบเทาที่เห็นข้างสกอลล์)
 */
html {
    overflow-y: scroll !important;
    scrollbar-gutter: auto !important;
    /* ไม่ใช้ scrollbar-gutter: stable — จะเกิดแถบเทาข้างสกอลล์ */
}

html,
body {
    background-color: #f4f6f9;
}

html[data-theme="light"] {
    color-scheme: light;
}

/* โหมดมืด: พื้นหลัง + สกอลล์เนทีฟให้เข้าธีม (กันแถบขาวข้างสกอลล์บน Windows) */
html[data-theme="dark"],
html:has(body.dark-mode),
body.dark-mode {
    color-scheme: dark;
    background-color: #343a40;
}

html[data-theme="dark"] body,
body.dark-mode {
    background-color: #343a40;
}

html[data-theme="dark"],
html[data-theme="dark"] body,
body.dark-mode {
    scrollbar-width: thin;
    scrollbar-color: #6c757d #2b3035;
}

html[data-theme="dark"]::-webkit-scrollbar,
html[data-theme="dark"] body::-webkit-scrollbar,
body.dark-mode::-webkit-scrollbar {
    width: 12px;
    height: 12px;
    background: #2b3035;
}

html[data-theme="dark"]::-webkit-scrollbar-track,
html[data-theme="dark"] body::-webkit-scrollbar-track,
body.dark-mode::-webkit-scrollbar-track {
    background: #2b3035;
}

html[data-theme="dark"]::-webkit-scrollbar-thumb,
html[data-theme="dark"] body::-webkit-scrollbar-thumb,
body.dark-mode::-webkit-scrollbar-thumb {
    background: #6c757d;
    border-radius: 6px;
    border: 2px solid #2b3035;
}

html[data-theme="dark"]::-webkit-scrollbar-thumb:hover,
html[data-theme="dark"] body::-webkit-scrollbar-thumb:hover,
body.dark-mode::-webkit-scrollbar-thumb:hover {
    background: #adb5bd;
}

html[data-theme="dark"]::-webkit-scrollbar-corner,
html[data-theme="dark"] body::-webkit-scrollbar-corner,
body.dark-mode::-webkit-scrollbar-corner {
    background: #2b3035;
}

html.swal2-shown,
html.swal2-height-auto,
body.modal-open,
body.swal2-shown,
body.swal2-height-auto,
body.swal2-no-backdrop {
    padding-right: 0 !important;
    margin-right: 0 !important;
    /* ทับ .modal-open { overflow: hidden } ของ Bootstrap / Swal */
    overflow: visible !important;
    overflow-y: scroll !important;
}

.modal-open .main-header,
.modal-open .main-sidebar,
.modal-open .control-sidebar,
.modal-open .navbar-fixed,
.modal-open .navbar,
.modal-open .content-wrapper,
.modal-open .main-footer,
.modal-open .wrapper,
.swal2-shown .main-header,
.swal2-shown .main-sidebar,
.swal2-shown .control-sidebar,
.swal2-shown .navbar,
.swal2-shown .content-wrapper,
.swal2-shown .main-footer,
.swal2-shown .wrapper,
.modal-open .fixed-top,
.modal-open .fixed-bottom,
.modal-open .sticky-top,
.swal2-shown .fixed-top,
.swal2-shown .fixed-bottom,
.swal2-shown .sticky-top {
    padding-right: 0 !important;
    margin-right: 0 !important;
}

/* กัน Bootstrap ใส่ padding ที่ตัว modal เองตอนซ้อน Swal */
.modal.padding-right,
.modal[style*="padding-right"] {
    padding-right: 0 !important;
}

/*
 * โมดัลยิงประกาศ — มือถือ/พับจอ: ย่อฟอร์ม ไม่ให้ดูใหญ่เกินจอ
 * สกอลล์เฉพาะตอนล้น ปุ่มยิงติดท้ายโมดัลกดได้ตลอด
 */
#modal-announce-project .modal-dialog {
    max-width: 420px;
    width: calc(100% - 1rem);
    max-height: calc(100vh - 1rem);
    max-height: calc(100dvh - 1rem);
    margin: 0.5rem auto;
}
#modal-announce-project .modal-content {
    max-height: calc(100vh - 1rem);
    max-height: calc(100dvh - 1rem);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
#modal-announce-project .modal-body {
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    flex: 1 1 auto;
    min-height: 0;
    padding: 0.75rem 1rem;
}
#modal-announce-project .modal-header {
    padding: 0.65rem 1rem;
}
#modal-announce-project .modal-footer {
    flex: 0 0 auto;
    padding: 0.5rem 0.75rem 0.75rem;
}
#modal-announce-project .modal-header,
#modal-announce-project .modal-footer {
    flex: 0 0 auto;
}
#modal-announce-project .modal-title {
    font-size: 1.05rem;
}
#modal-announce-project .form-group {
    margin-bottom: 0.55rem;
}
#modal-announce-project .form-control {
    font-size: 0.95rem;
    min-height: 2rem;
    padding: 0.3rem 0.55rem;
}
#modal-announce-project .announce-color-row {
    gap: 1.25rem !important;
    padding-top: 0.5rem !important;
    margin-top: 0.25rem !important;
}
@media (max-width: 576px) {
    #modal-announce-project .modal-dialog {
        max-width: calc(100% - 0.75rem);
        margin: 0.35rem auto;
    }
    #modal-announce-project .modal-body {
        padding: 0.55rem 0.75rem;
    }
    #modal-announce-project .form-group {
        margin-bottom: 0.4rem;
    }
    #modal-announce-project .form-control {
        font-size: 16px; /* กัน iOS ซูมตอนโฟกัส */
        min-height: 2.15rem;
    }
    #modal-announce-project .text-sm,
    #modal-announce-project .form-text {
        font-size: 0.75rem !important;
        line-height: 1.25;
    }
    #modal-announce-project .announce-color-row {
        gap: 0.75rem !important;
        flex-wrap: wrap;
        justify-content: space-around !important;
    }
    #modal-announce-project #btn-publish-announce {
        font-size: 0.95rem;
        padding: 0.45rem 0.75rem;
    }
}
