.wp-sjs-chat-toggle.button {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.wp-sjs-chat-toggle.is-active {
    background: #f0f6fc;
    border-color: var(--wp-admin-theme-color, #2271b1);
    color: var(--wp-admin-theme-color, #2271b1);
}

.wp-sjs-chat__sparkle {
    width: 16px;
    height: 16px;
    fill: currentColor;
    flex: none;
}

.wp-sjs-chat {
    --wp-sjs-chat-accent: var(--wp-admin-theme-color, #2271b1);
    position: fixed;
    top: 32px;
    right: 0;
    bottom: 0;
    z-index: 1001;
    display: flex;
    flex-direction: column;
    width: min(400px, 100vw);
    background: #fff;
    border-left: 1px solid #c3c4c7;
    box-shadow: -4px 0 16px rgba(0, 0, 0, 0.08);
    color: #1d2327;
    font-size: 13px;
}

.wp-sjs-chat[hidden] {
    display: none;
}

body.wp-sjs-addon-fullscreen-mode .wp-sjs-chat {
    top: 0;
}

@media screen and (max-width: 782px) {
    .wp-sjs-chat {
        top: 46px;
    }
}

@media screen and (min-width: 961px) {
    .wp-sjs-chat-open {
        padding-right: 400px;
    }

    /* The plugin header (with the AI assistant button) also ends at the panel: its 20px + the panel's 400px. */
    .wp-sjs-chat-is-open .wp-sjs-header {
        padding-right: 420px;
    }

    .wp-sjs-editor.wp-sjs-chat-open.wp-sjs-addon-fullscreen {
        padding-right: 416px;
    }
}

.wp-sjs-chat__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 10px 12px 10px 16px;
    border-bottom: 1px solid #dcdcde;
}

.wp-sjs-chat__title {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0;
    font-size: 14px;
    font-weight: 600;
}

.wp-sjs-chat__title .wp-sjs-chat__sparkle {
    width: 18px;
    height: 18px;
    color: var(--wp-sjs-chat-accent);
}

.wp-sjs-chat__header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* New chat: core's outlined (secondary) button, in the compact 32px size of the list-table buttons. */
.wp-core-ui .wp-sjs-chat__new.button {
    min-height: 32px;
    padding: 0 12px;
    line-height: 30px;
}

/* Close: a square 32px outlined button with the x in its middle. */
.wp-core-ui .wp-sjs-chat__close.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    min-height: 32px;
    height: 32px;
    padding: 0;
}

.wp-core-ui .wp-sjs-chat__close.button .dashicons {
    width: 20px;
    height: 20px;
    margin: 0;
    font-size: 20px;
    line-height: 1;
}

.wp-sjs-chat__icon-button.button {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    border-color: transparent;
    background: transparent;
    box-shadow: none;
}

.wp-sjs-chat__icon-button.button:hover,
.wp-sjs-chat__icon-button.button:focus-visible {
    background: #f0f0f1;
}

/* Opening the chat moves focus to the close button; after a click that showed core's focus frame around the x.
   The frame stays for keyboard focus only. */
.wp-core-ui .wp-sjs-chat__icon-button.button:focus:not(:focus-visible),
.wp-core-ui .wp-sjs-chat__close.button:focus:not(:focus-visible) {
    box-shadow: none;
    outline: none;
}

/* Core gives a dashicon in a .button a 1.9 line height and vertical-align: top, which put the icon off the
   middle of its label ("+ New chat") and of the button (x, the attach and mic icons). */
.wp-core-ui .wp-sjs-chat__icon-button.button .dashicons {
    width: 18px;
    height: 18px;
    margin: 0;
    font-size: 18px;
    line-height: 1;
    vertical-align: middle;
}

.wp-sjs-chat__model {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    border-bottom: 1px solid #f0f0f1;
    background: #f6f7f7;
}

.wp-sjs-chat__model[hidden] {
    display: none;
}

.wp-sjs-chat__model label {
    color: #50575e;
}

.wp-sjs-chat__model select {
    flex: 1;
    min-width: 0;
    max-width: none;
}

.wp-sjs-chat__log {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.wp-sjs-chat__message {
    display: flex;
    flex-direction: column;
    max-width: 90%;
}

.wp-sjs-chat__message.is-user {
    align-self: flex-end;
    align-items: flex-end;
}

.wp-sjs-chat__message.is-assistant {
    align-self: flex-start;
}

.wp-sjs-chat__bubble {
    padding: 8px 12px;
    border-radius: 12px;
    line-height: 1.5;
    overflow-wrap: anywhere;
    white-space: normal;
}

.wp-sjs-chat__message.is-user .wp-sjs-chat__bubble {
    background: var(--wp-sjs-chat-accent);
    color: #fff;
    border-bottom-right-radius: 4px;
    white-space: pre-wrap;
}

.wp-sjs-chat__message.is-assistant .wp-sjs-chat__bubble {
    background: #f0f0f1;
    border-bottom-left-radius: 4px;
}

.wp-sjs-chat__bubble p,
.wp-sjs-chat__bubble ul,
.wp-sjs-chat__bubble ol {
    margin: 0 0 6px;
}

.wp-sjs-chat__bubble > :last-child {
    margin-bottom: 0;
}

.wp-sjs-chat__bubble ul,
.wp-sjs-chat__bubble ol {
    padding-left: 18px;
}

.wp-sjs-chat__bubble ul {
    list-style: disc;
}

.wp-sjs-chat__bubble code {
    padding: 0 3px;
    background: rgba(0, 0, 0, 0.06);
    font-size: 12px;
}

.wp-sjs-chat__meta {
    margin-top: 4px;
    color: #646970;
    font-size: 11px;
}

.wp-sjs-chat__changes {
    margin-top: 6px;
    padding: 8px 10px;
    border: 1px solid #c5d9ed;
    border-left: 3px solid var(--wp-sjs-chat-accent);
    border-radius: 4px;
    background: #f6fbff;
}

.wp-sjs-chat__changes.is-undone {
    border-color: #dcdcde;
    background: #f6f7f7;
    color: #646970;
}

.wp-sjs-chat__changes.is-undone ul {
    text-decoration: line-through;
}

.wp-sjs-chat__changes-title {
    display: flex;
    align-items: center;
    gap: 4px;
    margin: 0 0 4px;
    font-weight: 600;
}

.wp-sjs-chat__changes-title .dashicons {
    font-size: 16px;
    width: 16px;
    height: 16px;
}

.wp-sjs-chat__changes ul {
    margin: 0 0 6px 18px;
    list-style: disc;
}

.wp-sjs-chat__changes li {
    margin: 0;
}

.wp-sjs-chat__undo.button {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.wp-sjs-chat__undo .dashicons {
    font-size: 16px;
    width: 16px;
    height: 16px;
}

.wp-sjs-chat__hint {
    margin: 4px 0 0;
    color: #646970;
}

.wp-sjs-chat__notice {
    align-self: center;
    padding: 2px 10px;
    border-radius: 10px;
    background: #f0f0f1;
    color: #50575e;
    font-size: 12px;
}

.wp-sjs-chat__empty {
    margin: auto 0;
    text-align: center;
}

.wp-sjs-chat__empty > .wp-sjs-chat__sparkle {
    width: 32px;
    height: 32px;
    color: var(--wp-sjs-chat-accent);
}

.wp-sjs-chat__greeting {
    font-size: 14px;
    font-weight: 600;
}

/* Example requests as chips: compact (core's .button is 40px high), white with a light gray border like the
   example chips on the AI MCP tab, dark text; the admin color on hover. A long request wraps inside its chip. */
.wp-sjs-chat__suggestions {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
    margin-top: 16px;
}

.wp-core-ui .wp-sjs-chat__suggestion.button {
    min-height: 0;
    margin: 0;
    padding: 6px 12px;
    border: 1px solid #dcdcde;
    border-radius: 16px;
    background: #fff;
    box-shadow: none;
    color: #1d2327;
    font-size: 13px;
    line-height: 18px;
    text-align: left;
    white-space: normal;
}

.wp-core-ui .wp-sjs-chat__suggestion.button:hover {
    border-color: var(--wp-admin-theme-color, #2271b1);
    background: color-mix(in srgb, var(--wp-admin-theme-color, #2271b1) 6%, #fff);
    color: var(--wp-admin-theme-color, #2271b1);
}

.wp-core-ui .wp-sjs-chat__suggestion.button:focus {
    border-color: var(--wp-admin-theme-color, #2271b1);
    box-shadow: 0 0 0 1px var(--wp-admin-theme-color, #2271b1);
    outline: none;
}

.wp-core-ui .wp-sjs-chat__suggestion.button:focus:not(:focus-visible) {
    border-color: #dcdcde;
    box-shadow: none;
}

.wp-sjs-chat__setup h3 {
    margin: 0 0 8px;
}

.wp-sjs-chat__setup-steps {
    margin: 12px 0;
    list-style: none;
}

.wp-sjs-chat__setup-steps li {
    display: flex;
    gap: 6px;
    align-items: flex-start;
}

.wp-sjs-chat__setup-steps li.is-done {
    color: #007017;
}

.wp-sjs-chat__problem {
    padding: 8px 10px;
    border-left: 3px solid #dba617;
    background: #fcf9e8;
}

.wp-sjs-chat__error {
    padding: 8px 12px;
    border-left: 3px solid #d63638;
    background: #fcf0f1;
}

.wp-sjs-chat__error p {
    margin: 0 0 6px;
}

.wp-sjs-chat__error details p {
    color: #50575e;
    font-size: 12px;
    overflow-wrap: anywhere;
}

.wp-sjs-chat__loading {
    color: #646970;
}

.wp-sjs-chat__status {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 16px;
    color: #50575e;
}

.wp-sjs-chat__status[hidden] {
    display: none;
}

.wp-sjs-chat__spinner {
    width: 12px;
    height: 12px;
    border: 2px solid #c3c4c7;
    border-top-color: var(--wp-sjs-chat-accent);
    border-radius: 50%;
    animation: wp-sjs-chat-spin 0.8s linear infinite;
}

@keyframes wp-sjs-chat-spin {
    to {
        transform: rotate(360deg);
    }
}

@media (prefers-reduced-motion: reduce) {
    .wp-sjs-chat__spinner {
        animation: none;
    }
}

.wp-sjs-chat__composer {
    padding: 12px 16px;
    border-top: 1px solid #dcdcde;
}

.wp-sjs-chat__composer[hidden] {
    display: none;
}

.wp-sjs-chat__input {
    width: 100%;
    resize: vertical;
    min-height: 60px;
    max-height: 240px;
}

.wp-sjs-chat__composer-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 6px;
}

.wp-sjs-chat__counter {
    color: #646970;
    font-size: 11px;
}

.wp-sjs-chat__privacy {
    margin: 8px 0 0;
    color: #646970;
    font-size: 11px;
    line-height: 1.4;
}

.wp-sjs-chat-open .wp-sjs-editor__tabs {
    flex-wrap: wrap;
    row-gap: 6px;
}

.wp-sjs-chat-toggle.page-title-action {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.wrap > h2.wp-heading-inline {
    display: inline-block;
    margin-right: 5px;
}

.wp-sjs-chat__form {
    margin: 0 0 6px;
}

.wp-sjs-chat__form .button {
    white-space: normal;
    height: auto;
    line-height: 1.4;
    padding: 4px 10px;
    text-align: left;
}

.wp-sjs-chat__composer-row {
    gap: 8px;
}

.wp-sjs-chat__tools {
    display: flex;
    flex: 1;
    flex-wrap: wrap;
    align-items: center;
    gap: 2px 8px;
}

.wp-sjs-chat__tools .wp-sjs-chat__icon-button.button {
    padding: 0 4px;
    min-height: 28px;
}

.wp-sjs-chat__mic.is-active {
    color: #d63638;
    background: #fcf0f1;
}

.wp-sjs-chat__mic.is-active .dashicons {
    animation: wp-sjs-chat-pulse 1.2s ease-in-out infinite;
}

@keyframes wp-sjs-chat-pulse {
    50% {
        opacity: 0.4;
    }
}

@media (prefers-reduced-motion: reduce) {
    .wp-sjs-chat__mic.is-active .dashicons {
        animation: none;
    }
}

.wp-sjs-chat__web {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    margin-left: 8px; /* 16px from the attach and mic buttons: a setting, not one of them */
    font-size: 12px;
    color: #50575e;
}

/* Core moves checkboxes 4px up (margin-top: -0.25rem) to sit on the text baseline; in this flex row the row
   centers them. */
.wp-sjs-chat__web input[type="checkbox"] {
    margin: 0;
}

.wp-sjs-chat__send.is-stop {
    background: #fff;
    border-color: #d63638;
    color: #d63638;
}

.wp-sjs-chat__attachments {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin: 0 0 8px;
    list-style: none;
}

.wp-sjs-chat__attachments[hidden] {
    display: none;
}

.wp-sjs-chat__attachment {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    max-width: 100%;
    margin: 0;
    padding: 2px 2px 2px 8px;
    border: 1px solid #c3c4c7;
    border-radius: 14px;
    background: #f6f7f7;
    font-size: 12px;
}

.wp-sjs-chat__attachment span:not(.dashicons) {
    overflow: hidden;
    max-width: 220px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.wp-sjs-chat__file {
    display: flex;
    align-items: center;
    gap: 2px;
    margin-top: 4px;
    font-size: 12px;
    opacity: 0.9;
}

.wp-sjs-chat__file .dashicons {
    font-size: 14px;
    width: 14px;
    height: 14px;
}

.wp-sjs-chat.is-dropping {
    outline: 3px dashed var(--wp-sjs-chat-accent);
    outline-offset: -8px;
}

.wp-sjs-chat__message.is-stopped .wp-sjs-chat__bubble {
    border-left: 3px solid #dba617;
}
