/* ── Reset & Variables ──────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:           #1a1f2e;
  --bg-raised:    #222838;
  --bg-hover:     rgba(255,255,255,0.06);
  --bg-active:    rgba(255,255,255,0.10);
  --sidebar-bg:   #151a26;
  --sidebar-w:    280px;
  --border:       #2a3346;
  --border-mid:   #354055;
  --text-1:       #e2e8f0;
  --text-2:       #94a3b8;
  --text-3:       #64748b;
  --text-4:       #475569;
  --user-bubble:  #1e3a5f;
  --input-bg:     #1e2433;
  --accent:       #f0f4f8;
  --green:        #34d399;
  --red:          #f87171;
  --header-h:     52px;
  --input-h:      72px;
  --radius:       12px;
  --font:         'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
}

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text-1);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  font-feature-settings: 'kern' 1, 'liga' 1, 'calt' 1;
}

/* ── Utilities ──────────────────────────────────────────────────────────── */
.hidden  { display: none !important; }
.icon-btn {
  background: transparent;
  border: none;
  color: var(--text-2);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 6px;
  border-radius: 8px;
  transition: background 0.15s, color 0.15s;
  flex-shrink: 0;
}
.icon-btn:hover { background: var(--bg-hover); color: var(--text-1); }

.error-msg {
  background: rgba(239,68,68,0.12);
  border: 1px solid rgba(239,68,68,0.3);
  color: #fca5a5;
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 0.8125rem;
  margin-bottom: 12px;
}
.rate-info {
  background: rgba(251,191,36,0.12);
  border: 1px solid rgba(251,191,36,0.3);
  color: #fcd34d;
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 0.8125rem;
  margin-bottom: 12px;
  text-align: center;
}

/* ── Scrollbar ──────────────────────────────────────────────────────────── */
::-webkit-scrollbar       { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #3a4556; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #4a5568; }

/* ═══════════════════════════════ LOGIN ═════════════════════════════════ */
#login-screen {
  min-height: 100vh;
  display: flex;
}

/* ── Left panel ───────────────────────────────────────────────────────── */
.login-left {
  width: 440px;
  min-width: 340px;
  background: var(--bg-raised);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 36px 48px;
}

.login-brand {
  flex-shrink: 0;
}
.brand-logo {
  height: 48px;
  width: auto;
  display: block;
}

.login-form-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  max-width: 320px;
  width: 100%;
  margin: 0 auto;
  padding: 40px 0;
}

.login-title {
  font-size: 1.625rem;
  font-weight: 700;
  color: var(--text-1);
  letter-spacing: -0.3px;
  margin-bottom: 6px;
}
.login-sub {
  font-size: 0.8rem;
  color: var(--text-3);
  margin-bottom: 32px;
}

/* Field groups */
.lf-group { margin-bottom: 14px; }
.lf-label {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-2);
  margin-bottom: 6px;
}
.lf-input-wrap {
  position: relative;
  display: flex;
  align-items: center;
}
.lf-icon {
  position: absolute;
  left: 13px;
  color: var(--text-3);
  pointer-events: none;
  flex-shrink: 0;
}
.lf-input-wrap input {
  display: block;
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border-mid);
  border-radius: 10px;
  color: var(--text-1);
  font-family: var(--font);
  font-size: 0.875rem;
  padding: 11px 14px 11px 38px;
  transition: border-color 0.15s;
  outline: none;
}
.lf-input-wrap input::placeholder { color: var(--text-3); }
.lf-input-wrap input:focus { border-color: #4a5a70; }

#login-btn {
  display: block;
  width: 100%;
  background: var(--accent);
  border: none;
  border-radius: 10px;
  color: #151a26;
  cursor: pointer;
  font-family: var(--font);
  font-size: 0.875rem;
  font-weight: 600;
  padding: 12px;
  margin-top: 8px;
  transition: background 0.15s;
}
#login-btn:hover    { background: #dde3eb; }
#login-btn:active   { background: #c8d0dc; }
#login-btn:disabled { opacity: 0.5; cursor: default; }

