:root {
    --ns-primary: var(--primary, #4f46e5);
    --ns-primary-strong: #3730a3;
    --ns-surface: var(--surface, #ffffff);
    --ns-surface-soft: #f7f7fb;
    --ns-text: var(--text, #17171c);
    --ns-muted: #6b7280;
    --ns-border: #e5e7eb;
    --ns-danger: #b42318;
    --ns-success: #087a47;
    --ns-radius: 16px;
    --ns-shadow: 0 18px 50px rgb(15 23 42 / 12%);
}

@media (prefers-color-scheme: dark) {
    :root {
        --ns-surface: #17171c;
        --ns-surface-soft: #222229;
        --ns-text: #f8fafc;
        --ns-muted: #a8a8b3;
        --ns-border: #363640;
        --ns-shadow: 0 20px 60px rgb(0 0 0 / 35%);
    }
}

[data-theme="dark"] {
    --ns-surface: #17171c;
    --ns-surface-soft: #222229;
    --ns-text: #f8fafc;
    --ns-muted: #a8a8b3;
    --ns-border: #363640;
}

* { box-sizing: border-box; }
.ns-page {
    margin: 0;
    min-height: 100vh;
    color: var(--ns-text);
    background: var(--ns-surface-soft);
    font-family: IRANSansX, Vazirmatn, Tahoma, sans-serif;
}
.ns-container { width: min(1240px, calc(100% - 32px)); margin-inline: auto; }
.ns-sr-only {
    position: absolute !important;
    width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}
.ns-skip-link {
    position: fixed; inset-block-start: 8px; inset-inline-start: 8px;
    z-index: 1000; transform: translateY(-150%);
    padding: 10px 16px; border-radius: 10px;
    color: #fff; background: var(--ns-primary);
}
.ns-skip-link:focus { transform: none; }
.ns-page__header {
    position: sticky; inset-block-start: 0; z-index: 30;
    padding-block: 18px; background: color-mix(in srgb, var(--ns-surface) 92%, transparent);
    border-block-end: 1px solid var(--ns-border); backdrop-filter: blur(14px);
}
.ns-search-box { position: relative; max-width: 840px; margin-inline: auto; }
.ns-search-box__form {
    display: flex; align-items: center; min-height: 56px;
    border: 1px solid var(--ns-border); border-radius: 18px;
    background: var(--ns-surface); box-shadow: 0 4px 18px rgb(15 23 42 / 5%);
}
.ns-search-box__form:focus-within {
    border-color: var(--ns-primary);
    box-shadow: 0 0 0 4px color-mix(in srgb, var(--ns-primary) 16%, transparent);
}
.ns-search-box__icon { display: grid; place-items: center; padding-inline-start: 18px; color: var(--ns-muted); }
.ns-search-box__input {
    flex: 1; min-width: 0; padding: 14px 12px; border: 0; outline: 0;
    color: var(--ns-text); background: transparent; font: inherit; font-size: 1rem;
}
.ns-search-box__input::-webkit-search-cancel-button { display: none; }
.ns-search-box__clear {
    width: 38px; height: 38px; border: 0; border-radius: 50%;
    color: var(--ns-muted); background: transparent; font-size: 24px; cursor: pointer;
}
.ns-search-box__clear:hover { background: var(--ns-surface-soft); }
.ns-search-box__submit, .ns-button {
    min-height: 42px; padding: 9px 18px; border: 1px solid var(--ns-border);
    border-radius: 12px; color: var(--ns-text); background: var(--ns-surface);
    font: inherit; font-weight: 700; text-decoration: none; cursor: pointer;
}
.ns-search-box__submit {
    margin-inline-end: 7px; color: #fff; border-color: var(--ns-primary);
    background: var(--ns-primary);
}
.ns-search-box__submit:hover, .ns-button--primary:hover { background: var(--ns-primary-strong); }
.ns-button--primary { color: #fff; border-color: var(--ns-primary); background: var(--ns-primary); }
.ns-button:disabled { opacity: .6; cursor: wait; }
.ns-search-box__spinner {
    width: 20px; height: 20px; border: 2px solid var(--ns-border);
    border-block-start-color: var(--ns-primary); border-radius: 50%;
    animation: ns-spin .7s linear infinite;
}
@keyframes ns-spin { to { transform: rotate(360deg); } }
.ns-autocomplete {
    position: absolute; inset-block-start: calc(100% + 8px); inset-inline: 0;
    z-index: 50; max-height: min(70vh, 560px); overflow: auto;
    padding: 8px; border: 1px solid var(--ns-border); border-radius: var(--ns-radius);
    background: var(--ns-surface); box-shadow: var(--ns-shadow);
}
.ns-autocomplete__group + .ns-autocomplete__group { border-block-start: 1px solid var(--ns-border); }
.ns-autocomplete__heading { display: flex; align-items: center; justify-content: space-between; }
.ns-autocomplete__heading h3 {
    margin: 0; padding: 12px 12px 6px; color: var(--ns-muted);
    font-size: .76rem; font-weight: 800;
}
.ns-autocomplete__heading button {
    min-height: 36px; padding: 6px 10px; border: 0; color: var(--ns-danger);
    background: transparent; font: inherit; font-size: .74rem; cursor: pointer;
}
.ns-autocomplete__recent { display: flex; align-items: center; }
.ns-autocomplete__recent .ns-autocomplete__option { flex: 1; min-width: 0; }
.ns-autocomplete__remove {
    width: 40px; height: 40px; border: 0; border-radius: 50%;
    color: var(--ns-muted); background: transparent; font-size: 22px; cursor: pointer;
}
.ns-autocomplete__remove:hover { color: var(--ns-danger); background: var(--ns-surface-soft); }
.ns-autocomplete__option {
    display: flex; align-items: center; gap: 12px; min-height: 52px;
    padding: 8px 12px; border-radius: 10px; color: var(--ns-text); text-decoration: none;
}
.ns-autocomplete__option:hover,
.ns-autocomplete__option[aria-selected="true"] { background: var(--ns-surface-soft); }
.ns-autocomplete__option img {
    width: 44px; height: 44px; border-radius: 9px; object-fit: cover; background: var(--ns-surface-soft);
}
.ns-autocomplete__content { display: flex; flex: 1; min-width: 0; flex-direction: column; }
.ns-autocomplete__content strong,
.ns-autocomplete__content small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ns-autocomplete__content small { color: var(--ns-muted); }
.ns-autocomplete__price { color: var(--ns-primary); white-space: nowrap; }
.ns-results { padding-block: 34px 72px; }
.ns-results__heading {
    display: flex; align-items: end; justify-content: space-between; gap: 24px; margin-block-end: 22px;
}
.ns-results__heading h1 { margin: 2px 0 6px; font-size: clamp(1.35rem, 3vw, 2rem); }
.ns-results__heading p { margin: 0; color: var(--ns-muted); }
.ns-results__eyebrow { color: var(--ns-primary) !important; font-size: .82rem; font-weight: 800; }
.ns-results__tools { display: flex; align-items: center; gap: 10px; }
.ns-select {
    min-height: 42px; padding-inline: 12px 34px; border: 1px solid var(--ns-border);
    border-radius: 12px; color: var(--ns-text); background: var(--ns-surface); font: inherit;
}
.ns-view-toggle { display: flex; padding: 3px; border: 1px solid var(--ns-border); border-radius: 12px; background: var(--ns-surface); }
.ns-view-toggle button {
    width: 36px; height: 34px; border: 0; border-radius: 9px; color: var(--ns-muted);
    background: transparent; cursor: pointer;
}
.ns-view-toggle button[aria-pressed="true"] { color: var(--ns-primary); background: var(--ns-surface-soft); }
.ns-correction, .ns-applied {
    margin-block-end: 16px; padding: 14px 16px; border: 1px solid var(--ns-border);
    border-radius: 13px; background: var(--ns-surface);
}
.ns-correction a { color: var(--ns-primary); font-weight: 800; }
.ns-applied { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.ns-chip-list { display: flex; flex-wrap: wrap; gap: 8px; }
.ns-chip {
    display: inline-flex; align-items: center; gap: 8px; min-height: 36px; padding: 6px 12px;
    border: 1px solid var(--ns-border); border-radius: 999px; color: var(--ns-text);
    background: var(--ns-surface); text-decoration: none;
}
.ns-chip--active { border-color: color-mix(in srgb, var(--ns-primary) 35%, var(--ns-border)); }
.ns-clear-filters { margin-inline-start: auto; color: var(--ns-danger); }
.ns-results__layout { display: grid; grid-template-columns: 250px minmax(0, 1fr); gap: 24px; align-items: start; }
.ns-filters {
    position: sticky; inset-block-start: 108px; max-height: calc(100vh - 130px); overflow: auto;
    padding: 18px; border: 1px solid var(--ns-border); border-radius: var(--ns-radius);
    background: var(--ns-surface);
}
.ns-filters__header { display: flex; align-items: center; justify-content: space-between; }
.ns-filters__header h2 { margin: 0; font-size: 1.08rem; }
.ns-filters__header button { display: none; border: 0; color: var(--ns-text); background: transparent; font-size: 26px; }
.ns-facet { margin: 18px 0 0; padding: 16px 0 0; border: 0; border-block-start: 1px solid var(--ns-border); }
.ns-facet legend { padding: 0; font-weight: 800; }
.ns-check { display: flex; align-items: center; gap: 9px; min-height: 40px; cursor: pointer; }
.ns-check input { width: 18px; height: 18px; accent-color: var(--ns-primary); }
.ns-check span { flex: 1; }
.ns-check small { color: var(--ns-muted); }
.ns-price-filter { display: grid; grid-template-columns: 28px 1fr; align-items: center; gap: 8px; margin-block-start: 9px; }
.ns-price-filter input {
    width: 100%; min-height: 40px; padding: 8px 10px; border: 1px solid var(--ns-border);
    border-radius: 10px; color: var(--ns-text); background: var(--ns-surface); font: inherit;
}
.ns-filters__apply { width: 100%; margin-block-start: 18px; }
.ns-filter-toggle { display: none; }
.ns-filter-backdrop { display: none; }
.ns-result-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; }
.ns-result-card {
    min-width: 0; overflow: hidden; border: 1px solid var(--ns-border);
    border-radius: var(--ns-radius); background: var(--ns-surface);
    transition: transform .18s ease, box-shadow .18s ease;
}
.ns-result-card:hover { transform: translateY(-2px); box-shadow: var(--ns-shadow); }
.ns-result-card__media {
    position: relative; display: grid; place-items: center; aspect-ratio: 4 / 3;
    overflow: hidden; color: var(--ns-muted); background: var(--ns-surface-soft);
}
.ns-result-card__media img { width: 100%; height: 100%; object-fit: cover; transition: transform .25s ease; }
.ns-result-card:hover .ns-result-card__media img { transform: scale(1.025); }
.ns-badge { position: absolute; inset-block-start: 10px; inset-inline-start: 10px; padding: 5px 8px; border-radius: 8px; }
.ns-badge--discount { color: #fff; background: var(--ns-danger); }
.ns-result-card__body { display: flex; min-height: 260px; padding: 16px; flex-direction: column; }
.ns-result-card__meta { display: flex; gap: 8px; color: var(--ns-muted); font-size: .78rem; }
.ns-result-card__meta span + span::before { content: "•"; margin-inline-end: 8px; }
.ns-result-card h2 { margin: 8px 0; font-size: 1rem; line-height: 1.8; }
.ns-result-card h2 a { color: var(--ns-text); text-decoration: none; }
mark { padding: 0 2px; border-radius: 3px; color: inherit; background: #fde68a; }
.ns-result-card__excerpt {
    display: -webkit-box; margin: 0 0 12px; overflow: hidden; color: var(--ns-muted);
    font-size: .86rem; line-height: 1.8; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
}
.ns-rating { margin: 0; color: #d97706; font-size: .86rem; }
.ns-result-card__footer { display: flex; align-items: end; justify-content: space-between; gap: 12px; margin-block-start: auto; }
.ns-price { display: flex; align-items: baseline; flex-wrap: wrap; gap: 5px; }
.ns-price del { width: 100%; color: var(--ns-muted); font-size: .78rem; }
.ns-price strong { font-size: 1.08rem; }
.ns-price small { color: var(--ns-muted); }
.ns-stock { color: var(--ns-danger); font-size: .78rem; font-weight: 800; }
.ns-stock--yes { color: var(--ns-success); }
.ns-result-card__actions { display: flex; gap: 8px; margin-block-start: 14px; }
.ns-result-card__actions > * { flex: 1; text-align: center; }
.ns-result-grid[data-view-mode="list"] { grid-template-columns: 1fr; }
.ns-result-grid[data-view-mode="list"] .ns-result-card { display: grid; grid-template-columns: minmax(180px, 260px) 1fr; }
.ns-result-grid[data-view-mode="list"] .ns-result-card__body { min-height: 220px; }
.ns-pagination { display: flex; align-items: center; justify-content: center; gap: 18px; margin-block-start: 28px; }
.ns-pagination a { padding: 9px 15px; border: 1px solid var(--ns-border); border-radius: 10px; color: var(--ns-text); background: var(--ns-surface); text-decoration: none; }
.ns-welcome, .ns-empty {
    max-width: 760px; margin: 30px auto; padding: clamp(28px, 6vw, 64px);
    border: 1px solid var(--ns-border); border-radius: 24px; text-align: center; background: var(--ns-surface);
}
.ns-welcome h1, .ns-empty h2 { margin: 8px 0; }
.ns-welcome > p, .ns-empty > p { color: var(--ns-muted); }
.ns-empty__icon { color: var(--ns-primary); font-size: 4rem; line-height: 1; }
.ns-empty__actions { display: flex; justify-content: center; flex-wrap: wrap; gap: 8px; margin-block: 22px; }
.ns-discovery { margin-block-start: 28px; }
.ns-discovery h2, .ns-discovery h3 { font-size: 1rem; }
.ns-toast {
    position: fixed; inset-inline-start: 50%; inset-block-end: 24px; z-index: 100;
    transform: translateX(-50%); max-width: calc(100vw - 32px); padding: 12px 18px;
    border-radius: 12px; color: #fff; background: var(--ns-success); box-shadow: var(--ns-shadow);
}
.ns-toast[data-error="true"] { background: var(--ns-danger); }
.ns-page-loading .ns-results { opacity: .55; pointer-events: none; }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--ns-primary) 55%, white); outline-offset: 2px; }

@media (max-width: 960px) {
    .ns-result-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .ns-results__layout { grid-template-columns: 1fr; }
    .ns-filter-toggle { display: inline-flex; }
    .ns-filters {
        position: fixed; inset-block: 0; inset-inline-start: 0; z-index: 80;
        width: min(88vw, 360px); max-height: 100vh; border-radius: 0;
        transform: translateX(110%); transition: transform .22s ease;
    }
    [dir="ltr"] .ns-filters { transform: translateX(-110%); }
    .ns-filters-open .ns-filters { transform: none; }
    .ns-filters__header button { display: block; }
    .ns-filter-backdrop {
        position: fixed; inset: 0; z-index: 70; border: 0; background: rgb(0 0 0 / 45%);
    }
    .ns-filters-open .ns-filter-backdrop { display: block; }
    .ns-filters-open { overflow: hidden; }
}

@media (max-width: 640px) {
    .ns-container { width: min(100% - 20px, 1240px); }
    .ns-page__header { padding-block: 10px; }
    .ns-search-box__submit { padding-inline: 12px; }
    .ns-results { padding-block-start: 22px; }
    .ns-results__heading { align-items: stretch; flex-direction: column; }
    .ns-results__tools { position: sticky; inset-block-start: 76px; z-index: 20; padding-block: 8px; background: var(--ns-surface-soft); }
    .ns-select { flex: 1; min-width: 0; }
    .ns-view-toggle { display: none; }
    .ns-result-grid { grid-template-columns: 1fr; }
    .ns-result-grid[data-view-mode="list"] .ns-result-card { grid-template-columns: 120px 1fr; }
    .ns-result-grid[data-view-mode="list"] .ns-result-card__body { min-height: 0; padding: 12px; }
    .ns-result-grid[data-view-mode="list"] .ns-result-card__excerpt,
    .ns-result-grid[data-view-mode="list"] .ns-result-card__actions { display: none; }
    .ns-search-mobile-open { overflow: hidden; }
    .ns-search-mobile-open [data-search-root] {
        position: fixed; inset: 0; z-index: 110; padding: 10px; background: var(--ns-surface);
    }
    .ns-search-mobile-open .ns-page__header { position: fixed; inset: 0; z-index: 100; padding: 10px; background: var(--ns-surface); }
    .ns-search-mobile-open .ns-page__header .ns-container { width: 100%; }
    .ns-search-mobile-open [data-search-root] .ns-autocomplete {
        position: fixed; inset: 76px 0 0; max-height: none; border-width: 1px 0 0; border-radius: 0; box-shadow: none;
    }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
