:root {
  --bg: #f6f7f9;
  --card: #fff;
  --text: #222;
  --muted: #667085;
  --placeholder: #ccc;
  --line: #d0d5dd;
  --primary: #1f6feb;
  --primary2: #d99;
  --primary-dark: #1557bd;
  --selected: #0f766e;
  --danger-bg: #fff3f3;
  --danger-text: #b42318;
  --notice-bg: #fff8e6;
  --disable-bg: #f2f4f7;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.6;
}

.app-shell {
  width: min(1120px, 100%);
  height: 100dvh;
  margin: 0 auto;
  padding: 12px;
  overflow: hidden;
}

.card {
  height: 100%;
  background: var(--card);
  display: grid;
  grid-template-rows: auto auto 1fr;
  overflow: hidden;
  border: 1px solid #eaecf0;
  border-radius: 20px;
  box-shadow: 0 12px 28px rgba(16, 24, 40, .08);
  padding: clamp(18px, 4vw, 36px);
}

h1 {
  font-size: clamp(22px, 4vw, 32px);
  margin: 0 0 8px;
}

.lead {
  color: var(--muted);
  padding-left: 1rem;
  font-size: smaller;
}

.page {
  display: none;
  min-height: 0;
}

.page.is-active {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) 64px;
  height: 100%;
  min-height: 0;
  overflow: hidden;
}

.page-header {
  min-height: 0;
  overflow: visible;
}

.page-content {
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 12px 4px;
}
.page-content .btn{
  min-height: 30px;
}

.page-footer {
  height: 64px;
  display: grid;
  align-items: center;
  grid-template-columns: 1fr;
  gap: 10px;
  padding-top: 10px;
  border-top: 1px solid #eaecf0;
  background: #fff;
}

.page-footer.two-buttons {
  grid-template-columns: 1fr 1fr;
}

.page-footer.three-buttons {
  grid-template-columns: 1fr 1fr 1fr;
}


.page-footer .btn {
  width: 100%;
  height: 44px;
}

/* 進捗バー */
.progress {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
  margin-bottom: 28px;
  flex: none;
}

.progress-item {
  height: 6px;
  width: auto;
  border: 0;
  border-radius: 999px;
  background: #e4e7ec;
  color: transparent;
  font-size: 0;
  pointer-events: none;
}

.progress-item.is-active{
  background: var(--primary);
}

.progress-item::after {
  content: attr(data-step-dot);
  display: block;
  margin-top: 10px;
  color: #98a2b3;
  font-size: 11px;
  font-weight: 600;
  text-align: center;
}

.progress-item.is-active::after {
  color: var(--primary);
}

.alert {
  padding: 12px;
  background: var(--danger-bg);
  color: var(--danger-text);
  border-radius: 12px;
  margin-bottom: 18px;
  flex: none;
}

/*=================================*/
/*======== 1ページ目 相談内容 =======*/
/*=================================*/
.counseling input[type="checkbox"] {
  width: 1rem;
  transform: scale(1.2);
  margin: 0.4rem 0.5rem 0 1rem;
}
.counseling input[type="checkbox"]:checked {
  accent-color: var(--selected);
}
.counselingCategory{
  background-color:lightslategray;
  color: white;
  text-align: center;
  box-sizing: border-box;
}
.counseling label{
  display:flex;
  align-items:flex-start;
  gap:0.5rem;
  min-height:2.5rem;
}


.counseling label span{
  flex:1;
  word-break:break-word;
}

.consultation-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  margin: 0 4px -1px;
  position: relative;
  z-index: 2;
}

.consultation-tab {
  appearance: none;
  border: 1px solid var(--line);
  border-bottom-color: var(--line);
  border-radius: 14px 14px 0 0;
  padding: 12px 10px;
  background: #fff;
  color: #475467;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  min-height: 48px;
  box-shadow: inset 0 -1px 0 rgba(16, 24, 40, .04);
}

.consultation-tab:hover {
  background: #fff;
  color: var(--text);
}

.consultation-tab.is-active {
  background: var(--disable-bg);
  color: var(--text);
  border-color: var(--line);
  border-bottom-color: var(--disable-bg);
  box-shadow: none;
}

