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

/* ── Design tokens ── */
:root {
  --bg: #F7F5F2;
  --bg2: #FFFFFF;
  --sidebar-bg: #EDE9E3;
  --surface: #FFFFFF;
  --border: rgba(0, 0, 0, 0.08);
  --border2: rgba(0, 0, 0, 0.12);
  --text: #1A1916;
  --text-muted: #6B6965;
  --text-faint: #A09C98;
  --accent: #D97757;
  --accent-dim: rgba(217, 119, 87, 0.12);
  --user-msg-bg: #E8E4DF;
  --danger: #C0392B;
  --danger-bg: rgba(192, 57, 43, 0.08);
  --success: #27AE60;
  --success-bg: rgba(39, 174, 96, 0.08);
  --radius: 12px;
  --sidebar-w: 280px;
  --ease: cubic-bezier(0.4, 0, 0.2, 1);
}

[data-theme="dark"] {
  --bg: #1A1916;
  --bg2: #242320;
  --sidebar-bg: #1F1D1A;
  --surface: #242320;
  --border: rgba(255, 255, 255, 0.07);
  --border2: rgba(255, 255, 255, 0.12);
  --text: #F0EDE8;
  --text-muted: #9B9895;
  --text-faint: #6B6865;
  --user-msg-bg: #2E2B27;
  --accent: #D97757;
  --accent-dim: rgba(217, 119, 87, 0.15);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]):not([data-theme="dark"]) {
    --bg: #1A1916;
    --bg2: #242320;
    --sidebar-bg: #1F1D1A;
    --surface: #242320;
    --border: rgba(255, 255, 255, 0.07);
    --border2: rgba(255, 255, 255, 0.12);
    --text: #F0EDE8;
    --text-muted: #9B9895;
    --text-faint: #6B6865;
    --user-msg-bg: #2E2B27;
    --accent: #D97757;
    --accent-dim: rgba(217, 119, 87, 0.15);
  }
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.7;
  min-height: 100vh;
}

.hidden {
  display: none !important;
}

/* ── Login ── */
#login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
}

.login-card {
  width: 380px;
  max-width: calc(100vw - 32px);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 40px 36px;
  text-align: center;
}

.login-logo {
  width: 52px;
  height: 52px;
  border-radius: 14px;
  object-fit: cover;
  margin-bottom: 16px;
}

.login-card h1 {
  font-size: 22px;
  font-weight: 500;
  color: var(--text);
  margin-bottom: 6px;
}

.login-sub {
  font-size: 13.5px;
  color: var(--text-muted);
  margin-bottom: 24px;
}

.auth-tabs {
  display: flex;
  gap: 2px;
  background: var(--bg);
  border-radius: 10px;
  padding: 3px;
  margin-bottom: 20px;
}

.auth-tab {
  flex: 1;
  padding: 8px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--text-muted);
  font-size: 13.5px;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.auth-tab.active {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 5px;
  text-align: left;
}

.field label {
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-muted);
}

.field input {
  background: var(--bg);
  border: 1px solid var(--border2);
  border-radius: 9px;
  padding: 10px 13px;
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
  outline: none;
  transition: border-color 0.15s;
  width: 100%;
}

.field input:focus {
  border-color: var(--accent);
}

.field input::placeholder {
  color: var(--text-faint);
}

.auth-error {
  font-size: 12.5px;
  color: var(--danger);
  background: var(--danger-bg);
  border-radius: 7px;
  padding: 8px 12px;
  text-align: left;
}

.btn-auth {
  padding: 11px;
  border-radius: 9px;
  border: none;
  background: var(--accent);
  color: #fff;
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: opacity 0.15s;
  margin-top: 4px;
}

.btn-auth:hover {
  opacity: 0.88;
}

.btn-auth:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Avatar upload (register) */
.avatar-upload {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  margin-bottom: 4px;
}

.avatar-preview {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  border: 2px dashed var(--border2);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  overflow: hidden;
  position: relative;
  color: var(--text-faint);
  font-size: 24px;
  transition: border-color 0.15s;
}

.avatar-preview:hover {
  border-color: var(--accent);
}

