/* 競合価格チェッカーの画面。
   見た目の題材は、店頭の値札と、相場を流す電光掲示板。
   文字の大きさ・行の高さ・ボタンの高さは、実在の価格比較サービス10件を測った範囲に合わせている
   (本文14〜16px、行間1.3〜1.5、いまの価格24〜28px、表の行29〜42px、ボタン40〜51px)。 */
:root {
  --ink: #14213d;
  --muted: #5b6577;
  --line: #d9dee8;
  --paper: #ffffff;
  --shade: #f1f3f8;
  --tag: #fca311;       /* 値札の色 */
  --tag-pale: #fff3d1;
  --up: #c62828;        /* 値上がり */
  --up-pale: #fdeceb;
  --down: #1d5fd0;      /* 値下がり */
  --down-pale: #e4edff;
  --lamp: #ffd166;      /* 電光掲示板の文字 */
  --night: #0b1326;
  --dots: "DotGothic16", monospace;
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: "BIZ UDPGothic", "Hiragino Sans", "Yu Gothic", Meiryo, sans-serif;
  font-size: 0.9375rem;
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
}
h1, h2, h3, p, ul, ol, dl, dd { margin: 0; padding: 0; }
ul, ol { list-style: none; }
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--tag); outline-offset: 2px; }

.wrap { width: min(100% - 2rem, 70rem); margin-inline: auto; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

/* ---------- 掲示板:紺の帯に、価格の動きが流れる ---------- */
.board { background: var(--ink); color: #fff; }
.board-top { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0.25rem 1rem; padding: 0.9rem 0 0.7rem; }
.board h1 { font-size: 1.25rem; letter-spacing: 0.04em; }
.board .updated { color: #b8c2d6; font-size: 0.8125rem; }

.ticker {
  overflow: hidden;
  background: var(--night);
  border-top: 1px solid #26355c;
  font-family: var(--dots);
  font-size: 0.9375rem;
  line-height: 2.3;
  white-space: nowrap;
}
.ticker-track { display: inline-flex; gap: 2.5rem; padding-left: 1rem; animation: ticker 48s linear infinite; }
.ticker:hover .ticker-track { animation-play-state: paused; }
.ticker-item { color: var(--lamp); }
.ticker-item b { font-weight: 400; color: #fff; margin-left: 0.6rem; }
.ticker-item .up { color: #ff8a80; margin-left: 0.5rem; }
.ticker-item .down { color: #8fc4ff; margin-left: 0.5rem; }
.ticker-item .flat { color: #7f8bab; margin-left: 0.5rem; }
@keyframes ticker { from { transform: translateX(0); } to { transform: translateX(-50%); } }

main.wrap { padding: 1rem 0 2.5rem; }

.banner {
  margin-bottom: 1rem;
  padding: 0.6rem 0.9rem;
  border-left: 4px solid var(--tag);
  background: var(--tag-pale);
  font-size: 0.875rem;
}
.banner-warn { border-left-color: var(--up); background: var(--up-pale); }

/* ---------- 商品を足すデモ ---------- */
.adder {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 0.5rem 1.25rem;
  margin-bottom: 1.25rem;
  padding: 0.9rem 1rem;
  border: 2px solid var(--ink);
  box-shadow: 5px 5px 0 var(--tag);
}
.adder > * { min-width: 0; }
.adder h2 { font-size: 1rem; }
.adder-form { display: flex; gap: 0.5rem; }
.adder-form input {
  flex: 1;
  min-width: 0;
  height: 2.75rem;
  padding: 0 0.8rem;
  border: 1px solid var(--ink);
  border-radius: 2px;
  background: #fff;
}
.adder-button {
  height: 2.75rem;
  padding: 0 1.25rem;
  font-weight: 700;
  border: 0;
  border-radius: 2px;
  background: var(--tag);
  color: var(--ink);
  cursor: pointer;
  white-space: nowrap;
}
.adder-button:disabled { opacity: 0.55; cursor: wait; }
.adder-note { grid-column: 1 / -1; font-size: 0.8125rem; color: var(--muted); }

.steps { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 0.35rem; counter-reset: step; font-size: 0.8125rem; }
.steps li {
  counter-increment: step;
  display: flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.2rem 0.7rem 0.2rem 0.35rem;
  border-radius: 999px;
  background: var(--shade);
  color: var(--muted);
}
.steps li::before {
  content: counter(step);
  display: inline-flex; align-items: center; justify-content: center;
  width: 1.5em; height: 1.5em; border-radius: 50%;
  background: #fff; font-weight: 700;
}
.steps li.is-active { background: var(--tag); color: var(--ink); font-weight: 700; }
.steps li.is-done { background: var(--ink); color: #fff; }
.steps li.is-done::before { content: "✓"; color: var(--ink); }

/* ---------- さがす・しぼる・並べる ---------- */
.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.6rem 0.75rem;
  margin-bottom: 0.75rem;
}
.search { flex: 1 1 14rem; }
.search input {
  width: 100%;
  height: 2.5rem;
  padding: 0 0.8rem;
  border: 1px solid var(--muted);
  border-radius: 2px;
  background: #fff;
}
.chips { display: flex; flex-wrap: wrap; gap: 0.35rem; }
.chip {
  height: 2.5rem;
  padding: 0 0.8rem;
  border: 1px solid var(--line);
  border-radius: 2px;
  background: #fff;
  font-size: 0.875rem;
  cursor: pointer;
}
.chip-count { margin-left: 0.4rem; font-family: var(--dots); color: var(--muted); }
.chip[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: #fff; font-weight: 700; }
.chip[aria-pressed="true"] .chip-count { color: var(--lamp); }
.sort { display: flex; align-items: center; gap: 0.4rem; font-size: 0.875rem; white-space: nowrap; }
.sort select {
  height: 2.5rem;
  padding: 0 0.5rem;
  border: 1px solid var(--line);
  border-radius: 2px;
  background: #fff;
}
.button {
  display: inline-flex;
  align-items: center;
  height: 2.5rem;
  padding: 0 0.9rem;
  border: 1px solid var(--ink);
  border-radius: 2px;
  background: #fff;
  font-size: 0.875rem;
  font-weight: 700;
  text-decoration: none;
  color: var(--ink);
}
.button:hover { background: var(--shade); }

/* ---------- 一覧と詳細 ---------- */
.split { display: grid; grid-template-columns: minmax(0, 1fr); gap: 1.25rem; }
.split > *, .row-item { min-width: 0; }

.list-head, .row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 5rem 5.25rem 6rem 4.2rem;
  gap: 0.75rem;
  align-items: center;
}
.list-head {
  padding: 0.4rem 0.75rem;
  border-bottom: 2px solid var(--ink);
  font-size: 0.75rem;
  color: var(--muted);
}
.list-head span:nth-child(2), .list-head span:nth-child(3) { text-align: right; }

.row-item { border-bottom: 1px solid var(--line); }
.row {
  width: 100%;
  min-height: 3.25rem;
  padding: 0.45rem 0.75rem;
  border: 0;
  border-left: 4px solid transparent;
  background: transparent;
  text-align: left;
  cursor: pointer;
}
.row:hover { background: var(--shade); }
.row.is-selected { background: var(--tag-pale); border-left-color: var(--tag); }
.row.is-new { animation: drop 0.5s ease-out; }
@keyframes drop { from { opacity: 0; transform: translateY(-10px); } to { opacity: 1; transform: none; } }

.row-name { display: grid; min-width: 0; }
.row-title { font-weight: 700; line-height: 1.35; overflow-wrap: anywhere; }
.row-shop { font-size: 0.75rem; color: var(--muted); }
.row-price { font-family: var(--dots); font-size: 1.125rem; text-align: right; white-space: nowrap; }
.row-price small { font-family: inherit; font-size: 0.75rem; margin-left: 1px; }

/* 前回からの動き。色だけに頼らず、矢印と数字でも伝える */
.delta { font-size: 0.8125rem; text-align: right; white-space: nowrap; color: var(--muted); }
.delta-arrow { margin-right: 0.2rem; font-size: 0.75em; }
.delta-rate { display: block; font-size: 0.75rem; }
.delta-up { color: var(--up); font-weight: 700; }
.delta-down { color: var(--down); font-weight: 700; }

/* 期間内の最安から最高までの幅と、いまの位置 */
.range { display: grid; gap: 0.2rem; }
.range-bar { position: relative; height: 4px; border-radius: 2px; background: var(--line); }
.range-dot {
  position: absolute;
  top: 50%;
  width: 10px;
  height: 10px;
  margin: -5px 0 0 -5px;
  border-radius: 50%;
  background: var(--ink);
  box-shadow: 0 0 0 2px #fff;
}
.range-ends { display: flex; justify-content: space-between; font-size: 0.75rem; color: var(--muted); }

.badge {
  justify-self: start;
  padding: 0.1rem 0.45rem;
  border-radius: 2px;
  font-size: 0.75rem;
  font-weight: 700;
  white-space: nowrap;
}
.badge-in { background: var(--ink); color: #fff; }
.badge-out { background: var(--shade); color: var(--muted); box-shadow: inset 0 0 0 1px var(--muted); }

.empty { padding: 1.5rem 0.75rem; color: var(--muted); }
.legend { margin-top: 0.75rem; font-size: 0.75rem; color: var(--muted); }

.detail { padding: 1rem; border: 1px solid var(--line); border-top: 4px solid var(--ink); background: #fff; }
.detail-head { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem 0.75rem; }
.detail-head h2 { font-size: 1.125rem; line-height: 1.4; }

/* いまの価格は、値札の形。左の角を落として、ひも通しの穴をあける */
.tag-row { display: flex; flex-wrap: wrap; align-items: center; gap: 0.75rem 1.25rem; margin-top: 0.75rem; }
.tag {
  display: grid;
  padding: 0.45rem 1.1rem 0.5rem 2.1rem;
  background: radial-gradient(circle at 0.95rem 50%, #fff 0 0.28rem, transparent 0.31rem), var(--tag);
  clip-path: polygon(0.7rem 0, 100% 0, 100% 100%, 0.7rem 100%, 0 50%);
}
.tag-label { font-size: 0.75rem; font-weight: 700; }
.tag-price { font-family: var(--dots); font-size: 1.75rem; line-height: 1.15; }
.tag-price small { font-size: 0.875rem; margin-left: 2px; }
.detail-delta { display: flex; align-items: baseline; gap: 0.5rem; }
.detail-delta-label { font-size: 0.75rem; color: var(--muted); }
.detail-delta .delta { font-size: 0.9375rem; text-align: left; }
.detail-delta .delta-rate { display: inline; margin-left: 0.4rem; font-size: 0.75rem; }

/* 期間は、選択の箱ではなく、並んだボタンで切りかえる */
.period { display: inline-flex; margin-top: 1rem; border: 1px solid var(--ink); border-radius: 2px; }
.period button {
  height: 2rem;
  padding: 0 0.9rem;
  border: 0;
  border-left: 1px solid var(--ink);
  background: #fff;
  font-size: 0.8125rem;
  cursor: pointer;
}
.period button:first-child { border-left: 0; }
.period button[aria-pressed="true"] { background: var(--ink); color: #fff; font-weight: 700; }

.chart-box { position: relative; height: 13.5rem; margin-top: 0.6rem; }
.chart-note { margin-top: 0.35rem; font-size: 0.75rem; color: var(--muted); }

.stats { display: grid; grid-template-columns: repeat(4, 1fr); margin-top: 1rem; border-top: 2px solid var(--ink); border-bottom: 1px solid var(--line); }
.stats div { padding: 0.5rem 0.6rem; border-left: 1px solid var(--line); }
.stats div:first-child { border-left: 0; padding-left: 0; }
.stats dt { font-size: 0.75rem; color: var(--muted); }
.stats dd { font-family: var(--dots); font-size: 1.0625rem; white-space: nowrap; }
.stats dd small { display: block; font-family: "BIZ UDPGothic", sans-serif; font-size: 0.75rem; color: var(--muted); }

.detail h3 { margin: 1.4rem 0 0.4rem; font-size: 0.9375rem; }
.table-wrap { overflow-x: auto; }
.detail table { width: 100%; border-collapse: collapse; font-size: 0.875rem; }
.detail th, .detail td { height: 2.25rem; padding: 0.25rem 0.6rem; border-bottom: 1px solid var(--line); text-align: right; white-space: nowrap; }
.detail thead th { height: 1.9rem; border-bottom: 2px solid var(--ink); font-size: 0.75rem; font-weight: 400; color: var(--muted); }
.detail th:first-child, .detail td[colspan] { text-align: left; padding-left: 0; }
.detail tbody th { font-weight: 400; }
.detail td[colspan] { white-space: normal; color: var(--muted); }
.shops .is-cheapest th, .shops .is-cheapest td { background: var(--tag-pale); font-weight: 700; }
.shops .is-cheapest th { padding-left: 0.5rem; }
.shops .is-out th, .shops .is-out td { color: var(--muted); }
.mark { margin-left: 0.5rem; padding: 0 0.35rem; background: var(--tag); font-size: 0.75rem; }
.is-up { color: var(--up); font-weight: 700; }
.is-down { color: var(--down); font-weight: 700; }
.table-note { margin-top: 0.35rem; font-size: 0.75rem; color: var(--muted); }
.more {
  margin-top: 0.5rem;
  height: 2.25rem;
  padding: 0 0.8rem;
  border: 1px solid var(--line);
  border-radius: 2px;
  background: #fff;
  font-size: 0.8125rem;
  cursor: pointer;
}

.notify-rule { font-size: 0.875rem; }
.notify-sample {
  margin: 0.5rem 0 0;
  padding: 0.7rem 0.9rem;
  background: var(--night);
  color: #fff;
  font-family: var(--dots);
  font-size: 0.875rem;
  line-height: 1.7;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.detail-link { margin-top: 1rem; font-size: 0.875rem; }
.detail-link a { color: var(--down); }

.site-footer { background: var(--ink); color: #b8c2d6; padding: 1.25rem 0; font-size: 0.8125rem; }
.site-footer a { color: #fff; }

/* ---------- 広い画面:左に一覧、右に詳細 ---------- */
@media (min-width: 62rem) {
  .split { grid-template-columns: minmax(0, 6fr) minmax(0, 5fr); align-items: start; }
  .detail { position: sticky; top: 0.75rem; max-height: calc(100vh - 1.5rem); overflow-y: auto; }
}

/* ---------- 狭い画面:行を2段にして、選んだ行のすぐ下に詳細を開く ---------- */
@media (max-width: 61.99rem) {
  .list-head { display: none; }
  .rows { border-top: 2px solid var(--ink); }
  .row {
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas: "name stock" "price delta" "range range";
    gap: 0.3rem 0.75rem;
    padding: 0.7rem 0.5rem;
  }
  .row-name { grid-area: name; }
  .row .badge { grid-area: stock; justify-self: end; }
  .row-price { grid-area: price; text-align: left; font-size: 1.25rem; }
  .row .delta { grid-area: delta; align-self: end; }
  .row .delta-rate { display: inline; margin-left: 0.35rem; }
  .row .range { grid-area: range; }
  .detail { margin: 0 0 0.75rem; padding: 0.9rem 0.75rem; border-left: 0; border-right: 0; }
  .adder { grid-template-columns: minmax(0, 1fr); }
  .adder-form { flex-wrap: wrap; }
  .adder-form input { flex: 1 1 10rem; }
  .adder-button { flex: 1 1 auto; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .stats div:nth-child(3) { border-left: 0; padding-left: 0; }
  .stats div:nth-child(n+3) { border-top: 1px solid var(--line); }
  .sort { flex: 1; }
  .sort select { flex: 1; min-width: 0; }
  .detail table { font-size: 0.8125rem; }
  .detail th, .detail td { padding: 0.25rem 0.4rem; }
}

@media (prefers-reduced-motion: reduce) {
  .ticker-track { animation: none; }
  .row.is-new { animation: none; }
}

/* スマートフォンでは、押す部品・入力欄の高さを44px以上にそろえる */
@media (max-width: 48rem) {
  button, select, a.button,
  input:not([type="radio"]):not([type="checkbox"]):not([type="hidden"]) { min-height: 2.75rem !important; }
}
