#hw-root {
  display: contents;
  --themeColor: #88ad6c;
  --accentColor: #fff;
}

/* ===== トグルボタン ===== */
#hw-toggle-btn {
  position: fixed;
  bottom: 28px;
  right: 28px;
  z-index: 9999;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: var(--themeColor);
  border: none;
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(44,61,46,0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s cubic-bezier(0.34,1.56,0.64,1);
  outline: none;
}
#hw-toggle-btn:hover {
  transform: scale(1.08);
  box-shadow: 0 6px 28px rgba(44,61,46,0.45);
}
#hw-toggle-btn.open {
  transform: scale(0.9) rotate(90deg);
}
#hw-toggle-btn svg {
  width: 26px;
  height: 26px;
  transition: opacity 0.2s;
}
#hw-toggle-btn .icon-chat { opacity: 1; position: absolute; }
#hw-toggle-btn .icon-close { opacity: 0; position: absolute; }
#hw-toggle-btn.open .icon-chat { opacity: 0; }
#hw-toggle-btn.open .icon-close { opacity: 1; }

/* ===== バブル ===== */
#hw-bubble {
  position: fixed;
  bottom: 100px;
  right: 28px;
  z-index: 9998;
  background: var(--themeColor);
  color: #f5f0e8;
  padding: 10px 16px;
  border-radius: 20px 20px 4px 20px;
  font-size: 12px;
  letter-spacing: 0.05em;
  box-shadow: 0 4px 16px rgba(44,61,46,0.3);
  white-space: nowrap;
  animation: bubbleIn 0.4s cubic-bezier(0.34,1.56,0.64,1) forwards;
  cursor: pointer;
}
@keyframes bubbleIn {
  from { opacity: 0; transform: translateY(10px) scale(0.9); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* ===== パネル ===== */
#hw-panel {
  position: fixed;
  bottom: 100px;
  right: 28px;
  z-index: 9998;
  width: 380px;
  height: 640px;
  background: #faf8f4;
  border-radius: 12px;
  box-shadow: 0 16px 60px rgba(44,61,46,0.2), 0 4px 20px rgba(44,61,46,0.1);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: scale(0.85) translateY(20px);
  transform-origin: bottom right;
  opacity: 0;
  pointer-events: none;
  transition: all 0.3s cubic-bezier(0.34,1.56,0.64,1);
}
#hw-panel.open {
  transform: scale(1) translateY(0);
  opacity: 1;
  pointer-events: all;
}
#hw-panel.expanded {
  width: 700px;
  height: 80vh;
  bottom: 100px;
}

/* ===== 拡大ボタン ===== */
.hw-expand-btn {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
  color: rgba(245,240,232,0.6);
  font-size: 16px;
  line-height: 1;
  transition: color 0.2s;
  margin-left: auto;
  flex-shrink: 0;
}
.hw-expand-btn:hover { color: #f5f0e8; }
@media (min-width: 481px) {
  .hw-expand-btn { display: block; }
}

/* ===== ヘッダー ===== */
.hw-header {
  background: var(--themeColor);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}
.hw-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: rgba(184,149,106,0.25);
  border: 1px solid rgba(184,149,106,0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  color: var(--accentColor);
  flex-shrink: 0;
}
.hw-name {
  font-size: 14px;
  color: #f5f0e8;
  letter-spacing: 0.06em;
}
.hw-status {
  font-size: 10px;
  color: #eee;
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 1px;
}
.hw-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #fff;
  animation: swPulse 2s infinite;
}
@keyframes swPulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.3; }
}

/* ===== メッセージエリア ===== */
.hw-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scroll-behavior: smooth;
}
.hw-messages::-webkit-scrollbar { width: 3px; }
.hw-messages::-webkit-scrollbar-thumb { background: rgba(44,61,46,0.15); border-radius: 2px; }

/* ===== メッセージ ===== */
.hw-msg {
  display: flex;
  gap: 8px;
  animation: swMsgIn 0.3s ease forwards;
  opacity: 0;
}
@keyframes swMsgIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}
.hw-msg.user { flex-direction: row-reverse; }

.hw-msg-avatar {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  margin-top: 2px;
}
.hw-msg.bot .hw-msg-avatar {
  background: var(--themeColor);
  color: var(--accentColor);
  font-size: 10px;
}
.hw-msg.user .hw-msg-avatar {
  background: #e8e0d4;
  font-size: 12px;
}

.hw-bubble {
  max-width: 78%;
  padding: 10px 13px;
  font-size: 13px;
  line-height: 1.75;
  border-radius: 2px;
}
.hw-msg.bot .hw-bubble {
  background: #fff;
  color: #3a3530;
  border: 1px solid rgba(184,149,106,0.2);
  border-top-left-radius: 0;
}
.hw-msg.user .hw-bubble {
  background: var(--themeColor);
  color: #f5f0e8;
  border-top-right-radius: 0;
}
.hw-bubble a {
  color: var(--accentColor);
  text-decoration: none;
  border-bottom: 1px solid rgba(184,149,106,0.3);
}

