/* =================================================================
   RadioMonster AI Chat Widget — Styles
   ================================================================= */

/* ─── CSS Custom Properties (Theming) ─── */
.rm-chat {
    --rm-chat-primary: #5cb13e;
    --rm-chat-primary-dark: #4a9632;
    --rm-chat-bg: #ffffff;
    --rm-chat-surface: #f4f5f7;
    --rm-chat-text: #1a1a1a;
    --rm-chat-text-muted: #6b7280;
    --rm-chat-border: #e5e7eb;
    --rm-chat-user-bg: var(--rm-chat-primary);
    --rm-chat-user-text: #ffffff;
    --rm-chat-bot-bg: var(--rm-chat-surface);
    --rm-chat-bot-text: var(--rm-chat-text);
    --rm-chat-radius: 12px;
    --rm-chat-shadow: 0 8px 30px rgba(0, 0, 0, 0.12);
    --rm-chat-z: 2147483647;
    --rm-chat-width: 380px;
    --rm-chat-height: 560px;

    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    position: fixed;
    bottom: var(--rm-chat-desktop-bottom, 80px);
    z-index: var(--rm-chat-z);
    box-sizing: border-box;
    /* Contain to bubble size when closed — prevent invisible overlap */
    width: auto;
    height: auto;
    pointer-events: none;
}

/* Re-enable pointer events on interactive children */
.rm-chat__bubble-wrap,
.rm-chat__bubble,
.rm-chat__window,
.rm-chat__backdrop {
    pointer-events: auto;
}

.rm-chat *,
.rm-chat *::before,
.rm-chat *::after {
    box-sizing: border-box;
}

/* Position */
.rm-chat[data-pos="right"] { right: 24px; }
.rm-chat[data-pos="left"]  { left: 24px; }

/* ─── Bubble Wrapper ─── */
.rm-chat__bubble-wrap {
    position: relative;
    display: inline-flex;
    flex-direction: column;
    align-items: flex-end;
    padding: 6px; /* breathing room for pulse/hover scale + drop-shadow */
    margin: -6px;
}

/* ─── Bubble (transparent button, img is the visible shape) ─── */
.rm-chat__bubble {
    position: relative;
    z-index: 3;
    width: 53px;
    height: 53px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: visible;
    flex-shrink: 0;
    transition: transform 0.25s ease;
    -webkit-tap-highlight-color: transparent;
    animation: rm-bubble-pulse 0.8s ease-in-out 3;
}

@keyframes rm-bubble-pulse {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-6px); }
}

.rm-chat__bubble::before,
.rm-chat__bubble::after {
    display: none !important;
    content: none !important;
}

