/* ワタシの電卓 - 見た目(色は config.js で変更できます) */
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--c-bg); }
body {
  font-family: system-ui, -apple-system, "Hiragino Sans", "Yu Gothic UI", "Meiryo", sans-serif;
  color: var(--c-number);
  --fs: 18px;
  overscroll-behavior: none;
}
body.fs-s { --fs: 16px; }
body.fs-m { --fs: 18px; }
body.fs-l { --fs: 22px; }

button { font: inherit; color: inherit; }

#app {
  display: flex; flex-direction: column;
  height: 100vh; height: 100dvh;
  max-width: 640px; margin: 0 auto;
  background: var(--c-bg);
}

/* 上部バー */
#topbar {
  display: flex; background: var(--c-bar); color: var(--c-barText);
  padding-top: env(safe-area-inset-top);
  flex: none;
}
#topbar button {
  flex: 1; border: 0; background: transparent; color: inherit;
  display: flex; flex-direction: column; align-items: center; gap: 1px;
  padding: 7px 2px 6px; cursor: pointer;
}
#topbar button:active { background: rgba(255,255,255,.15); }
#topbar .ic { width: 22px; height: 22px; display: block; }
#topbar .lb { font-size: 11px; }

/* 行リスト */
#list { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 4px 0 0; }
.row {
  display: grid; grid-template-columns: 2.6em minmax(0, 1fr) auto;
  align-items: start; border-bottom: 1px solid var(--c-line);
  font-size: var(--fs);
}
.row.active { background: var(--c-activeRow); }
.num {
  color: var(--c-rowNum); text-align: right; padding: 0 .5em 0 0;
  font-size: .72em; line-height: 3.47; font-variant-numeric: tabular-nums;
  user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; cursor: pointer;
}
.cell { position: relative; min-width: 0; }
/* 1行の高さは今までどおり 2.5em(上下の余白 .6em + 文字の行 1.3em)。
   長い行を折り返したときは、折り返しの行間だけが 1.3 倍になる(行番号・右の答えは1行目にそろう) */
.hl, .cell textarea {
  font: inherit; font-size: 1em; line-height: 1.3; letter-spacing: 0;
  padding: .6em .3em; margin: 0; border: 0;
  white-space: pre-wrap; overflow-wrap: anywhere; word-break: break-all;
}
.hl { min-height: 2.5em; pointer-events: none; }
.cell textarea {
  position: absolute; inset: 0; width: 100%; height: 100%;
  background: transparent; resize: none; outline: none; overflow: hidden;
  color: transparent; -webkit-text-fill-color: transparent;
  caret-color: var(--c-number);
}
.hl .t { color: var(--c-text); }
.hl .tax { color: var(--c-formula); font-weight: 700; } /* 1.20.0: 税込10 は計算式の色 */
.hl .n { color: var(--c-formula); }                     /* 1.20.0: 数字・単位は青系(文字はグレー) */
.hl .nb { color: var(--c-numberBare); }
.hl .o { color: var(--c-operator); font-weight: 600; }
.hl .r { color: var(--c-ref); }
.res {
  white-space: pre-line; text-align: right; padding: 0 .6em 0 .3em; line-height: 2.5;
  max-width: 48vw; overflow-wrap: anywhere; color: var(--c-result);
  font-variant-numeric: tabular-nums; font-weight: 600; min-width: 1em;
}
.res.err { color: var(--c-error); font-size: .62em; font-weight: 500; line-height: 4; }
.filler { min-height: 35vh; }

/* 合計・税バー */
/* 画面の下の3段(1.18.0): 段A タブ(.cat-row) / 段B 画面ごとのボタン(#optbar) / 段C 結果(#sumRows)。
   3段とも高さを固定して、どの画面でもタブの位置が同じになるようにする(段C は、いちばん高い価格の合計欄に合わせる)。
   段B・C は合わせて 50px(段B 22px・段C 28px)。比較の4個が、高さ720px以上でスクロールなしに収まるように */
#total {
  flex: none; background: var(--c-totalBg); padding: 5px 6px 6px;
  border-top: 1px solid var(--c-line);
}
.cat-row { display: flex; justify-content: space-between; align-items: center; gap: 4px; height: 28px; }
#catSeg { display: flex; }
#catSeg button {
  border: 1px solid var(--c-keyOpText); background: transparent; color: var(--c-keyOpText);
  padding: 4px 14px; font-size: .8rem; margin-left: -1px; touch-action: none;
}
#catSeg button:first-child { border-radius: 7px 0 0 7px; margin-left: 0; }
#catSeg button:last-child { border-radius: 0 7px 7px 0; }
#catSeg button:only-child { border-radius: 7px; }
#catSeg button.on { background: var(--c-keyOpText); color: var(--c-onAccent, #fff); }
#total .tl { font-size: .8rem; opacity: .75; white-space: nowrap; }
body.cmp #total .tl { display: none; }
#sumRows.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 2px 18px; }
#sumRows { height: 28px; overflow-x: hidden; overflow-y: auto; padding: 0 2px; scrollbar-width: none; }
#sumRows::-webkit-scrollbar { display: none; } /* 2行に折り返すほど大きい桁は、段Cの中でスクロール */
#sumRows.grid1 { display: flex; align-items: center; justify-content: flex-end; }
.sumrow { display: flex; justify-content: space-between; align-items: baseline; gap: 6px; min-width: 0; }
.sumrow .sl { font-size: .68rem; line-height: 1; opacity: .75; white-space: nowrap; }
.sumrow .sv { font-size: 1rem; line-height: 1; font-variant-numeric: tabular-nums; text-align: right; overflow-wrap: anywhere; }
.sumrow.main .sv { font-size: 1rem; font-weight: 700; }
#sumRows.grid1 .sumrow { justify-content: flex-end; }
#sumRows.grid1 .sumrow .sv { font-size: 1.35rem; line-height: 1.1; }
.res.taxed::after { content: "税抜"; font-size: .6em; font-weight: 700; color: var(--c-keyOpText); border: 1px solid var(--c-keyOpText); border-radius: 4px; padding: 0 3px; margin-left: 6px; vertical-align: middle; }
/* 価格の合計欄: 税抜価格・税額・税込価格の3つを横に並べる */
#sumRows.grid3 { display: flex; flex-wrap: wrap; justify-content: flex-end; align-items: center; align-content: center; gap: 0 14px; }
#sumRows.grid3 .sumrow { flex: 0 0 auto; max-width: 100%; flex-direction: column; align-items: flex-end; gap: 0; }
/* ABCキーボードのときだけ出す帯(「123」で計算キーに戻る) */
#taxbar {
  flex: none; display: none; gap: 8px; align-items: center;
  padding: 6px 10px; background: var(--c-padBg);
}
body.native #taxbar { display: flex; }
#taxbar .grow { flex: 1; }
.taxbtn {
  border: 0; border-radius: 8px; padding: 7px 18px; cursor: pointer;
  background: var(--c-keyOpBg); color: var(--c-keyOpText); font-weight: 700; touch-action: none;
}
.taxbtn:active, .taxbtn.down { filter: brightness(.9); }
.taxbtn[hidden] { display: none; }

