/* ============================================================
   小狸攻略 · AI 游戏攻略
   三层结构：灰底 → 白色主卡（左说明 + 右对话）→ 卡内分区
   ============================================================ */

* { box-sizing: border-box; }

body.ai-page {
    background: #eceef2;
    color: #1f2329;
    -webkit-font-smoothing: antialiased;
}

/* ---------- 主框架：一张白色大卡 ---------- */
.ai-frame {
    display: flex;
    align-items: stretch;
    gap: 0;
    width: 100%;
    max-width: 1440px;
    height: calc(100vh - 96px);
    min-height: 560px;
    margin: 14px auto 18px;
    padding: 0 24px;
    box-sizing: border-box;
}

.ai-frame > .ai-side,
.ai-frame > .ai-app {
    background: #fff;
    height: 100%;
}

/* ---------- 左侧说明栏 ---------- */
.ai-side {
    flex: none;
    width: 252px;
    display: flex;
    flex-direction: column;
    padding: 22px 20px;
    border-radius: 16px 0 0 16px;
    border: 1px solid #e4e7ec;
    border-right: 1px solid #eceef2;
}

.ai-side-head {
    display: flex;
    align-items: center;
    gap: 10px;
    padding-bottom: 18px;
    margin-bottom: 20px;
    border-bottom: 1px solid #f0f2f5;
}
.ai-side-mark {
    flex: none;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: linear-gradient(135deg, #f76341, #ff8a5c);
    color: #fff;
    font-size: 18px;
    box-shadow: 0 5px 14px rgba(247, 99, 65, .28);
}
.ai-side-head b {
    display: block;
    font-size: 15px;
    font-weight: 700;
    color: #111827;
    line-height: 1.3;
}
.ai-side-head div > span {
    display: block;
    margin-top: 2px;
    font-size: 11.5px;
    color: #9aa1ad;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ai-side-block { margin-bottom: 22px; }
.ai-side-block h3 {
    margin: 0 0 10px;
    font-size: 11.5px;
    font-weight: 700;
    letter-spacing: .08em;
    color: #a8aeb8;
}

.ai-side-list,
.ai-side-tips { margin: 0; padding: 0; list-style: none; }

.ai-side-list li {
    display: flex;
    align-items: flex-start;
    gap: 7px;
    margin-bottom: 9px;
    font-size: 12px;
    line-height: 1.6;
    color: #6b7280;
}
.ai-side-list li:last-child { margin-bottom: 0; }
.ai-side-list li b {
    font-weight: 700;
    color: #1f2329;
}
.ai-side-list .layui-icon {
    flex: none;
    margin-top: 4px;
    font-size: 11px;
    color: #f76341;
}

.ai-side-tips li {
    position: relative;
    padding-left: 12px;
    margin-bottom: 8px;
    font-size: 12px;
    line-height: 1.7;
    color: #8f959e;
}
.ai-side-tips li:last-child { margin-bottom: 0; }
.ai-side-tips li::before {
    content: "";
    position: absolute;
    left: 1px;
    top: 8px;
    width: 3px;
    height: 3px;
    border-radius: 50%;
    background: #c9cfd8;
}

.ai-side-note {
    display: flex;
    align-items: center;
    gap: 6px;
    margin: auto 0 0;
    padding: 9px 11px;
    border-radius: 9px;
    background: #fafbfc;
    border: 1px solid #eef0f4;
    font-size: 11.5px;
    color: #9aa1ad;
}
.ai-side-note .layui-icon { font-size: 12px; color: #ffb896; }

/* ---------- 右侧对话区 ---------- */
.ai-app {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    border-radius: 0 16px 16px 0;
    border: 1px solid #e4e7ec;
    border-left: 0;
    overflow: hidden;
}

/* 顶部条 */
.ai-bar {
    flex: none;
    border-bottom: 1px solid #f0f2f5;
}
.ai-bar-in {
    height: 52px;
    padding: 0 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}
.ai-bar-title {
    font-size: 14px;
    font-weight: 600;
    color: #374151;
}
.ai-bar-new {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    height: 30px;
    padding: 0 11px;
    border: 1px solid #e5e8ee;
    border-radius: 8px;
    background: #fff;
    color: #6b7280;
    font-size: 12.5px;
    cursor: pointer;
    transition: all .16s;
}
.ai-bar-new:hover {
    border-color: #ffcdb8;
    color: #e8552d;
    background: #fff8f4;
}
.ai-bar-new .layui-icon { font-size: 12px; }

/* ---------- 主舞台 ---------- */
.ai-stage {
    position: relative;
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    background: #fcfcfd;
}

/* 消息区 */
.ai-scroll {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 0 20px;
}
.ai-scroll::-webkit-scrollbar { width: 5px; }
.ai-scroll::-webkit-scrollbar-thumb {
    border-radius: 99px;
    background: rgba(31, 35, 41, .12);
}
.ai-thread {
    width: 100%;
    max-width: 760px;
    margin: 0 auto;
    padding: 20px 0 24px;
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.ai-stage.is-empty .ai-scroll { flex: 0 0 0; padding: 0; overflow: hidden; }
.ai-stage.is-empty .ai-thread { display: none; }

/* 空状态 */
.ai-intro {
    display: none;
    flex: 1;
    min-height: 0;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 0 24px 12px;
}
.ai-stage.is-empty .ai-intro { display: flex; }

.ai-intro-mark {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 46px;
    height: 46px;
    margin-bottom: 16px;
    border-radius: 14px;
    background: linear-gradient(135deg, #f76341, #ff8a5c);
    color: #fff;
    font-size: 21px;
    box-shadow: 0 8px 22px rgba(247, 99, 65, .26);
}
.ai-intro h1 {
    margin: 0 0 8px;
    font-size: 23px;
    font-weight: 700;
    letter-spacing: -.01em;
    color: #111827;
}
.ai-intro p {
    margin: 0;
    max-width: 460px;
    font-size: 13.5px;
    line-height: 1.7;
    color: #8f959e;
}

/* 首屏卖点徽标 */
.ai-intro-badges {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
    margin-top: 18px;
}
.ai-intro-badges span {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 5px 11px;
    border-radius: 999px;
    background: #fff;
    border: 1px solid #e8eaee;
    font-size: 12px;
    color: #6b7280;
}
.ai-intro-badges .layui-icon { font-size: 12px; color: #f76341; }

/* 示例标签 */
.ai-chips {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
    margin: 22px 0 0;
    max-width: 620px;
}
.ai-chip {
    padding: 7px 13px;
    border: 1px solid #e8eaee;
    border-radius: 999px;
    background: #fff;
    color: #5b6472;
    font-size: 12.5px;
    line-height: 1.3;
    cursor: pointer;
    transition: all .16s;
}
.ai-chip:hover {
    border-color: #ffcdb8;
    background: #fff8f4;
    color: #e8552d;
}

/* ---------- 底部输入 ---------- */
.ai-bottom {
    flex: none;
    padding: 12px 20px 14px;
    background: #fcfcfd;
    border-top: 1px solid #f4f5f8;
}
.ai-composer {
    width: 100%;
    max-width: 760px;
    margin: 0 auto;
}
.ai-field {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    padding: 10px 10px 10px 16px;
    border-radius: 14px;
    background: #fff;
    border: 1px solid #e4e7ec;
    transition: border-color .18s, box-shadow .18s;
}
.ai-field:focus-within {
    border-color: #ffc0a4;
    box-shadow: 0 0 0 3px rgba(247, 99, 65, .09);
}
.ai-field textarea {
    flex: 1;
    min-width: 0;
    max-height: 140px;
    padding: 4px 0;
    border: 0;
    background: transparent;
    color: #111827;
    font-size: 14.5px;
    line-height: 1.6;
    resize: none;
    outline: none;
    font-family: inherit;
}
.ai-field textarea::placeholder { color: #b3b9c4; }

.ai-send {
    flex: none;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border: 0;
    border-radius: 9px;
    background: #f0f2f5;
    color: #b3b9c4;
    font-size: 16px;
    cursor: pointer;
    transition: all .18s;
}
.ai-field:focus-within .ai-send {
    background: linear-gradient(135deg, #f76341, #ff8a5c);
    color: #fff;
    box-shadow: 0 3px 10px rgba(247, 99, 65, .3);
}
.ai-send:disabled { cursor: not-allowed; opacity: .6; }

.ai-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin: 8px 2px 0;
    font-size: 11px;
    color: #b0b6c0;
}
.ai-meta-left { display: inline-flex; align-items: center; gap: 4px; }
.ai-meta-left .layui-icon { font-size: 12px; color: #ffb896; }

/* 有对话后隐藏欢迎区 */
.ai-app.has-chat .ai-intro { display: none; }

/* ---------- 消息 ---------- */
.ai-msg { display: flex; }
.ai-msg--user { justify-content: flex-end; }

.ai-user-bubble {
    max-width: 74%;
    padding: 10px 15px;
    border-radius: 16px 16px 4px 16px;
    background: #f0f2f5;
    color: #1f2329;
    font-size: 14px;
    line-height: 1.7;
    word-break: break-word;
}

.ai-msg--ai { gap: 11px; align-items: flex-start; }
.ai-ai-mark {
    flex: none;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    margin-top: 2px;
    border-radius: 8px;
    background: linear-gradient(135deg, #f76341, #ff8a5c);
    color: #fff;
    font-size: 13px;
}
.ai-ai-body { flex: 1; min-width: 0; }
.ai-ai-text {
    font-size: 14.5px;
    line-height: 1.85;
    color: #374151;
    word-break: break-word;
}
.ai-ai-text > *:first-child { margin-top: 0; }
.ai-ai-text > *:last-child { margin-bottom: 0; }
.ai-ai-text p { margin: 0 0 11px; }
.ai-ai-text h3,
.ai-ai-text h4,
.ai-ai-text h5,
.ai-ai-text h6 {
    margin: 20px 0 8px;
    font-size: 15px;
    font-weight: 700;
    color: #111827;
}
.ai-ai-text ul,
.ai-ai-text ol { margin: 0 0 11px; padding-left: 21px; }
.ai-ai-text li { margin-bottom: 5px; }
.ai-ai-text strong { color: #111827; font-weight: 700; }
.ai-ai-text code {
    padding: 1px 5px;
    border-radius: 4px;
    background: #f3f5f8;
    color: #d9480f;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 12.5px;
}
.ai-error { color: #e05656; margin: 0; }
.ai-hint { margin: 0; color: #9aa1ad; font-size: 13.5px; }

.ai-dots { display: inline-flex; gap: 4px; padding: 8px 0; }
.ai-dots i {
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: #d5dae2;
    animation: ai-blink 1.3s infinite ease-in-out;
}
.ai-dots i:nth-child(2) { animation-delay: .16s; }
.ai-dots i:nth-child(3) { animation-delay: .32s; }
@keyframes ai-blink {
    0%, 60%, 100% { opacity: .35; transform: translateY(0); }
    30% { opacity: 1; transform: translateY(-3px); }
}

/* ---------- 登录弹窗 ---------- */
body.ai-locked { overflow: hidden; }

.ai-modal {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.ai-modal[hidden] { display: none; }
.ai-modal-mask {
    position: absolute;
    inset: 0;
    background: rgba(17, 24, 39, .42);
    animation: ai-fade .16s ease;
}
.ai-modal-box {
    position: relative;
    width: 100%;
    max-width: 330px;
    padding: 26px 24px 20px;
    border-radius: 16px;
    background: #fff;
    box-shadow: 0 20px 50px rgba(17, 24, 39, .2);
    text-align: center;
    animation: ai-pop .2s cubic-bezier(.2, .8, .2, 1);
}
@keyframes ai-fade { from { opacity: 0 } to { opacity: 1 } }
@keyframes ai-pop {
    from { opacity: 0; transform: translateY(8px) scale(.98); }
    to { opacity: 1; transform: none; }
}
.ai-modal-mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 46px;
    height: 46px;
    margin-bottom: 13px;
    border-radius: 13px;
    background: linear-gradient(135deg, #fff3ed, #ffe8dc);
    color: #f76341;
    font-size: 21px;
}
.ai-modal-box h3 {
    margin: 0 0 7px;
    font-size: 16px;
    font-weight: 700;
    color: #111827;
}
.ai-modal-box p {
    margin: 0 0 18px;
    font-size: 12.5px;
    line-height: 1.6;
    color: #8f959e;
}
.ai-modal-acts { display: flex; gap: 10px; }
.ai-modal-btn {
    flex: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 38px;
    border: 0;
    border-radius: 9px;
    font-size: 13.5px;
    font-weight: 600;
    cursor: pointer;
    transition: all .16s;
}
.ai-modal-btn.ghost { background: #f3f5f8; color: #6b7280; }
.ai-modal-btn.ghost:hover { background: #e9ecf1; }
.ai-modal-btn.primary {
    background: linear-gradient(135deg, #f76341, #ff8a5c);
    color: #fff;
    box-shadow: 0 5px 14px rgba(247, 99, 65, .28);
}
.ai-modal-btn.primary:hover { color: #fff; }

/* ---------- 自适应 ---------- */
@media (max-width: 1100px) {
    .ai-side { display: none; }
    .ai-app {
        border-radius: 16px;
        border-left: 1px solid #e4e7ec;
    }
}

@media (max-width: 860px) {
    .ai-frame {
        height: calc(100vh - 88px);
        min-height: 480px;
        margin: 8px auto 12px;
        padding: 0 12px;
    }
    .ai-bar-in { height: 48px; padding: 0 14px; }
    .ai-scroll { padding: 0 14px; }
    .ai-bottom { padding: 10px 14px 12px; }
    .ai-intro { padding: 0 16px 8px; }
    .ai-intro h1 { font-size: 20px; }
    .ai-intro p { font-size: 13px; }
    .ai-intro-mark { width: 42px; height: 42px; font-size: 19px; margin-bottom: 14px; }
    .ai-chips { gap: 7px; margin-top: 18px; }
    .ai-chip { font-size: 12px; padding: 6px 11px; }
    .ai-ai-text { font-size: 14px; }
    .ai-user-bubble { max-width: 86%; font-size: 13.5px; }
}

@media (max-width: 560px) {
    .ai-frame { height: calc(100vh - 80px); margin: 6px auto 10px; }
    .ai-scroll { padding: 0 12px; }
    .ai-bottom { padding: 8px 12px 10px; }
    .ai-thread { gap: 18px; }
    .ai-intro h1 { font-size: 18px; }
    .ai-intro p { font-size: 12px; line-height: 1.6; }
    .ai-chips { max-width: 100%; }
    .ai-ai-mark { width: 22px; height: 22px; font-size: 11px; border-radius: 7px; }
    .ai-msg--ai { gap: 8px; }
    .ai-user-bubble { max-width: 90%; }
    .ai-bar-new span { display: none; }
    .ai-bar-new { width: 30px; padding: 0; justify-content: center; }
    .ai-meta-left { font-size: 10.5px; }
}
