:root {
  --bg: #f8fafc;
  --card: #ffffff;
  --ink: #0f172a;
  --sub: #475569;
  --muted: #94a3b8;
  --line: #e2e8f0;
  --accent: #f59e0b;
  --accent-ink: #92400e;
  --navy: #0f172a;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, "Hiragino Sans", "Noto Sans JP", "Yu Gothic UI", sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.6;
}
.hidden { display: none !important; }

/* ヘッダー＋検索 */
.hero {
  background: var(--navy);
  color: #fff;
  padding: 28px 16px 22px;
  text-align: center;
}
.logo { color: #fff; text-decoration: none; font-weight: 800; font-size: 1.4rem; display: inline-flex; align-items: center; gap: 8px; }
.logo-mark { display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 9px; background: var(--accent); color: var(--navy); }
.tagline { margin: 6px 0 16px; color: #cbd5e1; font-size: 0.9rem; }
.search { display: flex; max-width: 620px; margin: 0 auto; gap: 8px; }
.search input {
  flex: 1; min-width: 0; font-size: 1.05rem; padding: 14px 16px; border-radius: 12px; border: 0; outline: none;
}
.search input:focus { box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.6); }
.search button {
  font-size: 1rem; font-weight: 700; padding: 0 22px; border-radius: 12px; border: 0;
  background: var(--accent); color: var(--navy); cursor: pointer;
}
.examples { margin-top: 12px; font-size: 0.85rem; color: #cbd5e1; display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; align-items: center; }
.examples button {
  background: rgba(255, 255, 255, 0.1); color: #fff; border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 999px; padding: 4px 12px; font-size: 0.85rem; cursor: pointer;
}

.wrap { max-width: 720px; margin: 0 auto; padding: 20px 16px 40px; }
.status { text-align: center; color: var(--sub); padding: 24px 0; }

/* 結果 */
.result-title { font-size: 1.3rem; margin: 4px 0 12px; }
.price-card { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 20px; }
.price-main { display: flex; flex-direction: column; align-items: center; }
.price-label { font-size: 0.8rem; color: var(--sub); }
.price-value { font-size: 2.6rem; font-weight: 800; color: var(--accent-ink); line-height: 1.2; }
.price-sub { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 16px 0; }
.price-sub > div { background: var(--bg); border-radius: 10px; padding: 10px; display: flex; flex-direction: column; align-items: center; }
.price-sub strong { font-size: 1.05rem; }
.hist { display: flex; align-items: flex-end; gap: 4px; height: 110px; margin-top: 8px; }
.hist-bar { flex: 1; background: #cbd5e1; border-radius: 4px 4px 0 0; transition: height 0.5s ease; }
.hist-bar.is-median { background: var(--accent); }
.hist-axis { display: flex; justify-content: space-between; font-size: 0.75rem; color: var(--muted); margin-top: 4px; }
.note { font-size: 0.8rem; color: var(--sub); margin: 12px 0 0; }

.section-title { font-size: 1.05rem; margin: 28px 0 10px; }
.links { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.link-btn {
  display: flex; flex-direction: column; text-decoration: none; color: var(--ink);
  background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px;
}
.link-btn:hover { border-color: var(--accent); }
.link-btn strong { font-size: 0.95rem; }
.link-btn span { font-size: 0.75rem; color: var(--sub); }

.deals { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 8px; }
.deals a {
  display: flex; gap: 12px; text-decoration: none; color: var(--ink);
  background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 10px;
}
.deals img, .deals .img-ph { width: 72px; height: 72px; object-fit: contain; flex-shrink: 0; border-radius: 8px; background: var(--bg); }
.deal-body { display: flex; flex-direction: column; min-width: 0; }
.deal-name { font-size: 0.85rem; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.deal-meta { font-size: 0.72rem; color: var(--muted); }
.deal-price { font-weight: 800; color: var(--accent-ink); }
.pr-note { font-size: 0.72rem; color: var(--muted); margin-top: 10px; }

.about { margin-top: 36px; background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 4px 20px 16px; font-size: 0.92rem; color: var(--sub); }
.about h2 { color: var(--ink); font-size: 1.05rem; }
.footer { text-align: center; font-size: 0.78rem; color: var(--muted); padding: 20px 16px 32px; }
.footer p { margin: 2px 0; }

@media (max-width: 480px) {
  .price-value { font-size: 2.1rem; }
  .search button { padding: 0 16px; }
}
.price-sub strong { white-space: nowrap; font-size: clamp(0.85rem, 3.8vw, 1.05rem); }

/* 検索のバーコードボタン */
.search .scan-btn {
  background: rgba(255, 255, 255, 0.12); color: #fff; border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 12px; padding: 0 12px; cursor: pointer; display: grid; place-items: center;
}
.search .go-btn { font-size: 1rem; font-weight: 700; padding: 0 22px; border-radius: 12px; border: 0; background: var(--accent); color: var(--navy); cursor: pointer; }

.product-name { margin: -6px 0 12px; color: var(--sub); font-size: 0.9rem; }

/* 値段の変化 */
.trend { margin-top: 4px; font-size: 0.85rem; font-weight: 700; padding: 2px 10px; border-radius: 999px; }
.trend.up { background: #fee2e2; color: #b91c1c; }
.trend.down { background: #dcfce7; color: #15803d; }
.trend.flat { background: #f1f5f9; color: var(--sub); }

/* 条件ごとの相場 */
.variants { margin: 4px 0 14px; }
.variant-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.variant-chip {
  display: flex; flex-direction: column; align-items: center; min-width: 84px;
  background: #fff7ed; border: 1px solid #fed7aa; border-radius: 10px; padding: 6px 10px; cursor: pointer; color: var(--ink);
}
.variant-chip strong { font-size: 0.9rem; }
.variant-chip span { font-size: 0.75rem; color: var(--accent-ink); }
.variant-chip:hover { border-color: var(--accent); }

/* 分布グラフの印 */
.hist-wrap { position: relative; margin-top: 24px; }
.hist-marker { position: absolute; top: -6px; bottom: 0; width: 2px; background: #2563eb; transform: translateX(-1px); }
.hist-marker span {
  position: absolute; top: -18px; left: 50%; transform: translateX(-50%); white-space: nowrap;
  font-size: 0.68rem; color: #fff; background: #2563eb; border-radius: 4px; padding: 0 5px;
}

/* 判定 */
.judge-card { margin-top: 14px; background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 16px 20px; }
.judge-form label { font-weight: 700; display: block; margin-bottom: 8px; }
.judge-row { display: flex; align-items: center; gap: 6px; }
.judge-row input { flex: 1; min-width: 0; font-size: 1.05rem; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; }
.judge-row .yen { color: var(--sub); }
.judge-row button { font-weight: 700; padding: 10px 18px; border: 0; border-radius: 10px; background: var(--navy); color: #fff; cursor: pointer; }
.judge-result { margin-top: 12px; display: flex; flex-direction: column; gap: 4px; }
.judge-verdict { font-size: 1.3rem; }
.judge-verdict.cheap2 { color: #15803d; }
.judge-verdict.cheap { color: #16a34a; }
.judge-verdict.fair { color: var(--ink); }
.judge-verdict.high { color: #ea580c; }
.judge-verdict.high2 { color: #b91c1c; }
.judge-detail { font-size: 0.85rem; color: var(--sub); }

/* 値段の移り変わり */
.history-card { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 14px 16px; }
.history-chart svg { width: 100%; height: auto; display: block; }
.history-chart .grid { stroke: var(--line); stroke-width: 1; }
.history-chart .axis { font-size: 11px; fill: var(--muted); }
.history-chart .band { fill: rgba(245, 158, 11, 0.15); }
.history-chart .line { fill: none; stroke: var(--accent); stroke-width: 2.5; }
.history-chart .dot { fill: var(--accent-ink); }
.history-card .note { margin-top: 6px; }

/* バーコード読み取り */
.scan-modal { position: fixed; inset: 0; background: rgba(15, 23, 42, 0.75); display: grid; place-items: center; z-index: 50; padding: 16px; }
.scan-box { background: #fff; border-radius: 16px; padding: 16px; width: 100%; max-width: 420px; text-align: center; }
.scan-title { margin: 0 0 10px; font-weight: 700; }
.scan-video-wrap { position: relative; background: #000; border-radius: 12px; overflow: hidden; aspect-ratio: 4 / 3; }
.scan-video-wrap video { width: 100%; height: 100%; object-fit: cover; display: block; }
.scan-frame { position: absolute; left: 12%; right: 12%; top: 35%; bottom: 35%; border: 3px solid var(--accent); border-radius: 8px; box-shadow: 0 0 0 999px rgba(0, 0, 0, 0.25); }
.scan-msg { min-height: 1.4em; font-size: 0.85rem; color: var(--sub); margin: 8px 0; }
.scan-manual { display: flex; gap: 6px; }
.scan-manual input { flex: 1; min-width: 0; padding: 10px; border: 1px solid var(--line); border-radius: 10px; font-size: 1rem; }
.scan-manual button { padding: 0 14px; border: 0; border-radius: 10px; background: var(--accent); font-weight: 700; cursor: pointer; }
.scan-close { margin-top: 10px; background: none; border: 0; color: var(--sub); cursor: pointer; font-size: 0.9rem; }

@media (max-width: 480px) {
  .search .go-btn { padding: 0 14px; }
  .search .scan-btn { padding: 0 9px; }
}
