/* ============================================
   🌙 邻星 · 全局样式
   版本: 1.0.0
   说明: 所有页面共享的样式
   ============================================ */

/* ----- 重置 & 基础 ----- */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: system-ui, -apple-system, sans-serif;
}

body {
    background: #fdf8f0;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    min-height: 100vh;
    padding: 16px;
}

#app {
    background: #fff;
    max-width: 440px;
    width: 100%;
    padding: 24px 20px;
    border-radius: 36px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, .08);
    margin: 20px 0;
    position: relative;
}

/* ----- 通用工具 ----- */
.hidden {
    display: none !important;
}

/* ----- Logo ----- */
.logo {
    font-size: 28px;
    font-weight: 700;
    color: #d4836c;
    letter-spacing: 2px;
    text-align: center;
    margin-bottom: 4px;
}

.sub {
    color: #b0a094;
    font-size: 14px;
    text-align: center;
    margin-bottom: 20px;
}

/* ----- 表单 ----- */
.form-group {
    margin-bottom: 14px;
}

label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: #4a3f38;
    margin-bottom: 3px;
}

input,
select {
    width: 100%;
    padding: 11px 16px;
    border: 1.5px solid #eee;
    border-radius: 30px;
    font-size: 15px;
    outline: none;
    transition: .2s;
    background: #fafaf8;
    appearance: auto;
}

input:focus,
select:focus {
    border-color: #d4836c;
    background: #fff;
}

.row-3 {
    display: flex;
    gap: 10px;
}
.row-3>* {
    flex: 1;
}

/* ----- 按钮 ----- */
button {
    padding: 14px;
    border: none;
    border-radius: 30px;
    font-size: 17px;
    font-weight: 600;
    color: #fff;
    background: #d4836c;
    cursor: pointer;
    transition: .2s;
    margin-top: 6px;
    width: 100%;
}
button:hover {
    background: #c2725b;
}

button.secondary {
    background: #ccc;
    color: #555;
}
button.secondary:hover {
    background: #bbb;
}

button.success {
    background: #7bc0a4;
}
button.success:hover {
    background: #66a88e;
}

button.danger {
    background: #e8a09c;
}
button.danger:hover {
    background: #d48a86;
}

button.small {
    padding: 6px 14px;
    font-size: 13px;
    width: auto;
    margin-top: 0;
    display: inline-block;
}

button.icon-btn {
    background: transparent;
    color: #d4836c;
    font-size: 22px;
    width: auto;
    padding: 0 6px;
    margin: 0;
    line-height: 1;
    position: relative;
}
button.icon-btn:hover {
    color: #c2725b;
    background: transparent;
}

/* 红点 */
.icon-btn .badge-dot {
    position: absolute;
    top: -4px;
    right: -6px;
    background: #e74c3c;
    color: #fff;
    font-size: 11px;
    border-radius: 50%;
    width: 18px;
    height: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    box-shadow: 0 0 0 2px #fff;
}
.icon-btn .badge-dot.hidden {
    display: none;
}

/* ----- 链接 ----- */
.link {
    color: #d4836c;
    font-size: 14px;
    text-align: center;
    margin-top: 14px;
    cursor: pointer;
    text-decoration: underline;
}
.link:hover {
    color: #c2725b;
}

/* ----- 状态信息 ----- */
#status,
#register-status,
#main-status {
    margin-top: 14px;
    color: #b0a094;
    font-size: 14px;
    text-align: center;
    word-break: break-all;
}

/* ----- 卡片 ----- */
.card {
    background: #fdf8f0;
    padding: 16px;
    border-radius: 20px;
    margin-top: 16px;
    color: #4a3f38;
}

.card-title {
    font-weight: 600;
    font-size: 15px;
    color: #4a3f38;
    margin-bottom: 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.badge {
    background: #d4836c;
    color: #fff;
    font-size: 12px;
    padding: 2px 10px;
    border-radius: 20px;
    font-weight: 500;
}

/* ----- 用户行 ----- */
.user-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid #f0ebe5;
    cursor: pointer;
}
.user-row:last-child {
    border-bottom: none;
}
.user-row:hover {
    background: #fdf8f0;
    margin: 0 -8px;
    padding: 10px 8px;
    border-radius: 12px;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
    min-width: 0;
}