.login-footer-text {
  font-size: 1rem;
  color: var(--text-2);
  text-align: center;
  flex-shrink: 0;
}

/* ── Right panel ──────────────────────────────────────────────────────── */
.login-right {
  flex: 1;
  background: var(--sidebar-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}

.login-deco {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  z-index: 1;
}

/* Decorative concentric rings */
.ring {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  border: 1px solid var(--border);
  pointer-events: none;
}
.r1 { width: 160px; height: 160px; }
.r2 { width: 300px; height: 300px; opacity: 0.6; }
.r3 { width: 440px; height: 440px; opacity: 0.3; }

/* Central floating card */
.deco-card {
  width: 180px;
  height: 100px;
  background: var(--bg-raised);
  border: 1px solid var(--border-mid);
  border-radius: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px 24px;
  margin-bottom: 20px;
  box-shadow: 0 8px 40px rgba(0,0,0,0.35);
  position: relative;
  z-index: 1;
}
.deco-logo {
  width: 100%;
  height: auto;
  display: block;
}
.deco-sub {
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--text-1);
  position: relative;
  z-index: 1;
}

.deco-copyright {
  font-size: 0.75rem;
  color: var(--text-3);
  position: relative;
  z-index: 1;
  margin-top: 8px;
}

/* ═════════════════════════════════ APP ═════════════════════════════════ */
#app {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* ── Mobile overlay ──────────────────────────────────────────────────── */
#sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 40;
}
#sidebar-overlay.active { display: block; }

/* ═══════════════════════════════ SIDEBAR ═══════════════════════════════ */
#sidebar {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  height: 100vh;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  flex-shrink: 0;
  position: relative;
  z-index: 50;
  transition: transform 0.25s ease;
}

/* Top: logo + close btn */
.sb-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 12px 14px 14px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.sb-logo {
  display: flex;
  align-items: center;
}
.sb-logo-img {
  height: 38px;
  width: auto;
  display: block;
}
#sidebar-close { display: none; }

/* New chat button */
.new-chat-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  background: transparent;
  border: 1px solid var(--border-mid);
  border-radius: 8px;
  color: var(--text-2);
  cursor: pointer;
  font-family: var(--font);
  font-size: 0.8125rem;
  font-weight: 500;
  padding: 8px 12px;
  margin: 10px 8px 4px;
  transition: background 0.1s, border-color 0.1s, color 0.1s;
  flex-shrink: 0;
}
.new-chat-btn:hover {
  background: var(--bg-hover);
  border-color: #3a4a5e;
  color: var(--text-1);
}
.new-chat-btn svg { flex-shrink: 0; }

/* Agents section */
#agents-section {
  padding: 0 8px;
  flex-shrink: 0;
}
.sb-section-label {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-3);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 0 12px;
  margin-top: 8px;
  flex-shrink: 0;
}

/* Agent button */
.agent-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  background: transparent;
  border: none;
  border-radius: 8px;
  color: var(--text-2);
  cursor: pointer;
  font-family: var(--font);
  font-size: 0.9rem;
  padding: 10px 12px;
  text-align: left;
  transition: background 0.1s, color 0.1s;
  margin-bottom: 2px;
}
.agent-btn:hover { background: var(--bg-hover); color: var(--text-1); }
.agent-btn.active { background: var(--bg-active); color: var(--text-1); font-weight: 500; }
.agent-btn-icon { font-size: 1.1rem; flex-shrink: 0; }
.agent-btn-name { font-weight: 500; font-size: 0.9rem; }
.agent-btn-desc { font-size: 0.75rem; color: var(--text-3); margin-top: 2px; }

/* Divider */
.sb-divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 10px 8px;
  flex-shrink: 0;
}

