/* maker側の文字を太く見せる */
.ihaimaker .image .text-element .el-text,
.ihaimaker .image .dyn-text .el-text {
  font-weight: 900 !important;
  -webkit-text-stroke: 0.5px currentColor;
  text-stroke: 0.5px currentColor;
}

/* スマホ: フォームモードで表裏を横並び表示（裏返しアニメ無し） */
@media (max-width: 840px) {
  .form-container .ihaimaker .image.omote,
  .form-container .ihaimaker .image.ura {
    position: relative !important;
    display: inline-block !important;
    width: 50% !important;
    transform: none !important;
    opacity: 1 !important;
    transition: none !important;
    float: left;
  }
  .form-container .ihaimaker .image .uragaeshi {
    display: none !important;
  }
  .form-container .ihaimaker .image.omote,
  .form-container .ihaimaker .image.ura {
    pointer-events: none;
  }
  .preview-modal-overlay * {
    pointer-events: auto !important;
  }
  .ihaimaker {
    padding: 0 !important;
  }
}

/* ===== 位牌画像: layoutmakerと一致させるため 260:600 + cover で表示 ===== */
.ihaimaker .image.omote,
.ihaimaker .image.ura {
  display: block !important;
  aspect-ratio: 260 / 600 !important;
  height: auto !important;
  overflow: hidden !important;
  top: 0px;
}
body.chatmode .shared-preview .ihaimaker .image,
body.chatmode .shared-preview .ihaimaker .image.omote,
body.chatmode .shared-preview .ihaimaker .image.ura {
  width: 50% !important;
  display: inline-block !important;
  aspect-ratio: 260 / 600 !important;
  height: auto !important;
  overflow: hidden !important;
}
.ihaimaker .image.omote > img.ihaiimg,
.ihaimaker .image.ura > img.ihaiimg {
  width: 100% !important;
  height: 100% !important;
  object-fit: cover !important;
  object-position: center !important;
  max-width: none !important;
  max-height: none !important;
  display: block !important;
}

/* ===== PCフォームモード: 左右分割 ===== */
@media (min-width: 768px) {
  body,
  html {
    overflow-x: clip !important;
  }
  .page-container {
    overflow: visible !important;
  }
  .ihaimaker {
    display: flex !important;
    align-items: flex-start;
    overflow: visible !important;
  }
  .form-container {
    overflow: visible !important;
  }
  .ihaimaker .image {
    flex-shrink: 0;
    position: sticky !important;
    overflow: hidden !important;
    align-self: flex-start;
  }
  .form-right-col {
    flex: 1;
    min-width: 0;
    padding-left: 1em;
    overflow: visible !important;
  }
}
.form-right-col {
  /* スマホではそのまま */
}

/* ===== レイアウト・梵字選択（フォームモード） ===== */
.form-selectors {
  margin: 0.5em 0 1em;
}
.form-selector-group {
  margin-bottom: 0.8em;
}
.form-selector-label {
  padding-left: 5px;
  border-left: 5px solid #c6a261;
  margin-bottom: 0.5em;
  font-weight: bold;
}
.form-selector-label .tab-icon {
  width: 18px;
  height: 18px;
}
.form-selector-items {
  display: flex !important;
  flex-wrap: wrap;
  gap: 0.5em;
  padding: 0.3em 0;
  height: auto !important;
  white-space: normal !important;
  background: none !important;
  overflow: visible !important;
}
.form-selector-items .layout1,
.form-selector-items .bonji1 {
  flex-shrink: 0;
  width: 120px !important;
  height: auto !important;
  max-width: 31%;
  border: 2px solid #e0e0e0 !important;
  border-radius: 6px !important;
  padding: 4px !important;
  margin: 0 !important;
  cursor: pointer;
  background: #fafafa !important;
  display: inline-flex !important;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  transition: border-color 200ms;
}
.form-selector-items .layout1 img,
.form-selector-items .bonji1 img {
  width: 100%;
  height: auto;
  aspect-ratio: 1 / 1;
  object-fit: contain;
  filter: brightness(0.3);
}
.form-selector-items .bonji1 .bonji-label {
  display: block;
  width: 100%;
  margin-top: 4px;
  font-size: 11px;
  line-height: 1.25;
  color: #555;
  text-align: center;
  word-break: keep-all;
}
.form-selector-items .layout1.selected,
.form-selector-items .bonji1.selected {
  border-color: #c6a261 !important;
  background: #fffbf0 !important;
  box-shadow: 0 0 0 2px rgba(198, 162, 97, 0.3);
}
.form-selector-items .layout1:hover,
.form-selector-items .bonji1:hover {
  border-color: #c6a261 !important;
}

