  * {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  font-family: "Helvetica Neue", Helvetica, Arial, "Noto Sans JP", sans-serif;
  background: #f5f5f5;
  overflow-x: hidden !important;
  height: 100%;
  width: 100%;
  max-width: 100vw;
  position: relative;
  touch-action: manipulation;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  -khtml-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
}

.container {
  display: flex;
  flex-direction: column;
  height: 100%;
  width: 100%;
  max-width: 100vw;
  overflow-x: hidden !important;
  touch-action: manipulation;
  position: relative;
}

.header {
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(10px);
  padding: 15px;
  box-shadow: 0 2px 20px rgba(0, 0, 0, 0.1);
  flex-shrink: 0;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  row-gap: 10px;
}

.header > #mapCalendarToggle,
.header > #calDarkToggle,
.header > .header-right { flex-shrink: 0; }
.header > #mapCalendarToggle button { white-space: nowrap; }

.header h1 {
  margin: 0;
  font-size: 24px;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.account-section {
  display: flex;
  align-items: center;
  gap: 8px;
}

.app-buttons {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* アプリバー（ヘッダー下の別段）— Mac風フラット */
.app-bar {
  background: rgba(246, 247, 249, 0.78);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  padding: 10px 20px;
  display: flex;
  justify-content: center;
  gap: 8px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.06);
  box-shadow: none;
}

.app-bar .app-buttons {
  justify-content: center;
  flex-wrap: wrap;
  gap: 6px;
}

#loginText {
  font-size: 14px;
  color: #2d3748;
  font-weight: 600;
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding: 8px 14px;
  border-radius: 10px;
  border: 2px solid #e2e8f0;
  letter-spacing: 0.3px;
}

#loginText:empty {
  display: none;
  padding: 0;
  border: none;
}

.login-btn,
.logout-btn,
.account-btn,
.home-btn {
  padding: 8px 18px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  pointer-events: auto !important;
  z-index: 1000 !important;
  position: relative !important;
  transition: all 0.2s ease;
  white-space: nowrap;
  letter-spacing: 0.3px;
  height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.login-btn {
  background: #ffffff;
  color: #0ea5e9;
  border: 1.5px solid #bae6fd;
  box-shadow: 0 1px 3px rgba(14, 165, 233, 0.1);
}

.login-btn:hover {
  background: #f0f9ff;
  border-color: #7dd3fc;
  box-shadow: 0 2px 8px rgba(14, 165, 233, 0.15);
}

.logout-btn {
  background: #0ea5e9;
  color: white;
  border: 1.5px solid #0ea5e9;
  box-shadow: 0 1px 3px rgba(14, 165, 233, 0.2);
}

.logout-btn:hover {
  background: #0284c7;
  border-color: #0284c7;
  box-shadow: 0 2px 8px rgba(14, 165, 233, 0.3);
}

.account-btn {
  background: #ffffff;
  color: #0ea5e9;
  border: 1.5px solid #bae6fd;
  box-shadow: 0 1px 3px rgba(14, 165, 233, 0.1);
}

.account-btn:hover {
  background: #f0f9ff;
  border-color: #7dd3fc;
  box-shadow: 0 2px 8px rgba(14, 165, 233, 0.15);
}

.home-btn {
  background: #10b981;
  color: white;
  border: 1.5px solid #10b981;
  box-shadow: 0 1px 3px rgba(16, 185, 129, 0.2);
  padding: 8px 12px;
  margin-right: 8px;
}

.home-btn:hover {
  background: #059669;
  border-color: #059669;
  box-shadow: 0 2px 8px rgba(16, 185, 129, 0.3);
}

.login-btn:active,
.logout-btn:active,
.account-btn:active,
.home-btn:active {
  transform: scale(0.98);
}

.shuttle-app-btn {
  background: #0ea5e9;
  color: #fff;
  border: none;
  padding: 7px 16px;
  border-radius: 11px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  pointer-events: auto !important;
  z-index: 1000 !important;
  position: relative !important;
  transition: transform 0.08s ease, filter 0.12s ease, box-shadow 0.12s ease;
  box-shadow: inset 0 0 0 0.5px rgba(255,255,255,0.24), 0 1px 2px rgba(0,0,0,0.12);
  white-space: nowrap;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  height: 38px;
  min-width: auto;
  letter-spacing: -0.005em;
  -webkit-font-smoothing: antialiased;
  background-image: none !important;
  border-color: transparent !important;
}

/* 準備中バッジ(未公開アプリの右上に付ける小ラベル) */
.prep-badge {
  position: absolute;
  top: -7px;
  right: -6px;
  background: #6b7280;
  color: #fff;
  border: 1.5px solid #fff;
  border-radius: 999px;
  padding: 1px 7px;
  font-size: 10px;
  font-weight: 800;
  line-height: 1.5;
  letter-spacing: 0;
  white-space: nowrap;
  box-shadow: 0 1px 4px rgba(0,0,0,0.3);
  pointer-events: none;
}
/* 準備中のアプリ本体は少し落として「まだ使えない」と分かるように */
.shuttle-app-btn.is-prep { filter: grayscale(0.35) brightness(0.92); }
.shuttle-app-btn.is-prep:hover { filter: grayscale(0.2) brightness(1); }

.shuttle-app-btn:hover {
  filter: brightness(1.08);
  box-shadow: inset 0 0 0 0.5px rgba(255,255,255,0.28), 0 2px 5px rgba(0,0,0,0.14);
}

.shuttle-app-btn:active {
  transform: scale(0.96);
  filter: brightness(0.95);
}

.shuttle-icon {
  width: 17px;
  height: 17px;
  flex-shrink: 0;
  stroke-width: 2;
}

.shuttle-text {
  font-weight: 600;
  letter-spacing: -0.005em;
}

/* 勤務表ボタンバッジ */
.kinmuhyo-btn-with-badges {
  position: relative;
}

.kinmuhyo-badges {
  position: absolute;
  top: -8px;
  right: -8px;
  display: flex;
  gap: 2px;
}

.kinmuhyo-badge {
  min-width: 18px;
  height: 18px;
  padding: 0 4px;
  font-size: 10px;
  font-weight: bold;
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}

.kinmuhyo-badge.incident-badge {
  background: #e74c3c;
}

.kinmuhyo-badge.yukyu-badge {
  background: #3498db;
}

.kinmuhyo-badge.jikangai-badge {
  background: #f39c12;
}

.kinmuhyo-badge.seasonal-badge {
  background: #e67e22;
}

@keyframes badge-pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.15); }
}

.kinmuhyo-badge.pulse {
  animation: badge-pulse 0.5s ease-in-out 3;
}

/* モバイル表示の最適化 */
@media (max-width: 768px) {
  .header {
    padding: 10px;
    flex-direction: column;
    gap: 10px;
    align-items: stretch;
  }

  .header h1 {
    font-size: 20px;
    order: 1;
  }

  .header-right {
    flex-direction: column;
    gap: 10px;
    width: 100%;
    order: 2;
  }

  .account-section {
    width: 100%;
    justify-content: flex-end;
    order: 1;
  }

  .app-buttons {
    width: 100%;
    justify-content: flex-end;
    order: 2;
    padding: 8px 12px;
    background: linear-gradient(135deg, #f0f9ff 0%, #e0f2fe 100%);
    border-radius: 8px;
  }

  /* モバイル：アプリバーを横スクロールに */
  .app-bar {
    padding: 8px 0;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    -ms-overflow-style: none;
    justify-content: flex-start;
  }

  .app-bar::-webkit-scrollbar {
    display: none;
  }

  .app-bar .app-buttons {
    display: flex;
    flex-wrap: nowrap;
    gap: 10px;
    padding: 0 12px;
    width: max-content;
    background: transparent;
  }

  .app-bar .shuttle-app-btn {
    flex-shrink: 0;
    min-width: 70px;
    padding: 10px 14px;
    font-size: 12px;
  }

  #loginText {
    font-size: 11px;
    max-width: 150px;
  }

  .login-btn,
  .logout-btn,
  .account-btn,
  .shuttle-app-btn {
    padding: 6px 12px;
    font-size: 11px;
    flex: 0 0 auto;
  }
}

.login-modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 10000;
}

.login-form {
  background: white;
  padding: 30px;
  border-radius: 10px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
  width: 300px;
  max-width: 90vw;
}

.login-form h3 {
  margin: 0 0 20px 0;
  color: #2c3e50;
  text-align: center;
}

.login-input {
  width: 100%;
  padding: 10px;
  margin: 10px 0;
  border: 2px solid #ddd;
  border-radius: 5px;
  font-size: 14px;
  box-sizing: border-box;
}

/* パスワード表示/非表示ボタン */
#togglePasswordBtn {
  transition: opacity 0.2s ease;
}

#togglePasswordBtn:hover {
  opacity: 0.7;
}

#togglePasswordBtn:active {
  opacity: 0.5;
}

.login-submit {
  width: 100%;
  padding: 12px;
  background: #667eea;
  color: white;
  border: none;
  border-radius: 5px;
  cursor: pointer;
  font-size: 14px;
  margin-top: 10px;
}

.login-cancel {
  width: 100%;
  padding: 12px;
  background: #ccc;
  color: white;
  border: none;
  border-radius: 5px;
  cursor: pointer;
  font-size: 14px;
  margin-top: 5px;
}

.account-modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 10000;
}

.account-content {
  background: white;
  padding: 30px;
  border-radius: 10px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
  width: 800px;
  max-width: 95vw;
  max-height: 90vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  position: relative;
}

.modal-header-with-close {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  padding-bottom: 15px;
  border-bottom: 2px solid #e2e8f0;
}

.modal-header-with-close h3 {
  margin: 0;
  font-size: 20px;
  color: #2d3748;
}

.modal-header-with-close .modal-close-btn {
  background: rgba(0, 0, 0, 0.05);
  border: none;
  color: #718096;
  font-size: 24px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  padding: 0;
  flex-shrink: 0;
}

.modal-header-with-close .modal-close-btn:hover {
  background: rgba(0, 0, 0, 0.1);
  color: #2d3748;
  transform: rotate(90deg);
}

/* 送迎アプリモーダル */
.shuttle-modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 10001;
  padding: 20px;
}

.shuttle-modal-content {
  background: white;
  border-radius: 12px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
  width: 95vw;
  height: 90vh;
  max-width: 1400px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.shuttle-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 25px;
  border-bottom: 2px solid #e2e8f0;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  flex-shrink: 0;
}

.shuttle-modal-header h3 {
  margin: 0;
  font-size: 20px;
  font-weight: 600;
}

.modal-close-btn {
  background: rgba(255, 255, 255, 0.2);
  border: none;
  color: white;
  font-size: 24px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  padding: 0;
}

.modal-close-btn:hover {
  background: rgba(255, 255, 255, 0.3);
  transform: rotate(90deg);
}

.shuttle-modal-body {
  flex: 1;
  overflow: hidden;
  position: relative;
}

/* 送迎アプリモーダルのモバイル対応 */
@media (max-width: 768px) {
  .shuttle-modal {
    padding: 0;
    align-items: stretch;
  }

  .shuttle-modal-content {
    width: 100vw;
    height: 100vh;
    max-width: 100vw;
    border-radius: 0;
  }

  .shuttle-modal-header {
    padding: 12px 15px;
  }

  .shuttle-modal-header h3 {
    font-size: 16px;
  }

  .modal-close-btn {
    width: 32px;
    height: 32px;
    font-size: 20px;
  }

  .shuttle-modal-body iframe {
    width: 100%;
    height: 100%;
  }
}

/* iPhone/iPad用のセレクトボックス修正 */
@media (max-width: 1024px) {
  .account-modal {
    align-items: flex-start;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 20px 0;
  }

  .account-content {
    overflow-y: visible !important;
    overflow-x: visible !important;
    max-height: none !important;
    min-height: auto;
    margin: auto;
  }

  .form-select {
    -webkit-appearance: menulist;
    appearance: menulist;
  }
}

