:root {
    --primary-color: #1465ff;
    --primary-gradient: linear-gradient(135deg, #1465ff 0%, #00d2ff 100%);
    --bg-color: #f0f2f5;
    --chat-bg: #f9f9f9;
    --text-main: #333;
    --text-muted: #8e8e93;
    --bubble-user-bg: var(--primary-gradient);
    --bubble-user-text: #ffffff;
    --bubble-service-bg: #ffffff;
    --bubble-service-text: #333;
    --header-height: 60px;
    --input-height: 70px;
    --safe-area-bottom: env(safe-area-inset-bottom);
}

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

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background-color: var(--bg-color);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    -webkit-font-smoothing: antialiased;
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 4px;
}
::-webkit-scrollbar-thumb {
    background: rgba(0,0,0,0.1);
    border-radius: 10px;
}

/* Layout */
.chatContainer {
    display: flex;
    flex-direction: column;
    width: 100%;
    height: 100%;
    max-width: 600px; /* Optimized for mobile, centered on PC */
    margin: 0 auto;
    background-color: var(--chat-bg);
    position: relative;
    box-shadow: 0 0 20px rgba(0,0,0,0.05);
}

/* Header */
.chatHeader {
    height: var(--header-height);
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(10px);
    display: flex;
    align-items: center;
    padding: 0 20px;
    border-bottom: 1px solid rgba(0,0,0,0.05);
    z-index: 100;
    position: sticky;
    top: 0;
}

.chatHeader .avatar {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    background: var(--primary-gradient);
    padding: 2px;
    margin-right: 12px;
}

.chatHeader .avatar img {
    width: 100%;
    height: 100%;
    border-radius: 10px;
    object-fit: cover;
}

.chatHeader .info {
    flex: 1;
}

.chatHeader .title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-main);
}

.chatHeader .status {
    font-size: 12px;
    color: #2ecc71;
    display: flex;
    align-items: center;
}

.chatHeader .status::before {
    content: '';
    width: 6px;
    height: 6px;
    background: #2ecc71;
    border-radius: 50%;
    margin-right: 5px;
    box-shadow: 0 0 5px #2ecc71;
}

/* Content Area */
.chatContentView {
    flex: 1;
    overflow-y: auto;
    padding: 20px 15px;
    scroll-behavior: smooth;
    display: flex;
    flex-direction: column;
}

#chatContent {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* Message Bubbles */
.messageItem {
    display: flex;
    max-width: 85%;
    animation: messageEntry 0.3s cubic-bezier(0.18, 0.89, 0.32, 1.28);
}

@keyframes messageEntry {
    from { opacity: 0; transform: translateY(15px) scale(0.95); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.messageItem.service {
    align-self: flex-start;
}

.messageItem.user {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.messageItem .avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    margin: 0 8px;
    flex-shrink: 0;
}

.messageItem .avatar img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
}

.bubble {
    padding: 12px 16px;
    font-size: 14px;
    line-height: 1.5;
    position: relative;
    box-shadow: 0 2px 10px rgba(0,0,0,0.03);
}

.messageItem.service .bubble {
    background: var(--bubble-service-bg);
    color: var(--bubble-service-text);
    border-radius: 4px 16px 16px 16px;
}

.messageItem.user .bubble {
    background: var(--bubble-user-bg);
    color: var(--bubble-user-text);
    border-radius: 16px 4px 16px 16px;
}

.bubble .time {
    font-size: 10px;
    margin-top: 5px;
    opacity: 0.6;
    display: block;
}

.messageItem.user .bubble .time {
    text-align: right;
}

/* Images */
.bubble img.contentImg {
    max-width: 100%;
    border-radius: 8px;
    display: block;
    cursor: pointer;
}

/* Input Area */
.chatInputArea {
    background: white;
    padding: 10px 15px calc(10px + var(--safe-area-bottom));
    display: flex;
    align-items: flex-end;
    gap: 10px;
    border-top: 1px solid rgba(0,0,0,0.05);
}

.actionBtn {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: #f0f2f5;
    color: var(--text-muted);
    border: none;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 18px;
}

.actionBtn:active {
    transform: scale(0.9);
}

.inputWrapper {
    flex: 1;
    background: #f0f2f5;
    border-radius: 20px;
    padding: 5px 15px;
    display: flex;
    align-items: center;
}

#textContent {
    width: 100%;
    min-height: 34px;
    max-height: 100px;
    background: transparent;
    border: none;
    resize: none;
    font-size: 15px;
    padding: 7px 0;
    line-height: 20px;
    color: var(--text-main);
}

#sendText {
    background: var(--primary-gradient);
    color: white;
    box-shadow: 0 4px 10px rgba(20, 101, 255, 0.3);
}

/* Utilities */
#notice { display: none; }

/* Connection Status Overlay */
#connStatus {
    position: absolute;
    top: 65px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0,0,0,0.6);
    color: white;
    padding: 5px 15px;
    border-radius: 20px;
    font-size: 12px;
    display: none;
    z-index: 200;
}