/* ===== 専用ヘッダー ===== */
.maker-header {
  display: flex;
  align-items: center;
  background: #fff;
  border-bottom: 2px solid #c6a261;
  padding: 0 12px;
  height: 48px;
  position: sticky;
  top: 0;
  z-index: 1000;
}
.maker-header-logo {
  display: flex;
  align-items: center;
  flex-shrink: 0;
}
.maker-header-logo img {
  height: 2em;
}
.maker-header-center {
  display: flex;
  margin: 0 auto;
  gap: 0;
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid #c6a261;
}
.maker-mode-tab {
  padding: 5px 18px;
  font-size: 0.85em;
  font-weight: bold;
  cursor: pointer;
  color: #c6a261;
  background: transparent;
  transition: all 200ms;
  user-select: none;
  white-space: nowrap;
}
.maker-mode-tab.active {
  color: #fff;
  background: #c6a261;
}
.maker-mode-tab:hover:not(.active) {
  background: rgba(198, 162, 97, 0.15);
}
.maker-header-right {
  flex-shrink: 0;
}
.maker-header-btn.btnchange {
  width: auto;
  max-width: none;
  margin: 0;
  padding: 5px 14px;
  font-size: 0.8em;
  box-shadow: none;
}
/* 専用ヘッダーがある場合、共通ヘッダーを非表示 */
.maker-header ~ .page-container .site-header {
  display: none;
}
/* ヘッダー分のpage-container調整 */
.maker-header + .page-container {
  padding-top: 0;
}

@media (max-width: 480px) {
  .maker-header {
    padding: 0 8px;
    height: 44px;
  }
  .maker-mode-tab {
    padding: 4px 12px;
    font-size: 0.75em;
  }
  .maker-header-btn.btnchange {
    padding: 4px 10px;
    font-size: 0.7em;
  }
}
@media (max-width: 400px) {
  .maker-header {
    padding: 0 4px;
    height: 50px;
    gap: 4px;
  }
  .maker-header-logo img {
    height: 1.4em;
  }
  .maker-mode-tab {
    padding: 3px 8px;
    font-size: 0.7em;
  }
  .maker-header-btn.btnchange {
    padding: 3px 6px;
    font-size: 0.65em;
  }
}

/* ===== モード切替 ===== */
.mode-switcher {
  display: flex;
  max-width: 1280px;
  margin: 0 auto;
  background: #f5f5f5;
  border-bottom: 2px solid #c6a261;
}
.mode-tab {
  flex: 1;
  text-align: center;
  padding: 0.5em;
  font-size: 1.1em;
  font-weight: bold;
  cursor: pointer;
  color: #888;
  background: #e8e8e8;
  transition: all 200ms;
  user-select: none;
}
.mode-tab.active {
  color: #fff;
  background: #c6a261;
}
.mode-tab:hover:not(.active) {
  background: #ddd;
}

/* ===== チャットモード ===== */
.chat-container {
  display: none;
  background: #fff;
  flex: 1;
  min-width: 0;
}
.chat-container.active {
  display: flex;
  flex-direction: column;
}
.form-container {
  display: none;
}
.form-container.active {
  display: block;
}

/* 共有プレビュー+チャット 横並びラッパー */
.chat-layout {
  display: none;
}
body.chatmode .chat-layout {
  display: flex;
  max-width: 1280px;
  margin: 0 auto;
  height: calc(100vh - 50px);
}

/* 共有プレビュー */
.shared-preview {
  display: none;
}
body.chatmode .shared-preview {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  width: 50%;
  min-width: 300px;
  background: #eee;
  padding: 0 1em 1em;
  box-sizing: border-box;
  position: sticky;
  top: 0;
  align-self: flex-start;
  max-height: 100vh;
  height: calc(100vh - 48px);
}
body.chatmode .shared-preview .ihaimaker {
  text-align: center;
  width: 100%;
  padding: 0;
  margin: 0;
}
body.chatmode .shared-preview .ihaimaker .image {
  width: 50% !important;
  max-width: 100%;
}
body.chatmode .shared-preview .ihaimaker .image.ura {
  position: relative !important;
  display: inline-block !important;
  opacity: 1 !important;
  transform: none !important;
  width: 50% !important;
  max-width: 100%;
}
body.chatmode .shared-preview .ihaimaker .image.omote {
  position: relative !important;
  display: inline-block !important;
}

/* チャットモード時はフッター非表示 */
body.chatmode .site-footer {
  display: none !important;
}

