/* 西野工房 AIチャット。色はQ&Aページの紺と茶系に合わせる */
.enc {
	--enc-navy: #122a52;
	--enc-paper: #f3ece1;
	--enc-line: #ddccb0;
	--enc-text: #2b2b2b;
	--enc-muted: #6b6255;
	position: fixed;
	right: 16px;
	bottom: 16px;
	z-index: 99990;
	font-size: 15px;
	line-height: 1.7;
	color: var(--enc-text);
}

.enc *,
.enc *::before,
.enc *::after {
	box-sizing: border-box;
}

.enc-toggle {
	padding: 12px 18px;
	border: 0;
	border-radius: 999px;
	background: var(--enc-navy);
	color: #fff;
	font: inherit;
	font-weight: bold;
	cursor: pointer;
	box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
}

.enc-toggle:focus-visible,
.enc-close:focus-visible,
.enc-send:focus-visible,
.enc-input:focus-visible,
.enc-link:focus-visible,
.enc-product:focus-visible,
.enc-contact:focus-visible {
	outline: 3px solid #c8772f;
	outline-offset: 2px;
}

.enc-panel {
	display: flex;
	flex-direction: column;
	width: 380px;
	height: min(600px, calc(100vh - 32px));
	border: 1px solid var(--enc-line);
	border-radius: 8px;
	background: #fff;
	box-shadow: 0 4px 20px rgba(0, 0, 0, 0.25);
	overflow: hidden;
}

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

.enc-head {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 10px 14px;
	background: var(--enc-navy);
	color: #fff;
}

/* テーマの h2 の飾りを打ち消す */
.enc .enc-title {
	margin: 0;
	padding: 0;
	border: 0;
	background: none;
	color: #fff;
	font-size: 16px;
	line-height: 1.4;
}

.enc .enc-title::before,
.enc .enc-title::after {
	content: none;
}

.enc-close {
	padding: 4px 10px;
	border: 1px solid rgba(255, 255, 255, 0.6);
	border-radius: 4px;
	background: transparent;
	color: #fff;
	font: inherit;
	font-size: 13px;
	cursor: pointer;
}

.enc-log {
	flex: 1;
	padding: 12px;
	overflow-y: auto;
	background: #faf7f2;
}

.enc-msg {
	max-width: 88%;
	margin: 0 0 10px;
	padding: 8px 12px;
	border-radius: 8px;
}

.enc-bot {
	margin-right: auto;
	background: var(--enc-paper);
}

.enc-user {
	margin-left: auto;
	background: var(--enc-navy);
	color: #fff;
}

.enc .enc-text {
	margin: 0;
	padding: 0;
	white-space: pre-wrap;
	overflow-wrap: anywhere;
}

.enc-pending .enc-text {
	color: var(--enc-muted);
}

.enc .enc-link,
.enc .enc-product,
.enc .enc-contact {
	display: block;
	margin-top: 6px;
	font-size: 14px;
}

/* 商品一覧へのボタン（お問い合わせより目立たせる） */
.enc .enc-product {
	padding: 6px 10px;
	border-radius: 4px;
	background: var(--enc-navy);
	color: #fff;
	text-align: center;
	text-decoration: none;
	font-weight: bold;
}

.enc .enc-link {
	color: var(--enc-navy);
	text-decoration: underline;
}

.enc .enc-contact {
	padding: 6px 10px;
	border: 1px solid var(--enc-navy);
	border-radius: 4px;
	background: #fff;
	color: var(--enc-navy);
	text-align: center;
	text-decoration: none;
	font-weight: bold;
}

.enc .enc-debug {
	margin: 6px 0 0;
	color: var(--enc-muted);
	font-size: 12px;
}

.enc .enc-notes {
	padding: 6px 12px;
	border-top: 1px solid var(--enc-line);
}

.enc .enc-note {
	margin: 0;
	color: var(--enc-muted);
	font-size: 12px;
	line-height: 1.5;
}

/* 個人情報の注意は読み飛ばされないよう、本文の色で太字にする */
.enc .enc-note-privacy {
	margin-bottom: 2px;
	color: var(--enc-text);
	font-weight: bold;
}

