/* Yoko & Shogo Web Chat Widget */
:root {
  --ycw-primary: #765487;
  --ycw-primary-light: #f3ebf6;
  --ycw-shogo-primary: #385b75;
  --ycw-shogo-light: #e4edf4;
  --ycw-line-green: #06c755;
  --ycw-line-green-hover: #05b04b;
  --ycw-bg: #ffffff;
  --ycw-text: #2d2633;
  --ycw-muted: #736979;
  --ycw-border: #ebdfee;
  --ycw-shadow: 0 12px 36px rgba(45, 25, 55, 0.16);
  --ycw-radius: 20px;
}

#yoko-chat-widget {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Yu Gothic UI", "Meiryo", sans-serif;
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 999999;
  color: var(--ycw-text);
  box-sizing: border-box;
}

#yoko-chat-widget,
#yoko-chat-widget * {
  box-sizing: border-box;
}

/* 待機バッジ（トリガー） */
.ycw-trigger {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  background: transparent;
  border: 0;
  cursor: pointer;
  padding: 0;
  user-select: none;
  outline: none;
}

.ycw-trigger-bubble {
  background: var(--ycw-bg);
  color: var(--ycw-primary);
  font-weight: 700;
  font-size: 13px;
  padding: 8px 14px;
  border-radius: 20px;
  box-shadow: 0 4px 16px rgba(45, 25, 55, 0.12);
  border: 1.5px solid var(--ycw-border);
  white-space: nowrap;
  animation: ycw-bubble-float 3s ease-in-out infinite;
  display: flex;
  align-items: center;
  gap: 6px;
}

#yoko-chat-widget.mode-shogo .ycw-trigger-bubble {
  color: var(--ycw-shogo-primary);
}

.ycw-trigger-avatar {
  width: 68px;
  height: 68px;
  border-radius: 50%;
  border: 3px solid #ffffff;
  box-shadow: 0 6px 20px rgba(70, 30, 85, 0.25);
  background: #fff;
  overflow: hidden;
  transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
  animation: ycw-breathe 4s ease-in-out infinite;
}

.ycw-trigger:hover .ycw-trigger-avatar {
  transform: translateY(-4px) scale(1.06);
}

.ycw-trigger-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.ycw-trigger-avatar .ycw-shogo-img { display: none; }
#yoko-chat-widget.mode-shogo .ycw-trigger-avatar .ycw-yoko-img { display: none; }
#yoko-chat-widget.mode-shogo .ycw-trigger-avatar .ycw-shogo-img { display: block; }

/* チャットパネル */
.ycw-panel {
  position: absolute;
  right: 0;
  bottom: 84px;
  width: 390px;
  max-width: calc(100vw - 32px);
  height: 620px;
  max-height: calc(100vh - 110px);
  background: var(--ycw-bg);
  border-radius: var(--ycw-radius);
  box-shadow: var(--ycw-shadow);
  border: 1px solid var(--ycw-border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
  transform: translateY(16px) scale(0.96);
  transform-origin: bottom right;
  transition: opacity 0.25s ease, transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

#yoko-chat-widget.is-open .ycw-panel {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0) scale(1);
}

/* ヘッダー */
.ycw-header {
  padding: 14px 16px;
  background: linear-gradient(135deg, #765487, #996c9c);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

#yoko-chat-widget.mode-shogo .ycw-header {
  background: linear-gradient(135deg, #345a75, #5582a2);
}

.ycw-header-profile {
  display: flex;
  align-items: center;
  gap: 10px;
}

.ycw-header-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.8);
  overflow: hidden;
  background: #fff;
  flex-shrink: 0;
}

.ycw-header-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.ycw-header-avatar .ycw-shogo-img { display: none; }
#yoko-chat-widget.mode-shogo .ycw-header-avatar .ycw-yoko-img { display: none; }
#yoko-chat-widget.mode-shogo .ycw-header-avatar .ycw-shogo-img { display: block; }

.ycw-header-info {
  display: flex;
  flex-direction: column;
}

.ycw-header-name {
  font-weight: 700;
  font-size: 15px;
  line-height: 1.2;
}

.ycw-header-sub {
  font-size: 11px;
  opacity: 0.85;
}

.ycw-header-controls {
  display: flex;
  align-items: center;
  gap: 6px;
}

.ycw-mode-switch {
  display: flex;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 20px;
  padding: 3px 5px;
  gap: 6px;
}

.ycw-mode-btn {
  border: 0;
  background: transparent;
  color: #fff;
  font-size: 11.5px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 14px;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

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

#yoko-chat-widget.mode-shogo .ycw-mode-btn.active {
  color: var(--ycw-shogo-primary);
}

.ycw-close-btn {
  width: 30px;
  height: 30px;
  border: 0;
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 16px;
  transition: background 0.15s ease;
}

.ycw-close-btn:hover {
  background: rgba(255, 255, 255, 0.3);
}

/* 上部固定エリア（よくある質問＆LINE相談） */
#yoko-chat-widget .ycw-fixed-top {
  background: #ffffff;
  border-bottom: 1px solid var(--ycw-border);
  padding: 10px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  box-shadow: 0 2px 8px rgba(45, 25, 55, 0.04);
  flex-shrink: 0;
  z-index: 2;
}

