/* ==========================================================================
   Kumakomoyo AI — design tokens
   Palette sampled from the brand mark: maroon mountains, sunrise gradient,
   charcoal wordmark.
   ========================================================================== */
:root {
  --maroon-900: #5c0a0d;
  --maroon-800: #6f0c10;
  --maroon-700: #8a0d11;
  --crimson-600: #b01018;
  --crimson-500: #c81e1e;
  --sun-orange: #ec522c;
  --sun-red: #e72c25;
  --charcoal: #4a4a4a;
  --charcoal-light: #78716c;
  --cream: #fff8f5;
  --cream-deep: #fff1ec;
  --white: #ffffff;
  --line: rgba(138, 13, 17, 0.12);
  --shadow: 0 10px 30px rgba(92, 10, 13, 0.08);

  --font-display: "Poppins", "Segoe UI", sans-serif;
  --font-body: "Inter", "Segoe UI", sans-serif;
}

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

html, body {
  height: 100%;
}

body {
  font-family: var(--font-body);
  background: var(--cream);
  color: var(--charcoal);
  -webkit-font-smoothing: antialiased;
}

#root {
  height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ---------- header ---------- */

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 20px;
  background: linear-gradient(135deg, var(--cream-deep), var(--cream));
  border-bottom: 1px solid var(--line);
  position: relative;
  overflow: hidden;
  flex-shrink: 0;
}

.app-header::after {
  /* faint mountain silhouette watermark, echoes the logo */
  content: "";
  position: absolute;
  right: -40px;
  bottom: -40px;
  width: 220px;
  height: 120px;
  background: linear-gradient(160deg, var(--maroon-700), var(--maroon-900));
  clip-path: polygon(0% 100%, 18% 40%, 34% 68%, 52% 20%, 68% 55%, 84% 30%, 100% 100%);
  opacity: 0.06;
  pointer-events: none;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand-logo {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  object-fit: cover;
  flex-shrink: 0;
  box-shadow: var(--shadow);
}

.brand-text {
  min-width: 0;
}

.brand-title {
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 700;
  color: var(--maroon-700);
  letter-spacing: 0.2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.brand-subtitle {
  font-size: 10px;
  color: var(--charcoal-light);
  font-weight: 500;
  letter-spacing: 0.3px;
  text-transform: uppercase;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  z-index: 1;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--white);
  color: var(--maroon-700);
  cursor: pointer;
  transition: background 0.15s ease, transform 0.15s ease;
}

.icon-btn:hover {
  background: var(--cream-deep);
}

.icon-btn:active {
  transform: scale(0.94);
}

.website-btn {
  text-decoration: none;
}

.footer-note a {
  color: var(--crimson-600);
  text-decoration: none;
  font-weight: 500;
}

.footer-note a:hover {
  text-decoration: underline;
}

.website-link-btn {
  display: inline-block;
  margin-top: 10px;
  font-size: 12px;
  font-weight: 600;
  color: var(--maroon-700);
  text-decoration: none;
  border: 1px solid var(--line);
  padding: 8px 16px;
  border-radius: 999px;
  background: var(--white);
}

.website-link-btn:hover {
  background: var(--cream-deep);
}

.key-status {
  font-size: 10px;
  font-weight: 600;
  padding: 4px 8px;
  border-radius: 999px;
  letter-spacing: 0.3px;
  text-transform: uppercase;
}

.key-status.connected {
  color: #1a7a4c;
  background: #e6f6ee;
}

.key-status.disconnected {
  color: var(--crimson-600);
  background: var(--cream-deep);
}

/* ---------- chat area ---------- */

#chat-msgs {
  flex: 1;
  overflow-y: auto;
  padding: 20px 16px 8px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

#chat-msgs::-webkit-scrollbar {
  width: 4px;
}

#chat-msgs::-webkit-scrollbar-thumb {
  background: rgba(138, 13, 17, 0.15);
  border-radius: 4px;
}

.empty-state {
  margin: auto;
  text-align: center;
  max-width: 340px;
  padding: 32px 20px;
}

