/* ===== Base (Reset, Typography, Colors) ===== */
:root {
  --bg: #f8fbff;
  --bg-surface: #ffffff;
  --fg: #0f172a;
  --fg-inverse: #ffffff;
  --muted: #64748b;
  --accent: #38bdf8;
  --accent-soft: rgba(56, 189, 248, 0.12);
  --brand-warm: #fb923c;
  --border: #e2e8f0;
  --shadow-xs: 0 4px 12px rgba(15, 23, 42, 0.08);
  --radius-sm: 12px;
  --radius-md: 16px;
  --status-ok: #16a34a;
  --status-pre: #2563eb;
  --status-warn: #f97316;
  --status-off: #94a3b8;
  font-family: system-ui, "Noto Sans JP", sans-serif;
  --font-family: system-ui, "Noto Sans JP", sans-serif;
}

*, *::before, *::after {
  box-sizing: border-box;
}

html {
  color-scheme: light dark;
}

body {
  margin: 0;
  font: 400 16px/1.6 var(--font-family);
  background: var(--bg);
  color: var(--fg);
  -webkit-font-smoothing: antialiased;
}

img {
  display: block;
  max-width: 100%;
}

h1, h2, h3 {
  margin: 0;
  font-weight: 700;
}

p {
  margin: 0;
}

ol, ul {
  margin: 0;
  padding: 0;
}

a {
  color: inherit;
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

a:focus-visible,
.button:focus-visible,
.pill:focus-visible,
.card__link:focus-visible,
input:focus-visible{
  outline: 3px solid var(--accent);
  outline-offset: 3px; /* 2px → 3px */
}

/* === Manual theme overrides (override system when html[data-theme] is present) === */

html[data-theme="light"] { color-scheme: light; }

html[data-theme="dark"]  { color-scheme: dark;  }

html[data-theme="light"]{
  --bg: #f8fbff;
  --bg-surface: #ffffff;
  --fg: #0f172a;
  --fg-inverse: #ffffff;
  --muted: #64748b;
  --accent: #38bdf8;
  --accent-soft: rgba(56, 189, 248, 0.12);
  --brand-warm: #fb923c;
  --border: #e2e8f0;
  --shadow-xs: 0 4px 12px rgba(15, 23, 42, 0.08);
  --status-ok: #16a34a;
  --status-pre: #2563eb;
  --status-warn: #f97316;
  --status-off: #94a3b8;
}

html[data-theme="dark"]{
  --bg: #0f172a;
  --bg-surface: #152238;
  --fg: #e2e8f0;
  --fg-inverse: #0f172a;
  --muted: #94a3b8;
  --accent: #0ea5e9;
  --accent-soft: rgba(14, 165, 233, 0.2);
  --border: #1e293b;
  --shadow-xs: 0 8px 18px rgba(2, 6, 23, 0.45);
  --status-off: #475569;
}

/* ===== Layout (Header, Footer, Grid, Containers) ===== */
.container {
  max-width: 1120px;
  margin: 0 auto;
  padding: 24px 16px 40px;
}

.site-header {
  position: relative;
  top: 0;
  z-index: 50;
  backdrop-filter: blur(6px);
  background: rgba(248, 251, 255, 0.9);
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-direction: row;   /* ← 横並び */
  align-items: center;   /* ← 縦方向中央寄せ */
  gap: 8px;
  padding: 16px;
  -webkit-backdrop-filter: blur(6px);
  box-shadow: 0 1px 0 var(--border);
  height:100px;
}

.site-header .brand {
  display: inline-flex;      /* aが幅100%にならない */
  align-items: center;
  line-height: 0;            /* 画像下の余白を消す */
  text-decoration: none;
}

.logo {
  height: 80px;        /* ロゴは固定高さ（親の100%より優先される） */
  max-height: 100%;  /* はみ出さないよう制御 */
  width: auto;       /* 縦横比を保つ */
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--bg);
  object-fit: contain;
}

.section {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-bottom: 32px;
}

.section__head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  margin-top: 24px;
  margin-bottom: 24px;
}

.section__title {
  font-size: 1.25rem;
}

.section__cta {
  font-size: 0.9rem;
  color: var(--accent);
}

.grid {
  display: grid;
  gap: 16px;
}

.grid--products {
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
}

