/* =============================================
   大嘴聊天 — 现代简约风格
   ============================================= */

:root {
    --primary: #6366f1;
    --primary-hover: #4f46e5;
    --bg: #f0f0f5;
    --card-bg: #fff;
    --text: #1a1a2e;
    --text-secondary: #6b7280;
    --border: #e5e7eb;
    --radius: 12px;
    --input-bg: #f9fafb;
    --gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

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

html, body { height: 100%; overflow: hidden; }

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
    font-size: 15px; color: var(--text); background: var(--bg); line-height: 1.6;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* =========== 认证页 =========== */
.auth-page {
    display: flex; justify-content: center; align-items: center;
    min-height: 100vh; padding: 20px;
    background: var(--gradient);
}
.auth-card {
    background: var(--card-bg); border-radius: 16px;
    padding: 40px 32px; width: 420px; max-width: 100%;
    box-shadow: 0 20px 60px rgba(0,0,0,.15);
}
.auth-header { text-align: center; margin-bottom: 28px; }
.auth-logo { font-size: 48px; margin-bottom: 8px; }
.auth-header h1 { font-size: 22px; font-weight: 700; margin-bottom: 4px; }
.auth-subtitle { color: var(--text-secondary); font-size: 14px; }
.auth-footer { text-align: center; margin-top: 20px; font-size: 14px; color: var(--text-secondary); }

.auth-form { display: flex; flex-direction: column; gap: 16px; }
.field { display: flex; flex-direction: column; gap: 4px; }
.field label { font-size: 13px; font-weight: 600; color: var(--text-secondary); }
.field input[type="text"],
.field input[type="password"] {
    padding: 10px 14px; border: 1px solid var(--border); border-radius: 8px;
    font-size: 15px; font-family: inherit; outline: none; background: var(--input-bg);
    transition: border .2s;
}
.field input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(99,102,241,.15); }
.req { color: #ef4444; } .opt { font-weight: 400; color: #9ca3af; }

.checkbox-row { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--text-secondary); cursor: pointer; }
.checkbox-row input { width: 16px; height: 16px; accent-color: var(--primary); }

.btn-primary {
    padding: 12px; border: none; border-radius: 8px;
    background: var(--primary); color: #fff; font-size: 16px; font-weight: 600;
    cursor: pointer; transition: background .2s;
}
.btn-primary:hover { background: var(--primary-hover); }