/* Threads list */
.threads-list {
  flex: 1;
  overflow-y: auto;
  padding: 0 8px;
  min-height: 0;
}
.sb-empty {
  font-size: 0.875rem;
  color: var(--text-3);
  padding: 8px 4px;
}
.thread-item {
  display: flex;
  align-items: center;
  border-radius: 8px;
  margin-bottom: 3px;
  transition: background 0.1s;
}
.thread-item:hover { background: var(--bg-hover); }
.thread-item.active { background: var(--bg-active); }
.thread-item:hover .thread-del-btn { opacity: 1; }
.thread-btn {
  display: block;
  flex: 1;
  min-width: 0;
  background: transparent;
  border: none;
  border-radius: 8px;
  color: var(--text-2);
  cursor: pointer;
  font-family: var(--font);
  text-align: left;
  padding: 9px 10px;
  transition: color 0.1s;
  overflow: hidden;
}
.thread-item:hover .thread-btn,
.thread-item.active .thread-btn { color: var(--text-1); }
.thread-del-btn {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  color: var(--text-4);
  padding: 5px 7px;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s, color 0.1s, background 0.1s;
  border-radius: 6px;
  margin-right: 4px;
}
.thread-del-btn:hover { color: #e55; background: rgba(220, 50, 50, 0.12); }

/* Admin user list */
.admin-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-right: 8px;
}
.admin-add-btn {
  background: transparent;
  border: 1px solid var(--border-mid);
  border-radius: 6px;
  color: var(--text-3);
  cursor: pointer;
  padding: 4px 6px;
  display: flex;
  align-items: center;
  transition: background 0.1s, color 0.1s, border-color 0.1s;
}
.admin-add-btn:hover { background: var(--bg-hover); color: var(--green); border-color: var(--green); }

.admin-user-item {
  display: flex;
  align-items: center;
  border-radius: 8px;
  margin-bottom: 2px;
  transition: background 0.1s;
}
.admin-user-item:hover { background: var(--bg-hover); }
.admin-user-item:hover .admin-user-del-btn { opacity: 1; }

.admin-user-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 0;
  background: transparent;
  border: none;
  border-radius: 8px;
  color: var(--text-2);
  cursor: pointer;
  font-family: var(--font);
  font-size: 0.875rem;
  text-align: left;
  padding: 8px 10px;
  transition: background 0.1s, color 0.1s;
}
.admin-user-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.admin-badge {
  font-size: 0.65rem;
  font-weight: 600;
  color: var(--green);
  background: rgba(52,211,153,0.12);
  border-radius: 4px;
  padding: 1px 5px;
  margin-left: auto;
  flex-shrink: 0;
}
.admin-user-btn:hover { color: var(--text-1); }
.admin-user-btn.active { background: var(--bg-active); color: var(--accent); }

