/* 買い物推薦(楽天市場の商品から選ぶ) スマホ版
   YouTube推薦 スマホ版(第4版)の見た目を元に、色を緑系にし、商品のカードの部品を足した(下の「買い物推薦の部品」)。
   Layout: 上に日付のバー、下に6つのタブ。「今日」は分野ごと(または点数順)のランキングのカード。
   色と文字の大きさは :root の値でまとめて変える(暗い表示・文字の大きさの設定に対応)。 */
:root {
  --bg: #f4f5f1;
  --surface: #ffffff;
  --surface-2: #e9ece4;
  --fg: #1a2018;
  --muted: #57604f;
  --line: #d7dccf;
  --accent: #2c6e49;
  --accent-fg: #ffffff;
  --accent-soft: #dcefe2;
  --ok: #1d7a3e;
  --ok-bg: #dff3e5;
  --warn: #7f5200;
  --warn-bg: #fbefcf;
  --bad: #a62626;
  --bad-bg: #fbe0e0;
  --rank-1: #8c5c00;
  --rank-2: #5f6b78;
  --rank-3: #8a5232;
  --overlay: rgba(10, 14, 18, 0.78);
  --shadow: 0 1px 2px rgba(16, 24, 32, 0.06);
  --font-ui: system-ui, -apple-system, "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP", "Yu Gothic UI", Meiryo, sans-serif;
  --font-mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --fs-2xs: 0.6875rem;
  --fs-xs: 0.75rem;
  --fs-s: 0.8125rem;
  --fs-m: 0.9375rem;
  --fs-l: 1.0625rem;
  --fs-xl: 1.25rem;
  --radius: 12px;
  --tabbar-h: 58px;
  --thumb-w: 136px;
  --pthumb-w: 104px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #121512;
    --surface: #1b201b;
    --surface-2: #252b24;
    --fg: #e6ebe3;
    --muted: #a1ab9c;
    --line: #323a30;
    --accent: #7fcf9c;
    --accent-fg: #0b2615;
    --accent-soft: #173322;
    --ok: #82d8a0;
    --ok-bg: #173825;
    --warn: #f0c96b;
    --warn-bg: #3b2f12;
    --bad: #f3a0a0;
    --bad-bg: #3d1b1b;
    --rank-1: #8c5c00;
    --rank-2: #5f6b78;
    --rank-3: #8a5232;
    --shadow: none;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #121512;
  --surface: #1b201b;
  --surface-2: #252b24;
  --fg: #e6ebe3;
  --muted: #a1ab9c;
  --line: #323a30;
  --accent: #7fcf9c;
  --accent-fg: #0b2615;
  --accent-soft: #173322;
  --ok: #82d8a0;
  --ok-bg: #173825;
  --warn: #f0c96b;
  --warn-bg: #3b2f12;
  --bad: #f3a0a0;
  --bad-bg: #3d1b1b;
  --rank-1: #8c5c00;
  --rank-2: #5f6b78;
  --rank-3: #8a5232;
  --shadow: none;
  color-scheme: dark;
}
/* 文字の大きさ(設定の「見やすさ」) */
:root[data-size="l"] {
  --fs-2xs: 0.8125rem;
  --fs-xs: 0.875rem;
  --fs-s: 0.9375rem;
  --fs-m: 1.0625rem;
  --fs-l: 1.1875rem;
  --fs-xl: 1.375rem;
  --thumb-w: 120px;
  --pthumb-w: 92px;
}
:root[data-size="xl"] {
  --fs-2xs: 0.9375rem;
  --fs-xs: 1rem;
  --fs-s: 1.0625rem;
  --fs-m: 1.1875rem;
  --fs-l: 1.3125rem;
  --fs-xl: 1.5rem;
  --thumb-w: 112px;
  --pthumb-w: 84px;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-ui);
  font-size: var(--fs-m);
  line-height: 1.6;
  -webkit-tap-highlight-color: transparent;
}
[hidden] { display: none !important; }
img { max-width: 100%; }
a { color: var(--accent); }
button, input, textarea, select { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.mono { font-family: var(--font-mono); font-size: 0.92em; overflow-wrap: anywhere; }
.icon { width: 18px; height: 18px; flex: 0 0 auto; }
strong { font-weight: 700; }

/* ---- 上のバー ---- */
.appbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
  padding-top: env(safe-area-inset-top, 0px);
}
.appbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-block: 8px;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  max-width: 720px;
  margin: 0 auto;
}
.brand { display: flex; align-items: baseline; gap: 10px; min-width: 0; flex-wrap: wrap; }
.brand-name { font-size: var(--fs-l); font-weight: 800; letter-spacing: 0.02em; }
.brand-date { font-size: var(--fs-s); color: var(--muted); }
.usage {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 999px;
  padding: 3px 10px;
  font-size: var(--fs-xs);
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  cursor: pointer;
  min-height: 32px;
}

