* { box-sizing: border-box; }
html, body {
    width: 100%;
    height: 100%;
    min-height: 100%;
    margin: 0;
    overflow: hidden;
}
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
    color: #111827;
    background: #f5f7fb;
}
button, input, textarea { font: inherit; }
button { cursor: pointer; }
.oaim-widget {
    width: 100%;
    height: 100%;
    min-height: 0;
    display: grid;
    grid-template-rows: 64px minmax(0, 1fr) auto;
    background: #f5f7fb;
}
.oaim-widget__head {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    border-bottom: 1px solid #e7edf5;
    background: #fff;
    color: #111827;
}
.oaim-widget__avatar {
    width: 38px;
    height: 38px;
    flex: 0 0 38px;
    display: grid;
    place-items: center;
    border-radius: 12px;
    background: #2563eb;
    color: #fff;
    font-size: 13px;
    font-weight: 850;
}
.oaim-widget__title {
    min-width: 0;
    flex: 1;
}
.oaim-widget__title strong {
    display: block;
    font-size: 16px;
    line-height: 21px;
    font-weight: 700;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}
.oaim-widget__title span {
    display: inline-block;
    margin-top: 1px;
    margin-right: 6px;
    font-size: 12px;
    line-height: 16px;
    color: #64748b;
}
.oaim-widget__title em {
    display: inline-flex;
    align-items: center;
    width: fit-content;
    max-width: 100%;
    height: 16px;
    margin-top: 1px;
    padding: 0 6px;
    border-radius: 999px;
    background: #fff7ed;
    color: #b45309;
    font-style: normal;
    font-size: 10px;
    font-weight: 700;
    line-height: 16px;
    white-space: nowrap;
    vertical-align: top;
}
.oaim-widget__title em[hidden] {
    display: none;
}
.oaim-widget__close {
    width: 32px;
    height: 32px;
    border: 0;
    border-radius: 10px;
    background: transparent;
    color: #475569;
    font-size: 26px;
    line-height: 30px;
}
.oaim-widget__close:hover {
    background: #f1f5f9;
    color: #0f172a;
}
.oaim-widget__messages {
    min-height: 0;
    overflow-y: auto;
    padding: 14px 12px 10px;
}
.oaim-widget__hint {
    margin: 0 auto 12px;
    width: fit-content;
    max-width: 90%;
    padding: 4px 10px;
    border-radius: 999px;
    background: rgba(100, 116, 139, .12);
    color: #64748b;
    font-size: 12px;
    line-height: 18px;
}
.oaim-widget__row {
    display: flex;
    margin: 10px 0;
}
.oaim-widget__system {
    display: flex;
    justify-content: center;
    margin: 10px 0;
}
.oaim-widget__system span {
    max-width: 86%;
    padding: 4px 10px;
    border-radius: 999px;
    background: rgba(100, 116, 139, .12);
    color: #64748b;
    font-size: 12px;
    line-height: 18px;
    text-align: center;
    word-break: break-word;
}
.oaim-widget__row--me { justify-content: flex-end; }
.oaim-widget__bubble {
    max-width: 78%;
    padding: 10px 12px;
    border-radius: 14px;
    background: #fff;
    color: #111827;
    font-size: 14px;
    line-height: 21px;
    word-break: break-word;
    box-shadow: 0 2px 8px rgba(15, 23, 42, .05);
}
.oaim-widget__row--me .oaim-widget__bubble {
    background: #2563eb;
    color: #fff;
}
.oaim-widget__bubble img {
    display: block;
    max-width: 180px;
    max-height: 180px;
    border-radius: 10px;
}
.oaim-widget__bubble .oaim-widget__inline-emoji {
    display: inline-block;
    width: 28px;
    height: 28px;
    max-width: 28px;
    max-height: 28px;
    margin: 0 2px;
    border-radius: 0;
    vertical-align: -7px;
    object-fit: contain;
}
.oaim-widget__video {
    max-width: 210px;
    max-height: 180px;
}
.oaim-widget__media-link {
    color: inherit;
    text-decoration: none;
}
.oaim-widget__chips {
    display: flex;
    gap: 8px;
    padding: 9px 12px;
    overflow-x: auto;
    scrollbar-width: none;
    background: #fff;
    border-top: 1px solid #e7edf5;
}
.oaim-widget__chips::-webkit-scrollbar {
    display: none;
}
.oaim-widget__chip {
    flex: 0 0 auto;
    height: 28px;
    padding: 0 12px;
    border: 1px solid #dbe3ef;
    border-radius: 999px;
    background: #f8fafc;
    color: #334155;
    font-size: 13px;
}
.oaim-widget__chip:hover {
    border-color: rgba(37, 99, 235, .28);
    color: #1d4ed8;
    background: #eff6ff;
}
.oaim-widget__emoji-panel {
    display: grid;
    grid-template-columns: repeat(8, 32px);
    gap: 6px;
    max-height: 132px;
    padding: 10px 12px;
    overflow-y: auto;
    background: #fff;
    border-top: 1px solid #e7edf5;
}
.oaim-widget__emoji-panel[hidden] {
    display: none;
}
.oaim-widget__emoji-panel button {
    width: 32px;
    height: 32px;
    display: grid;
    place-items: center;
    padding: 0;
    border: 0;
    border-radius: 8px;
    background: transparent;
}
.oaim-widget__emoji-panel button:hover {
    background: #f1f5f9;
}
.oaim-widget__emoji-panel img {
    width: 26px;
    height: 26px;
    display: block;
    object-fit: contain;
}
.oaim-widget__compose {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) 66px;
    gap: 8px;
    align-items: center;
    padding: 10px 12px calc(12px + env(safe-area-inset-bottom, 0px));
    background: #fff;
    border-top: 1px solid #e7edf5;
}
.oaim-widget__tools {
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 8px;
}
.oaim-widget__tool {
    position: relative;
    width: 36px;
    height: 36px;
    min-width: 36px;
    flex: 0 0 36px;
    display: grid;
    place-items: center;
    padding: 0;
    border: 1px solid #dce2eb;
    border-radius: 11px;
    background: #f8fafc;
    color: #475569;
    font-size: 0;
    font-weight: 800;
}
.oaim-widget__tool:hover {
    border-color: rgba(37, 99, 235, .28);
    color: #1d4ed8;
    background: #eff6ff;
}
.oaim-widget__tool-icon {
    position: relative;
    width: 18px;
    height: 18px;
    display: block;
}
.oaim-widget__tool-icon--image::before {
    position: absolute;
    left: 2px;
    top: 3px;
    width: 14px;
    height: 12px;
    border: 1.8px solid currentColor;
    border-radius: 4px;
    content: "";
}
.oaim-widget__tool-icon--image::after {
    position: absolute;
    left: 5px;
    bottom: 3px;
    width: 9px;
    height: 7px;
    border-left: 1.8px solid currentColor;
    border-bottom: 1.8px solid currentColor;
    content: "";
    transform: skew(-18deg) rotate(-4deg);
}
.oaim-widget__tool-icon--emoji {
    border: 1.8px solid currentColor;
    border-radius: 50%;
}
.oaim-widget__tool-icon--emoji::before,
.oaim-widget__tool-icon--emoji::after {
    position: absolute;
    top: 5px;
    width: 3px;
    height: 3px;
    border-radius: 50%;
    background: currentColor;
    content: "";
}
.oaim-widget__tool-icon--emoji::before { left: 4px; }
.oaim-widget__tool-icon--emoji::after { right: 4px; }
.oaim-widget__tool-icon--emoji span {
    position: absolute;
    left: 5px;
    bottom: 4px;
    width: 6px;
    height: 3px;
    border-bottom: 1.8px solid currentColor;
    border-radius: 0 0 999px 999px;
}
.oaim-widget__file { display: none; }
.oaim-widget__input {
    width: 100%;
    min-width: 0;
    min-height: 38px;
    max-height: 92px;
    display: block;
    resize: none;
    border: 1px solid #e2e8f0;
    outline: 0;
    border-radius: 12px;
    padding: 8px 11px;
    overflow-y: auto;
    color: #111827;
    background: #f8fafc;
    font-size: 14px;
    line-height: 20px;
}
.oaim-widget__input:focus {
    border-color: rgba(37, 99, 235, .34);
    background: #fff;
}
.oaim-widget__send {
    width: 66px;
    min-width: 66px;
    height: 38px;
    padding: 0;
    border: 0;
    border-radius: 12px;
    background: #2563eb;
    color: #fff;
    font-size: 14px;
    font-weight: 700;
}
.oaim-widget__send:disabled {
    opacity: .55;
    cursor: not-allowed;
}
@media (max-width: 360px) {
    .oaim-widget__compose {
        grid-template-columns: auto minmax(0, 1fr) 58px;
        gap: 6px;
        padding: 8px 10px calc(10px + env(safe-area-inset-bottom, 0px));
    }
    .oaim-widget__tools {
        gap: 6px;
    }
    .oaim-widget__send {
        width: 58px;
        min-width: 58px;
    }
}
@media (max-width: 520px) {
    html, body {
        height: 100vh;
        height: 100svh;
        height: 100dvh;
    }
    .oaim-widget {
        height: 100vh;
        height: 100svh;
        height: 100dvh;
        grid-template-rows: 58px minmax(0, 1fr) auto;
    }
    .oaim-widget__head {
        padding: 7px 12px;
    }
    .oaim-widget__title strong {
        font-size: 15px;
        line-height: 19px;
    }
    .oaim-widget__title span,
    .oaim-widget__title em {
        margin-top: 2px;
        margin-right: 4px;
        font-size: 11px;
        line-height: 15px;
    }
    .oaim-widget__title em {
        padding: 0 5px;
        height: 15px;
    }
    .oaim-widget__avatar {
        width: 36px;
        height: 36px;
        flex-basis: 36px;
        font-size: 12px;
    }
    .oaim-widget__messages {
        padding: 12px 12px 10px;
    }
    .oaim-widget__bubble {
        max-width: 86%;
        font-size: 14px;
        line-height: 21px;
    }
    .oaim-widget__chips {
        gap: 7px;
        padding: 8px 10px;
    }
    .oaim-widget__chip {
        height: 28px;
        padding: 0 11px;
        font-size: 12.5px;
    }
    .oaim-widget__compose {
        gap: 7px;
        padding: 9px 10px calc(11px + env(safe-area-inset-bottom, 0px));
    }
    .oaim-widget__tools {
        gap: 6px;
    }
    .oaim-widget__tool {
        width: 34px;
        height: 34px;
        min-width: 34px;
        flex-basis: 34px;
        border-radius: 10px;
    }
}
.oaim-widget__toast {
    position: fixed;
    left: 50%;
    bottom: 74px;
    z-index: 4;
    transform: translateX(-50%);
    max-width: calc(100% - 32px);
    padding: 8px 12px;
    border-radius: 999px;
    background: rgba(15, 23, 42, .86);
    color: #fff;
    font-size: 13px;
    line-height: 18px;
    opacity: 0;
    pointer-events: none;
    transition: opacity .16s ease;
}
.oaim-widget__toast.is-show { opacity: 1; }
.oaim-widget__loading {
    height: 100%;
    display: grid;
    place-items: center;
    color: #7d8796;
    font-size: 14px;
}