.rail--cards {
  display: grid;
  gap: 16px;
  grid-auto-flow: column;
  grid-auto-columns: minmax(220px, 1fr);
  overflow-x: auto;
  padding-bottom: 6px;
  scroll-snap-type: x proximity;
  mask-image: linear-gradient(90deg, transparent 0, #000 24px, #000 calc(100% - 24px), transparent 100%);
  -webkit-mask-image: linear-gradient(90deg, transparent 0, #000 24px, #000 calc(100% - 24px), transparent 100%);
}

.rail--cards > * {
  scroll-snap-align: start;
}

.site-footer {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 24px 0 32px;
  font-size: 0.85rem;
  color: var(--muted);
  margin-top: auto;
}

.site-footer p:last-child {
    margin-bottom: 0;
}

.site-footer .tiny {
  overflow-wrap: anywhere;
  word-break: normal;
}

.breadcrumbs {
  display: flex;
  gap: 6px;
  align-items: center;
  padding: 12px 16px;
  font-size: 0.85rem;
}

/* Keep header glass colors consistent per theme when manually set */

html[data-theme="light"] .site-header{ background: rgba(248, 251, 255, 0.9); }

html[data-theme="dark"]  .site-header{ background: rgba(21, 34, 56, 0.8); }

/* ===== Components (Buttons, Cards, Tags, Pills, Forms, Notices) ===== */
.skiplink {
  position: absolute;
  top: 8px;
  left: 8px;
  padding: 8px 12px;
  border-radius: 8px;
  background: var(--accent);
  color: var(--fg-inverse);
  transform: translateY(-140%);
  transition: transform 0.2s ease;
  z-index: 1000;
}

.skiplink:focus-visible {
  transform: translateY(0);
}

.search-form {
  display: flex;
  gap: 8px;
  width: 100%;
  margin-bottom: 16px;
}

.search-form .input {
  flex: 1;
  padding: 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg);
  font-size: 1rem;
  transition: border-color 0.2s ease;
}

.search-form .input:focus-visible {
  border-color: var(--accent);
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-surface);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.1s ease, box-shadow 0.2s ease;
  min-height: 40px;
}

.button:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-xs);
}

.button--primary {
  background: linear-gradient(90deg, var(--brand-warm), #facc15);
  color: #ffffff;
  border: none;
}

.pagination {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  margin: 32px 0;
}

.pagination__status {
  font-size: 0.9rem;
}

.pagination__links {
  display: flex;
  gap: 12px;
}

.pagination__links a {
  padding: 6px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-surface);
  transition: background 0.2s ease;
}

.pagination__links a:hover {
  background: var(--accent-soft);
}

.filter__pills {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.pill {
  display: inline-flex;
  align-items: center;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg);
  font-size: 0.9rem;
  transition: background 0.2s ease;
  min-height: 40px;
}

.pill:hover {
  background: var(--accent-soft);
}

.card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-xs);
  display: flex;
  flex-direction: column;
  transition: transform 0.1s ease, box-shadow 0.1s ease;
}

.card:hover,
.card:focus-within {
  transform: translateY(-2px);
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.12);
}

.card__link {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.card__img {
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: contain;     /* 切り抜きせずに収める */
  background-color: #fff;  /* 空白部分の色を指定 */
  border-bottom: 1px solid var(--border);
  contain: layout paint;
}

.card__body {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 16px;
  padding-bottom: 20px;
}

.card__title{
  display:-webkit-box;
  -webkit-line-clamp:2;
  -webkit-box-orient:vertical;
  overflow:hidden;
  min-height: calc(1em * 1.3 * 2); /* 2行分の高さを確保 */
}

.card__meta {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  margin-top: 4px;
}

.price {
  font-weight: 600;
}

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  background: rgba(100, 116, 139, 0.16);
  color: var(--muted);
}

.badge--ok {
  color: var(--status-ok);
  background: color-mix(in srgb, var(--status-ok) 16%, transparent);
}

.badge--pre {
  color: var(--status-pre);
  background: color-mix(in srgb, var(--status-pre) 14%, transparent);
}

.badge--warn {
  color: var(--status-warn);
  background: color-mix(in srgb, var(--status-warn) 16%, transparent);
}

.badge--off {
  color: var(--status-off);
  background: color-mix(in srgb, var(--status-off) 18%, transparent);
}

.badge--info {
  background: rgba(56, 189, 248, 0.18);
  color: var(--accent);
}

.badge--muted {
  background: rgba(148, 163, 184, 0.2);
  color: var(--muted);
}

.card__link:hover {
  text-decoration: none;
}

@supports not (background: color-mix(in srgb, #000 10%, transparent)){
  .badge--ok   { background: rgba(22,163,74,.16); }
  .badge--pre  { background: rgba(37,99,235,.14); }
  .badge--warn { background: rgba(249,115,22,.16); }
  .badge--off  { background: rgba(148,163,184,.18); }
}

/* === Theme toggle button === */

.theme-toggle{
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg-surface);
  color: var(--fg);
  cursor: pointer;
  box-shadow: var(--shadow-xs);
  line-height: 1;
}

.theme-toggle:hover{ transform: translateY(-1px); }

.theme-toggle__icon{ font-size: 1rem; }

