:root {
  --bg: #ffffff;
  --panel: #f7f7f8;
  --soft: #f1f1f2;
  --text: #171717;
  --muted: #737373;
  --line: #e5e5e5;
  --blue: #2563eb;
  --blue-soft: #eff6ff;
  --sidebar: 252px;
}

.auth-gate { position: fixed; z-index: 20; inset: 0; display: grid; place-items: center; padding: 20px; background: rgba(255,255,255,.98); }
.auth-gate[hidden] { display: none; }
.auth-card { width: min(390px, 100%); padding: 30px 24px; border: 1px solid var(--line); border-radius: 16px; background: var(--bg); box-shadow: 0 12px 40px rgba(0,0,0,.08); text-align: center; }
.auth-card h1 { font-size: 25px; }
.auth-card p { color: var(--muted); font-size: 14px; line-height: 1.5; }
.auth-card form { display: grid; gap: 9px; margin-top: 24px; text-align: left; }
.auth-card label { color: #555; font-size: 13px; font-weight: 600; }
.auth-card input { width: 100%; height: 45px; padding: 0 12px; border: 1px solid #d4d4d4; border-radius: 9px; outline: 0; font-size: 16px; }
.auth-card input:focus { border-color: var(--blue); box-shadow: 0 0 0 3px var(--blue-soft); }
.primary-button { min-height: 45px; margin-top: 7px; border: 0; border-radius: 9px; background: var(--text); color: #fff; cursor: pointer; font-weight: 650; }
.primary-button:hover { background: #3f3f46; }
.text-button { border: 0; background: transparent; color: var(--blue); cursor: pointer; font-size: 13px; }
.auth-error { min-height: 20px; margin-bottom: 0; color: #b91c1c !important; font-size: 13px !important; }

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body { color: var(--text); background: var(--bg); font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; }
button, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
a { color: inherit; text-decoration: none; }

.app-shell { min-height: 100dvh; display: flex; background: var(--bg); }
.sidebar { width: var(--sidebar); flex: 0 0 var(--sidebar); display: flex; flex-direction: column; padding: 18px 12px 14px; border-right: 1px solid var(--line); background: #fafafa; }
.sidebar-head { display: flex; align-items: center; justify-content: space-between; padding: 0 10px 20px; }
.brand { font-size: 19px; font-weight: 800; letter-spacing: -.05em; }
.icon-button { border: 0; background: transparent; color: var(--muted); cursor: pointer; font-size: 22px; line-height: 1; min-width: 40px; min-height: 40px; border-radius: 9px; }
.icon-button:hover { background: var(--soft); color: var(--text); }
.close-sidebar, .menu-button { display: none; }
.new-chat { width: 100%; display: flex; align-items: center; gap: 9px; padding: 11px 13px; border: 1px solid var(--line); border-radius: 9px; background: var(--bg); color: var(--text); cursor: pointer; font-size: 14px; text-align: left; }
.new-chat:hover { border-color: #c7c7c7; background: var(--panel); }
.primary-nav { display: grid; gap: 3px; margin-top: 20px; }
.nav-item { display: flex; align-items: center; gap: 11px; padding: 10px 12px; border-radius: 8px; color: #575757; font-size: 14px; }
.nav-item span { width: 18px; text-align: center; color: #707070; }
.nav-item:hover, .nav-item.active { background: #ececef; color: var(--text); }
.recent-label { margin: 29px 12px 8px; color: #888; font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; }
.recent-list { display: grid; gap: 2px; }
.recent-list a,
.recent-list button {
  display: block;
  width: 100%;
  border: 0;
  background: transparent;
  color: inherit;
  text-align: left;
  font: inherit;
  cursor: pointer; overflow: hidden; padding: 9px 12px; border-radius: 8px; color: #5d5d5d; font-size: 13px; text-overflow: ellipsis; white-space: nowrap; }
.recent-list a:hover { background: var(--soft); color: var(--text); }
.sidebar-footer { display: flex; align-items: center; gap: 8px; margin-top: auto; padding: 12px; color: var(--muted); font-size: 12px; }
.status-dot { width: 7px; height: 7px; display: inline-block; border-radius: 50%; background: #22c55e; }

.chat-panel { min-width: 0; flex: 1; min-height: 100dvh; display: flex; flex-direction: column; }
.topbar { height: 64px; display: flex; align-items: center; justify-content: space-between; padding: 0 24px; border-bottom: 1px solid var(--line); }
.agent-picker { display: flex; align-items: center; gap: 13px; font-size: 14px; }
.agent-picker strong { font-weight: 650; }
.online-state { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 12px; font-weight: 400; }
.conversation { width: min(760px, calc(100% - 32px)); flex: 1; margin: 0 auto; padding: 15vh 0 32px; }
.messages { display: grid; gap: 16px; }
.message-bubble { max-width: 88%; padding: 11px 14px; border-radius: 13px; font-size: 14px; line-height: 1.5; white-space: pre-wrap; }
.message-bubble.user { justify-self: end; background: var(--text); color: #fff; }
.message-bubble.assistant { justify-self: start; border: 1px solid var(--line); background: var(--panel); }
.progress-indicator { display: inline-flex; align-items: center; gap: 8px; margin: 15px 0 4px; color: var(--muted); font-size: 13px; }
.progress-indicator::before { width: 7px; height: 7px; content: ""; border-radius: 50%; background: var(--blue); box-shadow: 0 0 0 4px var(--blue-soft); }
.welcome-block { text-align: center; }
.agent-mark { width: 42px; height: 42px; display: grid; place-items: center; margin: 0 auto 22px; border-radius: 13px; background: var(--text); color: white; font-size: 18px; font-weight: 800; }
h1 { margin: 0; font-size: clamp(25px, 4vw, 34px); letter-spacing: -.045em; line-height: 1.1; }
.welcome-block p { margin: 13px 0 0; color: var(--muted); font-size: 14px; }
.suggestions { display: grid; grid-template-columns: repeat(3, 1fr); gap: 9px; margin-top: 42px; }
.suggestions button { min-height: 72px; padding: 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); color: #404040; cursor: pointer; font-size: 13px; text-align: left; }
.suggestions button:hover { border-color: #a7c3f9; background: var(--blue-soft); color: #1d4ed8; }
.composer { width: min(760px, calc(100% - 32px)); margin: 0 auto; padding: 12px 13px 10px; border: 1px solid #d4d4d4; border-radius: 14px; background: var(--bg); box-shadow: 0 2px 10px rgba(0,0,0,.04); }
textarea { width: 100%; display: block; min-height: 26px; max-height: 180px; padding: 3px 2px 8px; border: 0; outline: 0; resize: none; color: var(--text); background: transparent; font-size: 15px; line-height: 1.5; }
textarea::placeholder { color: #9a9a9a; }
.composer-actions { display: flex; align-items: center; gap: 8px; }
.attach-button, .send-button { width: 32px; height: 32px; display: grid; place-items: center; border: 0; border-radius: 9px; cursor: pointer; }
.attach-button { background: transparent; color: var(--muted); font-size: 22px; }
.attach-button:hover { background: var(--soft); color: var(--text); }
.send-button { margin-left: auto; background: var(--text); color: white; font-size: 18px; }
.send-button:hover { background: #3f3f46; }
.composer-hint { color: #a0a0a0; font-size: 11px; }
.privacy-note { width: min(760px, calc(100% - 32px)); margin: 9px auto 15px; color: #a0a0a0; font-size: 11px; text-align: center; }

@media (max-width: 700px) {
  .sidebar { position: fixed; z-index: 10; inset: 0 auto 0 0; width: min(292px, 86vw); transform: translateX(-105%); transition: transform .2s ease; box-shadow: 12px 0 30px rgba(0,0,0,.12); }
  .sidebar.open { transform: translateX(0); }
  .close-sidebar, .menu-button { display: inline-grid; place-items: center; }
  .topbar { height: 58px; padding: 0 9px; }
  .topbar .icon-button:last-child { font-size: 24px; }
  .agent-picker { flex-direction: column; align-items: center; gap: 1px; }
  .conversation { width: calc(100% - 28px); padding-top: 17vh; }
  .suggestions { grid-template-columns: 1fr; gap: 7px; margin-top: 31px; }
  .suggestions button { min-height: 48px; }
  .composer { width: calc(100% - 20px); padding: 11px 11px 9px; border-radius: 13px; }
  .composer-hint { display: none; }
  .privacy-note { width: calc(100% - 24px); margin-bottom: 10px; line-height: 1.4; }
}
