* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Helvetica Neue", Helvetica, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", Arial, sans-serif;
}

body {
    background-color: #EDEDED; /* 經典微信灰底 */
    color: #333;
    overflow: hidden;
}

#app {
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh; /* 適應手機瀏覽器高度 */
    max-width: 600px;
    margin: 0 auto;
    background-color: #EDEDED;
    box-shadow: 0 0 10px rgba(0,0,0,0.1);
}

/* 頂部導航列 */
.wechat-header {
    background-color: #EDEDED;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    border-bottom: 1px solid #D5D5D5;
    position: relative;
    z-index: 10;
}

.header-left {
    display: flex;
    align-items: center;
    font-size: 16px;
    cursor: pointer;
}

.back-icon {
    font-size: 20px;
    margin-right: 4px;
    font-weight: 300;
}

.header-title {
    font-size: 17px;
    font-weight: 500;
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
}

.header-right {
    font-size: 20px;
    font-weight: bold;
    cursor: pointer;
}

/* 聊天區域 */
.chat-container {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
}

.chat-time {
    text-align: center;
    font-size: 12px;
    color: #999;
    margin-bottom: 16px;
}

/* 訊息結構 */
.message {
    display: flex;
    margin-bottom: 20px;
    align-items: flex-start;
}

.message.user {
    flex-direction: row-reverse;
}

.avatar {
    width: 40px;
    height: 40px;
    border-radius: 4px;
    background-color: #CCC;
    flex-shrink: 0;
}

.message.user .avatar {
    margin-left: 12px;
    background-image: url('data:image/svg+xml;utf8,<svg viewBox="0 0 100 100" xmlns="http://www.w3.org/2000/svg"><rect width="100" height="100" fill="%23FFD700"/><circle cx="50" cy="40" r="20" fill="%23FFF"/><path d="M20 90 Q50 60 80 90" stroke="%23FFF" stroke-width="8" fill="none"/></svg>');
    background-size: cover;
}

.message.clone .avatar {
    margin-right: 12px;
    background-image: url('data:image/svg+xml;utf8,<svg viewBox="0 0 100 100" xmlns="http://www.w3.org/2000/svg"><rect width="100" height="100" fill="%2387CEEB"/><circle cx="50" cy="40" r="20" fill="%23FFF"/><path d="M20 90 Q50 60 80 90" stroke="%23FFF" stroke-width="8" fill="none"/></svg>');
    background-size: cover;
}

.bubble {
    max-width: 70%;
    padding: 10px 14px;
    border-radius: 8px;
    font-size: 16px;
    line-height: 1.4;
    word-wrap: break-word;
    position: relative;
}

/* 箭頭 */
.bubble::before {
    content: "";
    position: absolute;
    top: 14px;
    width: 0;
    height: 0;
    border-style: solid;
}

/* 對方 (左側白底) */
.message.clone .bubble {
    background-color: #FFFFFF;
    color: #000;
}

.message.clone .bubble::before {
    left: -6px;
    border-width: 6px 6px 6px 0;
    border-color: transparent #FFFFFF transparent transparent;
}

/* 自己 (右側綠底) */
.message.user .bubble {
    background-color: #95EC69; /* 經典蘋果綠 */
    color: #000;
}

.message.user .bubble::before {
    right: -6px;
    border-width: 6px 0 6px 6px;
    border-color: transparent transparent transparent #95EC69;
}

/* 打字狀態 */
.typing-indicator {
    display: inline-block;
    padding: 4px 8px;
}

.dot {
    display: inline-block;
    width: 6px;
    height: 6px;
    background-color: #999;
    border-radius: 50%;
    margin: 0 2px;
    animation: bounce 1.4s infinite ease-in-out both;
}

.dot:nth-child(1) { animation-delay: -0.32s; }
.dot:nth-child(2) { animation-delay: -0.16s; }

@keyframes bounce {
    0%, 80%, 100% { transform: scale(0); }
    40% { transform: scale(1); }
}

/* 底部輸入區域 */
.wechat-footer {
    background-color: #F7F7F7;
    border-top: 1px solid #D5D5D5;
    padding: 8px 12px;
    display: flex;
    align-items: flex-end;
    gap: 10px;
    padding-bottom: max(8px, env(safe-area-inset-bottom));
}

.voice-icon, .emoji-icon, .add-icon {
    font-size: 26px;
    color: #333;
    cursor: pointer;
    line-height: 1;
    margin-bottom: 6px;
    user-select: none;
}

.input-wrapper {
    flex: 1;
    background-color: #FFF;
    border-radius: 4px;
    padding: 8px;
}

#message-input {
    width: 100%;
    border: none;
    outline: none;
    font-size: 16px;
    background: transparent;
}

.send-btn-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
}

.send-btn {
    background-color: #07C160;
    color: white;
    border: none;
    border-radius: 4px;
    padding: 8px 14px;
    font-size: 15px;
    cursor: pointer;
}

.send-btn.hidden {
    display: none;
}

#add-icon.hidden {
    display: none;
}
