.mwi-header-search {
    width: 100%;
    max-width: 420px;
    margin: 0;
    padding: 0;
}

.mwi-header-search__form {
    margin: 0;
}

.mwi-header-search__input {
    width: 100%;
    height: 42px;
    padding: 0 16px;
    border: 1px solid rgba(0, 0, 0, 0.14);
    border-radius: 999px;
    background: #fff;
    color: #111;
    font-size: 15px;
    line-height: 42px;
    box-shadow: none;
    transition: border-color 160ms ease, box-shadow 160ms ease, opacity 160ms ease;
}

.mwi-header-search__input::placeholder {
    color: rgba(0, 0, 0, 0.48);
}

.mwi-header-search__input:focus {
    outline: none;
    border-color: rgba(0, 0, 0, 0.42);
    box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.07);
}

.mwi-header-search__input:disabled {
    opacity: 0.72;
    cursor: wait;
}

.mwi-header-search__input--loading {
    background-image: linear-gradient(
        90deg,
        rgba(0, 0, 0, 0.03),
        rgba(0, 0, 0, 0.08),
        rgba(0, 0, 0, 0.03)
    );
    background-size: 220% 100%;
    animation: mwiBacchusThinking 1.1s linear infinite;
}

.mwi-header-search__status,
.mwi-header-search__results {
    position: fixed;
    z-index: 999999;
    box-sizing: border-box;
    border-radius: 22px;
    background: rgba(255, 255, 255, 0.98);
    color: #111;
    box-shadow: 0 20px 70px rgba(0, 0, 0, 0.20);
    backdrop-filter: blur(14px);
}

.mwi-header-search__status {
    padding: 14px 16px;
    font-size: 14px;
    line-height: 1.45;
}

.mwi-header-search__status--error {
    background: #fff0f0;
    color: #8a1f1f;
}

.mwi-header-search__status--loading {
    color: rgba(0, 0, 0, 0.72);
}

.mwi-header-search__results {
    max-height: min(580px, calc(100vh - 110px));
    overflow: auto;
    padding: 14px;
}

.mwi-header-search__close {
    position: absolute;
    top: 10px;
    right: 12px;
    width: 28px;
    height: 28px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.06);
    color: #111;
    font-size: 22px;
    line-height: 26px;
    cursor: pointer;
}

.mwi-header-search__close:hover,
.mwi-header-search__close:focus {
    background: rgba(0, 0, 0, 0.12);
    color: #111;
}

.mwi-header-search__panel {
    animation: mwiSearchPanelIn 180ms ease both;
}

.mwi-header-search__site-results {
    padding-right: 28px;
}

.mwi-header-search__group {
    margin-top: 12px;
}

.mwi-header-search__group:first-child {
    margin-top: 0;
}

.mwi-header-search__group-title {
    margin: 0 0 6px;
    padding: 0 4px;
    font-size: 11px;
    font-weight: 900;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    opacity: 0.46;
}

.mwi-header-search__item {
    display: flex;
    gap: 11px;
    align-items: flex-start;
    padding: 10px;
    border-radius: 16px;
    color: #111;
    text-decoration: none;
    transition: background 130ms ease, transform 130ms ease;
}

.mwi-header-search__item:hover,
.mwi-header-search__item:focus {
    background: rgba(0, 0, 0, 0.045);
    color: #111;
    transform: translateY(-1px);
}

.mwi-header-search__item-image {
    width: 42px;
    height: 42px;
    flex: 0 0 42px;
    border-radius: 14px;
    object-fit: cover;
    background: linear-gradient(135deg, rgba(0, 0, 0, 0.07), rgba(0, 0, 0, 0.02));
}

.mwi-header-search__item-image--empty {
    display: block;
}

.mwi-header-search__item-body {
    min-width: 0;
    display: block;
}

.mwi-header-search__item-title {
    display: block;
    font-size: 14px;
    font-weight: 850;
    line-height: 1.25;
}

.mwi-header-search__item-text {
    display: block;
    margin-top: 4px;
    font-size: 13px;
    line-height: 1.35;
    opacity: 0.62;
}

