:root {
    --bk-malis-maroon: #7d1f20;
    --bk-malis-maroon-dark: #561516;
    --bk-malis-gold: #b98237;
    --bk-malis-cream: #fffaf1;
    --bk-malis-cream-deep: #f5ead7;
    --bk-malis-ink: #38241f;
    --bk-malis-muted: #705950;
    --bk-malis-border: rgba(125, 31, 32, 0.16);
}

.bk-malis {
    position: fixed;
    right: 20px;
    bottom: max(0px, env(safe-area-inset-bottom));
    z-index: 99990;
    color: var(--bk-malis-ink);
    line-height: 1.45;
    text-align: left;
    font-family: Georgia, "Times New Roman", serif;
}

.bk-malis, .bk-malis * { box-sizing: border-box; }
.bk-malis button, .bk-malis a { font: inherit; }

.bk-malis-launcher {
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 70px;
    margin-left: auto;
    padding: 4px 16px 4px 4px;
    border: 1px solid rgba(185, 130, 55, .58);
    border-radius: 999px;
    background: rgba(255, 250, 241, .98);
    box-shadow: 0 10px 30px rgba(70, 32, 25, .19);
    color: var(--bk-malis-maroon-dark);
    cursor: pointer;
    transition: transform .18s ease, box-shadow .18s ease, opacity .18s ease;
}

.bk-malis-launcher:hover,
.bk-malis-launcher:focus-visible {
    transform: translateY(-2px);
    box-shadow: 0 14px 34px rgba(70, 32, 25, .25);
    outline: none;
}

.bk-malis-launcher-avatar {
    width: 62px;
    height: 62px;
    flex: 0 0 62px;
    overflow: hidden;
    border-radius: 50%;
    background: #f4ecdc;
    box-shadow: inset 0 0 0 1px rgba(255,255,255,.72), 0 0 0 1px rgba(185,130,55,.44);
}

.bk-malis-launcher-avatar img {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: cover;
    object-position: center center;
}

.bk-malis-launcher-copy {
    display: flex;
    min-width: 106px;
    flex-direction: column;
}

.bk-malis-launcher-copy strong {
    font-size: 19px;
    line-height: 1.08;
    letter-spacing: .01em;
}

.bk-malis-launcher-copy small {
    margin-top: 2px;
    color: var(--bk-malis-muted);
    font-family: Arial, Helvetica, sans-serif;
    font-size: 11px;
    line-height: 1.2;
}

.bk-malis.is-open .bk-malis-launcher {
    opacity: 0;
    pointer-events: none;
    transform: translateY(8px);
}

.bk-malis-panel {
    position: absolute;
    right: 0;
    bottom: 0;
    width: min(735px, calc(100vw - 20px));
    min-height: 560px;
    pointer-events: none;
}

.bk-malis-panel[hidden] { display: none !important; }

.bk-malis.is-open .bk-malis-panel { bottom: 0; }

.bk-malis-character {
    position: absolute;
    left: -34px;
    bottom: 0;
    width: 398px;
    height: 610px;
    z-index: 2;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    pointer-events: none;
    filter: drop-shadow(0 18px 22px rgba(54, 26, 19, .18));
}

.bk-malis-character img {
    display: block;
    width: auto;
    max-width: 100%;
    height: 100%;
    object-fit: contain;
    object-position: center bottom;
}


/* Route-specific character positioning */
.bk-malis.bk-route-home .bk-malis-character {
    left: -8px;
    width: 418px;
}
.bk-malis.bk-route-gallery .bk-malis-character,
.bk-malis.bk-route-news .bk-malis-character,
.bk-malis.bk-route-articles .bk-malis-character {
    left: -10px;
    width: 414px;
}

.bk-malis-card {
    position: absolute;
    right: 0;
    bottom: 0;
    width: 455px;
    overflow: hidden;
    border: 1px solid rgba(185, 130, 55, .62);
    border-radius: 22px;
    background: var(--bk-malis-cream);
    box-shadow: 0 20px 56px rgba(55, 27, 22, .28);
    pointer-events: auto;
}

.bk-malis-panel-top {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto 30px;
    align-items: center;
    gap: 10px;
    min-height: 70px;
    padding: 13px 14px 12px 25px;
    background: linear-gradient(135deg, var(--bk-malis-maroon), var(--bk-malis-maroon-dark));
    color: #fff8ed;
}

.bk-malis-identity { min-width: 0; }
.bk-malis-identity strong {
    display: block;
    color: #fffaf2;
    font-size: 24px;
    line-height: 1;
}
.bk-malis-identity small {
    display: block;
    margin-top: 5px;
    color: rgba(255,250,242,.78);
    font-family: Arial, Helvetica, sans-serif;
    font-size: 11px;
    letter-spacing: .02em;
}

.bk-malis-language {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 6px;
    border: 1px solid rgba(255,250,242,.22);
    border-radius: 999px;
    background: rgba(255,255,255,.08);
    font-family: Arial, Helvetica, sans-serif;
    font-size: 11px;
}

.bk-malis-language button {
    padding: 4px 7px;
    border: 0;
    border-radius: 999px;
    background: transparent;
    color: rgba(255,250,242,.72);
    cursor: pointer;
}
.bk-malis-language button.is-active {
    background: #fff8ed;
    color: var(--bk-malis-maroon-dark);
    font-weight: 700;
}
.bk-malis-language span { color: rgba(255,255,255,.30); }