.user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: #d4836c22;
    color: #d4836c;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 18px;
    flex-shrink: 0;
}

.user-name {
    font-weight: 500;
    color: #4a3f38;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.user-id {
    font-size: 12px;
    color: #b0a094;
}
.user-location {
    font-size: 12px;
    color: #b0a094;
}

.empty-tip {
    color: #b0a094;
    font-size: 14px;
    text-align: center;
    padding: 20px 0;
}

.btn-group {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}

/* ----- 顶部导航 ----- */
.top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 0 16px 0;
}
.top-bar .greeting {
    font-size: 16px;
    font-weight: 500;
    color: #4a3f38;
}
.top-bar .actions {
    display: flex;
    gap: 6px;
    align-items: center;
}

/* ----- 模态框 ----- */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, .3);
    backdrop-filter: blur(4px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 999;
    padding: 20px;
}
.modal-box {
    background: #fff;
    max-width: 400px;
    width: 100%;
    border-radius: 36px;
    padding: 28px 24px;
    box-shadow: 0 30px 80px rgba(0, 0, 0, .2);
    max-height: 80vh;
    display: flex;
    flex-direction: column;
}
.modal-box .modal-title {
    font-size: 20px;
    font-weight: 600;
    color: #4a3f38;
    margin-bottom: 16px;
    text-align: center;
}
.modal-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
    border-bottom: 1px solid #f0ebe5;
}
.modal-tabs button {
    flex: 1;
    background: transparent;
    color: #b0a094;
    border: none;
    padding: 10px 0;
    font-size: 15px;
    font-weight: 500;
    border-bottom: 2px solid transparent;
    transition: .2s;
    width: auto;
    margin: 0;
}
.modal-tabs button.active {
    color: #d4836c;
    border-bottom-color: #d4836c;
}
.modal-tabs button:hover {
    color: #d4836c;
    background: transparent;
}
.modal-content {
    flex: 1;
    overflow-y: auto;
}
.modal-content .search-box {
    display: flex;
    gap: 10px;
    margin-bottom: 12px;
}
.modal-content .search-box input {
    flex: 1;
}
.modal-content .search-box button {
    width: auto;
    padding: 11px 18px;
    margin-top: 0;
    font-size: 15px;
    flex-shrink: 0;
}
.modal-content .result-item {
    padding: 10px 0;
    border-bottom: 1px solid #f0ebe5;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.modal-content .result-item:last-child {
    border-bottom: none;
}

/* ----- 聊天视图 ----- */
#chat-view {
    display: flex;
    flex-direction: column;
    height: 500px;
    max-height: 70vh;
}

.chat-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 0;
    border-bottom: 1px solid #f0ebe5;
    flex-shrink: 0;
}
.chat-header .back-btn {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: #d4836c;
    padding: 0 4px;
    width: auto;
    margin: 0;
}
.chat-header .chat-with {
    font-weight: 600;
    font-size: 17px;
    color: #4a3f38;
}
.chat-header .burn-status-label {
    margin-left: auto;
    font-size: 12px;
    color: #b0a094;
}

.messages {
    flex: 1;
    overflow-y: auto;
    padding: 12px 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
    position: relative;
}

/* ----- 消息样式 ----- */
.msg {
    max-width: 80%;
    padding: 10px 14px;
    border-radius: 20px;
    word-break: break-word;
    font-size: 15px;
    line-height: 1.4;
}
.msg.sent {
    align-self: flex-end;
    background: #d4836c;
    color: #fff;
    border-bottom-right-radius: 4px;
}
.msg.received {
    align-self: flex-start;
    background: #f0ebe5;
    color: #4a3f38;
    border-bottom-left-radius: 4px;
}
.msg .time {
    font-size: 10px;
    opacity: .6;
    margin-top: 4px;
    display: block;
    text-align: right;
}

/* 小纸条 */
.msg.sticker {
    border-left: 4px solid #d4836c;
}
.msg.sticker .sticker-label {
    font-size: 12px;
    font-weight: 600;
    color: #d4836c;
    display: block;
    margin-bottom: 4px;
}

