/* 希怡网页对话挂件：悬浮球 + 右侧抽屉 + 选中文字气泡 */

.xiyi-ball {
    position: fixed;
    right: 28px;
    bottom: 90px;
    z-index: 9998;
    width: 62px;
    height: 62px;
    border-radius: 50%;
    cursor: pointer;
    user-select: none;
    border: 3px solid #fff;
    box-shadow: 0 4px 18px rgba(22, 186, 170, 0.45), 0 0 0 1px rgba(22, 186, 170, 0.18);
    transition: transform 0.25s, box-shadow 0.25s;
}
.xiyi-ball img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
    display: block;
}
.xiyi-ball:hover {
    transform: translateY(-3px) scale(1.05);
    box-shadow: 0 8px 24px rgba(22, 186, 170, 0.55), 0 0 0 1px rgba(22, 186, 170, 0.3);
}
/* 呼吸光环 */
.xiyi-ball::after {
    content: '';
    position: absolute;
    inset: -7px;
    border-radius: 50%;
    border: 2px solid rgba(22, 186, 170, 0.55);
    animation: xiyi-pulse 2.6s ease-out infinite;
    pointer-events: none;
}
@keyframes xiyi-pulse {
    0% { transform: scale(0.88); opacity: 0.9; }
    70%, 100% { transform: scale(1.28); opacity: 0; }
}
/* 悬停问候气泡 */
.xiyi-ball-tip {
    position: absolute;
    right: 74px;
    top: 50%;
    transform: translateY(-50%) translateX(8px);
    background: #fff;
    color: #1f2d2c;
    font-size: 13px;
    line-height: 1;
    padding: 10px 13px;
    border-radius: 12px;
    border: 1px solid #e3f1ef;
    box-shadow: 0 6px 20px rgba(16, 24, 40, 0.12);
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s, transform 0.25s;
}
.xiyi-ball-tip::after {
    content: '';
    position: absolute;
    right: -5px;
    top: 50%;
    transform: translateY(-50%);
    border: 5px solid transparent;
    border-left-color: #fff;
    border-right: 0;
}
.xiyi-ball:hover .xiyi-ball-tip {
    opacity: 1;
    transform: translateY(-50%) translateX(0);
}

