:root {
  --bg: #fafaf9; --fg: #1c1917; --muted: #78716c; --line: #e7e5e4; --card: #ffffff;
  --ok: #15803d; --warn: #b45309; --bad: #b91c1c; --link: #1d4ed8; --accent: #1d4ed8; --accent-fg: #ffffff;
  --chip: #f5f5f4;
  --deal-bg: #bbf7d0; --deal-fg: #14532d; --cheap-bg: #dcfce7; --cheap-fg: #166534;
  /* 時系列の色（ジョブの種類ごとに固定。色の見分けは検証スクリプトで確かめた組） */
  --viz-1: #2a78d6; --viz-2: #eb6834; --viz-3: #1baf7a; --viz-4: #eda100; --viz-5: #e87ba4; --viz-6: #008300;
  --viz-crit: #d03b3b;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1c1917; --fg: #f5f5f4; --muted: #a8a29e; --line: #44403c; --card: #292524;
    --ok: #4ade80; --warn: #fbbf24; --bad: #f87171; --link: #93c5fd; --accent: #3b82f6; --accent-fg: #ffffff;
    --chip: #3a3532;
    --deal-bg: #166534; --deal-fg: #dcfce7; --cheap-bg: #1f3d2a; --cheap-fg: #86efac;
    --viz-1: #3987e5; --viz-2: #d95926; --viz-3: #199e70; --viz-4: #c98500; --viz-5: #d55181; --viz-6: #008300;
    --viz-crit: #e05555;
  }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--fg); font: 15px/1.6 system-ui, "Hiragino Sans", "Yu Gothic UI", sans-serif; }
