/*
 * TomarZo base.css（全画面共通の土台）
 *   デザイン仕様: docs/UI_SPEC.md ／ クラスの使い方: docs/UI_COMPONENTS.md
 *   ここには「どの画面でも使う部品」だけを書く。画面専用の見た目は
 *   calendar.css / reservation.css / pages.css / account.css に、接頭辞付きのクラスで書く。
 *
 *   目次
 *    1. デザイントークン（CSS 変数）    11. 選択チップ・フィルターチップ
 *    2. リセット・基本の文字            12. ステッパー・スイッチ
 *    3. ユーティリティ                  13. ステータスバッジ
 *    4. レイアウト（ナビ・ヘッダー）    14. フラッシュメッセージ
 *    5. 見出し・セクション              15. 空状態
 *    6. ボタン                          16. リスト
 *    7. カード                          17. 開閉（details）
 *    8. フォーム                        18. 施設色
 *    9. 予約カード（partial）           19. ログイン前の画面（.auth-*）
 *   10. 施設フィルター・エラー一覧      20. 動きを減らす設定
 */

/* ================= 1. デザイントークン ================= */
:root {
  color-scheme: light;

  /* 基本色（UI_SPEC 1-1） */
  --c-bg: #fdfaf1;
  --c-surface: #ffffff;
  --c-surface-2: #fbefdc;
  --c-sand: #f7dfbc;
  --c-muted: #efe8df;
  --c-text: #3d2418;
  --c-text-sub: #76584a;
  --c-text-faint: #8c7061;
  --c-done-text: #6b5a4e; /* チェックアウト済・使用停止中のバッジ文字 */
  --c-brown: #5a2815;
  --c-brown-hover: #43200f;
  --c-orange: #f5811f;       /* 装飾専用。白文字を載せない */
  --c-orange-light: #f9a534; /* 装飾専用 */
  --c-accent: #b8500d;
  --c-accent-hover: #9c430a;
  --c-green: #78ac60;
  --c-green-text: #3b6e28;
  --c-green-soft: #e8f3e1;
  --c-blue: #8cbbd9;
  --c-blue-text: #2b5f86;
  --c-blue-soft: #e6f1f9;
  --c-warn-text: #8a5300;
  --c-warn-soft: #fdf1d8;
  --c-danger: #b3261e;
  --c-danger-hover: #8f1d17;
  --c-danger-soft: #fbe8e4;
  --c-line: #e9dcc8;
  --c-line-strong: #a08470;
  --c-focus: #b8500d;
  --c-disabled-bg: #ece3d6;
  --c-disabled-text: #8a7666;

  /* 施設色（UI_SPEC 2章）: 帯の地 / 帯の文字 / 薄い地 / 薄い地の文字 */
  --fc-1-bg: #f9b95c; --fc-1-text: #5a2815; --fc-1-soft: #fdebd0; --fc-1-soft-text: #5a2815;
  --fc-2-bg: #a9d18e; --fc-2-text: #244a14; --fc-2-soft: #e9f3e1; --fc-2-soft-text: #244a14;
  --fc-3-bg: #a9cde6; --fc-3-text: #1c4466; --fc-3-soft: #e7f1f8; --fc-3-soft-text: #1c4466;
  --fc-4-bg: #f3b1b6; --fc-4-text: #6e1f2b; --fc-4-soft: #fce8e9; --fc-4-soft-text: #6e1f2b;
  --fc-5-bg: #c8b7e6; --fc-5-text: #3d2768; --fc-5-soft: #efe9f8; --fc-5-soft-text: #3d2768;
  --fc-6-bg: #90d0c3; --fc-6-text: #114a41; --fc-6-soft: #e2f4f0; --fc-6-soft-text: #114a41;
  --fc-7-bg: #f0d86a; --fc-7-text: #4a3a00; --fc-7-soft: #fbf4d4; --fc-7-soft-text: #4a3a00;
  --fc-8-bg: #8c5a3c; --fc-8-text: #ffffff; --fc-8-soft: #efe2d8; --fc-8-soft-text: #4a2a18;

  /* 文字（UI_SPEC 3章） */
  /* 書体は Noto Sans JP に統一（assets/css/fonts.css で自前配信）。
     読み込めない環境のために、端末の標準書体を後ろに並べておく */
  --font-base: "Noto Sans JP", "Hiragino Sans", "Hiragino Kaku Gothic ProN", "BIZ UDPGothic", "Meiryo", sans-serif;
  --font-round: "Noto Sans JP", "Hiragino Sans", "Hiragino Kaku Gothic ProN", "BIZ UDPGothic", "Meiryo", sans-serif;
  --fs-2xl: 2rem;
  --fs-xl: 1.5rem;
  --fs-lg: 1.25rem;
  --fs-md: 1.125rem;
  --fs-base: 1rem;
  --fs-sm: 0.875rem;
  --fs-xs: 0.75rem; /* カレンダーの帯・曜日・下部ナビのラベルだけ */

  /* 余白・角丸・影（UI_SPEC 4章） */
  --sp-1: 4px; --sp-2: 8px; --sp-3: 12px; --sp-4: 16px; --sp-5: 20px; --sp-6: 24px; --sp-8: 32px; --sp-12: 48px;
  --r-xs: 6px; --r-sm: 8px; --r-md: 12px; --r-lg: 16px; --r-xl: 20px; --r-full: 9999px;
  --sh-sm: 0 1px 2px rgba(90, 40, 21, .06);
  --sh-md: 0 4px 12px rgba(90, 40, 21, .10);
  --sh-lg: 0 12px 32px rgba(90, 40, 21, .18);
  --sh-nav: 0 -2px 10px rgba(90, 40, 21, .06);

  /* レイアウト */
  --header-h: 56px;
  --bnav-h: 64px;
  --snav-w: 240px;
  --content-max: 1120px;
  --form-max: 560px;
  --dur: 150ms;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
}