.account-tabs {
  display: flex;
  gap: 10px;
  margin-bottom: 25px;
  background: #f0f9ff;
  padding: 8px;
  border-radius: 12px;
}

.account-tab {
  flex: 1;
  padding: 12px 20px;
  cursor: pointer;
  border: 2px solid transparent;
  background: transparent;
  font-size: 15px;
  font-weight: 500;
  color: #64748b;
  border-radius: 8px;
  transition: all 0.3s ease;
}

.account-tab:hover {
  background: rgba(14, 165, 233, 0.1);
  color: #0ea5e9;
}

.account-tab.active {
  color: white;
  background: #0ea5e9;
  box-shadow: 0 4px 12px rgba(14, 165, 233, 0.3);
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
  animation: fadeIn 0.3s ease;
}

.tab-content h4 {
  background: #0ea5e9;
  color: white;
  padding: 12px 20px;
  margin: 0 0 20px 0;
  border-radius: 10px;
  font-size: 17px;
  font-weight: 600;
  box-shadow: 0 4px 12px rgba(14, 165, 233, 0.3);
  display: flex;
  align-items: center;
}

.tab-content h5 {
  background: #38bdf8;
  color: white;
  padding: 10px 15px;
  margin: 25px 0 15px 0;
  border-radius: 8px;
  font-size: 16px;
  font-weight: 600;
  box-shadow: 0 2px 8px rgba(56, 189, 248, 0.3);
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.schedule-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  margin: 20px 0;
  border-radius: 10px;
  /* overflow:hidden を外すとエラーの浮遊表示が切れないが、角丸のため維持しつつ
     エラーはセル内上寄せ表示にする */
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  /* ★列幅を内容で再計算させない: 「超過（3床）」等の文言変化で表がガタつくのを防止 */
  table-layout: fixed;
}

/* 列幅を固定(時間帯/稼働ベッド/患者数/空き状況) */
.schedule-table th:nth-child(1) { width: 18%; }
.schedule-table th:nth-child(2) { width: 27%; }
.schedule-table th:nth-child(3) { width: 27%; }
.schedule-table th:nth-child(4) { width: 28%; }

.schedule-table th,
.schedule-table td {
  border: 1px solid #e8e8e8;
  padding: 12px;
  text-align: center;
  /* 長い文言でも列幅は変えず折り返す */
  word-break: break-word;
  position: relative;
}

.schedule-table th {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  font-weight: 600;
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.schedule-table tr:hover {
  background: #f8f9ff;
}

/* 👇 ここから追加（エラー用） */
/* ★エラー文言はレイアウトに影響しない浮遊表示(absolute)。以前は display:none→block で
   行の高さが変わり、表とモーダル全体がガタついていた (2026-07-06 安定化) */
.input-error {
  position: absolute;
  left: 4px;
  right: 4px;
  bottom: 2px;
  color: #c62828;
  font-size: 10px;
  line-height: 1.3;
  background: rgba(255, 245, 245, 0.95);
  border: 1px solid #ef9a9a;
  border-radius: 4px;
  padding: 1px 4px;
  z-index: 5;
  display: none;
  pointer-events: none;
}

.input-error.show {
  display: block;
}

.schedule-input {
  width: 60px;
  padding: 8px;
  border: 2px solid #e8e8e8;
  border-radius: 6px;
  text-align: center;
  font-size: 14px;
  font-weight: 500;
  background: #fafafa;
  transition: all 0.3s ease;
}

.schedule-input:focus {
  outline: none;
  border-color: #667eea;
  background: white;
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.schedule-input.error {
  border-color: #c62828;
  background: #fff5f5;
}
.form-row {
  display: flex;
  gap: 15px;
  margin: 15px 0;
  align-items: center;
  background: white;
  padding: 12px 15px;
  border-radius: 10px;
  border: 1px solid #e8e8e8;
  transition: all 0.3s ease;
  user-select: none;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
}

.form-row:hover {
  border-color: #667eea;
  box-shadow: 0 2px 8px rgba(102, 126, 234, 0.1);
}

.form-label {
  min-width: 140px;
  font-weight: 600;
  color: #2c3e50;
  font-size: 14px;
  display: flex;
  align-items: center;
  user-select: none;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
}

.form-label::before {
  content: '▸';
  margin-right: 8px;
  color: #667eea;
  font-weight: bold;
  user-select: none;
  -webkit-user-select: none;
}

.form-input {
  flex: 1;
  padding: 10px 12px;
  border: 2px solid #e8e8e8;
  border-radius: 8px;
  font-size: 14px;
  transition: all 0.3s ease;
  background: #fafafa;
  user-select: text !important;
  -webkit-user-select: text !important;
  pointer-events: auto !important;
  touch-action: manipulation;
}

.form-input:focus {
  outline: none;
  border-color: #667eea;
  background: white;
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.form-select {
  padding: 10px 12px;
  border: 2px solid #e8e8e8;
  border-radius: 8px;
  font-size: 14px;
  background: #fafafa;
  transition: all 0.3s ease;
  cursor: pointer;
}

.form-select:focus {
  outline: none;
  border-color: #667eea;
  background: white;
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.form-textarea {
  width: 100%;
  padding: 12px;
  border: 2px solid #e8e8e8;
  border-radius: 8px;
  font-size: 14px;
  resize: vertical;
  min-height: 80px;
  background: #fafafa;
  transition: all 0.3s ease;
  font-family: inherit;
}

.form-textarea:focus {
  outline: none;
  border-color: #667eea;
  background: white;
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.save-btn {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border: none;
  padding: 12px 30px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 15px;
  font-weight: 600;
  margin-right: 10px;
  transition: all 0.3s ease;
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.save-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(102, 126, 234, 0.4);
}

.save-btn:active {
  transform: translateY(0);
}

/* フォームセクション（ラジオボタン用） */
.form-section {
  display: flex;
  gap: 15px;
  margin: 15px 0;
  align-items: center;
  background: white;
  padding: 12px 15px;
  border-radius: 10px;
  border: 1px solid #e8e8e8;
  transition: all 0.3s ease;
  user-select: none;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  flex-wrap: wrap;
}

.form-section:hover {
  border-color: #667eea;
  box-shadow: 0 2px 8px rgba(102, 126, 234, 0.1);
}

.form-section .form-label {
  width: 140px;
  flex-shrink: 0;
}

.option-buttons {
  display: flex;
  gap: 10px;
  flex: 1;
}

.option-btn {
  display: flex;
  align-items: center;
  padding: 8px 16px;
  border: 2px solid #e8e8e8;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.3s ease;
  background: #fafafa;
  min-width: 80px;
  justify-content: center;
}

.option-btn:hover {
  border-color: #667eea;
  background: rgba(102, 126, 234, 0.05);
}

.option-btn input[type="radio"] {
  margin-right: 6px;
  transform: scale(1.2);
  cursor: pointer;
}

.option-btn input[type="radio"]:checked + span {
  font-weight: 600;
  color: #667eea;
}

.option-btn:has(input[type="radio"]:checked) {
  border-color: #667eea;
  background: linear-gradient(135deg, rgba(102, 126, 234, 0.15) 0%, rgba(118, 75, 162, 0.15) 100%);
  box-shadow: 0 2px 8px rgba(102, 126, 234, 0.2);
}

.option-btn span {
  font-size: 14px;
  transition: all 0.3s ease;
}

/* 緊急状態選択セクション */
.emergency-status-section {
  background: #fef2f2;
  border: 2px solid #ef4444;
  border-radius: 10px;
  padding: 20px;
  margin-bottom: 20px;
}

.emergency-status-section h4 {
  margin: 0;
  color: #dc2626;
  font-size: 16px;
  font-weight: 600;
}

/* 緊急状態折りたたみヘッダー */
.emergency-header {
  cursor: pointer;
  display: flex;
  align-items: center;
  padding: 5px 0;
  user-select: none;
  -webkit-user-select: none;
}

.emergency-header:hover {
  opacity: 0.8;
}

.emergency-toggle-arrow {
  display: inline-block;
  margin-right: 8px;
  font-size: 12px;
  transition: transform 0.3s ease;
  color: #dc2626;
}

.emergency-toggle-arrow.open {
  transform: rotate(90deg);
}

.emergency-status-badge {
  margin-left: auto;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
}

.emergency-status-badge.normal {
  background: #d1fae5;
  color: #047857;
}

.emergency-status-badge.partial {
  background: #fef3c7;
  color: #b45309;
}

.emergency-status-badge.critical {
  background: #fee2e2;
  color: #dc2626;
}

.emergency-content {
  margin-top: 15px;
}

.emergency-options {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 15px;
}

.emergency-option {
  display: flex;
  align-items: center;
  padding: 14px;
  border: 2px solid #e2e8f0;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
  background: white;
}

.emergency-option:hover {
  border-color: #0ea5e9;
  background: #f0f9ff;
}

.emergency-option input[type="radio"] {
  margin-right: 10px;
  transform: scale(1.2);
  accent-color: #0ea5e9;
}

.emergency-option input[type="radio"]:checked + .emergency-icon + .emergency-text {
  font-weight: 600;
  color: #1e293b;
}

.emergency-option.selected {
  border-color: #0ea5e9;
  background: #f0f9ff;
  box-shadow: 0 2px 8px rgba(14, 165, 233, 0.15);
}

.emergency-icon {
  font-size: 28px; /* 施設一覧と統一 */
  margin-right: 10px;
  display: inline-block;
  width: 32px;
  text-align: center;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.2)); /* 影をつけて目立たせる */
}

.emergency-text {
  font-size: 15px; /* 少し大きく */
  color: #555;
}

.emergency-message-section {
  margin-top: 15px;
  padding: 15px;
  background: #fef3c7;
  border: 2px solid #fbbf24;
  border-radius: 8px;
}

.emergency-message-section label {
  display: block;
  font-weight: 600;
  margin-bottom: 8px;
  color: #92400e;
}

.message-char-count {
  text-align: right;
  font-size: 12px;
  color: #666;
  margin-top: 5px;
}

/* 緊急状態マーカー用スタイル */
.emergency-marker {
  position: absolute;
  top: -5px;
  right: -5px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 2px solid #dc3545;
  background: #000;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  z-index: 1000;
}

.emergency-marker.partial {
  background: #000;
}

.emergency-marker.critical {
  background: #000;
}

/* 施設一覧の緊急状態表示 */
.facility-emergency-status {
  flex-shrink: 0;
  width: auto;
  height: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px; /* 少し大きく */
  margin-left: 10px;
  cursor: pointer;
  transition: transform 0.2s ease;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.3)); /* 影をつけて目立たせる */
}

.facility-emergency-status:hover {
  transform: scale(1.3);
  filter: drop-shadow(0 3px 6px rgba(0,0,0,0.5));
}

/* 施設一覧の緊急メッセージ表示（詳細を開かなくても見える） */
.facility-emergency-message {
  margin: 8px 0;
  padding: 10px 12px;
  background: linear-gradient(135deg, #fff3cd 0%, #ffeaa7 100%);
  border-left: 4px solid #ff9800;
  border-radius: 6px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.1);
  animation: slideDown 0.3s ease;
}

.facility-emergency-message.critical {
  background: linear-gradient(135deg, #f8d7da 0%, #f5c6cb 100%);
  border-left-color: #dc3545;
}

.emergency-message-content {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.emergency-message-icon {
  font-size: 24px;
  flex-shrink: 0;
  margin-top: 2px;
}

.emergency-message-text {
  font-size: 14px;
  line-height: 1.6;
  color: #333;
  flex: 1;
  word-break: break-word;
}

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.close-btn {
  background: #6c757d;
  color: white;
  border: none;
  padding: 10px 20px;
  border-radius: 5px;
  cursor: pointer;
  font-size: 14px;
}

.detail-btn {
  background: linear-gradient(135deg, #4f86f7 0%, #6a82fb 100%);
  color: white !important;
  border: none;
  padding: 6px 12px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  margin-left: 8px;
  box-shadow: 0 2px 8px rgba(79, 134, 247, 0.3);
  transition: all 0.3s ease;
  letter-spacing: 0.5px;
  -webkit-text-fill-color: white !important;
  background-clip: border-box !important;
  -webkit-background-clip: border-box !important;
}

.detail-btn:hover {
  background: linear-gradient(135deg, #5a92ff 0%, #7590ff 100%);
  box-shadow: 0 4px 12px rgba(79, 134, 247, 0.4);
  transform: translateY(-1px);
}

.referral-btn {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  color: white !important;
  border: none;
  padding: 6px 12px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  margin-left: 8px;
  box-shadow: 0 2px 8px rgba(16, 185, 129, 0.3);
  transition: all 0.3s ease;
  letter-spacing: 0.5px;
  -webkit-text-fill-color: white !important;
  background-clip: border-box !important;
  -webkit-background-clip: border-box !important;
}

.referral-btn:hover {
  background: linear-gradient(135deg, #34d399 0%, #10b981 100%);
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.4);
  transform: translateY(-1px);
}

.facility-extended-details {
  display: none;
  margin-top: 10px;
  padding: 10px;
  background: #f8f9fa;
  border-radius: 5px;
  font-size: 13px;
}

.facility-extended-details.show {
  display: block;
}

.detail-row {
  margin: 5px 0;
  display: flex;
  justify-content: space-between;
  font-size: 13px;
}

.header h1 {
  margin: 0;
  color: #1a1a1a;
  font-size: clamp(20px, 5vw, 36px);
  font-weight: 300;
  font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
  letter-spacing: -0.02em;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  text-align: left;
  position: relative;
}

.subtitle {
  margin: 8px 0 0 0;
  color: #666;
  font-size: clamp(11px, 2.5vw, 14px);
  font-weight: 400;
  font-family: "Helvetica Neue", Helvetica, Arial, "Noto Sans JP", sans-serif;
  text-align: center;
  opacity: 0.8;
}

/* Year selector removed - only current year (2025) is used */

.stats {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin-top: 8px;
  font-size: clamp(9px, 2.2vw, 13px);
  color: #34495e;
  flex-wrap: wrap;
}

.controls {
  background: transparent;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  position: absolute;
  top: 0;
  left: 0;
  z-index: 10;
  width: fit-content;
  max-width: calc(100% - 20px); /* 右端まで使用可能（右側20pxのマージンのみ） */
}

.search-area {
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: flex-start;
}

.home-btn {
  padding: 8px 12px !important;
  min-width: auto !important;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%) !important;
  color: white !important;
  border: none !important;
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3) !important;
}

.home-btn svg {
  display: block;
  fill: white !important;
}

.home-btn:hover {
  background: linear-gradient(135deg, #5568d3 0%, #6a3f8f 100%) !important;
  box-shadow: 0 6px 16px rgba(102, 126, 234, 0.4) !important;
  transform: translateY(-1px);
}

.home-btn:active {
  background: linear-gradient(135deg, #4a5cc0 0%, #5e377d 100%) !important;
  color: white !important;
  transform: scale(0.95);
  box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3) !important;
}

/* 全ボタンを1行に表示 */
.control-buttons {
  display: flex;
  gap: 8px;
  flex-wrap: nowrap;
  align-items: center;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  scrollbar-color: rgba(0, 0, 0, 0.2) transparent;
}

/* PC/iPad用：スクロールバー表示 */
.control-buttons::-webkit-scrollbar {
  height: 6px;
}

.control-buttons::-webkit-scrollbar-track {
  background: transparent;
}

.control-buttons::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.2);
  border-radius: 3px;
}

.control-buttons::-webkit-scrollbar-thumb:hover {
  background: rgba(0, 0, 0, 0.3);
}

.btn {
  background: white;
  color: #3c4043;
  border: 1px solid #dadce0;
  padding: 8px 16px;
  border-radius: 20px;
  cursor: pointer;
  font-weight: 500;
  transition: all 0.2s ease;
  font-size: 14px;
  box-shadow: 0 1px 2px 0 rgba(60, 64, 67, 0.3), 0 1px 3px 1px rgba(60, 64, 67, 0.15);
  white-space: nowrap;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 6px;
}

.btn-icon {
  font-size: 15px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  color: #5f6368;
  transition: color 0.2s ease;
  line-height: 1;
}

.btn:hover {
  box-shadow: 0 1px 3px 0 rgba(60, 64, 67, 0.3), 0 4px 8px 3px rgba(60, 64, 67, 0.15);
}

.btn.active {
  background: #1a73e8;
  color: white;
  border-color: #1a73e8;
  box-shadow: 0 1px 3px 0 rgba(60, 64, 67, 0.3), 0 4px 8px 3px rgba(60, 64, 67, 0.15);
}

.btn.active .btn-icon {
  color: white;
}

.search-box {
  padding: 10px 16px;
  border: 1px solid #dadce0;
  border-radius: 20px;
  font-size: 14px;
  width: 200px;
  max-width: 100%;
  background: white;
  box-shadow: 0 1px 2px 0 rgba(60, 64, 67, 0.3), 0 1px 3px 1px rgba(60, 64, 67, 0.15);
  transition: box-shadow 0.2s ease;
}

.search-box:focus {
  outline: none;
  box-shadow: 0 1px 3px 0 rgba(60, 64, 67, 0.3), 0 4px 8px 3px rgba(60, 64, 67, 0.15);
}

.search-clear-btn {
  background: #ea4335;
  color: white;
  border-color: #ea4335;
}

.search-clear-btn:hover {
  background: #d33828;
  border-color: #d33828;
}

@media (max-width: 768px) {
  .controls {
    width: 100% !important;
    max-width: 100% !important;
    left: 0 !important;
    right: 0 !important;
    overflow-x: auto !important;
    overflow-y: hidden !important;
    -webkit-overflow-scrolling: touch !important;
    scrollbar-width: none !important;
  }

  .controls::-webkit-scrollbar {
    display: none !important;
  }

  .search-area {
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch !important;
    scrollbar-width: none !important;
  }

  .search-area::-webkit-scrollbar {
    display: none !important;
  }

  .control-buttons {
    flex-wrap: nowrap !important;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch !important;
    scrollbar-width: none !important;
  }

  .control-buttons::-webkit-scrollbar {
    display: none !important;
  }

  .search-box {
    font-size: 14px;
    padding: 8px 12px;
    width: 150px;
    flex-shrink: 0;
  }

  .btn {
    font-size: 13px;
    padding: 6px 12px;
    flex-shrink: 0;
    white-space: nowrap;
  }
}

.map-container {
  position: relative;
  flex: 1;
  width: 100%;
  min-height: 0;
  overflow: hidden;
}

#map {
  width: 100%;
  height: 100%;
  min-height: 300px;
  touch-action: pan-x pan-y pinch-zoom;
}

/* Temporarily disable all hiding to test controls */
/* #map [role="dialog"],
#map .gm-ui-hover-effect[data-value*="指"],
#map .gm-ui-hover-effect[data-value*="finger"],
#map .gm-ui-hover-effect[data-value*="タッチ"],
#map .gm-ui-hover-effect[data-value*="touch"],
#map .gm-ui-hover-effect:contains("指"),
#map .gm-ui-hover-effect:contains("finger") {
  display: none !important;
} */

/* Ensure map controls are visible */
#map .gm-style-mtc,
#map .gm-svpc,
#map [title*="ストリート"],
#map [title*="Street View"],
#map [title*="マップタイプ"],
#map [title*="Map Type"],
#map [title*="地図"],
#map [title*="マップ"],
#map .gmnoprint[title*="ストリート"],
#map .gmnoprint[title*="Street View"],
#map .gmnoprint[title*="マップタイプ"],
#map .gmnoprint[title*="Map Type"],
#map .gmnoprint[title*="地図"],
#map .gmnoprint[title*="マップ"] {
  display: block !important;
  visibility: visible !important;
  opacity: 1 !important;
  pointer-events: auto !important;
}

