/* =====================================================================
   Listing (shop, category, search, saved)
   ===================================================================== */
.tm-listing { padding-bottom: 20px; }
.tm-listing__head { margin: 4px 0 18px; }
.tm-listing__t { font-size: 30px; font-weight: 800; letter-spacing: -.015em; line-height: 1.15; }
.tm-listing__s { margin-top: 6px; max-width: 72ch; color: var(--muted); }
.tm-listing__grid { display: grid; grid-template-columns: 264px minmax(0, 1fr); gap: 32px; align-items: start; }

/* Rail */
.tm-rail {
  position: sticky; top: calc(var(--mast-h) + 16px);
  max-height: calc(100vh - var(--mast-h) - 32px);
  display: flex; flex-direction: column;
  border: 1px solid var(--line); border-radius: var(--r-lg);
  background: #fff;
}
.tm-rail__head { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.tm-rail__t { display: inline-flex; align-items: center; gap: 8px; font-size: 16px; font-weight: 800; }
.tm-rail__clear { margin-left: auto; font-size: 14px; font-weight: 600; text-decoration: underline; text-underline-offset: 2px; }
.tm-rail__x { display: none; }
.tm-rail__body { overflow-y: auto; padding: 0 16px; overscroll-behavior: contain; scrollbar-width: thin; }
.tm-rail__foot { display: none; }

.tm-facet { border-bottom: 1px solid var(--line-2); }
.tm-facet:last-child { border-bottom: 0; }
.tm-facet > summary {
  display: flex; align-items: center; gap: 8px;
  padding: 14px 0; list-style: none; cursor: pointer;
  font-size: 15px; font-weight: 800;
}
.tm-facet > summary::-webkit-details-marker { display: none; }
.tm-facet > summary > span:first-child { flex: 1; }
.tm-facet > summary > .tm-i { transition: transform .2s ease; color: var(--muted); }
.tm-facet[open] > summary > .tm-i { transform: rotate(180deg); }
.tm-facet__n { display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 5px; border-radius: 10px; background: var(--ink); color: #fff; font-size: 12px; }
.tm-facet__body { padding: 0 0 14px; }
.tm-opt { display: flex; align-items: center; gap: 10px; padding: 6px 0; font-size: 14.5px; color: var(--ink-2); }
.tm-opt:hover { color: var(--ink); }
.tm-opt:hover .tm-opt__box { border-color: var(--ink); }
.tm-opt__box {
  width: 20px; height: 20px; flex-shrink: 0;
  border: 1.5px solid var(--line-3); border-radius: 6px;
  display: grid; place-items: center; color: transparent; background: #fff;
}
.tm-opt.is-on .tm-opt__box { background: var(--brand); border-color: var(--brand); color: #fff; }
.tm-opt.is-on { color: var(--ink); font-weight: 700; }
.tm-opt__txt { flex: 1; min-width: 0; }
.tm-opt__n { font-size: 13px; color: var(--faint); }
.tm-opt--radio .tm-opt__box { border-radius: 50%; }
.tm-opt--radio.is-on .tm-opt__box { background: #fff; border: 6px solid var(--brand); }

.tm-facet__body--chips { display: flex; flex-wrap: wrap; gap: 6px; }
.tm-facet__body--chips .tm-opt { padding: 0 10px; height: 32px; border: 1px solid var(--line-3); border-radius: var(--pill); font-size: 13.5px; gap: 5px; }
.tm-facet__body--chips .tm-opt__box { display: none; }
.tm-facet__body--chips .tm-opt__txt { flex: none; }
.tm-facet__body--chips .tm-opt__n { font-size: 12px; }
.tm-facet__body--chips .tm-opt.is-on { background: var(--ink); border-color: var(--ink); color: #fff; }
.tm-facet__body--chips .tm-opt.is-on .tm-opt__n { color: rgba(255, 255, 255, .7); }

.tm-price { display: flex; align-items: center; gap: 6px; margin-top: 10px; }
.tm-price label { position: relative; flex: 1; min-width: 0; }
.tm-price label > span[aria-hidden] { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--muted); font-size: 14px; }
.tm-price input {
  width: 100%; height: 38px; padding: 0 8px 0 22px;
  border: 1px solid var(--line-3); border-radius: var(--r-sm);
  font-size: 16px; -moz-appearance: textfield;
}
.tm-price input::-webkit-inner-spin-button, .tm-price input::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.tm-price__to { font-size: 13px; color: var(--muted); }
.tm-price .tm-btn { height: 38px; padding: 0 12px; }

/* Results */
.tm-results { min-width: 0; }
.tm-results__bar { display: flex; align-items: center; gap: 10px; }
.tm-pill--filter { display: none; flex-shrink: 0; }
.tm-chips { display: flex; gap: 8px; min-width: 0; overflow-x: auto; scrollbar-width: none; padding: 2px; }
.tm-chips::-webkit-scrollbar { display: none; }
.tm-sort { display: flex; align-items: center; gap: 8px; margin-left: auto; flex-shrink: 0; }
.tm-sort label { font-size: 14px; color: var(--muted); white-space: nowrap; }
.tm-sort select {
  height: 38px; padding: 0 34px 0 14px;
  border: 1px solid var(--line-3); border-radius: var(--pill);
  background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23191816' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") no-repeat right 14px center;
  font-size: 14px; font-weight: 600;
  -webkit-appearance: none; appearance: none;
}
.tm-results__count { margin: 14px 0 6px; font-size: 14px; color: var(--muted); }
.tm-results__count strong { color: var(--ink); }

.tm-active { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 4px 0 16px; }
.tm-active__clear { font-size: 14px; font-weight: 600; text-decoration: underline; text-underline-offset: 2px; margin-left: 4px; }

.tm-grid--results { grid-template-columns: repeat(4, minmax(0, 1fr)); margin-top: 14px; }
@media (max-width: 1250px) { .tm-grid--results { grid-template-columns: repeat(3, minmax(0, 1fr)); } }

/* Pager */
.tm-pager { display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 6px; margin: 40px 0 8px; }
.tm-pager__n, .tm-pager__step, .tm-pager--plain .page-numbers {
  display: inline-flex; align-items: center; justify-content: center; gap: 4px;
  min-width: 42px; height: 42px; padding: 0 12px;
  border-radius: var(--pill); font-size: 15px; font-weight: 600;
}
.tm-pager__n:hover, .tm-pager__step:hover, .tm-pager--plain a.page-numbers:hover { background: var(--soft); }
.tm-pager__n.is-on, .tm-pager--plain .page-numbers.current { background: var(--brand); color: #fff; }
.tm-pager__step { border: 1px solid var(--line-3); }
.tm-pager__gap { color: var(--faint); padding: 0 2px; }

/* ---------- Phones / tablets: rail becomes a sheet ---------- */
@media (max-width: 1000px) {
  .tm-listing__grid { grid-template-columns: 1fr; gap: 0; }
  .tm-listing__t { font-size: 24px; }
  .tm-pill--filter { display: inline-flex; }
  .tm-rail {
    position: fixed; top: 0; bottom: 0; left: 0; z-index: 300;
    width: min(92vw, 400px); max-height: none;
    border: 0; border-radius: 0;
    transform: translateX(-102%); transition: transform .26s cubic-bezier(.2, .8, .2, 1);
    box-shadow: var(--sh-3);
  }
  .tm-rail.is-open { transform: none; }
  .tm-rail__head { padding: 10px 10px 10px 18px; }
  .tm-rail__x { display: grid; place-items: center; width: 44px; height: 44px; margin-left: auto; border: 0; border-radius: 50%; background: var(--soft); }
  .tm-rail__clear ~ .tm-rail__x { margin-left: 10px; }
  .tm-rail__clear { margin-left: auto; }
  .tm-rail__body { flex: 1; padding: 0 18px; }
  .tm-rail__foot { display: block; padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); }
  .tm-opt { min-height: 40px; }
  .tm-facet__body--chips .tm-opt { min-height: 36px; }
  .tm-results__bar { flex-wrap: wrap; }
  .tm-chips { order: 3; flex: 0 0 calc(100% + 2 * var(--gut)); max-width: none; margin: 0 calc(var(--gut) * -1); padding: 2px var(--gut); }
  .tm-sort label { display: none; }
}
@media (max-width: 1000px) and (min-width: 761px) { .tm-grid--results { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 760px) {
  .tm-grid--results { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tm-pager__step span { display: none; }
}

.js-rail:focus, .js-drawer:focus { outline: none; }
