* { margin: 0; padding: 0; box-sizing: border-box; }
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; background: #ededed; min-height: 100vh; overflow-y: auto; }

/* Login - simplified */
/* ============================================
   LOGIN PAGE — Redesigned with glassmorphism
   ============================================ */
/* ============================================ */
/* LOGIN PAGE — Dark Aurora Mesh Background     */
.login-page {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background: #020617; /* Extremely dark space blue */
    position: relative;
    overflow: hidden;
}

.login-page::before, .login-page::after {
    content: '';
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
    opacity: 0.45;
    z-index: 0;
    animation: driftBg 12s infinite alternate ease-in-out;
}

.login-page::before {
    width: 60vmax; height: 60vmax;
    top: -30vh; left: -20vw;
    background: radial-gradient(circle at center, #4f46e5, transparent 55%);
}

.login-page::after {
    width: 70vmax; height: 70vmax;
    bottom: -30vh; right: -15vw;
    background: radial-gradient(circle at center, #8b5cf6, transparent 50%);
    animation-delay: -6s;
}

@keyframes driftBg {
    0%   { transform: translate(0, 0) scale(1); }
    100% { transform: translate(40px, 30px) scale(1.1); }
}

/* Disable old dots so they don't clash */
.login-wrapper { position: relative; z-index: 1; }
.bg-dots span { opacity: 0 !important; animation: none !important; }/* Animated background dots */
.bg-dots {
    position: absolute;
    width: 100%;
    height: 100%;
    z-index: 0;
    pointer-events: none;
}
.bg-dots span {
    position: absolute;
    border-radius: 50%;
    background: rgba(139, 92, 246, 0.15);
    animation: floatUp 8s infinite linear;
}
.bg-dots span:nth-child(1) { width:80px;height:80px;left:10%;bottom:-100px;animation-delay:0s;animation-duration:12s }
.bg-dots span:nth-child(2) { width:40px;height:40px;left:30%;bottom:-80px;animation-delay:1s;animation-duration:9s }
.bg-dots span:nth-child(3) { width:60px;height:60px;left:50%;bottom:-120px;animation-delay:2s;animation-duration:14s }
.bg-dots span:nth-child(4) { width:35px;height:35px;left:70%;bottom:-90px;animation-delay:0.5s;animation-duration:11s }
.bg-dots span:nth-child(5) { width:50px;height:50px;left:85%;bottom:-110px;animation-delay:3s;animation-duration:10s }
.bg-dots span:nth-child(6) { width:70px;height:70px;left:20%;bottom:-130px;animation-delay:1.5s;animation-duration:13s }
.bg-dots span:nth-child(7) { width:45px;height:45px;left:60%;bottom:-75px;animation-delay:2.5s;animation-duration:8s }
.bg-dots span:nth-child(8) { width:55px;height:55px;left:90%;bottom:-100px;animation-delay:4s;animation-duration:15s }

@keyframes floatUp {
    0%   { transform: translateY(0) rotate(0deg); opacity:0.6 }
    50%  { opacity:1 }
    100% { transform: translateY(-120vh) rotate(360deg); opacity:0 }
}

.login-wrapper {
    position: relative;
    z-index: 1;
    animation: fadeInUp .8s ease-out both;
}

@keyframes fadeInUp {
    from { transform: translateY(40px); opacity: 0 }
    to   { transform: translateY(0);     opacity: 1 }
}

/* Glassmorphism Card */
.login-box {
    background: rgba(255, 255, 255, 0.07);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border: 1px solid rgba(255, 255, 255, 0.12);
    padding: 48px 44px 36px;
    border-radius: 24px;
    width: 400px;
    box-shadow:
        0 25px 60px rgba(0, 0, 0, 0.3),
        inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

/* Pig Logo — gentle breathing animation */
.pig-logo-wrap {
    display: flex;
    justify-content: center;
    margin-bottom: 16px;
    animation: breathe 3s ease-in-out infinite;
}
@keyframes breathe {
    0%, 100% { transform: scale(1) }
    50%      { transform: scale(1.05) }
}
.pig-logo-svg svg {
    width: 120px;
    height: 120px;
    filter: drop-shadow(0 0 20px rgba(139, 92, 246, 0.3));
}

/* Title & subtitle */
.login-title {
    text-align: center;
    color: #fff;
    font-size: 26px;
    font-weight: 700;
    margin: 20px 0 4px;
    letter-spacing: 1.5px;
}
.login-subtitle {
    text-align: center;
    color: rgba(255,255,255,0.5);
    font-size: 13px;
    margin-bottom: 32px;
    letter-spacing: .5px;
}

/* Login form */
.login-form {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

/* Input groups with icons */
.input-group {
    position: relative;
    display: block;
}
.input-group input {
    width: 100%;
    padding: 16px 20px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.06);
    color: #fff;
    font-size: 15px;
    outline: none;
    transition: all .25s;
}
.input-group input::placeholder {
    color: rgba(255, 255, 255, 0.3);
}
.input-group input:focus {
    border-color: #8b5cf6;
    background: rgba(139, 92, 246, 0.08);
    box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.15);
}

/* Login Button */
#loginBtn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-top: 8px;
    padding: 16px;
    border: none;
    border-radius: 14px;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    color: #fff;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    letter-spacing: 2px;
    transition: all .3s;
    box-shadow: 0 8px 30px rgba(99, 102, 241, .3);
}
#loginBtn:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 40px rgba(99, 102, 241, .5);
}
#loginBtn:active {
    transform: translateY(0);
    box-shadow: 0 4px 20px rgba(99, 102, 241, .3);
}
.btn-arrow { transition: transform .2s }
#loginBtn:hover .btn-arrow { transform: translateX(4px) }