.mwi-header-search__askbar {
    position: sticky;
    bottom: -14px;
    margin: 14px -14px -14px;
    padding: 12px 14px;
    border-top: 1px solid rgba(0, 0, 0, 0.08);
    background: rgba(255, 255, 255, 0.98);
    border-radius: 0 0 22px 22px;
    backdrop-filter: blur(14px);
}

.mwi-header-search__ask-button,
.mwi-header-search__bacchus-submit {
    width: 100%;
    height: 42px;
    border: 0;
    border-radius: 999px;
    background: #111;
    color: #fff;
    font-size: 14px;
    font-weight: 900;
    cursor: pointer;
}

.mwi-header-search__ask-button:hover,
.mwi-header-search__ask-button:focus,
.mwi-header-search__bacchus-submit:hover,
.mwi-header-search__bacchus-submit:focus {
    background: #333;
    color: #fff;
}

.mwi-header-search__back {
    display: inline-flex;
    align-items: center;
    height: 32px;
    margin-bottom: 12px;
    padding: 0 12px;
    border: 0;
    border-radius: 999px;
    background: rgba(0, 0, 0, 0.06);
    color: #111;
    font-size: 13px;
    font-weight: 800;
    cursor: pointer;
}

.mwi-header-search__back:hover,
.mwi-header-search__back:focus {
    background: rgba(0, 0, 0, 0.10);
    color: #111;
}

.mwi-header-search__bacchus-loading,
.mwi-header-search__bacchus-error,
.mwi-header-search__bacchus-answer {
    padding: 8px 2px 2px;
    font-size: 15px;
    line-height: 1.7;
}

.mwi-header-search__bacchus-error {
    color: #8a1f1f;
}

.mwi-header-search__bacchus-form {
    margin: 0;
}

.mwi-header-search__bacchus-input {
    width: 100%;
    min-height: 105px;
    margin: 0 0 10px;
    padding: 13px 14px;
    border: 1px solid rgba(0, 0, 0, 0.14);
    border-radius: 16px;
    background: rgba(0, 0, 0, 0.03);
    color: #111;
    font-size: 15px;
    line-height: 1.45;
    resize: vertical;
    box-sizing: border-box;
}

.mwi-header-search__bacchus-input:focus {
    outline: none;
    border-color: rgba(0, 0, 0, 0.42);
    background: #fff;
    box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.07);
}

.mwi-header-search__bacchus-followup {
    margin-top: 14px;
}

.mwi-header-search__secondary-button {
    width: 100%;
    height: 40px;
    border: 0;
    border-radius: 999px;
    background: rgba(0, 0, 0, 0.06);
    color: #111;
    font-size: 14px;
    font-weight: 850;
    cursor: pointer;
}

.mwi-header-search__secondary-button:hover,
.mwi-header-search__secondary-button:focus {
    background: rgba(0, 0, 0, 0.10);
    color: #111;
}

.mwi-header-search__empty {
    padding: 12px 6px;
    font-size: 14px;
    line-height: 1.45;
    opacity: 0.66;
}

@keyframes mwiBacchusThinking {
    0% {
        background-position: 120% 0;
    }

    100% {
        background-position: -120% 0;
    }
}

