/* ===== StartPort Chat Widget ===== */
.sp-chat-btn {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 99999;
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: linear-gradient(135deg, #2563eb, #1d4ed8);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 24px rgba(37,99,235,0.45);
    transition: all 0.3s ease;
    animation: sp-btn-pulse 3s ease-in-out infinite;
}

@keyframes sp-btn-pulse {
    0%, 100% { box-shadow: 0 4px 24px rgba(37,99,235,0.45); }
    50% { box-shadow: 0 4px 24px rgba(37,99,235,0.45), 0 0 0 8px rgba(37,99,235,0.15); }
}

.sp-chat-btn:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 30px rgba(37,99,235,0.5);
    animation: none;
}

.sp-chat-btn.sp-hidden {
    display: none !important;
}

.sp-chat-btn-icons {
    position: relative;
    width: 28px;
    height: 28px;
    display: block;
}

.sp-chat-btn-icon {
    position: absolute;
    top: 0;
    left: 0;
    width: 28px;
    height: 28px;
    fill: white;
    opacity: 0;
    transform: scale(0.85) rotate(-8deg);
    transition: opacity 0.3s ease, transform 0.3s ease;
    will-change: opacity, transform;
}

.sp-chat-btn-icon-bubble {
    animation: sp-btn-icon-bubble 10s ease-in-out infinite;
}

.sp-chat-btn-icon-question {
    animation: sp-btn-icon-question 10s ease-in-out infinite;
}

@keyframes sp-btn-icon-bubble {
    0%, 45%   { opacity: 1; transform: scale(1) rotate(0); }
    50%, 95%  { opacity: 0; transform: scale(0.85) rotate(-8deg); }
    100%      { opacity: 1; transform: scale(1) rotate(0); }
}

@keyframes sp-btn-icon-question {
    0%, 45%   { opacity: 0; transform: scale(0.85) rotate(8deg); }
    50%, 95%  { opacity: 1; transform: scale(1) rotate(0); }
    100%      { opacity: 0; transform: scale(0.85) rotate(8deg); }
}

/* При наведении — замораживаем текущее состояние (UX: не мешает клику) */
.sp-chat-btn:hover .sp-chat-btn-icon-bubble,
.sp-chat-btn:hover .sp-chat-btn-icon-question {
    animation-play-state: paused;
}

/* Прыгающие точки внутри облачка — эффект "печатает..." */
.sp-chat-btn-dot {
    fill: white;
    transform-origin: center;
    transform-box: fill-box;
    animation: sp-btn-dot-jump 1.2s ease-in-out infinite;
}

.sp-chat-btn-dot-1 { animation-delay: 0s; }
.sp-chat-btn-dot-2 { animation-delay: 0.18s; }
.sp-chat-btn-dot-3 { animation-delay: 0.36s; }

@keyframes sp-btn-dot-jump {
    0%, 60%, 100% { transform: translateY(0) scale(1);   opacity: 0.65; }
    30%           { transform: translateY(-2px) scale(1.25); opacity: 1; }
}

.sp-chat-btn:hover .sp-chat-btn-dot {
    animation-play-state: paused;
}

