.chat-view {
    --bg-color: #ffffff;
    --secondary-bg-color: #f5f5f5;
    --border-color: #e0e0e0;
    --text-color-dark: #333333;
    --text-color-light: #999999;
    --accent-color: #ffffff;
    --accent-color-dark: #333333;
    position: fixed;
    inset: 0;
    z-index: 1200;
    width: 100%;
    min-width: 280px;
    height: 100%;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior-y: contain;
    background-color: var(--bg-color);
    color: var(--text-color-dark);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    line-height: 1.6;
    -webkit-overflow-scrolling: touch;
}

.chat-view,
.chat-view * {
    box-sizing: border-box;
    letter-spacing: 0;
    -webkit-tap-highlight-color: transparent;
}

.chat-view button,
.chat-view input {
    color: inherit;
    font: inherit;
}

.chat-view button {
    background: transparent;
}

body.is-chat-open .desktop-container,
body.is-chat-open .pagination,
body.is-chat-open .dock-container,
body.is-chat-open .system-status-bar {
    visibility: hidden;
    pointer-events: none;
}

.chat-view .header {
    position: sticky;
    top: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: calc(58px + var(--safe-top));
    padding: calc(10px + var(--safe-top)) max(20px, var(--safe-right)) 10px max(20px, var(--safe-left));
    background-color: var(--bg-color);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.chat-view .header h1 {
    position: absolute;
    left: 50%;
    color: var(--text-color-dark);
    font-size: 20px;
    font-weight: 600;
    transform: translateX(-50%);
}

.chat-view .header-icon {
    color: var(--text-color-dark);
    font-size: 24px;
}

.chat-view .chat-exit {
    width: 63px;
    min-height: 38px;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    font-size: 24px;
    line-height: 1.6;
}

.chat-view .header-actions {
    min-width: 63px;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 15px;
}

.chat-view .header-actions button {
    display: grid;
    place-items: center;
    font-size: 24px;
    line-height: 1.6;
}

.chat-view .content {
    min-height: calc(100% - 58px);
    padding-bottom: calc(90px + var(--safe-bottom));
}

.chat-view .page-container {
    display: none;
}

.chat-view .page-container.active {
    display: block;
}

.chat-view .hero {
    display: flex;
    align-items: center;
    padding: 20px 25px;
}

.chat-view .hero-avatar {
    width: 70px;
    height: 70px;
    flex-shrink: 0;
    margin-right: 15px;
    overflow: hidden;
    border-radius: 50%;
    background-color: var(--border-color);
    box-shadow: 0 10px 15px rgba(0, 0, 0, 0.15);
}

.chat-view .hero-avatar img,
.chat-view .msg-hero-avatar img {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: cover;
}

.chat-view .hero-info {
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-width: 0;
}

.chat-view .username-section {
    display: flex;
    align-items: center;
    align-self: flex-start;
    margin-bottom: 4px;
}

.chat-view .username {
    color: var(--text-color-dark);
    font-size: 16px;
    font-weight: bold;
}

.chat-view .hero-text {
    max-width: 100%;
    color: var(--text-color-light);
    font-size: 12px;
    text-align: left;
}

.chat-view .info-card {
    display: flex;
    align-items: center;
    margin: 15px 20px;
    padding: 10px;
    border-radius: 15px;
    background-color: var(--bg-color);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.05);
}

.chat-view .card-details {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: space-between;
    color: var(--text-color-light);
    font-size: 12px;
}

.chat-view .card-details i {
    margin-right: 4px;
}

.chat-view .category-nav {
    display: flex;
    justify-content: space-around;
    margin: 10px 20px 0;
    padding: 15px 0 0;
    border-bottom: 1px solid var(--border-color);
}

.chat-view .category-item {
    position: relative;
    width: 33%;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding-bottom: 12px;
    color: var(--text-color-light);
}

.chat-view .category-item i {
    margin-bottom: 6px;
    font-size: 18px;
}

.chat-view .category-item span {
    font-size: 12px;
    font-weight: 500;
}

.chat-view .category-item.active {
    color: var(--text-color-dark);
}

.chat-view .category-item.active::after {
    position: absolute;
    bottom: -1px;
    left: 50%;
    width: 30px;
    height: 3px;
    border-radius: 3px 3px 0 0;
    background-color: var(--text-color-dark);
    content: "";
    transform: translateX(-50%);
}

.chat-view .placeholder-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    padding: 40px 20px;
    color: var(--text-color-light);
    font-size: 14px;
    text-align: center;
}

.chat-view .placeholder-content i {
    font-size: 24px;
    opacity: 0.5;
}

.chat-view .msg-hero {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 15px 0;
}