.rm-chat__bubble-img {
    width: 100%;
    height: 100%;
    display: block;
    pointer-events: none;
    object-fit: contain;
    filter:
        drop-shadow( 2px  0   0 #fff)
        drop-shadow(-2px  0   0 #fff)
        drop-shadow( 0    2px 0 #fff)
        drop-shadow( 0   -2px 0 #fff);
    transition: filter 0.25s ease;
}

/* Mirror for left-position: flip horizontally */
.rm-chat[data-pos="left"] .rm-chat__bubble-img {
    transform: scaleX(-1);
}

/* ─── Label tag (overlapping badge — white bg, green border + text) ─── */
.rm-chat__bubble-tag {
    position: relative;
    z-index: 1;
    margin-top: -3px;
    background: #fff;
    color: var(--rm-chat-primary);
    font-family: inherit;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.5px;
    padding: 4px 14px;
    border-radius: 12px;
    border: 2px solid var(--rm-chat-primary);
    box-shadow: 0 0 0 3px #fff;
    cursor: pointer;
    white-space: nowrap;
    pointer-events: auto;
    user-select: none;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

/* Hover on bubble + tag only — excludes hint from triggering */
.rm-chat__bubble-wrap:not(:has(.rm-chat__bubble-hint:hover)):hover .rm-chat__bubble {
    transform: translateY(-3px) scale(1.08);
}

.rm-chat__bubble-wrap:not(:has(.rm-chat__bubble-hint:hover)):hover .rm-chat__bubble-img {
    filter:
        drop-shadow( 3px  0   0 #fff)
        drop-shadow(-3px  0   0 #fff)
        drop-shadow( 0    3px 0 #fff)
        drop-shadow( 0   -3px 0 #fff);
}

.rm-chat__bubble-wrap:not(:has(.rm-chat__bubble-hint:hover)):hover .rm-chat__bubble-tag {
    transform: translateY(1px) scale(1.06);
    box-shadow: 0 0 0 4px #fff;
}

.rm-chat__bubble-wrap:not(:has(.rm-chat__bubble-hint:hover)):active .rm-chat__bubble {
    transform: translateY(0) scale(0.96);
}

.rm-chat__bubble--hidden {
    opacity: 0;
    transform: scale(0);
    pointer-events: none;
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.rm-chat__bubble-wrap {
    transition: opacity 0.2s ease, transform 0.2s ease;
}

/* ─── Bubble Hint (speech-bubble above tag, left of bubble) ─── */
.rm-chat__bubble-hint {
    position: absolute;
    right: 80px; /* ~28px gap to bubble left edge (bubble=53px) */
    bottom: 44px; /* gap above the tag, accounting for bubble-wrap padding */
    display: block;
    background: var(--rm-chat-primary);
    color: #fff;
    font-size: 13px;
    font-weight: 500;
    line-height: 1.3;
    padding: 8px 12px;
    border-radius: 10px;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.15);
    max-width: 220px;
    width: max-content;
    pointer-events: auto;
    animation: rm-hint-in 0.4s ease;
    cursor: pointer;
    transition: filter 0.15s ease, transform 0.15s ease;
    z-index: 2;
}

.rm-chat__bubble-hint:hover {
    filter: brightness(1.12);
    transform: translateY(-2px);
}

/* Speech-bubble tail pointing down toward the tag */
.rm-chat__bubble-hint::after {
    content: '';
    position: absolute;
    bottom: -7px;
    right: 14px;
    width: 0;
    height: 0;
    border-left: 7px solid transparent;
    border-right: 7px solid transparent;
    border-top: 7px solid var(--rm-chat-primary);
}

/* Left position: hint floats above tag, right of bubble */
.rm-chat[data-pos="left"] .rm-chat__bubble-hint {
    right: auto;
    left: 80px;
}

.rm-chat[data-pos="left"] .rm-chat__bubble-hint::after {
    right: auto;
    left: 14px;
}

.rm-chat__bubble-hint-text {
    display: inline;
}

.rm-chat .rm-chat__bubble-hint-close,
.rm-chat .rm-chat__bubble-hint-close:hover,
.rm-chat .rm-chat__bubble-hint-close:focus {
    position: static !important;
    float: right !important;
    background: none !important;
    background-color: transparent !important;
    border: none !important;
    box-shadow: none !important;
    outline: none !important;
    color: rgba(255, 255, 255, 0.7) !important;
    font-size: 15px !important;
    line-height: 1 !important;
    cursor: pointer !important;
    padding: 0 !important;
    margin: -2px -4px 2px 6px !important;
    width: 16px !important;
    height: 16px !important;
    min-width: 0 !important;
    min-height: 0 !important;
    max-width: 16px !important;
    max-height: 16px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    text-transform: none !important;
    letter-spacing: normal !important;
    text-decoration: none !important;
    transition: color 0.15s !important;
}

.rm-chat .rm-chat__bubble-hint-close:hover {
    color: #fff !important;
}

.rm-chat__bubble-hint--hidden {
    opacity: 0;
    transform: translateY(8px) scale(0.9);
    transition: opacity 0.3s ease, transform 0.3s ease;
}

@keyframes rm-hint-in {
    0% { opacity: 0; transform: translateY(8px) scale(0.9); }
    100% { opacity: 1; transform: translateY(0) scale(1); }
}

/* ─── Unread Badge (red, top corner of bubble) ─── */
.rm-chat__bubble-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    min-width: 22px;
    height: 22px;
    padding: 0 6px;
    border-radius: 11px;
    background: #e53e3e;
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    line-height: 22px;
    text-align: center;
    box-shadow: 0 2px 6px rgba(229, 62, 62, 0.4);
    pointer-events: none;
    z-index: 3;
    animation: rm-badge-pop 0.3s ease, rm-badge-pulse 2s ease-in-out 0.3s infinite;
}

@keyframes rm-badge-pop {
    0% { transform: scale(0); }
    60% { transform: scale(1.2); }
    100% { transform: scale(1); }
}

@keyframes rm-badge-pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.15); }
}

.rm-chat__bubble-dots {
    display: none;
}

.rm-chat__bubble svg {
    display: none;
}

/* ─── Window ─── */
.rm-chat__window {
    display: flex;
    flex-direction: column;
    width: var(--rm-chat-width);
    height: var(--rm-chat-height);
    max-height: calc(100dvh - 100px);
    background: var(--rm-chat-bg);
    border-radius: var(--rm-chat-radius);
    box-shadow: var(--rm-chat-shadow);
    overflow: hidden;
    position: absolute;
    bottom: 80px;
    z-index: 2;
    opacity: 0;
    transform: scale(0.3);
    pointer-events: none;
    transition: opacity 0.25s ease, transform 0.25s ease;
}

.rm-chat[data-pos="right"] .rm-chat__window {
    right: 0;
    transform-origin: bottom right;
}
.rm-chat[data-pos="left"] .rm-chat__window {
    left: 0;
    transform-origin: bottom left;
}

.rm-chat--open .rm-chat__window {
    opacity: 1;
    transform: scale(1);
    pointer-events: auto;
}

/* ─── Backdrop (mobile only, blocks touches above chat) ─── */
.rm-chat__backdrop {
    display: none;
}

/* ─── Header ─── */
.rm-chat__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px 10px 23px;
    background: var(--rm-chat-primary);
    color: #fff;
    flex-shrink: 0;
    position: relative;
}

.rm-chat__header::after {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    top: 100%;
    height: 10px;
    background: linear-gradient(to bottom, var(--rm-chat-bg), transparent);
    pointer-events: none;
    z-index: 1;
}

.rm-chat__header-title {
    font-weight: 600;
    font-size: 15px;
}

.rm-chat__header-close {
    background: none;
    border: none;
    color: #fff;
    cursor: pointer;
    padding: 4px;
    line-height: 0;
    opacity: 0.8;
    transition: opacity 0.15s;
}

.rm-chat__header-close:hover {
    opacity: 1;
}

/* ─── Takeover Bar ─── */
.rm-chat__takeover-bar {
    padding: 8px 16px;
    background: #dcfce7;
    color: #166534;
    font-size: 13px;
    font-weight: 500;
    flex-shrink: 0;
    position: relative;
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}
.rm-chat__pulse-dot--active {
    background: #22c55e;
    animation: none;
    opacity: 1;
}

/* ─── Contact Request Bar ─── */
.rm-chat__contact-request-bar {
    padding: 8px 16px;
    background: #dbeafe;
    color: #1e40af;
    font-size: 13px;
    font-weight: 500;
    text-align: center;
    flex-shrink: 0;
    position: relative;
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    flex-wrap: wrap;
}
.rm-chat__pulse-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #22c55e;
    animation: rm-pulse 1.5s ease-in-out infinite;
    flex-shrink: 0;
}
@keyframes rm-pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: .4; transform: scale(1.4); }
}
.rm-chat__contact-timer {
    font-size: 12px;
    font-weight: 400;
    opacity: .7;
}

.rm-chat__quip-text {
    transition: opacity .4s ease;
}
.rm-chat__quip-text--fade {
    opacity: 0;
}

.rm-chat__contact-cancel-btn {
    background: none;
    border: 1px solid #1e40af;
    color: #1e40af;
    border-radius: 4px;
    padding: 2px 8px;
    font-size: 12px;
    cursor: pointer;
    margin-left: 4px;
}
.rm-chat__contact-cancel-btn:hover {
    background: #1e40af;
    color: #fff;
}

/* ─── Contact Form (inline name + email) ─── */
.rm-chat__contact-form {
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
    border-radius: 12px;
    padding: 14px 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-width: 100%;
}
.rm-chat__contact-form-title {
    font-weight: 600;
    font-size: 13px;
    color: #166534;
}
.rm-chat__contact-form-desc {
    font-size: 13px;
    color: #4b5563;
    line-height: 1.4;
}
.rm-chat__contact-input {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 13px;
    font-family: inherit;
    outline: none;
    box-sizing: border-box;
    transition: border-color .15s;
}
.rm-chat__contact-input:focus {
    border-color: #5cb13e;
    box-shadow: 0 0 0 2px rgba(92, 177, 62, .15);
}
.rm-chat__contact-form-btns {
    display: flex;
    gap: 8px;
    margin-top: 2px;
}
.rm-chat__contact-submit-btn {
    flex: 1;
    padding: 7px 0;
    background: #5cb13e;
    color: #fff;
    border: none;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: background .15s;
}
.rm-chat__contact-submit-btn:hover {
    background: #4a9a2e;
}
.rm-chat__contact-submit-btn:disabled {
    opacity: .6;
    cursor: default;
}
.rm-chat__contact-skip-btn {
    padding: 7px 14px;
    background: transparent;
    color: #6b7280;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 13px;
    cursor: pointer;
    transition: background .15s;
}
.rm-chat__contact-skip-btn:hover {
    background: #f3f4f6;
}
.rm-chat__contact-form-done {
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
    border-radius: 12px;
    padding: 12px 16px;
    font-size: 13px;
    color: #166534;
    line-height: 1.4;
}

/* ─── Email Re-Prompt Form ─── */
.rm-chat__email-prompt-form {
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
    border-radius: 12px;
    padding: 14px 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-width: 100%;
}
.rm-chat__email-prompt-form .rm-chat__contact-form-title {
    color: #166534;
}
.rm-chat__email-prompt-form .rm-chat__contact-form-done {
    background: #f0fdf4;
    border-color: #bbf7d0;
    color: #166534;
}

/* ─── Can't-wait link in takeover bar ─── */
.rm-chat__cant-wait-link {
    font-size: 11px;
    color: #6b7280;
    text-decoration: underline;
    margin-left: 4px;
    cursor: pointer;
}
.rm-chat__cant-wait-link:hover {
    color: #374151;
}

/* ─── Messages ─── */
.rm-chat__messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    scroll-behavior: smooth;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
}