/* ---- 本文 ---- */
.wrap {
  max-width: 720px;
  margin: 0 auto;
  padding-block: 12px calc(var(--tabbar-h) + 28px + env(safe-area-inset-bottom, 0px));
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}
.view { display: flex; flex-direction: column; gap: 16px; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.hint { margin: 0; color: var(--muted); font-size: var(--fs-s); }
.note { color: var(--muted); font-size: var(--fs-xs); }
p.note { margin: 0; }
.msg { margin: 0; font-size: var(--fs-s); border-radius: 8px; padding: 8px 12px; background: var(--surface-2); }
.msg.ok { background: var(--ok-bg); color: var(--ok); }
.msg.bad { background: var(--bad-bg); color: var(--bad); }
.warn-text { margin: 0; color: var(--warn); font-size: var(--fs-s); }
.version { margin: 0; color: var(--muted); font-size: var(--fs-xs); text-align: center; }
.inline-icon { font-weight: 700; }

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.panel-title { margin: 0; font-size: var(--fs-m); font-weight: 700; }
details.panel > summary { cursor: pointer; list-style: revert; }
details.panel[open] > summary { margin-bottom: 2px; }
details.panel:not([open]) { gap: 0; }   /* 閉じているときに見出しの下へ空きが出ないように */
details, .panel { scroll-margin-top: calc(64px + env(safe-area-inset-top, 0px)); }   /* 上のバーに隠れないように */
.sub-title { margin: 6px 0 0; font-size: var(--fs-s); font-weight: 700; }
.field-label { margin: 0; font-size: var(--fs-s); font-weight: 700; }
.field-block { display: flex; flex-direction: column; gap: 6px; }

/* ---- ボタンと入力 ---- */
.btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--fg);
  border-radius: 8px;
  padding: 8px 14px;
  min-height: 42px;
  font-size: var(--fs-s);
  font-weight: 600;
  cursor: pointer;
  text-align: center;
}
.btn:disabled { opacity: 0.45; cursor: default; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-fg); }
.btn.big { width: 100%; min-height: 54px; font-size: var(--fs-l); font-weight: 700; border-radius: 10px; }
.btn.small { min-height: 34px; padding: 4px 12px; font-size: var(--fs-xs); }
.btn.danger-quiet { background: transparent; color: var(--bad); border-color: var(--line); }
.btn.armed { background: var(--bad-bg); border-color: var(--bad); color: var(--bad); }
.btn.primary.armed, .btn.armed:not(.danger-quiet) { background: var(--warn-bg); border-color: var(--warn); color: var(--warn); }
.btn.link { background: transparent; border: none; color: var(--accent); padding: 4px 0; min-height: 34px; font-weight: 600; justify-content: flex-start; }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; }
.field-row { display: flex; gap: 8px; align-items: stretch; }
.field-row input { flex: 1 1 auto; min-width: 0; }
input[type="text"], input[type="password"], input[type="search"], textarea, select {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  min-height: 42px;
  font-size: 16px; /* iPhone で入力時に拡大されないように */
  width: 100%;
}
.field-row input[type="text"], .field-row input[type="password"], .field-row input[type="search"] { width: auto; }
select { width: auto; max-width: 100%; }
textarea { font-family: var(--font-mono); font-size: 13px; line-height: 1.5; resize: vertical; }
@media (max-width: 380px) { textarea { font-size: 16px; } }

/* 2〜3択の切り替え(ラジオボタンを横並びのボタンに見せる) */
.seg { display: flex; flex-wrap: wrap; gap: 0; border: 1px solid var(--line); border-radius: 10px; padding: 3px; margin: 0; background: var(--surface-2); min-width: 0; }
.seg label { flex: 1 1 auto; position: relative; }
.seg input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.seg span, .seg button {
  display: flex; align-items: center; justify-content: center; text-align: center;
  min-height: 36px; padding: 4px 10px; border-radius: 8px; border: none; background: transparent;
  font-size: var(--fs-s); font-weight: 600; color: var(--muted); cursor: pointer; width: 100%;
}
.seg input:checked + span, .seg button[aria-pressed="true"] { background: var(--surface); color: var(--fg); box-shadow: 0 1px 2px rgba(0, 0, 0, 0.12); }
.seg input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 1px; }
.seg.inline { display: inline-flex; flex-wrap: nowrap; }
.seg.inline button { width: auto; white-space: nowrap; }

