/* 客の画面。大手のモバイルオーダーの作りに寄せる:
   白い地・OS 標準の文字・平らな面（グラデーションと影の重ねは使わない）・差し色は 1 色・1 列・下に次へ進むバー 1 本。
   写真の枠は全部の品に出す（写真が無い品は空の枠に「写真」。店側の画面から貼る） */
:root {
  --bg: #ffffff;
  --bg-2: #f4f4f5;        /* 面の区切り・選ばれていないボタン */
  --fg: #18181b;
  --muted: #6b6b73;
  --line: #e4e4e7;
  --accent: #b5121b;      /* 店の色。STORE.color で店ごとに上書きできる */
  --accent-fg: #ffffff;
  --accent-soft: #fbeaea;
  --soldout: #a1a1aa;
  --ok: #15803d;
  --warn: #b45309;
  --font: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP", "Yu Gothic UI", "Yu Gothic", Meiryo, sans-serif;
  color-scheme: light;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { min-height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--fg);
  font-family: var(--font); font-size: 16px; line-height: 1.5;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  padding-block: 0 16px;
  -webkit-tap-highlight-color: transparent;
  font-variant-numeric: tabular-nums;
}
#app { max-width: 520px; margin: 0 auto; min-height: 100vh; display: flex; flex-direction: column; }
button { font: inherit; color: inherit; }
button:focus-visible, a:focus-visible, input:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.screen { display: flex; flex-direction: column; flex: 1; }
main { flex: 1; display: flex; flex-direction: column; gap: 16px; padding-block: 16px; }
.center-main { justify-content: center; text-align: center; }
h1 { font-size: 20px; font-weight: 700; margin: 0; }
.sec { font-size: 15px; font-weight: 700; margin: 0; }
p { margin: 0; }
.muted { color: var(--muted); font-size: 14px; }
.center { text-align: center; }
.note { font-size: 13px; color: var(--muted); }
.stack { display: flex; flex-direction: column; gap: 10px; }
.row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }

