/* --- Bua design tokens (Worklyn family, shared with Dayo) ----------------- */
:root {
  --bg: #faf9f7;
  --ink: #1c1c1e;
  --muted: #a8a49c;
  --hairline: rgba(0, 0, 0, 0.07);
  --bubble: #efece7;      /* user bubble: warm tint, easy at all hours */
  --raised: #ffffff;
  --scrim: rgba(0, 0, 0, 0.28);
  --radius: 12px;
  --radius-lg: 20px;
  --shadow: 0 8px 32px rgba(0, 0, 0, 0.12), 0 1px 3px rgba(0, 0, 0, 0.06);
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1c1b1a;
    --ink: #ececea;
    --muted: #6f6c66;
    --hairline: rgba(255, 255, 255, 0.09);
    --bubble: #2a2927;
    --raised: #262524;
    --scrim: rgba(0, 0, 0, 0.5);
    --shadow: 0 8px 32px rgba(0, 0, 0, 0.5), 0 1px 3px rgba(0, 0, 0, 0.3);
  }
}

* { margin: 0; padding: 0; box-sizing: border-box; }
[hidden] { display: none !important; }

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.muted { color: var(--muted); }
.error { color: #c0392b; font-size: 14px; margin-top: 14px; }

/* --- login --- */
#view-login {
  min-height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.login-card { width: 100%; max-width: 320px; text-align: center; }
.logo { width: 60px; height: 60px; color: var(--ink); margin-bottom: 12px; }
.login-card h1 { font-size: 28px; font-weight: 600; letter-spacing: -0.02em; }
.tagline { font-size: 17px; color: var(--muted); margin: 6px 0 28px; }

.worklyn-signin {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  font-size: 15px;
  font-weight: 500;
  padding: 12px;
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  color: var(--ink);
  text-decoration: none;
}
.worklyn-signin:active { background: var(--hairline); }

/* --- chat shell --- */
#view-chat {
  display: flex;
  flex-direction: column;
  height: 100dvh;
}

.chat-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: calc(env(safe-area-inset-top, 0px) + 14px) 20px 10px;
}
.chat-title { font-size: 16px; font-weight: 600; letter-spacing: -0.01em; }

.avatar {
  width: 44px;
  height: 44px;
  margin: -8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  text-decoration: none;
  position: relative;
}
.avatar::before {
  content: "";
  position: absolute;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 1px solid var(--hairline);
}
.avatar img {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  object-fit: cover;
}

/* --- feed --- */
#feed {
  flex: 1;
  overflow-y: auto;
  width: 100%;
  max-width: 760px;
  margin: 0 auto;
  padding: 8px 20px 12px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  overscroll-behavior: contain;
  scrollbar-width: none;         /* Firefox */
}
#feed::-webkit-scrollbar { display: none; }  /* WebKit/Blink */

/* desktop: the reading column breathes a little wider than the composer */
@media (min-width: 900px) {
  #feed { max-width: 840px; }
}

.msg { animation: msg-in 240ms var(--ease); }
@keyframes msg-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

/* user: bubble, right (the grammar everyone knows) */
.msg-user {
  align-self: flex-end;
  max-width: 78%;
  background: var(--bubble);
  border-radius: 18px 18px 6px 18px;
  padding: 10px 14px;
  font-size: 16px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
}

/* assistant: no bubble, reads like a page */
.msg-assistant {
  align-self: flex-start;
  width: 100%;
  font-size: 16px;
  line-height: 1.7;
  word-break: break-word;
}
.msg-assistant.streaming::after {
  content: "▍";
  animation: blink 1.1s steps(1) infinite;
  color: var(--muted);
}
@keyframes blink { 50% { opacity: 0; } }

.msg-assistant p { margin: 0 0 10px; }
.msg-assistant p:last-child { margin-bottom: 0; }
.msg-assistant code {
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 14px;
  background: var(--hairline);
  border-radius: 5px;
  padding: 1px 5px;
}
.msg-assistant pre {
  background: var(--hairline);
  border-radius: var(--radius);
  padding: 12px 14px;
  overflow-x: auto;
  margin: 0 0 10px;
}
.msg-assistant pre code { background: none; padding: 0; }
.msg-assistant ul, .msg-assistant ol { margin: 0 0 10px; padding-left: 24px; }
.msg-assistant a { color: inherit; text-underline-offset: 3px; }
.msg-assistant strong { font-weight: 650; }

.msg-error {
  align-self: flex-start;
  font-size: 14px;
  color: var(--muted);
  border-left: 2px solid #c0392b;
  padding-left: 12px;
}

/* thinking indicator */
.thinking {
  align-self: flex-start;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  color: var(--muted);
}
.thinking .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--muted);
  animation: breathe 1.4s var(--ease) infinite;
}
@keyframes breathe {
  0%, 100% { transform: scale(0.8); opacity: 0.5; }
  50% { transform: scale(1.15); opacity: 1; }
}

.day-divider {
  align-self: center;
  font-size: 12px;
  color: var(--muted);
  padding: 6px 0;
}

/* --- composer --- */
.composer-wrap {
  width: 100%;
  max-width: 760px;
  margin: 0 auto;
  padding: 4px 16px calc(env(safe-area-inset-bottom, 0px) + 14px);
}

/* raised card: input on top, controls row beneath (Claude-style) */
.composer {
  display: flex;
  flex-direction: column;
  gap: 10px;
  border: none;
  border-radius: var(--radius-lg);
  padding: 14px 14px 12px 16px;
  background: var(--raised);
}

#input {
  width: 100%;
  border: none;
  outline: none;
  resize: none;
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-size: 16px;
  line-height: 1.5;
  max-height: 40dvh;
  caret-color: var(--ink);
  scrollbar-width: none;
}
#input::-webkit-scrollbar { display: none; }
#input::placeholder { color: var(--muted); }

.composer-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 32px;
}
.composer-hint { font-size: 12px; }

#send {
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 50%;
  background: var(--ink);
  color: var(--bg);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 150ms var(--ease), transform 150ms var(--ease);
}
#send:disabled { opacity: 0.25; cursor: default; transform: scale(0.94); }