/* Footer text */
.login-footer {
    text-align: center;
    color: rgba(255,255,255,0.2);
    font-size: 11px;
    margin-top: 16px;
}

/* Error message — shake on appear */
.error-msg {
    text-align: center;
    color: #f87171;
    margin-top: 12px;
    font-size: 13px;
    min-height: 20px;
    transition: all .3s;
}
.error-msg:not(:empty) {
    animation: shake .4s ease-in-out;
}
@keyframes shake {
    0%, 100% { transform: translateX(0) }
    25%      { transform: translateX(-6px) }
    75%      { transform: translateX(6px) }
}
.login-box {
    background: rgba(255, 255, 255, 0.97);
    padding: 48px 40px 40px;
    border-radius: 20px;
    width: 360px;
    box-shadow: 0 25px 80px rgba(0, 0, 0, 0.3);
}

/* SVG Pig logo */
.pig-logo {
    display: block;
    margin: 0 auto 20px;
    width: 72px;
    height: 72px;
}
.pig-logo svg {
    width: 100%;
    height: 100%;
}

.login-box h1 {
    text-align: center;
    margin-bottom: 8px;
    color: #1a1a2e;
    font-size: 22px;
    font-weight: 600;
    letter-spacing: 1px;
}

/* Tagline */
.login-tagline {
    text-align: center;
    margin-bottom: 20px;
}
.login-tagline strong {
    color: #1a1a2e;
    font-weight: 700;
    font-size: 16px;
    text-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

/* ===== Desktop/Home page - 简洁精致的单页风格 ===== */
.desktop-page {
    display: none;
    flex-direction: column;
    min-height: 100vh;
    background: #f5f5f5;
    overflow-y: auto;
}
.desktop-page.active { display: flex; }

/* Desktop header */
.desktop-header {
    text-align: center;
    padding: 50px 20px 10px;
}
.desktop-header h1 {
    font-size: 24px;
    color: #1a1a2e;
    font-weight: 600;
    margin-bottom: 6px;
}
.desktop-header p {
    font-size: 14px;
    color: #999;
}

/* Desktop grid */
.desktop-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    padding: 30px 20px;
    max-width: 800px;
    margin: 0 auto;
}
@media (min-width: 768px) {
    .desktop-grid { grid-template-columns: repeat(2, 1fr); gap: 16px; padding: 40px 30px; }
}
@media (min-width: 1024px) {
    .desktop-grid { grid-template-columns: repeat(3, 1fr); max-width: 900px; gap: 20px; padding: 50px 40px; }
}