.admin-user-del-btn {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  color: var(--text-4);
  padding: 5px 7px;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s, color 0.1s, background 0.1s;
  border-radius: 6px;
  margin-right: 4px;
}
.admin-user-del-btn:hover { color: #e55; background: rgba(220,50,50,0.12); }

/* Create user form */
.create-user-form {
  background: var(--bg-raised);
  border: 1px solid var(--border-mid);
  border-radius: 10px;
  padding: 14px 12px;
  margin: 8px 0;
}
.cuf-title {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-1);
  margin-bottom: 10px;
}
.create-user-form input[type="text"],
.create-user-form input[type="password"] {
  display: block;
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border-mid);
  border-radius: 7px;
  color: var(--text-1);
  font-family: var(--font);
  font-size: 0.8125rem;
  padding: 8px 10px;
  margin-bottom: 8px;
  outline: none;
  transition: border-color 0.15s;
}
.create-user-form input:focus { border-color: #4a5a70; }
.cuf-password-wrap {
  position: relative;
  display: flex;
  align-items: center;
}
.cuf-password-wrap input { padding-right: 34px; }
.cuf-toggle-pw {
  position: absolute;
  right: 6px;
  background: transparent;
  border: none;
  color: var(--text-3);
  cursor: pointer;
  padding: 4px;
  display: flex;
  align-items: center;
  border-radius: 4px;
  transition: color 0.15s;
}
.cuf-toggle-pw:hover { color: var(--text-1); }
.create-user-form input::placeholder { color: var(--text-4); }
.cuf-agents-label {
  font-size: 0.75rem;
  color: var(--text-3);
  margin-bottom: 4px;
}
.cuf-agents { margin-bottom: 8px; }
.cuf-checkbox {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8125rem;
  color: var(--text-2);
  cursor: pointer;
  margin-bottom: 4px;
}
.cuf-checkbox input { accent-color: var(--green); }
.cuf-actions {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}
.cuf-btn {
  flex: 1;
  padding: 7px 0;
  border: none;
  border-radius: 7px;
  font-family: var(--font);
  font-size: 0.8125rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s;
}
.cuf-btn-cancel {
  background: transparent;
  border: 1px solid var(--border-mid);
  color: var(--text-2);
}
.cuf-btn-cancel:hover { background: var(--bg-hover); }
.cuf-btn-submit {
  background: var(--green);
  color: #151a26;
}
.cuf-btn-submit:hover { background: #2ec48a; }
.cuf-error {
  margin-top: 8px;
  font-size: 0.75rem;
  color: #fca5a5;
  text-align: center;
}

/* Admin view notice in input area */
#admin-view-notice {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 0.78rem;
  color: var(--text-3);
  padding: 6px 16px 0;
}
.thread-title {
  font-size: 0.875rem;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.thread-date { font-size: 0.75rem; color: var(--text-3); margin-top: 2px; }

/* Footer */
.sb-footer {
  border-top: 1px solid var(--border);
  padding: 12px 8px;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}
.user-badge {
  display: flex;
  align-items: center;
  gap: 9px;
  flex: 1;
  min-width: 0;
}
.user-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: #2d3548;
  color: var(--text-2);
  font-size: 0.75rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.user-info { min-width: 0; }
.user-name {
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-1);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.user-role { font-size: 0.7rem; color: var(--text-4); }
.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--green);
  flex-shrink: 0;
}
.logout-btn {
  background: transparent;
  border: none;
  color: var(--text-3);
  cursor: pointer;
  padding: 6px;
  border-radius: 7px;
  display: flex;
  align-items: center;
  transition: background 0.1s, color 0.1s;
  flex-shrink: 0;
}
.logout-btn:hover { background: var(--bg-hover); color: var(--red); }

/* ═════════════════════════════════ MAIN ════════════════════════════════ */
#main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  height: 100vh;
  overflow: hidden;
  background: var(--bg);
}

/* Header */
#main-header {
  height: var(--header-h);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 20px;
  flex-shrink: 0;
}
#hamburger { display: none; }

#agent-header-info {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 0;
}
#agent-header-icon { font-size: 1.1rem; flex-shrink: 0; }
#agent-header-icon .icon-img { width: 28px; height: 28px; border-radius: 6px; }
#agent-header-name {
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--text-1);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
#agent-header-desc {
  font-size: 0.75rem;
  color: var(--text-3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.online-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--green);
  flex-shrink: 0;
}

/* Messages container */
#messages-container {
  flex: 1;
  overflow-y: auto;
  min-height: 0;
}
#messages-inner {
  max-width: 720px;
  margin: 0 auto;
  padding: 24px 20px 8px;
}

/* ── Hero zone (empty state) ─────────────────────────────────────────── */
#hero-zone {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 28px;
  padding: 48px 24px 28px;
  min-height: 0;
  overflow-y: auto;
}

.hero-agent {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  text-align: center;
}
.hero-icon { font-size: 3rem; line-height: 1; }
.hero-icon .icon-img { width: 96px; height: 96px; object-fit: contain; border-radius: 16px; }