/* ================= 2. リセット・基本の文字 ================= */
*, *::before, *::after { box-sizing: border-box; }

html {
  font-size: 100%; /* OS の文字サイズ設定に合わせて大きくなる */
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  background: var(--c-bg);
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--c-bg);
  color: var(--c-text);
  font-family: var(--font-base);
  font-size: var(--fs-base);
  line-height: 1.7;
  overflow-wrap: anywhere;
  -webkit-tap-highlight-color: transparent;
}

h1, h2, h3, h4, p, ul, ol, dl, dd, figure { margin: 0; }
ul[class], ol[class] { padding: 0; list-style: none; }

/* 見出しは丸ゴシック。W4 しかない書体を無理に太らせない（font-synthesis: none） */
h1, h2, h3, h4 {
  font-family: var(--font-round);
  font-weight: 700;
  font-synthesis: none;
  color: var(--c-brown);
  line-height: 1.4;
}

img, svg { vertical-align: middle; }
img { max-width: 100%; height: auto; }

a { color: var(--c-accent); text-underline-offset: 2px; }
a:hover { color: var(--c-accent-hover); }

button, input, select, textarea { font: inherit; color: inherit; }
fieldset { min-width: 0; margin: 0; padding: 0; border: 0; }
legend { padding: 0; }
button { cursor: pointer; }

/* アイコン（app/lib/icons.php の icon()）。既定 24px */
.icon { width: 24px; height: 24px; flex: none; }

/* フォーカス表示。outline は消さない（UI_SPEC 4-5） */
:focus-visible {
  outline: 3px solid var(--c-focus);
  outline-offset: 2px;
}

/* ページ内リンク（#guest_name など）で移動したとき、固定ヘッダーの下に隠れないように */
[id] { scroll-margin-top: calc(var(--header-h) + var(--safe-top) + var(--sp-4)); }

strong { font-weight: 700; }
hr, .divider { border: 0; border-top: 1px solid var(--c-line); margin: var(--sp-6) 0; }

/* ================= 3. ユーティリティ（最小限） ================= */
.stack { display: flex; flex-direction: column; gap: var(--sp-4); }
.stack-sm { display: flex; flex-direction: column; gap: var(--sp-2); }
.stack-lg { display: flex; flex-direction: column; gap: var(--sp-6); }
.row { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-2); }
.row-between { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--sp-2); }
.narrow { max-width: var(--form-max); }
.text-sub { color: var(--c-text-sub); }
.text-sm { font-size: var(--fs-sm); }
.text-danger { color: var(--c-danger); }
.num { font-variant-numeric: tabular-nums; }

/* 画面には見せず、読み上げソフトには読ませる */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* JS が動く環境（app.js が <html> に .js を付ける）でだけ隠す／出す */
.js .js-hide { display: none; }
html:not(.js) .js-only { display: none; }
html.js .no-js-only { display: none; }  /* JS があるときは代わりのボタンを出すので隠す */

/* ================= 4. レイアウト ================= */
.skip-link {
  position: absolute;
  top: -100px;
  left: var(--sp-2);
  z-index: 200;
  padding: var(--sp-3) var(--sp-4);
  background: var(--c-brown);
  color: #fff;
  border-radius: var(--r-md);
  font-weight: 700;
  text-decoration: none;
}
.skip-link:focus { top: calc(var(--sp-2) + var(--safe-top)); color: #fff; }

/* --- ページヘッダー（スマホ: 上に固定） --- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  min-height: calc(var(--header-h) + var(--safe-top));
  padding: var(--safe-top) max(var(--sp-4), var(--safe-right)) 0 max(var(--sp-4), var(--safe-left));
  background: var(--c-bg);
  border-bottom: 1px solid var(--c-line);
}
.topbar-brand { display: inline-flex; align-items: center; min-width: 44px; min-height: 44px; flex: none; }
.topbar-brand img { width: 28px; height: 28px; }
.topbar-back {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-1);
  min-height: 44px;
  margin-left: calc(var(--sp-2) * -1);
  padding: 0 var(--sp-3) 0 var(--sp-1);
  border-radius: var(--r-md);
  color: var(--c-brown);
  font-family: var(--font-round);
  font-weight: 700;
  font-synthesis: none;
  text-decoration: none;
  white-space: nowrap;
  flex: none;
  transition: background-color var(--dur);
}
.topbar-back:hover { background: var(--c-surface-2); color: var(--c-brown); }
.topbar-title {
  flex: 1;
  min-width: 0;
  font-size: var(--fs-lg);
  line-height: 1.4;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.topbar-action { flex: none; margin-left: auto; display: flex; align-items: center; gap: var(--sp-2); }

/* --- 本文 --- */
.main {
  display: block;
  padding: var(--sp-4) max(var(--sp-4), var(--safe-right)) calc(var(--bnav-h) + var(--safe-bottom) + var(--sp-6)) max(var(--sp-4), var(--safe-left));
}
.flash-area { display: flex; flex-direction: column; gap: var(--sp-2); margin-bottom: var(--sp-4); }

/* --- 下部ナビ（〜899px） --- */
.bottomnav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  min-height: calc(var(--bnav-h) + var(--safe-bottom));
  padding: 0 var(--safe-right) var(--safe-bottom) var(--safe-left);
  background: var(--c-surface);
  border-top: 1px solid var(--c-line);
  box-shadow: var(--sh-nav);
}
.bottomnav-link {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-width: 0;
  min-height: var(--bnav-h);
  color: var(--c-text-sub);
  text-decoration: none;
}
.bottomnav-link:hover { color: var(--c-brown); }
.bottomnav-link:focus-visible { outline-offset: -3px; border-radius: var(--r-md); }
.bottomnav-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 56px;
  height: 32px;
  border-radius: var(--r-full);
  transition: background-color var(--dur);
}
.bottomnav-label {
  font-family: var(--font-round);
  font-size: var(--fs-xs);
  font-weight: 700;
  font-synthesis: none;
  line-height: 1.2;
  /* 文字を大きくする設定（200%）でも隣と重ならないよう、折り返しを許す */
  white-space: normal;
  overflow-wrap: anywhere;
  text-align: center;
}
.bottomnav-link[aria-current="page"] { color: var(--c-brown); }
.bottomnav-link[aria-current="page"] .bottomnav-icon { background: var(--c-sand); }