/* Position controls for iPhone - 施設リストパネル閉じた状態のすぐ上 */
/* iPhone専用（iPadは除外 - iPhoneの最大幅は約430px） */
@media (max-width: 480px) {
  .gm-style-mtc {
    margin-bottom: -60px !important;
  }

  /* 地図ボタンと航空写真ボタンの間隔を広げる */
  .gm-style-mtc > div {
    gap: 8px !important;
  }

  /* 地図コントロールボタンのスタイル - ログアウトボタンと同じ色 */
  .gm-style-mtc button {
    margin-right: 8px !important;
    background: #0ea5e9 !important;
    color: white !important;
    border: 1.5px solid #0ea5e9 !important;
    border-radius: 8px !important;
    box-shadow: 0 1px 3px rgba(14, 165, 233, 0.2) !important;
  }

  .gm-style-mtc button:hover {
    background: #0284c7 !important;
    border-color: #0284c7 !important;
  }

  /* ストリートビューボタンのスタイル */
  .gm-svpc {
    transform: translateY(-140px) !important;  /* 地図/航空写真ボタンの上に配置 */
  }

  .gm-svpc button,
  .gm-svpc > div,
  .gm-svpc div[role="button"] {
    background: #0ea5e9 !important;
    border: 1.5px solid #0ea5e9 !important;
    border-radius: 8px !important;
    box-shadow: 0 1px 3px rgba(14, 165, 233, 0.2) !important;
  }

  .gm-svpc button:hover,
  .gm-svpc > div:hover,
  .gm-svpc div[role="button"]:hover {
    background: #0284c7 !important;
    border-color: #0284c7 !important;
  }
}

/* Simple control visibility */
#map .gm-style-mtc,
#map .gm-svpc {
  display: block !important;
  visibility: visible !important;
  opacity: 1 !important;
}

/* タブレット・PC用：地図コントロールボタンのスタイル - iPhoneと同じ色 */
@media (min-width: 481px) {
  .gm-style-mtc button {
    background: #0ea5e9 !important;
    color: white !important;
    border: 1.5px solid #0ea5e9 !important;
    border-radius: 8px !important;
    box-shadow: 0 1px 3px rgba(14, 165, 233, 0.2) !important;
  }

  .gm-style-mtc button:hover {
    background: #0284c7 !important;
    border-color: #0284c7 !important;
  }
}

/* Hide zoom controls (+ and - buttons) */
button[title="ズームイン"],
button[title="ズームアウト"],
button[aria-label="ズームイン"],
button[aria-label="ズームアウト"],
button[aria-label="Zoom in"],
button[aria-label="Zoom out"] {
  display: none !important;
}

/* Hide tilt/rotate/compass buttons */
div[aria-label="地図を回転"],
div[aria-label="Rotate map"],
button[aria-label="地図を回転"],
button[aria-label="Rotate map"],
button[aria-label="地図を傾ける"],
button[aria-label="Tilt map"],
div[aria-label="地図を傾ける"],
div[aria-label="Tilt map"] {
  display: none !important;
}

/* ストリートビューボタンを確実に表示 */
.gm-svpc {
  display: block !important;
  visibility: visible !important;
  opacity: 1 !important;
}

/* タブレット用：PCと同じだが100vhの問題を回避 */
@media (min-width: 481px) and (max-width: 1024px) {
  body {
    overflow: hidden !important;
  }

  #map {
    min-height: 0 !important;
  }

  /* 透析施設リストの下部余白を調整 */
  .facility-list {
    bottom: 20px !important;
  }

  .facility-list-content {
    padding-bottom: 30px !important;
  }
}

#map .gm-style-cc {
  display: none !important;
}

/* Hide any overlay messages */
#map [role="dialog"] {
  display: none !important;
}