/* 选中文字气泡 */
.xiyi-pick {
    position: absolute;
    z-index: 9998;
    background: #16baaa;
    color: #fff;
    font-size: 13px;
    padding: 6px 12px;
    border-radius: 14px;
    cursor: pointer;
    box-shadow: 0 3px 10px rgba(22, 186, 170, 0.4);
    user-select: none;
    white-space: nowrap;
}
.xiyi-pick:hover { background: #12a599; }
.xiyi-pick::after {
    content: '';
    position: absolute;
    left: 50%;
    bottom: -5px;
    transform: translateX(-50%);
    border: 5px solid transparent;
    border-top-color: #16baaa;
    border-bottom: 0;
}

/* 抽屉 */
.xiyi-mask {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: rgba(0, 0, 0, 0.25);
}
.xiyi-mask.show { display: block; }
.xiyi-drawer {
    position: fixed;
    top: 0;
    right: -420px;
    z-index: 10000;
    width: 400px;
    max-width: 100vw;
    height: 100vh;
    background: #fff;
    box-shadow: -6px 0 24px rgba(0, 0, 0, 0.12);
    display: flex;
    flex-direction: column;
    transition: right 0.25s ease;
}
.xiyi-drawer.show { right: 0; }

.xiyi-head {
    display: flex;
    align-items: center;
    padding: 14px 16px;
    border-bottom: 1px solid #d8ece9;
    background: #eefafa; /* 首页同款浅薄荷绿 */
    color: #1f2d2c;
    flex-shrink: 0;
}
.xiyi-head-avatar {
    width: 40px; height: 40px; border-radius: 50%;
    border: 2px solid #fff;
    box-shadow: 0 1px 4px rgba(22, 186, 170, 0.35);
    margin-right: 10px;
    object-fit: cover;
    display: block;
}
.xiyi-head-title { font-size: 16px; font-weight: bold; color: #1f2d2c; }
.xiyi-head-sub { font-size: 12px; color: #5f7371; margin-top: 1px; }
.xiyi-head-close {
    margin-left: auto;
    cursor: pointer;
    font-size: 20px;
    line-height: 1;
    color: #5f7371;
    padding: 4px;
}
.xiyi-head-close:hover { color: #1f2d2c; }

.xiyi-msgs {
    flex: 1;
    overflow-y: auto;
    padding: 16px 14px;
    background: #f7fafa;
    scrollbar-width: none;          /* Firefox：隐藏滚动条（保留滚动） */
    -ms-overflow-style: none;
}
.xiyi-msgs::-webkit-scrollbar { display: none; }  /* Chrome/Edge */
.xiyi-msg { display: flex; margin-bottom: 14px; }
.xiyi-msg.user { justify-content: flex-end; }
.xiyi-msg-bubble {
    max-width: 86%;
    padding: 10px 13px;
    border-radius: 12px;
    font-size: 14px;
    line-height: 1.65;
    word-break: break-word;
    overflow-wrap: anywhere;
}
.xiyi-msg.user .xiyi-msg-bubble { background: #16baaa; color: #fff; border-top-right-radius: 3px; }
.xiyi-msg.bot .xiyi-msg-bubble { background: #fff; color: #333; border: 1px solid #e8eefe; border-top-left-radius: 3px; }
.xiyi-msg-bubble.error { color: #c00; background: #fff5f5; border-color: #f3c8c8; }
.xiyi-typing { display: inline-block; }
.xiyi-typing::after {
    content: '…';
    animation: xiyi-blink 1s infinite;
}
@keyframes xiyi-blink { 50% { opacity: 0.2; } }

/* 回答里的 Markdown：对齐文章详情 .article-body 的渲染风格 */
.xiyi-md p { margin: 0 0 8px; }
.xiyi-md p:last-child { margin-bottom: 0; }
.xiyi-md h1, .xiyi-md h2, .xiyi-md h3, .xiyi-md h4 { margin: 12px 0 8px; color: #222; font-size: 15px; }
.xiyi-md a { color: #16baaa; text-decoration: underline; overflow-wrap: anywhere; }
.xiyi-md ul, .xiyi-md ol { margin: 6px 0; padding-left: 22px; }
.xiyi-md ul > li { list-style: disc outside !important; }
.xiyi-md ol > li { list-style: decimal outside !important; }
.xiyi-md li { margin-bottom: 4px; }
.xiyi-md blockquote { border-left: 4px solid #16baaa; padding: 6px 12px; margin: 8px 0;
    background: #f8fdfc; color: #555; border-radius: 0 4px 4px 0; }
.xiyi-md blockquote p { margin: 0; }
.xiyi-md code { font-family: Consolas, monospace; background: #ccf1f1; color: #2f363c;
    padding: 1px 5px; border-radius: 8px; font-size: 13px; }
.xiyi-md pre { background: #2f363c; color: #e2e8f0; padding: 12px; border-radius: 8px;
    overflow-x: auto; margin: 8px 0; font-size: 13px; line-height: 1.6; }
.xiyi-md pre code { background: transparent; color: inherit; padding: 0; font-size: 13px; }
.xiyi-md .codehilite { background: transparent; padding: 0; margin: 8px 0; }
.xiyi-md .codehilite pre { background: #2f363c; padding: 12px; margin: 0; }
.xiyi-md table { width: 100%; border-collapse: collapse; margin: 8px 0; font-size: 13px; }
.xiyi-md th, .xiyi-md td { border: 1px solid #ddd; padding: 6px 9px; text-align: left; }
.xiyi-md th { background: #f5f5f5; font-weight: 600; }
.xiyi-md img { max-width: 100%; border-radius: 6px; }
.xiyi-md hr { border: 0; border-top: 1px solid #eee; margin: 10px 0; }
.xiyi-md .mermaid { margin: 8px 0; overflow-x: auto; }

.xiyi-input-wrap {
    flex-shrink: 0;
    border-top: 1px solid #eee;
    padding: 10px 12px;
    background: #fff;
}
.xiyi-quota { font-size: 12px; color: #999; margin-bottom: 6px; }
.xiyi-quota .xiyi-quota-badge { color: #16baaa; font-weight: bold; }
.xiyi-input-row { display: flex; gap: 8px; }
.xiyi-input-row textarea {
    flex: 1;
    resize: none;
    min-height: 42px;
    max-height: 110px;
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 10px 12px;
    font-size: 14px;
    line-height: 1.5;
    font-family: inherit;
    outline: none;
    overflow-y: auto;
    white-space: nowrap;
    scrollbar-width: none;                 /* Firefox：隐藏滚动条（滚轮/方向键仍可滚动） */
    -ms-overflow-style: none;
}
.xiyi-input-row textarea::-webkit-scrollbar { display: none; }   /* Chrome/Edge：隐藏 */
.xiyi-input-row textarea:focus { border-color: #16baaa; outline: none; }
.xiyi-input-row textarea.has-content { white-space: normal; }
.xiyi-send {
    flex-shrink: 0;
    align-self: center;                    /* 输入框长高时保持垂直居中 */
    width: 42px;
    height: 42px;
    border: 0;
    border-radius: 50%;
    background: #16baaa;
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    transition: background 0.2s, transform 0.15s;
}
.xiyi-send svg { display: block; }
.xiyi-send:hover { background: #12a599; transform: scale(1.06); }
.xiyi-send:disabled { background: #b7e6e1; cursor: not-allowed; transform: none; }

/* 未登录视图 */
.xiyi-login-tip { text-align: center; padding: 60px 24px; }
.xiyi-login-avatar {
    width: 84px; height: 84px; border-radius: 50%;
    border: 3px solid #eefafa;
    box-shadow: 0 4px 14px rgba(22, 186, 170, 0.25);
    object-fit: cover;
    margin-bottom: 8px;
}
.xiyi-login-tip p { color: #666; font-size: 14px; margin: 14px 0 20px; line-height: 1.7; }
.xiyi-login-btn {
    display: inline-block;
    background: #16baaa;
    color: #fff;
    text-decoration: none;
    padding: 9px 34px;
    border-radius: 20px;
    font-size: 14px;
}
.xiyi-login-btn:hover { background: #12a599; color: #fff; }

@media (max-width: 480px) {
    .xiyi-drawer { width: 100vw; right: -100vw; }
    .xiyi-ball { right: 18px; bottom: 76px; width: 50px; height: 50px; font-size: 14px; }
}