/* 中央の「予約追加」: 丸いボタンを少し上に飛び出させる */
.bottomnav-link.is-primary { color: var(--c-accent); justify-content: flex-end; padding-bottom: 6px; }
.bottomnav-link.is-primary .bottomnav-icon {
  width: 56px;
  height: 56px;
  margin-top: -20px;
  background: var(--c-accent);
  color: #fff;
  border: 4px solid var(--c-surface);
  box-shadow: var(--sh-md);
}
.bottomnav-link.is-primary .bottomnav-icon .icon { width: 28px; height: 28px; }
.bottomnav-link.is-primary:hover .bottomnav-icon,
.bottomnav-link.is-primary[aria-current="page"] .bottomnav-icon { background: var(--c-accent-hover); }
.bottomnav-link.is-primary[aria-current="page"] { color: var(--c-accent-hover); }

/* --- サイドナビ（900px〜。スマホでは出さない） --- */
.sidenav { display: none; }

/* タブレット（600〜899px）: 本文を中央寄せで最大 720px */
@media (min-width: 600px) {
  .topbar, .main {
    padding-left: max(var(--sp-6), calc((100% - 720px) / 2));
    padding-right: max(var(--sp-6), calc((100% - 720px) / 2));
  }
  .app-main.is-wide .topbar, .app-main.is-wide .main { padding-left: var(--sp-4); padding-right: var(--sp-4); }
}

/* PC（900px〜）: 左サイドナビ、下部ナビは出さない */
@media (min-width: 900px) {
  .bottomnav { display: none; }

  .sidenav {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 20;
    display: flex;
    flex-direction: column;
    width: var(--snav-w);
    padding: var(--sp-5) var(--sp-4);
    padding-left: max(var(--sp-4), var(--safe-left));
    overflow-y: auto;
    background: var(--c-surface);
    border-right: 1px solid var(--c-line);
  }
  .sidenav-brand {
    display: flex;
    align-items: center;
    gap: var(--sp-3);
    padding: var(--sp-1);
    border-radius: var(--r-md);
    color: var(--c-brown);
    text-decoration: none;
  }
  .sidenav-brand:hover { color: var(--c-brown); background: var(--c-bg); }
  .sidenav-brand img { width: 40px; height: 40px; flex: none; }
  .sidenav-brand-text { display: flex; flex-direction: column; line-height: 1.3; }
  .brand-name { font-family: var(--font-round); font-weight: 700; font-synthesis: none; font-size: var(--fs-lg); }
  .brand-zo { color: var(--c-accent); }
  .brand-sub { font-size: var(--fs-sm); color: var(--c-text-sub); }
  .sidenav-add { margin: var(--sp-4) 0; }
  .sidenav-list { display: flex; flex-direction: column; gap: var(--sp-1); }
  .sidenav-link {
    display: flex;
    align-items: center;
    gap: var(--sp-3);
    min-height: 48px;
    padding: 0 var(--sp-3);
    border-radius: var(--r-md);
    color: var(--c-text-sub);
    font-family: var(--font-round);
    font-weight: 700;
    font-synthesis: none;
    text-decoration: none;
    transition: background-color var(--dur), color var(--dur);
  }
  .sidenav-link:hover { background: var(--c-bg); color: var(--c-brown); }
  .sidenav-link[aria-current="page"] { background: var(--c-sand); color: var(--c-brown); }
  .sidenav-foot {
    margin-top: auto;
    padding-top: var(--sp-6);
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: var(--sp-1);
  }
  .sidenav-user { font-size: var(--fs-sm); color: var(--c-text-sub); padding: 0 var(--sp-3); }

  .app-main { margin-left: var(--snav-w); }
  .topbar, .main { max-width: calc(var(--content-max) + var(--sp-8) * 2); }
  .topbar {
    position: static;
    min-height: 0;
    padding: var(--sp-8) var(--sp-8) 0;
    border-bottom: 0;
    background: transparent;
  }
  .topbar-brand { display: none; }
  .topbar-title { font-size: var(--fs-xl); white-space: normal; }
  .main { padding: var(--sp-6) var(--sp-8) var(--sp-12); }

  /* カレンダーなど広く使いたい画面（layout の $wide = true） */
  .app-main.is-wide .topbar, .app-main.is-wide .main { max-width: none; padding-left: var(--sp-8); padding-right: var(--sp-8); }
}

