:root {
  --bg: #f6f7f9;
  --card: #ffffff;
  --text: #1b1f24;
  --muted: #52606d;
  --line: #e2e5ea;
  --head: #eef1f5;
  --group: #f3f0e8;
  --accent: #2456d6;
  --up: #c62828;
  --down: #1565c0;
  --new-bg: #e6f6ea;
  --new-fg: #16793a;
  --gone-fg: #5c6069;
  --warn-bg: #fff4d6;
  --warn-fg: #8a5a00;
  --max-bg: #dbeafe;
  --notice-bg: #fde2e1;
  --notice-fg: #b3261e;
  --scroll-shadow: rgba(0, 0, 0, .18);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14171b;
    --card: #1c2026;
    --text: #e8eaee;
    --muted: #98a1ae;
    --line: #2d333b;
    --head: #242a32;
    --group: #2a2721;
    --accent: #7ea6ff;
    --up: #ff7b72;
    --down: #6cb0ff;
    --new-bg: #17311f;
    --new-fg: #6fdc95;
    --gone-fg: #969ca5;
    --warn-bg: #3a2f10;
    --warn-fg: #f0c060;
    --max-bg: #1c3252;
    --notice-bg: #3a1f1f;
    --notice-fg: #ff8a80;
    --scroll-shadow: rgba(255, 255, 255, .10);
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.55 -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Yu Gothic UI", "Noto Sans JP", Meiryo, sans-serif;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
.muted { color: var(--muted); }
.pad { padding: 16px; }
.top {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  padding: 10px 16px; background: var(--card); border-bottom: 1px solid var(--line);
}
.brand { font-weight: 700; color: var(--text); font-size: 16px; }
.top nav { display: flex; gap: 16px; font-size: 14px; }
main { max-width: 1100px; margin: 0 auto; padding: 16px; }
h1 { font-size: 20px; margin: 4px 0 12px; }
h2 { font-size: 16px; margin: 24px 0 8px; }
.crumb { font-size: 13px; margin-bottom: 4px; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; }
.card {
  display: block; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; color: var(--text);
}
a.card:hover { text-decoration: none; border-color: var(--accent); }
.card.off { opacity: .55; }
.card .t { font-weight: 600; }
.card .s { font-size: 12px; color: var(--muted); margin-top: 2px; }

.feed { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 4px 12px; }
.feed .row { display: flex; align-items: baseline; gap: 8px; padding: 8px 0; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.feed .row:last-child { border-bottom: 0; }
.feed .when { font-size: 12px; color: var(--muted); min-width: 4.5em; }

.badge { display: inline-block; font-size: 11px; font-weight: 700; padding: 1px 6px; border-radius: 999px; white-space: nowrap; }
.badge.new { background: var(--new-bg); color: var(--new-fg); }
.badge.gone { background: var(--head); color: var(--gone-fg); }
.badge.warn { background: var(--warn-bg); color: var(--warn-fg); }

.tablewrap {
  overflow: auto; max-height: calc(100vh - 170px); max-height: calc(100dvh - 170px);
  background: var(--card); border: 1px solid var(--line); border-radius: 12px;
}
/* スマホ等で表が横スクロールできるとき、続きがあることに気づけるよう端に影を出す（JS側でscroll-l/scroll-rを付け外しする）。
   右端(scroll-r)は何も重ならないので.tablewrap自体に。左端(scroll-l)は商品名の固定列がそこを覆ってしまうため、
   固定列そのものの右側に影を出す（固定列の裏に隠れず見えるように） */
.tablewrap.scroll-r { box-shadow: inset -14px 0 10px -10px var(--scroll-shadow); }
.tablewrap.scroll-l td.name, .tablewrap.scroll-l th.name { box-shadow: 6px 0 8px -6px var(--scroll-shadow); }
table { border-collapse: separate; border-spacing: 0; width: 100%; }
th, td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
thead th {
  position: sticky; top: 0; z-index: 3; background: var(--head); font-size: 13px; font-weight: 600; vertical-align: bottom;
}
thead th.store a.store-link { color: inherit; text-decoration: underline dotted; text-underline-offset: 3px; }
thead th.store a.store-link:hover { color: var(--accent); }
thead th.store { text-align: center; } /* 買取店の名前は、左右どちらにも寄せず中央に */
thead th small { display: block; font-weight: 400; font-size: 11px; color: var(--muted); }
thead th .badge { font-size: 10px; } /* white-space: nowrap は .badge から継承（幅が足りない分は表の横スクロールに任せ、途中で折り返さない） */
.badge.notice { background: var(--notice-bg); color: var(--notice-fg); }
.tag-link { display: inline-block; background: var(--accent); color: #fff; font-size: 14px; font-weight: 700; padding: 7px 14px; border-radius: 999px; white-space: nowrap; }
.tag-link:hover { opacity: .88; text-decoration: none; }
th.name, td.name { position: sticky; left: 0; z-index: 2; text-align: left; background: var(--card); min-width: 128px; max-width: 46vw; white-space: normal; }
thead th.name { z-index: 4; background: var(--head); }
tr.group td { position: sticky; left: 0; background: var(--group); font-weight: 600; font-size: 13px; text-align: left; }
.pname { display: flex; align-items: center; gap: 8px; }
.pname img, .thumb { width: 30px; height: 42px; object-fit: contain; flex: none; background: var(--head); border-radius: 3px; }
.pname a { color: var(--text); }
td.cell { text-align: center; } /* 価格のセルは中央寄せ */
td.is-new { background: var(--new-bg); }
td.is-max { background: var(--max-bg); }
td.is-new.is-max { background: var(--max-bg); } /* 出現かつ最高値のときは、最高値の背景色を優先する */
td.is-max .price { font-weight: 700; color: var(--accent); } /* 一番高い価格は、背景だけでなく文字も強調 */
td.cell:not(.is-max) .price { color: var(--muted); } /* 一番高い価格以外は少し控えめにして、最高値を目立たせる */
td.gone { color: var(--gone-fg); }
td.gone .price { text-decoration: line-through; }
td.dash { color: var(--muted); }
td.unk { color: var(--muted); font-style: italic; }
td small { display: block; font-size: 11px; color: var(--muted); font-style: normal; }
.legend { font-size: 12px; color: var(--muted); margin: 8px 0; display: flex; gap: 12px; flex-wrap: wrap; }

.hero { display: flex; gap: 14px; align-items: flex-start; flex-wrap: wrap; margin-bottom: 8px; }
.hero img { width: 84px; height: auto; max-height: 120px; object-fit: contain; border-radius: 6px; background: var(--head); }
.hero .info { flex: 1 1 auto; min-width: 160px; }
.restock { font-size: 13px; margin: 0 0 16px; border-left: 3px solid var(--accent); padding: 2px 0 2px 12px; } /* 背景は付けず、縦線だけで区切る */
.restock .t { font-weight: 700; color: var(--accent); font-size: 15px; margin-bottom: 6px; }
.restock .restock-list { list-style: none; margin: 0; padding: 0; font-variant-numeric: tabular-nums; }
.restock .restock-list li { line-height: 1.7; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin: 8px 0 12px; }
.chip { border: 1px solid var(--line); background: var(--card); color: var(--text); padding: 4px 12px; border-radius: 999px; font-size: 13px; cursor: pointer; }
.chip[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: #fff; }
.store-reorder { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 6px; margin-top: 4px; max-width: 280px; }
.store-reorder-row { display: flex; align-items: center; gap: 6px; padding: 4px 6px; border-radius: 6px; }
.store-reorder-row:not(:last-child) { border-bottom: 1px solid var(--line); }
.store-reorder-name { flex: 1 1 auto; font-size: 13px; }
.order-btn { border: 1px solid var(--line); background: var(--bg); color: var(--muted); width: 30px; height: 30px; border-radius: 6px; font-size: 12px; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; padding: 0; flex: none; }
.order-btn:active { background: var(--head); }
.order-btn:disabled { opacity: .3; cursor: default; }
.up { color: var(--up); font-weight: 600; }
.down { color: var(--down); font-weight: 600; }
.panel { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; overflow-x: auto; }
.panel table th, .panel table td { padding: 6px 8px; }
.chart { width: 100%; height: auto; display: block; }
.chart .grid { stroke: var(--line); stroke-width: 1; }
.chart .ax { fill: var(--muted); font-size: 11px; }
.chart .ln { stroke: var(--accent); stroke-width: 2; fill: none; stroke-linejoin: round; stroke-linecap: round; }
.chart .area { stroke: none; }
.chart .pt { fill: transparent; stroke: none; } /* 見た目には出さず、ホバー時の日付・金額ポップアップの当たり判定だけ残す */
.empty { color: var(--muted); padding: 16px 4px; }
.foot { max-width: 1100px; margin: 8px auto 32px; padding: 0 16px; font-size: 12px; color: var(--muted); display: flex; flex-direction: column; gap: 2px; }
@media (min-width: 720px) { th, td { padding: 9px 14px; } }

/* ---- 管理画面 ---- */
.box { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; margin: 12px 0; }
.row-between { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; }
.row-gap { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.small { font-size: 12px; }
.steps { padding-left: 20px; margin: 8px 0 12px; }
.steps li { margin: 6px 0; }
code { background: var(--head); padding: 1px 5px; border-radius: 4px; font-size: 13px; }
.field { font: inherit; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--card); color: var(--text); min-width: 0; flex: 1 1 220px; }
.field.short { flex: 0 1 170px; }
.btn { font: inherit; font-size: 14px; padding: 8px 14px; border-radius: 8px; border: 1px solid var(--line); background: var(--card); color: var(--text); cursor: pointer; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.status { padding: 10px 12px; border-radius: 10px; margin: 8px 0; font-size: 14px; }
.status.ok { background: var(--new-bg); color: var(--new-fg); }
.status.err { background: var(--warn-bg); color: var(--warn-fg); }
.status.info { background: var(--head); color: var(--muted); }
.item { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; margin: 10px 0; display: flex; flex-direction: column; gap: 8px; }
.item-title { font-weight: 600; }
.item-price { font-variant-numeric: tabular-nums; }
.actions { display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }

/* ---- 管理画面: 買取EXPOの取り込み ---- */
.field.area { width: 100%; flex: none; display: block; margin: 8px 0; font-size: 13px; line-height: 1.5; resize: vertical; }
select.field { padding: 6px 8px; }
.chips-row { display: flex; gap: 6px; flex-wrap: wrap; margin: 6px 0 10px; }
.sub { font-size: 15px; margin: 16px 0 6px; }
.sep { border: 0; border-top: 1px solid var(--line); margin: 14px 0 10px; }
.chk { font-size: 13px; display: inline-flex; align-items: center; gap: 4px; cursor: pointer; }
details.ev { font-size: 13px; }
details.ev summary { cursor: pointer; padding: 2px 0; }
details.ev ul { margin: 4px 0 6px; padding-left: 20px; }
table.mini { width: 100%; font-size: 13px; }
table.mini td { padding: 3px 6px; text-align: left; white-space: normal; border-bottom: 1px solid var(--line); }
.status.err label { display: block; margin-top: 6px; }
.store-row { margin: 6px 0 2px; }
.store-name { font-size: 12px; font-weight: 700; color: var(--muted); }
@media (min-width: 720px) { th.name, td.name { min-width: 200px; max-width: 40vw; } }
/* スマホ: 店舗の列が4つ並んでも、できるだけ横スクロールしないように余白と文字を詰める */
@media (max-width: 480px) {
  th, td { padding: 8px 4px; font-size: 13px; }
  thead th { font-size: 12px; }
  thead th small { font-size: 9.5px; }
  th.name, td.name { min-width: 92px; max-width: 30vw; padding-left: 8px; }
  tr.group td { font-size: 12px; }
}

/* ---- ゲーム価格表のフィルタ（状態・店舗）---- */
.filters { margin: 4px 0 12px; display: flex; flex-direction: column; gap: 6px; }
.filter-label { font-size: 12px; font-weight: 700; color: var(--muted); margin: 6px 0 -2px; }
.filter-row { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.filter-row .chip { padding: 3px 11px; font-size: 12px; }
.chip.off { opacity: .45; text-decoration: line-through; }
.chip.ghost { border-style: dashed; color: var(--muted); }
.filter-actions { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-top: -2px; }
.link-btn { border: none; background: none; color: var(--accent); font-size: 12px; font-weight: 600; cursor: pointer; padding: 4px 2px; text-decoration: underline; text-underline-offset: 2px; }
