@layer channels {
    .chart-container.chat-chart-host {
        background: transparent;
        border-radius: 0;
        overflow: visible;
    }

    .chat-chart {
        min-width: 0;
        color: var(--ink-primary);
        background: var(--surface-panel);
        font-family: var(--font-ui);
        font-size: var(--text-xs);
        line-height: 1.4;
        text-align: left;
        --cc-plot-height: 270px;
    }

    .chat-chart [hidden] { display: none !important; }

    .chat-chart .cc-header {
        display: flex;
        align-items: center;
        gap: var(--space-3);
        padding: var(--space-4) 0;
    }

    .chat-chart .cc-logo {
        position: relative;
        display: grid;
        place-items: center;
        flex: 0 0 36px;
        height: 36px;
        border-radius: var(--radius-control);
        background: var(--surface-raised);
        color: var(--ink-secondary);
        font-size: var(--text-xs);
    }

    .chat-chart .cc-logo img { width: 28px; height: 28px; object-fit: contain; border-radius: var(--radius-chip); }
    .chat-chart .cc-company { flex: 1; min-width: 0; }
    .chat-chart .cc-name { display: block; font-size: var(--text-base); font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    .chat-chart .cc-symbol { display: block; margin-top: 3px; font-size: var(--text-xs); color: var(--ink-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    .chat-chart .cc-quote { flex-shrink: 0; text-align: right; font-variant-numeric: tabular-nums; }
    .chat-chart .cc-price { font-family: var(--font-data); font-size: 22px; font-weight: 500; letter-spacing: 0; }
    .chat-chart .cc-currency { margin-inline-start: var(--space-2); color: var(--ink-muted); font-size: var(--text-xs); }
    .chat-chart .cc-change { display: block; margin-top: 3px; color: var(--ink-muted); font-size: var(--text-xs); }
    .chat-chart .cc-change[data-direction="up"] { color: var(--signal-up); }
    .chat-chart .cc-change[data-direction="down"] { color: var(--signal-down); }

    .chat-chart .cc-toolbar { display: flex; align-items: center; justify-content: space-between; gap: var(--space-2); padding-block: var(--space-2); }
    .chat-chart .cc-periods, .chat-chart .cc-tools { display: flex; align-items: center; gap: 2px; }
    .chat-chart button {
        display: inline-flex;
        justify-content: center;
        align-items: center;
        min-width: 32px;
        min-height: 32px;
        padding: 6px 8px;
        border: 0;
        border-radius: var(--radius-chip);
        background: transparent;
        color: var(--ink-muted);
        font: inherit;
        text-transform: none;
        letter-spacing: normal;
        cursor: pointer;
        transition: background-color var(--dur-fast) var(--ease-out), color var(--dur-fast) var(--ease-out);
    }

    .chat-chart button[aria-pressed="true"], .chat-chart button[aria-expanded="true"] { background: var(--surface-selected); color: var(--ink-primary); }
    .chat-chart button:disabled { cursor: default; opacity: 0.45; }
    .chat-chart button:focus-visible, .chat-chart input:focus-visible, .chat-chart select:focus-visible { outline: 2px solid var(--line-focus); outline-offset: 2px; }
    .chat-chart button .icon { width: var(--icon-nav); height: var(--icon-nav); }
    .chat-chart .cc-interval-button { color: var(--ink-secondary); min-width: 54px; }
    .chat-chart .cc-readout { display: flex; gap: 0 var(--space-2); min-height: 26px; padding-block: 4px; color: var(--ink-muted); font: var(--text-2xs)/1.6 var(--font-data); overflow: hidden; white-space: nowrap; }
    .chat-chart .cc-readout span { flex-shrink: 0; }
    .chat-chart .cc-stage { position: relative; height: var(--cc-plot-height); }
    .chat-chart .cc-plot { width: 100%; height: 100%; }
    .chat-chart .cc-message { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: var(--space-3); padding: var(--space-4); color: var(--ink-muted); text-align: center; background: var(--surface-panel); }
    .chat-chart .cc-retry { background: var(--surface-raised); color: var(--ink-primary); }
    .chat-chart .cc-footer { display: flex; align-items: center; justify-content: space-between; gap: var(--space-2); min-height: 32px; color: var(--ink-muted); font-size: 11px; }
    .chat-chart .cc-credits { display: flex; flex-wrap: wrap; gap: 0 var(--space-2); min-width: 0; }
    .chat-chart .cc-attribution { color: var(--ink-muted); text-decoration: none; }
    .chat-chart .cc-attribution:hover { color: var(--ink-secondary); text-decoration: underline; }
    .chat-chart .cc-attribution:focus-visible { outline: 2px solid var(--line-focus); outline-offset: 2px; }
    .chat-chart .cc-source.is-stale { color: var(--signal-warn); }
    .chat-chart .cc-refresh { min-height: 28px; }
    .chat-chart .cc-refresh .icon { width: var(--icon-inline); height: var(--icon-inline); }

    .chat-chart .cc-popover {
        position: fixed;
        inset: auto;
        margin: 0;
        width: min(304px, calc(100vw - 16px));
        max-height: calc(100dvh - 16px);
        box-sizing: border-box;
        padding: var(--space-3);
        overflow-y: auto;
        border: 1px solid var(--line);
        border-radius: var(--radius-panel);
        background: var(--surface-overlay);
        color: var(--ink-primary);
        font-family: var(--font-ui);
        font-size: var(--text-xs);
    }

    .chat-chart .cc-panel-title { padding-block: var(--space-2); color: var(--ink-secondary); font-weight: 500; }
    .chat-chart .cc-types { display: flex; gap: 2px; margin-bottom: var(--space-2); }
    .chat-chart .cc-types button { flex: 1; }
    .chat-chart .cc-option { display: flex; align-items: center; justify-content: space-between; gap: var(--space-2); min-height: 38px; }
    .chat-chart .cc-option > label { display: flex; align-items: center; gap: var(--space-2); }
    .chat-chart .cc-option input[type="checkbox"] { appearance: none; display: inline-grid; place-content: center; width: 16px; height: 16px; margin: 0; border: 1px solid var(--ink-muted); border-radius: 4px; background: transparent; cursor: pointer; }
    .chat-chart .cc-option input[type="checkbox"]:checked { background: var(--accent); border-color: var(--accent); }
    .chat-chart .cc-option input[type="checkbox"]:checked::after { content: ''; width: 7px; height: 4px; border-bottom: 2px solid var(--accent-ink); border-left: 2px solid var(--accent-ink); transform: rotate(-45deg) translateY(-1px); }
    .chat-chart .cc-option input:disabled { opacity: 0.45; cursor: default; }
    .chat-chart .cc-option input[type="number"], .chat-chart .cc-option select { min-height: 30px; padding: 4px 6px; border: 1px solid var(--line); border-radius: var(--radius-chip); color: var(--ink-primary); background: var(--surface-panel); font: inherit; color-scheme: dark; }
    .chat-chart .cc-option input[type="number"] { width: 64px; font-family: var(--font-data); }
    .chat-chart .cc-length { color: var(--ink-muted); font-size: 11px; }
    .chat-chart .cc-indicator-hint { margin: var(--space-2) 0; color: var(--ink-muted); font-size: 11px; }
    .chat-chart .cc-indicator-hint:empty { display: none; }
    .chat-chart .cc-reset-settings { margin-top: var(--space-2); }
    .chat-chart .cc-intervals:popover-open { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; }
    .chat-chart:fullscreen { display: flex; flex-direction: column; padding: var(--space-5); box-sizing: border-box; width: 100%; height: 100%; }
    .chat-chart:fullscreen .cc-stage { flex: 1; min-height: 0; }

    @media (hover: hover) and (pointer: fine) {
        .chat-chart button:not(:disabled):hover { color: var(--ink-primary); background: var(--surface-hover); }
    }

    @media (max-width: 640px) {
        .chat-chart { --cc-plot-height: 245px; }
        .chat-chart .cc-toolbar { flex-wrap: wrap; gap: 0; }
        .chat-chart .cc-periods { flex: 1 0 100%; justify-content: space-between; }
        .chat-chart .cc-tools { justify-content: flex-end; width: 100%; }
        .chat-chart .cc-header { gap: var(--space-2); }
        .chat-chart .cc-name { font-size: var(--text-sm); }
        .chat-chart .cc-price { font-size: 18px; }
        .chat-chart .cc-logo { flex-basis: 30px; height: 30px; }
        .chat-chart .cc-logo img { width: 24px; height: 24px; }
        .chat-chart .cc-change { font-size: 11px; }
        .chat-chart .cc-readout { flex-wrap: wrap; align-content: start; min-height: 42px; }
        .chat-chart:fullscreen { padding: var(--space-3); }
    }

    @media (prefers-reduced-motion: reduce) {
        .chat-chart button { transition: none; }
    }
}