.avatar-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.avatar-label {
  font-size: 12px;
  color: var(--text-muted);
  cursor: pointer;
}

/* ── App layout ── */
#app {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* ── Sidebar ── */
#sidebar {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 16px 12px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 9px;
}

.brand-logo {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  object-fit: cover;
}

.brand-name {
  font-size: 15px;
  font-weight: 500;
  color: var(--text);
}

.icon-btn {
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 7px;
  background: transparent;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  flex-shrink: 0;
}

.icon-btn:hover {
  background: var(--border);
  color: var(--text);
}

.btn-new-conv {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 12px 8px;
  padding: 9px 13px;
  border-radius: 9px;
  border: none;
  background: var(--accent);
  color: #fff;
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  transition: opacity 0.15s;
}

.btn-new-conv:hover {
  opacity: 0.88;
}

.conv-section-label {
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.04em;
  color: var(--text-faint);
  text-transform: uppercase;
  padding: 8px 16px 4px;
}

#conv-list {
  flex: 1;
  overflow-y: auto;
  padding: 2px 8px 8px;
}

#conv-list::-webkit-scrollbar {
  width: 4px;
}

#conv-list::-webkit-scrollbar-thumb {
  background: var(--border2);
  border-radius: 4px;
}

.conv-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 9px 10px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.12s;
  gap: 6px;
  user-select: none;
}

.conv-item:hover {
  background: var(--border);
}

.conv-item.active {
  background: var(--accent-dim);
}

.conv-item-title {
  font-size: 13.5px;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  min-width: 0;
}

.conv-item.active .conv-item-title {
  color: var(--accent);
}

.conv-delete-btn {
  width: 24px;
  height: 24px;
  border: none;
  border-radius: 5px;
  background: transparent;
  color: var(--text-faint);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.1s, background 0.1s;
  flex-shrink: 0;
}

.conv-item:hover .conv-delete-btn {
  opacity: 1;
}

.conv-delete-btn:hover {
  background: var(--danger-bg);
  color: var(--danger);
}

/* Sidebar footer */
.sidebar-footer {
  padding: 12px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
  flex: 1;
}

.user-avatar-wrap {
  flex-shrink: 0;
}

.user-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  object-fit: cover;
}

.user-avatar-letter {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 600;
}

.user-name {
  font-size: 13.5px;
  font-weight: 500;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-actions {
  display: flex;
  gap: 2px;
  flex-shrink: 0;
}

/* ── Main ── */
#main {
  flex: 1;
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
  background: var(--bg);
}

.main-topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  flex-shrink: 0;
}

.conv-title {
  font-size: 14px;
  color: var(--text-muted);
  font-weight: 400;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── Cooldown banner ── */
.cooldown-banner {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 10px 20px;
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  font-size: 13.5px;
  color: var(--text-muted);
  flex-shrink: 0;
}

.cooldown-banner strong {
  color: var(--text);
}

/* ── Messages ── */
#messages-wrap {
  flex: 1;
  overflow-y: auto;
  padding: 24px 0;
  display: flex;
  flex-direction: column;
}

#messages-wrap::-webkit-scrollbar {
  width: 5px;
}

#messages-wrap::-webkit-scrollbar-thumb {
  background: var(--border2);
  border-radius: 4px;
}

#welcome {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 40px 20px;
  text-align: center;
}

.welcome-avatar {
  width: 64px;
  height: 64px;
  border-radius: 18px;
  overflow: hidden;
}

.welcome-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

#welcome h2 {
  font-size: 22px;
  font-weight: 500;
}

#welcome p {
  font-size: 14.5px;
  color: var(--text-muted);
}

#messages {
  max-width: 780px;
  width: 100%;
  margin: 0 auto;
  padding: 0 20px;
}

/* User message */
.msg-user {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 20px;
}

.msg-user-bubble {
  max-width: 72%;
  background: var(--user-msg-bg);
  border-radius: var(--radius);
  padding: 12px 16px;
  font-size: 14.5px;
  line-height: 1.65;
  white-space: pre-wrap;
  word-break: break-word;
  border: 1px solid var(--border);
}

