/* 車を探す（/car/search/）の画面の組み — templates/car_search.html・partials/car_search_results.html・js/car_search.js。
   PC（1000px 以上）: 左に絞り込み（固定・内側だけスクロール）・右に結果。
   スマホ: 結果が先。上の「絞り込み」で下からシートが開く（JS が無くても #csSheet のチェックで開く）。 */
.cs-top h1 { margin: 6px 0 2px; font-size: 1.7rem; }
.cs-q { display: flex; gap: 8px; margin: 0 0 18px; max-width: 760px; }
.cs-q input { flex: 1; min-width: 0; height: 46px; font: inherit; font-size: 1rem; padding: 0 14px; border: 1px solid var(--line); border-radius: 12px; background: #fff; }
.cs-q input:focus { outline: 3px solid var(--tint); border-color: var(--brand); }
.cs-q .cs-btn { height: 46px; padding: 0 22px; border-radius: 12px; }

.cs-layout { display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: 24px; align-items: start; }
.cs-sheet-toggle, .cs-mbar { display: none; }

/* ---- 絞り込み ---- */
.cs-side { position: sticky; top: 90px; max-height: calc(100vh - 106px); display: flex; flex-direction: column;
  background: var(--card); border: 1px solid var(--line); border-radius: 14px; overflow: hidden; }
.cs-side-h { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.cs-side-h b { font-size: .95rem; }
.cs-side-reset { margin-left: auto; font-size: .8rem; }
.cs-side-x { display: none; }
.cs-side-b { overflow-y: auto; overscroll-behavior: contain; padding: 0 14px 6px; flex: 1; }
.cs-side-f { padding: 10px 14px; border-top: 1px solid var(--line); background: var(--card); }
.js .cs-side-f { display: none; }
.cs-apply { width: 100%; height: 44px; border-radius: 10px; }
.cs-sec { border-bottom: 1px solid var(--line); }
.cs-sec:last-child { border-bottom: 0; }
.cs-sec > summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: 8px; padding: 12px 0; font-weight: 800; font-size: .88rem; color: var(--ink); }
.cs-sec > summary::-webkit-details-marker { display: none; }
.cs-sec > summary::after { content: ""; margin-left: auto; width: 8px; height: 8px; border-right: 2px solid var(--mute); border-bottom: 2px solid var(--mute);
  transform: rotate(45deg); transition: transform .15s; flex: 0 0 auto; }
.cs-sec[open] > summary::after { transform: rotate(-135deg); }
.cs-sec-on { display: inline-flex; align-items: center; justify-content: center; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px;
  background: var(--g); color: #fff; font-size: .7rem; }
.cs-sec-b { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 0 14px; }
.cs-sub-h { flex: 0 0 100%; margin: 6px 0 0; font-size: .76rem; font-weight: 700; color: var(--mute); }

.cs-opt { display: inline-flex; position: relative; }
.cs-opt input { position: absolute; opacity: 0; width: 1px; height: 1px; pointer-events: none; }
.cs-opt span { display: inline-flex; align-items: center; gap: 5px; padding: 5px 10px; border: 1px solid var(--line); border-radius: 999px; font-size: .82rem;
  cursor: pointer; background: #fff; color: var(--ink); line-height: 1.4; transition: background .12s, border-color .12s; }
.cs-opt span:hover { border-color: var(--brand); }
.cs-opt input:checked + span { background: var(--g); border-color: var(--g); color: #fff; }
.cs-opt input:focus-visible + span { outline: 3px solid var(--brand); outline-offset: 1px; }
.cs-n { font-size: .7rem; color: var(--mute); font-variant-numeric: tabular-nums; }
.cs-opt input:checked + span .cs-n { color: rgba(255,255,255,.8); }
.cs-opt.is-zero span { opacity: .45; }
.cs-more { flex: 0 0 100%; }
.cs-more > summary { cursor: pointer; font-size: .8rem; color: var(--g); font-weight: 700; padding: 4px 0; }
.cs-more[open] { display: flex; flex-wrap: wrap; gap: 6px; }
.cs-more[open] > summary { flex: 0 0 100%; }

.cs-range-in { display: flex; align-items: center; gap: 6px; flex: 0 0 100%; font-size: .85rem; }
.cs-range-in label { flex: 1; }
.cs-range-in input, .cs-dim input { width: 100%; height: 36px; font: inherit; font-size: .9rem; padding: 0 8px; border: 1px solid var(--line); border-radius: 8px; background: #fff; }
.cs-dim { display: grid; grid-template-columns: 1fr; gap: 6px; flex: 0 0 100%; }
.cs-dim label { display: grid; grid-template-columns: 3em 1fr auto; align-items: center; gap: 6px; font-size: .85rem; }
.cs-presets { display: flex; flex-wrap: wrap; gap: 6px; }
.cs-preset { display: inline-flex; align-items: center; gap: 5px; font: inherit; font-size: .78rem; padding: 4px 9px; border: 1px solid var(--line); border-radius: 8px;
  background: var(--soft); color: var(--ink); cursor: pointer; justify-self: start; }
.cs-preset:hover { border-color: var(--brand); }
.cs-preset.is-on { background: var(--g); border-color: var(--g); color: #fff; }
.cs-preset.is-on .cs-n { color: rgba(255,255,255,.8); }
.cs-preset.is-zero { opacity: .45; }

/* ---- 結果の列 ---- */
.cs-main { min-width: 0; }
.cs-main.is-loading { opacity: .55; transition: opacity .15s .1s; }
.cs-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; margin: 0 0 10px; }
.cs-count { margin: 0; font-size: .9rem; color: var(--mute); }
.cs-count b { font-size: 1.6rem; color: var(--ink); font-variant-numeric: tabular-nums; margin-right: 2px; }
.cs-count small { font-size: .82rem; }
.cs-range { margin-left: 10px; font-size: .8rem; }
.cs-tools { margin-left: auto; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.cs-sort { display: inline-flex; align-items: center; gap: 6px; font-size: .82rem; color: var(--mute); }
.cs-sort select { height: 36px; font: inherit; font-size: .86rem; color: var(--ink); padding: 0 30px 0 10px; border: 1px solid var(--line); border-radius: 8px;
  background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%235C7280' stroke-width='1.6'/%3E%3C/svg%3E") no-repeat right 10px center;
  appearance: none; -webkit-appearance: none; max-width: 100%; }
.cs-view { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: #fff; }
.cs-view label { position: relative; }
.cs-view input { position: absolute; opacity: 0; pointer-events: none; }
.cs-view span { display: block; padding: 7px 12px; font-size: .8rem; font-weight: 700; color: var(--mute); cursor: pointer; }
.cs-view input:checked + span { background: var(--g); color: #fff; }
.cs-view input:focus-visible + span { outline: 3px solid var(--brand); outline-offset: -3px; }

.cs-chips { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 0 0 10px; }
.cs-chipx { display: inline-flex; align-items: center; gap: 6px; padding: 4px 6px 4px 12px; border-radius: 999px; background: var(--g); color: #fff; font-size: .8rem;
  font-weight: 700; text-decoration: none; }
.cs-chipx:hover { background: var(--g-dark); color: #fff; text-decoration: none; }
.cs-x { display: inline-flex; align-items: center; justify-content: center; width: 18px; height: 18px; border-radius: 50%; background: rgba(255,255,255,.22); font-size: .78rem; }
.cs-clear { font-size: .8rem; margin-left: 4px; }
.cs-quick { display: flex; gap: 6px; margin: 0 0 16px; overflow-x: auto; padding-bottom: 4px; scrollbar-width: thin; }
.cs-qchip { flex: 0 0 auto; padding: 5px 12px; border: 1px solid var(--line); border-radius: 999px; background: #fff; color: var(--ink); font-size: .8rem;
  text-decoration: none; white-space: nowrap; }
.cs-qchip:hover { border-color: var(--brand); color: var(--ink); text-decoration: none; }
.cs-qchip.is-on { background: var(--tint); border-color: var(--g); color: var(--g); font-weight: 700; }
.cs-qchip.is-on::before { content: "✓ "; }
.vh { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }


.cs-empty { padding: 26px 22px; border: 1px dashed var(--line); border-radius: 14px; background: var(--card); }
.cs-empty p { margin: 0 0 10px; }
.cs-relax { list-style: none; margin: 0 0 12px; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.cs-relax a { display: inline-flex; gap: 8px; align-items: center; padding: 6px 12px; border: 1px solid var(--line); border-radius: 999px; background: #fff; text-decoration: none; font-size: .85rem; }
.cs-relax b { color: var(--g); }

/* 表で見る: 車種の列を左に固定 */
.cs-tbl-wrap { border-radius: 12px; }
.cs-tbl th[scope="row"] { position: sticky; left: 0; z-index: 1; background: var(--card); min-width: 190px; color: var(--ink); white-space: normal; }
.cs-tbl thead th:first-child { position: sticky; left: 0; z-index: 2; }
.cs-tbl th[scope="row"] a { display: flex; gap: 8px; align-items: center; color: inherit; text-decoration: none; }
.cs-tbl th[scope="row"] a:hover b { color: var(--g); text-decoration: underline; }
.cs-tbl th[scope="row"] small { display: block; font-size: .7rem; color: var(--mute); font-weight: 500; }
.cs-tbl th[scope="row"] b { font-size: .88rem; }
.cs-tbl-ph { flex: 0 0 64px; height: 43px; border-radius: 6px; overflow: hidden; background: var(--soft); }
.cs-tbl-ph img { width: 100%; height: 100%; object-fit: contain; display: block; }
.cs-tbl td { white-space: nowrap; font-variant-numeric: tabular-nums; vertical-align: middle; }
.cs-tbl tbody tr:hover td, .cs-tbl tbody tr:hover th { background: var(--soft); }

@media (max-width: 1180px) {
  .cs-layout { grid-template-columns: 270px minmax(0, 1fr); gap: 18px; }
}
/* ---- スマホ・タブレット: 結果が先・絞り込みはシート ---- */
@media (max-width: 999.98px) {
  .cs-top h1 { font-size: 1.4rem; }
  .cs-q { margin-bottom: 10px; }
  .cs-layout { display: block; }
  .cs-mbar { display: flex; align-items: center; gap: 12px; position: sticky; top: 62px; z-index: 20; margin: 0 -18px 12px; padding: 8px 18px;
    background: rgba(238,243,247,.94); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); border-bottom: 1px solid var(--line); }
  .cs-mbtn { display: inline-flex; align-items: center; gap: 8px; height: 40px; padding: 0 16px; border-radius: 10px; background: var(--g); color: #fff;
    font-weight: 800; font-size: .9rem; cursor: pointer; }
  .cs-mbtn::before { content: ""; width: 14px; height: 10px; border-top: 2px solid #fff; border-bottom: 2px solid #fff; box-sizing: border-box;
    background: linear-gradient(#fff, #fff) center / 8px 2px no-repeat; }
  .cs-mbadge { display: inline-flex; align-items: center; justify-content: center; min-width: 20px; height: 20px; border-radius: 10px; background: #fff;
    color: var(--g); font-size: .72rem; padding: 0 5px; }
  .cs-mcount { font-size: .85rem; color: var(--mute); }
  .cs-mcount b { color: var(--ink); font-size: 1.05rem; }
  .cs-side { display: none; position: fixed; inset: 0; top: 0; z-index: 1100; max-height: none; border-radius: 0; border: 0; }
  .cs-sheet-toggle:checked ~ .cs-layout .cs-side { display: flex; animation: cs-up .2s ease-out; }
  .cs-side-x { display: inline-flex; align-items: center; justify-content: center; width: 36px; height: 36px; border-radius: 50%; background: var(--soft);
    font-size: 1.2rem; cursor: pointer; margin-left: 6px; }
  .cs-side-f, .js .cs-side-f { display: block; padding-bottom: calc(10px + env(safe-area-inset-bottom)); }
  .cs-head { margin-bottom: 8px; }
  .cs-count { display: none; }   /* 件数は上の固定の帯に出ている */
  .cs-tools { margin-left: 0; width: 100%; }
  .cs-sort { flex: 1; }
  .cs-sort span { display: none; }
  .cs-sort select { width: 100%; }
  html.cs-lock, html.cs-lock body { overflow: hidden; }
}
@media (max-width: 560px) {
  .cs-range { display: none; }
}
@keyframes cs-up { from { transform: translateY(24px); opacity: 0; } to { transform: none; opacity: 1; } }
@media (prefers-reduced-motion: reduce) {
  .cs-card-a, .cs-sec > summary::after { transition: none; }
  .cs-sheet-toggle:checked ~ .cs-layout .cs-side { animation: none; }
}
