/* ===== 全体レイアウト・フォント ===== */
#myschedule,
#myschedule * {
  box-sizing: border-box;
  font-family:
    "Yu Gothic UI",
    "Yu Gothic",
    "Hiragino Kaku Gothic ProN",
    "Hiragino Sans",
    "Meiryo",
    "Noto Sans JP",
    system-ui,
    -apple-system,
    "Segoe UI",
    Roboto,
    "Helvetica Neue",
    Arial,
    sans-serif;
}

#myschedule {
  --bg-silver: #f2f2f2;
  --card-white: #fff;
  --border: #ccc;
  --edo-purple: #6f3381;
  --edo-purple-dark: #5b2a6b;
  --red: #e11d48;
  --blue: #2563eb;
  max-width: 480px;
  margin: 0 auto;
  padding: 16px;
  background: var(--bg-silver);
  min-height: 100vh;
  --dayhead-h: 28px;
  --slot-h: 36px;
}

.ms-topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.ms-title {
  color: var(--edo-purple);
  font-weight: 700;
  font-size: 20px;
}

/* カード */
.ms-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 16px;
}

.ms-h2 {
  font-size: 16px;
  font-weight: 700;
  margin: 0 0 12px;
}

/* タブ */
.ms-tabs {
  display: flex;
  gap: 6px;
}

.ms-tab {
  flex: 1;
  text-align: center;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fafafa;
  color: var(--edo-purple);
  font-weight: 700;
  text-decoration: none;
}

.ms-tab.is-active {
  background: var(--edo-purple);
  color: #fff;
  border-color: var(--edo-purple);
}

/* カレンダー */
.ms-monthbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.ms-monthttl {
  font-size: 16px;
  font-weight: 700;
}

.ms-cal-head {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  text-align: center;
  font-size: 12px;
  color: #000;
  margin-bottom: 8px;
}

.ms-cal-head .is-sun {
  color: var(--red);
}

.ms-cal-head .is-sat {
  color: var(--blue);
}

.ms-cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px 4px;
  text-align: center;
}

.ms-cal-cell {
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
}

.ms-cal-cell span {
  padding: 4px 10px;
  border-radius: 9999px;
  background: transparent;
  border: none;
  color: #000;
  font-size: 13px;
  line-height: 1.2;
}

.ms-cal-cell.is-sun span {
  color: var(--red);
}

.ms-cal-cell.is-sat span {
  color: var(--blue);
}

.ms-cal-cell.is-selected span {
  background: var(--edo-purple);
  color: #fff;
  font-weight: 700;
}

/* 週ビュー */
.ms-week {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0 0 8px;
}

.ms-weekbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px;
}

/* 週バーの週タイトルをカレンダー年月と同じサイズに */
.ms-weekbar h3 {
  font-size: 16px;
  font-weight: 700;
}

.ms-weekwrap {
  display: flex;
  height: calc(var(--dayhead-h) + var(--slot-h) * 11);
  overflow-y: auto;
  border-top: 1px solid var(--border);
}

.ms-hours {
  width: 44px;
  color: #777;
  font-size: 11px;
  text-align: center;
  background: #fff;
  border-right: 1px solid var(--border);
}

.ms-hours .ms-spacer {
  height: var(--dayhead-h);
}

.ms-hour {
  height: var(--slot-h);
  display: flex;
  align-items: center;
  justify-content: center;
  border-bottom: 1px solid var(--border);
}

.ms-weekgrid {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(7, 1fr);
}

.ms-day {
  border-right: 1px solid var(--border);
}

.ms-dayhead {
  height: var(--dayhead-h);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  font-size: 10px;
  border-bottom: 1px solid var(--border);
}

.ms-daydate {
  font-weight: 700;
  font-size: 11px;
}

.ms-slot {
  height: var(--slot-h);
  display: flex;
  align-items: center;
  justify-content: center;
  border-bottom: 1px solid var(--border);
}

.ms-slot.is-closed {
  background: #eee;
  color: #777;
}

