body:has(#lbs-agent-preview) {
    margin: 0;
}

#lbs-agent-preview,
#lbs-agent-preview * {
    box-sizing: border-box;
}

#lbs-agent-preview {
    --ink: #102b4c;
    --muted: #49596c;
    --line: #dce5ee;
    --paper: #fff;
    --canvas: #f3f6fa;
    --action: #123e68;
    --focus: #1469a8;
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    place-items: center;
    height: 100vh;
    height: var(--ap-viewport-height, 100dvh);
    padding: clamp(16px, 4vw, 40px);
    background: var(--canvas);
    color: var(--ink);
    font: 16px/1.5 system-ui, sans-serif;
}

#lbs-agent-preview [hidden] {
    display: none !important;
}

#lbs-agent-preview .visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
}

.ap-chat {
    width: min(100%, 860px);
    height: min(100%, 900px);
    min-height: 0;
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto minmax(0, 1fr) auto;
    overflow: hidden;
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: 18px;
    box-shadow: 0 10px 35px #102b4c10;
}

.ap-chat-head, .ap-identity, .ap-header-actions {
    display: flex;
    align-items: center;
}

.ap-chat-head {
    gap: 12px;
    justify-content: space-between;
    padding: 12px 20px;
    border-bottom: 1px solid var(--line);
}

.ap-identity, .ap-header-actions {
    gap: 12px;
    min-width: 0;
}

.ap-identity h1 {
    margin: 0;
    font-size: 1rem;
    line-height: 1.18;
}

.ap-logo {
    width: 106px;
    height: 41px;
    object-fit: contain;
    object-position: left center;
    flex-shrink: 0;
}

.ap-header-actions a,
.ap-chat button,
.ap-apply {
    display: inline-flex;
    min-height: 44px;
    align-items: center;
    justify-content: center;
    padding: 9px 13px;
    border: 1px solid transparent;
    border-radius: 9px;
    font: inherit;
    font-size: .875rem;
    font-weight: 650;
    line-height: 1.25;
    white-space: nowrap;
    cursor: pointer;
    text-decoration: none;
}

.ap-chat a { color: var(--action); }

.ap-chat button {
    background: #f1f5fa;
    color: var(--ink);
}

.ap-chat .ap-primary, .ap-chat .ap-apply {
    background: var(--action);
    color: #fff;
}

.ap-chat button:disabled {
    opacity: .58;
    cursor: default;
}

.ap-chat :focus-visible {
    outline: 2px solid var(--focus);
    outline-offset: 2px;
}

#ap-voice {
    width: min(520px, calc(100% - 24px));
    max-height: calc(100% - 24px);
    padding: 16px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: var(--paper);
    color: var(--ink);
    overscroll-behavior: contain;
    overflow-wrap: anywhere;
}

#ap-voice::backdrop { background: #102b4c75; }
.ap-voice-head, #ap-voice .mba-voice-controls {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}
.ap-voice-head { justify-content: space-between; }
.ap-voice-head h2 { margin: 0; font-size: 1.15rem; }
#ap-voice #mba-voice-start { background: var(--action); color: #fff; }
#ap-voice #mba-voice { margin-top: 12px; }
#ap-voice #mba-voice label { display: block; margin: 8px 0; }
#ap-voice #mba-voice input, #ap-voice #mba-voice audio { max-width: 100%; }
#ap-voice #mba-voice button { white-space: normal; }
#ap-voice #mba-voice-status, #ap-voice .note { margin: 8px 0; }
#ap-voice #mba-voice-transcript { max-height: 160px; overflow: auto; white-space: pre-wrap; }

#ap-application {
    container-type: inline-size;
    margin: 18px 0 2px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: var(--paper);
    overflow-wrap: anywhere;
    scroll-margin: 12px;
}

.ap-application-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--line);
}

.ap-application-head h2 { margin: 0; font-size: 1.05rem; }
.ap-application-head button { white-space: normal; text-align: center; }
#ap-recommendation .ap-apply { margin-right: 8px; }

#ap-start-application {
    max-width: 540px;
    margin: auto;
    padding: 22px;
    color: var(--ink, #102b4c);
    font: 16px/1.5 system-ui, sans-serif;
    overflow-wrap: anywhere;
}

#ap-start-application h1 { margin: 0 0 8px; font-size: 1.35rem; }
#ap-start-application label { display: block; font-weight: 600; }
#ap-start-application p { margin: 0 0 14px; color: var(--muted, #49596c); }
#ap-start-application [data-step] p { margin: 6px 0 0; font-size: .875rem; }
#ap-start-application input:not([type=checkbox]), #ap-start-application select {
    display: block;
    width: 100%;
    min-width: 0;
    min-height: 46px;
    margin: 8px 0 0;
    padding: 8px 12px;
    box-sizing: border-box;
    border: 1px solid #abb9c9;
    border-radius: 9px;
    background: #fff;
    color: inherit;
    font: inherit;
}

#ap-start-application button { min-height: 44px; padding-inline: 14px; white-space: normal; }
.ap-application-buttons { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 16px; }
#ap-application-next { background: #123e68; color: white; border: 0; border-radius: 8px; }
#ap-application-status { margin: 12px 0 0; }
#ap-application-status:empty { margin: 0; }
#ap-resend-code { margin-top: 8px; }
#ap-start-application .ap-application-consent { margin-top: 12px; }
#ap-application-thread { display: grid; gap: 10px; padding: 12px 16px; }
#ap-application-thread:empty { padding: 0; }
#ap-application-thread .ap-message { max-width: min(100%, 48rem); }
#ap-application-thread button { margin: 8px 8px 0 0; white-space: normal; text-align: left; }
.ap-guided-link { display: block; margin-top: 8px; }
.ap-guided-changes { margin: 10px 0 0; padding-left: 22px; }
#ap-guided-code { flex: 1; min-width: 0; width: 100%; }
#lbs-agent-preview[data-application-mode="start"] :is(#ap-actions, #ap-recommendation),
#lbs-agent-preview[data-application-mode="guided"] :is(#ap-actions, #ap-recommendation) { display: none; }

