/* =============================================================================
   STAYSIGHT — Editorial AI assistant
   A refined, restrained interface for the AI bot FAB and off-canvas panel.
   ========================================================================== */

:root {
    /* Brand */
    --ai-violet: #6e00ff;
    --ai-violet-soft: #8b33ff;
    --ai-violet-deep: #5800cc;
    --ai-violet-wash: rgba(110, 0, 255, 0.08);
    --ai-violet-wash-strong: rgba(110, 0, 255, 0.14);

    /* Legacy aliases — kept so any third-party / older references still work */
    --purple-gradient-from: #7141fb;
    --purple-gradient-to: #6e00ff;
    --purple-light: #8b33ff;
    --purple-dark: #5800cc;

    /* V3 application palette */
    --ink-900: #273444;
    --ink-700: #3c4858;
    --ink-500: #525f7f;
    --ink-400: #8492a6;
    --ink-300: #aabacd;
    --ink-200: #c0ccda;

    --paper-0: #ffffff;
    --paper-50: #f8f8fb;
    --paper-100: #eff2f7;
    --paper-200: #e5e9f2;
    --paper-border: #eff2f7;
    --paper-border-strong: #e0e6ed;

    /* Accents */
    --warm-gold: #ffab00;
    --warm-gold-wash: rgba(255, 171, 0, 0.12);
    --success: #36b37e;
    --danger: #ff5630;

    /* Legacy variable aliases (some inherited rules still reference these) */
    --text-gray-900: var(--ink-900);
    --text-gray-700: var(--ink-700);
    --text-gray-600: var(--ink-500);
    --text-gray-500: var(--ink-400);
    --text-gray-400: var(--ink-300);
    --text-gray-300: var(--ink-200);
    --bg-gray-50: var(--paper-50);
    --border-gray-100: var(--paper-border);
    --border-gray-200: var(--paper-border-strong);
    --placeholder-color: #aabacd;

    /* Typography */
    --ai-bot-font-display: "Nunito", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --ai-bot-font-family: "Nunito", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --ai-bot-font-mono: SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;

    /* Motion */
    --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
    --ease-in-out: cubic-bezier(0.65, 0, 0.35, 1);
    --transition-fast: 0.15s var(--ease-out);
    --transition-normal: 0.26s var(--ease-out);

    /* Elevation */
    --ai-bot-panel-shadow: -20px 0 60px -24px rgba(31, 45, 61, 0.34), -1px 0 0 rgba(31, 45, 61, 0.04);
    --ai-bot-surface-shadow: 0 12px 30px -18px rgba(31, 45, 61, 0.22);
    --shadow-purple: 0 10px 30px -12px rgba(110, 0, 255, 0.42);
}

/* =============================================================================
   OVERLAY + PANEL FRAME
   ========================================================================== */

.ai-bot-overlay {
    position: fixed;
    inset: 0;
    background: rgba(12, 14, 18, 0.42);
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.22s var(--ease-out);
    z-index: 1050;
}

.ai-bot-overlay.show {
    opacity: 1;
    visibility: visible;
}

.ai-bot-panel {
    --ai-bot-base-width: min(62vw, 1080px);
    --ai-bot-history-width: 0px;
    position: fixed;
    top: 0;
    right: 0;
    width: calc(var(--ai-bot-base-width) + var(--ai-bot-history-width));
    max-width: 100vw;
    height: 100vh;
    background: var(--paper-50);
    border-left: 1px solid var(--paper-border);
    box-shadow: var(--ai-bot-panel-shadow);
    transform: translateX(100%);
    transition: transform 0.32s var(--ease-out), width 0.32s var(--ease-out);
    z-index: 1051;
    display: flex;
    flex-direction: column;
    font-family: var(--ai-bot-font-family);
    font-feature-settings: "ss01", "cv02", "cv11";
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
    color: var(--ink-700);
}

.ai-bot-panel.history-open {
    --ai-bot-history-width: 296px;
}

.ai-bot-panel.show {
    transform: translateX(0);
}

body.ai-bot-open {
    overflow: hidden;
}

.ai-bot-grain {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 0;
    opacity: 0.55;
    background-image:
        linear-gradient(180deg, rgba(255, 255, 255, 0.72), rgba(248, 248, 251, 0.88)),
        radial-gradient(circle at 100% 0%, rgba(110, 0, 255, 0.045) 0, transparent 34%);
}

.ai-bot-panel > .offcanvas-header,
.ai-bot-panel > .offcanvas-body {
    position: relative;
    z-index: 1;
}

/* =============================================================================
   TOPBAR
   ========================================================================== */

.ai-bot .offcanvas-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--paper-border);
    padding: 14px 22px;
    flex-shrink: 0;
    background: var(--paper-0);
}

.ai-bot .topbar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.ai-bot .brand-name {
    font-size: 14px;
    font-weight: 700;
    color: var(--ink-900);
    margin: 0;
    line-height: 1.05;
}

.ai-bot .brand-wordmark {
    letter-spacing: 0.14em;
    font-feature-settings: "ss01";
}

.ai-bot .brand-status {
    margin-top: 4px;
    display: flex;
    align-items: center;
    gap: 7px;
    font-size: 10.5px;
    color: var(--ink-400);
    letter-spacing: 0.01em;
}

.ai-bot .brand-status-label {
    font-variant-numeric: tabular-nums;
}

.ai-bot .status-dot {
    position: relative;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--success);
    box-shadow: 0 0 0 2px rgba(16, 153, 106, 0.16);
}

.ai-bot .status-dot::after {
    content: "";
    position: absolute;
    inset: -3px;
    border-radius: 50%;
    border: 1.5px solid rgba(16, 153, 106, 0.55);
    animation: ai-bot-status-pulse 2.6s ease-out infinite;
}

@keyframes ai-bot-status-pulse {
    0% { transform: scale(0.6); opacity: 0; }
    40% { opacity: 0.6; }
    100% { transform: scale(1.7); opacity: 0; }
}

.ai-bot .topbar-actions {
    display: flex;
    align-items: center;
    gap: 6px;
}

.ai-bot .topbar-divider {
    width: 1px;
    height: 18px;
    background: var(--paper-border-strong);
    margin: 0 4px;
}

.ai-bot .topbar-btn {
    border: 1px solid transparent;
    background: transparent;
    color: var(--ink-500);
    border-radius: 10px;
    transition: color var(--transition-fast),
                border-color var(--transition-fast),
                background var(--transition-fast),
                transform var(--transition-fast);
}

.ai-bot .topbar-btn.icon-only {
    width: 34px;
    height: 34px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
}

.ai-bot .topbar-btn:hover {
    color: var(--ink-900);
    background: rgba(12, 14, 18, 0.05);
    border-color: rgba(12, 14, 18, 0.06);
}

.ai-bot .topbar-btn.active {
    color: var(--ai-violet-deep);
    border-color: rgba(109, 74, 255, 0.25);
    background: var(--ai-violet-wash);
}

.ai-bot .topbar-btn--close:hover {
    color: var(--danger);
    background: rgba(219, 50, 50, 0.07);
    border-color: rgba(219, 50, 50, 0.18);
}

/* =============================================================================
   BODY LAYOUT
   ========================================================================== */

.ai-bot .offcanvas-body {
    flex: 1;
    display: flex;
    min-height: 0;
}

/* =============================================================================
   SESSION HISTORY SIDEBAR
   ========================================================================== */

