* { margin: 0; padding: 0; box-sizing: border-box; }
body {
    font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
    min-height: 100dvh;
    background: linear-gradient(145deg, #f7f0e6 0%, #e3d6c8 100%);
    display: flex; justify-content: center; align-items: center;
    position: relative; overflow: auto;
}
.background-lines { position: fixed; inset: 0; z-index: 0; pointer-events: none; overflow: hidden; }
.line { position: absolute; border-radius: 50%; animation: floatLine 6s infinite alternate ease-in-out; }
.line:nth-child(1) { width: 12px; height: 90vh; left: 5%; top: -20%; animation-duration: 5s; background: rgba(120, 90, 70, 0.25); }
.line:nth-child(2) { width: 8px; height: 70vh; right: 10%; bottom: -30%; animation-duration: 7s; animation-delay: 1s; background: rgba(140, 110, 90, 0.2); transform: rotate(45deg); }
.line:nth-child(3) { width: 6px; height: 110vh; left: 25%; top: -60%; animation-duration: 4.5s; animation-delay: 2s; background: rgba(160, 130, 110, 0.2); transform: rotate(-30deg); }
.line:nth-child(4) { width: 15px; height: 80vh; right: 5%; top: 15%; animation-duration: 8s; animation-delay: 0.5s; background: rgba(100, 80, 60, 0.15); transform: rotate(60deg); }
.line:nth-child(5) { width: 10px; height: 100vh; left: 55%; bottom: -10%; animation-duration: 6s; animation-delay: 3s; background: rgba(130, 105, 85, 0.2); }
.line:nth-child(6) { width: 5px; height: 130vh; left: 40%; top: -50%; animation-duration: 4s; animation-delay: 1.5s; background: rgba(150, 125, 105, 0.15); transform: rotate(20deg); }
.line:nth-child(7) { width: 20px; height: 60vh; right: 25%; top: 80%; animation-duration: 9s; animation-delay: 0.8s; background: rgba(180, 150, 130, 0.15); transform: rotate(-15deg); }
.line:nth-child(8) { width: 4px; height: 150vh; left: 75%; top: -20%; animation-duration: 5.5s; animation-delay: 2.5s; background: rgba(90, 70, 50, 0.2); transform: rotate(80deg); }
@keyframes floatLine { 0% { transform: translate(0, 0) rotate(0) scale(1); opacity: 0.2; } 100% { transform: translate(120px, -120px) rotate(35deg) scale(1.6); opacity: 0.7; } }

.card {
    background: rgba(255, 248, 240, 0.2); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.05); border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 48px; padding: 24px 20px 16px; max-width: 600px; width: 100%;
    position: relative; z-index: 2; margin: 20px; display: flex; flex-direction: column;
}
.header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; border-bottom: 1px solid rgba(255, 255, 255, 0.2); padding-bottom: 12px; }
.header h1 { font-size: 1.3rem; font-weight: 600; color: #2d1f18; text-shadow: 0 2px 10px #fff8; }
.header-buttons { display: flex; gap: 10px; }
.header-buttons button, .header-buttons a { background: rgba(255, 255, 255, 0.4); border: none; border-radius: 20px; padding: 4px 16px; font-size: 0.8rem; font-weight: 500; color: #2d1f18; cursor: pointer; text-decoration: none; transition: 0.2s; backdrop-filter: blur(4px); }
.header-buttons button:hover, .header-buttons a:hover { background: rgba(255, 255, 255, 0.7); }

#message-container { flex: 1 1 0; display: flex; flex-direction: column; gap: 12px; padding: 10px 6px; scroll-behavior: smooth; overflow-y: auto; margin-bottom: 8px; }
#message-container::-webkit-scrollbar { width: 4px; }
#message-container::-webkit-scrollbar-track { background: transparent; }
#message-container::-webkit-scrollbar-thumb { background: rgba(0, 0, 0, 0.15); border-radius: 10px; }

.msg { padding: 12px 16px; border-radius: 20px; max-width: 80%; word-wrap: break-word; box-shadow: 0 2px 6px rgba(0, 0, 0, 0.04); animation: popIn 0.2s ease-out; }
@keyframes popIn { 0% { transform: scale(0.9); opacity: 0; } 100% { transform: scale(1); opacity: 1; } }
.msg-sent { align-self: flex-end; background: rgba(60, 130, 210, 0.75); backdrop-filter: blur(4px); color: #fff; border-bottom-right-radius: 4px; }
.msg-received { align-self: flex-start; background: rgba(255, 255, 255, 0.7); backdrop-filter: blur(4px); color: #2d1f18; border-bottom-left-radius: 4px; }
.msg-user { font-size: 0.7rem; font-weight: 600; opacity: 0.8; margin-bottom: 4px; display: block; }
.msg-time { font-size: 0.6rem; opacity: 0.6; margin-top: 4px; text-align: right; display: block; }

.file-attachment { margin-top: 8px; padding: 8px; border-radius: 12px; background: rgba(255, 255, 255, 0.2); display: flex; align-items: center; gap: 8px; max-width: 280px; }
.file-attachment img { max-width: 100%; max-height: 300px; border-radius: 8px; cursor: pointer; object-fit: cover; }
.file-attachment audio { width: 100%; margin-top: 4px; }
.file-attachment video { max-width: 100%; border-radius: 8px; }
.file-icon { font-size: 1.5rem; }
.file-info { flex: 1; min-width: 0; }
.file-name { font-size: 0.8rem; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.file-size { font-size: 0.7rem; opacity: 0.7; }
.download-btn { background: rgba(255, 255, 255, 0.3); border: none; border-radius: 50%; width: 32px; height: 32px; cursor: pointer; display: flex; align-items: center; justify-content: center; transition: 0.2s; text-decoration: none; color: inherit; }
.download-btn:hover { background: rgba(255, 255, 255, 0.5); transform: scale(1.1); }

.input-area { display: flex; gap: 10px; background: rgba(255, 255, 255, 0.4); backdrop-filter: blur(8px); padding: 10px 14px; border-radius: 40px; border: 1px solid rgba(255, 255, 255, 0.5); }
#chat-input { flex: 1; border: none; outline: none; background: transparent; font-size: 1rem; color: #2d1f18; padding: 4px 0; }
#chat-input::placeholder { color: rgba(45, 31, 24, 0.4); }
.action-btn { background: rgba(255, 255, 255, 0.7); border: none; border-radius: 50%; width: 44px; height: 44px; font-size: 1.3rem; cursor: pointer; transition: 0.2s; display: flex; justify-content: center; align-items: center; flex-shrink: 0; }
.action-btn:hover { background: #fff; transform: scale(1.05); }

#file-preview { display: none; padding: 10px; background: rgba(255, 255, 255, 0.3); border-radius: 16px; margin-bottom: 8px; gap: 8px; flex-wrap: wrap; }
.preview-item { position: relative; background: rgba(255, 255, 255, 0.5); border-radius: 12px; padding: 8px; display: flex; align-items: center; gap: 8px; max-width: 200px; }
.preview-item img { width: 60px; height: 60px; object-fit: cover; border-radius: 8px; }
.preview-item .remove-preview { position: absolute; top: -8px; right: -8px; background: rgba(220, 50, 50, 0.8); border: none; border-radius: 50%; width: 24px; height: 24px; cursor: pointer; color: #fff; font-size: 0.9rem; display: flex; align-items: center; justify-content: center; transition: 0.2s; }
.preview-item .remove-preview:hover { background: rgba(220, 50, 50, 1); transform: scale(1.1); }

#modal-overlay { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.3); backdrop-filter: blur(4px); display: flex; justify-content: center; align-items: center; z-index: 999; opacity: 0; pointer-events: none; transition: opacity 0.3s ease; }
#modal-overlay.active { opacity: 1; pointer-events: all; }
.modal-box { background: rgba(255, 248, 240, 0.95); padding: 30px; border-radius: 24px; max-width: 320px; width: 90%; text-align: center; box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2); transform: scale(0.9); transition: transform 0.3s ease; }
#modal-overlay.active .modal-box { transform: scale(1); }
.modal-box h2 { font-size: 1.2rem; color: #2d1f18; margin-bottom: 10px; }
.modal-box p { font-size: 0.9rem; color: #5a4a3e; margin-bottom: 20px; }
.modal-input { width: 100%; padding: 12px 16px; border-radius: 16px; border: 1px solid rgba(0, 0, 0, 0.1); font-size: 1rem; margin-bottom: 16px; background: #fff; outline: none; }
.modal-input:focus { border-color: rgba(60, 130, 210, 0.5); }
.modal-btn { width: 100%; padding: 12px; border: none; border-radius: 40px; background: rgba(60, 130, 210, 0.8); color: #fff; font-size: 1rem; font-weight: 600; cursor: pointer; transition: 0.2s; }
.modal-btn:hover { background: rgba(60, 130, 210, 1); }

@media (max-width: 650px) {
    body { padding: 0; align-items: stretch; overflow-y: auto; touch-action: pan-y; }
    .card { border-radius: 0; margin: 0; max-width: 100%; height: 100dvh; max-height: none; padding: 16px 12px 7px !important; background: rgba(255, 248, 240, 0.15); }
    .header { padding-top: 6px; padding-bottom: 8px; margin-bottom: 8px; }
    #message-container { flex: 1; display: flex; flex-direction: column; gap: 12px; padding: 10px 6px; scroll-behavior: smooth; overflow-y: auto; margin-bottom: 8px; }
    .input-area { background: rgba(255, 255, 255, 0.85) !important; backdrop-filter: none !important; -webkit-backdrop-filter: none !important; padding: 8px 12px; margin-bottom: 4px !important; border-radius: 30px !important; flex-shrink: 0; }
    #file-preview { margin: 8px 0; }
}
@media (min-width: 651px) {
    body { align-items: stretch; padding: 0; }
    .card { margin: 0; border-radius: 0; height: 100vh; max-width: 100%; background: rgba(255, 248, 240, 0.25); }
}
@media (min-width: 651px) { body { overflow: auto !important; } }


/* Явные стили для иконок файлов */
.file-icon {
    font-size: 1.5rem !important;
    display: inline-block !important;
    line-height: 1 !important;
}

/* Красный крестик удаления */
.remove-preview {
    background: rgba(220, 50, 50, 0.8) !important;
    color: #fff !important;
    font-size: 0.9rem !important;
    font-weight: bold !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
}

.remove-preview:hover {
    background: rgba(220, 50, 50, 1) !important;
    transform: scale(1.1) !important;
}

/* Иконка для PDF */
.file-attachment span.file-icon {
    font-size: 1.5rem;
    margin-right: 8px;
}