/* Allow text selection on input elements */
input, textarea, button {
  user-select: auto;
  -webkit-user-select: auto;
  -khtml-user-select: auto;
  -moz-user-select: auto;
  -ms-user-select: auto;
  touch-action: manipulation;
}

/* Specific styles for number inputs */
input[type="number"] {
  user-select: text !important;
  -webkit-user-select: text !important;
  pointer-events: auto !important;
}

/* Prevent double-tap zoom on buttons and clickable elements */
button, .btn, .login-btn, .year-btn {
  touch-action: manipulation;
}

/* 使用率横棒グラフ */
.occupancy-charts {
  margin-top: 15px;
  padding: 0;
  background: none;
  border-radius: 0;
  border: none;
}

.occupancy-charts h4 {
  margin: 0 0 10px 0;
  font-size: 13px;
  color: #2c3e50;
  font-weight: 600;
  text-align: left;
  background: none;
  -webkit-background-clip: unset;
  -webkit-text-fill-color: unset;
  background-clip: unset;
}

.chart-section {
  margin-bottom: 5px;
}

.chart-section:last-child {
  margin-bottom: 0;
}

.chart-section h5 {
  margin: 0 0 8px 0;
  font-size: 12px;
  color: #495057;
  font-weight: 500;
  padding-left: 0;
  border-left: none;
}

.chart-row {
  display: flex;
  align-items: center;
  margin-bottom: 8px;
  padding: 5px 0;
}

.chart-label {
  width: 40px;
  font-size: 12px;
  color: #6c757d;
  font-weight: 500;
  text-align: left;
  margin-right: 8px;
}

.chart-bar-container {
  flex: 1;
  height: 20px;
  background: #e9ecef;
  border-radius: 10px;
  overflow: hidden;
  position: relative;
  box-shadow: inset 0 1px 3px rgba(0,0,0,0.1);
}

.chart-bar {
  height: 100%;
  border-radius: 10px;
  position: relative;
  transition: width 0.6s ease-in-out;
  background: linear-gradient(90deg, #28a745 0%, #20c997 50%, #17a2b8 100%);
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.chart-bar.high-usage {
  background: linear-gradient(90deg, #ffc107 0%, #fd7e14 50%, #dc3545 100%);
}

.chart-bar.full-usage {
  background: linear-gradient(90deg, #dc3545 0%, #c82333 100%);
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0% { box-shadow: 0 2px 4px rgba(0,0,0,0.1); }
  50% { box-shadow: 0 2px 8px rgba(220,53,69,0.3); }
  100% { box-shadow: 0 2px 4px rgba(0,0,0,0.1); }
}

.chart-value {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 11px;
  font-weight: 600;
  color: white;
  text-shadow: 0 1px 2px rgba(0,0,0,0.3);
}

.chart-info {
  margin-left: 8px;
  font-size: 13px;
  color: #6c757d;
  min-width: 70px;
  flex-shrink: 0;
}

/* 全体使用率セクション */
.overall-section {
  margin-top: 15px;
  padding-top: 15px;
  border-top: 2px solid #e8e8e8;
}

.overall-section h5 {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 10px;
  box-shadow: 0 2px 6px rgba(102, 126, 234, 0.3);
}

.overall-section .chart-row {
  /* 枠を外して上と同じスタイルに */
  background: none;
  padding: 5px 0;
  border-radius: 0;
  border: none;
  margin-bottom: 8px;
}

.overall-section .chart-bar {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  box-shadow: 0 2px 6px rgba(102, 126, 234, 0.4);
}

.overall-section .chart-bar.high-usage {
  background: linear-gradient(135deg, #f39c12 0%, #e67e22 100%);
  box-shadow: 0 2px 6px rgba(243, 156, 18, 0.4);
}

.overall-section .chart-bar.full-usage {
  background: linear-gradient(135deg, #dc3545 0%, #c82333 100%);
  box-shadow: 0 2px 6px rgba(220, 53, 69, 0.4);
  animation: pulse-overall 2s ease-in-out infinite;
}

@keyframes pulse-overall {
  0%, 100% {
    box-shadow: 0 2px 6px rgba(220, 53, 69, 0.4);
    transform: scale(1);
  }
  50% {
    box-shadow: 0 4px 12px rgba(220, 53, 69, 0.6);
    transform: scaleY(1.05);
  }
}

.overall-section .time-label {
  font-weight: 700;
  color: #667eea;
  font-size: 14px;
}

.overall-section .chart-detail {
  margin-left: 8px;
  font-size: 13px;
  color: #6c757d;
  min-width: 70px;
  flex-shrink: 0;
  text-align: right;
}

/* パソコン・iPad用のグラフ横幅調整 */
@media (min-width: 769px) {
  .occupancy-charts {
    padding: 0;
  }

  .chart-row {
    padding: 8px 0;
  }

  .chart-label {
    width: 32px;
    margin-right: 4px;
    flex-shrink: 0;
    text-align: left;
  }

  .chart-bar-container {
    height: 24px;
    flex: 1;
    max-width: calc(100% - 95px);
  }

  .chart-info {
    margin-left: 4px;
    min-width: 55px;
    font-size: 14px;
    flex-shrink: 0;
  }

  .chart-value {
    font-size: 12px;
  }
}

/* iPad専用の調整 */
@media (min-width: 769px) and (max-width: 1024px) {
  .chart-bar-container {
    height: 22px;
    max-width: calc(100% - 92px);
  }

  .chart-info {
    min-width: 52px;
  }
}

@media (min-width: 769px) {
  .selected-facility-popup,
  .popup-overlay {
    display: none !important;
  }

  .legend {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    position: absolute;
    top: 130px;
    right: 15px;
    background: rgba(255, 255, 255, 0.95);
    padding: 12px;
    border-radius: 16px;
    z-index: 100;
    max-width: 300px;
    max-height: calc(100vh - 210px);
    font-size: 11px;
    box-shadow: 0 2px 15px rgba(0, 0, 0, 0.2);
    pointer-events: auto !important;
    overflow: visible;
  }

  .legend.collapsed {
    width: 60px;
    height: 60px;
    max-width: 60px;
    max-height: 60px;
    padding: 0;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #5a6fd8;
    bottom: auto;
  }

  .facility-list {
    position: absolute !important;
    top: 130px !important;
    left: 15px !important;
    bottom: 80px !important;
    background: rgba(255, 255, 255, 0.95) !important;
    padding: 0 !important;
    border-radius: 16px !important;
    z-index: 100 !important;
    width: 320px !important;
    font-size: 11px !important;
    transition: all 0.3s ease !important;
    box-shadow: 0 2px 15px rgba(0, 0, 0, 0.2) !important;
    display: flex !important;
    flex-direction: column !important;
    transform: none !important;
    right: auto !important;
    overflow: hidden !important;
  }

  .facility-list.collapsed {
    width: 60px !important;
    height: 60px !important;
    max-width: 60px !important;
    max-height: 60px !important;
    min-height: 60px !important;
    padding: 0 !important;
    border-radius: 50% !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    background: #5a6fd8 !important;
    bottom: auto !important;
    overflow: visible !important;
  }

  .facility-list-header {
    background: rgba(255, 255, 255, 0.98);
    backdrop-filter: blur(10px);
    padding: 12px 15px;
    border-bottom: 1px solid #e0e0e0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-radius: 16px 16px 0 0;
  }

  .facility-list-header h4 {
    margin: 0;
    color: #2c3e50;
    font-size: 14px;
    font-weight: bold;
  }

  .region-filter {
    padding: 10px 15px;
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.03) 0%, rgba(118, 75, 162, 0.03) 100%);
    border-bottom: 1px solid rgba(102, 126, 234, 0.1);
    position: relative;
    display: flex;
    gap: 8px;
    align-items: center;
  }

  .region-filter-icon {
    position: absolute;
    left: 25px;
    top: 50%;
    transform: translateY(-50%);
    z-index: 2;
    pointer-events: none;
  }

  .region-filter select {
    width: 100%;
    padding: 10px 12px 10px 48px;
    border: 1px solid rgba(102, 126, 234, 0.2);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(8px);
    font-size: 13px;
    font-weight: 500;
    color: #2c3e50;
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    box-shadow: 0 1px 4px rgba(102, 126, 234, 0.08);
    transition: all 0.2s ease;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23667eea' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6,9 12,15 18,9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 8px center;
    background-size: 16px;
  }

  .region-filter select:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.15);
    transform: translateY(-0.5px);
  }

  .region-filter select:hover {
    border-color: rgba(102, 126, 234, 0.3);
    box-shadow: 0 1.5px 6px rgba(102, 126, 234, 0.12);
  }

  .favorite-filter-btn {
    padding: 10px 12px;
    background: rgba(255, 255, 255, 0.95);
    border: 1px solid rgba(102, 126, 234, 0.2);
    border-radius: 8px;
    cursor: pointer;
    font-size: 16px;
    transition: all 0.2s ease;
    box-shadow: 0 1px 4px rgba(102, 126, 234, 0.08);
    flex-shrink: 0;
  }

  .favorite-filter-btn:hover {
    border-color: rgba(102, 126, 234, 0.3);
    box-shadow: 0 1.5px 6px rgba(102, 126, 234, 0.12);
  }

  .favorite-filter-btn.active {
    background: #fbbf24;
    border-color: #f59e0b;
    box-shadow: 0 2px 8px rgba(251, 191, 36, 0.3);
  }

  .favorite-filter-btn.active .btn-icon {
    content: "⭐";
  }

  .facility-list-toggle {
    background: #667eea;
    color: white;
    border: none;
    border-radius: 6px;
    width: 30px;
    height: 25px;
    cursor: pointer;
    font-size: 16px;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    margin: 0;
    pointer-events: auto;
    touch-action: manipulation;
    -webkit-tap-highlight-color: rgba(102, 126, 234, 0.3);
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
    z-index: 1000;
    position: relative;
  }

  .facility-list-toggle:hover {
    background: #5a6fd8;
    transform: scale(1.05);
  }

  .facility-list-toggle:active {
    background: #4a5fc7;
    transform: scale(0.95);
    -webkit-tap-highlight-color: rgba(102, 126, 234, 0.5);
  }

  .facility-list-content {
    flex: 1;
    min-height: 0;
    padding: 0 15px 15px;
    padding-bottom: 150px; /* 最後の施設と詳細表示のための余白 */
    overflow-y: auto;
    overflow-x: visible;
    scrollbar-width: thin;
    scrollbar-color: #ccc transparent;
  }

  .facility-list-content::-webkit-scrollbar {
    width: 6px;
  }

  .facility-list-content::-webkit-scrollbar-track {
    background: transparent;
  }

  .facility-list-content::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 3px;
  }

  .facility-list-content::-webkit-scrollbar-thumb:hover {
    background: #999;
  }

  .facility-list.collapsed .facility-list-content {
    display: none;
  }

  .facility-list.collapsed .facility-list-header h4 {
    display: none;
  }

  .facility-list.collapsed .facility-list-header {
    background: transparent !important;
    border: none !important;
    padding: 0 !important;
    backdrop-filter: none !important;
  }

  .facility-list.collapsed .region-filter {
    display: none;
  }

  .facility-list.collapsed .facility-list-toggle {
    position: relative;
    margin: 0;
    display: block !important;
    z-index: 10;
  }

  .facility-list-handle {
    display: none !important;
  }
}

/* iPad用の特別なスタイル - 高さ制限のみ、基本的にはデスクトップ表示 */
@media (min-width: 769px) and (max-width: 1024px) and (orientation: portrait),
       (min-width: 769px) and (max-width: 1366px) and (orientation: landscape),
       (min-device-width: 768px) and (max-device-width: 1024px) {

  /* 施設リスト全体の高さを制限 */
  .facility-list {
    bottom: 20px !important;
    overflow: hidden !important;
  }

  /* 施設リストの内容部分の高さを制限してスクロール可能にする */
  .facility-list-content {
    max-height: none !important;
    height: auto !important;
    padding-bottom: 30px !important; /* 余白を最小限に */
    overflow-y: auto !important;
    overflow-x: hidden !important;
    -webkit-overflow-scrolling: touch;
  }

  /* スクロールバーを見やすくする */
  .facility-list-content::-webkit-scrollbar {
    width: 8px;
  }

  .facility-list-content::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.1);
    border-radius: 4px;
  }

  .facility-list-content::-webkit-scrollbar-thumb {
    background-color: rgba(102, 126, 234, 0.6);
    border-radius: 4px;
  }

  .facility-list-content::-webkit-scrollbar-thumb:hover {
    background-color: rgba(102, 126, 234, 0.8);
  }

  /* 折りたたみ状態での高さも制限 */
  .facility-list.collapsed {
    max-height: 60px !important;
  }
}

