:root {
    --steam-bg-dark: #171a21;
    --steam-bg-secondary: #1b2838;
    --steam-header-bg: #171d25;
    --steam-content-bg: #0f1215; /* 极深的聊天背景 */
    --steam-text-main: #c7d5e0;
    --steam-text-highlight: #ffffff;
    --steam-text-secondary: #8f98a0;
    --steam-blue: #66c0f4;
    --steam-blue-hover: #41a5e4;
    --steam-green: #a4d007;
    --steam-message-bg-other: #1b2838; /* 别人的消息背景 */
    --steam-message-bg-self: #2a475e;  /* 自己的消息背景 */
    --steam-border: #2a475e;
    --steam-input-bg: #222b35;
    --shadow-soft: 0 4px 12px rgba(0, 0, 0, 0.5);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: "Motiva Sans", "Helvetica Neue", Helvetica, Arial, "PingFang SC", "Microsoft YaHei", sans-serif;
    background-color: var(--steam-bg-dark);
    color: var(--steam-text-main);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    /* Steam 风格的深色背景纹理 */
    background: radial-gradient(circle at top center, #2a475e 0%, #171a21 60%);
}

.container {
    width: 100%;
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* 登录界面 */
.login-screen {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    backdrop-filter: blur(5px);
}

.login-box {
    background: linear-gradient(135deg, #2a475e 0%, #1b2838 100%);
    padding: 3rem 2.5rem;
    border-radius: 4px; /* Steam 风格圆角较小 */
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.5);
    text-align: center;
    max-width: 440px;
    width: 90%;
    border: 1px solid #3c4d5d;
    position: relative;
    overflow: hidden;
}

/* 顶部光条装饰 */
.login-box::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 2px;
    background: linear-gradient(90deg, var(--steam-blue), transparent);
}

.login-box h1 {
    font-size: 24px;
    color: var(--steam-blue);
    margin-bottom: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 300;
}

.subtitle {
    color: var(--steam-text-secondary);
    margin-bottom: 2rem;
    font-size: 14px;
}

.login-box input {
    width: 100%;
    padding: 12px;
    background: #101215;
    border: 1px solid #000;
    border-radius: 2px;
    color: var(--steam-text-main);
    font-size: 15px;
    margin-bottom: 1.5rem;
    transition: all 0.3s;
    box-shadow: inset 0 0 8px rgba(0,0,0,0.5);
}

.login-box input:focus {
    outline: none;
    border-color: var(--steam-blue);
    background: #181d24;
}

/* 聊天界面 */
.chat-screen {
    width: 100%;
    height: 100%;
    padding: 2rem; /* 增加外边距，像桌面应用窗口 */
}

@media (max-width: 768px) {
    .chat-screen {
        padding: 0;
    }
}

.chat-container {
    background: var(--steam-bg-secondary);
    border-radius: 4px;
    max-width: 1000px;
    margin: 0 auto;
    height: 100%; /* 充满容器 */
    max-height: 90vh; /* 上下留空 */
    display: flex;
    flex-direction: column;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.6);
    border: 1px solid #2a3f5a;
    position: relative;
}

@media (max-width: 768px) {
    .chat-container {
        max-height: 100vh;
        border: none;
    }
}

/* 头部 */
.chat-header {
    padding: 1rem 1.5rem;
    background: linear-gradient(to right, #171d25, #212c3d);
    border-bottom: 1px solid #000;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 10px rgba(0,0,0,0.2);
}

.header-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.header-info h2 {
    font-size: 18px;
    color: var(--steam-text-highlight);
    font-weight: 500;
    letter-spacing: 0.5px;
}

.username-badge {
    background: rgba(0, 0, 0, 0.3);
    padding: 4px 10px;
    border-radius: 2px;
    font-size: 12px;
    color: var(--steam-blue);
    border: 1px solid #3c4d5d;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.key-btn {
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid #3c4d5d;
    color: var(--steam-blue);
    padding: 6px 12px;
    border-radius: 2px;
    cursor: pointer;
    font-size: 16px;
    transition: all 0.2s;
}

.key-btn:hover {
    background: rgba(102, 192, 244, 0.2);
    border-color: var(--steam-blue);
}

.online-count {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: var(--steam-blue);
}

.status-dot {
    width: 8px;
    height: 8px;
    background: var(--steam-blue);
    border-radius: 50%;
    box-shadow: 0 0 8px var(--steam-blue);
}

/* 密钥管理模态框 */
.key-modal {
    max-width: 600px;
}

.key-info {
    margin: 1.5rem 0;
    padding: 1rem;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 4px;
    border: 1px solid #3c4d5d;
}

.key-info label {
    display: block;
    color: var(--steam-text-secondary);
    font-size: 12px;
    margin-bottom: 0.5rem;
}

.fingerprint {
    font-family: 'Courier New', monospace;
    font-size: 18px;
    color: var(--steam-blue);
    letter-spacing: 2px;
    padding: 0.5rem;
    background: #0f1215;
    border-radius: 2px;
    text-align: center;
    margin-bottom: 0.5rem;
}

.hint {
    font-size: 11px;
    color: var(--steam-text-secondary);
    margin: 0;
}

.key-actions-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
    margin: 1.5rem 0;
}

