/* ===========================================================
   チラシまとめ  デザイン
   ※ 画像の大きさは割合(height:100%)に頼らず position:absolute で確定させる
     （iOS Safari で高さが解決されず画像が重なる問題の対策。おうちレシピで実際に起きた）
   =========================================================== */
:root {
  --bg: #f7f2ec;
  --card: #ffffff;
  --ink: #2c2724;
  --sub: #857b73;
  --line: #ebe3da;
  --accent: #d9452b;
  --accent-soft: #fcebe6;
  --new: #f5b400;
  --ok: #3f8f5a;
  --radius: 16px;
  --shadow: 0 1px 2px rgba(60, 40, 20, .06), 0 4px 14px rgba(60, 40, 20, .06);
  --font: "M PLUS Rounded 1c", "Hiragino Maru Gothic ProN", "Hiragino Sans", "Meiryo", sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-weight: 500;
  line-height: 1.55;
  padding-bottom: env(safe-area-inset-bottom);
}
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; }

/* ---------- ヘッダー ---------- */
.top {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  background: rgba(247, 242, 236, .92);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 800; font-size: 18px; }
.brand-mark {
  display: grid; place-items: center;
  width: 30px; height: 30px; border-radius: 9px;
  background: var(--accent); color: #fff; font-size: 16px;
}
.top-date { font-size: 13px; color: var(--sub); }

main { max-width: 760px; margin: 0 auto; padding: 14px 16px 40px; }
.loading, .empty { color: var(--sub); text-align: center; padding: 40px 0; }

/* ---------- 切り替えタブ ---------- */
.tabs {
  display: flex; gap: 6px; padding: 4px; margin-bottom: 14px;
  background: #efe7de; border-radius: 999px;
}
.tab {
  flex: 1; border: 0; background: transparent; padding: 8px 0;
  border-radius: 999px; font-weight: 700; font-size: 14px; color: var(--sub); cursor: pointer;
}
.tab[aria-selected="true"] { background: var(--card); color: var(--ink); box-shadow: var(--shadow); }

.updated { font-size: 12px; color: var(--sub); text-align: right; margin: -6px 2px 10px; }