/* 週ビューをスクロール可能に */
.ms-weekwrap {
  height: auto;
  /* 既存の height を無効化 */
  max-height: 320px;
  /* 好みで 260–420px などに調整可 */
  overflow-y: auto;
  /* 縦スクロール */
  -webkit-overflow-scrolling: touch;
}

/* 空き枠 */
.ms-slot.is-free {
  color: #e11d48;
  font-weight: 700;
}

/* 週ビューの枠線 */
.ms-week,
.ms-weekwrap,
.ms-hours,
.ms-hour,
.ms-day,
.ms-dayhead,
.ms-slot {
  border-color: #ccc;
}
/* プラン選択／日時選択：カード外観（枠なし） */
.ms-card.plan,
.ms-card.datetime {
  background: transparent;
  border: none;
  padding: 0;
  margin-bottom: 16px;
}

/* 見出し：江戸紫の下線のみ */
.ms-card.plan .ms-h2,
.ms-card.datetime .ms-h2 {
  margin: 0 0 6px;
  padding-bottom: 4px;
  padding-left: 6px;
  padding-right: 6px;
  display: inline-block;
  border-bottom: 1px solid var(--edo-purple);
  min-width: 445px;
  /* 長さを統一 */
  font-family:
    "Yu Mincho", "游明朝", "Hiragino Mincho ProN", "Hiragino Mincho Pro",
    "MS PMincho", "MS Mincho", "Noto Serif JP", serif !important;
}

/* 左の細い四角：高さ=フォントサイズ(1em)・江戸紫 */
.ms-card.plan .ms-h2::before,
.ms-card.datetime .ms-h2::before {
  content: "";
  display: inline-block;
  width: 3px;
  /* 細い縦線の太さ */
  height: 1em;
  /* 見出しと同じ高さ */
  background: var(--edo-purple);
  border-radius: 1px;
  margin-right: 8px;
  vertical-align: -0.1em;
}

/* テキストサイズ統一 */
.ms-card.plan .ms-subtext,
.ms-card.datetime .ms-subtext {
  font-size: 12px;
  color: #666;
  margin: 4px 0 12px;
  font-family:
    "Yu Mincho", "游明朝", "Hiragino Mincho ProN", "Hiragino Mincho Pro",
    "MS PMincho", "MS Mincho", "Noto Serif JP", serif;
}

/* カレンダーと日時選択の間の余白を少し強調 */
.ms-card + .ms-card.datetime {
  margin-top: 8px;
}

/* ▼▼ 追加：江戸紫のプライマリーボタン ▼▼ */
.ms-footer-action {
  margin-top: 12px;
}

.ms-btn-primary {
  display: block;
  width: 100%;
  padding: 12px 16px;
  background: var(--edo-purple);
  color: #fff;
  text-align: center;
  text-decoration: none;
  border: none;
  border-radius: 9999px;
  font-size: 16px;
  font-weight: 700;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
}

.ms-btn-primary:focus {
  outline: 2px solid rgba(111, 51, 129, 0.35);
  outline-offset: 2px;
}

.ms-btn-primary:active {
  transform: translateY(1px);
}

/* 週タイトル行をコンパクトに（高さ＝paddingで調整） */
.ms-weekbar {
  padding: 6px 10px; /* 既存: 12px -> 6px に */
}
.ms-weekbar h3 {
  font-size: 14px; /* 既存: 16px -> 14px に */
  line-height: 1.2;
}

/* 縦幅はカスタムプロパティで一括調整（この再定義が後勝ちで効く） */
#myschedule {
  --dayhead-h: 40px; /* 曜日ヘッダーを少し高く（既存: 28px） */
  --slot-h: 44px; /* タイムスロットも広めに（既存: 36px） */
}

/* 左の時間列の“上部空白”にも下線を入れて、ヘッダー線と揃える */
.ms-hours .ms-spacer {
  border-bottom: 1px solid var(--border);
}

/* 週グリッドの外周ラインを明確に */
.ms-weekwrap {
  border-top: 1px solid var(--border); /* 既存と同じだが明示 */
}
.ms-weekgrid {
  /* 右端は .ms-day の border-right が作るので、左端だけ足す */
  border-left: 1px solid var(--border);
}

