:root {
  --bg: #fafaf7;
  --fg: #1f2937;
  --muted: #6b7280;
  --line: #e5e7eb;
  --accent: #b45309;
  --accent-soft: #fef3c7;
  --link: #2563eb;
  --good: #15803d;
  --card: #ffffff;
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: -apple-system, BlinkMacSystemFont, "Helvetica Neue", "Hiragino Sans", "Yu Gothic", sans-serif;
  font-size: 15px;
  line-height: 1.6;
}

a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ===== Header ===== */
.site-header {
  background: #fff;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 10;
}
.hwrap {
  max-width: 980px;
  margin: 0 auto;
  padding: 12px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}
.brand {
  font-size: 17px;
  font-weight: 700;
  color: var(--fg);
}
.brand:hover { text-decoration: none; }
.back {
  font-size: 13px;
  color: var(--muted);
}

/* ===== Container / Lede ===== */
.container {
  max-width: 980px;
  margin: 0 auto;
  padding: 24px 16px 48px;
}
.lede h1 {
  font-size: 28px;
  margin: 0 0 8px;
}
.lede .sub {
  margin: 0 0 12px;
  color: var(--fg);
}
.lede .meta {
  margin: 0 0 12px;
  font-size: 13px;
  color: var(--muted);
}
.lede .meta .dot {
  margin: 0 6px;
}
.lede .notice {
  background: var(--accent-soft);
  border-left: 3px solid var(--accent);
  padding: 10px 14px;
  border-radius: 4px;
  font-size: 13px;
  margin: 16px 0 0;
}

.lede .wip {
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-left: 4px solid #dc2626;
  padding: 12px 16px;
  border-radius: 6px;
  font-size: 14px;
  margin: 12px 0;
  color: #7f1d1d;
}

.wip-tag {
  display: inline-block;
  background: #dc2626;
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 4px;
  vertical-align: middle;
  margin-left: 8px;
  letter-spacing: 0.05em;
}

/* ===== Filter ===== */
.filter {
  margin: 24px 0 16px;
}
.filter input {
  width: 100%;
  padding: 12px 14px;
  font-size: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}
.filter input:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