/* キーパッド(5列×4行) */
#pad {
  flex: none; display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px;
  padding: 8px 8px calc(8px + env(safe-area-inset-bottom)); background: var(--c-padBg);
}
body.native #pad { display: none; }
body.native #taxbar { padding-bottom: calc(6px + env(safe-area-inset-bottom)); }
#pad button {
  position: relative; min-width: 0; padding: 0;
  height: clamp(50px, 8.2vh, 66px); border: 0; border-radius: 9px; font-size: 1.3rem;
  background: var(--c-keyBg); color: var(--c-keyText);
  box-shadow: 0 1px 0 rgba(0,0,0,.22); touch-action: none; user-select: none; cursor: pointer;
}
#pad button.op { background: var(--c-padOpBg, var(--c-keyOpBg)); color: var(--c-padOpText, var(--c-keyOpText)); font-weight: 700; }
#pad button.sub { background: var(--c-keySubBg); color: var(--c-keySubText); font-size: 1.05rem; }
#pad button.unit { background: var(--c-keySubBg); color: var(--c-keySubText); font-size: 1.05rem; font-weight: 700; }
#pad button.longlabel .kl { font-size: .72rem; }
#pad button.soon { opacity: .6; }
#pad button.down { filter: brightness(.88); transform: translateY(1px); }

/* トースト */
#toast {
  position: fixed; left: 50%; transform: translateX(-50%);
  top: calc(env(safe-area-inset-top) + 64px); /* 上部に出す(キーや税ボタンに重ならないように) */
  background: var(--c-toastBg, rgba(40,40,40,.92)); color: var(--c-toastText, #fff); padding: 9px 14px; border-radius: 20px;
  font-size: .9rem; display: flex; gap: 12px; align-items: center; z-index: 30; max-width: 92vw;
}
#toast[hidden] { display: none; }
#toast button { border: 0; background: transparent; color: var(--c-toastBtn, #ffd27a); font-weight: 700; padding: 2px 4px; }

/* オーバーレイ */
.overlay { position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 20; display: flex; }
.overlay[hidden] { display: none; }
.sheet { background: var(--c-bg); display: flex; flex-direction: column; max-height: 100%; }
.sheet.side { width: min(86vw, 360px); height: 100%; padding-top: env(safe-area-inset-top); }
.sheet.full { width: 100%; max-width: 640px; margin: 0 auto; height: 100%; padding-top: env(safe-area-inset-top); }
.sheet-head {
  display: flex; justify-content: space-between; align-items: center;
  background: var(--c-bar); color: var(--c-barText); padding: 10px 14px; flex: none;
}
.sheet-head h2 { margin: 0; font-size: 1.1rem; }
.close { border: 1px solid rgba(255,255,255,.5); background: transparent; color: inherit; border-radius: 8px; padding: 5px 12px; }
.sheet-body { overflow-y: auto; padding: 4px 16px calc(24px + env(safe-area-inset-bottom)); line-height: 1.7; font-size: .95rem; }
.sheet-body h3 { margin: 20px 0 6px; font-size: 1rem; color: var(--c-ink, var(--c-bar)); border-bottom: 1px solid var(--c-line); padding-bottom: 4px; }
.sheet-body p { margin: 4px 0; }
.about { display: flex; gap: 14px; align-items: center; margin-top: 14px; }
.about img { border-radius: 14px; }
.about-name { font-size: 1.3rem; font-weight: 700; }
.about-sub { opacity: .8; }
.about-ver { font-size: .8rem; opacity: .6; }
.seg { display: flex; gap: 8px; }
.seg button { flex: 1; border: 1px solid var(--c-ink, var(--c-bar)); background: transparent; border-radius: 8px; padding: 8px; color: var(--c-ink, var(--c-bar)); }
.seg button.on { background: var(--c-ink, var(--c-bar)); color: var(--c-onInk, var(--c-barText)); }
#noteList { list-style: none; margin: 0; padding: 0; overflow-y: auto; flex: 1; }
#noteList li { display: flex; align-items: center; border-bottom: 1px solid var(--c-line); }
#noteList li.cur { background: var(--c-activeRow); }
#noteList .nt { flex: 1; text-align: left; border: 0; background: transparent; padding: 12px 14px; min-width: 0; }
#noteList .nt b { display: block; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#noteList .nt small { opacity: .6; }
.wide { margin: 10px; border: 0; border-radius: 8px; padding: 12px; background: var(--c-ink, var(--c-bar)); color: var(--c-onInk, var(--c-barText)); }

/* スプラッシュ */
#splash {
  position: fixed; inset: 0; z-index: 100; background: var(--c-splashBg); color: var(--c-splashText);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; text-align: center;
  opacity: 1; transition: opacity var(--splash-fade) ease;
}
#splash.hide { opacity: 0; pointer-events: none; }
#splash img { border-radius: 22px; margin-bottom: 14px; }
#splash h1 { margin: 0; font-size: 1.9rem; letter-spacing: .08em; }
#splash p { margin: 0; opacity: .85; }

/* 距離の画面 */
#optbar { height: 32px; padding-top: 4px; display: flex; align-items: flex-start; gap: 12px; overflow-x: auto; overflow-y: hidden; white-space: nowrap; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
#optbar::-webkit-scrollbar { display: none; } /* 横にスクロールできる(はしのボタンが切れて見えるので分かる) */
#unitbar { --ug: 10px; flex: none; display: flex; gap: var(--ug); align-items: center; }
#unitbar[hidden] { display: none; }
#unitbar .ul { font-size: 12px; opacity: .75; margin-right: 2px; white-space: nowrap; } /* ボタンとのあいだ 12px */
#unitbar button { border: 1px solid var(--c-keyOpText); background: transparent; color: var(--c-keyOpText); border-radius: 6px; padding: 1px 10px; font-weight: 700; font-size: 13px; line-height: 1.2; white-space: nowrap; cursor: pointer; touch-action: none; }
#unitbar button.on { background: var(--c-keyOpText); color: var(--c-onAccent, #fff); }
#cfgnote { flex: none; display: block; border: 0; background: transparent; color: var(--c-keyOpText); font-size: 12px; padding: 0 2px; white-space: nowrap; margin-left: auto; cursor: pointer; text-decoration: underline; }
#cfgnote[hidden] { display: none; }
.tmbox { margin-top: 8px; }
.tmrow { display: flex; align-items: center; gap: 8px; margin: 6px 0; flex-wrap: wrap; }
.tmrow > span { min-width: 4.5em; font-size: .85rem; }
.tmrow .seg { flex: 1; min-width: 200px; }
.tmrow input, .tmrow select { font: inherit; padding: 6px; border: 1px solid var(--c-ink, var(--c-bar)); border-radius: 8px; background: transparent; color: inherit; }
.tmrow input { width: 5.5em; }
#tmCalInfo { font-size: .8rem; margin: 2px 0; }
#foodbar { flex: 0 1 auto; min-width: 0; display: flex; gap: 3px; align-items: center; margin-left: auto; } /* 段Bの右端に固定 */
#foodbar[hidden] { display: none; }
#foodbar .ul { font-size: 12px; opacity: .75; white-space: nowrap; }
#foodbar .ul::after { content: ":"; }
#foodbar select { flex: 0 1 auto; width: 6.5em; min-width: 4.5em; font: inherit; font-size: 13px; height: 28px; padding: 0 2px; border: 1px solid var(--c-keyOpText); border-radius: 7px; background: transparent; color: inherit; }
.foodrow { display: flex; align-items: center; gap: 6px; margin: 6px 0; }
.foodrow .fname { flex: 1; min-width: 0; font: inherit; padding: 6px; border: 1px solid var(--c-ink, var(--c-bar)); border-radius: 8px; background: transparent; color: inherit; }
.foodrow .fgram { width: 4.6em; font: inherit; padding: 6px; border: 1px solid var(--c-ink, var(--c-bar)); border-radius: 8px; background: transparent; color: inherit; }
.foodrow .fu { font-size: .8rem; white-space: nowrap; }
.foodrow .fdel { border: 1px solid var(--c-error); color: var(--c-error); background: transparent; border-radius: 8px; padding: 6px 8px; font: inherit; font-size: .8rem; cursor: pointer; }
.tmtoday { border: 1px solid var(--c-ink, var(--c-bar)); background: transparent; color: var(--c-ink, var(--c-bar)); border-radius: 8px; padding: 6px 12px; font: inherit; font-size: .85rem; cursor: pointer; }
.tmtoday:disabled { opacity: .45; cursor: default; }
#unitbar .modeseg { margin-left: 2px; display: flex; gap: 0; } /* 単位ボタンのグループとのあいだ 12px */
#unitbar .modeseg button { border-radius: 0; padding: 1px 7px; font-size: 12px; }
#unitbar .modeseg button:first-child { border-radius: 7px 0 0 7px; }
#unitbar .modeseg button:last-child { border-radius: 0 7px 7px 0; border-left: 0; }