/* AI message */
.msg-ai {
  display: flex;
  flex-direction: column;
  margin-bottom: 24px;
}

.msg-ai-header {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-bottom: 8px;
}

.msg-ai-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 600;
  flex-shrink: 0;
  overflow: hidden;
}

.msg-ai-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.msg-ai-name {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
}

.msg-ai-content {
  background: var(--surface);
  border: 0.5px solid var(--border2);
  border-radius: var(--radius);
  padding: 16px 18px;
  font-size: 14.5px;
  line-height: 1.75;
  word-break: break-word;
}

/* Markdown inside AI message */
.msg-ai-content p {
  margin: 0 0 10px;
}

.msg-ai-content p:last-child {
  margin-bottom: 0;
}

.msg-ai-content h1,
.msg-ai-content h2,
.msg-ai-content h3 {
  font-weight: 500;
  margin: 14px 0 6px;
  line-height: 1.3;
}

.msg-ai-content h1 {
  font-size: 17px;
}

.msg-ai-content h2 {
  font-size: 16px;
}

.msg-ai-content h3 {
  font-size: 15px;
}

.msg-ai-content ul,
.msg-ai-content ol {
  padding-left: 20px;
  margin: 6px 0;
}

.msg-ai-content li {
  margin: 3px 0;
}

.msg-ai-content pre {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px 16px;
  overflow-x: auto;
  margin: 10px 0;
  font-size: 13px;
}

.msg-ai-content code {
  font-family: "SF Mono", "Fira Code", monospace;
  font-size: 13px;
  background: var(--bg);
  border-radius: 4px;
  padding: 2px 5px;
  border: 1px solid var(--border);
}

.msg-ai-content pre code {
  background: none;
  border: none;
  padding: 0;
}

.msg-ai-content blockquote {
  border-left: 3px solid var(--accent);
  padding: 4px 0 4px 14px;
  color: var(--text-muted);
  margin: 8px 0;
}

.msg-ai-content a {
  color: var(--accent);
  text-decoration: none;
}

.msg-ai-content a:hover {
  text-decoration: underline;
}

.msg-ai-content strong {
  font-weight: 600;
}

.msg-ai-content hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 12px 0;
}

/* Action buttons */
.msg-actions {
  display: flex;
  align-items: center;
  gap: 2px;
  margin-top: 6px;
  padding-left: 2px;
  opacity: 0;
  transition: opacity 0.15s;
}

.msg-ai:hover .msg-actions {
  opacity: 1;
}

.msg-action-btn {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 5px 8px;
  border: none;
  border-radius: 7px;
  background: transparent;
  color: var(--text-faint);
  font-family: inherit;
  font-size: 12px;
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
}

.msg-action-btn:hover {
  background: var(--border);
  color: var(--text-muted);
}

.msg-action-btn.liked {
  color: var(--accent);
}

.msg-action-btn.disliked {
  color: var(--danger);
}

.reaction-count {
  font-size: 11.5px;
}

/* Typing indicator */
.msg-typing {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 24px;
}

.typing-header {
  display: flex;
  align-items: center;
  gap: 9px;
}

.typing-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 600;
  overflow: hidden;
}

.typing-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.typing-name {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
}

.typing-dots {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface);
  border: 0.5px solid var(--border2);
  border-radius: var(--radius);
  padding: 14px 18px;
  color: var(--text-muted);
  font-size: 13px;
}

.dots {
  display: flex;
  align-items: center;
  gap: 5px;
}

.dots span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-faint);
  animation: pulse 1.2s infinite;
}

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

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

@keyframes pulse {

  0%,
  80%,
  100% {
    opacity: 0.3;
    transform: scale(0.8);
  }

  40% {
    opacity: 1;
    transform: scale(1);
  }
}

/* ── Input area ── */
#input-area {
  border-top: 1px solid var(--border);
  background: var(--bg);
  flex-shrink: 0;
  padding: 12px 20px 16px;
}