.chat-view .msg-hero-avatar {
    width: 60px;
    height: 60px;
    margin-bottom: 10px;
    overflow: hidden;
    border-radius: 50%;
    background-color: var(--border-color);
    box-shadow: 0 10px 15px rgba(0, 0, 0, 0.15);
}

.chat-view .msg-hero-text {
    max-width: 80%;
    color: var(--text-color-light);
    font-size: 14px;
    text-align: center;
}

.chat-view .tabs {
    display: flex;
    justify-content: space-around;
    margin-bottom: 5px;
    padding: 10px 20px;
    border-bottom: 1px solid var(--border-color);
    background-color: var(--secondary-bg-color);
}

.chat-view .tab {
    color: var(--text-color-light);
    font-size: 14px;
}

.chat-view .tab i {
    margin-left: 4px;
    font-size: 10px;
}

.chat-view .tab.active {
    color: var(--text-color-dark);
    font-weight: bold;
}

.chat-view .chat-list {
    padding: 0 20px;
    background-color: var(--secondary-bg-color);
}

.chat-view .chat-item {
    width: 100%;
    display: flex;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid var(--border-color);
    text-align: left;
}

.chat-view .item-avatar-wrapper {
    position: relative;
    margin-right: 12px;
}

.chat-view .tape {
    position: absolute;
    top: -6px;
    left: 50%;
    z-index: 10;
    width: 22px;
    height: 10px;
    background-color: rgba(200, 200, 200, 0.5);
    rotate: 10deg;
    transform: translateX(-50%);
}

.chat-view .item-avatar {
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    background-color: var(--bg-color);
    color: var(--text-color-light);
    font-size: 16px;
}

.chat-view .item-info {
    min-width: 0;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.chat-view .item-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 2px;
}

.chat-view .item-name {
    overflow: hidden;
    font-size: 14px;
    font-weight: bold;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.chat-view .item-time,
.chat-view .item-status {
    color: var(--text-color-light);
    font-size: 10px;
}

.chat-view .navbar {
    position: fixed;
    right: max(20px, var(--safe-right));
    bottom: calc(20px + var(--safe-bottom));
    left: max(20px, var(--safe-left));
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: space-around;
    padding: 12px;
    border-radius: 25px;
    background-color: var(--secondary-bg-color);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.chat-view .nav-item {
    color: var(--text-color-light);
    font-size: 22px;
}

.chat-view .nav-item.active {
    color: var(--text-color-dark);
}

.chat-view .discover-header {
    position: relative;
}

.chat-view .discover-bg-wrapper {
    position: relative;
    width: 100%;
    height: 300px;
    cursor: pointer;
}

.chat-view .discover-bg-img {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: cover;
}

.chat-view .discover-avatar {
    position: absolute;
    right: 20px;
    bottom: -30px;
    width: 70px;
    height: 70px;
    padding: 3px;
    border-radius: 10px;
    background-color: var(--bg-color);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
}

.chat-view .discover-avatar img {
    width: 100%;
    height: 100%;
    display: block;
    border-radius: 8px;
    object-fit: cover;
}

.chat-view #chat-page-detail {
    position: absolute;
    top: 0;
    left: 0;
    z-index: 2000;
    width: 100%;
    min-height: 100%;
    display: none;
    background-color: #ffffff;
}

.chat-view #chat-page-detail.active {
    display: flex;
    flex-direction: column;
}

.chat-view .chat-detail-header {
    position: sticky;
    top: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: calc(62px + var(--safe-top));
    padding: calc(15px + var(--safe-top)) max(20px, var(--safe-right)) 15px max(20px, var(--safe-left));
    background-color: #ffffff;
}

.chat-view .chat-detail-header .header-left {
    display: flex;
    align-items: center;
    min-width: 0;
}

.chat-view .chat-detail-header .header-left > i {
    margin-right: 15px;
    color: var(--text-color-light);
    font-size: 18px;
}

.chat-view .chat-detail-header .header-avatar {
    width: 32px;
    height: 32px;
    flex-shrink: 0;
    margin-right: 10px;
    border-radius: 50%;
    object-fit: cover;
}

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

.chat-view .chat-detail-header .header-right {
    position: relative;
    display: flex;
    align-items: center;
    gap: 15px;
    color: var(--text-color-light);
    font-size: 18px;
}

.chat-view .chat-detail-header .header-right button {
    display: grid;
    place-items: center;
    color: inherit;
    font-size: inherit;
}

.chat-view .chat-detail-header .top-cards {
    position: absolute;
    top: -5px;
    right: 50px;
    width: 50px;
    height: 40px;
    pointer-events: none;
}