.bk-malis-x {
    width: 30px;
    height: 30px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: rgba(255,255,255,.84);
    font-family: Arial, Helvetica, sans-serif !important;
    font-size: 25px !important;
    line-height: 28px !important;
    cursor: pointer;
}
.bk-malis-x:hover,
.bk-malis-x:focus-visible { background: rgba(255,255,255,.12); color: #fff; outline: none; }

.bk-malis-body {
    position: relative;
    min-height: 292px;
    padding: 24px 22px 18px 158px;
    background: radial-gradient(circle at 95% 0%, rgba(185,130,55,.12), transparent 37%), var(--bk-malis-cream);
}

.bk-malis-eyebrow {
    margin-bottom: 7px;
    color: var(--bk-malis-gold);
    font-family: Arial, Helvetica, sans-serif;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: .12em;
    text-transform: uppercase;
}

.bk-malis-body h2 {
    margin: 0 0 9px;
    color: var(--bk-malis-maroon-dark);
    font-size: 25px;
    line-height: 1.12;
    font-weight: 600;
}

.bk-malis-message {
    margin: 0;
    color: #513a32;
    font-family: Arial, Helvetica, sans-serif;
    font-size: 14px;
    line-height: 1.58;
}

.bk-malis-cta {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    margin-top: 16px;
    padding: 9px 13px;
    border: 1px solid rgba(125,31,32,.16);
    border-radius: 999px;
    background: #fffdf8;
    color: var(--bk-malis-maroon-dark);
    font-family: Arial, Helvetica, sans-serif;
    font-size: 12px;
    font-weight: 700;
    text-decoration: none;
}
.bk-malis-cta:hover,
.bk-malis-cta:focus-visible { border-color: rgba(125,31,32,.32); background: #fff8ed; outline: none; }
.bk-malis-cta b { color: var(--bk-malis-gold); font-size: 16px; }

.bk-malis-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 10px 13px 10px 156px;
    border-top: 1px solid var(--bk-malis-border);
    background: #f8efdf;
}
.bk-malis-footer button { border: 0; background: transparent; cursor: pointer; }
.bk-malis-auto {
    padding: 5px 0;
    color: var(--bk-malis-muted);
    font-family: Arial, Helvetica, sans-serif !important;
    font-size: 11px !important;
    text-decoration: underline;
    text-underline-offset: 2px;
}
.bk-malis-close {
    padding: 7px 12px !important;
    border: 1px solid rgba(125,31,32,.18) !important;
    border-radius: 999px;
    background: #fffaf2 !important;
    color: var(--bk-malis-maroon-dark);
    font-family: Arial, Helvetica, sans-serif !important;
    font-size: 12px !important;
    font-weight: 700 !important;
}

.bk-malis-khmer,
.bk-malis-khmer button,
.bk-malis-khmer .bk-malis-message,
.bk-malis-khmer .bk-malis-identity small,
.bk-malis-khmer .bk-malis-launcher-copy small,
.bk-malis-khmer .bk-malis-cta {
    font-family: "Noto Serif Khmer", "Noto Sans Khmer", "Khmer OS System", "Leelawadee UI", sans-serif;
}
.bk-malis-khmer .bk-malis-body h2 { font-size: 21px; line-height: 1.55; }
.bk-malis-khmer .bk-malis-message { line-height: 1.8; }

@media (max-width: 720px) {
    .bk-malis { right: 10px; bottom: max(0px, env(safe-area-inset-bottom)); }
    .bk-malis-launcher { min-height: 62px; padding: 4px 12px 4px 4px; }
    .bk-malis-launcher-avatar { width: 56px; height: 56px; flex-basis: 56px; }
    .bk-malis-panel {
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        width: 100vw;
        max-width: none;
        min-height: 0;
        padding: 0;
    }
    .bk-malis-card {
        width: 100%;
        border-radius: 18px 18px 0 0;
        border-bottom: 0;
        box-shadow: 0 -10px 35px rgba(55, 27, 22, .22);
    }
    .bk-malis-character {
        left: 6px;
        bottom: 44px;
        width: 158px;
        height: 286px;
        z-index: 3;
    }
    .bk-malis-panel-top { min-height: 64px; padding: 11px 10px 10px 15px; gap: 7px; }
    .bk-malis-identity strong { font-size: 21px; }
    .bk-malis-language { font-size: 10px; }
    .bk-malis-body { min-height: 232px; padding: 18px 15px 16px 148px; }
    .bk-malis-body h2 { font-size: 21px; }
    .bk-malis-message { font-size: 13px; line-height: 1.5; }
    .bk-malis-cta { margin-top: 12px; padding: 8px 11px; }
    .bk-malis-footer { padding: 9px 10px calc(9px + env(safe-area-inset-bottom)) 148px; }
}

@media (max-width: 390px) {
    .bk-malis-launcher-copy { display: none; }
    .bk-malis-launcher { padding-right: 6px; }
    .bk-malis-character { width: 130px; height: 242px; bottom: 42px; }
    .bk-malis-body { padding-left: 122px; }
    .bk-malis-footer { padding-left: 122px; }
    .bk-malis-auto { font-size: 10px !important; }
}

@media (prefers-reduced-motion: reduce) {
    .bk-malis-launcher { transition: none; }
}