#input-box {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  background: var(--surface);
  border: 1px solid var(--border2);
  border-radius: 14px;
  padding: 10px 12px;
  max-width: 780px;
  margin: 0 auto;
  transition: border-color 0.15s;
}

#input-box:focus-within {
  border-color: var(--accent);
}

#user-input {
  flex: 1;
  border: none;
  background: transparent;
  resize: none;
  font-family: inherit;
  font-size: 14.5px;
  color: var(--text);
  line-height: 1.6;
  max-height: 180px;
  outline: none;
  min-height: 24px;
}

#user-input::placeholder {
  color: var(--text-faint);
}

#btn-send {
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: opacity 0.15s;
}

#btn-send:hover {
  opacity: 0.85;
}

#btn-send:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.input-hint {
  font-size: 11.5px;
  color: var(--text-faint);
  text-align: center;
  margin-top: 8px;
}

/* ── Modals ── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 20px;
}

.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  overflow-y: auto;
}

.modal-sm {
  max-width: 380px;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--surface);
}

.modal-header h2 {
  font-size: 17px;
  font-weight: 500;
}

.modal-body {
  padding: 20px 24px 24px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.settings-section {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 4px 0;
}

.settings-section h3 {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.settings-divider {
  height: 1px;
  background: var(--border);
  margin: 8px 0;
}

.settings-avatar-row {
  display: flex;
  align-items: center;
  gap: 14px;
}

.settings-avatar {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  flex-shrink: 0;
  background: var(--accent);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  font-weight: 500;
  overflow: hidden;
}

.settings-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.settings-avatar-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

.settings-row {
  display: flex;
  gap: 8px;
}

.settings-row input {
  flex: 1;
}

.settings-section input {
  background: var(--bg);
  border: 1px solid var(--border2);
  border-radius: 9px;
  padding: 9px 13px;
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
  outline: none;
  transition: border-color 0.15s;
  width: 100%;
}

.settings-section input:focus {
  border-color: var(--accent);
}

.settings-section input::placeholder {
  color: var(--text-faint);
}

.settings-feedback {
  font-size: 12.5px;
  padding: 7px 11px;
  border-radius: 7px;
}

.settings-feedback.ok {
  background: var(--success-bg);
  color: var(--success);
}

.settings-feedback.err {
  background: var(--danger-bg);
  color: var(--danger);
}

.btn-primary {
  padding: 9px 16px;
  border-radius: 9px;
  border: none;
  background: var(--accent);
  color: #fff;
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  transition: opacity 0.15s;
  white-space: nowrap;
}

.btn-primary:hover {
  opacity: 0.88;
}

.btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-secondary {
  padding: 9px 16px;
  border-radius: 9px;
  border: 1px solid var(--border2);
  background: transparent;
  color: var(--text);
  font-family: inherit;
  font-size: 13.5px;
  cursor: pointer;
  transition: background 0.15s;
  white-space: nowrap;
  display: inline-block;
  text-align: center;
}

.btn-secondary:hover {
  background: var(--border);
}

.theme-row {
  display: flex;
  gap: 6px;
}

.theme-btn {
  padding: 7px 14px;
  border-radius: 8px;
  border: 1px solid var(--border2);
  background: transparent;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.15s;
}

.theme-btn.active {
  background: var(--accent-dim);
  color: var(--accent);
  border-color: var(--accent);
}

.theme-btn:hover:not(.active) {
  background: var(--border);
  color: var(--text);
}

.warning-icon {
  font-size: 36px;
  text-align: center;
  margin-bottom: 8px;
}

.warning-text {
  font-size: 14.5px;
  line-height: 1.6;
  color: var(--text);
  margin-bottom: 8px;
}

.warning-sub {
  font-size: 13px;
  color: var(--text-muted);
}

/* ── Sidebar overlay (mobile) ── */
#sidebar-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.3);
  z-index: 40;
  display: none;
}

#sidebar-overlay:not(.hidden) {
  display: block;
}

/* ── Responsive ── */
@media (max-width: 768px) {
  #sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    z-index: 50;
    transform: translateX(-100%);
    transition: transform 0.22s ease;
  }

  #sidebar.open {
    transform: translateX(0);
  }

  #messages {
    padding: 0 14px;
  }

  #input-area {
    padding: 10px 14px 14px;
  }

  .msg-user-bubble {
    max-width: 88%;
  }
}