/* ================= 5. 見出し・セクション ================= */
.page-lead { margin: 0 0 var(--sp-4); color: var(--c-text-sub); }
.section + .section { margin-top: var(--sp-8); }
.section-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-2);
  margin-bottom: var(--sp-3);
}
.section-title { font-size: var(--fs-md); line-height: 1.5; }
.section-count {
  margin-left: var(--sp-1);
  font-family: var(--font-round);
  font-weight: 700;
  font-synthesis: none;
  font-size: var(--fs-base);
  color: var(--c-text-sub);
  font-variant-numeric: tabular-nums;
}
.subhead {
  margin: var(--sp-4) 0 var(--sp-2);
  font-family: var(--font-round);
  font-size: var(--fs-sm);
  font-weight: 700;
  font-synthesis: none;
  color: var(--c-text-sub);
}

/* ================= 6. ボタン ================= */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  min-height: 48px;
  padding: 6px var(--sp-5);
  border: 1.5px solid transparent;
  border-radius: var(--r-md);
  background: var(--c-surface);
  color: var(--c-brown);
  font-family: var(--font-round);
  font-size: var(--fs-base);
  font-weight: 700;
  font-synthesis: none;
  line-height: 1.3;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  user-select: none;
  transition: background-color var(--dur), border-color var(--dur), color var(--dur);
}
.btn .icon { width: 20px; height: 20px; }
.btn:active { transform: translateY(1px); }

