:root {
  --bg: #fbfaf8; --fg: #1d1c1a; --muted: #6b6862; --line: #ddd9d2;
  --panel: #ffffff; --accent: #2f6f4f; --warn: #8a5a12; --warn-bg: #fdf6e6;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #17181a; --fg: #e9e7e3; --muted: #a4a09a; --line: #34363a;
    --panel: #1f2124; --accent: #7fc4a0; --warn: #e0b25f; --warn-bg: #2a2317;
  }
}
* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--fg);
  font-family: system-ui, -apple-system, "Hiragino Sans", "Noto Sans JP", sans-serif;
  line-height: 1.7; font-size: 15px;
}
.wrap { max-width: 1080px; margin: 0 auto; padding: 0 20px; }
.head {
  position: sticky; top: 0; z-index: 20;
  background: var(--bg); border-bottom: 1px solid var(--line);
  padding: 14px 0 12px; margin-bottom: 24px;
}
/* 固定したぶん背が高いと本文が読めない。スクロールしたら説明文を畳む */
.head .lead { margin: 6px 0 0; transition: max-height .2s ease, opacity .2s ease; }
.head.compact { padding: 8px 0; }
.head.compact .lead { max-height: 0; opacity: 0; overflow: hidden; margin: 0; }
.head.compact h1 { font-size: 17px; margin: 0; }
h1 { font-size: 22px; margin: 0 0 8px; }
.draft {
  font-size: 12px; font-weight: normal; color: var(--warn);
  border: 1px solid var(--warn); border-radius: 3px; padding: 1px 6px; vertical-align: 3px;
}
.lead { margin: 0; color: var(--muted); max-width: 60ch; }

.panel {
  background: var(--panel); border: 1px solid var(--line); border-radius: 6px;
  padding: 16px; display: flex; gap: 16px; flex-wrap: wrap; align-items: flex-start;
}
.cart { flex: 1 1 620px; min-width: 320px; }
.cart-head { display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap; margin-bottom: 8px; }
.cart-head > span:first-child { font-size: 12px; color: var(--muted); }
.cart-note { font-size: 12px; color: var(--muted); }
/* 棚 1 行 = 「棚の選択・数量・単位・削除」＋その下に呼び名の目安。折り返して 2 段にする */
.cart-line { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 14px; }
.cart-line .cat-select { flex: 0 0 auto; width: 140px; }
.cart-line .axis-select { flex: 0 0 auto; width: 210px; }
.cart-line .axis-select:disabled { color: var(--muted); }
.cart-line .size-select { flex: 1 1 260px; min-width: 220px; }
/* 段階の軸は実測値ではない。**そう書いておく。**黙って並べると測ったように見える */
.axis-note { flex-basis: 100%; font-size: 12px; color: var(--muted); margin: -4px 0 0 2px; }
.label-hint { flex-basis: 100%; font-size: 12px; line-height: 1.6; margin: -2px 0 0 2px; }
.cart-line + .cart-line { border-top: 1px solid var(--line); padding-top: 12px; }
.label-hint .label-names { color: var(--text); }
.cart-line .qty { min-width: 88px; max-width: 96px; }
.cart-line .unit { font-size: 12px; min-width: 62px; }
button.ghost {
  background: transparent; color: var(--accent); border: 1px solid var(--line);
  padding: 6px 12px; font-size: 13px;
}
button.ghost:disabled { color: var(--muted); }
.field { display: flex; flex-direction: column; gap: 4px; }
.field label { font-size: 12px; color: var(--muted); }
.unit { color: var(--accent); font-weight: bold; }
select, input[type="number"] {
  font: inherit; padding: 7px 9px; border: 1px solid var(--line);
  border-radius: 4px; background: var(--bg); color: var(--fg); min-width: 140px;
}
input[type="number"] { min-width: 100px; }
button {
  font: inherit; padding: 8px 18px; border: 0; border-radius: 4px;
  background: var(--accent); color: #fff; cursor: pointer;
}
button:disabled { opacity: .5; cursor: not-allowed; }

.notice {
  margin: 20px 0; padding: 14px 16px; border-radius: 6px;
  background: var(--warn-bg); border: 1px solid var(--line); color: var(--fg);
}
.notice h2 { font-size: 15px; margin: 0 0 6px; }
.notice ul { margin: 6px 0 0; padding-left: 1.2em; color: var(--muted); }