/* チャット側 */
body.chatmode .chat-container.active {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  height: calc(100vh - 48px);
  position: relative;
}

/* 進捗バー: プレビュー下部に配置 */
.shared-preview .chat-progress {
  width: 100%;
  margin-top: 75px;
  position: relative;
  z-index: 1;
}

/* スマホ: 縦並び */
@media (max-width: 480px) {
  body.chatmode .chat-layout {
    flex-direction: column;
  }
  body.chatmode .shared-preview {
    width: 100%;
    min-width: 0;
    position: relative;
    max-height: none;
    height: auto;
    padding: 0;
  }
  .shared-preview .chat-progress {
    margin-top: 0 !important;
  }
  body.chatmode .shared-preview .ihaimaker {
    aspect-ratio: 1 / 0.8;
    overflow: hidden;
  }
  body.chatmode.keyboard-open .shared-preview .ihaimaker {
    height: 0 !important;
    overflow: hidden !important;
  }
  body.chatmode .shared-preview .ihaimaker .image,
  body.chatmode .shared-preview .ihaimaker .image.ura {
    width: 50% !important;
    max-width: none;
  }
  body.chatmode .chat-layout {
    height: calc(100dvh - 48px);
  }
  body.chatmode .chat-container.active {
    flex: 1;
    min-height: 0;
    max-height: none;
  }
  body.chatmode .shared-preview .ihaimaker .image .menmark {
    top: 0.3em;
  }
  body.chatmode .shared-preview .ihaimaker .image .menmark img {
    width: 2em;
  }
  body.chatmode .shared-preview .ihaimaker .image.omote .menmark {
    right: 0.3em;
  }
  body.chatmode .shared-preview .ihaimaker .image.ura .menmark {
    left: 0.3em;
  }
}

.chat-messages {
  padding: 1em;
  flex: 1;
  overflow-y: auto;
  min-height: 0;
  background: #fff;
}
.chat-msg {
  margin-bottom: 1.5em;
  margin-top: 2em;
  display: flex;
  align-items: flex-start;
}
.chat-msg.bot {
  justify-content: flex-start;
}
.chat-msg.user {
  justify-content: flex-end;
}
.chat-bubble {
  padding: 0.75em 0.5em 0.75em 0.75em;
  border-radius: 1em;
  line-height: 1.5;
  font-size: 0.95em;
  word-break: break-word;
  position: relative;
}
.chat-msg.bot .chat-bubble {
  background: #eee;
  color: #333;
  border-bottom-left-radius: 0.3em;
  margin-left: 0.6em;
}
.chat-msg.bot .chat-bubble::before {
  content: "";
  position: absolute;
  left: -0.5em;
  bottom: 0;
  width: 0;
  height: 0;
  border: 0.4em solid transparent;
  border-right-color: #eee;
  border-bottom-color: #eee;
}
.chat-msg.user .chat-bubble {
  background: #c6a261;
  color: #fff;
  border-bottom-right-radius: 0.3em;
  margin-right: 0.6em;
}
/* 過去ステップの自分の吹き出し: クリックで再入力可能 */
.chat-msg.user[data-step-index] .chat-bubble {
  cursor: pointer;
  transition: background 0.15s;
}
.chat-msg.user[data-step-index] .chat-bubble:hover {
  background: #b18f50;
}
.chat-msg.user[data-step-index] .chat-bubble:hover::after {
  border-left-color: #b18f50;
  border-bottom-color: #b18f50;
}
.chat-msg.user .chat-bubble::after {
  content: "";
  position: absolute;
  right: -0.5em;
  bottom: 0;
  width: 0;
  height: 0;
  border: 0.4em solid transparent;
  border-left-color: #c6a261;
  border-bottom-color: #c6a261;
}

/* やり直しボタン */
.chat-restart-btn {
  padding: 0.3em 0.75em;
  background: #ccc;
  border: 1px solid #ccc;
  border-radius: 2em;
  color: #000;
  font-size: 0.8em;
  cursor: pointer;
  transition: all 150ms;
  font-weight: bold;
}
.chat-restart-btn:hover {
  background: #eee;
  color: #000;
}