.grid--products .card {
  margin-bottom: 1.2rem;  /* 高さを詰めすぎてない余白 */
}

.grid--products .card__img {
  margin-bottom: 0.6rem;
}

.grid--products .card .card__meta {
  margin-top: 0.4rem;
  margin-bottom: 0.6rem;
}

/* ===== Utilities (Helpers, Visibility, Spacing, Text Helpers, Animations) ===== */
/* Tailwind visibility candidate */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

/* Tailwind typography candidate */
.muted {
  color: var(--muted);
  text-align: center;
}

/* Tailwind typography candidate */
.tiny {
  font-size: 0.8rem;
  line-height: 0.5rem; 
}

/* Tailwind typography candidate */
.a11y-note {
  font-size: 0.85rem;
  color: var(--muted);
}

/* Tailwind visibility candidate */
.sp-only {
  display: none;
}

/* ===== Page: Search ===== */
.filter {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.filter section > h2 {
  letter-spacing: 0.08em;
  font-weight: 600;
  opacity: 0.88;
}

/* Search: カードの密度を少し上げる（HTML構造は不変） */

.grid--products .card { /* 検索カードだけ対象 */
  border-radius: var(--radius-sm);
}

.grid--products .card .card__img {
  aspect-ratio: 1 / 1;
  object-fit: contain;
}

.grid--products .card .card__body {
  padding: 12px 12px 14px;
  gap: 6px;
}

.grid--products .card .card__title {
  font-size: 0.95rem;
  line-height: 1.35;
}

.search .filters {
  padding-right: 1rem;
}

.search .filters li {
  margin-bottom: 0.6rem;
}

.search .filters .tag {
  padding: 0.25rem 0.6rem;
  font-size: 0.9rem;
}

/* --- 検索タグの横並び修正 --- */

.filter__pills,
#facetPanel .filters {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
}

#facetPanel .filters li {
  list-style: none;
  margin: 0;
}

#facetPanel .filters .tag {
  display: inline-block;
  padding: .25rem .6rem;
  font-size: .9rem;
  border-radius: .4rem;
  background: var(--tag-bg, #f2f2f2);
  transition: background .2s;
}

#facetPanel .filters .tag:hover {
  background: var(--tag-hover, #e0e0e0);
}

/* === search タグの横並び・折返し 強制修正（追加）=== */

/* フィルタ内のタグリストを必ずフレックスにする */

#facetPanel .filters,
.search #facetPanel .filters,
.search .filters {
  display: flex !important;
  flex-wrap: wrap !important;
  column-gap: .5rem;
  row-gap: .5rem;
  padding-left: 0;
}

/* li をインライン化して“縦積み化”を防ぐ */

#facetPanel .filters li,
.search #facetPanel .filters li,
.search .filters li {
  display: inline-flex !important;
  align-items: center;
  list-style: none;
  margin: 0;            /* 既存の margin-bottom を無効化 */
}

/* ピル自体が横幅100%にならないようにする */

#facetPanel .filters .tag,
.search #facetPanel .filters .tag,
.search .filters .tag {
  display: inline-block;
  width: auto;
}

/* === search タグ並び修正（副作用最小のスコープ）=== */

.search #filterTrail.filter__pills,
.search #facetPanel .filters {
  display: flex !important;
  flex-wrap: wrap !important;
  column-gap: .5rem;
  row-gap: .5rem;
  padding-left: 0; /* ul の既定インデント除去 */
}

.search #facetPanel .filters li {
  display: inline-flex !important;
  align-items: center;
  list-style: none;
  margin: 0; /* 既存の margin-bottom を無効化 */
}

.search #filterTrail .tag,
.search #facetPanel .filters .tag {
  display: inline-block;
  width: auto;
  max-width: 100%;
}

/* ===== Page: Product ===== */
.product {
  display: grid;
  gap: 24px;
}

.product__head {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 24px;
}

.product section > h2 {
  margin-top: 28px;
  margin-bottom: 12px;
}

.product__img {
  width: 200px;        /* 固定の横幅 */
  height: 200px;       /* 固定の縦幅 */
  object-fit: contain; /* 枠の中に縮小・拡大して収める */
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: #fff;    /* 透過や余白があるときに背景を塗ると綺麗 */
}

.tags {
  list-style: none;
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  font-size: 0.85rem;
  color: var(--muted);
}

.summary {
  display: grid;
  gap: 8px;
  padding: 16px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--bg-surface);
}

.merchants {
  display: grid;
  gap: 16px;
}

.merchant-list {
  display: grid;
  gap: 12px;
}

.merchant {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr 0.8fr 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 12px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--bg-surface);
}

.merchant__shop {
  font-weight: 600;
}

.merchant__price {
  font-size: 1.1rem;
  font-weight: 700;
}

.merchant__action .btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg);
}