.toast { padding: 10px 14px; border-radius: 8px; font-size: 14px; margin-bottom: 12px; }
.toast-error { background: #fef2f2; color: #dc2626; border: 1px solid #fecaca; }
.toast-success { background: #f0fdf4; color: #16a34a; border: 1px solid #bbf7d0; }

.avatar-grid { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 4px; }
.avatar-item { cursor: pointer; }
.avatar-item input { display: none; }
.avatar-item img {
    width: 48px; height: 48px; border-radius: 50%; border: 3px solid transparent; transition: all .15s;
}
.avatar-item input:checked + img {
    border-color: var(--primary); transform: scale(1.1); box-shadow: 0 0 0 3px rgba(99,102,241,.25);
}

/* =========== 聊天页面布局 =========== */
.chat-page {
    height: 100vh; display: flex; flex-direction: column;
    background: var(--gradient); overflow: hidden;
}

/* 顶栏 */
.chat-topbar {
    background: linear-gradient(135deg, #1e1b4b 0%, #312e81 100%);
    color: #fff; padding: 10px 20px; display: flex;
    justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,.1);
}
.chat-topbar .brand { font-size: 18px; font-weight: 700; }
.chat-topbar .brand a { color: #fff; text-decoration: none; }
.chat-topbar .topbar-center { color: #a5b4fc; font-size: 13px; }
.chat-topbar .topbar-right { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.chat-topbar .topbar-right a { color: #c7d2fe; }
.chat-topbar .topbar-right a:hover { color: #fff; }

.rank-badge {
    display: inline-block; color: #fff; padding: 2px 8px;
    font-size: 11px; font-weight: 700; border-radius: 4px;
}

/* 聊天主体 */
.chat-body { display: flex; flex: 1; padding: 12px; gap: 12px; max-width: 1200px; margin: 0 auto; width: 100%; overflow: hidden; }

/* ---- 侧边栏 ---- */
.chat-sidebar { width: 200px; flex-shrink: 0; display: flex; flex-direction: column; gap: 12px; overflow-y: auto; }

.sidebar-card {
    background: var(--card-bg); border-radius: var(--radius);
    padding: 16px; box-shadow: 0 1px 4px rgba(0,0,0,.06);
}
.sidebar-card h3 { font-size: 13px; font-weight: 700; color: var(--text-secondary); text-transform: uppercase; margin-bottom: 10px; letter-spacing: .5px; }

.room-list { list-style: none; }
.room-list li { padding: 6px 8px; border-radius: 6px; margin-bottom: 2px; transition: background .15s; }
.room-list li:hover { background: var(--input-bg); }
.room-list li.active { background: #eef2ff; }
.room-list li.active a { color: var(--primary); font-weight: 600; }
.room-list a { font-size: 14px; display: block; }
.room-meta { font-size: 11px; color: var(--text-secondary); }

.online-list { list-style: none; }
.online-list li { padding: 4px 0; font-size: 13px; display: flex; align-items: center; gap: 6px; }
.online-dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }

.create-room { margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--border); }
.create-room summary { cursor: pointer; font-size: 13px; color: var(--primary); font-weight: 600; }
.create-room form { margin-top: 8px; display: flex; flex-direction: column; gap: 6px; }
.create-room input { padding: 6px 10px; border: 1px solid var(--border); border-radius: 6px; font-size: 13px; font-family: inherit; background: var(--input-bg); }
.create-room button { padding: 6px 12px; background: var(--primary); color: #fff; border: none; border-radius: 6px; font-size: 13px; cursor: pointer; }

/* ---- 聊天主区域 ---- */
.chat-main { flex: 1; min-width: 0; min-height: 0; display: flex; flex-direction: column; }

.chat-card {
    background: var(--card-bg); border-radius: var(--radius);
    box-shadow: 0 1px 4px rgba(0,0,0,.06); display: flex; flex-direction: column;
    flex: 1; overflow: hidden;
}
.chat-card-header {
    padding: 12px 16px; border-bottom: 1px solid var(--border);
    font-weight: 700; font-size: 15px; display: flex; justify-content: space-between; align-items: center;
}
.chat-card-header .room-info { font-size: 12px; color: var(--text-secondary); font-weight: 400; }

.msg-list { flex: 1; overflow-y: auto; padding: 12px 16px; display: flex; flex-direction: column; gap: 6px; }
.msg { display: flex; align-items: flex-start; gap: 8px; animation: fadeIn .2s; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: translateY(0); } }

.msg-avatar { width: 32px; height: 32px; border-radius: 50%; flex-shrink: 0; overflow: hidden; }
.msg-avatar img { width: 100%; height: 100%; }
.msg-body { flex: 1; min-width: 0; }
.msg-meta { display: flex; align-items: center; gap: 6px; margin-bottom: 2px; }
.msg-user { font-weight: 700; font-size: 13px; }
.msg-time { font-size: 11px; color: #999; }
.msg-rank-sm { color: #fff; padding: 0 4px; font-size: 10px; border-radius: 3px; }
.msg-text { font-size: 14px; line-height: 1.5; word-break: break-word; }

.msg-del-btn {
    background: none; border: none; color: #ccc; font-size: 14px;
    cursor: pointer; padding: 0 4px; line-height: 1; margin-left: auto;
}
.msg-del-btn:hover { color: #ef4444; }

/* @提及 */
.mention { color: var(--primary); font-weight: 700; background: rgba(99,102,241,0.1); padding: 1px 5px; border-radius: 4px; cursor: pointer; white-space: nowrap; }
.mention:hover { background: rgba(99,102,241,0.2); }
.mention-me { color: #fff; background: var(--primary); animation: mentionPulse .6s 3; }
@keyframes mentionPulse { 0%,100%{ box-shadow: 0 0 0 0 rgba(99,102,241,0.4) } 50%{ box-shadow: 0 0 0 6px rgba(99,102,241,0) } }
.msg-mentioned { border-left: 3px solid var(--primary); padding-left: 8px; animation: mentionGlow 1s 2; }
@keyframes mentionGlow { 0%,100%{ background:transparent } 50%{ background:rgba(99,102,241,0.06) } }

/* 城主墙 */
.wall-banner {
    font-size: 12px; background: linear-gradient(135deg, #fef3c7, #fde68a);
    color: #92400e; padding: 3px 12px; border-radius: 20px; font-weight: 700;
    animation: wallPulse 2s infinite; white-space: nowrap;
}
@keyframes wallPulse { 0%,100%{ box-shadow: 0 0 0 0 rgba(245,158,11,0.3) } 50%{ box-shadow: 0 0 0 4px rgba(245,158,11,0) } }

/* 输入区 */
.chat-input-bar {
    padding: 12px 16px; border-top: 1px solid var(--border);
    display: flex; gap: 8px; background: var(--input-bg);
}
.chat-input-bar input {
    flex: 1; padding: 10px 14px; border: 1px solid var(--border); border-radius: 8px;
    font-size: 15px; font-family: inherit; outline: none; background: #fff;
    transition: border .2s;
}
.chat-input-bar input:focus { border-color: var(--primary); }
.chat-input-bar button {
    padding: 10px 20px; background: var(--primary); color: #fff; border: none;
    border-radius: 8px; font-size: 14px; font-weight: 600; cursor: pointer;
    transition: background .2s;
}
.chat-input-bar button:hover { background: var(--primary-hover); }

.chat-muted { text-align: center; padding: 12px; color: #ef4444; font-size: 13px; background: #fef2f2; }

/* 管理按钮 */
.admin-actions { display: inline-flex; gap: 2px; margin-left: auto; }
.admin-btn {
    background: none; border: none; font-size: 12px; cursor: pointer;
    padding: 0 2px; opacity: 0.5;
}
.admin-btn:hover { opacity: 1; }

/* 页脚 */
.chat-footer {
    text-align: center; padding: 8px; font-size: 11px;
    color: var(--text-secondary); background: var(--card-bg);
    border-top: 1px solid var(--border);
}

/* 回退链接 */
.back-link { display: block; text-align: center; font-size: 13px; margin-top: 8px; }

/* 密码验证弹窗 */
.pwd-card {
    max-width: 400px; margin: 60px auto;
    background: var(--card-bg); border-radius: var(--radius); padding: 32px 24px;
    box-shadow: 0 8px 30px rgba(0,0,0,.1); text-align: center;
}
.pwd-card h2 { margin-bottom: 16px; }
.pwd-card input { width: 100%; padding: 10px; border: 1px solid var(--border); border-radius: 8px; text-align: center; font-size: 16px; }
.pwd-card button { margin-top: 12px; }

/* =========== 首页（Landing） =========== */
.landing-page {
    min-height: 100vh;
    display: flex; flex-direction: column;
    background: var(--bg);
}

/* 顶栏 */
.landing-topbar {
    background: linear-gradient(135deg, #1e1b4b 0%, #312e81 100%);
    color: #fff; padding: 10px 20px; display: flex;
    justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,.1);
}
.landing-topbar .brand { font-size: 18px; font-weight: 700; }
.landing-topbar .brand a { color: #fff; text-decoration: none; }
.landing-topbar .topbar-center { color: #a5b4fc; font-size: 13px; }
.landing-topbar .topbar-right { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.landing-topbar .topbar-right a { color: #c7d2fe; }
.landing-topbar .topbar-right a:hover { color: #fff; }

/* Hero */
.landing-hero {
    text-align: center; padding: 36px 20px 28px;
    background: var(--gradient);
}
.landing-hero h1 { font-size: 28px; color: #fff; font-weight: 800; margin: 0 0 6px; }
.landing-hero .subtitle { font-size: 14px; color: rgba(255,255,255,.75); margin-bottom: 20px; }
.landing-actions { display: flex; justify-content: center; gap: 10px; flex-wrap: wrap; }
.landing-btn {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 10px 22px; border-radius: 8px; font-size: 14px; font-weight: 600;
    text-decoration: none; transition: transform .15s, box-shadow .15s;
}
.landing-btn:hover { transform: translateY(-1px); box-shadow: 0 4px 12px rgba(0,0,0,.15); text-decoration: none; }
.landing-btn-primary { background: #fff; color: var(--primary); }
.landing-btn-outline { background: rgba(255,255,255,.15); color: #fff; border: 1px solid rgba(255,255,255,.3); }

/* 主区两栏 */
.landing-main {
    flex: 1; display: flex; gap: 16px;
    max-width: 1100px; margin: 0 auto; width: 100%; padding: 16px 20px 24px;
}
.landing-card {
    background: var(--card-bg); border-radius: var(--radius);
    box-shadow: 0 1px 4px rgba(0,0,0,.06);
    display: flex; flex-direction: column; overflow: hidden;
}
.landing-card-header {
    padding: 12px 16px; border-bottom: 1px solid var(--border);
    font-weight: 700; font-size: 14px; display: flex; align-items: center; gap: 6px;
}
.landing-card-body { flex: 1; overflow-y: auto; }

/* 房间列表 */
.landing-rooms { flex: 1; min-width: 0; }
.landing-rooms .landing-card-body { padding: 4px 8px; max-height: 400px; }
.landing-room-item {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 12px; border-radius: 8px; text-decoration: none; color: var(--text);
    transition: background .15s;
}
.landing-room-item:hover { background: var(--input-bg); text-decoration: none; }
.landing-room-item .room-icon { font-size: 24px; flex-shrink: 0; }
.landing-room-item .room-info { flex: 1; min-width: 0; }
.landing-room-item .room-name { font-size: 14px; font-weight: 600; }
.landing-room-item .room-desc { font-size: 12px; color: var(--text-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.landing-room-item .room-online { font-size: 12px; color: var(--text-secondary); flex-shrink: 0; background: var(--input-bg); padding: 2px 8px; border-radius: 10px; }

/* 大厅预览 */
.landing-chat { flex: 1; min-width: 0; }
.landing-chat .landing-card-body { padding: 4px 12px; max-height: 400px; }
.landing-msg { display: flex; gap: 8px; padding: 6px 0; border-bottom: 1px solid var(--input-bg); }
.landing-msg:last-child { border-bottom: none; }
.landing-msg-avatar { width: 28px; height: 28px; border-radius: 50%; flex-shrink: 0; overflow: hidden; }
.landing-msg-avatar img { width: 100%; height: 100%; }
.landing-msg-body { flex: 1; min-width: 0; }
.landing-msg-meta { display: flex; align-items: center; gap: 4px; margin-bottom: 2px; flex-wrap: wrap; }
.landing-msg-user { font-weight: 700; font-size: 12px; }
.landing-msg-rank { color: #fff; padding: 0 4px; font-size: 10px; border-radius: 3px; }
.landing-msg-time { font-size: 11px; color: #999; }
.landing-msg-text { font-size: 13px; line-height: 1.5; word-break: break-word; }
.landing-cta { text-align: center; padding: 12px; border-top: 1px solid var(--border); background: var(--input-bg); }
.landing-cta .hint { font-size: 12px; color: var(--text-secondary); margin-bottom: 8px; }
.landing-cta .btn-primary { display: inline-block; font-size: 13px; padding: 8px 20px; }

/* 页脚 */
.landing-footer {
    text-align: center; padding: 10px 20px; font-size: 11px;
    color: var(--text-secondary); background: var(--card-bg);
    border-top: 1px solid var(--border);
    display: flex; justify-content: center; align-items: center; gap: 8px; flex-wrap: wrap;
}

/* =========== 手机端 =========== */
@media (max-width: 700px) {
    .chat-body { flex-direction: column; padding: 8px; }
    .chat-sidebar { width: 100%; }
    .chat-body .chat-sidebar { order: 2; }
    .chat-main { order: 1; height: 55vh; }
    .auth-card { padding: 24px 18px; }
    .chat-topbar { padding: 8px 12px; }
    .chat-topbar .topbar-center { display: none; }
    .chat-input-bar input { font-size: 16px; }
    .avatar-item img { width: 40px; height: 40px; }

    /* 触控友好 */
    .chat-input-bar button, .btn-primary, .xh-input-bar button, .st-input-bar button,
    .ys-input-bar button, .ih-input-bar button { min-height: 44px; min-width: 44px; }
    .room-list a, .online-list li { padding: 8px; }
    .msg-del-btn, .admin-btn { min-width: 30px; min-height: 30px; font-size: 16px; }

    /* 安全区 */
    body { padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left); }
    .chat-input-bar { padding-bottom: max(12px, env(safe-area-inset-bottom)); }

    /* 输入框防 iOS 缩放 */
    input[type="text"], input[type="password"], input[type="search"],
    textarea, select { font-size: 16px !important; }

    /* 首页手机端 */
    .landing-main { flex-direction: column; padding: 12px; gap: 12px; }
    .landing-hero { padding: 24px 16px 20px; }
    .landing-hero h1 { font-size: 22px; }
    .landing-rooms .landing-card-body,
    .landing-chat .landing-card-body { max-height: none; }
    .landing-btn { padding: 8px 16px; font-size: 13px; }
    .landing-topbar .topbar-center { display: none; }
    .landing-footer { padding: 10px 12px; }
}