.btn-primary { background: var(--c-accent); color: #fff; }
.btn-primary:hover { background: var(--c-accent-hover); color: #fff; }

.btn-brown { background: var(--c-brown); color: #fff; }
.btn-brown:hover { background: var(--c-brown-hover); color: #fff; }

.btn-secondary { background: var(--c-surface); border-color: var(--c-line-strong); color: var(--c-brown); }
.btn-secondary:hover { background: var(--c-surface-2); color: var(--c-brown); }

.btn-danger { background: var(--c-danger); color: #fff; }
.btn-danger:hover { background: var(--c-danger-hover); color: #fff; }

.btn-danger-outline { background: var(--c-surface); border-color: var(--c-danger); color: var(--c-danger); }
.btn-danger-outline:hover { background: var(--c-danger-soft); color: var(--c-danger); }

/* 控えめな操作（背景なし）。ホバー時は accent-hover にしてコントラストを保つ */
.btn-text { background: transparent; color: var(--c-accent); padding-left: var(--sp-3); padding-right: var(--sp-3); }
.btn-text:hover { background: var(--c-surface-2); color: var(--c-accent-hover); text-decoration: underline; }
.btn-text-danger { color: var(--c-danger); }
.btn-text-danger:hover { background: var(--c-danger-soft); color: var(--c-danger); }

.btn-block { display: flex; width: 100%; }
.btn-lg { min-height: 56px; }
.btn-sm { min-height: 44px; padding-left: 14px; padding-right: 14px; }

.btn:disabled,
.btn[aria-disabled="true"] {
  background: var(--c-disabled-bg);
  border-color: transparent;
  color: var(--c-disabled-text);
  cursor: not-allowed;
  transform: none;
  text-decoration: none;
}

/* ボタンを縦に並べる（スマホ）→ PC は横に並べる */
.btn-group { display: flex; flex-direction: column; gap: var(--sp-3); }
@media (min-width: 900px) {
  .btn-group { flex-direction: row; flex-wrap: wrap; align-items: center; }
}

/* ================= 7. カード ================= */
.card {
  display: block;
  padding: var(--sp-4);
  background: var(--c-surface);
  border: 1px solid var(--c-line);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-sm);
}
@media (min-width: 900px) { .card { padding: var(--sp-6); } }

/* カード全体が押せるとき: 右端に「›」 */
a.card {
  position: relative;
  padding-right: calc(var(--sp-4) + 20px);
  color: var(--c-text);
  text-decoration: none;
  transition: box-shadow var(--dur), border-color var(--dur);
}
a.card:hover { color: var(--c-text); border-color: var(--c-line-strong); box-shadow: var(--sh-md); }
a.card::after,
a.list-item::after {
  content: "";
  position: absolute;
  top: 50%;
  right: var(--sp-4);
  width: 9px;
  height: 9px;
  margin-top: -5px;
  border-top: 2px solid var(--c-text-sub);
  border-right: 2px solid var(--c-text-sub);
  transform: rotate(45deg);
}
.card-title { font-size: var(--fs-md); line-height: 1.5; }

/* ================= 8. フォーム ================= */
.field { margin: 0 0 var(--sp-5); }
.field-label {
  display: block;
  margin-bottom: var(--sp-2);
  font-weight: 600;
  color: var(--c-text);
}
.field-optional { margin-left: var(--sp-1); font-size: var(--fs-sm); font-weight: 400; color: var(--c-text-sub); }
.field-help { margin: calc(var(--sp-1) * -1) 0 var(--sp-2); font-size: var(--fs-sm); color: var(--c-text-sub); }
.field-error {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  margin: var(--sp-2) 0 0;
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--c-danger);
}
/* 先頭の「!」の丸（色だけに頼らない） */
.field-error::before {
  content: "!";
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  width: 16px;
  height: 16px;
  margin-top: 0.2em;
  border-radius: var(--r-full);
  background: var(--c-danger);
  color: #fff;
  font-size: 12px;
  line-height: 1;
}
/* 日付を2つ並べるなど（スマホでも2列） */
/* minmax(0, 1fr): 日付入力欄の最小幅で列がはみ出さないように */
.field-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: var(--sp-2); }
.field-row .input { min-width: 0; }

.input, .select, .textarea {
  display: block;
  width: 100%;
  min-height: 52px;
  padding: 0 14px;
  background: var(--c-surface);
  border: 1.5px solid var(--c-line-strong);
  border-radius: var(--r-md);
  color: var(--c-text);
  font-size: max(16px, var(--fs-base)); /* 16px 未満だと iPhone で画面が拡大される */
  line-height: 1.5;
  transition: border-color var(--dur), background-color var(--dur);
}
.textarea { min-height: 120px; padding: 12px 14px; line-height: 1.6; resize: vertical; }
.input::placeholder, .textarea::placeholder { color: var(--c-text-faint); opacity: 1; }
.input:focus, .select:focus, .textarea:focus { border-color: var(--c-accent); }
.input:disabled, .select:disabled, .textarea:disabled { background: var(--c-disabled-bg); color: var(--c-disabled-text); }
input[type="date"].input, input[type="time"].input { -webkit-appearance: none; appearance: none; }
input[type="date"].input::-webkit-date-and-time-value,
input[type="time"].input::-webkit-date-and-time-value { text-align: left; }

/* select: 右端の「⌄」は隣に置いた SVG（背景画像は使わない） */
.select-wrap { position: relative; }
.select { -webkit-appearance: none; appearance: none; padding-right: 44px; cursor: pointer; }
.select-wrap > .icon {
  position: absolute;
  top: 50%;
  right: 14px;
  width: 20px;
  height: 20px;
  margin-top: -10px;
  color: var(--c-brown);
  pointer-events: none;
}

/* 入力欄の後ろに単位（名・円）を付ける */
.input-affix { display: flex; align-items: center; gap: var(--sp-2); }
.input-affix .input { flex: 1; min-width: 0; }
.input-suffix { flex: none; color: var(--c-text); }

/* チェックボックス・ラジオ（素の input） */
input[type="checkbox"], input[type="radio"] { accent-color: var(--c-accent); width: 22px; height: 22px; margin: 0; flex: none; }
.check-row { display: flex; align-items: center; gap: var(--sp-3); min-height: 48px; cursor: pointer; }

/* エラーのある項目（.field に .has-error） */
.has-error .input, .has-error .select, .has-error .textarea,
.input[aria-invalid="true"], .select[aria-invalid="true"], .textarea[aria-invalid="true"] {
  border: 2px solid var(--c-danger);
  background: var(--c-danger-soft);
}
.has-error .field-label { color: var(--c-danger); }

/* ================= 9. 予約カード（partials/reservation_card.php） ================= */
.rcard-list { display: flex; flex-direction: column; gap: var(--sp-3); }
.rcard { padding: 0; overflow: hidden; }
.rcard-link {
  display: block;
  padding: var(--sp-4);
  color: var(--c-text);
  text-decoration: none;
  transition: background-color var(--dur);
}
.rcard-link:hover { background: var(--c-bg); color: var(--c-text); }
.rcard-link:focus-visible { outline-offset: -3px; border-radius: var(--r-lg); }
.rcard-top { display: flex; align-items: flex-start; gap: var(--sp-2); }
.rcard-name { flex: 1; min-width: 0; font-size: var(--fs-md); font-weight: 600; line-height: 1.5; }
.rcard-chevron { color: var(--c-text-sub); margin-top: 2px; }
.rcard-badges { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.rcard-place, .rcard-meta {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  margin-top: 6px;
  font-size: var(--fs-sm);
  color: var(--c-text-sub);
  line-height: 1.5;
}
.rcard-meta { font-variant-numeric: tabular-nums; gap: var(--sp-1); }
.rcard-meta .icon { width: 16px; height: 16px; }
.rcard-action { padding: 0 var(--sp-4) var(--sp-4); }
.rcard.is-cancelled .rcard-name { color: var(--c-text-sub); } /* 取り消し線・opacity は使わない */
@media (min-width: 900px) {
  .rcard-link { padding: var(--sp-5); }
  .rcard-action { padding: 0 var(--sp-5) var(--sp-5); }
}

/* ================= 10. 施設フィルター・エラー一覧 ================= */
.facility-filter { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-2) var(--sp-3); margin-bottom: var(--sp-4); }
.facility-filter-label { font-weight: 600; }
.facility-filter .select-wrap { flex: 1 1 160px; max-width: 360px; }
.facility-filter .btn { flex: none; }

.form-errors { margin-bottom: var(--sp-5); }
/* 押せる部品ではなく、読み込み時に JS が移動先としてフォーカスするだけの箱。赤い箱自体が目立つので枠は出さない */
.form-errors:focus, .form-errors:focus-visible { outline: none; }
.form-errors-list { margin: var(--sp-2) 0 0; padding-left: 1.2em; font-size: var(--fs-sm); font-weight: 600; }
.form-errors-list a { color: var(--c-danger); }

/* ================= 11. 選択チップ・フィルターチップ ================= */
.chip-group { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: var(--sp-2); }
.chip { position: relative; display: block; margin: 0; }
.chip-input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.chip-body {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 56px;
  height: 100%;
  padding: var(--sp-2) 36px var(--sp-2) 14px;
  background: var(--c-surface);
  border: 1.5px solid var(--c-line-strong);
  border-radius: var(--r-md);
  cursor: pointer;
  line-height: 1.4;
  transition: background-color var(--dur), border-color var(--dur);
}
.chip-body:hover { background: var(--c-surface-2); }
.chip-title { display: flex; align-items: center; gap: var(--sp-2); font-weight: 600; }
.chip-sub { font-size: var(--fs-sm); color: var(--c-text-sub); }
.chip-sub.is-free { color: var(--c-green-text); }
.chip-sub.is-busy { color: var(--c-danger); }
.chip.is-busy .chip-body { background: var(--c-muted); }
/* 選択中: 枠を太く見せ（影で足してずれを防ぐ）、右上にチェックの丸 */
.chip-input:checked + .chip-body {
  background: var(--c-surface-2);
  border-color: var(--c-accent);
  box-shadow: inset 0 0 0 1px var(--c-accent);
  color: var(--c-brown);
}
.chip-input:checked + .chip-body::after {
  content: "✓";
  position: absolute;
  top: 8px;
  right: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border-radius: var(--r-full);
  background: var(--c-accent);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
}
.chip-input:focus-visible + .chip-body { outline: 3px solid var(--c-focus); outline-offset: 2px; }
.chip-input:disabled + .chip-body { background: var(--c-disabled-bg); color: var(--c-disabled-text); cursor: not-allowed; }

/* フィルターチップ（リンクの横並び。横スクロール） */
.filter-chips { display: flex; gap: var(--sp-2); overflow-x: auto; padding: 2px 2px var(--sp-1); margin: 0 -2px; }
.filter-chip {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  flex: none;
  min-height: 44px;
  padding: 0 var(--sp-4);
  background: var(--c-surface);
  border: 1px solid var(--c-line-strong);
  border-radius: var(--r-full);
  color: var(--c-text);
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
  transition: background-color var(--dur);
}
.filter-chip:hover { background: var(--c-surface-2); color: var(--c-brown); }
.filter-chip[aria-current="true"], .filter-chip.is-selected { background: var(--c-brown); border-color: var(--c-brown); color: #fff; }

/* ================= 12. ステッパー・スイッチ ================= */
.stepper { display: inline-flex; align-items: center; gap: var(--sp-2); }
.stepper-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  padding: 0;
  background: var(--c-surface);
  border: 1.5px solid var(--c-line-strong);
  border-radius: var(--r-full);
  color: var(--c-brown);
  transition: background-color var(--dur);
}
.stepper-btn:hover, .stepper-btn:active { background: var(--c-surface-2); }
.stepper-btn:disabled { background: var(--c-disabled-bg); border-color: var(--c-disabled-bg); color: var(--c-disabled-text); cursor: not-allowed; }
html:not(.js) .stepper-btn { display: none; } /* JS がないときは数字を直接入力 */
.stepper-input {
  width: 80px;
  min-height: 52px;
  padding: 0 var(--sp-2);
  text-align: center;
  font-family: var(--font-round);
  font-size: var(--fs-lg);
  font-weight: 700;
  font-synthesis: none;
  font-variant-numeric: tabular-nums;
  -moz-appearance: textfield;
  appearance: textfield;
}
.stepper-input::-webkit-inner-spin-button,
.stepper-input::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.stepper-unit { font-size: var(--fs-base); }

/* スイッチ（checkbox を大きなスイッチの見た目に。押せる範囲は行全体） */
.switch-row { display: flex; align-items: center; gap: var(--sp-4); min-height: 56px; cursor: pointer; }
.switch-text { flex: 1; min-width: 0; }
.switch-label { display: block; font-weight: 600; }
.switch-input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.switch-track {
  position: relative;
  flex: none;
  width: 52px;
  height: 32px;
  border-radius: var(--r-full);
  background: var(--c-line-strong);
  transition: background-color var(--dur);
}
.switch-track::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 26px;
  height: 26px;
  border-radius: var(--r-full);
  background: #fff;
  box-shadow: var(--sh-sm);
  transition: transform var(--dur);
}
.switch-input:checked + .switch-track { background: var(--c-green-text); }
.switch-input:checked + .switch-track::after { transform: translateX(20px); }
.switch-input:focus-visible + .switch-track { outline: 3px solid var(--c-focus); outline-offset: 2px; }

/* ================= 13. ステータスバッジ（色 + アイコン + 文字） ================= */
.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-1);
  min-height: 28px;
  padding: 2px 10px;
  border-radius: var(--r-full);
  background: var(--c-muted);
  color: var(--c-done-text);
  font-family: var(--font-round);
  font-size: var(--fs-sm);
  font-weight: 700;
  font-synthesis: none;
  line-height: 1.3;
  white-space: nowrap;
}
.badge .icon { width: 16px; height: 16px; }
/* 状態の値（reserved など）をそのままクラス名にできる */
.badge-reserved    { background: var(--c-sand);        color: var(--c-brown); }
.badge-checked_in  { background: var(--c-green-soft);  color: var(--c-green-text); }
.badge-checked_out { background: var(--c-muted);       color: var(--c-done-text); }
.badge-cancelled   { background: var(--c-danger-soft); color: var(--c-danger); }
.badge-unpaid      { background: var(--c-warn-soft);   color: var(--c-warn-text); }
.badge-paid        { background: var(--c-green-soft);  color: var(--c-green-text); }
.badge-active      { background: var(--c-green-soft);  color: var(--c-green-text); }
.badge-paused      { background: var(--c-muted);       color: var(--c-done-text); }

