:root {
    --green: #07c160;
    --green-dark: #06ad56;
    --red: #fa5151;
    --ink: #111214;
    --muted: #8b9096;
    --line: #e6e7e9;
    --chat-bg: #ededed;
    --page-bg: #f2f3f5;
}

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

html,
body {
    height: 100%;
}

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Helvetica Neue", "Microsoft YaHei", sans-serif;
    font-size: 15px;
    color: var(--ink);
    background: #dfe2e6;
    -webkit-font-smoothing: antialiased;
}

button {
    font-family: inherit;
    cursor: pointer;
}

img {
    -webkit-user-drag: none;
    user-select: none;
}

.phone {
    position: relative;
    width: 100%;
    max-width: 480px;
    height: 100%;
    margin: 0 auto;
    background: var(--page-bg);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

@media (min-width: 760px) {
    .phone {
        height: calc(100vh - 48px);
        margin: 24px auto;
        border-radius: 14px;
        box-shadow: 0 24px 60px rgba(18, 24, 30, .22);
    }
}

.hidden {
    display: none !important;
}

/* ============ 首页 ============ */

.home {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    background: #fff;
}

.topbar {
    flex: 0 0 auto;
    height: 54px;
    padding: 0 12px 0 14px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #fff;
    border-bottom: 1px solid var(--line);
}

.brand {
    display: flex;
    align-items: center;
    gap: 9px;
    min-width: 0;
}

.brand img {
    width: 28px;
    height: 28px;
    border-radius: 6px;
    object-fit: cover;
    background: #fff;
}

.brand span {
    font-size: 17px;
    font-weight: 600;
    letter-spacing: .5px;
    white-space: nowrap;
}

.top-actions {
    display: flex;
    align-items: center;
    gap: 2px;
}

.icon-btn {
    width: 38px;
    height: 38px;
    border: 0;
    background: transparent;
    color: #1b1c1e;
    border-radius: 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    position: relative;
}

.icon-btn:active {
    background: #f2f3f5;
}

.icon-btn svg {
    width: 25px;
    height: 25px;
    display: block;
}

.badge {
    position: absolute;
    top: 1px;
    right: 1px;
    min-width: 17px;
    height: 17px;
    padding: 0 4px;
    border-radius: 9px;
    background: var(--red);
    color: #fff;
    font-size: 11px;
    line-height: 17px;
    text-align: center;
    font-weight: 500;
    border: 1.5px solid #fff;
}

.badge.dot {
    min-width: 9px;
    width: 9px;
    height: 9px;
    padding: 0;
    border-radius: 50%;
}

.chat-list {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    background: #fff;
}

.chat-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 14px;
    border-bottom: 1px solid #f0f0f0;
    background: #fff;
    transition: background .12s;
}

.chat-item:active {
    background: #f5f5f5;
}

.chat-avatar-wrap {
    position: relative;
    width: 48px;
    height: 48px;
    flex: 0 0 48px;
}

.chat-item .avatar {
    width: 48px;
    height: 48px;
    border-radius: 8px;
    object-fit: cover;
    display: block;
    background: #eef0f2;
}

.chat-avatar-badge {
    top: -6px;
    right: -6px;
    border-width: 2px;
}

.chat-main {
    flex: 1;
    min-width: 0;
}