/* ===== フィードバックボタン ===== */
.hw-feedback {
  display: flex;
  gap: 4px;
  margin-top: 4px;
  padding-left: 36px;
}
.hw-fb-btn {
  background: none;
  border: 1px solid rgba(44,61,46,0.1);
  border-radius: 12px;
  padding: 2px 8px;
  font-size: 11px;
  cursor: pointer;
  color: rgba(44,61,46,0.4);
  transition: all 0.2s;
  line-height: 1.4;
}
.hw-fb-btn:hover      { background: rgba(44,61,46,0.06); color: rgba(44,61,46,0.8); }
.hw-fb-btn.active-good { background: rgba(74,122,89,0.1); border-color: rgba(74,122,89,0.3); color: #4a7c59; }
.hw-fb-btn.active-bad  { background: rgba(180,60,60,0.1); border-color: rgba(180,60,60,0.3); color: #b43c3c; }

/* ===== 満足度パネル ===== */
.hw-satisfaction {
  padding: 12px 16px;
  background: rgba(44,61,46,0.04);
  border-top: 1px solid rgba(44,61,46,0.08);
  text-align: center;
  flex-shrink: 0;
  animation: swMsgIn 0.3s ease forwards;
}
.hw-satisfaction-label {
  font-size: 11px;
  color: rgba(44,61,46,0.6);
  margin-bottom: 8px;
}
.hw-satisfaction-btns {
  display: flex;
  justify-content: center;
  gap: 8px;
}
.hw-sat-btn {
  padding: 5px 14px;
  border-radius: 16px;
  border: 1px solid rgba(44,61,46,0.2);
  background: #fff;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.2s;
  color: rgba(44,61,46,0.7);
}
.hw-sat-btn:hover    { border-color: rgba(44,61,46,0.4); background: rgba(44,61,46,0.04); }
.hw-sat-btn.selected { background: var(--themeColor); color: #f5f0e8; border-color: var(--themeColor); }
.hw-sat-thanks {
  font-size: 11px;
  color: rgba(44,61,46,0.5);
  margin-top: 6px;
}

/* ===== タイピングインジケーター ===== */
.hw-typing {
  display: flex;
  gap: 8px;
  align-items: flex-end;
  opacity: 0;
  transition: opacity 0.2s;
  padding: 0 14px 8px;
  flex-shrink: 0;
}
.hw-typing.show { opacity: 1; }
.hw-typing-dots {
  background: #fff;
  border: 1px solid rgba(184,149,106,0.2);
  padding: 10px 13px;
  border-radius: 2px;
  border-top-left-radius: 0;
  display: flex;
  gap: 4px;
  align-items: center;
}
.hw-typing-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--accentColor);
  animation: swTyping 1.4s infinite;
}
.hw-typing-dot:nth-child(2) { animation-delay: 0.2s; }
.hw-typing-dot:nth-child(3) { animation-delay: 0.4s; }
@keyframes swTyping {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30%            { transform: translateY(-4px); opacity: 1; }
}

/* ===== クイックボタン ===== */
.hw-quick {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 0 14px 10px;
  flex-shrink: 0;
}
.hw-quick-btn {
  padding: 5px 11px;
  background: #fff;
  border: 1px solid rgba(184,149,106,0.3);
  border-radius: 16px;
  font-size: 11px;
  color: #3a3530;
  cursor: pointer;
  transition: all 0.2s;
  letter-spacing: 0.02em;
}
.hw-quick-btn:hover {
  background: var(--themeColor);
  color: #f5f0e8;
  border-color: var(--themeColor);
}

/* ===== 入力エリア ===== */
.hw-input-area {
  padding: 10px 14px 14px;
  background: #fff;
  border-top: 1px solid rgba(184,149,106,0.15);
  display: flex;
  gap: 8px;
  align-items: flex-end;
  flex-shrink: 0;
}
.hw-input {
  flex: 1;
  border: 1px solid rgba(184,149,106,0.25);
  border-radius: 2px;
  padding: 9px 12px;
  font-size: 13px;
  color: #3a3530;
  background: #faf8f4;
  resize: none;
  outline: none;
  min-height: 40px;
  max-height: 100px;
  line-height: 1.5;
  transition: border-color 0.2s;
}
.hw-input:focus       { border-color: var(--accentColor); }
.hw-input::placeholder { color: #bbb0a0; font-size: 12px; }

.hw-send {
  width: 40px;
  height: 40px;
  background: var(--themeColor);
  border: none;
  border-radius: 2px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all 0.2s;
}
.hw-send:hover    { background: #7a9b7c; }
.hw-send:disabled { background: #ccc; cursor: not-allowed; }
.hw-send svg      { width: 16px; height: 16px; fill: none; stroke: #fff; stroke-width: 2; }

/* ===== レスポンシブ（スマホ） ===== */
@media (max-width: 480px) {
  #hw-toggle-btn {
    bottom: 16px;
    right: 16px;
    width: 54px;
    height: 54px;
  }
  #hw-bubble {
    bottom: 82px;
    right: 16px;
    font-size: 11px;
    padding: 8px 13px;
  }
  #hw-panel {
    width: calc(100vw - 16px);
    height: 82dvh;
    top: 40px;
    right: 8px;
    bottom: 80px;
    border-radius: 16px;
  }
  .hw-header {
    padding: 12px 14px;
  }
  .hw-name {
    font-size: 12px;
  }
  .hw-messages {
    padding: 12px;
    gap: 10px;
  }
  .hw-bubble {
    font-size: 13px;
    padding: 9px 12px;
    max-width: 82%;
  }
  .hw-quick {
    padding: 0 12px 8px;
    gap: 5px;
  }
  .hw-quick-btn {
    font-size: 11px;
    padding: 5px 10px;
  }
  .hw-input-area {
    position: relative;
    padding: 10px 70px 14px 12px;
    padding-bottom: max(14px, env(safe-area-inset-bottom));
  }
  .hw-input {
    font-size: 16px; /* iOSズーム防止 */
    padding: 8px 10px;
  }
  .hw-send {
    width: 38px;
    height: 38px;
    position: absolute;
    right: 16px;
    bottom: max(14px, env(safe-area-inset-bottom));
  }
}