.icon-img { width: 1.4em; height: 1.4em; object-fit: contain; vertical-align: middle; }
.hero-name {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-1);
  letter-spacing: -0.3px;
}
.hero-desc { font-size: 0.875rem; color: var(--text-3); }

.hero-welcome {
  max-width: 620px;
  width: 100%;
}

.hero-welcome-details {
  background: #1e2536;
  border: 1px solid #2a3346;
  border-radius: 14px;
  overflow: hidden;
}

.hero-welcome-details summary {
  list-style: none;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 13px 20px;
  cursor: pointer;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-2);
  user-select: none;
  transition: color 0.15s;
}
.hero-welcome-details summary::-webkit-details-marker { display: none; }
.hero-welcome-details summary::before {
  content: '▶';
  font-size: 0.65rem;
  color: var(--text-4);
  transition: transform 0.2s;
  display: inline-block;
}
.hero-welcome-details[open] summary::before {
  transform: rotate(90deg);
}
.hero-welcome-details summary:hover { color: var(--text-1); }

.hero-welcome-body {
  padding: 0 20px 18px;
  color: var(--text-2);
  font-size: 0.9375rem;
  line-height: 1.7;
  border-top: 1px solid #2a3346;
}


/* ── Messages ─────────────────────────────────────────────────────────── */
.msg-row {
  display: flex;
  margin-bottom: 6px;
  padding: 2px 0;
}
.msg-row.user      { justify-content: flex-end; }
.msg-row.assistant { justify-content: flex-start; }
.msg-row.user + .msg-row.assistant,
.msg-row.assistant + .msg-row.user { margin-top: 10px; }

/* User bubble */
.msg-row.user .msg-content {
  background: var(--user-bubble);
  border-radius: 18px 18px 4px 18px;
  border: 1px solid rgba(96, 165, 250, 0.18);
  padding: 11px 16px;
  max-width: 72%;
  color: #e8ecf2;
  font-size: 0.9375rem;
  line-height: 1.65;
  word-break: break-word;
}

/* Assistant bubble */
.msg-row.assistant .msg-content {
  background: #1e2536;
  border: 1px solid #2a3346;
  border-radius: 4px 18px 18px 18px;
  padding: 14px 18px;
  max-width: 85%;
  color: #d0d8e4;
  font-size: 0.9375rem;
  line-height: 1.75;
  word-break: break-word;
}

/* Markdown inside assistant */
.msg-content p          { margin: 0 0 10px 0; }
.msg-content p:last-child { margin-bottom: 0; }
.msg-content h1, .msg-content h2, .msg-content h3 {
  color: var(--text-1);
  font-weight: 600;
  margin: 18px 0 8px;
}
.msg-content h1 { font-size: 1.15rem; }
.msg-content h2 { font-size: 1.05rem; }
.msg-content h3 { font-size: 0.9625rem; }
.msg-content ul, .msg-content ol {
  padding-left: 22px;
  margin: 8px 0 10px;
}
.msg-content li { margin-bottom: 5px; }
.msg-content code {
  background: #171d2b;
  border: 1px solid var(--border-mid);
  border-radius: 4px;
  font-family: 'JetBrains Mono', 'Fira Mono', monospace;
  font-size: 0.8rem;
  padding: 1px 5px;
  color: #e2e8f0;
}
.msg-content pre {
  background: #151b28;
  border: 1px solid var(--border-mid);
  border-radius: 8px;
  overflow-x: auto;
  padding: 14px 16px;
  margin: 8px 0;
}
.msg-content pre code {
  background: none;
  border: none;
  padding: 0;
  font-size: 0.8125rem;
  line-height: 1.6;
}
.msg-content blockquote {
  border-left: 3px solid #3a4a60;
  color: var(--text-3);
  margin: 6px 0;
  padding: 4px 0 4px 14px;
}
.msg-content table {
  border-collapse: collapse;
  width: 100%;
  margin: 8px 0;
  font-size: 0.8125rem;
}
.msg-content th, .msg-content td {
  border: 1px solid var(--border-mid);
  padding: 7px 12px;
  text-align: left;
}
.msg-content th { background: #1e2433; color: var(--text-1); font-weight: 600; }
.msg-content a { color: #60a5fa; text-decoration: underline; }
.msg-content strong { color: var(--text-1); font-weight: 600; }
.msg-content hr { border: none; border-top: 1px solid var(--border); margin: 12px 0; }

/* Typing indicator */
.typing-indicator {
  display: flex;
  gap: 4px;
  padding: 12px 4px 4px;
}
.typing-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-4);
  animation: bounce 1.3s infinite ease-in-out;
}
.typing-dot:nth-child(1) { animation-delay: 0s; }
.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }
@keyframes bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.5; }
  30%            { transform: translateY(-6px); opacity: 1; }
}