/* メッセージエリア */
#yoko-chat-widget .ycw-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: #fbf9fc;
}

#yoko-chat-widget .ycw-message {
  display: flex;
  gap: 8px;
  max-width: 88%;
}

#yoko-chat-widget .ycw-message.assistant {
  align-self: flex-start;
}

#yoko-chat-widget .ycw-message.user {
  align-self: flex-end;
  flex-direction: row-reverse;
}

#yoko-chat-widget .ycw-msg-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  overflow: hidden;
  flex-shrink: 0;
  border: 1.5px solid #fff;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
}

#yoko-chat-widget .ycw-msg-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

#yoko-chat-widget .ycw-bubble {
  padding: 12px 18px;
  border-radius: 18px;
  font-size: 14px;
  line-height: 1.6;
  word-break: break-word;
  white-space: pre-wrap;
  position: relative;
  letter-spacing: 0.02em;
}

#yoko-chat-widget .ycw-message.assistant .ycw-bubble {
  background: #ffffff;
  color: var(--ycw-text);
  border: 1px solid #ede4f0;
  box-shadow: 0 2px 8px rgba(50, 20, 60, 0.05);
  border-radius: 4px 18px 18px 18px;
}

/* アシスタント吹き出しのLINE風三角しっぽ */
#yoko-chat-widget .ycw-message.assistant .ycw-bubble::before {
  content: "";
  position: absolute;
  top: 10px;
  left: -7px;
  width: 0;
  height: 0;
  border-top: 5px solid transparent;
  border-bottom: 5px solid transparent;
  border-right: 7px solid #ede4f0;
}
#yoko-chat-widget .ycw-message.assistant .ycw-bubble::after {
  content: "";
  position: absolute;
  top: 10px;
  left: -5.5px;
  width: 0;
  height: 0;
  border-top: 5px solid transparent;
  border-bottom: 5px solid transparent;
  border-right: 7px solid #ffffff;
}

#yoko-chat-widget .ycw-message.assistant.speaker-male .ycw-bubble,
#yoko-chat-widget.mode-shogo .ycw-message.assistant:not(.speaker-female) .ycw-bubble {
  border-color: #dce7f0;
}
#yoko-chat-widget .ycw-message.assistant.speaker-male .ycw-bubble::before,
#yoko-chat-widget.mode-shogo .ycw-message.assistant:not(.speaker-female) .ycw-bubble::before {
  border-right-color: #dce7f0;
}

#yoko-chat-widget .ycw-message.user .ycw-bubble {
  background: var(--ycw-primary);
  color: #ffffff;
  border-radius: 18px 4px 18px 18px;
  box-shadow: 0 2px 8px rgba(118, 84, 135, 0.22);
}

/* ユーザー吹き出しのLINE風三角しっぽ */
#yoko-chat-widget .ycw-message.user .ycw-bubble::after {
  content: "";
  position: absolute;
  top: 10px;
  right: -6px;
  width: 0;
  height: 0;
  border-top: 5px solid transparent;
  border-bottom: 5px solid transparent;
  border-left: 7px solid var(--ycw-primary);
}

#yoko-chat-widget.mode-shogo .ycw-message.user .ycw-bubble {
  background: var(--ycw-shogo-primary);
  box-shadow: 0 2px 8px rgba(52, 90, 117, 0.22);
}
#yoko-chat-widget.mode-shogo .ycw-message.user .ycw-bubble::after {
  border-left-color: var(--ycw-shogo-primary);
}

/* クイック質問チップ（1画面で折り返し一覧表示） */
#yoko-chat-widget .ycw-chips-container {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

#yoko-chat-widget .ycw-chips-title {
  font-size: 11px;
  color: var(--ycw-muted);
  font-weight: 700;
  padding-left: 2px;
  letter-spacing: 0.02em;
}

#yoko-chat-widget .ycw-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