/* 上部バーの下の小さなお知らせ(自動保存) */
#savenote { flex: none; font-size: .62rem; text-align: right; padding: 1px 10px; background: var(--c-bar); color: var(--c-barText); opacity: .85; }

/* お知らせを合計欄のすぐ上に出す(コピー・貼り付けのとき。上の方には出さない) */
#toast.low { top: auto; }

/* 貼り付けの画面 */
.sheet.paste { width: 100%; max-width: 560px; margin: auto; border-radius: 12px; overflow: hidden; max-height: 92%; }
#pasteText { width: 100%; box-sizing: border-box; font: inherit; font-size: 16px; padding: 8px; border: 1px solid var(--c-ink, var(--c-bar)); border-radius: 8px; background: var(--c-bg); color: inherit; resize: vertical; }
#pasteInfo { min-height: 1.4em; font-size: .85rem; color: var(--c-error); }
.btnrow { display: flex; gap: 10px; justify-content: flex-end; align-items: center; }
.btnrow .wide { margin: 0; padding: 10px 18px; }
.btnrow .tmtoday { padding: 10px 16px; font-size: .95rem; }

/* 設定の開閉式の項目(価格・距離・容量・時間・食材) */
details.cfg { margin-top: 14px; border-bottom: 1px solid var(--c-line); }
details.cfg > summary { cursor: pointer; list-style: none; font-size: 1rem; font-weight: 700; color: var(--c-ink, var(--c-bar)); padding: 6px 0 4px; }
details.cfg > summary::-webkit-details-marker { display: none; }
details.cfg > summary::before { content: "▸"; display: inline-block; width: 1.2em; transition: transform .15s; }
details.cfg[open] > summary::before { transform: rotate(90deg); }
details.cfg > *:last-child { margin-bottom: 12px; }
details.cfg h4 { margin: 12px 0 6px; font-size: .9rem; }


/* 比較の画面(A〜D のカード)
   1.17.0: 4個でも、タブとキーパッドのあいだにスクロールなしで収まるよう、カードをコンパクトにした(幅360px・高さ640〜800pxで自動確認)。
   カード = 1行目: 品名と特売マーク / 2行目: 詳細(日付・店名・メモ) / 3行目: 価格・円・税込/税抜・税率 / 4行目: 数量と単価。文字は12px以上 */
#cmp { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 12px 6px 4px; display: flex; flex-direction: column; gap: 6px; } /* 上の余白は「最安」の印の分 */
#cmp[hidden] { display: none; }
body.cmp #list { display: none; }
body.cmp-text #pad { display: none; } /* 品名・店名・メモの入力中は OS のキーボードを使う */
.cmp-btns { display: none; flex: none; gap: 4px; }
body.cmp .cmp-btns { display: flex; }
.cmp-btns button { flex: none; border: 1.5px solid var(--c-keyOpText); background: transparent; color: var(--c-keyOpText); border-radius: 14px; padding: 3px 12px; font-size: 13px; font-weight: 700; line-height: 1.25; cursor: pointer; }
.cmp-btns button:active { background: var(--c-keyOpBg); }
#cmpCount::before { content: "⇄"; }
#cmpMsg { flex: 1; min-width: 0; margin: 0; font-size: 13px; line-height: 1.2; font-weight: 700; color: var(--c-error); text-align: center; }
#cmpMsg[hidden] { display: none; }
/* 1.17.1: 大きさは app.js の fitCmp が、比べる数と画面の高さに合わせて決める(下の変数を上書き。ここの値は一番小さいとき)。
   カードはタブとキーパッドのあいだを下まで使い切り、余った高さは品名・価格・数量の行に分ける(入力欄が縦に広がる)。
   --cf 入力の文字 / --ch 入力欄の高さ / --cg カード内のすきま / --cp カードの余白 / --uf 単価の文字 / --sf 小さい文字(12px以上) / --lt A〜D の丸 */
#cmpCards { --cf: 15px; --ch: 24px; --cg: 2px; --cp: 6px; --uf: 14px; --sf: 12px; --lt: 19px;
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); grid-auto-rows: 1fr; gap: 9px 6px; align-items: stretch; }
#cmpCards.fitting { height: auto !important; grid-auto-rows: auto; align-items: start; } /* 測るとき: 中身だけの高さにする */
.ccard { position: relative; display: flex; flex-direction: column; gap: var(--cg); min-width: 0; background: var(--c-keyBg); border: 1.5px solid var(--c-line); border-radius: 10px; padding: var(--cp) var(--cp) calc(var(--cp) - 1px); box-shadow: 0 1px 0 rgba(0,0,0,.08); }
.ccard[hidden] { display: none; }
.ccard.on { border-color: var(--c-ink, var(--c-bar)); }
.ccard.best { border-color: var(--c-keyOpText); box-shadow: 0 0 0 1px var(--c-keyOpText); }
.ccard input { font: inherit; font-size: var(--cf); line-height: 1.25; width: 100%; min-width: 0; margin: 0; padding: 2px 3px; border: 0; border-bottom: 1.5px solid var(--c-line); border-radius: 4px 4px 0 0; background: transparent; color: var(--c-number); }
.ccard input::placeholder { color: var(--c-number); opacity: .3; font-weight: 400; }
.ccard input.on, .ccard input:focus { outline: none; border-bottom-color: var(--c-keyOpText); background: var(--c-activeRow); }
/* 品名・価格・数量の欄の高さは --ch(比べる数と画面の高さで fitCmp が決める)。それでも余った高さは、
   この3つの行に分けて、欄を行の上下まん中に置く(行と行のすきまが広がる。欄だけが間延びしないように)。
   position: relative は、自前のカーソルの位置の基準(価格・数量) */