/* ── Input area ───────────────────────────────────────────────────────── */
#input-area {
  padding: 10px 20px 16px;
  flex-shrink: 0;
  background: linear-gradient(to top, var(--bg) 75%, transparent);
}
.input-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--input-bg);
  border: 1.5px solid var(--border-mid);
  border-radius: var(--radius);
  padding: 10px 10px 10px 14px;
  max-width: 720px;
  margin: 0 auto;
  transition: border-color 0.15s;
}
.input-wrap:focus-within { border-color: #4a5a70; }

#message-input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text-1);
  font-family: var(--font);
  font-size: 0.875rem;
  line-height: 1.5;
  resize: none;
  max-height: 200px;
  overflow-y: auto;
  caret-color: var(--text-1);
}
#message-input::placeholder { color: var(--text-3); }

#send-btn {
  background: var(--accent);
  border: none;
  border-radius: 8px;
  color: #151a26;
  cursor: pointer;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s, opacity 0.15s;
}
#send-btn:hover:not(:disabled) { background: #dde3eb; }
#send-btn:disabled { opacity: 0.3; cursor: default; }

.input-hint {
  text-align: center;
  font-size: 0.7rem;
  color: var(--text-4);
  margin-top: 6px;
  max-width: 720px;
  margin-left: auto;
  margin-right: auto;
}

/* ═══════════════════════════ RESPONSIVE ════════════════════════════════ */

/* Tablet: 768px – 1024px */
@media (max-width: 1024px) {
  :root { --sidebar-w: 240px; }
  #messages-inner { padding: 20px 16px 8px; }
}

/* Mobile: ≤ 767px */
@media (max-width: 767px) {
  /* Sidebar becomes drawer */
  #sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    transform: translateX(-100%);
    z-index: 50;
    box-shadow: 4px 0 24px rgba(0,0,0,0.4);
  }
  #sidebar.open { transform: translateX(0); }
  #sidebar-close { display: flex; }

  /* Show hamburger */
  #hamburger { display: flex; }

  #main-header { padding: 0 14px; }

  #agent-header-desc { display: none; }

  #messages-inner { padding: 16px 12px 8px; }

  .msg-row.user .msg-content { max-width: 88%; }
  .msg-row.assistant .msg-content { max-width: 100%; }

  #input-area { padding: 8px 12px 14px; }
  .input-hint  { display: none; }

  /* Login: hide right panel, left fills screen */
  .login-right { display: none; }
  .login-left {
    width: 100%;
    min-width: 0;
    padding: 32px 28px;
    border-right: none;
  }
  .login-form-wrap { max-width: 100%; padding: 32px 0; }
}

/* Very small: ≤ 380px */
@media (max-width: 380px) {
  .login-left { padding: 24px 20px; }
  .login-title { font-size: 1.375rem; }
  #messages-inner { padding: 12px 8px 8px; }
}

/* Wide screens: ≥ 1440px */
@media (min-width: 1440px) {
  :root { --sidebar-w: 280px; }
  #messages-inner { max-width: 800px; padding: 28px 24px 8px; }
  .input-wrap { max-width: 800px; }
  .input-hint  { max-width: 800px; }
}