/* ================= 14. フラッシュメッセージ（自動では消さない） ================= */
.flash {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-3);
  padding: 14px var(--sp-4);
  border-radius: var(--r-lg);
  background: var(--c-blue-soft);
  color: var(--c-blue-text);
  font-size: var(--fs-base);
  line-height: 1.6;
}
.flash > .icon { margin-top: 1px; }
.flash-body { flex: 1; min-width: 0; }
.flash-success { background: var(--c-green-soft);  color: var(--c-green-text); }
.flash-error   { background: var(--c-danger-soft); color: var(--c-danger); }
.flash-warning { background: var(--c-warn-soft);   color: var(--c-warn-text); }
.flash-info    { background: var(--c-blue-soft);   color: var(--c-blue-text); }
.flash-close {
  display: none;
  align-items: center;
  justify-content: center;
  flex: none;
  width: 44px;
  height: 44px;
  margin: -10px -10px -10px 0;
  padding: 0;
  background: transparent;
  border: 0;
  border-radius: var(--r-md);
  color: inherit;
}
.flash-close .icon { width: 20px; height: 20px; }
.js .flash-close { display: inline-flex; }

/* ================= 15. 空状態 ================= */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-12) var(--sp-4);
  text-align: center;
}
.card.empty-state { padding: var(--sp-12) var(--sp-6); }
.empty-state-illust {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 96px;
  height: 96px;
  border-radius: var(--r-full);
  background: var(--c-surface-2);
  color: var(--c-line-strong);
}
.empty-state-illust .icon { width: 56px; height: 56px; }
.empty-state img { width: 96px; height: 96px; }
.empty-state-title { font-size: var(--fs-md); line-height: 1.5; }
.empty-state-text, .empty-state p { max-width: 32em; font-size: var(--fs-sm); color: var(--c-text-sub); }
.empty-state .btn { margin-top: var(--sp-2); }

