* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: #1a1a1a;
  color: #e0e0e0;
  min-height: 100dvh;
  display: flex;
  justify-content: center;
  align-items: center;
}

.chat-container {
  width: 100%;
  max-width: 480px;
  height: 100dvh;
  max-height: 800px;
  display: flex;
  flex-direction: column;
  background: #242424;
  border-radius: 0;
}

@media (min-width: 520px) {
  .chat-container {
    height: 90dvh;
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
  }
}

/* ヘッダー */
.chat-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  background: #2a2a2a;
  border-bottom: 1px solid #333;
}

.header-icon {
  font-size: 28px;
}

.header-text {
  flex: 1;
}

.chat-header h1 {
  font-size: 18px;
  font-weight: 700;
  color: #c8a87c;
  letter-spacing: 2px;
}

.chat-header p {
  font-size: 12px;
  color: #888;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.lang-switcher {
  display: flex;
  gap: 2px;
  background: #333;
  border-radius: 8px;
  padding: 2px;
}

.lang-btn {
  background: none;
  border: none;
  color: #888;
  font-size: 11px;
  font-weight: 600;
  padding: 4px 8px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s;
  line-height: 1;
}

.lang-btn:hover {
  color: #c8a87c;
}

.lang-btn.active {
  background: #c8a87c;
  color: #1a1a1a;
}

.reset-btn {
  background: none;
  border: 1px solid #444;
  color: #888;
  font-size: 20px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.reset-btn:hover {
  border-color: #c8a87c;
  color: #c8a87c;
}

/* メッセージエリア */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.message {
  max-width: 85%;
  animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.message.user {
  align-self: flex-end;
}

.message.assistant {
  align-self: flex-start;
}

.message-content {
  padding: 12px 16px;
  border-radius: 16px;
  font-size: 14px;
  line-height: 1.6;
  word-break: break-word;
}

.message.user .message-content {
  background: #c8a87c;
  color: #1a1a1a;
  border-bottom-right-radius: 4px;
}

.message.assistant .message-content {
  background: #333;
  color: #e0e0e0;
  border-bottom-left-radius: 4px;
}

/* エラーメッセージ */
.message.error .message-content {
  background: #3d2a2a;
  color: #e8a0a0;
  border-left: 3px solid #c55;
}

/* リンクスタイル */
.message.assistant .message-content a {
  color: #c8a87c;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.message.assistant .message-content a:hover {
  opacity: 0.8;
}

/* ソース表示 */
.message-sources {
  margin-top: 8px;
  padding: 8px 12px;
  background: #2a2a2a;
  border-radius: 8px;
  font-size: 11px;
  color: #888;
}

.message-sources span {
  display: inline-block;
  margin-right: 8px;
  padding: 2px 8px;
  background: #3a3a3a;
  border-radius: 4px;
}

/* よくある質問カード */
.quick-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 4px 0;
}

.quick-btn {
  padding: 8px 14px;
  background: #2a2a2a;
  border: 1px solid #444;
  border-radius: 20px;
  color: #c8a87c;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s;
}

.quick-btn:hover {
  background: #3a3a3a;
  border-color: #c8a87c;
}

/* ローディング */
.typing-indicator {
  display: flex;
  gap: 4px;
  padding: 4px 0;
}

.typing-indicator span {
  width: 8px;
  height: 8px;
  background: #666;
  border-radius: 50%;
  animation: bounce 1.4s infinite ease-in-out both;
}

.typing-indicator span:nth-child(1) { animation-delay: -0.32s; }
.typing-indicator span:nth-child(2) { animation-delay: -0.16s; }

@keyframes bounce {
  0%, 80%, 100% { transform: scale(0); }
  40% { transform: scale(1); }
}

.loading-text {
  font-size: 12px;
  color: #888;
  margin-top: 4px;
  min-height: 16px;
}

/* 入力エリア */
.chat-input-area {
  padding: 12px 16px;
  background: #2a2a2a;
  border-top: 1px solid #333;
}

#chatForm {
  display: flex;
  gap: 8px;
}

#chatInput {
  flex: 1;
  padding: 12px 16px;
  background: #333;
  border: 1px solid #444;
  border-radius: 24px;
  color: #e0e0e0;
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s;
}

#chatInput:focus {
  border-color: #c8a87c;
}

#chatInput::placeholder {
  color: #666;
}

#sendBtn {
  padding: 12px 20px;
  background: #c8a87c;
  color: #1a1a1a;
  border: none;
  border-radius: 24px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.2s;
  min-height: 44px;
}

#sendBtn:hover {
  opacity: 0.9;
}

#sendBtn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* キャッシュ表示 */
.cached-badge {
  display: inline-block;
  font-size: 10px;
  color: #666;
  margin-top: 4px;
}

/* アンケートモーダル */
.survey-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  z-index: 1000;
  justify-content: center;
  align-items: center;
  padding: 16px;
}

.survey-overlay.active {
  display: flex;
}

.survey-modal {
  background: #2a2a2a;
  border-radius: 16px;
  width: 100%;
  max-width: 420px;
  max-height: 85dvh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
  animation: fadeIn 0.3s ease;
}

.survey-header {
  padding: 24px 24px 16px;
  text-align: center;
  border-bottom: 1px solid #333;
}

.survey-lang-switcher {
  display: flex;
  justify-content: center;
  gap: 4px;
  margin-bottom: 16px;
}

.survey-lang-btn {
  background: #333;
  border: 1px solid #444;
  color: #888;
  font-size: 12px;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
}

.survey-lang-btn:hover {
  border-color: #c8a87c;
  color: #c8a87c;
}

.survey-lang-btn.active {
  background: #c8a87c;
  color: #1a1a1a;
  border-color: #c8a87c;
}

.survey-header h2 {
  font-size: 20px;
  color: #c8a87c;
  margin-bottom: 8px;
}

.survey-header p {
  font-size: 13px;
  color: #888;
  line-height: 1.6;
}

.survey-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px 24px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.survey-question {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.survey-question label {
  font-size: 13px;
  font-weight: 600;
  color: #ccc;
}

.survey-options {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.survey-option {
  padding: 6px 14px;
  background: #333;
  border: 1px solid #444;
  border-radius: 20px;
  color: #aaa;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.2s;
}

.survey-option:hover {
  border-color: #c8a87c;
  color: #c8a87c;
}

.survey-option.selected {
  background: #c8a87c;
  color: #1a1a1a;
  border-color: #c8a87c;
  font-weight: 600;
}

.survey-footer {
  padding: 16px 24px 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  border-top: 1px solid #333;
}

.survey-submit-btn {
  padding: 12px;
  background: #c8a87c;
  color: #1a1a1a;
  border: none;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.2s;
}

.survey-submit-btn:hover {
  opacity: 0.9;
}

.survey-skip-btn {
  padding: 8px;
  background: none;
  border: none;
  color: #666;
  font-size: 12px;
  cursor: pointer;
  transition: color 0.2s;
}

.survey-skip-btn:hover {
  color: #888;
}