.chat-line1 {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.chat-name {
    font-size: 16px;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-time {
    font-size: 12px;
    color: #a3a7ac;
    flex: 0 0 auto;
}

.chat-line2 {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-top: 4px;
}

.chat-preview {
    font-size: 13px;
    color: var(--muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-badge {
    flex: 0 0 auto;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 9px;
    background: var(--red);
    color: #fff;
    font-size: 11px;
    line-height: 18px;
    text-align: center;
}

.home-empty {
    padding: 60px 30px;
    text-align: center;
    color: #a6abb1;
    font-size: 13px;
    line-height: 1.8;
}

.logout-line {
    padding: 18px 0 26px;
    text-align: center;
}

.logout-line button {
    border: 0;
    background: transparent;
    color: #9aa0a6;
    font-size: 13px;
}

/* ============ 底部导航 ============ */

.tabbar {
    flex: 0 0 auto;
    height: calc(54px + env(safe-area-inset-bottom));
    padding-bottom: env(safe-area-inset-bottom);
    display: flex;
    align-items: stretch;
    justify-content: center;
    background: #f7f7f7;
    border-top: 1px solid #dedfe1;
}

.tab {
    width: 50%;
    max-width: 200px;
    border: 0;
    background: transparent;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    color: #1a1b1d;
    padding: 4px 0;
}

.tab svg {
    width: 24px;
    height: 24px;
    display: block;
}

.tab span {
    font-size: 11px;
    line-height: 1.2;
}

.tab.active {
    color: var(--green-dark);
}

/* ============ 聊天页 ============ */

.chat-view {
    position: absolute;
    inset: 0;
    z-index: 15;
    display: flex;
    flex-direction: column;
    background: var(--chat-bg);
    transform: translateX(0);
    transition: transform .22s ease;
}

.chat-view.hidden {
    display: flex !important;
    transform: translateX(100%);
    pointer-events: none;
}

.chat-top {
    flex: 0 0 auto;
    height: 54px;
    padding: 0 6px;
    display: flex;
    align-items: center;
    background: #f7f7f7;
    border-bottom: 1px solid #dcdddf;
    position: relative;
}

.back-btn {
    width: 40px;
    height: 40px;
    border: 0;
    background: transparent;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    color: #161719;
}

.back-btn svg {
    width: 23px;
    height: 23px;
}

.chat-title {
    flex: 1;
    min-width: 0;
    text-align: center;
    font-size: 16px;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-top .spacer {
    width: 40px;
    flex: 0 0 40px;
}

.peer-bar {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 10px 14px;
    background: #fff;
    border-bottom: 1px solid var(--line);
}

.peer-bar img {
    width: 40px;
    height: 40px;
    border-radius: 7px;
    object-fit: cover;
    background: #eef0f2;
}

.peer-bar .peer-name {
    font-size: 15px;
    font-weight: 500;
    flex: 1;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.add-user-btn {
    border: 1px solid #d7dadd;
    background: #fff;
    color: #2b2f33;
    height: 31px;
    padding: 0 13px;
    border-radius: 6px;
    font-size: 13px;
    flex: 0 0 auto;
}

.add-user-btn:active {
    background: #f3f4f5;
}

.msg-list {
    flex: 1;
    overscroll-behavior: contain;
    min-height: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 14px 10px 18px;
    background: var(--chat-bg);
}

.msg-row {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    margin-bottom: 15px;
}

.msg-row.mine {
    flex-direction: row-reverse;
}

.msg-avatar {
    width: 38px;
    height: 38px;
    border-radius: 6px;
    object-fit: cover;
    background: #fff;
    flex: 0 0 38px;
}

.msg-body {
    max-width: 74%;
    min-width: 0;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
}

.msg-row.mine .msg-body {
    align-items: flex-end;
}

.msg-name {
    font-size: 11px;
    color: #93989d;
    line-height: 1;
    padding: 0 2px;
}

.bubble {
    position: relative;
    -webkit-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
    max-width: 100%;
    padding: 9px 11px;
    border-radius: 7px;
    background: #fff;
    font-size: 15px;
    line-height: 1.5;
    color: #17181a;
    word-break: break-word;
    overflow-wrap: anywhere;
}

.bubble:before {
    content: "";
    position: absolute;
    top: 13px;
    left: -5px;
    width: 0;
    height: 0;
    border-top: 5px solid transparent;
    border-bottom: 5px solid transparent;
    border-right: 6px solid #fff;
}

.msg-row.mine .bubble {
    background: #95ec69;
}

.msg-row.mine .bubble:before {
    left: auto;
    right: -5px;
    border-right: 0;
    border-left: 6px solid #95ec69;
}

.bubble.voice {
    padding: 8px 12px;
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 92px;
}

.voice-icon {
    width: 0;
    height: 0;
    border-top: 6px solid transparent;
    border-bottom: 6px solid transparent;
    border-left: 9px solid #2b2f31;
    margin-right: 1px;
}

.voice-waves {
    display: flex;
    align-items: center;
    gap: 2px;
    height: 16px;
}

.voice-waves i {
    display: block;
    width: 2px;
    border-radius: 1px;
    background: #5b6166;
    height: 6px;
}

.voice-waves i:nth-child(2),
.voice-waves i:nth-child(5) {
    height: 11px;
}

.voice-waves i:nth-child(3),
.voice-waves i:nth-child(4) {
    height: 15px;
}

.voice-dur {
    font-size: 12px;
    color: #565b60;
    min-width: 22px;
    text-align: right;
}

.msg-img {
    display: block;
    max-width: 210px;
    max-height: 260px;
    border-radius: 7px;
    object-fit: cover;
    background: #fff;
}

.file-card {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 238px;
    max-width: 62vw;
    padding: 11px;
    border-radius: 7px;
    background: #fff;
}

.msg-row.mine .file-card {
    background: #95ec69;
}

.file-icon {
    width: 38px;
    height: 44px;
    flex: 0 0 38px;
    position: relative;
    border: 1.5px solid #9aa1a7;
    border-radius: 4px;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    font-size: 9px;
    color: #6f767c;
    padding-bottom: 4px;
    background: #fafbfc;
}

.file-icon:after {
    content: "";
    position: absolute;
    top: -1px;
    right: -1px;
    width: 11px;
    height: 11px;
    background: linear-gradient(225deg, #ededed 50%, #c7ccd1 51%);
}

.file-main {
    min-width: 0;
    flex: 1;
}

.file-name {
    font-size: 13px;
    line-height: 1.35;
    color: #1c1e20;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    word-break: break-all;
}

.file-meta {
    margin-top: 3px;
    font-size: 11px;
    color: #7c8288;
}

.msg-state {
    font-size: 11px;
    color: #a1a6ab;
    margin-top: 2px;
    padding: 0 2px;
}

.bubble audio {
    display: none;
}

a.file-card {
    color: inherit;
    text-decoration: none;
}

.msg-reject {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    margin: 10px auto 16px;
    padding: 7px 12px;
    max-width: 88%;
    border-radius: 6px;
    background: #fdecec;
    color: #c53434;
    font-size: 12.5px;
    line-height: 1.4;
}

.reject-icon {
    width: 17px;
    height: 17px;
    flex: 0 0 17px;
    border-radius: 50%;
    border: 1.5px solid #e04141;
    color: #e04141;
    font-size: 11px;
    font-weight: 700;
    line-height: 14px;
    text-align: center;
    background: #fff;
}

.recalled-text {
    font-size: 12px;
    color: #9aa0a6;
    padding: 2px 4px;
}

.composer {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 8px 9px calc(8px + env(safe-area-inset-bottom));
    background: #f7f7f7;
    border-top: 1px solid #dedfe1;
}

.composer .icon-btn {
    width: 34px;
    height: 34px;
    flex: 0 0 34px;
    color: #33373b;
}

.composer .icon-btn svg {
    width: 26px;
    height: 26px;
}

.msg-input {
    flex: 1;
    min-width: 0;
    height: 37px;
    border: 1px solid #e1e2e4;
    background: #fff;
    border-radius: 6px;
    padding: 0 10px;
    font-size: 15px;
    color: #16181a;
    outline: none;
    -webkit-appearance: none;
}

.msg-input:focus {
    border-color: #cfd2d6;
}

.send-btn {
    flex: 0 0 auto;
    height: 35px;
    padding: 0 14px;
    border: 0;
    border-radius: 6px;
    background: var(--green);
    color: #fff;
    font-size: 14px;
}

.send-btn:active {
    background: var(--green-dark);
}

.voice-hold {
    flex: 1;
    height: 38px;
    border: 1px solid #d9dcdf;
    background: #fff;
    border-radius: 6px;
    font-size: 15px;
    color: #1c1e20;
    user-select: none;
    -webkit-user-select: none;
    touch-action: none;
}

.voice-hold.active {
    background: #e8f7ef;
    border-color: #b9e6cd;
}

/* 录音浮层 */

.recording-mask {
    position: absolute;
    inset: 0;
    z-index: 60;
    background: rgba(0, 0, 0, .22);
    display: flex;
    align-items: center;
    justify-content: center;
}

.recording-panel {
    width: 190px;
    padding: 22px 18px;
    border-radius: 12px;
    background: rgba(32, 34, 36, .9);
    color: #fff;
    text-align: center;
}

.rec-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #ff5a5a;
    margin: 0 auto 12px;
    animation: pulse 1s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: .45; transform: scale(.85); }
}

.rec-time {
    font-size: 20px;
    font-variant-numeric: tabular-nums;
    letter-spacing: 1px;
}

.rec-tip {
    margin-top: 10px;
    font-size: 12px;
    color: #c9cdd1;
}

/* ============ 浮层 / 弹窗 ============ */

.overlay {
    position: absolute;
    inset: 0;
    z-index: 40;
    background: rgba(14, 17, 20, .5);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 18px;
}

.overlay.bottom {
    align-items: flex-end;
    padding: 0;
}

.modal {
    width: 100%;
    max-width: 340px;
    background: #fff;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 18px 50px rgba(0, 0, 0, .18);
}

.modal-head {
    padding: 20px 20px 4px;
    text-align: center;
}

.modal-title {
    font-size: 18px;
    font-weight: 600;
    color: #15171a;
}

.modal-sub {
    margin-top: 6px;
    font-size: 12.5px;
    color: #8c9197;
    line-height: 1.5;
}

.modal-body {
    padding: 14px 20px 4px;
}

.modal-foot {
    padding: 16px 20px 20px;
    display: flex;
    gap: 10px;
}

.btn {
    flex: 1;
    height: 42px;
    border-radius: 7px;
    border: 1px solid #dfe1e3;
    background: #fff;
    color: #26292c;
    font-size: 15px;
}

.btn.primary {
    border-color: var(--green);
    background: var(--green);
    color: #fff;
}

.btn.primary:active {
    background: var(--green-dark);
}

.btn.danger {
    border-color: #f3c4c4;
    background: #fff;
    color: #d63b3b;
}

.btn.small {
    height: 34px;
    font-size: 13.5px;
    flex: 0 0 auto;
    padding: 0 14px;
}

.field {
    margin-bottom: 12px;
}

.field label {
    display: block;
    font-size: 12.5px;
    color: #777d83;
    margin-bottom: 6px;
}

.field input,
.field textarea,
.field select {
    width: 100%;
    border: 1px solid #e0e2e4;
    border-radius: 6px;
    background: #fff;
    height: 42px;
    padding: 0 11px;
    font-size: 15px;
    color: #17191b;
    outline: none;
    font-family: inherit;
    -webkit-appearance: none;
}

.field input:focus,
.field textarea:focus {
    border-color: #b9dec9;
}

.field textarea {
    height: 96px;
    padding: 10px 11px;
    resize: none;
    line-height: 1.5;
}

.form-error {
    min-height: 18px;
    font-size: 12.5px;
    color: #d63b3b;
    padding: 2px 0 6px;
}

.spinner {
    display: inline-block;
    width: 14px;
    height: 14px;
    border: 2px solid rgba(255, 255, 255, .45);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin .7s linear infinite;
    vertical-align: -2px;
    margin-right: 6px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* 底部动作面板 */

.sheet {
    width: 100%;
    max-width: 480px;
    background: #f7f7f7;
    border-radius: 12px 12px 0 0;
    padding: 8px 8px calc(8px + env(safe-area-inset-bottom));
    animation: sheet-up .18s ease;
}

@keyframes sheet-up {
    from { transform: translateY(14px); opacity: .6; }
    to { transform: translateY(0); opacity: 1; }
}

.sheet-btn {
    width: 100%;
    height: 50px;
    border: 0;
    border-bottom: 1px solid #e8e9eb;
    background: #fff;
    font-size: 16px;
    color: #1c1e20;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.sheet-btn:first-child {
    border-radius: 10px 10px 0 0;
}

.sheet-btn.danger {
    color: #d63b3b;
}

.sheet-btn:disabled {
    color: #b4b8bc;
}

.sheet-btn svg {
    width: 22px;
    height: 22px;
}

.sheet-cancel {
    margin-top: 8px;
    border-radius: 10px;
    border: 0;
}

.sheet-note {
    font-size: 12px;
    color: #9aa0a6;
    text-align: center;
    padding: 8px 0 0;
}

/* 创建群聊 / 好友申请 列表 */

.overlay.bottom .group-modal {
    margin-bottom: calc(10px + env(safe-area-inset-bottom));
}

.group-modal {
    width: 100%;
    max-width: 380px;
    max-height: 82vh;
    display: flex;
    flex-direction: column;
    background: #fff;
    border-radius: 12px;
    overflow: hidden;
}

.group-modal-head {
    padding: 16px 18px 12px;
    border-bottom: 1px solid #f0f1f2;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.group-modal-head b {
    font-size: 16px;
}

.close-x {
    width: 30px;
    height: 30px;
    border: 0;
    background: transparent;
    color: #8d9298;
    font-size: 22px;
    line-height: 1;
}

.modal-scroll {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 12px 18px;
}

.pick-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 0;
    border-bottom: 1px solid #f3f4f5;
}

.pick-row img {
    width: 38px;
    height: 38px;
    border-radius: 6px;
    object-fit: cover;
}

.pick-row .pick-name {
    flex: 1;
    font-size: 14.5px;
}

.check {
    width: 20px;
    height: 20px;
    accent-color: var(--green);
}

.group-modal-foot {
    padding: 12px 18px calc(12px + env(safe-area-inset-bottom));
    border-top: 1px solid #f0f1f2;
    display: flex;
    gap: 10px;
}

.request-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 11px 0;
    border-bottom: 1px solid #f2f3f4;
}

.request-row img {
    width: 42px;
    height: 42px;
    border-radius: 6px;
    object-fit: cover;
}

.request-row .rname {
    flex: 1;
    font-size: 14.5px;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.request-row .btn {
    flex: 0 0 auto;
    width: 64px;
    height: 32px;
    font-size: 13px;
    padding: 0;
}

.empty-mini {
    padding: 38px 0;
    text-align: center;
    color: #a0a5aa;
    font-size: 13px;
}

/* 用户资料 */

.profile-card {
    width: 100%;
    max-width: 340px;
    background: #fff;
    border-radius: 12px;
    overflow: hidden;
    text-align: center;
}

.profile-top {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 20px;
    text-align: left;
    border-bottom: 1px solid #f2f3f4;
}

.profile-avatar {
    width: 62px;
    height: 62px;
    flex: 0 0 62px;
    border-radius: 9px;
    object-fit: cover;
    background: #eef0f2;
}

.profile-name {
    margin-top: 0;
    font-size: 18px;
    font-weight: 600;
    min-width: 0;
    word-break: break-all;
}

.profile-actions {
    padding: 0 20px 20px;
}

.profile-actions .btn {
    width: 100%;
}

/* 图片预览 */

.image-viewer {
    position: absolute;
    inset: 0;
    z-index: 70;
    background: rgba(0, 0, 0, .92);
    display: flex;
    align-items: center;
    justify-content: center;
}

.image-viewer img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.image-viewer .close-x {
    position: absolute;
    top: 8px;
    right: 8px;
    color: #fff;
    font-size: 30px;
}

/* Toast */

.toast {
    position: absolute;
    left: 50%;
    bottom: 110px;
    transform: translateX(-50%);
    max-width: 78%;
    padding: 10px 16px;
    border-radius: 8px;
    background: rgba(22, 24, 26, .86);
    color: #fff;
    font-size: 13.5px;
    line-height: 1.5;
    text-align: center;
    z-index: 90;
    pointer-events: none;
    animation: toast-in .16s ease;
}

@keyframes toast-in {
    from { opacity: 0; transform: translate(-50%, 6px); }
    to { opacity: 1; transform: translate(-50%, 0); }
}

/* 登录 */

.login-layer {
    position: absolute;
    inset: 0;
    z-index: 100;
    background: #eef0f2;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.login-box {
    width: 100%;
    max-width: 344px;
    background: #fff;
    border: 1px solid #e6e8ea;
    border-radius: 12px;
    padding: 30px 24px 22px;
    box-shadow: 0 22px 55px rgba(20, 25, 30, .09);
}

.login-logo {
    width: 64px;
    height: 64px;
    border-radius: 10px;
    display: block;
    margin: 0 auto 14px;
    object-fit: cover;
    background: #fff;
}

.login-title {
    text-align: center;
    margin-top: 2px;
    font-size: 21px;
    font-weight: 600;
    letter-spacing: .5px;
}

.login-sub {
    text-align: center;
    font-size: 12.5px;
    color: #969ba1;
    margin: 7px 0 22px;
}

.login-box .field input {
    height: 46px;
    background: #fff;
}

.login-btn {
    width: 100%;
    height: 46px;
    border: 0;
    border-radius: 7px;
    background: var(--green);
    color: #fff;
    font-size: 16px;
    margin-top: 4px;
}

.login-btn:active {
    background: var(--green-dark);
}

.login-note {
    margin-top: 20px;
    text-align: center;
    font-size: 11.5px;
    color: #a8adb2;
}

/* 滚动条收敛 */

::-webkit-scrollbar {
    width: 0;
    height: 0;
}
