* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: -apple-system, "Hiragino Sans", "Noto Sans JP", sans-serif;
  background: #F7F5F0;
  color: #1F2A37;
  padding-bottom: env(safe-area-inset-bottom);
}
button {
  font: inherit;
  font-weight: 700;
  border: none;
  border-radius: 14px;
  padding: 14px 10px;
  background: #FFFFFF;
  color: #1F2A37;
  box-shadow: 0 1px 3px rgba(31, 42, 55, .2);
  -webkit-tap-highlight-color: transparent;
}
button:active { transform: scale(.97); }

/* 合計バー */
.status {
  position: sticky; top: 0; z-index: 10;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  color: #F7F5F0;
  transition: background-color .2s;
}
.status.ok { background: #23704A; }
.status.near { background: #F2C230; color: #1F2A37; }
.status.over { background: #B5332A; }
.status-main { display: flex; justify-content: space-between; align-items: flex-end; }
.label { font-size: 14px; font-weight: 700; opacity: .9; }
.total { font-size: 40px; font-weight: 800; line-height: 1.1; }
.rest-box { text-align: right; }
.rest { font-size: 28px; font-weight: 800; }
.over-banner { display: none; margin-top: 6px; font-size: 22px; font-weight: 800; text-align: center; }
.status.over .over-banner { display: block; }
body.over { background: #F6D5D1; }

/* カメラ */
.camera { position: relative; background: #111; height: 50vh; overflow: hidden; }
.camera video { width: 100%; height: 100%; object-fit: cover; display: block; }
.guide {
  position: absolute; left: 5%; right: 5%; top: 16%; height: 56%;
  border: 4px solid #E86A1A; border-radius: 14px;
  box-shadow: 0 0 0 2000px rgba(0, 0, 0, .35);
  pointer-events: none;
}
.guide span {
  position: absolute; top: -28px; left: 0; right: 0; text-align: center;
  color: #FFF; font-size: 14px; font-weight: 700; text-shadow: 0 1px 3px #000;
}
.candidates {
  position: absolute; left: 12px; right: 12px; bottom: 12px;
  display: flex; flex-direction: column; gap: 8px;
}
.cand {
  background: #E86A1A; color: #1F2A37;
  font-size: 22px; padding: 16px; border-radius: 16px;
}
.cand small { display: block; font-size: 13px; font-weight: 700; opacity: .85; }
.overlay {
  position: absolute; inset: 0; background: rgba(31, 42, 55, .88);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px;
  padding: 20px;
}
.big-btn { background: #E86A1A; color: #1F2A37; font-size: 24px; padding: 20px 36px; border-radius: 20px; }
.overlay-note { color: #C9D3DC; font-size: 14px; margin: 0; text-align: center; }
.loading {
  position: absolute; top: 10px; left: 50%; transform: translateX(-50%);
  background: rgba(0, 0, 0, .7); color: #FFF; padding: 6px 14px; border-radius: 999px; font-size: 14px;
}
.hidden { display: none !important; }

/* デバッグ */
.debug { background: #222; color: #9EF; padding: 8px; }
.debug canvas { max-width: 100%; background: #FFF; display: block; }
.debug pre { margin: 6px 0 0; white-space: pre-wrap; font-size: 13px; }

/* ボタン列 */
.actions { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; padding: 10px 12px; }
.actions button { font-size: 15px; }

/* 一覧 */
main { padding: 0 12px 24px; }
.items { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.item {
  background: #FFF; border-radius: 14px; padding: 10px 12px;
  display: flex; align-items: center; gap: 8px;
}
.item-info { flex: 1; min-width: 0; }
.item-price { font-size: 20px; font-weight: 800; }
.item-sub { font-size: 13px; color: #4A5568; }
.qty { display: flex; align-items: center; gap: 4px; }
.qty button { width: 40px; height: 40px; padding: 0; font-size: 20px; }
.qty span { min-width: 28px; text-align: center; font-weight: 800; font-size: 18px; }
.del { width: 40px; height: 40px; padding: 0; color: #B5332A; }
.empty { text-align: center; color: #4A5568; }
.note { font-size: 12px; color: #4A5568; line-height: 1.6; }
.clear-btn { width: 100%; color: #B5332A; }
.overlay-warn { color: #F4C9A8; font-weight: 700; }
.disclaimer { margin-top: 24px; padding: 14px 16px; background: #FFFFFF; border-radius: 14px; }
.disclaimer h2 { margin: 0 0 6px; font-size: 15px; }
.disclaimer ul { margin: 0; padding-left: 1.2em; }
.disclaimer li { font-size: 12px; color: #4A5568; line-height: 1.7; }

/* ダイアログ */
dialog { border: none; border-radius: 20px; padding: 0; width: min(92vw, 420px); }
dialog::backdrop { background: rgba(0, 0, 0, .5); }
.dlg { display: flex; flex-direction: column; gap: 12px; padding: 20px; }
.dlg h2 { margin: 0 0 4px; font-size: 20px; }
.dlg input[type=text], .dlg input[type=number] {
  width: 100%; font-size: 22px; padding: 12px; border: 2px solid #D9DED9; border-radius: 12px; margin-top: 6px;
}
.dlg label { font-weight: 700; font-size: 15px; display: block; }
.dlg label small { display: block; font-weight: 400; color: #4A5568; margin-top: 4px; }
.dlg .check { display: flex; align-items: center; gap: 10px; }
.dlg .check input { width: 24px; height: 24px; }
.dlg-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.primary { background: #E86A1A; color: #1F2A37; }
.danger { background: #B5332A; color: #FFF; }