.rm-chat__messages::-webkit-scrollbar {
    width: 6px;
}

.rm-chat__messages::-webkit-scrollbar-track {
    background: transparent;
}

.rm-chat__messages::-webkit-scrollbar-thumb {
    background: var(--rm-chat-border);
    border-radius: 3px;
}

/* ─── Message Bubbles ─── */
.rm-chat__msg {
    display: flex;
    max-width: 85%;
    animation: rm-chat-fade-in 0.2s ease;
}

.rm-chat__msg--user {
    align-self: flex-end;
}

.rm-chat__msg--assistant {
    align-self: flex-start;
}

.rm-chat__msg--system {
    align-self: center;
    max-width: 90%;
}

.rm-chat__msg-bubble {
    padding: 10px 14px;
    border-radius: 16px;
    word-break: break-word;
    overflow-wrap: break-word;
}

.rm-chat__msg--user .rm-chat__msg-bubble {
    background: var(--rm-chat-user-bg);
    color: var(--rm-chat-user-text);
    border-bottom-right-radius: 4px;
}

.rm-chat__msg--assistant .rm-chat__msg-bubble {
    background: var(--rm-chat-bot-bg);
    color: var(--rm-chat-bot-text);
    border-bottom-left-radius: 4px;
}

.rm-chat__msg--support {
    align-self: flex-start;
}

