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

:root {
  --bg: #f5f2eb;
  --text: #1a1a1a;
  --text-dim: #999;
  --border: #1a1a1a;
  --bubble-user: #1a1a1a;
  --bubble-god: #fff;
  --font: 'Courier Prime', 'Courier New', monospace;
}

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
}

.app {
  max-width: 580px;
  margin: 0 auto;
  height: 100vh;
  display: flex;
  flex-direction: column;
}

.header {
  text-align: center;
  padding: 28px 24px 16px;
  border-bottom: 1px solid #ddd;
  flex-shrink: 0;
}

.title {
  font-size: clamp(1.3rem, 4vw, 1.8rem);
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  margin-bottom: 4px;
}

.subtitle {
  font-size: 0.82rem;
  color: var(--text-dim);
  font-style: italic;
}

.mood-bar {
  flex-shrink: 0;
  padding: 10px 16px;
  border-bottom: 1px solid #ddd;
  display: flex;
  align-items: center;
  gap: 8px;
  overflow-x: auto;
  scrollbar-width: none;
}
.mood-bar::-webkit-scrollbar { display: none; }

.mood-label {
  font-size: 0.65rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--text-dim);
  white-space: nowrap;
  flex-shrink: 0;
}

.mood-pills { display: flex; gap: 6px; flex-shrink: 0; }

.mood-pill {
  background: transparent;
  border: 1px solid #ccc;
  border-radius: 100px;
  padding: 4px 12px;
  font-family: var(--font);
  font-size: 0.72rem;
  letter-spacing: 0.05em;
  cursor: pointer;
  color: var(--text-dim);
  transition: all 0.15s;
  white-space: nowrap;
}
.mood-pill:hover { border-color: var(--text); color: var(--text); }
.mood-pill.active { background: var(--text); border-color: var(--text); color: var(--bg); }

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

.empty-state {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  color: var(--text-dim);
  padding: 40px 24px;
  gap: 10px;
  pointer-events: none;
}
.empty-icon { font-size: 2.4rem; opacity: 0.35; }
.empty-text { font-size: 0.85rem; font-style: italic; line-height: 1.6; max-width: 240px; }

.msg-row {
  display: flex;
  flex-direction: column;
  gap: 2px;
  animation: msgIn 0.22s cubic-bezier(0.16,1,0.3,1) both;
}
.msg-row.user { align-items: flex-end; margin-top: 10px; }
.msg-row.god  { align-items: flex-start; margin-top: 10px; }

.msg-row.user + .msg-row.user,
.msg-row.god  + .msg-row.god  { margin-top: 3px; }

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

.msg-sender {
  font-size: 0.6rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--text-dim);
  padding: 0 14px;
  margin-bottom: 2px;
}

.bubble {
  max-width: 78%;
  padding: 10px 15px;
  font-size: 0.93rem;
  line-height: 1.6;
  border-radius: 18px;
  word-break: break-word;
}

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

.msg-row.god .bubble {
  background: var(--bubble-god);
  color: var(--text);
  border: 1px solid #e0ddd5;
  border-bottom-left-radius: 4px;
  font-style: italic;
}

.god-status {
  font-size: 0.7rem;
  color: var(--text-dim);
  font-style: italic;
  padding: 0 4px;
  margin-top: 6px;
  min-height: 16px;
  animation: fadeIn 0.3s ease both;
  align-self: flex-start;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@keyframes fadeOut {
  from { opacity: 1; }
  to   { opacity: 0; }
}

.typing-wrap {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  animation: msgIn 0.22s ease both;
  margin-top: 10px;
}

.typing-bubble {
  background: var(--bubble-god);
  border: 1px solid #e0ddd5;
  border-radius: 18px;
  border-bottom-left-radius: 4px;
  padding: 12px 16px;
  display: flex;
  gap: 5px;
  align-items: center;
}

.typing-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: #bbb;
  animation: typingBounce 1.1s ease-in-out infinite;
}
.typing-dot:nth-child(2) { animation-delay: 0.18s; }
.typing-dot:nth-child(3) { animation-delay: 0.36s; }

@keyframes typingBounce {
  0%, 80%, 100% { transform: translateY(0); background: #ccc; }
  40%           { transform: translateY(-5px); background: #888; }
}

.cursor {
  display: inline-block;
  width: 7px; height: 0.88em;
  background: var(--text);
  vertical-align: middle;
  margin-left: 1px;
  animation: blink 0.7s step-end infinite;
}

@keyframes blink {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0; }
}

.input-area {
  flex-shrink: 0;
  border-top: 1px solid #ddd;
  padding: 10px 14px;
  display: flex;
  gap: 10px;
  align-items: flex-end;
  background: var(--bg);
}

.new-chat-btn {
  background: transparent;
  border: none;
  font-family: var(--font);
  font-size: 0.65rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--text-dim);
  cursor: pointer;
  padding: 4px 0;
  transition: color 0.15s;
  flex-shrink: 0;
  padding-bottom: 10px;
}
.new-chat-btn:hover { color: var(--text); }

.input-wrap { flex: 1; }

textarea {
  width: 100%;
  background: #fff;
  border: 1px solid #ddd;
  border-radius: 20px;
  padding: 10px 16px;
  font-family: var(--font);
  font-size: 0.9rem;
  line-height: 1.5;
  color: var(--text);
  resize: none;
  outline: none;
  max-height: 120px;
  overflow-y: auto;
  transition: border-color 0.15s;
  display: block;
}
textarea::placeholder { color: #bbb; }
textarea:focus { border-color: #aaa; }

.send-btn {
  width: 38px; height: 38px;
  background: var(--text);
  border: none;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s, transform 0.1s;
  font-size: 1rem;
  color: var(--bg);
  padding-bottom: 1px;
  margin-bottom: 1px;
}
.send-btn:hover:not(:disabled) { background: #333; }
.send-btn:active:not(:disabled) { transform: scale(0.92); }
.send-btn:disabled { opacity: 0.3; cursor: not-allowed; }

.toast {
  position: fixed;
  bottom: 80px; left: 50%;
  transform: translateX(-50%) translateY(8px);
  background: var(--text);
  color: var(--bg);
  font-family: var(--font);
  font-size: 0.78rem;
  padding: 8px 18px;
  opacity: 0;
  transition: all 0.22s;
  pointer-events: none;
  white-space: nowrap;
  border-radius: 2px;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

@media (max-width: 480px) {
  .bubble { max-width: 86%; }
}