@media (min-width: 769px) {
  #btn-sidebar-open {
    display: none;
  }

  #btn-sidebar-close {
    display: none;
  }
}

/* ══════════════════════════════════════════
   ANIMATIONS
══════════════════════════════════════════ */

@keyframes nx-fade-up {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes nx-scale-in {
  from { opacity: 0; transform: scale(0.95); }
  to   { opacity: 1; transform: scale(1); }
}
@keyframes nx-slide-down {
  from { opacity: 0; transform: translateY(-8px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes nx-shake {
  0%,  100% { transform: translateX(0); }
  18%        { transform: translateX(-6px); }
  38%        { transform: translateX(5px); }
  58%        { transform: translateX(-4px); }
  78%        { transform: translateX(3px); }
}
@keyframes nx-spin {
  to { transform: rotate(360deg); }
}
@keyframes nx-shimmer {
  from { background-position: -200% center; }
  to   { background-position:  200% center; }
}

/* ── Login card entrance ── */
.login-card {
  animation: nx-scale-in 0.35s var(--ease) both;
}

/* ── Input focus glow ── */
.field input,
.settings-section input {
  transition: border-color 0.2s var(--ease), box-shadow 0.2s var(--ease);
}
.field input:focus,
.settings-section input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(217, 119, 87, 0.15);
}

/* ── Error shake ── */
.auth-error.shake,
.settings-feedback.shake {
  animation: nx-shake 0.38s var(--ease);
}

/* ── btn-auth: lift + press + shimmer ── */
.btn-auth {
  position: relative;
  overflow: hidden;
  transition: opacity 0.15s var(--ease), transform 0.15s var(--ease);
}
.btn-auth:hover:not(:disabled) {
  opacity: 0.92;
  transform: translateY(-2px);
}
.btn-auth:active:not(:disabled) {
  transform: scale(0.97);
  transition-duration: 0.08s;
}
.btn-auth::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(
    105deg,
    transparent 30%,
    rgba(255, 255, 255, 0.22) 50%,
    transparent 70%
  );
  background-size: 200% 100%;
  opacity: 0;
  pointer-events: none;
  border-radius: inherit;
  transition: opacity 0.2s var(--ease);
}
.btn-auth:hover::after {
  opacity: 1;
  animation: nx-shimmer 0.5s var(--ease);
}

/* ── btn-new-conv ── */
.btn-new-conv {
  transition: opacity 0.15s var(--ease), transform 0.15s var(--ease);
}
.btn-new-conv:hover {
  opacity: 0.92;
  transform: translateY(-1px);
}
.btn-new-conv:active {
  transform: scale(0.97);
  transition-duration: 0.08s;
}

/* ── icon-btn ── */
.icon-btn {
  transition: background 0.15s var(--ease), color 0.15s var(--ease),
              transform 0.15s var(--ease);
}
.icon-btn:hover {
  background: var(--border);
  color: var(--text);
  transform: translateY(-1px);
}
.icon-btn:active {
  transform: scale(0.93);
  transition-duration: 0.08s;
}

/* ── Send button: lift + icon rotation ── */
#btn-send {
  transition: opacity 0.15s var(--ease), transform 0.15s var(--ease);
}
#btn-send:hover:not(:disabled) {
  opacity: 0.85;
  transform: translateY(-2px);
}
#btn-send:active:not(:disabled) {
  transform: scale(0.93);
  transition-duration: 0.08s;
}
#btn-send svg {
  transition: transform 0.2s var(--ease);
}
#btn-send:hover:not(:disabled) svg {
  transform: rotate(-15deg) scale(1.1);
}

/* ── Input box focus expand ── */
#input-box {
  transition: border-color 0.2s var(--ease), box-shadow 0.2s var(--ease);
}
#input-box:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(217, 119, 87, 0.1);
}

/* ── Message entrance ── */
.msg-user,
.msg-ai,
.msg-typing {
  animation: nx-fade-up 0.3s var(--ease) both;
}