.ccard .ch, .ccard .prow, .ccard .qrow { flex: 1 0 auto; position: relative; }
.ccard .ch input, .ccard .prow input, .ccard .qrow input { box-sizing: border-box; height: var(--ch); }
/* 1行目: A 品名 [特] */
.ccard .ch { display: flex; align-items: center; gap: 4px; }
.ccard .lt { flex: none; width: var(--lt); height: var(--lt); border-radius: 50%; background: var(--c-ink, var(--c-bar)); color: var(--c-onInk, var(--c-barText)); display: inline-flex; align-items: center; justify-content: center; font-weight: 700; font-size: max(12px, calc(var(--lt) * .62)); }
.ccard .cname { font-weight: 700; }
.ccard .csale { flex: none; width: calc(var(--lt) + 4px); height: calc(var(--lt) + 2px); padding: 0; border: 1.5px solid var(--c-keyOpText); border-radius: 4px 10px 10px 4px; background: transparent; color: var(--c-keyOpText); font-size: var(--sf); font-weight: 700; line-height: 1; opacity: .3; cursor: pointer; }
.ccard .csale.on { background: var(--c-keyOpText); color: var(--c-onAccent, #fff); opacity: 1; }
/* 2行目: ▸詳細 日付 · 店名(閉じているときの見本) */
.ccard .cxs { display: flex; align-items: center; gap: 5px; flex: none; width: 100%; min-height: calc(var(--sf) + 6px); margin: 0; padding: 0 2px; border: 0; border-radius: 5px; background: transparent; font: inherit; font-size: var(--sf); line-height: 1.2; color: var(--c-ink, var(--c-bar)); text-align: left; cursor: pointer; -webkit-tap-highlight-color: transparent; }
.ccard .cxs:active { background: var(--c-activeRow); }
.ccard .cxl { flex: none; font-weight: 700; }
.ccard .cxl::before { content: "▸"; display: inline-block; width: .85em; transition: transform .15s; }
.ccard.xopen .cxl::before { transform: rotate(90deg); }
.ccard .cxp { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--c-number); opacity: .75; }
.ccard .cxp:empty::before { content: "日付・店名・メモ"; opacity: .5; }
/* 詳細の中身(開いたときだけ): 日付・店名・メモ */
.ccard .cxb { display: none; grid-template-columns: auto minmax(0, 1fr); align-items: center; gap: 3px 5px; padding: 1px 0 3px 2px; }
.ccard.xopen .cxb { display: grid; }
.ccard .cxk { font-size: 12px; opacity: .6; white-space: nowrap; }
#cmpCards .ccard .cxb input, #cmpCards .ccard .cxb textarea {
  font: inherit; font-size: 14px; font-weight: 400; line-height: 1.3; width: 100%; min-width: 0; margin: 0; padding: 2px 3px; box-sizing: border-box;
  border: 0; border-bottom: 1.5px solid var(--c-line); border-radius: 4px 4px 0 0; background: transparent; color: var(--c-number);
}
#cmpCards .ccard .cxb input:focus, #cmpCards .ccard .cxb textarea:focus { outline: none; border-bottom-color: var(--c-ink, var(--c-bar)); background: var(--c-activeRow); }
#cmpCards .ccard .cxb ::placeholder { color: var(--c-number); opacity: .3; }
#cmpCards .ccard .cxb textarea { display: block; resize: none; max-height: calc(5 * 1.3em + 6px); overflow-y: auto; }
/* 日付: 見た目は短い文字(.cxdv)。本物の日付の欄は透明にして、その上に重ねる(タップで OS の日付選択) */
.ccard .cxd { display: flex; align-items: center; gap: 4px; min-width: 0; }
.ccard .cxdw { position: relative; flex: 1; min-width: 0; display: block; cursor: pointer; }
.ccard .cxdv { display: block; font-size: 14px; line-height: 1.3; padding: 2px 3px; border-bottom: 1.5px solid var(--c-line); border-radius: 4px 4px 0 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--c-number); font-variant-numeric: tabular-nums; }
.ccard .cxdv.empty { opacity: .32; }
#cmpCards .ccard .cxb input.cdate { position: absolute; inset: 0; width: 100%; height: 100%; padding: 0; border: 0; opacity: 0; cursor: pointer; }
#cmpCards .ccard .cxb input.cdate::-webkit-calendar-picker-indicator { position: absolute; inset: 0; width: auto; height: auto; opacity: 0; cursor: pointer; }
.ccard .cxdw:focus-within .cxdv { border-bottom-color: var(--c-ink, var(--c-bar)); background: var(--c-activeRow); }
.ccard .cxt { flex: none; border: 1px solid var(--c-ink, var(--c-bar)); background: transparent; color: var(--c-ink, var(--c-bar)); border-radius: 9px; font-size: 12px; font-weight: 700; line-height: 1; padding: 3px 7px; cursor: pointer; }
.ccard .cxt:active { background: var(--c-activeRow); }
.ccard .cxt.clr { border-color: var(--c-line); color: var(--c-number); opacity: .6; font-weight: 400; }
/* 3行目: 価格 円 [税抜][10%](タップで切り替え) */
.ccard .prow { display: flex; align-items: center; gap: 3px; }
.ccard .prow .yen { flex: none; font-size: var(--sf); margin-right: 1px; }
.ccard .ctw { flex: none; display: flex; flex-direction: column; gap: 3px; margin-left: 4px; margin-right: calc(8px - var(--cp)); position: relative; z-index: 1; } /* 「円」から8px、カードの右の縁から8px、2段のあいだ3px */ /* 円の右に、上=税込|税抜、下=10%|軽減税率 */
.ccard .tseg { display: flex; }
.ccard .tseg button { flex: 1; margin: 0 0 0 -1px; border: 1px solid var(--c-keyOpText); border-radius: 0; background: transparent; color: var(--c-keyOpText);
  font-size: 12px; font-weight: 700; line-height: 1.1; padding: 1px 3px; white-space: nowrap; opacity: .45; cursor: pointer; font-variant-numeric: tabular-nums; }