.merchant-list.sellers {
  display: grid;
  gap: 12px;
}

.merchant.seller {
  transition: background 0.2s ease;
}

.merchant.seller .name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.merchant.seller .price {
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.merchant--inactive {
  opacity: 0.85;
}

.product .merchant-list {
  display: grid;
  gap: 0.75rem;
}

.product .merchant-list .merchant__shop,
.product .merchant-list .merchant__price,
.product .merchant-list .merchant__stock,
.product .merchant-list .merchant__updated,
.product .merchant-list .merchant__action {
  margin-bottom: 0.25rem;
}

.product .cards .card {
  padding: 0.75rem;
}

.product .cards .card .card__img {
  max-width: 120px;
  height: auto;
  margin: 0 auto;
}

.product .cards .card .card__title {
  font-size: 0.95rem;
  line-height: 1.4;
}

/* Product: 販売元カードを読みやすいグリッドに（構造はそのまま） */

.product .merchant {
  display: grid;
  grid-template-areas:
    "shop   price  action"
    "stock  updated action";
  grid-template-columns: 1.2fr 0.8fr auto;
  row-gap: 6px;
  max-width: 500px;  /* 全体幅を制限して無駄な伸びを防ぐ */
  margin: 0 auto;    /* 中央寄せで左右空白を均等に */
}

.product .merchant__shop    { grid-area: shop; }

.product .merchant__price   { grid-area: price; }

.product .merchant__stock   { grid-area: stock; }

.product .merchant__updated { grid-area: updated; }

.product .merchant__action  { grid-area: action; justify-self: end; }

/* 文字が詰まって見えるのを防ぐ（子要素の下マージンを微調整） */

.product .merchant__shop,
.product .merchant__price,
.product .merchant__stock,
.product .merchant__updated { margin-bottom: 2px; }

.product .merchant__stock,
.product .merchant__updated {
  white-space: nowrap;
}

/* Product: 関連カードは小さめグリッドで */

.product [aria-label="関連アイテム"] .cards{
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 12px;
  max-width: 160px;
}

.product [aria-label="関連アイテム"] .card .card__title {
  font-size: 0.85rem;
  line-height: 1.3;
}

.product .cards .card{
  padding: 0.6rem;
}

.product .cards .card .card__img{
  max-width: 100px;
  margin: 0.25rem auto 0.5rem;
}

.product .cards .card .card__title{
  font-size: 0.9rem;
  line-height: 1.35;
}

/* ===== Page: Ranking ===== */
/* (none) */

/* ===== Media Queries (All breakpoints grouped last) ===== */
@media (prefers-color-scheme: dark) {

  :root {
    --bg: #0f172a;
    --bg-surface: #152238;
    --fg: #e2e8f0;
    --fg-inverse: #0f172a;
    --muted: #94a3b8;
    --accent: #0ea5e9;
    --accent-soft: rgba(14, 165, 233, 0.2);
    --border: #1e293b;
    --shadow-xs: 0 8px 18px rgba(2, 6, 23, 0.45);
    --status-off: #475569;
    --font-family: system-ui, "Noto Sans JP", sans-serif;
  }

  .site-header {
    background: rgba(21, 34, 56, 0.8);
    -webkit-backdrop-filter: blur(6px);
    box-shadow: 0 1px 0 var(--border);
  }

}

@media (prefers-reduced-motion: reduce) {

  *{ animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }

}

@media (min-width: 600px) {

  .product .merchant-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

}

@media (min-width: 640px) {

  .container {
    padding: 32px 32px 48px;
  }

}

@media (max-width: 520px) {

  .theme-toggle__label{ display: none; } /* モバイルはアイコンだけ */

}

/* === Mobile: ヘッダーとロゴを小さく === */

@media (max-width: 600px) {

  .sp-only {
    display: inline;
  }

  .product__img {
    width: 200px;
    height: 200px;
    text-align: center;
    display: block;
    margin: 0 auto;
  }

  .site-header{
    height: 64px;      /* ヘッダーの高さを小さく */
    padding: 8px 16px; /* ヘッダー内の余白を小さく */
  }
  .site-header .logo{
    height: 50px;        /* ロゴは固定高さ（親の100%より優先される） */
    width: auto;
  }

}

@media (max-width: 680px) {

  .search-form {
    flex-direction: column;
  }

  .merchant {
    grid-template-columns: 1fr;
  }

  .merchant__action {
    justify-self: flex-start;
  }

  .product .merchant{
    grid-template-areas:
      "shop"
      "price"
      "stock"
      "updated"
      "action";
    grid-template-columns: 1fr;
  }
  .product .merchant__action{ justify-self: start; }

  .merchant.seller .name {
    white-space: normal;
    overflow: visible;
    text-overflow: clip;
  }

}
/* lines: 985 */