@keyframes mwiSearchPanelIn {
    from {
        opacity: 0;
        transform: translateY(6px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@media (max-width: 640px) {
    .mwi-header-search {
        max-width: 100%;
    }

    .mwi-header-search__input {
        height: 40px;
        font-size: 14px;
    }

    .mwi-header-search__results,
    .mwi-header-search__status {
        border-radius: 18px;
    }

    .mwi-header-search__askbar {
        border-radius: 0 0 18px 18px;
    }
}

/* =========================================
   Bacchus Chat UI v2
   ========================================= */

.mwi-bacchus-chat-window__header {
    position: sticky;
    top: 0;
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    margin: -18px -18px 16px;
    padding: 14px 18px;
    border-bottom: 1px solid #e2e6eb;
    background: rgba(255, 255, 255, 0.94);
    backdrop-filter: blur(12px);
}

.mwi-bacchus-chat-window__header strong,
.mwi-bacchus-chat-window__header span {
    display: block;
}

.mwi-bacchus-chat-window__header span {
    margin-top: 2px;
    font-size: 12px;
    opacity: 0.62;
}

.mwi-bacchus-copy {
    border: 1px solid #e2e6eb;
    border-radius: 999px;
    background: #fff;
    color: #111;
    cursor: pointer;
    font-size: 12px;
    font-weight: 700;
    padding: 8px 12px;
}

.mwi-bacchus-chat {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.mwi-bacchus-chat__message {
    display: flex;
    align-items: flex-start;
    gap: 10px;
}

.mwi-bacchus-chat__message--user {
    flex-direction: row-reverse;
}

.mwi-bacchus-chat__avatar {
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 34px;
    width: 34px;
    height: 34px;
    border-radius: 999px;
    background: #111;
    color: #fff;
    font-size: 11px;
    font-weight: 800;
}

.mwi-bacchus-chat__message--user .mwi-bacchus-chat__avatar {
    background: #2f88ff;
}

.mwi-bacchus-chat__bubble {
    box-sizing: border-box;
    max-width: min(88%, 760px);
    padding: 13px 15px;
    border: 1px solid #e2e6eb;
    border-radius: 18px;
    background: #fff;
    box-shadow: 0 10px 28px rgba(15, 23, 42, 0.06);
}

.mwi-bacchus-chat__message--user .mwi-bacchus-chat__bubble {
    border-color: rgba(47, 136, 255, 0.25);
    background: rgba(47, 136, 255, 0.08);
}

.mwi-bacchus-chat__bubble p:first-child {
    margin-top: 0;
}

.mwi-bacchus-chat__bubble p:last-child {
    margin-bottom: 0;
}

.mwi-header-search__bacchus-answer--streaming p::after {
    content: "";
    display: inline-block;
    width: 7px;
    height: 1em;
    margin-left: 3px;
    vertical-align: -2px;
    background: currentColor;
    animation: mwiBacchusCursor 0.9s steps(2, start) infinite;
}

@keyframes mwiBacchusCursor {
    0%, 45% { opacity: 1; }
    46%, 100% { opacity: 0; }
}

.mwi-bacchus-followups {
    margin-top: 16px;
    padding-top: 14px;
    border-top: 1px solid #e2e6eb;
}

.mwi-bacchus-followups h4 {
    margin: 0 0 10px;
    font-size: 13px;
    font-weight: 800;
}

.mwi-bacchus-followups button {
    display: block;
    width: 100%;
    margin: 7px 0 0;
    padding: 9px 11px;
    border: 1px solid #e2e6eb;
    border-radius: 12px;
    background: #fff;
    color: #111;
    cursor: pointer;
    font-size: 13px;
    line-height: 1.35;
    text-align: left;
}

.mwi-bacchus-followups button:hover,
.mwi-bacchus-followups button:focus {
    border-color: #2f88ff;
    color: #2f88ff;
}

.mwi-bacchus-explore__card--skeleton {
    pointer-events: none;
}

.mwi-bacchus-explore__card--skeleton .mwi-bacchus-explore__image,
.mwi-bacchus-explore__card--skeleton .mwi-bacchus-explore__body span,
.mwi-bacchus-explore__card--skeleton .mwi-bacchus-explore__body strong {
    display: block;
    border-radius: 10px;
    background: linear-gradient(90deg, rgba(226,230,235,.7), rgba(245,248,252,1), rgba(226,230,235,.7));
    background-size: 220% 100%;
    animation: mwiBacchusSkeleton 1.2s linear infinite;
}

.mwi-bacchus-explore__card--skeleton .mwi-bacchus-explore__body span {
    height: 10px;
    width: 44%;
    margin-bottom: 8px;
}

.mwi-bacchus-explore__card--skeleton .mwi-bacchus-explore__body strong {
    height: 14px;
    width: 84%;
    margin-bottom: 8px;
}

@keyframes mwiBacchusSkeleton {
    from { background-position: 120% 0; }
    to { background-position: -120% 0; }
}

@media (max-width: 900px) {
    .mwi-bacchus-chat__bubble {
        max-width: calc(100vw - 92px);
    }
}


/* =========================================
   Bacchus chat cleanup
   ========================================= */

.mwi-bacchus-chat__body {
    min-width: 0;
    max-width: min(88%, 760px);
}

.mwi-bacchus-chat__message--user .mwi-bacchus-chat__body {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
}

.mwi-bacchus-chat__message--assistant .mwi-bacchus-chat__body {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
}

.mwi-bacchus-chat__name {
    margin: 0 0 5px;
    padding: 0 4px;
    font-size: 11px;
    font-weight: 800;
    line-height: 1.2;
    opacity: 0.58;
}

.mwi-bacchus-chat__avatar--user,
.mwi-bacchus-chat__avatar--assistant {
    overflow: hidden;
}

.mwi-bacchus-chat__avatar--user img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.mwi-bacchus-chat__avatar--assistant svg {
    width: 20px;
    height: 20px;
    fill: currentColor;
}

.mwi-bacchus-chat__bubble {
    position: relative;
}

.mwi-bacchus-chat__bubble--user {
    border-color: rgba(47, 136, 255, 0.25);
    background: rgba(47, 136, 255, 0.08);
}

.mwi-bacchus-chat__bubble--assistant {
    border-color: #e2e6eb;
    background: #fff;
}

.mwi-bacchus-copy--message {
    position: absolute;
    top: 8px;
    right: 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    padding: 0;
    border: 1px solid #e2e6eb;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.92);
    color: #111;
    cursor: pointer;
    opacity: 0;
    transform: translateY(-2px);
    transition: opacity 160ms ease, transform 160ms ease, color 160ms ease, border-color 160ms ease;
    z-index: 3;
}

.mwi-bacchus-chat__bubble--assistant:hover .mwi-bacchus-copy--message,
.mwi-bacchus-copy--message:focus {
    opacity: 1;
    transform: translateY(0);
}

.mwi-bacchus-copy--message:hover,
.mwi-bacchus-copy--message:focus {
    border-color: #2f88ff;
    color: #2f88ff;
}

.mwi-bacchus-copy--copied {
    border-color: #2f88ff;
    color: #2f88ff;
}

.mwi-bacchus-followups {
    display: none !important;
}

@media (max-width: 900px) {
    .mwi-bacchus-chat__body {
        max-width: calc(100vw - 92px);
    }
}



/* Explore empty state */
.mwi-bacchus-explore__empty {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 16px;
    border: 1px solid #e2e6eb;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.72);
    color: #111;
}

.mwi-bacchus-explore__empty strong {
    font-size: 15px;
    font-weight: 800;
}

.mwi-bacchus-explore__empty span {
    font-size: 13px;
    line-height: 1.45;
    opacity: 0.72;
}


/* Explore empty state create links */
.mwi-bacchus-explore__create-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
    margin-top: 10px;
}

.mwi-bacchus-explore__create-grid .create-link {
    display: flex;
    align-items: center;
    gap: 9px;
    min-height: 40px;
    padding: 9px 11px;
    border: 1px solid #e2e6eb;
    border-radius: 12px;
    background: #fff;
    color: #111;
    font-size: 13px;
    font-weight: 700;
    text-decoration: none;
    box-shadow: 0 8px 20px rgba(15, 23, 42, 0.04);
    transition: color 160ms ease, border-color 160ms ease, transform 160ms ease, box-shadow 160ms ease;
}

.mwi-bacchus-explore__create-grid .create-link i {
    width: 18px;
    text-align: center;
    opacity: 0.72;
}

.mwi-bacchus-explore__create-grid .create-link:hover,
.mwi-bacchus-explore__create-grid .create-link:focus {
    color: #2f88ff;
    border-color: rgba(47, 136, 255, 0.45);
    transform: translateY(-1px);
    box-shadow: 0 10px 24px rgba(15, 23, 42, 0.08);
}

