﻿/* Extracted from style block 1 */
*{box-sizing:border-box}
[hidden]{display:none !important}
*{
    scrollbar-width:none;
    -ms-overflow-style:none;
}
*::-webkit-scrollbar{
    width:0;
    height:0;
    display:none;
}
html,body{
    margin:0;
    padding:0;
    font-family:"IBM Plex Sans Thai",system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif;
    background:#eef2f7;
    color:#111827;
}
.access-gate{
    position:fixed;
    inset:0;
    z-index:100000;
    display:flex;
    align-items:center;
    justify-content:center;
    padding:20px;
    background:linear-gradient(145deg,#0f172a 0%,#1e293b 55%,#172554 100%);
}
.access-gate-card{
    width:min(390px,100%);
    padding:28px;
    border:1px solid rgba(255,255,255,.14);
    border-radius:24px;
    background:rgba(255,255,255,.97);
    box-shadow:0 24px 70px rgba(0,0,0,.34);
    text-align:center;
}
.access-gate-icon{
    display:flex;
    align-items:center;
    justify-content:center;
    width:58px;
    height:58px;
    margin:0 auto 14px;
    border-radius:18px;
    background:#dbeafe;
    color:#1d4ed8;
    font-size:24px;
}
.access-gate-card h1{margin:0 0 6px;font-size:23px;color:#0f172a}
.access-gate-card p{margin:0 0 18px;color:#64748b;font-size:14px}
.access-gate-card input{
    width:100%;
    min-height:50px;
    margin-bottom:12px;
    border:1px solid #cbd5e1;
    border-radius:14px;
    padding:10px 14px;
    font-family:inherit;
    font-size:18px;
    font-weight:700;
    text-align:center;
    letter-spacing:.18em;
}
.access-gate-card button{
    width:100%;
    min-height:48px;
    border:0;
    border-radius:14px;
    background:#2563eb;
    color:#fff;
    font-family:inherit;
    font-size:15px;
    font-weight:800;
    cursor:pointer;
}
.access-gate-card button:hover{background:#1d4ed8}
.access-gate-status{min-height:22px;margin-top:10px;color:#dc2626;font-size:13px;font-weight:700}
body.access-locked{overflow:hidden !important}
body.access-locked > :not(.access-gate):not(script){visibility:hidden}
html.access-state-unlocked .access-gate{display:none !important}
html.access-state-unlocked body.access-locked{overflow:auto !important}
html.access-state-unlocked body.access-locked > :not(.access-gate):not(script){visibility:visible}
:root{--quick-menu-height:64px}
body{min-height:100vh;padding-top:var(--quick-menu-height) !important}
.app{
    max-width:1500px;
    margin:0 auto;
    padding:16px;
    display:grid;
    grid-template-columns:minmax(0,1fr) 472px;
    gap:10px;
    align-items:start;
}
.preview-side{
    position:sticky;
    top:calc(var(--quick-menu-height) + 16px);
    height:calc(100vh - var(--quick-menu-height) - 32px);
    background:#eef2f7;
    padding:0;
    overflow:auto;
    display:flex;
    align-items:center;
    /* ชิด Canvas ไปทาง Sidebar เสมอ แม้ผู้ใช้ซูมเบราว์เซอร์ */
    justify-content:flex-end;
}
.canvas-box{
    width:100%;
    min-height:100%;
    display:flex;
    align-items:flex-start;
    /* ป้องกันพื้นที่ว่างคั่นกลางระหว่าง Canvas กับ Sidebar */
    justify-content:flex-end;
}
canvas{
    display:block;
    background:#fff;
    width:auto;
    max-width:100%;
    max-height:calc(100vh - var(--quick-menu-height) - 32px);
    height:auto;
    border:0;
    outline:0;
    box-shadow:none;
    cursor:move;
    touch-action:none;
}
canvas.resizing-crop{cursor:crosshair}
canvas.blur-region-mode{cursor:crosshair}
.menu-side{width:100%}
@media(min-width:1001px){
    .menu-side{
        position:sticky;
        top:calc(var(--quick-menu-height) + 16px);
        max-height:calc(100vh - var(--quick-menu-height) - 32px);
        overflow-y:auto;
        overscroll-behavior:contain;
        scrollbar-gutter:stable;
    }
}
.panel{
    background:#ffffff;
    border:1px solid #e2e8f0;
    border-radius:18px;
    padding:16px;
    box-shadow:0 8px 22px rgba(15,23,42,.07);
}
.panel h2{
    margin:0 0 14px;
    font-size:20px;
    display:flex;
    align-items:center;
    gap:8px;
}
.sidebar-panel-section{display:none}
.sidebar-panel-section.is-active{
    display:block;
    animation:none !important;
}
.sidebar-panel-section > .section-title{margin-top:0}
@keyframes sidebarPanelIn{
    from{opacity:0;transform:translateY(4px)}
    to{opacity:1;transform:translateY(0)}
}
.quick-menu button.is-active{
    background:#ffffff !important;
    color:#0f172a !important;
    border-color:#ffffff !important;
    box-shadow:0 3px 12px rgba(255,255,255,.25);
}
.menu-icon{
    display:inline-flex;
    align-items:center;
    justify-content:center;
    width:26px;
    height:26px;
    border-radius:9px;
    background:#f3f4f6;
    font-size:16px;
    line-height:1;
    flex:0 0 auto;
}
.group{margin-bottom:14px}
label{
    display:block;
    font-size:14px;
    font-weight:700;
    margin-bottom:6px;
}
input[type="file"]{width:100%;font-family:inherit}
input[type="text"],input[type="number"],textarea,select{
    width:100%;
    border:1px solid #d1d5db;
    border-radius:10px;
    padding:10px 12px;
    font-size:16px;
    font-family:inherit;
    outline:none;
    background:#fff;
}
textarea{min-height:100px;resize:vertical}
.rich-text-editor{
    width:100%;
    min-height:128px;
    border:1px solid #d1d5db;
    border-radius:10px;
    padding:10px 12px;
    font-size:16px;
    font-family:inherit;
    line-height:1.5;
    outline:none;
    background:#fff;
    white-space:pre-wrap;
    overflow-wrap:anywhere;
    color:#111827 !important;
}
.rich-text-editor *{color:#111827 !important}
#headlineEditor,
#extraTextEditor{
    font-family:system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",Arial,sans-serif !important;
    font-size:16px !important;
    font-weight:400 !important;
    line-height:1.5 !important;
    text-align:left !important;
}
.editor-with-color{
    position:relative;
}
.editor-with-color .rich-text-editor{
    padding-right:12px;
    padding-bottom:12px;
}
.editor-inline-color-btn{
    display:none !important;
}
.editor-inline-color-input{
    position:absolute;
    right:10px;
    bottom:10px;
    width:1px;
    height:1px;
    opacity:0;
    pointer-events:none;
}
.canvas-color-popup{
    position:fixed;
    z-index:2147483646;
    display:none;
    width:max-content;
    max-width:min(260px,calc(100vw - 20px));
    padding:10px;
    border:1px solid rgba(191,219,254,.95);
    border-radius:12px;
    background:#ffffff;
}
.canvas-color-popup.is-open{
    display:block;
}
body.canvas-fullscreen-open .canvas-color-popup{
    z-index:2147483646 !important;
    pointer-events:auto !important;
}
.canvas-color-popup-title{
    margin:0 0 8px;
    color:#334155;
    font-size:12px;
    font-weight:900;
}
.canvas-color-popup-grid{
    display:grid;
    grid-template-columns:repeat(6,28px);
    gap:7px;
}
.canvas-color-swatch{
    width:28px;
    height:28px;
    border:1px solid #cbd5e1;
    border-radius:999px;
    cursor:pointer;
}
.canvas-color-popup-custom{
    margin-top:9px;
    display:flex;
    align-items:center;
    gap:8px;
}
.canvas-color-popup-custom input[type="color"]{
    width:34px;
    height:34px;
}
.canvas-color-popup-custom span{
    color:#475569;
    font-size:12px;
    font-weight:800;
}
.rich-text-editor:focus{
    border-color:#38bdf8;
    box-shadow:0 0 0 3px rgba(56,189,248,.16);
}
.rich-text-editor:empty::before{
    content:attr(data-placeholder);
    color:#9ca3af;
    pointer-events:none;
}
input[type="color"]{
    width:52px;
    height:52px;
    border:2px solid #dbe3ee;
    border-radius:50%;
    padding:3px;
    background:#fff;
    cursor:pointer;
    overflow:hidden;
    transition:transform .15s ease,box-shadow .15s ease,border-color .15s ease;
}
input[type="color"]:hover{transform:scale(1.06);border-color:#93c5fd}
input[type="color"]:focus-visible{outline:none;box-shadow:0 0 0 4px rgba(59,130,246,.2)}
input[type="color"]::-webkit-color-swatch-wrapper{padding:0}
input[type="color"]::-webkit-color-swatch{border:0;border-radius:50%}
input[type="color"]::-moz-color-swatch{border:0;border-radius:50%}
.row:has(input[type="color"]){
    display:flex;
    align-items:flex-start;
    justify-content:flex-start;
    gap:12px;
}
.row:has(input[type="color"]) > .group{
    flex:0 0 118px;
    width:118px;
}
.line-color-grid{
    display:grid;
    grid-template-columns:repeat(4,minmax(58px,1fr));
    gap:12px 8px;
    margin:4px 0 18px;
}
.line-color-grid .group{
    position:relative;
    display:flex;
    align-items:center;
    justify-content:center;
    min-height:72px;
    margin:0;
    padding:8px;
    border:1px solid #e2e8f0;
    border-radius:16px;
    background:#f8fafc;
    text-align:center;
    transition:border-color .15s ease,background .15s ease,transform .15s ease;
}
.line-color-grid .group:hover{
    border-color:#bfdbfe;
    background:#eff6ff;
    transform:translateY(-1px);
}
.line-color-grid label{
    position:absolute;
    left:calc(50% + 10px);
    top:calc(50% + 10px);
    z-index:2;
    transform:translate(-50%,-50%);
    display:flex;
    align-items:center;
    justify-content:center;
    width:20px;
    height:20px;
    margin:0;
    border:1px solid rgba(15,23,42,.12);
    border-radius:50%;
    background:rgba(255,255,255,.96);
    color:#0f172a;
    font-size:11px;
    font-weight:900;
    line-height:1;
    box-shadow:0 2px 6px rgba(15,23,42,.18);
    pointer-events:none;
}
.line-color-grid input[type="color"]{margin:0 auto}
input[type="range"]{width:100%}
.row{display:grid;grid-template-columns:1fr 1fr;gap:10px}
.row-3{display:grid;grid-template-columns:repeat(auto-fit,minmax(118px,1fr));gap:10px}
.bg-mode-menu{display:grid;grid-template-columns:1fr 1fr;gap:8px}
.bg-mode-btn{
    min-height:44px;
    border:1px solid #dbeafe;
    border-radius:12px;
    padding:9px 10px;
    background:#eff6ff;
    color:#1e40af;
    font-family:inherit;
    font-size:13px;
    font-weight:800;
    cursor:pointer;
}
.bg-mode-btn:hover{background:#dbeafe}
.bg-mode-btn.is-active{background:#2563eb;color:#fff;border-color:#2563eb;box-shadow:0 5px 14px rgba(37,99,235,.2)}
#bgColorControls.is-single{grid-template-columns:1fr}
.bg-file-input{position:absolute;width:1px;height:1px;opacity:0;pointer-events:none}
.bg-file-picker{
    display:inline-flex;
    align-items:center;
    justify-content:center;
    gap:7px;
    min-height:42px;
    margin:0;
    padding:9px 16px;
    border:1px solid #bfdbfe;
    border-radius:12px;
    background:#dbeafe;
    color:#1e40af;
    font-size:13px;
    font-weight:800;
    cursor:pointer;
}
.bg-file-picker:hover{background:#bfdbfe}
#bgImageUploadGroup{text-align:center}
.bg-file-name{margin-top:7px;color:#64748b;font-size:12px;text-align:center;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
#resetBgImageBtn{
    width:auto !important;
    min-width:190px;
    min-height:38px !important;
    margin:8px auto 14px !important;
    padding:8px 16px !important;
    display:flex !important;
    align-items:center;
    justify-content:center;
    background:#f8fafc !important;
    color:#1e40af !important;
    border:1px solid #bfdbfe !important;
    border-radius:999px !important;
}
#resetBgImageBtn:hover{background:#eff6ff !important}
#bgEffectControls{align-items:stretch}
#bgEffectControls .group,
#bgTintGroup{
    margin:0 0 12px !important;
    padding:12px !important;
    border:1px solid #e2e8f0 !important;
    border-radius:14px !important;
    background:linear-gradient(180deg,#ffffff,#f8fafc) !important;
    box-shadow:0 3px 10px rgba(15,23,42,.04) !important;
}
#bgEffectControls label{
    display:flex !important;
    align-items:center;
    justify-content:space-between;
    gap:8px;
    margin-bottom:10px !important;
}
#bgEffectControls .value-pill{margin-left:auto !important;white-space:nowrap}
#bgTintGroup{text-align:center}
#bgTintGroup label{display:flex !important;align-items:center;justify-content:center;margin-bottom:10px !important}
#bgTintGroup input[type="color"]{display:block;margin:0 auto}
@media(max-width:600px){
    #bgEffectControls{grid-template-columns:1fr !important}
}
.btn{
    width:100%;
    border:0;
    border-radius:12px;
    padding:12px;
    font-size:16px;
    font-weight:800;
    font-family:inherit;
    cursor:pointer;
    background:#334155;
    color:#ffffff;
}
.btn.secondary{background:#3b82f6}
.btn.gray{background:#64748b}
.btn.red{background:#ef4444}
.btn.green{background:#22c55e;color:#052e16}
.btn.orange{background:#f97316;color:#431407}
.btn.purple{background:#8b5cf6}
.btn.small{padding:9px;font-size:14px}
.btn:hover{opacity:.92}
.btn:disabled{opacity:.55;cursor:not-allowed}

.sidebar-action-buttons{
    position:sticky;
    top:calc(var(--quick-menu-height) + 10px);
    z-index:50;
    display:flex;
    flex-direction:column;
    gap:7px;
    width:100%;
    margin:-4px 0 12px;
    padding:7px;
    border:1px solid #e2e8f0;
    border-radius:13px;
    background:linear-gradient(180deg,#f8fafc,#ffffff);
    box-shadow:0 6px 16px rgba(15,23,42,.06);
}
.sidebar-action-buttons .btn{
    width:100%;
    min-height:38px;
    padding:8px 10px;
    display:flex;
    align-items:center;
    justify-content:center;
    gap:6px;
    border-radius:11px;
    font-size:14px;
    line-height:1.15;
    white-space:normal;
}
.sidebar-action-buttons .btn span{
    display:inline-flex;
    align-items:center;
    justify-content:center;
    font-size:14px;
}
.sidebar-file-hidden{
    position:absolute;
    width:1px;
    height:1px;
    opacity:0;
    pointer-events:none;
}

.help{
    font-size:13px;
    color:#6b7280;
    line-height:1.6;
    margin-bottom:0;
}
.section-title{
    margin:18px 0 10px;
    padding-top:12px;
    border-top:1px solid #e5e7eb;
    font-size:15px;
    font-weight:800;
    display:flex;
    align-items:center;
    gap:8px;
    color:#111827;
}
.section-title .menu-icon{
    width:28px;
    height:28px;
    background:#eef2ff;
    border:1px solid #dbeafe;
}
.menu-side .section-title,
.menu-side .section-title-inline{
    margin:12px 0 !important;
    padding:10px 12px !important;
    border:1px solid #dbeafe !important;
    border-left:4px solid #2563eb !important;
    border-radius:12px !important;
    background:linear-gradient(180deg,#ffffff,#f8fbff) !important;
    color:#0f172a !important;
    box-shadow:0 4px 12px rgba(15,23,42,.06) !important;
}


body > .quick-menu{
    position:fixed !important;
    top:0 !important;
    left:0 !important;
    right:auto !important;
    width:100vw !important;
    max-width:100vw !important;
    z-index:2147483000 !important;
    height:var(--quick-menu-height) !important;
    margin:0 !important;
    padding:8px 12px !important;
    border:0 !important;
    border-bottom:1px solid rgba(255,255,255,.14) !important;
    border-radius:0 !important;
    background:#1e293b !important;
    box-shadow:0 8px 22px rgba(15,23,42,.18) !important;
    display:flex !important;
    align-items:center !important;
    gap:10px !important;
    overflow:hidden !important;
}
.quick-menu-title{
    display:flex;
    align-items:center;
    gap:7px;
    margin:0;
    padding:0 4px 0 0;
    font-size:15px;
    font-weight:900;
    color:#ffffff;
    white-space:nowrap;
    flex:0 0 auto;
}
.quick-menu-title .menu-icon{
    background:#e0f2fe;
    color:#075985;
}
.quick-menu-title .page-refresh-icon-btn{
    width:30px !important;
    height:30px !important;
    min-width:30px !important;
    min-height:30px !important;
    margin-left:2px !important;
    padding:0 !important;
    border:1px solid rgba(219,234,254,.35) !important;
    border-radius:50% !important;
    background:rgba(255,255,255,.12) !important;
    color:#dbeafe !important;
    display:inline-flex !important;
    align-items:center !important;
    justify-content:center !important;
    flex:0 0 30px !important;
}
.quick-menu-title .page-refresh-icon-btn:hover{background:#2563eb !important;color:#fff !important}
.quick-menu-title .page-refresh-icon-btn i{margin:0 !important;font-size:12px !important}
.quick-menu-grid{
    display:flex;
    align-items:center;
    gap:8px;
    overflow-x:auto;
    overflow-y:hidden;
    -webkit-overflow-scrolling:touch;
    scrollbar-width:none;
    flex:1 1 auto;
    min-width:0;
    height:46px;
    padding:2px 4px;
}
.quick-menu-grid::-webkit-scrollbar{display:none}
.quick-menu-scroll-btn{display:none}
.mobile-refresh-grid-btn{display:none !important}
.quick-menu .quick-highlight-btn{
    background:linear-gradient(135deg,#14532d,#064e3b) !important;
    color:#dcfce7 !important;
    border-color:#166534 !important;
    box-shadow:0 4px 10px rgba(2,44,34,.22) !important;
}
.quick-menu .quick-highlight-btn:hover{background:linear-gradient(135deg,#166534,#065f46) !important;color:#f0fdf4 !important}
.mobile-chat-composer{display:none}
.quick-menu button{
    border:1px solid rgba(255,255,255,.18);
    border-radius:999px;
    padding:10px 15px;
    background:#1e293b;
    color:#ffffff;
    font-size:13px;
    font-weight:850;
    font-family:inherit;
    cursor:pointer;
    line-height:1.2;
    white-space:nowrap;
    flex:0 0 auto;
}
.quick-menu button:hover{
    background:#2563eb;
    border-color:#93c5fd;
}
.quick-menu button:active{transform:scale(.98)}
.quick-anchor{scroll-margin-top:calc(var(--quick-menu-height) + 20px)}

.value-pill{
    display:inline-block;
    margin-left:6px;
    padding:2px 8px;
    border-radius:999px;
    background:#f3f4f6;
    color:#374151;
    font-size:12px;
}
.status-box{
    display:none;
    margin-top:8px;
    padding:10px;
    border-radius:10px;
    background:#ecfdf5;
    color:#166534;
    font-size:13px;
    line-height:1.5;
}
.status-box.error{background:#fef2f2;color:#991b1b}
.status-box.info{background:#eff6ff;color:#1d4ed8}
.layer-list,.txt-list{
    display:flex;
    flex-direction:column;
    gap:8px;
    max-height:210px;
    overflow:auto;
    border:1px solid #e5e7eb;
    border-radius:12px;
    padding:8px;
    background:#f9fafb;
}
.layer-item,.txt-item{
    display:flex;
    align-items:center;
    gap:8px;
    padding:8px;
    border-radius:10px;
    background:#fff;
    border:1px solid #e5e7eb;
    cursor:pointer;
}
.layer-item.active,.txt-item.active{border-color:#2563eb;background:#eff6ff}
.layer-overlay-toggle{
    flex:0 0 auto;
    min-width:76px;
    min-height:34px;
    padding:6px 9px;
    border:1px solid #cbd5e1;
    border-radius:9px;
    background:#f8fafc;
    color:#475569;
    font-family:inherit;
    font-size:11px;
    font-weight:800;
    cursor:pointer;
}
.layer-overlay-toggle:hover{background:#e2e8f0}
.layer-overlay-toggle.is-above{
    border-color:#60a5fa;
    background:#dbeafe;
    color:#1d4ed8;
}
.extra-text-actions{margin-bottom:18px}
.txt-item-delete{
    flex:0 0 32px;
    width:32px;
    height:32px;
    margin-left:auto;
    padding:0;
    border:1px solid #fecdd3;
    border-radius:9px;
    background:#fff1f2;
    color:#be123c;
    display:inline-flex;
    align-items:center;
    justify-content:center;
    cursor:pointer;
    transition:background .18s ease, border-color .18s ease, transform .18s ease;
}
.txt-item-delete:hover{
    background:#ffe4e6;
    border-color:#fda4af;
    transform:translateY(-1px);
}
.txt-item-delete:active{transform:translateY(0)}
.txt-item-delete i{margin:0!important;font-size:13px}
.extra-text-editor-group{
    padding-top:2px;
    margin-bottom:18px;
}
.layer-thumb{
    width:46px;
    height:46px;
    object-fit:cover;
    background:#e5e7eb;
    border-radius:8px;
    flex:0 0 auto;
}
.layer-name,.txt-name{
    font-size:13px;
    font-weight:700;
    overflow:hidden;
    text-overflow:ellipsis;
    white-space:nowrap;
}
.layer-sub,.txt-sub{font-size:12px;color:#6b7280}
.switch-row{
    display:flex;
    align-items:center;
    gap:8px;
    font-size:14px;
    font-weight:700;
}
.switch-row input{width:18px;height:18px}

@media(max-width:1000px){
    html,body{overflow-x:hidden}
    body{padding-top:calc(56vh + var(--quick-menu-height)) !important}
    .app{display:block;max-width:none;width:100%;padding:0;margin:0}
    .preview-side{
        position:fixed;
        top:var(--quick-menu-height);
        left:0;
        right:0;
        z-index:9999;
        width:100%;
        height:56vh;
        min-height:320px;
        max-height:620px;
        background:#4b5563;
        padding:8px;
        overflow:hidden;
        border-bottom:1px solid rgba(255,255,255,.18);
        box-shadow:0 8px 18px rgba(0,0,0,.22);
    }
    .canvas-box{
        width:100%;
        height:100%;
        min-height:100%;
        display:flex;
        align-items:center;
        justify-content:center;
    }
    canvas{
        max-height:calc(56vh - 16px);
        max-width:100%;
        width:auto;
        height:auto;
    }
    .menu-side{width:100%;padding:10px}

    .sidebar-action-buttons{
        position:relative;
        top:auto;
        margin:0 0 10px;
        padding:6px;
        gap:6px;
        border-radius:12px;
    }
    .sidebar-action-buttons .btn{
        min-height:36px;
        padding:8px 10px;
        font-size:14px;
        border-radius:10px;
    }
    .panel{border-radius:14px;padding:12px}

    body > .quick-menu{height:58px !important;padding:7px 8px !important;gap:7px !important}
    .quick-menu-title{font-size:13px}
    .quick-menu-title .menu-icon{width:24px;height:24px;font-size:14px}
        .quick-menu-grid{height:44px;gap:7px}
    .quick-menu button{font-size:12px;padding:9px 12px}
    .quick-anchor{scroll-margin-top:calc(var(--quick-menu-height) + 20px)}
    input[type="text"],input[type="number"],textarea,select{font-size:16px}
}

/* Comfort color tuning */
.panel,
.layer-list,
.txt-list{
    color:#1e293b;
}

input[type="text"],
input[type="number"],
textarea,
select{
    border-color:#dbe3ee;
    background:#fbfdff;
    color:#1e293b;
}

input[type="text"]:focus,
input[type="number"]:focus,
textarea:focus,
select:focus{
    border-color:#93c5fd;
    box-shadow:0 0 0 3px rgba(147,197,253,.22);
}

.section-title{
    color:#0f172a;
    border-top-color:#edf2f7;
}

.section-title .menu-icon,
.menu-icon{
    background:#f1f5f9;
    color:#334155;
}

.layer-item,
.txt-item{
    border-color:#e2e8f0;
    background:#ffffff;
}

.layer-item.active,
.txt-item.active{
    border-color:#93c5fd;
    background:#eff6ff;
}

.value-pill{
    background:#eaf2fb;
    color:#334155;
}

.help{
    color:#64748b;
}

.status-box.info{
    background:#eff6ff;
    color:#1e40af;
}

.status-box.error{
    background:#fff1f2;
    color:#be123c;
}

.quick-menu button:hover,
.btn:hover{
    opacity:.96;
    filter:brightness(1.02);
}

.quick-menu button{
    background:#334155 !important;
    color:#f8fafc !important;
    border-color:rgba(226,232,240,.22) !important;
}

.quick-menu button:hover{
    background:#475569 !important;
}

.sidebar-action-buttons .btn.green{
    background:#dcfce7;
    color:#166534;
}

.sidebar-action-buttons .btn.secondary{
    background:#dbeafe;
    color:#1d4ed8;
}

.sidebar-action-buttons .btn.purple{
    background:#ede9fe;
    color:#5b21b6;
}

body > .quick-menu{
    backdrop-filter:saturate(130%) blur(8px);
}


/* Unified icon/button tone */
:root{
    --ui-main:#2563eb;
    --ui-main-soft:#dbeafe;
    --ui-main-soft-2:#eff6ff;
    --ui-main-text:#1e40af;
    --ui-border:#dbeafe;
}

.menu-icon,
.section-title .menu-icon,
.quick-menu-title .menu-icon{
    background:var(--ui-main-soft) !important;
    color:var(--ui-main-text) !important;
    border:1px solid var(--ui-border) !important;
}

.btn,
.btn.secondary,
.btn.gray,
.btn.red,
.btn.green,
.btn.orange,
.btn.purple,
.sidebar-action-buttons .btn.green,
.sidebar-action-buttons .btn.secondary,
.sidebar-action-buttons .btn.purple{
    background:var(--ui-main-soft) !important;
    color:var(--ui-main-text) !important;
    border:1px solid var(--ui-border) !important;
    box-shadow:none !important;
}

.btn:hover,
.btn.secondary:hover,
.btn.gray:hover,
.btn.red:hover,
.btn.green:hover,
.btn.orange:hover,
.btn.purple:hover{
    background:#bfdbfe !important;
    color:#1d4ed8 !important;
    opacity:1;
}

#removeBgBtn{
    background:#ef4444 !important;
    color:#ffffff !important;
    border-color:#dc2626 !important;
}

#removeBgBtn:hover{
    background:#dc2626 !important;
    color:#ffffff !important;
}

.quick-menu button{
    background:#334155 !important;
    color:#e0f2fe !important;
    border-color:rgba(219,234,254,.24) !important;
}

.quick-menu button:hover{
    background:#475569 !important;
    color:#ffffff !important;
}

.layer-item.active,
.txt-item.active{
    border-color:#93c5fd !important;
    background:var(--ui-main-soft-2) !important;
}

.value-pill{
    background:var(--ui-main-soft) !important;
    color:var(--ui-main-text) !important;
}

.status-box.info{
    background:var(--ui-main-soft-2) !important;
    color:var(--ui-main-text) !important;
}


/* Font Awesome icon alignment */
.menu-icon i,
.btn i,
.quick-menu i,
label i{
    display:inline-flex;
    align-items:center;
    justify-content:center;
    width:1.15em;
    min-width:1.15em;
    line-height:1;
    font-size:.95em;
}

.menu-icon i{
    font-size:14px;
}

.btn i{
    margin-right:4px;
}

.sidebar-action-buttons .btn span i{
    margin-right:0;
}

.quick-menu button i{
    margin-right:5px;
}

label i{
    color:var(--ui-main-text);
    margin-right:5px;
}


/* Smaller button text */
.btn{
    font-size:14px !important;
}

.btn.small{
    font-size:13px !important;
}

.sidebar-action-buttons .btn{
    font-size:13px !important;
}

.quick-menu button{
    font-size:13px !important;
}

.btn i,
.quick-menu button i{
    font-size:.9em;
}


#quick-headline + .group textarea#headline{
    min-height:128px;
}

/* Action buttons moved to top menu */
.quick-menu-grid > button:nth-child(-n+4){
    background:#dbeafe !important;
    color:#1e40af !important;
    border-color:#bfdbfe !important;
    font-weight:900 !important;
}
.quick-menu-grid > button:nth-child(-n+4):hover{
    background:#bfdbfe !important;
    color:#1d4ed8 !important;
}




/* Main headline line colors: one full-width picker per row */
.headline-line-color-list{
    display:block;
    width:100%;
}
.headline-line-color-list > .group{
    width:100%;
}

/* =========================================================
   MOBILE-FIRST REDESIGN V26
   โทนเดิม ฟ้า-ขาว-เทา / ใช้งานมือถือเป็นหลัก / ไม่ตัดฟังก์ชันเดิม
   ========================================================= */
:root{
    --mobile-preview-height:36svh;
    --mobile-bottom-menu-height:60px;
    --mobile-card-radius:20px;
    --mobile-soft-bg:#f4f8fd;
    --mobile-card:#ffffff;
    --mobile-ink:#0f172a;
    --mobile-muted:#64748b;
    --mobile-line:#dbeafe;
    --mobile-blue:#2563eb;
    --mobile-blue-soft:#dbeafe;
    --mobile-blue-soft-2:#eff6ff;
}

@media(max-width:1000px){
    :root{
        --quick-menu-height:0px;
        --mobile-bottom-menu-height:140px;
    }
    html{
        height:100%;
        background:var(--mobile-soft-bg);
        -webkit-text-size-adjust:100%;
    }
    body{
        min-height:100%;
        padding-top:var(--mobile-preview-height) !important;
        padding-bottom:calc(var(--mobile-bottom-menu-height) + env(safe-area-inset-bottom) + 18px) !important;
        background:linear-gradient(180deg,#eef6ff 0%,#f8fbff 42%,#eef2f7 100%);
        color:var(--mobile-ink);
        overflow-x:hidden;
    }

    body.mobile-chat-composer-open > .quick-menu{
        display:none !important;
    }

    body.mobile-chat-composer-open{
        overflow:hidden !important;
    }

    body.mobile-chat-composer-open::before{
        content:"";
        position:fixed;
        left:0;
        right:0;
        top:var(--mobile-preview-bottom,var(--mobile-preview-height));
        bottom:0;
        z-index:2147483400;
        background:#ffffff;
        pointer-events:auto;
    }

    .mobile-chat-composer{
        position:fixed;
        left:0;
        right:0;
        bottom:var(--mobile-keyboard-offset,0px);
        z-index:2147483500;
        display:none;
        align-items:stretch;
        padding:8px max(8px,env(safe-area-inset-right)) calc(8px + env(safe-area-inset-bottom)) max(8px,env(safe-area-inset-left));
        border-top:1px solid #dbeafe;
        background:rgba(255,255,255,.98);
        box-shadow:0 -10px 28px rgba(15,23,42,.18);
        backdrop-filter:blur(14px) saturate(140%);
    }

    body.mobile-chat-composer-open .mobile-chat-composer{
        display:flex;
    }

    .mobile-chat-input-shell{
        position:relative;
        width:100%;
        min-width:0;
    }

    .mobile-chat-composer textarea{
        display:block;
        width:100% !important;
        min-width:0;
        min-height:44px !important;
        max-height:132px !important;
        height:44px;
        margin:0;
        padding:10px 78px 10px 14px !important;
        border:1px solid #cbd5e1 !important;
        border-radius:22px !important;
        background:#f8fafc !important;
        color:#0f172a !important;
        font-family:inherit;
        font-size:16px !important;
        line-height:1.4;
        resize:none;
        overflow-y:auto;
        outline:none;
    }

    .mobile-chat-composer textarea:focus{
        border-color:#60a5fa !important;
        box-shadow:0 0 0 3px rgba(96,165,250,.18) !important;
    }

    .mobile-chat-composer button{
        position:absolute;
        right:4px;
        bottom:4px;
        min-width:66px;
        min-height:36px;
        padding:6px 11px;
        border:0;
        border-radius:22px;
        background:#16a34a;
        color:#fff;
        font-family:inherit;
        font-size:13px;
        font-weight:900;
    }

    .app{
        display:block !important;
        width:100% !important;
        max-width:none !important;
        margin:0 !important;
        padding:0 !important;
    }

    .preview-side{
        position:fixed !important;
        top:0 !important;
        left:0 !important;
        right:0 !important;
        width:100% !important;
        height:var(--mobile-preview-height) !important;
        min-height:240px !important;
        max-height:400px !important;
        z-index:9000 !important;
        padding:7px 8px 9px !important;
        background:
            radial-gradient(circle at 20% 0%,rgba(219,234,254,.55),transparent 38%),
            linear-gradient(180deg,#eaf3ff 0%,#dbe7f5 100%) !important;
        border-bottom:1px solid rgba(148,163,184,.36) !important;
        box-shadow:0 14px 30px rgba(15,23,42,.14) !important;
        overflow:hidden !important;
        align-items:center !important;
        justify-content:center !important;
    }

    .canvas-box{
        width:100% !important;
        height:100% !important;
        min-height:0 !important;
        padding:0 !important;
        border-radius:16px;
        background:rgba(255,255,255,.54);
        border:1px solid rgba(255,255,255,.75);
        box-shadow:inset 0 1px 0 rgba(255,255,255,.65),0 10px 28px rgba(15,23,42,.10);
        overflow:hidden;
    }

    canvas{
        max-width:calc(100vw - 20px) !important;
        max-height:calc(var(--mobile-preview-height) - 20px) !important;
        width:auto !important;
        height:auto !important;
        border-radius:12px !important;
        box-shadow:0 8px 24px rgba(15,23,42,.16) !important;
        touch-action:none !important;
        background:#fff !important;
    }

    .menu-side{
        width:100% !important;
        padding:7px 7px 0 !important;
    }

    .panel{
        width:100% !important;
        padding:8px !important;
        border:0 !important;
        border-radius:18px 18px 0 0 !important;
        background:rgba(255,255,255,.92) !important;
        box-shadow:0 -8px 28px rgba(15,23,42,.08) !important;
    }

    .panel h2{
        position:relative !important;
        top:auto !important;
        z-index:auto !important;
        margin:0 0 8px !important;
        padding:8px 9px !important;
        border-radius:14px !important;
        background:rgba(255,255,255,.92) !important;
        border:1px solid rgba(219,234,254,.95) !important;
        box-shadow:0 8px 18px rgba(15,23,42,.08) !important;
        font-size:15px !important;
        backdrop-filter:blur(12px) saturate(140%);
    }

    .section-title{
        margin:10px 0 7px !important;
        padding:8px 9px !important;
        border:1px solid var(--mobile-line) !important;
        border-radius:14px !important;
        background:linear-gradient(180deg,#ffffff,#f8fbff) !important;
        box-shadow:0 8px 18px rgba(15,23,42,.055) !important;
        color:#0f172a !important;
        font-size:13px !important;
    }

    .quick-anchor{
        scroll-margin-top:calc(var(--mobile-preview-height) + 16px) !important;
    }

    .group{
        margin-bottom:8px !important;
        padding:7px 8px !important;
        border:1px solid rgba(226,232,240,.9) !important;
        border-radius:14px !important;
        background:#ffffff !important;
        box-shadow:0 5px 16px rgba(15,23,42,.045) !important;
    }

    .row,
    .row-3{
        display:grid !important;
        grid-template-columns:1fr 1fr !important;
        gap:7px !important;
    }

    .row-3{
        grid-template-columns:1fr 1fr 1fr !important;
    }

    label{
        margin-bottom:4px !important;
        color:#1e293b !important;
        font-size:12px !important;
        line-height:1.35 !important;
    }

    input[type="text"],
    input[type="number"],
    textarea,
    select{
        min-height:40px !important;
        border-radius:11px !important;
        border-color:#dbe7f5 !important;
        background:#fbfdff !important;
        font-size:16px !important;
        padding:8px 10px !important;
        box-shadow:inset 0 1px 0 rgba(255,255,255,.8) !important;
    }

    textarea{
        min-height:88px !important;
        line-height:1.55 !important;
    }

    select{
        appearance:none;
        background-image:linear-gradient(45deg,transparent 50%,#2563eb 50%),linear-gradient(135deg,#2563eb 50%,transparent 50%);
        background-position:calc(100% - 18px) 20px,calc(100% - 12px) 20px;
        background-size:6px 6px,6px 6px;
        background-repeat:no-repeat;
        padding-right:34px !important;
    }

    input[type="color"]{
        width:48px !important;
        height:48px !important;
        border-radius:50% !important;
    }

    input[type="range"]{
        height:24px !important;
        accent-color:var(--mobile-blue);
    }

    .btn{
        min-height:40px !important;
        border-radius:12px !important;
        padding:7px 9px !important;
        font-size:13px !important;
        line-height:1.25 !important;
        display:flex !important;
        align-items:center !important;
        justify-content:center !important;
        gap:6px !important;
        background:linear-gradient(180deg,#eaf3ff,#dbeafe) !important;
        color:#1e40af !important;
        border:1px solid #bfdbfe !important;
        box-shadow:0 5px 14px rgba(37,99,235,.08) !important;
    }

    .btn.small{
        min-height:36px !important;
        font-size:12px !important;
        padding:8px 9px !important;
    }

    .btn:active,
    .quick-menu button:active{
        transform:scale(.985);
    }

    .menu-icon{
        width:28px !important;
        height:28px !important;
        min-width:28px !important;
        border-radius:10px !important;
    }

    .layer-list,
    .txt-list{
        max-height:190px !important;
        border-radius:16px !important;
        padding:8px !important;
        background:#f8fbff !important;
        border-color:#e2e8f0 !important;
    }

    .layer-item,
    .txt-item{
        min-height:64px !important;
        padding:9px !important;
        border-radius:14px !important;
        background:#fff !important;
    }

    .layer-thumb{
        width:54px !important;
        height:46px !important;
        border-radius:12px !important;
    }

    .layer-name,
    .txt-name{
        font-size:13px !important;
    }

    .layer-sub,
    .txt-sub,
    .help{
        font-size:12px !important;
        color:var(--mobile-muted) !important;
    }

    .help{
        padding:0 4px !important;
        line-height:1.55 !important;
    }

    .status-box{
        border-radius:14px !important;
        padding:10px 12px !important;
    }

    body > .quick-menu{
        top:auto !important;
        bottom:0 !important;
        left:0 !important;
        right:0 !important;
        width:100vw !important;
        height:calc(var(--mobile-bottom-menu-height) + env(safe-area-inset-bottom)) !important;
        padding:6px 6px calc(6px + env(safe-area-inset-bottom)) !important;
        border-top:1px solid rgba(219,234,254,.46) !important;
        border-bottom:0 !important;
        background:rgba(15,23,42,.96) !important;
        box-shadow:0 -12px 30px rgba(15,23,42,.26) !important;
        backdrop-filter:blur(14px) saturate(140%) !important;
        gap:6px !important;
        overflow:hidden !important;
    }

    .quick-menu-title{
        display:none !important;
    }

    .quick-menu-title .menu-icon{
        width:26px !important;
        height:26px !important;
        min-width:26px !important;
    }

    .quick-menu-grid{
        width:100% !important;
        height:auto !important;
        padding:0 !important;
        display:grid !important;
        grid-template-columns:repeat(3,minmax(0,1fr)) !important;
        grid-template-rows:repeat(3,40px) !important;
        gap:4px !important;
        overflow:visible !important;
        touch-action:manipulation;
    }

    .quick-menu .quick-menu-scroll-btn{
        display:none !important;
    }

    .quick-menu button{
        width:100% !important;
        min-width:0 !important;
        height:40px !important;
        padding:4px 6px !important;
        border-radius:13px !important;
        background:rgba(51,65,85,.92) !important;
        color:#eaf3ff !important;
        border:1px solid rgba(219,234,254,.20) !important;
        font-size:10.5px !important;
        line-height:1.08 !important;
        display:flex !important;
        flex-direction:column !important;
        align-items:center !important;
        justify-content:center !important;
        gap:3px !important;
        scroll-snap-align:start;
        box-shadow:none !important;
    }

    .quick-menu button i{
        margin:0 !important;
        font-size:15px !important;
    }

    .quick-menu-grid .mobile-refresh-grid-btn{
        display:flex !important;
        width:40px !important;
        min-width:40px !important;
        justify-self:center !important;
        border-radius:50% !important;
        background:#2563eb !important;
        color:#ffffff !important;
        border-color:#60a5fa !important;
    }

    .quick-menu-grid > button:nth-child(-n+4){
        min-width:0 !important;
        background:linear-gradient(180deg,#eff6ff,#dbeafe) !important;
        color:#1e40af !important;
        border-color:#bfdbfe !important;
        box-shadow:0 6px 16px rgba(37,99,235,.18) !important;
    }

    .quick-menu button:hover{
        background:#475569 !important;
        color:#ffffff !important;
    }

    .quick-menu-grid > button:nth-child(-n+4):hover{
        background:#bfdbfe !important;
        color:#1d4ed8 !important;
    }

    .sidebar-action-buttons{
        display:none !important;
    }

    .switch-row{
        min-height:44px !important;
        align-items:center !important;
        gap:9px !important;
        font-size:13px !important;
    }

    .switch-row input{
        width:22px !important;
        height:22px !important;
        accent-color:var(--mobile-blue);
    }

    .value-pill{
        padding:3px 9px !important;
        font-size:11px !important;
        background:#eaf3ff !important;
    }

    #removeBgBtn,
    button[onclick="downloadImage()"]{
        min-height:52px !important;
        font-size:14px !important;
        font-weight:900 !important;
    }

    .headline-legacy-hidden[hidden],
    [hidden]{
        display:none !important;
    }
}

@media(max-width:430px){
    :root{
        --mobile-preview-height:34svh;
        --mobile-bottom-menu-height:140px;
    }
    .preview-side{min-height:220px !important}
    .row-3{grid-template-columns:1fr !important}
    .row{grid-template-columns:1fr 1fr !important}
    .btn{min-height:38px !important}
    .quick-menu button{min-width:0 !important;font-size:9.5px !important}
    .quick-menu-grid > button:nth-child(-n+4){min-width:0 !important}
}

@media(max-width:360px){
    .row{grid-template-columns:1fr !important}
    .preview-side{min-height:280px !important}
}



/* =========================================================
   TEMPLATE DATABASE MANAGER
   ========================================================= */
.template-manager{
    border:1px solid #dbeafe;
    border-radius:16px;
    padding:12px;
    margin:12px 0 16px;
    background:linear-gradient(180deg,#f8fbff,#ffffff);
}
.template-toolbar{
    display:grid;
    grid-template-columns:minmax(0,1fr) auto;
    gap:9px;
    align-items:end;
}
.template-actions{
    display:grid;
    grid-template-columns:repeat(3,minmax(0,1fr));
    gap:8px;
    margin-top:9px;
}
.template-current{
    display:none;
    margin-top:9px;
    padding:8px 10px;
    border-radius:11px;
    background:#eff6ff;
    color:#1e40af;
    font-size:12px;
    font-weight:700;
}
.template-current.show{display:block}
.template-list{
    display:flex;
    flex-direction:column;
    gap:9px;
    max-height:390px;
    margin-top:10px;
    overflow:auto;
}
.template-empty{
    padding:16px 10px;
    border:1px dashed #bfdbfe;
    border-radius:13px;
    text-align:center;
    color:#64748b;
    font-size:13px;
}
.template-item{
    display:grid;
    grid-template-columns:76px minmax(0,1fr);
    gap:10px;
    padding:9px;
    border:1px solid #e2e8f0;
    border-radius:14px;
    background:#fff;
}
.template-item.active{
    border-color:#60a5fa;
    box-shadow:0 0 0 3px rgba(96,165,250,.13);
}
.template-preview{
    width:76px;
    height:88px;
    object-fit:cover;
    border-radius:10px;
    background:#e2e8f0;
    border:1px solid #dbeafe;
}
.template-preview.placeholder{
    display:flex;
    align-items:center;
    justify-content:center;
    color:#64748b;
    font-size:22px;
}
.template-info{min-width:0}
.template-name{
    font-size:14px;
    font-weight:850;
    color:#0f172a;
    white-space:nowrap;
    overflow:hidden;
    text-overflow:ellipsis;
}
.template-meta{
    margin-top:3px;
    color:#64748b;
    font-size:11px;
    line-height:1.45;
}
.template-item-actions{
    display:grid;
    grid-template-columns:1fr 1fr;
    gap:7px;
    margin-top:8px;
}
.template-item-actions .btn{
    min-height:36px;
    padding:7px 8px;
    font-size:12px !important;
}
.template-item{cursor:pointer}
.template-item:focus-visible{
    outline:3px solid rgba(37,99,235,.28);
    outline-offset:2px;
}
.template-loading{
    opacity:.65;
    pointer-events:none;
}
@media(max-width:1000px){
    .template-manager{padding:10px;margin-bottom:14px}
    .template-toolbar{grid-template-columns:1fr}
    .template-actions{grid-template-columns:1fr 1fr 1fr}
    .template-list{max-height:330px}
}
@media(max-width:430px){
    .template-actions{grid-template-columns:1fr}
    .template-item{grid-template-columns:66px minmax(0,1fr)}
    .template-preview{width:66px;height:78px}
}


/* Download button in the main quick menu */
.quick-menu .quick-download-btn{
    background:linear-gradient(135deg,#16a34a,#15803d) !important;
    color:#ffffff !important;
    border-color:#4ade80 !important;
    box-shadow:0 5px 14px rgba(22,163,74,.24) !important;
}
.quick-menu .quick-download-btn:hover{
    background:linear-gradient(135deg,#15803d,#166534) !important;
    color:#ffffff !important;
    border-color:#86efac !important;
}
@media(max-width:1000px){
    .quick-menu .quick-download-btn{
        background:linear-gradient(180deg,#22c55e,#16a34a) !important;
        color:#ffffff !important;
        border-color:#4ade80 !important;
    }
}



/* =========================================================
   IMAGE ERASER TOOL
   ========================================================= */
.eraser-tool-card{
    border-color:#bfdbfe !important;
    background:linear-gradient(180deg,#eff6ff,#ffffff) !important;
}
.eraser-actions{
    display:grid;
    grid-template-columns:1fr 1fr;
    gap:8px;
    margin-top:9px;
}
#eraserToggleBtn.is-active,
#quickEraserBtn.is-active,
#blurRegionToggleBtn.is-active,
#quickBlurRegionBtn.is-active{
    background:#2563eb !important;
    color:#ffffff !important;
    border-color:#1d4ed8 !important;
    box-shadow:0 6px 16px rgba(37,99,235,.22) !important;
}
#eraserToggleBtn.is-active:hover,
#quickEraserBtn.is-active:hover,
#blurRegionToggleBtn.is-active:hover,
#quickBlurRegionBtn.is-active:hover{
    background:#1d4ed8 !important;
    color:#ffffff !important;
}
#eraserStatus,
#blurRegionStatus{
    margin-top:9px;
}
canvas.eraser-mode{
    cursor:crosshair !important;
}
@media(max-width:1000px){
    .eraser-actions{grid-template-columns:1fr 1fr}
    #eraserToggleBtn,#eraserUndoBtn,#eraserRestoreBtn,
    #blurRegionToggleBtn,#blurRegionUndoBtn,#blurRegionClearBtn{min-height:42px !important}
}