@media (max-width: 768px) {
  body {
    touch-action: pan-x pan-y;
    overflow: hidden;
    position: fixed;
    width: 100%;
    height: 100%;
  }

  .container {
    position: fixed;
    width: 100%;
    height: 100%;
    overflow: hidden;
  }

  /* Hide legend completely on mobile */
  .legend {
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
    pointer-events: none !important;
  }

  /* Hide legend toggle button completely on mobile */
  .legend-toggle, #legendToggle {
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
    pointer-events: none !important;
  }

  /* Prevent any unexpected elements from appearing */
  .legend *, .legend *::before, .legend *::after {
    display: none !important;
    visibility: hidden !important;
  }

  .facility-list {
    position: fixed !important;
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
    background: white;
    border-radius: 16px 16px 0 0;
    z-index: 200;
    height: 35vh;
    --drag-offset: calc(35vh - 80px);
    transform: translateY(var(--drag-offset));
    -webkit-transform: translateY(var(--drag-offset));
    transition: transform 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    -webkit-transition: -webkit-transform 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    box-shadow: 0 -5px 25px rgba(0, 0, 0, 0.3);
    padding: 0;
    will-change: transform;
    touch-action: pan-y;
    max-width: 100% !important;
    top: auto !important;
    display: flex !important;
    flex-direction: column;
    overflow: visible;
  }

  .facility-list.expanded {
    --drag-offset: 0px;
    transform: translateY(0px);
    -webkit-transform: translateY(0px);
  }

  .facility-list-header {
    background: rgba(255, 255, 255, 0.98);
    backdrop-filter: blur(10px);
    padding: 12px 16px;
    border-bottom: none;
    display: flex;
    justify-content: space-between;
    align-items: center;
    min-height: 80px;
    box-sizing: border-box;
    cursor: pointer;
    user-select: none;
    -webkit-user-select: none;
    -webkit-tap-highlight-color: transparent;
    position: sticky;
    top: 0;
    z-index: 1001;
  }

  .facility-list-header:active {
    background: rgba(245, 245, 245, 0.98);
  }

  .facility-list-header h4 {
    margin: 0;
    color: #2c3e50;
    font-size: 14px;
    font-weight: bold;
  }

  /* iPhone用地域フィルターデザイン */
  .region-filter {
    padding: 0 16px 12px 16px;
    background: rgba(255, 255, 255, 0.98);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid rgba(102, 126, 234, 0.15);
    position: sticky;
    top: 80px;
    z-index: 1000;
    display: flex;
    gap: 8px;
    align-items: flex-end;
  }

  .region-filter-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    z-index: 2;
    pointer-events: none;
  }

  .region-filter select {
    width: 100%;
    padding: 12px 16px 12px 48px;
    border: 2px solid rgba(102, 126, 234, 0.2);
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    font-size: 15px;
    font-weight: 500;
    color: #2c3e50;
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.1);
    transition: all 0.3s ease;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23667eea' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6,9 12,15 18,9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 20px;
  }

  .region-filter select:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 4px 16px rgba(102, 126, 234, 0.25);
    transform: translateY(-1px);
  }

  .region-filter select:active {
    transform: translateY(0px);
  }

  .favorite-filter-btn {
    padding: 12px 14px;
    background: rgba(255, 255, 255, 0.95);
    border: 2px solid rgba(102, 126, 234, 0.2);
    border-radius: 12px;
    cursor: pointer;
    font-size: 18px;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.1);
    flex-shrink: 0;
    min-width: 48px;
  }

  .favorite-filter-btn:active {
    transform: translateY(0px);
  }

  .favorite-filter-btn.active {
    background: #fbbf24;
    border-color: #f59e0b;
    box-shadow: 0 4px 16px rgba(251, 191, 36, 0.3);
  }

  .facility-list-handle {
    display: block !important;
    width: 72px;
    height: 4px;
    background: #d1d5db;
    border-radius: 2px;
    margin: 0 auto;
    cursor: grab;
    transition: all 0.2s ease;
    position: absolute;
    top: 10px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1003;
    opacity: 1;
    box-shadow: none;
  }

  .facility-list-handle::before {
    content: "";
    position: absolute;
    top: -15px;
    left: -15px;
    right: -15px;
    bottom: -15px;
    cursor: grab;
  }

  .facility-list-handle:hover {
    background: #9ca3af;
    opacity: 1;
    height: 5px;
  }

  .facility-list-handle:active {
    background: #6b7280;
    cursor: grabbing;
    opacity: 1;
    height: 5px;
    transform: translateX(-50%);
  }

  .facility-list-content {
    padding: 0 16px 30px;
    padding-bottom: 200px; /* 最後の施設と詳細表示のための余白（モバイル） */
    overflow-y: auto;
    overflow-x: hidden;
    flex: 1;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-y;
    position: relative;
    z-index: 1;
  }

  .facility-list-content h4 {
    margin: 0 0 5px 0;
    padding: 8px 0 0 0;
  }

  #facilityListItems {
    display: flex;
    flex-direction: column;
    gap: 0;
    margin: 0;
    padding: 0;
  }

  .facility-list-toggle {
    background: #667eea;
    color: white;
    border: none;
    border-radius: 6px;
    width: 30px;
    height: 25px;
    cursor: pointer;
    font-size: 16px;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    margin: 0;
    position: relative;
    z-index: 1002;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
  }

  .facility-list-toggle:active {
    background: #5a6fd8;
    transform: scale(0.95);
  }

  .selected-facility-popup {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: white;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    z-index: 1000;
    max-width: 90vw;
    max-height: 80vh;
    overflow-y: auto;
    display: none;
  }

  .selected-facility-popup.show {
    display: block;
  }

  .popup-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
    display: none;
  }

  .popup-overlay.show {
    display: block;
  }

  .popup-close {
    position: absolute;
    top: 10px;
    right: 15px;
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: #666;
  }

  .popup-facility-name {
    font-size: 16px;
    font-weight: bold;
    color: #2c3e50;
    margin-bottom: 15px;
    padding-right: 30px;
  }

  .popup-detail-row {
    margin: 8px 0;
    display: flex;
    align-items: flex-start;
  }

  .popup-detail-label {
    font-weight: bold;
    min-width: 60px;
    color: #2c3e50;
    font-size: 14px;
  }

  .popup-detail-value {
    flex: 1;
    font-size: 14px;
    color: #555;
  }
}

.legend-toggle,
.facility-list-toggle {
  background: #667eea;
  color: white;
  border: none;
  border-radius: 50%;
  width: 22px;
  height: 22px;
  cursor: pointer;
  font-size: 11px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
  z-index: 150;
}

.legend-toggle {
  position: absolute;
  top: 5px;
  right: 5px;
}

.legend-toggle:hover,
.facility-list-toggle:hover {
  background: #5a6fd8;
  transform: scale(1.1);
}

.legend-content {
  max-height: calc(100vh - 274px);
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: thin;
  scrollbar-color: #ccc transparent;
  padding-right: 4px;
}

.legend-content::-webkit-scrollbar {
  width: 6px;
}

.legend-content::-webkit-scrollbar-track {
  background: transparent;
}

.legend-content::-webkit-scrollbar-thumb {
  background: #ccc;
  border-radius: 3px;
}

.legend-content::-webkit-scrollbar-thumb:hover {
  background: #999;
}

.facility-list-content {
  transition: all 0.3s ease;
}

.legend.collapsed .legend-content,
.facility-list.collapsed .facility-list-content {
  display: none;
}

/* ★畳んだときは丸1つだけにする(2026-08-24 オーナー指摘)。
   以前は「未選択/透析」の切り替えと患者数の凡例が丸のまわりに残っていた */
.facility-list.collapsed .category-switcher,
.facility-list.collapsed .mini-legend,
.facility-list.collapsed .region-filter,
.facility-list.collapsed .favorite-filter-btn,
.facility-list.collapsed .facility-list-header h4,
.facility-list.collapsed .facility-list-handle {
  display: none !important;
}
.facility-list.collapsed { overflow: hidden !important; }

.legend.collapsed .legend-toggle {
  position: relative;
  top: 0;
  right: 0;
  margin: 0 auto;
  float: none;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: #5a6fd8;
  border: none;
  font-size: 24px;
  font-weight: bold;
  color: white;
  display: flex !important;
  align-items: center;
  justify-content: center;
}

.facility-list.collapsed .facility-list-toggle {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  margin: 0;
  float: none;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: #5a6fd8;
  border: none;
  font-size: 24px;
  font-weight: bold;
  color: white;
  display: flex !important;
  align-items: center;
  justify-content: center;
  z-index: 10;
}

.facility-item {
  padding: 14px 18px;
  margin: 0 0 10px 0;
  border-radius: 14px;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  border-left: 4px solid transparent;
  font-size: 13px;
  line-height: 1.5;
  overflow: hidden;
  width: 100%;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.98) 0%, rgba(247, 250, 255, 0.98) 100%);
  border: 1px solid rgba(79, 134, 247, 0.15);
  box-shadow: 0 2px 8px rgba(79, 134, 247, 0.08), 0 1px 3px rgba(0, 0, 0, 0.05);
  backdrop-filter: blur(10px);
  position: relative;
  box-sizing: border-box;
  display: block;
  touch-action: manipulation;
  -webkit-tap-highlight-color: rgba(79, 134, 247, 0.1);
  user-select: none;
  -webkit-user-select: none;
}

.facility-item:hover,
.facility-item:active {
  background: linear-gradient(135deg, rgba(79, 134, 247, 0.12) 0%, rgba(106, 130, 251, 0.12) 100%);
  border-left-color: #4f86f7;
  border-left-width: 5px;
  transform: translateX(5px) scale(1.01);
  box-shadow: 0 6px 20px rgba(79, 134, 247, 0.25), 0 2px 8px rgba(79, 134, 247, 0.15);
  border-color: rgba(79, 134, 247, 0.35);
}

.facility-item.selected {
  border-left-color: #4f86f7;
  border-left-width: 6px;
  font-weight: 600;
  padding: 16px 20px;
  margin: 0 0 12px 0;
  box-shadow: 0 8px 32px rgba(79, 134, 247, 0.35), 0 4px 12px rgba(79, 134, 247, 0.25);
  transform: scale(1.03);
  transform-origin: left center;
  border-radius: 16px;
  position: relative;
  background: linear-gradient(135deg, rgba(79, 134, 247, 0.15) 0%, rgba(126, 140, 245, 0.12) 100%);
  border: 2px solid rgba(79, 134, 247, 0.4);
  z-index: 1000;
  overflow: visible;
}

@media (min-width: 769px) {
  .facility-item {
    width: 100%;
  }

  .facility-item.selected {
    width: 100%;
    background: rgba(102, 126, 234, 0.1);
    animation: pulseSelection 0.6s ease-out;
  }

  @keyframes pulseSelection {
    0% {
      transform: scale(1);
      box-shadow: 0 4px 20px rgba(102, 126, 234, 0.4);
    }
    50% {
      transform: scale(1.02);
      box-shadow: 0 6px 30px rgba(102, 126, 234, 0.6);
    }
    100% {
      transform: scale(1);
      box-shadow: 0 4px 20px rgba(102, 126, 234, 0.4);
    }
  }

  @keyframes markerPulse {
    0% {
      transform: scale(1);
    }
    25% {
      transform: scale(1.3);
    }
    50% {
      transform: scale(1.1);
    }
    75% {
      transform: scale(1.2);
    }
    100% {
      transform: scale(1);
    }
  }

  .marker-selected {
    animation: markerPulse 0.8s ease-out;
  }
}

