/*
 * デモ用の黒基調の配色（店舗ごとにCSS変数で差し替える）。
 * 色は必ず CSS変数を経由し、店舗ごとの差し替えは :root[data-store="..."] だけで行う。
 * 暗い店内で片手で使う前提は初期版から据え置き（ダーク固定・数字を大きく・タップ48px）。
 */
:root {
  /* --- 共通の面（両店とも公式サイトが黒地・白文字） --- */
  --bg: #000;
  --card: #111;
  --card-2: #1b1b1b;
  --line: #333;
  --text: #fff;
  --muted: #a6a6a6;
  --plate: #fff;          /* 白地前提のロゴを載せる角丸プレート */
  --radius: 14px;
  --tap: 48px;

  /* --- アクセント（店舗未選択のときは色を持たせない中立テーマ） --- */
  --accent: #3a3a3a;        /* ボタンの塗り */
  --accent-ink: #fff;       /* --accent の塗りに載せる文字 */
  --accent-bright: #fff;    /* 黒地に置く文字・枠（金額の強調はここ） */
  --accent-2: #d9d9d9;      /* 差し色（個数バッジ・割引額） */
  --accent-2-ink: #1a1a1a;  /* --accent-2 の塗りに載せる文字 */
  --accent-tint: #1b1b1b;   /* 選択中の面のうすい塗り */
}

/* デモ店A: 黒 × ワインレッド */
:root[data-store="demo-a"] {
  --accent: #990023;
  --accent-ink: #fff;
  --accent-bright: #e8365c;
  --accent-2: #ffe205;
  --accent-2-ink: #1a1a1a;
  --accent-tint: #2a0711;
}

/* デモ店B: 黒 × ブルー、差し色は肉球のピンク */
:root[data-store="demo-b"] {
  --accent: #0073a5;
  --accent-ink: #fff;
  --accent-bright: #0099db;
  --accent-2: #ffb9c1;
  --accent-2-ink: #1a1a1a;
  --accent-tint: #052430;
}

* { box-sizing: border-box; }

/* ダブルタップでの拡大を止める（会計中に画面が急に拡大するのを防ぐ。ピンチ拡大は残る） */
html, body, button, input, select, label, a { touch-action: manipulation; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  /* 公式サイトは tbudgothic-std（Adobe Fonts）。端末に無いので同系の角ゴシックへ落とす */
  font-family: "Yu Gothic Medium", "游ゴシック Medium", YuGothic, "ヒラギノ角ゴ Pro W3", "メイリオ", sans-serif;
  font-size: 17px;
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
}

/* ===== アプリバー（ロゴ2枚がそのまま店舗切替になっている） ===== */

.appbar {
  position: sticky;
  top: 0;
  z-index: 10;
  padding: max(8px, env(safe-area-inset-top)) 12px 0;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}
.appbar-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-bottom: 8px;
}

/* 画面には出さないが、文書の見出しとしては残す */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* 上のバーは店名（小さく）と設定ボタンだけ */
.store-name { flex: 1 1 auto; font-size: 14px; color: var(--accent-bright); font-weight: 700; letter-spacing: .04em; }

/* 設定画面の店舗選択（2枚並べて、選択中だけ色を出す） */
.store-pick { display: flex; gap: 8px; }
.store-pick .store-btn {
  flex: 1 1 0;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 64px;
  padding: 6px 12px;
  border-radius: 12px;
  border: 2px solid transparent;
  background: var(--plate);
  opacity: .32;
  filter: grayscale(1);
}
.store-pick .store-btn img { height: 44px; width: auto; max-width: 100%; display: block; }
.store-pick .store-btn.on { opacity: 1; filter: none; border-color: var(--accent-bright); }

/* 新しい版が届いたときだけ出る帯（アプリバーの一部なので、スクロールしても見えたままになる） */
.update-bar { display: flex; margin: 0 -12px; }
.update-bar[hidden] { display: none; }
.update-bar button {
  flex: 1 1 auto;
  min-height: 44px;
  border: 0;
  border-top: 1px solid var(--line);
  border-radius: 0;
  background: var(--accent);
  color: var(--accent-ink);
  font-size: 15px;
  font-weight: 700;
}


.icon-btn {
  flex: 0 0 auto;
  margin-left: auto;
  min-height: 38px;
  padding: 0 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--text);
  font-size: 15px;
}

/* 底は下の固定バーの高さぶん空ける（バーに隠れて最後のカードが押せない、をなくす） */
main { padding: 12px 12px calc(96px + env(safe-area-inset-bottom)); max-width: 620px; margin: 0 auto; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 12px;
}
.card h2 {
  margin: 0 0 10px;
  font-size: 14px;
  color: var(--muted);
  font-weight: 600;
  letter-spacing: .08em;
}

