/* ============================================================
   モグさんぽ Web版 — 画面・部品のスタイル
   色は必ず theme.css の変数を参照する（ここで色値を直書きしない）。
   ============================================================ */

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }   /* display:flex の指定に負けないようにする */

html, body {
  margin: 0; padding: 0; height: 100%;
  background: var(--bg); color: var(--fg);
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Hiragino Kaku Gothic ProN",
               "Noto Sans JP", "Yu Gothic", Meiryo, system-ui, sans-serif;
  font-size: 16px; line-height: 1.45;
  overscroll-behavior-y: none;
}
body { overflow: hidden; }         /* スクロールは各画面のスクロール領域が持つ */
button, input, select, textarea { font: inherit; color: inherit; touch-action: manipulation; }
button { background: none; border: 0; padding: 0; cursor: pointer; }
a { color: var(--navy-light); }
[data-theme="dark"] a { color: var(--sky); }

#app { position: fixed; inset: 0; }

/* --- 画面（スタック）--------------------------------------- */
.screen {
  position: absolute; inset: 0;
  display: flex; flex-direction: column;
  background: var(--bg);
}
.screen.pushed { animation: push-in .26s cubic-bezier(.32,.72,0,1); }
@keyframes push-in { from { transform: translateX(100%); } to { transform: translateX(0); } }
@media (prefers-reduced-motion: reduce) { .screen.pushed { animation: none; } }