/* ── Action buttons ── */
.msg-action-btn {
  transition: background 0.15s var(--ease), color 0.15s var(--ease),
              transform 0.12s var(--ease);
}
.msg-action-btn:hover {
  background: var(--border);
  color: var(--text-muted);
  transform: translateY(-1px);
}
.msg-action-btn:active {
  transform: scale(0.93);
  transition-duration: 0.06s;
}

/* ── Auth tab ── */
.auth-tab {
  transition: background 0.15s var(--ease), color 0.15s var(--ease);
}

/* ── Conv item entrance ── */
.conv-item {
  animation: nx-fade-up 0.25s var(--ease) both;
  transition: background 0.15s var(--ease);
}

/* ── Welcome stagger ── */
#welcome .welcome-avatar { animation: nx-fade-up 0.4s var(--ease) 0.05s both; }
#welcome h2              { animation: nx-fade-up 0.4s var(--ease) 0.12s both; }
#welcome p               { animation: nx-fade-up 0.4s var(--ease) 0.19s both; }

/* ── Modal entrance ── */
.modal-overlay:not(.hidden) .modal {
  animation: nx-scale-in 0.25s var(--ease) both;
}

/* ── Cooldown banner slide ── */
.cooldown-banner:not(.hidden) {
  animation: nx-slide-down 0.3s var(--ease) both;
}

/* ── Settings feedback ── */
.settings-feedback:not(.hidden) {
  animation: nx-fade-up 0.25s var(--ease) both;
}

/* ── Loading spinner ── */
.btn-spinner {
  display: inline-block;
  width: 12px;
  height: 12px;
  border: 2px solid rgba(255, 255, 255, 0.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: nx-spin 0.65s linear infinite;
  margin-right: 6px;
  vertical-align: middle;
}

/* ── btn-primary / btn-secondary ── */
.btn-primary,
.btn-secondary {
  transition: background 0.15s var(--ease), opacity 0.15s var(--ease),
              transform 0.15s var(--ease), border-color 0.15s var(--ease);
}
.btn-primary:hover,
.btn-secondary:hover {
  transform: translateY(-1px);
}
.btn-primary:active,
.btn-secondary:active {
  transform: scale(0.97);
  transition-duration: 0.08s;
}

/* ── Reduced motion ── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ══════════════════════════════════════════
   LANDING PAGE
══════════════════════════════════════════ */

.lp-body {
  background: var(--bg);
  color: var(--text);
  font-family: inherit;
}

/* ── Navbar ── */
.lp-nav {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(8px);
}

.lp-nav-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 24px;
  height: 60px;
  display: flex;
  align-items: center;
  gap: 32px;
}

.lp-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  color: var(--text);
  flex-shrink: 0;
}

.lp-brand-logo {
  width: 28px;
  height: 28px;
  border-radius: 7px;
  object-fit: cover;
}

.lp-brand-name {
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.3px;
}

.lp-nav-links {
  display: flex;
  align-items: center;
  gap: 4px;
  list-style: none;
  flex: 1;
}

.lp-nav-item {
  position: relative;
}

.lp-nav-btn {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 6px 12px;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  border-radius: 8px;
  transition: background 0.15s, color 0.15s;
  font-family: inherit;
}

.lp-nav-btn:hover {
  background: var(--accent-dim);
  color: var(--text);
}

.lp-chevron {
  transition: transform 0.2s;
  flex-shrink: 0;
}

.lp-nav-item.open .lp-chevron {
  transform: rotate(180deg);
}

/* Dropdown */
.lp-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  min-width: 300px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
  padding: 6px;
  z-index: 200;
}

.lp-nav-item.open .lp-dropdown {
  display: block;
}

.lp-dd-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 8px;
  text-decoration: none;
  color: var(--text);
  transition: background 0.15s;
}

.lp-dd-item:hover {
  background: var(--accent-dim);
}

.lp-dd-icon {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: var(--accent);
}

.lp-dd-item strong {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 2px;
}

.lp-dd-item span {
  display: block;
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.4;
}