/* ---- 上の帯 ---- */
.bar {
  position: sticky; top: 0; z-index: 6;
  display: flex; align-items: center; gap: 12px; min-height: 52px;
  margin-inline: calc(-1 * max(16px, env(safe-area-inset-left, 0px)));
  padding: env(safe-area-inset-top, 0px) max(16px, env(safe-area-inset-left, 0px)) 0;
  background: var(--bg); border-bottom: 1px solid var(--line);
}
.bar .title { flex: 1; min-width: 0; font-size: 17px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar .back + .title { text-align: center; }
.bar .back { background: none; border: 0; color: var(--accent); font-size: 16px; padding: 12px 4px; cursor: pointer; white-space: nowrap; }
.bar .back + .seat { margin-left: auto; }
.bar .hist {
  display: inline-flex; align-items: center; gap: 6px; min-height: 36px; padding: 0 12px;
  border: 1px solid var(--line); border-radius: 18px; background: var(--bg); font-size: 14px; cursor: pointer;
}
.badge { background: var(--accent); color: var(--accent-fg); font-size: 12px; font-weight: 700; border-radius: 10px; min-width: 20px; padding: 0 6px; text-align: center; }
.seat { display: flex; align-items: baseline; gap: 4px; white-space: nowrap; }
.seat small { font-size: 12px; color: var(--muted); }
.seat .tno { font-size: 17px; font-weight: 700; }
.seatline { display: flex; justify-content: space-between; font-size: 13px; color: var(--muted); padding-top: 10px; }
.seatline b { color: var(--fg); font-size: 15px; }

/* ---- 入口 ---- */
.hero-head {
  margin-inline: calc(-1 * max(16px, env(safe-area-inset-left, 0px)));
  padding: calc(28px + env(safe-area-inset-top, 0px)) 16px 24px; text-align: center;
  background: var(--accent); color: var(--accent-fg);
}
.hero-head .kind { font-size: 13px; opacity: .85; }
.hero-head .store-name { font-size: 28px; font-weight: 700; letter-spacing: .04em; overflow-wrap: anywhere; }
.seat-plate { margin: 4px auto 0; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 16px 32px; border: 1px solid var(--line); border-radius: 12px; }
.seat-plate .lbl { font-size: 13px; color: var(--muted); }
.seat-plate .n { font-size: 44px; font-weight: 700; line-height: 1.1; }
.tables, .guests { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.guests { grid-template-columns: repeat(5, 1fr); }
.tables button, .guests button {
  min-height: 52px; border-radius: 8px; border: 1px solid var(--line); background: var(--bg);
  font-size: 18px; font-weight: 600; cursor: pointer;
}
.tables button[aria-pressed="true"], .guests button[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-fg); }
.thanks { font-size: 22px; font-weight: 700; }
.link { display: block; margin: 8px auto 0; background: none; border: 0; color: var(--accent); font-size: 14px; padding: 10px; cursor: pointer; }
.local-note { font-size: 13px; line-height: 1.6; color: #713f12; background: #fef3c7; border: 1px solid #fde68a; border-radius: 8px; padding: 10px 12px; }

/* ---- 分類のタブ（下線で今の分類を示す） ---- */
.cats {
  position: sticky; top: calc(52px + env(safe-area-inset-top, 0px)); z-index: 5;
  display: flex; overflow-x: auto; scrollbar-width: none;
  margin-inline: calc(-1 * max(16px, env(safe-area-inset-left, 0px)));
  padding: 0 max(8px, env(safe-area-inset-left, 0px));
  background: var(--bg); border-bottom: 1px solid var(--line);
}
.cats::-webkit-scrollbar { display: none; }
.cats button {
  flex: 0 0 auto; border: 0; background: none; padding: 12px 12px 10px; font-size: 15px; cursor: pointer; white-space: nowrap;
  color: var(--muted); border-bottom: 3px solid transparent;
}
.cats button[aria-selected="true"] { color: var(--fg); font-weight: 700; border-bottom-color: var(--accent); }

/* ---- 品書き（1 品 1 行。左に写真の枠） ---- */
.items { display: flex; flex-direction: column; margin-top: -8px; }
.cat-note { font-size: 12px; color: var(--muted); padding: 4px 0 8px; }
.item {
  position: relative; display: flex; align-items: center; gap: 12px;
  width: 100%; text-align: left; padding: 14px 0; border: 0; border-bottom: 1px solid var(--line); background: none; cursor: pointer;
}
.item .rank { flex: 0 0 28px; font-size: 20px; font-weight: 700; color: var(--accent); text-align: center; }
.item .photo { flex: 0 0 80px; width: 80px; height: 80px; border-radius: 8px; overflow: hidden; background: var(--bg-2); }
.item .photo.none, .hero.none { display: grid; place-items: center; color: var(--soldout); font-size: 12px; border: 1px dashed #d4d4d8; }
.hero.none { font-size: 14px; }
.item .photo img, .hero img { width: 100%; height: 100%; object-fit: cover; display: block; }
.item .body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.item .name { font-weight: 700; font-size: 16px; }
.item .desc { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item .price { font-size: 16px; font-weight: 700; }
.item .price small { font-weight: 400; font-size: 12px; color: var(--muted); }
.item .plus {
  flex: 0 0 36px; width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center;
  border: 1.5px solid var(--accent); color: var(--accent); font-size: 22px; line-height: 1;
}
.item .tags { display: flex; gap: 4px; flex-wrap: wrap; }
.tag { font-size: 11px; font-weight: 700; padding: 1px 6px; border-radius: 4px; line-height: 1.6; }
.tag.badge { background: var(--accent-soft); color: var(--accent); }
.tag.pop { background: var(--accent); color: var(--accent-fg); }
.tag.left { background: #fef3c7; color: var(--warn); }
.tag.incart { background: var(--bg-2); color: var(--fg); }
.item.soldout { cursor: not-allowed; }
.item.soldout .name, .item.soldout .price, .item.soldout .price small, .item.soldout .desc { color: var(--soldout); }
.item.soldout .photo { opacity: .4; }
.stamp { flex: 0 0 auto; font-size: 12px; font-weight: 700; color: var(--muted); background: var(--bg-2); border-radius: 4px; padding: 4px 8px; }

/* ---- 下の帯（次へ進む 1 本） ---- */
.bottom {
  position: sticky; bottom: 0; z-index: 5; background: var(--bg);
  margin-inline: calc(-1 * max(16px, env(safe-area-inset-left, 0px)));
  padding: 12px max(16px, env(safe-area-inset-left, 0px)) calc(12px + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid var(--line); margin-top: auto;
}
.bottom.stack { gap: 8px; }
.btn {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  width: 100%; min-height: 52px; padding: 12px 20px; border: 0; border-radius: 8px; cursor: pointer;
  background: var(--accent); color: var(--accent-fg); font-size: 16px; font-weight: 700;
}
.btn .amt { font-weight: 700; }
.btn[disabled] { background: var(--bg-2); color: var(--soldout); cursor: not-allowed; }
.btn.secondary { background: var(--bg); color: var(--fg); border: 1px solid var(--line); font-weight: 600; }
.btn.center { justify-content: center; }

/* ---- 詳細 ---- */
.hero { aspect-ratio: 16 / 10; border-radius: 8px; overflow: hidden; background: var(--bg-2); }
.d-head { display: flex; flex-direction: column; gap: 4px; }
.d-badge { align-self: flex-start; }
.price-big { font-size: 22px; font-weight: 700; }
.price-big small { font-weight: 400; font-size: 13px; color: var(--muted); }
.left { color: var(--warn); font-size: 14px; font-weight: 700; }
fieldset { border: 0; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 8px; }
legend { font-size: 15px; font-weight: 700; padding: 0; margin-bottom: 8px; }
legend .req { color: var(--accent); font-size: 12px; margin-left: 6px; font-weight: 600; }
.choices { display: flex; flex-wrap: wrap; gap: 8px; }
.choice { position: relative; }
.choice input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.choice span {
  display: inline-flex; gap: 6px; align-items: center; min-height: 44px; padding: 0 18px; border-radius: 8px;
  border: 1px solid var(--line); background: var(--bg); cursor: pointer; font-size: 15px;
}
.choice input:checked + span { border: 2px solid var(--accent); color: var(--accent); font-weight: 700; padding: 0 17px; }
.choice input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.choice .delta { font-size: 12px; color: var(--muted); }

.qty { display: flex; align-items: center; border: 1px solid var(--line); border-radius: 8px; width: max-content; }
.qty button { width: 44px; height: 44px; border: 0; background: none; font-size: 20px; cursor: pointer; color: var(--accent); }
.qty button:disabled { color: var(--soldout); cursor: not-allowed; }
.qty output { min-width: 44px; text-align: center; font-size: 17px; font-weight: 700; }

/* ---- かご・確認・履歴の明細 ---- */
.lines { display: flex; flex-direction: column; border-top: 1px solid var(--line); }
.line { display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; padding-block: 12px; border-bottom: 1px solid var(--line); align-items: center; }
.line .lname { font-weight: 700; min-width: 0; }
.line .lopt { font-size: 13px; color: var(--muted); grid-column: 1; }
.line .lamt { font-weight: 700; text-align: right; }
.line .lctl { grid-column: 1 / -1; display: flex; align-items: center; gap: 12px; margin-top: 6px; }
.line .remove { background: none; border: 0; color: var(--muted); font-size: 14px; cursor: pointer; padding: 10px 6px; }
.line .lqty { font-size: 13px; color: var(--muted); }
.total { display: flex; justify-content: space-between; align-items: baseline; font-size: 16px; font-weight: 700; }
.total .n { font-size: 22px; }
.total.grand { border-top: 1px solid var(--fg); padding-top: 12px; }
.empty { padding-block: 32px; text-align: center; color: var(--muted); }

/* ---- 注文番号 ---- */
.ticket { border: 1px solid var(--line); border-radius: 12px; padding: 24px 20px; text-align: center; display: flex; flex-direction: column; gap: 6px; }
.ticket .lbl { font-size: 13px; color: var(--muted); }
.ticket .no { font-size: 64px; font-weight: 700; line-height: 1.05; }
.ticket .meta { font-size: 13px; color: var(--muted); }
.ticket.done .no { color: var(--muted); }
.status { display: inline-flex; align-items: center; gap: 6px; justify-content: center; font-size: 15px; font-weight: 700; }
.status::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.status.new { color: var(--accent); }
.status.cooking { color: var(--warn); }
.status.served, .status.ok { color: var(--ok); }
.status.cancelled { color: var(--muted); }

.hcard { border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; display: flex; flex-direction: column; gap: 6px; }
.hcard .hhead { display: flex; align-items: center; gap: 10px; }
.hcard .hno { font-size: 18px; font-weight: 700; }
.hcard .hno small { font-size: 12px; color: var(--muted); font-weight: 400; margin-right: 2px; }
.hcard .hat { font-size: 12px; color: var(--muted); }
.hcard .status { margin-left: auto; font-size: 13px; }
.hcard .line { padding-block: 8px; }
.hcard .line:last-child { border-bottom: 0; }
.hcard .btn { min-height: 44px; font-size: 15px; }
.hcard.cancelled { opacity: .6; }

.foot { font-size: 11px; color: var(--muted); text-align: center; padding-block: 8px; }

/* 一時通知（上の帯のすぐ下。下の主ボタンに被せない） */
.toast {
  position: fixed; left: 50%; top: calc(60px + env(safe-area-inset-top, 0px)); transform: translateX(-50%);
  background: var(--fg); color: var(--bg); padding: 10px 16px; border-radius: 8px; font-size: 14px;
  max-width: calc(100% - 32px); z-index: 20; opacity: 0; transition: opacity .15s; pointer-events: none;
}
.toast.show { opacity: 1; }
@media (prefers-reduced-motion: reduce) { .toast { transition: none; } }