.rm-chat__msg--support .rm-chat__msg-bubble {
    background: #fef3c7;
    color: #92400e;
    border-bottom-left-radius: 4px;
    border-left: 3px solid #f59e0b;
}

/* Message content typography */
.rm-chat__msg-bubble p {
    margin: 0 0 8px 0;
}

.rm-chat__msg-bubble p:last-child {
    margin-bottom: 0;
}

.rm-chat__msg-bubble ul,
.rm-chat__msg-bubble ol {
    margin: 4px 0;
    padding-left: 20px;
}

.rm-chat__msg-bubble li {
    margin: 1px 0;
}

.rm-chat__msg-bubble li + li {
    margin-top: 2px;
}

.rm-chat__msg-bubble a {
    color: inherit;
    text-decoration: underline;
}

.rm-chat__msg-bubble code {
    background: rgba(0, 0, 0, 0.08);
    padding: 1px 4px;
    border-radius: 3px;
    font-size: 0.9em;
    font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
}

.rm-chat__msg-bubble pre {
    background: #1e1e1e;
    color: #d4d4d4;
    padding: 10px 12px;
    border-radius: 8px;
    overflow-x: auto;
    margin: 8px 0;
    font-size: 0.85em;
}

.rm-chat__msg-bubble pre code {
    background: none;
    padding: 0;
    color: inherit;
}