.ai-bot .session-history {
    width: 296px;
    border-right: 1px solid var(--paper-border);
    background: linear-gradient(180deg, var(--paper-50) 0%, #f5f1e9 100%);
    padding: 18px 14px;
    display: none;
    flex-direction: column;
    gap: 14px;
    overflow-y: auto;
}

.ai-bot .session-history::-webkit-scrollbar { width: 6px; }
.ai-bot .session-history::-webkit-scrollbar-thumb { background: var(--paper-border-strong); border-radius: 999px; }

.ai-bot .session-history-mobile-header {
    display: none;
}

/* History search */
.ai-bot .session-history-search {
    position: relative;
    display: flex;
    align-items: center;
    flex-shrink: 0;
}

.ai-bot .session-history-search-icon {
    position: absolute;
    left: 11px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--ink-300);
    pointer-events: none;
}

.ai-bot .session-history-search-input {
    width: 100%;
    height: 34px;
    padding: 0 32px 0 32px;
    border: 1px solid var(--paper-border-strong);
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.7);
    font-family: var(--ai-bot-font-family);
    font-size: 12.5px;
    color: var(--ink-900);
    transition: border-color var(--transition-fast),
                background var(--transition-fast),
                box-shadow var(--transition-fast);
    appearance: none;
    -webkit-appearance: none;
}

.ai-bot .session-history-search-input::placeholder {
    color: var(--ink-300);
}

.ai-bot .session-history-search-input::-webkit-search-cancel-button { display: none; }

.ai-bot .session-history-search-input:focus {
    outline: none;
    border-color: var(--ai-violet-soft);
    background: var(--paper-0);
    box-shadow: 0 0 0 3px var(--ai-violet-wash);
}

.ai-bot .session-history-search-input:focus + .session-history-search-clear,
.ai-bot .session-history-search-input:not(:placeholder-shown) + .session-history-search-clear {
    color: var(--ink-500);
}

.ai-bot .session-history-search-clear {
    position: absolute;
    right: 6px;
    top: 50%;
    transform: translateY(-50%);
    width: 22px;
    height: 22px;
    border: 0;
    border-radius: 6px;
    background: transparent;
    color: var(--ink-300);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background var(--transition-fast), color var(--transition-fast);
}

.ai-bot .session-history-search-clear:hover {
    background: var(--paper-100);
    color: var(--ink-900);
}

.ai-bot .session-history-search-clear[hidden] {
    display: none;
}

.ai-bot .session-history-no-results {
    font-size: 12px;
    color: var(--ink-400);
    padding: 14px 12px;
    text-align: center;
    border: 1px dashed var(--paper-border-strong);
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.45);
}

.ai-bot .history-item.is-hidden,
.ai-bot .replay-item.is-hidden {
    display: none;
}

/* Inline rename input */
.ai-bot .history-item-title-input {
    width: 100%;
    border: 1px solid var(--ai-violet-soft);
    background: var(--paper-0);
    color: var(--ink-900);
    border-radius: 6px;
    padding: 3px 6px;
    font-family: var(--ai-bot-font-family);
    font-size: 13px;
    font-weight: 600;
    line-height: 1.2;
    box-shadow: 0 0 0 3px var(--ai-violet-wash);
}

.ai-bot .history-item-title-input:focus {
    outline: none;
}

.ai-bot .session-history-back {
    border: 1px solid var(--paper-border-strong);
    background: var(--paper-0);
    color: var(--ink-700);
    border-radius: 10px;
    min-height: 38px;
    padding: 0 12px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    font-size: 13px;
}

.ai-bot.history-open .session-history {
    display: flex;
}

.ai-bot .session-history-title {
    font-family: var(--ai-bot-font-family);
    font-size: 10.5px;
    text-transform: uppercase;
    letter-spacing: 0.14em;
    font-weight: 700;
    color: var(--ink-400);
    padding: 4px 6px 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.ai-bot .session-history-title::before {
    content: "";
    width: 12px;
    height: 1px;
    background: var(--paper-border-strong);
}

.ai-bot .session-history-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.ai-bot .session-history-empty {
    font-size: 12px;
    color: var(--ink-400);
    padding: 14px 12px;
    text-align: center;
    border: 1px dashed var(--paper-border-strong);
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.45);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
}

.ai-bot .session-history-empty-mark {
    font-size: 18px;
    color: var(--ai-violet-soft);
    letter-spacing: 0;
}

.ai-bot .history-item {
    width: 100%;
    border: 1px solid transparent;
    border-radius: 11px;
    background: transparent;
    padding: 10px 12px;
    text-align: left;
    transition: all var(--transition-fast);
    position: relative;
}

.ai-bot .history-item::before {
    content: "";
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%) scaleY(0);
    width: 2px;
    height: 60%;
    background: var(--ai-violet);
    border-radius: 0 2px 2px 0;
    transition: transform 0.18s var(--ease-out);
}

.ai-bot .history-item:hover {
    background: rgba(255, 255, 255, 0.6);
    border-color: var(--paper-border-strong);
}

.ai-bot .history-item.active {
    background: var(--paper-0);
    border-color: rgba(109, 74, 255, 0.25);
    box-shadow: 0 8px 22px -16px rgba(75, 37, 214, 0.3);
}

.ai-bot .history-item.active::before {
    transform: translateY(-50%) scaleY(1);
}

.ai-bot .history-item-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--ink-900);
    margin-bottom: 3px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    letter-spacing: -0.005em;
}

.ai-bot .history-item-meta {
    font-size: 11px;
    color: var(--ink-400);
    font-variant-numeric: tabular-nums;
}

/* =============================================================================
   CONTENT SHELL — INITIAL / EMPTY STATE
   ========================================================================== */