/* 阅后即焚标记 */
.msg .burn-badge {
    font-size: 10px;
    background: #e74c3c;
    color: #fff;
    padding: 1px 8px;
    border-radius: 10px;
    margin-left: 6px;
}

/* 已读状态 */
.msg .read-status {
    font-size: 10px;
    color: #b0a094;
    margin-left: 6px;
}

/* 媒体消息 */
.msg.media img {
    max-width: 100%;
    max-height: 300px;
    height: auto;
    width: auto;
    border-radius: 12px;
    display: block;
    cursor: pointer;
}
.msg.media video {
    max-width: 100%;
    max-height: 300px;
    height: auto;
    width: auto;
    border-radius: 12px;
    display: block;
}
.msg.media .time {
    padding: 0 8px 4px 8px;
}

/* 文件过期 */
.media-expired {
    background: #f0ebe5;
    color: #b0a094;
    padding: 30px 16px;
    text-align: center;
    border-radius: 12px;
    font-size: 14px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
}
.media-expired .icon {
    font-size: 32px;
}

/* 系统消息 */
.msg.system {
    background: #fdf8f0;
    color: #4a3f38;
    border: 1px solid #f0ebe5;
    align-self: center;
    text-align: center;
    font-size: 14px;
    max-width: 90%;
}
.msg.system .system-content {
    padding: 4px 0;
}
.msg.system .system-actions {
    display: flex;
    gap: 8px;
    justify-content: center;
    margin-top: 8px;
}
.msg.system .system-actions button {
    padding: 4px 16px;
    font-size: 13px;
    width: auto;
    margin: 0;
}

/* 打字气泡 */
.typing-bubble {
    align-self: flex-start;
    background: #f0ebe5;
    color: #b0a094;
    padding: 8px 14px;
    border-radius: 20px;
    border-bottom-left-radius: 4px;
    font-size: 14px;
    max-width: 80%;
    display: inline-block;
    margin-top: 4px;
    opacity: .8;
    min-height: 36px;
    word-break: break-word;
    line-height: 1.4;
}
.typing-bubble.hidden {
    display: none;
}

/* 输入栏 */
.chat-input {
    display: flex;
    gap: 8px;
    padding: 12px 0 0;
    border-top: 1px solid #f0ebe5;
    flex-shrink: 0;
    align-items: center;
}
.chat-input .plus-btn {
    background: none;
    border: none;
    font-size: 28px;
    color: #d4836c;
    cursor: pointer;
    padding: 0 4px;
    width: auto;
    margin: 0;
    line-height: 1;
}
.chat-input .plus-btn:hover {
    color: #c2725b;
}
.chat-input input {
    flex: 1;
    padding: 10px 16px;
    border-radius: 30px;
    border: 1.5px solid #eee;
    outline: none;
    font-size: 15px;
}
.chat-input input:focus {
    border-color: #d4836c;
}
.chat-input button {
    width: auto;
    padding: 10px 20px;
    margin: 0;
}

/* ----- 功能面板 ----- */
.action-sheet-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, .4);
    z-index: 1000;
    display: flex;
    justify-content: center;
    align-items: flex-end;
}
.action-sheet {
    background: #fff;
    border-radius: 24px 24px 0 0;
    padding: 20px 20px 30px;
    max-width: 440px;
    width: 100%;
    animation: slideUp .25s ease-out;
}
@keyframes slideUp {
    from {
        transform: translateY(100%);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}
.action-sheet .handle {
    width: 40px;
    height: 4px;
    background: #ddd;
    border-radius: 4px;
    margin: 0 auto 16px;
}
.action-sheet .grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
}
.action-sheet .grid .item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    padding: 8px 0;
}
.action-sheet .grid .item .icon {
    width: 56px;
    height: 56px;
    border-radius: 16px;
    background: #fdf8f0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
}
.action-sheet .grid .item .label {
    font-size: 12px;
    color: #4a3f38;
}
.action-sheet .grid .item:active .icon {
    background: #f0ebe5;
}
.action-sheet .close-btn {
    margin-top: 16px;
    background: #f5f5f5;
    color: #4a3f38;
    font-size: 16px;
    padding: 12px;
    border-radius: 30px;
    width: 100%;
    border: none;
    cursor: pointer;
}
.action-sheet .close-btn:hover {
    background: #eee;
}