/* セクションごとの短い空表示（1行） */
.empty-inline {
  padding: var(--sp-3) var(--sp-4);
  border: 1px dashed var(--c-line-strong);
  border-radius: var(--r-lg);
  color: var(--c-text-sub);
  font-size: var(--fs-sm);
}

/* ================= 16. リスト（設定・部屋の一覧など） ================= */
.list-heading {
  margin: var(--sp-6) var(--sp-1) var(--sp-2);
  font-family: var(--font-round);
  font-size: var(--fs-sm);
  font-weight: 700;
  font-synthesis: none;
  color: var(--c-text-sub);
}
.list {
  margin: 0;
  padding: 0;
  list-style: none;
  background: var(--c-surface);
  border: 1px solid var(--c-line);
  border-radius: var(--r-lg);
  overflow: hidden;
}
.list > li + li, .list > .list-item + .list-item { border-top: 1px solid var(--c-line); }
.list-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  min-height: 56px;
  padding: var(--sp-2) var(--sp-4);
  color: var(--c-text);
}
a.list-item { padding-right: calc(var(--sp-4) + 20px); text-decoration: none; transition: background-color var(--dur); }
a.list-item:hover { background: var(--c-bg); color: var(--c-text); }
a.list-item:focus-visible { outline-offset: -3px; }
.list-item > .icon { color: var(--c-text-sub); }
.list-item-main { flex: 1; min-width: 0; }
.list-item-sub { display: block; font-size: var(--fs-sm); color: var(--c-text-sub); }
.list-item-value { flex: none; color: var(--c-text-sub); }

/* ================= 17. 開閉（details / summary） ================= */
.disclosure-summary {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 52px;
  padding: var(--sp-2) var(--sp-4);
  background: var(--c-surface);
  border: 1.5px dashed var(--c-line-strong);
  border-radius: var(--r-md);
  cursor: pointer;
  list-style: none;
  transition: background-color var(--dur);
}
.disclosure-summary::-webkit-details-marker { display: none; }
.disclosure-summary:hover { background: var(--c-surface-2); }
.disclosure-closed, .disclosure-opened {
  font-family: var(--font-round);
  font-weight: 700;
  font-synthesis: none;
  color: var(--c-brown);
}
.disclosure-opened { display: none; }
.disclosure[open] > .disclosure-summary .disclosure-closed { display: none; }
.disclosure[open] > .disclosure-summary .disclosure-opened { display: inline; }
.disclosure-hint { font-size: var(--fs-sm); color: var(--c-text-sub); }
.disclosure-body { padding-top: var(--sp-5); }

/* ================= 18. 施設色 =================
 * .fc-N だけで「帯」の見た目（中くらいの地 + 濃い文字）。
 * .fc-N.is-soft で「薄い地 + 濃い文字 + 細い枠」。
 * .fc-N は変数 --fc-bg / --fc-text / --fc-soft / --fc-soft-text も配るので、枠線などに var() で使える。 */