.lp-cta-nav {
  margin-left: auto;
  padding: 7px 18px;
  background: var(--accent);
  color: #fff;
  border-radius: 8px;
  text-decoration: none;
  font-size: 14px;
  font-weight: 600;
  transition: opacity 0.15s;
  flex-shrink: 0;
}

.lp-cta-nav:hover {
  opacity: 0.88;
}

/* ── Shared section helpers ── */
.lp-section-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 24px;
}

.lp-section-label {
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent);
  margin-bottom: 10px;
}

.lp-section-title {
  font-size: 32px;
  font-weight: 700;
  letter-spacing: -0.5px;
  color: var(--text);
  margin-bottom: 48px;
}

/* ── Hero ── */
.lp-hero {
  padding: 80px 0 60px;
}

.lp-hero-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.lp-hero-badge {
  display: inline-block;
  padding: 4px 14px;
  background: var(--accent-dim);
  color: var(--accent);
  border-radius: 99px;
  font-size: 12px;
  font-weight: 600;
  margin-bottom: 24px;
  letter-spacing: 0.02em;
}

.lp-hero-title {
  font-size: clamp(36px, 5vw, 56px);
  font-weight: 700;
  letter-spacing: -1px;
  line-height: 1.12;
  margin-bottom: 20px;
  color: var(--text);
}

.lp-hero-accent {
  color: var(--accent);
}

.lp-hero-sub {
  max-width: 560px;
  font-size: 17px;
  line-height: 1.65;
  color: var(--text-muted);
  margin-bottom: 36px;
}

.lp-hero-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: center;
  margin-bottom: 56px;
}

.lp-btn-primary {
  padding: 11px 28px;
  background: var(--accent);
  color: #fff;
  border-radius: 10px;
  text-decoration: none;
  font-size: 15px;
  font-weight: 600;
  transition: opacity 0.15s;
  border: none;
  cursor: pointer;
}

.lp-btn-primary:hover {
  opacity: 0.88;
}

.lp-btn-ghost {
  padding: 11px 28px;
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border2);
  border-radius: 10px;
  text-decoration: none;
  font-size: 15px;
  font-weight: 500;
  transition: background 0.15s, border-color 0.15s;
}

.lp-btn-ghost:hover {
  background: var(--accent-dim);
  border-color: var(--accent);
}

/* Chat preview card */
.lp-hero-visual {
  width: 100%;
  max-width: 560px;
}

.lp-chat-preview {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.06);
  text-align: left;
}

.lp-chat-msg {
  display: flex;
  align-items: flex-end;
  gap: 10px;
}

.lp-chat-msg.lp-chat-user {
  flex-direction: row-reverse;
}

.lp-chat-avatar {
  width: 32px;
  height: 32px;
  border-radius: 9px;
  object-fit: cover;
  flex-shrink: 0;
}

.lp-chat-bubble {
  max-width: 80%;
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 13.5px;
  line-height: 1.55;
}

.lp-chat-ai .lp-chat-bubble {
  background: var(--bg);
  color: var(--text);
  border-bottom-left-radius: 4px;
}

.lp-chat-user .lp-chat-bubble {
  background: var(--accent);
  color: #fff;
  border-bottom-right-radius: 4px;
}

/* ── Features grid ── */
.lp-features {
  padding: 72px 0;
  background: var(--bg2);
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}

.lp-features-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
}

.lp-feature-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  transition: border-color 0.15s;
}

.lp-feature-card:hover {
  border-color: var(--accent);
}

.lp-feature-icon {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  background: var(--accent-dim);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent);
  margin-bottom: 16px;
}

.lp-feature-card h3 {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--text);
}

.lp-feature-card p {
  font-size: 13.5px;
  line-height: 1.6;
  color: var(--text-muted);
}

/* ── CTA banner ── */
.lp-cta-section {
  padding: 72px 0;
}

.lp-cta-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 16px;
}

.lp-cta-logo {
  width: 56px;
  height: 56px;
  border-radius: 14px;
  object-fit: cover;
  margin-bottom: 4px;
}