.facility-item.selected .facility-name {
  color: #2c3e50;
  font-size: 13px;
  font-weight: bold;
}

.facility-item.selected .facility-patients {
  font-weight: bold;
  font-size: 13px;
}

.facility-item .facility-name {
  color: #1e3a8a;
  font-weight: 600;
  margin-bottom: 8px;
  width: 100%;
  word-wrap: break-word;
  overflow-wrap: break-word;
  font-size: 14px;
  letter-spacing: 0.3px;
}

.facility-item .facility-patients {
  font-size: 13px;
  color: #3b82f6;
  margin-bottom: 4px;
  width: 100%;
  font-weight: 600;
  background: linear-gradient(90deg, #3b82f6, #60a5fa);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.facility-star-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: all 0.2s ease;
}

.facility-star-btn:hover {
  background: #f3f4f6;
  transform: scale(1.1);
}

.facility-star-btn:active {
  transform: scale(0.95);
}

.facility-star-btn svg {
  transition: all 0.2s ease;
}

.facility-item .facility-details {
  display: none;
  font-size: 13px;
  color: #555;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid #eee;
  width: 100%;
}

.facility-item.selected .facility-details {
  display: block;
}

.facility-detail-row {
  margin: 3px 0;
  display: flex;
  align-items: flex-start;
  width: 100%;
  word-wrap: break-word;
}

.facility-detail-label {
  font-weight: bold;
  min-width: 50px;
  color: #2c3e50;
  flex-shrink: 0;
  font-size: 13px;
}

.facility-detail-value {
  flex: 1;
  word-wrap: break-word;
  overflow-wrap: break-word;
  font-size: 13px;
}

.facility-detail-value a {
  word-break: break-all;
  display: inline-block;
  max-width: 100%;
}

.city-group {
  margin: 0 0 16px 0;
  width: 100%;
  display: block;
  overflow: visible;
  position: relative;
}

.city-header {
  background: linear-gradient(135deg, #4f86f7 0%, #6a82fb 50%, #7e8cf5 100%);
  color: white;
  padding: 12px 18px;
  border-radius: 16px;
  font-weight: 600;
  font-size: 14px;
  margin: 0 0 10px 0;
  width: 100%;
  box-sizing: border-box;
  box-shadow: 0 4px 16px rgba(79, 134, 247, 0.3), 0 1px 3px rgba(79, 134, 247, 0.2);
  letter-spacing: 0.4px;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.city-header:hover {
  box-shadow: 0 6px 20px rgba(79, 134, 247, 0.4), 0 2px 6px rgba(79, 134, 247, 0.25);
  transform: translateY(-2px);
  background: linear-gradient(135deg, #5a92ff 0%, #7590ff 50%, #8a9eff 100%);
}

.future-stats {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid #ddd;
}

.demand-level {
  display: flex;
  align-items: center;
  margin: 4px 0;
  font-size: 10px;
}

.demand-box {
  width: 16px;
  height: 12px;
  margin-right: 6px;
  border: 1px solid #ccc;
}

.alert-box {
  background: #fff3cd;
  border: 1px solid #ffeaa7;
  border-radius: 6px;
  padding: 8px;
  margin: 6px 0;
  color: #856404;
  font-size: 10px;
}

.critical-box {
  background: #f8d7da;
  border: 1px solid #f5c6cb;
  border-radius: 6px;
  padding: 8px;
  margin: 6px 0;
  color: #721c24;
  font-size: 10px;
}

.info-window {
  font-family: Arial, sans-serif;
  font-size: 13px;
  line-height: 1.4;
}

.facility-name {
    cursor: pointer;
}

.facility-name:hover {
    opacity: 0.8;
    text-decoration: underline;
}

.city-name {
  font-size: 15px;
  font-weight: bold;
  color: #2c3e50;
  margin-bottom: 6px;
  border-bottom: 2px solid #27ae60;
  padding-bottom: 3px;
}

.facility-info,
.city-info {
  margin: 3px 0;
  color: #666;
  font-size: 12px;
}

.gm-style .gm-style-iw-c {
  max-width: 300px !important;
  padding: 10px !important;
  border-radius: 8px !important;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4) !important;
  z-index: 99999 !important;
  position: relative !important;
}

.gm-style .gm-style-iw-d {
  overflow: hidden !important;
  z-index: 99999 !important;
}

.gm-style .gm-style-iw {
  z-index: 99999 !important;
  position: relative !important;
}

.gm-style .gm-style-iw-chr {
  z-index: 99999 !important;
  position: relative !important;
}

.gm-style .gm-style-iw-a {
  z-index: 99999 !important;
  position: relative !important;
}

.gm-style [data-infobubble] {
  z-index: 99999 !important;
}

.gm-style .gm-style-iw-t {
  z-index: 99998 !important;
}

/* デスクトップとiPad用のドラッグスタイル */
@media (min-width: 769px) {
  /* ドラッグ中のスタイル */
  .facility-list[style*="cursor: grabbing"] {
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.3) !important;
    transform: scale(1.02) !important;
    opacity: 0.9;
  }

  /* ヘッダーのカーソルスタイル */
  .facility-list-header {
    cursor: grab;
  }

  .facility-list-header:active {
    cursor: grabbing;
  }

  /* 格納時のドラッグ対応 */
  .facility-list.collapsed {
    cursor: grab;
  }

  .facility-list.collapsed:active {
    cursor: grabbing;
  }

  /* 判例ボックスのドラッグスタイル */
  #legend {
    cursor: grab;
  }

  #legend:active {
    cursor: grabbing;
  }

  #legend.collapsed {
    cursor: grab;
  }

  #legend.collapsed:active {
    cursor: grabbing;
  }

  /* ドラッグ中の判例ボックス */
  #legend[style*="cursor: grabbing"] {
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.3) !important;
    transform: scale(1.02) !important;
    opacity: 0.9;
  }
}

/* タブレット専用：施設リストと凡例の下部余白（デスクトップ設定を上書き） */
@media (min-width: 481px) and (max-width: 1024px) {
  .facility-list {
    bottom: 20px !important;
  }

  .facility-list-content {
    padding-bottom: 30px !important;
  }

  .legend {
    bottom: 20px !important;
  }
}

/* 既存のCSS内容... */

/* ========== 施設詳細の表示/非表示 ========== */
.facility-details,
.facility-extended-details {
    display: none;
}

.facility-details.show,
.facility-extended-details.show {
    display: block;
}

/* アニメーション（オプション） */
.facility-details,
.facility-extended-details {
    transition: all 0.3s ease;
}

/* フルスクリーンモード時も施設一覧と凡例を表示 */
html:fullscreen .facility-list,
html:-webkit-full-screen .facility-list,
html:-moz-full-screen .facility-list,
body:fullscreen .facility-list,
body:-webkit-full-screen .facility-list,
body:-moz-full-screen .facility-list,
:fullscreen .facility-list,
:-webkit-full-screen .facility-list,
:-moz-full-screen .facility-list {
    display: block !important;
    position: fixed !important;
    top: 15px !important;
    left: 15px !important;
    z-index: 2147483647 !important;
    background: rgba(255, 255, 255, 0.95) !important;
    border-radius: 16px !important;
    width: 320px !important;
    max-height: calc(100vh - 280px) !important;
    overflow: hidden !important;
    box-shadow: 0 2px 15px rgba(0, 0, 0, 0.2) !important;
}

html:fullscreen .legend,
html:-webkit-full-screen .legend,
html:-moz-full-screen .legend,
body:fullscreen .legend,
body:-webkit-full-screen .legend,
body:-moz-full-screen .legend,
:fullscreen .legend,
:-webkit-full-screen .legend,
:-moz-full-screen .legend {
    display: block !important;
    position: fixed !important;
    top: 15px !important;
    right: 15px !important;
    z-index: 2147483647 !important;
    background: rgba(255, 255, 255, 0.95) !important;
    padding: 12px !important;
    border-radius: 16px !important;
    max-width: 300px !important;
    box-shadow: 0 2px 15px rgba(0, 0, 0, 0.2) !important;
}

/* フルスクリーン時のマップ調整 */
html:fullscreen #map,
html:-webkit-full-screen #map,
html:-moz-full-screen #map,
body:fullscreen #map,
body:-webkit-full-screen #map,
body:-moz-full-screen #map,
:fullscreen #map,
:-webkit-full-screen #map,
:-moz-full-screen #map {
    height: 100vh !important;
    width: 100vw !important;
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    z-index: 1 !important;
}

/* フルスクリーン時のコントロール要素も表示 */
html:fullscreen .controls,
html:-webkit-full-screen .controls,
html:-moz-full-screen .controls,
body:fullscreen .controls,
body:-webkit-full-screen .controls,
body:-moz-full-screen .controls {
    display: block !important;
    position: fixed !important;
    z-index: 2147483647 !important;
}

/* ログインユーザーの施設用特別スタイル - モダンフラットデザイン */
.facility-item.user-facility {
  background: linear-gradient(to right, #eff6ff 0%, #ffffff 100%) !important;
  border: 2px solid #3b82f6 !important;
  border-radius: 12px !important;
  box-shadow: 0 2px 8px rgba(59, 130, 246, 0.15) !important;
  position: relative;
  margin-top: 8px !important;
}

/* マイ施設バッジ - 施設名の左に配置 */
.facility-item.user-facility .facility-name::before {
  content: 'MY';
  display: inline-block;
  background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
  color: white;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 4px;
  margin-right: 8px;
  vertical-align: middle;
  letter-spacing: 1px;
}

/* マイ施設の施設名スタイル */
.facility-item.user-facility .facility-name {
  font-weight: 600 !important;
  color: #1e40af !important;
}
/* 検索モーダルスタイル */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
}

.search-modal-content {
  background: white;
  border-radius: 12px;
  max-width: 600px;
  width: 90%;
  height: 85vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
}

.search-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 24px;
  border-bottom: 1px solid #e0e0e0;
  background: white;
  flex-shrink: 0;
}

.search-modal-header h3 {
  margin: 0;
  font-size: 20px;
  color: #202124;
}

.modal-close-icon {
  background: none;
  border: none;
  font-size: 24px;
  color: #5f6368;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 50%;
  transition: background 0.2s;
}

.modal-close-icon:hover {
  background: #f1f3f4;
}

/* タブメニュー */
.search-tabs {
  display: flex;
  border-bottom: 1px solid #e0e0e0;
  background: white;
  flex-shrink: 0;
}

