/* AI Copilot drawer (js/s8-copilot.js). Right-side panel over the sim, on s8-tokens. */
.s8cp {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: min(420px, 100vw);
    z-index: 1040; /* under Bootstrap modals (1055) so the paywall opens on top */
    display: flex;
    flex-direction: column;
    background: var(--s8-panel, #0e1016);
    border-left: 1px solid var(--s8-line, #262a33);
    box-shadow: -12px 0 32px rgba(0, 0, 0, 0.45);
    color: var(--s8-fg, #e8eaf0);
    font-family: var(--s8-sans, system-ui, sans-serif);
    transform: translateX(100%);
    transition: transform 0.2s ease, opacity 0.2s ease;
}
.s8cp.is-open { transform: none; }
/* Docked over the trading sidebar (js syncWidth): a short slide + fade, so it never passes
   over the icon rail on its way in. */
.s8cp.is-docked { transform: translateX(16px); opacity: 0; border-right: 1px solid var(--s8-line, #262a33); box-shadow: -8px 0 24px rgba(0, 0, 0, 0.35); }
.s8cp.is-docked.is-open { transform: none; opacity: 1; }
.s8cp[hidden] { display: none; }

/* Same height as the sim panel header and the rail buttons beside it (--s8-toolbar, 48px). */
.s8cp-head {
    box-sizing: border-box;
    flex: none;
    display: flex;
    align-items: center;
    gap: 6px;
    height: var(--s8-toolbar, 48px);
    padding: 0 10px 0 16px;
    border-bottom: 1px solid var(--s8-line, #262a33);
}
.s8cp-title {
    flex: 1;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-weight: 700;
    font-size: 15px;
}
.s8cp-title svg { width: 18px; height: 18px; fill: var(--s8-accent, #f5b301); }
.s8cp-iconbtn {
    width: 30px;
    height: 30px;
    display: inline-grid;
    place-items: center;
    border: 0;
    border-radius: 5px;
    background: transparent;
    color: var(--s8-fg-3, #8b91a0);
    cursor: pointer;
}
.s8cp-iconbtn:hover { background: var(--s8-hover, rgba(255,255,255,0.06)); color: var(--s8-fg, #fff); }
.s8cp-iconbtn svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }

.s8cp-list {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}
/* Site scrollbar (same as .s8-scroll in s8-ui.css): thin, rounded, no arrows, transparent track. */
.s8cp-list, .s8cp-form textarea { scrollbar-width: thin; scrollbar-color: var(--s8-line-3, #4a5260) transparent; }
.s8cp-list::-webkit-scrollbar, .s8cp-form textarea::-webkit-scrollbar { width: 9px; height: 9px; }
.s8cp-list::-webkit-scrollbar-track, .s8cp-form textarea::-webkit-scrollbar-track { background: transparent; }
.s8cp-list::-webkit-scrollbar-button, .s8cp-form textarea::-webkit-scrollbar-button { display: none; width: 0; height: 0; }
.s8cp-list::-webkit-scrollbar-thumb, .s8cp-form textarea::-webkit-scrollbar-thumb { background: var(--s8-line-2, #3D4450); border: 2px solid transparent; background-clip: content-box; border-radius: 999px; }
.s8cp-list::-webkit-scrollbar-thumb:hover, .s8cp-form textarea::-webkit-scrollbar-thumb:hover { background: var(--s8-line-3, #4a5260); background-clip: content-box; }
.s8cp-list { overflow-x: hidden; }

/* Fresh chat: the intro fills the list; the mascot takes the free space above the greeting
   (centered, never larger than 200px wide) and shrinks away on short screens. */
.s8cp-intro { flex: 1 0 auto; margin-top: auto; display: flex; flex-direction: column; align-items: flex-start; gap: 8px; min-height: 0; }
.s8cp-mascot { flex: 1 1 auto; align-self: stretch; display: flex; align-items: center; justify-content: center; min-height: 0; padding: 8px 0 12px; }
.s8cp-mascot img { width: min(200px, 60%); height: auto; max-height: min(200px, 26vh); object-fit: contain; filter: drop-shadow(0 6px 24px rgba(43, 143, 224, 0.25)); user-select: none; pointer-events: none; }
@media (max-height: 620px) { .s8cp-mascot { display: none; } }
.s8cp-hello { margin: 0 0 6px; color: var(--s8-fg-2, #c3c8d4); font-size: 14px; line-height: 1.5; }
.s8cp-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border: 1px solid var(--s8-line, #262a33);
    border-radius: 5px;
    background: var(--s8-panel-2, #161922);
    color: var(--s8-fg, #e8eaf0);
    font: inherit;
    font-size: 13px;
    font-weight: 600;
    text-align: left;
    cursor: pointer;
}
.s8cp-chip:hover { border-color: var(--s8-accent-line, rgba(245,179,1,0.5)); }
.s8cp-chip svg { width: 14px; height: 14px; flex: none; fill: var(--s8-accent, #f5b301); }

.s8cp-msg { display: flex; }
.s8cp-msg--user { justify-content: flex-end; }
.s8cp-bubble {
    max-width: 88%;
    padding: 10px 12px;
    border-radius: 8px;
    font-size: 13.5px;
    line-height: 1.5;
    overflow-wrap: anywhere;
}
.s8cp-msg--user .s8cp-bubble { background: var(--s8-accent-tint, rgba(245,179,1,0.14)); border: 1px solid var(--s8-accent-line, rgba(245,179,1,0.35)); white-space: pre-wrap; }
.s8cp-msg--ai .s8cp-bubble { background: var(--s8-panel-2, #161922); border: 1px solid var(--s8-line, #262a33); }
.s8cp-bubble p { margin: 0 0 8px; }
.s8cp-bubble p:last-child, .s8cp-bubble ul:last-child { margin-bottom: 0; }
.s8cp-bubble ul { margin: 0 0 8px; padding-left: 18px; }
.s8cp-bubble li { margin: 2px 0; }
.s8cp-bubble strong { color: var(--s8-fg, #fff); }

.s8cp-msg.is-typing .s8cp-bubble { display: inline-flex; gap: 4px; padding: 12px 14px; }
.s8cp-msg.is-typing span { width: 6px; height: 6px; border-radius: 50%; background: var(--s8-fg-3, #8b91a0); animation: s8cp-dot 1s infinite ease-in-out; }
.s8cp-msg.is-typing span:nth-child(2) { animation-delay: 0.15s; }
.s8cp-msg.is-typing span:nth-child(3) { animation-delay: 0.3s; }
@keyframes s8cp-dot { 0%, 80%, 100% { opacity: 0.3; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-3px); } }

.s8cp-notice { align-self: center; font-size: 12px; color: var(--s8-fg-3, #8b91a0); text-align: center; }


.s8cp-form {
    margin: 0 16px;
    border: 1px solid var(--s8-line-2, #313642);
    border-radius: 8px;
    background: var(--s8-panel-2, #161922);
    padding: 8px 8px 6px 12px;
}
.s8cp-form:focus-within { border-color: var(--s8-line-3, #4a5260); }
/* The box's border is the focus cue; the site-wide input focus ring/outline must not
   show on the bare textarea inside it. */
.s8cp-form textarea,
.s8cp-form textarea:hover,
.s8cp-form textarea:focus,
.s8cp-form textarea:focus-visible {
    display: block;
    width: 100%;
    margin: 0;
    padding: 0;
    resize: none;
    border: 0 !important;
    outline: none !important;
    box-shadow: none !important;
    background: transparent !important;
    -webkit-appearance: none;
    appearance: none;
    color: var(--s8-fg, #e8eaf0);
    font: inherit;
    font-size: 13.5px;
    line-height: 1.45;
}
.s8cp-form textarea::placeholder { color: var(--s8-fg-4, #6b7180); }
.s8cp-formrow { display: flex; align-items: center; justify-content: flex-end; gap: 8px; }
.s8cp-counter { font-size: 11px; color: var(--s8-fg-4, #6b7180); }
.s8cp-send {
    width: 30px;
    height: 30px;
    display: inline-grid;
    place-items: center;
    border: 0;
    border-radius: 5px;
    background: var(--s8-accent, #f5b301);
    color: var(--s8-on-accent, #111);
    cursor: pointer;
}
.s8cp-send:disabled { opacity: 0.45; cursor: default; }
.s8cp-send svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }

/* History view: covers everything under the header. */
.s8cp-history {
    position: absolute;
    top: var(--s8-toolbar, 48px);
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 2;
    display: flex;
    flex-direction: column;
    background: var(--s8-panel, #0e1016);
}
.s8cp-history[hidden] { display: none; }
.s8cp-hhead { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px 4px; font-size: 14px; }
.s8cp-hhead button {
    border: 0;
    border-radius: 5px;
    padding: 5px 10px;
    background: var(--s8-panel-2, #161922);
    color: var(--s8-fg-2, #c3c8d4);
    font: inherit;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
}
.s8cp-hhead button:hover { color: var(--s8-fg, #fff); background: var(--s8-hover, rgba(255,255,255,0.06)); }
.s8cp-hnote { margin: 0 16px 8px; font-size: 12px; color: var(--s8-fg-3, #8b91a0); }
.s8cp-hlist {
    flex: 1;
    margin: 0;
    padding: 4px 16px 16px;
    list-style: none;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 8px;
    scrollbar-width: thin;
    scrollbar-color: var(--s8-line-3, #4a5260) transparent;
}
.s8cp-hlist::-webkit-scrollbar { width: 9px; }
.s8cp-hlist::-webkit-scrollbar-button { display: none; width: 0; height: 0; }
.s8cp-hlist::-webkit-scrollbar-track { background: transparent; }
.s8cp-hlist::-webkit-scrollbar-thumb { background: var(--s8-line-2, #3D4450); border: 2px solid transparent; background-clip: content-box; border-radius: 999px; }
/* Each chat is its own card with room between rows; the open chat gets a thin blue border. */
.s8cp-hrow {
    display: flex;
    align-items: center;
    gap: 4px;
    border: 1px solid var(--s8-line, #262a33);
    border-radius: 8px;
    background: var(--s8-panel-2, #161922);
    transition: border-color 0.15s ease;
}
.s8cp-hrow:hover { border-color: var(--s8-line-3, #4a5260); }
.s8cp-hrow.is-current { border-color: var(--s8-accent, #2B8FE0); }
.s8cp-hopen {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 3px;
    padding: 11px 12px;
    border: 0;
    background: transparent;
    color: inherit;
    font: inherit;
    text-align: left;
    cursor: pointer;
}
.s8cp-htitle { font-size: 13px; font-weight: 600; color: var(--s8-fg, #e8eaf0); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.s8cp-hmeta { font-size: 11.5px; color: var(--s8-fg-3, #8b91a0); }
.s8cp-hdel {
    flex: none;
    height: 28px;
    min-width: 28px;
    margin-right: 6px;
    padding: 0 6px;
    display: inline-grid;
    place-items: center;
    border: 0;
    border-radius: 5px;
    background: transparent;
    color: var(--s8-fg-4, #6b7180);
    font: inherit;
    font-size: 11.5px;
    font-weight: 700;
    cursor: pointer;
    opacity: 0;
}
.s8cp-hrow:hover .s8cp-hdel, .s8cp-hdel:focus-visible, .s8cp-hrow.is-confirm .s8cp-hdel { opacity: 1; }
.s8cp-hdel:hover { color: var(--s8-down, #ff6e7a); background: var(--s8-hover, rgba(255,255,255,0.06)); }
.s8cp-hrow.is-confirm .s8cp-hdel { color: #fff; background: var(--s8-down, #e5484d); }
.s8cp-hdel svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
@media (hover: none) { .s8cp-hdel { opacity: 1; } }

.s8cp-quota { margin: 8px 16px 0; font-size: 11.5px; font-weight: 600; color: var(--s8-fg-3, #8b91a0); }
.s8cp-quota.is-low { color: var(--s8-warn, #e8b04b); }
.s8cp-quota[hidden] { display: none; }
.s8cp-fine { margin: 6px 16px 12px; font-size: 11px; color: var(--s8-fg-4, #6b7180); }
@media (max-width: 639px) { .s8cp { width: 100vw; } }

.s8cp a, .s8cp a:hover, .s8cp a:focus { text-decoration: none; }

/* NEW state on the rail button. The pill/chip styles and keyframes come from s8-learn-links.css
   (shared with the Learn button); this adds the gold icon + glow for the copilot button. */
.s8cp-railbtn { position: relative; }
.s8-iconbtn.s8cp-railbtn > svg { width: 22px; height: 22px; }
.s8cp-railbtn.is-new { color: var(--s8-gold, #F5B14A); }
.s8cp-railbtn.is-new > svg { animation: s8-railnew-glow 2.2s ease-in-out 0.9s 3; }
@media (prefers-reduced-motion: reduce) { .s8cp-railbtn.is-new > svg { animation: none; } }

/* While the copilot is open, the tour's first-visit prompt stays out of the way (js/sim-tour.js
   also waits to show it; the first-trade nudge waits too, js/s8-first-trade.js). */
html.s8-copilot-open .s8t-prompt { visibility: hidden; }

/* Chart card above a question: the chart it was asked on (thumbnail when the chart changed). */
.s8cp-chart {
    flex: none; /* overflow:hidden lets a flex item shrink; in a long chat it collapsed to a 2px line */
    align-self: stretch;
    border: 1px solid var(--s8-line, #262a33);
    border-radius: 8px;
    background: var(--s8-panel-2, #161922);
    overflow: hidden;
}
.s8cp-chart img { display: block; width: 100%; height: auto; max-height: 220px; object-fit: cover; object-position: right center; border-bottom: 1px solid var(--s8-line, #262a33); }
.s8cp-chart__row { display: flex; align-items: center; gap: 8px; padding: 7px 10px; }
.s8cp-chart__cap { flex: 1; min-width: 0; font-size: 11.5px; font-weight: 600; color: var(--s8-fg-3, #8b91a0); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.s8cp-chart__open { flex: none; font-size: 12px; font-weight: 700; color: var(--s8-accent, #2B8FE0); text-decoration: none; }
.s8cp-chart__open:hover, .s8cp-chart__open:focus { color: var(--s8-accent-hi, #5fb0f0); text-decoration: none; }
