* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: -apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,sans-serif
}
body {
    background: #e7ebf0;
    height: 100vh;
    height: 100dvh;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow:hidden;
}
.tg-wrap {
    width: 100%;
    max-width: 420px;
    height: 90vh;
    height: 90dvh;
    background: #fff;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 10px 30px rgba(0,0,0,.15);
    display: flex;
    flex-direction: column;
}
.tg-header {
    background: #2b5278;
    color: #fff;
    padding: 12px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
    position:relative;
    z-index:2;
}
.tg-header h3 { font-weight: 500; font-size: 18px }

.tg-body{ flex:1; overflow:hidden; display:flex; flex-direction:column; min-height:0 }
.tg-logo{ width:60px; height:60px; background:#2b5278; border-radius:50%; display:flex; align-items:center; justify-content:center; margin:0 auto 20px; font-size:30px; color:#fff }
.tg-input{ width:100%; padding:12px 14px; border:1px solid #dfe1e5; border-radius:22px; outline:none; margin-top:12px; font-size:15px }
.tg-input:focus{ border-color:#2b5278 }
.tg-btn{ width:100%; background:#2b5278; color:#fff; border:none; padding:12px; border-radius:22px; margin-top:18px; font-size:15px; cursor:pointer; font-weight:500 }
.tg-btn:hover{ background:#1e3f5e }
.tg-user{ display:flex; gap:12px; padding:12px 20px; border-bottom:1px solid #f0f0f0; cursor:pointer; text-decoration:none; color:#000 }
.tg-user:hover{ background:#f5f7f8 }
.tg-avatar{ width:46px; height:46px; min-width:46px; min-height:46px; border-radius:50%; object-fit:cover; display:block; background:#e7ebf0; }
.tg-avatar-small{ width:36px !important; height:36px !important; min-width:36px; min-height:36px; border-radius:50%; object-fit:cover; display:block; background:#fff; }
.tg-header .tg-avatar-small{ border:2px solid rgba(255,255,255,.5); }

.bubble{ max-width:75%; padding:8px 12px; border-radius:18px; font-size:14px; line-height:1.4; word-break:break-word; position:relative; z-index:1 }
.bubble.me{ align-self:flex-end; background:#00a65a;color:white;  border-radius:18px 18px 4px 18px }
.bubble.you{ align-self:flex-start; background:#2b5278; color:white;border-radius:18px 18px 18px 4px; box-shadow:0 1px 1px rgba(0,0,0,.1) }

.msg-row{display:flex;gap:8px;align-items:flex-end;margin-bottom:6px;max-width:85%;position:relative;z-index:1}
.msg-row.you{align-self:flex-start}
.msg-row.me{align-self:flex-end;flex-direction:row-reverse}
.msg-row .chat-avatar{width:32px;height:32px;min-width:32px;min-height:32px;border-radius:50%;object-fit:cover;display:block;background:#fff}
.msg-row{
  max-width: 90% !important;
}
.bubble{
  max-width: 90% !important;
  width: fit-content;
}
.loading-small{ text-align:center; padding:12px; font-size:13px; color:#888; display:flex; align-items:center; justify-content:center; gap:8px; position:relative; z-index:1 }
.loading-small span{ width:16px; height:16px; border:2px solid #2b5278; border-top-color:transparent; border-radius:50%; display:inline-block; animation:spin .6s linear infinite; }
@keyframes spin{ to{ transform:rotate(360deg) } }

/* CHAT BACKGROUND + SHADOW HITAM FIT */
.tg-chat{
  flex:1; 
  overflow-y:auto; 
  padding:12px; 
  display:flex; 
  flex-direction:column; 
  gap:6px;
  min-height:0;
  position:relative;
  z-index:0;
  background-color: rgba(244, 241, 236, 1);
 background-image: 
    linear-gradient(rgba(244, 241, 236, 0.85), rgba(244, 241, 236, 0.85)),
    url('assets/images/patern.jpeg');
  background-repeat: repeat;
  background-size: 380px 380px;
  background-attachment: fixed;
   box-shadow: inset 0 0 120px rgba(226, 214, 194, 0.6);
}

/* ==== FIX GAP DI HP ==== */
@media (max-width: 480px){
  body{
    align-items: flex-start;
    background:#2b5278;
    height:100dvh;
  }
  .tg-wrap{
    max-width:100%;
    width:100%;
    height:100dvh;
    height:100vh;
    border-radius:0;
    box-shadow:none;
  }
  .tg-header{
    padding-top: max(12px, env(safe-area-inset-top));
    border-radius:0;
  }
}

/* FOOTER FIX CHROME ANDROID */
.tg-footer{
  padding: 8px 10px;
  padding-bottom: max(8px, env(safe-area-inset-bottom));
  background: #fff;
  display: flex;
  gap: 6px;
  align-items: center;
  border-top: 1px solid #e7ebf0;
  flex-shrink: 0;
  position: sticky;
  bottom: 0;
  z-index: 10;
  min-height: 58px;
}
.tg-footer form{
  display:flex;
  gap:6px;
  width:100%;
  align-items:center;
}
.tg-footer .tg-input{
  margin:0 !important;
  height:42px;
  background:#f0f2f5;
  border:none;
  border-radius:20px;
  padding:0 14px;
}
.tg-footer .tg-btn{
  margin:0 !important;
  width:42px !important;
  height:42px !important;
  min-width:42px;
  border-radius:50%;
  display:flex;
  align-items:center;
  justify-content:center;
  padding:0;
}

/* FIX WRAP BIAR FOOTER TIDAK KETUTUP KEYBOARD CHROME */
@media (max-width: 480px){
  html, body{
    height:100%;
    overflow:hidden;
  }
  .tg-wrap{
    height:100dvh;
    height:-webkit-fill-available;
  }
  .tg-chat{
    padding-bottom: 10px;
  }
}