.row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}
.row label { flex: 0 0 6.5em; font-size: 15px; color: var(--muted); }
.row .unit { font-size: 14px; color: var(--muted); }

input[type="time"],
input[type="number"],
input[type="text"],
select,
textarea {
  flex: 1 1 auto;
  min-width: 0;
  min-height: var(--tap);
  padding: 6px 10px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--card-2);
  color: var(--text);
  font-size: 17px;
  font-family: inherit;
}
input[type="number"] { text-align: right; }
textarea { width: 100%; font-size: 14px; resize: vertical; }

button {
  min-height: var(--tap);
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--card-2);
  color: var(--text);
  font-size: 16px;
  font-family: inherit;
  cursor: pointer;
}
button:active { transform: translateY(1px); }

/* ===== 時刻の桁入力（入店・退店を1行に。テンキーで "2107" と打つ） ===== */
.time-row { display: flex; gap: 10px; margin-bottom: 8px; }
.time-cell { flex: 1 1 0; min-width: 0; }
.time-cell > label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 2px; }
.digit-wrap { display: flex; gap: 4px; }
.digit-wrap input { flex: 1 1 0; min-width: 0; }
/* 桁入力の欄は等幅・大きめで、打った数字が読み違えにくいように */
#in-time, #out-time, #prior {
  font-size: 22px;
  font-variant-numeric: tabular-nums;
  letter-spacing: .08em;
  text-align: center;
  padding: 4px 6px;
}
#in-time.bad, #out-time.bad, #prior.bad { border-color: #e05050; color: #ff9d9d; }
/* 読み取った結果（"21:07"・"3時間45分"） */
.digit-read { display: block; min-height: 1.3em; font-size: 14px; color: var(--accent-2); text-align: center; }
.digit-read.bad { color: #ff9d9d; }

/* 他店時間: 欄（読みは下）と MAX チェックを1行に */
.prior-row { align-items: center; }
.prior-row .time-cell { flex: 0 0 46%; }
.max-check { flex: 1 1 auto; gap: 8px; font-size: 16px; font-weight: 700; }
.max-check small { display: block; font-size: 12px; font-weight: 400; color: var(--muted); }

.check {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: var(--tap);
  font-size: 16px;
}
.check.sub { padding-left: 22px; font-size: 14px; color: var(--muted); }
.check input[type="checkbox"] { width: 24px; height: 24px; accent-color: var(--accent-bright); }
.check em { font-style: normal; color: var(--accent-2); }

.base-line {
  margin: 6px 0 0;
  padding: 10px;
  border-radius: 10px;
  background: var(--card-2);
  font-size: 15px;
  color: var(--muted);
}
.base-line strong { color: var(--text); font-size: 18px; }

/* オプション: 品目ごとに個数を数字で打つ。個数が入った行だけ店の色で縁取る */
.opt-list { display: flex; flex-direction: column; gap: 6px; }
.opt-row {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: var(--tap);
  padding: 4px 4px 4px 12px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--card-2);
}
.opt-row .n { flex: 1 1 auto; font-size: 15px; line-height: 1.25; }
.opt-row .p { flex: 0 0 auto; font-size: 13px; color: var(--muted); white-space: nowrap; }
.opt-row input[type="number"] {
  flex: 0 0 4.2em;
  min-height: 40px;
  font-size: 20px;
  text-align: center;
  background: var(--card);
}
.opt-row.on { border-color: var(--accent-bright); background: var(--accent-tint); }
.opt-row.on input[type="number"] { color: var(--accent-2); font-weight: 700; }

.free-opt { display: flex; gap: 6px; margin-top: 10px; }
.free-opt input[type="text"] { flex: 2 1 0; }
.free-opt input[type="number"] { flex: 1 1 0; }
.free-opt button { flex: 0 0 auto; padding: 0 14px; background: var(--accent); color: var(--accent-ink); border-color: transparent; }

/* 「その他」の金額欄は品目の行と同じ見た目で、欄だけ広い */
.other-row { margin-top: 6px; }
.other-row input[type="number"] { flex: 0 0 7em; }


.hint { margin: 6px 0 0; font-size: 13px; color: var(--muted); }