/* ---------- 店舗カード ---------- */
.stores { display: grid; gap: 12px; }
.store {
  display: block; background: var(--card); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 14px 14px 12px; overflow: hidden;
}
.store-head { display: flex; align-items: center; gap: 8px; }
.store-name { font-weight: 800; font-size: 16px; flex: 1; min-width: 0; }
.store-meta { font-size: 12px; color: var(--sub); white-space: nowrap; }
.badge {
  display: inline-block; font-size: 11px; font-weight: 800; line-height: 1;
  padding: 4px 7px; border-radius: 999px; vertical-align: 2px; white-space: nowrap;
}
.badge-new { background: var(--new); color: #3a2a00; }
.badge-today { background: var(--accent); color: #fff; }
.badge-soon { background: #e8eef6; color: #3b5a85; }
.badge-src { background: #f1ece6; color: var(--sub); font-weight: 700; }

/* 店舗カード内の横並びサムネイル */
.strip {
  display: flex; gap: 8px; margin: 10px -14px 0; padding: 0 14px 4px;
  overflow-x: auto; scroll-snap-type: x proximity; -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.strip::-webkit-scrollbar { display: none; }
.strip-item { flex: 0 0 auto; width: 104px; scroll-snap-align: start; }
.strip-cap { font-size: 11px; color: var(--sub); margin-top: 4px; line-height: 1.35;
  overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }

/* 画像の枠（縦横比は style で指定し、画像は絶対配置） */
.frame {
  position: relative; width: 100%; overflow: hidden;
  background: #f1ebe4; border-radius: 10px;
}
.frame img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: top center; }
.frame.contain img { object-fit: contain; }
.store-none { font-size: 13px; color: var(--sub); margin: 8px 0 0; }

/* ---------- 店舗ページ ---------- */
.back { display: inline-flex; align-items: center; gap: 4px; font-size: 14px; color: var(--sub); margin-bottom: 8px; }
.page-title { font-size: 22px; font-weight: 800; margin: 0 0 2px; line-height: 1.35; }
.page-sub { font-size: 13px; color: var(--sub); margin: 0 0 16px; display: flex; flex-wrap: wrap; gap: 4px 12px; }
.page-sub a { text-decoration: underline; text-underline-offset: 2px; }

.flyer { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px; margin-bottom: 14px; }
.flyer-head { display: flex; align-items: flex-start; gap: 8px; margin-bottom: 4px; }
.flyer-title { font-weight: 800; font-size: 16px; flex: 1; line-height: 1.4; }
.flyer-period { font-size: 13px; color: var(--sub); margin-bottom: 10px; }
.pages { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.pages.one { grid-template-columns: 1fr; }
.pages button { border: 0; padding: 0; background: none; cursor: zoom-in; display: block; width: 100%; }
.page-no { font-size: 11px; color: var(--sub); text-align: center; margin-top: 3px; }
.flyer-links { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.chip {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 12px; font-weight: 700; padding: 6px 11px; border-radius: 999px;
  background: #f4eee8; color: var(--ink);
}

/* ---------- 新着順 ---------- */
.feed { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (min-width: 600px) { .feed { grid-template-columns: repeat(3, 1fr); } }
.feed-item { display: block; background: var(--card); border-radius: 14px; box-shadow: var(--shadow); padding: 8px; }
.feed-store { font-size: 12px; font-weight: 800; margin-top: 6px; line-height: 1.35; }
.feed-title { font-size: 11px; color: var(--sub); line-height: 1.35;
  overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.feed-item .badge { margin-top: 4px; }

/* ---------- 拡大表示 ---------- */
.viewer {
  position: fixed; inset: 0; z-index: 100; background: #1d1a18; color: #fff;
  touch-action: none; overscroll-behavior: contain;
}
.viewer[hidden] { display: none; }
.viewer-bar {
  position: absolute; top: 0; left: 0; right: 0; z-index: 3;
  display: flex; align-items: center; gap: 8px;
  padding: calc(8px + env(safe-area-inset-top)) 10px 8px;
  background: linear-gradient(rgba(0,0,0,.7), rgba(0,0,0,0));
}
.viewer-title { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.3; }
.viewer-title b { font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.viewer-title span { font-size: 12px; opacity: .75; }
.vbtn {
  flex: 0 0 auto; min-width: 40px; height: 40px; border-radius: 999px; border: 0;
  background: rgba(255,255,255,.16); color: #fff; font-size: 18px; cursor: pointer;
  display: grid; place-items: center; padding: 0 12px;
}
.vbtn-text { font-size: 13px; font-weight: 800; }
.vbtn[hidden] { display: none; }
.viewer-stage { position: absolute; inset: 0; overflow: hidden; }
.viewer-stage img {
  position: absolute; left: 0; top: 0; transform-origin: 0 0;
  max-width: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
  will-change: transform;
}
.viewer-spin {
  position: absolute; left: 50%; top: 50%; width: 34px; height: 34px; margin: -17px;
  border: 3px solid rgba(255,255,255,.25); border-top-color: #fff; border-radius: 50%;
  animation: spin .8s linear infinite;
}
.viewer-spin[hidden] { display: none; }
@keyframes spin { to { transform: rotate(360deg); } }
.vnav {
  position: absolute; top: 50%; z-index: 3; width: 44px; height: 64px; margin-top: -32px;
  border: 0; background: rgba(0,0,0,.35); color: #fff; font-size: 34px; line-height: 1; cursor: pointer;
}
.vprev { left: 0; border-radius: 0 12px 12px 0; }
.vnext { right: 0; border-radius: 12px 0 0 12px; }
.vnav[hidden] { display: none; }
.viewer-hint {
  position: absolute; left: 0; right: 0; bottom: calc(14px + env(safe-area-inset-bottom)); z-index: 3;
  margin: 0; text-align: center; font-size: 12px; opacity: .7; pointer-events: none;
  transition: opacity .6s;
}
@media (hover: none) { .vnav { background: rgba(0,0,0,.18); width: 36px; } }

/* ---------- 価格比較 ---------- */
.psearch { margin-bottom: 12px; }
.psearch input {
  width: 100%; padding: 12px 14px; font: inherit; font-size: 16px;
  border: 1px solid var(--line); border-radius: 12px; background: var(--card); color: var(--ink);
}
.pgroup { margin-bottom: 14px; }
.pgroup h2 { font-size: 14px; font-weight: 800; color: var(--sub); margin: 0 0 6px 2px; }
.pchips { display: flex; flex-wrap: wrap; gap: 6px; }
.pchip {
  display: inline-flex; align-items: center; gap: 6px; padding: 7px 12px;
  background: var(--card); border-radius: 999px; box-shadow: var(--shadow); font-size: 14px; font-weight: 700;
}
.pchip span { font-size: 11px; color: var(--sub); font-weight: 500; }
.pnote { font-size: 12px; color: var(--sub); margin: 18px 2px 0; }

.plist { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.prow {
  display: flex; gap: 10px; align-items: center; justify-content: space-between;
  background: var(--card); border-radius: 14px; box-shadow: var(--shadow); padding: 11px 13px;
}
.prow.is-best { box-shadow: 0 0 0 2px var(--accent), var(--shadow); }
.prow-main { min-width: 0; flex: 1; }
.prow-store { font-size: 12px; font-weight: 800; color: var(--accent); }
.prow-name { font-size: 14px; font-weight: 700; line-height: 1.4; margin-top: 1px; }
.pqty { font-size: 12px; color: var(--sub); font-weight: 500; white-space: nowrap; }
.prow-meta { display: flex; flex-wrap: wrap; gap: 4px 8px; margin-top: 4px; font-size: 11px; color: var(--sub); align-items: center; }
.pcat { background: #f1ece6; border-radius: 999px; padding: 2px 7px; }
.pcond { color: #8a5a00; }
.pdate { white-space: nowrap; }
.prow-price { flex: 0 0 auto; text-align: right; display: flex; flex-direction: column; align-items: flex-end; }
.prow-price b { font-size: 19px; font-weight: 800; line-height: 1.2; }
.prow-price small { font-size: 10px; color: var(--sub); }
.prow-price .punit { font-size: 11px; color: var(--ink); margin-top: 2px; white-space: nowrap; }

/* ---------- お店の検索・いつもの商品・価格の推移 ---------- */
.store[hidden] { display: none; }
.wsec { margin: 4px 0 18px; }
.wsec h2, .sub-h { font-size: 15px; font-weight: 800; margin: 0 0 8px 2px; }
.sub-h { margin-top: 18px; }
.wempty { font-size: 13px; color: var(--sub); background: var(--card); border-radius: 12px; padding: 12px 14px; margin: 0; box-shadow: var(--shadow); }
.wlist { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
@media (min-width: 600px) { .wlist { grid-template-columns: repeat(3, 1fr); } }
.wcard { display: block; background: var(--card); border-radius: 14px; box-shadow: var(--shadow); padding: 10px 12px; border-left: 4px solid var(--new); }
.wname { font-weight: 800; font-size: 14px; }
.wbest b { font-size: 18px; font-weight: 800; }
.wbest small { display: block; font-size: 11px; color: var(--sub); }
.wstore { font-size: 11px; color: var(--accent); font-weight: 700; margin-top: 2px; }
.wnone { font-size: 12px; color: var(--sub); margin-top: 6px; }
.wbtn {
  display: inline-block; margin: 0 0 12px; padding: 8px 14px; border-radius: 999px; cursor: pointer;
  border: 1px solid var(--new); background: #fff8e1; color: #6b4f00; font-weight: 800; font-size: 13px;
}
.wbtn.is-on { background: var(--new); color: #3a2a00; }
.wbtn:disabled { opacity: .6; }
.chart { background: var(--card); border-radius: 14px; box-shadow: var(--shadow); padding: 10px 10px 8px; }
.chart svg { display: block; width: 100%; height: auto; }
.cunit { font-size: 11px; color: var(--sub); margin: 0 0 4px 4px; }
.cgrid { stroke: var(--line); stroke-width: 1; }
.ctoday { stroke: var(--accent); stroke-width: 1; stroke-dasharray: 3 3; opacity: .6; }
.clabel { font-size: 10px; fill: var(--sub); font-family: var(--font); }
.cline { fill: none; stroke: var(--ink); stroke-width: 1.5; opacity: .35; }
.clegend { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 11px; color: var(--sub); margin: 6px 4px 0; }
.clegend i { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 4px; vertical-align: -1px; }
.ctable { width: 100%; border-collapse: collapse; margin-top: 8px; font-size: 12px; background: var(--card); border-radius: 12px; overflow: hidden; box-shadow: var(--shadow); }
.ctable td { padding: 7px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
.ctable td small { display: block; color: var(--sub); font-size: 11px; }
.ctable td.r { text-align: right; white-space: nowrap; font-weight: 700; }

/* ---------- 検索欄の×・管理ボタン・いつもの商品の補足 ---------- */
.psearch { position: relative; }
.psearch input { padding-right: 44px; }
.psearch input::-webkit-search-cancel-button { display: none; }
.sclear {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  width: 32px; height: 32px; border: 0; border-radius: 50%; cursor: pointer;
  background: #e9e1d8; color: var(--ink); font-size: 18px; line-height: 1;
}
.sclear[hidden] { display: none; }
.top-right { display: flex; align-items: center; gap: 10px; }
.top-admin {
  font-size: 12px; font-weight: 700; color: var(--sub); padding: 5px 10px;
  border: 1px solid var(--line); border-radius: 999px; background: var(--card); white-space: nowrap;
}
.wlabel { font-size: 10px; color: var(--sub); margin-top: 2px; }
.wsoon { font-size: 11px; color: #3b5a85; margin-top: 4px; }

/* 各店共通の商品をまとめた行の店名一覧 */
.pbranches { font-weight: 500; color: var(--sub); font-size: 11px; }
.wstore .pbranches { display: none; }
