/* 詳細検索の画面(Phase 6A 工程2)。商品カードのスタイルは card.css(商品カード試作の複製・無変更)を使い、ここでは画面の配置だけを定める。
 * 幅の切り替え(サイトの既存CSSは、900px以下で本文・サイドバーが縦並びになる):
 *   1000px以上      : 左に条件(260px)+右に商品4列
 *   900〜999px      : 左に条件(240px)+右に商品3列(4列だとカード幅が約140pxになり、レーダーと商品名が窮屈になるため)
 *   600〜899px      : 条件は上部の「絞り込み」から展開 + 商品3列
 *   600px未満(スマホ): 条件は上部の「絞り込み」から展開 + 商品2列
 */
:root { --ds-bg: #f3f4f8; --ds-line: #d3d7e2; --ds-accent: #164A80; --ds-accent-bg: #e8f2ff; --ds-muted: #566074; --ds-focus: #0b5fff; --cols: 4; }
* { box-sizing: border-box; }
body { margin: 0; background: var(--ds-bg); color: #222; font-family: "メイリオ", Meiryo, "ヒラギノ角ゴ Pro W3", "Hiragino Kaku Gothic Pro", sans-serif; font-size: 15px; line-height: 1.5; }
[hidden] { display: none !important; }
.skip { position: absolute; left: -9999px; top: 0; }
.skip:focus { left: 8px; top: 8px; z-index: 100; background: #fff; padding: 8px 12px; border: 2px solid var(--ds-focus); }
button, input, select { font: inherit; }
:focus-visible { outline: 3px solid var(--ds-focus); outline-offset: 2px; }

/* 検証用データの表示(常に見える。本番のデータではないことを明示) */
.ds-testbar { background: #fff3cd; border-bottom: 1px solid #e0c060; padding: 6px 12px; font-size: 12.5px; display: flex; flex-wrap: wrap; gap: 4px 16px; align-items: center; }
.ds-testbar p { margin: 0; flex: 1 1 320px; }
.ds-dsel { display: flex; align-items: center; gap: 6px; min-width: 0; max-width: 100%; }
.ds-dsel select { min-width: 0; max-width: 100%; flex: 1 1 auto; }
.ds-head h1 { font-size: 18px; margin: 8px 12px 4px; max-width: 1200px; }
.ds-head h1 small { font-size: 12px; color: var(--ds-muted); font-weight: normal; }

.ds-search { display: flex; gap: 8px; align-items: center; padding: 8px 12px; background: #fff; border-bottom: 1px solid var(--ds-line); position: sticky; top: 0; z-index: 20; }
.ds-search input[type=search] { flex: 1 1 auto; min-width: 0; min-height: 44px; padding: 6px 12px; border: 1px solid #9aa3b5; border-radius: 6px; background: #fff; }
.ds-btn { min-height: 44px; padding: 6px 14px; border: 1px solid var(--ds-accent); background: #fff; color: var(--ds-accent); border-radius: 6px; cursor: pointer; white-space: nowrap; }
.ds-btn:hover { background: var(--ds-accent-bg); }
.ds-primary { background: var(--ds-accent); color: #fff; }
.ds-primary:hover { background: #0f3a66; }
#filterCount { margin-left: 4px; }

.ds-layout { display: grid; grid-template-columns: 260px minmax(0, 1fr); gap: 16px; padding: 12px; max-width: 1200px; margin: 0 auto; align-items: start; }
.ds-filters { background: #fff; border: 1px solid var(--ds-line); border-radius: 8px; padding: 10px; position: sticky; top: 68px; max-height: calc(100vh - 80px); overflow: auto; }
.ds-fhead { display: flex; align-items: center; justify-content: space-between; }
.ds-fhead h2 { font-size: 16px; margin: 0; }
.ds-close, .ds-ffoot { display: none; }
.ds-fnote { font-size: 12px; color: var(--ds-muted); margin: 6px 0 8px; }

/* 条件(項目ごとの開閉) */
.facet { border-top: 1px solid var(--ds-line); }
.facet > summary { cursor: pointer; padding: 8px 4px; min-height: 40px; display: flex; align-items: center; gap: 6px; font-weight: bold; list-style: none; }
.facet > summary::-webkit-details-marker { display: none; }
.facet > summary::before { content: "▸"; font-size: 12px; color: var(--ds-muted); }
.facet[open] > summary::before { content: "▾"; }
.facet .sel { margin-left: auto; font-weight: normal; font-size: 12px; color: #fff; background: var(--ds-accent); border-radius: 10px; padding: 0 8px; }
.facet .scope { font-weight: normal; font-size: 11px; color: var(--ds-muted); }
.opts { list-style: none; margin: 0 0 8px; padding: 0 0 0 4px; }
.opt { display: flex; align-items: center; gap: 8px; min-height: 36px; padding: 2px 4px; cursor: pointer; border-radius: 4px; }
.opt:hover { background: #f1f4fb; }
.opt input { width: 20px; height: 20px; flex: none; margin: 0; }
.opt .lbl { flex: 1 1 auto; min-width: 0; overflow-wrap: anywhere; }
.opt .grp { color: var(--ds-muted); font-size: 11px; }
.opt .cnt { flex: none; color: var(--ds-muted); font-size: 13px; font-variant-numeric: tabular-nums; }
.opt.is-zero { opacity: .5; cursor: default; }
.opt.is-extra { display: none; }
.facet.show-extra .opt.is-extra, .opt.is-extra.is-selected { display: flex; }
.fmore { margin: 0 0 8px 4px; padding: 2px 10px; min-height: 32px; border: 1px solid var(--ds-line); background: #fff; border-radius: 4px; cursor: pointer; font-size: 13px; }
.fsearch { width: calc(100% - 8px); margin: 0 4px 6px; min-height: 34px; padding: 4px 8px; border: 1px solid #9aa3b5; border-radius: 4px; }
.unk { margin: 0 0 8px 8px; font-size: 12px; color: var(--ds-muted); }
.axisgroup { margin-top: 8px; border-top: 2px solid var(--ds-line); padding-top: 4px; }
.axisgroup > h3 { font-size: 13px; margin: 6px 4px 0; color: var(--ds-muted); }

/* 結果の見出し・件数・並べ替え */
.ds-h2 { font-size: 16px; margin: 0 0 6px; }
.ds-toolbar { display: flex; flex-wrap: wrap; gap: 6px 16px; align-items: center; justify-content: space-between; margin-bottom: 4px; }
.ds-count { margin: 0; font-weight: bold; }
.ds-sort { display: flex; align-items: center; gap: 6px; }
.ds-sort label { white-space: nowrap; }
.ds-sort select { min-height: 44px; max-width: 100%; padding: 4px 8px; border: 1px solid #9aa3b5; border-radius: 6px; background: #fff; }
.ds-sortchip { width: 14px; height: 14px; border-radius: 50%; flex: none; }
.ds-hint { margin: 0 0 8px; font-size: 12px; color: var(--ds-muted); min-height: 1px; }

/* 選択中の条件タグ: タグの中では改行しない(タグ単位で折り返す)。長い名前は省略記号 */
.ds-tagbar { margin: 4px 0 10px; }
.ds-taglist { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.ds-taglist > li { flex: 0 1 auto; max-width: 100%; display: flex; }
.ds-tag { display: inline-flex; align-items: center; gap: 6px; max-width: 100%; min-height: 36px; padding: 2px 6px 2px 12px; border: 1px solid var(--ds-accent); background: var(--ds-accent-bg); color: var(--ds-accent); border-radius: 18px; cursor: pointer; white-space: nowrap; overflow: hidden; }
.ds-tag .t { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.ds-tag .x { flex: none; width: 24px; height: 24px; line-height: 22px; text-align: center; border-radius: 50%; background: #fff; font-weight: bold; }
.ds-tag:hover { background: #d4e6ff; }
.ds-tagmore { min-height: 36px; padding: 2px 12px; border: 1px dashed var(--ds-accent); background: #fff; color: var(--ds-accent); border-radius: 18px; cursor: pointer; white-space: nowrap; }
.ds-tagactions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.ds-tagactions .ds-btn { min-height: 40px; }
.ds-notices { margin: 0 0 10px; padding: 8px 12px; background: #fff8e1; border: 1px solid #ecd68a; border-radius: 6px; font-size: 13px; }
.ds-notices ul { margin: 4px 0 0; padding-left: 20px; }

/* 商品一覧(カードは card.css)。列数は --cols */
.ds-grid { grid-template-columns: repeat(var(--cols), minmax(0, 1fr)); gap: 12px; --name-lines: 2; --name-size: 13px; }
.ds-testchip { position: absolute; left: 4px; bottom: 4px; z-index: 4; background: rgba(60, 60, 60, .82); color: #fff; font-size: 10px; line-height: 1; padding: 3px 5px; border-radius: 3px; pointer-events: none; }
.ds-empty { background: #fff; border: 1px solid var(--ds-line); border-radius: 8px; padding: 12px 16px; }
.ds-emptyactions { list-style: none; margin: 8px 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.ds-morewrap { text-align: center; margin: 16px 0 32px; }
.ds-toast { position: fixed; left: 50%; bottom: 16px; transform: translateX(-50%); max-width: 90vw; background: #222; color: #fff; padding: 8px 14px; border-radius: 6px; font-size: 13px; z-index: 60; overflow-wrap: anywhere; }

/* 幅の切り替え */
@media (min-width: 900px) and (max-width: 999px) { .ds-layout { grid-template-columns: 240px minmax(0, 1fr); } :root { --cols: 3; } }
@media (max-width: 899px) {
  :root { --cols: 3; }
  .ds-layout { grid-template-columns: minmax(0, 1fr); padding: 8px; }
  #filterToggle { display: inline-block; }
  .ds-filters { display: none; position: static; max-height: none; overflow: visible; }
  .ds-filters.is-open { display: block; }
  .ds-close { display: inline-block; }
  .ds-ffoot { display: block; position: sticky; bottom: 0; background: #fff; padding: 8px 0 4px; border-top: 1px solid var(--ds-line); margin-top: 8px; }
  .ds-ffoot .ds-btn { width: 100%; }
  .opt { min-height: 44px; }
  .facet > summary { min-height: 48px; }
  .fmore { min-height: 44px; }
  .fsearch { min-height: 44px; }
  .ds-tag, .ds-tagmore { min-height: 44px; }
  .ds-tagactions .ds-btn { min-height: 44px; }
}
@media (min-width: 900px) { #filterToggle { display: none; } }
@media (max-width: 599px) {
  :root { --cols: 2; }
  .ds-grid { gap: 8px; --name-lines: 3; --name-size: 12px; }
  .ds-grid .rc-price { font-size: 13px; }
  .ds-toolbar { align-items: flex-start; }
  .ds-sort { width: 100%; }
  .ds-sort select { flex: 1 1 auto; min-width: 0; }
  .ds-head h1 small { display: block; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; scroll-behavior: auto !important; } }