/* Desktop cards - 简洁风格，类似工具栏按钮 */
.desktop-card {
    background: white;
    border-radius: 12px;
    padding: 24px 16px;
    text-align: center;
    cursor: pointer;
    transition: transform 0.15s, box-shadow 0.15s;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
    border: 1px solid #eee;
}
.desktop-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.12);
    border-color: #4a90d9;
}
.desktop-card:active {
    transform: scale(0.97);
}
.desktop-card .card-icon {
    font-size: 36px;
    margin-bottom: 10px;
}
.desktop-card .card-title {
    font-size: 15px;
    font-weight: 600;
    color: #333;
    margin-bottom: 4px;
}
.desktop-card .card-desc {
    font-size: 11px;
    color: #bbb;
}

/* Philosophy section */
.philosophy-section {
    text-align: center;
    padding: 40px 20px;
    max-width: 600px;
    margin: 30px auto 0;
}
.philosophy-quote {
    font-size: 18px;
    color: #555;
    font-weight: 500;
    min-height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Desktop logout */
.desktop-logout {
    text-align: center;
    padding: 20px;
}
.desktop-logout button {
    background: rgba(255,255,255,0.6);
    border: 1px solid #ddd;
    padding: 8px 24px;
    border-radius: 20px;
    cursor: pointer;
    font-size: 13px;
    color: #999;
}

.login-box input { width: 100%; padding: 12px; margin: 8px 0; border: none; border-bottom: 1px solid #ddd; font-size: 15px; outline: none; background: transparent; transition: border-color 0.3s; }
.login-box input:focus { border-bottom-color: #4a90d9; }
.login-box button { width: 100%; padding: 12px; background: #4a90d9; color: white; border: none; border-radius: 8px; font-size: 16px; cursor: pointer; margin-top: 24px; transition: transform 0.2s, box-shadow 0.2s, background 0.2s; }
.login-box button:hover { background: #3d7fc7; box-shadow: 0 4px 15px rgba(74, 144, 217, 0.3); }
.login-box button:active { transform: translateY(0); }
.error-msg { color: red; text-align: center; margin-top: 10px; font-size: 13px; }

/* Main App */
.app { display: none; height: 100vh; min-height: 200px; flex-direction: column; }

/* Top bar (wechat style) */
.topbar { background: #ededed; padding: 8px 12px; display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid #d9d9d9; flex-shrink: 0; min-height: 44px; }
.topbar-left { display: flex; align-items: center; gap: 4px; }
.topbar-back {
    background: none;
    border: none;
    cursor: pointer;
    color: #191919;
    padding: 6px 8px;
    display: flex;
    align-items: center;
    gap: 2px;
    font-size: 14px;
}
.topbar-back svg {
    width: 20px;
    height: 20px;
}
.topbar-title { font-size: 17px; font-weight: 500; color: #191919; flex: 1; text-align: center; }
.topbar-right { display: flex; gap: 8px; align-items: center; }
.topbar-btn { background: none; border: none; font-size: 20px; cursor: pointer; color: #191919; padding: 4px 8px; }
.ws-status { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.ws-status.connected { background: #07c160; }
.ws-status.disconnected { background: #fa5151; }

/* Container */
.container { flex: 1; display: flex; overflow: hidden; }

/* Admin mode: left panel for buttons, right panel for details - side by side */
.container.admin-mode {
    background: #f5f5f5;
}
.container.admin-mode .chat-area,
.container.admin-mode #noChatSelected,
.container.admin-mode .message-list,
.container.admin-mode .input-bar {
    display: none !important;
}
.container.admin-mode .sidebar {
    width: 35% !important;
    max-width: 35% !important;
    min-width: 260px !important;
    border-right: 1px solid #e5e5e5;
    overflow-y: auto;
}
/* Admin detail panel */
#adminDetail {
    display: none;
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    background: #f5f5f5;
}
.container.admin-mode #adminDetail {
    display: block !important;
}
/* Sidebar (group list - wechat style) */
.sidebar { width: 180px; min-width: 120px; max-width: 500px; background: white; border-right: 1px solid #e5e5e5; overflow-y: auto; flex-shrink: 1; position: relative; }
/* Resize handle */
.sidebar-resize-handle {
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    width: 4px;
    cursor: col-resize;
    background: transparent;
    z-index: 10;
}
.sidebar-resize-handle:hover {
    background: #4a90d9;
}
.sidebar-tabs { display: flex; border-bottom: 1px solid #e5e5e5; position: sticky; top: 0; background: white; z-index: 1; }
.sidebar-tab { flex: 1; padding: 12px; text-align: center; font-size: 14px; cursor: pointer; border-bottom: 2px solid transparent; color: #666; }
.sidebar-tab.active { color: #07c160; border-bottom-color: #07c160; font-weight: 500; }

/* Group list items */
.group-item { display: flex; align-items: center; gap: 8px; padding: 10px 12px; cursor: pointer; border-bottom: 1px solid #f0f0f0; transition: background 0.1s; }
.group-item:hover { background: #f5f5f5; }
.group-item.active { background: #d6eaf8; }
.group-avatar { width: 32px; height: 32px; border-radius: 4px; background: #07c160; color: white; display: flex; align-items: center; justify-content: center; font-size: 14px; flex-shrink: 0; }
.group-info { flex: 1; overflow: hidden; }
.group-name { font-size: 13px; color: #191919; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.group-last-msg { font-size: 11px; color: #999; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Chat area (fullscreen focus) */
.chat-area { flex: 1; display: flex; flex-direction: column; background: #f5f5f5; min-height: 0; }
.chat-area.visible { flex: 1; }

/* Messages */
.chat-messages { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 8px; min-height: 0; }
.message { margin-bottom: 20px; display: flex; flex-direction: column; }
.message.sent { align-items: flex-end; }
.message.received { align-items: flex-start; }

.msg-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    color: white;
    flex-shrink: 0;
    margin-bottom: 4px;
    overflow: hidden;
}
.msg-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
.sent .msg-avatar { background: #07c160; }
.received .msg-avatar { background: #e91e63; }

.msg-bubble-wrap { display: flex; gap: 8px; align-items: flex-start; max-width: 75%; }
.sent .msg-bubble-wrap { flex-direction: row-reverse; }

.msg-bubble { padding: 10px 14px; border-radius: 4px; font-size: 15px; line-height: 1.5; word-wrap: break-word; position: relative; cursor: pointer; }
.msg-bubble:hover { opacity: 0.9; }
.sent .msg-bubble { background: #95ec69; color: #191919; }
/* Image/video bubbles: no colored background */
.msg-bubble.has-media.sent { background: transparent !important; }
.msg-bubble.has-media.sent:hover { opacity: 1; }
.received .msg-bubble { background: white; color: #191919; border: none; }

/* Selected message highlight */
.msg-bubble.selected {
    opacity: 0.6;
}

/* Message context menu for forwarding */
.msg-context-menu {
    display: none;
    position: fixed;
    background: #3a3a3c;
    border-radius: 14px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.3);
    z-index: 1000;
    min-width: 150px;
    overflow: hidden;
}
.msg-context-menu.visible { display: block; }
.msg-context-overlay {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    z-index: 999;
}
.msg-context-overlay.visible { display: block; }

.msg-time-divider { text-align: center; margin: 16px 0; font-size: 12px; color: #999; }
.msg-name { font-size: 12px; color: #999; margin-bottom: 2px; padding-left: 4px; }

.active-chat { display: none; flex-direction: column; min-height: 0; overflow: hidden; flex: 1; }
.active-chat.visible { display: flex; }

/* Messages area - fill remaining space */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-height: 0;
}

/* msg action bar */
.msg-action-bar {
    display: none;
    background: #fff;
    padding: 12px;
    border-top: 1px solid #e5e5e5;
    flex-shrink: 0;
    gap: 8px;
    align-items: center;
}
.msg-action-bar.visible { display: flex; }

/* Input bar - always at bottom */
/* Chat input area - WeChat style two-row layout */
.chat-input-bar {
    background: #f7f7f7;
    border-top: 1px solid #e5e5e5;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
}
/* Top toolbar row */
.chat-toolbar {
    display: flex;
    gap: 4px;
    align-items: center;
    padding: 8px 12px 4px;
}
.toolbar-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    transition: background 0.15s;
    padding: 0;
    flex-shrink: 0;
}
.toolbar-btn:hover {
    background: #e8e8e8;
}
.toolbar-btn.recording {
    background: #ffeaea;
    animation: pulse-red 1.5s infinite;
}
@keyframes pulse-red {
    0%, 100% { box-shadow: 0 0 0 0 rgba(255,70,70,0.3); }
    50% { box-shadow: 0 0 0 6px rgba(255,70,70,0); }
}
.toolbar-btn svg {
    width: 22px;
    height: 22px;
}
/* Bottom input row */
.chat-input-row {
    display: flex;
    gap: 8px;
    align-items: center;
    padding: 4px 12px 12px;
}
.chat-input-field {
    flex: 1;
    padding: 10px 14px;
    border: none;
    border-radius: 20px;
    font-size: 15px;
    background: #fff;
    outline: none;
    min-height: 38px;
}
.chat-input-field:focus {
    box-shadow: 0 0 0 1.5px #07c160;
}
.chat-input-row button.send-btn {
    padding: 10px 20px;
    background: #07c160;
    color: white;
    border: none;
    border-radius: 20px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    flex-shrink: 0;
    white-space: nowrap;
    transition: background 0.15s, transform 0.1s;
}
.chat-input-row button.send-btn:hover {
    background: #06ad56;
}
.chat-input-row button.send-btn:active {
    transform: scale(0.96);
}

/* Reply quote bar - shows when replying to a message */
.reply-quote-bar {
    background: #f7f7f7;
    padding: 8px 14px;
    border-top: 1px solid #e5e5e5;
    display: none;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}
.reply-quote-bar.visible { display: flex; }
.reply-quote-bar .reply-info {
    flex: 1;
    font-size: 13px;
}
.reply-quote-bar .reply-name {
    color: #07c160;
    font-weight: 600;
    margin-right: 6px;
}
.reply-quote-bar .reply-text {
    color: #999;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 300px;
}
.reply-quote-bar button {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 18px;
    color: #999;
    padding: 4px;
}

/* Reply preview in message bubble - WeChat style */
.msg-reply-preview {
    background: #f5f5f5;
    padding: 6px 10px;
    margin-bottom: 4px;
    border-radius: 4px;
    font-size: 13px;
    color: #999;
    display: flex;
    align-items: center;
    gap: 6px;
}
.msg-reply-preview .reply-name {
    color: #07c160;
    color: #666;
    font-weight: 500;
}

/* Revoked message */
.msg-revoked {
    color: #bbb;
    font-style: italic;
    font-size: 13px;
}

/* Message context menu (long press / right click) */
.msg-context-menu {
    display: none;
    position: fixed;
    background: white;
    border-radius: 8px;
    box-shadow: 0 4px 24px rgba(0,0,0,0.15);
    z-index: 3000;
    min-width: 140px;
    overflow: hidden;
    padding: 4px 0;
}
.msg-context-menu.visible { display: block; }
.msg-context-item {
    padding: 10px 16px;
    font-size: 14px;
    cursor: pointer;
    color: #333;
    display: flex;
    align-items: center;
    gap: 8px;
}
.msg-context-item:hover { background: #f5f5f5; }
.msg-context-item.danger { color: #fa5151; }

/* Message action bar (appears when message is selected) */
.msg-action-bar {
    display: none;
    background: #fff;
    padding: 12px;
    border-top: 1px solid #e5e5e5;
    flex-shrink: 0;
    gap: 8px;
    align-items: center;
}
.msg-action-bar.visible { display: flex; }
.msg-action-btn {
    padding: 10px 20px;
    border-radius: 6px;
    border: none;
    cursor: pointer;
    font-size: 14px;
    flex: 1;
    text-align: center;
}
.msg-action-btn.forward { background: #4a90d9; color: white; }
.msg-action-btn.deselect { background: #eee; color: #333; }

/* Image editor overlay */
.image-editor-overlay {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.9);
    z-index: 2000;
    flex-direction: column;
}
.image-editor-overlay.visible { display: flex; }
.image-editor-toolbar {
    background: #333;
    padding: 10px;
    display: flex;
    gap: 8px;
    align-items: center;
    justify-content: center;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    flex-wrap: nowrap;
}
.image-editor-toolbar::-webkit-scrollbar {
    display: none;
}
/* Smaller buttons on mobile */
@media (max-width: 768px) {
    .image-editor-toolbar {
        padding: 6px 4px;
        gap: 4px;
        justify-content: flex-start;
    }
    .image-editor-toolbar button {
        min-width: 48px !important;
        padding: 6px 8px !important;
    }
    .image-editor-toolbar button svg {
        width: 20px !important;
        height: 20px !important;
    }
    .image-editor-toolbar button span {
        font-size: 10px !important;
    }
    .color-swatch {
        width: 24px !important;
        height: 24px !important;
    }
}
.editor-btn {
    padding: 8px 16px;
    border-radius: 6px;
    border: none;
    cursor: pointer;
    font-size: 14px;
}
.editor-btn.danger { background: #fa5151; color: white; }
.editor-btn.success { background: #07c160; color: white; }
.editor-btn.secondary { background: #666; color: white; }
.editor-btn.crop-active { background: #07c160; color: white; box-shadow: 0 0 0 2px white; }
.image-editor-canvas-wrap {
    flex: 1;
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}
.image-editor-canvas-wrap canvas {
    max-width: 100%;
    max-height: 100%;
    touch-action: none;
    cursor: crosshair;
}

/* Crop overlay - dark mask with selection rectangle */
.crop-overlay {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    display: none;
}
.crop-overlay.active { 
    display: block;
    pointer-events: auto;
}
.crop-selection {
    position: absolute;
    border: 2px solid #07c160;
    background: rgba(7, 193, 96, 0.1);
    box-shadow: 0 0 0 9999px rgba(0,0,0,0.5);
}

/* Admin Panel */
.admin-panel { flex: 1; overflow-y: auto; padding: 16px; background: #f5f5f5; }
.card { background: white; border-radius: 8px; padding: 20px; margin-bottom: 16px; }
.card h3 { margin-bottom: 16px; color: #333; font-size: 16px; }
.form-group { margin-bottom: 12px; }
.form-group label { display: block; margin-bottom: 4px; font-size: 13px; color: #666; }
.form-group input, .form-group select, .form-group textarea { width: 100%; padding: 8px; border: 1px solid #ddd; border-radius: 4px; font-size: 14px; }
.btn { padding: 8px 16px; background: #07c160; color: white; border: none; border-radius: 4px; cursor: pointer; font-size: 13px; }
.btn:hover { background: #06ad56; }
.btn-danger { background: #fa5151; }

.member-checkbox { display: flex; align-items: center; gap: 8px; padding: 6px 0; }
.member-checkbox input[type="checkbox"] { width: auto; }

.group-table { width: 100%; border-collapse: collapse; }
.group-table th, .group-table td { padding: 8px 12px; text-align: left; border-bottom: 1px solid #eee; }
.group-table th { font-size: 12px; color: #999; font-weight: normal; }

.question-card { background: white; border-radius: 8px; padding: 16px; margin-bottom: 12px; border-left: 4px solid #07c160; }
.question-card h4 { margin-bottom: 8px; }

/* Empty state */
.empty-chat { flex: 1; display: flex; align-items: center; justify-content: center; color: #999; font-size: 14px; }

/* Tab content panels */
.tab-panel { display: none; flex: 1; overflow: hidden; }
.tab-panel.active { display: flex; flex-direction: column; }

/* No chat selected state */
.no-chat-selected { flex: 1; display: flex; align-items: center; justify-content: center; flex-direction: column; gap: 12px; color: #999; }
.no-chat-selected .icon { font-size: 48px; }

/* Mobile responsive - iPad/tablet */
@media (max-width: 1024px) {
    .container { overflow: visible !important; }
    .sidebar { width: 100%; flex-shrink: 0; }
    /* Chat area is hidden by default on mobile, shown only after group selected */
    .chat-area {
        display: none;
        flex: 1;
        min-width: 0;
        min-height: 0;
        flex-direction: column;
    }
    .chat-area.visible {
        position: fixed !important;
        top: 44px !important;
        left: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
        z-index: 50 !important;
        display: flex !important;
        background: #f5f5f5 !important;
        width: 100% !important;
        transition: background 0.2s;
    }
    
    .chat-area.drag-active {
        background: #e8f4fd !important;
        outline: 3px dashed #4a90d9;
        outline-offset: -3px;
    }
    /* When chat is visible, force sidebar to stay hidden even if inline style fails */
    .sidebar + .chat-area.visible ~ .sidebar,
    .container > .chat-area.visible {
        /* ensure container layout works with fixed child */
    }
    .msg-bubble-wrap { max-width: 85%; }
}
@media (min-width: 1025px) {
    .chat-area { display: flex !important; flex-direction: column; }
}

/* ==================== Video Card (WeChat-style) ==================== */

.video-card {
    width: 200px;
    pointer-events: auto;
}

.video-thumb {
    position: relative;
    width: 100%;
    aspect-ratio: 16 / 9;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    overflow: hidden;
    transition: transform 0.2s, box-shadow 0.2s;
}

.video-thumb:hover {
    transform: scale(1.03);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
}

.video-thumb svg {
    width: 48px;
    height: 48px;
    opacity: 0.9;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3));
}

.video-size {
    margin-top: 6px;
    font-size: 11px;
    color: rgba(255, 255, 255, 0.7);
}

.video-loading .video-size {
    color: rgba(255, 255, 255, 0.9);
}

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

.video-card.video-loaded {
    width: 100%;
    max-width: 280px;
}

/* Scrollbar styling */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-thumb { background: #ccc; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #aaa; }

/* Search highlight animation */
.msg-bubble.search-highlight {
    outline: 3px solid #4a90d9;
    outline-offset: 2px;
    box-shadow: 0 0 16px rgba(74, 144, 217, 0.4);
    transition: outline 0.2s, box-shadow 0.2s;
}

.search-result-item:hover {
    background: #f0f8ff;
}

/* File card */
.file-card {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 12px 16px;
    background: rgba(255,255,255,0.1);
    border: 1px solid rgba(255,255,255,0.2);
    border-radius: 8px;
    cursor: pointer;
    min-width: 120px;
    text-align: center;
}
.file-card:hover {
    background: rgba(255,255,255,0.15);
}
