/* ホネマチ API連携 */
:root {
	--hfm-primary: #1a7f6e;
	--hfm-text: #1f2933;
	--hfm-muted: #66727f;
	--hfm-border: #dde3e8;
	--hfm-bg: #ffffff;
	--hfm-bg-soft: #f5f7f9;
	--hfm-ok: #1a7f6e;
	--hfm-few: #c27c0e;
	--hfm-full: #9aa5b1;
	--hfm-error: #c0392b;
	--hfm-pr: #d9480f;
	--hfm-radius: 10px;
	--hfm-shadow: 0 6px 24px rgba(15, 23, 42, .16);
}

.hfm-sr-only {
	position: absolute !important;
	width: 1px; height: 1px;
	padding: 0; margin: -1px;
	overflow: hidden; clip: rect(0, 0, 0, 0);
	white-space: nowrap; border: 0;
}

.hfm-loading, .hfm-empty { color: var(--hfm-muted); }
.hfm-error { color: var(--hfm-error); }
.hfm-notice { padding: .75em 1em; border-left: 4px solid var(--hfm-few); background: #fff8e6; }

/* ボタン */
.hfm-button {
	display: inline-flex; align-items: center; justify-content: center;
	padding: .6em 1.2em;
	border: 1px solid var(--hfm-primary); border-radius: 999px;
	background: var(--hfm-primary); color: #fff;
	font-size: 1em; font-weight: 600; line-height: 1.2;
	text-decoration: none; cursor: pointer;
	transition: opacity .15s;
}
.hfm-button:hover, .hfm-button:focus-visible { opacity: .85; color: #fff; text-decoration: none; }
.hfm-button:disabled { opacity: .5; cursor: default; }
.hfm-button--small { padding: .4em .9em; font-size: .85em; }
.hfm-button--ghost { background: transparent; color: var(--hfm-primary); }
.hfm-button--ghost:hover, .hfm-button--ghost:focus-visible { color: var(--hfm-primary); background: var(--hfm-bg-soft); }

/* ------------------------------------------------------------------
 * 店舗カード
 * ------------------------------------------------------------------ */
.hfm-card-list { display: grid; gap: 16px; }
.hfm-card {
	display: flex; gap: 16px;
	padding: 16px;
	border: 1px solid var(--hfm-border); border-radius: var(--hfm-radius);
	background: var(--hfm-bg); color: var(--hfm-text);
}
.hfm-card--pr { border-color: var(--hfm-pr); }
.hfm-card__photo { flex: 0 0 160px; }
.hfm-card__photo img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: 6px; display: block; }
.hfm-card__body { flex: 1 1 auto; min-width: 0; }
.hfm-card__name { margin: 0 0 .3em; font-size: 1.1em; line-height: 1.4; }
.hfm-card__name a { color: inherit; }
.hfm-badge {
	display: inline-block; margin-right: .2em;
	color: var(--hfm-pr); font-size: .85em; font-weight: 700; vertical-align: baseline;
}
.hfm-card__meta { margin: 0 0 .3em; color: var(--hfm-muted); font-size: .9em; }
.hfm-card__stats { display: flex; flex-wrap: wrap; gap: .8em; margin: 0 0 .5em; font-size: .9em; }
.hfm-card__star { color: #f5a623; margin-right: .15em; }
.hfm-card__reviews { color: var(--hfm-muted); }
.hfm-card__price { font-weight: 700; }
.hfm-card__appeal { margin: 0 0 .5em; padding-left: 1.2em; font-size: .9em; }
.hfm-card__chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 .6em; padding: 0; list-style: none; }
.hfm-chip { padding: .15em .6em; border-radius: 999px; background: var(--hfm-bg-soft); font-size: .78em; color: var(--hfm-muted); }
.hfm-chip--symptom { background: color-mix(in srgb, var(--hfm-primary) 12%, #fff); color: var(--hfm-primary); }
.hfm-card__actions { display: flex; flex-wrap: wrap; gap: 8px; }
.hfm-card__calendar { margin-top: 12px; }

.hfm-card--compact { flex-direction: column; gap: 8px; padding: 12px; font-size: .92em; }
.hfm-card--compact .hfm-card__photo { flex-basis: auto; }
.hfm-card--compact .hfm-card__photo img { aspect-ratio: 16 / 9; }
.hfm-card--compact .hfm-card__name { font-size: 1em; }

@media (max-width: 600px) {
	.hfm-card { flex-direction: column; }
	.hfm-card__photo { flex-basis: auto; }
	.hfm-card__photo img { aspect-ratio: 16 / 9; }
}

/* ------------------------------------------------------------------
 * 予約カレンダー
 * ------------------------------------------------------------------ */
.hfm-calendar { color: var(--hfm-text); transition: opacity .15s; }
.hfm-calendar.hfm-is-loading .hfm-calendar__scroll { opacity: .5; }
.hfm-calendar__nav { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.hfm-calendar__nav button {
	padding: .35em .8em; border: 1px solid var(--hfm-border); border-radius: 6px;
	background: var(--hfm-bg); color: var(--hfm-text); font-size: .9em; cursor: pointer;
}
.hfm-calendar__nav button:disabled { opacity: .4; cursor: default; }
.hfm-calendar__range { font-weight: 700; }
.hfm-calendar__scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.hfm-calendar__table { width: 100%; min-width: 280px; border-collapse: collapse; table-layout: fixed; margin: 0; font-size: .9em; }
.hfm-calendar__table th, .hfm-calendar__table td {
	padding: 6px 2px; border: 1px solid var(--hfm-border); text-align: center; vertical-align: middle;
}
.hfm-calendar__table thead th { background: var(--hfm-bg-soft); font-weight: 600; line-height: 1.3; }
.hfm-calendar__corner, .hfm-calendar__time { width: 4.2em; }
.hfm-calendar__time { background: var(--hfm-bg-soft); font-weight: 500; white-space: nowrap; }
.hfm-calendar__date, .hfm-calendar__weekday, .hfm-calendar__closed { display: block; }
.hfm-calendar__weekday { font-size: .85em; }
.hfm-calendar__closed { font-size: .75em; color: var(--hfm-muted); }
.hfm-wd-sat .hfm-calendar__weekday { color: #1c64c8; }
.hfm-wd-sun .hfm-calendar__weekday { color: #c0392b; }
.hfm-calendar__day.is-closed { color: var(--hfm-muted); }

.hfm-mark { display: inline-block; min-width: 1.6em; font-weight: 700; line-height: 1.6; text-decoration: none; }
.hfm-mark--ok { color: var(--hfm-ok); }
.hfm-mark--few { color: var(--hfm-few); }
.hfm-mark--full, .hfm-mark--none { color: var(--hfm-full); font-weight: 400; }
a.hfm-mark { border-radius: 4px; }
a.hfm-mark:hover, a.hfm-mark:focus-visible { background: color-mix(in srgb, currentColor 14%, transparent); }
.hfm-cell--none { background: var(--hfm-bg-soft); }
.hfm-calendar__legend { margin: 8px 0 0; color: var(--hfm-muted); font-size: .8em; }
.hfm-calendar__legend .hfm-mark { min-width: 0; }
.hfm-calendar__unavailable { padding: 12px 16px; border-radius: var(--hfm-radius); background: var(--hfm-bg-soft); }
.hfm-calendar__unavailable p { margin: 0 0 .6em; }

/* ------------------------------------------------------------------
 * 店舗検索
 * ------------------------------------------------------------------ */
.hfm-search { color: var(--hfm-text); }
.hfm-search__form {
	display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px 16px;
	margin-bottom: 20px; padding: 16px;
	border-radius: var(--hfm-radius); background: var(--hfm-bg-soft);
}
.hfm-field label { display: block; margin-bottom: 4px; font-size: .88em; font-weight: 600; }
.hfm-field input, .hfm-field select {
	width: 100%; box-sizing: border-box; padding: .5em .6em;
	border: 1px solid var(--hfm-border); border-radius: 6px; background: #fff; font-size: 1em;
}
.hfm-required { color: var(--hfm-error); }
.hfm-search__actions { grid-column: 1 / -1; text-align: center; }

/* ベータ版表示 */
.hfm-beta { display: inline-block; margin-left: .25em; padding: 1px 6px; border: 1px solid currentColor; border-radius: 3px; font-size: .72em; font-weight: 700; line-height: 1.4; vertical-align: middle; white-space: nowrap; }
.hfm-notice { margin: 12px 0 0; color: var(--hfm-muted); font-size: .8rem; line-height: 1.6; }
.hfm-notice .hfm-beta { margin: 0 .25em 0 0; color: #c2410c; }
.hfm-modal__notice { flex: 0 0 auto; margin: 12px 20px 0; padding: 8px 10px; background: var(--hfm-bg-soft); border-radius: 6px; }
.hfm-search__actions .hfm-button { min-width: 200px; }
.hfm-search__count { margin: 0 0 12px; font-weight: 600; }
.hfm-search__more { margin-top: 16px; text-align: center; }

/* ------------------------------------------------------------------
 * TOPページ用 店舗検索 ([honefix_top_search])
 * ------------------------------------------------------------------ */
.hfm-top-search { width: 100%; max-width: 880px; margin: 0 auto; color: var(--hfm-text); text-align: left; }
.hfm-top-search__form {
	display: flex; align-items: stretch;
	padding: 8px;
	border-radius: 16px; background: rgba(255, 255, 255, .97);
	box-shadow: 0 10px 30px rgba(15, 23, 42, .18);
}
.hfm-top-search__field {
	position: relative; flex: 1 1 0; min-width: 0;
	display: flex; flex-direction: column; justify-content: center;
	padding: 6px 16px;
}
.hfm-top-search__field + .hfm-top-search__field::before {
	content: ""; position: absolute; left: 0; top: 14px; bottom: 14px; width: 1px; background: var(--hfm-border);
}
.hfm-top-search__field label { margin: 0 0 2px; color: var(--hfm-muted); font-size: 12px; font-weight: 700; letter-spacing: .04em; }
.hfm-top-search__control {
	width: 100%; box-sizing: border-box; margin: 0; padding: 4px 0;
	border: 0; border-radius: 0; background: transparent; box-shadow: none;
	color: var(--hfm-text); font-size: 16px; line-height: 1.5;
	-webkit-appearance: none; appearance: none;
}
select.hfm-top-search__control {
	padding-right: 20px; cursor: pointer;
	background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24'%3E%3Cpath fill='%2366727f' d='M12 15.5 5.5 9l1.4-1.4 5.1 5.1 5.1-5.1L18.5 9z'/%3E%3C/svg%3E") no-repeat right center;
}
.hfm-top-search__control:focus { outline: none; }
.hfm-top-search__field:focus-within { border-radius: 10px; box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--hfm-primary) 45%, transparent); }
.hfm-top-search__control[aria-invalid="true"] { color: var(--hfm-error); }
.hfm-top-search__field:has([aria-invalid="true"]) { border-radius: 10px; box-shadow: inset 0 0 0 2px var(--hfm-error); }
.hfm-top-search__submit {
	flex: 0 0 auto; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
	min-width: 140px; padding: 0 24px;
	border: 0; border-radius: 12px; background: var(--hfm-primary); color: #fff;
	font-size: 16px; font-weight: 700; cursor: pointer; transition: opacity .15s;
}
.hfm-top-search__submit:hover { opacity: .9; }
.hfm-top-search__submit:focus-visible { outline: 3px solid color-mix(in srgb, var(--hfm-primary) 40%, #fff); outline-offset: 2px; }
.hfm-top-search__submit:disabled { opacity: .6; cursor: progress; }
.hfm-top-search__message {
	display: inline-block; margin: 10px 0 0; padding: 6px 12px;
	border-radius: 8px; background: #fff; color: var(--hfm-error); font-size: 14px; font-weight: 600;
	box-shadow: 0 4px 12px rgba(15, 23, 42, .12);
}
.hfm-top-search__message[hidden] { display: none; }

@media (max-width: 720px) {
	.hfm-top-search__form { flex-direction: column; padding: 8px; }
	.hfm-top-search__field { padding: 10px 12px; }
	.hfm-top-search__field + .hfm-top-search__field::before { left: 12px; right: 12px; top: 0; bottom: auto; width: auto; height: 1px; }
	.hfm-top-search__submit { min-height: 52px; margin-top: 6px; }
}

/* ------------------------------------------------------------------
 * 検索結果モーダル
 * ------------------------------------------------------------------ */
html.hfm-modal-open { overflow: hidden; }
.hfm-modal {
	width: min(960px, calc(100vw - 32px)); max-width: none;
	height: fit-content; max-height: calc(100vh - 48px); max-height: calc(100dvh - 48px);
	margin: auto; padding: 0;
	border: 0; border-radius: 16px; background: var(--hfm-bg); color: var(--hfm-text);
	box-shadow: 0 20px 60px rgba(15, 23, 42, .35);
	overflow: hidden;
}
.hfm-modal[open] { display: flex; }
.hfm-modal::backdrop { background: rgba(15, 23, 42, .55); }
/* showModal 非対応ブラウザ向け */
.hfm-modal--fallback[open] { position: fixed; inset: 0; z-index: 100000; }
.hfm-modal__inner { display: flex; flex-direction: column; width: 100%; min-height: 0; }
.hfm-modal__header {
	display: flex; align-items: flex-start; gap: 12px;
	padding: 18px 20px 14px; border-bottom: 1px solid var(--hfm-border);
}
.hfm-modal__heading { flex: 1 1 auto; min-width: 0; }
.hfm-modal__title { margin: 0; font-size: 1.25rem; line-height: 1.4; }
.hfm-modal__summary { margin: 2px 0 0; color: var(--hfm-muted); font-size: .88rem; overflow-wrap: anywhere; }
.hfm-modal__close {
	flex: 0 0 auto; width: 40px; height: 40px; padding: 0;
	border: 0; border-radius: 50%; background: var(--hfm-bg-soft); color: var(--hfm-text);
	font-size: 24px; line-height: 1; cursor: pointer;
}
.hfm-modal__close:hover { background: var(--hfm-border); }
.hfm-modal__body { flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 20px; }
.hfm-modal__count { margin: 0 0 14px; }
.hfm-modal__count strong { font-size: 1.3em; color: var(--hfm-primary); }
.hfm-modal__more { margin-top: 16px; text-align: center; }
.hfm-modal__actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; margin-top: 20px; }
.hfm-modal__state { padding: 32px 8px; text-align: center; }
.hfm-modal__state-title { margin: 0 0 8px; font-size: 1.1rem; font-weight: 700; }
.hfm-modal__state-text { max-width: 32em; margin: 0 auto; color: var(--hfm-muted); }
.hfm-modal__state--error .hfm-modal__state-title { color: var(--hfm-error); }

@media (max-width: 600px) {
	.hfm-modal { width: 100vw; height: 100%; max-height: none; border-radius: 0; }
	.hfm-modal__header { padding: 14px 16px 12px; }
	.hfm-modal__body { padding: 16px; }
	.hfm-modal__notice { margin: 10px 16px 0; }
}

/* スケルトンローダー */
.hfm-skeleton { pointer-events: none; }
.hfm-skeleton .hfm-card__body { display: flex; flex-direction: column; gap: 10px; }
.hfm-skeleton__block {
	border-radius: 6px;
	background: linear-gradient(90deg, #e9edf1 0%, #f5f7f9 40%, #e9edf1 80%) 0 0 / 300% 100%;
	animation: hfm-shimmer 1.4s ease-in-out infinite;
}
.hfm-skeleton__photo { width: 100%; aspect-ratio: 4 / 3; }
.hfm-skeleton__line { height: 12px; width: 100%; }
.hfm-skeleton__line--title { height: 20px; width: 55%; }
.hfm-skeleton__line--short { width: 35%; }
.hfm-skeleton__line--mid { width: 75%; }
.hfm-skeleton__chips { display: flex; gap: 6px; }
.hfm-skeleton__chip { width: 56px; height: 20px; border-radius: 999px; }
@keyframes hfm-shimmer {
	0% { background-position: 100% 0; }
	100% { background-position: 0 0; }
}
@media (max-width: 600px) {
	.hfm-skeleton__photo { aspect-ratio: 16 / 9; }
}
@media (prefers-reduced-motion: reduce) {
	.hfm-skeleton__block { animation: none; }
}

/* ------------------------------------------------------------------
 * AI相談 (フローティングチャット)
 * ------------------------------------------------------------------ */
.hfm-chat { position: fixed; bottom: 20px; z-index: 99990; color: var(--hfm-text); font-size: 15px; line-height: 1.6; }
.hfm-chat--right { right: 20px; }
.hfm-chat--left { left: 20px; }

.hfm-chat__launcher {
	display: flex; align-items: center; justify-content: center;
	width: 60px; height: 60px; padding: 0;
	border: 0; border-radius: 50%;
	background: var(--hfm-primary); color: #fff;
	box-shadow: var(--hfm-shadow); cursor: pointer;
	transition: transform .15s;
}
.hfm-chat__launcher:hover { transform: scale(1.06); }
.hfm-chat__launcher:focus-visible { outline: 3px solid color-mix(in srgb, var(--hfm-primary) 40%, #fff); outline-offset: 2px; }
.hfm-chat__icon-close { display: none; }
.hfm-chat.is-open .hfm-chat__icon-open { display: none; }
.hfm-chat.is-open .hfm-chat__icon-close { display: block; }
.hfm-chat--left .hfm-chat__launcher { margin-right: auto; }
.hfm-chat--right .hfm-chat__launcher { margin-left: auto; }

.hfm-chat__panel {
	position: absolute; bottom: 76px;
	display: flex; flex-direction: column;
	width: 380px; max-width: calc(100vw - 40px);
	height: 600px; max-height: calc(100vh - 120px);
	overflow: hidden;
	border-radius: 14px; background: var(--hfm-bg);
	box-shadow: var(--hfm-shadow);
}
.hfm-chat__panel[hidden] { display: none; }
.hfm-chat--right .hfm-chat__panel { right: 0; }
.hfm-chat--left .hfm-chat__panel { left: 0; }

.hfm-chat__header {
	display: flex; align-items: center; gap: 8px;
	padding: 12px 14px; background: var(--hfm-primary); color: #fff;
}
.hfm-chat__title { flex: 1 1 auto; font-weight: 700; }
.hfm-chat__reset, .hfm-chat__close {
	padding: 2px 8px; border: 0; border-radius: 6px;
	background: transparent; color: #fff; cursor: pointer; line-height: 1.4;
}
.hfm-chat__reset { font-size: .8em; border: 1px solid rgba(255, 255, 255, .6); }
.hfm-chat__close { font-size: 1.5em; }
.hfm-chat__reset:hover, .hfm-chat__close:hover { background: rgba(255, 255, 255, .15); }

.hfm-chat__log { flex: 1 1 auto; overflow-y: auto; padding: 14px; background: var(--hfm-bg-soft); }
.hfm-msg { max-width: 88%; margin-bottom: 12px; }
.hfm-msg--user { margin-left: auto; }
.hfm-msg__text {
	padding: 10px 12px; border-radius: 12px;
	white-space: pre-wrap; word-break: break-word;
}
.hfm-msg--bot .hfm-msg__text { background: var(--hfm-bg); border: 1px solid var(--hfm-border); border-top-left-radius: 4px; }
.hfm-msg--user .hfm-msg__text { background: var(--hfm-primary); color: #fff; border-top-right-radius: 4px; }
.hfm-msg--error .hfm-msg__text { border-color: var(--hfm-error); color: var(--hfm-error); }
.hfm-msg--bot:has(.hfm-msg__clinics) { max-width: 100%; }
.hfm-msg__note { margin: 6px 0 0; color: var(--hfm-muted); font-size: .82em; }
.hfm-msg__clinics { display: grid; gap: 10px; margin-top: 10px; }
.hfm-msg__clinics .hfm-calendar__table { font-size: .8em; }

.hfm-msg--typing {
	display: inline-flex; gap: 4px; padding: 12px 14px;
	border: 1px solid var(--hfm-border); border-radius: 12px; border-top-left-radius: 4px; background: var(--hfm-bg);
}
.hfm-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--hfm-muted); animation: hfm-bounce 1.2s infinite ease-in-out; }
.hfm-dot:nth-child(2) { animation-delay: .15s; }
.hfm-dot:nth-child(3) { animation-delay: .3s; }
@keyframes hfm-bounce {
	0%, 80%, 100% { opacity: .3; transform: translateY(0); }
	40% { opacity: 1; transform: translateY(-4px); }
}
@media (prefers-reduced-motion: reduce) {
	.hfm-dot { animation: none; }
	.hfm-chat__launcher, .hfm-chat.is-scroll-hidden .hfm-chat__launcher { transition: none; }
}

.hfm-chat__form { display: flex; align-items: flex-end; gap: 8px; padding: 10px; border-top: 1px solid var(--hfm-border); background: var(--hfm-bg); }
.hfm-chat__input {
	flex: 1 1 auto; box-sizing: border-box; min-height: 44px; max-height: 120px; margin: 0;
	padding: 8px 10px; border: 1px solid var(--hfm-border); border-radius: 8px;
	font: inherit; resize: none;
}
.hfm-chat__send {
	flex: 0 0 auto; height: 44px; padding: 0 16px;
	border: 0; border-radius: 8px; background: var(--hfm-primary); color: #fff;
	font-weight: 700; cursor: pointer;
}
.hfm-chat__send:disabled { opacity: .5; cursor: default; }
.hfm-chat__note { margin: 0; padding: 0 10px 8px; background: var(--hfm-bg); color: var(--hfm-muted); font-size: .72em; }

@media (max-width: 480px) {
	/* 追従バナーの上に置く。--hfm-chat-avoid は JS がバナーを測って入れる値 (セレクタ指定時) */
	.hfm-chat { bottom: var(--hfm-chat-avoid, calc(var(--hfm-chat-mobile-bottom, 16px) + env(safe-area-inset-bottom, 0px))); }
	/* ページ最下部では隠す (上へスクロールすると再表示) */
	.hfm-chat__launcher { transition: transform .25s, opacity .25s, visibility 0s; }
	.hfm-chat.is-scroll-hidden .hfm-chat__launcher {
		transform: translateY(16px) scale(.85); opacity: 0; visibility: hidden; pointer-events: none;
		transition: transform .25s, opacity .25s, visibility 0s .25s;
	}
	.hfm-chat--right { right: 16px; }
	.hfm-chat--left { left: 16px; }
	.hfm-chat__panel {
		position: fixed; inset: 0; bottom: 0;
		width: 100%; max-width: none; height: 100%; max-height: none; border-radius: 0;
	}
	.hfm-chat.is-open .hfm-chat__launcher { display: none; }
}
