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

body {
  font-family: -apple-system, Helvetica, Arial, sans-serif;
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  background: #f0f2f5;
  color: #1a1a1a;
}

/* Header */
#header {
  background: #1F4E79;
  color: #fff;
  padding: 12px 16px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

#header h1 {
  font-size: 18px;
  font-weight: 600;
  margin: 0;
}

#new-chat-btn {
  background: rgba(255,255,255,0.15);
  color: #fff;
  border: 1px solid rgba(255,255,255,0.3);
  border-radius: 6px;
  padding: 6px 12px;
  font-size: 13px;
  cursor: pointer;
}

/* Messages area */
#messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  -webkit-overflow-scrolling: touch;
}

/* Scrollbar */
#messages::-webkit-scrollbar {
  width: 4px;
}

#messages::-webkit-scrollbar-track {
  background: transparent;
}

#messages::-webkit-scrollbar-thumb {
  background: #c0c0c0;
  border-radius: 2px;
}

/* Messages */
.message {
  max-width: 85%;
  padding: 10px 14px;
  line-height: 1.45;
  font-size: 15px;
  word-wrap: break-word;
  white-space: pre-wrap;
}

.message.user {
  align-self: flex-end;
  background: #1F4E79;
  color: #fff;
  border-radius: 18px 4px 18px 18px;
}

.message.assistant {
  align-self: flex-start;
  background: #fff;
  color: #1a1a1a;
  border-radius: 4px 18px 18px 18px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
}

.message.error {
  align-self: flex-start;
  background: #fff0f0;
  color: #c0392b;
  border-radius: 4px 18px 18px 18px;
  border: 1px solid #f5c6cb;
}

/* System message */
.system-message {
  text-align: center;
  padding: 32px 20px;
  color: #555;
  font-size: 15px;
  line-height: 1.5;
}

.system-message .action-link {
  display: inline-block;
  margin-top: 16px;
  padding: 10px 24px;
  background: #1F4E79;
  color: #fff;
  text-decoration: none;
  border-radius: 20px;
  font-size: 15px;
  font-weight: 500;
}

/* Action cards */
.action-card {
  align-self: flex-start;
  max-width: 85%;
  background: #fff;
  border-left: 4px solid #1F4E79;
  border-radius: 4px 12px 12px 4px;
  padding: 16px;
  margin: 8px 0;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
}

.action-title {
  font-weight: 600;
  font-size: 15px;
  margin-bottom: 6px;
}

.action-details {
  font-size: 14px;
  color: #444;
  line-height: 1.45;
  margin-bottom: 12px;
}

.action-buttons {
  display: flex;
  gap: 8px;
}

.btn-accept {
  padding: 8px 20px;
  background: #1F4E79;
  color: #fff;
  border: none;
  border-radius: 16px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
}

.btn-accept:active {
  background: #163a5c;
}

.btn-cancel {
  padding: 8px 20px;
  background: transparent;
  color: #666;
  border: 1px solid #d0d0d0;
  border-radius: 16px;
  font-size: 14px;
  cursor: pointer;
}

.btn-cancel:active {
  background: #f0f0f0;
}

.action-status {
  font-size: 14px;
  color: #27ae60;
  font-weight: 500;
}

.action-status.cancelled {
  color: #999;
}

/* Loading dots */
.message.loading {
  display: flex;
  gap: 4px;
  padding: 14px 18px;
}

.dot {
  width: 8px;
  height: 8px;
  background: #999;
  border-radius: 50%;
  animation: pulse 1.4s infinite ease-in-out both;
}

.dot:nth-child(1) { animation-delay: 0s; }
.dot:nth-child(2) { animation-delay: 0.2s; }
.dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes pulse {
  0%, 80%, 100% {
    transform: scale(0.6);
    opacity: 0.4;
  }
  40% {
    transform: scale(1);
    opacity: 1;
  }
}

/* Input bar */
#input-bar {
  flex-shrink: 0;
  display: flex;
  gap: 8px;
  padding: 8px 12px;
  padding-bottom: calc(8px + env(safe-area-inset-bottom, 0px));
  background: #fff;
  border-top: 1px solid #e0e0e0;
}

#message-input {
  flex: 1;
  border: 1px solid #d0d0d0;
  border-radius: 20px;
  padding: 10px 16px;
  font-size: 16px;
  font-family: inherit;
  line-height: 1.4;
  resize: none;
  max-height: 120px;
  outline: none;
  transition: border-color 0.15s;
}

#message-input:focus {
  border-color: #1F4E79;
}

#send-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: #1F4E79;
  color: #fff;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: opacity 0.15s;
}

#send-btn:active {
  background: #163a5c;
}

#send-btn:disabled {
  opacity: 0.4;
  cursor: default;
}