.search-tab {
  flex: 1;
  padding: 16px 12px;
  border: none;
  background: none;
  cursor: pointer;
  font-size: 14px;
  color: #5f6368;
  border-bottom: 3px solid transparent;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.search-tab:hover {
  background: #f8f9fa;
}

.search-tab.active {
  color: #1a73e8;
  border-bottom-color: #1a73e8;
  font-weight: 500;
}

.tab-icon {
  font-size: 16px;
}

/* タブコンテンツ */
.search-tab-content {
  display: none;
  padding: 20px 24px;
  overflow-y: auto;
  flex: 1;
  min-height: 400px;
}

.search-tab-content.active {
  display: block;
}

/* 検索セクション */
.search-section {
  margin-bottom: 24px;
}

.search-section h4 {
  font-size: 15px;
  color: #202124;
  margin: 0 0 12px 0;
  font-weight: 500;
}

/* 位置選択オプション */
.location-options {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.location-option {
  display: flex;
  align-items: center;
  padding: 12px 16px;
  border: 2px solid #e0e0e0;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
}

.location-option:hover {
  border-color: #1a73e8;
  background: #f8f9fa;
}

.location-option.disabled {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

.location-option.disabled .location-text::after {
  content: " (ログインが必要)";
  font-size: 11px;
  color: #999;
}

.location-option input[type="radio"] {
  margin-right: 12px;
  width: 18px;
  height: 18px;
}

.location-option input[type="radio"]:checked + .location-icon {
  color: #1a73e8;
}

.location-option input[type="radio"]:checked + .location-icon svg {
  fill: #1a73e8;
}

.location-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  margin-right: 12px;
  color: #5f6368;
  transition: color 0.2s;
}

.location-icon svg {
  fill: #5f6368;
  transition: fill 0.2s;
}

.location-text {
  font-size: 14px;
  color: #202124;
  font-weight: 500;
}

/* 検索オプション */
.search-options {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.search-option {
  display: inline-flex;
  align-items: center;
  padding: 8px 16px;
  border: 1px solid #dadce0;
  border-radius: 20px;
  cursor: pointer;
  font-size: 14px;
  transition: all 0.2s;
}

.search-option:hover {
  border-color: #1a73e8;
  background: #f8f9fa;
}

.search-option input[type="radio"] {
  margin-right: 8px;
}

.search-option input[type="radio"]:checked {
  accent-color: #1a73e8;
}

/* チェックボックス */
.search-checkboxes {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.search-checkbox {
  display: flex;
  align-items: center;
  cursor: pointer;
  font-size: 14px;
  color: #202124;
}

.search-checkbox input[type="checkbox"] {
  margin-right: 12px;
  width: 18px;
  height: 18px;
  accent-color: #1a73e8;
}

/* ボタン */
.search-modal-buttons {
  display: flex;
  gap: 12px;
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid #e0e0e0;
}

.search-apply-btn {
  flex: 2;
  background: #1a73e8 !important;
  color: white !important;
  border-color: #1a73e8 !important;
}

.search-reset-btn {
  flex: 1;
  background: white !important;
  color: #5f6368 !important;
}

/* 保存済み・履歴リスト */
.saved-facilities-list,
.search-history-list {
  min-height: 200px;
}

.saved-facility-item,
.history-item {
  padding: 16px;
  border-bottom: 1px solid #e0e0e0;
  cursor: pointer;
  transition: background 0.2s;
}

.saved-facility-item:hover,
.history-item:hover {
  background: #f8f9fa;
}

.saved-facility-name {
  font-size: 15px;
  font-weight: 500;
  color: #202124;
  margin-bottom: 4px;
}

.saved-facility-address {
  font-size: 13px;
  color: #5f6368;
}

/* モバイル対応 */
@media (max-width: 768px) {
  .search-modal-content {
    width: 95%;
    max-height: 90vh;
  }

  .search-modal-header {
    padding: 16px 20px;
  }

  .search-tab-content {
    padding: 16px 20px;
  }

  .location-options {
    gap: 10px;
  }

  .location-option {
    padding: 10px 14px;
  }

  .search-modal-buttons {
    flex-direction: column;
  }

  .search-apply-btn,
  .search-reset-btn {
    flex: 1;
  }
}

/* メッセージボタンとバッジ */
.message-btn {
  background: #0ea5e9;
  color: white;
  border: 1.5px solid #0ea5e9;
  padding: 8px 16px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  pointer-events: auto !important;
  z-index: 1000 !important;
  position: relative !important;
  transition: all 0.2s ease;
  box-shadow: 0 1px 3px rgba(14, 165, 233, 0.2);
  white-space: nowrap;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 40px;
  min-width: 90px;
}

.message-btn:hover {
  background: #0284c7;
  border-color: #0284c7;
  box-shadow: 0 2px 8px rgba(14, 165, 233, 0.3);
}

.mail-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.mail-text {
  font-weight: 600;
  letter-spacing: 0.3px;
}

.message-badge {
  position: absolute;
  top: -6px;
  right: -6px;
  background: #ef4444;
  color: white;
  border-radius: 50%;
  width: 18px;
  height: 18px;
  font-size: 10px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid #ffffff;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.15);
}

.reservation-badge {
  position: absolute;
  top: -6px;
  right: -6px;
  background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
  color: white;
  border-radius: 50%;
  min-width: 18px;
  height: 18px;
  padding: 0 4px;
  font-size: 10px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid #ffffff;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.15);
  animation: pulse 2s infinite;
}

/* 外来予約バッジ（青/右上） */
.outpatient-badge {
  position: absolute;
  top: -6px;
  right: -6px;
  background: linear-gradient(135deg, #1a73e8 0%, #1565c0 100%);
  color: white;
  border-radius: 50%;
  min-width: 18px;
  height: 18px;
  padding: 0 4px;
  font-size: 10px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid #ffffff;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.15);
  animation: pulse 2s infinite;
}

/* 予防接種バッジ（緑/左上） */
.vaccination-badge {
  position: absolute;
  top: -6px;
  left: -6px;
  background: linear-gradient(135deg, #4caf50 0%, #388e3c 100%);
  color: white;
  border-radius: 50%;
  min-width: 18px;
  height: 18px;
  padding: 0 4px;
  font-size: 10px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid #ffffff;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.15);
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.1);
  }
}

/* 問診票バッジ */
.monshin-badge {
  position: absolute;
  color: white;
  border-radius: 50%;
  min-width: 16px;
  height: 16px;
  padding: 0 3px;
  font-size: 9px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid #ffffff;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
  animation: pulse 2s infinite;
}

/* ★2026-09-06: 問診バッジは「外来」ボタン(予約バッジと同居)へ。上段=予約(右:外来/左:予防接種)、下段=問診(右:発熱/左:一般/中央:予防注射) */
.monshin-badge.fever-badge {
  bottom: -6px;
  right: -6px;
  background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
}

.monshin-badge.general-badge {
  bottom: -6px;
  left: -6px;
  background: linear-gradient(135deg, #2196f3 0%, #1976d2 100%);
}

.monshin-badge.vaccine-badge {
  bottom: -6px;
  left: calc(50% - 8px);
  background: linear-gradient(135deg, #84cc16 0%, #65a30d 100%);
}

/* Legend Stylish Design */
.legend-content h4 {
  background: linear-gradient(135deg, #4f86f7 0%, #6a82fb 50%, #7e8cf5 100%);
  color: white;
  padding: 12px 16px;
  border-radius: 12px;
  margin: 0 0 16px 0;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.5px;
  box-shadow: 0 4px 12px rgba(79, 134, 247, 0.3);
  text-align: center;
}

.legend-item {
  display: flex;
  align-items: center;
  padding: 10px 12px;
  margin: 6px 0;
  border-radius: 10px;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.98) 0%, rgba(247, 250, 255, 0.98) 100%);
  border: 1px solid rgba(79, 134, 247, 0.12);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  cursor: default;
}

.legend-item:hover {
  background: linear-gradient(135deg, rgba(79, 134, 247, 0.08) 0%, rgba(106, 130, 251, 0.08) 100%);
  border-color: rgba(79, 134, 247, 0.25);
  transform: translateX(4px);
  box-shadow: 0 3px 10px rgba(79, 134, 247, 0.15);
}

.legend-marker {
  width: 20px;
  height: 20px;
  display: inline-block;
  margin-right: 12px;
  border-radius: 50%;
  flex-shrink: 0;
  border: 2px solid white;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
  opacity: 0.9;
}

.legend-text {
  font-size: 13px;
  color: #1e3a8a;
  font-weight: 500;
  letter-spacing: 0.3px;
}

.alert-box {
  margin-top: 16px;
  padding: 14px 16px;
  background: linear-gradient(135deg, rgba(79, 134, 247, 0.12) 0%, rgba(126, 140, 245, 0.1) 100%);
  border-radius: 12px;
  font-size: 13px;
  color: #1e3a8a;
  border: 1px solid rgba(79, 134, 247, 0.25);
  box-shadow: 0 2px 8px rgba(79, 134, 247, 0.12);
  line-height: 1.6;
}

.alert-box strong {
  color: #4f86f7;
  font-weight: 600;
  font-size: 14px;
}

/* ストリートビューから戻るボタン */
#backToMapButton:hover {
  background: #5a6fd8 !important;
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(102, 126, 234, 0.5) !important;
}

#backToMapButton:active {
  transform: translateY(0);
  box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3) !important;
}

/* ========== カレンダーウィジェット ========== */
.calendar-widget {
  position: absolute;
  top: 130px;
  right: 15px;
  bottom: 80px;
  background: rgba(255, 255, 255, 0.98);
  border-radius: 16px;
  z-index: 100;
  width: 380px;
  max-width: calc(100vw - 400px);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
  overflow: hidden;
  transition: all 0.3s ease;
  display: flex;
  flex-direction: column;
}
.calendar-widget .calendar-content {
  flex: 1 1 auto;
  overflow-y: auto;
  scrollbar-width: thin;
}
.calendar-widget .calendar-content::-webkit-scrollbar { width: 6px; }
.calendar-widget .calendar-content::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.2); border-radius: 3px; }
body[data-cal-dark="1"] .calendar-widget .calendar-content::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.2); }

/* カレンダーウィジェットのヘッダー（左モーダルと同じ見た目） */
.calendar-widget .cw-header {
  padding: 12px 16px;
  background: #ffffff;
  border-bottom: 1px solid #e5e5e7;
  font-size: 14px;
  font-weight: 700;
  color: #1d1d1f;
  letter-spacing: -0.01em;
  display: flex;
  align-items: center;
  border-top-left-radius: 16px;
  border-top-right-radius: 16px;
  position: sticky;
  top: 0;
  z-index: 5;
}
body[data-cal-dark="1"] .calendar-widget .cw-header {
  background: #1f1f21 !important;
  color: #f5f5f7 !important;
  border-bottom-color: #3a3a3c !important;
}

.calendar-widget.collapsed {
  width: 50px;
  height: 50px;
  min-height: 50px;
  max-width: 50px;
  bottom: auto;
  border-radius: 50%;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  overflow: hidden;
}

.calendar-widget.collapsed .calendar-content,
.calendar-widget.collapsed .cw-header {
  display: none;
}

.calendar-widget.collapsed .calendar-toggle {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: transparent;
  color: white;
  font-size: 24px;
  font-weight: 300;
  top: 0;
  right: 0;
  line-height: 1;
}

.calendar-toggle {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 28px;
  height: 28px;
  border: none;
  background: rgba(102, 126, 234, 0.1);
  border-radius: 50%;
  cursor: pointer;
  font-size: 16px;
  color: #667eea;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
  transition: all 0.2s;
}

.calendar-toggle:hover {
  background: rgba(102, 126, 234, 0.2);
}

/* モバイル展開ボタン（デスクトップでは非表示） */
.mobile-expand-btn {
  display: none;
}

.calendar-content {
  padding: 16px;
}

/* 本日のピックアップ */
.today-pickup {
  background: linear-gradient(135deg, #f0f4ff 0%, #e8ecff 100%);
  border-radius: 10px;
  padding: 12px;
  margin-bottom: 12px;
}

/* デジタル時計 - Bold Gradient */
.digital-clock {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  border-radius: 16px;
  padding: 20px;
  margin-bottom: 12px;
  text-align: left;
}

.clock-year {
  font-size: 16px;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.75);
  letter-spacing: 1px;
  margin-bottom: 2px;
  font-family: 'Helvetica Neue', 'Hiragino Sans', sans-serif;
}
.clock-date {
  font-size: 26px;
  font-weight: 800;
  color: white;
  letter-spacing: 1px;
  margin-bottom: 6px;
  font-family: 'Arial Black', 'Helvetica Neue', 'Hiragino Sans', sans-serif;
}

.clock-time {
  font-size: 28px;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.9);
  font-family: 'Arial Black', 'SF Mono', 'Monaco', monospace;
  letter-spacing: 2px;
}