.fc-1 { --fc-bg: var(--fc-1-bg); --fc-text: var(--fc-1-text); --fc-soft: var(--fc-1-soft); --fc-soft-text: var(--fc-1-soft-text); }
.fc-2 { --fc-bg: var(--fc-2-bg); --fc-text: var(--fc-2-text); --fc-soft: var(--fc-2-soft); --fc-soft-text: var(--fc-2-soft-text); }
.fc-3 { --fc-bg: var(--fc-3-bg); --fc-text: var(--fc-3-text); --fc-soft: var(--fc-3-soft); --fc-soft-text: var(--fc-3-soft-text); }
.fc-4 { --fc-bg: var(--fc-4-bg); --fc-text: var(--fc-4-text); --fc-soft: var(--fc-4-soft); --fc-soft-text: var(--fc-4-soft-text); }
.fc-5 { --fc-bg: var(--fc-5-bg); --fc-text: var(--fc-5-text); --fc-soft: var(--fc-5-soft); --fc-soft-text: var(--fc-5-soft-text); }
.fc-6 { --fc-bg: var(--fc-6-bg); --fc-text: var(--fc-6-text); --fc-soft: var(--fc-6-soft); --fc-soft-text: var(--fc-6-soft-text); }
.fc-7 { --fc-bg: var(--fc-7-bg); --fc-text: var(--fc-7-text); --fc-soft: var(--fc-7-soft); --fc-soft-text: var(--fc-7-soft-text); }
.fc-8 { --fc-bg: var(--fc-8-bg); --fc-text: var(--fc-8-text); --fc-soft: var(--fc-8-soft); --fc-soft-text: var(--fc-8-soft-text); }
.fc-1, .fc-2, .fc-3, .fc-4, .fc-5, .fc-6, .fc-7, .fc-8 { background-color: var(--fc-bg); color: var(--fc-text); }
.fc-1.is-soft, .fc-2.is-soft, .fc-3.is-soft, .fc-4.is-soft,
.fc-5.is-soft, .fc-6.is-soft, .fc-7.is-soft, .fc-8.is-soft {
  background-color: var(--fc-soft);
  color: var(--fc-soft-text);
  box-shadow: inset 0 0 0 1px var(--fc-bg);
}

/* 色の丸（施設名の前に置く。色だけにしないため、必ず施設名の文字と一緒に使う） */
.fc-dot {
  display: inline-block;
  flex: none;
  width: 12px;
  height: 12px;
  border-radius: var(--r-full);
  /* .fc-N が --fc-bg を配る。付いていないときは落ち着いた色（書く順番に左右されないように var の既定値で指定） */
  background-color: var(--fc-bg, var(--c-muted));
  border: 1px solid rgba(61, 36, 24, .25);
  vertical-align: middle;
}
.fc-dot-lg { width: 16px; height: 16px; }

/* ================= 19. ログイン前の画面（ログイン・新規登録・セットアップ・オフライン） ================= */
.guest-main {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--sp-4);
  min-height: 100vh;
  min-height: 100dvh;
  padding: max(var(--sp-8), var(--safe-top)) max(var(--sp-4), var(--safe-right)) max(var(--sp-8), var(--safe-bottom)) max(var(--sp-4), var(--safe-left));
}
.guest-main > .flash, .guest-main > .flash-area, .guest-main > .card { width: min(100%, 400px); }
.guest-main > .flash-area { margin-bottom: 0; }
.auth { display: flex; flex-direction: column; gap: var(--sp-4); width: min(100%, 400px); }
.auth-brand { text-align: center; }
.auth-logo { width: 120px; height: 120px; }
.auth-card { padding: var(--sp-6); border-radius: var(--r-xl); }
.auth-title { margin-bottom: var(--sp-5); font-size: var(--fs-xl); text-align: center; line-height: 1.35; }
.auth-card > .btn { margin-top: var(--sp-2); }
.auth-card > p { margin-bottom: var(--sp-4); }
.auth-card > .flash { margin-bottom: var(--sp-4); }
.auth-switch { margin: var(--sp-5) 0 0; text-align: center; }
.auth-note, .auth-foot { text-align: center; font-size: var(--fs-sm); color: var(--c-text-sub); }
.auth-foot { margin-top: var(--sp-2); font-family: var(--font-round); font-weight: 700; font-synthesis: none; }
.setup-login { margin: var(--sp-4) 0; padding: var(--sp-3) var(--sp-4); background: var(--c-surface-2); border-radius: var(--r-md); }
.setup-login dt { font-size: var(--fs-sm); color: var(--c-text-sub); }
.setup-login dd { margin: 0 0 var(--sp-2); font-weight: 600; color: var(--c-brown); }

/* ================= 20. 動きを減らす設定 ================= */
@media (prefers-reduced-motion: reduce) {
  :root { --dur: 0ms; }
  .btn:active { transform: none; }
}

/* ---- UI/UX レビューでの調整（押しやすさ・折り返し） ---- */
/* エラー一覧の項目リンクを押しやすく */
.form-errors-list a { display: inline-block; padding: 6px 0; }
.form-errors-list li + li { margin-top: 2px; }
/* ログイン画面などの補助リンクも押しやすく */
.auth-switch a { display: inline-block; padding: 10px 4px; }
/* 「女性ドミトリ／ー」のように、のばす音だけが次の行に落ちないように */
.chip-title, .rcard-name, .list-item-title { line-break: strict; word-break: keep-all; overflow-wrap: anywhere; }
/* タブレット幅でフォームが左に寄らないように中央へ */
@media (min-width: 600px) and (max-width: 899px) {
  .narrow { margin-inline: auto; }
}

/* 「お試し」データの目印（施設一覧・施設編集・カレンダー・部屋別で共通） */
.badge-demo { background: var(--c-sand); color: var(--c-brown); }

/* 施設色の帯は、色の違いが分かりにくい人にも境界が分かるよう、同系の濃い輪郭を付ける */
.cal-bar, .rooms-bar { box-shadow: inset 0 0 0 1.5px currentColor; }
.fc-dot { box-shadow: inset 0 0 0 1px rgba(61,36,24,.45); }

/* 端に達したステッパーのボタン（フォーカスは保つので disabled にはしない） */
.stepper-btn[aria-disabled="true"] { background: var(--c-disabled-bg); color: var(--c-disabled-text); cursor: default; }