.enc-form {
	padding: 8px 12px 12px;
	border-top: 1px solid var(--enc-line);
}

.enc-label {
	position: absolute;
	width: 1px;
	height: 1px;
	overflow: hidden;
	clip: rect(0 0 0 0);
	white-space: nowrap;
}

.enc .enc-input {
	display: block;
	width: 100%;
	margin: 0;
	padding: 8px;
	border: 1px solid #b9ab94;
	border-radius: 4px;
	font: inherit;
	font-size: 16px; /* iPhone で入力時に拡大されないように 16px 以上 */
	resize: none;
}

.enc-row {
	display: flex;
	align-items: center;
	justify-content: space-between;
	margin-top: 6px;
}

.enc-count {
	color: var(--enc-muted);
	font-size: 12px;
}

.enc-send {
	padding: 6px 20px;
	border: 0;
	border-radius: 4px;
	background: var(--enc-navy);
	color: #fff;
	font: inherit;
	font-weight: bold;
	cursor: pointer;
}

.enc-send:disabled,
.enc-input:disabled {
	opacity: 0.5;
	cursor: not-allowed;
}

@media (max-width: 600px) {
	.enc {
		right: 12px;
		bottom: 12px;
	}

	.enc-panel {
		position: fixed;
		right: 0;
		bottom: 0;
		left: 0;
		width: auto;
		height: 85vh;
		border-radius: 8px 8px 0 0;
	}
}

/*
 * 本番の固定メニュー（共通コンテンツ51921・2026-10-27〜）と重ならない位置にする（2026-11-04）
 * 固定メニューの script が <html> に付ける印（nisino-desktop-dock-ready / nisino-dock-ready）があるときだけ動かす
 */
@media (min-width: 768px) {
	/* 右下の「上へ」の丸（右20px・下20px・64px角）の左に12px空けて並べ、丸と上下の中心をそろえる */
	html.nisino-desktop-dock-ready .enc {
		right: 96px;
		bottom: 20px;
	}

	html.nisino-desktop-dock-ready .enc-toggle {
		margin: 0 0 7px;
	}
}


@media (min-width: 768px) {
	/* LPの5項目メニュー（高さ72px）の上に12px空けて置く */
	body:has(.lp-site-dock) .enc {
		bottom: 84px;
	}

	body:has(.lp-site-dock) .enc-panel {
		height: min(600px, calc(100dvh - 96px));
	}
}

@media (max-width: 767px) {
	/* 画面下の横長のメニュー（高さ72px）の上に12px空けて出す */
	html.nisino-dock-ready .enc {
		bottom: 84px;
	}

	/* 実印・銀行印などのページに出る「印材一覧へ ↑」（右下・下から88〜128px）があるときは、その上に出す */
	html.nisino-dock-ready body:has(.inzai-top) .enc {
		bottom: 138px;
	}
}

@media (min-width: 601px) and (max-width: 767px) {
	/* この幅では欄がボタンの位置から上に開くので、上に動かした分だけ高さを縮めて画面からはみ出さないようにする */
	html.nisino-dock-ready .enc-panel {
		height: min(600px, calc(100vh - 160px));
	}
}

/* コンパクト表示では共通の固定フッターからAIチャットを開く */
[data-enc-dock-chat] {
  display: none !important;
}

.enc-dock-faq {
  flex: none;
  align-self: flex-start;
  margin: 0 12px 8px;
  color: #122a52;
  font-size: 13px;
  text-decoration: underline;
}

@media (max-width: 950px) {
  .enc--dock-mode .enc-toggle,
  body:has(.enc--dock-mode) [data-enc-dock-faq] {
    display: none !important;
  }

  body:has(.enc--dock-mode) :is(#nisino-mobile-dock, .lp-site-dock) [data-enc-dock-chat] {
    display: flex !important;
    white-space: nowrap;
  }

  .enc--dock-mode .enc-panel {
    position: fixed;
    inset: 0;
    width: auto;
    height: auto;
    padding-bottom: env(safe-area-inset-bottom, 0px);
    border-radius: 0;
  }

  body:has(.enc--dock-mode .enc-panel:not([hidden])) :is(#nisino-mobile-dock, .lp-site-dock) {
    display: none !important;
  }

  .enc--dock-mode .enc-panel:focus {
    outline: none;
  }

  .enc--dock-mode .enc-head,
  .enc--dock-mode .enc-notes,
  .enc--dock-mode .enc-form {
    flex-shrink: 0;
  }

  .enc--dock-mode .enc-log {
    min-height: 0;
    overscroll-behavior-y: contain;
  }
}

