* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

html, body {
    height: 100%;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
    font-size: 14px;
    line-height: 1.6;
    color: #333;
    background-color: #fff;
    overscroll-behavior: none;
}

.app-container {
    display: flex;
    flex-direction: column;
    height: 100%;
    max-width: 100%;
    overflow: hidden;
    position: relative;
}

.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 50px;
    padding: 0 16px;
    background: #fff;
    border-bottom: 1px solid #eee;
    flex-shrink: 0;
    z-index: 10;
}

.header-title {
    font-size: 18px;
    font-weight: bold;
    color: #333;
}

.header-my {
    font-size: 14px;
    color: #999;
    cursor: pointer;
}

.chat-container {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    background: #f5f5f5;
    -webkit-overflow-scrolling: touch;
}

.chat-container::-webkit-scrollbar {
    width: 4px;
}

.chat-container::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 2px;
}

.welcome-message {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
}

.message-avatar {
    width: 36px;
    height: 36px;
    background: #fff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    flex-shrink: 0;
}

.message-content {
    background: #f5f5f5;
    border-radius: 12px;
    padding: 12px 16px;
    max-width: 280px;
}

.message-text {
    color: #333;
    margin-bottom: 8px;
}

.message-text:last-child {
    margin-bottom: 0;
}

.welcome-list {
    margin: 8px 0;
    padding-left: 20px;
    color: #666;
}

.welcome-list li {
    margin-bottom: 4px;
}

