:root {
  --bg-app: #ffffff;
  --bg-chat: #f5f7fb;
  --bg-me: #007aff;
  --bg-other: #ffffff;
  --text-me: #ffffff;
  --text-other: #1a1a1a;
  --text-muted: #8e8e93;
  --border: #e5e5ea;
  --header-height: 64px;
  --footer-height: 70px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg-app: #1c1c1e;
    --bg-chat: #000000;
    --bg-me: #0a84ff;
    --bg-other: #2c2c2e;
    --text-me: #ffffff;
    --text-other: #ffffff;
    --text-muted: #98989d;
    --border: #38383a;
  }
}

* {
  box-sizing: border-box;
  -webkit-font-smoothing: antialiased;
}

body, html {
  margin: 0;
  padding: 0;
  height: 100%;
  width: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  background-color: var(--bg-app);
  overflow: hidden;
}

#app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: -webkit-fill-available;
  max-width: 600px;
  margin: 0 auto;
  position: relative;
  background: var(--bg-chat);
}

.app-header {
  height: var(--header-height);
  background: var(--bg-app);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 16px;
  flex-shrink: 0;
  z-index: 10;
}

.header-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.status-indicator {
  width: 10px;
  height: 10px;
  background: #34c759;
  border-radius: 50%;
  box-shadow: 0 0 0 2px var(--bg-app);
}

.text-info h1 {
  margin: 0;
  font-size: 17px;
  font-weight: 600;
  color: var(--text-other);
}

.text-info p {
  margin: 0;
  font-size: 12px;
  color: var(--text-muted);
}

#chat-window {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  scroll-behavior: smooth;
}

#messages-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.date-separator {
  text-align: center;
  margin: 20px 0;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.msg-wrapper {
  display: flex;
  flex-direction: column;
  margin-bottom: 12px;
  max-width: 85%;
}

.msg-wrapper.me {
  align-self: flex-end;
}

.msg-wrapper.other {
  align-self: flex-start;
}

.sender-info {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 2px;
  margin-left: 12px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.msg-bubble {
  padding: 8px 14px;
  border-radius: 18px;
  font-size: 15px;
  line-height: 1.4;
  word-wrap: break-word;
  position: relative;
  box-shadow: 0 1px 1px rgba(0,0,0,0.05);
}

.me .msg-bubble {
  background: var(--bg-me);
  color: var(--text-me);
  border-bottom-right-radius: 4px;
}

.other .msg-bubble {
  background: var(--bg-other);
  color: var(--text-other);
  border-bottom-left-radius: 4px;
}

.msg-time {
  font-size: 10px;
  margin-top: 4px;
  display: block;
  opacity: 0.7;
  text-align: right;
}

.me .msg-time {
  color: rgba(255,255,255,0.8);
}

.other .msg-time {
  color: var(--text-muted);
}

#typing-container {
  min-height: 20px;
  font-size: 12px;
  color: var(--text-muted);
  font-style: italic;
  margin-top: 4px;
}

.app-footer {
  padding: 10px 16px;
  padding-bottom: calc(10px + env(safe-area-inset-bottom));
  background: var(--bg-app);
  border-top: 1px solid var(--border);
}

#chat-form {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg-chat);
  border-radius: 24px;
  padding: 4px 6px 4px 16px;
  border: 1px solid var(--border);
}

#message-input {
  flex: 1;
  border: none;
  background: transparent;
  padding: 8px 0;
  font-size: 16px;
  color: var(--text-other);
  outline: none;
}

#send-btn {
  background: var(--bg-me);
  color: white;
  border: none;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.2s;
  flex-shrink: 0;
}

#send-btn:active {
  transform: scale(0.9);
}

#send-btn svg {
  width: 16px;
  height: 16px;
}

/* Animations */
@keyframes slideIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.msg-wrapper {
  animation: slideIn 0.2s ease-out forwards;
}