/* 曜日カラムの縦罫線：全カラムに右罫線、先頭だけ左罫線も追加 */
.ms-day {
  border-right: 1px solid var(--border);
}
.ms-day:first-child {
  border-left: 1px solid var(--border);
}

/* 各スロットの横罫線（既存の bottom 線を維持） */
.ms-slot {
  border-bottom: 1px solid var(--border);
}

/* 必要なら最下段だけ二重線を避ける（外枠の下線と被る環境向け）
.ms-day .ms-slot:last-child {
  border-bottom: 0;
}
*/
/* --- 時間列の右となりの縦線が太く見える問題の修正 --- */
/* 週グリッドの左線は消す（時間列の border-right を唯一の境界に） */
.ms-weekgrid {
  border-left: 0 !important;
}

/* 先頭カラムの左線も消す（二重線回避） */
.ms-day:first-child {
  border-left: 0 !important;
}

/* 時間列は右線だけを残す（基準線） */
.ms-hours {
  border-right: 1px solid var(--border) !important;
}

/* 横線が“継ぎ目”で途切れたように見える場合の微調整： */
/* ヘッダーの下線を両側で揃える */
.ms-hours .ms-spacer {
  border-bottom: 1px solid var(--border) !important;
}
.ms-dayhead {
  border-bottom: 1px solid var(--border) !important;
}

/* 小数幅の丸め誤差で線が滲む場合に安定させる */
.ms-weekgrid {
  grid-template-columns: repeat(7, minmax(0, 1fr));
}
/* 押せないスロット */
.ms-slot.is-disabled {
  background-color: #f3f4f6; /* 明るいグレー */
  color: #9ca3af;
  pointer-events: none;
}

/* 予約可能スロット（初期） */
.ms-slot.is-free {
  background-color: #ffffff;
  color: #111827;
  cursor: pointer;
  transition:
    background-color 0.15s,
    color 0.15s,
    border-color 0.15s;
  border: 1px solid #d1d5db;
}

/* ユーザーがタップして「ここでお願いしたい」と選んだ状態 */
.ms-slot.is-picked {
  background-color: #6d3c9e; /* 江戸紫トーンに合わせた主カラー */
  border-color: #6d3c9e;
  color: #ffffff;
  font-weight: 600;
}

/* 中のマーク ◎ / × のため */
.ms-slot .ms-slot-mark {
  display: block;
  font-size: 12px;
  line-height: 1;
  text-align: center;
}

/* タップ時の軽いフィードバック */
.ms-slot.is-free:active {
  background-color: #ede9fe;
  border-color: #6d3c9e;
  color: #6d3c9e;
}
/* すでに他の人が確定済みの枠（×） */
.ms-slot.is-disabled {
  background-color: #f3f4f6;
  color: #9ca3af;
  pointer-events: none;
  border: 1px solid #d1d5db;
  text-align: center;
  font-size: 12px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* まだ予約されていない枠（初期◎） */
.ms-slot.is-free {
  background-color: #ffffff;
  color: #e11d48 !important;
  cursor: pointer;
  transition:
    background-color 0.15s,
    color 0.15s,
    border-color 0.15s;
  border: 1px solid #d1d5db;
  text-align: center;
  font-size: 12px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ユーザーが「候補」に入れた枠（まだDB書き込み前） */
.ms-slot.is-picked {
  background-color: #6d3c9e; /* あなたのブランド紫 */
  border-color: #6d3c9e;
  color: #ffffff;
  font-weight: 600;
}

/* 記号（◎, ×） */
.ms-slot .ms-slot-mark {
  display: block;
  font-size: 12px;
  line-height: 1;
  text-align: center;
  /* 色は親(.ms-slot)に任せる */
  color: inherit;
}

/* タップ時のフィードバック */
.ms-slot.is-free:active {
  background-color: #ede9fe;
  border-color: #6d3c9e;
  color: #6d3c9e;
}
/* モーダルのオーバーレイ */
.ms-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

/* モーダル本体 */
.ms-modal-box {
  background: #fff;
  border-radius: 12px;
  width: 100%;
  max-width: 360px;
  padding: 16px 20px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.2);
  font-size: 14px;
  line-height: 1.5;
  color: #111827;
}

.ms-modal-title {
  font-size: 16px;
  font-weight: 600;
  margin: 0 0 8px;
  text-align: center;
}

.ms-modal-desc {
  font-size: 13px;
  margin: 0 0 12px;
  text-align: center;
  color: #6b7280;
}

/* ラジオリスト */
.ms-modal-list {
  max-height: 200px;
  overflow-y: auto;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 8px 12px;
  margin-bottom: 16px;
}

.ms-modal-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
  border-bottom: 1px solid #e5e7eb;
}
.ms-modal-item:last-child {
  border-bottom: none;
}