.clock-time .clock-seconds {
  font-size: 16px;
  color: rgba(255, 255, 255, 0.5);
  margin-left: 2px;
}

/* 日付詳細モーダル */
.day-detail-modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.day-detail-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.4);
}

.day-detail-content {
  position: relative;
  background: white;
  border-radius: 16px;
  padding: 20px;
  min-width: 280px;
  max-width: 90%;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
  animation: dayDetailIn 0.2s ease-out;
}

@keyframes dayDetailIn {
  from {
    opacity: 0;
    transform: scale(0.9);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

.day-detail-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.day-detail-date {
  font-size: 20px;
  font-weight: 700;
  color: #333;
}

.day-detail-close {
  width: 32px;
  height: 32px;
  border: none;
  background: #f5f5f5;
  border-radius: 50%;
  font-size: 20px;
  color: #666;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.day-detail-close:hover {
  background: #eee;
}

.day-detail-label {
  font-size: 12px;
  color: #667eea;
  font-weight: 600;
  margin-bottom: 12px;
}

.day-detail-doctors {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.day-detail-doctor {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  padding: 12px 16px;
  border-radius: 10px;
  font-size: 16px;
  font-weight: 500;
}

.pickup-header {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  color: #667eea;
  margin-bottom: 8px;
}

.pickup-items {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.pickup-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  background: white;
  border-radius: 6px;
  font-size: 12px;
}

.pickup-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  color: #667eea;
  flex-shrink: 0;
}

.pickup-icon svg {
  width: 16px;
  height: 16px;
}

.pickup-label {
  color: #666;
  flex-shrink: 0;
}

.pickup-value {
  margin-left: auto;
  font-weight: 600;
  color: #333;
}

/* 緊急通知スタイル（配信予定日など） */
.pickup-urgent {
  background: linear-gradient(135deg, #ff4444, #cc0000);
  border-radius: 8px;
  padding: 12px;
  color: white;
  box-shadow: 0 2px 8px rgba(255, 0, 0, 0.3);
  animation: pulse-urgent 2s infinite;
}

.pickup-urgent-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}

.pickup-urgent-icon {
  display: flex;
  align-items: center;
  justify-content: center;
}

.pickup-urgent-icon svg {
  width: 22px;
  height: 22px;
}

.pickup-urgent-title {
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.5px;
}

.pickup-urgent-body {
  font-size: 13px;
  font-weight: 500;
  padding-left: 30px;
  opacity: 0.95;
}

@keyframes pulse-urgent {
  0%, 100% {
    box-shadow: 0 2px 8px rgba(255, 0, 0, 0.3);
  }
  50% {
    box-shadow: 0 2px 16px rgba(255, 0, 0, 0.5);
  }
}

/* 外来担当医は大きく表示 */
#pickupDoctor {
  flex-wrap: wrap;
  padding: 12px;
  position: relative;
  text-align: right;
}

#pickupDoctor .pickup-label {
  width: 100%;
  margin-bottom: 6px;
  font-size: 11px;
  text-align: right;
}

#pickupDoctor .pickup-value {
  width: 100%;
  margin-left: 0;
  font-size: 16px;
  line-height: 1.4;
  color: #333;
  text-align: right;
}

#pickupDoctor .pickup-icon {
  position: absolute;
  top: 10px;
  left: 10px;
}

.pickup-empty {
  justify-content: center;
  background: transparent;
}

/* カレンダーヘッダー */
.calendar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 0;
  margin-bottom: 8px;
}

.calendar-month {
  font-size: 14px;
  font-weight: 600;
  color: #333;
}

.calendar-nav {
  width: 28px;
  height: 28px;
  border: none;
  background: #f5f5f5;
  border-radius: 6px;
  cursor: pointer;
  font-size: 12px;
  color: #666;
  transition: all 0.2s;
}

.calendar-nav:hover {
  background: #e0e0e0;
}

/* カレンダー曜日 */
.calendar-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
  margin-bottom: 4px;
}

.calendar-weekdays .weekday {
  text-align: center;
  font-size: 10px;
  font-weight: 600;
  color: #888;
  padding: 4px 0;
}

.calendar-weekdays .weekday.sun {
  color: #e53935;
}

.calendar-weekdays .weekday.sat {
  color: #1976d2;
}

/* カレンダー日付 */
.calendar-days {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}

.calendar-day {
  min-height: 52px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding: 4px 2px;
  font-size: 12px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s;
  position: relative;
  overflow: hidden;
}

.calendar-day:hover {
  background: #f0f0f0;
}

.calendar-day.today {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  font-weight: 700;
}

.calendar-day.other-month {
  color: #ccc;
}

.calendar-day.sunday {
  color: #e53935;
}

.calendar-day.saturday {
  color: #1976d2;
}

.calendar-day.today.sunday,
.calendar-day.today.saturday {
  color: white;
}

/* 休診日 */
.calendar-day.closed {
  background: #d0d0d0;
}

.calendar-day.closed .day-num {
  color: #666;
}

.calendar-day.has-event {
  cursor: pointer;
}

.calendar-day.has-event:hover {
  background: rgba(102, 126, 234, 0.1);
}

.calendar-day.has-event::after {
  display: none; /* 医師名表示時は不要 */
}

/* カレンダー内の医師表示 */
.calendar-day .day-num {
  font-size: 12px;
  font-weight: 600;
  line-height: 1;
  margin-bottom: 2px;
}

.calendar-day .cal-events {
  display: flex;
  flex-direction: column;
  gap: 2px;
  width: 100%;
  overflow: hidden;
}

.calendar-day .cal-doctor {
  font-size: 10px;
  line-height: 1.2;
  color: #1a73e8;
  background: #e8f0fe;
  padding: 2px 3px;
  border-radius: 3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-align: center;
}

.calendar-day .cal-more {
  font-size: 9px;
  color: #666;
  text-align: center;
}

.calendar-day.sunday .cal-doctor,
.calendar-day.saturday .cal-doctor {
  background: rgba(232, 240, 254, 0.7);
}

.calendar-day.today .cal-doctor {
  background: rgba(255, 255, 255, 0.9);
  color: #1a73e8;
}

/* ミニ凡例（施設一覧下部） */
.mini-legend {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 8px 12px;
  background: #f8f9fa;
  border-top: 1px solid #e0e0e0;
}

.mini-legend-item {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 1px solid rgba(255,255,255,0.5);
  box-shadow: 0 1px 2px rgba(0,0,0,0.1);
  cursor: help;
}

.mini-legend-label {
  font-size: 10px;
  color: #888;
  margin-left: 4px;
}

/* タブレット対応 */
@media (min-width: 769px) and (max-width: 1200px) {
  .calendar-widget {
    width: 340px;
    max-width: calc(100vw - 380px);
  }
}

/* モバイル対応 */
@media (max-width: 768px) {
  /* モバイル：右側の四角いボタン */
  .calendar-widget {
    position: fixed;
    top: 380px;
    bottom: auto;
    left: auto;
    right: 12px;
    width: auto;
    max-width: none;
    border-radius: 14px;
    z-index: 100;
    overflow: visible;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
    background: transparent;
  }

  .calendar-widget .calendar-content {
    padding: 0;
    display: none;
  }

  /* デフォルトでカレンダー・時計を非表示 */
  .calendar-widget .calendar-header,
  .calendar-widget .calendar-weekdays,
  .calendar-widget .calendar-days,
  .calendar-widget .today-pickup,
  .calendar-widget .digital-clock {
    display: none !important;
  }

  /* デスクトップのトグルボタン非表示 */
  .calendar-widget .calendar-toggle {
    display: none;
  }

  /* モバイル：四角いボタン */
  .calendar-widget .mobile-expand-btn {
    display: flex;
    flex-direction: column;
    width: 82px;
    height: auto;
    min-height: 82px;
    padding: 10px;
    background: rgba(255, 255, 255, 0.98);
    color: #333;
    border: 2px solid #667eea;
    border-radius: 16px;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    align-items: center;
    justify-content: center;
    gap: 5px;
    box-shadow: 0 4px 20px rgba(102, 126, 234, 0.3);
  }

  .calendar-widget .mobile-pickup-info {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    width: 100%;
  }

  .calendar-widget .mobile-pickup-item {
    display: flex;
    align-items: center;
    gap: 3px;
    font-size: 11px;
    white-space: nowrap;
    font-weight: 600;
  }

  .calendar-widget .mobile-pickup-item svg {
    width: 12px;
    height: 12px;
  }

  /* 医師 - 紫 */
  .calendar-widget .mobile-pickup-item.doctor {
    color: #667eea;
  }

  /* 外来予約 - 青 */
  .calendar-widget .mobile-pickup-item.reservation {
    color: #2196f3;
  }

  /* 予防接種 - 緑 */
  .calendar-widget .mobile-pickup-item.vaccination {
    color: #4caf50;
  }

  /* 配信アラート - 赤 */
  .calendar-widget .mobile-pickup-item.alert {
    color: #d32f2f;
    font-weight: 700;
    animation: pulse-alert 1.5s ease-in-out infinite;
  }

  .calendar-widget .mobile-label {
    font-size: 9px;
    opacity: 0.8;
  }

  @keyframes pulse-alert {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
  }

  .calendar-widget .mobile-calendar-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 10px;
    color: white;
    flex-shrink: 0;
  }

  .calendar-widget .mobile-calendar-icon svg {
    width: 20px;
    height: 20px;
  }

  /* モバイル展開時 */
  .calendar-widget.mobile-expanded {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    max-height: 100vh;
    overflow-y: auto;
    border-radius: 0;
    z-index: 200;
    background: rgba(255, 255, 255, 0.98);
  }

  .calendar-widget.mobile-expanded .calendar-content {
    display: block;
    padding: 16px;
    padding-bottom: 100px;
  }

  .calendar-widget.mobile-expanded .today-pickup {
    display: block !important;
    padding: 12px;
    border-radius: 10px;
    margin-bottom: 12px;
  }

  .calendar-widget.mobile-expanded .digital-clock {
    display: block !important;
  }

  .calendar-widget.mobile-expanded .calendar-header {
    display: flex !important;
  }

  .calendar-widget.mobile-expanded .calendar-weekdays {
    display: grid !important;
  }

  .calendar-widget.mobile-expanded .calendar-days {
    display: grid !important;
  }

  .calendar-widget.mobile-expanded .pickup-items {
    display: flex !important;
    flex-direction: column;
  }

  .calendar-widget.mobile-expanded .mobile-expand-btn {
    position: sticky;
    top: 0;
    z-index: 10;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
  }

  .calendar-widget.mobile-expanded .mobile-pickup-info {
    display: none;
  }

  .calendar-widget.mobile-expanded .mobile-calendar-icon {
    background: rgba(255, 255, 255, 0.2);
  }

  /* デジタル時計のモバイル調整（折りたたみ時は横並び） */
  .calendar-widget.mobile-collapsed .digital-clock {
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-radius: 0;
    padding: 10px 16px;
    margin-bottom: 0;
  }

  .calendar-widget.mobile-collapsed .clock-date {
    font-size: 14px;
    margin-bottom: 0;
  }

  .calendar-widget.mobile-collapsed .clock-time {
    font-size: 22px;
  }

  .calendar-widget.mobile-collapsed .clock-seconds {
    font-size: 12px;
  }

  /* デスクトップの折りたたみ状態を無効化 */
  .calendar-widget.collapsed {
    width: 100%;
    height: auto;
    min-height: auto;
    max-width: none;
    border-radius: 0;
    background: rgba(255, 255, 255, 0.98);
  }

  .calendar-widget.collapsed .calendar-content {
    display: block;
  }

  .calendar-widget.collapsed .calendar-toggle {
    display: none;
  }
}

@media (max-width: 480px) {
  .calendar-day {
    min-height: 48px;
  }

  .calendar-day .cal-doctor {
    font-size: 9px;
  }
}