.btn-action {
    background: #2a3f5a;
    color: white;
    border: 1px solid #3c4d5d;
    padding: 0.8rem;
    border-radius: 2px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s;
}

.btn-action:hover {
    background: #3c5268;
    border-color: var(--steam-blue);
}

.btn-danger {
    background: #5a2a2a;
    border-color: #6d3535;
}

.btn-danger:hover {
    background: #7a3535;
    border-color: #ff4d4d;
}

.key-warning {
    background: rgba(255, 140, 0, 0.1);
    border: 1px solid rgba(255, 140, 0, 0.3);
    padding: 1rem;
    border-radius: 4px;
    color: #ffa500;
    font-size: 12px;
    line-height: 1.6;
}

/* 消息列表 */
.message-list {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem;
    background: var(--steam-content-bg);
    /* 内阴影 */
    box-shadow: inset 0 0 20px rgba(0,0,0,0.5);
}

.message {
    margin-bottom: 1.2rem;
    animation: fadeIn 0.2s ease;
}

.message-header {
    display: flex;
    align-items: baseline;
    gap: 8px;
    margin-bottom: 4px;
    padding-left: 4px;
}

.message-author {
    font-weight: bold;
    color: var(--steam-blue);
    font-size: 14px;
    cursor: pointer;
}

.message-author:hover {
    text-decoration: underline;
}

.message-time {
    font-size: 11px;
    color: #4f5a66;
}

.message-content {
    background: var(--steam-message-bg-other);
    padding: 10px 14px;
    border-radius: 0 4px 4px 4px; /* 硬朗风格 */
    color: #c6d4df;
    font-size: 14px;
    line-height: 1.5;
    position: relative;
    max-width: 85%;
    display: inline-block;
    border-left: 3px solid #3c4d5d;
}

/* 当前用户的消息 */
.message[data-self="true"] {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
}

.message[data-self="true"] .message-header {
    flex-direction: row-reverse;
    padding-right: 4px;
}

.message[data-self="true"] .message-content {
    background: var(--steam-message-bg-self);
    border-left: none;
    border-right: 3px solid var(--steam-blue);
    border-radius: 4px 0 4px 4px;
    color: white;
}

.message-content.edited::after {
    content: '(已编辑)';
    margin-left: 8px;
    font-size: 11px;
    color: #5c6670;
}

/* 操作按钮 */
.message-actions {
    margin-top: 4px;
    display: flex;
    gap: 8px;
    opacity: 0;
    transition: opacity 0.2s;
    justify-content: flex-end; /* 靠右对齐 */
}

.message:hover .message-actions {
    opacity: 1;
}

.message-actions button {
    background: transparent;
    color: #5c6670;
    border: none;
    font-size: 11px;
    cursor: pointer;
    padding: 2px 5px;
}

.message-actions button:hover {
    color: white;
    text-decoration: underline;
}

.message-actions button.delete-btn:hover {
    color: #ff4d4d;
}

.system-message {
    text-align: center;
    color: #4f5a66;
    font-size: 12px;
    margin: 1rem 0;
    border-bottom: 1px solid #1e242b;
    line-height: 0.1em;
}

.system-message span {
    background: var(--steam-content-bg);
    padding: 0 10px;
}

/* 输入区域 */
.input-area {
    padding: 1.5rem;
    background: #171d25;
    border-top: 1px solid #000;
    display: flex;
    gap: 0.5rem;
    align-items: flex-end;
}

.input-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.image-preview {
    position: relative;
    display: inline-block;
    max-width: 200px;
    padding: 4px;
    background: #222b35;
    border: 1px solid #364252;
    border-radius: 4px;
}

.image-preview img {
    display: block;
    max-width: 100%;
    max-height: 150px;
    border-radius: 2px;
}

.remove-preview {
    position: absolute;
    top: 8px;
    right: 8px;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    border: none;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.remove-preview:hover {
    background: rgba(255, 0, 0, 0.8);
}

#messageInput {
    width: 100%;
    padding: 12px;
    background: #222b35;
    border: 1px solid #364252;
    border-radius: 2px;
    color: #e1e1e1;
    font-size: 14px;
    font-family: inherit;
    resize: none;
    max-height: 120px;
    transition: border-color 0.2s;
}

#messageInput:focus {
    outline: none;
    border-color: var(--steam-blue);
    box-shadow: 0 0 5px rgba(102, 192, 244, 0.2);
}

.input-actions {
    display: flex;
    gap: 0.5rem;
    align-items: flex-end;
}

.action-btn {
    background: #2a3f5a;
    color: var(--steam-blue);
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 2px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    font-size: 18px;
}

.action-btn:hover {
    background: #3c5268;
    color: white;
}