.ms-modal-item label {
  font-size: 14px;
  color: #111827;
}

.ms-modal-actions {
  display: flex;
  justify-content: space-between;
  gap: 8px;
}

.ms-btn-cancel {
  flex: 1;
  background: #e5e7eb;
  border-radius: 8px;
  padding: 10px;
  font-size: 14px;
  border: 0;
  color: #374151;
}

.ms-btn-ok {
  flex: 1;
  background: #6d3c9e; /* ブランド紫 */
  border-radius: 8px;
  padding: 10px;
  font-size: 14px;
  border: 0;
  color: #fff;
  font-weight: 600;
}

/* フッターの予約ボタンはそのままでOK */
.ms-tab.is-disabled {
  opacity: 0.35;
  pointer-events: none;
  cursor: default;
  /* 必要なら色も薄く */
  /* color: #9ca3af; */
}
/* ================================
   スマホ幅のときは画面いっぱいに
   ================================ */
@media (max-width: 480px) {
  /* コンテナを画面幅100%に */
  #myschedule {
    max-width: 100%;
    width: 100%;
    margin: 0; /* 中央寄せやめる */
    padding: 12px 12px 24px; /* 端から少しだけ内側に余白 */
  }

  /* 見出しの min-width=445px がスマホでははみ出すのでリセット */
  .ms-card.plan .ms-h2,
  .ms-card.datetime .ms-h2 {
    min-width: 0;
    width: 100%;
    box-sizing: border-box;
  }

  /* タブの隙間も少しだけ詰めておく（お好み） */
  .ms-tabs {
    gap: 4px;
  }
}
/* プラン選択／日時選択：カード外観（枠なし） */
.ms-card.plan,
.ms-card.datetime {
  background: transparent;
  border: none;
  padding: 0;
  margin-bottom: 16px;
}

/* 見出し：江戸紫の下線のみ（画面幅にフィットさせる） */
.ms-card.plan .ms-h2,
.ms-card.datetime .ms-h2 {
  margin: 0 0 6px;
  padding: 0 6px 4px;
  display: block; /* inline-block → block に */
  width: 100%; /* 親幅いっぱいに */
  box-sizing: border-box; /* padding 込みで100% */
  border-bottom: 1px solid var(--edo-purple);
  /* min-width は削除！ */
  font-family:
    "Yu Mincho", "游明朝", "Hiragino Mincho ProN", "Hiragino Mincho Pro",
    "MS PMincho", "MS Mincho", "Noto Serif JP", serif !important;
}

/* 左の細い四角：高さ=フォントサイズ(1em)・江戸紫 */
.ms-card.plan .ms-h2::before,
.ms-card.datetime .ms-h2::before {
  content: "";
  display: inline-block;
  width: 3px;
  height: 1em;
  background: var(--edo-purple);
  border-radius: 1px;
  margin-right: 8px;
  vertical-align: -0.1em;
}
/* ================================
   スマホではグレー背景を画面いっぱいに & 横スクロール禁止
   ================================ */
@media (max-width: 480px) {
  html,
  body {
    margin: 0;
    padding: 0;
    overflow-x: hidden; /* 横スクロールを根こそぎ封じる */
  }

  /* グレー背景（#myschedule）を画面いっぱいに広げる */
  #myschedule {
    max-width: 100vw;
    width: 100vw;
    margin: 0 calc(50% - 50vw); /* 親の中央コンテナからはみ出してフル幅にするテク */
    padding-left: 12px;
    padding-right: 12px;
    box-sizing: border-box;
  }
}