/* --- ネイビーのヘッダー ------------------------------------ */
.navbar {
  background: var(--brand-header); color: var(--on-navy);
  padding-top: var(--safe-top);
  flex: 0 0 auto; box-shadow: var(--shadow); z-index: 2;
}
.navbar-row {
  height: var(--header-h);
  display: flex; align-items: center; gap: 4px; padding: 0 6px;
}
.navbar .title { font-size: 17px; font-weight: 700; }
.navbar .subtitle { font-size: 12px; opacity: .85; margin-left: 2px; }
.navbar .spacer { flex: 1 1 auto; }
.iconbtn {
  width: 40px; height: 40px; display: grid; place-items: center;
  color: inherit; border-radius: 10px;
}
.iconbtn:active { background: rgba(255,255,255,.16); }
.iconbtn.dark:active { background: rgba(0,0,0,.08); }
.backbtn { display: flex; align-items: center; gap: 2px; color: inherit; padding: 6px 8px 6px 2px; }
.backbtn .label { font-size: 17px; font-weight: 600; max-width: 60vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* メイン画面のヘッダー（iOS 版 appHeader に合わせる：ロゴ76・タイトル22・件数26。
   高さも iOS と同じく「本文領域の 2/13」にする）*/
.navbar-row.home {
  height: calc((100dvh - var(--safe-top) - var(--safe-bottom)) * 2 / 13);
  min-height: 100px; padding: 0 18px; gap: 14px;
}
.apptitle { font-size: 22px; font-weight: 700; line-height: 1.15; }
.tagline {
  display: flex; align-items: center; gap: 4px; margin-top: 3px;
  font-size: 11px; color: rgba(255,255,255,.75); white-space: nowrap;
}
.tagline .stars { color: var(--gold); font-size: 10px; font-weight: 600; letter-spacing: -1px; }
.headcount { display: flex; align-items: baseline; gap: 2px; }
.headcount .n { font-size: 26px; font-weight: 700; }
.headcount .unit { font-size: 10px; color: rgba(255,255,255,.7); }

/* --- 状態タブ（ヘッダーの外・本文背景の上に置く。iOS 版 StatusTabBar）--- */
.statustabs {
  position: relative; display: flex; gap: 4px;
  margin: 8px 16px 0; padding: 4px;
  background: var(--bg-elev); border-radius: 999px;
  flex: 0 0 auto;
}
.statustabs .indicator {
  position: absolute; top: 4px; bottom: 4px; left: 4px;
  width: calc((100% - 16px) / 3);
  background: var(--tab-fill); border-radius: 999px;
  transition: transform .3s cubic-bezier(.2,.8,.2,1);
  pointer-events: none;
}
.statustabs button {
  position: relative; flex: 1 1 0; min-width: 0;
  display: flex; align-items: center; justify-content: center; gap: 5px;
  padding: 8px 0; border-radius: 999px;
  color: var(--fg-muted); font-size: 15px; font-weight: 500;
}
.statustabs button.on { color: var(--navy-light); font-weight: 600; }
.statustabs button > span:not(.count) { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.statustabs .count {
  font-size: 11px; font-weight: 700; padding: 1px 6px; border-radius: 999px;
  background: color-mix(in srgb, var(--fg-muted) 15%, transparent); color: var(--fg-muted);
}
.statustabs button.on .count { background: rgba(33,84,179,.18); color: var(--navy-light); }

/* --- スクロール領域 ---------------------------------------- */
.scroll {
  flex: 1 1 auto; overflow-y: auto; -webkit-overflow-scrolling: touch;
  overscroll-behavior-y: contain;
}

/* --- お店カードのグリッド ----------------------------------- */
.grid {
  /* minmax(0,1fr)＝長い店名（折り返し禁止）で列が広がって横スクロールしないようにする */
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--gap); padding: var(--gap);
  padding-bottom: calc(var(--bottom-h) + var(--safe-bottom) + 90px);
}
/* カード：写真は高さ110固定・角丸10、店名は写真の下に中央揃え（iOS 版 RestaurantCardView）*/
.card { display: block; width: 100%; background: none; }
.card:active { transform: scale(.97); transition: transform .12s; }
.card .thumb {
  position: relative; width: 100%; height: 110px; background: var(--placeholder);
  display: block; overflow: hidden; border-radius: 10px;
}
/* object-position は既定（中央）のまま。iOS の .scaledToFill() を .overlay{} で中央に置く指定と同じ。
   top にすると縦長の写真で上端だけが見え、iOS と写り方がずれる。 */
.card .thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.card .thumb .ph { width: 100%; height: 100%; display: grid; place-items: center; color: var(--fg-faint); }
.card .thumb .ph svg { width: 30px; height: 30px; }
.card .name {
  font-size: var(--size-card-name); font-weight: 500; line-height: 1.3;
  margin-top: 4px; text-align: center;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.badge {
  position: absolute; bottom: 4px;
  background: rgba(20,56,127,.85); color: var(--on-navy);
  font-size: 10px; font-weight: 700; padding: 2px 5px; border-radius: 999px;
}
.badge.rating { right: 4px; }
.badge.visits { left: 4px; }

/* --- 下部バー（検索フィールド＋タグ・地図・並び替え）--------- */
.bottombar {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 3;
  background: var(--brand-header); color: var(--on-navy);
  padding-bottom: var(--safe-bottom);
}
.bottombar .row { display: flex; align-items: center; gap: 10px; padding: 6px 16px; }
.bottombar .iconbtn { width: 36px; height: 36px; color: rgba(255,255,255,.85); }
.bottombar .iconbtn.on { color: var(--sky); }
.bottombar .searchfield {
  flex: 1 1 auto; margin: 0; background: rgba(255,255,255,.15); color: #fff;
}
.bottombar .searchfield input { color: #fff; }
.bottombar .searchfield input::placeholder { color: rgba(255,255,255,.55); }
.bottombar .searchfield svg { color: rgba(255,255,255,.7); }
.fab {
  position: absolute; right: 16px; z-index: 4;
  bottom: calc(var(--bottom-h) + var(--safe-bottom) + 16px);
  width: 56px; height: 56px; border-radius: 50%;
  background: var(--accent); color: var(--on-navy);
  display: grid; place-items: center; box-shadow: 0 3px 6px rgba(0,0,0,.25);
}
.fab:active { transform: scale(.94); }

/* --- 選択中タグのチップ列 ----------------------------------- */
.chipbar {
  display: flex; gap: 8px; align-items: center; overflow-x: auto;
  padding: 6px 12px; background: var(--bg-grouped); scrollbar-width: none;
}
.chipbar:empty { display: none; }
.chipbar::-webkit-scrollbar { display: none; }
.chip {
  display: inline-flex; align-items: center; gap: 4px; flex: 0 0 auto;
  background: var(--chip); color: var(--chip-fg);
  font-size: var(--size-tag); padding: 4px 10px; border-radius: 999px;
}
.chip.on { background: var(--navy); color: var(--on-navy); }
.chip .x { opacity: .8; display: grid; place-items: center; }
.chipbar .clearall { color: var(--fg-muted); font-size: 12px; flex: 0 0 auto; padding: 4px; }

/* --- 状態の空表示・読み込み --------------------------------- */
.empty { padding: 48px 24px; text-align: center; color: var(--fg-muted); }
.empty h2 { color: var(--fg); font-size: 17px; margin: 0 0 8px; }
.empty ol { text-align: left; max-width: 320px; margin: 20px auto; padding-left: 20px; }
.empty li { margin-bottom: 8px; }
.spinner {
  width: 26px; height: 26px; border-radius: 50%; margin: 40px auto;
  border: 3px solid var(--separator); border-top-color: var(--navy-light);
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* --- ボタン ------------------------------------------------ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 11px 18px; border-radius: 10px; font-size: 15px; font-weight: 600;
  background: var(--field); color: var(--fg);
}
.btn.primary { background: var(--brand-header); color: var(--on-navy); }
.btn.danger { color: var(--danger); }
.btn:active { opacity: .75; }
.btn.block { width: 100%; }

/* --- 詳細画面（iOS 版 RestaurantDetailView に合わせる）------- */
.carousel { position: relative; background: var(--placeholder); }
.carousel .pages {
  display: flex; overflow-x: auto; scroll-snap-type: x mandatory; scrollbar-width: none;
  height: 300px;
}
.carousel .pages::-webkit-scrollbar { display: none; }
.carousel .pages > div {
  flex: 0 0 100%; scroll-snap-align: center; position: relative; overflow: hidden;
}
/* 画像は入れ物いっぱいに絶対配置する。
   grid + place-items:center の中で height:100% に頼ると、**iOS Safari では 100% が解決されず**
   画像が本来の高さになって枠からはみ出し、縦長の写真で上端だけが見える状態になる
   （実データの縦長3枚で発生。Chrome では解決されるため PC では再現しない）。
   inset:0 なら、どのブラウザでも寸法が確定する。 */
.carousel img {
  position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block;
}
.carousel .capture {
  position: absolute; right: 8px; bottom: 8px;
  background: rgba(0,0,0,.35); color: rgba(255,255,255,.9);
  font-size: 11px; padding: 3px 8px; border-radius: 999px;
}
.carousel .noimage {
  height: 300px; display: grid; place-items: center; gap: 8px;
  color: #8e8e93; background: var(--placeholder);
}
.carousel .noimage svg { width: 48px; height: 48px; }
.thumbstrip {
  display: flex; gap: 4px; overflow-x: auto; padding: 8px 12px;
  background: var(--bg); scrollbar-width: none;
}
.thumbstrip::-webkit-scrollbar { display: none; }
.thumbstrip button {
  flex: 0 0 auto; width: 64px; height: 64px; border-radius: 6px; overflow: hidden;
  border: 4px solid transparent;
}
.thumbstrip button.on { border-color: var(--accent); }
.thumbstrip img { width: 100%; height: 100%; object-fit: cover; display: block; }

.titleband {
  background: var(--brand-header); color: var(--on-navy);
  padding: 16px; display: flex; flex-direction: column; gap: 4px;
}
.titleband .name { font-size: 22px; font-weight: 700; }
.titleband .meta { display: flex; align-items: center; gap: 12px; }
.titleband .status { display: flex; align-items: center; gap: 5px; font-size: 15px; color: rgba(255,255,255,.8); }
.visitlink { display: flex; align-items: center; gap: 4px; color: #fff; font-size: 15px; margin-left: auto; }

/* 詳細の本文：SwiftUI の .padding()＝16、セクション間 16 */
.detail-body { padding: 16px; display: flex; flex-direction: column; gap: 16px; }
.sec-title { font-size: 17px; font-weight: 600; margin: 0 0 8px; }
.divider { height: 1px; background: var(--separator); }
.inforows { display: flex; flex-direction: column; gap: 12px; }
.inforow { display: flex; align-items: flex-start; gap: 10px; font-size: var(--size-basic); }
.inforow .ic { width: 24px; flex: 0 0 auto; display: grid; place-items: center; }
.inforow .ic svg { width: 19px; height: 19px; }
.inforow a { color: #0a84ff; text-decoration: none; word-break: break-all; }
.memo {
  white-space: pre-wrap; font-size: var(--size-basic);
  background: var(--bg-elev); border-radius: 10px; padding: 10px;
}

/* 設定など「セクション」を使う画面用（詳細画面では使わない）*/
.section { padding: 14px var(--gap); border-bottom: 1px solid var(--separator); }
.section h3 { margin: 0 0 10px; font-size: 17px; font-weight: 600; }
.rows { display: flex; flex-direction: column; gap: 10px; font-size: var(--size-basic); }

/* --- 星評価 ------------------------------------------------ */
.stars { display: inline-flex; gap: 2px; align-items: center; }
.stars svg { width: 1em; height: 1em; display: block; }
.stars .track { color: var(--separator); }
.ratingrow { display: flex; align-items: center; gap: 8px; font-size: var(--size-basic); }
.ratingrow .k { flex: 0 0 auto; white-space: nowrap; }
.ratingrow .sp { flex: 1 1 auto; min-width: 8px; }
.ratingrow .n { color: var(--fg-muted); font-size: 12px; width: 36px; text-align: right; flex: 0 0 auto; }
.ratingrow.total .k { font-weight: 600; }
.ratingrow.total .n { font-size: 15px; }

/* --- シート（モーダル）------------------------------------- */
#sheets { position: fixed; inset: 0; pointer-events: none; z-index: 20; }
.sheet-scrim {
  position: absolute; inset: 0; background: var(--scrim); pointer-events: auto;
  animation: fade .2s;
}
@keyframes fade { from { opacity: 0 } to { opacity: 1 } }
.sheet {
  position: absolute; left: 0; right: 0; bottom: 0; max-height: 92%;
  display: flex; flex-direction: column; pointer-events: auto;
  background: var(--bg); border-radius: 16px 16px 0 0; overflow: hidden;
  box-shadow: 0 -6px 24px rgba(0,0,0,.35);
  animation: sheet-up .28s cubic-bezier(.32,.72,0,1);
  padding-bottom: var(--safe-bottom);
}
.sheet.full { top: 0; border-radius: 0; padding-top: var(--safe-top); max-height: none; }
@keyframes sheet-up { from { transform: translateY(100%); } to { transform: translateY(0); } }
.sheet-head {
  display: flex; align-items: center; gap: 8px; padding: 12px var(--gap);
  border-bottom: 1px solid var(--separator);
}
.sheet-head .t { font-size: 16px; font-weight: 700; flex: 1 1 auto; }
.sheet-head .done { font-weight: 700; color: var(--navy-light); padding: 4px 6px; }
[data-theme="dark"] .sheet-head .done { color: var(--sky); }
.sheet-body { overflow-y: auto; padding: var(--gap); }

/* --- Form（iOS の inset grouped list。編集画面・設定で使う）--- */
.form { background: var(--bg-grouped); padding: 18px 0 calc(40px + var(--safe-bottom)); }
.form-section { margin-bottom: 22px; }
.form-header { font-size: 13px; color: var(--fg-muted); padding: 0 32px 6px; }
.form-footer { font-size: 13px; color: var(--fg-muted); padding: 6px 32px 0; line-height: 1.5; }
.form-card { background: var(--card); border-radius: 10px; margin: 0 16px; overflow: hidden; }
.form-row {
  display: flex; align-items: center; gap: 10px; width: 100%; text-align: left;
  padding: 11px 16px; min-height: 44px; font-size: 17px; color: var(--fg);
}
.form-row + .form-row { box-shadow: inset 0 .5px 0 var(--separator); }
.form-row input, .form-row textarea {
  flex: 1 1 auto; min-width: 0; background: none; border: 0; outline: none;
  font-size: 17px; color: var(--fg); font-family: inherit;
}
.form-row textarea { resize: vertical; line-height: 1.5; padding: 2px 0; }
.form-row input::placeholder, .form-row textarea::placeholder { color: var(--fg-faint); }
.form-row .ic { width: 24px; flex: 0 0 auto; display: grid; place-items: center; }
.form-row .ic svg { width: 19px; height: 19px; }
.form-row .clear { color: var(--fg-muted); display: grid; place-items: center; flex: 0 0 auto; }
.form-row .value { margin-left: auto; color: var(--accent); }
.form-action { color: var(--accent); }
.form-action svg { width: 19px; height: 19px; }
.form-warn { color: #ff9f0a; font-size: 12px; display: flex; align-items: center; gap: 6px; }

/* --- 設定 -------------------------------------------------- */
/* 設定も iOS 版は Form（inset grouped list）なので同じ寸法にそろえる */
.settings-group { margin: 0 16px 22px; background: var(--card); border-radius: 10px; overflow: hidden; }
.settings-title {
  display: flex; align-items: center; gap: 6px;
  padding: 0 32px 6px; font-size: 13px; font-weight: 400; color: var(--fg-muted);
}
.settings-title .info { width: 22px; height: 22px; display: grid; place-items: center; color: var(--accent); }
.setrow {
  display: flex; align-items: center; gap: 10px; width: 100%; text-align: left;
  padding: 11px 16px; min-height: 44px; font-size: 17px; color: var(--fg);
}
.setrow + .setrow { box-shadow: inset 0 .5px 0 var(--separator); }
.setrow .v { margin-left: auto; color: var(--fg-muted); font-size: 17px; display: flex; align-items: center; gap: 4px; }
.seg { display: flex; background: var(--placeholder); border-radius: 9px; padding: 2px; width: 100%; }
.seg button {
  flex: 1 1 0; min-width: 0; padding: 6px 8px; border-radius: 7px; font-size: 14px;
  color: var(--fg); white-space: nowrap; display: flex; align-items: center;
  justify-content: center; gap: 4px; overflow: hidden;
}
.seg button.on { background: var(--bg-elev); color: var(--fg); font-weight: 600; box-shadow: 0 1px 3px rgba(0,0,0,.18); }

/* --- 検索フィールド ---------------------------------------- */
.searchfield {
  display: flex; align-items: center; gap: 8px; background: var(--field);
  border-radius: 10px; padding: 9px 12px; margin-bottom: 10px;
}
.searchfield input { flex: 1 1 auto; background: none; border: 0; outline: none; font-size: 15px; }
.searchfield input::placeholder { color: var(--fg-faint); }

/* --- トースト ---------------------------------------------- */
.toast {
  position: fixed; left: 50%; bottom: calc(var(--safe-bottom) + 88px); transform: translateX(-50%);
  background: var(--bg-elev); color: var(--fg); font-size: 14px;
  padding: 10px 16px; border-radius: 999px; box-shadow: var(--shadow);
  z-index: 60; max-width: 88vw; text-align: center;
}
.toast[hidden] { display: none; }

/* --- 警告バナー -------------------------------------------- */
.banner {
  margin: var(--gap); padding: 12px; border-radius: var(--radius);
  background: color-mix(in srgb, var(--warn) 16%, var(--bg-elev));
  border: 1px solid color-mix(in srgb, var(--warn) 40%, transparent);
  font-size: 13px;
}
.banner b { color: var(--warn); }

/* --- 進捗 -------------------------------------------------- */
.progress { height: 6px; background: var(--field); border-radius: 3px; overflow: hidden; margin-top: 10px; }
.progress > div { height: 100%; background: var(--navy-light); width: 0; transition: width .15s linear; }

/* --- 幅の広い画面（PC）-------------------------------------
   スマホの縦画面を基準に作ってあるので、PC では「中央に寄せて広がりすぎない」ようにする。
   ------------------------------------------------------------ */
@media (min-width: 700px) {
  .navbar-row, .statustabs, .bottombar .row { max-width: 900px; margin-left: auto; margin-right: auto; }
  .statustabs { margin-bottom: 10px; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); max-width: 900px; margin: 0 auto; }
  .chipbar { max-width: 900px; margin: 0 auto; }
  .sheet { left: 50%; transform: translateX(-50%); width: min(620px, 100%); }
  .sheet.full { border-radius: 16px 16px 0 0; top: 40px; }

  /* 詳細・編集・設定は読み物なので1カラムのまま中央に置く */
  .carousel, .thumbstrip, .titleband, .section,
  .settings-group, .settings-title, .banner {
    max-width: 760px; margin-left: auto; margin-right: auto;
  }
  .carousel .pages { aspect-ratio: 3 / 2; }
  .empty { max-width: 620px; margin: 0 auto; }
}
