*{box-sizing:border-box}

:root{
  --bg:#050b1d;
  --text:#f5f7ff;
  --muted:#8e9dbd;
  --line:rgba(112,154,255,.32);
}

html,body{
  margin:0;
  width:100%;
  height:100%;
  overflow:hidden;
  background:var(--bg);
  color:var(--text);
  font-family:-apple-system,BlinkMacSystemFont,"SF Pro Display","Segoe UI",sans-serif;
  -webkit-text-size-adjust:100%;
  text-size-adjust:100%;
}

body{
  padding-top:env(safe-area-inset-top);
  padding-bottom:env(safe-area-inset-bottom);
  background:
    radial-gradient(circle at 50% 25%,rgba(55,91,255,.20),transparent 38%),
    radial-gradient(circle at 15% 80%,rgba(123,58,255,.11),transparent 35%),
    linear-gradient(145deg,#030817 0%,#071332 52%,#05091a 100%);
}

.chat-page{
  position:relative;
  width:min(100%,620px);
  height:100dvh;
  margin:auto;
  padding:12px 18px 12px;
  display:flex;
  flex-direction:column;
}

.chat-top{
  flex:0 0 auto;
  min-height:62px;
  display:flex;
  align-items:center;
  gap:11px;
}

.back-button{
  width:42px;
  height:42px;
  flex:0 0 42px;
  display:grid;
  place-items:center;
  border:1px solid var(--line);
  border-radius:50%;
  background:rgba(12,27,61,.78);
  color:#c9d9ff;
  text-decoration:none;
  font-size:32px;
  line-height:1;
}

.chat-brand{
  flex:1;
  min-width:0;
}

.chat-title{
  font-size:18px;
  font-weight:600;
  letter-spacing:-.2px;
}

.chat-subtitle{
  margin-top:3px;
  color:var(--muted);
  font-size:12px;
}

.status{
  white-space:nowrap;
  padding:7px 11px;
  border-radius:18px;
  background:rgba(40,66,119,.45);
  color:#dbe5ff;
  font-size:12px;
}

.status i{
  display:inline-block;
  width:7px;
  height:7px;
  margin-right:5px;
  border-radius:50%;
  background:#35d995;
  box-shadow:0 0 8px #35d995;
}

.chat-messages{
  flex:1 1 auto;
  min-height:0;
  overflow-y:auto;
  overflow-x:hidden;
  padding:18px 2px 16px;
  display:flex;
  flex-direction:column;
  gap:12px;
  -webkit-overflow-scrolling:touch;
  overscroll-behavior:contain;
  scrollbar-width:thin;
}

.ai-message,.user-message{
  max-width:84%;
  padding:13px 15px;
  font-size:16px;
  line-height:1.5;
  overflow-wrap:anywhere;
  word-break:break-word;
}

.ai-message{
  align-self:flex-start;
  margin-right:auto;
  border:1px solid rgba(82,125,220,.35);
  border-radius:18px 18px 18px 5px;
  background:rgba(19,37,78,.72);
  color:#d9e1f4;
}

.user-message{
  align-self:flex-end;
  margin-left:auto;
  border:1px solid rgba(88,132,236,.35);
  border-radius:18px 18px 5px 18px;
  background:rgba(65,105,205,.38);
  color:#fff;
}

.thinking{
  opacity:.72;
}

.chat-form{
  flex:0 0 auto;
  display:flex;
  align-items:center;
  gap:9px;
  min-height:58px;
  margin:0 0 11px;
  padding:6px 7px 6px 17px;
  border:1px solid rgba(91,131,219,.38);
  border-radius:31px;
  background:rgba(4,13,34,.78);
  box-shadow:0 10px 35px rgba(0,0,0,.20);
}

.chat-form input{
  width:100%;
  min-width:0;
  border:0;
  outline:0;
  background:transparent;
  color:white;
  font-family:inherit;
  font-size:16px!important;
  line-height:1.4;
  padding:10px 0;
  -webkit-appearance:none;
  appearance:none;
}

.chat-form input::placeholder{
  color:#647291;
  opacity:1;
}

.chat-form button{
  width:46px;
  height:46px;
  flex:0 0 46px;
  border:0;
  border-radius:50%;
  background:linear-gradient(145deg,#6570ff,#5545dd);
  color:white;
  font-size:27px;
  cursor:pointer;
}

.chat-form button:disabled{
  opacity:.55;
}

.back-to-scan{
  flex:0 0 auto;
  width:100%;
  min-height:48px;
  display:grid;
  place-items:center;
  border:1px solid rgba(112,154,255,.30);
  border-radius:24px;
  background:rgba(10,23,52,.78);
  color:#b9c9e8;
  text-decoration:none;
  font-size:13px;
  letter-spacing:1px;
}

input,textarea,select,button{
  -webkit-tap-highlight-color:transparent;
}

@media(max-width:430px){
  .chat-page{padding-left:12px;padding-right:12px}
  .chat-title{font-size:16px}
  .status{font-size:11px;padding:7px 9px}
  .ai-message,.user-message{max-width:89%;font-size:15px}
}