.chat-input-area {
  display: flex;
  padding: 0.75em 1em;
  border: none;
  border-top: 1px solid #fff;
  border-left: 1px solid #fff;
  outline: none;
  background: #f0ede8;
  align-items: center;
  gap: 0.5em;
}
.chat-input-area input[type="text"] {
  flex: 1;
  padding: 0.6em 1em;
  border: 1px solid #ccc;
  border-radius: 2em;
  font-size: 1em;
  outline: none;
}
.chat-input-area input[type="text"]::placeholder {
  color: #ccc;
}
.chat-input-area input[type="text"]:focus {
  border-color: #c6a261;
}
.chat-send-btn {
  padding: 0.6em 1.5em;
  background: #c6a261;
  color: #fff;
  border: none;
  border-radius: 2em;
  font-weight: bold;
  cursor: pointer;
  font-size: 1em;
}
.chat-send-btn:hover {
  opacity: 0.8;
}
@media screen and (max-width: 375px) {
  .chat-restart-btn { padding: 0.3em 0.5em; line-height: 1.2em; }
  .chat-send-btn { padding: 0.6em 1em; }
}
.chat-confirm-ihai-btn {
  display: none !important;
  padding: 0.6em 1.5em;
  background: #c6a261;
  color: #fff;
  border: none;
  border-radius: 2em;
  font-weight: bold;
  cursor: pointer;
  font-size: 1em;
  width: auto;
  position: absolute;
  right: 1em;
}
.chat-confirm-ihai-btn:hover {
  opacity: 0.8;
}

/* チャット選択肢ボタン */
.chat-options {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5em;
  margin-top: 0.5em;
}
.chat-option-btn {
  padding: 0.4em 1em;
  background: #fff;
  border: 2px solid #c6a261;
  border-radius: 2em;
  color: #c6a261;
  font-weight: bold;
  cursor: pointer;
  font-size: 0.9em;
  transition: all 150ms;
}
.chat-option-btn:hover {
  background: #c6a261;
  color: #fff;
}

/* チャット画像選択肢 */
.chat-image-options {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6em;
  margin-top: 0.5em;
}
.chat-image-btn {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  background: #515151;
  border: 3px solid transparent;
  border-radius: 0.7em;
  padding: 0.5em;
  cursor: pointer;
  transition: all 150ms;
  width: 8em;
  box-sizing: border-box;
}
.chat-image-btn img {
  width: 100%;
  /*height: 5.5em;*/
  object-fit: contain;
}
.chat-image-btn .chat-img-label {
  color: #ddd;
  font-size: 0.75em;
  margin-top: 0.3em;
  text-align: center;
  line-height: 1.2;
  word-break: break-all;
}
.chat-image-btn:hover {
  border-color: #c6a261;
}
.chat-image-btn.selected {
  border-color: #c6a261;
  background: #5f5541;
}
.chat-image-btn.disabled {
  opacity: 0.4;
}
.chat-image-btn.disabled:hover {
  opacity: 0.7;
  cursor: pointer;
}

/* チャットファイルアップロード */
.chat-file-area {
  margin-top: 0.5em;
}
.chat-file-btn {
  display: inline-block;
  padding: 0.5em 1.2em;
  background: #fff;
  border: 2px solid #c6a261;
  border-radius: 2em;
  color: #c6a261;
  font-weight: bold;
  font-size: 0.9em;
  cursor: pointer;
  transition: all 150ms;
}
.chat-file-btn:hover {
  background: #c6a261;
  color: #fff;
}
.chat-file-names {
  margin-top: 0.4em;
}
.chat-file-item {
  font-size: 0.85em;
  padding: 0.2em 0;
  color: #555;
}
.chat-file-done-btn,
.chat-file-buttons .chat-skip-btn {
  padding: 0.5em 1.2em;
  color: #fff;
  border: none;
  border-radius: 2em;
  font-weight: bold;
  font-size: 0.9em;
  cursor: pointer;
  line-height: 1.2;
  box-sizing: border-box;
  margin: 0;
}
.chat-file-done-btn {
  background: #c6a261;
}
.chat-file-buttons .chat-skip-btn {
  background: #aaa;
}
.chat-file-done-btn:hover,
.chat-file-buttons .chat-skip-btn:hover {
  opacity: 0.8;
}

/* チャットスキップ */
.chat-skip-btn {
  padding: 0.3em 0.8em;
  background: #aaa;
  color: #fff;
  border: none;
  border-radius: 1em;
  cursor: pointer;
  font-size: 0.85em;
  margin-top: 0.3em;
}
.chat-skip-btn:hover {
  opacity: 0.8;
}

/* ===== プレビュー拡大 ===== */
.preview-expand-btn {
  position: fixed;
  margin-top: 0.3em;
  padding: 0.4em 1.2em;
  background: rgba(0, 0, 0, 0.5);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.4);
  border-radius: 1.5em;
  font-size: 0.8em;
  cursor: pointer;
  z-index: 10;
  transition: background 150ms;
}
.preview-expand-btn:hover {
  background: rgba(0, 0, 0, 0.7);
}
.form-container .preview-expand-btn {
  left: 50%;
  transform: translate(-50%, 0);
}
@media (min-width: 481px) {
  .form-container .preview-expand-btn {
    left: 29.5%;
  }
}