.ai-bot .ai-content-shell {
    flex: 1;
    min-width: 0;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

.ai-bot .initial-state,
.ai-bot .conversation-state {
    height: 100%;
    display: flex;
    flex-direction: column;
    padding: 22px 24px 16px;
    gap: 14px;
}

.ai-bot .initial-state {
    overflow: hidden;
}

.ai-bot .conversation-state {
    display: none;
    padding-top: 14px;
}

/* HERO — compact center stage on first open */
.ai-bot .initial-hero {
    text-align: center;
    padding: 2px 0 4px;
    flex-shrink: 0;
    animation: ai-bot-hero-rise 0.55s var(--ease-out) both;
}

@keyframes ai-bot-hero-rise {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

.ai-bot .logo-container {
    background: linear-gradient(50deg, #7141fb 0%, #6d05f6 44%, var(--ai-violet) 100%);
    border-radius: 13px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 14px 30px -14px rgba(75, 37, 214, 0.55),
                inset 0 1px 0 rgba(255, 255, 255, 0.25);
    color: #fff;
}

.ai-bot .logo-container.small {
    width: 32px;
    height: 32px;
    border-radius: 9px;
    margin: 0;
    box-shadow: 0 6px 14px -8px rgba(75, 37, 214, 0.55),
                inset 0 1px 0 rgba(255, 255, 255, 0.18);
}

.ai-bot .logo-container.small svg {
    width: 20px;
    height: 20px;
}

.ai-bot .initial-hero-mark {
    position: relative;
    width: 44px;
    height: 44px;
    margin: 0 auto 10px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.ai-bot .initial-hero-mark .logo-container {
    margin: 0;
    width: 44px;
    height: 44px;
    padding: 8px;
    position: relative;
    z-index: 2;
}

.ai-bot .initial-hero-mark .logo-container svg {
    width: 28px;
    height: 28px;
}

.ai-bot .brand-title {
    font-size: 22px;
    font-weight: 700;
    color: var(--ink-900);
    margin: 0 0 4px;
    line-height: 1.05;
    letter-spacing: 0;
    display: inline-flex;
    align-items: baseline;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: center;
}

.ai-bot .brand-title-serif {
    font-family: var(--ai-bot-font-family);
    font-style: normal;
    font-weight: 600;
    color: var(--ink-400);
    letter-spacing: 0;
}

.ai-bot .brand-title-mark {
    font-weight: 700;
    letter-spacing: 0.08em;
    color: var(--ink-900);
}

.ai-bot .subtitle {
    font-size: 14px;
    color: var(--ink-400);
    margin-bottom: 4px;
}

.ai-bot .description {
    font-size: 13px;
    color: var(--ink-400);
    line-height: 1.45;
    margin: 0 auto;
    max-width: 460px;
    letter-spacing: -0.005em;
}

/* SUGGESTED QUESTIONS — categorized 2-column grid (no scroll) */
.ai-bot .quick-questions-section {
    flex: 1;
    min-height: 0;
    overflow: hidden;
    margin: 0;
    padding: 0;
    animation: ai-bot-hero-rise 0.7s 0.05s var(--ease-out) both;
    display: flex;
    flex-direction: column;
}

.ai-bot .quick-questions-grid {
    display: flex;
    flex-direction: column;
    gap: 12px;
    flex: 1;
    min-height: 0;
}

.ai-bot .quick-questions-group {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 14px;
    background: var(--paper-0);
    border: 1px solid var(--paper-border-strong);
    border-radius: 8px;
    position: relative;
    transition: border-color var(--transition-fast), background var(--transition-fast), box-shadow var(--transition-fast);
}

.ai-bot .quick-questions-group:hover {
    border-color: rgba(110, 0, 255, 0.28);
    background: var(--paper-0);
    box-shadow: var(--ai-bot-surface-shadow);
}

.ai-bot .quick-questions-group-label {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 11px;
    font-weight: 700;
    color: var(--ink-700);
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.ai-bot .quick-questions-group-icon {
    width: 20px;
    height: 20px;
    border-radius: 7px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--ai-violet-wash);
    color: var(--ai-violet-deep);
}

.ai-bot .quick-questions-row {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
}

.ai-bot .question-btn {
    appearance: none;
    background: #fbfcff;
    border: 1px solid var(--paper-border-strong);
    border-radius: 7px;
    padding: 8px 12px;
    font-size: 13px;
    color: var(--ink-700);
    cursor: pointer;
    line-height: 1.35;
    letter-spacing: 0;
    text-align: left;
    width: 100%;
    min-width: 0;
    transition: border-color var(--transition-fast),
                color var(--transition-fast),
                background var(--transition-fast),
                transform var(--transition-fast),
                box-shadow var(--transition-fast);
    position: relative;
    white-space: normal;
    overflow-wrap: anywhere;
}

.ai-bot .question-btn:hover {
    border-color: rgba(110, 0, 255, 0.38);
    color: var(--ai-violet-deep);
    background: #ffffff;
    transform: translateY(-1px);
    box-shadow: 0 10px 22px -18px rgba(110, 0, 255, 0.42);
}

.ai-bot .question-btn:focus-visible {
    outline: 2px solid var(--ai-violet);
    outline-offset: 2px;
}

.ai-bot .divider {
    height: 1px;
    background: var(--paper-border-strong);
    margin: 0;
    flex-shrink: 0;
}

/* Wider panels — go to 3 columns within a category for richer density */
@media (min-width: 1100px) {
    .ai-bot .quick-questions-row {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

/* =============================================================================
   CONVERSATION
   ========================================================================== */

/* Chat scroll wrapper — holds messages + floating scroll-to-bottom */
.ai-bot .chat-scroll-wrap {
    flex: 1;
    min-height: 0;
    position: relative;
    display: flex;
    flex-direction: column;
    margin-bottom: 8px;
}

.ai-bot .chat-messages {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 6px 8px 6px 4px;
    scroll-behavior: smooth;
    position: relative;
}

.ai-bot .chat-scroll-to-bottom {
    position: absolute;
    bottom: 14px;
    left: 50%;
    transform: translateX(-50%) translateY(6px);
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 14px 7px 12px;
    background: var(--ink-900);
    color: #fff;
    border: 0;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.02em;
    cursor: pointer;
    opacity: 0;
    pointer-events: none;
    box-shadow: 0 12px 28px -10px rgba(12, 14, 18, 0.5),
                0 2px 0 rgba(255, 255, 255, 0.08) inset;
    transition: opacity 0.18s var(--ease-out),
                transform 0.18s var(--ease-out),
                background 0.18s var(--ease-out);
    z-index: 4;
}

.ai-bot .chat-scroll-to-bottom.is-visible {
    opacity: 1;
    pointer-events: auto;
    transform: translateX(-50%) translateY(0);
}

.ai-bot .chat-scroll-to-bottom:hover {
    background: var(--ai-violet-deep);
}

.ai-bot .chat-scroll-to-bottom[hidden] {
    display: none;
}

.ai-bot .chat-scroll-to-bottom-label {
    line-height: 1;
}

@media (max-width: 600px) {
    .ai-bot .chat-scroll-to-bottom-label { display: none; }
    .ai-bot .chat-scroll-to-bottom { padding: 8px 10px; }
}

.ai-bot .chat-messages::-webkit-scrollbar { width: 6px; }
.ai-bot .chat-messages::-webkit-scrollbar-thumb { background: var(--paper-border-strong); border-radius: 999px; }

.ai-bot .message {
    margin-bottom: 16px;
    display: flex;
    animation: ai-bot-message-in 0.32s var(--ease-out) both;
}

@keyframes ai-bot-message-in {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}

.ai-bot .message.user {
    justify-content: flex-end;
}

.ai-bot .message.assistant {
    justify-content: flex-start;
}

.ai-bot .message-avatar {
    width: 32px;
    height: 32px;
    border-radius: 10px;
    margin-right: 10px;
    margin-top: 2px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    background: linear-gradient(140deg, var(--ai-violet) 0%, var(--ai-violet-deep) 100%);
    box-shadow: 0 8px 18px -10px rgba(75, 37, 214, 0.55),
                inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

.ai-bot .message-content {
    max-width: min(88%, 760px);
    padding: 13px 16px;
    border-radius: 16px;
    font-size: 14px;
    line-height: 1.6;
    overflow-wrap: anywhere;
    letter-spacing: -0.005em;
}

.ai-bot .message.assistant .message-content:has(table),
.ai-bot .message.assistant .message-content:has(.ai-chart-container) {
    max-width: min(96%, 960px);
    padding: 18px;
}

.ai-bot .message.user .message-content {
    background: var(--ink-900);
    color: var(--paper-50);
    border-bottom-right-radius: 5px;
    box-shadow: 0 10px 24px -16px rgba(12, 14, 18, 0.4);
}

.ai-bot .message.assistant .message-content {
    background: var(--paper-0);
    border: 1px solid var(--paper-border);
    color: var(--ink-700);
    border-bottom-left-radius: 5px;
    box-shadow: 0 14px 32px -22px rgba(12, 14, 18, 0.18);
}

/* Typing indicator */
.ai-bot .typing-indicator { display: none; align-items: center; gap: 6px; padding: 4px 0; }
.ai-bot .typing-indicator.show { display: flex; }
.ai-bot .typing-dot {
    width: 7px;
    height: 7px;
    background: var(--ai-violet-soft);
    border-radius: 50%;
    animation: ai-bot-typing 1.2s infinite ease-in-out;
}
.ai-bot .typing-dot:nth-child(2) { animation-delay: 0.15s; }
.ai-bot .typing-dot:nth-child(3) { animation-delay: 0.3s; }
@keyframes ai-bot-typing {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.35; }
    30% { transform: translateY(-6px); opacity: 1; }
}

/* =============================================================================
   COMPOSER (input section)
   ========================================================================== */

.ai-bot .input-section {
    margin-top: auto;
    padding-top: 14px;
    background: transparent;
}

.ai-bot .input-section.initial {
    border-top: none;
    padding-top: 0;
}

.ai-bot .conversation-state .input-section {
    border-top: 1px solid var(--paper-border);
}

.ai-bot .input-container {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-height: 118px;
    padding: 13px 13px 11px;
    background: var(--paper-0);
    border: 1px solid var(--paper-border-strong);
    border-radius: 8px;
    box-shadow: 0 16px 34px -28px rgba(31, 45, 61, 0.38),
                0 1px 2px rgba(31, 45, 61, 0.04);
    transition: border-color var(--transition-fast),
                box-shadow var(--transition-fast),
                background var(--transition-fast);
}

.ai-bot .input-container:focus-within {
    border-color: rgba(110, 0, 255, 0.5);
    box-shadow: inset 0 1px 1px rgba(31, 45, 61, 0.075),
                0 0 20px rgba(110, 0, 255, 0.1),
                0 18px 38px -26px rgba(110, 0, 255, 0.32);
}

.ai-bot .input-container.drag-over {
    border-color: var(--ai-violet);
    background: linear-gradient(180deg, rgba(109, 74, 255, 0.03), var(--paper-0));
    box-shadow: 0 0 0 4px var(--ai-violet-wash-strong),
                0 18px 44px -22px rgba(75, 37, 214, 0.35);
}

.ai-bot .message-input {
    width: 100%;
    min-height: 54px;
    overflow-y: auto;
    padding: 4px 4px;
    background: transparent;
    border: 0;
    border-radius: 0;
    resize: none;
    font-family: var(--ai-bot-font-family);
    font-size: 14px;
    color: var(--ink-900);
    line-height: 1.55;
    letter-spacing: 0;
}

.ai-bot .message-input:focus {
    outline: none;
}

.ai-bot .message-input::placeholder {
    color: var(--placeholder-color);
    font-style: normal;
    font-family: var(--ai-bot-font-family);
    font-size: 14px;
}

.ai-bot .ai-bot-composer-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 38px;
}

.ai-bot .ai-bot-composer-spacer {
    flex: 1;
    display: flex;
    align-items: center;
    min-width: 0;
}

.ai-bot .ai-bot-composer-hint {
    font-size: 11px;
    color: var(--ink-300);
    display: inline-flex;
    align-items: center;
    gap: 4px;
    letter-spacing: 0.02em;
    opacity: 0;
    transform: translateY(2px);
    transition: opacity var(--transition-fast), transform var(--transition-fast);
    pointer-events: none;
}

.ai-bot .input-container:focus-within .ai-bot-composer-hint {
    opacity: 1;
    transform: translateY(0);
}

.ai-bot .ai-bot-composer-hint kbd {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 16px;
    height: 16px;
    padding: 0 4px;
    margin: 0 2px;
    background: var(--paper-50);
    border: 1px solid var(--paper-border-strong);
    border-radius: 4px;
    font-family: var(--ai-bot-font-mono);
    font-size: 10px;
    color: var(--ink-500);
    box-shadow: 0 1px 0 rgba(12, 14, 18, 0.06);
}

.ai-bot .ai-bot-composer-hint-sep {
    margin: 0 4px;
    color: var(--ink-200);
}

@media (max-width: 600px) {
    .ai-bot .ai-bot-composer-hint { display: none; }
}

.ai-bot .ai-bot-attach-btn {
    width: 34px;
    height: 34px;
    border: 1px solid transparent;
    border-radius: 7px;
    background: transparent;
    color: var(--ink-400);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 14px;
    transition: background var(--transition-fast),
                color var(--transition-fast),
                border-color var(--transition-fast);
}

.ai-bot .ai-bot-attach-btn:hover {
    background: var(--paper-50);
    color: var(--ink-900);
    border-color: var(--paper-border);
}

.ai-bot .ai-bot-attachment-tray {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.ai-bot .ai-bot-attachment-tray[hidden] {
    display: none;
}

.ai-bot .ai-bot-attachment-chip {
    max-width: 100%;
    display: inline-flex;
    align-items: center;
    gap: 7px;
    height: 28px;
    padding: 0 4px 0 10px;
    border: 1px solid var(--paper-border-strong);
    border-radius: 999px;
    background: var(--paper-50);
    color: var(--ink-700);
    font-size: 12px;
    line-height: 1;
}

.ai-bot .ai-bot-attachment-chip span {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ai-bot .ai-bot-attachment-remove {
    width: 20px;
    height: 20px;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: var(--ink-400);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    padding: 0;
    font-size: 12px;
}

.ai-bot .ai-bot-attachment-remove:hover {
    background: var(--paper-200);
    color: var(--ink-900);
}

.ai-bot .send-button {
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 8px;
    background: var(--ink-900);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--paper-0);
    transition: background var(--transition-fast),
                transform var(--transition-fast),
                box-shadow var(--transition-fast);
    box-shadow: 0 8px 20px -10px rgba(12, 14, 18, 0.4),
                inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.ai-bot .send-button:hover,
.ai-bot .send-button.active {
    background: var(--ai-violet);
    transform: translateY(-1px);
    box-shadow: 0 12px 24px -10px rgba(75, 37, 214, 0.55),
                inset 0 1px 0 rgba(255, 255, 255, 0.15);
}

.ai-bot .send-button:active {
    transform: translateY(0);
}

.ai-bot .send-icon { width: 20px; height: 20px; color: currentColor; }

.ai-bot .powered-by {
    margin-top: 10px;
    text-align: center;
    color: var(--ink-300);
    font-size: 10.5px;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    width: 100%;
}

.ai-bot .powered-by-dot {
    width: 3px;
    height: 3px;
    border-radius: 50%;
    background: var(--warm-gold);
}

.ai-bot .suggested-actions {
    display: flex;
    gap: 8px;
    margin-bottom: 10px;
    flex-wrap: wrap;
}

.ai-bot .suggested-action {
    padding: 7px 13px;
    border-radius: 999px;
    border: 1px solid var(--paper-border-strong);
    background: var(--paper-0);
    font-size: 12px;
    color: var(--ink-500);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.ai-bot .suggested-action:hover {
    border-color: var(--ai-violet-soft);
    color: var(--ai-violet-deep);
    background: var(--ai-violet-wash);
}

/* =============================================================================
   ASSISTANT MESSAGE CONTENT (markdown rendering)
   ========================================================================== */

.ai-bot .message-content h1,
.ai-bot .message-content h2,
.ai-bot .message-content h3,
.ai-bot .message-content h4 {
    color: var(--ink-900);
    line-height: 1.3;
    margin: 0 0 8px;
    font-weight: 700;
    letter-spacing: -0.012em;
}
.ai-bot .message-content h1 { font-size: 1.22rem; }
.ai-bot .message-content h2 { font-size: 1.08rem; }
.ai-bot .message-content h3 { font-size: 0.98rem; }
.ai-bot .message-content p { margin: 0 0 8px; }
.ai-bot .message-content p:has(+ table),
.ai-bot .message-content p:has(+ .ai-chart-container) {
    margin-bottom: 12px;
}
.ai-bot .message-content strong { font-weight: 700; color: var(--ink-900); }
.ai-bot .message-content ul,
.ai-bot .message-content ol { margin: 0 0 8px 18px; padding: 0; }
.ai-bot .message-content li { margin-bottom: 4px; }
.ai-bot .message-content code {
    background: var(--paper-50);
    border: 1px solid var(--paper-border-strong);
    border-radius: 6px;
    padding: 1px 6px;
    font-family: var(--ai-bot-font-mono);
    font-size: 0.85em;
    color: var(--ai-violet-deep);
}
.ai-bot .message-content pre {
    background: var(--ink-900);
    color: #e8eaf0;
    border-radius: 12px;
    padding: 14px 16px;
    overflow-x: auto;
    margin: 0 0 12px;
    font-family: var(--ai-bot-font-mono);
    font-size: 12.5px;
    line-height: 1.6;
}
.ai-bot .message-content pre code {
    background: transparent;
    border: 0;
    color: inherit;
    padding: 0;
}

/* Tables */
.ai-bot .message-content table {
    width: max-content;
    min-width: 100%;
    margin: 10px 0 14px;
    border: 1px solid var(--paper-border);
    border-radius: 12px;
    border-spacing: 0;
    border-collapse: separate;
    overflow: hidden;
    background: var(--paper-0);
    box-shadow: 0 1px 2px rgba(12, 14, 18, 0.04);
    font-size: 13px;
    line-height: 1.4;
}

.ai-bot .message-content:has(table) {
    overflow: visible;
    scrollbar-width: thin;
    scrollbar-color: var(--paper-border-strong) transparent;
}

.ai-bot .message-content:has(table)::-webkit-scrollbar { height: 8px; }
.ai-bot .message-content:has(table)::-webkit-scrollbar-thumb {
    background: var(--paper-border-strong);
    border-radius: 999px;
}

.ai-bot .message-content thead th {
    position: sticky;
    top: 0;
    z-index: 1;
    background: linear-gradient(180deg, var(--paper-50) 0%, var(--paper-100) 100%);
    color: var(--ink-900);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    white-space: nowrap;
    border-bottom: 1px solid var(--paper-border-strong);
}

.ai-bot .message-content th,
.ai-bot .message-content td {
    padding: 11px 14px;
    border-bottom: 1px solid var(--paper-border);
    vertical-align: middle;
}

.ai-bot .message-content th:not(:first-child),
.ai-bot .message-content td:not(:first-child) {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.ai-bot .message-content tbody tr:last-child td {
    border-bottom: 0;
}

.ai-bot .message-content tbody tr:nth-child(even) td {
    background: var(--paper-50);
}

.ai-bot .message-content tbody tr:hover td {
    background: var(--ai-violet-wash);
}

.ai-bot .message-content td:first-child,
.ai-bot .message-content th:first-child {
    padding-left: 16px;
}

.ai-bot .message-content td:last-child,
.ai-bot .message-content th:last-child {
    padding-right: 16px;
}

.ai-bot .message-content table .ai-record-link {
    font-weight: 700;
    text-decoration-thickness: 1.5px;
}

.ai-bot .ai-record-link {
    appearance: none;
    border: 0;
    background: transparent;
    color: var(--ai-violet-deep);
    cursor: pointer;
    display: inline;
    font: inherit;
    font-weight: 700;
    padding: 0;
    text-decoration: underline;
    text-decoration-thickness: 1px;
    text-underline-offset: 2px;
}

.ai-bot .ai-record-link:hover { color: var(--ai-violet); }

/* Auto-prefixed report / portal links. The renderer absolutizes the href
   to the current account origin and forces target=_blank. */
.ai-bot .message-content a.ai-bot-link {
    color: var(--ai-violet-deep);
    font-weight: 600;
    text-decoration: underline;
    text-decoration-thickness: 1px;
    text-underline-offset: 2.5px;
    text-decoration-color: rgba(75, 37, 214, 0.35);
    transition: color var(--transition-fast),
                text-decoration-color var(--transition-fast),
                background var(--transition-fast);
    border-radius: 3px;
    padding: 0 1px;
}

.ai-bot .message-content a.ai-bot-link:hover {
    color: var(--ai-violet);
    text-decoration-color: var(--ai-violet);
    background: var(--ai-violet-wash);
}

/* External-link glyph on absolute https?:// links to signal "opens in new tab". */
.ai-bot .message-content a.ai-bot-link[target="_blank"]::after {
    content: "↗";
    display: inline-block;
    margin-left: 2px;
    font-size: 0.85em;
    opacity: 0.55;
    transition: opacity var(--transition-fast), transform var(--transition-fast);
}

.ai-bot .message-content a.ai-bot-link[target="_blank"]:hover::after {
    opacity: 1;
    transform: translate(1px, -1px);
}

/* Autolinked report/portal references → a compact pill so they read as
   "the thing you can click" rather than inline prose. */
.ai-bot .message-content a.ai-bot-link--autolinked {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    background: var(--ai-violet-wash);
    color: var(--ai-violet-deep);
    padding: 2px 9px 2px 8px;
    border: 1px solid rgba(109, 74, 255, 0.25);
    border-radius: 999px;
    font-weight: 600;
    font-size: 0.92em;
    text-decoration: none;
    line-height: 1.4;
    white-space: nowrap;
    vertical-align: baseline;
}

.ai-bot .message-content a.ai-bot-link--autolinked::before {
    content: "";
    width: 13px;
    height: 13px;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%234b25d6' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'><path d='M2 13h12M3.5 13V7.5M7 13V4M10.5 13V8.5M14 13V5.5'/></svg>");
    background-repeat: no-repeat;
    background-position: center;
    background-size: contain;
    flex-shrink: 0;
}

.ai-bot .message-content a.ai-bot-link--autolinked:hover {
    background: var(--ai-violet-wash-strong);
    color: var(--ai-violet-deep);
    border-color: var(--ai-violet-soft);
    text-decoration: none;
}

/* The external-tab arrow is decorative chrome for plain anchors; suppress it
   inside the autolinked pill since the chart-icon already says "go look". */
.ai-bot .message-content a.ai-bot-link--autolinked[target="_blank"]::after {
    content: none;
}

/* =============================================================================
   ERROR STATE
   ========================================================================== */

.ai-bot .chat-messages { position: relative; }

.ai-bot .ai-error-overlay {
    position: absolute;
    inset: 0;
    background: rgba(250, 248, 244, 0.92);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    border-radius: 12px;
    z-index: 5;
}

.ai-bot .ai-error-state {
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    gap: 12px;
    padding: 24px;
}

.ai-bot .ai-error-title {
    font-size: 17px;
    font-weight: 700;
    color: var(--ink-900);
    letter-spacing: -0.012em;
}

.ai-bot .ai-error-description {
    font-size: 13px;
    color: var(--ink-400);
    max-width: 320px;
    line-height: 1.5;
}

.ai-bot .ai-error-retry-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    border: none;
    border-radius: 11px;
    padding: 10px 16px;
    color: #fff;
    background: var(--ink-900);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: background var(--transition-fast), transform var(--transition-fast);
}

.ai-bot .ai-error-retry-btn:hover {
    background: var(--ai-violet-deep);
    transform: translateY(-1px);
}

/* =============================================================================
   FAB (floating action button)
   ========================================================================== */

.ai-bot-fab {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 58px;
    height: 58px;
    background: var(--ink-900);
    border-radius: 18px;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1060;
    color: #fff;
    box-shadow: 0 14px 28px -12px rgba(12, 14, 18, 0.55),
                0 4px 10px -4px rgba(12, 14, 18, 0.3),
                inset 0 1px 0 rgba(255, 255, 255, 0.08);
    transition: transform 0.24s var(--ease-out),
                box-shadow 0.24s var(--ease-out),
                background 0.24s var(--ease-out);
    overflow: visible;
}

.ai-bot-fab::before {
    content: "";
    position: absolute;
    inset: 1px;
    border-radius: 17px;
    background:
        radial-gradient(120% 80% at 30% 0%, rgba(109, 74, 255, 0.45) 0%, transparent 60%),
        linear-gradient(160deg, rgba(255, 255, 255, 0.04) 0%, rgba(0, 0, 0, 0.2) 100%);
    pointer-events: none;
    z-index: 0;
}

.ai-bot-fab:hover {
    transform: translateY(-2px) scale(1.03);
    box-shadow: 0 20px 38px -10px rgba(75, 37, 214, 0.55),
                0 8px 14px -4px rgba(12, 14, 18, 0.35),
                inset 0 1px 0 rgba(255, 255, 255, 0.12);
    background: var(--ai-violet-deep);
}

.ai-bot-fab:active {
    transform: translateY(0) scale(0.98);
}

.ai-bot-fab.hide { opacity: 0; pointer-events: none; transform: translateY(10px) scale(0.9); }

.ai-bot-fab-icon {
    position: relative;
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Ambient breathing rings — signal that AI is "listening" */
.ai-bot-fab-ring {
    position: absolute;
    inset: -4px;
    border-radius: 22px;
    border: 1.5px solid var(--ai-violet);
    opacity: 0;
    pointer-events: none;
    z-index: 0;
    animation: ai-bot-fab-breath 4s ease-out infinite;
}

.ai-bot-fab-ring--delayed {
    animation-delay: 2s;
}

@keyframes ai-bot-fab-breath {
    0% { transform: scale(0.85); opacity: 0; }
    40% { opacity: 0.55; }
    100% { transform: scale(1.4); opacity: 0; }
}

.ai-bot-fab-tooltip {
    position: absolute;
    right: calc(100% + 14px);
    top: 50%;
    transform: translateY(-50%) translateX(6px);
    background: var(--ink-900);
    color: var(--paper-50);
    padding: 9px 14px;
    border-radius: 10px;
    font-size: 12px;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.18s var(--ease-out), transform 0.18s var(--ease-out), visibility 0.18s var(--ease-out);
    display: flex;
    flex-direction: column;
    line-height: 1.2;
    box-shadow: 0 14px 28px -12px rgba(12, 14, 18, 0.5);
    pointer-events: none;
}

.ai-bot-fab-tooltip-kicker {
    font-size: 9.5px;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--ink-300);
    font-weight: 600;
}

.ai-bot-fab-tooltip-name {
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 0.06em;
    margin-top: 1px;
}

.ai-bot-fab-tooltip-arrow {
    position: absolute;
    right: -5px;
    top: 50%;
    transform: translateY(-50%) rotate(45deg);
    width: 10px;
    height: 10px;
    background: var(--ink-900);
}

.ai-bot-fab:hover .ai-bot-fab-tooltip {
    opacity: 1;
    visibility: visible;
    transform: translateY(-50%) translateX(0);
}

.ai-bot-fab-notification {
    position: absolute;
    top: 5px;
    right: 5px;
    width: 11px;
    height: 11px;
    border: 2px solid var(--ink-900);
    border-radius: 50%;
    background: var(--warm-gold);
    display: none;
    z-index: 3;
}

.ai-bot-fab-notification.active {
    display: block;
    animation: ai-bot-fab-notif 2.4s ease-out infinite;
}

@keyframes ai-bot-fab-notif {
    0%, 100% { box-shadow: 0 0 0 0 rgba(181, 131, 43, 0.5); }
    50% { box-shadow: 0 0 0 6px rgba(181, 131, 43, 0); }
}

/* =============================================================================
   RESPONSIVE
   ========================================================================== */

@media (max-width: 1200px) {
    .ai-bot-panel { width: min(72vw, 1080px); }
}

@media (max-width: 992px) {
    .ai-bot-panel,
    .ai-bot-panel.history-open {
        --ai-bot-history-width: 0px;
        width: 100vw;
        max-width: 100vw;
    }

    .ai-bot .quick-questions-grid {
        gap: 12px;
    }

    .ai-bot .offcanvas-body {
        position: relative;
        overflow: hidden;
    }

    .ai-bot .session-history {
        position: absolute;
        inset: 0;
        z-index: 4;
        width: 100%;
        display: flex;
        padding: 14px;
        background: var(--paper-50);
        border-right: 0;
        box-shadow: none;
        opacity: 0;
        visibility: hidden;
        pointer-events: none;
        transform: translateX(100%);
        transition: transform 0.24s var(--ease-out),
                    opacity 0.18s var(--ease-out),
                    visibility 0.18s var(--ease-out);
    }

    .ai-bot.history-open .session-history {
        opacity: 1;
        visibility: visible;
        pointer-events: auto;
        transform: translateX(0);
    }

    .ai-bot .session-history-mobile-header {
        display: flex;
        align-items: center;
        justify-content: space-between;
        flex-shrink: 0;
        padding: 2px 2px 6px;
    }

    .ai-bot .session-history-mobile-title {
        color: var(--ink-400);
        font-size: 12px;
        font-weight: 700;
        letter-spacing: 0.14em;
        text-transform: uppercase;
    }

    .ai-bot .ai-content-shell {
        min-width: 100%;
    }

    .ai-bot .history-item,
    .ai-bot .replay-item {
        border-radius: 14px;
        background: var(--paper-0);
        box-shadow: 0 8px 24px -16px rgba(12, 14, 18, 0.18);
    }

    .ai-bot .ai-bot-history-item .history-item-body {
        padding: 13px 14px;
    }

    .ai-bot .ai-bot-history-menu-btn {
        opacity: 1;
        min-height: 48px;
    }
}

@media (max-width: 768px) {
    .ai-bot .offcanvas-header { padding: 14px 16px; }
    .ai-bot .initial-state,
    .ai-bot .conversation-state { padding: 16px 18px; }
    .ai-bot .initial-hero { padding: 4px 0 12px; }
    .ai-bot .initial-hero-mark { width: 54px; height: 54px; margin-bottom: 10px; }
    .ai-bot .initial-hero-mark .logo-container { width: 48px; height: 48px; border-radius: 14px; }
    .ai-bot .topbar-btn.icon-only { width: 32px; height: 32px; }
    .ai-bot .brand-title { font-size: 22px; }
    .ai-bot .description { font-size: 13px; }
    .ai-bot .message-content { max-width: 94%; font-size: 13.5px; }
    .ai-bot .message.assistant .message-content:has(table),
    .ai-bot .message.assistant .message-content:has(.ai-chart-container) {
        max-width: 100%;
        padding: 14px;
    }
    .ai-bot .message-content table { font-size: 12.5px; }
    .ai-bot .message-content th,
    .ai-bot .message-content td { padding: 9px 11px; }
    .ai-bot-fab { width: 52px; height: 52px; right: 18px; bottom: 18px; border-radius: 16px; }
    .ai-bot-fab-tooltip { display: none; }
    .ai-bot .powered-by { font-size: 9.5px; }
}

/* =============================================================================
   HISTORY ITEM CONTEXT MENU
   ========================================================================== */

.ai-bot .ai-bot-history-item {
    position: relative;
    display: flex;
    align-items: center;
    padding: 0;
}
.ai-bot .history-item.ai-bot-history-item { padding: 0; }
.ai-bot .ai-bot-history-item .history-item-body { flex: 1; min-width: 0; padding: 10px 12px; cursor: pointer; }

.ai-bot .ai-bot-history-menu-btn {
    opacity: 0;
    padding: 0 8px;
    height: 100%;
    min-height: 36px;
    cursor: pointer;
    background: transparent;
    border: 0;
    color: var(--ink-400);
    font-size: 18px;
    line-height: 1;
    flex-shrink: 0;
    border-radius: 0 11px 11px 0;
    transition: opacity var(--transition-fast), background var(--transition-fast);
}
.ai-bot .ai-bot-history-item:hover .ai-bot-history-menu-btn { opacity: 1; }
.ai-bot .ai-bot-history-menu-btn:hover {
    background: var(--ai-violet-wash);
    color: var(--ai-violet-deep);
}

.ai-bot .ai-bot-history-menu {
    position: absolute;
    right: 4px;
    top: 100%;
    background: var(--paper-0);
    border: 1px solid var(--paper-border-strong);
    box-shadow: 0 14px 36px -14px rgba(12, 14, 18, 0.3);
    border-radius: 10px;
    padding: 4px;
    z-index: 10;
    min-width: 128px;
}

.ai-bot .ai-bot-history-menu button {
    display: block;
    width: 100%;
    padding: 7px 12px;
    text-align: left;
    background: transparent;
    border: 0;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    color: var(--ink-700);
    transition: background var(--transition-fast), color var(--transition-fast);
}

.ai-bot .ai-bot-history-menu button:hover {
    background: var(--paper-50);
    color: var(--ink-900);
}

/* =============================================================================
   SAVED REPLAYS section
   ========================================================================== */

.ai-bot-history-panel { margin-bottom: 6px; }

.ai-bot-history-heading {
    font-size: 10.5px;
    text-transform: uppercase;
    letter-spacing: 0.14em;
    font-weight: 700;
    color: var(--ink-400);
    margin: 0 0 10px;
    padding: 0 6px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.ai-bot-history-heading-icon {
    color: var(--warm-gold);
    font-size: 13px;
}

.ai-bot-history-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.ai-bot-replays-empty { font-size: 12px; color: var(--ink-400); padding: 0 6px; }
.replay-item { list-style: none; }

/* =============================================================================
   MODAL — Save Replay
   ========================================================================== */

.ai-bot-modal {
    position: fixed;
    inset: 0;
    background: rgba(12, 14, 18, 0.5);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    padding: 20px;
    animation: ai-bot-modal-fade 0.18s var(--ease-out);
}

.ai-bot-modal[hidden] { display: none !important; }

@keyframes ai-bot-modal-fade {
    from { opacity: 0; }
    to { opacity: 1; }
}

.ai-bot-modal-card {
    background: var(--paper-50);
    border: 1px solid var(--paper-border-strong);
    border-radius: 18px;
    padding: 26px 26px 22px;
    min-width: 420px;
    max-width: 92vw;
    box-shadow: 0 30px 80px -20px rgba(12, 14, 18, 0.55);
    font-family: var(--ai-bot-font-family);
    color: var(--ink-700);
    animation: ai-bot-modal-rise 0.28s var(--ease-out);
}

@keyframes ai-bot-modal-rise {
    from { opacity: 0; transform: translateY(12px) scale(0.97); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.ai-bot-modal-header {
    margin-bottom: 18px;
}

.ai-bot-modal-eyebrow {
    display: block;
    font-size: 10.5px;
    font-weight: 700;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--ai-violet-deep);
    margin-bottom: 6px;
}

.ai-bot-modal-title {
    margin: 0 0 4px;
    font-size: 19px;
    font-weight: 700;
    color: var(--ink-900);
    letter-spacing: -0.018em;
    line-height: 1.2;
}

.ai-bot-modal-subtitle {
    margin: 0;
    font-size: 13px;
    color: var(--ink-400);
    font-family: var(--ai-bot-font-family);
    font-style: normal;
}

.ai-bot-modal-label {
    display: block;
    margin-bottom: 14px;
    font-size: 13px;
    color: var(--ink-500);
}

.ai-bot-modal-label-text {
    display: block;
    font-size: 11px;
    font-weight: 700;
    color: var(--ink-700);
    letter-spacing: 0.08em;
    text-transform: uppercase;
    margin-bottom: 6px;
}

.ai-bot-modal-input,
.ai-bot-modal-textarea {
    display: block;
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--paper-border-strong);
    border-radius: 10px;
    background: var(--paper-0);
    color: var(--ink-900);
    box-sizing: border-box;
    font-family: inherit;
    font-size: 13.5px;
    line-height: 1.45;
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.ai-bot-modal-input:focus,
.ai-bot-modal-textarea:focus {
    outline: none;
    border-color: var(--ai-violet-soft);
    box-shadow: 0 0 0 3px var(--ai-violet-wash);
}

.ai-bot-modal-textarea {
    resize: vertical;
    min-height: 70px;
    font-family: var(--ai-bot-font-family);
}

.ai-bot-modal-fieldset {
    border: 1px solid var(--paper-border-strong);
    border-radius: 12px;
    padding: 6px 12px 10px;
    margin: 4px 0 22px;
    background: var(--paper-0);
}

.ai-bot-modal-fieldset legend {
    font-size: 10.5px;
    color: var(--ink-700);
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    padding: 0 6px;
}

.ai-bot-modal-radio {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 8px 4px;
    border-radius: 8px;
    cursor: pointer;
    transition: background var(--transition-fast);
}

.ai-bot-modal-radio:hover {
    background: var(--paper-50);
}

.ai-bot-modal-radio input[type="radio"] {
    margin: 3px 0 0;
    accent-color: var(--ai-violet);
    flex-shrink: 0;
}

.ai-bot-modal-radio-body {
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.ai-bot-modal-radio-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--ink-900);
}

.ai-bot-modal-radio-desc {
    font-size: 12px;
    color: var(--ink-400);
}

.ai-bot-modal-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

.ai-bot-modal-btn {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 9px 16px;
    border: 1px solid var(--paper-border-strong);
    border-radius: 10px;
    background: var(--paper-0);
    color: var(--ink-700);
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    font-family: inherit;
    transition: all var(--transition-fast);
}

.ai-bot-modal-btn:hover {
    background: var(--paper-50);
    border-color: var(--ink-300);
}

.ai-bot-modal-btn.primary {
    background: var(--ink-900);
    color: #fff;
    border-color: var(--ink-900);
    box-shadow: 0 8px 18px -8px rgba(12, 14, 18, 0.45);
}

.ai-bot-modal-btn.primary:hover {
    background: var(--ai-violet-deep);
    border-color: var(--ai-violet-deep);
    box-shadow: 0 12px 24px -10px rgba(75, 37, 214, 0.55);
    transform: translateY(-1px);
}

/* =============================================================================
   ASSISTANT MESSAGE TOOLBAR (save / export)
   ========================================================================== */

.ai-bot-message-toolbar {
    position: relative;
    z-index: 25;
    display: inline-flex;
    gap: 6px;
    margin-top: 10px;
    margin-left: 10px;
    opacity: 0;
    transition: opacity 0.15s var(--ease-out);
    vertical-align: middle;
    flex-wrap: wrap;
}

.ai-bot .message:hover .ai-bot-message-toolbar { opacity: 1; }

.ai-bot-message-toolbar button {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 10px;
    border: 1px solid var(--paper-border-strong);
    background: var(--paper-50);
    cursor: pointer;
    font-size: 11.5px;
    border-radius: 7px;
    color: var(--ink-500);
    white-space: nowrap;
    line-height: 1;
    transition: all var(--transition-fast);
}

.ai-bot-message-toolbar button:hover {
    background: var(--paper-0);
    border-color: var(--ai-violet-soft);
    color: var(--ai-violet-deep);
}

.ai-bot-message-toolbar button.copied,
.ai-table-copy-btn.copied {
    border-color: rgba(16, 153, 106, 0.45);
    background: rgba(16, 153, 106, 0.12);
    color: var(--success);
}

/* Per-message export dropdown */
.ai-bot-export-dropdown { position: relative; z-index: 30; display: inline-block; }

.ai-bot-export-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 10px;
    border: 1px solid var(--paper-border-strong);
    background: var(--paper-50);
    cursor: pointer;
    font-size: 11.5px;
    border-radius: 7px;
    color: var(--ink-500);
    white-space: nowrap;
    line-height: 1;
    transition: all var(--transition-fast);
}

.ai-bot-export-btn:hover {
    background: var(--paper-0);
    border-color: var(--ai-violet-soft);
    color: var(--ai-violet-deep);
}

.ai-bot-export-menu {
    position: absolute;
    right: 0;
    top: calc(100% + 6px);
    margin: 0;
    padding: 4px;
    list-style: none;
    background: var(--paper-0);
    border: 1px solid var(--paper-border-strong);
    border-radius: 10px;
    box-shadow: 0 18px 38px -14px rgba(12, 14, 18, 0.32);
    min-width: 116px;
    z-index: 2000;
}

.ai-bot-export-menu[hidden] { display: none; }
.ai-bot-export-menu li { padding: 0; }
.ai-bot-export-menu button {
    display: block;
    width: 100%;
    padding: 7px 12px;
    text-align: left;
    background: transparent;
    border: 0;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    color: var(--ink-700);
}
.ai-bot-export-menu button:hover { background: var(--paper-50); color: var(--ink-900); }

/* =============================================================================
   MIC / VOICE INPUT
   ========================================================================== */

.ai-bot-mic {
    flex-shrink: 0;
    width: 34px;
    height: 34px;
    border: 1px solid transparent;
    border-radius: 10px;
    background: transparent;
    cursor: pointer;
    font-size: 14px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--ink-400);
    transition: background 0.15s var(--ease-out),
                color 0.15s var(--ease-out),
                border-color 0.15s var(--ease-out),
                transform 0.15s var(--ease-out);
}

.ai-bot-mic:hover {
    background: var(--paper-50);
    color: var(--ink-900);
    border-color: var(--paper-border);
}

.ai-bot-mic.listening {
    background: var(--danger);
    color: #fff;
    border-color: var(--danger);
    animation: ai-bot-mic-pulse 1.2s ease-in-out infinite;
}

@keyframes ai-bot-mic-pulse {
    0%, 100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(219, 50, 50, 0.5); }
    50%      { transform: scale(1.06); box-shadow: 0 0 0 9px rgba(219, 50, 50, 0); }
}

/* =============================================================================
   TABLE COPY ACTION
   ========================================================================== */

.ai-table-copy-shell {
    position: relative;
    margin: 10px 0 14px;
    padding-top: 36px;
    overflow-x: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--paper-border-strong) transparent;
}

.ai-table-copy-shell table {
    margin: 0;
}

.ai-table-copy-shell .ai-table-copy-btn {
    position: absolute;
    top: 0;
    right: 0;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 28px;
    padding: 0 10px;
    border: 1px solid var(--paper-border-strong);
    border-radius: 8px;
    background: var(--paper-0);
    color: var(--ink-500);
    box-shadow: 0 1px 2px rgba(12, 14, 18, 0.04);
    cursor: pointer;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    line-height: 1;
    white-space: nowrap;
    transition: all var(--transition-fast);
}

.ai-table-copy-shell .ai-table-copy-btn:hover {
    border-color: var(--ai-violet-soft);
    color: var(--ai-violet-deep);
    background: var(--ai-violet-wash);
}

.ai-table-copy-shell .ai-table-copy-btn svg {
    width: 13px;
    height: 13px;
}

/* =============================================================================
   AI CHART CONTAINER
   ========================================================================== */

.ai-chart-container {
    width: 100%;
    max-width: 760px;
    margin-top: 14px;
    background: linear-gradient(180deg, var(--paper-0) 0%, var(--paper-50) 100%);
    border: 1px solid var(--paper-border);
    border-radius: 14px;
    padding: 16px 18px 10px;
    box-shadow: var(--ai-bot-surface-shadow);
    position: relative;
    overflow: hidden;
}

.ai-chart-container::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--ai-violet) 0%, var(--warm-gold) 60%, transparent 100%);
    opacity: 0.7;
    border-radius: 14px 14px 0 0;
}

/* Force the entire Apex canvas to be transparent so our container shows through */
.ai-chart-container .apexcharts-canvas {
    background: transparent !important;
    max-width: 100%;
}

.ai-chart-container .apexcharts-svg {
    max-width: 100%;
    background: transparent !important;
}

.ai-chart-container .apexcharts-inner,
.ai-chart-container .apexcharts-graphical {
    background: transparent !important;
}

/* Title */
.ai-chart-container .apexcharts-title-text {
    font-family: var(--ai-bot-font-family) !important;
    font-weight: 700;
    fill: var(--ink-900) !important;
    letter-spacing: -0.012em;
}

/* Axis + legend labels */
.ai-chart-container .apexcharts-xaxis-label,
.ai-chart-container .apexcharts-yaxis-label,
.ai-chart-container .apexcharts-legend-text {
    fill: var(--ink-500) !important;
    color: var(--ink-500) !important;
    font-family: var(--ai-bot-font-family) !important;
    font-feature-settings: "tnum";
}

/* Grid lines — barely-there */
.ai-chart-container .apexcharts-grid line,
.ai-chart-container .apexcharts-gridline {
    stroke: rgba(12, 14, 18, 0.06) !important;
}

.ai-chart-container .apexcharts-xaxis-tick,
.ai-chart-container .apexcharts-yaxis-tick,
.ai-chart-container .apexcharts-xaxis line:not(.apexcharts-gridline),
.ai-chart-container .apexcharts-yaxis line:not(.apexcharts-gridline) {
    stroke: transparent !important;
}

/* Data labels (slice labels in pie/donut) */
.ai-chart-container .apexcharts-datalabels text,
.ai-chart-container .apexcharts-pie-label,
.ai-chart-container .apexcharts-datalabel {
    fill: #ffffff !important;
    font-weight: 600 !important;
    font-family: var(--ai-bot-font-family) !important;
}

/* Donut center value */
.ai-chart-container .apexcharts-datalabels-group text.apexcharts-text {
    fill: var(--ink-900) !important;
}

/* Tooltip — force light theme to match the panel, override Apex's dark default */
.ai-chart-container .apexcharts-tooltip,
.apexcharts-tooltip.apexcharts-theme-light,
.apexcharts-tooltip.apexcharts-theme-dark {
    background: var(--paper-0) !important;
    color: var(--ink-900) !important;
    border: 1px solid var(--paper-border-strong) !important;
    border-radius: 10px !important;
    box-shadow: 0 18px 38px -14px rgba(12, 14, 18, 0.28) !important;
    font-family: var(--ai-bot-font-family) !important;
    font-size: 12px !important;
    overflow: hidden;
}

.apexcharts-tooltip-title {
    background: var(--paper-50) !important;
    border-bottom: 1px solid var(--paper-border) !important;
    color: var(--ink-700) !important;
    font-weight: 700 !important;
    font-size: 11px !important;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    padding: 7px 10px !important;
}

.apexcharts-tooltip-series-group {
    padding: 4px 10px !important;
}

.apexcharts-tooltip-text-y-label,
.apexcharts-tooltip-text-y-value {
    color: var(--ink-900) !important;
    font-weight: 600 !important;
}

.apexcharts-tooltip-marker {
    width: 9px !important;
    height: 9px !important;
    border-radius: 3px !important;
}

/* xaxis tooltip (crosshair label) */
.apexcharts-xaxistooltip,
.apexcharts-yaxistooltip {
    background: var(--ink-900) !important;
    color: #fff !important;
    border-color: var(--ink-900) !important;
    border-radius: 6px !important;
    font-family: var(--ai-bot-font-family) !important;
    font-size: 11px !important;
    padding: 4px 8px !important;
}

.apexcharts-xaxistooltip::before,
.apexcharts-xaxistooltip::after,
.apexcharts-yaxistooltip::before,
.apexcharts-yaxistooltip::after {
    border-bottom-color: var(--ink-900) !important;
    border-top-color: var(--ink-900) !important;
}

/* Legend marker hover ring */
.ai-chart-container .apexcharts-legend-marker {
    margin-right: 6px !important;
}

/* =============================================================================
   REDUCED MOTION
   ========================================================================== */

@media (prefers-reduced-motion: reduce) {
    .ai-bot-fab-ring,
    .ai-bot .status-dot::after,
    .ai-bot .initial-hero-orbit,
    .ai-bot-fab-notification.active {
        animation: none !important;
    }
    .ai-bot .initial-hero,
    .ai-bot .quick-questions-section,
    .ai-bot .message,
    .ai-bot-modal,
    .ai-bot-modal-card {
        animation: none !important;
    }
    .ai-bot-fab:hover,
    .ai-bot .send-button:hover {
        transform: none !important;
    }
}