/* ----- 对话框（小纸条 / 阅后即焚 / 已读回执） ----- */
.dialog-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, .45);
    z-index: 1100;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
}
.dialog-box {
    background: #fff;
    border-radius: 24px;
    padding: 24px 20px;
    max-width: 360px;
    width: 100%;
}
.dialog-box h3 {
    font-size: 18px;
    color: #4a3f38;
    text-align: center;
    margin-bottom: 12px;
}
.dialog-box p {
    font-size: 14px;
    color: #6b5f54;
    text-align: center;
    margin-bottom: 16px;
    line-height: 1.6;
}
.dialog-box textarea {
    width: 100%;
    padding: 12px;
    border: 1.5px solid #eee;
    border-radius: 16px;
    font-size: 15px;
    resize: none;
    min-height: 100px;
    outline: none;
    font-family: inherit;
}
.dialog-box textarea:focus {
    border-color: #d4836c;
}
.dialog-box .input-row {
    display: flex;
    align-items: center;
    gap: 8px;
    justify-content: center;
    margin-bottom: 16px;
}
.dialog-box .input-row input {
    width: 80px;
    padding: 8px;
    border: 1.5px solid #eee;
    border-radius: 30px;
    font-size: 16px;
    text-align: center;
    outline: none;
}
.dialog-box .input-row input:focus {
    border-color: #d4836c;
}
.dialog-box .input-row span {
    font-size: 15px;
    color: #4a3f38;
}
.dialog-box .btn-row {
    display: flex;
    gap: 10px;
    margin-top: 12px;
}
.dialog-box .btn-row button {
    flex: 1;
    padding: 12px;
    border: none;
    border-radius: 30px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
}
.dialog-box .btn-row .cancel {
    background: #f0ebe5;
    color: #4a3f38;
}
.dialog-box .btn-row .send {
    background: #d4836c;
    color: #fff;
}
.dialog-box .btn-row .send:hover {
    background: #c2725b;
}
.dialog-box .btn-row .cancel:hover {
    background: #e5ddd5;
}
.dialog-status {
    font-size: 13px;
    color: #d4836c;
    text-align: center;
    margin-top: 8px;
}

/* ----- 文件输入（隐藏） ----- */
#file-input,
#video-input {
    display: none;
}

/* ----- 图片预览 ----- */
.image-preview-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, .85);
    z-index: 2000;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
    cursor: pointer;
}
.image-preview-overlay img {
    max-width: 100%;
    max-height: 90vh;
    border-radius: 12px;
    object-fit: contain;
}
.image-preview-overlay .close-preview {
    position: absolute;
    top: 20px;
    right: 20px;
    color: #fff;
    font-size: 32px;
    cursor: pointer;
    background: none;
    border: none;
    width: auto;
    padding: 0 12px;
    margin: 0;
}
.image-preview-overlay .close-preview:hover {
    color: #ddd;
}

/* ----- 协议勾选框 ----- */
.agree-check {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    margin: 12px 0 16px;
    font-size: 14px;
    color: #4a3f38;
}
.agree-check input[type=checkbox] {
    width: 18px;
    height: 18px;
    margin-top: 1px;
    flex-shrink: 0;
    accent-color: #d4836c;
}
.agree-check a {
    color: #d4836c;
    text-decoration: none;
}
.agree-check a:hover {
    text-decoration: underline;
}
.agree-check .error-text {
    color: #e74c3c;
    font-size: 13px;
    display: block;
    margin-top: 4px;
}

/* ----- 响应式 ----- */
@media (max-width: 480px) {
    #app {
        padding: 20px 16px;
        border-radius: 24px;
        margin: 10px 0;
    }
    .action-sheet .grid {
        grid-template-columns: repeat(4, 1fr);
        gap: 12px;
    }
    .action-sheet .grid .item .icon {
        width: 48px;
        height: 48px;
        font-size: 24px;
    }
    .dialog-box {
        padding: 20px 16px;
    }
    .modal-box {
        padding: 20px 16px;
    }
}