/* 拡大モーダル */
.preview-modal-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.85);
  z-index: 99999;
  justify-content: center;
  align-items: center;
  flex-direction: column;
}
.preview-modal-overlay.show {
  display: flex;
}
.preview-modal-close {
  position: absolute;
  top: 1em;
  right: 1em;
  width: 2.5em;
  height: 2.5em;
  background: rgba(255, 255, 255, 0.15);
  border: 1px solid rgba(255, 255, 255, 0.4);
  border-radius: 50%;
  color: #fff;
  font-size: 1.2em;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10001;
}
.preview-modal-close:hover {
  background: rgba(255, 255, 255, 0.3);
}
/* モーダル内の .ihaimaker はスマホフォームモードと同じ表示 */
.preview-modal-body {
  width: 95vw;
  max-width: 360px;
}
.preview-modal-body .ihaimaker {
  background: transparent !important;
  padding: 0 !important;
  max-width: 100% !important;
  position: relative !important;
}
.preview-modal-body .ihaimaker .image {
  width: 100% !important;
  display: block !important;
  overflow: hidden !important;
}
.preview-modal-body .ihaimaker .image.omote {
  position: relative !important;
  display: block !important;
  width: 100% !important;
  left: 0 !important;
  top: 0 !important;
  transform: rotateY(0deg) !important;
  opacity: 1 !important;
  transition: transform 300ms 0s linear !important;
}
.preview-modal-body .ihaimaker .image.ura {
  position: absolute !important;
  left: 0 !important;
  top: 0 !important;
  display: block !important;
  width: 100% !important;
  transform: rotateY(180deg) !important;
  opacity: 0 !important;
  transition: transform 300ms 0s linear !important;
}
.preview-modal-body .ihaimaker.anime1 .image.omote {
  transform: rotateY(90deg) !important;
  opacity: 1 !important;
}
.preview-modal-body .ihaimaker.anime1 .image.ura {
  transform: rotateY(90deg) !important;
  opacity: 0 !important;
}
.preview-modal-body .ihaimaker.anime2 .image.omote {
  transform: rotateY(180deg) !important;
  opacity: 0 !important;
}
.preview-modal-body .ihaimaker.anime2 .image.ura {
  transform: rotateY(0deg) !important;
  opacity: 1 !important;
}
.preview-modal-body .ihaimaker.anime3 .image.omote {
  transform: rotateY(90deg) !important;
  opacity: 0 !important;
}
.preview-modal-body .ihaimaker.anime3 .image.ura {
  transform: rotateY(90deg) !important;
  opacity: 1 !important;
}
.preview-modal-body .ihaimaker .image .uragaeshi {
  display: block;
}
.preview-modal-hint {
  position: absolute;
  top: 1em;
  left: 50%;
  transform: translateX(-50%);
  color: #fff;
  font-size: 0.85em;
  text-align: center;
  z-index: 10;
  pointer-events: none;
  background: rgba(0, 0, 0, 0.5);
  padding: 0.4em 1em;
  border-radius: 999px;
  white-space: nowrap;
}
.preview-modal-close {
  background: rgba(0, 0, 0, 0.5) !important;
  border-radius: 50% !important;
}

/* ===== チャット完了時の注文ボタン ===== */
.chat-order-area {
  display: none;
  max-width: 1280px;
  margin: 0 auto;
}
.chat-order-area.show {
  display: block;
}

/* ===== チャット進捗バー ===== */
.chat-progress {
  padding: 0em 0;
}
.chat-progress-bar {
  height: 6px;
  background: #e0ddd0;
  border-radius: 3px;
  overflow: hidden;
}
@media (min-width: 481px) {
  .chat-progress-bar {
    margin-top: -45px;
  }
}
.chat-progress-fill {
  height: 100%;
  background: #c6a261;
  border-radius: 3px;
  transition: width 300ms;
  width: 0%;
}
.chat-progress-text {
  font-size: 0.8em;
  color: #888;
  margin-top: 1em;
  /* text-shadow: 0 0 3px #fff, 0 0 6px #fff, 0 0 10px #fff; */
  position: absolute;
  top: auto;
  text-align: right;
  /* width: 100%; */
  font-weight: bold;
  padding: 0.25em 0.5em 0.25em 0.5em;
  right: 0.5em;
  background-color: rgba(255, 255, 255, 0.5);
  border-radius: 0.5em;
}