/* 按钮样式 */
.btn-primary {
    background: linear-gradient(to bottom, #47bfff 5%, #1a44c2 100%); /* Steam 经典蓝渐变按钮 */
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 2px;
    font-size: 15px;
    cursor: pointer;
    text-shadow: 1px 1px 0px rgba(0,0,0,0.3);
    transition: all 0.2s;
    width: 100%;
    font-weight: 500;
    letter-spacing: 0.5px;
}

.btn-primary:hover {
    background: linear-gradient(to bottom, #66c0f4 5%, #225ad6 100%);
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0,0,0,0.4);
}

.send-btn {
    background: linear-gradient(to bottom, #47bfff 5%, #1a44c2 100%);
    color: white;
    border: none;
    padding: 0;
    width: 40px;
    height: 40px;
    border-radius: 2px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.send-btn:hover {
    background: linear-gradient(to bottom, #66c0f4 5%, #225ad6 100%);
}

.send-btn svg {
    width: 20px;
    height: 20px;
}

/* Emoji 选择器 */
.emoji-picker {
    position: absolute;
    bottom: 80px;
    right: 80px;
    background: linear-gradient(135deg, #2a475e 0%, #1b2838 100%);
    border: 1px solid #3c4d5d;
    border-radius: 4px;
    padding: 1rem;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
    z-index: 100;
    max-width: 320px;
}

.emoji-grid {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 8px;
    max-height: 200px;
    overflow-y: auto;
}

.emoji-item {
    font-size: 24px;
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    text-align: center;
    transition: background 0.2s;
}

.emoji-item:hover {
    background: rgba(102, 192, 244, 0.2);
}

/* 图片消息样式 */
.message-image {
    max-width: 100%;
    max-height: 400px;
    border-radius: 4px;
    cursor: pointer;
    transition: opacity 0.2s;
}

.message-image:hover {
    opacity: 0.9;
}

/* 模态框 */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(2px);
}

.modal.show {
    display: flex;
}

.modal-content {
    background: linear-gradient(135deg, #2a475e 0%, #1b2838 100%);
    padding: 2rem;
    border-radius: 2px;
    max-width: 500px;
    width: 90%;
    border: 1px solid #3c4d5d;
    box-shadow: 0 0 30px rgba(0,0,0,0.8);
}

.modal-content h3 {
    margin-bottom: 1rem;
    color: var(--steam-blue);
    text-transform: uppercase;
    font-size: 16px;
    border-bottom: 2px solid #2a475e;
    padding-bottom: 10px;
}

.modal-content textarea {
    width: 100%;
    padding: 10px;
    background: #0f1215;
    border: 1px solid #000;
    color: white;
    font-family: inherit;
    margin-bottom: 1.5rem;
    border-radius: 2px;
}

.modal-content textarea:focus {
    outline: none;
    border-color: var(--steam-blue);
}

.modal-actions {
    display: flex;
    gap: 1rem;
    justify-content: flex-end;
}

.btn-secondary {
    background: #3d4450;
    color: #c7d5e0;
    border: none;
    padding: 8px 20px;
    border-radius: 2px;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-secondary:hover {
    background: #4b5463;
    color: white;
}

/* 滚动条美化 (Webkit) */
::-webkit-scrollbar {
    width: 10px;
}

::-webkit-scrollbar-track {
    background: #171a21;
}

::-webkit-scrollbar-thumb {
    background: #2a3f5a;
    border-radius: 5px;
}

::-webkit-scrollbar-thumb:hover {
    background: #415b7a;
}

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

/* ===== 手机端适配 ===== */
@media screen and (max-width: 768px) {
    .container {
        padding: 0;
    }
    
    .login-box {
        width: 90%;
        padding: 30px 20px;
        margin: 20px;
    }
    
    .login-box h1 {
        font-size: 28px;
    }
    
    .chat-container {
        height: 100vh;
        border-radius: 0;
    }
    
    .chat-header {
        padding: 12px 15px;
    }
    
    .chat-header h2 {
        font-size: 16px;
    }
    
    .message-list {
        padding: 10px;
    }
    
    .message {
        max-width: 85%;
        padding: 10px 12px;
    }
    
    .message-author {
        font-size: 12px;
    }
    
    .message-content {
        font-size: 14px;
    }
    
    .message-time {
        font-size: 10px;
    }
    
    .input-area {
        padding: 10px;
    }
    
    .input-container textarea {
        font-size: 16px; /* 防止 iOS 缩放 */
        padding: 10px 12px;
    }
    
    .input-actions {
        gap: 8px;
    }
    
    .action-btn {
        width: 40px;
        height: 40px;
    }
    
    .send-btn {
        width: 44px;
        height: 44px;
    }
    
    .emoji-picker {
        width: 280px;
        right: 10px;
        bottom: 70px;
    }
    
    .emoji-grid {
        grid-template-columns: repeat(7, 1fr);
    }
    
    .modal-content {
        width: 90%;
        margin: 20px;
        padding: 20px;
    }
    
    .message-image {
        max-width: 100%;
    }
    
    /* 隐藏密钥管理按钮（手机端不需要） */
    .key-btn {
        display: none;
    }
    
    /* 消息操作按钮 */
    .message-actions {
        position: static;
        opacity: 1;
        margin-top: 8px;
    }
}