.result-block { margin: 28px 0; }
h2 { font-size: 16px; margin: 0 0 10px; }
.table-scroll { overflow-x: auto; border: 1px solid var(--line); border-radius: 6px; }
table.ranking { border-collapse: collapse; width: 100%; background: var(--panel); font-size: 14px; }
table.ranking th, table.ranking td {
  padding: 9px 11px; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap;
}
table.ranking th { font-size: 12px; color: var(--muted); font-weight: normal; background: var(--bg); }
table.ranking tr:last-child td { border-bottom: 0; }
td.unit-price { font-weight: bold; font-size: 15px; }
/* table.ranking td より詳細度を上げないと nowrap に負ける */
table.ranking td.breakdown { color: var(--muted); font-size: 12px; white-space: normal; }
table.ranking td.breakdown .bd { max-width: 320px; line-height: 1.5; }
.once { color: var(--accent); font-size: 11px; }
table.ranking td.name .lines { display: flex; flex-direction: column; gap: 8px; }
.line { border-left: 2px solid var(--line); padding-left: 9px; }
.line-head { display: flex; gap: 8px; flex-wrap: wrap; align-items: baseline; }
.line-size { font-weight: bold; font-size: 12px; }
.line-detail { color: var(--muted); font-size: 11px; }
table.ranking td.name { white-space: normal; min-width: 300px; max-width: 400px; }
.free-ship { color: var(--accent); font-size: 11px; }
.stamp { color: var(--muted); font-size: 12px; }
a.shop { color: var(--accent); }

.caution { color: var(--warn); font-size: 13px; margin: 6px 0 10px; }
.excluded { margin: 24px 0; }
.excluded summary { cursor: pointer; font-size: 14px; }
.assumptions { margin: 32px 0; padding: 16px; border: 1px solid var(--line); border-radius: 6px; }
.assumptions ul { margin: 0; padding-left: 1.2em; color: var(--muted); font-size: 13px; }

.foot { margin: 48px 0 40px; padding-top: 20px; border-top: 1px solid var(--line); color: var(--muted); }
.foot .small { font-size: 12px; }

/* 最安の買い方の札 */
.plan-card {
  border: 1px solid var(--line); border-radius: 6px; background: var(--panel);
  padding: 16px 18px; margin: 24px 0;
}
.plan-card.now { border-left: 4px solid var(--accent); }
.plan-card.later { border-left: 4px solid var(--warn); background: var(--warn-bg); }
.plan-card h2 { margin: 0 0 6px; font-size: 16px; }
.plan-total { display: flex; gap: 12px; align-items: baseline; flex-wrap: wrap; }
.plan-amount { font-size: 26px; font-weight: bold; }
.plan-where { color: var(--muted); font-size: 13px; }
.plan-lead { margin: 6px 0 0; font-size: 13px; }
.plan-shop {
  margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line);
}
.plan-shop-head { display: flex; gap: 10px; align-items: baseline; justify-content: space-between; }
.plan-shop-total { font-weight: bold; }
.plan-shop .breakdown { color: var(--muted); font-size: 12px; margin: 4px 0 8px; }
.plan-shop .bd { max-width: none; }
.oos-tag { color: var(--warn); font-weight: bold; font-size: 11px; }
.line-detail.muted { color: var(--muted); }
select.unit-select { min-width: 72px; }

.upper { color: var(--warn); font-size: 11px; }
#goods-only-block { margin: 28px 0; }

.shop-label { color: var(--muted); font-size: 11px; }
.unknown-tag { color: var(--muted); font-size: 11px; }
.shelf-note { color: var(--muted); font-weight: normal; font-size: 10px; margin-left: 4px; }

.plan-card.unconfirmed { border-left: 4px solid var(--muted); }

.label-hint .muted { color: var(--muted); }

/* 何をいくつ買うか。店を分けるときはここが読めないと動けない */
.line-detail .packs { color: var(--text); }
.line-detail .muted { color: var(--muted); }
.plan-shop-head .shop-step {
  font-size: 11px; color: var(--muted); border: 1px solid var(--line);
  border-radius: 3px; padding: 1px 6px; margin-right: 8px;
}
/* 店名は左に寄せる。何店目かの札を足したぶん、間延びしないように */
.plan-shop-head .shop { margin-right: auto; }

/* 準備中であることと、掲載拒否の窓口。**目立たせる。**見落とされると意味がない */
.foot .notice {
  background: #fff8e1; border: 1px solid #e6d28a; border-radius: 4px;
  padding: 10px 12px; margin-bottom: 12px;
}
.foot .contact {
  border-left: 3px solid var(--accent); padding: 4px 0 4px 12px; margin-bottom: 12px;
}

/* 説明のページ（プライバシーポリシーなど） */
.doc { max-width: 760px; padding-bottom: 48px; }
.doc h2 { margin: 24px 0 8px; font-size: 20px; }
.doc h3 { margin: 24px 0 6px; font-size: 15px; }
.doc p, .doc li { line-height: 1.9; }
.doc ul { padding-left: 20px; margin: 6px 0; }
