.chat-tool-wrapper { --p-bg: #ffffff; --p-border: #e2e8f0; --p-primary: #14b8a6; --p-text: #0f172a; width: 100%; max-width: 1250px; margin: 0 auto; background: var(--p-bg); border-radius: 24px; padding: 32px; border: 1px solid var(--p-border); box-shadow: 0 10px 25px -5px rgba(0,0,0,0.05); transition: 0.3s; }
.chat-header-main { font-size: 1.5rem; font-weight: 600; color: var(--p-text); margin-bottom: 8px; display: flex; align-items: center; gap: 12px; }
.chat-badge { background: #ccfbf1; color: #0f766e; padding: 4px 12px; border-radius: 30px; font-size: 0.8rem; font-weight: 500; }
.chat-subtitle { color: #64748b; font-size: 0.95rem; padding-bottom: 16px; border-bottom: 1px solid var(--p-border); margin-bottom: 24px; }

.chat-layout { display: grid; grid-template-columns: 1fr 400px; gap: 32px; }
@media(max-width: 950px) { 
    .chat-layout { grid-template-columns: 1fr; } 
    .chat-tool-wrapper { padding: 20px; border-radius: 16px; }
    .chat-preview-container { align-items: center; }
}

.chat-controls { background: #f8fafc; padding: 24px; border-radius: 16px; border: 1px solid var(--p-border); }
.chat-control-group { margin-bottom: 16px; }
.chat-control-group label { display: block; font-weight: 600; margin-bottom: 8px; color: var(--p-text); font-size: 0.95rem; }
.chat-input, .chat-select { width: 100%; padding: 12px; background: #ffffff; border: 1px solid #cbd5e1; color: #0f172a; border-radius: 8px; outline: none; font-size: 0.95rem; transition: 0.2s; }
.chat-input:focus, .chat-select:focus { border-color: var(--p-primary); box-shadow: 0 0 0 3px rgba(20, 184, 166, 0.1); }
.chat-textarea { width: 100%; height: 80px; padding: 12px; background: #ffffff; border: 1px solid #cbd5e1; color: #0f172a; border-radius: 8px; outline: none; resize: none; font-family: inherit; }
.chat-textarea:focus { border-color: var(--p-primary); box-shadow: 0 0 0 3px rgba(20, 184, 166, 0.1); }

.sys-setup-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 12px; }
.sys-slider-wrap { display: flex; align-items: center; gap: 12px; background: #fff; padding: 8px 12px; border-radius: 8px; border: 1px solid #cbd5e1; }
.sys-slider-wrap input[type="range"] { flex: 1; accent-color: #10b981; }
.sys-slider-val { font-size: 0.85rem; font-weight: 600; font-family: monospace; color: #475569; width: 40px; text-align: right; }

.avatar-setup { display: flex; gap: 20px; }
.avatar-box { display: flex; flex-direction: column; align-items: center; gap: 8px; cursor: pointer; }
.avatar-preview { width: 50px; height: 50px; border-radius: 12px; background: #e2e8f0; border: 2px dashed #cbd5e1; display: flex; align-items: center; justify-content: center; overflow: hidden; position: relative; transition: 0.2s; }
.avatar-preview:hover { border-color: var(--p-primary); }
.avatar-preview img { width: 100%; height: 100%; object-fit: cover; display: none; }
.avatar-preview::after { content: '+'; font-size: 20px; color: #94a3b8; position: absolute; }
.avatar-preview.has-img::after { display: none; }
.avatar-preview.has-img img { display: block; }
.avatar-label { font-size: 0.8rem; font-weight: 500; color: #475569; }

.chat-btn-group { display: flex; gap: 12px; margin-top: 12px; }
.btn-primary { padding: 10px; flex: 1; background: var(--p-primary); color: white; border: none; border-radius: 8px; cursor: pointer; font-weight: 600; transition: 0.2s; display: flex; align-items: center; justify-content: center; gap: 6px;}
.btn-primary:hover { filter: brightness(1.1); transform: translateY(-1px); }
.btn-secondary { padding: 10px; flex: 1; background: #f1f5f9; color: #475569; border: 1px solid #cbd5e1; border-radius: 8px; cursor: pointer; font-weight: 600; transition: 0.2s; display: flex; align-items: center; justify-content: center; gap: 6px;}
.btn-secondary:hover { background: #e2e8f0; }
.btn-image { background: #f8fafc; border: 1px dashed #94a3b8; color: #475569; }
.btn-image:hover { border-color: var(--p-primary); color: var(--p-primary); background: #f0fdfa; }

.msg-list { margin-top: 24px; border-top: 1px dashed #cbd5e1; padding-top: 16px; max-height: 200px; overflow-y: auto; }
.msg-item { display: flex; justify-content: space-between; align-items: center; background: #ffffff; padding: 10px 12px; border: 1px solid #e2e8f0; border-radius: 8px; margin-bottom: 8px; font-size: 0.9rem; color: #334155; }
.msg-item-del { color: #ef4444; cursor: pointer; font-weight: bold; background: none; border: none; }
.msg-preview-img { height: 24px; border-radius: 4px; vertical-align: middle; margin-left: 8px; border: 1px solid #e2e8f0;}

.chat-preview-container { display: flex; flex-direction: column; align-items: center; }
.phone-mockup { width: 375px; height: 812px; background: #ffffff; border-radius: 40px; border: 12px solid #0f172a; overflow: hidden; display: flex; flex-direction: column; position: relative; box-shadow: 0 20px 25px -5px rgba(0,0,0,0.1); }

.status-bar { height: 48px; display: flex; justify-content: space-between; align-items: center; padding: 0 24px 0 32px; font-size: 15px; font-weight: 600; font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif; z-index: 10; position: relative; letter-spacing: -0.2px; }
.status-right { display: flex; align-items: center; gap: 5px; }
.status-icon { display: flex; align-items: center; justify-content: center; }
.status-network-text { font-size: 12px; font-weight: 700; margin-right: 2px; margin-left: 1px; }

.chat-screen { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 16px; }
.chat-screen::-webkit-scrollbar { width: 0px; }
.bottom-bar { padding: 10px 16px 30px 16px; display: flex; align-items: center; }

.bubble img { max-width: 220px; max-height: 300px; object-fit: cover; display: block; }
.bubble.image-msg { padding: 0 !important; background: transparent !important; border: none !important; box-shadow: none !important; overflow: hidden; }

.mock-input-text { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; width: 100%; transition: color 0.2s; }

.theme-ios .status-bar { background: #f9f9f9; color: #000; }
.theme-ios .phone-header { background: #f9f9f9; padding: 0 16px 12px 16px; border-bottom: 1px solid #e5e5ea; display: flex; align-items: center; justify-content: center; position: relative; }
.theme-ios .header-title { font-weight: 600; color: #000; font-size: 1.1rem; display: flex; flex-direction: column; align-items: center; }
.theme-ios .header-avatar { width: 45px; height: 45px; border-radius: 50%; background: #ccc; margin-bottom: 4px; overflow: hidden; }
.theme-ios .header-avatar img { width: 100%; height: 100%; object-fit: cover; }
.theme-ios .header-back { position: absolute; left: 16px; color: #007aff; font-size: 1.5rem; display: flex; align-items: center; gap: 4px; }
.theme-ios .header-back::before { content: '❮'; }
.theme-ios .chat-screen { background: #ffffff; }
.theme-ios .bubble { max-width: 75%; padding: 10px 16px; font-size: 1rem; line-height: 1.4; word-wrap: break-word; position: relative; }
.theme-ios .bubble.me { background: #0b93f6; color: white; border-radius: 18px 18px 4px 18px; align-self: flex-end; }
.theme-ios .bubble.them { background: #e5e5ea; color: black; border-radius: 18px 18px 18px 4px; align-self: flex-start; }
.theme-ios .bubble.image-msg img { border-radius: 18px; }
.theme-ios .bottom-bar { background: #f9f9f9; border-top: 1px solid #e5e5ea; gap: 12px; color: #8e8e93; }
.theme-ios .bottom-bar-input { flex: 1; height: 36px; border-radius: 18px; border: 1px solid #c7c7cc; background: #fff; padding: 0 16px; display: flex; align-items: center; color: #c7c7cc; font-size: 1rem; }
.theme-ios .bottom-bar-icon { font-size: 1.5rem; color: #007aff; }

.theme-wechat .status-bar { background: #ededed; color: #000; }
.theme-wechat .phone-header { background: #ededed; padding: 0 16px 12px 16px; display: flex; align-items: center; justify-content: center; position: relative; border-bottom: 1px solid #dcdcdc; }
.theme-wechat .header-title { font-weight: 500; color: #111; font-size: 1.1rem; }
.theme-wechat .header-back { position: absolute; left: 16px; color: #111; font-size: 1.2rem; display: flex; align-items: center; gap: 4px; }
.theme-wechat .header-back::before { content: '❮'; }
.theme-wechat .chat-screen { background: #ededed; }
.theme-wechat .bubble-wrapper { display: flex; gap: 12px; width: 100%; margin-bottom: 4px; }
.theme-wechat .bubble-wrapper.me { flex-direction: row-reverse; }
.theme-wechat .chat-avatar { width: 40px; height: 40px; border-radius: 6px; background-color: #fff; flex-shrink: 0; overflow: hidden; }
.theme-wechat .chat-avatar img { width: 100%; height: 100%; object-fit: cover; }
.theme-wechat .bubble { max-width: 65%; padding: 10px 14px; font-size: 1rem; line-height: 1.5; word-wrap: break-word; border-radius: 8px; position: relative; }
.theme-wechat .bubble.me { background: #95ec69; color: #000; }
.theme-wechat .bubble.them { background: #ffffff; color: #000; }
.theme-wechat .bubble.image-msg img { border-radius: 8px; }
.theme-wechat .bottom-bar { background: #f7f7f7; border-top: 1px solid #ececec; gap: 12px; }
.theme-wechat .bottom-bar-icon { width: 28px; height: 28px; border-radius: 50%; border: 2px solid #111; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.theme-wechat .bottom-bar-input { flex: 1; height: 40px; background: #fff; border-radius: 4px; padding: 0 12px; display: flex; align-items: center; font-size: 1rem; }

.theme-wa .status-bar { background: #075e54; color: #fff; }
.theme-wa .phone-header { background: #075e54; padding: 0 16px 12px 16px; display: flex; align-items: center; gap: 12px; color: white; }
.theme-wa .header-back { font-size: 1.2rem; display: flex; align-items: center; margin-right: -4px;}
.theme-wa .header-back::before { content: '❮'; }
.theme-wa .header-avatar { width: 40px; height: 40px; background: #ccc; border-radius: 50%; overflow: hidden; }
.theme-wa .header-avatar img { width: 100%; height: 100%; object-fit: cover; }
.theme-wa .header-title { font-weight: 600; font-size: 1.1rem; }
.theme-wa .chat-screen { background: #efe7dd url('https://i.ibb.co/3M3w5B8/wa-bg.png') repeat; background-size: contain; }
.theme-wa .bubble { max-width: 80%; padding: 8px 12px; font-size: 0.95rem; line-height: 1.4; word-wrap: break-word; border-radius: 8px; box-shadow: 0 1px 1px rgba(0,0,0,0.1); position: relative; }
.theme-wa .bubble.me { background: #dcf8c6; color: #000; align-self: flex-end; border-top-right-radius: 0; }
.theme-wa .bubble.them { background: #ffffff; color: #000; align-self: flex-start; border-top-left-radius: 0; }
.theme-wa .bubble-time { font-size: 0.7rem; color: #999; float: right; margin: 8px 0 -4px 12px; }
.theme-wa .bubble.image-msg { padding: 4px !important; border-radius: 8px !important; box-shadow: 0 1px 1px rgba(0,0,0,0.1) !important; background: #fff !important; }
.theme-wa .bubble.image-msg.me { background: #dcf8c6 !important; }
.theme-wa .bubble.image-msg img { border-radius: 4px; }
.theme-wa .bottom-bar { background: transparent; padding: 10px; gap: 8px; padding-bottom: 30px; }
.theme-wa .bottom-bar-input { flex: 1; height: 42px; background: #fff; border-radius: 21px; display: flex; align-items: center; padding: 0 16px; color: #888; box-shadow: 0 1px 2px rgba(0,0,0,0.1); }
.theme-wa .wa-mic-btn { width: 42px; height: 42px; background: #00897b; border-radius: 50%; display: flex; align-items: center; justify-content: center; color: #fff; box-shadow: 0 1px 2px rgba(0,0,0,0.1); }

[data-theme="dark"] .chat-tool-wrapper { background: #1e293b !important; border-color: #334155 !important; }
[data-theme="dark"] .chat-controls { background: #0f172a; border-color: #475569; }
[data-theme="dark"] .chat-input, [data-theme="dark"] .chat-select, [data-theme="dark"] .chat-textarea { background: #1e293b; border-color: #475569; color: #f8fafc; }
[data-theme="dark"] .msg-item, [data-theme="dark"] .sys-slider-wrap { background: #1e293b; border-color: #475569; color: #cbd5e1; }
[data-theme="dark"] .sys-slider-val, [data-theme="dark"] .avatar-label { color: #cbd5e1; }
[data-theme="dark"] .btn-image { background: #0f172a; border-color: #475569; color: #cbd5e1; }
[data-theme="dark"] .btn-image:hover { background: #1e293b; border-color: var(--p-primary); }