/* 画面の下に出る短いお知らせ */
.snackbar {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(var(--tabbar-h) + 12px + env(safe-area-inset-bottom, 0px));
  z-index: 40;
  width: min(688px, calc(100% - 32px));
  display: flex;
  align-items: center;
  gap: 12px;
  background: #1f2830;
  color: #f2f6f9;
  border-radius: 10px;
  padding: 10px 14px;
  font-size: var(--fs-s);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
}
.snackbar.ok { background: #17492b; }
.snackbar.bad { background: #6d1d1d; }
.snack-text { flex: 1 1 auto; min-width: 0; overflow-wrap: anywhere; }
.snack-act { appearance: none; background: transparent; border: 1px solid rgba(255, 255, 255, 0.5); color: #fff; border-radius: 8px; padding: 6px 10px; font-weight: 700; font-size: var(--fs-s); cursor: pointer; white-space: nowrap; min-height: 36px; }

.warnings { background: var(--warn-bg); color: var(--warn); border-radius: 8px; padding: 8px 12px; font-size: var(--fs-s); }
.warnings ul { margin: 4px 0 0; padding-left: 1.2em; }

/* ---- 説明のかたまり ---- */
.explain > summary { cursor: pointer; font-weight: 700; color: var(--accent); font-size: var(--fs-s); }
.explain-body { display: flex; flex-direction: column; gap: 8px; font-size: var(--fs-s); }
.explain-body p { margin: 0; }
.flow-list { margin: 0; padding-left: 1.4em; display: flex; flex-direction: column; gap: 6px; font-size: var(--fs-s); }
.plain-list { margin: 0; padding-left: 1.2em; display: flex; flex-direction: column; gap: 5px; font-size: var(--fs-s); }
.example { background: var(--surface-2); border-radius: 8px; padding: 8px 12px; display: flex; flex-direction: column; gap: 4px; font-size: var(--fs-s); }
.example p { margin: 0; }
.example-title { font-weight: 700; font-size: var(--fs-xs); color: var(--muted); }
.kw-sample { background: var(--surface); border: 1px solid var(--line); border-radius: 6px; padding: 1px 6px; }
.steps { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; font-size: var(--fs-s); }
.steps li { display: grid; grid-template-columns: 28px minmax(0, 1fr); gap: 8px; align-items: start; }
.step-n { width: 26px; height: 26px; border-radius: 50%; background: var(--accent); color: var(--accent-fg); display: inline-flex; align-items: center; justify-content: center; font-weight: 800; font-size: var(--fs-xs); }
.steps .btn { margin-top: 6px; }

/* ---- 今日: 状態 ---- */
.status { gap: 10px; }
.status-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.status-title { margin: 0; font-size: var(--fs-l); font-weight: 800; }
.status-time { font-size: var(--fs-xs); color: var(--muted); font-variant-numeric: tabular-nums; }
.status-line { margin: 0; font-size: var(--fs-s); color: var(--muted); }
.status-error { background: var(--bad-bg); color: var(--bad); border-radius: 8px; padding: 10px 12px; font-size: var(--fs-s); margin: 0; display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
.status-error p { margin: 0; }
.status-sample { background: var(--warn-bg); color: var(--warn); border-radius: 8px; padding: 10px 12px; font-size: var(--fs-s); margin: 0; }
progress { width: 100%; height: 8px; accent-color: var(--accent); }
.progress-list { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: var(--fs-xs); color: var(--muted); }
.progress-list li { display: inline-flex; gap: 4px; align-items: baseline; }
.progress-list .pl-done { color: var(--ok); }
.progress-list .pl-now { color: var(--fg); font-weight: 700; }
.onboard p { margin: 0; font-size: var(--fs-s); }

/* ---- 今日: しぼり込みと並べ方 ---- */
.toolbar { display: flex; flex-direction: column; gap: 8px; }
.chip-scroll { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; margin-inline: -16px; padding-inline: 16px; scroll-padding-inline: 16px; }
.chip-scroll::-webkit-scrollbar { display: none; }
.fchip {
  appearance: none; flex: 0 0 auto; display: inline-flex; align-items: center; gap: 6px;
  border: 1px solid var(--line); background: var(--surface); color: var(--fg);
  border-radius: 999px; padding: 4px 12px; min-height: 36px; font-size: var(--fs-s); font-weight: 600; cursor: pointer; white-space: nowrap;
}
.fchip[aria-pressed="true"] { background: var(--fg); color: var(--bg); border-color: var(--fg); }
.fchip-n { font-size: var(--fs-xs); opacity: 0.75; font-variant-numeric: tabular-nums; }
.toolbar-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.toolbar-label { font-size: var(--fs-xs); color: var(--muted); }

/* ---- 今日: 分野の見出し ---- */
.group { display: flex; flex-direction: column; gap: 8px; }
.group-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; border-bottom: 2px solid var(--line); padding-bottom: 4px; flex-wrap: wrap; }
.group-title { margin: 0; font-size: var(--fs-l); font-weight: 800; text-wrap: balance; }
.group-count { font-size: var(--fs-xs); color: var(--muted); margin-left: 6px; font-weight: 400; }
.none { margin: 0; color: var(--muted); font-size: var(--fs-s); background: var(--surface); border: 1px dashed var(--line); border-radius: var(--radius); padding: 10px 12px; }
.rank-list { display: flex; flex-direction: column; gap: 8px; }

/* ---- 動画のカード ---- */
.video {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.video-top { display: grid; grid-template-columns: var(--thumb-w) minmax(0, 1fr); gap: 12px; align-items: start; text-decoration: none; color: inherit; }
.thumb-wrap { position: relative; width: var(--thumb-w); height: calc(var(--thumb-w) * 9 / 16); border-radius: 8px; overflow: hidden; background: var(--surface-2); }   /* 16:9。古い iPhone のため aspect-ratio は使わない */
.thumb { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb-empty { width: 100%; height: 100%; background: var(--surface-2); }
.rank-badge {
  position: absolute; top: 0; left: 0; min-width: 28px; height: 28px; padding: 0 6px;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--overlay); color: #fff; font-weight: 800; font-size: 0.875rem; border-bottom-right-radius: 8px; font-variant-numeric: tabular-nums;
}
.rank-badge.rank-1 { background: var(--rank-1); }
.rank-badge.rank-2 { background: var(--rank-2); }
.rank-badge.rank-3 { background: var(--rank-3); }
.duration { position: absolute; right: 4px; bottom: 4px; background: var(--overlay); color: #fff; font-size: 0.6875rem; font-weight: 600; padding: 0 5px; border-radius: 4px; line-height: 1.6; font-variant-numeric: tabular-nums; }
.watched-badge { position: absolute; left: 4px; bottom: 4px; background: var(--overlay); color: #fff; font-size: 0.6875rem; font-weight: 700; padding: 0 6px; border-radius: 4px; line-height: 1.6; }
.video.is-watched .thumb { opacity: 0.72; }
.video-body { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.video-title { font-size: var(--fs-m); font-weight: 700; line-height: 1.45; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; }
a.video-top:active .video-title { color: var(--accent); }
.sub { font-size: var(--fs-xs); color: var(--muted); overflow-wrap: anywhere; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { font-size: var(--fs-xs); border-radius: 999px; padding: 2px 9px; background: var(--surface-2); color: var(--fg); font-variant-numeric: tabular-nums; white-space: nowrap; }
.chip.accent { background: var(--accent-soft); color: var(--accent); font-weight: 700; }

.score-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.score-badge { display: inline-flex; align-items: baseline; gap: 1px; border-radius: 8px; padding: 1px 10px; font-weight: 800; font-size: var(--fs-l); font-variant-numeric: tabular-nums; line-height: 1.5; }
.score-badge small { font-size: var(--fs-2xs); font-weight: 700; margin-left: 1px; }
.risk-low { background: var(--ok-bg); color: var(--ok); }
.risk-mid { background: var(--warn-bg); color: var(--warn); }
.risk-high { background: var(--bad-bg); color: var(--bad); }
.risk-text { font-size: var(--fs-xs); color: var(--muted); }

.points-label { font-size: var(--fs-xs); font-weight: 700; color: var(--muted); margin: 0; }
.points { margin: 0; padding-left: 1.2em; font-size: var(--fs-s); display: flex; flex-direction: column; gap: 2px; }
.points li { overflow-wrap: anywhere; }
.points-block { display: flex; flex-direction: column; gap: 4px; }

.actions { display: flex; gap: 8px; }
.act {
  appearance: none; flex: 1 1 0; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 40px; border: 1px solid var(--line); border-radius: 8px; background: transparent; color: var(--fg);
  font-size: var(--fs-s); font-weight: 600; cursor: pointer; padding: 4px 8px;
}
.act[aria-pressed="true"] { color: var(--accent); border-color: var(--accent); background: var(--accent-soft); }

/* 評価の根拠(点数の内訳) */
.reasons { border-top: 1px solid var(--line); padding-top: 6px; }
.reasons > summary { cursor: pointer; font-size: var(--fs-s); font-weight: 700; color: var(--accent); min-height: 32px; display: flex; align-items: center; gap: 6px; list-style: none; }
.reasons > summary::-webkit-details-marker { display: none; }
.reasons > summary::before { content: "▸"; display: inline-block; transition: transform 0.15s ease; }
.reasons[open] > summary::before { transform: rotate(90deg); }
.bd { display: flex; flex-direction: column; gap: 12px; padding-top: 6px; }
.bd p { margin: 0; }
.bd-total { font-size: var(--fs-s); }
.bd-total strong { font-size: var(--fs-l); }
.bd-rule { font-size: var(--fs-xs); color: var(--muted); }
.bd-row { display: flex; flex-direction: column; gap: 4px; }
.bd-head { display: flex; justify-content: space-between; gap: 8px; font-size: var(--fs-s); font-weight: 700; }
.bd-pts { font-variant-numeric: tabular-nums; white-space: nowrap; }
.bar { height: 7px; border-radius: 4px; background: var(--surface-2); overflow: hidden; }
.bar > span { display: block; height: 100%; border-radius: 4px; background: var(--accent); }
.bar.lowish > span { background: var(--warn); }
.bd-facts { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; font-size: var(--fs-xs); }
.bd-facts li { display: grid; grid-template-columns: 1.3em minmax(0, 1fr); overflow-wrap: anywhere; }
.mk { font-weight: 800; text-align: center; }
.mk-plus { color: var(--ok); }
.mk-minus { color: var(--muted); }
.mk-warn { color: var(--warn); }
.mk-info { color: var(--muted); }
.bd-extra { background: var(--surface-2); border-radius: 8px; padding: 8px 10px; font-size: var(--fs-xs); display: flex; flex-direction: column; gap: 2px; }
.bd-extra-title { font-weight: 700; color: var(--muted); }

/* ---- あとで見る ---- */
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; border-bottom: 2px solid var(--line); padding-bottom: 4px; }
.section-title { margin: 0; font-size: var(--fs-l); font-weight: 800; }
.section-count { font-size: var(--fs-xs); color: var(--muted); }
.empty p { margin: 0; }
.archive-day > summary { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.archive-day[open] { gap: 8px; }

/* ---- キーワード ---- */
.kw-summary p { margin: 0; font-size: var(--fs-s); }
.kw-group { gap: 10px; }
.kw-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.kw-head .panel-title { display: inline-flex; align-items: baseline; gap: 6px; flex-wrap: wrap; font-size: var(--fs-l); }
.tag { font-size: var(--fs-2xs); font-weight: 700; border-radius: 999px; padding: 1px 8px; background: var(--accent-soft); color: var(--accent); white-space: nowrap; }
.tag.today { background: var(--ok-bg); color: var(--ok); }
.tag.spare { background: var(--surface-2); color: var(--muted); }
.kw-today { font-size: var(--fs-xs); color: var(--muted); }
.kw-settings { display: flex; flex-direction: column; gap: 8px; background: var(--surface-2); border-radius: 8px; padding: 8px 10px; }
.kw-setting { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; font-size: var(--fs-s); }
.kw-setting-name { font-weight: 700; min-width: 7.5em; }
.kw-setting-desc { flex: 1 1 100%; font-size: var(--fs-xs); color: var(--muted); }
.kw-setting select { background: var(--surface); min-height: 38px; }
.stepper { display: inline-flex; align-items: center; gap: 4px; }
.stepper .btn { min-width: 42px; min-height: 38px; padding: 4px 0; font-size: var(--fs-l); background: var(--surface); }
.stepper output { min-width: 2.2em; text-align: center; font-variant-numeric: tabular-nums; font-weight: 800; font-size: var(--fs-m); }
.kw-rotation { margin: 0; display: flex; flex-wrap: wrap; gap: 4px 6px; font-size: var(--fs-xs); align-items: center; }
.rot-item { display: inline-flex; gap: 4px; align-items: baseline; border: 1px solid var(--line); border-radius: 999px; padding: 1px 8px; }
.rot-item.is-today { border-color: var(--ok); color: var(--ok); font-weight: 700; }
.rot-day { color: var(--muted); font-weight: 400; }
.rot-label { font-weight: 700; color: var(--muted); }
.kw-list-title { margin: 0; font-size: var(--fs-xs); font-weight: 700; color: var(--muted); }
.kw-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; border-top: 1px solid var(--line); }
.kw-item { display: grid; grid-template-columns: 22px minmax(0, 1fr) auto; align-items: center; gap: 6px; border-bottom: 1px solid var(--line); padding-block: 2px; }
.kw-item.is-spare .kw-text { color: var(--muted); }
.kw-num { font-size: var(--fs-2xs); font-weight: 800; color: var(--muted); text-align: center; font-variant-numeric: tabular-nums; }
.kw-text { font-size: var(--fs-s); min-width: 0; overflow-wrap: anywhere; }
.kw-acts { display: inline-flex; gap: 0; }
.icon-btn { appearance: none; display: inline-flex; align-items: center; justify-content: center; width: 38px; height: 38px; border: none; background: transparent; color: var(--muted); border-radius: 8px; cursor: pointer; text-decoration: none; }
.icon-btn:disabled { opacity: 0.3; cursor: default; }
.icon-btn:active { background: var(--surface-2); }
.icon-btn.danger:active { background: var(--bad-bg); color: var(--bad); }
.kw-divider { font-size: var(--fs-2xs); color: var(--muted); padding: 4px 0 2px 28px; border-bottom: 1px dashed var(--line); }
.kw-sub-block { display: flex; flex-direction: column; gap: 4px; border-left: 3px solid var(--line); padding-left: 10px; }
.kw-sub-block.is-today { border-left-color: var(--ok); }
.kw-sub-head { display: flex; align-items: baseline; gap: 6px; font-weight: 700; font-size: var(--fs-s); flex-wrap: wrap; }
.kw-unused { border-left-color: var(--warn); }
.kw-add { display: flex; flex-direction: column; gap: 6px; }
.kw-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.format-list { margin: 6px 0 0; display: flex; flex-direction: column; gap: 4px; font-size: var(--fs-xs); }
.format-list div { display: grid; grid-template-columns: minmax(0, 11em) minmax(0, 1fr); gap: 8px; }
.format-list dt { margin: 0; }
.format-list dd { margin: 0; color: var(--muted); }

/* ---- 設定 ---- */
.key-status { border-radius: 8px; padding: 8px 12px; font-size: var(--fs-s); background: var(--surface-2); }
.key-status.ok { background: var(--ok-bg); color: var(--ok); }
.key-status.warn { background: var(--warn-bg); color: var(--warn); }
.key-status.bad { background: var(--bad-bg); color: var(--bad); }
.howto { border-top: 1px solid var(--line); padding-top: 8px; }
.howto > summary { cursor: pointer; font-size: var(--fs-s); color: var(--accent); font-weight: 700; display: flex; align-items: center; gap: 8px; min-height: 34px; }
.howto[open] > summary { margin-bottom: 6px; }
.letter { display: inline-flex; width: 22px; height: 22px; border-radius: 6px; align-items: center; justify-content: center; background: var(--accent); color: var(--accent-fg); font-size: var(--fs-xs); font-weight: 800; flex: 0 0 auto; }
.howto-steps { padding-left: 1.3em; margin: 0 0 6px; font-size: var(--fs-s); display: flex; flex-direction: column; gap: 8px; }
.howto-steps .plain-list { margin-top: 4px; }
.addr-box { display: flex; align-items: center; gap: 8px; margin: 4px 0; padding: 6px 8px; background: var(--surface-2); border-radius: 8px; }
.addr-box .mono { flex: 1 1 auto; min-width: 0; }
.addr-box .btn { flex: 0 0 auto; white-space: nowrap; }
.trouble { margin: 0; display: flex; flex-direction: column; gap: 2px; font-size: var(--fs-s); }
.trouble dt { font-weight: 700; margin-top: 6px; }
.trouble dd { margin: 0; color: var(--muted); }
.meter { height: 10px; border-radius: 5px; background: var(--surface-2); overflow: hidden; }
.meter > span { display: block; height: 100%; background: var(--accent); border-radius: 5px; }
.meter.high > span { background: var(--warn); }
.usage-text { margin: 0; font-size: var(--fs-s); font-variant-numeric: tabular-nums; }
.facts { margin: 0; display: flex; flex-direction: column; gap: 6px; }
.facts div { display: flex; justify-content: space-between; gap: 12px; font-size: var(--fs-s); }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; font-variant-numeric: tabular-nums; font-weight: 700; white-space: nowrap; }

/* ---- 使い方 ---- */
.help-intro p { margin: 0; font-size: var(--fs-s); }
.help p { margin: 0; font-size: var(--fs-s); }
.help-list { margin: 0; display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 6px 12px; font-size: var(--fs-s); }
.help-list dt { font-weight: 700; white-space: nowrap; }
.help-list dd { margin: 0; }
.score-list { margin: 0; display: flex; flex-direction: column; gap: 8px; font-size: var(--fs-s); }
.score-list div { background: var(--surface-2); border-radius: 8px; padding: 8px 10px; }
.score-list dt { font-weight: 700; display: flex; justify-content: space-between; gap: 8px; }
.score-list .max { color: var(--accent); font-variant-numeric: tabular-nums; }
.score-list dd { margin: 2px 0 0; color: var(--fg); }

/* ---- 「くわしく」などのボタンで開く説明 ---- */
details.more > summary {
  display: inline-flex; align-items: center; gap: 6px; cursor: pointer; list-style: none;
  min-height: 34px; padding: 4px 14px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--surface); color: var(--accent);
  font-size: var(--fs-xs); font-weight: 700;
}
details.more > summary::-webkit-details-marker { display: none; }
details.more > summary::before { content: "▸"; display: inline-block; }
details.more[open] > summary { background: var(--accent-soft); border-color: var(--accent); margin-bottom: 8px; }
details.more[open] > summary::before { transform: rotate(90deg); }
.more-body { display: flex; flex-direction: column; gap: 6px; padding-left: 12px; border-left: 3px solid var(--accent-soft); font-size: var(--fs-s); }
.more-body p { margin: 0; }
.more-body .flow-list, .more-body .score-list { margin: 0; }
details.more.big > summary { display: flex; width: 100%; justify-content: center; min-height: 44px; font-size: var(--fs-s); border-radius: 10px; }
.tips { display: flex; flex-direction: column; gap: 14px; }
.tip { display: flex; flex-direction: column; gap: 6px; font-size: var(--fs-s); }
.tip p { margin: 0; }
.tip .sub-title { margin: 0; font-size: var(--fs-m); }
.flow-simple { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 0; font-size: var(--fs-s); color: var(--muted); }
.flow-simple span { background: var(--accent-soft); color: var(--accent); font-weight: 700; border-radius: 999px; padding: 3px 12px; }
.bd-short { margin: 0; font-size: var(--fs-xs); color: var(--fg); overflow-wrap: anywhere; }
.bd-detail-name { font-weight: 700; font-size: var(--fs-xs); margin-top: 4px !important; }
.steps details.more { margin-top: 4px; }

@media (prefers-reduced-motion: no-preference) {
  details.more > summary::before { transition: transform 0.15s ease; }
}

/* ---- 下のタブ ---- */
.tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 30;
  display: flex;
  background: var(--surface);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom, 0px);
  padding-left: env(safe-area-inset-left, 0px);
  padding-right: env(safe-area-inset-right, 0px);
}
.tab {
  flex: 1 1 0;
  min-width: 0;
  min-height: var(--tabbar-h);
  background: transparent;
  border: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  font-size: 0.6875rem;
  font-weight: 700;
  color: var(--muted);
  cursor: pointer;
  padding: 4px 2px;
}
.tab span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.tab-icon { width: 22px; height: 22px; }
.tab[aria-selected="true"] { color: var(--accent); }
.tab[aria-selected="true"] .tab-icon { stroke-width: 2.4; }

@media (prefers-reduced-motion: no-preference) {
  .btn, .tab, .icon-btn, .act, .fchip { transition: background-color 0.15s ease, color 0.15s ease; }
}
@media (min-width: 600px) {
  :root { --thumb-w: 176px; --pthumb-w: 128px; }
}

/* ================================================================
   買い物推薦の部品(商品のカード・値段・目印・設定の数の欄など)
   ================================================================ */
.brand-sub { font-size: var(--fs-xs); color: var(--muted); white-space: nowrap; }
.item {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.item-top { display: grid; grid-template-columns: var(--pthumb-w) minmax(0, 1fr); gap: 12px; align-items: start; text-decoration: none; color: inherit; }
.pthumb-wrap { position: relative; width: var(--pthumb-w); height: var(--pthumb-w); border-radius: 8px; overflow: hidden; background: #ffffff; border: 1px solid var(--line); }   /* 商品の画像は白地が多いので、暗い表示でも白い台に置く */
.pthumb { width: 100%; height: 100%; object-fit: contain; display: block; }
.pthumb-empty { width: 100%; height: 100%; background: var(--surface-2); }
.item.is-opened .pthumb { opacity: 0.75; }
.item.is-hidden { opacity: 0.6; }
.item-body { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.item-title { font-size: var(--fs-m); font-weight: 700; line-height: 1.45; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; }
a.item-top:active .item-title { color: var(--accent); }
.price-row { display: flex; align-items: baseline; flex-wrap: wrap; gap: 2px 6px; margin-top: 2px; }
.price { font-size: var(--fs-xl); font-weight: 800; font-variant-numeric: tabular-nums; line-height: 1.3; }
.price-note { font-size: var(--fs-2xs); color: var(--muted); }
.sub.eff strong, .sub.unit strong { color: var(--fg); font-variant-numeric: tabular-nums; }
.badges { display: flex; flex-wrap: wrap; gap: 6px; }
.badge { font-size: var(--fs-xs); border-radius: 6px; padding: 1px 8px; background: var(--surface-2); color: var(--fg); white-space: nowrap; font-variant-numeric: tabular-nums; }
.badge.good { background: var(--ok-bg); color: var(--ok); font-weight: 700; }
.lv-high { background: var(--ok-bg); color: var(--ok); }
.lv-mid { background: var(--warn-bg); color: var(--warn); }
.lv-low { background: var(--bad-bg); color: var(--bad); }
.why { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; font-size: var(--fs-s); }
.why li { display: grid; grid-template-columns: 1.3em minmax(0, 1fr); overflow-wrap: anywhere; }
.why.caution { font-size: var(--fs-xs); }
.pfacts { margin: 0; display: flex; flex-direction: column; gap: 2px; font-size: var(--fs-s); }
.pfacts div { display: grid; grid-template-columns: minmax(4.5em, auto) minmax(0, 1fr); gap: 8px; }
.pfacts dt { color: var(--muted); font-size: var(--fs-xs); padding-top: 2px; }
.pfacts dd { margin: 0; overflow-wrap: anywhere; }
.hide-row { display: flex; flex-direction: column; gap: 6px; align-items: stretch; background: var(--surface-2); border-radius: 8px; padding: 8px 10px; }
.hide-row .btn { justify-content: flex-start; }
.hidden-note { margin: 0; font-size: var(--fs-xs); color: var(--warn); }
.bd-fullname { font-size: var(--fs-xs); color: var(--muted); overflow-wrap: anywhere; }
.saved-price { display: flex; flex-wrap: wrap; gap: 4px 10px; font-size: var(--fs-xs); color: var(--muted); font-variant-numeric: tabular-nums; }
.chg { font-weight: 700; color: var(--fg); }
.chg.good { color: var(--ok); }
.chg.bad { color: var(--bad); }
.range-row { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.range-row input { width: 6.2em; min-width: 0; background: var(--surface); }
.kw-setting .field-row.grow { flex: 1 1 14em; }
.kw-setting .field-row.grow input { background: var(--surface); }
.num-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.num-input { display: inline-flex; align-items: center; gap: 6px; font-size: var(--fs-s); }
.num-input input { width: 6.5em; text-align: right; font-variant-numeric: tabular-nums; }
.check { display: flex; align-items: center; gap: 8px; font-size: var(--fs-s); min-height: 40px; cursor: pointer; }
.check input { width: 20px; height: 20px; accent-color: var(--accent); }
.hidden-ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; border-top: 1px solid var(--line); }
.hidden-ul li { display: flex; align-items: center; justify-content: space-between; gap: 8px; border-bottom: 1px solid var(--line); padding: 4px 0; font-size: var(--fs-s); }
.hidden-label { min-width: 0; overflow-wrap: anywhere; }
.seg.inline.wrap-ok { flex-wrap: wrap; }
.credit { margin-top: 24px; display: flex; flex-direction: column; gap: 4px; align-items: center; text-align: center; font-size: var(--fs-xs); color: var(--muted); }
.credit p { margin: 0; }
.credit a { font-weight: 700; }
