:root {
  --bg: #f5f3f0;
  --surface: #ffffff;
  --text: #2c2c2c;
  --text-light: #8c8c8c;
  --text-tiny: #b8b4ad;
  --border: #e8e5e0;
  --accent: #5b7a6f;
  --accent-light: #e8f0ec;
  --user-bubble: #e8f0ec;
  --ayan-bubble: #f7f5f2;
  --night-bg: #f0eee9;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Noto Sans SC", sans-serif;
  background: var(--bg);
  color: var(--text);
  height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  -webkit-font-smoothing: antialiased;
  user-select: none;
  transition: background 0.5s ease;
}

body.night-mode { background: var(--night-bg); }

.app {
  width: 100%;
  max-width: 420px;
  height: 100vh;
  max-height: 780px;
  background: var(--surface);
  display: flex;
  flex-direction: column;
  box-shadow: 0 0 40px rgba(0,0,0,0.06);
  overflow: hidden;
  position: relative;
  border-radius: 0;
  transition: background 0.5s ease;
}

body.night-mode .app { background: var(--night-bg); }

@media (min-width: 421px) {
  .app { border-radius: 24px; height: 90vh; }
}

.status-bar {
  padding: 12px 20px 8px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  color: var(--text-light);
  letter-spacing: 0.5px;
  border-bottom: 1px solid var(--border);
}

.status-bar .title { font-weight: 500; color: var(--text); opacity: 0.7; }

.memory-indicator {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--accent); opacity: 0.4;
  transition: all 0.6s ease;
}
.memory-indicator.warm { opacity: 0.9; box-shadow: 0 0 8px rgba(91,122,111,0.5); }

.chat-area {
  flex: 1; overflow-y: auto; padding: 12px 16px 20px;
  display: flex; flex-direction: column; gap: 14px; scroll-behavior: smooth;
}
.chat-area::-webkit-scrollbar { width: 3px; }
.chat-area::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

.message {
  max-width: 85%; padding: 10px 14px; border-radius: 18px;
  font-size: 15px; line-height: 1.6; letter-spacing: 0.3px;
  word-break: break-word; animation: fadeIn 0.3s ease;
}
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
.message.ayan { background: var(--ayan-bubble); align-self: flex-start; border-bottom-left-radius: 6px; }
.message.user { background: var(--user-bubble); align-self: flex-end; border-bottom-right-radius: 6px; }

.time-divider {
  text-align: center; font-size: 11px; color: var(--text-light);
  opacity: 0.5; letter-spacing: 1px; margin: 8px 0;
}
.privacy-note {
  text-align: center; font-size: 10px; color: var(--text-tiny);
  margin-top: 8px; opacity: 0.7; letter-spacing: 0.5px;
}
.greeting-card {
  background: #faf9f7; border-radius: 16px; padding: 20px; margin: 12px 0;
  text-align: center; color: var(--text-light); font-size: 13px;
  letter-spacing: 0.5px; line-height: 1.8; border: 1px solid var(--border);
}

.input-area {
  padding: 10px 16px 16px; border-top: 1px solid var(--border);
  display: flex; gap: 8px; align-items: center; background: var(--surface);
}
.input-area input {
  flex: 1; border: none; background: #f7f5f2; border-radius: 22px;
  padding: 12px 18px; font-size: 15px; font-family: inherit; outline: none;
  color: var(--text); letter-spacing: 0.3px; transition: background 0.2s;
}
.input-area input:focus { background: #efede9; }
.input-area input::placeholder { color: #bfbdb8; }

.icon-btn {
  width: 40px; height: 40px; border-radius: 50%; border: none;
  background: transparent; color: var(--accent); font-size: 20px;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
}
.icon-btn:active { background: var(--accent-light); }
.send-btn {
  width: 42px; height: 42px; border-radius: 50%; border: none;
  background: var(--accent); color: white; font-size: 18px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.send-btn:active { transform: scale(0.94); opacity: 0.85; }
.send-btn:disabled { background: #ccc; cursor: default; }

.typing-indicator {
  align-self: flex-start; padding: 10px 14px; background: var(--ayan-bubble);
  border-radius: 18px; border-bottom-left-radius: 6px; display: flex; gap: 4px;
}
.typing-indicator span {
  width: 5px; height: 5px; border-radius: 50%; background: #c5c2bc;
  animation: bounce 1.2s infinite;
}
.typing-indicator span:nth-child(2) { animation-delay: 0.15s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.3s; }
@keyframes bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-6px); opacity: 0.9; }
}