.rm-chat__msg-bubble ul,
.rm-chat__msg-bubble ol {
    margin: 4px 0 8px 0;
    padding-left: 20px;
}

.rm-chat__msg-bubble li {
    margin-bottom: 2px;
}

.rm-chat__msg-bubble strong {
    font-weight: 600;
}

/* System messages */
.rm-chat__msg-system {
    font-size: 12px;
    color: var(--rm-chat-text-muted);
    text-align: center;
    padding: 4px 12px;
    background: var(--rm-chat-surface);
    border-radius: 8px;
}

/* ─── Typing Indicator ─── */
.rm-chat__typing {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 12px 14px;
    background: var(--rm-chat-bot-bg);
    border-radius: 16px;
    border-bottom-left-radius: 4px;
    align-self: flex-start;
    width: fit-content;
}

.rm-chat__typing span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--rm-chat-text-muted);
    animation: rm-chat-typing 1.4s infinite both;
}

.rm-chat__typing span:nth-child(2) { animation-delay: 0.2s; }
.rm-chat__typing span:nth-child(3) { animation-delay: 0.4s; }

@keyframes rm-chat-typing {
    0%, 80%, 100% { opacity: 0.3; transform: scale(0.8); }
    40% { opacity: 1; transform: scale(1); }
}

/* ─── Function Call Indicator ─── */
.rm-chat__fn-indicator {
    font-size: 13px;
    color: var(--rm-chat-text-muted);
    padding: 6px 12px;
    background: var(--rm-chat-surface);
    border-radius: 8px;
    align-self: flex-start;
    animation: rm-chat-pulse 2s infinite;
}

@keyframes rm-chat-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* ─── Consent Overlay ─── */
.rm-chat__consent {
    position: absolute;
    inset: 0;
    top: 48px; /* below header */
    background: rgba(255, 255, 255, 0.96);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2;
    padding: 20px;
}

.rm-chat__consent-inner {
    text-align: left;
    max-width: 320px;
}

.rm-chat__consent-inner > div {
    font-size: 13px;
    color: var(--rm-chat-text-muted);
    margin: 0 0 16px 0;
    line-height: 1.6;
}

.rm-chat__consent-inner a {
    color: var(--rm-chat-primary);
    text-decoration: underline;
}

.rm-chat__consent-inner details {
    margin-top: 8px;
    font-size: 12px;
    line-height: 1.5;
}

.rm-chat__consent-inner summary {
    font-size: 13px;
    list-style: none;
}

.rm-chat__consent-inner summary::-webkit-details-marker {
    display: none;
}

.rm-chat__consent-btn {
    display: block;
    width: 100%;
    background: var(--rm-chat-primary);
    color: #fff;
    border: none;
    border-radius: 8px;
    padding: 10px 24px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s;
}

.rm-chat__consent-btn:hover {
    background: var(--rm-chat-primary-dark);
}

/* ─── Input Area ─── */
.rm-chat__input-wrap {
    display: flex;
    align-items: flex-end;
    padding: 10px 12px;
    border-top: 1px solid var(--rm-chat-border);
    gap: 8px;
    flex-shrink: 0;
    background: var(--rm-chat-surface);
    position: relative;
}

.rm-chat__input-wrap::before {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    bottom: 100%;
    height: 10px;
    background: linear-gradient(to top, var(--rm-chat-bg), transparent);
    pointer-events: none;
    z-index: 1;
}

.rm-chat__input {
    flex: 1;
    resize: none;
    border: 1px solid var(--rm-chat-border);
    border-radius: 10px;
    padding: 8px 12px;
    font-size: 14px;
    font-family: inherit;
    line-height: 1.4;
    max-height: 120px;
    overflow-y: hidden;
    outline: none;
    transition: border-color 0.15s;
    background: var(--rm-chat-bg);
    color: var(--rm-chat-text);
}