a { color: var(--link); }
.bar { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 16px; border-bottom: 1px solid var(--line); background: var(--card); position: sticky; top: 0; z-index: 2; }
.bar h1 { font-size: 18px; margin: 0; }
.who { font-size: 13px; color: var(--muted); display: flex; gap: 8px; align-items: center; min-width: 0; }
.who span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
main { max-width: 1000px; margin: 0 auto; padding: 12px 16px 40px; }
h2 { font-size: 16px; margin: 22px 0 8px; }
h3 { font-size: 15px; margin: 0 0 4px; }
.muted { color: var(--muted); } .ok { color: var(--ok); } .warn { color: var(--warn); } .bad { color: var(--bad); }
.small { font-size: 13px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; margin: 10px 0; }
.center { text-align: center; padding: 28px 16px; }
.gsi-button { display: flex; justify-content: center; min-height: 44px; }
button { font: inherit; border: 1px solid var(--line); background: var(--card); color: var(--fg); border-radius: 8px; padding: 6px 12px; cursor: pointer; white-space: nowrap; }
button.primary { background: var(--accent); color: var(--accent-fg); border-color: var(--accent); }
button.danger { color: var(--bad); }
button:disabled { opacity: .5; cursor: default; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 8px; overflow-x: auto; }
.tabs button { border: none; border-bottom: 2px solid transparent; border-radius: 0; background: none; padding: 8px 12px; white-space: nowrap; }
.tabs button[aria-selected="true"] { border-bottom-color: var(--accent); font-weight: 600; }
/* タブの区切り: 自分で登録（監視中・お得順・追加）｜自動で探す（見つけた・フリマ）｜動作状況 */
.tabs .tab-group { position: relative; margin-left: 8px; }
.tabs .tab-group::before { content: ""; position: absolute; left: -5px; top: 25%; bottom: 25%; border-left: 1px solid var(--line); }
/* スマホの幅でも6つのタブが横に収まるよう余白を詰める（収まらない文字の大きさの時は従来どおり横にスクロール） */
@media (max-width: 480px) { .tabs { gap: 0; } .tabs button { flex: 1 0 auto; padding: 8px 5px; } .tabs .tab-group { margin-left: 5px; } .tabs .tab-group::before { left: -3px; } }
.row { display: flex; gap: 8px; margin: 6px 0; }
.row input { flex: 1; min-width: 0; }
input[type=url], input[type=text] { font: inherit; padding: 6px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); color: var(--fg); }
label { font-weight: 600; }
.badge { display: inline-block; font-size: 12px; padding: 0 8px; border-radius: 999px; background: var(--chip); color: var(--muted); margin-left: 6px; vertical-align: middle; }
.head { display: flex; justify-content: space-between; gap: 8px; align-items: flex-start; }
.head { flex-wrap: wrap; }
.head > div { min-width: 0; flex: 1 1 320px; }
/* 操作ボタンは縮めず横に並べる。幅が足りなければボタン欄ごとタイトルの下へ回る */
.head > .actions { flex: 0 0 auto; flex-wrap: nowrap; margin-top: 0; }
details summary { cursor: pointer; color: var(--link); font-size: 13px; margin-top: 6px; }
.dim { margin: 10px 0; }
.dim .opts { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.opt { display: inline-flex; align-items: center; gap: 4px; background: var(--chip); border-radius: 8px; padding: 3px 8px; font-size: 13px; font-weight: 400; cursor: pointer; }
.opt input { margin: 0; }
/* アウトレットで巡回するジャンルの木（app.js の genrePicker） */
.genre-row { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 10px; margin: 4px 0; }
.genre-kids { margin-left: 14px; padding-left: 8px; border-left: 1px solid var(--line); }
.opt.pic { flex-direction: column; align-items: center; padding: 6px; width: 96px; text-align: center; font-size: 12px; }
.opt.pic .thumb { width: 72px; height: 72px; }
.thumb { width: 40px; height: 40px; object-fit: contain; background: #fff; border-radius: 6px; flex: none; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 10px; }
ul { margin: 4px 0; padding-left: 20px; }
@media (max-width: 600px) {
  .row { flex-direction: column; }
}
button.small { padding: 2px 8px; }
.reselect:not(:empty) { margin: 8px 0; padding: 8px; border: 1px solid var(--line); border-radius: 8px; }
/* お得スコアの凡例と「他の中古」の色分け（スコアの札は .rank-score） */
.legend.deal { background: var(--deal-bg); color: var(--deal-fg); font-weight: 700; }
.legend.cheap { background: var(--cheap-bg); color: var(--cheap-fg); }
.legend { display: inline-block; padding: 0 6px; border-radius: 4px; }
/* 商品のタイトル: 押すと表をたたむ（app.js の watchCard） */
.title-toggle { all: unset; cursor: pointer; font: inherit; font-weight: 700; }
.title-toggle:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
.title-toggle .chev { display: inline-block; width: 1.1em; color: var(--muted); }
/* 色・サイズ1件のカード（app.js の variantCard。監視中・お得順で共通）。上に写真と色・サイズ、下に新品・中古の2行。
   広い画面では左右に並べる。在庫切れは薄く、Keepa の推移は下に全幅で開く */
/* フリマ・動作状況の一覧（app.js の itemList）。1件ずつ、右端に価格や結果 */
.item { display: flex; align-items: center; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.item:last-child { border-bottom: none; }
.item-body { flex: 1; min-width: 0; }
.item-main, .item-note { display: -webkit-box; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; }
.item-main { -webkit-line-clamp: 2; }
.item-note { -webkit-line-clamp: 2; }
.item > :last-child:not(.item-body) { flex: none; text-align: right; white-space: nowrap; }
/* 畳んだ一覧を開くボタン（app.js の fold） */
.rank-list + div { margin-top: 10px; }
.fold-btn { display: block; width: 100%; text-align: left; margin: 8px 0 0; padding: 8px 10px; background: var(--chip); border: none; color: var(--fg); font-size: 14px; }
.rank-card.oos { color: var(--muted); }
.rank-card.oos img { opacity: .5; }
.rank-btns { flex: none; display: flex; gap: 8px; align-items: center; }
/* 外のサイトを開くリンクをボタンと同じ見た目にする（「見つけた」のメルカリ検索） */
.btn-link { display: inline-block; border: 1px solid var(--line); background: var(--card); color: var(--fg); border-radius: 8px;
  padding: 6px 12px; white-space: nowrap; text-decoration: none; }
.btn-link.small { padding: 2px 8px; }
.btn-link:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.rank-graph { grid-column: 1 / -1; }
.rank-graph img { max-width: 100%; height: auto; border-radius: 6px; background: #fff; display: block; }
.rank-card { display: grid; grid-template-columns: minmax(0, 1fr); gap: 6px 16px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.rank-head { display: flex; align-items: center; gap: 8px; min-width: 0; }
.rank-no { flex: none; width: 1.8em; text-align: right; color: var(--muted); font-variant-numeric: tabular-nums; }
.rank-name { min-width: 0; flex: 1; }
.found-title { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; }
.rank-name .link-btn { padding: 0; display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical; overflow: hidden; }
.rank-offers { display: grid; gap: 4px; }
.rank-offer { display: grid; grid-template-columns: 2.6em 2.6em 1fr auto; align-items: center; gap: 8px; }
.rank-kind { font-size: 13px; font-weight: 600; }
.rank-score { text-align: center; font-weight: 700; border-radius: 6px; padding: 1px 0; background: var(--chip); font-variant-numeric: tabular-nums; }
.rank-score.deal { background: var(--deal-bg); color: var(--deal-fg); }
.rank-score.cheap { background: var(--cheap-bg); color: var(--cheap-fg); }
.rank-score.none { background: none; color: var(--muted); }
.rank-note { color: var(--muted); min-width: 0; }
.rank-price { font-weight: 600; text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
/* 「見つけた」の価格の縦並び（app.js の priceRow）。見出し・補足・価格の3列で、価格は右にそろえる */
.price-rows { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 2px 10px; align-items: center; }
.price-row { display: contents; }
.price-label { font-size: 13px; color: var(--muted); white-space: nowrap; }
.price-note { min-width: 0; }
.price-val { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; color: var(--muted); }
.price-row.main .price-label { color: var(--fg); font-weight: 600; }
.price-row.main .price-val { color: var(--fg); font-weight: 700; font-size: 17px; }
.price-row .rank-score { display: inline-block; padding: 1px 6px; }
@media (min-width: 720px) {
  .rank-card { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-items: center; }
}
/* 右のボタン（推移・メルカリ・買わない等）が商品名の列を細くして何行も折り返すので、
   商品名と説明に写真の横の幅を全部使わせ、ボタンの箱は次の行の右へ回す（監視中・見つけた・買わないで共通。
   広い画面でも札は左右2列に分かれて左の列が狭いので、幅によらずこうする） */
.rank-head { flex-wrap: wrap; row-gap: 6px; }
.rank-btns { flex-basis: 100%; justify-content: flex-end; }
.link-btn { border: none; background: none; padding: 0; margin: 0; border-radius: 0; color: var(--muted); font-size: 13px; text-align: left; white-space: normal; overflow-wrap: anywhere; }
.link-btn:hover { text-decoration: underline; }
.link-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
/* 以前監視をやめた商品の再登録の警告（app.js の chooser） */
.stopped-warn { margin: 6px 0; padding: 6px 10px; border-radius: 8px; border: 1px solid var(--warn); color: var(--warn); font-weight: 600; }
/* 「買わない」タブ（app.js の renderSkip） */
.skip-words { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0; }
.skip-word { display: inline-flex; align-items: center; gap: 6px; padding: 2px 4px 2px 10px; border-radius: 999px; background: var(--chip); }
.skip-word.pending { opacity: .6; }
.skip-word .link-btn { font-size: 18px; line-height: 1; padding: 2px 8px; }
/* 「見つけた」タブの巡回の進み（app.js の patrolCard） */
.patrol-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.patrol-track { height: 10px; margin: 8px 0 4px; border-radius: 999px; background: var(--chip); overflow: hidden; }
.patrol-fill { height: 100%; background: var(--accent); border-radius: 999px; }
.patrol p { margin: 4px 0; }
.patrol-list { margin: 6px 0 0; padding-left: 2.2em; }
.patrol-list li.now { font-weight: 600; }

/* ---------- 動作状況: 一覧／時系列の切り替えと時系列 ---------- */
.seg-row { display: flex; flex-wrap: wrap; gap: 8px; margin: 6px 0 4px; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg button { border: none; border-radius: 0; padding: 6px 14px; background: var(--card); color: var(--muted); }
.seg button + button { border-left: 1px solid var(--line); }
.seg button[aria-pressed="true"] { background: var(--accent); color: var(--accent-fg); }
.tl-legend { display: flex; flex-wrap: wrap; gap: 4px 14px; margin-bottom: 10px; color: var(--fg); }
.tl-legend span { display: inline-flex; align-items: center; gap: 6px; }
.tl-swatch { display: inline-block; width: 14px; height: 8px; border-radius: 4px; }
.tl-lanes { position: relative; }
.tl-lane { margin-bottom: 10px; }
.tl-label { display: flex; justify-content: space-between; gap: 8px; margin-bottom: 2px; }
.tl-track { position: relative; height: 26px; background: var(--chip); border-radius: 6px; }
.tl-grid { position: absolute; top: 0; bottom: 0; width: 1px; background: var(--line); }
.tl-track::after { content: ""; position: absolute; top: -3px; bottom: -3px; right: 0; width: 2px; background: var(--fg); border-radius: 1px; }
/* 24時間だと1回が1〜2px になるので、縁取りで隣を覆わない（細くても色がそのまま見えるように） */
.tl-bar { position: absolute; top: 5px; height: 16px; min-width: 2px; padding: 0; border: none; border-radius: 3px; cursor: pointer; }
.tl-bar.picked { outline: 2px solid var(--fg); outline-offset: 2px; z-index: 2; }
.tl-bar.running, .tl-swatch.running { opacity: .45; }
.tl-bar:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.k0 { background: var(--muted); }
.k1 { background: var(--viz-1); } .k2 { background: var(--viz-2); } .k3 { background: var(--viz-3); }
.k4 { background: var(--viz-4); } .k5 { background: var(--viz-5); } .k6 { background: var(--viz-6); }
.tl-err, .tl-err-key { position: absolute; top: -9px; left: 50%; transform: translateX(-50%); width: 14px; height: 14px;
  border-radius: 50%; background: var(--viz-crit); color: #fff; font: 700 10px/14px system-ui, sans-serif; text-align: center; }
.tl-err-key { position: static; transform: none; display: inline-block; }
.tl-axis { position: relative; height: 18px; }
.tl-axis span { position: absolute; transform: translateX(-50%); white-space: nowrap; }
.tl-axis .tl-now-label { right: 0; transform: none; color: var(--fg); font-weight: 600; }