.empty-orb {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  margin: 0 auto 16px;
  background: radial-gradient(circle at 32% 30%, #ffd08a, var(--sun-orange) 45%, var(--sun-red) 75%, var(--maroon-700));
  box-shadow: 0 0 0 6px rgba(236, 82, 44, 0.08);
  animation: sunrise-pulse 3.2s ease-in-out infinite;
}

.empty-state h2 {
  font-family: var(--font-display);
  font-size: 17px;
  color: var(--maroon-700);
  margin-bottom: 8px;
}

.empty-state p {
  font-size: 13px;
  color: var(--charcoal-light);
  line-height: 1.6;
  margin-bottom: 18px;
}

.empty-state button {
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 600;
  color: var(--white);
  background: linear-gradient(135deg, var(--sun-orange), var(--crimson-600));
  border: none;
  padding: 10px 20px;
  border-radius: 999px;
  cursor: pointer;
  box-shadow: var(--shadow);
}

.msg-row {
  display: flex;
  gap: 10px;
  max-width: 88%;
  animation: fade-up 0.25s ease;
}

.msg-row.user {
  margin-left: auto;
  flex-direction: row-reverse;
}

.msg-row.assistant {
  margin-right: auto;
}

.avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  flex-shrink: 0;
  background: radial-gradient(circle at 32% 30%, #ffd08a, var(--sun-orange) 45%, var(--sun-red) 75%, var(--maroon-700));
}

.avatar.thinking {
  animation: sunrise-pulse 1.6s ease-in-out infinite;
}

.bubble {
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 13.5px;
  line-height: 1.55;
  word-wrap: break-word;
  white-space: pre-wrap;
}

.msg-row.user .bubble {
  background: linear-gradient(135deg, var(--crimson-500), var(--maroon-700));
  color: var(--white);
  border-bottom-right-radius: 4px;
}

.msg-row.assistant .bubble {
  background: var(--white);
  color: #292524;
  border: 1px solid var(--line);
  border-bottom-left-radius: 4px;
}

.msg-row.error .bubble {
  background: var(--cream-deep);
  color: var(--crimson-600);
  border: 1px solid rgba(184, 24, 24, 0.2);
}

.typing-dots {
  display: flex;
  gap: 5px;
  padding: 10px 4px;
  align-items: center;
}

.typing-dots span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--charcoal-light);
  animation: dot-bounce 1.2s ease infinite;
}

.typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-dots span:nth-child(3) { animation-delay: 0.4s; }

/* ---------- composer ---------- */

.composer {
  flex-shrink: 0;
  padding: 12px 16px 16px;
  background: var(--cream);
  border-top: 1px solid var(--line);
}

.composer-inner {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 6px 6px 6px 16px;
  box-shadow: var(--shadow);
  transition: border-color 0.15s ease;
}

.composer-inner:focus-within {
  border-color: var(--crimson-500);
}

.composer textarea {
  flex: 1;
  border: none;
  resize: none;
  font-family: var(--font-body);
  font-size: 13.5px;
  line-height: 1.5;
  max-height: 120px;
  padding: 8px 0;
  background: transparent;
  color: #292524;
}

.composer textarea:focus {
  outline: none;
}

.composer textarea::placeholder {
  color: #a8a29e;
}

.send-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  flex-shrink: 0;
  background: linear-gradient(135deg, var(--sun-orange), var(--crimson-600));
  color: var(--white);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.15s ease, opacity 0.15s ease;
}

.send-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.send-btn:not(:disabled):hover {
  transform: scale(1.06);
}

.footer-note {
  text-align: center;
  font-size: 10px;
  color: var(--charcoal-light);
  margin-top: 8px;
  letter-spacing: 0.2px;
}

.footer-note strong {
  color: var(--maroon-700);
}

/* ---------- settings modal ---------- */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(41, 37, 36, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 50;
}

.modal {
  width: 100%;
  max-width: 380px;
  background: var(--white);
  border-radius: 18px;
  padding: 22px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25);
}

.modal h3 {
  font-family: var(--font-display);
  font-size: 16px;
  color: var(--maroon-700);
  margin-bottom: 4px;
}

.modal p {
  font-size: 12px;
  color: var(--charcoal-light);
  line-height: 1.6;
  margin-bottom: 16px;
}

.modal p a {
  color: var(--crimson-600);
  font-weight: 600;
  text-decoration: none;
}

.modal label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  color: var(--charcoal);
  text-transform: uppercase;
  letter-spacing: 0.3px;
  margin-bottom: 6px;
}

.modal input[type="password"],
.modal input[type="text"],
.modal select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 13px;
  font-family: var(--font-body);
  margin-bottom: 14px;
  color: #292524;
  background: var(--cream);
}

.modal input:focus,
.modal select:focus {
  outline: none;
  border-color: var(--crimson-500);
}

.modal-actions {
  display: flex;
  gap: 10px;
  margin-top: 4px;
}

.modal-actions button {
  flex: 1;
  padding: 10px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 600;
  border: none;
  cursor: pointer;
  font-family: var(--font-body);
}

.btn-secondary {
  background: var(--cream-deep);
  color: var(--charcoal);
}

.btn-primary {
  background: linear-gradient(135deg, var(--sun-orange), var(--crimson-600));
  color: var(--white);
}

.modal-close {
  position: absolute;
  top: 14px;
  right: 14px;
}

/* ---------- animations ---------- */

@keyframes sunrise-pulse {
  0%, 100% { transform: scale(1); filter: brightness(1); }
  50% { transform: scale(1.08); filter: brightness(1.12); }
}

@keyframes dot-bounce {
  0%, 60%, 100% { transform: translateY(0); }
  30% { transform: translateY(-5px); }
}

@keyframes fade-up {
  0% { opacity: 0; transform: translateY(6px); }
  100% { opacity: 1; transform: translateY(0); }
}

@media (max-width: 480px) {
  .msg-row { max-width: 94%; }
  .brand-title { font-size: 14px; }
}