#yoko-chat-widget .ycw-chip-btn {
  background: #fbf9fc;
  border: 1px solid #dfd3e3;
  color: var(--ycw-primary);
  font-size: 11.5px;
  font-weight: 600;
  padding: 5px 11px;
  border-radius: 13px;
  cursor: pointer;
  line-height: 1.35;
  transition: all 0.15s ease;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.03);
}

#yoko-chat-widget .ycw-chip-btn:hover {
  background: var(--ycw-primary-light);
  border-color: var(--ycw-primary);
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(118, 84, 135, 0.15);
}

#yoko-chat-widget.mode-shogo .ycw-chip-btn {
  background: #f8fafc;
  color: var(--ycw-shogo-primary);
  border-color: #ccd9e2;
}

#yoko-chat-widget.mode-shogo .ycw-chip-btn:hover {
  background: var(--ycw-shogo-light);
  border-color: var(--ycw-shogo-primary);
  box-shadow: 0 2px 8px rgba(52, 90, 117, 0.15);
}

/* 公式LINE相談ボタン（シンプル配置） */
#yoko-chat-widget .ycw-line-action {
  display: flex;
  flex-direction: column;
  margin-top: 2px;
}

#yoko-chat-widget .ycw-line-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: var(--ycw-line-green);
  color: #fff;
  text-decoration: none;
  font-size: 13px;
  font-weight: 700;
  padding: 9px 16px;
  border-radius: 12px;
  transition: background 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
  box-shadow: 0 3px 10px rgba(6, 199, 85, 0.28);
}

#yoko-chat-widget .ycw-line-btn:hover {
  background: var(--ycw-line-green-hover);
  transform: translateY(-1px);
  box-shadow: 0 5px 14px rgba(6, 199, 85, 0.36);
}

#yoko-chat-widget .ycw-line-btn svg {
  width: 18px;
  height: 18px;
  fill: currentColor;
}

/* チャット内インラインLINE誘導 */
.ycw-chat-line-cta {
  margin: 2px 0 4px;
  align-self: flex-start;
  width: 100%;
}

/* 入力エリア */
.ycw-footer {
  padding: 10px 14px 12px;
  background: #fff;
  border-top: 1px solid var(--ycw-border);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.ycw-form {
  display: flex;
  gap: 8px;
}

.ycw-input {
  flex: 1;
  border: 1.5px solid #dfd4e2;
  border-radius: 12px;
  padding: 10px 14px;
  font-size: 13.5px;
  outline: none;
  transition: border-color 0.15s ease;
}

.ycw-input:focus {
  border-color: var(--ycw-primary);
}

#yoko-chat-widget.mode-shogo .ycw-input:focus {
  border-color: var(--ycw-shogo-primary);
}

.ycw-send-btn {
  border: 0;
  background: var(--ycw-primary);
  color: #fff;
  width: 42px;
  height: 42px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: opacity 0.15s ease, transform 0.15s ease;
  flex-shrink: 0;
}

.ycw-send-btn:hover {
  opacity: 0.9;
  transform: scale(1.04);
}

.ycw-send-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
}

#yoko-chat-widget.mode-shogo .ycw-send-btn {
  background: var(--ycw-shogo-primary);
}

.ycw-note {
  font-size: 10.5px;
  color: var(--ycw-muted);
  text-align: center;
  line-height: 1.3;
}

/* キーフレームアニメーション */
@keyframes ycw-breathe {
  0%, 100% { transform: translateY(0) scale(1); }
  50% { transform: translateY(-3px) scale(1.015, 0.99); }
}

@keyframes ycw-bubble-float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-3px); }
}

@keyframes ycw-pop {
  0% { transform: scale(0.9); }
  60% { transform: scale(1.06); }
  100% { transform: scale(1); }
}

/* スマホ対応（480px以下） */
@media (max-width: 480px) {
  #yoko-chat-widget {
    right: 16px;
    bottom: 16px;
  }
  
  .ycw-trigger-bubble {
    display: none; /* スマホではアイコンのみでスッキリ */
  }

  .ycw-trigger-avatar {
    width: 60px;
    height: 60px;
  }

  .ycw-panel {
    position: fixed;
    right: 0;
    bottom: 0;
    width: 100vw;
    height: 84vh;
    max-height: 84vh;
    border-radius: 20px 20px 0 0;
    transform-origin: bottom center;
  }
}

@media (prefers-reduced-motion: reduce) {
  .ycw-trigger-avatar,
  .ycw-trigger-bubble,
  .ycw-panel {
    animation: none !important;
    transition: none !important;
  }
}
