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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Kaku Gothic ProN", "Hiragino Sans", "Meiryo", sans-serif;
  background: #f5f7fa;
  color: #333;
  line-height: 1.7;
  min-height: 100vh;
}

.chat-container {
  max-width: 720px;
  margin: 0 auto;
  background: #fff;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.chat-header {
  padding: 20px 16px;
  background: #5a7a9a;
  color: #fff;
  text-align: center;
}

.chat-header h1 {
  font-size: 1.3rem;
  margin-bottom: 4px;
  font-weight: 600;
}

.chat-subtitle {
  font-size: 0.85rem;
  opacity: 0.9;
}

.chat-examples {
  padding: 16px;
  background: #eef2f5;
  border-bottom: 1px solid #ddd;
}

.examples-label {
  font-size: 0.85rem;
  color: #666;
  margin-bottom: 8px;
}

.example-btn {
  display: block;
  width: 100%;
  padding: 10px 14px;
  margin-bottom: 6px;
  background: #fff;
  border: 1px solid #c8d4dd;
  border-radius: 8px;
  text-align: left;
  font-size: 0.9rem;
  color: #4a6a8a;
  cursor: pointer;
  font-family: inherit;
}

.example-btn:hover {
  background: #f0f5fa;
}

.example-btn:last-child {
  margin-bottom: 0;
}

.chat-messages {
  flex: 1;
  padding: 16px;
  overflow-y: auto;
  min-height: 200px;
}

.message {
  margin-bottom: 16px;
  display: flex;
}

.message.user {
  justify-content: flex-end;
}

.message.assistant {
  justify-content: flex-start;
}

.message-bubble {
  max-width: 80%;
  padding: 12px 16px;
  border-radius: 16px;
  font-size: 0.95rem;
  white-space: pre-wrap;
  word-wrap: break-word;
}

.message.user .message-bubble {
  background: #5a7a9a;
  color: #fff;
  border-bottom-right-radius: 4px;
}

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

.message-bubble strong {
  font-weight: 600;
}

.message-bubble code {
  background: rgba(0, 0, 0, 0.06);
  padding: 1px 5px;
  border-radius: 3px;
  font-family: "SF Mono", Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 0.88em;
}

.references {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px dashed rgba(0, 0, 0, 0.15);
}

.references-label {
  font-size: 0.8rem;
  color: #6a7a8a;
  margin-bottom: 6px;
  font-weight: 600;
}

.references ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

.references li {
  font-size: 0.85rem;
  margin-bottom: 4px;
  padding-left: 12px;
  position: relative;
}

.references li:before {
  content: "▸";
  position: absolute;
  left: 0;
  color: #5a7a9a;
}

.references a {
  color: #4a6a8a;
  text-decoration: none;
  border-bottom: 1px solid transparent;
}

.references a:hover {
  border-bottom-color: #4a6a8a;
}

.references .ref-no-link {
  color: #888;
  font-style: italic;
}

.message.user .message-bubble code {
  background: rgba(255, 255, 255, 0.2);
}

.message.loading .message-bubble {
  background: #eef2f5;
  color: #999;
  font-style: italic;
}

.message.error .message-bubble {
  background: #fdecea;
  color: #c0392b;
}

.chat-input-area {
  padding: 12px 16px;
  border-top: 1px solid #ddd;
  display: flex;
  gap: 8px;
  background: #fff;
}

#input {
  flex: 1;
  padding: 10px 12px;
  border: 1px solid #c8d4dd;
  border-radius: 8px;
  font-size: 0.95rem;
  font-family: inherit;
  resize: none;
}

#input:focus {
  outline: none;
  border-color: #5a7a9a;
}

#send-btn {
  padding: 10px 20px;
  background: #5a7a9a;
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 0.95rem;
  cursor: pointer;
  font-family: inherit;
}

#send-btn:disabled {
  background: #aaa;
  cursor: not-allowed;
}

.chat-disclaimer {
  padding: 10px 16px;
  background: #fff8e7;
  border-top: 1px solid #f0e0c0;
  font-size: 0.78rem;
  color: #7a6a4a;
  line-height: 1.5;
}

.chat-disclaimer p {
  margin-bottom: 4px;
}

.chat-disclaimer p:last-child {
  margin-bottom: 0;
}

.chat-footer {
  padding: 12px 16px;
  border-top: 1px solid #eee;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #fafafa;
}

.reset-btn {
  padding: 6px 12px;
  background: #fff;
  border: 1px solid #c8d4dd;
  border-radius: 6px;
  font-size: 0.85rem;
  color: #666;
  cursor: pointer;
  font-family: inherit;
}

.back-link {
  font-size: 0.85rem;
  color: #5a7a9a;
  text-decoration: none;
}

.back-link:hover {
  text-decoration: underline;
}

@media (max-width: 480px) {
  .chat-container {
    max-width: 100%;
  }
  .chat-header h1 {
    font-size: 1.1rem;
  }
  .message-bubble {
    max-width: 90%;
    font-size: 0.9rem;
  }
}