/* PCのチャットを「上へ」と同じ中心線に置く */
@media (width > 950px) {
  html.nisino-desktop-dock-ready .enc.enc-pc-launcher {
    right: 26px;
    bottom: 96px;
    pointer-events: none;
  }
  html.nisino-desktop-dock-ready body:has(.inzai-top) .enc.enc-pc-launcher {
    bottom: 148px;
  }
  .enc-pc-launcher .enc-panel {
    height: min(600px, max(160px, calc(100dvh - 164px)));
    pointer-events: auto;
  }
  html.nisino-desktop-dock-ready .enc-pc-launcher .enc-toggle:not([hidden]) {
    display: flex;
    align-items: center;
    flex-direction: row-reverse;
    gap: 18px;
    width: 52px;
    height: 52px;
    padding: 0 13px;
    margin: 0 0 0 auto;
    overflow: hidden;
    white-space: nowrap;
    transition: width .35s ease;
    pointer-events: auto;
  }
  html.nisino-desktop-dock-ready .enc-pc-launcher .enc-toggle:not([hidden]):is(:hover, :focus-visible, .enc-show-label) {
    width: 224px;
  }
  .enc-pc-launcher .enc-toggle svg {
    flex: none;
    width: 26px;
    height: 26px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.65;
    stroke-linecap: round;
    stroke-linejoin: round;
  }
  .enc-pc-launcher .enc-toggle:not(:hover):not(:focus-visible):not(.enc-show-label) span {
    visibility: hidden;
  }
  @media (prefers-reduced-motion: reduce) {
    html.nisino-desktop-dock-ready .enc-pc-launcher .enc-toggle:not([hidden]) {
      transition: none;
    }
  }
}

@media (max-width: 767px) {
  #nisino-mobile-dock .mobile-chat-invitation:not([hidden]) {
    position: absolute;
    left: 50%;
    bottom: calc(100% + 14px);
    transform: translateX(-50%);
    width: max-content;
    max-width: calc(100vw - 24px);
    box-sizing: border-box;
    padding: 9px 13px;
    border-radius: 12px;
    background: #122a52;
    color: #fff;
    font: 600 13px/1.5 system-ui, sans-serif;
    text-align: center;
    white-space: normal;
    box-shadow: 0 2px 9px #0003;
    pointer-events: none;
    animation: mobile-chat-invitation-in .18s ease-out both;
  }
  #nisino-mobile-dock .mobile-chat-invitation::after {
    content: "";
    position: absolute;
    top: 100%;
    left: calc(50% - 6px);
    border: 6px solid transparent;
    border-top-color: #122a52;
  }
  @media (prefers-reduced-motion: reduce) {
    #nisino-mobile-dock .mobile-chat-invitation:not([hidden]) { animation: none; }
  }
}
@keyframes mobile-chat-invitation-in {
  from { opacity: 0; transform: translate(-50%, 6px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

@media (max-width: 767px) {
  #nisino-mobile-dock .mobile-chat-invitation {
    bottom: calc(100% + 14px);
    pointer-events: auto;
    padding: 3px 4px 3px 13px;
  }

  #nisino-mobile-dock .mobile-chat-invitation:not([hidden]) {
    display: flex;
    align-items: center;
    gap: 6px;
  }

  #nisino-mobile-dock .mobile-chat-invitation-close {
    flex: none;
    width: 44px;
    height: 44px;
    min-height: 0;
    pointer-events: auto;
    padding: 0;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: inherit;
    font: 400 22px/1 system-ui, sans-serif;
  }

  #nisino-mobile-dock .mobile-chat-invitation-close:focus-visible {
    outline-color: currentColor;
  }
}