/* ===== Products ===== */
.products {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.loading {
  text-align: center;
  color: var(--muted);
  padding: 32px 0;
}

.product {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}
.product-header {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 16px;
  border: 0;
  background: #fff;
  cursor: pointer;
  font-size: 15px;
  text-align: left;
  font-family: inherit;
  color: var(--fg);
  font-weight: 500;
  gap: 12px;
}
.product-header:hover {
  background: #f9fafb;
}
.product-header .phead-left {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.product-header .pname-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.product-header .pname {
  user-select: text;
  -webkit-user-select: text;
  cursor: text;
}
.product-header .pbadge {
  flex: none;
  font-size: 11px;
  font-weight: 700;
  color: #fff;
  background: var(--accent, #2c3e50);
  padding: 2px 8px;
  border-radius: 999px;
  white-space: nowrap;
}
.product-header .pnote {
  font-size: 11.5px;
  font-weight: 400;
  color: var(--muted);
  line-height: 1.55;
}
.product-header .pmeta {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
}
.product-header .chev {
  color: var(--muted);
  transition: transform .2s;
  font-size: 12px;
}
.product[open] .chev {
  transform: rotate(180deg);
}
/* 開いている商品のヘッダーを色分け＝「タップで閉じる元タイトル」だと一目で分かるように */
.product[open] .product-header {
  background: #eef2f7;
  box-shadow: inset 3px 0 0 var(--accent, #2c3e50);
}
.product[open] .product-header:hover {
  background: #e6edf5;
}
.product[open] .pname {
  color: var(--accent, #2c3e50);
  font-weight: 700;
}

/* どこからでも閉じられるフローティングボタン（app.js が開閉で表示制御） */
#closeFab {
  position: fixed;
  left: 50%;
  bottom: 20px;
  transform: translateX(-50%);
  z-index: 60;
  border: 0;
  background: var(--accent, #2c3e50);
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  font-family: inherit;
  padding: 11px 22px;
  border-radius: 999px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, .25);
  cursor: pointer;
}
#closeFab:hover { background: #1f2d3d; }

.product-body {
  display: none;
  border-top: 1px solid var(--line);
  padding: 0;
  background: #fdfdfb;
}
.product[open] .product-body {
  display: block;
}

.empty {
  padding: 14px 16px;
  color: var(--muted);
  font-size: 14px;
}

/* 検索方法ノート（キーワード/ジャンル検索の商品で表示） */
.search-note {
  margin: 8px 12px 10px;
  padding: 8px 12px;
  background: #f1f5f9;
  border-left: 3px solid var(--accent, #2c3e50);
  border-radius: 6px;
  color: #475569;
  font-size: 12.5px;
  line-height: 1.55;
}
.search-note strong { color: #1f2937; }

/* ===== Items table ===== */
.items {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.items thead th {
  position: sticky;
  top: 56px;
  background: #f3f4f6;
  text-align: left;
  padding: 8px 10px;
  font-weight: 600;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}
.items thead th .arrow {
  color: var(--muted);
  margin-left: 4px;
  font-size: 11px;
}
.items thead th.active {
  color: var(--accent);
}
.items tbody tr {
  border-bottom: 1px solid #f0eee8;
}
.items tbody tr:hover {
  background: #fff8e1;
}
.items td {
  padding: 8px 10px;
  vertical-align: top;
}
.items td.col-name {
  min-width: 240px;
}
.items td.col-price {
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.items td.col-unit {
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  color: var(--good);
  font-weight: 600;
}
.items td.col-cap {
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  color: var(--muted);
}
.items td.col-shop {
  color: var(--muted);
  font-size: 12px;
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.item-link {
  color: var(--fg);
  text-decoration: none;
}
.item-link:hover {
  color: #bf0000;
  text-decoration: underline;
}
.qty-mini {
  color: var(--muted);
  font-size: 11px;
  margin-left: 6px;
}
.items td.col-ec {
  text-align: center;
  white-space: nowrap;
  width: 48px;
}
.ec-badge {
  display: inline-block;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 700;
  line-height: 1.4;
  letter-spacing: 0.02em;
}
.ec-rakuten {
  background: #bf0000;
  color: #fff;
}
.ec-yahoo {
  background: #6300fa;
  color: #fff;
}

/* ===== Search form (JAN自由検索) ===== */
.search-form {
  margin: 28px 0 16px;
  padding: 24px;
  background: #fff8e6;
  border: 2px solid #fbbf24;
  border-radius: 10px;
}
.search-form h2 {
  margin: 0 0 8px;
  font-size: 18px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.search-form p {
  margin: 0 0 14px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.6;
}
.new-tag {
  display: inline-block;
  background: #dc2626;
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 4px;
  letter-spacing: 0.5px;
}
.search-result-wrap {
  margin-top: 16px;
}
.search-result-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
}
.search-result-card h3 {
  margin: 0 0 12px;
  font-size: 15px;
  color: var(--accent);
}
.cap-reached {
  background: #fff;
  border: 1px solid #fca5a5;
  border-radius: 8px;
  padding: 18px;
  margin-top: 12px;
}
.cap-reached h3 {
  margin: 0 0 8px;
  font-size: 16px;
  color: #b91c1c;
}
.cap-reached p {
  margin: 6px 0;
  font-size: 14px;
  line-height: 1.6;
}
.cap-cta {
  display: inline-block;
  margin-top: 12px;
  padding: 10px 22px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}
.cap-cta:hover {
  background: #92400e;
}

/* ===== Request form ===== */
.request-form {
  margin: 28px 0 24px;
  padding: 24px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
}
.request-form h2 {
  margin: 0 0 8px;
  font-size: 18px;
}
.request-form p {
  margin: 0 0 14px;
  color: var(--muted);
  font-size: 14px;
}
.rfrow {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.rfrow input[type="text"] {
  flex: 1;
  min-width: 200px;
  padding: 12px 14px;
  font-size: 16px; /* 16px未満はiOSでフォーカス時に強制ズームされる */
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fafafa;
}
.rfrow input[type="text"]:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
  background: #fff;
}
.rfrow button {
  padding: 12px 24px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}
.rfrow button:hover {
  background: #92400e;
}
.note-small {
  font-size: 12px !important;
  margin-top: 10px !important;
  color: var(--muted) !important;
}

/* ===== Footer ===== */
.site-footer {
  border-top: 1px solid var(--line);
  padding: 20px 16px 32px;
  text-align: center;
  font-size: 12px;
  color: var(--muted);
}
.site-footer .attr {
  margin-top: 8px;
}

/* ===== Mobile ===== */
@media (max-width: 720px) {
  .lede h1 { font-size: 22px; }
  .items thead { display: none; }
  .items, .items tbody, .items tr, .items td {
    display: block;
    width: 100%;
  }
  .items tbody tr {
    padding: 12px 14px;
    border-bottom: 8px solid #f0ede5;
  }
  .items td {
    padding: 2px 0;
    text-align: left !important;
  }
  .items td.col-ec {
    width: auto;
    text-align: left !important;
    margin-bottom: 4px;
  }
  .items td.col-name {
    font-weight: 500;
    margin-bottom: 4px;
  }
  .items td.col-price::before { content: "価格: "; color: var(--muted); }
  .items td.col-unit::before { content: "単価: "; color: var(--muted); }
  .items td.col-cap::before { content: "容量単価: "; color: var(--muted); }
  .items td.col-shop::before { content: "店舗: "; }

  /* 商品ヘッダー: スマホでは「タイトル＝上段全幅」「価格メタ＝下段」に積む。
     価格メタ(.pmeta)が white-space:nowrap で横に長く、左のタイトル列を
     数文字幅まで圧迫して縦長になる不具合の対策。 */
  .product-header {
    flex-wrap: wrap;
    align-items: flex-start;
  }
  .product-header .chev {
    order: 1;
    margin-top: 2px;
  }
  .product-header .pmeta {
    order: 2;
    flex: 1 1 100%;
    white-space: normal;
    margin-top: 6px;
  }
  #closeFab {
    bottom: 16px;
    padding: 12px 24px;
    font-size: 15px;
  }
}
