.chat-experience-root,
.ai-chat-page,
.ai-login-page,
.ai-floating-panel {
    --admin-card: var(--bg-card, #161616);
    --admin-border: var(--border, #2a2a2a);
    --admin-text: var(--text-primary, #d4d4d4);
    --admin-muted: var(--text-secondary, #777777);
    --admin-accent: var(--accent-blue, #4a9eff);
}

.ai-login-page {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 460px;
    width: 100%;
}

.ai-login-card {
    width: min(560px, 100%);
    background: var(--admin-card);
    border: 1px solid var(--admin-border);
    border-radius: 12px;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
}

.ai-login-card h2 {
    margin: 0;
    font-size: 1.05rem;
}

.ai-login-card p {
    margin: 0;
    color: var(--admin-muted);
    font-size: 0.84rem;
}

.ai-login-step {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.4rem;
}

.ai-login-step label {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--admin-muted);
}

.ai-login-info {
    border: 1px solid rgba(214, 220, 229, 0.6);
    background: rgba(255, 255, 255, 0.08);
    color: var(--admin-text);
    border-radius: 8px;
    padding: 0.55rem 0.75rem;
    font-size: 0.8rem;
}

.ai-chat-page {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    width: 100%;
    max-width: 980px;
    margin: 0 auto;
    min-height: 0;
    height: 100%;
}

.ai-chat-auth {
    display: grid;
    grid-template-columns: auto 1fr auto auto;
    align-items: center;
    gap: 0.5rem;
}

.ai-chat-auth label {
    font-size: 0.8125rem;
    color: var(--admin-muted);
    font-weight: 600;
}

.ai-chat-jwt-input {
    border: 1px solid var(--admin-border);
    border-radius: 8px;
    background: var(--admin-card);
    color: var(--admin-text);
    padding: 0.45rem 0.65rem;
    font-size: 0.8125rem;
}

.ai-chat-btn {
    border: 1px solid var(--admin-border);
    border-radius: 8px;
    background: var(--admin-accent);
    color: #fff;
    padding: 0.45rem 0.7rem;
    font-size: 0.78rem;
    font-weight: 600;
}

.ai-chat-btn:disabled {
    opacity: 0.6;
}

.ai-chat-btn-ghost {
    background: transparent;
    color: var(--admin-text);
}

.ai-chat-tenant-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.ai-chat-switch-btn {
    border: 1px solid var(--admin-border);
    border-radius: 999px;
    background: var(--bg-elevated, #1a1a1a);
    color: var(--admin-text);
    padding: 0.2rem 0.55rem;
    font-size: 0.66rem;
    font-family: var(--font-mono, 'JetBrains Mono', monospace);
    font-weight: 600;
}

.ai-chat-pill {
    background: rgba(16, 185, 129, 0.12);
    color: #065f46;
    border: 1px solid rgba(16, 185, 129, 0.2);
    border-radius: 999px;
    padding: 0.2rem 0.55rem;
    font-size: 0.74rem;
    font-weight: 700;
}

.ai-chat-pill-readonly {
    background: rgba(245, 158, 11, 0.12);
    color: #92400e;
    border-color: rgba(245, 158, 11, 0.2);
}

.ai-chat-error {
    border: 1px solid var(--accent-red, #e85454);
    background: var(--accent-red-dim, #2b1414);
    color: var(--accent-red, #e85454);
    border-radius: 8px;
    padding: 0.55rem 0.75rem;
    font-size: 0.72rem;
    font-family: var(--font-mono, 'JetBrains Mono', monospace);
}

.ai-chat-suggestions {
    border: 1px solid var(--admin-border);
    border-radius: 10px;
    padding: 0.45rem 0.55rem;
    display: flex;
    align-items: center;
    gap: 0.45rem;
    flex-wrap: wrap;
    background: var(--bg-elevated, #1a1a1a);
}

.ai-chat-suggestions-label {
    font-size: 0.68rem;
    color: var(--admin-muted);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.ai-chat-suggestion-pill {
    border: 1px solid var(--admin-border);
    background: var(--bg-card, #161616);
    color: var(--admin-text);
    border-radius: 999px;
    font-size: 0.68rem;
    font-family: var(--font-mono, 'JetBrains Mono', monospace);
    line-height: 1.1;
    padding: 0.28rem 0.58rem;
    cursor: pointer;
}

/* Briefings & Communication group gets a subtle teal accent */
.ai-chat-suggestion-group:first-child .ai-chat-suggestion-pill {
    border-color: var(--accent-blue, #4a9eff);
    background: var(--accent-blue-dim, #141e2e);
}

.ai-chat-suggestion-pill:hover {
    border-color: var(--accent-blue, #4a9eff);
    color: var(--accent-blue, #4a9eff);
    background: var(--accent-blue-dim, #141e2e);
}

.ai-chat-download-notice {
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    border: 1px solid var(--accent-green, #3cba6f);
    background: var(--accent-green-dim, #162b1e);
    color: var(--accent-green, #3cba6f);
    border-radius: 8px;
    padding: 0.55rem 0.75rem;
    font-size: 0.8rem;
    animation: ai-chat-download-slide 220ms ease-out;
}

.ai-chat-download-check {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--accent-green, #3cba6f);
    color: var(--bg-deep, #0c0c0c);
    font-size: 0.76rem;
    font-weight: 700;
    animation: ai-chat-download-pop 280ms ease-out;
}

.ai-chat-download-text {
    position: relative;
    z-index: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ai-chat-download-progress {
    position: absolute;
    left: 0;
    bottom: 0;
    height: 2px;
    width: 100%;
    background: var(--accent-green, #3cba6f);
    transform-origin: left;
    animation: ai-chat-download-progress 2.8s linear forwards;
}

.ai-chat-messages {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    border: 1px solid var(--admin-border);
    border-radius: 12px;
    background: var(--admin-card);
    padding: 0.85rem;
    display: flex;
    flex-direction: column;
    gap: 0.7rem;
}

.ai-chat-empty {
    color: var(--admin-muted);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    gap: 0.4rem;
}

.ai-chat-msg {
    display: flex;
}

.ai-chat-msg.user {
    justify-content: flex-end;
}

.ai-chat-msg.assistant {
    flex-direction: column;
    align-items: flex-start;
}

.ai-chat-bubble {
    max-width: 82%;
    border-radius: 11px;
    padding: 0.6rem 0.75rem;
    font-size: 0.86rem;
    line-height: 1.45;
    border: 1px solid var(--admin-border);
    background: var(--admin-card);
    color: var(--admin-text);
}

.ai-chat-msg.user .ai-chat-bubble {
    white-space: pre-wrap;
    border-color: rgba(255, 255, 255, 0.2);
    background: rgba(58, 58, 58, 0.92);
    color: rgba(248, 250, 252, 0.96);
}

.ai-chat-user-wrap {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    max-width: min(85%, 820px);
    gap: 0.25rem;
}

.ai-chat-user-wrap .ai-chat-bubble {
    max-width: 100%;
}

/* Chat action pills are intentionally owned by this shipped stylesheet.
   Do not restyle these surfaces in isolated component CSS. */
.emma-actions.ai-chat-user-actions,
.ai-chat-msg.assistant .emma-actions,
.ai-floating-msg.assistant .emma-actions {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.4rem;
    padding: 0.15rem 0 0;
    margin: 0;
}

.emma-actions.ai-chat-user-actions {
    justify-content: flex-end;
    width: 100%;
}

.ai-chat-msg.assistant .emma-actions,
.ai-floating-msg.assistant .emma-actions {
    justify-content: flex-start;
}

.ai-chat-msg.assistant .emma-act,
.ai-floating-msg.assistant .emma-act,
.ai-chat-user-actions .emma-act,
.emma-actions.ai-chat-user-actions .emma-act {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    min-height: 28px;
    padding: 0.34rem 0.72rem 0.34rem 0.58rem;
    margin: 0;
    border-radius: 999px;
    border: 1px solid var(--admin-border);
    background: var(--bg-elevated, #1a1a1a);
    color: var(--admin-text);
    font-family: var(--font-mono, 'JetBrains Mono', monospace);
    font-size: 0.66rem;
    font-weight: 600;
    line-height: 1;
    white-space: nowrap;
    text-decoration: none;
    appearance: none;
    -webkit-appearance: none;
    box-shadow: none;
    cursor: pointer;
    transition: color 0.15s ease, background 0.15s ease, border-color 0.15s ease, transform 0.15s ease;
}

.emma-act-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 14px;
    height: 14px;
    flex-shrink: 0;
}

.emma-act-label {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.ai-chat-msg.assistant .emma-act:hover,
.ai-floating-msg.assistant .emma-act:hover,
.ai-chat-user-actions .emma-act:hover,
.emma-actions.ai-chat-user-actions .emma-act:hover {
    color: var(--accent-blue, #4a9eff);
    background: var(--accent-blue-dim, #141e2e);
    border-color: var(--accent-blue, #4a9eff);
    transform: translateY(-1px);
}

.ai-chat-msg.assistant .emma-act:active,
.ai-floating-msg.assistant .emma-act:active,
.ai-chat-user-actions .emma-act:active,
.emma-actions.ai-chat-user-actions .emma-act:active {
    transform: translateY(0);
}

.ai-chat-msg.assistant .emma-act:focus-visible,
.ai-floating-msg.assistant .emma-act:focus-visible,
.ai-chat-user-actions .emma-act:focus-visible,
.emma-actions.ai-chat-user-actions .emma-act:focus-visible {
    outline: 2px solid var(--accent-blue, #4a9eff);
    outline-offset: 1px;
}

.ai-chat-msg.assistant .emma-act:disabled,
.ai-floating-msg.assistant .emma-act:disabled,
.ai-chat-user-actions .emma-act:disabled,
.emma-actions.ai-chat-user-actions .emma-act:disabled {
    opacity: 0.6;
    pointer-events: none;
}

.ai-chat-msg.assistant .emma-act svg,
.ai-floating-msg.assistant .emma-act svg,
.ai-chat-user-actions .emma-act svg,
.emma-actions.ai-chat-user-actions .emma-act svg {
    width: 14px;
    height: 14px;
    display: block;
    flex-shrink: 0;
    stroke: currentColor;
    fill: none;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.ai-chat-msg.assistant .emma-act.email:hover,
.ai-floating-msg.assistant .emma-act.email:hover {
    color: #b8d2ff;
}

.ai-chat-msg.assistant .emma-act.slack:hover,
.ai-floating-msg.assistant .emma-act.slack:hover {
    color: #98f0bf;
}

.ai-chat-msg.assistant .emma-act.sms:hover,
.ai-floating-msg.assistant .emma-act.sms:hover {
    color: #ffd49c;
}

.ai-chat-msg.assistant .emma-act.copy:hover,
.ai-floating-msg.assistant .emma-act.copy:hover,
.ai-chat-user-actions .emma-act.copy:hover {
    color: #d5e5ff;
}

.ai-chat-user-actions .emma-act.edit:hover {
    color: #b8d2ff;
}

.ai-chat-msg.assistant .emma-act.busy,
.ai-floating-msg.assistant .emma-act.busy,
.ai-chat-user-actions .emma-act.busy {
    color: var(--admin-text);
    border-color: var(--admin-border);
}

.emma-act-spin {
    display: inline-block;
    width: 12px;
    height: 12px;
    border: 1.5px solid var(--border-subtle, #1f1f1f);
    border-top-color: var(--admin-text);
    border-radius: 50%;
    animation: emma-act-rotate 0.55s linear infinite;
    flex-shrink: 0;
}

@keyframes emma-act-rotate {
    to { transform: rotate(360deg); }
}

@media (max-width: 768px) {
    .emma-actions.ai-chat-user-actions,
    .ai-chat-msg.assistant .emma-actions,
    .ai-floating-msg.assistant .emma-actions {
        gap: 0.35rem;
    }

    .ai-chat-msg.assistant .emma-act,
    .ai-floating-msg.assistant .emma-act,
    .ai-chat-user-actions .emma-act,
    .emma-actions.ai-chat-user-actions .emma-act {
        min-height: 26px;
        font-size: 0.72rem;
        padding: 0.3rem 0.64rem 0.3rem 0.5rem;
    }
}

.ai-chat-msg.error .ai-chat-bubble {
    border-color: var(--accent-red, #e85454);
    background: var(--accent-red-dim, #2b1414);
    color: var(--accent-red, #e85454);
}

.ai-chat-streaming {
    opacity: 0.95;
    min-height: 2.2rem;
    display: inline-flex;
    align-items: center;
}

.ai-chat-typing {
    display: inline-flex;
    align-items: center;
    min-height: 1rem;
}

.ai-chat-status-label {
    display: block;
    font-size: 0.72rem;
    color: var(--admin-muted);
    margin-bottom: 0.45rem;
    letter-spacing: 0.02em;
}

/* ── Thinking trail (standalone) ── */
.ai-chat-thinking-trail {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    margin-bottom: 0.5rem;
    font-size: 0.75rem;
    font-family: var(--font-mono, 'JetBrains Mono', monospace);
    line-height: 1.4;
}

.ai-chat-thinking-step {
    display: flex;
    align-items: flex-start;
    gap: 0.4rem;
    color: var(--admin-text);
    animation: ai-thinking-fade-in 0.2s ease-out;
}

.ai-chat-thinking-icon {
    flex-shrink: 0;
    width: 1.1em;
    text-align: center;
    font-weight: 600;
}

.ai-chat-thinking-label {
    font-weight: 500;
}

.ai-chat-thinking-detail {
    color: rgba(148, 163, 184, 0.55);
    word-break: break-word;
    max-height: 3.6em;
    overflow: hidden;
}

.ai-chat-thinking-running .ai-chat-thinking-icon { color: var(--accent-blue, #4a9eff); }
.ai-chat-thinking-ok .ai-chat-thinking-icon { color: var(--accent-green, #3cba6f); }
.ai-chat-thinking-fail .ai-chat-thinking-icon { color: var(--accent-red, #e85454); }
.ai-chat-thinking-fail .ai-chat-thinking-label { color: var(--accent-red, #e85454); }
.ai-chat-thinking-reason .ai-chat-thinking-icon { color: var(--accent-purple, #a57aff); }

@keyframes ai-thinking-fade-in {
    from { opacity: 0; transform: translateY(-2px); }
    to { opacity: 1; transform: translateY(0); }
}

.ai-chat-rich {
    white-space: normal;
    word-break: break-word;
}

.ai-chat-rich p {
    margin: 0 0 0.45rem;
}

.ai-chat-rich p:last-child {
    margin-bottom: 0;
}

.ai-chat-rich ol,
.ai-chat-rich ul {
    margin: 0.3rem 0 0.45rem 1.1rem;
    padding: 0;
}

.ai-chat-rich ol:last-child,
.ai-chat-rich ul:last-child {
    margin-bottom: 0;
}

.ai-chat-rich li {
    margin: 0.18rem 0;
}

.ai-chat-rich li > p {
    margin-bottom: 0.15rem;
}

.ai-chat-rich h2,
.ai-chat-rich h3,
.ai-chat-rich h4 {
    margin: 0.55rem 0 0.25rem;
    line-height: 1.25;
    font-weight: 700;
}

.ai-chat-rich h2:first-child,
.ai-chat-rich h3:first-child,
.ai-chat-rich h4:first-child {
    margin-top: 0;
}

.ai-chat-rich h2 {
    font-size: 1.05rem;
}

.ai-chat-rich h3 {
    font-size: 0.95rem;
}

.ai-chat-rich h4 {
    font-size: 0.88rem;
}

.ai-chat-rich hr {
    border: none;
    border-top: 1px solid var(--admin-border);
    margin: 0.5rem 0;
}

.ai-chat-rich code {
    font-family: var(--font-mono, 'JetBrains Mono', monospace);
    font-size: 0.82em;
    background: var(--bg-elevated, #1a1a1a);
    border: 1px solid var(--admin-border);
    border-radius: 4px;
    padding: 0.12em 0.32em;
}

.ai-chat-rich pre {
    margin: 0.4rem 0;
    padding: 0.55rem 0.65rem;
    background: var(--bg-deep, #0c0c0c);
    border: 1px solid var(--border-subtle, #1f1f1f);
    border-radius: 8px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.ai-chat-rich pre:last-child {
    margin-bottom: 0;
}

.ai-chat-rich pre code {
    background: none;
    border: none;
    padding: 0;
    font-size: 0.8rem;
    line-height: 1.5;
    white-space: pre;
}

.ai-chat-rich .ai-md-table-wrap,
.ai-floating-rich .ai-md-table-wrap {
    margin: 0.4rem 0;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.ai-chat-rich .ai-md-table,
.ai-floating-rich .ai-md-table {
    width: 100%;
    min-width: 420px;
    border-collapse: collapse;
    border: 1px solid var(--admin-border);
    border-radius: 8px;
    overflow: hidden;
}

.ai-chat-rich .ai-md-table th,
.ai-chat-rich .ai-md-table td,
.ai-floating-rich .ai-md-table th,
.ai-floating-rich .ai-md-table td {
    border: 1px solid var(--admin-border);
    padding: 0.36rem 0.48rem;
    text-align: left;
    vertical-align: top;
}

.ai-chat-rich .ai-md-table th,
.ai-floating-rich .ai-md-table th {
    background: var(--bg-elevated, #1a1a1a);
    font-weight: 700;
}

.ai-chat-rich .ai-inline-image,
.ai-floating-rich .ai-inline-image {
    display: block;
    max-width: min(100%, 680px);
    height: auto;
    border-radius: 10px;
    border: 1px solid var(--admin-border);
    margin: 0.35rem 0;
    background: rgba(0, 0, 0, 0.03);
}

.ai-chat-dot {
    display: inline-block;
    width: 6px;
    height: 6px;
    margin-right: 4px;
    border-radius: 50%;
    background: var(--admin-muted);
    animation: ai-chat-pulse 1s infinite ease-in-out;
}

.ai-chat-dot:nth-child(2) {
    animation-delay: 0.2s;
}

.ai-chat-dot:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes ai-chat-pulse {
    0%, 80%, 100% { transform: scale(0.7); opacity: 0.4; }
    40% { transform: scale(1); opacity: 1; }
}

.ai-chat-artifacts {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.ai-chat-artifact-history-note {
    font-size: 0.74rem;
    color: rgba(255, 255, 255, 0.38);
    padding: 0.5rem 0.65rem;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 8px;
    position: relative;
    z-index: 1;
}

.ai-chat-artifact-btn {
    border: 1px solid var(--admin-border);
    border-radius: 8px;
    background: var(--admin-card);
    color: var(--admin-text);
    padding: 0.35rem 0.55rem;
    font-size: 0.78rem;
}

.ai-chat-chart-card {
    --card-glow: rgba(74, 158, 255, 0.04);
    background: linear-gradient(168deg, rgba(255, 255, 255, 0.025) 0%, var(--card-glow) 100%);
    border: 1px solid rgba(255, 255, 255, 0.07);
    border-radius: 14px;
    padding: 0.9rem 1rem 0.85rem;
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
    position: relative;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25),
                inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.ai-chat-chart-card::before {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(ellipse at 20% 0%, rgba(74, 158, 255, 0.06) 0%, transparent 55%);
    pointer-events: none;
}

.ai-chat-chart-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    user-select: none;
    list-style: none;
    padding: 0.1rem 0;
    position: relative;
    z-index: 1;
}

.ai-chat-chart-header::-webkit-details-marker {
    display: none;
}

.ai-chat-chart-header::marker {
    content: "";
}

.ai-chat-chart-title {
    font-size: 0.84rem;
    font-weight: 650;
    color: rgba(255, 255, 255, 0.92);
    letter-spacing: -0.005em;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ai-chat-chart-toggle {
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.6rem;
    color: rgba(255, 255, 255, 0.3);
    transition: transform 0.2s ease, color 0.15s ease;
    flex-shrink: 0;
    border-radius: 4px;
}

.ai-chat-chart-toggle::before {
    content: "\25BC";
}

.ai-chat-chart-header:hover .ai-chat-chart-toggle {
    color: rgba(255, 255, 255, 0.55);
}

.ai-chat-chart-card:not([open]) .ai-chat-chart-toggle {
    transform: rotate(-90deg);
}

.ai-chat-chart-subtitle {
    font-size: 0.74rem;
    color: rgba(255, 255, 255, 0.4);
    margin-top: -0.1rem;
    position: relative;
    z-index: 1;
}

.ai-chat-chart-canvas-wrap {
    position: relative;
    width: 100%;
    height: 280px;
    border-radius: 10px;
    background: rgba(0, 0, 0, 0.22);
    border: 1px solid rgba(255, 255, 255, 0.04);
    padding: 0.4rem 0.3rem 0.2rem;
    z-index: 1;
}

.ai-chat-chart-canvas-wrap canvas {
    width: 100% !important;
    height: 100% !important;
}

.ai-chat-table-wrap {
    max-height: 280px;
    overflow: auto;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.05);
    position: relative;
    z-index: 1;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.1) transparent;
}

.ai-chat-data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.78rem;
}

.ai-chat-data-table th {
    position: sticky;
    top: 0;
    z-index: 2;
    background: rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    padding: 0.45rem 0.6rem;
    text-align: left;
    font-weight: 600;
    font-size: 0.66rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: rgba(255, 255, 255, 0.5);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    white-space: nowrap;
}

.ai-chat-data-table td {
    padding: 0.4rem 0.6rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
    color: rgba(255, 255, 255, 0.78);
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

.ai-chat-data-table tbody tr {
    transition: background 0.12s ease;
}

.ai-chat-data-table tbody tr:hover {
    background: rgba(255, 255, 255, 0.03);
}

.ai-chat-chart-loading {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.76rem;
    color: rgba(255, 255, 255, 0.38);
    padding: 0.75rem 0.5rem;
    position: relative;
    z-index: 1;
}

.ai-chat-chart-error {
    font-size: 0.76rem;
    color: rgba(215, 95, 95, 0.75);
    padding: 0.55rem 0.6rem;
    background: rgba(215, 95, 95, 0.06);
    border: 1px solid rgba(215, 95, 95, 0.12);
    border-radius: 8px;
    position: relative;
    z-index: 1;
}

@keyframes ai-chat-download-slide {
    from { opacity: 0; transform: translateY(-4px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes ai-chat-download-pop {
    0% { transform: scale(0.6); }
    70% { transform: scale(1.08); }
    100% { transform: scale(1); }
}

@keyframes ai-chat-download-progress {
    from { transform: scaleX(1); }
    to { transform: scaleX(0); }
}

.ai-chat-input-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto auto;
    gap: 0.5rem;
    align-items: end;
}

.ai-chat-input {
    border: 1px solid var(--admin-border);
    border-radius: 8px;
    background: var(--admin-card);
    color: var(--admin-text);
    resize: none;
    overflow-x: hidden;
    overflow-y: auto;
    min-height: 48px;
    padding: 0.55rem 0.65rem;
    font-size: 0.8rem;
}

.ai-chat-send-btn {
    border: 1px solid var(--admin-border);
    border-radius: 8px;
    background: var(--bg-elevated, #1a1a1a);
    color: var(--admin-text);
    padding: 0 0.78rem;
    font-size: 0.66rem;
    font-family: var(--font-mono, 'JetBrains Mono', monospace);
    text-transform: uppercase;
    letter-spacing: 0.03em;
    font-weight: 600;
    min-height: 42px;
    height: 42px;
    min-width: 42px;
}

.ai-chat-send-btn:hover:not(:disabled) {
    border-color: var(--accent-blue, #4a9eff);
    color: var(--accent-blue, #4a9eff);
    background: var(--accent-blue-dim, #141e2e);
}

.ai-chat-voice-btn,
.ai-floating-voice-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    min-width: 42px;
    min-height: 42px;
    padding: 0;
    border: 1px solid var(--admin-border);
    border-radius: 8px;
    background: var(--bg-elevated, #1a1a1a);
    color: var(--admin-text);
}

.ai-chat-voice-btn:hover:not(:disabled),
.ai-floating-voice-btn:hover:not(:disabled) {
    border-color: var(--accent-blue, #4a9eff);
    color: var(--accent-blue, #4a9eff);
    background: var(--accent-blue-dim, #141e2e);
}

.ai-chat-voice-btn.recording,
.ai-floating-voice-btn.recording {
    border-color: var(--accent-red, #e85454);
    color: var(--accent-red, #e85454);
    background: var(--accent-red-dim, #2b1414);
}

.ai-chat-voice-btn:disabled,
.ai-floating-voice-btn:disabled {
    opacity: 0.5;
    pointer-events: none;
}

.emma-voice-icon {
    display: block;
    width: 16px;
    height: 16px;
}

.emma-voice-icon-active {
    width: 18px;
    height: 18px;
}

@media (max-width: 900px) {
    .ai-chat-page {
        height: 100%;
        min-height: 0;
    }

    .ai-chat-auth {
        grid-template-columns: 1fr;
    }

    .ai-chat-btn,
    .ai-chat-btn-ghost {
        width: fit-content;
    }
}

@media (max-width: 640px) {
    .ai-chat-bubble {
        max-width: 94%;
        font-size: 0.9rem;
        padding: 0.65rem 0.8rem;
    }

    .ai-chat-messages {
        padding: 0.6rem;
        gap: 0.6rem;
    }

    .ai-chat-input {
        font-size: 16px;
        min-height: 48px;
        padding: 0.6rem 0.7rem;
    }

    .ai-chat-send-btn {
        min-width: 48px;
        min-height: 48px;
        padding: 0 0.7rem;
    }

    .ai-chat-suggestion-pill {
        font-size: 0.8rem;
        padding: 0.4rem 0.7rem;
        min-height: 36px;
        display: inline-flex;
        align-items: center;
    }

    .ai-chat-suggestions {
        gap: 0.4rem;
        padding: 0.5rem 0.6rem;
    }

    .ai-chat-artifact-btn {
        min-height: 44px;
        font-size: 0.82rem;
        padding: 0.4rem 0.6rem;
    }

    .ai-chat-chart-canvas-wrap {
        height: 220px;
    }

    .ai-chat-download-notice {
        font-size: 0.82rem;
        padding: 0.6rem 0.75rem;
    }

    .ai-chat-rich .ai-md-table {
        min-width: 300px;
        font-size: 0.82rem;
    }

    .ai-chat-rich .ai-md-table th,
    .ai-chat-rich .ai-md-table td {
        padding: 0.4rem 0.5rem;
    }
}
