/* Full-screen chat — ai-flip style */
:root {
  --chat-bg: #0a0a0a;
  --chat-sidebar: #111;
  --chat-surface: #1a1a1a;
  --chat-border: rgba(255, 255, 255, 0.08);
  --chat-text: #ececec;
  --chat-muted: #888;
  --chat-user-bubble: #2a2a2a;
  --chat-composer-bg: #1c1c1c;
  --chat-sidebar-w: 52px;
  --chat-thread-max: 720px;
  font-family: Inter, system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body.chat-app {
  background: var(--chat-bg);
  color: var(--chat-text);
  overflow: hidden;
}

.material {
  font-family: 'Material Symbols Outlined';
  font-size: 22px;
  line-height: 1;
  font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 24;
}

.chat-app {
  display: grid;
  grid-template-columns: var(--chat-sidebar-w) 1fr;
  height: 100dvh;
}

/* Sidebar */
.chat-sidebar {
  background: var(--chat-sidebar);
  border-right: 1px solid var(--chat-border);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 12px 0;
  gap: 8px;
}
.chat-sidebar__logo {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: #ffd426;
  color: #111;
  font-size: 0.7rem;
  font-weight: 800;
  display: grid;
  place-items: center;
  text-decoration: none;
  margin-bottom: 8px;
}
.chat-sidebar__nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
}
.chat-sidebar__bottom {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.chat-sidebar__btn {
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 10px;
  background: transparent;
  color: var(--chat-muted);
  cursor: pointer;
  display: grid;
  place-items: center;
  text-decoration: none;
  padding: 0;
}
.chat-sidebar__btn:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.06);
  color: var(--chat-text);
}
.chat-sidebar__btn:disabled { opacity: 0.35; cursor: default; }

/* Main */
.chat-main {
  display: flex;
  flex-direction: column;
  min-width: 0;
  height: 100dvh;
  position: relative;
}
.chat-main__scroll {
  flex: 1;
  overflow: auto;
  scroll-behavior: smooth;
}
.chat-thread {
  max-width: var(--chat-thread-max);
  margin: 0 auto;
  padding: 48px 24px 160px;
  display: flex;
  flex-direction: column;
  gap: 28px;
}

/* Messages */
.chat-msg--user {
  display: flex;
  justify-content: flex-end;
}
.chat-msg__bubble {
  max-width: 85%;
  padding: 10px 16px;
  border-radius: 18px;
  background: var(--chat-user-bubble);
  color: var(--chat-text);
  font-size: 0.95rem;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
}
.chat-msg--assistant .chat-msg__text {
  font-size: 0.95rem;
  line-height: 1.65;
  color: var(--chat-text);
  white-space: pre-wrap;
  word-break: break-word;
}
.chat-msg--assistant .chat-msg__text.streaming::after {
  content: '▍';
  animation: chat-blink 1s step-end infinite;
}
@keyframes chat-blink { 50% { opacity: 0; } }

.chat-msg__actions {
  display: flex;
  gap: 2px;
  margin-top: 10px;
  opacity: 0;
  transition: opacity 0.15s;
}
.chat-msg--assistant:hover .chat-msg__actions { opacity: 1; }
.chat-msg__actions button {
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--chat-muted);
  cursor: pointer;
  display: grid;
  place-items: center;
  padding: 0;
}
.chat-msg__actions button .material { font-size: 18px; }
.chat-msg__actions button:hover {
  background: rgba(255, 255, 255, 0.06);
  color: var(--chat-text);
}

/* Composer */
.chat-composer-wrap {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 0 24px 24px;
  background: linear-gradient(transparent, var(--chat-bg) 40%);
  pointer-events: none;
}
.chat-composer__hint {
  max-width: var(--chat-thread-max);
  margin: 0 auto 6px;
  font-size: 0.72rem;
  color: var(--chat-muted);
  text-align: center;
  pointer-events: none;
}
.widget-chat__error {
  display: none;
  max-width: var(--chat-thread-max);
  margin: 0 auto 8px;
  color: #ff6b6b;
  font-size: 0.82rem;
  text-align: center;
  pointer-events: auto;
}
.widget-chat__error.show { display: block; }