/* ===== 下の固定バー（閉じているときは細く、金額と滞在時間だけ大きく。タップで内訳が開く） ===== */
.total-bar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 20;
  max-width: 620px;
  margin: 0 auto;
  background: linear-gradient(160deg, var(--accent-tint), var(--card));
  border-top: 2px solid var(--accent-bright);
  border-radius: 16px 16px 0 0;
  box-shadow: 0 -6px 24px rgba(0, 0, 0, .6);
  padding-bottom: env(safe-area-inset-bottom);
}
.total-bar[hidden] { display: none; }
.tb-head {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 64px;
  padding: 8px 10px 6px 14px;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
}
/* 開閉のつまみ: バーの上辺の真ん中に、縁をまたぐ小さなボタン風のタブ。中の三角で方向を示す */
.tb-tab {
  position: absolute;
  top: -16px;
  left: 50%;
  width: 56px;
  height: 28px;
  margin-left: -28px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 14px;
  border: 2px solid var(--accent-bright);
  background: var(--card);
  box-shadow: 0 -3px 10px rgba(0, 0, 0, .5);
  min-height: 0;
  cursor: pointer;
}
.tb-caret {
  width: 0;
  height: 0;
  border-left: 7px solid transparent;
  border-right: 7px solid transparent;
  border-bottom: 9px solid var(--accent-bright);   /* ▲ 閉じているとき（上に広がる） */
}
.total-bar.open .tb-caret {
  border-bottom: 0;
  border-top: 9px solid var(--accent-bright);      /* ▼ 開いているとき（下に畳む） */
}
.tb-stay { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; line-height: 1.2; }
.tb-stay-main { font-size: 22px; font-weight: 700; }
.tb-formula { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
/* 金額は縦2段（上: 税込を大きく、下: 税抜を小さく薄く）。右揃えで税込の邪魔をしない */
.tb-amount-wrap { flex: 0 0 auto; display: flex; flex-direction: column; align-items: flex-end; line-height: 1.1; }
.tb-excl { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.tb-amount {
  flex: 0 0 auto;
  font-size: 34px;
  font-weight: 700;
  letter-spacing: -.02em;
  color: var(--accent-bright);
  font-variant-numeric: tabular-nums;
}
/* 開いているときは見出しの下に線を引き、上の丸みを消して「伸びた」ことが分かるようにする */
.total-bar.open { border-radius: 0; }
.total-bar.open .tb-head { border-bottom: 1px solid var(--line); }
.tb-body { max-height: 60vh; overflow-y: auto; padding: 8px 14px 14px; }
.tb-body[hidden] { display: none; }

/* 内訳は確認用なので、閉じているバーより文字を大きく・行間を広く */
#breakdown { font-size: 20px; }
#breakdown .bd-line { display: flex; justify-content: space-between; gap: 10px; padding: 10px 0; border-bottom: 1px dashed var(--line); font-variant-numeric: tabular-nums; }
#breakdown .bd-line.total { border-bottom: none; font-weight: 700; font-size: 26px; color: var(--accent-bright); }
#breakdown .bd-line .name { color: var(--muted); }
/* 時間の行は値を少し小さく（"21:07→23:30　2時間23分" が1行に収まるように） */
#breakdown .bd-line.time { font-size: 18px; }
/* 計算式の行は薄く・小さく・線なしで、すぐ下の基本料金にぶら下がって見えるように */
#breakdown .bd-line.formula { font-size: 16px; padding: 4px 0; border-bottom: none; color: var(--muted); }
#breakdown .bd-line.formula .name { color: var(--muted); }

/* クリアはバーの右端。1回目で「もう一度」に変わり、2秒以内の2回目で実行する */
.clear-btn { flex: 0 0 auto; min-height: 40px; padding: 0 12px; font-size: 14px; border-radius: 999px; }
.clear-btn.armed { background: #7a3030; border-color: #e05050; color: #fff; }
.primary { width: 100%; background: var(--accent); color: var(--accent-ink); border-color: transparent; }
/* 「初期設定に戻す」は取り消せない操作なので、店舗の色ではなく固定の警告色にする */
.danger { width: 100%; margin-top: 10px; background: transparent; border-color: #7a3030; color: #ff9d9d; }

.io-row { display: flex; gap: 8px; margin-bottom: 8px; }
.io-row button { flex: 1; }

.setting-opts { list-style: none; margin: 0; padding: 0; }
.setting-opts li { display: flex; align-items: center; gap: 6px; padding: 6px 0; border-top: 1px dashed var(--line); }
.setting-opts li input[type="text"] { flex: 2 1 0; min-height: 40px; font-size: 15px; }
.setting-opts li input[type="number"] { flex: 1 1 0; min-height: 40px; font-size: 15px; }
.setting-opts li button { min-height: 40px; padding: 0 12px; font-size: 14px; }

.foot { text-align: center; font-size: 12px; color: var(--muted); margin-top: 18px; }

/* 端末がライトテーマでも見やすさは変えない（店内が暗いので固定のダーク配色にしている） */