.chat-view .card-deco {
    position: absolute;
    width: 35px;
    height: 45px;
    overflow: hidden;
    border: 2px solid #ffffff;
    border-radius: 4px;
    background-color: #ffffff;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.chat-view .card-deco img {
    width: 100%;
    height: 100%;
    display: block;
    border-radius: 2px;
    object-fit: cover;
}

.chat-view .card-deco:nth-child(1) {
    top: 5px;
    right: 0;
    z-index: 2;
    transform: rotate(15deg);
}

.chat-view .card-deco:nth-child(2) {
    top: 0;
    right: 15px;
    z-index: 1;
    transform: rotate(-10deg);
}

.chat-view .chat-messages {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 20px;
    padding: 20px 20px calc(90px + var(--safe-bottom));
    background-color: #ffffff;
}

.chat-view .msg-block {
    max-width: 100%;
    display: flex;
    align-items: flex-start;
}

.chat-view .msg-block.left {
    flex-direction: row;
}

.chat-view .msg-block.right {
    flex-direction: row-reverse;
    align-self: flex-end;
}

.chat-view .msg-block.first-message {
    padding-left: 50px;
}

.chat-view .msg-avatar {
    width: 40px;
    height: 40px;
    margin: 0 10px;
    border-radius: 50%;
    object-fit: cover;
}

.chat-view .msg-content {
    max-width: 75%;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.chat-view .msg-block.right .msg-content {
    align-items: flex-end;
}

.chat-view .msg-block.left .msg-content {
    align-items: flex-start;
}

.chat-view .msg-header {
    width: 100%;
    display: flex;
    flex-direction: column;
    margin-bottom: 2px;
    padding-bottom: 5px;
    border-bottom: 1px dashed #e0e0e0;
}

.chat-view .msg-header .name-time {
    display: flex;
    align-items: baseline;
    gap: 10px;
}

.chat-view .msg-header .name {
    color: var(--text-color-light);
    font-size: 13px;
}

.chat-view .msg-header .time {
    color: #999999;
    font-size: 10px;
}

.chat-view .msg-header .tag {
    margin-top: 2px;
    color: #666666;
    font-size: 11px;
}

.chat-view .msg-bubble {
    position: relative;
    padding: 10px 14px;
    border: 1px solid #e0e0e0;
    border-radius: 20px;
    background-color: transparent;
    color: #333333;
    font-size: 14px;
    word-break: break-all;
}

.chat-view .msg-bubble.small {
    display: inline-block;
    padding: 6px 12px;
    border-radius: 15px;
}

.chat-view .msg-bubble.has-image {
    padding: 4px;
}

.chat-view .message-image {
    width: min(220px, 60vw);
    max-height: 280px;
    display: block;
    border-radius: 16px;
    object-fit: cover;
}

.chat-view .msg-meta {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 4px 8px;
    border: 1px solid #f0f0f0;
    border-radius: 10px;
    background-color: #f9f9f9;
    color: #999999;
    font-size: 11px;
}

.chat-view .msg-meta.image-meta {
    padding: 0;
    border: 0;
    background: transparent;
    color: #666666;
}

.chat-view .msg-meta.image-meta i {
    font-size: 16px;
}

.chat-view .msg-action-text {
    display: inline-block;
    padding: 4px 8px;
    border-radius: 6px;
    background: #f5f5f5;
    color: #999999;
    font-size: 11px;
}

.chat-view .msg-time-label {
    margin-top: 2px;
    color: #999999;
    font-size: 11px;
}

.chat-view .chat-input-area {
    position: fixed;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px max(20px, var(--safe-right)) calc(12px + var(--safe-bottom)) max(20px, var(--safe-left));
    background-color: #ffffff;
}

.chat-view .chat-input-box {
    flex: 1;
    display: flex;
    align-items: center;
    padding: 10px 15px;
    border-radius: 20px;
    background-color: #f5f5f5;
}

.chat-view .chat-input-box input {
    width: 100%;
    border: 0;
    outline: 0;
    background: transparent;
    color: #333333;
    font-size: 15px;
}

.chat-view .chat-input-actions {
    display: flex;
    align-items: center;
    gap: 15px;
}

.chat-view .chat-input-actions button {
    display: grid;
    place-items: center;
    color: #333333;
    font-size: 22px;
}

.chat-view .chat-input-actions .send-btn {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background-color: #000000;
    color: #ffffff;
}

.chat-view .chat-input-actions .send-btn i {
    color: #ffffff;
    font-size: 14px;
}

@supports (height: 100dvh) {
    .chat-view {
        height: 100dvh;
    }

    .chat-view #chat-page-detail {
        min-height: 100dvh;
    }
}