@container (max-width: 420px) {
    .ap-application-head, #ap-application-thread { padding-inline: 12px; }
    #ap-start-application { padding: 16px 12px; }
    .ap-application-buttons { display: grid; grid-template-columns: 1fr; }
}

.ap-content {
    padding: 24px clamp(16px, 5vw, 48px);
    min-height: 0;
    overflow: auto;
    overscroll-behavior: contain;
}

.ap-welcome {
    max-width: 430px;
    margin: min(9vh, 85px) auto 0;
}

.ap-welcome h2 { margin: 0 0 8px; font-size: clamp(1.5rem, 4vw, 2rem); }
.ap-welcome p { margin: 0 0 20px; color: var(--muted); }
.ap-disclosure { font-size: .875rem; }

.ap-consent {
    display: flex;
    align-items: flex-start;
    gap: 11px;
    margin: 12px 0 18px;
    color: var(--muted);
    font-size: .875rem;
}

.ap-consent input {
    accent-color: var(--action);
    width: 18px;
    height: 18px;
    margin: 3px 0 0;
    flex: 0 0 18px;
}

#ap-thread {
    display: grid;
    gap: 16px;
}

.ap-message {
    max-width: min(90%, 600px);
    justify-self: start;
    padding: 11px 15px;
    border: 1px solid var(--line);
    border-radius: 14px 14px 14px 4px;
    background: #f5f8fc;
    overflow-wrap: anywhere;
}

.ap-message > strong {
    display: block;
    margin-bottom: 3px;
    color: var(--muted);
    font-size: .77rem;
}

.ap-message > div { white-space: pre-wrap; }
.ap-user {
    justify-self: end;
    background: #e8f1fc;
    border-color: #d8e5f5;
    border-radius: 14px 14px 4px 14px;
}

#ap-recommendation, .ap-card {
    margin-top: 16px;
    padding: 15px 17px;
    border: 1px solid var(--line);
    border-radius: 12px;
    overflow-wrap: anywhere;
}

#ap-recommendation {
    background: #f0f7f3;
    border-color: #d1e8da;
}

#ap-recommendation h3, .ap-card h3 {
    margin: 2px 0 6px;
    font-size: 1rem;
}

#ap-recommendation p, .ap-card p {
    margin: 5px 0 10px;
    font-size: .9rem;
}

#ap-recommendation small, .ap-card small {
    display: block;
    color: var(--muted);
    font-size: .8rem;
}

.ap-apply { margin: 5px 0 8px; }
.ap-brochure-link { display: inline-flex; align-items: center; min-height: 44px; }
.ap-receipt { color: var(--muted); }
.ap-card pre { white-space: pre-wrap; }

.ap-contact {
    display: grid;
    gap: 10px;
}

.ap-contact label { font-size: .875rem; }
.ap-contact .ap-consent { margin: 2px 0; }

.ap-contact label > input:not([type=checkbox]), #ap-message, #ap-guided-code {
    display: block;
    width: 100%;
    min-height: 44px;
    padding: 9px 11px;
    border: 1px solid #abb9c9;
    border-radius: 9px;
    background: var(--paper);
    color: var(--ink);
    font: inherit;
    font-size: 1rem;
}

.ap-contact label > input:not([type=checkbox]) { margin-top: 4px; }
.ap-card > button { margin: 5px 8px 0 0; }

.ap-composer {
    background: var(--paper);
    padding: 0 clamp(16px, 5vw, 48px);
}

.ap-composer:has(#ap-form:not([hidden])) {
    border-top: 1px solid var(--line);
    padding-block: 10px max(10px, env(safe-area-inset-bottom));
}

#ap-status {
    margin: 0 0 6px;
    color: var(--muted);
    font-size: .875rem;
}

#ap-status:empty { margin: 0; }

#ap-form {
    display: flex;
    align-items: end;
    gap: 8px;
}

#ap-message, #ap-guided-code {
    min-width: 0;
    max-height: 106px;
    resize: none;
}

.ap-error { color: #a52723; }

@media (max-width: 600px) {
    #lbs-agent-preview {
        padding: 0;
    }

    .ap-chat {
        height: 100%;
        border: 0;
        border-radius: 0;
        box-shadow: none;
    }

    .ap-chat-head {
        gap: 6px;
        padding: max(8px, env(safe-area-inset-top)) 12px 8px;
    }

    .ap-identity, .ap-header-actions { gap: 4px; }
    .ap-logo { width: 66px; height: 32px; }
    .ap-identity h1 { font-size: .875rem; }
    .ap-header-actions { flex-shrink: 0; }
    .ap-header-actions a, .ap-header-actions button { min-width: 44px; padding-inline: 6px; font-size: .8rem; }
    .ap-content { padding: 16px 12px; }
    .ap-composer { padding-inline: 12px; }
    .ap-message { max-width: 93%; }
    .ap-application-head button { padding-inline: 8px; }
}

@media (max-width: 350px) {
    .ap-logo { width: 74px; }
    .ap-identity h1 { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
}
