/* Backdrop */
#tss-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    z-index: 99998;
}

#tss-backdrop.is-open {
    display: block;
}

/* Modal */
#tss-modal {
    display: none;
    position: fixed;
    top: 110px;
    left: 50%;
    transform: translateX(-50%);
    width: min(680px, calc(100vw - 32px));
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.18);
    z-index: 99999;
    overflow: hidden;
    max-height: calc(100vh - 150px);
    overflow-y: auto;
}

#tss-modal.is-open {
    display: block;
}

body.tss-modal-open {
    overflow: hidden;
}

/* Input row */
#tss-input-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 18px;
    border-bottom: 1px solid #eee;
    position: sticky;
    top: 0;
    background: #fff !important;
    z-index: 1;
    color: #111 !important;
}

#tss-search-icon {
    font-size: 18px;
    flex-shrink: 0;
    color: #999;
}

#tss-input {
    flex: 1;
    font-size: 18px;
    font-weight: 500;
    border: 0;
    outline: 0;
    background: #fff !important;
    color: #111 !important;
    min-width: 0;
    -webkit-text-fill-color: #111 !important;
}

#tss-input::placeholder {
    color: #bbb;
}

#tss-clear {
    color: #888;
    background: 0;
    border: 0;
    cursor: pointer;
    font-size: 13px;
    padding: 4px 8px;
    border-radius: 6px;
    flex-shrink: 0;
}

#tss-clear:hover {
    background: #f0f0f0;
    color: #333;
}

/* Cancel: the only close affordance a phone has (no Esc key, and the
   full-screen sheet leaves no backdrop to tap). Hidden on desktop. */
#tss-cancel {
    display: none;
    color: #111;
    background: 0;
    border: 0;
    cursor: pointer;
    font-size: 15px;
    font-weight: 600;
    padding: 8px 4px 8px 10px;
    flex-shrink: 0;
}

/* Sections */
.tss-section {
    padding: 12px 18px 4px;
    border-top: 1px solid #f0f0f0;
}

.tss-section:first-child {
    border-top: 0;
}

.tss-section-label {
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: #999;
    margin-bottom: 6px;
}

.tss-section-body {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding-bottom: 6px;
}

/* Suggestions */
.tss-suggestion {
    display: block;
    width: 100%;
    padding: 8px 10px;
    border: 0;
    background: transparent;
    text-align: left;
    font-size: 15px;
    font-weight: 500;
    color: #111;
    cursor: pointer;
    border-radius: 8px;
}

.tss-suggestion:hover {
    background: #f5f5f5;
}

/* Products */
.tss-product {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 10px;
    text-decoration: none;
    color: inherit;
    border-radius: 8px;
}

.tss-product:hover {
    background: #f5f5f5;
}

.tss-product-img {
    width: 48px;
    height: 48px;
    object-fit: contain;
    border: 1px solid #eee;
    border-radius: 8px;
    flex-shrink: 0;
    background: #fff;
}

.tss-product-copy {
    min-width: 0;
}

.tss-product-title {
    display: block;
    font-size: 14px;
    font-weight: 600;
    color: #111;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.tss-product-price {
    display: block;
    font-size: 13px;
    color: #666;
    margin-top: 2px;
}

.tss-product-price ins {
    text-decoration: none;
}

/* Collections */
.tss-collection {
    display: block;
    padding: 8px 10px;
    font-size: 15px;
    font-weight: 500;
    text-decoration: none;
    color: #111;
    border-radius: 8px;
}

.tss-collection:hover {
    background: #f5f5f5;
    color: #111;
}

/* Footer */
.tss-footer {
    padding: 12px 18px 16px;
    border-top: 1px solid #eee;
}

.tss-view-all {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    padding: 14px;
    background: #9bc400;
    color: #111;
    border: 0;
    border-radius: 12px;
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    text-decoration: none;
}

.tss-view-all:hover {
    background: #85a800;
    color: #111;
}

/* Empty state */
.tss-empty {
    padding: 24px 18px;
    color: #888;
    font-size: 15px;
}

/* Loading skeletons */
.tss-loading {
    padding: 18px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.tss-skeleton {
    height: 14px;
    background: linear-gradient(90deg, #f0f0f0 25%, #e8e8e8 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: tss-shimmer 1.2s infinite;
    border-radius: 6px;
}

.tss-skeleton--short {
    width: 60%;
}

@keyframes tss-shimmer {
    0%   { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* Mobile: a full-screen search takeover, not a floating card.
   85vh measured the layout viewport, which on iOS includes the space under
   the keyboard — the keyboard covered the results. dvh tracks the visible
   viewport instead, and the sheet owns all of it. */
@media (max-width: 640px) {
    #tss-modal {
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        transform: none;
        width: 100%;
        height: 100vh;
        height: 100dvh;
        max-height: none;
        border-radius: 0;
        display: none;
        flex-direction: column;
    }

    #tss-modal.is-open {
        display: flex;
    }

    #tss-input-row {
        position: static;
        padding-top: calc(14px + env(safe-area-inset-top));
    }

    #tss-results {
        flex: 1 1 auto;
        min-height: 0;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        padding-bottom: env(safe-area-inset-bottom);
    }

    #tss-cancel {
        display: block;
    }

    /* Finger-sized rows (44px minimum). */
    .tss-suggestion,
    .tss-collection {
        padding: 12px 10px;
        font-size: 16px;
    }

    .tss-product {
        padding: 10px;
    }

    .tss-product-title {
        font-size: 15px;
        white-space: normal;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
    }

    .tss-footer {
        padding-bottom: calc(16px + env(safe-area-inset-bottom));
    }
}