.message-item {
    display: flex;
    gap: 10px;
    margin-bottom: 12px;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

.message-item.user .message-content {
    background: #07c160;
    color: #fff;
}

.message-item.user .message-content ul {
    color: rgba(255,255,255,0.9);
}

.message-item.user .message-content li {
    color: rgba(255,255,255,0.9);
}

.message-item.ai .message-content {
    background: #fff;
}

.message-item.ai .message-avatar {
    background: #fff;
}

.message-item .message-content {
    border-radius: 12px;
    padding: 10px 14px;
    max-width: 260px;
    word-break: break-word;
}

.message-item .message-content p {
    margin-bottom: 6px;
}

.message-item .message-content p:last-child {
    margin-bottom: 0;
}

.message-item .message-content ol,
.message-item .message-content ul {
    margin: 8px 0;
    padding-left: 20px;
}

.message-item .message-content li {
    margin-bottom: 4px;
}

.message-item .message-content strong {
    font-weight: 600;
}

.message-item .message-content em {
    font-style: italic;
}

.message-image {
    max-width: 200px;
    border-radius: 8px;
    margin-bottom: 8px;
    cursor: pointer;
}

.loading-dots {
    display: flex;
    gap: 4px;
    padding: 8px 0;
}

.loading-dots span {
    width: 8px;
    height: 8px;
    background: #999;
    border-radius: 50%;
    animation: bounce 1.4s infinite ease-in-out both;
}

.loading-dots span:nth-child(1) {
    animation-delay: -0.32s;
}

.loading-dots span:nth-child(2) {
    animation-delay: -0.16s;
}

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

.input-area {
    background: #fff;
    border-top: 1px solid #eee;
    padding: 10px 16px;
    flex-shrink: 0;
    z-index: 10;
}

.input-wrapper {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.image-preview {
    position: relative;
    display: inline-block;
}

.image-preview img {
    width: 80px;
    height: 80px;
    object-fit: cover;
    border-radius: 8px;
    border: 1px solid #eee;
}

.remove-image {
    position: absolute;
    top: -8px;
    right: -8px;
    width: 20px;
    height: 20px;
    background: #ff6b6b;
    color: #fff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    cursor: pointer;
}

.input-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.btn-camera {
    width: 40px;
    height: 40px;
    border: none;
    background: #f5f5f5;
    border-radius: 50%;
    font-size: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.btn-camera:active {
    background: #e0e0e0;
}

.input-field {
    flex: 1;
    height: 40px;
    padding: 0 16px;
    border: 1px solid #eee;
    border-radius: 20px;
    font-size: 14px;
    outline: none;
    background: #f5f5f5;
}

.input-field:focus {
    border-color: #07c160;
    background: #fff;
}

.btn-send {
    width: 56px;
    height: 40px;
    border: none;
    background: #07c160;
    color: #fff;
    border-radius: 20px;
    font-size: 14px;
    cursor: pointer;
    flex-shrink: 0;
}

.btn-send:disabled {
    background: #ccc;
    cursor: not-allowed;
}

.btn-send:not(:disabled):active {
    background: #059b4c;
}

.footer {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 40px;
    background: #fafafa;
    font-size: 12px;
    color: #999;
    gap: 2px;
    flex-shrink: 0;
    z-index: 10;
}

.my-panel {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1000;
    display: none;
}

.my-panel.active {
    display: block;
}

.panel-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(2px);
}

.panel-content {
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    width: 75%;
    max-width: 320px;
    background: #fff;
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
    }
    to {
        transform: translateX(0);
    }
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 50px;
    padding: 0 16px;
    border-bottom: 1px solid #eee;
    font-size: 16px;
    font-weight: 600;
}

.panel-close {
    font-size: 24px;
    color: #999;
    cursor: pointer;
}

.panel-body {
    padding: 20px 16px;
    overflow-y: auto;
    height: calc(100% - 50px);
    -webkit-overflow-scrolling: touch;
}

.usage-info {
    margin-bottom: 24px;
}

.usage-title,
.member-title,
.benefits-title {
    font-size: 14px;
    color: #999;
    margin-bottom: 10px;
}

.usage-count {
    display: flex;
    justify-content: space-between;
    font-size: 14px;
}

.usage-count strong {
    color: #07c160;
}

.member-status {
    margin-bottom: 24px;
}

.member-content {
    font-size: 14px;
    color: #333;
}

.member-benefits {
    margin-bottom: 24px;
}

.benefits-list {
    list-style: none;
}

.benefits-list li {
    font-size: 14px;
    color: #333;
    margin-bottom: 8px;
}

.btn-open-member {
    width: 100%;
    padding: 14px;
    background: linear-gradient(135deg, #07c160, #06ad56);
    border: none;
    border-radius: 12px;
    color: #fff;
    cursor: pointer;
    text-align: center;
    box-shadow: 0 4px 12px rgba(7, 193, 96, 0.3);
}

.btn-open-member strong {
    font-size: 16px;
    display: block;
    margin-bottom: 4px;
}

.btn-open-member span {
    font-size: 12px;
    opacity: 0.9;
}

.btn-open-member:active {
    transform: scale(0.98);
}

.toast {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 0, 0, 0.75);
    color: #fff;
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 14px;
    z-index: 2000;
    display: none;
    animation: toastFade 0.3s ease;
    max-width: 80%;
    word-break: break-word;
}

@keyframes toastFade {
    from {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.9);
    }
    to {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }
}

.toast.show {
    display: block;
}

/* 图片查看器 */
.image-viewer {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.9);
    z-index: 3000;
    display: none;
    align-items: center;
    justify-content: center;
    animation: viewerFadeIn 0.3s ease;
}

.image-viewer.show {
    display: flex;
}

.image-viewer img {
    max-width: 90%;
    max-height: 90%;
    border-radius: 8px;
    animation: imageZoomIn 0.3s ease;
}

@keyframes viewerFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes imageZoomIn {
    from { transform: scale(0.8); }
    to { transform: scale(1); }
}

/* 适配微信键盘弹出 */
@media screen and (max-height: 500px) {
    .footer {
        display: none;
    }
    
    .input-area {
        padding-bottom: 8px;
    }
}

@media screen and (max-width: 320px) {
    .header {
        padding: 0 12px;
    }

    .header-title {
        font-size: 16px;
    }

    .chat-container {
        padding: 12px;
    }

    .message-content {
        max-width: 220px;
    }

    .input-area {
        padding: 8px 12px;
    }

    .message-item .message-image {
        max-width: 160px;
    }
}

/* 横屏适配 */
@media screen and (orientation: landscape) and (max-height: 450px) {
    .header {
        height: 40px;
    }
    
    .footer {
        display: none;
    }
    
    .input-area {
        padding: 8px 16px;
    }
}