/* =========================================
   5. EL CHAT (MENSAJES Y HEADER)
   ========================================= */
#view-chat {
    position: relative;
    padding-right: 0 !important;
}

/* 1. Ajustamos el Header para que flote a la misma altura que el Sidebar */
.chat-header {
    position: absolute;
    top: 15px; /* 🔥 Antes estaba en 0 o 35px. 15px lo alinea con el Sidebar */
    left: 0;
    width: 100%;
    display: flex;
    justify-content: center;
    padding: 20px 0; 
    transition: opacity 0.3s ease, transform 0.3s ease;
    z-index: 15;
}

#view-chat.chat-scrolled .chat-header {
    opacity: 0;
    transform: translateY(-18px);
    pointer-events: none;
}

.header-pill {
    background-color: white; border-radius: 40px; padding: 20px 45px; 
    box-shadow: var(--shadow-soft); display: flex; align-items: center; gap: 15px; border: 1px solid var(--border-color);
}
.header-logo { width: 45px; height: 45px; object-fit: contain; } 
.header-wordmark { width: 270px; height: 54px; object-fit: contain; display: block; }
.header-logo.is-custom { border-radius: 14px; object-fit: cover; box-shadow: 0 10px 24px rgba(15, 23, 42, 0.14); }
.header-pill h1 { font-size: 2.2rem; font-weight: 800; color: #111; letter-spacing: -0.5px; }

.chat-corner-logo {
    position: absolute;
    top: 32px;
    right: 42px;
    width: 126px;
    height: 42px;
    object-fit: contain;
    z-index: 16;
    pointer-events: none;
    filter: drop-shadow(0 10px 18px rgba(15, 23, 42, 0.08));
}

/* 🔥 NUEVO: Contenedor del Mini Título */
.mini-header {
    position: absolute;
    top: 15px;
    left: 5px;
    display: flex;
    align-items: center;
    gap: 12px;
    font-weight: 800;
    font-size: 0.98rem;
    color: #101828;
    background: rgba(255, 255, 255, 0.96);
    padding: 13px 20px;
    border-radius: 40px;
    box-shadow: 0 14px 30px rgba(15, 23, 42, 0.08);
    border: 1px solid rgba(15, 23, 42, 0.08);
    opacity: 0;
    transform: translateY(-12px);
    transition: opacity 0.28s var(--apple-ease), transform 0.28s var(--apple-ease);
    z-index: 20;
    pointer-events: none;
}

.mini-header i {
    color: #111827;
}

.mini-header-avatar {
    width: 35px;
    height: 35px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(145deg, #111827, #1f2937);
    color: #ffffff;
    overflow: hidden;
    flex-shrink: 0;
}

.mini-header-avatar.has-image {
    background: #ffffff;
    border: 1px solid rgba(226, 232, 240, 0.9);
}

.mini-header-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.mini-header-wordmark {
    width: 96px;
    height: 24px;
    object-fit: contain;
    display: block;
}

#view-chat.chat-scrolled .mini-header {
    opacity: 1;
    transform: translateY(0);
}

.chat-container {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 154px 22px 158px 22px;
    width: 100%;
    max-width: 100%; 
    margin: 0 auto;
    display: flex;
    flex-direction: column;
}

.chat-container::-webkit-scrollbar { width: 6px; }
.chat-container::-webkit-scrollbar-track { background: transparent; }
.chat-container::-webkit-scrollbar-thumb { background-color: #d1d1d1; border-radius: 10px; }
.chat-container::-webkit-scrollbar-thumb:hover { background-color: #a8a8a8; }

@keyframes messageSlideIn { 0% { opacity: 0; transform: translateY(15px) scale(0.98); } 100% { opacity: 1; transform: translateY(0) scale(1); } }

/* 🔥 BURBUJAS DE CHAT CORREGIDAS 🔥 */
.message {
    display: flex;
    align-items: stretch !important;
    gap: 14px;
    width: 100%; 
    max-width: var(--chat-shell-width);
    margin: 0 auto 18px auto;
    animation: messageSlideIn 0.5s var(--apple-ease) forwards;
    box-sizing: border-box;
}

.avatar {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    margin-top: 0;
    border: 1px solid rgba(15, 23, 42, 0.08);
    box-shadow: 0 10px 20px rgba(15, 23, 42, 0.08);
}
.avatar.has-image {
    overflow: hidden;
    background: #ffffff;
}
.avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
.ia-avatar {
    background: linear-gradient(145deg, #1f2937, #111827);
    color: white;
}
.user-avatar {
    background: linear-gradient(180deg, #f8fafc, #eef2f7);
    color: #334155;
}

.message-content {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 18px;
    line-height: 1.62;
    font-size: 0.95rem;
    width: 100%;
    border-radius: var(--chat-bubble-radius);
    padding: 18px 20px;
    position: relative;
    overflow: hidden;
}

.bubble-copy {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.message.ia-message .bubble-copy {
    max-width: min(78ch, 100%);
}

.message.user-message .bubble-copy {
    max-width: min(76ch, 100%);
    margin-left: auto;
    align-items: flex-end;
    text-align: right;
}

.message-content p,
.table-intro-copy p {
    margin: 0;
}

.message-content p + p,
.table-intro-copy p + p {
    margin-top: 10px;
}

.message-content ul,
.message-content ol,
.table-intro-copy ul,
.table-intro-copy ol {
    margin: 10px 0 0;
    padding-left: 22px;
}

.message-content li + li,
.table-intro-copy li + li {
    margin-top: 6px;
}

.message-content strong,
.table-intro-copy strong {
    color: #0f172a;
    font-weight: 800;
}

.message.user-message .message-content strong {
    color: #ffffff;
}

.message-content code,
.table-intro-copy code {
    padding: 2px 7px;
    border-radius: 8px;
    background: #eef2ff;
    color: #1e293b;
    font-size: 0.88em;
}

.table-intro-copy {
    font-size: 0.95rem;
    color: #243042;
}

/* Burbuja IA */
.message.ia-message {
    flex-direction: row;
    justify-content: flex-start;
}

.message.ia-message .message-content {
    background: linear-gradient(180deg, #ffffff, #fdfefe);
    border: 1px solid rgba(226, 232, 240, 0.95);
    box-shadow: 0 14px 26px rgba(15, 23, 42, 0.055);
    color: #243042;
    width: 100%;
    max-width: none;
    align-items: flex-start;
    border-radius: var(--chat-bubble-radius) var(--chat-bubble-radius) var(--chat-bubble-radius) var(--chat-bubble-notch);
}

.message.thinking-message .message-content,
.message.thinking-message .thinking-stream {
    width: 100%;
    min-width: 0;
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    padding: 4px 0 2px !important;
    border-radius: 0 !important;
    overflow: visible !important;
}

.thinking-stream {
    display: grid;
    grid-template-columns: 42px minmax(0, 1fr);
    align-items: start;
    gap: 14px;
    width: 100%;
    padding: 6px 0 4px;
}

.message.thinking-message .bubble-copy,
.message.thinking-message .thinking-copy {
    flex: 1;
    min-width: 0;
    max-width: 100%;
    padding: 0 !important;
}

.message.thinking-message .avatar {
    margin-top: 4px;
}

.thinking-copy {
    flex: 1;
    min-width: 0;
    max-width: 100%;
    padding-left: 0;
}

.thinking-copy::before {
    display: none;
}

.thinking-label {
    display: inline-flex;
    align-items: center;
    width: fit-content;
    padding: 4px 9px;
    border-radius: 999px;
    background: #eef2ff;
    color: #334155;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.02em;
}

.thinking-meta-badges {
    display: inline-flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    margin-left: auto;
    flex-wrap: wrap;
}

.thinking-meta-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}

.thinking-phase-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 3px 9px;
    border-radius: 999px;
    background: rgba(15, 23, 42, 0.04);
    color: #64748b;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.01em;
}

.thinking-live-pill {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 3px 10px;
    border-radius: 999px;
    background: rgba(37, 99, 235, 0.08);
    color: #1d4ed8;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.01em;
}

.thinking-live-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: currentColor;
    animation: thinkingPulse 1.1s ease-in-out infinite;
}

.thinking-card {
    display: flex;
    flex-direction: column;
    gap: 10px;
    position: relative;
    padding: 14px 16px 13px 18px;
    border-radius: 18px;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.92), rgba(248, 250, 252, 0.82));
    border: 1px solid rgba(226, 232, 240, 0.9);
    box-shadow: 0 12px 24px rgba(15, 23, 42, 0.045);
    overflow: hidden;
}

.thinking-card::before {
    content: "";
    position: absolute;
    left: 0;
    top: 12px;
    bottom: 12px;
    width: 3px;
    border-radius: 999px;
    background: linear-gradient(180deg, rgba(148, 163, 184, 0.28), rgba(37, 99, 235, 0.9), rgba(148, 163, 184, 0.28));
}

.live-thinking-card {
    padding: 0;
}

.thinking-live-summary {
    list-style: none;
    cursor: pointer;
    min-height: 52px;
    padding: 14px 16px 13px 18px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
}

.thinking-live-summary::-webkit-details-marker {
    display: none;
}

.thinking-summary-main {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.thinking-live-body {
    display: grid;
    gap: 10px;
    padding: 0 16px 13px 18px;
}

.thinking-detail-list {
    margin: 0;
    padding: 2px 0 0;
    list-style: none;
    display: grid;
    gap: 8px;
}

.thinking-detail-step {
    display: grid;
    grid-template-columns: 10px 1fr;
    gap: 9px;
    align-items: start;
    color: #64748b;
    font-size: 0.82rem;
    line-height: 1.42;
}

.thinking-detail-step.is-active {
    color: #0f172a;
    font-weight: 700;
}

.thinking-detail-step.is-done {
    color: #475569;
}

.thinking-detail-dot {
    width: 8px;
    height: 8px;
    margin-top: 6px;
    border-radius: 50%;
    background: #cbd5e1;
}

.thinking-detail-step.is-active .thinking-detail-dot {
    background: #2563eb;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.13);
}

.thinking-detail-step.is-done .thinking-detail-dot {
    background: #22c55e;
}

.thinking-status-row {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 10px;
}

.thinking-status-text {
    display: block;
    font-size: 0.94rem;
    font-weight: 700;
    color: #0f172a;
    line-height: 1.45;
}

.thinking-helper-text {
    margin: 0;
    color: #64748b;
    font-size: 0.82rem;
    line-height: 1.5;
}

.thinking-progress-track {
    position: relative;
    overflow: hidden;
    height: 5px;
    border-radius: 999px;
    background: linear-gradient(90deg, #eef2f7 0%, #f8fafc 100%);
}

.thinking-progress-fill {
    position: absolute;
    inset: 0;
    width: 0;
    border-radius: inherit;
    background: linear-gradient(90deg, #0f172a, #334155 45%, #2563eb 100%);
    transition: width 0.32s ease;
}

.message.ia-message.has-data-table {
    width: 100%;
    max-width: var(--chat-shell-width);
}

.message.ia-message.has-data-table .message-content {
    width: 100%;
    display: block;
    position: relative;
}

.message.ia-message.has-data-table .avatar {
    position: absolute;
    top: 18px;
    left: 18px;
    z-index: 1;
}

.message.ia-message.has-data-table .bubble-copy {
    width: 100%;
    max-width: 100%;
    padding-left: 0;
}

.message.ia-message.has-data-table .table-answer-shell {
    width: 100%;
    align-items: stretch;
}

.message.ia-message.has-data-table .table-intro-copy {
    width: 100%;
    min-height: 42px;
    padding-left: 58px;
}

.message.ia-message.has-data-table .dynamic-table-container {
    width: 100%;
    margin: 18px auto 0;
}

/* Burbuja Usuario */
/* 4. BURBUJA DEL USUARIO (Avatar a la Derecha) */
.message.user-message {
    flex-direction: row;
    justify-content: flex-end;
}

.message.user-message .message-content {
    background: linear-gradient(145deg, #0f172a, #111827);
    color: #ffffff;
    box-shadow: 0 14px 24px rgba(15, 23, 42, 0.13);
    border: 1px solid rgba(15, 23, 42, 0.08);
    width: 100%;
    max-width: none;
    margin-left: 0;
    text-align: right;
    align-items: flex-start;
    border-radius: var(--chat-bubble-radius) var(--chat-bubble-radius) var(--chat-bubble-notch) var(--chat-bubble-radius);
}

.assistant-actions {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 10px;
    width: 100%;
    margin-top: 14px;
    padding-top: 12px;
    border-top: 1px solid rgba(226, 232, 240, 0.8);
}

.bubble-copy.is-typing {
    position: relative;
}

.typing-cursor {
    display: inline-block;
    width: 0.68ch;
    height: 1.05em;
    margin-left: 3px;
    border-radius: 3px;
    background: #0f172a;
    vertical-align: -0.14em;
    animation: typingCursorBlink 1s steps(1) infinite;
}

@keyframes typingCursorBlink {
    0%, 49% { opacity: 1; }
    50%, 100% { opacity: 0; }
}

.feedback-btn {
    width: 34px;
    height: 34px;
    border-radius: 999px;
    border: 1px solid rgba(226, 232, 240, 0.95);
    background: linear-gradient(180deg, #ffffff, #f8fafc);
    color: #64748b;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

.feedback-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 10px 18px rgba(15, 23, 42, 0.08);
}

.feedback-btn.is-active {
    color: #0f172a;
    border-color: #cbd5e1;
    box-shadow: inset 0 0 0 1px rgba(203, 213, 225, 0.85);
}

.feedback-btn.admin-trace-btn:hover { color: #0f766e; border-color: #0f766e; }
.feedback-btn.is-active:first-child { color: #15803d; }
.feedback-btn.is-active:last-child { color: #b91c1c; }

/* =========================================
   6. INPUT Y DIFUMINADO (FADE)
   ========================================= */
.chat-fade {
    position: absolute;
    bottom: 102px;
    left: 0;
    width: 100%;
    height: 82px;
    background: linear-gradient(to bottom, rgba(248, 250, 252, 0), rgba(248, 250, 252, 0.86), var(--bg-app));
    pointer-events: none; 
    z-index: 5;
}

.input-area {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    background: linear-gradient(to top, var(--bg-app) 62%, rgba(248, 250, 252, 0));
    padding: 6px 0 22px 0;
    z-index: 10;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.input-wrapper {
    position: relative;
    width: 100%;
    max-width: var(--chat-shell-width);
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(248, 250, 252, 0.96)) padding-box,
        linear-gradient(135deg, rgba(203, 213, 225, 0.9), rgba(96, 165, 250, 0.44), rgba(251, 191, 36, 0.42), rgba(226, 232, 240, 0.88)) border-box;
    backdrop-filter: blur(12px);
    border-radius: 26px;
    padding: 12px 10px 12px 18px;
    display: flex;
    align-items: flex-end;
    box-shadow:
        0 18px 34px rgba(15, 23, 42, 0.09),
        inset 0 1px 0 rgba(255, 255, 255, 0.9),
        inset 0 -14px 24px rgba(148, 163, 184, 0.08);
    border: 1px solid transparent;
    isolation: isolate;
    transition: box-shadow 0.4s var(--apple-ease), border-color 0.4s var(--apple-ease), background 0.4s ease;
}

.input-wrapper::before {
    content: "";
    position: absolute;
    top: 4px;
    left: 22px;
    right: 22px;
    height: 1px;
    border-radius: 999px;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.95), transparent);
    pointer-events: none;
    z-index: 0;
}

.input-wrapper > * {
    position: relative;
    z-index: 1;
}

.input-wrapper:focus-within {
    box-shadow:
        0 22px 42px rgba(37, 99, 235, 0.13),
        0 0 0 4px rgba(219, 234, 254, 0.48),
        inset 0 1px 0 rgba(255, 255, 255, 0.92),
        inset 0 -14px 24px rgba(59, 130, 246, 0.08);
    border-color: transparent;
}

.input-wrapper.is-expanded-composer {
    flex-wrap: wrap;
    align-items: center;
    row-gap: 6px;
    padding: 14px 10px 12px 18px;
}

.input-wrapper.is-expanded-composer #chat-input {
    order: 1;
    flex: 0 0 100%;
    width: 100%;
    min-height: 0;
    padding: 4px 4px 2px 0;
}

.input-wrapper.is-expanded-composer .keyword-help-btn {
    order: 2;
}

.input-wrapper.is-expanded-composer .chat-mode-dropdown {
    order: 3;
    margin-left: auto;
}

.input-wrapper.is-expanded-composer .send-btn {
    order: 4;
}

.chat-mode-dropdown summary {
    list-style: none;
}

.chat-mode-dropdown {
    order: 2;
}

.chat-mode-dropdown summary::-webkit-details-marker {
    display: none;
}

.chat-mode-trigger {
    height: 44px;
    border: none;
    border-radius: 10px;
    background: transparent;
    color: #6b7280;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 10px 0 8px;
    cursor: pointer;
    font-size: 0.86rem;
    font-weight: 500;
    box-shadow: none;
    user-select: none;
    transition: background 0.18s ease, color 0.18s ease;
}

.chat-mode-trigger .chat-mode-current i {
    display: none;
}

.chat-mode-current {
    display: inline-flex;
    align-items: center;
    gap: 0;
    white-space: nowrap;
    color: inherit;
}
.chat-mode-trigger:hover {
    background: #f3f4f6;
    color: #374151;
}

.chat-mode-dropdown[open] .chat-mode-trigger {
    background: #f3f4f6;
    color: #374151;
}
.chat-mode-chevron {
    font-size: 0.68rem;
    color: #9ca3af;
    transition: transform 0.18s ease;
}

.chat-mode-dropdown[open] .chat-mode-chevron {
    transform: rotate(180deg);
}

.chat-mode-menu {
    position: absolute;
    right: 0;
    bottom: calc(100% + 8px);
    width: 152px;
    padding: 6px;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.98);
    border: 1px solid #e5e7eb;
    box-shadow: 0 12px 30px rgba(15, 23, 42, 0.12);
    display: grid;
    gap: 4px;
}

.chat-mode-trigger::after {
    content: "";
    width: 7px;
    height: 7px;
    border-radius: 999px;
    background: #2563eb;
    display: inline-block;
    margin-left: 3px;
}

.chat-mode-option {
    width: 100%;
    min-height: 34px;
    border: 0;
    border-radius: 10px;
    background: transparent;
    color: #4b5563;
    padding: 0 10px;
    display: flex;
    align-items: center;
    gap: 8px;
    font: inherit;
    font-size: 0.84rem;
    font-weight: 500;
    cursor: pointer;
    text-align: left;
    transition: background 0.18s ease, color 0.18s ease;
}

.chat-mode-option:hover {
    background: #f3f4f6;
    color: #111827;
}

.chat-mode-option.active {
    background: #eef2f7;
    color: #111827;
}
.chat-mode-option.active i {
    color: #111827;
}

.chat-mode-option i {
    width: 14px;
    color: #9ca3af;
}

.keyword-help-btn {
    order: 0;
    width: 42px;
    height: 42px;
    margin: 0 10px 2px 0;
    border: 1px solid rgba(245, 158, 11, 0.28);
    border-radius: 42px;
    background:
        linear-gradient(145deg, #fffaf0, #fef3c7 58%, #fde68a);
    color: #b77900;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
    font-size: 0.95rem;
    box-shadow:
        0 10px 18px rgba(180, 120, 0, 0.08),
        inset 0 1px 0 rgba(255, 255, 255, 0.92),
        inset 0 -8px 14px rgba(217, 119, 6, 0.1);
    transition: transform 0.7s var(--apple-spring), background 0.4s ease, box-shadow 0.4s ease, color 0.4s ease, border-color 0.4s ease;
}

.keyword-help-btn:hover,
.keyword-help-btn.is-open {
    background:
        linear-gradient(145deg, #fff7d6, #fde68a 56%, #fbbf24);
    border-color: rgba(217, 119, 6, 0.34);
    color: #111827;
    transform: translateY(-1px);
    box-shadow:
        0 14px 24px rgba(180, 120, 0, 0.16),
        inset 0 1px 0 rgba(255, 255, 255, 0.78),
        inset 0 -9px 14px rgba(180, 83, 9, 0.12);
}

.keyword-help-popup[hidden] {
    display: none;
}

.keyword-help-popup {
    position: absolute;
    --keyword-help-width: min(860px, calc(100vw - 40px));
    left: calc((100% - var(--keyword-help-width)) / 2);
    bottom: calc(100% + 14px);
    width: var(--keyword-help-width);
    z-index: 90;
    opacity: 0;
    pointer-events: none;
    margin-bottom: -6px;
    transition: opacity 0.18s ease, margin-bottom 0.22s var(--apple-spring);
}

.keyword-help-popup.is-open {
    opacity: 1;
    pointer-events: auto;
    margin-bottom: 0;
}

.keyword-help-popup.is-closing {
    opacity: 0;
    pointer-events: none;
    margin-bottom: -5px;
}

.keyword-help-card {
    background: rgba(255, 255, 255, 0.98);
    border: 1px solid rgba(226, 232, 240, 0.96);
    border-radius: 22px;
    padding: 20px;
    box-shadow: 0 24px 52px rgba(15, 23, 42, 0.18);
    color: #1e293b;
    max-height: min(72vh, 680px);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.keyword-help-head {
    display: flex;
    gap: 12px;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 14px;
    flex-shrink: 0;
}

.keyword-help-title-block {
    display: flex;
    gap: 12px;
    align-items: flex-start;
    min-width: 0;
}

.keyword-help-icon {
    width: 34px;
    height: 34px;
    border-radius: 12px;
    background: #fff3c4;
    color: #b77900;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.keyword-help-brand {
    display: inline-flex;
    align-items: center;
    justify-content: flex-end;
    flex: 0 0 auto;
    min-width: 190px;
}

.keyword-help-brand img {
    display: block;
    width: 186px;
    height: auto;
    max-height: 42px;
    object-fit: contain;
}

.keyword-help-head h3 {
    margin: 0 0 4px;
    font-size: 1rem;
    line-height: 1.2;
    color: #0f172a;
}

.keyword-help-head p {
    margin: 0;
    color: #64748b;
    font-size: 0.86rem;
    line-height: 1.4;
}

.keyword-help-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding-right: 10px;
    margin-right: -6px;
    scrollbar-width: thin;
    scrollbar-color: rgba(100, 116, 139, 0.42) transparent;
}

.keyword-help-grid::-webkit-scrollbar {
    width: 6px;
}

.keyword-help-grid::-webkit-scrollbar-track {
    background: transparent;
}

.keyword-help-grid::-webkit-scrollbar-thumb {
    background: rgba(100, 116, 139, 0.38);
    border-radius: 999px;
}

.keyword-help-grid::-webkit-scrollbar-thumb:hover {
    background: rgba(71, 85, 105, 0.56);
}

.keyword-help-section {
    padding: 11px 12px;
    border-radius: 14px;
    background: #f8fafc;
    border: 1px solid #e8eef6;
}

.keyword-help-section span {
    display: block;
    margin-bottom: 5px;
    color: #475569;
    font-size: 0.74rem;
    font-weight: 800;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.keyword-help-section small {
    display: block;
    margin: 0 0 8px;
    color: #64748b;
    font-size: 0.78rem;
    line-height: 1.35;
    font-weight: 600;
}

.keyword-help-section p {
    margin: 0;
    color: #1e293b;
    font-size: 0.88rem;
    line-height: 1.45;
}

.keyword-help-section:last-child {
    grid-column: auto;
}

.keyword-help-empty {
    grid-column: 1 / -1;
    padding: 14px 16px;
    border-radius: 14px;
    border: 1px dashed #cbd5e1;
    color: #64748b;
    background: #f8fafc;
    font-size: 0.88rem;
    font-weight: 700;
    text-align: center;
}

body.dark-mode .keyword-help-btn {
    background: rgba(251, 191, 36, 0.14);
    color: #fbbf24;
    box-shadow: inset 0 0 0 1px rgba(251, 191, 36, 0.24);
}

body.dark-mode .keyword-help-btn:hover,
body.dark-mode .keyword-help-btn.is-open {
    background: #fbbf24;
    color: #111827;
}

body.dark-mode .keyword-help-card {
    background: rgba(15, 23, 42, 0.98);
    border-color: rgba(71, 85, 105, 0.76);
    color: #e5e7eb;
    box-shadow: 0 24px 52px rgba(0, 0, 0, 0.42);
}

body.dark-mode .keyword-help-icon {
    background: rgba(251, 191, 36, 0.16);
    color: #fbbf24;
}

body.dark-mode .keyword-help-head h3 {
    color: #f8fafc;
}

body.dark-mode .keyword-help-head p {
    color: #94a3b8;
}

body.dark-mode .keyword-help-section {
    background: rgba(30, 41, 59, 0.78);
    border-color: rgba(71, 85, 105, 0.7);
}

body.dark-mode .keyword-help-section span {
    color: #cbd5e1;
}

body.dark-mode .keyword-help-section small {
    color: #94a3b8;
}

body.dark-mode .keyword-help-section p {
    color: #e2e8f0;
}

body.dark-mode .keyword-help-empty {
    background: rgba(15, 23, 42, 0.92);
    border-color: rgba(148, 163, 184, 0.28);
    color: #cbd5e1;
}

body.dark-mode .keyword-help-grid {
    scrollbar-color: rgba(148, 163, 184, 0.38) transparent;
}

body.dark-mode .keyword-help-grid::-webkit-scrollbar-thumb {
    background: rgba(148, 163, 184, 0.34);
}

body.dark-mode .keyword-help-grid::-webkit-scrollbar-thumb:hover {
    background: rgba(203, 213, 225, 0.48);
}

@media (max-width: 720px) {
    .input-wrapper {
        flex-wrap: nowrap;
        align-items: center;
        padding: 10px;
    }

    .input-wrapper.is-expanded-composer {
        flex-wrap: wrap;
        row-gap: 6px;
    }

    #chat-input {
        order: initial;
        flex: 1;
        flex-basis: auto;
        padding: 8px 4px;
    }

    .input-wrapper.is-expanded-composer #chat-input {
        order: 1;
        flex-basis: 100%;
        width: 100%;
    }

    .chat-mode-dropdown {
    position: relative;
    align-self: center;
    flex-shrink: 0;
    margin-left: 8px;
    margin-right: 6px;
    z-index: 40;
    }

    .chat-mode-current span {
        display: none;
    }

    .chat-mode-trigger {
        width: 44px;
        min-width: 44px;
        height: 44px;
        padding: 0;
    }

    .chat-mode-chevron {
        display: none;
    }

    .send-btn {
        order: initial;
        margin-left: 0;
    }

    .keyword-help-btn {
        width: 42px;
        height: 42px;
        margin-right: 6px;
    }

    .keyword-help-popup {
        --keyword-help-width: min(560px, calc(100vw - 28px));
    }

    .keyword-help-grid {
        grid-template-columns: 1fr;
    }

    .keyword-help-brand {
        min-width: 150px;
    }

    .keyword-help-brand img {
        width: 146px;
        max-height: 34px;
    }

    .keyword-help-section:last-child {
        grid-column: auto;
    }
}

.chat-mode-option {
    border: 0;
    background: transparent;
    color: #64748b;
    border-radius: 999px;
    min-height: 34px;
    padding: 0 10px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font: inherit;
    font-size: 0.78rem;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.2s ease, color 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
}

.chat-mode-option:hover {
    color: #0f172a;
    transform: translateY(-1px);
}

.chat-mode-option.active {
    background: #ffffff;
    color: #0f172a;
    box-shadow: 0 6px 16px rgba(15, 23, 42, 0.1), inset 0 0 0 1px rgba(226, 232, 240, 0.95);
}

#chat-input {
    order: 1; flex: 1; border: none; outline: none; resize: none; padding: 12px 0;
    font-size: 0.97rem; font-family: inherit; min-height: 48px; max-height: 220px; background: transparent;
    color: #1e293b;
    line-height: 1.5;
    overflow-y: auto;
}

.send-btn {
    position: relative;
    order: 3;
    width: 46px; height: 46px; border-radius: 50%; background: linear-gradient(180deg, #ffffff, #f3f4f6); color: #0f172a;
    border: none; cursor: pointer; display: flex; align-items: center; justify-content: center;
    transition: transform 0.3s var(--apple-spring), background 0.3s ease, box-shadow 0.3s ease; flex-shrink: 0; font-size: 1rem;
    box-shadow: inset 0 0 0 1px rgba(226, 232, 240, 0.9);
}
.send-btn:hover {
    background: linear-gradient(180deg, #ffffff, #eef2f7);
    transform: translateY(-1px);
    box-shadow: 0 12px 20px rgba(15, 23, 42, 0.1), inset 0 0 0 1px rgba(226, 232, 240, 0.9);
}
.send-btn.is-loading {
    border-radius: 50%;
    background: linear-gradient(180deg, #f8fafc, #eef1f5);
    color: #050505;
    transform: none;
    box-shadow:
        0 10px 22px rgba(15, 23, 42, 0.1),
        inset 0 1px 0 rgba(255, 255, 255, 0.96),
        inset 0 -8px 14px rgba(148, 163, 184, 0.16);
    isolation: isolate;
    animation: none;
}
.send-btn.is-loading::before,
.send-btn.is-loading::after {
    display: none;
}
.send-btn.is-loading:hover {
    background: linear-gradient(180deg, #f8fafc, #eef1f5);
    transform: none;
}

@media (max-width: 720px) {
    .input-wrapper {
        flex-wrap: wrap;
        align-items: center;
        padding: 10px;
    }

    .chat-mode-selector {
        order: 1;
        width: calc(100% - 58px);
        margin-right: 8px;
        overflow-x: auto;
    }

    #chat-input {
        order: 3;
        flex-basis: 100%;
        padding: 8px 4px 4px;
    }

    .input-wrapper.is-expanded-composer #chat-input {
        order: 1;
        padding: 6px 4px 2px;
    }

    .send-btn {
        order: 2;
        margin-left: auto;
    }

    .keyword-help-btn {
        order: 2;
        margin-left: 0;
    }

}

.stop-loader {
    position: relative;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    box-shadow: none;
}

.stop-loader::before {
    display: none;
}

.stop-loader-core {
    width: 9px;
    height: 9px;
    border-radius: 2px;
    background: #050505;
    animation: none;
}

.input-disclaimer { font-size: 0.75rem; color: #94a3b8; text-align: center; margin-top: 12px; }

@keyframes thinkingPulse {
    0%, 100% { opacity: 0.35; transform: scale(0.9); }
    50% { opacity: 1; transform: scale(1); }
}

@keyframes thinkingSweep {
    100% { transform: translateX(100%); }
}

@keyframes stopButtonPulse {
    0%, 100% { box-shadow: 0 12px 24px rgba(15, 23, 42, 0.2); }
    50% { box-shadow: 0 14px 28px rgba(15, 23, 42, 0.28); }
}

@keyframes stopButtonAura {
    0%, 100% {
        box-shadow:
            0 0 0 7px rgba(37, 99, 235, 0.055),
            0 0 0 14px rgba(251, 191, 36, 0.03),
            0 16px 32px rgba(15, 23, 42, 0.22);
    }
    50% {
        box-shadow:
            0 0 0 10px rgba(37, 99, 235, 0.09),
            0 0 0 18px rgba(251, 191, 36, 0.05),
            0 18px 36px rgba(15, 23, 42, 0.28);
    }
}

@keyframes sendAuraOrbit {
    0%, 100% {
        transform: translate3d(0, 0, 0) rotate(0deg) scale(0.96);
        border-radius: 44% 56% 52% 48% / 48% 45% 55% 52%;
    }
    35% {
        transform: translate3d(1px, -2px, 0) rotate(92deg) scale(1.04);
        border-radius: 56% 44% 45% 55% / 52% 58% 42% 48%;
    }
    68% {
        transform: translate3d(-2px, 1px, 0) rotate(214deg) scale(1.01);
        border-radius: 49% 51% 60% 40% / 42% 48% 52% 58%;
    }
}

@keyframes stopHaloPulse {
    0%, 100% { opacity: 0.35; transform: scale(0.92); }
    50% { opacity: 0.8; transform: scale(1.08); }
}

@keyframes stopCoreBeat {
    0%, 100% { transform: scale(0.9); border-radius: 3px; }
    50% { transform: scale(1); border-radius: 4px; }
}


