/* Madeline 聊天卡片基础样式：diary 与 write 共用，页面样式在其后覆盖差异项 */
#madeline-chat-dialog {
    width: 420px;
    height: 500px;
    background: url('../celeste-gui/card.webp') top / 100% 123% no-repeat;
    border: none;
    border-radius: 0;
    display:flex; flex-direction:column;
    opacity:0; pointer-events:none;
    transform: perspective(1200px) rotateY(32deg) rotateX(8deg) scale(0.85);
    transform-origin: 100% 100%;
    transition: opacity .3s ease, transform .45s cubic-bezier(0.34,1.3,0.64,1);
    z-index:1000;
    box-shadow: 0 10px 30px rgba(0,0,0,.35);
    overflow:hidden;
}
#madeline-chat-dialog.show {
    opacity:1; pointer-events:all;
    transform: perspective(1200px) rotateY(0) rotateX(0) scale(1);
}
.chat-header {
    padding: 14px 16px 8px 42px;
    display:flex; align-items:center; gap:10px;
    border-bottom: 1px dashed rgba(58,46,42,.35);
    background: transparent;
    flex-shrink:0;
}
#chat-madeline-avatar-wrap {
    width:32px; height:32px; border-radius:50%; overflow:hidden;
    border:2px solid #2b2018; flex-shrink:0; display:block;
}
#chat-madeline-avatar-wrap img {
    width:100%; height:100%; object-fit:cover; display:block;
}
.chat-header .chat-title {
    font-family: var(--chat-font, 'Renogare','CelesteZH','Microsoft YaHei',sans-serif);
    font-size:18px;
    letter-spacing:1px;
    color: #2b2018;
    flex:1;
}
.chat-header .close-btn {
    width:24px; height:24px;
    border:none; border-radius:50%;
    background:transparent;
    color: rgba(43,32,24,.55);
    font-size:16px;
    cursor:pointer;
    display:flex; align-items:center; justify-content:center;
    flex-shrink:0;
    transition:color .2s;
}
.chat-header .close-btn:hover { color:#2b2018; }

.chat-messages {
    flex:1;
    overflow-y:auto;
    padding:14px 16px 10px 42px;
    display:flex;
    flex-direction:column;
    gap:10px;
    min-height:0;
}
.chat-messages::-webkit-scrollbar { width:4px; }
.chat-messages::-webkit-scrollbar-thumb { background:rgba(58,46,42,.4); border-radius:2px; }

/* 消息气泡 */
.msg-row {
    display:flex;
    align-items:flex-end;
    gap:8px;
    max-width:90%;
}
.msg-row.madeline-row { align-self:flex-start; }
.msg-row.user-row { align-self:flex-end; }

.msg-avatar-wrap {
    width:28px; height:28px; border-radius:50%; overflow:hidden;
    border:1px solid var(--c-yellow, #FFEB3B); flex-shrink:0; display:block;
}
.msg-avatar-wrap img {
    width:100%; height:100%; object-fit:cover; display:block;
}

.msg-bubble {
    padding:8px 12px;
    border-radius:12px;
    font-family: var(--chat-font, 'Renogare','CelesteZH','Microsoft YaHei',sans-serif);
    font-size:13px;
    line-height:1.6;
    word-break:break-word;
    max-width:260px;
}
.msg-row.madeline-row .msg-bubble {
    background: transparent;
    color: #3a2e2a;
    border: none;
    padding-left: 2px;
}
.msg-row.user-row .msg-bubble {
    background: rgba(74,144,226,.14);
    color: #2b3a52;
    border: 1px solid rgba(74,144,226,.4);
}

/* 输入区 */
.chat-input {
    margin-top: auto;
    display:flex; gap:8px;
    padding: 8px 10px 5px 10px;
    border-bottom: 1px dashed rgba(58,46,42,.35);
    background: transparent;
    flex-shrink:0;
}
.chat-input input {
    flex:1;
    padding:8px 10px;
    border-radius:6px;
    background: rgba(255,255,255,.55);
    color: #3a2e2a;
    border: 1px solid rgba(58,46,42,.35);
    font-family: var(--chat-font, 'Renogare','CelesteZH','Microsoft YaHei',sans-serif);
    font-size:13px;
    outline:none;
}
.chat-input input:focus { border-color:var(--c-teal, #7DCFFF); }
.chat-input input::placeholder { color:rgba(58,46,42,.45); }
.chat-input button {
    padding:8px 14px;
    border:none; border-radius:6px;
    background:var(--c-yellow, #FFEB3B); color:#111;
    font-family: 'Renogare', sans-serif;
    font-size: 14px;
    letter-spacing: 1px;
    cursor:pointer;
    box-shadow:inset 0 -2px var(--c-border, #111111);
    transition:background .2s;
    flex-shrink:0;
}
.chat-input button:hover:not(:disabled) { background:#ffeb85; }
.chat-input button:disabled { background:#555; color:#999; cursor:not-allowed; }
