/* ── Overlay ── */
#csm-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 999999;
    background: rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    align-items: flex-start;
    justify-content: center;
    padding: 72px 16px 16px;
    box-sizing: border-box;
}
#csm-overlay.open {
    display: flex;
    animation: csm-fade 0.18s ease;
}
@keyframes csm-fade {
    from { opacity: 0; }
    to   { opacity: 1; }
}

/* ── Modal card ── */
#csm-modal {
    width: 100%;
    max-width: 640px;
    max-height: calc(100vh - 88px);
    background: #fff;
    border-radius: 14px;
    box-shadow: 0 24px 64px rgba(0, 0, 0, 0.28);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: csm-up 0.18s ease;
}
@keyframes csm-up {
    from { transform: translateY(16px); opacity: 0; }
    to   { transform: translateY(0);    opacity: 1; }
}

/* ── Search bar ── */
#csm-search-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 18px;
    border-bottom: 1px solid #efefef;
    flex-shrink: 0;
    color: #aaa;
}
#csm-input {
    flex: 1;
    border: none;
    outline: none;
    font-size: 17px;
    color: #111;
    background: transparent;
    min-width: 0;
}
#csm-input::placeholder { color: #bbb; }
#csm-close {
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    cursor: pointer;
    color: #aaa;
    padding: 6px;
    border-radius: 6px;
    line-height: 1;
    flex-shrink: 0;
    transition: background 0.12s, color 0.12s;
}
#csm-close:hover { background: #f2f2f2; color: #333; }

/* ── Results ── */
#csm-results {
    overflow-y: auto;
    overscroll-behavior: contain;
    flex: 1;
}
.csm-result {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 11px 18px;
    text-decoration: none;
    color: inherit;
    cursor: pointer;
    transition: background 0.1s;
    outline: none;
}
.csm-result:hover,
.csm-result:focus,
.csm-result.csm-focused { background: #f6f6f6; }
.csm-result-img {
    width: 54px;
    height: 54px;
    object-fit: cover;
    border-radius: 8px;
    flex-shrink: 0;
    background: #f0f0f0;
}
.csm-result-img-placeholder {
    width: 54px;
    height: 54px;
    border-radius: 8px;
    background: #f0f0f0;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #ccc;
}
.csm-result-info { flex: 1; min-width: 0; }
.csm-result-title {
    font-size: 14px;
    font-weight: 500;
    color: #111;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.3;
}
.csm-result-price {
    font-size: 13px;
    color: #555;
    margin-top: 3px;
    line-height: 1.3;
}
.csm-result-price del { color: #bbb; margin-right: 4px; }
.csm-result-price ins { text-decoration: none; color: #c0392b; }

/* ── States ── */
.csm-loading {
    display: flex;
    justify-content: center;
    padding: 28px 0;
}
.csm-spinner {
    width: 26px;
    height: 26px;
    border: 2.5px solid #eee;
    border-top-color: #555;
    border-radius: 50%;
    animation: csm-spin 0.55s linear infinite;
}
@keyframes csm-spin { to { transform: rotate(360deg); } }
.csm-message {
    padding: 28px 20px;
    text-align: center;
    font-size: 14px;
    color: #888;
    line-height: 1.5;
}
.csm-footer {
    border-top: 1px solid #efefef;
    padding: 10px 18px;
    flex-shrink: 0;
}
.csm-footer a {
    display: block;
    text-align: center;
    font-size: 13px;
    color: #555;
    text-decoration: none;
    padding: 6px;
    border-radius: 6px;
    transition: background 0.1s;
}
.csm-footer a:hover { background: #f6f6f6; color: #111; }

/* ── Mobile ── */
@media (max-width: 660px) {
    #csm-overlay {
        padding: 0;
        align-items: flex-start;
    }
    #csm-modal {
        border-radius: 0 0 14px 14px;
        max-height: 82vh;
    }
}