.page[data-page="1"] .page-content {
  padding-top: 0;
}

.consultation-panel {
  border: 1px solid var(--line);
  border-radius: 0 0 14px 14px;
  background: var(--disable-bg);
  padding: 12px;
}

.consultation-panel[hidden] {
  display: none;
}

/*=================================*/
/*======== 2ページ目 日時選択 =======*/
/*=================================*/
.summary-box {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px;
  background: #fcfcfd;
  margin: 16px 0;
  line-height: 1.2;
}

.total {
  margin-top: 8px;
  font-weight: 700;
}

.notice {
  padding: 12px;
  border-radius: 12px;
  background: var(--notice-bg);
  color: #7a4d00;
}

.calendar-toolbar {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 10px;
  margin: 16px 0;
}

.week-range {
  text-align: center;
  font-weight: 700;
}

.calendar-swipe-area {
  height: 100%;
  min-height: 0;
  overflow: hidden;
  touch-action: pan-y;
}

.calendar {
  height: 100%;
  min-height: 0;
  display: grid;
  font-size: 12px;
  /*カレンダーのヘッダ（時間）の幅を決め、残りを7枠で均等割する*/
  grid-template-columns: 44px repeat(7, 1fr);
  overflow: auto;
}
.calendar[hidden]{
  display: none!important;
}


.calendar-cell {
  border-left: 1px solid var(--line);
  border-top: 1px solid var(--line);
  min-height: 42px;
  padding: 8px;
  background: #fff;
  font-size: 13px;
}

.calendar-cell.header {
  position: sticky;
  top: 0;
  z-index: 2;
  background: #f9fafb;
  font-weight: 700;
  text-align: center;
  line-height: 1.1;
  padding: auto;
  border-bottom: 3px double #bbb;
}
/*----- 左上 ------*/
.calendar-cell.corner {
  position: sticky;
  top: 0;
  z-index: 2;
  font-weight: 700;
  text-align: center;
  line-height: 1.1;
  padding: auto;
  background: white;
  border: none;
}
.calendar-cell.time {
  position: sticky;
  right: 0;
  z-index: 1;
  background: #f9fafb;
  color: var(--muted);
  border: none;
  background: none;
  text-align: right;
  padding: 6px 0!important;
}
.calendar-cell.hour {
  color: var(--primary);
  font-weight: bold;
  font-size: 120%;

}
.calendar-cell.slot {
  cursor: pointer;
  text-align: center;
}

.calendar-cell.slot:hover {
  outline: 2px solid var(--primary);
  outline-offset: -2px;
}

.calendar-cell.slot.is-selected {
  background: var(--selected);
  color: #fff;
  font-weight: 700;
}

.calendar-cell.disabled {
  color: #aaa;
  background: var(--disable-bg);
  cursor: not-allowed;
}
.calendar-cell.disabled_counseling {
  color: #aaa;
  background: var(--disable-bg);
  cursor: not-allowed;
}
.calendar-cell.holiday{
  color: var(--line);
}
.calendar-cell.rightSide{
  border-right: 1px solid var(--line);
}
.calendar-cell.bottom{
  border-bottom: 1px solid var(--line);
}


/*===============================*/
/*==== 3ページ目　個人情報の入力 ====*/
/*===============================*/
em{
  color: var(--danger-text);
  font-weight: normal;
  font-style: normal;
  display:inline;
}
/*--- 初診／再診のradio ---*/
.radio-group {
  display: grid;
  gap: 12px;
}

.radio-group > p {
  margin: 0 0 4px;
  font-weight: 700;
  font-size: 14px;
  color: #444;
}

.radio-label {
  display: flex;
  align-items: center;
  gap: 10px;

  padding: 14px 16px;
  border: 1px solid #d7dbe0;
  border-radius: 12px;

  background: #fff;
  cursor: pointer;

  transition:
    border-color 0.2s,
    background-color 0.2s,
    box-shadow 0.2s;
}

.radio-label:hover {
  border-color: #999;
}

.radio-label input[type="radio"] {
  margin: 0;
  width: 18px;
  height: 18px;
  accent-color: #222;
}