.lp-cta-inner h2 {
  font-size: 30px;
  font-weight: 700;
  letter-spacing: -0.4px;
  color: var(--text);
}

.lp-cta-inner p {
  font-size: 16px;
  color: var(--text-muted);
  max-width: 420px;
}

/* ── Footer ── */
.lp-footer {
  border-top: 1px solid var(--border);
  padding: 24px 0;
}

.lp-footer-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.lp-footer-brand {
  display: flex;
  align-items: center;
  gap: 8px;
}

.lp-footer-copy {
  font-size: 13px;
  color: var(--text-faint);
}

/* ── Landing responsive ── */
@media (max-width: 900px) {
  .lp-features-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 640px) {
  .lp-nav-links {
    display: none;
  }

  .lp-hero {
    padding: 48px 0 40px;
  }

  .lp-hero-title {
    font-size: 32px;
  }

  .lp-hero-sub {
    font-size: 15px;
  }

  .lp-features-grid {
    grid-template-columns: 1fr;
  }

  .lp-section-title {
    font-size: 24px;
  }

  .lp-footer-inner {
    flex-direction: column;
    align-items: flex-start;
  }
}

/* ── Landing: Dropdown animation ── */
.lp-nav-item.open .lp-dropdown {
  display: block;
  animation: nx-scale-in 0.2s var(--ease) both;
  transform-origin: top left;
}

/* ── Landing: Dropdown item hover upgrade ── */
.lp-dd-item {
  transition: background 0.15s var(--ease);
  cursor: default;
}

/* ── Landing: Nav buttons ── */
.lp-nav-btn {
  transition: background 0.15s var(--ease), color 0.15s var(--ease),
              transform 0.1s var(--ease);
}
.lp-nav-btn:hover {
  transform: translateY(-1px);
}

/* ── Landing: CTA buttons ── */
.lp-btn-primary {
  transition: opacity 0.15s var(--ease), transform 0.15s var(--ease);
}
.lp-btn-primary:hover {
  opacity: 0.88;
  transform: translateY(-2px);
}
.lp-btn-primary:active {
  transform: scale(0.97);
  transition-duration: 0.08s;
}
.lp-btn-ghost {
  transition: background 0.15s var(--ease), border-color 0.15s var(--ease),
              transform 0.15s var(--ease);
}
.lp-btn-ghost:hover {
  transform: translateY(-2px);
}
.lp-btn-ghost:active {
  transform: scale(0.97);
  transition-duration: 0.08s;
}
.lp-cta-nav {
  transition: opacity 0.15s var(--ease), transform 0.15s var(--ease);
}
.lp-cta-nav:hover {
  opacity: 0.88;
  transform: translateY(-1px);
}

/* ── Landing: Hero entrance ── */
.lp-hero-badge    { animation: nx-fade-up 0.5s var(--ease) 0.05s both; }
.lp-hero-title    { animation: nx-fade-up 0.5s var(--ease) 0.13s both; }
.lp-hero-sub      { animation: nx-fade-up 0.5s var(--ease) 0.21s both; }
.lp-hero-actions  { animation: nx-fade-up 0.5s var(--ease) 0.29s both; }
.lp-hero-visual   { animation: nx-fade-up 0.5s var(--ease) 0.38s both; }

/* ── Landing: Scroll animation base ── */
.lp-animate {
  opacity: 0;
  transform: translateY(16px);
  transition: opacity 0.5s var(--ease), transform 0.5s var(--ease);
}
.lp-animate.lp-visible {
  opacity: 1;
  transform: translateY(0);
}

/* ── Landing: Feature card hover ── */
.lp-feature-card {
  transition: border-color 0.2s var(--ease), transform 0.2s var(--ease),
              box-shadow 0.2s var(--ease);
}
.lp-feature-card:hover {
  border-color: var(--accent);
  transform: translateY(-3px);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.06);
}

/* ── Landing: CTA logo ── */
.lp-cta-logo {
  transition: transform 0.3s var(--ease);
}
.lp-cta-section:hover .lp-cta-logo {
  transform: rotate(-5deg) scale(1.05);
}