.ccard .tseg button:first-child { margin-left: 0; border-radius: 6px 0 0 6px; }
.ccard .tseg button:last-child { border-radius: 0 6px 6px 0; }
.ccard .tseg button.on { background: var(--c-keyOpText); color: var(--c-onAccent, #fff); opacity: 1; } /* 選んでいる方は濃い色 */
.ccard .tseg button:not(.on):active { background: var(--c-keyOpBg); }
/* 4行目: 数量 … 単価 */
.ccard .qrow { display: flex; align-items: center; gap: 4px; }
.ccard .qrow input { flex: 1 0 64px; min-width: 64px; }
.ccard .cu { flex: 0 1 auto; text-align: right; line-height: 1; } /* 幅が足りないときは「/100ml」を単価の下に回す(数量の欄を狭くしすぎない) */
.ccard .up { font-size: var(--uf); font-variant-numeric: tabular-nums; color: var(--c-result); white-space: nowrap; }
.ccard .per { display: inline-block; font-size: var(--sf); opacity: .7; white-space: nowrap; }
.ccard .up.err { display: block; font-size: var(--sf); font-weight: 500; color: var(--c-error); white-space: normal; overflow-wrap: anywhere; }
.ccard .up.none { font-size: var(--sf); font-weight: 400; opacity: .4; }
.ccard.best .up { color: var(--c-keyOpText); }
.ccard .bestmark { position: absolute; top: -9px; right: 30px; font-size: 12px; font-weight: 700; line-height: 15px; color: var(--c-onAccent, #fff); background: var(--c-keyOpText); border-radius: 8px; padding: 0 6px; pointer-events: none; }
.ccard .bestmark[hidden] { display: none; }
/* タブが6つになったので、少し詰めて1行に収める */
#catSeg button { padding: 4px 7px; white-space: nowrap; } /* 1.18.1: 幅40px以上 */ /* 1.18.0: 右に比較のボタンが入るよう、少し詰める */
#total .tl { min-width: 0; overflow: hidden; text-overflow: ellipsis; }

/* 計算式: 枠(点線。文字の幅は変えない)、枠が残っているときの薄いお知らせ、タップで単位が変わる速さの答え */
.hl .frm { color: var(--c-ink, var(--c-bar)); background: var(--c-frameBg, rgba(91,111,106,.10)); outline: 1px dashed var(--c-ink, var(--c-bar)); outline-offset: -1px; border-radius: 3px; }
.res.hint { color: var(--c-result); opacity: .45; font-size: .62em; font-weight: 400; line-height: 4; }
.res.speedres { text-decoration: underline dotted; text-underline-offset: 4px; cursor: pointer; }

#sumRows .sumrow.hint .sv { font-size: .85rem; font-weight: 400; opacity: .5; } /* 枠が残っているときの合計欄(薄く小さく) */

/* ---------- フリックの目印(1.16.1) ----------
   ・記号の目印(( ) × ÷ など)は、中央の文字の約60%(.6em = キーの文字の大きさの6割)。線は細め。
   ・+ − × ÷(中央の文字がない演算子キー)は 20〜22px(キーの高さに合わせる)。
   ・文字の目印(割引・ABC・10%・単位・時速など)は 13px(中央の文字がないキーは 14px)。
   ・目印は、どれもキーの縁から 6px 以上離す。
   中央の文字は、目印と重ならない位置・大きさにする(--kh = キーの高さ)。幅360pxの画面で自動確認している */
#pad { --kh: clamp(50px, 8.2vh, 66px); }
#pad button { height: var(--kh); display: flex; align-items: center; justify-content: center; } /* 中央の文字を、キーのちょうど真ん中に */
#pad .fm { position: absolute; font-size: 13px; font-weight: 600; opacity: .8; line-height: 1; pointer-events: none; white-space: nowrap; }
#pad .fm.sym { font-size: .6em; font-weight: 400; opacity: .85; }
#pad .fm.fu { top: 6px; left: 50%; transform: translateX(-50%); }
#pad .fm.fd { bottom: 6px; left: 50%; transform: translateX(-50%); }
#pad .fm.fl { left: 6px; top: 50%; transform: translateY(-50%); }
#pad .fm.fr { right: 6px; top: 50%; transform: translateY(-50%); }
#pad button.nolabel .fm { font-size: 14px; opacity: 1; font-weight: 700; }
#pad button.nolabel .fm.sym { font-size: clamp(20px, calc((var(--kh) - 13px) / 2), 22px); font-weight: 700; } /* + − × ÷: 20〜22px(上下が重ならない大きさ) */
#pad button.smallmarks .fm { font-size: 13px; letter-spacing: -1px; } /* 時速・分速・秒速(2文字ずつ)は、左右が近いので字間を詰める */
#pad button.taxkey .fm { color: var(--c-padOpText, var(--c-keyOpText)); opacity: 1; font-weight: 700; }
/* 中央の文字 */
#pad .kl { display: inline-block; line-height: 1; height: 1em; }
#pad button.mu:not(.md) .kl { transform: translateY(7px); }                 /* 上だけに目印: 少し下へ */
#pad button.mu.md .kl { font-size: clamp(13px, calc(var(--kh) - 40px), 18px); } /* 上下に文字の目印: あいだに入る大きさ */
#pad button.mu.md[data-key="bs"] .kl { font-size: 1em; }                     /* ⌫キー: 上下の目印が小さいので、中央はそのままの大きさ */

/* ---------- 自前のカーソル(計算キーのとき。入力欄は readonly でブラウザのカーソルが出ないため) ---------- */
.fcaret { position: absolute; width: 2px; background: var(--c-number); pointer-events: none; z-index: 2; border-radius: 1px; }
.fcaret[hidden] { display: none; }
.fcaret.blink { animation: fcaret-blink 1.06s steps(1) infinite; }
@keyframes fcaret-blink { 0%, 55% { opacity: 1; } 56%, 100% { opacity: 0; } }
.caret-measure { position: absolute; left: -9999px; top: 0; visibility: hidden; white-space: pre; }

/* 1.17.2: 目印の微調整
   ・( ) × ÷(左右の記号)は、キーの左右の縁から 11px(中央寄り)。+ − はそのまま。
   ・全削除は文字「ALL」(ほかの文字の目印と同じ 13px)。
   ・1行削除(|⌫)・戻る(↶)は「割引」「10%」と同じくらいの見た目の大きさ(線は細め)。 */
#pad .fm.fl.side { left: 11px; }
#pad .fm.fr.side { right: 11px; }
#pad .fm.big { font-size: 17px; font-weight: 300; }
#pad button[data-key="enter"] .fm.big { font-size: 23px; } /* ↶ は形が小さいので、大きい文字で「割引」と同じくらいに見せる */
/* ⌫キー: 上に ALL、下に |⌫、まん中に ⌫。見た目(文字の形)で縁から6px以上・重ならないように並べる */
#pad button[data-key="bs"] .fm.fu { top: 3px; }              /* ALL の形の上端が、縁から約6px */
#pad button[data-key="bs"] .fm.big { font-size: 15px; bottom: 9px; } /* |⌫ の縦線は下にはみ出すので、少し上げる */
#pad button.mu.md[data-key="bs"] .kl { font-size: clamp(14px, calc(var(--kh) - 38px), 1em); transform: translateY(-3px); }

/* ---------- 1.18.0 ---------- */
/* %キー: 「割引」の目印があっても、% と ( ) は、ほかの画面と同じ高さ(割引は上に固定して、中央の文字を動かさない) */
#pad button.mu[data-key="pct"]:not(.md) .kl { transform: none; }

/* 自作のアイコン(index.html の <symbol>): 細い線・文字と同じ色 */
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.ico { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; flex: none; }
#btnNew2 { display: flex; align-items: center; justify-content: center; gap: 6px; }
#btnNew2 .ico { width: 20px; height: 20px; }
/* ノート一覧の削除: ふた付きのごみ箱(強調色)。押せる範囲は 44px 四方以上、押すと少し濃く */
#noteList .del { flex: none; display: flex; align-items: center; justify-content: center; min-width: 48px; min-height: 48px; padding: 0 12px; border: 0; background: transparent; color: var(--c-keyOpText); cursor: pointer; }
#noteList .del:active { color: var(--c-delActive, #8f430c); background: var(--c-activeRow); }

/* 比較の段C: 最安(1行。長いときは …) */
#sumRows.cmpsum .sumrow { min-width: 0; justify-content: flex-end; gap: 8px; }
#sumRows.cmpsum .sumrow .sv { font-size: 1.05rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
#sumRows.cmpsum .sumrow.hint .sv { font-size: .85rem; }

/* ---------- 1.18.1: 押せる範囲(見た目の外側に透明な余白。見た目の大きさは変えない) ----------
   タブ・段Bのボタン・比べる数: 高さ32px・幅40px以上。比較の税の切り替え(2段)は、外側(上の段は上、下の段は下)へ広げる */
#catSeg button, #unitbar button, #cfgnote, .cmp-btns button, .ccard .tseg button { position: relative; }
#catSeg button::after, #unitbar button::after, #cfgnote::after, .cmp-btns button::after, .ccard .tseg button::after { content: ""; position: absolute; }
.cat-row { position: relative; z-index: 2; } /* タブの押せる範囲が、段Bの上に出るように */
#catSeg button::after { top: -6px; bottom: -1px; left: 0; right: 0; } /* 下の段Bのボタンと重ならないよう、上へ多めに */
#unitbar button::after { top: -4px; bottom: -9px; left: calc(var(--ug) / -2); right: calc(var(--ug) / -2); } /* 段Bの高さ(32px)いっぱい */
#cfgnote { height: 26px; }
#cfgnote::after { top: -3px; bottom: -3px; left: -4px; right: 0; } /* 右は画面の端なので、外へ出さない */
.cmp-btns button::after { top: -7px; bottom: -3px; left: 0; right: 0; }
.ccard .tseg:first-child button::after { top: -6px; bottom: -1px; left: 0; right: 0; }
.ccard .tseg:last-child button::after { top: -2px; bottom: -6px; left: 0; right: 0; }
#topbar { gap: 2px; } /* ヘッダーの5つのボタン: となりと少し離す */
#topbar button { gap: 3px; }

/* ---------- 1.18.2: 段Bは、横にスクロールしなくても全部見える ----------
   入らないときは app.js の fitOptbar が data-o を 1→4 と上げて、余白・文字を小さくする(文字は12px以上) */
#optbar[data-o] { gap: 8px; }
#optbar[data-o] #unitbar { --ug: 8px; }
#optbar[data-o] #unitbar button { padding: 1px 7px; }
#optbar[data-o="2"] #unitbar, #optbar[data-o="3"] #unitbar, #optbar[data-o="4"] #unitbar { --ug: 6px; }
#optbar[data-o="2"] #unitbar button, #optbar[data-o="3"] #unitbar button { font-size: 12px; padding: 1px 5px; }
#optbar[data-o="3"] #unitbar .ul, #optbar[data-o="4"] #unitbar .ul { display: none; }  /* 「単位」の文字を隠す */
#optbar[data-o="4"] { gap: 6px; }
#optbar[data-o="4"] #unitbar { --ug: 4px; }
#optbar[data-o="4"] #unitbar button { font-size: 12px; padding: 1px 4px; }
#optbar[data-o="2"] #foodbar select, #optbar[data-o="3"] #foodbar select, #optbar[data-o="4"] #foodbar select { font-size: 12px; width: 5.5em; }

/* ---------- 1.18.3: 比較の税の4つのボタン ----------
   価格の行の下に、横1列(税込|税抜 と 10%|8%)。1つ約30px・高さ28px(押せる範囲32px)。カードの縁から8px以上、グループのあいだ6px以上。
   2個・3個はいつもこの形。4個は、縦に収まるときだけ(収まらないときは、円の右に縦2段。app.js の fitCmp が決める) */
#cmpCards.trow .prow { flex-wrap: wrap; row-gap: 5px; }
#cmpCards.trow .prow input { flex: 1 1 0; width: 0; }      /* 価格と「円」は1行目に */
#cmpCards.trow .ccard .ctw { flex: 0 0 100%; min-width: 0; flex-direction: row; justify-content: space-between; gap: 6px; margin: 0; padding: 0 2px 2px; }
#cmpCards.trow .ccard .tseg { flex: none; }
#cmpCards.trow .ccard .tseg button { height: 28px; min-width: 30px; padding: 0 3px; font-size: 12px; line-height: 1; }
#cmpCards.trow .ccard .tseg:first-child button::after, #cmpCards.trow .ccard .tseg:last-child button::after { top: -3px; bottom: -3px; left: 0; right: 0; }

/* ---------- 1.19.0: 画面の高さが低いときだけ、固定部分を段階的に詰める(高さが十分なときは、今までと同じ) ----------
   app.js の fitScreen が、使える高さ(安全領域を除く)で html に付ける: sh1 = 700px 以下、sh2 = 600px 以下。
   キーの高さは 46px 以上(押せる大きさ約40px以上)。目印は縁から6px以上・重なりなし(画面テストで確認) */
.sa-probe { position: fixed; left: 0; top: 0; width: 0; height: 0; visibility: hidden; pointer-events: none; padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom); }
html.sh1 #topbar button { padding: 5px 2px 4px; }
html.sh1 #total { padding: 4px 6px 4px; }
html.sh1 #pad { --kh: clamp(48px, calc(8.2vh - 4px), 66px); gap: 5px; padding: 6px 6px calc(6px + env(safe-area-inset-bottom)); }
html.sh2 #topbar button { padding: 3px 2px 3px; gap: 1px; }
html.sh2 #topbar .ic { width: 20px; height: 20px; }
html.sh2 #total { padding: 3px 6px 3px; }
html.sh2 #pad { --kh: 46px; gap: 4px; padding: 5px 6px calc(5px + env(safe-area-inset-bottom)); }
/* 低いキー(sh1・sh2)の目印: 重ならないように、↶ は上へ・%と( )は少し下へ(「割引」があるとき)・時間の f キーの中央の字は少し小さく */
html.sh1 #pad button[data-key="enter"] .fm.fu { top: 2px; }
html.sh2 #pad button[data-key="enter"] .fm.fu { top: 1px; }
html.sh1 #pad button[data-key="pct"]:not(.md) .kl { transform: translateY(3px); }                /* どの画面でも同じ位置(1.18.0) */
html.sh1 #pad button[data-key="pct"] .fm.side { transform: translateY(calc(-50% + 3px)); }
html.sh1 #pad button.mu.md[data-key="f"] .kl { font-size: clamp(10px, calc(var(--kh) - 37px), 13px); transform: translateY(2px); }   /* 時間の f キー: 中段(週 月 年)を少し下へ */
html.sh1 #pad button.mu.md[data-key="f"] .fm.fl, html.sh1 #pad button.mu.md[data-key="f"] .fm.fr { transform: translateY(calc(-50% + 2px)); }
html.sh2 #pad button.mu.md[data-key="f"] .kl { transform: translateY(1.5px); }
html.sh2 #pad button.mu.md[data-key="f"] .fm.fl, html.sh2 #pad button.mu.md[data-key="f"] .fm.fr { transform: translateY(calc(-50% + 2.5px)); }
html.sh2 #pad button.nolabel.mu:not(.md) .fm.fl, html.sh2 #pad button.nolabel.mu:not(.md) .fm.fr { transform: translateY(calc(-50% + 2px)); } /* 中央の字がなく上だけに目印(時速/分速・秒速): 左右を少し下へ */
/* sh3 = 450px 以下(横向き): 上部バーは文字を隠してアイコンだけ(読み上げの名前は残す)。キーは 40px、目印は少し小さく */
html.sh3 #topbar button { padding: 10px 2px; }
html.sh3 #topbar .lb { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
html.sh3 #total { padding: 2px 6px 2px; }
html.sh3 #pad { --kh: 40px; gap: 3px; padding: 4px 6px calc(4px + env(safe-area-inset-bottom)); }
html.sh3 #pad .fm { font-size: 11px; }
html.sh3 #pad .fm.fu, html.sh3 #pad button[data-key="bs"] .fm.fu { top: 2px; }
html.sh3 #pad .fm.fd, html.sh3 #pad button[data-key="bs"] .fm.big { bottom: 2px; }
html.sh3 #pad button.mu:not(.md) .kl { transform: translateY(5px); }
html.sh3 #pad button.mu.md .kl, html.sh3 #pad button.mu.md[data-key="bs"] .kl { font-size: 12px; transform: none; }
html.sh3 #pad button[data-key="bs"] .fm.fu { top: 1px; }
html.sh3 #pad button[data-key="bs"] .fm.big { font-size: 12px; bottom: 2px; }
/* 段A が幅に入らないとき(端末の文字が大きい・画面が狭い)だけ: app.js の fitOptbar が data-c を 1→3 と上げる */
.cat-row[data-c] .cmp-btns button { padding: 3px 8px; }
.cat-row[data-c] #catSeg button { padding: 4px 5px; }
.cat-row[data-c="2"] #catSeg button, .cat-row[data-c="3"] #catSeg button { padding: 4px 3px; }
.cat-row[data-c="2"] #cmpCount::before, .cat-row[data-c="3"] #cmpCount::before { content: none; }
.cat-row[data-c="3"] #catSeg button { font-size: 12px; padding: 4px 2px; }
.cat-row[data-c="3"] .cmp-btns button { font-size: 12px; padding: 3px 6px; }
#optbar[data-o="4"] #cfgnote { flex: 0 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } /* それでも入らないとき(とても狭いとき)だけ、末尾を「…」に */
html.sh3 #savenote { display: none; }                                                  /* 横向き: 入力欄を1行以上見せるため(縦向きでは表示) */
html.sh3 #pad button[data-key="enter"] .fm.fu { font-size: 17px; top: 0; }               /* 横向き: ↶ と ⏎ が重ならないように */

/* ---------- 1.20.0: タブ(段A)は画面の上。下は 段B(画面ごとのボタン)と 段C(行の見出しと結果)だけ ----------
   タブの列の高さは、どの画面(sh1〜sh3 も)でも同じ 37px。段C は 24px に細くした */
#catbar { flex: none; box-sizing: border-box; height: 37px; padding: 4px 6px; background: var(--c-totalBg); border-bottom: 1px solid var(--c-line); }
#catSeg button::after { top: -4px; bottom: -4px; }          /* 押せる範囲: タブの列の中で上下に広げる(36px) */
#total, html.sh1 #total, html.sh2 #total, html.sh3 #total { padding-top: 2px; }
#total { padding-bottom: 4px; }
html.sh1 #total { padding-bottom: 3px; }
html.sh2 #total, html.sh3 #total { padding-bottom: 2px; }
#unitbar button::after { top: -6px; }                       /* 段Bの上の余白まで */
#sumbar { display: flex; align-items: center; gap: 8px; height: 24px; min-width: 0; }
#sumbar .tl { flex: 0 1 auto; min-width: 0; max-width: 45%; }
#sumRows { flex: 1 1 auto; min-width: 0; height: 24px; }
#sumRows.grid1 .sumrow .sv { font-size: 1.3rem; line-height: 1; }
#sumRows.grid2, #sumRows.grid3 { align-content: center; }
#sumRows.grid3 .sumrow .sl { font-size: .6rem; }
#sumRows.grid3 .sumrow .sv, #sumRows.grid2 .sumrow .sv { font-size: .85rem; line-height: 1.1; }
body.cmp #sumbar .tl { display: none; }
/* 料理: 食材を選んだ行は、行の右下に小さく食材名 */
.row { position: relative; }
.row .ftag { position: absolute; right: .6em; bottom: 1px; font-size: 11px; line-height: 1.2; color: var(--c-text); opacity: .85; pointer-events: none; white-space: nowrap; max-width: 40%; overflow: hidden; text-overflow: ellipsis; }
.row .ftag[hidden] { display: none; }
.row.hasfood .res { padding-bottom: 6px; line-height: 2.2; } /* 答えを少し上げて、食材名と重ならないように */
/* 1.20.0: 「答えの単位」は2行(答えの/単位)にして、幅を「単位」と同じくらいに(文字は12px) */
#optbar { padding-top: 2px; } /* 1.20.0: タブが上に移ったので、段Bの上の余白は #total の 2px と合わせて小さく */
/* 料理のカップキー: 低いキー(sh1)では、中央の「カップ」を小さくして、上下の 大さじ・小さじ と重ならないように */
html.sh1 #pad button.mu.md[data-key="u"] .kl { font-size: clamp(10px, calc(var(--kh) - 37px), 13px); }

/* ---------- 1.21.0: 大きさと余白の調整 ---------- */
/* 段B: ボタンどうしは 8px にそろえる。ボタンの横の余白は詰める(押せる範囲は ::after で 幅40px以上)。
   「答えの単位」は、入るときは1行。入らないときは fitOptbar が data-o を上げる: 1=2行 / 2=すきま6px / 3=名前を隠して文字12px / 4=いちばん詰める */
#unitbar { --ug: 8px; }
#unitbar button { padding: 1px 9px; min-width: 34px; }
#unitbar .modeseg button { min-width: 0; padding: 1px 7px; }
#unitbar .ul { width: auto; white-space: nowrap; line-height: 1.2; text-align: left; margin-right: calc(12px - var(--ug)); } /* ボタンとのあいだ 12px */
#unitbar .modeseg { margin-left: calc(12px - var(--ug)); }                                                                  /* 単位ボタンのグループとのあいだ 12px */
#optbar[data-o] { gap: 12px; }
#optbar[data-o] #unitbar { --ug: 8px; }
#optbar[data-o] #unitbar button { padding: 1px 9px; font-size: 13px; }
#optbar[data-o] #unitbar .modeseg button { padding: 1px 7px; font-size: 12px; }
#optbar[data-o="1"] #unitbar .ul, #optbar[data-o="2"] #unitbar .ul { width: 3.25em; white-space: normal; line-height: 1.05; } /* 答えの/単位 の2行 */
#optbar[data-o="2"] #unitbar, #optbar[data-o="3"] #unitbar { --ug: 6px; }
#optbar[data-o="2"] #unitbar button { padding: 1px 6px; }
#optbar[data-o="3"] #unitbar button { font-size: 12px; padding: 1px 5px; }
#optbar[data-o="3"] #unitbar .modeseg button, #optbar[data-o="4"] #unitbar .modeseg button { padding: 1px 5px; }
#optbar[data-o="4"] { gap: 8px; }
#optbar[data-o="4"] #unitbar { --ug: 4px; }
#optbar[data-o="4"] #unitbar button { font-size: 12px; padding: 1px 4px; min-width: 0; }

/* 価格の合計欄: 段B(価格の画面では使わない)の分まで広げて、金額を大きく。下の部分の高さは、ほかのタブと同じ(入力エリアは変わらない)
   上に行の見出し、下に 税抜価格・税額・税込価格(名前の下に金額)。金額が入らないときは app.js の fitSum が文字を小さくする */
body.cat-yen #optbar { display: none; }
body.cat-yen #sumbar { height: 56px; flex-direction: column; align-items: stretch; justify-content: center; gap: 1px; }
body.cat-yen #sumbar .tl { max-width: none; font-size: 12px; line-height: 1.2; }
body.cat-yen #sumRows { flex: none; height: auto; overflow: hidden; }
body.cat-yen #sumRows.grid3 { justify-content: flex-end; gap: 0 18px; flex-wrap: nowrap; }
body.cat-yen #sumRows.grid3 .sumrow .sl { font-size: 11px; line-height: 1.2; }
body.cat-yen #sumRows.grid3 .sumrow .sv { font-size: 1.3rem; line-height: 1.15; }
body.cat-yen #sumRows[data-f="1"].grid3 .sumrow .sv { font-size: 1.1rem; }
body.cat-yen #sumRows[data-f="2"].grid3 .sumrow .sv { font-size: .95rem; }
body.cat-yen #sumRows[data-f="3"].grid3 .sumrow .sv { font-size: .8rem; }
body.cat-yen #sumRows[data-f].grid3 { gap: 0 10px; }
body.cat-yen #sumRows.grid1 .sumrow .sv { font-size: 1.4rem; line-height: 1.15; }

/* 比較が2つのとき: 税込・税抜、10%・8% のボタンを大きく(高さ36px・文字14px)。周りの余白は詰める。3つ・4つは今のまま */
#cmpCards.trow.n2 .prow { row-gap: 3px; }
#cmpCards.trow.n2 .ccard .tseg button { height: 36px; min-width: 33px; padding: 0 3px; font-size: 13.5px; }
/* 段Bのボタンは、段B(32px)の上下の真ん中に(押せる範囲を上下とも 16px に。段Bは中身を切り取るので、外へは出せない) */
#optbar { padding-top: 0; align-items: center; }
#total, html.sh1 #total, html.sh2 #total, html.sh3 #total { padding-top: 1px; }
/* いちばん詰めた段階(とても狭いとき)は、「食材:」の名前も隠す(読み上げの名前は残す) */
#optbar[data-o="4"] #foodbar .ul { display: none; }
#optbar[data-o="4"] #foodbar select { width: 5em; }
#unitbar button::after { top: -6px; bottom: -7px; } /* 段B(32px)の中で、上下に広げる(段Bの外は切り取られる。押せる範囲は高さ32px) */
body.cat-yen #sumRows.grid3 .sumrow { flex: 0 0 auto; }
body.cat-yen #sumRows.grid3 .sumrow .sv { white-space: nowrap; }  /* 金額は折り返さない(入らないときは文字を小さく) */
body.cat-yen #sumRows[data-f="4"].grid3 .sumrow .sv { font-size: .7rem; }
body.cat-yen #sumRows[data-f="5"].grid3 .sumrow .sv { font-size: .6rem; }

/* ---------- 1.22.0 ---------- */
/* 結果の、数字のあとの単位(円・km・時間・g など)は、数字の約80%(数字が自動で小さくなるときも、いっしょに) */
.yu { font-size: .8em; }
.ccard .up .yu { font-size: max(12px, .8em); } /* 比較のカードは文字が小さいので、12px より小さくはしない */

/* 横1列のとき(1.22.0 は2つだけ。1.24.0 から3つ・4つも): 税込|税抜 と 10%|8% の2組を、横の幅いっぱいに均等に広げる(あいだは 6px)。高さと文字の大きさは同じ */
#cmpCards.trow .ccard .tseg { flex: 1 1 0; }
#cmpCards.trow .ccard .tseg button { flex: 1 1 0; min-width: 33px; }
/* 押せる範囲: 外側のボタンはカードの縁の方へ、内側は組のあいだの半分まで広げる(高さ42px・幅は約40px以上) */
/* 幅360pxでも押せる幅が約40pxになるように: 左右の余白を詰め(縁からは8px以上)、押せる範囲は枠線の分も広げる */
#cmpCards.trow .ccard .ctw { padding: 0; margin: 0 0 0 calc(7.25px - var(--cp)); flex: 0 0 calc(100% + 2 * (var(--cp) - 7.25px)); } /* 左右とも、カードの縁から約8px */
#cmpCards.trow:not(.n2) .ccard .ctw { padding-bottom: 2px; }
#cmpCards.trow .ccard .tseg:first-child button:first-child::after { left: -7px; }
#cmpCards.trow .ccard .tseg:first-child button:last-child::after { right: -4px; }
#cmpCards.trow .ccard .tseg:last-child button:first-child::after { left: -4px; }
#cmpCards.trow .ccard .tseg:last-child button:last-child::after { right: -7px; }
#cmpCards.trow:not(.n2) .ccard .tseg button::after { top: -4px; bottom: -4px; } /* 3つ・4つ(高さ28px)は、押せる高さを少し広く */

/* ---------- 1.24.0: 2段(円の右。上=税込|税抜、下=10%|8%)のときも、押しやすく ----------
   1つの幅 32px → 36px(押せる幅は約40px。幅が360pxより狭いときは30pxまで)。高さは、縦に余裕があるときだけ高くする(4つが高さ640pxで収まる大きさは今まで通り) */
#cmpCards:not(.trow) .ccard .tseg button { min-width: clamp(30px, calc(11vw - 3.6px), 36px); padding-left: 0; padding-right: 0; height: max(17.2px, calc(var(--ch) * .72)); }
#cmpCards:not(.trow) .ccard .tseg button:first-child::after { left: -6px; }
#cmpCards:not(.trow) .ccard .tseg button:last-child::after { right: -7px; }

/* ---------- 1.23.0 配色パターン ----------
   色は config.js の colors(標準)と themes。theme.js が --c-… に入れる。「標準」以外のときは html に data-skin が付く。
   ここでは色と濃さだけを変える(大きさ・配置は変えない) */
/* 1.25.0: 配色は18個になったので、1行ずつの一覧(中でスクロール)。1行 44px。色の丸3つ = 背景・上部バー・ボタン */
#themeNow { margin: 4px 0 6px; font-size: .85rem; font-weight: 700; color: var(--c-ink, var(--c-bar)); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#themeList { position: relative; max-height: 292px; overflow-y: auto; -webkit-overflow-scrolling: touch; border: 1px solid var(--c-ink, var(--c-bar)); border-radius: 10px; }  /* 6行半: 続きがあると分かる高さ */
#themeList button { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 44px; padding: 4px 12px; text-align: left; font: inherit; font-size: .9rem; line-height: 1.3;
  border: 0; border-bottom: 1px solid var(--c-line); background: transparent; color: var(--c-number); cursor: pointer; }
#themeList button:last-child { border-bottom: 0; }
#themeList button.on { background: var(--c-ink, var(--c-bar)); color: var(--c-onInk, var(--c-barText)); font-weight: 700; }
#themeList .sw { display: flex; flex: none; gap: 3px; }
#themeList .swd { width: 18px; height: 18px; border-radius: 50%; border: 1px solid rgba(128,128,128,.75); display: block; }
#themeList .thn { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#themeList .thc { flex: none; font-size: .75rem; white-space: nowrap; }

/* 「標準」以外: 薄くしていた文字(透かし)は、透かさずに色で薄くする(コントラスト比 4.5 以上を守る) */
html[data-skin] #savenote, html[data-skin] #splash p, html[data-skin] .about-sub { opacity: 1; }
html[data-skin] .sumrow .sl, html[data-skin] #total .tl, html[data-skin] #unitbar .ul, html[data-skin] #foodbar .ul,
html[data-skin] .row .ftag, html[data-skin] .about-ver, html[data-skin] #noteList .nt small, html[data-skin] .tmtoday:disabled { opacity: 1; color: var(--c-muted); }
html[data-skin] .res.hint, html[data-skin] #sumRows .sumrow.hint .sv { opacity: 1; color: var(--c-muted); }
html[data-skin] .ccard input::placeholder, html[data-skin] #cmpCards .ccard .cxb ::placeholder, html[data-skin] #pasteText::placeholder { opacity: 1; color: var(--c-muted); }
html[data-skin] .ccard .cxp, html[data-skin] .ccard .cxp:empty::before, html[data-skin] .ccard .cxk, html[data-skin] .ccard .per,
html[data-skin] .ccard .up.none, html[data-skin] .ccard .cxdv.empty { opacity: 1; color: var(--c-muted); }
html[data-skin] .ccard .cxt.clr { opacity: 1; color: var(--c-muted); border-color: var(--c-muted); }
html[data-skin] .ccard .csale:not(.on) { opacity: 1; color: var(--c-muted); border-color: var(--c-muted); }
html[data-skin] .ccard .tseg button { opacity: 1; }          /* 税の切り替え: 選んでいない方も読める濃さに(選んでいる方は塗り) */
html[data-skin] #pad .fm { opacity: 1; }                     /* フリックの目印 */
html[data-skin] #pad button.soon { opacity: 1; }
html[data-skin] select option { background: var(--c-bg); color: var(--c-number); }
html[data-skin] { --c-delActive: var(--c-number); }

/* 1.27.0 行の並べ替え(番号の長押し → ドラッグ)。大きさ・配置は変えない(transform で動かすだけ) */
body.rowdrag .row { transition: transform .16s ease; }
body.rowdrag .row.dragging {
  transition: none; z-index: 3; opacity: .72; background: var(--c-activeRow);
  outline: 2px solid var(--c-keyOpText); outline-offset: -2px; box-shadow: 0 6px 16px rgba(0,0,0,.28);
}
body.rowdrag .row.dragging .num { font-weight: 700; }
body.rowdrag, body.rowdrag * { cursor: grabbing; user-select: none; -webkit-user-select: none; }
body.rowdrag #pad, body.rowdrag #topbar, body.rowdrag #catbar, body.rowdrag #sumbar, body.rowdrag .row textarea, body.rowdrag .res { pointer-events: none; } /* 移動中は、キーや入力が動かない */
@media (prefers-reduced-motion: reduce) { body.rowdrag .row { transition: none; } }