/* 選択状態 */
.radio-label:has(input[type="radio"]:checked) {
  border-color: #222;
  background: #f7f7f7;
  box-shadow: 0 0 0 1px #222 inset;
}
/*--- 初診／再診のradio 終わり ---*/


.form-grid {
  display: grid;
  gap: 16px;
}

label {
  display: grid;
  gap: 6px;
  font-weight: 700;
}

input,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
  font: inherit;
  font-weight: 400;
}


input::-webkit-input-placeholder {
  color: var(--placeholder);
}
input::-moz-placeholder {
  color: var(--placeholder);
}
input:-ms-input-placeholder {
  color: var(--placeholder);
}
input::placeholder {
  color: var(--placeholder);
}

.btn {
  border: 0;
  border-radius: 999px;
  padding: 0 18px;
  font-weight: 700;
  cursor: pointer;
}

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

.btn.primary:hover {
  background: var(--primary-dark);
}

.btn.secondary {
  background: #e4e7ec;
  color: #344054;
}

.birthdate-inputs {
  display: grid;
  grid-template-columns: minmax(5.8em, 1.1fr) minmax(4.2em, .8fr) minmax(4.2em, .8fr);
  gap: 6px;
  width: 100%;
  margin-bottom: 5rem;
}

.birthdate-inputs select {
  min-width: 0;
  padding: 12px 8px;
  font-size: 16px;
}



/*---     予約済みの場合のコンタクトボタン     ---*/
.contact-buttons {
  gap: 12px;
  grid-template-columns: repeat(3, 1fr);
  display: none;
  max-height: 4rem;
}

.contact-button {
  width:100%;
  text-decoration:none;
  display:flex;
  align-items:center;
  justify-content:center;

  text-align: center;
  background: var(--primary2);
  color: white;
  border-radius: 30px;
  min-height: 36px;
  max-height: 3rem;
}



/* ====================== */
/*     ローディング表示     */
/* ====================== */
.btn.is-loading {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.btn-spinner {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255,255,255,.35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: btn-spin .8s linear infinite;
  flex-shrink: 0;
}


.btn.ghost {
  background: #fff;
  color: var(--primary);
  border: 1px solid var(--primary);
}
.btn.ghost.is-loading .btn-spinner {
  border-color: rgba(31,111,235,.2);
  border-top-color: var(--primary);
}

.btn:disabled {
  opacity: .45;
  cursor: not-allowed;
}

.complete-message {
  font-size: 20px;
  font-weight: 700;
  color: var(--danger-text);
}


/*------ オーバーレイ -------*/
.message-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: rgba(0, 0, 0, 0.45);
  display: grid;
  place-items: center;
  padding: 24px;
}

.message-overlay__box {
  width: min(92vw, 420px);
  max-height: 80dvh;
  overflow-y: auto;

  background: #fff;
  border-radius: 16px;
  padding: 24px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.2);
  text-align: left;
}

.message-overlay__box p {
  margin: 0 0 16px;
  line-height: 1.7;
}

.message-overlay__box .btn {
  width: 100%;
  padding: 0.2rem 0;
  margin-top: 8px;
  min-height: 30px;
}

.message-overlay__list {
  margin: 0 0 20px;
  padding: 0;
  list-style: none;
}

.message-overlay__list li {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin-bottom: 2rem;
  line-height: 1.7;
}

.note-mark {
  color: var(--danger-text);
  flex-shrink: 0;
  font-weight: bold;
}

.message-overlay__buttons {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 20px;
}
/*------ オーバーレイ 終わり -------*/



@media (max-width: 760px) {
  .app-shell {
    padding: 8px;
  }

  .card {
    border-radius: 14px;
    padding: 16px;
  }

  .page.is-active {
    grid-template-rows: auto minmax(0, 1fr) 64px;
  }


  .calendar-cell {
    padding: 6px;
    min-height: 38px;
  }

  .btn {
    width: 100%;
    font-size: medium;
  }

  .counseling input[type="checkbox"] {
    transform: scale(0.9);
  }
  .counseling span{
    padding-top: 0.4rem;
  }
}

@keyframes btn-spin {
  to {
    transform: rotate(360deg);
  }
}