/* ---------- 全局重置 & 字体 ---------- */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: #f6f8fc;
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
    margin: 0;
}

/* ---------- 主卡片 ---------- */
.app {
    width: 100%;
    max-width: 1100px;
    height: 100%;
    max-height: 850px;
    background: #ffffff;
    border-radius: 32px;
    box-shadow: 0 25px 60px -12px rgba(0, 20, 40, 0.25);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: all 0.2s ease;
}

/* ---------- 顶部栏 ---------- */
.header {
    padding: 20px 28px;
    border-bottom: 1px solid #eef2f6;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
    background: #fafcff;
}

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

.logo {
    font-size: 22px;
    font-weight: 700;
    color: #1a2634;
    letter-spacing: -0.3px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.logo span {
    background: #3b82f6;
    color: #fff;
    font-size: 14px;
    font-weight: 600;
    padding: 2px 12px;
    border-radius: 30px;
    letter-spacing: 0;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}

.online-badge {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 14px;
    color: #2d3a4a;
    background: #eef2f6;
    padding: 6px 14px;
    border-radius: 30px;
    font-weight: 500;
}

.online-badge .dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #22c55e;
    display: inline-block;
    animation: pulse-dot 2s infinite;
}

@keyframes pulse-dot {
    0%,
    100% {
        opacity: 1;
        transform: scale(1);
    }
    50% {
        opacity: 0.5;
        transform: scale(0.85);
    }
}

.room-id {
    font-size: 13px;
    color: #6b7a8d;
    background: #f0f4fa;
    padding: 5px 14px;
    border-radius: 30px;
    font-family: 'SF Mono', 'Fira Code', monospace;
    letter-spacing: 0.3px;
    user-select: all;
    cursor: pointer;
}

.room-id:hover {
    background: #e6ecf4;
}

/* ---------- 用户列表 ---------- */
.users-bar {
    padding: 12px 28px;
    background: #f8faff;
    border-bottom: 1px solid #eef2f6;
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    min-height: 56px;
}

.users-bar .label {
    font-size: 13px;
    font-weight: 500;
    color: #6b7a8d;
    margin-right: 4px;
}

.user-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 14px 4px 10px;
    border-radius: 30px;
    font-size: 13px;
    font-weight: 500;
    background: #fff;
    border: 1px solid #e2e8f0;
    transition: all 0.15s;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.02);
}

.user-chip .color-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    display: inline-block;
    flex-shrink: 0;
}

.user-chip .name {
    color: #1a2634;
    max-width: 90px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.user-chip .badge-me {
    font-size: 10px;
    background: #3b82f6;
    color: #fff;
    padding: 0 8px;
    border-radius: 20px;
    font-weight: 600;
    line-height: 18px;
}

.user-chip .status-typing {
    font-size: 12px;
    color: #3b82f6;
    animation: blink 1.2s infinite;
    font-weight: 400;
}

@keyframes blink {
    0%,
    100% {
        opacity: 1;
    }
    50% {
        opacity: 0.2;
    }
}

.typing-indicator-global {
    font-size: 13px;
    color: #6b7a8d;
    font-weight: 400;
    margin-left: 4px;
    min-height: 20px;
}

/* ---------- 编辑器 ---------- */
.editor-wrapper {
    flex: 1;
    padding: 16px 28px 28px 28px;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.editor-wrapper textarea {
    width: 100%;
    height: 100%;
    border: none;
    outline: none;
    resize: none;
    font-size: 16px;
    line-height: 1.7;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    color: #1a2634;
    background: #fcfdff;
    padding: 16px 20px;
    border-radius: 20px;
    border: 1px solid #eef2f6;
    transition: border-color 0.2s, background 0.2s;
    box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.02);
}

.editor-wrapper textarea:focus {
    border-color: #3b82f6;
    background: #ffffff;
    box-shadow: inset 0 2px 6px rgba(59, 130, 246, 0.06), 0 0 0 4px rgba(59, 130, 246, 0.08);
}

.editor-wrapper textarea::placeholder {
    color: #b0c0d0;
    font-weight: 400;
}

/* ---------- 底部状态 ---------- */
.footer {
    padding: 12px 28px 18px 28px;
    border-top: 1px solid #eef2f6;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    background: #fafcff;
    font-size: 13px;
    color: #8a9aa8;
}

.footer .status-text {
    display: flex;
    align-items: center;
    gap: 6px;
}

.footer .status-text .indicator {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    display: inline-block;
}

.footer .status-text .indicator.online {
    background: #22c55e;
}

.footer .status-text .indicator.offline {
    background: #ef4444;
}

.footer .key-hint {
    font-size: 12px;
    color: #b0c0d0;
}

/* ---------- 响应式 ---------- */
@media (max-width: 640px) {
    body {
        padding: 10px;
    }
    .app {
        max-height: 100vh;
        border-radius: 20px;
    }
    .header {
        padding: 14px 16px;
    }
    .logo {
        font-size: 18px;
    }
    .logo span {
        font-size: 12px;
        padding: 1px 10px;
    }
    .users-bar {
        padding: 8px 16px;
        gap: 8px;
    }
    .editor-wrapper {
        padding: 12px 16px 16px 16px;
    }
    .editor-wrapper textarea {
        font-size: 15px;
        padding: 12px 14px;
        border-radius: 14px;
    }
    .footer {
        padding: 10px 16px 14px 16px;
        font-size: 12px;
    }
    .room-id {
        font-size: 11px;
        padding: 3px 10px;
    }
    .user-chip {
        font-size: 12px;
        padding: 3px 10px 3px 8px;
    }
    .header-right {
        gap: 8px;
    }
    .online-badge {
        font-size: 12px;
        padding: 4px 10px;
    }
}

@media (max-width: 480px) {
    .header {
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
    }
    .header-right {
        justify-content: space-between;
    }
    .users-bar .label {
        font-size: 12px;
    }
    .typing-indicator-global {
        font-size: 12px;
    }
}

/* ---------- 滚动条美化 ---------- */
.editor-wrapper textarea::-webkit-scrollbar {
    width: 5px;
}
.editor-wrapper textarea::-webkit-scrollbar-track {
    background: transparent;
}
.editor-wrapper textarea::-webkit-scrollbar-thumb {
    background: #d0d8e0;
    border-radius: 10px;
}
.editor-wrapper textarea::-webkit-scrollbar-thumb:hover {
    background: #b8c4d0;
}

/* ---------- 连接状态 ---------- */
.connecting-overlay {
    position: fixed;
    inset: 0;
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(6px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 999;
    transition: opacity 0.5s ease;
}
.connecting-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}
.connecting-overlay .spinner {
    width: 44px;
    height: 44px;
    border: 4px solid #e2e8f0;
    border-top-color: #3b82f6;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}
@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}
.connecting-overlay p {
    margin-top: 18px;
    font-size: 15px;
    color: #4a5a6a;
    font-weight: 500;
}