.chat-composer {
  max-width: var(--chat-thread-max);
  margin: 0 auto;
  display: flex;
  align-items: flex-end;
  gap: 10px;
  pointer-events: auto;
}
.chat-composer__attach {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--chat-muted);
  cursor: pointer;
  display: grid;
  place-items: center;
  margin-bottom: 6px;
}
.chat-composer__attach:hover { color: var(--chat-text); }

.chat-composer__box {
  flex: 1;
  background: var(--chat-composer-bg);
  border: 1px solid var(--chat-border);
  border-radius: 20px;
  padding: 14px 16px 10px;
  min-width: 0;
}
.chat-composer__box textarea {
  width: 100%;
  border: none;
  background: transparent;
  color: var(--chat-text);
  font: inherit;
  font-size: 0.95rem;
  resize: none;
  outline: none;
  min-height: 24px;
  max-height: 160px;
  line-height: 1.5;
  padding: 0;
}
.chat-composer__box textarea::placeholder { color: #666; }

.chat-composer__toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
}
.chat-composer__model {
  position: relative;
  display: inline-flex;
  align-items: center;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 999px;
  padding: 0 28px 0 12px;
  max-width: 220px;
  cursor: pointer;
}
.chat-composer__model select {
  appearance: none;
  border: none;
  background: transparent;
  color: var(--chat-text);
  font: inherit;
  font-size: 0.78rem;
  padding: 6px 0;
  width: 100%;
  cursor: pointer;
  outline: none;
  text-overflow: ellipsis;
}
.chat-composer__model-arrow {
  position: absolute;
  right: 6px;
  font-size: 18px !important;
  color: var(--chat-muted);
  pointer-events: none;
}
.chat-composer__balance {
  flex: 1;
  font-size: 0.72rem;
  color: var(--chat-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.chat-composer__mic {
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--chat-muted);
  cursor: pointer;
  display: grid;
  place-items: center;
  padding: 0;
}
.chat-composer__mic:hover { color: var(--chat-text); }
.chat-composer__send {
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 10px;
  background: #333;
  color: #fff;
  cursor: pointer;
  display: grid;
  place-items: center;
  padding: 0;
  flex-shrink: 0;
}
.chat-composer__send:hover { background: #444; }
.chat-composer__send:disabled { opacity: 0.4; cursor: default; }
.chat-composer__send .material { font-size: 20px; }

/* Auth modal (shared) */
.auth-modal {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.auth-modal.is-open { display: flex; }
.auth-modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
}
.auth-modal__box {
  position: relative;
  width: 100%;
  max-width: 400px;
  background: #2a2a2a;
  border-radius: 16px;
  padding: 32px 28px 24px;
  color: #fff;
  box-shadow: 0 24px 48px rgba(0, 0, 0, 0.4);
}
.auth-modal__close {
  position: absolute;
  top: 14px;
  right: 16px;
  background: transparent;
  border: none;
  color: #888;
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
}
.auth-modal__title {
  margin: 0 0 24px;
  text-align: center;
  font-size: 1.5rem;
  font-weight: 700;
}
.auth-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  padding: 14px 16px;
  margin-bottom: 12px;
  border-radius: 10px;
  font: inherit;
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
}
.auth-btn--google { background: #fff; color: #333; border: none; }
.auth-btn--outline {
  background: transparent;
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.2);
}
.auth-btn--submit { background: #ffd426; color: #111; border: none; margin-bottom: 0; }
.auth-email-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 4px 0 12px;
}
.auth-email-form input {
  width: 100%;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  background: #1e1e1e;
  color: #fff;
  font: inherit;
}
.auth-modal__error {
  color: #ff6b6b;
  font-size: 0.85rem;
  text-align: center;
  margin: 0 0 8px;
}
.auth-modal__switch {
  text-align: center;
  margin: 16px 0 0;
  font-size: 0.9rem;
  color: #888;
}
.auth-modal__switch button {
  background: none;
  border: none;
  color: #fff;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  margin-left: 4px;
}

@media (max-width: 640px) {
  :root { --chat-sidebar-w: 44px; }
  .chat-thread { padding: 32px 16px 150px; }
  .chat-composer-wrap { padding: 0 12px 16px; }
  .chat-composer__balance { display: none; }
  .chat-msg__actions { opacity: 1; }
}