.sp-chat-btn .sp-badge {
    position: absolute;
    top: -2px;
    right: -2px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #ef4444;
    color: white;
    font-size: 11px;
    font-weight: 600;
    display: none;
    align-items: center;
    justify-content: center;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

.sp-chat-btn .sp-badge.visible {
    display: flex;
}

/* Tooltip "Техподдержка" */
.sp-chat-tooltip {
    position: fixed;
    bottom: 36px;
    right: 96px;
    z-index: 99999;
    background: #1f2937;
    color: white;
    font-size: 13px;
    font-weight: 500;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    padding: 8px 14px;
    border-radius: 8px;
    white-space: nowrap;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    opacity: 0;
    transform: translateX(8px);
    transition: opacity 0.4s ease, transform 0.4s ease;
    pointer-events: none;
}

.sp-chat-tooltip::after {
    content: '';
    position: absolute;
    top: 50%;
    right: -6px;
    transform: translateY(-50%);
    border: 6px solid transparent;
    border-right: none;
    border-left-color: #1f2937;
}

.sp-chat-tooltip.visible {
    opacity: 1;
    transform: translateX(0);
}

/* Widget Container */
.sp-chat-widget {
    position: fixed;
    bottom: 96px;
    right: 24px;
    z-index: 99998;
    width: 380px;
    height: min(728px, calc(100vh - 120px));
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 12px 60px rgba(0,0,0,0.15), 0 0 0 1px rgba(0,0,0,0.05);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 14px;
    color: #1f2937;
    overscroll-behavior: contain;
    opacity: 0;
    transform: translateY(20px) scale(0.98);
    pointer-events: none;
    visibility: hidden;
    transition:
        opacity 0.25s ease,
        transform 0.3s cubic-bezier(0.22, 1, 0.36, 1),
        visibility 0s linear 0.3s;
}

.sp-chat-widget.open {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
    visibility: visible;
    touch-action: none;
    transition:
        opacity 0.25s ease,
        transform 0.3s cubic-bezier(0.22, 1, 0.36, 1),
        visibility 0s linear 0s;
}

.sp-chat-widget.open * {
    touch-action: pan-y;
}

.sp-chat-widget input,
.sp-chat-widget textarea {
    font-size: 16px !important;
}

/* Header */
.sp-chat-header {
    padding: 16px 20px;
    background: linear-gradient(135deg, #2563eb, #1d4ed8);
    color: white;
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}

.sp-chat-header-info {
    flex: 1;
}

.sp-chat-header-title {
    font-size: 15px;
    font-weight: 600;
}

.sp-chat-header-subtitle {
    font-size: 12px;
    opacity: 0.8;
    margin-top: 2px;
}

.sp-chat-header-btn {
    background: rgba(255,255,255,0.15);
    border: none;
    color: white;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    transition: background 0.2s;
}

.sp-chat-header-btn:hover {
    background: rgba(255,255,255,0.25);
}

/* Компактная иконочная кнопка (создать чат) */
.sp-chat-header-icon-btn {
    background: rgba(255,255,255,0.15);
    border: none;
    color: white;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    transition: background 0.2s;
    margin-right: 4px;
}

.sp-chat-header-icon-btn:hover {
    background: rgba(255,255,255,0.25);
}

/* Аватар пользователя в шапке */
.sp-chat-header-avatar {
    background: rgba(255,255,255,0.22);
    color: white;
    border: none;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 4px;
    font-family: inherit;
    transition: background 0.2s, transform 0.15s;
}

.sp-chat-header-avatar:hover {
    background: rgba(255,255,255,0.32);
    transform: scale(1.05);
}

/* Выпадающее меню пользователя */
.sp-chat-user-menu {
    position: absolute;
    top: 66px;
    right: 12px;
    background: #fff;
    border-radius: 10px;
    box-shadow: 0 8px 28px rgba(0,0,0,0.18), 0 0 0 1px rgba(0,0,0,0.05);
    padding: 6px;
    min-width: 180px;
    z-index: 10;
    animation: sp-menu-in 0.12s ease-out;
}

@keyframes sp-menu-in {
    from { opacity: 0; transform: translateY(-4px); }
    to { opacity: 1; transform: translateY(0); }
}

.sp-chat-user-menu-name {
    padding: 8px 10px 6px;
    font-size: 12px;
    color: #6b7280;
    border-bottom: 1px solid #f3f4f6;
    margin-bottom: 4px;
    font-weight: 500;
    word-break: break-all;
}

.sp-chat-user-menu-item {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 8px;
    background: none;
    border: none;
    padding: 8px 10px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    color: #374151;
    font-family: inherit;
    transition: background 0.15s, color 0.15s;
    text-align: left;
}

.sp-chat-user-menu-item:hover {
    background: #fef2f2;
    color: #dc2626;
}

/* Tabs */
.sp-chat-tabs {
    display: flex;
    background: #f8fafc;
    border-bottom: 1px solid #e5e7eb;
    flex-shrink: 0;
}

.sp-chat-tab {
    flex: 1;
    padding: 10px;
    background: none;
    border: none;
    font-size: 13px;
    font-weight: 500;
    color: #9ca3af;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: all 0.2s;
    font-family: inherit;
}

.sp-chat-tab:hover {
    color: #6b7280;
}

.sp-chat-tab.active {
    color: #2563eb;
    border-bottom-color: #2563eb;
}

/* Body */
.sp-chat-body {
    flex: 1;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

/* Auth Screen */
.sp-chat-auth {
    padding: 24px 20px;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start;
    flex: 1;
    overflow-y: auto;
}

.sp-chat-auth-icon {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: #eff6ff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    margin-bottom: 16px;
}

.sp-chat-auth h3 {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 6px;
}

.sp-chat-auth p {
    font-size: 13px;
    color: #9ca3af;
    margin-bottom: 24px;
    text-align: center;
}

.sp-chat-auth-form {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.sp-chat-input {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    font-size: 14px;
    font-family: inherit;
    color: #1f2937;
    background: #f9fafb;
    transition: all 0.2s;
    box-sizing: border-box;
}

.sp-chat-input:focus {
    outline: none;
    border-color: #2563eb;
    background: white;
    box-shadow: 0 0 0 3px rgba(37,99,235,0.1);
}

.sp-chat-input::placeholder {
    color: #9ca3af;
}

.sp-chat-submit {
    width: 100%;
    padding: 12px;
    border: none;
    border-radius: 10px;
    background: #2563eb;
    color: white;
    font-size: 14px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.2s;
}

.sp-chat-submit:hover {
    background: #1d4ed8;
}

.sp-chat-submit:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.sp-chat-welcome {
    background: #f0f9ff;
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 16px;
    text-align: left;
}

/* FAQ accordion (pre-auth screen) */
.sp-chat-faq {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 16px;
}

.sp-chat-faq-item {
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    background: #fff;
    overflow: hidden;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.sp-chat-faq-item.open {
    border-color: #bfdbfe;
    box-shadow: 0 1px 2px rgba(37,99,235,0.08);
}

.sp-chat-faq-q {
    width: 100%;
    background: none;
    border: none;
    padding: 11px 14px;
    font: inherit;
    font-size: 13px;
    color: #1f2937;
    text-align: left;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    line-height: 1.35;
}

.sp-chat-faq-q:hover {
    background: #f9fafb;
}

.sp-chat-faq-q-text {
    flex: 1;
    min-width: 0;
}

.sp-chat-faq-chevron {
    flex-shrink: 0;
    color: #6b7280;
    transition: transform 0.2s;
}

.sp-chat-faq-item.open .sp-chat-faq-chevron {
    transform: rotate(180deg);
}

.sp-chat-faq-a {
    max-height: 0;
    overflow: hidden;
    padding: 0 14px;
    font-size: 13px;
    color: #4b5563;
    line-height: 1.5;
    transition: max-height 0.25s ease, padding 0.25s ease;
}

.sp-chat-faq-item.open .sp-chat-faq-a {
    max-height: 600px;
    padding: 0 14px 12px;
}

.sp-chat-faq-a a {
    color: #2563eb;
}

.sp-chat-auth-cta {
    font-size: 12px;
    color: #6b7280;
    margin: 0 0 12px;
    text-align: center;
    line-height: 1.45;
}

.sp-chat-welcome-icon {
    font-size: 28px;
    margin-bottom: 8px;
}

.sp-chat-welcome p {
    font-size: 14px;
    color: #1f2937;
    margin: 0;
    line-height: 1.5;
}

.sp-chat-auth-toggle {
    margin-top: 16px;
    font-size: 13px;
    color: #9ca3af;
}

.sp-chat-auth-toggle a {
    color: #2563eb;
    cursor: pointer;
    text-decoration: none;
}

.sp-chat-auth-toggle a:hover {
    text-decoration: underline;
}

.sp-chat-error {
    color: #ef4444;
    font-size: 13px;
    text-align: center;
    min-height: 20px;
    margin-top: 4px;
}

/* Room List */
.sp-chat-rooms {
    flex: 1;
    overflow-y: auto;
}

.sp-chat-room {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 20px;
    cursor: pointer;
    border-bottom: 1px solid #f3f4f6;
    transition: background 0.15s;
}

.sp-chat-room:hover {
    background: #f8fafc;
}

.sp-chat-room-avatar {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: #eff6ff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
    color: #2563eb;
    font-weight: 600;
}

.sp-chat-room-avatar.support {
    background: #fef3c7;
    color: #d97706;
}

.sp-chat-room-info {
    flex: 1;
    min-width: 0;
}

.sp-chat-room-name {
    font-size: 14px;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sp-chat-room-last {
    font-size: 12px;
    color: #9ca3af;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-top: 2px;
}

.sp-chat-room-time {
    font-size: 11px;
    color: #9ca3af;
    flex-shrink: 0;
}

/* Phone search results */
.sp-phone-results-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.sp-phone-result {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    background: #f8fafc;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s;
}

.sp-phone-result:hover {
    background: #eff6ff;
    border-color: #2563eb;
}

.sp-phone-result-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: #2563eb;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 15px;
    font-weight: 600;
    flex-shrink: 0;
}

.sp-phone-result-info {
    flex: 1;
    min-width: 0;
}

.sp-phone-result-name {
    font-size: 14px;
    font-weight: 500;
    color: #1f2937;
}

.sp-phone-result-btn {
    background: #2563eb;
    color: white;
    border: none;
    border-radius: 8px;
    padding: 6px 14px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    flex-shrink: 0;
    font-family: inherit;
    transition: background 0.2s;
}

.sp-phone-result-btn:hover {
    background: #1d4ed8;
}

.sp-chat-room-unread {
    background: #ef4444;
    color: white;
    font-size: 11px;
    font-weight: 600;
    min-width: 20px;
    height: 20px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 6px;
    flex-shrink: 0;
}

.sp-chat-empty {
    padding: 40px 20px;
    text-align: center;
    color: #9ca3af;
    font-size: 13px;
}

.sp-chat-empty-icon {
    font-size: 36px;
    margin-bottom: 12px;
}

/* Messages */
.sp-chat-messages-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    border-bottom: 1px solid #e5e7eb;
    flex-shrink: 0;
}

.sp-chat-back {
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    color: #6b7280;
    padding: 4px;
    display: flex;
    align-items: center;
}

.sp-chat-back:hover {
    color: #1f2937;
}

.sp-chat-messages-title {
    font-size: 14px;
    font-weight: 600;
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sp-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.sp-chat-msg {
    max-width: 80%;
    padding: 10px 14px;
    border-radius: 16px;
    font-size: 14px;
    line-height: 1.45;
    word-break: break-word;
}

.sp-chat-msg-mine {
    align-self: flex-end;
    background: #2563eb;
    color: white;
    border-bottom-right-radius: 4px;
}

.sp-chat-msg-other {
    align-self: flex-start;
    background: #f3f4f6;
    color: #1f2937;
    border-bottom-left-radius: 4px;
}

.sp-chat-msg-sender {
    font-size: 12px;
    font-weight: 600;
    color: #2563eb;
    margin-bottom: 3px;
}

.sp-chat-msg-time {
    font-size: 11px;
    opacity: 0.6;
    text-align: right;
    margin-top: 4px;
}

/* Media placeholder */
.sp-chat-img-placeholder {
    padding: 20px 30px;
    text-align: center;
    background: rgba(0,0,0,0.04);
    border-radius: 8px;
    font-size: 13px;
    color: #9ca3af;
}

.sp-chat-msg-mine .sp-chat-img-placeholder {
    background: rgba(0,0,0,0.1);
    color: rgba(255,255,255,0.7);
}

/* Images */
.sp-chat-img {
    max-width: 100%;
    max-height: 240px;
    border-radius: 8px;
    display: block;
    cursor: pointer;
}

.sp-chat-media-link {
    display: block;
    text-decoration: none;
}

/* Audio / Voice */
.sp-chat-audio-wrap {
    min-width: 200px;
}

.sp-chat-audio-label {
    font-size: 12px;
    margin-bottom: 6px;
    opacity: 0.8;
}

.sp-chat-audio {
    width: 100%;
    height: 36px;
    border-radius: 18px;
}

.sp-chat-msg-mine .sp-chat-audio::-webkit-media-controls-panel {
    background: rgba(0,0,0,0.1);
}

/* Video */
.sp-chat-video-wrap {
    max-width: 100%;
}

.sp-chat-video {
    max-width: 100%;
    max-height: 240px;
    border-radius: 8px;
    display: block;
}

/* File */
.sp-chat-file {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: rgba(0,0,0,0.06);
    border-radius: 8px;
    text-decoration: none;
    color: inherit;
    transition: background 0.2s;
}

.sp-chat-file:hover {
    background: rgba(0,0,0,0.1);
}

.sp-chat-msg-mine .sp-chat-file {
    background: rgba(0,0,0,0.12);
}

.sp-chat-file-icon {
    font-size: 20px;
    flex-shrink: 0;
}

.sp-chat-file-name {
    font-size: 13px;
    word-break: break-all;
}

/* Input Area */
.sp-chat-input-area {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    border-top: 1px solid #e5e7eb;
    flex-shrink: 0;
    background: #fff;
}

.sp-chat-input-area input {
    flex: 1;
    padding: 10px 14px;
    border: 1px solid #e5e7eb;
    border-radius: 20px;
    font-size: 14px;
    font-family: inherit;
    color: #1f2937;
    background: #f9fafb;
    transition: all 0.2s;
}

.sp-chat-input-area input:focus {
    outline: none;
    border-color: #2563eb;
    background: white;
}

.sp-chat-input-area input::placeholder {
    color: #9ca3af;
}

.sp-chat-send {
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 50%;
    background: #2563eb;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all 0.2s;
}

.sp-chat-send:hover {
    background: #1d4ed8;
    transform: scale(1.05);
}

.sp-chat-send svg {
    width: 18px;
    height: 18px;
    fill: white;
}

/* New Chat */
.sp-chat-new-user {
    padding: 16px 20px;
    border-bottom: 1px solid #e5e7eb;
    display: flex;
    gap: 8px;
}

.sp-chat-new-user input {
    flex: 1;
    padding: 10px 14px;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    font-size: 14px;
    font-family: inherit;
}

.sp-chat-new-user input:focus {
    outline: none;
    border-color: #2563eb;
}

.sp-chat-new-user button {
    padding: 10px 16px;
    background: #2563eb;
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    font-family: inherit;
}

/* Responsive: tablets */
@media (max-width: 768px) {
    .sp-chat-widget {
        width: 340px;
        height: 520px;
        bottom: 80px;
        right: 16px;
    }

    .sp-chat-header {
        padding: 12px 16px;
    }

    .sp-chat-room {
        padding: 12px 16px;
        gap: 10px;
    }

    .sp-chat-room-avatar {
        width: 38px;
        height: 38px;
        font-size: 16px;
    }

    .sp-chat-msg {
        max-width: 85%;
        padding: 8px 12px;
        font-size: 13px;
    }

    .sp-chat-messages {
        padding: 12px;
        gap: 4px;
    }
}

/* Responsive: mobile fullscreen */
@media (max-width: 480px) {
    .sp-chat-widget {
        bottom: 0;
        right: 0;
        left: 0;
        top: 0;
        width: 100%;
        height: 100%;
        border-radius: 0;
        transform: translateY(100%);
    }

    .sp-chat-widget.open {
        transform: translateY(0);
    }

    .sp-chat-btn {
        bottom: 16px;
        right: 16px;
        width: 56px;
        height: 56px;
    }

    .sp-chat-btn svg {
        width: 24px;
        height: 24px;
    }

    .sp-chat-tooltip {
        bottom: 28px;
        right: 80px;
    }

    .sp-chat-header {
        padding: 14px 16px;
        padding-top: max(14px, env(safe-area-inset-top));
    }

    .sp-chat-header-title {
        font-size: 16px;
    }

    .sp-chat-tabs {
        background: #f3f4f6;
    }

    .sp-chat-tab {
        padding: 12px;
        font-size: 14px;
    }

    .sp-chat-room {
        padding: 14px 16px;
    }

    .sp-chat-room-avatar {
        width: 44px;
        height: 44px;
        font-size: 18px;
    }

    .sp-chat-room-name {
        font-size: 15px;
    }

    .sp-chat-messages-header {
        padding: 14px 16px;
    }

    .sp-chat-messages-title {
        font-size: 15px;
    }

    .sp-chat-messages {
        padding: 12px;
        gap: 4px;
    }

    .sp-chat-msg {
        max-width: 85%;
        border-radius: 18px;
        padding: 10px 14px;
        font-size: 15px;
        line-height: 1.4;
    }

    .sp-chat-msg-mine {
        border-bottom-right-radius: 4px;
    }

    .sp-chat-msg-other {
        border-bottom-left-radius: 4px;
    }

    .sp-chat-msg-sender {
        font-size: 12px;
    }

    .sp-chat-msg-time {
        font-size: 11px;
    }

    .sp-chat-input-bar {
        padding: 10px 12px;
        padding-bottom: max(10px, env(safe-area-inset-bottom));
    }

    .sp-chat-msg-input {
        font-size: 16px;
        padding: 10px 14px;
    }

    .sp-chat-send {
        width: 40px;
        height: 40px;
    }

    .sp-chat-auth {
        padding: 24px 20px;
    }

    .sp-chat-faq-q {
        font-size: 14px;
        padding: 13px 14px;
    }

    .sp-chat-faq-a {
        font-size: 14px;
    }

    .sp-chat-auth-cta {
        font-size: 13px;
    }

    .sp-chat-auth h3 {
        font-size: 20px;
    }

    .sp-chat-auth p {
        font-size: 14px;
    }

    .sp-chat-input {
        padding: 14px 16px;
        font-size: 16px;
    }

    .sp-chat-submit {
        padding: 14px;
        font-size: 15px;
    }

    .sp-chat-empty {
        padding: 60px 24px;
        font-size: 14px;
    }

    .sp-chat-empty-icon {
        font-size: 42px;
    }

    .sp-chat-new-user input {
        font-size: 16px;
    }

    .sp-chat-auth-toggle {
        font-size: 14px;
    }
}

/* System notice between messages */
.sp-chat-notice {
    text-align: center;
    font-size: 11px;
    color: #9ca3af;
    padding: 8px 16px;
    font-style: italic;
}

/* Typing indicator */
.sp-typing-dots {
    display: flex;
    gap: 4px;
    align-items: center;
    padding: 8px 4px;
}
.sp-typing-dots span {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #999;
    animation: sp-typing 1.4s infinite ease-in-out;
}
.sp-typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.sp-typing-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes sp-typing {
    0%, 80%, 100% { opacity: 0.3; transform: scale(0.8); }
    40% { opacity: 1; transform: scale(1); }
}

/* FAQ details in messages */
.sp-chat-msg details { margin: 4px 0; cursor: pointer; }
.sp-chat-msg details summary { font-weight: 500; padding: 2px 0; }
.sp-chat-msg details summary:hover { color: #6366f1; }
.sp-chat-msg details div { padding: 4px 0 2px 12px; font-size: 0.9em; opacity: 0.9; }