.rm-chat__input::-webkit-scrollbar {
    display: none;
}

.rm-chat__input:focus {
    border-color: var(--rm-chat-primary);
}

.rm-chat__input::placeholder {
    color: var(--rm-chat-text-muted);
}

.rm-chat__input:disabled {
    opacity: 0.6;
}

.rm-chat__send {
    all: unset;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--rm-chat-primary);
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background 0.15s;
    box-sizing: border-box;
}

.rm-chat__send:hover {
    background: var(--rm-chat-primary-dark);
}

.rm-chat__send--disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ─── Fade-in Animation ─── */
@keyframes rm-chat-fade-in {
    from {
        opacity: 0;
        transform: translateY(6px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ─── Mobile Responsive ─── */
@media (max-width: 768px) {
    .rm-chat__window {
        width: 100vw;
        height: 75dvh;
        max-height: none;
        bottom: 0;
        right: 0 !important;
        left: 0 !important;
        border-radius: var(--rm-chat-radius) var(--rm-chat-radius) 0 0;
    }

    .rm-chat__header {
        padding-top: calc(10px + env(safe-area-inset-top, 0px));
    }

    .rm-chat__header-title {
        font-size: 17px;
    }

    .rm-chat__header-close svg {
        width: 24px;
        height: 24px;
    }

    .rm-chat__input-wrap {
        border-radius: 0;
        padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px));
    }

    .rm-chat {
        bottom: var(--rm-chat-mobile-bottom, 70px);
        right: 15px !important;
        left: auto !important;
    }

    .rm-chat--open {
        bottom: 0;
        right: 0 !important;
        left: 0 !important;
        width: 100vw;
        height: auto;
        top: auto;
    }

    /* Backdrop overlay — blocks touches above chat on mobile */
    .rm-chat--open .rm-chat__backdrop {
        display: block;
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.4);
        z-index: 1;
        pointer-events: auto;
        -webkit-tap-highlight-color: transparent;
    }

    /* Lock page scroll when chat is open on mobile */
    body.rm-chat-scroll-lock {
        overflow: hidden !important;
        position: fixed !important;
        width: 100% !important;
        height: 100% !important;
    }
}

/* ===================================================================
   DEBUG PANEL (test mode only)
=================================================================== */
.rm-chat__debug {
    border-top: 2px solid #f0ad4e;
    background: #1e1e1e;
    color: #d4d4d4;
    font-family: 'SF Mono', Monaco, 'Cascadia Code', monospace;
    font-size: 11px;
    max-height: 200px;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}
.rm-chat__debug--collapsed .rm-chat__debug-log {
    display: none;
}
.rm-chat__debug-header {
    padding: 4px 8px;
    background: #2d2d2d;
    cursor: pointer;
    user-select: none;
    font-weight: 600;
    color: #f0ad4e;
    border-bottom: 1px solid #444;
}
.rm-chat__debug-log {
    overflow-y: auto;
    padding: 4px;
    flex: 1;
    min-height: 0;
}
.rm-chat__debug-entry {
    margin-bottom: 4px;
    border-left: 3px solid #555;
    padding-left: 6px;
}
.rm-chat__debug-entry--function_call,
.rm-chat__debug-entry--function_executing {
    border-left-color: #569cd6;
}
.rm-chat__debug-entry--function_result {
    border-left-color: #4ec9b0;
}
.rm-chat__debug-entry--error {
    border-left-color: #f44747;
}
.rm-chat__debug-entry--done {
    border-left-color: #608b4e;
}
.rm-chat__debug-label {
    color: #9cdcfe;
    font-weight: 600;
}
.rm-chat__debug-entry--error .rm-chat__debug-label {
    color: #f44747;
}
.rm-chat__debug-content {
    margin: 2px 0 0;
    padding: 3px 6px;
    background: #252526;
    border-radius: 3px;
    white-space: pre-wrap;
    word-break: break-all;
    max-height: 120px;
    overflow-y: auto;
    color: #d4d4d4;
    font-size: 10px;
    line-height: 1.4;
}
